diff --git a/booger b/booger new file mode 100644 index 00000000000..1293cf30e0a --- /dev/null +++ b/booger @@ -0,0 +1,481169 @@ +diff --git a/dist/README.md b/dist/README.md +index 92bffb4..278692d 100644 +--- a/dist/README.md ++++ b/dist/README.md +@@ -49,7 +49,7 @@ The main plotly.js bundle weights in at: + + | plotly.js | plotly.min.js | plotly.min.js + gzip | plotly-with-meta.js | + |-----------|---------------|----------------------|---------------------| +-| 3.8 MB | 1.6 MB | 488.7 kB | 3.9 MB | ++| 3.8 MB | 1.6 MB | 491.9 kB | 4 MB | + + ## Partial bundles + +@@ -64,7 +64,7 @@ Starting in `v1.15.0`, plotly.js also ships with several _partial_ bundles: + + ### plotly.js basic + +-The `basic` partial bundle contains the `scatter`, `bar`and `pie` trace modules. ++The `basic` partial bundle contains the `scatter`, `bar` and `pie` trace modules. + + | Way to import | Location | + |---------------|----------| +@@ -78,11 +78,11 @@ The `basic` partial bundle contains the `scatter`, `bar`and `pie` trace modules. + + | Raw size | Minified size | Minified + gzip size | + |------|-----------------|------------------------| +-| 1.4 MB | 548.4 kB | 180.3 kB | ++| 1.4 MB | 549.9 kB | 180.6 kB | + + ### plotly.js cartesian + +-The `cartesian` partial bundle contains the `scatter`, `bar`, `box`, `heatmap`, `histogram`, `histogram2d`, `histogram2dcontour`, `pie`, `contour`and `scatterternary` trace modules. ++The `cartesian` partial bundle contains the `scatter`, `bar`, `box`, `heatmap`, `histogram`, `histogram2d`, `histogram2dcontour`, `pie`, `contour` and `scatterternary` trace modules. + + | Way to import | Location | + |---------------|----------| +@@ -96,11 +96,11 @@ The `cartesian` partial bundle contains the `scatter`, `bar`, `box`, `heatmap`, + + | Raw size | Minified size | Minified + gzip size | + |------|-----------------|------------------------| +-| 1.6 MB | 617.5 kB | 201.1 kB | ++| 1.6 MB | 619.1 kB | 201.3 kB | + + ### plotly.js geo + +-The `geo` partial bundle contains the `scatter`, `scattergeo`and `choropleth` trace modules. ++The `geo` partial bundle contains the `scatter`, `scattergeo` and `choropleth` trace modules. + + | Way to import | Location | + |---------------|----------| +@@ -114,11 +114,11 @@ The `geo` partial bundle contains the `scatter`, `scattergeo`and `choropleth` tr + + | Raw size | Minified size | Minified + gzip size | + |------|-----------------|------------------------| +-| 1.4 MB | 577.8 kB | 191.3 kB | ++| 1.5 MB | 579.5 kB | 191.5 kB | + + ### plotly.js gl3d + +-The `gl3d` partial bundle contains the `scatter`, `scatter3d`, `surface`and `mesh3d` trace modules. ++The `gl3d` partial bundle contains the `scatter`, `scatter3d`, `surface` and `mesh3d` trace modules. + + | Way to import | Location | + |---------------|----------| +@@ -132,11 +132,11 @@ The `gl3d` partial bundle contains the `scatter`, `scatter3d`, `surface`and `mes + + | Raw size | Minified size | Minified + gzip size | + |------|-----------------|------------------------| +-| 2.3 MB | 984.4 kB | 310.4 kB | ++| 2.3 MB | 995.2 kB | 312.8 kB | + + ### plotly.js gl2d + +-The `gl2d` partial bundle contains the `scatter`, `scattergl`, `heatmapgl`and `contourgl` trace modules. ++The `gl2d` partial bundle contains the `scatter`, `scattergl`, `heatmapgl` and `contourgl` trace modules. + + | Way to import | Location | + |---------------|----------| +@@ -150,11 +150,11 @@ The `gl2d` partial bundle contains the `scatter`, `scattergl`, `heatmapgl`and `c + + | Raw size | Minified size | Minified + gzip size | + |------|-----------------|------------------------| +-| 2 MB | 854 kB | 270.8 kB | ++| 2 MB | 859.2 kB | 271.4 kB | + + ### plotly.js mapbox + +-The `mapbox` partial bundle contains the `scatter`and `scattermapbox` trace modules. ++The `mapbox` partial bundle contains the `scatter` and `scattermapbox` trace modules. + + | Way to import | Location | + |---------------|----------| +@@ -168,7 +168,7 @@ The `mapbox` partial bundle contains the `scatter`and `scattermapbox` trace modu + + | Raw size | Minified size | Minified + gzip size | + |------|-----------------|------------------------| +-| 2.3 MB | 957.2 kB | 284.9 kB | ++| 2.4 MB | 973.9 kB | 286.5 kB | + + ---------------- + +diff --git a/dist/plotly-basic.js b/dist/plotly-basic.js +index 828afed..9672cdc 100644 +--- a/dist/plotly-basic.js ++++ b/dist/plotly-basic.js +@@ -242,402 +242,9 @@ module.exports = Plotly; + module.exports = require('../src/traces/pie'); + + },{"../src/traces/pie":165}],7:[function(require,module,exports){ +-// Copyright Joyent, Inc. and other Node contributors. +-// +-// Permission is hereby granted, free of charge, to any person obtaining a +-// copy of this software and associated documentation files (the +-// "Software"), to deal in the Software without restriction, including +-// without limitation the rights to use, copy, modify, merge, publish, +-// distribute, sublicense, and/or sell copies of the Software, and to permit +-// persons to whom the Software is furnished to do so, subject to the +-// following conditions: +-// +-// The above copyright notice and this permission notice shall be included +-// in all copies or substantial portions of the Software. +-// +-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +-// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +-// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +-// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +-// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +-// USE OR OTHER DEALINGS IN THE SOFTWARE. +- +-function EventEmitter() { +- this._events = this._events || {}; +- this._maxListeners = this._maxListeners || undefined; +-} +-module.exports = EventEmitter; +- +-// Backwards-compat with node 0.10.x +-EventEmitter.EventEmitter = EventEmitter; +- +-EventEmitter.prototype._events = undefined; +-EventEmitter.prototype._maxListeners = undefined; +- +-// By default EventEmitters will print a warning if more than 10 listeners are +-// added to it. This is a useful default which helps finding memory leaks. +-EventEmitter.defaultMaxListeners = 10; +- +-// Obviously not all Emitters should be limited to 10. This function allows +-// that to be increased. Set to zero for unlimited. +-EventEmitter.prototype.setMaxListeners = function(n) { +- if (!isNumber(n) || n < 0 || isNaN(n)) +- throw TypeError('n must be a positive number'); +- this._maxListeners = n; +- return this; +-}; +- +-EventEmitter.prototype.emit = function(type) { +- var er, handler, len, args, i, listeners; +- +- if (!this._events) +- this._events = {}; +- +- // If there is no 'error' event listener then throw. +- if (type === 'error') { +- if (!this._events.error || +- (isObject(this._events.error) && !this._events.error.length)) { +- er = arguments[1]; +- if (er instanceof Error) { +- throw er; // Unhandled 'error' event +- } +- throw TypeError('Uncaught, unspecified "error" event.'); +- } +- } +- +- handler = this._events[type]; +- +- if (isUndefined(handler)) +- return false; +- +- if (isFunction(handler)) { +- switch (arguments.length) { +- // fast cases +- case 1: +- handler.call(this); +- break; +- case 2: +- handler.call(this, arguments[1]); +- break; +- case 3: +- handler.call(this, arguments[1], arguments[2]); +- break; +- // slower +- default: +- args = Array.prototype.slice.call(arguments, 1); +- handler.apply(this, args); +- } +- } else if (isObject(handler)) { +- args = Array.prototype.slice.call(arguments, 1); +- listeners = handler.slice(); +- len = listeners.length; +- for (i = 0; i < len; i++) +- listeners[i].apply(this, args); +- } +- +- return true; +-}; +- +-EventEmitter.prototype.addListener = function(type, listener) { +- var m; +- +- if (!isFunction(listener)) +- throw TypeError('listener must be a function'); +- +- if (!this._events) +- this._events = {}; +- +- // To avoid recursion in the case that type === "newListener"! Before +- // adding it to the listeners, first emit "newListener". +- if (this._events.newListener) +- this.emit('newListener', type, +- isFunction(listener.listener) ? +- listener.listener : listener); +- +- if (!this._events[type]) +- // Optimize the case of one listener. Don't need the extra array object. +- this._events[type] = listener; +- else if (isObject(this._events[type])) +- // If we've already got an array, just append. +- this._events[type].push(listener); +- else +- // Adding the second element, need to change to array. +- this._events[type] = [this._events[type], listener]; +- +- // Check for listener leak +- if (isObject(this._events[type]) && !this._events[type].warned) { +- if (!isUndefined(this._maxListeners)) { +- m = this._maxListeners; +- } else { +- m = EventEmitter.defaultMaxListeners; +- } +- +- if (m && m > 0 && this._events[type].length > m) { +- this._events[type].warned = true; +- console.error('(node) warning: possible EventEmitter memory ' + +- 'leak detected. %d listeners added. ' + +- 'Use emitter.setMaxListeners() to increase limit.', +- this._events[type].length); +- if (typeof console.trace === 'function') { +- // not supported in IE 10 +- console.trace(); +- } +- } +- } +- +- return this; +-}; +- +-EventEmitter.prototype.on = EventEmitter.prototype.addListener; +- +-EventEmitter.prototype.once = function(type, listener) { +- if (!isFunction(listener)) +- throw TypeError('listener must be a function'); +- +- var fired = false; +- +- function g() { +- this.removeListener(type, g); +- +- if (!fired) { +- fired = true; +- listener.apply(this, arguments); +- } +- } +- +- g.listener = listener; +- this.on(type, g); +- +- return this; +-}; +- +-// emits a 'removeListener' event iff the listener was removed +-EventEmitter.prototype.removeListener = function(type, listener) { +- var list, position, length, i; +- +- if (!isFunction(listener)) +- throw TypeError('listener must be a function'); +- +- if (!this._events || !this._events[type]) +- return this; +- +- list = this._events[type]; +- length = list.length; +- position = -1; +- +- if (list === listener || +- (isFunction(list.listener) && list.listener === listener)) { +- delete this._events[type]; +- if (this._events.removeListener) +- this.emit('removeListener', type, listener); +- +- } else if (isObject(list)) { +- for (i = length; i-- > 0;) { +- if (list[i] === listener || +- (list[i].listener && list[i].listener === listener)) { +- position = i; +- break; +- } +- } +- +- if (position < 0) +- return this; +- +- if (list.length === 1) { +- list.length = 0; +- delete this._events[type]; +- } else { +- list.splice(position, 1); +- } +- +- if (this._events.removeListener) +- this.emit('removeListener', type, listener); +- } +- +- return this; +-}; +- +-EventEmitter.prototype.removeAllListeners = function(type) { +- var key, listeners; +- +- if (!this._events) +- return this; +- +- // not listening for removeListener, no need to emit +- if (!this._events.removeListener) { +- if (arguments.length === 0) +- this._events = {}; +- else if (this._events[type]) +- delete this._events[type]; +- return this; +- } +- +- // emit removeListener for all listeners on all events +- if (arguments.length === 0) { +- for (key in this._events) { +- if (key === 'removeListener') continue; +- this.removeAllListeners(key); +- } +- this.removeAllListeners('removeListener'); +- this._events = {}; +- return this; +- } +- +- listeners = this._events[type]; +- +- if (isFunction(listeners)) { +- this.removeListener(type, listeners); +- } else if (listeners) { +- // LIFO order +- while (listeners.length) +- this.removeListener(type, listeners[listeners.length - 1]); +- } +- delete this._events[type]; +- +- return this; +-}; +- +-EventEmitter.prototype.listeners = function(type) { +- var ret; +- if (!this._events || !this._events[type]) +- ret = []; +- else if (isFunction(this._events[type])) +- ret = [this._events[type]]; +- else +- ret = this._events[type].slice(); +- return ret; +-}; +- +-EventEmitter.prototype.listenerCount = function(type) { +- if (this._events) { +- var evlistener = this._events[type]; +- +- if (isFunction(evlistener)) +- return 1; +- else if (evlistener) +- return evlistener.length; +- } +- return 0; +-}; +- +-EventEmitter.listenerCount = function(emitter, type) { +- return emitter.listenerCount(type); +-}; +- +-function isFunction(arg) { +- return typeof arg === 'function'; +-} +- +-function isNumber(arg) { +- return typeof arg === 'number'; +-} +- +-function isObject(arg) { +- return typeof arg === 'object' && arg !== null; +-} +- +-function isUndefined(arg) { +- return arg === void 0; +-} +- +-},{}],8:[function(require,module,exports){ +-// shim for using process in browser +- +-var process = module.exports = {}; +-var queue = []; +-var draining = false; +-var currentQueue; +-var queueIndex = -1; +- +-function cleanUpNextTick() { +- draining = false; +- if (currentQueue.length) { +- queue = currentQueue.concat(queue); +- } else { +- queueIndex = -1; +- } +- if (queue.length) { +- drainQueue(); +- } +-} +- +-function drainQueue() { +- if (draining) { +- return; +- } +- var timeout = setTimeout(cleanUpNextTick); +- draining = true; +- +- var len = queue.length; +- while(len) { +- currentQueue = queue; +- queue = []; +- while (++queueIndex < len) { +- if (currentQueue) { +- currentQueue[queueIndex].run(); +- } +- } +- queueIndex = -1; +- len = queue.length; +- } +- currentQueue = null; +- draining = false; +- clearTimeout(timeout); +-} +- +-process.nextTick = function (fun) { +- var args = new Array(arguments.length - 1); +- if (arguments.length > 1) { +- for (var i = 1; i < arguments.length; i++) { +- args[i - 1] = arguments[i]; +- } +- } +- queue.push(new Item(fun, args)); +- if (queue.length === 1 && !draining) { +- setTimeout(drainQueue, 0); +- } +-}; +- +-// v8 likes predictible objects +-function Item(fun, array) { +- this.fun = fun; +- this.array = array; +-} +-Item.prototype.run = function () { +- this.fun.apply(null, this.array); +-}; +-process.title = 'browser'; +-process.browser = true; +-process.env = {}; +-process.argv = []; +-process.version = ''; // empty string to avoid regexp issues +-process.versions = {}; +- +-function noop() {} +- +-process.on = noop; +-process.addListener = noop; +-process.once = noop; +-process.off = noop; +-process.removeListener = noop; +-process.removeAllListeners = noop; +-process.emit = noop; +- +-process.binding = function (name) { +- throw new Error('process.binding is not supported'); +-}; +- +-process.cwd = function () { return '/' }; +-process.chdir = function (dir) { +- throw new Error('process.chdir is not supported'); +-}; +-process.umask = function() { return 0; }; +- +-},{}],9:[function(require,module,exports){ + !function() { + var d3 = { +- version: "3.5.16" ++ version: "3.5.17" + }; + var d3_arraySlice = [].slice, d3_array = function(list) { + return d3_arraySlice.call(list); +@@ -4162,7 +3769,7 @@ process.umask = function() { return 0; }; + λ0 = λ, sinφ0 = sinφ, cosφ0 = cosφ, point0 = point; + } + } +- return (polarAngle < -ε || polarAngle < ε && d3_geo_areaRingSum < 0) ^ winding & 1; ++ return (polarAngle < -ε || polarAngle < ε && d3_geo_areaRingSum < -ε) ^ winding & 1; + } + function d3_geo_clipCircle(radius) { + var cr = Math.cos(radius), smallRadius = cr > 0, notHemisphere = abs(cr) > ε, interpolate = d3_geo_circleInterpolate(radius, 6 * d3_radians); +@@ -10189,965 +9796,1468 @@ process.umask = function() { return 0; }; + }); + if (typeof define === "function" && define.amd) this.d3 = d3, define(d3); else if (typeof module === "object" && module.exports) module.exports = d3; else this.d3 = d3; + }(); +-},{}],10:[function(require,module,exports){ ++},{}],8:[function(require,module,exports){ + (function (process,global){ + /*! + * @overview es6-promise - a tiny implementation of Promises/A+. + * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald) + * @license Licensed under MIT license +- * See https://raw.githubusercontent.com/jakearchibald/es6-promise/master/LICENSE +- * @version 3.1.2 ++ * See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE ++ * @version 3.3.1 + */ + +-(function() { +- "use strict"; +- function lib$es6$promise$utils$$objectOrFunction(x) { +- return typeof x === 'function' || (typeof x === 'object' && x !== null); +- } ++(function (global, factory) { ++ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : ++ typeof define === 'function' && define.amd ? define(factory) : ++ (global.ES6Promise = factory()); ++}(this, (function () { 'use strict'; + +- function lib$es6$promise$utils$$isFunction(x) { +- return typeof x === 'function'; +- } ++function objectOrFunction(x) { ++ return typeof x === 'function' || typeof x === 'object' && x !== null; ++} + +- function lib$es6$promise$utils$$isMaybeThenable(x) { +- return typeof x === 'object' && x !== null; +- } ++function isFunction(x) { ++ return typeof x === 'function'; ++} + +- var lib$es6$promise$utils$$_isArray; +- if (!Array.isArray) { +- lib$es6$promise$utils$$_isArray = function (x) { +- return Object.prototype.toString.call(x) === '[object Array]'; +- }; ++var _isArray = undefined; ++if (!Array.isArray) { ++ _isArray = function (x) { ++ return Object.prototype.toString.call(x) === '[object Array]'; ++ }; ++} else { ++ _isArray = Array.isArray; ++} ++ ++var isArray = _isArray; ++ ++var len = 0; ++var vertxNext = undefined; ++var customSchedulerFn = undefined; ++ ++var asap = function asap(callback, arg) { ++ queue[len] = callback; ++ queue[len + 1] = arg; ++ len += 2; ++ if (len === 2) { ++ // If len is 2, that means that we need to schedule an async flush. ++ // If additional callbacks are queued before the queue is flushed, they ++ // will be processed by this flush that we are scheduling. ++ if (customSchedulerFn) { ++ customSchedulerFn(flush); + } else { +- lib$es6$promise$utils$$_isArray = Array.isArray; +- } +- +- var lib$es6$promise$utils$$isArray = lib$es6$promise$utils$$_isArray; +- var lib$es6$promise$asap$$len = 0; +- var lib$es6$promise$asap$$vertxNext; +- var lib$es6$promise$asap$$customSchedulerFn; +- +- var lib$es6$promise$asap$$asap = function asap(callback, arg) { +- lib$es6$promise$asap$$queue[lib$es6$promise$asap$$len] = callback; +- lib$es6$promise$asap$$queue[lib$es6$promise$asap$$len + 1] = arg; +- lib$es6$promise$asap$$len += 2; +- if (lib$es6$promise$asap$$len === 2) { +- // If len is 2, that means that we need to schedule an async flush. +- // If additional callbacks are queued before the queue is flushed, they +- // will be processed by this flush that we are scheduling. +- if (lib$es6$promise$asap$$customSchedulerFn) { +- lib$es6$promise$asap$$customSchedulerFn(lib$es6$promise$asap$$flush); +- } else { +- lib$es6$promise$asap$$scheduleFlush(); +- } +- } ++ scheduleFlush(); + } ++ } ++}; + +- function lib$es6$promise$asap$$setScheduler(scheduleFn) { +- lib$es6$promise$asap$$customSchedulerFn = scheduleFn; +- } ++function setScheduler(scheduleFn) { ++ customSchedulerFn = scheduleFn; ++} + +- function lib$es6$promise$asap$$setAsap(asapFn) { +- lib$es6$promise$asap$$asap = asapFn; +- } ++function setAsap(asapFn) { ++ asap = asapFn; ++} + +- var lib$es6$promise$asap$$browserWindow = (typeof window !== 'undefined') ? window : undefined; +- var lib$es6$promise$asap$$browserGlobal = lib$es6$promise$asap$$browserWindow || {}; +- var lib$es6$promise$asap$$BrowserMutationObserver = lib$es6$promise$asap$$browserGlobal.MutationObserver || lib$es6$promise$asap$$browserGlobal.WebKitMutationObserver; +- var lib$es6$promise$asap$$isNode = typeof process !== 'undefined' && {}.toString.call(process) === '[object process]'; ++var browserWindow = typeof window !== 'undefined' ? window : undefined; ++var browserGlobal = browserWindow || {}; ++var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver; ++var isNode = typeof self === 'undefined' && typeof process !== 'undefined' && ({}).toString.call(process) === '[object process]'; + +- // test for web worker but not in IE10 +- var lib$es6$promise$asap$$isWorker = typeof Uint8ClampedArray !== 'undefined' && +- typeof importScripts !== 'undefined' && +- typeof MessageChannel !== 'undefined'; ++// test for web worker but not in IE10 ++var isWorker = typeof Uint8ClampedArray !== 'undefined' && typeof importScripts !== 'undefined' && typeof MessageChannel !== 'undefined'; + +- // node +- function lib$es6$promise$asap$$useNextTick() { +- // node version 0.10.x displays a deprecation warning when nextTick is used recursively +- // see https://github.com/cujojs/when/issues/410 for details +- return function() { +- process.nextTick(lib$es6$promise$asap$$flush); +- }; +- } ++// node ++function useNextTick() { ++ // node version 0.10.x displays a deprecation warning when nextTick is used recursively ++ // see https://github.com/cujojs/when/issues/410 for details ++ return function () { ++ return process.nextTick(flush); ++ }; ++} + +- // vertx +- function lib$es6$promise$asap$$useVertxTimer() { +- return function() { +- lib$es6$promise$asap$$vertxNext(lib$es6$promise$asap$$flush); +- }; +- } ++// vertx ++function useVertxTimer() { ++ return function () { ++ vertxNext(flush); ++ }; ++} + +- function lib$es6$promise$asap$$useMutationObserver() { +- var iterations = 0; +- var observer = new lib$es6$promise$asap$$BrowserMutationObserver(lib$es6$promise$asap$$flush); +- var node = document.createTextNode(''); +- observer.observe(node, { characterData: true }); ++function useMutationObserver() { ++ var iterations = 0; ++ var observer = new BrowserMutationObserver(flush); ++ var node = document.createTextNode(''); ++ observer.observe(node, { characterData: true }); + +- return function() { +- node.data = (iterations = ++iterations % 2); +- }; +- } ++ return function () { ++ node.data = iterations = ++iterations % 2; ++ }; ++} + +- // web worker +- function lib$es6$promise$asap$$useMessageChannel() { +- var channel = new MessageChannel(); +- channel.port1.onmessage = lib$es6$promise$asap$$flush; +- return function () { +- channel.port2.postMessage(0); +- }; +- } ++// web worker ++function useMessageChannel() { ++ var channel = new MessageChannel(); ++ channel.port1.onmessage = flush; ++ return function () { ++ return channel.port2.postMessage(0); ++ }; ++} + +- function lib$es6$promise$asap$$useSetTimeout() { +- return function() { +- setTimeout(lib$es6$promise$asap$$flush, 1); +- }; +- } ++function useSetTimeout() { ++ // Store setTimeout reference so es6-promise will be unaffected by ++ // other code modifying setTimeout (like sinon.useFakeTimers()) ++ var globalSetTimeout = setTimeout; ++ return function () { ++ return globalSetTimeout(flush, 1); ++ }; ++} + +- var lib$es6$promise$asap$$queue = new Array(1000); +- function lib$es6$promise$asap$$flush() { +- for (var i = 0; i < lib$es6$promise$asap$$len; i+=2) { +- var callback = lib$es6$promise$asap$$queue[i]; +- var arg = lib$es6$promise$asap$$queue[i+1]; ++var queue = new Array(1000); ++function flush() { ++ for (var i = 0; i < len; i += 2) { ++ var callback = queue[i]; ++ var arg = queue[i + 1]; + +- callback(arg); ++ callback(arg); + +- lib$es6$promise$asap$$queue[i] = undefined; +- lib$es6$promise$asap$$queue[i+1] = undefined; +- } ++ queue[i] = undefined; ++ queue[i + 1] = undefined; ++ } + +- lib$es6$promise$asap$$len = 0; +- } ++ len = 0; ++} + +- function lib$es6$promise$asap$$attemptVertx() { +- try { +- var r = require; +- var vertx = r('vertx'); +- lib$es6$promise$asap$$vertxNext = vertx.runOnLoop || vertx.runOnContext; +- return lib$es6$promise$asap$$useVertxTimer(); +- } catch(e) { +- return lib$es6$promise$asap$$useSetTimeout(); +- } +- } ++function attemptVertx() { ++ try { ++ var r = require; ++ var vertx = r('vertx'); ++ vertxNext = vertx.runOnLoop || vertx.runOnContext; ++ return useVertxTimer(); ++ } catch (e) { ++ return useSetTimeout(); ++ } ++} + +- var lib$es6$promise$asap$$scheduleFlush; +- // Decide what async method to use to triggering processing of queued callbacks: +- if (lib$es6$promise$asap$$isNode) { +- lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useNextTick(); +- } else if (lib$es6$promise$asap$$BrowserMutationObserver) { +- lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useMutationObserver(); +- } else if (lib$es6$promise$asap$$isWorker) { +- lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useMessageChannel(); +- } else if (lib$es6$promise$asap$$browserWindow === undefined && typeof require === 'function') { +- lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$attemptVertx(); +- } else { +- lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useSetTimeout(); +- } +- function lib$es6$promise$then$$then(onFulfillment, onRejection) { +- var parent = this; +- var state = parent._state; ++var scheduleFlush = undefined; ++// Decide what async method to use to triggering processing of queued callbacks: ++if (isNode) { ++ scheduleFlush = useNextTick(); ++} else if (BrowserMutationObserver) { ++ scheduleFlush = useMutationObserver(); ++} else if (isWorker) { ++ scheduleFlush = useMessageChannel(); ++} else if (browserWindow === undefined && typeof require === 'function') { ++ scheduleFlush = attemptVertx(); ++} else { ++ scheduleFlush = useSetTimeout(); ++} + +- if (state === lib$es6$promise$$internal$$FULFILLED && !onFulfillment || state === lib$es6$promise$$internal$$REJECTED && !onRejection) { +- return this; +- } ++function then(onFulfillment, onRejection) { ++ var _arguments = arguments; + +- var child = new this.constructor(lib$es6$promise$$internal$$noop); +- var result = parent._result; ++ var parent = this; + +- if (state) { +- var callback = arguments[state - 1]; +- lib$es6$promise$asap$$asap(function(){ +- lib$es6$promise$$internal$$invokeCallback(state, child, callback, result); +- }); +- } else { +- lib$es6$promise$$internal$$subscribe(parent, child, onFulfillment, onRejection); +- } ++ var child = new this.constructor(noop); + +- return child; +- } +- var lib$es6$promise$then$$default = lib$es6$promise$then$$then; +- function lib$es6$promise$promise$resolve$$resolve(object) { +- /*jshint validthis:true */ +- var Constructor = this; ++ if (child[PROMISE_ID] === undefined) { ++ makePromise(child); ++ } + +- if (object && typeof object === 'object' && object.constructor === Constructor) { +- return object; +- } ++ var _state = parent._state; + +- var promise = new Constructor(lib$es6$promise$$internal$$noop); +- lib$es6$promise$$internal$$resolve(promise, object); +- return promise; +- } +- var lib$es6$promise$promise$resolve$$default = lib$es6$promise$promise$resolve$$resolve; ++ if (_state) { ++ (function () { ++ var callback = _arguments[_state - 1]; ++ asap(function () { ++ return invokeCallback(_state, child, callback, parent._result); ++ }); ++ })(); ++ } else { ++ subscribe(parent, child, onFulfillment, onRejection); ++ } + +- function lib$es6$promise$$internal$$noop() {} ++ return child; ++} + +- var lib$es6$promise$$internal$$PENDING = void 0; +- var lib$es6$promise$$internal$$FULFILLED = 1; +- var lib$es6$promise$$internal$$REJECTED = 2; ++/** ++ `Promise.resolve` returns a promise that will become resolved with the ++ passed `value`. It is shorthand for the following: + +- var lib$es6$promise$$internal$$GET_THEN_ERROR = new lib$es6$promise$$internal$$ErrorObject(); ++ ```javascript ++ let promise = new Promise(function(resolve, reject){ ++ resolve(1); ++ }); + +- function lib$es6$promise$$internal$$selfFulfillment() { +- return new TypeError("You cannot resolve a promise with itself"); +- } ++ promise.then(function(value){ ++ // value === 1 ++ }); ++ ``` + +- function lib$es6$promise$$internal$$cannotReturnOwn() { +- return new TypeError('A promises callback cannot return that same promise.'); +- } ++ Instead of writing the above, your code now simply becomes the following: + +- function lib$es6$promise$$internal$$getThen(promise) { +- try { +- return promise.then; +- } catch(error) { +- lib$es6$promise$$internal$$GET_THEN_ERROR.error = error; +- return lib$es6$promise$$internal$$GET_THEN_ERROR; +- } +- } ++ ```javascript ++ let promise = Promise.resolve(1); + +- function lib$es6$promise$$internal$$tryThen(then, value, fulfillmentHandler, rejectionHandler) { +- try { +- then.call(value, fulfillmentHandler, rejectionHandler); +- } catch(e) { +- return e; +- } +- } ++ promise.then(function(value){ ++ // value === 1 ++ }); ++ ``` ++ ++ @method resolve ++ @static ++ @param {Any} value value that the returned promise will be resolved with ++ Useful for tooling. ++ @return {Promise} a promise that will become fulfilled with the given ++ `value` ++*/ ++function resolve(object) { ++ /*jshint validthis:true */ ++ var Constructor = this; + +- function lib$es6$promise$$internal$$handleForeignThenable(promise, thenable, then) { +- lib$es6$promise$asap$$asap(function(promise) { +- var sealed = false; +- var error = lib$es6$promise$$internal$$tryThen(then, thenable, function(value) { +- if (sealed) { return; } +- sealed = true; +- if (thenable !== value) { +- lib$es6$promise$$internal$$resolve(promise, value); +- } else { +- lib$es6$promise$$internal$$fulfill(promise, value); +- } +- }, function(reason) { +- if (sealed) { return; } +- sealed = true; ++ if (object && typeof object === 'object' && object.constructor === Constructor) { ++ return object; ++ } + +- lib$es6$promise$$internal$$reject(promise, reason); +- }, 'Settle: ' + (promise._label || ' unknown promise')); ++ var promise = new Constructor(noop); ++ _resolve(promise, object); ++ return promise; ++} + +- if (!sealed && error) { +- sealed = true; +- lib$es6$promise$$internal$$reject(promise, error); +- } +- }, promise); +- } ++var PROMISE_ID = Math.random().toString(36).substring(16); + +- function lib$es6$promise$$internal$$handleOwnThenable(promise, thenable) { +- if (thenable._state === lib$es6$promise$$internal$$FULFILLED) { +- lib$es6$promise$$internal$$fulfill(promise, thenable._result); +- } else if (thenable._state === lib$es6$promise$$internal$$REJECTED) { +- lib$es6$promise$$internal$$reject(promise, thenable._result); +- } else { +- lib$es6$promise$$internal$$subscribe(thenable, undefined, function(value) { +- lib$es6$promise$$internal$$resolve(promise, value); +- }, function(reason) { +- lib$es6$promise$$internal$$reject(promise, reason); +- }); +- } +- } ++function noop() {} + +- function lib$es6$promise$$internal$$handleMaybeThenable(promise, maybeThenable, then) { +- if (maybeThenable.constructor === promise.constructor && +- then === lib$es6$promise$then$$default && +- constructor.resolve === lib$es6$promise$promise$resolve$$default) { +- lib$es6$promise$$internal$$handleOwnThenable(promise, maybeThenable); +- } else { +- if (then === lib$es6$promise$$internal$$GET_THEN_ERROR) { +- lib$es6$promise$$internal$$reject(promise, lib$es6$promise$$internal$$GET_THEN_ERROR.error); +- } else if (then === undefined) { +- lib$es6$promise$$internal$$fulfill(promise, maybeThenable); +- } else if (lib$es6$promise$utils$$isFunction(then)) { +- lib$es6$promise$$internal$$handleForeignThenable(promise, maybeThenable, then); +- } else { +- lib$es6$promise$$internal$$fulfill(promise, maybeThenable); +- } +- } +- } ++var PENDING = void 0; ++var FULFILLED = 1; ++var REJECTED = 2; + +- function lib$es6$promise$$internal$$resolve(promise, value) { +- if (promise === value) { +- lib$es6$promise$$internal$$reject(promise, lib$es6$promise$$internal$$selfFulfillment()); +- } else if (lib$es6$promise$utils$$objectOrFunction(value)) { +- lib$es6$promise$$internal$$handleMaybeThenable(promise, value, lib$es6$promise$$internal$$getThen(value)); +- } else { +- lib$es6$promise$$internal$$fulfill(promise, value); +- } +- } ++var GET_THEN_ERROR = new ErrorObject(); + +- function lib$es6$promise$$internal$$publishRejection(promise) { +- if (promise._onerror) { +- promise._onerror(promise._result); +- } ++function selfFulfillment() { ++ return new TypeError("You cannot resolve a promise with itself"); ++} + +- lib$es6$promise$$internal$$publish(promise); +- } ++function cannotReturnOwn() { ++ return new TypeError('A promises callback cannot return that same promise.'); ++} + +- function lib$es6$promise$$internal$$fulfill(promise, value) { +- if (promise._state !== lib$es6$promise$$internal$$PENDING) { return; } ++function getThen(promise) { ++ try { ++ return promise.then; ++ } catch (error) { ++ GET_THEN_ERROR.error = error; ++ return GET_THEN_ERROR; ++ } ++} + +- promise._result = value; +- promise._state = lib$es6$promise$$internal$$FULFILLED; ++function tryThen(then, value, fulfillmentHandler, rejectionHandler) { ++ try { ++ then.call(value, fulfillmentHandler, rejectionHandler); ++ } catch (e) { ++ return e; ++ } ++} + +- if (promise._subscribers.length !== 0) { +- lib$es6$promise$asap$$asap(lib$es6$promise$$internal$$publish, promise); ++function handleForeignThenable(promise, thenable, then) { ++ asap(function (promise) { ++ var sealed = false; ++ var error = tryThen(then, thenable, function (value) { ++ if (sealed) { ++ return; + } ++ sealed = true; ++ if (thenable !== value) { ++ _resolve(promise, value); ++ } else { ++ fulfill(promise, value); ++ } ++ }, function (reason) { ++ if (sealed) { ++ return; ++ } ++ sealed = true; ++ ++ _reject(promise, reason); ++ }, 'Settle: ' + (promise._label || ' unknown promise')); ++ ++ if (!sealed && error) { ++ sealed = true; ++ _reject(promise, error); + } ++ }, promise); ++} + +- function lib$es6$promise$$internal$$reject(promise, reason) { +- if (promise._state !== lib$es6$promise$$internal$$PENDING) { return; } +- promise._state = lib$es6$promise$$internal$$REJECTED; +- promise._result = reason; ++function handleOwnThenable(promise, thenable) { ++ if (thenable._state === FULFILLED) { ++ fulfill(promise, thenable._result); ++ } else if (thenable._state === REJECTED) { ++ _reject(promise, thenable._result); ++ } else { ++ subscribe(thenable, undefined, function (value) { ++ return _resolve(promise, value); ++ }, function (reason) { ++ return _reject(promise, reason); ++ }); ++ } ++} + +- lib$es6$promise$asap$$asap(lib$es6$promise$$internal$$publishRejection, promise); ++function handleMaybeThenable(promise, maybeThenable, then$$) { ++ if (maybeThenable.constructor === promise.constructor && then$$ === then && maybeThenable.constructor.resolve === resolve) { ++ handleOwnThenable(promise, maybeThenable); ++ } else { ++ if (then$$ === GET_THEN_ERROR) { ++ _reject(promise, GET_THEN_ERROR.error); ++ } else if (then$$ === undefined) { ++ fulfill(promise, maybeThenable); ++ } else if (isFunction(then$$)) { ++ handleForeignThenable(promise, maybeThenable, then$$); ++ } else { ++ fulfill(promise, maybeThenable); + } ++ } ++} + +- function lib$es6$promise$$internal$$subscribe(parent, child, onFulfillment, onRejection) { +- var subscribers = parent._subscribers; +- var length = subscribers.length; ++function _resolve(promise, value) { ++ if (promise === value) { ++ _reject(promise, selfFulfillment()); ++ } else if (objectOrFunction(value)) { ++ handleMaybeThenable(promise, value, getThen(value)); ++ } else { ++ fulfill(promise, value); ++ } ++} + +- parent._onerror = null; ++function publishRejection(promise) { ++ if (promise._onerror) { ++ promise._onerror(promise._result); ++ } + +- subscribers[length] = child; +- subscribers[length + lib$es6$promise$$internal$$FULFILLED] = onFulfillment; +- subscribers[length + lib$es6$promise$$internal$$REJECTED] = onRejection; ++ publish(promise); ++} + +- if (length === 0 && parent._state) { +- lib$es6$promise$asap$$asap(lib$es6$promise$$internal$$publish, parent); +- } +- } ++function fulfill(promise, value) { ++ if (promise._state !== PENDING) { ++ return; ++ } + +- function lib$es6$promise$$internal$$publish(promise) { +- var subscribers = promise._subscribers; +- var settled = promise._state; ++ promise._result = value; ++ promise._state = FULFILLED; + +- if (subscribers.length === 0) { return; } ++ if (promise._subscribers.length !== 0) { ++ asap(publish, promise); ++ } ++} + +- var child, callback, detail = promise._result; ++function _reject(promise, reason) { ++ if (promise._state !== PENDING) { ++ return; ++ } ++ promise._state = REJECTED; ++ promise._result = reason; + +- for (var i = 0; i < subscribers.length; i += 3) { +- child = subscribers[i]; +- callback = subscribers[i + settled]; ++ asap(publishRejection, promise); ++} + +- if (child) { +- lib$es6$promise$$internal$$invokeCallback(settled, child, callback, detail); +- } else { +- callback(detail); +- } +- } ++function subscribe(parent, child, onFulfillment, onRejection) { ++ var _subscribers = parent._subscribers; ++ var length = _subscribers.length; + +- promise._subscribers.length = 0; +- } ++ parent._onerror = null; + +- function lib$es6$promise$$internal$$ErrorObject() { +- this.error = null; +- } ++ _subscribers[length] = child; ++ _subscribers[length + FULFILLED] = onFulfillment; ++ _subscribers[length + REJECTED] = onRejection; + +- var lib$es6$promise$$internal$$TRY_CATCH_ERROR = new lib$es6$promise$$internal$$ErrorObject(); ++ if (length === 0 && parent._state) { ++ asap(publish, parent); ++ } ++} + +- function lib$es6$promise$$internal$$tryCatch(callback, detail) { +- try { +- return callback(detail); +- } catch(e) { +- lib$es6$promise$$internal$$TRY_CATCH_ERROR.error = e; +- return lib$es6$promise$$internal$$TRY_CATCH_ERROR; +- } ++function publish(promise) { ++ var subscribers = promise._subscribers; ++ var settled = promise._state; ++ ++ if (subscribers.length === 0) { ++ return; ++ } ++ ++ var child = undefined, ++ callback = undefined, ++ detail = promise._result; ++ ++ for (var i = 0; i < subscribers.length; i += 3) { ++ child = subscribers[i]; ++ callback = subscribers[i + settled]; ++ ++ if (child) { ++ invokeCallback(settled, child, callback, detail); ++ } else { ++ callback(detail); + } ++ } + +- function lib$es6$promise$$internal$$invokeCallback(settled, promise, callback, detail) { +- var hasCallback = lib$es6$promise$utils$$isFunction(callback), +- value, error, succeeded, failed; ++ promise._subscribers.length = 0; ++} + +- if (hasCallback) { +- value = lib$es6$promise$$internal$$tryCatch(callback, detail); ++function ErrorObject() { ++ this.error = null; ++} + +- if (value === lib$es6$promise$$internal$$TRY_CATCH_ERROR) { +- failed = true; +- error = value.error; +- value = null; +- } else { +- succeeded = true; +- } ++var TRY_CATCH_ERROR = new ErrorObject(); + +- if (promise === value) { +- lib$es6$promise$$internal$$reject(promise, lib$es6$promise$$internal$$cannotReturnOwn()); +- return; +- } ++function tryCatch(callback, detail) { ++ try { ++ return callback(detail); ++ } catch (e) { ++ TRY_CATCH_ERROR.error = e; ++ return TRY_CATCH_ERROR; ++ } ++} + +- } else { +- value = detail; +- succeeded = true; +- } ++function invokeCallback(settled, promise, callback, detail) { ++ var hasCallback = isFunction(callback), ++ value = undefined, ++ error = undefined, ++ succeeded = undefined, ++ failed = undefined; + +- if (promise._state !== lib$es6$promise$$internal$$PENDING) { +- // noop +- } else if (hasCallback && succeeded) { +- lib$es6$promise$$internal$$resolve(promise, value); +- } else if (failed) { +- lib$es6$promise$$internal$$reject(promise, error); +- } else if (settled === lib$es6$promise$$internal$$FULFILLED) { +- lib$es6$promise$$internal$$fulfill(promise, value); +- } else if (settled === lib$es6$promise$$internal$$REJECTED) { +- lib$es6$promise$$internal$$reject(promise, value); +- } ++ if (hasCallback) { ++ value = tryCatch(callback, detail); ++ ++ if (value === TRY_CATCH_ERROR) { ++ failed = true; ++ error = value.error; ++ value = null; ++ } else { ++ succeeded = true; + } + +- function lib$es6$promise$$internal$$initializePromise(promise, resolver) { +- try { +- resolver(function resolvePromise(value){ +- lib$es6$promise$$internal$$resolve(promise, value); +- }, function rejectPromise(reason) { +- lib$es6$promise$$internal$$reject(promise, reason); +- }); +- } catch(e) { +- lib$es6$promise$$internal$$reject(promise, e); +- } ++ if (promise === value) { ++ _reject(promise, cannotReturnOwn()); ++ return; + } ++ } else { ++ value = detail; ++ succeeded = true; ++ } + +- function lib$es6$promise$promise$all$$all(entries) { +- return new lib$es6$promise$enumerator$$default(this, entries).promise; ++ if (promise._state !== PENDING) { ++ // noop ++ } else if (hasCallback && succeeded) { ++ _resolve(promise, value); ++ } else if (failed) { ++ _reject(promise, error); ++ } else if (settled === FULFILLED) { ++ fulfill(promise, value); ++ } else if (settled === REJECTED) { ++ _reject(promise, value); + } +- var lib$es6$promise$promise$all$$default = lib$es6$promise$promise$all$$all; +- function lib$es6$promise$promise$race$$race(entries) { +- /*jshint validthis:true */ +- var Constructor = this; ++} + +- var promise = new Constructor(lib$es6$promise$$internal$$noop); ++function initializePromise(promise, resolver) { ++ try { ++ resolver(function resolvePromise(value) { ++ _resolve(promise, value); ++ }, function rejectPromise(reason) { ++ _reject(promise, reason); ++ }); ++ } catch (e) { ++ _reject(promise, e); ++ } ++} + +- if (!lib$es6$promise$utils$$isArray(entries)) { +- lib$es6$promise$$internal$$reject(promise, new TypeError('You must pass an array to race.')); +- return promise; +- } ++var id = 0; ++function nextId() { ++ return id++; ++} + +- var length = entries.length; ++function makePromise(promise) { ++ promise[PROMISE_ID] = id++; ++ promise._state = undefined; ++ promise._result = undefined; ++ promise._subscribers = []; ++} + +- function onFulfillment(value) { +- lib$es6$promise$$internal$$resolve(promise, value); +- } ++function Enumerator(Constructor, input) { ++ this._instanceConstructor = Constructor; ++ this.promise = new Constructor(noop); + +- function onRejection(reason) { +- lib$es6$promise$$internal$$reject(promise, reason); +- } ++ if (!this.promise[PROMISE_ID]) { ++ makePromise(this.promise); ++ } + +- for (var i = 0; promise._state === lib$es6$promise$$internal$$PENDING && i < length; i++) { +- lib$es6$promise$$internal$$subscribe(Constructor.resolve(entries[i]), undefined, onFulfillment, onRejection); +- } ++ if (isArray(input)) { ++ this._input = input; ++ this.length = input.length; ++ this._remaining = input.length; + +- return promise; +- } +- var lib$es6$promise$promise$race$$default = lib$es6$promise$promise$race$$race; +- function lib$es6$promise$promise$reject$$reject(reason) { +- /*jshint validthis:true */ +- var Constructor = this; +- var promise = new Constructor(lib$es6$promise$$internal$$noop); +- lib$es6$promise$$internal$$reject(promise, reason); +- return promise; ++ this._result = new Array(this.length); ++ ++ if (this.length === 0) { ++ fulfill(this.promise, this._result); ++ } else { ++ this.length = this.length || 0; ++ this._enumerate(); ++ if (this._remaining === 0) { ++ fulfill(this.promise, this._result); ++ } + } +- var lib$es6$promise$promise$reject$$default = lib$es6$promise$promise$reject$$reject; ++ } else { ++ _reject(this.promise, validationError()); ++ } ++} + +- var lib$es6$promise$promise$$counter = 0; ++function validationError() { ++ return new Error('Array Methods must be provided an Array'); ++}; ++ ++Enumerator.prototype._enumerate = function () { ++ var length = this.length; ++ var _input = this._input; ++ ++ for (var i = 0; this._state === PENDING && i < length; i++) { ++ this._eachEntry(_input[i], i); ++ } ++}; ++ ++Enumerator.prototype._eachEntry = function (entry, i) { ++ var c = this._instanceConstructor; ++ var resolve$$ = c.resolve; + +- function lib$es6$promise$promise$$needsResolver() { +- throw new TypeError('You must pass a resolver function as the first argument to the promise constructor'); ++ if (resolve$$ === resolve) { ++ var _then = getThen(entry); ++ ++ if (_then === then && entry._state !== PENDING) { ++ this._settledAt(entry._state, i, entry._result); ++ } else if (typeof _then !== 'function') { ++ this._remaining--; ++ this._result[i] = entry; ++ } else if (c === Promise) { ++ var promise = new c(noop); ++ handleMaybeThenable(promise, entry, _then); ++ this._willSettleAt(promise, i); ++ } else { ++ this._willSettleAt(new c(function (resolve$$) { ++ return resolve$$(entry); ++ }), i); + } ++ } else { ++ this._willSettleAt(resolve$$(entry), i); ++ } ++}; ++ ++Enumerator.prototype._settledAt = function (state, i, value) { ++ var promise = this.promise; ++ ++ if (promise._state === PENDING) { ++ this._remaining--; + +- function lib$es6$promise$promise$$needsNew() { +- throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function."); ++ if (state === REJECTED) { ++ _reject(promise, value); ++ } else { ++ this._result[i] = value; + } ++ } + +- var lib$es6$promise$promise$$default = lib$es6$promise$promise$$Promise; +- /** +- Promise objects represent the eventual result of an asynchronous operation. The +- primary way of interacting with a promise is through its `then` method, which +- registers callbacks to receive either a promise's eventual value or the reason +- why the promise cannot be fulfilled. ++ if (this._remaining === 0) { ++ fulfill(promise, this._result); ++ } ++}; + +- Terminology +- ----------- ++Enumerator.prototype._willSettleAt = function (promise, i) { ++ var enumerator = this; + +- - `promise` is an object or function with a `then` method whose behavior conforms to this specification. +- - `thenable` is an object or function that defines a `then` method. +- - `value` is any legal JavaScript value (including undefined, a thenable, or a promise). +- - `exception` is a value that is thrown using the throw statement. +- - `reason` is a value that indicates why a promise was rejected. +- - `settled` the final resting state of a promise, fulfilled or rejected. ++ subscribe(promise, undefined, function (value) { ++ return enumerator._settledAt(FULFILLED, i, value); ++ }, function (reason) { ++ return enumerator._settledAt(REJECTED, i, reason); ++ }); ++}; + +- A promise can be in one of three states: pending, fulfilled, or rejected. ++/** ++ `Promise.all` accepts an array of promises, and returns a new promise which ++ is fulfilled with an array of fulfillment values for the passed promises, or ++ rejected with the reason of the first passed promise to be rejected. It casts all ++ elements of the passed iterable to promises as it runs this algorithm. + +- Promises that are fulfilled have a fulfillment value and are in the fulfilled +- state. Promises that are rejected have a rejection reason and are in the +- rejected state. A fulfillment value is never a thenable. ++ Example: + +- Promises can also be said to *resolve* a value. If this value is also a +- promise, then the original promise's settled state will match the value's +- settled state. So a promise that *resolves* a promise that rejects will +- itself reject, and a promise that *resolves* a promise that fulfills will +- itself fulfill. ++ ```javascript ++ let promise1 = resolve(1); ++ let promise2 = resolve(2); ++ let promise3 = resolve(3); ++ let promises = [ promise1, promise2, promise3 ]; + ++ Promise.all(promises).then(function(array){ ++ // The array here would be [ 1, 2, 3 ]; ++ }); ++ ``` + +- Basic Usage: +- ------------ ++ If any of the `promises` given to `all` are rejected, the first promise ++ that is rejected will be given as an argument to the returned promises's ++ rejection handler. For example: + +- ```js +- var promise = new Promise(function(resolve, reject) { +- // on success +- resolve(value); ++ Example: + +- // on failure +- reject(reason); +- }); ++ ```javascript ++ let promise1 = resolve(1); ++ let promise2 = reject(new Error("2")); ++ let promise3 = reject(new Error("3")); ++ let promises = [ promise1, promise2, promise3 ]; + +- promise.then(function(value) { +- // on fulfillment +- }, function(reason) { +- // on rejection +- }); +- ``` ++ Promise.all(promises).then(function(array){ ++ // Code here never runs because there are rejected promises! ++ }, function(error) { ++ // error.message === "2" ++ }); ++ ``` ++ ++ @method all ++ @static ++ @param {Array} entries array of promises ++ @param {String} label optional string for labeling the promise. ++ Useful for tooling. ++ @return {Promise} promise that is fulfilled when all `promises` have been ++ fulfilled, or rejected if any of them become rejected. ++ @static ++*/ ++function all(entries) { ++ return new Enumerator(this, entries).promise; ++} + +- Advanced Usage: +- --------------- ++/** ++ `Promise.race` returns a new promise which is settled in the same way as the ++ first passed promise to settle. + +- Promises shine when abstracting away asynchronous interactions such as +- `XMLHttpRequest`s. ++ Example: + +- ```js +- function getJSON(url) { +- return new Promise(function(resolve, reject){ +- var xhr = new XMLHttpRequest(); ++ ```javascript ++ let promise1 = new Promise(function(resolve, reject){ ++ setTimeout(function(){ ++ resolve('promise 1'); ++ }, 200); ++ }); + +- xhr.open('GET', url); +- xhr.onreadystatechange = handler; +- xhr.responseType = 'json'; +- xhr.setRequestHeader('Accept', 'application/json'); +- xhr.send(); ++ let promise2 = new Promise(function(resolve, reject){ ++ setTimeout(function(){ ++ resolve('promise 2'); ++ }, 100); ++ }); + +- function handler() { +- if (this.readyState === this.DONE) { +- if (this.status === 200) { +- resolve(this.response); +- } else { +- reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']')); +- } +- } +- }; +- }); +- } ++ Promise.race([promise1, promise2]).then(function(result){ ++ // result === 'promise 2' because it was resolved before promise1 ++ // was resolved. ++ }); ++ ``` ++ ++ `Promise.race` is deterministic in that only the state of the first ++ settled promise matters. For example, even if other promises given to the ++ `promises` array argument are resolved, but the first settled promise has ++ become rejected before the other promises became fulfilled, the returned ++ promise will become rejected: ++ ++ ```javascript ++ let promise1 = new Promise(function(resolve, reject){ ++ setTimeout(function(){ ++ resolve('promise 1'); ++ }, 200); ++ }); + +- getJSON('/posts.json').then(function(json) { +- // on fulfillment +- }, function(reason) { +- // on rejection +- }); +- ``` ++ let promise2 = new Promise(function(resolve, reject){ ++ setTimeout(function(){ ++ reject(new Error('promise 2')); ++ }, 100); ++ }); ++ ++ Promise.race([promise1, promise2]).then(function(result){ ++ // Code here never runs ++ }, function(reason){ ++ // reason.message === 'promise 2' because promise 2 became rejected before ++ // promise 1 became fulfilled ++ }); ++ ``` + +- Unlike callbacks, promises are great composable primitives. ++ An example real-world use case is implementing timeouts: + +- ```js +- Promise.all([ +- getJSON('/posts'), +- getJSON('/comments') +- ]).then(function(values){ +- values[0] // => postsJSON +- values[1] // => commentsJSON ++ ```javascript ++ Promise.race([ajax('foo.json'), timeout(5000)]) ++ ``` + +- return values; +- }); +- ``` +- +- @class Promise +- @param {function} resolver +- Useful for tooling. +- @constructor +- */ +- function lib$es6$promise$promise$$Promise(resolver) { +- this._id = lib$es6$promise$promise$$counter++; +- this._state = undefined; +- this._result = undefined; +- this._subscribers = []; +- +- if (lib$es6$promise$$internal$$noop !== resolver) { +- typeof resolver !== 'function' && lib$es6$promise$promise$$needsResolver(); +- this instanceof lib$es6$promise$promise$$Promise ? lib$es6$promise$$internal$$initializePromise(this, resolver) : lib$es6$promise$promise$$needsNew(); ++ @method race ++ @static ++ @param {Array} promises array of promises to observe ++ Useful for tooling. ++ @return {Promise} a promise which settles in the same way as the first passed ++ promise to settle. ++*/ ++function race(entries) { ++ /*jshint validthis:true */ ++ var Constructor = this; ++ ++ if (!isArray(entries)) { ++ return new Constructor(function (_, reject) { ++ return reject(new TypeError('You must pass an array to race.')); ++ }); ++ } else { ++ return new Constructor(function (resolve, reject) { ++ var length = entries.length; ++ for (var i = 0; i < length; i++) { ++ Constructor.resolve(entries[i]).then(resolve, reject); + } +- } ++ }); ++ } ++} + +- lib$es6$promise$promise$$Promise.all = lib$es6$promise$promise$all$$default; +- lib$es6$promise$promise$$Promise.race = lib$es6$promise$promise$race$$default; +- lib$es6$promise$promise$$Promise.resolve = lib$es6$promise$promise$resolve$$default; +- lib$es6$promise$promise$$Promise.reject = lib$es6$promise$promise$reject$$default; +- lib$es6$promise$promise$$Promise._setScheduler = lib$es6$promise$asap$$setScheduler; +- lib$es6$promise$promise$$Promise._setAsap = lib$es6$promise$asap$$setAsap; +- lib$es6$promise$promise$$Promise._asap = lib$es6$promise$asap$$asap; ++/** ++ `Promise.reject` returns a promise rejected with the passed `reason`. ++ It is shorthand for the following: + +- lib$es6$promise$promise$$Promise.prototype = { +- constructor: lib$es6$promise$promise$$Promise, ++ ```javascript ++ let promise = new Promise(function(resolve, reject){ ++ reject(new Error('WHOOPS')); ++ }); + +- /** +- The primary way of interacting with a promise is through its `then` method, +- which registers callbacks to receive either a promise's eventual value or the +- reason why the promise cannot be fulfilled. +- +- ```js +- findUser().then(function(user){ +- // user is available +- }, function(reason){ +- // user is unavailable, and you are given the reason why +- }); +- ``` +- +- Chaining +- -------- +- +- The return value of `then` is itself a promise. This second, 'downstream' +- promise is resolved with the return value of the first promise's fulfillment +- or rejection handler, or rejected if the handler throws an exception. +- +- ```js +- findUser().then(function (user) { +- return user.name; +- }, function (reason) { +- return 'default name'; +- }).then(function (userName) { +- // If `findUser` fulfilled, `userName` will be the user's name, otherwise it +- // will be `'default name'` +- }); ++ promise.then(function(value){ ++ // Code here doesn't run because the promise is rejected! ++ }, function(reason){ ++ // reason.message === 'WHOOPS' ++ }); ++ ``` + +- findUser().then(function (user) { +- throw new Error('Found user, but still unhappy'); +- }, function (reason) { +- throw new Error('`findUser` rejected and we're unhappy'); +- }).then(function (value) { +- // never reached +- }, function (reason) { +- // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'. +- // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'. +- }); +- ``` +- If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream. +- +- ```js +- findUser().then(function (user) { +- throw new PedagogicalException('Upstream error'); +- }).then(function (value) { +- // never reached +- }).then(function (value) { +- // never reached +- }, function (reason) { +- // The `PedgagocialException` is propagated all the way down to here +- }); +- ``` ++ Instead of writing the above, your code now simply becomes the following: + +- Assimilation +- ------------ ++ ```javascript ++ let promise = Promise.reject(new Error('WHOOPS')); + +- Sometimes the value you want to propagate to a downstream promise can only be +- retrieved asynchronously. This can be achieved by returning a promise in the +- fulfillment or rejection handler. The downstream promise will then be pending +- until the returned promise is settled. This is called *assimilation*. ++ promise.then(function(value){ ++ // Code here doesn't run because the promise is rejected! ++ }, function(reason){ ++ // reason.message === 'WHOOPS' ++ }); ++ ``` + +- ```js +- findUser().then(function (user) { +- return findCommentsByAuthor(user); +- }).then(function (comments) { +- // The user's comments are now available +- }); +- ``` ++ @method reject ++ @static ++ @param {Any} reason value that the returned promise will be rejected with. ++ Useful for tooling. ++ @return {Promise} a promise rejected with the given `reason`. ++*/ ++function reject(reason) { ++ /*jshint validthis:true */ ++ var Constructor = this; ++ var promise = new Constructor(noop); ++ _reject(promise, reason); ++ return promise; ++} + +- If the assimliated promise rejects, then the downstream promise will also reject. ++function needsResolver() { ++ throw new TypeError('You must pass a resolver function as the first argument to the promise constructor'); ++} + +- ```js +- findUser().then(function (user) { +- return findCommentsByAuthor(user); +- }).then(function (comments) { +- // If `findCommentsByAuthor` fulfills, we'll have the value here +- }, function (reason) { +- // If `findCommentsByAuthor` rejects, we'll have the reason here +- }); +- ``` ++function needsNew() { ++ throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function."); ++} + +- Simple Example +- -------------- ++/** ++ Promise objects represent the eventual result of an asynchronous operation. The ++ primary way of interacting with a promise is through its `then` method, which ++ registers callbacks to receive either a promise's eventual value or the reason ++ why the promise cannot be fulfilled. + +- Synchronous Example ++ Terminology ++ ----------- + +- ```javascript +- var result; ++ - `promise` is an object or function with a `then` method whose behavior conforms to this specification. ++ - `thenable` is an object or function that defines a `then` method. ++ - `value` is any legal JavaScript value (including undefined, a thenable, or a promise). ++ - `exception` is a value that is thrown using the throw statement. ++ - `reason` is a value that indicates why a promise was rejected. ++ - `settled` the final resting state of a promise, fulfilled or rejected. + +- try { +- result = findResult(); +- // success +- } catch(reason) { +- // failure +- } +- ``` ++ A promise can be in one of three states: pending, fulfilled, or rejected. + +- Errback Example ++ Promises that are fulfilled have a fulfillment value and are in the fulfilled ++ state. Promises that are rejected have a rejection reason and are in the ++ rejected state. A fulfillment value is never a thenable. + +- ```js +- findResult(function(result, err){ +- if (err) { +- // failure +- } else { +- // success +- } +- }); +- ``` ++ Promises can also be said to *resolve* a value. If this value is also a ++ promise, then the original promise's settled state will match the value's ++ settled state. So a promise that *resolves* a promise that rejects will ++ itself reject, and a promise that *resolves* a promise that fulfills will ++ itself fulfill. + +- Promise Example; + +- ```javascript +- findResult().then(function(result){ +- // success +- }, function(reason){ +- // failure +- }); +- ``` ++ Basic Usage: ++ ------------ ++ ++ ```js ++ let promise = new Promise(function(resolve, reject) { ++ // on success ++ resolve(value); + +- Advanced Example +- -------------- ++ // on failure ++ reject(reason); ++ }); ++ ++ promise.then(function(value) { ++ // on fulfillment ++ }, function(reason) { ++ // on rejection ++ }); ++ ``` + +- Synchronous Example ++ Advanced Usage: ++ --------------- + +- ```javascript +- var author, books; ++ Promises shine when abstracting away asynchronous interactions such as ++ `XMLHttpRequest`s. + +- try { +- author = findAuthor(); +- books = findBooksByAuthor(author); ++ ```js ++ function getJSON(url) { ++ return new Promise(function(resolve, reject){ ++ let xhr = new XMLHttpRequest(); ++ ++ xhr.open('GET', url); ++ xhr.onreadystatechange = handler; ++ xhr.responseType = 'json'; ++ xhr.setRequestHeader('Accept', 'application/json'); ++ xhr.send(); ++ ++ function handler() { ++ if (this.readyState === this.DONE) { ++ if (this.status === 200) { ++ resolve(this.response); ++ } else { ++ reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']')); ++ } ++ } ++ }; ++ }); ++ } ++ ++ getJSON('/posts.json').then(function(json) { ++ // on fulfillment ++ }, function(reason) { ++ // on rejection ++ }); ++ ``` ++ ++ Unlike callbacks, promises are great composable primitives. ++ ++ ```js ++ Promise.all([ ++ getJSON('/posts'), ++ getJSON('/comments') ++ ]).then(function(values){ ++ values[0] // => postsJSON ++ values[1] // => commentsJSON ++ ++ return values; ++ }); ++ ``` ++ ++ @class Promise ++ @param {function} resolver ++ Useful for tooling. ++ @constructor ++*/ ++function Promise(resolver) { ++ this[PROMISE_ID] = nextId(); ++ this._result = this._state = undefined; ++ this._subscribers = []; ++ ++ if (noop !== resolver) { ++ typeof resolver !== 'function' && needsResolver(); ++ this instanceof Promise ? initializePromise(this, resolver) : needsNew(); ++ } ++} ++ ++Promise.all = all; ++Promise.race = race; ++Promise.resolve = resolve; ++Promise.reject = reject; ++Promise._setScheduler = setScheduler; ++Promise._setAsap = setAsap; ++Promise._asap = asap; ++ ++Promise.prototype = { ++ constructor: Promise, ++ ++ /** ++ The primary way of interacting with a promise is through its `then` method, ++ which registers callbacks to receive either a promise's eventual value or the ++ reason why the promise cannot be fulfilled. ++ ++ ```js ++ findUser().then(function(user){ ++ // user is available ++ }, function(reason){ ++ // user is unavailable, and you are given the reason why ++ }); ++ ``` ++ ++ Chaining ++ -------- ++ ++ The return value of `then` is itself a promise. This second, 'downstream' ++ promise is resolved with the return value of the first promise's fulfillment ++ or rejection handler, or rejected if the handler throws an exception. ++ ++ ```js ++ findUser().then(function (user) { ++ return user.name; ++ }, function (reason) { ++ return 'default name'; ++ }).then(function (userName) { ++ // If `findUser` fulfilled, `userName` will be the user's name, otherwise it ++ // will be `'default name'` ++ }); ++ ++ findUser().then(function (user) { ++ throw new Error('Found user, but still unhappy'); ++ }, function (reason) { ++ throw new Error('`findUser` rejected and we're unhappy'); ++ }).then(function (value) { ++ // never reached ++ }, function (reason) { ++ // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'. ++ // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'. ++ }); ++ ``` ++ If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream. ++ ++ ```js ++ findUser().then(function (user) { ++ throw new PedagogicalException('Upstream error'); ++ }).then(function (value) { ++ // never reached ++ }).then(function (value) { ++ // never reached ++ }, function (reason) { ++ // The `PedgagocialException` is propagated all the way down to here ++ }); ++ ``` ++ ++ Assimilation ++ ------------ ++ ++ Sometimes the value you want to propagate to a downstream promise can only be ++ retrieved asynchronously. This can be achieved by returning a promise in the ++ fulfillment or rejection handler. The downstream promise will then be pending ++ until the returned promise is settled. This is called *assimilation*. ++ ++ ```js ++ findUser().then(function (user) { ++ return findCommentsByAuthor(user); ++ }).then(function (comments) { ++ // The user's comments are now available ++ }); ++ ``` ++ ++ If the assimliated promise rejects, then the downstream promise will also reject. ++ ++ ```js ++ findUser().then(function (user) { ++ return findCommentsByAuthor(user); ++ }).then(function (comments) { ++ // If `findCommentsByAuthor` fulfills, we'll have the value here ++ }, function (reason) { ++ // If `findCommentsByAuthor` rejects, we'll have the reason here ++ }); ++ ``` ++ ++ Simple Example ++ -------------- ++ ++ Synchronous Example ++ ++ ```javascript ++ let result; ++ ++ try { ++ result = findResult(); ++ // success ++ } catch(reason) { ++ // failure ++ } ++ ``` ++ ++ Errback Example ++ ++ ```js ++ findResult(function(result, err){ ++ if (err) { ++ // failure ++ } else { + // success +- } catch(reason) { ++ } ++ }); ++ ``` ++ ++ Promise Example; ++ ++ ```javascript ++ findResult().then(function(result){ ++ // success ++ }, function(reason){ ++ // failure ++ }); ++ ``` ++ ++ Advanced Example ++ -------------- ++ ++ Synchronous Example ++ ++ ```javascript ++ let author, books; ++ ++ try { ++ author = findAuthor(); ++ books = findBooksByAuthor(author); ++ // success ++ } catch(reason) { ++ // failure ++ } ++ ``` ++ ++ Errback Example ++ ++ ```js ++ ++ function foundBooks(books) { ++ ++ } ++ ++ function failure(reason) { ++ ++ } ++ ++ findAuthor(function(author, err){ ++ if (err) { ++ failure(err); + // failure ++ } else { ++ try { ++ findBoooksByAuthor(author, function(books, err) { ++ if (err) { ++ failure(err); ++ } else { ++ try { ++ foundBooks(books); ++ } catch(reason) { ++ failure(reason); ++ } ++ } ++ }); ++ } catch(error) { ++ failure(err); ++ } ++ // success + } +- ``` ++ }); ++ ``` ++ ++ Promise Example; ++ ++ ```javascript ++ findAuthor(). ++ then(findBooksByAuthor). ++ then(function(books){ ++ // found books ++ }).catch(function(reason){ ++ // something went wrong ++ }); ++ ``` ++ ++ @method then ++ @param {Function} onFulfilled ++ @param {Function} onRejected ++ Useful for tooling. ++ @return {Promise} ++ */ ++ then: then, ++ ++ /** ++ `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same ++ as the catch block of a try/catch statement. ++ ++ ```js ++ function findAuthor(){ ++ throw new Error('couldn't find that author'); ++ } ++ ++ // synchronous ++ try { ++ findAuthor(); ++ } catch(reason) { ++ // something went wrong ++ } ++ ++ // async with promises ++ findAuthor().catch(function(reason){ ++ // something went wrong ++ }); ++ ``` ++ ++ @method catch ++ @param {Function} onRejection ++ Useful for tooling. ++ @return {Promise} ++ */ ++ 'catch': function _catch(onRejection) { ++ return this.then(null, onRejection); ++ } ++}; + +- Errback Example ++function polyfill() { ++ var local = undefined; + +- ```js ++ if (typeof global !== 'undefined') { ++ local = global; ++ } else if (typeof self !== 'undefined') { ++ local = self; ++ } else { ++ try { ++ local = Function('return this')(); ++ } catch (e) { ++ throw new Error('polyfill failed because global object is unavailable in this environment'); ++ } ++ } + +- function foundBooks(books) { ++ var P = local.Promise; + +- } ++ if (P) { ++ var promiseToString = null; ++ try { ++ promiseToString = Object.prototype.toString.call(P.resolve()); ++ } catch (e) { ++ // silently ignored ++ } + +- function failure(reason) { ++ if (promiseToString === '[object Promise]' && !P.cast) { ++ return; ++ } ++ } + +- } ++ local.Promise = Promise; ++} + +- findAuthor(function(author, err){ +- if (err) { +- failure(err); +- // failure +- } else { +- try { +- findBoooksByAuthor(author, function(books, err) { +- if (err) { +- failure(err); +- } else { +- try { +- foundBooks(books); +- } catch(reason) { +- failure(reason); +- } +- } +- }); +- } catch(error) { +- failure(err); +- } +- // success +- } +- }); +- ``` ++polyfill(); ++// Strange compat.. ++Promise.polyfill = polyfill; ++Promise.Promise = Promise; + +- Promise Example; ++return Promise; + +- ```javascript +- findAuthor(). +- then(findBooksByAuthor). +- then(function(books){ +- // found books +- }).catch(function(reason){ +- // something went wrong +- }); +- ``` ++}))); ++ ++}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) ++},{"_process":12}],9:[function(require,module,exports){ ++// Copyright Joyent, Inc. and other Node contributors. ++// ++// Permission is hereby granted, free of charge, to any person obtaining a ++// copy of this software and associated documentation files (the ++// "Software"), to deal in the Software without restriction, including ++// without limitation the rights to use, copy, modify, merge, publish, ++// distribute, sublicense, and/or sell copies of the Software, and to permit ++// persons to whom the Software is furnished to do so, subject to the ++// following conditions: ++// ++// The above copyright notice and this permission notice shall be included ++// in all copies or substantial portions of the Software. ++// ++// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ++// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ++// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN ++// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, ++// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR ++// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE ++// USE OR OTHER DEALINGS IN THE SOFTWARE. + +- @method then +- @param {Function} onFulfilled +- @param {Function} onRejected +- Useful for tooling. +- @return {Promise} +- */ +- then: lib$es6$promise$then$$default, ++function EventEmitter() { ++ this._events = this._events || {}; ++ this._maxListeners = this._maxListeners || undefined; ++} ++module.exports = EventEmitter; + +- /** +- `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same +- as the catch block of a try/catch statement. ++// Backwards-compat with node 0.10.x ++EventEmitter.EventEmitter = EventEmitter; + +- ```js +- function findAuthor(){ +- throw new Error('couldn't find that author'); +- } ++EventEmitter.prototype._events = undefined; ++EventEmitter.prototype._maxListeners = undefined; + +- // synchronous +- try { +- findAuthor(); +- } catch(reason) { +- // something went wrong +- } ++// By default EventEmitters will print a warning if more than 10 listeners are ++// added to it. This is a useful default which helps finding memory leaks. ++EventEmitter.defaultMaxListeners = 10; + +- // async with promises +- findAuthor().catch(function(reason){ +- // something went wrong +- }); +- ``` +- +- @method catch +- @param {Function} onRejection +- Useful for tooling. +- @return {Promise} +- */ +- 'catch': function(onRejection) { +- return this.then(null, onRejection); +- } +- }; +- var lib$es6$promise$enumerator$$default = lib$es6$promise$enumerator$$Enumerator; +- function lib$es6$promise$enumerator$$Enumerator(Constructor, input) { +- this._instanceConstructor = Constructor; +- this.promise = new Constructor(lib$es6$promise$$internal$$noop); ++// Obviously not all Emitters should be limited to 10. This function allows ++// that to be increased. Set to zero for unlimited. ++EventEmitter.prototype.setMaxListeners = function(n) { ++ if (!isNumber(n) || n < 0 || isNaN(n)) ++ throw TypeError('n must be a positive number'); ++ this._maxListeners = n; ++ return this; ++}; + +- if (Array.isArray(input)) { +- this._input = input; +- this.length = input.length; +- this._remaining = input.length; ++EventEmitter.prototype.emit = function(type) { ++ var er, handler, len, args, i, listeners; + +- this._result = new Array(this.length); ++ if (!this._events) ++ this._events = {}; + +- if (this.length === 0) { +- lib$es6$promise$$internal$$fulfill(this.promise, this._result); +- } else { +- this.length = this.length || 0; +- this._enumerate(); +- if (this._remaining === 0) { +- lib$es6$promise$$internal$$fulfill(this.promise, this._result); +- } +- } ++ // If there is no 'error' event listener then throw. ++ if (type === 'error') { ++ if (!this._events.error || ++ (isObject(this._events.error) && !this._events.error.length)) { ++ er = arguments[1]; ++ if (er instanceof Error) { ++ throw er; // Unhandled 'error' event + } else { +- lib$es6$promise$$internal$$reject(this.promise, this._validationError()); ++ // At least give some kind of context to the user ++ var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); ++ err.context = er; ++ throw err; + } + } ++ } + +- lib$es6$promise$enumerator$$Enumerator.prototype._validationError = function() { +- return new Error('Array Methods must be provided an Array'); +- }; ++ handler = this._events[type]; + +- lib$es6$promise$enumerator$$Enumerator.prototype._enumerate = function() { +- var length = this.length; +- var input = this._input; ++ if (isUndefined(handler)) ++ return false; + +- for (var i = 0; this._state === lib$es6$promise$$internal$$PENDING && i < length; i++) { +- this._eachEntry(input[i], i); +- } +- }; ++ if (isFunction(handler)) { ++ switch (arguments.length) { ++ // fast cases ++ case 1: ++ handler.call(this); ++ break; ++ case 2: ++ handler.call(this, arguments[1]); ++ break; ++ case 3: ++ handler.call(this, arguments[1], arguments[2]); ++ break; ++ // slower ++ default: ++ args = Array.prototype.slice.call(arguments, 1); ++ handler.apply(this, args); ++ } ++ } else if (isObject(handler)) { ++ args = Array.prototype.slice.call(arguments, 1); ++ listeners = handler.slice(); ++ len = listeners.length; ++ for (i = 0; i < len; i++) ++ listeners[i].apply(this, args); ++ } + +- lib$es6$promise$enumerator$$Enumerator.prototype._eachEntry = function(entry, i) { +- var c = this._instanceConstructor; +- var resolve = c.resolve; ++ return true; ++}; + +- if (resolve === lib$es6$promise$promise$resolve$$default) { +- var then = lib$es6$promise$$internal$$getThen(entry); ++EventEmitter.prototype.addListener = function(type, listener) { ++ var m; + +- if (then === lib$es6$promise$then$$default && +- entry._state !== lib$es6$promise$$internal$$PENDING) { +- this._settledAt(entry._state, i, entry._result); +- } else if (typeof then !== 'function') { +- this._remaining--; +- this._result[i] = entry; +- } else if (c === lib$es6$promise$promise$$default) { +- var promise = new c(lib$es6$promise$$internal$$noop); +- lib$es6$promise$$internal$$handleMaybeThenable(promise, entry, then); +- this._willSettleAt(promise, i); +- } else { +- this._willSettleAt(new c(function(resolve) { resolve(entry); }), i); +- } +- } else { +- this._willSettleAt(resolve(entry), i); +- } +- }; ++ if (!isFunction(listener)) ++ throw TypeError('listener must be a function'); + +- lib$es6$promise$enumerator$$Enumerator.prototype._settledAt = function(state, i, value) { +- var promise = this.promise; ++ if (!this._events) ++ this._events = {}; + +- if (promise._state === lib$es6$promise$$internal$$PENDING) { +- this._remaining--; ++ // To avoid recursion in the case that type === "newListener"! Before ++ // adding it to the listeners, first emit "newListener". ++ if (this._events.newListener) ++ this.emit('newListener', type, ++ isFunction(listener.listener) ? ++ listener.listener : listener); + +- if (state === lib$es6$promise$$internal$$REJECTED) { +- lib$es6$promise$$internal$$reject(promise, value); +- } else { +- this._result[i] = value; +- } +- } ++ if (!this._events[type]) ++ // Optimize the case of one listener. Don't need the extra array object. ++ this._events[type] = listener; ++ else if (isObject(this._events[type])) ++ // If we've already got an array, just append. ++ this._events[type].push(listener); ++ else ++ // Adding the second element, need to change to array. ++ this._events[type] = [this._events[type], listener]; + +- if (this._remaining === 0) { +- lib$es6$promise$$internal$$fulfill(promise, this._result); ++ // Check for listener leak ++ if (isObject(this._events[type]) && !this._events[type].warned) { ++ if (!isUndefined(this._maxListeners)) { ++ m = this._maxListeners; ++ } else { ++ m = EventEmitter.defaultMaxListeners; ++ } ++ ++ if (m && m > 0 && this._events[type].length > m) { ++ this._events[type].warned = true; ++ console.error('(node) warning: possible EventEmitter memory ' + ++ 'leak detected. %d listeners added. ' + ++ 'Use emitter.setMaxListeners() to increase limit.', ++ this._events[type].length); ++ if (typeof console.trace === 'function') { ++ // not supported in IE 10 ++ console.trace(); + } +- }; ++ } ++ } + +- lib$es6$promise$enumerator$$Enumerator.prototype._willSettleAt = function(promise, i) { +- var enumerator = this; ++ return this; ++}; + +- lib$es6$promise$$internal$$subscribe(promise, undefined, function(value) { +- enumerator._settledAt(lib$es6$promise$$internal$$FULFILLED, i, value); +- }, function(reason) { +- enumerator._settledAt(lib$es6$promise$$internal$$REJECTED, i, reason); +- }); +- }; +- function lib$es6$promise$polyfill$$polyfill() { +- var local; ++EventEmitter.prototype.on = EventEmitter.prototype.addListener; + +- if (typeof global !== 'undefined') { +- local = global; +- } else if (typeof self !== 'undefined') { +- local = self; +- } else { +- try { +- local = Function('return this')(); +- } catch (e) { +- throw new Error('polyfill failed because global object is unavailable in this environment'); +- } +- } ++EventEmitter.prototype.once = function(type, listener) { ++ if (!isFunction(listener)) ++ throw TypeError('listener must be a function'); + +- var P = local.Promise; ++ var fired = false; + +- if (P && Object.prototype.toString.call(P.resolve()) === '[object Promise]' && !P.cast) { +- return; ++ function g() { ++ this.removeListener(type, g); ++ ++ if (!fired) { ++ fired = true; ++ listener.apply(this, arguments); ++ } ++ } ++ ++ g.listener = listener; ++ this.on(type, g); ++ ++ return this; ++}; ++ ++// emits a 'removeListener' event iff the listener was removed ++EventEmitter.prototype.removeListener = function(type, listener) { ++ var list, position, length, i; ++ ++ if (!isFunction(listener)) ++ throw TypeError('listener must be a function'); ++ ++ if (!this._events || !this._events[type]) ++ return this; ++ ++ list = this._events[type]; ++ length = list.length; ++ position = -1; ++ ++ if (list === listener || ++ (isFunction(list.listener) && list.listener === listener)) { ++ delete this._events[type]; ++ if (this._events.removeListener) ++ this.emit('removeListener', type, listener); ++ ++ } else if (isObject(list)) { ++ for (i = length; i-- > 0;) { ++ if (list[i] === listener || ++ (list[i].listener && list[i].listener === listener)) { ++ position = i; ++ break; + } ++ } + +- local.Promise = lib$es6$promise$promise$$default; ++ if (position < 0) ++ return this; ++ ++ if (list.length === 1) { ++ list.length = 0; ++ delete this._events[type]; ++ } else { ++ list.splice(position, 1); + } +- var lib$es6$promise$polyfill$$default = lib$es6$promise$polyfill$$polyfill; + +- var lib$es6$promise$umd$$ES6Promise = { +- 'Promise': lib$es6$promise$promise$$default, +- 'polyfill': lib$es6$promise$polyfill$$default +- }; ++ if (this._events.removeListener) ++ this.emit('removeListener', type, listener); ++ } ++ ++ return this; ++}; ++ ++EventEmitter.prototype.removeAllListeners = function(type) { ++ var key, listeners; ++ ++ if (!this._events) ++ return this; + +- /* global define:true module:true window: true */ +- if (typeof define === 'function' && define['amd']) { +- define(function() { return lib$es6$promise$umd$$ES6Promise; }); +- } else if (typeof module !== 'undefined' && module['exports']) { +- module['exports'] = lib$es6$promise$umd$$ES6Promise; +- } else if (typeof this !== 'undefined') { +- this['ES6Promise'] = lib$es6$promise$umd$$ES6Promise; ++ // not listening for removeListener, no need to emit ++ if (!this._events.removeListener) { ++ if (arguments.length === 0) ++ this._events = {}; ++ else if (this._events[type]) ++ delete this._events[type]; ++ return this; ++ } ++ ++ // emit removeListener for all listeners on all events ++ if (arguments.length === 0) { ++ for (key in this._events) { ++ if (key === 'removeListener') continue; ++ this.removeAllListeners(key); + } ++ this.removeAllListeners('removeListener'); ++ this._events = {}; ++ return this; ++ } + +- lib$es6$promise$polyfill$$default(); +-}).call(this); ++ listeners = this._events[type]; + ++ if (isFunction(listeners)) { ++ this.removeListener(type, listeners); ++ } else if (listeners) { ++ // LIFO order ++ while (listeners.length) ++ this.removeListener(type, listeners[listeners.length - 1]); ++ } ++ delete this._events[type]; + +-}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +-},{"_process":8}],11:[function(require,module,exports){ ++ return this; ++}; ++ ++EventEmitter.prototype.listeners = function(type) { ++ var ret; ++ if (!this._events || !this._events[type]) ++ ret = []; ++ else if (isFunction(this._events[type])) ++ ret = [this._events[type]]; ++ else ++ ret = this._events[type].slice(); ++ return ret; ++}; ++ ++EventEmitter.prototype.listenerCount = function(type) { ++ if (this._events) { ++ var evlistener = this._events[type]; ++ ++ if (isFunction(evlistener)) ++ return 1; ++ else if (evlistener) ++ return evlistener.length; ++ } ++ return 0; ++}; ++ ++EventEmitter.listenerCount = function(emitter, type) { ++ return emitter.listenerCount(type); ++}; ++ ++function isFunction(arg) { ++ return typeof arg === 'function'; ++} ++ ++function isNumber(arg) { ++ return typeof arg === 'number'; ++} ++ ++function isObject(arg) { ++ return typeof arg === 'object' && arg !== null; ++} ++ ++function isUndefined(arg) { ++ return arg === void 0; ++} ++ ++},{}],10:[function(require,module,exports){ + /** + * inspired by is-number + * but significantly simplified and sped up by ignoring number and string constructors +@@ -11204,7 +11314,7 @@ module.exports = function(n) { + return n - n < 1; + }; + +-},{}],12:[function(require,module,exports){ ++},{}],11:[function(require,module,exports){ + module.exports = fromQuat; + + /** +@@ -11252,21 +11362,202 @@ function fromQuat(out, q) { + + return out; + }; ++},{}],12:[function(require,module,exports){ ++// shim for using process in browser ++var process = module.exports = {}; ++ ++// cached from whatever global is present so that test runners that stub it ++// don't break things. But we need to wrap it in a try catch in case it is ++// wrapped in strict mode code which doesn't define any globals. It's inside a ++// function because try/catches deoptimize in certain engines. ++ ++var cachedSetTimeout; ++var cachedClearTimeout; ++ ++function defaultSetTimout() { ++ throw new Error('setTimeout has not been defined'); ++} ++function defaultClearTimeout () { ++ throw new Error('clearTimeout has not been defined'); ++} ++(function () { ++ try { ++ if (typeof setTimeout === 'function') { ++ cachedSetTimeout = setTimeout; ++ } else { ++ cachedSetTimeout = defaultSetTimout; ++ } ++ } catch (e) { ++ cachedSetTimeout = defaultSetTimout; ++ } ++ try { ++ if (typeof clearTimeout === 'function') { ++ cachedClearTimeout = clearTimeout; ++ } else { ++ cachedClearTimeout = defaultClearTimeout; ++ } ++ } catch (e) { ++ cachedClearTimeout = defaultClearTimeout; ++ } ++} ()) ++function runTimeout(fun) { ++ if (cachedSetTimeout === setTimeout) { ++ //normal enviroments in sane situations ++ return setTimeout(fun, 0); ++ } ++ // if setTimeout wasn't available but was latter defined ++ if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { ++ cachedSetTimeout = setTimeout; ++ return setTimeout(fun, 0); ++ } ++ try { ++ // when when somebody has screwed with setTimeout but no I.E. maddness ++ return cachedSetTimeout(fun, 0); ++ } catch(e){ ++ try { ++ // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally ++ return cachedSetTimeout.call(null, fun, 0); ++ } catch(e){ ++ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error ++ return cachedSetTimeout.call(this, fun, 0); ++ } ++ } ++ ++ ++} ++function runClearTimeout(marker) { ++ if (cachedClearTimeout === clearTimeout) { ++ //normal enviroments in sane situations ++ return clearTimeout(marker); ++ } ++ // if clearTimeout wasn't available but was latter defined ++ if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { ++ cachedClearTimeout = clearTimeout; ++ return clearTimeout(marker); ++ } ++ try { ++ // when when somebody has screwed with setTimeout but no I.E. maddness ++ return cachedClearTimeout(marker); ++ } catch (e){ ++ try { ++ // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally ++ return cachedClearTimeout.call(null, marker); ++ } catch (e){ ++ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. ++ // Some versions of I.E. have different rules for clearTimeout vs setTimeout ++ return cachedClearTimeout.call(this, marker); ++ } ++ } ++ ++ ++ ++} ++var queue = []; ++var draining = false; ++var currentQueue; ++var queueIndex = -1; ++ ++function cleanUpNextTick() { ++ if (!draining || !currentQueue) { ++ return; ++ } ++ draining = false; ++ if (currentQueue.length) { ++ queue = currentQueue.concat(queue); ++ } else { ++ queueIndex = -1; ++ } ++ if (queue.length) { ++ drainQueue(); ++ } ++} ++ ++function drainQueue() { ++ if (draining) { ++ return; ++ } ++ var timeout = runTimeout(cleanUpNextTick); ++ draining = true; ++ ++ var len = queue.length; ++ while(len) { ++ currentQueue = queue; ++ queue = []; ++ while (++queueIndex < len) { ++ if (currentQueue) { ++ currentQueue[queueIndex].run(); ++ } ++ } ++ queueIndex = -1; ++ len = queue.length; ++ } ++ currentQueue = null; ++ draining = false; ++ runClearTimeout(timeout); ++} ++ ++process.nextTick = function (fun) { ++ var args = new Array(arguments.length - 1); ++ if (arguments.length > 1) { ++ for (var i = 1; i < arguments.length; i++) { ++ args[i - 1] = arguments[i]; ++ } ++ } ++ queue.push(new Item(fun, args)); ++ if (queue.length === 1 && !draining) { ++ runTimeout(drainQueue); ++ } ++}; ++ ++// v8 likes predictible objects ++function Item(fun, array) { ++ this.fun = fun; ++ this.array = array; ++} ++Item.prototype.run = function () { ++ this.fun.apply(null, this.array); ++}; ++process.title = 'browser'; ++process.browser = true; ++process.env = {}; ++process.argv = []; ++process.version = ''; // empty string to avoid regexp issues ++process.versions = {}; ++ ++function noop() {} ++ ++process.on = noop; ++process.addListener = noop; ++process.once = noop; ++process.off = noop; ++process.removeListener = noop; ++process.removeAllListeners = noop; ++process.emit = noop; ++ ++process.binding = function (name) { ++ throw new Error('process.binding is not supported'); ++}; ++ ++process.cwd = function () { return '/' }; ++process.chdir = function (dir) { ++ throw new Error('process.chdir is not supported'); ++}; ++process.umask = function() { return 0; }; ++ + },{}],13:[function(require,module,exports){ +-// TinyColor v1.3.0 ++// TinyColor v1.4.1 + // https://github.com/bgrins/TinyColor + // Brian Grinstead, MIT License + +-(function() { ++(function(Math) { + + var trimLeft = /^\s+/, + trimRight = /\s+$/, + tinyCounter = 0, +- math = Math, +- mathRound = math.round, +- mathMin = math.min, +- mathMax = math.max, +- mathRandom = math.random; ++ mathRound = Math.round, ++ mathMin = Math.min, ++ mathMax = Math.max, ++ mathRandom = Math.random; + + function tinycolor (color, opts) { + +@@ -11374,11 +11665,11 @@ tinycolor.prototype = { + toHexString: function(allow3Char) { + return '#' + this.toHex(allow3Char); + }, +- toHex8: function() { +- return rgbaToHex(this._r, this._g, this._b, this._a); ++ toHex8: function(allow4Char) { ++ return rgbaToHex(this._r, this._g, this._b, this._a, allow4Char); + }, +- toHex8String: function() { +- return '#' + this.toHex8(); ++ toHex8String: function(allow4Char) { ++ return '#' + this.toHex8(allow4Char); + }, + toRgb: function() { + return { r: mathRound(this._r), g: mathRound(this._g), b: mathRound(this._b), a: this._a }; +@@ -11408,13 +11699,13 @@ tinycolor.prototype = { + return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false; + }, + toFilter: function(secondColor) { +- var hex8String = '#' + rgbaToHex(this._r, this._g, this._b, this._a); ++ var hex8String = '#' + rgbaToArgbHex(this._r, this._g, this._b, this._a); + var secondHex8String = hex8String; + var gradientType = this._gradientType ? "GradientType = 1, " : ""; + + if (secondColor) { + var s = tinycolor(secondColor); +- secondHex8String = s.toHex8String(); ++ secondHex8String = '#' + rgbaToArgbHex(s._r, s._g, s._b, s._a); + } + + return "progid:DXImageTransform.Microsoft.gradient("+gradientType+"startColorstr="+hex8String+",endColorstr="+secondHex8String+")"; +@@ -11425,7 +11716,7 @@ tinycolor.prototype = { + + var formattedString = false; + var hasAlpha = this._a < 1 && this._a >= 0; +- var needsAlphaFormat = !formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "name"); ++ var needsAlphaFormat = !formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "hex4" || format === "hex8" || format === "name"); + + if (needsAlphaFormat) { + // Special case for "transparent", all other non-alpha formats +@@ -11447,6 +11738,9 @@ tinycolor.prototype = { + if (format === "hex3") { + formattedString = this.toHexString(true); + } ++ if (format === "hex4") { ++ formattedString = this.toHex8String(true); ++ } + if (format === "hex8") { + formattedString = this.toHex8String(); + } +@@ -11559,6 +11853,9 @@ function inputToRGB(color) { + + var rgb = { r: 0, g: 0, b: 0 }; + var a = 1; ++ var s = null; ++ var v = null; ++ var l = null; + var ok = false; + var format = false; + +@@ -11567,22 +11864,22 @@ function inputToRGB(color) { + } + + if (typeof color == "object") { +- if (color.hasOwnProperty("r") && color.hasOwnProperty("g") && color.hasOwnProperty("b")) { ++ if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) { + rgb = rgbToRgb(color.r, color.g, color.b); + ok = true; + format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb"; + } +- else if (color.hasOwnProperty("h") && color.hasOwnProperty("s") && color.hasOwnProperty("v")) { +- color.s = convertToPercentage(color.s); +- color.v = convertToPercentage(color.v); +- rgb = hsvToRgb(color.h, color.s, color.v); ++ else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) { ++ s = convertToPercentage(color.s); ++ v = convertToPercentage(color.v); ++ rgb = hsvToRgb(color.h, s, v); + ok = true; + format = "hsv"; + } +- else if (color.hasOwnProperty("h") && color.hasOwnProperty("s") && color.hasOwnProperty("l")) { +- color.s = convertToPercentage(color.s); +- color.l = convertToPercentage(color.l); +- rgb = hslToRgb(color.h, color.s, color.l); ++ else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) { ++ s = convertToPercentage(color.s); ++ l = convertToPercentage(color.l); ++ rgb = hslToRgb(color.h, s, l); + ok = true; + format = "hsl"; + } +@@ -11729,7 +12026,7 @@ function rgbToHsv(r, g, b) { + s = bound01(s, 100); + v = bound01(v, 100); + +- var i = math.floor(h), ++ var i = Math.floor(h), + f = h - i, + p = v * (1 - s), + q = v * (1 - f * s), +@@ -11764,9 +12061,29 @@ function rgbToHex(r, g, b, allow3Char) { + + // `rgbaToHex` + // Converts an RGBA color plus alpha transparency to hex +-// Assumes r, g, b and a are contained in the set [0, 255] +-// Returns an 8 character hex +-function rgbaToHex(r, g, b, a) { ++// Assumes r, g, b are contained in the set [0, 255] and ++// a in [0, 1]. Returns a 4 or 8 character rgba hex ++function rgbaToHex(r, g, b, a, allow4Char) { ++ ++ var hex = [ ++ pad2(mathRound(r).toString(16)), ++ pad2(mathRound(g).toString(16)), ++ pad2(mathRound(b).toString(16)), ++ pad2(convertDecimalToHex(a)) ++ ]; ++ ++ // Return a 4 character hex if possible ++ if (allow4Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1) && hex[3].charAt(0) == hex[3].charAt(1)) { ++ return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0); ++ } ++ ++ return hex.join(""); ++} ++ ++// `rgbaToArgbHex` ++// Converts an RGBA color to an ARGB Hex8 string ++// Rarely used, but required for "toFilter()" ++function rgbaToArgbHex(r, g, b, a) { + + var hex = [ + pad2(convertDecimalToHex(a)), +@@ -11848,7 +12165,7 @@ function darken (color, amount) { + // Values outside of this range will be wrapped into this range. + function spin(color, amount) { + var hsl = tinycolor(color).toHsl(); +- var hue = (mathRound(hsl.h) + amount) % 360; ++ var hue = (hsl.h + amount) % 360; + hsl.h = hue < 0 ? 360 + hue : hue; + return tinycolor(hsl); + } +@@ -11935,26 +12252,12 @@ tinycolor.mix = function(color1, color2, amount) { + var rgb2 = tinycolor(color2).toRgb(); + + var p = amount / 100; +- var w = p * 2 - 1; +- var a = rgb2.a - rgb1.a; +- +- var w1; +- +- if (w * a == -1) { +- w1 = w; +- } else { +- w1 = (w + a) / (1 + w * a); +- } +- +- w1 = (w1 + 1) / 2; +- +- var w2 = 1 - w1; + + var rgba = { +- r: rgb2.r * w1 + rgb1.r * w2, +- g: rgb2.g * w1 + rgb1.g * w2, +- b: rgb2.b * w1 + rgb1.b * w2, +- a: rgb2.a * p + rgb1.a * (1 - p) ++ r: ((rgb2.r - rgb1.r) * p) + rgb1.r, ++ g: ((rgb2.g - rgb1.g) * p) + rgb1.g, ++ b: ((rgb2.b - rgb1.b) * p) + rgb1.b, ++ a: ((rgb2.a - rgb1.a) * p) + rgb1.a + }; + + return tinycolor(rgba); +@@ -12240,7 +12543,7 @@ function bound01(n, max) { + } + + // Handle floating point rounding errors +- if ((math.abs(n - max) < 0.000001)) { ++ if ((Math.abs(n - max) < 0.000001)) { + return 1; + } + +@@ -12310,6 +12613,7 @@ var matchers = (function() { + var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?"; + + return { ++ CSS_UNIT: new RegExp(CSS_UNIT), + rgb: new RegExp("rgb" + PERMISSIVE_MATCH3), + rgba: new RegExp("rgba" + PERMISSIVE_MATCH4), + hsl: new RegExp("hsl" + PERMISSIVE_MATCH3), +@@ -12318,10 +12622,18 @@ var matchers = (function() { + hsva: new RegExp("hsva" + PERMISSIVE_MATCH4), + hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/, + hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/, ++ hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/, + hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/ + }; + })(); + ++// `isValidCSSUnit` ++// Take in a single string / number and check to see if it looks like a CSS unit ++// (see `matchers` above for definition). ++function isValidCSSUnit(color) { ++ return !!matchers.CSS_UNIT.exec(color); ++} ++ + // `stringInputToObject` + // Permissive string parsing. Take in a number of formats, and output an object + // based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}` +@@ -12362,10 +12674,10 @@ function stringInputToObject(color) { + } + if ((match = matchers.hex8.exec(color))) { + return { +- a: convertHexToDecimal(match[1]), +- r: parseIntFromHex(match[2]), +- g: parseIntFromHex(match[3]), +- b: parseIntFromHex(match[4]), ++ r: parseIntFromHex(match[1]), ++ g: parseIntFromHex(match[2]), ++ b: parseIntFromHex(match[3]), ++ a: convertHexToDecimal(match[4]), + format: named ? "name" : "hex8" + }; + } +@@ -12377,6 +12689,15 @@ function stringInputToObject(color) { + format: named ? "name" : "hex" + }; + } ++ if ((match = matchers.hex4.exec(color))) { ++ return { ++ r: parseIntFromHex(match[1] + '' + match[1]), ++ g: parseIntFromHex(match[2] + '' + match[2]), ++ b: parseIntFromHex(match[3] + '' + match[3]), ++ a: convertHexToDecimal(match[4] + '' + match[4]), ++ format: named ? "name" : "hex8" ++ }; ++ } + if ((match = matchers.hex3.exec(color))) { + return { + r: parseIntFromHex(match[1] + '' + match[1]), +@@ -12418,7 +12739,7 @@ else { + window.tinycolor = tinycolor; + } + +-})(); ++})(Math); + + },{}],14:[function(require,module,exports){ + /** +@@ -13684,7 +14005,7 @@ function lineIntersect(x1, y1, x2, y2, x3, y3, x4, y4) { + return {x: x1 + a * t, y: y1 + d * t}; + } + +-},{"../../lib":94,"../../lib/setcursor":103,"../../lib/svg_text_utils":105,"../../plotly":112,"../../plots/cartesian/axes":115,"../color":18,"../dragelement":39,"../drawing":41,"./arrow_paths":14,"./attributes":15,"d3":9,"fast-isnumeric":11}],17:[function(require,module,exports){ ++},{"../../lib":94,"../../lib/setcursor":103,"../../lib/svg_text_utils":105,"../../plotly":112,"../../plots/cartesian/axes":115,"../color":18,"../dragelement":39,"../drawing":41,"./arrow_paths":14,"./attributes":15,"d3":7,"fast-isnumeric":10}],17:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -13878,7 +14199,7 @@ function cleanOne(val) { + return 'rgb(' + rgbStr + ')'; + } + +-},{"./attributes":17,"fast-isnumeric":11,"tinycolor2":13}],19:[function(require,module,exports){ ++},{"./attributes":17,"fast-isnumeric":10,"tinycolor2":13}],19:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -14730,7 +15051,7 @@ module.exports = function draw(gd, id) { + return component; + }; + +-},{"../../lib":94,"../../lib/extend":93,"../../lib/setcursor":103,"../../plotly":112,"../../plots/cartesian/axes":115,"../../plots/cartesian/axis_defaults":116,"../../plots/cartesian/layout_attributes":124,"../../plots/cartesian/position_defaults":127,"../../plots/plots":135,"../color":18,"../dragelement":39,"../drawing":41,"../titles":81,"./attributes":19,"d3":9,"tinycolor2":13}],22:[function(require,module,exports){ ++},{"../../lib":94,"../../lib/extend":93,"../../lib/setcursor":103,"../../plotly":112,"../../plots/cartesian/axes":115,"../../plots/cartesian/axis_defaults":116,"../../plots/cartesian/layout_attributes":124,"../../plots/cartesian/position_defaults":127,"../../plots/plots":135,"../color":18,"../dragelement":39,"../drawing":41,"../titles":81,"./attributes":19,"d3":7,"tinycolor2":13}],22:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -15015,7 +15336,7 @@ module.exports = function colorScaleDefaults(traceIn, traceOut, layout, coerce, + if(showScale) colorbarDefaults(containerIn, containerOut, layout); + }; + +-},{"../../lib":94,"../colorbar/defaults":20,"../colorbar/has_colorbar":22,"./flip_scale":29,"./is_valid_scale":33,"fast-isnumeric":11}],29:[function(require,module,exports){ ++},{"../../lib":94,"../colorbar/defaults":20,"../colorbar/has_colorbar":22,"./flip_scale":29,"./is_valid_scale":33,"fast-isnumeric":10}],29:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -15126,7 +15447,7 @@ module.exports = function hasColorscale(trace, containerStr) { + ); + }; + +-},{"../../lib":94,"./is_valid_scale":33,"fast-isnumeric":11}],32:[function(require,module,exports){ ++},{"../../lib":94,"./is_valid_scale":33,"fast-isnumeric":10}],32:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -15265,7 +15586,7 @@ module.exports = function makeScaleFunction(scl, cmin, cmax) { + }; + }; + +-},{"../../lib":94,"../color":18,"d3":9,"fast-isnumeric":11,"tinycolor2":13}],36:[function(require,module,exports){ ++},{"../../lib":94,"../color":18,"d3":7,"fast-isnumeric":10,"tinycolor2":13}],36:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -16267,7 +16588,7 @@ drawing.setClipUrl = function(s, localId) { + s.attr('clip-path', 'url(' + url + ')'); + }; + +-},{"../../constants/xmlns_namespaces":87,"../../lib":94,"../../lib/svg_text_utils":105,"../../plots/plots":135,"../../traces/scatter/make_bubble_size_func":186,"../../traces/scatter/subtypes":191,"../color":18,"../colorscale":32,"./symbol_defs":42,"d3":9,"fast-isnumeric":11}],42:[function(require,module,exports){ ++},{"../../constants/xmlns_namespaces":87,"../../lib":94,"../../lib/svg_text_utils":105,"../../plots/plots":135,"../../traces/scatter/make_bubble_size_func":186,"../../traces/scatter/subtypes":191,"../color":18,"../colorscale":32,"./symbol_defs":42,"d3":7,"fast-isnumeric":10}],42:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -16743,7 +17064,7 @@ module.exports = { + } + }; + +-},{"d3":9}],43:[function(require,module,exports){ ++},{"d3":7}],43:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -16905,7 +17226,7 @@ function calcOneAxis(calcTrace, trace, axis, coord) { + Axes.expand(axis, vals, {padded: true}); + } + +-},{"../../plots/cartesian/axes":115,"../../plots/plots":135,"./compute_error":45,"fast-isnumeric":11}],45:[function(require,module,exports){ ++},{"../../plots/cartesian/axes":115,"../../plots/plots":135,"./compute_error":45,"fast-isnumeric":10}],45:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -17078,7 +17399,7 @@ module.exports = function(traceIn, traceOut, defaultColor, opts) { + } + }; + +-},{"../../lib":94,"../../plots/plots":135,"./attributes":43,"fast-isnumeric":11}],47:[function(require,module,exports){ ++},{"../../lib":94,"../../plots/plots":135,"./attributes":43,"fast-isnumeric":10}],47:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -17258,7 +17579,7 @@ function errorCoords(d, xa, ya) { + return out; + } + +-},{"../../lib":94,"../../traces/scatter/subtypes":191,"d3":9,"fast-isnumeric":11}],49:[function(require,module,exports){ ++},{"../../lib":94,"../../traces/scatter/subtypes":191,"d3":7,"fast-isnumeric":10}],49:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -17295,7 +17616,7 @@ module.exports = function style(traces) { + }); + }; + +-},{"../color":18,"d3":9}],50:[function(require,module,exports){ ++},{"../color":18,"d3":7}],50:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -17649,7 +17970,7 @@ module.exports = function draw(gd) { + imagesAbove.each(applyAttributes); + }; + +-},{"../../plots/cartesian/axes":115,"../drawing":41,"d3":9}],53:[function(require,module,exports){ ++},{"../../plots/cartesian/axes":115,"../drawing":41,"d3":7}],53:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -17766,6 +18087,13 @@ module.exports = { + + + }, ++ horizontalspacing: { ++ valType: 'enumerated', ++ values: ['column', 'wrapped'], ++ dflt: ['column'], ++ ++ ++ }, + traceorder: { + valType: 'flaglist', + flags: ['reversed', 'grouped'], +@@ -17855,6 +18183,7 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { + + var visibleTraces = 0, + defaultOrder = 'normal', ++ defaultHorizontalSpacing = 'column', + defaultX, + defaultY, + defaultXAnchor, +@@ -17919,6 +18248,7 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { + coerce('xanchor', defaultXAnchor); + coerce('y', defaultY); + coerce('yanchor', defaultYAnchor); ++ coerce('horizontalspacing', defaultHorizontalSpacing); + Lib.noneOrAll(containerIn, containerOut, ['x', 'y']); + }; + +@@ -18399,7 +18729,8 @@ function computeLegendDimensions(gd, groups, traces) { + var fullLayout = gd._fullLayout, + opts = fullLayout.legend, + borderwidth = opts.borderwidth, +- isGrouped = helpers.isGrouped(opts); ++ isGrouped = helpers.isGrouped(opts), ++ isHorizontalColumn = helpers.isHorizontalColumn(opts); + + if(helpers.isVertical(opts)) { + if(isGrouped) { +@@ -18506,7 +18837,7 @@ function computeLegendDimensions(gd, groups, traces) { + traces.each(function(d) { + + var legendItem = d[0], +- traceWidth = maxTraceWidth, ++ traceWidth = isHorizontalColumn ? maxTraceWidth : 40 + d[0], + traceGap = opts.tracegroupgap || 5; + + if((borderwidth + offsetX + traceGap + traceWidth) > (fullLayout.width - (fullLayout.margin.r + fullLayout.margin.l))) { +@@ -18595,7 +18926,7 @@ function expandHorizontalMargin(gd) { + }); + } + +-},{"../../lib":94,"../../plotly":112,"../../plots/plots":135,"../color":18,"../dragelement":39,"../drawing":41,"./anchor_utils":54,"./constants":56,"./get_legend_data":59,"./helpers":60,"./style":62,"d3":9}],59:[function(require,module,exports){ ++},{"../../lib":94,"../../plotly":112,"../../plots/plots":135,"../color":18,"../dragelement":39,"../drawing":41,"./anchor_utils":54,"./constants":56,"./get_legend_data":59,"./helpers":60,"./style":62,"d3":7}],59:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -18732,6 +19063,9 @@ exports.isReversed = function isReversed(legendLayout) { + return (legendLayout.traceorder || '').indexOf('reversed') !== -1; + }; + ++exports.isHorizontalColumn = function isReversed(legendLayout) { ++ return legendLayout.horizontalspacing === 'column'; ++}; + },{"../../plots/plots":135}],61:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. +@@ -18977,7 +19311,7 @@ function stylePies(d) { + if(pts.size()) pts.call(stylePie, d[0], trace); + } + +-},{"../../lib":94,"../../plots/plots":135,"../../traces/pie/style_one":170,"../../traces/scatter/subtypes":191,"../color":18,"../drawing":41,"d3":9}],63:[function(require,module,exports){ ++},{"../../lib":94,"../../plots/plots":135,"../../traces/pie/style_one":170,"../../traces/scatter/subtypes":191,"../color":18,"../drawing":41,"d3":7}],63:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -19775,7 +20109,7 @@ function createModeBar(gd, buttons) { + + module.exports = createModeBar; + +-},{"../../../build/ploticon":2,"../../lib":94,"d3":9}],65:[function(require,module,exports){ ++},{"../../../build/ploticon":2,"../../lib":94,"d3":7}],65:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -20529,7 +20863,7 @@ function reposition(gd, buttons, opts, axName) { + }); + } + +-},{"../../lib/svg_text_utils":105,"../../plotly":112,"../../plots/cartesian/axis_ids":117,"../../plots/plots":135,"../color":18,"../drawing":41,"../legend/anchor_utils":54,"./constants":68,"./get_update_object":71,"d3":9}],71:[function(require,module,exports){ ++},{"../../lib/svg_text_utils":105,"../../plotly":112,"../../plots/cartesian/axis_ids":117,"../../plots/plots":135,"../color":18,"../drawing":41,"../legend/anchor_utils":54,"./constants":68,"./get_update_object":71,"d3":7}],71:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -20587,7 +20921,7 @@ function getXRange(axisLayout, buttonLayout) { + return [range0, range1]; + } + +-},{"d3":9}],72:[function(require,module,exports){ ++},{"d3":7}],72:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -21276,7 +21610,7 @@ function makeScatter(trace, pointPairs, w, h) { + return [line, markers, fill]; + } + +-},{"../../constants/xmlns_namespaces":87,"../../lib":94,"../drawing":41,"../drawing/symbol_defs":42,"./helpers":76,"d3":9}],79:[function(require,module,exports){ ++},{"../../constants/xmlns_namespaces":87,"../../lib":94,"../drawing":41,"../drawing/symbol_defs":42,"./helpers":76,"d3":7}],79:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -22157,7 +22491,7 @@ function shapeBounds(ax, v0, v1, path, paramsToUse) { + if(max >= min) return [min, max]; + } + +-},{"../../lib":94,"../../lib/setcursor":103,"../../plotly":112,"../../plots/cartesian/axes":115,"../color":18,"../dragelement":39,"../drawing":41,"./attributes":79,"fast-isnumeric":11}],81:[function(require,module,exports){ ++},{"../../lib":94,"../../lib/setcursor":103,"../../plotly":112,"../../plots/cartesian/axes":115,"../color":18,"../dragelement":39,"../drawing":41,"./attributes":79,"fast-isnumeric":10}],81:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -22387,7 +22721,7 @@ Titles.draw = function(gd, titleClass, options) { + el.classed('js-placeholder', isplaceholder); + }; + +-},{"../../lib":94,"../../lib/svg_text_utils":105,"../../plotly":112,"../../plots/plots":135,"../color":18,"../drawing":41,"d3":9,"fast-isnumeric":11}],82:[function(require,module,exports){ ++},{"../../lib":94,"../../lib/svg_text_utils":105,"../../plotly":112,"../../plots/plots":135,"../color":18,"../drawing":41,"d3":7,"fast-isnumeric":10}],82:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -23135,7 +23469,7 @@ function clearPushMargins(gd) { + } + } + +-},{"../../lib":94,"../../lib/svg_text_utils":105,"../../plotly":112,"../../plots/plots":135,"../color":18,"../drawing":41,"../legend/anchor_utils":54,"./constants":83,"d3":9}],86:[function(require,module,exports){ ++},{"../../lib":94,"../../lib/svg_text_utils":105,"../../plotly":112,"../../plots/plots":135,"../color":18,"../drawing":41,"../legend/anchor_utils":54,"./constants":83,"d3":7}],86:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -23228,7 +23562,7 @@ exports.Queue = Plotly.Queue; + // export d3 used in the bundle + exports.d3 = require('d3'); + +-},{"../build/ploticon":2,"./plot_api/set_plot_config":109,"./plot_api/to_image":110,"./plot_api/validate":111,"./plotly":112,"./snapshot/download":142,"d3":9}],89:[function(require,module,exports){ ++},{"../build/ploticon":2,"./plot_api/set_plot_config":109,"./plot_api/to_image":110,"./plot_api/validate":111,"./plotly":112,"./snapshot/download":142,"d3":7}],89:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -23571,7 +23905,7 @@ exports.validate = function(value, opts) { + return out !== failed; + }; + +-},{"../components/colorscale/get_scale":30,"../components/colorscale/scales":36,"./nested_property":98,"fast-isnumeric":11,"tinycolor2":13}],91:[function(require,module,exports){ ++},{"../components/colorscale/get_scale":30,"../components/colorscale/scales":36,"./nested_property":98,"fast-isnumeric":10,"tinycolor2":13}],91:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -23910,7 +24244,7 @@ exports.parseDate = function(v) { + return out; + }; + +-},{"../lib":94,"d3":9,"fast-isnumeric":11}],92:[function(require,module,exports){ ++},{"../lib":94,"d3":7,"fast-isnumeric":10}],92:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -24044,7 +24378,7 @@ var Events = { + + module.exports = Events; + +-},{"events":7}],93:[function(require,module,exports){ ++},{"events":9}],93:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -24778,7 +25112,7 @@ lib.numSeparate = function(value, separators) { + return x1 + x2; + }; + +-},{"./coerce":90,"./dates":91,"./extend":93,"./is_plain_object":95,"./loggers":96,"./matrix":97,"./nested_property":98,"./notifier":99,"./search":102,"./stats":104,"d3":9}],95:[function(require,module,exports){ ++},{"./coerce":90,"./dates":91,"./extend":93,"./is_plain_object":95,"./loggers":96,"./matrix":97,"./nested_property":98,"./notifier":99,"./search":102,"./stats":104,"d3":7}],95:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -25240,7 +25574,7 @@ function badContainer(container, propStr, propParts) { + }; + } + +-},{"fast-isnumeric":11}],99:[function(require,module,exports){ ++},{"fast-isnumeric":10}],99:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -25317,7 +25651,7 @@ module.exports = function(text, displayLength) { + }); + }; + +-},{"d3":9,"fast-isnumeric":11}],100:[function(require,module,exports){ ++},{"d3":7,"fast-isnumeric":10}],100:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -25880,7 +26214,7 @@ exports.roundUp = function(val, arrayIn, reverse) { + return arrayIn[low]; + }; + +-},{"../lib":94,"fast-isnumeric":11}],103:[function(require,module,exports){ ++},{"../lib":94,"fast-isnumeric":10}],103:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -25999,7 +26333,7 @@ exports.interp = function(arr, n) { + return frac * arr[Math.ceil(n)] + (1 - frac) * arr[Math.floor(n)]; + }; + +-},{"fast-isnumeric":11}],105:[function(require,module,exports){ ++},{"fast-isnumeric":10}],105:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -26500,7 +26834,7 @@ util.makeEditable = function(context, _delegate, options) { + return d3.rebind(this, dispatch, 'on'); + }; + +-},{"../constants/xmlns_namespaces":87,"../lib":94,"../plotly":112,"d3":9}],106:[function(require,module,exports){ ++},{"../constants/xmlns_namespaces":87,"../lib":94,"../plotly":112,"d3":7}],106:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -29615,7 +29949,7 @@ function drawMainTitle(gd) { + }); + } + +-},{"../components/color":18,"../components/drawing":41,"../components/errorbars":47,"../components/images":53,"../components/legend":61,"../components/modebar/manage":65,"../components/rangeselector":72,"../components/rangeslider":77,"../components/shapes":80,"../components/titles":81,"../components/updatemenus":86,"../constants/xmlns_namespaces":87,"../lib":94,"../lib/events":92,"../lib/queue":101,"../plotly":112,"../plots/cartesian/graph_interact":122,"../plots/plots":135,"d3":9,"fast-isnumeric":11,"gl-mat4/fromQuat":12}],107:[function(require,module,exports){ ++},{"../components/color":18,"../components/drawing":41,"../components/errorbars":47,"../components/images":53,"../components/legend":61,"../components/modebar/manage":65,"../components/rangeselector":72,"../components/rangeslider":77,"../components/shapes":80,"../components/titles":81,"../components/updatemenus":86,"../constants/xmlns_namespaces":87,"../lib":94,"../lib/events":92,"../lib/queue":101,"../plotly":112,"../plots/cartesian/graph_interact":122,"../plots/plots":135,"d3":7,"fast-isnumeric":10,"gl-mat4/fromQuat":11}],107:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -30203,7 +30537,7 @@ function toImage(gd, opts) { + + module.exports = toImage; + +-},{"../lib":94,"../plotly":112,"../snapshot":144,"fast-isnumeric":11}],111:[function(require,module,exports){ ++},{"../lib":94,"../plotly":112,"../snapshot":144,"fast-isnumeric":10}],111:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -30691,7 +31025,7 @@ exports.PlotSchema = require('./plot_api/plot_schema'); + // imaging routines + exports.Snapshot = require('./snapshot'); + +-},{"../build/plotcss":1,"./components/annotations":16,"./components/color":18,"./components/colorbar":23,"./components/colorscale":32,"./components/drawing":41,"./components/errorbars":47,"./components/images":53,"./components/legend":61,"./components/modebar":64,"./components/shapes":80,"./components/updatemenus":86,"./fonts/mathjax_config":89,"./lib":94,"./lib/queue":101,"./lib/svg_text_utils":105,"./plot_api/plot_api":106,"./plot_api/plot_config":107,"./plot_api/plot_schema":108,"./plots/cartesian/axes":115,"./plots/cartesian/graph_interact":122,"./plots/plots":135,"./plots/polar/micropolar":138,"./snapshot":144,"./traces/scatter":182,"es6-promise":10}],113:[function(require,module,exports){ ++},{"../build/plotcss":1,"./components/annotations":16,"./components/color":18,"./components/colorbar":23,"./components/colorscale":32,"./components/drawing":41,"./components/errorbars":47,"./components/images":53,"./components/legend":61,"./components/modebar":64,"./components/shapes":80,"./components/updatemenus":86,"./fonts/mathjax_config":89,"./lib":94,"./lib/queue":101,"./lib/svg_text_utils":105,"./plot_api/plot_api":106,"./plot_api/plot_config":107,"./plot_api/plot_schema":108,"./plots/cartesian/axes":115,"./plots/cartesian/graph_interact":122,"./plots/plots":135,"./plots/polar/micropolar":138,"./snapshot":144,"./traces/scatter":182,"es6-promise":8}],113:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -30974,14 +31308,27 @@ axes.getAutoRange = function(ax) { + } + + if(minmin === maxmax) { +- newRange = axReverse ? +- [minmin + 1, ax.rangemode !== 'normal' ? 0 : minmin - 1] : +- [ax.rangemode !== 'normal' ? 0 : minmin - 1, minmin + 1]; ++ var lower = minmin - 1; ++ var upper = minmin + 1; ++ if(ax.rangemode === 'tozero') { ++ newRange = minmin < 0 ? [lower, 0] : [0, upper]; ++ } ++ else if(ax.rangemode === 'nonnegative') { ++ newRange = [Math.max(0, lower), Math.max(0, upper)]; ++ } ++ else { ++ newRange = [lower, upper]; ++ } + } + else if(mbest) { + if(ax.type === 'linear' || ax.type === '-') { +- if(ax.rangemode === 'tozero' && minbest.val >= 0) { +- minbest = {val: 0, pad: 0}; ++ if(ax.rangemode === 'tozero') { ++ if(minbest.val >= 0) { ++ minbest = {val: 0, pad: 0}; ++ } ++ if(maxbest.val <= 0) { ++ maxbest = {val: 0, pad: 0}; ++ } + } + else if(ax.rangemode === 'nonnegative') { + if(minbest.val - mbest * minbest.pad < 0) { +@@ -30995,22 +31342,39 @@ axes.getAutoRange = function(ax) { + // in case it changed again... + mbest = (maxbest.val - minbest.val) / + (ax._length - minbest.pad - maxbest.pad); ++ + } + + newRange = [ + minbest.val - mbest * minbest.pad, + maxbest.val + mbest * maxbest.pad + ]; ++ } + +- // don't let axis have zero size +- if(newRange[0] === newRange[1]) { ++ // don't let axis have zero size, while still respecting tozero and nonnegative ++ if(newRange[0] === newRange[1]) { ++ if(ax.rangemode === 'tozero') { ++ if(newRange[0] < 0) { ++ newRange = [newRange[0], 0]; ++ } ++ else if(newRange[0] > 0) { ++ newRange = [0, newRange[0]]; ++ } ++ else { ++ newRange = [0, 1]; ++ } ++ } ++ else { + newRange = [newRange[0] - 1, newRange[0] + 1]; ++ if(ax.rangemode === 'nonnegative') { ++ newRange[0] = Math.max(0, newRange[0]); ++ } + } ++ } + +- // maintain reversal +- if(axReverse) { +- newRange.reverse(); +- } ++ // maintain reversal ++ if(axReverse) { ++ newRange.reverse(); + } + + return newRange; +@@ -32793,7 +33157,7 @@ function swapAxisAttrs(layout, key, xFullAxes, yFullAxes) { + // rather than built-in % which gives a negative value for negative v + function mod(v, d) { return ((v % d) + d) % d; } + +-},{"../../components/color":18,"../../components/drawing":41,"../../components/titles":81,"../../lib":94,"../../lib/svg_text_utils":105,"../../plotly":112,"./axis_ids":117,"./layout_attributes":124,"./layout_defaults":125,"./set_convert":129,"d3":9,"fast-isnumeric":11}],116:[function(require,module,exports){ ++},{"../../components/color":18,"../../components/drawing":41,"../../components/titles":81,"../../lib":94,"../../lib/svg_text_utils":105,"../../plotly":112,"./axis_ids":117,"./layout_attributes":124,"./layout_defaults":125,"./set_convert":129,"d3":7,"fast-isnumeric":10}],116:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -33076,7 +33440,7 @@ function category(a) { + return curvecats > curvenums * 2; + } + +-},{"../../components/color/attributes":17,"../../lib":94,"../plots":135,"./axis_ids":117,"./category_order_defaults":118,"./clean_datum":119,"./layout_attributes":124,"./ordered_categories":126,"./set_convert":129,"./tick_label_defaults":130,"./tick_mark_defaults":131,"./tick_value_defaults":132,"fast-isnumeric":11,"tinycolor2":13}],117:[function(require,module,exports){ ++},{"../../components/color/attributes":17,"../../lib":94,"../plots":135,"./axis_ids":117,"./category_order_defaults":118,"./clean_datum":119,"./layout_attributes":124,"./ordered_categories":126,"./set_convert":129,"./tick_label_defaults":130,"./tick_mark_defaults":131,"./tick_value_defaults":132,"fast-isnumeric":10,"tinycolor2":13}],117:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -33270,7 +33634,7 @@ module.exports = function cleanDatum(c) { + return c; + }; + +-},{"../../lib":94,"fast-isnumeric":11}],120:[function(require,module,exports){ ++},{"../../lib":94,"fast-isnumeric":10}],120:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -34037,7 +34401,7 @@ function isSelectOrLasso(dragmode) { + return modes.indexOf(dragmode) !== -1; + } + +-},{"../../components/color":18,"../../components/dragelement":39,"../../components/drawing":41,"../../lib":94,"../../lib/setcursor":103,"../../lib/svg_text_utils":105,"../../plotly":112,"./axes":115,"./constants":120,"./select":128,"d3":9,"tinycolor2":13}],122:[function(require,module,exports){ ++},{"../../components/color":18,"../../components/dragelement":39,"../../components/drawing":41,"../../lib":94,"../../lib/setcursor":103,"../../lib/svg_text_utils":105,"../../plotly":112,"./axes":115,"./constants":120,"./select":128,"d3":7,"tinycolor2":13}],122:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -35379,7 +35743,7 @@ fx.inbox = function(v0, v1) { + return Infinity; + }; + +-},{"../../components/color":18,"../../components/dragelement":39,"../../components/drawing":41,"../../lib":94,"../../lib/events":92,"../../lib/svg_text_utils":105,"./axes":115,"./constants":120,"./dragbox":121,"d3":9,"fast-isnumeric":11,"tinycolor2":13}],123:[function(require,module,exports){ ++},{"../../components/color":18,"../../components/dragelement":39,"../../components/drawing":41,"../../lib":94,"../../lib/events":92,"../../lib/svg_text_utils":105,"./axes":115,"./constants":120,"./dragbox":121,"d3":7,"fast-isnumeric":10,"tinycolor2":13}],123:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -36063,7 +36427,7 @@ module.exports = function orderedCategories(axisLetter, categoryorder, categorya + } + }; + +-},{"d3":9}],127:[function(require,module,exports){ ++},{"d3":7}],127:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -36128,7 +36492,7 @@ module.exports = function handlePositionDefaults(containerIn, containerOut, coer + return containerOut; + }; + +-},{"../../lib":94,"fast-isnumeric":11}],128:[function(require,module,exports){ ++},{"../../lib":94,"fast-isnumeric":10}],128:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -36572,7 +36936,7 @@ module.exports = function setConvert(ax) { + ax._forceTick0 = null; + }; + +-},{"../../lib":94,"./axis_ids":117,"./clean_datum":119,"./constants":120,"d3":9,"fast-isnumeric":11}],130:[function(require,module,exports){ ++},{"../../lib":94,"./axis_ids":117,"./clean_datum":119,"./constants":120,"d3":7,"fast-isnumeric":10}],130:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -36729,7 +37093,7 @@ module.exports = function handleTickValueDefaults(containerIn, containerOut, coe + } + }; + +-},{"fast-isnumeric":11}],133:[function(require,module,exports){ ++},{"fast-isnumeric":10}],133:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -38116,7 +38480,7 @@ plots.graphJson = function(gd, dataonly, mode, output, useDefaults) { + return (output === 'object') ? obj : JSON.stringify(obj); + }; + +-},{"../components/color":18,"../lib":94,"../plotly":112,"./attributes":113,"./font_attributes":133,"./layout_attributes":134,"d3":9,"fast-isnumeric":11}],136:[function(require,module,exports){ ++},{"../components/color":18,"../lib":94,"../plotly":112,"./attributes":113,"./font_attributes":133,"./layout_attributes":134,"d3":7,"fast-isnumeric":10}],136:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -39679,7 +40043,7 @@ var extendDeepAll = Plotly.Lib.extendDeepAll; + return exports; + }; + +-},{"../../plotly":112,"./micropolar_manager":139,"d3":9}],139:[function(require,module,exports){ ++},{"../../plotly":112,"./micropolar_manager":139,"d3":7}],139:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -39762,7 +40126,7 @@ manager.fillLayout = function(_gd) { + _gd._fullLayout = extendDeepAll(dflts, _gd.layout); + }; + +-},{"../../plotly":112,"./undo_manager":140,"d3":9}],140:[function(require,module,exports){ ++},{"../../plotly":112,"./undo_manager":140,"d3":7}],140:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -40294,7 +40658,7 @@ function svgToImg(opts) { + + module.exports = svgToImg; + +-},{"../lib":94,"events":7}],146:[function(require,module,exports){ ++},{"../lib":94,"events":9}],146:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -40373,7 +40737,7 @@ function toImage(gd, opts) { + + module.exports = toImage; + +-},{"../lib":94,"../plotly":112,"events":7}],147:[function(require,module,exports){ ++},{"../lib":94,"../plotly":112,"events":9}],147:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -40485,7 +40849,7 @@ module.exports = function toSVG(gd, format) { + return s; + }; + +-},{"../components/color":18,"../components/drawing":41,"../constants/xmlns_namespaces":87,"../lib/svg_text_utils":105,"d3":9}],148:[function(require,module,exports){ ++},{"../components/color":18,"../components/drawing":41,"../constants/xmlns_namespaces":87,"../lib/svg_text_utils":105,"d3":7}],148:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -40646,7 +41010,7 @@ module.exports = function calc(gd, trace) { + return cd; + }; + +-},{"../../components/colorscale/calc":25,"../../components/colorscale/has_colorscale":31,"../../plots/cartesian/axes":115,"fast-isnumeric":11}],151:[function(require,module,exports){ ++},{"../../components/colorscale/calc":25,"../../components/colorscale/has_colorscale":31,"../../plots/cartesian/axes":115,"fast-isnumeric":10}],151:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -41029,7 +41393,7 @@ module.exports = function plot(gd, plotinfo, cdbar) { + + }; + +-},{"../../components/color":18,"../../components/errorbars":47,"../../lib":94,"./arrays_to_calcdata":148,"d3":9,"fast-isnumeric":11}],157:[function(require,module,exports){ ++},{"../../components/color":18,"../../components/errorbars":47,"../../lib":94,"./arrays_to_calcdata":148,"d3":7,"fast-isnumeric":10}],157:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -41260,7 +41624,7 @@ module.exports = function setPositions(gd, plotinfo) { + }); + }; + +-},{"../../lib":94,"../../plots/cartesian/axes":115,"../../plots/plots":135,"fast-isnumeric":11}],158:[function(require,module,exports){ ++},{"../../lib":94,"../../plots/cartesian/axes":115,"../../plots/plots":135,"fast-isnumeric":10}],158:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -41339,7 +41703,7 @@ module.exports = function style(gd) { + s.call(ErrorBars.style); + }; + +-},{"../../components/color":18,"../../components/drawing":41,"../../components/errorbars":47,"d3":9}],159:[function(require,module,exports){ ++},{"../../components/color":18,"../../components/drawing":41,"../../components/errorbars":47,"d3":7}],159:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -41795,7 +42159,7 @@ function nextDefaultColor(index) { + return pieDefaultColors[index % pieDefaultColors.length]; + } + +-},{"../../components/color":18,"./helpers":164,"fast-isnumeric":11,"tinycolor2":13}],163:[function(require,module,exports){ ++},{"../../components/color":18,"./helpers":164,"fast-isnumeric":10,"tinycolor2":13}],163:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -42677,7 +43041,7 @@ function maxExtent(tilt, tiltAxisFraction, depth) { + 2 * Math.sqrt(1 - sinTilt * sinTilt * tiltAxisFraction * tiltAxisFraction)); + } + +-},{"../../components/color":18,"../../components/drawing":41,"../../lib/svg_text_utils":105,"../../plots/cartesian/graph_interact":122,"./helpers":164,"d3":9}],169:[function(require,module,exports){ ++},{"../../components/color":18,"../../components/drawing":41,"../../lib/svg_text_utils":105,"../../plots/cartesian/graph_interact":122,"./helpers":164,"d3":7}],169:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -42706,7 +43070,7 @@ module.exports = function style(gd) { + }); + }; + +-},{"./style_one":170,"d3":9}],170:[function(require,module,exports){ ++},{"./style_one":170,"d3":7}],170:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -43148,7 +43512,7 @@ module.exports = function calc(gd, trace) { + return cd; + }; + +-},{"../../lib":94,"../../plots/cartesian/axes":115,"./colorscale_calc":176,"./subtypes":191,"fast-isnumeric":11}],174:[function(require,module,exports){ ++},{"../../lib":94,"../../plots/cartesian/axes":115,"./colorscale_calc":176,"./subtypes":191,"fast-isnumeric":10}],174:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -43242,7 +43606,7 @@ module.exports = function colorbar(gd, cd) { + .options(marker.colorbar)(); + }; + +-},{"../../components/colorbar/draw":21,"../../components/colorscale/get_scale":30,"../../lib":94,"../../plots/plots":135,"d3":9,"fast-isnumeric":11}],176:[function(require,module,exports){ ++},{"../../components/colorbar/draw":21,"../../components/colorscale/get_scale":30,"../../lib":94,"../../plots/plots":135,"d3":7,"fast-isnumeric":10}],176:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -43936,7 +44300,7 @@ module.exports = function makeBubbleSizeFn(trace) { + }; + }; + +-},{"fast-isnumeric":11}],187:[function(require,module,exports){ ++},{"fast-isnumeric":10}],187:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -44289,7 +44653,7 @@ function selectMarkers(gd, plotinfo, cdscatter) { + }); + } + +-},{"../../components/drawing":41,"../../components/errorbars":47,"../../lib":94,"../../lib/polygon":100,"./arrays_to_calcdata":171,"./line_points":184,"./subtypes":191,"d3":9}],189:[function(require,module,exports){ ++},{"../../components/drawing":41,"../../components/errorbars":47,"../../lib":94,"../../lib/polygon":100,"./arrays_to_calcdata":171,"./line_points":184,"./subtypes":191,"d3":7}],189:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -44402,7 +44766,7 @@ module.exports = function style(gd) { + s.call(ErrorBars.style); + }; + +-},{"../../components/drawing":41,"../../components/errorbars":47,"d3":9}],191:[function(require,module,exports){ ++},{"../../components/drawing":41,"../../components/errorbars":47,"d3":7}],191:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +diff --git a/dist/plotly-basic.min.js b/dist/plotly-basic.min.js +index d9a3c65..d1bb5de 100644 +--- a/dist/plotly-basic.min.js ++++ b/dist/plotly-basic.min.js +@@ -4,21 +4,21 @@ + * All rights reserved. + * Licensed under the MIT license + */ +-!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.Plotly=t()}}(function(){var t;return function e(t,n,r){function a(i,l){if(!n[i]){if(!t[i]){var s="function"==typeof require&&require;if(!l&&s)return s(i,!0);if(o)return o(i,!0);var c=new Error("Cannot find module '"+i+"'");throw c.code="MODULE_NOT_FOUND",c}var u=n[i]={exports:{}};t[i][0].call(u.exports,function(e){var n=t[i][1][e];return a(n?n:e)},u,u.exports,e,t,n,r)}return n[i].exports}for(var o="function"==typeof require&&require,i=0;it||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},r.prototype.emit=function(t){var e,n,r,o,s,c;if(this._events||(this._events={}),"error"===t&&(!this._events.error||i(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;throw TypeError('Uncaught, unspecified "error" event.')}if(n=this._events[t],l(n))return!1;if(a(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:o=Array.prototype.slice.call(arguments,1),n.apply(this,o)}else if(i(n))for(o=Array.prototype.slice.call(arguments,1),c=n.slice(),r=c.length,s=0;r>s;s++)c[s].apply(this,o);return!0},r.prototype.addListener=function(t,e){var n;if(!a(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,a(e.listener)?e.listener:e),this._events[t]?i(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,i(this._events[t])&&!this._events[t].warned&&(n=l(this._maxListeners)?r.defaultMaxListeners:this._maxListeners,n&&n>0&&this._events[t].length>n&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(t,e){function n(){this.removeListener(t,n),r||(r=!0,e.apply(this,arguments))}if(!a(e))throw TypeError("listener must be a function");var r=!1;return n.listener=e,this.on(t,n),this},r.prototype.removeListener=function(t,e){var n,r,o,l;if(!a(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(n=this._events[t],o=n.length,r=-1,n===e||a(n.listener)&&n.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(i(n)){for(l=o;l-- >0;)if(n[l]===e||n[l].listener&&n[l].listener===e){r=l;break}if(0>r)return this;1===n.length?(n.length=0,delete this._events[t]):n.splice(r,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},r.prototype.removeAllListeners=function(t){var e,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[t],a(n))this.removeListener(t,n);else if(n)for(;n.length;)this.removeListener(t,n[n.length-1]);return delete this._events[t],this},r.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?a(this._events[t])?[this._events[t]]:this._events[t].slice():[]},r.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(a(e))return 1;if(e)return e.length}return 0},r.listenerCount=function(t,e){return t.listenerCount(e)}},{}],8:[function(t,e,n){function r(){u=!1,l.length?c=l.concat(c):f=-1,c.length&&a()}function a(){if(!u){var t=setTimeout(r);u=!0;for(var e=c.length;e;){for(l=c,c=[];++f1)for(var n=1;nt?-1:t>e?1:t>=e?0:NaN}function o(t){return null===t?NaN:+t}function i(t){return!isNaN(t)}function l(t){return{left:function(e,n,r,a){for(arguments.length<3&&(r=0),arguments.length<4&&(a=e.length);a>r;){var o=r+a>>>1;t(e[o],n)<0?r=o+1:a=o}return r},right:function(e,n,r,a){for(arguments.length<3&&(r=0),arguments.length<4&&(a=e.length);a>r;){var o=r+a>>>1;t(e[o],n)>0?a=o:r=o+1}return r}}}function s(t){return t.length}function c(t){for(var e=1;t*e%1;)e*=10;return e}function u(t,e){for(var n in e)Object.defineProperty(t.prototype,n,{value:e[n],enumerable:!1})}function f(){this._=Object.create(null)}function d(t){return(t+="")===ki||t[0]===Mi?Mi+t:t}function h(t){return(t+="")[0]===Mi?t.slice(1):t}function p(t){return d(t)in this._}function g(t){return(t=d(t))in this._&&delete this._[t]}function v(){var t=[];for(var e in this._)t.push(h(e));return t}function m(){var t=0;for(var e in this._)++t;return t}function y(){for(var t in this._)return!1;return!0}function x(){this._=Object.create(null)}function b(t){return t}function _(t,e,n){return function(){var r=n.apply(e,arguments);return r===e?t:r}}function w(t,e){if(e in t)return e;e=e.charAt(0).toUpperCase()+e.slice(1);for(var n=0,r=Ai.length;r>n;++n){var a=Ai[n]+e;if(a in t)return a}}function k(){}function M(){}function A(t){function e(){for(var e,r=n,a=-1,o=r.length;++an;n++)for(var a,o=t[n],i=0,l=o.length;l>i;i++)(a=o[i])&&e(a,i,n);return t}function U(t){return Li(t,Ni),t}function X(t){var e,n;return function(r,a,o){var i,l=t[o].update,s=l.length;for(o!=n&&(n=o,e=0),a>=e&&(e=a+1);!(i=l[e])&&++e0&&(t=t.slice(0,l));var c=Di.get(t);return c&&(t=c,s=Q),l?e?a:r:e?k:o}function $(t,e){return function(n){var r=ui.event;ui.event=n,e[0]=this.__data__;try{t.apply(this,e)}finally{ui.event=r}}}function Q(t,e){var n=$(t,e);return function(t){var e=this,r=t.relatedTarget;r&&(r===e||8&r.compareDocumentPosition(e))||n.call(e,t)}}function W(t){var n=".dragsuppress-"+ ++Ri,a="click"+n,o=ui.select(r(t)).on("touchmove"+n,T).on("dragstart"+n,T).on("selectstart"+n,T);if(null==Ii&&(Ii="onselectstart"in t?!1:w(t.style,"userSelect")),Ii){var i=e(t).style,l=i[Ii];i[Ii]="none"}return function(t){if(o.on(n,null),Ii&&(i[Ii]=l),t){var e=function(){o.on(a,null)};o.on(a,function(){T(),e()},!0),setTimeout(e,0)}}}function J(t,e){e.changedTouches&&(e=e.changedTouches[0]);var n=t.ownerSVGElement||t;if(n.createSVGPoint){var a=n.createSVGPoint();if(0>ji){var o=r(t);if(o.scrollX||o.scrollY){n=ui.select("body").append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important");var i=n[0][0].getScreenCTM();ji=!(i.f||i.e),n.remove()}}return ji?(a.x=e.pageX,a.y=e.pageY):(a.x=e.clientX,a.y=e.clientY),a=a.matrixTransform(t.getScreenCTM().inverse()),[a.x,a.y]}var l=t.getBoundingClientRect();return[e.clientX-l.left-t.clientLeft,e.clientY-l.top-t.clientTop]}function K(){return ui.event.changedTouches[0].identifier}function tt(t){return t>0?1:0>t?-1:0}function et(t,e,n){return(e[0]-t[0])*(n[1]-t[1])-(e[1]-t[1])*(n[0]-t[0])}function nt(t){return t>1?0:-1>t?Bi:Math.acos(t)}function rt(t){return t>1?Zi:-1>t?-Zi:Math.asin(t)}function at(t){return((t=Math.exp(t))-1/t)/2}function ot(t){return((t=Math.exp(t))+1/t)/2}function it(t){return((t=Math.exp(2*t))-1)/(t+1)}function lt(t){return(t=Math.sin(t/2))*t}function st(){}function ct(t,e,n){return this instanceof ct?(this.h=+t,this.s=+e,void(this.l=+n)):arguments.length<2?t instanceof ct?new ct(t.h,t.s,t.l):kt(""+t,Mt,ct):new ct(t,e,n)}function ut(t,e,n){function r(t){return t>360?t-=360:0>t&&(t+=360),60>t?o+(i-o)*t/60:180>t?i:240>t?o+(i-o)*(240-t)/60:o}function a(t){return Math.round(255*r(t))}var o,i;return t=isNaN(t)?0:(t%=360)<0?t+360:t,e=isNaN(e)?0:0>e?0:e>1?1:e,n=0>n?0:n>1?1:n,i=.5>=n?n*(1+e):n+e-n*e,o=2*n-i,new xt(a(t+120),a(t),a(t-120))}function ft(t,e,n){return this instanceof ft?(this.h=+t,this.c=+e,void(this.l=+n)):arguments.length<2?t instanceof ft?new ft(t.h,t.c,t.l):t instanceof ht?gt(t.l,t.a,t.b):gt((t=At((t=ui.rgb(t)).r,t.g,t.b)).l,t.a,t.b):new ft(t,e,n)}function dt(t,e,n){return isNaN(t)&&(t=0),isNaN(e)&&(e=0),new ht(n,Math.cos(t*=Yi)*e,Math.sin(t)*e)}function ht(t,e,n){return this instanceof ht?(this.l=+t,this.a=+e,void(this.b=+n)):arguments.length<2?t instanceof ht?new ht(t.l,t.a,t.b):t instanceof ft?dt(t.h,t.c,t.l):At((t=xt(t)).r,t.g,t.b):new ht(t,e,n)}function pt(t,e,n){var r=(t+16)/116,a=r+e/500,o=r-n/200;return a=vt(a)*nl,r=vt(r)*rl,o=vt(o)*al,new xt(yt(3.2404542*a-1.5371385*r-.4985314*o),yt(-.969266*a+1.8760108*r+.041556*o),yt(.0556434*a-.2040259*r+1.0572252*o))}function gt(t,e,n){return t>0?new ft(Math.atan2(n,e)*Ui,Math.sqrt(e*e+n*n),t):new ft(NaN,NaN,t)}function vt(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function mt(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function yt(t){return Math.round(255*(.00304>=t?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}function xt(t,e,n){return this instanceof xt?(this.r=~~t,this.g=~~e,void(this.b=~~n)):arguments.length<2?t instanceof xt?new xt(t.r,t.g,t.b):kt(""+t,xt,ut):new xt(t,e,n)}function bt(t){return new xt(t>>16,t>>8&255,255&t)}function _t(t){return bt(t)+""}function wt(t){return 16>t?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function kt(t,e,n){var r,a,o,i=0,l=0,s=0;if(r=/([a-z]+)\((.*)\)/.exec(t=t.toLowerCase()))switch(a=r[2].split(","),r[1]){case"hsl":return n(parseFloat(a[0]),parseFloat(a[1])/100,parseFloat(a[2])/100);case"rgb":return e(Lt(a[0]),Lt(a[1]),Lt(a[2]))}return(o=ll.get(t))?e(o.r,o.g,o.b):(null==t||"#"!==t.charAt(0)||isNaN(o=parseInt(t.slice(1),16))||(4===t.length?(i=(3840&o)>>4,i=i>>4|i,l=240&o,l=l>>4|l,s=15&o,s=s<<4|s):7===t.length&&(i=(16711680&o)>>16,l=(65280&o)>>8,s=255&o)),e(i,l,s))}function Mt(t,e,n){var r,a,o=Math.min(t/=255,e/=255,n/=255),i=Math.max(t,e,n),l=i-o,s=(i+o)/2;return l?(a=.5>s?l/(i+o):l/(2-i-o),r=t==i?(e-n)/l+(n>e?6:0):e==i?(n-t)/l+2:(t-e)/l+4,r*=60):(r=NaN,a=s>0&&1>s?0:r),new ct(r,a,s)}function At(t,e,n){t=Tt(t),e=Tt(e),n=Tt(n);var r=mt((.4124564*t+.3575761*e+.1804375*n)/nl),a=mt((.2126729*t+.7151522*e+.072175*n)/rl),o=mt((.0193339*t+.119192*e+.9503041*n)/al);return ht(116*a-16,500*(r-a),200*(a-o))}function Tt(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Lt(t){var e=parseFloat(t);return"%"===t.charAt(t.length-1)?Math.round(2.55*e):e}function zt(t){return"function"==typeof t?t:function(){return t}}function St(t){return function(e,n,r){return 2===arguments.length&&"function"==typeof n&&(r=n,n=null),Ct(e,n,t,r)}}function Ct(t,e,n,r){function a(){var t,e=s.status;if(!e&&Ot(s)||e>=200&&300>e||304===e){try{t=n.call(o,s)}catch(r){return void i.error.call(o,r)}i.load.call(o,t)}else i.error.call(o,s)}var o={},i=ui.dispatch("beforesend","progress","load","error"),l={},s=new XMLHttpRequest,c=null;return!this.XDomainRequest||"withCredentials"in s||!/^(http(s)?:)?\/\//.test(t)||(s=new XDomainRequest),"onload"in s?s.onload=s.onerror=a:s.onreadystatechange=function(){s.readyState>3&&a()},s.onprogress=function(t){var e=ui.event;ui.event=t;try{i.progress.call(o,s)}finally{ui.event=e}},o.header=function(t,e){return t=(t+"").toLowerCase(),arguments.length<2?l[t]:(null==e?delete l[t]:l[t]=e+"",o)},o.mimeType=function(t){return arguments.length?(e=null==t?null:t+"",o):e},o.responseType=function(t){return arguments.length?(c=t,o):c},o.response=function(t){return n=t,o},["get","post"].forEach(function(t){o[t]=function(){return o.send.apply(o,[t].concat(di(arguments)))}}),o.send=function(n,r,a){if(2===arguments.length&&"function"==typeof r&&(a=r,r=null),s.open(n,t,!0),null==e||"accept"in l||(l.accept=e+",*/*"),s.setRequestHeader)for(var u in l)s.setRequestHeader(u,l[u]);return null!=e&&s.overrideMimeType&&s.overrideMimeType(e),null!=c&&(s.responseType=c),null!=a&&o.on("error",a).on("load",function(t){a(null,t)}),i.beforesend.call(o,s),s.send(null==r?null:r),o},o.abort=function(){return s.abort(),o},ui.rebind(o,i,"on"),null==r?o:o.get(Et(r))}function Et(t){return 1===t.length?function(e,n){t(null==e?n:null)}:t}function Ot(t){var e=t.responseType;return e&&"text"!==e?t.response:t.responseText}function Pt(t,e,n){var r=arguments.length;2>r&&(e=0),3>r&&(n=Date.now());var a=n+e,o={c:t,t:a,n:null};return cl?cl.n=o:sl=o,cl=o,ul||(fl=clearTimeout(fl),ul=1,dl(Nt)),o}function Nt(){var t=Dt(),e=It()-t;e>24?(isFinite(e)&&(clearTimeout(fl),fl=setTimeout(Nt,e)),ul=0):(ul=1,dl(Nt))}function Dt(){for(var t=Date.now(),e=sl;e;)t>=e.t&&e.c(t-e.t)&&(e.c=null),e=e.n;return t}function It(){for(var t,e=sl,n=1/0;e;)e.c?(e.t8?function(t){return t/n}:function(t){return t*n},symbol:t}}function Ft(t){var e=t.decimal,n=t.thousands,r=t.grouping,a=t.currency,o=r&&n?function(t,e){for(var a=t.length,o=[],i=0,l=r[0],s=0;a>0&&l>0&&(s+l+1>e&&(l=Math.max(1,e-s)),o.push(t.substring(a-=l,a+l)),!((s+=l+1)>e));)l=r[i=(i+1)%r.length];return o.reverse().join(n)}:b;return function(t){var n=pl.exec(t),r=n[1]||" ",i=n[2]||">",l=n[3]||"-",s=n[4]||"",c=n[5],u=+n[6],f=n[7],d=n[8],h=n[9],p=1,g="",v="",m=!1,y=!0;switch(d&&(d=+d.substring(1)),(c||"0"===r&&"="===i)&&(c=r="0",i="="),h){case"n":f=!0,h="g";break;case"%":p=100,v="%",h="f";break;case"p":p=100,v="%",h="r";break;case"b":case"o":case"x":case"X":"#"===s&&(g="0"+h.toLowerCase());case"c":y=!1;case"d":m=!0,d=0;break;case"s":p=-1,h="r"}"$"===s&&(g=a[0],v=a[1]),"r"!=h||d||(h="g"),null!=d&&("g"==h?d=Math.max(1,Math.min(21,d)):"e"!=h&&"f"!=h||(d=Math.max(0,Math.min(20,d)))),h=gl.get(h)||qt;var x=c&&f;return function(t){var n=v;if(m&&t%1)return"";var a=0>t||0===t&&0>1/t?(t=-t,"-"):"-"===l?"":l;if(0>p){var s=ui.formatPrefix(t,d);t=s.scale(t),n=s.symbol+v}else t*=p;t=h(t,d);var b,_,w=t.lastIndexOf(".");if(0>w){var k=y?t.lastIndexOf("e"):-1;0>k?(b=t,_=""):(b=t.substring(0,k),_=t.substring(k))}else b=t.substring(0,w),_=e+t.substring(w+1);!c&&f&&(b=o(b,1/0));var M=g.length+b.length+_.length+(x?0:a.length),A=u>M?new Array(M=u-M+1).join(r):"";return x&&(b=o(A+b,A.length?u-_.length:1/0)),a+=g,t=b+_,("<"===i?a+t+A:">"===i?A+a+t:"^"===i?A.substring(0,M>>=1)+a+t+A.substring(M):a+(x?t:A+t))+n}}}function qt(t){return t+""}function Bt(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}function Ht(t,e,n){function r(e){var n=t(e),r=o(n,1);return r-e>e-n?n:r}function a(n){return e(n=t(new ml(n-1)),1),n}function o(t,n){return e(t=new ml(+t),n),t}function i(t,r,o){var i=a(t),l=[];if(o>1)for(;r>i;)n(i)%o||l.push(new Date(+i)),e(i,1);else for(;r>i;)l.push(new Date(+i)),e(i,1);return l}function l(t,e,n){try{ml=Bt;var r=new Bt;return r._=t,i(r,e,n)}finally{ml=Date}}t.floor=t,t.round=r,t.ceil=a,t.offset=o,t.range=i;var s=t.utc=Vt(t);return s.floor=s,s.round=Vt(r),s.ceil=Vt(a),s.offset=Vt(o),s.range=l,t}function Vt(t){return function(e,n){try{ml=Bt;var r=new Bt;return r._=e,t(r,n)._}finally{ml=Date}}}function Zt(t){function e(t){function e(e){for(var n,a,o,i=[],l=-1,s=0;++ll;){if(r>=c)return-1; +-if(a=e.charCodeAt(l++),37===a){if(i=e.charAt(l++),o=S[i in xl?e.charAt(l++):i],!o||(r=o(t,n,r))<0)return-1}else if(a!=n.charCodeAt(r++))return-1}return r}function r(t,e,n){w.lastIndex=0;var r=w.exec(e.slice(n));return r?(t.w=k.get(r[0].toLowerCase()),n+r[0].length):-1}function a(t,e,n){b.lastIndex=0;var r=b.exec(e.slice(n));return r?(t.w=_.get(r[0].toLowerCase()),n+r[0].length):-1}function o(t,e,n){T.lastIndex=0;var r=T.exec(e.slice(n));return r?(t.m=L.get(r[0].toLowerCase()),n+r[0].length):-1}function i(t,e,n){M.lastIndex=0;var r=M.exec(e.slice(n));return r?(t.m=A.get(r[0].toLowerCase()),n+r[0].length):-1}function l(t,e,r){return n(t,z.c.toString(),e,r)}function s(t,e,r){return n(t,z.x.toString(),e,r)}function c(t,e,r){return n(t,z.X.toString(),e,r)}function u(t,e,n){var r=x.get(e.slice(n,n+=2).toLowerCase());return null==r?-1:(t.p=r,n)}var f=t.dateTime,d=t.date,h=t.time,p=t.periods,g=t.days,v=t.shortDays,m=t.months,y=t.shortMonths;e.utc=function(t){function n(t){try{ml=Bt;var e=new ml;return e._=t,r(e)}finally{ml=Date}}var r=e(t);return n.parse=function(t){try{ml=Bt;var e=r.parse(t);return e&&e._}finally{ml=Date}},n.toString=r.toString,n},e.multi=e.utc.multi=ue;var x=ui.map(),b=Ut(g),_=Xt(g),w=Ut(v),k=Xt(v),M=Ut(m),A=Xt(m),T=Ut(y),L=Xt(y);p.forEach(function(t,e){x.set(t.toLowerCase(),e)});var z={a:function(t){return v[t.getDay()]},A:function(t){return g[t.getDay()]},b:function(t){return y[t.getMonth()]},B:function(t){return m[t.getMonth()]},c:e(f),d:function(t,e){return Yt(t.getDate(),e,2)},e:function(t,e){return Yt(t.getDate(),e,2)},H:function(t,e){return Yt(t.getHours(),e,2)},I:function(t,e){return Yt(t.getHours()%12||12,e,2)},j:function(t,e){return Yt(1+vl.dayOfYear(t),e,3)},L:function(t,e){return Yt(t.getMilliseconds(),e,3)},m:function(t,e){return Yt(t.getMonth()+1,e,2)},M:function(t,e){return Yt(t.getMinutes(),e,2)},p:function(t){return p[+(t.getHours()>=12)]},S:function(t,e){return Yt(t.getSeconds(),e,2)},U:function(t,e){return Yt(vl.sundayOfYear(t),e,2)},w:function(t){return t.getDay()},W:function(t,e){return Yt(vl.mondayOfYear(t),e,2)},x:e(d),X:e(h),y:function(t,e){return Yt(t.getFullYear()%100,e,2)},Y:function(t,e){return Yt(t.getFullYear()%1e4,e,4)},Z:se,"%":function(){return"%"}},S={a:r,A:a,b:o,B:i,c:l,d:ne,e:ne,H:ae,I:ae,j:re,L:le,m:ee,M:oe,p:u,S:ie,U:$t,w:Gt,W:Qt,x:s,X:c,y:Jt,Y:Wt,Z:Kt,"%":ce};return e}function Yt(t,e,n){var r=0>t?"-":"",a=(r?-t:t)+"",o=a.length;return r+(n>o?new Array(n-o+1).join(e)+a:a)}function Ut(t){return new RegExp("^(?:"+t.map(ui.requote).join("|")+")","i")}function Xt(t){for(var e=new f,n=-1,r=t.length;++n68?1900:2e3)}function ee(t,e,n){bl.lastIndex=0;var r=bl.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function ne(t,e,n){bl.lastIndex=0;var r=bl.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function re(t,e,n){bl.lastIndex=0;var r=bl.exec(e.slice(n,n+3));return r?(t.j=+r[0],n+r[0].length):-1}function ae(t,e,n){bl.lastIndex=0;var r=bl.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function oe(t,e,n){bl.lastIndex=0;var r=bl.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function ie(t,e,n){bl.lastIndex=0;var r=bl.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function le(t,e,n){bl.lastIndex=0;var r=bl.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function se(t){var e=t.getTimezoneOffset(),n=e>0?"-":"+",r=wi(e)/60|0,a=wi(e)%60;return n+Yt(r,"0",2)+Yt(a,"0",2)}function ce(t,e,n){_l.lastIndex=0;var r=_l.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function ue(t){for(var e=t.length,n=-1;++n=0?1:-1,l=i*n,s=Math.cos(e),c=Math.sin(e),u=o*c,f=a*s+u*Math.cos(l),d=u*i*Math.sin(l);Ll.add(Math.atan2(d,f)),r=t,a=s,o=c}var e,n,r,a,o;zl.point=function(i,l){zl.point=t,r=(e=i)*Yi,a=Math.cos(l=(n=l)*Yi/2+Bi/4),o=Math.sin(l)},zl.lineEnd=function(){t(e,n)}}function me(t){var e=t[0],n=t[1],r=Math.cos(n);return[r*Math.cos(e),r*Math.sin(e),Math.sin(n)]}function ye(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function xe(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function be(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function _e(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function we(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function ke(t){return[Math.atan2(t[1],t[0]),rt(t[2])]}function Me(t,e){return wi(t[0]-e[0])l;++l)a.point((n=t[l])[0],n[1]);return void a.lineEnd()}var s=new Ne(n,t,null,!0),c=new Ne(n,null,s,!1);s.o=c,o.push(s),i.push(c),s=new Ne(r,t,null,!1),c=new Ne(r,null,s,!0),s.o=c,o.push(s),i.push(c)}}),i.sort(e),Pe(o),Pe(i),o.length){for(var l=0,s=n,c=i.length;c>l;++l)i[l].e=s=!s;for(var u,f,d=o[0];;){for(var h=d,p=!0;h.v;)if((h=h.n)===d)return;u=h.z,a.lineStart();do{if(h.v=h.o.v=!0,h.e){if(p)for(var l=0,c=u.length;c>l;++l)a.point((f=u[l])[0],f[1]);else r(h.x,h.n.x,1,a);h=h.n}else{if(p){u=h.p.z;for(var l=u.length-1;l>=0;--l)a.point((f=u[l])[0],f[1])}else r(h.x,h.p.x,-1,a);h=h.p}h=h.o,u=h.z,p=!p}while(!h.v);a.lineEnd()}}}function Pe(t){if(e=t.length){for(var e,n,r=0,a=t[0];++r0){for(_||(o.polygonStart(),_=!0),o.lineStart();++i1&&2&e&&n.push(n.pop().concat(n.shift())),h.push(n.filter(Ie))}var h,p,g,v=e(o),m=a.invert(r[0],r[1]),y={point:i,lineStart:s,lineEnd:c,polygonStart:function(){y.point=u,y.lineStart=f,y.lineEnd=d,h=[],p=[]},polygonEnd:function(){y.point=i,y.lineStart=s,y.lineEnd=c,h=ui.merge(h);var t=He(m,p);h.length?(_||(o.polygonStart(),_=!0),Oe(h,je,t,n,o)):t&&(_||(o.polygonStart(),_=!0),o.lineStart(),n(null,null,1,o),o.lineEnd()),_&&(o.polygonEnd(),_=!1),h=p=null},sphere:function(){o.polygonStart(),o.lineStart(),n(null,null,1,o),o.lineEnd(),o.polygonEnd()}},x=Re(),b=e(x),_=!1;return y}}function Ie(t){return t.length>1}function Re(){var t,e=[];return{lineStart:function(){e.push(t=[])},point:function(e,n){t.push([e,n])},lineEnd:k,buffer:function(){var n=e;return e=[],t=null,n},rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))}}}function je(t,e){return((t=t.x)[0]<0?t[1]-Zi-Fi:Zi-t[1])-((e=e.x)[0]<0?e[1]-Zi-Fi:Zi-e[1])}function Fe(t){var e,n=NaN,r=NaN,a=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(o,i){var l=o>0?Bi:-Bi,s=wi(o-n);wi(s-Bi)0?Zi:-Zi),t.point(a,r),t.lineEnd(),t.lineStart(),t.point(l,r),t.point(o,r),e=0):a!==l&&s>=Bi&&(wi(n-a)Fi?Math.atan((Math.sin(e)*(o=Math.cos(r))*Math.sin(n)-Math.sin(r)*(a=Math.cos(e))*Math.sin(t))/(a*o*i)):(e+r)/2}function Be(t,e,n,r){var a;if(null==t)a=n*Zi,r.point(-Bi,a),r.point(0,a),r.point(Bi,a),r.point(Bi,0),r.point(Bi,-a),r.point(0,-a),r.point(-Bi,-a),r.point(-Bi,0),r.point(-Bi,a);else if(wi(t[0]-e[0])>Fi){var o=t[0]l;++l){var c=e[l],u=c.length;if(u)for(var f=c[0],d=f[0],h=f[1]/2+Bi/4,p=Math.sin(h),g=Math.cos(h),v=1;;){v===u&&(v=0),t=c[v];var m=t[0],y=t[1]/2+Bi/4,x=Math.sin(y),b=Math.cos(y),_=m-d,w=_>=0?1:-1,k=w*_,M=k>Bi,A=p*x;if(Ll.add(Math.atan2(A*w*Math.sin(k),g*b+A*Math.cos(k))),o+=M?_+w*Hi:_,M^d>=n^m>=n){var T=xe(me(f),me(t));we(T);var L=xe(a,T);we(L);var z=(M^_>=0?-1:1)*rt(L[2]);(r>z||r===z&&(T[0]||T[1]))&&(i+=M^_>=0?1:-1)}if(!v++)break;d=m,p=x,g=b,f=t}}return(-Fi>o||Fi>o&&0>Ll)^1&i}function Ve(t){function e(t,e){return Math.cos(t)*Math.cos(e)>o}function n(t){var n,o,s,c,u;return{lineStart:function(){c=s=!1,u=1},point:function(f,d){var h,p=[f,d],g=e(f,d),v=i?g?0:a(f,d):g?a(f+(0>f?Bi:-Bi),d):0;if(!n&&(c=s=g)&&t.lineStart(),g!==s&&(h=r(n,p),(Me(n,h)||Me(p,h))&&(p[0]+=Fi,p[1]+=Fi,g=e(p[0],p[1]))),g!==s)u=0,g?(t.lineStart(),h=r(p,n),t.point(h[0],h[1])):(h=r(n,p),t.point(h[0],h[1]),t.lineEnd()),n=h;else if(l&&n&&i^g){var m;v&o||!(m=r(p,n,!0))||(u=0,i?(t.lineStart(),t.point(m[0][0],m[0][1]),t.point(m[1][0],m[1][1]),t.lineEnd()):(t.point(m[1][0],m[1][1]),t.lineEnd(),t.lineStart(),t.point(m[0][0],m[0][1])))}!g||n&&Me(n,p)||t.point(p[0],p[1]),n=p,s=g,o=v},lineEnd:function(){s&&t.lineEnd(),n=null},clean:function(){return u|(c&&s)<<1}}}function r(t,e,n){var r=me(t),a=me(e),i=[1,0,0],l=xe(r,a),s=ye(l,l),c=l[0],u=s-c*c;if(!u)return!n&&t;var f=o*s/u,d=-o*c/u,h=xe(i,l),p=_e(i,f),g=_e(l,d);be(p,g);var v=h,m=ye(p,v),y=ye(v,v),x=m*m-y*(ye(p,p)-1);if(!(0>x)){var b=Math.sqrt(x),_=_e(v,(-m-b)/y);if(be(_,p),_=ke(_),!n)return _;var w,k=t[0],M=e[0],A=t[1],T=e[1];k>M&&(w=k,k=M,M=w);var L=M-k,z=wi(L-Bi)L;if(!z&&A>T&&(w=A,A=T,T=w),S?z?A+T>0^_[1]<(wi(_[0]-k)Bi^(k<=_[0]&&_[0]<=M)){var C=_e(v,(-m+b)/y);return be(C,p),[_,ke(C)]}}}function a(e,n){var r=i?t:Bi-t,a=0;return-r>e?a|=1:e>r&&(a|=2),-r>n?a|=4:n>r&&(a|=8),a}var o=Math.cos(t),i=o>0,l=wi(o)>Fi,s=mn(t,6*Yi);return De(e,n,s,i?[0,-t]:[-Bi,t-Bi])}function Ze(t,e,n,r){return function(a){var o,i=a.a,l=a.b,s=i.x,c=i.y,u=l.x,f=l.y,d=0,h=1,p=u-s,g=f-c;if(o=t-s,p||!(o>0)){if(o/=p,0>p){if(d>o)return;h>o&&(h=o)}else if(p>0){if(o>h)return;o>d&&(d=o)}if(o=n-s,p||!(0>o)){if(o/=p,0>p){if(o>h)return;o>d&&(d=o)}else if(p>0){if(d>o)return;h>o&&(h=o)}if(o=e-c,g||!(o>0)){if(o/=g,0>g){if(d>o)return;h>o&&(h=o)}else if(g>0){if(o>h)return;o>d&&(d=o)}if(o=r-c,g||!(0>o)){if(o/=g,0>g){if(o>h)return;o>d&&(d=o)}else if(g>0){if(d>o)return;h>o&&(h=o)}return d>0&&(a.a={x:s+d*p,y:c+d*g}),1>h&&(a.b={x:s+h*p,y:c+h*g}),a}}}}}}function Ye(t,e,n,r){function a(r,a){return wi(r[0]-t)0?0:3:wi(r[0]-n)0?2:1:wi(r[1]-e)0?1:0:a>0?3:2}function o(t,e){return i(t.x,e.x)}function i(t,e){var n=a(t,1),r=a(e,1);return n!==r?n-r:0===n?e[1]-t[1]:1===n?t[0]-e[0]:2===n?t[1]-e[1]:e[0]-t[0]}return function(l){function s(t){for(var e=0,n=v.length,r=t[1],a=0;n>a;++a)for(var o,i=1,l=v[a],s=l.length,c=l[0];s>i;++i)o=l[i],c[1]<=r?o[1]>r&&et(c,o,t)>0&&++e:o[1]<=r&&et(c,o,t)<0&&--e,c=o;return 0!==e}function c(o,l,s,c){var u=0,f=0;if(null==o||(u=a(o,s))!==(f=a(l,s))||i(o,l)<0^s>0){do c.point(0===u||3===u?t:n,u>1?r:e);while((u=(u+s+4)%4)!==f)}else c.point(l[0],l[1])}function u(a,o){return a>=t&&n>=a&&o>=e&&r>=o}function f(t,e){u(t,e)&&l.point(t,e)}function d(){S.point=p,v&&v.push(m=[]),M=!0,k=!1,_=w=NaN}function h(){g&&(p(y,x),b&&k&&L.rejoin(),g.push(L.buffer())),S.point=f,k&&l.lineEnd()}function p(t,e){t=Math.max(-Hl,Math.min(Hl,t)),e=Math.max(-Hl,Math.min(Hl,e));var n=u(t,e);if(v&&m.push([t,e]),M)y=t,x=e,b=n,M=!1,n&&(l.lineStart(),l.point(t,e));else if(n&&k)l.point(t,e);else{var r={a:{x:_,y:w},b:{x:t,y:e}};z(r)?(k||(l.lineStart(),l.point(r.a.x,r.a.y)),l.point(r.b.x,r.b.y),n||l.lineEnd(),A=!1):n&&(l.lineStart(),l.point(t,e),A=!1)}_=t,w=e,k=n}var g,v,m,y,x,b,_,w,k,M,A,T=l,L=Re(),z=Ze(t,e,n,r),S={point:f,lineStart:d,lineEnd:h,polygonStart:function(){l=L,g=[],v=[],A=!0},polygonEnd:function(){l=T,g=ui.merge(g);var e=s([t,r]),n=A&&e,a=g.length;(n||a)&&(l.polygonStart(),n&&(l.lineStart(),c(null,null,1,l),l.lineEnd()),a&&Oe(g,o,e,c,l),l.polygonEnd()),g=v=m=null}};return S}}function Ue(t){var e=0,n=Bi/3,r=cn(t),a=r(e,n);return a.parallels=function(t){return arguments.length?r(e=t[0]*Bi/180,n=t[1]*Bi/180):[e/Bi*180,n/Bi*180]},a}function Xe(t,e){function n(t,e){var n=Math.sqrt(o-2*a*Math.sin(e))/a;return[n*Math.sin(t*=a),i-n*Math.cos(t)]}var r=Math.sin(t),a=(r+Math.sin(e))/2,o=1+r*(2*a-r),i=Math.sqrt(o)/a;return n.invert=function(t,e){var n=i-e;return[Math.atan2(t,n)/a,rt((o-(t*t+n*n)*a*a)/(2*a))]},n}function Ge(){function t(t,e){Zl+=a*t-r*e,r=t,a=e}var e,n,r,a;$l.point=function(o,i){$l.point=t,e=r=o,n=a=i},$l.lineEnd=function(){t(e,n)}}function $e(t,e){Yl>t&&(Yl=t),t>Xl&&(Xl=t),Ul>e&&(Ul=e),e>Gl&&(Gl=e)}function Qe(){function t(t,e){i.push("M",t,",",e,o)}function e(t,e){i.push("M",t,",",e),l.point=n}function n(t,e){i.push("L",t,",",e)}function r(){l.point=t}function a(){i.push("Z")}var o=We(4.5),i=[],l={point:t,lineStart:function(){l.point=e},lineEnd:r,polygonStart:function(){l.lineEnd=a},polygonEnd:function(){l.lineEnd=r,l.point=t},pointRadius:function(t){return o=We(t),l},result:function(){if(i.length){var t=i.join("");return i=[],t}}};return l}function We(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}function Je(t,e){El+=t,Ol+=e,++Pl}function Ke(){function t(t,r){var a=t-e,o=r-n,i=Math.sqrt(a*a+o*o);Nl+=i*(e+t)/2,Dl+=i*(n+r)/2,Il+=i,Je(e=t,n=r)}var e,n;Wl.point=function(r,a){Wl.point=t,Je(e=r,n=a)}}function tn(){Wl.point=Je}function en(){function t(t,e){var n=t-r,o=e-a,i=Math.sqrt(n*n+o*o);Nl+=i*(r+t)/2,Dl+=i*(a+e)/2,Il+=i,i=a*t-r*e,Rl+=i*(r+t),jl+=i*(a+e),Fl+=3*i,Je(r=t,a=e)}var e,n,r,a;Wl.point=function(o,i){Wl.point=t,Je(e=r=o,n=a=i)},Wl.lineEnd=function(){t(e,n)}}function nn(t){function e(e,n){t.moveTo(e+i,n),t.arc(e,n,i,0,Hi)}function n(e,n){t.moveTo(e,n),l.point=r}function r(e,n){t.lineTo(e,n)}function a(){l.point=e}function o(){t.closePath()}var i=4.5,l={point:e,lineStart:function(){l.point=n},lineEnd:a,polygonStart:function(){l.lineEnd=o},polygonEnd:function(){l.lineEnd=a,l.point=e},pointRadius:function(t){return i=t,l},result:k};return l}function rn(t){function e(t){return(l?r:n)(t)}function n(e){return ln(e,function(n,r){n=t(n,r),e.point(n[0],n[1])})}function r(e){function n(n,r){n=t(n,r),e.point(n[0],n[1])}function r(){x=NaN,M.point=o,e.lineStart()}function o(n,r){var o=me([n,r]),i=t(n,r);a(x,b,y,_,w,k,x=i[0],b=i[1],y=n,_=o[0],w=o[1],k=o[2],l,e),e.point(x,b)}function i(){M.point=n,e.lineEnd()}function s(){r(),M.point=c,M.lineEnd=u}function c(t,e){o(f=t,d=e),h=x,p=b,g=_,v=w,m=k,M.point=o}function u(){a(x,b,y,_,w,k,h,p,f,g,v,m,l,e),M.lineEnd=i,i()}var f,d,h,p,g,v,m,y,x,b,_,w,k,M={point:n,lineStart:r,lineEnd:i,polygonStart:function(){e.polygonStart(),M.lineStart=s},polygonEnd:function(){e.polygonEnd(),M.lineStart=r}};return M}function a(e,n,r,l,s,c,u,f,d,h,p,g,v,m){var y=u-e,x=f-n,b=y*y+x*x;if(b>4*o&&v--){var _=l+h,w=s+p,k=c+g,M=Math.sqrt(_*_+w*w+k*k),A=Math.asin(k/=M),T=wi(wi(k)-1)o||wi((y*C+x*E)/b-.5)>.3||i>l*h+s*p+c*g)&&(a(e,n,r,l,s,c,z,S,T,_/=M,w/=M,k,v,m),m.point(z,S),a(z,S,T,_,w,k,u,f,d,h,p,g,v,m))}}var o=.5,i=Math.cos(30*Yi),l=16;return e.precision=function(t){return arguments.length?(l=(o=t*t)>0&&16,e):Math.sqrt(o)},e}function an(t){var e=rn(function(e,n){return t([e*Ui,n*Ui])});return function(t){return un(e(t))}}function on(t){this.stream=t}function ln(t,e){return{point:e,sphere:function(){t.sphere()},lineStart:function(){t.lineStart()},lineEnd:function(){t.lineEnd()},polygonStart:function(){t.polygonStart()},polygonEnd:function(){t.polygonEnd()}}}function sn(t){return cn(function(){return t})()}function cn(t){function e(t){return t=l(t[0]*Yi,t[1]*Yi),[t[0]*d+s,c-t[1]*d]}function n(t){return t=l.invert((t[0]-s)/d,(c-t[1])/d),t&&[t[0]*Ui,t[1]*Ui]}function r(){l=Ce(i=hn(m,y,x),o);var t=o(g,v);return s=h-t[0]*d,c=p+t[1]*d,a()}function a(){return u&&(u.valid=!1,u=null),e}var o,i,l,s,c,u,f=rn(function(t,e){return t=o(t,e),[t[0]*d+s,c-t[1]*d]}),d=150,h=480,p=250,g=0,v=0,m=0,y=0,x=0,_=Bl,w=b,k=null,M=null;return e.stream=function(t){return u&&(u.valid=!1),u=un(_(i,f(w(t)))),u.valid=!0,u},e.clipAngle=function(t){return arguments.length?(_=null==t?(k=t,Bl):Ve((k=+t)*Yi),a()):k},e.clipExtent=function(t){return arguments.length?(M=t,w=t?Ye(t[0][0],t[0][1],t[1][0],t[1][1]):b,a()):M},e.scale=function(t){return arguments.length?(d=+t,r()):d},e.translate=function(t){return arguments.length?(h=+t[0],p=+t[1],r()):[h,p]},e.center=function(t){return arguments.length?(g=t[0]%360*Yi,v=t[1]%360*Yi,r()):[g*Ui,v*Ui]},e.rotate=function(t){return arguments.length?(m=t[0]%360*Yi,y=t[1]%360*Yi,x=t.length>2?t[2]%360*Yi:0,r()):[m*Ui,y*Ui,x*Ui]},ui.rebind(e,f,"precision"),function(){return o=t.apply(this,arguments),e.invert=o.invert&&n,r()}}function un(t){return ln(t,function(e,n){t.point(e*Yi,n*Yi)})}function fn(t,e){return[t,e]}function dn(t,e){return[t>Bi?t-Hi:-Bi>t?t+Hi:t,e]}function hn(t,e,n){return t?e||n?Ce(gn(t),vn(e,n)):gn(t):e||n?vn(e,n):dn}function pn(t){return function(e,n){return e+=t,[e>Bi?e-Hi:-Bi>e?e+Hi:e,n]}}function gn(t){var e=pn(t);return e.invert=pn(-t),e}function vn(t,e){function n(t,e){var n=Math.cos(e),l=Math.cos(t)*n,s=Math.sin(t)*n,c=Math.sin(e),u=c*r+l*a;return[Math.atan2(s*o-u*i,l*r-c*a),rt(u*o+s*i)]}var r=Math.cos(t),a=Math.sin(t),o=Math.cos(e),i=Math.sin(e);return n.invert=function(t,e){var n=Math.cos(e),l=Math.cos(t)*n,s=Math.sin(t)*n,c=Math.sin(e),u=c*o-s*i;return[Math.atan2(s*o+c*i,l*r+u*a),rt(u*r-l*a)]},n}function mn(t,e){var n=Math.cos(t),r=Math.sin(t);return function(a,o,i,l){var s=i*e;null!=a?(a=yn(n,a),o=yn(n,o),(i>0?o>a:a>o)&&(a+=i*Hi)):(a=t+i*Hi,o=t-.5*s);for(var c,u=a;i>0?u>o:o>u;u-=s)l.point((c=ke([n,-r*Math.cos(u),-r*Math.sin(u)]))[0],c[1])}}function yn(t,e){var n=me(e);n[0]-=t,we(n);var r=nt(-n[1]);return((-n[2]<0?-r:r)+2*Math.PI-Fi)%(2*Math.PI)}function xn(t,e,n){var r=ui.range(t,e-Fi,n).concat(e);return function(t){return r.map(function(e){return[t,e]})}}function bn(t,e,n){var r=ui.range(t,e-Fi,n).concat(e);return function(t){return r.map(function(e){return[e,t]})}}function _n(t){return t.source}function wn(t){return t.target}function kn(t,e,n,r){var a=Math.cos(e),o=Math.sin(e),i=Math.cos(r),l=Math.sin(r),s=a*Math.cos(t),c=a*Math.sin(t),u=i*Math.cos(n),f=i*Math.sin(n),d=2*Math.asin(Math.sqrt(lt(r-e)+a*i*lt(n-t))),h=1/Math.sin(d),p=d?function(t){var e=Math.sin(t*=d)*h,n=Math.sin(d-t)*h,r=n*s+e*u,a=n*c+e*f,i=n*o+e*l;return[Math.atan2(a,r)*Ui,Math.atan2(i,Math.sqrt(r*r+a*a))*Ui]}:function(){return[t*Ui,e*Ui]};return p.distance=d,p}function Mn(){function t(t,a){var o=Math.sin(a*=Yi),i=Math.cos(a),l=wi((t*=Yi)-e),s=Math.cos(l);Jl+=Math.atan2(Math.sqrt((l=i*Math.sin(l))*l+(l=r*o-n*i*s)*l),n*o+r*i*s),e=t,n=o,r=i}var e,n,r;Kl.point=function(a,o){e=a*Yi,n=Math.sin(o*=Yi),r=Math.cos(o),Kl.point=t},Kl.lineEnd=function(){Kl.point=Kl.lineEnd=k}}function An(t,e){function n(e,n){var r=Math.cos(e),a=Math.cos(n),o=t(r*a);return[o*a*Math.sin(e),o*Math.sin(n)]}return n.invert=function(t,n){var r=Math.sqrt(t*t+n*n),a=e(r),o=Math.sin(a),i=Math.cos(a);return[Math.atan2(t*o,r*i),Math.asin(r&&n*o/r)]},n}function Tn(t,e){function n(t,e){i>0?-Zi+Fi>e&&(e=-Zi+Fi):e>Zi-Fi&&(e=Zi-Fi);var n=i/Math.pow(a(e),o);return[n*Math.sin(o*t),i-n*Math.cos(o*t)]}var r=Math.cos(t),a=function(t){return Math.tan(Bi/4+t/2)},o=t===e?Math.sin(t):Math.log(r/Math.cos(e))/Math.log(a(e)/a(t)),i=r*Math.pow(a(t),o)/o;return o?(n.invert=function(t,e){var n=i-e,r=tt(o)*Math.sqrt(t*t+n*n);return[Math.atan2(t,n)/o,2*Math.atan(Math.pow(i/r,1/o))-Zi]},n):zn}function Ln(t,e){function n(t,e){var n=o-e;return[n*Math.sin(a*t),o-n*Math.cos(a*t)]}var r=Math.cos(t),a=t===e?Math.sin(t):(r-Math.cos(e))/(e-t),o=r/a+t;return wi(a)a;a++){for(;r>1&&et(t[n[r-2]],t[n[r-1]],t[a])<=0;)--r;n[r++]=a}return n.slice(0,r)}function Nn(t,e){return t[0]-e[0]||t[1]-e[1]}function Dn(t,e,n){return(n[0]-e[0])*(t[1]-e[1])<(n[1]-e[1])*(t[0]-e[0])}function In(t,e,n,r){var a=t[0],o=n[0],i=e[0]-a,l=r[0]-o,s=t[1],c=n[1],u=e[1]-s,f=r[1]-c,d=(l*(s-c)-f*(a-o))/(f*i-l*u);return[a+d*i,s+d*u]}function Rn(t){var e=t[0],n=t[t.length-1];return!(e[0]-n[0]||e[1]-n[1])}function jn(){or(this),this.edge=this.site=this.circle=null}function Fn(t){var e=fs.pop()||new jn;return e.site=t,e}function qn(t){Qn(t),ss.remove(t),fs.push(t),or(t)}function Bn(t){var e=t.circle,n=e.x,r=e.cy,a={x:n,y:r},o=t.P,i=t.N,l=[t];qn(t);for(var s=o;s.circle&&wi(n-s.circle.x)u;++u)c=l[u],s=l[u-1],nr(c.edge,s.site,c.site,a);s=l[0],c=l[f-1],c.edge=tr(s.site,c.site,null,a),$n(s),$n(c)}function Hn(t){for(var e,n,r,a,o=t.x,i=t.y,l=ss._;l;)if(r=Vn(l,i)-o,r>Fi)l=l.L;else{if(a=o-Zn(l,i),!(a>Fi)){r>-Fi?(e=l.P,n=l):a>-Fi?(e=l,n=l.N):e=n=l;break}if(!l.R){e=l;break}l=l.R}var s=Fn(t);if(ss.insert(e,s),e||n){if(e===n)return Qn(e),n=Fn(e.site),ss.insert(s,n),s.edge=n.edge=tr(e.site,s.site),$n(e),void $n(n);if(!n)return void(s.edge=tr(e.site,s.site));Qn(e),Qn(n);var c=e.site,u=c.x,f=c.y,d=t.x-u,h=t.y-f,p=n.site,g=p.x-u,v=p.y-f,m=2*(d*v-h*g),y=d*d+h*h,x=g*g+v*v,b={x:(v*y-h*x)/m+u,y:(d*x-g*y)/m+f};nr(n.edge,c,p,b),s.edge=tr(c,t,null,b),n.edge=tr(t,p,null,b),$n(e),$n(n)}}function Vn(t,e){var n=t.site,r=n.x,a=n.y,o=a-e;if(!o)return r;var i=t.P;if(!i)return-(1/0);n=i.site;var l=n.x,s=n.y,c=s-e;if(!c)return l;var u=l-r,f=1/o-1/c,d=u/c;return f?(-d+Math.sqrt(d*d-2*f*(u*u/(-2*c)-s+c/2+a-o/2)))/f+r:(r+l)/2}function Zn(t,e){var n=t.N;if(n)return Vn(n,e);var r=t.site;return r.y===e?r.x:1/0}function Yn(t){this.site=t,this.edges=[]}function Un(t){for(var e,n,r,a,o,i,l,s,c,u,f=t[0][0],d=t[1][0],h=t[0][1],p=t[1][1],g=ls,v=g.length;v--;)if(o=g[v],o&&o.prepare())for(l=o.edges,s=l.length,i=0;s>i;)u=l[i].end(),r=u.x,a=u.y,c=l[++i%s].start(),e=c.x,n=c.y,(wi(r-e)>Fi||wi(a-n)>Fi)&&(l.splice(i,0,new rr(er(o.site,u,wi(r-f)Fi?{x:f,y:wi(e-f)Fi?{x:wi(n-p)Fi?{x:d,y:wi(e-d)Fi?{x:wi(n-h)=-qi)){var h=s*s+c*c,p=u*u+f*f,g=(f*h-c*p)/d,v=(s*p-u*h)/d,f=v+l,m=ds.pop()||new Gn;m.arc=t,m.site=a,m.x=g+i,m.y=f+Math.sqrt(g*g+v*v),m.cy=f,t.circle=m;for(var y=null,x=us._;x;)if(m.yv||v>=l)return;if(d>p){if(o){if(o.y>=c)return}else o={x:v,y:s};n={x:v,y:c}}else{if(o){if(o.yr||r>1)if(d>p){if(o){if(o.y>=c)return}else o={x:(s-a)/r,y:s};n={x:(c-a)/r,y:c}}else{if(o){if(o.yh){if(o){if(o.x>=l)return}else o={x:i,y:r*i+a};n={x:l,y:r*l+a}}else{if(o){if(o.xo||f>i||r>d||a>h)){if(p=t.point){var p,g=e-t.x,v=n-t.y,m=g*g+v*v;if(s>m){var y=Math.sqrt(s=m);r=e-y,a=n-y,o=e+y,i=n+y,l=p}}for(var x=t.nodes,b=.5*(u+d),_=.5*(f+h),w=e>=b,k=n>=_,M=k<<1|w,A=M+4;A>M;++M)if(t=x[3&M])switch(3&M){case 0:c(t,u,f,b,_);break;case 1:c(t,b,f,d,_);break;case 2:c(t,u,_,b,h);break;case 3:c(t,b,_,d,h)}}}(t,r,a,o,i),l}function mr(t,e){t=ui.rgb(t),e=ui.rgb(e);var n=t.r,r=t.g,a=t.b,o=e.r-n,i=e.g-r,l=e.b-a;return function(t){return"#"+wt(Math.round(n+o*t))+wt(Math.round(r+i*t))+wt(Math.round(a+l*t))}}function yr(t,e){var n,r={},a={};for(n in t)n in e?r[n]=_r(t[n],e[n]):a[n]=t[n];for(n in e)n in t||(a[n]=e[n]);return function(t){for(n in r)a[n]=r[n](t);return a}}function xr(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function br(t,e){var n,r,a,o=ps.lastIndex=gs.lastIndex=0,i=-1,l=[],s=[];for(t+="",e+="";(n=ps.exec(t))&&(r=gs.exec(e));)(a=r.index)>o&&(a=e.slice(o,a),l[i]?l[i]+=a:l[++i]=a),(n=n[0])===(r=r[0])?l[i]?l[i]+=r:l[++i]=r:(l[++i]=null,s.push({i:i,x:xr(n,r)})),o=gs.lastIndex;return or;++r)l[(n=s[r]).i]=n.x(t);return l.join("")})}function _r(t,e){for(var n,r=ui.interpolators.length;--r>=0&&!(n=ui.interpolators[r](t,e)););return n}function wr(t,e){var n,r=[],a=[],o=t.length,i=e.length,l=Math.min(t.length,e.length);for(n=0;l>n;++n)r.push(_r(t[n],e[n]));for(;o>n;++n)a[n]=t[n];for(;i>n;++n)a[n]=e[n];return function(t){for(n=0;l>n;++n)a[n]=r[n](t);return a}}function kr(t){return function(e){return 0>=e?0:e>=1?1:t(e)}}function Mr(t){return function(e){return 1-t(1-e)}}function Ar(t){return function(e){return.5*(.5>e?t(2*e):2-t(2-2*e))}}function Tr(t){return t*t}function Lr(t){return t*t*t}function zr(t){if(0>=t)return 0;if(t>=1)return 1;var e=t*t,n=e*t;return 4*(.5>t?n:3*(t-e)+n-.75)}function Sr(t){return function(e){return Math.pow(e,t)}}function Cr(t){return 1-Math.cos(t*Zi)}function Er(t){return Math.pow(2,10*(t-1))}function Or(t){return 1-Math.sqrt(1-t*t)}function Pr(t,e){var n;return arguments.length<2&&(e=.45),arguments.length?n=e/Hi*Math.asin(1/t):(t=1,n=e/4),function(r){return 1+t*Math.pow(2,-10*r)*Math.sin((r-n)*Hi/e)}}function Nr(t){return t||(t=1.70158),function(e){return e*e*((t+1)*e-t)}}function Dr(t){return 1/2.75>t?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}function Ir(t,e){t=ui.hcl(t),e=ui.hcl(e);var n=t.h,r=t.c,a=t.l,o=e.h-n,i=e.c-r,l=e.l-a;return isNaN(i)&&(i=0,r=isNaN(r)?e.c:r),isNaN(o)?(o=0,n=isNaN(n)?e.h:n):o>180?o-=360:-180>o&&(o+=360),function(t){return dt(n+o*t,r+i*t,a+l*t)+""}}function Rr(t,e){t=ui.hsl(t),e=ui.hsl(e);var n=t.h,r=t.s,a=t.l,o=e.h-n,i=e.s-r,l=e.l-a;return isNaN(i)&&(i=0,r=isNaN(r)?e.s:r),isNaN(o)?(o=0,n=isNaN(n)?e.h:n):o>180?o-=360:-180>o&&(o+=360),function(t){return ut(n+o*t,r+i*t,a+l*t)+""}}function jr(t,e){t=ui.lab(t),e=ui.lab(e);var n=t.l,r=t.a,a=t.b,o=e.l-n,i=e.a-r,l=e.b-a;return function(t){return pt(n+o*t,r+i*t,a+l*t)+""}}function Fr(t,e){return e-=t,function(n){return Math.round(t+e*n)}}function qr(t){var e=[t.a,t.b],n=[t.c,t.d],r=Hr(e),a=Br(e,n),o=Hr(Vr(n,e,-a))||0;e[0]*n[1]180?e+=360:e-t>180&&(t+=360),r.push({i:n.push(Zr(n)+"rotate(",null,")")-2,x:xr(t,e)})):e&&n.push(Zr(n)+"rotate("+e+")")}function Xr(t,e,n,r){t!==e?r.push({i:n.push(Zr(n)+"skewX(",null,")")-2,x:xr(t,e)}):e&&n.push(Zr(n)+"skewX("+e+")")}function Gr(t,e,n,r){if(t[0]!==e[0]||t[1]!==e[1]){var a=n.push(Zr(n)+"scale(",null,",",null,")");r.push({i:a-4,x:xr(t[0],e[0])},{i:a-2,x:xr(t[1],e[1])})}else 1===e[0]&&1===e[1]||n.push(Zr(n)+"scale("+e+")")}function $r(t,e){var n=[],r=[];return t=ui.transform(t),e=ui.transform(e),Yr(t.translate,e.translate,n,r),Ur(t.rotate,e.rotate,n,r),Xr(t.skew,e.skew,n,r),Gr(t.scale,e.scale,n,r),t=e=null,function(t){for(var e,a=-1,o=r.length;++a=0;)n.push(a[r])}function sa(t,e){for(var n=[t],r=[];null!=(t=n.pop());)if(r.push(t),(o=t.children)&&(a=o.length))for(var a,o,i=-1;++in;++n)(e=t[n][1])>a&&(r=n,a=e);return r}function xa(t){return t.reduce(ba,0)}function ba(t,e){return t+e[1]}function _a(t,e){return wa(t,Math.ceil(Math.log(e.length)/Math.LN2+1))}function wa(t,e){for(var n=-1,r=+t[0],a=(t[1]-r)/e,o=[];++n<=e;)o[n]=a*n+r;return o}function ka(t){return[ui.min(t),ui.max(t)]}function Ma(t,e){return t.value-e.value}function Aa(t,e){var n=t._pack_next;t._pack_next=e,e._pack_prev=t,e._pack_next=n,n._pack_prev=e}function Ta(t,e){t._pack_next=e,e._pack_prev=t}function La(t,e){var n=e.x-t.x,r=e.y-t.y,a=t.r+e.r;return.999*a*a>n*n+r*r}function za(t){function e(t){u=Math.min(t.x-t.r,u),f=Math.max(t.x+t.r,f),d=Math.min(t.y-t.r,d),h=Math.max(t.y+t.r,h)}if((n=t.children)&&(c=n.length)){var n,r,a,o,i,l,s,c,u=1/0,f=-(1/0),d=1/0,h=-(1/0);if(n.forEach(Sa),r=n[0],r.x=-r.r,r.y=0,e(r),c>1&&(a=n[1],a.x=a.r,a.y=0,e(a),c>2))for(o=n[2],Oa(r,a,o),e(o),Aa(r,o),r._pack_prev=o,Aa(o,a),a=r._pack_next,i=3;c>i;i++){Oa(r,a,o=n[i]);var p=0,g=1,v=1;for(l=a._pack_next;l!==a;l=l._pack_next,g++)if(La(l,o)){p=1;break}if(1==p)for(s=r._pack_prev;s!==l._pack_prev&&!La(s,o);s=s._pack_prev,v++);p?(v>g||g==v&&a.ri;i++)o=n[i],o.x-=m,o.y-=y,x=Math.max(x,o.r+Math.sqrt(o.x*o.x+o.y*o.y));t.r=x,n.forEach(Ca)}}function Sa(t){t._pack_next=t._pack_prev=t}function Ca(t){delete t._pack_next,delete t._pack_prev}function Ea(t,e,n,r){var a=t.children;if(t.x=e+=r*t.x,t.y=n+=r*t.y,t.r*=r,a)for(var o=-1,i=a.length;++o=0;)e=a[o],e.z+=n,e.m+=n,n+=e.s+(r+=e.c)}function ja(t,e,n){return t.a.parent===e.parent?t.a:n}function Fa(t){return 1+ui.max(t,function(t){return t.y})}function qa(t){return t.reduce(function(t,e){return t+e.x},0)/t.length}function Ba(t){var e=t.children;return e&&e.length?Ba(e[0]):t}function Ha(t){var e,n=t.children;return n&&(e=n.length)?Ha(n[e-1]):t}function Va(t){return{x:t.x,y:t.y,dx:t.dx,dy:t.dy}}function Za(t,e){var n=t.x+e[3],r=t.y+e[0],a=t.dx-e[1]-e[3],o=t.dy-e[0]-e[2];return 0>a&&(n+=a/2,a=0),0>o&&(r+=o/2,o=0),{x:n,y:r,dx:a,dy:o}}function Ya(t){var e=t[0],n=t[t.length-1];return n>e?[e,n]:[n,e]}function Ua(t){return t.rangeExtent?t.rangeExtent():Ya(t.range())}function Xa(t,e,n,r){var a=n(t[0],t[1]),o=r(e[0],e[1]);return function(t){return o(a(t))}}function Ga(t,e){var n,r=0,a=t.length-1,o=t[r],i=t[a];return o>i&&(n=r,r=a,a=n,n=o,o=i,i=n),t[r]=e.floor(o),t[a]=e.ceil(i),t}function $a(t){return t?{floor:function(e){return Math.floor(e/t)*t},ceil:function(e){return Math.ceil(e/t)*t}}:Ts}function Qa(t,e,n,r){var a=[],o=[],i=0,l=Math.min(t.length,e.length)-1;for(t[l]2?Qa:Xa,s=r?Wr:Qr;return i=a(t,e,s,n),l=a(e,t,s,_r),o}function o(t){return i(t)}var i,l;return o.invert=function(t){return l(t)},o.domain=function(e){return arguments.length?(t=e.map(Number),a()):t},o.range=function(t){return arguments.length?(e=t,a()):e},o.rangeRound=function(t){return o.range(t).interpolate(Fr)},o.clamp=function(t){return arguments.length?(r=t,a()):r},o.interpolate=function(t){return arguments.length?(n=t,a()):n},o.ticks=function(e){return eo(t,e)},o.tickFormat=function(e,n){return no(t,e,n)},o.nice=function(e){return Ka(t,e),a()},o.copy=function(){return Wa(t,e,n,r)},a()}function Ja(t,e){return ui.rebind(t,e,"range","rangeRound","interpolate","clamp")}function Ka(t,e){return Ga(t,$a(to(t,e)[2])),Ga(t,$a(to(t,e)[2])),t}function to(t,e){null==e&&(e=10);var n=Ya(t),r=n[1]-n[0],a=Math.pow(10,Math.floor(Math.log(r/e)/Math.LN10)),o=e/r*a;return.15>=o?a*=10:.35>=o?a*=5:.75>=o&&(a*=2),n[0]=Math.ceil(n[0]/a)*a,n[1]=Math.floor(n[1]/a)*a+.5*a,n[2]=a,n}function eo(t,e){return ui.range.apply(ui,to(t,e))}function no(t,e,n){var r=to(t,e);if(n){var a=pl.exec(n);if(a.shift(),"s"===a[8]){var o=ui.formatPrefix(Math.max(wi(r[0]),wi(r[1])));return a[7]||(a[7]="."+ro(o.scale(r[2]))),a[8]="f",n=ui.format(a.join("")),function(t){return n(o.scale(t))+o.symbol}}a[7]||(a[7]="."+ao(a[8],r)),n=a.join("")}else n=",."+ro(r[2])+"f";return ui.format(n)}function ro(t){return-Math.floor(Math.log(t)/Math.LN10+.01)}function ao(t,e){var n=ro(e[2]);return t in Ls?Math.abs(n-ro(Math.max(wi(e[0]),wi(e[1]))))+ +("e"!==t):n-2*("%"===t)}function oo(t,e,n,r){function a(t){return(n?Math.log(0>t?0:t):-Math.log(t>0?0:-t))/Math.log(e)}function o(t){return n?Math.pow(e,t):-Math.pow(e,-t)}function i(e){return t(a(e))}return i.invert=function(e){return o(t.invert(e))},i.domain=function(e){return arguments.length?(n=e[0]>=0,t.domain((r=e.map(Number)).map(a)),i):r},i.base=function(n){return arguments.length?(e=+n,t.domain(r.map(a)),i):e},i.nice=function(){var e=Ga(r.map(a),n?Math:Ss);return t.domain(e),r=e.map(o),i},i.ticks=function(){var t=Ya(r),i=[],l=t[0],s=t[1],c=Math.floor(a(l)),u=Math.ceil(a(s)),f=e%1?2:e;if(isFinite(u-c)){if(n){for(;u>c;c++)for(var d=1;f>d;d++)i.push(o(c)*d);i.push(o(c))}else for(i.push(o(c));c++0;d--)i.push(o(c)*d);for(c=0;i[c]s;u--);i=i.slice(c,u)}return i},i.tickFormat=function(t,n){if(!arguments.length)return zs;arguments.length<2?n=zs:"function"!=typeof n&&(n=ui.format(n));var r=Math.max(1,e*t/i.ticks().length);return function(t){var i=t/o(Math.round(a(t)));return e-.5>i*e&&(i*=e),r>=i?n(t):""}},i.copy=function(){return oo(t.copy(),e,n,r)},Ja(i,t)}function io(t,e,n){function r(e){return t(a(e))}var a=lo(e),o=lo(1/e);return r.invert=function(e){return o(t.invert(e))},r.domain=function(e){return arguments.length?(t.domain((n=e.map(Number)).map(a)),r):n},r.ticks=function(t){return eo(n,t)},r.tickFormat=function(t,e){return no(n,t,e)},r.nice=function(t){return r.domain(Ka(n,t))},r.exponent=function(i){return arguments.length?(a=lo(e=i),o=lo(1/e),t.domain(n.map(a)),r):e},r.copy=function(){return io(t.copy(),e,n)},Ja(r,t)}function lo(t){return function(e){return 0>e?-Math.pow(-e,t):Math.pow(e,t)}}function so(t,e){function n(n){return o[((a.get(n)||("range"===e.t?a.set(n,t.push(n)):NaN))-1)%o.length]}function r(e,n){return ui.range(t.length).map(function(t){return e+n*t})}var a,o,i;return n.domain=function(r){if(!arguments.length)return t;t=[],a=new f;for(var o,i=-1,l=r.length;++in?[NaN,NaN]:[n>0?l[n-1]:t[0],ne?NaN:e/o+t,[e,e+1/o]},r.copy=function(){return uo(t,e,n)},a()}function fo(t,e){function n(n){return n>=n?e[ui.bisect(t,n)]:void 0}return n.domain=function(e){return arguments.length?(t=e,n):t},n.range=function(t){return arguments.length?(e=t,n):e},n.invertExtent=function(n){return n=e.indexOf(n),[t[n-1],t[n]]},n.copy=function(){return fo(t,e)},n}function ho(t){function e(t){return+t}return e.invert=e,e.domain=e.range=function(n){return arguments.length?(t=n.map(e),e):t},e.ticks=function(e){return eo(t,e)},e.tickFormat=function(e,n){return no(t,e,n)},e.copy=function(){return ho(t)},e}function po(){return 0}function go(t){return t.innerRadius}function vo(t){return t.outerRadius}function mo(t){return t.startAngle}function yo(t){return t.endAngle}function xo(t){return t&&t.padAngle}function bo(t,e,n,r){return(t-n)*e-(e-r)*t>0?0:1}function _o(t,e,n,r,a){var o=t[0]-e[0],i=t[1]-e[1],l=(a?r:-r)/Math.sqrt(o*o+i*i),s=l*i,c=-l*o,u=t[0]+s,f=t[1]+c,d=e[0]+s,h=e[1]+c,p=(u+d)/2,g=(f+h)/2,v=d-u,m=h-f,y=v*v+m*m,x=n-r,b=u*h-d*f,_=(0>m?-1:1)*Math.sqrt(Math.max(0,x*x*y-b*b)),w=(b*m-v*_)/y,k=(-b*v-m*_)/y,M=(b*m+v*_)/y,A=(-b*v+m*_)/y,T=w-p,L=k-g,z=M-p,S=A-g;return T*T+L*L>z*z+S*S&&(w=M,k=A),[[w-s,k-c],[w*n/x,k*n/x]]}function wo(t){function e(e){function i(){c.push("M",o(t(u),l))}for(var s,c=[],u=[],f=-1,d=e.length,h=zt(n),p=zt(r);++f1?t.join("L"):t+"Z"}function Mo(t){return t.join("L")+"Z"}function Ao(t){for(var e=0,n=t.length,r=t[0],a=[r[0],",",r[1]];++e1&&a.push("H",r[0]),a.join("")}function To(t){for(var e=0,n=t.length,r=t[0],a=[r[0],",",r[1]];++e1){l=e[1],o=t[s],s++,r+="C"+(a[0]+i[0])+","+(a[1]+i[1])+","+(o[0]-l[0])+","+(o[1]-l[1])+","+o[0]+","+o[1];for(var c=2;c9&&(a=3*e/Math.sqrt(a),i[l]=a*n,i[l+1]=a*r));for(l=-1;++l<=s;)a=(t[Math.min(s,l+1)][0]-t[Math.max(0,l-1)][0])/(6*(1+i[l]*i[l])),o.push([a||0,i[l]*a||0]);return o}function Ho(t){return t.length<3?ko(t):t[0]+Eo(t,Bo(t))}function Vo(t){for(var e,n,r,a=-1,o=t.length;++a=e?i(t-e):void(c.c=i)}function i(n){var a=p.active,o=p[a];o&&(o.timer.c=null,o.timer.t=NaN,--p.count,delete p[a],o.event&&o.event.interrupt.call(t,t.__data__,o.index));for(var i in p)if(r>+i){var f=p[i];f.timer.c=null,f.timer.t=NaN,--p.count,delete p[i]}c.c=l,Pt(function(){return c.c&&l(n||1)&&(c.c=null,c.t=NaN),1},0,s),p.active=r,g.event&&g.event.start.call(t,t.__data__,e),h=[],g.tween.forEach(function(n,r){(r=r.call(t,t.__data__,e))&&h.push(r)}),d=g.ease,u=g.duration}function l(a){for(var o=a/u,i=d(o),l=h.length;l>0;)h[--l].call(t,i);return o>=1?(g.event&&g.event.end.call(t,t.__data__,e),--p.count?delete p[r]:delete t[n],1):void 0}var s,c,u,d,h,p=t[n]||(t[n]={active:0,count:0}),g=p[r];g||(s=a.time,c=Pt(o,0,s),g=p[r]={tween:new f,time:s,timer:c,delay:a.delay,duration:a.duration,ease:a.ease,index:e},a=null,++p.count)}function ri(t,e,n){t.attr("transform",function(t){var r=e(t);return"translate("+(isFinite(r)?r:n(t))+",0)"})}function ai(t,e,n){t.attr("transform",function(t){var r=e(t);return"translate(0,"+(isFinite(r)?r:n(t))+")"})}function oi(t){return t.toISOString()}function ii(t,e,n){function r(e){return t(e)}function a(t,n){var r=t[1]-t[0],a=r/n,o=ui.bisect(tc,a);return o==tc.length?[e.year,to(t.map(function(t){return t/31536e6}),n)[2]]:o?e[a/tc[o-1]1?{floor:function(e){for(;n(e=t.floor(e));)e=li(e-1);return e},ceil:function(e){for(;n(e=t.ceil(e));)e=li(+e+1);return e}}:t))},r.ticks=function(t,e){var n=Ya(r.domain()),o=null==t?a(n,10):"number"==typeof t?a(n,t):!t.range&&[{range:t},e];return o&&(t=o[0],e=o[1]),t.range(n[0],li(+n[1]+1),1>e?1:e)},r.tickFormat=function(){return n},r.copy=function(){return ii(t.copy(),e,n)},Ja(r,t)}function li(t){return new Date(t)}function si(t){return JSON.parse(t.responseText)}function ci(t){var e=hi.createRange();return e.selectNode(hi.body),e.createContextualFragment(t.responseText)}var ui={version:"3.5.16"},fi=[].slice,di=function(t){return fi.call(t)},hi=this.document;if(hi)try{di(hi.documentElement.childNodes)[0].nodeType}catch(pi){di=function(t){for(var e=t.length,n=new Array(e);e--;)n[e]=t[e];return n}}if(Date.now||(Date.now=function(){return+new Date}),hi)try{hi.createElement("DIV").style.setProperty("opacity",0,"")}catch(gi){var vi=this.Element.prototype,mi=vi.setAttribute,yi=vi.setAttributeNS,xi=this.CSSStyleDeclaration.prototype,bi=xi.setProperty;vi.setAttribute=function(t,e){mi.call(this,t,e+"")},vi.setAttributeNS=function(t,e,n){yi.call(this,t,e,n+"")},xi.setProperty=function(t,e,n){bi.call(this,t,e+"",n)}}ui.ascending=a,ui.descending=function(t,e){return t>e?-1:e>t?1:e>=t?0:NaN},ui.min=function(t,e){var n,r,a=-1,o=t.length;if(1===arguments.length){for(;++a=r){n=r;break}for(;++ar&&(n=r)}else{for(;++a=r){n=r;break}for(;++ar&&(n=r)}return n},ui.max=function(t,e){var n,r,a=-1,o=t.length;if(1===arguments.length){for(;++a=r){n=r;break}for(;++an&&(n=r)}else{for(;++a=r){n=r;break}for(;++an&&(n=r)}return n},ui.extent=function(t,e){var n,r,a,o=-1,i=t.length;if(1===arguments.length){for(;++o=r){n=a=r;break}for(;++or&&(n=r),r>a&&(a=r))}else{for(;++o=r){n=a=r;break}for(;++or&&(n=r),r>a&&(a=r))}return[n,a]},ui.sum=function(t,e){var n,r=0,a=t.length,o=-1;if(1===arguments.length)for(;++o1?s/(u-1):void 0},ui.deviation=function(){var t=ui.variance.apply(this,arguments);return t?Math.sqrt(t):t};var _i=l(a);ui.bisectLeft=_i.left,ui.bisect=ui.bisectRight=_i.right,ui.bisector=function(t){return l(1===t.length?function(e,n){return a(t(e),n)}:t)},ui.shuffle=function(t,e,n){(o=arguments.length)<3&&(n=t.length,2>o&&(e=0));for(var r,a,o=n-e;o;)a=Math.random()*o--|0,r=t[o+e],t[o+e]=t[a+e],t[a+e]=r;return t},ui.permute=function(t,e){for(var n=e.length,r=new Array(n);n--;)r[n]=t[e[n]];return r},ui.pairs=function(t){for(var e,n=0,r=t.length-1,a=t[0],o=new Array(0>r?0:r);r>n;)o[n]=[e=a,a=t[++n]];return o},ui.transpose=function(t){if(!(a=t.length))return[];for(var e=-1,n=ui.min(t,s),r=new Array(n);++e=0;)for(r=t[a],e=r.length;--e>=0;)n[--i]=r[e];return n};var wi=Math.abs;ui.range=function(t,e,n){if(arguments.length<3&&(n=1,arguments.length<2&&(e=t,t=0)),(e-t)/n===1/0)throw new Error("infinite range");var r,a=[],o=c(wi(n)),i=-1;if(t*=o,e*=o,n*=o,0>n)for(;(r=t+n*++i)>e;)a.push(r/o);else for(;(r=t+n*++i)=o.length)return r?r.call(a,i):n?i.sort(n):i;for(var s,c,u,d,h=-1,p=i.length,g=o[l++],v=new f;++h=o.length)return t;var r=[],a=i[n++];return t.forEach(function(t,a){r.push({key:t,values:e(a,n)})}),a?r.sort(function(t,e){return a(t.key,e.key)}):r}var n,r,a={},o=[],i=[];return a.map=function(e,n){return t(n,e,0)},a.entries=function(n){return e(t(ui.map,n,0),0)},a.key=function(t){return o.push(t),a},a.sortKeys=function(t){return i[o.length-1]=t,a},a.sortValues=function(t){return n=t,a},a.rollup=function(t){return r=t,a},a},ui.set=function(t){var e=new x;if(t)for(var n=0,r=t.length;r>n;++n)e.add(t[n]);return e},u(x,{has:p,add:function(t){return this._[d(t+="")]=!0,t},remove:g,values:v,size:m,empty:y,forEach:function(t){for(var e in this._)t.call(this,h(e))}}),ui.behavior={},ui.rebind=function(t,e){for(var n,r=1,a=arguments.length;++r=0&&(r=t.slice(n+1),t=t.slice(0,n)),t)return arguments.length<2?this[t].on(r):this[t].on(r,e);if(2===arguments.length){if(null==e)for(t in this)this.hasOwnProperty(t)&&this[t].on(r,null);return this}},ui.event=null,ui.requote=function(t){return t.replace(Ti,"\\$&")};var Ti=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,Li={}.__proto__?function(t,e){t.__proto__=e}:function(t,e){for(var n in e)t[n]=e[n]},zi=function(t,e){return e.querySelector(t)},Si=function(t,e){return e.querySelectorAll(t)},Ci=function(t,e){var n=t.matches||t[w(t,"matchesSelector")];return(Ci=function(t,e){return n.call(t,e)})(t,e)};"function"==typeof Sizzle&&(zi=function(t,e){return Sizzle(t,e)[0]||null},Si=Sizzle,Ci=Sizzle.matchesSelector),ui.selection=function(){return ui.select(hi.documentElement)};var Ei=ui.selection.prototype=[];Ei.select=function(t){var e,n,r,a,o=[];t=C(t);for(var i=-1,l=this.length;++i=0&&"xmlns"!==(n=t.slice(0,e))&&(t=t.slice(e+1)),Pi.hasOwnProperty(n)?{space:Pi[n],local:t}:t}},Ei.attr=function(t,e){if(arguments.length<2){if("string"==typeof t){var n=this.node();return t=ui.ns.qualify(t),t.local?n.getAttributeNS(t.space,t.local):n.getAttribute(t)}for(e in t)this.each(O(e,t[e]));return this}return this.each(O(t,e))},Ei.classed=function(t,e){if(arguments.length<2){if("string"==typeof t){var n=this.node(),r=(t=D(t)).length,a=-1;if(e=n.classList){for(;++aa){if("string"!=typeof t){2>a&&(e="");for(n in t)this.each(j(n,t[n],e));return this}if(2>a){var o=this.node();return r(o).getComputedStyle(o,null).getPropertyValue(t)}n=""}return this.each(j(t,e,n))},Ei.property=function(t,e){if(arguments.length<2){if("string"==typeof t)return this.node()[t];for(e in t)this.each(F(e,t[e]));return this}return this.each(F(t,e))},Ei.text=function(t){return arguments.length?this.each("function"==typeof t?function(){var e=t.apply(this,arguments);this.textContent=null==e?"":e}:null==t?function(){this.textContent=""}:function(){this.textContent=t}):this.node().textContent},Ei.html=function(t){return arguments.length?this.each("function"==typeof t?function(){var e=t.apply(this,arguments);this.innerHTML=null==e?"":e}:null==t?function(){this.innerHTML=""}:function(){this.innerHTML=t}):this.node().innerHTML},Ei.append=function(t){return t=q(t),this.select(function(){return this.appendChild(t.apply(this,arguments))})},Ei.insert=function(t,e){return t=q(t),e=C(e),this.select(function(){return this.insertBefore(t.apply(this,arguments),e.apply(this,arguments)||null)})},Ei.remove=function(){return this.each(B)},Ei.data=function(t,e){function n(t,n){var r,a,o,i=t.length,u=n.length,d=Math.min(i,u),h=new Array(u),p=new Array(u),g=new Array(i);if(e){var v,m=new f,y=new Array(i);for(r=-1;++rr;++r)p[r]=H(n[r]);for(;i>r;++r)g[r]=t[r]}p.update=h,p.parentNode=h.parentNode=g.parentNode=t.parentNode,l.push(p),s.push(h),c.push(g)}var r,a,o=-1,i=this.length;if(!arguments.length){for(t=new Array(i=(r=this[0]).length);++oo;o++){a.push(e=[]),e.parentNode=(n=this[o]).parentNode;for(var l=0,s=n.length;s>l;l++)(r=n[l])&&t.call(r,r.__data__,l,o)&&e.push(r)}return S(a)},Ei.order=function(){for(var t=-1,e=this.length;++t=0;)(n=r[a])&&(o&&o!==n.nextSibling&&o.parentNode.insertBefore(n,o),o=n);return this},Ei.sort=function(t){t=Z.apply(this,arguments);for(var e=-1,n=this.length;++et;t++)for(var n=this[t],r=0,a=n.length;a>r;r++){var o=n[r];if(o)return o}return null},Ei.size=function(){var t=0;return Y(this,function(){++t}),t};var Ni=[];ui.selection.enter=U,ui.selection.enter.prototype=Ni,Ni.append=Ei.append,Ni.empty=Ei.empty,Ni.node=Ei.node,Ni.call=Ei.call,Ni.size=Ei.size,Ni.select=function(t){for(var e,n,r,a,o,i=[],l=-1,s=this.length;++lr){if("string"!=typeof t){2>r&&(e=!1);for(n in t)this.each(G(n,t[n],e));return this}if(2>r)return(r=this.node()["__on"+t])&&r._;n=!1}return this.each(G(t,e,n))};var Di=ui.map({mouseenter:"mouseover",mouseleave:"mouseout"});hi&&Di.forEach(function(t){"on"+t in hi&&Di.remove(t)});var Ii,Ri=0;ui.mouse=function(t){return J(t,L())};var ji=this.navigator&&/WebKit/.test(this.navigator.userAgent)?-1:0;ui.touch=function(t,e,n){if(arguments.length<3&&(n=e,e=L().changedTouches),e)for(var r,a=0,o=e.length;o>a;++a)if((r=e[a]).identifier===n)return J(t,r)},ui.behavior.drag=function(){function t(){this.on("mousedown.drag",o).on("touchstart.drag",i)}function e(t,e,r,o,i){return function(){function l(){var t,n,r=e(d,g);r&&(t=r[0]-x[0],n=r[1]-x[1],p|=t|n,x=r,h({type:"drag",x:r[0]+c[0],y:r[1]+c[1],dx:t,dy:n}))}function s(){e(d,g)&&(m.on(o+v,null).on(i+v,null),y(p),h({type:"dragend"}))}var c,u=this,f=ui.event.target.correspondingElement||ui.event.target,d=u.parentNode,h=n.of(u,arguments),p=0,g=t(),v=".drag"+(null==g?"":"-"+g),m=ui.select(r(f)).on(o+v,l).on(i+v,s),y=W(f),x=e(d,g);a?(c=a.apply(u,arguments),c=[c.x-x[0],c.y-x[1]]):c=[0,0],h({type:"dragstart"})}}var n=z(t,"drag","dragstart","dragend"),a=null,o=e(k,ui.mouse,r,"mousemove","mouseup"),i=e(K,ui.touch,b,"touchmove","touchend");return t.origin=function(e){return arguments.length?(a=e,t):a},ui.rebind(t,n,"on")},ui.touches=function(t,e){return arguments.length<2&&(e=L().touches),e?di(e).map(function(e){var n=J(t,e);return n.identifier=e.identifier,n}):[]};var Fi=1e-6,qi=Fi*Fi,Bi=Math.PI,Hi=2*Bi,Vi=Hi-Fi,Zi=Bi/2,Yi=Bi/180,Ui=180/Bi,Xi=Math.SQRT2,Gi=2,$i=4;ui.interpolateZoom=function(t,e){var n,r,a=t[0],o=t[1],i=t[2],l=e[0],s=e[1],c=e[2],u=l-a,f=s-o,d=u*u+f*f;if(qi>d)r=Math.log(c/i)/Xi,n=function(t){return[a+t*u,o+t*f,i*Math.exp(Xi*t*r)]};else{var h=Math.sqrt(d),p=(c*c-i*i+$i*d)/(2*i*Gi*h),g=(c*c-i*i-$i*d)/(2*c*Gi*h),v=Math.log(Math.sqrt(p*p+1)-p),m=Math.log(Math.sqrt(g*g+1)-g);r=(m-v)/Xi,n=function(t){var e=t*r,n=ot(v),l=i/(Gi*h)*(n*it(Xi*e+v)-at(v));return[a+l*u,o+l*f,i*n/ot(Xi*e+v)]}}return n.duration=1e3*r,n},ui.behavior.zoom=function(){function t(t){t.on(E,f).on(Wi+".zoom",h).on("dblclick.zoom",p).on(N,d)}function e(t){return[(t[0]-M.x)/M.k,(t[1]-M.y)/M.k]}function n(t){return[t[0]*M.k+M.x,t[1]*M.k+M.y]}function a(t){M.k=Math.max(L[0],Math.min(L[1],t))}function o(t,e){e=n(e),M.x+=t[0]-e[0],M.y+=t[1]-e[1]}function i(e,n,r,i){e.__chart__={x:M.x,y:M.y,k:M.k},a(Math.pow(2,i)),o(v=n,r),e=ui.select(e),S>0&&(e=e.transition().duration(S)),e.call(t.event)}function l(){_&&_.domain(b.range().map(function(t){return(t-M.x)/M.k}).map(b.invert)),k&&k.domain(w.range().map(function(t){return(t-M.y)/M.k}).map(w.invert))}function s(t){C++||t({type:"zoomstart"})}function c(t){l(),t({type:"zoom",scale:M.k,translate:[M.x,M.y]})}function u(t){--C||(t({type:"zoomend"}),v=null)}function f(){function t(){l=1,o(ui.mouse(a),d),c(i)}function n(){f.on(O,null).on(P,null),h(l),u(i)}var a=this,i=D.of(a,arguments),l=0,f=ui.select(r(a)).on(O,t).on(P,n),d=e(ui.mouse(a)),h=W(a);Zs.call(a),s(i)}function d(){function t(){var t=ui.touches(p);return h=M.k,t.forEach(function(t){t.identifier in v&&(v[t.identifier]=e(t))}),t}function n(){var e=ui.event.target;ui.select(e).on(b,r).on(_,l),w.push(e);for(var n=ui.event.changedTouches,a=0,o=n.length;o>a;++a)v[n[a].identifier]=null;var s=t(),c=Date.now();if(1===s.length){if(500>c-x){var u=s[0];i(p,u,v[u.identifier],Math.floor(Math.log(M.k)/Math.LN2)+1),T()}x=c}else if(s.length>1){var u=s[0],f=s[1],d=u[0]-f[0],h=u[1]-f[1];m=d*d+h*h}}function r(){var t,e,n,r,i=ui.touches(p);Zs.call(p);for(var l=0,s=i.length;s>l;++l,r=null)if(n=i[l],r=v[n.identifier]){if(e)break;t=n,e=r}if(r){var u=(u=n[0]-t[0])*u+(u=n[1]-t[1])*u,f=m&&Math.sqrt(u/m);t=[(t[0]+n[0])/2,(t[1]+n[1])/2],e=[(e[0]+r[0])/2,(e[1]+r[1])/2],a(f*h)}x=null,o(t,e),c(g)}function l(){if(ui.event.touches.length){for(var e=ui.event.changedTouches,n=0,r=e.length;r>n;++n)delete v[e[n].identifier];for(var a in v)return void t()}ui.selectAll(w).on(y,null),k.on(E,f).on(N,d),A(),u(g)}var h,p=this,g=D.of(p,arguments),v={},m=0,y=".zoom-"+ui.event.changedTouches[0].identifier,b="touchmove"+y,_="touchend"+y,w=[],k=ui.select(p),A=W(p);n(),s(g),k.on(E,null).on(N,n)}function h(){var t=D.of(this,arguments);y?clearTimeout(y):(Zs.call(this),g=e(v=m||ui.mouse(this)),s(t)),y=setTimeout(function(){y=null,u(t)},50),T(),a(Math.pow(2,.002*Qi())*M.k),o(v,g),c(t)}function p(){var t=ui.mouse(this),n=Math.log(M.k)/Math.LN2;i(this,t,e(t),ui.event.shiftKey?Math.ceil(n)-1:Math.floor(n)+1)}var g,v,m,y,x,b,_,w,k,M={x:0,y:0,k:1},A=[960,500],L=Ji,S=250,C=0,E="mousedown.zoom",O="mousemove.zoom",P="mouseup.zoom",N="touchstart.zoom",D=z(t,"zoomstart","zoom","zoomend");return Wi||(Wi="onwheel"in hi?(Qi=function(){return-ui.event.deltaY*(ui.event.deltaMode?120:1)},"wheel"):"onmousewheel"in hi?(Qi=function(){return ui.event.wheelDelta},"mousewheel"):(Qi=function(){return-ui.event.detail},"MozMousePixelScroll")),t.event=function(t){t.each(function(){var t=D.of(this,arguments),e=M;Hs?ui.select(this).transition().each("start.zoom",function(){M=this.__chart__||{x:0,y:0,k:1},s(t)}).tween("zoom:zoom",function(){var n=A[0],r=A[1],a=v?v[0]:n/2,o=v?v[1]:r/2,i=ui.interpolateZoom([(a-M.x)/M.k,(o-M.y)/M.k,n/M.k],[(a-e.x)/e.k,(o-e.y)/e.k,n/e.k]);return function(e){var r=i(e),l=n/r[2];this.__chart__=M={x:a-r[0]*l,y:o-r[1]*l,k:l},c(t)}}).each("interrupt.zoom",function(){u(t)}).each("end.zoom",function(){u(t)}):(this.__chart__=M,s(t),c(t),u(t))})},t.translate=function(e){return arguments.length?(M={x:+e[0],y:+e[1],k:M.k},l(),t):[M.x,M.y]},t.scale=function(e){return arguments.length?(M={x:M.x,y:M.y,k:null},a(+e),l(),t):M.k},t.scaleExtent=function(e){return arguments.length?(L=null==e?Ji:[+e[0],+e[1]],t):L},t.center=function(e){return arguments.length?(m=e&&[+e[0],+e[1]],t):m},t.size=function(e){return arguments.length?(A=e&&[+e[0],+e[1]],t):A},t.duration=function(e){return arguments.length?(S=+e,t):S},t.x=function(e){return arguments.length?(_=e,b=e.copy(),M={x:0,y:0,k:1},t):_},t.y=function(e){return arguments.length?(k=e,w=e.copy(),M={x:0,y:0,k:1},t):k},ui.rebind(t,D,"on")};var Qi,Wi,Ji=[0,1/0];ui.color=st,st.prototype.toString=function(){return this.rgb()+""},ui.hsl=ct;var Ki=ct.prototype=new st;Ki.brighter=function(t){return t=Math.pow(.7,arguments.length?t:1),new ct(this.h,this.s,this.l/t)},Ki.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new ct(this.h,this.s,t*this.l)},Ki.rgb=function(){return ut(this.h,this.s,this.l)},ui.hcl=ft;var tl=ft.prototype=new st;tl.brighter=function(t){return new ft(this.h,this.c,Math.min(100,this.l+el*(arguments.length?t:1)))},tl.darker=function(t){return new ft(this.h,this.c,Math.max(0,this.l-el*(arguments.length?t:1)))},tl.rgb=function(){return dt(this.h,this.c,this.l).rgb()},ui.lab=ht;var el=18,nl=.95047,rl=1,al=1.08883,ol=ht.prototype=new st;ol.brighter=function(t){return new ht(Math.min(100,this.l+el*(arguments.length?t:1)),this.a,this.b)},ol.darker=function(t){return new ht(Math.max(0,this.l-el*(arguments.length?t:1)),this.a,this.b)},ol.rgb=function(){return pt(this.l,this.a,this.b)},ui.rgb=xt;var il=xt.prototype=new st;il.brighter=function(t){t=Math.pow(.7,arguments.length?t:1);var e=this.r,n=this.g,r=this.b,a=30;return e||n||r?(e&&a>e&&(e=a),n&&a>n&&(n=a),r&&a>r&&(r=a),new xt(Math.min(255,e/t),Math.min(255,n/t),Math.min(255,r/t))):new xt(a,a,a)},il.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new xt(t*this.r,t*this.g,t*this.b)},il.hsl=function(){return Mt(this.r,this.g,this.b)},il.toString=function(){return"#"+wt(this.r)+wt(this.g)+wt(this.b)};var ll=ui.map({aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074});ll.forEach(function(t,e){ll.set(t,bt(e))}),ui.functor=zt,ui.xhr=St(b),ui.dsv=function(t,e){function n(t,n,o){arguments.length<3&&(o=n,n=null);var i=Ct(t,e,null==n?r:a(n),o);return i.row=function(t){return arguments.length?i.response(null==(n=t)?r:a(t)):n},i}function r(t){return n.parse(t.responseText)}function a(t){return function(e){return n.parse(e.responseText,t)}}function o(e){return e.map(i).join(t)}function i(t){return l.test(t)?'"'+t.replace(/\"/g,'""')+'"':t}var l=new RegExp('["'+t+"\n]"),s=t.charCodeAt(0);return n.parse=function(t,e){var r;return n.parseRows(t,function(t,n){if(r)return r(t,n-1);var a=new Function("d","return {"+t.map(function(t,e){return JSON.stringify(t)+": d["+e+"]"}).join(",")+"}");r=e?function(t,n){return e(a(t),n)}:a})},n.parseRows=function(t,e){function n(){if(u>=c)return i;if(a)return a=!1,o;var e=u;if(34===t.charCodeAt(e)){for(var n=e;n++u;){var r=t.charCodeAt(u++),l=1;if(10===r)a=!0;else if(13===r)a=!0,10===t.charCodeAt(u)&&(++u,++l);else if(r!==s)continue;return t.slice(e,u-l)}return t.slice(e)}for(var r,a,o={},i={},l=[],c=t.length,u=0,f=0;(r=n())!==i;){for(var d=[];r!==o&&r!==i;)d.push(r),r=n();e&&null==(d=e(d,f++))||l.push(d)}return l},n.format=function(e){if(Array.isArray(e[0]))return n.formatRows(e);var r=new x,a=[];return e.forEach(function(t){for(var e in t)r.has(e)||a.push(r.add(e))}),[a.map(i).join(t)].concat(e.map(function(e){return a.map(function(t){return i(e[t])}).join(t)})).join("\n")},n.formatRows=function(t){return t.map(o).join("\n")},n},ui.csv=ui.dsv(",","text/csv"),ui.tsv=ui.dsv(" ","text/tab-separated-values");var sl,cl,ul,fl,dl=this[w(this,"requestAnimationFrame")]||function(t){setTimeout(t,17)};ui.timer=function(){Pt.apply(this,arguments)},ui.timer.flush=function(){Dt(),It()},ui.round=function(t,e){return e?Math.round(t*(e=Math.pow(10,e)))/e:Math.round(t)};var hl=["y","z","a","f","p","n","\xb5","m","","k","M","G","T","P","E","Z","Y"].map(jt);ui.formatPrefix=function(t,e){var n=0;return(t=+t)&&(0>t&&(t*=-1),e&&(t=ui.round(t,Rt(t,e))),n=1+Math.floor(1e-12+Math.log(t)/Math.LN10),n=Math.max(-24,Math.min(24,3*Math.floor((n-1)/3)))),hl[8+n/3]};var pl=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,gl=ui.map({b:function(t){return t.toString(2)},c:function(t){return String.fromCharCode(t)},o:function(t){return t.toString(8)},x:function(t){return t.toString(16)},X:function(t){return t.toString(16).toUpperCase()},g:function(t,e){return t.toPrecision(e)},e:function(t,e){return t.toExponential(e)},f:function(t,e){return t.toFixed(e)},r:function(t,e){return(t=ui.round(t,Rt(t,e))).toFixed(Math.max(0,Math.min(20,Rt(t*(1+1e-15),e))))}}),vl=ui.time={},ml=Date;Bt.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){yl.setUTCDate.apply(this._,arguments)},setDay:function(){yl.setUTCDay.apply(this._,arguments)},setFullYear:function(){yl.setUTCFullYear.apply(this._,arguments)},setHours:function(){yl.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){yl.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){yl.setUTCMinutes.apply(this._,arguments)},setMonth:function(){yl.setUTCMonth.apply(this._,arguments)},setSeconds:function(){yl.setUTCSeconds.apply(this._,arguments)},setTime:function(){yl.setTime.apply(this._,arguments)}};var yl=Date.prototype;vl.year=Ht(function(t){return t=vl.day(t),t.setMonth(0,1),t},function(t,e){t.setFullYear(t.getFullYear()+e)},function(t){return t.getFullYear()}),vl.years=vl.year.range,vl.years.utc=vl.year.utc.range,vl.day=Ht(function(t){var e=new ml(2e3,0);return e.setFullYear(t.getFullYear(),t.getMonth(),t.getDate()),e},function(t,e){t.setDate(t.getDate()+e)},function(t){return t.getDate()-1}),vl.days=vl.day.range,vl.days.utc=vl.day.utc.range,vl.dayOfYear=function(t){var e=vl.year(t);return Math.floor((t-e-6e4*(t.getTimezoneOffset()-e.getTimezoneOffset()))/864e5)},["sunday","monday","tuesday","wednesday","thursday","friday","saturday"].forEach(function(t,e){e=7-e;var n=vl[t]=Ht(function(t){return(t=vl.day(t)).setDate(t.getDate()-(t.getDay()+e)%7),t},function(t,e){t.setDate(t.getDate()+7*Math.floor(e))},function(t){var n=vl.year(t).getDay();return Math.floor((vl.dayOfYear(t)+(n+e)%7)/7)-(n!==e)});vl[t+"s"]=n.range,vl[t+"s"].utc=n.utc.range,vl[t+"OfYear"]=function(t){var n=vl.year(t).getDay();return Math.floor((vl.dayOfYear(t)+(n+e)%7)/7)}}),vl.week=vl.sunday,vl.weeks=vl.sunday.range,vl.weeks.utc=vl.sunday.utc.range,vl.weekOfYear=vl.sundayOfYear;var xl={"-":"",_:" ",0:"0"},bl=/^\s*\d+/,_l=/^%/;ui.locale=function(t){return{numberFormat:Ft(t),timeFormat:Zt(t)}};var wl=ui.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});ui.format=wl.numberFormat,ui.geo={},fe.prototype={s:0,t:0,add:function(t){de(t,this.t,kl),de(kl.s,this.s,this),this.s?this.t+=kl.t:this.s=kl.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var kl=new fe;ui.geo.stream=function(t,e){t&&Ml.hasOwnProperty(t.type)?Ml[t.type](t,e):he(t,e)};var Ml={Feature:function(t,e){he(t.geometry,e)},FeatureCollection:function(t,e){for(var n=t.features,r=-1,a=n.length;++rt?4*Bi+t:t,zl.lineStart=zl.lineEnd=zl.point=k}};ui.geo.bounds=function(){function t(t,e){x.push(b=[u=t,d=t]),f>e&&(f=e),e>h&&(h=e)}function e(e,n){var r=me([e*Yi,n*Yi]);if(m){var a=xe(m,r),o=[a[1],-a[0],0],i=xe(o,a);we(i),i=ke(i);var s=e-p,c=s>0?1:-1,g=i[0]*Ui*c,v=wi(s)>180;if(v^(g>c*p&&c*e>g)){var y=i[1]*Ui;y>h&&(h=y)}else if(g=(g+360)%360-180,v^(g>c*p&&c*e>g)){var y=-i[1]*Ui;f>y&&(f=y)}else f>n&&(f=n),n>h&&(h=n);v?p>e?l(u,e)>l(u,d)&&(d=e):l(e,d)>l(u,d)&&(u=e):d>=u?(u>e&&(u=e),e>d&&(d=e)):e>p?l(u,e)>l(u,d)&&(d=e):l(e,d)>l(u,d)&&(u=e)}else t(e,n);m=r,p=e}function n(){_.point=e}function r(){b[0]=u,b[1]=d,_.point=t,m=null}function a(t,n){if(m){var r=t-p;y+=wi(r)>180?r+(r>0?360:-360):r}else g=t,v=n;zl.point(t,n),e(t,n)}function o(){zl.lineStart()}function i(){a(g,v),zl.lineEnd(),wi(y)>Fi&&(u=-(d=180)),b[0]=u,b[1]=d,m=null}function l(t,e){return(e-=t)<0?e+360:e}function s(t,e){return t[0]-e[0]}function c(t,e){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:tLl?(u=-(d=180),f=-(h=90)):y>Fi?h=90:-Fi>y&&(f=-90),b[0]=u,b[1]=d}};return function(t){h=d=-(u=f=1/0),x=[],ui.geo.stream(t,_);var e=x.length;if(e){x.sort(s);for(var n,r=1,a=x[0],o=[a];e>r;++r)n=x[r],c(n[0],a)||c(n[1],a)?(l(a[0],n[1])>l(a[0],a[1])&&(a[1]=n[1]),l(n[0],a[1])>l(a[0],a[1])&&(a[0]=n[0])):o.push(a=n);for(var i,n,p=-(1/0),e=o.length-1,r=0,a=o[e];e>=r;a=n,++r)n=o[r],(i=l(a[1],n[0]))>p&&(p=i,u=n[0],d=a[1])}return x=b=null,u===1/0||f===1/0?[[NaN,NaN],[NaN,NaN]]:[[u,f],[d,h]]}}(),ui.geo.centroid=function(t){Sl=Cl=El=Ol=Pl=Nl=Dl=Il=Rl=jl=Fl=0,ui.geo.stream(t,ql);var e=Rl,n=jl,r=Fl,a=e*e+n*n+r*r;return qi>a&&(e=Nl,n=Dl,r=Il,Fi>Cl&&(e=El,n=Ol,r=Pl),a=e*e+n*n+r*r,qi>a)?[NaN,NaN]:[Math.atan2(n,e)*Ui,rt(r/Math.sqrt(a))*Ui]};var Sl,Cl,El,Ol,Pl,Nl,Dl,Il,Rl,jl,Fl,ql={sphere:k,point:Ae,lineStart:Le,lineEnd:ze,polygonStart:function(){ql.lineStart=Se},polygonEnd:function(){ql.lineStart=Le}},Bl=De(Ee,Fe,Be,[-Bi,-Bi/2]),Hl=1e9;ui.geo.clipExtent=function(){var t,e,n,r,a,o,i={stream:function(t){return a&&(a.valid=!1),a=o(t),a.valid=!0,a},extent:function(l){return arguments.length?(o=Ye(t=+l[0][0],e=+l[0][1],n=+l[1][0],r=+l[1][1]),a&&(a.valid=!1,a=null),i):[[t,e],[n,r]]}};return i.extent([[0,0],[960,500]])},(ui.geo.conicEqualArea=function(){return Ue(Xe)}).raw=Xe,ui.geo.albers=function(){return ui.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},ui.geo.albersUsa=function(){function t(t){var o=t[0],i=t[1];return e=null,n(o,i),e||(r(o,i),e)||a(o,i),e}var e,n,r,a,o=ui.geo.albers(),i=ui.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),l=ui.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),s={point:function(t,n){e=[t,n]}};return t.invert=function(t){var e=o.scale(),n=o.translate(),r=(t[0]-n[0])/e,a=(t[1]-n[1])/e;return(a>=.12&&.234>a&&r>=-.425&&-.214>r?i:a>=.166&&.234>a&&r>=-.214&&-.115>r?l:o).invert(t)},t.stream=function(t){var e=o.stream(t),n=i.stream(t),r=l.stream(t);return{point:function(t,a){e.point(t,a),n.point(t,a),r.point(t,a)},sphere:function(){e.sphere(),n.sphere(),r.sphere()},lineStart:function(){e.lineStart(),n.lineStart(),r.lineStart()},lineEnd:function(){e.lineEnd(),n.lineEnd(),r.lineEnd()},polygonStart:function(){e.polygonStart(),n.polygonStart(),r.polygonStart()},polygonEnd:function(){e.polygonEnd(),n.polygonEnd(),r.polygonEnd()}}},t.precision=function(e){return arguments.length?(o.precision(e),i.precision(e),l.precision(e),t):o.precision()},t.scale=function(e){return arguments.length?(o.scale(e),i.scale(.35*e),l.scale(e),t.translate(o.translate())):o.scale()},t.translate=function(e){if(!arguments.length)return o.translate();var c=o.scale(),u=+e[0],f=+e[1];return n=o.translate(e).clipExtent([[u-.455*c,f-.238*c],[u+.455*c,f+.238*c]]).stream(s).point,r=i.translate([u-.307*c,f+.201*c]).clipExtent([[u-.425*c+Fi,f+.12*c+Fi],[u-.214*c-Fi,f+.234*c-Fi]]).stream(s).point,a=l.translate([u-.205*c,f+.212*c]).clipExtent([[u-.214*c+Fi,f+.166*c+Fi],[u-.115*c-Fi,f+.234*c-Fi]]).stream(s).point,t},t.scale(1070)};var Vl,Zl,Yl,Ul,Xl,Gl,$l={point:k,lineStart:k,lineEnd:k,polygonStart:function(){Zl=0,$l.lineStart=Ge},polygonEnd:function(){$l.lineStart=$l.lineEnd=$l.point=k,Vl+=wi(Zl/2)}},Ql={point:$e,lineStart:k,lineEnd:k,polygonStart:k,polygonEnd:k},Wl={point:Je,lineStart:Ke,lineEnd:tn,polygonStart:function(){Wl.lineStart=en},polygonEnd:function(){Wl.point=Je,Wl.lineStart=Ke,Wl.lineEnd=tn}};ui.geo.path=function(){function t(t){return t&&("function"==typeof l&&o.pointRadius(+l.apply(this,arguments)),i&&i.valid||(i=a(o)),ui.geo.stream(t,i)),o.result()}function e(){return i=null,t}var n,r,a,o,i,l=4.5;return t.area=function(t){return Vl=0,ui.geo.stream(t,a($l)),Vl},t.centroid=function(t){return El=Ol=Pl=Nl=Dl=Il=Rl=jl=Fl=0,ui.geo.stream(t,a(Wl)),Fl?[Rl/Fl,jl/Fl]:Il?[Nl/Il,Dl/Il]:Pl?[El/Pl,Ol/Pl]:[NaN,NaN]},t.bounds=function(t){return Xl=Gl=-(Yl=Ul=1/0),ui.geo.stream(t,a(Ql)),[[Yl,Ul],[Xl,Gl]]},t.projection=function(t){return arguments.length?(a=(n=t)?t.stream||an(t):b,e()):n},t.context=function(t){return arguments.length?(o=null==(r=t)?new Qe:new nn(t),"function"!=typeof l&&o.pointRadius(l),e()):r},t.pointRadius=function(e){return arguments.length?(l="function"==typeof e?e:(o.pointRadius(+e),+e),t):l},t.projection(ui.geo.albersUsa()).context(null)},ui.geo.transform=function(t){return{stream:function(e){var n=new on(e);for(var r in t)n[r]=t[r];return n}}},on.prototype={point:function(t,e){this.stream.point(t,e)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}},ui.geo.projection=sn,ui.geo.projectionMutator=cn,(ui.geo.equirectangular=function(){return sn(fn)}).raw=fn.invert=fn,ui.geo.rotation=function(t){function e(e){return e=t(e[0]*Yi,e[1]*Yi),e[0]*=Ui,e[1]*=Ui,e}return t=hn(t[0]%360*Yi,t[1]*Yi,t.length>2?t[2]*Yi:0),e.invert=function(e){return e=t.invert(e[0]*Yi,e[1]*Yi),e[0]*=Ui,e[1]*=Ui,e},e},dn.invert=fn,ui.geo.circle=function(){function t(){var t="function"==typeof r?r.apply(this,arguments):r,e=hn(-t[0]*Yi,-t[1]*Yi,0).invert,a=[];return n(null,null,1,{point:function(t,n){a.push(t=e(t,n)),t[0]*=Ui,t[1]*=Ui}}),{type:"Polygon",coordinates:[a]}}var e,n,r=[0,0],a=6;return t.origin=function(e){return arguments.length?(r=e,t):r},t.angle=function(r){return arguments.length?(n=mn((e=+r)*Yi,a*Yi),t):e},t.precision=function(r){return arguments.length?(n=mn(e*Yi,(a=+r)*Yi),t):a},t.angle(90)},ui.geo.distance=function(t,e){var n,r=(e[0]-t[0])*Yi,a=t[1]*Yi,o=e[1]*Yi,i=Math.sin(r),l=Math.cos(r),s=Math.sin(a),c=Math.cos(a),u=Math.sin(o),f=Math.cos(o);return Math.atan2(Math.sqrt((n=f*i)*n+(n=c*u-s*f*l)*n),s*u+c*f*l)},ui.geo.graticule=function(){function t(){return{type:"MultiLineString",coordinates:e()}}function e(){return ui.range(Math.ceil(o/v)*v,a,v).map(d).concat(ui.range(Math.ceil(c/m)*m,s,m).map(h)).concat(ui.range(Math.ceil(r/p)*p,n,p).filter(function(t){return wi(t%v)>Fi}).map(u)).concat(ui.range(Math.ceil(l/g)*g,i,g).filter(function(t){return wi(t%m)>Fi}).map(f))}var n,r,a,o,i,l,s,c,u,f,d,h,p=10,g=p,v=90,m=360,y=2.5;return t.lines=function(){return e().map(function(t){return{type:"LineString",coordinates:t}})},t.outline=function(){return{type:"Polygon",coordinates:[d(o).concat(h(s).slice(1),d(a).reverse().slice(1),h(c).reverse().slice(1))]}},t.extent=function(e){return arguments.length?t.majorExtent(e).minorExtent(e):t.minorExtent()},t.majorExtent=function(e){return arguments.length?(o=+e[0][0],a=+e[1][0],c=+e[0][1],s=+e[1][1],o>a&&(e=o,o=a,a=e),c>s&&(e=c,c=s,s=e),t.precision(y)):[[o,c],[a,s]]},t.minorExtent=function(e){return arguments.length?(r=+e[0][0],n=+e[1][0],l=+e[0][1],i=+e[1][1],r>n&&(e=r,r=n,n=e),l>i&&(e=l,l=i,i=e),t.precision(y)):[[r,l],[n,i]]},t.step=function(e){return arguments.length?t.majorStep(e).minorStep(e):t.minorStep()},t.majorStep=function(e){return arguments.length?(v=+e[0],m=+e[1],t):[v,m]},t.minorStep=function(e){return arguments.length?(p=+e[0],g=+e[1],t):[p,g]},t.precision=function(e){return arguments.length?(y=+e,u=xn(l,i,90),f=bn(r,n,y),d=xn(c,s,90),h=bn(o,a,y),t):y},t.majorExtent([[-180,-90+Fi],[180,90-Fi]]).minorExtent([[-180,-80-Fi],[180,80+Fi]])},ui.geo.greatArc=function(){function t(){return{type:"LineString",coordinates:[e||r.apply(this,arguments),n||a.apply(this,arguments)]}}var e,n,r=_n,a=wn;return t.distance=function(){return ui.geo.distance(e||r.apply(this,arguments),n||a.apply(this,arguments))},t.source=function(n){return arguments.length?(r=n,e="function"==typeof n?null:n,t):r},t.target=function(e){return arguments.length?(a=e,n="function"==typeof e?null:e,t):a},t.precision=function(){return arguments.length?t:0},t},ui.geo.interpolate=function(t,e){return kn(t[0]*Yi,t[1]*Yi,e[0]*Yi,e[1]*Yi)},ui.geo.length=function(t){return Jl=0,ui.geo.stream(t,Kl),Jl};var Jl,Kl={sphere:k,point:k,lineStart:Mn,lineEnd:k,polygonStart:k,polygonEnd:k},ts=An(function(t){return Math.sqrt(2/(1+t))},function(t){return 2*Math.asin(t/2)});(ui.geo.azimuthalEqualArea=function(){return sn(ts)}).raw=ts;var es=An(function(t){var e=Math.acos(t);return e&&e/Math.sin(e)},b);(ui.geo.azimuthalEquidistant=function(){return sn(es)}).raw=es,(ui.geo.conicConformal=function(){return Ue(Tn)}).raw=Tn,(ui.geo.conicEquidistant=function(){return Ue(Ln)}).raw=Ln;var ns=An(function(t){return 1/t},Math.atan);(ui.geo.gnomonic=function(){return sn(ns)}).raw=ns,zn.invert=function(t,e){return[t,2*Math.atan(Math.exp(e))-Zi]},(ui.geo.mercator=function(){return Sn(zn)}).raw=zn;var rs=An(function(){return 1},Math.asin);(ui.geo.orthographic=function(){return sn(rs)}).raw=rs;var as=An(function(t){return 1/(1+t)},function(t){return 2*Math.atan(t)});(ui.geo.stereographic=function(){return sn(as)}).raw=as,Cn.invert=function(t,e){return[-e,2*Math.atan(Math.exp(t))-Zi]},(ui.geo.transverseMercator=function(){var t=Sn(Cn),e=t.center,n=t.rotate;return t.center=function(t){return t?e([-t[1],t[0]]):(t=e(),[t[1],-t[0]])},t.rotate=function(t){return t?n([t[0],t[1],t.length>2?t[2]+90:90]):(t=n(),[t[0],t[1],t[2]-90])},n([0,0,90])}).raw=Cn,ui.geom={},ui.geom.hull=function(t){function e(t){if(t.length<3)return[];var e,a=zt(n),o=zt(r),i=t.length,l=[],s=[];for(e=0;i>e;e++)l.push([+a.call(this,t[e],e),+o.call(this,t[e],e),e]);for(l.sort(Nn),e=0;i>e;e++)s.push([l[e][0],-l[e][1]]);var c=Pn(l),u=Pn(s),f=u[0]===c[0],d=u[u.length-1]===c[c.length-1],h=[];for(e=c.length-1;e>=0;--e)h.push(t[l[c[e]][2]]);for(e=+f;e=r&&c.x<=o&&c.y>=a&&c.y<=i?[[r,i],[o,i],[o,a],[r,a]]:[];u.point=t[l]}),e}function n(t){return t.map(function(t,e){return{x:Math.round(o(t,e)/Fi)*Fi,y:Math.round(i(t,e)/Fi)*Fi,i:e}})}var r=En,a=On,o=r,i=a,l=hs;return t?e(t):(e.links=function(t){return cr(n(t)).edges.filter(function(t){return t.l&&t.r}).map(function(e){ +-return{source:t[e.l.i],target:t[e.r.i]}})},e.triangles=function(t){var e=[];return cr(n(t)).cells.forEach(function(n,r){for(var a,o,i=n.site,l=n.edges.sort(Xn),s=-1,c=l.length,u=l[c-1].edge,f=u.l===i?u.r:u.l;++s=c,d=r>=u,h=d<<1|f;t.leaf=!1,t=t.nodes[h]||(t.nodes[h]=pr()),f?a=c:l=c,d?i=u:s=u,o(t,e,n,r,a,i,l,s)}var u,f,d,h,p,g,v,m,y,x=zt(l),b=zt(s);if(null!=e)g=e,v=n,m=r,y=a;else if(m=y=-(g=v=1/0),f=[],d=[],p=t.length,i)for(h=0;p>h;++h)u=t[h],u.xm&&(m=u.x),u.y>y&&(y=u.y),f.push(u.x),d.push(u.y);else for(h=0;p>h;++h){var _=+x(u=t[h],h),w=+b(u,h);g>_&&(g=_),v>w&&(v=w),_>m&&(m=_),w>y&&(y=w),f.push(_),d.push(w)}var k=m-g,M=y-v;k>M?y=v+k:m=g+M;var A=pr();if(A.add=function(t){o(A,t,+x(t,++h),+b(t,h),g,v,m,y)},A.visit=function(t){gr(t,A,g,v,m,y)},A.find=function(t){return vr(A,t[0],t[1],g,v,m,y)},h=-1,null==e){for(;++h=0?t.slice(0,e):t,r=e>=0?t.slice(e+1):"in";return n=ms.get(n)||vs,r=ys.get(r)||b,kr(r(n.apply(null,fi.call(arguments,1))))},ui.interpolateHcl=Ir,ui.interpolateHsl=Rr,ui.interpolateLab=jr,ui.interpolateRound=Fr,ui.transform=function(t){var e=hi.createElementNS(ui.ns.prefix.svg,"g");return(ui.transform=function(t){if(null!=t){e.setAttribute("transform",t);var n=e.transform.baseVal.consolidate()}return new qr(n?n.matrix:xs)})(t)},qr.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var xs={a:1,b:0,c:0,d:1,e:0,f:0};ui.interpolateTransform=$r,ui.layout={},ui.layout.bundle=function(){return function(t){for(var e=[],n=-1,r=t.length;++nl*l/m){if(g>s){var c=e.charge/s;t.px-=o*c,t.py-=i*c}return!0}if(e.point&&s&&g>s){var c=e.pointCharge/s;t.px-=o*c,t.py-=i*c}}return!e.charge}}function e(t){t.px=ui.event.x,t.py=ui.event.y,s.resume()}var n,r,a,o,i,l,s={},c=ui.dispatch("start","tick","end"),u=[1,1],f=.9,d=bs,h=_s,p=-30,g=ws,v=.1,m=.64,y=[],x=[];return s.tick=function(){if((a*=.99)<.005)return n=null,c.end({type:"end",alpha:a=0}),!0;var e,r,s,d,h,g,m,b,_,w=y.length,k=x.length;for(r=0;k>r;++r)s=x[r],d=s.source,h=s.target,b=h.x-d.x,_=h.y-d.y,(g=b*b+_*_)&&(g=a*i[r]*((g=Math.sqrt(g))-o[r])/g,b*=g,_*=g,h.x-=b*(m=d.weight+h.weight?d.weight/(d.weight+h.weight):.5),h.y-=_*m,d.x+=b*(m=1-m),d.y+=_*m);if((m=a*v)&&(b=u[0]/2,_=u[1]/2,r=-1,m))for(;++r0?a=t:(n.c=null,n.t=NaN,n=null,c.end({type:"end",alpha:a=0})):t>0&&(c.start({type:"start",alpha:a=t}),n=Pt(s.tick)),s):a},s.start=function(){function t(t,r){if(!n){for(n=new Array(a),s=0;a>s;++s)n[s]=[];for(s=0;c>s;++s){var o=x[s];n[o.source.index].push(o.target),n[o.target.index].push(o.source)}}for(var i,l=n[e],s=-1,u=l.length;++se;++e)(r=y[e]).index=e,r.weight=0;for(e=0;c>e;++e)r=x[e],"number"==typeof r.source&&(r.source=y[r.source]),"number"==typeof r.target&&(r.target=y[r.target]),++r.source.weight,++r.target.weight;for(e=0;a>e;++e)r=y[e],isNaN(r.x)&&(r.x=t("x",f)),isNaN(r.y)&&(r.y=t("y",g)),isNaN(r.px)&&(r.px=r.x),isNaN(r.py)&&(r.py=r.y);if(o=[],"function"==typeof d)for(e=0;c>e;++e)o[e]=+d.call(this,x[e],e);else for(e=0;c>e;++e)o[e]=d;if(i=[],"function"==typeof h)for(e=0;c>e;++e)i[e]=+h.call(this,x[e],e);else for(e=0;c>e;++e)i[e]=h;if(l=[],"function"==typeof p)for(e=0;a>e;++e)l[e]=+p.call(this,y[e],e);else for(e=0;a>e;++e)l[e]=p;return s.resume()},s.resume=function(){return s.alpha(.1)},s.stop=function(){return s.alpha(0)},s.drag=function(){return r||(r=ui.behavior.drag().origin(b).on("dragstart.force",ea).on("drag.force",e).on("dragend.force",na)),arguments.length?void this.on("mouseover.force",ra).on("mouseout.force",aa).call(r):r},ui.rebind(s,c,"on")};var bs=20,_s=1,ws=1/0;ui.layout.hierarchy=function(){function t(a){var o,i=[a],l=[];for(a.depth=0;null!=(o=i.pop());)if(l.push(o),(c=n.call(t,o,o.depth))&&(s=c.length)){for(var s,c,u;--s>=0;)i.push(u=c[s]),u.parent=o,u.depth=o.depth+1;r&&(o.value=0),o.children=c}else r&&(o.value=+r.call(t,o,o.depth)||0),delete o.children;return sa(a,function(t){var n,a;e&&(n=t.children)&&n.sort(e),r&&(a=t.parent)&&(a.value+=t.value)}),l}var e=fa,n=ca,r=ua;return t.sort=function(n){return arguments.length?(e=n,t):e},t.children=function(e){return arguments.length?(n=e,t):n},t.value=function(e){return arguments.length?(r=e,t):r},t.revalue=function(e){return r&&(la(e,function(t){t.children&&(t.value=0)}),sa(e,function(e){var n;e.children||(e.value=+r.call(t,e,e.depth)||0),(n=e.parent)&&(n.value+=e.value)})),e},t},ui.layout.partition=function(){function t(e,n,r,a){var o=e.children;if(e.x=n,e.y=e.depth*a,e.dx=r,e.dy=a,o&&(i=o.length)){var i,l,s,c=-1;for(r=e.value?r/e.value:0;++cf?-1:1),p=ui.sum(c),g=p?(f-s*h)/p:0,v=ui.range(s),m=[];return null!=n&&v.sort(n===ks?function(t,e){return c[e]-c[t]}:function(t,e){return n(i[t],i[e])}),v.forEach(function(t){m[t]={data:i[t],value:l=c[t],startAngle:u,endAngle:u+=l*g+h,padAngle:d}}),m}var e=Number,n=ks,r=0,a=Hi,o=0;return t.value=function(n){return arguments.length?(e=n,t):e},t.sort=function(e){return arguments.length?(n=e,t):n},t.startAngle=function(e){return arguments.length?(r=e,t):r},t.endAngle=function(e){return arguments.length?(a=e,t):a},t.padAngle=function(e){return arguments.length?(o=e,t):o},t};var ks={};ui.layout.stack=function(){function t(l,s){if(!(d=l.length))return l;var c=l.map(function(n,r){return e.call(t,n,r)}),u=c.map(function(e){return e.map(function(e,n){return[o.call(t,e,n),i.call(t,e,n)]})}),f=n.call(t,u,s);c=ui.permute(c,f),u=ui.permute(u,f);var d,h,p,g,v=r.call(t,u,s),m=c[0].length;for(p=0;m>p;++p)for(a.call(t,c[0][p],g=v[p],u[0][p][1]),h=1;d>h;++h)a.call(t,c[h][p],g+=u[h-1][p][1],u[h][p][1]);return l}var e=b,n=va,r=ma,a=ga,o=ha,i=pa;return t.values=function(n){return arguments.length?(e=n,t):e},t.order=function(e){return arguments.length?(n="function"==typeof e?e:Ms.get(e)||va,t):n},t.offset=function(e){return arguments.length?(r="function"==typeof e?e:As.get(e)||ma,t):r},t.x=function(e){return arguments.length?(o=e,t):o},t.y=function(e){return arguments.length?(i=e,t):i},t.out=function(e){return arguments.length?(a=e,t):a},t};var Ms=ui.map({"inside-out":function(t){var e,n,r=t.length,a=t.map(ya),o=t.map(xa),i=ui.range(r).sort(function(t,e){return a[t]-a[e]}),l=0,s=0,c=[],u=[];for(e=0;r>e;++e)n=i[e],s>l?(l+=o[n],c.push(n)):(s+=o[n],u.push(n));return u.reverse().concat(c)},reverse:function(t){return ui.range(t.length).reverse()},"default":va}),As=ui.map({silhouette:function(t){var e,n,r,a=t.length,o=t[0].length,i=[],l=0,s=[];for(n=0;o>n;++n){for(e=0,r=0;a>e;e++)r+=t[e][n][1];r>l&&(l=r),i.push(r)}for(n=0;o>n;++n)s[n]=(l-i[n])/2;return s},wiggle:function(t){var e,n,r,a,o,i,l,s,c,u=t.length,f=t[0],d=f.length,h=[];for(h[0]=s=c=0,n=1;d>n;++n){for(e=0,a=0;u>e;++e)a+=t[e][n][1];for(e=0,o=0,l=f[n][0]-f[n-1][0];u>e;++e){for(r=0,i=(t[e][n][1]-t[e][n-1][1])/(2*l);e>r;++r)i+=(t[r][n][1]-t[r][n-1][1])/l;o+=i*t[e][n][1]}h[n]=s-=a?o/a*l:0,c>s&&(c=s)}for(n=0;d>n;++n)h[n]-=c;return h},expand:function(t){var e,n,r,a=t.length,o=t[0].length,i=1/a,l=[];for(n=0;o>n;++n){for(e=0,r=0;a>e;e++)r+=t[e][n][1];if(r)for(e=0;a>e;e++)t[e][n][1]/=r;else for(e=0;a>e;e++)t[e][n][1]=i}for(n=0;o>n;++n)l[n]=0;return l},zero:ma});ui.layout.histogram=function(){function t(t,o){for(var i,l,s=[],c=t.map(n,this),u=r.call(this,c,o),f=a.call(this,u,c,o),o=-1,d=c.length,h=f.length-1,p=e?1:1/d;++o0)for(o=-1;++o=u[0]&&l<=u[1]&&(i=s[ui.bisect(f,l,1,h)-1],i.y+=p,i.push(t[o]));return s}var e=!0,n=Number,r=ka,a=_a;return t.value=function(e){return arguments.length?(n=e,t):n},t.range=function(e){return arguments.length?(r=zt(e),t):r},t.bins=function(e){return arguments.length?(a="number"==typeof e?function(t){return wa(t,e)}:zt(e),t):a},t.frequency=function(n){return arguments.length?(e=!!n,t):e},t},ui.layout.pack=function(){function t(t,o){var i=n.call(this,t,o),l=i[0],s=a[0],c=a[1],u=null==e?Math.sqrt:"function"==typeof e?e:function(){return e};if(l.x=l.y=0,sa(l,function(t){t.r=+u(t.value)}),sa(l,za),r){var f=r*(e?1:Math.max(2*l.r/s,2*l.r/c))/2;sa(l,function(t){t.r+=f}),sa(l,za),sa(l,function(t){t.r-=f})}return Ea(l,s/2,c/2,e?1:1/Math.max(2*l.r/s,2*l.r/c)),i}var e,n=ui.layout.hierarchy().sort(Ma),r=0,a=[1,1];return t.size=function(e){return arguments.length?(a=e,t):a},t.radius=function(n){return arguments.length?(e=null==n||"function"==typeof n?n:+n,t):e},t.padding=function(e){return arguments.length?(r=+e,t):r},ia(t,n)},ui.layout.tree=function(){function t(t,a){var u=i.call(this,t,a),f=u[0],d=e(f);if(sa(d,n),d.parent.m=-d.z,la(d,r),c)la(f,o);else{var h=f,p=f,g=f;la(f,function(t){t.xp.x&&(p=t),t.depth>g.depth&&(g=t)});var v=l(h,p)/2-h.x,m=s[0]/(p.x+l(p,h)/2+v),y=s[1]/(g.depth||1);la(f,function(t){t.x=(t.x+v)*m,t.y=t.depth*y})}return u}function e(t){for(var e,n={A:null,children:[t]},r=[n];null!=(e=r.pop());)for(var a,o=e.children,i=0,l=o.length;l>i;++i)r.push((o[i]=a={_:o[i],parent:e,children:(a=o[i].children)&&a.slice()||[],A:null,a:null,z:0,m:0,c:0,s:0,t:null,i:i}).a=a);return n.children[0]}function n(t){var e=t.children,n=t.parent.children,r=t.i?n[t.i-1]:null;if(e.length){Ra(t);var o=(e[0].z+e[e.length-1].z)/2;r?(t.z=r.z+l(t._,r._),t.m=t.z-o):t.z=o}else r&&(t.z=r.z+l(t._,r._));t.parent.A=a(t,r,t.parent.A||n[0])}function r(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function a(t,e,n){if(e){for(var r,a=t,o=t,i=e,s=a.parent.children[0],c=a.m,u=o.m,f=i.m,d=s.m;i=Da(i),a=Na(a),i&&a;)s=Na(s),o=Da(o),o.a=t,r=i.z+f-a.z-c+l(i._,a._),r>0&&(Ia(ja(i,t,n),t,r),c+=r,u+=r),f+=i.m,c+=a.m,d+=s.m,u+=o.m;i&&!Da(o)&&(o.t=i,o.m+=f-u),a&&!Na(s)&&(s.t=a,s.m+=c-d,n=t)}return n}function o(t){t.x*=s[0],t.y=t.depth*s[1]}var i=ui.layout.hierarchy().sort(null).value(null),l=Pa,s=[1,1],c=null;return t.separation=function(e){return arguments.length?(l=e,t):l},t.size=function(e){return arguments.length?(c=null==(s=e)?o:null,t):c?null:s},t.nodeSize=function(e){return arguments.length?(c=null==(s=e)?null:o,t):c?s:null},ia(t,i)},ui.layout.cluster=function(){function t(t,o){var i,l=e.call(this,t,o),s=l[0],c=0;sa(s,function(t){var e=t.children;e&&e.length?(t.x=qa(e),t.y=Fa(e)):(t.x=i?c+=n(t,i):0,t.y=0,i=t)});var u=Ba(s),f=Ha(s),d=u.x-n(u,f)/2,h=f.x+n(f,u)/2;return sa(s,a?function(t){t.x=(t.x-s.x)*r[0],t.y=(s.y-t.y)*r[1]}:function(t){t.x=(t.x-d)/(h-d)*r[0],t.y=(1-(s.y?t.y/s.y:1))*r[1]}),l}var e=ui.layout.hierarchy().sort(null).value(null),n=Pa,r=[1,1],a=!1;return t.separation=function(e){return arguments.length?(n=e,t):n},t.size=function(e){return arguments.length?(a=null==(r=e),t):a?null:r},t.nodeSize=function(e){return arguments.length?(a=null!=(r=e),t):a?r:null},ia(t,e)},ui.layout.treemap=function(){function t(t,e){for(var n,r,a=-1,o=t.length;++ae?0:e),n.area=isNaN(r)||0>=r?0:r}function e(n){var o=n.children;if(o&&o.length){var i,l,s,c=f(n),u=[],d=o.slice(),p=1/0,g="slice"===h?c.dx:"dice"===h?c.dy:"slice-dice"===h?1&n.depth?c.dy:c.dx:Math.min(c.dx,c.dy);for(t(d,c.dx*c.dy/n.value),u.area=0;(s=d.length)>0;)u.push(i=d[s-1]),u.area+=i.area,"squarify"!==h||(l=r(u,g))<=p?(d.pop(),p=l):(u.area-=u.pop().area,a(u,g,c,!1),g=Math.min(c.dx,c.dy),u.length=u.area=0,p=1/0);u.length&&(a(u,g,c,!0),u.length=u.area=0),o.forEach(e)}}function n(e){var r=e.children;if(r&&r.length){var o,i=f(e),l=r.slice(),s=[];for(t(l,i.dx*i.dy/e.value),s.area=0;o=l.pop();)s.push(o),s.area+=o.area,null!=o.z&&(a(s,o.z?i.dx:i.dy,i,!l.length),s.length=s.area=0);r.forEach(n)}}function r(t,e){for(var n,r=t.area,a=0,o=1/0,i=-1,l=t.length;++in&&(o=n),n>a&&(a=n));return r*=r,e*=e,r?Math.max(e*a*p/r,r/(e*o*p)):1/0}function a(t,e,n,r){var a,o=-1,i=t.length,l=n.x,c=n.y,u=e?s(t.area/e):0;if(e==n.dx){for((r||u>n.dy)&&(u=n.dy);++on.dx)&&(u=n.dx);++on&&(e=1),1>n&&(t=0),function(){var n,r,a;do n=2*Math.random()-1,r=2*Math.random()-1,a=n*n+r*r;while(!a||a>1);return t+e*n*Math.sqrt(-2*Math.log(a)/a)}},logNormal:function(){var t=ui.random.normal.apply(ui,arguments);return function(){return Math.exp(t())}},bates:function(t){var e=ui.random.irwinHall(t);return function(){return e()/t}},irwinHall:function(t){return function(){for(var e=0,n=0;t>n;n++)e+=Math.random();return e}}},ui.scale={};var Ts={floor:b,ceil:b};ui.scale.linear=function(){return Wa([0,1],[0,1],_r,!1)};var Ls={s:1,g:1,p:1,r:1,e:1};ui.scale.log=function(){return oo(ui.scale.linear().domain([0,1]),10,!0,[1,10])};var zs=ui.format(".0e"),Ss={floor:function(t){return-Math.ceil(-t)},ceil:function(t){return-Math.floor(-t)}};ui.scale.pow=function(){return io(ui.scale.linear(),1,[0,1])},ui.scale.sqrt=function(){return ui.scale.pow().exponent(.5)},ui.scale.ordinal=function(){return so([],{t:"range",a:[[]]})},ui.scale.category10=function(){return ui.scale.ordinal().range(Cs)},ui.scale.category20=function(){return ui.scale.ordinal().range(Es)},ui.scale.category20b=function(){return ui.scale.ordinal().range(Os)},ui.scale.category20c=function(){return ui.scale.ordinal().range(Ps)};var Cs=[2062260,16744206,2924588,14034728,9725885,9197131,14907330,8355711,12369186,1556175].map(_t),Es=[2062260,11454440,16744206,16759672,2924588,10018698,14034728,16750742,9725885,12955861,9197131,12885140,14907330,16234194,8355711,13092807,12369186,14408589,1556175,10410725].map(_t),Os=[3750777,5395619,7040719,10264286,6519097,9216594,11915115,13556636,9202993,12426809,15186514,15190932,8666169,11356490,14049643,15177372,8077683,10834324,13528509,14589654].map(_t),Ps=[3244733,7057110,10406625,13032431,15095053,16616764,16625259,16634018,3253076,7652470,10607003,13101504,7695281,10394312,12369372,14342891,6513507,9868950,12434877,14277081].map(_t);ui.scale.quantile=function(){return co([],[])},ui.scale.quantize=function(){return uo(0,1,[0,1])},ui.scale.threshold=function(){return fo([.5],[0,1])},ui.scale.identity=function(){return ho([0,1])},ui.svg={},ui.svg.arc=function(){function t(){var t=Math.max(0,+n.apply(this,arguments)),c=Math.max(0,+r.apply(this,arguments)),u=i.apply(this,arguments)-Zi,f=l.apply(this,arguments)-Zi,d=Math.abs(f-u),h=u>f?0:1;if(t>c&&(p=c,c=t,t=p),d>=Vi)return e(c,h)+(t?e(t,1-h):"")+"Z";var p,g,v,m,y,x,b,_,w,k,M,A,T=0,L=0,z=[];if((m=(+s.apply(this,arguments)||0)/2)&&(v=o===Ns?Math.sqrt(t*t+c*c):+o.apply(this,arguments),h||(L*=-1),c&&(L=rt(v/c*Math.sin(m))),t&&(T=rt(v/t*Math.sin(m)))),c){y=c*Math.cos(u+L),x=c*Math.sin(u+L),b=c*Math.cos(f-L),_=c*Math.sin(f-L);var S=Math.abs(f-u-2*L)<=Bi?0:1;if(L&&bo(y,x,b,_)===h^S){var C=(u+f)/2;y=c*Math.cos(C),x=c*Math.sin(C),b=_=null}}else y=x=0;if(t){w=t*Math.cos(f-T),k=t*Math.sin(f-T),M=t*Math.cos(u+T),A=t*Math.sin(u+T);var E=Math.abs(u-f+2*T)<=Bi?0:1;if(T&&bo(w,k,M,A)===1-h^E){var O=(u+f)/2;w=t*Math.cos(O),k=t*Math.sin(O),M=A=null}}else w=k=0;if(d>Fi&&(p=Math.min(Math.abs(c-t)/2,+a.apply(this,arguments)))>.001){g=c>t^h?0:1;var P=p,N=p;if(Bi>d){var D=null==M?[w,k]:null==b?[y,x]:In([y,x],[M,A],[b,_],[w,k]),I=y-D[0],R=x-D[1],j=b-D[0],F=_-D[1],q=1/Math.sin(Math.acos((I*j+R*F)/(Math.sqrt(I*I+R*R)*Math.sqrt(j*j+F*F)))/2),B=Math.sqrt(D[0]*D[0]+D[1]*D[1]);N=Math.min(p,(t-B)/(q-1)),P=Math.min(p,(c-B)/(q+1))}if(null!=b){var H=_o(null==M?[w,k]:[M,A],[y,x],c,P,h),V=_o([b,_],[w,k],c,P,h);p===P?z.push("M",H[0],"A",P,",",P," 0 0,",g," ",H[1],"A",c,",",c," 0 ",1-h^bo(H[1][0],H[1][1],V[1][0],V[1][1]),",",h," ",V[1],"A",P,",",P," 0 0,",g," ",V[0]):z.push("M",H[0],"A",P,",",P," 0 1,",g," ",V[0])}else z.push("M",y,",",x);if(null!=M){var Z=_o([y,x],[M,A],t,-N,h),Y=_o([w,k],null==b?[y,x]:[b,_],t,-N,h);p===N?z.push("L",Y[0],"A",N,",",N," 0 0,",g," ",Y[1],"A",t,",",t," 0 ",h^bo(Y[1][0],Y[1][1],Z[1][0],Z[1][1]),",",1-h," ",Z[1],"A",N,",",N," 0 0,",g," ",Z[0]):z.push("L",Y[0],"A",N,",",N," 0 0,",g," ",Z[0])}else z.push("L",w,",",k)}else z.push("M",y,",",x),null!=b&&z.push("A",c,",",c," 0 ",S,",",h," ",b,",",_),z.push("L",w,",",k),null!=M&&z.push("A",t,",",t," 0 ",E,",",1-h," ",M,",",A);return z.push("Z"),z.join("")}function e(t,e){return"M0,"+t+"A"+t+","+t+" 0 1,"+e+" 0,"+-t+"A"+t+","+t+" 0 1,"+e+" 0,"+t}var n=go,r=vo,a=po,o=Ns,i=mo,l=yo,s=xo;return t.innerRadius=function(e){return arguments.length?(n=zt(e),t):n},t.outerRadius=function(e){return arguments.length?(r=zt(e),t):r},t.cornerRadius=function(e){return arguments.length?(a=zt(e),t):a},t.padRadius=function(e){return arguments.length?(o=e==Ns?Ns:zt(e),t):o},t.startAngle=function(e){return arguments.length?(i=zt(e),t):i},t.endAngle=function(e){return arguments.length?(l=zt(e),t):l},t.padAngle=function(e){return arguments.length?(s=zt(e),t):s},t.centroid=function(){var t=(+n.apply(this,arguments)+ +r.apply(this,arguments))/2,e=(+i.apply(this,arguments)+ +l.apply(this,arguments))/2-Zi;return[Math.cos(e)*t,Math.sin(e)*t]},t};var Ns="auto";ui.svg.line=function(){return wo(b)};var Ds=ui.map({linear:ko,"linear-closed":Mo,step:Ao,"step-before":To,"step-after":Lo,basis:Po,"basis-open":No,"basis-closed":Do,bundle:Io,cardinal:Co,"cardinal-open":zo,"cardinal-closed":So,monotone:Ho});Ds.forEach(function(t,e){e.key=t,e.closed=/-closed$/.test(t)});var Is=[0,2/3,1/3,0],Rs=[0,1/3,2/3,0],js=[0,1/6,2/3,1/6];ui.svg.line.radial=function(){var t=wo(Vo);return t.radius=t.x,delete t.x,t.angle=t.y,delete t.y,t},To.reverse=Lo,Lo.reverse=To,ui.svg.area=function(){return Zo(b)},ui.svg.area.radial=function(){var t=Zo(Vo);return t.radius=t.x,delete t.x,t.innerRadius=t.x0,delete t.x0,t.outerRadius=t.x1,delete t.x1,t.angle=t.y,delete t.y,t.startAngle=t.y0,delete t.y0,t.endAngle=t.y1,delete t.y1,t},ui.svg.chord=function(){function t(t,l){var s=e(this,o,t,l),c=e(this,i,t,l);return"M"+s.p0+r(s.r,s.p1,s.a1-s.a0)+(n(s,c)?a(s.r,s.p1,s.r,s.p0):a(s.r,s.p1,c.r,c.p0)+r(c.r,c.p1,c.a1-c.a0)+a(c.r,c.p1,s.r,s.p0))+"Z"}function e(t,e,n,r){var a=e.call(t,n,r),o=l.call(t,a,r),i=s.call(t,a,r)-Zi,u=c.call(t,a,r)-Zi;return{r:o,a0:i,a1:u,p0:[o*Math.cos(i),o*Math.sin(i)],p1:[o*Math.cos(u),o*Math.sin(u)]}}function n(t,e){return t.a0==e.a0&&t.a1==e.a1}function r(t,e,n){return"A"+t+","+t+" 0 "+ +(n>Bi)+",1 "+e}function a(t,e,n,r){return"Q 0,0 "+r}var o=_n,i=wn,l=Yo,s=mo,c=yo;return t.radius=function(e){return arguments.length?(l=zt(e),t):l},t.source=function(e){return arguments.length?(o=zt(e),t):o},t.target=function(e){return arguments.length?(i=zt(e),t):i},t.startAngle=function(e){return arguments.length?(s=zt(e),t):s},t.endAngle=function(e){return arguments.length?(c=zt(e),t):c},t},ui.svg.diagonal=function(){function t(t,a){var o=e.call(this,t,a),i=n.call(this,t,a),l=(o.y+i.y)/2,s=[o,{x:o.x,y:l},{x:i.x,y:l},i];return s=s.map(r),"M"+s[0]+"C"+s[1]+" "+s[2]+" "+s[3]}var e=_n,n=wn,r=Uo;return t.source=function(n){return arguments.length?(e=zt(n),t):e},t.target=function(e){return arguments.length?(n=zt(e),t):n},t.projection=function(e){return arguments.length?(r=e,t):r},t},ui.svg.diagonal.radial=function(){var t=ui.svg.diagonal(),e=Uo,n=t.projection;return t.projection=function(t){return arguments.length?n(Xo(e=t)):e},t},ui.svg.symbol=function(){function t(t,r){return(Fs.get(e.call(this,t,r))||Qo)(n.call(this,t,r))}var e=$o,n=Go;return t.type=function(n){return arguments.length?(e=zt(n),t):e},t.size=function(e){return arguments.length?(n=zt(e),t):n},t};var Fs=ui.map({circle:Qo,cross:function(t){var e=Math.sqrt(t/5)/2;return"M"+-3*e+","+-e+"H"+-e+"V"+-3*e+"H"+e+"V"+-e+"H"+3*e+"V"+e+"H"+e+"V"+3*e+"H"+-e+"V"+e+"H"+-3*e+"Z"},diamond:function(t){var e=Math.sqrt(t/(2*Bs)),n=e*Bs;return"M0,"+-e+"L"+n+",0 0,"+e+" "+-n+",0Z"},square:function(t){var e=Math.sqrt(t)/2;return"M"+-e+","+-e+"L"+e+","+-e+" "+e+","+e+" "+-e+","+e+"Z"},"triangle-down":function(t){var e=Math.sqrt(t/qs),n=e*qs/2;return"M0,"+n+"L"+e+","+-n+" "+-e+","+-n+"Z"},"triangle-up":function(t){var e=Math.sqrt(t/qs),n=e*qs/2;return"M0,"+-n+"L"+e+","+n+" "+-e+","+n+"Z"}});ui.svg.symbolTypes=Fs.keys();var qs=Math.sqrt(3),Bs=Math.tan(30*Yi);Ei.transition=function(t){for(var e,n,r=Hs||++Us,a=ei(t),o=[],i=Vs||{time:Date.now(),ease:zr,delay:0,duration:250},l=-1,s=this.length;++lo;o++){a.push(e=[]);for(var n=this[o],l=0,s=n.length;s>l;l++)(r=n[l])&&t.call(r,r.__data__,l,o)&&e.push(r)}return Jo(a,this.namespace,this.id)},Ys.tween=function(t,e){var n=this.id,r=this.namespace;return arguments.length<2?this.node()[r][n].tween.get(t):Y(this,null==e?function(e){e[r][n].tween.remove(t)}:function(a){a[r][n].tween.set(t,e)})},Ys.attr=function(t,e){function n(){this.removeAttribute(l)}function r(){this.removeAttributeNS(l.space,l.local)}function a(t){return null==t?n:(t+="",function(){var e,n=this.getAttribute(l);return n!==t&&(e=i(n,t),function(t){this.setAttribute(l,e(t))})})}function o(t){return null==t?r:(t+="",function(){var e,n=this.getAttributeNS(l.space,l.local);return n!==t&&(e=i(n,t),function(t){this.setAttributeNS(l.space,l.local,e(t))})})}if(arguments.length<2){for(e in t)this.attr(e,t[e]);return this}var i="transform"==t?$r:_r,l=ui.ns.qualify(t);return Ko(this,"attr."+t,e,l.local?o:a)},Ys.attrTween=function(t,e){function n(t,n){var r=e.call(this,t,n,this.getAttribute(a));return r&&function(t){this.setAttribute(a,r(t))}}function r(t,n){var r=e.call(this,t,n,this.getAttributeNS(a.space,a.local));return r&&function(t){this.setAttributeNS(a.space,a.local,r(t))}}var a=ui.ns.qualify(t);return this.tween("attr."+t,a.local?r:n)},Ys.style=function(t,e,n){function a(){this.style.removeProperty(t)}function o(e){return null==e?a:(e+="",function(){var a,o=r(this).getComputedStyle(this,null).getPropertyValue(t);return o!==e&&(a=_r(o,e),function(e){this.style.setProperty(t,a(e),n)})})}var i=arguments.length;if(3>i){if("string"!=typeof t){2>i&&(e="");for(n in t)this.style(n,t[n],e);return this}n=""}return Ko(this,"style."+t,e,o)},Ys.styleTween=function(t,e,n){function a(a,o){var i=e.call(this,a,o,r(this).getComputedStyle(this,null).getPropertyValue(t));return i&&function(e){this.style.setProperty(t,i(e),n)}}return arguments.length<3&&(n=""),this.tween("style."+t,a)},Ys.text=function(t){return Ko(this,"text",t,ti)},Ys.remove=function(){var t=this.namespace;return this.each("end.transition",function(){var e;this[t].count<2&&(e=this.parentNode)&&e.removeChild(this)})},Ys.ease=function(t){var e=this.id,n=this.namespace;return arguments.length<1?this.node()[n][e].ease:("function"!=typeof t&&(t=ui.ease.apply(ui,arguments)),Y(this,function(r){r[n][e].ease=t}))},Ys.delay=function(t){var e=this.id,n=this.namespace;return arguments.length<1?this.node()[n][e].delay:Y(this,"function"==typeof t?function(r,a,o){r[n][e].delay=+t.call(r,r.__data__,a,o)}:(t=+t,function(r){r[n][e].delay=t}))},Ys.duration=function(t){var e=this.id,n=this.namespace;return arguments.length<1?this.node()[n][e].duration:Y(this,"function"==typeof t?function(r,a,o){r[n][e].duration=Math.max(1,t.call(r,r.__data__,a,o))}:(t=Math.max(1,t),function(r){r[n][e].duration=t}))},Ys.each=function(t,e){var n=this.id,r=this.namespace;if(arguments.length<2){var a=Vs,o=Hs;try{Hs=n,Y(this,function(e,a,o){Vs=e[r][n],t.call(e,e.__data__,a,o)})}finally{Vs=a,Hs=o}}else Y(this,function(a){var o=a[r][n];(o.event||(o.event=ui.dispatch("start","end","interrupt"))).on(t,e)});return this},Ys.transition=function(){for(var t,e,n,r,a=this.id,o=++Us,i=this.namespace,l=[],s=0,c=this.length;c>s;s++){l.push(t=[]);for(var e=this[s],u=0,f=e.length;f>u;u++)(n=e[u])&&(r=n[i][a],ni(n,u,i,o,{time:r.time,ease:r.ease,delay:r.delay+r.duration,duration:r.duration})),t.push(n)}return Jo(l,i,o)},ui.svg.axis=function(){function t(t){t.each(function(){var t,c=ui.select(this),u=this.__chart__||n,f=this.__chart__=n.copy(),d=null==s?f.ticks?f.ticks.apply(f,l):f.domain():s,h=null==e?f.tickFormat?f.tickFormat.apply(f,l):b:e,p=c.selectAll(".tick").data(d,f),g=p.enter().insert("g",".domain").attr("class","tick").style("opacity",Fi),v=ui.transition(p.exit()).style("opacity",Fi).remove(),m=ui.transition(p.order()).style("opacity",1),y=Math.max(a,0)+i,x=Ua(f),_=c.selectAll(".domain").data([0]),w=(_.enter().append("path").attr("class","domain"),ui.transition(_));g.append("line"),g.append("text");var k,M,A,T,L=g.select("line"),z=m.select("line"),S=p.select("text").text(h),C=g.select("text"),E=m.select("text"),O="top"===r||"left"===r?-1:1;if("bottom"===r||"top"===r?(t=ri,k="x",A="y",M="x2",T="y2",S.attr("dy",0>O?"0em":".71em").style("text-anchor","middle"),w.attr("d","M"+x[0]+","+O*o+"V0H"+x[1]+"V"+O*o)):(t=ai,k="y",A="x",M="y2",T="x2",S.attr("dy",".32em").style("text-anchor",0>O?"end":"start"),w.attr("d","M"+O*o+","+x[0]+"H0V"+x[1]+"H"+O*o)),L.attr(T,O*a),C.attr(A,O*y),z.attr(M,0).attr(T,O*a),E.attr(k,0).attr(A,O*y),f.rangeBand){var P=f,N=P.rangeBand()/2;u=f=function(t){return P(t)+N}}else u.rangeBand?u=f:v.call(t,f,u);g.call(t,u,f),m.call(t,f,f)})}var e,n=ui.scale.linear(),r=Xs,a=6,o=6,i=3,l=[10],s=null;return t.scale=function(e){ +-return arguments.length?(n=e,t):n},t.orient=function(e){return arguments.length?(r=e in Gs?e+"":Xs,t):r},t.ticks=function(){return arguments.length?(l=di(arguments),t):l},t.tickValues=function(e){return arguments.length?(s=e,t):s},t.tickFormat=function(n){return arguments.length?(e=n,t):e},t.tickSize=function(e){var n=arguments.length;return n?(a=+e,o=+arguments[n-1],t):a},t.innerTickSize=function(e){return arguments.length?(a=+e,t):a},t.outerTickSize=function(e){return arguments.length?(o=+e,t):o},t.tickPadding=function(e){return arguments.length?(i=+e,t):i},t.tickSubdivide=function(){return arguments.length&&t},t};var Xs="bottom",Gs={top:1,right:1,bottom:1,left:1};ui.svg.brush=function(){function t(r){r.each(function(){var r=ui.select(this).style("pointer-events","all").style("-webkit-tap-highlight-color","rgba(0,0,0,0)").on("mousedown.brush",o).on("touchstart.brush",o),i=r.selectAll(".background").data([0]);i.enter().append("rect").attr("class","background").style("visibility","hidden").style("cursor","crosshair"),r.selectAll(".extent").data([0]).enter().append("rect").attr("class","extent").style("cursor","move");var l=r.selectAll(".resize").data(g,b);l.exit().remove(),l.enter().append("g").attr("class",function(t){return"resize "+t}).style("cursor",function(t){return $s[t]}).append("rect").attr("x",function(t){return/[ew]$/.test(t)?-3:null}).attr("y",function(t){return/^[ns]/.test(t)?-3:null}).attr("width",6).attr("height",6).style("visibility","hidden"),l.style("display",t.empty()?"none":null);var s,f=ui.transition(r),d=ui.transition(i);c&&(s=Ua(c),d.attr("x",s[0]).attr("width",s[1]-s[0]),n(f)),u&&(s=Ua(u),d.attr("y",s[0]).attr("height",s[1]-s[0]),a(f)),e(f)})}function e(t){t.selectAll(".resize").attr("transform",function(t){return"translate("+f[+/e$/.test(t)]+","+d[+/^s/.test(t)]+")"})}function n(t){t.select(".extent").attr("x",f[0]),t.selectAll(".extent,.n>rect,.s>rect").attr("width",f[1]-f[0])}function a(t){t.select(".extent").attr("y",d[0]),t.selectAll(".extent,.e>rect,.w>rect").attr("height",d[1]-d[0])}function o(){function o(){32==ui.event.keyCode&&(S||(x=null,E[0]-=f[1],E[1]-=d[1],S=2),T())}function g(){32==ui.event.keyCode&&2==S&&(E[0]+=f[1],E[1]+=d[1],S=0,T())}function v(){var t=ui.mouse(_),r=!1;b&&(t[0]+=b[0],t[1]+=b[1]),S||(ui.event.altKey?(x||(x=[(f[0]+f[1])/2,(d[0]+d[1])/2]),E[0]=f[+(t[0]u?(a=r,r=u):a=u),g[0]!=r||g[1]!=a?(n?l=null:i=null,g[0]=r,g[1]=a,!0):void 0}function y(){v(),M.style("pointer-events","all").selectAll(".resize").style("display",t.empty()?"none":null),ui.select("body").style("cursor",null),O.on("mousemove.brush",null).on("mouseup.brush",null).on("touchmove.brush",null).on("touchend.brush",null).on("keydown.brush",null).on("keyup.brush",null),C(),k({type:"brushend"})}var x,b,_=this,w=ui.select(ui.event.target),k=s.of(_,arguments),M=ui.select(_),A=w.datum(),L=!/^(n|s)$/.test(A)&&c,z=!/^(e|w)$/.test(A)&&u,S=w.classed("extent"),C=W(_),E=ui.mouse(_),O=ui.select(r(_)).on("keydown.brush",o).on("keyup.brush",g);if(ui.event.changedTouches?O.on("touchmove.brush",v).on("touchend.brush",y):O.on("mousemove.brush",v).on("mouseup.brush",y),M.interrupt().selectAll("*").interrupt(),S)E[0]=f[0]-E[0],E[1]=d[0]-E[1];else if(A){var P=+/w$/.test(A),N=+/^n/.test(A);b=[f[1-P]-E[0],d[1-N]-E[1]],E[0]=f[P],E[1]=d[N]}else ui.event.altKey&&(x=E.slice());M.style("pointer-events","none").selectAll(".resize").style("display",null),ui.select("body").style("cursor",w.style("cursor")),k({type:"brushstart"}),v()}var i,l,s=z(t,"brushstart","brush","brushend"),c=null,u=null,f=[0,0],d=[0,0],h=!0,p=!0,g=Qs[0];return t.event=function(t){t.each(function(){var t=s.of(this,arguments),e={x:f,y:d,i:i,j:l},n=this.__chart__||e;this.__chart__=e,Hs?ui.select(this).transition().each("start.brush",function(){i=n.i,l=n.j,f=n.x,d=n.y,t({type:"brushstart"})}).tween("brush:brush",function(){var n=wr(f,e.x),r=wr(d,e.y);return i=l=null,function(a){f=e.x=n(a),d=e.y=r(a),t({type:"brush",mode:"resize"})}}).each("end.brush",function(){i=e.i,l=e.j,t({type:"brush",mode:"resize"}),t({type:"brushend"})}):(t({type:"brushstart"}),t({type:"brush",mode:"resize"}),t({type:"brushend"}))})},t.x=function(e){return arguments.length?(c=e,g=Qs[!c<<1|!u],t):c},t.y=function(e){return arguments.length?(u=e,g=Qs[!c<<1|!u],t):u},t.clamp=function(e){return arguments.length?(c&&u?(h=!!e[0],p=!!e[1]):c?h=!!e:u&&(p=!!e),t):c&&u?[h,p]:c?h:u?p:null},t.extent=function(e){var n,r,a,o,s;return arguments.length?(c&&(n=e[0],r=e[1],u&&(n=n[0],r=r[0]),i=[n,r],c.invert&&(n=c(n),r=c(r)),n>r&&(s=n,n=r,r=s),n==f[0]&&r==f[1]||(f=[n,r])),u&&(a=e[0],o=e[1],c&&(a=a[1],o=o[1]),l=[a,o],u.invert&&(a=u(a),o=u(o)),a>o&&(s=a,a=o,o=s),a==d[0]&&o==d[1]||(d=[a,o])),t):(c&&(i?(n=i[0],r=i[1]):(n=f[0],r=f[1],c.invert&&(n=c.invert(n),r=c.invert(r)),n>r&&(s=n,n=r,r=s))),u&&(l?(a=l[0],o=l[1]):(a=d[0],o=d[1],u.invert&&(a=u.invert(a),o=u.invert(o)),a>o&&(s=a,a=o,o=s))),c&&u?[[n,a],[r,o]]:c?[n,r]:u&&[a,o])},t.clear=function(){return t.empty()||(f=[0,0],d=[0,0],i=l=null),t},t.empty=function(){return!!c&&f[0]==f[1]||!!u&&d[0]==d[1]},ui.rebind(t,s,"on")};var $s={n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},Qs=[["n","e","s","w","nw","ne","se","sw"],["e","w"],["n","s"],[]],Ws=vl.format=wl.timeFormat,Js=Ws.utc,Ks=Js("%Y-%m-%dT%H:%M:%S.%LZ");Ws.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?oi:Ks,oi.parse=function(t){var e=new Date(t);return isNaN(e)?null:e},oi.toString=Ks.toString,vl.second=Ht(function(t){return new ml(1e3*Math.floor(t/1e3))},function(t,e){t.setTime(t.getTime()+1e3*Math.floor(e))},function(t){return t.getSeconds()}),vl.seconds=vl.second.range,vl.seconds.utc=vl.second.utc.range,vl.minute=Ht(function(t){return new ml(6e4*Math.floor(t/6e4))},function(t,e){t.setTime(t.getTime()+6e4*Math.floor(e))},function(t){return t.getMinutes()}),vl.minutes=vl.minute.range,vl.minutes.utc=vl.minute.utc.range,vl.hour=Ht(function(t){var e=t.getTimezoneOffset()/60;return new ml(36e5*(Math.floor(t/36e5-e)+e))},function(t,e){t.setTime(t.getTime()+36e5*Math.floor(e))},function(t){return t.getHours()}),vl.hours=vl.hour.range,vl.hours.utc=vl.hour.utc.range,vl.month=Ht(function(t){return t=vl.day(t),t.setDate(1),t},function(t,e){t.setMonth(t.getMonth()+e)},function(t){return t.getMonth()}),vl.months=vl.month.range,vl.months.utc=vl.month.utc.range;var tc=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],ec=[[vl.second,1],[vl.second,5],[vl.second,15],[vl.second,30],[vl.minute,1],[vl.minute,5],[vl.minute,15],[vl.minute,30],[vl.hour,1],[vl.hour,3],[vl.hour,6],[vl.hour,12],[vl.day,1],[vl.day,2],[vl.week,1],[vl.month,1],[vl.month,3],[vl.year,1]],nc=Ws.multi([[".%L",function(t){return t.getMilliseconds()}],[":%S",function(t){return t.getSeconds()}],["%I:%M",function(t){return t.getMinutes()}],["%I %p",function(t){return t.getHours()}],["%a %d",function(t){return t.getDay()&&1!=t.getDate()}],["%b %d",function(t){return 1!=t.getDate()}],["%B",function(t){return t.getMonth()}],["%Y",Ee]]),rc={range:function(t,e,n){return ui.range(Math.ceil(t/n)*n,+e,n).map(li)},floor:b,ceil:b};ec.year=vl.year,vl.scale=function(){return ii(ui.scale.linear(),ec,nc)};var ac=ec.map(function(t){return[t[0].utc,t[1]]}),oc=Js.multi([[".%L",function(t){return t.getUTCMilliseconds()}],[":%S",function(t){return t.getUTCSeconds()}],["%I:%M",function(t){return t.getUTCMinutes()}],["%I %p",function(t){return t.getUTCHours()}],["%a %d",function(t){return t.getUTCDay()&&1!=t.getUTCDate()}],["%b %d",function(t){return 1!=t.getUTCDate()}],["%B",function(t){return t.getUTCMonth()}],["%Y",Ee]]);ac.year=vl.year.utc,vl.scale.utc=function(){return ii(ui.scale.linear(),ac,oc)},ui.text=St(function(t){return t.responseText}),ui.json=function(t,e){return Ct(t,"application/json",si,e)},ui.html=function(t,e){return Ct(t,"text/html",ci,e)},ui.xml=St(function(t){return t.responseXML}),"function"==typeof t&&t.amd?(this.d3=ui,t(ui)):"object"==typeof n&&n.exports?n.exports=ui:this.d3=ui}()},{}],10:[function(e,n,r){(function(r,a){(function(){"use strict";function o(t){return"function"==typeof t||"object"==typeof t&&null!==t}function i(t){return"function"==typeof t}function l(t){U=t}function s(t){Q=t}function c(){return function(){r.nextTick(p)}}function u(){return function(){Y(p)}}function f(){var t=0,e=new K(p),n=document.createTextNode("");return e.observe(n,{characterData:!0}),function(){n.data=t=++t%2}}function d(){var t=new MessageChannel;return t.port1.onmessage=p,function(){t.port2.postMessage(0)}}function h(){return function(){setTimeout(p,1)}}function p(){for(var t=0;$>t;t+=2){var e=nt[t],n=nt[t+1];e(n),nt[t]=void 0,nt[t+1]=void 0}$=0}function g(){try{var t=e,n=t("vertx");return Y=n.runOnLoop||n.runOnContext,u()}catch(r){return h()}}function v(t,e){var n=this,r=n._state;if(r===it&&!t||r===lt&&!e)return this;var a=new this.constructor(y),o=n._result;if(r){var i=arguments[r-1];Q(function(){N(r,a,i,o)})}else C(n,a,t,e);return a}function m(t){var e=this;if(t&&"object"==typeof t&&t.constructor===e)return t;var n=new e(y);return T(n,t),n}function y(){}function x(){return new TypeError("You cannot resolve a promise with itself")}function b(){return new TypeError("A promises callback cannot return that same promise.")}function _(t){try{return t.then}catch(e){return st.error=e,st}}function w(t,e,n,r){try{t.call(e,n,r)}catch(a){return a}}function k(t,e,n){Q(function(t){var r=!1,a=w(n,e,function(n){r||(r=!0,e!==n?T(t,n):z(t,n))},function(e){r||(r=!0,S(t,e))},"Settle: "+(t._label||" unknown promise"));!r&&a&&(r=!0,S(t,a))},t)}function M(t,e){e._state===it?z(t,e._result):e._state===lt?S(t,e._result):C(e,void 0,function(e){T(t,e)},function(e){S(t,e)})}function A(t,e,n){e.constructor===t.constructor&&n===rt&&constructor.resolve===at?M(t,e):n===st?S(t,st.error):void 0===n?z(t,e):i(n)?k(t,e,n):z(t,e)}function T(t,e){t===e?S(t,x()):o(e)?A(t,e,_(e)):z(t,e)}function L(t){t._onerror&&t._onerror(t._result),E(t)}function z(t,e){t._state===ot&&(t._result=e,t._state=it,0!==t._subscribers.length&&Q(E,t))}function S(t,e){t._state===ot&&(t._state=lt,t._result=e,Q(L,t))}function C(t,e,n,r){var a=t._subscribers,o=a.length;t._onerror=null,a[o]=e,a[o+it]=n,a[o+lt]=r,0===o&&t._state&&Q(E,t)}function E(t){var e=t._subscribers,n=t._state;if(0!==e.length){for(var r,a,o=t._result,i=0;ii;i++)C(r.resolve(t[i]),void 0,e,n);return a}function j(t){var e=this,n=new e(y);return S(n,t),n}function F(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function q(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function B(t){this._id=ht++,this._state=void 0,this._result=void 0,this._subscribers=[],y!==t&&("function"!=typeof t&&F(),this instanceof B?D(this,t):q())}function H(t,e){this._instanceConstructor=t,this.promise=new t(y),Array.isArray(e)?(this._input=e,this.length=e.length,this._remaining=e.length,this._result=new Array(this.length),0===this.length?z(this.promise,this._result):(this.length=this.length||0,this._enumerate(),0===this._remaining&&z(this.promise,this._result))):S(this.promise,this._validationError())}function V(){var t;if("undefined"!=typeof a)t=a;else if("undefined"!=typeof self)t=self;else try{t=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var n=t.Promise;n&&"[object Promise]"===Object.prototype.toString.call(n.resolve())&&!n.cast||(t.Promise=pt)}var Z;Z=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)};var Y,U,X,G=Z,$=0,Q=function(t,e){nt[$]=t,nt[$+1]=e,$+=2,2===$&&(U?U(p):X())},W="undefined"!=typeof window?window:void 0,J=W||{},K=J.MutationObserver||J.WebKitMutationObserver,tt="undefined"!=typeof r&&"[object process]"==={}.toString.call(r),et="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,nt=new Array(1e3);X=tt?c():K?f():et?d():void 0===W&&"function"==typeof e?g():h();var rt=v,at=m,ot=void 0,it=1,lt=2,st=new O,ct=new O,ut=I,ft=R,dt=j,ht=0,pt=B;B.all=ut,B.race=ft,B.resolve=at,B.reject=dt,B._setScheduler=l,B._setAsap=s,B._asap=Q,B.prototype={constructor:B,then:rt,"catch":function(t){return this.then(null,t)}};var gt=H;H.prototype._validationError=function(){return new Error("Array Methods must be provided an Array")},H.prototype._enumerate=function(){for(var t=this.length,e=this._input,n=0;this._state===ot&&t>n;n++)this._eachEntry(e[n],n)},H.prototype._eachEntry=function(t,e){var n=this._instanceConstructor,r=n.resolve;if(r===at){var a=_(t);if(a===rt&&t._state!==ot)this._settledAt(t._state,e,t._result);else if("function"!=typeof a)this._remaining--,this._result[e]=t;else if(n===pt){var o=new n(y);A(o,t,a),this._willSettleAt(o,e)}else this._willSettleAt(new n(function(e){e(t)}),e)}else this._willSettleAt(r(t),e)},H.prototype._settledAt=function(t,e,n){var r=this.promise;r._state===ot&&(this._remaining--,t===lt?S(r,n):this._result[e]=n),0===this._remaining&&z(r,this._result)},H.prototype._willSettleAt=function(t,e){var n=this;C(t,void 0,function(t){n._settledAt(it,e,t)},function(t){n._settledAt(lt,e,t)})};var vt=V,mt={Promise:pt,polyfill:vt};"function"==typeof t&&t.amd?t(function(){return mt}):"undefined"!=typeof n&&n.exports?n.exports=mt:"undefined"!=typeof this&&(this.ES6Promise=mt),vt()}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:8}],11:[function(t,e,n){"use strict";function r(t){for(var e,n=t.length,r=0;n>r;r++)if(e=t.charCodeAt(r),(9>e||e>13)&&32!==e&&133!==e&&160!==e&&5760!==e&&6158!==e&&(8192>e||e>8205)&&8232!==e&&8233!==e&&8239!==e&&8287!==e&&8288!==e&&12288!==e&&65279!==e)return!1;return!0}e.exports=function(t){var e=typeof t;if("string"===e){var n=t;if(t=+t,0===t&&r(n))return!1}else if("number"!==e)return!1;return 1>t-t}},{}],12:[function(t,e,n){function r(t,e){var n=e[0],r=e[1],a=e[2],o=e[3],i=n+n,l=r+r,s=a+a,c=n*i,u=r*i,f=r*l,d=a*i,h=a*l,p=a*s,g=o*i,v=o*l,m=o*s;return t[0]=1-f-p,t[1]=u+m,t[2]=d-v,t[3]=0,t[4]=u-m,t[5]=1-c-p,t[6]=h+g,t[7]=0,t[8]=d+v,t[9]=h-g,t[10]=1-c-f,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}e.exports=r},{}],13:[function(e,n,r){!function(){function e(t,n){if(t=t?t:"",n=n||{},t instanceof e)return t;if(!(this instanceof e))return new e(t,n);var a=r(t);this._originalInput=t,this._r=a.r,this._g=a.g,this._b=a.b,this._a=a.a,this._roundA=B(100*this._a)/100,this._format=n.format||a.format,this._gradientType=n.gradientType,this._r<1&&(this._r=B(this._r)),this._g<1&&(this._g=B(this._g)),this._b<1&&(this._b=B(this._b)),this._ok=a.ok,this._tc_id=F++}function r(t){var e={r:0,g:0,b:0},n=1,r=!1,o=!1;return"string"==typeof t&&(t=D(t)),"object"==typeof t&&(t.hasOwnProperty("r")&&t.hasOwnProperty("g")&&t.hasOwnProperty("b")?(e=a(t.r,t.g,t.b),r=!0,o="%"===String(t.r).substr(-1)?"prgb":"rgb"):t.hasOwnProperty("h")&&t.hasOwnProperty("s")&&t.hasOwnProperty("v")?(t.s=O(t.s),t.v=O(t.v),e=s(t.h,t.s,t.v),r=!0,o="hsv"):t.hasOwnProperty("h")&&t.hasOwnProperty("s")&&t.hasOwnProperty("l")&&(t.s=O(t.s),t.l=O(t.l),e=i(t.h,t.s,t.l),r=!0,o="hsl"),t.hasOwnProperty("a")&&(n=t.a)),n=A(n),{ok:r,format:t.format||o,r:H(255,V(e.r,0)),g:H(255,V(e.g,0)),b:H(255,V(e.b,0)),a:n}}function a(t,e,n){return{r:255*T(t,255),g:255*T(e,255),b:255*T(n,255)}}function o(t,e,n){t=T(t,255),e=T(e,255),n=T(n,255);var r,a,o=V(t,e,n),i=H(t,e,n),l=(o+i)/2;if(o==i)r=a=0;else{var s=o-i;switch(a=l>.5?s/(2-o-i):s/(o+i),o){case t:r=(e-n)/s+(n>e?6:0);break;case e:r=(n-t)/s+2;break;case n:r=(t-e)/s+4}r/=6}return{h:r,s:a,l:l}}function i(t,e,n){function r(t,e,n){return 0>n&&(n+=1),n>1&&(n-=1),1/6>n?t+6*(e-t)*n:.5>n?e:2/3>n?t+(e-t)*(2/3-n)*6:t}var a,o,i;if(t=T(t,360),e=T(e,100),n=T(n,100),0===e)a=o=i=n;else{var l=.5>n?n*(1+e):n+e-n*e,s=2*n-l;a=r(s,l,t+1/3),o=r(s,l,t),i=r(s,l,t-1/3)}return{r:255*a,g:255*o,b:255*i}}function l(t,e,n){t=T(t,255),e=T(e,255),n=T(n,255);var r,a,o=V(t,e,n),i=H(t,e,n),l=o,s=o-i;if(a=0===o?0:s/o,o==i)r=0;else{switch(o){case t:r=(e-n)/s+(n>e?6:0);break;case e:r=(n-t)/s+2;break;case n:r=(t-e)/s+4}r/=6}return{h:r,s:a,v:l}}function s(t,e,n){t=6*T(t,360),e=T(e,100),n=T(n,100);var r=q.floor(t),a=t-r,o=n*(1-e),i=n*(1-a*e),l=n*(1-(1-a)*e),s=r%6,c=[n,i,o,o,l,n][s],u=[l,n,n,i,o,o][s],f=[o,o,l,n,n,i][s];return{r:255*c,g:255*u,b:255*f}}function c(t,e,n,r){var a=[E(B(t).toString(16)),E(B(e).toString(16)),E(B(n).toString(16))];return r&&a[0].charAt(0)==a[0].charAt(1)&&a[1].charAt(0)==a[1].charAt(1)&&a[2].charAt(0)==a[2].charAt(1)?a[0].charAt(0)+a[1].charAt(0)+a[2].charAt(0):a.join("")}function u(t,e,n,r){var a=[E(P(r)),E(B(t).toString(16)),E(B(e).toString(16)),E(B(n).toString(16))];return a.join("")}function f(t,n){n=0===n?0:n||10;var r=e(t).toHsl();return r.s-=n/100,r.s=L(r.s),e(r)}function d(t,n){n=0===n?0:n||10;var r=e(t).toHsl();return r.s+=n/100,r.s=L(r.s),e(r)}function h(t){return e(t).desaturate(100)}function p(t,n){n=0===n?0:n||10;var r=e(t).toHsl();return r.l+=n/100,r.l=L(r.l),e(r)}function g(t,n){n=0===n?0:n||10;var r=e(t).toRgb();return r.r=V(0,H(255,r.r-B(255*-(n/100)))),r.g=V(0,H(255,r.g-B(255*-(n/100)))),r.b=V(0,H(255,r.b-B(255*-(n/100)))),e(r)}function v(t,n){n=0===n?0:n||10;var r=e(t).toHsl();return r.l-=n/100,r.l=L(r.l),e(r)}function m(t,n){var r=e(t).toHsl(),a=(B(r.h)+n)%360;return r.h=0>a?360+a:a,e(r)}function y(t){var n=e(t).toHsl();return n.h=(n.h+180)%360,e(n)}function x(t){var n=e(t).toHsl(),r=n.h;return[e(t),e({h:(r+120)%360,s:n.s,l:n.l}),e({h:(r+240)%360,s:n.s,l:n.l})]}function b(t){var n=e(t).toHsl(),r=n.h;return[e(t),e({h:(r+90)%360,s:n.s,l:n.l}),e({h:(r+180)%360,s:n.s,l:n.l}),e({h:(r+270)%360,s:n.s,l:n.l})]}function _(t){var n=e(t).toHsl(),r=n.h;return[e(t),e({h:(r+72)%360,s:n.s,l:n.l}),e({h:(r+216)%360,s:n.s,l:n.l})]}function w(t,n,r){n=n||6,r=r||30;var a=e(t).toHsl(),o=360/r,i=[e(t)];for(a.h=(a.h-(o*n>>1)+720)%360;--n;)a.h=(a.h+o)%360,i.push(e(a));return i}function k(t,n){n=n||6;for(var r=e(t).toHsv(),a=r.h,o=r.s,i=r.v,l=[],s=1/n;n--;)l.push(e({h:a,s:o,v:i})),i=(i+s)%1;return l}function M(t){var e={};for(var n in t)t.hasOwnProperty(n)&&(e[t[n]]=n);return e}function A(t){return t=parseFloat(t),(isNaN(t)||0>t||t>1)&&(t=1),t}function T(t,e){S(t)&&(t="100%");var n=C(t);return t=H(e,V(0,parseFloat(t))),n&&(t=parseInt(t*e,10)/100),q.abs(t-e)<1e-6?1:t%e/parseFloat(e)}function L(t){return H(1,V(0,t))}function z(t){return parseInt(t,16)}function S(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)}function C(t){return"string"==typeof t&&-1!=t.indexOf("%")}function E(t){return 1==t.length?"0"+t:""+t}function O(t){return 1>=t&&(t=100*t+"%"),t}function P(t){return Math.round(255*parseFloat(t)).toString(16)}function N(t){return z(t)/255}function D(t){t=t.replace(R,"").replace(j,"").toLowerCase();var e=!1;if(Y[t])t=Y[t],e=!0;else if("transparent"==t)return{r:0,g:0,b:0,a:0,format:"name"};var n;return(n=X.rgb.exec(t))?{r:n[1],g:n[2],b:n[3]}:(n=X.rgba.exec(t))?{r:n[1],g:n[2],b:n[3],a:n[4]}:(n=X.hsl.exec(t))?{h:n[1],s:n[2],l:n[3]}:(n=X.hsla.exec(t))?{h:n[1],s:n[2],l:n[3],a:n[4]}:(n=X.hsv.exec(t))?{h:n[1],s:n[2],v:n[3]}:(n=X.hsva.exec(t))?{h:n[1],s:n[2],v:n[3],a:n[4]}:(n=X.hex8.exec(t))?{a:N(n[1]),r:z(n[2]),g:z(n[3]),b:z(n[4]),format:e?"name":"hex8"}:(n=X.hex6.exec(t))?{r:z(n[1]),g:z(n[2]),b:z(n[3]),format:e?"name":"hex"}:(n=X.hex3.exec(t))?{r:z(n[1]+""+n[1]),g:z(n[2]+""+n[2]),b:z(n[3]+""+n[3]),format:e?"name":"hex"}:!1}function I(t){var e,n;return t=t||{level:"AA",size:"small"},e=(t.level||"AA").toUpperCase(),n=(t.size||"small").toLowerCase(),"AA"!==e&&"AAA"!==e&&(e="AA"),"small"!==n&&"large"!==n&&(n="small"),{level:e,size:n}}var R=/^\s+/,j=/\s+$/,F=0,q=Math,B=q.round,H=q.min,V=q.max,Z=q.random;e.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var t,e,n,r,a,o,i=this.toRgb();return t=i.r/255,e=i.g/255,n=i.b/255,r=.03928>=t?t/12.92:Math.pow((t+.055)/1.055,2.4),a=.03928>=e?e/12.92:Math.pow((e+.055)/1.055,2.4),o=.03928>=n?n/12.92:Math.pow((n+.055)/1.055,2.4),.2126*r+.7152*a+.0722*o},setAlpha:function(t){return this._a=A(t),this._roundA=B(100*this._a)/100,this},toHsv:function(){var t=l(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=l(this._r,this._g,this._b),e=B(360*t.h),n=B(100*t.s),r=B(100*t.v);return 1==this._a?"hsv("+e+", "+n+"%, "+r+"%)":"hsva("+e+", "+n+"%, "+r+"%, "+this._roundA+")"},toHsl:function(){var t=o(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=o(this._r,this._g,this._b),e=B(360*t.h),n=B(100*t.s),r=B(100*t.l);return 1==this._a?"hsl("+e+", "+n+"%, "+r+"%)":"hsla("+e+", "+n+"%, "+r+"%, "+this._roundA+")"},toHex:function(t){return c(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(){return u(this._r,this._g,this._b,this._a)},toHex8String:function(){return"#"+this.toHex8()},toRgb:function(){return{r:B(this._r),g:B(this._g),b:B(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+B(this._r)+", "+B(this._g)+", "+B(this._b)+")":"rgba("+B(this._r)+", "+B(this._g)+", "+B(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:B(100*T(this._r,255))+"%",g:B(100*T(this._g,255))+"%",b:B(100*T(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+B(100*T(this._r,255))+"%, "+B(100*T(this._g,255))+"%, "+B(100*T(this._b,255))+"%)":"rgba("+B(100*T(this._r,255))+"%, "+B(100*T(this._g,255))+"%, "+B(100*T(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":this._a<1?!1:U[c(this._r,this._g,this._b,!0)]||!1},toFilter:function(t){var n="#"+u(this._r,this._g,this._b,this._a),r=n,a=this._gradientType?"GradientType = 1, ":"";if(t){var o=e(t);r=o.toHex8String()}return"progid:DXImageTransform.Microsoft.gradient("+a+"startColorstr="+n+",endColorstr="+r+")"},toString:function(t){var e=!!t;t=t||this._format;var n=!1,r=this._a<1&&this._a>=0,a=!e&&r&&("hex"===t||"hex6"===t||"hex3"===t||"name"===t);return a?"name"===t&&0===this._a?this.toName():this.toRgbString():("rgb"===t&&(n=this.toRgbString()),"prgb"===t&&(n=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(n=this.toHexString()),"hex3"===t&&(n=this.toHexString(!0)),"hex8"===t&&(n=this.toHex8String()),"name"===t&&(n=this.toName()),"hsl"===t&&(n=this.toHslString()),"hsv"===t&&(n=this.toHsvString()),n||this.toHexString())},clone:function(){return e(this.toString())},_applyModification:function(t,e){var n=t.apply(null,[this].concat([].slice.call(e)));return this._r=n._r,this._g=n._g,this._b=n._b,this.setAlpha(n._a),this},lighten:function(){return this._applyModification(p,arguments)},brighten:function(){return this._applyModification(g,arguments)},darken:function(){return this._applyModification(v,arguments)},desaturate:function(){return this._applyModification(f,arguments)},saturate:function(){return this._applyModification(d,arguments)},greyscale:function(){return this._applyModification(h,arguments)},spin:function(){return this._applyModification(m,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(w,arguments)},complement:function(){return this._applyCombination(y,arguments)},monochromatic:function(){return this._applyCombination(k,arguments)},splitcomplement:function(){return this._applyCombination(_,arguments)},triad:function(){return this._applyCombination(x,arguments)},tetrad:function(){return this._applyCombination(b,arguments)}},e.fromRatio=function(t,n){if("object"==typeof t){var r={};for(var a in t)t.hasOwnProperty(a)&&("a"===a?r[a]=t[a]:r[a]=O(t[a]));t=r}return e(t,n)},e.equals=function(t,n){return t&&n?e(t).toRgbString()==e(n).toRgbString():!1},e.random=function(){return e.fromRatio({r:Z(),g:Z(),b:Z()})},e.mix=function(t,n,r){r=0===r?0:r||50;var a,o=e(t).toRgb(),i=e(n).toRgb(),l=r/100,s=2*l-1,c=i.a-o.a;a=s*c==-1?s:(s+c)/(1+s*c),a=(a+1)/2;var u=1-a,f={r:i.r*a+o.r*u,g:i.g*a+o.g*u,b:i.b*a+o.b*u,a:i.a*l+o.a*(1-l)};return e(f)},e.readability=function(t,n){var r=e(t),a=e(n);return(Math.max(r.getLuminance(),a.getLuminance())+.05)/(Math.min(r.getLuminance(),a.getLuminance())+.05)},e.isReadable=function(t,n,r){var a,o,i=e.readability(t,n);switch(o=!1,a=I(r),a.level+a.size){case"AAsmall":case"AAAlarge":o=i>=4.5;break;case"AAlarge":o=i>=3;break;case"AAAsmall":o=i>=7}return o},e.mostReadable=function(t,n,r){var a,o,i,l,s=null,c=0;r=r||{},o=r.includeFallbackColors,i=r.level,l=r.size;for(var u=0;uc&&(c=a,s=e(n[u]));return e.isReadable(t,s,{level:i,size:l})||!o?s:(r.includeFallbackColors=!1,e.mostReadable(t,["#fff","#000"],r))};var Y=e.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},U=e.hexNames=M(Y),X=function(){var t="[-\\+]?\\d+%?",e="[-\\+]?\\d*\\.\\d+%?",n="(?:"+e+")|(?:"+t+")",r="[\\s|\\(]+("+n+")[,|\\s]+("+n+")[,|\\s]+("+n+")\\s*\\)?",a="[\\s|\\(]+("+n+")[,|\\s]+("+n+")[,|\\s]+("+n+")[,|\\s]+("+n+")\\s*\\)?";return{rgb:new RegExp("rgb"+r),rgba:new RegExp("rgba"+a),hsl:new RegExp("hsl"+r),hsla:new RegExp("hsla"+a),hsv:new RegExp("hsv"+r),hsva:new RegExp("hsva"+a),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();"undefined"!=typeof n&&n.exports?n.exports=e:"function"==typeof t&&t.amd?t(function(){return e}):window.tinycolor=e}()},{}],14:[function(t,e,n){"use strict";e.exports=["",{path:"M-2.4,-3V3L0.6,0Z",backoff:.6},{path:"M-3.7,-2.5V2.5L1.3,0Z",backoff:1.3},{path:"M-4.45,-3L-1.65,-0.2V0.2L-4.45,3L1.55,0Z",backoff:1.55},{path:"M-2.2,-2.2L-0.2,-0.2V0.2L-2.2,2.2L-1.4,3L1.6,0L-1.4,-3Z",backoff:1.6},{path:"M-4.4,-2.1L-0.6,-0.2V0.2L-4.4,2.1L-4,3L2,0L-4,-3Z",backoff:2},{path:"M2,0A2,2 0 1,1 0,-2A2,2 0 0,1 2,0Z",backoff:0},{path:"M2,2V-2H-2V2Z",backoff:0}]},{}],15:[function(t,e,n){"use strict";var r=t("./arrow_paths"),a=t("../../plots/font_attributes"),o=t("../../plots/cartesian/constants"),i=t("../../lib/extend").extendFlat;e.exports={_isLinkedToArray:!0,text:{valType:"string"},textangle:{valType:"angle",dflt:0},font:i({},a,{}),opacity:{valType:"number",min:0,max:1,dflt:1},align:{valType:"enumerated",values:["left","center","right"],dflt:"center"},bgcolor:{valType:"color",dflt:"rgba(0,0,0,0)"},bordercolor:{valType:"color",dflt:"rgba(0,0,0,0)"},borderpad:{valType:"number",min:0,dflt:1},borderwidth:{valType:"number",min:0,dflt:1},showarrow:{valType:"boolean",dflt:!0},arrowcolor:{valType:"color"},arrowhead:{valType:"integer",min:0,max:r.length,dflt:1},arrowsize:{valType:"number",min:.3,dflt:1},arrowwidth:{valType:"number",min:.1},ax:{valType:"number",dflt:-10},ay:{valType:"number",dflt:-30},axref:{valType:"enumerated",dflt:"pixel",values:["pixel",o.idRegex.x.toString()]},ayref:{valType:"enumerated",dflt:"pixel",values:["pixel",o.idRegex.y.toString()]},xref:{valType:"enumerated",values:["paper",o.idRegex.x.toString()]},x:{valType:"number"},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"auto"},yref:{valType:"enumerated",values:["paper",o.idRegex.y.toString()]},y:{valType:"number"},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto"},_deprecated:{ref:{valType:"string"}}}},{"../../lib/extend":93,"../../plots/cartesian/constants":120,"../../plots/font_attributes":133,"./arrow_paths":14}],16:[function(t,e,n){"use strict";function r(t,e){function n(e,n){return c.coerce(t,r,v.layoutAttributes,e,n)}var r={};n("opacity"),n("align"),n("bgcolor");var a=n("bordercolor"),o=f.opacity(a);n("borderpad");var i=n("borderwidth"),l=n("showarrow");l&&(n("arrowcolor",o?r.bordercolor:f.defaultLine),n("arrowhead"),n("arrowsize"),n("arrowwidth",2*(o&&i||1)),n("ax"),n("ay"),n("axref"),n("ayref"),c.noneOrAll(t,r,["ax","ay"])),n("text",l?" ":"new text"),n("textangle"),c.coerceFont(n,"font",e.font); +-for(var s=["x","y"],d=0;2>d;d++){var h=s[d],p={_fullLayout:e},g=u.coerceRef(t,r,p,h),m=u.coerceARef(t,r,p,h),y=.5;if("paper"!==g){var x=u.getFromId(p,g);if(y=x.range[0]+y*(x.range[1]-x.range[0]),-1!==["date","category"].indexOf(x.type)&&"string"==typeof t[h]){var b;if("date"===x.type){if(b=c.dateTime2ms(t[h]),b!==!1&&(t[h]=b),m===g){var _=c.dateTime2ms(t["a"+h]);_!==!1&&(t["a"+h]=_)}}else(x._categories||[]).length&&(b=x._categories.indexOf(t[h]),-1!==b&&(t[h]=b))}}n(h,y),l||n(h+"anchor")}return c.noneOrAll(t,r,["x","y"]),r}function a(t){var e=t._fullLayout;e.annotations.forEach(function(e){var n=u.getFromId(t,e.xref),r=u.getFromId(t,e.yref);if(n||r){var a=(e._xsize||0)/2,o=e._xshift||0,i=(e._ysize||0)/2,l=e._yshift||0,s=a-o,c=a+o,f=i-l,d=i+l;if(e.showarrow){var h=3*e.arrowsize*e.arrowwidth;s=Math.max(s,h),c=Math.max(c,h),f=Math.max(f,h),d=Math.max(d,h)}n&&n.autorange&&u.expand(n,[n.l2c(e.x)],{ppadplus:c,ppadminus:s}),r&&r.autorange&&u.expand(r,[r.l2c(e.y)],{ppadplus:d,ppadminus:f})}})}function o(t,e,n,r,a,o,i,l){var s=n-t,c=a-t,u=i-a,f=r-e,d=o-e,h=l-o,p=s*h-u*f;if(0===p)return null;var g=(c*h-u*d)/p,v=(c*f-s*d)/p;return 0>v||v>1||0>g||g>1?null:{x:t+s*g,y:e+f*g}}var i=t("d3"),l=t("fast-isnumeric"),s=t("../../plotly"),c=t("../../lib"),u=t("../../plots/cartesian/axes"),f=t("../color"),d=t("../drawing"),h=t("../../lib/svg_text_utils"),p=t("../../lib/setcursor"),g=t("../dragelement"),v=e.exports={};v.ARROWPATHS=t("./arrow_paths"),v.layoutAttributes=t("./attributes"),v.supplyLayoutDefaults=function(t,e){for(var n=t.annotations||[],a=e.annotations=[],o=0;ot?"left":t>2/3?"right":"center"),{center:0,middle:0,left:.5,bottom:-.5,right:-.5,top:.5}[e]}tt.selectAll("tspan.line").attr({y:0,x:0});var r=G.select(".annotation-math-group"),a=!r.empty(),l=d.bBox((a?r:tt).node()),h=l.width,m=l.height,y=Math.round(h+2*W),x=Math.round(m+2*W);B._w=h,B._h=m;var b=!1;if(["x","y"].forEach(function(e){var r,a=B[e+"ref"]||e,o=u.getFromId(t,a),i=(Y+("x"===e?0:90))*Math.PI/180,l=y*Math.abs(Math.cos(i))+x*Math.abs(Math.sin(i)),s=B[e+"anchor"];if(o){if(!o.autorange&&(B[e]-o.range[0])*(B[e]-o.range[1])>0&&(B["a"+e+"ref"]===a?(B["a"+e]-o.range[0])*(B["a"+e]-o.range[1])>0&&(b=!0):b=!0,b))return;Z[e]=o._offset+o.l2p(B[e]),r=.5}else r=B[e],"y"===e&&(r=1-r),Z[e]="x"===e?S.l+S.w*r:S.t+S.h*r;var c=0;B["a"+e+"ref"]===a?Z["aa"+e]=o._offset+o.l2p(B["a"+e]):(c=B.showarrow?B["a"+e]:l*n(r,s),Z[e]+=c),B["_"+e+"type"]=o&&o.type,B["_"+e+"size"]=l,B["_"+e+"shift"]=c}),b)return void G.remove();var w,k;B.showarrow&&(w=B.axref===B.xref?Z.x:c.constrain(Z.x-B.ax,1,_.width-1),k=B.ayref===B.yref?Z.y:c.constrain(Z.y-B.ay,1,_.height-1)),Z.x=c.constrain(Z.x,1,_.width-1),Z.y=c.constrain(Z.y,1,_.height-1);var M=W-l.top,A=W-l.left;a?r.select("svg").attr({x:W-1,y:W}):(tt.attr({x:A,y:M}),tt.selectAll("tspan.line").attr({y:M,x:A})),J.call(d.setRect,$/2,$/2,y-$,x-$);var T=0,L=0;T=B.axref===B.xref?Math.round(Z.aax-y/2):Math.round(Z.x-y/2),L=B.ayref===B.yref?Math.round(Z.aay-x/2):Math.round(Z.y-x/2),G.call(c.setTranslate,T,L);var z="annotations["+e+"]",C=function(n,r){i.select(t).selectAll('.annotation-arrow-g[data-index="'+e+'"]').remove();var a,l;a=B.axref===B.xref?Z.aax+n:Z.x+n,l=B.ayref===B.yref?Z.aay+r:Z.y+r;var u=c.rotationXYMatrix(Y,a,l),d=c.apply2DTransform(u),h=c.apply2DTransform2(u),p=J.attr("width")/2,m=J.attr("height")/2,y=[[a-p,l-m,a-p,l+m],[a-p,l+m,a+p,l+m],[a+p,l+m,a+p,l-m],[a+p,l-m,a-p,l-m]].map(h);if(!y.reduce(function(t,e){return t^!!o(w,k,w+1e6,k+1e6,e[0],e[1],e[2],e[3])},!1)){y.forEach(function(t){var e=o(a,l,w,k,t[0],t[1],t[2],t[3]);e&&(a=e.x,l=e.y)});var x=B.arrowwidth,b=B.arrowcolor,_=U.append("g").style({opacity:f.opacity(b)}).classed("annotation-arrow-g",!0).attr("data-index",String(e)),M=_.append("path").attr("d","M"+a+","+l+"L"+w+","+k).style("stroke-width",x+"px").call(f.stroke,f.rgb(b));v.arrowhead(M,B.arrowhead,"end",B.arrowsize);var A=_.append("path").classed("annotation",!0).classed("anndrag",!0).attr({"data-index":String(e),d:"M3,3H-3V-3H3ZM0,0L"+(a-w)+","+(l-k),transform:"translate("+w+","+k+")"}).style("stroke-width",x+6+"px").call(f.stroke,"rgba(0,0,0,0)").call(f.fill,"rgba(0,0,0,0)");if(t._context.editable){var T,L,C;g.init({element:A.node(),prepFn:function(){var t=c.getTranslate(G);L=t.x,C=t.y,T={},H&&H.autorange&&(T[H._name+".autorange"]=!0),V&&V.autorange&&(T[V._name+".autorange"]=!0)},moveFn:function(t,e){_.attr("transform","translate("+t+","+e+")");var n=d(L,C),r=n[0]+t,a=n[1]+e;G.call(c.setTranslate,r,a),T[z+".x"]=H?B.x+t/H._m:(w+t-S.l)/S.w,T[z+".y"]=V?B.y+e/V._m:1-(k+e-S.t)/S.h,B.axref===B.xref&&(T[z+".ax"]=H?B.ax+t/H._m:(w+t-S.l)/S.w),B.ayref===B.yref&&(T[z+".ay"]=V?B.ay+e/V._m:1-(k+e-S.t)/S.h),X.attr({transform:"rotate("+Y+","+r+","+a+")"})},doneFn:function(e){if(e){s.relayout(t,T);var n=document.querySelector(".js-notes-box-panel");n&&n.redraw(n.selectedObj)}}})}}};B.showarrow&&C(0,0);var E=c.rotationXYMatrix(Y,Z.x,Z.y),O=c.apply2DTransform(E);if(t._context.editable){var P,N,D;g.init({element:G.node(),prepFn:function(){var t=c.getTranslate(G);P=t.x,N=t.y,D={}},moveFn:function(t,e){G.call(c.setTranslate,P+t,N+e);var n="pointer";if(B.showarrow)B.axref===B.xref?D[z+".ax"]=H.p2l(H.l2p(B.ax)+t):D[z+".ax"]=B.ax+t,B.ayref===B.yref?D[z+".ay"]=V.p2l(V.l2p(B.ay)+e):D[z+".ay"]=B.ay+e,C(t,e);else{if(H)D[z+".x"]=B.x+t/H._m;else{var r=B._xsize/S.w,a=B.x+B._xshift/S.w-r/2;D[z+".x"]=g.align(a+t/S.w,r,0,1,B.xanchor)}if(V)D[z+".y"]=B.y+e/V._m;else{var o=B._ysize/S.h,i=B.y-B._yshift/S.h-o/2;D[z+".y"]=g.align(i-e/S.h,o,0,1,B.yanchor)}H&&V||(n=g.getCursor(H?.5:D[z+".x"],V?.5:D[z+".y"],B.xanchor,B.yanchor))}var l=O(P,N),s=l[0]+t,u=l[1]+e;G.call(c.setTranslate,P+t,N+e),X.attr({transform:"rotate("+Y+","+s+","+u+")"}),p(G,n)},doneFn:function(e){if(p(G),e){s.relayout(t,D);var n=document.querySelector(".js-notes-box-panel");n&&n.redraw(n.selectedObj)}}})}}var x,b=t.layout,_=t._fullLayout;if(!l(e)||-1===e){if(!e&&Array.isArray(a))return b.annotations=a,v.supplyLayoutDefaults(b,_),void v.drawAll(t);if("remove"===a)return delete b.annotations,_.annotations=[],void v.drawAll(t);if(n&&"add"!==a){for(x=0;x<_.annotations.length;x++)v.draw(t,x,n,a);return}e=_.annotations.length,_.annotations.push({})}if(!n&&a){if("remove"===a){for(_._infolayer.selectAll('.annotation[data-index="'+e+'"]').remove(),_.annotations.splice(e,1),b.annotations.splice(e,1),x=e;x<_.annotations.length;x++)_._infolayer.selectAll('.annotation[data-index="'+(x+1)+'"]').attr("data-index",String(x)),v.draw(t,x);return}if("add"===a||c.isPlainObject(a)){_.annotations.splice(e,0,{});var w=c.isPlainObject(a)?c.extendFlat({},a):{text:"New text"};for(b.annotations?b.annotations.splice(e,0,w):b.annotations=[w],x=_.annotations.length-1;x>e;x--)_._infolayer.selectAll('.annotation[data-index="'+(x-1)+'"]').attr("data-index",String(x)),v.draw(t,x)}}_._infolayer.selectAll('.annotation[data-index="'+e+'"]').remove();var k=b.annotations[e],M=_.annotations[e];if(k){var A={xref:k.xref,yref:k.yref},T={};"string"==typeof n&&n?T[n]=a:c.isPlainObject(n)&&(T=n);var L=Object.keys(T);for(x=0;xx;x++){var E=C[x];if(void 0===T[E]&&void 0!==k[E]){var O=u.getFromId(t,u.coerceRef(A,{},t,E)),P=u.getFromId(t,u.coerceRef(k,{},t,E)),N=k[E],D=M["_"+E+"type"];if(void 0!==T[E+"ref"]){var I="auto"===k[E+"anchor"],R="x"===E?S.w:S.h,j=(M["_"+E+"size"]||0)/(2*R);if(O&&P)N=(N-O.range[0])/(O.range[1]-O.range[0]),N=P.range[0]+N*(P.range[1]-P.range[0]);else if(O){if(N=(N-O.range[0])/(O.range[1]-O.range[0]),N=O.domain[0]+N*(O.domain[1]-O.domain[0]),I){var F=N+j,q=N-j;2/3>N+q?N=q:N+F>4/3&&(N=F)}}else P&&(I&&(1/3>N?N+=j:N>2/3&&(N-=j)),N=(N-P.domain[0])/(P.domain[1]-P.domain[0]),N=P.range[0]+N*(P.range[1]-P.range[0]))}P&&P===O&&D&&("log"===D&&"log"!==P.type?N=Math.pow(10,N):"log"!==D&&"log"===P.type&&(N=N>0?Math.log(N)/Math.LN10:void 0)),k[E]=N}}var B=r(k,_);_.annotations[e]=B;var H=u.getFromId(t,B.xref),V=u.getFromId(t,B.yref),Z={x:0,y:0},Y=+B.textangle||0,U=_._infolayer.append("g").classed("annotation",!0).attr("data-index",String(e)).style("opacity",B.opacity).on("click",function(){t._dragging=!1,t.emit("plotly_clickannotation",{index:e,annotation:k,fullAnnotation:B})}),X=U.append("g").classed("annotation-text-g",!0).attr("data-index",String(e)),G=X.append("g"),$=B.borderwidth,Q=B.borderpad,W=$+Q,J=G.append("rect").attr("class","bg").style("stroke-width",$+"px").call(f.stroke,B.bordercolor).call(f.fill,B.bgcolor),K=B.font,tt=G.append("text").classed("annotation",!0).attr("data-unformatted",B.text).text(B.text);t._context.editable?tt.call(h.makeEditable,G).call(m).on("edit",function(n){B.text=n,this.attr({"data-unformatted":B.text}),this.call(m);var r={};r["annotations["+e+"].text"]=B.text,H&&H.autorange&&(r[H._name+".autorange"]=!0),V&&V.autorange&&(r[V._name+".autorange"]=!0),s.relayout(t,r)}):tt.call(m),X.attr({transform:"rotate("+Y+","+Z.x+","+Z.y+")"}).call(d.setPosition,Z.x,Z.y)}},v.arrowhead=function(t,e,n,r){l(r)||(r=1);var a=t.node(),o=v.ARROWPATHS[e||0];if(o){"string"==typeof n&&n||(n="end");var s,c,u,h,p=(d.getPx(t,"stroke-width")||1)*r,g=t.style("stroke")||f.defaultLine,m=t.style("stroke-opacity")||1,y=n.indexOf("start")>=0,x=n.indexOf("end")>=0,b=o.backoff*p;if("line"===a.nodeName){if(s={x:+t.attr("x1"),y:+t.attr("y1")},c={x:+t.attr("x2"),y:+t.attr("y2")},u=Math.atan2(s.y-c.y,s.x-c.x),h=u+Math.PI,b){var _=b*Math.cos(u),w=b*Math.sin(u);y&&(s.x-=_,s.y-=w,t.attr({x1:s.x,y1:s.y})),x&&(c.x+=_,c.y+=w,t.attr({x2:c.x,y2:c.y}))}}else if("path"===a.nodeName){var k=a.getTotalLength(),M="";if(y){var A=a.getPointAtLength(0),T=a.getPointAtLength(.1);u=Math.atan2(A.y-T.y,A.x-T.x),s=a.getPointAtLength(Math.min(b,k)),b&&(M="0px,"+b+"px,")}if(x){var L=a.getPointAtLength(k),z=a.getPointAtLength(k-.1);if(h=Math.atan2(L.y-z.y,L.x-z.x),c=a.getPointAtLength(Math.max(0,k-b)),b){var S=M?2*b:b;M+=k-S+"px,"+k+"px"}}else M&&(M+=k+"px");M&&t.style("stroke-dasharray",M)}var C=function(n,r){e>5&&(r=0),i.select(a.parentElement).append("path").attr({"class":t.attr("class"),d:o.path,transform:"translate("+n.x+","+n.y+")rotate("+180*r/Math.PI+")scale("+p+")"}).style({fill:g,opacity:m,"stroke-width":0})};y&&C(s,u),x&&C(c,h)}},v.calcAutorange=function(t){var e=t._fullLayout,n=e.annotations;if(n.length&&t._fullData.length){var r={};n.forEach(function(t){r[t.xref]=!0,r[t.yref]=!0});var o=u.list(t).filter(function(t){return t.autorange&&r[t._id]});if(o.length)return c.syncOrAsync([v.drawAll,a],t)}}},{"../../lib":94,"../../lib/setcursor":103,"../../lib/svg_text_utils":105,"../../plotly":112,"../../plots/cartesian/axes":115,"../color":18,"../dragelement":39,"../drawing":41,"./arrow_paths":14,"./attributes":15,d3:9,"fast-isnumeric":11}],17:[function(t,e,n){"use strict";n.defaults=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],n.defaultLine="#444",n.lightLine="#eee",n.background="#fff",n.borderLine="#BEC8D9",n.lightFraction=1e3/11},{}],18:[function(t,e,n){"use strict";function r(t){if(o(t)||"string"!=typeof t)return t;var e=t.trim();if("rgb"!==e.substr(0,3))return t;var n=e.match(/^rgba?\s*\(([^()]*)\)$/);if(!n)return t;var r=n[1].trim().split(/\s*[\s,]\s*/),a="a"===e.charAt(3)&&4===r.length;if(!a&&3!==r.length)return t;for(var i=0;i=0))return t;if(3===i)r[i]>1&&(r[i]=1);else if(r[i]>=1)return t}var l=Math.round(255*r[0])+", "+Math.round(255*r[1])+", "+Math.round(255*r[2]);return a?"rgba("+l+", "+r[3]+")":"rgb("+l+")"}var a=t("tinycolor2"),o=t("fast-isnumeric"),i=e.exports={},l=t("./attributes");i.defaults=l.defaults,i.defaultLine=l.defaultLine,i.lightLine=l.lightLine,i.background=l.background,i.tinyRGB=function(t){var e=t.toRgb();return"rgb("+Math.round(e.r)+", "+Math.round(e.g)+", "+Math.round(e.b)+")"},i.rgb=function(t){return i.tinyRGB(a(t))},i.opacity=function(t){return t?a(t).getAlpha():0},i.addOpacity=function(t,e){var n=a(t).toRgb();return"rgba("+Math.round(n.r)+", "+Math.round(n.g)+", "+Math.round(n.b)+", "+e+")"},i.combine=function(t,e){var n=a(t).toRgb();if(1===n.a)return a(t).toRgbString();var r=a(e||i.background).toRgb(),o=1===r.a?r:{r:255*(1-r.a)+r.r*r.a,g:255*(1-r.a)+r.g*r.a,b:255*(1-r.a)+r.b*r.a},l={r:o.r*(1-n.a)+n.r*n.a,g:o.g*(1-n.a)+n.g*n.a,b:o.b*(1-n.a)+n.b*n.a};return a(l).toRgbString()},i.contrast=function(t,e,n){var r=a(t),o=r.isLight()?r.darken(n):r.lighten(e);return o.toString()},i.stroke=function(t,e){var n=a(e);t.style({stroke:i.tinyRGB(n),"stroke-opacity":n.getAlpha()})},i.fill=function(t,e){var n=a(e);t.style({fill:i.tinyRGB(n),"fill-opacity":n.getAlpha()})},i.clean=function(t){if(t&&"object"==typeof t){var e,n,a,o,l=Object.keys(t);for(e=0;es&&(o[1]-=(it-s)/2)):n.node()&&!n.classed("js-placeholder")&&(it=d.bBox(e.node()).height),it){if(it+=5,"top"===b.titleside)J.domain[1]-=it/A.h,o[1]*=-1;else{J.domain[0]+=it/A.h;var u=Math.max(1,n.selectAll("tspan.line").size());o[1]+=(1-u)*s}e.attr("transform","translate("+o+")"),J.setScale()}}at.selectAll(".cbfills,.cblines,.cbaxis").attr("transform","translate(0,"+Math.round(A.h*(1-J.domain[1]))+")");var f=at.select(".cbfills").selectAll("rect.cbfill").data(S);f.enter().append("rect").classed("cbfill",!0).style("stroke","none"),f.exit().remove(),f.each(function(t,e){var n=[0===e?L[0]:(S[e]+S[e-1])/2,e===S.length-1?L[1]:(S[e]+S[e+1])/2].map(J.c2p).map(Math.round);e!==S.length-1&&(n[1]+=n[1]>n[0]?1:-1);var o=E(t).replace("e-",""),i=a(o).toHexString();r.select(this).attr({x:U,width:Math.max(F,2),y:r.min(n),height:Math.max(r.max(n)-r.min(n),2),fill:i})});var h=at.select(".cblines").selectAll("path.cbline").data(b.line.color&&b.line.width?z:[]);return h.enter().append("path").classed("cbline",!0),h.exit().remove(),h.each(function(t){r.select(this).attr("d","M"+U+","+(Math.round(J.c2p(t))+b.line.width/2%1)+"h"+F).call(d.lineGroupStyle,b.line.width,C(t),b.line.dash)}),J._axislayer.selectAll("g."+J._id+"tick,path").remove(),J._pos=U+F+(b.outlinewidth||0)/2-("outside"===b.ticks?1:0),J.side="right",c.syncOrAsync([function(){return l.doTicks(t,J,!0)},function(){if(-1===["top","bottom"].indexOf(b.titleside)){var e=J.titlefont.size,n=J._offset+J._length/2,a=A.l+(J.position||0)*A.w+("right"===J.side?10+e*(J.showticklabels?1:.5):-10-e*(J.showticklabels?.5:0));w("h"+J._id+"title",{avoid:{selection:r.select(t).selectAll("g."+J._id+"tick"),side:b.titleside,offsetLeft:A.l,offsetTop:A.t,maxShift:M.width},attributes:{x:a,y:n,"text-anchor":"middle"},transform:{rotate:"-90",offset:0}})}}])}function w(e,n){var r,a=x();r=i.traceIs(a,"markerColorscale")?"marker.colorbar.title":"colorbar.title";var o={propContainer:J,propName:r,traceIndex:a.index,dfltName:"colorscale",containerGroup:at.select(".cbtitle")},l="h"===e.charAt(0)?e.substr(1):"h"+e;at.selectAll("."+l+",."+l+"-math-group").remove(),p.draw(t,e,u(o,n||{}))}function k(){var n=F+b.outlinewidth/2+d.bBox(J._axislayer.node()).width;if(I=ot.select("text"),I.node()&&!I.classed("js-placeholder")){var r,a=ot.select(".h"+J._id+"title-math-group").node();r=a&&-1!==["top","bottom"].indexOf(b.titleside)?d.bBox(a).width:d.bBox(ot.node()).right-U-A.l,n=Math.max(n,r)}var o=2*b.xpad+n+b.borderwidth+b.outlinewidth/2,l=$-Q;at.select(".cbbg").attr({x:U-b.xpad-(b.borderwidth+b.outlinewidth)/2,y:Q-Z,width:Math.max(o,2),height:Math.max(l+2*Z,2)}).call(h.fill,b.bgcolor).call(h.stroke,b.bordercolor).style({"stroke-width":b.borderwidth}),at.selectAll(".cboutline").attr({x:U,y:Q+b.ypad+("top"===b.titleside?it:0),width:Math.max(F,2),height:Math.max(l-2*b.ypad-it,2)}).call(h.stroke,b.outlinecolor).style({fill:"None","stroke-width":b.outlinewidth});var s=({center:.5,right:1}[b.xanchor]||0)*o;at.attr("transform","translate("+(A.l-s)+","+A.t+")"),i.autoMargin(t,e,{x:b.x,y:b.y,l:o*({right:1,center:.5}[b.xanchor]||0),r:o*({left:1,center:.5}[b.xanchor]||0),t:l*({bottom:1,middle:.5}[b.yanchor]||0),b:l*({top:1,middle:.5}[b.yanchor]||0)})}var M=t._fullLayout,A=M._size;if("function"!=typeof b.fillcolor&&"function"!=typeof b.line.color)return void M._infolayer.selectAll("g."+e).remove();var T,L=r.extent(("function"==typeof b.fillcolor?b.fillcolor:b.line.color).domain()),z=[],S=[],C="function"==typeof b.line.color?b.line.color:function(){return b.line.color},E="function"==typeof b.fillcolor?b.fillcolor:function(){return b.fillcolor},O=b.levels.end+b.levels.size/100,P=b.levels.size,N=1.001*L[0]-.001*L[1],D=1.001*L[1]-.001*L[0];for(T=b.levels.start;0>(T-O)*P;T+=P)T>N&&D>T&&z.push(T);if("function"==typeof b.fillcolor)if(b.filllevels)for(O=b.filllevels.end+b.filllevels.size/100,P=b.filllevels.size,T=b.filllevels.start;0>(T-O)*P;T+=P)T>L[0]&&T1){var rt=Math.pow(10,Math.floor(Math.log(nt)/Math.LN10));tt*=rt*c.roundUp(nt/rt,[2,5,10]),(Math.abs(b.levels.start)/b.levels.size+1e-6)%1<2e-6&&(J.tick0=0)}J.dtick=tt}J.domain=[G+Y,G+H-Y],J.setScale();var at=M._infolayer.selectAll("g."+e).data([0]);at.enter().append("g").classed(e,!0).each(function(){var t=r.select(this);t.append("rect").classed("cbbg",!0),t.append("g").classed("cbfills",!0),t.append("g").classed("cblines",!0),t.append("g").classed("cbaxis",!0).classed("crisp",!0),t.append("g").classed("cbtitleunshift",!0).append("g").classed("cbtitle",!0),t.append("rect").classed("cboutline",!0),t.select(".cbtitle").datum(0)}),at.attr("transform","translate("+Math.round(A.l)+","+Math.round(A.t)+")");var ot=at.select(".cbtitleunshift").attr("transform","translate(-"+Math.round(A.l)+",-"+Math.round(A.t)+")");J._axislayer=at.select(".cbaxis");var it=0;if(-1!==["top","bottom"].indexOf(b.titleside)){var lt,st=A.l+(b.x+V)*A.w,ct=J.titlefont.size;lt="top"===b.titleside?(1-(G+H-Y))*A.h+A.t+3+.75*ct:(1-(G+Y))*A.h+A.t-3-.25*ct,w(J._id+"title",{attributes:{x:st,y:lt,"text-anchor":"start"}})}var ut=c.syncOrAsync([i.previousPromises,_,i.previousPromises,k],t);if(ut&&ut.then&&(t._promises||[]).push(ut),t._context.editable){var ft,dt,ht;s.init({element:at.node(),prepFn:function(){ft=at.attr("transform"),f(at)},moveFn:function(t,e){at.attr("transform",ft+" translate("+t+","+e+")"),dt=s.align(X+t/A.w,q,0,1,b.xanchor),ht=s.align(G-e/A.h,H,0,1,b.yanchor);var n=s.getCursor(dt,ht,b.xanchor,b.yanchor);f(at,n)},doneFn:function(e){f(at),e&&void 0!==dt&&void 0!==ht&&o.restyle(t,{"colorbar.x":dt,"colorbar.y":ht},x().index)}})}return ut}function x(){var n,r,a=e.substr(2);for(n=0;nu*f?a.RdBu:u>=0?a.Reds:a.Blues,s.colorscale=d,l.reversescale&&(d=o(d)),l.colorscale=d)}},{"../../lib":94,"./flip_scale":29,"./scales":36}],26:[function(t,e,n){"use strict";var r=t("./attributes"),a=t("../../lib/extend").extendDeep;t("./scales.js");e.exports=function(t){return{color:{valType:"color",arrayOk:!0},colorscale:a({},r.colorscale,{}),cauto:a({},r.zauto,{}),cmax:a({},r.zmax,{}),cmin:a({},r.zmin,{}),autocolorscale:a({},r.autocolorscale,{}),reversescale:a({},r.reversescale,{})}}},{"../../lib/extend":93,"./attributes":24,"./scales.js":36}],27:[function(t,e,n){"use strict";var r=t("./scales");e.exports=r.RdBu},{"./scales":36}],28:[function(t,e,n){"use strict";var r=t("fast-isnumeric"),a=t("../../lib"),o=t("../colorbar/has_colorbar"),i=t("../colorbar/defaults"),l=t("./is_valid_scale"),s=t("./flip_scale");e.exports=function(t,e,n,c,u){var f=u.prefix,d=u.cLetter,h=f.slice(0,f.length-1),p=f?a.nestedProperty(t,h).get()||{}:t,g=f?a.nestedProperty(e,h).get()||{}:e,v=p[d+"min"],m=p[d+"max"],y=p.colorscale,x=r(v)&&r(m)&&m>v;c(f+d+"auto",!x),c(f+d+"min"),c(f+d+"max");var b;void 0!==y&&(b=!l(y)),c(f+"autocolorscale",b);var _=c(f+"colorscale"),w=c(f+"reversescale");if(w&&(g.colorscale=s(_)),"marker.line."!==f){var k;f&&(k=o(p));var M=c(f+"showscale",k);M&&i(p,g,n)}}},{"../../lib":94,"../colorbar/defaults":20,"../colorbar/has_colorbar":22,"./flip_scale":29,"./is_valid_scale":33,"fast-isnumeric":11}],29:[function(t,e,n){"use strict";e.exports=function(t){for(var e,n=t.length,r=new Array(n),a=n-1,o=0;a>=0;a--,o++)e=t[a],r[o]=[1-e[0],e[1]];return r}},{}],30:[function(t,e,n){"use strict";var r=t("./scales"),a=t("./default_scale"),o=t("./is_valid_scale_array");e.exports=function(t,e){function n(){try{t=r[t]||JSON.parse(t)}catch(n){t=e}}return e||(e=a),t?("string"==typeof t&&(n(),"string"==typeof t&&n()),o(t)?t:e):e}},{"./default_scale":27,"./is_valid_scale_array":34,"./scales":36}],31:[function(t,e,n){"use strict";var r=t("fast-isnumeric"),a=t("../../lib"),o=t("./is_valid_scale");e.exports=function(t,e){var n=e?a.nestedProperty(t,e).get()||{}:t,i=n.color,l=!1;if(Array.isArray(i))for(var s=0;sd;d++)s=t[d],u[d]=e+s[0]*(n-e),f[d]=a(s[1]).toRgb();var h=r.scale.linear().domain(u).interpolate(r.interpolateObject).range(f);return function(t){if(o(t)){var r=i.constrain(t,e,n),s=h(r);return a(s).toRgbString()}return a(t).isValid()?t:l.defaultLine}}},{"../../lib":94,"../color":18,d3:9,"fast-isnumeric":11,tinycolor2:13}],36:[function(t,e,n){"use strict";e.exports={Greys:[[0,"rgb(0,0,0)"],[1,"rgb(255,255,255)"]],YlGnBu:[[0,"rgb(8,29,88)"],[.125,"rgb(37,52,148)"],[.25,"rgb(34,94,168)"],[.375,"rgb(29,145,192)"],[.5,"rgb(65,182,196)"],[.625,"rgb(127,205,187)"],[.75,"rgb(199,233,180)"],[.875,"rgb(237,248,217)"],[1,"rgb(255,255,217)"]],Greens:[[0,"rgb(0,68,27)"],[.125,"rgb(0,109,44)"],[.25,"rgb(35,139,69)"],[.375,"rgb(65,171,93)"],[.5,"rgb(116,196,118)"],[.625,"rgb(161,217,155)"],[.75,"rgb(199,233,192)"],[.875,"rgb(229,245,224)"],[1,"rgb(247,252,245)"]],YlOrRd:[[0,"rgb(128,0,38)"],[.125,"rgb(189,0,38)"],[.25,"rgb(227,26,28)"],[.375,"rgb(252,78,42)"],[.5,"rgb(253,141,60)"],[.625,"rgb(254,178,76)"],[.75,"rgb(254,217,118)"],[.875,"rgb(255,237,160)"],[1,"rgb(255,255,204)"]],Bluered:[[0,"rgb(0,0,255)"],[1,"rgb(255,0,0)"]],RdBu:[[0,"rgb(5,10,172)"],[.35,"rgb(106,137,247)"],[.5,"rgb(190,190,190)"],[.6,"rgb(220,170,132)"],[.7,"rgb(230,145,90)"],[1,"rgb(178,10,28)"]],Reds:[[0,"rgb(220,220,220)"],[.2,"rgb(245,195,157)"],[.4,"rgb(245,160,105)"],[1,"rgb(178,10,28)"]],Blues:[[0,"rgb(5,10,172)"],[.35,"rgb(40,60,190)"],[.5,"rgb(70,100,245)"],[.6,"rgb(90,120,245)"],[.7,"rgb(106,137,247)"],[1,"rgb(220,220,220)"]],Picnic:[[0,"rgb(0,0,255)"],[.1,"rgb(51,153,255)"],[.2,"rgb(102,204,255)"],[.3,"rgb(153,204,255)"],[.4,"rgb(204,204,255)"],[.5,"rgb(255,255,255)"],[.6,"rgb(255,204,255)"],[.7,"rgb(255,153,255)"],[.8,"rgb(255,102,204)"],[.9,"rgb(255,102,102)"],[1,"rgb(255,0,0)"]],Rainbow:[[0,"rgb(150,0,90)"],[.125,"rgb(0,0,200)"],[.25,"rgb(0,25,255)"],[.375,"rgb(0,152,255)"],[.5,"rgb(44,255,150)"],[.625,"rgb(151,255,0)"],[.75,"rgb(255,234,0)"],[.875,"rgb(255,111,0)"],[1,"rgb(255,0,0)"]],Portland:[[0,"rgb(12,51,131)"],[.25,"rgb(10,136,186)"],[.5,"rgb(242,211,56)"],[.75,"rgb(242,143,56)"],[1,"rgb(217,30,30)"]],Jet:[[0,"rgb(0,0,131)"],[.125,"rgb(0,60,170)"],[.375,"rgb(5,255,255)"],[.625,"rgb(255,255,0)"],[.875,"rgb(250,0,0)"],[1,"rgb(128,0,0)"]], +-Hot:[[0,"rgb(0,0,0)"],[.3,"rgb(230,0,0)"],[.6,"rgb(255,210,0)"],[1,"rgb(255,255,255)"]],Blackbody:[[0,"rgb(0,0,0)"],[.2,"rgb(230,0,0)"],[.4,"rgb(230,210,0)"],[.7,"rgb(255,255,255)"],[1,"rgb(160,200,255)"]],Earth:[[0,"rgb(0,0,130)"],[.1,"rgb(0,180,180)"],[.2,"rgb(40,210,40)"],[.4,"rgb(230,230,50)"],[.6,"rgb(120,70,20)"],[1,"rgb(255,255,255)"]],Electric:[[0,"rgb(0,0,0)"],[.15,"rgb(30,0,100)"],[.4,"rgb(120,0,100)"],[.6,"rgb(160,90,0)"],[.8,"rgb(230,200,0)"],[1,"rgb(255,250,220)"]],Viridis:[[0,"#440154"],[.06274509803921569,"#48186a"],[.12549019607843137,"#472d7b"],[.18823529411764706,"#424086"],[.25098039215686274,"#3b528b"],[.3137254901960784,"#33638d"],[.3764705882352941,"#2c728e"],[.4392156862745098,"#26828e"],[.5019607843137255,"#21918c"],[.5647058823529412,"#1fa088"],[.6274509803921569,"#28ae80"],[.6901960784313725,"#3fbc73"],[.7529411764705882,"#5ec962"],[.8156862745098039,"#84d44b"],[.8784313725490196,"#addc30"],[.9411764705882353,"#d8e219"],[1,"#fde725"]]}},{}],37:[function(t,e,n){"use strict";e.exports=function(t,e,n,r,a){var o=(t-n)/(r-n),i=o+e/(r-n),l=(o+i)/2;return"left"===a||"bottom"===a?o:"center"===a||"middle"===a?l:"right"===a||"top"===a?i:2/3-l>o?o:i>4/3-l?i:l}},{}],38:[function(t,e,n){"use strict";var r=t("../../lib"),a=[["sw-resize","s-resize","se-resize"],["w-resize","move","e-resize"],["nw-resize","n-resize","ne-resize"]];e.exports=function(t,e,n,o){return t="left"===n?0:"center"===n?1:"right"===n?2:r.constrain(Math.floor(3*t),0,2),e="bottom"===o?0:"middle"===o?1:"top"===o?2:r.constrain(Math.floor(3*e),0,2),a[e][t]}},{"../../lib":94}],39:[function(t,e,n){"use strict";function r(){var t=document.createElement("div");t.className="dragcover";var e=t.style;return e.position="fixed",e.left=0,e.right=0,e.top=0,e.bottom=0,e.zIndex=999999999,e.background="none",document.body.appendChild(t),t}function a(t){t._dragging=!1,t._replotPending&&o.plot(t)}var o=t("../../plotly"),i=t("../../lib"),l=t("../../plots/cartesian/constants"),s=e.exports={};s.align=t("./align"),s.getCursor=t("./cursor");var c=t("./unhover");s.unhover=c.wrapped,s.unhoverRaw=c.raw,s.init=function(t){function e(e){return t.element.onmousemove=p,g._dragged=!1,g._dragging=!0,c=e.clientX,u=e.clientY,h=e.target,f=(new Date).getTime(),f-g._mouseDownTimem&&(v=Math.max(v-1,1)),t.doneFn&&t.doneFn(g._dragged,v),!g._dragged){var n=document.createEvent("MouseEvents");n.initEvent("click",!0,!0),h.dispatchEvent(n)}return a(g),g._dragged=!1,i.pauseEvent(e)}var c,u,f,d,h,p,g=i.getPlotDiv(t.element)||{},v=1,m=l.DBLCLICKDELAY;g._mouseDownTime||(g._mouseDownTime=0),p=t.element.onmousemove,t.setCursor&&(t.element.onmousemove=t.setCursor),t.element.onmousedown=e,t.element.style.pointerEvents="all"}},{"../../lib":94,"../../plotly":112,"../../plots/cartesian/constants":120,"./align":37,"./cursor":38,"./unhover":40}],40:[function(t,e,n){"use strict";var r=t("../../lib/events"),a=e.exports={};a.wrapped=function(t,e,n){"string"==typeof t&&(t=document.getElementById(t)),t._hoverTimer&&(clearTimeout(t._hoverTimer),t._hoverTimer=void 0),a.raw(t,e,n)},a.raw=function(t,e){var n=t._fullLayout;e||(e={}),e.target&&r.triggerHandler(t,"plotly_beforehover",e)===!1||(n._hoverlayer.selectAll("g").remove(),e.target&&t._hoverdata&&t.emit("plotly_unhover",{points:t._hoverdata}),t._hoverdata=void 0)}},{"../../lib/events":92}],41:[function(t,e,n){"use strict";function r(t,e,n,r){var o=t[0]-e[0],i=t[1]-e[1],l=n[0]-e[0],s=n[1]-e[1],c=Math.pow(o*o+i*i,b/2),u=Math.pow(l*l+s*s,b/2),f=(u*u*o-c*c*l)*r,d=(u*u*i-c*c*s)*r,h=3*u*(c+u),p=3*c*(c+u);return[[a.round(e[0]+(h&&f/h),2),a.round(e[1]+(h&&d/h),2)],[a.round(e[0]-(p&&f/p),2),a.round(e[1]-(p&&d/p),2)]]}var a=t("d3"),o=t("fast-isnumeric"),i=t("../../plots/plots"),l=t("../color"),s=t("../colorscale"),c=t("../../lib"),u=t("../../lib/svg_text_utils"),f=t("../../constants/xmlns_namespaces"),d=t("../../traces/scatter/subtypes"),h=t("../../traces/scatter/make_bubble_size_func"),p=e.exports={};p.font=function(t,e,n,r){e&&e.family&&(r=e.color,n=e.size,e=e.family),e&&t.style("font-family",e),n+1&&t.style("font-size",n+"px"),r&&t.call(l.fill,r)},p.setPosition=function(t,e,n){t.attr("x",e).attr("y",n)},p.setSize=function(t,e,n){t.attr("width",e).attr("height",n)},p.setRect=function(t,e,n,r,a){t.call(p.setPosition,e,n).call(p.setSize,r,a)},p.translatePoints=function(t,e,n){t.each(function(t){var r=t.xp||e.c2p(t.x),i=t.yp||n.c2p(t.y),l=a.select(this);o(r)&&o(i)?"text"===this.nodeName?l.attr("x",r).attr("y",i):l.attr("transform","translate("+r+","+i+")"):l.remove()})},p.getPx=function(t,e){return Number(t.style(e).replace(/px$/,""))},p.crispRound=function(t,e,n){return e&&o(e)?t._context.staticPlot?e:1>e?1:Math.round(e):n||0},p.lineGroupStyle=function(t,e,n,r){t.style("fill","none").each(function(t){var o=(((t||[])[0]||{}).trace||{}).line||{},i=e||o.width||0,s=r||o.dash||"";a.select(this).call(l.stroke,n||o.color).call(p.dashLine,s,i)})},p.dashLine=function(t,e,n){var r=Math.max(n,3);"solid"===e?e="":"dot"===e?e=r+"px,"+r+"px":"dash"===e?e=3*r+"px,"+3*r+"px":"longdash"===e?e=5*r+"px,"+5*r+"px":"dashdot"===e?e=3*r+"px,"+r+"px,"+r+"px,"+r+"px":"longdashdot"===e&&(e=5*r+"px,"+2*r+"px,"+r+"px,"+2*r+"px"),t.style({"stroke-dasharray":e,"stroke-width":n+"px"})},p.fillGroupStyle=function(t){t.style("stroke-width",0).each(function(e){var n=a.select(this);try{n.call(l.fill,e[0].trace.fillcolor)}catch(r){c.error(r,t),n.remove()}})};var g=t("./symbol_defs");p.symbolNames=[],p.symbolFuncs=[],p.symbolNeedLines={},p.symbolNoDot={},p.symbolList=[],Object.keys(g).forEach(function(t){var e=g[t];p.symbolList=p.symbolList.concat([e.n,t,e.n+100,t+"-open"]),p.symbolNames[e.n]=t,p.symbolFuncs[e.n]=e.f,e.needLine&&(p.symbolNeedLines[e.n]=!0),e.noDot?p.symbolNoDot[e.n]=!0:p.symbolList=p.symbolList.concat([e.n+200,t+"-dot",e.n+300,t+"-open-dot"])});var v=p.symbolNames.length,m="M0,0.5L0.5,0L0,-0.5L-0.5,0Z";p.symbolNumber=function(t){if("string"==typeof t){var e=0;t.indexOf("-open")>0&&(e=100,t=t.replace("-open","")),t.indexOf("-dot")>0&&(e+=200,t=t.replace("-dot","")),t=p.symbolNames.indexOf(t),t>=0&&(t+=e)}return t%100>=v||t>=400?0:Math.floor(Math.max(t,0))},p.pointStyle=function(t,e){if(t.size()){var n=e.marker,r=n.line;if(i.traceIs(e,"symbols")){var o=h(e);t.attr("d",function(t){var r;r="various"===t.ms||"various"===n.size?3:d.isBubble(e)?o(t.ms):(n.size||6)/2,t.mrc=r;var a=p.symbolNumber(t.mx||n.symbol)||0,i=a%100;return t.om=a%200>=100,p.symbolFuncs[i](r)+(a>=200?m:"")}).style("opacity",function(t){return(t.mo+1||n.opacity+1)-1})}var s=(e._input||{}).marker||{},c=p.tryColorscale(n,s,""),u=p.tryColorscale(n,s,"line.");t.each(function(t){var e,o,i;t.so?(i=r.outlierwidth,o=r.outliercolor,e=n.outliercolor):(i=(t.mlw+1||r.width+1||(t.trace?t.trace.marker.line.width:0)+1)-1,o="mlc"in t?t.mlcc=u(t.mlc):Array.isArray(r.color)?l.defaultLine:r.color,e="mc"in t?t.mcc=c(t.mc):Array.isArray(n.color)?l.defaultLine:n.color||"rgba(0,0,0,0)");var s=a.select(this);t.om?s.call(l.stroke,e).style({"stroke-width":(i||1)+"px",fill:"none"}):(s.style("stroke-width",i+"px").call(l.fill,e),i&&s.call(l.stroke,o))})}},p.tryColorscale=function(t,e,n){var r=c.nestedProperty(t,n+"color").get(),a=c.nestedProperty(t,n+"colorscale").get(),i=c.nestedProperty(t,n+"cauto").get(),l=c.nestedProperty(t,n+"cmin"),u=c.nestedProperty(t,n+"cmax"),f=l.get(),d=u.get();return a&&Array.isArray(r)?(!i&&o(f)&&o(d)||(f=1/0,d=-(1/0),r.forEach(function(t){o(t)&&(f>t&&(f=+t),t>d&&(d=+t))}),f>d&&(f=0,d=1),l.set(f),u.set(d),c.nestedProperty(e,n+"cmin").set(f),c.nestedProperty(e,n+"cmax").set(d)),s.makeScaleFunction(a,f,d)):c.identity};var y={start:1,end:-1,middle:0,bottom:1,top:-1},x=1.3;p.textPointStyle=function(t,e){t.each(function(t){var n=a.select(this),r=t.tx||e.text;if(!r||Array.isArray(r))return void n.remove();var i=t.tp||e.textposition,l=-1!==i.indexOf("top")?"top":-1!==i.indexOf("bottom")?"bottom":"middle",s=-1!==i.indexOf("left")?"end":-1!==i.indexOf("right")?"start":"middle",c=t.ts||e.textfont.size,f=t.mrc?t.mrc/.8+1:0;c=o(c)&&c>0?c:0,n.call(p.font,t.tf||e.textfont.family,c,t.tc||e.textfont.color).attr("text-anchor",s).text(r).call(u.convertToTspans);var d=a.select(this.parentNode),h=n.selectAll("tspan.line"),g=((h[0].length||1)-1)*x+1,v=y[s]*f,m=.75*c+y[l]*f+(y[l]-1)*g*c/2;d.attr("transform","translate("+v+","+m+")"),g>1&&h.attr({x:n.attr("x"),y:n.attr("y")})})};var b=.5;p.smoothopen=function(t,e){if(t.length<3)return"M"+t.join("L");var n,a="M"+t[0],o=[];for(n=1;nn;n++)i.push(r(t[n-1],t[n],t[n+1],e));for(i.push(r(t[o-1],t[o],t[0],e)),n=1;o>=n;n++)a+="C"+i[n-1][1]+" "+i[n][0]+" "+t[n];return a+="C"+i[o][1]+" "+i[0][0]+" "+t[0]+"Z"};var _={hv:function(t,e){return"H"+a.round(e[0],2)+"V"+a.round(e[1],2)},vh:function(t,e){return"V"+a.round(e[1],2)+"H"+a.round(e[0],2)},hvh:function(t,e){return"H"+a.round((t[0]+e[0])/2,2)+"V"+a.round(e[1],2)+"H"+a.round(e[0],2)},vhv:function(t,e){return"V"+a.round((t[1]+e[1])/2,2)+"H"+a.round(e[0],2)+"V"+a.round(e[1],2)}},w=function(t,e){return"L"+a.round(e[0],2)+","+a.round(e[1],2)};p.steps=function(t){var e=_[t]||w;return function(t){for(var n="M"+a.round(t[0][0],2)+","+a.round(t[0][1],2),r=1;r=M&&(a.selectAll("[data-bb]").attr("data-bb",null),k=[]),t.setAttribute("data-bb",k.length),k.push(s),c.extendFlat({},s)},p.setClipUrl=function(t,e){if(!e)return void t.attr("clip-path",null);var n="#"+e,r=a.select("base");r.size()&&r.attr("href")&&(n=window.location.href+n),t.attr("clip-path","url("+n+")")}},{"../../constants/xmlns_namespaces":87,"../../lib":94,"../../lib/svg_text_utils":105,"../../plots/plots":135,"../../traces/scatter/make_bubble_size_func":186,"../../traces/scatter/subtypes":191,"../color":18,"../colorscale":32,"./symbol_defs":42,d3:9,"fast-isnumeric":11}],42:[function(t,e,n){"use strict";var r=t("d3");e.exports={circle:{n:0,f:function(t){var e=r.round(t,2);return"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"}},square:{n:1,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"}},diamond:{n:2,f:function(t){var e=r.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"Z"}},cross:{n:3,f:function(t){var e=r.round(.4*t,2),n=r.round(1.2*t,2);return"M"+n+","+e+"H"+e+"V"+n+"H-"+e+"V"+e+"H-"+n+"V-"+e+"H-"+e+"V-"+n+"H"+e+"V-"+e+"H"+n+"Z"}},x:{n:4,f:function(t){var e=r.round(.8*t/Math.sqrt(2),2),n="l"+e+","+e,a="l"+e+",-"+e,o="l-"+e+",-"+e,i="l-"+e+","+e;return"M0,"+e+n+a+o+a+o+i+o+i+n+i+n+"Z"}},"triangle-up":{n:5,f:function(t){var e=r.round(2*t/Math.sqrt(3),2),n=r.round(t/2,2),a=r.round(t,2);return"M-"+e+","+n+"H"+e+"L0,-"+a+"Z"}},"triangle-down":{n:6,f:function(t){var e=r.round(2*t/Math.sqrt(3),2),n=r.round(t/2,2),a=r.round(t,2);return"M-"+e+",-"+n+"H"+e+"L0,"+a+"Z"}},"triangle-left":{n:7,f:function(t){var e=r.round(2*t/Math.sqrt(3),2),n=r.round(t/2,2),a=r.round(t,2);return"M"+n+",-"+e+"V"+e+"L-"+a+",0Z"}},"triangle-right":{n:8,f:function(t){var e=r.round(2*t/Math.sqrt(3),2),n=r.round(t/2,2),a=r.round(t,2);return"M-"+n+",-"+e+"V"+e+"L"+a+",0Z"}},"triangle-ne":{n:9,f:function(t){var e=r.round(.6*t,2),n=r.round(1.2*t,2);return"M-"+n+",-"+e+"H"+e+"V"+n+"Z"}},"triangle-se":{n:10,f:function(t){var e=r.round(.6*t,2),n=r.round(1.2*t,2);return"M"+e+",-"+n+"V"+e+"H-"+n+"Z"}},"triangle-sw":{n:11,f:function(t){var e=r.round(.6*t,2),n=r.round(1.2*t,2);return"M"+n+","+e+"H-"+e+"V-"+n+"Z"}},"triangle-nw":{n:12,f:function(t){var e=r.round(.6*t,2),n=r.round(1.2*t,2);return"M-"+e+","+n+"V-"+e+"H"+n+"Z"}},pentagon:{n:13,f:function(t){var e=r.round(.951*t,2),n=r.round(.588*t,2),a=r.round(-t,2),o=r.round(t*-.309,2),i=r.round(.809*t,2);return"M"+e+","+o+"L"+n+","+i+"H-"+n+"L-"+e+","+o+"L0,"+a+"Z"}},hexagon:{n:14,f:function(t){var e=r.round(t,2),n=r.round(t/2,2),a=r.round(t*Math.sqrt(3)/2,2);return"M"+a+",-"+n+"V"+n+"L0,"+e+"L-"+a+","+n+"V-"+n+"L0,-"+e+"Z"}},hexagon2:{n:15,f:function(t){var e=r.round(t,2),n=r.round(t/2,2),a=r.round(t*Math.sqrt(3)/2,2);return"M-"+n+","+a+"H"+n+"L"+e+",0L"+n+",-"+a+"H-"+n+"L-"+e+",0Z"}},octagon:{n:16,f:function(t){var e=r.round(.924*t,2),n=r.round(.383*t,2);return"M-"+n+",-"+e+"H"+n+"L"+e+",-"+n+"V"+n+"L"+n+","+e+"H-"+n+"L-"+e+","+n+"V-"+n+"Z"}},star:{n:17,f:function(t){var e=1.4*t,n=r.round(.225*e,2),a=r.round(.951*e,2),o=r.round(.363*e,2),i=r.round(.588*e,2),l=r.round(-e,2),s=r.round(e*-.309,2),c=r.round(.118*e,2),u=r.round(.809*e,2),f=r.round(.382*e,2);return"M"+n+","+s+"H"+a+"L"+o+","+c+"L"+i+","+u+"L0,"+f+"L-"+i+","+u+"L-"+o+","+c+"L-"+a+","+s+"H-"+n+"L0,"+l+"Z"}},hexagram:{n:18,f:function(t){var e=r.round(.66*t,2),n=r.round(.38*t,2),a=r.round(.76*t,2);return"M-"+a+",0l-"+n+",-"+e+"h"+a+"l"+n+",-"+e+"l"+n+","+e+"h"+a+"l-"+n+","+e+"l"+n+","+e+"h-"+a+"l-"+n+","+e+"l-"+n+",-"+e+"h-"+a+"Z"}},"star-triangle-up":{n:19,f:function(t){var e=r.round(t*Math.sqrt(3)*.8,2),n=r.round(.8*t,2),a=r.round(1.6*t,2),o=r.round(4*t,2),i="A "+o+","+o+" 0 0 1 ";return"M-"+e+","+n+i+e+","+n+i+"0,-"+a+i+"-"+e+","+n+"Z"}},"star-triangle-down":{n:20,f:function(t){var e=r.round(t*Math.sqrt(3)*.8,2),n=r.round(.8*t,2),a=r.round(1.6*t,2),o=r.round(4*t,2),i="A "+o+","+o+" 0 0 1 ";return"M"+e+",-"+n+i+"-"+e+",-"+n+i+"0,"+a+i+e+",-"+n+"Z"}},"star-square":{n:21,f:function(t){var e=r.round(1.1*t,2),n=r.round(2*t,2),a="A "+n+","+n+" 0 0 1 ";return"M-"+e+",-"+e+a+"-"+e+","+e+a+e+","+e+a+e+",-"+e+a+"-"+e+",-"+e+"Z"}},"star-diamond":{n:22,f:function(t){var e=r.round(1.4*t,2),n=r.round(1.9*t,2),a="A "+n+","+n+" 0 0 1 ";return"M-"+e+",0"+a+"0,"+e+a+e+",0"+a+"0,-"+e+a+"-"+e+",0Z"}},"diamond-tall":{n:23,f:function(t){var e=r.round(.7*t,2),n=r.round(1.4*t,2);return"M0,"+n+"L"+e+",0L0,-"+n+"L-"+e+",0Z"}},"diamond-wide":{n:24,f:function(t){var e=r.round(1.4*t,2),n=r.round(.7*t,2);return"M0,"+n+"L"+e+",0L0,-"+n+"L-"+e+",0Z"}},hourglass:{n:25,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"H-"+e+"L"+e+",-"+e+"H-"+e+"Z"},noDot:!0},bowtie:{n:26,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"V-"+e+"L-"+e+","+e+"V-"+e+"Z"},noDot:!0},"circle-cross":{n:27,f:function(t){var e=r.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"circle-x":{n:28,f:function(t){var e=r.round(t,2),n=r.round(t/Math.sqrt(2),2);return"M"+n+","+n+"L-"+n+",-"+n+"M"+n+",-"+n+"L-"+n+","+n+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"square-cross":{n:29,f:function(t){var e=r.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"square-x":{n:30,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"diamond-cross":{n:31,f:function(t){var e=r.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM0,-"+e+"V"+e+"M-"+e+",0H"+e},needLine:!0,noDot:!0},"diamond-x":{n:32,f:function(t){var e=r.round(1.3*t,2),n=r.round(.65*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM-"+n+",-"+n+"L"+n+","+n+"M-"+n+","+n+"L"+n+",-"+n},needLine:!0,noDot:!0},"cross-thin":{n:33,f:function(t){var e=r.round(1.4*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e},needLine:!0,noDot:!0},"x-thin":{n:34,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0},asterisk:{n:35,f:function(t){var e=r.round(1.2*t,2),n=r.round(.85*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+n+","+n+"L-"+n+",-"+n+"M"+n+",-"+n+"L-"+n+","+n},needLine:!0,noDot:!0},hash:{n:36,f:function(t){var e=r.round(t/2,2),n=r.round(t,2);return"M"+e+","+n+"V-"+n+"m-"+n+",0V"+n+"M"+n+","+e+"H-"+n+"m0,-"+n+"H"+n},needLine:!0},"y-up":{n:37,f:function(t){var e=r.round(1.2*t,2),n=r.round(1.6*t,2),a=r.round(.8*t,2);return"M-"+e+","+a+"L0,0M"+e+","+a+"L0,0M0,-"+n+"L0,0"},needLine:!0,noDot:!0},"y-down":{n:38,f:function(t){var e=r.round(1.2*t,2),n=r.round(1.6*t,2),a=r.round(.8*t,2);return"M-"+e+",-"+a+"L0,0M"+e+",-"+a+"L0,0M0,"+n+"L0,0"},needLine:!0,noDot:!0},"y-left":{n:39,f:function(t){var e=r.round(1.2*t,2),n=r.round(1.6*t,2),a=r.round(.8*t,2);return"M"+a+","+e+"L0,0M"+a+",-"+e+"L0,0M-"+n+",0L0,0"},needLine:!0,noDot:!0},"y-right":{n:40,f:function(t){var e=r.round(1.2*t,2),n=r.round(1.6*t,2),a=r.round(.8*t,2);return"M-"+a+","+e+"L0,0M-"+a+",-"+e+"L0,0M"+n+",0L0,0"},needLine:!0,noDot:!0},"line-ew":{n:41,f:function(t){var e=r.round(1.4*t,2);return"M"+e+",0H-"+e},needLine:!0,noDot:!0},"line-ns":{n:42,f:function(t){var e=r.round(1.4*t,2);return"M0,"+e+"V-"+e},needLine:!0,noDot:!0},"line-ne":{n:43,f:function(t){var e=r.round(t,2);return"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0},"line-nw":{n:44,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e},needLine:!0,noDot:!0}}},{d3:9}],43:[function(t,e,n){"use strict";e.exports={visible:{valType:"boolean"},type:{valType:"enumerated",values:["percent","constant","sqrt","data"]},symmetric:{valType:"boolean"},array:{valType:"data_array"},arrayminus:{valType:"data_array"},value:{valType:"number",min:0,dflt:10},valueminus:{valType:"number",min:0,dflt:10},traceref:{valType:"integer",min:0,dflt:0},tracerefminus:{valType:"integer",min:0,dflt:0},copy_ystyle:{valType:"boolean"},copy_zstyle:{valType:"boolean"},color:{valType:"color"},thickness:{valType:"number",min:0,dflt:2},width:{valType:"number",min:0},_deprecated:{opacity:{valType:"number"}}}},{}],44:[function(t,e,n){"use strict";function r(t,e,n,r){var o=e["error_"+r]||{},s=o.visible&&-1!==["linear","log"].indexOf(n.type),c=[];if(s){for(var u=l(o),f=0;fl;l++)i[l]={x:n[l],y:a[l]};return i[0].trace=t,r.calc({calcdata:[i],_fullLayout:e}),i},r.plot=t("./plot"),r.style=t("./style"),r.hoverInfo=function(t,e,n){(e.error_y||{}).visible&&(n.yerr=t.yh-t.y,e.error_y.symmetric||(n.yerrneg=t.y-t.ys)),(e.error_x||{}).visible&&(n.xerr=t.xh-t.x,e.error_x.symmetric||(n.xerrneg=t.x-t.xs))}},{"./attributes":43,"./calc":44,"./defaults":46,"./plot":48,"./style":49}],48:[function(t,e,n){"use strict";function r(t,e,n){var r={x:e.c2p(t.x),y:n.c2p(t.y)};return void 0!==t.yh&&(r.yh=n.c2p(t.yh),r.ys=n.c2p(t.ys),o(r.ys)||(r.noYS=!0,r.ys=n.c2p(t.ys,!0))),void 0!==t.xh&&(r.xh=e.c2p(t.xh),r.xs=e.c2p(t.xs),o(r.xs)||(r.noXS=!0,r.xs=e.c2p(t.xs,!0))),r}var a=t("d3"),o=t("fast-isnumeric"),i=t("../../lib"),l=t("../../traces/scatter/subtypes");e.exports=function(t,e){var n=e.x(),s=e.y();t.each(function(t){var e=t[0].trace,c=e.error_x||{},u=e.error_y||{},f=l.hasMarkers(e)&&e.marker.maxdisplayed>0;if(u.visible||c.visible){var d=a.select(this).selectAll("g.errorbar").data(i.identity);d.enter().append("g").classed("errorbar",!0),d.each(function(t){var e=a.select(this),i=r(t,n,s);if(!f||t.vis){var l;if(u.visible&&o(i.x)&&o(i.yh)&&o(i.ys)){var d=u.width;l="M"+(i.x-d)+","+i.yh+"h"+2*d+"m-"+d+",0V"+i.ys,i.noYS||(l+="m-"+d+",0h"+2*d),e.append("path").classed("yerror",!0).attr("d",l)}if(c.visible&&o(i.y)&&o(i.xh)&&o(i.xs)){var h=(c.copy_ystyle?u:c).width;l="M"+i.xh+","+(i.y-h)+"v"+2*h+"m0,-"+h+"H"+i.xs,i.noXS||(l+="m0,-"+h+"v"+2*h),e.append("path").classed("xerror",!0).attr("d",l)}}})}})}},{"../../lib":94,"../../traces/scatter/subtypes":191,d3:9,"fast-isnumeric":11}],49:[function(t,e,n){"use strict";var r=t("d3"),a=t("../color");e.exports=function(t){t.each(function(t){var e=t[0].trace,n=e.error_y||{},o=e.error_x||{},i=r.select(this);i.selectAll("path.yerror").style("stroke-width",n.thickness+"px").call(a.stroke,n.color),o.copy_ystyle&&(o=n),i.selectAll("path.xerror").style("stroke-width",o.thickness+"px").call(a.stroke,o.color)})}},{"../color":18,d3:9}],50:[function(t,e,n){"use strict";var r=t("../../plots/cartesian/constants");e.exports={_isLinkedToArray:!0,source:{valType:"string"},layer:{valType:"enumerated",values:["below","above"],dflt:"above"},sizex:{valType:"number",dflt:0},sizey:{valType:"number",dflt:0},sizing:{valType:"enumerated",values:["fill","contain","stretch"],dflt:"contain"},opacity:{valType:"number",min:0,max:1,dflt:1},x:{valType:"number",dflt:0},y:{valType:"number",dflt:0},xanchor:{valType:"enumerated",values:["left","center","right"],dflt:"left"},yanchor:{valType:"enumerated",values:["top","middle","bottom"],dflt:"top"},xref:{valType:"enumerated",values:["paper",r.idRegex.x.toString()],dflt:"paper"},yref:{valType:"enumerated",values:["paper",r.idRegex.y.toString()],dflt:"paper"}}},{"../../plots/cartesian/constants":120}],51:[function(t,e,n){"use strict";function r(t,e,n){function r(n,r){return o.coerce(t,e,i,n,r)}e=e||{},r("source"),r("layer"),r("x"),r("y"),r("xanchor"),r("yanchor"),r("sizex"),r("sizey"),r("sizing"),r("opacity");for(var l=0;2>l;l++){var s={_fullLayout:n},c=["x","y"][l];a.coerceRef(t,e,s,c,"paper")}return e}var a=t("../../plots/cartesian/axes"),o=t("../../lib"),i=t("./attributes");e.exports=function(t,e){if(t.images&&Array.isArray(t.images))for(var n=t.images,a=e.images=[],o=0;o=2/3},n.isCenterAnchor=function(t){return"center"===t.xanchor||"auto"===t.xanchor&&t.x>1/3&&t.x<2/3},n.isBottomAnchor=function(t){return"bottom"===t.yanchor||"auto"===t.yanchor&&t.y<=1/3},n.isMiddleAnchor=function(t){return"middle"===t.yanchor||"auto"===t.yanchor&&t.y>1/3&&t.y<2/3}},{}],55:[function(t,e,n){"use strict";var r=t("../../plots/font_attributes"),a=t("../color/attributes"),o=t("../../lib/extend").extendFlat;e.exports={bgcolor:{valType:"color"},bordercolor:{valType:"color",dflt:a.defaultLine},borderwidth:{valType:"number",min:0,dflt:0},font:o({},r,{}),orientation:{valType:"enumerated",values:["v","h"],dflt:"v"},traceorder:{valType:"flaglist",flags:["reversed","grouped"],extras:["normal"]},tracegroupgap:{valType:"number",min:0,dflt:10},x:{valType:"number",min:-2,max:3,dflt:1.02},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"left"},y:{valType:"number",min:-2,max:3,dflt:1},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto"}}},{"../../lib/extend":93,"../../plots/font_attributes":133,"../color/attributes":17}],56:[function(t,e,n){"use strict";e.exports={scrollBarWidth:4,scrollBarHeight:20,scrollBarColor:"#808BA4",scrollBarMargin:4}},{}],57:[function(t,e,n){"use strict";var r=t("../../lib"),a=t("../../plots/plots"),o=t("./attributes"),i=t("./helpers");e.exports=function(t,e,n){function l(t,e){return r.coerce(d,h,o,t,e)}for(var s,c,u,f,d=t.legend||{},h=e.legend={},p=0,g="normal",v=0;v1);if(y!==!1){if(l("bgcolor",e.paper_bgcolor),l("bordercolor"),l("borderwidth"),r.coerceFont(l,"font",e.font),l("orientation"),"h"===h.orientation){var x=t.xaxis;x&&x.rangeslider&&x.rangeslider.visible?(s=0,u="left",c=1.1,f="bottom"):(s=0,u="left",c=-.1,f="top")}l("traceorder",g),i.isGrouped(e.legend)&&l("tracegroupgap"),l("x",s),l("xanchor",u),l("y",c),l("yanchor",f),r.noneOrAll(d,h,["x","y"])}}},{"../../lib":94,"../../plots/plots":135,"./attributes":55,"./helpers":60}],58:[function(t,e,n){"use strict";function r(t,e){function n(n){u.util.convertToTspans(n,function(){n.selectAll("tspan.line").attr({x:n.attr("x")}),t.call(o,e)})}var r=t.data()[0][0],a=e._fullLayout,i=r.trace,l=d.traceIs(i,"pie"),s=i.index,c=l?r.label:i.name,f=t.selectAll("text.legendtext").data([0]);f.enter().append("text").classed("legendtext",!0),f.attr({x:40,y:0,"data-unformatted":c}).style("text-anchor","start").classed("user-select-none",!0).call(p.font,a.legend.font).text(c),e._context.editable&&!l?f.call(u.util.makeEditable).call(n).on("edit",function(t){this.attr({"data-unformatted":t}),this.text(t).call(n),this.text()||(t=" "),u.restyle(e,"name",t,s)}):f.call(n)}function a(t,e){var n=e._fullLayout.hiddenlabels?e._fullLayout.hiddenlabels.slice():[],r=t.selectAll("rect").data([0]);r.enter().append("rect").classed("legendtoggle",!0).style("cursor","pointer").attr("pointer-events","all").call(g.fill,"rgba(0,0,0,0)"),r.on("click",function(){if(!e._dragged){var r,a,o=t.data()[0][0],i=e._fullData,l=o.trace,s=l.legendgroup,c=[];if(d.traceIs(l,"pie")){var f=o.label,h=n.indexOf(f);-1===h?n.push(f):n.splice(h,1),u.relayout(e,"hiddenlabels",n)}else{if(""===s)c=[l.index];else for(var p=0;ptspan"),h=d[0].length||1;n=s*h,r=u.node()&&p.bBox(u.node()).width;var g=s*(.3+(1-h)/2);u.attr("y",g),d.attr("y",g)}n=Math.max(n,16)+3,o.attr({x:0,y:-n/2,height:n}),a.height=n,a.width=r}function i(t,e,n){var r=t._fullLayout,a=r.legend,o=a.borderwidth,i=x.isGrouped(a);if(x.isVertical(a))i&&e.each(function(t,e){f.setTranslate(this,0,e*a.tracegroupgap)}),a.width=0,a.height=0,n.each(function(t){var e=t[0],n=e.height,r=e.width;f.setTranslate(this,o,5+o+a.height+n/2),a.height+=n,a.width=Math.max(a.width,r)}),a.width+=45+2*o,a.height+=10+2*o,i&&(a.height+=(a._lgroupsLength-1)*a.tracegroupgap),n.selectAll(".legendtoggle").attr("width",(t._context.editable?0:a.width)+40),a.width=Math.ceil(a.width), +-a.height=Math.ceil(a.height);else if(i){a.width=0,a.height=0;for(var l=[a.width],s=e.data(),u=0,d=s.length;d>u;u++){var h=s[u].map(function(t){return t[0].width}),p=40+Math.max.apply(null,h);a.width+=a.tracegroupgap+p,l.push(a.width)}e.each(function(t,e){f.setTranslate(this,l[e],0)}),e.each(function(){var t=c.select(this),e=t.selectAll("g.traces"),n=0;e.each(function(t){var e=t[0],r=e.height;f.setTranslate(this,0,5+o+n+r/2),n+=r}),a.height=Math.max(a.height,n)}),a.height+=10+2*o,a.width+=2*o,a.width=Math.ceil(a.width),a.height=Math.ceil(a.height),n.selectAll(".legendtoggle").attr("width",t._context.editable?0:a.width)}else{a.width=0,a.height=0;var g=0,v=0,m=0,y=0;n.each(function(t){m=Math.max(40+t[0].width,m)}),n.each(function(t){var e=t[0],n=m,i=a.tracegroupgap||5;o+y+i+n>r.width-(r.margin.r+r.margin.l)&&(y=0,g+=v,a.height=a.height+v,v=0),f.setTranslate(this,o+y,5+o+e.height/2+g),a.width+=i+n,a.height=Math.max(a.height,e.height),y+=i+n,v=Math.max(e.height,v)}),a.width+=2*o,a.height+=10+2*o,a.width=Math.ceil(a.width),a.height=Math.ceil(a.height),n.selectAll(".legendtoggle").attr("width",t._context.editable?0:a.width)}}function l(t){var e=t._fullLayout,n=e.legend,r="left";b.isRightAnchor(n)?r="right":b.isCenterAnchor(n)&&(r="center");var a="top";b.isBottomAnchor(n)?a="bottom":b.isMiddleAnchor(n)&&(a="middle"),d.autoMargin(t,"legend",{x:n.x,y:n.y,l:n.width*({right:1,center:.5}[r]||0),r:n.width*({left:1,center:.5}[r]||0),b:n.height*({top:1,middle:.5}[a]||0),t:n.height*({bottom:1,middle:.5}[a]||0)})}function s(t){var e=t._fullLayout,n=e.legend,r="left";b.isRightAnchor(n)?r="right":b.isCenterAnchor(n)&&(r="center"),d.autoMargin(t,"legend",{x:n.x,y:.5,l:n.width*({right:1,center:.5}[r]||0),r:n.width*({left:1,center:.5}[r]||0),b:0,t:0})}var c=t("d3"),u=t("../../plotly"),f=t("../../lib"),d=t("../../plots/plots"),h=t("../dragelement"),p=t("../drawing"),g=t("../color"),v=t("./constants"),m=t("./get_legend_data"),y=t("./style"),x=t("./helpers"),b=t("./anchor_utils");e.exports=function(t){function e(t,e){T.attr("data-scroll",e).call(f.setTranslate,0,e),L.call(p.setRect,j,t,v.scrollBarWidth,v.scrollBarHeight),M.select("rect").attr({y:x.borderwidth-e})}var n=t._fullLayout,o="legend"+n._uid;if(n._infolayer&&t.calcdata){var x=n.legend,_=n.showlegend&&m(t.calcdata,x),w=n.hiddenlabels||[];if(!n.showlegend||!_.length)return n._infolayer.selectAll(".legend").remove(),n._topdefs.select("#"+o).remove(),void d.autoMargin(t,"legend");var k=n._infolayer.selectAll("g.legend").data([0]);k.enter().append("g").attr({"class":"legend","pointer-events":"all"});var M=n._topdefs.selectAll("#"+o).data([0]);M.enter().append("clipPath").attr("id",o).append("rect");var A=k.selectAll("rect.bg").data([0]);A.enter().append("rect").attr({"class":"bg","shape-rendering":"crispEdges"}),A.call(g.stroke,x.bordercolor),A.call(g.fill,x.bgcolor),A.style("stroke-width",x.borderwidth+"px");var T=k.selectAll("g.scrollbox").data([0]);T.enter().append("g").attr("class","scrollbox");var L=k.selectAll("rect.scrollbar").data([0]);L.enter().append("rect").attr({"class":"scrollbar",rx:20,ry:2,width:0,height:0}).call(g.fill,"#808BA4");var z=T.selectAll("g.groups").data(_);z.enter().append("g").attr("class","groups"),z.exit().remove();var S=z.selectAll("g.traces").data(f.identity);S.enter().append("g").attr("class","traces"),S.exit().remove(),S.call(y).style("opacity",function(t){var e=t[0].trace;return d.traceIs(e,"pie")?-1!==w.indexOf(t[0].label)?.5:1:"legendonly"===e.visible?.5:1}).each(function(){c.select(this).call(r,t).call(a,t)});var C=0!==k.enter().size();C&&(i(t,z,S),l(t));var E=0,O=n.width,P=0,N=n.height;i(t,z,S),x.height>N?s(t):l(t);var D=n._size,I=D.l+D.w*x.x,R=D.t+D.h*(1-x.y);b.isRightAnchor(x)?I-=x.width:b.isCenterAnchor(x)&&(I-=x.width/2),b.isBottomAnchor(x)?R-=x.height:b.isMiddleAnchor(x)&&(R-=x.height/2);var j=x.width,F=D.w;j>F?(I=D.l,j=F):(I+j>O&&(I=O-j),E>I&&(I=E),j=Math.min(O-I,x.width));var q=x.height,B=D.h;q>B?(R=D.t,q=B):(R+q>N&&(R=N-q),P>R&&(R=P),q=Math.min(N-R,x.height)),f.setTranslate(k,I,R);var H,V,Z=q-v.scrollBarHeight-2*v.scrollBarMargin,Y=x.height-q;if(x.height<=q||t._context.staticPlot)A.attr({width:j-x.borderwidth,height:q-x.borderwidth,x:x.borderwidth/2,y:x.borderwidth/2}),f.setTranslate(T,0,0),M.select("rect").attr({width:j-2*x.borderwidth,height:q-2*x.borderwidth,x:x.borderwidth,y:x.borderwidth}),T.call(p.setClipUrl,o);else{H=v.scrollBarMargin,V=T.attr("data-scroll")||0,A.attr({width:j-2*x.borderwidth+v.scrollBarWidth+v.scrollBarMargin,height:q-x.borderwidth,x:x.borderwidth/2,y:x.borderwidth/2}),M.select("rect").attr({width:j-2*x.borderwidth+v.scrollBarWidth+v.scrollBarMargin,height:q-2*x.borderwidth,x:x.borderwidth,y:x.borderwidth-V}),T.call(p.setClipUrl,o),C&&e(H,V),k.on("wheel",null),k.on("wheel",function(){V=f.constrain(T.attr("data-scroll")-c.event.deltaY/Z*Y,-Y,0),H=v.scrollBarMargin-V/Y*Z,e(H,V),c.event.preventDefault()}),L.on(".drag",null),T.on(".drag",null);var U=c.behavior.drag().on("drag",function(){H=f.constrain(c.event.y-v.scrollBarHeight/2,v.scrollBarMargin,v.scrollBarMargin+Z),V=-(H-v.scrollBarMargin)/Z*Y,e(H,V)});L.call(U),T.call(U)}if(t._context.editable){var X,G,$,Q;k.classed("cursor-move",!0),h.init({element:k.node(),prepFn:function(){var t=f.getTranslate(k);$=t.x,Q=t.y},moveFn:function(t,e){var n=$+t,r=Q+e;f.setTranslate(k,n,r),X=h.align(n,0,D.l,D.l+D.w,x.xanchor),G=h.align(r,0,D.t+D.h,D.t,x.yanchor)},doneFn:function(e){e&&void 0!==X&&void 0!==G&&u.relayout(t,{"legend.x":X,"legend.y":G})}})}}}},{"../../lib":94,"../../plotly":112,"../../plots/plots":135,"../color":18,"../dragelement":39,"../drawing":41,"./anchor_utils":54,"./constants":56,"./get_legend_data":59,"./helpers":60,"./style":62,d3:9}],59:[function(t,e,n){"use strict";var r=t("../../plots/plots"),a=t("./helpers");e.exports=function(t,e){function n(t,n){if(""!==t&&a.isGrouped(e))-1===s.indexOf(t)?(s.push(t),c=!0,l[t]=[[n]]):l[t].push([n]);else{var r="~~i"+f;s.push(r),l[r]=[[n]],f++}}var o,i,l={},s=[],c=!1,u={},f=0;for(o=0;oo;o++)m=l[s[o]],y[o]=a.isReversed(e)?m.reverse():m;else{for(y=[new Array(x)],o=0;x>o;o++)m=l[s[o]][0],y[0][a.isReversed(e)?x-o-1:o]=m;x=1}return e._lgroupsLength=x,y}},{"../../plots/plots":135,"./helpers":60}],60:[function(t,e,n){"use strict";var r=t("../../plots/plots");n.legendGetsTrace=function(t){return t.visible&&r.traceIs(t,"showLegend")},n.isGrouped=function(t){return-1!==(t.traceorder||"").indexOf("grouped")},n.isVertical=function(t){return"h"!==t.orientation},n.isReversed=function(t){return-1!==(t.traceorder||"").indexOf("reversed")}},{"../../plots/plots":135}],61:[function(t,e,n){"use strict";var r=e.exports={};r.layoutAttributes=t("./attributes"),r.supplyLayoutDefaults=t("./defaults"),r.draw=t("./draw"),r.style=t("./style")},{"./attributes":55,"./defaults":57,"./draw":58,"./style":62}],62:[function(t,e,n){"use strict";function r(t){var e=t[0].trace,n=e.visible&&e.fill&&"none"!==e.fill,r=h.hasLines(e),a=s.select(this).select(".legendfill").selectAll("path").data(n?[t]:[]);a.enter().append("path").classed("js-fill",!0),a.exit().remove(),a.attr("d","M5,0h30v6h-30z").call(f.fillGroupStyle);var o=s.select(this).select(".legendlines").selectAll("path").data(r?[t]:[]);o.enter().append("path").classed("js-line",!0).attr("d","M5,0h30"),o.exit().remove(),o.call(f.lineGroupStyle)}function a(t){function e(t,e,n){var r=c.nestedProperty(i,t).get(),a=Array.isArray(r)&&e?e(r):r;if(n){if(an[1])return n[1]}return a}function n(t){return t[0]}var r,a,o=t[0],i=o.trace,l=h.hasMarkers(i),u=h.hasText(i),d=h.hasLines(i);if(l||u||d){var p={},g={};l&&(p.mc=e("marker.color",n),p.mo=e("marker.opacity",c.mean,[.2,1]),p.ms=e("marker.size",c.mean,[2,16]),p.mlc=e("marker.line.color",n),p.mlw=e("marker.line.width",c.mean,[0,5]),g.marker={sizeref:1,sizemin:1,sizemode:"diameter"}),d&&(g.line={width:e("line.width",n,[0,10])}),u&&(p.tx="Aa",p.tp=e("textposition",n),p.ts=10,p.tc=e("textfont.color",n),p.tf=e("textfont.family",n)),r=[c.minExtend(o,p)],a=c.minExtend(i,g)}var v=s.select(this).select("g.legendpoints"),m=v.selectAll("path.scatterpts").data(l?r:[]);m.enter().append("path").classed("scatterpts",!0).attr("transform","translate(20,0)"),m.exit().remove(),m.call(f.pointStyle,a),l&&(r[0].mrc=3);var y=v.selectAll("g.pointtext").data(u?r:[]);y.enter().append("g").classed("pointtext",!0).append("text").attr("transform","translate(20,0)"),y.exit().remove(),y.selectAll("text").call(f.textPointStyle,a)}function o(t){var e=t[0].trace,n=e.marker||{},r=n.line||{},a=s.select(this).select("g.legendpoints").selectAll("path.legendbar").data(u.traceIs(e,"bar")?[t]:[]);a.enter().append("path").classed("legendbar",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),a.exit().remove(),a.each(function(t){var e=(t.mlw+1||r.width+1)-1,a=s.select(this);a.style("stroke-width",e+"px").call(d.fill,t.mc||n.color),e&&a.call(d.stroke,t.mlc||r.color)})}function i(t){var e=t[0].trace,n=s.select(this).select("g.legendpoints").selectAll("path.legendbox").data(u.traceIs(e,"box")&&e.visible?[t]:[]);n.enter().append("path").classed("legendbox",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),n.exit().remove(),n.each(function(t){var n=(t.lw+1||e.line.width+1)-1,r=s.select(this);r.style("stroke-width",n+"px").call(d.fill,t.fc||e.fillcolor),n&&r.call(d.stroke,t.lc||e.line.color)})}function l(t){var e=t[0].trace,n=s.select(this).select("g.legendpoints").selectAll("path.legendpie").data(u.traceIs(e,"pie")&&e.visible?[t]:[]);n.enter().append("path").classed("legendpie",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),n.exit().remove(),n.size()&&n.call(p,t[0],e)}var s=t("d3"),c=t("../../lib"),u=t("../../plots/plots"),f=t("../drawing"),d=t("../color"),h=t("../../traces/scatter/subtypes"),p=t("../../traces/pie/style_one");e.exports=function(t){t.each(function(t){var e=s.select(this),n=e.selectAll("g.legendfill").data([t]);n.enter().append("g").classed("legendfill",!0);var r=e.selectAll("g.legendlines").data([t]);r.enter().append("g").classed("legendlines",!0);var a=e.selectAll("g.legendsymbols").data([t]);a.enter().append("g").classed("legendsymbols",!0),a.style("opacity",t[0].trace.opacity),a.selectAll("g.legendpoints").data([t]).enter().append("g").classed("legendpoints",!0)}).each(o).each(i).each(l).each(r).each(a)}},{"../../lib":94,"../../plots/plots":135,"../../traces/pie/style_one":170,"../../traces/scatter/subtypes":191,"../color":18,"../drawing":41,d3:9}],63:[function(t,e,n){"use strict";function r(t,e){var n=e.currentTarget,r=n.getAttribute("data-attr"),a=n.getAttribute("data-val")||!0,o=t._fullLayout,i={};if("zoom"===r){for(var l,s,u="in"===a?.5:2,f=(1+u)/2,d=(1-u)/2,h=c.Axes.list(t,null,!0),p=0;py;y++){var x=l[y];d=m[x]={};for(var b=0;b1)return r(["resetViews","toggleHover"]),i(v,n);u&&(r(["zoom3d","pan3d","orbitRotation","tableRotation"]),r(["resetCameraDefault3d","resetCameraLastSave3d"]),r(["hoverClosest3d"])),d&&(r(["zoomInGeo","zoomOutGeo","resetGeo"]),r(["hoverClosestGeo"]));var m=a(l),y=[];return((c||p)&&!m||g)&&(y=["zoom2d","pan2d"]),(c||g)&&o(s)&&(y.push("select2d"),y.push("lasso2d")),y.length&&r(y),!c&&!p||m||g||r(["zoomIn2d","zoomOut2d","autoScale2d","resetScale2d"]),c&&h?r(["toggleHover"]):p?r(["hoverClosestGl2d"]):c?r(["hoverClosestCartesian","hoverCompareCartesian"]):h&&r(["hoverClosestPie"]),i(v,n)}function a(t){for(var e=s.Axes.list({_fullLayout:t},null,!0),n=!0,r=0;r0);if(p){var g=a(e,n,s);u("x",g[0]),u("y",g[1]),o.noneOrAll(t,e,["x","y"]),u("xanchor"),u("yanchor"),o.coerceFont(u,"font",n.font);var v=u("bgcolor");u("activecolor",i.contrast(v,c.lightAmount,c.darkAmount)),u("bordercolor"),u("borderwidth")}}},{"../../lib":94,"../color":18,"./attributes":66,"./button_attributes":67,"./constants":68}],70:[function(t,e,n){"use strict";function r(t){for(var e=m.list(t,"x",!0),n=[],r=0;re){var n=e;e=t,t=n}l.setAttributes(w,{"data-min":t,"data-max":e}),l.setAttributes(P,{x:t,width:e-t}),l.setAttributes(A,{width:t}),l.setAttributes(T,{x:e,width:p-e}),l.setAttributes(L,{transform:"translate("+(t-v-1)+")"}),l.setAttributes(C,{transform:"translate("+e+")"})}var f=t._fullLayout,d=f._infolayer.selectAll("g.range-slider"),h=f.xaxis.rangeslider,p=f._size.w,g=(f.height-f.margin.b-f.margin.t)*h.thickness,v=2,m=Math.floor(h.borderwidth/2),y=f.margin.l,x=f.height-g-f.margin.b,b=0,_=p,w=document.createElementNS(i,"g");l.setAttributes(w,{"class":"range-slider","data-min":b,"data-max":_,"pointer-events":"all",transform:"translate("+y+","+x+")"});var k=document.createElementNS(i,"rect"),M=h.borderwidth%2===0?h.borderwidth:h.borderwidth-1;l.setAttributes(k,{fill:h.bgcolor,stroke:h.bordercolor,"stroke-width":h.borderwidth,height:g+M,width:p+M,transform:"translate(-"+m+", -"+m+")","shape-rendering":"crispEdges"});var A=document.createElementNS(i,"rect");l.setAttributes(A,{x:0,width:b,height:g,fill:"rgba(0,0,0,0.4)"});var T=document.createElementNS(i,"rect");l.setAttributes(T,{x:_,width:p-_,height:g,fill:"rgba(0,0,0,0.4)"});var L=document.createElementNS(i,"g"),z=document.createElementNS(i,"rect"),S=document.createElementNS(i,"rect");l.setAttributes(L,{transform:"translate("+(b-v-1)+")"}),l.setAttributes(z,{width:10,height:g,x:-6,fill:"transparent",cursor:"col-resize"}),l.setAttributes(S,{width:v,height:g/2,y:g/4,rx:1,fill:"white",stroke:"#666","shape-rendering":"crispEdges"}),l.appendChildren(L,[S,z]);var C=document.createElementNS(i,"g"),E=document.createElementNS(i,"rect"),O=document.createElementNS(i,"rect"); +-l.setAttributes(C,{transform:"translate("+_+")"}),l.setAttributes(E,{width:10,height:g,x:-2,fill:"transparent",cursor:"col-resize"}),l.setAttributes(O,{width:v,height:g/2,y:g/4,rx:1,fill:"white",stroke:"#666","shape-rendering":"crispEdges"}),l.appendChildren(C,[O,E]);var P=document.createElementNS(i,"rect");l.setAttributes(P,{x:b,width:_-b,height:g,cursor:"ew-resize",fill:"transparent"}),w.addEventListener("mousedown",function(t){function n(t){var n,r,f=+t.clientX-o;switch(a){case P:w.style.cursor="ew-resize",n=+l+f,r=+s+f,u(n,r),c(e(n),e(r));break;case z:w.style.cursor="col-resize",n=+l+f,r=+s,u(n,r),c(e(n),e(r));break;case E:w.style.cursor="col-resize",n=+l,r=+s+f,u(n,r),c(e(n),e(r));break;default:w.style.cursor="ew-resize",n=i,r=i+f,u(n,r),c(e(n),e(r))}}function r(){window.removeEventListener("mousemove",n),window.removeEventListener("mouseup",r),w.style.cursor="auto"}var a=t.target,o=t.clientX,i=o-w.getBoundingClientRect().left,l=w.getAttribute("data-min"),s=w.getAttribute("data-max");window.addEventListener("mousemove",n),window.addEventListener("mouseup",r)}),h.range||(h.range=a.getAutoRange(f.xaxis));var N=s(t,p,g);l.appendChildren(w,[k,N,A,T,P,L,C]),n(f.xaxis.range[0],f.xaxis.range[1]),d.data([0]).enter().append(function(){return h.setRange=n,w})}},{"../../constants/xmlns_namespaces":87,"../../lib":94,"../../plotly":112,"../../plots/cartesian/axes":115,"./helpers":76,"./range_plot":78}],75:[function(t,e,n){"use strict";var r=t("../../lib"),a=t("./attributes");e.exports=function(t,e,n,o){function i(t,e){return r.coerce(l,s,a,t,e)}if(t[n].rangeslider){var l=r.isPlainObject(t[n].rangeslider)?t[n].rangeslider:{},s=e[n].rangeslider={};if(i("bgcolor"),i("bordercolor"),i("borderwidth"),i("thickness"),i("visible"),i("range"),s.range&&!e[n].autorange){var c=s.range,u=e[n].range;c[0]=Math.min(c[0],u[0]),c[1]=Math.max(c[1],u[1])}else e[n]._needsExpand=!0;s.visible&&o.forEach(function(t){var n=e[t]||{};n.fixedrange=!0,e[t]=n})}}},{"../../lib":94,"./attributes":73}],76:[function(t,e,n){"use strict";n.setAttributes=function(t,e){for(var n in e)t.setAttribute(n,e[n])},n.appendChildren=function(t,e){for(var n=0;ns;s++){var c=l[s],u={_fullLayout:e},f=A.coerceRef(t,r,u,c);if("path"!==i){var d=.25,h=.75;if("paper"!==f){var p=A.getFromId(u,f),g=o(p);d=g(p.range[0]+d*(p.range[1]-p.range[0])),h=g(p.range[0]+h*(p.range[1]-p.range[0]))}n(c+"0",d),n(c+"1",h)}}return"path"===i?n("path"):M.noneOrAll(t,r,["x0","x1","y0","y1"]),r}function a(t){return"category"===t.type?t.c2l:t.d2l}function o(t){return"category"===t.type?t.l2c:t.l2d}function i(t,e){t.layout.shapes=e,C.supplyLayoutDefaults(t.layout,t._fullLayout),C.drawAll(t)}function l(t){delete t.layout.shapes,t._fullLayout.shapes=[],C.drawAll(t)}function s(t,e,n){for(var r=0;re;a--)h(t,a).selectAll('[data-index="'+(a-1)+'"]').attr("data-index",a),C.draw(t,a)}function f(t,e,n,i){function l(n){var r={"data-index":e,"fill-rule":"evenodd",d:x(t,C)},a=C.line.width?C.line.color:"rgba(0,0,0,0)",o=n.append("path").attr(r).style("opacity",C.opacity).call(T.stroke,a).call(T.fill,C.fillcolor).call(L.dashLine,C.line.dash,C.line.width);E&&o.call(L.setClipUrl,"clip"+t._fullLayout._uid+E),t._context.editable&&d(t,o,C,e)}var s,c;h(t,e).selectAll('[data-index="'+e+'"]').remove();var u=t.layout.shapes[e];if(u){var f={xref:u.xref,yref:u.yref},g={};"string"==typeof n&&n?g[n]=i:M.isPlainObject(n)&&(g=n);var v=Object.keys(g);for(s=0;ss;s++){var b=y[s];if(void 0===g[b]&&void 0!==u[b]){var _,w=b.charAt(0),k=A.getFromId(t,A.coerceRef(f,{},t,w)),z=A.getFromId(t,A.coerceRef(u,{},t,w)),S=u[b];void 0!==g[w+"ref"]&&(k?(_=a(k)(S),S=(_-k.range[0])/(k.range[1]-k.range[0])):S=(S-z.domain[0])/(z.domain[1]-z.domain[0]),z?(_=z.range[0]+S*(z.range[1]-z.range[0]),S=o(z)(_)):S=k.domain[0]+S*(k.domain[1]-k.domain[0])),u[b]=S}}var C=r(u,t._fullLayout);t._fullLayout.shapes[e]=C;var E;if("below"!==C.layer)E=(C.xref+C.yref).replace(/paper/g,""),l(t._fullLayout._shapeUpperLayer);else if("paper"===C.xref&&"paper"===C.yref)E="",l(t._fullLayout._shapeLowerLayer);else{var O,P=t._fullLayout._plots||{},N=Object.keys(P);for(s=0,c=N.length;c>s;s++)O=P[N[s]],E=N[s],p(t,C,O)&&l(O.shapelayer)}}}function d(t,e,n,r){function a(t){var n=W.right-W.left,r=W.bottom-W.top,a=t.clientX-W.left,o=t.clientY-W.top,i=n>G&&r>$&&!t.shiftKey?z.getCursor(a/n,1-o/r):"move";S(e,i),X=i.split("-")[0]}function o(e){B=A.getFromId(t,n.xref),H=A.getFromId(t,n.yref),V=m(t,B),Z=m(t,H,!0),Y=y(t,B),U=y(t,H,!0);var o="shapes["+r+"]";"path"===n.type?(F=n.path,q=o+".path"):(u=V(n.x0),f=Z(n.y0),d=V(n.x1),h=Z(n.y1),p=o+".x0",g=o+".y0",_=o+".x1",w=o+".y1"),d>u?(L=u,P=o+".x0",R="x0",C=d,N=o+".x1",j="x1"):(L=d,P=o+".x1",R="x1",C=u,N=o+".x0",j="x0"),h>f?(M=f,E=o+".y0",D="y0",T=h,O=o+".y1",I="y1"):(M=h,E=o+".y1",D="y1",T=f,O=o+".y0",I="y0"),c={},a(e),Q.moveFn="move"===X?l:s}function i(n){S(e),n&&k.relayout(t,c)}function l(r,a){if("path"===n.type){var o=function(t){return Y(V(t)+r)};B&&"date"===B.type&&(o=v(o));var i=function(t){return U(Z(t)+a)};H&&"date"===H.type&&(i=v(i)),n.path=b(F,o,i),c[q]=n.path}else c[p]=n.x0=Y(u+r),c[g]=n.y0=U(f+a),c[_]=n.x1=Y(d+r),c[w]=n.y1=U(h+a);e.attr("d",x(t,n))}function s(r,a){if("path"===n.type){var o=function(t){return Y(V(t)+r)};B&&"date"===B.type&&(o=v(o));var i=function(t){return U(Z(t)+a)};H&&"date"===H.type&&(i=v(i)),n.path=b(F,o,i),c[q]=n.path}else{var l=~X.indexOf("n")?M+a:M,s=~X.indexOf("s")?T+a:T,u=~X.indexOf("w")?L+r:L,f=~X.indexOf("e")?C+r:C;s-l>$&&(c[E]=n[D]=U(l),c[O]=n[I]=U(s)),f-u>G&&(c[P]=n[R]=Y(u),c[N]=n[j]=Y(f))}e.attr("d",x(t,n))}var c,u,f,d,h,p,g,_,w,M,T,L,C,E,O,P,N,D,I,R,j,F,q,B,H,V,Z,Y,U,X,G=10,$=10,Q={setCursor:a,element:e.node(),prepFn:o,doneFn:i},W=Q.element.getBoundingClientRect();z.init(Q)}function h(t,e){var n=t._fullLayout.shapes[e],r=t._fullLayout._shapeUpperLayer;return n?"below"===n.layer&&(r="paper"===n.xref&&"paper"===n.yref?t._fullLayout._shapeLowerLayer:t._fullLayout._shapeSubplotLayer):M.log("getShapeLayer: undefined shape: index",e),r}function p(t,e,n){var r=k.Axes.getFromId(t,n.id,"x")._id,a=k.Axes.getFromId(t,n.id,"y")._id,o="below"===e.layer,i=r===e.xref||a===e.yref,l=!!n.shapelayer;return o&&i&&l}function g(t){return function(e){return e.replace&&(e=e.replace("_"," ")),t(e)}}function v(t){return function(e){return t(e).replace(" ","_")}}function m(t,e,n){var r,o=t._fullLayout._size;if(e){var i=a(e);r=function(t){return e._offset+e.l2p(i(t,!0))},"date"===e.type&&(r=g(r))}else r=n?function(t){return o.t+o.h*(1-t)}:function(t){return o.l+o.w*t};return r}function y(t,e,n){var r,a=t._fullLayout._size;if(e){var i=o(e);r=function(t){return i(e.p2l(t-e._offset))}}else r=n?function(t){return 1-(t-a.t)/a.h}:function(t){return(t-a.l)/a.w};return r}function x(t,e){var n,r,o,i,l=e.type,s=A.getFromId(t,e.xref),c=A.getFromId(t,e.yref),u=t._fullLayout._size;if(s?(n=a(s),r=function(t){return s._offset+s.l2p(n(t,!0))}):r=function(t){return u.l+u.w*t},c?(o=a(c),i=function(t){return c._offset+c.l2p(o(t,!0))}):i=function(t){return u.t+u.h*(1-t)},"path"===l)return s&&"date"===s.type&&(r=g(r)),c&&"date"===c.type&&(i=g(i)),C.convertPath(e.path,r,i);var f=r(e.x0),d=r(e.x1),h=i(e.y0),p=i(e.y1);if("line"===l)return"M"+f+","+h+"L"+d+","+p;if("rect"===l)return"M"+f+","+h+"H"+d+"V"+p+"H"+f+"Z";var v=(f+d)/2,m=(h+p)/2,y=Math.abs(v-f),x=Math.abs(m-h),b="A"+y+","+x,_=v+y+","+m,w=v+","+(m-x);return"M"+_+b+" 0 1,1 "+w+b+" 0 0,1 "+_+"Z"}function b(t,e,n){return t.replace(E,function(t){var r=0,a=t.charAt(0),o=P[a],i=N[a],l=D[a],s=t.substr(1).replace(O,function(t){return r>=l?t:(o[r]?t=e(t):i[r]&&(t=n(t)),r++,t)});return a+s})}function _(t,e,n,r,a){var o="category"===t.type?Number:t.d2c;if(void 0!==e)return[o(e),o(n)];if(r){var i,l,s,c,u,f=1/0,d=-(1/0),h=r.match(E);for("date"===t.type&&(o=g(o)),i=0;iu&&(f=u),u>d&&(d=u)));return d>=f?[f,d]:void 0}}var w=t("fast-isnumeric"),k=t("../../plotly"),M=t("../../lib"),A=t("../../plots/cartesian/axes"),T=t("../color"),L=t("../drawing"),z=t("../dragelement"),S=t("../../lib/setcursor"),C=e.exports={};C.layoutAttributes=t("./attributes"),C.supplyLayoutDefaults=function(t,e){for(var n=t.shapes||[],a=e.shapes=[],o=0;ol&&(t="X"),t});return r>l&&(s=s.replace(/[\s,]*X.*/,""),M.log("Ignoring extra params in segment "+t)),a+s})},C.calcAutorange=function(t){var e,n,r,a,o,i=t._fullLayout,l=i.shapes;if(l.length&&t._fullData.length)for(e=0;ed?n=d:(u.left-=x.offsetLeft,u.right-=x.offsetLeft,u.top-=x.offsetTop,u.bottom-=x.offsetTop,x.selection.each(function(){var t=s.bBox(this);l.bBoxIntersect(u,t,c)&&(n=Math.max(n,i*(t[x.side]-u[o])+c))}),n=Math.min(d,n)),n>0||0>d){var h={left:[-n,0],right:[n,0],top:[0,-n],bottom:[0,n]}[x.side];e.attr("transform","translate("+h+")")}}}function p(){L=0,z=!0,S=E,k._infolayer.select("."+e).attr({"data-unformatted":S}).text(S).on("mouseover.opacity",function(){r.select(this).transition().duration(100).style("opacity",1)}).on("mouseout.opacity",function(){r.select(this).transition().duration(1e3).style("opacity",0)})}var g=n.propContainer,v=n.propName,m=n.traceIndex,y=n.dfltName,x=n.avoid||{},b=n.attributes,_=n.transform,w=n.containerGroup,k=t._fullLayout,M=g.titlefont.family,A=g.titlefont.size,T=g.titlefont.color,L=1,z=!1,S=g.title.trim();""===S&&(L=0),S.match(/Click to enter .+ title/)&&(L=.2,z=!0),w||(w=k._infolayer.selectAll(".g-"+e).data([0]),w.enter().append("g").classed("g-"+e,!0));var C=w.selectAll("text").data([0]);C.enter().append("text"),C.text(S).attr("class",e),C.attr({"data-unformatted":S}).call(f);var E="Click to enter "+y+" title";t._context.editable?(S||p(),C.call(u.makeEditable).on("edit",function(e){void 0!==m?o.restyle(t,v,e,m):o.relayout(t,v,e)}).on("cancel",function(){this.text(this.attr("data-unformatted")).call(f)}).on("input",function(t){this.text(t||" ").attr(b).selectAll("tspan.line").attr(b)})):S&&!S.match(/Click to enter .+ title/)||C.remove(),C.classed("js-placeholder",z)}},{"../../lib":94,"../../lib/svg_text_utils":105,"../../plotly":112,"../../plots/plots":135,"../color":18,"../drawing":41,d3:9,"fast-isnumeric":11}],82:[function(t,e,n){"use strict";var r=t("../../plots/font_attributes"),a=t("../color/attributes"),o=t("../../lib/extend").extendFlat,i={_isLinkedToArray:!0,method:{valType:"enumerated",values:["restyle","relayout"],dflt:"restyle"},args:{valType:"info_array",freeLength:!0,items:[{valType:"any"},{valType:"any"},{valType:"any"}]},label:{valType:"string",dflt:""}};e.exports={_isLinkedToArray:!0,visible:{valType:"boolean"},active:{valType:"integer",min:-1,dflt:0},buttons:i,x:{valType:"number",min:-2,max:3,dflt:-.05},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"right"},y:{valType:"number",min:-2,max:3,dflt:1},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"bottom"},font:o({},r,{}),bgcolor:{valType:"color"},bordercolor:{valType:"color",dflt:a.borderLine},borderwidth:{valType:"number",min:0,dflt:1}}},{"../../lib/extend":93,"../../plots/font_attributes":133,"../color/attributes":17}],83:[function(t,e,n){"use strict";e.exports={name:"updatemenus",itemName:"updatemenu",containerClassName:"updatemenu-container",headerGroupClassName:"updatemenu-header-group",headerClassName:"updatemenu-header",headerArrowClassName:"updatemenu-header-arrow",buttonGroupClassName:"updatemenu-button-group",buttonClassName:"updatemenu-button",itemRectClassName:"updatemenu-item-rect",itemTextClassName:"updatemenu-item-text",menuIndexAttrName:"updatemenu-active-index",autoMarginIdRoot:"updatemenu-",blankHeaderOpts:{label:" "},minWidth:30,minHeight:30,textPadX:40,fontSizeToHeight:1.3,rx:2,ry:2,textOffsetX:12,textOffsetY:3,arrowOffsetX:4,gapButtonHeader:5,gapButton:2,activeColor:"#F4FAFF",hoverColor:"#F4FAFF"}},{}],84:[function(t,e,n){"use strict";function r(t,e,n){function r(n,r){return o.coerce(t,e,i,n,r)}var l=a(t,e),s=r("visible",l.length>0);s&&(r("active"),r("x"),r("y"),o.noneOrAll(t,e,["x","y"]),r("xanchor"),r("yanchor"),o.coerceFont(r,"font",n.font),r("bgcolor",n.paper_bgcolor),r("bordercolor"),r("borderwidth"))}function a(t,e){function n(t,e){return o.coerce(r,a,c,t,e)}for(var r,a,i=t.buttons||[],l=e.buttons=[],s=0;s0?[0]:[]);if(s.enter().append("g").classed(T.containerClassName,!0).style("cursor","pointer"),s.exit().remove(),s.exit().size()&&m(t),0!==n.length){var c=s.selectAll("g."+T.headerGroupClassName).data(n,a);c.enter().append("g").classed(T.headerGroupClassName,!0);var u=s.selectAll("g."+T.buttonGroupClassName).data([0]);u.enter().append("g").classed(T.buttonGroupClassName,!0).style("pointer-events","all"),c.enter().size()&&u.call(v).attr(T.menuIndexAttrName,"-1"),c.exit().each(function(e){y.select(this).remove(),u.call(v).attr(T.menuIndexAttrName,"-1"),b.autoMargin(t,T.autoMarginIdRoot+e._index)});for(var f=0;fa.max?e.set(n):e.set(+t)}},integer:{coerceFunction:function(t,e,n,a){t%1||!r(t)||void 0!==a.min&&ta.max?e.set(n):e.set(+t)}},string:{coerceFunction:function(t,e,n,r){if("string"!=typeof t){var a="number"==typeof t;r.strict!==!0&&a?e.set(String(t)):e.set(n)}else r.noBlank&&!t?e.set(n):e.set(t)}},color:{coerceFunction:function(t,e,n){a(t).isValid()?e.set(t):e.set(n)}},colorscale:{coerceFunction:function(t,e,n){e.set(i(t,n))}},angle:{coerceFunction:function(t,e,n){"auto"===t?e.set("auto"):r(t)?(Math.abs(t)>180&&(t-=360*Math.round(t/360)),e.set(+t)):e.set(n)}},subplotid:{coerceFunction:function(t,e,n){var r=n.length;return"string"==typeof t&&t.substr(0,r)===n&&l.test(t.substr(r))?void e.set(t):void e.set(n)},validateFunction:function(t,e){var n=e.dflt,r=n.length;return t===n?!0:"string"!=typeof t?!1:!(t.substr(0,r)!==n||!l.test(t.substr(r)))}},flaglist:{coerceFunction:function(t,e,n,r){if("string"!=typeof t)return void e.set(n);if(-1!==(r.extras||[]).indexOf(t))return void e.set(t);for(var a=t.split("+"),o=0;o2)return!1;var s=i[0].split("-");if(s.length>3||3!==s.length&&i[1])return!1;if(4===s[0].length)n=Number(s[0]);else{if(2!==s[0].length)return!1;var c=(new Date).getFullYear();n=((Number(s[0])-c+70)%100+200)%100+c-70}return l(n)?1===s.length?new Date(n,0,1).getTime():(r=Number(s[1])-1,s[1].length>2||!(r>=0&&11>=r)?!1:2===s.length?new Date(n,r,1).getTime():(a=Number(s[2]),s[2].length>2||!(a>=1&&31>=a)?!1:(a=new Date(n,r,a).getTime(),i[1]?(s=i[1].split(":"),s.length>3?!1:(o=Number(s[0]),s[0].length>2||!(o>=0&&23>=o)?!1:(a+=36e5*o,1===s.length?a:(r=Number(s[1]),s[1].length>2||!(r>=0&&59>=r)?!1:(a+=6e4*r,2===s.length?a:(t=Number(s[2]),t>=0&&60>t?a+1e3*t:!1)))))):a))):!1},n.isDateTime=function(t){return n.dateTime2ms(t)!==!1},n.ms2DateTime=function(t,e){if("undefined"==typeof i)return void s.error("d3 is not defined.");e||(e=0);var n=new Date(t),a=i.time.format("%Y-%m-%d")(n);return 7776e6>e?(a+=" "+r(n.getHours(),2),432e6>e&&(a+=":"+r(n.getMinutes(),2),108e5>e&&(a+=":"+r(n.getSeconds(),2),3e5>e&&(a+="."+r(n.getMilliseconds(),3)))),a.replace(/([:\s]00)*\.?[0]*$/,"")):a};var c={H:["%H:%M:%S~%L","%H:%M:%S","%H:%M"],I:["%I:%M:%S~%L%p","%I:%M:%S%p","%I:%M%p"],D:["%H","%I%p","%Hh"]},u={Y:["%Y~%m~%d","%Y%m%d","%y%m%d","%m~%d~%Y","%d~%m~%Y"],Yb:["%b~%d~%Y","%d~%b~%Y","%Y~%d~%b","%Y~%b~%d"],y:["%m~%d~%y","%d~%m~%y","%y~%m~%d"],yb:["%b~%d~%y","%d~%b~%y","%y~%d~%b","%y~%b~%d"]},f=i.time.format.utc,d={Y:{H:["%Y~%m~%dT%H:%M:%S","%Y~%m~%dT%H:%M:%S~%L"].map(f),I:[],D:["%Y%m%d%H%M%S","%Y~%m","%m~%Y"].map(f)},Yb:{H:[],I:[],D:["%Y~%b","%b~%Y"].map(f)},y:{H:[],I:[],D:[]},yb:{H:[],I:[],D:[]}};["Y","Yb","y","yb"].forEach(function(t){u[t].forEach(function(e){d[t].D.push(f(e)),["H","I","D"].forEach(function(n){c[n].forEach(function(r){var a=d[t][n];a.push(f(e+"~"+r)), +-a.push(f(r+"~"+e))})})})});var h=/[a-z]*/g,p=function(t){return t.substr(0,3)},g=/(mon|tue|wed|thu|fri|sat|sun|the|of|st|nd|rd|th)/g,v=/[\s,\/\-\.\(\)]+/g,m=/~?([ap])~?m(~|$)/,y=function(t,e){return e+"m "},x=/\d\d\d\d/,b=/(^|~)[a-z]{3}/,_=/[ap]m/,w=/:/,k=/q([1-4])/,M=["31~mar","30~jun","30~sep","31~dec"],A=function(t,e){return M[e-1]},T=/ ?([+\-]\d\d:?\d\d|Z)$/;n.parseDate=function(t){if(t.getTime)return t;if("string"!=typeof t)return!1;t=t.toLowerCase().replace(h,p).replace(g,"").replace(v,"~").replace(m,y).replace(k,A).trim().replace(T,"");var e,n,r=null,i=a(t),l=o(t);e=d[i][l],n=e.length;for(var s=0;n>s&&!(r=e[s].parse(t));s++);if(!(r instanceof Date))return!1;var c=r.getTimezoneOffset();return r.setTime(r.getTime()+60*c*1e3),r}},{"../lib":94,d3:9,"fast-isnumeric":11}],92:[function(t,e,n){"use strict";var r=t("events").EventEmitter,a={init:function(t){if(t._ev instanceof r)return t;var e=new r;return t._ev=e,t.on=e.on.bind(e),t.once=e.once.bind(e),t.removeListener=e.removeListener.bind(e),t.removeAllListeners=e.removeAllListeners.bind(e),t.emit=function(n,r){"undefined"!=typeof jQuery&&jQuery(t).trigger(n,r),e.emit(n,r)},t},triggerHandler:function(t,e,n){var r,a;"undefined"!=typeof jQuery&&(r=jQuery(t).triggerHandler(e,n));var o=t._ev;if(!o)return r;var i=o._events[e];if(!i)return r;"function"==typeof i&&(i=[i]);for(var l=i.pop(),s=0;sm;m++){s=t[m];for(c in s)u=g[c],f=s[c],l&&i(f)?g[c]=f:e&&f&&(o(f)||(d=i(f)))?(d?(d=!1,h=u&&i(u)?u:[]):h=u&&o(u)?u:{},g[c]=a([h,f],e,n,l)):("undefined"!=typeof f||n)&&(g[c]=f)}return g}var o=t("./is_plain_object.js"),i=Array.isArray;n.extendFlat=function(){return a(arguments,!1,!1,!1)},n.extendDeep=function(){return a(arguments,!0,!1,!1)},n.extendDeepAll=function(){return a(arguments,!0,!0,!1)},n.extendDeepNoArrays=function(){return a(arguments,!0,!1,!0)}},{"./is_plain_object.js":95}],94:[function(t,e,n){"use strict";var r=t("d3"),a=e.exports={};a.nestedProperty=t("./nested_property"),a.isPlainObject=t("./is_plain_object");var o=t("./coerce");a.valObjects=o.valObjects,a.coerce=o.coerce,a.coerce2=o.coerce2,a.coerceFont=o.coerceFont,a.validate=o.validate;var i=t("./dates");a.dateTime2ms=i.dateTime2ms,a.isDateTime=i.isDateTime,a.ms2DateTime=i.ms2DateTime,a.parseDate=i.parseDate;var l=t("./search");a.findBin=l.findBin,a.sorterAsc=l.sorterAsc,a.sorterDes=l.sorterDes,a.distinctVals=l.distinctVals,a.roundUp=l.roundUp;var s=t("./stats");a.aggNums=s.aggNums,a.len=s.len,a.mean=s.mean,a.variance=s.variance,a.stdev=s.stdev,a.interp=s.interp;var c=t("./matrix");a.init2dArray=c.init2dArray,a.transposeRagged=c.transposeRagged,a.dot=c.dot,a.translationMatrix=c.translationMatrix,a.rotationMatrix=c.rotationMatrix,a.rotationXYMatrix=c.rotationXYMatrix,a.apply2DTransform=c.apply2DTransform,a.apply2DTransform2=c.apply2DTransform2;var u=t("./extend");a.extendFlat=u.extendFlat,a.extendDeep=u.extendDeep,a.extendDeepAll=u.extendDeepAll,a.extendDeepNoArrays=u.extendDeepNoArrays;var f=t("./loggers");a.log=f.log,a.warn=f.warn,a.error=f.error,a.notifier=t("./notifier"),a.swapAttrs=function(t,e,n,r){n||(n="x"),r||(r="y");for(var o=0;on?Math.max(n,Math.min(e,t)):Math.max(e,Math.min(n,t))},a.bBoxIntersect=function(t,e,n){return n=n||0,t.left<=e.right+n&&e.left<=t.right+n&&t.top<=e.bottom+n&&e.top<=t.bottom+n},a.identity=function(t){return t},a.randstr=function d(t,e,n){if(n||(n=16),void 0===e&&(e=24),0>=e)return"0";var r,a,o,i=Math.log(Math.pow(2,e))/Math.log(n),l="";for(r=2;i===1/0;r*=2)i=Math.log(Math.pow(2,e/r))/Math.log(n)*r;var s=i-Math.floor(i);for(r=0;r-1||c!==1/0&&c>=Math.pow(2,e)?d(t,e,n):l},a.OptionControl=function(t,e){t||(t={}),e||(e="opt");var n={};return n.optionList=[],n._newoption=function(r){r[e]=t,n[r.name]=r,n.optionList.push(r)},n["_"+e]=t,n},a.smooth=function(t,e){if(e=Math.round(e)||0,2>e)return t;var n,r,a,o,i=t.length,l=2*i,s=2*e-1,c=new Array(s),u=new Array(i);for(n=0;s>n;n++)c[n]=(1-Math.cos(Math.PI*(n+1)/e))/(2*e);for(n=0;i>n;n++){for(o=0,r=0;s>r;r++)a=n+r+1-e,-i>a?a-=l*Math.round(a/l):a>=l&&(a-=l*Math.floor(a/l)),0>a?a=-1-a:a>=i&&(a=l-1-a),o+=t[a]*c[r];u[n]=o}return u},a.syncOrAsync=function(t,e,n){function r(){return a.syncOrAsync(t,e,n)}for(var o,i;t.length;)if(i=t.splice(0,1)[0],o=i(e),o&&o.then)return o.then(r).then(void 0,a.promiseError);return n&&n(e)},a.stripTrailingSlash=function(t){return"/"===t.substr(-1)?t.substr(0,t.length-1):t},a.noneOrAll=function(t,e,n){if(t){var r,a,o=!1,i=!0;for(r=0;ra;a++)e[a][n]=t[a]},a.minExtend=function(t,e){var n={};"object"!=typeof e&&(e={});var r,o,i,l=3,s=Object.keys(t);for(r=0;r1?r+o[1]:"";if(a&&(o.length>1||i.length>4))for(;n.test(i);)i=i.replace(n,"$1"+a+"$2");return i+l}},{"./coerce":90,"./dates":91,"./extend":93,"./is_plain_object":95,"./loggers":96,"./matrix":97,"./nested_property":98,"./notifier":99,"./search":102,"./stats":104,d3:9}],95:[function(t,e,n){"use strict";e.exports=function(t){return window&&window.process&&window.process.versions?"[object Object]"===Object.prototype.toString.call(t):"[object Object]"===Object.prototype.toString.call(t)&&Object.getPrototypeOf(t)===Object.prototype}},{}],96:[function(t,e,n){"use strict";var r=t("../plot_api/plot_config"),a=e.exports={};a.log=function(){if(r.logging>1){for(var t=["LOG:"],e=0;e0){for(var t=["WARN:"],e=0;e0){for(var t=["ERROR:"],e=0;er;r++)n[r]=new Array(e);return n},n.transposeRagged=function(t){var e,n,r=0,a=t.length;for(e=0;a>e;e++)r=Math.max(r,t[e].length);var o=new Array(r);for(e=0;r>e;e++)for(o[e]=new Array(a),n=0;a>n;n++)o[e][n]=t[n][e];return o},n.dot=function(t,e){if(!t.length||!e.length||t.length!==e.length)return null;var r,a,o=t.length;if(t[0].length)for(r=new Array(o),a=0;o>a;a++)r[a]=n.dot(t[a],e);else if(e[0].length){var i=n.transposeRagged(e);for(r=new Array(i.length),a=0;aa;a++)r+=t[a]*e[a];return r},n.translationMatrix=function(t,e){return[[1,0,t],[0,1,e],[0,0,1]]},n.rotationMatrix=function(t){var e=t*Math.PI/180;return[[Math.cos(e),-Math.sin(e),0],[Math.sin(e),Math.cos(e),0],[0,0,1]]},n.rotationXYMatrix=function(t,e,r){return n.dot(n.dot(n.translationMatrix(e,r),n.rotationMatrix(t)),n.translationMatrix(-e,-r))},n.apply2DTransform=function(t){return function(){var e=arguments;3===e.length&&(e=e[0]);var r=1===arguments.length?e[0]:[e[0],e[1]];return n.dot(t,[r[0],r[1],1]).slice(0,2)}},n.apply2DTransform2=function(t){var e=n.apply2DTransform(t);return function(t){return e(t.slice(0,2)).concat(e(t.slice(2,4)))}}},{}],98:[function(t,e,n){"use strict";function r(t,e){return function(){var n,a,o,i,l,s=t;for(i=0;i=0;e--){if(r=t[e],i=!1,Array.isArray(r))for(n=r.length-1;n>=0;n--)c(r[n])?i?r[n]=void 0:r.pop():i=!0;else if("object"==typeof r&&null!==r)for(o=Object.keys(r),i=!1,n=o.length-1;n>=0;n--)c(r[o[n]])&&!a(r[o[n]],o[n])?delete r[o[n]]:i=!0;if(i)return}}function c(t){return void 0===t||null===t?!0:"object"!=typeof t?!1:Array.isArray(t)?!t.length:!Object.keys(t).length}function u(t,e,n){return{set:function(){throw"bad container"},get:function(){},astr:e,parts:n,obj:t}}var f=t("fast-isnumeric");e.exports=function(t,e){if(f(e))e=String(e);else if("string"!=typeof e||"[-1]"===e.substr(e.length-4))throw"bad property string";for(var n,a,i,l=0,s=e.split(".");ln||n>o||i>r||r>l?!1:!e||!c(t)}function n(t,e){var n=t[0],s=t[1];if(a>n||n>o||i>s||s>l)return!1;var c,u,f,d,h,p=r.length,g=r[0][0],v=r[0][1],m=0;for(c=1;p>c;c++)if(u=g,f=v,g=r[c][0],v=r[c][1],d=Math.min(u,g),!(d>n||n>Math.max(u,g)||s>Math.max(f,v)))if(s=s&&n!==d&&m++}return m%2===1}var r=t.slice(),a=r[0][0],o=a,i=r[0][1],l=i;r.push(r[0]);for(var s=1;so;o++)if(i=[t[o][0]-s[0],t[o][1]-s[1]],l=r(i,c),0>l||l>u||Math.abs(r(i,d))>a)return!0;return!1};a.filter=function(t,e){function n(n){t.push(n);var l=r.length,s=a;r.splice(i+1);for(var c=s+1;c1){var l=t.pop();n(l)}return{addPt:n,raw:t,filtered:r}}},{"./matrix":97}],101:[function(t,e,n){"use strict";function r(t,e){for(var n,r=[],o=0;oo.queueLength&&(t.undoQueue.queue.shift(),t.undoQueue.index--)))},i.startSequence=function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!0,t.undoQueue.beginSequence=!0},i.stopSequence=function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!1,t.undoQueue.beginSequence=!1},i.undo=function(t){var e,n;if(t.framework&&t.framework.isPolar)return void t.framework.undo();if(!(void 0===t.undoQueue||isNaN(t.undoQueue.index)||t.undoQueue.index<=0)){for(t.undoQueue.index--,e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,n=0;n=t.undoQueue.queue.length)){for(e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,n=0;nt}function a(t,e){return e>=t}function o(t,e){return t>e}function i(t,e){return t>=e}var l=t("fast-isnumeric"),s=t("../lib");n.findBin=function(t,e,n){if(l(e.start))return n?Math.ceil((t-e.start)/e.size)-1:Math.floor((t-e.start)/e.size);var c,u,f=0,d=e.length,h=0;for(u=e[e.length-1]>=e[0]?n?r:a:n?i:o;d>f&&h++<100;)c=Math.floor((f+d)/2),u(e[c],t)?f=c+1:d=c;return h>90&&s.log("Long binary search..."),f-1},n.sorterAsc=function(t,e){return t-e},n.sorterDes=function(t,e){return e-t},n.distinctVals=function(t){var e=t.slice();e.sort(n.sorterAsc);for(var r=e.length-1,a=e[r]-e[0]||1,o=a/(r||1)/1e4,i=[e[0]],l=0;r>l;l++)e[l+1]>e[l]+o&&(a=Math.min(a,e[l+1]-e[l]),i.push(e[l+1]));return{vals:i,minDiff:a}},n.roundUp=function(t,e,n){for(var r,a=0,o=e.length-1,i=0,l=n?0:1,s=n?1:0,c=n?Math.ceil:Math.floor;o>a&&i++<100;)r=c((a+o)/2),e[r]<=t?a=r+l:o=r-s;return e[a]}},{"../lib":94,"fast-isnumeric":11}],103:[function(t,e,n){"use strict";e.exports=function(t,e){(t.attr("class")||"").split(" ").forEach(function(e){0===e.indexOf("cursor-")&&t.classed(e,!1)}),e&&t.classed("cursor-"+e,!0)}},{}],104:[function(t,e,n){"use strict";var r=t("fast-isnumeric");n.aggNums=function(t,e,a,o){var i,l;if(o||(o=a.length),r(e)||(e=!1),Array.isArray(a[0])){for(l=new Array(o),i=0;o>i;i++)l[i]=n.aggNums(t,e,a[i]);a=l}for(i=0;o>i;i++)r(e)?r(a[i])&&(e=t(+e,+a[i])):e=a[i];return e},n.len=function(t){return n.aggNums(function(t){return t+1},0,t)},n.mean=function(t,e){return e||(e=n.len(t)),n.aggNums(function(t,e){return t+e},0,t)/e},n.variance=function(t,e,a){return e||(e=n.len(t)),r(a)||(a=n.mean(t,e)),n.aggNums(function(t,e){return t+Math.pow(e-a,2)},0,t)/e},n.stdev=function(t,e,r){return Math.sqrt(n.variance(t,e,r))},n.interp=function(t,e){if(!r(e))throw"n should be a finite number";if(e=e*t.length-.5,0>e)return t[0];if(e>t.length-1)return t[t.length-1];var n=e%1;return n*t[Math.ceil(e)]+(1-n)*t[Math.floor(e)]}},{"fast-isnumeric":11}],105:[function(t,e,n){"use strict";function r(t,e){return t.node().getBoundingClientRect()[e]}function a(t){return t.replace(/(<|<|<)/g,"\\lt ").replace(/(>|>|>)/g,"\\gt ")}function o(t,e,n){var r="math-output-"+c.Lib.randstr([],64),o=u.select("body").append("div").attr({id:r}).style({visibility:"hidden",position:"absolute"}).style({"font-size":e.fontSize+"px"}).text(a(t));MathJax.Hub.Queue(["Typeset",MathJax.Hub,o.node()],function(){var e=u.select("body").select("#MathJax_SVG_glyphs");if(o.select(".MathJax_SVG").empty()||!o.select("svg").node())f.log("There was an error in the tex syntax.",t),n();else{var r=o.select("svg").node().getBoundingClientRect();n(o.select(".MathJax_SVG"),e,r)}o.remove()})}function i(t){return(t||"").replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")}function l(t){for(var e=t.split(/(<[^<>]*>)/).map(function(t){var e=t.match(/<(\/?)([^ >]*)\s*(.*)>/i),n=e&&e[2].toLowerCase(),r=p[n];if(void 0!==r){var a=e[1],o=e[3],l=o.match(/^style\s*=\s*"([^"]+)"\s*/i);if("a"===n){if(a)return"";if("href"!==o.substr(0,4).toLowerCase())return"";var s=o.substr(4).replace(/["']/g,"").replace(/=/,""),u=document.createElement("a");return u.href=s,-1===g.indexOf(u.protocol)?"":''}if("br"===n)return"
";if(a)return"sup"===n?'':"sub"===n?'':"";var f=""}return c.util.xml_entity_encode(t).replace(/");r>0;r=e.indexOf("
",r+1))n.push(r);var a=0;n.forEach(function(t){for(var n=t+a,r=e.slice(0,n),o="",i=r.length-1;i>=0;i--){var l=r[i].match(/<(\/?).*>/i);if(l&&"
"!==r[i]){l[1]||(o=r[i]);break}}o&&(e.splice(n+1,0,o),e.splice(n,0,""),a+=2)});var o=e.join(""),l=o.split(/
/gi);return l.length>1&&(e=l.map(function(t,e){return''+t+""})),e.join("")}function s(t,e,n){var r,a,o,i=n.horizontalAlign,l=n.verticalAlign||"top",s=t.node().getBoundingClientRect(),c=e.node().getBoundingClientRect();return a="bottom"===l?function(){return s.bottom-r.height}:"middle"===l?function(){return s.top+(s.height-r.height)/2}:function(){return s.top},o="right"===i?function(){return s.right-r.width}:"center"===i?function(){return s.left+(s.width-r.width)/2}:function(){return s.left},function(){return r=this.node().getBoundingClientRect(),this.style({top:a()-c.top+"px",left:o()-c.left+"px","z-index":1e3}),this}}var c=t("../plotly"),u=t("d3"),f=t("../lib"),d=t("../constants/xmlns_namespaces"),h=e.exports={};u.selection.prototype.appendSVG=function(t){for(var e=['',t,""].join(""),n=(new DOMParser).parseFromString(e,"application/xml"),r=n.documentElement.firstChild;r;)this.node().appendChild(this.node().ownerDocument.importNode(r,!0)),r=r.nextSibling;return n.querySelector("parsererror")?(f.log(n.querySelector("parsererror div").textContent),null):u.select(this.node().lastChild)},h.html_entity_decode=function(t){var e=u.select("body").append("div").style({display:"none"}).html(""),n=t.replace(/(&[^;]*;)/gi,function(t){return"<"===t?"<":"&rt;"===t?">":e.html(t).text()});return e.remove(),n},h.xml_entity_encode=function(t){return t.replace(/&(?!\w+;|\#[0-9]+;| \#x[0-9A-F]+;)/g,"&")},h.convertToTspans=function(t,e){function n(){h.empty()||(p=s.attr("class")+"-math",h.select("svg."+p).remove()),t.text("").style({visibility:"visible","white-space":"pre"}),d=t.appendSVG(i),d||t.text(a),t.select("a").size()&&t.style("pointer-events","all"),e&&e.call(s)}var a=t.text(),i=l(a),s=t,f=!s.attr("data-notex")&&i.match(/([^$]*)([$]+[^$]*[$]+)([^$]*)/),d=a,h=u.select(s.node().parentNode);if(!h.empty()){var p=s.attr("class")?s.attr("class").split(" ")[0]:"text";p+="-math",h.selectAll("svg."+p).remove(),h.selectAll("g."+p+"-group").remove(),t.style({visibility:null});for(var g=t.node();g&&g.removeAttribute;g=g.parentNode)g.removeAttribute("data-bb");if(f){var v=c.Lib.getPlotDiv(s.node());(v&&v._promises||[]).push(new Promise(function(t){s.style({visibility:"hidden"});var a={fontSize:parseInt(s.style("font-size"),10)};o(f[2],a,function(a,o,i){h.selectAll("svg."+p).remove(),h.selectAll("g."+p+"-group").remove();var l=a&&a.select("svg");if(!l||!l.node())return n(),void t();var c=h.append("g").classed(p+"-group",!0).attr({"pointer-events":"none"});c.node().appendChild(l.node()),o&&o.node()&&l.node().insertBefore(o.node().cloneNode(!0),l.node().firstChild),l.attr({"class":p,height:i.height,preserveAspectRatio:"xMinYMin meet"}).style({overflow:"visible","pointer-events":"none"});var u=s.style("fill")||"black";l.select("g").attr({fill:u,stroke:u});var f=r(l,"width"),d=r(l,"height"),g=+s.attr("x")-f*{start:0,middle:.5,end:1}[s.attr("text-anchor")||"start"],v=parseInt(s.style("font-size"),10)||r(s,"height"),m=-v/4;"y"===p[0]?(c.attr({transform:"rotate("+[-90,+s.attr("x"),+s.attr("y")]+") translate("+[-f/2,m-d/2]+")"}),l.attr({x:+s.attr("x"),y:+s.attr("y")})):"l"===p[0]?l.attr({x:s.attr("x"),y:m-d/2}):"a"===p[0]?l.attr({x:0,y:m}):l.attr({x:g,y:+s.attr("y")+m-d/2}),e&&e.call(s,c),t(c)})}))}else n();return t}};var p={sup:'font-size:70%" dy="-0.6em',sub:'font-size:70%" dy="0.3em',b:"font-weight:bold",i:"font-style:italic",a:"",span:"",br:"",em:"font-style:italic;font-weight:bold"},g=["http:","https:","mailto:"],v=new RegExp("]*)?/?>","g");h.plainText=function(t){return(t||"").replace(v," ")},h.makeEditable=function(t,e,n){function r(){o(),i.style({opacity:0});var t,e=d.attr("class");t=e?"."+e.split(" ")[0]+"-math-group":"[class*=-math-group]",t&&u.select(i.node().parentNode).select(t).style({opacity:0})}function a(t){var e=t.node(),n=document.createRange();n.selectNodeContents(e);var r=window.getSelection();r.removeAllRanges(),r.addRange(n),e.focus()}function o(){var t=u.select(c.Lib.getPlotDiv(i.node())),e=t.select(".svg-container"),r=e.append("div");r.classed("plugin-editable editable",!0).style({position:"absolute","font-family":i.style("font-family")||"Arial","font-size":i.style("font-size")||12,color:n.fill||i.style("fill")||"black",opacity:1,"background-color":n.background||"transparent",outline:"#ffffff33 1px solid",margin:[-parseFloat(i.style("font-size"))/8+1,0,0,-1].join("px ")+"px",padding:"0","box-sizing":"border-box"}).attr({contenteditable:!0}).text(n.text||i.attr("data-unformatted")).call(s(i,e,n)).on("blur",function(){i.text(this.textContent).style({opacity:1});var t,e=u.select(this).attr("class");t=e?"."+e.split(" ")[0]+"-math-group":"[class*=-math-group]",t&&u.select(i.node().parentNode).select(t).style({opacity:0});var n=this.textContent;u.select(this).transition().duration(0).remove(),u.select(document).on("mouseup",null),l.edit.call(i,n)}).on("focus",function(){var t=this;u.select(document).on("mouseup",function(){return u.event.target===t?!1:void(document.activeElement===r.node()&&r.node().blur())})}).on("keyup",function(){27===u.event.which?(i.style({opacity:1}),u.select(this).style({opacity:0}).on("blur",function(){return!1}).transition().remove(),l.cancel.call(i,this.textContent)):(l.input.call(i,this.textContent),u.select(this).call(s(i,e,n)))}).on("keydown",function(){13===u.event.which&&this.blur()}).call(a)}n||(n={});var i=this,l=u.dispatch("edit","input","cancel"),f=u.select(this.node()).style({"pointer-events":"all"}),d=e||f;return e&&f.style({"pointer-events":"none"}),n.immediate?r():d.on("click",r),u.rebind(this,l,"on")}},{"../constants/xmlns_namespaces":87,"../lib":94,"../plotly":112,d3:9}],106:[function(t,e,n){"use strict";function r(t){var e;if("string"==typeof t){if(e=document.getElementById(t),null===e)throw new Error("No DOM element with id '"+t+"' exists on the page.");return e}if(null===t||void 0===t)throw new Error("DOM element provided is null or undefined");return t}function a(t){Array.isArray(t._promises)&&t._promises.length>0&&N.log("Clearing previous rejected promises from queue."),t._promises=[]}function o(t,e){t._fullLayout._paperdiv.style("background","white"),P.defaultConfig.setBackground(t,e)}function i(t,e){t._context||(t._context=N.extendFlat({},P.defaultConfig));var n=t._context;e&&(Object.keys(e).forEach(function(t){t in n&&("setBackground"===t&&"opaque"===e[t]?n[t]=o:n[t]=e[t])}),e.plot3dPixelRatio&&!n.plotGlPixelRatio&&(n.plotGlPixelRatio=n.plot3dPixelRatio)),n.staticPlot&&(n.editable=!1,n.autosizable=!1,n.scrollZoom=!1,n.doubleClick=!1,n.showTips=!1,n.showLink=!1,n.displayModeBar=!1)}function l(t,e,n){var r=C.select(t).selectAll(".plot-container").data([0]);r.enter().insert("div",":first-child").classed("plot-container plotly",!0);var a=r.selectAll(".svg-container").data([0]);a.enter().append("div").classed("svg-container",!0).style("position","relative"),a.html(""),e&&(t.data=e),n&&(t.layout=n),P.micropolar.manager.fillLayout(t),"initial"===t._fullLayout.autosize&&t._context.autosizable&&(k(t,{}),t._fullLayout.autosize=n.autosize=!0),a.style({width:t._fullLayout.width+"px",height:t._fullLayout.height+"px"}),t.framework=P.micropolar.manager.framework(t),t.framework({data:t.data,layout:t.layout},a.node()),t.framework.setUndoPoint();var o=t.framework.svg(),i=1,l=t._fullLayout.title;""!==l&&l||(i=0);var s="Click to enter title",c=function(){this.call(P.util.convertToTspans)},u=o.select(".title-group text").call(c);if(t._context.editable){u.attr({"data-unformatted":l}),l&&l!==s||(i=.2,u.attr({"data-unformatted":s}).text(s).style({opacity:i}).on("mouseover.opacity",function(){C.select(this).transition().duration(100).style("opacity",1)}).on("mouseout.opacity",function(){C.select(this).transition().duration(1e3).style("opacity",0)}));var f=function(){this.call(P.util.makeEditable).on("edit",function(e){t.framework({layout:{title:e}}),this.attr({"data-unformatted":e}).text(e).call(c),this.call(f)}).on("cancel",function(){var t=this.attr("data-unformatted");this.text(t).call(c)})};u.call(f)}return t._context.setBackground(t,t._fullLayout.paper_bgcolor),R.addLinks(t),Promise.resolve()}function s(t){var e,n;t||(t={}),t.xaxis1&&(t.xaxis||(t.xaxis=t.xaxis1),delete t.xaxis1),t.yaxis1&&(t.yaxis||(t.yaxis=t.yaxis1),delete t.yaxis1);var r=P.Axes.list({_fullLayout:t});for(e=0;ee;e++){var i=t.annotations[e];i.ref&&("paper"===i.ref?(i.xref="paper",i.yref="paper"):"data"===i.ref&&(i.xref="x",i.yref="y"),delete i.ref),c(i,"xref"),c(i,"yref")}void 0===t.shapes||Array.isArray(t.shapes)||(N.warn("Shapes must be an array."),delete t.shapes);var l=(t.shapes||[]).length;for(e=0;l>e;e++){var s=t.shapes[e];c(s,"xref"),c(s,"yref")}var u=t.legend;u&&(u.x>3?(u.x=1.02,u.xanchor="left"):u.x<-2&&(u.x=-.02,u.xanchor="right"),u.y>3?(u.y=1.02,u.yanchor="bottom"):u.y<-2&&(u.y=-.02,u.yanchor="top")),"rotate"===t.dragmode&&(t.dragmode="orbit"),t.scene1&&(t.scene||(t.scene=t.scene1),delete t.scene1);var f=R.getSubplotIds(t,"gl3d");for(e=0;en;++n)x[n]=v[e]+m*y[2+4*n];h.camera={eye:{x:x[0],y:x[1],z:x[2]},center:{x:v[0],y:v[1],z:v[2]},up:{x:y[1],y:y[5],z:y[9]}},delete h.cameraposition}}return F.clean(t),t}function c(t,e){var n=t[e],r=e.charAt(0);n&&"paper"!==n&&(t[e]=P.Axes.cleanId(n,r))}function u(t,e){for(var n=[],r=(t.concat(Array.isArray(e)?e:[]).filter(function(t){return"uid"in t}).map(function(t){return t.uid})),a=0;ao&&(l=N.randstr(r),-1!==n.indexOf(l));o++);i.uid=N.randstr(r),r.push(i.uid)}if(n.push(i.uid),"histogramy"===i.type&&"xbins"in i&&!("ybins"in i)&&(i.ybins=i.xbins,delete i.xbins),i.error_y&&"opacity"in i.error_y){var s=F.defaults,c=i.error_y.color||(R.traceIs(i,"bar")?F.defaultLine:s[a%s.length]);i.error_y.color=F.addOpacity(F.rgb(c),F.opacity(c)*i.error_y.opacity),delete i.error_y.opacity}if("bardir"in i&&("h"!==i.bardir||!R.traceIs(i,"bar")&&"histogram"!==i.type.substr(0,9)||(i.orientation="h",_(i)),delete i.bardir),"histogramy"===i.type&&_(i),"histogramx"!==i.type&&"histogramy"!==i.type||(i.type="histogram"),"scl"in i&&(i.colorscale=i.scl,delete i.scl),"reversescl"in i&&(i.reversescale=i.reversescl,delete i.reversescl),i.xaxis&&(i.xaxis=P.Axes.cleanId(i.xaxis,"x")),i.yaxis&&(i.yaxis=P.Axes.cleanId(i.yaxis,"y")),R.traceIs(i,"gl3d")&&i.scene&&(i.scene=R.subplotsRegistry.gl3d.cleanId(i.scene)),R.traceIs(i,"pie")||(Array.isArray(i.textposition)?i.textposition=i.textposition.map(f):i.textposition&&(i.textposition=f(i.textposition))),R.traceIs(i,"2dMap")&&("YIGnBu"===i.colorscale&&(i.colorscale="YlGnBu"),"YIOrRd"===i.colorscale&&(i.colorscale="YlOrRd")),R.traceIs(i,"markerColorscale")&&i.marker){var u=i.marker;"YIGnBu"===u.colorscale&&(u.colorscale="YlGnBu"),"YIOrRd"===u.colorscale&&(u.colorscale="YlOrRd")}if("surface"===i.type&&N.isPlainObject(i.contours)){var h=["x","y","z"];for(o=0;or?o.push(a+r):o.push(r);return o}function g(t,e,n){var r,a;for(r=0;r=t.data.length||a<-t.data.length)throw new Error(n+" must be valid indices for gd.data.");if(e.indexOf(a,r+1)>-1||a>=0&&e.indexOf(-t.data.length+a)>-1||0>a&&e.indexOf(t.data.length+a)>-1)throw new Error("each index in "+n+" must be unique.")}}function v(t,e,n){if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("currentIndices is a required argument.");if(Array.isArray(e)||(e=[e]),g(t,e,"currentIndices"),"undefined"==typeof n||Array.isArray(n)||(n=[n]),"undefined"!=typeof n&&g(t,n,"newIndices"),"undefined"!=typeof n&&e.length!==n.length)throw new Error("current and new indices must be of equal length.")}function m(t,e,n){var r,a;if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("traces must be defined.");for(Array.isArray(e)||(e=[e]),r=0;r=0&&s0){var l=w(t._boundingBoxMargins),s=l.left+l.right,c=l.bottom+l.top,u=o._container.node().getBoundingClientRect(),f=1-2*i.frameMargins;a=Math.round(f*(u.width-s)),r=Math.round(f*(u.height-c))}else n=window.getComputedStyle(t),r=parseFloat(n.height)||o.height,a=parseFloat(n.width)||o.width;return Math.abs(o.width-a)>1||Math.abs(o.height-r)>1?(o.height=t.layout.height=r,o.width=t.layout.width=a):"initial"!==o.autosize&&(delete e.autosize,o.autosize=t.layout.autosize=!0),R.sanitizeMargins(o),e}function M(t){var e=C.select(t),n=t._fullLayout;if(n._container=e.selectAll(".plot-container").data([0]),n._container.enter().insert("div",":first-child").classed("plot-container",!0).classed("plotly",!0),n._paperdiv=n._container.selectAll(".svg-container").data([0]),n._paperdiv.enter().append("div").classed("svg-container",!0).style("position","relative"),"initial"===n.autosize&&(k(t,{}),n.autosize=!0,t.layout.autosize=!0),n._glcontainer=n._paperdiv.selectAll(".gl-container").data([0]),n._glcontainer.enter().append("div").classed("gl-container",!0),n._geocontainer=n._paperdiv.selectAll(".geo-container").data([0]),n._geocontainer.enter().append("div").classed("geo-container",!0),n._paperdiv.selectAll(".main-svg").remove(),n._paper=n._paperdiv.insert("svg",":first-child").classed("main-svg",!0),n._toppaper=n._paperdiv.append("svg").classed("main-svg",!0),!n._uid){var r=[];C.selectAll("defs").each(function(){this.id&&r.push(this.id.split("-")[1])}),n._uid=N.randstr(r)}n._paperdiv.selectAll(".main-svg").attr(Q.svgAttrs),n._defs=n._paper.append("defs").attr("id","defs-"+n._uid),n._topdefs=n._toppaper.append("defs").attr("id","topdefs-"+n._uid),n._draggers=n._paper.append("g").classed("draglayer",!0);var a=n._paper.append("g").classed("layer-below",!0);n._imageLowerLayer=a.append("g").classed("imagelayer",!0),n._shapeLowerLayer=a.append("g").classed("shapelayer",!0);var o=P.Axes.getSubplots(t);o.join("")!==Object.keys(t._fullLayout._plots||{}).join("")&&A(t,o),n._has("cartesian")&&T(t,o),n._ternarylayer=n._paper.append("g").classed("ternarylayer",!0);var i=n._paper.selectAll(".layer-subplot");n._imageSubplotLayer=i.selectAll(".imagelayer"),n._shapeSubplotLayer=i.selectAll(".shapelayer");var l=n._paper.append("g").classed("layer-above",!0);n._imageUpperLayer=l.append("g").classed("imagelayer",!0),n._shapeUpperLayer=l.append("g").classed("shapelayer",!0),n._pielayer=n._paper.append("g").classed("pielayer",!0),n._glimages=n._paper.append("g").classed("glimages",!0),n._geoimages=n._paper.append("g").classed("geoimages",!0),n._infolayer=n._toppaper.append("g").classed("infolayer",!0),n._zoomlayer=n._toppaper.append("g").classed("zoomlayer",!0),n._hoverlayer=n._toppaper.append("g").classed("hoverlayer",!0),t.emit("plotly_framework");var s=N.syncOrAsync([L,function(){return P.Axes.doTicks(t,"redraw")},j.init],t);return s&&s.then&&t._promises.push(s),s}function A(t,e){function n(e,n){return function(){return P.Axes.getFromId(t,e,n)}}for(var r,a,o=t._fullLayout._plots={},i=0;i0,_=P.Axes.getSubplots(t).join(""),w=Object.keys(t._fullLayout._plots||{}).join(""),k=w===_;b?t.framework===M&&!x&&k||(t.framework=M,M(t)):k?x&&M(t):(t.framework=M,M(t)),x&&P.Axes.saveRangeInitial(t);var A=t._fullLayout,T=!t.calcdata||t.calcdata.length!==(t.data||[]).length;T&&h(t);for(var z=0;zG.range[0]?[1,2]:[2,1]);else{var Q=G.range[0],W=G.range[1];"log"===j?(0>=Q&&0>=W&&o(Y+".autorange",!0),0>=Q?Q=W/1e6:0>=W&&(W=Q/1e6),o(Y+".range[0]",Math.log(Q)/Math.LN10),o(Y+".range[1]",Math.log(W)/Math.LN10)):(o(Y+".range[0]",Math.pow(10,Q)),o(Y+".range[1]",Math.pow(10,W)))}else o(Y+".autorange",!0)}if("reverse"===B)U.range?U.range.reverse():(o(Y+".autorange",!0),U.range=[1,0]),X.autorange?w=!0:_=!0;else if("annotations"===D.parts[0]||"shapes"===D.parts[0]){var J=D.parts[1],K=D.parts[0],tt=g[K]||[],et=P[N.titleCase(K)],nt=tt[J]||{};2===D.parts.length&&("add"===m[E]||N.isPlainObject(m[E])?z[E]="remove":"remove"===m[E]?-1===J?(z[K]=tt,delete z[E]):z[E]=nt:N.log("???",m)),!i(nt,"x")&&!i(nt,"y")||N.containsAny(E,["color","opacity","align","dash"])||(w=!0),et.draw(t,J,D.parts.slice(2).join("."),m[E]),delete m[E]}else if("images"===D.parts[0]){var at=N.objectFromPath(E,j);N.extendDeepAll(t.layout,at),H.supplyLayoutDefaults(t.layout,t._fullLayout),H.draw(t)}else if("mapbox"===D.parts[0]&&"layers"===D.parts[1]){N.extendDeepAll(t.layout,N.objectFromPath(E,j));var ot=(t._fullLayout.mapbox||{}).layers||[];for(O=D.parts[2]+1-ot.length,p=0;O>p;p++)ot.push({});_=!0}else if("updatemenus"===D.parts[0]){N.extendDeepAll(t.layout,N.objectFromPath(E,j));var it=t._fullLayout.updatemenus||[];for(O=D.parts[2]+1-it.length,p=0;O>p;p++)it.push({});_=!0}else 0===D.parts[0].indexOf("scene")?_=!0:0===D.parts[0].indexOf("geo")?_=!0:0===D.parts[0].indexOf("ternary")?_=!0:!v._has("gl2d")||-1===E.indexOf("axis")&&"plot_bgcolor"!==D.parts[0]?"hiddenlabels"===E?w=!0:-1!==D.parts[0].indexOf("legend")?y=!0:-1!==E.indexOf("title")?x=!0:-1!==D.parts[0].indexOf("bgcolor")?b=!0:D.parts.length>1&&N.containsAny(D.parts[1],["tick","exponent","grid","zeroline"])?x=!0:-1!==E.indexOf(".linewidth")&&-1!==E.indexOf("axis")?x=b=!0:D.parts.length>1&&-1!==D.parts[1].indexOf("line")?b=!0:D.parts.length>1&&"mirror"===D.parts[1]?x=b=!0:"margin.pad"===E?x=b=!0:"margin"===D.parts[0]||"autorange"===D.parts[1]||"rangemode"===D.parts[1]||"type"===D.parts[1]||"domain"===D.parts[1]||E.match(/^(bar|box|font)/)?w=!0:-1!==["hovermode","dragmode"].indexOf(E)?M=!0:-1===["hovermode","dragmode","height","width","autosize"].indexOf(E)&&(_=!0):_=!0,D.set(j)}I.add(t,rt,[t,z],rt,[t,T]),m.autosize&&(m=k(t,m)),(m.height||m.width||m.autosize)&&(w=!0); +-var lt=Object.keys(m),st=[R.previousPromises];if(_||w)st.push(function(){return t.layout=void 0,w&&(t.calcdata=void 0),P.plot(t,"",g)});else if(lt.length&&(R.supplyDefaults(t),v=t._fullLayout,y&&st.push(function(){return V.draw(t),R.previousPromises(t)}),b&&st.push(L),x&&st.push(function(){return P.Axes.doTicks(t,"redraw"),S(t),R.previousPromises(t)}),M)){var ct;for($(t),P.Fx.supplyLayoutDefaults(t.layout,v,t._fullData),P.Fx.init(t),ct=R.getSubplotIds(v,"gl3d"),p=0;p1)};c(n.width)&&c(n.height)||l(new Error("Height and width should be pixel values."));var u=r.clone(e,{format:"png",height:n.height,width:n.width}),f=u.td;f.style.position="absolute",f.style.left="-5000px",document.body.appendChild(f);var d=r.getRedrawFunc(f);o.plot(f,u.data,u.layout,u.config).then(d).then(s).then(function(e){t(e)}).catch(function(t){l(t)})});return l}var a=t("fast-isnumeric"),o=t("../plotly"),i=t("../lib");e.exports=r},{"../lib":94,"../plotly":112,"../snapshot":144,"fast-isnumeric":11}],111:[function(t,e,n){"use strict";function r(t,e,n,a,o,c){c=c||[];for(var u=Object.keys(t),d=0;d1&&s.push(i("object","layout"))),d.supplyDefaults(c);for(var u=c._fullData,v=n.length,m=0;v>m;m++){var y=n[m],x=["data",m];if(p(y)){var b=u[m],_=b.type,w=l.traces[_].attributes;w.type={valType:"enumerated",values:[_]},b.visible===!1&&y.visible!==!1&&s.push(i("invisible",x)),r(y,b,w,s,x);var k=y.transforms,M=b.transforms;if(k){g(k)||s.push(i("array",x,["transforms"])),x.push("transforms");for(var A=0;Ac&&u>e&&(void 0===a[n]?o[f]=T.tickText(t,e):o[f]=l(t,e,String(a[n])),f++);return f=864e5?t._tickround="d":n>=36e5?t._tickround="H":n>=6e4?t._tickround="M":n>=1e3?t._tickround="S":t._tickround=3-Math.round(Math.log(n/2)/Math.LN10);else{x(n)||(n=Number(n.substr(1))),t._tickround=2-Math.floor(Math.log(n)/Math.LN10+.01),e="log"===t.type?Math.pow(10,Math.max(t.range[0],t.range[1])):Math.max(Math.abs(t.range[0]),Math.abs(t.range[1]));var r=Math.floor(Math.log(e)/Math.LN10+.01);Math.abs(r)>3&&("SI"===t.exponentformat||"B"===t.exponentformat?t._tickexponent=3*Math.round((r-1)/3):t._tickexponent=r)}else"M"===n.charAt(0)?t._tickround=2===n.length?"m":"y":t._tickround=null}function i(t,e){var n=t.match(B),r=new Date(e);if(n){var a=Math.min(+n[1]||6,6),o=String(e/1e3%1+2.0000005).substr(2,a).replace(/0+$/,"")||"0";return y.time.format(t.replace(B,o))(r)}return y.time.format(t)(r)}function l(t,e,n){var r=t.tickfont||t._gd._fullLayout.font;return{x:e,dx:0,dy:0,text:n||"",fontSize:r.size,font:r.family,fontColor:r.color}}function s(t,e,n,r){var a,o=e.x,l=t._tickround,s=new Date(o),c="";n&&t.hoverformat?a=i(t.hoverformat,o):t.tickformat?a=i(t.tickformat,o):(r&&(x(l)?l+=2:l={y:"m",m:"d",d:"H",H:"M",M:"S",S:2}[l]),"y"===l?a=D(s):"m"===l?a=I(s):(o!==t._tmin||n||(c="
"+D(s)),"d"===l?a=R(s):"H"===l?a=j(s):(o!==t._tmin||n||(c="
"+R(s)+", "+D(s)),a=F(s),"M"!==l&&(a+=q(s),"S"!==l&&(a+=d(m(o/1e3,1),t,"none",n).substr(1)))))),e.text=a+c}function c(t,e,n,r,a){var o=t.dtick,i=e.x;if(!r||"string"==typeof o&&"L"===o.charAt(0)||(o="L3"),t.tickformat||"string"==typeof o&&"L"===o.charAt(0))e.text=d(Math.pow(10,i),t,a,r);else if(x(o)||"D"===o.charAt(0)&&m(i+.01,1)<.1)if(-1!==["e","E","power"].indexOf(t.exponentformat)){var l=Math.round(i);0===l?e.text=1:1===l?e.text="10":l>1?e.text="10"+l+"":e.text="10\u2212"+-l+"",e.fontSize*=1.25}else e.text=d(Math.pow(10,i),t,"","fakehover"),"D1"===o&&"y"===t._id.charAt(0)&&(e.dy-=e.fontSize/6);else{if("D"!==o.charAt(0))throw"unrecognized dtick "+String(o);e.text=String(Math.round(Math.pow(10,m(i,1)))),e.fontSize*=.75}if("D1"===t.dtick){var s=String(e.text).charAt(0);"0"!==s&&"1"!==s||("y"===t._id.charAt(0)?e.dx-=e.fontSize/4:(e.dy+=e.fontSize/2,e.dx+=(t.range[1]>t.range[0]?1:-1)*e.fontSize*(0>i?.5:.25)))}}function u(t,e){var n=t._categories[Math.round(e.x)];void 0===n&&(n=""),e.text=String(n)}function f(t,e,n,r,a){"all"===t.showexponent&&Math.abs(e.x/t.dtick)<1e-6&&(a="hide"),e.text=d(e.x,t,a,r)}function d(t,e,n,r){var a=0>t,i=e._tickround,l=n||e.exponentformat||"B",s=e._tickexponent,c=e.tickformat;if(r){var u={exponentformat:e.exponentformat,dtick:"none"===e.showexponent?e.dtick:x(t)?Math.abs(t)||1:1,range:"none"===e.showexponent?e.range:[0,t||1]};o(u),i=(Number(u._tickround)||0)+4,s=u._tickexponent,e.hoverformat&&(c=e.hoverformat)}if(c)return y.format(c)(t).replace(/-/g,"\u2212");var f=Math.pow(10,-i)/2;if("none"===l&&(s=0),t=Math.abs(t),f>t)t="0",a=!1;else{if(t+=f,s&&(t*=Math.pow(10,-s),i+=s),0===i)t=String(Math.floor(t));else if(0>i){t=String(Math.round(t)),t=t.substr(0,t.length+i);for(var d=i;0>d;d++)t+="0"}else{t=String(t);var h=t.indexOf(".")+1;h&&(t=t.substr(0,h+i).replace(/\.?0+$/,""))}t=_.numSeparate(t,e._gd._fullLayout.separators)}if(s&&"hide"!==l){var p;p=0>s?"\u2212"+-s:"power"!==l?"+"+s:String(s),"e"===l||("SI"===l||"B"===l)&&(s>12||-15>s)?t+="e"+p:"E"===l?t+="E"+p:"power"===l?t+="\xd710"+p+"":"B"===l&&9===s?t+="B":"SI"!==l&&"B"!==l||(t+=H[s/3+5])}return a?"\u2212"+t:t}function h(t,e){var n,r,a=[];for(n=0;n1)for(r=1;r2e-6||((n-t._forceTick0)/t._minDtick%1+1.000001)%1>2e-6)&&(t._minDtick=0)):t._minDtick=0},T.getAutoRange=function(t){var e,n=[],r=t._min[0].val,a=t._max[0].val;for(e=1;e0&&u>0&&f/u>d&&(s=i,c=l,d=f/u);return r===a?n=h?[r+1,"normal"!==t.rangemode?0:r-1]:["normal"!==t.rangemode?0:r-1,r+1]:d&&("linear"!==t.type&&"-"!==t.type||("tozero"===t.rangemode&&s.val>=0?s={val:0,pad:0}:"nonnegative"===t.rangemode&&(s.val-d*s.pad<0&&(s={val:0,pad:0}),c.val<0&&(c={val:1,pad:0})),d=(c.val-s.val)/(t._length-s.pad-c.pad)),n=[s.val-d*s.pad,c.val+d*c.pad],n[0]===n[1]&&(n=[n[0]-1,n[0]+1]),h&&n.reverse()),n},T.doAutoRange=function(t){t._length||t.setScale();var e=t._min&&t._max&&t._min.length&&t._max.length;if(t.autorange&&e){t.range=T.getAutoRange(t);var n=t._gd.layout[t._name];n||(t._gd.layout[t._name]=n={}),n!==t&&(n.range=t.range.slice(),n.autorange=t.autorange)}},T.saveRangeInitial=function(t,e){for(var n=T.list(t,"",!0),r=!1,a=0;ap&&(p=g/10),c=t.c2l(p),u=t.c2l(g),y&&(c=Math.min(0,c),u=Math.max(0,u)),r(c)){for(h=!0,i=0;i=d?h=!1:l.val>=c&&l.pad<=d&&(t._min.splice(i,1),i--);h&&t._min.push({val:c,pad:y&&0===c?0:d})}if(r(u)){for(h=!0,i=0;i=u&&l.pad>=f?h=!1:l.val<=u&&l.pad<=f&&(t._max.splice(i,1),i--);h&&t._max.push({val:u,pad:y&&0===u?0:f})}}}if((t.autorange||t._needsExpand)&&e){t._min||(t._min=[]),t._max||(t._max=[]),n||(n={}),t._m||t.setScale();var o,i,l,s,c,u,f,d,h,p,g,v=e.length,m=n.padded?.05*t._length:0,y=n.tozero&&("linear"===t.type||"-"===t.type),b=r((t._m>0?n.ppadplus:n.ppadminus)||n.ppad||0),_=r((t._m>0?n.ppadminus:n.ppadplus)||n.ppad||0),w=r(n.vpadplus||n.vpad),k=r(n.vpadminus||n.vpad);for(o=0;6>o;o++)a(o);for(o=v-1;o>5;o--)a(o)}},T.autoBin=function(t,e,n,r){function a(t){return(1+100*(t-h)/f.dtick)%100<2}var o=_.aggNums(Math.min,null,t),i=_.aggNums(Math.max,null,t);if("category"===e.type)return{start:o-.5,end:i+.5,size:1};var l;if(n)l=(i-o)/n;else{var s=_.distinctVals(t),c=Math.pow(10,Math.floor(Math.log(s.minDiff)/Math.LN10)),u=c*_.roundUp(s.minDiff/c,[.9,1.9,4.9,9.9],!0);l=Math.max(u,2*_.stdev(t)/Math.pow(t.length,r?.25:.4))}var f={type:"log"===e.type?"linear":e.type,range:[o,i]};T.autoTicks(f,l);var d,h=T.tickIncrement(T.tickFirst(f),f.dtick,"reverse");if("number"==typeof f.dtick){for(var p=0,g=0,v=0,m=0,y=0;yg&&(p>.3*b||a(o)||a(i))){var w=f.dtick/2;h+=o>h+w?w:-w}var k=1+Math.floor((i-h)/f.dtick);d=h+k*f.dtick}else for(d=h;i>=d;)d=T.tickIncrement(d,f.dtick);return{start:h,end:d,size:f.dtick}},T.calcTicks=function(t){if("array"===t.tickmode)return r(t);if("auto"===t.tickmode||!t.dtick){var e,n=t.nticks;n||("category"===t.type?(e=t.tickfont?1.2*(t.tickfont.size||12):15,n=t._length/e):(e="y"===t._id.charAt(0)?40:80,n=_.constrain(t._length/e,4,9)+1)),T.autoTicks(t,Math.abs(t.range[1]-t.range[0])/n),t._minDtick>0&&t.dtick<2*t._minDtick&&(t.dtick=t._minDtick,t.tick0=t._forceTick0)}t.tick0||(t.tick0="date"===t.type?new Date(2e3,0,1).getTime():0),o(t),t._tmin=T.tickFirst(t);var a=t.range[1]=l:l>=s)&&(i.push(s),!(i.length>1e3));s=T.tickIncrement(s,t.dtick,a));t._tmax=i[i.length-1];for(var c=new Array(i.length),u=0;u157788e5?(e/=315576e5,n=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick="M"+12*a(e,n,S)):e>12096e5?(e/=26298e5,t.dtick="M"+a(e,1,C)):e>432e5?(t.dtick=a(e,864e5,O),t.tick0=new Date(2e3,0,2).getTime()):e>18e5?t.dtick=a(e,36e5,C):e>3e4?t.dtick=a(e,6e4,E):e>500?t.dtick=a(e,1e3,E):(n=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick=a(e,n,S));else if("log"===t.type)if(t.tick0=0,e>.7)t.dtick=Math.ceil(e);else if(Math.abs(t.range[1]-t.range[0])<1){var r=1.5*Math.abs((t.range[1]-t.range[0])/e);e=Math.abs(Math.pow(10,t.range[1])-Math.pow(10,t.range[0]))/r,n=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick="L"+a(e,n,S)}else t.dtick=e>.3?"D2":"D1";else"category"===t.type?(t.tick0=0,t.dtick=Math.ceil(Math.max(e,1))):(t.tick0=0,n=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick=a(e,n,S));if(0===t.dtick&&(t.dtick=1),!x(t.dtick)&&"string"!=typeof t.dtick){var o=t.dtick;throw t.dtick=1,"ax.dtick error: "+String(o)}},T.tickIncrement=function(t,e,n){var r=n?-1:1;if(x(e))return t+r*e;var a=e.charAt(0),o=r*Number(e.substr(1));if("M"===a){var i=new Date(t);return i.setMonth(i.getMonth()+o)}if("L"===a)return Math.log(Math.pow(10,t)+o)/Math.LN10;if("D"===a){var l="D2"===e?N:P,s=t+.01*r,c=_.roundUp(m(s,1),l,n);return Math.floor(s)+Math.log(y.round(Math.pow(10,c),1))/Math.LN10}throw"unrecognized dtick "+String(e)},T.tickFirst=function(t){var e=t.range[1]r:r>c;)c=T.tickIncrement(c,a,e);return c}if("L"===u)return Math.log(n((Math.pow(10,r)-o)/f)*f+o)/Math.LN10;if("D"===u){var d="D2"===a?N:P,h=_.roundUp(m(r,1),d,e);return Math.floor(r)+Math.log(y.round(Math.pow(10,h),1))/Math.LN10}throw"unrecognized dtick "+String(a)};var D=y.time.format("%Y"),I=y.time.format("%b %Y"),R=y.time.format("%b %-d"),j=y.time.format("%b %-d %Hh"),F=y.time.format("%H:%M"),q=y.time.format(":%S"),B=/%(\d?)f/g;T.tickText=function(t,e,n){function r(r){var a;return void 0===r?!0:n?"none"===r:(a={first:t._tmin,last:t._tmax}[r],"all"!==r&&e!==a)}var a,o,i=l(t,e),d="array"===t.tickmode,h=n||d;if(d&&Array.isArray(t.ticktext)){var p=Math.abs(t.range[1]-t.range[0])/1e4;for(o=0;o1&&en&&(M=90),a(u,M)}c._lastangle=M}return i(e),e+" done"}function s(){c._boundingBox=n.node().getBoundingClientRect()}var u=n.selectAll("g."+C).data(z,S);if(!c.showticklabels||!x(r))return u.remove(),void i(e);var f,d,p,m,b;"x"===v?(b="bottom"===q?1:-1,f=function(t){return t.dx+D*b},m=r+(N+P)*b,d=function(t){return t.dy+m+t.fontSize*("bottom"===q?1:-.5)},p=function(t){return x(t)&&0!==t&&180!==t?0>t*b?"end":"start":"middle"}):(b="right"===q?1:-1,d=function(t){return t.dy+t.fontSize/2-D*b},f=function(t){return t.dx+r+(N+P+(90===Math.abs(c.tickangle)?t.fontSize/2:0))*b},p=function(t){return x(t)&&90===Math.abs(t)?"middle":"right"===q?"start":"end"});var k=0,M=0,T=[];u.enter().append("g").classed(C,1).append("text").attr("text-anchor","middle").each(function(e){var n=y.select(this),r=t._promises.length;n.call(A.setPosition,f(e),d(e)).call(A.font,e.font,e.fontSize,e.fontColor).text(e.text).call(w.convertToTspans), +-r=t._promises[r],r?T.push(t._promises.pop().then(function(){a(n,c.tickangle)})):a(n,c.tickangle)}),u.exit().remove(),u.each(function(t){k=Math.max(k,t.fontSize)}),a(u,c._lastangle||c.tickangle);var L=_.syncOrAsync([o,l,s]);return L&&L.then&&t._promises.push(L),L}function i(e){if(!n){var r,a,o,i,l=L.getFromId(t,e),s=y.select(t).selectAll("g."+e+"tick"),c={selection:s,side:l.side},f=e.charAt(0),d=t._fullLayout._size,h=1.5,p=l.titlefont.size;if(s.size()){var g=y.select(s.node().parentNode).attr("transform").match(/translate\(([-\.\d]+),([-\.\d]+)\)/);g&&(c.offsetLeft=+g[1],c.offsetTop=+g[2])}"x"===f?(a="free"===l.anchor?{_offset:d.t+(1-(l.position||0))*d.h,_length:0}:L.getFromId(t,l.anchor),o=l._offset+l._length/2,i=a._offset+("top"===l.side?-10-p*(h+(l.showticklabels?1:0)):a._length+10+p*(h+(l.showticklabels?1.5:.5))),l.rangeslider&&l.rangeslider.visible&&l._boundingBox&&(i+=(u.height-u.margin.b-u.margin.t)*l.rangeslider.thickness+l._boundingBox.height),c.side||(c.side="bottom")):(a="free"===l.anchor?{_offset:d.l+(l.position||0)*d.w,_length:0}:L.getFromId(t,l.anchor),i=l._offset+l._length/2,o=a._offset+("right"===l.side?a._length+10+p*(h+(l.showticklabels?1:.5)):-10-p*(h+(l.showticklabels?.5:0))),r={rotate:"-90",offset:0},c.side||(c.side="left")),k.draw(t,e+"title",{propContainer:l,propName:l._name+".title",dfltName:f.toUpperCase()+" axis",avoid:c,transform:r,attributes:{x:o,y:i,"text-anchor":"middle"}})}}function l(t,e){return t.visible!==!0||t.xaxis+t.yaxis!==e?!1:b.Plots.traceIs(t,"bar")&&t.orientation==={x:"h",y:"v"}[v]?!0:t.fill&&t.fill.charAt(t.fill.length-1)===v}function s(e,n,a){var o=e.gridlayer,i=e.zerolinelayer,s=e["hidegrid"+v]?[]:H,u=c._gridpath||"M0,0"+("x"===v?"v":"h")+n._length,f=o.selectAll("path."+E).data(c.showgrid===!1?[]:s,S);if(f.enter().append("path").classed(E,1).classed("crisp",1).attr("d",u).each(function(t){c.zeroline&&("linear"===c.type||"-"===c.type)&&Math.abs(t.x)g;g++){var y=c.mirrors[i._id+d[g]];"ticks"!==y&&"labels"!==y||(f[g]=!0)}return void 0!==r[2]&&(f[2]=!0),f.forEach(function(t,e){var n=r[e],a=B[e];t&&x(n)&&(h+=p(n+P*a,a*c.ticklen))}),a(n,h),s(e,i,t),o(n,r[3])}}).filter(function(t){return t&&t.then});return Z.length?Promise.all(Z):0},T.swap=function(t,e){for(var n=h(t,e),r=0;r2*r}function u(t){for(var e,n=Math.max(1,(t.length-1)/1e3),r=0,a=0,o=0;o2*r}var f=t("fast-isnumeric"),d=t("tinycolor2").mix,h=t("../../lib"),p=t("../plots"),g=t("../../components/color/attributes").lightFraction,v=t("./layout_attributes"),m=t("./tick_value_defaults"),y=t("./tick_mark_defaults"),x=t("./tick_label_defaults"),b=t("./category_order_defaults"),_=t("./set_convert"),w=t("./ordered_categories"),k=t("./clean_datum"),M=t("./axis_ids");e.exports=function(t,e,n,a){function o(n,r){return h.coerce2(t,e,v,n,r)}var i=a.letter,l=a.font||{},s="Click to enter "+(a.title||i.toUpperCase()+" axis")+" title";a.name&&(e._name=a.name,e._id=M.name2id(a.name));var c=n("type");"-"===c&&(r(e,a.data),"-"===e.type?e.type="linear":c=t.type=e.type),_(e);var u=n("color"),p=u===t.color?u:l.color;n("title",s),h.coerceFont(n,"titlefont",{family:l.family,size:Math.round(1.2*l.size),color:p});var k=2===(t.range||[]).length&&f(t.range[0])&&f(t.range[1]),A=n("autorange",!k);A&&n("rangemode");var T=n("range",[-1,"x"===i?6:4]);T[0]===T[1]&&(e.range=[T[0]-1,T[0]+1]),h.noneOrAll(t.range,e.range,[0,1]),n("fixedrange"),m(t,e,n,c),x(t,e,n,c,a),y(t,e,n,a),b(t,e,n);var L=o("linecolor",u),z=o("linewidth"),S=n("showline",!!L||!!z);S||(delete e.linecolor,delete e.linewidth),(S||e.ticks)&&n("mirror");var C=o("gridcolor",d(u,a.bgColor,g).toRgbString()),E=o("gridwidth"),O=n("showgrid",a.showGrid||!!C||!!E);O||(delete e.gridcolor,delete e.gridwidth);var P=o("zerolinecolor",u),N=o("zerolinewidth"),D=n("zeroline",a.showGrid||!!P||!!N);return D||(delete e.zerolinecolor,delete e.zerolinewidth),e._initialCategories="category"===c?w(i,e.categoryorder,e.categoryarray,a.data):[],e}},{"../../components/color/attributes":17,"../../lib":94,"../plots":135,"./axis_ids":117,"./category_order_defaults":118,"./clean_datum":119,"./layout_attributes":124,"./ordered_categories":126,"./set_convert":129,"./tick_label_defaults":130,"./tick_mark_defaults":131,"./tick_value_defaults":132,"fast-isnumeric":11,tinycolor2:13}],117:[function(t,e,n){"use strict";function r(t,e,n){function r(t,n){for(var r=Object.keys(t),a=/^[xyz]axis[0-9]*/,o=[],i=0;i0;o&&(r="array");var i=n("categoryorder",r);"array"===i&&n("categoryarray"),o||"array"!==i||(e.categoryorder="trace")}}},{}],119:[function(t,e,n){"use strict";var r=t("fast-isnumeric"),a=t("../../lib");e.exports=function(t){try{if("object"==typeof t&&null!==t&&t.getTime)return a.ms2DateTime(t);if("string"!=typeof t&&!r(t))return"";t=t.toString().replace(/['"%,$# ]/g,"")}catch(e){a.error(e,t)}return t}},{"../../lib":94,"fast-isnumeric":11}],120:[function(t,e,n){"use strict";e.exports={idRegex:{x:/^x([2-9]|[1-9][0-9]+)?$/,y:/^y([2-9]|[1-9][0-9]+)?$/},attrRegex:{x:/^xaxis([2-9]|[1-9][0-9]+)?$/,y:/^yaxis([2-9]|[1-9][0-9]+)?$/},BADNUM:void 0,xAxisMatch:/^xaxis[0-9]*$/,yAxisMatch:/^yaxis[0-9]*$/,AX_ID_PATTERN:/^[xyz][0-9]*$/,AX_NAME_PATTERN:/^[xyz]axis[0-9]*$/,DBLCLICKDELAY:300,MINDRAG:8,MINSELECT:12,MINZOOM:20,DRAGGERSIZE:20,MAXDIST:20,YANGLE:60,HOVERARROWSIZE:6,HOVERTEXTPAD:3,HOVERFONTSIZE:13,HOVERFONT:"Arial, sans-serif",HOVERMINTIME:50,BENDPX:1.5,REDRAWDELAY:50}},{}],121:[function(t,e,n){"use strict";function r(t,e){var n,r=t.range[e],a=Math.abs(r-t.range[1-e]);return"date"===t.type?u.ms2DateTime(r,a):"log"===t.type?(n=Math.ceil(Math.max(0,-Math.log(a)/Math.LN10))+3,l.format("."+n+"g")(Math.pow(10,r))):(n=Math.floor(Math.log(Math.abs(r))/Math.LN10)-Math.floor(Math.log(a)/Math.LN10)+4,l.format("."+String(n)+"g")(r))}function a(t,e){return t?"nsew"===t?"pan"===e?"move":"crosshair":t.toLowerCase()+"-resize":"pointer"}function o(t){l.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}function i(t){var e=["lasso","select"];return-1!==e.indexOf(t)}var l=t("d3"),s=t("tinycolor2"),c=t("../../plotly"),u=t("../../lib"),f=t("../../lib/svg_text_utils"),d=t("../../components/color"),h=t("../../components/drawing"),p=t("../../lib/setcursor"),g=t("../../components/dragelement"),v=t("./axes"),m=t("./select"),y=t("./constants"),x=!0;e.exports=function(t,e,n,l,b,_,w,k){function M(t,e){for(var n=0;n.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("transform","translate("+pt+", "+gt+")").attr("d",st+"Z"),dt=ht.append("path").attr("class","zoombox-corners").style({fill:d.background,stroke:d.defaultLine,"stroke-width":1,opacity:0}).attr("transform","translate("+pt+", "+gt+")").attr("d","M0,0Z"),L();for(var o=0;oa?(ut="",it.r=it.l,it.t=it.b,dt.attr("d","M0,0Z")):(it.t=0,it.b=V,ut="x",dt.attr("d","M"+(it.l-.5)+","+(ot-Y-.5)+"h-3v"+(2*Y+1)+"h3ZM"+(it.r+.5)+","+(ot-Y-.5)+"h3v"+(2*Y+1)+"h-3Z")):!W||a.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),dt.transition().style("opacity",1).duration(200),ct=!0)}function S(t,e,n){var r,a,o;for(r=0;rzoom back out","long"),x=!1)))}function E(e,n){var a=1===(w+k).length;if(e)I();else if(2!==n||a){if(1===n&&a){var o=w?B[0]:q[0],i="s"===w||"w"===k?0:1,l=o._name+".range["+i+"]",s=r(o,i),u="left",d="middle";if(o.fixedrange)return;w?(d="n"===w?"top":"bottom","right"===o.side&&(u="right")):"e"===k&&(u="right"),et.call(f.makeEditable,null,{immediate:!0,background:j.paper_bgcolor,text:String(s),fill:o.tickfont?o.tickfont.color:"#444",horizontalAlign:u,verticalAlign:d}).on("edit",function(e){var n="category"===o.type?o.c2l(e):o.d2l(e);void 0!==n&&c.relayout(t,l,n)})}}else D()}function O(e){function n(t,e,n){if(!t.fixedrange){A(t.range);var r=t.range,a=r[0]+(r[1]-r[0])*e;t.range=[a+(r[0]-a)*n,a+(r[1]-a)*n]}}if(t._context.scrollZoom||j._enablescrollzoom){var r=t.querySelector(".plotly");if(!(r.scrollHeight-r.clientHeight>10||r.scrollWidth-r.clientWidth>10)){clearTimeout(mt);var a=-e.deltaY;if(isFinite(a)||(a=e.wheelDelta/10),!isFinite(a))return void u.log("Did not find wheel motion attributes: ",e);var o,i=Math.exp(-Math.min(Math.max(a,-20),20)/100),l=xt.draglayer.select(".nsewdrag").node().getBoundingClientRect(),s=(e.clientX-l.left)/l.width,c=vt[0]+vt[2]*s,f=(l.bottom-e.clientY)/l.height,d=vt[1]+vt[3]*(1-f);if(k){for(o=0;o=0?Math.min(t,.9):1/(1/Math.max(t,-.3)+3.222))}function a(t,e,n){for(var a=1-e,o=0,i=0;i0;r--)n.push(e);return n}function a(t,e){for(var n=[],r=0;rT;T++){var L=o[T],z=h[L];if(z)M[T]=w.getFromId(t,z.xaxis._id),A[T]=w.getFromId(t,z.yaxis._id);else{var S=i[L]._subplot;M[T]=S.xaxis,A[T]=S.yaxis}}var C=e.hovermode||i.hovermode;if(-1===["x","y","closest"].indexOf(C)||!t.calcdata||t.querySelector(".zoombox")||t._dragging)return _.unhoverRaw(t,e);var E,O,P,N,D,I,R,j,F,q,B,H,V=[],Z=[];if(Array.isArray(e))for(C="array",P=0;PY||Y>X.width||0>U||U>X.height)return _.unhoverRaw(t,e)}else Y="xpx"in e?e.xpx:M[0]._length/2,U="ypx"in e?e.ypx:A[0]._length/2;if(E="xval"in e?r(o,e.xval):a(M,Y),O="yval"in e?r(o,e.yval):a(A,U),!g(E[0])||!g(O[0]))return v.warn("Plotly.Fx.hover failed",e,t),_.unhoverRaw(t,e)}var G=1/0;for(N=0;N1||-1!==I.hoverinfo.indexOf("name")?I.name:void 0,index:!1,distance:Math.min(G,k.MAXDIST),color:x.defaultLine,x0:void 0,x1:void 0,y0:void 0,y1:void 0,xLabelVal:void 0,yLabelVal:void 0,zLabelVal:void 0,text:void 0},H=V.length,"array"===j){var $=e[N];"pointNumber"in $?(B.index=$.pointNumber,j="closest"):(j="","xval"in $&&(F=$.xval,j="x"),"yval"in $&&(q=$.yval,j=j?"closest":"y"))}else F=E[R],q=O[R];if(I._module&&I._module.hoverPoints){var Q=I._module.hoverPoints(B,F,q,j);if(Q)for(var W,J=0;JH&&(V.splice(0,H),G=V[0].distance)}if(0===V.length)return _.unhoverRaw(t,e);var K="y"===C&&Z.length>1;V.sort(function(t,e){return t.distance-e.distance});var tt=x.combine(i.plot_bgcolor||x.background,i.paper_bgcolor),et={hovermode:C,rotateLabels:K,bgColor:tt,container:i._hoverlayer,outerContainer:i._paperdiv},nt=c(V,et);u(V,K?"xa":"ya"),f(nt,K);var rt=t._hoverdata,at=[];for(P=0;P128?"#000":x.background;if(t.name&&void 0===t.zLabelVal){var u=document.createElement("p");u.innerHTML=t.name,n=u.textContent||"",n.length>15&&(n=n.substr(0,12)+"...")}void 0!==t.extraText&&(r+=t.extraText),void 0!==t.zLabel?(void 0!==t.xLabel&&(r+="x: "+t.xLabel+"
"),void 0!==t.yLabel&&(r+="y: "+t.yLabel+"
"),r+=(r?"z: ":"")+t.zLabel):A&&t[a+"Label"]===g?r=t[("x"===a?"y":"x")+"Label"]||"":void 0===t.xLabel?void 0!==t.yLabel&&(r=t.yLabel):r=void 0===t.yLabel?t.xLabel:"("+t.xLabel+", "+t.yLabel+")",t.text&&!Array.isArray(t.text)&&(r+=(r?"
":"")+t.text),""===r&&(""===n&&e.remove(),r=n);var f=e.select("text.nums").style("fill",c).call(b.setPosition,0,0).text(r).attr("data-notex",1).call(y.convertToTspans);f.selectAll("tspan.line").call(b.setPosition,0,0);var d=e.select("text.name"),v=0;n&&n!==r?(d.style("fill",s).text(n).call(b.setPosition,0,0).attr("data-notex",1).call(y.convertToTspans),d.selectAll("tspan.line").call(b.setPosition,0,0),v=d.node().getBoundingClientRect().width+2*O):(d.remove(),e.select("rect").remove()),e.select("path").style({fill:s,stroke:c});var m,k,L=f.node().getBoundingClientRect(),z=t.xa._offset+(t.x0+t.x1)/2,S=t.ya._offset+(t.y0+t.y1)/2,C=Math.abs(t.x1-t.x0),P=Math.abs(t.y1-t.y0),N=L.width+E+O+v;t.ty0=_-L.top,t.bx=L.width+2*O,t.by=L.height+2*O,t.anchor="start",t.txwidth=L.width,t.tx2width=v,t.offset=0,o?(t.pos=z,m=M>=S+P/2+N,k=S-P/2-N>=0,"top"!==t.idealAlign&&m||!k?m?(S+=P/2,t.anchor="start"):t.anchor="middle":(S-=P/2,t.anchor="end")):(t.pos=S,m=w>=z+C/2+N,k=z-C/2-N>=0,"left"!==t.idealAlign&&m||!k?m?(z+=C/2,t.anchor="start"):t.anchor="middle":(z-=C/2,t.anchor="end")),f.attr("text-anchor",t.anchor),v&&d.attr("text-anchor",t.anchor),e.attr("transform","translate("+z+","+S+")"+(o?"rotate("+T+")":""))}),S}function u(t,e){function n(t){var e=t[0],n=t[t.length-1];if(a=e.pmin-e.pos-e.dp+e.size,o=n.pos+n.dp+n.size-e.pmax,a>.01){for(l=t.length-1;l>=0;l--)t[l].dp+=a;r=!1}if(!(.01>o)){if(-.01>a){for(l=t.length-1;l>=0;l--)t[l].dp-=o;r=!1}if(r){var c=0;for(i=0;ie.pmax&&c++;for(i=t.length-1;i>=0&&!(0>=c);i--)s=t[i],s.pos>e.pmax-1&&(s.del=!0,c--);for(i=0;i=c);i++)if(s=t[i],s.pos=0;l--)t[l].dp-=o;for(i=t.length-1;i>=0&&!(0>=c);i--)s=t[i],s.pos+s.dp+s.size>e.pmax&&(s.del=!0,c--)}}}for(var r,a,o,i,l,s,c,u=0,f=t.map(function(t,n){var r=t[e];return[{i:n,dp:0,pos:t.pos,posref:t.posref,size:t.by*("x"===r._id.charAt(0)?z:1)/2,pmin:r._offset,pmax:r._offset+r._length}]}).sort(function(t,e){return t[0].posref-e[0].posref});!r&&u<=t.length;){for(u++,r=!0,i=0;i.01&&p.pmin===g.pmin&&p.pmax===g.pmax){for(l=h.length-1;l>=0;l--)h[l].dp+=a;for(d.push.apply(d,h),f.splice(i+1,1),c=0,l=d.length-1;l>=0;l--)c+=d[l].dp;for(o=c/d.length,l=d.length-1;l>=0;l--)d[l].dp-=o;r=!1}else i++}f.forEach(n)}for(i=f.length-1;i>=0;i--){var v=f[i];for(l=v.length-1;l>=0;l--){var m=v[l],y=t[m.i];y.offset=m.dp,y.del=m.del}}}function f(t,e){t.each(function(t){var n=h.select(this);if(t.del)return void n.remove();var r="end"===t.anchor?-1:1,a=n.select("text.nums"),o={start:1,end:-1,middle:0}[t.anchor],i=o*(E+O),l=i+o*(t.txwidth+O),s=0,c=t.offset;"middle"===t.anchor&&(i-=t.tx2width/2,l-=t.tx2width/2),e&&(c*=-C,s=t.offset*S),n.select("path").attr("d","middle"===t.anchor?"M-"+t.bx/2+",-"+t.by/2+"h"+t.bx+"v"+t.by+"h-"+t.bx+"Z":"M0,0L"+(r*E+s)+","+(E+c)+"v"+(t.by/2-E)+"h"+r*t.bx+"v-"+t.by+"H"+(r*E+s)+"V"+(c-E)+"Z"),a.call(b.setPosition,i+s,c+t.ty0-t.by/2+O).selectAll("tspan.line").attr({x:a.attr("x"),y:a.attr("y")}),t.tx2width&&(n.select("text.name, text.name tspan.line").call(b.setPosition,l+o*O+s,c+t.ty0-t.by/2+O),n.select("rect").call(b.setRect,l+(o-1)*t.tx2width/2+s,c-t.by/2-1,t.tx2width,t.by+2))})}function d(t,e,n){if(!e.target)return!1;if(!n||n.length!==t._hoverdata.length)return!0;for(var r=n.length-1;r>=0;r--){var a=n[r],o=t._hoverdata[r];if(a.curveNumber!==o.curveNumber||String(a.pointNumber)!==String(o.pointNumber))return!0}return!1}var h=t("d3"),p=t("tinycolor2"),g=t("fast-isnumeric"),v=t("../../lib"),m=t("../../lib/events"),y=t("../../lib/svg_text_utils"),x=t("../../components/color"),b=t("../../components/drawing"),_=t("../../components/dragelement"),w=t("./axes"),k=t("./constants"),M=t("./dragbox"),A=e.exports={};A.unhover=_.unhover,A.layoutAttributes={dragmode:{valType:"enumerated",values:["zoom","pan","select","lasso","orbit","turntable"],dflt:"zoom"},hovermode:{valType:"enumerated",values:["x","y","closest",!1]}},A.supplyLayoutDefaults=function(t,e,n){function r(n,r){return v.coerce(t,e,A.layoutAttributes,n,r)}r("dragmode");var a;if(e._has("cartesian")){var o=e._isHoriz=A.isHoriz(n);a=o?"y":"x"}else a="closest";r("hovermode",a)},A.isHoriz=function(t){for(var e=!0,n=0;nt._lastHoverTime+k.HOVERMINTIME?(i(t,e,n),void(t._lastHoverTime=Date.now())):void(t._hoverTimer=setTimeout(function(){i(t,e,n),t._lastHoverTime=Date.now(),t._hoverTimer=void 0},k.HOVERMINTIME))},A.getDistanceFunction=function(t,e,n,r){return"closest"===t?r||o(e,n):"x"===t?e:n},A.getClosest=function(t,e,n){if(n.index!==!1)n.index>=0&&n.indext*e||0===t?k.MAXDIST*(.6-.3/Math.max(3,Math.abs(t-e))):1/0}},{"../../components/color":18,"../../components/dragelement":39,"../../components/drawing":41,"../../lib":94,"../../lib/events":92,"../../lib/svg_text_utils":105,"./axes":115,"./constants":120,"./dragbox":121,d3:9,"fast-isnumeric":11,tinycolor2:13}],123:[function(t,e,n){"use strict";var r=t("../plots"),a=t("./constants");n.name="cartesian",n.attr=["xaxis","yaxis"],n.idRoot=["x","y"],n.idRegex=a.idRegex,n.attrRegex=a.attrRegex,n.attributes=t("./attributes"),n.plot=function(t){function e(t,e){for(var n=[],r=0;rf[1]-.01&&(e.domain=[0,1]),a.noneOrAll(t.domain,e.domain,[0,1])}return e}},{"../../lib":94,"fast-isnumeric":11}],128:[function(t,e,n){"use strict";function r(t){return t._id}var a=t("../../lib/polygon"),o=t("../../components/color"),i=t("./axes"),l=t("./constants"),s=a.filter,c=a.tester,u=l.MINSELECT;e.exports=function(t,e,n,a,f){function d(t){var e="y"===t._id.charAt(0)?1:0;return function(n){return t.p2d(n[e])}}function h(t,e){return t-e}var p,g=a.gd._fullLayout._zoomlayer,v=a.element.getBoundingClientRect(),m=a.plotinfo.x()._offset,y=a.plotinfo.y()._offset,x=e-v.left,b=n-v.top,_=x,w=b,k="M"+x+","+b,M=a.xaxes[0]._length,A=a.yaxes[0]._length,T=a.xaxes.map(r),L=a.yaxes.map(r),z=a.xaxes.concat(a.yaxes);"lasso"===f&&(p=s([[x,b]],l.BENDPX));var S=g.selectAll("path.select-outline").data([1,2]);S.enter().append("path").attr("class",function(t){return"select-outline select-outline-"+t}).attr("transform","translate("+m+", "+y+")").attr("d",k+"Z");var C,E,O,P,N,D=g.append("path").attr("class","zoombox-corners").style({fill:o.background,stroke:o.defaultLine,"stroke-width":1}).attr("transform","translate("+m+", "+y+")").attr("d","M0,0Z"),I=[],R=a.gd,j=[];for(C=0;C0)return Math.log(e)/Math.LN10;if(0>=e&&n&&t.range&&2===t.range.length){var r=t.range[0],a=t.range[1];return.5*(r+a-3*u*Math.abs(r-a))}return i.BADNUM}function n(t){return Math.pow(10,t)}function c(t){return a(t)?Number(t):i.BADNUM}var u=10;if(t.c2l="log"===t.type?e:c,t.l2c="log"===t.type?n:c,t.l2d=function(e){return t.c2d(t.l2c(e))},t.p2d=function(e){return t.l2d(t.p2l(e))},t.setScale=function(){var e,n=t._gd._fullLayout._size;if(t._categories||(t._categories=[]),t.overlaying){var r=s.getFromId(t._gd,t.overlaying);t.domain=r.domain}for(t.range&&2===t.range.length&&t.range[0]!==t.range[1]||(t.range=[-1,1]),e=0;2>e;e++)a(t.range[e])||(t.range[e]=a(t.range[1-e])?t.range[1-e]*(e?10:.1):e?1:-1),t.range[e]<-(Number.MAX_VALUE/2)?t.range[e]=-(Number.MAX_VALUE/2):t.range[e]>Number.MAX_VALUE/2&&(t.range[e]=Number.MAX_VALUE/2);if("y"===t._id.charAt(0)?(t._offset=n.t+(1-t.domain[1])*n.h,t._length=n.h*(t.domain[1]-t.domain[0]),t._m=t._length/(t.range[0]-t.range[1]),t._b=-t._m*t.range[1]):(t._offset=n.l+t.domain[0]*n.w,t._length=n.w*(t.domain[1]-t.domain[0]),t._m=t._length/(t.range[1]-t.range[0]),t._b=-t._m*t.range[0]),!isFinite(t._m)||!isFinite(t._b))throw o.notifier("Something went wrong with axis scaling","long"),t._gd._replotting=!1,new Error("axis scaling")},t.l2p=function(e){return a(e)?r.round(t._b+t._m*e,2):i.BADNUM},t.p2l=function(e){return(e-t._b)/t._m},t.c2p=function(e,n){return t.l2p(t.c2l(e,n))},t.p2c=function(e){return t.l2c(t.p2l(e))},-1!==["linear","log","-"].indexOf(t.type))t.c2d=c,t.d2c=function(t){return t=l(t),a(t)?Number(t):i.BADNUM},t.d2l=function(e,n){return"log"===t.type?t.c2l(t.d2c(e),n):t.d2c(e)};else if("date"===t.type){if(t.c2d=function(t){return a(t)?o.ms2DateTime(t):i.BADNUM},t.d2c=function(t){return a(t)?Number(t):o.dateTime2ms(t)},t.d2l=t.d2c,t.range&&t.range.length>1)try{var f=t.range.map(o.dateTime2ms);!a(t.range[0])&&a(f[0])&&(t.range[0]=f[0]),!a(t.range[1])&&a(f[1])&&(t.range[1]=f[1])}catch(d){o.error(d,t.range)}}else"category"===t.type&&(t.c2d=function(e){return t._categories[Math.round(e)]},t.d2c=function(e){null!==e&&void 0!==e&&-1===t._categories.indexOf(e)&&t._categories.push(e);var n=t._categories.indexOf(e);return-1===n?i.BADNUM:n},t.d2l=t.d2c);t.makeCalcdata=function(e,n){var r,a,o;if(n in e)for(r=e[n],a=new Array(r.length),o=0;o=e.width-20?(o["text-anchor"]="start",o.x=5):(o["text-anchor"]="end",o.x=e._paper.attr("width")-7),n.attr(o);var i=n.select(".js-link-to-tool"),l=n.select(".js-link-spacer"),c=n.select(".js-sourcelinks");t._context.showSources&&t._context.showSources(t),t._context.showLink&&a(t,i),l.text(i.text()&&c.text()?" - ":"")},h.sendDataToCloud=function(t){t.emit("plotly_beforeexport");var e=window.PLOTLYENV&&window.PLOTLYENV.BASE_URL||"https://plot.ly",n=s.select(t).append("div").attr("id","hiddenform").style("display","none"),r=n.append("form").attr({action:e+"/external",method:"post",target:"_blank"}),a=r.append("input").attr({type:"text",name:"data"});return a.node().value=h.graphJson(t,!1,"keepdata"),r.node().submit(),n.remove(),t.emit("plotly_afterexport"),!1},h.supplyDefaults=function(t){var e,n=t._fullLayout||{},r=t._fullLayout={},a=t.layout||{},i=t._fullData||[],l=t._fullData=[],s=t.data||[];h.supplyLayoutGlobalDefaults(a,r),r._dataLength=s.length,h.supplyDataDefaults(s,l,r),r._has=h._hasPlotType.bind(r);var c=r._modules;for(e=0;eo&&(e=(n-1)/(a.l+a.r),a.l=Math.floor(e*a.l),a.r=Math.floor(e*a.r)),0>i&&(e=(r-1)/(a.t+a.b),a.t=Math.floor(e*a.t),a.b=Math.floor(e*a.b))}},h.autoMargin=function(t,e,n){var r=t._fullLayout;if(r._pushmargin||(r._pushmargin={}),r.margin.autoexpand!==!1){if(n){var a=void 0===n.pad?12:n.pad;n.l+n.r>.5*r.width&&(n.l=n.r=0),n.b+n.t>.5*r.height&&(n.b=n.t=0),r._pushmargin[e]={l:{val:n.x,size:n.l+a},r:{val:n.x,size:n.r+a},b:{val:n.y,size:n.b+a},t:{val:n.y,size:n.t+a}}}else delete r._pushmargin[e];t._replotting||h.doAutoMargin(t)}},h.doAutoMargin=function(t){var e=t._fullLayout;e._size||(e._size={}),e._pushmargin||(e._pushmargin={});var n=e._size,r=JSON.stringify(n),a=Math.max(e.margin.l||0,0),o=Math.max(e.margin.r||0,0),i=Math.max(e.margin.t||0,0),l=Math.max(e.margin.b||0,0),s=e._pushmargin;return e.margin.autoexpand!==!1&&(s.base={l:{val:0,size:a},r:{val:1,size:o},t:{val:1,size:i},b:{val:0,size:l}},Object.keys(s).forEach(function(t){var n=s[t].l||{},r=s[t].b||{},u=n.val,f=n.size,d=r.val,h=r.size;Object.keys(s).forEach(function(t){if(c(f)&&s[t].r){var n=s[t].r.val,r=s[t].r.size;if(n>u){var p=(f*n+(r-e.width)*u)/(n-u),g=(r*(1-u)+(f-e.width)*(1-n))/(n-u);p>=0&&g>=0&&p+g>a+o&&(a=p,o=g)}}if(c(h)&&s[t].t){var v=s[t].t.val,m=s[t].t.size;if(v>d){var y=(h*v+(m-e.height)*d)/(v-d),x=(m*(1-d)+(h-e.height)*(1-v))/(v-d);y>=0&&x>=0&&y+x>l+i&&(l=y,i=x)}}})})),n.l=Math.round(a),n.r=Math.round(o),n.t=Math.round(i),n.b=Math.round(l),n.p=Math.round(e.margin.pad),n.w=Math.round(e.width)-n.l-n.r,n.h=Math.round(e.height)-n.t-n.b,t._replotting||"{}"===r||r===JSON.stringify(e._size)?void 0:u.plot(t)},h.graphJson=function(t,e,n,r,a){function o(t){if("function"==typeof t)return null;if(f.isPlainObject(t)){var e,r,a={};for(e in t)if("function"!=typeof t[e]&&-1===["_","["].indexOf(e.charAt(0))){if("keepdata"===n){if("src"===e.substr(e.length-3))continue}else if("keepstream"===n){if(r=t[e+"src"],"string"==typeof r&&r.indexOf(":")>0&&!f.isPlainObject(t.stream))continue}else if("keepall"!==n&&(r=t[e+"src"],"string"==typeof r&&r.indexOf(":")>0))continue;a[e]=o(t[e])}return a}return Array.isArray(t)?t.map(o):t&&t.getTime?f.ms2DateTime(t):t}(a&&e&&!t._fullData||a&&!e&&!t._fullLayout)&&h.supplyDefaults(t);var i=a?t._fullData:t.data,l=a?t._fullLayout:t.layout,s={data:(i||[]).map(function(t){var n=o(t);return e&&delete n.fit,n})};return e||(s.layout=o(l)),t.framework&&t.framework.isPolar&&(s=t.framework.getConfig()),"object"===r?s:JSON.stringify(s)}},{"../components/color":18,"../lib":94,"../plotly":112,"./attributes":113,"./font_attributes":133,"./layout_attributes":134,d3:9,"fast-isnumeric":11}],136:[function(t,e,n){"use strict";var r=t("../../traces/scatter/attributes"),a=r.marker;e.exports={r:r.r,t:r.t,marker:{color:a.color,size:a.size,symbol:a.symbol,opacity:a.opacity}}},{"../../traces/scatter/attributes":172}],137:[function(t,e,n){"use strict";function r(t,e){var n={showline:{valType:"boolean"},showticklabels:{valType:"boolean"},tickorientation:{valType:"enumerated",values:["horizontal","vertical"]},ticklen:{valType:"number",min:0},tickcolor:{valType:"color"},ticksuffix:{valType:"string"},endpadding:{valType:"number"},visible:{valType:"boolean"}};return o({},e,n)}var a=t("../cartesian/layout_attributes"),o=t("../../lib/extend").extendFlat,i=o({},a.domain,{}); +-e.exports={radialaxis:r("radial",{range:{valType:"info_array",items:[{valType:"number"},{valType:"number"}]},domain:i,orientation:{valType:"number"}}),angularaxis:r("angular",{range:{valType:"info_array",items:[{valType:"number",dflt:0},{valType:"number",dflt:360}]},domain:i}),layout:{direction:{valType:"enumerated",values:["clockwise","counterclockwise"]},orientation:{valType:"angle"}}}},{"../../lib/extend":93,"../cartesian/layout_attributes":124}],138:[function(t,e,n){var r=t("../../plotly"),a=t("d3"),o=e.exports={version:"0.2.2",manager:t("./micropolar_manager")},i=r.Lib.extendDeepAll;o.Axis=function(){function t(t){n=t||n;var c=s.data,f=s.layout;return("string"==typeof n||n.nodeName)&&(n=a.select(n)),n.datum(c).each(function(t,n){function s(t,e){return l(t)%360+f.orientation}var c=t.slice();u={data:o.util.cloneJson(c),layout:o.util.cloneJson(f)};var d=0;c.forEach(function(t,e){t.color||(t.color=f.defaultColorRange[d],d=(d+1)%f.defaultColorRange.length),t.strokeColor||(t.strokeColor="LinePlot"===t.geometry?t.color:a.rgb(t.color).darker().toString()),u.data[e].color=t.color,u.data[e].strokeColor=t.strokeColor,u.data[e].strokeDash=t.strokeDash,u.data[e].strokeSize=t.strokeSize});var h=c.filter(function(t,e){var n=t.visible;return"undefined"==typeof n||n===!0}),p=!1,g=h.map(function(t,e){return p=p||"undefined"!=typeof t.groupId,t});if(p){var v=a.nest().key(function(t,e){return"undefined"!=typeof t.groupId?t.groupId:"unstacked"}).entries(g),m=[],y=v.map(function(t,e){if("unstacked"===t.key)return t.values;var n=t.values[0].r.map(function(t,e){return 0});return t.values.forEach(function(t,e,r){t.yStack=[n],m.push(n),n=o.util.sumArrays(t.r,n)}),t.values});h=a.merge(y)}h.forEach(function(t,e){t.t=Array.isArray(t.t[0])?t.t:[t.t],t.r=Array.isArray(t.r[0])?t.r:[t.r]});var x=Math.min(f.width-f.margin.left-f.margin.right,f.height-f.margin.top-f.margin.bottom)/2;x=Math.max(10,x);var b,_=[f.margin.left+x,f.margin.top+x];if(p){var w=a.max(o.util.sumArrays(o.util.arrayLast(h).r[0],o.util.arrayLast(m)));b=[0,w]}else b=a.extent(o.util.flattenArray(h.map(function(t,e){return t.r})));f.radialAxis.domain!=o.DATAEXTENT&&(b[0]=0),r=a.scale.linear().domain(f.radialAxis.domain!=o.DATAEXTENT&&f.radialAxis.domain?f.radialAxis.domain:b).range([0,x]),u.layout.radialAxis.domain=r.domain();var k,M=o.util.flattenArray(h.map(function(t,e){return t.t})),A="string"==typeof M[0];A&&(M=o.util.deduplicate(M),k=M.slice(),M=a.range(M.length),h=h.map(function(t,e){var n=t;return t.t=[M],p&&(n.yStack=t.yStack),n}));var T=h.filter(function(t,e){return"LinePlot"===t.geometry||"DotPlot"===t.geometry}).length===h.length,L=null===f.needsEndSpacing?A||!T:f.needsEndSpacing,z=f.angularAxis.domain&&f.angularAxis.domain!=o.DATAEXTENT&&!A&&f.angularAxis.domain[0]>=0,S=z?f.angularAxis.domain:a.extent(M),C=Math.abs(M[1]-M[0]);T&&!A&&(C=0);var E=S.slice();L&&A&&(E[1]+=C);var O=f.angularAxis.ticksCount||4;O>8&&(O=O/(O/8)+O%8),f.angularAxis.ticksStep&&(O=(E[1]-E[0])/O);var P=f.angularAxis.ticksStep||(E[1]-E[0])/(O*(f.minorTicks+1));k&&(P=Math.max(Math.round(P),1)),E[2]||(E[2]=P);var N=a.range.apply(this,E);if(N=N.map(function(t,e){return parseFloat(t.toPrecision(12))}),l=a.scale.linear().domain(E.slice(0,2)).range("clockwise"===f.direction?[0,360]:[360,0]),u.layout.angularAxis.domain=l.domain(),u.layout.angularAxis.endPadding=L?C:0,e=a.select(this).select("svg.chart-root"),"undefined"==typeof e||e.empty()){var D="' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '",I=(new DOMParser).parseFromString(D,"application/xml"),R=this.appendChild(this.ownerDocument.importNode(I.documentElement,!0));e=a.select(R)}e.select(".guides-group").style({"pointer-events":"none"}),e.select(".angular.axis-group").style({"pointer-events":"none"}),e.select(".radial.axis-group").style({"pointer-events":"none"});var j,F=e.select(".chart-group"),q={fill:"none",stroke:f.tickColor},B={"font-size":f.font.size,"font-family":f.font.family,fill:f.font.color,"text-shadow":["-1px 0px","1px -1px","-1px 1px","1px 1px"].map(function(t,e){return" "+t+" 0 "+f.font.outlineColor}).join(",")};if(f.showLegend){j=e.select(".legend-group").attr({transform:"translate("+[x,f.margin.top]+")"}).style({display:"block"});var H=h.map(function(t,e){var n=o.util.cloneJson(t);return n.symbol="DotPlot"===t.geometry?t.dotType||"circle":"LinePlot"!=t.geometry?"square":"line",n.visibleInLegend="undefined"==typeof t.visibleInLegend||t.visibleInLegend,n.color="LinePlot"===t.geometry?t.strokeColor:t.color,n});o.Legend().config({data:h.map(function(t,e){return t.name||"Element"+e}),legendConfig:i({},o.Legend.defaultConfig().legendConfig,{container:j,elements:H,reverseOrder:f.legend.reverseOrder})})();var V=j.node().getBBox();x=Math.min(f.width-V.width-f.margin.left-f.margin.right,f.height-f.margin.top-f.margin.bottom)/2,x=Math.max(10,x),_=[f.margin.left+x,f.margin.top+x],r.range([0,x]),u.layout.radialAxis.domain=r.domain(),j.attr("transform","translate("+[_[0]+x,_[1]-x]+")")}else j=e.select(".legend-group").style({display:"none"});e.attr({width:f.width,height:f.height}).style({opacity:f.opacity}),F.attr("transform","translate("+_+")").style({cursor:"crosshair"});var Z=[(f.width-(f.margin.left+f.margin.right+2*x+(V?V.width:0)))/2,(f.height-(f.margin.top+f.margin.bottom+2*x))/2];if(Z[0]=Math.max(0,Z[0]),Z[1]=Math.max(0,Z[1]),e.select(".outer-group").attr("transform","translate("+Z+")"),f.title){var Y=e.select("g.title-group text").style(B).text(f.title),U=Y.node().getBBox();Y.attr({x:_[0]-U.width/2,y:_[1]-x-20})}var X=e.select(".radial.axis-group");if(f.radialAxis.gridLinesVisible){var G=X.selectAll("circle.grid-circle").data(r.ticks(5));G.enter().append("circle").attr({"class":"grid-circle"}).style(q),G.attr("r",r),G.exit().remove()}X.select("circle.outside-circle").attr({r:x}).style(q);var $=e.select("circle.background-circle").attr({r:x}).style({fill:f.backgroundColor,stroke:f.stroke});if(f.radialAxis.visible){var Q=a.svg.axis().scale(r).ticks(5).tickSize(5);X.call(Q).attr({transform:"rotate("+f.radialAxis.orientation+")"}),X.selectAll(".domain").style(q),X.selectAll("g>text").text(function(t,e){return this.textContent+f.radialAxis.ticksSuffix}).style(B).style({"text-anchor":"start"}).attr({x:0,y:0,dx:0,dy:0,transform:function(t,e){return"horizontal"===f.radialAxis.tickOrientation?"rotate("+-f.radialAxis.orientation+") translate("+[0,B["font-size"]]+")":"translate("+[0,B["font-size"]]+")"}}),X.selectAll("g>line").style({stroke:"black"})}var W=e.select(".angular.axis-group").selectAll("g.angular-tick").data(N),J=W.enter().append("g").classed("angular-tick",!0);W.attr({transform:function(t,e){return"rotate("+s(t,e)+")"}}).style({display:f.angularAxis.visible?"block":"none"}),W.exit().remove(),J.append("line").classed("grid-line",!0).classed("major",function(t,e){return e%(f.minorTicks+1)==0}).classed("minor",function(t,e){return!(e%(f.minorTicks+1)==0)}).style(q),J.selectAll(".minor").style({stroke:f.minorTickColor}),W.select("line.grid-line").attr({x1:f.tickLength?x-f.tickLength:0,x2:x}).style({display:f.angularAxis.gridLinesVisible?"block":"none"}),J.append("text").classed("axis-text",!0).style(B);var K=W.select("text.axis-text").attr({x:x+f.labelOffset,dy:".35em",transform:function(t,e){var n=s(t,e),r=x+f.labelOffset,a=f.angularAxis.tickOrientation;return"horizontal"==a?"rotate("+-n+" "+r+" 0)":"radial"==a?270>n&&n>90?"rotate(180 "+r+" 0)":null:"rotate("+(180>=n&&n>0?-90:90)+" "+r+" 0)"}}).style({"text-anchor":"middle",display:f.angularAxis.labelsVisible?"block":"none"}).text(function(t,e){return e%(f.minorTicks+1)!=0?"":k?k[t]+f.angularAxis.ticksSuffix:t+f.angularAxis.ticksSuffix}).style(B);f.angularAxis.rewriteTicks&&K.text(function(t,e){return e%(f.minorTicks+1)!=0?"":f.angularAxis.rewriteTicks(this.textContent,e)});var tt=a.max(F.selectAll(".angular-tick text")[0].map(function(t,e){return t.getCTM().e+t.getBBox().width}));j.attr({transform:"translate("+[x+tt,f.margin.top]+")"});var et=e.select("g.geometry-group").selectAll("g").size()>0,nt=e.select("g.geometry-group").selectAll("g.geometry").data(h);if(nt.enter().append("g").attr({"class":function(t,e){return"geometry geometry"+e}}),nt.exit().remove(),h[0]||et){var rt=[];h.forEach(function(t,e){var n={};n.radialScale=r,n.angularScale=l,n.container=nt.filter(function(t,n){return n==e}),n.geometry=t.geometry,n.orientation=f.orientation,n.direction=f.direction,n.index=e,rt.push({data:t,geometryConfig:n})});var at=a.nest().key(function(t,e){return"undefined"!=typeof t.data.groupId||"unstacked"}).entries(rt),ot=[];at.forEach(function(t,e){"unstacked"===t.key?ot=ot.concat(t.values.map(function(t,e){return[t]})):ot.push(t.values)}),ot.forEach(function(t,e){var n;n=Array.isArray(t)?t[0].geometryConfig.geometry:t.geometryConfig.geometry;var r=t.map(function(t,e){return i(o[n].defaultConfig(),t)});o[n]().config(r)()})}var it,lt,st=e.select(".guides-group"),ct=e.select(".tooltips-group"),ut=o.tooltipPanel().config({container:ct,fontSize:8})(),ft=o.tooltipPanel().config({container:ct,fontSize:8})(),dt=o.tooltipPanel().config({container:ct,hasTick:!0})();if(!A){var ht=st.select("line").attr({x1:0,y1:0,y2:0}).style({stroke:"grey","pointer-events":"none"});F.on("mousemove.angular-guide",function(t,e){var n=o.util.getMousePos($).angle;ht.attr({x2:-x,transform:"rotate("+n+")"}).style({opacity:.5});var r=(n+180+360-f.orientation)%360;it=l.invert(r);var a=o.util.convertToCartesian(x+12,n+180);ut.text(o.util.round(it)).move([a[0]+_[0],a[1]+_[1]])}).on("mouseout.angular-guide",function(t,e){st.select("line").style({opacity:0})})}var pt=st.select("circle").style({stroke:"grey",fill:"none"});F.on("mousemove.radial-guide",function(t,e){var n=o.util.getMousePos($).radius;pt.attr({r:n}).style({opacity:.5}),lt=r.invert(o.util.getMousePos($).radius);var a=o.util.convertToCartesian(n,f.radialAxis.orientation);ft.text(o.util.round(lt)).move([a[0]+_[0],a[1]+_[1]])}).on("mouseout.radial-guide",function(t,e){pt.style({opacity:0}),dt.hide(),ut.hide(),ft.hide()}),e.selectAll(".geometry-group .mark").on("mouseover.tooltip",function(t,n){var r=a.select(this),i=r.style("fill"),l="black",s=r.style("opacity")||1;if(r.attr({"data-opacity":s}),"none"!=i){r.attr({"data-fill":i}),l=a.hsl(i).darker().toString(),r.style({fill:l,opacity:1});var c={t:o.util.round(t[0]),r:o.util.round(t[1])};A&&(c.t=k[t[0]]);var u="t: "+c.t+", r: "+c.r,f=this.getBoundingClientRect(),d=e.node().getBoundingClientRect(),h=[f.left+f.width/2-Z[0]-d.left,f.top+f.height/2-Z[1]-d.top];dt.config({color:l}).text(u),dt.move(h)}else i=r.style("stroke"),r.attr({"data-stroke":i}),l=a.hsl(i).darker().toString(),r.style({stroke:l,opacity:1})}).on("mousemove.tooltip",function(t,e){return 0!=a.event.which?!1:void(a.select(this).attr("data-fill")&&dt.show())}).on("mouseout.tooltip",function(t,e){dt.hide();var n=a.select(this),r=n.attr("data-fill");r?n.style({fill:r,opacity:n.attr("data-opacity")}):n.style({stroke:n.attr("data-stroke"),opacity:n.attr("data-opacity")})})}),d}var e,n,r,l,s={data:[],layout:{}},c={},u={},f=a.dispatch("hover"),d={};return d.render=function(e){return t(e),this},d.config=function(t){if(!arguments.length)return s;var e=o.util.cloneJson(t);return e.data.forEach(function(t,e){s.data[e]||(s.data[e]={}),i(s.data[e],o.Axis.defaultConfig().data[0]),i(s.data[e],t)}),i(s.layout,o.Axis.defaultConfig().layout),i(s.layout,e.layout),this},d.getLiveConfig=function(){return u},d.getinputConfig=function(){return c},d.radialScale=function(t){return r},d.angularScale=function(t){return l},d.svg=function(){return e},a.rebind(d,f,"on"),d},o.Axis.defaultConfig=function(t,e){var n={data:[{t:[1,2,3,4],r:[10,11,12,13],name:"Line1",geometry:"LinePlot",color:null,strokeDash:"solid",strokeColor:null,strokeSize:"1",visibleInLegend:!0,opacity:1}],layout:{defaultColorRange:a.scale.category10().range(),title:null,height:450,width:500,margin:{top:40,right:40,bottom:40,left:40},font:{size:12,color:"gray",outlineColor:"white",family:"Tahoma, sans-serif"},direction:"clockwise",orientation:0,labelOffset:10,radialAxis:{domain:null,orientation:-45,ticksSuffix:"",visible:!0,gridLinesVisible:!0,tickOrientation:"horizontal",rewriteTicks:null},angularAxis:{domain:[0,360],ticksSuffix:"",visible:!0,gridLinesVisible:!0,labelsVisible:!0,tickOrientation:"horizontal",rewriteTicks:null,ticksCount:null,ticksStep:null},minorTicks:0,tickLength:null,tickColor:"silver",minorTickColor:"#eee",backgroundColor:"none",needsEndSpacing:null,showLegend:!0,legend:{reverseOrder:!1},opacity:1}};return n},o.util={},o.DATAEXTENT="dataExtent",o.AREA="AreaChart",o.LINE="LinePlot",o.DOT="DotPlot",o.BAR="BarChart",o.util._override=function(t,e){for(var n in t)n in e&&(e[n]=t[n])},o.util._extend=function(t,e){for(var n in t)e[n]=t[n]},o.util._rndSnd=function(){return 2*Math.random()-1+(2*Math.random()-1)+(2*Math.random()-1)},o.util.dataFromEquation2=function(t,e){var n=e||6,r=a.range(0,360+n,n).map(function(e,n){var r=e*Math.PI/180,a=t(r);return[e,a]});return r},o.util.dataFromEquation=function(t,e,n){var r=e||6,o=[],i=[];a.range(0,360+r,r).forEach(function(e,n){var r=e*Math.PI/180,a=t(r);o.push(e),i.push(a)});var l={t:o,r:i};return n&&(l.name=n),l},o.util.ensureArray=function(t,e){if("undefined"==typeof t)return null;var n=[].concat(t);return a.range(e).map(function(t,e){return n[e]||n[0]})},o.util.fillArrays=function(t,e,n){return e.forEach(function(e,r){t[e]=o.util.ensureArray(t[e],n)}),t},o.util.cloneJson=function(t){return JSON.parse(JSON.stringify(t))},o.util.validateKeys=function(t,e){"string"==typeof e&&(e=e.split("."));var n=e.shift();return t[n]&&(!e.length||objHasKeys(t[n],e))},o.util.sumArrays=function(t,e){return a.zip(t,e).map(function(t,e){return a.sum(t)})},o.util.arrayLast=function(t){return t[t.length-1]},o.util.arrayEqual=function(t,e){for(var n=Math.max(t.length,e.length,1);n-- >=0&&t[n]===e[n];);return-2===n},o.util.flattenArray=function(t){for(var e=[];!o.util.arrayEqual(e,t);)e=t,t=[].concat.apply([],t);return t},o.util.deduplicate=function(t){return t.filter(function(t,e,n){return n.indexOf(t)==e})},o.util.convertToCartesian=function(t,e){var n=e*Math.PI/180,r=t*Math.cos(n),a=t*Math.sin(n);return[r,a]},o.util.round=function(t,e){var n=e||2,r=Math.pow(10,n);return Math.round(t*r)/r},o.util.getMousePos=function(t){var e=a.mouse(t.node()),n=e[0],r=e[1],o={};return o.x=n,o.y=r,o.pos=e,o.angle=180*(Math.atan2(r,n)+Math.PI)/Math.PI,o.radius=Math.sqrt(n*n+r*r),o},o.util.duplicatesCount=function(t){for(var e,n={},r={},a=0,o=t.length;o>a;a++)e=t[a],e in n?(n[e]++,r[e]=n[e]):n[e]=1;return r},o.util.duplicates=function(t){return Object.keys(o.util.duplicatesCount(t))},o.util.translator=function(t,e,n,r){if(r){var a=n.slice();n=e,e=a}var o=e.reduce(function(t,e){return"undefined"!=typeof t?t[e]:void 0},t);"undefined"!=typeof o&&(e.reduce(function(t,n,r){return"undefined"!=typeof t?(r===e.length-1&&delete t[n],t[n]):void 0},t),n.reduce(function(t,e,r){return"undefined"==typeof t[e]&&(t[e]={}),r===n.length-1&&(t[e]=o),t[e]},t))},o.PolyChart=function(){function t(){var t=n[0].geometryConfig,e=t.container;"string"==typeof e&&(e=a.select(e)),e.datum(n).each(function(e,n){function r(e,n){var r=t.radialScale(e[1]),a=(t.angularScale(e[0])+t.orientation)*Math.PI/180;return{r:r,t:a}}function o(t){var e=t.r*Math.cos(t.t),n=t.r*Math.sin(t.t);return{x:e,y:n}}var i=!!e[0].data.yStack,s=e.map(function(t,e){return i?a.zip(t.data.t[0],t.data.r[0],t.data.yStack[0]):a.zip(t.data.t[0],t.data.r[0])}),c=t.angularScale,u=t.radialScale.domain()[0],f={};f.bar=function(n,r,o){var i=e[o].data,l=t.radialScale(n[1])-t.radialScale(0),s=t.radialScale(n[2]||0),u=i.barWidth;a.select(this).attr({"class":"mark bar",d:"M"+[[l+s,-u/2],[l+s,u/2],[s,u/2],[s,-u/2]].join("L")+"Z",transform:function(e,n){return"rotate("+(t.orientation+c(e[0]))+")"}})},f.dot=function(t,n,i){var l=t[2]?[t[0],t[1]+t[2]]:t,s=a.svg.symbol().size(e[i].data.dotSize).type(e[i].data.dotType)(t,n);a.select(this).attr({"class":"mark dot",d:s,transform:function(t,e){var n=o(r(l));return"translate("+[n.x,n.y]+")"}})};var d=a.svg.line.radial().interpolate(e[0].data.lineInterpolation).radius(function(e){return t.radialScale(e[1])}).angle(function(e){return t.angularScale(e[0])*Math.PI/180});f.line=function(n,r,o){var i=n[2]?s[o].map(function(t,e){return[t[0],t[1]+t[2]]}):s[o];if(a.select(this).each(f.dot).style({opacity:function(t,n){return+e[o].data.dotVisible},fill:v.stroke(n,r,o)}).attr({"class":"mark dot"}),!(r>0)){var l=a.select(this.parentNode).selectAll("path.line").data([0]);l.enter().insert("path"),l.attr({"class":"line",d:d(i),transform:function(e,n){return"rotate("+(t.orientation+90)+")"},"pointer-events":"none"}).style({fill:function(t,e){return v.fill(n,r,o)},"fill-opacity":0,stroke:function(t,e){return v.stroke(n,r,o)},"stroke-width":function(t,e){return v["stroke-width"](n,r,o)},"stroke-dasharray":function(t,e){return v["stroke-dasharray"](n,r,o)},opacity:function(t,e){return v.opacity(n,r,o)},display:function(t,e){return v.display(n,r,o)}})}};var h=t.angularScale.range(),p=Math.abs(h[1]-h[0])/s[0].length*Math.PI/180,g=a.svg.arc().startAngle(function(t){return-p/2}).endAngle(function(t){return p/2}).innerRadius(function(e){return t.radialScale(u+(e[2]||0))}).outerRadius(function(e){return t.radialScale(u+(e[2]||0))+t.radialScale(e[1])});f.arc=function(e,n,r){a.select(this).attr({"class":"mark arc",d:g,transform:function(e,n){return"rotate("+(t.orientation+c(e[0])+90)+")"}})};var v={fill:function(t,n,r){return e[r].data.color},stroke:function(t,n,r){return e[r].data.strokeColor},"stroke-width":function(t,n,r){return e[r].data.strokeSize+"px"},"stroke-dasharray":function(t,n,r){return l[e[r].data.strokeDash]},opacity:function(t,n,r){return e[r].data.opacity},display:function(t,n,r){return"undefined"==typeof e[r].data.visible||e[r].data.visible?"block":"none"}},m=a.select(this).selectAll("g.layer").data(s);m.enter().append("g").attr({"class":"layer"});var y=m.selectAll("path.mark").data(function(t,e){return t});y.enter().append("path").attr({"class":"mark"}),y.style(v).each(f[t.geometryType]),y.exit().remove(),m.exit().remove()})}var e,n=[o.PolyChart.defaultConfig()],r=a.dispatch("hover"),l={solid:"none",dash:[5,2],dot:[2,5]};return t.config=function(t){return arguments.length?(t.forEach(function(t,e){n[e]||(n[e]={}),i(n[e],o.PolyChart.defaultConfig()),i(n[e],t)}),this):n},t.getColorScale=function(){return e},a.rebind(t,r,"on"),t},o.PolyChart.defaultConfig=function(){var t={data:{name:"geom1",t:[[1,2,3,4]],r:[[1,2,3,4]],dotType:"circle",dotSize:64,dotVisible:!1,barWidth:20,color:"#ffa500",strokeSize:1,strokeColor:"silver",strokeDash:"solid",opacity:1,index:0,visible:!0,visibleInLegend:!0},geometryConfig:{geometry:"LinePlot",geometryType:"arc",direction:"clockwise",orientation:0,container:"body",radialScale:null,angularScale:null,colorScale:a.scale.category20()}};return t},o.BarChart=function(){return o.PolyChart()},o.BarChart.defaultConfig=function(){var t={geometryConfig:{geometryType:"bar"}};return t},o.AreaChart=function(){return o.PolyChart()},o.AreaChart.defaultConfig=function(){var t={geometryConfig:{geometryType:"arc"}};return t},o.DotPlot=function(){return o.PolyChart()},o.DotPlot.defaultConfig=function(){var t={geometryConfig:{geometryType:"dot",dotType:"circle"}};return t},o.LinePlot=function(){return o.PolyChart()},o.LinePlot.defaultConfig=function(){var t={geometryConfig:{geometryType:"line"}};return t},o.Legend=function(){function t(){var n=e.legendConfig,r=e.data.map(function(t,e){return[].concat(t).map(function(t,r){var a=i({},n.elements[e]);return a.name=t,a.color=[].concat(n.elements[e].color)[r],a})}),o=a.merge(r);o=o.filter(function(t,e){return n.elements[e]&&(n.elements[e].visibleInLegend||"undefined"==typeof n.elements[e].visibleInLegend)}),n.reverseOrder&&(o=o.reverse());var l=n.container;("string"==typeof l||l.nodeName)&&(l=a.select(l));var s=o.map(function(t,e){return t.color}),c=n.fontSize,u=null==n.isContinuous?"number"==typeof o[0]:n.isContinuous,f=u?n.height:c*o.length,d=l.classed("legend-group",!0),h=d.selectAll("svg").data([0]),p=h.enter().append("svg").attr({width:300,height:f+c,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"});p.append("g").classed("legend-axis",!0),p.append("g").classed("legend-marks",!0);var g=a.range(o.length),v=a.scale[u?"linear":"ordinal"]().domain(g).range(s),m=a.scale[u?"linear":"ordinal"]().domain(g)[u?"range":"rangePoints"]([0,f]),y=function(t,e){var n=3*e;return"line"===t?"M"+[[-e/2,-e/12],[e/2,-e/12],[e/2,e/12],[-e/2,e/12]]+"Z":-1!=a.svg.symbolTypes.indexOf(t)?a.svg.symbol().type(t).size(n)():a.svg.symbol().type("square").size(n)()};if(u){var x=h.select(".legend-marks").append("defs").append("linearGradient").attr({id:"grad1",x1:"0%",y1:"0%",x2:"0%",y2:"100%"}).selectAll("stop").data(s);x.enter().append("stop"),x.attr({offset:function(t,e){return e/(s.length-1)*100+"%"}}).style({"stop-color":function(t,e){return t}}),h.append("rect").classed("legend-mark",!0).attr({height:n.height,width:n.colorBandWidth,fill:"url(#grad1)"})}else{var b=h.select(".legend-marks").selectAll("path.legend-mark").data(o);b.enter().append("path").classed("legend-mark",!0),b.attr({transform:function(t,e){return"translate("+[c/2,m(e)+c/2]+")"},d:function(t,e){var n=t.symbol;return y(n,c)},fill:function(t,e){return v(e)}}),b.exit().remove()}var _=a.svg.axis().scale(m).orient("right"),w=h.select("g.legend-axis").attr({transform:"translate("+[u?n.colorBandWidth:c,c/2]+")"}).call(_);return w.selectAll(".domain").style({fill:"none",stroke:"none"}),w.selectAll("line").style({fill:"none",stroke:u?n.textColor:"none"}),w.selectAll("text").style({fill:n.textColor,"font-size":n.fontSize}).text(function(t,e){return o[e].name}),t}var e=o.Legend.defaultConfig(),n=a.dispatch("hover");return t.config=function(t){return arguments.length?(i(e,t),this):e},a.rebind(t,n,"on"),t},o.Legend.defaultConfig=function(t,e){var n={data:["a","b","c"],legendConfig:{elements:[{symbol:"line",color:"red"},{symbol:"square",color:"yellow"},{symbol:"diamond",color:"limegreen"}],height:150,colorBandWidth:30,fontSize:12,container:"body",isContinuous:null,textColor:"grey",reverseOrder:!1}};return n},o.tooltipPanel=function(){var t,e,n,r={container:null,hasTick:!1,fontSize:12,color:"white",padding:5},l="tooltip-"+o.tooltipPanel.uid++,s=10,c=function(){t=r.container.selectAll("g."+l).data([0]);var a=t.enter().append("g").classed(l,!0).style({"pointer-events":"none",display:"none"});return n=a.append("path").style({fill:"white","fill-opacity":.9}).attr({d:"M0 0"}),e=a.append("text").attr({dx:r.padding+s,dy:.3*+r.fontSize}),c};return c.text=function(o){var i=a.hsl(r.color).l,l=i>=.5?"#aaa":"white",u=i>=.5?"black":"white",f=o||"";e.style({fill:u,"font-size":r.fontSize+"px"}).text(f);var d=r.padding,h=e.node().getBBox(),p={fill:r.color,stroke:l,"stroke-width":"2px"},g=h.width+2*d+s,v=h.height+2*d;return n.attr({d:"M"+[[s,-v/2],[s,-v/4],[r.hasTick?0:s,0],[s,v/4],[s,v/2],[g,v/2],[g,-v/2]].join("L")+"Z"}).style(p),t.attr({transform:"translate("+[s,-v/2+2*d]+")"}),t.style({display:"block"}),c},c.move=function(e){return t?(t.attr({transform:"translate("+[e[0],e[1]]+")"}).style({display:"block"}),c):void 0},c.hide=function(){return t?(t.style({display:"none"}),c):void 0},c.show=function(){return t?(t.style({display:"block"}),c):void 0},c.config=function(t){return i(r,t),c},c},o.tooltipPanel.uid=1,o.adapter={},o.adapter.plotly=function(){var t={};return t.convert=function(t,e){var n={};if(t.data&&(n.data=t.data.map(function(t,n){var r=i({},t),a=[[r,["marker","color"],["color"]],[r,["marker","opacity"],["opacity"]],[r,["marker","line","color"],["strokeColor"]],[r,["marker","line","dash"],["strokeDash"]],[r,["marker","line","width"],["strokeSize"]],[r,["marker","symbol"],["dotType"]],[r,["marker","size"],["dotSize"]],[r,["marker","barWidth"],["barWidth"]],[r,["line","interpolation"],["lineInterpolation"]],[r,["showlegend"],["visibleInLegend"]]];return a.forEach(function(t,n){o.util.translator.apply(null,t.concat(e))}),e||delete r.marker,e&&delete r.groupId,e?("LinePlot"===r.geometry?(r.type="scatter",r.dotVisible===!0?(delete r.dotVisible,r.mode="lines+markers"):r.mode="lines"):"DotPlot"===r.geometry?(r.type="scatter",r.mode="markers"):"AreaChart"===r.geometry?r.type="area":"BarChart"===r.geometry&&(r.type="bar"),delete r.geometry):("scatter"===r.type?"lines"===r.mode?r.geometry="LinePlot":"markers"===r.mode?r.geometry="DotPlot":"lines+markers"===r.mode&&(r.geometry="LinePlot",r.dotVisible=!0):"area"===r.type?r.geometry="AreaChart":"bar"===r.type&&(r.geometry="BarChart"),delete r.mode,delete r.type),r}),!e&&t.layout&&"stack"===t.layout.barmode)){var r=o.util.duplicates(n.data.map(function(t,e){return t.geometry}));n.data.forEach(function(t,e){var a=r.indexOf(t.geometry);-1!=a&&(n.data[e].groupId=a)})}if(t.layout){var l=i({},t.layout),s=[[l,["plot_bgcolor"],["backgroundColor"]],[l,["showlegend"],["showLegend"]],[l,["radialaxis"],["radialAxis"]],[l,["angularaxis"],["angularAxis"]],[l.angularaxis,["showline"],["gridLinesVisible"]],[l.angularaxis,["showticklabels"],["labelsVisible"]],[l.angularaxis,["nticks"],["ticksCount"]],[l.angularaxis,["tickorientation"],["tickOrientation"]],[l.angularaxis,["ticksuffix"],["ticksSuffix"]],[l.angularaxis,["range"],["domain"]],[l.angularaxis,["endpadding"],["endPadding"]],[l.radialaxis,["showline"],["gridLinesVisible"]],[l.radialaxis,["tickorientation"],["tickOrientation"]],[l.radialaxis,["ticksuffix"],["ticksSuffix"]],[l.radialaxis,["range"],["domain"]],[l.angularAxis,["showline"],["gridLinesVisible"]],[l.angularAxis,["showticklabels"],["labelsVisible"]],[l.angularAxis,["nticks"],["ticksCount"]],[l.angularAxis,["tickorientation"],["tickOrientation"]],[l.angularAxis,["ticksuffix"],["ticksSuffix"]],[l.angularAxis,["range"],["domain"]],[l.angularAxis,["endpadding"],["endPadding"]],[l.radialAxis,["showline"],["gridLinesVisible"]],[l.radialAxis,["tickorientation"],["tickOrientation"]],[l.radialAxis,["ticksuffix"],["ticksSuffix"]],[l.radialAxis,["range"],["domain"]],[l.font,["outlinecolor"],["outlineColor"]],[l.legend,["traceorder"],["reverseOrder"]],[l,["labeloffset"],["labelOffset"]],[l,["defaultcolorrange"],["defaultColorRange"]]];if(s.forEach(function(t,n){o.util.translator.apply(null,t.concat(e))}),e?("undefined"!=typeof l.tickLength&&(l.angularaxis.ticklen=l.tickLength,delete l.tickLength),l.tickColor&&(l.angularaxis.tickcolor=l.tickColor,delete l.tickColor)):(l.angularAxis&&"undefined"!=typeof l.angularAxis.ticklen&&(l.tickLength=l.angularAxis.ticklen),l.angularAxis&&"undefined"!=typeof l.angularAxis.tickcolor&&(l.tickColor=l.angularAxis.tickcolor)),l.legend&&"boolean"!=typeof l.legend.reverseOrder&&(l.legend.reverseOrder="normal"!=l.legend.reverseOrder),l.legend&&"boolean"==typeof l.legend.traceorder&&(l.legend.traceorder=l.legend.traceorder?"reversed":"normal",delete l.legend.reverseOrder),l.margin&&"undefined"!=typeof l.margin.t){var c=["t","r","b","l","pad"],u=["top","right","bottom","left","pad"],f={};a.entries(l.margin).forEach(function(t,e){f[u[c.indexOf(t.key)]]=t.value}),l.margin=f}e&&(delete l.needsEndSpacing,delete l.minorTickColor,delete l.minorTicks,delete l.angularaxis.ticksCount,delete l.angularaxis.ticksCount,delete l.angularaxis.ticksStep,delete l.angularaxis.rewriteTicks,delete l.angularaxis.nticks,delete l.radialaxis.ticksCount,delete l.radialaxis.ticksCount,delete l.radialaxis.ticksStep,delete l.radialaxis.rewriteTicks,delete l.radialaxis.nticks),n.layout=l}return n},t}},{"../../plotly":112,"./micropolar_manager":139,d3:9}],139:[function(t,e,n){"use strict";var r=t("../../plotly"),a=t("d3"),o=t("./undo_manager"),i=e.exports={},l=r.Lib.extendDeepAll;i.framework=function(t){function e(e,o){return o&&(f=o),a.select(a.select(f).node().parentNode).selectAll(".svg-container>*:not(.chart-root)").remove(),n=n?l(n,e):e,c||(c=r.micropolar.Axis()),u=r.micropolar.adapter.plotly().convert(n),c.config(u).render(f),t.data=n.data,t.layout=n.layout,i.fillLayout(t),n}var n,s,c,u,f,d=new o;return e.isPolar=!0,e.svg=function(){return c.svg()},e.getConfig=function(){return n},e.getLiveConfig=function(){return r.micropolar.adapter.plotly().convert(c.getLiveConfig(),!0)},e.getLiveScales=function(){return{t:c.angularScale(),r:c.radialScale()}},e.setUndoPoint=function(){var t=this,e=r.micropolar.util.cloneJson(n);!function(e,n){d.add({undo:function(){n&&t(n)},redo:function(){t(e)}})}(e,s),s=r.micropolar.util.cloneJson(e)},e.undo=function(){d.undo()},e.redo=function(){d.redo()},e},i.fillLayout=function(t){var e=a.select(t).selectAll(".plot-container"),n=e.selectAll(".svg-container"),o=t.framework&&t.framework.svg&&t.framework.svg(),i={width:800,height:600,paper_bgcolor:r.Color.background,_container:e,_paperdiv:n,_paper:o};t._fullLayout=l(i,t.layout)}},{"../../plotly":112,"./undo_manager":140,d3:9}],140:[function(t,e,n){"use strict";e.exports=function(){function t(t,e){return t?(a=!0,t[e](),a=!1,this):this}var e,n=[],r=-1,a=!1;return{add:function(t){return a?this:(n.splice(r+1,n.length-r),n.push(t),r=n.length-1,this)},setCallback:function(t){e=t},undo:function(){var a=n[r];return a?(t(a,"undo"),r-=1,e&&e(a.undo),this):this},redo:function(){var a=n[r+1];return a?(t(a,"redo"),r+=1,e&&e(a.redo),this):this},clear:function(){n=[],r=-1},hasUndo:function(){return-1!==r},hasRedo:function(){return r-1}var o=t("../plotly"),i=o.Lib.extendFlat,l=o.Lib.extendDeep;e.exports=function(t,e){t.framework&&t.framework.isPolar&&(t=t.framework.getConfig());var n,s=t.data,c=t.layout,u=l([],s),f=l({},c,r(e.tileClass));if(e.width&&(f.width=e.width),e.height&&(f.height=e.height),"thumbnail"===e.tileClass||"themes__thumb"===e.tileClass){f.annotations=[];var d=Object.keys(f);for(n=0;ns;s++)r(n[s])&&h.push({p:n[s],s:l[s],b:0});return o(e,"marker")&&i(e,e.marker.color,"marker","c"),o(e,"marker.line")&&i(e,e.marker.line.color,"marker.line","c"),h}},{"../../components/colorscale/calc":25,"../../components/colorscale/has_colorscale":31,"../../plots/cartesian/axes":115,"fast-isnumeric":11}],151:[function(t,e,n){"use strict";var r=t("../../lib"),a=t("../../components/color"),o=t("../scatter/xy_defaults"),i=t("../bar/style_defaults"),l=t("../../components/errorbars/defaults"),s=t("./attributes");e.exports=function(t,e,n,c){function u(n,a){return r.coerce(t,e,s,n,a)}var f=o(t,e,u);return f?(u("orientation",e.x&&!e.y?"h":"v"),u("text"),i(t,e,u,n,c),l(t,e,a.defaultLine,{axis:"y"}),void l(t,e,a.defaultLine,{axis:"x",inherit:"y"})):void(e.visible=!1)}},{"../../components/color":18,"../../components/errorbars/defaults":46,"../../lib":94,"../bar/style_defaults":159,"../scatter/xy_defaults":193,"./attributes":149}],152:[function(t,e,n){"use strict";var r=t("../../plots/cartesian/graph_interact"),a=t("../../components/errorbars"),o=t("../../components/color");e.exports=function(t,e,n,i){var l,s=t.cd,c=s[0].trace,u=s[0].t,f=t.xa,d=t.ya,h="closest"===i?u.barwidth/2:u.dbar*(1-f._gd._fullLayout.bargap)/2;l="closest"!==i?function(t){return t.p}:"h"===c.orientation?function(t){return t.y}:function(t){return t.x};var p,g;"h"===c.orientation?(p=function(t){return r.inbox(t.b-e,t.x-e)+(t.x-e)/(t.x-t.b)},g=function(t){var e=l(t)-n;return r.inbox(e-h,e+h)}):(g=function(t){return r.inbox(t.b-n,t.y-n)+(t.y-n)/(t.y-t.b)},p=function(t){var n=l(t)-e;return r.inbox(n-h,n+h)});var v=r.getDistanceFunction(i,p,g);if(r.getClosest(s,v,t),t.index!==!1){var m=s[t.index],y=m.mcc||c.marker.color,x=m.mlcc||c.marker.line.color,b=m.mlw||c.marker.line.width;return o.opacity(y)?t.color=y:o.opacity(x)&&b&&(t.color=x),"h"===c.orientation?(t.x0=t.x1=f.c2p(m.x,!0),t.xLabelVal=m.s,t.y0=d.c2p(l(m)-h,!0),t.y1=d.c2p(l(m)+h,!0),t.yLabelVal=m.p):(t.y0=t.y1=d.c2p(m.y,!0),t.yLabelVal=m.s,t.x0=f.c2p(l(m)-h,!0),t.x1=f.c2p(l(m)+h,!0),t.xLabelVal=m.p),m.tx&&(t.text=m.tx),a.hoverInfo(m,c,t),[t]}}},{"../../components/color":18,"../../components/errorbars":47,"../../plots/cartesian/graph_interact":122}],153:[function(t,e,n){"use strict";var r={};r.attributes=t("./attributes"),r.layoutAttributes=t("./layout_attributes"),r.supplyDefaults=t("./defaults"),r.supplyLayoutDefaults=t("./layout_defaults"),r.calc=t("./calc"),r.setPositions=t("./set_positions"),r.colorbar=t("../scatter/colorbar"),r.arraysToCalcdata=t("./arrays_to_calcdata"),r.plot=t("./plot"),r.style=t("./style"),r.hoverPoints=t("./hover"),r.moduleType="trace",r.name="bar",r.basePlotModule=t("../../plots/cartesian"),r.categories=["cartesian","bar","oriented","markerColorscale","errorBarsOK","showLegend"],r.meta={},e.exports=r},{"../../plots/cartesian":123,"../scatter/colorbar":175,"./arrays_to_calcdata":148,"./attributes":149,"./calc":150,"./defaults":151,"./hover":152,"./layout_attributes":154,"./layout_defaults":155,"./plot":156,"./set_positions":157,"./style":158}],154:[function(t,e,n){"use strict";e.exports={barmode:{valType:"enumerated",values:["stack","group","overlay","relative"],dflt:"group"},barnorm:{valType:"enumerated",values:["","fraction","percent"],dflt:""},bargap:{valType:"number",min:0,max:1},bargroupgap:{valType:"number",min:0,max:1,dflt:0}}},{}],155:[function(t,e,n){"use strict";var r=t("../../plots/plots"),a=t("../../plots/cartesian/axes"),o=t("../../lib"),i=t("./layout_attributes");e.exports=function(t,e,n){function l(n,r){return o.coerce(t,e,i,n,r)}for(var s=!1,c=!1,u=!1,f={},d=0;d=2?o(t):t>e?Math.ceil(t):Math.floor(t)}var d,h,p,g;if("h"===l.orientation?(p=u.c2p(n.poffset+e.p,!0),g=u.c2p(n.poffset+e.p+n.barwidth,!0),d=c.c2p(e.b,!0),h=c.c2p(e.s+e.b,!0)):(d=c.c2p(n.poffset+e.p,!0),h=c.c2p(n.poffset+e.p+n.barwidth,!0),g=u.c2p(e.s+e.b,!0),p=u.c2p(e.b,!0)),!(a(d)&&a(h)&&a(p)&&a(g)&&d!==h&&p!==g))return void r.select(this).remove();var v=(e.mlw+1||l.marker.line.width+1||(e.trace?e.trace.marker.line.width:0)+1)-1,m=r.round(v/2%1,2);if(!t._context.staticPlot){var y=i.opacity(e.mc||l.marker.color),x=1>y||v>.01?o:s;d=x(d,h),h=x(h,d),p=x(p,g),g=x(g,p)}r.select(this).attr("d","M"+d+","+p+"V"+g+"H"+h+"V"+p+"Z")})}),d.call(l.plot,e)}},{"../../components/color":18,"../../components/errorbars":47,"../../lib":94,"./arrays_to_calcdata":148,d3:9,"fast-isnumeric":11}],157:[function(t,e,n){"use strict";var r=t("fast-isnumeric"),a=t("../../plots/plots"),o=t("../../plots/cartesian/axes"),i=t("../../lib");e.exports=function(t,e){var n,l,s=t._fullLayout,c=e.x(),u=e.y();["v","h"].forEach(function(f){function d(e){function n(t){t[p]=t.p+d}var r=[];e.forEach(function(e){t.calcdata[e].forEach(function(t){r.push(t.p)})});var a=i.distinctVals(r),l=a.vals,c=a.minDiff,u=!1,f=[];"group"===s.barmode&&e.forEach(function(e){u||(t.calcdata[e].forEach(function(t){u||f.forEach(function(e){Math.abs(t.p-e)_&&(S=!0,A=_),_>M+P&&(S=!0,M=_))}o.expand(m,[A,M],{tozero:!0,padded:S})}else{var N=function(t){return t[g]=t.s,t.s};for(n=0;n1||0===l.bargap&&0===l.bargroupgap&&!t[0].trace.marker.line.width)&&r.select(this).attr("shape-rendering","crispEdges")}),e.selectAll("g.points").each(function(t){var e=t[0].trace,n=e.marker,i=n.line,l=(e._input||{}).marker||{},s=o.tryColorscale(n,l,""),c=o.tryColorscale(n,l,"line.");r.select(this).selectAll("path").each(function(t){var e,o,l=(t.mlw+1||i.width+1)-1,u=r.select(this);e="mc"in t?t.mcc=s(t.mc):Array.isArray(n.color)?a.defaultLine:n.color,u.style("stroke-width",l+"px").call(a.fill,e),l&&(o="mlc"in t?t.mlcc=c(t.mlc):Array.isArray(i.color)?a.defaultLine:i.color,u.call(a.stroke,o))})}),e.call(i.style)}},{"../../components/color":18,"../../components/drawing":41,"../../components/errorbars":47,d3:9}],159:[function(t,e,n){"use strict";var r=t("../../components/color"),a=t("../../components/colorscale/has_colorscale"),o=t("../../components/colorscale/defaults");e.exports=function(t,e,n,i,l){n("marker.color",i),a(t,"marker")&&o(t,e,l,n,{prefix:"marker.",cLetter:"c"}),n("marker.line.color",r.defaultLine),a(t,"marker.line")&&o(t,e,l,n,{prefix:"marker.line.",cLetter:"c"}),n("marker.line.width")}},{"../../components/color":18,"../../components/colorscale/defaults":28,"../../components/colorscale/has_colorscale":31}],160:[function(t,e,n){"use strict";var r=t("../../components/color/attributes"),a=t("../../plots/font_attributes"),o=t("../../plots/attributes"),i=t("../../lib/extend").extendFlat;e.exports={labels:{valType:"data_array"},label0:{valType:"number",dflt:0},dlabel:{valType:"number",dflt:1},values:{valType:"data_array"},marker:{colors:{valType:"data_array"},line:{color:{valType:"color",dflt:r.defaultLine,arrayOk:!0},width:{valType:"number",min:0,dflt:0,arrayOk:!0}}},text:{valType:"data_array"},scalegroup:{valType:"string",dflt:""},textinfo:{valType:"flaglist",flags:["label","text","value","percent"],extras:["none"]},hoverinfo:i({},o.hoverinfo,{flags:["label","text","value","percent","name"]}),textposition:{valType:"enumerated",values:["inside","outside","auto","none"],dflt:"auto",arrayOk:!0},textfont:i({},a,{}),insidetextfont:i({},a,{}),outsidetextfont:i({},a,{}),domain:{x:{valType:"info_array",items:[{valType:"number",min:0,max:1},{valType:"number",min:0,max:1}],dflt:[0,1]},y:{valType:"info_array",items:[{valType:"number",min:0,max:1},{valType:"number",min:0,max:1}],dflt:[0,1]}},hole:{valType:"number",min:0,max:1,dflt:0},sort:{valType:"boolean",dflt:!0},direction:{valType:"enumerated",values:["clockwise","counterclockwise"],dflt:"counterclockwise"},rotation:{valType:"number",min:-360,max:360,dflt:0},pull:{valType:"number",min:0,max:1,dflt:0,arrayOk:!0}}},{"../../components/color/attributes":17,"../../lib/extend":93,"../../plots/attributes":113,"../../plots/font_attributes":133}],161:[function(t,e,n){"use strict";function r(t,e){for(var n=[],r=0;rs||(c=p[n],void 0!==c&&""!==c||(c=n),c=String(c),void 0===y[c]&&(y[c]=!0,u=o(e.marker.colors[n]),u.isValid()?(u=i.addOpacity(u,u.getAlpha()),m[c]||(m[c]=u)):m[c]?u=m[c]:(u=!1,x=!0),f=-1!==_.indexOf(c),f||(b+=s),g.push({v:s,label:c,color:u,i:n,hidden:f}))));if(e.sort&&g.sort(function(t,e){return e.v-t.v}),x)for(n=0;n")}return g};var s},{"../../components/color":18,"./helpers":164,"fast-isnumeric":11,tinycolor2:13}],163:[function(t,e,n){"use strict";var r=t("../../lib"),a=t("./attributes");e.exports=function(t,e,n,o){function i(n,o){return r.coerce(t,e,a,n,o)}var l=r.coerceFont,s=i("values");if(!Array.isArray(s)||!s.length)return void(e.visible=!1);var c=i("labels");Array.isArray(c)||(i("label0"),i("dlabel"));var u=i("marker.line.width");u&&i("marker.line.color");var f=i("marker.colors");Array.isArray(f)||(e.marker.colors=[]),i("scalegroup");var d=i("text"),h=i("textinfo",Array.isArray(d)?"text+percent":"percent");if(i("hoverinfo",1===o._dataLength?"label+text+value+percent":void 0),h&&"none"!==h){var p=i("textposition"),g=Array.isArray(p)||"auto"===p,v=g||"inside"===p,m=g||"outside"===p;if(v||m){var y=l(i,"textfont",o.font);v&&l(i,"insidetextfont",y),m&&l(i,"outsidetextfont",y)}}i("domain.x"),i("domain.y"),i("hole"),i("sort"),i("direction"),i("rotation"),i("pull")}},{"../../lib":94,"./attributes":160}],164:[function(t,e,n){"use strict";var r=t("../../lib");n.formatPiePercent=function(t,e){var n=(100*t).toPrecision(3);return-1!==n.lastIndexOf(".")&&(n=n.replace(/[.]?0+$/,"")),r.numSeparate(n,e)+"%"},n.formatPieValue=function(t,e){var n=t.toPrecision(10);return-1!==n.lastIndexOf(".")&&(n=n.replace(/[.]?0+$/,"")),r.numSeparate(n,e)}},{"../../lib":94}],165:[function(t,e,n){"use strict";var r={};r.attributes=t("./attributes"),r.supplyDefaults=t("./defaults"),r.supplyLayoutDefaults=t("./layout_defaults"),r.layoutAttributes=t("./layout_attributes"),r.calc=t("./calc"),r.plot=t("./plot"),r.style=t("./style"),r.styleOne=t("./style_one"),r.moduleType="trace",r.name="pie",r.basePlotModule=t("./base_plot"),r.categories=["pie","showLegend"],r.meta={},e.exports=r},{"./attributes":160,"./base_plot":161,"./calc":162,"./defaults":163,"./layout_attributes":166,"./layout_defaults":167,"./plot":168,"./style":169,"./style_one":170}],166:[function(t,e,n){"use strict";e.exports={hiddenlabels:{valType:"data_array"}}},{}],167:[function(t,e,n){"use strict";var r=t("../../lib"),a=t("./layout_attributes");e.exports=function(t,e){function n(n,o){return r.coerce(t,e,a,n,o)}n("hiddenlabels")}},{"../../lib":94,"./layout_attributes":166}],168:[function(t,e,n){"use strict";function r(t,e,n){var r=Math.sqrt(t.width*t.width+t.height*t.height),o=t.width/t.height,i=Math.PI*Math.min(e.v/n.vTotal,.5),l=1-n.trace.hole,s=a(e,n),c={scale:s*n.r*2/r,rCenter:1-s,rotate:0};if(c.scale>=1)return c;var u=o+1/(2*Math.tan(i)),f=n.r*Math.min(1/(Math.sqrt(u*u+.5)+u),l/(Math.sqrt(o*o+l/2)+o)),d={scale:2*f/t.height,rCenter:Math.cos(f/n.r)-f*o/n.r,rotate:(180/Math.PI*e.midangle+720)%180-90},h=1/o,p=h+1/(2*Math.tan(i)),g=n.r*Math.min(1/(Math.sqrt(p*p+.5)+p),l/(Math.sqrt(h*h+l/2)+h)),v={scale:2*g/t.width,rCenter:Math.cos(g/n.r)-g/o/n.r,rotate:(180/Math.PI*e.midangle+810)%180-90},m=v.scale>d.scale?v:d;return c.scale<1&&m.scale>c.scale?m:c}function a(t,e){if(t.v===e.vTotal&&!e.trace.hole)return 1;var n=Math.PI*Math.min(t.v/e.vTotal,.5);return Math.min(1/(1+1/Math.sin(n)),(1-e.trace.hole)/2)}function o(t,e){var n=e.pxmid[0],r=e.pxmid[1],a=t.width/2,o=t.height/2;return 0>n&&(a*=-1),0>r&&(o*=-1),{scale:1,rCenter:1,rotate:0,x:a+Math.abs(o)*(a>0?1:-1)/2,y:o/(1+n*n/(r*r)),outside:!0}}function i(t,e){function n(t,e){return t.pxmid[1]-e.pxmid[1]}function r(t,e){return e.pxmid[1]-t.pxmid[1]}function a(t,n){n||(n={});var r,a,o,l,d,h,g=n.labelExtraY+(i?n.yLabelMax:n.yLabelMin),v=i?t.yLabelMin:t.yLabelMax,m=i?t.yLabelMax:t.yLabelMin,y=t.cyFinal+c(t.px0[1],t.px1[1]),x=g-v;if(x*f>0&&(t.labelExtraY=x),Array.isArray(e.pull))for(a=0;a=e.pull[o.i]||((t.pxmid[1]-o.pxmid[1])*f>0?(l=o.cyFinal+c(o.px0[1],o.px1[1]),x=l-v-t.labelExtraY,x*f>0&&(t.labelExtraY+=x)):(m+t.labelExtraY-y)*f>0&&(r=3*u*Math.abs(a-p.indexOf(t)),d=o.cxFinal+s(o.px0[0],o.px1[0]),h=d+r-(t.cxFinal+t.pxmid[0])-t.labelExtraX,h*u>0&&(t.labelExtraX+=h)))}var o,i,l,s,c,u,f,d,h,p,g,v,m;for(i=0;2>i;i++)for(l=i?n:r,c=i?Math.max:Math.min,f=i?1:-1,o=0;2>o;o++){for(s=o?Math.max:Math.min,u=o?1:-1,d=t[i][o],d.sort(l),h=t[1-i][o],p=h.concat(d),v=[],g=0;gu&&(u=l.pull[o]);i.r=Math.min(n/c(l.tilt,Math.sin(s),l.depth),r/c(l.tilt,Math.cos(s),l.depth))/(2+2*u),i.cx=e.l+e.w*(l.domain.x[1]+l.domain.x[0])/2,i.cy=e.t+e.h*(2-l.domain.y[1]-l.domain.y[0])/2,l.scalegroup&&-1===h.indexOf(l.scalegroup)&&h.push(l.scalegroup)}for(o=0;of.vTotal/2?1:0)}function c(t,e,n){if(!t)return 1;var r=Math.sin(t*Math.PI/180);return Math.max(.01,n*r*Math.abs(e)+2*Math.sqrt(1-r*r*e*e))}var u=t("d3"),f=t("../../plots/cartesian/graph_interact"),d=t("../../components/color"),h=t("../../components/drawing"),p=t("../../lib/svg_text_utils"),g=t("./helpers");e.exports=function(t,e){var n=t._fullLayout;l(e,n._size);var c=n._pielayer.selectAll("g.trace").data(e);c.enter().append("g").attr({"stroke-linejoin":"round","class":"trace"}),c.exit().remove(),c.order(),c.each(function(e){var l=u.select(this),c=e[0],v=c.trace,m=0,y=(v.depth||0)*c.r*Math.sin(m)/2,x=v.tiltaxis||0,b=x*Math.PI/180,_=[y*Math.sin(b),y*Math.cos(b)],w=c.r*Math.cos(m),k=l.selectAll("g.part").data(v.tilt?["top","sides"]:["top"]);k.enter().append("g").attr("class",function(t){return t+" part"}),k.exit().remove(),k.order(),s(e),l.selectAll(".top").each(function(){var l=u.select(this).selectAll("g.slice").data(e);l.enter().append("g").classed("slice",!0),l.exit().remove();var s=[[[],[]],[[],[]]],m=!1;l.each(function(i){function l(e){var r=t._fullLayout,o=t._fullData[v.index],l=o.hoverinfo;if("all"===l&&(l="label+text+value+percent+name"),!t._dragging&&r.hovermode!==!1&&"none"!==l&&l){var s=a(i,c),u=k+i.pxmid[0]*(1-s),d=M+i.pxmid[1]*(1-s),h=n.separators,p=[];-1!==l.indexOf("label")&&p.push(i.label),o.text&&o.text[i.i]&&-1!==l.indexOf("text")&&p.push(o.text[i.i]),-1!==l.indexOf("value")&&p.push(g.formatPieValue(i.v,h)),-1!==l.indexOf("percent")&&p.push(g.formatPiePercent(i.v/c.vTotal,h)),f.loneHover({x0:u-s*c.r,x1:u+s*c.r,y:d,text:p.join("
"),name:-1!==l.indexOf("name")?o.name:void 0,color:i.color,idealAlign:i.pxmid[0]<0?"left":"right"},{container:r._hoverlayer.node(),outerContainer:r._paper.node()}),f.hover(t,e,"pie"),L=!0}}function d(e){t.emit("plotly_unhover",{points:[e]}),L&&(f.loneUnhover(n._hoverlayer.node()),L=!1)}function y(){t._hoverdata=[i],t._hoverdata.trace=e.trace,f.click(t,{target:!0})}function b(t,e,n,r){return"a"+r*c.r+","+r*w+" "+x+" "+i.largeArc+(n?" 1 ":" 0 ")+r*(e[0]-t[0])+","+r*(e[1]-t[1])}if(i.hidden)return void u.select(this).selectAll("path,g").remove();s[i.pxmid[1]<0?0:1][i.pxmid[0]<0?0:1].push(i);var k=c.cx+_[0],M=c.cy+_[1],A=u.select(this),T=A.selectAll("path.surface").data([i]),L=!1;if(T.enter().append("path").classed("surface",!0).style({"pointer-events":"all"}),A.select("path.textline").remove(),A.on("mouseover",l).on("mouseout",d).on("click",y),v.pull){var z=+(Array.isArray(v.pull)?v.pull[i.i]:v.pull)||0;z>0&&(k+=z*i.pxmid[0],M+=z*i.pxmid[1])}i.cxFinal=k,i.cyFinal=M;var S=v.hole;if(i.v===c.vTotal){var C="M"+(k+i.px0[0])+","+(M+i.px0[1])+b(i.px0,i.pxmid,!0,1)+b(i.pxmid,i.px0,!0,1)+"Z";S?T.attr("d","M"+(k+S*i.px0[0])+","+(M+S*i.px0[1])+b(i.px0,i.pxmid,!1,S)+b(i.pxmid,i.px0,!1,S)+"Z"+C):T.attr("d",C)}else{var E=b(i.px0,i.px1,!0,1);if(S){var O=1-S;T.attr("d","M"+(k+S*i.px1[0])+","+(M+S*i.px1[1])+b(i.px1,i.px0,!1,S)+"l"+O*i.px0[0]+","+O*i.px0[1]+E+"Z")}else T.attr("d","M"+k+","+M+"l"+i.px0[0]+","+i.px0[1]+E+"Z")}var P=Array.isArray(v.textposition)?v.textposition[i.i]:v.textposition,N=A.selectAll("g.slicetext").data(i.text&&"none"!==P?[0]:[]);N.enter().append("g").classed("slicetext",!0),N.exit().remove(),N.each(function(){var t=u.select(this).selectAll("text").data([0]);t.enter().append("text").attr("data-notex",1),t.exit().remove(),t.text(i.text).attr({"class":"slicetext",transform:"","data-bb":"","text-anchor":"middle",x:0,y:0}).call(h.font,"outside"===P?v.outsidetextfont:v.insidetextfont).call(p.convertToTspans),t.selectAll("tspan.line").attr({x:0,y:0});var e,n=h.bBox(t.node());"outside"===P?e=o(n,i):(e=r(n,i,c),"auto"===P&&e.scale<1&&(t.call(h.font,v.outsidetextfont),v.outsidetextfont.family===v.insidetextfont.family&&v.outsidetextfont.size===v.insidetextfont.size||(t.attr({"data-bb":""}),n=h.bBox(t.node())),e=o(n,i)));var a=k+i.pxmid[0]*e.rCenter+(e.x||0),l=M+i.pxmid[1]*e.rCenter+(e.y||0);e.outside&&(i.yLabelMin=l-n.height/2,i.yLabelMid=l,i.yLabelMax=l+n.height/2,i.labelExtraX=0,i.labelExtraY=0,m=!0),t.attr("transform","translate("+a+","+l+")"+(e.scale<1?"scale("+e.scale+")":"")+(e.rotate?"rotate("+e.rotate+")":"")+"translate("+-(n.left+n.right)/2+","+-(n.top+n.bottom)/2+")")})}),m&&i(s,v),l.each(function(t){if(t.labelExtraX||t.labelExtraY){var e=u.select(this),n=e.select("g.slicetext text");n.attr("transform","translate("+t.labelExtraX+","+t.labelExtraY+")"+n.attr("transform"));var r=t.cxFinal+t.pxmid[0],a=t.cyFinal+t.pxmid[1],o="M"+r+","+a,i=(t.yLabelMax-t.yLabelMin)*(t.pxmid[0]<0?-1:1)/4;if(t.labelExtraX){var l=t.labelExtraX*t.pxmid[1]/t.pxmid[0],s=t.yLabelMid+t.labelExtraY-(t.cyFinal+t.pxmid[1]);o+=Math.abs(l)>Math.abs(s)?"l"+s*t.pxmid[0]/t.pxmid[1]+","+s+"H"+(r+t.labelExtraX+i):"l"+t.labelExtraX+","+l+"v"+(s-l)+"h"+i}else o+="V"+(t.yLabelMid+t.labelExtraY)+"h"+i;e.append("path").classed("textline",!0).call(d.stroke,v.outsidetextfont.color).attr({"stroke-width":Math.min(2,v.outsidetextfont.size/8),d:o,fill:"none"})}})})}),setTimeout(function(){c.selectAll("tspan").each(function(){var t=u.select(this);t.attr("dy")&&t.attr("dy",t.attr("dy"))})},0)}},{"../../components/color":18,"../../components/drawing":41,"../../lib/svg_text_utils":105,"../../plots/cartesian/graph_interact":122,"./helpers":164,d3:9}],169:[function(t,e,n){"use strict";var r=t("d3"),a=t("./style_one");e.exports=function(t){t._fullLayout._pielayer.selectAll(".trace").each(function(t){var e=t[0],n=e.trace,o=r.select(this);o.style({opacity:n.opacity}),o.selectAll(".top path.surface").each(function(t){r.select(this).call(a,t,n)})})}},{"./style_one":170,d3:9}],170:[function(t,e,n){"use strict";var r=t("../../components/color");e.exports=function(t,e,n){var a=n.marker.line.color;Array.isArray(a)&&(a=a[e.i]||r.defaultLine);var o=n.marker.line.width||0;Array.isArray(o)&&(o=o[e.i]||0),t.style({"stroke-width":o,fill:e.color}).call(r.stroke,a)}},{"../../components/color":18}],171:[function(t,e,n){"use strict";var r=t("../../lib");e.exports=function(t){var e=t[0].trace,n=e.marker;if(r.mergeArray(e.text,t,"tx"),r.mergeArray(e.textposition,t,"tp"),e.textfont&&(r.mergeArray(e.textfont.size,t,"ts"),r.mergeArray(e.textfont.color,t,"tc"),r.mergeArray(e.textfont.family,t,"tf")),n&&n.line){var a=n.line;r.mergeArray(n.opacity,t,"mo"),r.mergeArray(n.symbol,t,"mx"),r.mergeArray(n.color,t,"mc"),r.mergeArray(a.color,t,"mlc"),r.mergeArray(a.width,t,"mlw")}}},{"../../lib":94}],172:[function(t,e,n){"use strict";var r=t("../../components/colorscale/color_attributes"),a=t("../../components/drawing"),o=(t("./constants"),t("../../lib/extend").extendFlat);e.exports={x:{valType:"data_array"},x0:{valType:"any",dflt:0},dx:{valType:"number",dflt:1},y:{valType:"data_array"},y0:{valType:"any",dflt:0},dy:{valType:"number",dflt:1},text:{valType:"string",dflt:"",arrayOk:!0},mode:{valType:"flaglist",flags:["lines","markers","text"],extras:["none"]},hoveron:{valType:"flaglist",flags:["points","fills"]},line:{color:{valType:"color"},width:{valType:"number",min:0,dflt:2},shape:{valType:"enumerated",values:["linear","spline","hv","vh","hvh","vhv"],dflt:"linear"},smoothing:{valType:"number",min:0,max:1.3,dflt:1},dash:{valType:"string",values:["solid","dot","dash","longdash","dashdot","longdashdot"],dflt:"solid"}},connectgaps:{valType:"boolean",dflt:!1},fill:{valType:"enumerated",values:["none","tozeroy","tozerox","tonexty","tonextx","toself","tonext"],dflt:"none"},fillcolor:{valType:"color"},marker:o({},{symbol:{valType:"enumerated",values:a.symbolList,dflt:"circle",arrayOk:!0},opacity:{valType:"number",min:0,max:1,arrayOk:!0},size:{valType:"number",min:0,dflt:6,arrayOk:!0},maxdisplayed:{valType:"number",min:0,dflt:0},sizeref:{valType:"number", +-dflt:1},sizemin:{valType:"number",min:0,dflt:0},sizemode:{valType:"enumerated",values:["diameter","area"],dflt:"diameter"},showscale:{valType:"boolean",dflt:!1},line:o({},{width:{valType:"number",min:0,arrayOk:!0}},r("marker.line"))},r("marker")),textposition:{valType:"enumerated",values:["top left","top center","top right","middle left","middle center","middle right","bottom left","bottom center","bottom right"],dflt:"middle center",arrayOk:!0},textfont:{family:{valType:"string",noBlank:!0,strict:!0,arrayOk:!0},size:{valType:"number",min:1,arrayOk:!0},color:{valType:"color",arrayOk:!0}},r:{valType:"data_array"},t:{valType:"data_array"},_nestedModules:{error_y:"ErrorBars",error_x:"ErrorBars","marker.colorbar":"Colorbar"}}},{"../../components/colorscale/color_attributes":26,"../../components/drawing":41,"../../lib/extend":93,"./constants":177}],173:[function(t,e,n){"use strict";var r=t("fast-isnumeric"),a=t("../../plots/cartesian/axes"),o=t("../../lib"),i=t("./subtypes"),l=t("./colorscale_calc");e.exports=function(t,e){var n,s,c,u=a.getFromId(t,e.xaxis||"x"),f=a.getFromId(t,e.yaxis||"y"),d=u.makeCalcdata(e,"x"),h=f.makeCalcdata(e,"y"),p=Math.min(d.length,h.length);u._minDtick=0,f._minDtick=0,d.length>p&&d.splice(p,d.length-p),h.length>p&&h.splice(p,h.length-p);var g={padded:!0},v={padded:!0};if(i.hasMarkers(e)){if(n=e.marker,s=n.size,Array.isArray(s)){var m={type:"linear"};a.setConvert(m),s=m.makeCalcdata(e.marker,"size"),s.length>p&&s.splice(p,s.length-p)}var y,x=1.6*(e.marker.sizeref||1);y="area"===e.marker.sizemode?function(t){return Math.max(Math.sqrt((t||0)/x),3)}:function(t){return Math.max((t||0)/x,3)},g.ppad=v.ppad=Array.isArray(s)?s.map(y):y(s)}l(e),!("tozerox"===e.fill||"tonextx"===e.fill&&t.firstscatter)||d[0]===d[p-1]&&h[0]===h[p-1]?e.error_y.visible||-1===["tonexty","tozeroy"].indexOf(e.fill)&&(i.hasMarkers(e)||i.hasText(e))||(g.padded=!1,g.ppad=0):g.tozero=!0,!("tozeroy"===e.fill||"tonexty"===e.fill&&t.firstscatter)||d[0]===d[p-1]&&h[0]===h[p-1]?-1!==["tonextx","tozerox"].indexOf(e.fill)&&(v.padded=!1):v.tozero=!0,a.expand(u,d,g),a.expand(f,h,v);var b=new Array(p);for(c=0;p>c;c++)b[c]=r(d[c])&&r(h[c])?{x:d[c],y:h[c]}:{x:!1,y:!1};return void 0!==typeof s&&o.mergeArray(s,b,"ms"),t.firstscatter=!1,b}},{"../../lib":94,"../../plots/cartesian/axes":115,"./colorscale_calc":176,"./subtypes":191,"fast-isnumeric":11}],174:[function(t,e,n){"use strict";e.exports=function(t){var e,n,r,a,o;for(e=0;e=0;a--)if(o=t[a],"scatter"===o.type&&o.xaxis===n.xaxis&&o.yaxis===n.yaxis){o.opacity=void 0;break}}},{}],175:[function(t,e,n){"use strict";var r=t("d3"),a=t("fast-isnumeric"),o=t("../../lib"),i=t("../../plots/plots"),l=t("../../components/colorscale/get_scale"),s=t("../../components/colorbar/draw");e.exports=function(t,e){var n=e[0].trace,c=n.marker,u="cb"+n.uid;if(t._fullLayout._infolayer.selectAll("."+u).remove(),void 0===c||!c.showscale)return void i.autoMargin(t,u);var f=l(c.colorscale),d=c.color,h=c.cmin,p=c.cmax;a(h)||(h=o.aggNums(Math.min,null,d)),a(p)||(p=o.aggNums(Math.max,null,d));var g=e[0].t.cb=s(t,u);g.fillcolor(r.scale.linear().domain(f.map(function(t){return h+t[0]*(p-h)})).range(f.map(function(t){return t[1]}))).filllevels({start:h,end:p,size:(p-h)/254}).options(c.colorbar)()}},{"../../components/colorbar/draw":21,"../../components/colorscale/get_scale":30,"../../lib":94,"../../plots/plots":135,d3:9,"fast-isnumeric":11}],176:[function(t,e,n){"use strict";var r=t("../../components/colorscale/has_colorscale"),a=t("../../components/colorscale/calc"),o=t("./subtypes");e.exports=function(t){o.hasLines(t)&&r(t,"line")&&a(t,t.line.color,"line","c"),o.hasMarkers(t)&&(r(t,"marker")&&a(t,t.marker.color,"marker","c"),r(t,"marker.line")&&a(t,t.marker.line.color,"marker.line","c"))}},{"../../components/colorscale/calc":25,"../../components/colorscale/has_colorscale":31,"./subtypes":191}],177:[function(t,e,n){"use strict";e.exports={PTS_LINESONLY:20}},{}],178:[function(t,e,n){"use strict";var r=t("../../lib"),a=t("./attributes"),o=t("./constants"),i=t("./subtypes"),l=t("./xy_defaults"),s=t("./marker_defaults"),c=t("./line_defaults"),u=t("./line_shape_defaults"),f=t("./text_defaults"),d=t("./fillcolor_defaults"),h=t("../../components/errorbars/defaults");e.exports=function(t,e,n,p){function g(n,o){return r.coerce(t,e,a,n,o)}var v=l(t,e,g),m=vB!=P>=B&&(C=z[T-1][0],E=z[T][0],S=C+(E-C)*(B-O)/(P-O),R=Math.min(R,S),j=Math.max(j,S));R=Math.max(R,0),j=Math.min(j,d._length);var H=s.defaultLine;return s.opacity(f.fillcolor)?H=f.fillcolor:s.opacity((f.line||{}).color)&&(H=f.line.color),r.extendFlat(t,{distance:o.MAXDIST+10,x0:R,x1:j,y0:B,y1:B,color:H}),delete t.index,f.text&&!Array.isArray(f.text)?t.text=String(f.text):t.text=f.name,[t]}}}},{"../../components/color":18,"../../components/errorbars":47,"../../lib":94,"../../plots/cartesian/constants":120,"../../plots/cartesian/graph_interact":122,"./get_trace_color":180}],182:[function(t,e,n){"use strict";var r={},a=t("./subtypes");r.hasLines=a.hasLines,r.hasMarkers=a.hasMarkers,r.hasText=a.hasText,r.isBubble=a.isBubble,r.attributes=t("./attributes"),r.supplyDefaults=t("./defaults"),r.cleanData=t("./clean_data"),r.calc=t("./calc"),r.arraysToCalcdata=t("./arrays_to_calcdata"),r.plot=t("./plot"),r.colorbar=t("./colorbar"),r.style=t("./style"),r.hoverPoints=t("./hover"),r.selectPoints=t("./select"),r.moduleType="trace",r.name="scatter",r.basePlotModule=t("../../plots/cartesian"),r.categories=["cartesian","symbols","markerColorscale","errorBarsOK","showLegend"],r.meta={},e.exports=r},{"../../plots/cartesian":123,"./arrays_to_calcdata":171,"./attributes":172,"./calc":173,"./clean_data":174,"./colorbar":175,"./defaults":178,"./hover":181,"./plot":188,"./select":189,"./style":190,"./subtypes":191}],183:[function(t,e,n){"use strict";var r=t("../../components/colorscale/has_colorscale"),a=t("../../components/colorscale/defaults");e.exports=function(t,e,n,o,i){var l=(t.marker||{}).color;if(i("line.color",n),r(t,"line"))a(t,e,o,i,{prefix:"line.",cLetter:"c"});else{var s=(Array.isArray(l)?!1:l)||n;i("line.color",s)}i("line.width"),i("line.dash")}},{"../../components/colorscale/defaults":28,"../../components/colorscale/has_colorscale":31}],184:[function(t,e,n){"use strict";var r=t("../../plots/cartesian/axes");e.exports=function(t,e){function n(e){var n=w.c2p(t[e].x),r=k.c2p(t[e].y);return n===z||r===z?!1:[n,r]}function a(t){var e=t[0]/w._length,n=t[1]/k._length;return(1+10*Math.max(0,-e,e-1,-n,n-1))*A}function o(t,e){var n=t[0]-e[0],r=t[1]-e[1];return Math.sqrt(n*n+r*r)}var i,l,s,c,u,f,d,h,p,g,v,m,y,x,b,_,w=e.xaxis,k=e.yaxis,M=e.connectGaps,A=e.baseTolerance,T=e.linear,L=[],z=r.BADNUM,S=.2,C=new Array(t.length),E=0;for(i=0;ia(f))break;s=f,y=g[0]*p[0]+g[1]*p[1],y>v?(v=y,c=f,h=!1):m>y&&(m=y,u=f,h=!0)}if(h?(C[E++]=c,s!==u&&(C[E++]=u)):(u!==l&&(C[E++]=u),s!==c&&(C[E++]=c)),C[E++]=s,i>=t.length||!f)break;C[E++]=f,l=f}}else C[E++]=c}L.push(C.slice(0,E))}return L}},{"../../plots/cartesian/axes":115}],185:[function(t,e,n){"use strict";e.exports=function(t,e,n){var r=n("line.shape");"spline"===r&&n("line.smoothing")}},{}],186:[function(t,e,n){"use strict";var r=t("fast-isnumeric");e.exports=function(t){var e=t.marker,n=e.sizeref||1,a=e.sizemin||0,o="area"===e.sizemode?function(t){return Math.sqrt(t/n)}:function(t){return t/n};return function(t){var e=o(t/2);return r(e)&&e>0?Math.max(e,a):0}}},{"fast-isnumeric":11}],187:[function(t,e,n){"use strict";var r=t("../../components/color"),a=t("../../components/colorscale/has_colorscale"),o=t("../../components/colorscale/defaults"),i=t("./subtypes");e.exports=function(t,e,n,l,s){var c,u=i.isBubble(t),f=(t.line||{}).color;f&&(n=f),s("marker.symbol"),s("marker.opacity",u?.7:1),s("marker.size"),s("marker.color",n),a(t,"marker")&&o(t,e,l,s,{prefix:"marker.",cLetter:"c"}),c=f&&!Array.isArray(f)&&e.marker.color!==f?f:u?r.background:r.defaultLine,s("marker.line.color",c),a(t,"marker.line")&&o(t,e,l,s,{prefix:"marker.line.",cLetter:"c"}),s("marker.line.width",u?1:0),u&&(s("marker.sizeref"),s("marker.sizemin"),s("marker.sizemode"))}},{"../../components/color":18,"../../components/colorscale/defaults":28,"../../components/colorscale/has_colorscale":31,"./subtypes":191}],188:[function(t,e,n){"use strict";function r(t,e,n){var r=e.x(),o=e.y(),i=a.extent(r.range.map(r.l2c)),l=a.extent(o.range.map(o.l2c));n.forEach(function(t,e){var r=t[0].trace;if(c.hasMarkers(r)){var a=r.marker.maxdisplayed;if(0!==a){var o=t.filter(function(t){return t.x>=i[0]&&t.x<=i[1]&&t.y>=l[0]&&t.y<=l[1]}),s=Math.ceil(o.length/a),u=0;n.forEach(function(t,n){var r=t[0].trace;c.hasMarkers(r)&&r.marker.maxdisplayed>0&&e>n&&u++});var f=Math.round(u*s/3+Math.floor(u/3)*s/7.1);t.forEach(function(t){delete t.vis}),o.forEach(function(t,e){0===Math.round((e+f)%s)&&(t.vis=!0)})}}})}var a=t("d3"),o=t("../../lib"),i=t("../../components/drawing"),l=t("../../components/errorbars"),s=t("../../lib/polygon").tester,c=t("./subtypes"),u=t("./arrays_to_calcdata"),f=t("./line_points");e.exports=function(t,e,n){function d(t){return t.filter(function(t){return t.vis})}r(t,e,n);var h=e.x(),p=e.y(),g=e.plot.select(".scatterlayer").selectAll("g.trace.scatter").data(n);g.enter().append("g").attr("class","trace scatter").style("stroke-miterlimit",2),g.call(l.plot,e);var v,m,y,x,b="",_=[];g.each(function(t){var e=t[0].trace,n=e.line,r=a.select(this);if(e.visible===!0&&(m=e.fill.charAt(e.fill.length-1),"x"!==m&&"y"!==m&&(m=""),t[0].node3=r,u(t),c.hasLines(e)||"none"!==e.fill)){var o,l,d,g,w,k="",M="";v="tozero"===e.fill.substr(0,6)||"toself"===e.fill||"to"===e.fill.substr(0,2)&&!b?r.append("path").classed("js-fill",!0):null,x&&(y=x.datum(t)),x=r.append("path").classed("js-fill",!0),-1!==["hv","vh","hvh","vhv"].indexOf(n.shape)?(d=i.steps(n.shape),g=i.steps(n.shape.split("").reverse().join(""))):d=g="spline"===n.shape?function(t){var e=t[t.length-1];return t[0][0]===e[0]&&t[0][1]===e[1]?i.smoothclosed(t.slice(1),n.smoothing):i.smoothopen(t,n.smoothing)}:function(t){return"M"+t.join("L")},w=function(t){return g(t.reverse())};var A,T=f(t,{xaxis:h,yaxis:p,connectGaps:e.connectgaps,baseTolerance:Math.max(n.width||1,3)/4,linear:"linear"===n.shape}),L=e._polygons=new Array(T.length);for(A=0;A1&&r.append("path").classed("js-line",!0).style("vector-effect","non-scaling-stroke").attr("d",o)}v?z&&C&&(m?("y"===m?z[1]=C[1]=p.c2p(0,!0):"x"===m&&(z[0]=C[0]=h.c2p(0,!0)),v.attr("d",k+"L"+C+"L"+z+"Z")):v.attr("d",k+"Z")):"tonext"===e.fill.substr(0,6)&&k&&b&&("tonext"===e.fill?y.attr("d",k+"Z"+b+"Z"):y.attr("d",k+"L"+b.substr(1)+"Z"),e._polygons=e._polygons.concat(_)),b=M,_=L}}}),g.selectAll("path:not([d])").remove(),g.append("g").attr("class","points").each(function(t){var e=t[0].trace,n=a.select(this),r=c.hasMarkers(e),l=c.hasText(e);!r&&!l||e.visible!==!0?n.remove():(r&&n.selectAll("path.point").data(e.marker.maxdisplayed?d:o.identity).enter().append("path").classed("point",!0).call(i.translatePoints,h,p),l&&n.selectAll("g").data(e.marker.maxdisplayed?d:o.identity).enter().append("g").append("text").call(i.translatePoints,h,p))})}},{"../../components/drawing":41,"../../components/errorbars":47,"../../lib":94,"../../lib/polygon":100,"./arrays_to_calcdata":171,"./line_points":184,"./subtypes":191,d3:9}],189:[function(t,e,n){"use strict";var r=t("./subtypes"),a=.2;e.exports=function(t,e){var n,o,i,l,s=t.cd,c=t.xaxis,u=t.yaxis,f=[],d=s[0].trace,h=d.index,p=d.marker,g=!r.hasMarkers(d)&&!r.hasText(d);if(d.visible===!0&&!g){var v=Array.isArray(p.opacity)?1:p.opacity;if(e===!1)for(n=0;ne?1:t>=e?0:NaN}function o(t){return null===t?NaN:+t}function i(t){return!isNaN(t)}function l(t){return{left:function(e,n,r,a){for(arguments.length<3&&(r=0),arguments.length<4&&(a=e.length);r>>1;t(e[o],n)<0?r=o+1:a=o}return r},right:function(e,n,r,a){for(arguments.length<3&&(r=0),arguments.length<4&&(a=e.length);r>>1;t(e[o],n)>0?a=o:r=o+1}return r}}}function s(t){return t.length}function c(t){for(var e=1;t*e%1;)e*=10;return e}function u(t,e){for(var n in e)Object.defineProperty(t.prototype,n,{value:e[n],enumerable:!1})}function f(){this._=Object.create(null)}function d(t){return(t+="")===_i||t[0]===wi?wi+t:t}function h(t){return(t+="")[0]===wi?t.slice(1):t}function p(t){return d(t)in this._}function g(t){return(t=d(t))in this._&&delete this._[t]}function v(){var t=[];for(var e in this._)t.push(h(e));return t}function m(){var t=0;for(var e in this._)++t;return t}function y(){for(var t in this._)return!1;return!0}function x(){this._=Object.create(null)}function b(t){return t}function _(t,e,n){return function(){var r=n.apply(e,arguments);return r===e?t:r}}function w(t,e){if(e in t)return e;e=e.charAt(0).toUpperCase()+e.slice(1);for(var n=0,r=ki.length;n=e&&(e=a+1);!(i=l[e])&&++e0&&(t=t.slice(0,l));var c=Ni.get(t);return c&&(t=c,s=Q),l?e?a:r:e?k:o}function $(t,e){return function(n){var r=ui.event;ui.event=n,e[0]=this.__data__;try{t.apply(this,e)}finally{ui.event=r}}}function Q(t,e){var n=$(t,e);return function(t){var e=this,r=t.relatedTarget;r&&(r===e||8&r.compareDocumentPosition(e))||n.call(e,t)}}function W(t){var n=".dragsuppress-"+ ++Di,a="click"+n,o=ui.select(r(t)).on("touchmove"+n,T).on("dragstart"+n,T).on("selectstart"+n,T);if(null==Pi&&(Pi=!("onselectstart"in t)&&w(t.style,"userSelect")),Pi){var i=e(t).style,l=i[Pi];i[Pi]="none"}return function(t){if(o.on(n,null),Pi&&(i[Pi]=l),t){var e=function(){o.on(a,null)};o.on(a,function(){T(),e()},!0),setTimeout(e,0)}}}function J(t,e){e.changedTouches&&(e=e.changedTouches[0]);var n=t.ownerSVGElement||t;if(n.createSVGPoint){var a=n.createSVGPoint();if(Ii<0){var o=r(t);if(o.scrollX||o.scrollY){n=ui.select("body").append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important");var i=n[0][0].getScreenCTM();Ii=!(i.f||i.e),n.remove()}}return Ii?(a.x=e.pageX,a.y=e.pageY):(a.x=e.clientX,a.y=e.clientY),a=a.matrixTransform(t.getScreenCTM().inverse()),[a.x,a.y]}var l=t.getBoundingClientRect();return[e.clientX-l.left-t.clientLeft,e.clientY-l.top-t.clientTop]}function K(){return ui.event.changedTouches[0].identifier}function tt(t){return t>0?1:t<0?-1:0}function et(t,e,n){return(e[0]-t[0])*(n[1]-t[1])-(e[1]-t[1])*(n[0]-t[0])}function nt(t){return t>1?0:t<-1?Fi:Math.acos(t)}function rt(t){return t>1?Hi:t<-1?-Hi:Math.asin(t)}function at(t){return((t=Math.exp(t))-1/t)/2}function ot(t){return((t=Math.exp(t))+1/t)/2}function it(t){return((t=Math.exp(2*t))-1)/(t+1)}function lt(t){return(t=Math.sin(t/2))*t}function st(){}function ct(t,e,n){return this instanceof ct?(this.h=+t,this.s=+e,void(this.l=+n)):arguments.length<2?t instanceof ct?new ct(t.h,t.s,t.l):kt(""+t,Mt,ct):new ct(t,e,n)}function ut(t,e,n){function r(t){return t>360?t-=360:t<0&&(t+=360),t<60?o+(i-o)*t/60:t<180?i:t<240?o+(i-o)*(240-t)/60:o}function a(t){return Math.round(255*r(t))}var o,i;return t=isNaN(t)?0:(t%=360)<0?t+360:t,e=isNaN(e)?0:e<0?0:e>1?1:e,n=n<0?0:n>1?1:n,i=n<=.5?n*(1+e):n+e-n*e,o=2*n-i,new xt(a(t+120),a(t),a(t-120))}function ft(t,e,n){return this instanceof ft?(this.h=+t,this.c=+e,void(this.l=+n)):arguments.length<2?t instanceof ft?new ft(t.h,t.c,t.l):t instanceof ht?gt(t.l,t.a,t.b):gt((t=At((t=ui.rgb(t)).r,t.g,t.b)).l,t.a,t.b):new ft(t,e,n)}function dt(t,e,n){return isNaN(t)&&(t=0),isNaN(e)&&(e=0),new ht(n,Math.cos(t*=Vi)*e,Math.sin(t)*e)}function ht(t,e,n){return this instanceof ht?(this.l=+t,this.a=+e,void(this.b=+n)):arguments.length<2?t instanceof ht?new ht(t.l,t.a,t.b):t instanceof ft?dt(t.h,t.c,t.l):At((t=xt(t)).r,t.g,t.b):new ht(t,e,n)}function pt(t,e,n){var r=(t+16)/116,a=r+e/500,o=r-n/200;return a=vt(a)*tl,r=vt(r)*el,o=vt(o)*nl,new xt(yt(3.2404542*a-1.5371385*r-.4985314*o),yt(-.969266*a+1.8760108*r+.041556*o),yt(.0556434*a-.2040259*r+1.0572252*o))}function gt(t,e,n){return t>0?new ft(Math.atan2(n,e)*Zi,Math.sqrt(e*e+n*n),t):new ft(NaN,NaN,t)}function vt(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function mt(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function yt(t){return Math.round(255*(t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}function xt(t,e,n){return this instanceof xt?(this.r=~~t,this.g=~~e,void(this.b=~~n)):arguments.length<2?t instanceof xt?new xt(t.r,t.g,t.b):kt(""+t,xt,ut):new xt(t,e,n)}function bt(t){return new xt(t>>16,t>>8&255,255&t)}function _t(t){return bt(t)+""}function wt(t){return t<16?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function kt(t,e,n){var r,a,o,i=0,l=0,s=0;if(r=/([a-z]+)\((.*)\)/.exec(t=t.toLowerCase()))switch(a=r[2].split(","),r[1]){case"hsl":return n(parseFloat(a[0]),parseFloat(a[1])/100,parseFloat(a[2])/100);case"rgb":return e(Lt(a[0]),Lt(a[1]),Lt(a[2]))}return(o=ol.get(t))?e(o.r,o.g,o.b):(null==t||"#"!==t.charAt(0)||isNaN(o=parseInt(t.slice(1),16))||(4===t.length?(i=(3840&o)>>4,i=i>>4|i,l=240&o,l=l>>4|l,s=15&o,s=s<<4|s):7===t.length&&(i=(16711680&o)>>16,l=(65280&o)>>8,s=255&o)),e(i,l,s))}function Mt(t,e,n){var r,a,o=Math.min(t/=255,e/=255,n/=255),i=Math.max(t,e,n),l=i-o,s=(i+o)/2;return l?(a=s<.5?l/(i+o):l/(2-i-o),r=t==i?(e-n)/l+(e0&&s<1?0:r),new ct(r,a,s)}function At(t,e,n){t=Tt(t),e=Tt(e),n=Tt(n);var r=mt((.4124564*t+.3575761*e+.1804375*n)/tl),a=mt((.2126729*t+.7151522*e+.072175*n)/el),o=mt((.0193339*t+.119192*e+.9503041*n)/nl);return ht(116*a-16,500*(r-a),200*(a-o))}function Tt(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Lt(t){var e=parseFloat(t);return"%"===t.charAt(t.length-1)?Math.round(2.55*e):e}function zt(t){return"function"==typeof t?t:function(){return t}}function St(t){return function(e,n,r){return 2===arguments.length&&"function"==typeof n&&(r=n,n=null),Ct(e,n,t,r)}}function Ct(t,e,n,r){function a(){var t,e=s.status;if(!e&&Ot(s)||e>=200&&e<300||304===e){try{t=n.call(o,s)}catch(t){return void i.error.call(o,t)}i.load.call(o,t)}else i.error.call(o,s)}var o={},i=ui.dispatch("beforesend","progress","load","error"),l={},s=new XMLHttpRequest,c=null;return!this.XDomainRequest||"withCredentials"in s||!/^(http(s)?:)?\/\//.test(t)||(s=new XDomainRequest),"onload"in s?s.onload=s.onerror=a:s.onreadystatechange=function(){s.readyState>3&&a()},s.onprogress=function(t){var e=ui.event;ui.event=t;try{i.progress.call(o,s)}finally{ui.event=e}},o.header=function(t,e){return t=(t+"").toLowerCase(),arguments.length<2?l[t]:(null==e?delete l[t]:l[t]=e+"",o)},o.mimeType=function(t){return arguments.length?(e=null==t?null:t+"",o):e},o.responseType=function(t){return arguments.length?(c=t,o):c},o.response=function(t){return n=t,o},["get","post"].forEach(function(t){o[t]=function(){return o.send.apply(o,[t].concat(di(arguments)))}}),o.send=function(n,r,a){if(2===arguments.length&&"function"==typeof r&&(a=r,r=null),s.open(n,t,!0),null==e||"accept"in l||(l.accept=e+",*/*"),s.setRequestHeader)for(var u in l)s.setRequestHeader(u,l[u]);return null!=e&&s.overrideMimeType&&s.overrideMimeType(e),null!=c&&(s.responseType=c),null!=a&&o.on("error",a).on("load",function(t){a(null,t)}),i.beforesend.call(o,s),s.send(null==r?null:r),o},o.abort=function(){return s.abort(),o},ui.rebind(o,i,"on"),null==r?o:o.get(Et(r))}function Et(t){return 1===t.length?function(e,n){t(null==e?n:null)}:t}function Ot(t){var e=t.responseType;return e&&"text"!==e?t.response:t.responseText}function Nt(t,e,n){var r=arguments.length;r<2&&(e=0),r<3&&(n=Date.now());var a=n+e,o={c:t,t:a,n:null};return ll?ll.n=o:il=o,ll=o,sl||(cl=clearTimeout(cl),sl=1,ul(Pt)),o}function Pt(){var t=Dt(),e=It()-t;e>24?(isFinite(e)&&(clearTimeout(cl),cl=setTimeout(Pt,e)),sl=0):(sl=1,ul(Pt))}function Dt(){for(var t=Date.now(),e=il;e;)t>=e.t&&e.c(t-e.t)&&(e.c=null),e=e.n;return t}function It(){for(var t,e=il,n=1/0;e;)e.c?(e.t8?function(t){return t/n}:function(t){return t*n},symbol:t}}function Ft(t){var e=t.decimal,n=t.thousands,r=t.grouping,a=t.currency,o=r&&n?function(t,e){for(var a=t.length,o=[],i=0,l=r[0],s=0;a>0&&l>0&&(s+l+1>e&&(l=Math.max(1,e-s)),o.push(t.substring(a-=l,a+l)),!((s+=l+1)>e));)l=r[i=(i+1)%r.length];return o.reverse().join(n)}:b;return function(t){var n=dl.exec(t),r=n[1]||" ",i=n[2]||">",l=n[3]||"-",s=n[4]||"",c=n[5],u=+n[6],f=n[7],d=n[8],h=n[9],p=1,g="",v="",m=!1,y=!0;switch(d&&(d=+d.substring(1)),(c||"0"===r&&"="===i)&&(c=r="0",i="="),h){case"n":f=!0,h="g";break;case"%":p=100,v="%",h="f";break;case"p":p=100,v="%",h="r";break;case"b":case"o":case"x":case"X":"#"===s&&(g="0"+h.toLowerCase());case"c":y=!1;case"d":m=!0,d=0;break;case"s":p=-1,h="r"}"$"===s&&(g=a[0],v=a[1]),"r"!=h||d||(h="g"),null!=d&&("g"==h?d=Math.max(1,Math.min(21,d)):"e"!=h&&"f"!=h||(d=Math.max(0,Math.min(20,d)))),h=hl.get(h)||qt;var x=c&&f;return function(t){var n=v;if(m&&t%1)return"";var a=t<0||0===t&&1/t<0?(t=-t,"-"):"-"===l?"":l;if(p<0){var s=ui.formatPrefix(t,d);t=s.scale(t),n=s.symbol+v}else t*=p;t=h(t,d);var b,_,w=t.lastIndexOf(".");if(w<0){var k=y?t.lastIndexOf("e"):-1;k<0?(b=t,_=""):(b=t.substring(0,k),_=t.substring(k))}else b=t.substring(0,w),_=e+t.substring(w+1);!c&&f&&(b=o(b,1/0));var M=g.length+b.length+_.length+(x?0:a.length),A=M"===i?A+a+t:"^"===i?A.substring(0,M>>=1)+a+t+A.substring(M):a+(x?t:A+t))+n}}}function qt(t){return t+""}function Bt(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}function Ht(t,e,n){function r(e){var n=t(e),r=o(n,1);return e-n1)for(;i=c)return-1;if(a=e.charCodeAt(l++),37===a){if(i=e.charAt(l++),o=S[i in ml?e.charAt(l++):i],!o||(r=o(t,n,r))<0)return-1}else if(a!=n.charCodeAt(r++))return-1}return r}function r(t,e,n){w.lastIndex=0;var r=w.exec(e.slice(n));return r?(t.w=k.get(r[0].toLowerCase()),n+r[0].length):-1}function a(t,e,n){b.lastIndex=0;var r=b.exec(e.slice(n));return r?(t.w=_.get(r[0].toLowerCase()),n+r[0].length):-1}function o(t,e,n){T.lastIndex=0;var r=T.exec(e.slice(n));return r?(t.m=L.get(r[0].toLowerCase()),n+r[0].length):-1}function i(t,e,n){M.lastIndex=0;var r=M.exec(e.slice(n));return r?(t.m=A.get(r[0].toLowerCase()),n+r[0].length):-1}function l(t,e,r){return n(t,z.c.toString(),e,r)}function s(t,e,r){return n(t,z.x.toString(),e,r)}function c(t,e,r){return n(t,z.X.toString(),e,r)}function u(t,e,n){var r=x.get(e.slice(n,n+=2).toLowerCase());return null==r?-1:(t.p=r,n)}var f=t.dateTime,d=t.date,h=t.time,p=t.periods,g=t.days,v=t.shortDays,m=t.months,y=t.shortMonths;e.utc=function(t){function n(t){try{gl=Bt;var e=new gl;return e._=t,r(e)}finally{gl=Date}}var r=e(t);return n.parse=function(t){try{gl=Bt;var e=r.parse(t);return e&&e._}finally{gl=Date}},n.toString=r.toString,n},e.multi=e.utc.multi=ue;var x=ui.map(),b=Ut(g),_=Xt(g),w=Ut(v),k=Xt(v),M=Ut(m),A=Xt(m),T=Ut(y),L=Xt(y);p.forEach(function(t,e){x.set(t.toLowerCase(),e)});var z={a:function(t){return v[t.getDay()]},A:function(t){return g[t.getDay()]},b:function(t){return y[t.getMonth()]},B:function(t){return m[t.getMonth()]},c:e(f),d:function(t,e){return Yt(t.getDate(),e,2)},e:function(t,e){return Yt(t.getDate(),e,2)},H:function(t,e){return Yt(t.getHours(),e,2)},I:function(t,e){return Yt(t.getHours()%12||12,e,2)},j:function(t,e){return Yt(1+pl.dayOfYear(t),e,3)},L:function(t,e){return Yt(t.getMilliseconds(),e,3)},m:function(t,e){return Yt(t.getMonth()+1,e,2)},M:function(t,e){return Yt(t.getMinutes(),e,2)},p:function(t){return p[+(t.getHours()>=12)]},S:function(t,e){return Yt(t.getSeconds(),e,2)},U:function(t,e){return Yt(pl.sundayOfYear(t),e,2)},w:function(t){return t.getDay()},W:function(t,e){return Yt(pl.mondayOfYear(t),e,2)},x:e(d),X:e(h),y:function(t,e){return Yt(t.getFullYear()%100,e,2)},Y:function(t,e){return Yt(t.getFullYear()%1e4,e,4)},Z:se,"%":function(){return"%"}},S={a:r,A:a,b:o,B:i,c:l,d:ne,e:ne,H:ae,I:ae,j:re,L:le,m:ee,M:oe,p:u,S:ie,U:$t,w:Gt,W:Qt,x:s,X:c,y:Jt,Y:Wt,Z:Kt,"%":ce};return e}function Yt(t,e,n){var r=t<0?"-":"",a=(r?-t:t)+"",o=a.length;return r+(o68?1900:2e3)}function ee(t,e,n){yl.lastIndex=0;var r=yl.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function ne(t,e,n){yl.lastIndex=0;var r=yl.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function re(t,e,n){yl.lastIndex=0;var r=yl.exec(e.slice(n,n+3));return r?(t.j=+r[0],n+r[0].length):-1}function ae(t,e,n){yl.lastIndex=0;var r=yl.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function oe(t,e,n){yl.lastIndex=0;var r=yl.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function ie(t,e,n){yl.lastIndex=0;var r=yl.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function le(t,e,n){yl.lastIndex=0;var r=yl.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function se(t){var e=t.getTimezoneOffset(),n=e>0?"-":"+",r=bi(e)/60|0,a=bi(e)%60;return n+Yt(r,"0",2)+Yt(a,"0",2)}function ce(t,e,n){xl.lastIndex=0;var r=xl.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function ue(t){for(var e=t.length,n=-1;++n=0?1:-1,l=i*n,s=Math.cos(e),c=Math.sin(e),u=o*c,f=a*s+u*Math.cos(l),d=u*i*Math.sin(l);Al.add(Math.atan2(d,f)),r=t,a=s,o=c}var e,n,r,a,o;Tl.point=function(i,l){Tl.point=t,r=(e=i)*Vi,a=Math.cos(l=(n=l)*Vi/2+Fi/4),o=Math.sin(l)},Tl.lineEnd=function(){t(e,n)}}function me(t){var e=t[0],n=t[1],r=Math.cos(n);return[r*Math.cos(e),r*Math.sin(e),Math.sin(n)]}function ye(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function xe(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function be(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function _e(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function we(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function ke(t){return[Math.atan2(t[1],t[0]),rt(t[2])]}function Me(t,e){return bi(t[0]-e[0])=0;--l)a.point((f=u[l])[0],f[1])}else r(h.x,h.p.x,-1,a);h=h.p}h=h.o,u=h.z,p=!p}while(!h.v);a.lineEnd()}}}function Ne(t){if(e=t.length){for(var e,n,r=0,a=t[0];++r0){for(_||(o.polygonStart(),_=!0),o.lineStart();++i1&&2&e&&n.push(n.pop().concat(n.shift())),h.push(n.filter(Ie))}var h,p,g,v=e(o),m=a.invert(r[0],r[1]),y={point:i,lineStart:s,lineEnd:c,polygonStart:function(){y.point=u,y.lineStart=f,y.lineEnd=d,h=[],p=[]},polygonEnd:function(){y.point=i,y.lineStart=s,y.lineEnd=c,h=ui.merge(h);var t=He(m,p);h.length?(_||(o.polygonStart(),_=!0),Oe(h,je,t,n,o)):t&&(_||(o.polygonStart(),_=!0),o.lineStart(),n(null,null,1,o),o.lineEnd()),_&&(o.polygonEnd(),_=!1),h=p=null},sphere:function(){o.polygonStart(),o.lineStart(),n(null,null,1,o),o.lineEnd(),o.polygonEnd()}},x=Re(),b=e(x),_=!1;return y}}function Ie(t){return t.length>1}function Re(){var t,e=[];return{lineStart:function(){e.push(t=[])},point:function(e,n){t.push([e,n])},lineEnd:k,buffer:function(){var n=e;return e=[],t=null,n},rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))}}}function je(t,e){return((t=t.x)[0]<0?t[1]-Hi-Ri:Hi-t[1])-((e=e.x)[0]<0?e[1]-Hi-Ri:Hi-e[1])}function Fe(t){var e,n=NaN,r=NaN,a=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(o,i){var l=o>0?Fi:-Fi,s=bi(o-n);bi(s-Fi)0?Hi:-Hi),t.point(a,r),t.lineEnd(),t.lineStart(),t.point(l,r),t.point(o,r),e=0):a!==l&&s>=Fi&&(bi(n-a)Ri?Math.atan((Math.sin(e)*(o=Math.cos(r))*Math.sin(n)-Math.sin(r)*(a=Math.cos(e))*Math.sin(t))/(a*o*i)):(e+r)/2}function Be(t,e,n,r){var a;if(null==t)a=n*Hi,r.point(-Fi,a),r.point(0,a),r.point(Fi,a),r.point(Fi,0),r.point(Fi,-a),r.point(0,-a),r.point(-Fi,-a),r.point(-Fi,0),r.point(-Fi,a);else if(bi(t[0]-e[0])>Ri){var o=t[0]=0?1:-1,k=w*_,M=k>Fi,A=p*x;if(Al.add(Math.atan2(A*w*Math.sin(k),g*b+A*Math.cos(k))),o+=M?_+w*qi:_,M^d>=n^m>=n){var T=xe(me(f),me(t));we(T);var L=xe(a,T);we(L);var z=(M^_>=0?-1:1)*rt(L[2]);(r>z||r===z&&(T[0]||T[1]))&&(i+=M^_>=0?1:-1)}if(!v++)break;d=m,p=x,g=b,f=t}}return(o<-Ri||oo}function n(t){var n,o,s,c,u;return{lineStart:function(){c=s=!1,u=1},point:function(f,d){var h,p=[f,d],g=e(f,d),v=i?g?0:a(f,d):g?a(f+(f<0?Fi:-Fi),d):0;if(!n&&(c=s=g)&&t.lineStart(),g!==s&&(h=r(n,p),(Me(n,h)||Me(p,h))&&(p[0]+=Ri,p[1]+=Ri,g=e(p[0],p[1]))),g!==s)u=0,g?(t.lineStart(),h=r(p,n),t.point(h[0],h[1])):(h=r(n,p),t.point(h[0],h[1]),t.lineEnd()),n=h;else if(l&&n&&i^g){var m;v&o||!(m=r(p,n,!0))||(u=0,i?(t.lineStart(),t.point(m[0][0],m[0][1]),t.point(m[1][0],m[1][1]),t.lineEnd()):(t.point(m[1][0],m[1][1]),t.lineEnd(),t.lineStart(),t.point(m[0][0],m[0][1])))}!g||n&&Me(n,p)||t.point(p[0],p[1]),n=p,s=g,o=v},lineEnd:function(){s&&t.lineEnd(),n=null},clean:function(){return u|(c&&s)<<1}}}function r(t,e,n){var r=me(t),a=me(e),i=[1,0,0],l=xe(r,a),s=ye(l,l),c=l[0],u=s-c*c;if(!u)return!n&&t;var f=o*s/u,d=-o*c/u,h=xe(i,l),p=_e(i,f),g=_e(l,d);be(p,g);var v=h,m=ye(p,v),y=ye(v,v),x=m*m-y*(ye(p,p)-1);if(!(x<0)){var b=Math.sqrt(x),_=_e(v,(-m-b)/y);if(be(_,p),_=ke(_),!n)return _;var w,k=t[0],M=e[0],A=t[1],T=e[1];M0^_[1]<(bi(_[0]-k)Fi^(k<=_[0]&&_[0]<=M)){var C=_e(v,(-m+b)/y);return be(C,p),[_,ke(C)]}}}function a(e,n){var r=i?t:Fi-t,a=0;return e<-r?a|=1:e>r&&(a|=2),n<-r?a|=4:n>r&&(a|=8),a}var o=Math.cos(t),i=o>0,l=bi(o)>Ri,s=mn(t,6*Vi);return De(e,n,s,i?[0,-t]:[-Fi,t-Fi])}function Ze(t,e,n,r){return function(a){var o,i=a.a,l=a.b,s=i.x,c=i.y,u=l.x,f=l.y,d=0,h=1,p=u-s,g=f-c;if(o=t-s,p||!(o>0)){if(o/=p,p<0){if(o0){if(o>h)return;o>d&&(d=o)}if(o=n-s,p||!(o<0)){if(o/=p,p<0){if(o>h)return;o>d&&(d=o)}else if(p>0){if(o0)){if(o/=g,g<0){if(o0){if(o>h)return;o>d&&(d=o)}if(o=r-c,g||!(o<0)){if(o/=g,g<0){if(o>h)return;o>d&&(d=o)}else if(g>0){if(o0&&(a.a={x:s+d*p,y:c+d*g}),h<1&&(a.b={x:s+h*p,y:c+h*g}),a}}}}}}function Ye(t,e,n,r){function a(r,a){return bi(r[0]-t)0?0:3:bi(r[0]-n)0?2:1:bi(r[1]-e)0?1:0:a>0?3:2}function o(t,e){return i(t.x,e.x)}function i(t,e){var n=a(t,1),r=a(e,1);return n!==r?n-r:0===n?e[1]-t[1]:1===n?t[0]-e[0]:2===n?t[1]-e[1]:e[0]-t[0]}return function(l){function s(t){for(var e=0,n=v.length,r=t[1],a=0;ar&&et(c,o,t)>0&&++e:o[1]<=r&&et(c,o,t)<0&&--e,c=o;return 0!==e}function c(o,l,s,c){var u=0,f=0;if(null==o||(u=a(o,s))!==(f=a(l,s))||i(o,l)<0^s>0){do c.point(0===u||3===u?t:n,u>1?r:e);while((u=(u+s+4)%4)!==f)}else c.point(l[0],l[1])}function u(a,o){return t<=a&&a<=n&&e<=o&&o<=r}function f(t,e){u(t,e)&&l.point(t,e)}function d(){S.point=p,v&&v.push(m=[]),M=!0,k=!1,_=w=NaN}function h(){g&&(p(y,x),b&&k&&L.rejoin(),g.push(L.buffer())),S.point=f,k&&l.lineEnd()}function p(t,e){t=Math.max(-ql,Math.min(ql,t)),e=Math.max(-ql,Math.min(ql,e));var n=u(t,e);if(v&&m.push([t,e]),M)y=t,x=e,b=n,M=!1,n&&(l.lineStart(),l.point(t,e));else if(n&&k)l.point(t,e);else{var r={a:{x:_,y:w},b:{x:t,y:e}};z(r)?(k||(l.lineStart(),l.point(r.a.x,r.a.y)),l.point(r.b.x,r.b.y),n||l.lineEnd(),A=!1):n&&(l.lineStart(),l.point(t,e),A=!1)}_=t,w=e,k=n}var g,v,m,y,x,b,_,w,k,M,A,T=l,L=Re(),z=Ze(t,e,n,r),S={point:f,lineStart:d,lineEnd:h,polygonStart:function(){l=L,g=[],v=[],A=!0},polygonEnd:function(){l=T,g=ui.merge(g);var e=s([t,r]),n=A&&e,a=g.length;(n||a)&&(l.polygonStart(),n&&(l.lineStart(),c(null,null,1,l),l.lineEnd()),a&&Oe(g,o,e,c,l),l.polygonEnd()),g=v=m=null}};return S}}function Ue(t){var e=0,n=Fi/3,r=cn(t),a=r(e,n);return a.parallels=function(t){return arguments.length?r(e=t[0]*Fi/180,n=t[1]*Fi/180):[e/Fi*180,n/Fi*180]},a}function Xe(t,e){function n(t,e){var n=Math.sqrt(o-2*a*Math.sin(e))/a;return[n*Math.sin(t*=a),i-n*Math.cos(t)]}var r=Math.sin(t),a=(r+Math.sin(e))/2,o=1+r*(2*a-r),i=Math.sqrt(o)/a;return n.invert=function(t,e){var n=i-e;return[Math.atan2(t,n)/a,rt((o-(t*t+n*n)*a*a)/(2*a))]},n}function Ge(){function t(t,e){Hl+=a*t-r*e,r=t,a=e}var e,n,r,a;Xl.point=function(o,i){Xl.point=t,e=r=o,n=a=i},Xl.lineEnd=function(){t(e,n)}}function $e(t,e){tYl&&(Yl=t),eUl&&(Ul=e)}function Qe(){function t(t,e){i.push("M",t,",",e,o)}function e(t,e){i.push("M",t,",",e),l.point=n}function n(t,e){i.push("L",t,",",e)}function r(){l.point=t}function a(){i.push("Z")}var o=We(4.5),i=[],l={point:t,lineStart:function(){l.point=e},lineEnd:r,polygonStart:function(){l.lineEnd=a},polygonEnd:function(){l.lineEnd=r,l.point=t},pointRadius:function(t){return o=We(t),l},result:function(){if(i.length){var t=i.join("");return i=[],t}}};return l}function We(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}function Je(t,e){Sl+=t,Cl+=e,++El}function Ke(){function t(t,r){var a=t-e,o=r-n,i=Math.sqrt(a*a+o*o);Ol+=i*(e+t)/2,Nl+=i*(n+r)/2,Pl+=i,Je(e=t,n=r)}var e,n;$l.point=function(r,a){$l.point=t,Je(e=r,n=a)}}function tn(){$l.point=Je}function en(){function t(t,e){var n=t-r,o=e-a,i=Math.sqrt(n*n+o*o);Ol+=i*(r+t)/2,Nl+=i*(a+e)/2,Pl+=i,i=a*t-r*e,Dl+=i*(r+t),Il+=i*(a+e),Rl+=3*i,Je(r=t,a=e)}var e,n,r,a;$l.point=function(o,i){$l.point=t,Je(e=r=o,n=a=i)},$l.lineEnd=function(){t(e,n)}}function nn(t){function e(e,n){t.moveTo(e+i,n),t.arc(e,n,i,0,qi)}function n(e,n){t.moveTo(e,n),l.point=r}function r(e,n){t.lineTo(e,n)}function a(){l.point=e}function o(){t.closePath()}var i=4.5,l={point:e,lineStart:function(){l.point=n},lineEnd:a,polygonStart:function(){l.lineEnd=o},polygonEnd:function(){l.lineEnd=a,l.point=e},pointRadius:function(t){return i=t,l},result:k};return l}function rn(t){function e(t){return(l?r:n)(t)}function n(e){return ln(e,function(n,r){n=t(n,r),e.point(n[0],n[1])})}function r(e){function n(n,r){n=t(n,r),e.point(n[0],n[1])}function r(){x=NaN,M.point=o,e.lineStart()}function o(n,r){var o=me([n,r]),i=t(n,r);a(x,b,y,_,w,k,x=i[0],b=i[1],y=n,_=o[0],w=o[1],k=o[2],l,e),e.point(x,b)}function i(){M.point=n,e.lineEnd()}function s(){r(),M.point=c,M.lineEnd=u}function c(t,e){o(f=t,d=e),h=x,p=b,g=_,v=w,m=k,M.point=o}function u(){a(x,b,y,_,w,k,h,p,f,g,v,m,l,e),M.lineEnd=i,i()}var f,d,h,p,g,v,m,y,x,b,_,w,k,M={point:n,lineStart:r,lineEnd:i,polygonStart:function(){e.polygonStart(),M.lineStart=s},polygonEnd:function(){e.polygonEnd(),M.lineStart=r}};return M}function a(e,n,r,l,s,c,u,f,d,h,p,g,v,m){var y=u-e,x=f-n,b=y*y+x*x;if(b>4*o&&v--){var _=l+h,w=s+p,k=c+g,M=Math.sqrt(_*_+w*w+k*k),A=Math.asin(k/=M),T=bi(bi(k)-1)o||bi((y*C+x*E)/b-.5)>.3||l*h+s*p+c*g0&&16,e):Math.sqrt(o)},e}function an(t){var e=rn(function(e,n){return t([e*Zi,n*Zi])});return function(t){return un(e(t))}}function on(t){this.stream=t}function ln(t,e){return{point:e,sphere:function(){t.sphere()},lineStart:function(){t.lineStart()},lineEnd:function(){t.lineEnd()},polygonStart:function(){t.polygonStart()},polygonEnd:function(){t.polygonEnd()}}}function sn(t){return cn(function(){return t})()}function cn(t){function e(t){return t=l(t[0]*Vi,t[1]*Vi),[t[0]*d+s,c-t[1]*d]}function n(t){return t=l.invert((t[0]-s)/d,(c-t[1])/d),t&&[t[0]*Zi,t[1]*Zi]}function r(){l=Ce(i=hn(m,y,x),o);var t=o(g,v);return s=h-t[0]*d,c=p+t[1]*d,a()}function a(){return u&&(u.valid=!1,u=null),e}var o,i,l,s,c,u,f=rn(function(t,e){return t=o(t,e),[t[0]*d+s,c-t[1]*d]}),d=150,h=480,p=250,g=0,v=0,m=0,y=0,x=0,_=Fl,w=b,k=null,M=null;return e.stream=function(t){return u&&(u.valid=!1),u=un(_(i,f(w(t)))),u.valid=!0,u},e.clipAngle=function(t){return arguments.length?(_=null==t?(k=t,Fl):Ve((k=+t)*Vi),a()):k},e.clipExtent=function(t){return arguments.length?(M=t,w=t?Ye(t[0][0],t[0][1],t[1][0],t[1][1]):b,a()):M},e.scale=function(t){return arguments.length?(d=+t,r()):d},e.translate=function(t){return arguments.length?(h=+t[0],p=+t[1],r()):[h,p]},e.center=function(t){return arguments.length?(g=t[0]%360*Vi,v=t[1]%360*Vi,r()):[g*Zi,v*Zi]},e.rotate=function(t){return arguments.length?(m=t[0]%360*Vi,y=t[1]%360*Vi,x=t.length>2?t[2]%360*Vi:0,r()):[m*Zi,y*Zi,x*Zi]},ui.rebind(e,f,"precision"),function(){return o=t.apply(this,arguments),e.invert=o.invert&&n,r()}}function un(t){return ln(t,function(e,n){t.point(e*Vi,n*Vi)})}function fn(t,e){return[t,e]}function dn(t,e){return[t>Fi?t-qi:t<-Fi?t+qi:t,e]}function hn(t,e,n){return t?e||n?Ce(gn(t),vn(e,n)):gn(t):e||n?vn(e,n):dn}function pn(t){return function(e,n){return e+=t,[e>Fi?e-qi:e<-Fi?e+qi:e,n]}}function gn(t){var e=pn(t);return e.invert=pn(-t),e}function vn(t,e){function n(t,e){var n=Math.cos(e),l=Math.cos(t)*n,s=Math.sin(t)*n,c=Math.sin(e),u=c*r+l*a;return[Math.atan2(s*o-u*i,l*r-c*a),rt(u*o+s*i)]}var r=Math.cos(t),a=Math.sin(t),o=Math.cos(e),i=Math.sin(e);return n.invert=function(t,e){var n=Math.cos(e),l=Math.cos(t)*n,s=Math.sin(t)*n,c=Math.sin(e),u=c*o-s*i;return[Math.atan2(s*o+c*i,l*r+u*a),rt(u*r-l*a)]},n}function mn(t,e){var n=Math.cos(t),r=Math.sin(t);return function(a,o,i,l){var s=i*e;null!=a?(a=yn(n,a),o=yn(n,o),(i>0?ao)&&(a+=i*qi)):(a=t+i*qi,o=t-.5*s);for(var c,u=a;i>0?u>o:u0?e<-Hi+Ri&&(e=-Hi+Ri):e>Hi-Ri&&(e=Hi-Ri);var n=i/Math.pow(a(e),o);return[n*Math.sin(o*t),i-n*Math.cos(o*t)]}var r=Math.cos(t),a=function(t){return Math.tan(Fi/4+t/2)},o=t===e?Math.sin(t):Math.log(r/Math.cos(e))/Math.log(a(e)/a(t)),i=r*Math.pow(a(t),o)/o;return o?(n.invert=function(t,e){var n=i-e,r=tt(o)*Math.sqrt(t*t+n*n);return[Math.atan2(t,n)/o,2*Math.atan(Math.pow(i/r,1/o))-Hi]},n):zn}function Ln(t,e){function n(t,e){var n=o-e;return[n*Math.sin(a*t),o-n*Math.cos(a*t)]}var r=Math.cos(t),a=t===e?Math.sin(t):(r-Math.cos(e))/(e-t),o=r/a+t;return bi(a)1&&et(t[n[r-2]],t[n[r-1]],t[a])<=0;)--r;n[r++]=a}return n.slice(0,r)}function Pn(t,e){return t[0]-e[0]||t[1]-e[1]}function Dn(t,e,n){return(n[0]-e[0])*(t[1]-e[1])<(n[1]-e[1])*(t[0]-e[0])}function In(t,e,n,r){var a=t[0],o=n[0],i=e[0]-a,l=r[0]-o,s=t[1],c=n[1],u=e[1]-s,f=r[1]-c,d=(l*(s-c)-f*(a-o))/(f*i-l*u);return[a+d*i,s+d*u]}function Rn(t){var e=t[0],n=t[t.length-1];return!(e[0]-n[0]||e[1]-n[1])}function jn(){or(this),this.edge=this.site=this.circle=null}function Fn(t){var e=cs.pop()||new jn;return e.site=t,e}function qn(t){Qn(t),is.remove(t),cs.push(t),or(t)}function Bn(t){var e=t.circle,n=e.x,r=e.cy,a={x:n,y:r},o=t.P,i=t.N,l=[t];qn(t);for(var s=o;s.circle&&bi(n-s.circle.x)Ri)l=l.L;else{if(a=o-Zn(l,i),!(a>Ri)){r>-Ri?(e=l.P,n=l):a>-Ri?(e=l,n=l.N):e=n=l;break}if(!l.R){e=l;break}l=l.R}var s=Fn(t);if(is.insert(e,s),e||n){if(e===n)return Qn(e),n=Fn(e.site),is.insert(s,n),s.edge=n.edge=tr(e.site,s.site),$n(e),void $n(n);if(!n)return void(s.edge=tr(e.site,s.site));Qn(e),Qn(n);var c=e.site,u=c.x,f=c.y,d=t.x-u,h=t.y-f,p=n.site,g=p.x-u,v=p.y-f,m=2*(d*v-h*g),y=d*d+h*h,x=g*g+v*v,b={x:(v*y-h*x)/m+u,y:(d*x-g*y)/m+f};nr(n.edge,c,p,b),s.edge=tr(c,t,null,b),n.edge=tr(t,p,null,b),$n(e),$n(n)}}function Vn(t,e){var n=t.site,r=n.x,a=n.y,o=a-e;if(!o)return r;var i=t.P;if(!i)return-(1/0);n=i.site;var l=n.x,s=n.y,c=s-e;if(!c)return l;var u=l-r,f=1/o-1/c,d=u/c;return f?(-d+Math.sqrt(d*d-2*f*(u*u/(-2*c)-s+c/2+a-o/2)))/f+r:(r+l)/2}function Zn(t,e){var n=t.N;if(n)return Vn(n,e);var r=t.site;return r.y===e?r.x:1/0}function Yn(t){this.site=t,this.edges=[]}function Un(t){for(var e,n,r,a,o,i,l,s,c,u,f=t[0][0],d=t[1][0],h=t[0][1],p=t[1][1],g=os,v=g.length;v--;)if(o=g[v],o&&o.prepare())for(l=o.edges,s=l.length,i=0;iRi||bi(a-n)>Ri)&&(l.splice(i,0,new rr(er(o.site,u,bi(r-f)Ri?{x:f,y:bi(e-f)Ri?{x:bi(n-p)Ri?{x:d,y:bi(e-d)Ri?{x:bi(n-h)=-ji)){var h=s*s+c*c,p=u*u+f*f,g=(f*h-c*p)/d,v=(s*p-u*h)/d,f=v+l,m=us.pop()||new Gn;m.arc=t,m.site=a,m.x=g+i,m.y=f+Math.sqrt(g*g+v*v),m.cy=f,t.circle=m;for(var y=null,x=ss._;x;)if(m.y=l)return;if(d>p){if(o){if(o.y>=c)return}else o={x:v,y:s};n={x:v,y:c}}else{if(o){if(o.y1)if(d>p){if(o){if(o.y>=c)return}else o={x:(s-a)/r,y:s};n={x:(c-a)/r,y:c}}else{if(o){if(o.y=l)return}else o={x:i,y:r*i+a};n={x:l,y:r*l+a}}else{if(o){if(o.xo||f>i||d=b,k=n>=_,M=k<<1|w,A=M+4;Mo&&(a=e.slice(o,a),l[i]?l[i]+=a:l[++i]=a),(n=n[0])===(r=r[0])?l[i]?l[i]+=r:l[++i]=r:(l[++i]=null,s.push({i:i,x:xr(n,r)})),o=hs.lastIndex;return o=0&&!(n=ui.interpolators[r](t,e)););return n}function wr(t,e){var n,r=[],a=[],o=t.length,i=e.length,l=Math.min(t.length,e.length);for(n=0;n=1?1:t(e)}}function Mr(t){return function(e){return 1-t(1-e)}}function Ar(t){return function(e){return.5*(e<.5?t(2*e):2-t(2-2*e))}}function Tr(t){return t*t}function Lr(t){return t*t*t}function zr(t){if(t<=0)return 0;if(t>=1)return 1;var e=t*t,n=e*t;return 4*(t<.5?n:3*(t-e)+n-.75)}function Sr(t){return function(e){return Math.pow(e,t)}}function Cr(t){return 1-Math.cos(t*Hi)}function Er(t){return Math.pow(2,10*(t-1))}function Or(t){return 1-Math.sqrt(1-t*t)}function Nr(t,e){var n;return arguments.length<2&&(e=.45),arguments.length?n=e/qi*Math.asin(1/t):(t=1,n=e/4),function(r){return 1+t*Math.pow(2,-10*r)*Math.sin((r-n)*qi/e)}}function Pr(t){return t||(t=1.70158),function(e){return e*e*((t+1)*e-t)}}function Dr(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}function Ir(t,e){t=ui.hcl(t),e=ui.hcl(e);var n=t.h,r=t.c,a=t.l,o=e.h-n,i=e.c-r,l=e.l-a;return isNaN(i)&&(i=0,r=isNaN(r)?e.c:r),isNaN(o)?(o=0,n=isNaN(n)?e.h:n):o>180?o-=360:o<-180&&(o+=360),function(t){return dt(n+o*t,r+i*t,a+l*t)+""}}function Rr(t,e){t=ui.hsl(t),e=ui.hsl(e);var n=t.h,r=t.s,a=t.l,o=e.h-n,i=e.s-r,l=e.l-a;return isNaN(i)&&(i=0,r=isNaN(r)?e.s:r),isNaN(o)?(o=0,n=isNaN(n)?e.h:n):o>180?o-=360:o<-180&&(o+=360),function(t){return ut(n+o*t,r+i*t,a+l*t)+""}}function jr(t,e){t=ui.lab(t),e=ui.lab(e);var n=t.l,r=t.a,a=t.b,o=e.l-n,i=e.a-r,l=e.b-a;return function(t){return pt(n+o*t,r+i*t,a+l*t)+""}}function Fr(t,e){return e-=t,function(n){return Math.round(t+e*n)}}function qr(t){var e=[t.a,t.b],n=[t.c,t.d],r=Hr(e),a=Br(e,n),o=Hr(Vr(n,e,-a))||0;e[0]*n[1]180?e+=360:e-t>180&&(t+=360),r.push({i:n.push(Zr(n)+"rotate(",null,")")-2,x:xr(t,e)})):e&&n.push(Zr(n)+"rotate("+e+")")}function Xr(t,e,n,r){t!==e?r.push({i:n.push(Zr(n)+"skewX(",null,")")-2,x:xr(t,e)}):e&&n.push(Zr(n)+"skewX("+e+")")}function Gr(t,e,n,r){if(t[0]!==e[0]||t[1]!==e[1]){var a=n.push(Zr(n)+"scale(",null,",",null,")");r.push({i:a-4,x:xr(t[0],e[0])},{i:a-2,x:xr(t[1],e[1])})}else 1===e[0]&&1===e[1]||n.push(Zr(n)+"scale("+e+")")}function $r(t,e){var n=[],r=[];return t=ui.transform(t),e=ui.transform(e),Yr(t.translate,e.translate,n,r),Ur(t.rotate,e.rotate,n,r),Xr(t.skew,e.skew,n,r),Gr(t.scale,e.scale,n,r),t=e=null,function(t){for(var e,a=-1,o=r.length;++a=0;)n.push(a[r])}function sa(t,e){for(var n=[t],r=[];null!=(t=n.pop());)if(r.push(t),(o=t.children)&&(a=o.length))for(var a,o,i=-1;++ia&&(r=n,a=e);return r}function xa(t){return t.reduce(ba,0)}function ba(t,e){return t+e[1]}function _a(t,e){return wa(t,Math.ceil(Math.log(e.length)/Math.LN2+1))}function wa(t,e){for(var n=-1,r=+t[0],a=(t[1]-r)/e,o=[];++n<=e;)o[n]=a*n+r;return o}function ka(t){return[ui.min(t),ui.max(t)]}function Ma(t,e){return t.value-e.value}function Aa(t,e){var n=t._pack_next;t._pack_next=e,e._pack_prev=t,e._pack_next=n,n._pack_prev=e}function Ta(t,e){t._pack_next=e,e._pack_prev=t}function La(t,e){var n=e.x-t.x,r=e.y-t.y,a=t.r+e.r;return.999*a*a>n*n+r*r}function za(t){function e(t){u=Math.min(t.x-t.r,u),f=Math.max(t.x+t.r,f),d=Math.min(t.y-t.r,d),h=Math.max(t.y+t.r,h)}if((n=t.children)&&(c=n.length)){var n,r,a,o,i,l,s,c,u=1/0,f=-(1/0),d=1/0,h=-(1/0);if(n.forEach(Sa),r=n[0],r.x=-r.r,r.y=0,e(r),c>1&&(a=n[1],a.x=a.r,a.y=0,e(a),c>2))for(o=n[2],Oa(r,a,o),e(o),Aa(r,o),r._pack_prev=o,Aa(o,a),a=r._pack_next,i=3;i=0;)e=a[o],e.z+=n,e.m+=n,n+=e.s+(r+=e.c)}function ja(t,e,n){return t.a.parent===e.parent?t.a:n}function Fa(t){return 1+ui.max(t,function(t){return t.y})}function qa(t){return t.reduce(function(t,e){return t+e.x},0)/t.length}function Ba(t){var e=t.children;return e&&e.length?Ba(e[0]):t}function Ha(t){var e,n=t.children;return n&&(e=n.length)?Ha(n[e-1]):t}function Va(t){return{x:t.x,y:t.y,dx:t.dx,dy:t.dy}}function Za(t,e){var n=t.x+e[3],r=t.y+e[0],a=t.dx-e[1]-e[3],o=t.dy-e[0]-e[2];return a<0&&(n+=a/2,a=0),o<0&&(r+=o/2,o=0),{x:n,y:r,dx:a,dy:o}}function Ya(t){var e=t[0],n=t[t.length-1];return e2?Qa:Xa,s=r?Wr:Qr;return i=a(t,e,s,n),l=a(e,t,s,_r),o}function o(t){return i(t)}var i,l;return o.invert=function(t){return l(t)},o.domain=function(e){return arguments.length?(t=e.map(Number),a()):t},o.range=function(t){return arguments.length?(e=t,a()):e},o.rangeRound=function(t){return o.range(t).interpolate(Fr)},o.clamp=function(t){return arguments.length?(r=t,a()):r},o.interpolate=function(t){return arguments.length?(n=t,a()):n},o.ticks=function(e){return eo(t,e)},o.tickFormat=function(e,n){return no(t,e,n)},o.nice=function(e){return Ka(t,e),a()},o.copy=function(){return Wa(t,e,n,r)},a()}function Ja(t,e){return ui.rebind(t,e,"range","rangeRound","interpolate","clamp")}function Ka(t,e){return Ga(t,$a(to(t,e)[2])),Ga(t,$a(to(t,e)[2])),t}function to(t,e){null==e&&(e=10);var n=Ya(t),r=n[1]-n[0],a=Math.pow(10,Math.floor(Math.log(r/e)/Math.LN10)),o=e/r*a;return o<=.15?a*=10:o<=.35?a*=5:o<=.75&&(a*=2),n[0]=Math.ceil(n[0]/a)*a,n[1]=Math.floor(n[1]/a)*a+.5*a,n[2]=a,n}function eo(t,e){return ui.range.apply(ui,to(t,e))}function no(t,e,n){var r=to(t,e);if(n){var a=dl.exec(n);if(a.shift(),"s"===a[8]){var o=ui.formatPrefix(Math.max(bi(r[0]),bi(r[1])));return a[7]||(a[7]="."+ro(o.scale(r[2]))),a[8]="f",n=ui.format(a.join("")),function(t){return n(o.scale(t))+o.symbol}}a[7]||(a[7]="."+ao(a[8],r)),n=a.join("")}else n=",."+ro(r[2])+"f";return ui.format(n)}function ro(t){return-Math.floor(Math.log(t)/Math.LN10+.01)}function ao(t,e){var n=ro(e[2]);return t in As?Math.abs(n-ro(Math.max(bi(e[0]),bi(e[1]))))+ +("e"!==t):n-2*("%"===t)}function oo(t,e,n,r){function a(t){return(n?Math.log(t<0?0:t):-Math.log(t>0?0:-t))/Math.log(e)}function o(t){return n?Math.pow(e,t):-Math.pow(e,-t)}function i(e){return t(a(e))}return i.invert=function(e){return o(t.invert(e))},i.domain=function(e){return arguments.length?(n=e[0]>=0,t.domain((r=e.map(Number)).map(a)),i):r},i.base=function(n){return arguments.length?(e=+n,t.domain(r.map(a)),i):e},i.nice=function(){var e=Ga(r.map(a),n?Math:Ls);return t.domain(e),r=e.map(o),i},i.ticks=function(){var t=Ya(r),i=[],l=t[0],s=t[1],c=Math.floor(a(l)),u=Math.ceil(a(s)),f=e%1?2:e;if(isFinite(u-c)){if(n){for(;c0;d--)i.push(o(c)*d);for(c=0;i[c]s;u--);i=i.slice(c,u)}return i},i.tickFormat=function(t,n){if(!arguments.length)return Ts;arguments.length<2?n=Ts:"function"!=typeof n&&(n=ui.format(n));var r=Math.max(1,e*t/i.ticks().length);return function(t){var i=t/o(Math.round(a(t)));return i*e0?l[n-1]:t[0],n0?0:1}function _o(t,e,n,r,a){var o=t[0]-e[0],i=t[1]-e[1],l=(a?r:-r)/Math.sqrt(o*o+i*i),s=l*i,c=-l*o,u=t[0]+s,f=t[1]+c,d=e[0]+s,h=e[1]+c,p=(u+d)/2,g=(f+h)/2,v=d-u,m=h-f,y=v*v+m*m,x=n-r,b=u*h-d*f,_=(m<0?-1:1)*Math.sqrt(Math.max(0,x*x*y-b*b)),w=(b*m-v*_)/y,k=(-b*v-m*_)/y,M=(b*m+v*_)/y,A=(-b*v+m*_)/y,T=w-p,L=k-g,z=M-p,S=A-g;return T*T+L*L>z*z+S*S&&(w=M,k=A),[[w-s,k-c],[w*n/x,k*n/x]]}function wo(t){function e(e){function i(){c.push("M",o(t(u),l))}for(var s,c=[],u=[],f=-1,d=e.length,h=zt(n),p=zt(r);++f1?t.join("L"):t+"Z"}function Mo(t){return t.join("L")+"Z"}function Ao(t){for(var e=0,n=t.length,r=t[0],a=[r[0],",",r[1]];++e1&&a.push("H",r[0]),a.join("")}function To(t){for(var e=0,n=t.length,r=t[0],a=[r[0],",",r[1]];++e1){l=e[1],o=t[s],s++,r+="C"+(a[0]+i[0])+","+(a[1]+i[1])+","+(o[0]-l[0])+","+(o[1]-l[1])+","+o[0]+","+o[1];for(var c=2;c9&&(a=3*e/Math.sqrt(a),i[l]=a*n,i[l+1]=a*r));for(l=-1;++l<=s;)a=(t[Math.min(s,l+1)][0]-t[Math.max(0,l-1)][0])/(6*(1+i[l]*i[l])),o.push([a||0,i[l]*a||0]);return o}function Ho(t){return t.length<3?ko(t):t[0]+Eo(t,Bo(t))}function Vo(t){for(var e,n,r,a=-1,o=t.length;++a0;)h[--l].call(t,i);if(o>=1)return g.event&&g.event.end.call(t,t.__data__,e),--p.count?delete p[r]:delete t[n],1}var s,c,u,d,h,p=t[n]||(t[n]={active:0,count:0}),g=p[r];g||(s=a.time,c=Nt(o,0,s),g=p[r]={tween:new f,time:s,timer:c,delay:a.delay,duration:a.duration,ease:a.ease,index:e},a=null,++p.count)}function ri(t,e,n){t.attr("transform",function(t){var r=e(t);return"translate("+(isFinite(r)?r:n(t))+",0)"})}function ai(t,e,n){t.attr("transform",function(t){var r=e(t);return"translate(0,"+(isFinite(r)?r:n(t))+")"})}function oi(t){return t.toISOString()}function ii(t,e,n){function r(e){return t(e)}function a(t,n){var r=t[1]-t[0],a=r/n,o=ui.bisect(Js,a);return o==Js.length?[e.year,to(t.map(function(t){return t/31536e6}),n)[2]]:o?e[a/Js[o-1]1?{floor:function(e){for(;n(e=t.floor(e));)e=li(e-1);return e},ceil:function(e){for(;n(e=t.ceil(e));)e=li(+e+1);return e}}:t))},r.ticks=function(t,e){var n=Ya(r.domain()),o=null==t?a(n,10):"number"==typeof t?a(n,t):!t.range&&[{range:t},e];return o&&(t=o[0],e=o[1]),t.range(n[0],li(+n[1]+1),e<1?1:e)},r.tickFormat=function(){return n},r.copy=function(){return ii(t.copy(),e,n)},Ja(r,t)}function li(t){return new Date(t)}function si(t){return JSON.parse(t.responseText)}function ci(t){var e=hi.createRange();return e.selectNode(hi.body),e.createContextualFragment(t.responseText)}var ui={version:"3.5.17"},fi=[].slice,di=function(t){return fi.call(t)},hi=this.document;if(hi)try{di(hi.documentElement.childNodes)[0].nodeType}catch(t){di=function(t){for(var e=t.length,n=new Array(e);e--;)n[e]=t[e];return n}}if(Date.now||(Date.now=function(){return+new Date}),hi)try{hi.createElement("DIV").style.setProperty("opacity",0,"")}catch(t){var pi=this.Element.prototype,gi=pi.setAttribute,vi=pi.setAttributeNS,mi=this.CSSStyleDeclaration.prototype,yi=mi.setProperty;pi.setAttribute=function(t,e){gi.call(this,t,e+"")},pi.setAttributeNS=function(t,e,n){vi.call(this,t,e,n+"")},mi.setProperty=function(t,e,n){yi.call(this,t,e+"",n)}}ui.ascending=a,ui.descending=function(t,e){return et?1:e>=t?0:NaN},ui.min=function(t,e){var n,r,a=-1,o=t.length;if(1===arguments.length){for(;++a=r){n=r;break}for(;++ar&&(n=r)}else{for(;++a=r){n=r;break}for(;++ar&&(n=r)}return n},ui.max=function(t,e){var n,r,a=-1,o=t.length;if(1===arguments.length){for(;++a=r){n=r;break}for(;++an&&(n=r)}else{for(;++a=r){n=r;break}for(;++an&&(n=r)}return n},ui.extent=function(t,e){var n,r,a,o=-1,i=t.length;if(1===arguments.length){for(;++o=r){n=a=r;break}for(;++or&&(n=r),a=r){n=a=r;break}for(;++or&&(n=r),a1)return s/(u-1)},ui.deviation=function(){var t=ui.variance.apply(this,arguments);return t?Math.sqrt(t):t};var xi=l(a);ui.bisectLeft=xi.left,ui.bisect=ui.bisectRight=xi.right,ui.bisector=function(t){return l(1===t.length?function(e,n){return a(t(e),n)}:t)},ui.shuffle=function(t,e,n){(o=arguments.length)<3&&(n=t.length,o<2&&(e=0));for(var r,a,o=n-e;o;)a=Math.random()*o--|0,r=t[o+e],t[o+e]=t[a+e],t[a+e]=r;return t},ui.permute=function(t,e){for(var n=e.length,r=new Array(n);n--;)r[n]=t[e[n]];return r},ui.pairs=function(t){for(var e,n=0,r=t.length-1,a=t[0],o=new Array(r<0?0:r);n=0;)for(r=t[a],e=r.length;--e>=0;)n[--i]=r[e];return n};var bi=Math.abs;ui.range=function(t,e,n){if(arguments.length<3&&(n=1,arguments.length<2&&(e=t,t=0)),(e-t)/n===1/0)throw new Error("infinite range");var r,a=[],o=c(bi(n)),i=-1;if(t*=o,e*=o,n*=o,n<0)for(;(r=t+n*++i)>e;)a.push(r/o);else for(;(r=t+n*++i)=o.length)return r?r.call(a,i):n?i.sort(n):i;for(var s,c,u,d,h=-1,p=i.length,g=o[l++],v=new f;++h=o.length)return t;var r=[],a=i[n++];return t.forEach(function(t,a){r.push({key:t,values:e(a,n)})}),a?r.sort(function(t,e){return a(t.key,e.key)}):r}var n,r,a={},o=[],i=[];return a.map=function(e,n){return t(n,e,0)},a.entries=function(n){return e(t(ui.map,n,0),0)},a.key=function(t){return o.push(t),a},a.sortKeys=function(t){return i[o.length-1]=t,a},a.sortValues=function(t){return n=t,a},a.rollup=function(t){return r=t,a},a},ui.set=function(t){var e=new x;if(t)for(var n=0,r=t.length;n=0&&(r=t.slice(n+1),t=t.slice(0,n)),t)return arguments.length<2?this[t].on(r):this[t].on(r,e);if(2===arguments.length){if(null==e)for(t in this)this.hasOwnProperty(t)&&this[t].on(r,null);return this}},ui.event=null,ui.requote=function(t){return t.replace(Mi,"\\$&")};var Mi=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,Ai={}.__proto__?function(t,e){t.__proto__=e}:function(t,e){for(var n in e)t[n]=e[n]},Ti=function(t,e){return e.querySelector(t)},Li=function(t,e){return e.querySelectorAll(t)},zi=function(t,e){var n=t.matches||t[w(t,"matchesSelector")];return(zi=function(t,e){return n.call(t,e)})(t,e)};"function"==typeof Sizzle&&(Ti=function(t,e){return Sizzle(t,e)[0]||null},Li=Sizzle,zi=Sizzle.matchesSelector),ui.selection=function(){return ui.select(hi.documentElement)};var Si=ui.selection.prototype=[];Si.select=function(t){var e,n,r,a,o=[];t=C(t);for(var i=-1,l=this.length;++i=0&&"xmlns"!==(n=t.slice(0,e))&&(t=t.slice(e+1)),Ei.hasOwnProperty(n)?{space:Ei[n],local:t}:t}},Si.attr=function(t,e){if(arguments.length<2){if("string"==typeof t){var n=this.node();return t=ui.ns.qualify(t),t.local?n.getAttributeNS(t.space,t.local):n.getAttribute(t)}for(e in t)this.each(O(e,t[e]));return this}return this.each(O(t,e))},Si.classed=function(t,e){if(arguments.length<2){if("string"==typeof t){var n=this.node(),r=(t=D(t)).length,a=-1;if(e=n.classList){for(;++a=0;)(n=r[a])&&(o&&o!==n.nextSibling&&o.parentNode.insertBefore(n,o),o=n);return this},Si.sort=function(t){t=Z.apply(this,arguments);for(var e=-1,n=this.length;++e0&&(e=e.transition().duration(S)),e.call(t.event)}function l(){_&&_.domain(b.range().map(function(t){return(t-M.x)/M.k}).map(b.invert)),k&&k.domain(w.range().map(function(t){return(t-M.y)/M.k}).map(w.invert))}function s(t){C++||t({type:"zoomstart"})}function c(t){l(),t({type:"zoom",scale:M.k,translate:[M.x,M.y]})}function u(t){--C||(t({type:"zoomend"}),v=null)}function f(){function t(){l=1,o(ui.mouse(a),d),c(i)}function n(){f.on(O,null).on(N,null),h(l),u(i)}var a=this,i=D.of(a,arguments),l=0,f=ui.select(r(a)).on(O,t).on(N,n),d=e(ui.mouse(a)),h=W(a);Hs.call(a),s(i)}function d(){function t(){var t=ui.touches(p);return h=M.k,t.forEach(function(t){t.identifier in v&&(v[t.identifier]=e(t))}),t}function n(){var e=ui.event.target;ui.select(e).on(b,r).on(_,l),w.push(e);for(var n=ui.event.changedTouches,a=0,o=n.length;a1){var u=s[0],f=s[1],d=u[0]-f[0],h=u[1]-f[1]; ++m=d*d+h*h}}function r(){var t,e,n,r,i=ui.touches(p);Hs.call(p);for(var l=0,s=i.length;l=c)return i;if(a)return a=!1,o;var e=u;if(34===t.charCodeAt(e)){for(var n=e;n++=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,hl=ui.map({b:function(t){return t.toString(2)},c:function(t){return String.fromCharCode(t)},o:function(t){return t.toString(8)},x:function(t){return t.toString(16)},X:function(t){return t.toString(16).toUpperCase()},g:function(t,e){return t.toPrecision(e)},e:function(t,e){return t.toExponential(e)},f:function(t,e){return t.toFixed(e)},r:function(t,e){return(t=ui.round(t,Rt(t,e))).toFixed(Math.max(0,Math.min(20,Rt(t*(1+1e-15),e))))}}),pl=ui.time={},gl=Date;Bt.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){vl.setUTCDate.apply(this._,arguments)},setDay:function(){vl.setUTCDay.apply(this._,arguments)},setFullYear:function(){vl.setUTCFullYear.apply(this._,arguments)},setHours:function(){vl.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){vl.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){vl.setUTCMinutes.apply(this._,arguments)},setMonth:function(){vl.setUTCMonth.apply(this._,arguments)},setSeconds:function(){vl.setUTCSeconds.apply(this._,arguments)},setTime:function(){vl.setTime.apply(this._,arguments)}};var vl=Date.prototype;pl.year=Ht(function(t){return t=pl.day(t),t.setMonth(0,1),t},function(t,e){t.setFullYear(t.getFullYear()+e)},function(t){return t.getFullYear()}),pl.years=pl.year.range,pl.years.utc=pl.year.utc.range,pl.day=Ht(function(t){var e=new gl(2e3,0);return e.setFullYear(t.getFullYear(),t.getMonth(),t.getDate()),e},function(t,e){t.setDate(t.getDate()+e)},function(t){return t.getDate()-1}),pl.days=pl.day.range,pl.days.utc=pl.day.utc.range,pl.dayOfYear=function(t){var e=pl.year(t);return Math.floor((t-e-6e4*(t.getTimezoneOffset()-e.getTimezoneOffset()))/864e5)},["sunday","monday","tuesday","wednesday","thursday","friday","saturday"].forEach(function(t,e){e=7-e;var n=pl[t]=Ht(function(t){return(t=pl.day(t)).setDate(t.getDate()-(t.getDay()+e)%7),t},function(t,e){t.setDate(t.getDate()+7*Math.floor(e))},function(t){var n=pl.year(t).getDay();return Math.floor((pl.dayOfYear(t)+(n+e)%7)/7)-(n!==e)});pl[t+"s"]=n.range,pl[t+"s"].utc=n.utc.range,pl[t+"OfYear"]=function(t){var n=pl.year(t).getDay();return Math.floor((pl.dayOfYear(t)+(n+e)%7)/7)}}),pl.week=pl.sunday,pl.weeks=pl.sunday.range,pl.weeks.utc=pl.sunday.utc.range,pl.weekOfYear=pl.sundayOfYear;var ml={"-":"",_:" ",0:"0"},yl=/^\s*\d+/,xl=/^%/;ui.locale=function(t){return{numberFormat:Ft(t),timeFormat:Zt(t)}};var bl=ui.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});ui.format=bl.numberFormat,ui.geo={},fe.prototype={s:0,t:0,add:function(t){de(t,this.t,_l),de(_l.s,this.s,this),this.s?this.t+=_l.t:this.s=_l.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var _l=new fe;ui.geo.stream=function(t,e){t&&wl.hasOwnProperty(t.type)?wl[t.type](t,e):he(t,e)};var wl={Feature:function(t,e){he(t.geometry,e)},FeatureCollection:function(t,e){for(var n=t.features,r=-1,a=n.length;++rh&&(h=e)}function e(e,n){var r=me([e*Vi,n*Vi]);if(m){var a=xe(m,r),o=[a[1],-a[0],0],i=xe(o,a);we(i),i=ke(i);var s=e-p,c=s>0?1:-1,g=i[0]*Zi*c,v=bi(s)>180;if(v^(c*ph&&(h=y)}else if(g=(g+360)%360-180,v^(c*ph&&(h=n);v?el(u,d)&&(d=e):l(e,d)>l(u,d)&&(u=e):d>=u?(ed&&(d=e)):e>p?l(u,e)>l(u,d)&&(d=e):l(e,d)>l(u,d)&&(u=e)}else t(e,n);m=r,p=e}function n(){_.point=e}function r(){b[0]=u,b[1]=d,_.point=t,m=null}function a(t,n){if(m){var r=t-p;y+=bi(r)>180?r+(r>0?360:-360):r}else g=t,v=n;Tl.point(t,n),e(t,n)}function o(){Tl.lineStart()}function i(){a(g,v),Tl.lineEnd(),bi(y)>Ri&&(u=-(d=180)),b[0]=u,b[1]=d,m=null}function l(t,e){return(e-=t)<0?e+360:e}function s(t,e){return t[0]-e[0]}function c(t,e){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:tRi?h=90:y<-Ri&&(f=-90),b[0]=u,b[1]=d}};return function(t){h=d=-(u=f=1/0),x=[],ui.geo.stream(t,_);var e=x.length;if(e){x.sort(s);for(var n,r=1,a=x[0],o=[a];rl(a[0],a[1])&&(a[1]=n[1]),l(n[0],a[1])>l(a[0],a[1])&&(a[0]=n[0])):o.push(a=n);for(var i,n,p=-(1/0),e=o.length-1,r=0,a=o[e];r<=e;a=n,++r)n=o[r],(i=l(a[1],n[0]))>p&&(p=i,u=n[0],d=a[1])}return x=b=null,u===1/0||f===1/0?[[NaN,NaN],[NaN,NaN]]:[[u,f],[d,h]]}}(),ui.geo.centroid=function(t){Ll=zl=Sl=Cl=El=Ol=Nl=Pl=Dl=Il=Rl=0,ui.geo.stream(t,jl);var e=Dl,n=Il,r=Rl,a=e*e+n*n+r*r;return a=.12&&a<.234&&r>=-.425&&r<-.214?i:a>=.166&&a<.234&&r>=-.214&&r<-.115?l:o).invert(t)},t.stream=function(t){var e=o.stream(t),n=i.stream(t),r=l.stream(t);return{point:function(t,a){e.point(t,a),n.point(t,a),r.point(t,a)},sphere:function(){e.sphere(),n.sphere(),r.sphere()},lineStart:function(){e.lineStart(),n.lineStart(),r.lineStart()},lineEnd:function(){e.lineEnd(),n.lineEnd(),r.lineEnd()},polygonStart:function(){e.polygonStart(),n.polygonStart(),r.polygonStart()},polygonEnd:function(){e.polygonEnd(),n.polygonEnd(),r.polygonEnd()}}},t.precision=function(e){return arguments.length?(o.precision(e),i.precision(e),l.precision(e),t):o.precision()},t.scale=function(e){return arguments.length?(o.scale(e),i.scale(.35*e),l.scale(e),t.translate(o.translate())):o.scale()},t.translate=function(e){if(!arguments.length)return o.translate();var c=o.scale(),u=+e[0],f=+e[1];return n=o.translate(e).clipExtent([[u-.455*c,f-.238*c],[u+.455*c,f+.238*c]]).stream(s).point,r=i.translate([u-.307*c,f+.201*c]).clipExtent([[u-.425*c+Ri,f+.12*c+Ri],[u-.214*c-Ri,f+.234*c-Ri]]).stream(s).point,a=l.translate([u-.205*c,f+.212*c]).clipExtent([[u-.214*c+Ri,f+.166*c+Ri],[u-.115*c-Ri,f+.234*c-Ri]]).stream(s).point,t},t.scale(1070)};var Bl,Hl,Vl,Zl,Yl,Ul,Xl={point:k,lineStart:k,lineEnd:k,polygonStart:function(){Hl=0,Xl.lineStart=Ge},polygonEnd:function(){Xl.lineStart=Xl.lineEnd=Xl.point=k,Bl+=bi(Hl/2)}},Gl={point:$e,lineStart:k,lineEnd:k,polygonStart:k,polygonEnd:k},$l={point:Je,lineStart:Ke,lineEnd:tn,polygonStart:function(){$l.lineStart=en},polygonEnd:function(){$l.point=Je,$l.lineStart=Ke,$l.lineEnd=tn}};ui.geo.path=function(){function t(t){return t&&("function"==typeof l&&o.pointRadius(+l.apply(this,arguments)),i&&i.valid||(i=a(o)),ui.geo.stream(t,i)),o.result()}function e(){return i=null,t}var n,r,a,o,i,l=4.5;return t.area=function(t){return Bl=0,ui.geo.stream(t,a(Xl)),Bl},t.centroid=function(t){return Sl=Cl=El=Ol=Nl=Pl=Dl=Il=Rl=0,ui.geo.stream(t,a($l)),Rl?[Dl/Rl,Il/Rl]:Pl?[Ol/Pl,Nl/Pl]:El?[Sl/El,Cl/El]:[NaN,NaN]},t.bounds=function(t){return Yl=Ul=-(Vl=Zl=1/0),ui.geo.stream(t,a(Gl)),[[Vl,Zl],[Yl,Ul]]},t.projection=function(t){return arguments.length?(a=(n=t)?t.stream||an(t):b,e()):n},t.context=function(t){return arguments.length?(o=null==(r=t)?new Qe:new nn(t),"function"!=typeof l&&o.pointRadius(l),e()):r},t.pointRadius=function(e){return arguments.length?(l="function"==typeof e?e:(o.pointRadius(+e),+e),t):l},t.projection(ui.geo.albersUsa()).context(null)},ui.geo.transform=function(t){return{stream:function(e){var n=new on(e);for(var r in t)n[r]=t[r];return n}}},on.prototype={point:function(t,e){this.stream.point(t,e)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}},ui.geo.projection=sn,ui.geo.projectionMutator=cn,(ui.geo.equirectangular=function(){return sn(fn)}).raw=fn.invert=fn,ui.geo.rotation=function(t){function e(e){return e=t(e[0]*Vi,e[1]*Vi),e[0]*=Zi,e[1]*=Zi,e}return t=hn(t[0]%360*Vi,t[1]*Vi,t.length>2?t[2]*Vi:0),e.invert=function(e){return e=t.invert(e[0]*Vi,e[1]*Vi),e[0]*=Zi,e[1]*=Zi,e},e},dn.invert=fn,ui.geo.circle=function(){function t(){var t="function"==typeof r?r.apply(this,arguments):r,e=hn(-t[0]*Vi,-t[1]*Vi,0).invert,a=[];return n(null,null,1,{point:function(t,n){a.push(t=e(t,n)),t[0]*=Zi,t[1]*=Zi}}),{type:"Polygon",coordinates:[a]}}var e,n,r=[0,0],a=6;return t.origin=function(e){return arguments.length?(r=e,t):r},t.angle=function(r){return arguments.length?(n=mn((e=+r)*Vi,a*Vi),t):e},t.precision=function(r){return arguments.length?(n=mn(e*Vi,(a=+r)*Vi),t):a},t.angle(90)},ui.geo.distance=function(t,e){var n,r=(e[0]-t[0])*Vi,a=t[1]*Vi,o=e[1]*Vi,i=Math.sin(r),l=Math.cos(r),s=Math.sin(a),c=Math.cos(a),u=Math.sin(o),f=Math.cos(o);return Math.atan2(Math.sqrt((n=f*i)*n+(n=c*u-s*f*l)*n),s*u+c*f*l)},ui.geo.graticule=function(){function t(){return{type:"MultiLineString",coordinates:e()}}function e(){return ui.range(Math.ceil(o/v)*v,a,v).map(d).concat(ui.range(Math.ceil(c/m)*m,s,m).map(h)).concat(ui.range(Math.ceil(r/p)*p,n,p).filter(function(t){return bi(t%v)>Ri}).map(u)).concat(ui.range(Math.ceil(l/g)*g,i,g).filter(function(t){return bi(t%m)>Ri}).map(f))}var n,r,a,o,i,l,s,c,u,f,d,h,p=10,g=p,v=90,m=360,y=2.5;return t.lines=function(){return e().map(function(t){return{type:"LineString",coordinates:t}})},t.outline=function(){return{type:"Polygon",coordinates:[d(o).concat(h(s).slice(1),d(a).reverse().slice(1),h(c).reverse().slice(1))]}},t.extent=function(e){return arguments.length?t.majorExtent(e).minorExtent(e):t.minorExtent()},t.majorExtent=function(e){return arguments.length?(o=+e[0][0],a=+e[1][0],c=+e[0][1],s=+e[1][1],o>a&&(e=o,o=a,a=e),c>s&&(e=c,c=s,s=e),t.precision(y)):[[o,c],[a,s]]},t.minorExtent=function(e){return arguments.length?(r=+e[0][0],n=+e[1][0],l=+e[0][1],i=+e[1][1],r>n&&(e=r,r=n,n=e),l>i&&(e=l,l=i,i=e),t.precision(y)):[[r,l],[n,i]]},t.step=function(e){return arguments.length?t.majorStep(e).minorStep(e):t.minorStep()},t.majorStep=function(e){return arguments.length?(v=+e[0],m=+e[1],t):[v,m]},t.minorStep=function(e){return arguments.length?(p=+e[0],g=+e[1],t):[p,g]},t.precision=function(e){return arguments.length?(y=+e,u=xn(l,i,90),f=bn(r,n,y),d=xn(c,s,90),h=bn(o,a,y),t):y},t.majorExtent([[-180,-90+Ri],[180,90-Ri]]).minorExtent([[-180,-80-Ri],[180,80+Ri]])},ui.geo.greatArc=function(){function t(){return{type:"LineString",coordinates:[e||r.apply(this,arguments),n||a.apply(this,arguments)]}}var e,n,r=_n,a=wn;return t.distance=function(){return ui.geo.distance(e||r.apply(this,arguments),n||a.apply(this,arguments))},t.source=function(n){return arguments.length?(r=n,e="function"==typeof n?null:n,t):r},t.target=function(e){return arguments.length?(a=e,n="function"==typeof e?null:e,t):a},t.precision=function(){return arguments.length?t:0},t},ui.geo.interpolate=function(t,e){return kn(t[0]*Vi,t[1]*Vi,e[0]*Vi,e[1]*Vi)},ui.geo.length=function(t){return Ql=0,ui.geo.stream(t,Wl),Ql};var Ql,Wl={sphere:k,point:k,lineStart:Mn,lineEnd:k,polygonStart:k,polygonEnd:k},Jl=An(function(t){return Math.sqrt(2/(1+t))},function(t){return 2*Math.asin(t/2)});(ui.geo.azimuthalEqualArea=function(){return sn(Jl)}).raw=Jl;var Kl=An(function(t){var e=Math.acos(t);return e&&e/Math.sin(e)},b);(ui.geo.azimuthalEquidistant=function(){return sn(Kl)}).raw=Kl,(ui.geo.conicConformal=function(){return Ue(Tn)}).raw=Tn,(ui.geo.conicEquidistant=function(){return Ue(Ln)}).raw=Ln;var ts=An(function(t){return 1/t},Math.atan);(ui.geo.gnomonic=function(){return sn(ts)}).raw=ts,zn.invert=function(t,e){return[t,2*Math.atan(Math.exp(e))-Hi]},(ui.geo.mercator=function(){return Sn(zn)}).raw=zn;var es=An(function(){return 1},Math.asin);(ui.geo.orthographic=function(){return sn(es)}).raw=es;var ns=An(function(t){return 1/(1+t)},function(t){return 2*Math.atan(t)});(ui.geo.stereographic=function(){return sn(ns)}).raw=ns,Cn.invert=function(t,e){return[-e,2*Math.atan(Math.exp(t))-Hi]},(ui.geo.transverseMercator=function(){var t=Sn(Cn),e=t.center,n=t.rotate;return t.center=function(t){return t?e([-t[1],t[0]]):(t=e(),[t[1],-t[0]])},t.rotate=function(t){return t?n([t[0],t[1],t.length>2?t[2]+90:90]):(t=n(),[t[0],t[1],t[2]-90])},n([0,0,90])}).raw=Cn,ui.geom={},ui.geom.hull=function(t){function e(t){if(t.length<3)return[];var e,a=zt(n),o=zt(r),i=t.length,l=[],s=[];for(e=0;e=0;--e)h.push(t[l[c[e]][2]]);for(e=+f;e=r&&c.x<=o&&c.y>=a&&c.y<=i?[[r,i],[o,i],[o,a],[r,a]]:[];u.point=t[l]}),e}function n(t){return t.map(function(t,e){return{x:Math.round(o(t,e)/Ri)*Ri,y:Math.round(i(t,e)/Ri)*Ri,i:e}})}var r=En,a=On,o=r,i=a,l=fs;return t?e(t):(e.links=function(t){return cr(n(t)).edges.filter(function(t){return t.l&&t.r}).map(function(e){return{source:t[e.l.i],target:t[e.r.i]}})},e.triangles=function(t){var e=[];return cr(n(t)).cells.forEach(function(n,r){for(var a,o,i=n.site,l=n.edges.sort(Xn),s=-1,c=l.length,u=l[c-1].edge,f=u.l===i?u.r:u.l;++s=c,d=r>=u,h=d<<1|f;t.leaf=!1,t=t.nodes[h]||(t.nodes[h]=pr()),f?a=c:l=c,d?i=u:s=u,o(t,e,n,r,a,i,l,s)}var u,f,d,h,p,g,v,m,y,x=zt(l),b=zt(s);if(null!=e)g=e,v=n,m=r,y=a;else if(m=y=-(g=v=1/0),f=[],d=[],p=t.length,i)for(h=0;hm&&(m=u.x),u.y>y&&(y=u.y),f.push(u.x),d.push(u.y);else for(h=0;hm&&(m=_),w>y&&(y=w),f.push(_),d.push(w)}var k=m-g,M=y-v;k>M?y=v+k:m=g+M;var A=pr();if(A.add=function(t){o(A,t,+x(t,++h),+b(t,h),g,v,m,y)},A.visit=function(t){gr(t,A,g,v,m,y)},A.find=function(t){return vr(A,t[0],t[1],g,v,m,y)},h=-1,null==e){for(;++h=0?t.slice(0,e):t,r=e>=0?t.slice(e+1):"in";return n=gs.get(n)||ps,r=vs.get(r)||b,kr(r(n.apply(null,fi.call(arguments,1))))},ui.interpolateHcl=Ir,ui.interpolateHsl=Rr,ui.interpolateLab=jr,ui.interpolateRound=Fr,ui.transform=function(t){var e=hi.createElementNS(ui.ns.prefix.svg,"g");return(ui.transform=function(t){if(null!=t){e.setAttribute("transform",t);var n=e.transform.baseVal.consolidate()}return new qr(n?n.matrix:ms)})(t)},qr.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var ms={a:1,b:0,c:0,d:1,e:0,f:0};ui.interpolateTransform=$r,ui.layout={},ui.layout.bundle=function(){return function(t){for(var e=[],n=-1,r=t.length;++n0?a=t:(n.c=null,n.t=NaN,n=null,c.end({type:"end",alpha:a=0})):t>0&&(c.start({type:"start",alpha:a=t}),n=Nt(s.tick)),s):a},s.start=function(){function t(t,r){if(!n){for(n=new Array(a),s=0;s=0;)i.push(u=c[s]),u.parent=o,u.depth=o.depth+1;r&&(o.value=0),o.children=c}else r&&(o.value=+r.call(t,o,o.depth)||0),delete o.children;return sa(a,function(t){var n,a;e&&(n=t.children)&&n.sort(e),r&&(a=t.parent)&&(a.value+=t.value)}),l}var e=fa,n=ca,r=ua;return t.sort=function(n){return arguments.length?(e=n,t):e},t.children=function(e){return arguments.length?(n=e,t):n},t.value=function(e){return arguments.length?(r=e,t):r},t.revalue=function(e){return r&&(la(e,function(t){t.children&&(t.value=0)}),sa(e,function(e){var n;e.children||(e.value=+r.call(t,e,e.depth)||0),(n=e.parent)&&(n.value+=e.value)})),e},t},ui.layout.partition=function(){function t(e,n,r,a){var o=e.children;if(e.x=n,e.y=e.depth*a,e.dx=r,e.dy=a,o&&(i=o.length)){var i,l,s,c=-1;for(r=e.value?r/e.value:0;++cl&&(l=r),i.push(r)}for(n=0;n0)for(o=-1;++o=u[0]&&l<=u[1]&&(i=s[ui.bisect(f,l,1,h)-1],i.y+=p,i.push(t[o]));return s}var e=!0,n=Number,r=ka,a=_a;return t.value=function(e){return arguments.length?(n=e,t):n},t.range=function(e){return arguments.length?(r=zt(e),t):r},t.bins=function(e){return arguments.length?(a="number"==typeof e?function(t){return wa(t,e)}:zt(e),t):a},t.frequency=function(n){return arguments.length?(e=!!n,t):e},t},ui.layout.pack=function(){function t(t,o){var i=n.call(this,t,o),l=i[0],s=a[0],c=a[1],u=null==e?Math.sqrt:"function"==typeof e?e:function(){return e};if(l.x=l.y=0,sa(l,function(t){t.r=+u(t.value)}),sa(l,za),r){var f=r*(e?1:Math.max(2*l.r/s,2*l.r/c))/2;sa(l,function(t){t.r+=f}),sa(l,za),sa(l,function(t){t.r-=f})}return Ea(l,s/2,c/2,e?1:1/Math.max(2*l.r/s,2*l.r/c)),i}var e,n=ui.layout.hierarchy().sort(Ma),r=0,a=[1,1];return t.size=function(e){return arguments.length?(a=e,t):a},t.radius=function(n){return arguments.length?(e=null==n||"function"==typeof n?n:+n,t):e},t.padding=function(e){return arguments.length?(r=+e,t):r},ia(t,n)},ui.layout.tree=function(){function t(t,a){var u=i.call(this,t,a),f=u[0],d=e(f);if(sa(d,n),d.parent.m=-d.z,la(d,r),c)la(f,o);else{var h=f,p=f,g=f;la(f,function(t){t.xp.x&&(p=t),t.depth>g.depth&&(g=t)});var v=l(h,p)/2-h.x,m=s[0]/(p.x+l(p,h)/2+v),y=s[1]/(g.depth||1);la(f,function(t){t.x=(t.x+v)*m,t.y=t.depth*y})}return u}function e(t){for(var e,n={A:null,children:[t]},r=[n];null!=(e=r.pop());)for(var a,o=e.children,i=0,l=o.length;i0&&(Ia(ja(i,t,n),t,r),c+=r,u+=r),f+=i.m,c+=a.m,d+=s.m,u+=o.m;i&&!Da(o)&&(o.t=i,o.m+=f-u),a&&!Pa(s)&&(s.t=a,s.m+=c-d,n=t)}return n}function o(t){t.x*=s[0],t.y=t.depth*s[1]}var i=ui.layout.hierarchy().sort(null).value(null),l=Na,s=[1,1],c=null;return t.separation=function(e){return arguments.length?(l=e,t):l},t.size=function(e){return arguments.length?(c=null==(s=e)?o:null,t):c?null:s},t.nodeSize=function(e){return arguments.length?(c=null==(s=e)?null:o,t):c?s:null},ia(t,i)},ui.layout.cluster=function(){function t(t,o){var i,l=e.call(this,t,o),s=l[0],c=0;sa(s,function(t){var e=t.children;e&&e.length?(t.x=qa(e),t.y=Fa(e)):(t.x=i?c+=n(t,i):0,t.y=0,i=t)});var u=Ba(s),f=Ha(s),d=u.x-n(u,f)/2,h=f.x+n(f,u)/2;return sa(s,a?function(t){t.x=(t.x-s.x)*r[0],t.y=(s.y-t.y)*r[1]}:function(t){t.x=(t.x-d)/(h-d)*r[0],t.y=(1-(s.y?t.y/s.y:1))*r[1]}),l}var e=ui.layout.hierarchy().sort(null).value(null),n=Na,r=[1,1],a=!1;return t.separation=function(e){return arguments.length?(n=e,t):n},t.size=function(e){return arguments.length?(a=null==(r=e),t):a?null:r},t.nodeSize=function(e){return arguments.length?(a=null!=(r=e),t):a?r:null},ia(t,e)},ui.layout.treemap=function(){function t(t,e){for(var n,r,a=-1,o=t.length;++a0;)u.push(i=d[s-1]),u.area+=i.area,"squarify"!==h||(l=r(u,g))<=p?(d.pop(),p=l):(u.area-=u.pop().area,a(u,g,c,!1),g=Math.min(c.dx,c.dy),u.length=u.area=0,p=1/0);u.length&&(a(u,g,c,!0),u.length=u.area=0),o.forEach(e)}}function n(e){var r=e.children;if(r&&r.length){var o,i=f(e),l=r.slice(),s=[];for(t(l,i.dx*i.dy/e.value),s.area=0;o=l.pop();)s.push(o),s.area+=o.area,null!=o.z&&(a(s,o.z?i.dx:i.dy,i,!l.length),s.length=s.area=0);r.forEach(n)}}function r(t,e){for(var n,r=t.area,a=0,o=1/0,i=-1,l=t.length;++ia&&(a=n));return r*=r,e*=e,r?Math.max(e*a*p/r,r/(e*o*p)):1/0}function a(t,e,n,r){var a,o=-1,i=t.length,l=n.x,c=n.y,u=e?s(t.area/e):0;if(e==n.dx){for((r||u>n.dy)&&(u=n.dy);++on.dx)&&(u=n.dx);++o1);return t+e*n*Math.sqrt(-2*Math.log(a)/a)}},logNormal:function(){var t=ui.random.normal.apply(ui,arguments);return function(){return Math.exp(t())}},bates:function(t){var e=ui.random.irwinHall(t);return function(){return e()/t}},irwinHall:function(t){return function(){for(var e=0,n=0;nf?0:1;if(c=Bi)return e(c,h)+(t?e(t,1-h):"")+"Z";var p,g,v,m,y,x,b,_,w,k,M,A,T=0,L=0,z=[];if((m=(+s.apply(this,arguments)||0)/2)&&(v=o===Os?Math.sqrt(t*t+c*c):+o.apply(this,arguments),h||(L*=-1),c&&(L=rt(v/c*Math.sin(m))),t&&(T=rt(v/t*Math.sin(m)))),c){y=c*Math.cos(u+L),x=c*Math.sin(u+L),b=c*Math.cos(f-L),_=c*Math.sin(f-L);var S=Math.abs(f-u-2*L)<=Fi?0:1;if(L&&bo(y,x,b,_)===h^S){var C=(u+f)/2;y=c*Math.cos(C),x=c*Math.sin(C),b=_=null}}else y=x=0;if(t){w=t*Math.cos(f-T),k=t*Math.sin(f-T),M=t*Math.cos(u+T),A=t*Math.sin(u+T);var E=Math.abs(u-f+2*T)<=Fi?0:1;if(T&&bo(w,k,M,A)===1-h^E){var O=(u+f)/2;w=t*Math.cos(O),k=t*Math.sin(O),M=A=null}}else w=k=0;if(d>Ri&&(p=Math.min(Math.abs(c-t)/2,+a.apply(this,arguments)))>.001){g=tFi)+",1 "+e}function a(t,e,n,r){return"Q 0,0 "+r}var o=_n,i=wn,l=Yo,s=mo,c=yo;return t.radius=function(e){return arguments.length?(l=zt(e),t):l},t.source=function(e){return arguments.length?(o=zt(e),t):o},t.target=function(e){return arguments.length?(i=zt(e),t):i},t.startAngle=function(e){return arguments.length?(s=zt(e),t):s},t.endAngle=function(e){return arguments.length?(c=zt(e),t):c},t},ui.svg.diagonal=function(){function t(t,a){var o=e.call(this,t,a),i=n.call(this,t,a),l=(o.y+i.y)/2,s=[o,{x:o.x,y:l},{x:i.x,y:l},i];return s=s.map(r),"M"+s[0]+"C"+s[1]+" "+s[2]+" "+s[3]}var e=_n,n=wn,r=Uo;return t.source=function(n){return arguments.length?(e=zt(n),t):e},t.target=function(e){return arguments.length?(n=zt(e),t):n},t.projection=function(e){return arguments.length?(r=e,t):r},t},ui.svg.diagonal.radial=function(){var t=ui.svg.diagonal(),e=Uo,n=t.projection;return t.projection=function(t){return arguments.length?n(Xo(e=t)):e},t},ui.svg.symbol=function(){function t(t,r){return(Rs.get(e.call(this,t,r))||Qo)(n.call(this,t,r))}var e=$o,n=Go;return t.type=function(n){return arguments.length?(e=zt(n),t):e},t.size=function(e){return arguments.length?(n=zt(e),t):n},t};var Rs=ui.map({circle:Qo,cross:function(t){var e=Math.sqrt(t/5)/2;return"M"+-3*e+","+-e+"H"+-e+"V"+-3*e+"H"+e+"V"+-e+"H"+3*e+"V"+e+"H"+e+"V"+3*e+"H"+-e+"V"+e+"H"+-3*e+"Z"},diamond:function(t){var e=Math.sqrt(t/(2*Fs)),n=e*Fs;return"M0,"+-e+"L"+n+",0 0,"+e+" "+-n+",0Z"},square:function(t){var e=Math.sqrt(t)/2;return"M"+-e+","+-e+"L"+e+","+-e+" "+e+","+e+" "+-e+","+e+"Z"},"triangle-down":function(t){var e=Math.sqrt(t/js),n=e*js/2;return"M0,"+n+"L"+e+","+-n+" "+-e+","+-n+"Z"},"triangle-up":function(t){var e=Math.sqrt(t/js),n=e*js/2;return"M0,"+-n+"L"+e+","+n+" "+-e+","+n+"Z"}});ui.svg.symbolTypes=Rs.keys();var js=Math.sqrt(3),Fs=Math.tan(30*Vi);Si.transition=function(t){for(var e,n,r=qs||++Zs,a=ei(t),o=[],i=Bs||{time:Date.now(),ease:zr,delay:0,duration:250},l=-1,s=this.length;++lrect,.s>rect").attr("width",f[1]-f[0])}function a(t){t.select(".extent").attr("y",d[0]),t.selectAll(".extent,.e>rect,.w>rect").attr("height",d[1]-d[0])}function o(){function o(){32==ui.event.keyCode&&(S||(x=null,E[0]-=f[1],E[1]-=d[1],S=2),T())}function g(){32==ui.event.keyCode&&2==S&&(E[0]+=f[1],E[1]+=d[1],S=0,T())}function v(){var t=ui.mouse(_),r=!1;b&&(t[0]+=b[0],t[1]+=b[1]),S||(ui.event.altKey?(x||(x=[(f[0]+f[1])/2,(d[0]+d[1])/2]),E[0]=f[+(t[0]0&&this._events[t].length>n&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(t,e){function n(){this.removeListener(t,n),r||(r=!0,e.apply(this,arguments))}if(!a(e))throw TypeError("listener must be a function");var r=!1;return n.listener=e,this.on(t,n),this},r.prototype.removeListener=function(t,e){var n,r,o,l;if(!a(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(n=this._events[t],o=n.length,r=-1,n===e||a(n.listener)&&n.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(i(n)){for(l=o;l-- >0;)if(n[l]===e||n[l].listener&&n[l].listener===e){r=l;break}if(r<0)return this;1===n.length?(n.length=0,delete this._events[t]):n.splice(r,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},r.prototype.removeAllListeners=function(t){var e,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[t],a(n))this.removeListener(t,n);else if(n)for(;n.length;)this.removeListener(t,n[n.length-1]);return delete this._events[t],this},r.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?a(this._events[t])?[this._events[t]]:this._events[t].slice():[]},r.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(a(e))return 1;if(e)return e.length}return 0},r.listenerCount=function(t,e){return t.listenerCount(e)}},{}],10:[function(t,e,n){"use strict";function r(t){for(var e,n=t.length,r=0;r13)&&32!==e&&133!==e&&160!==e&&5760!==e&&6158!==e&&(e<8192||e>8205)&&8232!==e&&8233!==e&&8239!==e&&8287!==e&&8288!==e&&12288!==e&&65279!==e)return!1;return!0}e.exports=function(t){var e=typeof t;if("string"===e){var n=t;if(t=+t,0===t&&r(n))return!1}else if("number"!==e)return!1;return t-t<1}},{}],11:[function(t,e,n){function r(t,e){var n=e[0],r=e[1],a=e[2],o=e[3],i=n+n,l=r+r,s=a+a,c=n*i,u=r*i,f=r*l,d=a*i,h=a*l,p=a*s,g=o*i,v=o*l,m=o*s;return t[0]=1-f-p,t[1]=u+m,t[2]=d-v,t[3]=0,t[4]=u-m,t[5]=1-c-p,t[6]=h+g,t[7]=0,t[8]=d+v,t[9]=h-g,t[10]=1-c-f,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}e.exports=r},{}],12:[function(t,e,n){function r(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function o(t){if(f===setTimeout)return setTimeout(t,0);if((f===r||!f)&&setTimeout)return f=setTimeout,setTimeout(t,0);try{return f(t,0)}catch(e){try{return f.call(null,t,0)}catch(e){return f.call(this,t,0)}}}function i(t){if(d===clearTimeout)return clearTimeout(t);if((d===a||!d)&&clearTimeout)return d=clearTimeout,clearTimeout(t);try{return d(t)}catch(e){try{return d.call(null,t)}catch(e){return d.call(this,t)}}}function l(){v&&p&&(v=!1,p.length?g=p.concat(g):m=-1,g.length&&s())}function s(){if(!v){var t=o(l);v=!0;for(var e=g.length;e;){for(p=g,g=[];++m1)for(var n=1;n.5?s/(2-o-i):s/(o+i),o){case t:r=(e-n)/s+(e1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+(e-t)*(2/3-n)*6:t}var a,o,i;if(t=z(t,360),e=z(e,100),n=z(n,100),0===e)a=o=i=n;else{var l=n<.5?n*(1+e):n+e-n*e,s=2*n-l;a=r(s,l,t+1/3),o=r(s,l,t),i=r(s,l,t-1/3)}return{r:255*a,g:255*o,b:255*i}}function s(t,e,n){t=z(t,255),e=z(e,255),n=z(n,255);var r,a,o=Y(t,e,n),i=Z(t,e,n),l=o,s=o-i;if(a=0===o?0:s/o,o==i)r=0;else{switch(o){case t:r=(e-n)/s+(e>1)+720)%360;--e;)a.h=(a.h+o)%360,i.push(r(a));return i}function A(t,e){e=e||6;for(var n=r(t).toHsv(),a=n.h,o=n.s,i=n.v,l=[],s=1/e;e--;)l.push(r({h:a,s:o,v:i})),i=(i+s)%1;return l}function T(t){var e={};for(var n in t)t.hasOwnProperty(n)&&(e[t[n]]=n);return e}function L(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function z(t,n){E(t)&&(t="100%");var r=O(t);return t=Z(n,Y(0,parseFloat(t))),r&&(t=parseInt(t*n,10)/100),e.abs(t-n)<1e-6?1:t%n/parseFloat(n)}function S(t){return Z(1,Y(0,t))}function C(t){return parseInt(t,16)}function E(t){return"string"==typeof t&&t.indexOf(".")!=-1&&1===parseFloat(t)}function O(t){return"string"==typeof t&&t.indexOf("%")!=-1}function N(t){return 1==t.length?"0"+t:""+t}function P(t){return t<=1&&(t=100*t+"%"),t}function D(t){return e.round(255*parseFloat(t)).toString(16)}function I(t){return C(t)/255}function R(t){return!!$.CSS_UNIT.exec(t)}function j(t){t=t.replace(q,"").replace(B,"").toLowerCase();var e=!1;if(X[t])t=X[t],e=!0;else if("transparent"==t)return{r:0,g:0,b:0,a:0,format:"name"};var n;return(n=$.rgb.exec(t))?{r:n[1],g:n[2],b:n[3]}:(n=$.rgba.exec(t))?{r:n[1],g:n[2],b:n[3],a:n[4]}:(n=$.hsl.exec(t))?{h:n[1],s:n[2],l:n[3]}:(n=$.hsla.exec(t))?{h:n[1],s:n[2],l:n[3],a:n[4]}:(n=$.hsv.exec(t))?{h:n[1],s:n[2],v:n[3]}:(n=$.hsva.exec(t))?{h:n[1],s:n[2],v:n[3],a:n[4]}:(n=$.hex8.exec(t))?{r:C(n[1]),g:C(n[2]),b:C(n[3]),a:I(n[4]),format:e?"name":"hex8"}:(n=$.hex6.exec(t))?{r:C(n[1]),g:C(n[2]),b:C(n[3]),format:e?"name":"hex"}:(n=$.hex4.exec(t))?{r:C(n[1]+""+n[1]),g:C(n[2]+""+n[2]),b:C(n[3]+""+n[3]),a:I(n[4]+""+n[4]),format:e?"name":"hex8"}:!!(n=$.hex3.exec(t))&&{r:C(n[1]+""+n[1]),g:C(n[2]+""+n[2]),b:C(n[3]+""+n[3]),format:e?"name":"hex"}}function F(t){var e,n;return t=t||{level:"AA",size:"small"},e=(t.level||"AA").toUpperCase(),n=(t.size||"small").toLowerCase(),"AA"!==e&&"AAA"!==e&&(e="AA"),"small"!==n&&"large"!==n&&(n="small"),{level:e,size:n}}var q=/^\s+/,B=/\s+$/,H=0,V=e.round,Z=e.min,Y=e.max,U=e.random;r.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var t,n,r,a,o,i,l=this.toRgb();return t=l.r/255,n=l.g/255,r=l.b/255,a=t<=.03928?t/12.92:e.pow((t+.055)/1.055,2.4),o=n<=.03928?n/12.92:e.pow((n+.055)/1.055,2.4),i=r<=.03928?r/12.92:e.pow((r+.055)/1.055,2.4),.2126*a+.7152*o+.0722*i},setAlpha:function(t){return this._a=L(t),this._roundA=V(100*this._a)/100,this},toHsv:function(){var t=s(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=s(this._r,this._g,this._b),e=V(360*t.h),n=V(100*t.s),r=V(100*t.v);return 1==this._a?"hsv("+e+", "+n+"%, "+r+"%)":"hsva("+e+", "+n+"%, "+r+"%, "+this._roundA+")"},toHsl:function(){var t=i(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=i(this._r,this._g,this._b),e=V(360*t.h),n=V(100*t.s),r=V(100*t.l);return 1==this._a?"hsl("+e+", "+n+"%, "+r+"%)":"hsla("+e+", "+n+"%, "+r+"%, "+this._roundA+")"},toHex:function(t){return u(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return f(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:V(this._r),g:V(this._g),b:V(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+V(this._r)+", "+V(this._g)+", "+V(this._b)+")":"rgba("+V(this._r)+", "+V(this._g)+", "+V(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:V(100*z(this._r,255))+"%",g:V(100*z(this._g,255))+"%",b:V(100*z(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+V(100*z(this._r,255))+"%, "+V(100*z(this._g,255))+"%, "+V(100*z(this._b,255))+"%)":"rgba("+V(100*z(this._r,255))+"%, "+V(100*z(this._g,255))+"%, "+V(100*z(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(G[u(this._r,this._g,this._b,!0)]||!1)},toFilter:function(t){var e="#"+d(this._r,this._g,this._b,this._a),n=e,a=this._gradientType?"GradientType = 1, ":"";if(t){var o=r(t);n="#"+d(o._r,o._g,o._b,o._a)}return"progid:DXImageTransform.Microsoft.gradient("+a+"startColorstr="+e+",endColorstr="+n+")"},toString:function(t){var e=!!t;t=t||this._format;var n=!1,r=this._a<1&&this._a>=0,a=!e&&r&&("hex"===t||"hex6"===t||"hex3"===t||"hex4"===t||"hex8"===t||"name"===t);return a?"name"===t&&0===this._a?this.toName():this.toRgbString():("rgb"===t&&(n=this.toRgbString()),"prgb"===t&&(n=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(n=this.toHexString()),"hex3"===t&&(n=this.toHexString(!0)),"hex4"===t&&(n=this.toHex8String(!0)),"hex8"===t&&(n=this.toHex8String()),"name"===t&&(n=this.toName()),"hsl"===t&&(n=this.toHslString()),"hsv"===t&&(n=this.toHsvString()),n||this.toHexString())},clone:function(){return r(this.toString())},_applyModification:function(t,e){var n=t.apply(null,[this].concat([].slice.call(e)));return this._r=n._r,this._g=n._g,this._b=n._b,this.setAlpha(n._a),this},lighten:function(){return this._applyModification(v,arguments)},brighten:function(){return this._applyModification(m,arguments)},darken:function(){return this._applyModification(y,arguments)},desaturate:function(){return this._applyModification(h,arguments)},saturate:function(){return this._applyModification(p,arguments)},greyscale:function(){return this._applyModification(g,arguments)},spin:function(){return this._applyModification(x,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(M,arguments)},complement:function(){return this._applyCombination(b,arguments)},monochromatic:function(){return this._applyCombination(A,arguments)},splitcomplement:function(){return this._applyCombination(k,arguments)},triad:function(){return this._applyCombination(_,arguments)},tetrad:function(){return this._applyCombination(w,arguments)}},r.fromRatio=function(t,e){if("object"==typeof t){var n={};for(var a in t)t.hasOwnProperty(a)&&("a"===a?n[a]=t[a]:n[a]=P(t[a]));t=n}return r(t,e)},r.equals=function(t,e){return!(!t||!e)&&r(t).toRgbString()==r(e).toRgbString()},r.random=function(){return r.fromRatio({r:U(),g:U(),b:U()})},r.mix=function(t,e,n){n=0===n?0:n||50;var a=r(t).toRgb(),o=r(e).toRgb(),i=n/100,l={r:(o.r-a.r)*i+a.r,g:(o.g-a.g)*i+a.g,b:(o.b-a.b)*i+a.b,a:(o.a-a.a)*i+a.a};return r(l)},r.readability=function(t,n){var a=r(t),o=r(n);return(e.max(a.getLuminance(),o.getLuminance())+.05)/(e.min(a.getLuminance(),o.getLuminance())+.05)},r.isReadable=function(t,e,n){var a,o,i=r.readability(t,e);switch(o=!1,a=F(n),a.level+a.size){case"AAsmall":case"AAAlarge":o=i>=4.5;break;case"AAlarge":o=i>=3;break;case"AAAsmall":o=i>=7}return o},r.mostReadable=function(t,e,n){var a,o,i,l,s=null,c=0;n=n||{},o=n.includeFallbackColors,i=n.level,l=n.size;for(var u=0;uc&&(c=a,s=r(e[u]));return r.isReadable(t,s,{level:i,size:l})||!o?s:(n.includeFallbackColors=!1,r.mostReadable(t,["#fff","#000"],n))};var X=r.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},G=r.hexNames=T(X),$=function(){var t="[-\\+]?\\d+%?",e="[-\\+]?\\d*\\.\\d+%?",n="(?:"+e+")|(?:"+t+")",r="[\\s|\\(]+("+n+")[,|\\s]+("+n+")[,|\\s]+("+n+")\\s*\\)?",a="[\\s|\\(]+("+n+")[,|\\s]+("+n+")[,|\\s]+("+n+")[,|\\s]+("+n+")\\s*\\)?";return{CSS_UNIT:new RegExp(n),rgb:new RegExp("rgb"+r),rgba:new RegExp("rgba"+a),hsl:new RegExp("hsl"+r),hsla:new RegExp("hsla"+a),hsv:new RegExp("hsv"+r),hsva:new RegExp("hsva"+a),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();"undefined"!=typeof n&&n.exports?n.exports=r:"function"==typeof t&&t.amd?t(function(){return r}):window.tinycolor=r}(Math)},{}],14:[function(t,e,n){"use strict";e.exports=["",{path:"M-2.4,-3V3L0.6,0Z",backoff:.6},{path:"M-3.7,-2.5V2.5L1.3,0Z",backoff:1.3},{path:"M-4.45,-3L-1.65,-0.2V0.2L-4.45,3L1.55,0Z",backoff:1.55},{path:"M-2.2,-2.2L-0.2,-0.2V0.2L-2.2,2.2L-1.4,3L1.6,0L-1.4,-3Z",backoff:1.6},{path:"M-4.4,-2.1L-0.6,-0.2V0.2L-4.4,2.1L-4,3L2,0L-4,-3Z",backoff:2},{path:"M2,0A2,2 0 1,1 0,-2A2,2 0 0,1 2,0Z",backoff:0},{path:"M2,2V-2H-2V2Z",backoff:0}]},{}],15:[function(t,e,n){"use strict";var r=t("./arrow_paths"),a=t("../../plots/font_attributes"),o=t("../../plots/cartesian/constants"),i=t("../../lib/extend").extendFlat;e.exports={_isLinkedToArray:!0,text:{valType:"string"},textangle:{valType:"angle",dflt:0},font:i({},a,{}),opacity:{valType:"number",min:0,max:1,dflt:1},align:{valType:"enumerated",values:["left","center","right"],dflt:"center"},bgcolor:{valType:"color",dflt:"rgba(0,0,0,0)"},bordercolor:{valType:"color",dflt:"rgba(0,0,0,0)"},borderpad:{valType:"number",min:0,dflt:1},borderwidth:{valType:"number",min:0,dflt:1},showarrow:{valType:"boolean",dflt:!0},arrowcolor:{valType:"color"},arrowhead:{valType:"integer",min:0,max:r.length,dflt:1},arrowsize:{valType:"number",min:.3,dflt:1 ++},arrowwidth:{valType:"number",min:.1},ax:{valType:"number",dflt:-10},ay:{valType:"number",dflt:-30},axref:{valType:"enumerated",dflt:"pixel",values:["pixel",o.idRegex.x.toString()]},ayref:{valType:"enumerated",dflt:"pixel",values:["pixel",o.idRegex.y.toString()]},xref:{valType:"enumerated",values:["paper",o.idRegex.x.toString()]},x:{valType:"number"},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"auto"},yref:{valType:"enumerated",values:["paper",o.idRegex.y.toString()]},y:{valType:"number"},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto"},_deprecated:{ref:{valType:"string"}}}},{"../../lib/extend":93,"../../plots/cartesian/constants":120,"../../plots/font_attributes":133,"./arrow_paths":14}],16:[function(t,e,n){"use strict";function r(t,e){function n(e,n){return c.coerce(t,r,v.layoutAttributes,e,n)}var r={};n("opacity"),n("align"),n("bgcolor");var a=n("bordercolor"),o=f.opacity(a);n("borderpad");var i=n("borderwidth"),l=n("showarrow");l&&(n("arrowcolor",o?r.bordercolor:f.defaultLine),n("arrowhead"),n("arrowsize"),n("arrowwidth",2*(o&&i||1)),n("ax"),n("ay"),n("axref"),n("ayref"),c.noneOrAll(t,r,["ax","ay"])),n("text",l?" ":"new text"),n("textangle"),c.coerceFont(n,"font",e.font);for(var s=["x","y"],d=0;d<2;d++){var h=s[d],p={_fullLayout:e},g=u.coerceRef(t,r,p,h),m=u.coerceARef(t,r,p,h),y=.5;if("paper"!==g){var x=u.getFromId(p,g);if(y=x.range[0]+y*(x.range[1]-x.range[0]),["date","category"].indexOf(x.type)!==-1&&"string"==typeof t[h]){var b;if("date"===x.type){if(b=c.dateTime2ms(t[h]),b!==!1&&(t[h]=b),m===g){var _=c.dateTime2ms(t["a"+h]);_!==!1&&(t["a"+h]=_)}}else(x._categories||[]).length&&(b=x._categories.indexOf(t[h]),b!==-1&&(t[h]=b))}}n(h,y),l||n(h+"anchor")}return c.noneOrAll(t,r,["x","y"]),r}function a(t){var e=t._fullLayout;e.annotations.forEach(function(e){var n=u.getFromId(t,e.xref),r=u.getFromId(t,e.yref);if(n||r){var a=(e._xsize||0)/2,o=e._xshift||0,i=(e._ysize||0)/2,l=e._yshift||0,s=a-o,c=a+o,f=i-l,d=i+l;if(e.showarrow){var h=3*e.arrowsize*e.arrowwidth;s=Math.max(s,h),c=Math.max(c,h),f=Math.max(f,h),d=Math.max(d,h)}n&&n.autorange&&u.expand(n,[n.l2c(e.x)],{ppadplus:c,ppadminus:s}),r&&r.autorange&&u.expand(r,[r.l2c(e.y)],{ppadplus:d,ppadminus:f})}})}function o(t,e,n,r,a,o,i,l){var s=n-t,c=a-t,u=i-a,f=r-e,d=o-e,h=l-o,p=s*h-u*f;if(0===p)return null;var g=(c*h-u*d)/p,v=(c*f-s*d)/p;return v<0||v>1||g<0||g>1?null:{x:t+s*g,y:e+f*g}}var i=t("d3"),l=t("fast-isnumeric"),s=t("../../plotly"),c=t("../../lib"),u=t("../../plots/cartesian/axes"),f=t("../color"),d=t("../drawing"),h=t("../../lib/svg_text_utils"),p=t("../../lib/setcursor"),g=t("../dragelement"),v=e.exports={};v.ARROWPATHS=t("./arrow_paths"),v.layoutAttributes=t("./attributes"),v.supplyLayoutDefaults=function(t,e){for(var n=t.annotations||[],a=e.annotations=[],o=0;o2/3?"right":"center"),{center:0,middle:0,left:.5,bottom:-.5,right:-.5,top:.5}[e]}tt.selectAll("tspan.line").attr({y:0,x:0});var r=G.select(".annotation-math-group"),a=!r.empty(),l=d.bBox((a?r:tt).node()),h=l.width,m=l.height,y=Math.round(h+2*W),x=Math.round(m+2*W);B._w=h,B._h=m;var b=!1;if(["x","y"].forEach(function(e){var r,a=B[e+"ref"]||e,o=u.getFromId(t,a),i=(Y+("x"===e?0:90))*Math.PI/180,l=y*Math.abs(Math.cos(i))+x*Math.abs(Math.sin(i)),s=B[e+"anchor"];if(o){if(!o.autorange&&(B[e]-o.range[0])*(B[e]-o.range[1])>0&&(B["a"+e+"ref"]===a?(B["a"+e]-o.range[0])*(B["a"+e]-o.range[1])>0&&(b=!0):b=!0,b))return;Z[e]=o._offset+o.l2p(B[e]),r=.5}else r=B[e],"y"===e&&(r=1-r),Z[e]="x"===e?S.l+S.w*r:S.t+S.h*r;var c=0;B["a"+e+"ref"]===a?Z["aa"+e]=o._offset+o.l2p(B["a"+e]):(c=B.showarrow?B["a"+e]:l*n(r,s),Z[e]+=c),B["_"+e+"type"]=o&&o.type,B["_"+e+"size"]=l,B["_"+e+"shift"]=c}),b)return void G.remove();var w,k;B.showarrow&&(w=B.axref===B.xref?Z.x:c.constrain(Z.x-B.ax,1,_.width-1),k=B.ayref===B.yref?Z.y:c.constrain(Z.y-B.ay,1,_.height-1)),Z.x=c.constrain(Z.x,1,_.width-1),Z.y=c.constrain(Z.y,1,_.height-1);var M=W-l.top,A=W-l.left;a?r.select("svg").attr({x:W-1,y:W}):(tt.attr({x:A,y:M}),tt.selectAll("tspan.line").attr({y:M,x:A})),J.call(d.setRect,$/2,$/2,y-$,x-$);var T=0,L=0;T=B.axref===B.xref?Math.round(Z.aax-y/2):Math.round(Z.x-y/2),L=B.ayref===B.yref?Math.round(Z.aay-x/2):Math.round(Z.y-x/2),G.call(c.setTranslate,T,L);var z="annotations["+e+"]",C=function(n,r){i.select(t).selectAll('.annotation-arrow-g[data-index="'+e+'"]').remove();var a,l;a=B.axref===B.xref?Z.aax+n:Z.x+n,l=B.ayref===B.yref?Z.aay+r:Z.y+r;var u=c.rotationXYMatrix(Y,a,l),d=c.apply2DTransform(u),h=c.apply2DTransform2(u),p=J.attr("width")/2,m=J.attr("height")/2,y=[[a-p,l-m,a-p,l+m],[a-p,l+m,a+p,l+m],[a+p,l+m,a+p,l-m],[a+p,l-m,a-p,l-m]].map(h);if(!y.reduce(function(t,e){return t^!!o(w,k,w+1e6,k+1e6,e[0],e[1],e[2],e[3])},!1)){y.forEach(function(t){var e=o(a,l,w,k,t[0],t[1],t[2],t[3]);e&&(a=e.x,l=e.y)});var x=B.arrowwidth,b=B.arrowcolor,_=U.append("g").style({opacity:f.opacity(b)}).classed("annotation-arrow-g",!0).attr("data-index",String(e)),M=_.append("path").attr("d","M"+a+","+l+"L"+w+","+k).style("stroke-width",x+"px").call(f.stroke,f.rgb(b));v.arrowhead(M,B.arrowhead,"end",B.arrowsize);var A=_.append("path").classed("annotation",!0).classed("anndrag",!0).attr({"data-index":String(e),d:"M3,3H-3V-3H3ZM0,0L"+(a-w)+","+(l-k),transform:"translate("+w+","+k+")"}).style("stroke-width",x+6+"px").call(f.stroke,"rgba(0,0,0,0)").call(f.fill,"rgba(0,0,0,0)");if(t._context.editable){var T,L,C;g.init({element:A.node(),prepFn:function(){var t=c.getTranslate(G);L=t.x,C=t.y,T={},H&&H.autorange&&(T[H._name+".autorange"]=!0),V&&V.autorange&&(T[V._name+".autorange"]=!0)},moveFn:function(t,e){_.attr("transform","translate("+t+","+e+")");var n=d(L,C),r=n[0]+t,a=n[1]+e;G.call(c.setTranslate,r,a),T[z+".x"]=H?B.x+t/H._m:(w+t-S.l)/S.w,T[z+".y"]=V?B.y+e/V._m:1-(k+e-S.t)/S.h,B.axref===B.xref&&(T[z+".ax"]=H?B.ax+t/H._m:(w+t-S.l)/S.w),B.ayref===B.yref&&(T[z+".ay"]=V?B.ay+e/V._m:1-(k+e-S.t)/S.h),X.attr({transform:"rotate("+Y+","+r+","+a+")"})},doneFn:function(e){if(e){s.relayout(t,T);var n=document.querySelector(".js-notes-box-panel");n&&n.redraw(n.selectedObj)}}})}}};B.showarrow&&C(0,0);var E=c.rotationXYMatrix(Y,Z.x,Z.y),O=c.apply2DTransform(E);if(t._context.editable){var N,P,D;g.init({element:G.node(),prepFn:function(){var t=c.getTranslate(G);N=t.x,P=t.y,D={}},moveFn:function(t,e){G.call(c.setTranslate,N+t,P+e);var n="pointer";if(B.showarrow)B.axref===B.xref?D[z+".ax"]=H.p2l(H.l2p(B.ax)+t):D[z+".ax"]=B.ax+t,B.ayref===B.yref?D[z+".ay"]=V.p2l(V.l2p(B.ay)+e):D[z+".ay"]=B.ay+e,C(t,e);else{if(H)D[z+".x"]=B.x+t/H._m;else{var r=B._xsize/S.w,a=B.x+B._xshift/S.w-r/2;D[z+".x"]=g.align(a+t/S.w,r,0,1,B.xanchor)}if(V)D[z+".y"]=B.y+e/V._m;else{var o=B._ysize/S.h,i=B.y-B._yshift/S.h-o/2;D[z+".y"]=g.align(i-e/S.h,o,0,1,B.yanchor)}H&&V||(n=g.getCursor(H?.5:D[z+".x"],V?.5:D[z+".y"],B.xanchor,B.yanchor))}var l=O(N,P),s=l[0]+t,u=l[1]+e;G.call(c.setTranslate,N+t,P+e),X.attr({transform:"rotate("+Y+","+s+","+u+")"}),p(G,n)},doneFn:function(e){if(p(G),e){s.relayout(t,D);var n=document.querySelector(".js-notes-box-panel");n&&n.redraw(n.selectedObj)}}})}}var x,b=t.layout,_=t._fullLayout;if(!l(e)||e===-1){if(!e&&Array.isArray(a))return b.annotations=a,v.supplyLayoutDefaults(b,_),void v.drawAll(t);if("remove"===a)return delete b.annotations,_.annotations=[],void v.drawAll(t);if(n&&"add"!==a){for(x=0;x<_.annotations.length;x++)v.draw(t,x,n,a);return}e=_.annotations.length,_.annotations.push({})}if(!n&&a){if("remove"===a){for(_._infolayer.selectAll('.annotation[data-index="'+e+'"]').remove(),_.annotations.splice(e,1),b.annotations.splice(e,1),x=e;x<_.annotations.length;x++)_._infolayer.selectAll('.annotation[data-index="'+(x+1)+'"]').attr("data-index",String(x)),v.draw(t,x);return}if("add"===a||c.isPlainObject(a)){_.annotations.splice(e,0,{});var w=c.isPlainObject(a)?c.extendFlat({},a):{text:"New text"};for(b.annotations?b.annotations.splice(e,0,w):b.annotations=[w],x=_.annotations.length-1;x>e;x--)_._infolayer.selectAll('.annotation[data-index="'+(x-1)+'"]').attr("data-index",String(x)),v.draw(t,x)}}_._infolayer.selectAll('.annotation[data-index="'+e+'"]').remove();var k=b.annotations[e],M=_.annotations[e];if(k){var A={xref:k.xref,yref:k.yref},T={};"string"==typeof n&&n?T[n]=a:c.isPlainObject(n)&&(T=n);var L=Object.keys(T);for(x=0;x4/3&&(P=F)}}else N&&(I&&(P<1/3?P+=j:P>2/3&&(P-=j)),P=(P-N.domain[0])/(N.domain[1]-N.domain[0]),P=N.range[0]+P*(N.range[1]-N.range[0]))}N&&N===O&&D&&("log"===D&&"log"!==N.type?P=Math.pow(10,P):"log"!==D&&"log"===N.type&&(P=P>0?Math.log(P)/Math.LN10:void 0)),k[E]=P}}var B=r(k,_);_.annotations[e]=B;var H=u.getFromId(t,B.xref),V=u.getFromId(t,B.yref),Z={x:0,y:0},Y=+B.textangle||0,U=_._infolayer.append("g").classed("annotation",!0).attr("data-index",String(e)).style("opacity",B.opacity).on("click",function(){t._dragging=!1,t.emit("plotly_clickannotation",{index:e,annotation:k,fullAnnotation:B})}),X=U.append("g").classed("annotation-text-g",!0).attr("data-index",String(e)),G=X.append("g"),$=B.borderwidth,Q=B.borderpad,W=$+Q,J=G.append("rect").attr("class","bg").style("stroke-width",$+"px").call(f.stroke,B.bordercolor).call(f.fill,B.bgcolor),K=B.font,tt=G.append("text").classed("annotation",!0).attr("data-unformatted",B.text).text(B.text);t._context.editable?tt.call(h.makeEditable,G).call(m).on("edit",function(n){B.text=n,this.attr({"data-unformatted":B.text}),this.call(m);var r={};r["annotations["+e+"].text"]=B.text,H&&H.autorange&&(r[H._name+".autorange"]=!0),V&&V.autorange&&(r[V._name+".autorange"]=!0),s.relayout(t,r)}):tt.call(m),X.attr({transform:"rotate("+Y+","+Z.x+","+Z.y+")"}).call(d.setPosition,Z.x,Z.y)}},v.arrowhead=function(t,e,n,r){l(r)||(r=1);var a=t.node(),o=v.ARROWPATHS[e||0];if(o){"string"==typeof n&&n||(n="end");var s,c,u,h,p=(d.getPx(t,"stroke-width")||1)*r,g=t.style("stroke")||f.defaultLine,m=t.style("stroke-opacity")||1,y=n.indexOf("start")>=0,x=n.indexOf("end")>=0,b=o.backoff*p;if("line"===a.nodeName){if(s={x:+t.attr("x1"),y:+t.attr("y1")},c={x:+t.attr("x2"),y:+t.attr("y2")},u=Math.atan2(s.y-c.y,s.x-c.x),h=u+Math.PI,b){var _=b*Math.cos(u),w=b*Math.sin(u);y&&(s.x-=_,s.y-=w,t.attr({x1:s.x,y1:s.y})),x&&(c.x+=_,c.y+=w,t.attr({x2:c.x,y2:c.y}))}}else if("path"===a.nodeName){var k=a.getTotalLength(),M="";if(y){var A=a.getPointAtLength(0),T=a.getPointAtLength(.1);u=Math.atan2(A.y-T.y,A.x-T.x),s=a.getPointAtLength(Math.min(b,k)),b&&(M="0px,"+b+"px,")}if(x){var L=a.getPointAtLength(k),z=a.getPointAtLength(k-.1);if(h=Math.atan2(L.y-z.y,L.x-z.x),c=a.getPointAtLength(Math.max(0,k-b)),b){var S=M?2*b:b;M+=k-S+"px,"+k+"px"}}else M&&(M+=k+"px");M&&t.style("stroke-dasharray",M)}var C=function(n,r){e>5&&(r=0),i.select(a.parentElement).append("path").attr({class:t.attr("class"),d:o.path,transform:"translate("+n.x+","+n.y+")rotate("+180*r/Math.PI+")scale("+p+")"}).style({fill:g,opacity:m,"stroke-width":0})};y&&C(s,u),x&&C(c,h)}},v.calcAutorange=function(t){var e=t._fullLayout,n=e.annotations;if(n.length&&t._fullData.length){var r={};n.forEach(function(t){r[t.xref]=!0,r[t.yref]=!0});var o=u.list(t).filter(function(t){return t.autorange&&r[t._id]});if(o.length)return c.syncOrAsync([v.drawAll,a],t)}}},{"../../lib":94,"../../lib/setcursor":103,"../../lib/svg_text_utils":105,"../../plotly":112,"../../plots/cartesian/axes":115,"../color":18,"../dragelement":39,"../drawing":41,"./arrow_paths":14,"./attributes":15,d3:7,"fast-isnumeric":10}],17:[function(t,e,n){"use strict";n.defaults=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],n.defaultLine="#444",n.lightLine="#eee",n.background="#fff",n.borderLine="#BEC8D9",n.lightFraction=1e3/11},{}],18:[function(t,e,n){"use strict";function r(t){if(o(t)||"string"!=typeof t)return t;var e=t.trim();if("rgb"!==e.substr(0,3))return t;var n=e.match(/^rgba?\s*\(([^()]*)\)$/);if(!n)return t;var r=n[1].trim().split(/\s*[\s,]\s*/),a="a"===e.charAt(3)&&4===r.length;if(!a&&3!==r.length)return t;for(var i=0;i=0))return t;if(3===i)r[i]>1&&(r[i]=1);else if(r[i]>=1)return t}var l=Math.round(255*r[0])+", "+Math.round(255*r[1])+", "+Math.round(255*r[2]);return a?"rgba("+l+", "+r[3]+")":"rgb("+l+")"}var a=t("tinycolor2"),o=t("fast-isnumeric"),i=e.exports={},l=t("./attributes");i.defaults=l.defaults,i.defaultLine=l.defaultLine,i.lightLine=l.lightLine,i.background=l.background,i.tinyRGB=function(t){var e=t.toRgb();return"rgb("+Math.round(e.r)+", "+Math.round(e.g)+", "+Math.round(e.b)+")"},i.rgb=function(t){return i.tinyRGB(a(t))},i.opacity=function(t){return t?a(t).getAlpha():0},i.addOpacity=function(t,e){var n=a(t).toRgb();return"rgba("+Math.round(n.r)+", "+Math.round(n.g)+", "+Math.round(n.b)+", "+e+")"},i.combine=function(t,e){var n=a(t).toRgb();if(1===n.a)return a(t).toRgbString();var r=a(e||i.background).toRgb(),o=1===r.a?r:{r:255*(1-r.a)+r.r*r.a,g:255*(1-r.a)+r.g*r.a,b:255*(1-r.a)+r.b*r.a},l={r:o.r*(1-n.a)+n.r*n.a,g:o.g*(1-n.a)+n.g*n.a,b:o.b*(1-n.a)+n.b*n.a};return a(l).toRgbString()},i.contrast=function(t,e,n){var r=a(t),o=r.isLight()?r.darken(n):r.lighten(e);return o.toString()},i.stroke=function(t,e){var n=a(e);t.style({stroke:i.tinyRGB(n),"stroke-opacity":n.getAlpha()})},i.fill=function(t,e){var n=a(e);t.style({fill:i.tinyRGB(n),"fill-opacity":n.getAlpha()})},i.clean=function(t){if(t&&"object"==typeof t){var e,n,a,o,l=Object.keys(t);for(e=0;es&&(o[1]-=(it-s)/2)):n.node()&&!n.classed("js-placeholder")&&(it=d.bBox(e.node()).height),it){if(it+=5,"top"===b.titleside)J.domain[1]-=it/A.h,o[1]*=-1;else{J.domain[0]+=it/A.h;var u=Math.max(1,n.selectAll("tspan.line").size());o[1]+=(1-u)*s}e.attr("transform","translate("+o+")"),J.setScale()}}at.selectAll(".cbfills,.cblines,.cbaxis").attr("transform","translate(0,"+Math.round(A.h*(1-J.domain[1]))+")");var f=at.select(".cbfills").selectAll("rect.cbfill").data(S);f.enter().append("rect").classed("cbfill",!0).style("stroke","none"),f.exit().remove(),f.each(function(t,e){var n=[0===e?L[0]:(S[e]+S[e-1])/2,e===S.length-1?L[1]:(S[e]+S[e+1])/2].map(J.c2p).map(Math.round);e!==S.length-1&&(n[1]+=n[1]>n[0]?1:-1);var o=E(t).replace("e-",""),i=a(o).toHexString();r.select(this).attr({x:U,width:Math.max(F,2),y:r.min(n),height:Math.max(r.max(n)-r.min(n),2),fill:i})});var h=at.select(".cblines").selectAll("path.cbline").data(b.line.color&&b.line.width?z:[]);return h.enter().append("path").classed("cbline",!0),h.exit().remove(),h.each(function(t){r.select(this).attr("d","M"+U+","+(Math.round(J.c2p(t))+b.line.width/2%1)+"h"+F).call(d.lineGroupStyle,b.line.width,C(t),b.line.dash)}),J._axislayer.selectAll("g."+J._id+"tick,path").remove(),J._pos=U+F+(b.outlinewidth||0)/2-("outside"===b.ticks?1:0),J.side="right",c.syncOrAsync([function(){return l.doTicks(t,J,!0)},function(){if(["top","bottom"].indexOf(b.titleside)===-1){var e=J.titlefont.size,n=J._offset+J._length/2,a=A.l+(J.position||0)*A.w+("right"===J.side?10+e*(J.showticklabels?1:.5):-10-e*(J.showticklabels?.5:0));w("h"+J._id+"title",{avoid:{selection:r.select(t).selectAll("g."+J._id+"tick"),side:b.titleside,offsetLeft:A.l,offsetTop:A.t,maxShift:M.width},attributes:{x:a,y:n,"text-anchor":"middle"},transform:{rotate:"-90",offset:0}})}}])}function w(e,n){var r,a=x();r=i.traceIs(a,"markerColorscale")?"marker.colorbar.title":"colorbar.title";var o={propContainer:J,propName:r,traceIndex:a.index,dfltName:"colorscale",containerGroup:at.select(".cbtitle")},l="h"===e.charAt(0)?e.substr(1):"h"+e;at.selectAll("."+l+",."+l+"-math-group").remove(),p.draw(t,e,u(o,n||{}))}function k(){var n=F+b.outlinewidth/2+d.bBox(J._axislayer.node()).width;if(I=ot.select("text"),I.node()&&!I.classed("js-placeholder")){var r,a=ot.select(".h"+J._id+"title-math-group").node();r=a&&["top","bottom"].indexOf(b.titleside)!==-1?d.bBox(a).width:d.bBox(ot.node()).right-U-A.l,n=Math.max(n,r)}var o=2*b.xpad+n+b.borderwidth+b.outlinewidth/2,l=$-Q;at.select(".cbbg").attr({x:U-b.xpad-(b.borderwidth+b.outlinewidth)/2,y:Q-Z,width:Math.max(o,2),height:Math.max(l+2*Z,2)}).call(h.fill,b.bgcolor).call(h.stroke,b.bordercolor).style({"stroke-width":b.borderwidth}),at.selectAll(".cboutline").attr({x:U,y:Q+b.ypad+("top"===b.titleside?it:0),width:Math.max(F,2),height:Math.max(l-2*b.ypad-it,2)}).call(h.stroke,b.outlinecolor).style({fill:"None","stroke-width":b.outlinewidth});var s=({center:.5,right:1}[b.xanchor]||0)*o;at.attr("transform","translate("+(A.l-s)+","+A.t+")"),i.autoMargin(t,e,{x:b.x,y:b.y,l:o*({right:1,center:.5}[b.xanchor]||0),r:o*({left:1,center:.5}[b.xanchor]||0),t:l*({bottom:1,middle:.5}[b.yanchor]||0),b:l*({top:1,middle:.5}[b.yanchor]||0)})}var M=t._fullLayout,A=M._size;if("function"!=typeof b.fillcolor&&"function"!=typeof b.line.color)return void M._infolayer.selectAll("g."+e).remove();var T,L=r.extent(("function"==typeof b.fillcolor?b.fillcolor:b.line.color).domain()),z=[],S=[],C="function"==typeof b.line.color?b.line.color:function(){return b.line.color},E="function"==typeof b.fillcolor?b.fillcolor:function(){return b.fillcolor},O=b.levels.end+b.levels.size/100,N=b.levels.size,P=1.001*L[0]-.001*L[1],D=1.001*L[1]-.001*L[0];for(T=b.levels.start;(T-O)*N<0;T+=N)T>P&&TL[0]&&T1){var rt=Math.pow(10,Math.floor(Math.log(nt)/Math.LN10));tt*=rt*c.roundUp(nt/rt,[2,5,10]),(Math.abs(b.levels.start)/b.levels.size+1e-6)%1<2e-6&&(J.tick0=0)}J.dtick=tt}J.domain=[G+Y,G+H-Y],J.setScale();var at=M._infolayer.selectAll("g."+e).data([0]);at.enter().append("g").classed(e,!0).each(function(){var t=r.select(this);t.append("rect").classed("cbbg",!0),t.append("g").classed("cbfills",!0),t.append("g").classed("cblines",!0),t.append("g").classed("cbaxis",!0).classed("crisp",!0),t.append("g").classed("cbtitleunshift",!0).append("g").classed("cbtitle",!0),t.append("rect").classed("cboutline",!0),t.select(".cbtitle").datum(0)}),at.attr("transform","translate("+Math.round(A.l)+","+Math.round(A.t)+")");var ot=at.select(".cbtitleunshift").attr("transform","translate(-"+Math.round(A.l)+",-"+Math.round(A.t)+")");J._axislayer=at.select(".cbaxis");var it=0;if(["top","bottom"].indexOf(b.titleside)!==-1){var lt,st=A.l+(b.x+V)*A.w,ct=J.titlefont.size;lt="top"===b.titleside?(1-(G+H-Y))*A.h+A.t+3+.75*ct:(1-(G+Y))*A.h+A.t-3-.25*ct,w(J._id+"title",{attributes:{x:st,y:lt,"text-anchor":"start"}})}var ut=c.syncOrAsync([i.previousPromises,_,i.previousPromises,k],t);if(ut&&ut.then&&(t._promises||[]).push(ut),t._context.editable){var ft,dt,ht;s.init({element:at.node(),prepFn:function(){ft=at.attr("transform"),f(at)},moveFn:function(t,e){at.attr("transform",ft+" translate("+t+","+e+")"),dt=s.align(X+t/A.w,q,0,1,b.xanchor),ht=s.align(G-e/A.h,H,0,1,b.yanchor);var n=s.getCursor(dt,ht,b.xanchor,b.yanchor);f(at,n)},doneFn:function(e){f(at),e&&void 0!==dt&&void 0!==ht&&o.restyle(t,{"colorbar.x":dt,"colorbar.y":ht},x().index)}})}return ut}function x(){var n,r,a=e.substr(2);for(n=0;n=0?a.Reds:a.Blues,s.colorscale=d,l.reversescale&&(d=o(d)),l.colorscale=d)}},{"../../lib":94,"./flip_scale":29,"./scales":36}],26:[function(t,e,n){"use strict";var r=t("./attributes"),a=t("../../lib/extend").extendDeep;t("./scales.js");e.exports=function(t){return{color:{valType:"color",arrayOk:!0},colorscale:a({},r.colorscale,{}),cauto:a({},r.zauto,{}),cmax:a({},r.zmax,{}),cmin:a({},r.zmin,{}),autocolorscale:a({},r.autocolorscale,{}),reversescale:a({},r.reversescale,{})}}},{"../../lib/extend":93,"./attributes":24,"./scales.js":36}],27:[function(t,e,n){"use strict";var r=t("./scales");e.exports=r.RdBu},{"./scales":36}],28:[function(t,e,n){"use strict";var r=t("fast-isnumeric"),a=t("../../lib"),o=t("../colorbar/has_colorbar"),i=t("../colorbar/defaults"),l=t("./is_valid_scale"),s=t("./flip_scale");e.exports=function(t,e,n,c,u){var f=u.prefix,d=u.cLetter,h=f.slice(0,f.length-1),p=f?a.nestedProperty(t,h).get()||{}:t,g=f?a.nestedProperty(e,h).get()||{}:e,v=p[d+"min"],m=p[d+"max"],y=p.colorscale,x=r(v)&&r(m)&&v=0;a--,o++)e=t[a],r[o]=[1-e[0],e[1]];return r}},{}],30:[function(t,e,n){"use strict";var r=t("./scales"),a=t("./default_scale"),o=t("./is_valid_scale_array");e.exports=function(t,e){function n(){try{t=r[t]||JSON.parse(t)}catch(n){t=e}}return e||(e=a),t?("string"==typeof t&&(n(),"string"==typeof t&&n()),o(t)?t:e):e}},{"./default_scale":27,"./is_valid_scale_array":34,"./scales":36}],31:[function(t,e,n){"use strict";var r=t("fast-isnumeric"),a=t("../../lib"),o=t("./is_valid_scale");e.exports=function(t,e){var n=e?a.nestedProperty(t,e).get()||{}:t,i=n.color,l=!1;if(Array.isArray(i))for(var s=0;s4/3-l?i:l}},{}],38:[function(t,e,n){"use strict";var r=t("../../lib"),a=[["sw-resize","s-resize","se-resize"],["w-resize","move","e-resize"],["nw-resize","n-resize","ne-resize"]];e.exports=function(t,e,n,o){return t="left"===n?0:"center"===n?1:"right"===n?2:r.constrain(Math.floor(3*t),0,2),e="bottom"===o?0:"middle"===o?1:"top"===o?2:r.constrain(Math.floor(3*e),0,2),a[e][t]}},{"../../lib":94}],39:[function(t,e,n){"use strict";function r(){var t=document.createElement("div");t.className="dragcover";var e=t.style;return e.position="fixed",e.left=0,e.right=0,e.top=0,e.bottom=0,e.zIndex=999999999,e.background="none",document.body.appendChild(t),t}function a(t){t._dragging=!1,t._replotPending&&o.plot(t)}var o=t("../../plotly"),i=t("../../lib"),l=t("../../plots/cartesian/constants"),s=e.exports={};s.align=t("./align"),s.getCursor=t("./cursor");var c=t("./unhover");s.unhover=c.wrapped,s.unhoverRaw=c.raw,s.init=function(t){function e(e){return t.element.onmousemove=p,g._dragged=!1,g._dragging=!0,c=e.clientX,u=e.clientY,h=e.target,f=(new Date).getTime(),f-g._mouseDownTimem&&(v=Math.max(v-1,1)),t.doneFn&&t.doneFn(g._dragged,v),!g._dragged){var n=document.createEvent("MouseEvents");n.initEvent("click",!0,!0),h.dispatchEvent(n)}return a(g),g._dragged=!1,i.pauseEvent(e)}var c,u,f,d,h,p,g=i.getPlotDiv(t.element)||{},v=1,m=l.DBLCLICKDELAY;g._mouseDownTime||(g._mouseDownTime=0),p=t.element.onmousemove,t.setCursor&&(t.element.onmousemove=t.setCursor),t.element.onmousedown=e,t.element.style.pointerEvents="all"}},{"../../lib":94,"../../plotly":112,"../../plots/cartesian/constants":120,"./align":37,"./cursor":38,"./unhover":40}],40:[function(t,e,n){"use strict";var r=t("../../lib/events"),a=e.exports={};a.wrapped=function(t,e,n){"string"==typeof t&&(t=document.getElementById(t)),t._hoverTimer&&(clearTimeout(t._hoverTimer),t._hoverTimer=void 0),a.raw(t,e,n)},a.raw=function(t,e){var n=t._fullLayout;e||(e={}),e.target&&r.triggerHandler(t,"plotly_beforehover",e)===!1||(n._hoverlayer.selectAll("g").remove(),e.target&&t._hoverdata&&t.emit("plotly_unhover",{points:t._hoverdata}),t._hoverdata=void 0)}},{"../../lib/events":92}],41:[function(t,e,n){"use strict";function r(t,e,n,r){var o=t[0]-e[0],i=t[1]-e[1],l=n[0]-e[0],s=n[1]-e[1],c=Math.pow(o*o+i*i,b/2),u=Math.pow(l*l+s*s,b/2),f=(u*u*o-c*c*l)*r,d=(u*u*i-c*c*s)*r,h=3*u*(c+u),p=3*c*(c+u);return[[a.round(e[0]+(h&&f/h),2),a.round(e[1]+(h&&d/h),2)],[a.round(e[0]-(p&&f/p),2),a.round(e[1]-(p&&d/p),2)]]}var a=t("d3"),o=t("fast-isnumeric"),i=t("../../plots/plots"),l=t("../color"),s=t("../colorscale"),c=t("../../lib"),u=t("../../lib/svg_text_utils"),f=t("../../constants/xmlns_namespaces"),d=t("../../traces/scatter/subtypes"),h=t("../../traces/scatter/make_bubble_size_func"),p=e.exports={};p.font=function(t,e,n,r){e&&e.family&&(r=e.color,n=e.size,e=e.family),e&&t.style("font-family",e),n+1&&t.style("font-size",n+"px"),r&&t.call(l.fill,r)},p.setPosition=function(t,e,n){t.attr("x",e).attr("y",n)},p.setSize=function(t,e,n){t.attr("width",e).attr("height",n)},p.setRect=function(t,e,n,r,a){t.call(p.setPosition,e,n).call(p.setSize,r,a)},p.translatePoints=function(t,e,n){t.each(function(t){var r=t.xp||e.c2p(t.x),i=t.yp||n.c2p(t.y),l=a.select(this);o(r)&&o(i)?"text"===this.nodeName?l.attr("x",r).attr("y",i):l.attr("transform","translate("+r+","+i+")"):l.remove()})},p.getPx=function(t,e){return Number(t.style(e).replace(/px$/,""))},p.crispRound=function(t,e,n){return e&&o(e)?t._context.staticPlot?e:e<1?1:Math.round(e):n||0},p.lineGroupStyle=function(t,e,n,r){t.style("fill","none").each(function(t){var o=(((t||[])[0]||{}).trace||{}).line||{},i=e||o.width||0,s=r||o.dash||"";a.select(this).call(l.stroke,n||o.color).call(p.dashLine,s,i)})},p.dashLine=function(t,e,n){var r=Math.max(n,3);"solid"===e?e="":"dot"===e?e=r+"px,"+r+"px":"dash"===e?e=3*r+"px,"+3*r+"px":"longdash"===e?e=5*r+"px,"+5*r+"px":"dashdot"===e?e=3*r+"px,"+r+"px,"+r+"px,"+r+"px":"longdashdot"===e&&(e=5*r+"px,"+2*r+"px,"+r+"px,"+2*r+"px"),t.style({"stroke-dasharray":e,"stroke-width":n+"px"})},p.fillGroupStyle=function(t){t.style("stroke-width",0).each(function(e){var n=a.select(this);try{n.call(l.fill,e[0].trace.fillcolor)}catch(e){c.error(e,t),n.remove()}})};var g=t("./symbol_defs");p.symbolNames=[],p.symbolFuncs=[],p.symbolNeedLines={},p.symbolNoDot={},p.symbolList=[],Object.keys(g).forEach(function(t){var e=g[t];p.symbolList=p.symbolList.concat([e.n,t,e.n+100,t+"-open"]),p.symbolNames[e.n]=t,p.symbolFuncs[e.n]=e.f,e.needLine&&(p.symbolNeedLines[e.n]=!0),e.noDot?p.symbolNoDot[e.n]=!0:p.symbolList=p.symbolList.concat([e.n+200,t+"-dot",e.n+300,t+"-open-dot"])});var v=p.symbolNames.length,m="M0,0.5L0.5,0L0,-0.5L-0.5,0Z";p.symbolNumber=function(t){if("string"==typeof t){var e=0;t.indexOf("-open")>0&&(e=100,t=t.replace("-open","")),t.indexOf("-dot")>0&&(e+=200,t=t.replace("-dot","")),t=p.symbolNames.indexOf(t),t>=0&&(t+=e)}return t%100>=v||t>=400?0:Math.floor(Math.max(t,0))},p.pointStyle=function(t,e){if(t.size()){var n=e.marker,r=n.line;if(i.traceIs(e,"symbols")){var o=h(e);t.attr("d",function(t){var r;r="various"===t.ms||"various"===n.size?3:d.isBubble(e)?o(t.ms):(n.size||6)/2,t.mrc=r;var a=p.symbolNumber(t.mx||n.symbol)||0,i=a%100;return t.om=a%200>=100,p.symbolFuncs[i](r)+(a>=200?m:"")}).style("opacity",function(t){return(t.mo+1||n.opacity+1)-1})}var s=(e._input||{}).marker||{},c=p.tryColorscale(n,s,""),u=p.tryColorscale(n,s,"line.");t.each(function(t){var e,o,i;t.so?(i=r.outlierwidth,o=r.outliercolor,e=n.outliercolor):(i=(t.mlw+1||r.width+1||(t.trace?t.trace.marker.line.width:0)+1)-1,o="mlc"in t?t.mlcc=u(t.mlc):Array.isArray(r.color)?l.defaultLine:r.color,e="mc"in t?t.mcc=c(t.mc):Array.isArray(n.color)?l.defaultLine:n.color||"rgba(0,0,0,0)");var s=a.select(this);t.om?s.call(l.stroke,e).style({"stroke-width":(i||1)+"px",fill:"none"}):(s.style("stroke-width",i+"px").call(l.fill,e),i&&s.call(l.stroke,o))})}},p.tryColorscale=function(t,e,n){var r=c.nestedProperty(t,n+"color").get(),a=c.nestedProperty(t,n+"colorscale").get(),i=c.nestedProperty(t,n+"cauto").get(),l=c.nestedProperty(t,n+"cmin"),u=c.nestedProperty(t,n+"cmax"),f=l.get(),d=u.get();return a&&Array.isArray(r)?(!i&&o(f)&&o(d)||(f=1/0,d=-(1/0),r.forEach(function(t){o(t)&&(f>t&&(f=+t),dd&&(f=0,d=1),l.set(f),u.set(d),c.nestedProperty(e,n+"cmin").set(f),c.nestedProperty(e,n+"cmax").set(d)),s.makeScaleFunction(a,f,d)):c.identity};var y={start:1,end:-1,middle:0,bottom:1,top:-1},x=1.3;p.textPointStyle=function(t,e){t.each(function(t){var n=a.select(this),r=t.tx||e.text;if(!r||Array.isArray(r))return void n.remove();var i=t.tp||e.textposition,l=i.indexOf("top")!==-1?"top":i.indexOf("bottom")!==-1?"bottom":"middle",s=i.indexOf("left")!==-1?"end":i.indexOf("right")!==-1?"start":"middle",c=t.ts||e.textfont.size,f=t.mrc?t.mrc/.8+1:0;c=o(c)&&c>0?c:0,n.call(p.font,t.tf||e.textfont.family,c,t.tc||e.textfont.color).attr("text-anchor",s).text(r).call(u.convertToTspans);var d=a.select(this.parentNode),h=n.selectAll("tspan.line"),g=((h[0].length||1)-1)*x+1,v=y[s]*f,m=.75*c+y[l]*f+(y[l]-1)*g*c/2;d.attr("transform","translate("+v+","+m+")"),g>1&&h.attr({x:n.attr("x"),y:n.attr("y")})})};var b=.5;p.smoothopen=function(t,e){if(t.length<3)return"M"+t.join("L");var n,a="M"+t[0],o=[];for(n=1;n=M&&(a.selectAll("[data-bb]").attr("data-bb",null),k=[]),t.setAttribute("data-bb",k.length),k.push(s),c.extendFlat({},s)},p.setClipUrl=function(t,e){if(!e)return void t.attr("clip-path",null);var n="#"+e,r=a.select("base");r.size()&&r.attr("href")&&(n=window.location.href+n),t.attr("clip-path","url("+n+")")}},{"../../constants/xmlns_namespaces":87,"../../lib":94,"../../lib/svg_text_utils":105,"../../plots/plots":135,"../../traces/scatter/make_bubble_size_func":186,"../../traces/scatter/subtypes":191,"../color":18,"../colorscale":32,"./symbol_defs":42,d3:7,"fast-isnumeric":10}],42:[function(t,e,n){"use strict";var r=t("d3");e.exports={circle:{n:0,f:function(t){var e=r.round(t,2);return"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"}},square:{n:1,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"}},diamond:{n:2,f:function(t){var e=r.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"Z"}},cross:{n:3,f:function(t){var e=r.round(.4*t,2),n=r.round(1.2*t,2);return"M"+n+","+e+"H"+e+"V"+n+"H-"+e+"V"+e+"H-"+n+"V-"+e+"H-"+e+"V-"+n+"H"+e+"V-"+e+"H"+n+"Z"}},x:{n:4,f:function(t){var e=r.round(.8*t/Math.sqrt(2),2),n="l"+e+","+e,a="l"+e+",-"+e,o="l-"+e+",-"+e,i="l-"+e+","+e;return"M0,"+e+n+a+o+a+o+i+o+i+n+i+n+"Z"}},"triangle-up":{n:5,f:function(t){var e=r.round(2*t/Math.sqrt(3),2),n=r.round(t/2,2),a=r.round(t,2);return"M-"+e+","+n+"H"+e+"L0,-"+a+"Z"}},"triangle-down":{n:6,f:function(t){var e=r.round(2*t/Math.sqrt(3),2),n=r.round(t/2,2),a=r.round(t,2);return"M-"+e+",-"+n+"H"+e+"L0,"+a+"Z"}},"triangle-left":{n:7,f:function(t){var e=r.round(2*t/Math.sqrt(3),2),n=r.round(t/2,2),a=r.round(t,2);return"M"+n+",-"+e+"V"+e+"L-"+a+",0Z"}},"triangle-right":{n:8,f:function(t){var e=r.round(2*t/Math.sqrt(3),2),n=r.round(t/2,2),a=r.round(t,2);return"M-"+n+",-"+e+"V"+e+"L"+a+",0Z"}},"triangle-ne":{n:9,f:function(t){var e=r.round(.6*t,2),n=r.round(1.2*t,2);return"M-"+n+",-"+e+"H"+e+"V"+n+"Z"}},"triangle-se":{n:10,f:function(t){var e=r.round(.6*t,2),n=r.round(1.2*t,2);return"M"+e+",-"+n+"V"+e+"H-"+n+"Z"}},"triangle-sw":{n:11,f:function(t){var e=r.round(.6*t,2),n=r.round(1.2*t,2);return"M"+n+","+e+"H-"+e+"V-"+n+"Z"}},"triangle-nw":{n:12,f:function(t){var e=r.round(.6*t,2),n=r.round(1.2*t,2);return"M-"+e+","+n+"V-"+e+"H"+n+"Z"}},pentagon:{n:13,f:function(t){var e=r.round(.951*t,2),n=r.round(.588*t,2),a=r.round(-t,2),o=r.round(t*-.309,2),i=r.round(.809*t,2);return"M"+e+","+o+"L"+n+","+i+"H-"+n+"L-"+e+","+o+"L0,"+a+"Z"}},hexagon:{n:14,f:function(t){var e=r.round(t,2),n=r.round(t/2,2),a=r.round(t*Math.sqrt(3)/2,2);return"M"+a+",-"+n+"V"+n+"L0,"+e+"L-"+a+","+n+"V-"+n+"L0,-"+e+"Z"}},hexagon2:{n:15,f:function(t){var e=r.round(t,2),n=r.round(t/2,2),a=r.round(t*Math.sqrt(3)/2,2);return"M-"+n+","+a+"H"+n+"L"+e+",0L"+n+",-"+a+"H-"+n+"L-"+e+",0Z"}},octagon:{n:16,f:function(t){var e=r.round(.924*t,2),n=r.round(.383*t,2);return"M-"+n+",-"+e+"H"+n+"L"+e+",-"+n+"V"+n+"L"+n+","+e+"H-"+n+"L-"+e+","+n+"V-"+n+"Z"}},star:{n:17,f:function(t){var e=1.4*t,n=r.round(.225*e,2),a=r.round(.951*e,2),o=r.round(.363*e,2),i=r.round(.588*e,2),l=r.round(-e,2),s=r.round(e*-.309,2),c=r.round(.118*e,2),u=r.round(.809*e,2),f=r.round(.382*e,2);return"M"+n+","+s+"H"+a+"L"+o+","+c+"L"+i+","+u+"L0,"+f+"L-"+i+","+u+"L-"+o+","+c+"L-"+a+","+s+"H-"+n+"L0,"+l+"Z"}},hexagram:{n:18,f:function(t){var e=r.round(.66*t,2),n=r.round(.38*t,2),a=r.round(.76*t,2);return"M-"+a+",0l-"+n+",-"+e+"h"+a+"l"+n+",-"+e+"l"+n+","+e+"h"+a+"l-"+n+","+e+"l"+n+","+e+"h-"+a+"l-"+n+","+e+"l-"+n+",-"+e+"h-"+a+"Z"}},"star-triangle-up":{n:19,f:function(t){var e=r.round(t*Math.sqrt(3)*.8,2),n=r.round(.8*t,2),a=r.round(1.6*t,2),o=r.round(4*t,2),i="A "+o+","+o+" 0 0 1 ";return"M-"+e+","+n+i+e+","+n+i+"0,-"+a+i+"-"+e+","+n+"Z"}},"star-triangle-down":{n:20,f:function(t){var e=r.round(t*Math.sqrt(3)*.8,2),n=r.round(.8*t,2),a=r.round(1.6*t,2),o=r.round(4*t,2),i="A "+o+","+o+" 0 0 1 ";return"M"+e+",-"+n+i+"-"+e+",-"+n+i+"0,"+a+i+e+",-"+n+"Z"}},"star-square":{n:21,f:function(t){var e=r.round(1.1*t,2),n=r.round(2*t,2),a="A "+n+","+n+" 0 0 1 ";return"M-"+e+",-"+e+a+"-"+e+","+e+a+e+","+e+a+e+",-"+e+a+"-"+e+",-"+e+"Z"}},"star-diamond":{n:22,f:function(t){var e=r.round(1.4*t,2),n=r.round(1.9*t,2),a="A "+n+","+n+" 0 0 1 ";return"M-"+e+",0"+a+"0,"+e+a+e+",0"+a+"0,-"+e+a+"-"+e+",0Z"}},"diamond-tall":{n:23,f:function(t){var e=r.round(.7*t,2),n=r.round(1.4*t,2);return"M0,"+n+"L"+e+",0L0,-"+n+"L-"+e+",0Z"}},"diamond-wide":{n:24,f:function(t){var e=r.round(1.4*t,2),n=r.round(.7*t,2);return"M0,"+n+"L"+e+",0L0,-"+n+"L-"+e+",0Z"}},hourglass:{n:25,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"H-"+e+"L"+e+",-"+e+"H-"+e+"Z"},noDot:!0},bowtie:{n:26,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"V-"+e+"L-"+e+","+e+"V-"+e+"Z"},noDot:!0},"circle-cross":{n:27,f:function(t){var e=r.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"circle-x":{n:28,f:function(t){var e=r.round(t,2),n=r.round(t/Math.sqrt(2),2);return"M"+n+","+n+"L-"+n+",-"+n+"M"+n+",-"+n+"L-"+n+","+n+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"square-cross":{n:29,f:function(t){var e=r.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"square-x":{n:30,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"diamond-cross":{n:31,f:function(t){var e=r.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM0,-"+e+"V"+e+"M-"+e+",0H"+e},needLine:!0,noDot:!0},"diamond-x":{n:32,f:function(t){var e=r.round(1.3*t,2),n=r.round(.65*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM-"+n+",-"+n+"L"+n+","+n+"M-"+n+","+n+"L"+n+",-"+n},needLine:!0,noDot:!0},"cross-thin":{n:33,f:function(t){var e=r.round(1.4*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e},needLine:!0,noDot:!0},"x-thin":{n:34,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0},asterisk:{n:35,f:function(t){var e=r.round(1.2*t,2),n=r.round(.85*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+n+","+n+"L-"+n+",-"+n+"M"+n+",-"+n+"L-"+n+","+n},needLine:!0,noDot:!0},hash:{n:36,f:function(t){var e=r.round(t/2,2),n=r.round(t,2);return"M"+e+","+n+"V-"+n+"m-"+n+",0V"+n+"M"+n+","+e+"H-"+n+"m0,-"+n+"H"+n},needLine:!0},"y-up":{n:37,f:function(t){var e=r.round(1.2*t,2),n=r.round(1.6*t,2),a=r.round(.8*t,2);return"M-"+e+","+a+"L0,0M"+e+","+a+"L0,0M0,-"+n+"L0,0"},needLine:!0,noDot:!0},"y-down":{n:38,f:function(t){var e=r.round(1.2*t,2),n=r.round(1.6*t,2),a=r.round(.8*t,2);return"M-"+e+",-"+a+"L0,0M"+e+",-"+a+"L0,0M0,"+n+"L0,0"},needLine:!0,noDot:!0},"y-left":{n:39,f:function(t){var e=r.round(1.2*t,2),n=r.round(1.6*t,2),a=r.round(.8*t,2);return"M"+a+","+e+"L0,0M"+a+",-"+e+"L0,0M-"+n+",0L0,0"},needLine:!0,noDot:!0},"y-right":{n:40,f:function(t){var e=r.round(1.2*t,2),n=r.round(1.6*t,2),a=r.round(.8*t,2);return"M-"+a+","+e+"L0,0M-"+a+",-"+e+"L0,0M"+n+",0L0,0"},needLine:!0,noDot:!0},"line-ew":{n:41,f:function(t){var e=r.round(1.4*t,2);return"M"+e+",0H-"+e},needLine:!0,noDot:!0},"line-ns":{n:42,f:function(t){var e=r.round(1.4*t,2);return"M0,"+e+"V-"+e},needLine:!0,noDot:!0},"line-ne":{n:43,f:function(t){var e=r.round(t,2);return"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0},"line-nw":{n:44,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e},needLine:!0,noDot:!0}}},{d3:7}],43:[function(t,e,n){"use strict";e.exports={visible:{valType:"boolean"},type:{valType:"enumerated",values:["percent","constant","sqrt","data"]},symmetric:{valType:"boolean"},array:{valType:"data_array"},arrayminus:{valType:"data_array"},value:{valType:"number",min:0,dflt:10},valueminus:{valType:"number",min:0,dflt:10},traceref:{valType:"integer",min:0,dflt:0},tracerefminus:{valType:"integer",min:0,dflt:0},copy_ystyle:{valType:"boolean"},copy_zstyle:{valType:"boolean"},color:{valType:"color"},thickness:{valType:"number",min:0,dflt:2},width:{valType:"number",min:0},_deprecated:{opacity:{valType:"number"}}}},{}],44:[function(t,e,n){"use strict";function r(t,e,n,r){var o=e["error_"+r]||{},s=o.visible&&["linear","log"].indexOf(n.type)!==-1,c=[];if(s){for(var u=l(o),f=0;f0;if(u.visible||c.visible){var d=a.select(this).selectAll("g.errorbar").data(i.identity);d.enter().append("g").classed("errorbar",!0),d.each(function(t){var e=a.select(this),i=r(t,n,s);if(!f||t.vis){var l;if(u.visible&&o(i.x)&&o(i.yh)&&o(i.ys)){var d=u.width;l="M"+(i.x-d)+","+i.yh+"h"+2*d+"m-"+d+",0V"+i.ys,i.noYS||(l+="m-"+d+",0h"+2*d),e.append("path").classed("yerror",!0).attr("d",l)}if(c.visible&&o(i.y)&&o(i.xh)&&o(i.xs)){var h=(c.copy_ystyle?u:c).width;l="M"+i.xh+","+(i.y-h)+"v"+2*h+"m0,-"+h+"H"+i.xs,i.noXS||(l+="m0,-"+h+"v"+2*h),e.append("path").classed("xerror",!0).attr("d",l)}}})}})}},{"../../lib":94,"../../traces/scatter/subtypes":191,d3:7,"fast-isnumeric":10}],49:[function(t,e,n){"use strict";var r=t("d3"),a=t("../color");e.exports=function(t){t.each(function(t){var e=t[0].trace,n=e.error_y||{},o=e.error_x||{},i=r.select(this);i.selectAll("path.yerror").style("stroke-width",n.thickness+"px").call(a.stroke,n.color),o.copy_ystyle&&(o=n),i.selectAll("path.xerror").style("stroke-width",o.thickness+"px").call(a.stroke,o.color)})}},{"../color":18,d3:7}],50:[function(t,e,n){"use strict";var r=t("../../plots/cartesian/constants");e.exports={_isLinkedToArray:!0,source:{valType:"string"},layer:{valType:"enumerated",values:["below","above"],dflt:"above"},sizex:{valType:"number",dflt:0},sizey:{valType:"number",dflt:0},sizing:{valType:"enumerated",values:["fill","contain","stretch"],dflt:"contain"},opacity:{valType:"number",min:0,max:1,dflt:1},x:{valType:"number",dflt:0},y:{valType:"number",dflt:0},xanchor:{valType:"enumerated",values:["left","center","right"],dflt:"left"},yanchor:{valType:"enumerated",values:["top","middle","bottom"],dflt:"top"},xref:{valType:"enumerated",values:["paper",r.idRegex.x.toString()],dflt:"paper"},yref:{valType:"enumerated",values:["paper",r.idRegex.y.toString()],dflt:"paper"}}},{"../../plots/cartesian/constants":120}],51:[function(t,e,n){"use strict";function r(t,e,n){function r(n,r){return o.coerce(t,e,i,n,r)}e=e||{},r("source"),r("layer"),r("x"),r("y"),r("xanchor"),r("yanchor"),r("sizex"),r("sizey"),r("sizing"),r("opacity");for(var l=0;l<2;l++){var s={_fullLayout:n},c=["x","y"][l];a.coerceRef(t,e,s,c,"paper")}return e}var a=t("../../plots/cartesian/axes"),o=t("../../lib"),i=t("./attributes");e.exports=function(t,e){if(t.images&&Array.isArray(t.images))for(var n=t.images,a=e.images=[],o=0;o=2/3},n.isCenterAnchor=function(t){return"center"===t.xanchor||"auto"===t.xanchor&&t.x>1/3&&t.x<2/3},n.isBottomAnchor=function(t){return"bottom"===t.yanchor||"auto"===t.yanchor&&t.y<=1/3},n.isMiddleAnchor=function(t){return"middle"===t.yanchor||"auto"===t.yanchor&&t.y>1/3&&t.y<2/3}},{}],55:[function(t,e,n){"use strict";var r=t("../../plots/font_attributes"),a=t("../color/attributes"),o=t("../../lib/extend").extendFlat;e.exports={bgcolor:{valType:"color"},bordercolor:{valType:"color",dflt:a.defaultLine},borderwidth:{valType:"number",min:0,dflt:0},font:o({},r,{}),orientation:{valType:"enumerated",values:["v","h"],dflt:"v"},horizontalspacing:{valType:"enumerated",values:["column","wrapped"],dflt:["column"]},traceorder:{valType:"flaglist",flags:["reversed","grouped"],extras:["normal"]},tracegroupgap:{valType:"number",min:0,dflt:10},x:{valType:"number",min:-2,max:3,dflt:1.02},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"left"},y:{valType:"number",min:-2,max:3,dflt:1},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto"}}},{"../../lib/extend":93,"../../plots/font_attributes":133,"../color/attributes":17}],56:[function(t,e,n){"use strict";e.exports={scrollBarWidth:4,scrollBarHeight:20,scrollBarColor:"#808BA4",scrollBarMargin:4}},{}],57:[function(t,e,n){"use strict";var r=t("../../lib"),a=t("../../plots/plots"),o=t("./attributes"),i=t("./helpers");e.exports=function(t,e,n){function l(t,e){return r.coerce(d,h,o,t,e)}for(var s,c,u,f,d=t.legend||{},h=e.legend={},p=0,g="normal",v="column",m=0;m1);if(x!==!1){if(l("bgcolor",e.paper_bgcolor),l("bordercolor"),l("borderwidth"),r.coerceFont(l,"font",e.font),l("orientation"),"h"===h.orientation){var b=t.xaxis;b&&b.rangeslider&&b.rangeslider.visible?(s=0,u="left",c=1.1,f="bottom"):(s=0,u="left",c=-.1,f="top")}l("traceorder",g),i.isGrouped(e.legend)&&l("tracegroupgap"),l("x",s),l("xanchor",u),l("y",c),l("yanchor",f),l("horizontalspacing",v),r.noneOrAll(d,h,["x","y"])}}},{"../../lib":94,"../../plots/plots":135,"./attributes":55,"./helpers":60}],58:[function(t,e,n){"use strict";function r(t,e){function n(n){u.util.convertToTspans(n,function(){n.selectAll("tspan.line").attr({x:n.attr("x")}),t.call(o,e)})}var r=t.data()[0][0],a=e._fullLayout,i=r.trace,l=d.traceIs(i,"pie"),s=i.index,c=l?r.label:i.name,f=t.selectAll("text.legendtext").data([0]);f.enter().append("text").classed("legendtext",!0),f.attr({x:40,y:0,"data-unformatted":c}).style("text-anchor","start").classed("user-select-none",!0).call(p.font,a.legend.font).text(c),e._context.editable&&!l?f.call(u.util.makeEditable).call(n).on("edit",function(t){this.attr({"data-unformatted":t}),this.text(t).call(n),this.text()||(t=" "),u.restyle(e,"name",t,s)}):f.call(n)}function a(t,e){var n=e._fullLayout.hiddenlabels?e._fullLayout.hiddenlabels.slice():[],r=t.selectAll("rect").data([0]);r.enter().append("rect").classed("legendtoggle",!0).style("cursor","pointer").attr("pointer-events","all").call(g.fill,"rgba(0,0,0,0)"), ++r.on("click",function(){if(!e._dragged){var r,a,o=t.data()[0][0],i=e._fullData,l=o.trace,s=l.legendgroup,c=[];if(d.traceIs(l,"pie")){var f=o.label,h=n.indexOf(f);h===-1?n.push(f):n.splice(h,1),u.relayout(e,"hiddenlabels",n)}else{if(""===s)c=[l.index];else for(var p=0;ptspan"),h=d[0].length||1;n=s*h,r=u.node()&&p.bBox(u.node()).width;var g=s*(.3+(1-h)/2);u.attr("y",g),d.attr("y",g)}n=Math.max(n,16)+3,o.attr({x:0,y:-n/2,height:n}),a.height=n,a.width=r}function i(t,e,n){var r=t._fullLayout,a=r.legend,o=a.borderwidth,i=x.isGrouped(a),l=x.isHorizontalColumn(a);if(x.isVertical(a))i&&e.each(function(t,e){f.setTranslate(this,0,e*a.tracegroupgap)}),a.width=0,a.height=0,n.each(function(t){var e=t[0],n=e.height,r=e.width;f.setTranslate(this,o,5+o+a.height+n/2),a.height+=n,a.width=Math.max(a.width,r)}),a.width+=45+2*o,a.height+=10+2*o,i&&(a.height+=(a._lgroupsLength-1)*a.tracegroupgap),n.selectAll(".legendtoggle").attr("width",(t._context.editable?0:a.width)+40),a.width=Math.ceil(a.width),a.height=Math.ceil(a.height);else if(i){a.width=0,a.height=0;for(var s=[a.width],u=e.data(),d=0,h=u.length;dr.width-(r.margin.r+r.margin.l)&&(b=0,v+=m,a.height=a.height+m,m=0),f.setTranslate(this,o+b,5+o+e.height/2+v),a.width+=i+n,a.height=Math.max(a.height,e.height),b+=i+n,m=Math.max(e.height,m)}),a.width+=2*o,a.height+=10+2*o,a.width=Math.ceil(a.width),a.height=Math.ceil(a.height),n.selectAll(".legendtoggle").attr("width",t._context.editable?0:a.width)}}function l(t){var e=t._fullLayout,n=e.legend,r="left";b.isRightAnchor(n)?r="right":b.isCenterAnchor(n)&&(r="center");var a="top";b.isBottomAnchor(n)?a="bottom":b.isMiddleAnchor(n)&&(a="middle"),d.autoMargin(t,"legend",{x:n.x,y:n.y,l:n.width*({right:1,center:.5}[r]||0),r:n.width*({left:1,center:.5}[r]||0),b:n.height*({top:1,middle:.5}[a]||0),t:n.height*({bottom:1,middle:.5}[a]||0)})}function s(t){var e=t._fullLayout,n=e.legend,r="left";b.isRightAnchor(n)?r="right":b.isCenterAnchor(n)&&(r="center"),d.autoMargin(t,"legend",{x:n.x,y:.5,l:n.width*({right:1,center:.5}[r]||0),r:n.width*({left:1,center:.5}[r]||0),b:0,t:0})}var c=t("d3"),u=t("../../plotly"),f=t("../../lib"),d=t("../../plots/plots"),h=t("../dragelement"),p=t("../drawing"),g=t("../color"),v=t("./constants"),m=t("./get_legend_data"),y=t("./style"),x=t("./helpers"),b=t("./anchor_utils");e.exports=function(t){function e(t,e){T.attr("data-scroll",e).call(f.setTranslate,0,e),L.call(p.setRect,j,t,v.scrollBarWidth,v.scrollBarHeight),M.select("rect").attr({y:x.borderwidth-e})}var n=t._fullLayout,o="legend"+n._uid;if(n._infolayer&&t.calcdata){var x=n.legend,_=n.showlegend&&m(t.calcdata,x),w=n.hiddenlabels||[];if(!n.showlegend||!_.length)return n._infolayer.selectAll(".legend").remove(),n._topdefs.select("#"+o).remove(),void d.autoMargin(t,"legend");var k=n._infolayer.selectAll("g.legend").data([0]);k.enter().append("g").attr({class:"legend","pointer-events":"all"});var M=n._topdefs.selectAll("#"+o).data([0]);M.enter().append("clipPath").attr("id",o).append("rect");var A=k.selectAll("rect.bg").data([0]);A.enter().append("rect").attr({class:"bg","shape-rendering":"crispEdges"}),A.call(g.stroke,x.bordercolor),A.call(g.fill,x.bgcolor),A.style("stroke-width",x.borderwidth+"px");var T=k.selectAll("g.scrollbox").data([0]);T.enter().append("g").attr("class","scrollbox");var L=k.selectAll("rect.scrollbar").data([0]);L.enter().append("rect").attr({class:"scrollbar",rx:20,ry:2,width:0,height:0}).call(g.fill,"#808BA4");var z=T.selectAll("g.groups").data(_);z.enter().append("g").attr("class","groups"),z.exit().remove();var S=z.selectAll("g.traces").data(f.identity);S.enter().append("g").attr("class","traces"),S.exit().remove(),S.call(y).style("opacity",function(t){var e=t[0].trace;return d.traceIs(e,"pie")?w.indexOf(t[0].label)!==-1?.5:1:"legendonly"===e.visible?.5:1}).each(function(){c.select(this).call(r,t).call(a,t)});var C=0!==k.enter().size();C&&(i(t,z,S),l(t));var E=0,O=n.width,N=0,P=n.height;i(t,z,S),x.height>P?s(t):l(t);var D=n._size,I=D.l+D.w*x.x,R=D.t+D.h*(1-x.y);b.isRightAnchor(x)?I-=x.width:b.isCenterAnchor(x)&&(I-=x.width/2),b.isBottomAnchor(x)?R-=x.height:b.isMiddleAnchor(x)&&(R-=x.height/2);var j=x.width,F=D.w;j>F?(I=D.l,j=F):(I+j>O&&(I=O-j),IB?(R=D.t,q=B):(R+q>P&&(R=P-q),Rn[1])return n[1]}return a}function n(t){return t[0]}var r,a,o=t[0],i=o.trace,l=h.hasMarkers(i),u=h.hasText(i),d=h.hasLines(i);if(l||u||d){var p={},g={};l&&(p.mc=e("marker.color",n),p.mo=e("marker.opacity",c.mean,[.2,1]),p.ms=e("marker.size",c.mean,[2,16]),p.mlc=e("marker.line.color",n),p.mlw=e("marker.line.width",c.mean,[0,5]),g.marker={sizeref:1,sizemin:1,sizemode:"diameter"}),d&&(g.line={width:e("line.width",n,[0,10])}),u&&(p.tx="Aa",p.tp=e("textposition",n),p.ts=10,p.tc=e("textfont.color",n),p.tf=e("textfont.family",n)),r=[c.minExtend(o,p)],a=c.minExtend(i,g)}var v=s.select(this).select("g.legendpoints"),m=v.selectAll("path.scatterpts").data(l?r:[]);m.enter().append("path").classed("scatterpts",!0).attr("transform","translate(20,0)"),m.exit().remove(),m.call(f.pointStyle,a),l&&(r[0].mrc=3);var y=v.selectAll("g.pointtext").data(u?r:[]);y.enter().append("g").classed("pointtext",!0).append("text").attr("transform","translate(20,0)"),y.exit().remove(),y.selectAll("text").call(f.textPointStyle,a)}function o(t){var e=t[0].trace,n=e.marker||{},r=n.line||{},a=s.select(this).select("g.legendpoints").selectAll("path.legendbar").data(u.traceIs(e,"bar")?[t]:[]);a.enter().append("path").classed("legendbar",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),a.exit().remove(),a.each(function(t){var e=(t.mlw+1||r.width+1)-1,a=s.select(this);a.style("stroke-width",e+"px").call(d.fill,t.mc||n.color),e&&a.call(d.stroke,t.mlc||r.color)})}function i(t){var e=t[0].trace,n=s.select(this).select("g.legendpoints").selectAll("path.legendbox").data(u.traceIs(e,"box")&&e.visible?[t]:[]);n.enter().append("path").classed("legendbox",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),n.exit().remove(),n.each(function(t){var n=(t.lw+1||e.line.width+1)-1,r=s.select(this);r.style("stroke-width",n+"px").call(d.fill,t.fc||e.fillcolor),n&&r.call(d.stroke,t.lc||e.line.color)})}function l(t){var e=t[0].trace,n=s.select(this).select("g.legendpoints").selectAll("path.legendpie").data(u.traceIs(e,"pie")&&e.visible?[t]:[]);n.enter().append("path").classed("legendpie",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),n.exit().remove(),n.size()&&n.call(p,t[0],e)}var s=t("d3"),c=t("../../lib"),u=t("../../plots/plots"),f=t("../drawing"),d=t("../color"),h=t("../../traces/scatter/subtypes"),p=t("../../traces/pie/style_one");e.exports=function(t){t.each(function(t){var e=s.select(this),n=e.selectAll("g.legendfill").data([t]);n.enter().append("g").classed("legendfill",!0);var r=e.selectAll("g.legendlines").data([t]);r.enter().append("g").classed("legendlines",!0);var a=e.selectAll("g.legendsymbols").data([t]);a.enter().append("g").classed("legendsymbols",!0),a.style("opacity",t[0].trace.opacity),a.selectAll("g.legendpoints").data([t]).enter().append("g").classed("legendpoints",!0)}).each(o).each(i).each(l).each(r).each(a)}},{"../../lib":94,"../../plots/plots":135,"../../traces/pie/style_one":170,"../../traces/scatter/subtypes":191,"../color":18,"../drawing":41,d3:7}],63:[function(t,e,n){"use strict";function r(t,e){var n=e.currentTarget,r=n.getAttribute("data-attr"),a=n.getAttribute("data-val")||!0,o=t._fullLayout,i={};if("zoom"===r){for(var l,s,u="in"===a?.5:2,f=(1+u)/2,d=(1-u)/2,h=c.Axes.list(t,null,!0),p=0;p1)return r(["resetViews","toggleHover"]),i(v,n);u&&(r(["zoom3d","pan3d","orbitRotation","tableRotation"]),r(["resetCameraDefault3d","resetCameraLastSave3d"]),r(["hoverClosest3d"])),d&&(r(["zoomInGeo","zoomOutGeo","resetGeo"]),r(["hoverClosestGeo"]));var m=a(l),y=[];return((c||p)&&!m||g)&&(y=["zoom2d","pan2d"]),(c||g)&&o(s)&&(y.push("select2d"),y.push("lasso2d")),y.length&&r(y),!c&&!p||m||g||r(["zoomIn2d","zoomOut2d","autoScale2d","resetScale2d"]),c&&h?r(["toggleHover"]):p?r(["hoverClosestGl2d"]):c?r(["hoverClosestCartesian","hoverCompareCartesian"]):h&&r(["hoverClosestPie"]),i(v,n)}function a(t){for(var e=s.Axes.list({_fullLayout:t},null,!0),n=!0,r=0;r0);if(p){var g=a(e,n,s);u("x",g[0]),u("y",g[1]),o.noneOrAll(t,e,["x","y"]),u("xanchor"),u("yanchor"),o.coerceFont(u,"font",n.font);var v=u("bgcolor");u("activecolor",i.contrast(v,c.lightAmount,c.darkAmount)),u("bordercolor"),u("borderwidth")}}},{"../../lib":94,"../color":18,"./attributes":66,"./button_attributes":67,"./constants":68}],70:[function(t,e,n){"use strict";function r(t){for(var e=m.list(t,"x",!0),n=[],r=0;re;a--)h(t,a).selectAll('[data-index="'+(a-1)+'"]').attr("data-index",a),C.draw(t,a)}function f(t,e,n,i){function l(n){var r={"data-index":e,"fill-rule":"evenodd",d:x(t,C)},a=C.line.width?C.line.color:"rgba(0,0,0,0)",o=n.append("path").attr(r).style("opacity",C.opacity).call(T.stroke,a).call(T.fill,C.fillcolor).call(L.dashLine,C.line.dash,C.line.width);E&&o.call(L.setClipUrl,"clip"+t._fullLayout._uid+E),t._context.editable&&d(t,o,C,e)}var s,c;h(t,e).selectAll('[data-index="'+e+'"]').remove();var u=t.layout.shapes[e];if(u){var f={xref:u.xref,yref:u.yref},g={};"string"==typeof n&&n?g[n]=i:M.isPlainObject(n)&&(g=n);var v=Object.keys(g);for(s=0;sG&&r>$&&!t.shiftKey?z.getCursor(a/n,1-o/r):"move";S(e,i),X=i.split("-")[0]}function o(e){B=A.getFromId(t,n.xref),H=A.getFromId(t,n.yref),V=m(t,B),Z=m(t,H,!0),Y=y(t,B),U=y(t,H,!0);var o="shapes["+r+"]";"path"===n.type?(F=n.path,q=o+".path"):(u=V(n.x0),f=Z(n.y0),d=V(n.x1),h=Z(n.y1),p=o+".x0",g=o+".y0",_=o+".x1",w=o+".y1"),u$&&(c[E]=n[D]=U(l),c[O]=n[I]=U(s)),f-u>G&&(c[N]=n[R]=Y(u),c[P]=n[j]=Y(f))}e.attr("d",x(t,n))}var c,u,f,d,h,p,g,_,w,M,T,L,C,E,O,N,P,D,I,R,j,F,q,B,H,V,Z,Y,U,X,G=10,$=10,Q={setCursor:a,element:e.node(),prepFn:o,doneFn:i},W=Q.element.getBoundingClientRect();z.init(Q)}function h(t,e){var n=t._fullLayout.shapes[e],r=t._fullLayout._shapeUpperLayer;return n?"below"===n.layer&&(r="paper"===n.xref&&"paper"===n.yref?t._fullLayout._shapeLowerLayer:t._fullLayout._shapeSubplotLayer):M.log("getShapeLayer: undefined shape: index",e),r}function p(t,e,n){var r=k.Axes.getFromId(t,n.id,"x")._id,a=k.Axes.getFromId(t,n.id,"y")._id,o="below"===e.layer,i=r===e.xref||a===e.yref,l=!!n.shapelayer;return o&&i&&l}function g(t){return function(e){return e.replace&&(e=e.replace("_"," ")),t(e)}}function v(t){return function(e){return t(e).replace(" ","_")}}function m(t,e,n){var r,o=t._fullLayout._size;if(e){var i=a(e);r=function(t){return e._offset+e.l2p(i(t,!0))},"date"===e.type&&(r=g(r))}else r=n?function(t){return o.t+o.h*(1-t)}:function(t){return o.l+o.w*t};return r}function y(t,e,n){var r,a=t._fullLayout._size;if(e){var i=o(e);r=function(t){return i(e.p2l(t-e._offset))}}else r=n?function(t){return 1-(t-a.t)/a.h}:function(t){return(t-a.l)/a.w};return r}function x(t,e){var n,r,o,i,l=e.type,s=A.getFromId(t,e.xref),c=A.getFromId(t,e.yref),u=t._fullLayout._size;if(s?(n=a(s),r=function(t){return s._offset+s.l2p(n(t,!0))}):r=function(t){return u.l+u.w*t},c?(o=a(c),i=function(t){return c._offset+c.l2p(o(t,!0))}):i=function(t){return u.t+u.h*(1-t)},"path"===l)return s&&"date"===s.type&&(r=g(r)),c&&"date"===c.type&&(i=g(i)),C.convertPath(e.path,r,i);var f=r(e.x0),d=r(e.x1),h=i(e.y0),p=i(e.y1);if("line"===l)return"M"+f+","+h+"L"+d+","+p;if("rect"===l)return"M"+f+","+h+"H"+d+"V"+p+"H"+f+"Z";var v=(f+d)/2,m=(h+p)/2,y=Math.abs(v-f),x=Math.abs(m-h),b="A"+y+","+x,_=v+y+","+m,w=v+","+(m-x);return"M"+_+b+" 0 1,1 "+w+b+" 0 0,1 "+_+"Z"}function b(t,e,n){return t.replace(E,function(t){var r=0,a=t.charAt(0),o=N[a],i=P[a],l=D[a],s=t.substr(1).replace(O,function(t){return r>=l?t:(o[r]?t=e(t):i[r]&&(t=n(t)),r++,t)});return a+s})}function _(t,e,n,r,a){var o="category"===t.type?Number:t.d2c;if(void 0!==e)return[o(e),o(n)];if(r){var i,l,s,c,u,f=1/0,d=-(1/0),h=r.match(E);for("date"===t.type&&(o=g(o)),i=0;id&&(d=u)));return d>=f?[f,d]:void 0}}var w=t("fast-isnumeric"),k=t("../../plotly"),M=t("../../lib"),A=t("../../plots/cartesian/axes"),T=t("../color"),L=t("../drawing"),z=t("../dragelement"),S=t("../../lib/setcursor"),C=e.exports={};C.layoutAttributes=t("./attributes"),C.supplyLayoutDefaults=function(t,e){for(var n=t.shapes||[],a=e.shapes=[],o=0;ol&&(t="X"),t});return r>l&&(s=s.replace(/[\s,]*X.*/,""),M.log("Ignoring extra params in segment "+t)),a+s})},C.calcAutorange=function(t){var e,n,r,a,o,i=t._fullLayout,l=i.shapes;if(l.length&&t._fullData.length)for(e=0;e0||d<0){var h={left:[-n,0],right:[n,0],top:[0,-n],bottom:[0,n]}[x.side];e.attr("transform","translate("+h+")")}}}function p(){L=0,z=!0,S=E,k._infolayer.select("."+e).attr({"data-unformatted":S}).text(S).on("mouseover.opacity",function(){r.select(this).transition().duration(100).style("opacity",1)}).on("mouseout.opacity",function(){r.select(this).transition().duration(1e3).style("opacity",0)})}var g=n.propContainer,v=n.propName,m=n.traceIndex,y=n.dfltName,x=n.avoid||{},b=n.attributes,_=n.transform,w=n.containerGroup,k=t._fullLayout,M=g.titlefont.family,A=g.titlefont.size,T=g.titlefont.color,L=1,z=!1,S=g.title.trim();""===S&&(L=0),S.match(/Click to enter .+ title/)&&(L=.2,z=!0),w||(w=k._infolayer.selectAll(".g-"+e).data([0]),w.enter().append("g").classed("g-"+e,!0));var C=w.selectAll("text").data([0]);C.enter().append("text"),C.text(S).attr("class",e),C.attr({"data-unformatted":S}).call(f);var E="Click to enter "+y+" title";t._context.editable?(S||p(),C.call(u.makeEditable).on("edit",function(e){void 0!==m?o.restyle(t,v,e,m):o.relayout(t,v,e)}).on("cancel",function(){this.text(this.attr("data-unformatted")).call(f)}).on("input",function(t){this.text(t||" ").attr(b).selectAll("tspan.line").attr(b)})):S&&!S.match(/Click to enter .+ title/)||C.remove(),C.classed("js-placeholder",z)}},{"../../lib":94,"../../lib/svg_text_utils":105,"../../plotly":112,"../../plots/plots":135,"../color":18,"../drawing":41,d3:7,"fast-isnumeric":10}],82:[function(t,e,n){"use strict";var r=t("../../plots/font_attributes"),a=t("../color/attributes"),o=t("../../lib/extend").extendFlat,i={_isLinkedToArray:!0,method:{valType:"enumerated",values:["restyle","relayout"],dflt:"restyle"},args:{valType:"info_array",freeLength:!0,items:[{valType:"any"},{valType:"any"},{valType:"any"}]},label:{valType:"string",dflt:""}};e.exports={_isLinkedToArray:!0,visible:{valType:"boolean"},active:{valType:"integer",min:-1,dflt:0},buttons:i,x:{valType:"number",min:-2,max:3,dflt:-.05},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"right"},y:{valType:"number",min:-2,max:3,dflt:1},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"bottom"},font:o({},r,{}),bgcolor:{valType:"color"},bordercolor:{valType:"color",dflt:a.borderLine},borderwidth:{valType:"number",min:0,dflt:1}}},{"../../lib/extend":93,"../../plots/font_attributes":133,"../color/attributes":17}],83:[function(t,e,n){"use strict";e.exports={name:"updatemenus",itemName:"updatemenu",containerClassName:"updatemenu-container",headerGroupClassName:"updatemenu-header-group",headerClassName:"updatemenu-header",headerArrowClassName:"updatemenu-header-arrow",buttonGroupClassName:"updatemenu-button-group",buttonClassName:"updatemenu-button",itemRectClassName:"updatemenu-item-rect",itemTextClassName:"updatemenu-item-text",menuIndexAttrName:"updatemenu-active-index",autoMarginIdRoot:"updatemenu-",blankHeaderOpts:{label:" "},minWidth:30,minHeight:30,textPadX:40,fontSizeToHeight:1.3,rx:2,ry:2,textOffsetX:12,textOffsetY:3,arrowOffsetX:4,gapButtonHeader:5,gapButton:2,activeColor:"#F4FAFF",hoverColor:"#F4FAFF"}},{}],84:[function(t,e,n){"use strict";function r(t,e,n){function r(n,r){return o.coerce(t,e,i,n,r)}var l=a(t,e),s=r("visible",l.length>0);s&&(r("active"),r("x"),r("y"),o.noneOrAll(t,e,["x","y"]),r("xanchor"),r("yanchor"),o.coerceFont(r,"font",n.font),r("bgcolor",n.paper_bgcolor),r("bordercolor"),r("borderwidth"))}function a(t,e){function n(t,e){return o.coerce(r,a,c,t,e)}for(var r,a,i=t.buttons||[],l=e.buttons=[],s=0;s0?[0]:[]);if(s.enter().append("g").classed(T.containerClassName,!0).style("cursor","pointer"),s.exit().remove(),s.exit().size()&&m(t),0!==n.length){var c=s.selectAll("g."+T.headerGroupClassName).data(n,a);c.enter().append("g").classed(T.headerGroupClassName,!0);var u=s.selectAll("g."+T.buttonGroupClassName).data([0]);u.enter().append("g").classed(T.buttonGroupClassName,!0).style("pointer-events","all"),c.enter().size()&&u.call(v).attr(T.menuIndexAttrName,"-1"),c.exit().each(function(e){y.select(this).remove(),u.call(v).attr(T.menuIndexAttrName,"-1"),b.autoMargin(t,T.autoMarginIdRoot+e._index)});for(var f=0;fa.max?e.set(n):e.set(+t)}},integer:{coerceFunction:function(t,e,n,a){t%1||!r(t)||void 0!==a.min&&ta.max?e.set(n):e.set(+t)}},string:{coerceFunction:function(t,e,n,r){if("string"!=typeof t){var a="number"==typeof t;r.strict!==!0&&a?e.set(String(t)):e.set(n)}else r.noBlank&&!t?e.set(n):e.set(t)}},color:{coerceFunction:function(t,e,n){a(t).isValid()?e.set(t):e.set(n)}},colorscale:{coerceFunction:function(t,e,n){e.set(i(t,n))}},angle:{coerceFunction:function(t,e,n){"auto"===t?e.set("auto"):r(t)?(Math.abs(t)>180&&(t-=360*Math.round(t/360)),e.set(+t)):e.set(n)}},subplotid:{coerceFunction:function(t,e,n){var r=n.length;return"string"==typeof t&&t.substr(0,r)===n&&l.test(t.substr(r))?void e.set(t):void e.set(n)},validateFunction:function(t,e){var n=e.dflt,r=n.length;return t===n||"string"==typeof t&&!(t.substr(0,r)!==n||!l.test(t.substr(r)))}},flaglist:{coerceFunction:function(t,e,n,r){if("string"!=typeof t)return void e.set(n);if((r.extras||[]).indexOf(t)!==-1)return void e.set(t);for(var a=t.split("+"),o=0;o2)return!1;var i=o[0].split("-");if(i.length>3||3!==i.length&&o[1])return!1;if(4===i[0].length)e=Number(i[0]);else{if(2!==i[0].length)return!1;var s=(new Date).getFullYear();e=((Number(i[0])-s+70)%100+200)%100+s-70}return!!l(e)&&(1===i.length?new Date(e,0,1).getTime():(n=Number(i[1])-1, ++!(i[1].length>2)&&n>=0&&n<=11&&(2===i.length?new Date(e,n,1).getTime():(r=Number(i[2]),!(i[2].length>2)&&r>=1&&r<=31&&(r=new Date(e,n,r).getTime(),o[1]?(i=o[1].split(":"),!(i.length>3)&&(a=Number(i[0]),!(i[0].length>2)&&a>=0&&a<=23&&(r+=36e5*a,1===i.length?r:(n=Number(i[1]),!(i[1].length>2)&&n>=0&&n<=59&&(r+=6e4*n,2===i.length?r:(t=Number(i[2]),t>=0&&t<60&&r+1e3*t)))))):r)))))},n.isDateTime=function(t){return n.dateTime2ms(t)!==!1},n.ms2DateTime=function(t,e){if("undefined"==typeof i)return void s.error("d3 is not defined.");e||(e=0);var n=new Date(t),a=i.time.format("%Y-%m-%d")(n);return e<7776e6?(a+=" "+r(n.getHours(),2),e<432e6&&(a+=":"+r(n.getMinutes(),2),e<108e5&&(a+=":"+r(n.getSeconds(),2),e<3e5&&(a+="."+r(n.getMilliseconds(),3)))),a.replace(/([:\s]00)*\.?[0]*$/,"")):a};var c={H:["%H:%M:%S~%L","%H:%M:%S","%H:%M"],I:["%I:%M:%S~%L%p","%I:%M:%S%p","%I:%M%p"],D:["%H","%I%p","%Hh"]},u={Y:["%Y~%m~%d","%Y%m%d","%y%m%d","%m~%d~%Y","%d~%m~%Y"],Yb:["%b~%d~%Y","%d~%b~%Y","%Y~%d~%b","%Y~%b~%d"],y:["%m~%d~%y","%d~%m~%y","%y~%m~%d"],yb:["%b~%d~%y","%d~%b~%y","%y~%d~%b","%y~%b~%d"]},f=i.time.format.utc,d={Y:{H:["%Y~%m~%dT%H:%M:%S","%Y~%m~%dT%H:%M:%S~%L"].map(f),I:[],D:["%Y%m%d%H%M%S","%Y~%m","%m~%Y"].map(f)},Yb:{H:[],I:[],D:["%Y~%b","%b~%Y"].map(f)},y:{H:[],I:[],D:[]},yb:{H:[],I:[],D:[]}};["Y","Yb","y","yb"].forEach(function(t){u[t].forEach(function(e){d[t].D.push(f(e)),["H","I","D"].forEach(function(n){c[n].forEach(function(r){var a=d[t][n];a.push(f(e+"~"+r)),a.push(f(r+"~"+e))})})})});var h=/[a-z]*/g,p=function(t){return t.substr(0,3)},g=/(mon|tue|wed|thu|fri|sat|sun|the|of|st|nd|rd|th)/g,v=/[\s,\/\-\.\(\)]+/g,m=/~?([ap])~?m(~|$)/,y=function(t,e){return e+"m "},x=/\d\d\d\d/,b=/(^|~)[a-z]{3}/,_=/[ap]m/,w=/:/,k=/q([1-4])/,M=["31~mar","30~jun","30~sep","31~dec"],A=function(t,e){return M[e-1]},T=/ ?([+\-]\d\d:?\d\d|Z)$/;n.parseDate=function(t){if(t.getTime)return t;if("string"!=typeof t)return!1;t=t.toLowerCase().replace(h,p).replace(g,"").replace(v,"~").replace(m,y).replace(k,A).trim().replace(T,"");var e,n,r=null,i=a(t),l=o(t);e=d[i][l],n=e.length;for(var s=0;sn?Math.max(n,Math.min(e,t)):Math.max(e,Math.min(n,t))},a.bBoxIntersect=function(t,e,n){return n=n||0,t.left<=e.right+n&&e.left<=t.right+n&&t.top<=e.bottom+n&&e.top<=t.bottom+n},a.identity=function(t){return t},a.randstr=function t(e,n,r){if(r||(r=16),void 0===n&&(n=24),n<=0)return"0";var a,o,i,l=Math.log(Math.pow(2,n))/Math.log(r),s="";for(a=2;l===1/0;a*=2)l=Math.log(Math.pow(2,n/a))/Math.log(r)*a;var c=l-Math.floor(l);for(a=0;a-1||u!==1/0&&u>=Math.pow(2,n)?t(e,n,r):s},a.OptionControl=function(t,e){t||(t={}),e||(e="opt");var n={};return n.optionList=[],n._newoption=function(r){r[e]=t,n[r.name]=r,n.optionList.push(r)},n["_"+e]=t,n},a.smooth=function(t,e){if(e=Math.round(e)||0,e<2)return t;var n,r,a,o,i=t.length,l=2*i,s=2*e-1,c=new Array(s),u=new Array(i);for(n=0;n=l&&(a-=l*Math.floor(a/l)),a<0?a=-1-a:a>=i&&(a=l-1-a),o+=t[a]*c[r];u[n]=o}return u},a.syncOrAsync=function(t,e,n){function r(){return a.syncOrAsync(t,e,n)}for(var o,i;t.length;)if(i=t.splice(0,1)[0],o=i(e),o&&o.then)return o.then(r).then(void 0,a.promiseError);return n&&n(e)},a.stripTrailingSlash=function(t){return"/"===t.substr(-1)?t.substr(0,t.length-1):t},a.noneOrAll=function(t,e,n){if(t){var r,a,o=!1,i=!0;for(r=0;r1?r+o[1]:"";if(a&&(o.length>1||i.length>4))for(;n.test(i);)i=i.replace(n,"$1"+a+"$2");return i+l}},{"./coerce":90,"./dates":91,"./extend":93,"./is_plain_object":95,"./loggers":96,"./matrix":97,"./nested_property":98,"./notifier":99,"./search":102,"./stats":104,d3:7}],95:[function(t,e,n){"use strict";e.exports=function(t){return window&&window.process&&window.process.versions?"[object Object]"===Object.prototype.toString.call(t):"[object Object]"===Object.prototype.toString.call(t)&&Object.getPrototypeOf(t)===Object.prototype}},{}],96:[function(t,e,n){"use strict";var r=t("../plot_api/plot_config"),a=e.exports={};a.log=function(){if(r.logging>1){for(var t=["LOG:"],e=0;e0){for(var t=["WARN:"],e=0;e0){for(var t=["ERROR:"],e=0;e=0;e--){if(r=t[e],i=!1,Array.isArray(r))for(n=r.length-1;n>=0;n--)c(r[n])?i?r[n]=void 0:r.pop():i=!0;else if("object"==typeof r&&null!==r)for(o=Object.keys(r),i=!1,n=o.length-1;n>=0;n--)c(r[o[n]])&&!a(r[o[n]],o[n])?delete r[o[n]]:i=!0;if(i)return}}function c(t){return void 0===t||null===t||"object"==typeof t&&(Array.isArray(t)?!t.length:!Object.keys(t).length)}function u(t,e,n){return{set:function(){throw"bad container"},get:function(){},astr:e,parts:n,obj:t}}var f=t("fast-isnumeric");e.exports=function(t,e){if(f(e))e=String(e);else if("string"!=typeof e||"[-1]"===e.substr(e.length-4))throw"bad property string";for(var n,a,i,l=0,s=e.split(".");lo||rl)&&(!e||!c(t))}function n(t,e){var n=t[0],s=t[1];if(no||sl)return!1;var c,u,f,d,h,p=r.length,g=r[0][0],v=r[0][1],m=0;for(c=1;cMath.max(u,g)||s>Math.max(f,v)))if(su||Math.abs(r(i,d))>a)return!0;return!1};a.filter=function(t,e){function n(n){t.push(n);var l=r.length,s=a;r.splice(i+1);for(var c=s+1;c1){var l=t.pop();n(l)}return{addPt:n,raw:t,filtered:r}}},{"./matrix":97}],101:[function(t,e,n){"use strict";function r(t,e){for(var n,r=[],o=0;oo.queueLength&&(t.undoQueue.queue.shift(),t.undoQueue.index--)))},i.startSequence=function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!0,t.undoQueue.beginSequence=!0},i.stopSequence=function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!1,t.undoQueue.beginSequence=!1},i.undo=function(t){var e,n;if(t.framework&&t.framework.isPolar)return void t.framework.undo();if(!(void 0===t.undoQueue||isNaN(t.undoQueue.index)||t.undoQueue.index<=0)){for(t.undoQueue.index--,e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,n=0;n=t.undoQueue.queue.length)){for(e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,n=0;ne}function i(t,e){return t>=e}var l=t("fast-isnumeric"),s=t("../lib");n.findBin=function(t,e,n){if(l(e.start))return n?Math.ceil((t-e.start)/e.size)-1:Math.floor((t-e.start)/e.size);var c,u,f=0,d=e.length,h=0;for(u=e[e.length-1]>=e[0]?n?r:a:n?i:o;f90&&s.log("Long binary search..."),f-1},n.sorterAsc=function(t,e){return t-e},n.sorterDes=function(t,e){return e-t},n.distinctVals=function(t){var e=t.slice();e.sort(n.sorterAsc);for(var r=e.length-1,a=e[r]-e[0]||1,o=a/(r||1)/1e4,i=[e[0]],l=0;le[l]+o&&(a=Math.min(a,e[l+1]-e[l]),i.push(e[l+1]));return{vals:i,minDiff:a}},n.roundUp=function(t,e,n){for(var r,a=0,o=e.length-1,i=0,l=n?0:1,s=n?1:0,c=n?Math.ceil:Math.floor;at.length-1)return t[t.length-1];var n=e%1;return n*t[Math.ceil(e)]+(1-n)*t[Math.floor(e)]}},{"fast-isnumeric":10}],105:[function(t,e,n){"use strict";function r(t,e){return t.node().getBoundingClientRect()[e]}function a(t){return t.replace(/(<|<|<)/g,"\\lt ").replace(/(>|>|>)/g,"\\gt ")}function o(t,e,n){var r="math-output-"+c.Lib.randstr([],64),o=u.select("body").append("div").attr({id:r}).style({visibility:"hidden",position:"absolute"}).style({"font-size":e.fontSize+"px"}).text(a(t));MathJax.Hub.Queue(["Typeset",MathJax.Hub,o.node()],function(){var e=u.select("body").select("#MathJax_SVG_glyphs");if(o.select(".MathJax_SVG").empty()||!o.select("svg").node())f.log("There was an error in the tex syntax.",t),n();else{var r=o.select("svg").node().getBoundingClientRect();n(o.select(".MathJax_SVG"),e,r)}o.remove()})}function i(t){return(t||"").replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")}function l(t){for(var e=t.split(/(<[^<>]*>)/).map(function(t){var e=t.match(/<(\/?)([^ >]*)\s*(.*)>/i),n=e&&e[2].toLowerCase(),r=p[n];if(void 0!==r){var a=e[1],o=e[3],l=o.match(/^style\s*=\s*"([^"]+)"\s*/i);if("a"===n){if(a)return"
";if("href"!==o.substr(0,4).toLowerCase())return"";var s=o.substr(4).replace(/["']/g,"").replace(/=/,""),u=document.createElement("a");return u.href=s,g.indexOf(u.protocol)===-1?"":''}if("br"===n)return"
";if(a)return"sup"===n?'':"sub"===n?'':"";var f=""}return c.util.xml_entity_encode(t).replace(/");r>0;r=e.indexOf("
",r+1))n.push(r);var a=0;n.forEach(function(t){for(var n=t+a,r=e.slice(0,n),o="",i=r.length-1;i>=0;i--){var l=r[i].match(/<(\/?).*>/i);if(l&&"
"!==r[i]){l[1]||(o=r[i]);break}}o&&(e.splice(n+1,0,o),e.splice(n,0,""),a+=2)});var o=e.join(""),l=o.split(/
/gi);return l.length>1&&(e=l.map(function(t,e){return''+t+""})),e.join("")}function s(t,e,n){var r,a,o,i=n.horizontalAlign,l=n.verticalAlign||"top",s=t.node().getBoundingClientRect(),c=e.node().getBoundingClientRect();return a="bottom"===l?function(){return s.bottom-r.height}:"middle"===l?function(){return s.top+(s.height-r.height)/2}:function(){return s.top},o="right"===i?function(){return s.right-r.width}:"center"===i?function(){return s.left+(s.width-r.width)/2}:function(){return s.left},function(){return r=this.node().getBoundingClientRect(),this.style({top:a()-c.top+"px",left:o()-c.left+"px","z-index":1e3}),this}}var c=t("../plotly"),u=t("d3"),f=t("../lib"),d=t("../constants/xmlns_namespaces"),h=e.exports={};u.selection.prototype.appendSVG=function(t){for(var e=['',t,""].join(""),n=(new DOMParser).parseFromString(e,"application/xml"),r=n.documentElement.firstChild;r;)this.node().appendChild(this.node().ownerDocument.importNode(r,!0)),r=r.nextSibling;return n.querySelector("parsererror")?(f.log(n.querySelector("parsererror div").textContent),null):u.select(this.node().lastChild)},h.html_entity_decode=function(t){var e=u.select("body").append("div").style({display:"none"}).html(""),n=t.replace(/(&[^;]*;)/gi,function(t){return"<"===t?"<":"&rt;"===t?">":e.html(t).text()});return e.remove(),n},h.xml_entity_encode=function(t){return t.replace(/&(?!\w+;|\#[0-9]+;| \#x[0-9A-F]+;)/g,"&")},h.convertToTspans=function(t,e){function n(){h.empty()||(p=s.attr("class")+"-math",h.select("svg."+p).remove()),t.text("").style({visibility:"visible","white-space":"pre"}),d=t.appendSVG(i),d||t.text(a),t.select("a").size()&&t.style("pointer-events","all"),e&&e.call(s)}var a=t.text(),i=l(a),s=t,f=!s.attr("data-notex")&&i.match(/([^$]*)([$]+[^$]*[$]+)([^$]*)/),d=a,h=u.select(s.node().parentNode);if(!h.empty()){var p=s.attr("class")?s.attr("class").split(" ")[0]:"text";p+="-math",h.selectAll("svg."+p).remove(),h.selectAll("g."+p+"-group").remove(),t.style({visibility:null});for(var g=t.node();g&&g.removeAttribute;g=g.parentNode)g.removeAttribute("data-bb");if(f){var v=c.Lib.getPlotDiv(s.node());(v&&v._promises||[]).push(new Promise(function(t){s.style({visibility:"hidden"});var a={fontSize:parseInt(s.style("font-size"),10)};o(f[2],a,function(a,o,i){h.selectAll("svg."+p).remove(),h.selectAll("g."+p+"-group").remove();var l=a&&a.select("svg");if(!l||!l.node())return n(),void t();var c=h.append("g").classed(p+"-group",!0).attr({"pointer-events":"none"});c.node().appendChild(l.node()),o&&o.node()&&l.node().insertBefore(o.node().cloneNode(!0),l.node().firstChild),l.attr({class:p,height:i.height,preserveAspectRatio:"xMinYMin meet"}).style({overflow:"visible","pointer-events":"none"});var u=s.style("fill")||"black";l.select("g").attr({fill:u,stroke:u});var f=r(l,"width"),d=r(l,"height"),g=+s.attr("x")-f*{start:0,middle:.5,end:1}[s.attr("text-anchor")||"start"],v=parseInt(s.style("font-size"),10)||r(s,"height"),m=-v/4;"y"===p[0]?(c.attr({transform:"rotate("+[-90,+s.attr("x"),+s.attr("y")]+") translate("+[-f/2,m-d/2]+")"}),l.attr({x:+s.attr("x"),y:+s.attr("y")})):"l"===p[0]?l.attr({x:s.attr("x"),y:m-d/2}):"a"===p[0]?l.attr({x:0,y:m}):l.attr({x:g,y:+s.attr("y")+m-d/2}),e&&e.call(s,c),t(c)})}))}else n();return t}};var p={sup:'font-size:70%" dy="-0.6em',sub:'font-size:70%" dy="0.3em',b:"font-weight:bold",i:"font-style:italic",a:"",span:"",br:"",em:"font-style:italic;font-weight:bold"},g=["http:","https:","mailto:"],v=new RegExp("]*)?/?>","g");h.plainText=function(t){return(t||"").replace(v," ")},h.makeEditable=function(t,e,n){function r(){o(),i.style({opacity:0});var t,e=d.attr("class");t=e?"."+e.split(" ")[0]+"-math-group":"[class*=-math-group]",t&&u.select(i.node().parentNode).select(t).style({opacity:0})}function a(t){var e=t.node(),n=document.createRange();n.selectNodeContents(e);var r=window.getSelection();r.removeAllRanges(),r.addRange(n),e.focus()}function o(){var t=u.select(c.Lib.getPlotDiv(i.node())),e=t.select(".svg-container"),r=e.append("div");r.classed("plugin-editable editable",!0).style({position:"absolute","font-family":i.style("font-family")||"Arial","font-size":i.style("font-size")||12,color:n.fill||i.style("fill")||"black",opacity:1,"background-color":n.background||"transparent",outline:"#ffffff33 1px solid",margin:[-parseFloat(i.style("font-size"))/8+1,0,0,-1].join("px ")+"px",padding:"0","box-sizing":"border-box"}).attr({contenteditable:!0}).text(n.text||i.attr("data-unformatted")).call(s(i,e,n)).on("blur",function(){i.text(this.textContent).style({opacity:1});var t,e=u.select(this).attr("class");t=e?"."+e.split(" ")[0]+"-math-group":"[class*=-math-group]",t&&u.select(i.node().parentNode).select(t).style({opacity:0});var n=this.textContent;u.select(this).transition().duration(0).remove(),u.select(document).on("mouseup",null),l.edit.call(i,n)}).on("focus",function(){var t=this;u.select(document).on("mouseup",function(){return u.event.target!==t&&void(document.activeElement===r.node()&&r.node().blur())})}).on("keyup",function(){27===u.event.which?(i.style({opacity:1}),u.select(this).style({opacity:0}).on("blur",function(){return!1}).transition().remove(),l.cancel.call(i,this.textContent)):(l.input.call(i,this.textContent),u.select(this).call(s(i,e,n)))}).on("keydown",function(){13===u.event.which&&this.blur()}).call(a)}n||(n={});var i=this,l=u.dispatch("edit","input","cancel"),f=u.select(this.node()).style({"pointer-events":"all"}),d=e||f;return e&&f.style({"pointer-events":"none"}),n.immediate?r():d.on("click",r),u.rebind(this,l,"on")}},{"../constants/xmlns_namespaces":87,"../lib":94,"../plotly":112,d3:7}],106:[function(t,e,n){"use strict";function r(t){var e;if("string"==typeof t){if(e=document.getElementById(t),null===e)throw new Error("No DOM element with id '"+t+"' exists on the page.");return e}if(null===t||void 0===t)throw new Error("DOM element provided is null or undefined");return t}function a(t){Array.isArray(t._promises)&&t._promises.length>0&&P.log("Clearing previous rejected promises from queue."),t._promises=[]}function o(t,e){t._fullLayout._paperdiv.style("background","white"),N.defaultConfig.setBackground(t,e)}function i(t,e){t._context||(t._context=P.extendFlat({},N.defaultConfig));var n=t._context;e&&(Object.keys(e).forEach(function(t){t in n&&("setBackground"===t&&"opaque"===e[t]?n[t]=o:n[t]=e[t])}),e.plot3dPixelRatio&&!n.plotGlPixelRatio&&(n.plotGlPixelRatio=n.plot3dPixelRatio)),n.staticPlot&&(n.editable=!1,n.autosizable=!1,n.scrollZoom=!1,n.doubleClick=!1,n.showTips=!1,n.showLink=!1,n.displayModeBar=!1)}function l(t,e,n){var r=C.select(t).selectAll(".plot-container").data([0]);r.enter().insert("div",":first-child").classed("plot-container plotly",!0);var a=r.selectAll(".svg-container").data([0]);a.enter().append("div").classed("svg-container",!0).style("position","relative"),a.html(""),e&&(t.data=e),n&&(t.layout=n),N.micropolar.manager.fillLayout(t),"initial"===t._fullLayout.autosize&&t._context.autosizable&&(k(t,{}),t._fullLayout.autosize=n.autosize=!0),a.style({width:t._fullLayout.width+"px",height:t._fullLayout.height+"px"}),t.framework=N.micropolar.manager.framework(t),t.framework({data:t.data,layout:t.layout},a.node()),t.framework.setUndoPoint();var o=t.framework.svg(),i=1,l=t._fullLayout.title;""!==l&&l||(i=0);var s="Click to enter title",c=function(){this.call(N.util.convertToTspans)},u=o.select(".title-group text").call(c);if(t._context.editable){u.attr({"data-unformatted":l}),l&&l!==s||(i=.2,u.attr({"data-unformatted":s}).text(s).style({opacity:i}).on("mouseover.opacity",function(){C.select(this).transition().duration(100).style("opacity",1)}).on("mouseout.opacity",function(){C.select(this).transition().duration(1e3).style("opacity",0)}));var f=function(){this.call(N.util.makeEditable).on("edit",function(e){t.framework({layout:{title:e}}),this.attr({"data-unformatted":e}).text(e).call(c),this.call(f)}).on("cancel",function(){var t=this.attr("data-unformatted");this.text(t).call(c)})};u.call(f)}return t._context.setBackground(t,t._fullLayout.paper_bgcolor),R.addLinks(t),Promise.resolve()}function s(t){var e,n;t||(t={}),t.xaxis1&&(t.xaxis||(t.xaxis=t.xaxis1),delete t.xaxis1),t.yaxis1&&(t.yaxis||(t.yaxis=t.yaxis1),delete t.yaxis1);var r=N.Axes.list({_fullLayout:t});for(e=0;e3?(u.x=1.02,u.xanchor="left"):u.x<-2&&(u.x=-.02,u.xanchor="right"),u.y>3?(u.y=1.02,u.yanchor="bottom"):u.y<-2&&(u.y=-.02,u.yanchor="top")),"rotate"===t.dragmode&&(t.dragmode="orbit"),t.scene1&&(t.scene||(t.scene=t.scene1),delete t.scene1);var f=R.getSubplotIds(t,"gl3d");for(e=0;e=t.data.length||a<-t.data.length)throw new Error(n+" must be valid indices for gd.data.");if(e.indexOf(a,r+1)>-1||a>=0&&e.indexOf(-t.data.length+a)>-1||a<0&&e.indexOf(t.data.length+a)>-1)throw new Error("each index in "+n+" must be unique.")}}function v(t,e,n){if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("currentIndices is a required argument.");if(Array.isArray(e)||(e=[e]),g(t,e,"currentIndices"),"undefined"==typeof n||Array.isArray(n)||(n=[n]),"undefined"!=typeof n&&g(t,n,"newIndices"),"undefined"!=typeof n&&e.length!==n.length)throw new Error("current and new indices must be of equal length.")}function m(t,e,n){var r,a;if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("traces must be defined.");for(Array.isArray(e)||(e=[e]),r=0;r=0&&s0){var l=w(t._boundingBoxMargins),s=l.left+l.right,c=l.bottom+l.top,u=o._container.node().getBoundingClientRect(),f=1-2*i.frameMargins;a=Math.round(f*(u.width-s)),r=Math.round(f*(u.height-c))}else n=window.getComputedStyle(t),r=parseFloat(n.height)||o.height,a=parseFloat(n.width)||o.width;return Math.abs(o.width-a)>1||Math.abs(o.height-r)>1?(o.height=t.layout.height=r,o.width=t.layout.width=a):"initial"!==o.autosize&&(delete e.autosize,o.autosize=t.layout.autosize=!0),R.sanitizeMargins(o),e}function M(t){var e=C.select(t),n=t._fullLayout;if(n._container=e.selectAll(".plot-container").data([0]),n._container.enter().insert("div",":first-child").classed("plot-container",!0).classed("plotly",!0),n._paperdiv=n._container.selectAll(".svg-container").data([0]),n._paperdiv.enter().append("div").classed("svg-container",!0).style("position","relative"),"initial"===n.autosize&&(k(t,{}),n.autosize=!0,t.layout.autosize=!0),n._glcontainer=n._paperdiv.selectAll(".gl-container").data([0]),n._glcontainer.enter().append("div").classed("gl-container",!0),n._geocontainer=n._paperdiv.selectAll(".geo-container").data([0]),n._geocontainer.enter().append("div").classed("geo-container",!0),n._paperdiv.selectAll(".main-svg").remove(),n._paper=n._paperdiv.insert("svg",":first-child").classed("main-svg",!0),n._toppaper=n._paperdiv.append("svg").classed("main-svg",!0),!n._uid){var r=[];C.selectAll("defs").each(function(){this.id&&r.push(this.id.split("-")[1])}),n._uid=P.randstr(r)}n._paperdiv.selectAll(".main-svg").attr(Q.svgAttrs),n._defs=n._paper.append("defs").attr("id","defs-"+n._uid),n._topdefs=n._toppaper.append("defs").attr("id","topdefs-"+n._uid),n._draggers=n._paper.append("g").classed("draglayer",!0);var a=n._paper.append("g").classed("layer-below",!0);n._imageLowerLayer=a.append("g").classed("imagelayer",!0),n._shapeLowerLayer=a.append("g").classed("shapelayer",!0);var o=N.Axes.getSubplots(t);o.join("")!==Object.keys(t._fullLayout._plots||{}).join("")&&A(t,o),n._has("cartesian")&&T(t,o),n._ternarylayer=n._paper.append("g").classed("ternarylayer",!0);var i=n._paper.selectAll(".layer-subplot");n._imageSubplotLayer=i.selectAll(".imagelayer"),n._shapeSubplotLayer=i.selectAll(".shapelayer");var l=n._paper.append("g").classed("layer-above",!0);n._imageUpperLayer=l.append("g").classed("imagelayer",!0),n._shapeUpperLayer=l.append("g").classed("shapelayer",!0),n._pielayer=n._paper.append("g").classed("pielayer",!0),n._glimages=n._paper.append("g").classed("glimages",!0),n._geoimages=n._paper.append("g").classed("geoimages",!0),n._infolayer=n._toppaper.append("g").classed("infolayer",!0),n._zoomlayer=n._toppaper.append("g").classed("zoomlayer",!0),n._hoverlayer=n._toppaper.append("g").classed("hoverlayer",!0),t.emit("plotly_framework");var s=P.syncOrAsync([L,function(){return N.Axes.doTicks(t,"redraw")},j.init],t);return s&&s.then&&t._promises.push(s),s}function A(t,e){function n(e,n){return function(){return N.Axes.getFromId(t,e,n)}}for(var r,a,o=t._fullLayout._plots={},i=0;i0,_=N.Axes.getSubplots(t).join(""),w=Object.keys(t._fullLayout._plots||{}).join(""),k=w===_;b?t.framework===M&&!x&&k||(t.framework=M,M(t)):k?x&&M(t):(t.framework=M,M(t)),x&&N.Axes.saveRangeInitial(t);var A=t._fullLayout,T=!t.calcdata||t.calcdata.length!==(t.data||[]).length;T&&h(t);for(var z=0;zQ.range[0]?[1,2]:[2,1]);else{var W=Q.range[0],J=Q.range[1];"log"===F?(W<=0&&J<=0&&i(U+".autorange",!0),W<=0?W=J/1e6:J<=0&&(J=W/1e6),i(U+".range[0]",Math.log(W)/Math.LN10),i(U+".range[1]",Math.log(J)/Math.LN10)):(i(U+".range[0]",Math.pow(10,W)),i(U+".range[1]",Math.pow(10,J)))}else i(U+".autorange",!0)}if("reverse"===Z)X.range?X.range.reverse():(i(U+".autorange",!0),X.range=[1,0]),G.autorange?M=!0:w=!0;else if("annotations"===j.parts[0]||"shapes"===j.parts[0]){var K=j.parts[1],tt=j.parts[0],et=v[tt]||[],nt=N[P.titleCase(tt)],rt=et[K]||{};2===j.parts.length&&("add"===y[O]||P.isPlainObject(y[O])?C[O]="remove":"remove"===y[O]?K===-1?(C[tt]=et,delete C[O]):C[O]=rt:P.log("???",y)),!l(rt,"x")&&!l(rt,"y")||P.containsAny(O,["color","opacity","align","dash"])||(M=!0),nt.draw(e,K,j.parts.slice(2).join("."),y[O]),delete y[O]}else if("images"===j.parts[0]){var at=P.objectFromPath(O,F); ++P.extendDeepAll(e.layout,at),H.supplyLayoutDefaults(e.layout,e._fullLayout),H.draw(e)}else if("mapbox"===j.parts[0]&&"layers"===j.parts[1]){P.extendDeepAll(e.layout,P.objectFromPath(O,F));var ot=(e._fullLayout.mapbox||{}).layers||[];for(D=j.parts[2]+1-ot.length,g=0;g1&&P.containsAny(j.parts[1],["tick","exponent","grid","zeroline"])?b=!0:O.indexOf(".linewidth")!==-1&&O.indexOf("axis")!==-1?b=_=!0:j.parts.length>1&&j.parts[1].indexOf("line")!==-1?_=!0:j.parts.length>1&&"mirror"===j.parts[1]?b=_=!0:"margin.pad"===O?b=_=!0:"margin"===j.parts[0]||"autorange"===j.parts[1]||"rangemode"===j.parts[1]||"type"===j.parts[1]||"domain"===j.parts[1]||O.match(/^(bar|box|font)/)?M=!0:["hovermode","dragmode"].indexOf(O)!==-1?A=!0:["hovermode","dragmode","height","width","autosize"].indexOf(O)===-1&&(w=!0):w=!0,j.set(F)}I.add(e,t,[e,C],t,[e,z]),y.autosize&&(y=k(e,y)),(y.height||y.width||y.autosize)&&(M=!0);var lt=Object.keys(y),st=[R.previousPromises];if(w||M)st.push(function(){return e.layout=void 0,M&&(e.calcdata=void 0),N.plot(e,"",v)});else if(lt.length&&(R.supplyDefaults(e),m=e._fullLayout,x&&st.push(function(){return V.draw(e),R.previousPromises(e)}),_&&st.push(L),b&&st.push(function(){return N.Axes.doTicks(e,"redraw"),S(e),R.previousPromises(e)}),A)){var ct;for($(e),N.Fx.supplyLayoutDefaults(e.layout,m,e._fullData),N.Fx.init(e),ct=R.getSubplotIds(m,"gl3d"),g=0;g1)};c(n.width)&&c(n.height)||l(new Error("Height and width should be pixel values."));var u=r.clone(e,{format:"png",height:n.height,width:n.width}),f=u.td;f.style.position="absolute",f.style.left="-5000px",document.body.appendChild(f);var d=r.getRedrawFunc(f);o.plot(f,u.data,u.layout,u.config).then(d).then(s).then(function(e){t(e)}).catch(function(t){l(t)})});return l}var a=t("fast-isnumeric"),o=t("../plotly"),i=t("../lib");e.exports=r},{"../lib":94,"../plotly":112,"../snapshot":144,"fast-isnumeric":10}],111:[function(t,e,n){"use strict";function r(t,e,n,a,o,c){c=c||[];for(var u=Object.keys(t),d=0;d1&&s.push(i("object","layout"))),d.supplyDefaults(c);for(var u=c._fullData,v=n.length,m=0;mc&&e=864e5?t._tickround="d":n>=36e5?t._tickround="H":n>=6e4?t._tickround="M":n>=1e3?t._tickround="S":t._tickround=3-Math.round(Math.log(n/2)/Math.LN10);else{x(n)||(n=Number(n.substr(1))),t._tickround=2-Math.floor(Math.log(n)/Math.LN10+.01),e="log"===t.type?Math.pow(10,Math.max(t.range[0],t.range[1])):Math.max(Math.abs(t.range[0]),Math.abs(t.range[1]));var r=Math.floor(Math.log(e)/Math.LN10+.01);Math.abs(r)>3&&("SI"===t.exponentformat||"B"===t.exponentformat?t._tickexponent=3*Math.round((r-1)/3):t._tickexponent=r)}else"M"===n.charAt(0)?t._tickround=2===n.length?"m":"y":t._tickround=null}function i(t,e){var n=t.match(B),r=new Date(e);if(n){var a=Math.min(+n[1]||6,6),o=String(e/1e3%1+2.0000005).substr(2,a).replace(/0+$/,"")||"0";return y.time.format(t.replace(B,o))(r)}return y.time.format(t)(r)}function l(t,e,n){var r=t.tickfont||t._gd._fullLayout.font;return{x:e,dx:0,dy:0,text:n||"",fontSize:r.size,font:r.family,fontColor:r.color}}function s(t,e,n,r){var a,o=e.x,l=t._tickround,s=new Date(o),c="";n&&t.hoverformat?a=i(t.hoverformat,o):t.tickformat?a=i(t.tickformat,o):(r&&(x(l)?l+=2:l={y:"m",m:"d",d:"H",H:"M",M:"S",S:2}[l]),"y"===l?a=D(s):"m"===l?a=I(s):(o!==t._tmin||n||(c="
"+D(s)),"d"===l?a=R(s):"H"===l?a=j(s):(o!==t._tmin||n||(c="
"+R(s)+", "+D(s)),a=F(s),"M"!==l&&(a+=q(s),"S"!==l&&(a+=d(m(o/1e3,1),t,"none",n).substr(1)))))),e.text=a+c}function c(t,e,n,r,a){var o=t.dtick,i=e.x;if(!r||"string"==typeof o&&"L"===o.charAt(0)||(o="L3"),t.tickformat||"string"==typeof o&&"L"===o.charAt(0))e.text=d(Math.pow(10,i),t,a,r);else if(x(o)||"D"===o.charAt(0)&&m(i+.01,1)<.1)if(["e","E","power"].indexOf(t.exponentformat)!==-1){var l=Math.round(i);0===l?e.text=1:1===l?e.text="10":l>1?e.text="10"+l+"":e.text="10\u2212"+-l+"",e.fontSize*=1.25}else e.text=d(Math.pow(10,i),t,"","fakehover"),"D1"===o&&"y"===t._id.charAt(0)&&(e.dy-=e.fontSize/6);else{if("D"!==o.charAt(0))throw"unrecognized dtick "+String(o);e.text=String(Math.round(Math.pow(10,m(i,1)))),e.fontSize*=.75}if("D1"===t.dtick){var s=String(e.text).charAt(0);"0"!==s&&"1"!==s||("y"===t._id.charAt(0)?e.dx-=e.fontSize/4:(e.dy+=e.fontSize/2,e.dx+=(t.range[1]>t.range[0]?1:-1)*e.fontSize*(i<0?.5:.25)))}}function u(t,e){var n=t._categories[Math.round(e.x)];void 0===n&&(n=""),e.text=String(n)}function f(t,e,n,r,a){"all"===t.showexponent&&Math.abs(e.x/t.dtick)<1e-6&&(a="hide"),e.text=d(e.x,t,a,r)}function d(t,e,n,r){var a=t<0,i=e._tickround,l=n||e.exponentformat||"B",s=e._tickexponent,c=e.tickformat;if(r){var u={exponentformat:e.exponentformat,dtick:"none"===e.showexponent?e.dtick:x(t)?Math.abs(t)||1:1,range:"none"===e.showexponent?e.range:[0,t||1]};o(u),i=(Number(u._tickround)||0)+4,s=u._tickexponent,e.hoverformat&&(c=e.hoverformat)}if(c)return y.format(c)(t).replace(/-/g,"\u2212");var f=Math.pow(10,-i)/2;if("none"===l&&(s=0),t=Math.abs(t),t12||s<-15)?t+="e"+p:"E"===l?t+="E"+p:"power"===l?t+="\xd710"+p+"":"B"===l&&9===s?t+="B":"SI"!==l&&"B"!==l||(t+=H[s/3+5])}return a?"\u2212"+t:t}function h(t,e){var n,r,a=[];for(n=0;n1)for(r=1;r2e-6||((n-t._forceTick0)/t._minDtick%1+1.000001)%1>2e-6)&&(t._minDtick=0)):t._minDtick=0},T.getAutoRange=function(t){var e,n=[],r=t._min[0].val,a=t._max[0].val;for(e=1;e0&&u>0&&f/u>d&&(s=i,c=l,d=f/u);if(r===a){var p=r-1,g=r+1;n="tozero"===t.rangemode?r<0?[p,0]:[0,g]:"nonnegative"===t.rangemode?[Math.max(0,p),Math.max(0,g)]:[p,g]}else d&&("linear"!==t.type&&"-"!==t.type||("tozero"===t.rangemode?(s.val>=0&&(s={val:0,pad:0}),c.val<=0&&(c={val:0,pad:0})):"nonnegative"===t.rangemode&&(s.val-d*s.pad<0&&(s={val:0,pad:0}),c.val<0&&(c={val:1,pad:0})),d=(c.val-s.val)/(t._length-s.pad-c.pad)),n=[s.val-d*s.pad,c.val+d*c.pad]);return n[0]===n[1]&&("tozero"===t.rangemode?n=n[0]<0?[n[0],0]:n[0]>0?[0,n[0]]:[0,1]:(n=[n[0]-1,n[0]+1],"nonnegative"===t.rangemode&&(n[0]=Math.max(0,n[0])))),h&&n.reverse(),n},T.doAutoRange=function(t){t._length||t.setScale();var e=t._min&&t._max&&t._min.length&&t._max.length;if(t.autorange&&e){t.range=T.getAutoRange(t);var n=t._gd.layout[t._name];n||(t._gd.layout[t._name]=n={}),n!==t&&(n.range=t.range.slice(),n.autorange=t.autorange)}},T.saveRangeInitial=function(t,e){for(var n=T.list(t,"",!0),r=!1,a=0;a=d?h=!1:l.val>=c&&l.pad<=d&&(t._min.splice(i,1),i--);h&&t._min.push({val:c,pad:y&&0===c?0:d})}if(r(u)){for(h=!0,i=0;i=u&&l.pad>=f?h=!1:l.val<=u&&l.pad<=f&&(t._max.splice(i,1),i--);h&&t._max.push({val:u,pad:y&&0===u?0:f})}}}if((t.autorange||t._needsExpand)&&e){t._min||(t._min=[]),t._max||(t._max=[]),n||(n={}),t._m||t.setScale();var o,i,l,s,c,u,f,d,h,p,g,v=e.length,m=n.padded?.05*t._length:0,y=n.tozero&&("linear"===t.type||"-"===t.type),b=r((t._m>0?n.ppadplus:n.ppadminus)||n.ppad||0),_=r((t._m>0?n.ppadminus:n.ppadplus)||n.ppad||0),w=r(n.vpadplus||n.vpad),k=r(n.vpadminus||n.vpad);for(o=0;o<6;o++)a(o);for(o=v-1;o>5;o--)a(o)}},T.autoBin=function(t,e,n,r){function a(t){return(1+100*(t-h)/f.dtick)%100<2}var o=_.aggNums(Math.min,null,t),i=_.aggNums(Math.max,null,t);if("category"===e.type)return{start:o-.5,end:i+.5,size:1};var l;if(n)l=(i-o)/n;else{var s=_.distinctVals(t),c=Math.pow(10,Math.floor(Math.log(s.minDiff)/Math.LN10)),u=c*_.roundUp(s.minDiff/c,[.9,1.9,4.9,9.9],!0);l=Math.max(u,2*_.stdev(t)/Math.pow(t.length,r?.25:.4))}var f={type:"log"===e.type?"linear":e.type,range:[o,i]};T.autoTicks(f,l);var d,h=T.tickIncrement(T.tickFirst(f),f.dtick,"reverse");if("number"==typeof f.dtick){for(var p=0,g=0,v=0,m=0,y=0;y.3*b||a(o)||a(i))){var w=f.dtick/2;h+=h+w0&&t.dtick<2*t._minDtick&&(t.dtick=t._minDtick,t.tick0=t._forceTick0)}t.tick0||(t.tick0="date"===t.type?new Date(2e3,0,1).getTime():0),o(t),t._tmin=T.tickFirst(t);var a=t.range[1]=l:s<=l)&&(i.push(s),!(i.length>1e3));s=T.tickIncrement(s,t.dtick,a));t._tmax=i[i.length-1];for(var c=new Array(i.length),u=0;u157788e5?(e/=315576e5,n=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick="M"+12*a(e,n,S)):e>12096e5?(e/=26298e5,t.dtick="M"+a(e,1,C)):e>432e5?(t.dtick=a(e,864e5,O),t.tick0=new Date(2e3,0,2).getTime()):e>18e5?t.dtick=a(e,36e5,C):e>3e4?t.dtick=a(e,6e4,E):e>500?t.dtick=a(e,1e3,E):(n=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick=a(e,n,S));else if("log"===t.type)if(t.tick0=0,e>.7)t.dtick=Math.ceil(e);else if(Math.abs(t.range[1]-t.range[0])<1){var r=1.5*Math.abs((t.range[1]-t.range[0])/e);e=Math.abs(Math.pow(10,t.range[1])-Math.pow(10,t.range[0]))/r,n=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick="L"+a(e,n,S)}else t.dtick=e>.3?"D2":"D1";else"category"===t.type?(t.tick0=0,t.dtick=Math.ceil(Math.max(e,1))):(t.tick0=0,n=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick=a(e,n,S));if(0===t.dtick&&(t.dtick=1),!x(t.dtick)&&"string"!=typeof t.dtick){var o=t.dtick;throw t.dtick=1,"ax.dtick error: "+String(o)}},T.tickIncrement=function(t,e,n){var r=n?-1:1;if(x(e))return t+r*e;var a=e.charAt(0),o=r*Number(e.substr(1));if("M"===a){var i=new Date(t);return i.setMonth(i.getMonth()+o)}if("L"===a)return Math.log(Math.pow(10,t)+o)/Math.LN10;if("D"===a){var l="D2"===e?P:N,s=t+.01*r,c=_.roundUp(m(s,1),l,n);return Math.floor(s)+Math.log(y.round(Math.pow(10,c),1))/Math.LN10}throw"unrecognized dtick "+String(e)},T.tickFirst=function(t){var e=t.range[1]r:c1&&e2*r}function u(t){for(var e,n=Math.max(1,(t.length-1)/1e3),r=0,a=0,o=0;o2*r}var f=t("fast-isnumeric"),d=t("tinycolor2").mix,h=t("../../lib"),p=t("../plots"),g=t("../../components/color/attributes").lightFraction,v=t("./layout_attributes"),m=t("./tick_value_defaults"),y=t("./tick_mark_defaults"),x=t("./tick_label_defaults"),b=t("./category_order_defaults"),_=t("./set_convert"),w=t("./ordered_categories"),k=t("./clean_datum"),M=t("./axis_ids");e.exports=function(t,e,n,a){function o(n,r){return h.coerce2(t,e,v,n,r)}var i=a.letter,l=a.font||{},s="Click to enter "+(a.title||i.toUpperCase()+" axis")+" title";a.name&&(e._name=a.name,e._id=M.name2id(a.name));var c=n("type");"-"===c&&(r(e,a.data),"-"===e.type?e.type="linear":c=t.type=e.type),_(e);var u=n("color"),p=u===t.color?u:l.color;n("title",s),h.coerceFont(n,"titlefont",{family:l.family,size:Math.round(1.2*l.size),color:p});var k=2===(t.range||[]).length&&f(t.range[0])&&f(t.range[1]),A=n("autorange",!k);A&&n("rangemode");var T=n("range",[-1,"x"===i?6:4]);T[0]===T[1]&&(e.range=[T[0]-1,T[0]+1]),h.noneOrAll(t.range,e.range,[0,1]),n("fixedrange"),m(t,e,n,c),x(t,e,n,c,a),y(t,e,n,a),b(t,e,n);var L=o("linecolor",u),z=o("linewidth"),S=n("showline",!!L||!!z);S||(delete e.linecolor,delete e.linewidth),(S||e.ticks)&&n("mirror");var C=o("gridcolor",d(u,a.bgColor,g).toRgbString()),E=o("gridwidth"),O=n("showgrid",a.showGrid||!!C||!!E);O||(delete e.gridcolor,delete e.gridwidth);var N=o("zerolinecolor",u),P=o("zerolinewidth"),D=n("zeroline",a.showGrid||!!N||!!P);return D||(delete e.zerolinecolor,delete e.zerolinewidth),e._initialCategories="category"===c?w(i,e.categoryorder,e.categoryarray,a.data):[],e}},{"../../components/color/attributes":17,"../../lib":94,"../plots":135,"./axis_ids":117,"./category_order_defaults":118,"./clean_datum":119,"./layout_attributes":124,"./ordered_categories":126,"./set_convert":129,"./tick_label_defaults":130,"./tick_mark_defaults":131,"./tick_value_defaults":132,"fast-isnumeric":10,tinycolor2:13}],117:[function(t,e,n){"use strict";function r(t,e,n){function r(t,n){for(var r=Object.keys(t),a=/^[xyz]axis[0-9]*/,o=[],i=0;i0;o&&(r="array");var i=n("categoryorder",r);"array"===i&&n("categoryarray"),o||"array"!==i||(e.categoryorder="trace")}}},{}],119:[function(t,e,n){"use strict";var r=t("fast-isnumeric"),a=t("../../lib");e.exports=function(t){try{if("object"==typeof t&&null!==t&&t.getTime)return a.ms2DateTime(t);if("string"!=typeof t&&!r(t))return"";t=t.toString().replace(/['"%,$# ]/g,"")}catch(e){a.error(e,t)}return t}},{"../../lib":94,"fast-isnumeric":10}],120:[function(t,e,n){"use strict";e.exports={idRegex:{x:/^x([2-9]|[1-9][0-9]+)?$/,y:/^y([2-9]|[1-9][0-9]+)?$/},attrRegex:{x:/^xaxis([2-9]|[1-9][0-9]+)?$/,y:/^yaxis([2-9]|[1-9][0-9]+)?$/},BADNUM:void 0,xAxisMatch:/^xaxis[0-9]*$/,yAxisMatch:/^yaxis[0-9]*$/,AX_ID_PATTERN:/^[xyz][0-9]*$/,AX_NAME_PATTERN:/^[xyz]axis[0-9]*$/,DBLCLICKDELAY:300,MINDRAG:8,MINSELECT:12,MINZOOM:20,DRAGGERSIZE:20,MAXDIST:20,YANGLE:60,HOVERARROWSIZE:6,HOVERTEXTPAD:3,HOVERFONTSIZE:13,HOVERFONT:"Arial, sans-serif",HOVERMINTIME:50,BENDPX:1.5,REDRAWDELAY:50}},{}],121:[function(t,e,n){"use strict";function r(t,e){var n,r=t.range[e],a=Math.abs(r-t.range[1-e]);return"date"===t.type?u.ms2DateTime(r,a):"log"===t.type?(n=Math.ceil(Math.max(0,-Math.log(a)/Math.LN10))+3,l.format("."+n+"g")(Math.pow(10,r))):(n=Math.floor(Math.log(Math.abs(r))/Math.LN10)-Math.floor(Math.log(a)/Math.LN10)+4,l.format("."+String(n)+"g")(r))}function a(t,e){return t?"nsew"===t?"pan"===e?"move":"crosshair":t.toLowerCase()+"-resize":"pointer"}function o(t){l.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}function i(t){var e=["lasso","select"];return e.indexOf(t)!==-1}var l=t("d3"),s=t("tinycolor2"),c=t("../../plotly"),u=t("../../lib"),f=t("../../lib/svg_text_utils"),d=t("../../components/color"),h=t("../../components/drawing"),p=t("../../lib/setcursor"),g=t("../../components/dragelement"),v=t("./axes"),m=t("./select"),y=t("./constants"),x=!0;e.exports=function(t,e,n,l,b,_,w,k){function M(t,e){for(var n=0;n.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("transform","translate("+pt+", "+gt+")").attr("d",st+"Z"),dt=ht.append("path").attr("class","zoombox-corners").style({fill:d.background,stroke:d.defaultLine,"stroke-width":1,opacity:0}).attr("transform","translate("+pt+", "+gt+")").attr("d","M0,0Z"),L();for(var o=0;o.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),dt.transition().style("opacity",1).duration(200),ct=!0)}function S(t,e,n){var r,a,o;for(r=0;rzoom back out","long"),x=!1)))}function E(e,n){var a=1===(w+k).length;if(e)I();else if(2!==n||a){if(1===n&&a){var o=w?B[0]:q[0],i="s"===w||"w"===k?0:1,l=o._name+".range["+i+"]",s=r(o,i),u="left",d="middle";if(o.fixedrange)return;w?(d="n"===w?"top":"bottom","right"===o.side&&(u="right")):"e"===k&&(u="right"),et.call(f.makeEditable,null,{immediate:!0,background:j.paper_bgcolor,text:String(s),fill:o.tickfont?o.tickfont.color:"#444",horizontalAlign:u,verticalAlign:d}).on("edit",function(e){var n="category"===o.type?o.c2l(e):o.d2l(e);void 0!==n&&c.relayout(t,l,n)})}}else D()}function O(e){function n(t,e,n){if(!t.fixedrange){A(t.range);var r=t.range,a=r[0]+(r[1]-r[0])*e;t.range=[a+(r[0]-a)*n,a+(r[1]-a)*n]}}if(t._context.scrollZoom||j._enablescrollzoom){var r=t.querySelector(".plotly");if(!(r.scrollHeight-r.clientHeight>10||r.scrollWidth-r.clientWidth>10)){clearTimeout(mt);var a=-e.deltaY;if(isFinite(a)||(a=e.wheelDelta/10),!isFinite(a))return void u.log("Did not find wheel motion attributes: ",e);var o,i=Math.exp(-Math.min(Math.max(a,-20),20)/100),l=xt.draglayer.select(".nsewdrag").node().getBoundingClientRect(),s=(e.clientX-l.left)/l.width,c=vt[0]+vt[2]*s,f=(l.bottom-e.clientY)/l.height,d=vt[1]+vt[3]*(1-f);if(k){for(o=0;o=0?Math.min(t,.9):1/(1/Math.max(t,-.3)+3.222))}function a(t,e,n){for(var a=1-e,o=0,i=0;i0;r--)n.push(e);return n}function a(t,e){for(var n=[],r=0;rX.width||U<0||U>X.height)return _.unhoverRaw(t,e)}else Y="xpx"in e?e.xpx:M[0]._length/2,U="ypx"in e?e.ypx:A[0]._length/2;if(E="xval"in e?r(o,e.xval):a(M,Y),O="yval"in e?r(o,e.yval):a(A,U),!g(E[0])||!g(O[0]))return v.warn("Plotly.Fx.hover failed",e,t),_.unhoverRaw(t,e)}var G=1/0;for(P=0;P1||I.hoverinfo.indexOf("name")!==-1?I.name:void 0,index:!1,distance:Math.min(G,k.MAXDIST),color:x.defaultLine,x0:void 0,x1:void 0,y0:void 0,y1:void 0,xLabelVal:void 0,yLabelVal:void 0,zLabelVal:void 0,text:void 0},H=V.length,"array"===j){var $=e[P];"pointNumber"in $?(B.index=$.pointNumber,j="closest"):(j="","xval"in $&&(F=$.xval,j="x"),"yval"in $&&(q=$.yval,j=j?"closest":"y"))}else F=E[R],q=O[R];if(I._module&&I._module.hoverPoints){var Q=I._module.hoverPoints(B,F,q,j);if(Q)for(var W,J=0;JH&&(V.splice(0,H),G=V[0].distance)}if(0===V.length)return _.unhoverRaw(t,e);var K="y"===C&&Z.length>1;V.sort(function(t,e){return t.distance-e.distance});var tt=x.combine(i.plot_bgcolor||x.background,i.paper_bgcolor),et={hovermode:C,rotateLabels:K,bgColor:tt,container:i._hoverlayer,outerContainer:i._paperdiv},nt=c(V,et);u(V,K?"xa":"ya"),f(nt,K);var rt=t._hoverdata,at=[];for(N=0;N128?"#000":x.background;if(t.name&&void 0===t.zLabelVal){var u=document.createElement("p");u.innerHTML=t.name,n=u.textContent||"",n.length>15&&(n=n.substr(0,12)+"...")}void 0!==t.extraText&&(r+=t.extraText),void 0!==t.zLabel?(void 0!==t.xLabel&&(r+="x: "+t.xLabel+"
"),void 0!==t.yLabel&&(r+="y: "+t.yLabel+"
"),r+=(r?"z: ":"")+t.zLabel):A&&t[a+"Label"]===g?r=t[("x"===a?"y":"x")+"Label"]||"":void 0===t.xLabel?void 0!==t.yLabel&&(r=t.yLabel):r=void 0===t.yLabel?t.xLabel:"("+t.xLabel+", "+t.yLabel+")",t.text&&!Array.isArray(t.text)&&(r+=(r?"
":"")+t.text),""===r&&(""===n&&e.remove(),r=n);var f=e.select("text.nums").style("fill",c).call(b.setPosition,0,0).text(r).attr("data-notex",1).call(y.convertToTspans);f.selectAll("tspan.line").call(b.setPosition,0,0);var d=e.select("text.name"),v=0;n&&n!==r?(d.style("fill",s).text(n).call(b.setPosition,0,0).attr("data-notex",1).call(y.convertToTspans),d.selectAll("tspan.line").call(b.setPosition,0,0),v=d.node().getBoundingClientRect().width+2*O):(d.remove(),e.select("rect").remove()),e.select("path").style({fill:s,stroke:c});var m,k,L=f.node().getBoundingClientRect(),z=t.xa._offset+(t.x0+t.x1)/2,S=t.ya._offset+(t.y0+t.y1)/2,C=Math.abs(t.x1-t.x0),N=Math.abs(t.y1-t.y0),P=L.width+E+O+v;t.ty0=_-L.top,t.bx=L.width+2*O,t.by=L.height+2*O,t.anchor="start",t.txwidth=L.width,t.tx2width=v,t.offset=0,o?(t.pos=z,m=S+N/2+P<=M,k=S-N/2-P>=0,"top"!==t.idealAlign&&m||!k?m?(S+=N/2,t.anchor="start"):t.anchor="middle":(S-=N/2,t.anchor="end")):(t.pos=S,m=z+C/2+P<=w,k=z-C/2-P>=0,"left"!==t.idealAlign&&m||!k?m?(z+=C/2,t.anchor="start"):t.anchor="middle":(z-=C/2,t.anchor="end")),f.attr("text-anchor",t.anchor),v&&d.attr("text-anchor",t.anchor),e.attr("transform","translate("+z+","+S+")"+(o?"rotate("+T+")":""))}),S}function u(t,e){function n(t){var e=t[0],n=t[t.length-1];if(a=e.pmin-e.pos-e.dp+e.size,o=n.pos+n.dp+n.size-e.pmax,a>.01){for(l=t.length-1;l>=0;l--)t[l].dp+=a;r=!1}if(!(o<.01)){if(a<-.01){for(l=t.length-1;l>=0;l--)t[l].dp-=o;r=!1}if(r){var c=0;for(i=0;ie.pmax&&c++;for(i=t.length-1;i>=0&&!(c<=0);i--)s=t[i],s.pos>e.pmax-1&&(s.del=!0,c--);for(i=0;i=0;l--)t[l].dp-=o;for(i=t.length-1;i>=0&&!(c<=0);i--)s=t[i],s.pos+s.dp+s.size>e.pmax&&(s.del=!0,c--)}}}for(var r,a,o,i,l,s,c,u=0,f=t.map(function(t,n){var r=t[e];return[{i:n,dp:0,pos:t.pos,posref:t.posref,size:t.by*("x"===r._id.charAt(0)?z:1)/2,pmin:r._offset,pmax:r._offset+r._length}]}).sort(function(t,e){return t[0].posref-e[0].posref});!r&&u<=t.length;){for(u++,r=!0,i=0;i.01&&p.pmin===g.pmin&&p.pmax===g.pmax){for(l=h.length-1;l>=0;l--)h[l].dp+=a;for(d.push.apply(d,h),f.splice(i+1,1),c=0,l=d.length-1;l>=0;l--)c+=d[l].dp;for(o=c/d.length,l=d.length-1;l>=0;l--)d[l].dp-=o;r=!1}else i++}f.forEach(n)}for(i=f.length-1;i>=0;i--){var v=f[i];for(l=v.length-1;l>=0;l--){var m=v[l],y=t[m.i];y.offset=m.dp,y.del=m.del}}}function f(t,e){t.each(function(t){var n=h.select(this);if(t.del)return void n.remove();var r="end"===t.anchor?-1:1,a=n.select("text.nums"),o={start:1,end:-1,middle:0}[t.anchor],i=o*(E+O),l=i+o*(t.txwidth+O),s=0,c=t.offset;"middle"===t.anchor&&(i-=t.tx2width/2,l-=t.tx2width/2),e&&(c*=-C,s=t.offset*S),n.select("path").attr("d","middle"===t.anchor?"M-"+t.bx/2+",-"+t.by/2+"h"+t.bx+"v"+t.by+"h-"+t.bx+"Z":"M0,0L"+(r*E+s)+","+(E+c)+"v"+(t.by/2-E)+"h"+r*t.bx+"v-"+t.by+"H"+(r*E+s)+"V"+(c-E)+"Z"), ++a.call(b.setPosition,i+s,c+t.ty0-t.by/2+O).selectAll("tspan.line").attr({x:a.attr("x"),y:a.attr("y")}),t.tx2width&&(n.select("text.name, text.name tspan.line").call(b.setPosition,l+o*O+s,c+t.ty0-t.by/2+O),n.select("rect").call(b.setRect,l+(o-1)*t.tx2width/2+s,c-t.by/2-1,t.tx2width,t.by+2))})}function d(t,e,n){if(!e.target)return!1;if(!n||n.length!==t._hoverdata.length)return!0;for(var r=n.length-1;r>=0;r--){var a=n[r],o=t._hoverdata[r];if(a.curveNumber!==o.curveNumber||String(a.pointNumber)!==String(o.pointNumber))return!0}return!1}var h=t("d3"),p=t("tinycolor2"),g=t("fast-isnumeric"),v=t("../../lib"),m=t("../../lib/events"),y=t("../../lib/svg_text_utils"),x=t("../../components/color"),b=t("../../components/drawing"),_=t("../../components/dragelement"),w=t("./axes"),k=t("./constants"),M=t("./dragbox"),A=e.exports={};A.unhover=_.unhover,A.layoutAttributes={dragmode:{valType:"enumerated",values:["zoom","pan","select","lasso","orbit","turntable"],dflt:"zoom"},hovermode:{valType:"enumerated",values:["x","y","closest",!1]}},A.supplyLayoutDefaults=function(t,e,n){function r(n,r){return v.coerce(t,e,A.layoutAttributes,n,r)}r("dragmode");var a;if(e._has("cartesian")){var o=e._isHoriz=A.isHoriz(n);a=o?"y":"x"}else a="closest";r("hovermode",a)},A.isHoriz=function(t){for(var e=!0,n=0;nt._lastHoverTime+k.HOVERMINTIME?(i(t,e,n),void(t._lastHoverTime=Date.now())):void(t._hoverTimer=setTimeout(function(){i(t,e,n),t._lastHoverTime=Date.now(),t._hoverTimer=void 0},k.HOVERMINTIME))},A.getDistanceFunction=function(t,e,n,r){return"closest"===t?r||o(e,n):"x"===t?e:n},A.getClosest=function(t,e,n){if(n.index!==!1)n.index>=0&&n.indexf[1]-.01&&(e.domain=[0,1]),a.noneOrAll(t.domain,e.domain,[0,1])}return e}},{"../../lib":94,"fast-isnumeric":10}],128:[function(t,e,n){"use strict";function r(t){return t._id}var a=t("../../lib/polygon"),o=t("../../components/color"),i=t("./axes"),l=t("./constants"),s=a.filter,c=a.tester,u=l.MINSELECT;e.exports=function(t,e,n,a,f){function d(t){var e="y"===t._id.charAt(0)?1:0;return function(n){return t.p2d(n[e])}}function h(t,e){return t-e}var p,g=a.gd._fullLayout._zoomlayer,v=a.element.getBoundingClientRect(),m=a.plotinfo.x()._offset,y=a.plotinfo.y()._offset,x=e-v.left,b=n-v.top,_=x,w=b,k="M"+x+","+b,M=a.xaxes[0]._length,A=a.yaxes[0]._length,T=a.xaxes.map(r),L=a.yaxes.map(r),z=a.xaxes.concat(a.yaxes);"lasso"===f&&(p=s([[x,b]],l.BENDPX));var S=g.selectAll("path.select-outline").data([1,2]);S.enter().append("path").attr("class",function(t){return"select-outline select-outline-"+t}).attr("transform","translate("+m+", "+y+")").attr("d",k+"Z");var C,E,O,N,P,D=g.append("path").attr("class","zoombox-corners").style({fill:o.background,stroke:o.defaultLine,"stroke-width":1}).attr("transform","translate("+m+", "+y+")").attr("d","M0,0Z"),I=[],R=a.gd,j=[];for(C=0;C0)return Math.log(e)/Math.LN10;if(e<=0&&n&&t.range&&2===t.range.length){var r=t.range[0],a=t.range[1];return.5*(r+a-3*u*Math.abs(r-a))}return i.BADNUM}function n(t){return Math.pow(10,t)}function c(t){return a(t)?Number(t):i.BADNUM}var u=10;if(t.c2l="log"===t.type?e:c,t.l2c="log"===t.type?n:c,t.l2d=function(e){return t.c2d(t.l2c(e))},t.p2d=function(e){return t.l2d(t.p2l(e))},t.setScale=function(){var e,n=t._gd._fullLayout._size;if(t._categories||(t._categories=[]),t.overlaying){var r=s.getFromId(t._gd,t.overlaying);t.domain=r.domain}for(t.range&&2===t.range.length&&t.range[0]!==t.range[1]||(t.range=[-1,1]),e=0;e<2;e++)a(t.range[e])||(t.range[e]=a(t.range[1-e])?t.range[1-e]*(e?10:.1):e?1:-1),t.range[e]<-(Number.MAX_VALUE/2)?t.range[e]=-(Number.MAX_VALUE/2):t.range[e]>Number.MAX_VALUE/2&&(t.range[e]=Number.MAX_VALUE/2);if("y"===t._id.charAt(0)?(t._offset=n.t+(1-t.domain[1])*n.h,t._length=n.h*(t.domain[1]-t.domain[0]),t._m=t._length/(t.range[0]-t.range[1]),t._b=-t._m*t.range[1]):(t._offset=n.l+t.domain[0]*n.w,t._length=n.w*(t.domain[1]-t.domain[0]),t._m=t._length/(t.range[1]-t.range[0]),t._b=-t._m*t.range[0]),!isFinite(t._m)||!isFinite(t._b))throw o.notifier("Something went wrong with axis scaling","long"),t._gd._replotting=!1,new Error("axis scaling")},t.l2p=function(e){return a(e)?r.round(t._b+t._m*e,2):i.BADNUM},t.p2l=function(e){return(e-t._b)/t._m},t.c2p=function(e,n){return t.l2p(t.c2l(e,n))},t.p2c=function(e){return t.l2c(t.p2l(e))},["linear","log","-"].indexOf(t.type)!==-1)t.c2d=c,t.d2c=function(t){return t=l(t),a(t)?Number(t):i.BADNUM},t.d2l=function(e,n){return"log"===t.type?t.c2l(t.d2c(e),n):t.d2c(e)};else if("date"===t.type){if(t.c2d=function(t){return a(t)?o.ms2DateTime(t):i.BADNUM},t.d2c=function(t){return a(t)?Number(t):o.dateTime2ms(t)},t.d2l=t.d2c,t.range&&t.range.length>1)try{var f=t.range.map(o.dateTime2ms);!a(t.range[0])&&a(f[0])&&(t.range[0]=f[0]),!a(t.range[1])&&a(f[1])&&(t.range[1]=f[1])}catch(e){o.error(e,t.range)}}else"category"===t.type&&(t.c2d=function(e){return t._categories[Math.round(e)]},t.d2c=function(e){null!==e&&void 0!==e&&t._categories.indexOf(e)===-1&&t._categories.push(e);var n=t._categories.indexOf(e);return n===-1?i.BADNUM:n},t.d2l=t.d2c);t.makeCalcdata=function(e,n){var r,a,o;if(n in e)for(r=e[n],a=new Array(r.length),o=0;o=e.width-20?(o["text-anchor"]="start",o.x=5):(o["text-anchor"]="end",o.x=e._paper.attr("width")-7),n.attr(o);var i=n.select(".js-link-to-tool"),l=n.select(".js-link-spacer"),c=n.select(".js-sourcelinks");t._context.showSources&&t._context.showSources(t),t._context.showLink&&a(t,i),l.text(i.text()&&c.text()?" - ":"")},h.sendDataToCloud=function(t){t.emit("plotly_beforeexport");var e=window.PLOTLYENV&&window.PLOTLYENV.BASE_URL||"https://plot.ly",n=s.select(t).append("div").attr("id","hiddenform").style("display","none"),r=n.append("form").attr({action:e+"/external",method:"post",target:"_blank"}),a=r.append("input").attr({type:"text",name:"data"});return a.node().value=h.graphJson(t,!1,"keepdata"),r.node().submit(),n.remove(),t.emit("plotly_afterexport"),!1},h.supplyDefaults=function(t){var e,n=t._fullLayout||{},r=t._fullLayout={},a=t.layout||{},i=t._fullData||[],l=t._fullData=[],s=t.data||[];h.supplyLayoutGlobalDefaults(a,r),r._dataLength=s.length,h.supplyDataDefaults(s,l,r),r._has=h._hasPlotType.bind(r);var c=r._modules;for(e=0;e.5*r.width&&(n.l=n.r=0),n.b+n.t>.5*r.height&&(n.b=n.t=0),r._pushmargin[e]={l:{val:n.x,size:n.l+a},r:{val:n.x,size:n.r+a},b:{val:n.y,size:n.b+a},t:{val:n.y,size:n.t+a}}}else delete r._pushmargin[e];t._replotting||h.doAutoMargin(t)}},h.doAutoMargin=function(t){var e=t._fullLayout;e._size||(e._size={}),e._pushmargin||(e._pushmargin={});var n=e._size,r=JSON.stringify(n),a=Math.max(e.margin.l||0,0),o=Math.max(e.margin.r||0,0),i=Math.max(e.margin.t||0,0),l=Math.max(e.margin.b||0,0),s=e._pushmargin;if(e.margin.autoexpand!==!1&&(s.base={l:{val:0,size:a},r:{val:1,size:o},t:{val:1,size:i},b:{val:0,size:l}},Object.keys(s).forEach(function(t){var n=s[t].l||{},r=s[t].b||{},u=n.val,f=n.size,d=r.val,h=r.size;Object.keys(s).forEach(function(t){if(c(f)&&s[t].r){var n=s[t].r.val,r=s[t].r.size;if(n>u){var p=(f*n+(r-e.width)*u)/(n-u),g=(r*(1-u)+(f-e.width)*(1-n))/(n-u);p>=0&&g>=0&&p+g>a+o&&(a=p,o=g)}}if(c(h)&&s[t].t){var v=s[t].t.val,m=s[t].t.size;if(v>d){var y=(h*v+(m-e.height)*d)/(v-d),x=(m*(1-d)+(h-e.height)*(1-v))/(v-d);y>=0&&x>=0&&y+x>l+i&&(l=y,i=x)}}})})),n.l=Math.round(a),n.r=Math.round(o),n.t=Math.round(i),n.b=Math.round(l),n.p=Math.round(e.margin.pad),n.w=Math.round(e.width)-n.l-n.r,n.h=Math.round(e.height)-n.t-n.b,!t._replotting&&"{}"!==r&&r!==JSON.stringify(e._size))return u.plot(t)},h.graphJson=function(t,e,n,r,a){function o(t){if("function"==typeof t)return null;if(f.isPlainObject(t)){var e,r,a={}; ++for(e in t)if("function"!=typeof t[e]&&["_","["].indexOf(e.charAt(0))===-1){if("keepdata"===n){if("src"===e.substr(e.length-3))continue}else if("keepstream"===n){if(r=t[e+"src"],"string"==typeof r&&r.indexOf(":")>0&&!f.isPlainObject(t.stream))continue}else if("keepall"!==n&&(r=t[e+"src"],"string"==typeof r&&r.indexOf(":")>0))continue;a[e]=o(t[e])}return a}return Array.isArray(t)?t.map(o):t&&t.getTime?f.ms2DateTime(t):t}(a&&e&&!t._fullData||a&&!e&&!t._fullLayout)&&h.supplyDefaults(t);var i=a?t._fullData:t.data,l=a?t._fullLayout:t.layout,s={data:(i||[]).map(function(t){var n=o(t);return e&&delete n.fit,n})};return e||(s.layout=o(l)),t.framework&&t.framework.isPolar&&(s=t.framework.getConfig()),"object"===r?s:JSON.stringify(s)}},{"../components/color":18,"../lib":94,"../plotly":112,"./attributes":113,"./font_attributes":133,"./layout_attributes":134,d3:7,"fast-isnumeric":10}],136:[function(t,e,n){"use strict";var r=t("../../traces/scatter/attributes"),a=r.marker;e.exports={r:r.r,t:r.t,marker:{color:a.color,size:a.size,symbol:a.symbol,opacity:a.opacity}}},{"../../traces/scatter/attributes":172}],137:[function(t,e,n){"use strict";function r(t,e){var n={showline:{valType:"boolean"},showticklabels:{valType:"boolean"},tickorientation:{valType:"enumerated",values:["horizontal","vertical"]},ticklen:{valType:"number",min:0},tickcolor:{valType:"color"},ticksuffix:{valType:"string"},endpadding:{valType:"number"},visible:{valType:"boolean"}};return o({},e,n)}var a=t("../cartesian/layout_attributes"),o=t("../../lib/extend").extendFlat,i=o({},a.domain,{});e.exports={radialaxis:r("radial",{range:{valType:"info_array",items:[{valType:"number"},{valType:"number"}]},domain:i,orientation:{valType:"number"}}),angularaxis:r("angular",{range:{valType:"info_array",items:[{valType:"number",dflt:0},{valType:"number",dflt:360}]},domain:i}),layout:{direction:{valType:"enumerated",values:["clockwise","counterclockwise"]},orientation:{valType:"angle"}}}},{"../../lib/extend":93,"../cartesian/layout_attributes":124}],138:[function(t,e,n){var r=t("../../plotly"),a=t("d3"),o=e.exports={version:"0.2.2",manager:t("./micropolar_manager")},i=r.Lib.extendDeepAll;o.Axis=function(){function t(t){n=t||n;var c=s.data,f=s.layout;return("string"==typeof n||n.nodeName)&&(n=a.select(n)),n.datum(c).each(function(t,n){function s(t,e){return l(t)%360+f.orientation}var c=t.slice();u={data:o.util.cloneJson(c),layout:o.util.cloneJson(f)};var d=0;c.forEach(function(t,e){t.color||(t.color=f.defaultColorRange[d],d=(d+1)%f.defaultColorRange.length),t.strokeColor||(t.strokeColor="LinePlot"===t.geometry?t.color:a.rgb(t.color).darker().toString()),u.data[e].color=t.color,u.data[e].strokeColor=t.strokeColor,u.data[e].strokeDash=t.strokeDash,u.data[e].strokeSize=t.strokeSize});var h=c.filter(function(t,e){var n=t.visible;return"undefined"==typeof n||n===!0}),p=!1,g=h.map(function(t,e){return p=p||"undefined"!=typeof t.groupId,t});if(p){var v=a.nest().key(function(t,e){return"undefined"!=typeof t.groupId?t.groupId:"unstacked"}).entries(g),m=[],y=v.map(function(t,e){if("unstacked"===t.key)return t.values;var n=t.values[0].r.map(function(t,e){return 0});return t.values.forEach(function(t,e,r){t.yStack=[n],m.push(n),n=o.util.sumArrays(t.r,n)}),t.values});h=a.merge(y)}h.forEach(function(t,e){t.t=Array.isArray(t.t[0])?t.t:[t.t],t.r=Array.isArray(t.r[0])?t.r:[t.r]});var x=Math.min(f.width-f.margin.left-f.margin.right,f.height-f.margin.top-f.margin.bottom)/2;x=Math.max(10,x);var b,_=[f.margin.left+x,f.margin.top+x];if(p){var w=a.max(o.util.sumArrays(o.util.arrayLast(h).r[0],o.util.arrayLast(m)));b=[0,w]}else b=a.extent(o.util.flattenArray(h.map(function(t,e){return t.r})));f.radialAxis.domain!=o.DATAEXTENT&&(b[0]=0),r=a.scale.linear().domain(f.radialAxis.domain!=o.DATAEXTENT&&f.radialAxis.domain?f.radialAxis.domain:b).range([0,x]),u.layout.radialAxis.domain=r.domain();var k,M=o.util.flattenArray(h.map(function(t,e){return t.t})),A="string"==typeof M[0];A&&(M=o.util.deduplicate(M),k=M.slice(),M=a.range(M.length),h=h.map(function(t,e){var n=t;return t.t=[M],p&&(n.yStack=t.yStack),n}));var T=h.filter(function(t,e){return"LinePlot"===t.geometry||"DotPlot"===t.geometry}).length===h.length,L=null===f.needsEndSpacing?A||!T:f.needsEndSpacing,z=f.angularAxis.domain&&f.angularAxis.domain!=o.DATAEXTENT&&!A&&f.angularAxis.domain[0]>=0,S=z?f.angularAxis.domain:a.extent(M),C=Math.abs(M[1]-M[0]);T&&!A&&(C=0);var E=S.slice();L&&A&&(E[1]+=C);var O=f.angularAxis.ticksCount||4;O>8&&(O=O/(O/8)+O%8),f.angularAxis.ticksStep&&(O=(E[1]-E[0])/O);var N=f.angularAxis.ticksStep||(E[1]-E[0])/(O*(f.minorTicks+1));k&&(N=Math.max(Math.round(N),1)),E[2]||(E[2]=N);var P=a.range.apply(this,E);if(P=P.map(function(t,e){return parseFloat(t.toPrecision(12))}),l=a.scale.linear().domain(E.slice(0,2)).range("clockwise"===f.direction?[0,360]:[360,0]),u.layout.angularAxis.domain=l.domain(),u.layout.angularAxis.endPadding=L?C:0,e=a.select(this).select("svg.chart-root"),"undefined"==typeof e||e.empty()){var D="' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '",I=(new DOMParser).parseFromString(D,"application/xml"),R=this.appendChild(this.ownerDocument.importNode(I.documentElement,!0));e=a.select(R)}e.select(".guides-group").style({"pointer-events":"none"}),e.select(".angular.axis-group").style({"pointer-events":"none"}),e.select(".radial.axis-group").style({"pointer-events":"none"});var j,F=e.select(".chart-group"),q={fill:"none",stroke:f.tickColor},B={"font-size":f.font.size,"font-family":f.font.family,fill:f.font.color,"text-shadow":["-1px 0px","1px -1px","-1px 1px","1px 1px"].map(function(t,e){return" "+t+" 0 "+f.font.outlineColor}).join(",")};if(f.showLegend){j=e.select(".legend-group").attr({transform:"translate("+[x,f.margin.top]+")"}).style({display:"block"});var H=h.map(function(t,e){var n=o.util.cloneJson(t);return n.symbol="DotPlot"===t.geometry?t.dotType||"circle":"LinePlot"!=t.geometry?"square":"line",n.visibleInLegend="undefined"==typeof t.visibleInLegend||t.visibleInLegend,n.color="LinePlot"===t.geometry?t.strokeColor:t.color,n});o.Legend().config({data:h.map(function(t,e){return t.name||"Element"+e}),legendConfig:i({},o.Legend.defaultConfig().legendConfig,{container:j,elements:H,reverseOrder:f.legend.reverseOrder})})();var V=j.node().getBBox();x=Math.min(f.width-V.width-f.margin.left-f.margin.right,f.height-f.margin.top-f.margin.bottom)/2,x=Math.max(10,x),_=[f.margin.left+x,f.margin.top+x],r.range([0,x]),u.layout.radialAxis.domain=r.domain(),j.attr("transform","translate("+[_[0]+x,_[1]-x]+")")}else j=e.select(".legend-group").style({display:"none"});e.attr({width:f.width,height:f.height}).style({opacity:f.opacity}),F.attr("transform","translate("+_+")").style({cursor:"crosshair"});var Z=[(f.width-(f.margin.left+f.margin.right+2*x+(V?V.width:0)))/2,(f.height-(f.margin.top+f.margin.bottom+2*x))/2];if(Z[0]=Math.max(0,Z[0]),Z[1]=Math.max(0,Z[1]),e.select(".outer-group").attr("transform","translate("+Z+")"),f.title){var Y=e.select("g.title-group text").style(B).text(f.title),U=Y.node().getBBox();Y.attr({x:_[0]-U.width/2,y:_[1]-x-20})}var X=e.select(".radial.axis-group");if(f.radialAxis.gridLinesVisible){var G=X.selectAll("circle.grid-circle").data(r.ticks(5));G.enter().append("circle").attr({class:"grid-circle"}).style(q),G.attr("r",r),G.exit().remove()}X.select("circle.outside-circle").attr({r:x}).style(q);var $=e.select("circle.background-circle").attr({r:x}).style({fill:f.backgroundColor,stroke:f.stroke});if(f.radialAxis.visible){var Q=a.svg.axis().scale(r).ticks(5).tickSize(5);X.call(Q).attr({transform:"rotate("+f.radialAxis.orientation+")"}),X.selectAll(".domain").style(q),X.selectAll("g>text").text(function(t,e){return this.textContent+f.radialAxis.ticksSuffix}).style(B).style({"text-anchor":"start"}).attr({x:0,y:0,dx:0,dy:0,transform:function(t,e){return"horizontal"===f.radialAxis.tickOrientation?"rotate("+-f.radialAxis.orientation+") translate("+[0,B["font-size"]]+")":"translate("+[0,B["font-size"]]+")"}}),X.selectAll("g>line").style({stroke:"black"})}var W=e.select(".angular.axis-group").selectAll("g.angular-tick").data(P),J=W.enter().append("g").classed("angular-tick",!0);W.attr({transform:function(t,e){return"rotate("+s(t,e)+")"}}).style({display:f.angularAxis.visible?"block":"none"}),W.exit().remove(),J.append("line").classed("grid-line",!0).classed("major",function(t,e){return e%(f.minorTicks+1)==0}).classed("minor",function(t,e){return!(e%(f.minorTicks+1)==0)}).style(q),J.selectAll(".minor").style({stroke:f.minorTickColor}),W.select("line.grid-line").attr({x1:f.tickLength?x-f.tickLength:0,x2:x}).style({display:f.angularAxis.gridLinesVisible?"block":"none"}),J.append("text").classed("axis-text",!0).style(B);var K=W.select("text.axis-text").attr({x:x+f.labelOffset,dy:".35em",transform:function(t,e){var n=s(t,e),r=x+f.labelOffset,a=f.angularAxis.tickOrientation;return"horizontal"==a?"rotate("+-n+" "+r+" 0)":"radial"==a?n<270&&n>90?"rotate(180 "+r+" 0)":null:"rotate("+(n<=180&&n>0?-90:90)+" "+r+" 0)"}}).style({"text-anchor":"middle",display:f.angularAxis.labelsVisible?"block":"none"}).text(function(t,e){return e%(f.minorTicks+1)!=0?"":k?k[t]+f.angularAxis.ticksSuffix:t+f.angularAxis.ticksSuffix}).style(B);f.angularAxis.rewriteTicks&&K.text(function(t,e){return e%(f.minorTicks+1)!=0?"":f.angularAxis.rewriteTicks(this.textContent,e)});var tt=a.max(F.selectAll(".angular-tick text")[0].map(function(t,e){return t.getCTM().e+t.getBBox().width}));j.attr({transform:"translate("+[x+tt,f.margin.top]+")"});var et=e.select("g.geometry-group").selectAll("g").size()>0,nt=e.select("g.geometry-group").selectAll("g.geometry").data(h);if(nt.enter().append("g").attr({class:function(t,e){return"geometry geometry"+e}}),nt.exit().remove(),h[0]||et){var rt=[];h.forEach(function(t,e){var n={};n.radialScale=r,n.angularScale=l,n.container=nt.filter(function(t,n){return n==e}),n.geometry=t.geometry,n.orientation=f.orientation,n.direction=f.direction,n.index=e,rt.push({data:t,geometryConfig:n})});var at=a.nest().key(function(t,e){return"undefined"!=typeof t.data.groupId||"unstacked"}).entries(rt),ot=[];at.forEach(function(t,e){"unstacked"===t.key?ot=ot.concat(t.values.map(function(t,e){return[t]})):ot.push(t.values)}),ot.forEach(function(t,e){var n;n=Array.isArray(t)?t[0].geometryConfig.geometry:t.geometryConfig.geometry;var r=t.map(function(t,e){return i(o[n].defaultConfig(),t)});o[n]().config(r)()})}var it,lt,st=e.select(".guides-group"),ct=e.select(".tooltips-group"),ut=o.tooltipPanel().config({container:ct,fontSize:8})(),ft=o.tooltipPanel().config({container:ct,fontSize:8})(),dt=o.tooltipPanel().config({container:ct,hasTick:!0})();if(!A){var ht=st.select("line").attr({x1:0,y1:0,y2:0}).style({stroke:"grey","pointer-events":"none"});F.on("mousemove.angular-guide",function(t,e){var n=o.util.getMousePos($).angle;ht.attr({x2:-x,transform:"rotate("+n+")"}).style({opacity:.5});var r=(n+180+360-f.orientation)%360;it=l.invert(r);var a=o.util.convertToCartesian(x+12,n+180);ut.text(o.util.round(it)).move([a[0]+_[0],a[1]+_[1]])}).on("mouseout.angular-guide",function(t,e){st.select("line").style({opacity:0})})}var pt=st.select("circle").style({stroke:"grey",fill:"none"});F.on("mousemove.radial-guide",function(t,e){var n=o.util.getMousePos($).radius;pt.attr({r:n}).style({opacity:.5}),lt=r.invert(o.util.getMousePos($).radius);var a=o.util.convertToCartesian(n,f.radialAxis.orientation);ft.text(o.util.round(lt)).move([a[0]+_[0],a[1]+_[1]])}).on("mouseout.radial-guide",function(t,e){pt.style({opacity:0}),dt.hide(),ut.hide(),ft.hide()}),e.selectAll(".geometry-group .mark").on("mouseover.tooltip",function(t,n){var r=a.select(this),i=r.style("fill"),l="black",s=r.style("opacity")||1;if(r.attr({"data-opacity":s}),"none"!=i){r.attr({"data-fill":i}),l=a.hsl(i).darker().toString(),r.style({fill:l,opacity:1});var c={t:o.util.round(t[0]),r:o.util.round(t[1])};A&&(c.t=k[t[0]]);var u="t: "+c.t+", r: "+c.r,f=this.getBoundingClientRect(),d=e.node().getBoundingClientRect(),h=[f.left+f.width/2-Z[0]-d.left,f.top+f.height/2-Z[1]-d.top];dt.config({color:l}).text(u),dt.move(h)}else i=r.style("stroke"),r.attr({"data-stroke":i}),l=a.hsl(i).darker().toString(),r.style({stroke:l,opacity:1})}).on("mousemove.tooltip",function(t,e){return 0==a.event.which&&void(a.select(this).attr("data-fill")&&dt.show())}).on("mouseout.tooltip",function(t,e){dt.hide();var n=a.select(this),r=n.attr("data-fill");r?n.style({fill:r,opacity:n.attr("data-opacity")}):n.style({stroke:n.attr("data-stroke"),opacity:n.attr("data-opacity")})})}),d}var e,n,r,l,s={data:[],layout:{}},c={},u={},f=a.dispatch("hover"),d={};return d.render=function(e){return t(e),this},d.config=function(t){if(!arguments.length)return s;var e=o.util.cloneJson(t);return e.data.forEach(function(t,e){s.data[e]||(s.data[e]={}),i(s.data[e],o.Axis.defaultConfig().data[0]),i(s.data[e],t)}),i(s.layout,o.Axis.defaultConfig().layout),i(s.layout,e.layout),this},d.getLiveConfig=function(){return u},d.getinputConfig=function(){return c},d.radialScale=function(t){return r},d.angularScale=function(t){return l},d.svg=function(){return e},a.rebind(d,f,"on"),d},o.Axis.defaultConfig=function(t,e){var n={data:[{t:[1,2,3,4],r:[10,11,12,13],name:"Line1",geometry:"LinePlot",color:null,strokeDash:"solid",strokeColor:null,strokeSize:"1",visibleInLegend:!0,opacity:1}],layout:{defaultColorRange:a.scale.category10().range(),title:null,height:450,width:500,margin:{top:40,right:40,bottom:40,left:40},font:{size:12,color:"gray",outlineColor:"white",family:"Tahoma, sans-serif"},direction:"clockwise",orientation:0,labelOffset:10,radialAxis:{domain:null,orientation:-45,ticksSuffix:"",visible:!0,gridLinesVisible:!0,tickOrientation:"horizontal",rewriteTicks:null},angularAxis:{domain:[0,360],ticksSuffix:"",visible:!0,gridLinesVisible:!0,labelsVisible:!0,tickOrientation:"horizontal",rewriteTicks:null,ticksCount:null,ticksStep:null},minorTicks:0,tickLength:null,tickColor:"silver",minorTickColor:"#eee",backgroundColor:"none",needsEndSpacing:null,showLegend:!0,legend:{reverseOrder:!1},opacity:1}};return n},o.util={},o.DATAEXTENT="dataExtent",o.AREA="AreaChart",o.LINE="LinePlot",o.DOT="DotPlot",o.BAR="BarChart",o.util._override=function(t,e){for(var n in t)n in e&&(e[n]=t[n])},o.util._extend=function(t,e){for(var n in t)e[n]=t[n]},o.util._rndSnd=function(){return 2*Math.random()-1+(2*Math.random()-1)+(2*Math.random()-1)},o.util.dataFromEquation2=function(t,e){var n=e||6,r=a.range(0,360+n,n).map(function(e,n){var r=e*Math.PI/180,a=t(r);return[e,a]});return r},o.util.dataFromEquation=function(t,e,n){var r=e||6,o=[],i=[];a.range(0,360+r,r).forEach(function(e,n){var r=e*Math.PI/180,a=t(r);o.push(e),i.push(a)});var l={t:o,r:i};return n&&(l.name=n),l},o.util.ensureArray=function(t,e){if("undefined"==typeof t)return null;var n=[].concat(t);return a.range(e).map(function(t,e){return n[e]||n[0]})},o.util.fillArrays=function(t,e,n){return e.forEach(function(e,r){t[e]=o.util.ensureArray(t[e],n)}),t},o.util.cloneJson=function(t){return JSON.parse(JSON.stringify(t))},o.util.validateKeys=function(t,e){"string"==typeof e&&(e=e.split("."));var n=e.shift();return t[n]&&(!e.length||objHasKeys(t[n],e))},o.util.sumArrays=function(t,e){return a.zip(t,e).map(function(t,e){return a.sum(t)})},o.util.arrayLast=function(t){return t[t.length-1]},o.util.arrayEqual=function(t,e){for(var n=Math.max(t.length,e.length,1);n-- >=0&&t[n]===e[n];);return n===-2},o.util.flattenArray=function(t){for(var e=[];!o.util.arrayEqual(e,t);)e=t,t=[].concat.apply([],t);return t},o.util.deduplicate=function(t){return t.filter(function(t,e,n){return n.indexOf(t)==e})},o.util.convertToCartesian=function(t,e){var n=e*Math.PI/180,r=t*Math.cos(n),a=t*Math.sin(n);return[r,a]},o.util.round=function(t,e){var n=e||2,r=Math.pow(10,n);return Math.round(t*r)/r},o.util.getMousePos=function(t){var e=a.mouse(t.node()),n=e[0],r=e[1],o={};return o.x=n,o.y=r,o.pos=e,o.angle=180*(Math.atan2(r,n)+Math.PI)/Math.PI,o.radius=Math.sqrt(n*n+r*r),o},o.util.duplicatesCount=function(t){for(var e,n={},r={},a=0,o=t.length;a0)){var l=a.select(this.parentNode).selectAll("path.line").data([0]);l.enter().insert("path"),l.attr({class:"line",d:d(i),transform:function(e,n){return"rotate("+(t.orientation+90)+")"},"pointer-events":"none"}).style({fill:function(t,e){return v.fill(n,r,o)},"fill-opacity":0,stroke:function(t,e){return v.stroke(n,r,o)},"stroke-width":function(t,e){return v["stroke-width"](n,r,o)},"stroke-dasharray":function(t,e){return v["stroke-dasharray"](n,r,o)},opacity:function(t,e){return v.opacity(n,r,o)},display:function(t,e){return v.display(n,r,o)}})}};var h=t.angularScale.range(),p=Math.abs(h[1]-h[0])/s[0].length*Math.PI/180,g=a.svg.arc().startAngle(function(t){return-p/2}).endAngle(function(t){return p/2}).innerRadius(function(e){return t.radialScale(u+(e[2]||0))}).outerRadius(function(e){return t.radialScale(u+(e[2]||0))+t.radialScale(e[1])});f.arc=function(e,n,r){a.select(this).attr({class:"mark arc",d:g,transform:function(e,n){return"rotate("+(t.orientation+c(e[0])+90)+")"}})};var v={fill:function(t,n,r){return e[r].data.color},stroke:function(t,n,r){return e[r].data.strokeColor},"stroke-width":function(t,n,r){return e[r].data.strokeSize+"px"},"stroke-dasharray":function(t,n,r){return l[e[r].data.strokeDash]},opacity:function(t,n,r){return e[r].data.opacity},display:function(t,n,r){return"undefined"==typeof e[r].data.visible||e[r].data.visible?"block":"none"}},m=a.select(this).selectAll("g.layer").data(s);m.enter().append("g").attr({class:"layer"});var y=m.selectAll("path.mark").data(function(t,e){return t});y.enter().append("path").attr({class:"mark"}),y.style(v).each(f[t.geometryType]),y.exit().remove(),m.exit().remove()})}var e,n=[o.PolyChart.defaultConfig()],r=a.dispatch("hover"),l={solid:"none",dash:[5,2],dot:[2,5]};return t.config=function(t){return arguments.length?(t.forEach(function(t,e){n[e]||(n[e]={}),i(n[e],o.PolyChart.defaultConfig()),i(n[e],t)}),this):n},t.getColorScale=function(){return e},a.rebind(t,r,"on"),t},o.PolyChart.defaultConfig=function(){var t={data:{name:"geom1",t:[[1,2,3,4]],r:[[1,2,3,4]],dotType:"circle",dotSize:64,dotVisible:!1,barWidth:20,color:"#ffa500",strokeSize:1,strokeColor:"silver",strokeDash:"solid",opacity:1,index:0,visible:!0,visibleInLegend:!0},geometryConfig:{geometry:"LinePlot",geometryType:"arc",direction:"clockwise",orientation:0,container:"body",radialScale:null,angularScale:null,colorScale:a.scale.category20()}};return t},o.BarChart=function(){return o.PolyChart()},o.BarChart.defaultConfig=function(){var t={geometryConfig:{geometryType:"bar"}};return t},o.AreaChart=function(){return o.PolyChart()},o.AreaChart.defaultConfig=function(){var t={geometryConfig:{geometryType:"arc"}};return t},o.DotPlot=function(){return o.PolyChart()},o.DotPlot.defaultConfig=function(){var t={geometryConfig:{geometryType:"dot",dotType:"circle"}};return t},o.LinePlot=function(){return o.PolyChart()},o.LinePlot.defaultConfig=function(){var t={geometryConfig:{geometryType:"line"}};return t},o.Legend=function(){function t(){var n=e.legendConfig,r=e.data.map(function(t,e){return[].concat(t).map(function(t,r){var a=i({},n.elements[e]);return a.name=t,a.color=[].concat(n.elements[e].color)[r],a})}),o=a.merge(r);o=o.filter(function(t,e){return n.elements[e]&&(n.elements[e].visibleInLegend||"undefined"==typeof n.elements[e].visibleInLegend)}),n.reverseOrder&&(o=o.reverse());var l=n.container;("string"==typeof l||l.nodeName)&&(l=a.select(l));var s=o.map(function(t,e){return t.color}),c=n.fontSize,u=null==n.isContinuous?"number"==typeof o[0]:n.isContinuous,f=u?n.height:c*o.length,d=l.classed("legend-group",!0),h=d.selectAll("svg").data([0]),p=h.enter().append("svg").attr({width:300,height:f+c,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"});p.append("g").classed("legend-axis",!0),p.append("g").classed("legend-marks",!0);var g=a.range(o.length),v=a.scale[u?"linear":"ordinal"]().domain(g).range(s),m=a.scale[u?"linear":"ordinal"]().domain(g)[u?"range":"rangePoints"]([0,f]),y=function(t,e){var n=3*e;return"line"===t?"M"+[[-e/2,-e/12],[e/2,-e/12],[e/2,e/12],[-e/2,e/12]]+"Z":a.svg.symbolTypes.indexOf(t)!=-1?a.svg.symbol().type(t).size(n)():a.svg.symbol().type("square").size(n)()};if(u){var x=h.select(".legend-marks").append("defs").append("linearGradient").attr({id:"grad1",x1:"0%",y1:"0%",x2:"0%",y2:"100%"}).selectAll("stop").data(s);x.enter().append("stop"),x.attr({offset:function(t,e){return e/(s.length-1)*100+"%"}}).style({"stop-color":function(t,e){return t}}),h.append("rect").classed("legend-mark",!0).attr({height:n.height,width:n.colorBandWidth,fill:"url(#grad1)"})}else{var b=h.select(".legend-marks").selectAll("path.legend-mark").data(o);b.enter().append("path").classed("legend-mark",!0),b.attr({transform:function(t,e){return"translate("+[c/2,m(e)+c/2]+")"},d:function(t,e){var n=t.symbol;return y(n,c)},fill:function(t,e){return v(e)}}),b.exit().remove()}var _=a.svg.axis().scale(m).orient("right"),w=h.select("g.legend-axis").attr({transform:"translate("+[u?n.colorBandWidth:c,c/2]+")"}).call(_);return w.selectAll(".domain").style({fill:"none",stroke:"none"}),w.selectAll("line").style({fill:"none",stroke:u?n.textColor:"none"}),w.selectAll("text").style({fill:n.textColor,"font-size":n.fontSize}).text(function(t,e){return o[e].name}),t}var e=o.Legend.defaultConfig(),n=a.dispatch("hover");return t.config=function(t){return arguments.length?(i(e,t),this):e},a.rebind(t,n,"on"),t},o.Legend.defaultConfig=function(t,e){var n={data:["a","b","c"],legendConfig:{elements:[{symbol:"line",color:"red"},{symbol:"square",color:"yellow"},{symbol:"diamond",color:"limegreen"}],height:150,colorBandWidth:30,fontSize:12,container:"body",isContinuous:null,textColor:"grey",reverseOrder:!1}};return n},o.tooltipPanel=function(){var t,e,n,r={container:null,hasTick:!1,fontSize:12,color:"white",padding:5},l="tooltip-"+o.tooltipPanel.uid++,s=10,c=function(){t=r.container.selectAll("g."+l).data([0]);var a=t.enter().append("g").classed(l,!0).style({"pointer-events":"none",display:"none"});return n=a.append("path").style({fill:"white","fill-opacity":.9}).attr({d:"M0 0"}),e=a.append("text").attr({dx:r.padding+s,dy:.3*+r.fontSize}),c};return c.text=function(o){var i=a.hsl(r.color).l,l=i>=.5?"#aaa":"white",u=i>=.5?"black":"white",f=o||"";e.style({fill:u,"font-size":r.fontSize+"px"}).text(f);var d=r.padding,h=e.node().getBBox(),p={fill:r.color,stroke:l,"stroke-width":"2px"},g=h.width+2*d+s,v=h.height+2*d;return n.attr({d:"M"+[[s,-v/2],[s,-v/4],[r.hasTick?0:s,0],[s,v/4],[s,v/2],[g,v/2],[g,-v/2]].join("L")+"Z"}).style(p),t.attr({transform:"translate("+[s,-v/2+2*d]+")"}),t.style({display:"block"}),c},c.move=function(e){if(t)return t.attr({transform:"translate("+[e[0],e[1]]+")"}).style({display:"block"}),c},c.hide=function(){if(t)return t.style({display:"none"}),c},c.show=function(){if(t)return t.style({display:"block"}),c},c.config=function(t){return i(r,t),c},c},o.tooltipPanel.uid=1,o.adapter={},o.adapter.plotly=function(){var t={};return t.convert=function(t,e){var n={};if(t.data&&(n.data=t.data.map(function(t,n){var r=i({},t),a=[[r,["marker","color"],["color"]],[r,["marker","opacity"],["opacity"]],[r,["marker","line","color"],["strokeColor"]],[r,["marker","line","dash"],["strokeDash"]],[r,["marker","line","width"],["strokeSize"]],[r,["marker","symbol"],["dotType"]],[r,["marker","size"],["dotSize"]],[r,["marker","barWidth"],["barWidth"]],[r,["line","interpolation"],["lineInterpolation"]],[r,["showlegend"],["visibleInLegend"]]];return a.forEach(function(t,n){o.util.translator.apply(null,t.concat(e))}),e||delete r.marker,e&&delete r.groupId,e?("LinePlot"===r.geometry?(r.type="scatter",r.dotVisible===!0?(delete r.dotVisible,r.mode="lines+markers"):r.mode="lines"):"DotPlot"===r.geometry?(r.type="scatter",r.mode="markers"):"AreaChart"===r.geometry?r.type="area":"BarChart"===r.geometry&&(r.type="bar"),delete r.geometry):("scatter"===r.type?"lines"===r.mode?r.geometry="LinePlot":"markers"===r.mode?r.geometry="DotPlot":"lines+markers"===r.mode&&(r.geometry="LinePlot",r.dotVisible=!0):"area"===r.type?r.geometry="AreaChart":"bar"===r.type&&(r.geometry="BarChart"),delete r.mode,delete r.type),r}),!e&&t.layout&&"stack"===t.layout.barmode)){var r=o.util.duplicates(n.data.map(function(t,e){return t.geometry}));n.data.forEach(function(t,e){var a=r.indexOf(t.geometry);a!=-1&&(n.data[e].groupId=a)})}if(t.layout){var l=i({},t.layout),s=[[l,["plot_bgcolor"],["backgroundColor"]],[l,["showlegend"],["showLegend"]],[l,["radialaxis"],["radialAxis"]],[l,["angularaxis"],["angularAxis"]],[l.angularaxis,["showline"],["gridLinesVisible"]],[l.angularaxis,["showticklabels"],["labelsVisible"]],[l.angularaxis,["nticks"],["ticksCount"]],[l.angularaxis,["tickorientation"],["tickOrientation"]],[l.angularaxis,["ticksuffix"],["ticksSuffix"]],[l.angularaxis,["range"],["domain"]],[l.angularaxis,["endpadding"],["endPadding"]],[l.radialaxis,["showline"],["gridLinesVisible"]],[l.radialaxis,["tickorientation"],["tickOrientation"]],[l.radialaxis,["ticksuffix"],["ticksSuffix"]],[l.radialaxis,["range"],["domain"]],[l.angularAxis,["showline"],["gridLinesVisible"]],[l.angularAxis,["showticklabels"],["labelsVisible"]],[l.angularAxis,["nticks"],["ticksCount"]],[l.angularAxis,["tickorientation"],["tickOrientation"]],[l.angularAxis,["ticksuffix"],["ticksSuffix"]],[l.angularAxis,["range"],["domain"]],[l.angularAxis,["endpadding"],["endPadding"]],[l.radialAxis,["showline"],["gridLinesVisible"]],[l.radialAxis,["tickorientation"],["tickOrientation"]],[l.radialAxis,["ticksuffix"],["ticksSuffix"]],[l.radialAxis,["range"],["domain"]],[l.font,["outlinecolor"],["outlineColor"]],[l.legend,["traceorder"],["reverseOrder"]],[l,["labeloffset"],["labelOffset"]],[l,["defaultcolorrange"],["defaultColorRange"]]];if(s.forEach(function(t,n){o.util.translator.apply(null,t.concat(e))}),e?("undefined"!=typeof l.tickLength&&(l.angularaxis.ticklen=l.tickLength,delete l.tickLength),l.tickColor&&(l.angularaxis.tickcolor=l.tickColor,delete l.tickColor)):(l.angularAxis&&"undefined"!=typeof l.angularAxis.ticklen&&(l.tickLength=l.angularAxis.ticklen),l.angularAxis&&"undefined"!=typeof l.angularAxis.tickcolor&&(l.tickColor=l.angularAxis.tickcolor)),l.legend&&"boolean"!=typeof l.legend.reverseOrder&&(l.legend.reverseOrder="normal"!=l.legend.reverseOrder),l.legend&&"boolean"==typeof l.legend.traceorder&&(l.legend.traceorder=l.legend.traceorder?"reversed":"normal",delete l.legend.reverseOrder),l.margin&&"undefined"!=typeof l.margin.t){var c=["t","r","b","l","pad"],u=["top","right","bottom","left","pad"],f={};a.entries(l.margin).forEach(function(t,e){f[u[c.indexOf(t.key)]]=t.value}),l.margin=f}e&&(delete l.needsEndSpacing,delete l.minorTickColor,delete l.minorTicks,delete l.angularaxis.ticksCount,delete l.angularaxis.ticksCount,delete l.angularaxis.ticksStep,delete l.angularaxis.rewriteTicks,delete l.angularaxis.nticks,delete l.radialaxis.ticksCount,delete l.radialaxis.ticksCount,delete l.radialaxis.ticksStep,delete l.radialaxis.rewriteTicks,delete l.radialaxis.nticks),n.layout=l}return n},t}},{"../../plotly":112,"./micropolar_manager":139,d3:7}],139:[function(t,e,n){"use strict";var r=t("../../plotly"),a=t("d3"),o=t("./undo_manager"),i=e.exports={},l=r.Lib.extendDeepAll;i.framework=function(t){function e(e,o){return o&&(f=o),a.select(a.select(f).node().parentNode).selectAll(".svg-container>*:not(.chart-root)").remove(),n=n?l(n,e):e,c||(c=r.micropolar.Axis()),u=r.micropolar.adapter.plotly().convert(n),c.config(u).render(f),t.data=n.data,t.layout=n.layout,i.fillLayout(t),n}var n,s,c,u,f,d=new o;return e.isPolar=!0,e.svg=function(){return c.svg()},e.getConfig=function(){return n},e.getLiveConfig=function(){return r.micropolar.adapter.plotly().convert(c.getLiveConfig(),!0)},e.getLiveScales=function(){return{t:c.angularScale(),r:c.radialScale()}},e.setUndoPoint=function(){var t=this,e=r.micropolar.util.cloneJson(n);!function(e,n){d.add({undo:function(){n&&t(n)},redo:function(){t(e)}})}(e,s),s=r.micropolar.util.cloneJson(e)},e.undo=function(){d.undo()},e.redo=function(){d.redo()},e},i.fillLayout=function(t){var e=a.select(t).selectAll(".plot-container"),n=e.selectAll(".svg-container"),o=t.framework&&t.framework.svg&&t.framework.svg(),i={width:800,height:600,paper_bgcolor:r.Color.background,_container:e,_paperdiv:n,_paper:o};t._fullLayout=l(i,t.layout)}},{"../../plotly":112,"./undo_manager":140,d3:7}],140:[function(t,e,n){"use strict";e.exports=function(){function t(t,e){return t?(a=!0,t[e](),a=!1,this):this}var e,n=[],r=-1,a=!1;return{add:function(t){return a?this:(n.splice(r+1,n.length-r),n.push(t),r=n.length-1,this)},setCallback:function(t){e=t},undo:function(){var a=n[r];return a?(t(a,"undo"),r-=1,e&&e(a.undo),this):this},redo:function(){var a=n[r+1];return a?(t(a,"redo"),r+=1,e&&e(a.redo),this):this},clear:function(){n=[],r=-1},hasUndo:function(){return r!==-1},hasRedo:function(){return r-1}var o=t("../plotly"),i=o.Lib.extendFlat,l=o.Lib.extendDeep;e.exports=function(t,e){t.framework&&t.framework.isPolar&&(t=t.framework.getConfig());var n,s=t.data,c=t.layout,u=l([],s),f=l({},c,r(e.tileClass)); ++if(e.width&&(f.width=e.width),e.height&&(f.height=e.height),"thumbnail"===e.tileClass||"themes__thumb"===e.tileClass){f.annotations=[];var d=Object.keys(f);for(n=0;n=2?o(t):t>e?Math.ceil(t):Math.floor(t)}var d,h,p,g;if("h"===l.orientation?(p=u.c2p(n.poffset+e.p,!0),g=u.c2p(n.poffset+e.p+n.barwidth,!0),d=c.c2p(e.b,!0),h=c.c2p(e.s+e.b,!0)):(d=c.c2p(n.poffset+e.p,!0),h=c.c2p(n.poffset+e.p+n.barwidth,!0),g=u.c2p(e.s+e.b,!0),p=u.c2p(e.b,!0)),!(a(d)&&a(h)&&a(p)&&a(g)&&d!==h&&p!==g))return void r.select(this).remove();var v=(e.mlw+1||l.marker.line.width+1||(e.trace?e.trace.marker.line.width:0)+1)-1,m=r.round(v/2%1,2);if(!t._context.staticPlot){var y=i.opacity(e.mc||l.marker.color),x=y<1||v>.01?o:s;d=x(d,h),h=x(h,d),p=x(p,g),g=x(g,p)}r.select(this).attr("d","M"+d+","+p+"V"+g+"H"+h+"V"+p+"Z")})}),d.call(l.plot,e)}},{"../../components/color":18,"../../components/errorbars":47,"../../lib":94,"./arrays_to_calcdata":148,d3:7,"fast-isnumeric":10}],157:[function(t,e,n){"use strict";var r=t("fast-isnumeric"),a=t("../../plots/plots"),o=t("../../plots/cartesian/axes"),i=t("../../lib");e.exports=function(t,e){var n,l,s=t._fullLayout,c=e.x(),u=e.y();["v","h"].forEach(function(f){function d(e){function n(t){t[p]=t.p+d}var r=[];e.forEach(function(e){t.calcdata[e].forEach(function(t){r.push(t.p)})});var a=i.distinctVals(r),l=a.vals,c=a.minDiff,u=!1,f=[];"group"===s.barmode&&e.forEach(function(e){u||(t.calcdata[e].forEach(function(t){u||f.forEach(function(e){Math.abs(t.p-e)M+N&&(S=!0,M=_))}o.expand(m,[A,M],{tozero:!0,padded:S})}else{var P=function(t){return t[g]=t.s,t.s};for(n=0;n1||0===l.bargap&&0===l.bargroupgap&&!t[0].trace.marker.line.width)&&r.select(this).attr("shape-rendering","crispEdges")}),e.selectAll("g.points").each(function(t){var e=t[0].trace,n=e.marker,i=n.line,l=(e._input||{}).marker||{},s=o.tryColorscale(n,l,""),c=o.tryColorscale(n,l,"line.");r.select(this).selectAll("path").each(function(t){var e,o,l=(t.mlw+1||i.width+1)-1,u=r.select(this);e="mc"in t?t.mcc=s(t.mc):Array.isArray(n.color)?a.defaultLine:n.color,u.style("stroke-width",l+"px").call(a.fill,e),l&&(o="mlc"in t?t.mlcc=c(t.mlc):Array.isArray(i.color)?a.defaultLine:i.color,u.call(a.stroke,o))})}),e.call(i.style)}},{"../../components/color":18,"../../components/drawing":41,"../../components/errorbars":47,d3:7}],159:[function(t,e,n){"use strict";var r=t("../../components/color"),a=t("../../components/colorscale/has_colorscale"),o=t("../../components/colorscale/defaults");e.exports=function(t,e,n,i,l){n("marker.color",i),a(t,"marker")&&o(t,e,l,n,{prefix:"marker.",cLetter:"c"}),n("marker.line.color",r.defaultLine),a(t,"marker.line")&&o(t,e,l,n,{prefix:"marker.line.",cLetter:"c"}),n("marker.line.width")}},{"../../components/color":18,"../../components/colorscale/defaults":28,"../../components/colorscale/has_colorscale":31}],160:[function(t,e,n){"use strict";var r=t("../../components/color/attributes"),a=t("../../plots/font_attributes"),o=t("../../plots/attributes"),i=t("../../lib/extend").extendFlat;e.exports={labels:{valType:"data_array"},label0:{valType:"number",dflt:0},dlabel:{valType:"number",dflt:1},values:{valType:"data_array"},marker:{colors:{valType:"data_array"},line:{color:{valType:"color",dflt:r.defaultLine,arrayOk:!0},width:{valType:"number",min:0,dflt:0,arrayOk:!0}}},text:{valType:"data_array"},scalegroup:{valType:"string",dflt:""},textinfo:{valType:"flaglist",flags:["label","text","value","percent"],extras:["none"]},hoverinfo:i({},o.hoverinfo,{flags:["label","text","value","percent","name"]}),textposition:{valType:"enumerated",values:["inside","outside","auto","none"],dflt:"auto",arrayOk:!0},textfont:i({},a,{}),insidetextfont:i({},a,{}),outsidetextfont:i({},a,{}),domain:{x:{valType:"info_array",items:[{valType:"number",min:0,max:1},{valType:"number",min:0,max:1}],dflt:[0,1]},y:{valType:"info_array",items:[{valType:"number",min:0,max:1},{valType:"number",min:0,max:1}],dflt:[0,1]}},hole:{valType:"number",min:0,max:1,dflt:0},sort:{valType:"boolean",dflt:!0},direction:{valType:"enumerated",values:["clockwise","counterclockwise"],dflt:"counterclockwise"},rotation:{valType:"number",min:-360,max:360,dflt:0},pull:{valType:"number",min:0,max:1,dflt:0,arrayOk:!0}}},{"../../components/color/attributes":17,"../../lib/extend":93,"../../plots/attributes":113,"../../plots/font_attributes":133}],161:[function(t,e,n){"use strict";function r(t,e){for(var n=[],r=0;r")}return g};var s},{"../../components/color":18,"./helpers":164,"fast-isnumeric":10,tinycolor2:13}],163:[function(t,e,n){"use strict";var r=t("../../lib"),a=t("./attributes");e.exports=function(t,e,n,o){function i(n,o){return r.coerce(t,e,a,n,o)}var l=r.coerceFont,s=i("values");if(!Array.isArray(s)||!s.length)return void(e.visible=!1);var c=i("labels");Array.isArray(c)||(i("label0"),i("dlabel"));var u=i("marker.line.width");u&&i("marker.line.color");var f=i("marker.colors");Array.isArray(f)||(e.marker.colors=[]),i("scalegroup");var d=i("text"),h=i("textinfo",Array.isArray(d)?"text+percent":"percent");if(i("hoverinfo",1===o._dataLength?"label+text+value+percent":void 0),h&&"none"!==h){var p=i("textposition"),g=Array.isArray(p)||"auto"===p,v=g||"inside"===p,m=g||"outside"===p;if(v||m){var y=l(i,"textfont",o.font);v&&l(i,"insidetextfont",y),m&&l(i,"outsidetextfont",y)}}i("domain.x"),i("domain.y"),i("hole"),i("sort"),i("direction"),i("rotation"),i("pull")}},{"../../lib":94,"./attributes":160}],164:[function(t,e,n){"use strict";var r=t("../../lib");n.formatPiePercent=function(t,e){var n=(100*t).toPrecision(3);return n.lastIndexOf(".")!==-1&&(n=n.replace(/[.]?0+$/,"")),r.numSeparate(n,e)+"%"},n.formatPieValue=function(t,e){var n=t.toPrecision(10);return n.lastIndexOf(".")!==-1&&(n=n.replace(/[.]?0+$/,"")),r.numSeparate(n,e)}},{"../../lib":94}],165:[function(t,e,n){"use strict";var r={};r.attributes=t("./attributes"),r.supplyDefaults=t("./defaults"),r.supplyLayoutDefaults=t("./layout_defaults"),r.layoutAttributes=t("./layout_attributes"),r.calc=t("./calc"),r.plot=t("./plot"),r.style=t("./style"),r.styleOne=t("./style_one"),r.moduleType="trace",r.name="pie",r.basePlotModule=t("./base_plot"),r.categories=["pie","showLegend"],r.meta={},e.exports=r},{"./attributes":160,"./base_plot":161,"./calc":162,"./defaults":163,"./layout_attributes":166,"./layout_defaults":167,"./plot":168,"./style":169,"./style_one":170}],166:[function(t,e,n){"use strict";e.exports={hiddenlabels:{valType:"data_array"}}},{}],167:[function(t,e,n){"use strict";var r=t("../../lib"),a=t("./layout_attributes");e.exports=function(t,e){function n(n,o){return r.coerce(t,e,a,n,o)}n("hiddenlabels")}},{"../../lib":94,"./layout_attributes":166}],168:[function(t,e,n){"use strict";function r(t,e,n){var r=Math.sqrt(t.width*t.width+t.height*t.height),o=t.width/t.height,i=Math.PI*Math.min(e.v/n.vTotal,.5),l=1-n.trace.hole,s=a(e,n),c={scale:s*n.r*2/r,rCenter:1-s,rotate:0};if(c.scale>=1)return c;var u=o+1/(2*Math.tan(i)),f=n.r*Math.min(1/(Math.sqrt(u*u+.5)+u),l/(Math.sqrt(o*o+l/2)+o)),d={scale:2*f/t.height,rCenter:Math.cos(f/n.r)-f*o/n.r,rotate:(180/Math.PI*e.midangle+720)%180-90},h=1/o,p=h+1/(2*Math.tan(i)),g=n.r*Math.min(1/(Math.sqrt(p*p+.5)+p),l/(Math.sqrt(h*h+l/2)+h)),v={scale:2*g/t.width,rCenter:Math.cos(g/n.r)-g/o/n.r,rotate:(180/Math.PI*e.midangle+810)%180-90},m=v.scale>d.scale?v:d;return c.scale<1&&m.scale>c.scale?m:c}function a(t,e){if(t.v===e.vTotal&&!e.trace.hole)return 1;var n=Math.PI*Math.min(t.v/e.vTotal,.5);return Math.min(1/(1+1/Math.sin(n)),(1-e.trace.hole)/2)}function o(t,e){var n=e.pxmid[0],r=e.pxmid[1],a=t.width/2,o=t.height/2;return n<0&&(a*=-1),r<0&&(o*=-1),{scale:1,rCenter:1,rotate:0,x:a+Math.abs(o)*(a>0?1:-1)/2,y:o/(1+n*n/(r*r)),outside:!0}}function i(t,e){function n(t,e){return t.pxmid[1]-e.pxmid[1]}function r(t,e){return e.pxmid[1]-t.pxmid[1]}function a(t,n){n||(n={});var r,a,o,l,d,h,g=n.labelExtraY+(i?n.yLabelMax:n.yLabelMin),v=i?t.yLabelMin:t.yLabelMax,m=i?t.yLabelMax:t.yLabelMin,y=t.cyFinal+c(t.px0[1],t.px1[1]),x=g-v;if(x*f>0&&(t.labelExtraY=x),Array.isArray(e.pull))for(a=0;a=e.pull[o.i]||((t.pxmid[1]-o.pxmid[1])*f>0?(l=o.cyFinal+c(o.px0[1],o.px1[1]),x=l-v-t.labelExtraY,x*f>0&&(t.labelExtraY+=x)):(m+t.labelExtraY-y)*f>0&&(r=3*u*Math.abs(a-p.indexOf(t)),d=o.cxFinal+s(o.px0[0],o.px1[0]),h=d+r-(t.cxFinal+t.pxmid[0])-t.labelExtraX,h*u>0&&(t.labelExtraX+=h)))}var o,i,l,s,c,u,f,d,h,p,g,v,m;for(i=0;i<2;i++)for(l=i?n:r,c=i?Math.max:Math.min,f=i?1:-1,o=0;o<2;o++){for(s=o?Math.max:Math.min,u=o?1:-1,d=t[i][o],d.sort(l),h=t[1-i][o],p=h.concat(d),v=[],g=0;gu&&(u=l.pull[o]);i.r=Math.min(n/c(l.tilt,Math.sin(s),l.depth),r/c(l.tilt,Math.cos(s),l.depth))/(2+2*u),i.cx=e.l+e.w*(l.domain.x[1]+l.domain.x[0])/2,i.cy=e.t+e.h*(2-l.domain.y[1]-l.domain.y[0])/2,l.scalegroup&&h.indexOf(l.scalegroup)===-1&&h.push(l.scalegroup)}for(o=0;of.vTotal/2?1:0)}function c(t,e,n){if(!t)return 1;var r=Math.sin(t*Math.PI/180);return Math.max(.01,n*r*Math.abs(e)+2*Math.sqrt(1-r*r*e*e))}var u=t("d3"),f=t("../../plots/cartesian/graph_interact"),d=t("../../components/color"),h=t("../../components/drawing"),p=t("../../lib/svg_text_utils"),g=t("./helpers");e.exports=function(t,e){var n=t._fullLayout;l(e,n._size);var c=n._pielayer.selectAll("g.trace").data(e);c.enter().append("g").attr({"stroke-linejoin":"round",class:"trace"}),c.exit().remove(),c.order(),c.each(function(e){var l=u.select(this),c=e[0],v=c.trace,m=0,y=(v.depth||0)*c.r*Math.sin(m)/2,x=v.tiltaxis||0,b=x*Math.PI/180,_=[y*Math.sin(b),y*Math.cos(b)],w=c.r*Math.cos(m),k=l.selectAll("g.part").data(v.tilt?["top","sides"]:["top"]);k.enter().append("g").attr("class",function(t){return t+" part"}),k.exit().remove(),k.order(),s(e),l.selectAll(".top").each(function(){var l=u.select(this).selectAll("g.slice").data(e);l.enter().append("g").classed("slice",!0),l.exit().remove();var s=[[[],[]],[[],[]]],m=!1;l.each(function(i){function l(e){var r=t._fullLayout,o=t._fullData[v.index],l=o.hoverinfo;if("all"===l&&(l="label+text+value+percent+name"),!t._dragging&&r.hovermode!==!1&&"none"!==l&&l){var s=a(i,c),u=k+i.pxmid[0]*(1-s),d=M+i.pxmid[1]*(1-s),h=n.separators,p=[];l.indexOf("label")!==-1&&p.push(i.label),o.text&&o.text[i.i]&&l.indexOf("text")!==-1&&p.push(o.text[i.i]),l.indexOf("value")!==-1&&p.push(g.formatPieValue(i.v,h)),l.indexOf("percent")!==-1&&p.push(g.formatPiePercent(i.v/c.vTotal,h)),f.loneHover({x0:u-s*c.r,x1:u+s*c.r,y:d,text:p.join("
"),name:l.indexOf("name")!==-1?o.name:void 0,color:i.color,idealAlign:i.pxmid[0]<0?"left":"right"},{container:r._hoverlayer.node(),outerContainer:r._paper.node()}),f.hover(t,e,"pie"),L=!0}}function d(e){t.emit("plotly_unhover",{points:[e]}),L&&(f.loneUnhover(n._hoverlayer.node()),L=!1)}function y(){t._hoverdata=[i],t._hoverdata.trace=e.trace,f.click(t,{target:!0})}function b(t,e,n,r){return"a"+r*c.r+","+r*w+" "+x+" "+i.largeArc+(n?" 1 ":" 0 ")+r*(e[0]-t[0])+","+r*(e[1]-t[1])}if(i.hidden)return void u.select(this).selectAll("path,g").remove();s[i.pxmid[1]<0?0:1][i.pxmid[0]<0?0:1].push(i);var k=c.cx+_[0],M=c.cy+_[1],A=u.select(this),T=A.selectAll("path.surface").data([i]),L=!1;if(T.enter().append("path").classed("surface",!0).style({"pointer-events":"all"}),A.select("path.textline").remove(),A.on("mouseover",l).on("mouseout",d).on("click",y),v.pull){var z=+(Array.isArray(v.pull)?v.pull[i.i]:v.pull)||0;z>0&&(k+=z*i.pxmid[0],M+=z*i.pxmid[1])}i.cxFinal=k,i.cyFinal=M;var S=v.hole;if(i.v===c.vTotal){var C="M"+(k+i.px0[0])+","+(M+i.px0[1])+b(i.px0,i.pxmid,!0,1)+b(i.pxmid,i.px0,!0,1)+"Z";S?T.attr("d","M"+(k+S*i.px0[0])+","+(M+S*i.px0[1])+b(i.px0,i.pxmid,!1,S)+b(i.pxmid,i.px0,!1,S)+"Z"+C):T.attr("d",C)}else{var E=b(i.px0,i.px1,!0,1);if(S){var O=1-S;T.attr("d","M"+(k+S*i.px1[0])+","+(M+S*i.px1[1])+b(i.px1,i.px0,!1,S)+"l"+O*i.px0[0]+","+O*i.px0[1]+E+"Z")}else T.attr("d","M"+k+","+M+"l"+i.px0[0]+","+i.px0[1]+E+"Z")}var N=Array.isArray(v.textposition)?v.textposition[i.i]:v.textposition,P=A.selectAll("g.slicetext").data(i.text&&"none"!==N?[0]:[]);P.enter().append("g").classed("slicetext",!0),P.exit().remove(),P.each(function(){var t=u.select(this).selectAll("text").data([0]);t.enter().append("text").attr("data-notex",1),t.exit().remove(),t.text(i.text).attr({class:"slicetext",transform:"","data-bb":"","text-anchor":"middle",x:0,y:0}).call(h.font,"outside"===N?v.outsidetextfont:v.insidetextfont).call(p.convertToTspans),t.selectAll("tspan.line").attr({x:0,y:0});var e,n=h.bBox(t.node());"outside"===N?e=o(n,i):(e=r(n,i,c),"auto"===N&&e.scale<1&&(t.call(h.font,v.outsidetextfont),v.outsidetextfont.family===v.insidetextfont.family&&v.outsidetextfont.size===v.insidetextfont.size||(t.attr({"data-bb":""}),n=h.bBox(t.node())),e=o(n,i)));var a=k+i.pxmid[0]*e.rCenter+(e.x||0),l=M+i.pxmid[1]*e.rCenter+(e.y||0);e.outside&&(i.yLabelMin=l-n.height/2,i.yLabelMid=l,i.yLabelMax=l+n.height/2,i.labelExtraX=0,i.labelExtraY=0,m=!0),t.attr("transform","translate("+a+","+l+")"+(e.scale<1?"scale("+e.scale+")":"")+(e.rotate?"rotate("+e.rotate+")":"")+"translate("+-(n.left+n.right)/2+","+-(n.top+n.bottom)/2+")")})}),m&&i(s,v),l.each(function(t){if(t.labelExtraX||t.labelExtraY){var e=u.select(this),n=e.select("g.slicetext text");n.attr("transform","translate("+t.labelExtraX+","+t.labelExtraY+")"+n.attr("transform"));var r=t.cxFinal+t.pxmid[0],a=t.cyFinal+t.pxmid[1],o="M"+r+","+a,i=(t.yLabelMax-t.yLabelMin)*(t.pxmid[0]<0?-1:1)/4;if(t.labelExtraX){var l=t.labelExtraX*t.pxmid[1]/t.pxmid[0],s=t.yLabelMid+t.labelExtraY-(t.cyFinal+t.pxmid[1]);o+=Math.abs(l)>Math.abs(s)?"l"+s*t.pxmid[0]/t.pxmid[1]+","+s+"H"+(r+t.labelExtraX+i):"l"+t.labelExtraX+","+l+"v"+(s-l)+"h"+i}else o+="V"+(t.yLabelMid+t.labelExtraY)+"h"+i;e.append("path").classed("textline",!0).call(d.stroke,v.outsidetextfont.color).attr({"stroke-width":Math.min(2,v.outsidetextfont.size/8),d:o,fill:"none"})}})})}),setTimeout(function(){c.selectAll("tspan").each(function(){var t=u.select(this);t.attr("dy")&&t.attr("dy",t.attr("dy"))})},0)}},{"../../components/color":18,"../../components/drawing":41,"../../lib/svg_text_utils":105,"../../plots/cartesian/graph_interact":122,"./helpers":164,d3:7}],169:[function(t,e,n){"use strict";var r=t("d3"),a=t("./style_one");e.exports=function(t){t._fullLayout._pielayer.selectAll(".trace").each(function(t){var e=t[0],n=e.trace,o=r.select(this);o.style({opacity:n.opacity}),o.selectAll(".top path.surface").each(function(t){r.select(this).call(a,t,n)})})}},{"./style_one":170,d3:7}],170:[function(t,e,n){"use strict";var r=t("../../components/color");e.exports=function(t,e,n){var a=n.marker.line.color;Array.isArray(a)&&(a=a[e.i]||r.defaultLine);var o=n.marker.line.width||0;Array.isArray(o)&&(o=o[e.i]||0),t.style({"stroke-width":o,fill:e.color}).call(r.stroke,a)}},{"../../components/color":18}],171:[function(t,e,n){"use strict";var r=t("../../lib");e.exports=function(t){var e=t[0].trace,n=e.marker;if(r.mergeArray(e.text,t,"tx"),r.mergeArray(e.textposition,t,"tp"),e.textfont&&(r.mergeArray(e.textfont.size,t,"ts"),r.mergeArray(e.textfont.color,t,"tc"),r.mergeArray(e.textfont.family,t,"tf")), ++n&&n.line){var a=n.line;r.mergeArray(n.opacity,t,"mo"),r.mergeArray(n.symbol,t,"mx"),r.mergeArray(n.color,t,"mc"),r.mergeArray(a.color,t,"mlc"),r.mergeArray(a.width,t,"mlw")}}},{"../../lib":94}],172:[function(t,e,n){"use strict";var r=t("../../components/colorscale/color_attributes"),a=t("../../components/drawing"),o=(t("./constants"),t("../../lib/extend").extendFlat);e.exports={x:{valType:"data_array"},x0:{valType:"any",dflt:0},dx:{valType:"number",dflt:1},y:{valType:"data_array"},y0:{valType:"any",dflt:0},dy:{valType:"number",dflt:1},text:{valType:"string",dflt:"",arrayOk:!0},mode:{valType:"flaglist",flags:["lines","markers","text"],extras:["none"]},hoveron:{valType:"flaglist",flags:["points","fills"]},line:{color:{valType:"color"},width:{valType:"number",min:0,dflt:2},shape:{valType:"enumerated",values:["linear","spline","hv","vh","hvh","vhv"],dflt:"linear"},smoothing:{valType:"number",min:0,max:1.3,dflt:1},dash:{valType:"string",values:["solid","dot","dash","longdash","dashdot","longdashdot"],dflt:"solid"}},connectgaps:{valType:"boolean",dflt:!1},fill:{valType:"enumerated",values:["none","tozeroy","tozerox","tonexty","tonextx","toself","tonext"],dflt:"none"},fillcolor:{valType:"color"},marker:o({},{symbol:{valType:"enumerated",values:a.symbolList,dflt:"circle",arrayOk:!0},opacity:{valType:"number",min:0,max:1,arrayOk:!0},size:{valType:"number",min:0,dflt:6,arrayOk:!0},maxdisplayed:{valType:"number",min:0,dflt:0},sizeref:{valType:"number",dflt:1},sizemin:{valType:"number",min:0,dflt:0},sizemode:{valType:"enumerated",values:["diameter","area"],dflt:"diameter"},showscale:{valType:"boolean",dflt:!1},line:o({},{width:{valType:"number",min:0,arrayOk:!0}},r("marker.line"))},r("marker")),textposition:{valType:"enumerated",values:["top left","top center","top right","middle left","middle center","middle right","bottom left","bottom center","bottom right"],dflt:"middle center",arrayOk:!0},textfont:{family:{valType:"string",noBlank:!0,strict:!0,arrayOk:!0},size:{valType:"number",min:1,arrayOk:!0},color:{valType:"color",arrayOk:!0}},r:{valType:"data_array"},t:{valType:"data_array"},_nestedModules:{error_y:"ErrorBars",error_x:"ErrorBars","marker.colorbar":"Colorbar"}}},{"../../components/colorscale/color_attributes":26,"../../components/drawing":41,"../../lib/extend":93,"./constants":177}],173:[function(t,e,n){"use strict";var r=t("fast-isnumeric"),a=t("../../plots/cartesian/axes"),o=t("../../lib"),i=t("./subtypes"),l=t("./colorscale_calc");e.exports=function(t,e){var n,s,c,u=a.getFromId(t,e.xaxis||"x"),f=a.getFromId(t,e.yaxis||"y"),d=u.makeCalcdata(e,"x"),h=f.makeCalcdata(e,"y"),p=Math.min(d.length,h.length);u._minDtick=0,f._minDtick=0,d.length>p&&d.splice(p,d.length-p),h.length>p&&h.splice(p,h.length-p);var g={padded:!0},v={padded:!0};if(i.hasMarkers(e)){if(n=e.marker,s=n.size,Array.isArray(s)){var m={type:"linear"};a.setConvert(m),s=m.makeCalcdata(e.marker,"size"),s.length>p&&s.splice(p,s.length-p)}var y,x=1.6*(e.marker.sizeref||1);y="area"===e.marker.sizemode?function(t){return Math.max(Math.sqrt((t||0)/x),3)}:function(t){return Math.max((t||0)/x,3)},g.ppad=v.ppad=Array.isArray(s)?s.map(y):y(s)}l(e),!("tozerox"===e.fill||"tonextx"===e.fill&&t.firstscatter)||d[0]===d[p-1]&&h[0]===h[p-1]?e.error_y.visible||["tonexty","tozeroy"].indexOf(e.fill)===-1&&(i.hasMarkers(e)||i.hasText(e))||(g.padded=!1,g.ppad=0):g.tozero=!0,!("tozeroy"===e.fill||"tonexty"===e.fill&&t.firstscatter)||d[0]===d[p-1]&&h[0]===h[p-1]?["tonextx","tozerox"].indexOf(e.fill)!==-1&&(v.padded=!1):v.tozero=!0,a.expand(u,d,g),a.expand(f,h,v);var b=new Array(p);for(c=0;c=0;a--)if(o=t[a],"scatter"===o.type&&o.xaxis===n.xaxis&&o.yaxis===n.yaxis){o.opacity=void 0;break}}},{}],175:[function(t,e,n){"use strict";var r=t("d3"),a=t("fast-isnumeric"),o=t("../../lib"),i=t("../../plots/plots"),l=t("../../components/colorscale/get_scale"),s=t("../../components/colorbar/draw");e.exports=function(t,e){var n=e[0].trace,c=n.marker,u="cb"+n.uid;if(t._fullLayout._infolayer.selectAll("."+u).remove(),void 0===c||!c.showscale)return void i.autoMargin(t,u);var f=l(c.colorscale),d=c.color,h=c.cmin,p=c.cmax;a(h)||(h=o.aggNums(Math.min,null,d)),a(p)||(p=o.aggNums(Math.max,null,d));var g=e[0].t.cb=s(t,u);g.fillcolor(r.scale.linear().domain(f.map(function(t){return h+t[0]*(p-h)})).range(f.map(function(t){return t[1]}))).filllevels({start:h,end:p,size:(p-h)/254}).options(c.colorbar)()}},{"../../components/colorbar/draw":21,"../../components/colorscale/get_scale":30,"../../lib":94,"../../plots/plots":135,d3:7,"fast-isnumeric":10}],176:[function(t,e,n){"use strict";var r=t("../../components/colorscale/has_colorscale"),a=t("../../components/colorscale/calc"),o=t("./subtypes");e.exports=function(t){o.hasLines(t)&&r(t,"line")&&a(t,t.line.color,"line","c"),o.hasMarkers(t)&&(r(t,"marker")&&a(t,t.marker.color,"marker","c"),r(t,"marker.line")&&a(t,t.marker.line.color,"marker.line","c"))}},{"../../components/colorscale/calc":25,"../../components/colorscale/has_colorscale":31,"./subtypes":191}],177:[function(t,e,n){"use strict";e.exports={PTS_LINESONLY:20}},{}],178:[function(t,e,n){"use strict";var r=t("../../lib"),a=t("./attributes"),o=t("./constants"),i=t("./subtypes"),l=t("./xy_defaults"),s=t("./marker_defaults"),c=t("./line_defaults"),u=t("./line_shape_defaults"),f=t("./text_defaults"),d=t("./fillcolor_defaults"),h=t("../../components/errorbars/defaults");e.exports=function(t,e,n,p){function g(n,o){return r.coerce(t,e,a,n,o)}var v=l(t,e,g),m=vB!=N>=B&&(C=z[T-1][0],E=z[T][0],S=C+(E-C)*(B-O)/(N-O),R=Math.min(R,S),j=Math.max(j,S));R=Math.max(R,0),j=Math.min(j,d._length);var H=s.defaultLine;return s.opacity(f.fillcolor)?H=f.fillcolor:s.opacity((f.line||{}).color)&&(H=f.line.color),r.extendFlat(t,{distance:o.MAXDIST+10,x0:R,x1:j,y0:B,y1:B,color:H}),delete t.index,f.text&&!Array.isArray(f.text)?t.text=String(f.text):t.text=f.name,[t]}}}},{"../../components/color":18,"../../components/errorbars":47,"../../lib":94,"../../plots/cartesian/constants":120,"../../plots/cartesian/graph_interact":122,"./get_trace_color":180}],182:[function(t,e,n){"use strict";var r={},a=t("./subtypes");r.hasLines=a.hasLines,r.hasMarkers=a.hasMarkers,r.hasText=a.hasText,r.isBubble=a.isBubble,r.attributes=t("./attributes"),r.supplyDefaults=t("./defaults"),r.cleanData=t("./clean_data"),r.calc=t("./calc"),r.arraysToCalcdata=t("./arrays_to_calcdata"),r.plot=t("./plot"),r.colorbar=t("./colorbar"),r.style=t("./style"),r.hoverPoints=t("./hover"),r.selectPoints=t("./select"),r.moduleType="trace",r.name="scatter",r.basePlotModule=t("../../plots/cartesian"),r.categories=["cartesian","symbols","markerColorscale","errorBarsOK","showLegend"],r.meta={},e.exports=r},{"../../plots/cartesian":123,"./arrays_to_calcdata":171,"./attributes":172,"./calc":173,"./clean_data":174,"./colorbar":175,"./defaults":178,"./hover":181,"./plot":188,"./select":189,"./style":190,"./subtypes":191}],183:[function(t,e,n){"use strict";var r=t("../../components/colorscale/has_colorscale"),a=t("../../components/colorscale/defaults");e.exports=function(t,e,n,o,i){var l=(t.marker||{}).color;if(i("line.color",n),r(t,"line"))a(t,e,o,i,{prefix:"line.",cLetter:"c"});else{var s=!Array.isArray(l)&&l||n;i("line.color",s)}i("line.width"),i("line.dash")}},{"../../components/colorscale/defaults":28,"../../components/colorscale/has_colorscale":31}],184:[function(t,e,n){"use strict";var r=t("../../plots/cartesian/axes");e.exports=function(t,e){function n(e){var n=w.c2p(t[e].x),r=k.c2p(t[e].y);return n!==z&&r!==z&&[n,r]}function a(t){var e=t[0]/w._length,n=t[1]/k._length;return(1+10*Math.max(0,-e,e-1,-n,n-1))*A}function o(t,e){var n=t[0]-e[0],r=t[1]-e[1];return Math.sqrt(n*n+r*r)}var i,l,s,c,u,f,d,h,p,g,v,m,y,x,b,_,w=e.xaxis,k=e.yaxis,M=e.connectGaps,A=e.baseTolerance,T=e.linear,L=[],z=r.BADNUM,S=.2,C=new Array(t.length),E=0;for(i=0;ia(f))break;s=f,y=g[0]*p[0]+g[1]*p[1],y>v?(v=y,c=f,h=!1):y=t.length||!f)break;C[E++]=f,l=f}}else C[E++]=c}L.push(C.slice(0,E))}return L}},{"../../plots/cartesian/axes":115}],185:[function(t,e,n){"use strict";e.exports=function(t,e,n){var r=n("line.shape");"spline"===r&&n("line.smoothing")}},{}],186:[function(t,e,n){"use strict";var r=t("fast-isnumeric");e.exports=function(t){var e=t.marker,n=e.sizeref||1,a=e.sizemin||0,o="area"===e.sizemode?function(t){return Math.sqrt(t/n)}:function(t){return t/n};return function(t){var e=o(t/2);return r(e)&&e>0?Math.max(e,a):0}}},{"fast-isnumeric":10}],187:[function(t,e,n){"use strict";var r=t("../../components/color"),a=t("../../components/colorscale/has_colorscale"),o=t("../../components/colorscale/defaults"),i=t("./subtypes");e.exports=function(t,e,n,l,s){var c,u=i.isBubble(t),f=(t.line||{}).color;f&&(n=f),s("marker.symbol"),s("marker.opacity",u?.7:1),s("marker.size"),s("marker.color",n),a(t,"marker")&&o(t,e,l,s,{prefix:"marker.",cLetter:"c"}),c=f&&!Array.isArray(f)&&e.marker.color!==f?f:u?r.background:r.defaultLine,s("marker.line.color",c),a(t,"marker.line")&&o(t,e,l,s,{prefix:"marker.line.",cLetter:"c"}),s("marker.line.width",u?1:0),u&&(s("marker.sizeref"),s("marker.sizemin"),s("marker.sizemode"))}},{"../../components/color":18,"../../components/colorscale/defaults":28,"../../components/colorscale/has_colorscale":31,"./subtypes":191}],188:[function(t,e,n){"use strict";function r(t,e,n){var r=e.x(),o=e.y(),i=a.extent(r.range.map(r.l2c)),l=a.extent(o.range.map(o.l2c));n.forEach(function(t,e){var r=t[0].trace;if(c.hasMarkers(r)){var a=r.marker.maxdisplayed;if(0!==a){var o=t.filter(function(t){return t.x>=i[0]&&t.x<=i[1]&&t.y>=l[0]&&t.y<=l[1]}),s=Math.ceil(o.length/a),u=0;n.forEach(function(t,n){var r=t[0].trace;c.hasMarkers(r)&&r.marker.maxdisplayed>0&&n1&&r.append("path").classed("js-line",!0).style("vector-effect","non-scaling-stroke").attr("d",o)}v?z&&C&&(m?("y"===m?z[1]=C[1]=p.c2p(0,!0):"x"===m&&(z[0]=C[0]=h.c2p(0,!0)),v.attr("d",k+"L"+C+"L"+z+"Z")):v.attr("d",k+"Z")):"tonext"===e.fill.substr(0,6)&&k&&b&&("tonext"===e.fill?y.attr("d",k+"Z"+b+"Z"):y.attr("d",k+"L"+b.substr(1)+"Z"),e._polygons=e._polygons.concat(_)),b=M,_=L}}}),g.selectAll("path:not([d])").remove(),g.append("g").attr("class","points").each(function(t){var e=t[0].trace,n=a.select(this),r=c.hasMarkers(e),l=c.hasText(e);!r&&!l||e.visible!==!0?n.remove():(r&&n.selectAll("path.point").data(e.marker.maxdisplayed?d:o.identity).enter().append("path").classed("point",!0).call(i.translatePoints,h,p),l&&n.selectAll("g").data(e.marker.maxdisplayed?d:o.identity).enter().append("g").append("text").call(i.translatePoints,h,p))})}},{"../../components/drawing":41,"../../components/errorbars":47,"../../lib":94,"../../lib/polygon":100,"./arrays_to_calcdata":171,"./line_points":184,"./subtypes":191,d3:7}],189:[function(t,e,n){"use strict";var r=t("./subtypes"),a=.2;e.exports=function(t,e){var n,o,i,l,s=t.cd,c=t.xaxis,u=t.yaxis,f=[],d=s[0].trace,h=d.index,p=d.marker,g=!r.hasMarkers(d)&&!r.hasText(d);if(d.visible===!0&&!g){var v=Array.isArray(p.opacity)?1:p.opacity;if(e===!1)for(n=0;n 0 && this._events[type].length > m) { +- this._events[type].warned = true; +- console.error('(node) warning: possible EventEmitter memory ' + +- 'leak detected. %d listeners added. ' + +- 'Use emitter.setMaxListeners() to increase limit.', +- this._events[type].length); +- if (typeof console.trace === 'function') { +- // not supported in IE 10 +- console.trace(); +- } +- } +- } +- +- return this; +-}; +- +-EventEmitter.prototype.on = EventEmitter.prototype.addListener; +- +-EventEmitter.prototype.once = function(type, listener) { +- if (!isFunction(listener)) +- throw TypeError('listener must be a function'); +- +- var fired = false; +- +- function g() { +- this.removeListener(type, g); +- +- if (!fired) { +- fired = true; +- listener.apply(this, arguments); +- } +- } +- +- g.listener = listener; +- this.on(type, g); +- +- return this; +-}; +- +-// emits a 'removeListener' event iff the listener was removed +-EventEmitter.prototype.removeListener = function(type, listener) { +- var list, position, length, i; +- +- if (!isFunction(listener)) +- throw TypeError('listener must be a function'); +- +- if (!this._events || !this._events[type]) +- return this; +- +- list = this._events[type]; +- length = list.length; +- position = -1; +- +- if (list === listener || +- (isFunction(list.listener) && list.listener === listener)) { +- delete this._events[type]; +- if (this._events.removeListener) +- this.emit('removeListener', type, listener); +- +- } else if (isObject(list)) { +- for (i = length; i-- > 0;) { +- if (list[i] === listener || +- (list[i].listener && list[i].listener === listener)) { +- position = i; +- break; +- } +- } +- +- if (position < 0) +- return this; +- +- if (list.length === 1) { +- list.length = 0; +- delete this._events[type]; +- } else { +- list.splice(position, 1); +- } +- +- if (this._events.removeListener) +- this.emit('removeListener', type, listener); +- } +- +- return this; +-}; +- +-EventEmitter.prototype.removeAllListeners = function(type) { +- var key, listeners; +- +- if (!this._events) +- return this; +- +- // not listening for removeListener, no need to emit +- if (!this._events.removeListener) { +- if (arguments.length === 0) +- this._events = {}; +- else if (this._events[type]) +- delete this._events[type]; +- return this; +- } +- +- // emit removeListener for all listeners on all events +- if (arguments.length === 0) { +- for (key in this._events) { +- if (key === 'removeListener') continue; +- this.removeAllListeners(key); +- } +- this.removeAllListeners('removeListener'); +- this._events = {}; +- return this; +- } +- +- listeners = this._events[type]; +- +- if (isFunction(listeners)) { +- this.removeListener(type, listeners); +- } else if (listeners) { +- // LIFO order +- while (listeners.length) +- this.removeListener(type, listeners[listeners.length - 1]); +- } +- delete this._events[type]; +- +- return this; +-}; +- +-EventEmitter.prototype.listeners = function(type) { +- var ret; +- if (!this._events || !this._events[type]) +- ret = []; +- else if (isFunction(this._events[type])) +- ret = [this._events[type]]; +- else +- ret = this._events[type].slice(); +- return ret; +-}; +- +-EventEmitter.prototype.listenerCount = function(type) { +- if (this._events) { +- var evlistener = this._events[type]; +- +- if (isFunction(evlistener)) +- return 1; +- else if (evlistener) +- return evlistener.length; +- } +- return 0; +-}; +- +-EventEmitter.listenerCount = function(emitter, type) { +- return emitter.listenerCount(type); +-}; +- +-function isFunction(arg) { +- return typeof arg === 'function'; +-} +- +-function isNumber(arg) { +- return typeof arg === 'number'; +-} +- +-function isObject(arg) { +- return typeof arg === 'object' && arg !== null; +-} +- +-function isUndefined(arg) { +- return arg === void 0; +-} +- +-},{}],15:[function(require,module,exports){ +-// shim for using process in browser +- +-var process = module.exports = {}; +-var queue = []; +-var draining = false; +-var currentQueue; +-var queueIndex = -1; +- +-function cleanUpNextTick() { +- draining = false; +- if (currentQueue.length) { +- queue = currentQueue.concat(queue); +- } else { +- queueIndex = -1; +- } +- if (queue.length) { +- drainQueue(); +- } +-} +- +-function drainQueue() { +- if (draining) { +- return; +- } +- var timeout = setTimeout(cleanUpNextTick); +- draining = true; +- +- var len = queue.length; +- while(len) { +- currentQueue = queue; +- queue = []; +- while (++queueIndex < len) { +- if (currentQueue) { +- currentQueue[queueIndex].run(); +- } +- } +- queueIndex = -1; +- len = queue.length; +- } +- currentQueue = null; +- draining = false; +- clearTimeout(timeout); +-} +- +-process.nextTick = function (fun) { +- var args = new Array(arguments.length - 1); +- if (arguments.length > 1) { +- for (var i = 1; i < arguments.length; i++) { +- args[i - 1] = arguments[i]; +- } +- } +- queue.push(new Item(fun, args)); +- if (queue.length === 1 && !draining) { +- setTimeout(drainQueue, 0); +- } +-}; +- +-// v8 likes predictible objects +-function Item(fun, array) { +- this.fun = fun; +- this.array = array; +-} +-Item.prototype.run = function () { +- this.fun.apply(null, this.array); +-}; +-process.title = 'browser'; +-process.browser = true; +-process.env = {}; +-process.argv = []; +-process.version = ''; // empty string to avoid regexp issues +-process.versions = {}; +- +-function noop() {} +- +-process.on = noop; +-process.addListener = noop; +-process.once = noop; +-process.off = noop; +-process.removeListener = noop; +-process.removeAllListeners = noop; +-process.emit = noop; +- +-process.binding = function (name) { +- throw new Error('process.binding is not supported'); +-}; +- +-process.cwd = function () { return '/' }; +-process.chdir = function (dir) { +- throw new Error('process.chdir is not supported'); +-}; +-process.umask = function() { return 0; }; +- +-},{}],16:[function(require,module,exports){ + !function() { + var d3 = { +- version: "3.5.16" ++ version: "3.5.17" + }; + var d3_arraySlice = [].slice, d3_array = function(list) { + return d3_arraySlice.call(list); +@@ -4246,7 +3853,7 @@ process.umask = function() { return 0; }; + λ0 = λ, sinφ0 = sinφ, cosφ0 = cosφ, point0 = point; + } + } +- return (polarAngle < -ε || polarAngle < ε && d3_geo_areaRingSum < 0) ^ winding & 1; ++ return (polarAngle < -ε || polarAngle < ε && d3_geo_areaRingSum < -ε) ^ winding & 1; + } + function d3_geo_clipCircle(radius) { + var cr = Math.cos(radius), smallRadius = cr > 0, notHemisphere = abs(cr) > ε, interpolate = d3_geo_circleInterpolate(radius, 6 * d3_radians); +@@ -10273,965 +9880,1468 @@ process.umask = function() { return 0; }; + }); + if (typeof define === "function" && define.amd) this.d3 = d3, define(d3); else if (typeof module === "object" && module.exports) module.exports = d3; else this.d3 = d3; + }(); +-},{}],17:[function(require,module,exports){ ++},{}],15:[function(require,module,exports){ + (function (process,global){ + /*! + * @overview es6-promise - a tiny implementation of Promises/A+. + * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald) + * @license Licensed under MIT license +- * See https://raw.githubusercontent.com/jakearchibald/es6-promise/master/LICENSE +- * @version 3.1.2 ++ * See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE ++ * @version 3.3.1 + */ + +-(function() { +- "use strict"; +- function lib$es6$promise$utils$$objectOrFunction(x) { +- return typeof x === 'function' || (typeof x === 'object' && x !== null); +- } ++(function (global, factory) { ++ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : ++ typeof define === 'function' && define.amd ? define(factory) : ++ (global.ES6Promise = factory()); ++}(this, (function () { 'use strict'; + +- function lib$es6$promise$utils$$isFunction(x) { +- return typeof x === 'function'; +- } ++function objectOrFunction(x) { ++ return typeof x === 'function' || typeof x === 'object' && x !== null; ++} + +- function lib$es6$promise$utils$$isMaybeThenable(x) { +- return typeof x === 'object' && x !== null; +- } ++function isFunction(x) { ++ return typeof x === 'function'; ++} + +- var lib$es6$promise$utils$$_isArray; +- if (!Array.isArray) { +- lib$es6$promise$utils$$_isArray = function (x) { +- return Object.prototype.toString.call(x) === '[object Array]'; +- }; ++var _isArray = undefined; ++if (!Array.isArray) { ++ _isArray = function (x) { ++ return Object.prototype.toString.call(x) === '[object Array]'; ++ }; ++} else { ++ _isArray = Array.isArray; ++} ++ ++var isArray = _isArray; ++ ++var len = 0; ++var vertxNext = undefined; ++var customSchedulerFn = undefined; ++ ++var asap = function asap(callback, arg) { ++ queue[len] = callback; ++ queue[len + 1] = arg; ++ len += 2; ++ if (len === 2) { ++ // If len is 2, that means that we need to schedule an async flush. ++ // If additional callbacks are queued before the queue is flushed, they ++ // will be processed by this flush that we are scheduling. ++ if (customSchedulerFn) { ++ customSchedulerFn(flush); + } else { +- lib$es6$promise$utils$$_isArray = Array.isArray; +- } +- +- var lib$es6$promise$utils$$isArray = lib$es6$promise$utils$$_isArray; +- var lib$es6$promise$asap$$len = 0; +- var lib$es6$promise$asap$$vertxNext; +- var lib$es6$promise$asap$$customSchedulerFn; +- +- var lib$es6$promise$asap$$asap = function asap(callback, arg) { +- lib$es6$promise$asap$$queue[lib$es6$promise$asap$$len] = callback; +- lib$es6$promise$asap$$queue[lib$es6$promise$asap$$len + 1] = arg; +- lib$es6$promise$asap$$len += 2; +- if (lib$es6$promise$asap$$len === 2) { +- // If len is 2, that means that we need to schedule an async flush. +- // If additional callbacks are queued before the queue is flushed, they +- // will be processed by this flush that we are scheduling. +- if (lib$es6$promise$asap$$customSchedulerFn) { +- lib$es6$promise$asap$$customSchedulerFn(lib$es6$promise$asap$$flush); +- } else { +- lib$es6$promise$asap$$scheduleFlush(); +- } +- } ++ scheduleFlush(); + } ++ } ++}; + +- function lib$es6$promise$asap$$setScheduler(scheduleFn) { +- lib$es6$promise$asap$$customSchedulerFn = scheduleFn; +- } ++function setScheduler(scheduleFn) { ++ customSchedulerFn = scheduleFn; ++} + +- function lib$es6$promise$asap$$setAsap(asapFn) { +- lib$es6$promise$asap$$asap = asapFn; +- } ++function setAsap(asapFn) { ++ asap = asapFn; ++} + +- var lib$es6$promise$asap$$browserWindow = (typeof window !== 'undefined') ? window : undefined; +- var lib$es6$promise$asap$$browserGlobal = lib$es6$promise$asap$$browserWindow || {}; +- var lib$es6$promise$asap$$BrowserMutationObserver = lib$es6$promise$asap$$browserGlobal.MutationObserver || lib$es6$promise$asap$$browserGlobal.WebKitMutationObserver; +- var lib$es6$promise$asap$$isNode = typeof process !== 'undefined' && {}.toString.call(process) === '[object process]'; ++var browserWindow = typeof window !== 'undefined' ? window : undefined; ++var browserGlobal = browserWindow || {}; ++var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver; ++var isNode = typeof self === 'undefined' && typeof process !== 'undefined' && ({}).toString.call(process) === '[object process]'; + +- // test for web worker but not in IE10 +- var lib$es6$promise$asap$$isWorker = typeof Uint8ClampedArray !== 'undefined' && +- typeof importScripts !== 'undefined' && +- typeof MessageChannel !== 'undefined'; ++// test for web worker but not in IE10 ++var isWorker = typeof Uint8ClampedArray !== 'undefined' && typeof importScripts !== 'undefined' && typeof MessageChannel !== 'undefined'; + +- // node +- function lib$es6$promise$asap$$useNextTick() { +- // node version 0.10.x displays a deprecation warning when nextTick is used recursively +- // see https://github.com/cujojs/when/issues/410 for details +- return function() { +- process.nextTick(lib$es6$promise$asap$$flush); +- }; +- } ++// node ++function useNextTick() { ++ // node version 0.10.x displays a deprecation warning when nextTick is used recursively ++ // see https://github.com/cujojs/when/issues/410 for details ++ return function () { ++ return process.nextTick(flush); ++ }; ++} + +- // vertx +- function lib$es6$promise$asap$$useVertxTimer() { +- return function() { +- lib$es6$promise$asap$$vertxNext(lib$es6$promise$asap$$flush); +- }; +- } ++// vertx ++function useVertxTimer() { ++ return function () { ++ vertxNext(flush); ++ }; ++} + +- function lib$es6$promise$asap$$useMutationObserver() { +- var iterations = 0; +- var observer = new lib$es6$promise$asap$$BrowserMutationObserver(lib$es6$promise$asap$$flush); +- var node = document.createTextNode(''); +- observer.observe(node, { characterData: true }); ++function useMutationObserver() { ++ var iterations = 0; ++ var observer = new BrowserMutationObserver(flush); ++ var node = document.createTextNode(''); ++ observer.observe(node, { characterData: true }); + +- return function() { +- node.data = (iterations = ++iterations % 2); +- }; +- } ++ return function () { ++ node.data = iterations = ++iterations % 2; ++ }; ++} + +- // web worker +- function lib$es6$promise$asap$$useMessageChannel() { +- var channel = new MessageChannel(); +- channel.port1.onmessage = lib$es6$promise$asap$$flush; +- return function () { +- channel.port2.postMessage(0); +- }; +- } ++// web worker ++function useMessageChannel() { ++ var channel = new MessageChannel(); ++ channel.port1.onmessage = flush; ++ return function () { ++ return channel.port2.postMessage(0); ++ }; ++} + +- function lib$es6$promise$asap$$useSetTimeout() { +- return function() { +- setTimeout(lib$es6$promise$asap$$flush, 1); +- }; +- } ++function useSetTimeout() { ++ // Store setTimeout reference so es6-promise will be unaffected by ++ // other code modifying setTimeout (like sinon.useFakeTimers()) ++ var globalSetTimeout = setTimeout; ++ return function () { ++ return globalSetTimeout(flush, 1); ++ }; ++} + +- var lib$es6$promise$asap$$queue = new Array(1000); +- function lib$es6$promise$asap$$flush() { +- for (var i = 0; i < lib$es6$promise$asap$$len; i+=2) { +- var callback = lib$es6$promise$asap$$queue[i]; +- var arg = lib$es6$promise$asap$$queue[i+1]; ++var queue = new Array(1000); ++function flush() { ++ for (var i = 0; i < len; i += 2) { ++ var callback = queue[i]; ++ var arg = queue[i + 1]; + +- callback(arg); ++ callback(arg); + +- lib$es6$promise$asap$$queue[i] = undefined; +- lib$es6$promise$asap$$queue[i+1] = undefined; +- } ++ queue[i] = undefined; ++ queue[i + 1] = undefined; ++ } + +- lib$es6$promise$asap$$len = 0; +- } ++ len = 0; ++} + +- function lib$es6$promise$asap$$attemptVertx() { +- try { +- var r = require; +- var vertx = r('vertx'); +- lib$es6$promise$asap$$vertxNext = vertx.runOnLoop || vertx.runOnContext; +- return lib$es6$promise$asap$$useVertxTimer(); +- } catch(e) { +- return lib$es6$promise$asap$$useSetTimeout(); +- } +- } ++function attemptVertx() { ++ try { ++ var r = require; ++ var vertx = r('vertx'); ++ vertxNext = vertx.runOnLoop || vertx.runOnContext; ++ return useVertxTimer(); ++ } catch (e) { ++ return useSetTimeout(); ++ } ++} + +- var lib$es6$promise$asap$$scheduleFlush; +- // Decide what async method to use to triggering processing of queued callbacks: +- if (lib$es6$promise$asap$$isNode) { +- lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useNextTick(); +- } else if (lib$es6$promise$asap$$BrowserMutationObserver) { +- lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useMutationObserver(); +- } else if (lib$es6$promise$asap$$isWorker) { +- lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useMessageChannel(); +- } else if (lib$es6$promise$asap$$browserWindow === undefined && typeof require === 'function') { +- lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$attemptVertx(); +- } else { +- lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useSetTimeout(); +- } +- function lib$es6$promise$then$$then(onFulfillment, onRejection) { +- var parent = this; +- var state = parent._state; ++var scheduleFlush = undefined; ++// Decide what async method to use to triggering processing of queued callbacks: ++if (isNode) { ++ scheduleFlush = useNextTick(); ++} else if (BrowserMutationObserver) { ++ scheduleFlush = useMutationObserver(); ++} else if (isWorker) { ++ scheduleFlush = useMessageChannel(); ++} else if (browserWindow === undefined && typeof require === 'function') { ++ scheduleFlush = attemptVertx(); ++} else { ++ scheduleFlush = useSetTimeout(); ++} + +- if (state === lib$es6$promise$$internal$$FULFILLED && !onFulfillment || state === lib$es6$promise$$internal$$REJECTED && !onRejection) { +- return this; +- } ++function then(onFulfillment, onRejection) { ++ var _arguments = arguments; + +- var child = new this.constructor(lib$es6$promise$$internal$$noop); +- var result = parent._result; ++ var parent = this; + +- if (state) { +- var callback = arguments[state - 1]; +- lib$es6$promise$asap$$asap(function(){ +- lib$es6$promise$$internal$$invokeCallback(state, child, callback, result); +- }); +- } else { +- lib$es6$promise$$internal$$subscribe(parent, child, onFulfillment, onRejection); +- } ++ var child = new this.constructor(noop); + +- return child; +- } +- var lib$es6$promise$then$$default = lib$es6$promise$then$$then; +- function lib$es6$promise$promise$resolve$$resolve(object) { +- /*jshint validthis:true */ +- var Constructor = this; ++ if (child[PROMISE_ID] === undefined) { ++ makePromise(child); ++ } + +- if (object && typeof object === 'object' && object.constructor === Constructor) { +- return object; +- } ++ var _state = parent._state; + +- var promise = new Constructor(lib$es6$promise$$internal$$noop); +- lib$es6$promise$$internal$$resolve(promise, object); +- return promise; +- } +- var lib$es6$promise$promise$resolve$$default = lib$es6$promise$promise$resolve$$resolve; ++ if (_state) { ++ (function () { ++ var callback = _arguments[_state - 1]; ++ asap(function () { ++ return invokeCallback(_state, child, callback, parent._result); ++ }); ++ })(); ++ } else { ++ subscribe(parent, child, onFulfillment, onRejection); ++ } + +- function lib$es6$promise$$internal$$noop() {} ++ return child; ++} + +- var lib$es6$promise$$internal$$PENDING = void 0; +- var lib$es6$promise$$internal$$FULFILLED = 1; +- var lib$es6$promise$$internal$$REJECTED = 2; ++/** ++ `Promise.resolve` returns a promise that will become resolved with the ++ passed `value`. It is shorthand for the following: + +- var lib$es6$promise$$internal$$GET_THEN_ERROR = new lib$es6$promise$$internal$$ErrorObject(); ++ ```javascript ++ let promise = new Promise(function(resolve, reject){ ++ resolve(1); ++ }); + +- function lib$es6$promise$$internal$$selfFulfillment() { +- return new TypeError("You cannot resolve a promise with itself"); +- } ++ promise.then(function(value){ ++ // value === 1 ++ }); ++ ``` + +- function lib$es6$promise$$internal$$cannotReturnOwn() { +- return new TypeError('A promises callback cannot return that same promise.'); +- } ++ Instead of writing the above, your code now simply becomes the following: + +- function lib$es6$promise$$internal$$getThen(promise) { +- try { +- return promise.then; +- } catch(error) { +- lib$es6$promise$$internal$$GET_THEN_ERROR.error = error; +- return lib$es6$promise$$internal$$GET_THEN_ERROR; +- } +- } ++ ```javascript ++ let promise = Promise.resolve(1); + +- function lib$es6$promise$$internal$$tryThen(then, value, fulfillmentHandler, rejectionHandler) { +- try { +- then.call(value, fulfillmentHandler, rejectionHandler); +- } catch(e) { +- return e; +- } +- } ++ promise.then(function(value){ ++ // value === 1 ++ }); ++ ``` + +- function lib$es6$promise$$internal$$handleForeignThenable(promise, thenable, then) { +- lib$es6$promise$asap$$asap(function(promise) { +- var sealed = false; +- var error = lib$es6$promise$$internal$$tryThen(then, thenable, function(value) { +- if (sealed) { return; } +- sealed = true; +- if (thenable !== value) { +- lib$es6$promise$$internal$$resolve(promise, value); +- } else { +- lib$es6$promise$$internal$$fulfill(promise, value); +- } +- }, function(reason) { +- if (sealed) { return; } +- sealed = true; ++ @method resolve ++ @static ++ @param {Any} value value that the returned promise will be resolved with ++ Useful for tooling. ++ @return {Promise} a promise that will become fulfilled with the given ++ `value` ++*/ ++function resolve(object) { ++ /*jshint validthis:true */ ++ var Constructor = this; + +- lib$es6$promise$$internal$$reject(promise, reason); +- }, 'Settle: ' + (promise._label || ' unknown promise')); ++ if (object && typeof object === 'object' && object.constructor === Constructor) { ++ return object; ++ } + +- if (!sealed && error) { +- sealed = true; +- lib$es6$promise$$internal$$reject(promise, error); +- } +- }, promise); +- } ++ var promise = new Constructor(noop); ++ _resolve(promise, object); ++ return promise; ++} + +- function lib$es6$promise$$internal$$handleOwnThenable(promise, thenable) { +- if (thenable._state === lib$es6$promise$$internal$$FULFILLED) { +- lib$es6$promise$$internal$$fulfill(promise, thenable._result); +- } else if (thenable._state === lib$es6$promise$$internal$$REJECTED) { +- lib$es6$promise$$internal$$reject(promise, thenable._result); +- } else { +- lib$es6$promise$$internal$$subscribe(thenable, undefined, function(value) { +- lib$es6$promise$$internal$$resolve(promise, value); +- }, function(reason) { +- lib$es6$promise$$internal$$reject(promise, reason); +- }); +- } +- } ++var PROMISE_ID = Math.random().toString(36).substring(16); + +- function lib$es6$promise$$internal$$handleMaybeThenable(promise, maybeThenable, then) { +- if (maybeThenable.constructor === promise.constructor && +- then === lib$es6$promise$then$$default && +- constructor.resolve === lib$es6$promise$promise$resolve$$default) { +- lib$es6$promise$$internal$$handleOwnThenable(promise, maybeThenable); +- } else { +- if (then === lib$es6$promise$$internal$$GET_THEN_ERROR) { +- lib$es6$promise$$internal$$reject(promise, lib$es6$promise$$internal$$GET_THEN_ERROR.error); +- } else if (then === undefined) { +- lib$es6$promise$$internal$$fulfill(promise, maybeThenable); +- } else if (lib$es6$promise$utils$$isFunction(then)) { +- lib$es6$promise$$internal$$handleForeignThenable(promise, maybeThenable, then); +- } else { +- lib$es6$promise$$internal$$fulfill(promise, maybeThenable); +- } +- } +- } ++function noop() {} + +- function lib$es6$promise$$internal$$resolve(promise, value) { +- if (promise === value) { +- lib$es6$promise$$internal$$reject(promise, lib$es6$promise$$internal$$selfFulfillment()); +- } else if (lib$es6$promise$utils$$objectOrFunction(value)) { +- lib$es6$promise$$internal$$handleMaybeThenable(promise, value, lib$es6$promise$$internal$$getThen(value)); +- } else { +- lib$es6$promise$$internal$$fulfill(promise, value); +- } +- } ++var PENDING = void 0; ++var FULFILLED = 1; ++var REJECTED = 2; + +- function lib$es6$promise$$internal$$publishRejection(promise) { +- if (promise._onerror) { +- promise._onerror(promise._result); +- } ++var GET_THEN_ERROR = new ErrorObject(); + +- lib$es6$promise$$internal$$publish(promise); +- } ++function selfFulfillment() { ++ return new TypeError("You cannot resolve a promise with itself"); ++} + +- function lib$es6$promise$$internal$$fulfill(promise, value) { +- if (promise._state !== lib$es6$promise$$internal$$PENDING) { return; } ++function cannotReturnOwn() { ++ return new TypeError('A promises callback cannot return that same promise.'); ++} + +- promise._result = value; +- promise._state = lib$es6$promise$$internal$$FULFILLED; ++function getThen(promise) { ++ try { ++ return promise.then; ++ } catch (error) { ++ GET_THEN_ERROR.error = error; ++ return GET_THEN_ERROR; ++ } ++} ++ ++function tryThen(then, value, fulfillmentHandler, rejectionHandler) { ++ try { ++ then.call(value, fulfillmentHandler, rejectionHandler); ++ } catch (e) { ++ return e; ++ } ++} + +- if (promise._subscribers.length !== 0) { +- lib$es6$promise$asap$$asap(lib$es6$promise$$internal$$publish, promise); ++function handleForeignThenable(promise, thenable, then) { ++ asap(function (promise) { ++ var sealed = false; ++ var error = tryThen(then, thenable, function (value) { ++ if (sealed) { ++ return; ++ } ++ sealed = true; ++ if (thenable !== value) { ++ _resolve(promise, value); ++ } else { ++ fulfill(promise, value); + } ++ }, function (reason) { ++ if (sealed) { ++ return; ++ } ++ sealed = true; ++ ++ _reject(promise, reason); ++ }, 'Settle: ' + (promise._label || ' unknown promise')); ++ ++ if (!sealed && error) { ++ sealed = true; ++ _reject(promise, error); + } ++ }, promise); ++} + +- function lib$es6$promise$$internal$$reject(promise, reason) { +- if (promise._state !== lib$es6$promise$$internal$$PENDING) { return; } +- promise._state = lib$es6$promise$$internal$$REJECTED; +- promise._result = reason; ++function handleOwnThenable(promise, thenable) { ++ if (thenable._state === FULFILLED) { ++ fulfill(promise, thenable._result); ++ } else if (thenable._state === REJECTED) { ++ _reject(promise, thenable._result); ++ } else { ++ subscribe(thenable, undefined, function (value) { ++ return _resolve(promise, value); ++ }, function (reason) { ++ return _reject(promise, reason); ++ }); ++ } ++} + +- lib$es6$promise$asap$$asap(lib$es6$promise$$internal$$publishRejection, promise); ++function handleMaybeThenable(promise, maybeThenable, then$$) { ++ if (maybeThenable.constructor === promise.constructor && then$$ === then && maybeThenable.constructor.resolve === resolve) { ++ handleOwnThenable(promise, maybeThenable); ++ } else { ++ if (then$$ === GET_THEN_ERROR) { ++ _reject(promise, GET_THEN_ERROR.error); ++ } else if (then$$ === undefined) { ++ fulfill(promise, maybeThenable); ++ } else if (isFunction(then$$)) { ++ handleForeignThenable(promise, maybeThenable, then$$); ++ } else { ++ fulfill(promise, maybeThenable); + } ++ } ++} + +- function lib$es6$promise$$internal$$subscribe(parent, child, onFulfillment, onRejection) { +- var subscribers = parent._subscribers; +- var length = subscribers.length; ++function _resolve(promise, value) { ++ if (promise === value) { ++ _reject(promise, selfFulfillment()); ++ } else if (objectOrFunction(value)) { ++ handleMaybeThenable(promise, value, getThen(value)); ++ } else { ++ fulfill(promise, value); ++ } ++} + +- parent._onerror = null; ++function publishRejection(promise) { ++ if (promise._onerror) { ++ promise._onerror(promise._result); ++ } + +- subscribers[length] = child; +- subscribers[length + lib$es6$promise$$internal$$FULFILLED] = onFulfillment; +- subscribers[length + lib$es6$promise$$internal$$REJECTED] = onRejection; ++ publish(promise); ++} + +- if (length === 0 && parent._state) { +- lib$es6$promise$asap$$asap(lib$es6$promise$$internal$$publish, parent); +- } +- } ++function fulfill(promise, value) { ++ if (promise._state !== PENDING) { ++ return; ++ } + +- function lib$es6$promise$$internal$$publish(promise) { +- var subscribers = promise._subscribers; +- var settled = promise._state; ++ promise._result = value; ++ promise._state = FULFILLED; + +- if (subscribers.length === 0) { return; } ++ if (promise._subscribers.length !== 0) { ++ asap(publish, promise); ++ } ++} + +- var child, callback, detail = promise._result; ++function _reject(promise, reason) { ++ if (promise._state !== PENDING) { ++ return; ++ } ++ promise._state = REJECTED; ++ promise._result = reason; + +- for (var i = 0; i < subscribers.length; i += 3) { +- child = subscribers[i]; +- callback = subscribers[i + settled]; ++ asap(publishRejection, promise); ++} + +- if (child) { +- lib$es6$promise$$internal$$invokeCallback(settled, child, callback, detail); +- } else { +- callback(detail); +- } +- } ++function subscribe(parent, child, onFulfillment, onRejection) { ++ var _subscribers = parent._subscribers; ++ var length = _subscribers.length; + +- promise._subscribers.length = 0; +- } ++ parent._onerror = null; + +- function lib$es6$promise$$internal$$ErrorObject() { +- this.error = null; +- } ++ _subscribers[length] = child; ++ _subscribers[length + FULFILLED] = onFulfillment; ++ _subscribers[length + REJECTED] = onRejection; + +- var lib$es6$promise$$internal$$TRY_CATCH_ERROR = new lib$es6$promise$$internal$$ErrorObject(); ++ if (length === 0 && parent._state) { ++ asap(publish, parent); ++ } ++} + +- function lib$es6$promise$$internal$$tryCatch(callback, detail) { +- try { +- return callback(detail); +- } catch(e) { +- lib$es6$promise$$internal$$TRY_CATCH_ERROR.error = e; +- return lib$es6$promise$$internal$$TRY_CATCH_ERROR; +- } ++function publish(promise) { ++ var subscribers = promise._subscribers; ++ var settled = promise._state; ++ ++ if (subscribers.length === 0) { ++ return; ++ } ++ ++ var child = undefined, ++ callback = undefined, ++ detail = promise._result; ++ ++ for (var i = 0; i < subscribers.length; i += 3) { ++ child = subscribers[i]; ++ callback = subscribers[i + settled]; ++ ++ if (child) { ++ invokeCallback(settled, child, callback, detail); ++ } else { ++ callback(detail); + } ++ } + +- function lib$es6$promise$$internal$$invokeCallback(settled, promise, callback, detail) { +- var hasCallback = lib$es6$promise$utils$$isFunction(callback), +- value, error, succeeded, failed; ++ promise._subscribers.length = 0; ++} + +- if (hasCallback) { +- value = lib$es6$promise$$internal$$tryCatch(callback, detail); ++function ErrorObject() { ++ this.error = null; ++} + +- if (value === lib$es6$promise$$internal$$TRY_CATCH_ERROR) { +- failed = true; +- error = value.error; +- value = null; +- } else { +- succeeded = true; +- } ++var TRY_CATCH_ERROR = new ErrorObject(); + +- if (promise === value) { +- lib$es6$promise$$internal$$reject(promise, lib$es6$promise$$internal$$cannotReturnOwn()); +- return; +- } ++function tryCatch(callback, detail) { ++ try { ++ return callback(detail); ++ } catch (e) { ++ TRY_CATCH_ERROR.error = e; ++ return TRY_CATCH_ERROR; ++ } ++} + +- } else { +- value = detail; +- succeeded = true; +- } ++function invokeCallback(settled, promise, callback, detail) { ++ var hasCallback = isFunction(callback), ++ value = undefined, ++ error = undefined, ++ succeeded = undefined, ++ failed = undefined; + +- if (promise._state !== lib$es6$promise$$internal$$PENDING) { +- // noop +- } else if (hasCallback && succeeded) { +- lib$es6$promise$$internal$$resolve(promise, value); +- } else if (failed) { +- lib$es6$promise$$internal$$reject(promise, error); +- } else if (settled === lib$es6$promise$$internal$$FULFILLED) { +- lib$es6$promise$$internal$$fulfill(promise, value); +- } else if (settled === lib$es6$promise$$internal$$REJECTED) { +- lib$es6$promise$$internal$$reject(promise, value); +- } ++ if (hasCallback) { ++ value = tryCatch(callback, detail); ++ ++ if (value === TRY_CATCH_ERROR) { ++ failed = true; ++ error = value.error; ++ value = null; ++ } else { ++ succeeded = true; + } + +- function lib$es6$promise$$internal$$initializePromise(promise, resolver) { +- try { +- resolver(function resolvePromise(value){ +- lib$es6$promise$$internal$$resolve(promise, value); +- }, function rejectPromise(reason) { +- lib$es6$promise$$internal$$reject(promise, reason); +- }); +- } catch(e) { +- lib$es6$promise$$internal$$reject(promise, e); +- } ++ if (promise === value) { ++ _reject(promise, cannotReturnOwn()); ++ return; + } ++ } else { ++ value = detail; ++ succeeded = true; ++ } + +- function lib$es6$promise$promise$all$$all(entries) { +- return new lib$es6$promise$enumerator$$default(this, entries).promise; ++ if (promise._state !== PENDING) { ++ // noop ++ } else if (hasCallback && succeeded) { ++ _resolve(promise, value); ++ } else if (failed) { ++ _reject(promise, error); ++ } else if (settled === FULFILLED) { ++ fulfill(promise, value); ++ } else if (settled === REJECTED) { ++ _reject(promise, value); + } +- var lib$es6$promise$promise$all$$default = lib$es6$promise$promise$all$$all; +- function lib$es6$promise$promise$race$$race(entries) { +- /*jshint validthis:true */ +- var Constructor = this; ++} + +- var promise = new Constructor(lib$es6$promise$$internal$$noop); ++function initializePromise(promise, resolver) { ++ try { ++ resolver(function resolvePromise(value) { ++ _resolve(promise, value); ++ }, function rejectPromise(reason) { ++ _reject(promise, reason); ++ }); ++ } catch (e) { ++ _reject(promise, e); ++ } ++} + +- if (!lib$es6$promise$utils$$isArray(entries)) { +- lib$es6$promise$$internal$$reject(promise, new TypeError('You must pass an array to race.')); +- return promise; +- } ++var id = 0; ++function nextId() { ++ return id++; ++} + +- var length = entries.length; ++function makePromise(promise) { ++ promise[PROMISE_ID] = id++; ++ promise._state = undefined; ++ promise._result = undefined; ++ promise._subscribers = []; ++} + +- function onFulfillment(value) { +- lib$es6$promise$$internal$$resolve(promise, value); +- } ++function Enumerator(Constructor, input) { ++ this._instanceConstructor = Constructor; ++ this.promise = new Constructor(noop); + +- function onRejection(reason) { +- lib$es6$promise$$internal$$reject(promise, reason); +- } ++ if (!this.promise[PROMISE_ID]) { ++ makePromise(this.promise); ++ } + +- for (var i = 0; promise._state === lib$es6$promise$$internal$$PENDING && i < length; i++) { +- lib$es6$promise$$internal$$subscribe(Constructor.resolve(entries[i]), undefined, onFulfillment, onRejection); +- } ++ if (isArray(input)) { ++ this._input = input; ++ this.length = input.length; ++ this._remaining = input.length; + +- return promise; +- } +- var lib$es6$promise$promise$race$$default = lib$es6$promise$promise$race$$race; +- function lib$es6$promise$promise$reject$$reject(reason) { +- /*jshint validthis:true */ +- var Constructor = this; +- var promise = new Constructor(lib$es6$promise$$internal$$noop); +- lib$es6$promise$$internal$$reject(promise, reason); +- return promise; ++ this._result = new Array(this.length); ++ ++ if (this.length === 0) { ++ fulfill(this.promise, this._result); ++ } else { ++ this.length = this.length || 0; ++ this._enumerate(); ++ if (this._remaining === 0) { ++ fulfill(this.promise, this._result); ++ } + } +- var lib$es6$promise$promise$reject$$default = lib$es6$promise$promise$reject$$reject; ++ } else { ++ _reject(this.promise, validationError()); ++ } ++} ++ ++function validationError() { ++ return new Error('Array Methods must be provided an Array'); ++}; ++ ++Enumerator.prototype._enumerate = function () { ++ var length = this.length; ++ var _input = this._input; ++ ++ for (var i = 0; this._state === PENDING && i < length; i++) { ++ this._eachEntry(_input[i], i); ++ } ++}; ++ ++Enumerator.prototype._eachEntry = function (entry, i) { ++ var c = this._instanceConstructor; ++ var resolve$$ = c.resolve; + +- var lib$es6$promise$promise$$counter = 0; ++ if (resolve$$ === resolve) { ++ var _then = getThen(entry); + +- function lib$es6$promise$promise$$needsResolver() { +- throw new TypeError('You must pass a resolver function as the first argument to the promise constructor'); ++ if (_then === then && entry._state !== PENDING) { ++ this._settledAt(entry._state, i, entry._result); ++ } else if (typeof _then !== 'function') { ++ this._remaining--; ++ this._result[i] = entry; ++ } else if (c === Promise) { ++ var promise = new c(noop); ++ handleMaybeThenable(promise, entry, _then); ++ this._willSettleAt(promise, i); ++ } else { ++ this._willSettleAt(new c(function (resolve$$) { ++ return resolve$$(entry); ++ }), i); + } ++ } else { ++ this._willSettleAt(resolve$$(entry), i); ++ } ++}; ++ ++Enumerator.prototype._settledAt = function (state, i, value) { ++ var promise = this.promise; + +- function lib$es6$promise$promise$$needsNew() { +- throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function."); ++ if (promise._state === PENDING) { ++ this._remaining--; ++ ++ if (state === REJECTED) { ++ _reject(promise, value); ++ } else { ++ this._result[i] = value; + } ++ } + +- var lib$es6$promise$promise$$default = lib$es6$promise$promise$$Promise; +- /** +- Promise objects represent the eventual result of an asynchronous operation. The +- primary way of interacting with a promise is through its `then` method, which +- registers callbacks to receive either a promise's eventual value or the reason +- why the promise cannot be fulfilled. ++ if (this._remaining === 0) { ++ fulfill(promise, this._result); ++ } ++}; + +- Terminology +- ----------- ++Enumerator.prototype._willSettleAt = function (promise, i) { ++ var enumerator = this; + +- - `promise` is an object or function with a `then` method whose behavior conforms to this specification. +- - `thenable` is an object or function that defines a `then` method. +- - `value` is any legal JavaScript value (including undefined, a thenable, or a promise). +- - `exception` is a value that is thrown using the throw statement. +- - `reason` is a value that indicates why a promise was rejected. +- - `settled` the final resting state of a promise, fulfilled or rejected. ++ subscribe(promise, undefined, function (value) { ++ return enumerator._settledAt(FULFILLED, i, value); ++ }, function (reason) { ++ return enumerator._settledAt(REJECTED, i, reason); ++ }); ++}; + +- A promise can be in one of three states: pending, fulfilled, or rejected. ++/** ++ `Promise.all` accepts an array of promises, and returns a new promise which ++ is fulfilled with an array of fulfillment values for the passed promises, or ++ rejected with the reason of the first passed promise to be rejected. It casts all ++ elements of the passed iterable to promises as it runs this algorithm. + +- Promises that are fulfilled have a fulfillment value and are in the fulfilled +- state. Promises that are rejected have a rejection reason and are in the +- rejected state. A fulfillment value is never a thenable. ++ Example: + +- Promises can also be said to *resolve* a value. If this value is also a +- promise, then the original promise's settled state will match the value's +- settled state. So a promise that *resolves* a promise that rejects will +- itself reject, and a promise that *resolves* a promise that fulfills will +- itself fulfill. ++ ```javascript ++ let promise1 = resolve(1); ++ let promise2 = resolve(2); ++ let promise3 = resolve(3); ++ let promises = [ promise1, promise2, promise3 ]; + ++ Promise.all(promises).then(function(array){ ++ // The array here would be [ 1, 2, 3 ]; ++ }); ++ ``` + +- Basic Usage: +- ------------ ++ If any of the `promises` given to `all` are rejected, the first promise ++ that is rejected will be given as an argument to the returned promises's ++ rejection handler. For example: + +- ```js +- var promise = new Promise(function(resolve, reject) { +- // on success +- resolve(value); ++ Example: + +- // on failure +- reject(reason); +- }); ++ ```javascript ++ let promise1 = resolve(1); ++ let promise2 = reject(new Error("2")); ++ let promise3 = reject(new Error("3")); ++ let promises = [ promise1, promise2, promise3 ]; + +- promise.then(function(value) { +- // on fulfillment +- }, function(reason) { +- // on rejection +- }); +- ``` ++ Promise.all(promises).then(function(array){ ++ // Code here never runs because there are rejected promises! ++ }, function(error) { ++ // error.message === "2" ++ }); ++ ``` + +- Advanced Usage: +- --------------- ++ @method all ++ @static ++ @param {Array} entries array of promises ++ @param {String} label optional string for labeling the promise. ++ Useful for tooling. ++ @return {Promise} promise that is fulfilled when all `promises` have been ++ fulfilled, or rejected if any of them become rejected. ++ @static ++*/ ++function all(entries) { ++ return new Enumerator(this, entries).promise; ++} + +- Promises shine when abstracting away asynchronous interactions such as +- `XMLHttpRequest`s. ++/** ++ `Promise.race` returns a new promise which is settled in the same way as the ++ first passed promise to settle. + +- ```js +- function getJSON(url) { +- return new Promise(function(resolve, reject){ +- var xhr = new XMLHttpRequest(); ++ Example: + +- xhr.open('GET', url); +- xhr.onreadystatechange = handler; +- xhr.responseType = 'json'; +- xhr.setRequestHeader('Accept', 'application/json'); +- xhr.send(); ++ ```javascript ++ let promise1 = new Promise(function(resolve, reject){ ++ setTimeout(function(){ ++ resolve('promise 1'); ++ }, 200); ++ }); + +- function handler() { +- if (this.readyState === this.DONE) { +- if (this.status === 200) { +- resolve(this.response); +- } else { +- reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']')); +- } +- } +- }; +- }); +- } ++ let promise2 = new Promise(function(resolve, reject){ ++ setTimeout(function(){ ++ resolve('promise 2'); ++ }, 100); ++ }); + +- getJSON('/posts.json').then(function(json) { +- // on fulfillment +- }, function(reason) { +- // on rejection +- }); +- ``` ++ Promise.race([promise1, promise2]).then(function(result){ ++ // result === 'promise 2' because it was resolved before promise1 ++ // was resolved. ++ }); ++ ``` ++ ++ `Promise.race` is deterministic in that only the state of the first ++ settled promise matters. For example, even if other promises given to the ++ `promises` array argument are resolved, but the first settled promise has ++ become rejected before the other promises became fulfilled, the returned ++ promise will become rejected: ++ ++ ```javascript ++ let promise1 = new Promise(function(resolve, reject){ ++ setTimeout(function(){ ++ resolve('promise 1'); ++ }, 200); ++ }); + +- Unlike callbacks, promises are great composable primitives. ++ let promise2 = new Promise(function(resolve, reject){ ++ setTimeout(function(){ ++ reject(new Error('promise 2')); ++ }, 100); ++ }); + +- ```js +- Promise.all([ +- getJSON('/posts'), +- getJSON('/comments') +- ]).then(function(values){ +- values[0] // => postsJSON +- values[1] // => commentsJSON ++ Promise.race([promise1, promise2]).then(function(result){ ++ // Code here never runs ++ }, function(reason){ ++ // reason.message === 'promise 2' because promise 2 became rejected before ++ // promise 1 became fulfilled ++ }); ++ ``` + +- return values; +- }); +- ``` +- +- @class Promise +- @param {function} resolver +- Useful for tooling. +- @constructor +- */ +- function lib$es6$promise$promise$$Promise(resolver) { +- this._id = lib$es6$promise$promise$$counter++; +- this._state = undefined; +- this._result = undefined; +- this._subscribers = []; +- +- if (lib$es6$promise$$internal$$noop !== resolver) { +- typeof resolver !== 'function' && lib$es6$promise$promise$$needsResolver(); +- this instanceof lib$es6$promise$promise$$Promise ? lib$es6$promise$$internal$$initializePromise(this, resolver) : lib$es6$promise$promise$$needsNew(); ++ An example real-world use case is implementing timeouts: ++ ++ ```javascript ++ Promise.race([ajax('foo.json'), timeout(5000)]) ++ ``` ++ ++ @method race ++ @static ++ @param {Array} promises array of promises to observe ++ Useful for tooling. ++ @return {Promise} a promise which settles in the same way as the first passed ++ promise to settle. ++*/ ++function race(entries) { ++ /*jshint validthis:true */ ++ var Constructor = this; ++ ++ if (!isArray(entries)) { ++ return new Constructor(function (_, reject) { ++ return reject(new TypeError('You must pass an array to race.')); ++ }); ++ } else { ++ return new Constructor(function (resolve, reject) { ++ var length = entries.length; ++ for (var i = 0; i < length; i++) { ++ Constructor.resolve(entries[i]).then(resolve, reject); + } +- } ++ }); ++ } ++} + +- lib$es6$promise$promise$$Promise.all = lib$es6$promise$promise$all$$default; +- lib$es6$promise$promise$$Promise.race = lib$es6$promise$promise$race$$default; +- lib$es6$promise$promise$$Promise.resolve = lib$es6$promise$promise$resolve$$default; +- lib$es6$promise$promise$$Promise.reject = lib$es6$promise$promise$reject$$default; +- lib$es6$promise$promise$$Promise._setScheduler = lib$es6$promise$asap$$setScheduler; +- lib$es6$promise$promise$$Promise._setAsap = lib$es6$promise$asap$$setAsap; +- lib$es6$promise$promise$$Promise._asap = lib$es6$promise$asap$$asap; ++/** ++ `Promise.reject` returns a promise rejected with the passed `reason`. ++ It is shorthand for the following: + +- lib$es6$promise$promise$$Promise.prototype = { +- constructor: lib$es6$promise$promise$$Promise, ++ ```javascript ++ let promise = new Promise(function(resolve, reject){ ++ reject(new Error('WHOOPS')); ++ }); + +- /** +- The primary way of interacting with a promise is through its `then` method, +- which registers callbacks to receive either a promise's eventual value or the +- reason why the promise cannot be fulfilled. +- +- ```js +- findUser().then(function(user){ +- // user is available +- }, function(reason){ +- // user is unavailable, and you are given the reason why +- }); +- ``` +- +- Chaining +- -------- +- +- The return value of `then` is itself a promise. This second, 'downstream' +- promise is resolved with the return value of the first promise's fulfillment +- or rejection handler, or rejected if the handler throws an exception. +- +- ```js +- findUser().then(function (user) { +- return user.name; +- }, function (reason) { +- return 'default name'; +- }).then(function (userName) { +- // If `findUser` fulfilled, `userName` will be the user's name, otherwise it +- // will be `'default name'` +- }); ++ promise.then(function(value){ ++ // Code here doesn't run because the promise is rejected! ++ }, function(reason){ ++ // reason.message === 'WHOOPS' ++ }); ++ ``` + +- findUser().then(function (user) { +- throw new Error('Found user, but still unhappy'); +- }, function (reason) { +- throw new Error('`findUser` rejected and we're unhappy'); +- }).then(function (value) { +- // never reached +- }, function (reason) { +- // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'. +- // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'. +- }); +- ``` +- If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream. +- +- ```js +- findUser().then(function (user) { +- throw new PedagogicalException('Upstream error'); +- }).then(function (value) { +- // never reached +- }).then(function (value) { +- // never reached +- }, function (reason) { +- // The `PedgagocialException` is propagated all the way down to here +- }); +- ``` ++ Instead of writing the above, your code now simply becomes the following: + +- Assimilation +- ------------ ++ ```javascript ++ let promise = Promise.reject(new Error('WHOOPS')); + +- Sometimes the value you want to propagate to a downstream promise can only be +- retrieved asynchronously. This can be achieved by returning a promise in the +- fulfillment or rejection handler. The downstream promise will then be pending +- until the returned promise is settled. This is called *assimilation*. ++ promise.then(function(value){ ++ // Code here doesn't run because the promise is rejected! ++ }, function(reason){ ++ // reason.message === 'WHOOPS' ++ }); ++ ``` + +- ```js +- findUser().then(function (user) { +- return findCommentsByAuthor(user); +- }).then(function (comments) { +- // The user's comments are now available +- }); +- ``` ++ @method reject ++ @static ++ @param {Any} reason value that the returned promise will be rejected with. ++ Useful for tooling. ++ @return {Promise} a promise rejected with the given `reason`. ++*/ ++function reject(reason) { ++ /*jshint validthis:true */ ++ var Constructor = this; ++ var promise = new Constructor(noop); ++ _reject(promise, reason); ++ return promise; ++} + +- If the assimliated promise rejects, then the downstream promise will also reject. ++function needsResolver() { ++ throw new TypeError('You must pass a resolver function as the first argument to the promise constructor'); ++} + +- ```js +- findUser().then(function (user) { +- return findCommentsByAuthor(user); +- }).then(function (comments) { +- // If `findCommentsByAuthor` fulfills, we'll have the value here +- }, function (reason) { +- // If `findCommentsByAuthor` rejects, we'll have the reason here +- }); +- ``` ++function needsNew() { ++ throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function."); ++} + +- Simple Example +- -------------- ++/** ++ Promise objects represent the eventual result of an asynchronous operation. The ++ primary way of interacting with a promise is through its `then` method, which ++ registers callbacks to receive either a promise's eventual value or the reason ++ why the promise cannot be fulfilled. + +- Synchronous Example ++ Terminology ++ ----------- + +- ```javascript +- var result; ++ - `promise` is an object or function with a `then` method whose behavior conforms to this specification. ++ - `thenable` is an object or function that defines a `then` method. ++ - `value` is any legal JavaScript value (including undefined, a thenable, or a promise). ++ - `exception` is a value that is thrown using the throw statement. ++ - `reason` is a value that indicates why a promise was rejected. ++ - `settled` the final resting state of a promise, fulfilled or rejected. + +- try { +- result = findResult(); +- // success +- } catch(reason) { +- // failure +- } +- ``` ++ A promise can be in one of three states: pending, fulfilled, or rejected. + +- Errback Example ++ Promises that are fulfilled have a fulfillment value and are in the fulfilled ++ state. Promises that are rejected have a rejection reason and are in the ++ rejected state. A fulfillment value is never a thenable. + +- ```js +- findResult(function(result, err){ +- if (err) { +- // failure +- } else { +- // success +- } +- }); +- ``` ++ Promises can also be said to *resolve* a value. If this value is also a ++ promise, then the original promise's settled state will match the value's ++ settled state. So a promise that *resolves* a promise that rejects will ++ itself reject, and a promise that *resolves* a promise that fulfills will ++ itself fulfill. + +- Promise Example; + +- ```javascript +- findResult().then(function(result){ +- // success +- }, function(reason){ +- // failure +- }); +- ``` ++ Basic Usage: ++ ------------ + +- Advanced Example +- -------------- ++ ```js ++ let promise = new Promise(function(resolve, reject) { ++ // on success ++ resolve(value); + +- Synchronous Example ++ // on failure ++ reject(reason); ++ }); + +- ```javascript +- var author, books; ++ promise.then(function(value) { ++ // on fulfillment ++ }, function(reason) { ++ // on rejection ++ }); ++ ``` + +- try { +- author = findAuthor(); +- books = findBooksByAuthor(author); ++ Advanced Usage: ++ --------------- ++ ++ Promises shine when abstracting away asynchronous interactions such as ++ `XMLHttpRequest`s. ++ ++ ```js ++ function getJSON(url) { ++ return new Promise(function(resolve, reject){ ++ let xhr = new XMLHttpRequest(); ++ ++ xhr.open('GET', url); ++ xhr.onreadystatechange = handler; ++ xhr.responseType = 'json'; ++ xhr.setRequestHeader('Accept', 'application/json'); ++ xhr.send(); ++ ++ function handler() { ++ if (this.readyState === this.DONE) { ++ if (this.status === 200) { ++ resolve(this.response); ++ } else { ++ reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']')); ++ } ++ } ++ }; ++ }); ++ } ++ ++ getJSON('/posts.json').then(function(json) { ++ // on fulfillment ++ }, function(reason) { ++ // on rejection ++ }); ++ ``` ++ ++ Unlike callbacks, promises are great composable primitives. ++ ++ ```js ++ Promise.all([ ++ getJSON('/posts'), ++ getJSON('/comments') ++ ]).then(function(values){ ++ values[0] // => postsJSON ++ values[1] // => commentsJSON ++ ++ return values; ++ }); ++ ``` ++ ++ @class Promise ++ @param {function} resolver ++ Useful for tooling. ++ @constructor ++*/ ++function Promise(resolver) { ++ this[PROMISE_ID] = nextId(); ++ this._result = this._state = undefined; ++ this._subscribers = []; ++ ++ if (noop !== resolver) { ++ typeof resolver !== 'function' && needsResolver(); ++ this instanceof Promise ? initializePromise(this, resolver) : needsNew(); ++ } ++} ++ ++Promise.all = all; ++Promise.race = race; ++Promise.resolve = resolve; ++Promise.reject = reject; ++Promise._setScheduler = setScheduler; ++Promise._setAsap = setAsap; ++Promise._asap = asap; ++ ++Promise.prototype = { ++ constructor: Promise, ++ ++ /** ++ The primary way of interacting with a promise is through its `then` method, ++ which registers callbacks to receive either a promise's eventual value or the ++ reason why the promise cannot be fulfilled. ++ ++ ```js ++ findUser().then(function(user){ ++ // user is available ++ }, function(reason){ ++ // user is unavailable, and you are given the reason why ++ }); ++ ``` ++ ++ Chaining ++ -------- ++ ++ The return value of `then` is itself a promise. This second, 'downstream' ++ promise is resolved with the return value of the first promise's fulfillment ++ or rejection handler, or rejected if the handler throws an exception. ++ ++ ```js ++ findUser().then(function (user) { ++ return user.name; ++ }, function (reason) { ++ return 'default name'; ++ }).then(function (userName) { ++ // If `findUser` fulfilled, `userName` will be the user's name, otherwise it ++ // will be `'default name'` ++ }); ++ ++ findUser().then(function (user) { ++ throw new Error('Found user, but still unhappy'); ++ }, function (reason) { ++ throw new Error('`findUser` rejected and we're unhappy'); ++ }).then(function (value) { ++ // never reached ++ }, function (reason) { ++ // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'. ++ // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'. ++ }); ++ ``` ++ If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream. ++ ++ ```js ++ findUser().then(function (user) { ++ throw new PedagogicalException('Upstream error'); ++ }).then(function (value) { ++ // never reached ++ }).then(function (value) { ++ // never reached ++ }, function (reason) { ++ // The `PedgagocialException` is propagated all the way down to here ++ }); ++ ``` ++ ++ Assimilation ++ ------------ ++ ++ Sometimes the value you want to propagate to a downstream promise can only be ++ retrieved asynchronously. This can be achieved by returning a promise in the ++ fulfillment or rejection handler. The downstream promise will then be pending ++ until the returned promise is settled. This is called *assimilation*. ++ ++ ```js ++ findUser().then(function (user) { ++ return findCommentsByAuthor(user); ++ }).then(function (comments) { ++ // The user's comments are now available ++ }); ++ ``` ++ ++ If the assimliated promise rejects, then the downstream promise will also reject. ++ ++ ```js ++ findUser().then(function (user) { ++ return findCommentsByAuthor(user); ++ }).then(function (comments) { ++ // If `findCommentsByAuthor` fulfills, we'll have the value here ++ }, function (reason) { ++ // If `findCommentsByAuthor` rejects, we'll have the reason here ++ }); ++ ``` ++ ++ Simple Example ++ -------------- ++ ++ Synchronous Example ++ ++ ```javascript ++ let result; ++ ++ try { ++ result = findResult(); ++ // success ++ } catch(reason) { ++ // failure ++ } ++ ``` ++ ++ Errback Example ++ ++ ```js ++ findResult(function(result, err){ ++ if (err) { ++ // failure ++ } else { + // success +- } catch(reason) { ++ } ++ }); ++ ``` ++ ++ Promise Example; ++ ++ ```javascript ++ findResult().then(function(result){ ++ // success ++ }, function(reason){ ++ // failure ++ }); ++ ``` ++ ++ Advanced Example ++ -------------- ++ ++ Synchronous Example ++ ++ ```javascript ++ let author, books; ++ ++ try { ++ author = findAuthor(); ++ books = findBooksByAuthor(author); ++ // success ++ } catch(reason) { ++ // failure ++ } ++ ``` ++ ++ Errback Example ++ ++ ```js ++ ++ function foundBooks(books) { ++ ++ } ++ ++ function failure(reason) { ++ ++ } ++ ++ findAuthor(function(author, err){ ++ if (err) { ++ failure(err); + // failure ++ } else { ++ try { ++ findBoooksByAuthor(author, function(books, err) { ++ if (err) { ++ failure(err); ++ } else { ++ try { ++ foundBooks(books); ++ } catch(reason) { ++ failure(reason); ++ } ++ } ++ }); ++ } catch(error) { ++ failure(err); ++ } ++ // success + } +- ``` ++ }); ++ ``` ++ ++ Promise Example; ++ ++ ```javascript ++ findAuthor(). ++ then(findBooksByAuthor). ++ then(function(books){ ++ // found books ++ }).catch(function(reason){ ++ // something went wrong ++ }); ++ ``` ++ ++ @method then ++ @param {Function} onFulfilled ++ @param {Function} onRejected ++ Useful for tooling. ++ @return {Promise} ++ */ ++ then: then, ++ ++ /** ++ `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same ++ as the catch block of a try/catch statement. ++ ++ ```js ++ function findAuthor(){ ++ throw new Error('couldn't find that author'); ++ } ++ ++ // synchronous ++ try { ++ findAuthor(); ++ } catch(reason) { ++ // something went wrong ++ } ++ ++ // async with promises ++ findAuthor().catch(function(reason){ ++ // something went wrong ++ }); ++ ``` ++ ++ @method catch ++ @param {Function} onRejection ++ Useful for tooling. ++ @return {Promise} ++ */ ++ 'catch': function _catch(onRejection) { ++ return this.then(null, onRejection); ++ } ++}; + +- Errback Example ++function polyfill() { ++ var local = undefined; + +- ```js ++ if (typeof global !== 'undefined') { ++ local = global; ++ } else if (typeof self !== 'undefined') { ++ local = self; ++ } else { ++ try { ++ local = Function('return this')(); ++ } catch (e) { ++ throw new Error('polyfill failed because global object is unavailable in this environment'); ++ } ++ } + +- function foundBooks(books) { ++ var P = local.Promise; + +- } ++ if (P) { ++ var promiseToString = null; ++ try { ++ promiseToString = Object.prototype.toString.call(P.resolve()); ++ } catch (e) { ++ // silently ignored ++ } + +- function failure(reason) { ++ if (promiseToString === '[object Promise]' && !P.cast) { ++ return; ++ } ++ } + +- } ++ local.Promise = Promise; ++} + +- findAuthor(function(author, err){ +- if (err) { +- failure(err); +- // failure +- } else { +- try { +- findBoooksByAuthor(author, function(books, err) { +- if (err) { +- failure(err); +- } else { +- try { +- foundBooks(books); +- } catch(reason) { +- failure(reason); +- } +- } +- }); +- } catch(error) { +- failure(err); +- } +- // success +- } +- }); +- ``` ++polyfill(); ++// Strange compat.. ++Promise.polyfill = polyfill; ++Promise.Promise = Promise; + +- Promise Example; ++return Promise; + +- ```javascript +- findAuthor(). +- then(findBooksByAuthor). +- then(function(books){ +- // found books +- }).catch(function(reason){ +- // something went wrong +- }); +- ``` ++}))); ++ ++}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) ++},{"_process":19}],16:[function(require,module,exports){ ++// Copyright Joyent, Inc. and other Node contributors. ++// ++// Permission is hereby granted, free of charge, to any person obtaining a ++// copy of this software and associated documentation files (the ++// "Software"), to deal in the Software without restriction, including ++// without limitation the rights to use, copy, modify, merge, publish, ++// distribute, sublicense, and/or sell copies of the Software, and to permit ++// persons to whom the Software is furnished to do so, subject to the ++// following conditions: ++// ++// The above copyright notice and this permission notice shall be included ++// in all copies or substantial portions of the Software. ++// ++// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ++// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ++// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN ++// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, ++// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR ++// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE ++// USE OR OTHER DEALINGS IN THE SOFTWARE. + +- @method then +- @param {Function} onFulfilled +- @param {Function} onRejected +- Useful for tooling. +- @return {Promise} +- */ +- then: lib$es6$promise$then$$default, ++function EventEmitter() { ++ this._events = this._events || {}; ++ this._maxListeners = this._maxListeners || undefined; ++} ++module.exports = EventEmitter; + +- /** +- `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same +- as the catch block of a try/catch statement. ++// Backwards-compat with node 0.10.x ++EventEmitter.EventEmitter = EventEmitter; + +- ```js +- function findAuthor(){ +- throw new Error('couldn't find that author'); +- } ++EventEmitter.prototype._events = undefined; ++EventEmitter.prototype._maxListeners = undefined; + +- // synchronous +- try { +- findAuthor(); +- } catch(reason) { +- // something went wrong +- } ++// By default EventEmitters will print a warning if more than 10 listeners are ++// added to it. This is a useful default which helps finding memory leaks. ++EventEmitter.defaultMaxListeners = 10; + +- // async with promises +- findAuthor().catch(function(reason){ +- // something went wrong +- }); +- ``` +- +- @method catch +- @param {Function} onRejection +- Useful for tooling. +- @return {Promise} +- */ +- 'catch': function(onRejection) { +- return this.then(null, onRejection); +- } +- }; +- var lib$es6$promise$enumerator$$default = lib$es6$promise$enumerator$$Enumerator; +- function lib$es6$promise$enumerator$$Enumerator(Constructor, input) { +- this._instanceConstructor = Constructor; +- this.promise = new Constructor(lib$es6$promise$$internal$$noop); ++// Obviously not all Emitters should be limited to 10. This function allows ++// that to be increased. Set to zero for unlimited. ++EventEmitter.prototype.setMaxListeners = function(n) { ++ if (!isNumber(n) || n < 0 || isNaN(n)) ++ throw TypeError('n must be a positive number'); ++ this._maxListeners = n; ++ return this; ++}; + +- if (Array.isArray(input)) { +- this._input = input; +- this.length = input.length; +- this._remaining = input.length; ++EventEmitter.prototype.emit = function(type) { ++ var er, handler, len, args, i, listeners; + +- this._result = new Array(this.length); ++ if (!this._events) ++ this._events = {}; + +- if (this.length === 0) { +- lib$es6$promise$$internal$$fulfill(this.promise, this._result); +- } else { +- this.length = this.length || 0; +- this._enumerate(); +- if (this._remaining === 0) { +- lib$es6$promise$$internal$$fulfill(this.promise, this._result); +- } +- } ++ // If there is no 'error' event listener then throw. ++ if (type === 'error') { ++ if (!this._events.error || ++ (isObject(this._events.error) && !this._events.error.length)) { ++ er = arguments[1]; ++ if (er instanceof Error) { ++ throw er; // Unhandled 'error' event + } else { +- lib$es6$promise$$internal$$reject(this.promise, this._validationError()); ++ // At least give some kind of context to the user ++ var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); ++ err.context = er; ++ throw err; + } + } ++ } + +- lib$es6$promise$enumerator$$Enumerator.prototype._validationError = function() { +- return new Error('Array Methods must be provided an Array'); +- }; ++ handler = this._events[type]; + +- lib$es6$promise$enumerator$$Enumerator.prototype._enumerate = function() { +- var length = this.length; +- var input = this._input; ++ if (isUndefined(handler)) ++ return false; + +- for (var i = 0; this._state === lib$es6$promise$$internal$$PENDING && i < length; i++) { +- this._eachEntry(input[i], i); +- } +- }; ++ if (isFunction(handler)) { ++ switch (arguments.length) { ++ // fast cases ++ case 1: ++ handler.call(this); ++ break; ++ case 2: ++ handler.call(this, arguments[1]); ++ break; ++ case 3: ++ handler.call(this, arguments[1], arguments[2]); ++ break; ++ // slower ++ default: ++ args = Array.prototype.slice.call(arguments, 1); ++ handler.apply(this, args); ++ } ++ } else if (isObject(handler)) { ++ args = Array.prototype.slice.call(arguments, 1); ++ listeners = handler.slice(); ++ len = listeners.length; ++ for (i = 0; i < len; i++) ++ listeners[i].apply(this, args); ++ } + +- lib$es6$promise$enumerator$$Enumerator.prototype._eachEntry = function(entry, i) { +- var c = this._instanceConstructor; +- var resolve = c.resolve; ++ return true; ++}; + +- if (resolve === lib$es6$promise$promise$resolve$$default) { +- var then = lib$es6$promise$$internal$$getThen(entry); ++EventEmitter.prototype.addListener = function(type, listener) { ++ var m; + +- if (then === lib$es6$promise$then$$default && +- entry._state !== lib$es6$promise$$internal$$PENDING) { +- this._settledAt(entry._state, i, entry._result); +- } else if (typeof then !== 'function') { +- this._remaining--; +- this._result[i] = entry; +- } else if (c === lib$es6$promise$promise$$default) { +- var promise = new c(lib$es6$promise$$internal$$noop); +- lib$es6$promise$$internal$$handleMaybeThenable(promise, entry, then); +- this._willSettleAt(promise, i); +- } else { +- this._willSettleAt(new c(function(resolve) { resolve(entry); }), i); +- } +- } else { +- this._willSettleAt(resolve(entry), i); +- } +- }; ++ if (!isFunction(listener)) ++ throw TypeError('listener must be a function'); + +- lib$es6$promise$enumerator$$Enumerator.prototype._settledAt = function(state, i, value) { +- var promise = this.promise; ++ if (!this._events) ++ this._events = {}; + +- if (promise._state === lib$es6$promise$$internal$$PENDING) { +- this._remaining--; ++ // To avoid recursion in the case that type === "newListener"! Before ++ // adding it to the listeners, first emit "newListener". ++ if (this._events.newListener) ++ this.emit('newListener', type, ++ isFunction(listener.listener) ? ++ listener.listener : listener); + +- if (state === lib$es6$promise$$internal$$REJECTED) { +- lib$es6$promise$$internal$$reject(promise, value); +- } else { +- this._result[i] = value; +- } +- } ++ if (!this._events[type]) ++ // Optimize the case of one listener. Don't need the extra array object. ++ this._events[type] = listener; ++ else if (isObject(this._events[type])) ++ // If we've already got an array, just append. ++ this._events[type].push(listener); ++ else ++ // Adding the second element, need to change to array. ++ this._events[type] = [this._events[type], listener]; + +- if (this._remaining === 0) { +- lib$es6$promise$$internal$$fulfill(promise, this._result); ++ // Check for listener leak ++ if (isObject(this._events[type]) && !this._events[type].warned) { ++ if (!isUndefined(this._maxListeners)) { ++ m = this._maxListeners; ++ } else { ++ m = EventEmitter.defaultMaxListeners; ++ } ++ ++ if (m && m > 0 && this._events[type].length > m) { ++ this._events[type].warned = true; ++ console.error('(node) warning: possible EventEmitter memory ' + ++ 'leak detected. %d listeners added. ' + ++ 'Use emitter.setMaxListeners() to increase limit.', ++ this._events[type].length); ++ if (typeof console.trace === 'function') { ++ // not supported in IE 10 ++ console.trace(); + } +- }; ++ } ++ } + +- lib$es6$promise$enumerator$$Enumerator.prototype._willSettleAt = function(promise, i) { +- var enumerator = this; ++ return this; ++}; + +- lib$es6$promise$$internal$$subscribe(promise, undefined, function(value) { +- enumerator._settledAt(lib$es6$promise$$internal$$FULFILLED, i, value); +- }, function(reason) { +- enumerator._settledAt(lib$es6$promise$$internal$$REJECTED, i, reason); +- }); +- }; +- function lib$es6$promise$polyfill$$polyfill() { +- var local; ++EventEmitter.prototype.on = EventEmitter.prototype.addListener; + +- if (typeof global !== 'undefined') { +- local = global; +- } else if (typeof self !== 'undefined') { +- local = self; +- } else { +- try { +- local = Function('return this')(); +- } catch (e) { +- throw new Error('polyfill failed because global object is unavailable in this environment'); +- } +- } ++EventEmitter.prototype.once = function(type, listener) { ++ if (!isFunction(listener)) ++ throw TypeError('listener must be a function'); + +- var P = local.Promise; ++ var fired = false; + +- if (P && Object.prototype.toString.call(P.resolve()) === '[object Promise]' && !P.cast) { +- return; ++ function g() { ++ this.removeListener(type, g); ++ ++ if (!fired) { ++ fired = true; ++ listener.apply(this, arguments); ++ } ++ } ++ ++ g.listener = listener; ++ this.on(type, g); ++ ++ return this; ++}; ++ ++// emits a 'removeListener' event iff the listener was removed ++EventEmitter.prototype.removeListener = function(type, listener) { ++ var list, position, length, i; ++ ++ if (!isFunction(listener)) ++ throw TypeError('listener must be a function'); ++ ++ if (!this._events || !this._events[type]) ++ return this; ++ ++ list = this._events[type]; ++ length = list.length; ++ position = -1; ++ ++ if (list === listener || ++ (isFunction(list.listener) && list.listener === listener)) { ++ delete this._events[type]; ++ if (this._events.removeListener) ++ this.emit('removeListener', type, listener); ++ ++ } else if (isObject(list)) { ++ for (i = length; i-- > 0;) { ++ if (list[i] === listener || ++ (list[i].listener && list[i].listener === listener)) { ++ position = i; ++ break; + } ++ } + +- local.Promise = lib$es6$promise$promise$$default; ++ if (position < 0) ++ return this; ++ ++ if (list.length === 1) { ++ list.length = 0; ++ delete this._events[type]; ++ } else { ++ list.splice(position, 1); + } +- var lib$es6$promise$polyfill$$default = lib$es6$promise$polyfill$$polyfill; + +- var lib$es6$promise$umd$$ES6Promise = { +- 'Promise': lib$es6$promise$promise$$default, +- 'polyfill': lib$es6$promise$polyfill$$default +- }; ++ if (this._events.removeListener) ++ this.emit('removeListener', type, listener); ++ } ++ ++ return this; ++}; ++ ++EventEmitter.prototype.removeAllListeners = function(type) { ++ var key, listeners; ++ ++ if (!this._events) ++ return this; + +- /* global define:true module:true window: true */ +- if (typeof define === 'function' && define['amd']) { +- define(function() { return lib$es6$promise$umd$$ES6Promise; }); +- } else if (typeof module !== 'undefined' && module['exports']) { +- module['exports'] = lib$es6$promise$umd$$ES6Promise; +- } else if (typeof this !== 'undefined') { +- this['ES6Promise'] = lib$es6$promise$umd$$ES6Promise; ++ // not listening for removeListener, no need to emit ++ if (!this._events.removeListener) { ++ if (arguments.length === 0) ++ this._events = {}; ++ else if (this._events[type]) ++ delete this._events[type]; ++ return this; ++ } ++ ++ // emit removeListener for all listeners on all events ++ if (arguments.length === 0) { ++ for (key in this._events) { ++ if (key === 'removeListener') continue; ++ this.removeAllListeners(key); + } ++ this.removeAllListeners('removeListener'); ++ this._events = {}; ++ return this; ++ } + +- lib$es6$promise$polyfill$$default(); +-}).call(this); ++ listeners = this._events[type]; + ++ if (isFunction(listeners)) { ++ this.removeListener(type, listeners); ++ } else if (listeners) { ++ // LIFO order ++ while (listeners.length) ++ this.removeListener(type, listeners[listeners.length - 1]); ++ } ++ delete this._events[type]; + +-}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +-},{"_process":15}],18:[function(require,module,exports){ ++ return this; ++}; ++ ++EventEmitter.prototype.listeners = function(type) { ++ var ret; ++ if (!this._events || !this._events[type]) ++ ret = []; ++ else if (isFunction(this._events[type])) ++ ret = [this._events[type]]; ++ else ++ ret = this._events[type].slice(); ++ return ret; ++}; ++ ++EventEmitter.prototype.listenerCount = function(type) { ++ if (this._events) { ++ var evlistener = this._events[type]; ++ ++ if (isFunction(evlistener)) ++ return 1; ++ else if (evlistener) ++ return evlistener.length; ++ } ++ return 0; ++}; ++ ++EventEmitter.listenerCount = function(emitter, type) { ++ return emitter.listenerCount(type); ++}; ++ ++function isFunction(arg) { ++ return typeof arg === 'function'; ++} ++ ++function isNumber(arg) { ++ return typeof arg === 'number'; ++} ++ ++function isObject(arg) { ++ return typeof arg === 'object' && arg !== null; ++} ++ ++function isUndefined(arg) { ++ return arg === void 0; ++} ++ ++},{}],17:[function(require,module,exports){ + /** + * inspired by is-number + * but significantly simplified and sped up by ignoring number and string constructors +@@ -11288,7 +11398,7 @@ module.exports = function(n) { + return n - n < 1; + }; + +-},{}],19:[function(require,module,exports){ ++},{}],18:[function(require,module,exports){ + module.exports = fromQuat; + + /** +@@ -11336,21 +11446,202 @@ function fromQuat(out, q) { + + return out; + }; ++},{}],19:[function(require,module,exports){ ++// shim for using process in browser ++var process = module.exports = {}; ++ ++// cached from whatever global is present so that test runners that stub it ++// don't break things. But we need to wrap it in a try catch in case it is ++// wrapped in strict mode code which doesn't define any globals. It's inside a ++// function because try/catches deoptimize in certain engines. ++ ++var cachedSetTimeout; ++var cachedClearTimeout; ++ ++function defaultSetTimout() { ++ throw new Error('setTimeout has not been defined'); ++} ++function defaultClearTimeout () { ++ throw new Error('clearTimeout has not been defined'); ++} ++(function () { ++ try { ++ if (typeof setTimeout === 'function') { ++ cachedSetTimeout = setTimeout; ++ } else { ++ cachedSetTimeout = defaultSetTimout; ++ } ++ } catch (e) { ++ cachedSetTimeout = defaultSetTimout; ++ } ++ try { ++ if (typeof clearTimeout === 'function') { ++ cachedClearTimeout = clearTimeout; ++ } else { ++ cachedClearTimeout = defaultClearTimeout; ++ } ++ } catch (e) { ++ cachedClearTimeout = defaultClearTimeout; ++ } ++} ()) ++function runTimeout(fun) { ++ if (cachedSetTimeout === setTimeout) { ++ //normal enviroments in sane situations ++ return setTimeout(fun, 0); ++ } ++ // if setTimeout wasn't available but was latter defined ++ if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { ++ cachedSetTimeout = setTimeout; ++ return setTimeout(fun, 0); ++ } ++ try { ++ // when when somebody has screwed with setTimeout but no I.E. maddness ++ return cachedSetTimeout(fun, 0); ++ } catch(e){ ++ try { ++ // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally ++ return cachedSetTimeout.call(null, fun, 0); ++ } catch(e){ ++ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error ++ return cachedSetTimeout.call(this, fun, 0); ++ } ++ } ++ ++ ++} ++function runClearTimeout(marker) { ++ if (cachedClearTimeout === clearTimeout) { ++ //normal enviroments in sane situations ++ return clearTimeout(marker); ++ } ++ // if clearTimeout wasn't available but was latter defined ++ if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { ++ cachedClearTimeout = clearTimeout; ++ return clearTimeout(marker); ++ } ++ try { ++ // when when somebody has screwed with setTimeout but no I.E. maddness ++ return cachedClearTimeout(marker); ++ } catch (e){ ++ try { ++ // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally ++ return cachedClearTimeout.call(null, marker); ++ } catch (e){ ++ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. ++ // Some versions of I.E. have different rules for clearTimeout vs setTimeout ++ return cachedClearTimeout.call(this, marker); ++ } ++ } ++ ++ ++ ++} ++var queue = []; ++var draining = false; ++var currentQueue; ++var queueIndex = -1; ++ ++function cleanUpNextTick() { ++ if (!draining || !currentQueue) { ++ return; ++ } ++ draining = false; ++ if (currentQueue.length) { ++ queue = currentQueue.concat(queue); ++ } else { ++ queueIndex = -1; ++ } ++ if (queue.length) { ++ drainQueue(); ++ } ++} ++ ++function drainQueue() { ++ if (draining) { ++ return; ++ } ++ var timeout = runTimeout(cleanUpNextTick); ++ draining = true; ++ ++ var len = queue.length; ++ while(len) { ++ currentQueue = queue; ++ queue = []; ++ while (++queueIndex < len) { ++ if (currentQueue) { ++ currentQueue[queueIndex].run(); ++ } ++ } ++ queueIndex = -1; ++ len = queue.length; ++ } ++ currentQueue = null; ++ draining = false; ++ runClearTimeout(timeout); ++} ++ ++process.nextTick = function (fun) { ++ var args = new Array(arguments.length - 1); ++ if (arguments.length > 1) { ++ for (var i = 1; i < arguments.length; i++) { ++ args[i - 1] = arguments[i]; ++ } ++ } ++ queue.push(new Item(fun, args)); ++ if (queue.length === 1 && !draining) { ++ runTimeout(drainQueue); ++ } ++}; ++ ++// v8 likes predictible objects ++function Item(fun, array) { ++ this.fun = fun; ++ this.array = array; ++} ++Item.prototype.run = function () { ++ this.fun.apply(null, this.array); ++}; ++process.title = 'browser'; ++process.browser = true; ++process.env = {}; ++process.argv = []; ++process.version = ''; // empty string to avoid regexp issues ++process.versions = {}; ++ ++function noop() {} ++ ++process.on = noop; ++process.addListener = noop; ++process.once = noop; ++process.off = noop; ++process.removeListener = noop; ++process.removeAllListeners = noop; ++process.emit = noop; ++ ++process.binding = function (name) { ++ throw new Error('process.binding is not supported'); ++}; ++ ++process.cwd = function () { return '/' }; ++process.chdir = function (dir) { ++ throw new Error('process.chdir is not supported'); ++}; ++process.umask = function() { return 0; }; ++ + },{}],20:[function(require,module,exports){ +-// TinyColor v1.3.0 ++// TinyColor v1.4.1 + // https://github.com/bgrins/TinyColor + // Brian Grinstead, MIT License + +-(function() { ++(function(Math) { + + var trimLeft = /^\s+/, + trimRight = /\s+$/, + tinyCounter = 0, +- math = Math, +- mathRound = math.round, +- mathMin = math.min, +- mathMax = math.max, +- mathRandom = math.random; ++ mathRound = Math.round, ++ mathMin = Math.min, ++ mathMax = Math.max, ++ mathRandom = Math.random; + + function tinycolor (color, opts) { + +@@ -11458,11 +11749,11 @@ tinycolor.prototype = { + toHexString: function(allow3Char) { + return '#' + this.toHex(allow3Char); + }, +- toHex8: function() { +- return rgbaToHex(this._r, this._g, this._b, this._a); ++ toHex8: function(allow4Char) { ++ return rgbaToHex(this._r, this._g, this._b, this._a, allow4Char); + }, +- toHex8String: function() { +- return '#' + this.toHex8(); ++ toHex8String: function(allow4Char) { ++ return '#' + this.toHex8(allow4Char); + }, + toRgb: function() { + return { r: mathRound(this._r), g: mathRound(this._g), b: mathRound(this._b), a: this._a }; +@@ -11492,13 +11783,13 @@ tinycolor.prototype = { + return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false; + }, + toFilter: function(secondColor) { +- var hex8String = '#' + rgbaToHex(this._r, this._g, this._b, this._a); ++ var hex8String = '#' + rgbaToArgbHex(this._r, this._g, this._b, this._a); + var secondHex8String = hex8String; + var gradientType = this._gradientType ? "GradientType = 1, " : ""; + + if (secondColor) { + var s = tinycolor(secondColor); +- secondHex8String = s.toHex8String(); ++ secondHex8String = '#' + rgbaToArgbHex(s._r, s._g, s._b, s._a); + } + + return "progid:DXImageTransform.Microsoft.gradient("+gradientType+"startColorstr="+hex8String+",endColorstr="+secondHex8String+")"; +@@ -11509,7 +11800,7 @@ tinycolor.prototype = { + + var formattedString = false; + var hasAlpha = this._a < 1 && this._a >= 0; +- var needsAlphaFormat = !formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "name"); ++ var needsAlphaFormat = !formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "hex4" || format === "hex8" || format === "name"); + + if (needsAlphaFormat) { + // Special case for "transparent", all other non-alpha formats +@@ -11531,6 +11822,9 @@ tinycolor.prototype = { + if (format === "hex3") { + formattedString = this.toHexString(true); + } ++ if (format === "hex4") { ++ formattedString = this.toHex8String(true); ++ } + if (format === "hex8") { + formattedString = this.toHex8String(); + } +@@ -11643,6 +11937,9 @@ function inputToRGB(color) { + + var rgb = { r: 0, g: 0, b: 0 }; + var a = 1; ++ var s = null; ++ var v = null; ++ var l = null; + var ok = false; + var format = false; + +@@ -11651,22 +11948,22 @@ function inputToRGB(color) { + } + + if (typeof color == "object") { +- if (color.hasOwnProperty("r") && color.hasOwnProperty("g") && color.hasOwnProperty("b")) { ++ if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) { + rgb = rgbToRgb(color.r, color.g, color.b); + ok = true; + format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb"; + } +- else if (color.hasOwnProperty("h") && color.hasOwnProperty("s") && color.hasOwnProperty("v")) { +- color.s = convertToPercentage(color.s); +- color.v = convertToPercentage(color.v); +- rgb = hsvToRgb(color.h, color.s, color.v); ++ else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) { ++ s = convertToPercentage(color.s); ++ v = convertToPercentage(color.v); ++ rgb = hsvToRgb(color.h, s, v); + ok = true; + format = "hsv"; + } +- else if (color.hasOwnProperty("h") && color.hasOwnProperty("s") && color.hasOwnProperty("l")) { +- color.s = convertToPercentage(color.s); +- color.l = convertToPercentage(color.l); +- rgb = hslToRgb(color.h, color.s, color.l); ++ else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) { ++ s = convertToPercentage(color.s); ++ l = convertToPercentage(color.l); ++ rgb = hslToRgb(color.h, s, l); + ok = true; + format = "hsl"; + } +@@ -11813,7 +12110,7 @@ function rgbToHsv(r, g, b) { + s = bound01(s, 100); + v = bound01(v, 100); + +- var i = math.floor(h), ++ var i = Math.floor(h), + f = h - i, + p = v * (1 - s), + q = v * (1 - f * s), +@@ -11848,9 +12145,29 @@ function rgbToHex(r, g, b, allow3Char) { + + // `rgbaToHex` + // Converts an RGBA color plus alpha transparency to hex +-// Assumes r, g, b and a are contained in the set [0, 255] +-// Returns an 8 character hex +-function rgbaToHex(r, g, b, a) { ++// Assumes r, g, b are contained in the set [0, 255] and ++// a in [0, 1]. Returns a 4 or 8 character rgba hex ++function rgbaToHex(r, g, b, a, allow4Char) { ++ ++ var hex = [ ++ pad2(mathRound(r).toString(16)), ++ pad2(mathRound(g).toString(16)), ++ pad2(mathRound(b).toString(16)), ++ pad2(convertDecimalToHex(a)) ++ ]; ++ ++ // Return a 4 character hex if possible ++ if (allow4Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1) && hex[3].charAt(0) == hex[3].charAt(1)) { ++ return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0); ++ } ++ ++ return hex.join(""); ++} ++ ++// `rgbaToArgbHex` ++// Converts an RGBA color to an ARGB Hex8 string ++// Rarely used, but required for "toFilter()" ++function rgbaToArgbHex(r, g, b, a) { + + var hex = [ + pad2(convertDecimalToHex(a)), +@@ -11932,7 +12249,7 @@ function darken (color, amount) { + // Values outside of this range will be wrapped into this range. + function spin(color, amount) { + var hsl = tinycolor(color).toHsl(); +- var hue = (mathRound(hsl.h) + amount) % 360; ++ var hue = (hsl.h + amount) % 360; + hsl.h = hue < 0 ? 360 + hue : hue; + return tinycolor(hsl); + } +@@ -12019,26 +12336,12 @@ tinycolor.mix = function(color1, color2, amount) { + var rgb2 = tinycolor(color2).toRgb(); + + var p = amount / 100; +- var w = p * 2 - 1; +- var a = rgb2.a - rgb1.a; +- +- var w1; +- +- if (w * a == -1) { +- w1 = w; +- } else { +- w1 = (w + a) / (1 + w * a); +- } +- +- w1 = (w1 + 1) / 2; +- +- var w2 = 1 - w1; + + var rgba = { +- r: rgb2.r * w1 + rgb1.r * w2, +- g: rgb2.g * w1 + rgb1.g * w2, +- b: rgb2.b * w1 + rgb1.b * w2, +- a: rgb2.a * p + rgb1.a * (1 - p) ++ r: ((rgb2.r - rgb1.r) * p) + rgb1.r, ++ g: ((rgb2.g - rgb1.g) * p) + rgb1.g, ++ b: ((rgb2.b - rgb1.b) * p) + rgb1.b, ++ a: ((rgb2.a - rgb1.a) * p) + rgb1.a + }; + + return tinycolor(rgba); +@@ -12324,7 +12627,7 @@ function bound01(n, max) { + } + + // Handle floating point rounding errors +- if ((math.abs(n - max) < 0.000001)) { ++ if ((Math.abs(n - max) < 0.000001)) { + return 1; + } + +@@ -12394,6 +12697,7 @@ var matchers = (function() { + var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?"; + + return { ++ CSS_UNIT: new RegExp(CSS_UNIT), + rgb: new RegExp("rgb" + PERMISSIVE_MATCH3), + rgba: new RegExp("rgba" + PERMISSIVE_MATCH4), + hsl: new RegExp("hsl" + PERMISSIVE_MATCH3), +@@ -12402,10 +12706,18 @@ var matchers = (function() { + hsva: new RegExp("hsva" + PERMISSIVE_MATCH4), + hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/, + hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/, ++ hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/, + hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/ + }; + })(); + ++// `isValidCSSUnit` ++// Take in a single string / number and check to see if it looks like a CSS unit ++// (see `matchers` above for definition). ++function isValidCSSUnit(color) { ++ return !!matchers.CSS_UNIT.exec(color); ++} ++ + // `stringInputToObject` + // Permissive string parsing. Take in a number of formats, and output an object + // based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}` +@@ -12446,10 +12758,10 @@ function stringInputToObject(color) { + } + if ((match = matchers.hex8.exec(color))) { + return { +- a: convertHexToDecimal(match[1]), +- r: parseIntFromHex(match[2]), +- g: parseIntFromHex(match[3]), +- b: parseIntFromHex(match[4]), ++ r: parseIntFromHex(match[1]), ++ g: parseIntFromHex(match[2]), ++ b: parseIntFromHex(match[3]), ++ a: convertHexToDecimal(match[4]), + format: named ? "name" : "hex8" + }; + } +@@ -12461,6 +12773,15 @@ function stringInputToObject(color) { + format: named ? "name" : "hex" + }; + } ++ if ((match = matchers.hex4.exec(color))) { ++ return { ++ r: parseIntFromHex(match[1] + '' + match[1]), ++ g: parseIntFromHex(match[2] + '' + match[2]), ++ b: parseIntFromHex(match[3] + '' + match[3]), ++ a: convertHexToDecimal(match[4] + '' + match[4]), ++ format: named ? "name" : "hex8" ++ }; ++ } + if ((match = matchers.hex3.exec(color))) { + return { + r: parseIntFromHex(match[1] + '' + match[1]), +@@ -12502,7 +12823,7 @@ else { + window.tinycolor = tinycolor; + } + +-})(); ++})(Math); + + },{}],21:[function(require,module,exports){ + /** +@@ -13768,7 +14089,7 @@ function lineIntersect(x1, y1, x2, y2, x3, y3, x4, y4) { + return {x: x1 + a * t, y: y1 + d * t}; + } + +-},{"../../lib":102,"../../lib/setcursor":111,"../../lib/svg_text_utils":113,"../../plotly":120,"../../plots/cartesian/axes":123,"../color":25,"../dragelement":46,"../drawing":48,"./arrow_paths":21,"./attributes":22,"d3":16,"fast-isnumeric":18}],24:[function(require,module,exports){ ++},{"../../lib":102,"../../lib/setcursor":111,"../../lib/svg_text_utils":113,"../../plotly":120,"../../plots/cartesian/axes":123,"../color":25,"../dragelement":46,"../drawing":48,"./arrow_paths":21,"./attributes":22,"d3":14,"fast-isnumeric":17}],24:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -13962,7 +14283,7 @@ function cleanOne(val) { + return 'rgb(' + rgbStr + ')'; + } + +-},{"./attributes":24,"fast-isnumeric":18,"tinycolor2":20}],26:[function(require,module,exports){ ++},{"./attributes":24,"fast-isnumeric":17,"tinycolor2":20}],26:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -14814,7 +15135,7 @@ module.exports = function draw(gd, id) { + return component; + }; + +-},{"../../lib":102,"../../lib/extend":100,"../../lib/setcursor":111,"../../plotly":120,"../../plots/cartesian/axes":123,"../../plots/cartesian/axis_defaults":124,"../../plots/cartesian/layout_attributes":132,"../../plots/cartesian/position_defaults":135,"../../plots/plots":143,"../color":25,"../dragelement":46,"../drawing":48,"../titles":88,"./attributes":26,"d3":16,"tinycolor2":20}],29:[function(require,module,exports){ ++},{"../../lib":102,"../../lib/extend":100,"../../lib/setcursor":111,"../../plotly":120,"../../plots/cartesian/axes":123,"../../plots/cartesian/axis_defaults":124,"../../plots/cartesian/layout_attributes":132,"../../plots/cartesian/position_defaults":135,"../../plots/plots":143,"../color":25,"../dragelement":46,"../drawing":48,"../titles":88,"./attributes":26,"d3":14,"tinycolor2":20}],29:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -15099,7 +15420,7 @@ module.exports = function colorScaleDefaults(traceIn, traceOut, layout, coerce, + if(showScale) colorbarDefaults(containerIn, containerOut, layout); + }; + +-},{"../../lib":102,"../colorbar/defaults":27,"../colorbar/has_colorbar":29,"./flip_scale":36,"./is_valid_scale":40,"fast-isnumeric":18}],36:[function(require,module,exports){ ++},{"../../lib":102,"../colorbar/defaults":27,"../colorbar/has_colorbar":29,"./flip_scale":36,"./is_valid_scale":40,"fast-isnumeric":17}],36:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -15210,7 +15531,7 @@ module.exports = function hasColorscale(trace, containerStr) { + ); + }; + +-},{"../../lib":102,"./is_valid_scale":40,"fast-isnumeric":18}],39:[function(require,module,exports){ ++},{"../../lib":102,"./is_valid_scale":40,"fast-isnumeric":17}],39:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -15349,7 +15670,7 @@ module.exports = function makeScaleFunction(scl, cmin, cmax) { + }; + }; + +-},{"../../lib":102,"../color":25,"d3":16,"fast-isnumeric":18,"tinycolor2":20}],43:[function(require,module,exports){ ++},{"../../lib":102,"../color":25,"d3":14,"fast-isnumeric":17,"tinycolor2":20}],43:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -16351,7 +16672,7 @@ drawing.setClipUrl = function(s, localId) { + s.attr('clip-path', 'url(' + url + ')'); + }; + +-},{"../../constants/xmlns_namespaces":94,"../../lib":102,"../../lib/svg_text_utils":113,"../../plots/plots":143,"../../traces/scatter/make_bubble_size_func":250,"../../traces/scatter/subtypes":255,"../color":25,"../colorscale":39,"./symbol_defs":49,"d3":16,"fast-isnumeric":18}],49:[function(require,module,exports){ ++},{"../../constants/xmlns_namespaces":94,"../../lib":102,"../../lib/svg_text_utils":113,"../../plots/plots":143,"../../traces/scatter/make_bubble_size_func":250,"../../traces/scatter/subtypes":255,"../color":25,"../colorscale":39,"./symbol_defs":49,"d3":14,"fast-isnumeric":17}],49:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -16827,7 +17148,7 @@ module.exports = { + } + }; + +-},{"d3":16}],50:[function(require,module,exports){ ++},{"d3":14}],50:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -16989,7 +17310,7 @@ function calcOneAxis(calcTrace, trace, axis, coord) { + Axes.expand(axis, vals, {padded: true}); + } + +-},{"../../plots/cartesian/axes":123,"../../plots/plots":143,"./compute_error":52,"fast-isnumeric":18}],52:[function(require,module,exports){ ++},{"../../plots/cartesian/axes":123,"../../plots/plots":143,"./compute_error":52,"fast-isnumeric":17}],52:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -17162,7 +17483,7 @@ module.exports = function(traceIn, traceOut, defaultColor, opts) { + } + }; + +-},{"../../lib":102,"../../plots/plots":143,"./attributes":50,"fast-isnumeric":18}],54:[function(require,module,exports){ ++},{"../../lib":102,"../../plots/plots":143,"./attributes":50,"fast-isnumeric":17}],54:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -17342,7 +17663,7 @@ function errorCoords(d, xa, ya) { + return out; + } + +-},{"../../lib":102,"../../traces/scatter/subtypes":255,"d3":16,"fast-isnumeric":18}],56:[function(require,module,exports){ ++},{"../../lib":102,"../../traces/scatter/subtypes":255,"d3":14,"fast-isnumeric":17}],56:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -17379,7 +17700,7 @@ module.exports = function style(traces) { + }); + }; + +-},{"../color":25,"d3":16}],57:[function(require,module,exports){ ++},{"../color":25,"d3":14}],57:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -17733,7 +18054,7 @@ module.exports = function draw(gd) { + imagesAbove.each(applyAttributes); + }; + +-},{"../../plots/cartesian/axes":123,"../drawing":48,"d3":16}],60:[function(require,module,exports){ ++},{"../../plots/cartesian/axes":123,"../drawing":48,"d3":14}],60:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -17850,6 +18171,13 @@ module.exports = { + + + }, ++ horizontalspacing: { ++ valType: 'enumerated', ++ values: ['column', 'wrapped'], ++ dflt: ['column'], ++ ++ ++ }, + traceorder: { + valType: 'flaglist', + flags: ['reversed', 'grouped'], +@@ -17939,6 +18267,7 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { + + var visibleTraces = 0, + defaultOrder = 'normal', ++ defaultHorizontalSpacing = 'column', + defaultX, + defaultY, + defaultXAnchor, +@@ -18003,6 +18332,7 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { + coerce('xanchor', defaultXAnchor); + coerce('y', defaultY); + coerce('yanchor', defaultYAnchor); ++ coerce('horizontalspacing', defaultHorizontalSpacing); + Lib.noneOrAll(containerIn, containerOut, ['x', 'y']); + }; + +@@ -18483,7 +18813,8 @@ function computeLegendDimensions(gd, groups, traces) { + var fullLayout = gd._fullLayout, + opts = fullLayout.legend, + borderwidth = opts.borderwidth, +- isGrouped = helpers.isGrouped(opts); ++ isGrouped = helpers.isGrouped(opts), ++ isHorizontalColumn = helpers.isHorizontalColumn(opts); + + if(helpers.isVertical(opts)) { + if(isGrouped) { +@@ -18590,7 +18921,7 @@ function computeLegendDimensions(gd, groups, traces) { + traces.each(function(d) { + + var legendItem = d[0], +- traceWidth = maxTraceWidth, ++ traceWidth = isHorizontalColumn ? maxTraceWidth : 40 + d[0], + traceGap = opts.tracegroupgap || 5; + + if((borderwidth + offsetX + traceGap + traceWidth) > (fullLayout.width - (fullLayout.margin.r + fullLayout.margin.l))) { +@@ -18679,7 +19010,7 @@ function expandHorizontalMargin(gd) { + }); + } + +-},{"../../lib":102,"../../plotly":120,"../../plots/plots":143,"../color":25,"../dragelement":46,"../drawing":48,"./anchor_utils":61,"./constants":63,"./get_legend_data":66,"./helpers":67,"./style":69,"d3":16}],66:[function(require,module,exports){ ++},{"../../lib":102,"../../plotly":120,"../../plots/plots":143,"../color":25,"../dragelement":46,"../drawing":48,"./anchor_utils":61,"./constants":63,"./get_legend_data":66,"./helpers":67,"./style":69,"d3":14}],66:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -18816,6 +19147,9 @@ exports.isReversed = function isReversed(legendLayout) { + return (legendLayout.traceorder || '').indexOf('reversed') !== -1; + }; + ++exports.isHorizontalColumn = function isReversed(legendLayout) { ++ return legendLayout.horizontalspacing === 'column'; ++}; + },{"../../plots/plots":143}],68:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. +@@ -19061,7 +19395,7 @@ function stylePies(d) { + if(pts.size()) pts.call(stylePie, d[0], trace); + } + +-},{"../../lib":102,"../../plots/plots":143,"../../traces/pie/style_one":234,"../../traces/scatter/subtypes":255,"../color":25,"../drawing":48,"d3":16}],70:[function(require,module,exports){ ++},{"../../lib":102,"../../plots/plots":143,"../../traces/pie/style_one":234,"../../traces/scatter/subtypes":255,"../color":25,"../drawing":48,"d3":14}],70:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -19859,7 +20193,7 @@ function createModeBar(gd, buttons) { + + module.exports = createModeBar; + +-},{"../../../build/ploticon":2,"../../lib":102,"d3":16}],72:[function(require,module,exports){ ++},{"../../../build/ploticon":2,"../../lib":102,"d3":14}],72:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -20613,7 +20947,7 @@ function reposition(gd, buttons, opts, axName) { + }); + } + +-},{"../../lib/svg_text_utils":113,"../../plotly":120,"../../plots/cartesian/axis_ids":125,"../../plots/plots":143,"../color":25,"../drawing":48,"../legend/anchor_utils":61,"./constants":75,"./get_update_object":78,"d3":16}],78:[function(require,module,exports){ ++},{"../../lib/svg_text_utils":113,"../../plotly":120,"../../plots/cartesian/axis_ids":125,"../../plots/plots":143,"../color":25,"../drawing":48,"../legend/anchor_utils":61,"./constants":75,"./get_update_object":78,"d3":14}],78:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -20671,7 +21005,7 @@ function getXRange(axisLayout, buttonLayout) { + return [range0, range1]; + } + +-},{"d3":16}],79:[function(require,module,exports){ ++},{"d3":14}],79:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -21360,7 +21694,7 @@ function makeScatter(trace, pointPairs, w, h) { + return [line, markers, fill]; + } + +-},{"../../constants/xmlns_namespaces":94,"../../lib":102,"../drawing":48,"../drawing/symbol_defs":49,"./helpers":83,"d3":16}],86:[function(require,module,exports){ ++},{"../../constants/xmlns_namespaces":94,"../../lib":102,"../drawing":48,"../drawing/symbol_defs":49,"./helpers":83,"d3":14}],86:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -22241,7 +22575,7 @@ function shapeBounds(ax, v0, v1, path, paramsToUse) { + if(max >= min) return [min, max]; + } + +-},{"../../lib":102,"../../lib/setcursor":111,"../../plotly":120,"../../plots/cartesian/axes":123,"../color":25,"../dragelement":46,"../drawing":48,"./attributes":86,"fast-isnumeric":18}],88:[function(require,module,exports){ ++},{"../../lib":102,"../../lib/setcursor":111,"../../plotly":120,"../../plots/cartesian/axes":123,"../color":25,"../dragelement":46,"../drawing":48,"./attributes":86,"fast-isnumeric":17}],88:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -22471,7 +22805,7 @@ Titles.draw = function(gd, titleClass, options) { + el.classed('js-placeholder', isplaceholder); + }; + +-},{"../../lib":102,"../../lib/svg_text_utils":113,"../../plotly":120,"../../plots/plots":143,"../color":25,"../drawing":48,"d3":16,"fast-isnumeric":18}],89:[function(require,module,exports){ ++},{"../../lib":102,"../../lib/svg_text_utils":113,"../../plotly":120,"../../plots/plots":143,"../color":25,"../drawing":48,"d3":14,"fast-isnumeric":17}],89:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -23219,7 +23553,7 @@ function clearPushMargins(gd) { + } + } + +-},{"../../lib":102,"../../lib/svg_text_utils":113,"../../plotly":120,"../../plots/plots":143,"../color":25,"../drawing":48,"../legend/anchor_utils":61,"./constants":90,"d3":16}],93:[function(require,module,exports){ ++},{"../../lib":102,"../../lib/svg_text_utils":113,"../../plotly":120,"../../plots/plots":143,"../color":25,"../drawing":48,"../legend/anchor_utils":61,"./constants":90,"d3":14}],93:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -23312,7 +23646,7 @@ exports.Queue = Plotly.Queue; + // export d3 used in the bundle + exports.d3 = require('d3'); + +-},{"../build/ploticon":2,"./plot_api/set_plot_config":117,"./plot_api/to_image":118,"./plot_api/validate":119,"./plotly":120,"./snapshot/download":158,"d3":16}],96:[function(require,module,exports){ ++},{"../build/ploticon":2,"./plot_api/set_plot_config":117,"./plot_api/to_image":118,"./plot_api/validate":119,"./plotly":120,"./snapshot/download":158,"d3":14}],96:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -23655,7 +23989,7 @@ exports.validate = function(value, opts) { + return out !== failed; + }; + +-},{"../components/colorscale/get_scale":37,"../components/colorscale/scales":43,"./nested_property":106,"fast-isnumeric":18,"tinycolor2":20}],98:[function(require,module,exports){ ++},{"../components/colorscale/get_scale":37,"../components/colorscale/scales":43,"./nested_property":106,"fast-isnumeric":17,"tinycolor2":20}],98:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -23994,7 +24328,7 @@ exports.parseDate = function(v) { + return out; + }; + +-},{"../lib":102,"d3":16,"fast-isnumeric":18}],99:[function(require,module,exports){ ++},{"../lib":102,"d3":14,"fast-isnumeric":17}],99:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -24128,7 +24462,7 @@ var Events = { + + module.exports = Events; + +-},{"events":14}],100:[function(require,module,exports){ ++},{"events":16}],100:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -24886,7 +25220,7 @@ lib.numSeparate = function(value, separators) { + return x1 + x2; + }; + +-},{"./coerce":97,"./dates":98,"./extend":100,"./is_plain_object":103,"./loggers":104,"./matrix":105,"./nested_property":106,"./notifier":107,"./search":110,"./stats":112,"d3":16}],103:[function(require,module,exports){ ++},{"./coerce":97,"./dates":98,"./extend":100,"./is_plain_object":103,"./loggers":104,"./matrix":105,"./nested_property":106,"./notifier":107,"./search":110,"./stats":112,"d3":14}],103:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -25348,7 +25682,7 @@ function badContainer(container, propStr, propParts) { + }; + } + +-},{"fast-isnumeric":18}],107:[function(require,module,exports){ ++},{"fast-isnumeric":17}],107:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -25425,7 +25759,7 @@ module.exports = function(text, displayLength) { + }); + }; + +-},{"d3":16,"fast-isnumeric":18}],108:[function(require,module,exports){ ++},{"d3":14,"fast-isnumeric":17}],108:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -25988,7 +26322,7 @@ exports.roundUp = function(val, arrayIn, reverse) { + return arrayIn[low]; + }; + +-},{"../lib":102,"fast-isnumeric":18}],111:[function(require,module,exports){ ++},{"../lib":102,"fast-isnumeric":17}],111:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -26107,7 +26441,7 @@ exports.interp = function(arr, n) { + return frac * arr[Math.ceil(n)] + (1 - frac) * arr[Math.floor(n)]; + }; + +-},{"fast-isnumeric":18}],113:[function(require,module,exports){ ++},{"fast-isnumeric":17}],113:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -26608,7 +26942,7 @@ util.makeEditable = function(context, _delegate, options) { + return d3.rebind(this, dispatch, 'on'); + }; + +-},{"../constants/xmlns_namespaces":94,"../lib":102,"../plotly":120,"d3":16}],114:[function(require,module,exports){ ++},{"../constants/xmlns_namespaces":94,"../lib":102,"../plotly":120,"d3":14}],114:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -29723,7 +30057,7 @@ function drawMainTitle(gd) { + }); + } + +-},{"../components/color":25,"../components/drawing":48,"../components/errorbars":54,"../components/images":60,"../components/legend":68,"../components/modebar/manage":72,"../components/rangeselector":79,"../components/rangeslider":84,"../components/shapes":87,"../components/titles":88,"../components/updatemenus":93,"../constants/xmlns_namespaces":94,"../lib":102,"../lib/events":99,"../lib/queue":109,"../plotly":120,"../plots/cartesian/graph_interact":130,"../plots/plots":143,"d3":16,"fast-isnumeric":18,"gl-mat4/fromQuat":19}],115:[function(require,module,exports){ ++},{"../components/color":25,"../components/drawing":48,"../components/errorbars":54,"../components/images":60,"../components/legend":68,"../components/modebar/manage":72,"../components/rangeselector":79,"../components/rangeslider":84,"../components/shapes":87,"../components/titles":88,"../components/updatemenus":93,"../constants/xmlns_namespaces":94,"../lib":102,"../lib/events":99,"../lib/queue":109,"../plotly":120,"../plots/cartesian/graph_interact":130,"../plots/plots":143,"d3":14,"fast-isnumeric":17,"gl-mat4/fromQuat":18}],115:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -30311,7 +30645,7 @@ function toImage(gd, opts) { + + module.exports = toImage; + +-},{"../lib":102,"../plotly":120,"../snapshot":160,"fast-isnumeric":18}],119:[function(require,module,exports){ ++},{"../lib":102,"../plotly":120,"../snapshot":160,"fast-isnumeric":17}],119:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -30799,7 +31133,7 @@ exports.PlotSchema = require('./plot_api/plot_schema'); + // imaging routines + exports.Snapshot = require('./snapshot'); + +-},{"../build/plotcss":1,"./components/annotations":23,"./components/color":25,"./components/colorbar":30,"./components/colorscale":39,"./components/drawing":48,"./components/errorbars":54,"./components/images":60,"./components/legend":68,"./components/modebar":71,"./components/shapes":87,"./components/updatemenus":93,"./fonts/mathjax_config":96,"./lib":102,"./lib/queue":109,"./lib/svg_text_utils":113,"./plot_api/plot_api":114,"./plot_api/plot_config":115,"./plot_api/plot_schema":116,"./plots/cartesian/axes":123,"./plots/cartesian/graph_interact":130,"./plots/plots":143,"./plots/polar/micropolar":146,"./snapshot":160,"./traces/scatter":246,"es6-promise":17}],121:[function(require,module,exports){ ++},{"../build/plotcss":1,"./components/annotations":23,"./components/color":25,"./components/colorbar":30,"./components/colorscale":39,"./components/drawing":48,"./components/errorbars":54,"./components/images":60,"./components/legend":68,"./components/modebar":71,"./components/shapes":87,"./components/updatemenus":93,"./fonts/mathjax_config":96,"./lib":102,"./lib/queue":109,"./lib/svg_text_utils":113,"./plot_api/plot_api":114,"./plot_api/plot_config":115,"./plot_api/plot_schema":116,"./plots/cartesian/axes":123,"./plots/cartesian/graph_interact":130,"./plots/plots":143,"./plots/polar/micropolar":146,"./snapshot":160,"./traces/scatter":246,"es6-promise":15}],121:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -31082,14 +31416,27 @@ axes.getAutoRange = function(ax) { + } + + if(minmin === maxmax) { +- newRange = axReverse ? +- [minmin + 1, ax.rangemode !== 'normal' ? 0 : minmin - 1] : +- [ax.rangemode !== 'normal' ? 0 : minmin - 1, minmin + 1]; ++ var lower = minmin - 1; ++ var upper = minmin + 1; ++ if(ax.rangemode === 'tozero') { ++ newRange = minmin < 0 ? [lower, 0] : [0, upper]; ++ } ++ else if(ax.rangemode === 'nonnegative') { ++ newRange = [Math.max(0, lower), Math.max(0, upper)]; ++ } ++ else { ++ newRange = [lower, upper]; ++ } + } + else if(mbest) { + if(ax.type === 'linear' || ax.type === '-') { +- if(ax.rangemode === 'tozero' && minbest.val >= 0) { +- minbest = {val: 0, pad: 0}; ++ if(ax.rangemode === 'tozero') { ++ if(minbest.val >= 0) { ++ minbest = {val: 0, pad: 0}; ++ } ++ if(maxbest.val <= 0) { ++ maxbest = {val: 0, pad: 0}; ++ } + } + else if(ax.rangemode === 'nonnegative') { + if(minbest.val - mbest * minbest.pad < 0) { +@@ -31103,22 +31450,39 @@ axes.getAutoRange = function(ax) { + // in case it changed again... + mbest = (maxbest.val - minbest.val) / + (ax._length - minbest.pad - maxbest.pad); ++ + } + + newRange = [ + minbest.val - mbest * minbest.pad, + maxbest.val + mbest * maxbest.pad + ]; ++ } + +- // don't let axis have zero size +- if(newRange[0] === newRange[1]) { ++ // don't let axis have zero size, while still respecting tozero and nonnegative ++ if(newRange[0] === newRange[1]) { ++ if(ax.rangemode === 'tozero') { ++ if(newRange[0] < 0) { ++ newRange = [newRange[0], 0]; ++ } ++ else if(newRange[0] > 0) { ++ newRange = [0, newRange[0]]; ++ } ++ else { ++ newRange = [0, 1]; ++ } ++ } ++ else { + newRange = [newRange[0] - 1, newRange[0] + 1]; ++ if(ax.rangemode === 'nonnegative') { ++ newRange[0] = Math.max(0, newRange[0]); ++ } + } ++ } + +- // maintain reversal +- if(axReverse) { +- newRange.reverse(); +- } ++ // maintain reversal ++ if(axReverse) { ++ newRange.reverse(); + } + + return newRange; +@@ -32901,7 +33265,7 @@ function swapAxisAttrs(layout, key, xFullAxes, yFullAxes) { + // rather than built-in % which gives a negative value for negative v + function mod(v, d) { return ((v % d) + d) % d; } + +-},{"../../components/color":25,"../../components/drawing":48,"../../components/titles":88,"../../lib":102,"../../lib/svg_text_utils":113,"../../plotly":120,"./axis_ids":125,"./layout_attributes":132,"./layout_defaults":133,"./set_convert":137,"d3":16,"fast-isnumeric":18}],124:[function(require,module,exports){ ++},{"../../components/color":25,"../../components/drawing":48,"../../components/titles":88,"../../lib":102,"../../lib/svg_text_utils":113,"../../plotly":120,"./axis_ids":125,"./layout_attributes":132,"./layout_defaults":133,"./set_convert":137,"d3":14,"fast-isnumeric":17}],124:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -33184,7 +33548,7 @@ function category(a) { + return curvecats > curvenums * 2; + } + +-},{"../../components/color/attributes":24,"../../lib":102,"../plots":143,"./axis_ids":125,"./category_order_defaults":126,"./clean_datum":127,"./layout_attributes":132,"./ordered_categories":134,"./set_convert":137,"./tick_label_defaults":138,"./tick_mark_defaults":139,"./tick_value_defaults":140,"fast-isnumeric":18,"tinycolor2":20}],125:[function(require,module,exports){ ++},{"../../components/color/attributes":24,"../../lib":102,"../plots":143,"./axis_ids":125,"./category_order_defaults":126,"./clean_datum":127,"./layout_attributes":132,"./ordered_categories":134,"./set_convert":137,"./tick_label_defaults":138,"./tick_mark_defaults":139,"./tick_value_defaults":140,"fast-isnumeric":17,"tinycolor2":20}],125:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -33378,7 +33742,7 @@ module.exports = function cleanDatum(c) { + return c; + }; + +-},{"../../lib":102,"fast-isnumeric":18}],128:[function(require,module,exports){ ++},{"../../lib":102,"fast-isnumeric":17}],128:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -34145,7 +34509,7 @@ function isSelectOrLasso(dragmode) { + return modes.indexOf(dragmode) !== -1; + } + +-},{"../../components/color":25,"../../components/dragelement":46,"../../components/drawing":48,"../../lib":102,"../../lib/setcursor":111,"../../lib/svg_text_utils":113,"../../plotly":120,"./axes":123,"./constants":128,"./select":136,"d3":16,"tinycolor2":20}],130:[function(require,module,exports){ ++},{"../../components/color":25,"../../components/dragelement":46,"../../components/drawing":48,"../../lib":102,"../../lib/setcursor":111,"../../lib/svg_text_utils":113,"../../plotly":120,"./axes":123,"./constants":128,"./select":136,"d3":14,"tinycolor2":20}],130:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -35487,7 +35851,7 @@ fx.inbox = function(v0, v1) { + return Infinity; + }; + +-},{"../../components/color":25,"../../components/dragelement":46,"../../components/drawing":48,"../../lib":102,"../../lib/events":99,"../../lib/svg_text_utils":113,"./axes":123,"./constants":128,"./dragbox":129,"d3":16,"fast-isnumeric":18,"tinycolor2":20}],131:[function(require,module,exports){ ++},{"../../components/color":25,"../../components/dragelement":46,"../../components/drawing":48,"../../lib":102,"../../lib/events":99,"../../lib/svg_text_utils":113,"./axes":123,"./constants":128,"./dragbox":129,"d3":14,"fast-isnumeric":17,"tinycolor2":20}],131:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -36171,7 +36535,7 @@ module.exports = function orderedCategories(axisLetter, categoryorder, categorya + } + }; + +-},{"d3":16}],135:[function(require,module,exports){ ++},{"d3":14}],135:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -36236,7 +36600,7 @@ module.exports = function handlePositionDefaults(containerIn, containerOut, coer + return containerOut; + }; + +-},{"../../lib":102,"fast-isnumeric":18}],136:[function(require,module,exports){ ++},{"../../lib":102,"fast-isnumeric":17}],136:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -36680,7 +37044,7 @@ module.exports = function setConvert(ax) { + ax._forceTick0 = null; + }; + +-},{"../../lib":102,"./axis_ids":125,"./clean_datum":127,"./constants":128,"d3":16,"fast-isnumeric":18}],138:[function(require,module,exports){ ++},{"../../lib":102,"./axis_ids":125,"./clean_datum":127,"./constants":128,"d3":14,"fast-isnumeric":17}],138:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -36837,7 +37201,7 @@ module.exports = function handleTickValueDefaults(containerIn, containerOut, coe + } + }; + +-},{"fast-isnumeric":18}],141:[function(require,module,exports){ ++},{"fast-isnumeric":17}],141:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -38224,7 +38588,7 @@ plots.graphJson = function(gd, dataonly, mode, output, useDefaults) { + return (output === 'object') ? obj : JSON.stringify(obj); + }; + +-},{"../components/color":25,"../lib":102,"../plotly":120,"./attributes":121,"./font_attributes":141,"./layout_attributes":142,"d3":16,"fast-isnumeric":18}],144:[function(require,module,exports){ ++},{"../components/color":25,"../lib":102,"../plotly":120,"./attributes":121,"./font_attributes":141,"./layout_attributes":142,"d3":14,"fast-isnumeric":17}],144:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -39787,7 +40151,7 @@ var extendDeepAll = Plotly.Lib.extendDeepAll; + return exports; + }; + +-},{"../../plotly":120,"./micropolar_manager":147,"d3":16}],147:[function(require,module,exports){ ++},{"../../plotly":120,"./micropolar_manager":147,"d3":14}],147:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -39870,7 +40234,7 @@ manager.fillLayout = function(_gd) { + _gd._fullLayout = extendDeepAll(dflts, _gd.layout); + }; + +-},{"../../plotly":120,"./undo_manager":148,"d3":16}],148:[function(require,module,exports){ ++},{"../../plotly":120,"./undo_manager":148,"d3":14}],148:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -41058,7 +41422,7 @@ function removeZoombox(gd) { + .remove(); + } + +-},{"../../components/color":25,"../../components/dragelement":46,"../../components/drawing":48,"../../components/titles":88,"../../lib":102,"../../lib/extend":100,"../../lib/filter_visible":101,"../../plotly":120,"../cartesian/axes":123,"../cartesian/constants":128,"../cartesian/graph_interact":130,"../cartesian/select":136,"../cartesian/set_convert":137,"d3":16,"tinycolor2":20}],157:[function(require,module,exports){ ++},{"../../components/color":25,"../../components/dragelement":46,"../../components/drawing":48,"../../components/titles":88,"../../lib":102,"../../lib/extend":100,"../../lib/filter_visible":101,"../../plotly":120,"../cartesian/axes":123,"../cartesian/constants":128,"../cartesian/graph_interact":130,"../cartesian/select":136,"../cartesian/set_convert":137,"d3":14,"tinycolor2":20}],157:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -41524,7 +41888,7 @@ function svgToImg(opts) { + + module.exports = svgToImg; + +-},{"../lib":102,"events":14}],162:[function(require,module,exports){ ++},{"../lib":102,"events":16}],162:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -41603,7 +41967,7 @@ function toImage(gd, opts) { + + module.exports = toImage; + +-},{"../lib":102,"../plotly":120,"events":14}],163:[function(require,module,exports){ ++},{"../lib":102,"../plotly":120,"events":16}],163:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -41715,7 +42079,7 @@ module.exports = function toSVG(gd, format) { + return s; + }; + +-},{"../components/color":25,"../components/drawing":48,"../constants/xmlns_namespaces":94,"../lib/svg_text_utils":113,"d3":16}],164:[function(require,module,exports){ ++},{"../components/color":25,"../components/drawing":48,"../constants/xmlns_namespaces":94,"../lib/svg_text_utils":113,"d3":14}],164:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -41876,7 +42240,7 @@ module.exports = function calc(gd, trace) { + return cd; + }; + +-},{"../../components/colorscale/calc":32,"../../components/colorscale/has_colorscale":38,"../../plots/cartesian/axes":123,"fast-isnumeric":18}],167:[function(require,module,exports){ ++},{"../../components/colorscale/calc":32,"../../components/colorscale/has_colorscale":38,"../../plots/cartesian/axes":123,"fast-isnumeric":17}],167:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -42259,7 +42623,7 @@ module.exports = function plot(gd, plotinfo, cdbar) { + + }; + +-},{"../../components/color":25,"../../components/errorbars":54,"../../lib":102,"./arrays_to_calcdata":164,"d3":16,"fast-isnumeric":18}],173:[function(require,module,exports){ ++},{"../../components/color":25,"../../components/errorbars":54,"../../lib":102,"./arrays_to_calcdata":164,"d3":14,"fast-isnumeric":17}],173:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -42490,7 +42854,7 @@ module.exports = function setPositions(gd, plotinfo) { + }); + }; + +-},{"../../lib":102,"../../plots/cartesian/axes":123,"../../plots/plots":143,"fast-isnumeric":18}],174:[function(require,module,exports){ ++},{"../../lib":102,"../../plots/cartesian/axes":123,"../../plots/plots":143,"fast-isnumeric":17}],174:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -42569,7 +42933,7 @@ module.exports = function style(gd) { + s.call(ErrorBars.style); + }; + +-},{"../../components/color":25,"../../components/drawing":48,"../../components/errorbars":54,"d3":16}],175:[function(require,module,exports){ ++},{"../../components/color":25,"../../components/drawing":48,"../../components/errorbars":54,"d3":14}],175:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -42886,7 +43250,7 @@ module.exports = function calc(gd, trace) { + return cd; + }; + +-},{"../../lib":102,"../../plots/cartesian/axes":123,"fast-isnumeric":18}],178:[function(require,module,exports){ ++},{"../../lib":102,"../../plots/cartesian/axes":123,"fast-isnumeric":17}],178:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -43396,7 +43760,7 @@ module.exports = function plot(gd, plotinfo, cdbox) { + }); + }; + +-},{"../../components/drawing":48,"../../lib":102,"d3":16}],184:[function(require,module,exports){ ++},{"../../components/drawing":48,"../../lib":102,"d3":14}],184:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -43528,7 +43892,7 @@ module.exports = function style(gd) { + }); + }; + +-},{"../../components/color":25,"../../components/drawing":48,"d3":16}],186:[function(require,module,exports){ ++},{"../../components/color":25,"../../components/drawing":48,"d3":14}],186:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -43917,7 +44281,7 @@ module.exports = function makeColorMap(trace) { + return colorMap; + }; + +-},{"../../components/colorscale/get_scale":37,"d3":16}],193:[function(require,module,exports){ ++},{"../../components/colorscale/get_scale":37,"d3":14}],193:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -44627,7 +44991,7 @@ function makeClipMask(cd0) { + return z; + } + +-},{"../../components/drawing":48,"../../lib":102,"../heatmap/plot":205,"d3":16}],194:[function(require,module,exports){ ++},{"../../components/drawing":48,"../../lib":102,"../heatmap/plot":205,"d3":14}],194:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -44684,7 +45048,7 @@ module.exports = function style(gd) { + heatmapStyle(gd); + }; + +-},{"../../components/drawing":48,"../heatmap/style":206,"./make_color_map":192,"d3":16}],195:[function(require,module,exports){ ++},{"../../components/drawing":48,"../heatmap/style":206,"./make_color_map":192,"d3":14}],195:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -45238,7 +45602,7 @@ function iterateInterp2d(z, emptyPoints, overshoot) { + return maxFractionalChange; + } + +-},{"../../components/colorscale/calc":32,"../../lib":102,"../../plots/cartesian/axes":123,"../../plots/plots":143,"../histogram2d/calc":217,"./convert_column_xyz":199,"./has_columns":201,"./max_row_length":204,"fast-isnumeric":18}],198:[function(require,module,exports){ ++},{"../../components/colorscale/calc":32,"../../lib":102,"../../plots/cartesian/axes":123,"../../plots/plots":143,"../histogram2d/calc":217,"./convert_column_xyz":199,"./has_columns":201,"./max_row_length":204,"fast-isnumeric":17}],198:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -45284,7 +45648,7 @@ module.exports = function colorbar(gd, cd) { + .options(trace.colorbar)(); + }; + +-},{"../../components/colorbar/draw":28,"../../components/colorscale/get_scale":37,"../../lib":102,"../../plots/plots":143,"d3":16,"fast-isnumeric":18}],199:[function(require,module,exports){ ++},{"../../components/colorbar/draw":28,"../../components/colorscale/get_scale":37,"../../lib":102,"../../plots/plots":143,"d3":14,"fast-isnumeric":17}],199:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -45966,7 +46330,7 @@ function plotOne(gd, plotinfo, cd) { + image3.exit().remove(); + } + +-},{"../../components/colorscale/get_scale":37,"../../constants/xmlns_namespaces":94,"../../lib":102,"../../plots/plots":143,"./max_row_length":204,"d3":16,"tinycolor2":20}],206:[function(require,module,exports){ ++},{"../../components/colorscale/get_scale":37,"../../constants/xmlns_namespaces":94,"../../lib":102,"../../plots/plots":143,"./max_row_length":204,"d3":14,"tinycolor2":20}],206:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -45987,7 +46351,7 @@ module.exports = function style(gd) { + }); + }; + +-},{"d3":16}],207:[function(require,module,exports){ ++},{"d3":14}],207:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -46076,7 +46440,7 @@ function isValidZ(z) { + return (allRowsAreArrays && oneRowIsFilled && hasOneNumber); + } + +-},{"./has_columns":201,"fast-isnumeric":18}],208:[function(require,module,exports){ ++},{"./has_columns":201,"fast-isnumeric":17}],208:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -46314,7 +46678,7 @@ module.exports = { + } + }; + +-},{"fast-isnumeric":18}],212:[function(require,module,exports){ ++},{"fast-isnumeric":17}],212:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -46444,7 +46808,7 @@ module.exports = function calc(gd, trace) { + return cd; + }; + +-},{"../../lib":102,"../../plots/cartesian/axes":123,"./average":209,"./bin_functions":211,"./norm_functions":215,"fast-isnumeric":18}],213:[function(require,module,exports){ ++},{"../../lib":102,"../../plots/cartesian/axes":123,"./average":209,"./bin_functions":211,"./norm_functions":215,"fast-isnumeric":17}],213:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -47432,7 +47796,7 @@ function nextDefaultColor(index) { + return pieDefaultColors[index % pieDefaultColors.length]; + } + +-},{"../../components/color":25,"./helpers":228,"fast-isnumeric":18,"tinycolor2":20}],227:[function(require,module,exports){ ++},{"../../components/color":25,"./helpers":228,"fast-isnumeric":17,"tinycolor2":20}],227:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -48314,7 +48678,7 @@ function maxExtent(tilt, tiltAxisFraction, depth) { + 2 * Math.sqrt(1 - sinTilt * sinTilt * tiltAxisFraction * tiltAxisFraction)); + } + +-},{"../../components/color":25,"../../components/drawing":48,"../../lib/svg_text_utils":113,"../../plots/cartesian/graph_interact":130,"./helpers":228,"d3":16}],233:[function(require,module,exports){ ++},{"../../components/color":25,"../../components/drawing":48,"../../lib/svg_text_utils":113,"../../plots/cartesian/graph_interact":130,"./helpers":228,"d3":14}],233:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -48343,7 +48707,7 @@ module.exports = function style(gd) { + }); + }; + +-},{"./style_one":234,"d3":16}],234:[function(require,module,exports){ ++},{"./style_one":234,"d3":14}],234:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -48785,7 +49149,7 @@ module.exports = function calc(gd, trace) { + return cd; + }; + +-},{"../../lib":102,"../../plots/cartesian/axes":123,"./colorscale_calc":240,"./subtypes":255,"fast-isnumeric":18}],238:[function(require,module,exports){ ++},{"../../lib":102,"../../plots/cartesian/axes":123,"./colorscale_calc":240,"./subtypes":255,"fast-isnumeric":17}],238:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -48879,7 +49243,7 @@ module.exports = function colorbar(gd, cd) { + .options(marker.colorbar)(); + }; + +-},{"../../components/colorbar/draw":28,"../../components/colorscale/get_scale":37,"../../lib":102,"../../plots/plots":143,"d3":16,"fast-isnumeric":18}],240:[function(require,module,exports){ ++},{"../../components/colorbar/draw":28,"../../components/colorscale/get_scale":37,"../../lib":102,"../../plots/plots":143,"d3":14,"fast-isnumeric":17}],240:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -49573,7 +49937,7 @@ module.exports = function makeBubbleSizeFn(trace) { + }; + }; + +-},{"fast-isnumeric":18}],251:[function(require,module,exports){ ++},{"fast-isnumeric":17}],251:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -49926,7 +50290,7 @@ function selectMarkers(gd, plotinfo, cdscatter) { + }); + } + +-},{"../../components/drawing":48,"../../components/errorbars":54,"../../lib":102,"../../lib/polygon":108,"./arrays_to_calcdata":235,"./line_points":248,"./subtypes":255,"d3":16}],253:[function(require,module,exports){ ++},{"../../components/drawing":48,"../../components/errorbars":54,"../../lib":102,"../../lib/polygon":108,"./arrays_to_calcdata":235,"./line_points":248,"./subtypes":255,"d3":14}],253:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -50039,7 +50403,7 @@ module.exports = function style(gd) { + s.call(ErrorBars.style); + }; + +-},{"../../components/drawing":48,"../../components/errorbars":54,"d3":16}],255:[function(require,module,exports){ ++},{"../../components/drawing":48,"../../components/errorbars":54,"d3":14}],255:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -50326,7 +50690,7 @@ module.exports = function calc(gd, trace) { + return cd; + }; + +-},{"../../lib":102,"../../plots/cartesian/axes":123,"../scatter/colorscale_calc":240,"../scatter/subtypes":255,"fast-isnumeric":18}],260:[function(require,module,exports){ ++},{"../../lib":102,"../../plots/cartesian/axes":123,"../scatter/colorscale_calc":240,"../scatter/subtypes":255,"fast-isnumeric":17}],260:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +diff --git a/dist/plotly-cartesian.min.js b/dist/plotly-cartesian.min.js +index f76d38d..159a80b 100644 +--- a/dist/plotly-cartesian.min.js ++++ b/dist/plotly-cartesian.min.js +@@ -4,23 +4,23 @@ + * All rights reserved. + * Licensed under the MIT license + */ +-!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.Plotly=t()}}(function(){var t;return function e(t,n,r){function a(i,l){if(!n[i]){if(!t[i]){var s="function"==typeof require&&require;if(!l&&s)return s(i,!0);if(o)return o(i,!0);var c=new Error("Cannot find module '"+i+"'");throw c.code="MODULE_NOT_FOUND",c}var u=n[i]={exports:{}};t[i][0].call(u.exports,function(e){var n=t[i][1][e];return a(n?n:e)},u,u.exports,e,t,n,r)}return n[i].exports}for(var o="function"==typeof require&&require,i=0;it||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},r.prototype.emit=function(t){var e,n,r,o,s,c;if(this._events||(this._events={}),"error"===t&&(!this._events.error||i(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;throw TypeError('Uncaught, unspecified "error" event.')}if(n=this._events[t],l(n))return!1;if(a(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:o=Array.prototype.slice.call(arguments,1),n.apply(this,o)}else if(i(n))for(o=Array.prototype.slice.call(arguments,1),c=n.slice(),r=c.length,s=0;r>s;s++)c[s].apply(this,o);return!0},r.prototype.addListener=function(t,e){var n;if(!a(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,a(e.listener)?e.listener:e),this._events[t]?i(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,i(this._events[t])&&!this._events[t].warned&&(n=l(this._maxListeners)?r.defaultMaxListeners:this._maxListeners,n&&n>0&&this._events[t].length>n&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(t,e){function n(){this.removeListener(t,n),r||(r=!0,e.apply(this,arguments))}if(!a(e))throw TypeError("listener must be a function");var r=!1;return n.listener=e,this.on(t,n),this},r.prototype.removeListener=function(t,e){var n,r,o,l;if(!a(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(n=this._events[t],o=n.length,r=-1,n===e||a(n.listener)&&n.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(i(n)){for(l=o;l-- >0;)if(n[l]===e||n[l].listener&&n[l].listener===e){r=l;break}if(0>r)return this;1===n.length?(n.length=0,delete this._events[t]):n.splice(r,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},r.prototype.removeAllListeners=function(t){var e,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[t],a(n))this.removeListener(t,n);else if(n)for(;n.length;)this.removeListener(t,n[n.length-1]);return delete this._events[t],this},r.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?a(this._events[t])?[this._events[t]]:this._events[t].slice():[]},r.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(a(e))return 1;if(e)return e.length}return 0},r.listenerCount=function(t,e){return t.listenerCount(e)}},{}],15:[function(t,e,n){function r(){u=!1,l.length?c=l.concat(c):f=-1,c.length&&a()}function a(){if(!u){var t=setTimeout(r);u=!0;for(var e=c.length;e;){for(l=c,c=[];++f1)for(var n=1;nt?-1:t>e?1:t>=e?0:NaN}function o(t){return null===t?NaN:+t}function i(t){return!isNaN(t)}function l(t){return{left:function(e,n,r,a){for(arguments.length<3&&(r=0),arguments.length<4&&(a=e.length);a>r;){var o=r+a>>>1;t(e[o],n)<0?r=o+1:a=o}return r},right:function(e,n,r,a){for(arguments.length<3&&(r=0),arguments.length<4&&(a=e.length);a>r;){var o=r+a>>>1;t(e[o],n)>0?a=o:r=o+1}return r}}}function s(t){return t.length}function c(t){for(var e=1;t*e%1;)e*=10;return e}function u(t,e){for(var n in e)Object.defineProperty(t.prototype,n,{value:e[n],enumerable:!1})}function f(){this._=Object.create(null)}function d(t){return(t+="")===ki||t[0]===Mi?Mi+t:t}function h(t){return(t+="")[0]===Mi?t.slice(1):t}function p(t){return d(t)in this._}function g(t){return(t=d(t))in this._&&delete this._[t]}function m(){var t=[];for(var e in this._)t.push(h(e));return t}function v(){var t=0;for(var e in this._)++t;return t}function y(){for(var t in this._)return!1;return!0}function x(){this._=Object.create(null)}function b(t){return t}function _(t,e,n){return function(){var r=n.apply(e,arguments);return r===e?t:r}}function w(t,e){if(e in t)return e;e=e.charAt(0).toUpperCase()+e.slice(1);for(var n=0,r=Ai.length;r>n;++n){var a=Ai[n]+e;if(a in t)return a}}function k(){}function M(){}function A(t){function e(){for(var e,r=n,a=-1,o=r.length;++an;n++)for(var a,o=t[n],i=0,l=o.length;l>i;i++)(a=o[i])&&e(a,i,n);return t}function Y(t){return Li(t,Ni),t}function X(t){var e,n;return function(r,a,o){var i,l=t[o].update,s=l.length;for(o!=n&&(n=o,e=0),a>=e&&(e=a+1);!(i=l[e])&&++e0&&(t=t.slice(0,l));var c=Di.get(t);return c&&(t=c,s=Q),l?e?a:r:e?k:o}function $(t,e){return function(n){var r=ui.event;ui.event=n,e[0]=this.__data__;try{t.apply(this,e)}finally{ui.event=r}}}function Q(t,e){var n=$(t,e);return function(t){var e=this,r=t.relatedTarget;r&&(r===e||8&r.compareDocumentPosition(e))||n.call(e,t)}}function W(t){var n=".dragsuppress-"+ ++Ri,a="click"+n,o=ui.select(r(t)).on("touchmove"+n,T).on("dragstart"+n,T).on("selectstart"+n,T);if(null==Ii&&(Ii="onselectstart"in t?!1:w(t.style,"userSelect")),Ii){var i=e(t).style,l=i[Ii];i[Ii]="none"}return function(t){if(o.on(n,null),Ii&&(i[Ii]=l),t){var e=function(){o.on(a,null)};o.on(a,function(){T(),e()},!0),setTimeout(e,0)}}}function J(t,e){e.changedTouches&&(e=e.changedTouches[0]);var n=t.ownerSVGElement||t;if(n.createSVGPoint){var a=n.createSVGPoint();if(0>ji){var o=r(t);if(o.scrollX||o.scrollY){n=ui.select("body").append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important");var i=n[0][0].getScreenCTM();ji=!(i.f||i.e),n.remove()}}return ji?(a.x=e.pageX,a.y=e.pageY):(a.x=e.clientX,a.y=e.clientY),a=a.matrixTransform(t.getScreenCTM().inverse()),[a.x,a.y]}var l=t.getBoundingClientRect();return[e.clientX-l.left-t.clientLeft,e.clientY-l.top-t.clientTop]}function K(){return ui.event.changedTouches[0].identifier}function tt(t){return t>0?1:0>t?-1:0}function et(t,e,n){return(e[0]-t[0])*(n[1]-t[1])-(e[1]-t[1])*(n[0]-t[0])}function nt(t){return t>1?0:-1>t?Bi:Math.acos(t)}function rt(t){return t>1?Zi:-1>t?-Zi:Math.asin(t)}function at(t){return((t=Math.exp(t))-1/t)/2}function ot(t){return((t=Math.exp(t))+1/t)/2}function it(t){return((t=Math.exp(2*t))-1)/(t+1)}function lt(t){return(t=Math.sin(t/2))*t}function st(){}function ct(t,e,n){return this instanceof ct?(this.h=+t,this.s=+e,void(this.l=+n)):arguments.length<2?t instanceof ct?new ct(t.h,t.s,t.l):kt(""+t,Mt,ct):new ct(t,e,n)}function ut(t,e,n){function r(t){return t>360?t-=360:0>t&&(t+=360),60>t?o+(i-o)*t/60:180>t?i:240>t?o+(i-o)*(240-t)/60:o}function a(t){return Math.round(255*r(t))}var o,i;return t=isNaN(t)?0:(t%=360)<0?t+360:t,e=isNaN(e)?0:0>e?0:e>1?1:e,n=0>n?0:n>1?1:n,i=.5>=n?n*(1+e):n+e-n*e,o=2*n-i,new xt(a(t+120),a(t),a(t-120))}function ft(t,e,n){return this instanceof ft?(this.h=+t,this.c=+e,void(this.l=+n)):arguments.length<2?t instanceof ft?new ft(t.h,t.c,t.l):t instanceof ht?gt(t.l,t.a,t.b):gt((t=At((t=ui.rgb(t)).r,t.g,t.b)).l,t.a,t.b):new ft(t,e,n)}function dt(t,e,n){return isNaN(t)&&(t=0),isNaN(e)&&(e=0),new ht(n,Math.cos(t*=Ui)*e,Math.sin(t)*e)}function ht(t,e,n){return this instanceof ht?(this.l=+t,this.a=+e,void(this.b=+n)):arguments.length<2?t instanceof ht?new ht(t.l,t.a,t.b):t instanceof ft?dt(t.h,t.c,t.l):At((t=xt(t)).r,t.g,t.b):new ht(t,e,n)}function pt(t,e,n){var r=(t+16)/116,a=r+e/500,o=r-n/200;return a=mt(a)*nl,r=mt(r)*rl,o=mt(o)*al,new xt(yt(3.2404542*a-1.5371385*r-.4985314*o),yt(-.969266*a+1.8760108*r+.041556*o),yt(.0556434*a-.2040259*r+1.0572252*o))}function gt(t,e,n){return t>0?new ft(Math.atan2(n,e)*Yi,Math.sqrt(e*e+n*n),t):new ft(NaN,NaN,t)}function mt(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function vt(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function yt(t){return Math.round(255*(.00304>=t?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}function xt(t,e,n){return this instanceof xt?(this.r=~~t,this.g=~~e,void(this.b=~~n)):arguments.length<2?t instanceof xt?new xt(t.r,t.g,t.b):kt(""+t,xt,ut):new xt(t,e,n)}function bt(t){return new xt(t>>16,t>>8&255,255&t)}function _t(t){return bt(t)+""}function wt(t){return 16>t?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function kt(t,e,n){var r,a,o,i=0,l=0,s=0;if(r=/([a-z]+)\((.*)\)/.exec(t=t.toLowerCase()))switch(a=r[2].split(","),r[1]){case"hsl":return n(parseFloat(a[0]),parseFloat(a[1])/100,parseFloat(a[2])/100);case"rgb":return e(Lt(a[0]),Lt(a[1]),Lt(a[2]))}return(o=ll.get(t))?e(o.r,o.g,o.b):(null==t||"#"!==t.charAt(0)||isNaN(o=parseInt(t.slice(1),16))||(4===t.length?(i=(3840&o)>>4,i=i>>4|i,l=240&o,l=l>>4|l,s=15&o,s=s<<4|s):7===t.length&&(i=(16711680&o)>>16,l=(65280&o)>>8,s=255&o)),e(i,l,s))}function Mt(t,e,n){var r,a,o=Math.min(t/=255,e/=255,n/=255),i=Math.max(t,e,n),l=i-o,s=(i+o)/2;return l?(a=.5>s?l/(i+o):l/(2-i-o),r=t==i?(e-n)/l+(n>e?6:0):e==i?(n-t)/l+2:(t-e)/l+4,r*=60):(r=NaN,a=s>0&&1>s?0:r),new ct(r,a,s)}function At(t,e,n){t=Tt(t),e=Tt(e),n=Tt(n);var r=vt((.4124564*t+.3575761*e+.1804375*n)/nl),a=vt((.2126729*t+.7151522*e+.072175*n)/rl),o=vt((.0193339*t+.119192*e+.9503041*n)/al);return ht(116*a-16,500*(r-a),200*(a-o))}function Tt(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Lt(t){var e=parseFloat(t);return"%"===t.charAt(t.length-1)?Math.round(2.55*e):e}function zt(t){return"function"==typeof t?t:function(){return t}}function St(t){return function(e,n,r){return 2===arguments.length&&"function"==typeof n&&(r=n,n=null),Ct(e,n,t,r)}}function Ct(t,e,n,r){function a(){var t,e=s.status;if(!e&&Ot(s)||e>=200&&300>e||304===e){try{t=n.call(o,s)}catch(r){return void i.error.call(o,r)}i.load.call(o,t)}else i.error.call(o,s)}var o={},i=ui.dispatch("beforesend","progress","load","error"),l={},s=new XMLHttpRequest,c=null;return!this.XDomainRequest||"withCredentials"in s||!/^(http(s)?:)?\/\//.test(t)||(s=new XDomainRequest),"onload"in s?s.onload=s.onerror=a:s.onreadystatechange=function(){s.readyState>3&&a()},s.onprogress=function(t){var e=ui.event;ui.event=t;try{i.progress.call(o,s)}finally{ui.event=e}},o.header=function(t,e){return t=(t+"").toLowerCase(),arguments.length<2?l[t]:(null==e?delete l[t]:l[t]=e+"",o)},o.mimeType=function(t){return arguments.length?(e=null==t?null:t+"",o):e},o.responseType=function(t){return arguments.length?(c=t,o):c},o.response=function(t){return n=t,o},["get","post"].forEach(function(t){o[t]=function(){return o.send.apply(o,[t].concat(di(arguments)))}}),o.send=function(n,r,a){if(2===arguments.length&&"function"==typeof r&&(a=r,r=null),s.open(n,t,!0),null==e||"accept"in l||(l.accept=e+",*/*"),s.setRequestHeader)for(var u in l)s.setRequestHeader(u,l[u]);return null!=e&&s.overrideMimeType&&s.overrideMimeType(e),null!=c&&(s.responseType=c),null!=a&&o.on("error",a).on("load",function(t){a(null,t)}),i.beforesend.call(o,s),s.send(null==r?null:r),o},o.abort=function(){return s.abort(),o},ui.rebind(o,i,"on"),null==r?o:o.get(Et(r))}function Et(t){return 1===t.length?function(e,n){t(null==e?n:null)}:t}function Ot(t){var e=t.responseType;return e&&"text"!==e?t.response:t.responseText}function Pt(t,e,n){var r=arguments.length;2>r&&(e=0),3>r&&(n=Date.now());var a=n+e,o={c:t,t:a,n:null};return cl?cl.n=o:sl=o,cl=o,ul||(fl=clearTimeout(fl),ul=1,dl(Nt)),o}function Nt(){var t=Dt(),e=It()-t;e>24?(isFinite(e)&&(clearTimeout(fl),fl=setTimeout(Nt,e)),ul=0):(ul=1,dl(Nt))}function Dt(){for(var t=Date.now(),e=sl;e;)t>=e.t&&e.c(t-e.t)&&(e.c=null),e=e.n;return t}function It(){for(var t,e=sl,n=1/0;e;)e.c?(e.t8?function(t){return t/n}:function(t){return t*n},symbol:t}}function Ft(t){var e=t.decimal,n=t.thousands,r=t.grouping,a=t.currency,o=r&&n?function(t,e){for(var a=t.length,o=[],i=0,l=r[0],s=0;a>0&&l>0&&(s+l+1>e&&(l=Math.max(1,e-s)),o.push(t.substring(a-=l,a+l)),!((s+=l+1)>e));)l=r[i=(i+1)%r.length];return o.reverse().join(n)}:b;return function(t){var n=pl.exec(t),r=n[1]||" ",i=n[2]||">",l=n[3]||"-",s=n[4]||"",c=n[5],u=+n[6],f=n[7],d=n[8],h=n[9],p=1,g="",m="",v=!1,y=!0;switch(d&&(d=+d.substring(1)),(c||"0"===r&&"="===i)&&(c=r="0",i="="),h){case"n":f=!0,h="g";break;case"%":p=100,m="%",h="f";break;case"p":p=100,m="%",h="r";break;case"b":case"o":case"x":case"X":"#"===s&&(g="0"+h.toLowerCase());case"c":y=!1;case"d":v=!0,d=0;break;case"s":p=-1,h="r"}"$"===s&&(g=a[0],m=a[1]),"r"!=h||d||(h="g"),null!=d&&("g"==h?d=Math.max(1,Math.min(21,d)):"e"!=h&&"f"!=h||(d=Math.max(0,Math.min(20,d)))),h=gl.get(h)||qt;var x=c&&f;return function(t){var n=m;if(v&&t%1)return"";var a=0>t||0===t&&0>1/t?(t=-t,"-"):"-"===l?"":l;if(0>p){var s=ui.formatPrefix(t,d);t=s.scale(t),n=s.symbol+m}else t*=p;t=h(t,d);var b,_,w=t.lastIndexOf(".");if(0>w){var k=y?t.lastIndexOf("e"):-1;0>k?(b=t,_=""):(b=t.substring(0,k),_=t.substring(k))}else b=t.substring(0,w),_=e+t.substring(w+1);!c&&f&&(b=o(b,1/0));var M=g.length+b.length+_.length+(x?0:a.length),A=u>M?new Array(M=u-M+1).join(r):"";return x&&(b=o(A+b,A.length?u-_.length:1/0)),a+=g,t=b+_,("<"===i?a+t+A:">"===i?A+a+t:"^"===i?A.substring(0,M>>=1)+a+t+A.substring(M):a+(x?t:A+t))+n}}}function qt(t){return t+""}function Bt(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}function Ht(t,e,n){function r(e){var n=t(e),r=o(n,1);return r-e>e-n?n:r}function a(n){return e(n=t(new vl(n-1)),1),n}function o(t,n){return e(t=new vl(+t),n),t}function i(t,r,o){var i=a(t),l=[];if(o>1)for(;r>i;)n(i)%o||l.push(new Date(+i)),e(i,1);else for(;r>i;)l.push(new Date(+i)),e(i,1);return l}function l(t,e,n){try{vl=Bt;var r=new Bt;return r._=t,i(r,e,n)}finally{vl=Date}}t.floor=t,t.round=r,t.ceil=a,t.offset=o,t.range=i;var s=t.utc=Vt(t);return s.floor=s,s.round=Vt(r),s.ceil=Vt(a),s.offset=Vt(o),s.range=l,t}function Vt(t){return function(e,n){try{vl=Bt;var r=new Bt; +-return r._=e,t(r,n)._}finally{vl=Date}}}function Zt(t){function e(t){function e(e){for(var n,a,o,i=[],l=-1,s=0;++ll;){if(r>=c)return-1;if(a=e.charCodeAt(l++),37===a){if(i=e.charAt(l++),o=S[i in xl?e.charAt(l++):i],!o||(r=o(t,n,r))<0)return-1}else if(a!=n.charCodeAt(r++))return-1}return r}function r(t,e,n){w.lastIndex=0;var r=w.exec(e.slice(n));return r?(t.w=k.get(r[0].toLowerCase()),n+r[0].length):-1}function a(t,e,n){b.lastIndex=0;var r=b.exec(e.slice(n));return r?(t.w=_.get(r[0].toLowerCase()),n+r[0].length):-1}function o(t,e,n){T.lastIndex=0;var r=T.exec(e.slice(n));return r?(t.m=L.get(r[0].toLowerCase()),n+r[0].length):-1}function i(t,e,n){M.lastIndex=0;var r=M.exec(e.slice(n));return r?(t.m=A.get(r[0].toLowerCase()),n+r[0].length):-1}function l(t,e,r){return n(t,z.c.toString(),e,r)}function s(t,e,r){return n(t,z.x.toString(),e,r)}function c(t,e,r){return n(t,z.X.toString(),e,r)}function u(t,e,n){var r=x.get(e.slice(n,n+=2).toLowerCase());return null==r?-1:(t.p=r,n)}var f=t.dateTime,d=t.date,h=t.time,p=t.periods,g=t.days,m=t.shortDays,v=t.months,y=t.shortMonths;e.utc=function(t){function n(t){try{vl=Bt;var e=new vl;return e._=t,r(e)}finally{vl=Date}}var r=e(t);return n.parse=function(t){try{vl=Bt;var e=r.parse(t);return e&&e._}finally{vl=Date}},n.toString=r.toString,n},e.multi=e.utc.multi=ue;var x=ui.map(),b=Yt(g),_=Xt(g),w=Yt(m),k=Xt(m),M=Yt(v),A=Xt(v),T=Yt(y),L=Xt(y);p.forEach(function(t,e){x.set(t.toLowerCase(),e)});var z={a:function(t){return m[t.getDay()]},A:function(t){return g[t.getDay()]},b:function(t){return y[t.getMonth()]},B:function(t){return v[t.getMonth()]},c:e(f),d:function(t,e){return Ut(t.getDate(),e,2)},e:function(t,e){return Ut(t.getDate(),e,2)},H:function(t,e){return Ut(t.getHours(),e,2)},I:function(t,e){return Ut(t.getHours()%12||12,e,2)},j:function(t,e){return Ut(1+ml.dayOfYear(t),e,3)},L:function(t,e){return Ut(t.getMilliseconds(),e,3)},m:function(t,e){return Ut(t.getMonth()+1,e,2)},M:function(t,e){return Ut(t.getMinutes(),e,2)},p:function(t){return p[+(t.getHours()>=12)]},S:function(t,e){return Ut(t.getSeconds(),e,2)},U:function(t,e){return Ut(ml.sundayOfYear(t),e,2)},w:function(t){return t.getDay()},W:function(t,e){return Ut(ml.mondayOfYear(t),e,2)},x:e(d),X:e(h),y:function(t,e){return Ut(t.getFullYear()%100,e,2)},Y:function(t,e){return Ut(t.getFullYear()%1e4,e,4)},Z:se,"%":function(){return"%"}},S={a:r,A:a,b:o,B:i,c:l,d:ne,e:ne,H:ae,I:ae,j:re,L:le,m:ee,M:oe,p:u,S:ie,U:$t,w:Gt,W:Qt,x:s,X:c,y:Jt,Y:Wt,Z:Kt,"%":ce};return e}function Ut(t,e,n){var r=0>t?"-":"",a=(r?-t:t)+"",o=a.length;return r+(n>o?new Array(n-o+1).join(e)+a:a)}function Yt(t){return new RegExp("^(?:"+t.map(ui.requote).join("|")+")","i")}function Xt(t){for(var e=new f,n=-1,r=t.length;++n68?1900:2e3)}function ee(t,e,n){bl.lastIndex=0;var r=bl.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function ne(t,e,n){bl.lastIndex=0;var r=bl.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function re(t,e,n){bl.lastIndex=0;var r=bl.exec(e.slice(n,n+3));return r?(t.j=+r[0],n+r[0].length):-1}function ae(t,e,n){bl.lastIndex=0;var r=bl.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function oe(t,e,n){bl.lastIndex=0;var r=bl.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function ie(t,e,n){bl.lastIndex=0;var r=bl.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function le(t,e,n){bl.lastIndex=0;var r=bl.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function se(t){var e=t.getTimezoneOffset(),n=e>0?"-":"+",r=wi(e)/60|0,a=wi(e)%60;return n+Ut(r,"0",2)+Ut(a,"0",2)}function ce(t,e,n){_l.lastIndex=0;var r=_l.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function ue(t){for(var e=t.length,n=-1;++n=0?1:-1,l=i*n,s=Math.cos(e),c=Math.sin(e),u=o*c,f=a*s+u*Math.cos(l),d=u*i*Math.sin(l);Ll.add(Math.atan2(d,f)),r=t,a=s,o=c}var e,n,r,a,o;zl.point=function(i,l){zl.point=t,r=(e=i)*Ui,a=Math.cos(l=(n=l)*Ui/2+Bi/4),o=Math.sin(l)},zl.lineEnd=function(){t(e,n)}}function ve(t){var e=t[0],n=t[1],r=Math.cos(n);return[r*Math.cos(e),r*Math.sin(e),Math.sin(n)]}function ye(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function xe(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function be(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function _e(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function we(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function ke(t){return[Math.atan2(t[1],t[0]),rt(t[2])]}function Me(t,e){return wi(t[0]-e[0])l;++l)a.point((n=t[l])[0],n[1]);return void a.lineEnd()}var s=new Ne(n,t,null,!0),c=new Ne(n,null,s,!1);s.o=c,o.push(s),i.push(c),s=new Ne(r,t,null,!1),c=new Ne(r,null,s,!0),s.o=c,o.push(s),i.push(c)}}),i.sort(e),Pe(o),Pe(i),o.length){for(var l=0,s=n,c=i.length;c>l;++l)i[l].e=s=!s;for(var u,f,d=o[0];;){for(var h=d,p=!0;h.v;)if((h=h.n)===d)return;u=h.z,a.lineStart();do{if(h.v=h.o.v=!0,h.e){if(p)for(var l=0,c=u.length;c>l;++l)a.point((f=u[l])[0],f[1]);else r(h.x,h.n.x,1,a);h=h.n}else{if(p){u=h.p.z;for(var l=u.length-1;l>=0;--l)a.point((f=u[l])[0],f[1])}else r(h.x,h.p.x,-1,a);h=h.p}h=h.o,u=h.z,p=!p}while(!h.v);a.lineEnd()}}}function Pe(t){if(e=t.length){for(var e,n,r=0,a=t[0];++r0){for(_||(o.polygonStart(),_=!0),o.lineStart();++i1&&2&e&&n.push(n.pop().concat(n.shift())),h.push(n.filter(Ie))}var h,p,g,m=e(o),v=a.invert(r[0],r[1]),y={point:i,lineStart:s,lineEnd:c,polygonStart:function(){y.point=u,y.lineStart=f,y.lineEnd=d,h=[],p=[]},polygonEnd:function(){y.point=i,y.lineStart=s,y.lineEnd=c,h=ui.merge(h);var t=He(v,p);h.length?(_||(o.polygonStart(),_=!0),Oe(h,je,t,n,o)):t&&(_||(o.polygonStart(),_=!0),o.lineStart(),n(null,null,1,o),o.lineEnd()),_&&(o.polygonEnd(),_=!1),h=p=null},sphere:function(){o.polygonStart(),o.lineStart(),n(null,null,1,o),o.lineEnd(),o.polygonEnd()}},x=Re(),b=e(x),_=!1;return y}}function Ie(t){return t.length>1}function Re(){var t,e=[];return{lineStart:function(){e.push(t=[])},point:function(e,n){t.push([e,n])},lineEnd:k,buffer:function(){var n=e;return e=[],t=null,n},rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))}}}function je(t,e){return((t=t.x)[0]<0?t[1]-Zi-Fi:Zi-t[1])-((e=e.x)[0]<0?e[1]-Zi-Fi:Zi-e[1])}function Fe(t){var e,n=NaN,r=NaN,a=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(o,i){var l=o>0?Bi:-Bi,s=wi(o-n);wi(s-Bi)0?Zi:-Zi),t.point(a,r),t.lineEnd(),t.lineStart(),t.point(l,r),t.point(o,r),e=0):a!==l&&s>=Bi&&(wi(n-a)Fi?Math.atan((Math.sin(e)*(o=Math.cos(r))*Math.sin(n)-Math.sin(r)*(a=Math.cos(e))*Math.sin(t))/(a*o*i)):(e+r)/2}function Be(t,e,n,r){var a;if(null==t)a=n*Zi,r.point(-Bi,a),r.point(0,a),r.point(Bi,a),r.point(Bi,0),r.point(Bi,-a),r.point(0,-a),r.point(-Bi,-a),r.point(-Bi,0),r.point(-Bi,a);else if(wi(t[0]-e[0])>Fi){var o=t[0]l;++l){var c=e[l],u=c.length;if(u)for(var f=c[0],d=f[0],h=f[1]/2+Bi/4,p=Math.sin(h),g=Math.cos(h),m=1;;){m===u&&(m=0),t=c[m];var v=t[0],y=t[1]/2+Bi/4,x=Math.sin(y),b=Math.cos(y),_=v-d,w=_>=0?1:-1,k=w*_,M=k>Bi,A=p*x;if(Ll.add(Math.atan2(A*w*Math.sin(k),g*b+A*Math.cos(k))),o+=M?_+w*Hi:_,M^d>=n^v>=n){var T=xe(ve(f),ve(t));we(T);var L=xe(a,T);we(L);var z=(M^_>=0?-1:1)*rt(L[2]);(r>z||r===z&&(T[0]||T[1]))&&(i+=M^_>=0?1:-1)}if(!m++)break;d=v,p=x,g=b,f=t}}return(-Fi>o||Fi>o&&0>Ll)^1&i}function Ve(t){function e(t,e){return Math.cos(t)*Math.cos(e)>o}function n(t){var n,o,s,c,u;return{lineStart:function(){c=s=!1,u=1},point:function(f,d){var h,p=[f,d],g=e(f,d),m=i?g?0:a(f,d):g?a(f+(0>f?Bi:-Bi),d):0;if(!n&&(c=s=g)&&t.lineStart(),g!==s&&(h=r(n,p),(Me(n,h)||Me(p,h))&&(p[0]+=Fi,p[1]+=Fi,g=e(p[0],p[1]))),g!==s)u=0,g?(t.lineStart(),h=r(p,n),t.point(h[0],h[1])):(h=r(n,p),t.point(h[0],h[1]),t.lineEnd()),n=h;else if(l&&n&&i^g){var v;m&o||!(v=r(p,n,!0))||(u=0,i?(t.lineStart(),t.point(v[0][0],v[0][1]),t.point(v[1][0],v[1][1]),t.lineEnd()):(t.point(v[1][0],v[1][1]),t.lineEnd(),t.lineStart(),t.point(v[0][0],v[0][1])))}!g||n&&Me(n,p)||t.point(p[0],p[1]),n=p,s=g,o=m},lineEnd:function(){s&&t.lineEnd(),n=null},clean:function(){return u|(c&&s)<<1}}}function r(t,e,n){var r=ve(t),a=ve(e),i=[1,0,0],l=xe(r,a),s=ye(l,l),c=l[0],u=s-c*c;if(!u)return!n&&t;var f=o*s/u,d=-o*c/u,h=xe(i,l),p=_e(i,f),g=_e(l,d);be(p,g);var m=h,v=ye(p,m),y=ye(m,m),x=v*v-y*(ye(p,p)-1);if(!(0>x)){var b=Math.sqrt(x),_=_e(m,(-v-b)/y);if(be(_,p),_=ke(_),!n)return _;var w,k=t[0],M=e[0],A=t[1],T=e[1];k>M&&(w=k,k=M,M=w);var L=M-k,z=wi(L-Bi)L;if(!z&&A>T&&(w=A,A=T,T=w),S?z?A+T>0^_[1]<(wi(_[0]-k)Bi^(k<=_[0]&&_[0]<=M)){var C=_e(m,(-v+b)/y);return be(C,p),[_,ke(C)]}}}function a(e,n){var r=i?t:Bi-t,a=0;return-r>e?a|=1:e>r&&(a|=2),-r>n?a|=4:n>r&&(a|=8),a}var o=Math.cos(t),i=o>0,l=wi(o)>Fi,s=vn(t,6*Ui);return De(e,n,s,i?[0,-t]:[-Bi,t-Bi])}function Ze(t,e,n,r){return function(a){var o,i=a.a,l=a.b,s=i.x,c=i.y,u=l.x,f=l.y,d=0,h=1,p=u-s,g=f-c;if(o=t-s,p||!(o>0)){if(o/=p,0>p){if(d>o)return;h>o&&(h=o)}else if(p>0){if(o>h)return;o>d&&(d=o)}if(o=n-s,p||!(0>o)){if(o/=p,0>p){if(o>h)return;o>d&&(d=o)}else if(p>0){if(d>o)return;h>o&&(h=o)}if(o=e-c,g||!(o>0)){if(o/=g,0>g){if(d>o)return;h>o&&(h=o)}else if(g>0){if(o>h)return;o>d&&(d=o)}if(o=r-c,g||!(0>o)){if(o/=g,0>g){if(o>h)return;o>d&&(d=o)}else if(g>0){if(d>o)return;h>o&&(h=o)}return d>0&&(a.a={x:s+d*p,y:c+d*g}),1>h&&(a.b={x:s+h*p,y:c+h*g}),a}}}}}}function Ue(t,e,n,r){function a(r,a){return wi(r[0]-t)0?0:3:wi(r[0]-n)0?2:1:wi(r[1]-e)0?1:0:a>0?3:2}function o(t,e){return i(t.x,e.x)}function i(t,e){var n=a(t,1),r=a(e,1);return n!==r?n-r:0===n?e[1]-t[1]:1===n?t[0]-e[0]:2===n?t[1]-e[1]:e[0]-t[0]}return function(l){function s(t){for(var e=0,n=m.length,r=t[1],a=0;n>a;++a)for(var o,i=1,l=m[a],s=l.length,c=l[0];s>i;++i)o=l[i],c[1]<=r?o[1]>r&&et(c,o,t)>0&&++e:o[1]<=r&&et(c,o,t)<0&&--e,c=o;return 0!==e}function c(o,l,s,c){var u=0,f=0;if(null==o||(u=a(o,s))!==(f=a(l,s))||i(o,l)<0^s>0){do c.point(0===u||3===u?t:n,u>1?r:e);while((u=(u+s+4)%4)!==f)}else c.point(l[0],l[1])}function u(a,o){return a>=t&&n>=a&&o>=e&&r>=o}function f(t,e){u(t,e)&&l.point(t,e)}function d(){S.point=p,m&&m.push(v=[]),M=!0,k=!1,_=w=NaN}function h(){g&&(p(y,x),b&&k&&L.rejoin(),g.push(L.buffer())),S.point=f,k&&l.lineEnd()}function p(t,e){t=Math.max(-Hl,Math.min(Hl,t)),e=Math.max(-Hl,Math.min(Hl,e));var n=u(t,e);if(m&&v.push([t,e]),M)y=t,x=e,b=n,M=!1,n&&(l.lineStart(),l.point(t,e));else if(n&&k)l.point(t,e);else{var r={a:{x:_,y:w},b:{x:t,y:e}};z(r)?(k||(l.lineStart(),l.point(r.a.x,r.a.y)),l.point(r.b.x,r.b.y),n||l.lineEnd(),A=!1):n&&(l.lineStart(),l.point(t,e),A=!1)}_=t,w=e,k=n}var g,m,v,y,x,b,_,w,k,M,A,T=l,L=Re(),z=Ze(t,e,n,r),S={point:f,lineStart:d,lineEnd:h,polygonStart:function(){l=L,g=[],m=[],A=!0},polygonEnd:function(){l=T,g=ui.merge(g);var e=s([t,r]),n=A&&e,a=g.length;(n||a)&&(l.polygonStart(),n&&(l.lineStart(),c(null,null,1,l),l.lineEnd()),a&&Oe(g,o,e,c,l),l.polygonEnd()),g=m=v=null}};return S}}function Ye(t){var e=0,n=Bi/3,r=cn(t),a=r(e,n);return a.parallels=function(t){return arguments.length?r(e=t[0]*Bi/180,n=t[1]*Bi/180):[e/Bi*180,n/Bi*180]},a}function Xe(t,e){function n(t,e){var n=Math.sqrt(o-2*a*Math.sin(e))/a;return[n*Math.sin(t*=a),i-n*Math.cos(t)]}var r=Math.sin(t),a=(r+Math.sin(e))/2,o=1+r*(2*a-r),i=Math.sqrt(o)/a;return n.invert=function(t,e){var n=i-e;return[Math.atan2(t,n)/a,rt((o-(t*t+n*n)*a*a)/(2*a))]},n}function Ge(){function t(t,e){Zl+=a*t-r*e,r=t,a=e}var e,n,r,a;$l.point=function(o,i){$l.point=t,e=r=o,n=a=i},$l.lineEnd=function(){t(e,n)}}function $e(t,e){Ul>t&&(Ul=t),t>Xl&&(Xl=t),Yl>e&&(Yl=e),e>Gl&&(Gl=e)}function Qe(){function t(t,e){i.push("M",t,",",e,o)}function e(t,e){i.push("M",t,",",e),l.point=n}function n(t,e){i.push("L",t,",",e)}function r(){l.point=t}function a(){i.push("Z")}var o=We(4.5),i=[],l={point:t,lineStart:function(){l.point=e},lineEnd:r,polygonStart:function(){l.lineEnd=a},polygonEnd:function(){l.lineEnd=r,l.point=t},pointRadius:function(t){return o=We(t),l},result:function(){if(i.length){var t=i.join("");return i=[],t}}};return l}function We(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}function Je(t,e){El+=t,Ol+=e,++Pl}function Ke(){function t(t,r){var a=t-e,o=r-n,i=Math.sqrt(a*a+o*o);Nl+=i*(e+t)/2,Dl+=i*(n+r)/2,Il+=i,Je(e=t,n=r)}var e,n;Wl.point=function(r,a){Wl.point=t,Je(e=r,n=a)}}function tn(){Wl.point=Je}function en(){function t(t,e){var n=t-r,o=e-a,i=Math.sqrt(n*n+o*o);Nl+=i*(r+t)/2,Dl+=i*(a+e)/2,Il+=i,i=a*t-r*e,Rl+=i*(r+t),jl+=i*(a+e),Fl+=3*i,Je(r=t,a=e)}var e,n,r,a;Wl.point=function(o,i){Wl.point=t,Je(e=r=o,n=a=i)},Wl.lineEnd=function(){t(e,n)}}function nn(t){function e(e,n){t.moveTo(e+i,n),t.arc(e,n,i,0,Hi)}function n(e,n){t.moveTo(e,n),l.point=r}function r(e,n){t.lineTo(e,n)}function a(){l.point=e}function o(){t.closePath()}var i=4.5,l={point:e,lineStart:function(){l.point=n},lineEnd:a,polygonStart:function(){l.lineEnd=o},polygonEnd:function(){l.lineEnd=a,l.point=e},pointRadius:function(t){return i=t,l},result:k};return l}function rn(t){function e(t){return(l?r:n)(t)}function n(e){return ln(e,function(n,r){n=t(n,r),e.point(n[0],n[1])})}function r(e){function n(n,r){n=t(n,r),e.point(n[0],n[1])}function r(){x=NaN,M.point=o,e.lineStart()}function o(n,r){var o=ve([n,r]),i=t(n,r);a(x,b,y,_,w,k,x=i[0],b=i[1],y=n,_=o[0],w=o[1],k=o[2],l,e),e.point(x,b)}function i(){M.point=n,e.lineEnd()}function s(){r(),M.point=c,M.lineEnd=u}function c(t,e){o(f=t,d=e),h=x,p=b,g=_,m=w,v=k,M.point=o}function u(){a(x,b,y,_,w,k,h,p,f,g,m,v,l,e),M.lineEnd=i,i()}var f,d,h,p,g,m,v,y,x,b,_,w,k,M={point:n,lineStart:r,lineEnd:i,polygonStart:function(){e.polygonStart(),M.lineStart=s},polygonEnd:function(){e.polygonEnd(),M.lineStart=r}};return M}function a(e,n,r,l,s,c,u,f,d,h,p,g,m,v){var y=u-e,x=f-n,b=y*y+x*x;if(b>4*o&&m--){var _=l+h,w=s+p,k=c+g,M=Math.sqrt(_*_+w*w+k*k),A=Math.asin(k/=M),T=wi(wi(k)-1)o||wi((y*C+x*E)/b-.5)>.3||i>l*h+s*p+c*g)&&(a(e,n,r,l,s,c,z,S,T,_/=M,w/=M,k,m,v),v.point(z,S),a(z,S,T,_,w,k,u,f,d,h,p,g,m,v))}}var o=.5,i=Math.cos(30*Ui),l=16;return e.precision=function(t){return arguments.length?(l=(o=t*t)>0&&16,e):Math.sqrt(o)},e}function an(t){var e=rn(function(e,n){return t([e*Yi,n*Yi])});return function(t){return un(e(t))}}function on(t){this.stream=t}function ln(t,e){return{point:e,sphere:function(){t.sphere()},lineStart:function(){t.lineStart()},lineEnd:function(){t.lineEnd()},polygonStart:function(){t.polygonStart()},polygonEnd:function(){t.polygonEnd()}}}function sn(t){return cn(function(){return t})()}function cn(t){function e(t){return t=l(t[0]*Ui,t[1]*Ui),[t[0]*d+s,c-t[1]*d]}function n(t){return t=l.invert((t[0]-s)/d,(c-t[1])/d),t&&[t[0]*Yi,t[1]*Yi]}function r(){l=Ce(i=hn(v,y,x),o);var t=o(g,m);return s=h-t[0]*d,c=p+t[1]*d,a()}function a(){return u&&(u.valid=!1,u=null),e}var o,i,l,s,c,u,f=rn(function(t,e){return t=o(t,e),[t[0]*d+s,c-t[1]*d]}),d=150,h=480,p=250,g=0,m=0,v=0,y=0,x=0,_=Bl,w=b,k=null,M=null;return e.stream=function(t){return u&&(u.valid=!1),u=un(_(i,f(w(t)))),u.valid=!0,u},e.clipAngle=function(t){return arguments.length?(_=null==t?(k=t,Bl):Ve((k=+t)*Ui),a()):k},e.clipExtent=function(t){return arguments.length?(M=t,w=t?Ue(t[0][0],t[0][1],t[1][0],t[1][1]):b,a()):M},e.scale=function(t){return arguments.length?(d=+t,r()):d},e.translate=function(t){return arguments.length?(h=+t[0],p=+t[1],r()):[h,p]},e.center=function(t){return arguments.length?(g=t[0]%360*Ui,m=t[1]%360*Ui,r()):[g*Yi,m*Yi]},e.rotate=function(t){return arguments.length?(v=t[0]%360*Ui,y=t[1]%360*Ui,x=t.length>2?t[2]%360*Ui:0,r()):[v*Yi,y*Yi,x*Yi]},ui.rebind(e,f,"precision"),function(){return o=t.apply(this,arguments),e.invert=o.invert&&n,r()}}function un(t){return ln(t,function(e,n){t.point(e*Ui,n*Ui)})}function fn(t,e){return[t,e]}function dn(t,e){return[t>Bi?t-Hi:-Bi>t?t+Hi:t,e]}function hn(t,e,n){return t?e||n?Ce(gn(t),mn(e,n)):gn(t):e||n?mn(e,n):dn}function pn(t){return function(e,n){return e+=t,[e>Bi?e-Hi:-Bi>e?e+Hi:e,n]}}function gn(t){var e=pn(t);return e.invert=pn(-t),e}function mn(t,e){function n(t,e){var n=Math.cos(e),l=Math.cos(t)*n,s=Math.sin(t)*n,c=Math.sin(e),u=c*r+l*a;return[Math.atan2(s*o-u*i,l*r-c*a),rt(u*o+s*i)]}var r=Math.cos(t),a=Math.sin(t),o=Math.cos(e),i=Math.sin(e);return n.invert=function(t,e){var n=Math.cos(e),l=Math.cos(t)*n,s=Math.sin(t)*n,c=Math.sin(e),u=c*o-s*i;return[Math.atan2(s*o+c*i,l*r+u*a),rt(u*r-l*a)]},n}function vn(t,e){var n=Math.cos(t),r=Math.sin(t);return function(a,o,i,l){var s=i*e;null!=a?(a=yn(n,a),o=yn(n,o),(i>0?o>a:a>o)&&(a+=i*Hi)):(a=t+i*Hi,o=t-.5*s);for(var c,u=a;i>0?u>o:o>u;u-=s)l.point((c=ke([n,-r*Math.cos(u),-r*Math.sin(u)]))[0],c[1])}}function yn(t,e){var n=ve(e);n[0]-=t,we(n);var r=nt(-n[1]);return((-n[2]<0?-r:r)+2*Math.PI-Fi)%(2*Math.PI)}function xn(t,e,n){var r=ui.range(t,e-Fi,n).concat(e);return function(t){return r.map(function(e){return[t,e]})}}function bn(t,e,n){var r=ui.range(t,e-Fi,n).concat(e);return function(t){return r.map(function(e){return[e,t]})}}function _n(t){return t.source}function wn(t){return t.target}function kn(t,e,n,r){var a=Math.cos(e),o=Math.sin(e),i=Math.cos(r),l=Math.sin(r),s=a*Math.cos(t),c=a*Math.sin(t),u=i*Math.cos(n),f=i*Math.sin(n),d=2*Math.asin(Math.sqrt(lt(r-e)+a*i*lt(n-t))),h=1/Math.sin(d),p=d?function(t){var e=Math.sin(t*=d)*h,n=Math.sin(d-t)*h,r=n*s+e*u,a=n*c+e*f,i=n*o+e*l;return[Math.atan2(a,r)*Yi,Math.atan2(i,Math.sqrt(r*r+a*a))*Yi]}:function(){return[t*Yi,e*Yi]};return p.distance=d,p}function Mn(){function t(t,a){var o=Math.sin(a*=Ui),i=Math.cos(a),l=wi((t*=Ui)-e),s=Math.cos(l);Jl+=Math.atan2(Math.sqrt((l=i*Math.sin(l))*l+(l=r*o-n*i*s)*l),n*o+r*i*s),e=t,n=o,r=i}var e,n,r;Kl.point=function(a,o){e=a*Ui,n=Math.sin(o*=Ui),r=Math.cos(o),Kl.point=t},Kl.lineEnd=function(){Kl.point=Kl.lineEnd=k}}function An(t,e){function n(e,n){var r=Math.cos(e),a=Math.cos(n),o=t(r*a);return[o*a*Math.sin(e),o*Math.sin(n)]}return n.invert=function(t,n){var r=Math.sqrt(t*t+n*n),a=e(r),o=Math.sin(a),i=Math.cos(a);return[Math.atan2(t*o,r*i),Math.asin(r&&n*o/r)]},n}function Tn(t,e){function n(t,e){i>0?-Zi+Fi>e&&(e=-Zi+Fi):e>Zi-Fi&&(e=Zi-Fi);var n=i/Math.pow(a(e),o);return[n*Math.sin(o*t),i-n*Math.cos(o*t)]}var r=Math.cos(t),a=function(t){return Math.tan(Bi/4+t/2)},o=t===e?Math.sin(t):Math.log(r/Math.cos(e))/Math.log(a(e)/a(t)),i=r*Math.pow(a(t),o)/o;return o?(n.invert=function(t,e){var n=i-e,r=tt(o)*Math.sqrt(t*t+n*n);return[Math.atan2(t,n)/o,2*Math.atan(Math.pow(i/r,1/o))-Zi]},n):zn}function Ln(t,e){function n(t,e){var n=o-e;return[n*Math.sin(a*t),o-n*Math.cos(a*t)]}var r=Math.cos(t),a=t===e?Math.sin(t):(r-Math.cos(e))/(e-t),o=r/a+t;return wi(a)a;a++){for(;r>1&&et(t[n[r-2]],t[n[r-1]],t[a])<=0;)--r;n[r++]=a}return n.slice(0,r)}function Nn(t,e){return t[0]-e[0]||t[1]-e[1]}function Dn(t,e,n){return(n[0]-e[0])*(t[1]-e[1])<(n[1]-e[1])*(t[0]-e[0])}function In(t,e,n,r){var a=t[0],o=n[0],i=e[0]-a,l=r[0]-o,s=t[1],c=n[1],u=e[1]-s,f=r[1]-c,d=(l*(s-c)-f*(a-o))/(f*i-l*u);return[a+d*i,s+d*u]}function Rn(t){var e=t[0],n=t[t.length-1];return!(e[0]-n[0]||e[1]-n[1])}function jn(){or(this),this.edge=this.site=this.circle=null}function Fn(t){var e=fs.pop()||new jn;return e.site=t,e}function qn(t){Qn(t),ss.remove(t),fs.push(t),or(t)}function Bn(t){var e=t.circle,n=e.x,r=e.cy,a={x:n,y:r},o=t.P,i=t.N,l=[t];qn(t);for(var s=o;s.circle&&wi(n-s.circle.x)u;++u)c=l[u],s=l[u-1],nr(c.edge,s.site,c.site,a);s=l[0],c=l[f-1],c.edge=tr(s.site,c.site,null,a),$n(s),$n(c)}function Hn(t){for(var e,n,r,a,o=t.x,i=t.y,l=ss._;l;)if(r=Vn(l,i)-o,r>Fi)l=l.L;else{if(a=o-Zn(l,i),!(a>Fi)){r>-Fi?(e=l.P,n=l):a>-Fi?(e=l,n=l.N):e=n=l;break}if(!l.R){e=l;break}l=l.R}var s=Fn(t);if(ss.insert(e,s),e||n){if(e===n)return Qn(e),n=Fn(e.site),ss.insert(s,n),s.edge=n.edge=tr(e.site,s.site),$n(e),void $n(n);if(!n)return void(s.edge=tr(e.site,s.site));Qn(e),Qn(n);var c=e.site,u=c.x,f=c.y,d=t.x-u,h=t.y-f,p=n.site,g=p.x-u,m=p.y-f,v=2*(d*m-h*g),y=d*d+h*h,x=g*g+m*m,b={x:(m*y-h*x)/v+u,y:(d*x-g*y)/v+f};nr(n.edge,c,p,b),s.edge=tr(c,t,null,b),n.edge=tr(t,p,null,b),$n(e),$n(n)}}function Vn(t,e){var n=t.site,r=n.x,a=n.y,o=a-e;if(!o)return r;var i=t.P;if(!i)return-(1/0);n=i.site;var l=n.x,s=n.y,c=s-e;if(!c)return l;var u=l-r,f=1/o-1/c,d=u/c;return f?(-d+Math.sqrt(d*d-2*f*(u*u/(-2*c)-s+c/2+a-o/2)))/f+r:(r+l)/2}function Zn(t,e){var n=t.N;if(n)return Vn(n,e);var r=t.site;return r.y===e?r.x:1/0}function Un(t){this.site=t,this.edges=[]}function Yn(t){for(var e,n,r,a,o,i,l,s,c,u,f=t[0][0],d=t[1][0],h=t[0][1],p=t[1][1],g=ls,m=g.length;m--;)if(o=g[m],o&&o.prepare())for(l=o.edges,s=l.length,i=0;s>i;)u=l[i].end(),r=u.x,a=u.y,c=l[++i%s].start(),e=c.x,n=c.y,(wi(r-e)>Fi||wi(a-n)>Fi)&&(l.splice(i,0,new rr(er(o.site,u,wi(r-f)Fi?{x:f,y:wi(e-f)Fi?{x:wi(n-p)Fi?{x:d,y:wi(e-d)Fi?{x:wi(n-h)=-qi)){var h=s*s+c*c,p=u*u+f*f,g=(f*h-c*p)/d,m=(s*p-u*h)/d,f=m+l,v=ds.pop()||new Gn;v.arc=t,v.site=a,v.x=g+i,v.y=f+Math.sqrt(g*g+m*m),v.cy=f,t.circle=v;for(var y=null,x=us._;x;)if(v.ym||m>=l)return;if(d>p){if(o){if(o.y>=c)return}else o={x:m,y:s};n={x:m,y:c}}else{if(o){if(o.yr||r>1)if(d>p){if(o){if(o.y>=c)return}else o={x:(s-a)/r,y:s};n={x:(c-a)/r,y:c}}else{if(o){if(o.yh){if(o){if(o.x>=l)return}else o={x:i,y:r*i+a};n={x:l,y:r*l+a}}else{if(o){if(o.xo||f>i||r>d||a>h)){if(p=t.point){var p,g=e-t.x,m=n-t.y,v=g*g+m*m;if(s>v){var y=Math.sqrt(s=v);r=e-y,a=n-y,o=e+y,i=n+y,l=p}}for(var x=t.nodes,b=.5*(u+d),_=.5*(f+h),w=e>=b,k=n>=_,M=k<<1|w,A=M+4;A>M;++M)if(t=x[3&M])switch(3&M){case 0:c(t,u,f,b,_);break;case 1:c(t,b,f,d,_);break;case 2:c(t,u,_,b,h);break;case 3:c(t,b,_,d,h)}}}(t,r,a,o,i),l}function vr(t,e){t=ui.rgb(t),e=ui.rgb(e);var n=t.r,r=t.g,a=t.b,o=e.r-n,i=e.g-r,l=e.b-a;return function(t){return"#"+wt(Math.round(n+o*t))+wt(Math.round(r+i*t))+wt(Math.round(a+l*t))}}function yr(t,e){var n,r={},a={};for(n in t)n in e?r[n]=_r(t[n],e[n]):a[n]=t[n];for(n in e)n in t||(a[n]=e[n]);return function(t){for(n in r)a[n]=r[n](t);return a}}function xr(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function br(t,e){var n,r,a,o=ps.lastIndex=gs.lastIndex=0,i=-1,l=[],s=[];for(t+="",e+="";(n=ps.exec(t))&&(r=gs.exec(e));)(a=r.index)>o&&(a=e.slice(o,a),l[i]?l[i]+=a:l[++i]=a),(n=n[0])===(r=r[0])?l[i]?l[i]+=r:l[++i]=r:(l[++i]=null,s.push({i:i,x:xr(n,r)})),o=gs.lastIndex;return or;++r)l[(n=s[r]).i]=n.x(t);return l.join("")})}function _r(t,e){for(var n,r=ui.interpolators.length;--r>=0&&!(n=ui.interpolators[r](t,e)););return n}function wr(t,e){var n,r=[],a=[],o=t.length,i=e.length,l=Math.min(t.length,e.length);for(n=0;l>n;++n)r.push(_r(t[n],e[n]));for(;o>n;++n)a[n]=t[n];for(;i>n;++n)a[n]=e[n];return function(t){for(n=0;l>n;++n)a[n]=r[n](t);return a}}function kr(t){return function(e){return 0>=e?0:e>=1?1:t(e)}}function Mr(t){return function(e){return 1-t(1-e)}}function Ar(t){return function(e){return.5*(.5>e?t(2*e):2-t(2-2*e))}}function Tr(t){return t*t}function Lr(t){return t*t*t}function zr(t){if(0>=t)return 0;if(t>=1)return 1;var e=t*t,n=e*t;return 4*(.5>t?n:3*(t-e)+n-.75)}function Sr(t){return function(e){return Math.pow(e,t)}}function Cr(t){return 1-Math.cos(t*Zi)}function Er(t){return Math.pow(2,10*(t-1))}function Or(t){return 1-Math.sqrt(1-t*t)}function Pr(t,e){var n;return arguments.length<2&&(e=.45),arguments.length?n=e/Hi*Math.asin(1/t):(t=1,n=e/4),function(r){return 1+t*Math.pow(2,-10*r)*Math.sin((r-n)*Hi/e)}}function Nr(t){return t||(t=1.70158),function(e){return e*e*((t+1)*e-t)}}function Dr(t){return 1/2.75>t?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}function Ir(t,e){t=ui.hcl(t),e=ui.hcl(e);var n=t.h,r=t.c,a=t.l,o=e.h-n,i=e.c-r,l=e.l-a;return isNaN(i)&&(i=0,r=isNaN(r)?e.c:r),isNaN(o)?(o=0,n=isNaN(n)?e.h:n):o>180?o-=360:-180>o&&(o+=360),function(t){return dt(n+o*t,r+i*t,a+l*t)+""}}function Rr(t,e){t=ui.hsl(t),e=ui.hsl(e);var n=t.h,r=t.s,a=t.l,o=e.h-n,i=e.s-r,l=e.l-a;return isNaN(i)&&(i=0,r=isNaN(r)?e.s:r),isNaN(o)?(o=0, +-n=isNaN(n)?e.h:n):o>180?o-=360:-180>o&&(o+=360),function(t){return ut(n+o*t,r+i*t,a+l*t)+""}}function jr(t,e){t=ui.lab(t),e=ui.lab(e);var n=t.l,r=t.a,a=t.b,o=e.l-n,i=e.a-r,l=e.b-a;return function(t){return pt(n+o*t,r+i*t,a+l*t)+""}}function Fr(t,e){return e-=t,function(n){return Math.round(t+e*n)}}function qr(t){var e=[t.a,t.b],n=[t.c,t.d],r=Hr(e),a=Br(e,n),o=Hr(Vr(n,e,-a))||0;e[0]*n[1]180?e+=360:e-t>180&&(t+=360),r.push({i:n.push(Zr(n)+"rotate(",null,")")-2,x:xr(t,e)})):e&&n.push(Zr(n)+"rotate("+e+")")}function Xr(t,e,n,r){t!==e?r.push({i:n.push(Zr(n)+"skewX(",null,")")-2,x:xr(t,e)}):e&&n.push(Zr(n)+"skewX("+e+")")}function Gr(t,e,n,r){if(t[0]!==e[0]||t[1]!==e[1]){var a=n.push(Zr(n)+"scale(",null,",",null,")");r.push({i:a-4,x:xr(t[0],e[0])},{i:a-2,x:xr(t[1],e[1])})}else 1===e[0]&&1===e[1]||n.push(Zr(n)+"scale("+e+")")}function $r(t,e){var n=[],r=[];return t=ui.transform(t),e=ui.transform(e),Ur(t.translate,e.translate,n,r),Yr(t.rotate,e.rotate,n,r),Xr(t.skew,e.skew,n,r),Gr(t.scale,e.scale,n,r),t=e=null,function(t){for(var e,a=-1,o=r.length;++a=0;)n.push(a[r])}function sa(t,e){for(var n=[t],r=[];null!=(t=n.pop());)if(r.push(t),(o=t.children)&&(a=o.length))for(var a,o,i=-1;++in;++n)(e=t[n][1])>a&&(r=n,a=e);return r}function xa(t){return t.reduce(ba,0)}function ba(t,e){return t+e[1]}function _a(t,e){return wa(t,Math.ceil(Math.log(e.length)/Math.LN2+1))}function wa(t,e){for(var n=-1,r=+t[0],a=(t[1]-r)/e,o=[];++n<=e;)o[n]=a*n+r;return o}function ka(t){return[ui.min(t),ui.max(t)]}function Ma(t,e){return t.value-e.value}function Aa(t,e){var n=t._pack_next;t._pack_next=e,e._pack_prev=t,e._pack_next=n,n._pack_prev=e}function Ta(t,e){t._pack_next=e,e._pack_prev=t}function La(t,e){var n=e.x-t.x,r=e.y-t.y,a=t.r+e.r;return.999*a*a>n*n+r*r}function za(t){function e(t){u=Math.min(t.x-t.r,u),f=Math.max(t.x+t.r,f),d=Math.min(t.y-t.r,d),h=Math.max(t.y+t.r,h)}if((n=t.children)&&(c=n.length)){var n,r,a,o,i,l,s,c,u=1/0,f=-(1/0),d=1/0,h=-(1/0);if(n.forEach(Sa),r=n[0],r.x=-r.r,r.y=0,e(r),c>1&&(a=n[1],a.x=a.r,a.y=0,e(a),c>2))for(o=n[2],Oa(r,a,o),e(o),Aa(r,o),r._pack_prev=o,Aa(o,a),a=r._pack_next,i=3;c>i;i++){Oa(r,a,o=n[i]);var p=0,g=1,m=1;for(l=a._pack_next;l!==a;l=l._pack_next,g++)if(La(l,o)){p=1;break}if(1==p)for(s=r._pack_prev;s!==l._pack_prev&&!La(s,o);s=s._pack_prev,m++);p?(m>g||g==m&&a.ri;i++)o=n[i],o.x-=v,o.y-=y,x=Math.max(x,o.r+Math.sqrt(o.x*o.x+o.y*o.y));t.r=x,n.forEach(Ca)}}function Sa(t){t._pack_next=t._pack_prev=t}function Ca(t){delete t._pack_next,delete t._pack_prev}function Ea(t,e,n,r){var a=t.children;if(t.x=e+=r*t.x,t.y=n+=r*t.y,t.r*=r,a)for(var o=-1,i=a.length;++o=0;)e=a[o],e.z+=n,e.m+=n,n+=e.s+(r+=e.c)}function ja(t,e,n){return t.a.parent===e.parent?t.a:n}function Fa(t){return 1+ui.max(t,function(t){return t.y})}function qa(t){return t.reduce(function(t,e){return t+e.x},0)/t.length}function Ba(t){var e=t.children;return e&&e.length?Ba(e[0]):t}function Ha(t){var e,n=t.children;return n&&(e=n.length)?Ha(n[e-1]):t}function Va(t){return{x:t.x,y:t.y,dx:t.dx,dy:t.dy}}function Za(t,e){var n=t.x+e[3],r=t.y+e[0],a=t.dx-e[1]-e[3],o=t.dy-e[0]-e[2];return 0>a&&(n+=a/2,a=0),0>o&&(r+=o/2,o=0),{x:n,y:r,dx:a,dy:o}}function Ua(t){var e=t[0],n=t[t.length-1];return n>e?[e,n]:[n,e]}function Ya(t){return t.rangeExtent?t.rangeExtent():Ua(t.range())}function Xa(t,e,n,r){var a=n(t[0],t[1]),o=r(e[0],e[1]);return function(t){return o(a(t))}}function Ga(t,e){var n,r=0,a=t.length-1,o=t[r],i=t[a];return o>i&&(n=r,r=a,a=n,n=o,o=i,i=n),t[r]=e.floor(o),t[a]=e.ceil(i),t}function $a(t){return t?{floor:function(e){return Math.floor(e/t)*t},ceil:function(e){return Math.ceil(e/t)*t}}:Ts}function Qa(t,e,n,r){var a=[],o=[],i=0,l=Math.min(t.length,e.length)-1;for(t[l]2?Qa:Xa,s=r?Wr:Qr;return i=a(t,e,s,n),l=a(e,t,s,_r),o}function o(t){return i(t)}var i,l;return o.invert=function(t){return l(t)},o.domain=function(e){return arguments.length?(t=e.map(Number),a()):t},o.range=function(t){return arguments.length?(e=t,a()):e},o.rangeRound=function(t){return o.range(t).interpolate(Fr)},o.clamp=function(t){return arguments.length?(r=t,a()):r},o.interpolate=function(t){return arguments.length?(n=t,a()):n},o.ticks=function(e){return eo(t,e)},o.tickFormat=function(e,n){return no(t,e,n)},o.nice=function(e){return Ka(t,e),a()},o.copy=function(){return Wa(t,e,n,r)},a()}function Ja(t,e){return ui.rebind(t,e,"range","rangeRound","interpolate","clamp")}function Ka(t,e){return Ga(t,$a(to(t,e)[2])),Ga(t,$a(to(t,e)[2])),t}function to(t,e){null==e&&(e=10);var n=Ua(t),r=n[1]-n[0],a=Math.pow(10,Math.floor(Math.log(r/e)/Math.LN10)),o=e/r*a;return.15>=o?a*=10:.35>=o?a*=5:.75>=o&&(a*=2),n[0]=Math.ceil(n[0]/a)*a,n[1]=Math.floor(n[1]/a)*a+.5*a,n[2]=a,n}function eo(t,e){return ui.range.apply(ui,to(t,e))}function no(t,e,n){var r=to(t,e);if(n){var a=pl.exec(n);if(a.shift(),"s"===a[8]){var o=ui.formatPrefix(Math.max(wi(r[0]),wi(r[1])));return a[7]||(a[7]="."+ro(o.scale(r[2]))),a[8]="f",n=ui.format(a.join("")),function(t){return n(o.scale(t))+o.symbol}}a[7]||(a[7]="."+ao(a[8],r)),n=a.join("")}else n=",."+ro(r[2])+"f";return ui.format(n)}function ro(t){return-Math.floor(Math.log(t)/Math.LN10+.01)}function ao(t,e){var n=ro(e[2]);return t in Ls?Math.abs(n-ro(Math.max(wi(e[0]),wi(e[1]))))+ +("e"!==t):n-2*("%"===t)}function oo(t,e,n,r){function a(t){return(n?Math.log(0>t?0:t):-Math.log(t>0?0:-t))/Math.log(e)}function o(t){return n?Math.pow(e,t):-Math.pow(e,-t)}function i(e){return t(a(e))}return i.invert=function(e){return o(t.invert(e))},i.domain=function(e){return arguments.length?(n=e[0]>=0,t.domain((r=e.map(Number)).map(a)),i):r},i.base=function(n){return arguments.length?(e=+n,t.domain(r.map(a)),i):e},i.nice=function(){var e=Ga(r.map(a),n?Math:Ss);return t.domain(e),r=e.map(o),i},i.ticks=function(){var t=Ua(r),i=[],l=t[0],s=t[1],c=Math.floor(a(l)),u=Math.ceil(a(s)),f=e%1?2:e;if(isFinite(u-c)){if(n){for(;u>c;c++)for(var d=1;f>d;d++)i.push(o(c)*d);i.push(o(c))}else for(i.push(o(c));c++0;d--)i.push(o(c)*d);for(c=0;i[c]s;u--);i=i.slice(c,u)}return i},i.tickFormat=function(t,n){if(!arguments.length)return zs;arguments.length<2?n=zs:"function"!=typeof n&&(n=ui.format(n));var r=Math.max(1,e*t/i.ticks().length);return function(t){var i=t/o(Math.round(a(t)));return e-.5>i*e&&(i*=e),r>=i?n(t):""}},i.copy=function(){return oo(t.copy(),e,n,r)},Ja(i,t)}function io(t,e,n){function r(e){return t(a(e))}var a=lo(e),o=lo(1/e);return r.invert=function(e){return o(t.invert(e))},r.domain=function(e){return arguments.length?(t.domain((n=e.map(Number)).map(a)),r):n},r.ticks=function(t){return eo(n,t)},r.tickFormat=function(t,e){return no(n,t,e)},r.nice=function(t){return r.domain(Ka(n,t))},r.exponent=function(i){return arguments.length?(a=lo(e=i),o=lo(1/e),t.domain(n.map(a)),r):e},r.copy=function(){return io(t.copy(),e,n)},Ja(r,t)}function lo(t){return function(e){return 0>e?-Math.pow(-e,t):Math.pow(e,t)}}function so(t,e){function n(n){return o[((a.get(n)||("range"===e.t?a.set(n,t.push(n)):NaN))-1)%o.length]}function r(e,n){return ui.range(t.length).map(function(t){return e+n*t})}var a,o,i;return n.domain=function(r){if(!arguments.length)return t;t=[],a=new f;for(var o,i=-1,l=r.length;++in?[NaN,NaN]:[n>0?l[n-1]:t[0],ne?NaN:e/o+t,[e,e+1/o]},r.copy=function(){return uo(t,e,n)},a()}function fo(t,e){function n(n){return n>=n?e[ui.bisect(t,n)]:void 0}return n.domain=function(e){return arguments.length?(t=e,n):t},n.range=function(t){return arguments.length?(e=t,n):e},n.invertExtent=function(n){return n=e.indexOf(n),[t[n-1],t[n]]},n.copy=function(){return fo(t,e)},n}function ho(t){function e(t){return+t}return e.invert=e,e.domain=e.range=function(n){return arguments.length?(t=n.map(e),e):t},e.ticks=function(e){return eo(t,e)},e.tickFormat=function(e,n){return no(t,e,n)},e.copy=function(){return ho(t)},e}function po(){return 0}function go(t){return t.innerRadius}function mo(t){return t.outerRadius}function vo(t){return t.startAngle}function yo(t){return t.endAngle}function xo(t){return t&&t.padAngle}function bo(t,e,n,r){return(t-n)*e-(e-r)*t>0?0:1}function _o(t,e,n,r,a){var o=t[0]-e[0],i=t[1]-e[1],l=(a?r:-r)/Math.sqrt(o*o+i*i),s=l*i,c=-l*o,u=t[0]+s,f=t[1]+c,d=e[0]+s,h=e[1]+c,p=(u+d)/2,g=(f+h)/2,m=d-u,v=h-f,y=m*m+v*v,x=n-r,b=u*h-d*f,_=(0>v?-1:1)*Math.sqrt(Math.max(0,x*x*y-b*b)),w=(b*v-m*_)/y,k=(-b*m-v*_)/y,M=(b*v+m*_)/y,A=(-b*m+v*_)/y,T=w-p,L=k-g,z=M-p,S=A-g;return T*T+L*L>z*z+S*S&&(w=M,k=A),[[w-s,k-c],[w*n/x,k*n/x]]}function wo(t){function e(e){function i(){c.push("M",o(t(u),l))}for(var s,c=[],u=[],f=-1,d=e.length,h=zt(n),p=zt(r);++f1?t.join("L"):t+"Z"}function Mo(t){return t.join("L")+"Z"}function Ao(t){for(var e=0,n=t.length,r=t[0],a=[r[0],",",r[1]];++e1&&a.push("H",r[0]),a.join("")}function To(t){for(var e=0,n=t.length,r=t[0],a=[r[0],",",r[1]];++e1){l=e[1],o=t[s],s++,r+="C"+(a[0]+i[0])+","+(a[1]+i[1])+","+(o[0]-l[0])+","+(o[1]-l[1])+","+o[0]+","+o[1];for(var c=2;c9&&(a=3*e/Math.sqrt(a),i[l]=a*n,i[l+1]=a*r));for(l=-1;++l<=s;)a=(t[Math.min(s,l+1)][0]-t[Math.max(0,l-1)][0])/(6*(1+i[l]*i[l])),o.push([a||0,i[l]*a||0]);return o}function Ho(t){return t.length<3?ko(t):t[0]+Eo(t,Bo(t))}function Vo(t){for(var e,n,r,a=-1,o=t.length;++a=e?i(t-e):void(c.c=i)}function i(n){var a=p.active,o=p[a];o&&(o.timer.c=null,o.timer.t=NaN,--p.count,delete p[a],o.event&&o.event.interrupt.call(t,t.__data__,o.index));for(var i in p)if(r>+i){var f=p[i];f.timer.c=null,f.timer.t=NaN,--p.count,delete p[i]}c.c=l,Pt(function(){return c.c&&l(n||1)&&(c.c=null,c.t=NaN),1},0,s),p.active=r,g.event&&g.event.start.call(t,t.__data__,e),h=[],g.tween.forEach(function(n,r){(r=r.call(t,t.__data__,e))&&h.push(r)}),d=g.ease,u=g.duration}function l(a){for(var o=a/u,i=d(o),l=h.length;l>0;)h[--l].call(t,i);return o>=1?(g.event&&g.event.end.call(t,t.__data__,e),--p.count?delete p[r]:delete t[n],1):void 0}var s,c,u,d,h,p=t[n]||(t[n]={active:0,count:0}),g=p[r];g||(s=a.time,c=Pt(o,0,s),g=p[r]={tween:new f,time:s,timer:c,delay:a.delay,duration:a.duration,ease:a.ease,index:e},a=null,++p.count)}function ri(t,e,n){t.attr("transform",function(t){var r=e(t);return"translate("+(isFinite(r)?r:n(t))+",0)"})}function ai(t,e,n){t.attr("transform",function(t){var r=e(t);return"translate(0,"+(isFinite(r)?r:n(t))+")"})}function oi(t){return t.toISOString()}function ii(t,e,n){function r(e){return t(e)}function a(t,n){var r=t[1]-t[0],a=r/n,o=ui.bisect(tc,a);return o==tc.length?[e.year,to(t.map(function(t){return t/31536e6}),n)[2]]:o?e[a/tc[o-1]1?{floor:function(e){for(;n(e=t.floor(e));)e=li(e-1);return e},ceil:function(e){for(;n(e=t.ceil(e));)e=li(+e+1);return e}}:t))},r.ticks=function(t,e){var n=Ua(r.domain()),o=null==t?a(n,10):"number"==typeof t?a(n,t):!t.range&&[{range:t},e];return o&&(t=o[0],e=o[1]),t.range(n[0],li(+n[1]+1),1>e?1:e)},r.tickFormat=function(){return n},r.copy=function(){return ii(t.copy(),e,n)},Ja(r,t)}function li(t){return new Date(t)}function si(t){return JSON.parse(t.responseText)}function ci(t){var e=hi.createRange();return e.selectNode(hi.body),e.createContextualFragment(t.responseText)}var ui={version:"3.5.16"},fi=[].slice,di=function(t){return fi.call(t)},hi=this.document;if(hi)try{di(hi.documentElement.childNodes)[0].nodeType}catch(pi){di=function(t){for(var e=t.length,n=new Array(e);e--;)n[e]=t[e];return n}}if(Date.now||(Date.now=function(){return+new Date}),hi)try{hi.createElement("DIV").style.setProperty("opacity",0,"")}catch(gi){var mi=this.Element.prototype,vi=mi.setAttribute,yi=mi.setAttributeNS,xi=this.CSSStyleDeclaration.prototype,bi=xi.setProperty;mi.setAttribute=function(t,e){vi.call(this,t,e+"")},mi.setAttributeNS=function(t,e,n){yi.call(this,t,e,n+"")},xi.setProperty=function(t,e,n){bi.call(this,t,e+"",n)}}ui.ascending=a,ui.descending=function(t,e){return t>e?-1:e>t?1:e>=t?0:NaN},ui.min=function(t,e){var n,r,a=-1,o=t.length;if(1===arguments.length){for(;++a=r){n=r;break}for(;++ar&&(n=r)}else{for(;++a=r){n=r;break}for(;++ar&&(n=r)}return n},ui.max=function(t,e){var n,r,a=-1,o=t.length;if(1===arguments.length){for(;++a=r){n=r;break}for(;++an&&(n=r)}else{for(;++a=r){n=r;break}for(;++an&&(n=r)}return n},ui.extent=function(t,e){var n,r,a,o=-1,i=t.length;if(1===arguments.length){for(;++o=r){n=a=r;break}for(;++or&&(n=r),r>a&&(a=r))}else{for(;++o=r){n=a=r;break}for(;++or&&(n=r),r>a&&(a=r))}return[n,a]},ui.sum=function(t,e){var n,r=0,a=t.length,o=-1;if(1===arguments.length)for(;++o1?s/(u-1):void 0},ui.deviation=function(){var t=ui.variance.apply(this,arguments);return t?Math.sqrt(t):t};var _i=l(a);ui.bisectLeft=_i.left,ui.bisect=ui.bisectRight=_i.right,ui.bisector=function(t){return l(1===t.length?function(e,n){return a(t(e),n)}:t)},ui.shuffle=function(t,e,n){(o=arguments.length)<3&&(n=t.length,2>o&&(e=0));for(var r,a,o=n-e;o;)a=Math.random()*o--|0,r=t[o+e],t[o+e]=t[a+e],t[a+e]=r;return t},ui.permute=function(t,e){for(var n=e.length,r=new Array(n);n--;)r[n]=t[e[n]];return r},ui.pairs=function(t){for(var e,n=0,r=t.length-1,a=t[0],o=new Array(0>r?0:r);r>n;)o[n]=[e=a,a=t[++n]];return o},ui.transpose=function(t){if(!(a=t.length))return[];for(var e=-1,n=ui.min(t,s),r=new Array(n);++e=0;)for(r=t[a],e=r.length;--e>=0;)n[--i]=r[e];return n};var wi=Math.abs;ui.range=function(t,e,n){if(arguments.length<3&&(n=1,arguments.length<2&&(e=t,t=0)),(e-t)/n===1/0)throw new Error("infinite range");var r,a=[],o=c(wi(n)),i=-1;if(t*=o,e*=o,n*=o,0>n)for(;(r=t+n*++i)>e;)a.push(r/o);else for(;(r=t+n*++i)=o.length)return r?r.call(a,i):n?i.sort(n):i;for(var s,c,u,d,h=-1,p=i.length,g=o[l++],m=new f;++h=o.length)return t;var r=[],a=i[n++];return t.forEach(function(t,a){r.push({key:t,values:e(a,n)})}),a?r.sort(function(t,e){return a(t.key,e.key)}):r}var n,r,a={},o=[],i=[];return a.map=function(e,n){return t(n,e,0)},a.entries=function(n){return e(t(ui.map,n,0),0)},a.key=function(t){return o.push(t),a},a.sortKeys=function(t){return i[o.length-1]=t,a},a.sortValues=function(t){return n=t,a},a.rollup=function(t){return r=t,a},a},ui.set=function(t){var e=new x;if(t)for(var n=0,r=t.length;r>n;++n)e.add(t[n]);return e},u(x,{has:p,add:function(t){return this._[d(t+="")]=!0,t},remove:g,values:m,size:v,empty:y,forEach:function(t){for(var e in this._)t.call(this,h(e))}}),ui.behavior={},ui.rebind=function(t,e){for(var n,r=1,a=arguments.length;++r=0&&(r=t.slice(n+1),t=t.slice(0,n)),t)return arguments.length<2?this[t].on(r):this[t].on(r,e);if(2===arguments.length){if(null==e)for(t in this)this.hasOwnProperty(t)&&this[t].on(r,null);return this}},ui.event=null,ui.requote=function(t){return t.replace(Ti,"\\$&")};var Ti=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,Li={}.__proto__?function(t,e){t.__proto__=e}:function(t,e){for(var n in e)t[n]=e[n]},zi=function(t,e){return e.querySelector(t)},Si=function(t,e){return e.querySelectorAll(t)},Ci=function(t,e){var n=t.matches||t[w(t,"matchesSelector")];return(Ci=function(t,e){return n.call(t,e)})(t,e)};"function"==typeof Sizzle&&(zi=function(t,e){return Sizzle(t,e)[0]||null},Si=Sizzle,Ci=Sizzle.matchesSelector),ui.selection=function(){return ui.select(hi.documentElement)};var Ei=ui.selection.prototype=[];Ei.select=function(t){var e,n,r,a,o=[];t=C(t);for(var i=-1,l=this.length;++i=0&&"xmlns"!==(n=t.slice(0,e))&&(t=t.slice(e+1)),Pi.hasOwnProperty(n)?{space:Pi[n],local:t}:t}},Ei.attr=function(t,e){if(arguments.length<2){if("string"==typeof t){var n=this.node();return t=ui.ns.qualify(t),t.local?n.getAttributeNS(t.space,t.local):n.getAttribute(t)}for(e in t)this.each(O(e,t[e]));return this}return this.each(O(t,e))},Ei.classed=function(t,e){if(arguments.length<2){if("string"==typeof t){var n=this.node(),r=(t=D(t)).length,a=-1;if(e=n.classList){for(;++aa){if("string"!=typeof t){2>a&&(e="");for(n in t)this.each(j(n,t[n],e));return this}if(2>a){var o=this.node();return r(o).getComputedStyle(o,null).getPropertyValue(t)}n=""}return this.each(j(t,e,n))},Ei.property=function(t,e){if(arguments.length<2){if("string"==typeof t)return this.node()[t];for(e in t)this.each(F(e,t[e]));return this}return this.each(F(t,e))},Ei.text=function(t){return arguments.length?this.each("function"==typeof t?function(){var e=t.apply(this,arguments);this.textContent=null==e?"":e}:null==t?function(){this.textContent=""}:function(){this.textContent=t}):this.node().textContent},Ei.html=function(t){return arguments.length?this.each("function"==typeof t?function(){var e=t.apply(this,arguments);this.innerHTML=null==e?"":e}:null==t?function(){this.innerHTML=""}:function(){this.innerHTML=t}):this.node().innerHTML},Ei.append=function(t){return t=q(t),this.select(function(){return this.appendChild(t.apply(this,arguments))})},Ei.insert=function(t,e){return t=q(t),e=C(e),this.select(function(){return this.insertBefore(t.apply(this,arguments),e.apply(this,arguments)||null)})},Ei.remove=function(){return this.each(B)},Ei.data=function(t,e){function n(t,n){var r,a,o,i=t.length,u=n.length,d=Math.min(i,u),h=new Array(u),p=new Array(u),g=new Array(i);if(e){var m,v=new f,y=new Array(i);for(r=-1;++rr;++r)p[r]=H(n[r]);for(;i>r;++r)g[r]=t[r]}p.update=h,p.parentNode=h.parentNode=g.parentNode=t.parentNode,l.push(p),s.push(h),c.push(g)}var r,a,o=-1,i=this.length;if(!arguments.length){for(t=new Array(i=(r=this[0]).length);++oo;o++){a.push(e=[]),e.parentNode=(n=this[o]).parentNode;for(var l=0,s=n.length;s>l;l++)(r=n[l])&&t.call(r,r.__data__,l,o)&&e.push(r)}return S(a)},Ei.order=function(){for(var t=-1,e=this.length;++t=0;)(n=r[a])&&(o&&o!==n.nextSibling&&o.parentNode.insertBefore(n,o),o=n);return this},Ei.sort=function(t){t=Z.apply(this,arguments);for(var e=-1,n=this.length;++et;t++)for(var n=this[t],r=0,a=n.length;a>r;r++){var o=n[r];if(o)return o}return null},Ei.size=function(){var t=0;return U(this,function(){++t}),t};var Ni=[];ui.selection.enter=Y,ui.selection.enter.prototype=Ni,Ni.append=Ei.append,Ni.empty=Ei.empty,Ni.node=Ei.node,Ni.call=Ei.call,Ni.size=Ei.size,Ni.select=function(t){for(var e,n,r,a,o,i=[],l=-1,s=this.length;++lr){if("string"!=typeof t){2>r&&(e=!1);for(n in t)this.each(G(n,t[n],e));return this}if(2>r)return(r=this.node()["__on"+t])&&r._;n=!1}return this.each(G(t,e,n))};var Di=ui.map({mouseenter:"mouseover",mouseleave:"mouseout"});hi&&Di.forEach(function(t){"on"+t in hi&&Di.remove(t)});var Ii,Ri=0;ui.mouse=function(t){return J(t,L())};var ji=this.navigator&&/WebKit/.test(this.navigator.userAgent)?-1:0;ui.touch=function(t,e,n){if(arguments.length<3&&(n=e,e=L().changedTouches),e)for(var r,a=0,o=e.length;o>a;++a)if((r=e[a]).identifier===n)return J(t,r)},ui.behavior.drag=function(){function t(){this.on("mousedown.drag",o).on("touchstart.drag",i)}function e(t,e,r,o,i){return function(){function l(){var t,n,r=e(d,g);r&&(t=r[0]-x[0],n=r[1]-x[1],p|=t|n,x=r,h({type:"drag",x:r[0]+c[0],y:r[1]+c[1],dx:t,dy:n}))}function s(){e(d,g)&&(v.on(o+m,null).on(i+m,null),y(p),h({type:"dragend"}))}var c,u=this,f=ui.event.target.correspondingElement||ui.event.target,d=u.parentNode,h=n.of(u,arguments),p=0,g=t(),m=".drag"+(null==g?"":"-"+g),v=ui.select(r(f)).on(o+m,l).on(i+m,s),y=W(f),x=e(d,g);a?(c=a.apply(u,arguments),c=[c.x-x[0],c.y-x[1]]):c=[0,0],h({type:"dragstart"})}}var n=z(t,"drag","dragstart","dragend"),a=null,o=e(k,ui.mouse,r,"mousemove","mouseup"),i=e(K,ui.touch,b,"touchmove","touchend");return t.origin=function(e){return arguments.length?(a=e,t):a},ui.rebind(t,n,"on")},ui.touches=function(t,e){return arguments.length<2&&(e=L().touches),e?di(e).map(function(e){var n=J(t,e);return n.identifier=e.identifier,n}):[]};var Fi=1e-6,qi=Fi*Fi,Bi=Math.PI,Hi=2*Bi,Vi=Hi-Fi,Zi=Bi/2,Ui=Bi/180,Yi=180/Bi,Xi=Math.SQRT2,Gi=2,$i=4;ui.interpolateZoom=function(t,e){var n,r,a=t[0],o=t[1],i=t[2],l=e[0],s=e[1],c=e[2],u=l-a,f=s-o,d=u*u+f*f;if(qi>d)r=Math.log(c/i)/Xi,n=function(t){return[a+t*u,o+t*f,i*Math.exp(Xi*t*r)]};else{var h=Math.sqrt(d),p=(c*c-i*i+$i*d)/(2*i*Gi*h),g=(c*c-i*i-$i*d)/(2*c*Gi*h),m=Math.log(Math.sqrt(p*p+1)-p),v=Math.log(Math.sqrt(g*g+1)-g);r=(v-m)/Xi,n=function(t){var e=t*r,n=ot(m),l=i/(Gi*h)*(n*it(Xi*e+m)-at(m));return[a+l*u,o+l*f,i*n/ot(Xi*e+m)]}}return n.duration=1e3*r,n},ui.behavior.zoom=function(){function t(t){t.on(E,f).on(Wi+".zoom",h).on("dblclick.zoom",p).on(N,d)}function e(t){return[(t[0]-M.x)/M.k,(t[1]-M.y)/M.k]}function n(t){return[t[0]*M.k+M.x,t[1]*M.k+M.y]}function a(t){M.k=Math.max(L[0],Math.min(L[1],t))}function o(t,e){e=n(e),M.x+=t[0]-e[0],M.y+=t[1]-e[1]}function i(e,n,r,i){e.__chart__={x:M.x,y:M.y,k:M.k},a(Math.pow(2,i)),o(m=n,r),e=ui.select(e),S>0&&(e=e.transition().duration(S)),e.call(t.event)}function l(){_&&_.domain(b.range().map(function(t){return(t-M.x)/M.k}).map(b.invert)),k&&k.domain(w.range().map(function(t){return(t-M.y)/M.k}).map(w.invert))}function s(t){C++||t({type:"zoomstart"})}function c(t){l(),t({type:"zoom",scale:M.k,translate:[M.x,M.y]})}function u(t){--C||(t({type:"zoomend"}),m=null)}function f(){function t(){l=1,o(ui.mouse(a),d),c(i)}function n(){f.on(O,null).on(P,null),h(l),u(i)}var a=this,i=D.of(a,arguments),l=0,f=ui.select(r(a)).on(O,t).on(P,n),d=e(ui.mouse(a)),h=W(a);Zs.call(a),s(i)}function d(){function t(){var t=ui.touches(p);return h=M.k,t.forEach(function(t){t.identifier in m&&(m[t.identifier]=e(t))}),t}function n(){var e=ui.event.target;ui.select(e).on(b,r).on(_,l),w.push(e);for(var n=ui.event.changedTouches,a=0,o=n.length;o>a;++a)m[n[a].identifier]=null;var s=t(),c=Date.now();if(1===s.length){if(500>c-x){var u=s[0];i(p,u,m[u.identifier],Math.floor(Math.log(M.k)/Math.LN2)+1),T()}x=c}else if(s.length>1){var u=s[0],f=s[1],d=u[0]-f[0],h=u[1]-f[1];v=d*d+h*h}}function r(){var t,e,n,r,i=ui.touches(p);Zs.call(p);for(var l=0,s=i.length;s>l;++l,r=null)if(n=i[l],r=m[n.identifier]){if(e)break;t=n,e=r}if(r){var u=(u=n[0]-t[0])*u+(u=n[1]-t[1])*u,f=v&&Math.sqrt(u/v);t=[(t[0]+n[0])/2,(t[1]+n[1])/2],e=[(e[0]+r[0])/2,(e[1]+r[1])/2],a(f*h)}x=null,o(t,e),c(g)}function l(){if(ui.event.touches.length){for(var e=ui.event.changedTouches,n=0,r=e.length;r>n;++n)delete m[e[n].identifier];for(var a in m)return void t()}ui.selectAll(w).on(y,null),k.on(E,f).on(N,d),A(),u(g)}var h,p=this,g=D.of(p,arguments),m={},v=0,y=".zoom-"+ui.event.changedTouches[0].identifier,b="touchmove"+y,_="touchend"+y,w=[],k=ui.select(p),A=W(p);n(),s(g),k.on(E,null).on(N,n)}function h(){var t=D.of(this,arguments);y?clearTimeout(y):(Zs.call(this),g=e(m=v||ui.mouse(this)),s(t)),y=setTimeout(function(){y=null,u(t)},50),T(),a(Math.pow(2,.002*Qi())*M.k),o(m,g),c(t)}function p(){var t=ui.mouse(this),n=Math.log(M.k)/Math.LN2;i(this,t,e(t),ui.event.shiftKey?Math.ceil(n)-1:Math.floor(n)+1)}var g,m,v,y,x,b,_,w,k,M={x:0,y:0,k:1},A=[960,500],L=Ji,S=250,C=0,E="mousedown.zoom",O="mousemove.zoom",P="mouseup.zoom",N="touchstart.zoom",D=z(t,"zoomstart","zoom","zoomend");return Wi||(Wi="onwheel"in hi?(Qi=function(){return-ui.event.deltaY*(ui.event.deltaMode?120:1)},"wheel"):"onmousewheel"in hi?(Qi=function(){return ui.event.wheelDelta},"mousewheel"):(Qi=function(){return-ui.event.detail},"MozMousePixelScroll")),t.event=function(t){t.each(function(){var t=D.of(this,arguments),e=M;Hs?ui.select(this).transition().each("start.zoom",function(){M=this.__chart__||{x:0,y:0,k:1},s(t)}).tween("zoom:zoom",function(){var n=A[0],r=A[1],a=m?m[0]:n/2,o=m?m[1]:r/2,i=ui.interpolateZoom([(a-M.x)/M.k,(o-M.y)/M.k,n/M.k],[(a-e.x)/e.k,(o-e.y)/e.k,n/e.k]);return function(e){var r=i(e),l=n/r[2];this.__chart__=M={x:a-r[0]*l,y:o-r[1]*l,k:l},c(t)}}).each("interrupt.zoom",function(){u(t)}).each("end.zoom",function(){u(t)}):(this.__chart__=M,s(t),c(t),u(t))})},t.translate=function(e){return arguments.length?(M={x:+e[0],y:+e[1],k:M.k},l(),t):[M.x,M.y]},t.scale=function(e){return arguments.length?(M={x:M.x,y:M.y,k:null},a(+e),l(),t):M.k},t.scaleExtent=function(e){return arguments.length?(L=null==e?Ji:[+e[0],+e[1]],t):L},t.center=function(e){return arguments.length?(v=e&&[+e[0],+e[1]],t):v},t.size=function(e){return arguments.length?(A=e&&[+e[0],+e[1]],t):A},t.duration=function(e){return arguments.length?(S=+e,t):S},t.x=function(e){return arguments.length?(_=e,b=e.copy(),M={x:0,y:0,k:1},t):_},t.y=function(e){return arguments.length?(k=e,w=e.copy(),M={x:0,y:0,k:1},t):k},ui.rebind(t,D,"on")};var Qi,Wi,Ji=[0,1/0];ui.color=st,st.prototype.toString=function(){return this.rgb()+""},ui.hsl=ct;var Ki=ct.prototype=new st;Ki.brighter=function(t){return t=Math.pow(.7,arguments.length?t:1),new ct(this.h,this.s,this.l/t)},Ki.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new ct(this.h,this.s,t*this.l)},Ki.rgb=function(){return ut(this.h,this.s,this.l)},ui.hcl=ft;var tl=ft.prototype=new st;tl.brighter=function(t){return new ft(this.h,this.c,Math.min(100,this.l+el*(arguments.length?t:1)))},tl.darker=function(t){return new ft(this.h,this.c,Math.max(0,this.l-el*(arguments.length?t:1)))},tl.rgb=function(){return dt(this.h,this.c,this.l).rgb()},ui.lab=ht;var el=18,nl=.95047,rl=1,al=1.08883,ol=ht.prototype=new st;ol.brighter=function(t){return new ht(Math.min(100,this.l+el*(arguments.length?t:1)),this.a,this.b)},ol.darker=function(t){return new ht(Math.max(0,this.l-el*(arguments.length?t:1)),this.a,this.b)},ol.rgb=function(){return pt(this.l,this.a,this.b)},ui.rgb=xt;var il=xt.prototype=new st;il.brighter=function(t){t=Math.pow(.7,arguments.length?t:1);var e=this.r,n=this.g,r=this.b,a=30;return e||n||r?(e&&a>e&&(e=a),n&&a>n&&(n=a),r&&a>r&&(r=a),new xt(Math.min(255,e/t),Math.min(255,n/t),Math.min(255,r/t))):new xt(a,a,a)},il.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new xt(t*this.r,t*this.g,t*this.b)},il.hsl=function(){return Mt(this.r,this.g,this.b)},il.toString=function(){return"#"+wt(this.r)+wt(this.g)+wt(this.b)};var ll=ui.map({aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074});ll.forEach(function(t,e){ll.set(t,bt(e))}),ui.functor=zt,ui.xhr=St(b),ui.dsv=function(t,e){function n(t,n,o){arguments.length<3&&(o=n,n=null);var i=Ct(t,e,null==n?r:a(n),o);return i.row=function(t){return arguments.length?i.response(null==(n=t)?r:a(t)):n},i}function r(t){return n.parse(t.responseText)}function a(t){return function(e){return n.parse(e.responseText,t)}}function o(e){return e.map(i).join(t)}function i(t){return l.test(t)?'"'+t.replace(/\"/g,'""')+'"':t}var l=new RegExp('["'+t+"\n]"),s=t.charCodeAt(0);return n.parse=function(t,e){var r;return n.parseRows(t,function(t,n){if(r)return r(t,n-1);var a=new Function("d","return {"+t.map(function(t,e){return JSON.stringify(t)+": d["+e+"]"}).join(",")+"}");r=e?function(t,n){return e(a(t),n)}:a})},n.parseRows=function(t,e){function n(){if(u>=c)return i;if(a)return a=!1,o;var e=u;if(34===t.charCodeAt(e)){for(var n=e;n++u;){var r=t.charCodeAt(u++),l=1;if(10===r)a=!0;else if(13===r)a=!0,10===t.charCodeAt(u)&&(++u,++l);else if(r!==s)continue;return t.slice(e,u-l)}return t.slice(e)}for(var r,a,o={},i={},l=[],c=t.length,u=0,f=0;(r=n())!==i;){for(var d=[];r!==o&&r!==i;)d.push(r),r=n();e&&null==(d=e(d,f++))||l.push(d)}return l},n.format=function(e){if(Array.isArray(e[0]))return n.formatRows(e);var r=new x,a=[];return e.forEach(function(t){for(var e in t)r.has(e)||a.push(r.add(e))}),[a.map(i).join(t)].concat(e.map(function(e){return a.map(function(t){return i(e[t])}).join(t)})).join("\n")},n.formatRows=function(t){return t.map(o).join("\n")},n},ui.csv=ui.dsv(",","text/csv"),ui.tsv=ui.dsv(" ","text/tab-separated-values");var sl,cl,ul,fl,dl=this[w(this,"requestAnimationFrame")]||function(t){setTimeout(t,17)};ui.timer=function(){Pt.apply(this,arguments)},ui.timer.flush=function(){Dt(),It()},ui.round=function(t,e){return e?Math.round(t*(e=Math.pow(10,e)))/e:Math.round(t)};var hl=["y","z","a","f","p","n","\xb5","m","","k","M","G","T","P","E","Z","Y"].map(jt);ui.formatPrefix=function(t,e){var n=0;return(t=+t)&&(0>t&&(t*=-1),e&&(t=ui.round(t,Rt(t,e))),n=1+Math.floor(1e-12+Math.log(t)/Math.LN10),n=Math.max(-24,Math.min(24,3*Math.floor((n-1)/3)))),hl[8+n/3]};var pl=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,gl=ui.map({b:function(t){return t.toString(2)},c:function(t){return String.fromCharCode(t)},o:function(t){return t.toString(8)},x:function(t){return t.toString(16)},X:function(t){return t.toString(16).toUpperCase()},g:function(t,e){return t.toPrecision(e)},e:function(t,e){return t.toExponential(e)},f:function(t,e){return t.toFixed(e)},r:function(t,e){return(t=ui.round(t,Rt(t,e))).toFixed(Math.max(0,Math.min(20,Rt(t*(1+1e-15),e))))}}),ml=ui.time={},vl=Date;Bt.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){yl.setUTCDate.apply(this._,arguments)},setDay:function(){yl.setUTCDay.apply(this._,arguments)},setFullYear:function(){yl.setUTCFullYear.apply(this._,arguments)},setHours:function(){yl.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){yl.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){yl.setUTCMinutes.apply(this._,arguments)},setMonth:function(){yl.setUTCMonth.apply(this._,arguments)},setSeconds:function(){yl.setUTCSeconds.apply(this._,arguments)},setTime:function(){yl.setTime.apply(this._,arguments)}};var yl=Date.prototype;ml.year=Ht(function(t){return t=ml.day(t),t.setMonth(0,1),t},function(t,e){t.setFullYear(t.getFullYear()+e)},function(t){return t.getFullYear()}),ml.years=ml.year.range,ml.years.utc=ml.year.utc.range,ml.day=Ht(function(t){var e=new vl(2e3,0);return e.setFullYear(t.getFullYear(),t.getMonth(),t.getDate()),e},function(t,e){t.setDate(t.getDate()+e)},function(t){return t.getDate()-1}),ml.days=ml.day.range,ml.days.utc=ml.day.utc.range,ml.dayOfYear=function(t){var e=ml.year(t);return Math.floor((t-e-6e4*(t.getTimezoneOffset()-e.getTimezoneOffset()))/864e5)},["sunday","monday","tuesday","wednesday","thursday","friday","saturday"].forEach(function(t,e){e=7-e;var n=ml[t]=Ht(function(t){return(t=ml.day(t)).setDate(t.getDate()-(t.getDay()+e)%7),t},function(t,e){t.setDate(t.getDate()+7*Math.floor(e))},function(t){var n=ml.year(t).getDay();return Math.floor((ml.dayOfYear(t)+(n+e)%7)/7)-(n!==e)});ml[t+"s"]=n.range,ml[t+"s"].utc=n.utc.range,ml[t+"OfYear"]=function(t){var n=ml.year(t).getDay();return Math.floor((ml.dayOfYear(t)+(n+e)%7)/7)}}),ml.week=ml.sunday,ml.weeks=ml.sunday.range,ml.weeks.utc=ml.sunday.utc.range,ml.weekOfYear=ml.sundayOfYear;var xl={"-":"",_:" ",0:"0"},bl=/^\s*\d+/,_l=/^%/;ui.locale=function(t){return{numberFormat:Ft(t),timeFormat:Zt(t)}};var wl=ui.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});ui.format=wl.numberFormat,ui.geo={},fe.prototype={s:0,t:0,add:function(t){de(t,this.t,kl),de(kl.s,this.s,this),this.s?this.t+=kl.t:this.s=kl.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var kl=new fe;ui.geo.stream=function(t,e){t&&Ml.hasOwnProperty(t.type)?Ml[t.type](t,e):he(t,e)};var Ml={Feature:function(t,e){he(t.geometry,e)},FeatureCollection:function(t,e){for(var n=t.features,r=-1,a=n.length;++rt?4*Bi+t:t,zl.lineStart=zl.lineEnd=zl.point=k}};ui.geo.bounds=function(){function t(t,e){x.push(b=[u=t,d=t]),f>e&&(f=e),e>h&&(h=e)}function e(e,n){var r=ve([e*Ui,n*Ui]);if(v){var a=xe(v,r),o=[a[1],-a[0],0],i=xe(o,a);we(i),i=ke(i);var s=e-p,c=s>0?1:-1,g=i[0]*Yi*c,m=wi(s)>180;if(m^(g>c*p&&c*e>g)){var y=i[1]*Yi;y>h&&(h=y)}else if(g=(g+360)%360-180,m^(g>c*p&&c*e>g)){var y=-i[1]*Yi;f>y&&(f=y)}else f>n&&(f=n),n>h&&(h=n);m?p>e?l(u,e)>l(u,d)&&(d=e):l(e,d)>l(u,d)&&(u=e):d>=u?(u>e&&(u=e),e>d&&(d=e)):e>p?l(u,e)>l(u,d)&&(d=e):l(e,d)>l(u,d)&&(u=e)}else t(e,n);v=r,p=e}function n(){_.point=e}function r(){b[0]=u,b[1]=d,_.point=t,v=null}function a(t,n){if(v){var r=t-p;y+=wi(r)>180?r+(r>0?360:-360):r}else g=t,m=n;zl.point(t,n),e(t,n)}function o(){zl.lineStart()}function i(){a(g,m),zl.lineEnd(),wi(y)>Fi&&(u=-(d=180)),b[0]=u,b[1]=d,v=null}function l(t,e){return(e-=t)<0?e+360:e}function s(t,e){return t[0]-e[0]}function c(t,e){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:tLl?(u=-(d=180),f=-(h=90)):y>Fi?h=90:-Fi>y&&(f=-90),b[0]=u,b[1]=d}};return function(t){h=d=-(u=f=1/0),x=[],ui.geo.stream(t,_);var e=x.length;if(e){x.sort(s);for(var n,r=1,a=x[0],o=[a];e>r;++r)n=x[r],c(n[0],a)||c(n[1],a)?(l(a[0],n[1])>l(a[0],a[1])&&(a[1]=n[1]),l(n[0],a[1])>l(a[0],a[1])&&(a[0]=n[0])):o.push(a=n);for(var i,n,p=-(1/0),e=o.length-1,r=0,a=o[e];e>=r;a=n,++r)n=o[r],(i=l(a[1],n[0]))>p&&(p=i,u=n[0],d=a[1])}return x=b=null,u===1/0||f===1/0?[[NaN,NaN],[NaN,NaN]]:[[u,f],[d,h]]}}(),ui.geo.centroid=function(t){Sl=Cl=El=Ol=Pl=Nl=Dl=Il=Rl=jl=Fl=0,ui.geo.stream(t,ql);var e=Rl,n=jl,r=Fl,a=e*e+n*n+r*r;return qi>a&&(e=Nl,n=Dl,r=Il,Fi>Cl&&(e=El,n=Ol,r=Pl),a=e*e+n*n+r*r,qi>a)?[NaN,NaN]:[Math.atan2(n,e)*Yi,rt(r/Math.sqrt(a))*Yi]};var Sl,Cl,El,Ol,Pl,Nl,Dl,Il,Rl,jl,Fl,ql={sphere:k,point:Ae,lineStart:Le,lineEnd:ze,polygonStart:function(){ql.lineStart=Se},polygonEnd:function(){ql.lineStart=Le}},Bl=De(Ee,Fe,Be,[-Bi,-Bi/2]),Hl=1e9;ui.geo.clipExtent=function(){var t,e,n,r,a,o,i={stream:function(t){return a&&(a.valid=!1),a=o(t),a.valid=!0,a},extent:function(l){return arguments.length?(o=Ue(t=+l[0][0],e=+l[0][1],n=+l[1][0],r=+l[1][1]),a&&(a.valid=!1,a=null),i):[[t,e],[n,r]]}};return i.extent([[0,0],[960,500]])},(ui.geo.conicEqualArea=function(){return Ye(Xe)}).raw=Xe,ui.geo.albers=function(){return ui.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},ui.geo.albersUsa=function(){function t(t){var o=t[0],i=t[1];return e=null,n(o,i),e||(r(o,i),e)||a(o,i),e}var e,n,r,a,o=ui.geo.albers(),i=ui.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),l=ui.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),s={point:function(t,n){e=[t,n]}};return t.invert=function(t){var e=o.scale(),n=o.translate(),r=(t[0]-n[0])/e,a=(t[1]-n[1])/e;return(a>=.12&&.234>a&&r>=-.425&&-.214>r?i:a>=.166&&.234>a&&r>=-.214&&-.115>r?l:o).invert(t)},t.stream=function(t){var e=o.stream(t),n=i.stream(t),r=l.stream(t);return{point:function(t,a){e.point(t,a),n.point(t,a),r.point(t,a)},sphere:function(){e.sphere(),n.sphere(),r.sphere()},lineStart:function(){e.lineStart(),n.lineStart(),r.lineStart()},lineEnd:function(){e.lineEnd(),n.lineEnd(),r.lineEnd()},polygonStart:function(){e.polygonStart(),n.polygonStart(),r.polygonStart()},polygonEnd:function(){e.polygonEnd(),n.polygonEnd(),r.polygonEnd()}}},t.precision=function(e){return arguments.length?(o.precision(e),i.precision(e),l.precision(e),t):o.precision()},t.scale=function(e){return arguments.length?(o.scale(e),i.scale(.35*e),l.scale(e),t.translate(o.translate())):o.scale()},t.translate=function(e){if(!arguments.length)return o.translate();var c=o.scale(),u=+e[0],f=+e[1];return n=o.translate(e).clipExtent([[u-.455*c,f-.238*c],[u+.455*c,f+.238*c]]).stream(s).point,r=i.translate([u-.307*c,f+.201*c]).clipExtent([[u-.425*c+Fi,f+.12*c+Fi],[u-.214*c-Fi,f+.234*c-Fi]]).stream(s).point,a=l.translate([u-.205*c,f+.212*c]).clipExtent([[u-.214*c+Fi,f+.166*c+Fi],[u-.115*c-Fi,f+.234*c-Fi]]).stream(s).point,t},t.scale(1070)};var Vl,Zl,Ul,Yl,Xl,Gl,$l={point:k,lineStart:k,lineEnd:k,polygonStart:function(){Zl=0,$l.lineStart=Ge},polygonEnd:function(){$l.lineStart=$l.lineEnd=$l.point=k,Vl+=wi(Zl/2)}},Ql={point:$e,lineStart:k,lineEnd:k,polygonStart:k,polygonEnd:k},Wl={point:Je,lineStart:Ke,lineEnd:tn,polygonStart:function(){Wl.lineStart=en},polygonEnd:function(){Wl.point=Je,Wl.lineStart=Ke,Wl.lineEnd=tn}};ui.geo.path=function(){function t(t){return t&&("function"==typeof l&&o.pointRadius(+l.apply(this,arguments)),i&&i.valid||(i=a(o)),ui.geo.stream(t,i)),o.result()}function e(){return i=null,t}var n,r,a,o,i,l=4.5;return t.area=function(t){return Vl=0,ui.geo.stream(t,a($l)),Vl},t.centroid=function(t){return El=Ol=Pl=Nl=Dl=Il=Rl=jl=Fl=0,ui.geo.stream(t,a(Wl)),Fl?[Rl/Fl,jl/Fl]:Il?[Nl/Il,Dl/Il]:Pl?[El/Pl,Ol/Pl]:[NaN,NaN]},t.bounds=function(t){return Xl=Gl=-(Ul=Yl=1/0),ui.geo.stream(t,a(Ql)),[[Ul,Yl],[Xl,Gl]]},t.projection=function(t){return arguments.length?(a=(n=t)?t.stream||an(t):b,e()):n},t.context=function(t){return arguments.length?(o=null==(r=t)?new Qe:new nn(t),"function"!=typeof l&&o.pointRadius(l),e()):r},t.pointRadius=function(e){return arguments.length?(l="function"==typeof e?e:(o.pointRadius(+e),+e),t):l},t.projection(ui.geo.albersUsa()).context(null)},ui.geo.transform=function(t){return{stream:function(e){var n=new on(e);for(var r in t)n[r]=t[r];return n}}},on.prototype={point:function(t,e){this.stream.point(t,e)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}},ui.geo.projection=sn,ui.geo.projectionMutator=cn,(ui.geo.equirectangular=function(){return sn(fn)}).raw=fn.invert=fn,ui.geo.rotation=function(t){function e(e){return e=t(e[0]*Ui,e[1]*Ui),e[0]*=Yi,e[1]*=Yi,e}return t=hn(t[0]%360*Ui,t[1]*Ui,t.length>2?t[2]*Ui:0),e.invert=function(e){return e=t.invert(e[0]*Ui,e[1]*Ui),e[0]*=Yi,e[1]*=Yi,e},e},dn.invert=fn,ui.geo.circle=function(){function t(){var t="function"==typeof r?r.apply(this,arguments):r,e=hn(-t[0]*Ui,-t[1]*Ui,0).invert,a=[];return n(null,null,1,{point:function(t,n){a.push(t=e(t,n)),t[0]*=Yi,t[1]*=Yi}}),{type:"Polygon",coordinates:[a]}}var e,n,r=[0,0],a=6;return t.origin=function(e){return arguments.length?(r=e,t):r},t.angle=function(r){return arguments.length?(n=vn((e=+r)*Ui,a*Ui),t):e},t.precision=function(r){return arguments.length?(n=vn(e*Ui,(a=+r)*Ui),t):a},t.angle(90)},ui.geo.distance=function(t,e){var n,r=(e[0]-t[0])*Ui,a=t[1]*Ui,o=e[1]*Ui,i=Math.sin(r),l=Math.cos(r),s=Math.sin(a),c=Math.cos(a),u=Math.sin(o),f=Math.cos(o);return Math.atan2(Math.sqrt((n=f*i)*n+(n=c*u-s*f*l)*n),s*u+c*f*l)},ui.geo.graticule=function(){function t(){return{type:"MultiLineString",coordinates:e()}}function e(){return ui.range(Math.ceil(o/m)*m,a,m).map(d).concat(ui.range(Math.ceil(c/v)*v,s,v).map(h)).concat(ui.range(Math.ceil(r/p)*p,n,p).filter(function(t){return wi(t%m)>Fi}).map(u)).concat(ui.range(Math.ceil(l/g)*g,i,g).filter(function(t){return wi(t%v)>Fi}).map(f))}var n,r,a,o,i,l,s,c,u,f,d,h,p=10,g=p,m=90,v=360,y=2.5;return t.lines=function(){return e().map(function(t){return{type:"LineString",coordinates:t}})},t.outline=function(){return{type:"Polygon",coordinates:[d(o).concat(h(s).slice(1),d(a).reverse().slice(1),h(c).reverse().slice(1))]}},t.extent=function(e){return arguments.length?t.majorExtent(e).minorExtent(e):t.minorExtent()},t.majorExtent=function(e){return arguments.length?(o=+e[0][0],a=+e[1][0],c=+e[0][1],s=+e[1][1],o>a&&(e=o,o=a,a=e),c>s&&(e=c,c=s,s=e),t.precision(y)):[[o,c],[a,s]]},t.minorExtent=function(e){return arguments.length?(r=+e[0][0],n=+e[1][0],l=+e[0][1],i=+e[1][1],r>n&&(e=r,r=n,n=e),l>i&&(e=l,l=i,i=e),t.precision(y)):[[r,l],[n,i]]},t.step=function(e){return arguments.length?t.majorStep(e).minorStep(e):t.minorStep()},t.majorStep=function(e){return arguments.length?(m=+e[0],v=+e[1],t):[m,v]},t.minorStep=function(e){return arguments.length?(p=+e[0],g=+e[1],t):[p,g]},t.precision=function(e){return arguments.length?(y=+e,u=xn(l,i,90),f=bn(r,n,y),d=xn(c,s,90),h=bn(o,a,y),t):y},t.majorExtent([[-180,-90+Fi],[180,90-Fi]]).minorExtent([[-180,-80-Fi],[180,80+Fi]])},ui.geo.greatArc=function(){function t(){return{type:"LineString",coordinates:[e||r.apply(this,arguments),n||a.apply(this,arguments)]}}var e,n,r=_n,a=wn;return t.distance=function(){return ui.geo.distance(e||r.apply(this,arguments),n||a.apply(this,arguments))},t.source=function(n){return arguments.length?(r=n,e="function"==typeof n?null:n,t):r},t.target=function(e){return arguments.length?(a=e,n="function"==typeof e?null:e,t):a},t.precision=function(){return arguments.length?t:0},t},ui.geo.interpolate=function(t,e){return kn(t[0]*Ui,t[1]*Ui,e[0]*Ui,e[1]*Ui)},ui.geo.length=function(t){return Jl=0,ui.geo.stream(t,Kl),Jl};var Jl,Kl={sphere:k,point:k,lineStart:Mn,lineEnd:k,polygonStart:k,polygonEnd:k},ts=An(function(t){return Math.sqrt(2/(1+t))},function(t){return 2*Math.asin(t/2)});(ui.geo.azimuthalEqualArea=function(){return sn(ts)}).raw=ts;var es=An(function(t){var e=Math.acos(t);return e&&e/Math.sin(e)},b);(ui.geo.azimuthalEquidistant=function(){return sn(es)}).raw=es,(ui.geo.conicConformal=function(){return Ye(Tn)}).raw=Tn,(ui.geo.conicEquidistant=function(){return Ye(Ln)}).raw=Ln;var ns=An(function(t){return 1/t},Math.atan);(ui.geo.gnomonic=function(){return sn(ns)}).raw=ns,zn.invert=function(t,e){return[t,2*Math.atan(Math.exp(e))-Zi]},(ui.geo.mercator=function(){return Sn(zn)}).raw=zn;var rs=An(function(){return 1},Math.asin);(ui.geo.orthographic=function(){return sn(rs)}).raw=rs;var as=An(function(t){return 1/(1+t)},function(t){return 2*Math.atan(t)});(ui.geo.stereographic=function(){return sn(as)}).raw=as,Cn.invert=function(t,e){return[-e,2*Math.atan(Math.exp(t))-Zi]},(ui.geo.transverseMercator=function(){var t=Sn(Cn),e=t.center,n=t.rotate;return t.center=function(t){return t?e([-t[1],t[0]]):(t=e(),[t[1],-t[0]])},t.rotate=function(t){return t?n([t[0],t[1],t.length>2?t[2]+90:90]):(t=n(),[t[0],t[1],t[2]-90])},n([0,0,90])}).raw=Cn,ui.geom={},ui.geom.hull=function(t){function e(t){if(t.length<3)return[];var e,a=zt(n),o=zt(r),i=t.length,l=[],s=[];for(e=0;i>e;e++)l.push([+a.call(this,t[e],e),+o.call(this,t[e],e),e]);for(l.sort(Nn),e=0;i>e;e++)s.push([l[e][0],-l[e][1]]);var c=Pn(l),u=Pn(s),f=u[0]===c[0],d=u[u.length-1]===c[c.length-1],h=[];for(e=c.length-1;e>=0;--e)h.push(t[l[c[e]][2]]);for(e=+f;e=r&&c.x<=o&&c.y>=a&&c.y<=i?[[r,i],[o,i],[o,a],[r,a]]:[];u.point=t[l]}),e}function n(t){return t.map(function(t,e){return{x:Math.round(o(t,e)/Fi)*Fi,y:Math.round(i(t,e)/Fi)*Fi,i:e}})}var r=En,a=On,o=r,i=a,l=hs;return t?e(t):(e.links=function(t){return cr(n(t)).edges.filter(function(t){return t.l&&t.r}).map(function(e){return{source:t[e.l.i],target:t[e.r.i]}})},e.triangles=function(t){var e=[];return cr(n(t)).cells.forEach(function(n,r){for(var a,o,i=n.site,l=n.edges.sort(Xn),s=-1,c=l.length,u=l[c-1].edge,f=u.l===i?u.r:u.l;++s=c,d=r>=u,h=d<<1|f;t.leaf=!1,t=t.nodes[h]||(t.nodes[h]=pr()),f?a=c:l=c,d?i=u:s=u,o(t,e,n,r,a,i,l,s)}var u,f,d,h,p,g,m,v,y,x=zt(l),b=zt(s);if(null!=e)g=e,m=n,v=r,y=a;else if(v=y=-(g=m=1/0),f=[],d=[],p=t.length,i)for(h=0;p>h;++h)u=t[h],u.xv&&(v=u.x),u.y>y&&(y=u.y),f.push(u.x),d.push(u.y);else for(h=0;p>h;++h){var _=+x(u=t[h],h),w=+b(u,h);g>_&&(g=_),m>w&&(m=w),_>v&&(v=_),w>y&&(y=w),f.push(_),d.push(w)}var k=v-g,M=y-m;k>M?y=m+k:v=g+M;var A=pr();if(A.add=function(t){o(A,t,+x(t,++h),+b(t,h),g,m,v,y)},A.visit=function(t){gr(t,A,g,m,v,y)},A.find=function(t){return mr(A,t[0],t[1],g,m,v,y)},h=-1,null==e){for(;++h=0?t.slice(0,e):t,r=e>=0?t.slice(e+1):"in";return n=vs.get(n)||ms,r=ys.get(r)||b,kr(r(n.apply(null,fi.call(arguments,1))))},ui.interpolateHcl=Ir,ui.interpolateHsl=Rr,ui.interpolateLab=jr,ui.interpolateRound=Fr,ui.transform=function(t){var e=hi.createElementNS(ui.ns.prefix.svg,"g");return(ui.transform=function(t){if(null!=t){e.setAttribute("transform",t);var n=e.transform.baseVal.consolidate()}return new qr(n?n.matrix:xs)})(t)},qr.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var xs={a:1,b:0,c:0,d:1,e:0,f:0};ui.interpolateTransform=$r,ui.layout={},ui.layout.bundle=function(){return function(t){for(var e=[],n=-1,r=t.length;++nl*l/v){if(g>s){var c=e.charge/s;t.px-=o*c,t.py-=i*c}return!0}if(e.point&&s&&g>s){var c=e.pointCharge/s;t.px-=o*c,t.py-=i*c}}return!e.charge}}function e(t){t.px=ui.event.x,t.py=ui.event.y,s.resume()}var n,r,a,o,i,l,s={},c=ui.dispatch("start","tick","end"),u=[1,1],f=.9,d=bs,h=_s,p=-30,g=ws,m=.1,v=.64,y=[],x=[];return s.tick=function(){if((a*=.99)<.005)return n=null,c.end({type:"end",alpha:a=0}),!0;var e,r,s,d,h,g,v,b,_,w=y.length,k=x.length;for(r=0;k>r;++r)s=x[r],d=s.source,h=s.target,b=h.x-d.x,_=h.y-d.y,(g=b*b+_*_)&&(g=a*i[r]*((g=Math.sqrt(g))-o[r])/g,b*=g,_*=g,h.x-=b*(v=d.weight+h.weight?d.weight/(d.weight+h.weight):.5),h.y-=_*v,d.x+=b*(v=1-v),d.y+=_*v);if((v=a*m)&&(b=u[0]/2,_=u[1]/2,r=-1,v))for(;++r0?a=t:(n.c=null,n.t=NaN,n=null,c.end({type:"end",alpha:a=0})):t>0&&(c.start({type:"start",alpha:a=t}),n=Pt(s.tick)),s):a},s.start=function(){function t(t,r){if(!n){for(n=new Array(a),s=0;a>s;++s)n[s]=[];for(s=0;c>s;++s){var o=x[s];n[o.source.index].push(o.target),n[o.target.index].push(o.source)}}for(var i,l=n[e],s=-1,u=l.length;++se;++e)(r=y[e]).index=e,r.weight=0;for(e=0;c>e;++e)r=x[e],"number"==typeof r.source&&(r.source=y[r.source]),"number"==typeof r.target&&(r.target=y[r.target]),++r.source.weight,++r.target.weight;for(e=0;a>e;++e)r=y[e],isNaN(r.x)&&(r.x=t("x",f)),isNaN(r.y)&&(r.y=t("y",g)),isNaN(r.px)&&(r.px=r.x),isNaN(r.py)&&(r.py=r.y);if(o=[],"function"==typeof d)for(e=0;c>e;++e)o[e]=+d.call(this,x[e],e);else for(e=0;c>e;++e)o[e]=d;if(i=[],"function"==typeof h)for(e=0;c>e;++e)i[e]=+h.call(this,x[e],e);else for(e=0;c>e;++e)i[e]=h;if(l=[],"function"==typeof p)for(e=0;a>e;++e)l[e]=+p.call(this,y[e],e);else for(e=0;a>e;++e)l[e]=p;return s.resume()},s.resume=function(){return s.alpha(.1)},s.stop=function(){return s.alpha(0)},s.drag=function(){return r||(r=ui.behavior.drag().origin(b).on("dragstart.force",ea).on("drag.force",e).on("dragend.force",na)),arguments.length?void this.on("mouseover.force",ra).on("mouseout.force",aa).call(r):r},ui.rebind(s,c,"on")};var bs=20,_s=1,ws=1/0;ui.layout.hierarchy=function(){function t(a){var o,i=[a],l=[];for(a.depth=0;null!=(o=i.pop());)if(l.push(o),(c=n.call(t,o,o.depth))&&(s=c.length)){for(var s,c,u;--s>=0;)i.push(u=c[s]),u.parent=o,u.depth=o.depth+1;r&&(o.value=0),o.children=c}else r&&(o.value=+r.call(t,o,o.depth)||0),delete o.children;return sa(a,function(t){var n,a;e&&(n=t.children)&&n.sort(e),r&&(a=t.parent)&&(a.value+=t.value)}),l}var e=fa,n=ca,r=ua;return t.sort=function(n){return arguments.length?(e=n,t):e},t.children=function(e){return arguments.length?(n=e,t):n},t.value=function(e){return arguments.length?(r=e,t):r},t.revalue=function(e){return r&&(la(e,function(t){t.children&&(t.value=0)}),sa(e,function(e){var n;e.children||(e.value=+r.call(t,e,e.depth)||0),(n=e.parent)&&(n.value+=e.value)})),e},t},ui.layout.partition=function(){function t(e,n,r,a){var o=e.children;if(e.x=n,e.y=e.depth*a,e.dx=r,e.dy=a,o&&(i=o.length)){var i,l,s,c=-1;for(r=e.value?r/e.value:0;++cf?-1:1),p=ui.sum(c),g=p?(f-s*h)/p:0,m=ui.range(s),v=[];return null!=n&&m.sort(n===ks?function(t,e){return c[e]-c[t]}:function(t,e){return n(i[t],i[e])}),m.forEach(function(t){v[t]={data:i[t],value:l=c[t],startAngle:u,endAngle:u+=l*g+h,padAngle:d}}),v}var e=Number,n=ks,r=0,a=Hi,o=0;return t.value=function(n){return arguments.length?(e=n,t):e},t.sort=function(e){return arguments.length?(n=e,t):n},t.startAngle=function(e){return arguments.length?(r=e,t):r},t.endAngle=function(e){return arguments.length?(a=e,t):a},t.padAngle=function(e){return arguments.length?(o=e,t):o},t};var ks={};ui.layout.stack=function(){function t(l,s){if(!(d=l.length))return l;var c=l.map(function(n,r){return e.call(t,n,r)}),u=c.map(function(e){return e.map(function(e,n){return[o.call(t,e,n),i.call(t,e,n)]})}),f=n.call(t,u,s);c=ui.permute(c,f),u=ui.permute(u,f);var d,h,p,g,m=r.call(t,u,s),v=c[0].length;for(p=0;v>p;++p)for(a.call(t,c[0][p],g=m[p],u[0][p][1]),h=1;d>h;++h)a.call(t,c[h][p],g+=u[h-1][p][1],u[h][p][1]);return l}var e=b,n=ma,r=va,a=ga,o=ha,i=pa;return t.values=function(n){return arguments.length?(e=n,t):e},t.order=function(e){return arguments.length?(n="function"==typeof e?e:Ms.get(e)||ma,t):n},t.offset=function(e){return arguments.length?(r="function"==typeof e?e:As.get(e)||va,t):r},t.x=function(e){return arguments.length?(o=e,t):o},t.y=function(e){return arguments.length?(i=e,t):i},t.out=function(e){return arguments.length?(a=e,t):a},t};var Ms=ui.map({"inside-out":function(t){var e,n,r=t.length,a=t.map(ya),o=t.map(xa),i=ui.range(r).sort(function(t,e){return a[t]-a[e]}),l=0,s=0,c=[],u=[];for(e=0;r>e;++e)n=i[e],s>l?(l+=o[n],c.push(n)):(s+=o[n],u.push(n));return u.reverse().concat(c)},reverse:function(t){return ui.range(t.length).reverse()},"default":ma}),As=ui.map({silhouette:function(t){var e,n,r,a=t.length,o=t[0].length,i=[],l=0,s=[];for(n=0;o>n;++n){for(e=0,r=0;a>e;e++)r+=t[e][n][1];r>l&&(l=r),i.push(r)}for(n=0;o>n;++n)s[n]=(l-i[n])/2;return s},wiggle:function(t){var e,n,r,a,o,i,l,s,c,u=t.length,f=t[0],d=f.length,h=[];for(h[0]=s=c=0,n=1;d>n;++n){for(e=0,a=0;u>e;++e)a+=t[e][n][1];for(e=0,o=0,l=f[n][0]-f[n-1][0];u>e;++e){for(r=0,i=(t[e][n][1]-t[e][n-1][1])/(2*l);e>r;++r)i+=(t[r][n][1]-t[r][n-1][1])/l;o+=i*t[e][n][1]}h[n]=s-=a?o/a*l:0,c>s&&(c=s)}for(n=0;d>n;++n)h[n]-=c;return h},expand:function(t){var e,n,r,a=t.length,o=t[0].length,i=1/a,l=[];for(n=0;o>n;++n){for(e=0,r=0;a>e;e++)r+=t[e][n][1];if(r)for(e=0;a>e;e++)t[e][n][1]/=r;else for(e=0;a>e;e++)t[e][n][1]=i}for(n=0;o>n;++n)l[n]=0;return l},zero:va});ui.layout.histogram=function(){function t(t,o){for(var i,l,s=[],c=t.map(n,this),u=r.call(this,c,o),f=a.call(this,u,c,o),o=-1,d=c.length,h=f.length-1,p=e?1:1/d;++o0)for(o=-1;++o=u[0]&&l<=u[1]&&(i=s[ui.bisect(f,l,1,h)-1],i.y+=p,i.push(t[o]));return s}var e=!0,n=Number,r=ka,a=_a;return t.value=function(e){return arguments.length?(n=e,t):n},t.range=function(e){return arguments.length?(r=zt(e),t):r},t.bins=function(e){return arguments.length?(a="number"==typeof e?function(t){return wa(t,e)}:zt(e),t):a},t.frequency=function(n){return arguments.length?(e=!!n,t):e},t},ui.layout.pack=function(){function t(t,o){var i=n.call(this,t,o),l=i[0],s=a[0],c=a[1],u=null==e?Math.sqrt:"function"==typeof e?e:function(){return e};if(l.x=l.y=0,sa(l,function(t){t.r=+u(t.value)}),sa(l,za),r){var f=r*(e?1:Math.max(2*l.r/s,2*l.r/c))/2;sa(l,function(t){t.r+=f}),sa(l,za),sa(l,function(t){t.r-=f})}return Ea(l,s/2,c/2,e?1:1/Math.max(2*l.r/s,2*l.r/c)),i}var e,n=ui.layout.hierarchy().sort(Ma),r=0,a=[1,1];return t.size=function(e){return arguments.length?(a=e,t):a},t.radius=function(n){return arguments.length?(e=null==n||"function"==typeof n?n:+n,t):e},t.padding=function(e){return arguments.length?(r=+e,t):r},ia(t,n)},ui.layout.tree=function(){function t(t,a){var u=i.call(this,t,a),f=u[0],d=e(f);if(sa(d,n),d.parent.m=-d.z,la(d,r),c)la(f,o);else{var h=f,p=f,g=f;la(f,function(t){t.xp.x&&(p=t),t.depth>g.depth&&(g=t)});var m=l(h,p)/2-h.x,v=s[0]/(p.x+l(p,h)/2+m),y=s[1]/(g.depth||1);la(f,function(t){t.x=(t.x+m)*v,t.y=t.depth*y})}return u}function e(t){for(var e,n={A:null,children:[t]},r=[n];null!=(e=r.pop());)for(var a,o=e.children,i=0,l=o.length;l>i;++i)r.push((o[i]=a={_:o[i],parent:e,children:(a=o[i].children)&&a.slice()||[],A:null,a:null,z:0,m:0,c:0,s:0,t:null,i:i}).a=a);return n.children[0]}function n(t){var e=t.children,n=t.parent.children,r=t.i?n[t.i-1]:null;if(e.length){Ra(t);var o=(e[0].z+e[e.length-1].z)/2;r?(t.z=r.z+l(t._,r._),t.m=t.z-o):t.z=o}else r&&(t.z=r.z+l(t._,r._));t.parent.A=a(t,r,t.parent.A||n[0])}function r(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function a(t,e,n){if(e){for(var r,a=t,o=t,i=e,s=a.parent.children[0],c=a.m,u=o.m,f=i.m,d=s.m;i=Da(i),a=Na(a),i&&a;)s=Na(s),o=Da(o),o.a=t,r=i.z+f-a.z-c+l(i._,a._),r>0&&(Ia(ja(i,t,n),t,r),c+=r,u+=r),f+=i.m,c+=a.m,d+=s.m,u+=o.m;i&&!Da(o)&&(o.t=i,o.m+=f-u),a&&!Na(s)&&(s.t=a,s.m+=c-d,n=t)}return n}function o(t){t.x*=s[0],t.y=t.depth*s[1]}var i=ui.layout.hierarchy().sort(null).value(null),l=Pa,s=[1,1],c=null;return t.separation=function(e){return arguments.length?(l=e,t):l},t.size=function(e){return arguments.length?(c=null==(s=e)?o:null,t):c?null:s},t.nodeSize=function(e){return arguments.length?(c=null==(s=e)?null:o,t):c?s:null},ia(t,i)},ui.layout.cluster=function(){function t(t,o){var i,l=e.call(this,t,o),s=l[0],c=0;sa(s,function(t){var e=t.children;e&&e.length?(t.x=qa(e),t.y=Fa(e)):(t.x=i?c+=n(t,i):0,t.y=0,i=t)});var u=Ba(s),f=Ha(s),d=u.x-n(u,f)/2,h=f.x+n(f,u)/2;return sa(s,a?function(t){t.x=(t.x-s.x)*r[0],t.y=(s.y-t.y)*r[1]}:function(t){t.x=(t.x-d)/(h-d)*r[0],t.y=(1-(s.y?t.y/s.y:1))*r[1]}),l}var e=ui.layout.hierarchy().sort(null).value(null),n=Pa,r=[1,1],a=!1;return t.separation=function(e){return arguments.length?(n=e,t):n},t.size=function(e){return arguments.length?(a=null==(r=e),t):a?null:r},t.nodeSize=function(e){return arguments.length?(a=null!=(r=e),t):a?r:null},ia(t,e)},ui.layout.treemap=function(){function t(t,e){for(var n,r,a=-1,o=t.length;++ae?0:e),n.area=isNaN(r)||0>=r?0:r}function e(n){var o=n.children;if(o&&o.length){var i,l,s,c=f(n),u=[],d=o.slice(),p=1/0,g="slice"===h?c.dx:"dice"===h?c.dy:"slice-dice"===h?1&n.depth?c.dy:c.dx:Math.min(c.dx,c.dy);for(t(d,c.dx*c.dy/n.value),u.area=0;(s=d.length)>0;)u.push(i=d[s-1]),u.area+=i.area,"squarify"!==h||(l=r(u,g))<=p?(d.pop(),p=l):(u.area-=u.pop().area,a(u,g,c,!1),g=Math.min(c.dx,c.dy),u.length=u.area=0,p=1/0);u.length&&(a(u,g,c,!0),u.length=u.area=0),o.forEach(e)}}function n(e){var r=e.children;if(r&&r.length){var o,i=f(e),l=r.slice(),s=[];for(t(l,i.dx*i.dy/e.value),s.area=0;o=l.pop();)s.push(o),s.area+=o.area,null!=o.z&&(a(s,o.z?i.dx:i.dy,i,!l.length),s.length=s.area=0);r.forEach(n)}}function r(t,e){for(var n,r=t.area,a=0,o=1/0,i=-1,l=t.length;++in&&(o=n),n>a&&(a=n));return r*=r,e*=e,r?Math.max(e*a*p/r,r/(e*o*p)):1/0}function a(t,e,n,r){var a,o=-1,i=t.length,l=n.x,c=n.y,u=e?s(t.area/e):0;if(e==n.dx){for((r||u>n.dy)&&(u=n.dy);++on.dx)&&(u=n.dx);++on&&(e=1),1>n&&(t=0),function(){var n,r,a;do n=2*Math.random()-1,r=2*Math.random()-1,a=n*n+r*r;while(!a||a>1);return t+e*n*Math.sqrt(-2*Math.log(a)/a)}},logNormal:function(){var t=ui.random.normal.apply(ui,arguments);return function(){return Math.exp(t())}},bates:function(t){var e=ui.random.irwinHall(t);return function(){return e()/t}},irwinHall:function(t){return function(){for(var e=0,n=0;t>n;n++)e+=Math.random();return e}}},ui.scale={};var Ts={floor:b,ceil:b};ui.scale.linear=function(){return Wa([0,1],[0,1],_r,!1)};var Ls={s:1,g:1,p:1,r:1,e:1};ui.scale.log=function(){return oo(ui.scale.linear().domain([0,1]),10,!0,[1,10])};var zs=ui.format(".0e"),Ss={floor:function(t){return-Math.ceil(-t)},ceil:function(t){return-Math.floor(-t)}};ui.scale.pow=function(){return io(ui.scale.linear(),1,[0,1])},ui.scale.sqrt=function(){return ui.scale.pow().exponent(.5)},ui.scale.ordinal=function(){return so([],{t:"range",a:[[]]})},ui.scale.category10=function(){return ui.scale.ordinal().range(Cs)},ui.scale.category20=function(){return ui.scale.ordinal().range(Es)},ui.scale.category20b=function(){return ui.scale.ordinal().range(Os)},ui.scale.category20c=function(){return ui.scale.ordinal().range(Ps)};var Cs=[2062260,16744206,2924588,14034728,9725885,9197131,14907330,8355711,12369186,1556175].map(_t),Es=[2062260,11454440,16744206,16759672,2924588,10018698,14034728,16750742,9725885,12955861,9197131,12885140,14907330,16234194,8355711,13092807,12369186,14408589,1556175,10410725].map(_t),Os=[3750777,5395619,7040719,10264286,6519097,9216594,11915115,13556636,9202993,12426809,15186514,15190932,8666169,11356490,14049643,15177372,8077683,10834324,13528509,14589654].map(_t),Ps=[3244733,7057110,10406625,13032431,15095053,16616764,16625259,16634018,3253076,7652470,10607003,13101504,7695281,10394312,12369372,14342891,6513507,9868950,12434877,14277081].map(_t);ui.scale.quantile=function(){return co([],[])},ui.scale.quantize=function(){return uo(0,1,[0,1])},ui.scale.threshold=function(){return fo([.5],[0,1])},ui.scale.identity=function(){return ho([0,1])},ui.svg={},ui.svg.arc=function(){function t(){var t=Math.max(0,+n.apply(this,arguments)),c=Math.max(0,+r.apply(this,arguments)),u=i.apply(this,arguments)-Zi,f=l.apply(this,arguments)-Zi,d=Math.abs(f-u),h=u>f?0:1;if(t>c&&(p=c,c=t,t=p),d>=Vi)return e(c,h)+(t?e(t,1-h):"")+"Z";var p,g,m,v,y,x,b,_,w,k,M,A,T=0,L=0,z=[];if((v=(+s.apply(this,arguments)||0)/2)&&(m=o===Ns?Math.sqrt(t*t+c*c):+o.apply(this,arguments),h||(L*=-1),c&&(L=rt(m/c*Math.sin(v))),t&&(T=rt(m/t*Math.sin(v)))),c){y=c*Math.cos(u+L),x=c*Math.sin(u+L),b=c*Math.cos(f-L),_=c*Math.sin(f-L);var S=Math.abs(f-u-2*L)<=Bi?0:1;if(L&&bo(y,x,b,_)===h^S){var C=(u+f)/2;y=c*Math.cos(C),x=c*Math.sin(C),b=_=null}}else y=x=0;if(t){w=t*Math.cos(f-T),k=t*Math.sin(f-T),M=t*Math.cos(u+T),A=t*Math.sin(u+T);var E=Math.abs(u-f+2*T)<=Bi?0:1;if(T&&bo(w,k,M,A)===1-h^E){var O=(u+f)/2;w=t*Math.cos(O),k=t*Math.sin(O),M=A=null}}else w=k=0;if(d>Fi&&(p=Math.min(Math.abs(c-t)/2,+a.apply(this,arguments)))>.001){g=c>t^h?0:1;var P=p,N=p;if(Bi>d){var D=null==M?[w,k]:null==b?[y,x]:In([y,x],[M,A],[b,_],[w,k]),I=y-D[0],R=x-D[1],j=b-D[0],F=_-D[1],q=1/Math.sin(Math.acos((I*j+R*F)/(Math.sqrt(I*I+R*R)*Math.sqrt(j*j+F*F)))/2),B=Math.sqrt(D[0]*D[0]+D[1]*D[1]);N=Math.min(p,(t-B)/(q-1)),P=Math.min(p,(c-B)/(q+1))}if(null!=b){var H=_o(null==M?[w,k]:[M,A],[y,x],c,P,h),V=_o([b,_],[w,k],c,P,h);p===P?z.push("M",H[0],"A",P,",",P," 0 0,",g," ",H[1],"A",c,",",c," 0 ",1-h^bo(H[1][0],H[1][1],V[1][0],V[1][1]),",",h," ",V[1],"A",P,",",P," 0 0,",g," ",V[0]):z.push("M",H[0],"A",P,",",P," 0 1,",g," ",V[0])}else z.push("M",y,",",x);if(null!=M){var Z=_o([y,x],[M,A],t,-N,h),U=_o([w,k],null==b?[y,x]:[b,_],t,-N,h);p===N?z.push("L",U[0],"A",N,",",N," 0 0,",g," ",U[1],"A",t,",",t," 0 ",h^bo(U[1][0],U[1][1],Z[1][0],Z[1][1]),",",1-h," ",Z[1],"A",N,",",N," 0 0,",g," ",Z[0]):z.push("L",U[0],"A",N,",",N," 0 0,",g," ",Z[0])}else z.push("L",w,",",k)}else z.push("M",y,",",x),null!=b&&z.push("A",c,",",c," 0 ",S,",",h," ",b,",",_),z.push("L",w,",",k),null!=M&&z.push("A",t,",",t," 0 ",E,",",1-h," ",M,",",A);return z.push("Z"),z.join("")}function e(t,e){return"M0,"+t+"A"+t+","+t+" 0 1,"+e+" 0,"+-t+"A"+t+","+t+" 0 1,"+e+" 0,"+t}var n=go,r=mo,a=po,o=Ns,i=vo,l=yo,s=xo;return t.innerRadius=function(e){return arguments.length?(n=zt(e),t):n},t.outerRadius=function(e){return arguments.length?(r=zt(e),t):r},t.cornerRadius=function(e){return arguments.length?(a=zt(e),t):a},t.padRadius=function(e){return arguments.length?(o=e==Ns?Ns:zt(e),t):o},t.startAngle=function(e){return arguments.length?(i=zt(e),t):i},t.endAngle=function(e){return arguments.length?(l=zt(e),t):l},t.padAngle=function(e){return arguments.length?(s=zt(e),t):s},t.centroid=function(){var t=(+n.apply(this,arguments)+ +r.apply(this,arguments))/2,e=(+i.apply(this,arguments)+ +l.apply(this,arguments))/2-Zi;return[Math.cos(e)*t,Math.sin(e)*t]},t};var Ns="auto";ui.svg.line=function(){return wo(b)};var Ds=ui.map({linear:ko,"linear-closed":Mo,step:Ao,"step-before":To,"step-after":Lo,basis:Po,"basis-open":No,"basis-closed":Do,bundle:Io,cardinal:Co,"cardinal-open":zo,"cardinal-closed":So,monotone:Ho});Ds.forEach(function(t,e){e.key=t,e.closed=/-closed$/.test(t)});var Is=[0,2/3,1/3,0],Rs=[0,1/3,2/3,0],js=[0,1/6,2/3,1/6];ui.svg.line.radial=function(){var t=wo(Vo);return t.radius=t.x,delete t.x,t.angle=t.y,delete t.y,t},To.reverse=Lo,Lo.reverse=To,ui.svg.area=function(){return Zo(b)},ui.svg.area.radial=function(){var t=Zo(Vo);return t.radius=t.x,delete t.x,t.innerRadius=t.x0,delete t.x0,t.outerRadius=t.x1,delete t.x1,t.angle=t.y,delete t.y,t.startAngle=t.y0,delete t.y0,t.endAngle=t.y1,delete t.y1,t},ui.svg.chord=function(){function t(t,l){var s=e(this,o,t,l),c=e(this,i,t,l);return"M"+s.p0+r(s.r,s.p1,s.a1-s.a0)+(n(s,c)?a(s.r,s.p1,s.r,s.p0):a(s.r,s.p1,c.r,c.p0)+r(c.r,c.p1,c.a1-c.a0)+a(c.r,c.p1,s.r,s.p0))+"Z"}function e(t,e,n,r){var a=e.call(t,n,r),o=l.call(t,a,r),i=s.call(t,a,r)-Zi,u=c.call(t,a,r)-Zi;return{r:o,a0:i,a1:u,p0:[o*Math.cos(i),o*Math.sin(i)],p1:[o*Math.cos(u),o*Math.sin(u)]}}function n(t,e){return t.a0==e.a0&&t.a1==e.a1}function r(t,e,n){return"A"+t+","+t+" 0 "+ +(n>Bi)+",1 "+e}function a(t,e,n,r){return"Q 0,0 "+r}var o=_n,i=wn,l=Uo,s=vo,c=yo;return t.radius=function(e){return arguments.length?(l=zt(e),t):l},t.source=function(e){return arguments.length?(o=zt(e),t):o},t.target=function(e){return arguments.length?(i=zt(e),t):i},t.startAngle=function(e){return arguments.length?(s=zt(e),t):s},t.endAngle=function(e){return arguments.length?(c=zt(e),t):c},t},ui.svg.diagonal=function(){function t(t,a){var o=e.call(this,t,a),i=n.call(this,t,a),l=(o.y+i.y)/2,s=[o,{x:o.x,y:l},{x:i.x,y:l},i];return s=s.map(r),"M"+s[0]+"C"+s[1]+" "+s[2]+" "+s[3]}var e=_n,n=wn,r=Yo;return t.source=function(n){return arguments.length?(e=zt(n),t):e},t.target=function(e){return arguments.length?(n=zt(e),t):n},t.projection=function(e){return arguments.length?(r=e,t):r},t},ui.svg.diagonal.radial=function(){var t=ui.svg.diagonal(),e=Yo,n=t.projection;return t.projection=function(t){return arguments.length?n(Xo(e=t)):e},t},ui.svg.symbol=function(){function t(t,r){return(Fs.get(e.call(this,t,r))||Qo)(n.call(this,t,r))}var e=$o,n=Go;return t.type=function(n){return arguments.length?(e=zt(n),t):e},t.size=function(e){return arguments.length?(n=zt(e),t):n},t};var Fs=ui.map({circle:Qo,cross:function(t){var e=Math.sqrt(t/5)/2;return"M"+-3*e+","+-e+"H"+-e+"V"+-3*e+"H"+e+"V"+-e+"H"+3*e+"V"+e+"H"+e+"V"+3*e+"H"+-e+"V"+e+"H"+-3*e+"Z"},diamond:function(t){var e=Math.sqrt(t/(2*Bs)),n=e*Bs;return"M0,"+-e+"L"+n+",0 0,"+e+" "+-n+",0Z"},square:function(t){var e=Math.sqrt(t)/2;return"M"+-e+","+-e+"L"+e+","+-e+" "+e+","+e+" "+-e+","+e+"Z"},"triangle-down":function(t){var e=Math.sqrt(t/qs),n=e*qs/2;return"M0,"+n+"L"+e+","+-n+" "+-e+","+-n+"Z"},"triangle-up":function(t){var e=Math.sqrt(t/qs),n=e*qs/2;return"M0,"+-n+"L"+e+","+n+" "+-e+","+n+"Z"}});ui.svg.symbolTypes=Fs.keys();var qs=Math.sqrt(3),Bs=Math.tan(30*Ui);Ei.transition=function(t){for(var e,n,r=Hs||++Ys,a=ei(t),o=[],i=Vs||{time:Date.now(),ease:zr,delay:0,duration:250},l=-1,s=this.length;++lo;o++){a.push(e=[]);for(var n=this[o],l=0,s=n.length;s>l;l++)(r=n[l])&&t.call(r,r.__data__,l,o)&&e.push(r)}return Jo(a,this.namespace,this.id)},Us.tween=function(t,e){var n=this.id,r=this.namespace;return arguments.length<2?this.node()[r][n].tween.get(t):U(this,null==e?function(e){e[r][n].tween.remove(t)}:function(a){a[r][n].tween.set(t,e)})},Us.attr=function(t,e){function n(){this.removeAttribute(l)}function r(){this.removeAttributeNS(l.space,l.local)}function a(t){return null==t?n:(t+="",function(){var e,n=this.getAttribute(l);return n!==t&&(e=i(n,t),function(t){this.setAttribute(l,e(t))})})}function o(t){return null==t?r:(t+="",function(){var e,n=this.getAttributeNS(l.space,l.local);return n!==t&&(e=i(n,t),function(t){this.setAttributeNS(l.space,l.local,e(t))})})}if(arguments.length<2){for(e in t)this.attr(e,t[e]);return this}var i="transform"==t?$r:_r,l=ui.ns.qualify(t);return Ko(this,"attr."+t,e,l.local?o:a)},Us.attrTween=function(t,e){function n(t,n){var r=e.call(this,t,n,this.getAttribute(a));return r&&function(t){this.setAttribute(a,r(t))}}function r(t,n){var r=e.call(this,t,n,this.getAttributeNS(a.space,a.local));return r&&function(t){this.setAttributeNS(a.space,a.local,r(t))}}var a=ui.ns.qualify(t);return this.tween("attr."+t,a.local?r:n)},Us.style=function(t,e,n){function a(){this.style.removeProperty(t)}function o(e){return null==e?a:(e+="",function(){var a,o=r(this).getComputedStyle(this,null).getPropertyValue(t);return o!==e&&(a=_r(o,e),function(e){this.style.setProperty(t,a(e),n)})})}var i=arguments.length;if(3>i){if("string"!=typeof t){2>i&&(e="");for(n in t)this.style(n,t[n],e);return this}n=""}return Ko(this,"style."+t,e,o)},Us.styleTween=function(t,e,n){function a(a,o){var i=e.call(this,a,o,r(this).getComputedStyle(this,null).getPropertyValue(t));return i&&function(e){this.style.setProperty(t,i(e),n)}}return arguments.length<3&&(n=""),this.tween("style."+t,a)},Us.text=function(t){return Ko(this,"text",t,ti)},Us.remove=function(){var t=this.namespace;return this.each("end.transition",function(){var e;this[t].count<2&&(e=this.parentNode)&&e.removeChild(this)})},Us.ease=function(t){var e=this.id,n=this.namespace;return arguments.length<1?this.node()[n][e].ease:("function"!=typeof t&&(t=ui.ease.apply(ui,arguments)),U(this,function(r){r[n][e].ease=t}))},Us.delay=function(t){var e=this.id,n=this.namespace;return arguments.length<1?this.node()[n][e].delay:U(this,"function"==typeof t?function(r,a,o){r[n][e].delay=+t.call(r,r.__data__,a,o)}:(t=+t,function(r){r[n][e].delay=t}))},Us.duration=function(t){var e=this.id,n=this.namespace;return arguments.length<1?this.node()[n][e].duration:U(this,"function"==typeof t?function(r,a,o){r[n][e].duration=Math.max(1,t.call(r,r.__data__,a,o))}:(t=Math.max(1,t),function(r){r[n][e].duration=t}))},Us.each=function(t,e){var n=this.id,r=this.namespace;if(arguments.length<2){var a=Vs,o=Hs;try{Hs=n,U(this,function(e,a,o){Vs=e[r][n],t.call(e,e.__data__,a,o)})}finally{Vs=a,Hs=o}}else U(this,function(a){var o=a[r][n];(o.event||(o.event=ui.dispatch("start","end","interrupt"))).on(t,e)});return this},Us.transition=function(){for(var t,e,n,r,a=this.id,o=++Ys,i=this.namespace,l=[],s=0,c=this.length;c>s;s++){l.push(t=[]);for(var e=this[s],u=0,f=e.length;f>u;u++)(n=e[u])&&(r=n[i][a],ni(n,u,i,o,{time:r.time,ease:r.ease,delay:r.delay+r.duration,duration:r.duration})),t.push(n)}return Jo(l,i,o)},ui.svg.axis=function(){function t(t){t.each(function(){var t,c=ui.select(this),u=this.__chart__||n,f=this.__chart__=n.copy(),d=null==s?f.ticks?f.ticks.apply(f,l):f.domain():s,h=null==e?f.tickFormat?f.tickFormat.apply(f,l):b:e,p=c.selectAll(".tick").data(d,f),g=p.enter().insert("g",".domain").attr("class","tick").style("opacity",Fi),m=ui.transition(p.exit()).style("opacity",Fi).remove(),v=ui.transition(p.order()).style("opacity",1),y=Math.max(a,0)+i,x=Ya(f),_=c.selectAll(".domain").data([0]),w=(_.enter().append("path").attr("class","domain"), +-ui.transition(_));g.append("line"),g.append("text");var k,M,A,T,L=g.select("line"),z=v.select("line"),S=p.select("text").text(h),C=g.select("text"),E=v.select("text"),O="top"===r||"left"===r?-1:1;if("bottom"===r||"top"===r?(t=ri,k="x",A="y",M="x2",T="y2",S.attr("dy",0>O?"0em":".71em").style("text-anchor","middle"),w.attr("d","M"+x[0]+","+O*o+"V0H"+x[1]+"V"+O*o)):(t=ai,k="y",A="x",M="y2",T="x2",S.attr("dy",".32em").style("text-anchor",0>O?"end":"start"),w.attr("d","M"+O*o+","+x[0]+"H0V"+x[1]+"H"+O*o)),L.attr(T,O*a),C.attr(A,O*y),z.attr(M,0).attr(T,O*a),E.attr(k,0).attr(A,O*y),f.rangeBand){var P=f,N=P.rangeBand()/2;u=f=function(t){return P(t)+N}}else u.rangeBand?u=f:m.call(t,f,u);g.call(t,u,f),v.call(t,f,f)})}var e,n=ui.scale.linear(),r=Xs,a=6,o=6,i=3,l=[10],s=null;return t.scale=function(e){return arguments.length?(n=e,t):n},t.orient=function(e){return arguments.length?(r=e in Gs?e+"":Xs,t):r},t.ticks=function(){return arguments.length?(l=di(arguments),t):l},t.tickValues=function(e){return arguments.length?(s=e,t):s},t.tickFormat=function(n){return arguments.length?(e=n,t):e},t.tickSize=function(e){var n=arguments.length;return n?(a=+e,o=+arguments[n-1],t):a},t.innerTickSize=function(e){return arguments.length?(a=+e,t):a},t.outerTickSize=function(e){return arguments.length?(o=+e,t):o},t.tickPadding=function(e){return arguments.length?(i=+e,t):i},t.tickSubdivide=function(){return arguments.length&&t},t};var Xs="bottom",Gs={top:1,right:1,bottom:1,left:1};ui.svg.brush=function(){function t(r){r.each(function(){var r=ui.select(this).style("pointer-events","all").style("-webkit-tap-highlight-color","rgba(0,0,0,0)").on("mousedown.brush",o).on("touchstart.brush",o),i=r.selectAll(".background").data([0]);i.enter().append("rect").attr("class","background").style("visibility","hidden").style("cursor","crosshair"),r.selectAll(".extent").data([0]).enter().append("rect").attr("class","extent").style("cursor","move");var l=r.selectAll(".resize").data(g,b);l.exit().remove(),l.enter().append("g").attr("class",function(t){return"resize "+t}).style("cursor",function(t){return $s[t]}).append("rect").attr("x",function(t){return/[ew]$/.test(t)?-3:null}).attr("y",function(t){return/^[ns]/.test(t)?-3:null}).attr("width",6).attr("height",6).style("visibility","hidden"),l.style("display",t.empty()?"none":null);var s,f=ui.transition(r),d=ui.transition(i);c&&(s=Ya(c),d.attr("x",s[0]).attr("width",s[1]-s[0]),n(f)),u&&(s=Ya(u),d.attr("y",s[0]).attr("height",s[1]-s[0]),a(f)),e(f)})}function e(t){t.selectAll(".resize").attr("transform",function(t){return"translate("+f[+/e$/.test(t)]+","+d[+/^s/.test(t)]+")"})}function n(t){t.select(".extent").attr("x",f[0]),t.selectAll(".extent,.n>rect,.s>rect").attr("width",f[1]-f[0])}function a(t){t.select(".extent").attr("y",d[0]),t.selectAll(".extent,.e>rect,.w>rect").attr("height",d[1]-d[0])}function o(){function o(){32==ui.event.keyCode&&(S||(x=null,E[0]-=f[1],E[1]-=d[1],S=2),T())}function g(){32==ui.event.keyCode&&2==S&&(E[0]+=f[1],E[1]+=d[1],S=0,T())}function m(){var t=ui.mouse(_),r=!1;b&&(t[0]+=b[0],t[1]+=b[1]),S||(ui.event.altKey?(x||(x=[(f[0]+f[1])/2,(d[0]+d[1])/2]),E[0]=f[+(t[0]u?(a=r,r=u):a=u),g[0]!=r||g[1]!=a?(n?l=null:i=null,g[0]=r,g[1]=a,!0):void 0}function y(){m(),M.style("pointer-events","all").selectAll(".resize").style("display",t.empty()?"none":null),ui.select("body").style("cursor",null),O.on("mousemove.brush",null).on("mouseup.brush",null).on("touchmove.brush",null).on("touchend.brush",null).on("keydown.brush",null).on("keyup.brush",null),C(),k({type:"brushend"})}var x,b,_=this,w=ui.select(ui.event.target),k=s.of(_,arguments),M=ui.select(_),A=w.datum(),L=!/^(n|s)$/.test(A)&&c,z=!/^(e|w)$/.test(A)&&u,S=w.classed("extent"),C=W(_),E=ui.mouse(_),O=ui.select(r(_)).on("keydown.brush",o).on("keyup.brush",g);if(ui.event.changedTouches?O.on("touchmove.brush",m).on("touchend.brush",y):O.on("mousemove.brush",m).on("mouseup.brush",y),M.interrupt().selectAll("*").interrupt(),S)E[0]=f[0]-E[0],E[1]=d[0]-E[1];else if(A){var P=+/w$/.test(A),N=+/^n/.test(A);b=[f[1-P]-E[0],d[1-N]-E[1]],E[0]=f[P],E[1]=d[N]}else ui.event.altKey&&(x=E.slice());M.style("pointer-events","none").selectAll(".resize").style("display",null),ui.select("body").style("cursor",w.style("cursor")),k({type:"brushstart"}),m()}var i,l,s=z(t,"brushstart","brush","brushend"),c=null,u=null,f=[0,0],d=[0,0],h=!0,p=!0,g=Qs[0];return t.event=function(t){t.each(function(){var t=s.of(this,arguments),e={x:f,y:d,i:i,j:l},n=this.__chart__||e;this.__chart__=e,Hs?ui.select(this).transition().each("start.brush",function(){i=n.i,l=n.j,f=n.x,d=n.y,t({type:"brushstart"})}).tween("brush:brush",function(){var n=wr(f,e.x),r=wr(d,e.y);return i=l=null,function(a){f=e.x=n(a),d=e.y=r(a),t({type:"brush",mode:"resize"})}}).each("end.brush",function(){i=e.i,l=e.j,t({type:"brush",mode:"resize"}),t({type:"brushend"})}):(t({type:"brushstart"}),t({type:"brush",mode:"resize"}),t({type:"brushend"}))})},t.x=function(e){return arguments.length?(c=e,g=Qs[!c<<1|!u],t):c},t.y=function(e){return arguments.length?(u=e,g=Qs[!c<<1|!u],t):u},t.clamp=function(e){return arguments.length?(c&&u?(h=!!e[0],p=!!e[1]):c?h=!!e:u&&(p=!!e),t):c&&u?[h,p]:c?h:u?p:null},t.extent=function(e){var n,r,a,o,s;return arguments.length?(c&&(n=e[0],r=e[1],u&&(n=n[0],r=r[0]),i=[n,r],c.invert&&(n=c(n),r=c(r)),n>r&&(s=n,n=r,r=s),n==f[0]&&r==f[1]||(f=[n,r])),u&&(a=e[0],o=e[1],c&&(a=a[1],o=o[1]),l=[a,o],u.invert&&(a=u(a),o=u(o)),a>o&&(s=a,a=o,o=s),a==d[0]&&o==d[1]||(d=[a,o])),t):(c&&(i?(n=i[0],r=i[1]):(n=f[0],r=f[1],c.invert&&(n=c.invert(n),r=c.invert(r)),n>r&&(s=n,n=r,r=s))),u&&(l?(a=l[0],o=l[1]):(a=d[0],o=d[1],u.invert&&(a=u.invert(a),o=u.invert(o)),a>o&&(s=a,a=o,o=s))),c&&u?[[n,a],[r,o]]:c?[n,r]:u&&[a,o])},t.clear=function(){return t.empty()||(f=[0,0],d=[0,0],i=l=null),t},t.empty=function(){return!!c&&f[0]==f[1]||!!u&&d[0]==d[1]},ui.rebind(t,s,"on")};var $s={n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},Qs=[["n","e","s","w","nw","ne","se","sw"],["e","w"],["n","s"],[]],Ws=ml.format=wl.timeFormat,Js=Ws.utc,Ks=Js("%Y-%m-%dT%H:%M:%S.%LZ");Ws.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?oi:Ks,oi.parse=function(t){var e=new Date(t);return isNaN(e)?null:e},oi.toString=Ks.toString,ml.second=Ht(function(t){return new vl(1e3*Math.floor(t/1e3))},function(t,e){t.setTime(t.getTime()+1e3*Math.floor(e))},function(t){return t.getSeconds()}),ml.seconds=ml.second.range,ml.seconds.utc=ml.second.utc.range,ml.minute=Ht(function(t){return new vl(6e4*Math.floor(t/6e4))},function(t,e){t.setTime(t.getTime()+6e4*Math.floor(e))},function(t){return t.getMinutes()}),ml.minutes=ml.minute.range,ml.minutes.utc=ml.minute.utc.range,ml.hour=Ht(function(t){var e=t.getTimezoneOffset()/60;return new vl(36e5*(Math.floor(t/36e5-e)+e))},function(t,e){t.setTime(t.getTime()+36e5*Math.floor(e))},function(t){return t.getHours()}),ml.hours=ml.hour.range,ml.hours.utc=ml.hour.utc.range,ml.month=Ht(function(t){return t=ml.day(t),t.setDate(1),t},function(t,e){t.setMonth(t.getMonth()+e)},function(t){return t.getMonth()}),ml.months=ml.month.range,ml.months.utc=ml.month.utc.range;var tc=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],ec=[[ml.second,1],[ml.second,5],[ml.second,15],[ml.second,30],[ml.minute,1],[ml.minute,5],[ml.minute,15],[ml.minute,30],[ml.hour,1],[ml.hour,3],[ml.hour,6],[ml.hour,12],[ml.day,1],[ml.day,2],[ml.week,1],[ml.month,1],[ml.month,3],[ml.year,1]],nc=Ws.multi([[".%L",function(t){return t.getMilliseconds()}],[":%S",function(t){return t.getSeconds()}],["%I:%M",function(t){return t.getMinutes()}],["%I %p",function(t){return t.getHours()}],["%a %d",function(t){return t.getDay()&&1!=t.getDate()}],["%b %d",function(t){return 1!=t.getDate()}],["%B",function(t){return t.getMonth()}],["%Y",Ee]]),rc={range:function(t,e,n){return ui.range(Math.ceil(t/n)*n,+e,n).map(li)},floor:b,ceil:b};ec.year=ml.year,ml.scale=function(){return ii(ui.scale.linear(),ec,nc)};var ac=ec.map(function(t){return[t[0].utc,t[1]]}),oc=Js.multi([[".%L",function(t){return t.getUTCMilliseconds()}],[":%S",function(t){return t.getUTCSeconds()}],["%I:%M",function(t){return t.getUTCMinutes()}],["%I %p",function(t){return t.getUTCHours()}],["%a %d",function(t){return t.getUTCDay()&&1!=t.getUTCDate()}],["%b %d",function(t){return 1!=t.getUTCDate()}],["%B",function(t){return t.getUTCMonth()}],["%Y",Ee]]);ac.year=ml.year.utc,ml.scale.utc=function(){return ii(ui.scale.linear(),ac,oc)},ui.text=St(function(t){return t.responseText}),ui.json=function(t,e){return Ct(t,"application/json",si,e)},ui.html=function(t,e){return Ct(t,"text/html",ci,e)},ui.xml=St(function(t){return t.responseXML}),"function"==typeof t&&t.amd?(this.d3=ui,t(ui)):"object"==typeof n&&n.exports?n.exports=ui:this.d3=ui}()},{}],17:[function(e,n,r){(function(r,a){(function(){"use strict";function o(t){return"function"==typeof t||"object"==typeof t&&null!==t}function i(t){return"function"==typeof t}function l(t){Y=t}function s(t){Q=t}function c(){return function(){r.nextTick(p)}}function u(){return function(){U(p)}}function f(){var t=0,e=new K(p),n=document.createTextNode("");return e.observe(n,{characterData:!0}),function(){n.data=t=++t%2}}function d(){var t=new MessageChannel;return t.port1.onmessage=p,function(){t.port2.postMessage(0)}}function h(){return function(){setTimeout(p,1)}}function p(){for(var t=0;$>t;t+=2){var e=nt[t],n=nt[t+1];e(n),nt[t]=void 0,nt[t+1]=void 0}$=0}function g(){try{var t=e,n=t("vertx");return U=n.runOnLoop||n.runOnContext,u()}catch(r){return h()}}function m(t,e){var n=this,r=n._state;if(r===it&&!t||r===lt&&!e)return this;var a=new this.constructor(y),o=n._result;if(r){var i=arguments[r-1];Q(function(){N(r,a,i,o)})}else C(n,a,t,e);return a}function v(t){var e=this;if(t&&"object"==typeof t&&t.constructor===e)return t;var n=new e(y);return T(n,t),n}function y(){}function x(){return new TypeError("You cannot resolve a promise with itself")}function b(){return new TypeError("A promises callback cannot return that same promise.")}function _(t){try{return t.then}catch(e){return st.error=e,st}}function w(t,e,n,r){try{t.call(e,n,r)}catch(a){return a}}function k(t,e,n){Q(function(t){var r=!1,a=w(n,e,function(n){r||(r=!0,e!==n?T(t,n):z(t,n))},function(e){r||(r=!0,S(t,e))},"Settle: "+(t._label||" unknown promise"));!r&&a&&(r=!0,S(t,a))},t)}function M(t,e){e._state===it?z(t,e._result):e._state===lt?S(t,e._result):C(e,void 0,function(e){T(t,e)},function(e){S(t,e)})}function A(t,e,n){e.constructor===t.constructor&&n===rt&&constructor.resolve===at?M(t,e):n===st?S(t,st.error):void 0===n?z(t,e):i(n)?k(t,e,n):z(t,e)}function T(t,e){t===e?S(t,x()):o(e)?A(t,e,_(e)):z(t,e)}function L(t){t._onerror&&t._onerror(t._result),E(t)}function z(t,e){t._state===ot&&(t._result=e,t._state=it,0!==t._subscribers.length&&Q(E,t))}function S(t,e){t._state===ot&&(t._state=lt,t._result=e,Q(L,t))}function C(t,e,n,r){var a=t._subscribers,o=a.length;t._onerror=null,a[o]=e,a[o+it]=n,a[o+lt]=r,0===o&&t._state&&Q(E,t)}function E(t){var e=t._subscribers,n=t._state;if(0!==e.length){for(var r,a,o=t._result,i=0;ii;i++)C(r.resolve(t[i]),void 0,e,n);return a}function j(t){var e=this,n=new e(y);return S(n,t),n}function F(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function q(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function B(t){this._id=ht++,this._state=void 0,this._result=void 0,this._subscribers=[],y!==t&&("function"!=typeof t&&F(),this instanceof B?D(this,t):q())}function H(t,e){this._instanceConstructor=t,this.promise=new t(y),Array.isArray(e)?(this._input=e,this.length=e.length,this._remaining=e.length,this._result=new Array(this.length),0===this.length?z(this.promise,this._result):(this.length=this.length||0,this._enumerate(),0===this._remaining&&z(this.promise,this._result))):S(this.promise,this._validationError())}function V(){var t;if("undefined"!=typeof a)t=a;else if("undefined"!=typeof self)t=self;else try{t=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var n=t.Promise;n&&"[object Promise]"===Object.prototype.toString.call(n.resolve())&&!n.cast||(t.Promise=pt)}var Z;Z=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)};var U,Y,X,G=Z,$=0,Q=function(t,e){nt[$]=t,nt[$+1]=e,$+=2,2===$&&(Y?Y(p):X())},W="undefined"!=typeof window?window:void 0,J=W||{},K=J.MutationObserver||J.WebKitMutationObserver,tt="undefined"!=typeof r&&"[object process]"==={}.toString.call(r),et="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,nt=new Array(1e3);X=tt?c():K?f():et?d():void 0===W&&"function"==typeof e?g():h();var rt=m,at=v,ot=void 0,it=1,lt=2,st=new O,ct=new O,ut=I,ft=R,dt=j,ht=0,pt=B;B.all=ut,B.race=ft,B.resolve=at,B.reject=dt,B._setScheduler=l,B._setAsap=s,B._asap=Q,B.prototype={constructor:B,then:rt,"catch":function(t){return this.then(null,t)}};var gt=H;H.prototype._validationError=function(){return new Error("Array Methods must be provided an Array")},H.prototype._enumerate=function(){for(var t=this.length,e=this._input,n=0;this._state===ot&&t>n;n++)this._eachEntry(e[n],n)},H.prototype._eachEntry=function(t,e){var n=this._instanceConstructor,r=n.resolve;if(r===at){var a=_(t);if(a===rt&&t._state!==ot)this._settledAt(t._state,e,t._result);else if("function"!=typeof a)this._remaining--,this._result[e]=t;else if(n===pt){var o=new n(y);A(o,t,a),this._willSettleAt(o,e)}else this._willSettleAt(new n(function(e){e(t)}),e)}else this._willSettleAt(r(t),e)},H.prototype._settledAt=function(t,e,n){var r=this.promise;r._state===ot&&(this._remaining--,t===lt?S(r,n):this._result[e]=n),0===this._remaining&&z(r,this._result)},H.prototype._willSettleAt=function(t,e){var n=this;C(t,void 0,function(t){n._settledAt(it,e,t)},function(t){n._settledAt(lt,e,t)})};var mt=V,vt={Promise:pt,polyfill:mt};"function"==typeof t&&t.amd?t(function(){return vt}):"undefined"!=typeof n&&n.exports?n.exports=vt:"undefined"!=typeof this&&(this.ES6Promise=vt),mt()}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:15}],18:[function(t,e,n){"use strict";function r(t){for(var e,n=t.length,r=0;n>r;r++)if(e=t.charCodeAt(r),(9>e||e>13)&&32!==e&&133!==e&&160!==e&&5760!==e&&6158!==e&&(8192>e||e>8205)&&8232!==e&&8233!==e&&8239!==e&&8287!==e&&8288!==e&&12288!==e&&65279!==e)return!1;return!0}e.exports=function(t){var e=typeof t;if("string"===e){var n=t;if(t=+t,0===t&&r(n))return!1}else if("number"!==e)return!1;return 1>t-t}},{}],19:[function(t,e,n){function r(t,e){var n=e[0],r=e[1],a=e[2],o=e[3],i=n+n,l=r+r,s=a+a,c=n*i,u=r*i,f=r*l,d=a*i,h=a*l,p=a*s,g=o*i,m=o*l,v=o*s;return t[0]=1-f-p,t[1]=u+v,t[2]=d-m,t[3]=0,t[4]=u-v,t[5]=1-c-p,t[6]=h+g,t[7]=0,t[8]=d+m,t[9]=h-g,t[10]=1-c-f,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}e.exports=r},{}],20:[function(e,n,r){!function(){function e(t,n){if(t=t?t:"",n=n||{},t instanceof e)return t;if(!(this instanceof e))return new e(t,n);var a=r(t);this._originalInput=t,this._r=a.r,this._g=a.g,this._b=a.b,this._a=a.a,this._roundA=B(100*this._a)/100,this._format=n.format||a.format,this._gradientType=n.gradientType,this._r<1&&(this._r=B(this._r)),this._g<1&&(this._g=B(this._g)),this._b<1&&(this._b=B(this._b)),this._ok=a.ok,this._tc_id=F++}function r(t){var e={r:0,g:0,b:0},n=1,r=!1,o=!1;return"string"==typeof t&&(t=D(t)),"object"==typeof t&&(t.hasOwnProperty("r")&&t.hasOwnProperty("g")&&t.hasOwnProperty("b")?(e=a(t.r,t.g,t.b),r=!0,o="%"===String(t.r).substr(-1)?"prgb":"rgb"):t.hasOwnProperty("h")&&t.hasOwnProperty("s")&&t.hasOwnProperty("v")?(t.s=O(t.s),t.v=O(t.v),e=s(t.h,t.s,t.v),r=!0,o="hsv"):t.hasOwnProperty("h")&&t.hasOwnProperty("s")&&t.hasOwnProperty("l")&&(t.s=O(t.s),t.l=O(t.l),e=i(t.h,t.s,t.l),r=!0,o="hsl"),t.hasOwnProperty("a")&&(n=t.a)),n=A(n),{ok:r,format:t.format||o,r:H(255,V(e.r,0)),g:H(255,V(e.g,0)),b:H(255,V(e.b,0)),a:n}}function a(t,e,n){return{r:255*T(t,255),g:255*T(e,255),b:255*T(n,255)}}function o(t,e,n){t=T(t,255),e=T(e,255),n=T(n,255);var r,a,o=V(t,e,n),i=H(t,e,n),l=(o+i)/2;if(o==i)r=a=0;else{var s=o-i;switch(a=l>.5?s/(2-o-i):s/(o+i),o){case t:r=(e-n)/s+(n>e?6:0);break;case e:r=(n-t)/s+2;break;case n:r=(t-e)/s+4}r/=6}return{h:r,s:a,l:l}}function i(t,e,n){function r(t,e,n){return 0>n&&(n+=1),n>1&&(n-=1),1/6>n?t+6*(e-t)*n:.5>n?e:2/3>n?t+(e-t)*(2/3-n)*6:t}var a,o,i;if(t=T(t,360),e=T(e,100),n=T(n,100),0===e)a=o=i=n;else{var l=.5>n?n*(1+e):n+e-n*e,s=2*n-l;a=r(s,l,t+1/3),o=r(s,l,t),i=r(s,l,t-1/3)}return{r:255*a,g:255*o,b:255*i}}function l(t,e,n){t=T(t,255),e=T(e,255),n=T(n,255);var r,a,o=V(t,e,n),i=H(t,e,n),l=o,s=o-i;if(a=0===o?0:s/o,o==i)r=0;else{switch(o){case t:r=(e-n)/s+(n>e?6:0);break;case e:r=(n-t)/s+2;break;case n:r=(t-e)/s+4}r/=6}return{h:r,s:a,v:l}}function s(t,e,n){t=6*T(t,360),e=T(e,100),n=T(n,100);var r=q.floor(t),a=t-r,o=n*(1-e),i=n*(1-a*e),l=n*(1-(1-a)*e),s=r%6,c=[n,i,o,o,l,n][s],u=[l,n,n,i,o,o][s],f=[o,o,l,n,n,i][s];return{r:255*c,g:255*u,b:255*f}}function c(t,e,n,r){var a=[E(B(t).toString(16)),E(B(e).toString(16)),E(B(n).toString(16))];return r&&a[0].charAt(0)==a[0].charAt(1)&&a[1].charAt(0)==a[1].charAt(1)&&a[2].charAt(0)==a[2].charAt(1)?a[0].charAt(0)+a[1].charAt(0)+a[2].charAt(0):a.join("")}function u(t,e,n,r){var a=[E(P(r)),E(B(t).toString(16)),E(B(e).toString(16)),E(B(n).toString(16))];return a.join("")}function f(t,n){n=0===n?0:n||10;var r=e(t).toHsl();return r.s-=n/100,r.s=L(r.s),e(r)}function d(t,n){n=0===n?0:n||10;var r=e(t).toHsl();return r.s+=n/100,r.s=L(r.s),e(r)}function h(t){return e(t).desaturate(100)}function p(t,n){n=0===n?0:n||10;var r=e(t).toHsl();return r.l+=n/100,r.l=L(r.l),e(r)}function g(t,n){n=0===n?0:n||10;var r=e(t).toRgb();return r.r=V(0,H(255,r.r-B(255*-(n/100)))),r.g=V(0,H(255,r.g-B(255*-(n/100)))),r.b=V(0,H(255,r.b-B(255*-(n/100)))),e(r)}function m(t,n){n=0===n?0:n||10;var r=e(t).toHsl();return r.l-=n/100,r.l=L(r.l),e(r)}function v(t,n){var r=e(t).toHsl(),a=(B(r.h)+n)%360;return r.h=0>a?360+a:a,e(r)}function y(t){var n=e(t).toHsl();return n.h=(n.h+180)%360,e(n)}function x(t){var n=e(t).toHsl(),r=n.h;return[e(t),e({h:(r+120)%360,s:n.s,l:n.l}),e({h:(r+240)%360,s:n.s,l:n.l})]}function b(t){var n=e(t).toHsl(),r=n.h;return[e(t),e({h:(r+90)%360,s:n.s,l:n.l}),e({h:(r+180)%360,s:n.s,l:n.l}),e({h:(r+270)%360,s:n.s,l:n.l})]}function _(t){var n=e(t).toHsl(),r=n.h;return[e(t),e({h:(r+72)%360,s:n.s,l:n.l}),e({h:(r+216)%360,s:n.s,l:n.l})]}function w(t,n,r){n=n||6,r=r||30;var a=e(t).toHsl(),o=360/r,i=[e(t)];for(a.h=(a.h-(o*n>>1)+720)%360;--n;)a.h=(a.h+o)%360,i.push(e(a));return i}function k(t,n){n=n||6;for(var r=e(t).toHsv(),a=r.h,o=r.s,i=r.v,l=[],s=1/n;n--;)l.push(e({h:a,s:o,v:i})),i=(i+s)%1;return l}function M(t){var e={};for(var n in t)t.hasOwnProperty(n)&&(e[t[n]]=n);return e}function A(t){return t=parseFloat(t),(isNaN(t)||0>t||t>1)&&(t=1),t}function T(t,e){S(t)&&(t="100%");var n=C(t);return t=H(e,V(0,parseFloat(t))),n&&(t=parseInt(t*e,10)/100),q.abs(t-e)<1e-6?1:t%e/parseFloat(e)}function L(t){return H(1,V(0,t))}function z(t){return parseInt(t,16)}function S(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)}function C(t){return"string"==typeof t&&-1!=t.indexOf("%")}function E(t){return 1==t.length?"0"+t:""+t}function O(t){return 1>=t&&(t=100*t+"%"),t}function P(t){return Math.round(255*parseFloat(t)).toString(16)}function N(t){return z(t)/255}function D(t){t=t.replace(R,"").replace(j,"").toLowerCase();var e=!1;if(U[t])t=U[t],e=!0;else if("transparent"==t)return{r:0,g:0,b:0,a:0,format:"name"};var n;return(n=X.rgb.exec(t))?{r:n[1],g:n[2],b:n[3]}:(n=X.rgba.exec(t))?{r:n[1],g:n[2],b:n[3],a:n[4]}:(n=X.hsl.exec(t))?{h:n[1],s:n[2],l:n[3]}:(n=X.hsla.exec(t))?{h:n[1],s:n[2],l:n[3],a:n[4]}:(n=X.hsv.exec(t))?{h:n[1],s:n[2],v:n[3]}:(n=X.hsva.exec(t))?{h:n[1],s:n[2],v:n[3],a:n[4]}:(n=X.hex8.exec(t))?{a:N(n[1]),r:z(n[2]),g:z(n[3]),b:z(n[4]),format:e?"name":"hex8"}:(n=X.hex6.exec(t))?{r:z(n[1]),g:z(n[2]),b:z(n[3]),format:e?"name":"hex"}:(n=X.hex3.exec(t))?{r:z(n[1]+""+n[1]),g:z(n[2]+""+n[2]),b:z(n[3]+""+n[3]),format:e?"name":"hex"}:!1}function I(t){var e,n;return t=t||{level:"AA",size:"small"},e=(t.level||"AA").toUpperCase(),n=(t.size||"small").toLowerCase(),"AA"!==e&&"AAA"!==e&&(e="AA"),"small"!==n&&"large"!==n&&(n="small"),{level:e,size:n}}var R=/^\s+/,j=/\s+$/,F=0,q=Math,B=q.round,H=q.min,V=q.max,Z=q.random;e.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var t,e,n,r,a,o,i=this.toRgb();return t=i.r/255,e=i.g/255,n=i.b/255,r=.03928>=t?t/12.92:Math.pow((t+.055)/1.055,2.4),a=.03928>=e?e/12.92:Math.pow((e+.055)/1.055,2.4),o=.03928>=n?n/12.92:Math.pow((n+.055)/1.055,2.4),.2126*r+.7152*a+.0722*o},setAlpha:function(t){return this._a=A(t),this._roundA=B(100*this._a)/100,this},toHsv:function(){var t=l(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=l(this._r,this._g,this._b),e=B(360*t.h),n=B(100*t.s),r=B(100*t.v);return 1==this._a?"hsv("+e+", "+n+"%, "+r+"%)":"hsva("+e+", "+n+"%, "+r+"%, "+this._roundA+")"},toHsl:function(){var t=o(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=o(this._r,this._g,this._b),e=B(360*t.h),n=B(100*t.s),r=B(100*t.l);return 1==this._a?"hsl("+e+", "+n+"%, "+r+"%)":"hsla("+e+", "+n+"%, "+r+"%, "+this._roundA+")"},toHex:function(t){return c(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(){return u(this._r,this._g,this._b,this._a)},toHex8String:function(){return"#"+this.toHex8()},toRgb:function(){return{r:B(this._r),g:B(this._g),b:B(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+B(this._r)+", "+B(this._g)+", "+B(this._b)+")":"rgba("+B(this._r)+", "+B(this._g)+", "+B(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:B(100*T(this._r,255))+"%",g:B(100*T(this._g,255))+"%",b:B(100*T(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+B(100*T(this._r,255))+"%, "+B(100*T(this._g,255))+"%, "+B(100*T(this._b,255))+"%)":"rgba("+B(100*T(this._r,255))+"%, "+B(100*T(this._g,255))+"%, "+B(100*T(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":this._a<1?!1:Y[c(this._r,this._g,this._b,!0)]||!1},toFilter:function(t){var n="#"+u(this._r,this._g,this._b,this._a),r=n,a=this._gradientType?"GradientType = 1, ":"";if(t){var o=e(t);r=o.toHex8String()}return"progid:DXImageTransform.Microsoft.gradient("+a+"startColorstr="+n+",endColorstr="+r+")"},toString:function(t){var e=!!t;t=t||this._format;var n=!1,r=this._a<1&&this._a>=0,a=!e&&r&&("hex"===t||"hex6"===t||"hex3"===t||"name"===t);return a?"name"===t&&0===this._a?this.toName():this.toRgbString():("rgb"===t&&(n=this.toRgbString()),"prgb"===t&&(n=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(n=this.toHexString()),"hex3"===t&&(n=this.toHexString(!0)),"hex8"===t&&(n=this.toHex8String()),"name"===t&&(n=this.toName()),"hsl"===t&&(n=this.toHslString()),"hsv"===t&&(n=this.toHsvString()),n||this.toHexString())},clone:function(){return e(this.toString())},_applyModification:function(t,e){var n=t.apply(null,[this].concat([].slice.call(e)));return this._r=n._r,this._g=n._g,this._b=n._b,this.setAlpha(n._a),this},lighten:function(){return this._applyModification(p,arguments)},brighten:function(){return this._applyModification(g,arguments)},darken:function(){return this._applyModification(m,arguments)},desaturate:function(){return this._applyModification(f,arguments)},saturate:function(){return this._applyModification(d,arguments)},greyscale:function(){return this._applyModification(h,arguments)},spin:function(){return this._applyModification(v,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(w,arguments)},complement:function(){return this._applyCombination(y,arguments)},monochromatic:function(){return this._applyCombination(k,arguments)},splitcomplement:function(){return this._applyCombination(_,arguments)},triad:function(){return this._applyCombination(x,arguments)},tetrad:function(){return this._applyCombination(b,arguments)}},e.fromRatio=function(t,n){if("object"==typeof t){var r={};for(var a in t)t.hasOwnProperty(a)&&("a"===a?r[a]=t[a]:r[a]=O(t[a]));t=r}return e(t,n)},e.equals=function(t,n){return t&&n?e(t).toRgbString()==e(n).toRgbString():!1},e.random=function(){return e.fromRatio({r:Z(),g:Z(),b:Z()})},e.mix=function(t,n,r){r=0===r?0:r||50;var a,o=e(t).toRgb(),i=e(n).toRgb(),l=r/100,s=2*l-1,c=i.a-o.a;a=s*c==-1?s:(s+c)/(1+s*c),a=(a+1)/2;var u=1-a,f={r:i.r*a+o.r*u,g:i.g*a+o.g*u,b:i.b*a+o.b*u,a:i.a*l+o.a*(1-l)};return e(f)},e.readability=function(t,n){var r=e(t),a=e(n);return(Math.max(r.getLuminance(),a.getLuminance())+.05)/(Math.min(r.getLuminance(),a.getLuminance())+.05)},e.isReadable=function(t,n,r){var a,o,i=e.readability(t,n);switch(o=!1,a=I(r),a.level+a.size){case"AAsmall":case"AAAlarge":o=i>=4.5;break;case"AAlarge":o=i>=3;break;case"AAAsmall":o=i>=7}return o},e.mostReadable=function(t,n,r){var a,o,i,l,s=null,c=0;r=r||{},o=r.includeFallbackColors,i=r.level,l=r.size;for(var u=0;uc&&(c=a,s=e(n[u]));return e.isReadable(t,s,{level:i,size:l})||!o?s:(r.includeFallbackColors=!1,e.mostReadable(t,["#fff","#000"],r))};var U=e.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},Y=e.hexNames=M(U),X=function(){var t="[-\\+]?\\d+%?",e="[-\\+]?\\d*\\.\\d+%?",n="(?:"+e+")|(?:"+t+")",r="[\\s|\\(]+("+n+")[,|\\s]+("+n+")[,|\\s]+("+n+")\\s*\\)?",a="[\\s|\\(]+("+n+")[,|\\s]+("+n+")[,|\\s]+("+n+")[,|\\s]+("+n+")\\s*\\)?";return{rgb:new RegExp("rgb"+r),rgba:new RegExp("rgba"+a),hsl:new RegExp("hsl"+r),hsla:new RegExp("hsla"+a),hsv:new RegExp("hsv"+r),hsva:new RegExp("hsva"+a),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();"undefined"!=typeof n&&n.exports?n.exports=e:"function"==typeof t&&t.amd?t(function(){return e}):window.tinycolor=e}()},{}],21:[function(t,e,n){"use strict";e.exports=["",{path:"M-2.4,-3V3L0.6,0Z",backoff:.6},{path:"M-3.7,-2.5V2.5L1.3,0Z",backoff:1.3},{path:"M-4.45,-3L-1.65,-0.2V0.2L-4.45,3L1.55,0Z",backoff:1.55},{path:"M-2.2,-2.2L-0.2,-0.2V0.2L-2.2,2.2L-1.4,3L1.6,0L-1.4,-3Z",backoff:1.6},{path:"M-4.4,-2.1L-0.6,-0.2V0.2L-4.4,2.1L-4,3L2,0L-4,-3Z",backoff:2},{path:"M2,0A2,2 0 1,1 0,-2A2,2 0 0,1 2,0Z",backoff:0},{path:"M2,2V-2H-2V2Z",backoff:0}]},{}],22:[function(t,e,n){"use strict";var r=t("./arrow_paths"),a=t("../../plots/font_attributes"),o=t("../../plots/cartesian/constants"),i=t("../../lib/extend").extendFlat;e.exports={_isLinkedToArray:!0,text:{valType:"string"},textangle:{valType:"angle",dflt:0},font:i({},a,{}),opacity:{valType:"number",min:0,max:1,dflt:1},align:{valType:"enumerated",values:["left","center","right"],dflt:"center"},bgcolor:{valType:"color",dflt:"rgba(0,0,0,0)"},bordercolor:{valType:"color",dflt:"rgba(0,0,0,0)"},borderpad:{valType:"number",min:0,dflt:1},borderwidth:{valType:"number",min:0,dflt:1},showarrow:{valType:"boolean",dflt:!0},arrowcolor:{valType:"color"},arrowhead:{valType:"integer",min:0,max:r.length,dflt:1},arrowsize:{valType:"number",min:.3,dflt:1},arrowwidth:{valType:"number",min:.1},ax:{valType:"number",dflt:-10},ay:{valType:"number",dflt:-30},axref:{valType:"enumerated",dflt:"pixel",values:["pixel",o.idRegex.x.toString()]},ayref:{valType:"enumerated",dflt:"pixel",values:["pixel",o.idRegex.y.toString()]},xref:{valType:"enumerated",values:["paper",o.idRegex.x.toString()]},x:{valType:"number"},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"auto"}, +-yref:{valType:"enumerated",values:["paper",o.idRegex.y.toString()]},y:{valType:"number"},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto"},_deprecated:{ref:{valType:"string"}}}},{"../../lib/extend":100,"../../plots/cartesian/constants":128,"../../plots/font_attributes":141,"./arrow_paths":21}],23:[function(t,e,n){"use strict";function r(t,e){function n(e,n){return c.coerce(t,r,m.layoutAttributes,e,n)}var r={};n("opacity"),n("align"),n("bgcolor");var a=n("bordercolor"),o=f.opacity(a);n("borderpad");var i=n("borderwidth"),l=n("showarrow");l&&(n("arrowcolor",o?r.bordercolor:f.defaultLine),n("arrowhead"),n("arrowsize"),n("arrowwidth",2*(o&&i||1)),n("ax"),n("ay"),n("axref"),n("ayref"),c.noneOrAll(t,r,["ax","ay"])),n("text",l?" ":"new text"),n("textangle"),c.coerceFont(n,"font",e.font);for(var s=["x","y"],d=0;2>d;d++){var h=s[d],p={_fullLayout:e},g=u.coerceRef(t,r,p,h),v=u.coerceARef(t,r,p,h),y=.5;if("paper"!==g){var x=u.getFromId(p,g);if(y=x.range[0]+y*(x.range[1]-x.range[0]),-1!==["date","category"].indexOf(x.type)&&"string"==typeof t[h]){var b;if("date"===x.type){if(b=c.dateTime2ms(t[h]),b!==!1&&(t[h]=b),v===g){var _=c.dateTime2ms(t["a"+h]);_!==!1&&(t["a"+h]=_)}}else(x._categories||[]).length&&(b=x._categories.indexOf(t[h]),-1!==b&&(t[h]=b))}}n(h,y),l||n(h+"anchor")}return c.noneOrAll(t,r,["x","y"]),r}function a(t){var e=t._fullLayout;e.annotations.forEach(function(e){var n=u.getFromId(t,e.xref),r=u.getFromId(t,e.yref);if(n||r){var a=(e._xsize||0)/2,o=e._xshift||0,i=(e._ysize||0)/2,l=e._yshift||0,s=a-o,c=a+o,f=i-l,d=i+l;if(e.showarrow){var h=3*e.arrowsize*e.arrowwidth;s=Math.max(s,h),c=Math.max(c,h),f=Math.max(f,h),d=Math.max(d,h)}n&&n.autorange&&u.expand(n,[n.l2c(e.x)],{ppadplus:c,ppadminus:s}),r&&r.autorange&&u.expand(r,[r.l2c(e.y)],{ppadplus:d,ppadminus:f})}})}function o(t,e,n,r,a,o,i,l){var s=n-t,c=a-t,u=i-a,f=r-e,d=o-e,h=l-o,p=s*h-u*f;if(0===p)return null;var g=(c*h-u*d)/p,m=(c*f-s*d)/p;return 0>m||m>1||0>g||g>1?null:{x:t+s*g,y:e+f*g}}var i=t("d3"),l=t("fast-isnumeric"),s=t("../../plotly"),c=t("../../lib"),u=t("../../plots/cartesian/axes"),f=t("../color"),d=t("../drawing"),h=t("../../lib/svg_text_utils"),p=t("../../lib/setcursor"),g=t("../dragelement"),m=e.exports={};m.ARROWPATHS=t("./arrow_paths"),m.layoutAttributes=t("./attributes"),m.supplyLayoutDefaults=function(t,e){for(var n=t.annotations||[],a=e.annotations=[],o=0;ot?"left":t>2/3?"right":"center"),{center:0,middle:0,left:.5,bottom:-.5,right:-.5,top:.5}[e]}tt.selectAll("tspan.line").attr({y:0,x:0});var r=G.select(".annotation-math-group"),a=!r.empty(),l=d.bBox((a?r:tt).node()),h=l.width,v=l.height,y=Math.round(h+2*W),x=Math.round(v+2*W);B._w=h,B._h=v;var b=!1;if(["x","y"].forEach(function(e){var r,a=B[e+"ref"]||e,o=u.getFromId(t,a),i=(U+("x"===e?0:90))*Math.PI/180,l=y*Math.abs(Math.cos(i))+x*Math.abs(Math.sin(i)),s=B[e+"anchor"];if(o){if(!o.autorange&&(B[e]-o.range[0])*(B[e]-o.range[1])>0&&(B["a"+e+"ref"]===a?(B["a"+e]-o.range[0])*(B["a"+e]-o.range[1])>0&&(b=!0):b=!0,b))return;Z[e]=o._offset+o.l2p(B[e]),r=.5}else r=B[e],"y"===e&&(r=1-r),Z[e]="x"===e?S.l+S.w*r:S.t+S.h*r;var c=0;B["a"+e+"ref"]===a?Z["aa"+e]=o._offset+o.l2p(B["a"+e]):(c=B.showarrow?B["a"+e]:l*n(r,s),Z[e]+=c),B["_"+e+"type"]=o&&o.type,B["_"+e+"size"]=l,B["_"+e+"shift"]=c}),b)return void G.remove();var w,k;B.showarrow&&(w=B.axref===B.xref?Z.x:c.constrain(Z.x-B.ax,1,_.width-1),k=B.ayref===B.yref?Z.y:c.constrain(Z.y-B.ay,1,_.height-1)),Z.x=c.constrain(Z.x,1,_.width-1),Z.y=c.constrain(Z.y,1,_.height-1);var M=W-l.top,A=W-l.left;a?r.select("svg").attr({x:W-1,y:W}):(tt.attr({x:A,y:M}),tt.selectAll("tspan.line").attr({y:M,x:A})),J.call(d.setRect,$/2,$/2,y-$,x-$);var T=0,L=0;T=B.axref===B.xref?Math.round(Z.aax-y/2):Math.round(Z.x-y/2),L=B.ayref===B.yref?Math.round(Z.aay-x/2):Math.round(Z.y-x/2),G.call(c.setTranslate,T,L);var z="annotations["+e+"]",C=function(n,r){i.select(t).selectAll('.annotation-arrow-g[data-index="'+e+'"]').remove();var a,l;a=B.axref===B.xref?Z.aax+n:Z.x+n,l=B.ayref===B.yref?Z.aay+r:Z.y+r;var u=c.rotationXYMatrix(U,a,l),d=c.apply2DTransform(u),h=c.apply2DTransform2(u),p=J.attr("width")/2,v=J.attr("height")/2,y=[[a-p,l-v,a-p,l+v],[a-p,l+v,a+p,l+v],[a+p,l+v,a+p,l-v],[a+p,l-v,a-p,l-v]].map(h);if(!y.reduce(function(t,e){return t^!!o(w,k,w+1e6,k+1e6,e[0],e[1],e[2],e[3])},!1)){y.forEach(function(t){var e=o(a,l,w,k,t[0],t[1],t[2],t[3]);e&&(a=e.x,l=e.y)});var x=B.arrowwidth,b=B.arrowcolor,_=Y.append("g").style({opacity:f.opacity(b)}).classed("annotation-arrow-g",!0).attr("data-index",String(e)),M=_.append("path").attr("d","M"+a+","+l+"L"+w+","+k).style("stroke-width",x+"px").call(f.stroke,f.rgb(b));m.arrowhead(M,B.arrowhead,"end",B.arrowsize);var A=_.append("path").classed("annotation",!0).classed("anndrag",!0).attr({"data-index":String(e),d:"M3,3H-3V-3H3ZM0,0L"+(a-w)+","+(l-k),transform:"translate("+w+","+k+")"}).style("stroke-width",x+6+"px").call(f.stroke,"rgba(0,0,0,0)").call(f.fill,"rgba(0,0,0,0)");if(t._context.editable){var T,L,C;g.init({element:A.node(),prepFn:function(){var t=c.getTranslate(G);L=t.x,C=t.y,T={},H&&H.autorange&&(T[H._name+".autorange"]=!0),V&&V.autorange&&(T[V._name+".autorange"]=!0)},moveFn:function(t,e){_.attr("transform","translate("+t+","+e+")");var n=d(L,C),r=n[0]+t,a=n[1]+e;G.call(c.setTranslate,r,a),T[z+".x"]=H?B.x+t/H._m:(w+t-S.l)/S.w,T[z+".y"]=V?B.y+e/V._m:1-(k+e-S.t)/S.h,B.axref===B.xref&&(T[z+".ax"]=H?B.ax+t/H._m:(w+t-S.l)/S.w),B.ayref===B.yref&&(T[z+".ay"]=V?B.ay+e/V._m:1-(k+e-S.t)/S.h),X.attr({transform:"rotate("+U+","+r+","+a+")"})},doneFn:function(e){if(e){s.relayout(t,T);var n=document.querySelector(".js-notes-box-panel");n&&n.redraw(n.selectedObj)}}})}}};B.showarrow&&C(0,0);var E=c.rotationXYMatrix(U,Z.x,Z.y),O=c.apply2DTransform(E);if(t._context.editable){var P,N,D;g.init({element:G.node(),prepFn:function(){var t=c.getTranslate(G);P=t.x,N=t.y,D={}},moveFn:function(t,e){G.call(c.setTranslate,P+t,N+e);var n="pointer";if(B.showarrow)B.axref===B.xref?D[z+".ax"]=H.p2l(H.l2p(B.ax)+t):D[z+".ax"]=B.ax+t,B.ayref===B.yref?D[z+".ay"]=V.p2l(V.l2p(B.ay)+e):D[z+".ay"]=B.ay+e,C(t,e);else{if(H)D[z+".x"]=B.x+t/H._m;else{var r=B._xsize/S.w,a=B.x+B._xshift/S.w-r/2;D[z+".x"]=g.align(a+t/S.w,r,0,1,B.xanchor)}if(V)D[z+".y"]=B.y+e/V._m;else{var o=B._ysize/S.h,i=B.y-B._yshift/S.h-o/2;D[z+".y"]=g.align(i-e/S.h,o,0,1,B.yanchor)}H&&V||(n=g.getCursor(H?.5:D[z+".x"],V?.5:D[z+".y"],B.xanchor,B.yanchor))}var l=O(P,N),s=l[0]+t,u=l[1]+e;G.call(c.setTranslate,P+t,N+e),X.attr({transform:"rotate("+U+","+s+","+u+")"}),p(G,n)},doneFn:function(e){if(p(G),e){s.relayout(t,D);var n=document.querySelector(".js-notes-box-panel");n&&n.redraw(n.selectedObj)}}})}}var x,b=t.layout,_=t._fullLayout;if(!l(e)||-1===e){if(!e&&Array.isArray(a))return b.annotations=a,m.supplyLayoutDefaults(b,_),void m.drawAll(t);if("remove"===a)return delete b.annotations,_.annotations=[],void m.drawAll(t);if(n&&"add"!==a){for(x=0;x<_.annotations.length;x++)m.draw(t,x,n,a);return}e=_.annotations.length,_.annotations.push({})}if(!n&&a){if("remove"===a){for(_._infolayer.selectAll('.annotation[data-index="'+e+'"]').remove(),_.annotations.splice(e,1),b.annotations.splice(e,1),x=e;x<_.annotations.length;x++)_._infolayer.selectAll('.annotation[data-index="'+(x+1)+'"]').attr("data-index",String(x)),m.draw(t,x);return}if("add"===a||c.isPlainObject(a)){_.annotations.splice(e,0,{});var w=c.isPlainObject(a)?c.extendFlat({},a):{text:"New text"};for(b.annotations?b.annotations.splice(e,0,w):b.annotations=[w],x=_.annotations.length-1;x>e;x--)_._infolayer.selectAll('.annotation[data-index="'+(x-1)+'"]').attr("data-index",String(x)),m.draw(t,x)}}_._infolayer.selectAll('.annotation[data-index="'+e+'"]').remove();var k=b.annotations[e],M=_.annotations[e];if(k){var A={xref:k.xref,yref:k.yref},T={};"string"==typeof n&&n?T[n]=a:c.isPlainObject(n)&&(T=n);var L=Object.keys(T);for(x=0;xx;x++){var E=C[x];if(void 0===T[E]&&void 0!==k[E]){var O=u.getFromId(t,u.coerceRef(A,{},t,E)),P=u.getFromId(t,u.coerceRef(k,{},t,E)),N=k[E],D=M["_"+E+"type"];if(void 0!==T[E+"ref"]){var I="auto"===k[E+"anchor"],R="x"===E?S.w:S.h,j=(M["_"+E+"size"]||0)/(2*R);if(O&&P)N=(N-O.range[0])/(O.range[1]-O.range[0]),N=P.range[0]+N*(P.range[1]-P.range[0]);else if(O){if(N=(N-O.range[0])/(O.range[1]-O.range[0]),N=O.domain[0]+N*(O.domain[1]-O.domain[0]),I){var F=N+j,q=N-j;2/3>N+q?N=q:N+F>4/3&&(N=F)}}else P&&(I&&(1/3>N?N+=j:N>2/3&&(N-=j)),N=(N-P.domain[0])/(P.domain[1]-P.domain[0]),N=P.range[0]+N*(P.range[1]-P.range[0]))}P&&P===O&&D&&("log"===D&&"log"!==P.type?N=Math.pow(10,N):"log"!==D&&"log"===P.type&&(N=N>0?Math.log(N)/Math.LN10:void 0)),k[E]=N}}var B=r(k,_);_.annotations[e]=B;var H=u.getFromId(t,B.xref),V=u.getFromId(t,B.yref),Z={x:0,y:0},U=+B.textangle||0,Y=_._infolayer.append("g").classed("annotation",!0).attr("data-index",String(e)).style("opacity",B.opacity).on("click",function(){t._dragging=!1,t.emit("plotly_clickannotation",{index:e,annotation:k,fullAnnotation:B})}),X=Y.append("g").classed("annotation-text-g",!0).attr("data-index",String(e)),G=X.append("g"),$=B.borderwidth,Q=B.borderpad,W=$+Q,J=G.append("rect").attr("class","bg").style("stroke-width",$+"px").call(f.stroke,B.bordercolor).call(f.fill,B.bgcolor),K=B.font,tt=G.append("text").classed("annotation",!0).attr("data-unformatted",B.text).text(B.text);t._context.editable?tt.call(h.makeEditable,G).call(v).on("edit",function(n){B.text=n,this.attr({"data-unformatted":B.text}),this.call(v);var r={};r["annotations["+e+"].text"]=B.text,H&&H.autorange&&(r[H._name+".autorange"]=!0),V&&V.autorange&&(r[V._name+".autorange"]=!0),s.relayout(t,r)}):tt.call(v),X.attr({transform:"rotate("+U+","+Z.x+","+Z.y+")"}).call(d.setPosition,Z.x,Z.y)}},m.arrowhead=function(t,e,n,r){l(r)||(r=1);var a=t.node(),o=m.ARROWPATHS[e||0];if(o){"string"==typeof n&&n||(n="end");var s,c,u,h,p=(d.getPx(t,"stroke-width")||1)*r,g=t.style("stroke")||f.defaultLine,v=t.style("stroke-opacity")||1,y=n.indexOf("start")>=0,x=n.indexOf("end")>=0,b=o.backoff*p;if("line"===a.nodeName){if(s={x:+t.attr("x1"),y:+t.attr("y1")},c={x:+t.attr("x2"),y:+t.attr("y2")},u=Math.atan2(s.y-c.y,s.x-c.x),h=u+Math.PI,b){var _=b*Math.cos(u),w=b*Math.sin(u);y&&(s.x-=_,s.y-=w,t.attr({x1:s.x,y1:s.y})),x&&(c.x+=_,c.y+=w,t.attr({x2:c.x,y2:c.y}))}}else if("path"===a.nodeName){var k=a.getTotalLength(),M="";if(y){var A=a.getPointAtLength(0),T=a.getPointAtLength(.1);u=Math.atan2(A.y-T.y,A.x-T.x),s=a.getPointAtLength(Math.min(b,k)),b&&(M="0px,"+b+"px,")}if(x){var L=a.getPointAtLength(k),z=a.getPointAtLength(k-.1);if(h=Math.atan2(L.y-z.y,L.x-z.x),c=a.getPointAtLength(Math.max(0,k-b)),b){var S=M?2*b:b;M+=k-S+"px,"+k+"px"}}else M&&(M+=k+"px");M&&t.style("stroke-dasharray",M)}var C=function(n,r){e>5&&(r=0),i.select(a.parentElement).append("path").attr({"class":t.attr("class"),d:o.path,transform:"translate("+n.x+","+n.y+")rotate("+180*r/Math.PI+")scale("+p+")"}).style({fill:g,opacity:v,"stroke-width":0})};y&&C(s,u),x&&C(c,h)}},m.calcAutorange=function(t){var e=t._fullLayout,n=e.annotations;if(n.length&&t._fullData.length){var r={};n.forEach(function(t){r[t.xref]=!0,r[t.yref]=!0});var o=u.list(t).filter(function(t){return t.autorange&&r[t._id]});if(o.length)return c.syncOrAsync([m.drawAll,a],t)}}},{"../../lib":102,"../../lib/setcursor":111,"../../lib/svg_text_utils":113,"../../plotly":120,"../../plots/cartesian/axes":123,"../color":25,"../dragelement":46,"../drawing":48,"./arrow_paths":21,"./attributes":22,d3:16,"fast-isnumeric":18}],24:[function(t,e,n){"use strict";n.defaults=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],n.defaultLine="#444",n.lightLine="#eee",n.background="#fff",n.borderLine="#BEC8D9",n.lightFraction=1e3/11},{}],25:[function(t,e,n){"use strict";function r(t){if(o(t)||"string"!=typeof t)return t;var e=t.trim();if("rgb"!==e.substr(0,3))return t;var n=e.match(/^rgba?\s*\(([^()]*)\)$/);if(!n)return t;var r=n[1].trim().split(/\s*[\s,]\s*/),a="a"===e.charAt(3)&&4===r.length;if(!a&&3!==r.length)return t;for(var i=0;i=0))return t;if(3===i)r[i]>1&&(r[i]=1);else if(r[i]>=1)return t}var l=Math.round(255*r[0])+", "+Math.round(255*r[1])+", "+Math.round(255*r[2]);return a?"rgba("+l+", "+r[3]+")":"rgb("+l+")"}var a=t("tinycolor2"),o=t("fast-isnumeric"),i=e.exports={},l=t("./attributes");i.defaults=l.defaults,i.defaultLine=l.defaultLine,i.lightLine=l.lightLine,i.background=l.background,i.tinyRGB=function(t){var e=t.toRgb();return"rgb("+Math.round(e.r)+", "+Math.round(e.g)+", "+Math.round(e.b)+")"},i.rgb=function(t){return i.tinyRGB(a(t))},i.opacity=function(t){return t?a(t).getAlpha():0},i.addOpacity=function(t,e){var n=a(t).toRgb();return"rgba("+Math.round(n.r)+", "+Math.round(n.g)+", "+Math.round(n.b)+", "+e+")"},i.combine=function(t,e){var n=a(t).toRgb();if(1===n.a)return a(t).toRgbString();var r=a(e||i.background).toRgb(),o=1===r.a?r:{r:255*(1-r.a)+r.r*r.a,g:255*(1-r.a)+r.g*r.a,b:255*(1-r.a)+r.b*r.a},l={r:o.r*(1-n.a)+n.r*n.a,g:o.g*(1-n.a)+n.g*n.a,b:o.b*(1-n.a)+n.b*n.a};return a(l).toRgbString()},i.contrast=function(t,e,n){var r=a(t),o=r.isLight()?r.darken(n):r.lighten(e);return o.toString()},i.stroke=function(t,e){var n=a(e);t.style({stroke:i.tinyRGB(n),"stroke-opacity":n.getAlpha()})},i.fill=function(t,e){var n=a(e);t.style({fill:i.tinyRGB(n),"fill-opacity":n.getAlpha()})},i.clean=function(t){if(t&&"object"==typeof t){var e,n,a,o,l=Object.keys(t);for(e=0;es&&(o[1]-=(it-s)/2)):n.node()&&!n.classed("js-placeholder")&&(it=d.bBox(e.node()).height),it){if(it+=5,"top"===b.titleside)J.domain[1]-=it/A.h,o[1]*=-1;else{J.domain[0]+=it/A.h;var u=Math.max(1,n.selectAll("tspan.line").size());o[1]+=(1-u)*s}e.attr("transform","translate("+o+")"),J.setScale()}}at.selectAll(".cbfills,.cblines,.cbaxis").attr("transform","translate(0,"+Math.round(A.h*(1-J.domain[1]))+")");var f=at.select(".cbfills").selectAll("rect.cbfill").data(S);f.enter().append("rect").classed("cbfill",!0).style("stroke","none"),f.exit().remove(),f.each(function(t,e){var n=[0===e?L[0]:(S[e]+S[e-1])/2,e===S.length-1?L[1]:(S[e]+S[e+1])/2].map(J.c2p).map(Math.round);e!==S.length-1&&(n[1]+=n[1]>n[0]?1:-1);var o=E(t).replace("e-",""),i=a(o).toHexString();r.select(this).attr({x:Y,width:Math.max(F,2),y:r.min(n),height:Math.max(r.max(n)-r.min(n),2),fill:i})});var h=at.select(".cblines").selectAll("path.cbline").data(b.line.color&&b.line.width?z:[]);return h.enter().append("path").classed("cbline",!0),h.exit().remove(),h.each(function(t){r.select(this).attr("d","M"+Y+","+(Math.round(J.c2p(t))+b.line.width/2%1)+"h"+F).call(d.lineGroupStyle,b.line.width,C(t),b.line.dash)}),J._axislayer.selectAll("g."+J._id+"tick,path").remove(),J._pos=Y+F+(b.outlinewidth||0)/2-("outside"===b.ticks?1:0),J.side="right",c.syncOrAsync([function(){return l.doTicks(t,J,!0)},function(){if(-1===["top","bottom"].indexOf(b.titleside)){var e=J.titlefont.size,n=J._offset+J._length/2,a=A.l+(J.position||0)*A.w+("right"===J.side?10+e*(J.showticklabels?1:.5):-10-e*(J.showticklabels?.5:0));w("h"+J._id+"title",{avoid:{selection:r.select(t).selectAll("g."+J._id+"tick"),side:b.titleside,offsetLeft:A.l,offsetTop:A.t,maxShift:M.width},attributes:{x:a,y:n,"text-anchor":"middle"},transform:{rotate:"-90",offset:0}})}}])}function w(e,n){var r,a=x();r=i.traceIs(a,"markerColorscale")?"marker.colorbar.title":"colorbar.title";var o={propContainer:J,propName:r,traceIndex:a.index,dfltName:"colorscale",containerGroup:at.select(".cbtitle")},l="h"===e.charAt(0)?e.substr(1):"h"+e;at.selectAll("."+l+",."+l+"-math-group").remove(),p.draw(t,e,u(o,n||{}))}function k(){var n=F+b.outlinewidth/2+d.bBox(J._axislayer.node()).width;if(I=ot.select("text"),I.node()&&!I.classed("js-placeholder")){var r,a=ot.select(".h"+J._id+"title-math-group").node();r=a&&-1!==["top","bottom"].indexOf(b.titleside)?d.bBox(a).width:d.bBox(ot.node()).right-Y-A.l,n=Math.max(n,r)}var o=2*b.xpad+n+b.borderwidth+b.outlinewidth/2,l=$-Q;at.select(".cbbg").attr({x:Y-b.xpad-(b.borderwidth+b.outlinewidth)/2,y:Q-Z,width:Math.max(o,2),height:Math.max(l+2*Z,2)}).call(h.fill,b.bgcolor).call(h.stroke,b.bordercolor).style({"stroke-width":b.borderwidth}),at.selectAll(".cboutline").attr({x:Y,y:Q+b.ypad+("top"===b.titleside?it:0),width:Math.max(F,2),height:Math.max(l-2*b.ypad-it,2)}).call(h.stroke,b.outlinecolor).style({fill:"None","stroke-width":b.outlinewidth});var s=({center:.5,right:1}[b.xanchor]||0)*o;at.attr("transform","translate("+(A.l-s)+","+A.t+")"),i.autoMargin(t,e,{x:b.x,y:b.y,l:o*({right:1,center:.5}[b.xanchor]||0),r:o*({left:1,center:.5}[b.xanchor]||0),t:l*({bottom:1,middle:.5}[b.yanchor]||0),b:l*({top:1,middle:.5}[b.yanchor]||0)})}var M=t._fullLayout,A=M._size;if("function"!=typeof b.fillcolor&&"function"!=typeof b.line.color)return void M._infolayer.selectAll("g."+e).remove();var T,L=r.extent(("function"==typeof b.fillcolor?b.fillcolor:b.line.color).domain()),z=[],S=[],C="function"==typeof b.line.color?b.line.color:function(){return b.line.color},E="function"==typeof b.fillcolor?b.fillcolor:function(){return b.fillcolor},O=b.levels.end+b.levels.size/100,P=b.levels.size,N=1.001*L[0]-.001*L[1],D=1.001*L[1]-.001*L[0];for(T=b.levels.start;0>(T-O)*P;T+=P)T>N&&D>T&&z.push(T);if("function"==typeof b.fillcolor)if(b.filllevels)for(O=b.filllevels.end+b.filllevels.size/100,P=b.filllevels.size,T=b.filllevels.start;0>(T-O)*P;T+=P)T>L[0]&&T1){var rt=Math.pow(10,Math.floor(Math.log(nt)/Math.LN10));tt*=rt*c.roundUp(nt/rt,[2,5,10]),(Math.abs(b.levels.start)/b.levels.size+1e-6)%1<2e-6&&(J.tick0=0)}J.dtick=tt}J.domain=[G+U,G+H-U],J.setScale();var at=M._infolayer.selectAll("g."+e).data([0]);at.enter().append("g").classed(e,!0).each(function(){var t=r.select(this);t.append("rect").classed("cbbg",!0),t.append("g").classed("cbfills",!0),t.append("g").classed("cblines",!0),t.append("g").classed("cbaxis",!0).classed("crisp",!0),t.append("g").classed("cbtitleunshift",!0).append("g").classed("cbtitle",!0),t.append("rect").classed("cboutline",!0),t.select(".cbtitle").datum(0)}),at.attr("transform","translate("+Math.round(A.l)+","+Math.round(A.t)+")");var ot=at.select(".cbtitleunshift").attr("transform","translate(-"+Math.round(A.l)+",-"+Math.round(A.t)+")");J._axislayer=at.select(".cbaxis");var it=0;if(-1!==["top","bottom"].indexOf(b.titleside)){var lt,st=A.l+(b.x+V)*A.w,ct=J.titlefont.size;lt="top"===b.titleside?(1-(G+H-U))*A.h+A.t+3+.75*ct:(1-(G+U))*A.h+A.t-3-.25*ct,w(J._id+"title",{attributes:{x:st,y:lt,"text-anchor":"start"}})}var ut=c.syncOrAsync([i.previousPromises,_,i.previousPromises,k],t);if(ut&&ut.then&&(t._promises||[]).push(ut),t._context.editable){var ft,dt,ht;s.init({element:at.node(),prepFn:function(){ft=at.attr("transform"),f(at)},moveFn:function(t,e){at.attr("transform",ft+" translate("+t+","+e+")"),dt=s.align(X+t/A.w,q,0,1,b.xanchor),ht=s.align(G-e/A.h,H,0,1,b.yanchor);var n=s.getCursor(dt,ht,b.xanchor,b.yanchor);f(at,n)},doneFn:function(e){f(at),e&&void 0!==dt&&void 0!==ht&&o.restyle(t,{"colorbar.x":dt,"colorbar.y":ht},x().index)}})}return ut}function x(){var n,r,a=e.substr(2);for(n=0;nu*f?a.RdBu:u>=0?a.Reds:a.Blues,s.colorscale=d,l.reversescale&&(d=o(d)),l.colorscale=d)}},{"../../lib":102,"./flip_scale":36,"./scales":43}],33:[function(t,e,n){"use strict";var r=t("./attributes"),a=t("../../lib/extend").extendDeep;t("./scales.js");e.exports=function(t){return{color:{valType:"color",arrayOk:!0},colorscale:a({},r.colorscale,{}),cauto:a({},r.zauto,{}),cmax:a({},r.zmax,{}),cmin:a({},r.zmin,{}),autocolorscale:a({},r.autocolorscale,{}),reversescale:a({},r.reversescale,{})}}},{"../../lib/extend":100,"./attributes":31,"./scales.js":43}],34:[function(t,e,n){"use strict";var r=t("./scales");e.exports=r.RdBu},{"./scales":43}],35:[function(t,e,n){"use strict";var r=t("fast-isnumeric"),a=t("../../lib"),o=t("../colorbar/has_colorbar"),i=t("../colorbar/defaults"),l=t("./is_valid_scale"),s=t("./flip_scale");e.exports=function(t,e,n,c,u){var f=u.prefix,d=u.cLetter,h=f.slice(0,f.length-1),p=f?a.nestedProperty(t,h).get()||{}:t,g=f?a.nestedProperty(e,h).get()||{}:e,m=p[d+"min"],v=p[d+"max"],y=p.colorscale,x=r(m)&&r(v)&&v>m;c(f+d+"auto",!x),c(f+d+"min"),c(f+d+"max");var b;void 0!==y&&(b=!l(y)),c(f+"autocolorscale",b);var _=c(f+"colorscale"),w=c(f+"reversescale");if(w&&(g.colorscale=s(_)),"marker.line."!==f){var k;f&&(k=o(p));var M=c(f+"showscale",k);M&&i(p,g,n)}}},{"../../lib":102,"../colorbar/defaults":27,"../colorbar/has_colorbar":29,"./flip_scale":36,"./is_valid_scale":40,"fast-isnumeric":18}],36:[function(t,e,n){"use strict";e.exports=function(t){for(var e,n=t.length,r=new Array(n),a=n-1,o=0;a>=0;a--,o++)e=t[a],r[o]=[1-e[0],e[1]];return r}},{}],37:[function(t,e,n){"use strict";var r=t("./scales"),a=t("./default_scale"),o=t("./is_valid_scale_array");e.exports=function(t,e){function n(){try{t=r[t]||JSON.parse(t)}catch(n){t=e}}return e||(e=a),t?("string"==typeof t&&(n(),"string"==typeof t&&n()),o(t)?t:e):e}},{"./default_scale":34,"./is_valid_scale_array":41,"./scales":43}],38:[function(t,e,n){"use strict";var r=t("fast-isnumeric"),a=t("../../lib"),o=t("./is_valid_scale");e.exports=function(t,e){var n=e?a.nestedProperty(t,e).get()||{}:t,i=n.color,l=!1;if(Array.isArray(i))for(var s=0;sd;d++)s=t[d],u[d]=e+s[0]*(n-e),f[d]=a(s[1]).toRgb();var h=r.scale.linear().domain(u).interpolate(r.interpolateObject).range(f);return function(t){if(o(t)){var r=i.constrain(t,e,n),s=h(r);return a(s).toRgbString()}return a(t).isValid()?t:l.defaultLine}}},{"../../lib":102,"../color":25,d3:16,"fast-isnumeric":18,tinycolor2:20}],43:[function(t,e,n){"use strict";e.exports={Greys:[[0,"rgb(0,0,0)"],[1,"rgb(255,255,255)"]],YlGnBu:[[0,"rgb(8,29,88)"],[.125,"rgb(37,52,148)"],[.25,"rgb(34,94,168)"],[.375,"rgb(29,145,192)"],[.5,"rgb(65,182,196)"],[.625,"rgb(127,205,187)"],[.75,"rgb(199,233,180)"],[.875,"rgb(237,248,217)"],[1,"rgb(255,255,217)"]],Greens:[[0,"rgb(0,68,27)"],[.125,"rgb(0,109,44)"],[.25,"rgb(35,139,69)"],[.375,"rgb(65,171,93)"],[.5,"rgb(116,196,118)"],[.625,"rgb(161,217,155)"],[.75,"rgb(199,233,192)"],[.875,"rgb(229,245,224)"],[1,"rgb(247,252,245)"]],YlOrRd:[[0,"rgb(128,0,38)"],[.125,"rgb(189,0,38)"],[.25,"rgb(227,26,28)"],[.375,"rgb(252,78,42)"],[.5,"rgb(253,141,60)"],[.625,"rgb(254,178,76)"],[.75,"rgb(254,217,118)"],[.875,"rgb(255,237,160)"],[1,"rgb(255,255,204)"]],Bluered:[[0,"rgb(0,0,255)"],[1,"rgb(255,0,0)"]],RdBu:[[0,"rgb(5,10,172)"],[.35,"rgb(106,137,247)"],[.5,"rgb(190,190,190)"],[.6,"rgb(220,170,132)"],[.7,"rgb(230,145,90)"],[1,"rgb(178,10,28)"]],Reds:[[0,"rgb(220,220,220)"],[.2,"rgb(245,195,157)"],[.4,"rgb(245,160,105)"],[1,"rgb(178,10,28)"]], +-Blues:[[0,"rgb(5,10,172)"],[.35,"rgb(40,60,190)"],[.5,"rgb(70,100,245)"],[.6,"rgb(90,120,245)"],[.7,"rgb(106,137,247)"],[1,"rgb(220,220,220)"]],Picnic:[[0,"rgb(0,0,255)"],[.1,"rgb(51,153,255)"],[.2,"rgb(102,204,255)"],[.3,"rgb(153,204,255)"],[.4,"rgb(204,204,255)"],[.5,"rgb(255,255,255)"],[.6,"rgb(255,204,255)"],[.7,"rgb(255,153,255)"],[.8,"rgb(255,102,204)"],[.9,"rgb(255,102,102)"],[1,"rgb(255,0,0)"]],Rainbow:[[0,"rgb(150,0,90)"],[.125,"rgb(0,0,200)"],[.25,"rgb(0,25,255)"],[.375,"rgb(0,152,255)"],[.5,"rgb(44,255,150)"],[.625,"rgb(151,255,0)"],[.75,"rgb(255,234,0)"],[.875,"rgb(255,111,0)"],[1,"rgb(255,0,0)"]],Portland:[[0,"rgb(12,51,131)"],[.25,"rgb(10,136,186)"],[.5,"rgb(242,211,56)"],[.75,"rgb(242,143,56)"],[1,"rgb(217,30,30)"]],Jet:[[0,"rgb(0,0,131)"],[.125,"rgb(0,60,170)"],[.375,"rgb(5,255,255)"],[.625,"rgb(255,255,0)"],[.875,"rgb(250,0,0)"],[1,"rgb(128,0,0)"]],Hot:[[0,"rgb(0,0,0)"],[.3,"rgb(230,0,0)"],[.6,"rgb(255,210,0)"],[1,"rgb(255,255,255)"]],Blackbody:[[0,"rgb(0,0,0)"],[.2,"rgb(230,0,0)"],[.4,"rgb(230,210,0)"],[.7,"rgb(255,255,255)"],[1,"rgb(160,200,255)"]],Earth:[[0,"rgb(0,0,130)"],[.1,"rgb(0,180,180)"],[.2,"rgb(40,210,40)"],[.4,"rgb(230,230,50)"],[.6,"rgb(120,70,20)"],[1,"rgb(255,255,255)"]],Electric:[[0,"rgb(0,0,0)"],[.15,"rgb(30,0,100)"],[.4,"rgb(120,0,100)"],[.6,"rgb(160,90,0)"],[.8,"rgb(230,200,0)"],[1,"rgb(255,250,220)"]],Viridis:[[0,"#440154"],[.06274509803921569,"#48186a"],[.12549019607843137,"#472d7b"],[.18823529411764706,"#424086"],[.25098039215686274,"#3b528b"],[.3137254901960784,"#33638d"],[.3764705882352941,"#2c728e"],[.4392156862745098,"#26828e"],[.5019607843137255,"#21918c"],[.5647058823529412,"#1fa088"],[.6274509803921569,"#28ae80"],[.6901960784313725,"#3fbc73"],[.7529411764705882,"#5ec962"],[.8156862745098039,"#84d44b"],[.8784313725490196,"#addc30"],[.9411764705882353,"#d8e219"],[1,"#fde725"]]}},{}],44:[function(t,e,n){"use strict";e.exports=function(t,e,n,r,a){var o=(t-n)/(r-n),i=o+e/(r-n),l=(o+i)/2;return"left"===a||"bottom"===a?o:"center"===a||"middle"===a?l:"right"===a||"top"===a?i:2/3-l>o?o:i>4/3-l?i:l}},{}],45:[function(t,e,n){"use strict";var r=t("../../lib"),a=[["sw-resize","s-resize","se-resize"],["w-resize","move","e-resize"],["nw-resize","n-resize","ne-resize"]];e.exports=function(t,e,n,o){return t="left"===n?0:"center"===n?1:"right"===n?2:r.constrain(Math.floor(3*t),0,2),e="bottom"===o?0:"middle"===o?1:"top"===o?2:r.constrain(Math.floor(3*e),0,2),a[e][t]}},{"../../lib":102}],46:[function(t,e,n){"use strict";function r(){var t=document.createElement("div");t.className="dragcover";var e=t.style;return e.position="fixed",e.left=0,e.right=0,e.top=0,e.bottom=0,e.zIndex=999999999,e.background="none",document.body.appendChild(t),t}function a(t){t._dragging=!1,t._replotPending&&o.plot(t)}var o=t("../../plotly"),i=t("../../lib"),l=t("../../plots/cartesian/constants"),s=e.exports={};s.align=t("./align"),s.getCursor=t("./cursor");var c=t("./unhover");s.unhover=c.wrapped,s.unhoverRaw=c.raw,s.init=function(t){function e(e){return t.element.onmousemove=p,g._dragged=!1,g._dragging=!0,c=e.clientX,u=e.clientY,h=e.target,f=(new Date).getTime(),f-g._mouseDownTimev&&(m=Math.max(m-1,1)),t.doneFn&&t.doneFn(g._dragged,m),!g._dragged){var n=document.createEvent("MouseEvents");n.initEvent("click",!0,!0),h.dispatchEvent(n)}return a(g),g._dragged=!1,i.pauseEvent(e)}var c,u,f,d,h,p,g=i.getPlotDiv(t.element)||{},m=1,v=l.DBLCLICKDELAY;g._mouseDownTime||(g._mouseDownTime=0),p=t.element.onmousemove,t.setCursor&&(t.element.onmousemove=t.setCursor),t.element.onmousedown=e,t.element.style.pointerEvents="all"}},{"../../lib":102,"../../plotly":120,"../../plots/cartesian/constants":128,"./align":44,"./cursor":45,"./unhover":47}],47:[function(t,e,n){"use strict";var r=t("../../lib/events"),a=e.exports={};a.wrapped=function(t,e,n){"string"==typeof t&&(t=document.getElementById(t)),t._hoverTimer&&(clearTimeout(t._hoverTimer),t._hoverTimer=void 0),a.raw(t,e,n)},a.raw=function(t,e){var n=t._fullLayout;e||(e={}),e.target&&r.triggerHandler(t,"plotly_beforehover",e)===!1||(n._hoverlayer.selectAll("g").remove(),e.target&&t._hoverdata&&t.emit("plotly_unhover",{points:t._hoverdata}),t._hoverdata=void 0)}},{"../../lib/events":99}],48:[function(t,e,n){"use strict";function r(t,e,n,r){var o=t[0]-e[0],i=t[1]-e[1],l=n[0]-e[0],s=n[1]-e[1],c=Math.pow(o*o+i*i,b/2),u=Math.pow(l*l+s*s,b/2),f=(u*u*o-c*c*l)*r,d=(u*u*i-c*c*s)*r,h=3*u*(c+u),p=3*c*(c+u);return[[a.round(e[0]+(h&&f/h),2),a.round(e[1]+(h&&d/h),2)],[a.round(e[0]-(p&&f/p),2),a.round(e[1]-(p&&d/p),2)]]}var a=t("d3"),o=t("fast-isnumeric"),i=t("../../plots/plots"),l=t("../color"),s=t("../colorscale"),c=t("../../lib"),u=t("../../lib/svg_text_utils"),f=t("../../constants/xmlns_namespaces"),d=t("../../traces/scatter/subtypes"),h=t("../../traces/scatter/make_bubble_size_func"),p=e.exports={};p.font=function(t,e,n,r){e&&e.family&&(r=e.color,n=e.size,e=e.family),e&&t.style("font-family",e),n+1&&t.style("font-size",n+"px"),r&&t.call(l.fill,r)},p.setPosition=function(t,e,n){t.attr("x",e).attr("y",n)},p.setSize=function(t,e,n){t.attr("width",e).attr("height",n)},p.setRect=function(t,e,n,r,a){t.call(p.setPosition,e,n).call(p.setSize,r,a)},p.translatePoints=function(t,e,n){t.each(function(t){var r=t.xp||e.c2p(t.x),i=t.yp||n.c2p(t.y),l=a.select(this);o(r)&&o(i)?"text"===this.nodeName?l.attr("x",r).attr("y",i):l.attr("transform","translate("+r+","+i+")"):l.remove()})},p.getPx=function(t,e){return Number(t.style(e).replace(/px$/,""))},p.crispRound=function(t,e,n){return e&&o(e)?t._context.staticPlot?e:1>e?1:Math.round(e):n||0},p.lineGroupStyle=function(t,e,n,r){t.style("fill","none").each(function(t){var o=(((t||[])[0]||{}).trace||{}).line||{},i=e||o.width||0,s=r||o.dash||"";a.select(this).call(l.stroke,n||o.color).call(p.dashLine,s,i)})},p.dashLine=function(t,e,n){var r=Math.max(n,3);"solid"===e?e="":"dot"===e?e=r+"px,"+r+"px":"dash"===e?e=3*r+"px,"+3*r+"px":"longdash"===e?e=5*r+"px,"+5*r+"px":"dashdot"===e?e=3*r+"px,"+r+"px,"+r+"px,"+r+"px":"longdashdot"===e&&(e=5*r+"px,"+2*r+"px,"+r+"px,"+2*r+"px"),t.style({"stroke-dasharray":e,"stroke-width":n+"px"})},p.fillGroupStyle=function(t){t.style("stroke-width",0).each(function(e){var n=a.select(this);try{n.call(l.fill,e[0].trace.fillcolor)}catch(r){c.error(r,t),n.remove()}})};var g=t("./symbol_defs");p.symbolNames=[],p.symbolFuncs=[],p.symbolNeedLines={},p.symbolNoDot={},p.symbolList=[],Object.keys(g).forEach(function(t){var e=g[t];p.symbolList=p.symbolList.concat([e.n,t,e.n+100,t+"-open"]),p.symbolNames[e.n]=t,p.symbolFuncs[e.n]=e.f,e.needLine&&(p.symbolNeedLines[e.n]=!0),e.noDot?p.symbolNoDot[e.n]=!0:p.symbolList=p.symbolList.concat([e.n+200,t+"-dot",e.n+300,t+"-open-dot"])});var m=p.symbolNames.length,v="M0,0.5L0.5,0L0,-0.5L-0.5,0Z";p.symbolNumber=function(t){if("string"==typeof t){var e=0;t.indexOf("-open")>0&&(e=100,t=t.replace("-open","")),t.indexOf("-dot")>0&&(e+=200,t=t.replace("-dot","")),t=p.symbolNames.indexOf(t),t>=0&&(t+=e)}return t%100>=m||t>=400?0:Math.floor(Math.max(t,0))},p.pointStyle=function(t,e){if(t.size()){var n=e.marker,r=n.line;if(i.traceIs(e,"symbols")){var o=h(e);t.attr("d",function(t){var r;r="various"===t.ms||"various"===n.size?3:d.isBubble(e)?o(t.ms):(n.size||6)/2,t.mrc=r;var a=p.symbolNumber(t.mx||n.symbol)||0,i=a%100;return t.om=a%200>=100,p.symbolFuncs[i](r)+(a>=200?v:"")}).style("opacity",function(t){return(t.mo+1||n.opacity+1)-1})}var s=(e._input||{}).marker||{},c=p.tryColorscale(n,s,""),u=p.tryColorscale(n,s,"line.");t.each(function(t){var e,o,i;t.so?(i=r.outlierwidth,o=r.outliercolor,e=n.outliercolor):(i=(t.mlw+1||r.width+1||(t.trace?t.trace.marker.line.width:0)+1)-1,o="mlc"in t?t.mlcc=u(t.mlc):Array.isArray(r.color)?l.defaultLine:r.color,e="mc"in t?t.mcc=c(t.mc):Array.isArray(n.color)?l.defaultLine:n.color||"rgba(0,0,0,0)");var s=a.select(this);t.om?s.call(l.stroke,e).style({"stroke-width":(i||1)+"px",fill:"none"}):(s.style("stroke-width",i+"px").call(l.fill,e),i&&s.call(l.stroke,o))})}},p.tryColorscale=function(t,e,n){var r=c.nestedProperty(t,n+"color").get(),a=c.nestedProperty(t,n+"colorscale").get(),i=c.nestedProperty(t,n+"cauto").get(),l=c.nestedProperty(t,n+"cmin"),u=c.nestedProperty(t,n+"cmax"),f=l.get(),d=u.get();return a&&Array.isArray(r)?(!i&&o(f)&&o(d)||(f=1/0,d=-(1/0),r.forEach(function(t){o(t)&&(f>t&&(f=+t),t>d&&(d=+t))}),f>d&&(f=0,d=1),l.set(f),u.set(d),c.nestedProperty(e,n+"cmin").set(f),c.nestedProperty(e,n+"cmax").set(d)),s.makeScaleFunction(a,f,d)):c.identity};var y={start:1,end:-1,middle:0,bottom:1,top:-1},x=1.3;p.textPointStyle=function(t,e){t.each(function(t){var n=a.select(this),r=t.tx||e.text;if(!r||Array.isArray(r))return void n.remove();var i=t.tp||e.textposition,l=-1!==i.indexOf("top")?"top":-1!==i.indexOf("bottom")?"bottom":"middle",s=-1!==i.indexOf("left")?"end":-1!==i.indexOf("right")?"start":"middle",c=t.ts||e.textfont.size,f=t.mrc?t.mrc/.8+1:0;c=o(c)&&c>0?c:0,n.call(p.font,t.tf||e.textfont.family,c,t.tc||e.textfont.color).attr("text-anchor",s).text(r).call(u.convertToTspans);var d=a.select(this.parentNode),h=n.selectAll("tspan.line"),g=((h[0].length||1)-1)*x+1,m=y[s]*f,v=.75*c+y[l]*f+(y[l]-1)*g*c/2;d.attr("transform","translate("+m+","+v+")"),g>1&&h.attr({x:n.attr("x"),y:n.attr("y")})})};var b=.5;p.smoothopen=function(t,e){if(t.length<3)return"M"+t.join("L");var n,a="M"+t[0],o=[];for(n=1;nn;n++)i.push(r(t[n-1],t[n],t[n+1],e));for(i.push(r(t[o-1],t[o],t[0],e)),n=1;o>=n;n++)a+="C"+i[n-1][1]+" "+i[n][0]+" "+t[n];return a+="C"+i[o][1]+" "+i[0][0]+" "+t[0]+"Z"};var _={hv:function(t,e){return"H"+a.round(e[0],2)+"V"+a.round(e[1],2)},vh:function(t,e){return"V"+a.round(e[1],2)+"H"+a.round(e[0],2)},hvh:function(t,e){return"H"+a.round((t[0]+e[0])/2,2)+"V"+a.round(e[1],2)+"H"+a.round(e[0],2)},vhv:function(t,e){return"V"+a.round((t[1]+e[1])/2,2)+"H"+a.round(e[0],2)+"V"+a.round(e[1],2)}},w=function(t,e){return"L"+a.round(e[0],2)+","+a.round(e[1],2)};p.steps=function(t){var e=_[t]||w;return function(t){for(var n="M"+a.round(t[0][0],2)+","+a.round(t[0][1],2),r=1;r=M&&(a.selectAll("[data-bb]").attr("data-bb",null),k=[]),t.setAttribute("data-bb",k.length),k.push(s),c.extendFlat({},s)},p.setClipUrl=function(t,e){if(!e)return void t.attr("clip-path",null);var n="#"+e,r=a.select("base");r.size()&&r.attr("href")&&(n=window.location.href+n),t.attr("clip-path","url("+n+")")}},{"../../constants/xmlns_namespaces":94,"../../lib":102,"../../lib/svg_text_utils":113,"../../plots/plots":143,"../../traces/scatter/make_bubble_size_func":250,"../../traces/scatter/subtypes":255,"../color":25,"../colorscale":39,"./symbol_defs":49,d3:16,"fast-isnumeric":18}],49:[function(t,e,n){"use strict";var r=t("d3");e.exports={circle:{n:0,f:function(t){var e=r.round(t,2);return"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"}},square:{n:1,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"}},diamond:{n:2,f:function(t){var e=r.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"Z"}},cross:{n:3,f:function(t){var e=r.round(.4*t,2),n=r.round(1.2*t,2);return"M"+n+","+e+"H"+e+"V"+n+"H-"+e+"V"+e+"H-"+n+"V-"+e+"H-"+e+"V-"+n+"H"+e+"V-"+e+"H"+n+"Z"}},x:{n:4,f:function(t){var e=r.round(.8*t/Math.sqrt(2),2),n="l"+e+","+e,a="l"+e+",-"+e,o="l-"+e+",-"+e,i="l-"+e+","+e;return"M0,"+e+n+a+o+a+o+i+o+i+n+i+n+"Z"}},"triangle-up":{n:5,f:function(t){var e=r.round(2*t/Math.sqrt(3),2),n=r.round(t/2,2),a=r.round(t,2);return"M-"+e+","+n+"H"+e+"L0,-"+a+"Z"}},"triangle-down":{n:6,f:function(t){var e=r.round(2*t/Math.sqrt(3),2),n=r.round(t/2,2),a=r.round(t,2);return"M-"+e+",-"+n+"H"+e+"L0,"+a+"Z"}},"triangle-left":{n:7,f:function(t){var e=r.round(2*t/Math.sqrt(3),2),n=r.round(t/2,2),a=r.round(t,2);return"M"+n+",-"+e+"V"+e+"L-"+a+",0Z"}},"triangle-right":{n:8,f:function(t){var e=r.round(2*t/Math.sqrt(3),2),n=r.round(t/2,2),a=r.round(t,2);return"M-"+n+",-"+e+"V"+e+"L"+a+",0Z"}},"triangle-ne":{n:9,f:function(t){var e=r.round(.6*t,2),n=r.round(1.2*t,2);return"M-"+n+",-"+e+"H"+e+"V"+n+"Z"}},"triangle-se":{n:10,f:function(t){var e=r.round(.6*t,2),n=r.round(1.2*t,2);return"M"+e+",-"+n+"V"+e+"H-"+n+"Z"}},"triangle-sw":{n:11,f:function(t){var e=r.round(.6*t,2),n=r.round(1.2*t,2);return"M"+n+","+e+"H-"+e+"V-"+n+"Z"}},"triangle-nw":{n:12,f:function(t){var e=r.round(.6*t,2),n=r.round(1.2*t,2);return"M-"+e+","+n+"V-"+e+"H"+n+"Z"}},pentagon:{n:13,f:function(t){var e=r.round(.951*t,2),n=r.round(.588*t,2),a=r.round(-t,2),o=r.round(t*-.309,2),i=r.round(.809*t,2);return"M"+e+","+o+"L"+n+","+i+"H-"+n+"L-"+e+","+o+"L0,"+a+"Z"}},hexagon:{n:14,f:function(t){var e=r.round(t,2),n=r.round(t/2,2),a=r.round(t*Math.sqrt(3)/2,2);return"M"+a+",-"+n+"V"+n+"L0,"+e+"L-"+a+","+n+"V-"+n+"L0,-"+e+"Z"}},hexagon2:{n:15,f:function(t){var e=r.round(t,2),n=r.round(t/2,2),a=r.round(t*Math.sqrt(3)/2,2);return"M-"+n+","+a+"H"+n+"L"+e+",0L"+n+",-"+a+"H-"+n+"L-"+e+",0Z"}},octagon:{n:16,f:function(t){var e=r.round(.924*t,2),n=r.round(.383*t,2);return"M-"+n+",-"+e+"H"+n+"L"+e+",-"+n+"V"+n+"L"+n+","+e+"H-"+n+"L-"+e+","+n+"V-"+n+"Z"}},star:{n:17,f:function(t){var e=1.4*t,n=r.round(.225*e,2),a=r.round(.951*e,2),o=r.round(.363*e,2),i=r.round(.588*e,2),l=r.round(-e,2),s=r.round(e*-.309,2),c=r.round(.118*e,2),u=r.round(.809*e,2),f=r.round(.382*e,2);return"M"+n+","+s+"H"+a+"L"+o+","+c+"L"+i+","+u+"L0,"+f+"L-"+i+","+u+"L-"+o+","+c+"L-"+a+","+s+"H-"+n+"L0,"+l+"Z"}},hexagram:{n:18,f:function(t){var e=r.round(.66*t,2),n=r.round(.38*t,2),a=r.round(.76*t,2);return"M-"+a+",0l-"+n+",-"+e+"h"+a+"l"+n+",-"+e+"l"+n+","+e+"h"+a+"l-"+n+","+e+"l"+n+","+e+"h-"+a+"l-"+n+","+e+"l-"+n+",-"+e+"h-"+a+"Z"}},"star-triangle-up":{n:19,f:function(t){var e=r.round(t*Math.sqrt(3)*.8,2),n=r.round(.8*t,2),a=r.round(1.6*t,2),o=r.round(4*t,2),i="A "+o+","+o+" 0 0 1 ";return"M-"+e+","+n+i+e+","+n+i+"0,-"+a+i+"-"+e+","+n+"Z"}},"star-triangle-down":{n:20,f:function(t){var e=r.round(t*Math.sqrt(3)*.8,2),n=r.round(.8*t,2),a=r.round(1.6*t,2),o=r.round(4*t,2),i="A "+o+","+o+" 0 0 1 ";return"M"+e+",-"+n+i+"-"+e+",-"+n+i+"0,"+a+i+e+",-"+n+"Z"}},"star-square":{n:21,f:function(t){var e=r.round(1.1*t,2),n=r.round(2*t,2),a="A "+n+","+n+" 0 0 1 ";return"M-"+e+",-"+e+a+"-"+e+","+e+a+e+","+e+a+e+",-"+e+a+"-"+e+",-"+e+"Z"}},"star-diamond":{n:22,f:function(t){var e=r.round(1.4*t,2),n=r.round(1.9*t,2),a="A "+n+","+n+" 0 0 1 ";return"M-"+e+",0"+a+"0,"+e+a+e+",0"+a+"0,-"+e+a+"-"+e+",0Z"}},"diamond-tall":{n:23,f:function(t){var e=r.round(.7*t,2),n=r.round(1.4*t,2);return"M0,"+n+"L"+e+",0L0,-"+n+"L-"+e+",0Z"}},"diamond-wide":{n:24,f:function(t){var e=r.round(1.4*t,2),n=r.round(.7*t,2);return"M0,"+n+"L"+e+",0L0,-"+n+"L-"+e+",0Z"}},hourglass:{n:25,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"H-"+e+"L"+e+",-"+e+"H-"+e+"Z"},noDot:!0},bowtie:{n:26,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"V-"+e+"L-"+e+","+e+"V-"+e+"Z"},noDot:!0},"circle-cross":{n:27,f:function(t){var e=r.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"circle-x":{n:28,f:function(t){var e=r.round(t,2),n=r.round(t/Math.sqrt(2),2);return"M"+n+","+n+"L-"+n+",-"+n+"M"+n+",-"+n+"L-"+n+","+n+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"square-cross":{n:29,f:function(t){var e=r.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"square-x":{n:30,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"diamond-cross":{n:31,f:function(t){var e=r.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM0,-"+e+"V"+e+"M-"+e+",0H"+e},needLine:!0,noDot:!0},"diamond-x":{n:32,f:function(t){var e=r.round(1.3*t,2),n=r.round(.65*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM-"+n+",-"+n+"L"+n+","+n+"M-"+n+","+n+"L"+n+",-"+n},needLine:!0,noDot:!0},"cross-thin":{n:33,f:function(t){var e=r.round(1.4*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e},needLine:!0,noDot:!0},"x-thin":{n:34,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0},asterisk:{n:35,f:function(t){var e=r.round(1.2*t,2),n=r.round(.85*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+n+","+n+"L-"+n+",-"+n+"M"+n+",-"+n+"L-"+n+","+n},needLine:!0,noDot:!0},hash:{n:36,f:function(t){var e=r.round(t/2,2),n=r.round(t,2);return"M"+e+","+n+"V-"+n+"m-"+n+",0V"+n+"M"+n+","+e+"H-"+n+"m0,-"+n+"H"+n},needLine:!0},"y-up":{n:37,f:function(t){var e=r.round(1.2*t,2),n=r.round(1.6*t,2),a=r.round(.8*t,2);return"M-"+e+","+a+"L0,0M"+e+","+a+"L0,0M0,-"+n+"L0,0"},needLine:!0,noDot:!0},"y-down":{n:38,f:function(t){var e=r.round(1.2*t,2),n=r.round(1.6*t,2),a=r.round(.8*t,2);return"M-"+e+",-"+a+"L0,0M"+e+",-"+a+"L0,0M0,"+n+"L0,0"},needLine:!0,noDot:!0},"y-left":{n:39,f:function(t){var e=r.round(1.2*t,2),n=r.round(1.6*t,2),a=r.round(.8*t,2);return"M"+a+","+e+"L0,0M"+a+",-"+e+"L0,0M-"+n+",0L0,0"},needLine:!0,noDot:!0},"y-right":{n:40,f:function(t){var e=r.round(1.2*t,2),n=r.round(1.6*t,2),a=r.round(.8*t,2);return"M-"+a+","+e+"L0,0M-"+a+",-"+e+"L0,0M"+n+",0L0,0"},needLine:!0,noDot:!0},"line-ew":{n:41,f:function(t){var e=r.round(1.4*t,2);return"M"+e+",0H-"+e},needLine:!0,noDot:!0},"line-ns":{n:42,f:function(t){var e=r.round(1.4*t,2);return"M0,"+e+"V-"+e},needLine:!0,noDot:!0},"line-ne":{n:43,f:function(t){var e=r.round(t,2);return"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0},"line-nw":{n:44,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e},needLine:!0,noDot:!0}}},{d3:16}],50:[function(t,e,n){"use strict";e.exports={visible:{valType:"boolean"},type:{valType:"enumerated",values:["percent","constant","sqrt","data"]},symmetric:{valType:"boolean"},array:{valType:"data_array"},arrayminus:{valType:"data_array"},value:{valType:"number",min:0,dflt:10},valueminus:{valType:"number",min:0,dflt:10},traceref:{valType:"integer",min:0,dflt:0},tracerefminus:{valType:"integer",min:0,dflt:0},copy_ystyle:{valType:"boolean"},copy_zstyle:{valType:"boolean"},color:{valType:"color"},thickness:{valType:"number",min:0,dflt:2},width:{valType:"number",min:0},_deprecated:{opacity:{valType:"number"}}}},{}],51:[function(t,e,n){"use strict";function r(t,e,n,r){var o=e["error_"+r]||{},s=o.visible&&-1!==["linear","log"].indexOf(n.type),c=[];if(s){for(var u=l(o),f=0;fl;l++)i[l]={x:n[l],y:a[l]};return i[0].trace=t,r.calc({calcdata:[i],_fullLayout:e}),i},r.plot=t("./plot"),r.style=t("./style"),r.hoverInfo=function(t,e,n){(e.error_y||{}).visible&&(n.yerr=t.yh-t.y,e.error_y.symmetric||(n.yerrneg=t.y-t.ys)),(e.error_x||{}).visible&&(n.xerr=t.xh-t.x,e.error_x.symmetric||(n.xerrneg=t.x-t.xs))}},{"./attributes":50,"./calc":51,"./defaults":53,"./plot":55,"./style":56}],55:[function(t,e,n){"use strict";function r(t,e,n){var r={x:e.c2p(t.x),y:n.c2p(t.y)};return void 0!==t.yh&&(r.yh=n.c2p(t.yh),r.ys=n.c2p(t.ys),o(r.ys)||(r.noYS=!0,r.ys=n.c2p(t.ys,!0))),void 0!==t.xh&&(r.xh=e.c2p(t.xh),r.xs=e.c2p(t.xs),o(r.xs)||(r.noXS=!0,r.xs=e.c2p(t.xs,!0))),r}var a=t("d3"),o=t("fast-isnumeric"),i=t("../../lib"),l=t("../../traces/scatter/subtypes");e.exports=function(t,e){var n=e.x(),s=e.y();t.each(function(t){var e=t[0].trace,c=e.error_x||{},u=e.error_y||{},f=l.hasMarkers(e)&&e.marker.maxdisplayed>0;if(u.visible||c.visible){var d=a.select(this).selectAll("g.errorbar").data(i.identity);d.enter().append("g").classed("errorbar",!0),d.each(function(t){var e=a.select(this),i=r(t,n,s);if(!f||t.vis){var l;if(u.visible&&o(i.x)&&o(i.yh)&&o(i.ys)){var d=u.width;l="M"+(i.x-d)+","+i.yh+"h"+2*d+"m-"+d+",0V"+i.ys,i.noYS||(l+="m-"+d+",0h"+2*d),e.append("path").classed("yerror",!0).attr("d",l)}if(c.visible&&o(i.y)&&o(i.xh)&&o(i.xs)){var h=(c.copy_ystyle?u:c).width;l="M"+i.xh+","+(i.y-h)+"v"+2*h+"m0,-"+h+"H"+i.xs,i.noXS||(l+="m0,-"+h+"v"+2*h),e.append("path").classed("xerror",!0).attr("d",l)}}})}})}},{"../../lib":102,"../../traces/scatter/subtypes":255,d3:16,"fast-isnumeric":18}],56:[function(t,e,n){"use strict";var r=t("d3"),a=t("../color");e.exports=function(t){t.each(function(t){var e=t[0].trace,n=e.error_y||{},o=e.error_x||{},i=r.select(this);i.selectAll("path.yerror").style("stroke-width",n.thickness+"px").call(a.stroke,n.color),o.copy_ystyle&&(o=n),i.selectAll("path.xerror").style("stroke-width",o.thickness+"px").call(a.stroke,o.color)})}},{"../color":25,d3:16}],57:[function(t,e,n){"use strict";var r=t("../../plots/cartesian/constants");e.exports={_isLinkedToArray:!0,source:{valType:"string"},layer:{valType:"enumerated",values:["below","above"],dflt:"above"},sizex:{valType:"number",dflt:0},sizey:{valType:"number",dflt:0},sizing:{valType:"enumerated",values:["fill","contain","stretch"],dflt:"contain"},opacity:{valType:"number",min:0,max:1,dflt:1},x:{valType:"number",dflt:0},y:{valType:"number",dflt:0},xanchor:{valType:"enumerated",values:["left","center","right"],dflt:"left"},yanchor:{valType:"enumerated",values:["top","middle","bottom"],dflt:"top"},xref:{valType:"enumerated",values:["paper",r.idRegex.x.toString()],dflt:"paper"},yref:{valType:"enumerated",values:["paper",r.idRegex.y.toString()],dflt:"paper"}}},{"../../plots/cartesian/constants":128}],58:[function(t,e,n){"use strict";function r(t,e,n){function r(n,r){return o.coerce(t,e,i,n,r)}e=e||{},r("source"),r("layer"),r("x"),r("y"),r("xanchor"),r("yanchor"),r("sizex"),r("sizey"),r("sizing"),r("opacity");for(var l=0;2>l;l++){var s={_fullLayout:n},c=["x","y"][l];a.coerceRef(t,e,s,c,"paper")}return e}var a=t("../../plots/cartesian/axes"),o=t("../../lib"),i=t("./attributes");e.exports=function(t,e){if(t.images&&Array.isArray(t.images))for(var n=t.images,a=e.images=[],o=0;o=2/3},n.isCenterAnchor=function(t){return"center"===t.xanchor||"auto"===t.xanchor&&t.x>1/3&&t.x<2/3},n.isBottomAnchor=function(t){return"bottom"===t.yanchor||"auto"===t.yanchor&&t.y<=1/3},n.isMiddleAnchor=function(t){return"middle"===t.yanchor||"auto"===t.yanchor&&t.y>1/3&&t.y<2/3}},{}],62:[function(t,e,n){"use strict";var r=t("../../plots/font_attributes"),a=t("../color/attributes"),o=t("../../lib/extend").extendFlat;e.exports={bgcolor:{valType:"color"},bordercolor:{valType:"color",dflt:a.defaultLine},borderwidth:{valType:"number",min:0,dflt:0},font:o({},r,{}),orientation:{valType:"enumerated",values:["v","h"],dflt:"v"},traceorder:{valType:"flaglist",flags:["reversed","grouped"],extras:["normal"]},tracegroupgap:{valType:"number",min:0,dflt:10},x:{valType:"number",min:-2,max:3,dflt:1.02},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"left"},y:{valType:"number",min:-2,max:3,dflt:1},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto"}}},{"../../lib/extend":100,"../../plots/font_attributes":141,"../color/attributes":24}],63:[function(t,e,n){"use strict";e.exports={scrollBarWidth:4,scrollBarHeight:20,scrollBarColor:"#808BA4",scrollBarMargin:4}},{}],64:[function(t,e,n){"use strict";var r=t("../../lib"),a=t("../../plots/plots"),o=t("./attributes"),i=t("./helpers");e.exports=function(t,e,n){function l(t,e){return r.coerce(d,h,o,t,e)}for(var s,c,u,f,d=t.legend||{},h=e.legend={},p=0,g="normal",m=0;m1);if(y!==!1){if(l("bgcolor",e.paper_bgcolor),l("bordercolor"),l("borderwidth"),r.coerceFont(l,"font",e.font),l("orientation"),"h"===h.orientation){var x=t.xaxis;x&&x.rangeslider&&x.rangeslider.visible?(s=0,u="left",c=1.1,f="bottom"):(s=0,u="left",c=-.1,f="top")}l("traceorder",g),i.isGrouped(e.legend)&&l("tracegroupgap"),l("x",s),l("xanchor",u),l("y",c),l("yanchor",f),r.noneOrAll(d,h,["x","y"])}}},{"../../lib":102,"../../plots/plots":143,"./attributes":62,"./helpers":67}],65:[function(t,e,n){"use strict";function r(t,e){function n(n){u.util.convertToTspans(n,function(){n.selectAll("tspan.line").attr({x:n.attr("x")}),t.call(o,e)})}var r=t.data()[0][0],a=e._fullLayout,i=r.trace,l=d.traceIs(i,"pie"),s=i.index,c=l?r.label:i.name,f=t.selectAll("text.legendtext").data([0]);f.enter().append("text").classed("legendtext",!0),f.attr({x:40,y:0,"data-unformatted":c}).style("text-anchor","start").classed("user-select-none",!0).call(p.font,a.legend.font).text(c),e._context.editable&&!l?f.call(u.util.makeEditable).call(n).on("edit",function(t){this.attr({"data-unformatted":t}),this.text(t).call(n),this.text()||(t=" "),u.restyle(e,"name",t,s)}):f.call(n)}function a(t,e){var n=e._fullLayout.hiddenlabels?e._fullLayout.hiddenlabels.slice():[],r=t.selectAll("rect").data([0]);r.enter().append("rect").classed("legendtoggle",!0).style("cursor","pointer").attr("pointer-events","all").call(g.fill,"rgba(0,0,0,0)"),r.on("click",function(){if(!e._dragged){var r,a,o=t.data()[0][0],i=e._fullData,l=o.trace,s=l.legendgroup,c=[];if(d.traceIs(l,"pie")){var f=o.label,h=n.indexOf(f);-1===h?n.push(f):n.splice(h,1),u.relayout(e,"hiddenlabels",n)}else{if(""===s)c=[l.index];else for(var p=0;ptspan"),h=d[0].length||1;n=s*h,r=u.node()&&p.bBox(u.node()).width;var g=s*(.3+(1-h)/2);u.attr("y",g),d.attr("y",g)}n=Math.max(n,16)+3,o.attr({x:0,y:-n/2,height:n}),a.height=n,a.width=r}function i(t,e,n){var r=t._fullLayout,a=r.legend,o=a.borderwidth,i=x.isGrouped(a);if(x.isVertical(a))i&&e.each(function(t,e){f.setTranslate(this,0,e*a.tracegroupgap)}),a.width=0,a.height=0,n.each(function(t){var e=t[0],n=e.height,r=e.width;f.setTranslate(this,o,5+o+a.height+n/2),a.height+=n,a.width=Math.max(a.width,r)}),a.width+=45+2*o,a.height+=10+2*o,i&&(a.height+=(a._lgroupsLength-1)*a.tracegroupgap),n.selectAll(".legendtoggle").attr("width",(t._context.editable?0:a.width)+40),a.width=Math.ceil(a.width),a.height=Math.ceil(a.height);else if(i){a.width=0,a.height=0;for(var l=[a.width],s=e.data(),u=0,d=s.length;d>u;u++){var h=s[u].map(function(t){return t[0].width}),p=40+Math.max.apply(null,h);a.width+=a.tracegroupgap+p,l.push(a.width)}e.each(function(t,e){f.setTranslate(this,l[e],0)}),e.each(function(){var t=c.select(this),e=t.selectAll("g.traces"),n=0;e.each(function(t){var e=t[0],r=e.height;f.setTranslate(this,0,5+o+n+r/2),n+=r}),a.height=Math.max(a.height,n)}),a.height+=10+2*o,a.width+=2*o,a.width=Math.ceil(a.width),a.height=Math.ceil(a.height),n.selectAll(".legendtoggle").attr("width",t._context.editable?0:a.width)}else{a.width=0,a.height=0;var g=0,m=0,v=0,y=0;n.each(function(t){v=Math.max(40+t[0].width,v)}),n.each(function(t){var e=t[0],n=v,i=a.tracegroupgap||5;o+y+i+n>r.width-(r.margin.r+r.margin.l)&&(y=0,g+=m,a.height=a.height+m,m=0),f.setTranslate(this,o+y,5+o+e.height/2+g),a.width+=i+n,a.height=Math.max(a.height,e.height),y+=i+n,m=Math.max(e.height,m)}),a.width+=2*o,a.height+=10+2*o,a.width=Math.ceil(a.width),a.height=Math.ceil(a.height),n.selectAll(".legendtoggle").attr("width",t._context.editable?0:a.width)}}function l(t){var e=t._fullLayout,n=e.legend,r="left";b.isRightAnchor(n)?r="right":b.isCenterAnchor(n)&&(r="center");var a="top";b.isBottomAnchor(n)?a="bottom":b.isMiddleAnchor(n)&&(a="middle"),d.autoMargin(t,"legend",{x:n.x,y:n.y,l:n.width*({right:1,center:.5}[r]||0),r:n.width*({left:1,center:.5}[r]||0),b:n.height*({top:1,middle:.5}[a]||0),t:n.height*({bottom:1,middle:.5}[a]||0)})}function s(t){var e=t._fullLayout,n=e.legend,r="left";b.isRightAnchor(n)?r="right":b.isCenterAnchor(n)&&(r="center"),d.autoMargin(t,"legend",{x:n.x,y:.5,l:n.width*({right:1,center:.5}[r]||0),r:n.width*({left:1,center:.5}[r]||0),b:0,t:0})}var c=t("d3"),u=t("../../plotly"),f=t("../../lib"),d=t("../../plots/plots"),h=t("../dragelement"),p=t("../drawing"),g=t("../color"),m=t("./constants"),v=t("./get_legend_data"),y=t("./style"),x=t("./helpers"),b=t("./anchor_utils");e.exports=function(t){function e(t,e){T.attr("data-scroll",e).call(f.setTranslate,0,e),L.call(p.setRect,j,t,m.scrollBarWidth,m.scrollBarHeight),M.select("rect").attr({y:x.borderwidth-e})}var n=t._fullLayout,o="legend"+n._uid;if(n._infolayer&&t.calcdata){var x=n.legend,_=n.showlegend&&v(t.calcdata,x),w=n.hiddenlabels||[];if(!n.showlegend||!_.length)return n._infolayer.selectAll(".legend").remove(),n._topdefs.select("#"+o).remove(),void d.autoMargin(t,"legend");var k=n._infolayer.selectAll("g.legend").data([0]);k.enter().append("g").attr({"class":"legend","pointer-events":"all"});var M=n._topdefs.selectAll("#"+o).data([0]);M.enter().append("clipPath").attr("id",o).append("rect");var A=k.selectAll("rect.bg").data([0]);A.enter().append("rect").attr({"class":"bg","shape-rendering":"crispEdges"}),A.call(g.stroke,x.bordercolor),A.call(g.fill,x.bgcolor),A.style("stroke-width",x.borderwidth+"px");var T=k.selectAll("g.scrollbox").data([0]);T.enter().append("g").attr("class","scrollbox");var L=k.selectAll("rect.scrollbar").data([0]);L.enter().append("rect").attr({"class":"scrollbar",rx:20,ry:2,width:0,height:0}).call(g.fill,"#808BA4");var z=T.selectAll("g.groups").data(_);z.enter().append("g").attr("class","groups"),z.exit().remove();var S=z.selectAll("g.traces").data(f.identity);S.enter().append("g").attr("class","traces"),S.exit().remove(),S.call(y).style("opacity",function(t){var e=t[0].trace;return d.traceIs(e,"pie")?-1!==w.indexOf(t[0].label)?.5:1:"legendonly"===e.visible?.5:1}).each(function(){c.select(this).call(r,t).call(a,t)});var C=0!==k.enter().size();C&&(i(t,z,S),l(t));var E=0,O=n.width,P=0,N=n.height;i(t,z,S),x.height>N?s(t):l(t);var D=n._size,I=D.l+D.w*x.x,R=D.t+D.h*(1-x.y);b.isRightAnchor(x)?I-=x.width:b.isCenterAnchor(x)&&(I-=x.width/2),b.isBottomAnchor(x)?R-=x.height:b.isMiddleAnchor(x)&&(R-=x.height/2);var j=x.width,F=D.w;j>F?(I=D.l,j=F):(I+j>O&&(I=O-j),E>I&&(I=E),j=Math.min(O-I,x.width));var q=x.height,B=D.h;q>B?(R=D.t,q=B):(R+q>N&&(R=N-q),P>R&&(R=P),q=Math.min(N-R,x.height)),f.setTranslate(k,I,R);var H,V,Z=q-m.scrollBarHeight-2*m.scrollBarMargin,U=x.height-q;if(x.height<=q||t._context.staticPlot)A.attr({width:j-x.borderwidth,height:q-x.borderwidth,x:x.borderwidth/2,y:x.borderwidth/2}),f.setTranslate(T,0,0),M.select("rect").attr({width:j-2*x.borderwidth,height:q-2*x.borderwidth,x:x.borderwidth,y:x.borderwidth}),T.call(p.setClipUrl,o);else{H=m.scrollBarMargin,V=T.attr("data-scroll")||0,A.attr({width:j-2*x.borderwidth+m.scrollBarWidth+m.scrollBarMargin,height:q-x.borderwidth,x:x.borderwidth/2,y:x.borderwidth/2}),M.select("rect").attr({width:j-2*x.borderwidth+m.scrollBarWidth+m.scrollBarMargin,height:q-2*x.borderwidth,x:x.borderwidth,y:x.borderwidth-V}),T.call(p.setClipUrl,o),C&&e(H,V),k.on("wheel",null),k.on("wheel",function(){V=f.constrain(T.attr("data-scroll")-c.event.deltaY/Z*U,-U,0),H=m.scrollBarMargin-V/U*Z,e(H,V),c.event.preventDefault()}),L.on(".drag",null),T.on(".drag",null);var Y=c.behavior.drag().on("drag",function(){H=f.constrain(c.event.y-m.scrollBarHeight/2,m.scrollBarMargin,m.scrollBarMargin+Z),V=-(H-m.scrollBarMargin)/Z*U,e(H,V)});L.call(Y),T.call(Y)}if(t._context.editable){var X,G,$,Q;k.classed("cursor-move",!0),h.init({element:k.node(),prepFn:function(){var t=f.getTranslate(k);$=t.x,Q=t.y},moveFn:function(t,e){var n=$+t,r=Q+e;f.setTranslate(k,n,r),X=h.align(n,0,D.l,D.l+D.w,x.xanchor),G=h.align(r,0,D.t+D.h,D.t,x.yanchor)},doneFn:function(e){e&&void 0!==X&&void 0!==G&&u.relayout(t,{"legend.x":X,"legend.y":G})}})}}}},{"../../lib":102,"../../plotly":120,"../../plots/plots":143,"../color":25,"../dragelement":46,"../drawing":48,"./anchor_utils":61,"./constants":63,"./get_legend_data":66,"./helpers":67,"./style":69,d3:16}],66:[function(t,e,n){"use strict";var r=t("../../plots/plots"),a=t("./helpers");e.exports=function(t,e){function n(t,n){if(""!==t&&a.isGrouped(e))-1===s.indexOf(t)?(s.push(t),c=!0,l[t]=[[n]]):l[t].push([n]);else{var r="~~i"+f;s.push(r),l[r]=[[n]],f++}}var o,i,l={},s=[],c=!1,u={},f=0;for(o=0;oo;o++)v=l[s[o]],y[o]=a.isReversed(e)?v.reverse():v;else{for(y=[new Array(x)],o=0;x>o;o++)v=l[s[o]][0],y[0][a.isReversed(e)?x-o-1:o]=v;x=1}return e._lgroupsLength=x,y}},{"../../plots/plots":143,"./helpers":67}],67:[function(t,e,n){"use strict";var r=t("../../plots/plots");n.legendGetsTrace=function(t){return t.visible&&r.traceIs(t,"showLegend")},n.isGrouped=function(t){return-1!==(t.traceorder||"").indexOf("grouped")},n.isVertical=function(t){return"h"!==t.orientation},n.isReversed=function(t){return-1!==(t.traceorder||"").indexOf("reversed")}},{"../../plots/plots":143}],68:[function(t,e,n){"use strict";var r=e.exports={};r.layoutAttributes=t("./attributes"),r.supplyLayoutDefaults=t("./defaults"),r.draw=t("./draw"),r.style=t("./style")},{"./attributes":62,"./defaults":64,"./draw":65,"./style":69}],69:[function(t,e,n){"use strict";function r(t){var e=t[0].trace,n=e.visible&&e.fill&&"none"!==e.fill,r=h.hasLines(e),a=s.select(this).select(".legendfill").selectAll("path").data(n?[t]:[]);a.enter().append("path").classed("js-fill",!0),a.exit().remove(),a.attr("d","M5,0h30v6h-30z").call(f.fillGroupStyle);var o=s.select(this).select(".legendlines").selectAll("path").data(r?[t]:[]);o.enter().append("path").classed("js-line",!0).attr("d","M5,0h30"),o.exit().remove(),o.call(f.lineGroupStyle)}function a(t){function e(t,e,n){var r=c.nestedProperty(i,t).get(),a=Array.isArray(r)&&e?e(r):r;if(n){if(an[1])return n[1]}return a}function n(t){return t[0]}var r,a,o=t[0],i=o.trace,l=h.hasMarkers(i),u=h.hasText(i),d=h.hasLines(i);if(l||u||d){var p={},g={};l&&(p.mc=e("marker.color",n),p.mo=e("marker.opacity",c.mean,[.2,1]),p.ms=e("marker.size",c.mean,[2,16]),p.mlc=e("marker.line.color",n),p.mlw=e("marker.line.width",c.mean,[0,5]),g.marker={sizeref:1,sizemin:1,sizemode:"diameter"}),d&&(g.line={width:e("line.width",n,[0,10])}),u&&(p.tx="Aa",p.tp=e("textposition",n),p.ts=10,p.tc=e("textfont.color",n),p.tf=e("textfont.family",n)),r=[c.minExtend(o,p)],a=c.minExtend(i,g)}var m=s.select(this).select("g.legendpoints"),v=m.selectAll("path.scatterpts").data(l?r:[]);v.enter().append("path").classed("scatterpts",!0).attr("transform","translate(20,0)"),v.exit().remove(),v.call(f.pointStyle,a),l&&(r[0].mrc=3);var y=m.selectAll("g.pointtext").data(u?r:[]);y.enter().append("g").classed("pointtext",!0).append("text").attr("transform","translate(20,0)"),y.exit().remove(),y.selectAll("text").call(f.textPointStyle,a)}function o(t){var e=t[0].trace,n=e.marker||{},r=n.line||{},a=s.select(this).select("g.legendpoints").selectAll("path.legendbar").data(u.traceIs(e,"bar")?[t]:[]);a.enter().append("path").classed("legendbar",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),a.exit().remove(),a.each(function(t){var e=(t.mlw+1||r.width+1)-1,a=s.select(this);a.style("stroke-width",e+"px").call(d.fill,t.mc||n.color),e&&a.call(d.stroke,t.mlc||r.color)})}function i(t){var e=t[0].trace,n=s.select(this).select("g.legendpoints").selectAll("path.legendbox").data(u.traceIs(e,"box")&&e.visible?[t]:[]);n.enter().append("path").classed("legendbox",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),n.exit().remove(),n.each(function(t){var n=(t.lw+1||e.line.width+1)-1,r=s.select(this);r.style("stroke-width",n+"px").call(d.fill,t.fc||e.fillcolor),n&&r.call(d.stroke,t.lc||e.line.color)})}function l(t){var e=t[0].trace,n=s.select(this).select("g.legendpoints").selectAll("path.legendpie").data(u.traceIs(e,"pie")&&e.visible?[t]:[]);n.enter().append("path").classed("legendpie",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),n.exit().remove(),n.size()&&n.call(p,t[0],e)}var s=t("d3"),c=t("../../lib"),u=t("../../plots/plots"),f=t("../drawing"),d=t("../color"),h=t("../../traces/scatter/subtypes"),p=t("../../traces/pie/style_one");e.exports=function(t){t.each(function(t){var e=s.select(this),n=e.selectAll("g.legendfill").data([t]);n.enter().append("g").classed("legendfill",!0);var r=e.selectAll("g.legendlines").data([t]);r.enter().append("g").classed("legendlines",!0);var a=e.selectAll("g.legendsymbols").data([t]);a.enter().append("g").classed("legendsymbols",!0),a.style("opacity",t[0].trace.opacity),a.selectAll("g.legendpoints").data([t]).enter().append("g").classed("legendpoints",!0)}).each(o).each(i).each(l).each(r).each(a)}},{"../../lib":102,"../../plots/plots":143,"../../traces/pie/style_one":234,"../../traces/scatter/subtypes":255,"../color":25,"../drawing":48,d3:16}],70:[function(t,e,n){"use strict";function r(t,e){var n=e.currentTarget,r=n.getAttribute("data-attr"),a=n.getAttribute("data-val")||!0,o=t._fullLayout,i={};if("zoom"===r){for(var l,s,u="in"===a?.5:2,f=(1+u)/2,d=(1-u)/2,h=c.Axes.list(t,null,!0),p=0;py;y++){var x=l[y];d=v[x]={};for(var b=0;b1)return r(["resetViews","toggleHover"]),i(m,n);u&&(r(["zoom3d","pan3d","orbitRotation","tableRotation"]),r(["resetCameraDefault3d","resetCameraLastSave3d"]),r(["hoverClosest3d"])),d&&(r(["zoomInGeo","zoomOutGeo","resetGeo"]),r(["hoverClosestGeo"]));var v=a(l),y=[];return((c||p)&&!v||g)&&(y=["zoom2d","pan2d"]),(c||g)&&o(s)&&(y.push("select2d"),y.push("lasso2d")),y.length&&r(y),!c&&!p||v||g||r(["zoomIn2d","zoomOut2d","autoScale2d","resetScale2d"]),c&&h?r(["toggleHover"]):p?r(["hoverClosestGl2d"]):c?r(["hoverClosestCartesian","hoverCompareCartesian"]):h&&r(["hoverClosestPie"]),i(m,n)}function a(t){for(var e=s.Axes.list({_fullLayout:t},null,!0),n=!0,r=0;r0);if(p){var g=a(e,n,s);u("x",g[0]),u("y",g[1]),o.noneOrAll(t,e,["x","y"]),u("xanchor"),u("yanchor"),o.coerceFont(u,"font",n.font);var m=u("bgcolor");u("activecolor",i.contrast(m,c.lightAmount,c.darkAmount)),u("bordercolor"),u("borderwidth")}}},{"../../lib":102,"../color":25,"./attributes":73,"./button_attributes":74,"./constants":75}],77:[function(t,e,n){"use strict";function r(t){for(var e=v.list(t,"x",!0),n=[],r=0;re){var n=e;e=t,t=n}l.setAttributes(w,{"data-min":t,"data-max":e}),l.setAttributes(P,{x:t,width:e-t}),l.setAttributes(A,{width:t}),l.setAttributes(T,{x:e,width:p-e}),l.setAttributes(L,{transform:"translate("+(t-m-1)+")"}),l.setAttributes(C,{transform:"translate("+e+")"})}var f=t._fullLayout,d=f._infolayer.selectAll("g.range-slider"),h=f.xaxis.rangeslider,p=f._size.w,g=(f.height-f.margin.b-f.margin.t)*h.thickness,m=2,v=Math.floor(h.borderwidth/2),y=f.margin.l,x=f.height-g-f.margin.b,b=0,_=p,w=document.createElementNS(i,"g");l.setAttributes(w,{"class":"range-slider","data-min":b,"data-max":_,"pointer-events":"all",transform:"translate("+y+","+x+")"});var k=document.createElementNS(i,"rect"),M=h.borderwidth%2===0?h.borderwidth:h.borderwidth-1; +-l.setAttributes(k,{fill:h.bgcolor,stroke:h.bordercolor,"stroke-width":h.borderwidth,height:g+M,width:p+M,transform:"translate(-"+v+", -"+v+")","shape-rendering":"crispEdges"});var A=document.createElementNS(i,"rect");l.setAttributes(A,{x:0,width:b,height:g,fill:"rgba(0,0,0,0.4)"});var T=document.createElementNS(i,"rect");l.setAttributes(T,{x:_,width:p-_,height:g,fill:"rgba(0,0,0,0.4)"});var L=document.createElementNS(i,"g"),z=document.createElementNS(i,"rect"),S=document.createElementNS(i,"rect");l.setAttributes(L,{transform:"translate("+(b-m-1)+")"}),l.setAttributes(z,{width:10,height:g,x:-6,fill:"transparent",cursor:"col-resize"}),l.setAttributes(S,{width:m,height:g/2,y:g/4,rx:1,fill:"white",stroke:"#666","shape-rendering":"crispEdges"}),l.appendChildren(L,[S,z]);var C=document.createElementNS(i,"g"),E=document.createElementNS(i,"rect"),O=document.createElementNS(i,"rect");l.setAttributes(C,{transform:"translate("+_+")"}),l.setAttributes(E,{width:10,height:g,x:-2,fill:"transparent",cursor:"col-resize"}),l.setAttributes(O,{width:m,height:g/2,y:g/4,rx:1,fill:"white",stroke:"#666","shape-rendering":"crispEdges"}),l.appendChildren(C,[O,E]);var P=document.createElementNS(i,"rect");l.setAttributes(P,{x:b,width:_-b,height:g,cursor:"ew-resize",fill:"transparent"}),w.addEventListener("mousedown",function(t){function n(t){var n,r,f=+t.clientX-o;switch(a){case P:w.style.cursor="ew-resize",n=+l+f,r=+s+f,u(n,r),c(e(n),e(r));break;case z:w.style.cursor="col-resize",n=+l+f,r=+s,u(n,r),c(e(n),e(r));break;case E:w.style.cursor="col-resize",n=+l,r=+s+f,u(n,r),c(e(n),e(r));break;default:w.style.cursor="ew-resize",n=i,r=i+f,u(n,r),c(e(n),e(r))}}function r(){window.removeEventListener("mousemove",n),window.removeEventListener("mouseup",r),w.style.cursor="auto"}var a=t.target,o=t.clientX,i=o-w.getBoundingClientRect().left,l=w.getAttribute("data-min"),s=w.getAttribute("data-max");window.addEventListener("mousemove",n),window.addEventListener("mouseup",r)}),h.range||(h.range=a.getAutoRange(f.xaxis));var N=s(t,p,g);l.appendChildren(w,[k,N,A,T,P,L,C]),n(f.xaxis.range[0],f.xaxis.range[1]),d.data([0]).enter().append(function(){return h.setRange=n,w})}},{"../../constants/xmlns_namespaces":94,"../../lib":102,"../../plotly":120,"../../plots/cartesian/axes":123,"./helpers":83,"./range_plot":85}],82:[function(t,e,n){"use strict";var r=t("../../lib"),a=t("./attributes");e.exports=function(t,e,n,o){function i(t,e){return r.coerce(l,s,a,t,e)}if(t[n].rangeslider){var l=r.isPlainObject(t[n].rangeslider)?t[n].rangeslider:{},s=e[n].rangeslider={};if(i("bgcolor"),i("bordercolor"),i("borderwidth"),i("thickness"),i("visible"),i("range"),s.range&&!e[n].autorange){var c=s.range,u=e[n].range;c[0]=Math.min(c[0],u[0]),c[1]=Math.max(c[1],u[1])}else e[n]._needsExpand=!0;s.visible&&o.forEach(function(t){var n=e[t]||{};n.fixedrange=!0,e[t]=n})}}},{"../../lib":102,"./attributes":80}],83:[function(t,e,n){"use strict";n.setAttributes=function(t,e){for(var n in e)t.setAttribute(n,e[n])},n.appendChildren=function(t,e){for(var n=0;ns;s++){var c=l[s],u={_fullLayout:e},f=A.coerceRef(t,r,u,c);if("path"!==i){var d=.25,h=.75;if("paper"!==f){var p=A.getFromId(u,f),g=o(p);d=g(p.range[0]+d*(p.range[1]-p.range[0])),h=g(p.range[0]+h*(p.range[1]-p.range[0]))}n(c+"0",d),n(c+"1",h)}}return"path"===i?n("path"):M.noneOrAll(t,r,["x0","x1","y0","y1"]),r}function a(t){return"category"===t.type?t.c2l:t.d2l}function o(t){return"category"===t.type?t.l2c:t.l2d}function i(t,e){t.layout.shapes=e,C.supplyLayoutDefaults(t.layout,t._fullLayout),C.drawAll(t)}function l(t){delete t.layout.shapes,t._fullLayout.shapes=[],C.drawAll(t)}function s(t,e,n){for(var r=0;re;a--)h(t,a).selectAll('[data-index="'+(a-1)+'"]').attr("data-index",a),C.draw(t,a)}function f(t,e,n,i){function l(n){var r={"data-index":e,"fill-rule":"evenodd",d:x(t,C)},a=C.line.width?C.line.color:"rgba(0,0,0,0)",o=n.append("path").attr(r).style("opacity",C.opacity).call(T.stroke,a).call(T.fill,C.fillcolor).call(L.dashLine,C.line.dash,C.line.width);E&&o.call(L.setClipUrl,"clip"+t._fullLayout._uid+E),t._context.editable&&d(t,o,C,e)}var s,c;h(t,e).selectAll('[data-index="'+e+'"]').remove();var u=t.layout.shapes[e];if(u){var f={xref:u.xref,yref:u.yref},g={};"string"==typeof n&&n?g[n]=i:M.isPlainObject(n)&&(g=n);var m=Object.keys(g);for(s=0;ss;s++){var b=y[s];if(void 0===g[b]&&void 0!==u[b]){var _,w=b.charAt(0),k=A.getFromId(t,A.coerceRef(f,{},t,w)),z=A.getFromId(t,A.coerceRef(u,{},t,w)),S=u[b];void 0!==g[w+"ref"]&&(k?(_=a(k)(S),S=(_-k.range[0])/(k.range[1]-k.range[0])):S=(S-z.domain[0])/(z.domain[1]-z.domain[0]),z?(_=z.range[0]+S*(z.range[1]-z.range[0]),S=o(z)(_)):S=k.domain[0]+S*(k.domain[1]-k.domain[0])),u[b]=S}}var C=r(u,t._fullLayout);t._fullLayout.shapes[e]=C;var E;if("below"!==C.layer)E=(C.xref+C.yref).replace(/paper/g,""),l(t._fullLayout._shapeUpperLayer);else if("paper"===C.xref&&"paper"===C.yref)E="",l(t._fullLayout._shapeLowerLayer);else{var O,P=t._fullLayout._plots||{},N=Object.keys(P);for(s=0,c=N.length;c>s;s++)O=P[N[s]],E=N[s],p(t,C,O)&&l(O.shapelayer)}}}function d(t,e,n,r){function a(t){var n=W.right-W.left,r=W.bottom-W.top,a=t.clientX-W.left,o=t.clientY-W.top,i=n>G&&r>$&&!t.shiftKey?z.getCursor(a/n,1-o/r):"move";S(e,i),X=i.split("-")[0]}function o(e){B=A.getFromId(t,n.xref),H=A.getFromId(t,n.yref),V=v(t,B),Z=v(t,H,!0),U=y(t,B),Y=y(t,H,!0);var o="shapes["+r+"]";"path"===n.type?(F=n.path,q=o+".path"):(u=V(n.x0),f=Z(n.y0),d=V(n.x1),h=Z(n.y1),p=o+".x0",g=o+".y0",_=o+".x1",w=o+".y1"),d>u?(L=u,P=o+".x0",R="x0",C=d,N=o+".x1",j="x1"):(L=d,P=o+".x1",R="x1",C=u,N=o+".x0",j="x0"),h>f?(M=f,E=o+".y0",D="y0",T=h,O=o+".y1",I="y1"):(M=h,E=o+".y1",D="y1",T=f,O=o+".y0",I="y0"),c={},a(e),Q.moveFn="move"===X?l:s}function i(n){S(e),n&&k.relayout(t,c)}function l(r,a){if("path"===n.type){var o=function(t){return U(V(t)+r)};B&&"date"===B.type&&(o=m(o));var i=function(t){return Y(Z(t)+a)};H&&"date"===H.type&&(i=m(i)),n.path=b(F,o,i),c[q]=n.path}else c[p]=n.x0=U(u+r),c[g]=n.y0=Y(f+a),c[_]=n.x1=U(d+r),c[w]=n.y1=Y(h+a);e.attr("d",x(t,n))}function s(r,a){if("path"===n.type){var o=function(t){return U(V(t)+r)};B&&"date"===B.type&&(o=m(o));var i=function(t){return Y(Z(t)+a)};H&&"date"===H.type&&(i=m(i)),n.path=b(F,o,i),c[q]=n.path}else{var l=~X.indexOf("n")?M+a:M,s=~X.indexOf("s")?T+a:T,u=~X.indexOf("w")?L+r:L,f=~X.indexOf("e")?C+r:C;s-l>$&&(c[E]=n[D]=Y(l),c[O]=n[I]=Y(s)),f-u>G&&(c[P]=n[R]=U(u),c[N]=n[j]=U(f))}e.attr("d",x(t,n))}var c,u,f,d,h,p,g,_,w,M,T,L,C,E,O,P,N,D,I,R,j,F,q,B,H,V,Z,U,Y,X,G=10,$=10,Q={setCursor:a,element:e.node(),prepFn:o,doneFn:i},W=Q.element.getBoundingClientRect();z.init(Q)}function h(t,e){var n=t._fullLayout.shapes[e],r=t._fullLayout._shapeUpperLayer;return n?"below"===n.layer&&(r="paper"===n.xref&&"paper"===n.yref?t._fullLayout._shapeLowerLayer:t._fullLayout._shapeSubplotLayer):M.log("getShapeLayer: undefined shape: index",e),r}function p(t,e,n){var r=k.Axes.getFromId(t,n.id,"x")._id,a=k.Axes.getFromId(t,n.id,"y")._id,o="below"===e.layer,i=r===e.xref||a===e.yref,l=!!n.shapelayer;return o&&i&&l}function g(t){return function(e){return e.replace&&(e=e.replace("_"," ")),t(e)}}function m(t){return function(e){return t(e).replace(" ","_")}}function v(t,e,n){var r,o=t._fullLayout._size;if(e){var i=a(e);r=function(t){return e._offset+e.l2p(i(t,!0))},"date"===e.type&&(r=g(r))}else r=n?function(t){return o.t+o.h*(1-t)}:function(t){return o.l+o.w*t};return r}function y(t,e,n){var r,a=t._fullLayout._size;if(e){var i=o(e);r=function(t){return i(e.p2l(t-e._offset))}}else r=n?function(t){return 1-(t-a.t)/a.h}:function(t){return(t-a.l)/a.w};return r}function x(t,e){var n,r,o,i,l=e.type,s=A.getFromId(t,e.xref),c=A.getFromId(t,e.yref),u=t._fullLayout._size;if(s?(n=a(s),r=function(t){return s._offset+s.l2p(n(t,!0))}):r=function(t){return u.l+u.w*t},c?(o=a(c),i=function(t){return c._offset+c.l2p(o(t,!0))}):i=function(t){return u.t+u.h*(1-t)},"path"===l)return s&&"date"===s.type&&(r=g(r)),c&&"date"===c.type&&(i=g(i)),C.convertPath(e.path,r,i);var f=r(e.x0),d=r(e.x1),h=i(e.y0),p=i(e.y1);if("line"===l)return"M"+f+","+h+"L"+d+","+p;if("rect"===l)return"M"+f+","+h+"H"+d+"V"+p+"H"+f+"Z";var m=(f+d)/2,v=(h+p)/2,y=Math.abs(m-f),x=Math.abs(v-h),b="A"+y+","+x,_=m+y+","+v,w=m+","+(v-x);return"M"+_+b+" 0 1,1 "+w+b+" 0 0,1 "+_+"Z"}function b(t,e,n){return t.replace(E,function(t){var r=0,a=t.charAt(0),o=P[a],i=N[a],l=D[a],s=t.substr(1).replace(O,function(t){return r>=l?t:(o[r]?t=e(t):i[r]&&(t=n(t)),r++,t)});return a+s})}function _(t,e,n,r,a){var o="category"===t.type?Number:t.d2c;if(void 0!==e)return[o(e),o(n)];if(r){var i,l,s,c,u,f=1/0,d=-(1/0),h=r.match(E);for("date"===t.type&&(o=g(o)),i=0;iu&&(f=u),u>d&&(d=u)));return d>=f?[f,d]:void 0}}var w=t("fast-isnumeric"),k=t("../../plotly"),M=t("../../lib"),A=t("../../plots/cartesian/axes"),T=t("../color"),L=t("../drawing"),z=t("../dragelement"),S=t("../../lib/setcursor"),C=e.exports={};C.layoutAttributes=t("./attributes"),C.supplyLayoutDefaults=function(t,e){for(var n=t.shapes||[],a=e.shapes=[],o=0;ol&&(t="X"),t});return r>l&&(s=s.replace(/[\s,]*X.*/,""),M.log("Ignoring extra params in segment "+t)),a+s})},C.calcAutorange=function(t){var e,n,r,a,o,i=t._fullLayout,l=i.shapes;if(l.length&&t._fullData.length)for(e=0;ed?n=d:(u.left-=x.offsetLeft,u.right-=x.offsetLeft,u.top-=x.offsetTop,u.bottom-=x.offsetTop,x.selection.each(function(){var t=s.bBox(this);l.bBoxIntersect(u,t,c)&&(n=Math.max(n,i*(t[x.side]-u[o])+c))}),n=Math.min(d,n)),n>0||0>d){var h={left:[-n,0],right:[n,0],top:[0,-n],bottom:[0,n]}[x.side];e.attr("transform","translate("+h+")")}}}function p(){L=0,z=!0,S=E,k._infolayer.select("."+e).attr({"data-unformatted":S}).text(S).on("mouseover.opacity",function(){r.select(this).transition().duration(100).style("opacity",1)}).on("mouseout.opacity",function(){r.select(this).transition().duration(1e3).style("opacity",0)})}var g=n.propContainer,m=n.propName,v=n.traceIndex,y=n.dfltName,x=n.avoid||{},b=n.attributes,_=n.transform,w=n.containerGroup,k=t._fullLayout,M=g.titlefont.family,A=g.titlefont.size,T=g.titlefont.color,L=1,z=!1,S=g.title.trim();""===S&&(L=0),S.match(/Click to enter .+ title/)&&(L=.2,z=!0),w||(w=k._infolayer.selectAll(".g-"+e).data([0]),w.enter().append("g").classed("g-"+e,!0));var C=w.selectAll("text").data([0]);C.enter().append("text"),C.text(S).attr("class",e),C.attr({"data-unformatted":S}).call(f);var E="Click to enter "+y+" title";t._context.editable?(S||p(),C.call(u.makeEditable).on("edit",function(e){void 0!==v?o.restyle(t,m,e,v):o.relayout(t,m,e)}).on("cancel",function(){this.text(this.attr("data-unformatted")).call(f)}).on("input",function(t){this.text(t||" ").attr(b).selectAll("tspan.line").attr(b)})):S&&!S.match(/Click to enter .+ title/)||C.remove(),C.classed("js-placeholder",z)}},{"../../lib":102,"../../lib/svg_text_utils":113,"../../plotly":120,"../../plots/plots":143,"../color":25,"../drawing":48,d3:16,"fast-isnumeric":18}],89:[function(t,e,n){"use strict";var r=t("../../plots/font_attributes"),a=t("../color/attributes"),o=t("../../lib/extend").extendFlat,i={_isLinkedToArray:!0,method:{valType:"enumerated",values:["restyle","relayout"],dflt:"restyle"},args:{valType:"info_array",freeLength:!0,items:[{valType:"any"},{valType:"any"},{valType:"any"}]},label:{valType:"string",dflt:""}};e.exports={_isLinkedToArray:!0,visible:{valType:"boolean"},active:{valType:"integer",min:-1,dflt:0},buttons:i,x:{valType:"number",min:-2,max:3,dflt:-.05},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"right"},y:{valType:"number",min:-2,max:3,dflt:1},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"bottom"},font:o({},r,{}),bgcolor:{valType:"color"},bordercolor:{valType:"color",dflt:a.borderLine},borderwidth:{valType:"number",min:0,dflt:1}}},{"../../lib/extend":100,"../../plots/font_attributes":141,"../color/attributes":24}],90:[function(t,e,n){"use strict";e.exports={name:"updatemenus",itemName:"updatemenu",containerClassName:"updatemenu-container",headerGroupClassName:"updatemenu-header-group",headerClassName:"updatemenu-header",headerArrowClassName:"updatemenu-header-arrow",buttonGroupClassName:"updatemenu-button-group",buttonClassName:"updatemenu-button",itemRectClassName:"updatemenu-item-rect",itemTextClassName:"updatemenu-item-text",menuIndexAttrName:"updatemenu-active-index",autoMarginIdRoot:"updatemenu-",blankHeaderOpts:{label:" "},minWidth:30,minHeight:30,textPadX:40,fontSizeToHeight:1.3,rx:2,ry:2,textOffsetX:12,textOffsetY:3,arrowOffsetX:4,gapButtonHeader:5,gapButton:2,activeColor:"#F4FAFF",hoverColor:"#F4FAFF"}},{}],91:[function(t,e,n){"use strict";function r(t,e,n){function r(n,r){return o.coerce(t,e,i,n,r)}var l=a(t,e),s=r("visible",l.length>0);s&&(r("active"),r("x"),r("y"),o.noneOrAll(t,e,["x","y"]),r("xanchor"),r("yanchor"),o.coerceFont(r,"font",n.font),r("bgcolor",n.paper_bgcolor),r("bordercolor"),r("borderwidth"))}function a(t,e){function n(t,e){return o.coerce(r,a,c,t,e)}for(var r,a,i=t.buttons||[],l=e.buttons=[],s=0;s0?[0]:[]);if(s.enter().append("g").classed(T.containerClassName,!0).style("cursor","pointer"),s.exit().remove(),s.exit().size()&&v(t),0!==n.length){var c=s.selectAll("g."+T.headerGroupClassName).data(n,a);c.enter().append("g").classed(T.headerGroupClassName,!0);var u=s.selectAll("g."+T.buttonGroupClassName).data([0]);u.enter().append("g").classed(T.buttonGroupClassName,!0).style("pointer-events","all"),c.enter().size()&&u.call(m).attr(T.menuIndexAttrName,"-1"),c.exit().each(function(e){y.select(this).remove(),u.call(m).attr(T.menuIndexAttrName,"-1"),b.autoMargin(t,T.autoMarginIdRoot+e._index)});for(var f=0;fa.max?e.set(n):e.set(+t)}},integer:{coerceFunction:function(t,e,n,a){t%1||!r(t)||void 0!==a.min&&ta.max?e.set(n):e.set(+t)}},string:{coerceFunction:function(t,e,n,r){if("string"!=typeof t){var a="number"==typeof t;r.strict!==!0&&a?e.set(String(t)):e.set(n)}else r.noBlank&&!t?e.set(n):e.set(t)}},color:{coerceFunction:function(t,e,n){a(t).isValid()?e.set(t):e.set(n)}},colorscale:{coerceFunction:function(t,e,n){e.set(i(t,n))}},angle:{coerceFunction:function(t,e,n){"auto"===t?e.set("auto"):r(t)?(Math.abs(t)>180&&(t-=360*Math.round(t/360)),e.set(+t)):e.set(n)}},subplotid:{coerceFunction:function(t,e,n){var r=n.length;return"string"==typeof t&&t.substr(0,r)===n&&l.test(t.substr(r))?void e.set(t):void e.set(n)},validateFunction:function(t,e){var n=e.dflt,r=n.length;return t===n?!0:"string"!=typeof t?!1:!(t.substr(0,r)!==n||!l.test(t.substr(r)))}},flaglist:{coerceFunction:function(t,e,n,r){if("string"!=typeof t)return void e.set(n);if(-1!==(r.extras||[]).indexOf(t))return void e.set(t);for(var a=t.split("+"),o=0;o2)return!1;var s=i[0].split("-");if(s.length>3||3!==s.length&&i[1])return!1;if(4===s[0].length)n=Number(s[0]);else{if(2!==s[0].length)return!1;var c=(new Date).getFullYear();n=((Number(s[0])-c+70)%100+200)%100+c-70}return l(n)?1===s.length?new Date(n,0,1).getTime():(r=Number(s[1])-1,s[1].length>2||!(r>=0&&11>=r)?!1:2===s.length?new Date(n,r,1).getTime():(a=Number(s[2]),s[2].length>2||!(a>=1&&31>=a)?!1:(a=new Date(n,r,a).getTime(),i[1]?(s=i[1].split(":"),s.length>3?!1:(o=Number(s[0]),s[0].length>2||!(o>=0&&23>=o)?!1:(a+=36e5*o,1===s.length?a:(r=Number(s[1]),s[1].length>2||!(r>=0&&59>=r)?!1:(a+=6e4*r,2===s.length?a:(t=Number(s[2]),t>=0&&60>t?a+1e3*t:!1)))))):a))):!1},n.isDateTime=function(t){return n.dateTime2ms(t)!==!1},n.ms2DateTime=function(t,e){if("undefined"==typeof i)return void s.error("d3 is not defined.");e||(e=0);var n=new Date(t),a=i.time.format("%Y-%m-%d")(n); +-return 7776e6>e?(a+=" "+r(n.getHours(),2),432e6>e&&(a+=":"+r(n.getMinutes(),2),108e5>e&&(a+=":"+r(n.getSeconds(),2),3e5>e&&(a+="."+r(n.getMilliseconds(),3)))),a.replace(/([:\s]00)*\.?[0]*$/,"")):a};var c={H:["%H:%M:%S~%L","%H:%M:%S","%H:%M"],I:["%I:%M:%S~%L%p","%I:%M:%S%p","%I:%M%p"],D:["%H","%I%p","%Hh"]},u={Y:["%Y~%m~%d","%Y%m%d","%y%m%d","%m~%d~%Y","%d~%m~%Y"],Yb:["%b~%d~%Y","%d~%b~%Y","%Y~%d~%b","%Y~%b~%d"],y:["%m~%d~%y","%d~%m~%y","%y~%m~%d"],yb:["%b~%d~%y","%d~%b~%y","%y~%d~%b","%y~%b~%d"]},f=i.time.format.utc,d={Y:{H:["%Y~%m~%dT%H:%M:%S","%Y~%m~%dT%H:%M:%S~%L"].map(f),I:[],D:["%Y%m%d%H%M%S","%Y~%m","%m~%Y"].map(f)},Yb:{H:[],I:[],D:["%Y~%b","%b~%Y"].map(f)},y:{H:[],I:[],D:[]},yb:{H:[],I:[],D:[]}};["Y","Yb","y","yb"].forEach(function(t){u[t].forEach(function(e){d[t].D.push(f(e)),["H","I","D"].forEach(function(n){c[n].forEach(function(r){var a=d[t][n];a.push(f(e+"~"+r)),a.push(f(r+"~"+e))})})})});var h=/[a-z]*/g,p=function(t){return t.substr(0,3)},g=/(mon|tue|wed|thu|fri|sat|sun|the|of|st|nd|rd|th)/g,m=/[\s,\/\-\.\(\)]+/g,v=/~?([ap])~?m(~|$)/,y=function(t,e){return e+"m "},x=/\d\d\d\d/,b=/(^|~)[a-z]{3}/,_=/[ap]m/,w=/:/,k=/q([1-4])/,M=["31~mar","30~jun","30~sep","31~dec"],A=function(t,e){return M[e-1]},T=/ ?([+\-]\d\d:?\d\d|Z)$/;n.parseDate=function(t){if(t.getTime)return t;if("string"!=typeof t)return!1;t=t.toLowerCase().replace(h,p).replace(g,"").replace(m,"~").replace(v,y).replace(k,A).trim().replace(T,"");var e,n,r=null,i=a(t),l=o(t);e=d[i][l],n=e.length;for(var s=0;n>s&&!(r=e[s].parse(t));s++);if(!(r instanceof Date))return!1;var c=r.getTimezoneOffset();return r.setTime(r.getTime()+60*c*1e3),r}},{"../lib":102,d3:16,"fast-isnumeric":18}],99:[function(t,e,n){"use strict";var r=t("events").EventEmitter,a={init:function(t){if(t._ev instanceof r)return t;var e=new r;return t._ev=e,t.on=e.on.bind(e),t.once=e.once.bind(e),t.removeListener=e.removeListener.bind(e),t.removeAllListeners=e.removeAllListeners.bind(e),t.emit=function(n,r){"undefined"!=typeof jQuery&&jQuery(t).trigger(n,r),e.emit(n,r)},t},triggerHandler:function(t,e,n){var r,a;"undefined"!=typeof jQuery&&(r=jQuery(t).triggerHandler(e,n));var o=t._ev;if(!o)return r;var i=o._events[e];if(!i)return r;"function"==typeof i&&(i=[i]);for(var l=i.pop(),s=0;sv;v++){s=t[v];for(c in s)u=g[c],f=s[c],l&&i(f)?g[c]=f:e&&f&&(o(f)||(d=i(f)))?(d?(d=!1,h=u&&i(u)?u:[]):h=u&&o(u)?u:{},g[c]=a([h,f],e,n,l)):("undefined"!=typeof f||n)&&(g[c]=f)}return g}var o=t("./is_plain_object.js"),i=Array.isArray;n.extendFlat=function(){return a(arguments,!1,!1,!1)},n.extendDeep=function(){return a(arguments,!0,!1,!1)},n.extendDeepAll=function(){return a(arguments,!0,!0,!1)},n.extendDeepNoArrays=function(){return a(arguments,!0,!1,!0)}},{"./is_plain_object.js":103}],101:[function(t,e,n){"use strict";e.exports=function(t){for(var e=[],n=0;nn?Math.max(n,Math.min(e,t)):Math.max(e,Math.min(n,t))},a.bBoxIntersect=function(t,e,n){return n=n||0,t.left<=e.right+n&&e.left<=t.right+n&&t.top<=e.bottom+n&&e.top<=t.bottom+n},a.identity=function(t){return t},a.randstr=function d(t,e,n){if(n||(n=16),void 0===e&&(e=24),0>=e)return"0";var r,a,o,i=Math.log(Math.pow(2,e))/Math.log(n),l="";for(r=2;i===1/0;r*=2)i=Math.log(Math.pow(2,e/r))/Math.log(n)*r;var s=i-Math.floor(i);for(r=0;r-1||c!==1/0&&c>=Math.pow(2,e)?d(t,e,n):l},a.OptionControl=function(t,e){t||(t={}),e||(e="opt");var n={};return n.optionList=[],n._newoption=function(r){r[e]=t,n[r.name]=r,n.optionList.push(r)},n["_"+e]=t,n},a.smooth=function(t,e){if(e=Math.round(e)||0,2>e)return t;var n,r,a,o,i=t.length,l=2*i,s=2*e-1,c=new Array(s),u=new Array(i);for(n=0;s>n;n++)c[n]=(1-Math.cos(Math.PI*(n+1)/e))/(2*e);for(n=0;i>n;n++){for(o=0,r=0;s>r;r++)a=n+r+1-e,-i>a?a-=l*Math.round(a/l):a>=l&&(a-=l*Math.floor(a/l)),0>a?a=-1-a:a>=i&&(a=l-1-a),o+=t[a]*c[r];u[n]=o}return u},a.syncOrAsync=function(t,e,n){function r(){return a.syncOrAsync(t,e,n)}for(var o,i;t.length;)if(i=t.splice(0,1)[0],o=i(e),o&&o.then)return o.then(r).then(void 0,a.promiseError);return n&&n(e)},a.stripTrailingSlash=function(t){return"/"===t.substr(-1)?t.substr(0,t.length-1):t},a.noneOrAll=function(t,e,n){if(t){var r,a,o=!1,i=!0;for(r=0;ra;a++)e[a][n]=t[a]},a.minExtend=function(t,e){var n={};"object"!=typeof e&&(e={});var r,o,i,l=3,s=Object.keys(t);for(r=0;r1?r+o[1]:"";if(a&&(o.length>1||i.length>4))for(;n.test(i);)i=i.replace(n,"$1"+a+"$2");return i+l}},{"./coerce":97,"./dates":98,"./extend":100,"./is_plain_object":103,"./loggers":104,"./matrix":105,"./nested_property":106,"./notifier":107,"./search":110,"./stats":112,d3:16}],103:[function(t,e,n){"use strict";e.exports=function(t){return window&&window.process&&window.process.versions?"[object Object]"===Object.prototype.toString.call(t):"[object Object]"===Object.prototype.toString.call(t)&&Object.getPrototypeOf(t)===Object.prototype}},{}],104:[function(t,e,n){"use strict";var r=t("../plot_api/plot_config"),a=e.exports={};a.log=function(){if(r.logging>1){for(var t=["LOG:"],e=0;e0){for(var t=["WARN:"],e=0;e0){for(var t=["ERROR:"],e=0;er;r++)n[r]=new Array(e);return n},n.transposeRagged=function(t){var e,n,r=0,a=t.length;for(e=0;a>e;e++)r=Math.max(r,t[e].length);var o=new Array(r);for(e=0;r>e;e++)for(o[e]=new Array(a),n=0;a>n;n++)o[e][n]=t[n][e];return o},n.dot=function(t,e){if(!t.length||!e.length||t.length!==e.length)return null;var r,a,o=t.length;if(t[0].length)for(r=new Array(o),a=0;o>a;a++)r[a]=n.dot(t[a],e);else if(e[0].length){var i=n.transposeRagged(e);for(r=new Array(i.length),a=0;aa;a++)r+=t[a]*e[a];return r},n.translationMatrix=function(t,e){return[[1,0,t],[0,1,e],[0,0,1]]},n.rotationMatrix=function(t){var e=t*Math.PI/180;return[[Math.cos(e),-Math.sin(e),0],[Math.sin(e),Math.cos(e),0],[0,0,1]]},n.rotationXYMatrix=function(t,e,r){return n.dot(n.dot(n.translationMatrix(e,r),n.rotationMatrix(t)),n.translationMatrix(-e,-r))},n.apply2DTransform=function(t){return function(){var e=arguments;3===e.length&&(e=e[0]);var r=1===arguments.length?e[0]:[e[0],e[1]];return n.dot(t,[r[0],r[1],1]).slice(0,2)}},n.apply2DTransform2=function(t){var e=n.apply2DTransform(t);return function(t){return e(t.slice(0,2)).concat(e(t.slice(2,4)))}}},{}],106:[function(t,e,n){"use strict";function r(t,e){return function(){var n,a,o,i,l,s=t;for(i=0;i=0;e--){if(r=t[e],i=!1,Array.isArray(r))for(n=r.length-1;n>=0;n--)c(r[n])?i?r[n]=void 0:r.pop():i=!0;else if("object"==typeof r&&null!==r)for(o=Object.keys(r),i=!1,n=o.length-1;n>=0;n--)c(r[o[n]])&&!a(r[o[n]],o[n])?delete r[o[n]]:i=!0;if(i)return}}function c(t){return void 0===t||null===t?!0:"object"!=typeof t?!1:Array.isArray(t)?!t.length:!Object.keys(t).length}function u(t,e,n){return{set:function(){throw"bad container"},get:function(){},astr:e,parts:n,obj:t}}var f=t("fast-isnumeric");e.exports=function(t,e){if(f(e))e=String(e);else if("string"!=typeof e||"[-1]"===e.substr(e.length-4))throw"bad property string";for(var n,a,i,l=0,s=e.split(".");ln||n>o||i>r||r>l?!1:!e||!c(t)}function n(t,e){var n=t[0],s=t[1];if(a>n||n>o||i>s||s>l)return!1;var c,u,f,d,h,p=r.length,g=r[0][0],m=r[0][1],v=0;for(c=1;p>c;c++)if(u=g,f=m,g=r[c][0],m=r[c][1],d=Math.min(u,g),!(d>n||n>Math.max(u,g)||s>Math.max(f,m)))if(s=s&&n!==d&&v++}return v%2===1}var r=t.slice(),a=r[0][0],o=a,i=r[0][1],l=i;r.push(r[0]);for(var s=1;so;o++)if(i=[t[o][0]-s[0],t[o][1]-s[1]],l=r(i,c),0>l||l>u||Math.abs(r(i,d))>a)return!0;return!1};a.filter=function(t,e){function n(n){t.push(n);var l=r.length,s=a;r.splice(i+1);for(var c=s+1;c1){var l=t.pop();n(l)}return{addPt:n,raw:t,filtered:r}}},{"./matrix":105}],109:[function(t,e,n){"use strict";function r(t,e){for(var n,r=[],o=0;oo.queueLength&&(t.undoQueue.queue.shift(),t.undoQueue.index--)))},i.startSequence=function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!0,t.undoQueue.beginSequence=!0},i.stopSequence=function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!1,t.undoQueue.beginSequence=!1},i.undo=function(t){var e,n;if(t.framework&&t.framework.isPolar)return void t.framework.undo();if(!(void 0===t.undoQueue||isNaN(t.undoQueue.index)||t.undoQueue.index<=0)){for(t.undoQueue.index--,e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,n=0;n=t.undoQueue.queue.length)){for(e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,n=0;nt}function a(t,e){return e>=t}function o(t,e){return t>e}function i(t,e){return t>=e}var l=t("fast-isnumeric"),s=t("../lib");n.findBin=function(t,e,n){if(l(e.start))return n?Math.ceil((t-e.start)/e.size)-1:Math.floor((t-e.start)/e.size);var c,u,f=0,d=e.length,h=0;for(u=e[e.length-1]>=e[0]?n?r:a:n?i:o;d>f&&h++<100;)c=Math.floor((f+d)/2),u(e[c],t)?f=c+1:d=c;return h>90&&s.log("Long binary search..."),f-1},n.sorterAsc=function(t,e){return t-e},n.sorterDes=function(t,e){return e-t},n.distinctVals=function(t){var e=t.slice();e.sort(n.sorterAsc);for(var r=e.length-1,a=e[r]-e[0]||1,o=a/(r||1)/1e4,i=[e[0]],l=0;r>l;l++)e[l+1]>e[l]+o&&(a=Math.min(a,e[l+1]-e[l]),i.push(e[l+1]));return{vals:i,minDiff:a}},n.roundUp=function(t,e,n){for(var r,a=0,o=e.length-1,i=0,l=n?0:1,s=n?1:0,c=n?Math.ceil:Math.floor;o>a&&i++<100;)r=c((a+o)/2),e[r]<=t?a=r+l:o=r-s;return e[a]}},{"../lib":102,"fast-isnumeric":18}],111:[function(t,e,n){"use strict";e.exports=function(t,e){(t.attr("class")||"").split(" ").forEach(function(e){0===e.indexOf("cursor-")&&t.classed(e,!1)}),e&&t.classed("cursor-"+e,!0)}},{}],112:[function(t,e,n){"use strict";var r=t("fast-isnumeric");n.aggNums=function(t,e,a,o){var i,l;if(o||(o=a.length),r(e)||(e=!1),Array.isArray(a[0])){for(l=new Array(o),i=0;o>i;i++)l[i]=n.aggNums(t,e,a[i]);a=l}for(i=0;o>i;i++)r(e)?r(a[i])&&(e=t(+e,+a[i])):e=a[i];return e},n.len=function(t){return n.aggNums(function(t){return t+1},0,t)},n.mean=function(t,e){return e||(e=n.len(t)),n.aggNums(function(t,e){return t+e},0,t)/e},n.variance=function(t,e,a){return e||(e=n.len(t)),r(a)||(a=n.mean(t,e)),n.aggNums(function(t,e){return t+Math.pow(e-a,2)},0,t)/e},n.stdev=function(t,e,r){return Math.sqrt(n.variance(t,e,r))},n.interp=function(t,e){if(!r(e))throw"n should be a finite number";if(e=e*t.length-.5,0>e)return t[0];if(e>t.length-1)return t[t.length-1];var n=e%1;return n*t[Math.ceil(e)]+(1-n)*t[Math.floor(e)]}},{"fast-isnumeric":18}],113:[function(t,e,n){"use strict";function r(t,e){return t.node().getBoundingClientRect()[e]}function a(t){return t.replace(/(<|<|<)/g,"\\lt ").replace(/(>|>|>)/g,"\\gt ")}function o(t,e,n){var r="math-output-"+c.Lib.randstr([],64),o=u.select("body").append("div").attr({id:r}).style({visibility:"hidden",position:"absolute"}).style({"font-size":e.fontSize+"px"}).text(a(t));MathJax.Hub.Queue(["Typeset",MathJax.Hub,o.node()],function(){var e=u.select("body").select("#MathJax_SVG_glyphs");if(o.select(".MathJax_SVG").empty()||!o.select("svg").node())f.log("There was an error in the tex syntax.",t),n();else{var r=o.select("svg").node().getBoundingClientRect();n(o.select(".MathJax_SVG"),e,r)}o.remove()})}function i(t){return(t||"").replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")}function l(t){for(var e=t.split(/(<[^<>]*>)/).map(function(t){var e=t.match(/<(\/?)([^ >]*)\s*(.*)>/i),n=e&&e[2].toLowerCase(),r=p[n];if(void 0!==r){var a=e[1],o=e[3],l=o.match(/^style\s*=\s*"([^"]+)"\s*/i);if("a"===n){if(a)return"
";if("href"!==o.substr(0,4).toLowerCase())return"";var s=o.substr(4).replace(/["']/g,"").replace(/=/,""),u=document.createElement("a");return u.href=s,-1===g.indexOf(u.protocol)?"":''}if("br"===n)return"
";if(a)return"sup"===n?'':"sub"===n?'':"";var f=""}return c.util.xml_entity_encode(t).replace(/");r>0;r=e.indexOf("
",r+1))n.push(r);var a=0;n.forEach(function(t){for(var n=t+a,r=e.slice(0,n),o="",i=r.length-1;i>=0;i--){var l=r[i].match(/<(\/?).*>/i);if(l&&"
"!==r[i]){l[1]||(o=r[i]);break}}o&&(e.splice(n+1,0,o),e.splice(n,0,""),a+=2)});var o=e.join(""),l=o.split(/
/gi);return l.length>1&&(e=l.map(function(t,e){return''+t+""})),e.join("")}function s(t,e,n){var r,a,o,i=n.horizontalAlign,l=n.verticalAlign||"top",s=t.node().getBoundingClientRect(),c=e.node().getBoundingClientRect();return a="bottom"===l?function(){return s.bottom-r.height}:"middle"===l?function(){return s.top+(s.height-r.height)/2}:function(){return s.top},o="right"===i?function(){return s.right-r.width}:"center"===i?function(){return s.left+(s.width-r.width)/2}:function(){return s.left},function(){return r=this.node().getBoundingClientRect(),this.style({top:a()-c.top+"px",left:o()-c.left+"px","z-index":1e3}),this}}var c=t("../plotly"),u=t("d3"),f=t("../lib"),d=t("../constants/xmlns_namespaces"),h=e.exports={};u.selection.prototype.appendSVG=function(t){for(var e=['',t,""].join(""),n=(new DOMParser).parseFromString(e,"application/xml"),r=n.documentElement.firstChild;r;)this.node().appendChild(this.node().ownerDocument.importNode(r,!0)),r=r.nextSibling;return n.querySelector("parsererror")?(f.log(n.querySelector("parsererror div").textContent),null):u.select(this.node().lastChild)},h.html_entity_decode=function(t){var e=u.select("body").append("div").style({display:"none"}).html(""),n=t.replace(/(&[^;]*;)/gi,function(t){return"<"===t?"<":"&rt;"===t?">":e.html(t).text()});return e.remove(),n},h.xml_entity_encode=function(t){return t.replace(/&(?!\w+;|\#[0-9]+;| \#x[0-9A-F]+;)/g,"&")},h.convertToTspans=function(t,e){function n(){h.empty()||(p=s.attr("class")+"-math",h.select("svg."+p).remove()),t.text("").style({visibility:"visible","white-space":"pre"}),d=t.appendSVG(i),d||t.text(a),t.select("a").size()&&t.style("pointer-events","all"),e&&e.call(s)}var a=t.text(),i=l(a),s=t,f=!s.attr("data-notex")&&i.match(/([^$]*)([$]+[^$]*[$]+)([^$]*)/),d=a,h=u.select(s.node().parentNode);if(!h.empty()){var p=s.attr("class")?s.attr("class").split(" ")[0]:"text";p+="-math",h.selectAll("svg."+p).remove(),h.selectAll("g."+p+"-group").remove(),t.style({visibility:null});for(var g=t.node();g&&g.removeAttribute;g=g.parentNode)g.removeAttribute("data-bb");if(f){var m=c.Lib.getPlotDiv(s.node());(m&&m._promises||[]).push(new Promise(function(t){s.style({visibility:"hidden"});var a={fontSize:parseInt(s.style("font-size"),10)};o(f[2],a,function(a,o,i){h.selectAll("svg."+p).remove(),h.selectAll("g."+p+"-group").remove();var l=a&&a.select("svg");if(!l||!l.node())return n(),void t();var c=h.append("g").classed(p+"-group",!0).attr({"pointer-events":"none"});c.node().appendChild(l.node()),o&&o.node()&&l.node().insertBefore(o.node().cloneNode(!0),l.node().firstChild),l.attr({"class":p,height:i.height,preserveAspectRatio:"xMinYMin meet"}).style({overflow:"visible","pointer-events":"none"});var u=s.style("fill")||"black";l.select("g").attr({fill:u,stroke:u});var f=r(l,"width"),d=r(l,"height"),g=+s.attr("x")-f*{start:0,middle:.5,end:1}[s.attr("text-anchor")||"start"],m=parseInt(s.style("font-size"),10)||r(s,"height"),v=-m/4;"y"===p[0]?(c.attr({transform:"rotate("+[-90,+s.attr("x"),+s.attr("y")]+") translate("+[-f/2,v-d/2]+")"}),l.attr({x:+s.attr("x"),y:+s.attr("y")})):"l"===p[0]?l.attr({x:s.attr("x"),y:v-d/2}):"a"===p[0]?l.attr({x:0,y:v}):l.attr({x:g,y:+s.attr("y")+v-d/2}),e&&e.call(s,c),t(c)})}))}else n();return t}};var p={sup:'font-size:70%" dy="-0.6em',sub:'font-size:70%" dy="0.3em',b:"font-weight:bold",i:"font-style:italic",a:"",span:"",br:"",em:"font-style:italic;font-weight:bold"},g=["http:","https:","mailto:"],m=new RegExp("]*)?/?>","g");h.plainText=function(t){return(t||"").replace(m," ")},h.makeEditable=function(t,e,n){function r(){o(),i.style({opacity:0});var t,e=d.attr("class");t=e?"."+e.split(" ")[0]+"-math-group":"[class*=-math-group]",t&&u.select(i.node().parentNode).select(t).style({opacity:0})}function a(t){var e=t.node(),n=document.createRange();n.selectNodeContents(e);var r=window.getSelection();r.removeAllRanges(),r.addRange(n),e.focus()}function o(){var t=u.select(c.Lib.getPlotDiv(i.node())),e=t.select(".svg-container"),r=e.append("div");r.classed("plugin-editable editable",!0).style({position:"absolute","font-family":i.style("font-family")||"Arial","font-size":i.style("font-size")||12,color:n.fill||i.style("fill")||"black",opacity:1,"background-color":n.background||"transparent",outline:"#ffffff33 1px solid",margin:[-parseFloat(i.style("font-size"))/8+1,0,0,-1].join("px ")+"px",padding:"0","box-sizing":"border-box"}).attr({contenteditable:!0}).text(n.text||i.attr("data-unformatted")).call(s(i,e,n)).on("blur",function(){i.text(this.textContent).style({opacity:1});var t,e=u.select(this).attr("class");t=e?"."+e.split(" ")[0]+"-math-group":"[class*=-math-group]",t&&u.select(i.node().parentNode).select(t).style({opacity:0});var n=this.textContent;u.select(this).transition().duration(0).remove(),u.select(document).on("mouseup",null),l.edit.call(i,n)}).on("focus",function(){var t=this;u.select(document).on("mouseup",function(){return u.event.target===t?!1:void(document.activeElement===r.node()&&r.node().blur())})}).on("keyup",function(){27===u.event.which?(i.style({opacity:1}),u.select(this).style({opacity:0}).on("blur",function(){return!1}).transition().remove(),l.cancel.call(i,this.textContent)):(l.input.call(i,this.textContent),u.select(this).call(s(i,e,n)))}).on("keydown",function(){13===u.event.which&&this.blur()}).call(a)}n||(n={});var i=this,l=u.dispatch("edit","input","cancel"),f=u.select(this.node()).style({"pointer-events":"all"}),d=e||f;return e&&f.style({"pointer-events":"none"}),n.immediate?r():d.on("click",r),u.rebind(this,l,"on")}},{"../constants/xmlns_namespaces":94,"../lib":102,"../plotly":120,d3:16}],114:[function(t,e,n){"use strict";function r(t){var e;if("string"==typeof t){if(e=document.getElementById(t),null===e)throw new Error("No DOM element with id '"+t+"' exists on the page.");return e}if(null===t||void 0===t)throw new Error("DOM element provided is null or undefined");return t}function a(t){Array.isArray(t._promises)&&t._promises.length>0&&N.log("Clearing previous rejected promises from queue."),t._promises=[]}function o(t,e){t._fullLayout._paperdiv.style("background","white"),P.defaultConfig.setBackground(t,e)}function i(t,e){t._context||(t._context=N.extendFlat({},P.defaultConfig));var n=t._context;e&&(Object.keys(e).forEach(function(t){t in n&&("setBackground"===t&&"opaque"===e[t]?n[t]=o:n[t]=e[t])}),e.plot3dPixelRatio&&!n.plotGlPixelRatio&&(n.plotGlPixelRatio=n.plot3dPixelRatio)),n.staticPlot&&(n.editable=!1,n.autosizable=!1,n.scrollZoom=!1,n.doubleClick=!1,n.showTips=!1,n.showLink=!1,n.displayModeBar=!1)}function l(t,e,n){var r=C.select(t).selectAll(".plot-container").data([0]);r.enter().insert("div",":first-child").classed("plot-container plotly",!0);var a=r.selectAll(".svg-container").data([0]);a.enter().append("div").classed("svg-container",!0).style("position","relative"),a.html(""),e&&(t.data=e),n&&(t.layout=n),P.micropolar.manager.fillLayout(t),"initial"===t._fullLayout.autosize&&t._context.autosizable&&(k(t,{}),t._fullLayout.autosize=n.autosize=!0),a.style({width:t._fullLayout.width+"px",height:t._fullLayout.height+"px"}),t.framework=P.micropolar.manager.framework(t),t.framework({data:t.data,layout:t.layout},a.node()),t.framework.setUndoPoint();var o=t.framework.svg(),i=1,l=t._fullLayout.title;""!==l&&l||(i=0);var s="Click to enter title",c=function(){this.call(P.util.convertToTspans)},u=o.select(".title-group text").call(c);if(t._context.editable){u.attr({"data-unformatted":l}),l&&l!==s||(i=.2,u.attr({"data-unformatted":s}).text(s).style({opacity:i}).on("mouseover.opacity",function(){C.select(this).transition().duration(100).style("opacity",1)}).on("mouseout.opacity",function(){C.select(this).transition().duration(1e3).style("opacity",0)}));var f=function(){this.call(P.util.makeEditable).on("edit",function(e){t.framework({layout:{title:e}}),this.attr({"data-unformatted":e}).text(e).call(c),this.call(f)}).on("cancel",function(){var t=this.attr("data-unformatted");this.text(t).call(c)})};u.call(f)}return t._context.setBackground(t,t._fullLayout.paper_bgcolor),R.addLinks(t),Promise.resolve()}function s(t){var e,n;t||(t={}),t.xaxis1&&(t.xaxis||(t.xaxis=t.xaxis1),delete t.xaxis1),t.yaxis1&&(t.yaxis||(t.yaxis=t.yaxis1),delete t.yaxis1);var r=P.Axes.list({_fullLayout:t});for(e=0;ee;e++){var i=t.annotations[e];i.ref&&("paper"===i.ref?(i.xref="paper",i.yref="paper"):"data"===i.ref&&(i.xref="x",i.yref="y"),delete i.ref),c(i,"xref"),c(i,"yref")}void 0===t.shapes||Array.isArray(t.shapes)||(N.warn("Shapes must be an array."), +-delete t.shapes);var l=(t.shapes||[]).length;for(e=0;l>e;e++){var s=t.shapes[e];c(s,"xref"),c(s,"yref")}var u=t.legend;u&&(u.x>3?(u.x=1.02,u.xanchor="left"):u.x<-2&&(u.x=-.02,u.xanchor="right"),u.y>3?(u.y=1.02,u.yanchor="bottom"):u.y<-2&&(u.y=-.02,u.yanchor="top")),"rotate"===t.dragmode&&(t.dragmode="orbit"),t.scene1&&(t.scene||(t.scene=t.scene1),delete t.scene1);var f=R.getSubplotIds(t,"gl3d");for(e=0;en;++n)x[n]=m[e]+v*y[2+4*n];h.camera={eye:{x:x[0],y:x[1],z:x[2]},center:{x:m[0],y:m[1],z:m[2]},up:{x:y[1],y:y[5],z:y[9]}},delete h.cameraposition}}return F.clean(t),t}function c(t,e){var n=t[e],r=e.charAt(0);n&&"paper"!==n&&(t[e]=P.Axes.cleanId(n,r))}function u(t,e){for(var n=[],r=(t.concat(Array.isArray(e)?e:[]).filter(function(t){return"uid"in t}).map(function(t){return t.uid})),a=0;ao&&(l=N.randstr(r),-1!==n.indexOf(l));o++);i.uid=N.randstr(r),r.push(i.uid)}if(n.push(i.uid),"histogramy"===i.type&&"xbins"in i&&!("ybins"in i)&&(i.ybins=i.xbins,delete i.xbins),i.error_y&&"opacity"in i.error_y){var s=F.defaults,c=i.error_y.color||(R.traceIs(i,"bar")?F.defaultLine:s[a%s.length]);i.error_y.color=F.addOpacity(F.rgb(c),F.opacity(c)*i.error_y.opacity),delete i.error_y.opacity}if("bardir"in i&&("h"!==i.bardir||!R.traceIs(i,"bar")&&"histogram"!==i.type.substr(0,9)||(i.orientation="h",_(i)),delete i.bardir),"histogramy"===i.type&&_(i),"histogramx"!==i.type&&"histogramy"!==i.type||(i.type="histogram"),"scl"in i&&(i.colorscale=i.scl,delete i.scl),"reversescl"in i&&(i.reversescale=i.reversescl,delete i.reversescl),i.xaxis&&(i.xaxis=P.Axes.cleanId(i.xaxis,"x")),i.yaxis&&(i.yaxis=P.Axes.cleanId(i.yaxis,"y")),R.traceIs(i,"gl3d")&&i.scene&&(i.scene=R.subplotsRegistry.gl3d.cleanId(i.scene)),R.traceIs(i,"pie")||(Array.isArray(i.textposition)?i.textposition=i.textposition.map(f):i.textposition&&(i.textposition=f(i.textposition))),R.traceIs(i,"2dMap")&&("YIGnBu"===i.colorscale&&(i.colorscale="YlGnBu"),"YIOrRd"===i.colorscale&&(i.colorscale="YlOrRd")),R.traceIs(i,"markerColorscale")&&i.marker){var u=i.marker;"YIGnBu"===u.colorscale&&(u.colorscale="YlGnBu"),"YIOrRd"===u.colorscale&&(u.colorscale="YlOrRd")}if("surface"===i.type&&N.isPlainObject(i.contours)){var h=["x","y","z"];for(o=0;or?o.push(a+r):o.push(r);return o}function g(t,e,n){var r,a;for(r=0;r=t.data.length||a<-t.data.length)throw new Error(n+" must be valid indices for gd.data.");if(e.indexOf(a,r+1)>-1||a>=0&&e.indexOf(-t.data.length+a)>-1||0>a&&e.indexOf(t.data.length+a)>-1)throw new Error("each index in "+n+" must be unique.")}}function m(t,e,n){if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("currentIndices is a required argument.");if(Array.isArray(e)||(e=[e]),g(t,e,"currentIndices"),"undefined"==typeof n||Array.isArray(n)||(n=[n]),"undefined"!=typeof n&&g(t,n,"newIndices"),"undefined"!=typeof n&&e.length!==n.length)throw new Error("current and new indices must be of equal length.")}function v(t,e,n){var r,a;if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("traces must be defined.");for(Array.isArray(e)||(e=[e]),r=0;r=0&&s0){var l=w(t._boundingBoxMargins),s=l.left+l.right,c=l.bottom+l.top,u=o._container.node().getBoundingClientRect(),f=1-2*i.frameMargins;a=Math.round(f*(u.width-s)),r=Math.round(f*(u.height-c))}else n=window.getComputedStyle(t),r=parseFloat(n.height)||o.height,a=parseFloat(n.width)||o.width;return Math.abs(o.width-a)>1||Math.abs(o.height-r)>1?(o.height=t.layout.height=r,o.width=t.layout.width=a):"initial"!==o.autosize&&(delete e.autosize,o.autosize=t.layout.autosize=!0),R.sanitizeMargins(o),e}function M(t){var e=C.select(t),n=t._fullLayout;if(n._container=e.selectAll(".plot-container").data([0]),n._container.enter().insert("div",":first-child").classed("plot-container",!0).classed("plotly",!0),n._paperdiv=n._container.selectAll(".svg-container").data([0]),n._paperdiv.enter().append("div").classed("svg-container",!0).style("position","relative"),"initial"===n.autosize&&(k(t,{}),n.autosize=!0,t.layout.autosize=!0),n._glcontainer=n._paperdiv.selectAll(".gl-container").data([0]),n._glcontainer.enter().append("div").classed("gl-container",!0),n._geocontainer=n._paperdiv.selectAll(".geo-container").data([0]),n._geocontainer.enter().append("div").classed("geo-container",!0),n._paperdiv.selectAll(".main-svg").remove(),n._paper=n._paperdiv.insert("svg",":first-child").classed("main-svg",!0),n._toppaper=n._paperdiv.append("svg").classed("main-svg",!0),!n._uid){var r=[];C.selectAll("defs").each(function(){this.id&&r.push(this.id.split("-")[1])}),n._uid=N.randstr(r)}n._paperdiv.selectAll(".main-svg").attr(Q.svgAttrs),n._defs=n._paper.append("defs").attr("id","defs-"+n._uid),n._topdefs=n._toppaper.append("defs").attr("id","topdefs-"+n._uid),n._draggers=n._paper.append("g").classed("draglayer",!0);var a=n._paper.append("g").classed("layer-below",!0);n._imageLowerLayer=a.append("g").classed("imagelayer",!0),n._shapeLowerLayer=a.append("g").classed("shapelayer",!0);var o=P.Axes.getSubplots(t);o.join("")!==Object.keys(t._fullLayout._plots||{}).join("")&&A(t,o),n._has("cartesian")&&T(t,o),n._ternarylayer=n._paper.append("g").classed("ternarylayer",!0);var i=n._paper.selectAll(".layer-subplot");n._imageSubplotLayer=i.selectAll(".imagelayer"),n._shapeSubplotLayer=i.selectAll(".shapelayer");var l=n._paper.append("g").classed("layer-above",!0);n._imageUpperLayer=l.append("g").classed("imagelayer",!0),n._shapeUpperLayer=l.append("g").classed("shapelayer",!0),n._pielayer=n._paper.append("g").classed("pielayer",!0),n._glimages=n._paper.append("g").classed("glimages",!0),n._geoimages=n._paper.append("g").classed("geoimages",!0),n._infolayer=n._toppaper.append("g").classed("infolayer",!0),n._zoomlayer=n._toppaper.append("g").classed("zoomlayer",!0),n._hoverlayer=n._toppaper.append("g").classed("hoverlayer",!0),t.emit("plotly_framework");var s=N.syncOrAsync([L,function(){return P.Axes.doTicks(t,"redraw")},j.init],t);return s&&s.then&&t._promises.push(s),s}function A(t,e){function n(e,n){return function(){return P.Axes.getFromId(t,e,n)}}for(var r,a,o=t._fullLayout._plots={},i=0;i0,_=P.Axes.getSubplots(t).join(""),w=Object.keys(t._fullLayout._plots||{}).join(""),k=w===_;b?t.framework===M&&!x&&k||(t.framework=M,M(t)):k?x&&M(t):(t.framework=M,M(t)),x&&P.Axes.saveRangeInitial(t);var A=t._fullLayout,T=!t.calcdata||t.calcdata.length!==(t.data||[]).length;T&&h(t);for(var z=0;zG.range[0]?[1,2]:[2,1]);else{var Q=G.range[0],W=G.range[1];"log"===j?(0>=Q&&0>=W&&o(U+".autorange",!0),0>=Q?Q=W/1e6:0>=W&&(W=Q/1e6),o(U+".range[0]",Math.log(Q)/Math.LN10),o(U+".range[1]",Math.log(W)/Math.LN10)):(o(U+".range[0]",Math.pow(10,Q)),o(U+".range[1]",Math.pow(10,W)))}else o(U+".autorange",!0)}if("reverse"===B)Y.range?Y.range.reverse():(o(U+".autorange",!0),Y.range=[1,0]),X.autorange?w=!0:_=!0;else if("annotations"===D.parts[0]||"shapes"===D.parts[0]){var J=D.parts[1],K=D.parts[0],tt=g[K]||[],et=P[N.titleCase(K)],nt=tt[J]||{};2===D.parts.length&&("add"===v[E]||N.isPlainObject(v[E])?z[E]="remove":"remove"===v[E]?-1===J?(z[K]=tt,delete z[E]):z[E]=nt:N.log("???",v)),!i(nt,"x")&&!i(nt,"y")||N.containsAny(E,["color","opacity","align","dash"])||(w=!0),et.draw(t,J,D.parts.slice(2).join("."),v[E]),delete v[E]}else if("images"===D.parts[0]){var at=N.objectFromPath(E,j);N.extendDeepAll(t.layout,at),H.supplyLayoutDefaults(t.layout,t._fullLayout),H.draw(t)}else if("mapbox"===D.parts[0]&&"layers"===D.parts[1]){N.extendDeepAll(t.layout,N.objectFromPath(E,j));var ot=(t._fullLayout.mapbox||{}).layers||[];for(O=D.parts[2]+1-ot.length,p=0;O>p;p++)ot.push({});_=!0}else if("updatemenus"===D.parts[0]){N.extendDeepAll(t.layout,N.objectFromPath(E,j));var it=t._fullLayout.updatemenus||[];for(O=D.parts[2]+1-it.length, +-p=0;O>p;p++)it.push({});_=!0}else 0===D.parts[0].indexOf("scene")?_=!0:0===D.parts[0].indexOf("geo")?_=!0:0===D.parts[0].indexOf("ternary")?_=!0:!m._has("gl2d")||-1===E.indexOf("axis")&&"plot_bgcolor"!==D.parts[0]?"hiddenlabels"===E?w=!0:-1!==D.parts[0].indexOf("legend")?y=!0:-1!==E.indexOf("title")?x=!0:-1!==D.parts[0].indexOf("bgcolor")?b=!0:D.parts.length>1&&N.containsAny(D.parts[1],["tick","exponent","grid","zeroline"])?x=!0:-1!==E.indexOf(".linewidth")&&-1!==E.indexOf("axis")?x=b=!0:D.parts.length>1&&-1!==D.parts[1].indexOf("line")?b=!0:D.parts.length>1&&"mirror"===D.parts[1]?x=b=!0:"margin.pad"===E?x=b=!0:"margin"===D.parts[0]||"autorange"===D.parts[1]||"rangemode"===D.parts[1]||"type"===D.parts[1]||"domain"===D.parts[1]||E.match(/^(bar|box|font)/)?w=!0:-1!==["hovermode","dragmode"].indexOf(E)?M=!0:-1===["hovermode","dragmode","height","width","autosize"].indexOf(E)&&(_=!0):_=!0,D.set(j)}I.add(t,rt,[t,z],rt,[t,T]),v.autosize&&(v=k(t,v)),(v.height||v.width||v.autosize)&&(w=!0);var lt=Object.keys(v),st=[R.previousPromises];if(_||w)st.push(function(){return t.layout=void 0,w&&(t.calcdata=void 0),P.plot(t,"",g)});else if(lt.length&&(R.supplyDefaults(t),m=t._fullLayout,y&&st.push(function(){return V.draw(t),R.previousPromises(t)}),b&&st.push(L),x&&st.push(function(){return P.Axes.doTicks(t,"redraw"),S(t),R.previousPromises(t)}),M)){var ct;for($(t),P.Fx.supplyLayoutDefaults(t.layout,m,t._fullData),P.Fx.init(t),ct=R.getSubplotIds(m,"gl3d"),p=0;p1)};c(n.width)&&c(n.height)||l(new Error("Height and width should be pixel values."));var u=r.clone(e,{format:"png",height:n.height,width:n.width}),f=u.td;f.style.position="absolute",f.style.left="-5000px",document.body.appendChild(f);var d=r.getRedrawFunc(f);o.plot(f,u.data,u.layout,u.config).then(d).then(s).then(function(e){t(e)}).catch(function(t){l(t)})});return l}var a=t("fast-isnumeric"),o=t("../plotly"),i=t("../lib");e.exports=r},{"../lib":102,"../plotly":120,"../snapshot":160,"fast-isnumeric":18}],119:[function(t,e,n){"use strict";function r(t,e,n,a,o,c){c=c||[];for(var u=Object.keys(t),d=0;d1&&s.push(i("object","layout"))),d.supplyDefaults(c);for(var u=c._fullData,m=n.length,v=0;m>v;v++){var y=n[v],x=["data",v];if(p(y)){var b=u[v],_=b.type,w=l.traces[_].attributes;w.type={valType:"enumerated",values:[_]},b.visible===!1&&y.visible!==!1&&s.push(i("invisible",x)),r(y,b,w,s,x);var k=y.transforms,M=b.transforms;if(k){g(k)||s.push(i("array",x,["transforms"])),x.push("transforms");for(var A=0;Ac&&u>e&&(void 0===a[n]?o[f]=T.tickText(t,e):o[f]=l(t,e,String(a[n])),f++);return f=864e5?t._tickround="d":n>=36e5?t._tickround="H":n>=6e4?t._tickround="M":n>=1e3?t._tickround="S":t._tickround=3-Math.round(Math.log(n/2)/Math.LN10);else{x(n)||(n=Number(n.substr(1))),t._tickround=2-Math.floor(Math.log(n)/Math.LN10+.01),e="log"===t.type?Math.pow(10,Math.max(t.range[0],t.range[1])):Math.max(Math.abs(t.range[0]),Math.abs(t.range[1]));var r=Math.floor(Math.log(e)/Math.LN10+.01);Math.abs(r)>3&&("SI"===t.exponentformat||"B"===t.exponentformat?t._tickexponent=3*Math.round((r-1)/3):t._tickexponent=r)}else"M"===n.charAt(0)?t._tickround=2===n.length?"m":"y":t._tickround=null}function i(t,e){var n=t.match(B),r=new Date(e);if(n){var a=Math.min(+n[1]||6,6),o=String(e/1e3%1+2.0000005).substr(2,a).replace(/0+$/,"")||"0";return y.time.format(t.replace(B,o))(r)}return y.time.format(t)(r)}function l(t,e,n){var r=t.tickfont||t._gd._fullLayout.font;return{x:e,dx:0,dy:0,text:n||"",fontSize:r.size,font:r.family,fontColor:r.color}}function s(t,e,n,r){var a,o=e.x,l=t._tickround,s=new Date(o),c="";n&&t.hoverformat?a=i(t.hoverformat,o):t.tickformat?a=i(t.tickformat,o):(r&&(x(l)?l+=2:l={y:"m",m:"d",d:"H",H:"M",M:"S",S:2}[l]),"y"===l?a=D(s):"m"===l?a=I(s):(o!==t._tmin||n||(c="
"+D(s)),"d"===l?a=R(s):"H"===l?a=j(s):(o!==t._tmin||n||(c="
"+R(s)+", "+D(s)),a=F(s),"M"!==l&&(a+=q(s),"S"!==l&&(a+=d(v(o/1e3,1),t,"none",n).substr(1)))))),e.text=a+c}function c(t,e,n,r,a){var o=t.dtick,i=e.x;if(!r||"string"==typeof o&&"L"===o.charAt(0)||(o="L3"),t.tickformat||"string"==typeof o&&"L"===o.charAt(0))e.text=d(Math.pow(10,i),t,a,r);else if(x(o)||"D"===o.charAt(0)&&v(i+.01,1)<.1)if(-1!==["e","E","power"].indexOf(t.exponentformat)){var l=Math.round(i);0===l?e.text=1:1===l?e.text="10":l>1?e.text="10"+l+"":e.text="10\u2212"+-l+"",e.fontSize*=1.25}else e.text=d(Math.pow(10,i),t,"","fakehover"),"D1"===o&&"y"===t._id.charAt(0)&&(e.dy-=e.fontSize/6);else{if("D"!==o.charAt(0))throw"unrecognized dtick "+String(o);e.text=String(Math.round(Math.pow(10,v(i,1)))),e.fontSize*=.75}if("D1"===t.dtick){var s=String(e.text).charAt(0);"0"!==s&&"1"!==s||("y"===t._id.charAt(0)?e.dx-=e.fontSize/4:(e.dy+=e.fontSize/2,e.dx+=(t.range[1]>t.range[0]?1:-1)*e.fontSize*(0>i?.5:.25)))}}function u(t,e){var n=t._categories[Math.round(e.x)];void 0===n&&(n=""),e.text=String(n)}function f(t,e,n,r,a){"all"===t.showexponent&&Math.abs(e.x/t.dtick)<1e-6&&(a="hide"),e.text=d(e.x,t,a,r)}function d(t,e,n,r){var a=0>t,i=e._tickround,l=n||e.exponentformat||"B",s=e._tickexponent,c=e.tickformat;if(r){var u={exponentformat:e.exponentformat,dtick:"none"===e.showexponent?e.dtick:x(t)?Math.abs(t)||1:1,range:"none"===e.showexponent?e.range:[0,t||1]};o(u),i=(Number(u._tickround)||0)+4,s=u._tickexponent,e.hoverformat&&(c=e.hoverformat)}if(c)return y.format(c)(t).replace(/-/g,"\u2212");var f=Math.pow(10,-i)/2;if("none"===l&&(s=0),t=Math.abs(t),f>t)t="0",a=!1;else{if(t+=f,s&&(t*=Math.pow(10,-s),i+=s),0===i)t=String(Math.floor(t));else if(0>i){t=String(Math.round(t)),t=t.substr(0,t.length+i);for(var d=i;0>d;d++)t+="0"}else{t=String(t);var h=t.indexOf(".")+1;h&&(t=t.substr(0,h+i).replace(/\.?0+$/,""))}t=_.numSeparate(t,e._gd._fullLayout.separators)}if(s&&"hide"!==l){var p;p=0>s?"\u2212"+-s:"power"!==l?"+"+s:String(s),"e"===l||("SI"===l||"B"===l)&&(s>12||-15>s)?t+="e"+p:"E"===l?t+="E"+p:"power"===l?t+="\xd710"+p+"":"B"===l&&9===s?t+="B":"SI"!==l&&"B"!==l||(t+=H[s/3+5])}return a?"\u2212"+t:t}function h(t,e){var n,r,a=[];for(n=0;n1)for(r=1;r2e-6||((n-t._forceTick0)/t._minDtick%1+1.000001)%1>2e-6)&&(t._minDtick=0)):t._minDtick=0},T.getAutoRange=function(t){var e,n=[],r=t._min[0].val,a=t._max[0].val;for(e=1;e0&&u>0&&f/u>d&&(s=i,c=l,d=f/u);return r===a?n=h?[r+1,"normal"!==t.rangemode?0:r-1]:["normal"!==t.rangemode?0:r-1,r+1]:d&&("linear"!==t.type&&"-"!==t.type||("tozero"===t.rangemode&&s.val>=0?s={val:0,pad:0}:"nonnegative"===t.rangemode&&(s.val-d*s.pad<0&&(s={val:0,pad:0}),c.val<0&&(c={val:1,pad:0})),d=(c.val-s.val)/(t._length-s.pad-c.pad)),n=[s.val-d*s.pad,c.val+d*c.pad],n[0]===n[1]&&(n=[n[0]-1,n[0]+1]),h&&n.reverse()),n},T.doAutoRange=function(t){t._length||t.setScale();var e=t._min&&t._max&&t._min.length&&t._max.length;if(t.autorange&&e){t.range=T.getAutoRange(t);var n=t._gd.layout[t._name];n||(t._gd.layout[t._name]=n={}),n!==t&&(n.range=t.range.slice(),n.autorange=t.autorange)}},T.saveRangeInitial=function(t,e){for(var n=T.list(t,"",!0),r=!1,a=0;ap&&(p=g/10),c=t.c2l(p),u=t.c2l(g),y&&(c=Math.min(0,c),u=Math.max(0,u)),r(c)){for(h=!0,i=0;i=d?h=!1:l.val>=c&&l.pad<=d&&(t._min.splice(i,1),i--);h&&t._min.push({val:c,pad:y&&0===c?0:d})}if(r(u)){for(h=!0,i=0;i=u&&l.pad>=f?h=!1:l.val<=u&&l.pad<=f&&(t._max.splice(i,1),i--);h&&t._max.push({val:u,pad:y&&0===u?0:f})}}}if((t.autorange||t._needsExpand)&&e){t._min||(t._min=[]),t._max||(t._max=[]),n||(n={}),t._m||t.setScale();var o,i,l,s,c,u,f,d,h,p,g,m=e.length,v=n.padded?.05*t._length:0,y=n.tozero&&("linear"===t.type||"-"===t.type),b=r((t._m>0?n.ppadplus:n.ppadminus)||n.ppad||0),_=r((t._m>0?n.ppadminus:n.ppadplus)||n.ppad||0),w=r(n.vpadplus||n.vpad),k=r(n.vpadminus||n.vpad);for(o=0;6>o;o++)a(o);for(o=m-1;o>5;o--)a(o)}},T.autoBin=function(t,e,n,r){function a(t){return(1+100*(t-h)/f.dtick)%100<2}var o=_.aggNums(Math.min,null,t),i=_.aggNums(Math.max,null,t);if("category"===e.type)return{start:o-.5,end:i+.5,size:1};var l;if(n)l=(i-o)/n;else{var s=_.distinctVals(t),c=Math.pow(10,Math.floor(Math.log(s.minDiff)/Math.LN10)),u=c*_.roundUp(s.minDiff/c,[.9,1.9,4.9,9.9],!0);l=Math.max(u,2*_.stdev(t)/Math.pow(t.length,r?.25:.4))}var f={type:"log"===e.type?"linear":e.type,range:[o,i]};T.autoTicks(f,l);var d,h=T.tickIncrement(T.tickFirst(f),f.dtick,"reverse");if("number"==typeof f.dtick){for(var p=0,g=0,m=0,v=0,y=0;yg&&(p>.3*b||a(o)||a(i))){var w=f.dtick/2;h+=o>h+w?w:-w}var k=1+Math.floor((i-h)/f.dtick);d=h+k*f.dtick}else for(d=h;i>=d;)d=T.tickIncrement(d,f.dtick);return{start:h,end:d,size:f.dtick}},T.calcTicks=function(t){if("array"===t.tickmode)return r(t);if("auto"===t.tickmode||!t.dtick){var e,n=t.nticks;n||("category"===t.type?(e=t.tickfont?1.2*(t.tickfont.size||12):15,n=t._length/e):(e="y"===t._id.charAt(0)?40:80,n=_.constrain(t._length/e,4,9)+1)),T.autoTicks(t,Math.abs(t.range[1]-t.range[0])/n),t._minDtick>0&&t.dtick<2*t._minDtick&&(t.dtick=t._minDtick,t.tick0=t._forceTick0)}t.tick0||(t.tick0="date"===t.type?new Date(2e3,0,1).getTime():0),o(t),t._tmin=T.tickFirst(t);var a=t.range[1]=l:l>=s)&&(i.push(s),!(i.length>1e3));s=T.tickIncrement(s,t.dtick,a));t._tmax=i[i.length-1];for(var c=new Array(i.length),u=0;u157788e5?(e/=315576e5,n=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick="M"+12*a(e,n,S)):e>12096e5?(e/=26298e5,t.dtick="M"+a(e,1,C)):e>432e5?(t.dtick=a(e,864e5,O),t.tick0=new Date(2e3,0,2).getTime()):e>18e5?t.dtick=a(e,36e5,C):e>3e4?t.dtick=a(e,6e4,E):e>500?t.dtick=a(e,1e3,E):(n=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick=a(e,n,S));else if("log"===t.type)if(t.tick0=0,e>.7)t.dtick=Math.ceil(e);else if(Math.abs(t.range[1]-t.range[0])<1){var r=1.5*Math.abs((t.range[1]-t.range[0])/e);e=Math.abs(Math.pow(10,t.range[1])-Math.pow(10,t.range[0]))/r,n=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick="L"+a(e,n,S)}else t.dtick=e>.3?"D2":"D1";else"category"===t.type?(t.tick0=0,t.dtick=Math.ceil(Math.max(e,1))):(t.tick0=0,n=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick=a(e,n,S));if(0===t.dtick&&(t.dtick=1),!x(t.dtick)&&"string"!=typeof t.dtick){var o=t.dtick;throw t.dtick=1,"ax.dtick error: "+String(o)}},T.tickIncrement=function(t,e,n){var r=n?-1:1;if(x(e))return t+r*e;var a=e.charAt(0),o=r*Number(e.substr(1));if("M"===a){var i=new Date(t);return i.setMonth(i.getMonth()+o)}if("L"===a)return Math.log(Math.pow(10,t)+o)/Math.LN10;if("D"===a){var l="D2"===e?N:P,s=t+.01*r,c=_.roundUp(v(s,1),l,n);return Math.floor(s)+Math.log(y.round(Math.pow(10,c),1))/Math.LN10}throw"unrecognized dtick "+String(e)},T.tickFirst=function(t){var e=t.range[1]r:r>c;)c=T.tickIncrement(c,a,e);return c}if("L"===u)return Math.log(n((Math.pow(10,r)-o)/f)*f+o)/Math.LN10;if("D"===u){var d="D2"===a?N:P,h=_.roundUp(v(r,1),d,e);return Math.floor(r)+Math.log(y.round(Math.pow(10,h),1))/Math.LN10}throw"unrecognized dtick "+String(a)};var D=y.time.format("%Y"),I=y.time.format("%b %Y"),R=y.time.format("%b %-d"),j=y.time.format("%b %-d %Hh"),F=y.time.format("%H:%M"),q=y.time.format(":%S"),B=/%(\d?)f/g;T.tickText=function(t,e,n){function r(r){var a;return void 0===r?!0:n?"none"===r:(a={first:t._tmin,last:t._tmax}[r],"all"!==r&&e!==a)}var a,o,i=l(t,e),d="array"===t.tickmode,h=n||d;if(d&&Array.isArray(t.ticktext)){var p=Math.abs(t.range[1]-t.range[0])/1e4;for(o=0;o1&&en&&(M=90),a(u,M)}c._lastangle=M}return i(e),e+" done"}function s(){c._boundingBox=n.node().getBoundingClientRect()}var u=n.selectAll("g."+C).data(z,S);if(!c.showticklabels||!x(r))return u.remove(),void i(e);var f,d,p,v,b;"x"===m?(b="bottom"===q?1:-1,f=function(t){return t.dx+D*b},v=r+(N+P)*b,d=function(t){return t.dy+v+t.fontSize*("bottom"===q?1:-.5)},p=function(t){return x(t)&&0!==t&&180!==t?0>t*b?"end":"start":"middle"}):(b="right"===q?1:-1,d=function(t){return t.dy+t.fontSize/2-D*b},f=function(t){return t.dx+r+(N+P+(90===Math.abs(c.tickangle)?t.fontSize/2:0))*b},p=function(t){return x(t)&&90===Math.abs(t)?"middle":"right"===q?"start":"end"});var k=0,M=0,T=[];u.enter().append("g").classed(C,1).append("text").attr("text-anchor","middle").each(function(e){var n=y.select(this),r=t._promises.length;n.call(A.setPosition,f(e),d(e)).call(A.font,e.font,e.fontSize,e.fontColor).text(e.text).call(w.convertToTspans),r=t._promises[r],r?T.push(t._promises.pop().then(function(){a(n,c.tickangle)})):a(n,c.tickangle)}),u.exit().remove(),u.each(function(t){k=Math.max(k,t.fontSize)}),a(u,c._lastangle||c.tickangle);var L=_.syncOrAsync([o,l,s]);return L&&L.then&&t._promises.push(L),L}function i(e){if(!n){var r,a,o,i,l=L.getFromId(t,e),s=y.select(t).selectAll("g."+e+"tick"),c={selection:s,side:l.side},f=e.charAt(0),d=t._fullLayout._size,h=1.5,p=l.titlefont.size;if(s.size()){var g=y.select(s.node().parentNode).attr("transform").match(/translate\(([-\.\d]+),([-\.\d]+)\)/);g&&(c.offsetLeft=+g[1],c.offsetTop=+g[2])}"x"===f?(a="free"===l.anchor?{_offset:d.t+(1-(l.position||0))*d.h,_length:0}:L.getFromId(t,l.anchor),o=l._offset+l._length/2,i=a._offset+("top"===l.side?-10-p*(h+(l.showticklabels?1:0)):a._length+10+p*(h+(l.showticklabels?1.5:.5))),l.rangeslider&&l.rangeslider.visible&&l._boundingBox&&(i+=(u.height-u.margin.b-u.margin.t)*l.rangeslider.thickness+l._boundingBox.height),c.side||(c.side="bottom")):(a="free"===l.anchor?{_offset:d.l+(l.position||0)*d.w,_length:0}:L.getFromId(t,l.anchor),i=l._offset+l._length/2,o=a._offset+("right"===l.side?a._length+10+p*(h+(l.showticklabels?1:.5)):-10-p*(h+(l.showticklabels?.5:0))),r={rotate:"-90",offset:0},c.side||(c.side="left")),k.draw(t,e+"title",{propContainer:l,propName:l._name+".title",dfltName:f.toUpperCase()+" axis",avoid:c,transform:r,attributes:{x:o,y:i,"text-anchor":"middle"}})}}function l(t,e){return t.visible!==!0||t.xaxis+t.yaxis!==e?!1:b.Plots.traceIs(t,"bar")&&t.orientation==={x:"h",y:"v"}[m]?!0:t.fill&&t.fill.charAt(t.fill.length-1)===m}function s(e,n,a){var o=e.gridlayer,i=e.zerolinelayer,s=e["hidegrid"+m]?[]:H,u=c._gridpath||"M0,0"+("x"===m?"v":"h")+n._length,f=o.selectAll("path."+E).data(c.showgrid===!1?[]:s,S);if(f.enter().append("path").classed(E,1).classed("crisp",1).attr("d",u).each(function(t){c.zeroline&&("linear"===c.type||"-"===c.type)&&Math.abs(t.x)g;g++){var y=c.mirrors[i._id+d[g]];"ticks"!==y&&"labels"!==y||(f[g]=!0)}return void 0!==r[2]&&(f[2]=!0),f.forEach(function(t,e){var n=r[e],a=B[e];t&&x(n)&&(h+=p(n+P*a,a*c.ticklen))}),a(n,h),s(e,i,t),o(n,r[3])}}).filter(function(t){return t&&t.then});return Z.length?Promise.all(Z):0},T.swap=function(t,e){for(var n=h(t,e),r=0;r2*r}function u(t){for(var e,n=Math.max(1,(t.length-1)/1e3),r=0,a=0,o=0;o2*r}var f=t("fast-isnumeric"),d=t("tinycolor2").mix,h=t("../../lib"),p=t("../plots"),g=t("../../components/color/attributes").lightFraction,m=t("./layout_attributes"),v=t("./tick_value_defaults"),y=t("./tick_mark_defaults"),x=t("./tick_label_defaults"),b=t("./category_order_defaults"),_=t("./set_convert"),w=t("./ordered_categories"),k=t("./clean_datum"),M=t("./axis_ids");e.exports=function(t,e,n,a){function o(n,r){return h.coerce2(t,e,m,n,r)}var i=a.letter,l=a.font||{},s="Click to enter "+(a.title||i.toUpperCase()+" axis")+" title";a.name&&(e._name=a.name,e._id=M.name2id(a.name));var c=n("type");"-"===c&&(r(e,a.data),"-"===e.type?e.type="linear":c=t.type=e.type),_(e);var u=n("color"),p=u===t.color?u:l.color;n("title",s),h.coerceFont(n,"titlefont",{family:l.family,size:Math.round(1.2*l.size),color:p});var k=2===(t.range||[]).length&&f(t.range[0])&&f(t.range[1]),A=n("autorange",!k);A&&n("rangemode");var T=n("range",[-1,"x"===i?6:4]);T[0]===T[1]&&(e.range=[T[0]-1,T[0]+1]),h.noneOrAll(t.range,e.range,[0,1]),n("fixedrange"),v(t,e,n,c),x(t,e,n,c,a),y(t,e,n,a),b(t,e,n);var L=o("linecolor",u),z=o("linewidth"),S=n("showline",!!L||!!z);S||(delete e.linecolor,delete e.linewidth),(S||e.ticks)&&n("mirror");var C=o("gridcolor",d(u,a.bgColor,g).toRgbString()),E=o("gridwidth"),O=n("showgrid",a.showGrid||!!C||!!E);O||(delete e.gridcolor,delete e.gridwidth);var P=o("zerolinecolor",u),N=o("zerolinewidth"),D=n("zeroline",a.showGrid||!!P||!!N);return D||(delete e.zerolinecolor,delete e.zerolinewidth),e._initialCategories="category"===c?w(i,e.categoryorder,e.categoryarray,a.data):[],e}},{"../../components/color/attributes":24,"../../lib":102,"../plots":143,"./axis_ids":125,"./category_order_defaults":126,"./clean_datum":127,"./layout_attributes":132,"./ordered_categories":134,"./set_convert":137,"./tick_label_defaults":138,"./tick_mark_defaults":139,"./tick_value_defaults":140,"fast-isnumeric":18,tinycolor2:20}],125:[function(t,e,n){"use strict";function r(t,e,n){function r(t,n){for(var r=Object.keys(t),a=/^[xyz]axis[0-9]*/,o=[],i=0;i0;o&&(r="array");var i=n("categoryorder",r);"array"===i&&n("categoryarray"),o||"array"!==i||(e.categoryorder="trace")}}},{}],127:[function(t,e,n){"use strict";var r=t("fast-isnumeric"),a=t("../../lib");e.exports=function(t){try{if("object"==typeof t&&null!==t&&t.getTime)return a.ms2DateTime(t);if("string"!=typeof t&&!r(t))return"";t=t.toString().replace(/['"%,$# ]/g,"")}catch(e){a.error(e,t)}return t}},{"../../lib":102,"fast-isnumeric":18}],128:[function(t,e,n){"use strict";e.exports={idRegex:{x:/^x([2-9]|[1-9][0-9]+)?$/,y:/^y([2-9]|[1-9][0-9]+)?$/},attrRegex:{x:/^xaxis([2-9]|[1-9][0-9]+)?$/,y:/^yaxis([2-9]|[1-9][0-9]+)?$/},BADNUM:void 0,xAxisMatch:/^xaxis[0-9]*$/,yAxisMatch:/^yaxis[0-9]*$/,AX_ID_PATTERN:/^[xyz][0-9]*$/,AX_NAME_PATTERN:/^[xyz]axis[0-9]*$/,DBLCLICKDELAY:300,MINDRAG:8,MINSELECT:12,MINZOOM:20,DRAGGERSIZE:20,MAXDIST:20,YANGLE:60,HOVERARROWSIZE:6,HOVERTEXTPAD:3,HOVERFONTSIZE:13,HOVERFONT:"Arial, sans-serif",HOVERMINTIME:50,BENDPX:1.5,REDRAWDELAY:50}},{}],129:[function(t,e,n){"use strict";function r(t,e){var n,r=t.range[e],a=Math.abs(r-t.range[1-e]);return"date"===t.type?u.ms2DateTime(r,a):"log"===t.type?(n=Math.ceil(Math.max(0,-Math.log(a)/Math.LN10))+3,l.format("."+n+"g")(Math.pow(10,r))):(n=Math.floor(Math.log(Math.abs(r))/Math.LN10)-Math.floor(Math.log(a)/Math.LN10)+4,l.format("."+String(n)+"g")(r))}function a(t,e){return t?"nsew"===t?"pan"===e?"move":"crosshair":t.toLowerCase()+"-resize":"pointer"}function o(t){l.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}function i(t){var e=["lasso","select"];return-1!==e.indexOf(t)}var l=t("d3"),s=t("tinycolor2"),c=t("../../plotly"),u=t("../../lib"),f=t("../../lib/svg_text_utils"),d=t("../../components/color"),h=t("../../components/drawing"),p=t("../../lib/setcursor"),g=t("../../components/dragelement"),m=t("./axes"),v=t("./select"),y=t("./constants"),x=!0;e.exports=function(t,e,n,l,b,_,w,k){function M(t,e){for(var n=0;n.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("transform","translate("+pt+", "+gt+")").attr("d",st+"Z"),dt=ht.append("path").attr("class","zoombox-corners").style({fill:d.background,stroke:d.defaultLine,"stroke-width":1,opacity:0}).attr("transform","translate("+pt+", "+gt+")").attr("d","M0,0Z"),L();for(var o=0;oa?(ut="",it.r=it.l,it.t=it.b,dt.attr("d","M0,0Z")):(it.t=0,it.b=V,ut="x",dt.attr("d","M"+(it.l-.5)+","+(ot-U-.5)+"h-3v"+(2*U+1)+"h3ZM"+(it.r+.5)+","+(ot-U-.5)+"h3v"+(2*U+1)+"h-3Z")):!W||a.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),dt.transition().style("opacity",1).duration(200),ct=!0)}function S(t,e,n){var r,a,o;for(r=0;rzoom back out","long"),x=!1)))}function E(e,n){var a=1===(w+k).length;if(e)I();else if(2!==n||a){if(1===n&&a){var o=w?B[0]:q[0],i="s"===w||"w"===k?0:1,l=o._name+".range["+i+"]",s=r(o,i),u="left",d="middle";if(o.fixedrange)return;w?(d="n"===w?"top":"bottom","right"===o.side&&(u="right")):"e"===k&&(u="right"),et.call(f.makeEditable,null,{immediate:!0,background:j.paper_bgcolor,text:String(s),fill:o.tickfont?o.tickfont.color:"#444",horizontalAlign:u,verticalAlign:d}).on("edit",function(e){var n="category"===o.type?o.c2l(e):o.d2l(e);void 0!==n&&c.relayout(t,l,n)})}}else D()}function O(e){function n(t,e,n){if(!t.fixedrange){A(t.range);var r=t.range,a=r[0]+(r[1]-r[0])*e;t.range=[a+(r[0]-a)*n,a+(r[1]-a)*n]}}if(t._context.scrollZoom||j._enablescrollzoom){var r=t.querySelector(".plotly");if(!(r.scrollHeight-r.clientHeight>10||r.scrollWidth-r.clientWidth>10)){clearTimeout(vt);var a=-e.deltaY;if(isFinite(a)||(a=e.wheelDelta/10),!isFinite(a))return void u.log("Did not find wheel motion attributes: ",e);var o,i=Math.exp(-Math.min(Math.max(a,-20),20)/100),l=xt.draglayer.select(".nsewdrag").node().getBoundingClientRect(),s=(e.clientX-l.left)/l.width,c=mt[0]+mt[2]*s,f=(l.bottom-e.clientY)/l.height,d=mt[1]+mt[3]*(1-f);if(k){for(o=0;o=0?Math.min(t,.9):1/(1/Math.max(t,-.3)+3.222))}function a(t,e,n){for(var a=1-e,o=0,i=0;i0;r--)n.push(e);return n}function a(t,e){for(var n=[],r=0;rT;T++){var L=o[T],z=h[L];if(z)M[T]=w.getFromId(t,z.xaxis._id),A[T]=w.getFromId(t,z.yaxis._id);else{var S=i[L]._subplot;M[T]=S.xaxis,A[T]=S.yaxis}}var C=e.hovermode||i.hovermode;if(-1===["x","y","closest"].indexOf(C)||!t.calcdata||t.querySelector(".zoombox")||t._dragging)return _.unhoverRaw(t,e);var E,O,P,N,D,I,R,j,F,q,B,H,V=[],Z=[];if(Array.isArray(e))for(C="array",P=0;PU||U>X.width||0>Y||Y>X.height)return _.unhoverRaw(t,e)}else U="xpx"in e?e.xpx:M[0]._length/2,Y="ypx"in e?e.ypx:A[0]._length/2;if(E="xval"in e?r(o,e.xval):a(M,U),O="yval"in e?r(o,e.yval):a(A,Y),!g(E[0])||!g(O[0]))return m.warn("Plotly.Fx.hover failed",e,t),_.unhoverRaw(t,e)}var G=1/0;for(N=0;N1||-1!==I.hoverinfo.indexOf("name")?I.name:void 0,index:!1,distance:Math.min(G,k.MAXDIST),color:x.defaultLine,x0:void 0,x1:void 0,y0:void 0,y1:void 0,xLabelVal:void 0,yLabelVal:void 0,zLabelVal:void 0,text:void 0},H=V.length,"array"===j){var $=e[N];"pointNumber"in $?(B.index=$.pointNumber,j="closest"):(j="","xval"in $&&(F=$.xval,j="x"),"yval"in $&&(q=$.yval,j=j?"closest":"y"))}else F=E[R],q=O[R];if(I._module&&I._module.hoverPoints){var Q=I._module.hoverPoints(B,F,q,j);if(Q)for(var W,J=0;JH&&(V.splice(0,H),G=V[0].distance)}if(0===V.length)return _.unhoverRaw(t,e);var K="y"===C&&Z.length>1;V.sort(function(t,e){return t.distance-e.distance});var tt=x.combine(i.plot_bgcolor||x.background,i.paper_bgcolor),et={hovermode:C,rotateLabels:K,bgColor:tt,container:i._hoverlayer,outerContainer:i._paperdiv},nt=c(V,et);u(V,K?"xa":"ya"),f(nt,K);var rt=t._hoverdata,at=[];for(P=0;P128?"#000":x.background;if(t.name&&void 0===t.zLabelVal){var u=document.createElement("p");u.innerHTML=t.name,n=u.textContent||"",n.length>15&&(n=n.substr(0,12)+"...")}void 0!==t.extraText&&(r+=t.extraText),void 0!==t.zLabel?(void 0!==t.xLabel&&(r+="x: "+t.xLabel+"
"),void 0!==t.yLabel&&(r+="y: "+t.yLabel+"
"),r+=(r?"z: ":"")+t.zLabel):A&&t[a+"Label"]===g?r=t[("x"===a?"y":"x")+"Label"]||"":void 0===t.xLabel?void 0!==t.yLabel&&(r=t.yLabel):r=void 0===t.yLabel?t.xLabel:"("+t.xLabel+", "+t.yLabel+")",t.text&&!Array.isArray(t.text)&&(r+=(r?"
":"")+t.text),""===r&&(""===n&&e.remove(),r=n);var f=e.select("text.nums").style("fill",c).call(b.setPosition,0,0).text(r).attr("data-notex",1).call(y.convertToTspans);f.selectAll("tspan.line").call(b.setPosition,0,0);var d=e.select("text.name"),m=0;n&&n!==r?(d.style("fill",s).text(n).call(b.setPosition,0,0).attr("data-notex",1).call(y.convertToTspans),d.selectAll("tspan.line").call(b.setPosition,0,0),m=d.node().getBoundingClientRect().width+2*O):(d.remove(),e.select("rect").remove()),e.select("path").style({fill:s,stroke:c});var v,k,L=f.node().getBoundingClientRect(),z=t.xa._offset+(t.x0+t.x1)/2,S=t.ya._offset+(t.y0+t.y1)/2,C=Math.abs(t.x1-t.x0),P=Math.abs(t.y1-t.y0),N=L.width+E+O+m;t.ty0=_-L.top,t.bx=L.width+2*O,t.by=L.height+2*O,t.anchor="start",t.txwidth=L.width,t.tx2width=m,t.offset=0,o?(t.pos=z,v=M>=S+P/2+N,k=S-P/2-N>=0,"top"!==t.idealAlign&&v||!k?v?(S+=P/2,t.anchor="start"):t.anchor="middle":(S-=P/2,t.anchor="end")):(t.pos=S,v=w>=z+C/2+N,k=z-C/2-N>=0,"left"!==t.idealAlign&&v||!k?v?(z+=C/2,t.anchor="start"):t.anchor="middle":(z-=C/2,t.anchor="end")),f.attr("text-anchor",t.anchor),m&&d.attr("text-anchor",t.anchor),e.attr("transform","translate("+z+","+S+")"+(o?"rotate("+T+")":""))}),S}function u(t,e){function n(t){var e=t[0],n=t[t.length-1];if(a=e.pmin-e.pos-e.dp+e.size,o=n.pos+n.dp+n.size-e.pmax,a>.01){for(l=t.length-1;l>=0;l--)t[l].dp+=a;r=!1}if(!(.01>o)){if(-.01>a){for(l=t.length-1;l>=0;l--)t[l].dp-=o;r=!1}if(r){var c=0;for(i=0;ie.pmax&&c++;for(i=t.length-1;i>=0&&!(0>=c);i--)s=t[i],s.pos>e.pmax-1&&(s.del=!0,c--);for(i=0;i=c);i++)if(s=t[i],s.pos=0;l--)t[l].dp-=o;for(i=t.length-1;i>=0&&!(0>=c);i--)s=t[i],s.pos+s.dp+s.size>e.pmax&&(s.del=!0,c--)}}}for(var r,a,o,i,l,s,c,u=0,f=t.map(function(t,n){var r=t[e];return[{i:n,dp:0,pos:t.pos,posref:t.posref,size:t.by*("x"===r._id.charAt(0)?z:1)/2,pmin:r._offset,pmax:r._offset+r._length}]}).sort(function(t,e){return t[0].posref-e[0].posref});!r&&u<=t.length;){for(u++,r=!0,i=0;i.01&&p.pmin===g.pmin&&p.pmax===g.pmax){for(l=h.length-1;l>=0;l--)h[l].dp+=a;for(d.push.apply(d,h),f.splice(i+1,1),c=0,l=d.length-1;l>=0;l--)c+=d[l].dp;for(o=c/d.length,l=d.length-1;l>=0;l--)d[l].dp-=o;r=!1}else i++}f.forEach(n)}for(i=f.length-1;i>=0;i--){var m=f[i];for(l=m.length-1;l>=0;l--){var v=m[l],y=t[v.i];y.offset=v.dp,y.del=v.del}}}function f(t,e){t.each(function(t){var n=h.select(this);if(t.del)return void n.remove();var r="end"===t.anchor?-1:1,a=n.select("text.nums"),o={start:1,end:-1,middle:0}[t.anchor],i=o*(E+O),l=i+o*(t.txwidth+O),s=0,c=t.offset;"middle"===t.anchor&&(i-=t.tx2width/2,l-=t.tx2width/2),e&&(c*=-C,s=t.offset*S),n.select("path").attr("d","middle"===t.anchor?"M-"+t.bx/2+",-"+t.by/2+"h"+t.bx+"v"+t.by+"h-"+t.bx+"Z":"M0,0L"+(r*E+s)+","+(E+c)+"v"+(t.by/2-E)+"h"+r*t.bx+"v-"+t.by+"H"+(r*E+s)+"V"+(c-E)+"Z"),a.call(b.setPosition,i+s,c+t.ty0-t.by/2+O).selectAll("tspan.line").attr({x:a.attr("x"),y:a.attr("y")}),t.tx2width&&(n.select("text.name, text.name tspan.line").call(b.setPosition,l+o*O+s,c+t.ty0-t.by/2+O),n.select("rect").call(b.setRect,l+(o-1)*t.tx2width/2+s,c-t.by/2-1,t.tx2width,t.by+2))})}function d(t,e,n){if(!e.target)return!1;if(!n||n.length!==t._hoverdata.length)return!0;for(var r=n.length-1;r>=0;r--){var a=n[r],o=t._hoverdata[r];if(a.curveNumber!==o.curveNumber||String(a.pointNumber)!==String(o.pointNumber))return!0}return!1}var h=t("d3"),p=t("tinycolor2"),g=t("fast-isnumeric"),m=t("../../lib"),v=t("../../lib/events"),y=t("../../lib/svg_text_utils"),x=t("../../components/color"),b=t("../../components/drawing"),_=t("../../components/dragelement"),w=t("./axes"),k=t("./constants"),M=t("./dragbox"),A=e.exports={}; +-A.unhover=_.unhover,A.layoutAttributes={dragmode:{valType:"enumerated",values:["zoom","pan","select","lasso","orbit","turntable"],dflt:"zoom"},hovermode:{valType:"enumerated",values:["x","y","closest",!1]}},A.supplyLayoutDefaults=function(t,e,n){function r(n,r){return m.coerce(t,e,A.layoutAttributes,n,r)}r("dragmode");var a;if(e._has("cartesian")){var o=e._isHoriz=A.isHoriz(n);a=o?"y":"x"}else a="closest";r("hovermode",a)},A.isHoriz=function(t){for(var e=!0,n=0;nt._lastHoverTime+k.HOVERMINTIME?(i(t,e,n),void(t._lastHoverTime=Date.now())):void(t._hoverTimer=setTimeout(function(){i(t,e,n),t._lastHoverTime=Date.now(),t._hoverTimer=void 0},k.HOVERMINTIME))},A.getDistanceFunction=function(t,e,n,r){return"closest"===t?r||o(e,n):"x"===t?e:n},A.getClosest=function(t,e,n){if(n.index!==!1)n.index>=0&&n.indext*e||0===t?k.MAXDIST*(.6-.3/Math.max(3,Math.abs(t-e))):1/0}},{"../../components/color":25,"../../components/dragelement":46,"../../components/drawing":48,"../../lib":102,"../../lib/events":99,"../../lib/svg_text_utils":113,"./axes":123,"./constants":128,"./dragbox":129,d3:16,"fast-isnumeric":18,tinycolor2:20}],131:[function(t,e,n){"use strict";var r=t("../plots"),a=t("./constants");n.name="cartesian",n.attr=["xaxis","yaxis"],n.idRoot=["x","y"],n.idRegex=a.idRegex,n.attrRegex=a.attrRegex,n.attributes=t("./attributes"),n.plot=function(t){function e(t,e){for(var n=[],r=0;rf[1]-.01&&(e.domain=[0,1]),a.noneOrAll(t.domain,e.domain,[0,1])}return e}},{"../../lib":102,"fast-isnumeric":18}],136:[function(t,e,n){"use strict";function r(t){return t._id}var a=t("../../lib/polygon"),o=t("../../components/color"),i=t("./axes"),l=t("./constants"),s=a.filter,c=a.tester,u=l.MINSELECT;e.exports=function(t,e,n,a,f){function d(t){var e="y"===t._id.charAt(0)?1:0;return function(n){return t.p2d(n[e])}}function h(t,e){return t-e}var p,g=a.gd._fullLayout._zoomlayer,m=a.element.getBoundingClientRect(),v=a.plotinfo.x()._offset,y=a.plotinfo.y()._offset,x=e-m.left,b=n-m.top,_=x,w=b,k="M"+x+","+b,M=a.xaxes[0]._length,A=a.yaxes[0]._length,T=a.xaxes.map(r),L=a.yaxes.map(r),z=a.xaxes.concat(a.yaxes);"lasso"===f&&(p=s([[x,b]],l.BENDPX));var S=g.selectAll("path.select-outline").data([1,2]);S.enter().append("path").attr("class",function(t){return"select-outline select-outline-"+t}).attr("transform","translate("+v+", "+y+")").attr("d",k+"Z");var C,E,O,P,N,D=g.append("path").attr("class","zoombox-corners").style({fill:o.background,stroke:o.defaultLine,"stroke-width":1}).attr("transform","translate("+v+", "+y+")").attr("d","M0,0Z"),I=[],R=a.gd,j=[];for(C=0;C0)return Math.log(e)/Math.LN10;if(0>=e&&n&&t.range&&2===t.range.length){var r=t.range[0],a=t.range[1];return.5*(r+a-3*u*Math.abs(r-a))}return i.BADNUM}function n(t){return Math.pow(10,t)}function c(t){return a(t)?Number(t):i.BADNUM}var u=10;if(t.c2l="log"===t.type?e:c,t.l2c="log"===t.type?n:c,t.l2d=function(e){return t.c2d(t.l2c(e))},t.p2d=function(e){return t.l2d(t.p2l(e))},t.setScale=function(){var e,n=t._gd._fullLayout._size;if(t._categories||(t._categories=[]),t.overlaying){var r=s.getFromId(t._gd,t.overlaying);t.domain=r.domain}for(t.range&&2===t.range.length&&t.range[0]!==t.range[1]||(t.range=[-1,1]),e=0;2>e;e++)a(t.range[e])||(t.range[e]=a(t.range[1-e])?t.range[1-e]*(e?10:.1):e?1:-1),t.range[e]<-(Number.MAX_VALUE/2)?t.range[e]=-(Number.MAX_VALUE/2):t.range[e]>Number.MAX_VALUE/2&&(t.range[e]=Number.MAX_VALUE/2);if("y"===t._id.charAt(0)?(t._offset=n.t+(1-t.domain[1])*n.h,t._length=n.h*(t.domain[1]-t.domain[0]),t._m=t._length/(t.range[0]-t.range[1]),t._b=-t._m*t.range[1]):(t._offset=n.l+t.domain[0]*n.w,t._length=n.w*(t.domain[1]-t.domain[0]),t._m=t._length/(t.range[1]-t.range[0]),t._b=-t._m*t.range[0]),!isFinite(t._m)||!isFinite(t._b))throw o.notifier("Something went wrong with axis scaling","long"),t._gd._replotting=!1,new Error("axis scaling")},t.l2p=function(e){return a(e)?r.round(t._b+t._m*e,2):i.BADNUM},t.p2l=function(e){return(e-t._b)/t._m},t.c2p=function(e,n){return t.l2p(t.c2l(e,n))},t.p2c=function(e){return t.l2c(t.p2l(e))},-1!==["linear","log","-"].indexOf(t.type))t.c2d=c,t.d2c=function(t){return t=l(t),a(t)?Number(t):i.BADNUM},t.d2l=function(e,n){return"log"===t.type?t.c2l(t.d2c(e),n):t.d2c(e)};else if("date"===t.type){if(t.c2d=function(t){return a(t)?o.ms2DateTime(t):i.BADNUM},t.d2c=function(t){return a(t)?Number(t):o.dateTime2ms(t)},t.d2l=t.d2c,t.range&&t.range.length>1)try{var f=t.range.map(o.dateTime2ms);!a(t.range[0])&&a(f[0])&&(t.range[0]=f[0]),!a(t.range[1])&&a(f[1])&&(t.range[1]=f[1])}catch(d){o.error(d,t.range)}}else"category"===t.type&&(t.c2d=function(e){return t._categories[Math.round(e)]},t.d2c=function(e){null!==e&&void 0!==e&&-1===t._categories.indexOf(e)&&t._categories.push(e);var n=t._categories.indexOf(e);return-1===n?i.BADNUM:n},t.d2l=t.d2c);t.makeCalcdata=function(e,n){var r,a,o;if(n in e)for(r=e[n],a=new Array(r.length),o=0;o=e.width-20?(o["text-anchor"]="start",o.x=5):(o["text-anchor"]="end",o.x=e._paper.attr("width")-7),n.attr(o);var i=n.select(".js-link-to-tool"),l=n.select(".js-link-spacer"),c=n.select(".js-sourcelinks");t._context.showSources&&t._context.showSources(t),t._context.showLink&&a(t,i),l.text(i.text()&&c.text()?" - ":"")},h.sendDataToCloud=function(t){t.emit("plotly_beforeexport");var e=window.PLOTLYENV&&window.PLOTLYENV.BASE_URL||"https://plot.ly",n=s.select(t).append("div").attr("id","hiddenform").style("display","none"),r=n.append("form").attr({action:e+"/external",method:"post",target:"_blank"}),a=r.append("input").attr({type:"text",name:"data"});return a.node().value=h.graphJson(t,!1,"keepdata"),r.node().submit(),n.remove(),t.emit("plotly_afterexport"),!1},h.supplyDefaults=function(t){var e,n=t._fullLayout||{},r=t._fullLayout={},a=t.layout||{},i=t._fullData||[],l=t._fullData=[],s=t.data||[];h.supplyLayoutGlobalDefaults(a,r),r._dataLength=s.length,h.supplyDataDefaults(s,l,r),r._has=h._hasPlotType.bind(r);var c=r._modules;for(e=0;eo&&(e=(n-1)/(a.l+a.r),a.l=Math.floor(e*a.l),a.r=Math.floor(e*a.r)),0>i&&(e=(r-1)/(a.t+a.b),a.t=Math.floor(e*a.t),a.b=Math.floor(e*a.b))}},h.autoMargin=function(t,e,n){var r=t._fullLayout;if(r._pushmargin||(r._pushmargin={}),r.margin.autoexpand!==!1){if(n){var a=void 0===n.pad?12:n.pad;n.l+n.r>.5*r.width&&(n.l=n.r=0),n.b+n.t>.5*r.height&&(n.b=n.t=0),r._pushmargin[e]={l:{val:n.x,size:n.l+a},r:{val:n.x,size:n.r+a},b:{val:n.y,size:n.b+a},t:{val:n.y,size:n.t+a}}}else delete r._pushmargin[e];t._replotting||h.doAutoMargin(t)}},h.doAutoMargin=function(t){var e=t._fullLayout;e._size||(e._size={}),e._pushmargin||(e._pushmargin={});var n=e._size,r=JSON.stringify(n),a=Math.max(e.margin.l||0,0),o=Math.max(e.margin.r||0,0),i=Math.max(e.margin.t||0,0),l=Math.max(e.margin.b||0,0),s=e._pushmargin;return e.margin.autoexpand!==!1&&(s.base={l:{val:0,size:a},r:{val:1,size:o},t:{val:1,size:i},b:{val:0,size:l}},Object.keys(s).forEach(function(t){var n=s[t].l||{},r=s[t].b||{},u=n.val,f=n.size,d=r.val,h=r.size;Object.keys(s).forEach(function(t){if(c(f)&&s[t].r){var n=s[t].r.val,r=s[t].r.size;if(n>u){var p=(f*n+(r-e.width)*u)/(n-u),g=(r*(1-u)+(f-e.width)*(1-n))/(n-u);p>=0&&g>=0&&p+g>a+o&&(a=p,o=g)}}if(c(h)&&s[t].t){var m=s[t].t.val,v=s[t].t.size;if(m>d){var y=(h*m+(v-e.height)*d)/(m-d),x=(v*(1-d)+(h-e.height)*(1-m))/(m-d);y>=0&&x>=0&&y+x>l+i&&(l=y,i=x)}}})})),n.l=Math.round(a),n.r=Math.round(o),n.t=Math.round(i),n.b=Math.round(l),n.p=Math.round(e.margin.pad),n.w=Math.round(e.width)-n.l-n.r,n.h=Math.round(e.height)-n.t-n.b,t._replotting||"{}"===r||r===JSON.stringify(e._size)?void 0:u.plot(t)},h.graphJson=function(t,e,n,r,a){function o(t){if("function"==typeof t)return null;if(f.isPlainObject(t)){var e,r,a={};for(e in t)if("function"!=typeof t[e]&&-1===["_","["].indexOf(e.charAt(0))){if("keepdata"===n){if("src"===e.substr(e.length-3))continue}else if("keepstream"===n){if(r=t[e+"src"],"string"==typeof r&&r.indexOf(":")>0&&!f.isPlainObject(t.stream))continue}else if("keepall"!==n&&(r=t[e+"src"],"string"==typeof r&&r.indexOf(":")>0))continue;a[e]=o(t[e])}return a}return Array.isArray(t)?t.map(o):t&&t.getTime?f.ms2DateTime(t):t}(a&&e&&!t._fullData||a&&!e&&!t._fullLayout)&&h.supplyDefaults(t);var i=a?t._fullData:t.data,l=a?t._fullLayout:t.layout,s={data:(i||[]).map(function(t){var n=o(t);return e&&delete n.fit,n})};return e||(s.layout=o(l)),t.framework&&t.framework.isPolar&&(s=t.framework.getConfig()),"object"===r?s:JSON.stringify(s)}},{"../components/color":25,"../lib":102,"../plotly":120, +-"./attributes":121,"./font_attributes":141,"./layout_attributes":142,d3:16,"fast-isnumeric":18}],144:[function(t,e,n){"use strict";var r=t("../../traces/scatter/attributes"),a=r.marker;e.exports={r:r.r,t:r.t,marker:{color:a.color,size:a.size,symbol:a.symbol,opacity:a.opacity}}},{"../../traces/scatter/attributes":236}],145:[function(t,e,n){"use strict";function r(t,e){var n={showline:{valType:"boolean"},showticklabels:{valType:"boolean"},tickorientation:{valType:"enumerated",values:["horizontal","vertical"]},ticklen:{valType:"number",min:0},tickcolor:{valType:"color"},ticksuffix:{valType:"string"},endpadding:{valType:"number"},visible:{valType:"boolean"}};return o({},e,n)}var a=t("../cartesian/layout_attributes"),o=t("../../lib/extend").extendFlat,i=o({},a.domain,{});e.exports={radialaxis:r("radial",{range:{valType:"info_array",items:[{valType:"number"},{valType:"number"}]},domain:i,orientation:{valType:"number"}}),angularaxis:r("angular",{range:{valType:"info_array",items:[{valType:"number",dflt:0},{valType:"number",dflt:360}]},domain:i}),layout:{direction:{valType:"enumerated",values:["clockwise","counterclockwise"]},orientation:{valType:"angle"}}}},{"../../lib/extend":100,"../cartesian/layout_attributes":132}],146:[function(t,e,n){var r=t("../../plotly"),a=t("d3"),o=e.exports={version:"0.2.2",manager:t("./micropolar_manager")},i=r.Lib.extendDeepAll;o.Axis=function(){function t(t){n=t||n;var c=s.data,f=s.layout;return("string"==typeof n||n.nodeName)&&(n=a.select(n)),n.datum(c).each(function(t,n){function s(t,e){return l(t)%360+f.orientation}var c=t.slice();u={data:o.util.cloneJson(c),layout:o.util.cloneJson(f)};var d=0;c.forEach(function(t,e){t.color||(t.color=f.defaultColorRange[d],d=(d+1)%f.defaultColorRange.length),t.strokeColor||(t.strokeColor="LinePlot"===t.geometry?t.color:a.rgb(t.color).darker().toString()),u.data[e].color=t.color,u.data[e].strokeColor=t.strokeColor,u.data[e].strokeDash=t.strokeDash,u.data[e].strokeSize=t.strokeSize});var h=c.filter(function(t,e){var n=t.visible;return"undefined"==typeof n||n===!0}),p=!1,g=h.map(function(t,e){return p=p||"undefined"!=typeof t.groupId,t});if(p){var m=a.nest().key(function(t,e){return"undefined"!=typeof t.groupId?t.groupId:"unstacked"}).entries(g),v=[],y=m.map(function(t,e){if("unstacked"===t.key)return t.values;var n=t.values[0].r.map(function(t,e){return 0});return t.values.forEach(function(t,e,r){t.yStack=[n],v.push(n),n=o.util.sumArrays(t.r,n)}),t.values});h=a.merge(y)}h.forEach(function(t,e){t.t=Array.isArray(t.t[0])?t.t:[t.t],t.r=Array.isArray(t.r[0])?t.r:[t.r]});var x=Math.min(f.width-f.margin.left-f.margin.right,f.height-f.margin.top-f.margin.bottom)/2;x=Math.max(10,x);var b,_=[f.margin.left+x,f.margin.top+x];if(p){var w=a.max(o.util.sumArrays(o.util.arrayLast(h).r[0],o.util.arrayLast(v)));b=[0,w]}else b=a.extent(o.util.flattenArray(h.map(function(t,e){return t.r})));f.radialAxis.domain!=o.DATAEXTENT&&(b[0]=0),r=a.scale.linear().domain(f.radialAxis.domain!=o.DATAEXTENT&&f.radialAxis.domain?f.radialAxis.domain:b).range([0,x]),u.layout.radialAxis.domain=r.domain();var k,M=o.util.flattenArray(h.map(function(t,e){return t.t})),A="string"==typeof M[0];A&&(M=o.util.deduplicate(M),k=M.slice(),M=a.range(M.length),h=h.map(function(t,e){var n=t;return t.t=[M],p&&(n.yStack=t.yStack),n}));var T=h.filter(function(t,e){return"LinePlot"===t.geometry||"DotPlot"===t.geometry}).length===h.length,L=null===f.needsEndSpacing?A||!T:f.needsEndSpacing,z=f.angularAxis.domain&&f.angularAxis.domain!=o.DATAEXTENT&&!A&&f.angularAxis.domain[0]>=0,S=z?f.angularAxis.domain:a.extent(M),C=Math.abs(M[1]-M[0]);T&&!A&&(C=0);var E=S.slice();L&&A&&(E[1]+=C);var O=f.angularAxis.ticksCount||4;O>8&&(O=O/(O/8)+O%8),f.angularAxis.ticksStep&&(O=(E[1]-E[0])/O);var P=f.angularAxis.ticksStep||(E[1]-E[0])/(O*(f.minorTicks+1));k&&(P=Math.max(Math.round(P),1)),E[2]||(E[2]=P);var N=a.range.apply(this,E);if(N=N.map(function(t,e){return parseFloat(t.toPrecision(12))}),l=a.scale.linear().domain(E.slice(0,2)).range("clockwise"===f.direction?[0,360]:[360,0]),u.layout.angularAxis.domain=l.domain(),u.layout.angularAxis.endPadding=L?C:0,e=a.select(this).select("svg.chart-root"),"undefined"==typeof e||e.empty()){var D="' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '",I=(new DOMParser).parseFromString(D,"application/xml"),R=this.appendChild(this.ownerDocument.importNode(I.documentElement,!0));e=a.select(R)}e.select(".guides-group").style({"pointer-events":"none"}),e.select(".angular.axis-group").style({"pointer-events":"none"}),e.select(".radial.axis-group").style({"pointer-events":"none"});var j,F=e.select(".chart-group"),q={fill:"none",stroke:f.tickColor},B={"font-size":f.font.size,"font-family":f.font.family,fill:f.font.color,"text-shadow":["-1px 0px","1px -1px","-1px 1px","1px 1px"].map(function(t,e){return" "+t+" 0 "+f.font.outlineColor}).join(",")};if(f.showLegend){j=e.select(".legend-group").attr({transform:"translate("+[x,f.margin.top]+")"}).style({display:"block"});var H=h.map(function(t,e){var n=o.util.cloneJson(t);return n.symbol="DotPlot"===t.geometry?t.dotType||"circle":"LinePlot"!=t.geometry?"square":"line",n.visibleInLegend="undefined"==typeof t.visibleInLegend||t.visibleInLegend,n.color="LinePlot"===t.geometry?t.strokeColor:t.color,n});o.Legend().config({data:h.map(function(t,e){return t.name||"Element"+e}),legendConfig:i({},o.Legend.defaultConfig().legendConfig,{container:j,elements:H,reverseOrder:f.legend.reverseOrder})})();var V=j.node().getBBox();x=Math.min(f.width-V.width-f.margin.left-f.margin.right,f.height-f.margin.top-f.margin.bottom)/2,x=Math.max(10,x),_=[f.margin.left+x,f.margin.top+x],r.range([0,x]),u.layout.radialAxis.domain=r.domain(),j.attr("transform","translate("+[_[0]+x,_[1]-x]+")")}else j=e.select(".legend-group").style({display:"none"});e.attr({width:f.width,height:f.height}).style({opacity:f.opacity}),F.attr("transform","translate("+_+")").style({cursor:"crosshair"});var Z=[(f.width-(f.margin.left+f.margin.right+2*x+(V?V.width:0)))/2,(f.height-(f.margin.top+f.margin.bottom+2*x))/2];if(Z[0]=Math.max(0,Z[0]),Z[1]=Math.max(0,Z[1]),e.select(".outer-group").attr("transform","translate("+Z+")"),f.title){var U=e.select("g.title-group text").style(B).text(f.title),Y=U.node().getBBox();U.attr({x:_[0]-Y.width/2,y:_[1]-x-20})}var X=e.select(".radial.axis-group");if(f.radialAxis.gridLinesVisible){var G=X.selectAll("circle.grid-circle").data(r.ticks(5));G.enter().append("circle").attr({"class":"grid-circle"}).style(q),G.attr("r",r),G.exit().remove()}X.select("circle.outside-circle").attr({r:x}).style(q);var $=e.select("circle.background-circle").attr({r:x}).style({fill:f.backgroundColor,stroke:f.stroke});if(f.radialAxis.visible){var Q=a.svg.axis().scale(r).ticks(5).tickSize(5);X.call(Q).attr({transform:"rotate("+f.radialAxis.orientation+")"}),X.selectAll(".domain").style(q),X.selectAll("g>text").text(function(t,e){return this.textContent+f.radialAxis.ticksSuffix}).style(B).style({"text-anchor":"start"}).attr({x:0,y:0,dx:0,dy:0,transform:function(t,e){return"horizontal"===f.radialAxis.tickOrientation?"rotate("+-f.radialAxis.orientation+") translate("+[0,B["font-size"]]+")":"translate("+[0,B["font-size"]]+")"}}),X.selectAll("g>line").style({stroke:"black"})}var W=e.select(".angular.axis-group").selectAll("g.angular-tick").data(N),J=W.enter().append("g").classed("angular-tick",!0);W.attr({transform:function(t,e){return"rotate("+s(t,e)+")"}}).style({display:f.angularAxis.visible?"block":"none"}),W.exit().remove(),J.append("line").classed("grid-line",!0).classed("major",function(t,e){return e%(f.minorTicks+1)==0}).classed("minor",function(t,e){return!(e%(f.minorTicks+1)==0)}).style(q),J.selectAll(".minor").style({stroke:f.minorTickColor}),W.select("line.grid-line").attr({x1:f.tickLength?x-f.tickLength:0,x2:x}).style({display:f.angularAxis.gridLinesVisible?"block":"none"}),J.append("text").classed("axis-text",!0).style(B);var K=W.select("text.axis-text").attr({x:x+f.labelOffset,dy:".35em",transform:function(t,e){var n=s(t,e),r=x+f.labelOffset,a=f.angularAxis.tickOrientation;return"horizontal"==a?"rotate("+-n+" "+r+" 0)":"radial"==a?270>n&&n>90?"rotate(180 "+r+" 0)":null:"rotate("+(180>=n&&n>0?-90:90)+" "+r+" 0)"}}).style({"text-anchor":"middle",display:f.angularAxis.labelsVisible?"block":"none"}).text(function(t,e){return e%(f.minorTicks+1)!=0?"":k?k[t]+f.angularAxis.ticksSuffix:t+f.angularAxis.ticksSuffix}).style(B);f.angularAxis.rewriteTicks&&K.text(function(t,e){return e%(f.minorTicks+1)!=0?"":f.angularAxis.rewriteTicks(this.textContent,e)});var tt=a.max(F.selectAll(".angular-tick text")[0].map(function(t,e){return t.getCTM().e+t.getBBox().width}));j.attr({transform:"translate("+[x+tt,f.margin.top]+")"});var et=e.select("g.geometry-group").selectAll("g").size()>0,nt=e.select("g.geometry-group").selectAll("g.geometry").data(h);if(nt.enter().append("g").attr({"class":function(t,e){return"geometry geometry"+e}}),nt.exit().remove(),h[0]||et){var rt=[];h.forEach(function(t,e){var n={};n.radialScale=r,n.angularScale=l,n.container=nt.filter(function(t,n){return n==e}),n.geometry=t.geometry,n.orientation=f.orientation,n.direction=f.direction,n.index=e,rt.push({data:t,geometryConfig:n})});var at=a.nest().key(function(t,e){return"undefined"!=typeof t.data.groupId||"unstacked"}).entries(rt),ot=[];at.forEach(function(t,e){"unstacked"===t.key?ot=ot.concat(t.values.map(function(t,e){return[t]})):ot.push(t.values)}),ot.forEach(function(t,e){var n;n=Array.isArray(t)?t[0].geometryConfig.geometry:t.geometryConfig.geometry;var r=t.map(function(t,e){return i(o[n].defaultConfig(),t)});o[n]().config(r)()})}var it,lt,st=e.select(".guides-group"),ct=e.select(".tooltips-group"),ut=o.tooltipPanel().config({container:ct,fontSize:8})(),ft=o.tooltipPanel().config({container:ct,fontSize:8})(),dt=o.tooltipPanel().config({container:ct,hasTick:!0})();if(!A){var ht=st.select("line").attr({x1:0,y1:0,y2:0}).style({stroke:"grey","pointer-events":"none"});F.on("mousemove.angular-guide",function(t,e){var n=o.util.getMousePos($).angle;ht.attr({x2:-x,transform:"rotate("+n+")"}).style({opacity:.5});var r=(n+180+360-f.orientation)%360;it=l.invert(r);var a=o.util.convertToCartesian(x+12,n+180);ut.text(o.util.round(it)).move([a[0]+_[0],a[1]+_[1]])}).on("mouseout.angular-guide",function(t,e){st.select("line").style({opacity:0})})}var pt=st.select("circle").style({stroke:"grey",fill:"none"});F.on("mousemove.radial-guide",function(t,e){var n=o.util.getMousePos($).radius;pt.attr({r:n}).style({opacity:.5}),lt=r.invert(o.util.getMousePos($).radius);var a=o.util.convertToCartesian(n,f.radialAxis.orientation);ft.text(o.util.round(lt)).move([a[0]+_[0],a[1]+_[1]])}).on("mouseout.radial-guide",function(t,e){pt.style({opacity:0}),dt.hide(),ut.hide(),ft.hide()}),e.selectAll(".geometry-group .mark").on("mouseover.tooltip",function(t,n){var r=a.select(this),i=r.style("fill"),l="black",s=r.style("opacity")||1;if(r.attr({"data-opacity":s}),"none"!=i){r.attr({"data-fill":i}),l=a.hsl(i).darker().toString(),r.style({fill:l,opacity:1});var c={t:o.util.round(t[0]),r:o.util.round(t[1])};A&&(c.t=k[t[0]]);var u="t: "+c.t+", r: "+c.r,f=this.getBoundingClientRect(),d=e.node().getBoundingClientRect(),h=[f.left+f.width/2-Z[0]-d.left,f.top+f.height/2-Z[1]-d.top];dt.config({color:l}).text(u),dt.move(h)}else i=r.style("stroke"),r.attr({"data-stroke":i}),l=a.hsl(i).darker().toString(),r.style({stroke:l,opacity:1})}).on("mousemove.tooltip",function(t,e){return 0!=a.event.which?!1:void(a.select(this).attr("data-fill")&&dt.show())}).on("mouseout.tooltip",function(t,e){dt.hide();var n=a.select(this),r=n.attr("data-fill");r?n.style({fill:r,opacity:n.attr("data-opacity")}):n.style({stroke:n.attr("data-stroke"),opacity:n.attr("data-opacity")})})}),d}var e,n,r,l,s={data:[],layout:{}},c={},u={},f=a.dispatch("hover"),d={};return d.render=function(e){return t(e),this},d.config=function(t){if(!arguments.length)return s;var e=o.util.cloneJson(t);return e.data.forEach(function(t,e){s.data[e]||(s.data[e]={}),i(s.data[e],o.Axis.defaultConfig().data[0]),i(s.data[e],t)}),i(s.layout,o.Axis.defaultConfig().layout),i(s.layout,e.layout),this},d.getLiveConfig=function(){return u},d.getinputConfig=function(){return c},d.radialScale=function(t){return r},d.angularScale=function(t){return l},d.svg=function(){return e},a.rebind(d,f,"on"),d},o.Axis.defaultConfig=function(t,e){var n={data:[{t:[1,2,3,4],r:[10,11,12,13],name:"Line1",geometry:"LinePlot",color:null,strokeDash:"solid",strokeColor:null,strokeSize:"1",visibleInLegend:!0,opacity:1}],layout:{defaultColorRange:a.scale.category10().range(),title:null,height:450,width:500,margin:{top:40,right:40,bottom:40,left:40},font:{size:12,color:"gray",outlineColor:"white",family:"Tahoma, sans-serif"},direction:"clockwise",orientation:0,labelOffset:10,radialAxis:{domain:null,orientation:-45,ticksSuffix:"",visible:!0,gridLinesVisible:!0,tickOrientation:"horizontal",rewriteTicks:null},angularAxis:{domain:[0,360],ticksSuffix:"",visible:!0,gridLinesVisible:!0,labelsVisible:!0,tickOrientation:"horizontal",rewriteTicks:null,ticksCount:null,ticksStep:null},minorTicks:0,tickLength:null,tickColor:"silver",minorTickColor:"#eee",backgroundColor:"none",needsEndSpacing:null,showLegend:!0,legend:{reverseOrder:!1},opacity:1}};return n},o.util={},o.DATAEXTENT="dataExtent",o.AREA="AreaChart",o.LINE="LinePlot",o.DOT="DotPlot",o.BAR="BarChart",o.util._override=function(t,e){for(var n in t)n in e&&(e[n]=t[n])},o.util._extend=function(t,e){for(var n in t)e[n]=t[n]},o.util._rndSnd=function(){return 2*Math.random()-1+(2*Math.random()-1)+(2*Math.random()-1)},o.util.dataFromEquation2=function(t,e){var n=e||6,r=a.range(0,360+n,n).map(function(e,n){var r=e*Math.PI/180,a=t(r);return[e,a]});return r},o.util.dataFromEquation=function(t,e,n){var r=e||6,o=[],i=[];a.range(0,360+r,r).forEach(function(e,n){var r=e*Math.PI/180,a=t(r);o.push(e),i.push(a)});var l={t:o,r:i};return n&&(l.name=n),l},o.util.ensureArray=function(t,e){if("undefined"==typeof t)return null;var n=[].concat(t);return a.range(e).map(function(t,e){return n[e]||n[0]})},o.util.fillArrays=function(t,e,n){return e.forEach(function(e,r){t[e]=o.util.ensureArray(t[e],n)}),t},o.util.cloneJson=function(t){return JSON.parse(JSON.stringify(t))},o.util.validateKeys=function(t,e){"string"==typeof e&&(e=e.split("."));var n=e.shift();return t[n]&&(!e.length||objHasKeys(t[n],e))},o.util.sumArrays=function(t,e){return a.zip(t,e).map(function(t,e){return a.sum(t)})},o.util.arrayLast=function(t){return t[t.length-1]},o.util.arrayEqual=function(t,e){for(var n=Math.max(t.length,e.length,1);n-- >=0&&t[n]===e[n];);return-2===n},o.util.flattenArray=function(t){for(var e=[];!o.util.arrayEqual(e,t);)e=t,t=[].concat.apply([],t);return t},o.util.deduplicate=function(t){return t.filter(function(t,e,n){return n.indexOf(t)==e})},o.util.convertToCartesian=function(t,e){var n=e*Math.PI/180,r=t*Math.cos(n),a=t*Math.sin(n);return[r,a]},o.util.round=function(t,e){var n=e||2,r=Math.pow(10,n);return Math.round(t*r)/r},o.util.getMousePos=function(t){var e=a.mouse(t.node()),n=e[0],r=e[1],o={};return o.x=n,o.y=r,o.pos=e,o.angle=180*(Math.atan2(r,n)+Math.PI)/Math.PI,o.radius=Math.sqrt(n*n+r*r),o},o.util.duplicatesCount=function(t){for(var e,n={},r={},a=0,o=t.length;o>a;a++)e=t[a],e in n?(n[e]++,r[e]=n[e]):n[e]=1;return r},o.util.duplicates=function(t){return Object.keys(o.util.duplicatesCount(t))},o.util.translator=function(t,e,n,r){if(r){var a=n.slice();n=e,e=a}var o=e.reduce(function(t,e){return"undefined"!=typeof t?t[e]:void 0},t);"undefined"!=typeof o&&(e.reduce(function(t,n,r){return"undefined"!=typeof t?(r===e.length-1&&delete t[n],t[n]):void 0},t),n.reduce(function(t,e,r){return"undefined"==typeof t[e]&&(t[e]={}),r===n.length-1&&(t[e]=o),t[e]},t))},o.PolyChart=function(){function t(){var t=n[0].geometryConfig,e=t.container;"string"==typeof e&&(e=a.select(e)),e.datum(n).each(function(e,n){function r(e,n){var r=t.radialScale(e[1]),a=(t.angularScale(e[0])+t.orientation)*Math.PI/180;return{r:r,t:a}}function o(t){var e=t.r*Math.cos(t.t),n=t.r*Math.sin(t.t);return{x:e,y:n}}var i=!!e[0].data.yStack,s=e.map(function(t,e){return i?a.zip(t.data.t[0],t.data.r[0],t.data.yStack[0]):a.zip(t.data.t[0],t.data.r[0])}),c=t.angularScale,u=t.radialScale.domain()[0],f={};f.bar=function(n,r,o){var i=e[o].data,l=t.radialScale(n[1])-t.radialScale(0),s=t.radialScale(n[2]||0),u=i.barWidth;a.select(this).attr({"class":"mark bar",d:"M"+[[l+s,-u/2],[l+s,u/2],[s,u/2],[s,-u/2]].join("L")+"Z",transform:function(e,n){return"rotate("+(t.orientation+c(e[0]))+")"}})},f.dot=function(t,n,i){var l=t[2]?[t[0],t[1]+t[2]]:t,s=a.svg.symbol().size(e[i].data.dotSize).type(e[i].data.dotType)(t,n);a.select(this).attr({"class":"mark dot",d:s,transform:function(t,e){var n=o(r(l));return"translate("+[n.x,n.y]+")"}})};var d=a.svg.line.radial().interpolate(e[0].data.lineInterpolation).radius(function(e){return t.radialScale(e[1])}).angle(function(e){return t.angularScale(e[0])*Math.PI/180});f.line=function(n,r,o){var i=n[2]?s[o].map(function(t,e){return[t[0],t[1]+t[2]]}):s[o];if(a.select(this).each(f.dot).style({opacity:function(t,n){return+e[o].data.dotVisible},fill:m.stroke(n,r,o)}).attr({"class":"mark dot"}),!(r>0)){var l=a.select(this.parentNode).selectAll("path.line").data([0]);l.enter().insert("path"),l.attr({"class":"line",d:d(i),transform:function(e,n){return"rotate("+(t.orientation+90)+")"},"pointer-events":"none"}).style({fill:function(t,e){return m.fill(n,r,o)},"fill-opacity":0,stroke:function(t,e){return m.stroke(n,r,o)},"stroke-width":function(t,e){return m["stroke-width"](n,r,o)},"stroke-dasharray":function(t,e){return m["stroke-dasharray"](n,r,o)},opacity:function(t,e){return m.opacity(n,r,o)},display:function(t,e){return m.display(n,r,o)}})}};var h=t.angularScale.range(),p=Math.abs(h[1]-h[0])/s[0].length*Math.PI/180,g=a.svg.arc().startAngle(function(t){return-p/2}).endAngle(function(t){return p/2}).innerRadius(function(e){return t.radialScale(u+(e[2]||0))}).outerRadius(function(e){return t.radialScale(u+(e[2]||0))+t.radialScale(e[1])});f.arc=function(e,n,r){a.select(this).attr({"class":"mark arc",d:g,transform:function(e,n){return"rotate("+(t.orientation+c(e[0])+90)+")"}})};var m={fill:function(t,n,r){return e[r].data.color},stroke:function(t,n,r){return e[r].data.strokeColor},"stroke-width":function(t,n,r){return e[r].data.strokeSize+"px"},"stroke-dasharray":function(t,n,r){return l[e[r].data.strokeDash]},opacity:function(t,n,r){return e[r].data.opacity},display:function(t,n,r){return"undefined"==typeof e[r].data.visible||e[r].data.visible?"block":"none"}},v=a.select(this).selectAll("g.layer").data(s);v.enter().append("g").attr({"class":"layer"});var y=v.selectAll("path.mark").data(function(t,e){return t});y.enter().append("path").attr({"class":"mark"}),y.style(m).each(f[t.geometryType]),y.exit().remove(),v.exit().remove()})}var e,n=[o.PolyChart.defaultConfig()],r=a.dispatch("hover"),l={solid:"none",dash:[5,2],dot:[2,5]};return t.config=function(t){return arguments.length?(t.forEach(function(t,e){n[e]||(n[e]={}),i(n[e],o.PolyChart.defaultConfig()),i(n[e],t)}),this):n},t.getColorScale=function(){return e},a.rebind(t,r,"on"),t},o.PolyChart.defaultConfig=function(){var t={data:{name:"geom1",t:[[1,2,3,4]],r:[[1,2,3,4]],dotType:"circle",dotSize:64,dotVisible:!1,barWidth:20,color:"#ffa500",strokeSize:1,strokeColor:"silver",strokeDash:"solid",opacity:1,index:0,visible:!0,visibleInLegend:!0},geometryConfig:{geometry:"LinePlot",geometryType:"arc",direction:"clockwise",orientation:0,container:"body",radialScale:null,angularScale:null,colorScale:a.scale.category20()}};return t},o.BarChart=function(){return o.PolyChart()},o.BarChart.defaultConfig=function(){var t={geometryConfig:{geometryType:"bar"}};return t},o.AreaChart=function(){return o.PolyChart()},o.AreaChart.defaultConfig=function(){var t={geometryConfig:{geometryType:"arc"}};return t},o.DotPlot=function(){return o.PolyChart()},o.DotPlot.defaultConfig=function(){var t={geometryConfig:{geometryType:"dot",dotType:"circle"}};return t},o.LinePlot=function(){return o.PolyChart()},o.LinePlot.defaultConfig=function(){var t={geometryConfig:{geometryType:"line"}};return t},o.Legend=function(){function t(){var n=e.legendConfig,r=e.data.map(function(t,e){return[].concat(t).map(function(t,r){var a=i({},n.elements[e]);return a.name=t,a.color=[].concat(n.elements[e].color)[r],a})}),o=a.merge(r);o=o.filter(function(t,e){return n.elements[e]&&(n.elements[e].visibleInLegend||"undefined"==typeof n.elements[e].visibleInLegend)}),n.reverseOrder&&(o=o.reverse());var l=n.container;("string"==typeof l||l.nodeName)&&(l=a.select(l));var s=o.map(function(t,e){return t.color}),c=n.fontSize,u=null==n.isContinuous?"number"==typeof o[0]:n.isContinuous,f=u?n.height:c*o.length,d=l.classed("legend-group",!0),h=d.selectAll("svg").data([0]),p=h.enter().append("svg").attr({width:300,height:f+c,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"});p.append("g").classed("legend-axis",!0),p.append("g").classed("legend-marks",!0);var g=a.range(o.length),m=a.scale[u?"linear":"ordinal"]().domain(g).range(s),v=a.scale[u?"linear":"ordinal"]().domain(g)[u?"range":"rangePoints"]([0,f]),y=function(t,e){var n=3*e;return"line"===t?"M"+[[-e/2,-e/12],[e/2,-e/12],[e/2,e/12],[-e/2,e/12]]+"Z":-1!=a.svg.symbolTypes.indexOf(t)?a.svg.symbol().type(t).size(n)():a.svg.symbol().type("square").size(n)()};if(u){var x=h.select(".legend-marks").append("defs").append("linearGradient").attr({id:"grad1",x1:"0%",y1:"0%",x2:"0%",y2:"100%"}).selectAll("stop").data(s);x.enter().append("stop"),x.attr({offset:function(t,e){return e/(s.length-1)*100+"%"}}).style({"stop-color":function(t,e){return t}}),h.append("rect").classed("legend-mark",!0).attr({height:n.height,width:n.colorBandWidth,fill:"url(#grad1)"})}else{var b=h.select(".legend-marks").selectAll("path.legend-mark").data(o);b.enter().append("path").classed("legend-mark",!0),b.attr({transform:function(t,e){return"translate("+[c/2,v(e)+c/2]+")"},d:function(t,e){var n=t.symbol;return y(n,c)},fill:function(t,e){return m(e)}}),b.exit().remove()}var _=a.svg.axis().scale(v).orient("right"),w=h.select("g.legend-axis").attr({transform:"translate("+[u?n.colorBandWidth:c,c/2]+")"}).call(_);return w.selectAll(".domain").style({fill:"none",stroke:"none"}),w.selectAll("line").style({fill:"none",stroke:u?n.textColor:"none"}),w.selectAll("text").style({fill:n.textColor,"font-size":n.fontSize}).text(function(t,e){return o[e].name}),t}var e=o.Legend.defaultConfig(),n=a.dispatch("hover");return t.config=function(t){return arguments.length?(i(e,t),this):e},a.rebind(t,n,"on"),t},o.Legend.defaultConfig=function(t,e){var n={data:["a","b","c"],legendConfig:{elements:[{symbol:"line",color:"red"},{symbol:"square",color:"yellow"},{symbol:"diamond",color:"limegreen"}],height:150,colorBandWidth:30,fontSize:12,container:"body",isContinuous:null,textColor:"grey",reverseOrder:!1}};return n},o.tooltipPanel=function(){var t,e,n,r={container:null,hasTick:!1,fontSize:12,color:"white",padding:5},l="tooltip-"+o.tooltipPanel.uid++,s=10,c=function(){t=r.container.selectAll("g."+l).data([0]);var a=t.enter().append("g").classed(l,!0).style({"pointer-events":"none",display:"none"});return n=a.append("path").style({fill:"white","fill-opacity":.9}).attr({d:"M0 0"}),e=a.append("text").attr({dx:r.padding+s,dy:.3*+r.fontSize}),c};return c.text=function(o){var i=a.hsl(r.color).l,l=i>=.5?"#aaa":"white",u=i>=.5?"black":"white",f=o||"";e.style({fill:u,"font-size":r.fontSize+"px"}).text(f);var d=r.padding,h=e.node().getBBox(),p={fill:r.color,stroke:l,"stroke-width":"2px"},g=h.width+2*d+s,m=h.height+2*d;return n.attr({d:"M"+[[s,-m/2],[s,-m/4],[r.hasTick?0:s,0],[s,m/4],[s,m/2],[g,m/2],[g,-m/2]].join("L")+"Z"}).style(p),t.attr({transform:"translate("+[s,-m/2+2*d]+")"}),t.style({display:"block"}),c},c.move=function(e){return t?(t.attr({transform:"translate("+[e[0],e[1]]+")"}).style({display:"block"}),c):void 0},c.hide=function(){return t?(t.style({display:"none"}),c):void 0},c.show=function(){return t?(t.style({display:"block"}),c):void 0},c.config=function(t){return i(r,t),c},c},o.tooltipPanel.uid=1,o.adapter={},o.adapter.plotly=function(){var t={};return t.convert=function(t,e){var n={};if(t.data&&(n.data=t.data.map(function(t,n){var r=i({},t),a=[[r,["marker","color"],["color"]],[r,["marker","opacity"],["opacity"]],[r,["marker","line","color"],["strokeColor"]],[r,["marker","line","dash"],["strokeDash"]],[r,["marker","line","width"],["strokeSize"]],[r,["marker","symbol"],["dotType"]],[r,["marker","size"],["dotSize"]],[r,["marker","barWidth"],["barWidth"]],[r,["line","interpolation"],["lineInterpolation"]],[r,["showlegend"],["visibleInLegend"]]];return a.forEach(function(t,n){o.util.translator.apply(null,t.concat(e))}),e||delete r.marker,e&&delete r.groupId,e?("LinePlot"===r.geometry?(r.type="scatter",r.dotVisible===!0?(delete r.dotVisible,r.mode="lines+markers"):r.mode="lines"):"DotPlot"===r.geometry?(r.type="scatter",r.mode="markers"):"AreaChart"===r.geometry?r.type="area":"BarChart"===r.geometry&&(r.type="bar"),delete r.geometry):("scatter"===r.type?"lines"===r.mode?r.geometry="LinePlot":"markers"===r.mode?r.geometry="DotPlot":"lines+markers"===r.mode&&(r.geometry="LinePlot",r.dotVisible=!0):"area"===r.type?r.geometry="AreaChart":"bar"===r.type&&(r.geometry="BarChart"),delete r.mode,delete r.type),r}),!e&&t.layout&&"stack"===t.layout.barmode)){var r=o.util.duplicates(n.data.map(function(t,e){return t.geometry}));n.data.forEach(function(t,e){var a=r.indexOf(t.geometry);-1!=a&&(n.data[e].groupId=a)})}if(t.layout){var l=i({},t.layout),s=[[l,["plot_bgcolor"],["backgroundColor"]],[l,["showlegend"],["showLegend"]],[l,["radialaxis"],["radialAxis"]],[l,["angularaxis"],["angularAxis"]],[l.angularaxis,["showline"],["gridLinesVisible"]],[l.angularaxis,["showticklabels"],["labelsVisible"]],[l.angularaxis,["nticks"],["ticksCount"]],[l.angularaxis,["tickorientation"],["tickOrientation"]],[l.angularaxis,["ticksuffix"],["ticksSuffix"]],[l.angularaxis,["range"],["domain"]],[l.angularaxis,["endpadding"],["endPadding"]],[l.radialaxis,["showline"],["gridLinesVisible"]],[l.radialaxis,["tickorientation"],["tickOrientation"]],[l.radialaxis,["ticksuffix"],["ticksSuffix"]],[l.radialaxis,["range"],["domain"]],[l.angularAxis,["showline"],["gridLinesVisible"]],[l.angularAxis,["showticklabels"],["labelsVisible"]],[l.angularAxis,["nticks"],["ticksCount"]],[l.angularAxis,["tickorientation"],["tickOrientation"]],[l.angularAxis,["ticksuffix"],["ticksSuffix"]],[l.angularAxis,["range"],["domain"]],[l.angularAxis,["endpadding"],["endPadding"]],[l.radialAxis,["showline"],["gridLinesVisible"]],[l.radialAxis,["tickorientation"],["tickOrientation"]],[l.radialAxis,["ticksuffix"],["ticksSuffix"]],[l.radialAxis,["range"],["domain"]],[l.font,["outlinecolor"],["outlineColor"]],[l.legend,["traceorder"],["reverseOrder"]],[l,["labeloffset"],["labelOffset"]],[l,["defaultcolorrange"],["defaultColorRange"]]];if(s.forEach(function(t,n){o.util.translator.apply(null,t.concat(e))}),e?("undefined"!=typeof l.tickLength&&(l.angularaxis.ticklen=l.tickLength,delete l.tickLength),l.tickColor&&(l.angularaxis.tickcolor=l.tickColor,delete l.tickColor)):(l.angularAxis&&"undefined"!=typeof l.angularAxis.ticklen&&(l.tickLength=l.angularAxis.ticklen),l.angularAxis&&"undefined"!=typeof l.angularAxis.tickcolor&&(l.tickColor=l.angularAxis.tickcolor)),l.legend&&"boolean"!=typeof l.legend.reverseOrder&&(l.legend.reverseOrder="normal"!=l.legend.reverseOrder),l.legend&&"boolean"==typeof l.legend.traceorder&&(l.legend.traceorder=l.legend.traceorder?"reversed":"normal",delete l.legend.reverseOrder),l.margin&&"undefined"!=typeof l.margin.t){var c=["t","r","b","l","pad"],u=["top","right","bottom","left","pad"],f={};a.entries(l.margin).forEach(function(t,e){f[u[c.indexOf(t.key)]]=t.value}),l.margin=f}e&&(delete l.needsEndSpacing,delete l.minorTickColor,delete l.minorTicks,delete l.angularaxis.ticksCount,delete l.angularaxis.ticksCount,delete l.angularaxis.ticksStep,delete l.angularaxis.rewriteTicks,delete l.angularaxis.nticks,delete l.radialaxis.ticksCount,delete l.radialaxis.ticksCount,delete l.radialaxis.ticksStep,delete l.radialaxis.rewriteTicks,delete l.radialaxis.nticks),n.layout=l}return n},t}},{"../../plotly":120,"./micropolar_manager":147,d3:16}],147:[function(t,e,n){"use strict";var r=t("../../plotly"),a=t("d3"),o=t("./undo_manager"),i=e.exports={},l=r.Lib.extendDeepAll;i.framework=function(t){function e(e,o){return o&&(f=o),a.select(a.select(f).node().parentNode).selectAll(".svg-container>*:not(.chart-root)").remove(),n=n?l(n,e):e,c||(c=r.micropolar.Axis()),u=r.micropolar.adapter.plotly().convert(n),c.config(u).render(f),t.data=n.data,t.layout=n.layout,i.fillLayout(t),n}var n,s,c,u,f,d=new o;return e.isPolar=!0,e.svg=function(){return c.svg()},e.getConfig=function(){return n},e.getLiveConfig=function(){return r.micropolar.adapter.plotly().convert(c.getLiveConfig(),!0)},e.getLiveScales=function(){return{t:c.angularScale(),r:c.radialScale()}},e.setUndoPoint=function(){var t=this,e=r.micropolar.util.cloneJson(n);!function(e,n){d.add({undo:function(){n&&t(n)},redo:function(){t(e)}})}(e,s),s=r.micropolar.util.cloneJson(e)},e.undo=function(){d.undo()},e.redo=function(){d.redo()},e},i.fillLayout=function(t){var e=a.select(t).selectAll(".plot-container"),n=e.selectAll(".svg-container"),o=t.framework&&t.framework.svg&&t.framework.svg(),i={width:800,height:600,paper_bgcolor:r.Color.background,_container:e,_paperdiv:n,_paper:o};t._fullLayout=l(i,t.layout)}},{"../../plotly":120,"./undo_manager":148,d3:16}],148:[function(t,e,n){"use strict";e.exports=function(){function t(t,e){return t?(a=!0,t[e](),a=!1,this):this}var e,n=[],r=-1,a=!1;return{add:function(t){return a?this:(n.splice(r+1,n.length-r),n.push(t),r=n.length-1,this)},setCallback:function(t){e=t},undo:function(){var a=n[r];return a?(t(a,"undo"),r-=1,e&&e(a.undo),this):this},redo:function(){var a=n[r+1];return a?(t(a,"redo"),r+=1,e&&e(a.redo),this):this},clear:function(){n=[],r=-1},hasUndo:function(){return-1!==r},hasRedo:function(){return rg;g++){var m=h[g];l=t[m]?t[m]:t[m]={},e[m]=s={},i("domain."+d,[g/p,(g+1)/p]),i("domain."+{x:"y",y:"x"}[d]),o.id=m,f(l,s,i,o)}}},{"../lib":102,"./plots":143}],150:[function(t,e,n){"use strict";var r=t("./ternary"),a=t("../../plots/plots");n.name="ternary",n.attr="subplot",n.idRoot="ternary",n.idRegex=/^ternary([2-9]|[1-9][0-9]+)?$/,n.attrRegex=/^ternary([2-9]|[1-9][0-9]+)?$/,n.attributes=t("./layout/attributes"),n.layoutAttributes=t("./layout/layout_attributes"),n.supplyLayoutDefaults=t("./layout/defaults"),n.plot=function(t){for(var e=t._fullLayout,n=t._fullData,o=a.getSubplotIds(e,"ternary"),i=0;i=i&&(h.min=0,p.min=0,g.min=0,t.aaxis&&delete t.aaxis.min,t.baxis&&delete t.baxis.min,t.caxis&&delete t.caxis.min)}var a=t("../../../components/color"),o=t("../../subplot_defaults"),i=t("./layout_attributes"),l=t("./axis_defaults"),s=["aaxis","baxis","caxis"];e.exports=function(t,e,n){o(t,e,n,{type:"ternary",attributes:i,handleDefaults:r,font:e.font,paper_bgcolor:e.paper_bgcolor})}},{"../../../components/color":25,"../../subplot_defaults":149,"./axis_defaults":153,"./layout_attributes":155}],155:[function(t,e,n){"use strict";var r=t("../../../components/color/attributes"),a=t("./axis_attributes");e.exports={domain:{x:{valType:"info_array",items:[{valType:"number",min:0,max:1},{valType:"number",min:0,max:1}],dflt:[0,1]},y:{valType:"info_array",items:[{valType:"number",min:0,max:1},{valType:"number",min:0,max:1}],dflt:[0,1]}},bgcolor:{valType:"color",dflt:r.background},sum:{valType:"number",dflt:1,min:0},aaxis:a,baxis:a,caxis:a}},{"../../../components/color/attributes":24,"./axis_attributes":152}],156:[function(t,e,n){"use strict";function r(t,e){this.id=t.id,this.graphDiv=t.graphDiv,this.init(e),this.makeFramework()}function a(t){o.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}var o=t("d3"),i=t("tinycolor2"),l=t("../../plotly"),s=t("../../lib"),c=t("../../components/color"),u=t("../../components/drawing"),f=t("../cartesian/set_convert"),d=t("../../lib/extend").extendFlat,h=t("../cartesian/axes"),p=t("../../lib/filter_visible"),g=t("../../components/dragelement"),m=t("../../components/titles"),v=t("../cartesian/select"),y=t("../cartesian/constants"),x=t("../cartesian/graph_interact");e.exports=r;var b=r.prototype;b.init=function(t){this.container=t._ternarylayer,this.defs=t._defs,this.layoutId=t._uid,this.traceHash={}},b.plot=function(t,e){var n,r=this,a=e[r.id],o=e._size;s.getPlotDiv(r.plotContainer.node())!==r.graphDiv&&(r.init(r.graphDiv._fullLayout),r.makeFramework()),r.adjustLayout(a,o);var i=r.traceHash,l={};for(n=0;n_*y?(o=y,a=o*_):(a=v,o=a/_),i=g*a/v,l=m*o/y,n=e.l+e.w*h-a/2,r=e.t+e.h*(1-p)-o/2,s.x0=n,s.y0=r,s.w=a,s.h=o,s.sum=x,s.xaxis={type:"linear",range:[b+2*k-x,x-b-2*w],domain:[h-i/2,h+i/2],_id:"x",_gd:s.graphDiv},f(s.xaxis),s.xaxis.setScale(),s.yaxis={type:"linear",range:[b,x-w-k],domain:[p-l/2,p+l/2],_id:"y",_gd:s.graphDiv},f(s.yaxis),s.yaxis.setScale();var M=s.yaxis.domain[0],A=s.aaxis=d({},t.aaxis,{range:[b,x-w-k],side:"left",_counterangle:30,tickangle:(+t.aaxis.tickangle||0)-30,domain:[M,M+l*_],_axislayer:s.layers.aaxis,_gridlayer:s.layers.agrid,_pos:0,_gd:s.graphDiv,_id:"y",_length:a,_gridpath:"M0,0l"+o+",-"+a/2});f(A);var T=s.baxis=d({},t.baxis,{range:[x-b-k,w],side:"bottom",_counterangle:30,domain:s.xaxis.domain,_axislayer:s.layers.baxis,_gridlayer:s.layers.bgrid,_counteraxis:s.aaxis,_pos:0,_gd:s.graphDiv,_id:"x",_length:a,_gridpath:"M0,0l-"+a/2+",-"+o});f(T),A._counteraxis=T;var L=s.caxis=d({},t.caxis,{range:[x-b-w,k],side:"right",_counterangle:30,tickangle:(+t.caxis.tickangle||0)+30,domain:[M,M+l*_],_axislayer:s.layers.caxis,_gridlayer:s.layers.cgrid,_counteraxis:s.baxis,_pos:0,_gd:s.graphDiv,_id:"y",_length:a,_gridpath:"M0,0l-"+o+","+a/2});f(L);var z="M"+n+","+(r+o)+"h"+a+"l-"+a/2+",-"+o+"Z";s.clipDef.select("path").attr("d",z),s.layers.plotbg.select("path").attr("d",z);var S="translate("+n+","+r+")";s.plotContainer.selectAll(".scatterlayer,.maplayer,.zoom").attr("transform",S);var C="translate("+n+","+(r+o)+")";s.layers.baxis.attr("transform",C),s.layers.bgrid.attr("transform",C);var E="translate("+(n+a/2)+","+r+")rotate(30)";s.layers.aaxis.attr("transform",E),s.layers.agrid.attr("transform",E);var O="translate("+(n+a/2)+","+r+")rotate(-30)";s.layers.caxis.attr("transform",O),s.layers.cgrid.attr("transform",O),s.drawAxes(!0),s.plotContainer.selectAll(".crisp").classed("crisp",!1);var P=s.layers.axlines;P.select(".aline").attr("d",A.showline?"M"+n+","+(r+o)+"l"+a/2+",-"+o:"M0,0").call(c.stroke,A.linecolor||"#000").style("stroke-width",(A.linewidth||0)+"px"),P.select(".bline").attr("d",T.showline?"M"+n+","+(r+o)+"h"+a:"M0,0").call(c.stroke,T.linecolor||"#000").style("stroke-width",(T.linewidth||0)+"px"),P.select(".cline").attr("d",L.showline?"M"+(n+a/2)+","+r+"l"+a/2+","+o:"M0,0").call(c.stroke,L.linecolor||"#000").style("stroke-width",(L.linewidth||0)+"px")},b.drawAxes=function(t){var e=this,n=e.graphDiv,r=e.id.substr(7)+"title",a=e.aaxis,o=e.baxis,i=e.caxis;if(h.doTicks(n,a,!0),h.doTicks(n,o,!0),h.doTicks(n,i,!0),t){var l=Math.max(a.showticklabels?a.tickfont.size/2:0,(i.showticklabels?.75*i.tickfont.size:0)+("outside"===i.ticks?.87*i.ticklen:0));m.draw(n,"a"+r,{propContainer:a,propName:e.id+".aaxis.title",dfltName:"Component A",attributes:{x:e.x0+e.w/2,y:e.y0-a.titlefont.size/3-l,"text-anchor":"middle"}});var s=(o.showticklabels?o.tickfont.size:0)+("outside"===o.ticks?o.ticklen:0)+3;m.draw(n,"b"+r,{propContainer:o,propName:e.id+".baxis.title",dfltName:"Component B",attributes:{x:e.x0-s,y:e.y0+e.h+.83*o.titlefont.size+s,"text-anchor":"middle"}}),m.draw(n,"c"+r,{propContainer:i,propName:e.id+".caxis.title",dfltName:"Component C",attributes:{x:e.x0+e.w+s,y:e.y0+e.h+.83*i.titlefont.size+s,"text-anchor":"middle"}})}};var w=y.MINZOOM/2+.87,k="m-0.87,.5h"+w+"v3h-"+(w+5.2)+"l"+(w/2+2.6)+",-"+(.87*w+4.5)+"l2.6,1.5l-"+w/2+","+.87*w+"Z",M="m0.87,.5h-"+w+"v3h"+(w+5.2)+"l-"+(w/2+2.6)+",-"+(.87*w+4.5)+"l-2.6,1.5l"+w/2+","+.87*w+"Z",A="m0,1l"+w/2+","+.87*w+"l2.6,-1.5l-"+(w/2+2.6)+",-"+(.87*w+4.5)+"l-"+(w/2+2.6)+","+(.87*w+4.5)+"l2.6,1.5l"+w/2+",-"+.87*w+"Z",T="m0.5,0.5h5v-2h-5v-5h-2v5h-5v2h5v5h2Z",L=!0;b.initInteractions=function(){function t(t,e,n){var r=R.getBoundingClientRect();b=e-r.left,w=n-r.top,z={a:I.aaxis.range[0],b:I.baxis.range[1],c:I.caxis.range[1]},C=z,S=I.aaxis.range[1]-z.a,E=i(I.graphDiv._fullLayout[I.id].bgcolor).getLuminance(),O="M0,"+I.h+"L"+I.w/2+", 0L"+I.w+","+I.h+"Z",P=!1,N=F.append("path").attr("class","zoombox").style({fill:E>.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("d",O),D=F.append("path").attr("class","zoombox-corners").style({fill:c.background,stroke:c.defaultLine,"stroke-width":1,opacity:0}).attr("d","M0,0Z"),p()}function e(t,e){return 1-e/I.h}function n(t,e){return 1-(t+(I.h-e)/Math.sqrt(3))/I.w}function r(t,e){return(t-(I.h-e)/Math.sqrt(3))/I.w}function o(t,a){var o=b+t,i=w+a,l=Math.max(0,Math.min(1,e(b,w),e(o,i))),s=Math.max(0,Math.min(1,n(b,w),n(o,i))),c=Math.max(0,Math.min(1,r(b,w),r(o,i))),u=(l/2+c)*I.w,f=(1-l/2-s)*I.w,d=(u+f)/2,h=f-u,p=(1-l)*I.h,g=p-h/_;h.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),D.transition().style("opacity",1).duration(200),P=!0)}function u(t,e){if(C===z)return 2===e&&m(),a(j);a(j);var n={};n[I.id+".aaxis.min"]=C.a,n[I.id+".baxis.min"]=C.b,n[I.id+".caxis.min"]=C.c,l.relayout(j,n),L&&j.data&&j._context.showTips&&(s.notifier("Double-click to
zoom back out","long"),L=!1)}function f(){z={a:I.aaxis.range[0],b:I.baxis.range[1],c:I.caxis.range[1]},C=z}function d(t,e){var n=t/I.xaxis._m,r=e/I.yaxis._m;C={a:z.a-r,b:z.b+(n+r)/2,c:z.c-(n-r)/2};var a=[C.a,C.b,C.c].sort(),o={a:a.indexOf(C.a),b:a.indexOf(C.b),c:a.indexOf(C.c)};a[0]<0&&(a[1]+a[0]/2<0?(a[2]+=a[0]+a[1],a[0]=a[1]=0):(a[2]+=a[0]/2,a[1]+=a[0]/2,a[0]=0),C={a:a[o.a],b:a[o.b],c:a[o.c]},e=(z.a-C.a)*I.yaxis._m,t=(z.c-C.c-z.b+C.b)*I.xaxis._m);var i="translate("+(I.x0+t)+","+(I.y0+e)+")";I.plotContainer.selectAll(".scatterlayer,.maplayer").attr("transform",i),I.aaxis.range=[C.a,I.sum-C.b-C.c],I.baxis.range=[I.sum-C.a-C.c,C.b],I.caxis.range=[I.sum-C.a-C.b,C.c],I.drawAxes(!1),I.plotContainer.selectAll(".crisp").classed("crisp",!1)}function h(t,e){if(t){var n={};n[I.id+".aaxis.min"]=C.a,n[I.id+".baxis.min"]=C.b,n[I.id+".caxis.min"]=C.c,l.relayout(j,n)}else 2===e&&m()}function p(){I.plotContainer.selectAll(".select-outline").remove()}function m(){var t={};t[I.id+".aaxis.min"]=0,t[I.id+".baxis.min"]=0,t[I.id+".caxis.min"]=0,j.emit("plotly_doubleclick",null),l.relayout(j,t)}var b,w,z,S,C,E,O,P,N,D,I=this,R=I.layers.plotbg.select("path").node(),j=I.graphDiv,F=I.layers.zoom,q={element:R,gd:j,plotinfo:{plot:F},doubleclick:m,subplot:I.id,prepFn:function(e,n,r){q.xaxes=[I.xaxis],q.yaxes=[I.yaxis];var a=j._fullLayout.dragmode;e.shiftKey&&(a="pan"===a?"zoom":"pan"),"lasso"===a?q.minDrag=1:q.minDrag=void 0,"zoom"===a?(q.moveFn=o,q.doneFn=u,t(e,n,r)):"pan"===a?(q.moveFn=d,q.doneFn=h,f(),p()):"select"!==a&&"lasso"!==a||v(e,n,r,q,a)}};R.onmousemove=function(t){x.hover(j,t,I.id),j._fullLayout._lasthover=R,j._fullLayout._hoversubplot=I.id},R.onmouseout=function(t){j._dragging||g.unhover(j,t)},R.onclick=function(t){x.click(j,t)},g.init(q)}},{"../../components/color":25,"../../components/dragelement":46,"../../components/drawing":48,"../../components/titles":88,"../../lib":102,"../../lib/extend":100,"../../lib/filter_visible":101,"../../plotly":120,"../cartesian/axes":123,"../cartesian/constants":128,"../cartesian/graph_interact":130,"../cartesian/select":136,"../cartesian/set_convert":137,d3:16,tinycolor2:20}],157:[function(t,e,n){"use strict";function r(t){var e;switch(t){case"themes__thumb":e={autosize:!0,width:150,height:150,title:"",showlegend:!1,margin:{l:5,r:5,t:5,b:5,pad:0},annotations:[]};break;case"thumbnail":e={title:"",hidesources:!0,showlegend:!1,borderwidth:0,bordercolor:"",margin:{l:1,r:1,t:1,b:1,pad:0},annotations:[]};break;default:e={}}return e}function a(t){var e=["xaxis","yaxis","zaxis"];return e.indexOf(t.slice(0,5))>-1}var o=t("../plotly"),i=o.Lib.extendFlat,l=o.Lib.extendDeep;e.exports=function(t,e){t.framework&&t.framework.isPolar&&(t=t.framework.getConfig());var n,s=t.data,c=t.layout,u=l([],s),f=l({},c,r(e.tileClass));if(e.width&&(f.width=e.width),e.height&&(f.height=e.height),"thumbnail"===e.tileClass||"themes__thumb"===e.tileClass){f.annotations=[];var d=Object.keys(f);for(n=0;ns;s++)r(n[s])&&h.push({p:n[s],s:l[s],b:0});return o(e,"marker")&&i(e,e.marker.color,"marker","c"),o(e,"marker.line")&&i(e,e.marker.line.color,"marker.line","c"),h}},{"../../components/colorscale/calc":32,"../../components/colorscale/has_colorscale":38,"../../plots/cartesian/axes":123,"fast-isnumeric":18}],167:[function(t,e,n){"use strict";var r=t("../../lib"),a=t("../../components/color"),o=t("../scatter/xy_defaults"),i=t("../bar/style_defaults"),l=t("../../components/errorbars/defaults"),s=t("./attributes");e.exports=function(t,e,n,c){function u(n,a){return r.coerce(t,e,s,n,a)}var f=o(t,e,u);return f?(u("orientation",e.x&&!e.y?"h":"v"),u("text"),i(t,e,u,n,c),l(t,e,a.defaultLine,{axis:"y"}),void l(t,e,a.defaultLine,{axis:"x",inherit:"y"})):void(e.visible=!1)}},{"../../components/color":25,"../../components/errorbars/defaults":53,"../../lib":102,"../bar/style_defaults":175,"../scatter/xy_defaults":257,"./attributes":165}],168:[function(t,e,n){"use strict";var r=t("../../plots/cartesian/graph_interact"),a=t("../../components/errorbars"),o=t("../../components/color");e.exports=function(t,e,n,i){var l,s=t.cd,c=s[0].trace,u=s[0].t,f=t.xa,d=t.ya,h="closest"===i?u.barwidth/2:u.dbar*(1-f._gd._fullLayout.bargap)/2;l="closest"!==i?function(t){return t.p}:"h"===c.orientation?function(t){return t.y}:function(t){return t.x};var p,g;"h"===c.orientation?(p=function(t){return r.inbox(t.b-e,t.x-e)+(t.x-e)/(t.x-t.b)},g=function(t){var e=l(t)-n;return r.inbox(e-h,e+h)}):(g=function(t){return r.inbox(t.b-n,t.y-n)+(t.y-n)/(t.y-t.b)},p=function(t){var n=l(t)-e;return r.inbox(n-h,n+h)});var m=r.getDistanceFunction(i,p,g);if(r.getClosest(s,m,t),t.index!==!1){var v=s[t.index],y=v.mcc||c.marker.color,x=v.mlcc||c.marker.line.color,b=v.mlw||c.marker.line.width;return o.opacity(y)?t.color=y:o.opacity(x)&&b&&(t.color=x),"h"===c.orientation?(t.x0=t.x1=f.c2p(v.x,!0),t.xLabelVal=v.s,t.y0=d.c2p(l(v)-h,!0),t.y1=d.c2p(l(v)+h,!0),t.yLabelVal=v.p):(t.y0=t.y1=d.c2p(v.y,!0),t.yLabelVal=v.s,t.x0=f.c2p(l(v)-h,!0),t.x1=f.c2p(l(v)+h,!0),t.xLabelVal=v.p),v.tx&&(t.text=v.tx),a.hoverInfo(v,c,t),[t]}}},{"../../components/color":25,"../../components/errorbars":54,"../../plots/cartesian/graph_interact":130}],169:[function(t,e,n){"use strict";var r={};r.attributes=t("./attributes"),r.layoutAttributes=t("./layout_attributes"),r.supplyDefaults=t("./defaults"),r.supplyLayoutDefaults=t("./layout_defaults"),r.calc=t("./calc"),r.setPositions=t("./set_positions"),r.colorbar=t("../scatter/colorbar"),r.arraysToCalcdata=t("./arrays_to_calcdata"),r.plot=t("./plot"),r.style=t("./style"),r.hoverPoints=t("./hover"),r.moduleType="trace",r.name="bar",r.basePlotModule=t("../../plots/cartesian"),r.categories=["cartesian","bar","oriented","markerColorscale","errorBarsOK","showLegend"],r.meta={},e.exports=r},{"../../plots/cartesian":131,"../scatter/colorbar":239,"./arrays_to_calcdata":164,"./attributes":165,"./calc":166,"./defaults":167,"./hover":168,"./layout_attributes":170,"./layout_defaults":171,"./plot":172,"./set_positions":173,"./style":174}],170:[function(t,e,n){"use strict";e.exports={barmode:{valType:"enumerated",values:["stack","group","overlay","relative"],dflt:"group"},barnorm:{valType:"enumerated",values:["","fraction","percent"],dflt:""},bargap:{valType:"number",min:0,max:1},bargroupgap:{valType:"number",min:0,max:1,dflt:0}}},{}],171:[function(t,e,n){"use strict";var r=t("../../plots/plots"),a=t("../../plots/cartesian/axes"),o=t("../../lib"),i=t("./layout_attributes");e.exports=function(t,e,n){function l(n,r){return o.coerce(t,e,i,n,r)}for(var s=!1,c=!1,u=!1,f={},d=0;d=2?o(t):t>e?Math.ceil(t):Math.floor(t)}var d,h,p,g;if("h"===l.orientation?(p=u.c2p(n.poffset+e.p,!0),g=u.c2p(n.poffset+e.p+n.barwidth,!0),d=c.c2p(e.b,!0),h=c.c2p(e.s+e.b,!0)):(d=c.c2p(n.poffset+e.p,!0),h=c.c2p(n.poffset+e.p+n.barwidth,!0),g=u.c2p(e.s+e.b,!0),p=u.c2p(e.b,!0)),!(a(d)&&a(h)&&a(p)&&a(g)&&d!==h&&p!==g))return void r.select(this).remove();var m=(e.mlw+1||l.marker.line.width+1||(e.trace?e.trace.marker.line.width:0)+1)-1,v=r.round(m/2%1,2);if(!t._context.staticPlot){var y=i.opacity(e.mc||l.marker.color),x=1>y||m>.01?o:s;d=x(d,h),h=x(h,d),p=x(p,g),g=x(g,p)}r.select(this).attr("d","M"+d+","+p+"V"+g+"H"+h+"V"+p+"Z")})}),d.call(l.plot,e)}},{"../../components/color":25,"../../components/errorbars":54,"../../lib":102,"./arrays_to_calcdata":164,d3:16,"fast-isnumeric":18}],173:[function(t,e,n){"use strict";var r=t("fast-isnumeric"),a=t("../../plots/plots"),o=t("../../plots/cartesian/axes"),i=t("../../lib");e.exports=function(t,e){var n,l,s=t._fullLayout,c=e.x(),u=e.y();["v","h"].forEach(function(f){function d(e){function n(t){t[p]=t.p+d}var r=[];e.forEach(function(e){t.calcdata[e].forEach(function(t){r.push(t.p)})});var a=i.distinctVals(r),l=a.vals,c=a.minDiff,u=!1,f=[];"group"===s.barmode&&e.forEach(function(e){u||(t.calcdata[e].forEach(function(t){u||f.forEach(function(e){Math.abs(t.p-e)_&&(S=!0,A=_),_>M+P&&(S=!0,M=_))}o.expand(v,[A,M],{tozero:!0,padded:S})}else{var N=function(t){return t[g]=t.s,t.s};for(n=0;n1||0===l.bargap&&0===l.bargroupgap&&!t[0].trace.marker.line.width)&&r.select(this).attr("shape-rendering","crispEdges")}),e.selectAll("g.points").each(function(t){var e=t[0].trace,n=e.marker,i=n.line,l=(e._input||{}).marker||{},s=o.tryColorscale(n,l,""),c=o.tryColorscale(n,l,"line.");r.select(this).selectAll("path").each(function(t){var e,o,l=(t.mlw+1||i.width+1)-1,u=r.select(this);e="mc"in t?t.mcc=s(t.mc):Array.isArray(n.color)?a.defaultLine:n.color,u.style("stroke-width",l+"px").call(a.fill,e),l&&(o="mlc"in t?t.mlcc=c(t.mlc):Array.isArray(i.color)?a.defaultLine:i.color,u.call(a.stroke,o))})}),e.call(i.style)}},{"../../components/color":25,"../../components/drawing":48,"../../components/errorbars":54,d3:16}],175:[function(t,e,n){"use strict";var r=t("../../components/color"),a=t("../../components/colorscale/has_colorscale"),o=t("../../components/colorscale/defaults");e.exports=function(t,e,n,i,l){n("marker.color",i),a(t,"marker")&&o(t,e,l,n,{prefix:"marker.",cLetter:"c"}),n("marker.line.color",r.defaultLine),a(t,"marker.line")&&o(t,e,l,n,{prefix:"marker.line.",cLetter:"c"}),n("marker.line.width")}},{"../../components/color":25,"../../components/colorscale/defaults":35,"../../components/colorscale/has_colorscale":38}],176:[function(t,e,n){"use strict";var r=t("../scatter/attributes"),a=t("../../components/color/attributes"),o=t("../../lib/extend").extendFlat,i=r.marker,l=i.line;e.exports={y:{valType:"data_array"},x:{valType:"data_array"},x0:{valType:"any"},y0:{valType:"any"},whiskerwidth:{valType:"number",min:0,max:1,dflt:.5},boxpoints:{valType:"enumerated",values:["all","outliers","suspectedoutliers",!1],dflt:"outliers"},boxmean:{valType:"enumerated",values:[!0,"sd",!1],dflt:!1},jitter:{valType:"number",min:0,max:1},pointpos:{valType:"number",min:-2,max:2},orientation:{valType:"enumerated",values:["v","h"]},marker:{outliercolor:{valType:"color",dflt:"rgba(0, 0, 0, 0)"},symbol:o({},i.symbol,{arrayOk:!1}),opacity:o({},i.opacity,{arrayOk:!1,dflt:1}),size:o({},i.size,{arrayOk:!1}),color:o({},i.color,{arrayOk:!1}),line:{color:o({},l.color,{arrayOk:!1,dflt:a.defaultLine}),width:o({},l.width,{arrayOk:!1,dflt:0}),outliercolor:{valType:"color"},outlierwidth:{valType:"number",min:0,dflt:1}}},line:{color:{valType:"color"},width:{valType:"number",min:0,dflt:2}},fillcolor:r.fillcolor +-}},{"../../components/color/attributes":24,"../../lib/extend":100,"../scatter/attributes":236}],177:[function(t,e,n){"use strict";var r=t("fast-isnumeric"),a=t("../../lib"),o=t("../../plots/cartesian/axes");e.exports=function(t,e){function n(t,e,n,o,i){var l;return n in e?p=o.makeCalcdata(e,n):(l=n+"0"in e?e[n+"0"]:"name"in e&&("category"===o.type||r(e.name)&&-1!==["linear","log"].indexOf(o.type)||a.isDateTime(e.name)&&"date"===o.type)?e.name:t.numboxes,l=o.d2c(l),p=i.map(function(){return l})),p}function i(t,e,n,o,i){var l,s,c,u,f=o.length,d=e.length,h=[],p=[];for(l=0;f>l;++l)s=o[l],t[l]={pos:s},p[l]=s-i,h[l]=[];for(p.push(o[f-1]+i),l=0;d>l;++l)u=e[l],r(u)&&(c=a.findBin(n[l],p),c>=0&&d>c&&h[c].push(u));return h}function l(t,e){var n,r,o,i;for(i=0;i1,v=n.dPos*(1-d.boxgap)*(1-d.boxgroupgap)/(m?t.numboxes:1),y=m?2*n.dPos*(-.5+(n.boxnum+.5)/t.numboxes)*(1-d.boxgap):0,x=v*g.whiskerwidth;return g.visible!==!0||n.emptybox?void o.select(this).remove():("h"===g.orientation?(s=p,f=h):(s=h,f=p),n.bPos=y,n.bdPos=v,r(),o.select(this).selectAll("path.box").data(i.identity).enter().append("path").attr("class","box").each(function(t){var e=s.c2p(t.pos+y,!0),n=s.c2p(t.pos+y-v,!0),r=s.c2p(t.pos+y+v,!0),a=s.c2p(t.pos+y-x,!0),l=s.c2p(t.pos+y+x,!0),c=f.c2p(t.q1,!0),u=f.c2p(t.q3,!0),d=i.constrain(f.c2p(t.med,!0),Math.min(c,u)+1,Math.max(c,u)-1),h=f.c2p(g.boxpoints===!1?t.min:t.lf,!0),p=f.c2p(g.boxpoints===!1?t.max:t.uf,!0);"h"===g.orientation?o.select(this).attr("d","M"+d+","+n+"V"+r+"M"+c+","+n+"V"+r+"H"+u+"V"+n+"ZM"+c+","+e+"H"+h+"M"+u+","+e+"H"+p+(0===g.whiskerwidth?"":"M"+h+","+a+"V"+l+"M"+p+","+a+"V"+l)):o.select(this).attr("d","M"+n+","+d+"H"+r+"M"+n+","+c+"H"+r+"V"+u+"H"+n+"ZM"+e+","+c+"V"+h+"M"+e+","+u+"V"+p+(0===g.whiskerwidth?"":"M"+a+","+h+"H"+l+"M"+a+","+p+"H"+l))}),g.boxpoints&&o.select(this).selectAll("g.points").data(function(t){return t.forEach(function(t){t.t=n,t.trace=g}),t}).enter().append("g").attr("class","points").selectAll("path").data(function(t){var e,n,r,o,l,s,f,d="all"===g.boxpoints?t.val:t.val.filter(function(e){return et.uf}),h=(t.q3-t.q1)*u,p=[],m=0;if(g.jitter){for(e=0;et.lo&&(r.so=!0),r})}).enter().append("path").call(l.translatePoints,h,p),void(g.boxmean&&o.select(this).selectAll("path.mean").data(i.identity).enter().append("path").attr("class","mean").style("fill","none").each(function(t){var e=s.c2p(t.pos+y,!0),n=s.c2p(t.pos+y-v,!0),r=s.c2p(t.pos+y+v,!0),a=f.c2p(t.mean,!0),i=f.c2p(t.mean-t.sd,!0),l=f.c2p(t.mean+t.sd,!0);"h"===g.orientation?o.select(this).attr("d","M"+a+","+n+"V"+r+("sd"!==g.boxmean?"":"m0,0L"+i+","+e+"L"+a+","+n+"L"+l+","+e+"Z")):o.select(this).attr("d","M"+n+","+a+"H"+r+("sd"!==g.boxmean?"":"m0,0L"+e+","+i+"L"+n+","+a+"L"+e+","+l+"Z"))})))})}},{"../../components/drawing":48,"../../lib":102,d3:16}],184:[function(t,e,n){"use strict";var r=t("../../plots/plots"),a=t("../../plots/cartesian/axes"),o=t("../../lib");e.exports=function(t,e){var n,i,l,s,c=t._fullLayout,u=e.x(),f=e.y(),d=["v","h"];for(i=0;in;n++)e=f[n],h[n]=e[0]*(t.zmax-t.zmin)+t.zmin,p[n]=e[1];var g=r.extent([t.zmin,t.zmax,o.start,o.start+s*(c-1)]),m=g[t.zminn;n++)e=f[n],h[n]=(e[0]*(c+u-1)-u/2)*s+i,p[n]=e[1];var y=r.scale.linear().interpolate(r.interpolateRgb).domain(h).range(p);return y}},{"../../components/colorscale/get_scale":37,d3:16}],193:[function(t,e,n){"use strict";function r(t,e,n){var r=n[0].trace,o=n[0].x,l=n[0].y,c=r.contours,u=r.uid,f=e.x(),d=e.y(),m=t._fullLayout,x="contour"+u,b=a(c,e,n[0]);if(r.visible!==!0)return m._paper.selectAll("."+x+",.hm"+u).remove(),void m._infolayer.selectAll(".cb"+u).remove();"heatmap"===c.coloring?(r.zauto&&r.autocontour===!1&&(r._input.zmin=r.zmin=c.start-c.size/2,r._input.zmax=r.zmax=r.zmin+b.length*c.size),k(t,e,[n])):m._paper.selectAll(".hm"+u).remove(),i(b),s(b);var _=f.c2p(o[0],!0),w=f.c2p(o[o.length-1],!0),M=d.c2p(l[0],!0),A=d.c2p(l[l.length-1],!0),T=[[_,A],[w,A],[w,M],[_,M]],L=h(e,n,x);p(L,T,c),g(L,b,T,c),v(L,b,c),y(L,e,n[0],T)}function a(t,e,n){for(var r=t.size||1,a=[],o=t.start;ot?0:1)+(e[0][1]>t?0:2)+(e[1][1]>t?0:4)+(e[1][0]>t?0:8);if(5===n||10===n){var r=(e[0][0]+e[0][1]+e[1][0]+e[1][1])/4;return t>r?5===n?713:1114:5===n?104:208}return 15===n?0:n}function i(t){var e,n,r,a,i,l,s,c,u,f=t[0].z,d=f.length,h=f[0].length,p=2===d||2===h;for(n=0;d-1>n;n++)for(a=[],0===n&&(a=a.concat(M)),n===d-2&&(a=a.concat(A)),e=0;h-1>e;e++)for(r=a.slice(),0===e&&(r=r.concat(T)),e===h-2&&(r=r.concat(L)),i=e+","+n,l=[[f[n][e],f[n][e+1]],[f[n+1][e],f[n+1][e+1]]],u=0;ua;a++){if(l>20?(l=S[l][(s[0]||s[1])<0?0:1],t.crossings[i]=C[l]):delete t.crossings[i],s=z[l],!s){_.log("Found bad marching index:",l,e,t.level);break}if(h.push(d(t,e,s)),e[0]+=s[0],e[1]+=s[1],u(h[h.length-1],h[h.length-2])&&h.pop(),i=e.join(","),i===o&&s.join(",")===p||n&&(s[0]&&(e[0]<0||e[0]>m-2)||s[1]&&(e[1]<0||e[1]>g-2)))break;l=t.crossings[i]}1e4===a&&_.log("Infinite loop in contour?");var v,y,x,b,w,k,M,A=u(h[0],h[h.length-1]),T=0,L=.2*t.smoothing,E=[],O=0;for(a=1;a=O;a--)if(v=E[a],P>v){for(x=0,y=a-1;y>=O&&v+E[y]x&&v+E[x]e;)e++,n=Object.keys(a.crossings)[0].split(",").map(Number),l(a,n);1e4===e&&_.log("Infinite loop in contour?")}}function c(t,e,n){var r=0,a=0;return t>20&&e?208===t||1114===t?r=0===n[0]?1:-1:a=0===n[1]?1:-1:-1!==M.indexOf(t)?a=1:-1!==T.indexOf(t)?r=1:-1!==A.indexOf(t)?a=-1:r=-1,[r,a]}function u(t,e){return Math.abs(t[0]-e[0])<.01&&Math.abs(t[1]-e[1])<.01}function f(t,e){var n=t[0]-e[0],r=t[1]-e[1];return Math.sqrt(n*n+r*r)}function d(t,e,n){var r=e[0]+Math.max(n[0],0),a=e[1]+Math.max(n[1],0),o=t.z[a][r],i=t.xaxis,l=t.yaxis;if(n[1]){var s=(t.level-o)/(t.z[a][r+1]-o);return[i.c2p((1-s)*t.x[r]+s*t.x[r+1],!0),l.c2p(t.y[a],!0)]}var c=(t.level-o)/(t.z[a+1][r]-o);return[i.c2p(t.x[r],!0),l.c2p((1-c)*t.y[a]+c*t.y[a+1],!0)]}function h(t,e,n){var r=t.plot.select(".maplayer").selectAll("g.contour."+n).data(e);return r.enter().append("g").classed("contour",!0).classed(n,!0),r.exit().remove(),r}function p(t,e,n){var r=t.selectAll("g.contourbg").data([0]);r.enter().append("g").classed("contourbg",!0);var a=r.selectAll("path").data("fill"===n.coloring?[0]:[]);a.enter().append("path"),a.exit().remove(),a.attr("d","M"+e.join("L")+"Z").style("stroke","none")}function g(t,e,n,r){var a=t.selectAll("g.contourfill").data([0]);a.enter().append("g").classed("contourfill",!0);var o=a.selectAll("path").data("fill"===r.coloring?e:[]);o.enter().append("path"),o.exit().remove(),o.each(function(t){var e=m(t,n);e?b.select(this).attr("d",e).style("stroke","none"):b.select(this).remove()})}function m(t,e){function n(t){return Math.abs(t[1]-e[0][1])<.01}function r(t){return Math.abs(t[1]-e[2][1])<.01}function a(t){return Math.abs(t[0]-e[0][0])<.01}function o(t){return Math.abs(t[0]-e[2][0])<.01}for(var i,l,s,c,u,f,d=t.edgepaths.length||t.z[0][0]s;s++){if(!i){_.log("Missing end?",h,t);break}for(n(i)&&!o(i)?l=e[1]:a(i)?l=e[0]:r(i)?l=e[3]:o(i)&&(l=e[2]),u=0;u=0&&(l=m,c=u):Math.abs(i[1]-l[1])<.01?Math.abs(i[1]-m[1])<.01&&(m[0]-i[0])*(l[0]-m[0])>=0&&(l=m,c=u):_.log("endpt to newendpt is not vert. or horz.",i,l,m)}if(i=l,c>=0)break;d+="L"+l}if(c===t.edgepaths.length){_.log("unclosed perimeter path");break}h=c,g=-1===p.indexOf(h),g&&(h=p[0],d+="Z")}for(h=0;he;e++)l.push(1);for(e=0;o>e;e++)a.push(l.slice());for(e=0;ei;i++)for(r=a(s,i),u[i]=new Array(r),l=0;r>l;l++)u[i][l]=e(o(s,i,l));return u}function a(t,e,n,r,a,o){var i,l,s,c=[],u=d.traceIs(t,"contour"),f=d.traceIs(t,"histogram"),h=d.traceIs(t,"gl2d"),p=Array.isArray(e)&&e.length>1;if(p&&!f&&"category"!==o.type){e=e.map(o.d2c);var g=e.length;if(!(a>=g))return u?e.slice(0,a):e.slice(0,a+1);if(u||h)c=e.slice(0,a);else if(1===a)c=[e[0]-.5,e[0]+.5];else{for(c=[1.5*e[0]-.5*e[1]],s=1;g>s;s++)c.push(.5*(e[s-1]+e[s]));c.push(1.5*e[g-1]-.5*e[g-2])}if(a>g){var m=c[c.length-1],v=m-c[c.length-2];for(s=g;a>s;s++)m+=v,c.push(m)}}else for(l=r||1,i=f||"category"===o.type?n||0:Array.isArray(e)&&1===e.length?e[0]:void 0===n?0:o.d2c(n),s=u||h?0:-.5;a>s;s++)c.push(i+l*s);return c}function o(t){return.5-.25*Math.min(1,.5*t)}function i(t,e,n){var r,a,i=1;if(Array.isArray(n))for(r=0;rr&&i>y;r++)i=s(t,e,o(i));return i>y&&u.log("interp2d didn't converge quickly",i),t}function l(t){var e,n,r,a,o,i,l,s,c=[],u={},f=[],d=t[0],h=[],p=[0,0,0],g=v(t);for(n=0;nr;r++)void 0===h[r]&&(i=(void 0!==h[r-1]?1:0)+(void 0!==h[r+1]?1:0)+(void 0!==e[r]?1:0)+(void 0!==d[r]?1:0),i?(0===n&&i++,0===r&&i++,n===t.length-1&&i++,r===h.length-1&&i++,4>i&&(u[[n,r]]=[n,r,i]),c.push([n,r,i])):f.push([n,r]));for(;f.length;){for(l={},s=!1,o=f.length-1;o>=0;o--)a=f[o],n=a[0],r=a[1],i=((u[[n-1,r]]||p)[2]+(u[[n+1,r]]||p)[2]+(u[[n,r-1]]||p)[2]+(u[[n,r+1]]||p)[2])/20,i&&(l[a]=[n,r,i],f.splice(o,1),s=!0);if(!s)throw"findEmpties iterated with no new neighbors";for(a in l)u[a]=l[a],c.push(l[a])}return c.sort(function(t,e){return e[2]-t[2]})}function s(t,e,n){var r,a,o,i,l,s,c,u,f,d,h,p,g,m=0;for(i=0;il;l++)s=x[l],c=t[a+s[0]],c&&(u=c[o+s[1]],void 0!==u&&(0===d?p=g=u:(p=Math.min(p,u),g=Math.max(g,u)),f++,d+=u));if(0===f)throw"iterateInterp2d order is wrong: no defined neighbors";t[a][o]=d/f,void 0===h?4>f&&(m=1):(t[a][o]=(1+n)*t[a][o]-n*h,g>p&&(m=Math.max(m,Math.abs(t[a][o]-h)/(g-p))))}return m}var c=t("fast-isnumeric"),u=t("../../lib"),f=t("../../plots/cartesian/axes"),d=t("../../plots/plots"),h=t("../histogram2d/calc"),p=t("../../components/colorscale/calc"),g=t("./has_columns"),m=t("./convert_column_xyz"),v=t("./max_row_length");e.exports=function(t,e){function n(t){L=e._input.zsmooth=e.zsmooth=!1,u.notifier("cannot fast-zsmooth: "+t)}var o,s,c,y,x,b,_,w,k=f.getFromId(t,e.xaxis||"x"),M=f.getFromId(t,e.yaxis||"y"),A=d.traceIs(e,"contour"),T=d.traceIs(e,"histogram"),L=A?"best":e.zsmooth;if(k._minDtick=0,M._minDtick=0,T){var z=h(t,e);o=z.x,s=z.x0,c=z.dx,y=z.y,x=z.y0,b=z.dy,_=z.z}else g(e)&&m(e,k,M),o=e.x?k.makeCalcdata(e,"x"):[],y=e.y?M.makeCalcdata(e,"y"):[],s=e.x0||0,c=e.dx||1,x=e.y0||0,b=e.dy||1,_=r(e),(A||e.connectgaps)&&(e._emptypoints=l(_),e._interpz=i(_,e._emptypoints,e._interpz));if("fast"===L)if("log"===k.type||"log"===M.type)n("log axis found");else if(!T){if(o.length){var S=(o[o.length-1]-o[0])/(o.length-1),C=Math.abs(S/100);for(w=0;wC){n("x scale is not linear");break}}if(y.length&&"fast"===L){var E=(y[y.length-1]-y[0])/(y.length-1),O=Math.abs(E/100);for(w=0;wO){n("y scale is not linear");break}}}var P=v(_),N="scaled"===e.xtype?"":e.x,D=a(e,N,s,c,P,k),I="scaled"===e.ytype?"":e.y,R=a(e,I,x,b,_.length,M);f.expand(k,D),f.expand(M,R);var j={x:D,y:R,z:_};if(p(e,_,"","z"),A&&e.contours&&"heatmap"===e.contours.coloring){var F="contour"===e.type?"heatmap":"histogram2d";j.xfill=a(F,N,s,c,P,k),j.yfill=a(F,I,x,b,_.length,M)}return[j]};var y=.01,x=[[-1,0],[1,0],[0,-1],[0,1]]},{"../../components/colorscale/calc":32,"../../lib":102,"../../plots/cartesian/axes":123,"../../plots/plots":143,"../histogram2d/calc":217,"./convert_column_xyz":199,"./has_columns":201,"./max_row_length":204,"fast-isnumeric":18}],198:[function(t,e,n){"use strict";var r=t("d3"),a=t("fast-isnumeric"),o=t("../../lib"),i=t("../../plots/plots"),l=t("../../components/colorscale/get_scale"),s=t("../../components/colorbar/draw");e.exports=function(t,e){var n=e[0].trace,c="cb"+n.uid,u=l(n.colorscale),f=n.zmin,d=n.zmax;if(a(f)||(f=o.aggNums(Math.min,null,n.z)),a(d)||(d=o.aggNums(Math.max,null,n.z)),t._fullLayout._infolayer.selectAll("."+c).remove(),!n.showscale)return void i.autoMargin(t,c);var h=e[0].t.cb=s(t,c);h.fillcolor(r.scale.linear().domain(u.map(function(t){return f+t[0]*(d-f)})).range(u.map(function(t){return t[1]}))).filllevels({start:f,end:d,size:(d-f)/254}).options(n.colorbar)()}},{"../../components/colorbar/draw":28,"../../components/colorscale/get_scale":37,"../../lib":102,"../../plots/plots":143,d3:16,"fast-isnumeric":18}],199:[function(t,e,n){"use strict";var r=t("../../lib");e.exports=function(t,e,n){var a,o=t.x.slice(),i=t.y.slice(),l=t.z,s=t.text,c=Math.min(o.length,i.length,l.length),u=void 0!==s&&!Array.isArray(s[0]);for(ca;a++)o[a]=e.d2c(o[a]),i[a]=n.d2c(i[a]);var f,d,h,p=r.distinctVals(o),g=p.vals,m=r.distinctVals(i),v=m.vals,y=r.init2dArray(v.length,g.length);for(u&&(h=r.init2dArray(v.length,g.length)),a=0;c>a;a++)f=r.findBin(o[a]+p.minDiff/2,g),d=r.findBin(i[a]+m.minDiff/2,v),y[d][f]=l[a],u&&(h[d][f]=s[a]);t.x=g,t.y=v,t.z=y,u&&(t.text=h)}},{"../../lib":102}],200:[function(t,e,n){"use strict";var r=t("../../lib"),a=t("./has_columns"),o=t("./xyz_defaults"),i=t("../../components/colorscale/defaults"),l=t("./attributes");e.exports=function(t,e,n,s){function c(n,a){return r.coerce(t,e,l,n,a)}var u=o(t,e,c);return u?(c("text"),c("zsmooth"),c("connectgaps",a(e)&&e.zsmooth!==!1),void i(t,e,s,c,{prefix:"",cLetter:"z"})):void(e.visible=!1)}},{"../../components/colorscale/defaults":35,"../../lib":102,"./attributes":196,"./has_columns":201,"./xyz_defaults":207}],201:[function(t,e,n){"use strict";e.exports=function(t){return!Array.isArray(t.z[0])}},{}],202:[function(t,e,n){"use strict";var r=t("../../plots/cartesian/graph_interact"),a=t("../../lib"),o=t("../../plots/cartesian/constants").MAXDIST;e.exports=function(t,e,n,i,l){if(!(t.distanceu||u>=y[0].length||0>f||f>y.length)return}else{if(r.inbox(e-m[0],e-m[m.length-1])>o||r.inbox(n-v[0],n-v[v.length-1])>o)return;if(l){var k;for(b=[2*m[0]-m[1]],k=1;k0;)_=m.c2p(C[A]),A--;for(b>_&&(w=_,_=b,b=w,I=!0),A=0;void 0===k&&A0;)M=v.c2p(E[A]),A--;if(k>M&&(w=k,k=M,M=w,R=!0),O&&(C=n[0].xfill,E=n[0].yfill),"fast"!==P){var j="best"===P?0:.5;b=Math.max(-j*m._length,b),_=Math.min((1+j)*m._length,_),k=Math.max(-j*v._length,k),M=Math.min((1+j)*v._length,M)}var F=Math.round(_-b),q=Math.round(M-k),B=0>=F||0>=q,H=e.plot.select(".imagelayer").selectAll("g.hm."+x).data(B?[]:[0]);if(H.enter().append("g").classed("hm",!0).classed(x,!0),H.exit().remove(),!B){var V,Z;"fast"===P?(V=D,Z=N):(V=F,Z=q);var U=document.createElement("canvas");U.width=V,U.height=Z;var Y,X,G=U.getContext("2d"),$=a.scale.linear().domain(S.map(function(t){return t[0]})).range(S.map(function(t){var e=o(t[1]).toRgb();return[e.r,e.g,e.b,e.a]})).clamp(!0);"fast"===P?(Y=I?function(t){return D-1-t}:i.identity,X=R?function(t){return N-1-t}:i.identity):(Y=function(t){return i.constrain(Math.round(m.c2p(C[t])-b),0,F)},X=function(t){return i.constrain(Math.round(v.c2p(E[t])-k),0,q)});var Q,W,J,K,tt,et,nt=X(0),rt=[nt,nt],at=I?0:1,ot=R?0:1,it=0,lt=0,st=0,ct=0;if(P){var ut=0,ft=new Uint8Array(F*q*4);if("best"===P){var dt,ht,pt,gt=new Array(C.length),mt=new Array(E.length),vt=new Array(F);for(A=0;AA;A++)vt[A]=r(A,gt);for(W=0;q>W;W++)for(dt=r(W,mt),ht=T[dt.bin0],pt=T[dt.bin1],A=0;F>A;A++,ut+=4)et=h(ht,pt,vt[A],dt),d(ft,ut,et)}else for(W=0;N>W;W++)for(tt=T[W],rt=X(W),A=0;F>A;A++)et=f(tt[A],1),ut=4*(rt*F+Y(A)),d(ft,ut,et);var yt=G.createImageData(F,q);yt.data.set(ft),G.putImageData(yt,0,0)}else for(W=0;N>W;W++)if(tt=T[W],rt.reverse(),rt[ot]=X(W+1),rt[0]!==rt[1]&&void 0!==rt[0]&&void 0!==rt[1])for(J=Y(0),Q=[J,J],A=0;D>A;A++)Q.reverse(),Q[at]=Y(A+1),Q[0]!==Q[1]&&void 0!==Q[0]&&void 0!==Q[1]&&(K=tt[A],et=f(K,(Q[1]-Q[0])*(rt[1]-rt[0])),G.fillStyle="rgba("+et.join(",")+")",G.fillRect(Q[0],rt[0],Q[1]-Q[0],rt[1]-rt[0]));lt=Math.round(lt/it),st=Math.round(st/it),ct=Math.round(ct/it);var xt=o("rgb("+lt+","+st+","+ct+")");t._hmpixcount=(t._hmpixcount||0)+it,t._hmlumcount=(t._hmlumcount||0)+it*xt.getLuminance();var bt=H.selectAll("image").data(n);bt.enter().append("svg:image").attr({xmlns:c.svg,preserveAspectRatio:"none"}),bt.attr({height:q,width:F,x:b,y:k,"xlink:href":U.toDataURL("image/png")}),bt.exit().remove()}}var a=t("d3"),o=t("tinycolor2"),i=t("../../lib"),l=t("../../plots/plots"),s=t("../../components/colorscale/get_scale"),c=t("../../constants/xmlns_namespaces"),u=t("./max_row_length");e.exports=function(t,e,n){for(var a=0;a0&&(r=!0);for(var l=0;la;a++)e[a]?(t[a]/=e[a],r+=t[a]):t[a]=null;return r}},{}],210:[function(t,e,n){"use strict";e.exports=function(t,e,n,r){return n("histnorm"),r.forEach(function(t){var e=n(t+"bins.start"),r=n(t+"bins.end"),a=n("autobin"+t,!(e&&r));n(a?"nbins"+t:t+"bins.size")}),e}},{}],211:[function(t,e,n){"use strict";var r=t("fast-isnumeric");e.exports={count:function(t,e,n){return n[t]++,1},sum:function(t,e,n,a){var o=a[e];return r(o)?(o=Number(o),n[t]+=o,o):0},avg:function(t,e,n,a,o){var i=a[e];return r(i)&&(i=Number(i),n[t]+=i,o[t]++),0},min:function(t,e,n,a){var o=a[e];if(r(o)){if(o=Number(o),!r(n[t]))return n[t]=o,o;if(n[t]>o)return n[t]=o,o-n[t]}return 0},max:function(t,e,n,a){var o=a[e];if(r(o)){if(o=Number(o),!r(n[t]))return n[t]=o,o;if(n[t]n&&c.length<5e3;)g=o.tickIncrement(n,x.size),c.push((n+g)/2),u.push(S),b&&_.push(n),L&&w.push(1/(g-n)),O&&k.push(0),n=g;var P=u.length;for(n=0;n=0&&P>v&&(M+=C(v,n,u,y,k));O&&(M=s(u,k)),E&&E(u,M,w);var N=Math.min(c.length,u.length),D=[],I=0,R=N-1;for(n=0;N>n;n++)if(u[n]){I=n;break}for(n=N-1;n>I;n--)if(u[n]){R=n;break}for(n=I;R>=n;n++)r(c[n])&&r(u[n])&&D.push({p:c[n],s:u[n],b:0});return D}}},{"../../lib":102,"../../plots/cartesian/axes":123,"./average":209,"./bin_functions":211,"./norm_functions":215,"fast-isnumeric":18}],213:[function(t,e,n){"use strict";var r=t("../../lib"),a=t("../../components/color"),o=t("./bin_defaults"),i=t("../bar/style_defaults"),l=t("../../components/errorbars/defaults"),s=t("./attributes");e.exports=function(t,e,n,c){function u(n,a){return r.coerce(t,e,s,n,a)}var f=u("x"),d=u("y");u("text");var h=u("orientation",d&&!f?"h":"v"),p=e["v"===h?"x":"y"];if(!p||!p.length)return void(e.visible=!1);var g=e["h"===h?"x":"y"];g&&u("histfunc");var m="h"===h?["y"]:["x"];o(t,e,u,m),i(t,e,u,n,c),l(t,e,a.defaultLine,{axis:"y"}),l(t,e,a.defaultLine,{axis:"x",inherit:"y"})}},{"../../components/color":25,"../../components/errorbars/defaults":53,"../../lib":102,"../bar/style_defaults":175,"./attributes":208,"./bin_defaults":210}],214:[function(t,e,n){"use strict";var r={};r.attributes=t("./attributes"),r.layoutAttributes=t("../bar/layout_attributes"),r.supplyDefaults=t("./defaults"),r.supplyLayoutDefaults=t("../bar/layout_defaults"),r.calc=t("./calc"),r.setPositions=t("../bar/set_positions"),r.plot=t("../bar/plot"),r.style=t("../bar/style"),r.colorbar=t("../scatter/colorbar"),r.hoverPoints=t("../bar/hover"),r.moduleType="trace",r.name="histogram",r.basePlotModule=t("../../plots/cartesian"),r.categories=["cartesian","bar","histogram","oriented","errorBarsOK","showLegend"],r.meta={},e.exports=r},{"../../plots/cartesian":131,"../bar/hover":168,"../bar/layout_attributes":170,"../bar/layout_defaults":171,"../bar/plot":172,"../bar/set_positions":173,"../bar/style":174,"../scatter/colorbar":239,"./attributes":208,"./calc":212,"./defaults":213}],215:[function(t,e,n){"use strict";e.exports={percent:function(t,e){for(var n=t.length,r=100/e,a=0;n>a;a++)t[a]*=r},probability:function(t,e){for(var n=t.length,r=0;n>r;r++)t[r]/=e},density:function(t,e,n,r){var a=t.length;r=r||1;for(var o=0;a>o;o++)t[o]*=n[o]*r},"probability density":function(t,e,n,r){var a=t.length;r&&(e/=r);for(var o=0;a>o;o++)t[o]*=n[o]/e}}},{}],216:[function(t,e,n){"use strict";var r=t("../histogram/attributes"),a=t("../heatmap/attributes"),o=t("../../components/colorscale/attributes"),i=t("../../lib/extend").extendFlat;e.exports=i({},{x:r.x,y:r.y,z:{valType:"data_array"},marker:{color:{valType:"data_array"}},histnorm:r.histnorm,histfunc:r.histfunc,autobinx:r.autobinx,nbinsx:r.nbinsx,xbins:r.xbins,autobiny:r.autobiny,nbinsy:r.nbinsy,ybins:r.ybins,zsmooth:a.zsmooth,_nestedModules:{colorbar:"Colorbar"}},o,{autocolorscale:i({},o.autocolorscale,{dflt:!1})})},{"../../components/colorscale/attributes":31,"../../lib/extend":100,"../heatmap/attributes":196,"../histogram/attributes":208}],217:[function(t,e,n){"use strict";var r=t("../../lib"),a=t("../../plots/cartesian/axes"),o=t("../histogram/bin_functions"),i=t("../histogram/norm_functions"),l=t("../histogram/average");e.exports=function(t,e){var n,s,c,u,f,d,h=a.getFromId(t,e.xaxis||"x"),p=e.x?h.makeCalcdata(e,"x"):[],g=a.getFromId(t,e.yaxis||"y"),m=e.y?g.makeCalcdata(e,"y"):[],v=Math.min(p.length,m.length);p.length>v&&p.splice(v,p.length-v),m.length>v&&m.splice(v,m.length-v),!e.autobinx&&"xbins"in e||(e.xbins=a.autoBin(p,h,e.nbinsx,"2d"),"histogram2dcontour"===e.type&&(e.xbins.start-=e.xbins.size,e.xbins.end+=e.xbins.size),e._input.xbins=e.xbins),!e.autobiny&&"ybins"in e||(e.ybins=a.autoBin(m,g,e.nbinsy,"2d"),"histogram2dcontour"===e.type&&(e.ybins.start-=e.ybins.size,e.ybins.end+=e.ybins.size),e._input.ybins=e.ybins),f=[];var y,x,b=[],_=[],w="string"==typeof e.xbins.size?[]:e.xbins,k="string"==typeof e.xbins.size?[]:e.ybins,M=0,A=[],T=e.histnorm,L=e.histfunc,z=-1!==T.indexOf("density"),S="max"===L||"min"===L,C=S?null:0,E=o.count,O=i[T],P=!1,N=[],D=[],I="z"in e?e.z:"marker"in e&&Array.isArray(e.marker.color)?e.marker.color:"";I&&"count"!==L&&(P="avg"===L,E=o[L]);var R=e.xbins,j=R.end+(R.start-a.tickIncrement(R.start,R.size))/1e6;for(d=R.start;j>d;d=a.tickIncrement(d,R.size))b.push(C),Array.isArray(w)&&w.push(d),P&&_.push(0);Array.isArray(w)&&w.push(d);var F=b.length;for(n=e.xbins.start,s=(d-n)/F,n+=s/2,R=e.ybins,j=R.end+(R.start-a.tickIncrement(R.start,R.size))/1e6,d=R.start;j>d;d=a.tickIncrement(d,R.size))f.push(b.concat()),Array.isArray(k)&&k.push(d),P&&A.push(_.concat());Array.isArray(k)&&k.push(d);var q=f.length;for(c=e.ybins.start,u=(d-c)/q,c+=u/2,z&&(N=b.map(function(t,e){return Array.isArray(w)?1/(w[e+1]-w[e]):1/s}),D=f.map(function(t,e){return Array.isArray(k)?1/(k[e+1]-k[e]):1/u})),d=0;v>d;d++)y=r.findBin(p[d],w),x=r.findBin(m[d],k),y>=0&&F>y&&x>=0&&q>x&&(M+=E(y,d,f[x],I,A[x]));if(P)for(x=0;q>x;x++)M+=l(f[x],A[x]);if(O)for(x=0;q>x;x++)O(f[x],M,N,D[x]);return{x:p,x0:n,dx:s,y:m,y0:c,dy:u,z:f}}},{"../../lib":102,"../../plots/cartesian/axes":123,"../histogram/average":209,"../histogram/bin_functions":211,"../histogram/norm_functions":215}],218:[function(t,e,n){"use strict";var r=t("../../lib"),a=t("./sample_defaults"),o=t("../../components/colorscale/defaults"),i=t("./attributes");e.exports=function(t,e,n){function l(n,a){return r.coerce(t,e,i,n,a)}a(t,e,l),l("zsmooth"),o(t,e,n,l,{prefix:"",cLetter:"z"})}},{"../../components/colorscale/defaults":35,"../../lib":102,"./attributes":216,"./sample_defaults":220}],219:[function(t,e,n){"use strict";var r={};r.attributes=t("./attributes"),r.supplyDefaults=t("./defaults"),r.calc=t("../heatmap/calc"),r.plot=t("../heatmap/plot"),r.colorbar=t("../heatmap/colorbar"),r.style=t("../heatmap/style"),r.hoverPoints=t("../heatmap/hover"),r.moduleType="trace",r.name="histogram2d",r.basePlotModule=t("../../plots/cartesian"),r.categories=["cartesian","2dMap","histogram"],r.meta={},e.exports=r},{"../../plots/cartesian":131,"../heatmap/calc":197,"../heatmap/colorbar":198,"../heatmap/hover":202,"../heatmap/plot":205,"../heatmap/style":206,"./attributes":216,"./defaults":218}],220:[function(t,e,n){"use strict";var r=t("../histogram/bin_defaults");e.exports=function(t,e,n){var a=n("x"),o=n("y");if(!(a&&a.length&&o&&o.length))return void(e.visible=!1);var i=n("z")||n("marker.color");i&&n("histfunc");var l=["x","y"];r(t,e,n,l)}},{"../histogram/bin_defaults":210}],221:[function(t,e,n){"use strict";var r=t("../histogram2d/attributes"),a=t("../contour/attributes"),o=t("../../components/colorscale/attributes"),i=t("../../lib/extend").extendFlat;e.exports=i({},{x:r.x,y:r.y,z:r.z,marker:r.marker,histnorm:r.histnorm,histfunc:r.histfunc,autobinx:r.autobinx,nbinsx:r.nbinsx,xbins:r.xbins,autobiny:r.autobiny,nbinsy:r.nbinsy,ybins:r.ybins,autocontour:a.autocontour,ncontours:a.ncontours,contours:a.contours,line:a.line,_nestedModules:{colorbar:"Colorbar"}},o)},{"../../components/colorscale/attributes":31,"../../lib/extend":100,"../contour/attributes":186,"../histogram2d/attributes":216}],222:[function(t,e,n){"use strict";var r=t("../../lib"),a=t("../histogram2d/sample_defaults"),o=t("../contour/style_defaults"),i=t("./attributes");e.exports=function(t,e,n,l){function s(n,a){return r.coerce(t,e,i,n,a)}a(t,e,s);var c=r.coerce2(t,e,i,"contours.start"),u=r.coerce2(t,e,i,"contours.end"),f=s("autocontour",!(c&&u));s(f?"ncontours":"contours.size"),o(t,e,s,l)}},{"../../lib":102,"../contour/style_defaults":195,"../histogram2d/sample_defaults":220,"./attributes":221}],223:[function(t,e,n){"use strict";var r={};r.attributes=t("./attributes"),r.supplyDefaults=t("./defaults"),r.calc=t("../contour/calc"),r.plot=t("../contour/plot"),r.style=t("../contour/style"),r.colorbar=t("../contour/colorbar"),r.hoverPoints=t("../contour/hover"),r.moduleType="trace",r.name="histogram2dcontour",r.basePlotModule=t("../../plots/cartesian"),r.categories=["cartesian","2dMap","contour","histogram"],r.meta={},e.exports=r},{"../../plots/cartesian":131,"../contour/calc":187,"../contour/colorbar":188,"../contour/hover":190,"../contour/plot":193,"../contour/style":194,"./attributes":221,"./defaults":222}],224:[function(t,e,n){"use strict";var r=t("../../components/color/attributes"),a=t("../../plots/font_attributes"),o=t("../../plots/attributes"),i=t("../../lib/extend").extendFlat;e.exports={labels:{valType:"data_array"},label0:{valType:"number",dflt:0},dlabel:{valType:"number",dflt:1},values:{valType:"data_array"},marker:{colors:{valType:"data_array"},line:{color:{valType:"color",dflt:r.defaultLine,arrayOk:!0},width:{valType:"number",min:0,dflt:0,arrayOk:!0}}},text:{valType:"data_array"},scalegroup:{valType:"string",dflt:""},textinfo:{valType:"flaglist",flags:["label","text","value","percent"],extras:["none"]},hoverinfo:i({},o.hoverinfo,{flags:["label","text","value","percent","name"]}),textposition:{valType:"enumerated",values:["inside","outside","auto","none"],dflt:"auto",arrayOk:!0},textfont:i({},a,{}),insidetextfont:i({},a,{}),outsidetextfont:i({},a,{}),domain:{x:{valType:"info_array",items:[{valType:"number",min:0,max:1},{valType:"number",min:0,max:1}],dflt:[0,1]},y:{valType:"info_array",items:[{valType:"number",min:0,max:1},{valType:"number",min:0,max:1}],dflt:[0,1]}},hole:{valType:"number",min:0,max:1,dflt:0},sort:{valType:"boolean",dflt:!0},direction:{valType:"enumerated",values:["clockwise","counterclockwise"],dflt:"counterclockwise"},rotation:{valType:"number",min:-360,max:360,dflt:0},pull:{valType:"number",min:0,max:1,dflt:0,arrayOk:!0}}},{"../../components/color/attributes":24,"../../lib/extend":100,"../../plots/attributes":121,"../../plots/font_attributes":141}],225:[function(t,e,n){"use strict";function r(t,e){for(var n=[],r=0;rs||(c=p[n],void 0!==c&&""!==c||(c=n),c=String(c),void 0===y[c]&&(y[c]=!0,u=o(e.marker.colors[n]),u.isValid()?(u=i.addOpacity(u,u.getAlpha()),v[c]||(v[c]=u)):v[c]?u=v[c]:(u=!1,x=!0),f=-1!==_.indexOf(c),f||(b+=s),g.push({v:s,label:c,color:u,i:n,hidden:f}))));if(e.sort&&g.sort(function(t,e){return e.v-t.v}),x)for(n=0;n")}return g};var s},{"../../components/color":25,"./helpers":228,"fast-isnumeric":18,tinycolor2:20}],227:[function(t,e,n){"use strict";var r=t("../../lib"),a=t("./attributes");e.exports=function(t,e,n,o){function i(n,o){return r.coerce(t,e,a,n,o)}var l=r.coerceFont,s=i("values");if(!Array.isArray(s)||!s.length)return void(e.visible=!1);var c=i("labels");Array.isArray(c)||(i("label0"),i("dlabel"));var u=i("marker.line.width");u&&i("marker.line.color");var f=i("marker.colors");Array.isArray(f)||(e.marker.colors=[]),i("scalegroup");var d=i("text"),h=i("textinfo",Array.isArray(d)?"text+percent":"percent");if(i("hoverinfo",1===o._dataLength?"label+text+value+percent":void 0),h&&"none"!==h){var p=i("textposition"),g=Array.isArray(p)||"auto"===p,m=g||"inside"===p,v=g||"outside"===p;if(m||v){var y=l(i,"textfont",o.font);m&&l(i,"insidetextfont",y),v&&l(i,"outsidetextfont",y)}}i("domain.x"),i("domain.y"),i("hole"),i("sort"),i("direction"),i("rotation"),i("pull")}},{"../../lib":102,"./attributes":224}],228:[function(t,e,n){"use strict";var r=t("../../lib");n.formatPiePercent=function(t,e){var n=(100*t).toPrecision(3);return-1!==n.lastIndexOf(".")&&(n=n.replace(/[.]?0+$/,"")),r.numSeparate(n,e)+"%"},n.formatPieValue=function(t,e){var n=t.toPrecision(10);return-1!==n.lastIndexOf(".")&&(n=n.replace(/[.]?0+$/,"")),r.numSeparate(n,e)}},{"../../lib":102}],229:[function(t,e,n){"use strict";var r={};r.attributes=t("./attributes"),r.supplyDefaults=t("./defaults"),r.supplyLayoutDefaults=t("./layout_defaults"),r.layoutAttributes=t("./layout_attributes"),r.calc=t("./calc"),r.plot=t("./plot"),r.style=t("./style"),r.styleOne=t("./style_one"),r.moduleType="trace",r.name="pie",r.basePlotModule=t("./base_plot"),r.categories=["pie","showLegend"],r.meta={},e.exports=r},{"./attributes":224,"./base_plot":225,"./calc":226,"./defaults":227,"./layout_attributes":230,"./layout_defaults":231,"./plot":232,"./style":233,"./style_one":234}],230:[function(t,e,n){"use strict";e.exports={hiddenlabels:{valType:"data_array"}}},{}],231:[function(t,e,n){"use strict";var r=t("../../lib"),a=t("./layout_attributes");e.exports=function(t,e){function n(n,o){return r.coerce(t,e,a,n,o)}n("hiddenlabels")}},{"../../lib":102,"./layout_attributes":230}],232:[function(t,e,n){"use strict";function r(t,e,n){var r=Math.sqrt(t.width*t.width+t.height*t.height),o=t.width/t.height,i=Math.PI*Math.min(e.v/n.vTotal,.5),l=1-n.trace.hole,s=a(e,n),c={scale:s*n.r*2/r,rCenter:1-s,rotate:0};if(c.scale>=1)return c;var u=o+1/(2*Math.tan(i)),f=n.r*Math.min(1/(Math.sqrt(u*u+.5)+u),l/(Math.sqrt(o*o+l/2)+o)),d={scale:2*f/t.height,rCenter:Math.cos(f/n.r)-f*o/n.r,rotate:(180/Math.PI*e.midangle+720)%180-90},h=1/o,p=h+1/(2*Math.tan(i)),g=n.r*Math.min(1/(Math.sqrt(p*p+.5)+p),l/(Math.sqrt(h*h+l/2)+h)),m={scale:2*g/t.width,rCenter:Math.cos(g/n.r)-g/o/n.r,rotate:(180/Math.PI*e.midangle+810)%180-90},v=m.scale>d.scale?m:d;return c.scale<1&&v.scale>c.scale?v:c}function a(t,e){if(t.v===e.vTotal&&!e.trace.hole)return 1;var n=Math.PI*Math.min(t.v/e.vTotal,.5);return Math.min(1/(1+1/Math.sin(n)),(1-e.trace.hole)/2)}function o(t,e){var n=e.pxmid[0],r=e.pxmid[1],a=t.width/2,o=t.height/2;return 0>n&&(a*=-1),0>r&&(o*=-1),{scale:1,rCenter:1,rotate:0,x:a+Math.abs(o)*(a>0?1:-1)/2,y:o/(1+n*n/(r*r)),outside:!0}}function i(t,e){function n(t,e){return t.pxmid[1]-e.pxmid[1]}function r(t,e){return e.pxmid[1]-t.pxmid[1]}function a(t,n){n||(n={});var r,a,o,l,d,h,g=n.labelExtraY+(i?n.yLabelMax:n.yLabelMin),m=i?t.yLabelMin:t.yLabelMax,v=i?t.yLabelMax:t.yLabelMin,y=t.cyFinal+c(t.px0[1],t.px1[1]),x=g-m;if(x*f>0&&(t.labelExtraY=x),Array.isArray(e.pull))for(a=0;a=e.pull[o.i]||((t.pxmid[1]-o.pxmid[1])*f>0?(l=o.cyFinal+c(o.px0[1],o.px1[1]),x=l-m-t.labelExtraY,x*f>0&&(t.labelExtraY+=x)):(v+t.labelExtraY-y)*f>0&&(r=3*u*Math.abs(a-p.indexOf(t)),d=o.cxFinal+s(o.px0[0],o.px1[0]),h=d+r-(t.cxFinal+t.pxmid[0])-t.labelExtraX,h*u>0&&(t.labelExtraX+=h)))}var o,i,l,s,c,u,f,d,h,p,g,m,v;for(i=0;2>i;i++)for(l=i?n:r,c=i?Math.max:Math.min,f=i?1:-1,o=0;2>o;o++){for(s=o?Math.max:Math.min,u=o?1:-1,d=t[i][o],d.sort(l),h=t[1-i][o],p=h.concat(d),m=[],g=0;gu&&(u=l.pull[o]);i.r=Math.min(n/c(l.tilt,Math.sin(s),l.depth),r/c(l.tilt,Math.cos(s),l.depth))/(2+2*u),i.cx=e.l+e.w*(l.domain.x[1]+l.domain.x[0])/2,i.cy=e.t+e.h*(2-l.domain.y[1]-l.domain.y[0])/2,l.scalegroup&&-1===h.indexOf(l.scalegroup)&&h.push(l.scalegroup)}for(o=0;of.vTotal/2?1:0)}function c(t,e,n){if(!t)return 1;var r=Math.sin(t*Math.PI/180);return Math.max(.01,n*r*Math.abs(e)+2*Math.sqrt(1-r*r*e*e))}var u=t("d3"),f=t("../../plots/cartesian/graph_interact"),d=t("../../components/color"),h=t("../../components/drawing"),p=t("../../lib/svg_text_utils"),g=t("./helpers");e.exports=function(t,e){var n=t._fullLayout;l(e,n._size);var c=n._pielayer.selectAll("g.trace").data(e);c.enter().append("g").attr({"stroke-linejoin":"round","class":"trace"}),c.exit().remove(),c.order(),c.each(function(e){var l=u.select(this),c=e[0],m=c.trace,v=0,y=(m.depth||0)*c.r*Math.sin(v)/2,x=m.tiltaxis||0,b=x*Math.PI/180,_=[y*Math.sin(b),y*Math.cos(b)],w=c.r*Math.cos(v),k=l.selectAll("g.part").data(m.tilt?["top","sides"]:["top"]);k.enter().append("g").attr("class",function(t){return t+" part"}),k.exit().remove(),k.order(),s(e),l.selectAll(".top").each(function(){var l=u.select(this).selectAll("g.slice").data(e);l.enter().append("g").classed("slice",!0),l.exit().remove();var s=[[[],[]],[[],[]]],v=!1;l.each(function(i){function l(e){var r=t._fullLayout,o=t._fullData[m.index],l=o.hoverinfo;if("all"===l&&(l="label+text+value+percent+name"),!t._dragging&&r.hovermode!==!1&&"none"!==l&&l){var s=a(i,c),u=k+i.pxmid[0]*(1-s),d=M+i.pxmid[1]*(1-s),h=n.separators,p=[];-1!==l.indexOf("label")&&p.push(i.label),o.text&&o.text[i.i]&&-1!==l.indexOf("text")&&p.push(o.text[i.i]),-1!==l.indexOf("value")&&p.push(g.formatPieValue(i.v,h)),-1!==l.indexOf("percent")&&p.push(g.formatPiePercent(i.v/c.vTotal,h)),f.loneHover({x0:u-s*c.r,x1:u+s*c.r,y:d,text:p.join("
"),name:-1!==l.indexOf("name")?o.name:void 0,color:i.color,idealAlign:i.pxmid[0]<0?"left":"right"},{container:r._hoverlayer.node(),outerContainer:r._paper.node()}),f.hover(t,e,"pie"),L=!0}}function d(e){t.emit("plotly_unhover",{points:[e]}),L&&(f.loneUnhover(n._hoverlayer.node()),L=!1)}function y(){t._hoverdata=[i],t._hoverdata.trace=e.trace,f.click(t,{target:!0})}function b(t,e,n,r){return"a"+r*c.r+","+r*w+" "+x+" "+i.largeArc+(n?" 1 ":" 0 ")+r*(e[0]-t[0])+","+r*(e[1]-t[1])}if(i.hidden)return void u.select(this).selectAll("path,g").remove();s[i.pxmid[1]<0?0:1][i.pxmid[0]<0?0:1].push(i);var k=c.cx+_[0],M=c.cy+_[1],A=u.select(this),T=A.selectAll("path.surface").data([i]),L=!1;if(T.enter().append("path").classed("surface",!0).style({"pointer-events":"all"}),A.select("path.textline").remove(),A.on("mouseover",l).on("mouseout",d).on("click",y),m.pull){var z=+(Array.isArray(m.pull)?m.pull[i.i]:m.pull)||0;z>0&&(k+=z*i.pxmid[0],M+=z*i.pxmid[1])}i.cxFinal=k,i.cyFinal=M;var S=m.hole;if(i.v===c.vTotal){var C="M"+(k+i.px0[0])+","+(M+i.px0[1])+b(i.px0,i.pxmid,!0,1)+b(i.pxmid,i.px0,!0,1)+"Z";S?T.attr("d","M"+(k+S*i.px0[0])+","+(M+S*i.px0[1])+b(i.px0,i.pxmid,!1,S)+b(i.pxmid,i.px0,!1,S)+"Z"+C):T.attr("d",C)}else{var E=b(i.px0,i.px1,!0,1);if(S){var O=1-S;T.attr("d","M"+(k+S*i.px1[0])+","+(M+S*i.px1[1])+b(i.px1,i.px0,!1,S)+"l"+O*i.px0[0]+","+O*i.px0[1]+E+"Z")}else T.attr("d","M"+k+","+M+"l"+i.px0[0]+","+i.px0[1]+E+"Z")}var P=Array.isArray(m.textposition)?m.textposition[i.i]:m.textposition,N=A.selectAll("g.slicetext").data(i.text&&"none"!==P?[0]:[]);N.enter().append("g").classed("slicetext",!0),N.exit().remove(),N.each(function(){var t=u.select(this).selectAll("text").data([0]);t.enter().append("text").attr("data-notex",1),t.exit().remove(),t.text(i.text).attr({"class":"slicetext",transform:"","data-bb":"","text-anchor":"middle",x:0,y:0}).call(h.font,"outside"===P?m.outsidetextfont:m.insidetextfont).call(p.convertToTspans),t.selectAll("tspan.line").attr({x:0,y:0});var e,n=h.bBox(t.node());"outside"===P?e=o(n,i):(e=r(n,i,c),"auto"===P&&e.scale<1&&(t.call(h.font,m.outsidetextfont),m.outsidetextfont.family===m.insidetextfont.family&&m.outsidetextfont.size===m.insidetextfont.size||(t.attr({"data-bb":""}),n=h.bBox(t.node())),e=o(n,i)));var a=k+i.pxmid[0]*e.rCenter+(e.x||0),l=M+i.pxmid[1]*e.rCenter+(e.y||0);e.outside&&(i.yLabelMin=l-n.height/2,i.yLabelMid=l,i.yLabelMax=l+n.height/2,i.labelExtraX=0,i.labelExtraY=0,v=!0),t.attr("transform","translate("+a+","+l+")"+(e.scale<1?"scale("+e.scale+")":"")+(e.rotate?"rotate("+e.rotate+")":"")+"translate("+-(n.left+n.right)/2+","+-(n.top+n.bottom)/2+")")})}),v&&i(s,m),l.each(function(t){if(t.labelExtraX||t.labelExtraY){var e=u.select(this),n=e.select("g.slicetext text");n.attr("transform","translate("+t.labelExtraX+","+t.labelExtraY+")"+n.attr("transform"));var r=t.cxFinal+t.pxmid[0],a=t.cyFinal+t.pxmid[1],o="M"+r+","+a,i=(t.yLabelMax-t.yLabelMin)*(t.pxmid[0]<0?-1:1)/4;if(t.labelExtraX){var l=t.labelExtraX*t.pxmid[1]/t.pxmid[0],s=t.yLabelMid+t.labelExtraY-(t.cyFinal+t.pxmid[1]);o+=Math.abs(l)>Math.abs(s)?"l"+s*t.pxmid[0]/t.pxmid[1]+","+s+"H"+(r+t.labelExtraX+i):"l"+t.labelExtraX+","+l+"v"+(s-l)+"h"+i}else o+="V"+(t.yLabelMid+t.labelExtraY)+"h"+i;e.append("path").classed("textline",!0).call(d.stroke,m.outsidetextfont.color).attr({"stroke-width":Math.min(2,m.outsidetextfont.size/8),d:o,fill:"none"})}})})}),setTimeout(function(){c.selectAll("tspan").each(function(){var t=u.select(this);t.attr("dy")&&t.attr("dy",t.attr("dy"))})},0)}},{"../../components/color":25,"../../components/drawing":48,"../../lib/svg_text_utils":113,"../../plots/cartesian/graph_interact":130,"./helpers":228,d3:16}],233:[function(t,e,n){"use strict";var r=t("d3"),a=t("./style_one");e.exports=function(t){t._fullLayout._pielayer.selectAll(".trace").each(function(t){var e=t[0],n=e.trace,o=r.select(this);o.style({opacity:n.opacity}),o.selectAll(".top path.surface").each(function(t){r.select(this).call(a,t,n)})})}},{"./style_one":234,d3:16}],234:[function(t,e,n){"use strict";var r=t("../../components/color");e.exports=function(t,e,n){var a=n.marker.line.color;Array.isArray(a)&&(a=a[e.i]||r.defaultLine);var o=n.marker.line.width||0;Array.isArray(o)&&(o=o[e.i]||0),t.style({"stroke-width":o,fill:e.color}).call(r.stroke,a)}},{"../../components/color":25}],235:[function(t,e,n){"use strict";var r=t("../../lib");e.exports=function(t){var e=t[0].trace,n=e.marker;if(r.mergeArray(e.text,t,"tx"),r.mergeArray(e.textposition,t,"tp"),e.textfont&&(r.mergeArray(e.textfont.size,t,"ts"),r.mergeArray(e.textfont.color,t,"tc"),r.mergeArray(e.textfont.family,t,"tf")),n&&n.line){var a=n.line;r.mergeArray(n.opacity,t,"mo"),r.mergeArray(n.symbol,t,"mx"),r.mergeArray(n.color,t,"mc"),r.mergeArray(a.color,t,"mlc"),r.mergeArray(a.width,t,"mlw")}}},{"../../lib":102}],236:[function(t,e,n){"use strict";var r=t("../../components/colorscale/color_attributes"),a=t("../../components/drawing"),o=(t("./constants"),t("../../lib/extend").extendFlat);e.exports={x:{valType:"data_array"},x0:{valType:"any",dflt:0},dx:{valType:"number",dflt:1},y:{valType:"data_array"},y0:{valType:"any",dflt:0},dy:{valType:"number",dflt:1},text:{valType:"string",dflt:"",arrayOk:!0},mode:{valType:"flaglist",flags:["lines","markers","text"],extras:["none"]},hoveron:{valType:"flaglist",flags:["points","fills"]},line:{color:{valType:"color"},width:{valType:"number",min:0,dflt:2},shape:{valType:"enumerated",values:["linear","spline","hv","vh","hvh","vhv"],dflt:"linear"},smoothing:{valType:"number", +-min:0,max:1.3,dflt:1},dash:{valType:"string",values:["solid","dot","dash","longdash","dashdot","longdashdot"],dflt:"solid"}},connectgaps:{valType:"boolean",dflt:!1},fill:{valType:"enumerated",values:["none","tozeroy","tozerox","tonexty","tonextx","toself","tonext"],dflt:"none"},fillcolor:{valType:"color"},marker:o({},{symbol:{valType:"enumerated",values:a.symbolList,dflt:"circle",arrayOk:!0},opacity:{valType:"number",min:0,max:1,arrayOk:!0},size:{valType:"number",min:0,dflt:6,arrayOk:!0},maxdisplayed:{valType:"number",min:0,dflt:0},sizeref:{valType:"number",dflt:1},sizemin:{valType:"number",min:0,dflt:0},sizemode:{valType:"enumerated",values:["diameter","area"],dflt:"diameter"},showscale:{valType:"boolean",dflt:!1},line:o({},{width:{valType:"number",min:0,arrayOk:!0}},r("marker.line"))},r("marker")),textposition:{valType:"enumerated",values:["top left","top center","top right","middle left","middle center","middle right","bottom left","bottom center","bottom right"],dflt:"middle center",arrayOk:!0},textfont:{family:{valType:"string",noBlank:!0,strict:!0,arrayOk:!0},size:{valType:"number",min:1,arrayOk:!0},color:{valType:"color",arrayOk:!0}},r:{valType:"data_array"},t:{valType:"data_array"},_nestedModules:{error_y:"ErrorBars",error_x:"ErrorBars","marker.colorbar":"Colorbar"}}},{"../../components/colorscale/color_attributes":33,"../../components/drawing":48,"../../lib/extend":100,"./constants":241}],237:[function(t,e,n){"use strict";var r=t("fast-isnumeric"),a=t("../../plots/cartesian/axes"),o=t("../../lib"),i=t("./subtypes"),l=t("./colorscale_calc");e.exports=function(t,e){var n,s,c,u=a.getFromId(t,e.xaxis||"x"),f=a.getFromId(t,e.yaxis||"y"),d=u.makeCalcdata(e,"x"),h=f.makeCalcdata(e,"y"),p=Math.min(d.length,h.length);u._minDtick=0,f._minDtick=0,d.length>p&&d.splice(p,d.length-p),h.length>p&&h.splice(p,h.length-p);var g={padded:!0},m={padded:!0};if(i.hasMarkers(e)){if(n=e.marker,s=n.size,Array.isArray(s)){var v={type:"linear"};a.setConvert(v),s=v.makeCalcdata(e.marker,"size"),s.length>p&&s.splice(p,s.length-p)}var y,x=1.6*(e.marker.sizeref||1);y="area"===e.marker.sizemode?function(t){return Math.max(Math.sqrt((t||0)/x),3)}:function(t){return Math.max((t||0)/x,3)},g.ppad=m.ppad=Array.isArray(s)?s.map(y):y(s)}l(e),!("tozerox"===e.fill||"tonextx"===e.fill&&t.firstscatter)||d[0]===d[p-1]&&h[0]===h[p-1]?e.error_y.visible||-1===["tonexty","tozeroy"].indexOf(e.fill)&&(i.hasMarkers(e)||i.hasText(e))||(g.padded=!1,g.ppad=0):g.tozero=!0,!("tozeroy"===e.fill||"tonexty"===e.fill&&t.firstscatter)||d[0]===d[p-1]&&h[0]===h[p-1]?-1!==["tonextx","tozerox"].indexOf(e.fill)&&(m.padded=!1):m.tozero=!0,a.expand(u,d,g),a.expand(f,h,m);var b=new Array(p);for(c=0;p>c;c++)b[c]=r(d[c])&&r(h[c])?{x:d[c],y:h[c]}:{x:!1,y:!1};return void 0!==typeof s&&o.mergeArray(s,b,"ms"),t.firstscatter=!1,b}},{"../../lib":102,"../../plots/cartesian/axes":123,"./colorscale_calc":240,"./subtypes":255,"fast-isnumeric":18}],238:[function(t,e,n){"use strict";e.exports=function(t){var e,n,r,a,o;for(e=0;e=0;a--)if(o=t[a],"scatter"===o.type&&o.xaxis===n.xaxis&&o.yaxis===n.yaxis){o.opacity=void 0;break}}},{}],239:[function(t,e,n){"use strict";var r=t("d3"),a=t("fast-isnumeric"),o=t("../../lib"),i=t("../../plots/plots"),l=t("../../components/colorscale/get_scale"),s=t("../../components/colorbar/draw");e.exports=function(t,e){var n=e[0].trace,c=n.marker,u="cb"+n.uid;if(t._fullLayout._infolayer.selectAll("."+u).remove(),void 0===c||!c.showscale)return void i.autoMargin(t,u);var f=l(c.colorscale),d=c.color,h=c.cmin,p=c.cmax;a(h)||(h=o.aggNums(Math.min,null,d)),a(p)||(p=o.aggNums(Math.max,null,d));var g=e[0].t.cb=s(t,u);g.fillcolor(r.scale.linear().domain(f.map(function(t){return h+t[0]*(p-h)})).range(f.map(function(t){return t[1]}))).filllevels({start:h,end:p,size:(p-h)/254}).options(c.colorbar)()}},{"../../components/colorbar/draw":28,"../../components/colorscale/get_scale":37,"../../lib":102,"../../plots/plots":143,d3:16,"fast-isnumeric":18}],240:[function(t,e,n){"use strict";var r=t("../../components/colorscale/has_colorscale"),a=t("../../components/colorscale/calc"),o=t("./subtypes");e.exports=function(t){o.hasLines(t)&&r(t,"line")&&a(t,t.line.color,"line","c"),o.hasMarkers(t)&&(r(t,"marker")&&a(t,t.marker.color,"marker","c"),r(t,"marker.line")&&a(t,t.marker.line.color,"marker.line","c"))}},{"../../components/colorscale/calc":32,"../../components/colorscale/has_colorscale":38,"./subtypes":255}],241:[function(t,e,n){"use strict";e.exports={PTS_LINESONLY:20}},{}],242:[function(t,e,n){"use strict";var r=t("../../lib"),a=t("./attributes"),o=t("./constants"),i=t("./subtypes"),l=t("./xy_defaults"),s=t("./marker_defaults"),c=t("./line_defaults"),u=t("./line_shape_defaults"),f=t("./text_defaults"),d=t("./fillcolor_defaults"),h=t("../../components/errorbars/defaults");e.exports=function(t,e,n,p){function g(n,o){return r.coerce(t,e,a,n,o)}var m=l(t,e,g),v=mB!=P>=B&&(C=z[T-1][0],E=z[T][0],S=C+(E-C)*(B-O)/(P-O),R=Math.min(R,S),j=Math.max(j,S));R=Math.max(R,0),j=Math.min(j,d._length);var H=s.defaultLine;return s.opacity(f.fillcolor)?H=f.fillcolor:s.opacity((f.line||{}).color)&&(H=f.line.color),r.extendFlat(t,{distance:o.MAXDIST+10,x0:R,x1:j,y0:B,y1:B,color:H}),delete t.index,f.text&&!Array.isArray(f.text)?t.text=String(f.text):t.text=f.name,[t]}}}},{"../../components/color":25,"../../components/errorbars":54,"../../lib":102,"../../plots/cartesian/constants":128,"../../plots/cartesian/graph_interact":130,"./get_trace_color":244}],246:[function(t,e,n){"use strict";var r={},a=t("./subtypes");r.hasLines=a.hasLines,r.hasMarkers=a.hasMarkers,r.hasText=a.hasText,r.isBubble=a.isBubble,r.attributes=t("./attributes"),r.supplyDefaults=t("./defaults"),r.cleanData=t("./clean_data"),r.calc=t("./calc"),r.arraysToCalcdata=t("./arrays_to_calcdata"),r.plot=t("./plot"),r.colorbar=t("./colorbar"),r.style=t("./style"),r.hoverPoints=t("./hover"),r.selectPoints=t("./select"),r.moduleType="trace",r.name="scatter",r.basePlotModule=t("../../plots/cartesian"),r.categories=["cartesian","symbols","markerColorscale","errorBarsOK","showLegend"],r.meta={},e.exports=r},{"../../plots/cartesian":131,"./arrays_to_calcdata":235,"./attributes":236,"./calc":237,"./clean_data":238,"./colorbar":239,"./defaults":242,"./hover":245,"./plot":252,"./select":253,"./style":254,"./subtypes":255}],247:[function(t,e,n){"use strict";var r=t("../../components/colorscale/has_colorscale"),a=t("../../components/colorscale/defaults");e.exports=function(t,e,n,o,i){var l=(t.marker||{}).color;if(i("line.color",n),r(t,"line"))a(t,e,o,i,{prefix:"line.",cLetter:"c"});else{var s=(Array.isArray(l)?!1:l)||n;i("line.color",s)}i("line.width"),i("line.dash")}},{"../../components/colorscale/defaults":35,"../../components/colorscale/has_colorscale":38}],248:[function(t,e,n){"use strict";var r=t("../../plots/cartesian/axes");e.exports=function(t,e){function n(e){var n=w.c2p(t[e].x),r=k.c2p(t[e].y);return n===z||r===z?!1:[n,r]}function a(t){var e=t[0]/w._length,n=t[1]/k._length;return(1+10*Math.max(0,-e,e-1,-n,n-1))*A}function o(t,e){var n=t[0]-e[0],r=t[1]-e[1];return Math.sqrt(n*n+r*r)}var i,l,s,c,u,f,d,h,p,g,m,v,y,x,b,_,w=e.xaxis,k=e.yaxis,M=e.connectGaps,A=e.baseTolerance,T=e.linear,L=[],z=r.BADNUM,S=.2,C=new Array(t.length),E=0;for(i=0;ia(f))break;s=f,y=g[0]*p[0]+g[1]*p[1],y>m?(m=y,c=f,h=!1):v>y&&(v=y,u=f,h=!0)}if(h?(C[E++]=c,s!==u&&(C[E++]=u)):(u!==l&&(C[E++]=u),s!==c&&(C[E++]=c)),C[E++]=s,i>=t.length||!f)break;C[E++]=f,l=f}}else C[E++]=c}L.push(C.slice(0,E))}return L}},{"../../plots/cartesian/axes":123}],249:[function(t,e,n){"use strict";e.exports=function(t,e,n){var r=n("line.shape");"spline"===r&&n("line.smoothing")}},{}],250:[function(t,e,n){"use strict";var r=t("fast-isnumeric");e.exports=function(t){var e=t.marker,n=e.sizeref||1,a=e.sizemin||0,o="area"===e.sizemode?function(t){return Math.sqrt(t/n)}:function(t){return t/n};return function(t){var e=o(t/2);return r(e)&&e>0?Math.max(e,a):0}}},{"fast-isnumeric":18}],251:[function(t,e,n){"use strict";var r=t("../../components/color"),a=t("../../components/colorscale/has_colorscale"),o=t("../../components/colorscale/defaults"),i=t("./subtypes");e.exports=function(t,e,n,l,s){var c,u=i.isBubble(t),f=(t.line||{}).color;f&&(n=f),s("marker.symbol"),s("marker.opacity",u?.7:1),s("marker.size"),s("marker.color",n),a(t,"marker")&&o(t,e,l,s,{prefix:"marker.",cLetter:"c"}),c=f&&!Array.isArray(f)&&e.marker.color!==f?f:u?r.background:r.defaultLine,s("marker.line.color",c),a(t,"marker.line")&&o(t,e,l,s,{prefix:"marker.line.",cLetter:"c"}),s("marker.line.width",u?1:0),u&&(s("marker.sizeref"),s("marker.sizemin"),s("marker.sizemode"))}},{"../../components/color":25,"../../components/colorscale/defaults":35,"../../components/colorscale/has_colorscale":38,"./subtypes":255}],252:[function(t,e,n){"use strict";function r(t,e,n){var r=e.x(),o=e.y(),i=a.extent(r.range.map(r.l2c)),l=a.extent(o.range.map(o.l2c));n.forEach(function(t,e){var r=t[0].trace;if(c.hasMarkers(r)){var a=r.marker.maxdisplayed;if(0!==a){var o=t.filter(function(t){return t.x>=i[0]&&t.x<=i[1]&&t.y>=l[0]&&t.y<=l[1]}),s=Math.ceil(o.length/a),u=0;n.forEach(function(t,n){var r=t[0].trace;c.hasMarkers(r)&&r.marker.maxdisplayed>0&&e>n&&u++});var f=Math.round(u*s/3+Math.floor(u/3)*s/7.1);t.forEach(function(t){delete t.vis}),o.forEach(function(t,e){0===Math.round((e+f)%s)&&(t.vis=!0)})}}})}var a=t("d3"),o=t("../../lib"),i=t("../../components/drawing"),l=t("../../components/errorbars"),s=t("../../lib/polygon").tester,c=t("./subtypes"),u=t("./arrays_to_calcdata"),f=t("./line_points");e.exports=function(t,e,n){function d(t){return t.filter(function(t){return t.vis})}r(t,e,n);var h=e.x(),p=e.y(),g=e.plot.select(".scatterlayer").selectAll("g.trace.scatter").data(n);g.enter().append("g").attr("class","trace scatter").style("stroke-miterlimit",2),g.call(l.plot,e);var m,v,y,x,b="",_=[];g.each(function(t){var e=t[0].trace,n=e.line,r=a.select(this);if(e.visible===!0&&(v=e.fill.charAt(e.fill.length-1),"x"!==v&&"y"!==v&&(v=""),t[0].node3=r,u(t),c.hasLines(e)||"none"!==e.fill)){var o,l,d,g,w,k="",M="";m="tozero"===e.fill.substr(0,6)||"toself"===e.fill||"to"===e.fill.substr(0,2)&&!b?r.append("path").classed("js-fill",!0):null,x&&(y=x.datum(t)),x=r.append("path").classed("js-fill",!0),-1!==["hv","vh","hvh","vhv"].indexOf(n.shape)?(d=i.steps(n.shape),g=i.steps(n.shape.split("").reverse().join(""))):d=g="spline"===n.shape?function(t){var e=t[t.length-1];return t[0][0]===e[0]&&t[0][1]===e[1]?i.smoothclosed(t.slice(1),n.smoothing):i.smoothopen(t,n.smoothing)}:function(t){return"M"+t.join("L")},w=function(t){return g(t.reverse())};var A,T=f(t,{xaxis:h,yaxis:p,connectGaps:e.connectgaps,baseTolerance:Math.max(n.width||1,3)/4,linear:"linear"===n.shape}),L=e._polygons=new Array(T.length);for(A=0;A1&&r.append("path").classed("js-line",!0).style("vector-effect","non-scaling-stroke").attr("d",o)}m?z&&C&&(v?("y"===v?z[1]=C[1]=p.c2p(0,!0):"x"===v&&(z[0]=C[0]=h.c2p(0,!0)),m.attr("d",k+"L"+C+"L"+z+"Z")):m.attr("d",k+"Z")):"tonext"===e.fill.substr(0,6)&&k&&b&&("tonext"===e.fill?y.attr("d",k+"Z"+b+"Z"):y.attr("d",k+"L"+b.substr(1)+"Z"),e._polygons=e._polygons.concat(_)),b=M,_=L}}}),g.selectAll("path:not([d])").remove(),g.append("g").attr("class","points").each(function(t){var e=t[0].trace,n=a.select(this),r=c.hasMarkers(e),l=c.hasText(e);!r&&!l||e.visible!==!0?n.remove():(r&&n.selectAll("path.point").data(e.marker.maxdisplayed?d:o.identity).enter().append("path").classed("point",!0).call(i.translatePoints,h,p),l&&n.selectAll("g").data(e.marker.maxdisplayed?d:o.identity).enter().append("g").append("text").call(i.translatePoints,h,p))})}},{"../../components/drawing":48,"../../components/errorbars":54,"../../lib":102,"../../lib/polygon":108,"./arrays_to_calcdata":235,"./line_points":248,"./subtypes":255,d3:16}],253:[function(t,e,n){"use strict";var r=t("./subtypes"),a=.2;e.exports=function(t,e){var n,o,i,l,s=t.cd,c=t.xaxis,u=t.yaxis,f=[],d=s[0].trace,h=d.index,p=d.marker,g=!r.hasMarkers(d)&&!r.hasText(d);if(d.visible===!0&&!g){var m=Array.isArray(p.opacity)?1:p.opacity;if(e===!1)for(n=0;nn;n++)y=e.a[n],x=e.b[n],b=e.c[n],r(y)&&r(x)&&r(b)?(y=+y,x=+x,b=+b,_=m/(y+x+b),1!==_&&(y*=_,x*=_,b*=_),k=y,w=b-x,A[n]={x:w,y:k,a:y,b:x,c:b}):A[n]={x:!1,y:!1};var T,L;if(i.hasMarkers(e)&&(T=e.marker,L=T.size,Array.isArray(L))){var z={type:"linear"};a.setConvert(z),L=z.makeCalcdata(e.marker,"size"),L.length>M&&L.splice(M,L.length-M)}return l(e),void 0!==typeof L&&o.mergeArray(L,A,"ms"),A}},{"../../lib":102,"../../plots/cartesian/axes":123,"../scatter/colorscale_calc":240,"../scatter/subtypes":255,"fast-isnumeric":18}],260:[function(t,e,n){"use strict";var r=t("../../lib"),a=t("../scatter/constants"),o=t("../scatter/subtypes"),i=t("../scatter/marker_defaults"),l=t("../scatter/line_defaults"),s=t("../scatter/line_shape_defaults"),c=t("../scatter/text_defaults"),u=t("../scatter/fillcolor_defaults"),f=t("./attributes");e.exports=function(t,e,n,d){function h(n,a){return r.coerce(t,e,f,n,a)}var p,g=h("a"),m=h("b"),v=h("c");if(g?(p=g.length,m?(p=Math.min(p,m.length),v&&(p=Math.min(p,v.length))):p=v?Math.min(p,v.length):0):m&&v&&(p=Math.min(m.length,v.length)),!p)return void(e.visible=!1);g&&p"),l}}},{"../../plots/cartesian/axes":123,"../scatter/hover":245}],262:[function(t,e,n){"use strict";var r={};r.attributes=t("./attributes"),r.supplyDefaults=t("./defaults"),r.colorbar=t("../scatter/colorbar"),r.calc=t("./calc"),r.plot=t("./plot"),r.style=t("./style"),r.hoverPoints=t("./hover"),r.selectPoints=t("./select"),r.moduleType="trace",r.name="scatterternary",r.basePlotModule=t("../../plots/ternary"),r.categories=["ternary","symbols","markerColorscale","showLegend"],r.meta={},e.exports=r},{"../../plots/ternary":150,"../scatter/colorbar":239,"./attributes":258,"./calc":259,"./defaults":260,"./hover":261,"./plot":263,"./select":264,"./style":265}],263:[function(t,e,n){"use strict";var r=t("../scatter/plot");e.exports=function(t,e){var n=t.plotContainer;n.select(".scatterlayer").selectAll("*").remove();for(var a={x:function(){return t.xaxis},y:function(){return t.yaxis},plot:n},o=new Array(e.length),i=t.graphDiv.calcdata,l=0;le?1:t>=e?0:NaN}function o(t){return null===t?NaN:+t}function i(t){return!isNaN(t)}function l(t){return{left:function(e,n,r,a){for(arguments.length<3&&(r=0),arguments.length<4&&(a=e.length);r>>1;t(e[o],n)<0?r=o+1:a=o}return r},right:function(e,n,r,a){for(arguments.length<3&&(r=0),arguments.length<4&&(a=e.length);r>>1;t(e[o],n)>0?a=o:r=o+1}return r}}}function s(t){return t.length}function c(t){for(var e=1;t*e%1;)e*=10;return e}function u(t,e){for(var n in e)Object.defineProperty(t.prototype,n,{value:e[n],enumerable:!1})}function f(){this._=Object.create(null)}function d(t){return(t+="")===_i||t[0]===wi?wi+t:t}function h(t){return(t+="")[0]===wi?t.slice(1):t}function p(t){return d(t)in this._}function g(t){return(t=d(t))in this._&&delete this._[t]}function m(){var t=[];for(var e in this._)t.push(h(e));return t}function v(){var t=0;for(var e in this._)++t;return t}function y(){for(var t in this._)return!1;return!0}function x(){this._=Object.create(null)}function b(t){return t}function _(t,e,n){return function(){var r=n.apply(e,arguments);return r===e?t:r}}function w(t,e){if(e in t)return e;e=e.charAt(0).toUpperCase()+e.slice(1);for(var n=0,r=ki.length;n=e&&(e=a+1);!(i=l[e])&&++e0&&(t=t.slice(0,l));var c=Pi.get(t);return c&&(t=c,s=Q),l?e?a:r:e?k:o}function $(t,e){return function(n){var r=ui.event;ui.event=n,e[0]=this.__data__;try{t.apply(this,e)}finally{ui.event=r}}}function Q(t,e){var n=$(t,e);return function(t){var e=this,r=t.relatedTarget;r&&(r===e||8&r.compareDocumentPosition(e))||n.call(e,t)}}function W(t){var n=".dragsuppress-"+ ++Di,a="click"+n,o=ui.select(r(t)).on("touchmove"+n,T).on("dragstart"+n,T).on("selectstart"+n,T);if(null==Ni&&(Ni=!("onselectstart"in t)&&w(t.style,"userSelect")),Ni){var i=e(t).style,l=i[Ni];i[Ni]="none"}return function(t){if(o.on(n,null),Ni&&(i[Ni]=l),t){var e=function(){o.on(a,null)};o.on(a,function(){T(),e()},!0),setTimeout(e,0)}}}function J(t,e){e.changedTouches&&(e=e.changedTouches[0]);var n=t.ownerSVGElement||t;if(n.createSVGPoint){var a=n.createSVGPoint();if(Ii<0){var o=r(t);if(o.scrollX||o.scrollY){n=ui.select("body").append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important");var i=n[0][0].getScreenCTM();Ii=!(i.f||i.e),n.remove()}}return Ii?(a.x=e.pageX,a.y=e.pageY):(a.x=e.clientX,a.y=e.clientY),a=a.matrixTransform(t.getScreenCTM().inverse()),[a.x,a.y]}var l=t.getBoundingClientRect();return[e.clientX-l.left-t.clientLeft,e.clientY-l.top-t.clientTop]}function K(){return ui.event.changedTouches[0].identifier}function tt(t){return t>0?1:t<0?-1:0}function et(t,e,n){return(e[0]-t[0])*(n[1]-t[1])-(e[1]-t[1])*(n[0]-t[0])}function nt(t){return t>1?0:t<-1?Fi:Math.acos(t)}function rt(t){return t>1?Hi:t<-1?-Hi:Math.asin(t)}function at(t){return((t=Math.exp(t))-1/t)/2}function ot(t){return((t=Math.exp(t))+1/t)/2}function it(t){return((t=Math.exp(2*t))-1)/(t+1)}function lt(t){return(t=Math.sin(t/2))*t}function st(){}function ct(t,e,n){return this instanceof ct?(this.h=+t,this.s=+e,void(this.l=+n)):arguments.length<2?t instanceof ct?new ct(t.h,t.s,t.l):kt(""+t,Mt,ct):new ct(t,e,n)}function ut(t,e,n){function r(t){return t>360?t-=360:t<0&&(t+=360),t<60?o+(i-o)*t/60:t<180?i:t<240?o+(i-o)*(240-t)/60:o}function a(t){return Math.round(255*r(t))}var o,i;return t=isNaN(t)?0:(t%=360)<0?t+360:t,e=isNaN(e)?0:e<0?0:e>1?1:e,n=n<0?0:n>1?1:n,i=n<=.5?n*(1+e):n+e-n*e,o=2*n-i,new xt(a(t+120),a(t),a(t-120))}function ft(t,e,n){return this instanceof ft?(this.h=+t,this.c=+e,void(this.l=+n)):arguments.length<2?t instanceof ft?new ft(t.h,t.c,t.l):t instanceof ht?gt(t.l,t.a,t.b):gt((t=At((t=ui.rgb(t)).r,t.g,t.b)).l,t.a,t.b):new ft(t,e,n)}function dt(t,e,n){return isNaN(t)&&(t=0),isNaN(e)&&(e=0),new ht(n,Math.cos(t*=Vi)*e,Math.sin(t)*e)}function ht(t,e,n){return this instanceof ht?(this.l=+t,this.a=+e,void(this.b=+n)):arguments.length<2?t instanceof ht?new ht(t.l,t.a,t.b):t instanceof ft?dt(t.h,t.c,t.l):At((t=xt(t)).r,t.g,t.b):new ht(t,e,n)}function pt(t,e,n){var r=(t+16)/116,a=r+e/500,o=r-n/200;return a=mt(a)*tl,r=mt(r)*el,o=mt(o)*nl,new xt(yt(3.2404542*a-1.5371385*r-.4985314*o),yt(-.969266*a+1.8760108*r+.041556*o),yt(.0556434*a-.2040259*r+1.0572252*o))}function gt(t,e,n){return t>0?new ft(Math.atan2(n,e)*Zi,Math.sqrt(e*e+n*n),t):new ft(NaN,NaN,t)}function mt(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function vt(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function yt(t){return Math.round(255*(t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}function xt(t,e,n){return this instanceof xt?(this.r=~~t,this.g=~~e,void(this.b=~~n)):arguments.length<2?t instanceof xt?new xt(t.r,t.g,t.b):kt(""+t,xt,ut):new xt(t,e,n)}function bt(t){return new xt(t>>16,t>>8&255,255&t)}function _t(t){return bt(t)+""}function wt(t){return t<16?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function kt(t,e,n){var r,a,o,i=0,l=0,s=0;if(r=/([a-z]+)\((.*)\)/.exec(t=t.toLowerCase()))switch(a=r[2].split(","),r[1]){case"hsl":return n(parseFloat(a[0]),parseFloat(a[1])/100,parseFloat(a[2])/100);case"rgb":return e(Lt(a[0]),Lt(a[1]),Lt(a[2]))}return(o=ol.get(t))?e(o.r,o.g,o.b):(null==t||"#"!==t.charAt(0)||isNaN(o=parseInt(t.slice(1),16))||(4===t.length?(i=(3840&o)>>4,i=i>>4|i,l=240&o,l=l>>4|l,s=15&o,s=s<<4|s):7===t.length&&(i=(16711680&o)>>16,l=(65280&o)>>8,s=255&o)),e(i,l,s))}function Mt(t,e,n){var r,a,o=Math.min(t/=255,e/=255,n/=255),i=Math.max(t,e,n),l=i-o,s=(i+o)/2;return l?(a=s<.5?l/(i+o):l/(2-i-o),r=t==i?(e-n)/l+(e0&&s<1?0:r),new ct(r,a,s)}function At(t,e,n){t=Tt(t),e=Tt(e),n=Tt(n);var r=vt((.4124564*t+.3575761*e+.1804375*n)/tl),a=vt((.2126729*t+.7151522*e+.072175*n)/el),o=vt((.0193339*t+.119192*e+.9503041*n)/nl);return ht(116*a-16,500*(r-a),200*(a-o))}function Tt(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Lt(t){var e=parseFloat(t);return"%"===t.charAt(t.length-1)?Math.round(2.55*e):e}function zt(t){return"function"==typeof t?t:function(){return t}}function St(t){return function(e,n,r){return 2===arguments.length&&"function"==typeof n&&(r=n,n=null),Ct(e,n,t,r)}}function Ct(t,e,n,r){function a(){var t,e=s.status;if(!e&&Ot(s)||e>=200&&e<300||304===e){try{t=n.call(o,s)}catch(t){return void i.error.call(o,t)}i.load.call(o,t)}else i.error.call(o,s)}var o={},i=ui.dispatch("beforesend","progress","load","error"),l={},s=new XMLHttpRequest,c=null;return!this.XDomainRequest||"withCredentials"in s||!/^(http(s)?:)?\/\//.test(t)||(s=new XDomainRequest),"onload"in s?s.onload=s.onerror=a:s.onreadystatechange=function(){s.readyState>3&&a()},s.onprogress=function(t){var e=ui.event;ui.event=t;try{i.progress.call(o,s)}finally{ui.event=e}},o.header=function(t,e){return t=(t+"").toLowerCase(),arguments.length<2?l[t]:(null==e?delete l[t]:l[t]=e+"",o)},o.mimeType=function(t){return arguments.length?(e=null==t?null:t+"",o):e},o.responseType=function(t){return arguments.length?(c=t,o):c},o.response=function(t){return n=t,o},["get","post"].forEach(function(t){o[t]=function(){return o.send.apply(o,[t].concat(di(arguments)))}}),o.send=function(n,r,a){if(2===arguments.length&&"function"==typeof r&&(a=r,r=null),s.open(n,t,!0),null==e||"accept"in l||(l.accept=e+",*/*"),s.setRequestHeader)for(var u in l)s.setRequestHeader(u,l[u]);return null!=e&&s.overrideMimeType&&s.overrideMimeType(e),null!=c&&(s.responseType=c),null!=a&&o.on("error",a).on("load",function(t){a(null,t)}),i.beforesend.call(o,s),s.send(null==r?null:r),o},o.abort=function(){return s.abort(),o},ui.rebind(o,i,"on"),null==r?o:o.get(Et(r))}function Et(t){return 1===t.length?function(e,n){t(null==e?n:null)}:t}function Ot(t){var e=t.responseType;return e&&"text"!==e?t.response:t.responseText}function Pt(t,e,n){var r=arguments.length;r<2&&(e=0),r<3&&(n=Date.now());var a=n+e,o={c:t,t:a,n:null};return ll?ll.n=o:il=o,ll=o,sl||(cl=clearTimeout(cl),sl=1,ul(Nt)),o}function Nt(){var t=Dt(),e=It()-t;e>24?(isFinite(e)&&(clearTimeout(cl),cl=setTimeout(Nt,e)),sl=0):(sl=1,ul(Nt))}function Dt(){for(var t=Date.now(),e=il;e;)t>=e.t&&e.c(t-e.t)&&(e.c=null),e=e.n;return t}function It(){for(var t,e=il,n=1/0;e;)e.c?(e.t8?function(t){return t/n}:function(t){return t*n},symbol:t}}function Ft(t){var e=t.decimal,n=t.thousands,r=t.grouping,a=t.currency,o=r&&n?function(t,e){for(var a=t.length,o=[],i=0,l=r[0],s=0;a>0&&l>0&&(s+l+1>e&&(l=Math.max(1,e-s)),o.push(t.substring(a-=l,a+l)),!((s+=l+1)>e));)l=r[i=(i+1)%r.length];return o.reverse().join(n)}:b;return function(t){var n=dl.exec(t),r=n[1]||" ",i=n[2]||">",l=n[3]||"-",s=n[4]||"",c=n[5],u=+n[6],f=n[7],d=n[8],h=n[9],p=1,g="",m="",v=!1,y=!0;switch(d&&(d=+d.substring(1)),(c||"0"===r&&"="===i)&&(c=r="0",i="="),h){case"n":f=!0,h="g";break;case"%":p=100,m="%",h="f";break;case"p":p=100,m="%",h="r";break;case"b":case"o":case"x":case"X":"#"===s&&(g="0"+h.toLowerCase());case"c":y=!1;case"d":v=!0,d=0;break;case"s":p=-1,h="r"}"$"===s&&(g=a[0],m=a[1]),"r"!=h||d||(h="g"),null!=d&&("g"==h?d=Math.max(1,Math.min(21,d)):"e"!=h&&"f"!=h||(d=Math.max(0,Math.min(20,d)))),h=hl.get(h)||qt;var x=c&&f;return function(t){var n=m;if(v&&t%1)return"";var a=t<0||0===t&&1/t<0?(t=-t,"-"):"-"===l?"":l;if(p<0){var s=ui.formatPrefix(t,d);t=s.scale(t),n=s.symbol+m}else t*=p;t=h(t,d);var b,_,w=t.lastIndexOf(".");if(w<0){var k=y?t.lastIndexOf("e"):-1;k<0?(b=t,_=""):(b=t.substring(0,k),_=t.substring(k))}else b=t.substring(0,w),_=e+t.substring(w+1);!c&&f&&(b=o(b,1/0));var M=g.length+b.length+_.length+(x?0:a.length),A=M"===i?A+a+t:"^"===i?A.substring(0,M>>=1)+a+t+A.substring(M):a+(x?t:A+t))+n}}}function qt(t){return t+""}function Bt(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}function Ht(t,e,n){function r(e){var n=t(e),r=o(n,1);return e-n1)for(;i=c)return-1;if(a=e.charCodeAt(l++),37===a){if(i=e.charAt(l++),o=S[i in vl?e.charAt(l++):i],!o||(r=o(t,n,r))<0)return-1}else if(a!=n.charCodeAt(r++))return-1}return r}function r(t,e,n){w.lastIndex=0;var r=w.exec(e.slice(n));return r?(t.w=k.get(r[0].toLowerCase()),n+r[0].length):-1}function a(t,e,n){b.lastIndex=0;var r=b.exec(e.slice(n));return r?(t.w=_.get(r[0].toLowerCase()),n+r[0].length):-1}function o(t,e,n){T.lastIndex=0;var r=T.exec(e.slice(n));return r?(t.m=L.get(r[0].toLowerCase()),n+r[0].length):-1}function i(t,e,n){M.lastIndex=0;var r=M.exec(e.slice(n));return r?(t.m=A.get(r[0].toLowerCase()),n+r[0].length):-1}function l(t,e,r){return n(t,z.c.toString(),e,r)}function s(t,e,r){return n(t,z.x.toString(),e,r)}function c(t,e,r){return n(t,z.X.toString(),e,r)}function u(t,e,n){var r=x.get(e.slice(n,n+=2).toLowerCase());return null==r?-1:(t.p=r,n)}var f=t.dateTime,d=t.date,h=t.time,p=t.periods,g=t.days,m=t.shortDays,v=t.months,y=t.shortMonths;e.utc=function(t){function n(t){try{gl=Bt;var e=new gl;return e._=t,r(e)}finally{gl=Date}}var r=e(t);return n.parse=function(t){try{gl=Bt;var e=r.parse(t);return e&&e._}finally{gl=Date}},n.toString=r.toString,n},e.multi=e.utc.multi=ue;var x=ui.map(),b=Yt(g),_=Xt(g),w=Yt(m),k=Xt(m),M=Yt(v),A=Xt(v),T=Yt(y),L=Xt(y);p.forEach(function(t,e){x.set(t.toLowerCase(),e)});var z={a:function(t){return m[t.getDay()]},A:function(t){return g[t.getDay()]},b:function(t){return y[t.getMonth()]},B:function(t){return v[t.getMonth()]},c:e(f),d:function(t,e){return Ut(t.getDate(),e,2)},e:function(t,e){return Ut(t.getDate(),e,2)},H:function(t,e){return Ut(t.getHours(),e,2)},I:function(t,e){return Ut(t.getHours()%12||12,e,2)},j:function(t,e){return Ut(1+pl.dayOfYear(t),e,3)},L:function(t,e){return Ut(t.getMilliseconds(),e,3)},m:function(t,e){return Ut(t.getMonth()+1,e,2)},M:function(t,e){return Ut(t.getMinutes(),e,2)},p:function(t){return p[+(t.getHours()>=12)]},S:function(t,e){return Ut(t.getSeconds(),e,2)},U:function(t,e){return Ut(pl.sundayOfYear(t),e,2)},w:function(t){return t.getDay()},W:function(t,e){return Ut(pl.mondayOfYear(t),e,2)},x:e(d),X:e(h),y:function(t,e){return Ut(t.getFullYear()%100,e,2)},Y:function(t,e){return Ut(t.getFullYear()%1e4,e,4)},Z:se,"%":function(){return"%"}},S={a:r,A:a,b:o,B:i,c:l,d:ne,e:ne,H:ae,I:ae,j:re,L:le,m:ee,M:oe,p:u,S:ie,U:$t,w:Gt,W:Qt,x:s,X:c,y:Jt,Y:Wt,Z:Kt,"%":ce};return e}function Ut(t,e,n){var r=t<0?"-":"",a=(r?-t:t)+"",o=a.length;return r+(o68?1900:2e3)}function ee(t,e,n){yl.lastIndex=0;var r=yl.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function ne(t,e,n){yl.lastIndex=0;var r=yl.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function re(t,e,n){yl.lastIndex=0;var r=yl.exec(e.slice(n,n+3));return r?(t.j=+r[0],n+r[0].length):-1}function ae(t,e,n){ ++yl.lastIndex=0;var r=yl.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function oe(t,e,n){yl.lastIndex=0;var r=yl.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function ie(t,e,n){yl.lastIndex=0;var r=yl.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function le(t,e,n){yl.lastIndex=0;var r=yl.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function se(t){var e=t.getTimezoneOffset(),n=e>0?"-":"+",r=bi(e)/60|0,a=bi(e)%60;return n+Ut(r,"0",2)+Ut(a,"0",2)}function ce(t,e,n){xl.lastIndex=0;var r=xl.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function ue(t){for(var e=t.length,n=-1;++n=0?1:-1,l=i*n,s=Math.cos(e),c=Math.sin(e),u=o*c,f=a*s+u*Math.cos(l),d=u*i*Math.sin(l);Al.add(Math.atan2(d,f)),r=t,a=s,o=c}var e,n,r,a,o;Tl.point=function(i,l){Tl.point=t,r=(e=i)*Vi,a=Math.cos(l=(n=l)*Vi/2+Fi/4),o=Math.sin(l)},Tl.lineEnd=function(){t(e,n)}}function ve(t){var e=t[0],n=t[1],r=Math.cos(n);return[r*Math.cos(e),r*Math.sin(e),Math.sin(n)]}function ye(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function xe(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function be(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function _e(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function we(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function ke(t){return[Math.atan2(t[1],t[0]),rt(t[2])]}function Me(t,e){return bi(t[0]-e[0])=0;--l)a.point((f=u[l])[0],f[1])}else r(h.x,h.p.x,-1,a);h=h.p}h=h.o,u=h.z,p=!p}while(!h.v);a.lineEnd()}}}function Pe(t){if(e=t.length){for(var e,n,r=0,a=t[0];++r0){for(_||(o.polygonStart(),_=!0),o.lineStart();++i1&&2&e&&n.push(n.pop().concat(n.shift())),h.push(n.filter(Ie))}var h,p,g,m=e(o),v=a.invert(r[0],r[1]),y={point:i,lineStart:s,lineEnd:c,polygonStart:function(){y.point=u,y.lineStart=f,y.lineEnd=d,h=[],p=[]},polygonEnd:function(){y.point=i,y.lineStart=s,y.lineEnd=c,h=ui.merge(h);var t=He(v,p);h.length?(_||(o.polygonStart(),_=!0),Oe(h,je,t,n,o)):t&&(_||(o.polygonStart(),_=!0),o.lineStart(),n(null,null,1,o),o.lineEnd()),_&&(o.polygonEnd(),_=!1),h=p=null},sphere:function(){o.polygonStart(),o.lineStart(),n(null,null,1,o),o.lineEnd(),o.polygonEnd()}},x=Re(),b=e(x),_=!1;return y}}function Ie(t){return t.length>1}function Re(){var t,e=[];return{lineStart:function(){e.push(t=[])},point:function(e,n){t.push([e,n])},lineEnd:k,buffer:function(){var n=e;return e=[],t=null,n},rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))}}}function je(t,e){return((t=t.x)[0]<0?t[1]-Hi-Ri:Hi-t[1])-((e=e.x)[0]<0?e[1]-Hi-Ri:Hi-e[1])}function Fe(t){var e,n=NaN,r=NaN,a=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(o,i){var l=o>0?Fi:-Fi,s=bi(o-n);bi(s-Fi)0?Hi:-Hi),t.point(a,r),t.lineEnd(),t.lineStart(),t.point(l,r),t.point(o,r),e=0):a!==l&&s>=Fi&&(bi(n-a)Ri?Math.atan((Math.sin(e)*(o=Math.cos(r))*Math.sin(n)-Math.sin(r)*(a=Math.cos(e))*Math.sin(t))/(a*o*i)):(e+r)/2}function Be(t,e,n,r){var a;if(null==t)a=n*Hi,r.point(-Fi,a),r.point(0,a),r.point(Fi,a),r.point(Fi,0),r.point(Fi,-a),r.point(0,-a),r.point(-Fi,-a),r.point(-Fi,0),r.point(-Fi,a);else if(bi(t[0]-e[0])>Ri){var o=t[0]=0?1:-1,k=w*_,M=k>Fi,A=p*x;if(Al.add(Math.atan2(A*w*Math.sin(k),g*b+A*Math.cos(k))),o+=M?_+w*qi:_,M^d>=n^v>=n){var T=xe(ve(f),ve(t));we(T);var L=xe(a,T);we(L);var z=(M^_>=0?-1:1)*rt(L[2]);(r>z||r===z&&(T[0]||T[1]))&&(i+=M^_>=0?1:-1)}if(!m++)break;d=v,p=x,g=b,f=t}}return(o<-Ri||oo}function n(t){var n,o,s,c,u;return{lineStart:function(){c=s=!1,u=1},point:function(f,d){var h,p=[f,d],g=e(f,d),m=i?g?0:a(f,d):g?a(f+(f<0?Fi:-Fi),d):0;if(!n&&(c=s=g)&&t.lineStart(),g!==s&&(h=r(n,p),(Me(n,h)||Me(p,h))&&(p[0]+=Ri,p[1]+=Ri,g=e(p[0],p[1]))),g!==s)u=0,g?(t.lineStart(),h=r(p,n),t.point(h[0],h[1])):(h=r(n,p),t.point(h[0],h[1]),t.lineEnd()),n=h;else if(l&&n&&i^g){var v;m&o||!(v=r(p,n,!0))||(u=0,i?(t.lineStart(),t.point(v[0][0],v[0][1]),t.point(v[1][0],v[1][1]),t.lineEnd()):(t.point(v[1][0],v[1][1]),t.lineEnd(),t.lineStart(),t.point(v[0][0],v[0][1])))}!g||n&&Me(n,p)||t.point(p[0],p[1]),n=p,s=g,o=m},lineEnd:function(){s&&t.lineEnd(),n=null},clean:function(){return u|(c&&s)<<1}}}function r(t,e,n){var r=ve(t),a=ve(e),i=[1,0,0],l=xe(r,a),s=ye(l,l),c=l[0],u=s-c*c;if(!u)return!n&&t;var f=o*s/u,d=-o*c/u,h=xe(i,l),p=_e(i,f),g=_e(l,d);be(p,g);var m=h,v=ye(p,m),y=ye(m,m),x=v*v-y*(ye(p,p)-1);if(!(x<0)){var b=Math.sqrt(x),_=_e(m,(-v-b)/y);if(be(_,p),_=ke(_),!n)return _;var w,k=t[0],M=e[0],A=t[1],T=e[1];M0^_[1]<(bi(_[0]-k)Fi^(k<=_[0]&&_[0]<=M)){var C=_e(m,(-v+b)/y);return be(C,p),[_,ke(C)]}}}function a(e,n){var r=i?t:Fi-t,a=0;return e<-r?a|=1:e>r&&(a|=2),n<-r?a|=4:n>r&&(a|=8),a}var o=Math.cos(t),i=o>0,l=bi(o)>Ri,s=vn(t,6*Vi);return De(e,n,s,i?[0,-t]:[-Fi,t-Fi])}function Ze(t,e,n,r){return function(a){var o,i=a.a,l=a.b,s=i.x,c=i.y,u=l.x,f=l.y,d=0,h=1,p=u-s,g=f-c;if(o=t-s,p||!(o>0)){if(o/=p,p<0){if(o0){if(o>h)return;o>d&&(d=o)}if(o=n-s,p||!(o<0)){if(o/=p,p<0){if(o>h)return;o>d&&(d=o)}else if(p>0){if(o0)){if(o/=g,g<0){if(o0){if(o>h)return;o>d&&(d=o)}if(o=r-c,g||!(o<0)){if(o/=g,g<0){if(o>h)return;o>d&&(d=o)}else if(g>0){if(o0&&(a.a={x:s+d*p,y:c+d*g}),h<1&&(a.b={x:s+h*p,y:c+h*g}),a}}}}}}function Ue(t,e,n,r){function a(r,a){return bi(r[0]-t)0?0:3:bi(r[0]-n)0?2:1:bi(r[1]-e)0?1:0:a>0?3:2}function o(t,e){return i(t.x,e.x)}function i(t,e){var n=a(t,1),r=a(e,1);return n!==r?n-r:0===n?e[1]-t[1]:1===n?t[0]-e[0]:2===n?t[1]-e[1]:e[0]-t[0]}return function(l){function s(t){for(var e=0,n=m.length,r=t[1],a=0;ar&&et(c,o,t)>0&&++e:o[1]<=r&&et(c,o,t)<0&&--e,c=o;return 0!==e}function c(o,l,s,c){var u=0,f=0;if(null==o||(u=a(o,s))!==(f=a(l,s))||i(o,l)<0^s>0){do c.point(0===u||3===u?t:n,u>1?r:e);while((u=(u+s+4)%4)!==f)}else c.point(l[0],l[1])}function u(a,o){return t<=a&&a<=n&&e<=o&&o<=r}function f(t,e){u(t,e)&&l.point(t,e)}function d(){S.point=p,m&&m.push(v=[]),M=!0,k=!1,_=w=NaN}function h(){g&&(p(y,x),b&&k&&L.rejoin(),g.push(L.buffer())),S.point=f,k&&l.lineEnd()}function p(t,e){t=Math.max(-ql,Math.min(ql,t)),e=Math.max(-ql,Math.min(ql,e));var n=u(t,e);if(m&&v.push([t,e]),M)y=t,x=e,b=n,M=!1,n&&(l.lineStart(),l.point(t,e));else if(n&&k)l.point(t,e);else{var r={a:{x:_,y:w},b:{x:t,y:e}};z(r)?(k||(l.lineStart(),l.point(r.a.x,r.a.y)),l.point(r.b.x,r.b.y),n||l.lineEnd(),A=!1):n&&(l.lineStart(),l.point(t,e),A=!1)}_=t,w=e,k=n}var g,m,v,y,x,b,_,w,k,M,A,T=l,L=Re(),z=Ze(t,e,n,r),S={point:f,lineStart:d,lineEnd:h,polygonStart:function(){l=L,g=[],m=[],A=!0},polygonEnd:function(){l=T,g=ui.merge(g);var e=s([t,r]),n=A&&e,a=g.length;(n||a)&&(l.polygonStart(),n&&(l.lineStart(),c(null,null,1,l),l.lineEnd()),a&&Oe(g,o,e,c,l),l.polygonEnd()),g=m=v=null}};return S}}function Ye(t){var e=0,n=Fi/3,r=cn(t),a=r(e,n);return a.parallels=function(t){return arguments.length?r(e=t[0]*Fi/180,n=t[1]*Fi/180):[e/Fi*180,n/Fi*180]},a}function Xe(t,e){function n(t,e){var n=Math.sqrt(o-2*a*Math.sin(e))/a;return[n*Math.sin(t*=a),i-n*Math.cos(t)]}var r=Math.sin(t),a=(r+Math.sin(e))/2,o=1+r*(2*a-r),i=Math.sqrt(o)/a;return n.invert=function(t,e){var n=i-e;return[Math.atan2(t,n)/a,rt((o-(t*t+n*n)*a*a)/(2*a))]},n}function Ge(){function t(t,e){Hl+=a*t-r*e,r=t,a=e}var e,n,r,a;Xl.point=function(o,i){Xl.point=t,e=r=o,n=a=i},Xl.lineEnd=function(){t(e,n)}}function $e(t,e){tUl&&(Ul=t),eYl&&(Yl=e)}function Qe(){function t(t,e){i.push("M",t,",",e,o)}function e(t,e){i.push("M",t,",",e),l.point=n}function n(t,e){i.push("L",t,",",e)}function r(){l.point=t}function a(){i.push("Z")}var o=We(4.5),i=[],l={point:t,lineStart:function(){l.point=e},lineEnd:r,polygonStart:function(){l.lineEnd=a},polygonEnd:function(){l.lineEnd=r,l.point=t},pointRadius:function(t){return o=We(t),l},result:function(){if(i.length){var t=i.join("");return i=[],t}}};return l}function We(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}function Je(t,e){Sl+=t,Cl+=e,++El}function Ke(){function t(t,r){var a=t-e,o=r-n,i=Math.sqrt(a*a+o*o);Ol+=i*(e+t)/2,Pl+=i*(n+r)/2,Nl+=i,Je(e=t,n=r)}var e,n;$l.point=function(r,a){$l.point=t,Je(e=r,n=a)}}function tn(){$l.point=Je}function en(){function t(t,e){var n=t-r,o=e-a,i=Math.sqrt(n*n+o*o);Ol+=i*(r+t)/2,Pl+=i*(a+e)/2,Nl+=i,i=a*t-r*e,Dl+=i*(r+t),Il+=i*(a+e),Rl+=3*i,Je(r=t,a=e)}var e,n,r,a;$l.point=function(o,i){$l.point=t,Je(e=r=o,n=a=i)},$l.lineEnd=function(){t(e,n)}}function nn(t){function e(e,n){t.moveTo(e+i,n),t.arc(e,n,i,0,qi)}function n(e,n){t.moveTo(e,n),l.point=r}function r(e,n){t.lineTo(e,n)}function a(){l.point=e}function o(){t.closePath()}var i=4.5,l={point:e,lineStart:function(){l.point=n},lineEnd:a,polygonStart:function(){l.lineEnd=o},polygonEnd:function(){l.lineEnd=a,l.point=e},pointRadius:function(t){return i=t,l},result:k};return l}function rn(t){function e(t){return(l?r:n)(t)}function n(e){return ln(e,function(n,r){n=t(n,r),e.point(n[0],n[1])})}function r(e){function n(n,r){n=t(n,r),e.point(n[0],n[1])}function r(){x=NaN,M.point=o,e.lineStart()}function o(n,r){var o=ve([n,r]),i=t(n,r);a(x,b,y,_,w,k,x=i[0],b=i[1],y=n,_=o[0],w=o[1],k=o[2],l,e),e.point(x,b)}function i(){M.point=n,e.lineEnd()}function s(){r(),M.point=c,M.lineEnd=u}function c(t,e){o(f=t,d=e),h=x,p=b,g=_,m=w,v=k,M.point=o}function u(){a(x,b,y,_,w,k,h,p,f,g,m,v,l,e),M.lineEnd=i,i()}var f,d,h,p,g,m,v,y,x,b,_,w,k,M={point:n,lineStart:r,lineEnd:i,polygonStart:function(){e.polygonStart(),M.lineStart=s},polygonEnd:function(){e.polygonEnd(),M.lineStart=r}};return M}function a(e,n,r,l,s,c,u,f,d,h,p,g,m,v){var y=u-e,x=f-n,b=y*y+x*x;if(b>4*o&&m--){var _=l+h,w=s+p,k=c+g,M=Math.sqrt(_*_+w*w+k*k),A=Math.asin(k/=M),T=bi(bi(k)-1)o||bi((y*C+x*E)/b-.5)>.3||l*h+s*p+c*g0&&16,e):Math.sqrt(o)},e}function an(t){var e=rn(function(e,n){return t([e*Zi,n*Zi])});return function(t){return un(e(t))}}function on(t){this.stream=t}function ln(t,e){return{point:e,sphere:function(){t.sphere()},lineStart:function(){t.lineStart()},lineEnd:function(){t.lineEnd()},polygonStart:function(){t.polygonStart()},polygonEnd:function(){t.polygonEnd()}}}function sn(t){return cn(function(){return t})()}function cn(t){function e(t){return t=l(t[0]*Vi,t[1]*Vi),[t[0]*d+s,c-t[1]*d]}function n(t){return t=l.invert((t[0]-s)/d,(c-t[1])/d),t&&[t[0]*Zi,t[1]*Zi]}function r(){l=Ce(i=hn(v,y,x),o);var t=o(g,m);return s=h-t[0]*d,c=p+t[1]*d,a()}function a(){return u&&(u.valid=!1,u=null),e}var o,i,l,s,c,u,f=rn(function(t,e){return t=o(t,e),[t[0]*d+s,c-t[1]*d]}),d=150,h=480,p=250,g=0,m=0,v=0,y=0,x=0,_=Fl,w=b,k=null,M=null;return e.stream=function(t){return u&&(u.valid=!1),u=un(_(i,f(w(t)))),u.valid=!0,u},e.clipAngle=function(t){return arguments.length?(_=null==t?(k=t,Fl):Ve((k=+t)*Vi),a()):k},e.clipExtent=function(t){return arguments.length?(M=t,w=t?Ue(t[0][0],t[0][1],t[1][0],t[1][1]):b,a()):M},e.scale=function(t){return arguments.length?(d=+t,r()):d},e.translate=function(t){return arguments.length?(h=+t[0],p=+t[1],r()):[h,p]},e.center=function(t){return arguments.length?(g=t[0]%360*Vi,m=t[1]%360*Vi,r()):[g*Zi,m*Zi]},e.rotate=function(t){return arguments.length?(v=t[0]%360*Vi,y=t[1]%360*Vi,x=t.length>2?t[2]%360*Vi:0,r()):[v*Zi,y*Zi,x*Zi]},ui.rebind(e,f,"precision"),function(){return o=t.apply(this,arguments),e.invert=o.invert&&n,r()}}function un(t){return ln(t,function(e,n){t.point(e*Vi,n*Vi)})}function fn(t,e){return[t,e]}function dn(t,e){return[t>Fi?t-qi:t<-Fi?t+qi:t,e]}function hn(t,e,n){return t?e||n?Ce(gn(t),mn(e,n)):gn(t):e||n?mn(e,n):dn}function pn(t){return function(e,n){return e+=t,[e>Fi?e-qi:e<-Fi?e+qi:e,n]}}function gn(t){var e=pn(t);return e.invert=pn(-t),e}function mn(t,e){function n(t,e){var n=Math.cos(e),l=Math.cos(t)*n,s=Math.sin(t)*n,c=Math.sin(e),u=c*r+l*a;return[Math.atan2(s*o-u*i,l*r-c*a),rt(u*o+s*i)]}var r=Math.cos(t),a=Math.sin(t),o=Math.cos(e),i=Math.sin(e);return n.invert=function(t,e){var n=Math.cos(e),l=Math.cos(t)*n,s=Math.sin(t)*n,c=Math.sin(e),u=c*o-s*i;return[Math.atan2(s*o+c*i,l*r+u*a),rt(u*r-l*a)]},n}function vn(t,e){var n=Math.cos(t),r=Math.sin(t);return function(a,o,i,l){var s=i*e;null!=a?(a=yn(n,a),o=yn(n,o),(i>0?ao)&&(a+=i*qi)):(a=t+i*qi,o=t-.5*s);for(var c,u=a;i>0?u>o:u0?e<-Hi+Ri&&(e=-Hi+Ri):e>Hi-Ri&&(e=Hi-Ri);var n=i/Math.pow(a(e),o);return[n*Math.sin(o*t),i-n*Math.cos(o*t)]}var r=Math.cos(t),a=function(t){return Math.tan(Fi/4+t/2)},o=t===e?Math.sin(t):Math.log(r/Math.cos(e))/Math.log(a(e)/a(t)),i=r*Math.pow(a(t),o)/o;return o?(n.invert=function(t,e){var n=i-e,r=tt(o)*Math.sqrt(t*t+n*n);return[Math.atan2(t,n)/o,2*Math.atan(Math.pow(i/r,1/o))-Hi]},n):zn}function Ln(t,e){function n(t,e){var n=o-e;return[n*Math.sin(a*t),o-n*Math.cos(a*t)]}var r=Math.cos(t),a=t===e?Math.sin(t):(r-Math.cos(e))/(e-t),o=r/a+t;return bi(a)1&&et(t[n[r-2]],t[n[r-1]],t[a])<=0;)--r;n[r++]=a}return n.slice(0,r)}function Nn(t,e){return t[0]-e[0]||t[1]-e[1]}function Dn(t,e,n){return(n[0]-e[0])*(t[1]-e[1])<(n[1]-e[1])*(t[0]-e[0])}function In(t,e,n,r){var a=t[0],o=n[0],i=e[0]-a,l=r[0]-o,s=t[1],c=n[1],u=e[1]-s,f=r[1]-c,d=(l*(s-c)-f*(a-o))/(f*i-l*u);return[a+d*i,s+d*u]}function Rn(t){var e=t[0],n=t[t.length-1];return!(e[0]-n[0]||e[1]-n[1])}function jn(){or(this),this.edge=this.site=this.circle=null}function Fn(t){var e=cs.pop()||new jn;return e.site=t,e}function qn(t){Qn(t),is.remove(t),cs.push(t),or(t)}function Bn(t){var e=t.circle,n=e.x,r=e.cy,a={x:n,y:r},o=t.P,i=t.N,l=[t];qn(t);for(var s=o;s.circle&&bi(n-s.circle.x)Ri)l=l.L;else{if(a=o-Zn(l,i),!(a>Ri)){r>-Ri?(e=l.P,n=l):a>-Ri?(e=l,n=l.N):e=n=l;break}if(!l.R){e=l;break}l=l.R}var s=Fn(t);if(is.insert(e,s),e||n){if(e===n)return Qn(e),n=Fn(e.site),is.insert(s,n),s.edge=n.edge=tr(e.site,s.site),$n(e),void $n(n);if(!n)return void(s.edge=tr(e.site,s.site));Qn(e),Qn(n);var c=e.site,u=c.x,f=c.y,d=t.x-u,h=t.y-f,p=n.site,g=p.x-u,m=p.y-f,v=2*(d*m-h*g),y=d*d+h*h,x=g*g+m*m,b={x:(m*y-h*x)/v+u,y:(d*x-g*y)/v+f};nr(n.edge,c,p,b),s.edge=tr(c,t,null,b),n.edge=tr(t,p,null,b),$n(e),$n(n)}}function Vn(t,e){var n=t.site,r=n.x,a=n.y,o=a-e;if(!o)return r;var i=t.P;if(!i)return-(1/0);n=i.site;var l=n.x,s=n.y,c=s-e;if(!c)return l;var u=l-r,f=1/o-1/c,d=u/c;return f?(-d+Math.sqrt(d*d-2*f*(u*u/(-2*c)-s+c/2+a-o/2)))/f+r:(r+l)/2}function Zn(t,e){var n=t.N;if(n)return Vn(n,e);var r=t.site;return r.y===e?r.x:1/0}function Un(t){this.site=t,this.edges=[]}function Yn(t){for(var e,n,r,a,o,i,l,s,c,u,f=t[0][0],d=t[1][0],h=t[0][1],p=t[1][1],g=os,m=g.length;m--;)if(o=g[m],o&&o.prepare())for(l=o.edges,s=l.length,i=0;iRi||bi(a-n)>Ri)&&(l.splice(i,0,new rr(er(o.site,u,bi(r-f)Ri?{x:f,y:bi(e-f)Ri?{x:bi(n-p)Ri?{x:d,y:bi(e-d)Ri?{x:bi(n-h)=-ji)){var h=s*s+c*c,p=u*u+f*f,g=(f*h-c*p)/d,m=(s*p-u*h)/d,f=m+l,v=us.pop()||new Gn;v.arc=t,v.site=a,v.x=g+i,v.y=f+Math.sqrt(g*g+m*m),v.cy=f,t.circle=v;for(var y=null,x=ss._;x;)if(v.y=l)return;if(d>p){if(o){if(o.y>=c)return}else o={x:m,y:s};n={x:m,y:c}}else{if(o){if(o.y1)if(d>p){if(o){if(o.y>=c)return}else o={x:(s-a)/r,y:s};n={x:(c-a)/r,y:c}}else{if(o){if(o.y=l)return}else o={x:i,y:r*i+a};n={x:l,y:r*l+a}}else{if(o){if(o.xo||f>i||d=b,k=n>=_,M=k<<1|w,A=M+4;Mo&&(a=e.slice(o,a),l[i]?l[i]+=a:l[++i]=a),(n=n[0])===(r=r[0])?l[i]?l[i]+=r:l[++i]=r:(l[++i]=null,s.push({i:i,x:xr(n,r)})),o=hs.lastIndex;return o=0&&!(n=ui.interpolators[r](t,e)););return n}function wr(t,e){var n,r=[],a=[],o=t.length,i=e.length,l=Math.min(t.length,e.length);for(n=0;n=1?1:t(e)}}function Mr(t){return function(e){return 1-t(1-e)}}function Ar(t){return function(e){return.5*(e<.5?t(2*e):2-t(2-2*e))}}function Tr(t){return t*t}function Lr(t){return t*t*t}function zr(t){if(t<=0)return 0;if(t>=1)return 1;var e=t*t,n=e*t;return 4*(t<.5?n:3*(t-e)+n-.75)}function Sr(t){return function(e){return Math.pow(e,t)}}function Cr(t){return 1-Math.cos(t*Hi)}function Er(t){return Math.pow(2,10*(t-1))}function Or(t){return 1-Math.sqrt(1-t*t)}function Pr(t,e){var n;return arguments.length<2&&(e=.45),arguments.length?n=e/qi*Math.asin(1/t):(t=1,n=e/4),function(r){return 1+t*Math.pow(2,-10*r)*Math.sin((r-n)*qi/e)}}function Nr(t){return t||(t=1.70158),function(e){return e*e*((t+1)*e-t)}}function Dr(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}function Ir(t,e){t=ui.hcl(t),e=ui.hcl(e);var n=t.h,r=t.c,a=t.l,o=e.h-n,i=e.c-r,l=e.l-a;return isNaN(i)&&(i=0,r=isNaN(r)?e.c:r),isNaN(o)?(o=0,n=isNaN(n)?e.h:n):o>180?o-=360:o<-180&&(o+=360),function(t){return dt(n+o*t,r+i*t,a+l*t)+""}}function Rr(t,e){t=ui.hsl(t),e=ui.hsl(e);var n=t.h,r=t.s,a=t.l,o=e.h-n,i=e.s-r,l=e.l-a;return isNaN(i)&&(i=0,r=isNaN(r)?e.s:r),isNaN(o)?(o=0,n=isNaN(n)?e.h:n):o>180?o-=360:o<-180&&(o+=360),function(t){return ut(n+o*t,r+i*t,a+l*t)+""}}function jr(t,e){t=ui.lab(t),e=ui.lab(e);var n=t.l,r=t.a,a=t.b,o=e.l-n,i=e.a-r,l=e.b-a;return function(t){return pt(n+o*t,r+i*t,a+l*t)+""}}function Fr(t,e){return e-=t,function(n){return Math.round(t+e*n)}}function qr(t){var e=[t.a,t.b],n=[t.c,t.d],r=Hr(e),a=Br(e,n),o=Hr(Vr(n,e,-a))||0;e[0]*n[1]180?e+=360:e-t>180&&(t+=360),r.push({i:n.push(Zr(n)+"rotate(",null,")")-2,x:xr(t,e)})):e&&n.push(Zr(n)+"rotate("+e+")")}function Xr(t,e,n,r){t!==e?r.push({i:n.push(Zr(n)+"skewX(",null,")")-2,x:xr(t,e)}):e&&n.push(Zr(n)+"skewX("+e+")")}function Gr(t,e,n,r){if(t[0]!==e[0]||t[1]!==e[1]){var a=n.push(Zr(n)+"scale(",null,",",null,")");r.push({i:a-4,x:xr(t[0],e[0])},{i:a-2,x:xr(t[1],e[1])})}else 1===e[0]&&1===e[1]||n.push(Zr(n)+"scale("+e+")")}function $r(t,e){var n=[],r=[];return t=ui.transform(t),e=ui.transform(e),Ur(t.translate,e.translate,n,r),Yr(t.rotate,e.rotate,n,r),Xr(t.skew,e.skew,n,r),Gr(t.scale,e.scale,n,r),t=e=null,function(t){for(var e,a=-1,o=r.length;++a=0;)n.push(a[r])}function sa(t,e){for(var n=[t],r=[];null!=(t=n.pop());)if(r.push(t),(o=t.children)&&(a=o.length))for(var a,o,i=-1;++ia&&(r=n,a=e);return r}function xa(t){return t.reduce(ba,0)}function ba(t,e){return t+e[1]}function _a(t,e){return wa(t,Math.ceil(Math.log(e.length)/Math.LN2+1))}function wa(t,e){for(var n=-1,r=+t[0],a=(t[1]-r)/e,o=[];++n<=e;)o[n]=a*n+r;return o}function ka(t){return[ui.min(t),ui.max(t)]}function Ma(t,e){return t.value-e.value}function Aa(t,e){var n=t._pack_next;t._pack_next=e,e._pack_prev=t,e._pack_next=n,n._pack_prev=e}function Ta(t,e){t._pack_next=e,e._pack_prev=t}function La(t,e){var n=e.x-t.x,r=e.y-t.y,a=t.r+e.r;return.999*a*a>n*n+r*r}function za(t){function e(t){u=Math.min(t.x-t.r,u),f=Math.max(t.x+t.r,f),d=Math.min(t.y-t.r,d),h=Math.max(t.y+t.r,h)}if((n=t.children)&&(c=n.length)){var n,r,a,o,i,l,s,c,u=1/0,f=-(1/0),d=1/0,h=-(1/0);if(n.forEach(Sa),r=n[0],r.x=-r.r,r.y=0,e(r),c>1&&(a=n[1],a.x=a.r,a.y=0,e(a),c>2))for(o=n[2],Oa(r,a,o),e(o),Aa(r,o),r._pack_prev=o, ++Aa(o,a),a=r._pack_next,i=3;i=0;)e=a[o],e.z+=n,e.m+=n,n+=e.s+(r+=e.c)}function ja(t,e,n){return t.a.parent===e.parent?t.a:n}function Fa(t){return 1+ui.max(t,function(t){return t.y})}function qa(t){return t.reduce(function(t,e){return t+e.x},0)/t.length}function Ba(t){var e=t.children;return e&&e.length?Ba(e[0]):t}function Ha(t){var e,n=t.children;return n&&(e=n.length)?Ha(n[e-1]):t}function Va(t){return{x:t.x,y:t.y,dx:t.dx,dy:t.dy}}function Za(t,e){var n=t.x+e[3],r=t.y+e[0],a=t.dx-e[1]-e[3],o=t.dy-e[0]-e[2];return a<0&&(n+=a/2,a=0),o<0&&(r+=o/2,o=0),{x:n,y:r,dx:a,dy:o}}function Ua(t){var e=t[0],n=t[t.length-1];return e2?Qa:Xa,s=r?Wr:Qr;return i=a(t,e,s,n),l=a(e,t,s,_r),o}function o(t){return i(t)}var i,l;return o.invert=function(t){return l(t)},o.domain=function(e){return arguments.length?(t=e.map(Number),a()):t},o.range=function(t){return arguments.length?(e=t,a()):e},o.rangeRound=function(t){return o.range(t).interpolate(Fr)},o.clamp=function(t){return arguments.length?(r=t,a()):r},o.interpolate=function(t){return arguments.length?(n=t,a()):n},o.ticks=function(e){return eo(t,e)},o.tickFormat=function(e,n){return no(t,e,n)},o.nice=function(e){return Ka(t,e),a()},o.copy=function(){return Wa(t,e,n,r)},a()}function Ja(t,e){return ui.rebind(t,e,"range","rangeRound","interpolate","clamp")}function Ka(t,e){return Ga(t,$a(to(t,e)[2])),Ga(t,$a(to(t,e)[2])),t}function to(t,e){null==e&&(e=10);var n=Ua(t),r=n[1]-n[0],a=Math.pow(10,Math.floor(Math.log(r/e)/Math.LN10)),o=e/r*a;return o<=.15?a*=10:o<=.35?a*=5:o<=.75&&(a*=2),n[0]=Math.ceil(n[0]/a)*a,n[1]=Math.floor(n[1]/a)*a+.5*a,n[2]=a,n}function eo(t,e){return ui.range.apply(ui,to(t,e))}function no(t,e,n){var r=to(t,e);if(n){var a=dl.exec(n);if(a.shift(),"s"===a[8]){var o=ui.formatPrefix(Math.max(bi(r[0]),bi(r[1])));return a[7]||(a[7]="."+ro(o.scale(r[2]))),a[8]="f",n=ui.format(a.join("")),function(t){return n(o.scale(t))+o.symbol}}a[7]||(a[7]="."+ao(a[8],r)),n=a.join("")}else n=",."+ro(r[2])+"f";return ui.format(n)}function ro(t){return-Math.floor(Math.log(t)/Math.LN10+.01)}function ao(t,e){var n=ro(e[2]);return t in As?Math.abs(n-ro(Math.max(bi(e[0]),bi(e[1]))))+ +("e"!==t):n-2*("%"===t)}function oo(t,e,n,r){function a(t){return(n?Math.log(t<0?0:t):-Math.log(t>0?0:-t))/Math.log(e)}function o(t){return n?Math.pow(e,t):-Math.pow(e,-t)}function i(e){return t(a(e))}return i.invert=function(e){return o(t.invert(e))},i.domain=function(e){return arguments.length?(n=e[0]>=0,t.domain((r=e.map(Number)).map(a)),i):r},i.base=function(n){return arguments.length?(e=+n,t.domain(r.map(a)),i):e},i.nice=function(){var e=Ga(r.map(a),n?Math:Ls);return t.domain(e),r=e.map(o),i},i.ticks=function(){var t=Ua(r),i=[],l=t[0],s=t[1],c=Math.floor(a(l)),u=Math.ceil(a(s)),f=e%1?2:e;if(isFinite(u-c)){if(n){for(;c0;d--)i.push(o(c)*d);for(c=0;i[c]s;u--);i=i.slice(c,u)}return i},i.tickFormat=function(t,n){if(!arguments.length)return Ts;arguments.length<2?n=Ts:"function"!=typeof n&&(n=ui.format(n));var r=Math.max(1,e*t/i.ticks().length);return function(t){var i=t/o(Math.round(a(t)));return i*e0?l[n-1]:t[0],n0?0:1}function _o(t,e,n,r,a){var o=t[0]-e[0],i=t[1]-e[1],l=(a?r:-r)/Math.sqrt(o*o+i*i),s=l*i,c=-l*o,u=t[0]+s,f=t[1]+c,d=e[0]+s,h=e[1]+c,p=(u+d)/2,g=(f+h)/2,m=d-u,v=h-f,y=m*m+v*v,x=n-r,b=u*h-d*f,_=(v<0?-1:1)*Math.sqrt(Math.max(0,x*x*y-b*b)),w=(b*v-m*_)/y,k=(-b*m-v*_)/y,M=(b*v+m*_)/y,A=(-b*m+v*_)/y,T=w-p,L=k-g,z=M-p,S=A-g;return T*T+L*L>z*z+S*S&&(w=M,k=A),[[w-s,k-c],[w*n/x,k*n/x]]}function wo(t){function e(e){function i(){c.push("M",o(t(u),l))}for(var s,c=[],u=[],f=-1,d=e.length,h=zt(n),p=zt(r);++f1?t.join("L"):t+"Z"}function Mo(t){return t.join("L")+"Z"}function Ao(t){for(var e=0,n=t.length,r=t[0],a=[r[0],",",r[1]];++e1&&a.push("H",r[0]),a.join("")}function To(t){for(var e=0,n=t.length,r=t[0],a=[r[0],",",r[1]];++e1){l=e[1],o=t[s],s++,r+="C"+(a[0]+i[0])+","+(a[1]+i[1])+","+(o[0]-l[0])+","+(o[1]-l[1])+","+o[0]+","+o[1];for(var c=2;c9&&(a=3*e/Math.sqrt(a),i[l]=a*n,i[l+1]=a*r));for(l=-1;++l<=s;)a=(t[Math.min(s,l+1)][0]-t[Math.max(0,l-1)][0])/(6*(1+i[l]*i[l])),o.push([a||0,i[l]*a||0]);return o}function Ho(t){return t.length<3?ko(t):t[0]+Eo(t,Bo(t))}function Vo(t){for(var e,n,r,a=-1,o=t.length;++a0;)h[--l].call(t,i);if(o>=1)return g.event&&g.event.end.call(t,t.__data__,e),--p.count?delete p[r]:delete t[n],1}var s,c,u,d,h,p=t[n]||(t[n]={active:0,count:0}),g=p[r];g||(s=a.time,c=Pt(o,0,s),g=p[r]={tween:new f,time:s,timer:c,delay:a.delay,duration:a.duration,ease:a.ease,index:e},a=null,++p.count)}function ri(t,e,n){t.attr("transform",function(t){var r=e(t);return"translate("+(isFinite(r)?r:n(t))+",0)"})}function ai(t,e,n){t.attr("transform",function(t){var r=e(t);return"translate(0,"+(isFinite(r)?r:n(t))+")"})}function oi(t){return t.toISOString()}function ii(t,e,n){function r(e){return t(e)}function a(t,n){var r=t[1]-t[0],a=r/n,o=ui.bisect(Js,a);return o==Js.length?[e.year,to(t.map(function(t){return t/31536e6}),n)[2]]:o?e[a/Js[o-1]1?{floor:function(e){for(;n(e=t.floor(e));)e=li(e-1);return e},ceil:function(e){for(;n(e=t.ceil(e));)e=li(+e+1);return e}}:t))},r.ticks=function(t,e){var n=Ua(r.domain()),o=null==t?a(n,10):"number"==typeof t?a(n,t):!t.range&&[{range:t},e];return o&&(t=o[0],e=o[1]),t.range(n[0],li(+n[1]+1),e<1?1:e)},r.tickFormat=function(){return n},r.copy=function(){return ii(t.copy(),e,n)},Ja(r,t)}function li(t){return new Date(t)}function si(t){return JSON.parse(t.responseText)}function ci(t){var e=hi.createRange();return e.selectNode(hi.body),e.createContextualFragment(t.responseText)}var ui={version:"3.5.17"},fi=[].slice,di=function(t){return fi.call(t)},hi=this.document;if(hi)try{di(hi.documentElement.childNodes)[0].nodeType}catch(t){di=function(t){for(var e=t.length,n=new Array(e);e--;)n[e]=t[e];return n}}if(Date.now||(Date.now=function(){return+new Date}),hi)try{hi.createElement("DIV").style.setProperty("opacity",0,"")}catch(t){var pi=this.Element.prototype,gi=pi.setAttribute,mi=pi.setAttributeNS,vi=this.CSSStyleDeclaration.prototype,yi=vi.setProperty;pi.setAttribute=function(t,e){gi.call(this,t,e+"")},pi.setAttributeNS=function(t,e,n){mi.call(this,t,e,n+"")},vi.setProperty=function(t,e,n){yi.call(this,t,e+"",n)}}ui.ascending=a,ui.descending=function(t,e){return et?1:e>=t?0:NaN},ui.min=function(t,e){var n,r,a=-1,o=t.length;if(1===arguments.length){for(;++a=r){n=r;break}for(;++ar&&(n=r)}else{for(;++a=r){n=r;break}for(;++ar&&(n=r)}return n},ui.max=function(t,e){var n,r,a=-1,o=t.length;if(1===arguments.length){for(;++a=r){n=r;break}for(;++an&&(n=r)}else{for(;++a=r){n=r;break}for(;++an&&(n=r)}return n},ui.extent=function(t,e){var n,r,a,o=-1,i=t.length;if(1===arguments.length){for(;++o=r){n=a=r;break}for(;++or&&(n=r),a=r){n=a=r;break}for(;++or&&(n=r),a1)return s/(u-1)},ui.deviation=function(){var t=ui.variance.apply(this,arguments);return t?Math.sqrt(t):t};var xi=l(a);ui.bisectLeft=xi.left,ui.bisect=ui.bisectRight=xi.right,ui.bisector=function(t){return l(1===t.length?function(e,n){return a(t(e),n)}:t)},ui.shuffle=function(t,e,n){(o=arguments.length)<3&&(n=t.length,o<2&&(e=0));for(var r,a,o=n-e;o;)a=Math.random()*o--|0,r=t[o+e],t[o+e]=t[a+e],t[a+e]=r;return t},ui.permute=function(t,e){for(var n=e.length,r=new Array(n);n--;)r[n]=t[e[n]];return r},ui.pairs=function(t){for(var e,n=0,r=t.length-1,a=t[0],o=new Array(r<0?0:r);n=0;)for(r=t[a],e=r.length;--e>=0;)n[--i]=r[e];return n};var bi=Math.abs;ui.range=function(t,e,n){if(arguments.length<3&&(n=1,arguments.length<2&&(e=t,t=0)),(e-t)/n===1/0)throw new Error("infinite range");var r,a=[],o=c(bi(n)),i=-1;if(t*=o,e*=o,n*=o,n<0)for(;(r=t+n*++i)>e;)a.push(r/o);else for(;(r=t+n*++i)=o.length)return r?r.call(a,i):n?i.sort(n):i;for(var s,c,u,d,h=-1,p=i.length,g=o[l++],m=new f;++h=o.length)return t;var r=[],a=i[n++];return t.forEach(function(t,a){r.push({key:t,values:e(a,n)})}),a?r.sort(function(t,e){return a(t.key,e.key)}):r}var n,r,a={},o=[],i=[];return a.map=function(e,n){return t(n,e,0)},a.entries=function(n){return e(t(ui.map,n,0),0)},a.key=function(t){return o.push(t),a},a.sortKeys=function(t){return i[o.length-1]=t,a},a.sortValues=function(t){return n=t,a},a.rollup=function(t){return r=t,a},a},ui.set=function(t){var e=new x;if(t)for(var n=0,r=t.length;n=0&&(r=t.slice(n+1),t=t.slice(0,n)),t)return arguments.length<2?this[t].on(r):this[t].on(r,e);if(2===arguments.length){if(null==e)for(t in this)this.hasOwnProperty(t)&&this[t].on(r,null);return this}},ui.event=null,ui.requote=function(t){return t.replace(Mi,"\\$&")};var Mi=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,Ai={}.__proto__?function(t,e){t.__proto__=e}:function(t,e){for(var n in e)t[n]=e[n]},Ti=function(t,e){return e.querySelector(t)},Li=function(t,e){return e.querySelectorAll(t)},zi=function(t,e){var n=t.matches||t[w(t,"matchesSelector")];return(zi=function(t,e){return n.call(t,e)})(t,e)};"function"==typeof Sizzle&&(Ti=function(t,e){return Sizzle(t,e)[0]||null},Li=Sizzle,zi=Sizzle.matchesSelector),ui.selection=function(){return ui.select(hi.documentElement)};var Si=ui.selection.prototype=[];Si.select=function(t){var e,n,r,a,o=[];t=C(t);for(var i=-1,l=this.length;++i=0&&"xmlns"!==(n=t.slice(0,e))&&(t=t.slice(e+1)),Ei.hasOwnProperty(n)?{space:Ei[n],local:t}:t}},Si.attr=function(t,e){if(arguments.length<2){if("string"==typeof t){var n=this.node();return t=ui.ns.qualify(t),t.local?n.getAttributeNS(t.space,t.local):n.getAttribute(t)}for(e in t)this.each(O(e,t[e]));return this}return this.each(O(t,e))},Si.classed=function(t,e){if(arguments.length<2){if("string"==typeof t){var n=this.node(),r=(t=D(t)).length,a=-1;if(e=n.classList){for(;++a=0;)(n=r[a])&&(o&&o!==n.nextSibling&&o.parentNode.insertBefore(n,o),o=n);return this},Si.sort=function(t){t=Z.apply(this,arguments);for(var e=-1,n=this.length;++e0&&(e=e.transition().duration(S)),e.call(t.event)}function l(){_&&_.domain(b.range().map(function(t){ ++return(t-M.x)/M.k}).map(b.invert)),k&&k.domain(w.range().map(function(t){return(t-M.y)/M.k}).map(w.invert))}function s(t){C++||t({type:"zoomstart"})}function c(t){l(),t({type:"zoom",scale:M.k,translate:[M.x,M.y]})}function u(t){--C||(t({type:"zoomend"}),m=null)}function f(){function t(){l=1,o(ui.mouse(a),d),c(i)}function n(){f.on(O,null).on(P,null),h(l),u(i)}var a=this,i=D.of(a,arguments),l=0,f=ui.select(r(a)).on(O,t).on(P,n),d=e(ui.mouse(a)),h=W(a);Hs.call(a),s(i)}function d(){function t(){var t=ui.touches(p);return h=M.k,t.forEach(function(t){t.identifier in m&&(m[t.identifier]=e(t))}),t}function n(){var e=ui.event.target;ui.select(e).on(b,r).on(_,l),w.push(e);for(var n=ui.event.changedTouches,a=0,o=n.length;a1){var u=s[0],f=s[1],d=u[0]-f[0],h=u[1]-f[1];v=d*d+h*h}}function r(){var t,e,n,r,i=ui.touches(p);Hs.call(p);for(var l=0,s=i.length;l=c)return i;if(a)return a=!1,o;var e=u;if(34===t.charCodeAt(e)){for(var n=e;n++=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,hl=ui.map({b:function(t){return t.toString(2)},c:function(t){return String.fromCharCode(t)},o:function(t){return t.toString(8)},x:function(t){return t.toString(16)},X:function(t){return t.toString(16).toUpperCase()},g:function(t,e){return t.toPrecision(e)},e:function(t,e){return t.toExponential(e)},f:function(t,e){return t.toFixed(e)},r:function(t,e){return(t=ui.round(t,Rt(t,e))).toFixed(Math.max(0,Math.min(20,Rt(t*(1+1e-15),e))))}}),pl=ui.time={},gl=Date;Bt.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){ml.setUTCDate.apply(this._,arguments)},setDay:function(){ml.setUTCDay.apply(this._,arguments)},setFullYear:function(){ml.setUTCFullYear.apply(this._,arguments)},setHours:function(){ml.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){ml.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){ml.setUTCMinutes.apply(this._,arguments)},setMonth:function(){ml.setUTCMonth.apply(this._,arguments)},setSeconds:function(){ml.setUTCSeconds.apply(this._,arguments)},setTime:function(){ml.setTime.apply(this._,arguments)}};var ml=Date.prototype;pl.year=Ht(function(t){return t=pl.day(t),t.setMonth(0,1),t},function(t,e){t.setFullYear(t.getFullYear()+e)},function(t){return t.getFullYear()}),pl.years=pl.year.range,pl.years.utc=pl.year.utc.range,pl.day=Ht(function(t){var e=new gl(2e3,0);return e.setFullYear(t.getFullYear(),t.getMonth(),t.getDate()),e},function(t,e){t.setDate(t.getDate()+e)},function(t){return t.getDate()-1}),pl.days=pl.day.range,pl.days.utc=pl.day.utc.range,pl.dayOfYear=function(t){var e=pl.year(t);return Math.floor((t-e-6e4*(t.getTimezoneOffset()-e.getTimezoneOffset()))/864e5)},["sunday","monday","tuesday","wednesday","thursday","friday","saturday"].forEach(function(t,e){e=7-e;var n=pl[t]=Ht(function(t){return(t=pl.day(t)).setDate(t.getDate()-(t.getDay()+e)%7),t},function(t,e){t.setDate(t.getDate()+7*Math.floor(e))},function(t){var n=pl.year(t).getDay();return Math.floor((pl.dayOfYear(t)+(n+e)%7)/7)-(n!==e)});pl[t+"s"]=n.range,pl[t+"s"].utc=n.utc.range,pl[t+"OfYear"]=function(t){var n=pl.year(t).getDay();return Math.floor((pl.dayOfYear(t)+(n+e)%7)/7)}}),pl.week=pl.sunday,pl.weeks=pl.sunday.range,pl.weeks.utc=pl.sunday.utc.range,pl.weekOfYear=pl.sundayOfYear;var vl={"-":"",_:" ",0:"0"},yl=/^\s*\d+/,xl=/^%/;ui.locale=function(t){return{numberFormat:Ft(t),timeFormat:Zt(t)}};var bl=ui.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});ui.format=bl.numberFormat,ui.geo={},fe.prototype={s:0,t:0,add:function(t){de(t,this.t,_l),de(_l.s,this.s,this),this.s?this.t+=_l.t:this.s=_l.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var _l=new fe;ui.geo.stream=function(t,e){t&&wl.hasOwnProperty(t.type)?wl[t.type](t,e):he(t,e)};var wl={Feature:function(t,e){he(t.geometry,e)},FeatureCollection:function(t,e){for(var n=t.features,r=-1,a=n.length;++rh&&(h=e)}function e(e,n){var r=ve([e*Vi,n*Vi]);if(v){var a=xe(v,r),o=[a[1],-a[0],0],i=xe(o,a);we(i),i=ke(i);var s=e-p,c=s>0?1:-1,g=i[0]*Zi*c,m=bi(s)>180;if(m^(c*ph&&(h=y)}else if(g=(g+360)%360-180,m^(c*ph&&(h=n);m?el(u,d)&&(d=e):l(e,d)>l(u,d)&&(u=e):d>=u?(ed&&(d=e)):e>p?l(u,e)>l(u,d)&&(d=e):l(e,d)>l(u,d)&&(u=e)}else t(e,n);v=r,p=e}function n(){_.point=e}function r(){b[0]=u,b[1]=d,_.point=t,v=null}function a(t,n){if(v){var r=t-p;y+=bi(r)>180?r+(r>0?360:-360):r}else g=t,m=n;Tl.point(t,n),e(t,n)}function o(){Tl.lineStart()}function i(){a(g,m),Tl.lineEnd(),bi(y)>Ri&&(u=-(d=180)),b[0]=u,b[1]=d,v=null}function l(t,e){return(e-=t)<0?e+360:e}function s(t,e){return t[0]-e[0]}function c(t,e){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:tRi?h=90:y<-Ri&&(f=-90),b[0]=u,b[1]=d}};return function(t){h=d=-(u=f=1/0),x=[],ui.geo.stream(t,_);var e=x.length;if(e){x.sort(s);for(var n,r=1,a=x[0],o=[a];rl(a[0],a[1])&&(a[1]=n[1]),l(n[0],a[1])>l(a[0],a[1])&&(a[0]=n[0])):o.push(a=n);for(var i,n,p=-(1/0),e=o.length-1,r=0,a=o[e];r<=e;a=n,++r)n=o[r],(i=l(a[1],n[0]))>p&&(p=i,u=n[0],d=a[1])}return x=b=null,u===1/0||f===1/0?[[NaN,NaN],[NaN,NaN]]:[[u,f],[d,h]]}}(),ui.geo.centroid=function(t){Ll=zl=Sl=Cl=El=Ol=Pl=Nl=Dl=Il=Rl=0,ui.geo.stream(t,jl);var e=Dl,n=Il,r=Rl,a=e*e+n*n+r*r;return a=.12&&a<.234&&r>=-.425&&r<-.214?i:a>=.166&&a<.234&&r>=-.214&&r<-.115?l:o).invert(t)},t.stream=function(t){var e=o.stream(t),n=i.stream(t),r=l.stream(t);return{point:function(t,a){e.point(t,a),n.point(t,a),r.point(t,a)},sphere:function(){e.sphere(),n.sphere(),r.sphere()},lineStart:function(){e.lineStart(),n.lineStart(),r.lineStart()},lineEnd:function(){e.lineEnd(),n.lineEnd(),r.lineEnd()},polygonStart:function(){e.polygonStart(),n.polygonStart(),r.polygonStart()},polygonEnd:function(){e.polygonEnd(),n.polygonEnd(),r.polygonEnd()}}},t.precision=function(e){return arguments.length?(o.precision(e),i.precision(e),l.precision(e),t):o.precision()},t.scale=function(e){return arguments.length?(o.scale(e),i.scale(.35*e),l.scale(e),t.translate(o.translate())):o.scale()},t.translate=function(e){if(!arguments.length)return o.translate();var c=o.scale(),u=+e[0],f=+e[1];return n=o.translate(e).clipExtent([[u-.455*c,f-.238*c],[u+.455*c,f+.238*c]]).stream(s).point,r=i.translate([u-.307*c,f+.201*c]).clipExtent([[u-.425*c+Ri,f+.12*c+Ri],[u-.214*c-Ri,f+.234*c-Ri]]).stream(s).point,a=l.translate([u-.205*c,f+.212*c]).clipExtent([[u-.214*c+Ri,f+.166*c+Ri],[u-.115*c-Ri,f+.234*c-Ri]]).stream(s).point,t},t.scale(1070)};var Bl,Hl,Vl,Zl,Ul,Yl,Xl={point:k,lineStart:k,lineEnd:k,polygonStart:function(){Hl=0,Xl.lineStart=Ge},polygonEnd:function(){Xl.lineStart=Xl.lineEnd=Xl.point=k,Bl+=bi(Hl/2)}},Gl={point:$e,lineStart:k,lineEnd:k,polygonStart:k,polygonEnd:k},$l={point:Je,lineStart:Ke,lineEnd:tn,polygonStart:function(){$l.lineStart=en},polygonEnd:function(){$l.point=Je,$l.lineStart=Ke,$l.lineEnd=tn}};ui.geo.path=function(){function t(t){return t&&("function"==typeof l&&o.pointRadius(+l.apply(this,arguments)),i&&i.valid||(i=a(o)),ui.geo.stream(t,i)),o.result()}function e(){return i=null,t}var n,r,a,o,i,l=4.5;return t.area=function(t){return Bl=0,ui.geo.stream(t,a(Xl)),Bl},t.centroid=function(t){return Sl=Cl=El=Ol=Pl=Nl=Dl=Il=Rl=0,ui.geo.stream(t,a($l)),Rl?[Dl/Rl,Il/Rl]:Nl?[Ol/Nl,Pl/Nl]:El?[Sl/El,Cl/El]:[NaN,NaN]},t.bounds=function(t){return Ul=Yl=-(Vl=Zl=1/0),ui.geo.stream(t,a(Gl)),[[Vl,Zl],[Ul,Yl]]},t.projection=function(t){return arguments.length?(a=(n=t)?t.stream||an(t):b,e()):n},t.context=function(t){return arguments.length?(o=null==(r=t)?new Qe:new nn(t),"function"!=typeof l&&o.pointRadius(l),e()):r},t.pointRadius=function(e){return arguments.length?(l="function"==typeof e?e:(o.pointRadius(+e),+e),t):l},t.projection(ui.geo.albersUsa()).context(null)},ui.geo.transform=function(t){return{stream:function(e){var n=new on(e);for(var r in t)n[r]=t[r];return n}}},on.prototype={point:function(t,e){this.stream.point(t,e)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}},ui.geo.projection=sn,ui.geo.projectionMutator=cn,(ui.geo.equirectangular=function(){return sn(fn)}).raw=fn.invert=fn,ui.geo.rotation=function(t){function e(e){return e=t(e[0]*Vi,e[1]*Vi),e[0]*=Zi,e[1]*=Zi,e}return t=hn(t[0]%360*Vi,t[1]*Vi,t.length>2?t[2]*Vi:0),e.invert=function(e){return e=t.invert(e[0]*Vi,e[1]*Vi),e[0]*=Zi,e[1]*=Zi,e},e},dn.invert=fn,ui.geo.circle=function(){function t(){var t="function"==typeof r?r.apply(this,arguments):r,e=hn(-t[0]*Vi,-t[1]*Vi,0).invert,a=[];return n(null,null,1,{point:function(t,n){a.push(t=e(t,n)),t[0]*=Zi,t[1]*=Zi}}),{type:"Polygon",coordinates:[a]}}var e,n,r=[0,0],a=6;return t.origin=function(e){return arguments.length?(r=e,t):r},t.angle=function(r){return arguments.length?(n=vn((e=+r)*Vi,a*Vi),t):e},t.precision=function(r){return arguments.length?(n=vn(e*Vi,(a=+r)*Vi),t):a},t.angle(90)},ui.geo.distance=function(t,e){var n,r=(e[0]-t[0])*Vi,a=t[1]*Vi,o=e[1]*Vi,i=Math.sin(r),l=Math.cos(r),s=Math.sin(a),c=Math.cos(a),u=Math.sin(o),f=Math.cos(o);return Math.atan2(Math.sqrt((n=f*i)*n+(n=c*u-s*f*l)*n),s*u+c*f*l)},ui.geo.graticule=function(){function t(){return{type:"MultiLineString",coordinates:e()}}function e(){return ui.range(Math.ceil(o/m)*m,a,m).map(d).concat(ui.range(Math.ceil(c/v)*v,s,v).map(h)).concat(ui.range(Math.ceil(r/p)*p,n,p).filter(function(t){return bi(t%m)>Ri}).map(u)).concat(ui.range(Math.ceil(l/g)*g,i,g).filter(function(t){return bi(t%v)>Ri}).map(f))}var n,r,a,o,i,l,s,c,u,f,d,h,p=10,g=p,m=90,v=360,y=2.5;return t.lines=function(){return e().map(function(t){return{type:"LineString",coordinates:t}})},t.outline=function(){return{type:"Polygon",coordinates:[d(o).concat(h(s).slice(1),d(a).reverse().slice(1),h(c).reverse().slice(1))]}},t.extent=function(e){return arguments.length?t.majorExtent(e).minorExtent(e):t.minorExtent()},t.majorExtent=function(e){return arguments.length?(o=+e[0][0],a=+e[1][0],c=+e[0][1],s=+e[1][1],o>a&&(e=o,o=a,a=e),c>s&&(e=c,c=s,s=e),t.precision(y)):[[o,c],[a,s]]},t.minorExtent=function(e){return arguments.length?(r=+e[0][0],n=+e[1][0],l=+e[0][1],i=+e[1][1],r>n&&(e=r,r=n,n=e),l>i&&(e=l,l=i,i=e),t.precision(y)):[[r,l],[n,i]]},t.step=function(e){return arguments.length?t.majorStep(e).minorStep(e):t.minorStep()},t.majorStep=function(e){return arguments.length?(m=+e[0],v=+e[1],t):[m,v]},t.minorStep=function(e){return arguments.length?(p=+e[0],g=+e[1],t):[p,g]},t.precision=function(e){return arguments.length?(y=+e,u=xn(l,i,90),f=bn(r,n,y),d=xn(c,s,90),h=bn(o,a,y),t):y},t.majorExtent([[-180,-90+Ri],[180,90-Ri]]).minorExtent([[-180,-80-Ri],[180,80+Ri]])},ui.geo.greatArc=function(){function t(){return{type:"LineString",coordinates:[e||r.apply(this,arguments),n||a.apply(this,arguments)]}}var e,n,r=_n,a=wn;return t.distance=function(){return ui.geo.distance(e||r.apply(this,arguments),n||a.apply(this,arguments))},t.source=function(n){return arguments.length?(r=n,e="function"==typeof n?null:n,t):r},t.target=function(e){return arguments.length?(a=e,n="function"==typeof e?null:e,t):a},t.precision=function(){return arguments.length?t:0},t},ui.geo.interpolate=function(t,e){return kn(t[0]*Vi,t[1]*Vi,e[0]*Vi,e[1]*Vi)},ui.geo.length=function(t){return Ql=0,ui.geo.stream(t,Wl),Ql};var Ql,Wl={sphere:k,point:k,lineStart:Mn,lineEnd:k,polygonStart:k,polygonEnd:k},Jl=An(function(t){return Math.sqrt(2/(1+t))},function(t){return 2*Math.asin(t/2)});(ui.geo.azimuthalEqualArea=function(){return sn(Jl)}).raw=Jl;var Kl=An(function(t){var e=Math.acos(t);return e&&e/Math.sin(e)},b);(ui.geo.azimuthalEquidistant=function(){return sn(Kl)}).raw=Kl,(ui.geo.conicConformal=function(){return Ye(Tn)}).raw=Tn,(ui.geo.conicEquidistant=function(){return Ye(Ln)}).raw=Ln;var ts=An(function(t){return 1/t},Math.atan);(ui.geo.gnomonic=function(){return sn(ts)}).raw=ts,zn.invert=function(t,e){return[t,2*Math.atan(Math.exp(e))-Hi]},(ui.geo.mercator=function(){return Sn(zn)}).raw=zn;var es=An(function(){return 1},Math.asin);(ui.geo.orthographic=function(){return sn(es)}).raw=es;var ns=An(function(t){return 1/(1+t)},function(t){return 2*Math.atan(t)});(ui.geo.stereographic=function(){return sn(ns)}).raw=ns,Cn.invert=function(t,e){return[-e,2*Math.atan(Math.exp(t))-Hi]},(ui.geo.transverseMercator=function(){var t=Sn(Cn),e=t.center,n=t.rotate;return t.center=function(t){return t?e([-t[1],t[0]]):(t=e(),[t[1],-t[0]])},t.rotate=function(t){return t?n([t[0],t[1],t.length>2?t[2]+90:90]):(t=n(),[t[0],t[1],t[2]-90])},n([0,0,90])}).raw=Cn,ui.geom={},ui.geom.hull=function(t){function e(t){if(t.length<3)return[];var e,a=zt(n),o=zt(r),i=t.length,l=[],s=[];for(e=0;e=0;--e)h.push(t[l[c[e]][2]]);for(e=+f;e=r&&c.x<=o&&c.y>=a&&c.y<=i?[[r,i],[o,i],[o,a],[r,a]]:[];u.point=t[l]}),e}function n(t){return t.map(function(t,e){return{x:Math.round(o(t,e)/Ri)*Ri,y:Math.round(i(t,e)/Ri)*Ri,i:e}})}var r=En,a=On,o=r,i=a,l=fs;return t?e(t):(e.links=function(t){return cr(n(t)).edges.filter(function(t){return t.l&&t.r}).map(function(e){return{source:t[e.l.i],target:t[e.r.i]}})},e.triangles=function(t){var e=[];return cr(n(t)).cells.forEach(function(n,r){for(var a,o,i=n.site,l=n.edges.sort(Xn),s=-1,c=l.length,u=l[c-1].edge,f=u.l===i?u.r:u.l;++s=c,d=r>=u,h=d<<1|f;t.leaf=!1,t=t.nodes[h]||(t.nodes[h]=pr()),f?a=c:l=c,d?i=u:s=u,o(t,e,n,r,a,i,l,s)}var u,f,d,h,p,g,m,v,y,x=zt(l),b=zt(s);if(null!=e)g=e,m=n,v=r,y=a;else if(v=y=-(g=m=1/0),f=[],d=[],p=t.length,i)for(h=0;hv&&(v=u.x),u.y>y&&(y=u.y),f.push(u.x),d.push(u.y);else for(h=0;hv&&(v=_),w>y&&(y=w),f.push(_),d.push(w)}var k=v-g,M=y-m;k>M?y=m+k:v=g+M;var A=pr();if(A.add=function(t){o(A,t,+x(t,++h),+b(t,h),g,m,v,y)},A.visit=function(t){gr(t,A,g,m,v,y)},A.find=function(t){return mr(A,t[0],t[1],g,m,v,y)},h=-1,null==e){for(;++h=0?t.slice(0,e):t,r=e>=0?t.slice(e+1):"in";return n=gs.get(n)||ps,r=ms.get(r)||b,kr(r(n.apply(null,fi.call(arguments,1))))},ui.interpolateHcl=Ir,ui.interpolateHsl=Rr,ui.interpolateLab=jr,ui.interpolateRound=Fr,ui.transform=function(t){var e=hi.createElementNS(ui.ns.prefix.svg,"g");return(ui.transform=function(t){if(null!=t){e.setAttribute("transform",t);var n=e.transform.baseVal.consolidate()}return new qr(n?n.matrix:vs)})(t)},qr.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var vs={ ++a:1,b:0,c:0,d:1,e:0,f:0};ui.interpolateTransform=$r,ui.layout={},ui.layout.bundle=function(){return function(t){for(var e=[],n=-1,r=t.length;++n0?a=t:(n.c=null,n.t=NaN,n=null,c.end({type:"end",alpha:a=0})):t>0&&(c.start({type:"start",alpha:a=t}),n=Pt(s.tick)),s):a},s.start=function(){function t(t,r){if(!n){for(n=new Array(a),s=0;s=0;)i.push(u=c[s]),u.parent=o,u.depth=o.depth+1;r&&(o.value=0),o.children=c}else r&&(o.value=+r.call(t,o,o.depth)||0),delete o.children;return sa(a,function(t){var n,a;e&&(n=t.children)&&n.sort(e),r&&(a=t.parent)&&(a.value+=t.value)}),l}var e=fa,n=ca,r=ua;return t.sort=function(n){return arguments.length?(e=n,t):e},t.children=function(e){return arguments.length?(n=e,t):n},t.value=function(e){return arguments.length?(r=e,t):r},t.revalue=function(e){return r&&(la(e,function(t){t.children&&(t.value=0)}),sa(e,function(e){var n;e.children||(e.value=+r.call(t,e,e.depth)||0),(n=e.parent)&&(n.value+=e.value)})),e},t},ui.layout.partition=function(){function t(e,n,r,a){var o=e.children;if(e.x=n,e.y=e.depth*a,e.dx=r,e.dy=a,o&&(i=o.length)){var i,l,s,c=-1;for(r=e.value?r/e.value:0;++cl&&(l=r),i.push(r)}for(n=0;n0)for(o=-1;++o=u[0]&&l<=u[1]&&(i=s[ui.bisect(f,l,1,h)-1],i.y+=p,i.push(t[o]));return s}var e=!0,n=Number,r=ka,a=_a;return t.value=function(e){return arguments.length?(n=e,t):n},t.range=function(e){return arguments.length?(r=zt(e),t):r},t.bins=function(e){return arguments.length?(a="number"==typeof e?function(t){return wa(t,e)}:zt(e),t):a},t.frequency=function(n){return arguments.length?(e=!!n,t):e},t},ui.layout.pack=function(){function t(t,o){var i=n.call(this,t,o),l=i[0],s=a[0],c=a[1],u=null==e?Math.sqrt:"function"==typeof e?e:function(){return e};if(l.x=l.y=0,sa(l,function(t){t.r=+u(t.value)}),sa(l,za),r){var f=r*(e?1:Math.max(2*l.r/s,2*l.r/c))/2;sa(l,function(t){t.r+=f}),sa(l,za),sa(l,function(t){t.r-=f})}return Ea(l,s/2,c/2,e?1:1/Math.max(2*l.r/s,2*l.r/c)),i}var e,n=ui.layout.hierarchy().sort(Ma),r=0,a=[1,1];return t.size=function(e){return arguments.length?(a=e,t):a},t.radius=function(n){return arguments.length?(e=null==n||"function"==typeof n?n:+n,t):e},t.padding=function(e){return arguments.length?(r=+e,t):r},ia(t,n)},ui.layout.tree=function(){function t(t,a){var u=i.call(this,t,a),f=u[0],d=e(f);if(sa(d,n),d.parent.m=-d.z,la(d,r),c)la(f,o);else{var h=f,p=f,g=f;la(f,function(t){t.xp.x&&(p=t),t.depth>g.depth&&(g=t)});var m=l(h,p)/2-h.x,v=s[0]/(p.x+l(p,h)/2+m),y=s[1]/(g.depth||1);la(f,function(t){t.x=(t.x+m)*v,t.y=t.depth*y})}return u}function e(t){for(var e,n={A:null,children:[t]},r=[n];null!=(e=r.pop());)for(var a,o=e.children,i=0,l=o.length;i0&&(Ia(ja(i,t,n),t,r),c+=r,u+=r),f+=i.m,c+=a.m,d+=s.m,u+=o.m;i&&!Da(o)&&(o.t=i,o.m+=f-u),a&&!Na(s)&&(s.t=a,s.m+=c-d,n=t)}return n}function o(t){t.x*=s[0],t.y=t.depth*s[1]}var i=ui.layout.hierarchy().sort(null).value(null),l=Pa,s=[1,1],c=null;return t.separation=function(e){return arguments.length?(l=e,t):l},t.size=function(e){return arguments.length?(c=null==(s=e)?o:null,t):c?null:s},t.nodeSize=function(e){return arguments.length?(c=null==(s=e)?null:o,t):c?s:null},ia(t,i)},ui.layout.cluster=function(){function t(t,o){var i,l=e.call(this,t,o),s=l[0],c=0;sa(s,function(t){var e=t.children;e&&e.length?(t.x=qa(e),t.y=Fa(e)):(t.x=i?c+=n(t,i):0,t.y=0,i=t)});var u=Ba(s),f=Ha(s),d=u.x-n(u,f)/2,h=f.x+n(f,u)/2;return sa(s,a?function(t){t.x=(t.x-s.x)*r[0],t.y=(s.y-t.y)*r[1]}:function(t){t.x=(t.x-d)/(h-d)*r[0],t.y=(1-(s.y?t.y/s.y:1))*r[1]}),l}var e=ui.layout.hierarchy().sort(null).value(null),n=Pa,r=[1,1],a=!1;return t.separation=function(e){return arguments.length?(n=e,t):n},t.size=function(e){return arguments.length?(a=null==(r=e),t):a?null:r},t.nodeSize=function(e){return arguments.length?(a=null!=(r=e),t):a?r:null},ia(t,e)},ui.layout.treemap=function(){function t(t,e){for(var n,r,a=-1,o=t.length;++a0;)u.push(i=d[s-1]),u.area+=i.area,"squarify"!==h||(l=r(u,g))<=p?(d.pop(),p=l):(u.area-=u.pop().area,a(u,g,c,!1),g=Math.min(c.dx,c.dy),u.length=u.area=0,p=1/0);u.length&&(a(u,g,c,!0),u.length=u.area=0),o.forEach(e)}}function n(e){var r=e.children;if(r&&r.length){var o,i=f(e),l=r.slice(),s=[];for(t(l,i.dx*i.dy/e.value),s.area=0;o=l.pop();)s.push(o),s.area+=o.area,null!=o.z&&(a(s,o.z?i.dx:i.dy,i,!l.length),s.length=s.area=0);r.forEach(n)}}function r(t,e){for(var n,r=t.area,a=0,o=1/0,i=-1,l=t.length;++ia&&(a=n));return r*=r,e*=e,r?Math.max(e*a*p/r,r/(e*o*p)):1/0}function a(t,e,n,r){var a,o=-1,i=t.length,l=n.x,c=n.y,u=e?s(t.area/e):0;if(e==n.dx){for((r||u>n.dy)&&(u=n.dy);++on.dx)&&(u=n.dx);++o1);return t+e*n*Math.sqrt(-2*Math.log(a)/a)}},logNormal:function(){var t=ui.random.normal.apply(ui,arguments);return function(){return Math.exp(t())}},bates:function(t){var e=ui.random.irwinHall(t);return function(){return e()/t}},irwinHall:function(t){return function(){for(var e=0,n=0;nf?0:1;if(c=Bi)return e(c,h)+(t?e(t,1-h):"")+"Z";var p,g,m,v,y,x,b,_,w,k,M,A,T=0,L=0,z=[];if((v=(+s.apply(this,arguments)||0)/2)&&(m=o===Os?Math.sqrt(t*t+c*c):+o.apply(this,arguments),h||(L*=-1),c&&(L=rt(m/c*Math.sin(v))),t&&(T=rt(m/t*Math.sin(v)))),c){y=c*Math.cos(u+L),x=c*Math.sin(u+L),b=c*Math.cos(f-L),_=c*Math.sin(f-L);var S=Math.abs(f-u-2*L)<=Fi?0:1;if(L&&bo(y,x,b,_)===h^S){var C=(u+f)/2;y=c*Math.cos(C),x=c*Math.sin(C),b=_=null}}else y=x=0;if(t){w=t*Math.cos(f-T),k=t*Math.sin(f-T),M=t*Math.cos(u+T),A=t*Math.sin(u+T);var E=Math.abs(u-f+2*T)<=Fi?0:1;if(T&&bo(w,k,M,A)===1-h^E){var O=(u+f)/2;w=t*Math.cos(O),k=t*Math.sin(O),M=A=null}}else w=k=0;if(d>Ri&&(p=Math.min(Math.abs(c-t)/2,+a.apply(this,arguments)))>.001){g=tFi)+",1 "+e}function a(t,e,n,r){return"Q 0,0 "+r}var o=_n,i=wn,l=Uo,s=vo,c=yo;return t.radius=function(e){return arguments.length?(l=zt(e),t):l},t.source=function(e){return arguments.length?(o=zt(e),t):o},t.target=function(e){return arguments.length?(i=zt(e),t):i},t.startAngle=function(e){return arguments.length?(s=zt(e),t):s},t.endAngle=function(e){return arguments.length?(c=zt(e),t):c},t},ui.svg.diagonal=function(){function t(t,a){var o=e.call(this,t,a),i=n.call(this,t,a),l=(o.y+i.y)/2,s=[o,{x:o.x,y:l},{x:i.x,y:l},i];return s=s.map(r),"M"+s[0]+"C"+s[1]+" "+s[2]+" "+s[3]}var e=_n,n=wn,r=Yo;return t.source=function(n){return arguments.length?(e=zt(n),t):e},t.target=function(e){return arguments.length?(n=zt(e),t):n},t.projection=function(e){return arguments.length?(r=e,t):r},t},ui.svg.diagonal.radial=function(){var t=ui.svg.diagonal(),e=Yo,n=t.projection;return t.projection=function(t){return arguments.length?n(Xo(e=t)):e},t},ui.svg.symbol=function(){function t(t,r){return(Rs.get(e.call(this,t,r))||Qo)(n.call(this,t,r))}var e=$o,n=Go;return t.type=function(n){return arguments.length?(e=zt(n),t):e},t.size=function(e){return arguments.length?(n=zt(e),t):n},t};var Rs=ui.map({circle:Qo,cross:function(t){var e=Math.sqrt(t/5)/2;return"M"+-3*e+","+-e+"H"+-e+"V"+-3*e+"H"+e+"V"+-e+"H"+3*e+"V"+e+"H"+e+"V"+3*e+"H"+-e+"V"+e+"H"+-3*e+"Z"},diamond:function(t){var e=Math.sqrt(t/(2*Fs)),n=e*Fs;return"M0,"+-e+"L"+n+",0 0,"+e+" "+-n+",0Z"},square:function(t){var e=Math.sqrt(t)/2;return"M"+-e+","+-e+"L"+e+","+-e+" "+e+","+e+" "+-e+","+e+"Z"},"triangle-down":function(t){var e=Math.sqrt(t/js),n=e*js/2;return"M0,"+n+"L"+e+","+-n+" "+-e+","+-n+"Z"},"triangle-up":function(t){var e=Math.sqrt(t/js),n=e*js/2;return"M0,"+-n+"L"+e+","+n+" "+-e+","+n+"Z"}});ui.svg.symbolTypes=Rs.keys();var js=Math.sqrt(3),Fs=Math.tan(30*Vi);Si.transition=function(t){for(var e,n,r=qs||++Zs,a=ei(t),o=[],i=Bs||{time:Date.now(),ease:zr,delay:0,duration:250},l=-1,s=this.length;++lrect,.s>rect").attr("width",f[1]-f[0])}function a(t){t.select(".extent").attr("y",d[0]),t.selectAll(".extent,.e>rect,.w>rect").attr("height",d[1]-d[0])}function o(){function o(){32==ui.event.keyCode&&(S||(x=null,E[0]-=f[1],E[1]-=d[1],S=2),T())}function g(){32==ui.event.keyCode&&2==S&&(E[0]+=f[1],E[1]+=d[1],S=0,T())}function m(){var t=ui.mouse(_),r=!1;b&&(t[0]+=b[0],t[1]+=b[1]),S||(ui.event.altKey?(x||(x=[(f[0]+f[1])/2,(d[0]+d[1])/2]),E[0]=f[+(t[0]0&&this._events[t].length>n&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(t,e){function n(){this.removeListener(t,n),r||(r=!0,e.apply(this,arguments))}if(!a(e))throw TypeError("listener must be a function");var r=!1;return n.listener=e,this.on(t,n),this},r.prototype.removeListener=function(t,e){var n,r,o,l;if(!a(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(n=this._events[t],o=n.length,r=-1,n===e||a(n.listener)&&n.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(i(n)){for(l=o;l-- >0;)if(n[l]===e||n[l].listener&&n[l].listener===e){r=l;break}if(r<0)return this;1===n.length?(n.length=0,delete this._events[t]):n.splice(r,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},r.prototype.removeAllListeners=function(t){var e,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[t],a(n))this.removeListener(t,n);else if(n)for(;n.length;)this.removeListener(t,n[n.length-1]);return delete this._events[t],this},r.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?a(this._events[t])?[this._events[t]]:this._events[t].slice():[]},r.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(a(e))return 1;if(e)return e.length}return 0},r.listenerCount=function(t,e){return t.listenerCount(e)}},{}],17:[function(t,e,n){"use strict";function r(t){for(var e,n=t.length,r=0;r13)&&32!==e&&133!==e&&160!==e&&5760!==e&&6158!==e&&(e<8192||e>8205)&&8232!==e&&8233!==e&&8239!==e&&8287!==e&&8288!==e&&12288!==e&&65279!==e)return!1;return!0}e.exports=function(t){var e=typeof t;if("string"===e){var n=t;if(t=+t,0===t&&r(n))return!1}else if("number"!==e)return!1;return t-t<1}},{}],18:[function(t,e,n){function r(t,e){var n=e[0],r=e[1],a=e[2],o=e[3],i=n+n,l=r+r,s=a+a,c=n*i,u=r*i,f=r*l,d=a*i,h=a*l,p=a*s,g=o*i,m=o*l,v=o*s;return t[0]=1-f-p,t[1]=u+v,t[2]=d-m,t[3]=0,t[4]=u-v,t[5]=1-c-p,t[6]=h+g,t[7]=0,t[8]=d+m,t[9]=h-g,t[10]=1-c-f,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}e.exports=r},{}],19:[function(t,e,n){function r(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function o(t){if(f===setTimeout)return setTimeout(t,0);if((f===r||!f)&&setTimeout)return f=setTimeout,setTimeout(t,0);try{return f(t,0)}catch(e){try{return f.call(null,t,0)}catch(e){return f.call(this,t,0)}}}function i(t){if(d===clearTimeout)return clearTimeout(t);if((d===a||!d)&&clearTimeout)return d=clearTimeout,clearTimeout(t);try{return d(t)}catch(e){try{return d.call(null,t)}catch(e){return d.call(this,t)}}}function l(){m&&p&&(m=!1,p.length?g=p.concat(g):v=-1,g.length&&s())}function s(){if(!m){var t=o(l);m=!0;for(var e=g.length;e;){for(p=g,g=[];++v1)for(var n=1;n.5?s/(2-o-i):s/(o+i),o){case t:r=(e-n)/s+(e1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+(e-t)*(2/3-n)*6:t}var a,o,i;if(t=z(t,360),e=z(e,100),n=z(n,100),0===e)a=o=i=n;else{var l=n<.5?n*(1+e):n+e-n*e,s=2*n-l;a=r(s,l,t+1/3),o=r(s,l,t),i=r(s,l,t-1/3)}return{r:255*a,g:255*o,b:255*i}}function s(t,e,n){t=z(t,255),e=z(e,255),n=z(n,255);var r,a,o=U(t,e,n),i=Z(t,e,n),l=o,s=o-i;if(a=0===o?0:s/o,o==i)r=0;else{switch(o){case t:r=(e-n)/s+(e>1)+720)%360;--e;)a.h=(a.h+o)%360,i.push(r(a));return i}function A(t,e){e=e||6;for(var n=r(t).toHsv(),a=n.h,o=n.s,i=n.v,l=[],s=1/e;e--;)l.push(r({h:a,s:o,v:i})),i=(i+s)%1;return l}function T(t){var e={};for(var n in t)t.hasOwnProperty(n)&&(e[t[n]]=n);return e}function L(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function z(t,n){E(t)&&(t="100%");var r=O(t);return t=Z(n,U(0,parseFloat(t))),r&&(t=parseInt(t*n,10)/100),e.abs(t-n)<1e-6?1:t%n/parseFloat(n)}function S(t){return Z(1,U(0,t))}function C(t){return parseInt(t,16)}function E(t){return"string"==typeof t&&t.indexOf(".")!=-1&&1===parseFloat(t)}function O(t){return"string"==typeof t&&t.indexOf("%")!=-1}function P(t){return 1==t.length?"0"+t:""+t}function N(t){return t<=1&&(t=100*t+"%"),t}function D(t){return e.round(255*parseFloat(t)).toString(16)}function I(t){return C(t)/255}function R(t){return!!$.CSS_UNIT.exec(t)}function j(t){t=t.replace(q,"").replace(B,"").toLowerCase();var e=!1;if(X[t])t=X[t],e=!0;else if("transparent"==t)return{r:0,g:0,b:0,a:0,format:"name"};var n;return(n=$.rgb.exec(t))?{r:n[1],g:n[2],b:n[3]}:(n=$.rgba.exec(t))?{r:n[1],g:n[2],b:n[3],a:n[4]}:(n=$.hsl.exec(t))?{h:n[1],s:n[2],l:n[3]}:(n=$.hsla.exec(t))?{h:n[1],s:n[2],l:n[3],a:n[4]}:(n=$.hsv.exec(t))?{h:n[1],s:n[2],v:n[3]}:(n=$.hsva.exec(t))?{h:n[1],s:n[2],v:n[3],a:n[4]}:(n=$.hex8.exec(t))?{r:C(n[1]),g:C(n[2]),b:C(n[3]),a:I(n[4]),format:e?"name":"hex8"}:(n=$.hex6.exec(t))?{r:C(n[1]),g:C(n[2]),b:C(n[3]),format:e?"name":"hex"}:(n=$.hex4.exec(t))?{r:C(n[1]+""+n[1]),g:C(n[2]+""+n[2]),b:C(n[3]+""+n[3]),a:I(n[4]+""+n[4]),format:e?"name":"hex8"}:!!(n=$.hex3.exec(t))&&{r:C(n[1]+""+n[1]),g:C(n[2]+""+n[2]),b:C(n[3]+""+n[3]),format:e?"name":"hex"}}function F(t){var e,n;return t=t||{level:"AA",size:"small"},e=(t.level||"AA").toUpperCase(),n=(t.size||"small").toLowerCase(),"AA"!==e&&"AAA"!==e&&(e="AA"),"small"!==n&&"large"!==n&&(n="small"),{level:e,size:n}}var q=/^\s+/,B=/\s+$/,H=0,V=e.round,Z=e.min,U=e.max,Y=e.random;r.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var t,n,r,a,o,i,l=this.toRgb();return t=l.r/255,n=l.g/255,r=l.b/255,a=t<=.03928?t/12.92:e.pow((t+.055)/1.055,2.4),o=n<=.03928?n/12.92:e.pow((n+.055)/1.055,2.4),i=r<=.03928?r/12.92:e.pow((r+.055)/1.055,2.4),.2126*a+.7152*o+.0722*i},setAlpha:function(t){return this._a=L(t),this._roundA=V(100*this._a)/100,this},toHsv:function(){var t=s(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=s(this._r,this._g,this._b),e=V(360*t.h),n=V(100*t.s),r=V(100*t.v);return 1==this._a?"hsv("+e+", "+n+"%, "+r+"%)":"hsva("+e+", "+n+"%, "+r+"%, "+this._roundA+")"},toHsl:function(){var t=i(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=i(this._r,this._g,this._b),e=V(360*t.h),n=V(100*t.s),r=V(100*t.l);return 1==this._a?"hsl("+e+", "+n+"%, "+r+"%)":"hsla("+e+", "+n+"%, "+r+"%, "+this._roundA+")"},toHex:function(t){return u(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return f(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:V(this._r),g:V(this._g),b:V(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+V(this._r)+", "+V(this._g)+", "+V(this._b)+")":"rgba("+V(this._r)+", "+V(this._g)+", "+V(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:V(100*z(this._r,255))+"%",g:V(100*z(this._g,255))+"%",b:V(100*z(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+V(100*z(this._r,255))+"%, "+V(100*z(this._g,255))+"%, "+V(100*z(this._b,255))+"%)":"rgba("+V(100*z(this._r,255))+"%, "+V(100*z(this._g,255))+"%, "+V(100*z(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(G[u(this._r,this._g,this._b,!0)]||!1)},toFilter:function(t){var e="#"+d(this._r,this._g,this._b,this._a),n=e,a=this._gradientType?"GradientType = 1, ":"";if(t){var o=r(t);n="#"+d(o._r,o._g,o._b,o._a)}return"progid:DXImageTransform.Microsoft.gradient("+a+"startColorstr="+e+",endColorstr="+n+")"},toString:function(t){var e=!!t;t=t||this._format;var n=!1,r=this._a<1&&this._a>=0,a=!e&&r&&("hex"===t||"hex6"===t||"hex3"===t||"hex4"===t||"hex8"===t||"name"===t);return a?"name"===t&&0===this._a?this.toName():this.toRgbString():("rgb"===t&&(n=this.toRgbString()),"prgb"===t&&(n=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(n=this.toHexString()),"hex3"===t&&(n=this.toHexString(!0)),"hex4"===t&&(n=this.toHex8String(!0)),"hex8"===t&&(n=this.toHex8String()),"name"===t&&(n=this.toName()),"hsl"===t&&(n=this.toHslString()),"hsv"===t&&(n=this.toHsvString()),n||this.toHexString())},clone:function(){return r(this.toString())},_applyModification:function(t,e){var n=t.apply(null,[this].concat([].slice.call(e)));return this._r=n._r,this._g=n._g,this._b=n._b,this.setAlpha(n._a),this},lighten:function(){return this._applyModification(m,arguments)},brighten:function(){return this._applyModification(v,arguments)},darken:function(){return this._applyModification(y,arguments)},desaturate:function(){return this._applyModification(h,arguments)},saturate:function(){return this._applyModification(p,arguments)},greyscale:function(){return this._applyModification(g,arguments)},spin:function(){return this._applyModification(x,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(M,arguments)},complement:function(){return this._applyCombination(b,arguments)},monochromatic:function(){return this._applyCombination(A,arguments)},splitcomplement:function(){return this._applyCombination(k,arguments)},triad:function(){return this._applyCombination(_,arguments)},tetrad:function(){return this._applyCombination(w,arguments)}},r.fromRatio=function(t,e){if("object"==typeof t){var n={};for(var a in t)t.hasOwnProperty(a)&&("a"===a?n[a]=t[a]:n[a]=N(t[a]));t=n}return r(t,e)},r.equals=function(t,e){return!(!t||!e)&&r(t).toRgbString()==r(e).toRgbString()},r.random=function(){return r.fromRatio({r:Y(),g:Y(),b:Y()})},r.mix=function(t,e,n){n=0===n?0:n||50;var a=r(t).toRgb(),o=r(e).toRgb(),i=n/100,l={r:(o.r-a.r)*i+a.r,g:(o.g-a.g)*i+a.g,b:(o.b-a.b)*i+a.b,a:(o.a-a.a)*i+a.a};return r(l)},r.readability=function(t,n){var a=r(t),o=r(n);return(e.max(a.getLuminance(),o.getLuminance())+.05)/(e.min(a.getLuminance(),o.getLuminance())+.05)},r.isReadable=function(t,e,n){var a,o,i=r.readability(t,e);switch(o=!1,a=F(n),a.level+a.size){case"AAsmall":case"AAAlarge":o=i>=4.5;break;case"AAlarge":o=i>=3;break;case"AAAsmall":o=i>=7}return o},r.mostReadable=function(t,e,n){var a,o,i,l,s=null,c=0;n=n||{},o=n.includeFallbackColors,i=n.level,l=n.size;for(var u=0;uc&&(c=a,s=r(e[u]));return r.isReadable(t,s,{level:i,size:l})||!o?s:(n.includeFallbackColors=!1,r.mostReadable(t,["#fff","#000"],n))};var X=r.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},G=r.hexNames=T(X),$=function(){var t="[-\\+]?\\d+%?",e="[-\\+]?\\d*\\.\\d+%?",n="(?:"+e+")|(?:"+t+")",r="[\\s|\\(]+("+n+")[,|\\s]+("+n+")[,|\\s]+("+n+")\\s*\\)?",a="[\\s|\\(]+("+n+")[,|\\s]+("+n+")[,|\\s]+("+n+")[,|\\s]+("+n+")\\s*\\)?";return{CSS_UNIT:new RegExp(n),rgb:new RegExp("rgb"+r),rgba:new RegExp("rgba"+a),hsl:new RegExp("hsl"+r),hsla:new RegExp("hsla"+a),hsv:new RegExp("hsv"+r),hsva:new RegExp("hsva"+a),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();"undefined"!=typeof n&&n.exports?n.exports=r:"function"==typeof t&&t.amd?t(function(){return r}):window.tinycolor=r}(Math)},{}],21:[function(t,e,n){"use strict";e.exports=["",{path:"M-2.4,-3V3L0.6,0Z",backoff:.6},{path:"M-3.7,-2.5V2.5L1.3,0Z",backoff:1.3},{path:"M-4.45,-3L-1.65,-0.2V0.2L-4.45,3L1.55,0Z",backoff:1.55},{path:"M-2.2,-2.2L-0.2,-0.2V0.2L-2.2,2.2L-1.4,3L1.6,0L-1.4,-3Z", ++backoff:1.6},{path:"M-4.4,-2.1L-0.6,-0.2V0.2L-4.4,2.1L-4,3L2,0L-4,-3Z",backoff:2},{path:"M2,0A2,2 0 1,1 0,-2A2,2 0 0,1 2,0Z",backoff:0},{path:"M2,2V-2H-2V2Z",backoff:0}]},{}],22:[function(t,e,n){"use strict";var r=t("./arrow_paths"),a=t("../../plots/font_attributes"),o=t("../../plots/cartesian/constants"),i=t("../../lib/extend").extendFlat;e.exports={_isLinkedToArray:!0,text:{valType:"string"},textangle:{valType:"angle",dflt:0},font:i({},a,{}),opacity:{valType:"number",min:0,max:1,dflt:1},align:{valType:"enumerated",values:["left","center","right"],dflt:"center"},bgcolor:{valType:"color",dflt:"rgba(0,0,0,0)"},bordercolor:{valType:"color",dflt:"rgba(0,0,0,0)"},borderpad:{valType:"number",min:0,dflt:1},borderwidth:{valType:"number",min:0,dflt:1},showarrow:{valType:"boolean",dflt:!0},arrowcolor:{valType:"color"},arrowhead:{valType:"integer",min:0,max:r.length,dflt:1},arrowsize:{valType:"number",min:.3,dflt:1},arrowwidth:{valType:"number",min:.1},ax:{valType:"number",dflt:-10},ay:{valType:"number",dflt:-30},axref:{valType:"enumerated",dflt:"pixel",values:["pixel",o.idRegex.x.toString()]},ayref:{valType:"enumerated",dflt:"pixel",values:["pixel",o.idRegex.y.toString()]},xref:{valType:"enumerated",values:["paper",o.idRegex.x.toString()]},x:{valType:"number"},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"auto"},yref:{valType:"enumerated",values:["paper",o.idRegex.y.toString()]},y:{valType:"number"},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto"},_deprecated:{ref:{valType:"string"}}}},{"../../lib/extend":100,"../../plots/cartesian/constants":128,"../../plots/font_attributes":141,"./arrow_paths":21}],23:[function(t,e,n){"use strict";function r(t,e){function n(e,n){return c.coerce(t,r,m.layoutAttributes,e,n)}var r={};n("opacity"),n("align"),n("bgcolor");var a=n("bordercolor"),o=f.opacity(a);n("borderpad");var i=n("borderwidth"),l=n("showarrow");l&&(n("arrowcolor",o?r.bordercolor:f.defaultLine),n("arrowhead"),n("arrowsize"),n("arrowwidth",2*(o&&i||1)),n("ax"),n("ay"),n("axref"),n("ayref"),c.noneOrAll(t,r,["ax","ay"])),n("text",l?" ":"new text"),n("textangle"),c.coerceFont(n,"font",e.font);for(var s=["x","y"],d=0;d<2;d++){var h=s[d],p={_fullLayout:e},g=u.coerceRef(t,r,p,h),v=u.coerceARef(t,r,p,h),y=.5;if("paper"!==g){var x=u.getFromId(p,g);if(y=x.range[0]+y*(x.range[1]-x.range[0]),["date","category"].indexOf(x.type)!==-1&&"string"==typeof t[h]){var b;if("date"===x.type){if(b=c.dateTime2ms(t[h]),b!==!1&&(t[h]=b),v===g){var _=c.dateTime2ms(t["a"+h]);_!==!1&&(t["a"+h]=_)}}else(x._categories||[]).length&&(b=x._categories.indexOf(t[h]),b!==-1&&(t[h]=b))}}n(h,y),l||n(h+"anchor")}return c.noneOrAll(t,r,["x","y"]),r}function a(t){var e=t._fullLayout;e.annotations.forEach(function(e){var n=u.getFromId(t,e.xref),r=u.getFromId(t,e.yref);if(n||r){var a=(e._xsize||0)/2,o=e._xshift||0,i=(e._ysize||0)/2,l=e._yshift||0,s=a-o,c=a+o,f=i-l,d=i+l;if(e.showarrow){var h=3*e.arrowsize*e.arrowwidth;s=Math.max(s,h),c=Math.max(c,h),f=Math.max(f,h),d=Math.max(d,h)}n&&n.autorange&&u.expand(n,[n.l2c(e.x)],{ppadplus:c,ppadminus:s}),r&&r.autorange&&u.expand(r,[r.l2c(e.y)],{ppadplus:d,ppadminus:f})}})}function o(t,e,n,r,a,o,i,l){var s=n-t,c=a-t,u=i-a,f=r-e,d=o-e,h=l-o,p=s*h-u*f;if(0===p)return null;var g=(c*h-u*d)/p,m=(c*f-s*d)/p;return m<0||m>1||g<0||g>1?null:{x:t+s*g,y:e+f*g}}var i=t("d3"),l=t("fast-isnumeric"),s=t("../../plotly"),c=t("../../lib"),u=t("../../plots/cartesian/axes"),f=t("../color"),d=t("../drawing"),h=t("../../lib/svg_text_utils"),p=t("../../lib/setcursor"),g=t("../dragelement"),m=e.exports={};m.ARROWPATHS=t("./arrow_paths"),m.layoutAttributes=t("./attributes"),m.supplyLayoutDefaults=function(t,e){for(var n=t.annotations||[],a=e.annotations=[],o=0;o2/3?"right":"center"),{center:0,middle:0,left:.5,bottom:-.5,right:-.5,top:.5}[e]}tt.selectAll("tspan.line").attr({y:0,x:0});var r=G.select(".annotation-math-group"),a=!r.empty(),l=d.bBox((a?r:tt).node()),h=l.width,v=l.height,y=Math.round(h+2*W),x=Math.round(v+2*W);B._w=h,B._h=v;var b=!1;if(["x","y"].forEach(function(e){var r,a=B[e+"ref"]||e,o=u.getFromId(t,a),i=(U+("x"===e?0:90))*Math.PI/180,l=y*Math.abs(Math.cos(i))+x*Math.abs(Math.sin(i)),s=B[e+"anchor"];if(o){if(!o.autorange&&(B[e]-o.range[0])*(B[e]-o.range[1])>0&&(B["a"+e+"ref"]===a?(B["a"+e]-o.range[0])*(B["a"+e]-o.range[1])>0&&(b=!0):b=!0,b))return;Z[e]=o._offset+o.l2p(B[e]),r=.5}else r=B[e],"y"===e&&(r=1-r),Z[e]="x"===e?S.l+S.w*r:S.t+S.h*r;var c=0;B["a"+e+"ref"]===a?Z["aa"+e]=o._offset+o.l2p(B["a"+e]):(c=B.showarrow?B["a"+e]:l*n(r,s),Z[e]+=c),B["_"+e+"type"]=o&&o.type,B["_"+e+"size"]=l,B["_"+e+"shift"]=c}),b)return void G.remove();var w,k;B.showarrow&&(w=B.axref===B.xref?Z.x:c.constrain(Z.x-B.ax,1,_.width-1),k=B.ayref===B.yref?Z.y:c.constrain(Z.y-B.ay,1,_.height-1)),Z.x=c.constrain(Z.x,1,_.width-1),Z.y=c.constrain(Z.y,1,_.height-1);var M=W-l.top,A=W-l.left;a?r.select("svg").attr({x:W-1,y:W}):(tt.attr({x:A,y:M}),tt.selectAll("tspan.line").attr({y:M,x:A})),J.call(d.setRect,$/2,$/2,y-$,x-$);var T=0,L=0;T=B.axref===B.xref?Math.round(Z.aax-y/2):Math.round(Z.x-y/2),L=B.ayref===B.yref?Math.round(Z.aay-x/2):Math.round(Z.y-x/2),G.call(c.setTranslate,T,L);var z="annotations["+e+"]",C=function(n,r){i.select(t).selectAll('.annotation-arrow-g[data-index="'+e+'"]').remove();var a,l;a=B.axref===B.xref?Z.aax+n:Z.x+n,l=B.ayref===B.yref?Z.aay+r:Z.y+r;var u=c.rotationXYMatrix(U,a,l),d=c.apply2DTransform(u),h=c.apply2DTransform2(u),p=J.attr("width")/2,v=J.attr("height")/2,y=[[a-p,l-v,a-p,l+v],[a-p,l+v,a+p,l+v],[a+p,l+v,a+p,l-v],[a+p,l-v,a-p,l-v]].map(h);if(!y.reduce(function(t,e){return t^!!o(w,k,w+1e6,k+1e6,e[0],e[1],e[2],e[3])},!1)){y.forEach(function(t){var e=o(a,l,w,k,t[0],t[1],t[2],t[3]);e&&(a=e.x,l=e.y)});var x=B.arrowwidth,b=B.arrowcolor,_=Y.append("g").style({opacity:f.opacity(b)}).classed("annotation-arrow-g",!0).attr("data-index",String(e)),M=_.append("path").attr("d","M"+a+","+l+"L"+w+","+k).style("stroke-width",x+"px").call(f.stroke,f.rgb(b));m.arrowhead(M,B.arrowhead,"end",B.arrowsize);var A=_.append("path").classed("annotation",!0).classed("anndrag",!0).attr({"data-index":String(e),d:"M3,3H-3V-3H3ZM0,0L"+(a-w)+","+(l-k),transform:"translate("+w+","+k+")"}).style("stroke-width",x+6+"px").call(f.stroke,"rgba(0,0,0,0)").call(f.fill,"rgba(0,0,0,0)");if(t._context.editable){var T,L,C;g.init({element:A.node(),prepFn:function(){var t=c.getTranslate(G);L=t.x,C=t.y,T={},H&&H.autorange&&(T[H._name+".autorange"]=!0),V&&V.autorange&&(T[V._name+".autorange"]=!0)},moveFn:function(t,e){_.attr("transform","translate("+t+","+e+")");var n=d(L,C),r=n[0]+t,a=n[1]+e;G.call(c.setTranslate,r,a),T[z+".x"]=H?B.x+t/H._m:(w+t-S.l)/S.w,T[z+".y"]=V?B.y+e/V._m:1-(k+e-S.t)/S.h,B.axref===B.xref&&(T[z+".ax"]=H?B.ax+t/H._m:(w+t-S.l)/S.w),B.ayref===B.yref&&(T[z+".ay"]=V?B.ay+e/V._m:1-(k+e-S.t)/S.h),X.attr({transform:"rotate("+U+","+r+","+a+")"})},doneFn:function(e){if(e){s.relayout(t,T);var n=document.querySelector(".js-notes-box-panel");n&&n.redraw(n.selectedObj)}}})}}};B.showarrow&&C(0,0);var E=c.rotationXYMatrix(U,Z.x,Z.y),O=c.apply2DTransform(E);if(t._context.editable){var P,N,D;g.init({element:G.node(),prepFn:function(){var t=c.getTranslate(G);P=t.x,N=t.y,D={}},moveFn:function(t,e){G.call(c.setTranslate,P+t,N+e);var n="pointer";if(B.showarrow)B.axref===B.xref?D[z+".ax"]=H.p2l(H.l2p(B.ax)+t):D[z+".ax"]=B.ax+t,B.ayref===B.yref?D[z+".ay"]=V.p2l(V.l2p(B.ay)+e):D[z+".ay"]=B.ay+e,C(t,e);else{if(H)D[z+".x"]=B.x+t/H._m;else{var r=B._xsize/S.w,a=B.x+B._xshift/S.w-r/2;D[z+".x"]=g.align(a+t/S.w,r,0,1,B.xanchor)}if(V)D[z+".y"]=B.y+e/V._m;else{var o=B._ysize/S.h,i=B.y-B._yshift/S.h-o/2;D[z+".y"]=g.align(i-e/S.h,o,0,1,B.yanchor)}H&&V||(n=g.getCursor(H?.5:D[z+".x"],V?.5:D[z+".y"],B.xanchor,B.yanchor))}var l=O(P,N),s=l[0]+t,u=l[1]+e;G.call(c.setTranslate,P+t,N+e),X.attr({transform:"rotate("+U+","+s+","+u+")"}),p(G,n)},doneFn:function(e){if(p(G),e){s.relayout(t,D);var n=document.querySelector(".js-notes-box-panel");n&&n.redraw(n.selectedObj)}}})}}var x,b=t.layout,_=t._fullLayout;if(!l(e)||e===-1){if(!e&&Array.isArray(a))return b.annotations=a,m.supplyLayoutDefaults(b,_),void m.drawAll(t);if("remove"===a)return delete b.annotations,_.annotations=[],void m.drawAll(t);if(n&&"add"!==a){for(x=0;x<_.annotations.length;x++)m.draw(t,x,n,a);return}e=_.annotations.length,_.annotations.push({})}if(!n&&a){if("remove"===a){for(_._infolayer.selectAll('.annotation[data-index="'+e+'"]').remove(),_.annotations.splice(e,1),b.annotations.splice(e,1),x=e;x<_.annotations.length;x++)_._infolayer.selectAll('.annotation[data-index="'+(x+1)+'"]').attr("data-index",String(x)),m.draw(t,x);return}if("add"===a||c.isPlainObject(a)){_.annotations.splice(e,0,{});var w=c.isPlainObject(a)?c.extendFlat({},a):{text:"New text"};for(b.annotations?b.annotations.splice(e,0,w):b.annotations=[w],x=_.annotations.length-1;x>e;x--)_._infolayer.selectAll('.annotation[data-index="'+(x-1)+'"]').attr("data-index",String(x)),m.draw(t,x)}}_._infolayer.selectAll('.annotation[data-index="'+e+'"]').remove();var k=b.annotations[e],M=_.annotations[e];if(k){var A={xref:k.xref,yref:k.yref},T={};"string"==typeof n&&n?T[n]=a:c.isPlainObject(n)&&(T=n);var L=Object.keys(T);for(x=0;x4/3&&(N=F)}}else P&&(I&&(N<1/3?N+=j:N>2/3&&(N-=j)),N=(N-P.domain[0])/(P.domain[1]-P.domain[0]),N=P.range[0]+N*(P.range[1]-P.range[0]))}P&&P===O&&D&&("log"===D&&"log"!==P.type?N=Math.pow(10,N):"log"!==D&&"log"===P.type&&(N=N>0?Math.log(N)/Math.LN10:void 0)),k[E]=N}}var B=r(k,_);_.annotations[e]=B;var H=u.getFromId(t,B.xref),V=u.getFromId(t,B.yref),Z={x:0,y:0},U=+B.textangle||0,Y=_._infolayer.append("g").classed("annotation",!0).attr("data-index",String(e)).style("opacity",B.opacity).on("click",function(){t._dragging=!1,t.emit("plotly_clickannotation",{index:e,annotation:k,fullAnnotation:B})}),X=Y.append("g").classed("annotation-text-g",!0).attr("data-index",String(e)),G=X.append("g"),$=B.borderwidth,Q=B.borderpad,W=$+Q,J=G.append("rect").attr("class","bg").style("stroke-width",$+"px").call(f.stroke,B.bordercolor).call(f.fill,B.bgcolor),K=B.font,tt=G.append("text").classed("annotation",!0).attr("data-unformatted",B.text).text(B.text);t._context.editable?tt.call(h.makeEditable,G).call(v).on("edit",function(n){B.text=n,this.attr({"data-unformatted":B.text}),this.call(v);var r={};r["annotations["+e+"].text"]=B.text,H&&H.autorange&&(r[H._name+".autorange"]=!0),V&&V.autorange&&(r[V._name+".autorange"]=!0),s.relayout(t,r)}):tt.call(v),X.attr({transform:"rotate("+U+","+Z.x+","+Z.y+")"}).call(d.setPosition,Z.x,Z.y)}},m.arrowhead=function(t,e,n,r){l(r)||(r=1);var a=t.node(),o=m.ARROWPATHS[e||0];if(o){"string"==typeof n&&n||(n="end");var s,c,u,h,p=(d.getPx(t,"stroke-width")||1)*r,g=t.style("stroke")||f.defaultLine,v=t.style("stroke-opacity")||1,y=n.indexOf("start")>=0,x=n.indexOf("end")>=0,b=o.backoff*p;if("line"===a.nodeName){if(s={x:+t.attr("x1"),y:+t.attr("y1")},c={x:+t.attr("x2"),y:+t.attr("y2")},u=Math.atan2(s.y-c.y,s.x-c.x),h=u+Math.PI,b){var _=b*Math.cos(u),w=b*Math.sin(u);y&&(s.x-=_,s.y-=w,t.attr({x1:s.x,y1:s.y})),x&&(c.x+=_,c.y+=w,t.attr({x2:c.x,y2:c.y}))}}else if("path"===a.nodeName){var k=a.getTotalLength(),M="";if(y){var A=a.getPointAtLength(0),T=a.getPointAtLength(.1);u=Math.atan2(A.y-T.y,A.x-T.x),s=a.getPointAtLength(Math.min(b,k)),b&&(M="0px,"+b+"px,")}if(x){var L=a.getPointAtLength(k),z=a.getPointAtLength(k-.1);if(h=Math.atan2(L.y-z.y,L.x-z.x),c=a.getPointAtLength(Math.max(0,k-b)),b){var S=M?2*b:b;M+=k-S+"px,"+k+"px"}}else M&&(M+=k+"px");M&&t.style("stroke-dasharray",M)}var C=function(n,r){e>5&&(r=0),i.select(a.parentElement).append("path").attr({class:t.attr("class"),d:o.path,transform:"translate("+n.x+","+n.y+")rotate("+180*r/Math.PI+")scale("+p+")"}).style({fill:g,opacity:v,"stroke-width":0})};y&&C(s,u),x&&C(c,h)}},m.calcAutorange=function(t){var e=t._fullLayout,n=e.annotations;if(n.length&&t._fullData.length){var r={};n.forEach(function(t){r[t.xref]=!0,r[t.yref]=!0});var o=u.list(t).filter(function(t){return t.autorange&&r[t._id]});if(o.length)return c.syncOrAsync([m.drawAll,a],t)}}},{"../../lib":102,"../../lib/setcursor":111,"../../lib/svg_text_utils":113,"../../plotly":120,"../../plots/cartesian/axes":123,"../color":25,"../dragelement":46,"../drawing":48,"./arrow_paths":21,"./attributes":22,d3:14,"fast-isnumeric":17}],24:[function(t,e,n){"use strict";n.defaults=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],n.defaultLine="#444",n.lightLine="#eee",n.background="#fff",n.borderLine="#BEC8D9",n.lightFraction=1e3/11},{}],25:[function(t,e,n){"use strict";function r(t){if(o(t)||"string"!=typeof t)return t;var e=t.trim();if("rgb"!==e.substr(0,3))return t;var n=e.match(/^rgba?\s*\(([^()]*)\)$/);if(!n)return t;var r=n[1].trim().split(/\s*[\s,]\s*/),a="a"===e.charAt(3)&&4===r.length;if(!a&&3!==r.length)return t;for(var i=0;i=0))return t;if(3===i)r[i]>1&&(r[i]=1);else if(r[i]>=1)return t}var l=Math.round(255*r[0])+", "+Math.round(255*r[1])+", "+Math.round(255*r[2]);return a?"rgba("+l+", "+r[3]+")":"rgb("+l+")"}var a=t("tinycolor2"),o=t("fast-isnumeric"),i=e.exports={},l=t("./attributes");i.defaults=l.defaults,i.defaultLine=l.defaultLine,i.lightLine=l.lightLine,i.background=l.background,i.tinyRGB=function(t){var e=t.toRgb();return"rgb("+Math.round(e.r)+", "+Math.round(e.g)+", "+Math.round(e.b)+")"},i.rgb=function(t){return i.tinyRGB(a(t))},i.opacity=function(t){return t?a(t).getAlpha():0},i.addOpacity=function(t,e){var n=a(t).toRgb();return"rgba("+Math.round(n.r)+", "+Math.round(n.g)+", "+Math.round(n.b)+", "+e+")"},i.combine=function(t,e){var n=a(t).toRgb();if(1===n.a)return a(t).toRgbString();var r=a(e||i.background).toRgb(),o=1===r.a?r:{r:255*(1-r.a)+r.r*r.a,g:255*(1-r.a)+r.g*r.a,b:255*(1-r.a)+r.b*r.a},l={r:o.r*(1-n.a)+n.r*n.a,g:o.g*(1-n.a)+n.g*n.a,b:o.b*(1-n.a)+n.b*n.a};return a(l).toRgbString()},i.contrast=function(t,e,n){var r=a(t),o=r.isLight()?r.darken(n):r.lighten(e);return o.toString()},i.stroke=function(t,e){var n=a(e);t.style({stroke:i.tinyRGB(n),"stroke-opacity":n.getAlpha()})},i.fill=function(t,e){var n=a(e);t.style({fill:i.tinyRGB(n),"fill-opacity":n.getAlpha()})},i.clean=function(t){if(t&&"object"==typeof t){var e,n,a,o,l=Object.keys(t);for(e=0;es&&(o[1]-=(it-s)/2)):n.node()&&!n.classed("js-placeholder")&&(it=d.bBox(e.node()).height),it){if(it+=5,"top"===b.titleside)J.domain[1]-=it/A.h,o[1]*=-1;else{J.domain[0]+=it/A.h;var u=Math.max(1,n.selectAll("tspan.line").size());o[1]+=(1-u)*s}e.attr("transform","translate("+o+")"),J.setScale()}}at.selectAll(".cbfills,.cblines,.cbaxis").attr("transform","translate(0,"+Math.round(A.h*(1-J.domain[1]))+")");var f=at.select(".cbfills").selectAll("rect.cbfill").data(S);f.enter().append("rect").classed("cbfill",!0).style("stroke","none"),f.exit().remove(),f.each(function(t,e){var n=[0===e?L[0]:(S[e]+S[e-1])/2,e===S.length-1?L[1]:(S[e]+S[e+1])/2].map(J.c2p).map(Math.round);e!==S.length-1&&(n[1]+=n[1]>n[0]?1:-1);var o=E(t).replace("e-",""),i=a(o).toHexString();r.select(this).attr({x:Y,width:Math.max(F,2),y:r.min(n),height:Math.max(r.max(n)-r.min(n),2),fill:i})});var h=at.select(".cblines").selectAll("path.cbline").data(b.line.color&&b.line.width?z:[]);return h.enter().append("path").classed("cbline",!0),h.exit().remove(),h.each(function(t){r.select(this).attr("d","M"+Y+","+(Math.round(J.c2p(t))+b.line.width/2%1)+"h"+F).call(d.lineGroupStyle,b.line.width,C(t),b.line.dash)}),J._axislayer.selectAll("g."+J._id+"tick,path").remove(),J._pos=Y+F+(b.outlinewidth||0)/2-("outside"===b.ticks?1:0),J.side="right",c.syncOrAsync([function(){return l.doTicks(t,J,!0)},function(){if(["top","bottom"].indexOf(b.titleside)===-1){var e=J.titlefont.size,n=J._offset+J._length/2,a=A.l+(J.position||0)*A.w+("right"===J.side?10+e*(J.showticklabels?1:.5):-10-e*(J.showticklabels?.5:0));w("h"+J._id+"title",{avoid:{selection:r.select(t).selectAll("g."+J._id+"tick"),side:b.titleside,offsetLeft:A.l,offsetTop:A.t,maxShift:M.width},attributes:{x:a,y:n,"text-anchor":"middle"},transform:{rotate:"-90",offset:0}})}}])}function w(e,n){var r,a=x();r=i.traceIs(a,"markerColorscale")?"marker.colorbar.title":"colorbar.title";var o={propContainer:J,propName:r,traceIndex:a.index,dfltName:"colorscale",containerGroup:at.select(".cbtitle")},l="h"===e.charAt(0)?e.substr(1):"h"+e;at.selectAll("."+l+",."+l+"-math-group").remove(),p.draw(t,e,u(o,n||{}))}function k(){var n=F+b.outlinewidth/2+d.bBox(J._axislayer.node()).width;if(I=ot.select("text"),I.node()&&!I.classed("js-placeholder")){var r,a=ot.select(".h"+J._id+"title-math-group").node();r=a&&["top","bottom"].indexOf(b.titleside)!==-1?d.bBox(a).width:d.bBox(ot.node()).right-Y-A.l,n=Math.max(n,r)}var o=2*b.xpad+n+b.borderwidth+b.outlinewidth/2,l=$-Q;at.select(".cbbg").attr({x:Y-b.xpad-(b.borderwidth+b.outlinewidth)/2,y:Q-Z,width:Math.max(o,2),height:Math.max(l+2*Z,2)}).call(h.fill,b.bgcolor).call(h.stroke,b.bordercolor).style({"stroke-width":b.borderwidth}),at.selectAll(".cboutline").attr({x:Y,y:Q+b.ypad+("top"===b.titleside?it:0),width:Math.max(F,2),height:Math.max(l-2*b.ypad-it,2)}).call(h.stroke,b.outlinecolor).style({fill:"None","stroke-width":b.outlinewidth});var s=({center:.5,right:1}[b.xanchor]||0)*o;at.attr("transform","translate("+(A.l-s)+","+A.t+")"),i.autoMargin(t,e,{x:b.x,y:b.y,l:o*({right:1,center:.5}[b.xanchor]||0),r:o*({left:1,center:.5}[b.xanchor]||0),t:l*({bottom:1,middle:.5}[b.yanchor]||0),b:l*({top:1,middle:.5}[b.yanchor]||0)})}var M=t._fullLayout,A=M._size;if("function"!=typeof b.fillcolor&&"function"!=typeof b.line.color)return void M._infolayer.selectAll("g."+e).remove();var T,L=r.extent(("function"==typeof b.fillcolor?b.fillcolor:b.line.color).domain()),z=[],S=[],C="function"==typeof b.line.color?b.line.color:function(){return b.line.color},E="function"==typeof b.fillcolor?b.fillcolor:function(){return b.fillcolor},O=b.levels.end+b.levels.size/100,P=b.levels.size,N=1.001*L[0]-.001*L[1],D=1.001*L[1]-.001*L[0];for(T=b.levels.start;(T-O)*P<0;T+=P)T>N&&TL[0]&&T1){var rt=Math.pow(10,Math.floor(Math.log(nt)/Math.LN10));tt*=rt*c.roundUp(nt/rt,[2,5,10]),(Math.abs(b.levels.start)/b.levels.size+1e-6)%1<2e-6&&(J.tick0=0)}J.dtick=tt}J.domain=[G+U,G+H-U],J.setScale();var at=M._infolayer.selectAll("g."+e).data([0]);at.enter().append("g").classed(e,!0).each(function(){var t=r.select(this);t.append("rect").classed("cbbg",!0),t.append("g").classed("cbfills",!0),t.append("g").classed("cblines",!0),t.append("g").classed("cbaxis",!0).classed("crisp",!0),t.append("g").classed("cbtitleunshift",!0).append("g").classed("cbtitle",!0),t.append("rect").classed("cboutline",!0),t.select(".cbtitle").datum(0)}),at.attr("transform","translate("+Math.round(A.l)+","+Math.round(A.t)+")");var ot=at.select(".cbtitleunshift").attr("transform","translate(-"+Math.round(A.l)+",-"+Math.round(A.t)+")");J._axislayer=at.select(".cbaxis");var it=0;if(["top","bottom"].indexOf(b.titleside)!==-1){var lt,st=A.l+(b.x+V)*A.w,ct=J.titlefont.size;lt="top"===b.titleside?(1-(G+H-U))*A.h+A.t+3+.75*ct:(1-(G+U))*A.h+A.t-3-.25*ct,w(J._id+"title",{attributes:{x:st,y:lt,"text-anchor":"start"}})}var ut=c.syncOrAsync([i.previousPromises,_,i.previousPromises,k],t);if(ut&&ut.then&&(t._promises||[]).push(ut),t._context.editable){var ft,dt,ht;s.init({element:at.node(),prepFn:function(){ft=at.attr("transform"),f(at)},moveFn:function(t,e){at.attr("transform",ft+" translate("+t+","+e+")"),dt=s.align(X+t/A.w,q,0,1,b.xanchor),ht=s.align(G-e/A.h,H,0,1,b.yanchor);var n=s.getCursor(dt,ht,b.xanchor,b.yanchor);f(at,n)},doneFn:function(e){f(at),e&&void 0!==dt&&void 0!==ht&&o.restyle(t,{"colorbar.x":dt,"colorbar.y":ht},x().index)}})}return ut}function x(){var n,r,a=e.substr(2);for(n=0;n=0?a.Reds:a.Blues,s.colorscale=d,l.reversescale&&(d=o(d)),l.colorscale=d)}},{"../../lib":102,"./flip_scale":36,"./scales":43}],33:[function(t,e,n){"use strict";var r=t("./attributes"),a=t("../../lib/extend").extendDeep;t("./scales.js");e.exports=function(t){return{color:{valType:"color",arrayOk:!0},colorscale:a({},r.colorscale,{}),cauto:a({},r.zauto,{}),cmax:a({},r.zmax,{}),cmin:a({},r.zmin,{}),autocolorscale:a({},r.autocolorscale,{}),reversescale:a({},r.reversescale,{})}}},{"../../lib/extend":100,"./attributes":31,"./scales.js":43}],34:[function(t,e,n){"use strict";var r=t("./scales");e.exports=r.RdBu},{"./scales":43}],35:[function(t,e,n){"use strict";var r=t("fast-isnumeric"),a=t("../../lib"),o=t("../colorbar/has_colorbar"),i=t("../colorbar/defaults"),l=t("./is_valid_scale"),s=t("./flip_scale");e.exports=function(t,e,n,c,u){var f=u.prefix,d=u.cLetter,h=f.slice(0,f.length-1),p=f?a.nestedProperty(t,h).get()||{}:t,g=f?a.nestedProperty(e,h).get()||{}:e,m=p[d+"min"],v=p[d+"max"],y=p.colorscale,x=r(m)&&r(v)&&m=0;a--,o++)e=t[a],r[o]=[1-e[0],e[1]];return r}},{}],37:[function(t,e,n){"use strict";var r=t("./scales"),a=t("./default_scale"),o=t("./is_valid_scale_array");e.exports=function(t,e){function n(){try{t=r[t]||JSON.parse(t)}catch(n){t=e}}return e||(e=a),t?("string"==typeof t&&(n(),"string"==typeof t&&n()),o(t)?t:e):e}},{"./default_scale":34,"./is_valid_scale_array":41,"./scales":43}],38:[function(t,e,n){"use strict";var r=t("fast-isnumeric"),a=t("../../lib"),o=t("./is_valid_scale");e.exports=function(t,e){var n=e?a.nestedProperty(t,e).get()||{}:t,i=n.color,l=!1;if(Array.isArray(i))for(var s=0;s4/3-l?i:l}},{}],45:[function(t,e,n){"use strict";var r=t("../../lib"),a=[["sw-resize","s-resize","se-resize"],["w-resize","move","e-resize"],["nw-resize","n-resize","ne-resize"]];e.exports=function(t,e,n,o){return t="left"===n?0:"center"===n?1:"right"===n?2:r.constrain(Math.floor(3*t),0,2),e="bottom"===o?0:"middle"===o?1:"top"===o?2:r.constrain(Math.floor(3*e),0,2),a[e][t]}},{"../../lib":102}],46:[function(t,e,n){"use strict";function r(){var t=document.createElement("div");t.className="dragcover";var e=t.style;return e.position="fixed",e.left=0,e.right=0,e.top=0,e.bottom=0,e.zIndex=999999999,e.background="none",document.body.appendChild(t),t}function a(t){t._dragging=!1,t._replotPending&&o.plot(t)}var o=t("../../plotly"),i=t("../../lib"),l=t("../../plots/cartesian/constants"),s=e.exports={};s.align=t("./align"),s.getCursor=t("./cursor");var c=t("./unhover");s.unhover=c.wrapped,s.unhoverRaw=c.raw,s.init=function(t){function e(e){return t.element.onmousemove=p,g._dragged=!1,g._dragging=!0,c=e.clientX,u=e.clientY,h=e.target,f=(new Date).getTime(),f-g._mouseDownTimev&&(m=Math.max(m-1,1)),t.doneFn&&t.doneFn(g._dragged,m),!g._dragged){var n=document.createEvent("MouseEvents");n.initEvent("click",!0,!0),h.dispatchEvent(n)}return a(g),g._dragged=!1,i.pauseEvent(e)}var c,u,f,d,h,p,g=i.getPlotDiv(t.element)||{},m=1,v=l.DBLCLICKDELAY;g._mouseDownTime||(g._mouseDownTime=0),p=t.element.onmousemove,t.setCursor&&(t.element.onmousemove=t.setCursor),t.element.onmousedown=e,t.element.style.pointerEvents="all"}},{"../../lib":102,"../../plotly":120,"../../plots/cartesian/constants":128,"./align":44,"./cursor":45,"./unhover":47}],47:[function(t,e,n){"use strict";var r=t("../../lib/events"),a=e.exports={};a.wrapped=function(t,e,n){"string"==typeof t&&(t=document.getElementById(t)),t._hoverTimer&&(clearTimeout(t._hoverTimer),t._hoverTimer=void 0),a.raw(t,e,n)},a.raw=function(t,e){var n=t._fullLayout;e||(e={}),e.target&&r.triggerHandler(t,"plotly_beforehover",e)===!1||(n._hoverlayer.selectAll("g").remove(),e.target&&t._hoverdata&&t.emit("plotly_unhover",{points:t._hoverdata}),t._hoverdata=void 0)}},{"../../lib/events":99}],48:[function(t,e,n){"use strict";function r(t,e,n,r){var o=t[0]-e[0],i=t[1]-e[1],l=n[0]-e[0],s=n[1]-e[1],c=Math.pow(o*o+i*i,b/2),u=Math.pow(l*l+s*s,b/2),f=(u*u*o-c*c*l)*r,d=(u*u*i-c*c*s)*r,h=3*u*(c+u),p=3*c*(c+u);return[[a.round(e[0]+(h&&f/h),2),a.round(e[1]+(h&&d/h),2)],[a.round(e[0]-(p&&f/p),2),a.round(e[1]-(p&&d/p),2)]]}var a=t("d3"),o=t("fast-isnumeric"),i=t("../../plots/plots"),l=t("../color"),s=t("../colorscale"),c=t("../../lib"),u=t("../../lib/svg_text_utils"),f=t("../../constants/xmlns_namespaces"),d=t("../../traces/scatter/subtypes"),h=t("../../traces/scatter/make_bubble_size_func"),p=e.exports={};p.font=function(t,e,n,r){e&&e.family&&(r=e.color,n=e.size,e=e.family),e&&t.style("font-family",e),n+1&&t.style("font-size",n+"px"),r&&t.call(l.fill,r)},p.setPosition=function(t,e,n){t.attr("x",e).attr("y",n)},p.setSize=function(t,e,n){t.attr("width",e).attr("height",n)},p.setRect=function(t,e,n,r,a){t.call(p.setPosition,e,n).call(p.setSize,r,a)},p.translatePoints=function(t,e,n){t.each(function(t){var r=t.xp||e.c2p(t.x),i=t.yp||n.c2p(t.y),l=a.select(this);o(r)&&o(i)?"text"===this.nodeName?l.attr("x",r).attr("y",i):l.attr("transform","translate("+r+","+i+")"):l.remove()})},p.getPx=function(t,e){return Number(t.style(e).replace(/px$/,""))},p.crispRound=function(t,e,n){return e&&o(e)?t._context.staticPlot?e:e<1?1:Math.round(e):n||0},p.lineGroupStyle=function(t,e,n,r){t.style("fill","none").each(function(t){var o=(((t||[])[0]||{}).trace||{}).line||{},i=e||o.width||0,s=r||o.dash||"";a.select(this).call(l.stroke,n||o.color).call(p.dashLine,s,i)})},p.dashLine=function(t,e,n){var r=Math.max(n,3);"solid"===e?e="":"dot"===e?e=r+"px,"+r+"px":"dash"===e?e=3*r+"px,"+3*r+"px":"longdash"===e?e=5*r+"px,"+5*r+"px":"dashdot"===e?e=3*r+"px,"+r+"px,"+r+"px,"+r+"px":"longdashdot"===e&&(e=5*r+"px,"+2*r+"px,"+r+"px,"+2*r+"px"),t.style({"stroke-dasharray":e,"stroke-width":n+"px"})},p.fillGroupStyle=function(t){t.style("stroke-width",0).each(function(e){var n=a.select(this);try{n.call(l.fill,e[0].trace.fillcolor)}catch(e){c.error(e,t),n.remove()}})};var g=t("./symbol_defs");p.symbolNames=[],p.symbolFuncs=[],p.symbolNeedLines={},p.symbolNoDot={},p.symbolList=[],Object.keys(g).forEach(function(t){var e=g[t];p.symbolList=p.symbolList.concat([e.n,t,e.n+100,t+"-open"]),p.symbolNames[e.n]=t,p.symbolFuncs[e.n]=e.f,e.needLine&&(p.symbolNeedLines[e.n]=!0),e.noDot?p.symbolNoDot[e.n]=!0:p.symbolList=p.symbolList.concat([e.n+200,t+"-dot",e.n+300,t+"-open-dot"])});var m=p.symbolNames.length,v="M0,0.5L0.5,0L0,-0.5L-0.5,0Z";p.symbolNumber=function(t){if("string"==typeof t){var e=0;t.indexOf("-open")>0&&(e=100,t=t.replace("-open","")),t.indexOf("-dot")>0&&(e+=200,t=t.replace("-dot","")),t=p.symbolNames.indexOf(t),t>=0&&(t+=e)}return t%100>=m||t>=400?0:Math.floor(Math.max(t,0))},p.pointStyle=function(t,e){if(t.size()){var n=e.marker,r=n.line;if(i.traceIs(e,"symbols")){var o=h(e);t.attr("d",function(t){var r;r="various"===t.ms||"various"===n.size?3:d.isBubble(e)?o(t.ms):(n.size||6)/2,t.mrc=r;var a=p.symbolNumber(t.mx||n.symbol)||0,i=a%100;return t.om=a%200>=100,p.symbolFuncs[i](r)+(a>=200?v:"")}).style("opacity",function(t){return(t.mo+1||n.opacity+1)-1})}var s=(e._input||{}).marker||{},c=p.tryColorscale(n,s,""),u=p.tryColorscale(n,s,"line.");t.each(function(t){var e,o,i;t.so?(i=r.outlierwidth,o=r.outliercolor,e=n.outliercolor):(i=(t.mlw+1||r.width+1||(t.trace?t.trace.marker.line.width:0)+1)-1,o="mlc"in t?t.mlcc=u(t.mlc):Array.isArray(r.color)?l.defaultLine:r.color,e="mc"in t?t.mcc=c(t.mc):Array.isArray(n.color)?l.defaultLine:n.color||"rgba(0,0,0,0)");var s=a.select(this);t.om?s.call(l.stroke,e).style({"stroke-width":(i||1)+"px",fill:"none"}):(s.style("stroke-width",i+"px").call(l.fill,e),i&&s.call(l.stroke,o))})}},p.tryColorscale=function(t,e,n){var r=c.nestedProperty(t,n+"color").get(),a=c.nestedProperty(t,n+"colorscale").get(),i=c.nestedProperty(t,n+"cauto").get(),l=c.nestedProperty(t,n+"cmin"),u=c.nestedProperty(t,n+"cmax"),f=l.get(),d=u.get();return a&&Array.isArray(r)?(!i&&o(f)&&o(d)||(f=1/0,d=-(1/0),r.forEach(function(t){o(t)&&(f>t&&(f=+t),dd&&(f=0,d=1),l.set(f),u.set(d),c.nestedProperty(e,n+"cmin").set(f),c.nestedProperty(e,n+"cmax").set(d)),s.makeScaleFunction(a,f,d)):c.identity};var y={start:1,end:-1,middle:0,bottom:1,top:-1},x=1.3;p.textPointStyle=function(t,e){t.each(function(t){var n=a.select(this),r=t.tx||e.text;if(!r||Array.isArray(r))return void n.remove();var i=t.tp||e.textposition,l=i.indexOf("top")!==-1?"top":i.indexOf("bottom")!==-1?"bottom":"middle",s=i.indexOf("left")!==-1?"end":i.indexOf("right")!==-1?"start":"middle",c=t.ts||e.textfont.size,f=t.mrc?t.mrc/.8+1:0;c=o(c)&&c>0?c:0,n.call(p.font,t.tf||e.textfont.family,c,t.tc||e.textfont.color).attr("text-anchor",s).text(r).call(u.convertToTspans);var d=a.select(this.parentNode),h=n.selectAll("tspan.line"),g=((h[0].length||1)-1)*x+1,m=y[s]*f,v=.75*c+y[l]*f+(y[l]-1)*g*c/2;d.attr("transform","translate("+m+","+v+")"),g>1&&h.attr({x:n.attr("x"),y:n.attr("y")})})};var b=.5;p.smoothopen=function(t,e){if(t.length<3)return"M"+t.join("L");var n,a="M"+t[0],o=[];for(n=1;n=M&&(a.selectAll("[data-bb]").attr("data-bb",null),k=[]),t.setAttribute("data-bb",k.length),k.push(s),c.extendFlat({},s)},p.setClipUrl=function(t,e){if(!e)return void t.attr("clip-path",null);var n="#"+e,r=a.select("base");r.size()&&r.attr("href")&&(n=window.location.href+n),t.attr("clip-path","url("+n+")")}},{"../../constants/xmlns_namespaces":94,"../../lib":102,"../../lib/svg_text_utils":113,"../../plots/plots":143,"../../traces/scatter/make_bubble_size_func":250,"../../traces/scatter/subtypes":255,"../color":25,"../colorscale":39,"./symbol_defs":49,d3:14,"fast-isnumeric":17}],49:[function(t,e,n){"use strict";var r=t("d3");e.exports={circle:{n:0,f:function(t){var e=r.round(t,2);return"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"}},square:{n:1,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"}},diamond:{n:2,f:function(t){var e=r.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"Z"}},cross:{n:3,f:function(t){var e=r.round(.4*t,2),n=r.round(1.2*t,2);return"M"+n+","+e+"H"+e+"V"+n+"H-"+e+"V"+e+"H-"+n+"V-"+e+"H-"+e+"V-"+n+"H"+e+"V-"+e+"H"+n+"Z"}},x:{n:4,f:function(t){var e=r.round(.8*t/Math.sqrt(2),2),n="l"+e+","+e,a="l"+e+",-"+e,o="l-"+e+",-"+e,i="l-"+e+","+e;return"M0,"+e+n+a+o+a+o+i+o+i+n+i+n+"Z"}},"triangle-up":{n:5,f:function(t){var e=r.round(2*t/Math.sqrt(3),2),n=r.round(t/2,2),a=r.round(t,2);return"M-"+e+","+n+"H"+e+"L0,-"+a+"Z"}},"triangle-down":{n:6,f:function(t){var e=r.round(2*t/Math.sqrt(3),2),n=r.round(t/2,2),a=r.round(t,2);return"M-"+e+",-"+n+"H"+e+"L0,"+a+"Z"}},"triangle-left":{n:7,f:function(t){var e=r.round(2*t/Math.sqrt(3),2),n=r.round(t/2,2),a=r.round(t,2);return"M"+n+",-"+e+"V"+e+"L-"+a+",0Z"}},"triangle-right":{n:8,f:function(t){var e=r.round(2*t/Math.sqrt(3),2),n=r.round(t/2,2),a=r.round(t,2);return"M-"+n+",-"+e+"V"+e+"L"+a+",0Z"}},"triangle-ne":{n:9,f:function(t){var e=r.round(.6*t,2),n=r.round(1.2*t,2);return"M-"+n+",-"+e+"H"+e+"V"+n+"Z"}},"triangle-se":{n:10,f:function(t){var e=r.round(.6*t,2),n=r.round(1.2*t,2);return"M"+e+",-"+n+"V"+e+"H-"+n+"Z"}},"triangle-sw":{n:11,f:function(t){var e=r.round(.6*t,2),n=r.round(1.2*t,2);return"M"+n+","+e+"H-"+e+"V-"+n+"Z"}},"triangle-nw":{n:12,f:function(t){var e=r.round(.6*t,2),n=r.round(1.2*t,2);return"M-"+e+","+n+"V-"+e+"H"+n+"Z"}},pentagon:{n:13,f:function(t){var e=r.round(.951*t,2),n=r.round(.588*t,2),a=r.round(-t,2),o=r.round(t*-.309,2),i=r.round(.809*t,2);return"M"+e+","+o+"L"+n+","+i+"H-"+n+"L-"+e+","+o+"L0,"+a+"Z"}},hexagon:{n:14,f:function(t){var e=r.round(t,2),n=r.round(t/2,2),a=r.round(t*Math.sqrt(3)/2,2);return"M"+a+",-"+n+"V"+n+"L0,"+e+"L-"+a+","+n+"V-"+n+"L0,-"+e+"Z"}},hexagon2:{n:15,f:function(t){var e=r.round(t,2),n=r.round(t/2,2),a=r.round(t*Math.sqrt(3)/2,2);return"M-"+n+","+a+"H"+n+"L"+e+",0L"+n+",-"+a+"H-"+n+"L-"+e+",0Z"}},octagon:{n:16,f:function(t){var e=r.round(.924*t,2),n=r.round(.383*t,2);return"M-"+n+",-"+e+"H"+n+"L"+e+",-"+n+"V"+n+"L"+n+","+e+"H-"+n+"L-"+e+","+n+"V-"+n+"Z"}},star:{n:17,f:function(t){var e=1.4*t,n=r.round(.225*e,2),a=r.round(.951*e,2),o=r.round(.363*e,2),i=r.round(.588*e,2),l=r.round(-e,2),s=r.round(e*-.309,2),c=r.round(.118*e,2),u=r.round(.809*e,2),f=r.round(.382*e,2);return"M"+n+","+s+"H"+a+"L"+o+","+c+"L"+i+","+u+"L0,"+f+"L-"+i+","+u+"L-"+o+","+c+"L-"+a+","+s+"H-"+n+"L0,"+l+"Z"}},hexagram:{n:18,f:function(t){var e=r.round(.66*t,2),n=r.round(.38*t,2),a=r.round(.76*t,2);return"M-"+a+",0l-"+n+",-"+e+"h"+a+"l"+n+",-"+e+"l"+n+","+e+"h"+a+"l-"+n+","+e+"l"+n+","+e+"h-"+a+"l-"+n+","+e+"l-"+n+",-"+e+"h-"+a+"Z"}},"star-triangle-up":{n:19,f:function(t){var e=r.round(t*Math.sqrt(3)*.8,2),n=r.round(.8*t,2),a=r.round(1.6*t,2),o=r.round(4*t,2),i="A "+o+","+o+" 0 0 1 ";return"M-"+e+","+n+i+e+","+n+i+"0,-"+a+i+"-"+e+","+n+"Z"}},"star-triangle-down":{n:20,f:function(t){var e=r.round(t*Math.sqrt(3)*.8,2),n=r.round(.8*t,2),a=r.round(1.6*t,2),o=r.round(4*t,2),i="A "+o+","+o+" 0 0 1 ";return"M"+e+",-"+n+i+"-"+e+",-"+n+i+"0,"+a+i+e+",-"+n+"Z"}},"star-square":{n:21,f:function(t){var e=r.round(1.1*t,2),n=r.round(2*t,2),a="A "+n+","+n+" 0 0 1 ";return"M-"+e+",-"+e+a+"-"+e+","+e+a+e+","+e+a+e+",-"+e+a+"-"+e+",-"+e+"Z"}},"star-diamond":{n:22,f:function(t){var e=r.round(1.4*t,2),n=r.round(1.9*t,2),a="A "+n+","+n+" 0 0 1 ";return"M-"+e+",0"+a+"0,"+e+a+e+",0"+a+"0,-"+e+a+"-"+e+",0Z"}},"diamond-tall":{n:23,f:function(t){var e=r.round(.7*t,2),n=r.round(1.4*t,2);return"M0,"+n+"L"+e+",0L0,-"+n+"L-"+e+",0Z"}},"diamond-wide":{n:24,f:function(t){var e=r.round(1.4*t,2),n=r.round(.7*t,2);return"M0,"+n+"L"+e+",0L0,-"+n+"L-"+e+",0Z"}},hourglass:{n:25,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"H-"+e+"L"+e+",-"+e+"H-"+e+"Z"},noDot:!0},bowtie:{n:26,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"V-"+e+"L-"+e+","+e+"V-"+e+"Z"},noDot:!0},"circle-cross":{n:27,f:function(t){var e=r.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"circle-x":{n:28,f:function(t){var e=r.round(t,2),n=r.round(t/Math.sqrt(2),2);return"M"+n+","+n+"L-"+n+",-"+n+"M"+n+",-"+n+"L-"+n+","+n+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"square-cross":{n:29,f:function(t){var e=r.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"square-x":{n:30,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"diamond-cross":{n:31,f:function(t){var e=r.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM0,-"+e+"V"+e+"M-"+e+",0H"+e},needLine:!0,noDot:!0},"diamond-x":{n:32,f:function(t){var e=r.round(1.3*t,2),n=r.round(.65*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM-"+n+",-"+n+"L"+n+","+n+"M-"+n+","+n+"L"+n+",-"+n},needLine:!0,noDot:!0},"cross-thin":{n:33,f:function(t){var e=r.round(1.4*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e},needLine:!0,noDot:!0},"x-thin":{n:34,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0},asterisk:{n:35,f:function(t){var e=r.round(1.2*t,2),n=r.round(.85*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+n+","+n+"L-"+n+",-"+n+"M"+n+",-"+n+"L-"+n+","+n},needLine:!0,noDot:!0},hash:{n:36,f:function(t){var e=r.round(t/2,2),n=r.round(t,2);return"M"+e+","+n+"V-"+n+"m-"+n+",0V"+n+"M"+n+","+e+"H-"+n+"m0,-"+n+"H"+n},needLine:!0},"y-up":{n:37,f:function(t){var e=r.round(1.2*t,2),n=r.round(1.6*t,2),a=r.round(.8*t,2);return"M-"+e+","+a+"L0,0M"+e+","+a+"L0,0M0,-"+n+"L0,0"},needLine:!0,noDot:!0},"y-down":{n:38,f:function(t){var e=r.round(1.2*t,2),n=r.round(1.6*t,2),a=r.round(.8*t,2);return"M-"+e+",-"+a+"L0,0M"+e+",-"+a+"L0,0M0,"+n+"L0,0"},needLine:!0,noDot:!0},"y-left":{n:39,f:function(t){var e=r.round(1.2*t,2),n=r.round(1.6*t,2),a=r.round(.8*t,2);return"M"+a+","+e+"L0,0M"+a+",-"+e+"L0,0M-"+n+",0L0,0"},needLine:!0,noDot:!0},"y-right":{n:40,f:function(t){var e=r.round(1.2*t,2),n=r.round(1.6*t,2),a=r.round(.8*t,2);return"M-"+a+","+e+"L0,0M-"+a+",-"+e+"L0,0M"+n+",0L0,0"},needLine:!0,noDot:!0},"line-ew":{n:41,f:function(t){var e=r.round(1.4*t,2);return"M"+e+",0H-"+e},needLine:!0,noDot:!0},"line-ns":{n:42,f:function(t){var e=r.round(1.4*t,2);return"M0,"+e+"V-"+e},needLine:!0,noDot:!0},"line-ne":{n:43,f:function(t){var e=r.round(t,2);return"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0},"line-nw":{n:44,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e},needLine:!0,noDot:!0}}},{d3:14}],50:[function(t,e,n){"use strict";e.exports={visible:{valType:"boolean"},type:{valType:"enumerated",values:["percent","constant","sqrt","data"]},symmetric:{valType:"boolean"},array:{valType:"data_array"},arrayminus:{valType:"data_array"},value:{valType:"number",min:0,dflt:10},valueminus:{valType:"number",min:0,dflt:10},traceref:{valType:"integer",min:0,dflt:0},tracerefminus:{valType:"integer",min:0,dflt:0},copy_ystyle:{valType:"boolean"},copy_zstyle:{valType:"boolean"},color:{valType:"color"},thickness:{valType:"number",min:0,dflt:2},width:{valType:"number",min:0},_deprecated:{opacity:{valType:"number"}}}},{}],51:[function(t,e,n){"use strict";function r(t,e,n,r){var o=e["error_"+r]||{},s=o.visible&&["linear","log"].indexOf(n.type)!==-1,c=[];if(s){for(var u=l(o),f=0;f0;if(u.visible||c.visible){var d=a.select(this).selectAll("g.errorbar").data(i.identity);d.enter().append("g").classed("errorbar",!0),d.each(function(t){var e=a.select(this),i=r(t,n,s);if(!f||t.vis){var l;if(u.visible&&o(i.x)&&o(i.yh)&&o(i.ys)){var d=u.width;l="M"+(i.x-d)+","+i.yh+"h"+2*d+"m-"+d+",0V"+i.ys,i.noYS||(l+="m-"+d+",0h"+2*d),e.append("path").classed("yerror",!0).attr("d",l)}if(c.visible&&o(i.y)&&o(i.xh)&&o(i.xs)){var h=(c.copy_ystyle?u:c).width;l="M"+i.xh+","+(i.y-h)+"v"+2*h+"m0,-"+h+"H"+i.xs,i.noXS||(l+="m0,-"+h+"v"+2*h),e.append("path").classed("xerror",!0).attr("d",l)}}})}})}},{"../../lib":102,"../../traces/scatter/subtypes":255,d3:14,"fast-isnumeric":17}],56:[function(t,e,n){"use strict";var r=t("d3"),a=t("../color");e.exports=function(t){t.each(function(t){var e=t[0].trace,n=e.error_y||{},o=e.error_x||{},i=r.select(this);i.selectAll("path.yerror").style("stroke-width",n.thickness+"px").call(a.stroke,n.color),o.copy_ystyle&&(o=n),i.selectAll("path.xerror").style("stroke-width",o.thickness+"px").call(a.stroke,o.color)})}},{"../color":25,d3:14}],57:[function(t,e,n){"use strict";var r=t("../../plots/cartesian/constants");e.exports={_isLinkedToArray:!0,source:{valType:"string"},layer:{valType:"enumerated",values:["below","above"],dflt:"above"},sizex:{valType:"number",dflt:0},sizey:{valType:"number",dflt:0},sizing:{valType:"enumerated",values:["fill","contain","stretch"],dflt:"contain"},opacity:{valType:"number",min:0,max:1,dflt:1},x:{valType:"number",dflt:0},y:{valType:"number",dflt:0},xanchor:{valType:"enumerated",values:["left","center","right"],dflt:"left"},yanchor:{valType:"enumerated",values:["top","middle","bottom"],dflt:"top"},xref:{valType:"enumerated",values:["paper",r.idRegex.x.toString()],dflt:"paper"},yref:{valType:"enumerated",values:["paper",r.idRegex.y.toString()],dflt:"paper"}}},{"../../plots/cartesian/constants":128}],58:[function(t,e,n){"use strict";function r(t,e,n){function r(n,r){return o.coerce(t,e,i,n,r)}e=e||{},r("source"),r("layer"),r("x"),r("y"),r("xanchor"),r("yanchor"),r("sizex"),r("sizey"),r("sizing"),r("opacity");for(var l=0;l<2;l++){var s={_fullLayout:n},c=["x","y"][l];a.coerceRef(t,e,s,c,"paper")}return e}var a=t("../../plots/cartesian/axes"),o=t("../../lib"),i=t("./attributes");e.exports=function(t,e){if(t.images&&Array.isArray(t.images))for(var n=t.images,a=e.images=[],o=0;o=2/3},n.isCenterAnchor=function(t){return"center"===t.xanchor||"auto"===t.xanchor&&t.x>1/3&&t.x<2/3},n.isBottomAnchor=function(t){return"bottom"===t.yanchor||"auto"===t.yanchor&&t.y<=1/3},n.isMiddleAnchor=function(t){return"middle"===t.yanchor||"auto"===t.yanchor&&t.y>1/3&&t.y<2/3}},{}],62:[function(t,e,n){"use strict";var r=t("../../plots/font_attributes"),a=t("../color/attributes"),o=t("../../lib/extend").extendFlat;e.exports={bgcolor:{valType:"color"},bordercolor:{valType:"color",dflt:a.defaultLine},borderwidth:{valType:"number",min:0,dflt:0},font:o({},r,{}),orientation:{valType:"enumerated",values:["v","h"],dflt:"v"},horizontalspacing:{valType:"enumerated",values:["column","wrapped"],dflt:["column"]},traceorder:{valType:"flaglist",flags:["reversed","grouped"],extras:["normal"]},tracegroupgap:{valType:"number",min:0,dflt:10},x:{valType:"number",min:-2,max:3,dflt:1.02},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"left"},y:{valType:"number",min:-2,max:3,dflt:1},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto"}}},{"../../lib/extend":100,"../../plots/font_attributes":141,"../color/attributes":24}],63:[function(t,e,n){"use strict";e.exports={scrollBarWidth:4,scrollBarHeight:20,scrollBarColor:"#808BA4",scrollBarMargin:4}},{}],64:[function(t,e,n){"use strict";var r=t("../../lib"),a=t("../../plots/plots"),o=t("./attributes"),i=t("./helpers");e.exports=function(t,e,n){function l(t,e){return r.coerce(d,h,o,t,e)}for(var s,c,u,f,d=t.legend||{},h=e.legend={},p=0,g="normal",m="column",v=0;v1);if(x!==!1){if(l("bgcolor",e.paper_bgcolor),l("bordercolor"),l("borderwidth"),r.coerceFont(l,"font",e.font),l("orientation"),"h"===h.orientation){var b=t.xaxis;b&&b.rangeslider&&b.rangeslider.visible?(s=0,u="left",c=1.1,f="bottom"):(s=0,u="left",c=-.1,f="top")}l("traceorder",g),i.isGrouped(e.legend)&&l("tracegroupgap"),l("x",s),l("xanchor",u),l("y",c),l("yanchor",f),l("horizontalspacing",m),r.noneOrAll(d,h,["x","y"]); ++}}},{"../../lib":102,"../../plots/plots":143,"./attributes":62,"./helpers":67}],65:[function(t,e,n){"use strict";function r(t,e){function n(n){u.util.convertToTspans(n,function(){n.selectAll("tspan.line").attr({x:n.attr("x")}),t.call(o,e)})}var r=t.data()[0][0],a=e._fullLayout,i=r.trace,l=d.traceIs(i,"pie"),s=i.index,c=l?r.label:i.name,f=t.selectAll("text.legendtext").data([0]);f.enter().append("text").classed("legendtext",!0),f.attr({x:40,y:0,"data-unformatted":c}).style("text-anchor","start").classed("user-select-none",!0).call(p.font,a.legend.font).text(c),e._context.editable&&!l?f.call(u.util.makeEditable).call(n).on("edit",function(t){this.attr({"data-unformatted":t}),this.text(t).call(n),this.text()||(t=" "),u.restyle(e,"name",t,s)}):f.call(n)}function a(t,e){var n=e._fullLayout.hiddenlabels?e._fullLayout.hiddenlabels.slice():[],r=t.selectAll("rect").data([0]);r.enter().append("rect").classed("legendtoggle",!0).style("cursor","pointer").attr("pointer-events","all").call(g.fill,"rgba(0,0,0,0)"),r.on("click",function(){if(!e._dragged){var r,a,o=t.data()[0][0],i=e._fullData,l=o.trace,s=l.legendgroup,c=[];if(d.traceIs(l,"pie")){var f=o.label,h=n.indexOf(f);h===-1?n.push(f):n.splice(h,1),u.relayout(e,"hiddenlabels",n)}else{if(""===s)c=[l.index];else for(var p=0;ptspan"),h=d[0].length||1;n=s*h,r=u.node()&&p.bBox(u.node()).width;var g=s*(.3+(1-h)/2);u.attr("y",g),d.attr("y",g)}n=Math.max(n,16)+3,o.attr({x:0,y:-n/2,height:n}),a.height=n,a.width=r}function i(t,e,n){var r=t._fullLayout,a=r.legend,o=a.borderwidth,i=x.isGrouped(a),l=x.isHorizontalColumn(a);if(x.isVertical(a))i&&e.each(function(t,e){f.setTranslate(this,0,e*a.tracegroupgap)}),a.width=0,a.height=0,n.each(function(t){var e=t[0],n=e.height,r=e.width;f.setTranslate(this,o,5+o+a.height+n/2),a.height+=n,a.width=Math.max(a.width,r)}),a.width+=45+2*o,a.height+=10+2*o,i&&(a.height+=(a._lgroupsLength-1)*a.tracegroupgap),n.selectAll(".legendtoggle").attr("width",(t._context.editable?0:a.width)+40),a.width=Math.ceil(a.width),a.height=Math.ceil(a.height);else if(i){a.width=0,a.height=0;for(var s=[a.width],u=e.data(),d=0,h=u.length;dr.width-(r.margin.r+r.margin.l)&&(b=0,m+=v,a.height=a.height+v,v=0),f.setTranslate(this,o+b,5+o+e.height/2+m),a.width+=i+n,a.height=Math.max(a.height,e.height),b+=i+n,v=Math.max(e.height,v)}),a.width+=2*o,a.height+=10+2*o,a.width=Math.ceil(a.width),a.height=Math.ceil(a.height),n.selectAll(".legendtoggle").attr("width",t._context.editable?0:a.width)}}function l(t){var e=t._fullLayout,n=e.legend,r="left";b.isRightAnchor(n)?r="right":b.isCenterAnchor(n)&&(r="center");var a="top";b.isBottomAnchor(n)?a="bottom":b.isMiddleAnchor(n)&&(a="middle"),d.autoMargin(t,"legend",{x:n.x,y:n.y,l:n.width*({right:1,center:.5}[r]||0),r:n.width*({left:1,center:.5}[r]||0),b:n.height*({top:1,middle:.5}[a]||0),t:n.height*({bottom:1,middle:.5}[a]||0)})}function s(t){var e=t._fullLayout,n=e.legend,r="left";b.isRightAnchor(n)?r="right":b.isCenterAnchor(n)&&(r="center"),d.autoMargin(t,"legend",{x:n.x,y:.5,l:n.width*({right:1,center:.5}[r]||0),r:n.width*({left:1,center:.5}[r]||0),b:0,t:0})}var c=t("d3"),u=t("../../plotly"),f=t("../../lib"),d=t("../../plots/plots"),h=t("../dragelement"),p=t("../drawing"),g=t("../color"),m=t("./constants"),v=t("./get_legend_data"),y=t("./style"),x=t("./helpers"),b=t("./anchor_utils");e.exports=function(t){function e(t,e){T.attr("data-scroll",e).call(f.setTranslate,0,e),L.call(p.setRect,j,t,m.scrollBarWidth,m.scrollBarHeight),M.select("rect").attr({y:x.borderwidth-e})}var n=t._fullLayout,o="legend"+n._uid;if(n._infolayer&&t.calcdata){var x=n.legend,_=n.showlegend&&v(t.calcdata,x),w=n.hiddenlabels||[];if(!n.showlegend||!_.length)return n._infolayer.selectAll(".legend").remove(),n._topdefs.select("#"+o).remove(),void d.autoMargin(t,"legend");var k=n._infolayer.selectAll("g.legend").data([0]);k.enter().append("g").attr({class:"legend","pointer-events":"all"});var M=n._topdefs.selectAll("#"+o).data([0]);M.enter().append("clipPath").attr("id",o).append("rect");var A=k.selectAll("rect.bg").data([0]);A.enter().append("rect").attr({class:"bg","shape-rendering":"crispEdges"}),A.call(g.stroke,x.bordercolor),A.call(g.fill,x.bgcolor),A.style("stroke-width",x.borderwidth+"px");var T=k.selectAll("g.scrollbox").data([0]);T.enter().append("g").attr("class","scrollbox");var L=k.selectAll("rect.scrollbar").data([0]);L.enter().append("rect").attr({class:"scrollbar",rx:20,ry:2,width:0,height:0}).call(g.fill,"#808BA4");var z=T.selectAll("g.groups").data(_);z.enter().append("g").attr("class","groups"),z.exit().remove();var S=z.selectAll("g.traces").data(f.identity);S.enter().append("g").attr("class","traces"),S.exit().remove(),S.call(y).style("opacity",function(t){var e=t[0].trace;return d.traceIs(e,"pie")?w.indexOf(t[0].label)!==-1?.5:1:"legendonly"===e.visible?.5:1}).each(function(){c.select(this).call(r,t).call(a,t)});var C=0!==k.enter().size();C&&(i(t,z,S),l(t));var E=0,O=n.width,P=0,N=n.height;i(t,z,S),x.height>N?s(t):l(t);var D=n._size,I=D.l+D.w*x.x,R=D.t+D.h*(1-x.y);b.isRightAnchor(x)?I-=x.width:b.isCenterAnchor(x)&&(I-=x.width/2),b.isBottomAnchor(x)?R-=x.height:b.isMiddleAnchor(x)&&(R-=x.height/2);var j=x.width,F=D.w;j>F?(I=D.l,j=F):(I+j>O&&(I=O-j),IB?(R=D.t,q=B):(R+q>N&&(R=N-q),Rn[1])return n[1]}return a}function n(t){return t[0]}var r,a,o=t[0],i=o.trace,l=h.hasMarkers(i),u=h.hasText(i),d=h.hasLines(i);if(l||u||d){var p={},g={};l&&(p.mc=e("marker.color",n),p.mo=e("marker.opacity",c.mean,[.2,1]),p.ms=e("marker.size",c.mean,[2,16]),p.mlc=e("marker.line.color",n),p.mlw=e("marker.line.width",c.mean,[0,5]),g.marker={sizeref:1,sizemin:1,sizemode:"diameter"}),d&&(g.line={width:e("line.width",n,[0,10])}),u&&(p.tx="Aa",p.tp=e("textposition",n),p.ts=10,p.tc=e("textfont.color",n),p.tf=e("textfont.family",n)),r=[c.minExtend(o,p)],a=c.minExtend(i,g)}var m=s.select(this).select("g.legendpoints"),v=m.selectAll("path.scatterpts").data(l?r:[]);v.enter().append("path").classed("scatterpts",!0).attr("transform","translate(20,0)"),v.exit().remove(),v.call(f.pointStyle,a),l&&(r[0].mrc=3);var y=m.selectAll("g.pointtext").data(u?r:[]);y.enter().append("g").classed("pointtext",!0).append("text").attr("transform","translate(20,0)"),y.exit().remove(),y.selectAll("text").call(f.textPointStyle,a)}function o(t){var e=t[0].trace,n=e.marker||{},r=n.line||{},a=s.select(this).select("g.legendpoints").selectAll("path.legendbar").data(u.traceIs(e,"bar")?[t]:[]);a.enter().append("path").classed("legendbar",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),a.exit().remove(),a.each(function(t){var e=(t.mlw+1||r.width+1)-1,a=s.select(this);a.style("stroke-width",e+"px").call(d.fill,t.mc||n.color),e&&a.call(d.stroke,t.mlc||r.color)})}function i(t){var e=t[0].trace,n=s.select(this).select("g.legendpoints").selectAll("path.legendbox").data(u.traceIs(e,"box")&&e.visible?[t]:[]);n.enter().append("path").classed("legendbox",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),n.exit().remove(),n.each(function(t){var n=(t.lw+1||e.line.width+1)-1,r=s.select(this);r.style("stroke-width",n+"px").call(d.fill,t.fc||e.fillcolor),n&&r.call(d.stroke,t.lc||e.line.color)})}function l(t){var e=t[0].trace,n=s.select(this).select("g.legendpoints").selectAll("path.legendpie").data(u.traceIs(e,"pie")&&e.visible?[t]:[]);n.enter().append("path").classed("legendpie",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),n.exit().remove(),n.size()&&n.call(p,t[0],e)}var s=t("d3"),c=t("../../lib"),u=t("../../plots/plots"),f=t("../drawing"),d=t("../color"),h=t("../../traces/scatter/subtypes"),p=t("../../traces/pie/style_one");e.exports=function(t){t.each(function(t){var e=s.select(this),n=e.selectAll("g.legendfill").data([t]);n.enter().append("g").classed("legendfill",!0);var r=e.selectAll("g.legendlines").data([t]);r.enter().append("g").classed("legendlines",!0);var a=e.selectAll("g.legendsymbols").data([t]);a.enter().append("g").classed("legendsymbols",!0),a.style("opacity",t[0].trace.opacity),a.selectAll("g.legendpoints").data([t]).enter().append("g").classed("legendpoints",!0)}).each(o).each(i).each(l).each(r).each(a)}},{"../../lib":102,"../../plots/plots":143,"../../traces/pie/style_one":234,"../../traces/scatter/subtypes":255,"../color":25,"../drawing":48,d3:14}],70:[function(t,e,n){"use strict";function r(t,e){var n=e.currentTarget,r=n.getAttribute("data-attr"),a=n.getAttribute("data-val")||!0,o=t._fullLayout,i={};if("zoom"===r){for(var l,s,u="in"===a?.5:2,f=(1+u)/2,d=(1-u)/2,h=c.Axes.list(t,null,!0),p=0;p1)return r(["resetViews","toggleHover"]),i(m,n);u&&(r(["zoom3d","pan3d","orbitRotation","tableRotation"]),r(["resetCameraDefault3d","resetCameraLastSave3d"]),r(["hoverClosest3d"])),d&&(r(["zoomInGeo","zoomOutGeo","resetGeo"]),r(["hoverClosestGeo"]));var v=a(l),y=[];return((c||p)&&!v||g)&&(y=["zoom2d","pan2d"]),(c||g)&&o(s)&&(y.push("select2d"),y.push("lasso2d")),y.length&&r(y),!c&&!p||v||g||r(["zoomIn2d","zoomOut2d","autoScale2d","resetScale2d"]),c&&h?r(["toggleHover"]):p?r(["hoverClosestGl2d"]):c?r(["hoverClosestCartesian","hoverCompareCartesian"]):h&&r(["hoverClosestPie"]),i(m,n)}function a(t){for(var e=s.Axes.list({_fullLayout:t},null,!0),n=!0,r=0;r0);if(p){var g=a(e,n,s);u("x",g[0]),u("y",g[1]),o.noneOrAll(t,e,["x","y"]),u("xanchor"),u("yanchor"),o.coerceFont(u,"font",n.font);var m=u("bgcolor");u("activecolor",i.contrast(m,c.lightAmount,c.darkAmount)),u("bordercolor"),u("borderwidth")}}},{"../../lib":102,"../color":25,"./attributes":73,"./button_attributes":74,"./constants":75}],77:[function(t,e,n){"use strict";function r(t){for(var e=v.list(t,"x",!0),n=[],r=0;re;a--)h(t,a).selectAll('[data-index="'+(a-1)+'"]').attr("data-index",a),C.draw(t,a)}function f(t,e,n,i){function l(n){var r={"data-index":e,"fill-rule":"evenodd",d:x(t,C)},a=C.line.width?C.line.color:"rgba(0,0,0,0)",o=n.append("path").attr(r).style("opacity",C.opacity).call(T.stroke,a).call(T.fill,C.fillcolor).call(L.dashLine,C.line.dash,C.line.width);E&&o.call(L.setClipUrl,"clip"+t._fullLayout._uid+E),t._context.editable&&d(t,o,C,e)}var s,c;h(t,e).selectAll('[data-index="'+e+'"]').remove();var u=t.layout.shapes[e];if(u){var f={xref:u.xref,yref:u.yref},g={};"string"==typeof n&&n?g[n]=i:M.isPlainObject(n)&&(g=n);var m=Object.keys(g);for(s=0;sG&&r>$&&!t.shiftKey?z.getCursor(a/n,1-o/r):"move";S(e,i),X=i.split("-")[0]}function o(e){B=A.getFromId(t,n.xref),H=A.getFromId(t,n.yref),V=v(t,B),Z=v(t,H,!0),U=y(t,B),Y=y(t,H,!0);var o="shapes["+r+"]";"path"===n.type?(F=n.path,q=o+".path"):(u=V(n.x0),f=Z(n.y0),d=V(n.x1),h=Z(n.y1),p=o+".x0",g=o+".y0",_=o+".x1",w=o+".y1"),u$&&(c[E]=n[D]=Y(l),c[O]=n[I]=Y(s)),f-u>G&&(c[P]=n[R]=U(u),c[N]=n[j]=U(f))}e.attr("d",x(t,n))}var c,u,f,d,h,p,g,_,w,M,T,L,C,E,O,P,N,D,I,R,j,F,q,B,H,V,Z,U,Y,X,G=10,$=10,Q={setCursor:a,element:e.node(),prepFn:o,doneFn:i},W=Q.element.getBoundingClientRect();z.init(Q)}function h(t,e){var n=t._fullLayout.shapes[e],r=t._fullLayout._shapeUpperLayer;return n?"below"===n.layer&&(r="paper"===n.xref&&"paper"===n.yref?t._fullLayout._shapeLowerLayer:t._fullLayout._shapeSubplotLayer):M.log("getShapeLayer: undefined shape: index",e),r}function p(t,e,n){var r=k.Axes.getFromId(t,n.id,"x")._id,a=k.Axes.getFromId(t,n.id,"y")._id,o="below"===e.layer,i=r===e.xref||a===e.yref,l=!!n.shapelayer;return o&&i&&l}function g(t){return function(e){return e.replace&&(e=e.replace("_"," ")),t(e)}}function m(t){return function(e){return t(e).replace(" ","_")}}function v(t,e,n){var r,o=t._fullLayout._size;if(e){var i=a(e);r=function(t){return e._offset+e.l2p(i(t,!0))},"date"===e.type&&(r=g(r))}else r=n?function(t){return o.t+o.h*(1-t)}:function(t){return o.l+o.w*t};return r}function y(t,e,n){var r,a=t._fullLayout._size;if(e){var i=o(e);r=function(t){return i(e.p2l(t-e._offset))}}else r=n?function(t){return 1-(t-a.t)/a.h}:function(t){return(t-a.l)/a.w};return r}function x(t,e){var n,r,o,i,l=e.type,s=A.getFromId(t,e.xref),c=A.getFromId(t,e.yref),u=t._fullLayout._size;if(s?(n=a(s),r=function(t){return s._offset+s.l2p(n(t,!0))}):r=function(t){return u.l+u.w*t},c?(o=a(c),i=function(t){return c._offset+c.l2p(o(t,!0))}):i=function(t){return u.t+u.h*(1-t)},"path"===l)return s&&"date"===s.type&&(r=g(r)),c&&"date"===c.type&&(i=g(i)),C.convertPath(e.path,r,i);var f=r(e.x0),d=r(e.x1),h=i(e.y0),p=i(e.y1);if("line"===l)return"M"+f+","+h+"L"+d+","+p;if("rect"===l)return"M"+f+","+h+"H"+d+"V"+p+"H"+f+"Z";var m=(f+d)/2,v=(h+p)/2,y=Math.abs(m-f),x=Math.abs(v-h),b="A"+y+","+x,_=m+y+","+v,w=m+","+(v-x);return"M"+_+b+" 0 1,1 "+w+b+" 0 0,1 "+_+"Z"}function b(t,e,n){return t.replace(E,function(t){var r=0,a=t.charAt(0),o=P[a],i=N[a],l=D[a],s=t.substr(1).replace(O,function(t){return r>=l?t:(o[r]?t=e(t):i[r]&&(t=n(t)),r++,t)});return a+s})}function _(t,e,n,r,a){var o="category"===t.type?Number:t.d2c;if(void 0!==e)return[o(e),o(n)];if(r){var i,l,s,c,u,f=1/0,d=-(1/0),h=r.match(E);for("date"===t.type&&(o=g(o)),i=0;id&&(d=u)));return d>=f?[f,d]:void 0}}var w=t("fast-isnumeric"),k=t("../../plotly"),M=t("../../lib"),A=t("../../plots/cartesian/axes"),T=t("../color"),L=t("../drawing"),z=t("../dragelement"),S=t("../../lib/setcursor"),C=e.exports={};C.layoutAttributes=t("./attributes"),C.supplyLayoutDefaults=function(t,e){for(var n=t.shapes||[],a=e.shapes=[],o=0;ol&&(t="X"),t});return r>l&&(s=s.replace(/[\s,]*X.*/,""),M.log("Ignoring extra params in segment "+t)),a+s})},C.calcAutorange=function(t){var e,n,r,a,o,i=t._fullLayout,l=i.shapes;if(l.length&&t._fullData.length)for(e=0;e0||d<0){var h={left:[-n,0],right:[n,0],top:[0,-n],bottom:[0,n]}[x.side];e.attr("transform","translate("+h+")")}}}function p(){L=0,z=!0,S=E,k._infolayer.select("."+e).attr({"data-unformatted":S}).text(S).on("mouseover.opacity",function(){r.select(this).transition().duration(100).style("opacity",1)}).on("mouseout.opacity",function(){r.select(this).transition().duration(1e3).style("opacity",0)})}var g=n.propContainer,m=n.propName,v=n.traceIndex,y=n.dfltName,x=n.avoid||{},b=n.attributes,_=n.transform,w=n.containerGroup,k=t._fullLayout,M=g.titlefont.family,A=g.titlefont.size,T=g.titlefont.color,L=1,z=!1,S=g.title.trim();""===S&&(L=0),S.match(/Click to enter .+ title/)&&(L=.2,z=!0),w||(w=k._infolayer.selectAll(".g-"+e).data([0]),w.enter().append("g").classed("g-"+e,!0));var C=w.selectAll("text").data([0]);C.enter().append("text"),C.text(S).attr("class",e),C.attr({"data-unformatted":S}).call(f);var E="Click to enter "+y+" title";t._context.editable?(S||p(),C.call(u.makeEditable).on("edit",function(e){void 0!==v?o.restyle(t,m,e,v):o.relayout(t,m,e)}).on("cancel",function(){this.text(this.attr("data-unformatted")).call(f)}).on("input",function(t){this.text(t||" ").attr(b).selectAll("tspan.line").attr(b)})):S&&!S.match(/Click to enter .+ title/)||C.remove(),C.classed("js-placeholder",z)}},{"../../lib":102,"../../lib/svg_text_utils":113,"../../plotly":120,"../../plots/plots":143,"../color":25,"../drawing":48,d3:14,"fast-isnumeric":17}],89:[function(t,e,n){"use strict";var r=t("../../plots/font_attributes"),a=t("../color/attributes"),o=t("../../lib/extend").extendFlat,i={_isLinkedToArray:!0,method:{valType:"enumerated",values:["restyle","relayout"],dflt:"restyle"},args:{valType:"info_array",freeLength:!0,items:[{valType:"any"},{valType:"any"},{valType:"any"}]},label:{valType:"string",dflt:""}};e.exports={_isLinkedToArray:!0,visible:{valType:"boolean"},active:{valType:"integer",min:-1,dflt:0},buttons:i,x:{valType:"number",min:-2,max:3,dflt:-.05},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"right"},y:{valType:"number",min:-2,max:3,dflt:1},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"bottom"},font:o({},r,{}),bgcolor:{valType:"color"},bordercolor:{valType:"color",dflt:a.borderLine},borderwidth:{valType:"number",min:0,dflt:1}}},{"../../lib/extend":100,"../../plots/font_attributes":141,"../color/attributes":24}],90:[function(t,e,n){"use strict";e.exports={name:"updatemenus",itemName:"updatemenu",containerClassName:"updatemenu-container",headerGroupClassName:"updatemenu-header-group",headerClassName:"updatemenu-header",headerArrowClassName:"updatemenu-header-arrow",buttonGroupClassName:"updatemenu-button-group",buttonClassName:"updatemenu-button",itemRectClassName:"updatemenu-item-rect",itemTextClassName:"updatemenu-item-text",menuIndexAttrName:"updatemenu-active-index",autoMarginIdRoot:"updatemenu-",blankHeaderOpts:{label:" "},minWidth:30,minHeight:30,textPadX:40,fontSizeToHeight:1.3,rx:2,ry:2,textOffsetX:12,textOffsetY:3,arrowOffsetX:4,gapButtonHeader:5,gapButton:2,activeColor:"#F4FAFF",hoverColor:"#F4FAFF"}},{}],91:[function(t,e,n){"use strict";function r(t,e,n){function r(n,r){return o.coerce(t,e,i,n,r)}var l=a(t,e),s=r("visible",l.length>0);s&&(r("active"),r("x"),r("y"),o.noneOrAll(t,e,["x","y"]),r("xanchor"),r("yanchor"),o.coerceFont(r,"font",n.font),r("bgcolor",n.paper_bgcolor),r("bordercolor"),r("borderwidth"))}function a(t,e){function n(t,e){return o.coerce(r,a,c,t,e)}for(var r,a,i=t.buttons||[],l=e.buttons=[],s=0;s0?[0]:[]);if(s.enter().append("g").classed(T.containerClassName,!0).style("cursor","pointer"),s.exit().remove(),s.exit().size()&&v(t),0!==n.length){var c=s.selectAll("g."+T.headerGroupClassName).data(n,a);c.enter().append("g").classed(T.headerGroupClassName,!0);var u=s.selectAll("g."+T.buttonGroupClassName).data([0]);u.enter().append("g").classed(T.buttonGroupClassName,!0).style("pointer-events","all"),c.enter().size()&&u.call(m).attr(T.menuIndexAttrName,"-1"),c.exit().each(function(e){y.select(this).remove(),u.call(m).attr(T.menuIndexAttrName,"-1"),b.autoMargin(t,T.autoMarginIdRoot+e._index)});for(var f=0;fa.max?e.set(n):e.set(+t)}},integer:{coerceFunction:function(t,e,n,a){t%1||!r(t)||void 0!==a.min&&ta.max?e.set(n):e.set(+t)}},string:{coerceFunction:function(t,e,n,r){if("string"!=typeof t){var a="number"==typeof t;r.strict!==!0&&a?e.set(String(t)):e.set(n)}else r.noBlank&&!t?e.set(n):e.set(t)}},color:{coerceFunction:function(t,e,n){a(t).isValid()?e.set(t):e.set(n)}},colorscale:{coerceFunction:function(t,e,n){e.set(i(t,n))}},angle:{coerceFunction:function(t,e,n){"auto"===t?e.set("auto"):r(t)?(Math.abs(t)>180&&(t-=360*Math.round(t/360)),e.set(+t)):e.set(n)}},subplotid:{coerceFunction:function(t,e,n){var r=n.length;return"string"==typeof t&&t.substr(0,r)===n&&l.test(t.substr(r))?void e.set(t):void e.set(n)},validateFunction:function(t,e){var n=e.dflt,r=n.length;return t===n||"string"==typeof t&&!(t.substr(0,r)!==n||!l.test(t.substr(r)))}},flaglist:{coerceFunction:function(t,e,n,r){if("string"!=typeof t)return void e.set(n);if((r.extras||[]).indexOf(t)!==-1)return void e.set(t);for(var a=t.split("+"),o=0;o2)return!1;var i=o[0].split("-");if(i.length>3||3!==i.length&&o[1])return!1;if(4===i[0].length)e=Number(i[0]);else{if(2!==i[0].length)return!1;var s=(new Date).getFullYear();e=((Number(i[0])-s+70)%100+200)%100+s-70}return!!l(e)&&(1===i.length?new Date(e,0,1).getTime():(n=Number(i[1])-1,!(i[1].length>2)&&n>=0&&n<=11&&(2===i.length?new Date(e,n,1).getTime():(r=Number(i[2]),!(i[2].length>2)&&r>=1&&r<=31&&(r=new Date(e,n,r).getTime(),o[1]?(i=o[1].split(":"),!(i.length>3)&&(a=Number(i[0]),!(i[0].length>2)&&a>=0&&a<=23&&(r+=36e5*a,1===i.length?r:(n=Number(i[1]),!(i[1].length>2)&&n>=0&&n<=59&&(r+=6e4*n,2===i.length?r:(t=Number(i[2]),t>=0&&t<60&&r+1e3*t)))))):r)))))},n.isDateTime=function(t){return n.dateTime2ms(t)!==!1},n.ms2DateTime=function(t,e){if("undefined"==typeof i)return void s.error("d3 is not defined.");e||(e=0);var n=new Date(t),a=i.time.format("%Y-%m-%d")(n);return e<7776e6?(a+=" "+r(n.getHours(),2),e<432e6&&(a+=":"+r(n.getMinutes(),2),e<108e5&&(a+=":"+r(n.getSeconds(),2),e<3e5&&(a+="."+r(n.getMilliseconds(),3)))),a.replace(/([:\s]00)*\.?[0]*$/,"")):a};var c={H:["%H:%M:%S~%L","%H:%M:%S","%H:%M"],I:["%I:%M:%S~%L%p","%I:%M:%S%p","%I:%M%p"],D:["%H","%I%p","%Hh"]},u={Y:["%Y~%m~%d","%Y%m%d","%y%m%d","%m~%d~%Y","%d~%m~%Y"],Yb:["%b~%d~%Y","%d~%b~%Y","%Y~%d~%b","%Y~%b~%d"],y:["%m~%d~%y","%d~%m~%y","%y~%m~%d"],yb:["%b~%d~%y","%d~%b~%y","%y~%d~%b","%y~%b~%d"]},f=i.time.format.utc,d={Y:{H:["%Y~%m~%dT%H:%M:%S","%Y~%m~%dT%H:%M:%S~%L"].map(f),I:[],D:["%Y%m%d%H%M%S","%Y~%m","%m~%Y"].map(f)},Yb:{H:[],I:[],D:["%Y~%b","%b~%Y"].map(f)},y:{H:[],I:[],D:[]},yb:{H:[],I:[],D:[]}};["Y","Yb","y","yb"].forEach(function(t){u[t].forEach(function(e){d[t].D.push(f(e)),["H","I","D"].forEach(function(n){c[n].forEach(function(r){var a=d[t][n];a.push(f(e+"~"+r)),a.push(f(r+"~"+e))})})})});var h=/[a-z]*/g,p=function(t){return t.substr(0,3)},g=/(mon|tue|wed|thu|fri|sat|sun|the|of|st|nd|rd|th)/g,m=/[\s,\/\-\.\(\)]+/g,v=/~?([ap])~?m(~|$)/,y=function(t,e){return e+"m "},x=/\d\d\d\d/,b=/(^|~)[a-z]{3}/,_=/[ap]m/,w=/:/,k=/q([1-4])/,M=["31~mar","30~jun","30~sep","31~dec"],A=function(t,e){return M[e-1]},T=/ ?([+\-]\d\d:?\d\d|Z)$/;n.parseDate=function(t){if(t.getTime)return t;if("string"!=typeof t)return!1;t=t.toLowerCase().replace(h,p).replace(g,"").replace(m,"~").replace(v,y).replace(k,A).trim().replace(T,"");var e,n,r=null,i=a(t),l=o(t);e=d[i][l],n=e.length;for(var s=0;sn?Math.max(n,Math.min(e,t)):Math.max(e,Math.min(n,t))},a.bBoxIntersect=function(t,e,n){return n=n||0,t.left<=e.right+n&&e.left<=t.right+n&&t.top<=e.bottom+n&&e.top<=t.bottom+n},a.identity=function(t){return t},a.randstr=function t(e,n,r){if(r||(r=16),void 0===n&&(n=24),n<=0)return"0";var a,o,i,l=Math.log(Math.pow(2,n))/Math.log(r),s="";for(a=2;l===1/0;a*=2)l=Math.log(Math.pow(2,n/a))/Math.log(r)*a;var c=l-Math.floor(l);for(a=0;a-1||u!==1/0&&u>=Math.pow(2,n)?t(e,n,r):s},a.OptionControl=function(t,e){t||(t={}),e||(e="opt");var n={};return n.optionList=[],n._newoption=function(r){r[e]=t,n[r.name]=r,n.optionList.push(r)},n["_"+e]=t,n},a.smooth=function(t,e){if(e=Math.round(e)||0,e<2)return t;var n,r,a,o,i=t.length,l=2*i,s=2*e-1,c=new Array(s),u=new Array(i);for(n=0;n=l&&(a-=l*Math.floor(a/l)),a<0?a=-1-a:a>=i&&(a=l-1-a),o+=t[a]*c[r];u[n]=o}return u},a.syncOrAsync=function(t,e,n){function r(){return a.syncOrAsync(t,e,n)}for(var o,i;t.length;)if(i=t.splice(0,1)[0],o=i(e),o&&o.then)return o.then(r).then(void 0,a.promiseError);return n&&n(e)},a.stripTrailingSlash=function(t){return"/"===t.substr(-1)?t.substr(0,t.length-1):t},a.noneOrAll=function(t,e,n){if(t){var r,a,o=!1,i=!0;for(r=0;r1?r+o[1]:"";if(a&&(o.length>1||i.length>4))for(;n.test(i);)i=i.replace(n,"$1"+a+"$2");return i+l}},{"./coerce":97,"./dates":98,"./extend":100,"./is_plain_object":103,"./loggers":104,"./matrix":105,"./nested_property":106,"./notifier":107,"./search":110,"./stats":112,d3:14}],103:[function(t,e,n){"use strict";e.exports=function(t){return window&&window.process&&window.process.versions?"[object Object]"===Object.prototype.toString.call(t):"[object Object]"===Object.prototype.toString.call(t)&&Object.getPrototypeOf(t)===Object.prototype}},{}],104:[function(t,e,n){"use strict";var r=t("../plot_api/plot_config"),a=e.exports={};a.log=function(){if(r.logging>1){for(var t=["LOG:"],e=0;e0){for(var t=["WARN:"],e=0;e0){for(var t=["ERROR:"],e=0;e=0;e--){if(r=t[e],i=!1,Array.isArray(r))for(n=r.length-1;n>=0;n--)c(r[n])?i?r[n]=void 0:r.pop():i=!0;else if("object"==typeof r&&null!==r)for(o=Object.keys(r),i=!1,n=o.length-1;n>=0;n--)c(r[o[n]])&&!a(r[o[n]],o[n])?delete r[o[n]]:i=!0;if(i)return}}function c(t){return void 0===t||null===t||"object"==typeof t&&(Array.isArray(t)?!t.length:!Object.keys(t).length)}function u(t,e,n){return{set:function(){throw"bad container"},get:function(){},astr:e,parts:n,obj:t}}var f=t("fast-isnumeric");e.exports=function(t,e){if(f(e))e=String(e);else if("string"!=typeof e||"[-1]"===e.substr(e.length-4))throw"bad property string";for(var n,a,i,l=0,s=e.split(".");lo||rl)&&(!e||!c(t))}function n(t,e){var n=t[0],s=t[1];if(no||sl)return!1;var c,u,f,d,h,p=r.length,g=r[0][0],m=r[0][1],v=0;for(c=1;cMath.max(u,g)||s>Math.max(f,m)))if(su||Math.abs(r(i,d))>a)return!0;return!1};a.filter=function(t,e){function n(n){t.push(n);var l=r.length,s=a;r.splice(i+1);for(var c=s+1;c1){var l=t.pop();n(l)}return{addPt:n,raw:t,filtered:r}}},{"./matrix":105}],109:[function(t,e,n){"use strict";function r(t,e){for(var n,r=[],o=0;oo.queueLength&&(t.undoQueue.queue.shift(),t.undoQueue.index--)))},i.startSequence=function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!0,t.undoQueue.beginSequence=!0},i.stopSequence=function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!1,t.undoQueue.beginSequence=!1},i.undo=function(t){var e,n;if(t.framework&&t.framework.isPolar)return void t.framework.undo();if(!(void 0===t.undoQueue||isNaN(t.undoQueue.index)||t.undoQueue.index<=0)){for(t.undoQueue.index--,e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,n=0;n=t.undoQueue.queue.length)){for(e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,n=0;ne}function i(t,e){return t>=e}var l=t("fast-isnumeric"),s=t("../lib");n.findBin=function(t,e,n){if(l(e.start))return n?Math.ceil((t-e.start)/e.size)-1:Math.floor((t-e.start)/e.size);var c,u,f=0,d=e.length,h=0;for(u=e[e.length-1]>=e[0]?n?r:a:n?i:o;f90&&s.log("Long binary search..."),f-1},n.sorterAsc=function(t,e){return t-e},n.sorterDes=function(t,e){return e-t},n.distinctVals=function(t){var e=t.slice();e.sort(n.sorterAsc);for(var r=e.length-1,a=e[r]-e[0]||1,o=a/(r||1)/1e4,i=[e[0]],l=0;le[l]+o&&(a=Math.min(a,e[l+1]-e[l]),i.push(e[l+1]));return{vals:i,minDiff:a}},n.roundUp=function(t,e,n){for(var r,a=0,o=e.length-1,i=0,l=n?0:1,s=n?1:0,c=n?Math.ceil:Math.floor;at.length-1)return t[t.length-1];var n=e%1;return n*t[Math.ceil(e)]+(1-n)*t[Math.floor(e)]}},{"fast-isnumeric":17}],113:[function(t,e,n){"use strict";function r(t,e){return t.node().getBoundingClientRect()[e]}function a(t){return t.replace(/(<|<|<)/g,"\\lt ").replace(/(>|>|>)/g,"\\gt ")}function o(t,e,n){var r="math-output-"+c.Lib.randstr([],64),o=u.select("body").append("div").attr({id:r}).style({visibility:"hidden",position:"absolute"}).style({"font-size":e.fontSize+"px"}).text(a(t));MathJax.Hub.Queue(["Typeset",MathJax.Hub,o.node()],function(){var e=u.select("body").select("#MathJax_SVG_glyphs");if(o.select(".MathJax_SVG").empty()||!o.select("svg").node())f.log("There was an error in the tex syntax.",t),n();else{var r=o.select("svg").node().getBoundingClientRect();n(o.select(".MathJax_SVG"),e,r)}o.remove()})}function i(t){return(t||"").replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")}function l(t){for(var e=t.split(/(<[^<>]*>)/).map(function(t){var e=t.match(/<(\/?)([^ >]*)\s*(.*)>/i),n=e&&e[2].toLowerCase(),r=p[n];if(void 0!==r){var a=e[1],o=e[3],l=o.match(/^style\s*=\s*"([^"]+)"\s*/i);if("a"===n){if(a)return"
";if("href"!==o.substr(0,4).toLowerCase())return"";var s=o.substr(4).replace(/["']/g,"").replace(/=/,""),u=document.createElement("a");return u.href=s,g.indexOf(u.protocol)===-1?"":''}if("br"===n)return"
";if(a)return"sup"===n?'':"sub"===n?'':"";var f=""}return c.util.xml_entity_encode(t).replace(/");r>0;r=e.indexOf("
",r+1))n.push(r);var a=0;n.forEach(function(t){for(var n=t+a,r=e.slice(0,n),o="",i=r.length-1;i>=0;i--){var l=r[i].match(/<(\/?).*>/i);if(l&&"
"!==r[i]){l[1]||(o=r[i]);break}}o&&(e.splice(n+1,0,o),e.splice(n,0,""),a+=2)});var o=e.join(""),l=o.split(/
/gi);return l.length>1&&(e=l.map(function(t,e){return''+t+""})),e.join("")}function s(t,e,n){var r,a,o,i=n.horizontalAlign,l=n.verticalAlign||"top",s=t.node().getBoundingClientRect(),c=e.node().getBoundingClientRect();return a="bottom"===l?function(){return s.bottom-r.height}:"middle"===l?function(){return s.top+(s.height-r.height)/2}:function(){return s.top},o="right"===i?function(){return s.right-r.width}:"center"===i?function(){return s.left+(s.width-r.width)/2}:function(){return s.left},function(){return r=this.node().getBoundingClientRect(),this.style({top:a()-c.top+"px",left:o()-c.left+"px","z-index":1e3}),this}}var c=t("../plotly"),u=t("d3"),f=t("../lib"),d=t("../constants/xmlns_namespaces"),h=e.exports={};u.selection.prototype.appendSVG=function(t){for(var e=['',t,""].join(""),n=(new DOMParser).parseFromString(e,"application/xml"),r=n.documentElement.firstChild;r;)this.node().appendChild(this.node().ownerDocument.importNode(r,!0)),r=r.nextSibling;return n.querySelector("parsererror")?(f.log(n.querySelector("parsererror div").textContent),null):u.select(this.node().lastChild)},h.html_entity_decode=function(t){var e=u.select("body").append("div").style({display:"none"}).html(""),n=t.replace(/(&[^;]*;)/gi,function(t){return"<"===t?"<":"&rt;"===t?">":e.html(t).text()});return e.remove(),n},h.xml_entity_encode=function(t){return t.replace(/&(?!\w+;|\#[0-9]+;| \#x[0-9A-F]+;)/g,"&")},h.convertToTspans=function(t,e){function n(){h.empty()||(p=s.attr("class")+"-math",h.select("svg."+p).remove()),t.text("").style({visibility:"visible","white-space":"pre"}),d=t.appendSVG(i),d||t.text(a),t.select("a").size()&&t.style("pointer-events","all"),e&&e.call(s)}var a=t.text(),i=l(a),s=t,f=!s.attr("data-notex")&&i.match(/([^$]*)([$]+[^$]*[$]+)([^$]*)/),d=a,h=u.select(s.node().parentNode);if(!h.empty()){var p=s.attr("class")?s.attr("class").split(" ")[0]:"text";p+="-math",h.selectAll("svg."+p).remove(),h.selectAll("g."+p+"-group").remove(),t.style({visibility:null});for(var g=t.node();g&&g.removeAttribute;g=g.parentNode)g.removeAttribute("data-bb");if(f){var m=c.Lib.getPlotDiv(s.node());(m&&m._promises||[]).push(new Promise(function(t){s.style({visibility:"hidden"});var a={fontSize:parseInt(s.style("font-size"),10)};o(f[2],a,function(a,o,i){h.selectAll("svg."+p).remove(),h.selectAll("g."+p+"-group").remove();var l=a&&a.select("svg");if(!l||!l.node())return n(),void t();var c=h.append("g").classed(p+"-group",!0).attr({"pointer-events":"none"});c.node().appendChild(l.node()),o&&o.node()&&l.node().insertBefore(o.node().cloneNode(!0),l.node().firstChild),l.attr({class:p,height:i.height,preserveAspectRatio:"xMinYMin meet"}).style({overflow:"visible","pointer-events":"none"});var u=s.style("fill")||"black";l.select("g").attr({fill:u,stroke:u});var f=r(l,"width"),d=r(l,"height"),g=+s.attr("x")-f*{start:0,middle:.5,end:1}[s.attr("text-anchor")||"start"],m=parseInt(s.style("font-size"),10)||r(s,"height"),v=-m/4;"y"===p[0]?(c.attr({transform:"rotate("+[-90,+s.attr("x"),+s.attr("y")]+") translate("+[-f/2,v-d/2]+")"}),l.attr({x:+s.attr("x"),y:+s.attr("y")})):"l"===p[0]?l.attr({x:s.attr("x"),y:v-d/2}):"a"===p[0]?l.attr({x:0,y:v}):l.attr({x:g,y:+s.attr("y")+v-d/2}),e&&e.call(s,c),t(c)})}))}else n();return t}};var p={sup:'font-size:70%" dy="-0.6em',sub:'font-size:70%" dy="0.3em',b:"font-weight:bold",i:"font-style:italic",a:"",span:"",br:"",em:"font-style:italic;font-weight:bold"},g=["http:","https:","mailto:"],m=new RegExp("]*)?/?>","g");h.plainText=function(t){return(t||"").replace(m," ")},h.makeEditable=function(t,e,n){function r(){o(),i.style({opacity:0});var t,e=d.attr("class");t=e?"."+e.split(" ")[0]+"-math-group":"[class*=-math-group]",t&&u.select(i.node().parentNode).select(t).style({opacity:0})}function a(t){var e=t.node(),n=document.createRange();n.selectNodeContents(e);var r=window.getSelection();r.removeAllRanges(),r.addRange(n),e.focus()}function o(){var t=u.select(c.Lib.getPlotDiv(i.node())),e=t.select(".svg-container"),r=e.append("div");r.classed("plugin-editable editable",!0).style({position:"absolute","font-family":i.style("font-family")||"Arial","font-size":i.style("font-size")||12,color:n.fill||i.style("fill")||"black",opacity:1,"background-color":n.background||"transparent",outline:"#ffffff33 1px solid",margin:[-parseFloat(i.style("font-size"))/8+1,0,0,-1].join("px ")+"px",padding:"0","box-sizing":"border-box"}).attr({contenteditable:!0}).text(n.text||i.attr("data-unformatted")).call(s(i,e,n)).on("blur",function(){i.text(this.textContent).style({opacity:1});var t,e=u.select(this).attr("class");t=e?"."+e.split(" ")[0]+"-math-group":"[class*=-math-group]",t&&u.select(i.node().parentNode).select(t).style({opacity:0});var n=this.textContent;u.select(this).transition().duration(0).remove(),u.select(document).on("mouseup",null),l.edit.call(i,n)}).on("focus",function(){var t=this;u.select(document).on("mouseup",function(){return u.event.target!==t&&void(document.activeElement===r.node()&&r.node().blur())})}).on("keyup",function(){27===u.event.which?(i.style({opacity:1}),u.select(this).style({opacity:0}).on("blur",function(){return!1}).transition().remove(),l.cancel.call(i,this.textContent)):(l.input.call(i,this.textContent),u.select(this).call(s(i,e,n)))}).on("keydown",function(){13===u.event.which&&this.blur()}).call(a)}n||(n={});var i=this,l=u.dispatch("edit","input","cancel"),f=u.select(this.node()).style({"pointer-events":"all"}),d=e||f;return e&&f.style({"pointer-events":"none"}),n.immediate?r():d.on("click",r),u.rebind(this,l,"on")}},{"../constants/xmlns_namespaces":94,"../lib":102,"../plotly":120,d3:14}],114:[function(t,e,n){"use strict";function r(t){var e;if("string"==typeof t){if(e=document.getElementById(t),null===e)throw new Error("No DOM element with id '"+t+"' exists on the page.");return e}if(null===t||void 0===t)throw new Error("DOM element provided is null or undefined");return t}function a(t){Array.isArray(t._promises)&&t._promises.length>0&&N.log("Clearing previous rejected promises from queue."),t._promises=[]}function o(t,e){t._fullLayout._paperdiv.style("background","white"),P.defaultConfig.setBackground(t,e)}function i(t,e){t._context||(t._context=N.extendFlat({},P.defaultConfig));var n=t._context;e&&(Object.keys(e).forEach(function(t){t in n&&("setBackground"===t&&"opaque"===e[t]?n[t]=o:n[t]=e[t])}),e.plot3dPixelRatio&&!n.plotGlPixelRatio&&(n.plotGlPixelRatio=n.plot3dPixelRatio)),n.staticPlot&&(n.editable=!1,n.autosizable=!1,n.scrollZoom=!1,n.doubleClick=!1,n.showTips=!1,n.showLink=!1,n.displayModeBar=!1)}function l(t,e,n){var r=C.select(t).selectAll(".plot-container").data([0]);r.enter().insert("div",":first-child").classed("plot-container plotly",!0);var a=r.selectAll(".svg-container").data([0]);a.enter().append("div").classed("svg-container",!0).style("position","relative"),a.html(""),e&&(t.data=e),n&&(t.layout=n),P.micropolar.manager.fillLayout(t),"initial"===t._fullLayout.autosize&&t._context.autosizable&&(k(t,{}),t._fullLayout.autosize=n.autosize=!0),a.style({width:t._fullLayout.width+"px",height:t._fullLayout.height+"px"}),t.framework=P.micropolar.manager.framework(t),t.framework({data:t.data,layout:t.layout},a.node()),t.framework.setUndoPoint();var o=t.framework.svg(),i=1,l=t._fullLayout.title;""!==l&&l||(i=0);var s="Click to enter title",c=function(){this.call(P.util.convertToTspans)},u=o.select(".title-group text").call(c);if(t._context.editable){u.attr({"data-unformatted":l ++}),l&&l!==s||(i=.2,u.attr({"data-unformatted":s}).text(s).style({opacity:i}).on("mouseover.opacity",function(){C.select(this).transition().duration(100).style("opacity",1)}).on("mouseout.opacity",function(){C.select(this).transition().duration(1e3).style("opacity",0)}));var f=function(){this.call(P.util.makeEditable).on("edit",function(e){t.framework({layout:{title:e}}),this.attr({"data-unformatted":e}).text(e).call(c),this.call(f)}).on("cancel",function(){var t=this.attr("data-unformatted");this.text(t).call(c)})};u.call(f)}return t._context.setBackground(t,t._fullLayout.paper_bgcolor),R.addLinks(t),Promise.resolve()}function s(t){var e,n;t||(t={}),t.xaxis1&&(t.xaxis||(t.xaxis=t.xaxis1),delete t.xaxis1),t.yaxis1&&(t.yaxis||(t.yaxis=t.yaxis1),delete t.yaxis1);var r=P.Axes.list({_fullLayout:t});for(e=0;e3?(u.x=1.02,u.xanchor="left"):u.x<-2&&(u.x=-.02,u.xanchor="right"),u.y>3?(u.y=1.02,u.yanchor="bottom"):u.y<-2&&(u.y=-.02,u.yanchor="top")),"rotate"===t.dragmode&&(t.dragmode="orbit"),t.scene1&&(t.scene||(t.scene=t.scene1),delete t.scene1);var f=R.getSubplotIds(t,"gl3d");for(e=0;e=t.data.length||a<-t.data.length)throw new Error(n+" must be valid indices for gd.data.");if(e.indexOf(a,r+1)>-1||a>=0&&e.indexOf(-t.data.length+a)>-1||a<0&&e.indexOf(t.data.length+a)>-1)throw new Error("each index in "+n+" must be unique.")}}function m(t,e,n){if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("currentIndices is a required argument.");if(Array.isArray(e)||(e=[e]),g(t,e,"currentIndices"),"undefined"==typeof n||Array.isArray(n)||(n=[n]),"undefined"!=typeof n&&g(t,n,"newIndices"),"undefined"!=typeof n&&e.length!==n.length)throw new Error("current and new indices must be of equal length.")}function v(t,e,n){var r,a;if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("traces must be defined.");for(Array.isArray(e)||(e=[e]),r=0;r=0&&s0){var l=w(t._boundingBoxMargins),s=l.left+l.right,c=l.bottom+l.top,u=o._container.node().getBoundingClientRect(),f=1-2*i.frameMargins;a=Math.round(f*(u.width-s)),r=Math.round(f*(u.height-c))}else n=window.getComputedStyle(t),r=parseFloat(n.height)||o.height,a=parseFloat(n.width)||o.width;return Math.abs(o.width-a)>1||Math.abs(o.height-r)>1?(o.height=t.layout.height=r,o.width=t.layout.width=a):"initial"!==o.autosize&&(delete e.autosize,o.autosize=t.layout.autosize=!0),R.sanitizeMargins(o),e}function M(t){var e=C.select(t),n=t._fullLayout;if(n._container=e.selectAll(".plot-container").data([0]),n._container.enter().insert("div",":first-child").classed("plot-container",!0).classed("plotly",!0),n._paperdiv=n._container.selectAll(".svg-container").data([0]),n._paperdiv.enter().append("div").classed("svg-container",!0).style("position","relative"),"initial"===n.autosize&&(k(t,{}),n.autosize=!0,t.layout.autosize=!0),n._glcontainer=n._paperdiv.selectAll(".gl-container").data([0]),n._glcontainer.enter().append("div").classed("gl-container",!0),n._geocontainer=n._paperdiv.selectAll(".geo-container").data([0]),n._geocontainer.enter().append("div").classed("geo-container",!0),n._paperdiv.selectAll(".main-svg").remove(),n._paper=n._paperdiv.insert("svg",":first-child").classed("main-svg",!0),n._toppaper=n._paperdiv.append("svg").classed("main-svg",!0),!n._uid){var r=[];C.selectAll("defs").each(function(){this.id&&r.push(this.id.split("-")[1])}),n._uid=N.randstr(r)}n._paperdiv.selectAll(".main-svg").attr(Q.svgAttrs),n._defs=n._paper.append("defs").attr("id","defs-"+n._uid),n._topdefs=n._toppaper.append("defs").attr("id","topdefs-"+n._uid),n._draggers=n._paper.append("g").classed("draglayer",!0);var a=n._paper.append("g").classed("layer-below",!0);n._imageLowerLayer=a.append("g").classed("imagelayer",!0),n._shapeLowerLayer=a.append("g").classed("shapelayer",!0);var o=P.Axes.getSubplots(t);o.join("")!==Object.keys(t._fullLayout._plots||{}).join("")&&A(t,o),n._has("cartesian")&&T(t,o),n._ternarylayer=n._paper.append("g").classed("ternarylayer",!0);var i=n._paper.selectAll(".layer-subplot");n._imageSubplotLayer=i.selectAll(".imagelayer"),n._shapeSubplotLayer=i.selectAll(".shapelayer");var l=n._paper.append("g").classed("layer-above",!0);n._imageUpperLayer=l.append("g").classed("imagelayer",!0),n._shapeUpperLayer=l.append("g").classed("shapelayer",!0),n._pielayer=n._paper.append("g").classed("pielayer",!0),n._glimages=n._paper.append("g").classed("glimages",!0),n._geoimages=n._paper.append("g").classed("geoimages",!0),n._infolayer=n._toppaper.append("g").classed("infolayer",!0),n._zoomlayer=n._toppaper.append("g").classed("zoomlayer",!0),n._hoverlayer=n._toppaper.append("g").classed("hoverlayer",!0),t.emit("plotly_framework");var s=N.syncOrAsync([L,function(){return P.Axes.doTicks(t,"redraw")},j.init],t);return s&&s.then&&t._promises.push(s),s}function A(t,e){function n(e,n){return function(){return P.Axes.getFromId(t,e,n)}}for(var r,a,o=t._fullLayout._plots={},i=0;i0,_=P.Axes.getSubplots(t).join(""),w=Object.keys(t._fullLayout._plots||{}).join(""),k=w===_;b?t.framework===M&&!x&&k||(t.framework=M,M(t)):k?x&&M(t):(t.framework=M,M(t)),x&&P.Axes.saveRangeInitial(t);var A=t._fullLayout,T=!t.calcdata||t.calcdata.length!==(t.data||[]).length;T&&h(t);for(var z=0;zQ.range[0]?[1,2]:[2,1]);else{var W=Q.range[0],J=Q.range[1];"log"===F?(W<=0&&J<=0&&i(Y+".autorange",!0),W<=0?W=J/1e6:J<=0&&(J=W/1e6),i(Y+".range[0]",Math.log(W)/Math.LN10),i(Y+".range[1]",Math.log(J)/Math.LN10)):(i(Y+".range[0]",Math.pow(10,W)),i(Y+".range[1]",Math.pow(10,J)))}else i(Y+".autorange",!0)}if("reverse"===Z)X.range?X.range.reverse():(i(Y+".autorange",!0),X.range=[1,0]),G.autorange?M=!0:w=!0;else if("annotations"===j.parts[0]||"shapes"===j.parts[0]){var K=j.parts[1],tt=j.parts[0],et=m[tt]||[],nt=P[N.titleCase(tt)],rt=et[K]||{};2===j.parts.length&&("add"===y[O]||N.isPlainObject(y[O])?C[O]="remove":"remove"===y[O]?K===-1?(C[tt]=et,delete C[O]):C[O]=rt:N.log("???",y)),!l(rt,"x")&&!l(rt,"y")||N.containsAny(O,["color","opacity","align","dash"])||(M=!0),nt.draw(e,K,j.parts.slice(2).join("."),y[O]),delete y[O]}else if("images"===j.parts[0]){var at=N.objectFromPath(O,F);N.extendDeepAll(e.layout,at),H.supplyLayoutDefaults(e.layout,e._fullLayout),H.draw(e)}else if("mapbox"===j.parts[0]&&"layers"===j.parts[1]){N.extendDeepAll(e.layout,N.objectFromPath(O,F));var ot=(e._fullLayout.mapbox||{}).layers||[];for(D=j.parts[2]+1-ot.length,g=0;g1&&N.containsAny(j.parts[1],["tick","exponent","grid","zeroline"])?b=!0:O.indexOf(".linewidth")!==-1&&O.indexOf("axis")!==-1?b=_=!0:j.parts.length>1&&j.parts[1].indexOf("line")!==-1?_=!0:j.parts.length>1&&"mirror"===j.parts[1]?b=_=!0:"margin.pad"===O?b=_=!0:"margin"===j.parts[0]||"autorange"===j.parts[1]||"rangemode"===j.parts[1]||"type"===j.parts[1]||"domain"===j.parts[1]||O.match(/^(bar|box|font)/)?M=!0:["hovermode","dragmode"].indexOf(O)!==-1?A=!0:["hovermode","dragmode","height","width","autosize"].indexOf(O)===-1&&(w=!0):w=!0,j.set(F)}I.add(e,t,[e,C],t,[e,z]),y.autosize&&(y=k(e,y)),(y.height||y.width||y.autosize)&&(M=!0);var lt=Object.keys(y),st=[R.previousPromises];if(w||M)st.push(function(){return e.layout=void 0,M&&(e.calcdata=void 0),P.plot(e,"",m)});else if(lt.length&&(R.supplyDefaults(e),v=e._fullLayout,x&&st.push(function(){return V.draw(e),R.previousPromises(e)}),_&&st.push(L),b&&st.push(function(){return P.Axes.doTicks(e,"redraw"),S(e),R.previousPromises(e)}),A)){var ct;for($(e),P.Fx.supplyLayoutDefaults(e.layout,v,e._fullData),P.Fx.init(e),ct=R.getSubplotIds(v,"gl3d"),g=0;g1)};c(n.width)&&c(n.height)||l(new Error("Height and width should be pixel values."));var u=r.clone(e,{format:"png",height:n.height,width:n.width}),f=u.td;f.style.position="absolute",f.style.left="-5000px",document.body.appendChild(f);var d=r.getRedrawFunc(f);o.plot(f,u.data,u.layout,u.config).then(d).then(s).then(function(e){t(e)}).catch(function(t){l(t)})});return l}var a=t("fast-isnumeric"),o=t("../plotly"),i=t("../lib");e.exports=r},{"../lib":102,"../plotly":120,"../snapshot":160,"fast-isnumeric":17}],119:[function(t,e,n){"use strict";function r(t,e,n,a,o,c){c=c||[];for(var u=Object.keys(t),d=0;d1&&s.push(i("object","layout"))),d.supplyDefaults(c);for(var u=c._fullData,m=n.length,v=0;vc&&e=864e5?t._tickround="d":n>=36e5?t._tickround="H":n>=6e4?t._tickround="M":n>=1e3?t._tickround="S":t._tickround=3-Math.round(Math.log(n/2)/Math.LN10);else{x(n)||(n=Number(n.substr(1))),t._tickround=2-Math.floor(Math.log(n)/Math.LN10+.01),e="log"===t.type?Math.pow(10,Math.max(t.range[0],t.range[1])):Math.max(Math.abs(t.range[0]),Math.abs(t.range[1]));var r=Math.floor(Math.log(e)/Math.LN10+.01);Math.abs(r)>3&&("SI"===t.exponentformat||"B"===t.exponentformat?t._tickexponent=3*Math.round((r-1)/3):t._tickexponent=r)}else"M"===n.charAt(0)?t._tickround=2===n.length?"m":"y":t._tickround=null}function i(t,e){var n=t.match(B),r=new Date(e);if(n){var a=Math.min(+n[1]||6,6),o=String(e/1e3%1+2.0000005).substr(2,a).replace(/0+$/,"")||"0";return y.time.format(t.replace(B,o))(r)}return y.time.format(t)(r)}function l(t,e,n){var r=t.tickfont||t._gd._fullLayout.font;return{x:e,dx:0,dy:0,text:n||"",fontSize:r.size,font:r.family,fontColor:r.color}}function s(t,e,n,r){var a,o=e.x,l=t._tickround,s=new Date(o),c="";n&&t.hoverformat?a=i(t.hoverformat,o):t.tickformat?a=i(t.tickformat,o):(r&&(x(l)?l+=2:l={y:"m",m:"d",d:"H",H:"M",M:"S",S:2}[l]),"y"===l?a=D(s):"m"===l?a=I(s):(o!==t._tmin||n||(c="
"+D(s)),"d"===l?a=R(s):"H"===l?a=j(s):(o!==t._tmin||n||(c="
"+R(s)+", "+D(s)),a=F(s),"M"!==l&&(a+=q(s),"S"!==l&&(a+=d(v(o/1e3,1),t,"none",n).substr(1)))))),e.text=a+c}function c(t,e,n,r,a){var o=t.dtick,i=e.x;if(!r||"string"==typeof o&&"L"===o.charAt(0)||(o="L3"),t.tickformat||"string"==typeof o&&"L"===o.charAt(0))e.text=d(Math.pow(10,i),t,a,r);else if(x(o)||"D"===o.charAt(0)&&v(i+.01,1)<.1)if(["e","E","power"].indexOf(t.exponentformat)!==-1){var l=Math.round(i);0===l?e.text=1:1===l?e.text="10":l>1?e.text="10"+l+"":e.text="10\u2212"+-l+"",e.fontSize*=1.25}else e.text=d(Math.pow(10,i),t,"","fakehover"),"D1"===o&&"y"===t._id.charAt(0)&&(e.dy-=e.fontSize/6);else{if("D"!==o.charAt(0))throw"unrecognized dtick "+String(o);e.text=String(Math.round(Math.pow(10,v(i,1)))),e.fontSize*=.75}if("D1"===t.dtick){var s=String(e.text).charAt(0);"0"!==s&&"1"!==s||("y"===t._id.charAt(0)?e.dx-=e.fontSize/4:(e.dy+=e.fontSize/2,e.dx+=(t.range[1]>t.range[0]?1:-1)*e.fontSize*(i<0?.5:.25)))}}function u(t,e){var n=t._categories[Math.round(e.x)];void 0===n&&(n=""),e.text=String(n)}function f(t,e,n,r,a){"all"===t.showexponent&&Math.abs(e.x/t.dtick)<1e-6&&(a="hide"),e.text=d(e.x,t,a,r)}function d(t,e,n,r){var a=t<0,i=e._tickround,l=n||e.exponentformat||"B",s=e._tickexponent,c=e.tickformat;if(r){var u={exponentformat:e.exponentformat,dtick:"none"===e.showexponent?e.dtick:x(t)?Math.abs(t)||1:1,range:"none"===e.showexponent?e.range:[0,t||1]};o(u),i=(Number(u._tickround)||0)+4,s=u._tickexponent,e.hoverformat&&(c=e.hoverformat)}if(c)return y.format(c)(t).replace(/-/g,"\u2212");var f=Math.pow(10,-i)/2;if("none"===l&&(s=0),t=Math.abs(t),t12||s<-15)?t+="e"+p:"E"===l?t+="E"+p:"power"===l?t+="\xd710"+p+"":"B"===l&&9===s?t+="B":"SI"!==l&&"B"!==l||(t+=H[s/3+5])}return a?"\u2212"+t:t}function h(t,e){var n,r,a=[];for(n=0;n1)for(r=1;r2e-6||((n-t._forceTick0)/t._minDtick%1+1.000001)%1>2e-6)&&(t._minDtick=0)):t._minDtick=0},T.getAutoRange=function(t){var e,n=[],r=t._min[0].val,a=t._max[0].val;for(e=1;e0&&u>0&&f/u>d&&(s=i,c=l,d=f/u);if(r===a){var p=r-1,g=r+1;n="tozero"===t.rangemode?r<0?[p,0]:[0,g]:"nonnegative"===t.rangemode?[Math.max(0,p),Math.max(0,g)]:[p,g]}else d&&("linear"!==t.type&&"-"!==t.type||("tozero"===t.rangemode?(s.val>=0&&(s={val:0,pad:0}),c.val<=0&&(c={val:0,pad:0})):"nonnegative"===t.rangemode&&(s.val-d*s.pad<0&&(s={val:0,pad:0}),c.val<0&&(c={val:1,pad:0})),d=(c.val-s.val)/(t._length-s.pad-c.pad)),n=[s.val-d*s.pad,c.val+d*c.pad]);return n[0]===n[1]&&("tozero"===t.rangemode?n=n[0]<0?[n[0],0]:n[0]>0?[0,n[0]]:[0,1]:(n=[n[0]-1,n[0]+1],"nonnegative"===t.rangemode&&(n[0]=Math.max(0,n[0])))),h&&n.reverse(),n},T.doAutoRange=function(t){t._length||t.setScale();var e=t._min&&t._max&&t._min.length&&t._max.length;if(t.autorange&&e){t.range=T.getAutoRange(t);var n=t._gd.layout[t._name];n||(t._gd.layout[t._name]=n={}),n!==t&&(n.range=t.range.slice(),n.autorange=t.autorange)}},T.saveRangeInitial=function(t,e){for(var n=T.list(t,"",!0),r=!1,a=0;a=d?h=!1:l.val>=c&&l.pad<=d&&(t._min.splice(i,1),i--);h&&t._min.push({val:c,pad:y&&0===c?0:d})}if(r(u)){for(h=!0,i=0;i=u&&l.pad>=f?h=!1:l.val<=u&&l.pad<=f&&(t._max.splice(i,1),i--);h&&t._max.push({val:u,pad:y&&0===u?0:f})}}}if((t.autorange||t._needsExpand)&&e){t._min||(t._min=[]),t._max||(t._max=[]),n||(n={}),t._m||t.setScale();var o,i,l,s,c,u,f,d,h,p,g,m=e.length,v=n.padded?.05*t._length:0,y=n.tozero&&("linear"===t.type||"-"===t.type),b=r((t._m>0?n.ppadplus:n.ppadminus)||n.ppad||0),_=r((t._m>0?n.ppadminus:n.ppadplus)||n.ppad||0),w=r(n.vpadplus||n.vpad),k=r(n.vpadminus||n.vpad);for(o=0;o<6;o++)a(o);for(o=m-1;o>5;o--)a(o)}},T.autoBin=function(t,e,n,r){function a(t){return(1+100*(t-h)/f.dtick)%100<2}var o=_.aggNums(Math.min,null,t),i=_.aggNums(Math.max,null,t);if("category"===e.type)return{start:o-.5,end:i+.5,size:1};var l;if(n)l=(i-o)/n;else{var s=_.distinctVals(t),c=Math.pow(10,Math.floor(Math.log(s.minDiff)/Math.LN10)),u=c*_.roundUp(s.minDiff/c,[.9,1.9,4.9,9.9],!0);l=Math.max(u,2*_.stdev(t)/Math.pow(t.length,r?.25:.4))}var f={type:"log"===e.type?"linear":e.type,range:[o,i]};T.autoTicks(f,l);var d,h=T.tickIncrement(T.tickFirst(f),f.dtick,"reverse");if("number"==typeof f.dtick){for(var p=0,g=0,m=0,v=0,y=0;y.3*b||a(o)||a(i))){var w=f.dtick/2;h+=h+w0&&t.dtick<2*t._minDtick&&(t.dtick=t._minDtick,t.tick0=t._forceTick0)}t.tick0||(t.tick0="date"===t.type?new Date(2e3,0,1).getTime():0),o(t),t._tmin=T.tickFirst(t);var a=t.range[1]=l:s<=l)&&(i.push(s),!(i.length>1e3));s=T.tickIncrement(s,t.dtick,a));t._tmax=i[i.length-1];for(var c=new Array(i.length),u=0;u157788e5?(e/=315576e5,n=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick="M"+12*a(e,n,S)):e>12096e5?(e/=26298e5,t.dtick="M"+a(e,1,C)):e>432e5?(t.dtick=a(e,864e5,O),t.tick0=new Date(2e3,0,2).getTime()):e>18e5?t.dtick=a(e,36e5,C):e>3e4?t.dtick=a(e,6e4,E):e>500?t.dtick=a(e,1e3,E):(n=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick=a(e,n,S));else if("log"===t.type)if(t.tick0=0,e>.7)t.dtick=Math.ceil(e);else if(Math.abs(t.range[1]-t.range[0])<1){var r=1.5*Math.abs((t.range[1]-t.range[0])/e);e=Math.abs(Math.pow(10,t.range[1])-Math.pow(10,t.range[0]))/r,n=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick="L"+a(e,n,S)}else t.dtick=e>.3?"D2":"D1";else"category"===t.type?(t.tick0=0,t.dtick=Math.ceil(Math.max(e,1))):(t.tick0=0,n=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick=a(e,n,S));if(0===t.dtick&&(t.dtick=1),!x(t.dtick)&&"string"!=typeof t.dtick){var o=t.dtick;throw t.dtick=1,"ax.dtick error: "+String(o)}},T.tickIncrement=function(t,e,n){var r=n?-1:1;if(x(e))return t+r*e;var a=e.charAt(0),o=r*Number(e.substr(1));if("M"===a){var i=new Date(t);return i.setMonth(i.getMonth()+o)}if("L"===a)return Math.log(Math.pow(10,t)+o)/Math.LN10;if("D"===a){var l="D2"===e?N:P,s=t+.01*r,c=_.roundUp(v(s,1),l,n);return Math.floor(s)+Math.log(y.round(Math.pow(10,c),1))/Math.LN10}throw"unrecognized dtick "+String(e)},T.tickFirst=function(t){var e=t.range[1]r:c1&&e2*r}function u(t){for(var e,n=Math.max(1,(t.length-1)/1e3),r=0,a=0,o=0;o2*r}var f=t("fast-isnumeric"),d=t("tinycolor2").mix,h=t("../../lib"),p=t("../plots"),g=t("../../components/color/attributes").lightFraction,m=t("./layout_attributes"),v=t("./tick_value_defaults"),y=t("./tick_mark_defaults"),x=t("./tick_label_defaults"),b=t("./category_order_defaults"),_=t("./set_convert"),w=t("./ordered_categories"),k=t("./clean_datum"),M=t("./axis_ids");e.exports=function(t,e,n,a){function o(n,r){return h.coerce2(t,e,m,n,r)}var i=a.letter,l=a.font||{},s="Click to enter "+(a.title||i.toUpperCase()+" axis")+" title";a.name&&(e._name=a.name,e._id=M.name2id(a.name));var c=n("type");"-"===c&&(r(e,a.data),"-"===e.type?e.type="linear":c=t.type=e.type),_(e);var u=n("color"),p=u===t.color?u:l.color;n("title",s),h.coerceFont(n,"titlefont",{family:l.family,size:Math.round(1.2*l.size),color:p});var k=2===(t.range||[]).length&&f(t.range[0])&&f(t.range[1]),A=n("autorange",!k);A&&n("rangemode");var T=n("range",[-1,"x"===i?6:4]);T[0]===T[1]&&(e.range=[T[0]-1,T[0]+1]),h.noneOrAll(t.range,e.range,[0,1]),n("fixedrange"),v(t,e,n,c),x(t,e,n,c,a),y(t,e,n,a),b(t,e,n);var L=o("linecolor",u),z=o("linewidth"),S=n("showline",!!L||!!z);S||(delete e.linecolor,delete e.linewidth),(S||e.ticks)&&n("mirror");var C=o("gridcolor",d(u,a.bgColor,g).toRgbString()),E=o("gridwidth"),O=n("showgrid",a.showGrid||!!C||!!E);O||(delete e.gridcolor,delete e.gridwidth);var P=o("zerolinecolor",u),N=o("zerolinewidth"),D=n("zeroline",a.showGrid||!!P||!!N);return D||(delete e.zerolinecolor,delete e.zerolinewidth),e._initialCategories="category"===c?w(i,e.categoryorder,e.categoryarray,a.data):[],e}},{"../../components/color/attributes":24,"../../lib":102,"../plots":143,"./axis_ids":125,"./category_order_defaults":126,"./clean_datum":127,"./layout_attributes":132,"./ordered_categories":134,"./set_convert":137,"./tick_label_defaults":138,"./tick_mark_defaults":139,"./tick_value_defaults":140,"fast-isnumeric":17,tinycolor2:20}],125:[function(t,e,n){"use strict";function r(t,e,n){function r(t,n){for(var r=Object.keys(t),a=/^[xyz]axis[0-9]*/,o=[],i=0;i0;o&&(r="array");var i=n("categoryorder",r);"array"===i&&n("categoryarray"),o||"array"!==i||(e.categoryorder="trace")}}},{}],127:[function(t,e,n){"use strict";var r=t("fast-isnumeric"),a=t("../../lib");e.exports=function(t){try{if("object"==typeof t&&null!==t&&t.getTime)return a.ms2DateTime(t);if("string"!=typeof t&&!r(t))return"";t=t.toString().replace(/['"%,$# ]/g,"")}catch(e){a.error(e,t)}return t}},{"../../lib":102,"fast-isnumeric":17}],128:[function(t,e,n){"use strict";e.exports={idRegex:{x:/^x([2-9]|[1-9][0-9]+)?$/,y:/^y([2-9]|[1-9][0-9]+)?$/},attrRegex:{x:/^xaxis([2-9]|[1-9][0-9]+)?$/,y:/^yaxis([2-9]|[1-9][0-9]+)?$/},BADNUM:void 0,xAxisMatch:/^xaxis[0-9]*$/,yAxisMatch:/^yaxis[0-9]*$/,AX_ID_PATTERN:/^[xyz][0-9]*$/,AX_NAME_PATTERN:/^[xyz]axis[0-9]*$/,DBLCLICKDELAY:300,MINDRAG:8,MINSELECT:12,MINZOOM:20,DRAGGERSIZE:20,MAXDIST:20,YANGLE:60,HOVERARROWSIZE:6,HOVERTEXTPAD:3,HOVERFONTSIZE:13,HOVERFONT:"Arial, sans-serif",HOVERMINTIME:50,BENDPX:1.5,REDRAWDELAY:50}},{}],129:[function(t,e,n){"use strict";function r(t,e){var n,r=t.range[e],a=Math.abs(r-t.range[1-e]);return"date"===t.type?u.ms2DateTime(r,a):"log"===t.type?(n=Math.ceil(Math.max(0,-Math.log(a)/Math.LN10))+3,l.format("."+n+"g")(Math.pow(10,r))):(n=Math.floor(Math.log(Math.abs(r))/Math.LN10)-Math.floor(Math.log(a)/Math.LN10)+4,l.format("."+String(n)+"g")(r))}function a(t,e){return t?"nsew"===t?"pan"===e?"move":"crosshair":t.toLowerCase()+"-resize":"pointer"}function o(t){l.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}function i(t){var e=["lasso","select"];return e.indexOf(t)!==-1}var l=t("d3"),s=t("tinycolor2"),c=t("../../plotly"),u=t("../../lib"),f=t("../../lib/svg_text_utils"),d=t("../../components/color"),h=t("../../components/drawing"),p=t("../../lib/setcursor"),g=t("../../components/dragelement"),m=t("./axes"),v=t("./select"),y=t("./constants"),x=!0;e.exports=function(t,e,n,l,b,_,w,k){function M(t,e){for(var n=0;n.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("transform","translate("+pt+", "+gt+")").attr("d",st+"Z"),dt=ht.append("path").attr("class","zoombox-corners").style({fill:d.background,stroke:d.defaultLine,"stroke-width":1,opacity:0}).attr("transform","translate("+pt+", "+gt+")").attr("d","M0,0Z"),L();for(var o=0;o.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),dt.transition().style("opacity",1).duration(200),ct=!0)}function S(t,e,n){var r,a,o;for(r=0;rzoom back out","long"),x=!1)))}function E(e,n){var a=1===(w+k).length;if(e)I();else if(2!==n||a){if(1===n&&a){var o=w?B[0]:q[0],i="s"===w||"w"===k?0:1,l=o._name+".range["+i+"]",s=r(o,i),u="left",d="middle";if(o.fixedrange)return;w?(d="n"===w?"top":"bottom","right"===o.side&&(u="right")):"e"===k&&(u="right"),et.call(f.makeEditable,null,{immediate:!0,background:j.paper_bgcolor,text:String(s),fill:o.tickfont?o.tickfont.color:"#444",horizontalAlign:u,verticalAlign:d}).on("edit",function(e){var n="category"===o.type?o.c2l(e):o.d2l(e);void 0!==n&&c.relayout(t,l,n)})}}else D()}function O(e){function n(t,e,n){if(!t.fixedrange){A(t.range);var r=t.range,a=r[0]+(r[1]-r[0])*e;t.range=[a+(r[0]-a)*n,a+(r[1]-a)*n]}}if(t._context.scrollZoom||j._enablescrollzoom){var r=t.querySelector(".plotly");if(!(r.scrollHeight-r.clientHeight>10||r.scrollWidth-r.clientWidth>10)){clearTimeout(vt);var a=-e.deltaY;if(isFinite(a)||(a=e.wheelDelta/10),!isFinite(a))return void u.log("Did not find wheel motion attributes: ",e);var o,i=Math.exp(-Math.min(Math.max(a,-20),20)/100),l=xt.draglayer.select(".nsewdrag").node().getBoundingClientRect(),s=(e.clientX-l.left)/l.width,c=mt[0]+mt[2]*s,f=(l.bottom-e.clientY)/l.height,d=mt[1]+mt[3]*(1-f);if(k){for(o=0;o=0?Math.min(t,.9):1/(1/Math.max(t,-.3)+3.222))}function a(t,e,n){for(var a=1-e,o=0,i=0;i0;r--)n.push(e);return n}function a(t,e){for(var n=[],r=0;rX.width||Y<0||Y>X.height)return _.unhoverRaw(t,e)}else U="xpx"in e?e.xpx:M[0]._length/2,Y="ypx"in e?e.ypx:A[0]._length/2;if(E="xval"in e?r(o,e.xval):a(M,U),O="yval"in e?r(o,e.yval):a(A,Y),!g(E[0])||!g(O[0]))return m.warn("Plotly.Fx.hover failed",e,t),_.unhoverRaw(t,e)}var G=1/0;for(N=0;N1||I.hoverinfo.indexOf("name")!==-1?I.name:void 0,index:!1,distance:Math.min(G,k.MAXDIST),color:x.defaultLine,x0:void 0,x1:void 0,y0:void 0,y1:void 0,xLabelVal:void 0,yLabelVal:void 0,zLabelVal:void 0,text:void 0},H=V.length,"array"===j){var $=e[N];"pointNumber"in $?(B.index=$.pointNumber,j="closest"):(j="","xval"in $&&(F=$.xval,j="x"),"yval"in $&&(q=$.yval,j=j?"closest":"y"))}else F=E[R],q=O[R];if(I._module&&I._module.hoverPoints){var Q=I._module.hoverPoints(B,F,q,j);if(Q)for(var W,J=0;JH&&(V.splice(0,H),G=V[0].distance)}if(0===V.length)return _.unhoverRaw(t,e);var K="y"===C&&Z.length>1;V.sort(function(t,e){return t.distance-e.distance});var tt=x.combine(i.plot_bgcolor||x.background,i.paper_bgcolor),et={hovermode:C,rotateLabels:K,bgColor:tt,container:i._hoverlayer,outerContainer:i._paperdiv},nt=c(V,et);u(V,K?"xa":"ya"),f(nt,K);var rt=t._hoverdata,at=[];for(P=0;P128?"#000":x.background;if(t.name&&void 0===t.zLabelVal){var u=document.createElement("p");u.innerHTML=t.name,n=u.textContent||"",n.length>15&&(n=n.substr(0,12)+"...")}void 0!==t.extraText&&(r+=t.extraText),void 0!==t.zLabel?(void 0!==t.xLabel&&(r+="x: "+t.xLabel+"
"),void 0!==t.yLabel&&(r+="y: "+t.yLabel+"
"),r+=(r?"z: ":"")+t.zLabel):A&&t[a+"Label"]===g?r=t[("x"===a?"y":"x")+"Label"]||"":void 0===t.xLabel?void 0!==t.yLabel&&(r=t.yLabel):r=void 0===t.yLabel?t.xLabel:"("+t.xLabel+", "+t.yLabel+")",t.text&&!Array.isArray(t.text)&&(r+=(r?"
":"")+t.text),""===r&&(""===n&&e.remove(),r=n);var f=e.select("text.nums").style("fill",c).call(b.setPosition,0,0).text(r).attr("data-notex",1).call(y.convertToTspans);f.selectAll("tspan.line").call(b.setPosition,0,0);var d=e.select("text.name"),m=0;n&&n!==r?(d.style("fill",s).text(n).call(b.setPosition,0,0).attr("data-notex",1).call(y.convertToTspans),d.selectAll("tspan.line").call(b.setPosition,0,0),m=d.node().getBoundingClientRect().width+2*O):(d.remove(),e.select("rect").remove()),e.select("path").style({fill:s,stroke:c});var v,k,L=f.node().getBoundingClientRect(),z=t.xa._offset+(t.x0+t.x1)/2,S=t.ya._offset+(t.y0+t.y1)/2,C=Math.abs(t.x1-t.x0),P=Math.abs(t.y1-t.y0),N=L.width+E+O+m;t.ty0=_-L.top,t.bx=L.width+2*O,t.by=L.height+2*O,t.anchor="start",t.txwidth=L.width,t.tx2width=m,t.offset=0,o?(t.pos=z,v=S+P/2+N<=M,k=S-P/2-N>=0,"top"!==t.idealAlign&&v||!k?v?(S+=P/2,t.anchor="start"):t.anchor="middle":(S-=P/2,t.anchor="end")):(t.pos=S,v=z+C/2+N<=w,k=z-C/2-N>=0,"left"!==t.idealAlign&&v||!k?v?(z+=C/2,t.anchor="start"):t.anchor="middle":(z-=C/2,t.anchor="end")),f.attr("text-anchor",t.anchor),m&&d.attr("text-anchor",t.anchor),e.attr("transform","translate("+z+","+S+")"+(o?"rotate("+T+")":""))}),S}function u(t,e){function n(t){var e=t[0],n=t[t.length-1];if(a=e.pmin-e.pos-e.dp+e.size,o=n.pos+n.dp+n.size-e.pmax,a>.01){for(l=t.length-1;l>=0;l--)t[l].dp+=a;r=!1}if(!(o<.01)){if(a<-.01){for(l=t.length-1;l>=0;l--)t[l].dp-=o;r=!1}if(r){var c=0;for(i=0;ie.pmax&&c++;for(i=t.length-1;i>=0&&!(c<=0);i--)s=t[i],s.pos>e.pmax-1&&(s.del=!0,c--);for(i=0;i=0;l--)t[l].dp-=o;for(i=t.length-1;i>=0&&!(c<=0);i--)s=t[i],s.pos+s.dp+s.size>e.pmax&&(s.del=!0,c--)}}}for(var r,a,o,i,l,s,c,u=0,f=t.map(function(t,n){var r=t[e];return[{i:n,dp:0,pos:t.pos,posref:t.posref, ++size:t.by*("x"===r._id.charAt(0)?z:1)/2,pmin:r._offset,pmax:r._offset+r._length}]}).sort(function(t,e){return t[0].posref-e[0].posref});!r&&u<=t.length;){for(u++,r=!0,i=0;i.01&&p.pmin===g.pmin&&p.pmax===g.pmax){for(l=h.length-1;l>=0;l--)h[l].dp+=a;for(d.push.apply(d,h),f.splice(i+1,1),c=0,l=d.length-1;l>=0;l--)c+=d[l].dp;for(o=c/d.length,l=d.length-1;l>=0;l--)d[l].dp-=o;r=!1}else i++}f.forEach(n)}for(i=f.length-1;i>=0;i--){var m=f[i];for(l=m.length-1;l>=0;l--){var v=m[l],y=t[v.i];y.offset=v.dp,y.del=v.del}}}function f(t,e){t.each(function(t){var n=h.select(this);if(t.del)return void n.remove();var r="end"===t.anchor?-1:1,a=n.select("text.nums"),o={start:1,end:-1,middle:0}[t.anchor],i=o*(E+O),l=i+o*(t.txwidth+O),s=0,c=t.offset;"middle"===t.anchor&&(i-=t.tx2width/2,l-=t.tx2width/2),e&&(c*=-C,s=t.offset*S),n.select("path").attr("d","middle"===t.anchor?"M-"+t.bx/2+",-"+t.by/2+"h"+t.bx+"v"+t.by+"h-"+t.bx+"Z":"M0,0L"+(r*E+s)+","+(E+c)+"v"+(t.by/2-E)+"h"+r*t.bx+"v-"+t.by+"H"+(r*E+s)+"V"+(c-E)+"Z"),a.call(b.setPosition,i+s,c+t.ty0-t.by/2+O).selectAll("tspan.line").attr({x:a.attr("x"),y:a.attr("y")}),t.tx2width&&(n.select("text.name, text.name tspan.line").call(b.setPosition,l+o*O+s,c+t.ty0-t.by/2+O),n.select("rect").call(b.setRect,l+(o-1)*t.tx2width/2+s,c-t.by/2-1,t.tx2width,t.by+2))})}function d(t,e,n){if(!e.target)return!1;if(!n||n.length!==t._hoverdata.length)return!0;for(var r=n.length-1;r>=0;r--){var a=n[r],o=t._hoverdata[r];if(a.curveNumber!==o.curveNumber||String(a.pointNumber)!==String(o.pointNumber))return!0}return!1}var h=t("d3"),p=t("tinycolor2"),g=t("fast-isnumeric"),m=t("../../lib"),v=t("../../lib/events"),y=t("../../lib/svg_text_utils"),x=t("../../components/color"),b=t("../../components/drawing"),_=t("../../components/dragelement"),w=t("./axes"),k=t("./constants"),M=t("./dragbox"),A=e.exports={};A.unhover=_.unhover,A.layoutAttributes={dragmode:{valType:"enumerated",values:["zoom","pan","select","lasso","orbit","turntable"],dflt:"zoom"},hovermode:{valType:"enumerated",values:["x","y","closest",!1]}},A.supplyLayoutDefaults=function(t,e,n){function r(n,r){return m.coerce(t,e,A.layoutAttributes,n,r)}r("dragmode");var a;if(e._has("cartesian")){var o=e._isHoriz=A.isHoriz(n);a=o?"y":"x"}else a="closest";r("hovermode",a)},A.isHoriz=function(t){for(var e=!0,n=0;nt._lastHoverTime+k.HOVERMINTIME?(i(t,e,n),void(t._lastHoverTime=Date.now())):void(t._hoverTimer=setTimeout(function(){i(t,e,n),t._lastHoverTime=Date.now(),t._hoverTimer=void 0},k.HOVERMINTIME))},A.getDistanceFunction=function(t,e,n,r){return"closest"===t?r||o(e,n):"x"===t?e:n},A.getClosest=function(t,e,n){if(n.index!==!1)n.index>=0&&n.indexf[1]-.01&&(e.domain=[0,1]),a.noneOrAll(t.domain,e.domain,[0,1])}return e}},{"../../lib":102,"fast-isnumeric":17}],136:[function(t,e,n){"use strict";function r(t){return t._id}var a=t("../../lib/polygon"),o=t("../../components/color"),i=t("./axes"),l=t("./constants"),s=a.filter,c=a.tester,u=l.MINSELECT;e.exports=function(t,e,n,a,f){function d(t){var e="y"===t._id.charAt(0)?1:0;return function(n){return t.p2d(n[e])}}function h(t,e){return t-e}var p,g=a.gd._fullLayout._zoomlayer,m=a.element.getBoundingClientRect(),v=a.plotinfo.x()._offset,y=a.plotinfo.y()._offset,x=e-m.left,b=n-m.top,_=x,w=b,k="M"+x+","+b,M=a.xaxes[0]._length,A=a.yaxes[0]._length,T=a.xaxes.map(r),L=a.yaxes.map(r),z=a.xaxes.concat(a.yaxes);"lasso"===f&&(p=s([[x,b]],l.BENDPX));var S=g.selectAll("path.select-outline").data([1,2]);S.enter().append("path").attr("class",function(t){return"select-outline select-outline-"+t}).attr("transform","translate("+v+", "+y+")").attr("d",k+"Z");var C,E,O,P,N,D=g.append("path").attr("class","zoombox-corners").style({fill:o.background,stroke:o.defaultLine,"stroke-width":1}).attr("transform","translate("+v+", "+y+")").attr("d","M0,0Z"),I=[],R=a.gd,j=[];for(C=0;C0)return Math.log(e)/Math.LN10;if(e<=0&&n&&t.range&&2===t.range.length){var r=t.range[0],a=t.range[1];return.5*(r+a-3*u*Math.abs(r-a))}return i.BADNUM}function n(t){return Math.pow(10,t)}function c(t){return a(t)?Number(t):i.BADNUM}var u=10;if(t.c2l="log"===t.type?e:c,t.l2c="log"===t.type?n:c,t.l2d=function(e){return t.c2d(t.l2c(e))},t.p2d=function(e){return t.l2d(t.p2l(e))},t.setScale=function(){var e,n=t._gd._fullLayout._size;if(t._categories||(t._categories=[]),t.overlaying){var r=s.getFromId(t._gd,t.overlaying);t.domain=r.domain}for(t.range&&2===t.range.length&&t.range[0]!==t.range[1]||(t.range=[-1,1]),e=0;e<2;e++)a(t.range[e])||(t.range[e]=a(t.range[1-e])?t.range[1-e]*(e?10:.1):e?1:-1),t.range[e]<-(Number.MAX_VALUE/2)?t.range[e]=-(Number.MAX_VALUE/2):t.range[e]>Number.MAX_VALUE/2&&(t.range[e]=Number.MAX_VALUE/2);if("y"===t._id.charAt(0)?(t._offset=n.t+(1-t.domain[1])*n.h,t._length=n.h*(t.domain[1]-t.domain[0]),t._m=t._length/(t.range[0]-t.range[1]),t._b=-t._m*t.range[1]):(t._offset=n.l+t.domain[0]*n.w,t._length=n.w*(t.domain[1]-t.domain[0]),t._m=t._length/(t.range[1]-t.range[0]),t._b=-t._m*t.range[0]),!isFinite(t._m)||!isFinite(t._b))throw o.notifier("Something went wrong with axis scaling","long"),t._gd._replotting=!1,new Error("axis scaling")},t.l2p=function(e){return a(e)?r.round(t._b+t._m*e,2):i.BADNUM},t.p2l=function(e){return(e-t._b)/t._m},t.c2p=function(e,n){return t.l2p(t.c2l(e,n))},t.p2c=function(e){return t.l2c(t.p2l(e))},["linear","log","-"].indexOf(t.type)!==-1)t.c2d=c,t.d2c=function(t){return t=l(t),a(t)?Number(t):i.BADNUM},t.d2l=function(e,n){return"log"===t.type?t.c2l(t.d2c(e),n):t.d2c(e)};else if("date"===t.type){if(t.c2d=function(t){return a(t)?o.ms2DateTime(t):i.BADNUM},t.d2c=function(t){return a(t)?Number(t):o.dateTime2ms(t)},t.d2l=t.d2c,t.range&&t.range.length>1)try{var f=t.range.map(o.dateTime2ms);!a(t.range[0])&&a(f[0])&&(t.range[0]=f[0]),!a(t.range[1])&&a(f[1])&&(t.range[1]=f[1])}catch(e){o.error(e,t.range)}}else"category"===t.type&&(t.c2d=function(e){return t._categories[Math.round(e)]},t.d2c=function(e){null!==e&&void 0!==e&&t._categories.indexOf(e)===-1&&t._categories.push(e);var n=t._categories.indexOf(e);return n===-1?i.BADNUM:n},t.d2l=t.d2c);t.makeCalcdata=function(e,n){var r,a,o;if(n in e)for(r=e[n],a=new Array(r.length),o=0;o=e.width-20?(o["text-anchor"]="start",o.x=5):(o["text-anchor"]="end",o.x=e._paper.attr("width")-7),n.attr(o);var i=n.select(".js-link-to-tool"),l=n.select(".js-link-spacer"),c=n.select(".js-sourcelinks");t._context.showSources&&t._context.showSources(t),t._context.showLink&&a(t,i),l.text(i.text()&&c.text()?" - ":"")},h.sendDataToCloud=function(t){t.emit("plotly_beforeexport");var e=window.PLOTLYENV&&window.PLOTLYENV.BASE_URL||"https://plot.ly",n=s.select(t).append("div").attr("id","hiddenform").style("display","none"),r=n.append("form").attr({action:e+"/external",method:"post",target:"_blank"}),a=r.append("input").attr({type:"text",name:"data"});return a.node().value=h.graphJson(t,!1,"keepdata"),r.node().submit(),n.remove(),t.emit("plotly_afterexport"),!1},h.supplyDefaults=function(t){var e,n=t._fullLayout||{},r=t._fullLayout={},a=t.layout||{},i=t._fullData||[],l=t._fullData=[],s=t.data||[];h.supplyLayoutGlobalDefaults(a,r),r._dataLength=s.length,h.supplyDataDefaults(s,l,r),r._has=h._hasPlotType.bind(r);var c=r._modules;for(e=0;e.5*r.width&&(n.l=n.r=0),n.b+n.t>.5*r.height&&(n.b=n.t=0),r._pushmargin[e]={l:{val:n.x,size:n.l+a},r:{val:n.x,size:n.r+a},b:{val:n.y,size:n.b+a},t:{val:n.y,size:n.t+a}}}else delete r._pushmargin[e];t._replotting||h.doAutoMargin(t)}},h.doAutoMargin=function(t){var e=t._fullLayout;e._size||(e._size={}), ++e._pushmargin||(e._pushmargin={});var n=e._size,r=JSON.stringify(n),a=Math.max(e.margin.l||0,0),o=Math.max(e.margin.r||0,0),i=Math.max(e.margin.t||0,0),l=Math.max(e.margin.b||0,0),s=e._pushmargin;if(e.margin.autoexpand!==!1&&(s.base={l:{val:0,size:a},r:{val:1,size:o},t:{val:1,size:i},b:{val:0,size:l}},Object.keys(s).forEach(function(t){var n=s[t].l||{},r=s[t].b||{},u=n.val,f=n.size,d=r.val,h=r.size;Object.keys(s).forEach(function(t){if(c(f)&&s[t].r){var n=s[t].r.val,r=s[t].r.size;if(n>u){var p=(f*n+(r-e.width)*u)/(n-u),g=(r*(1-u)+(f-e.width)*(1-n))/(n-u);p>=0&&g>=0&&p+g>a+o&&(a=p,o=g)}}if(c(h)&&s[t].t){var m=s[t].t.val,v=s[t].t.size;if(m>d){var y=(h*m+(v-e.height)*d)/(m-d),x=(v*(1-d)+(h-e.height)*(1-m))/(m-d);y>=0&&x>=0&&y+x>l+i&&(l=y,i=x)}}})})),n.l=Math.round(a),n.r=Math.round(o),n.t=Math.round(i),n.b=Math.round(l),n.p=Math.round(e.margin.pad),n.w=Math.round(e.width)-n.l-n.r,n.h=Math.round(e.height)-n.t-n.b,!t._replotting&&"{}"!==r&&r!==JSON.stringify(e._size))return u.plot(t)},h.graphJson=function(t,e,n,r,a){function o(t){if("function"==typeof t)return null;if(f.isPlainObject(t)){var e,r,a={};for(e in t)if("function"!=typeof t[e]&&["_","["].indexOf(e.charAt(0))===-1){if("keepdata"===n){if("src"===e.substr(e.length-3))continue}else if("keepstream"===n){if(r=t[e+"src"],"string"==typeof r&&r.indexOf(":")>0&&!f.isPlainObject(t.stream))continue}else if("keepall"!==n&&(r=t[e+"src"],"string"==typeof r&&r.indexOf(":")>0))continue;a[e]=o(t[e])}return a}return Array.isArray(t)?t.map(o):t&&t.getTime?f.ms2DateTime(t):t}(a&&e&&!t._fullData||a&&!e&&!t._fullLayout)&&h.supplyDefaults(t);var i=a?t._fullData:t.data,l=a?t._fullLayout:t.layout,s={data:(i||[]).map(function(t){var n=o(t);return e&&delete n.fit,n})};return e||(s.layout=o(l)),t.framework&&t.framework.isPolar&&(s=t.framework.getConfig()),"object"===r?s:JSON.stringify(s)}},{"../components/color":25,"../lib":102,"../plotly":120,"./attributes":121,"./font_attributes":141,"./layout_attributes":142,d3:14,"fast-isnumeric":17}],144:[function(t,e,n){"use strict";var r=t("../../traces/scatter/attributes"),a=r.marker;e.exports={r:r.r,t:r.t,marker:{color:a.color,size:a.size,symbol:a.symbol,opacity:a.opacity}}},{"../../traces/scatter/attributes":236}],145:[function(t,e,n){"use strict";function r(t,e){var n={showline:{valType:"boolean"},showticklabels:{valType:"boolean"},tickorientation:{valType:"enumerated",values:["horizontal","vertical"]},ticklen:{valType:"number",min:0},tickcolor:{valType:"color"},ticksuffix:{valType:"string"},endpadding:{valType:"number"},visible:{valType:"boolean"}};return o({},e,n)}var a=t("../cartesian/layout_attributes"),o=t("../../lib/extend").extendFlat,i=o({},a.domain,{});e.exports={radialaxis:r("radial",{range:{valType:"info_array",items:[{valType:"number"},{valType:"number"}]},domain:i,orientation:{valType:"number"}}),angularaxis:r("angular",{range:{valType:"info_array",items:[{valType:"number",dflt:0},{valType:"number",dflt:360}]},domain:i}),layout:{direction:{valType:"enumerated",values:["clockwise","counterclockwise"]},orientation:{valType:"angle"}}}},{"../../lib/extend":100,"../cartesian/layout_attributes":132}],146:[function(t,e,n){var r=t("../../plotly"),a=t("d3"),o=e.exports={version:"0.2.2",manager:t("./micropolar_manager")},i=r.Lib.extendDeepAll;o.Axis=function(){function t(t){n=t||n;var c=s.data,f=s.layout;return("string"==typeof n||n.nodeName)&&(n=a.select(n)),n.datum(c).each(function(t,n){function s(t,e){return l(t)%360+f.orientation}var c=t.slice();u={data:o.util.cloneJson(c),layout:o.util.cloneJson(f)};var d=0;c.forEach(function(t,e){t.color||(t.color=f.defaultColorRange[d],d=(d+1)%f.defaultColorRange.length),t.strokeColor||(t.strokeColor="LinePlot"===t.geometry?t.color:a.rgb(t.color).darker().toString()),u.data[e].color=t.color,u.data[e].strokeColor=t.strokeColor,u.data[e].strokeDash=t.strokeDash,u.data[e].strokeSize=t.strokeSize});var h=c.filter(function(t,e){var n=t.visible;return"undefined"==typeof n||n===!0}),p=!1,g=h.map(function(t,e){return p=p||"undefined"!=typeof t.groupId,t});if(p){var m=a.nest().key(function(t,e){return"undefined"!=typeof t.groupId?t.groupId:"unstacked"}).entries(g),v=[],y=m.map(function(t,e){if("unstacked"===t.key)return t.values;var n=t.values[0].r.map(function(t,e){return 0});return t.values.forEach(function(t,e,r){t.yStack=[n],v.push(n),n=o.util.sumArrays(t.r,n)}),t.values});h=a.merge(y)}h.forEach(function(t,e){t.t=Array.isArray(t.t[0])?t.t:[t.t],t.r=Array.isArray(t.r[0])?t.r:[t.r]});var x=Math.min(f.width-f.margin.left-f.margin.right,f.height-f.margin.top-f.margin.bottom)/2;x=Math.max(10,x);var b,_=[f.margin.left+x,f.margin.top+x];if(p){var w=a.max(o.util.sumArrays(o.util.arrayLast(h).r[0],o.util.arrayLast(v)));b=[0,w]}else b=a.extent(o.util.flattenArray(h.map(function(t,e){return t.r})));f.radialAxis.domain!=o.DATAEXTENT&&(b[0]=0),r=a.scale.linear().domain(f.radialAxis.domain!=o.DATAEXTENT&&f.radialAxis.domain?f.radialAxis.domain:b).range([0,x]),u.layout.radialAxis.domain=r.domain();var k,M=o.util.flattenArray(h.map(function(t,e){return t.t})),A="string"==typeof M[0];A&&(M=o.util.deduplicate(M),k=M.slice(),M=a.range(M.length),h=h.map(function(t,e){var n=t;return t.t=[M],p&&(n.yStack=t.yStack),n}));var T=h.filter(function(t,e){return"LinePlot"===t.geometry||"DotPlot"===t.geometry}).length===h.length,L=null===f.needsEndSpacing?A||!T:f.needsEndSpacing,z=f.angularAxis.domain&&f.angularAxis.domain!=o.DATAEXTENT&&!A&&f.angularAxis.domain[0]>=0,S=z?f.angularAxis.domain:a.extent(M),C=Math.abs(M[1]-M[0]);T&&!A&&(C=0);var E=S.slice();L&&A&&(E[1]+=C);var O=f.angularAxis.ticksCount||4;O>8&&(O=O/(O/8)+O%8),f.angularAxis.ticksStep&&(O=(E[1]-E[0])/O);var P=f.angularAxis.ticksStep||(E[1]-E[0])/(O*(f.minorTicks+1));k&&(P=Math.max(Math.round(P),1)),E[2]||(E[2]=P);var N=a.range.apply(this,E);if(N=N.map(function(t,e){return parseFloat(t.toPrecision(12))}),l=a.scale.linear().domain(E.slice(0,2)).range("clockwise"===f.direction?[0,360]:[360,0]),u.layout.angularAxis.domain=l.domain(),u.layout.angularAxis.endPadding=L?C:0,e=a.select(this).select("svg.chart-root"),"undefined"==typeof e||e.empty()){var D="' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '",I=(new DOMParser).parseFromString(D,"application/xml"),R=this.appendChild(this.ownerDocument.importNode(I.documentElement,!0));e=a.select(R)}e.select(".guides-group").style({"pointer-events":"none"}),e.select(".angular.axis-group").style({"pointer-events":"none"}),e.select(".radial.axis-group").style({"pointer-events":"none"});var j,F=e.select(".chart-group"),q={fill:"none",stroke:f.tickColor},B={"font-size":f.font.size,"font-family":f.font.family,fill:f.font.color,"text-shadow":["-1px 0px","1px -1px","-1px 1px","1px 1px"].map(function(t,e){return" "+t+" 0 "+f.font.outlineColor}).join(",")};if(f.showLegend){j=e.select(".legend-group").attr({transform:"translate("+[x,f.margin.top]+")"}).style({display:"block"});var H=h.map(function(t,e){var n=o.util.cloneJson(t);return n.symbol="DotPlot"===t.geometry?t.dotType||"circle":"LinePlot"!=t.geometry?"square":"line",n.visibleInLegend="undefined"==typeof t.visibleInLegend||t.visibleInLegend,n.color="LinePlot"===t.geometry?t.strokeColor:t.color,n});o.Legend().config({data:h.map(function(t,e){return t.name||"Element"+e}),legendConfig:i({},o.Legend.defaultConfig().legendConfig,{container:j,elements:H,reverseOrder:f.legend.reverseOrder})})();var V=j.node().getBBox();x=Math.min(f.width-V.width-f.margin.left-f.margin.right,f.height-f.margin.top-f.margin.bottom)/2,x=Math.max(10,x),_=[f.margin.left+x,f.margin.top+x],r.range([0,x]),u.layout.radialAxis.domain=r.domain(),j.attr("transform","translate("+[_[0]+x,_[1]-x]+")")}else j=e.select(".legend-group").style({display:"none"});e.attr({width:f.width,height:f.height}).style({opacity:f.opacity}),F.attr("transform","translate("+_+")").style({cursor:"crosshair"});var Z=[(f.width-(f.margin.left+f.margin.right+2*x+(V?V.width:0)))/2,(f.height-(f.margin.top+f.margin.bottom+2*x))/2];if(Z[0]=Math.max(0,Z[0]),Z[1]=Math.max(0,Z[1]),e.select(".outer-group").attr("transform","translate("+Z+")"),f.title){var U=e.select("g.title-group text").style(B).text(f.title),Y=U.node().getBBox();U.attr({x:_[0]-Y.width/2,y:_[1]-x-20})}var X=e.select(".radial.axis-group");if(f.radialAxis.gridLinesVisible){var G=X.selectAll("circle.grid-circle").data(r.ticks(5));G.enter().append("circle").attr({class:"grid-circle"}).style(q),G.attr("r",r),G.exit().remove()}X.select("circle.outside-circle").attr({r:x}).style(q);var $=e.select("circle.background-circle").attr({r:x}).style({fill:f.backgroundColor,stroke:f.stroke});if(f.radialAxis.visible){var Q=a.svg.axis().scale(r).ticks(5).tickSize(5);X.call(Q).attr({transform:"rotate("+f.radialAxis.orientation+")"}),X.selectAll(".domain").style(q),X.selectAll("g>text").text(function(t,e){return this.textContent+f.radialAxis.ticksSuffix}).style(B).style({"text-anchor":"start"}).attr({x:0,y:0,dx:0,dy:0,transform:function(t,e){return"horizontal"===f.radialAxis.tickOrientation?"rotate("+-f.radialAxis.orientation+") translate("+[0,B["font-size"]]+")":"translate("+[0,B["font-size"]]+")"}}),X.selectAll("g>line").style({stroke:"black"})}var W=e.select(".angular.axis-group").selectAll("g.angular-tick").data(N),J=W.enter().append("g").classed("angular-tick",!0);W.attr({transform:function(t,e){return"rotate("+s(t,e)+")"}}).style({display:f.angularAxis.visible?"block":"none"}),W.exit().remove(),J.append("line").classed("grid-line",!0).classed("major",function(t,e){return e%(f.minorTicks+1)==0}).classed("minor",function(t,e){return!(e%(f.minorTicks+1)==0)}).style(q),J.selectAll(".minor").style({stroke:f.minorTickColor}),W.select("line.grid-line").attr({x1:f.tickLength?x-f.tickLength:0,x2:x}).style({display:f.angularAxis.gridLinesVisible?"block":"none"}),J.append("text").classed("axis-text",!0).style(B);var K=W.select("text.axis-text").attr({x:x+f.labelOffset,dy:".35em",transform:function(t,e){var n=s(t,e),r=x+f.labelOffset,a=f.angularAxis.tickOrientation;return"horizontal"==a?"rotate("+-n+" "+r+" 0)":"radial"==a?n<270&&n>90?"rotate(180 "+r+" 0)":null:"rotate("+(n<=180&&n>0?-90:90)+" "+r+" 0)"}}).style({"text-anchor":"middle",display:f.angularAxis.labelsVisible?"block":"none"}).text(function(t,e){return e%(f.minorTicks+1)!=0?"":k?k[t]+f.angularAxis.ticksSuffix:t+f.angularAxis.ticksSuffix}).style(B);f.angularAxis.rewriteTicks&&K.text(function(t,e){return e%(f.minorTicks+1)!=0?"":f.angularAxis.rewriteTicks(this.textContent,e)});var tt=a.max(F.selectAll(".angular-tick text")[0].map(function(t,e){return t.getCTM().e+t.getBBox().width}));j.attr({transform:"translate("+[x+tt,f.margin.top]+")"});var et=e.select("g.geometry-group").selectAll("g").size()>0,nt=e.select("g.geometry-group").selectAll("g.geometry").data(h);if(nt.enter().append("g").attr({class:function(t,e){return"geometry geometry"+e}}),nt.exit().remove(),h[0]||et){var rt=[];h.forEach(function(t,e){var n={};n.radialScale=r,n.angularScale=l,n.container=nt.filter(function(t,n){return n==e}),n.geometry=t.geometry,n.orientation=f.orientation,n.direction=f.direction,n.index=e,rt.push({data:t,geometryConfig:n})});var at=a.nest().key(function(t,e){return"undefined"!=typeof t.data.groupId||"unstacked"}).entries(rt),ot=[];at.forEach(function(t,e){"unstacked"===t.key?ot=ot.concat(t.values.map(function(t,e){return[t]})):ot.push(t.values)}),ot.forEach(function(t,e){var n;n=Array.isArray(t)?t[0].geometryConfig.geometry:t.geometryConfig.geometry;var r=t.map(function(t,e){return i(o[n].defaultConfig(),t)});o[n]().config(r)()})}var it,lt,st=e.select(".guides-group"),ct=e.select(".tooltips-group"),ut=o.tooltipPanel().config({container:ct,fontSize:8})(),ft=o.tooltipPanel().config({container:ct,fontSize:8})(),dt=o.tooltipPanel().config({container:ct,hasTick:!0})();if(!A){var ht=st.select("line").attr({x1:0,y1:0,y2:0}).style({stroke:"grey","pointer-events":"none"});F.on("mousemove.angular-guide",function(t,e){var n=o.util.getMousePos($).angle;ht.attr({x2:-x,transform:"rotate("+n+")"}).style({opacity:.5});var r=(n+180+360-f.orientation)%360;it=l.invert(r);var a=o.util.convertToCartesian(x+12,n+180);ut.text(o.util.round(it)).move([a[0]+_[0],a[1]+_[1]])}).on("mouseout.angular-guide",function(t,e){st.select("line").style({opacity:0})})}var pt=st.select("circle").style({stroke:"grey",fill:"none"});F.on("mousemove.radial-guide",function(t,e){var n=o.util.getMousePos($).radius;pt.attr({r:n}).style({opacity:.5}),lt=r.invert(o.util.getMousePos($).radius);var a=o.util.convertToCartesian(n,f.radialAxis.orientation);ft.text(o.util.round(lt)).move([a[0]+_[0],a[1]+_[1]])}).on("mouseout.radial-guide",function(t,e){pt.style({opacity:0}),dt.hide(),ut.hide(),ft.hide()}),e.selectAll(".geometry-group .mark").on("mouseover.tooltip",function(t,n){var r=a.select(this),i=r.style("fill"),l="black",s=r.style("opacity")||1;if(r.attr({"data-opacity":s}),"none"!=i){r.attr({"data-fill":i}),l=a.hsl(i).darker().toString(),r.style({fill:l,opacity:1});var c={t:o.util.round(t[0]),r:o.util.round(t[1])};A&&(c.t=k[t[0]]);var u="t: "+c.t+", r: "+c.r,f=this.getBoundingClientRect(),d=e.node().getBoundingClientRect(),h=[f.left+f.width/2-Z[0]-d.left,f.top+f.height/2-Z[1]-d.top];dt.config({color:l}).text(u),dt.move(h)}else i=r.style("stroke"),r.attr({"data-stroke":i}),l=a.hsl(i).darker().toString(),r.style({stroke:l,opacity:1})}).on("mousemove.tooltip",function(t,e){return 0==a.event.which&&void(a.select(this).attr("data-fill")&&dt.show())}).on("mouseout.tooltip",function(t,e){dt.hide();var n=a.select(this),r=n.attr("data-fill");r?n.style({fill:r,opacity:n.attr("data-opacity")}):n.style({stroke:n.attr("data-stroke"),opacity:n.attr("data-opacity")})})}),d}var e,n,r,l,s={data:[],layout:{}},c={},u={},f=a.dispatch("hover"),d={};return d.render=function(e){return t(e),this},d.config=function(t){if(!arguments.length)return s;var e=o.util.cloneJson(t);return e.data.forEach(function(t,e){s.data[e]||(s.data[e]={}),i(s.data[e],o.Axis.defaultConfig().data[0]),i(s.data[e],t)}),i(s.layout,o.Axis.defaultConfig().layout),i(s.layout,e.layout),this},d.getLiveConfig=function(){return u},d.getinputConfig=function(){return c},d.radialScale=function(t){return r},d.angularScale=function(t){return l},d.svg=function(){return e},a.rebind(d,f,"on"),d},o.Axis.defaultConfig=function(t,e){var n={data:[{t:[1,2,3,4],r:[10,11,12,13],name:"Line1",geometry:"LinePlot",color:null,strokeDash:"solid",strokeColor:null,strokeSize:"1",visibleInLegend:!0,opacity:1}],layout:{defaultColorRange:a.scale.category10().range(),title:null,height:450,width:500,margin:{top:40,right:40,bottom:40,left:40},font:{size:12,color:"gray",outlineColor:"white",family:"Tahoma, sans-serif"},direction:"clockwise",orientation:0,labelOffset:10,radialAxis:{domain:null,orientation:-45,ticksSuffix:"",visible:!0,gridLinesVisible:!0,tickOrientation:"horizontal",rewriteTicks:null},angularAxis:{domain:[0,360],ticksSuffix:"",visible:!0,gridLinesVisible:!0,labelsVisible:!0,tickOrientation:"horizontal",rewriteTicks:null,ticksCount:null,ticksStep:null},minorTicks:0,tickLength:null,tickColor:"silver",minorTickColor:"#eee",backgroundColor:"none",needsEndSpacing:null,showLegend:!0,legend:{reverseOrder:!1},opacity:1}};return n},o.util={},o.DATAEXTENT="dataExtent",o.AREA="AreaChart",o.LINE="LinePlot",o.DOT="DotPlot",o.BAR="BarChart",o.util._override=function(t,e){for(var n in t)n in e&&(e[n]=t[n])},o.util._extend=function(t,e){for(var n in t)e[n]=t[n]},o.util._rndSnd=function(){return 2*Math.random()-1+(2*Math.random()-1)+(2*Math.random()-1)},o.util.dataFromEquation2=function(t,e){var n=e||6,r=a.range(0,360+n,n).map(function(e,n){var r=e*Math.PI/180,a=t(r);return[e,a]});return r},o.util.dataFromEquation=function(t,e,n){var r=e||6,o=[],i=[];a.range(0,360+r,r).forEach(function(e,n){var r=e*Math.PI/180,a=t(r);o.push(e),i.push(a)});var l={t:o,r:i};return n&&(l.name=n),l},o.util.ensureArray=function(t,e){if("undefined"==typeof t)return null;var n=[].concat(t);return a.range(e).map(function(t,e){return n[e]||n[0]})},o.util.fillArrays=function(t,e,n){return e.forEach(function(e,r){t[e]=o.util.ensureArray(t[e],n)}),t},o.util.cloneJson=function(t){return JSON.parse(JSON.stringify(t))},o.util.validateKeys=function(t,e){"string"==typeof e&&(e=e.split("."));var n=e.shift();return t[n]&&(!e.length||objHasKeys(t[n],e))},o.util.sumArrays=function(t,e){return a.zip(t,e).map(function(t,e){return a.sum(t)})},o.util.arrayLast=function(t){return t[t.length-1]},o.util.arrayEqual=function(t,e){for(var n=Math.max(t.length,e.length,1);n-- >=0&&t[n]===e[n];);return n===-2},o.util.flattenArray=function(t){for(var e=[];!o.util.arrayEqual(e,t);)e=t,t=[].concat.apply([],t);return t},o.util.deduplicate=function(t){return t.filter(function(t,e,n){return n.indexOf(t)==e})},o.util.convertToCartesian=function(t,e){var n=e*Math.PI/180,r=t*Math.cos(n),a=t*Math.sin(n);return[r,a]},o.util.round=function(t,e){var n=e||2,r=Math.pow(10,n);return Math.round(t*r)/r},o.util.getMousePos=function(t){var e=a.mouse(t.node()),n=e[0],r=e[1],o={};return o.x=n,o.y=r,o.pos=e,o.angle=180*(Math.atan2(r,n)+Math.PI)/Math.PI,o.radius=Math.sqrt(n*n+r*r),o},o.util.duplicatesCount=function(t){for(var e,n={},r={},a=0,o=t.length;a0)){var l=a.select(this.parentNode).selectAll("path.line").data([0]);l.enter().insert("path"),l.attr({class:"line",d:d(i),transform:function(e,n){return"rotate("+(t.orientation+90)+")"},"pointer-events":"none"}).style({fill:function(t,e){return m.fill(n,r,o)},"fill-opacity":0,stroke:function(t,e){return m.stroke(n,r,o)},"stroke-width":function(t,e){return m["stroke-width"](n,r,o)},"stroke-dasharray":function(t,e){return m["stroke-dasharray"](n,r,o)},opacity:function(t,e){return m.opacity(n,r,o)},display:function(t,e){return m.display(n,r,o)}})}};var h=t.angularScale.range(),p=Math.abs(h[1]-h[0])/s[0].length*Math.PI/180,g=a.svg.arc().startAngle(function(t){return-p/2}).endAngle(function(t){return p/2}).innerRadius(function(e){return t.radialScale(u+(e[2]||0))}).outerRadius(function(e){return t.radialScale(u+(e[2]||0))+t.radialScale(e[1])});f.arc=function(e,n,r){a.select(this).attr({class:"mark arc",d:g,transform:function(e,n){return"rotate("+(t.orientation+c(e[0])+90)+")"}})};var m={fill:function(t,n,r){return e[r].data.color},stroke:function(t,n,r){return e[r].data.strokeColor},"stroke-width":function(t,n,r){return e[r].data.strokeSize+"px"},"stroke-dasharray":function(t,n,r){return l[e[r].data.strokeDash]},opacity:function(t,n,r){return e[r].data.opacity},display:function(t,n,r){return"undefined"==typeof e[r].data.visible||e[r].data.visible?"block":"none"}},v=a.select(this).selectAll("g.layer").data(s);v.enter().append("g").attr({class:"layer"});var y=v.selectAll("path.mark").data(function(t,e){return t});y.enter().append("path").attr({class:"mark"}),y.style(m).each(f[t.geometryType]),y.exit().remove(),v.exit().remove()})}var e,n=[o.PolyChart.defaultConfig()],r=a.dispatch("hover"),l={solid:"none",dash:[5,2],dot:[2,5]};return t.config=function(t){return arguments.length?(t.forEach(function(t,e){n[e]||(n[e]={}),i(n[e],o.PolyChart.defaultConfig()),i(n[e],t)}),this):n},t.getColorScale=function(){return e},a.rebind(t,r,"on"),t},o.PolyChart.defaultConfig=function(){var t={data:{name:"geom1",t:[[1,2,3,4]],r:[[1,2,3,4]],dotType:"circle",dotSize:64,dotVisible:!1,barWidth:20,color:"#ffa500",strokeSize:1,strokeColor:"silver",strokeDash:"solid",opacity:1,index:0,visible:!0,visibleInLegend:!0},geometryConfig:{geometry:"LinePlot",geometryType:"arc",direction:"clockwise",orientation:0,container:"body",radialScale:null,angularScale:null,colorScale:a.scale.category20()}};return t},o.BarChart=function(){return o.PolyChart()},o.BarChart.defaultConfig=function(){var t={geometryConfig:{geometryType:"bar"}};return t},o.AreaChart=function(){return o.PolyChart()},o.AreaChart.defaultConfig=function(){var t={geometryConfig:{geometryType:"arc"}};return t},o.DotPlot=function(){return o.PolyChart()},o.DotPlot.defaultConfig=function(){var t={geometryConfig:{geometryType:"dot",dotType:"circle"}};return t},o.LinePlot=function(){return o.PolyChart()},o.LinePlot.defaultConfig=function(){var t={geometryConfig:{geometryType:"line"}};return t},o.Legend=function(){function t(){var n=e.legendConfig,r=e.data.map(function(t,e){return[].concat(t).map(function(t,r){var a=i({},n.elements[e]);return a.name=t,a.color=[].concat(n.elements[e].color)[r],a})}),o=a.merge(r);o=o.filter(function(t,e){return n.elements[e]&&(n.elements[e].visibleInLegend||"undefined"==typeof n.elements[e].visibleInLegend)}),n.reverseOrder&&(o=o.reverse());var l=n.container;("string"==typeof l||l.nodeName)&&(l=a.select(l));var s=o.map(function(t,e){return t.color}),c=n.fontSize,u=null==n.isContinuous?"number"==typeof o[0]:n.isContinuous,f=u?n.height:c*o.length,d=l.classed("legend-group",!0),h=d.selectAll("svg").data([0]),p=h.enter().append("svg").attr({width:300,height:f+c,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"});p.append("g").classed("legend-axis",!0),p.append("g").classed("legend-marks",!0);var g=a.range(o.length),m=a.scale[u?"linear":"ordinal"]().domain(g).range(s),v=a.scale[u?"linear":"ordinal"]().domain(g)[u?"range":"rangePoints"]([0,f]),y=function(t,e){var n=3*e;return"line"===t?"M"+[[-e/2,-e/12],[e/2,-e/12],[e/2,e/12],[-e/2,e/12]]+"Z":a.svg.symbolTypes.indexOf(t)!=-1?a.svg.symbol().type(t).size(n)():a.svg.symbol().type("square").size(n)()};if(u){var x=h.select(".legend-marks").append("defs").append("linearGradient").attr({id:"grad1",x1:"0%",y1:"0%",x2:"0%",y2:"100%"}).selectAll("stop").data(s);x.enter().append("stop"),x.attr({offset:function(t,e){return e/(s.length-1)*100+"%"}}).style({"stop-color":function(t,e){return t}}),h.append("rect").classed("legend-mark",!0).attr({height:n.height,width:n.colorBandWidth,fill:"url(#grad1)"})}else{var b=h.select(".legend-marks").selectAll("path.legend-mark").data(o);b.enter().append("path").classed("legend-mark",!0),b.attr({transform:function(t,e){return"translate("+[c/2,v(e)+c/2]+")"},d:function(t,e){var n=t.symbol;return y(n,c)},fill:function(t,e){return m(e)}}),b.exit().remove()}var _=a.svg.axis().scale(v).orient("right"),w=h.select("g.legend-axis").attr({transform:"translate("+[u?n.colorBandWidth:c,c/2]+")"}).call(_);return w.selectAll(".domain").style({fill:"none",stroke:"none"}),w.selectAll("line").style({fill:"none",stroke:u?n.textColor:"none"}),w.selectAll("text").style({fill:n.textColor,"font-size":n.fontSize}).text(function(t,e){return o[e].name}),t}var e=o.Legend.defaultConfig(),n=a.dispatch("hover");return t.config=function(t){return arguments.length?(i(e,t),this):e},a.rebind(t,n,"on"),t},o.Legend.defaultConfig=function(t,e){var n={data:["a","b","c"],legendConfig:{elements:[{symbol:"line",color:"red"},{symbol:"square",color:"yellow"},{symbol:"diamond",color:"limegreen"}],height:150,colorBandWidth:30,fontSize:12,container:"body",isContinuous:null,textColor:"grey",reverseOrder:!1}};return n},o.tooltipPanel=function(){var t,e,n,r={container:null,hasTick:!1,fontSize:12,color:"white",padding:5},l="tooltip-"+o.tooltipPanel.uid++,s=10,c=function(){t=r.container.selectAll("g."+l).data([0]);var a=t.enter().append("g").classed(l,!0).style({"pointer-events":"none",display:"none"});return n=a.append("path").style({fill:"white","fill-opacity":.9}).attr({d:"M0 0"}),e=a.append("text").attr({dx:r.padding+s,dy:.3*+r.fontSize}),c};return c.text=function(o){var i=a.hsl(r.color).l,l=i>=.5?"#aaa":"white",u=i>=.5?"black":"white",f=o||"";e.style({fill:u,"font-size":r.fontSize+"px"}).text(f);var d=r.padding,h=e.node().getBBox(),p={fill:r.color,stroke:l,"stroke-width":"2px"},g=h.width+2*d+s,m=h.height+2*d;return n.attr({d:"M"+[[s,-m/2],[s,-m/4],[r.hasTick?0:s,0],[s,m/4],[s,m/2],[g,m/2],[g,-m/2]].join("L")+"Z"}).style(p),t.attr({transform:"translate("+[s,-m/2+2*d]+")"}),t.style({display:"block"}),c},c.move=function(e){if(t)return t.attr({transform:"translate("+[e[0],e[1]]+")"}).style({display:"block"}),c},c.hide=function(){if(t)return t.style({display:"none"}),c},c.show=function(){if(t)return t.style({display:"block"}),c},c.config=function(t){return i(r,t),c},c},o.tooltipPanel.uid=1,o.adapter={},o.adapter.plotly=function(){var t={};return t.convert=function(t,e){var n={};if(t.data&&(n.data=t.data.map(function(t,n){var r=i({},t),a=[[r,["marker","color"],["color"]],[r,["marker","opacity"],["opacity"]],[r,["marker","line","color"],["strokeColor"]],[r,["marker","line","dash"],["strokeDash"]],[r,["marker","line","width"],["strokeSize"]],[r,["marker","symbol"],["dotType"]],[r,["marker","size"],["dotSize"]],[r,["marker","barWidth"],["barWidth"]],[r,["line","interpolation"],["lineInterpolation"]],[r,["showlegend"],["visibleInLegend"]]];return a.forEach(function(t,n){o.util.translator.apply(null,t.concat(e))}),e||delete r.marker,e&&delete r.groupId,e?("LinePlot"===r.geometry?(r.type="scatter",r.dotVisible===!0?(delete r.dotVisible,r.mode="lines+markers"):r.mode="lines"):"DotPlot"===r.geometry?(r.type="scatter",r.mode="markers"):"AreaChart"===r.geometry?r.type="area":"BarChart"===r.geometry&&(r.type="bar"),delete r.geometry):("scatter"===r.type?"lines"===r.mode?r.geometry="LinePlot":"markers"===r.mode?r.geometry="DotPlot":"lines+markers"===r.mode&&(r.geometry="LinePlot",r.dotVisible=!0):"area"===r.type?r.geometry="AreaChart":"bar"===r.type&&(r.geometry="BarChart"),delete r.mode,delete r.type),r}),!e&&t.layout&&"stack"===t.layout.barmode)){var r=o.util.duplicates(n.data.map(function(t,e){return t.geometry}));n.data.forEach(function(t,e){var a=r.indexOf(t.geometry);a!=-1&&(n.data[e].groupId=a)})}if(t.layout){var l=i({},t.layout),s=[[l,["plot_bgcolor"],["backgroundColor"]],[l,["showlegend"],["showLegend"]],[l,["radialaxis"],["radialAxis"]],[l,["angularaxis"],["angularAxis"]],[l.angularaxis,["showline"],["gridLinesVisible"]],[l.angularaxis,["showticklabels"],["labelsVisible"]],[l.angularaxis,["nticks"],["ticksCount"]],[l.angularaxis,["tickorientation"],["tickOrientation"]],[l.angularaxis,["ticksuffix"],["ticksSuffix"]],[l.angularaxis,["range"],["domain"]],[l.angularaxis,["endpadding"],["endPadding"]],[l.radialaxis,["showline"],["gridLinesVisible"]],[l.radialaxis,["tickorientation"],["tickOrientation"]],[l.radialaxis,["ticksuffix"],["ticksSuffix"]],[l.radialaxis,["range"],["domain"]],[l.angularAxis,["showline"],["gridLinesVisible"]],[l.angularAxis,["showticklabels"],["labelsVisible"]],[l.angularAxis,["nticks"],["ticksCount"]],[l.angularAxis,["tickorientation"],["tickOrientation"]],[l.angularAxis,["ticksuffix"],["ticksSuffix"]],[l.angularAxis,["range"],["domain"]],[l.angularAxis,["endpadding"],["endPadding"]],[l.radialAxis,["showline"],["gridLinesVisible"]],[l.radialAxis,["tickorientation"],["tickOrientation"]],[l.radialAxis,["ticksuffix"],["ticksSuffix"]],[l.radialAxis,["range"],["domain"]],[l.font,["outlinecolor"],["outlineColor"]],[l.legend,["traceorder"],["reverseOrder"]],[l,["labeloffset"],["labelOffset"]],[l,["defaultcolorrange"],["defaultColorRange"]]];if(s.forEach(function(t,n){o.util.translator.apply(null,t.concat(e))}),e?("undefined"!=typeof l.tickLength&&(l.angularaxis.ticklen=l.tickLength,delete l.tickLength),l.tickColor&&(l.angularaxis.tickcolor=l.tickColor,delete l.tickColor)):(l.angularAxis&&"undefined"!=typeof l.angularAxis.ticklen&&(l.tickLength=l.angularAxis.ticklen),l.angularAxis&&"undefined"!=typeof l.angularAxis.tickcolor&&(l.tickColor=l.angularAxis.tickcolor)),l.legend&&"boolean"!=typeof l.legend.reverseOrder&&(l.legend.reverseOrder="normal"!=l.legend.reverseOrder),l.legend&&"boolean"==typeof l.legend.traceorder&&(l.legend.traceorder=l.legend.traceorder?"reversed":"normal",delete l.legend.reverseOrder),l.margin&&"undefined"!=typeof l.margin.t){var c=["t","r","b","l","pad"],u=["top","right","bottom","left","pad"],f={};a.entries(l.margin).forEach(function(t,e){f[u[c.indexOf(t.key)]]=t.value}),l.margin=f}e&&(delete l.needsEndSpacing,delete l.minorTickColor,delete l.minorTicks,delete l.angularaxis.ticksCount,delete l.angularaxis.ticksCount,delete l.angularaxis.ticksStep,delete l.angularaxis.rewriteTicks,delete l.angularaxis.nticks,delete l.radialaxis.ticksCount,delete l.radialaxis.ticksCount,delete l.radialaxis.ticksStep,delete l.radialaxis.rewriteTicks,delete l.radialaxis.nticks),n.layout=l}return n},t}},{"../../plotly":120,"./micropolar_manager":147,d3:14}],147:[function(t,e,n){"use strict";var r=t("../../plotly"),a=t("d3"),o=t("./undo_manager"),i=e.exports={},l=r.Lib.extendDeepAll;i.framework=function(t){function e(e,o){return o&&(f=o),a.select(a.select(f).node().parentNode).selectAll(".svg-container>*:not(.chart-root)").remove(),n=n?l(n,e):e,c||(c=r.micropolar.Axis()),u=r.micropolar.adapter.plotly().convert(n),c.config(u).render(f),t.data=n.data,t.layout=n.layout,i.fillLayout(t),n}var n,s,c,u,f,d=new o;return e.isPolar=!0,e.svg=function(){return c.svg()},e.getConfig=function(){return n},e.getLiveConfig=function(){return r.micropolar.adapter.plotly().convert(c.getLiveConfig(),!0)},e.getLiveScales=function(){return{t:c.angularScale(),r:c.radialScale()}},e.setUndoPoint=function(){var t=this,e=r.micropolar.util.cloneJson(n);!function(e,n){d.add({undo:function(){n&&t(n)},redo:function(){t(e)}})}(e,s),s=r.micropolar.util.cloneJson(e)},e.undo=function(){d.undo()},e.redo=function(){d.redo()},e},i.fillLayout=function(t){var e=a.select(t).selectAll(".plot-container"),n=e.selectAll(".svg-container"),o=t.framework&&t.framework.svg&&t.framework.svg(),i={width:800,height:600,paper_bgcolor:r.Color.background,_container:e,_paperdiv:n,_paper:o};t._fullLayout=l(i,t.layout)}},{"../../plotly":120,"./undo_manager":148,d3:14}],148:[function(t,e,n){"use strict";e.exports=function(){function t(t,e){return t?(a=!0,t[e](),a=!1,this):this; ++}var e,n=[],r=-1,a=!1;return{add:function(t){return a?this:(n.splice(r+1,n.length-r),n.push(t),r=n.length-1,this)},setCallback:function(t){e=t},undo:function(){var a=n[r];return a?(t(a,"undo"),r-=1,e&&e(a.undo),this):this},redo:function(){var a=n[r+1];return a?(t(a,"redo"),r+=1,e&&e(a.redo),this):this},clear:function(){n=[],r=-1},hasUndo:function(){return r!==-1},hasRedo:function(){return r=i&&(h.min=0,p.min=0,g.min=0,t.aaxis&&delete t.aaxis.min,t.baxis&&delete t.baxis.min,t.caxis&&delete t.caxis.min)}var a=t("../../../components/color"),o=t("../../subplot_defaults"),i=t("./layout_attributes"),l=t("./axis_defaults"),s=["aaxis","baxis","caxis"];e.exports=function(t,e,n){o(t,e,n,{type:"ternary",attributes:i,handleDefaults:r,font:e.font,paper_bgcolor:e.paper_bgcolor})}},{"../../../components/color":25,"../../subplot_defaults":149,"./axis_defaults":153,"./layout_attributes":155}],155:[function(t,e,n){"use strict";var r=t("../../../components/color/attributes"),a=t("./axis_attributes");e.exports={domain:{x:{valType:"info_array",items:[{valType:"number",min:0,max:1},{valType:"number",min:0,max:1}],dflt:[0,1]},y:{valType:"info_array",items:[{valType:"number",min:0,max:1},{valType:"number",min:0,max:1}],dflt:[0,1]}},bgcolor:{valType:"color",dflt:r.background},sum:{valType:"number",dflt:1,min:0},aaxis:a,baxis:a,caxis:a}},{"../../../components/color/attributes":24,"./axis_attributes":152}],156:[function(t,e,n){"use strict";function r(t,e){this.id=t.id,this.graphDiv=t.graphDiv,this.init(e),this.makeFramework()}function a(t){o.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}var o=t("d3"),i=t("tinycolor2"),l=t("../../plotly"),s=t("../../lib"),c=t("../../components/color"),u=t("../../components/drawing"),f=t("../cartesian/set_convert"),d=t("../../lib/extend").extendFlat,h=t("../cartesian/axes"),p=t("../../lib/filter_visible"),g=t("../../components/dragelement"),m=t("../../components/titles"),v=t("../cartesian/select"),y=t("../cartesian/constants"),x=t("../cartesian/graph_interact");e.exports=r;var b=r.prototype;b.init=function(t){this.container=t._ternarylayer,this.defs=t._defs,this.layoutId=t._uid,this.traceHash={}},b.plot=function(t,e){var n,r=this,a=e[r.id],o=e._size;s.getPlotDiv(r.plotContainer.node())!==r.graphDiv&&(r.init(r.graphDiv._fullLayout),r.makeFramework()),r.adjustLayout(a,o);var i=r.traceHash,l={};for(n=0;n_*y?(o=y,a=o*_):(a=v,o=a/_),i=g*a/v,l=m*o/y,n=e.l+e.w*h-a/2,r=e.t+e.h*(1-p)-o/2,s.x0=n,s.y0=r,s.w=a,s.h=o,s.sum=x,s.xaxis={type:"linear",range:[b+2*k-x,x-b-2*w],domain:[h-i/2,h+i/2],_id:"x",_gd:s.graphDiv},f(s.xaxis),s.xaxis.setScale(),s.yaxis={type:"linear",range:[b,x-w-k],domain:[p-l/2,p+l/2],_id:"y",_gd:s.graphDiv},f(s.yaxis),s.yaxis.setScale();var M=s.yaxis.domain[0],A=s.aaxis=d({},t.aaxis,{range:[b,x-w-k],side:"left",_counterangle:30,tickangle:(+t.aaxis.tickangle||0)-30,domain:[M,M+l*_],_axislayer:s.layers.aaxis,_gridlayer:s.layers.agrid,_pos:0,_gd:s.graphDiv,_id:"y",_length:a,_gridpath:"M0,0l"+o+",-"+a/2});f(A);var T=s.baxis=d({},t.baxis,{range:[x-b-k,w],side:"bottom",_counterangle:30,domain:s.xaxis.domain,_axislayer:s.layers.baxis,_gridlayer:s.layers.bgrid,_counteraxis:s.aaxis,_pos:0,_gd:s.graphDiv,_id:"x",_length:a,_gridpath:"M0,0l-"+a/2+",-"+o});f(T),A._counteraxis=T;var L=s.caxis=d({},t.caxis,{range:[x-b-w,k],side:"right",_counterangle:30,tickangle:(+t.caxis.tickangle||0)+30,domain:[M,M+l*_],_axislayer:s.layers.caxis,_gridlayer:s.layers.cgrid,_counteraxis:s.baxis,_pos:0,_gd:s.graphDiv,_id:"y",_length:a,_gridpath:"M0,0l-"+o+","+a/2});f(L);var z="M"+n+","+(r+o)+"h"+a+"l-"+a/2+",-"+o+"Z";s.clipDef.select("path").attr("d",z),s.layers.plotbg.select("path").attr("d",z);var S="translate("+n+","+r+")";s.plotContainer.selectAll(".scatterlayer,.maplayer,.zoom").attr("transform",S);var C="translate("+n+","+(r+o)+")";s.layers.baxis.attr("transform",C),s.layers.bgrid.attr("transform",C);var E="translate("+(n+a/2)+","+r+")rotate(30)";s.layers.aaxis.attr("transform",E),s.layers.agrid.attr("transform",E);var O="translate("+(n+a/2)+","+r+")rotate(-30)";s.layers.caxis.attr("transform",O),s.layers.cgrid.attr("transform",O),s.drawAxes(!0),s.plotContainer.selectAll(".crisp").classed("crisp",!1);var P=s.layers.axlines;P.select(".aline").attr("d",A.showline?"M"+n+","+(r+o)+"l"+a/2+",-"+o:"M0,0").call(c.stroke,A.linecolor||"#000").style("stroke-width",(A.linewidth||0)+"px"),P.select(".bline").attr("d",T.showline?"M"+n+","+(r+o)+"h"+a:"M0,0").call(c.stroke,T.linecolor||"#000").style("stroke-width",(T.linewidth||0)+"px"),P.select(".cline").attr("d",L.showline?"M"+(n+a/2)+","+r+"l"+a/2+","+o:"M0,0").call(c.stroke,L.linecolor||"#000").style("stroke-width",(L.linewidth||0)+"px")},b.drawAxes=function(t){var e=this,n=e.graphDiv,r=e.id.substr(7)+"title",a=e.aaxis,o=e.baxis,i=e.caxis;if(h.doTicks(n,a,!0),h.doTicks(n,o,!0),h.doTicks(n,i,!0),t){var l=Math.max(a.showticklabels?a.tickfont.size/2:0,(i.showticklabels?.75*i.tickfont.size:0)+("outside"===i.ticks?.87*i.ticklen:0));m.draw(n,"a"+r,{propContainer:a,propName:e.id+".aaxis.title",dfltName:"Component A",attributes:{x:e.x0+e.w/2,y:e.y0-a.titlefont.size/3-l,"text-anchor":"middle"}});var s=(o.showticklabels?o.tickfont.size:0)+("outside"===o.ticks?o.ticklen:0)+3;m.draw(n,"b"+r,{propContainer:o,propName:e.id+".baxis.title",dfltName:"Component B",attributes:{x:e.x0-s,y:e.y0+e.h+.83*o.titlefont.size+s,"text-anchor":"middle"}}),m.draw(n,"c"+r,{propContainer:i,propName:e.id+".caxis.title",dfltName:"Component C",attributes:{x:e.x0+e.w+s,y:e.y0+e.h+.83*i.titlefont.size+s,"text-anchor":"middle"}})}};var w=y.MINZOOM/2+.87,k="m-0.87,.5h"+w+"v3h-"+(w+5.2)+"l"+(w/2+2.6)+",-"+(.87*w+4.5)+"l2.6,1.5l-"+w/2+","+.87*w+"Z",M="m0.87,.5h-"+w+"v3h"+(w+5.2)+"l-"+(w/2+2.6)+",-"+(.87*w+4.5)+"l-2.6,1.5l"+w/2+","+.87*w+"Z",A="m0,1l"+w/2+","+.87*w+"l2.6,-1.5l-"+(w/2+2.6)+",-"+(.87*w+4.5)+"l-"+(w/2+2.6)+","+(.87*w+4.5)+"l2.6,1.5l"+w/2+",-"+.87*w+"Z",T="m0.5,0.5h5v-2h-5v-5h-2v5h-5v2h5v5h2Z",L=!0;b.initInteractions=function(){function t(t,e,n){var r=R.getBoundingClientRect();b=e-r.left,w=n-r.top,z={a:I.aaxis.range[0],b:I.baxis.range[1],c:I.caxis.range[1]},C=z,S=I.aaxis.range[1]-z.a,E=i(I.graphDiv._fullLayout[I.id].bgcolor).getLuminance(),O="M0,"+I.h+"L"+I.w/2+", 0L"+I.w+","+I.h+"Z",P=!1,N=F.append("path").attr("class","zoombox").style({fill:E>.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("d",O),D=F.append("path").attr("class","zoombox-corners").style({fill:c.background,stroke:c.defaultLine,"stroke-width":1,opacity:0}).attr("d","M0,0Z"),p()}function e(t,e){return 1-e/I.h}function n(t,e){return 1-(t+(I.h-e)/Math.sqrt(3))/I.w}function r(t,e){return(t-(I.h-e)/Math.sqrt(3))/I.w}function o(t,a){var o=b+t,i=w+a,l=Math.max(0,Math.min(1,e(b,w),e(o,i))),s=Math.max(0,Math.min(1,n(b,w),n(o,i))),c=Math.max(0,Math.min(1,r(b,w),r(o,i))),u=(l/2+c)*I.w,f=(1-l/2-s)*I.w,d=(u+f)/2,h=f-u,p=(1-l)*I.h,g=p-h/_;h.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),D.transition().style("opacity",1).duration(200),P=!0)}function u(t,e){if(C===z)return 2===e&&m(),a(j);a(j);var n={};n[I.id+".aaxis.min"]=C.a,n[I.id+".baxis.min"]=C.b,n[I.id+".caxis.min"]=C.c,l.relayout(j,n),L&&j.data&&j._context.showTips&&(s.notifier("Double-click to
zoom back out","long"),L=!1)}function f(){z={a:I.aaxis.range[0],b:I.baxis.range[1],c:I.caxis.range[1]},C=z}function d(t,e){var n=t/I.xaxis._m,r=e/I.yaxis._m;C={a:z.a-r,b:z.b+(n+r)/2,c:z.c-(n-r)/2};var a=[C.a,C.b,C.c].sort(),o={a:a.indexOf(C.a),b:a.indexOf(C.b),c:a.indexOf(C.c)};a[0]<0&&(a[1]+a[0]/2<0?(a[2]+=a[0]+a[1],a[0]=a[1]=0):(a[2]+=a[0]/2,a[1]+=a[0]/2,a[0]=0),C={a:a[o.a],b:a[o.b],c:a[o.c]},e=(z.a-C.a)*I.yaxis._m,t=(z.c-C.c-z.b+C.b)*I.xaxis._m);var i="translate("+(I.x0+t)+","+(I.y0+e)+")";I.plotContainer.selectAll(".scatterlayer,.maplayer").attr("transform",i),I.aaxis.range=[C.a,I.sum-C.b-C.c],I.baxis.range=[I.sum-C.a-C.c,C.b],I.caxis.range=[I.sum-C.a-C.b,C.c],I.drawAxes(!1),I.plotContainer.selectAll(".crisp").classed("crisp",!1)}function h(t,e){if(t){var n={};n[I.id+".aaxis.min"]=C.a,n[I.id+".baxis.min"]=C.b,n[I.id+".caxis.min"]=C.c,l.relayout(j,n)}else 2===e&&m()}function p(){I.plotContainer.selectAll(".select-outline").remove()}function m(){var t={};t[I.id+".aaxis.min"]=0,t[I.id+".baxis.min"]=0,t[I.id+".caxis.min"]=0,j.emit("plotly_doubleclick",null),l.relayout(j,t)}var b,w,z,S,C,E,O,P,N,D,I=this,R=I.layers.plotbg.select("path").node(),j=I.graphDiv,F=I.layers.zoom,q={element:R,gd:j,plotinfo:{plot:F},doubleclick:m,subplot:I.id,prepFn:function(e,n,r){q.xaxes=[I.xaxis],q.yaxes=[I.yaxis];var a=j._fullLayout.dragmode;e.shiftKey&&(a="pan"===a?"zoom":"pan"),"lasso"===a?q.minDrag=1:q.minDrag=void 0,"zoom"===a?(q.moveFn=o,q.doneFn=u,t(e,n,r)):"pan"===a?(q.moveFn=d,q.doneFn=h,f(),p()):"select"!==a&&"lasso"!==a||v(e,n,r,q,a)}};R.onmousemove=function(t){x.hover(j,t,I.id),j._fullLayout._lasthover=R,j._fullLayout._hoversubplot=I.id},R.onmouseout=function(t){j._dragging||g.unhover(j,t)},R.onclick=function(t){x.click(j,t)},g.init(q)}},{"../../components/color":25,"../../components/dragelement":46,"../../components/drawing":48,"../../components/titles":88,"../../lib":102,"../../lib/extend":100,"../../lib/filter_visible":101,"../../plotly":120,"../cartesian/axes":123,"../cartesian/constants":128,"../cartesian/graph_interact":130,"../cartesian/select":136,"../cartesian/set_convert":137,d3:14,tinycolor2:20}],157:[function(t,e,n){"use strict";function r(t){var e;switch(t){case"themes__thumb":e={autosize:!0,width:150,height:150,title:"",showlegend:!1,margin:{l:5,r:5,t:5,b:5,pad:0},annotations:[]};break;case"thumbnail":e={title:"",hidesources:!0,showlegend:!1,borderwidth:0,bordercolor:"",margin:{l:1,r:1,t:1,b:1,pad:0},annotations:[]};break;default:e={}}return e}function a(t){var e=["xaxis","yaxis","zaxis"];return e.indexOf(t.slice(0,5))>-1}var o=t("../plotly"),i=o.Lib.extendFlat,l=o.Lib.extendDeep;e.exports=function(t,e){t.framework&&t.framework.isPolar&&(t=t.framework.getConfig());var n,s=t.data,c=t.layout,u=l([],s),f=l({},c,r(e.tileClass));if(e.width&&(f.width=e.width),e.height&&(f.height=e.height),"thumbnail"===e.tileClass||"themes__thumb"===e.tileClass){f.annotations=[];var d=Object.keys(f);for(n=0;n=2?o(t):t>e?Math.ceil(t):Math.floor(t)}var d,h,p,g;if("h"===l.orientation?(p=u.c2p(n.poffset+e.p,!0),g=u.c2p(n.poffset+e.p+n.barwidth,!0),d=c.c2p(e.b,!0),h=c.c2p(e.s+e.b,!0)):(d=c.c2p(n.poffset+e.p,!0),h=c.c2p(n.poffset+e.p+n.barwidth,!0),g=u.c2p(e.s+e.b,!0),p=u.c2p(e.b,!0)),!(a(d)&&a(h)&&a(p)&&a(g)&&d!==h&&p!==g))return void r.select(this).remove();var m=(e.mlw+1||l.marker.line.width+1||(e.trace?e.trace.marker.line.width:0)+1)-1,v=r.round(m/2%1,2);if(!t._context.staticPlot){var y=i.opacity(e.mc||l.marker.color),x=y<1||m>.01?o:s;d=x(d,h),h=x(h,d),p=x(p,g),g=x(g,p)}r.select(this).attr("d","M"+d+","+p+"V"+g+"H"+h+"V"+p+"Z")})}),d.call(l.plot,e)}},{"../../components/color":25,"../../components/errorbars":54,"../../lib":102,"./arrays_to_calcdata":164,d3:14,"fast-isnumeric":17}],173:[function(t,e,n){"use strict";var r=t("fast-isnumeric"),a=t("../../plots/plots"),o=t("../../plots/cartesian/axes"),i=t("../../lib");e.exports=function(t,e){var n,l,s=t._fullLayout,c=e.x(),u=e.y();["v","h"].forEach(function(f){function d(e){function n(t){t[p]=t.p+d}var r=[];e.forEach(function(e){t.calcdata[e].forEach(function(t){r.push(t.p)})});var a=i.distinctVals(r),l=a.vals,c=a.minDiff,u=!1,f=[];"group"===s.barmode&&e.forEach(function(e){u||(t.calcdata[e].forEach(function(t){u||f.forEach(function(e){Math.abs(t.p-e)M+P&&(S=!0,M=_))}o.expand(v,[A,M],{tozero:!0,padded:S})}else{var N=function(t){return t[g]=t.s,t.s};for(n=0;n1||0===l.bargap&&0===l.bargroupgap&&!t[0].trace.marker.line.width)&&r.select(this).attr("shape-rendering","crispEdges")}),e.selectAll("g.points").each(function(t){var e=t[0].trace,n=e.marker,i=n.line,l=(e._input||{}).marker||{},s=o.tryColorscale(n,l,""),c=o.tryColorscale(n,l,"line.");r.select(this).selectAll("path").each(function(t){var e,o,l=(t.mlw+1||i.width+1)-1,u=r.select(this);e="mc"in t?t.mcc=s(t.mc):Array.isArray(n.color)?a.defaultLine:n.color, ++u.style("stroke-width",l+"px").call(a.fill,e),l&&(o="mlc"in t?t.mlcc=c(t.mlc):Array.isArray(i.color)?a.defaultLine:i.color,u.call(a.stroke,o))})}),e.call(i.style)}},{"../../components/color":25,"../../components/drawing":48,"../../components/errorbars":54,d3:14}],175:[function(t,e,n){"use strict";var r=t("../../components/color"),a=t("../../components/colorscale/has_colorscale"),o=t("../../components/colorscale/defaults");e.exports=function(t,e,n,i,l){n("marker.color",i),a(t,"marker")&&o(t,e,l,n,{prefix:"marker.",cLetter:"c"}),n("marker.line.color",r.defaultLine),a(t,"marker.line")&&o(t,e,l,n,{prefix:"marker.line.",cLetter:"c"}),n("marker.line.width")}},{"../../components/color":25,"../../components/colorscale/defaults":35,"../../components/colorscale/has_colorscale":38}],176:[function(t,e,n){"use strict";var r=t("../scatter/attributes"),a=t("../../components/color/attributes"),o=t("../../lib/extend").extendFlat,i=r.marker,l=i.line;e.exports={y:{valType:"data_array"},x:{valType:"data_array"},x0:{valType:"any"},y0:{valType:"any"},whiskerwidth:{valType:"number",min:0,max:1,dflt:.5},boxpoints:{valType:"enumerated",values:["all","outliers","suspectedoutliers",!1],dflt:"outliers"},boxmean:{valType:"enumerated",values:[!0,"sd",!1],dflt:!1},jitter:{valType:"number",min:0,max:1},pointpos:{valType:"number",min:-2,max:2},orientation:{valType:"enumerated",values:["v","h"]},marker:{outliercolor:{valType:"color",dflt:"rgba(0, 0, 0, 0)"},symbol:o({},i.symbol,{arrayOk:!1}),opacity:o({},i.opacity,{arrayOk:!1,dflt:1}),size:o({},i.size,{arrayOk:!1}),color:o({},i.color,{arrayOk:!1}),line:{color:o({},l.color,{arrayOk:!1,dflt:a.defaultLine}),width:o({},l.width,{arrayOk:!1,dflt:0}),outliercolor:{valType:"color"},outlierwidth:{valType:"number",min:0,dflt:1}}},line:{color:{valType:"color"},width:{valType:"number",min:0,dflt:2}},fillcolor:r.fillcolor}},{"../../components/color/attributes":24,"../../lib/extend":100,"../scatter/attributes":236}],177:[function(t,e,n){"use strict";var r=t("fast-isnumeric"),a=t("../../lib"),o=t("../../plots/cartesian/axes");e.exports=function(t,e){function n(t,e,n,o,i){var l;return n in e?p=o.makeCalcdata(e,n):(l=n+"0"in e?e[n+"0"]:"name"in e&&("category"===o.type||r(e.name)&&["linear","log"].indexOf(o.type)!==-1||a.isDateTime(e.name)&&"date"===o.type)?e.name:t.numboxes,l=o.d2c(l),p=i.map(function(){return l})),p}function i(t,e,n,o,i){var l,s,c,u,f=o.length,d=e.length,h=[],p=[];for(l=0;l=0&&c1,v=n.dPos*(1-d.boxgap)*(1-d.boxgroupgap)/(m?t.numboxes:1),y=m?2*n.dPos*(-.5+(n.boxnum+.5)/t.numboxes)*(1-d.boxgap):0,x=v*g.whiskerwidth;return g.visible!==!0||n.emptybox?void o.select(this).remove():("h"===g.orientation?(s=p,f=h):(s=h,f=p),n.bPos=y,n.bdPos=v,r(),o.select(this).selectAll("path.box").data(i.identity).enter().append("path").attr("class","box").each(function(t){var e=s.c2p(t.pos+y,!0),n=s.c2p(t.pos+y-v,!0),r=s.c2p(t.pos+y+v,!0),a=s.c2p(t.pos+y-x,!0),l=s.c2p(t.pos+y+x,!0),c=f.c2p(t.q1,!0),u=f.c2p(t.q3,!0),d=i.constrain(f.c2p(t.med,!0),Math.min(c,u)+1,Math.max(c,u)-1),h=f.c2p(g.boxpoints===!1?t.min:t.lf,!0),p=f.c2p(g.boxpoints===!1?t.max:t.uf,!0);"h"===g.orientation?o.select(this).attr("d","M"+d+","+n+"V"+r+"M"+c+","+n+"V"+r+"H"+u+"V"+n+"ZM"+c+","+e+"H"+h+"M"+u+","+e+"H"+p+(0===g.whiskerwidth?"":"M"+h+","+a+"V"+l+"M"+p+","+a+"V"+l)):o.select(this).attr("d","M"+n+","+d+"H"+r+"M"+n+","+c+"H"+r+"V"+u+"H"+n+"ZM"+e+","+c+"V"+h+"M"+e+","+u+"V"+p+(0===g.whiskerwidth?"":"M"+a+","+h+"H"+l+"M"+a+","+p+"H"+l))}),g.boxpoints&&o.select(this).selectAll("g.points").data(function(t){return t.forEach(function(t){t.t=n,t.trace=g}),t}).enter().append("g").attr("class","points").selectAll("path").data(function(t){var e,n,r,o,l,s,f,d="all"===g.boxpoints?t.val:t.val.filter(function(e){return et.uf}),h=(t.q3-t.q1)*u,p=[],m=0;if(g.jitter){for(e=0;et.lo&&(r.so=!0),r})}).enter().append("path").call(l.translatePoints,h,p),void(g.boxmean&&o.select(this).selectAll("path.mean").data(i.identity).enter().append("path").attr("class","mean").style("fill","none").each(function(t){var e=s.c2p(t.pos+y,!0),n=s.c2p(t.pos+y-v,!0),r=s.c2p(t.pos+y+v,!0),a=f.c2p(t.mean,!0),i=f.c2p(t.mean-t.sd,!0),l=f.c2p(t.mean+t.sd,!0);"h"===g.orientation?o.select(this).attr("d","M"+a+","+n+"V"+r+("sd"!==g.boxmean?"":"m0,0L"+i+","+e+"L"+a+","+n+"L"+l+","+e+"Z")):o.select(this).attr("d","M"+n+","+a+"H"+r+("sd"!==g.boxmean?"":"m0,0L"+e+","+i+"L"+n+","+a+"L"+e+","+l+"Z"))})))})}},{"../../components/drawing":48,"../../lib":102,d3:14}],184:[function(t,e,n){"use strict";var r=t("../../plots/plots"),a=t("../../plots/cartesian/axes"),o=t("../../lib");e.exports=function(t,e){var n,i,l,s,c=t._fullLayout,u=e.x(),f=e.y(),d=["v","h"];for(i=0;it?0:1)+(e[0][1]>t?0:2)+(e[1][1]>t?0:4)+(e[1][0]>t?0:8);if(5===n||10===n){var r=(e[0][0]+e[0][1]+e[1][0]+e[1][1])/4;return t>r?5===n?713:1114:5===n?104:208}return 15===n?0:n}function i(t){var e,n,r,a,i,l,s,c,u,f=t[0].z,d=f.length,h=f[0].length,p=2===d||2===h;for(n=0;n20?(l=S[l][(s[0]||s[1])<0?0:1],t.crossings[i]=C[l]):delete t.crossings[i],s=z[l],!s){_.log("Found bad marching index:",l,e,t.level);break}if(h.push(d(t,e,s)),e[0]+=s[0],e[1]+=s[1],u(h[h.length-1],h[h.length-2])&&h.pop(),i=e.join(","),i===o&&s.join(",")===p||n&&(s[0]&&(e[0]<0||e[0]>m-2)||s[1]&&(e[1]<0||e[1]>g-2)))break;l=t.crossings[i]}1e4===a&&_.log("Infinite loop in contour?");var v,y,x,b,w,k,M,A=u(h[0],h[h.length-1]),T=0,L=.2*t.smoothing,E=[],O=0;for(a=1;a=O;a--)if(v=E[a],v=O&&v+E[y]20&&e?208===t||1114===t?r=0===n[0]?1:-1:a=0===n[1]?1:-1:M.indexOf(t)!==-1?a=1:T.indexOf(t)!==-1?r=1:A.indexOf(t)!==-1?a=-1:r=-1,[r,a]}function u(t,e){return Math.abs(t[0]-e[0])<.01&&Math.abs(t[1]-e[1])<.01}function f(t,e){var n=t[0]-e[0],r=t[1]-e[1];return Math.sqrt(n*n+r*r)}function d(t,e,n){var r=e[0]+Math.max(n[0],0),a=e[1]+Math.max(n[1],0),o=t.z[a][r],i=t.xaxis,l=t.yaxis;if(n[1]){var s=(t.level-o)/(t.z[a][r+1]-o);return[i.c2p((1-s)*t.x[r]+s*t.x[r+1],!0),l.c2p(t.y[a],!0)]}var c=(t.level-o)/(t.z[a+1][r]-o);return[i.c2p(t.x[r],!0),l.c2p((1-c)*t.y[a]+c*t.y[a+1],!0)]}function h(t,e,n){var r=t.plot.select(".maplayer").selectAll("g.contour."+n).data(e);return r.enter().append("g").classed("contour",!0).classed(n,!0),r.exit().remove(),r}function p(t,e,n){var r=t.selectAll("g.contourbg").data([0]);r.enter().append("g").classed("contourbg",!0);var a=r.selectAll("path").data("fill"===n.coloring?[0]:[]);a.enter().append("path"),a.exit().remove(),a.attr("d","M"+e.join("L")+"Z").style("stroke","none")}function g(t,e,n,r){var a=t.selectAll("g.contourfill").data([0]);a.enter().append("g").classed("contourfill",!0);var o=a.selectAll("path").data("fill"===r.coloring?e:[]);o.enter().append("path"),o.exit().remove(),o.each(function(t){var e=m(t,n);e?b.select(this).attr("d",e).style("stroke","none"):b.select(this).remove()})}function m(t,e){function n(t){return Math.abs(t[1]-e[0][1])<.01}function r(t){return Math.abs(t[1]-e[2][1])<.01}function a(t){return Math.abs(t[0]-e[0][0])<.01}function o(t){return Math.abs(t[0]-e[2][0])<.01}for(var i,l,s,c,u,f,d=t.edgepaths.length||t.z[0][0]=0&&(l=m,c=u):Math.abs(i[1]-l[1])<.01?Math.abs(i[1]-m[1])<.01&&(m[0]-i[0])*(l[0]-m[0])>=0&&(l=m,c=u):_.log("endpt to newendpt is not vert. or horz.",i,l,m)}if(i=l,c>=0)break;d+="L"+l}if(c===t.edgepaths.length){_.log("unclosed perimeter path");break}h=c,g=p.indexOf(h)===-1,g&&(h=p[0],d+="Z")}for(h=0;h1;if(p&&!f&&"category"!==o.type){e=e.map(o.d2c);var g=e.length;if(!(g<=a))return u?e.slice(0,a):e.slice(0,a+1);if(u||h)c=e.slice(0,a);else if(1===a)c=[e[0]-.5,e[0]+.5];else{for(c=[1.5*e[0]-.5*e[1]],s=1;sy;r++)i=s(t,e,o(i));return i>y&&u.log("interp2d didn't converge quickly",i),t}function l(t){var e,n,r,a,o,i,l,s,c=[],u={},f=[],d=t[0],h=[],p=[0,0,0],g=v(t);for(n=0;n=0;o--)a=f[o],n=a[0],r=a[1],i=((u[[n-1,r]]||p)[2]+(u[[n+1,r]]||p)[2]+(u[[n,r-1]]||p)[2]+(u[[n,r+1]]||p)[2])/20,i&&(l[a]=[n,r,i],f.splice(o,1),s=!0);if(!s)throw"findEmpties iterated with no new neighbors";for(a in l)u[a]=l[a],c.push(l[a])}return c.sort(function(t,e){return e[2]-t[2]})}function s(t,e,n){var r,a,o,i,l,s,c,u,f,d,h,p,g,m=0;for(i=0;ip&&(m=Math.max(m,Math.abs(t[a][o]-h)/(g-p))))}return m}var c=t("fast-isnumeric"),u=t("../../lib"),f=t("../../plots/cartesian/axes"),d=t("../../plots/plots"),h=t("../histogram2d/calc"),p=t("../../components/colorscale/calc"),g=t("./has_columns"),m=t("./convert_column_xyz"),v=t("./max_row_length");e.exports=function(t,e){function n(t){L=e._input.zsmooth=e.zsmooth=!1,u.notifier("cannot fast-zsmooth: "+t)}var o,s,c,y,x,b,_,w,k=f.getFromId(t,e.xaxis||"x"),M=f.getFromId(t,e.yaxis||"y"),A=d.traceIs(e,"contour"),T=d.traceIs(e,"histogram"),L=A?"best":e.zsmooth;if(k._minDtick=0,M._minDtick=0,T){var z=h(t,e);o=z.x,s=z.x0,c=z.dx,y=z.y,x=z.y0,b=z.dy,_=z.z}else g(e)&&m(e,k,M),o=e.x?k.makeCalcdata(e,"x"):[],y=e.y?M.makeCalcdata(e,"y"):[],s=e.x0||0,c=e.dx||1,x=e.y0||0,b=e.dy||1,_=r(e),(A||e.connectgaps)&&(e._emptypoints=l(_),e._interpz=i(_,e._emptypoints,e._interpz));if("fast"===L)if("log"===k.type||"log"===M.type)n("log axis found");else if(!T){if(o.length){var S=(o[o.length-1]-o[0])/(o.length-1),C=Math.abs(S/100);for(w=0;wC){n("x scale is not linear");break}}if(y.length&&"fast"===L){var E=(y[y.length-1]-y[0])/(y.length-1),O=Math.abs(E/100);for(w=0;wO){n("y scale is not linear");break}}}var P=v(_),N="scaled"===e.xtype?"":e.x,D=a(e,N,s,c,P,k),I="scaled"===e.ytype?"":e.y,R=a(e,I,x,b,_.length,M);f.expand(k,D),f.expand(M,R);var j={x:D,y:R,z:_};if(p(e,_,"","z"),A&&e.contours&&"heatmap"===e.contours.coloring){var F="contour"===e.type?"heatmap":"histogram2d";j.xfill=a(F,N,s,c,P,k),j.yfill=a(F,I,x,b,_.length,M)}return[j]};var y=.01,x=[[-1,0],[1,0],[0,-1],[0,1]]},{"../../components/colorscale/calc":32,"../../lib":102,"../../plots/cartesian/axes":123,"../../plots/plots":143,"../histogram2d/calc":217,"./convert_column_xyz":199,"./has_columns":201,"./max_row_length":204,"fast-isnumeric":17}],198:[function(t,e,n){"use strict";var r=t("d3"),a=t("fast-isnumeric"),o=t("../../lib"),i=t("../../plots/plots"),l=t("../../components/colorscale/get_scale"),s=t("../../components/colorbar/draw");e.exports=function(t,e){var n=e[0].trace,c="cb"+n.uid,u=l(n.colorscale),f=n.zmin,d=n.zmax;if(a(f)||(f=o.aggNums(Math.min,null,n.z)),a(d)||(d=o.aggNums(Math.max,null,n.z)),t._fullLayout._infolayer.selectAll("."+c).remove(),!n.showscale)return void i.autoMargin(t,c);var h=e[0].t.cb=s(t,c);h.fillcolor(r.scale.linear().domain(u.map(function(t){return f+t[0]*(d-f)})).range(u.map(function(t){return t[1]}))).filllevels({start:f,end:d,size:(d-f)/254}).options(n.colorbar)()}},{"../../components/colorbar/draw":28,"../../components/colorscale/get_scale":37,"../../lib":102,"../../plots/plots":143,d3:14,"fast-isnumeric":17}],199:[function(t,e,n){"use strict";var r=t("../../lib");e.exports=function(t,e,n){var a,o=t.x.slice(),i=t.y.slice(),l=t.z,s=t.text,c=Math.min(o.length,i.length,l.length),u=void 0!==s&&!Array.isArray(s[0]);for(c=y[0].length||f<0||f>y.length)return}else{if(r.inbox(e-m[0],e-m[m.length-1])>o||r.inbox(n-v[0],n-v[v.length-1])>o)return;if(l){var w;for(b=[2*m[0]-m[1]],w=1;w0;)_=m.c2p(C[A]),A--;for(_0;)M=v.c2p(E[A]),A--;if(M0&&(r=!0);for(var l=0;lo)return n[t]=o,o-n[t]}return 0},max:function(t,e,n,a){var o=a[e];if(r(o)){if(o=Number(o),!r(n[t]))return n[t]=o,o;if(n[t]=0&&vI;n--)if(u[n]){R=n;break}for(n=I;n<=R;n++)r(c[n])&&r(u[n])&&D.push({p:c[n],s:u[n],b:0});return D}}},{"../../lib":102,"../../plots/cartesian/axes":123,"./average":209,"./bin_functions":211,"./norm_functions":215,"fast-isnumeric":17}],213:[function(t,e,n){"use strict";var r=t("../../lib"),a=t("../../components/color"),o=t("./bin_defaults"),i=t("../bar/style_defaults"),l=t("../../components/errorbars/defaults"),s=t("./attributes");e.exports=function(t,e,n,c){function u(n,a){return r.coerce(t,e,s,n,a)}var f=u("x"),d=u("y");u("text");var h=u("orientation",d&&!f?"h":"v"),p=e["v"===h?"x":"y"];if(!p||!p.length)return void(e.visible=!1);var g=e["h"===h?"x":"y"];g&&u("histfunc");var m="h"===h?["y"]:["x"];o(t,e,u,m),i(t,e,u,n,c),l(t,e,a.defaultLine,{axis:"y"}),l(t,e,a.defaultLine,{axis:"x",inherit:"y"})}},{"../../components/color":25,"../../components/errorbars/defaults":53,"../../lib":102,"../bar/style_defaults":175,"./attributes":208,"./bin_defaults":210}],214:[function(t,e,n){"use strict";var r={};r.attributes=t("./attributes"),r.layoutAttributes=t("../bar/layout_attributes"),r.supplyDefaults=t("./defaults"),r.supplyLayoutDefaults=t("../bar/layout_defaults"),r.calc=t("./calc"),r.setPositions=t("../bar/set_positions"),r.plot=t("../bar/plot"),r.style=t("../bar/style"),r.colorbar=t("../scatter/colorbar"),r.hoverPoints=t("../bar/hover"),r.moduleType="trace",r.name="histogram",r.basePlotModule=t("../../plots/cartesian"),r.categories=["cartesian","bar","histogram","oriented","errorBarsOK","showLegend"],r.meta={},e.exports=r},{"../../plots/cartesian":131,"../bar/hover":168,"../bar/layout_attributes":170,"../bar/layout_defaults":171,"../bar/plot":172,"../bar/set_positions":173,"../bar/style":174,"../scatter/colorbar":239,"./attributes":208,"./calc":212,"./defaults":213}],215:[function(t,e,n){"use strict";e.exports={percent:function(t,e){for(var n=t.length,r=100/e,a=0;av&&p.splice(v,p.length-v),m.length>v&&m.splice(v,m.length-v),!e.autobinx&&"xbins"in e||(e.xbins=a.autoBin(p,h,e.nbinsx,"2d"),"histogram2dcontour"===e.type&&(e.xbins.start-=e.xbins.size,e.xbins.end+=e.xbins.size),e._input.xbins=e.xbins),!e.autobiny&&"ybins"in e||(e.ybins=a.autoBin(m,g,e.nbinsy,"2d"),"histogram2dcontour"===e.type&&(e.ybins.start-=e.ybins.size,e.ybins.end+=e.ybins.size),e._input.ybins=e.ybins),f=[];var y,x,b=[],_=[],w="string"==typeof e.xbins.size?[]:e.xbins,k="string"==typeof e.xbins.size?[]:e.ybins,M=0,A=[],T=e.histnorm,L=e.histfunc,z=T.indexOf("density")!==-1,S="max"===L||"min"===L,C=S?null:0,E=o.count,O=i[T],P=!1,N=[],D=[],I="z"in e?e.z:"marker"in e&&Array.isArray(e.marker.color)?e.marker.color:"";I&&"count"!==L&&(P="avg"===L,E=o[L]);var R=e.xbins,j=R.end+(R.start-a.tickIncrement(R.start,R.size))/1e6;for(d=R.start;d=0&&y=0&&x")}return g};var s},{"../../components/color":25,"./helpers":228,"fast-isnumeric":17,tinycolor2:20}],227:[function(t,e,n){"use strict";var r=t("../../lib"),a=t("./attributes");e.exports=function(t,e,n,o){function i(n,o){return r.coerce(t,e,a,n,o)}var l=r.coerceFont,s=i("values");if(!Array.isArray(s)||!s.length)return void(e.visible=!1);var c=i("labels");Array.isArray(c)||(i("label0"),i("dlabel"));var u=i("marker.line.width");u&&i("marker.line.color");var f=i("marker.colors");Array.isArray(f)||(e.marker.colors=[]),i("scalegroup");var d=i("text"),h=i("textinfo",Array.isArray(d)?"text+percent":"percent");if(i("hoverinfo",1===o._dataLength?"label+text+value+percent":void 0),h&&"none"!==h){var p=i("textposition"),g=Array.isArray(p)||"auto"===p,m=g||"inside"===p,v=g||"outside"===p;if(m||v){var y=l(i,"textfont",o.font);m&&l(i,"insidetextfont",y),v&&l(i,"outsidetextfont",y)}}i("domain.x"),i("domain.y"),i("hole"),i("sort"),i("direction"),i("rotation"),i("pull")}},{"../../lib":102,"./attributes":224}],228:[function(t,e,n){"use strict";var r=t("../../lib");n.formatPiePercent=function(t,e){var n=(100*t).toPrecision(3);return n.lastIndexOf(".")!==-1&&(n=n.replace(/[.]?0+$/,"")),r.numSeparate(n,e)+"%"},n.formatPieValue=function(t,e){var n=t.toPrecision(10);return n.lastIndexOf(".")!==-1&&(n=n.replace(/[.]?0+$/,"")),r.numSeparate(n,e)}},{"../../lib":102}],229:[function(t,e,n){"use strict";var r={};r.attributes=t("./attributes"),r.supplyDefaults=t("./defaults"),r.supplyLayoutDefaults=t("./layout_defaults"),r.layoutAttributes=t("./layout_attributes"),r.calc=t("./calc"),r.plot=t("./plot"),r.style=t("./style"),r.styleOne=t("./style_one"),r.moduleType="trace",r.name="pie",r.basePlotModule=t("./base_plot"),r.categories=["pie","showLegend"],r.meta={},e.exports=r},{"./attributes":224,"./base_plot":225,"./calc":226,"./defaults":227,"./layout_attributes":230,"./layout_defaults":231,"./plot":232,"./style":233,"./style_one":234}],230:[function(t,e,n){"use strict";e.exports={hiddenlabels:{valType:"data_array"}}},{}],231:[function(t,e,n){"use strict";var r=t("../../lib"),a=t("./layout_attributes");e.exports=function(t,e){function n(n,o){return r.coerce(t,e,a,n,o)}n("hiddenlabels")}},{"../../lib":102,"./layout_attributes":230}],232:[function(t,e,n){"use strict";function r(t,e,n){var r=Math.sqrt(t.width*t.width+t.height*t.height),o=t.width/t.height,i=Math.PI*Math.min(e.v/n.vTotal,.5),l=1-n.trace.hole,s=a(e,n),c={scale:s*n.r*2/r,rCenter:1-s,rotate:0};if(c.scale>=1)return c;var u=o+1/(2*Math.tan(i)),f=n.r*Math.min(1/(Math.sqrt(u*u+.5)+u),l/(Math.sqrt(o*o+l/2)+o)),d={scale:2*f/t.height,rCenter:Math.cos(f/n.r)-f*o/n.r,rotate:(180/Math.PI*e.midangle+720)%180-90},h=1/o,p=h+1/(2*Math.tan(i)),g=n.r*Math.min(1/(Math.sqrt(p*p+.5)+p),l/(Math.sqrt(h*h+l/2)+h)),m={scale:2*g/t.width,rCenter:Math.cos(g/n.r)-g/o/n.r,rotate:(180/Math.PI*e.midangle+810)%180-90},v=m.scale>d.scale?m:d;return c.scale<1&&v.scale>c.scale?v:c}function a(t,e){if(t.v===e.vTotal&&!e.trace.hole)return 1;var n=Math.PI*Math.min(t.v/e.vTotal,.5);return Math.min(1/(1+1/Math.sin(n)),(1-e.trace.hole)/2)}function o(t,e){var n=e.pxmid[0],r=e.pxmid[1],a=t.width/2,o=t.height/2;return n<0&&(a*=-1),r<0&&(o*=-1),{scale:1,rCenter:1,rotate:0,x:a+Math.abs(o)*(a>0?1:-1)/2,y:o/(1+n*n/(r*r)),outside:!0}}function i(t,e){function n(t,e){return t.pxmid[1]-e.pxmid[1]}function r(t,e){return e.pxmid[1]-t.pxmid[1]}function a(t,n){n||(n={});var r,a,o,l,d,h,g=n.labelExtraY+(i?n.yLabelMax:n.yLabelMin),m=i?t.yLabelMin:t.yLabelMax,v=i?t.yLabelMax:t.yLabelMin,y=t.cyFinal+c(t.px0[1],t.px1[1]),x=g-m;if(x*f>0&&(t.labelExtraY=x),Array.isArray(e.pull))for(a=0;a=e.pull[o.i]||((t.pxmid[1]-o.pxmid[1])*f>0?(l=o.cyFinal+c(o.px0[1],o.px1[1]),x=l-m-t.labelExtraY,x*f>0&&(t.labelExtraY+=x)):(v+t.labelExtraY-y)*f>0&&(r=3*u*Math.abs(a-p.indexOf(t)),d=o.cxFinal+s(o.px0[0],o.px1[0]),h=d+r-(t.cxFinal+t.pxmid[0])-t.labelExtraX,h*u>0&&(t.labelExtraX+=h)))}var o,i,l,s,c,u,f,d,h,p,g,m,v;for(i=0;i<2;i++)for(l=i?n:r,c=i?Math.max:Math.min,f=i?1:-1,o=0;o<2;o++){for(s=o?Math.max:Math.min,u=o?1:-1,d=t[i][o],d.sort(l),h=t[1-i][o],p=h.concat(d),m=[],g=0;gu&&(u=l.pull[o]);i.r=Math.min(n/c(l.tilt,Math.sin(s),l.depth),r/c(l.tilt,Math.cos(s),l.depth))/(2+2*u),i.cx=e.l+e.w*(l.domain.x[1]+l.domain.x[0])/2,i.cy=e.t+e.h*(2-l.domain.y[1]-l.domain.y[0])/2,l.scalegroup&&h.indexOf(l.scalegroup)===-1&&h.push(l.scalegroup)}for(o=0;of.vTotal/2?1:0)}function c(t,e,n){if(!t)return 1;var r=Math.sin(t*Math.PI/180);return Math.max(.01,n*r*Math.abs(e)+2*Math.sqrt(1-r*r*e*e))}var u=t("d3"),f=t("../../plots/cartesian/graph_interact"),d=t("../../components/color"),h=t("../../components/drawing"),p=t("../../lib/svg_text_utils"),g=t("./helpers");e.exports=function(t,e){var n=t._fullLayout;l(e,n._size);var c=n._pielayer.selectAll("g.trace").data(e);c.enter().append("g").attr({"stroke-linejoin":"round",class:"trace"}),c.exit().remove(),c.order(),c.each(function(e){var l=u.select(this),c=e[0],m=c.trace,v=0,y=(m.depth||0)*c.r*Math.sin(v)/2,x=m.tiltaxis||0,b=x*Math.PI/180,_=[y*Math.sin(b),y*Math.cos(b)],w=c.r*Math.cos(v),k=l.selectAll("g.part").data(m.tilt?["top","sides"]:["top"]);k.enter().append("g").attr("class",function(t){return t+" part"}),k.exit().remove(),k.order(),s(e),l.selectAll(".top").each(function(){var l=u.select(this).selectAll("g.slice").data(e);l.enter().append("g").classed("slice",!0),l.exit().remove();var s=[[[],[]],[[],[]]],v=!1;l.each(function(i){function l(e){var r=t._fullLayout,o=t._fullData[m.index],l=o.hoverinfo;if("all"===l&&(l="label+text+value+percent+name"),!t._dragging&&r.hovermode!==!1&&"none"!==l&&l){var s=a(i,c),u=k+i.pxmid[0]*(1-s),d=M+i.pxmid[1]*(1-s),h=n.separators,p=[];l.indexOf("label")!==-1&&p.push(i.label),o.text&&o.text[i.i]&&l.indexOf("text")!==-1&&p.push(o.text[i.i]),l.indexOf("value")!==-1&&p.push(g.formatPieValue(i.v,h)),l.indexOf("percent")!==-1&&p.push(g.formatPiePercent(i.v/c.vTotal,h)),f.loneHover({x0:u-s*c.r,x1:u+s*c.r,y:d,text:p.join("
"),name:l.indexOf("name")!==-1?o.name:void 0,color:i.color,idealAlign:i.pxmid[0]<0?"left":"right"},{container:r._hoverlayer.node(),outerContainer:r._paper.node()}),f.hover(t,e,"pie"),L=!0}}function d(e){t.emit("plotly_unhover",{points:[e]}),L&&(f.loneUnhover(n._hoverlayer.node()),L=!1)}function y(){t._hoverdata=[i],t._hoverdata.trace=e.trace,f.click(t,{target:!0})}function b(t,e,n,r){return"a"+r*c.r+","+r*w+" "+x+" "+i.largeArc+(n?" 1 ":" 0 ")+r*(e[0]-t[0])+","+r*(e[1]-t[1])}if(i.hidden)return void u.select(this).selectAll("path,g").remove();s[i.pxmid[1]<0?0:1][i.pxmid[0]<0?0:1].push(i);var k=c.cx+_[0],M=c.cy+_[1],A=u.select(this),T=A.selectAll("path.surface").data([i]),L=!1;if(T.enter().append("path").classed("surface",!0).style({"pointer-events":"all"}),A.select("path.textline").remove(),A.on("mouseover",l).on("mouseout",d).on("click",y),m.pull){var z=+(Array.isArray(m.pull)?m.pull[i.i]:m.pull)||0;z>0&&(k+=z*i.pxmid[0],M+=z*i.pxmid[1])}i.cxFinal=k,i.cyFinal=M;var S=m.hole;if(i.v===c.vTotal){var C="M"+(k+i.px0[0])+","+(M+i.px0[1])+b(i.px0,i.pxmid,!0,1)+b(i.pxmid,i.px0,!0,1)+"Z";S?T.attr("d","M"+(k+S*i.px0[0])+","+(M+S*i.px0[1])+b(i.px0,i.pxmid,!1,S)+b(i.pxmid,i.px0,!1,S)+"Z"+C):T.attr("d",C)}else{var E=b(i.px0,i.px1,!0,1);if(S){var O=1-S;T.attr("d","M"+(k+S*i.px1[0])+","+(M+S*i.px1[1])+b(i.px1,i.px0,!1,S)+"l"+O*i.px0[0]+","+O*i.px0[1]+E+"Z")}else T.attr("d","M"+k+","+M+"l"+i.px0[0]+","+i.px0[1]+E+"Z")}var P=Array.isArray(m.textposition)?m.textposition[i.i]:m.textposition,N=A.selectAll("g.slicetext").data(i.text&&"none"!==P?[0]:[]);N.enter().append("g").classed("slicetext",!0),N.exit().remove(),N.each(function(){var t=u.select(this).selectAll("text").data([0]);t.enter().append("text").attr("data-notex",1),t.exit().remove(),t.text(i.text).attr({class:"slicetext",transform:"","data-bb":"","text-anchor":"middle",x:0,y:0}).call(h.font,"outside"===P?m.outsidetextfont:m.insidetextfont).call(p.convertToTspans),t.selectAll("tspan.line").attr({x:0,y:0});var e,n=h.bBox(t.node());"outside"===P?e=o(n,i):(e=r(n,i,c),"auto"===P&&e.scale<1&&(t.call(h.font,m.outsidetextfont),m.outsidetextfont.family===m.insidetextfont.family&&m.outsidetextfont.size===m.insidetextfont.size||(t.attr({"data-bb":""}),n=h.bBox(t.node())),e=o(n,i)));var a=k+i.pxmid[0]*e.rCenter+(e.x||0),l=M+i.pxmid[1]*e.rCenter+(e.y||0);e.outside&&(i.yLabelMin=l-n.height/2,i.yLabelMid=l,i.yLabelMax=l+n.height/2,i.labelExtraX=0,i.labelExtraY=0,v=!0),t.attr("transform","translate("+a+","+l+")"+(e.scale<1?"scale("+e.scale+")":"")+(e.rotate?"rotate("+e.rotate+")":"")+"translate("+-(n.left+n.right)/2+","+-(n.top+n.bottom)/2+")")})}),v&&i(s,m),l.each(function(t){if(t.labelExtraX||t.labelExtraY){var e=u.select(this),n=e.select("g.slicetext text");n.attr("transform","translate("+t.labelExtraX+","+t.labelExtraY+")"+n.attr("transform"));var r=t.cxFinal+t.pxmid[0],a=t.cyFinal+t.pxmid[1],o="M"+r+","+a,i=(t.yLabelMax-t.yLabelMin)*(t.pxmid[0]<0?-1:1)/4;if(t.labelExtraX){var l=t.labelExtraX*t.pxmid[1]/t.pxmid[0],s=t.yLabelMid+t.labelExtraY-(t.cyFinal+t.pxmid[1]);o+=Math.abs(l)>Math.abs(s)?"l"+s*t.pxmid[0]/t.pxmid[1]+","+s+"H"+(r+t.labelExtraX+i):"l"+t.labelExtraX+","+l+"v"+(s-l)+"h"+i}else o+="V"+(t.yLabelMid+t.labelExtraY)+"h"+i;e.append("path").classed("textline",!0).call(d.stroke,m.outsidetextfont.color).attr({"stroke-width":Math.min(2,m.outsidetextfont.size/8),d:o,fill:"none"})}})})}),setTimeout(function(){c.selectAll("tspan").each(function(){var t=u.select(this);t.attr("dy")&&t.attr("dy",t.attr("dy"))})},0)}},{"../../components/color":25,"../../components/drawing":48,"../../lib/svg_text_utils":113,"../../plots/cartesian/graph_interact":130,"./helpers":228, ++d3:14}],233:[function(t,e,n){"use strict";var r=t("d3"),a=t("./style_one");e.exports=function(t){t._fullLayout._pielayer.selectAll(".trace").each(function(t){var e=t[0],n=e.trace,o=r.select(this);o.style({opacity:n.opacity}),o.selectAll(".top path.surface").each(function(t){r.select(this).call(a,t,n)})})}},{"./style_one":234,d3:14}],234:[function(t,e,n){"use strict";var r=t("../../components/color");e.exports=function(t,e,n){var a=n.marker.line.color;Array.isArray(a)&&(a=a[e.i]||r.defaultLine);var o=n.marker.line.width||0;Array.isArray(o)&&(o=o[e.i]||0),t.style({"stroke-width":o,fill:e.color}).call(r.stroke,a)}},{"../../components/color":25}],235:[function(t,e,n){"use strict";var r=t("../../lib");e.exports=function(t){var e=t[0].trace,n=e.marker;if(r.mergeArray(e.text,t,"tx"),r.mergeArray(e.textposition,t,"tp"),e.textfont&&(r.mergeArray(e.textfont.size,t,"ts"),r.mergeArray(e.textfont.color,t,"tc"),r.mergeArray(e.textfont.family,t,"tf")),n&&n.line){var a=n.line;r.mergeArray(n.opacity,t,"mo"),r.mergeArray(n.symbol,t,"mx"),r.mergeArray(n.color,t,"mc"),r.mergeArray(a.color,t,"mlc"),r.mergeArray(a.width,t,"mlw")}}},{"../../lib":102}],236:[function(t,e,n){"use strict";var r=t("../../components/colorscale/color_attributes"),a=t("../../components/drawing"),o=(t("./constants"),t("../../lib/extend").extendFlat);e.exports={x:{valType:"data_array"},x0:{valType:"any",dflt:0},dx:{valType:"number",dflt:1},y:{valType:"data_array"},y0:{valType:"any",dflt:0},dy:{valType:"number",dflt:1},text:{valType:"string",dflt:"",arrayOk:!0},mode:{valType:"flaglist",flags:["lines","markers","text"],extras:["none"]},hoveron:{valType:"flaglist",flags:["points","fills"]},line:{color:{valType:"color"},width:{valType:"number",min:0,dflt:2},shape:{valType:"enumerated",values:["linear","spline","hv","vh","hvh","vhv"],dflt:"linear"},smoothing:{valType:"number",min:0,max:1.3,dflt:1},dash:{valType:"string",values:["solid","dot","dash","longdash","dashdot","longdashdot"],dflt:"solid"}},connectgaps:{valType:"boolean",dflt:!1},fill:{valType:"enumerated",values:["none","tozeroy","tozerox","tonexty","tonextx","toself","tonext"],dflt:"none"},fillcolor:{valType:"color"},marker:o({},{symbol:{valType:"enumerated",values:a.symbolList,dflt:"circle",arrayOk:!0},opacity:{valType:"number",min:0,max:1,arrayOk:!0},size:{valType:"number",min:0,dflt:6,arrayOk:!0},maxdisplayed:{valType:"number",min:0,dflt:0},sizeref:{valType:"number",dflt:1},sizemin:{valType:"number",min:0,dflt:0},sizemode:{valType:"enumerated",values:["diameter","area"],dflt:"diameter"},showscale:{valType:"boolean",dflt:!1},line:o({},{width:{valType:"number",min:0,arrayOk:!0}},r("marker.line"))},r("marker")),textposition:{valType:"enumerated",values:["top left","top center","top right","middle left","middle center","middle right","bottom left","bottom center","bottom right"],dflt:"middle center",arrayOk:!0},textfont:{family:{valType:"string",noBlank:!0,strict:!0,arrayOk:!0},size:{valType:"number",min:1,arrayOk:!0},color:{valType:"color",arrayOk:!0}},r:{valType:"data_array"},t:{valType:"data_array"},_nestedModules:{error_y:"ErrorBars",error_x:"ErrorBars","marker.colorbar":"Colorbar"}}},{"../../components/colorscale/color_attributes":33,"../../components/drawing":48,"../../lib/extend":100,"./constants":241}],237:[function(t,e,n){"use strict";var r=t("fast-isnumeric"),a=t("../../plots/cartesian/axes"),o=t("../../lib"),i=t("./subtypes"),l=t("./colorscale_calc");e.exports=function(t,e){var n,s,c,u=a.getFromId(t,e.xaxis||"x"),f=a.getFromId(t,e.yaxis||"y"),d=u.makeCalcdata(e,"x"),h=f.makeCalcdata(e,"y"),p=Math.min(d.length,h.length);u._minDtick=0,f._minDtick=0,d.length>p&&d.splice(p,d.length-p),h.length>p&&h.splice(p,h.length-p);var g={padded:!0},m={padded:!0};if(i.hasMarkers(e)){if(n=e.marker,s=n.size,Array.isArray(s)){var v={type:"linear"};a.setConvert(v),s=v.makeCalcdata(e.marker,"size"),s.length>p&&s.splice(p,s.length-p)}var y,x=1.6*(e.marker.sizeref||1);y="area"===e.marker.sizemode?function(t){return Math.max(Math.sqrt((t||0)/x),3)}:function(t){return Math.max((t||0)/x,3)},g.ppad=m.ppad=Array.isArray(s)?s.map(y):y(s)}l(e),!("tozerox"===e.fill||"tonextx"===e.fill&&t.firstscatter)||d[0]===d[p-1]&&h[0]===h[p-1]?e.error_y.visible||["tonexty","tozeroy"].indexOf(e.fill)===-1&&(i.hasMarkers(e)||i.hasText(e))||(g.padded=!1,g.ppad=0):g.tozero=!0,!("tozeroy"===e.fill||"tonexty"===e.fill&&t.firstscatter)||d[0]===d[p-1]&&h[0]===h[p-1]?["tonextx","tozerox"].indexOf(e.fill)!==-1&&(m.padded=!1):m.tozero=!0,a.expand(u,d,g),a.expand(f,h,m);var b=new Array(p);for(c=0;c=0;a--)if(o=t[a],"scatter"===o.type&&o.xaxis===n.xaxis&&o.yaxis===n.yaxis){o.opacity=void 0;break}}},{}],239:[function(t,e,n){"use strict";var r=t("d3"),a=t("fast-isnumeric"),o=t("../../lib"),i=t("../../plots/plots"),l=t("../../components/colorscale/get_scale"),s=t("../../components/colorbar/draw");e.exports=function(t,e){var n=e[0].trace,c=n.marker,u="cb"+n.uid;if(t._fullLayout._infolayer.selectAll("."+u).remove(),void 0===c||!c.showscale)return void i.autoMargin(t,u);var f=l(c.colorscale),d=c.color,h=c.cmin,p=c.cmax;a(h)||(h=o.aggNums(Math.min,null,d)),a(p)||(p=o.aggNums(Math.max,null,d));var g=e[0].t.cb=s(t,u);g.fillcolor(r.scale.linear().domain(f.map(function(t){return h+t[0]*(p-h)})).range(f.map(function(t){return t[1]}))).filllevels({start:h,end:p,size:(p-h)/254}).options(c.colorbar)()}},{"../../components/colorbar/draw":28,"../../components/colorscale/get_scale":37,"../../lib":102,"../../plots/plots":143,d3:14,"fast-isnumeric":17}],240:[function(t,e,n){"use strict";var r=t("../../components/colorscale/has_colorscale"),a=t("../../components/colorscale/calc"),o=t("./subtypes");e.exports=function(t){o.hasLines(t)&&r(t,"line")&&a(t,t.line.color,"line","c"),o.hasMarkers(t)&&(r(t,"marker")&&a(t,t.marker.color,"marker","c"),r(t,"marker.line")&&a(t,t.marker.line.color,"marker.line","c"))}},{"../../components/colorscale/calc":32,"../../components/colorscale/has_colorscale":38,"./subtypes":255}],241:[function(t,e,n){"use strict";e.exports={PTS_LINESONLY:20}},{}],242:[function(t,e,n){"use strict";var r=t("../../lib"),a=t("./attributes"),o=t("./constants"),i=t("./subtypes"),l=t("./xy_defaults"),s=t("./marker_defaults"),c=t("./line_defaults"),u=t("./line_shape_defaults"),f=t("./text_defaults"),d=t("./fillcolor_defaults"),h=t("../../components/errorbars/defaults");e.exports=function(t,e,n,p){function g(n,o){return r.coerce(t,e,a,n,o)}var m=l(t,e,g),v=mB!=P>=B&&(C=z[T-1][0],E=z[T][0],S=C+(E-C)*(B-O)/(P-O),R=Math.min(R,S),j=Math.max(j,S));R=Math.max(R,0),j=Math.min(j,d._length);var H=s.defaultLine;return s.opacity(f.fillcolor)?H=f.fillcolor:s.opacity((f.line||{}).color)&&(H=f.line.color),r.extendFlat(t,{distance:o.MAXDIST+10,x0:R,x1:j,y0:B,y1:B,color:H}),delete t.index,f.text&&!Array.isArray(f.text)?t.text=String(f.text):t.text=f.name,[t]}}}},{"../../components/color":25,"../../components/errorbars":54,"../../lib":102,"../../plots/cartesian/constants":128,"../../plots/cartesian/graph_interact":130,"./get_trace_color":244}],246:[function(t,e,n){"use strict";var r={},a=t("./subtypes");r.hasLines=a.hasLines,r.hasMarkers=a.hasMarkers,r.hasText=a.hasText,r.isBubble=a.isBubble,r.attributes=t("./attributes"),r.supplyDefaults=t("./defaults"),r.cleanData=t("./clean_data"),r.calc=t("./calc"),r.arraysToCalcdata=t("./arrays_to_calcdata"),r.plot=t("./plot"),r.colorbar=t("./colorbar"),r.style=t("./style"),r.hoverPoints=t("./hover"),r.selectPoints=t("./select"),r.moduleType="trace",r.name="scatter",r.basePlotModule=t("../../plots/cartesian"),r.categories=["cartesian","symbols","markerColorscale","errorBarsOK","showLegend"],r.meta={},e.exports=r},{"../../plots/cartesian":131,"./arrays_to_calcdata":235,"./attributes":236,"./calc":237,"./clean_data":238,"./colorbar":239,"./defaults":242,"./hover":245,"./plot":252,"./select":253,"./style":254,"./subtypes":255}],247:[function(t,e,n){"use strict";var r=t("../../components/colorscale/has_colorscale"),a=t("../../components/colorscale/defaults");e.exports=function(t,e,n,o,i){var l=(t.marker||{}).color;if(i("line.color",n),r(t,"line"))a(t,e,o,i,{prefix:"line.",cLetter:"c"});else{var s=!Array.isArray(l)&&l||n;i("line.color",s)}i("line.width"),i("line.dash")}},{"../../components/colorscale/defaults":35,"../../components/colorscale/has_colorscale":38}],248:[function(t,e,n){"use strict";var r=t("../../plots/cartesian/axes");e.exports=function(t,e){function n(e){var n=w.c2p(t[e].x),r=k.c2p(t[e].y);return n!==z&&r!==z&&[n,r]}function a(t){var e=t[0]/w._length,n=t[1]/k._length;return(1+10*Math.max(0,-e,e-1,-n,n-1))*A}function o(t,e){var n=t[0]-e[0],r=t[1]-e[1];return Math.sqrt(n*n+r*r)}var i,l,s,c,u,f,d,h,p,g,m,v,y,x,b,_,w=e.xaxis,k=e.yaxis,M=e.connectGaps,A=e.baseTolerance,T=e.linear,L=[],z=r.BADNUM,S=.2,C=new Array(t.length),E=0;for(i=0;ia(f))break;s=f,y=g[0]*p[0]+g[1]*p[1],y>m?(m=y,c=f,h=!1):y=t.length||!f)break;C[E++]=f,l=f}}else C[E++]=c}L.push(C.slice(0,E))}return L}},{"../../plots/cartesian/axes":123}],249:[function(t,e,n){"use strict";e.exports=function(t,e,n){var r=n("line.shape");"spline"===r&&n("line.smoothing")}},{}],250:[function(t,e,n){"use strict";var r=t("fast-isnumeric");e.exports=function(t){var e=t.marker,n=e.sizeref||1,a=e.sizemin||0,o="area"===e.sizemode?function(t){return Math.sqrt(t/n)}:function(t){return t/n};return function(t){var e=o(t/2);return r(e)&&e>0?Math.max(e,a):0}}},{"fast-isnumeric":17}],251:[function(t,e,n){"use strict";var r=t("../../components/color"),a=t("../../components/colorscale/has_colorscale"),o=t("../../components/colorscale/defaults"),i=t("./subtypes");e.exports=function(t,e,n,l,s){var c,u=i.isBubble(t),f=(t.line||{}).color;f&&(n=f),s("marker.symbol"),s("marker.opacity",u?.7:1),s("marker.size"),s("marker.color",n),a(t,"marker")&&o(t,e,l,s,{prefix:"marker.",cLetter:"c"}),c=f&&!Array.isArray(f)&&e.marker.color!==f?f:u?r.background:r.defaultLine,s("marker.line.color",c),a(t,"marker.line")&&o(t,e,l,s,{prefix:"marker.line.",cLetter:"c"}),s("marker.line.width",u?1:0),u&&(s("marker.sizeref"),s("marker.sizemin"),s("marker.sizemode"))}},{"../../components/color":25,"../../components/colorscale/defaults":35,"../../components/colorscale/has_colorscale":38,"./subtypes":255}],252:[function(t,e,n){"use strict";function r(t,e,n){var r=e.x(),o=e.y(),i=a.extent(r.range.map(r.l2c)),l=a.extent(o.range.map(o.l2c));n.forEach(function(t,e){var r=t[0].trace;if(c.hasMarkers(r)){var a=r.marker.maxdisplayed;if(0!==a){var o=t.filter(function(t){return t.x>=i[0]&&t.x<=i[1]&&t.y>=l[0]&&t.y<=l[1]}),s=Math.ceil(o.length/a),u=0;n.forEach(function(t,n){var r=t[0].trace;c.hasMarkers(r)&&r.marker.maxdisplayed>0&&n1&&r.append("path").classed("js-line",!0).style("vector-effect","non-scaling-stroke").attr("d",o)}m?z&&C&&(v?("y"===v?z[1]=C[1]=p.c2p(0,!0):"x"===v&&(z[0]=C[0]=h.c2p(0,!0)),m.attr("d",k+"L"+C+"L"+z+"Z")):m.attr("d",k+"Z")):"tonext"===e.fill.substr(0,6)&&k&&b&&("tonext"===e.fill?y.attr("d",k+"Z"+b+"Z"):y.attr("d",k+"L"+b.substr(1)+"Z"),e._polygons=e._polygons.concat(_)),b=M,_=L}}}),g.selectAll("path:not([d])").remove(),g.append("g").attr("class","points").each(function(t){var e=t[0].trace,n=a.select(this),r=c.hasMarkers(e),l=c.hasText(e);!r&&!l||e.visible!==!0?n.remove():(r&&n.selectAll("path.point").data(e.marker.maxdisplayed?d:o.identity).enter().append("path").classed("point",!0).call(i.translatePoints,h,p),l&&n.selectAll("g").data(e.marker.maxdisplayed?d:o.identity).enter().append("g").append("text").call(i.translatePoints,h,p))})}},{"../../components/drawing":48,"../../components/errorbars":54,"../../lib":102,"../../lib/polygon":108,"./arrays_to_calcdata":235,"./line_points":248,"./subtypes":255,d3:14}],253:[function(t,e,n){"use strict";var r=t("./subtypes"),a=.2;e.exports=function(t,e){var n,o,i,l,s=t.cd,c=t.xaxis,u=t.yaxis,f=[],d=s[0].trace,h=d.index,p=d.marker,g=!r.hasMarkers(d)&&!r.hasText(d);if(d.visible===!0&&!g){var m=Array.isArray(p.opacity)?1:p.opacity;if(e===!1)for(n=0;nM&&L.splice(M,L.length-M)}return l(e),void 0!==typeof L&&o.mergeArray(L,A,"ms"),A}},{"../../lib":102,"../../plots/cartesian/axes":123,"../scatter/colorscale_calc":240,"../scatter/subtypes":255,"fast-isnumeric":17}],260:[function(t,e,n){"use strict";var r=t("../../lib"),a=t("../scatter/constants"),o=t("../scatter/subtypes"),i=t("../scatter/marker_defaults"),l=t("../scatter/line_defaults"),s=t("../scatter/line_shape_defaults"),c=t("../scatter/text_defaults"),u=t("../scatter/fillcolor_defaults"),f=t("./attributes");e.exports=function(t,e,n,d){function h(n,a){return r.coerce(t,e,f,n,a)}var p,g=h("a"),m=h("b"),v=h("c");if(g?(p=g.length,m?(p=Math.min(p,m.length),v&&(p=Math.min(p,v.length))):p=v?Math.min(p,v.length):0):m&&v&&(p=Math.min(m.length,v.length)),!p)return void(e.visible=!1);g&&p"),l}}},{"../../plots/cartesian/axes":123,"../scatter/hover":245}],262:[function(t,e,n){"use strict";var r={};r.attributes=t("./attributes"),r.supplyDefaults=t("./defaults"),r.colorbar=t("../scatter/colorbar"),r.calc=t("./calc"),r.plot=t("./plot"),r.style=t("./style"),r.hoverPoints=t("./hover"),r.selectPoints=t("./select"),r.moduleType="trace",r.name="scatterternary",r.basePlotModule=t("../../plots/ternary"),r.categories=["ternary","symbols","markerColorscale","showLegend"],r.meta={},e.exports=r},{"../../plots/ternary":150,"../scatter/colorbar":239,"./attributes":258,"./calc":259,"./defaults":260,"./hover":261,"./plot":263,"./select":264,"./style":265}],263:[function(t,e,n){"use strict";var r=t("../scatter/plot");e.exports=function(t,e){var n=t.plotContainer;n.select(".scatterlayer").selectAll("*").remove();for(var a={x:function(){return t.xaxis},y:function(){return t.yaxis},plot:n},o=new Array(e.length),i=t.graphDiv.calcdata,l=0;l 0 && this._events[type].length > m) { +- this._events[type].warned = true; +- console.error('(node) warning: possible EventEmitter memory ' + +- 'leak detected. %d listeners added. ' + +- 'Use emitter.setMaxListeners() to increase limit.', +- this._events[type].length); +- if (typeof console.trace === 'function') { +- // not supported in IE 10 +- console.trace(); +- } +- } +- } +- +- return this; +-}; +- +-EventEmitter.prototype.on = EventEmitter.prototype.addListener; +- +-EventEmitter.prototype.once = function(type, listener) { +- if (!isFunction(listener)) +- throw TypeError('listener must be a function'); +- +- var fired = false; +- +- function g() { +- this.removeListener(type, g); +- +- if (!fired) { +- fired = true; +- listener.apply(this, arguments); +- } +- } +- +- g.listener = listener; +- this.on(type, g); +- +- return this; +-}; +- +-// emits a 'removeListener' event iff the listener was removed +-EventEmitter.prototype.removeListener = function(type, listener) { +- var list, position, length, i; +- +- if (!isFunction(listener)) +- throw TypeError('listener must be a function'); +- +- if (!this._events || !this._events[type]) +- return this; +- +- list = this._events[type]; +- length = list.length; +- position = -1; +- +- if (list === listener || +- (isFunction(list.listener) && list.listener === listener)) { +- delete this._events[type]; +- if (this._events.removeListener) +- this.emit('removeListener', type, listener); +- +- } else if (isObject(list)) { +- for (i = length; i-- > 0;) { +- if (list[i] === listener || +- (list[i].listener && list[i].listener === listener)) { +- position = i; +- break; +- } +- } +- +- if (position < 0) +- return this; +- +- if (list.length === 1) { +- list.length = 0; +- delete this._events[type]; +- } else { +- list.splice(position, 1); +- } +- +- if (this._events.removeListener) +- this.emit('removeListener', type, listener); +- } +- +- return this; +-}; +- +-EventEmitter.prototype.removeAllListeners = function(type) { +- var key, listeners; +- +- if (!this._events) +- return this; +- +- // not listening for removeListener, no need to emit +- if (!this._events.removeListener) { +- if (arguments.length === 0) +- this._events = {}; +- else if (this._events[type]) +- delete this._events[type]; +- return this; +- } +- +- // emit removeListener for all listeners on all events +- if (arguments.length === 0) { +- for (key in this._events) { +- if (key === 'removeListener') continue; +- this.removeAllListeners(key); +- } +- this.removeAllListeners('removeListener'); +- this._events = {}; +- return this; +- } +- +- listeners = this._events[type]; +- +- if (isFunction(listeners)) { +- this.removeListener(type, listeners); +- } else if (listeners) { +- // LIFO order +- while (listeners.length) +- this.removeListener(type, listeners[listeners.length - 1]); +- } +- delete this._events[type]; +- +- return this; +-}; +- +-EventEmitter.prototype.listeners = function(type) { +- var ret; +- if (!this._events || !this._events[type]) +- ret = []; +- else if (isFunction(this._events[type])) +- ret = [this._events[type]]; +- else +- ret = this._events[type].slice(); +- return ret; +-}; +- +-EventEmitter.prototype.listenerCount = function(type) { +- if (this._events) { +- var evlistener = this._events[type]; +- +- if (isFunction(evlistener)) +- return 1; +- else if (evlistener) +- return evlistener.length; +- } +- return 0; +-}; +- +-EventEmitter.listenerCount = function(emitter, type) { +- return emitter.listenerCount(type); +-}; +- +-function isFunction(arg) { +- return typeof arg === 'function'; +-} +- +-function isNumber(arg) { +- return typeof arg === 'number'; +-} +- +-function isObject(arg) { +- return typeof arg === 'object' && arg !== null; +-} +- +-function isUndefined(arg) { +- return arg === void 0; +-} +- +-},{}],8:[function(require,module,exports){ +-// shim for using process in browser +- +-var process = module.exports = {}; +-var queue = []; +-var draining = false; +-var currentQueue; +-var queueIndex = -1; +- +-function cleanUpNextTick() { +- draining = false; +- if (currentQueue.length) { +- queue = currentQueue.concat(queue); +- } else { +- queueIndex = -1; +- } +- if (queue.length) { +- drainQueue(); +- } +-} +- +-function drainQueue() { +- if (draining) { +- return; +- } +- var timeout = setTimeout(cleanUpNextTick); +- draining = true; +- +- var len = queue.length; +- while(len) { +- currentQueue = queue; +- queue = []; +- while (++queueIndex < len) { +- if (currentQueue) { +- currentQueue[queueIndex].run(); +- } +- } +- queueIndex = -1; +- len = queue.length; +- } +- currentQueue = null; +- draining = false; +- clearTimeout(timeout); +-} +- +-process.nextTick = function (fun) { +- var args = new Array(arguments.length - 1); +- if (arguments.length > 1) { +- for (var i = 1; i < arguments.length; i++) { +- args[i - 1] = arguments[i]; +- } +- } +- queue.push(new Item(fun, args)); +- if (queue.length === 1 && !draining) { +- setTimeout(drainQueue, 0); +- } +-}; +- +-// v8 likes predictible objects +-function Item(fun, array) { +- this.fun = fun; +- this.array = array; +-} +-Item.prototype.run = function () { +- this.fun.apply(null, this.array); +-}; +-process.title = 'browser'; +-process.browser = true; +-process.env = {}; +-process.argv = []; +-process.version = ''; // empty string to avoid regexp issues +-process.versions = {}; +- +-function noop() {} +- +-process.on = noop; +-process.addListener = noop; +-process.once = noop; +-process.off = noop; +-process.removeListener = noop; +-process.removeAllListeners = noop; +-process.emit = noop; +- +-process.binding = function (name) { +- throw new Error('process.binding is not supported'); +-}; +- +-process.cwd = function () { return '/' }; +-process.chdir = function (dir) { +- throw new Error('process.chdir is not supported'); +-}; +-process.umask = function() { return 0; }; +- +-},{}],9:[function(require,module,exports){ + module.exports = { + AFG: "afghan", + ALA: "\\b\\wland", +@@ -681,7 +288,7 @@ module.exports = { + CAF: "\\bcentral.african.republic", + TCD: "\\bchad", + CHL: "\\bchile", +- CHN: "^(?!.*\\bmac)(?!.*\\bhong)(?!.*\\btai).*china", ++ CHN: "^(?!.*\\bmac)(?!.*\\bhong)(?!.*\\btai)(?!.*\\brep).*china|^(?=.*peo)(?=.*rep).*china", + CXR: "christmas", + CCK: "\\bcocos|keeling", + COL: "colombia", +@@ -856,7 +463,7 @@ module.exports = { + SWE: "sweden", + CHE: "switz|swiss", + SYR: "syria", +- TWN: "taiwan|taipei|formosa", ++ TWN: "taiwan|taipei|formosa|^(?!.*peo)(?=.*rep).*china", + TJK: "tajik", + TZA: "tanzania", + THA: "thailand|\\bsiam", +@@ -893,10 +500,10 @@ module.exports = { + ZWE: "zimbabwe|^(?!.*northern).*rhodesia" + }; + +-},{}],10:[function(require,module,exports){ ++},{}],8:[function(require,module,exports){ + !function() { + var d3 = { +- version: "3.5.16" ++ version: "3.5.17" + }; + var d3_arraySlice = [].slice, d3_array = function(list) { + return d3_arraySlice.call(list); +@@ -4421,7 +4028,7 @@ module.exports = { + λ0 = λ, sinφ0 = sinφ, cosφ0 = cosφ, point0 = point; + } + } +- return (polarAngle < -ε || polarAngle < ε && d3_geo_areaRingSum < 0) ^ winding & 1; ++ return (polarAngle < -ε || polarAngle < ε && d3_geo_areaRingSum < -ε) ^ winding & 1; + } + function d3_geo_clipCircle(radius) { + var cr = Math.cos(radius), smallRadius = cr > 0, notHemisphere = abs(cr) > ε, interpolate = d3_geo_circleInterpolate(radius, 6 * d3_radians); +@@ -10448,965 +10055,1468 @@ module.exports = { + }); + if (typeof define === "function" && define.amd) this.d3 = d3, define(d3); else if (typeof module === "object" && module.exports) module.exports = d3; else this.d3 = d3; + }(); +-},{}],11:[function(require,module,exports){ ++},{}],9:[function(require,module,exports){ + (function (process,global){ + /*! + * @overview es6-promise - a tiny implementation of Promises/A+. + * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald) + * @license Licensed under MIT license +- * See https://raw.githubusercontent.com/jakearchibald/es6-promise/master/LICENSE +- * @version 3.1.2 ++ * See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE ++ * @version 3.3.1 + */ + +-(function() { +- "use strict"; +- function lib$es6$promise$utils$$objectOrFunction(x) { +- return typeof x === 'function' || (typeof x === 'object' && x !== null); +- } ++(function (global, factory) { ++ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : ++ typeof define === 'function' && define.amd ? define(factory) : ++ (global.ES6Promise = factory()); ++}(this, (function () { 'use strict'; + +- function lib$es6$promise$utils$$isFunction(x) { +- return typeof x === 'function'; +- } ++function objectOrFunction(x) { ++ return typeof x === 'function' || typeof x === 'object' && x !== null; ++} + +- function lib$es6$promise$utils$$isMaybeThenable(x) { +- return typeof x === 'object' && x !== null; +- } ++function isFunction(x) { ++ return typeof x === 'function'; ++} + +- var lib$es6$promise$utils$$_isArray; +- if (!Array.isArray) { +- lib$es6$promise$utils$$_isArray = function (x) { +- return Object.prototype.toString.call(x) === '[object Array]'; +- }; ++var _isArray = undefined; ++if (!Array.isArray) { ++ _isArray = function (x) { ++ return Object.prototype.toString.call(x) === '[object Array]'; ++ }; ++} else { ++ _isArray = Array.isArray; ++} ++ ++var isArray = _isArray; ++ ++var len = 0; ++var vertxNext = undefined; ++var customSchedulerFn = undefined; ++ ++var asap = function asap(callback, arg) { ++ queue[len] = callback; ++ queue[len + 1] = arg; ++ len += 2; ++ if (len === 2) { ++ // If len is 2, that means that we need to schedule an async flush. ++ // If additional callbacks are queued before the queue is flushed, they ++ // will be processed by this flush that we are scheduling. ++ if (customSchedulerFn) { ++ customSchedulerFn(flush); + } else { +- lib$es6$promise$utils$$_isArray = Array.isArray; +- } +- +- var lib$es6$promise$utils$$isArray = lib$es6$promise$utils$$_isArray; +- var lib$es6$promise$asap$$len = 0; +- var lib$es6$promise$asap$$vertxNext; +- var lib$es6$promise$asap$$customSchedulerFn; +- +- var lib$es6$promise$asap$$asap = function asap(callback, arg) { +- lib$es6$promise$asap$$queue[lib$es6$promise$asap$$len] = callback; +- lib$es6$promise$asap$$queue[lib$es6$promise$asap$$len + 1] = arg; +- lib$es6$promise$asap$$len += 2; +- if (lib$es6$promise$asap$$len === 2) { +- // If len is 2, that means that we need to schedule an async flush. +- // If additional callbacks are queued before the queue is flushed, they +- // will be processed by this flush that we are scheduling. +- if (lib$es6$promise$asap$$customSchedulerFn) { +- lib$es6$promise$asap$$customSchedulerFn(lib$es6$promise$asap$$flush); +- } else { +- lib$es6$promise$asap$$scheduleFlush(); +- } +- } ++ scheduleFlush(); + } ++ } ++}; + +- function lib$es6$promise$asap$$setScheduler(scheduleFn) { +- lib$es6$promise$asap$$customSchedulerFn = scheduleFn; +- } ++function setScheduler(scheduleFn) { ++ customSchedulerFn = scheduleFn; ++} + +- function lib$es6$promise$asap$$setAsap(asapFn) { +- lib$es6$promise$asap$$asap = asapFn; +- } ++function setAsap(asapFn) { ++ asap = asapFn; ++} + +- var lib$es6$promise$asap$$browserWindow = (typeof window !== 'undefined') ? window : undefined; +- var lib$es6$promise$asap$$browserGlobal = lib$es6$promise$asap$$browserWindow || {}; +- var lib$es6$promise$asap$$BrowserMutationObserver = lib$es6$promise$asap$$browserGlobal.MutationObserver || lib$es6$promise$asap$$browserGlobal.WebKitMutationObserver; +- var lib$es6$promise$asap$$isNode = typeof process !== 'undefined' && {}.toString.call(process) === '[object process]'; ++var browserWindow = typeof window !== 'undefined' ? window : undefined; ++var browserGlobal = browserWindow || {}; ++var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver; ++var isNode = typeof self === 'undefined' && typeof process !== 'undefined' && ({}).toString.call(process) === '[object process]'; + +- // test for web worker but not in IE10 +- var lib$es6$promise$asap$$isWorker = typeof Uint8ClampedArray !== 'undefined' && +- typeof importScripts !== 'undefined' && +- typeof MessageChannel !== 'undefined'; ++// test for web worker but not in IE10 ++var isWorker = typeof Uint8ClampedArray !== 'undefined' && typeof importScripts !== 'undefined' && typeof MessageChannel !== 'undefined'; + +- // node +- function lib$es6$promise$asap$$useNextTick() { +- // node version 0.10.x displays a deprecation warning when nextTick is used recursively +- // see https://github.com/cujojs/when/issues/410 for details +- return function() { +- process.nextTick(lib$es6$promise$asap$$flush); +- }; +- } ++// node ++function useNextTick() { ++ // node version 0.10.x displays a deprecation warning when nextTick is used recursively ++ // see https://github.com/cujojs/when/issues/410 for details ++ return function () { ++ return process.nextTick(flush); ++ }; ++} + +- // vertx +- function lib$es6$promise$asap$$useVertxTimer() { +- return function() { +- lib$es6$promise$asap$$vertxNext(lib$es6$promise$asap$$flush); +- }; +- } ++// vertx ++function useVertxTimer() { ++ return function () { ++ vertxNext(flush); ++ }; ++} + +- function lib$es6$promise$asap$$useMutationObserver() { +- var iterations = 0; +- var observer = new lib$es6$promise$asap$$BrowserMutationObserver(lib$es6$promise$asap$$flush); +- var node = document.createTextNode(''); +- observer.observe(node, { characterData: true }); ++function useMutationObserver() { ++ var iterations = 0; ++ var observer = new BrowserMutationObserver(flush); ++ var node = document.createTextNode(''); ++ observer.observe(node, { characterData: true }); + +- return function() { +- node.data = (iterations = ++iterations % 2); +- }; +- } ++ return function () { ++ node.data = iterations = ++iterations % 2; ++ }; ++} + +- // web worker +- function lib$es6$promise$asap$$useMessageChannel() { +- var channel = new MessageChannel(); +- channel.port1.onmessage = lib$es6$promise$asap$$flush; +- return function () { +- channel.port2.postMessage(0); +- }; +- } ++// web worker ++function useMessageChannel() { ++ var channel = new MessageChannel(); ++ channel.port1.onmessage = flush; ++ return function () { ++ return channel.port2.postMessage(0); ++ }; ++} + +- function lib$es6$promise$asap$$useSetTimeout() { +- return function() { +- setTimeout(lib$es6$promise$asap$$flush, 1); +- }; +- } ++function useSetTimeout() { ++ // Store setTimeout reference so es6-promise will be unaffected by ++ // other code modifying setTimeout (like sinon.useFakeTimers()) ++ var globalSetTimeout = setTimeout; ++ return function () { ++ return globalSetTimeout(flush, 1); ++ }; ++} + +- var lib$es6$promise$asap$$queue = new Array(1000); +- function lib$es6$promise$asap$$flush() { +- for (var i = 0; i < lib$es6$promise$asap$$len; i+=2) { +- var callback = lib$es6$promise$asap$$queue[i]; +- var arg = lib$es6$promise$asap$$queue[i+1]; ++var queue = new Array(1000); ++function flush() { ++ for (var i = 0; i < len; i += 2) { ++ var callback = queue[i]; ++ var arg = queue[i + 1]; + +- callback(arg); ++ callback(arg); + +- lib$es6$promise$asap$$queue[i] = undefined; +- lib$es6$promise$asap$$queue[i+1] = undefined; +- } ++ queue[i] = undefined; ++ queue[i + 1] = undefined; ++ } + +- lib$es6$promise$asap$$len = 0; +- } ++ len = 0; ++} + +- function lib$es6$promise$asap$$attemptVertx() { +- try { +- var r = require; +- var vertx = r('vertx'); +- lib$es6$promise$asap$$vertxNext = vertx.runOnLoop || vertx.runOnContext; +- return lib$es6$promise$asap$$useVertxTimer(); +- } catch(e) { +- return lib$es6$promise$asap$$useSetTimeout(); +- } +- } ++function attemptVertx() { ++ try { ++ var r = require; ++ var vertx = r('vertx'); ++ vertxNext = vertx.runOnLoop || vertx.runOnContext; ++ return useVertxTimer(); ++ } catch (e) { ++ return useSetTimeout(); ++ } ++} + +- var lib$es6$promise$asap$$scheduleFlush; +- // Decide what async method to use to triggering processing of queued callbacks: +- if (lib$es6$promise$asap$$isNode) { +- lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useNextTick(); +- } else if (lib$es6$promise$asap$$BrowserMutationObserver) { +- lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useMutationObserver(); +- } else if (lib$es6$promise$asap$$isWorker) { +- lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useMessageChannel(); +- } else if (lib$es6$promise$asap$$browserWindow === undefined && typeof require === 'function') { +- lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$attemptVertx(); +- } else { +- lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useSetTimeout(); +- } +- function lib$es6$promise$then$$then(onFulfillment, onRejection) { +- var parent = this; +- var state = parent._state; ++var scheduleFlush = undefined; ++// Decide what async method to use to triggering processing of queued callbacks: ++if (isNode) { ++ scheduleFlush = useNextTick(); ++} else if (BrowserMutationObserver) { ++ scheduleFlush = useMutationObserver(); ++} else if (isWorker) { ++ scheduleFlush = useMessageChannel(); ++} else if (browserWindow === undefined && typeof require === 'function') { ++ scheduleFlush = attemptVertx(); ++} else { ++ scheduleFlush = useSetTimeout(); ++} + +- if (state === lib$es6$promise$$internal$$FULFILLED && !onFulfillment || state === lib$es6$promise$$internal$$REJECTED && !onRejection) { +- return this; +- } ++function then(onFulfillment, onRejection) { ++ var _arguments = arguments; + +- var child = new this.constructor(lib$es6$promise$$internal$$noop); +- var result = parent._result; ++ var parent = this; + +- if (state) { +- var callback = arguments[state - 1]; +- lib$es6$promise$asap$$asap(function(){ +- lib$es6$promise$$internal$$invokeCallback(state, child, callback, result); +- }); +- } else { +- lib$es6$promise$$internal$$subscribe(parent, child, onFulfillment, onRejection); +- } ++ var child = new this.constructor(noop); + +- return child; +- } +- var lib$es6$promise$then$$default = lib$es6$promise$then$$then; +- function lib$es6$promise$promise$resolve$$resolve(object) { +- /*jshint validthis:true */ +- var Constructor = this; ++ if (child[PROMISE_ID] === undefined) { ++ makePromise(child); ++ } + +- if (object && typeof object === 'object' && object.constructor === Constructor) { +- return object; +- } ++ var _state = parent._state; + +- var promise = new Constructor(lib$es6$promise$$internal$$noop); +- lib$es6$promise$$internal$$resolve(promise, object); +- return promise; +- } +- var lib$es6$promise$promise$resolve$$default = lib$es6$promise$promise$resolve$$resolve; ++ if (_state) { ++ (function () { ++ var callback = _arguments[_state - 1]; ++ asap(function () { ++ return invokeCallback(_state, child, callback, parent._result); ++ }); ++ })(); ++ } else { ++ subscribe(parent, child, onFulfillment, onRejection); ++ } + +- function lib$es6$promise$$internal$$noop() {} ++ return child; ++} + +- var lib$es6$promise$$internal$$PENDING = void 0; +- var lib$es6$promise$$internal$$FULFILLED = 1; +- var lib$es6$promise$$internal$$REJECTED = 2; ++/** ++ `Promise.resolve` returns a promise that will become resolved with the ++ passed `value`. It is shorthand for the following: + +- var lib$es6$promise$$internal$$GET_THEN_ERROR = new lib$es6$promise$$internal$$ErrorObject(); ++ ```javascript ++ let promise = new Promise(function(resolve, reject){ ++ resolve(1); ++ }); + +- function lib$es6$promise$$internal$$selfFulfillment() { +- return new TypeError("You cannot resolve a promise with itself"); +- } ++ promise.then(function(value){ ++ // value === 1 ++ }); ++ ``` + +- function lib$es6$promise$$internal$$cannotReturnOwn() { +- return new TypeError('A promises callback cannot return that same promise.'); +- } ++ Instead of writing the above, your code now simply becomes the following: + +- function lib$es6$promise$$internal$$getThen(promise) { +- try { +- return promise.then; +- } catch(error) { +- lib$es6$promise$$internal$$GET_THEN_ERROR.error = error; +- return lib$es6$promise$$internal$$GET_THEN_ERROR; +- } +- } ++ ```javascript ++ let promise = Promise.resolve(1); + +- function lib$es6$promise$$internal$$tryThen(then, value, fulfillmentHandler, rejectionHandler) { +- try { +- then.call(value, fulfillmentHandler, rejectionHandler); +- } catch(e) { +- return e; +- } +- } ++ promise.then(function(value){ ++ // value === 1 ++ }); ++ ``` ++ ++ @method resolve ++ @static ++ @param {Any} value value that the returned promise will be resolved with ++ Useful for tooling. ++ @return {Promise} a promise that will become fulfilled with the given ++ `value` ++*/ ++function resolve(object) { ++ /*jshint validthis:true */ ++ var Constructor = this; + +- function lib$es6$promise$$internal$$handleForeignThenable(promise, thenable, then) { +- lib$es6$promise$asap$$asap(function(promise) { +- var sealed = false; +- var error = lib$es6$promise$$internal$$tryThen(then, thenable, function(value) { +- if (sealed) { return; } +- sealed = true; +- if (thenable !== value) { +- lib$es6$promise$$internal$$resolve(promise, value); +- } else { +- lib$es6$promise$$internal$$fulfill(promise, value); +- } +- }, function(reason) { +- if (sealed) { return; } +- sealed = true; ++ if (object && typeof object === 'object' && object.constructor === Constructor) { ++ return object; ++ } + +- lib$es6$promise$$internal$$reject(promise, reason); +- }, 'Settle: ' + (promise._label || ' unknown promise')); ++ var promise = new Constructor(noop); ++ _resolve(promise, object); ++ return promise; ++} + +- if (!sealed && error) { +- sealed = true; +- lib$es6$promise$$internal$$reject(promise, error); +- } +- }, promise); +- } ++var PROMISE_ID = Math.random().toString(36).substring(16); + +- function lib$es6$promise$$internal$$handleOwnThenable(promise, thenable) { +- if (thenable._state === lib$es6$promise$$internal$$FULFILLED) { +- lib$es6$promise$$internal$$fulfill(promise, thenable._result); +- } else if (thenable._state === lib$es6$promise$$internal$$REJECTED) { +- lib$es6$promise$$internal$$reject(promise, thenable._result); +- } else { +- lib$es6$promise$$internal$$subscribe(thenable, undefined, function(value) { +- lib$es6$promise$$internal$$resolve(promise, value); +- }, function(reason) { +- lib$es6$promise$$internal$$reject(promise, reason); +- }); +- } +- } ++function noop() {} + +- function lib$es6$promise$$internal$$handleMaybeThenable(promise, maybeThenable, then) { +- if (maybeThenable.constructor === promise.constructor && +- then === lib$es6$promise$then$$default && +- constructor.resolve === lib$es6$promise$promise$resolve$$default) { +- lib$es6$promise$$internal$$handleOwnThenable(promise, maybeThenable); +- } else { +- if (then === lib$es6$promise$$internal$$GET_THEN_ERROR) { +- lib$es6$promise$$internal$$reject(promise, lib$es6$promise$$internal$$GET_THEN_ERROR.error); +- } else if (then === undefined) { +- lib$es6$promise$$internal$$fulfill(promise, maybeThenable); +- } else if (lib$es6$promise$utils$$isFunction(then)) { +- lib$es6$promise$$internal$$handleForeignThenable(promise, maybeThenable, then); +- } else { +- lib$es6$promise$$internal$$fulfill(promise, maybeThenable); +- } +- } +- } ++var PENDING = void 0; ++var FULFILLED = 1; ++var REJECTED = 2; + +- function lib$es6$promise$$internal$$resolve(promise, value) { +- if (promise === value) { +- lib$es6$promise$$internal$$reject(promise, lib$es6$promise$$internal$$selfFulfillment()); +- } else if (lib$es6$promise$utils$$objectOrFunction(value)) { +- lib$es6$promise$$internal$$handleMaybeThenable(promise, value, lib$es6$promise$$internal$$getThen(value)); +- } else { +- lib$es6$promise$$internal$$fulfill(promise, value); +- } +- } ++var GET_THEN_ERROR = new ErrorObject(); + +- function lib$es6$promise$$internal$$publishRejection(promise) { +- if (promise._onerror) { +- promise._onerror(promise._result); +- } ++function selfFulfillment() { ++ return new TypeError("You cannot resolve a promise with itself"); ++} + +- lib$es6$promise$$internal$$publish(promise); +- } ++function cannotReturnOwn() { ++ return new TypeError('A promises callback cannot return that same promise.'); ++} + +- function lib$es6$promise$$internal$$fulfill(promise, value) { +- if (promise._state !== lib$es6$promise$$internal$$PENDING) { return; } ++function getThen(promise) { ++ try { ++ return promise.then; ++ } catch (error) { ++ GET_THEN_ERROR.error = error; ++ return GET_THEN_ERROR; ++ } ++} + +- promise._result = value; +- promise._state = lib$es6$promise$$internal$$FULFILLED; ++function tryThen(then, value, fulfillmentHandler, rejectionHandler) { ++ try { ++ then.call(value, fulfillmentHandler, rejectionHandler); ++ } catch (e) { ++ return e; ++ } ++} + +- if (promise._subscribers.length !== 0) { +- lib$es6$promise$asap$$asap(lib$es6$promise$$internal$$publish, promise); ++function handleForeignThenable(promise, thenable, then) { ++ asap(function (promise) { ++ var sealed = false; ++ var error = tryThen(then, thenable, function (value) { ++ if (sealed) { ++ return; ++ } ++ sealed = true; ++ if (thenable !== value) { ++ _resolve(promise, value); ++ } else { ++ fulfill(promise, value); ++ } ++ }, function (reason) { ++ if (sealed) { ++ return; + } ++ sealed = true; ++ ++ _reject(promise, reason); ++ }, 'Settle: ' + (promise._label || ' unknown promise')); ++ ++ if (!sealed && error) { ++ sealed = true; ++ _reject(promise, error); + } ++ }, promise); ++} + +- function lib$es6$promise$$internal$$reject(promise, reason) { +- if (promise._state !== lib$es6$promise$$internal$$PENDING) { return; } +- promise._state = lib$es6$promise$$internal$$REJECTED; +- promise._result = reason; ++function handleOwnThenable(promise, thenable) { ++ if (thenable._state === FULFILLED) { ++ fulfill(promise, thenable._result); ++ } else if (thenable._state === REJECTED) { ++ _reject(promise, thenable._result); ++ } else { ++ subscribe(thenable, undefined, function (value) { ++ return _resolve(promise, value); ++ }, function (reason) { ++ return _reject(promise, reason); ++ }); ++ } ++} + +- lib$es6$promise$asap$$asap(lib$es6$promise$$internal$$publishRejection, promise); ++function handleMaybeThenable(promise, maybeThenable, then$$) { ++ if (maybeThenable.constructor === promise.constructor && then$$ === then && maybeThenable.constructor.resolve === resolve) { ++ handleOwnThenable(promise, maybeThenable); ++ } else { ++ if (then$$ === GET_THEN_ERROR) { ++ _reject(promise, GET_THEN_ERROR.error); ++ } else if (then$$ === undefined) { ++ fulfill(promise, maybeThenable); ++ } else if (isFunction(then$$)) { ++ handleForeignThenable(promise, maybeThenable, then$$); ++ } else { ++ fulfill(promise, maybeThenable); + } ++ } ++} ++ ++function _resolve(promise, value) { ++ if (promise === value) { ++ _reject(promise, selfFulfillment()); ++ } else if (objectOrFunction(value)) { ++ handleMaybeThenable(promise, value, getThen(value)); ++ } else { ++ fulfill(promise, value); ++ } ++} + +- function lib$es6$promise$$internal$$subscribe(parent, child, onFulfillment, onRejection) { +- var subscribers = parent._subscribers; +- var length = subscribers.length; ++function publishRejection(promise) { ++ if (promise._onerror) { ++ promise._onerror(promise._result); ++ } ++ ++ publish(promise); ++} + +- parent._onerror = null; ++function fulfill(promise, value) { ++ if (promise._state !== PENDING) { ++ return; ++ } + +- subscribers[length] = child; +- subscribers[length + lib$es6$promise$$internal$$FULFILLED] = onFulfillment; +- subscribers[length + lib$es6$promise$$internal$$REJECTED] = onRejection; ++ promise._result = value; ++ promise._state = FULFILLED; + +- if (length === 0 && parent._state) { +- lib$es6$promise$asap$$asap(lib$es6$promise$$internal$$publish, parent); +- } +- } ++ if (promise._subscribers.length !== 0) { ++ asap(publish, promise); ++ } ++} + +- function lib$es6$promise$$internal$$publish(promise) { +- var subscribers = promise._subscribers; +- var settled = promise._state; ++function _reject(promise, reason) { ++ if (promise._state !== PENDING) { ++ return; ++ } ++ promise._state = REJECTED; ++ promise._result = reason; + +- if (subscribers.length === 0) { return; } ++ asap(publishRejection, promise); ++} + +- var child, callback, detail = promise._result; ++function subscribe(parent, child, onFulfillment, onRejection) { ++ var _subscribers = parent._subscribers; ++ var length = _subscribers.length; + +- for (var i = 0; i < subscribers.length; i += 3) { +- child = subscribers[i]; +- callback = subscribers[i + settled]; ++ parent._onerror = null; + +- if (child) { +- lib$es6$promise$$internal$$invokeCallback(settled, child, callback, detail); +- } else { +- callback(detail); +- } +- } ++ _subscribers[length] = child; ++ _subscribers[length + FULFILLED] = onFulfillment; ++ _subscribers[length + REJECTED] = onRejection; + +- promise._subscribers.length = 0; +- } ++ if (length === 0 && parent._state) { ++ asap(publish, parent); ++ } ++} + +- function lib$es6$promise$$internal$$ErrorObject() { +- this.error = null; +- } ++function publish(promise) { ++ var subscribers = promise._subscribers; ++ var settled = promise._state; ++ ++ if (subscribers.length === 0) { ++ return; ++ } + +- var lib$es6$promise$$internal$$TRY_CATCH_ERROR = new lib$es6$promise$$internal$$ErrorObject(); ++ var child = undefined, ++ callback = undefined, ++ detail = promise._result; + +- function lib$es6$promise$$internal$$tryCatch(callback, detail) { +- try { +- return callback(detail); +- } catch(e) { +- lib$es6$promise$$internal$$TRY_CATCH_ERROR.error = e; +- return lib$es6$promise$$internal$$TRY_CATCH_ERROR; +- } ++ for (var i = 0; i < subscribers.length; i += 3) { ++ child = subscribers[i]; ++ callback = subscribers[i + settled]; ++ ++ if (child) { ++ invokeCallback(settled, child, callback, detail); ++ } else { ++ callback(detail); + } ++ } + +- function lib$es6$promise$$internal$$invokeCallback(settled, promise, callback, detail) { +- var hasCallback = lib$es6$promise$utils$$isFunction(callback), +- value, error, succeeded, failed; ++ promise._subscribers.length = 0; ++} + +- if (hasCallback) { +- value = lib$es6$promise$$internal$$tryCatch(callback, detail); ++function ErrorObject() { ++ this.error = null; ++} + +- if (value === lib$es6$promise$$internal$$TRY_CATCH_ERROR) { +- failed = true; +- error = value.error; +- value = null; +- } else { +- succeeded = true; +- } ++var TRY_CATCH_ERROR = new ErrorObject(); + +- if (promise === value) { +- lib$es6$promise$$internal$$reject(promise, lib$es6$promise$$internal$$cannotReturnOwn()); +- return; +- } ++function tryCatch(callback, detail) { ++ try { ++ return callback(detail); ++ } catch (e) { ++ TRY_CATCH_ERROR.error = e; ++ return TRY_CATCH_ERROR; ++ } ++} + +- } else { +- value = detail; +- succeeded = true; +- } ++function invokeCallback(settled, promise, callback, detail) { ++ var hasCallback = isFunction(callback), ++ value = undefined, ++ error = undefined, ++ succeeded = undefined, ++ failed = undefined; + +- if (promise._state !== lib$es6$promise$$internal$$PENDING) { +- // noop +- } else if (hasCallback && succeeded) { +- lib$es6$promise$$internal$$resolve(promise, value); +- } else if (failed) { +- lib$es6$promise$$internal$$reject(promise, error); +- } else if (settled === lib$es6$promise$$internal$$FULFILLED) { +- lib$es6$promise$$internal$$fulfill(promise, value); +- } else if (settled === lib$es6$promise$$internal$$REJECTED) { +- lib$es6$promise$$internal$$reject(promise, value); +- } ++ if (hasCallback) { ++ value = tryCatch(callback, detail); ++ ++ if (value === TRY_CATCH_ERROR) { ++ failed = true; ++ error = value.error; ++ value = null; ++ } else { ++ succeeded = true; + } + +- function lib$es6$promise$$internal$$initializePromise(promise, resolver) { +- try { +- resolver(function resolvePromise(value){ +- lib$es6$promise$$internal$$resolve(promise, value); +- }, function rejectPromise(reason) { +- lib$es6$promise$$internal$$reject(promise, reason); +- }); +- } catch(e) { +- lib$es6$promise$$internal$$reject(promise, e); +- } ++ if (promise === value) { ++ _reject(promise, cannotReturnOwn()); ++ return; + } ++ } else { ++ value = detail; ++ succeeded = true; ++ } + +- function lib$es6$promise$promise$all$$all(entries) { +- return new lib$es6$promise$enumerator$$default(this, entries).promise; ++ if (promise._state !== PENDING) { ++ // noop ++ } else if (hasCallback && succeeded) { ++ _resolve(promise, value); ++ } else if (failed) { ++ _reject(promise, error); ++ } else if (settled === FULFILLED) { ++ fulfill(promise, value); ++ } else if (settled === REJECTED) { ++ _reject(promise, value); + } +- var lib$es6$promise$promise$all$$default = lib$es6$promise$promise$all$$all; +- function lib$es6$promise$promise$race$$race(entries) { +- /*jshint validthis:true */ +- var Constructor = this; ++} + +- var promise = new Constructor(lib$es6$promise$$internal$$noop); ++function initializePromise(promise, resolver) { ++ try { ++ resolver(function resolvePromise(value) { ++ _resolve(promise, value); ++ }, function rejectPromise(reason) { ++ _reject(promise, reason); ++ }); ++ } catch (e) { ++ _reject(promise, e); ++ } ++} + +- if (!lib$es6$promise$utils$$isArray(entries)) { +- lib$es6$promise$$internal$$reject(promise, new TypeError('You must pass an array to race.')); +- return promise; +- } ++var id = 0; ++function nextId() { ++ return id++; ++} + +- var length = entries.length; ++function makePromise(promise) { ++ promise[PROMISE_ID] = id++; ++ promise._state = undefined; ++ promise._result = undefined; ++ promise._subscribers = []; ++} + +- function onFulfillment(value) { +- lib$es6$promise$$internal$$resolve(promise, value); +- } ++function Enumerator(Constructor, input) { ++ this._instanceConstructor = Constructor; ++ this.promise = new Constructor(noop); + +- function onRejection(reason) { +- lib$es6$promise$$internal$$reject(promise, reason); +- } ++ if (!this.promise[PROMISE_ID]) { ++ makePromise(this.promise); ++ } + +- for (var i = 0; promise._state === lib$es6$promise$$internal$$PENDING && i < length; i++) { +- lib$es6$promise$$internal$$subscribe(Constructor.resolve(entries[i]), undefined, onFulfillment, onRejection); +- } ++ if (isArray(input)) { ++ this._input = input; ++ this.length = input.length; ++ this._remaining = input.length; + +- return promise; +- } +- var lib$es6$promise$promise$race$$default = lib$es6$promise$promise$race$$race; +- function lib$es6$promise$promise$reject$$reject(reason) { +- /*jshint validthis:true */ +- var Constructor = this; +- var promise = new Constructor(lib$es6$promise$$internal$$noop); +- lib$es6$promise$$internal$$reject(promise, reason); +- return promise; ++ this._result = new Array(this.length); ++ ++ if (this.length === 0) { ++ fulfill(this.promise, this._result); ++ } else { ++ this.length = this.length || 0; ++ this._enumerate(); ++ if (this._remaining === 0) { ++ fulfill(this.promise, this._result); ++ } + } +- var lib$es6$promise$promise$reject$$default = lib$es6$promise$promise$reject$$reject; ++ } else { ++ _reject(this.promise, validationError()); ++ } ++} ++ ++function validationError() { ++ return new Error('Array Methods must be provided an Array'); ++}; ++ ++Enumerator.prototype._enumerate = function () { ++ var length = this.length; ++ var _input = this._input; ++ ++ for (var i = 0; this._state === PENDING && i < length; i++) { ++ this._eachEntry(_input[i], i); ++ } ++}; ++ ++Enumerator.prototype._eachEntry = function (entry, i) { ++ var c = this._instanceConstructor; ++ var resolve$$ = c.resolve; + +- var lib$es6$promise$promise$$counter = 0; ++ if (resolve$$ === resolve) { ++ var _then = getThen(entry); + +- function lib$es6$promise$promise$$needsResolver() { +- throw new TypeError('You must pass a resolver function as the first argument to the promise constructor'); ++ if (_then === then && entry._state !== PENDING) { ++ this._settledAt(entry._state, i, entry._result); ++ } else if (typeof _then !== 'function') { ++ this._remaining--; ++ this._result[i] = entry; ++ } else if (c === Promise) { ++ var promise = new c(noop); ++ handleMaybeThenable(promise, entry, _then); ++ this._willSettleAt(promise, i); ++ } else { ++ this._willSettleAt(new c(function (resolve$$) { ++ return resolve$$(entry); ++ }), i); + } ++ } else { ++ this._willSettleAt(resolve$$(entry), i); ++ } ++}; ++ ++Enumerator.prototype._settledAt = function (state, i, value) { ++ var promise = this.promise; ++ ++ if (promise._state === PENDING) { ++ this._remaining--; + +- function lib$es6$promise$promise$$needsNew() { +- throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function."); ++ if (state === REJECTED) { ++ _reject(promise, value); ++ } else { ++ this._result[i] = value; + } ++ } + +- var lib$es6$promise$promise$$default = lib$es6$promise$promise$$Promise; +- /** +- Promise objects represent the eventual result of an asynchronous operation. The +- primary way of interacting with a promise is through its `then` method, which +- registers callbacks to receive either a promise's eventual value or the reason +- why the promise cannot be fulfilled. ++ if (this._remaining === 0) { ++ fulfill(promise, this._result); ++ } ++}; + +- Terminology +- ----------- ++Enumerator.prototype._willSettleAt = function (promise, i) { ++ var enumerator = this; + +- - `promise` is an object or function with a `then` method whose behavior conforms to this specification. +- - `thenable` is an object or function that defines a `then` method. +- - `value` is any legal JavaScript value (including undefined, a thenable, or a promise). +- - `exception` is a value that is thrown using the throw statement. +- - `reason` is a value that indicates why a promise was rejected. +- - `settled` the final resting state of a promise, fulfilled or rejected. ++ subscribe(promise, undefined, function (value) { ++ return enumerator._settledAt(FULFILLED, i, value); ++ }, function (reason) { ++ return enumerator._settledAt(REJECTED, i, reason); ++ }); ++}; + +- A promise can be in one of three states: pending, fulfilled, or rejected. ++/** ++ `Promise.all` accepts an array of promises, and returns a new promise which ++ is fulfilled with an array of fulfillment values for the passed promises, or ++ rejected with the reason of the first passed promise to be rejected. It casts all ++ elements of the passed iterable to promises as it runs this algorithm. + +- Promises that are fulfilled have a fulfillment value and are in the fulfilled +- state. Promises that are rejected have a rejection reason and are in the +- rejected state. A fulfillment value is never a thenable. ++ Example: + +- Promises can also be said to *resolve* a value. If this value is also a +- promise, then the original promise's settled state will match the value's +- settled state. So a promise that *resolves* a promise that rejects will +- itself reject, and a promise that *resolves* a promise that fulfills will +- itself fulfill. ++ ```javascript ++ let promise1 = resolve(1); ++ let promise2 = resolve(2); ++ let promise3 = resolve(3); ++ let promises = [ promise1, promise2, promise3 ]; + ++ Promise.all(promises).then(function(array){ ++ // The array here would be [ 1, 2, 3 ]; ++ }); ++ ``` + +- Basic Usage: +- ------------ ++ If any of the `promises` given to `all` are rejected, the first promise ++ that is rejected will be given as an argument to the returned promises's ++ rejection handler. For example: + +- ```js +- var promise = new Promise(function(resolve, reject) { +- // on success +- resolve(value); ++ Example: + +- // on failure +- reject(reason); +- }); ++ ```javascript ++ let promise1 = resolve(1); ++ let promise2 = reject(new Error("2")); ++ let promise3 = reject(new Error("3")); ++ let promises = [ promise1, promise2, promise3 ]; + +- promise.then(function(value) { +- // on fulfillment +- }, function(reason) { +- // on rejection +- }); +- ``` ++ Promise.all(promises).then(function(array){ ++ // Code here never runs because there are rejected promises! ++ }, function(error) { ++ // error.message === "2" ++ }); ++ ``` ++ ++ @method all ++ @static ++ @param {Array} entries array of promises ++ @param {String} label optional string for labeling the promise. ++ Useful for tooling. ++ @return {Promise} promise that is fulfilled when all `promises` have been ++ fulfilled, or rejected if any of them become rejected. ++ @static ++*/ ++function all(entries) { ++ return new Enumerator(this, entries).promise; ++} ++ ++/** ++ `Promise.race` returns a new promise which is settled in the same way as the ++ first passed promise to settle. + +- Advanced Usage: +- --------------- ++ Example: + +- Promises shine when abstracting away asynchronous interactions such as +- `XMLHttpRequest`s. ++ ```javascript ++ let promise1 = new Promise(function(resolve, reject){ ++ setTimeout(function(){ ++ resolve('promise 1'); ++ }, 200); ++ }); + +- ```js +- function getJSON(url) { +- return new Promise(function(resolve, reject){ +- var xhr = new XMLHttpRequest(); ++ let promise2 = new Promise(function(resolve, reject){ ++ setTimeout(function(){ ++ resolve('promise 2'); ++ }, 100); ++ }); + +- xhr.open('GET', url); +- xhr.onreadystatechange = handler; +- xhr.responseType = 'json'; +- xhr.setRequestHeader('Accept', 'application/json'); +- xhr.send(); ++ Promise.race([promise1, promise2]).then(function(result){ ++ // result === 'promise 2' because it was resolved before promise1 ++ // was resolved. ++ }); ++ ``` ++ ++ `Promise.race` is deterministic in that only the state of the first ++ settled promise matters. For example, even if other promises given to the ++ `promises` array argument are resolved, but the first settled promise has ++ become rejected before the other promises became fulfilled, the returned ++ promise will become rejected: ++ ++ ```javascript ++ let promise1 = new Promise(function(resolve, reject){ ++ setTimeout(function(){ ++ resolve('promise 1'); ++ }, 200); ++ }); + +- function handler() { +- if (this.readyState === this.DONE) { +- if (this.status === 200) { +- resolve(this.response); +- } else { +- reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']')); +- } +- } +- }; +- }); +- } ++ let promise2 = new Promise(function(resolve, reject){ ++ setTimeout(function(){ ++ reject(new Error('promise 2')); ++ }, 100); ++ }); + +- getJSON('/posts.json').then(function(json) { +- // on fulfillment +- }, function(reason) { +- // on rejection +- }); +- ``` ++ Promise.race([promise1, promise2]).then(function(result){ ++ // Code here never runs ++ }, function(reason){ ++ // reason.message === 'promise 2' because promise 2 became rejected before ++ // promise 1 became fulfilled ++ }); ++ ``` + +- Unlike callbacks, promises are great composable primitives. ++ An example real-world use case is implementing timeouts: + +- ```js +- Promise.all([ +- getJSON('/posts'), +- getJSON('/comments') +- ]).then(function(values){ +- values[0] // => postsJSON +- values[1] // => commentsJSON ++ ```javascript ++ Promise.race([ajax('foo.json'), timeout(5000)]) ++ ``` + +- return values; +- }); +- ``` +- +- @class Promise +- @param {function} resolver +- Useful for tooling. +- @constructor +- */ +- function lib$es6$promise$promise$$Promise(resolver) { +- this._id = lib$es6$promise$promise$$counter++; +- this._state = undefined; +- this._result = undefined; +- this._subscribers = []; +- +- if (lib$es6$promise$$internal$$noop !== resolver) { +- typeof resolver !== 'function' && lib$es6$promise$promise$$needsResolver(); +- this instanceof lib$es6$promise$promise$$Promise ? lib$es6$promise$$internal$$initializePromise(this, resolver) : lib$es6$promise$promise$$needsNew(); ++ @method race ++ @static ++ @param {Array} promises array of promises to observe ++ Useful for tooling. ++ @return {Promise} a promise which settles in the same way as the first passed ++ promise to settle. ++*/ ++function race(entries) { ++ /*jshint validthis:true */ ++ var Constructor = this; ++ ++ if (!isArray(entries)) { ++ return new Constructor(function (_, reject) { ++ return reject(new TypeError('You must pass an array to race.')); ++ }); ++ } else { ++ return new Constructor(function (resolve, reject) { ++ var length = entries.length; ++ for (var i = 0; i < length; i++) { ++ Constructor.resolve(entries[i]).then(resolve, reject); + } +- } ++ }); ++ } ++} + +- lib$es6$promise$promise$$Promise.all = lib$es6$promise$promise$all$$default; +- lib$es6$promise$promise$$Promise.race = lib$es6$promise$promise$race$$default; +- lib$es6$promise$promise$$Promise.resolve = lib$es6$promise$promise$resolve$$default; +- lib$es6$promise$promise$$Promise.reject = lib$es6$promise$promise$reject$$default; +- lib$es6$promise$promise$$Promise._setScheduler = lib$es6$promise$asap$$setScheduler; +- lib$es6$promise$promise$$Promise._setAsap = lib$es6$promise$asap$$setAsap; +- lib$es6$promise$promise$$Promise._asap = lib$es6$promise$asap$$asap; ++/** ++ `Promise.reject` returns a promise rejected with the passed `reason`. ++ It is shorthand for the following: + +- lib$es6$promise$promise$$Promise.prototype = { +- constructor: lib$es6$promise$promise$$Promise, ++ ```javascript ++ let promise = new Promise(function(resolve, reject){ ++ reject(new Error('WHOOPS')); ++ }); + +- /** +- The primary way of interacting with a promise is through its `then` method, +- which registers callbacks to receive either a promise's eventual value or the +- reason why the promise cannot be fulfilled. +- +- ```js +- findUser().then(function(user){ +- // user is available +- }, function(reason){ +- // user is unavailable, and you are given the reason why +- }); +- ``` +- +- Chaining +- -------- +- +- The return value of `then` is itself a promise. This second, 'downstream' +- promise is resolved with the return value of the first promise's fulfillment +- or rejection handler, or rejected if the handler throws an exception. +- +- ```js +- findUser().then(function (user) { +- return user.name; +- }, function (reason) { +- return 'default name'; +- }).then(function (userName) { +- // If `findUser` fulfilled, `userName` will be the user's name, otherwise it +- // will be `'default name'` +- }); ++ promise.then(function(value){ ++ // Code here doesn't run because the promise is rejected! ++ }, function(reason){ ++ // reason.message === 'WHOOPS' ++ }); ++ ``` + +- findUser().then(function (user) { +- throw new Error('Found user, but still unhappy'); +- }, function (reason) { +- throw new Error('`findUser` rejected and we're unhappy'); +- }).then(function (value) { +- // never reached +- }, function (reason) { +- // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'. +- // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'. +- }); +- ``` +- If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream. +- +- ```js +- findUser().then(function (user) { +- throw new PedagogicalException('Upstream error'); +- }).then(function (value) { +- // never reached +- }).then(function (value) { +- // never reached +- }, function (reason) { +- // The `PedgagocialException` is propagated all the way down to here +- }); +- ``` ++ Instead of writing the above, your code now simply becomes the following: + +- Assimilation +- ------------ ++ ```javascript ++ let promise = Promise.reject(new Error('WHOOPS')); + +- Sometimes the value you want to propagate to a downstream promise can only be +- retrieved asynchronously. This can be achieved by returning a promise in the +- fulfillment or rejection handler. The downstream promise will then be pending +- until the returned promise is settled. This is called *assimilation*. ++ promise.then(function(value){ ++ // Code here doesn't run because the promise is rejected! ++ }, function(reason){ ++ // reason.message === 'WHOOPS' ++ }); ++ ``` + +- ```js +- findUser().then(function (user) { +- return findCommentsByAuthor(user); +- }).then(function (comments) { +- // The user's comments are now available +- }); +- ``` ++ @method reject ++ @static ++ @param {Any} reason value that the returned promise will be rejected with. ++ Useful for tooling. ++ @return {Promise} a promise rejected with the given `reason`. ++*/ ++function reject(reason) { ++ /*jshint validthis:true */ ++ var Constructor = this; ++ var promise = new Constructor(noop); ++ _reject(promise, reason); ++ return promise; ++} + +- If the assimliated promise rejects, then the downstream promise will also reject. ++function needsResolver() { ++ throw new TypeError('You must pass a resolver function as the first argument to the promise constructor'); ++} + +- ```js +- findUser().then(function (user) { +- return findCommentsByAuthor(user); +- }).then(function (comments) { +- // If `findCommentsByAuthor` fulfills, we'll have the value here +- }, function (reason) { +- // If `findCommentsByAuthor` rejects, we'll have the reason here +- }); +- ``` ++function needsNew() { ++ throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function."); ++} + +- Simple Example +- -------------- ++/** ++ Promise objects represent the eventual result of an asynchronous operation. The ++ primary way of interacting with a promise is through its `then` method, which ++ registers callbacks to receive either a promise's eventual value or the reason ++ why the promise cannot be fulfilled. + +- Synchronous Example ++ Terminology ++ ----------- + +- ```javascript +- var result; ++ - `promise` is an object or function with a `then` method whose behavior conforms to this specification. ++ - `thenable` is an object or function that defines a `then` method. ++ - `value` is any legal JavaScript value (including undefined, a thenable, or a promise). ++ - `exception` is a value that is thrown using the throw statement. ++ - `reason` is a value that indicates why a promise was rejected. ++ - `settled` the final resting state of a promise, fulfilled or rejected. + +- try { +- result = findResult(); +- // success +- } catch(reason) { +- // failure +- } +- ``` ++ A promise can be in one of three states: pending, fulfilled, or rejected. + +- Errback Example ++ Promises that are fulfilled have a fulfillment value and are in the fulfilled ++ state. Promises that are rejected have a rejection reason and are in the ++ rejected state. A fulfillment value is never a thenable. + +- ```js +- findResult(function(result, err){ +- if (err) { +- // failure +- } else { +- // success +- } +- }); +- ``` ++ Promises can also be said to *resolve* a value. If this value is also a ++ promise, then the original promise's settled state will match the value's ++ settled state. So a promise that *resolves* a promise that rejects will ++ itself reject, and a promise that *resolves* a promise that fulfills will ++ itself fulfill. + +- Promise Example; + +- ```javascript +- findResult().then(function(result){ +- // success +- }, function(reason){ +- // failure +- }); +- ``` ++ Basic Usage: ++ ------------ ++ ++ ```js ++ let promise = new Promise(function(resolve, reject) { ++ // on success ++ resolve(value); + +- Advanced Example +- -------------- ++ // on failure ++ reject(reason); ++ }); + +- Synchronous Example ++ promise.then(function(value) { ++ // on fulfillment ++ }, function(reason) { ++ // on rejection ++ }); ++ ``` + +- ```javascript +- var author, books; ++ Advanced Usage: ++ --------------- + +- try { +- author = findAuthor(); +- books = findBooksByAuthor(author); ++ Promises shine when abstracting away asynchronous interactions such as ++ `XMLHttpRequest`s. ++ ++ ```js ++ function getJSON(url) { ++ return new Promise(function(resolve, reject){ ++ let xhr = new XMLHttpRequest(); ++ ++ xhr.open('GET', url); ++ xhr.onreadystatechange = handler; ++ xhr.responseType = 'json'; ++ xhr.setRequestHeader('Accept', 'application/json'); ++ xhr.send(); ++ ++ function handler() { ++ if (this.readyState === this.DONE) { ++ if (this.status === 200) { ++ resolve(this.response); ++ } else { ++ reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']')); ++ } ++ } ++ }; ++ }); ++ } ++ ++ getJSON('/posts.json').then(function(json) { ++ // on fulfillment ++ }, function(reason) { ++ // on rejection ++ }); ++ ``` ++ ++ Unlike callbacks, promises are great composable primitives. ++ ++ ```js ++ Promise.all([ ++ getJSON('/posts'), ++ getJSON('/comments') ++ ]).then(function(values){ ++ values[0] // => postsJSON ++ values[1] // => commentsJSON ++ ++ return values; ++ }); ++ ``` ++ ++ @class Promise ++ @param {function} resolver ++ Useful for tooling. ++ @constructor ++*/ ++function Promise(resolver) { ++ this[PROMISE_ID] = nextId(); ++ this._result = this._state = undefined; ++ this._subscribers = []; ++ ++ if (noop !== resolver) { ++ typeof resolver !== 'function' && needsResolver(); ++ this instanceof Promise ? initializePromise(this, resolver) : needsNew(); ++ } ++} ++ ++Promise.all = all; ++Promise.race = race; ++Promise.resolve = resolve; ++Promise.reject = reject; ++Promise._setScheduler = setScheduler; ++Promise._setAsap = setAsap; ++Promise._asap = asap; ++ ++Promise.prototype = { ++ constructor: Promise, ++ ++ /** ++ The primary way of interacting with a promise is through its `then` method, ++ which registers callbacks to receive either a promise's eventual value or the ++ reason why the promise cannot be fulfilled. ++ ++ ```js ++ findUser().then(function(user){ ++ // user is available ++ }, function(reason){ ++ // user is unavailable, and you are given the reason why ++ }); ++ ``` ++ ++ Chaining ++ -------- ++ ++ The return value of `then` is itself a promise. This second, 'downstream' ++ promise is resolved with the return value of the first promise's fulfillment ++ or rejection handler, or rejected if the handler throws an exception. ++ ++ ```js ++ findUser().then(function (user) { ++ return user.name; ++ }, function (reason) { ++ return 'default name'; ++ }).then(function (userName) { ++ // If `findUser` fulfilled, `userName` will be the user's name, otherwise it ++ // will be `'default name'` ++ }); ++ ++ findUser().then(function (user) { ++ throw new Error('Found user, but still unhappy'); ++ }, function (reason) { ++ throw new Error('`findUser` rejected and we're unhappy'); ++ }).then(function (value) { ++ // never reached ++ }, function (reason) { ++ // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'. ++ // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'. ++ }); ++ ``` ++ If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream. ++ ++ ```js ++ findUser().then(function (user) { ++ throw new PedagogicalException('Upstream error'); ++ }).then(function (value) { ++ // never reached ++ }).then(function (value) { ++ // never reached ++ }, function (reason) { ++ // The `PedgagocialException` is propagated all the way down to here ++ }); ++ ``` ++ ++ Assimilation ++ ------------ ++ ++ Sometimes the value you want to propagate to a downstream promise can only be ++ retrieved asynchronously. This can be achieved by returning a promise in the ++ fulfillment or rejection handler. The downstream promise will then be pending ++ until the returned promise is settled. This is called *assimilation*. ++ ++ ```js ++ findUser().then(function (user) { ++ return findCommentsByAuthor(user); ++ }).then(function (comments) { ++ // The user's comments are now available ++ }); ++ ``` ++ ++ If the assimliated promise rejects, then the downstream promise will also reject. ++ ++ ```js ++ findUser().then(function (user) { ++ return findCommentsByAuthor(user); ++ }).then(function (comments) { ++ // If `findCommentsByAuthor` fulfills, we'll have the value here ++ }, function (reason) { ++ // If `findCommentsByAuthor` rejects, we'll have the reason here ++ }); ++ ``` ++ ++ Simple Example ++ -------------- ++ ++ Synchronous Example ++ ++ ```javascript ++ let result; ++ ++ try { ++ result = findResult(); ++ // success ++ } catch(reason) { ++ // failure ++ } ++ ``` ++ ++ Errback Example ++ ++ ```js ++ findResult(function(result, err){ ++ if (err) { ++ // failure ++ } else { + // success +- } catch(reason) { ++ } ++ }); ++ ``` ++ ++ Promise Example; ++ ++ ```javascript ++ findResult().then(function(result){ ++ // success ++ }, function(reason){ ++ // failure ++ }); ++ ``` ++ ++ Advanced Example ++ -------------- ++ ++ Synchronous Example ++ ++ ```javascript ++ let author, books; ++ ++ try { ++ author = findAuthor(); ++ books = findBooksByAuthor(author); ++ // success ++ } catch(reason) { ++ // failure ++ } ++ ``` ++ ++ Errback Example ++ ++ ```js ++ ++ function foundBooks(books) { ++ ++ } ++ ++ function failure(reason) { ++ ++ } ++ ++ findAuthor(function(author, err){ ++ if (err) { ++ failure(err); + // failure ++ } else { ++ try { ++ findBoooksByAuthor(author, function(books, err) { ++ if (err) { ++ failure(err); ++ } else { ++ try { ++ foundBooks(books); ++ } catch(reason) { ++ failure(reason); ++ } ++ } ++ }); ++ } catch(error) { ++ failure(err); ++ } ++ // success + } +- ``` ++ }); ++ ``` ++ ++ Promise Example; ++ ++ ```javascript ++ findAuthor(). ++ then(findBooksByAuthor). ++ then(function(books){ ++ // found books ++ }).catch(function(reason){ ++ // something went wrong ++ }); ++ ``` ++ ++ @method then ++ @param {Function} onFulfilled ++ @param {Function} onRejected ++ Useful for tooling. ++ @return {Promise} ++ */ ++ then: then, ++ ++ /** ++ `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same ++ as the catch block of a try/catch statement. ++ ++ ```js ++ function findAuthor(){ ++ throw new Error('couldn't find that author'); ++ } ++ ++ // synchronous ++ try { ++ findAuthor(); ++ } catch(reason) { ++ // something went wrong ++ } ++ ++ // async with promises ++ findAuthor().catch(function(reason){ ++ // something went wrong ++ }); ++ ``` ++ ++ @method catch ++ @param {Function} onRejection ++ Useful for tooling. ++ @return {Promise} ++ */ ++ 'catch': function _catch(onRejection) { ++ return this.then(null, onRejection); ++ } ++}; + +- Errback Example ++function polyfill() { ++ var local = undefined; + +- ```js ++ if (typeof global !== 'undefined') { ++ local = global; ++ } else if (typeof self !== 'undefined') { ++ local = self; ++ } else { ++ try { ++ local = Function('return this')(); ++ } catch (e) { ++ throw new Error('polyfill failed because global object is unavailable in this environment'); ++ } ++ } + +- function foundBooks(books) { ++ var P = local.Promise; + +- } ++ if (P) { ++ var promiseToString = null; ++ try { ++ promiseToString = Object.prototype.toString.call(P.resolve()); ++ } catch (e) { ++ // silently ignored ++ } + +- function failure(reason) { ++ if (promiseToString === '[object Promise]' && !P.cast) { ++ return; ++ } ++ } + +- } ++ local.Promise = Promise; ++} + +- findAuthor(function(author, err){ +- if (err) { +- failure(err); +- // failure +- } else { +- try { +- findBoooksByAuthor(author, function(books, err) { +- if (err) { +- failure(err); +- } else { +- try { +- foundBooks(books); +- } catch(reason) { +- failure(reason); +- } +- } +- }); +- } catch(error) { +- failure(err); +- } +- // success +- } +- }); +- ``` ++polyfill(); ++// Strange compat.. ++Promise.polyfill = polyfill; ++Promise.Promise = Promise; + +- Promise Example; ++return Promise; + +- ```javascript +- findAuthor(). +- then(findBooksByAuthor). +- then(function(books){ +- // found books +- }).catch(function(reason){ +- // something went wrong +- }); +- ``` ++}))); + +- @method then +- @param {Function} onFulfilled +- @param {Function} onRejected +- Useful for tooling. +- @return {Promise} +- */ +- then: lib$es6$promise$then$$default, ++}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) ++},{"_process":13}],10:[function(require,module,exports){ ++// Copyright Joyent, Inc. and other Node contributors. ++// ++// Permission is hereby granted, free of charge, to any person obtaining a ++// copy of this software and associated documentation files (the ++// "Software"), to deal in the Software without restriction, including ++// without limitation the rights to use, copy, modify, merge, publish, ++// distribute, sublicense, and/or sell copies of the Software, and to permit ++// persons to whom the Software is furnished to do so, subject to the ++// following conditions: ++// ++// The above copyright notice and this permission notice shall be included ++// in all copies or substantial portions of the Software. ++// ++// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ++// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ++// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN ++// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, ++// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR ++// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE ++// USE OR OTHER DEALINGS IN THE SOFTWARE. + +- /** +- `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same +- as the catch block of a try/catch statement. ++function EventEmitter() { ++ this._events = this._events || {}; ++ this._maxListeners = this._maxListeners || undefined; ++} ++module.exports = EventEmitter; + +- ```js +- function findAuthor(){ +- throw new Error('couldn't find that author'); +- } ++// Backwards-compat with node 0.10.x ++EventEmitter.EventEmitter = EventEmitter; + +- // synchronous +- try { +- findAuthor(); +- } catch(reason) { +- // something went wrong +- } ++EventEmitter.prototype._events = undefined; ++EventEmitter.prototype._maxListeners = undefined; + +- // async with promises +- findAuthor().catch(function(reason){ +- // something went wrong +- }); +- ``` +- +- @method catch +- @param {Function} onRejection +- Useful for tooling. +- @return {Promise} +- */ +- 'catch': function(onRejection) { +- return this.then(null, onRejection); +- } +- }; +- var lib$es6$promise$enumerator$$default = lib$es6$promise$enumerator$$Enumerator; +- function lib$es6$promise$enumerator$$Enumerator(Constructor, input) { +- this._instanceConstructor = Constructor; +- this.promise = new Constructor(lib$es6$promise$$internal$$noop); ++// By default EventEmitters will print a warning if more than 10 listeners are ++// added to it. This is a useful default which helps finding memory leaks. ++EventEmitter.defaultMaxListeners = 10; ++ ++// Obviously not all Emitters should be limited to 10. This function allows ++// that to be increased. Set to zero for unlimited. ++EventEmitter.prototype.setMaxListeners = function(n) { ++ if (!isNumber(n) || n < 0 || isNaN(n)) ++ throw TypeError('n must be a positive number'); ++ this._maxListeners = n; ++ return this; ++}; + +- if (Array.isArray(input)) { +- this._input = input; +- this.length = input.length; +- this._remaining = input.length; ++EventEmitter.prototype.emit = function(type) { ++ var er, handler, len, args, i, listeners; + +- this._result = new Array(this.length); ++ if (!this._events) ++ this._events = {}; + +- if (this.length === 0) { +- lib$es6$promise$$internal$$fulfill(this.promise, this._result); +- } else { +- this.length = this.length || 0; +- this._enumerate(); +- if (this._remaining === 0) { +- lib$es6$promise$$internal$$fulfill(this.promise, this._result); +- } +- } ++ // If there is no 'error' event listener then throw. ++ if (type === 'error') { ++ if (!this._events.error || ++ (isObject(this._events.error) && !this._events.error.length)) { ++ er = arguments[1]; ++ if (er instanceof Error) { ++ throw er; // Unhandled 'error' event + } else { +- lib$es6$promise$$internal$$reject(this.promise, this._validationError()); ++ // At least give some kind of context to the user ++ var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); ++ err.context = er; ++ throw err; + } + } ++ } + +- lib$es6$promise$enumerator$$Enumerator.prototype._validationError = function() { +- return new Error('Array Methods must be provided an Array'); +- }; ++ handler = this._events[type]; + +- lib$es6$promise$enumerator$$Enumerator.prototype._enumerate = function() { +- var length = this.length; +- var input = this._input; ++ if (isUndefined(handler)) ++ return false; + +- for (var i = 0; this._state === lib$es6$promise$$internal$$PENDING && i < length; i++) { +- this._eachEntry(input[i], i); +- } +- }; ++ if (isFunction(handler)) { ++ switch (arguments.length) { ++ // fast cases ++ case 1: ++ handler.call(this); ++ break; ++ case 2: ++ handler.call(this, arguments[1]); ++ break; ++ case 3: ++ handler.call(this, arguments[1], arguments[2]); ++ break; ++ // slower ++ default: ++ args = Array.prototype.slice.call(arguments, 1); ++ handler.apply(this, args); ++ } ++ } else if (isObject(handler)) { ++ args = Array.prototype.slice.call(arguments, 1); ++ listeners = handler.slice(); ++ len = listeners.length; ++ for (i = 0; i < len; i++) ++ listeners[i].apply(this, args); ++ } + +- lib$es6$promise$enumerator$$Enumerator.prototype._eachEntry = function(entry, i) { +- var c = this._instanceConstructor; +- var resolve = c.resolve; ++ return true; ++}; ++ ++EventEmitter.prototype.addListener = function(type, listener) { ++ var m; + +- if (resolve === lib$es6$promise$promise$resolve$$default) { +- var then = lib$es6$promise$$internal$$getThen(entry); ++ if (!isFunction(listener)) ++ throw TypeError('listener must be a function'); + +- if (then === lib$es6$promise$then$$default && +- entry._state !== lib$es6$promise$$internal$$PENDING) { +- this._settledAt(entry._state, i, entry._result); +- } else if (typeof then !== 'function') { +- this._remaining--; +- this._result[i] = entry; +- } else if (c === lib$es6$promise$promise$$default) { +- var promise = new c(lib$es6$promise$$internal$$noop); +- lib$es6$promise$$internal$$handleMaybeThenable(promise, entry, then); +- this._willSettleAt(promise, i); +- } else { +- this._willSettleAt(new c(function(resolve) { resolve(entry); }), i); +- } +- } else { +- this._willSettleAt(resolve(entry), i); +- } +- }; ++ if (!this._events) ++ this._events = {}; + +- lib$es6$promise$enumerator$$Enumerator.prototype._settledAt = function(state, i, value) { +- var promise = this.promise; ++ // To avoid recursion in the case that type === "newListener"! Before ++ // adding it to the listeners, first emit "newListener". ++ if (this._events.newListener) ++ this.emit('newListener', type, ++ isFunction(listener.listener) ? ++ listener.listener : listener); + +- if (promise._state === lib$es6$promise$$internal$$PENDING) { +- this._remaining--; ++ if (!this._events[type]) ++ // Optimize the case of one listener. Don't need the extra array object. ++ this._events[type] = listener; ++ else if (isObject(this._events[type])) ++ // If we've already got an array, just append. ++ this._events[type].push(listener); ++ else ++ // Adding the second element, need to change to array. ++ this._events[type] = [this._events[type], listener]; + +- if (state === lib$es6$promise$$internal$$REJECTED) { +- lib$es6$promise$$internal$$reject(promise, value); +- } else { +- this._result[i] = value; +- } +- } ++ // Check for listener leak ++ if (isObject(this._events[type]) && !this._events[type].warned) { ++ if (!isUndefined(this._maxListeners)) { ++ m = this._maxListeners; ++ } else { ++ m = EventEmitter.defaultMaxListeners; ++ } + +- if (this._remaining === 0) { +- lib$es6$promise$$internal$$fulfill(promise, this._result); ++ if (m && m > 0 && this._events[type].length > m) { ++ this._events[type].warned = true; ++ console.error('(node) warning: possible EventEmitter memory ' + ++ 'leak detected. %d listeners added. ' + ++ 'Use emitter.setMaxListeners() to increase limit.', ++ this._events[type].length); ++ if (typeof console.trace === 'function') { ++ // not supported in IE 10 ++ console.trace(); + } +- }; ++ } ++ } ++ ++ return this; ++}; + +- lib$es6$promise$enumerator$$Enumerator.prototype._willSettleAt = function(promise, i) { +- var enumerator = this; ++EventEmitter.prototype.on = EventEmitter.prototype.addListener; + +- lib$es6$promise$$internal$$subscribe(promise, undefined, function(value) { +- enumerator._settledAt(lib$es6$promise$$internal$$FULFILLED, i, value); +- }, function(reason) { +- enumerator._settledAt(lib$es6$promise$$internal$$REJECTED, i, reason); +- }); +- }; +- function lib$es6$promise$polyfill$$polyfill() { +- var local; ++EventEmitter.prototype.once = function(type, listener) { ++ if (!isFunction(listener)) ++ throw TypeError('listener must be a function'); + +- if (typeof global !== 'undefined') { +- local = global; +- } else if (typeof self !== 'undefined') { +- local = self; +- } else { +- try { +- local = Function('return this')(); +- } catch (e) { +- throw new Error('polyfill failed because global object is unavailable in this environment'); +- } +- } ++ var fired = false; + +- var P = local.Promise; ++ function g() { ++ this.removeListener(type, g); + +- if (P && Object.prototype.toString.call(P.resolve()) === '[object Promise]' && !P.cast) { +- return; ++ if (!fired) { ++ fired = true; ++ listener.apply(this, arguments); ++ } ++ } ++ ++ g.listener = listener; ++ this.on(type, g); ++ ++ return this; ++}; ++ ++// emits a 'removeListener' event iff the listener was removed ++EventEmitter.prototype.removeListener = function(type, listener) { ++ var list, position, length, i; ++ ++ if (!isFunction(listener)) ++ throw TypeError('listener must be a function'); ++ ++ if (!this._events || !this._events[type]) ++ return this; ++ ++ list = this._events[type]; ++ length = list.length; ++ position = -1; ++ ++ if (list === listener || ++ (isFunction(list.listener) && list.listener === listener)) { ++ delete this._events[type]; ++ if (this._events.removeListener) ++ this.emit('removeListener', type, listener); ++ ++ } else if (isObject(list)) { ++ for (i = length; i-- > 0;) { ++ if (list[i] === listener || ++ (list[i].listener && list[i].listener === listener)) { ++ position = i; ++ break; + } ++ } ++ ++ if (position < 0) ++ return this; + +- local.Promise = lib$es6$promise$promise$$default; ++ if (list.length === 1) { ++ list.length = 0; ++ delete this._events[type]; ++ } else { ++ list.splice(position, 1); + } +- var lib$es6$promise$polyfill$$default = lib$es6$promise$polyfill$$polyfill; + +- var lib$es6$promise$umd$$ES6Promise = { +- 'Promise': lib$es6$promise$promise$$default, +- 'polyfill': lib$es6$promise$polyfill$$default +- }; ++ if (this._events.removeListener) ++ this.emit('removeListener', type, listener); ++ } ++ ++ return this; ++}; ++ ++EventEmitter.prototype.removeAllListeners = function(type) { ++ var key, listeners; ++ ++ if (!this._events) ++ return this; ++ ++ // not listening for removeListener, no need to emit ++ if (!this._events.removeListener) { ++ if (arguments.length === 0) ++ this._events = {}; ++ else if (this._events[type]) ++ delete this._events[type]; ++ return this; ++ } + +- /* global define:true module:true window: true */ +- if (typeof define === 'function' && define['amd']) { +- define(function() { return lib$es6$promise$umd$$ES6Promise; }); +- } else if (typeof module !== 'undefined' && module['exports']) { +- module['exports'] = lib$es6$promise$umd$$ES6Promise; +- } else if (typeof this !== 'undefined') { +- this['ES6Promise'] = lib$es6$promise$umd$$ES6Promise; ++ // emit removeListener for all listeners on all events ++ if (arguments.length === 0) { ++ for (key in this._events) { ++ if (key === 'removeListener') continue; ++ this.removeAllListeners(key); + } ++ this.removeAllListeners('removeListener'); ++ this._events = {}; ++ return this; ++ } + +- lib$es6$promise$polyfill$$default(); +-}).call(this); ++ listeners = this._events[type]; ++ ++ if (isFunction(listeners)) { ++ this.removeListener(type, listeners); ++ } else if (listeners) { ++ // LIFO order ++ while (listeners.length) ++ this.removeListener(type, listeners[listeners.length - 1]); ++ } ++ delete this._events[type]; + ++ return this; ++}; + +-}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +-},{"_process":8}],12:[function(require,module,exports){ ++EventEmitter.prototype.listeners = function(type) { ++ var ret; ++ if (!this._events || !this._events[type]) ++ ret = []; ++ else if (isFunction(this._events[type])) ++ ret = [this._events[type]]; ++ else ++ ret = this._events[type].slice(); ++ return ret; ++}; ++ ++EventEmitter.prototype.listenerCount = function(type) { ++ if (this._events) { ++ var evlistener = this._events[type]; ++ ++ if (isFunction(evlistener)) ++ return 1; ++ else if (evlistener) ++ return evlistener.length; ++ } ++ return 0; ++}; ++ ++EventEmitter.listenerCount = function(emitter, type) { ++ return emitter.listenerCount(type); ++}; ++ ++function isFunction(arg) { ++ return typeof arg === 'function'; ++} ++ ++function isNumber(arg) { ++ return typeof arg === 'number'; ++} ++ ++function isObject(arg) { ++ return typeof arg === 'object' && arg !== null; ++} ++ ++function isUndefined(arg) { ++ return arg === void 0; ++} ++ ++},{}],11:[function(require,module,exports){ + /** + * inspired by is-number + * but significantly simplified and sped up by ignoring number and string constructors +@@ -11463,7 +11573,7 @@ module.exports = function(n) { + return n - n < 1; + }; + +-},{}],13:[function(require,module,exports){ ++},{}],12:[function(require,module,exports){ + module.exports = fromQuat; + + /** +@@ -11511,21 +11621,202 @@ function fromQuat(out, q) { + + return out; + }; ++},{}],13:[function(require,module,exports){ ++// shim for using process in browser ++var process = module.exports = {}; ++ ++// cached from whatever global is present so that test runners that stub it ++// don't break things. But we need to wrap it in a try catch in case it is ++// wrapped in strict mode code which doesn't define any globals. It's inside a ++// function because try/catches deoptimize in certain engines. ++ ++var cachedSetTimeout; ++var cachedClearTimeout; ++ ++function defaultSetTimout() { ++ throw new Error('setTimeout has not been defined'); ++} ++function defaultClearTimeout () { ++ throw new Error('clearTimeout has not been defined'); ++} ++(function () { ++ try { ++ if (typeof setTimeout === 'function') { ++ cachedSetTimeout = setTimeout; ++ } else { ++ cachedSetTimeout = defaultSetTimout; ++ } ++ } catch (e) { ++ cachedSetTimeout = defaultSetTimout; ++ } ++ try { ++ if (typeof clearTimeout === 'function') { ++ cachedClearTimeout = clearTimeout; ++ } else { ++ cachedClearTimeout = defaultClearTimeout; ++ } ++ } catch (e) { ++ cachedClearTimeout = defaultClearTimeout; ++ } ++} ()) ++function runTimeout(fun) { ++ if (cachedSetTimeout === setTimeout) { ++ //normal enviroments in sane situations ++ return setTimeout(fun, 0); ++ } ++ // if setTimeout wasn't available but was latter defined ++ if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { ++ cachedSetTimeout = setTimeout; ++ return setTimeout(fun, 0); ++ } ++ try { ++ // when when somebody has screwed with setTimeout but no I.E. maddness ++ return cachedSetTimeout(fun, 0); ++ } catch(e){ ++ try { ++ // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally ++ return cachedSetTimeout.call(null, fun, 0); ++ } catch(e){ ++ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error ++ return cachedSetTimeout.call(this, fun, 0); ++ } ++ } ++ ++ ++} ++function runClearTimeout(marker) { ++ if (cachedClearTimeout === clearTimeout) { ++ //normal enviroments in sane situations ++ return clearTimeout(marker); ++ } ++ // if clearTimeout wasn't available but was latter defined ++ if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { ++ cachedClearTimeout = clearTimeout; ++ return clearTimeout(marker); ++ } ++ try { ++ // when when somebody has screwed with setTimeout but no I.E. maddness ++ return cachedClearTimeout(marker); ++ } catch (e){ ++ try { ++ // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally ++ return cachedClearTimeout.call(null, marker); ++ } catch (e){ ++ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. ++ // Some versions of I.E. have different rules for clearTimeout vs setTimeout ++ return cachedClearTimeout.call(this, marker); ++ } ++ } ++ ++ ++ ++} ++var queue = []; ++var draining = false; ++var currentQueue; ++var queueIndex = -1; ++ ++function cleanUpNextTick() { ++ if (!draining || !currentQueue) { ++ return; ++ } ++ draining = false; ++ if (currentQueue.length) { ++ queue = currentQueue.concat(queue); ++ } else { ++ queueIndex = -1; ++ } ++ if (queue.length) { ++ drainQueue(); ++ } ++} ++ ++function drainQueue() { ++ if (draining) { ++ return; ++ } ++ var timeout = runTimeout(cleanUpNextTick); ++ draining = true; ++ ++ var len = queue.length; ++ while(len) { ++ currentQueue = queue; ++ queue = []; ++ while (++queueIndex < len) { ++ if (currentQueue) { ++ currentQueue[queueIndex].run(); ++ } ++ } ++ queueIndex = -1; ++ len = queue.length; ++ } ++ currentQueue = null; ++ draining = false; ++ runClearTimeout(timeout); ++} ++ ++process.nextTick = function (fun) { ++ var args = new Array(arguments.length - 1); ++ if (arguments.length > 1) { ++ for (var i = 1; i < arguments.length; i++) { ++ args[i - 1] = arguments[i]; ++ } ++ } ++ queue.push(new Item(fun, args)); ++ if (queue.length === 1 && !draining) { ++ runTimeout(drainQueue); ++ } ++}; ++ ++// v8 likes predictible objects ++function Item(fun, array) { ++ this.fun = fun; ++ this.array = array; ++} ++Item.prototype.run = function () { ++ this.fun.apply(null, this.array); ++}; ++process.title = 'browser'; ++process.browser = true; ++process.env = {}; ++process.argv = []; ++process.version = ''; // empty string to avoid regexp issues ++process.versions = {}; ++ ++function noop() {} ++ ++process.on = noop; ++process.addListener = noop; ++process.once = noop; ++process.off = noop; ++process.removeListener = noop; ++process.removeAllListeners = noop; ++process.emit = noop; ++ ++process.binding = function (name) { ++ throw new Error('process.binding is not supported'); ++}; ++ ++process.cwd = function () { return '/' }; ++process.chdir = function (dir) { ++ throw new Error('process.chdir is not supported'); ++}; ++process.umask = function() { return 0; }; ++ + },{}],14:[function(require,module,exports){ +-// TinyColor v1.3.0 ++// TinyColor v1.4.1 + // https://github.com/bgrins/TinyColor + // Brian Grinstead, MIT License + +-(function() { ++(function(Math) { + + var trimLeft = /^\s+/, + trimRight = /\s+$/, + tinyCounter = 0, +- math = Math, +- mathRound = math.round, +- mathMin = math.min, +- mathMax = math.max, +- mathRandom = math.random; ++ mathRound = Math.round, ++ mathMin = Math.min, ++ mathMax = Math.max, ++ mathRandom = Math.random; + + function tinycolor (color, opts) { + +@@ -11633,11 +11924,11 @@ tinycolor.prototype = { + toHexString: function(allow3Char) { + return '#' + this.toHex(allow3Char); + }, +- toHex8: function() { +- return rgbaToHex(this._r, this._g, this._b, this._a); ++ toHex8: function(allow4Char) { ++ return rgbaToHex(this._r, this._g, this._b, this._a, allow4Char); + }, +- toHex8String: function() { +- return '#' + this.toHex8(); ++ toHex8String: function(allow4Char) { ++ return '#' + this.toHex8(allow4Char); + }, + toRgb: function() { + return { r: mathRound(this._r), g: mathRound(this._g), b: mathRound(this._b), a: this._a }; +@@ -11667,13 +11958,13 @@ tinycolor.prototype = { + return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false; + }, + toFilter: function(secondColor) { +- var hex8String = '#' + rgbaToHex(this._r, this._g, this._b, this._a); ++ var hex8String = '#' + rgbaToArgbHex(this._r, this._g, this._b, this._a); + var secondHex8String = hex8String; + var gradientType = this._gradientType ? "GradientType = 1, " : ""; + + if (secondColor) { + var s = tinycolor(secondColor); +- secondHex8String = s.toHex8String(); ++ secondHex8String = '#' + rgbaToArgbHex(s._r, s._g, s._b, s._a); + } + + return "progid:DXImageTransform.Microsoft.gradient("+gradientType+"startColorstr="+hex8String+",endColorstr="+secondHex8String+")"; +@@ -11684,7 +11975,7 @@ tinycolor.prototype = { + + var formattedString = false; + var hasAlpha = this._a < 1 && this._a >= 0; +- var needsAlphaFormat = !formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "name"); ++ var needsAlphaFormat = !formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "hex4" || format === "hex8" || format === "name"); + + if (needsAlphaFormat) { + // Special case for "transparent", all other non-alpha formats +@@ -11706,6 +11997,9 @@ tinycolor.prototype = { + if (format === "hex3") { + formattedString = this.toHexString(true); + } ++ if (format === "hex4") { ++ formattedString = this.toHex8String(true); ++ } + if (format === "hex8") { + formattedString = this.toHex8String(); + } +@@ -11818,6 +12112,9 @@ function inputToRGB(color) { + + var rgb = { r: 0, g: 0, b: 0 }; + var a = 1; ++ var s = null; ++ var v = null; ++ var l = null; + var ok = false; + var format = false; + +@@ -11826,22 +12123,22 @@ function inputToRGB(color) { + } + + if (typeof color == "object") { +- if (color.hasOwnProperty("r") && color.hasOwnProperty("g") && color.hasOwnProperty("b")) { ++ if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) { + rgb = rgbToRgb(color.r, color.g, color.b); + ok = true; + format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb"; + } +- else if (color.hasOwnProperty("h") && color.hasOwnProperty("s") && color.hasOwnProperty("v")) { +- color.s = convertToPercentage(color.s); +- color.v = convertToPercentage(color.v); +- rgb = hsvToRgb(color.h, color.s, color.v); ++ else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) { ++ s = convertToPercentage(color.s); ++ v = convertToPercentage(color.v); ++ rgb = hsvToRgb(color.h, s, v); + ok = true; + format = "hsv"; + } +- else if (color.hasOwnProperty("h") && color.hasOwnProperty("s") && color.hasOwnProperty("l")) { +- color.s = convertToPercentage(color.s); +- color.l = convertToPercentage(color.l); +- rgb = hslToRgb(color.h, color.s, color.l); ++ else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) { ++ s = convertToPercentage(color.s); ++ l = convertToPercentage(color.l); ++ rgb = hslToRgb(color.h, s, l); + ok = true; + format = "hsl"; + } +@@ -11988,7 +12285,7 @@ function rgbToHsv(r, g, b) { + s = bound01(s, 100); + v = bound01(v, 100); + +- var i = math.floor(h), ++ var i = Math.floor(h), + f = h - i, + p = v * (1 - s), + q = v * (1 - f * s), +@@ -12023,9 +12320,29 @@ function rgbToHex(r, g, b, allow3Char) { + + // `rgbaToHex` + // Converts an RGBA color plus alpha transparency to hex +-// Assumes r, g, b and a are contained in the set [0, 255] +-// Returns an 8 character hex +-function rgbaToHex(r, g, b, a) { ++// Assumes r, g, b are contained in the set [0, 255] and ++// a in [0, 1]. Returns a 4 or 8 character rgba hex ++function rgbaToHex(r, g, b, a, allow4Char) { ++ ++ var hex = [ ++ pad2(mathRound(r).toString(16)), ++ pad2(mathRound(g).toString(16)), ++ pad2(mathRound(b).toString(16)), ++ pad2(convertDecimalToHex(a)) ++ ]; ++ ++ // Return a 4 character hex if possible ++ if (allow4Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1) && hex[3].charAt(0) == hex[3].charAt(1)) { ++ return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0); ++ } ++ ++ return hex.join(""); ++} ++ ++// `rgbaToArgbHex` ++// Converts an RGBA color to an ARGB Hex8 string ++// Rarely used, but required for "toFilter()" ++function rgbaToArgbHex(r, g, b, a) { + + var hex = [ + pad2(convertDecimalToHex(a)), +@@ -12107,7 +12424,7 @@ function darken (color, amount) { + // Values outside of this range will be wrapped into this range. + function spin(color, amount) { + var hsl = tinycolor(color).toHsl(); +- var hue = (mathRound(hsl.h) + amount) % 360; ++ var hue = (hsl.h + amount) % 360; + hsl.h = hue < 0 ? 360 + hue : hue; + return tinycolor(hsl); + } +@@ -12194,26 +12511,12 @@ tinycolor.mix = function(color1, color2, amount) { + var rgb2 = tinycolor(color2).toRgb(); + + var p = amount / 100; +- var w = p * 2 - 1; +- var a = rgb2.a - rgb1.a; +- +- var w1; +- +- if (w * a == -1) { +- w1 = w; +- } else { +- w1 = (w + a) / (1 + w * a); +- } +- +- w1 = (w1 + 1) / 2; +- +- var w2 = 1 - w1; + + var rgba = { +- r: rgb2.r * w1 + rgb1.r * w2, +- g: rgb2.g * w1 + rgb1.g * w2, +- b: rgb2.b * w1 + rgb1.b * w2, +- a: rgb2.a * p + rgb1.a * (1 - p) ++ r: ((rgb2.r - rgb1.r) * p) + rgb1.r, ++ g: ((rgb2.g - rgb1.g) * p) + rgb1.g, ++ b: ((rgb2.b - rgb1.b) * p) + rgb1.b, ++ a: ((rgb2.a - rgb1.a) * p) + rgb1.a + }; + + return tinycolor(rgba); +@@ -12499,7 +12802,7 @@ function bound01(n, max) { + } + + // Handle floating point rounding errors +- if ((math.abs(n - max) < 0.000001)) { ++ if ((Math.abs(n - max) < 0.000001)) { + return 1; + } + +@@ -12569,6 +12872,7 @@ var matchers = (function() { + var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?"; + + return { ++ CSS_UNIT: new RegExp(CSS_UNIT), + rgb: new RegExp("rgb" + PERMISSIVE_MATCH3), + rgba: new RegExp("rgba" + PERMISSIVE_MATCH4), + hsl: new RegExp("hsl" + PERMISSIVE_MATCH3), +@@ -12577,10 +12881,18 @@ var matchers = (function() { + hsva: new RegExp("hsva" + PERMISSIVE_MATCH4), + hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/, + hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/, ++ hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/, + hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/ + }; + })(); + ++// `isValidCSSUnit` ++// Take in a single string / number and check to see if it looks like a CSS unit ++// (see `matchers` above for definition). ++function isValidCSSUnit(color) { ++ return !!matchers.CSS_UNIT.exec(color); ++} ++ + // `stringInputToObject` + // Permissive string parsing. Take in a number of formats, and output an object + // based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}` +@@ -12621,10 +12933,10 @@ function stringInputToObject(color) { + } + if ((match = matchers.hex8.exec(color))) { + return { +- a: convertHexToDecimal(match[1]), +- r: parseIntFromHex(match[2]), +- g: parseIntFromHex(match[3]), +- b: parseIntFromHex(match[4]), ++ r: parseIntFromHex(match[1]), ++ g: parseIntFromHex(match[2]), ++ b: parseIntFromHex(match[3]), ++ a: convertHexToDecimal(match[4]), + format: named ? "name" : "hex8" + }; + } +@@ -12636,6 +12948,15 @@ function stringInputToObject(color) { + format: named ? "name" : "hex" + }; + } ++ if ((match = matchers.hex4.exec(color))) { ++ return { ++ r: parseIntFromHex(match[1] + '' + match[1]), ++ g: parseIntFromHex(match[2] + '' + match[2]), ++ b: parseIntFromHex(match[3] + '' + match[3]), ++ a: convertHexToDecimal(match[4] + '' + match[4]), ++ format: named ? "name" : "hex8" ++ }; ++ } + if ((match = matchers.hex3.exec(color))) { + return { + r: parseIntFromHex(match[1] + '' + match[1]), +@@ -12677,557 +12998,556 @@ else { + window.tinycolor = tinycolor; + } + +-})(); ++})(Math); + + },{}],15:[function(require,module,exports){ + (function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : +- (factory((global.topojson = {}))); +-}(this, function (exports) { 'use strict'; ++ (factory((global.topojson = global.topojson || {}))); ++}(this, (function (exports) { 'use strict'; + +- function noop() {} ++function noop() {} + +- function absolute(transform) { +- if (!transform) return noop; +- var x0, +- y0, +- kx = transform.scale[0], +- ky = transform.scale[1], +- dx = transform.translate[0], +- dy = transform.translate[1]; +- return function(point, i) { +- if (!i) x0 = y0 = 0; +- point[0] = (x0 += point[0]) * kx + dx; +- point[1] = (y0 += point[1]) * ky + dy; +- }; +- } ++function transformAbsolute(transform) { ++ if (!transform) return noop; ++ var x0, ++ y0, ++ kx = transform.scale[0], ++ ky = transform.scale[1], ++ dx = transform.translate[0], ++ dy = transform.translate[1]; ++ return function(point, i) { ++ if (!i) x0 = y0 = 0; ++ point[0] = (x0 += point[0]) * kx + dx; ++ point[1] = (y0 += point[1]) * ky + dy; ++ }; ++} + +- function relative(transform) { +- if (!transform) return noop; +- var x0, +- y0, +- kx = transform.scale[0], +- ky = transform.scale[1], +- dx = transform.translate[0], +- dy = transform.translate[1]; +- return function(point, i) { +- if (!i) x0 = y0 = 0; +- var x1 = (point[0] - dx) / kx | 0, +- y1 = (point[1] - dy) / ky | 0; +- point[0] = x1 - x0; +- point[1] = y1 - y0; +- x0 = x1; +- y0 = y1; +- }; +- } ++function transformRelative(transform) { ++ if (!transform) return noop; ++ var x0, ++ y0, ++ kx = transform.scale[0], ++ ky = transform.scale[1], ++ dx = transform.translate[0], ++ dy = transform.translate[1]; ++ return function(point, i) { ++ if (!i) x0 = y0 = 0; ++ var x1 = Math.round((point[0] - dx) / kx), ++ y1 = Math.round((point[1] - dy) / ky); ++ point[0] = x1 - x0; ++ point[1] = y1 - y0; ++ x0 = x1; ++ y0 = y1; ++ }; ++} ++ ++function reverse(array, n) { ++ var t, j = array.length, i = j - n; ++ while (i < --j) t = array[i], array[i++] = array[j], array[j] = t; ++} + +- function reverse(array, n) { +- var t, j = array.length, i = j - n; +- while (i < --j) t = array[i], array[i++] = array[j], array[j] = t; ++function bisect(a, x) { ++ var lo = 0, hi = a.length; ++ while (lo < hi) { ++ var mid = lo + hi >>> 1; ++ if (a[mid] < x) lo = mid + 1; ++ else hi = mid; + } ++ return lo; ++} ++ ++function feature(topology, o) { ++ return o.type === "GeometryCollection" ? { ++ type: "FeatureCollection", ++ features: o.geometries.map(function(o) { return feature$1(topology, o); }) ++ } : feature$1(topology, o); ++} + +- function bisect(a, x) { +- var lo = 0, hi = a.length; +- while (lo < hi) { +- var mid = lo + hi >>> 1; +- if (a[mid] < x) lo = mid + 1; +- else hi = mid; ++function feature$1(topology, o) { ++ var f = { ++ type: "Feature", ++ id: o.id, ++ properties: o.properties || {}, ++ geometry: object(topology, o) ++ }; ++ if (o.id == null) delete f.id; ++ return f; ++} ++ ++function object(topology, o) { ++ var absolute = transformAbsolute(topology.transform), ++ arcs = topology.arcs; ++ ++ function arc(i, points) { ++ if (points.length) points.pop(); ++ for (var a = arcs[i < 0 ? ~i : i], k = 0, n = a.length, p; k < n; ++k) { ++ points.push(p = a[k].slice()); ++ absolute(p, k); + } +- return lo; ++ if (i < 0) reverse(points, n); ++ } ++ ++ function point(p) { ++ p = p.slice(); ++ absolute(p, 0); ++ return p; + } + +- function feature(topology, o) { +- return o.type === "GeometryCollection" ? { +- type: "FeatureCollection", +- features: o.geometries.map(function(o) { return feature$1(topology, o); }) +- } : feature$1(topology, o); ++ function line(arcs) { ++ var points = []; ++ for (var i = 0, n = arcs.length; i < n; ++i) arc(arcs[i], points); ++ if (points.length < 2) points.push(points[0].slice()); ++ return points; + } + +- function feature$1(topology, o) { +- var f = { +- type: "Feature", +- id: o.id, +- properties: o.properties || {}, +- geometry: object(topology, o) +- }; +- if (o.id == null) delete f.id; +- return f; ++ function ring(arcs) { ++ var points = line(arcs); ++ while (points.length < 4) points.push(points[0].slice()); ++ return points; + } + +- function object(topology, o) { +- var absolute$$ = absolute(topology.transform), +- arcs = topology.arcs; ++ function polygon(arcs) { ++ return arcs.map(ring); ++ } + +- function arc(i, points) { +- if (points.length) points.pop(); +- for (var a = arcs[i < 0 ? ~i : i], k = 0, n = a.length, p; k < n; ++k) { +- points.push(p = a[k].slice()); +- absolute$$(p, k); +- } +- if (i < 0) reverse(points, n); +- } ++ function geometry(o) { ++ var t = o.type; ++ return t === "GeometryCollection" ? {type: t, geometries: o.geometries.map(geometry)} ++ : t in geometryType ? {type: t, coordinates: geometryType[t](o)} ++ : null; ++ } + +- function point(p) { +- p = p.slice(); +- absolute$$(p, 0); +- return p; +- } ++ var geometryType = { ++ Point: function(o) { return point(o.coordinates); }, ++ MultiPoint: function(o) { return o.coordinates.map(point); }, ++ LineString: function(o) { return line(o.arcs); }, ++ MultiLineString: function(o) { return o.arcs.map(line); }, ++ Polygon: function(o) { return polygon(o.arcs); }, ++ MultiPolygon: function(o) { return o.arcs.map(polygon); } ++ }; + +- function line(arcs) { +- var points = []; +- for (var i = 0, n = arcs.length; i < n; ++i) arc(arcs[i], points); +- if (points.length < 2) points.push(points[0].slice()); +- return points; +- } ++ return geometry(o); ++} + +- function ring(arcs) { +- var points = line(arcs); +- while (points.length < 4) points.push(points[0].slice()); +- return points; +- } ++function stitchArcs(topology, arcs) { ++ var stitchedArcs = {}, ++ fragmentByStart = {}, ++ fragmentByEnd = {}, ++ fragments = [], ++ emptyIndex = -1; + +- function polygon(arcs) { +- return arcs.map(ring); ++ // Stitch empty arcs first, since they may be subsumed by other arcs. ++ arcs.forEach(function(i, j) { ++ var arc = topology.arcs[i < 0 ? ~i : i], t; ++ if (arc.length < 3 && !arc[1][0] && !arc[1][1]) { ++ t = arcs[++emptyIndex], arcs[emptyIndex] = i, arcs[j] = t; + } ++ }); + +- function geometry(o) { +- var t = o.type; +- return t === "GeometryCollection" ? {type: t, geometries: o.geometries.map(geometry)} +- : t in geometryType ? {type: t, coordinates: geometryType[t](o)} +- : null; ++ arcs.forEach(function(i) { ++ var e = ends(i), ++ start = e[0], ++ end = e[1], ++ f, g; ++ ++ if (f = fragmentByEnd[start]) { ++ delete fragmentByEnd[f.end]; ++ f.push(i); ++ f.end = end; ++ if (g = fragmentByStart[end]) { ++ delete fragmentByStart[g.start]; ++ var fg = g === f ? f : f.concat(g); ++ fragmentByStart[fg.start = f.start] = fragmentByEnd[fg.end = g.end] = fg; ++ } else { ++ fragmentByStart[f.start] = fragmentByEnd[f.end] = f; ++ } ++ } else if (f = fragmentByStart[end]) { ++ delete fragmentByStart[f.start]; ++ f.unshift(i); ++ f.start = start; ++ if (g = fragmentByEnd[start]) { ++ delete fragmentByEnd[g.end]; ++ var gf = g === f ? f : g.concat(f); ++ fragmentByStart[gf.start = g.start] = fragmentByEnd[gf.end = f.end] = gf; ++ } else { ++ fragmentByStart[f.start] = fragmentByEnd[f.end] = f; ++ } ++ } else { ++ f = [i]; ++ fragmentByStart[f.start = start] = fragmentByEnd[f.end = end] = f; + } ++ }); + +- var geometryType = { +- Point: function(o) { return point(o.coordinates); }, +- MultiPoint: function(o) { return o.coordinates.map(point); }, +- LineString: function(o) { return line(o.arcs); }, +- MultiLineString: function(o) { return o.arcs.map(line); }, +- Polygon: function(o) { return polygon(o.arcs); }, +- MultiPolygon: function(o) { return o.arcs.map(polygon); } +- }; +- +- return geometry(o); ++ function ends(i) { ++ var arc = topology.arcs[i < 0 ? ~i : i], p0 = arc[0], p1; ++ if (topology.transform) p1 = [0, 0], arc.forEach(function(dp) { p1[0] += dp[0], p1[1] += dp[1]; }); ++ else p1 = arc[arc.length - 1]; ++ return i < 0 ? [p1, p0] : [p0, p1]; + } + +- function stitchArcs(topology, arcs) { +- var stitchedArcs = {}, +- fragmentByStart = {}, +- fragmentByEnd = {}, +- fragments = [], +- emptyIndex = -1; ++ function flush(fragmentByEnd, fragmentByStart) { ++ for (var k in fragmentByEnd) { ++ var f = fragmentByEnd[k]; ++ delete fragmentByStart[f.start]; ++ delete f.start; ++ delete f.end; ++ f.forEach(function(i) { stitchedArcs[i < 0 ? ~i : i] = 1; }); ++ fragments.push(f); ++ } ++ } + +- // Stitch empty arcs first, since they may be subsumed by other arcs. +- arcs.forEach(function(i, j) { +- var arc = topology.arcs[i < 0 ? ~i : i], t; +- if (arc.length < 3 && !arc[1][0] && !arc[1][1]) { +- t = arcs[++emptyIndex], arcs[emptyIndex] = i, arcs[j] = t; +- } +- }); ++ flush(fragmentByEnd, fragmentByStart); ++ flush(fragmentByStart, fragmentByEnd); ++ arcs.forEach(function(i) { if (!stitchedArcs[i < 0 ? ~i : i]) fragments.push([i]); }); + +- arcs.forEach(function(i) { +- var e = ends(i), +- start = e[0], +- end = e[1], +- f, g; +- +- if (f = fragmentByEnd[start]) { +- delete fragmentByEnd[f.end]; +- f.push(i); +- f.end = end; +- if (g = fragmentByStart[end]) { +- delete fragmentByStart[g.start]; +- var fg = g === f ? f : f.concat(g); +- fragmentByStart[fg.start = f.start] = fragmentByEnd[fg.end = g.end] = fg; +- } else { +- fragmentByStart[f.start] = fragmentByEnd[f.end] = f; +- } +- } else if (f = fragmentByStart[end]) { +- delete fragmentByStart[f.start]; +- f.unshift(i); +- f.start = start; +- if (g = fragmentByEnd[start]) { +- delete fragmentByEnd[g.end]; +- var gf = g === f ? f : g.concat(f); +- fragmentByStart[gf.start = g.start] = fragmentByEnd[gf.end = f.end] = gf; +- } else { +- fragmentByStart[f.start] = fragmentByEnd[f.end] = f; +- } +- } else { +- f = [i]; +- fragmentByStart[f.start = start] = fragmentByEnd[f.end = end] = f; +- } +- }); ++ return fragments; ++} + +- function ends(i) { +- var arc = topology.arcs[i < 0 ? ~i : i], p0 = arc[0], p1; +- if (topology.transform) p1 = [0, 0], arc.forEach(function(dp) { p1[0] += dp[0], p1[1] += dp[1]; }); +- else p1 = arc[arc.length - 1]; +- return i < 0 ? [p1, p0] : [p0, p1]; +- } +- +- function flush(fragmentByEnd, fragmentByStart) { +- for (var k in fragmentByEnd) { +- var f = fragmentByEnd[k]; +- delete fragmentByStart[f.start]; +- delete f.start; +- delete f.end; +- f.forEach(function(i) { stitchedArcs[i < 0 ? ~i : i] = 1; }); +- fragments.push(f); +- } +- } ++function mesh(topology) { ++ return object(topology, meshArcs.apply(this, arguments)); ++} + +- flush(fragmentByEnd, fragmentByStart); +- flush(fragmentByStart, fragmentByEnd); +- arcs.forEach(function(i) { if (!stitchedArcs[i < 0 ? ~i : i]) fragments.push([i]); }); ++function meshArcs(topology, o, filter) { ++ var arcs = []; + +- return fragments; ++ function arc(i) { ++ var j = i < 0 ? ~i : i; ++ (geomsByArc[j] || (geomsByArc[j] = [])).push({i: i, g: geom}); + } + +- function mesh(topology) { +- return object(topology, meshArcs.apply(this, arguments)); ++ function line(arcs) { ++ arcs.forEach(arc); + } + +- function meshArcs(topology, o, filter) { +- var arcs = []; +- +- function arc(i) { +- var j = i < 0 ? ~i : i; +- (geomsByArc[j] || (geomsByArc[j] = [])).push({i: i, g: geom}); +- } +- +- function line(arcs) { +- arcs.forEach(arc); +- } +- +- function polygon(arcs) { +- arcs.forEach(line); +- } ++ function polygon(arcs) { ++ arcs.forEach(line); ++ } + +- function geometry(o) { +- if (o.type === "GeometryCollection") o.geometries.forEach(geometry); +- else if (o.type in geometryType) geom = o, geometryType[o.type](o.arcs); +- } ++ function geometry(o) { ++ if (o.type === "GeometryCollection") o.geometries.forEach(geometry); ++ else if (o.type in geometryType) geom = o, geometryType[o.type](o.arcs); ++ } + +- if (arguments.length > 1) { +- var geomsByArc = [], +- geom; +- +- var geometryType = { +- LineString: line, +- MultiLineString: polygon, +- Polygon: polygon, +- MultiPolygon: function(arcs) { arcs.forEach(polygon); } +- }; ++ if (arguments.length > 1) { ++ var geomsByArc = [], ++ geom; + +- geometry(o); ++ var geometryType = { ++ LineString: line, ++ MultiLineString: polygon, ++ Polygon: polygon, ++ MultiPolygon: function(arcs) { arcs.forEach(polygon); } ++ }; + +- geomsByArc.forEach(arguments.length < 3 +- ? function(geoms) { arcs.push(geoms[0].i); } +- : function(geoms) { if (filter(geoms[0].g, geoms[geoms.length - 1].g)) arcs.push(geoms[0].i); }); +- } else { +- for (var i = 0, n = topology.arcs.length; i < n; ++i) arcs.push(i); +- } ++ geometry(o); + +- return {type: "MultiLineString", arcs: stitchArcs(topology, arcs)}; ++ geomsByArc.forEach(arguments.length < 3 ++ ? function(geoms) { arcs.push(geoms[0].i); } ++ : function(geoms) { if (filter(geoms[0].g, geoms[geoms.length - 1].g)) arcs.push(geoms[0].i); }); ++ } else { ++ for (var i = 0, n = topology.arcs.length; i < n; ++i) arcs.push(i); + } + +- function triangle(triangle) { +- var a = triangle[0], b = triangle[1], c = triangle[2]; +- return Math.abs((a[0] - c[0]) * (b[1] - a[1]) - (a[0] - b[0]) * (c[1] - a[1])); +- } ++ return {type: "MultiLineString", arcs: stitchArcs(topology, arcs)}; ++} + +- function ring(ring) { +- var i = -1, +- n = ring.length, +- a, +- b = ring[n - 1], +- area = 0; ++function cartesianTriangleArea(triangle) { ++ var a = triangle[0], b = triangle[1], c = triangle[2]; ++ return Math.abs((a[0] - c[0]) * (b[1] - a[1]) - (a[0] - b[0]) * (c[1] - a[1])); ++} + +- while (++i < n) { +- a = b; +- b = ring[i]; +- area += a[0] * b[1] - a[1] * b[0]; +- } ++function ring(ring) { ++ var i = -1, ++ n = ring.length, ++ a, ++ b = ring[n - 1], ++ area = 0; + +- return area / 2; ++ while (++i < n) { ++ a = b; ++ b = ring[i]; ++ area += a[0] * b[1] - a[1] * b[0]; + } + +- function merge(topology) { +- return object(topology, mergeArcs.apply(this, arguments)); +- } ++ return area / 2; ++} + +- function mergeArcs(topology, objects) { +- var polygonsByArc = {}, +- polygons = [], +- components = []; ++function merge(topology) { ++ return object(topology, mergeArcs.apply(this, arguments)); ++} + +- objects.forEach(function(o) { +- if (o.type === "Polygon") register(o.arcs); +- else if (o.type === "MultiPolygon") o.arcs.forEach(register); +- }); ++function mergeArcs(topology, objects) { ++ var polygonsByArc = {}, ++ polygons = [], ++ components = []; + +- function register(polygon) { +- polygon.forEach(function(ring$$) { +- ring$$.forEach(function(arc) { +- (polygonsByArc[arc = arc < 0 ? ~arc : arc] || (polygonsByArc[arc] = [])).push(polygon); +- }); ++ objects.forEach(function(o) { ++ if (o.type === "Polygon") register(o.arcs); ++ else if (o.type === "MultiPolygon") o.arcs.forEach(register); ++ }); ++ ++ function register(polygon) { ++ polygon.forEach(function(ring$$) { ++ ring$$.forEach(function(arc) { ++ (polygonsByArc[arc = arc < 0 ? ~arc : arc] || (polygonsByArc[arc] = [])).push(polygon); + }); +- polygons.push(polygon); +- } +- +- function exterior(ring$$) { +- return ring(object(topology, {type: "Polygon", arcs: [ring$$]}).coordinates[0]) > 0; // TODO allow spherical? +- } +- +- polygons.forEach(function(polygon) { +- if (!polygon._) { +- var component = [], +- neighbors = [polygon]; +- polygon._ = 1; +- components.push(component); +- while (polygon = neighbors.pop()) { +- component.push(polygon); +- polygon.forEach(function(ring$$) { +- ring$$.forEach(function(arc) { +- polygonsByArc[arc < 0 ? ~arc : arc].forEach(function(polygon) { +- if (!polygon._) { +- polygon._ = 1; +- neighbors.push(polygon); +- } +- }); ++ }); ++ polygons.push(polygon); ++ } ++ ++ function area(ring$$) { ++ return Math.abs(ring(object(topology, {type: "Polygon", arcs: [ring$$]}).coordinates[0])); ++ } ++ ++ polygons.forEach(function(polygon) { ++ if (!polygon._) { ++ var component = [], ++ neighbors = [polygon]; ++ polygon._ = 1; ++ components.push(component); ++ while (polygon = neighbors.pop()) { ++ component.push(polygon); ++ polygon.forEach(function(ring$$) { ++ ring$$.forEach(function(arc) { ++ polygonsByArc[arc < 0 ? ~arc : arc].forEach(function(polygon) { ++ if (!polygon._) { ++ polygon._ = 1; ++ neighbors.push(polygon); ++ } + }); + }); +- } ++ }); + } +- }); ++ } ++ }); + +- polygons.forEach(function(polygon) { +- delete polygon._; +- }); ++ polygons.forEach(function(polygon) { ++ delete polygon._; ++ }); + +- return { +- type: "MultiPolygon", +- arcs: components.map(function(polygons) { +- var arcs = [], n; +- +- // Extract the exterior (unique) arcs. +- polygons.forEach(function(polygon) { +- polygon.forEach(function(ring$$) { +- ring$$.forEach(function(arc) { +- if (polygonsByArc[arc < 0 ? ~arc : arc].length < 2) { +- arcs.push(arc); +- } +- }); ++ return { ++ type: "MultiPolygon", ++ arcs: components.map(function(polygons) { ++ var arcs = [], n; ++ ++ // Extract the exterior (unique) arcs. ++ polygons.forEach(function(polygon) { ++ polygon.forEach(function(ring$$) { ++ ring$$.forEach(function(arc) { ++ if (polygonsByArc[arc < 0 ? ~arc : arc].length < 2) { ++ arcs.push(arc); ++ } + }); + }); ++ }); + +- // Stitch the arcs into one or more rings. +- arcs = stitchArcs(topology, arcs); +- +- // If more than one ring is returned, +- // at most one of these rings can be the exterior; +- // this exterior ring has the same winding order +- // as any exterior ring in the original polygons. +- if ((n = arcs.length) > 1) { +- var sgn = exterior(polygons[0][0]); +- for (var i = 0, t; i < n; ++i) { +- if (sgn === exterior(arcs[i])) { +- t = arcs[0], arcs[0] = arcs[i], arcs[i] = t; +- break; +- } ++ // Stitch the arcs into one or more rings. ++ arcs = stitchArcs(topology, arcs); ++ ++ // If more than one ring is returned, ++ // at most one of these rings can be the exterior; ++ // choose the one with the greatest absolute area. ++ if ((n = arcs.length) > 1) { ++ for (var i = 1, k = area(arcs[0]), ki, t; i < n; ++i) { ++ if ((ki = area(arcs[i])) > k) { ++ t = arcs[0], arcs[0] = arcs[i], arcs[i] = t, k = ki; + } + } ++ } + +- return arcs; +- }) +- }; +- } ++ return arcs; ++ }) ++ }; ++} + +- function neighbors(objects) { +- var indexesByArc = {}, // arc index -> array of object indexes +- neighbors = objects.map(function() { return []; }); ++function neighbors(objects) { ++ var indexesByArc = {}, // arc index -> array of object indexes ++ neighbors = objects.map(function() { return []; }); + +- function line(arcs, i) { +- arcs.forEach(function(a) { +- if (a < 0) a = ~a; +- var o = indexesByArc[a]; +- if (o) o.push(i); +- else indexesByArc[a] = [i]; +- }); +- } ++ function line(arcs, i) { ++ arcs.forEach(function(a) { ++ if (a < 0) a = ~a; ++ var o = indexesByArc[a]; ++ if (o) o.push(i); ++ else indexesByArc[a] = [i]; ++ }); ++ } + +- function polygon(arcs, i) { +- arcs.forEach(function(arc) { line(arc, i); }); +- } ++ function polygon(arcs, i) { ++ arcs.forEach(function(arc) { line(arc, i); }); ++ } + +- function geometry(o, i) { +- if (o.type === "GeometryCollection") o.geometries.forEach(function(o) { geometry(o, i); }); +- else if (o.type in geometryType) geometryType[o.type](o.arcs, i); +- } ++ function geometry(o, i) { ++ if (o.type === "GeometryCollection") o.geometries.forEach(function(o) { geometry(o, i); }); ++ else if (o.type in geometryType) geometryType[o.type](o.arcs, i); ++ } + +- var geometryType = { +- LineString: line, +- MultiLineString: polygon, +- Polygon: polygon, +- MultiPolygon: function(arcs, i) { arcs.forEach(function(arc) { polygon(arc, i); }); } +- }; ++ var geometryType = { ++ LineString: line, ++ MultiLineString: polygon, ++ Polygon: polygon, ++ MultiPolygon: function(arcs, i) { arcs.forEach(function(arc) { polygon(arc, i); }); } ++ }; + +- objects.forEach(geometry); ++ objects.forEach(geometry); + +- for (var i in indexesByArc) { +- for (var indexes = indexesByArc[i], m = indexes.length, j = 0; j < m; ++j) { +- for (var k = j + 1; k < m; ++k) { +- var ij = indexes[j], ik = indexes[k], n; +- if ((n = neighbors[ij])[i = bisect(n, ik)] !== ik) n.splice(i, 0, ik); +- if ((n = neighbors[ik])[i = bisect(n, ij)] !== ij) n.splice(i, 0, ij); +- } ++ for (var i in indexesByArc) { ++ for (var indexes = indexesByArc[i], m = indexes.length, j = 0; j < m; ++j) { ++ for (var k = j + 1; k < m; ++k) { ++ var ij = indexes[j], ik = indexes[k], n; ++ if ((n = neighbors[ij])[i = bisect(n, ik)] !== ik) n.splice(i, 0, ik); ++ if ((n = neighbors[ik])[i = bisect(n, ij)] !== ij) n.splice(i, 0, ij); + } + } +- +- return neighbors; + } + +- function compareArea(a, b) { +- return a[1][2] - b[1][2]; +- } ++ return neighbors; ++} + +- function minAreaHeap() { +- var heap = {}, +- array = [], +- size = 0; ++function compareArea(a, b) { ++ return a[1][2] - b[1][2]; ++} + +- heap.push = function(object) { +- up(array[object._ = size] = object, size++); +- return size; +- }; ++function minAreaHeap() { ++ var heap = {}, ++ array = [], ++ size = 0; + +- heap.pop = function() { +- if (size <= 0) return; +- var removed = array[0], object; +- if (--size > 0) object = array[size], down(array[object._ = 0] = object, 0); +- return removed; +- }; ++ heap.push = function(object) { ++ up(array[object._ = size] = object, size++); ++ return size; ++ }; + +- heap.remove = function(removed) { +- var i = removed._, object; +- if (array[i] !== removed) return; // invalid request +- if (i !== --size) object = array[size], (compareArea(object, removed) < 0 ? up : down)(array[object._ = i] = object, i); +- return i; +- }; ++ heap.pop = function() { ++ if (size <= 0) return; ++ var removed = array[0], object; ++ if (--size > 0) object = array[size], down(array[object._ = 0] = object, 0); ++ return removed; ++ }; + +- function up(object, i) { +- while (i > 0) { +- var j = ((i + 1) >> 1) - 1, +- parent = array[j]; +- if (compareArea(object, parent) >= 0) break; +- array[parent._ = i] = parent; +- array[object._ = i = j] = object; +- } +- } ++ heap.remove = function(removed) { ++ var i = removed._, object; ++ if (array[i] !== removed) return; // invalid request ++ if (i !== --size) object = array[size], (compareArea(object, removed) < 0 ? up : down)(array[object._ = i] = object, i); ++ return i; ++ }; + +- function down(object, i) { +- while (true) { +- var r = (i + 1) << 1, +- l = r - 1, +- j = i, +- child = array[j]; +- if (l < size && compareArea(array[l], child) < 0) child = array[j = l]; +- if (r < size && compareArea(array[r], child) < 0) child = array[j = r]; +- if (j === i) break; +- array[child._ = i] = child; +- array[object._ = i = j] = object; +- } ++ function up(object, i) { ++ while (i > 0) { ++ var j = ((i + 1) >> 1) - 1, ++ parent = array[j]; ++ if (compareArea(object, parent) >= 0) break; ++ array[parent._ = i] = parent; ++ array[object._ = i = j] = object; + } ++ } + +- return heap; ++ function down(object, i) { ++ while (true) { ++ var r = (i + 1) << 1, ++ l = r - 1, ++ j = i, ++ child = array[j]; ++ if (l < size && compareArea(array[l], child) < 0) child = array[j = l]; ++ if (r < size && compareArea(array[r], child) < 0) child = array[j = r]; ++ if (j === i) break; ++ array[child._ = i] = child; ++ array[object._ = i = j] = object; ++ } + } + +- function presimplify(topology, triangleArea) { +- var absolute$$ = absolute(topology.transform), +- relative$$ = relative(topology.transform), +- heap = minAreaHeap(); ++ return heap; ++} + +- if (!triangleArea) triangleArea = triangle; ++function presimplify(topology, triangleArea) { ++ var absolute = transformAbsolute(topology.transform), ++ relative = transformRelative(topology.transform), ++ heap = minAreaHeap(); + +- topology.arcs.forEach(function(arc) { +- var triangles = [], +- maxArea = 0, +- triangle, +- i, +- n, +- p; ++ if (!triangleArea) triangleArea = cartesianTriangleArea; + +- // To store each point’s effective area, we create a new array rather than +- // extending the passed-in point to workaround a Chrome/V8 bug (getting +- // stuck in smi mode). For midpoints, the initial effective area of +- // Infinity will be computed in the next step. +- for (i = 0, n = arc.length; i < n; ++i) { +- p = arc[i]; +- absolute$$(arc[i] = [p[0], p[1], Infinity], i); +- } ++ topology.arcs.forEach(function(arc) { ++ var triangles = [], ++ maxArea = 0, ++ triangle, ++ i, ++ n, ++ p; + +- for (i = 1, n = arc.length - 1; i < n; ++i) { +- triangle = arc.slice(i - 1, i + 2); +- triangle[1][2] = triangleArea(triangle); +- triangles.push(triangle); +- heap.push(triangle); +- } ++ // To store each point’s effective area, we create a new array rather than ++ // extending the passed-in point to workaround a Chrome/V8 bug (getting ++ // stuck in smi mode). For midpoints, the initial effective area of ++ // Infinity will be computed in the next step. ++ for (i = 0, n = arc.length; i < n; ++i) { ++ p = arc[i]; ++ absolute(arc[i] = [p[0], p[1], Infinity], i); ++ } + +- for (i = 0, n = triangles.length; i < n; ++i) { +- triangle = triangles[i]; +- triangle.previous = triangles[i - 1]; +- triangle.next = triangles[i + 1]; +- } ++ for (i = 1, n = arc.length - 1; i < n; ++i) { ++ triangle = arc.slice(i - 1, i + 2); ++ triangle[1][2] = triangleArea(triangle); ++ triangles.push(triangle); ++ heap.push(triangle); ++ } + +- while (triangle = heap.pop()) { +- var previous = triangle.previous, +- next = triangle.next; ++ for (i = 0, n = triangles.length; i < n; ++i) { ++ triangle = triangles[i]; ++ triangle.previous = triangles[i - 1]; ++ triangle.next = triangles[i + 1]; ++ } + +- // If the area of the current point is less than that of the previous point +- // to be eliminated, use the latter's area instead. This ensures that the +- // current point cannot be eliminated without eliminating previously- +- // eliminated points. +- if (triangle[1][2] < maxArea) triangle[1][2] = maxArea; +- else maxArea = triangle[1][2]; ++ while (triangle = heap.pop()) { ++ var previous = triangle.previous, ++ next = triangle.next; + +- if (previous) { +- previous.next = next; +- previous[2] = triangle[2]; +- update(previous); +- } ++ // If the area of the current point is less than that of the previous point ++ // to be eliminated, use the latter's area instead. This ensures that the ++ // current point cannot be eliminated without eliminating previously- ++ // eliminated points. ++ if (triangle[1][2] < maxArea) triangle[1][2] = maxArea; ++ else maxArea = triangle[1][2]; + +- if (next) { +- next.previous = previous; +- next[0] = triangle[0]; +- update(next); +- } ++ if (previous) { ++ previous.next = next; ++ previous[2] = triangle[2]; ++ update(previous); + } + +- arc.forEach(relative$$); +- }); +- +- function update(triangle) { +- heap.remove(triangle); +- triangle[1][2] = triangleArea(triangle); +- heap.push(triangle); ++ if (next) { ++ next.previous = previous; ++ next[0] = triangle[0]; ++ update(next); ++ } + } + +- return topology; ++ arc.forEach(relative); ++ }); ++ ++ function update(triangle) { ++ heap.remove(triangle); ++ triangle[1][2] = triangleArea(triangle); ++ heap.push(triangle); + } + +- var version = "1.6.24"; ++ return topology; ++} ++ ++var version = "1.6.27"; + +- exports.version = version; +- exports.mesh = mesh; +- exports.meshArcs = meshArcs; +- exports.merge = merge; +- exports.mergeArcs = mergeArcs; +- exports.feature = feature; +- exports.neighbors = neighbors; +- exports.presimplify = presimplify; ++exports.version = version; ++exports.mesh = mesh; ++exports.meshArcs = meshArcs; ++exports.merge = merge; ++exports.mergeArcs = mergeArcs; ++exports.feature = feature; ++exports.neighbors = neighbors; ++exports.presimplify = presimplify; + +-})); ++Object.defineProperty(exports, '__esModule', { value: true }); ++ ++}))); + },{}],16:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. +@@ -14492,7 +14812,7 @@ function lineIntersect(x1, y1, x2, y2, x3, y3, x4, y4) { + return {x: x1 + a * t, y: y1 + d * t}; + } + +-},{"../../lib":99,"../../lib/setcursor":108,"../../lib/svg_text_utils":110,"../../plotly":118,"../../plots/cartesian/axes":121,"../color":20,"../dragelement":41,"../drawing":43,"./arrow_paths":16,"./attributes":17,"d3":10,"fast-isnumeric":12}],19:[function(require,module,exports){ ++},{"../../lib":99,"../../lib/setcursor":108,"../../lib/svg_text_utils":110,"../../plotly":118,"../../plots/cartesian/axes":121,"../color":20,"../dragelement":41,"../drawing":43,"./arrow_paths":16,"./attributes":17,"d3":8,"fast-isnumeric":11}],19:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -14686,7 +15006,7 @@ function cleanOne(val) { + return 'rgb(' + rgbStr + ')'; + } + +-},{"./attributes":19,"fast-isnumeric":12,"tinycolor2":14}],21:[function(require,module,exports){ ++},{"./attributes":19,"fast-isnumeric":11,"tinycolor2":14}],21:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -15538,7 +15858,7 @@ module.exports = function draw(gd, id) { + return component; + }; + +-},{"../../lib":99,"../../lib/extend":96,"../../lib/setcursor":108,"../../plotly":118,"../../plots/cartesian/axes":121,"../../plots/cartesian/axis_defaults":122,"../../plots/cartesian/layout_attributes":130,"../../plots/cartesian/position_defaults":133,"../../plots/plots":153,"../color":20,"../dragelement":41,"../drawing":43,"../titles":83,"./attributes":21,"d3":10,"tinycolor2":14}],24:[function(require,module,exports){ ++},{"../../lib":99,"../../lib/extend":96,"../../lib/setcursor":108,"../../plotly":118,"../../plots/cartesian/axes":121,"../../plots/cartesian/axis_defaults":122,"../../plots/cartesian/layout_attributes":130,"../../plots/cartesian/position_defaults":133,"../../plots/plots":153,"../color":20,"../dragelement":41,"../drawing":43,"../titles":83,"./attributes":21,"d3":8,"tinycolor2":14}],24:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -15823,7 +16143,7 @@ module.exports = function colorScaleDefaults(traceIn, traceOut, layout, coerce, + if(showScale) colorbarDefaults(containerIn, containerOut, layout); + }; + +-},{"../../lib":99,"../colorbar/defaults":22,"../colorbar/has_colorbar":24,"./flip_scale":31,"./is_valid_scale":35,"fast-isnumeric":12}],31:[function(require,module,exports){ ++},{"../../lib":99,"../colorbar/defaults":22,"../colorbar/has_colorbar":24,"./flip_scale":31,"./is_valid_scale":35,"fast-isnumeric":11}],31:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -15934,7 +16254,7 @@ module.exports = function hasColorscale(trace, containerStr) { + ); + }; + +-},{"../../lib":99,"./is_valid_scale":35,"fast-isnumeric":12}],34:[function(require,module,exports){ ++},{"../../lib":99,"./is_valid_scale":35,"fast-isnumeric":11}],34:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -16073,7 +16393,7 @@ module.exports = function makeScaleFunction(scl, cmin, cmax) { + }; + }; + +-},{"../../lib":99,"../color":20,"d3":10,"fast-isnumeric":12,"tinycolor2":14}],38:[function(require,module,exports){ ++},{"../../lib":99,"../color":20,"d3":8,"fast-isnumeric":11,"tinycolor2":14}],38:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -17075,7 +17395,7 @@ drawing.setClipUrl = function(s, localId) { + s.attr('clip-path', 'url(' + url + ')'); + }; + +-},{"../../constants/xmlns_namespaces":89,"../../lib":99,"../../lib/svg_text_utils":110,"../../plots/plots":153,"../../traces/scatter/make_bubble_size_func":189,"../../traces/scatter/subtypes":194,"../color":20,"../colorscale":34,"./symbol_defs":44,"d3":10,"fast-isnumeric":12}],44:[function(require,module,exports){ ++},{"../../constants/xmlns_namespaces":89,"../../lib":99,"../../lib/svg_text_utils":110,"../../plots/plots":153,"../../traces/scatter/make_bubble_size_func":189,"../../traces/scatter/subtypes":194,"../color":20,"../colorscale":34,"./symbol_defs":44,"d3":8,"fast-isnumeric":11}],44:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -17551,7 +17871,7 @@ module.exports = { + } + }; + +-},{"d3":10}],45:[function(require,module,exports){ ++},{"d3":8}],45:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -17713,7 +18033,7 @@ function calcOneAxis(calcTrace, trace, axis, coord) { + Axes.expand(axis, vals, {padded: true}); + } + +-},{"../../plots/cartesian/axes":121,"../../plots/plots":153,"./compute_error":47,"fast-isnumeric":12}],47:[function(require,module,exports){ ++},{"../../plots/cartesian/axes":121,"../../plots/plots":153,"./compute_error":47,"fast-isnumeric":11}],47:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -17886,7 +18206,7 @@ module.exports = function(traceIn, traceOut, defaultColor, opts) { + } + }; + +-},{"../../lib":99,"../../plots/plots":153,"./attributes":45,"fast-isnumeric":12}],49:[function(require,module,exports){ ++},{"../../lib":99,"../../plots/plots":153,"./attributes":45,"fast-isnumeric":11}],49:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -18066,7 +18386,7 @@ function errorCoords(d, xa, ya) { + return out; + } + +-},{"../../lib":99,"../../traces/scatter/subtypes":194,"d3":10,"fast-isnumeric":12}],51:[function(require,module,exports){ ++},{"../../lib":99,"../../traces/scatter/subtypes":194,"d3":8,"fast-isnumeric":11}],51:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -18103,7 +18423,7 @@ module.exports = function style(traces) { + }); + }; + +-},{"../color":20,"d3":10}],52:[function(require,module,exports){ ++},{"../color":20,"d3":8}],52:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -18457,7 +18777,7 @@ module.exports = function draw(gd) { + imagesAbove.each(applyAttributes); + }; + +-},{"../../plots/cartesian/axes":121,"../drawing":43,"d3":10}],55:[function(require,module,exports){ ++},{"../../plots/cartesian/axes":121,"../drawing":43,"d3":8}],55:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -18574,6 +18894,13 @@ module.exports = { + + + }, ++ horizontalspacing: { ++ valType: 'enumerated', ++ values: ['column', 'wrapped'], ++ dflt: ['column'], ++ ++ ++ }, + traceorder: { + valType: 'flaglist', + flags: ['reversed', 'grouped'], +@@ -18663,6 +18990,7 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { + + var visibleTraces = 0, + defaultOrder = 'normal', ++ defaultHorizontalSpacing = 'column', + defaultX, + defaultY, + defaultXAnchor, +@@ -18727,6 +19055,7 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { + coerce('xanchor', defaultXAnchor); + coerce('y', defaultY); + coerce('yanchor', defaultYAnchor); ++ coerce('horizontalspacing', defaultHorizontalSpacing); + Lib.noneOrAll(containerIn, containerOut, ['x', 'y']); + }; + +@@ -19207,7 +19536,8 @@ function computeLegendDimensions(gd, groups, traces) { + var fullLayout = gd._fullLayout, + opts = fullLayout.legend, + borderwidth = opts.borderwidth, +- isGrouped = helpers.isGrouped(opts); ++ isGrouped = helpers.isGrouped(opts), ++ isHorizontalColumn = helpers.isHorizontalColumn(opts); + + if(helpers.isVertical(opts)) { + if(isGrouped) { +@@ -19314,7 +19644,7 @@ function computeLegendDimensions(gd, groups, traces) { + traces.each(function(d) { + + var legendItem = d[0], +- traceWidth = maxTraceWidth, ++ traceWidth = isHorizontalColumn ? maxTraceWidth : 40 + d[0], + traceGap = opts.tracegroupgap || 5; + + if((borderwidth + offsetX + traceGap + traceWidth) > (fullLayout.width - (fullLayout.margin.r + fullLayout.margin.l))) { +@@ -19403,7 +19733,7 @@ function expandHorizontalMargin(gd) { + }); + } + +-},{"../../lib":99,"../../plotly":118,"../../plots/plots":153,"../color":20,"../dragelement":41,"../drawing":43,"./anchor_utils":56,"./constants":58,"./get_legend_data":61,"./helpers":62,"./style":64,"d3":10}],61:[function(require,module,exports){ ++},{"../../lib":99,"../../plotly":118,"../../plots/plots":153,"../color":20,"../dragelement":41,"../drawing":43,"./anchor_utils":56,"./constants":58,"./get_legend_data":61,"./helpers":62,"./style":64,"d3":8}],61:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -19540,6 +19870,9 @@ exports.isReversed = function isReversed(legendLayout) { + return (legendLayout.traceorder || '').indexOf('reversed') !== -1; + }; + ++exports.isHorizontalColumn = function isReversed(legendLayout) { ++ return legendLayout.horizontalspacing === 'column'; ++}; + },{"../../plots/plots":153}],63:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. +@@ -19785,7 +20118,7 @@ function stylePies(d) { + if(pts.size()) pts.call(stylePie, d[0], trace); + } + +-},{"../../lib":99,"../../plots/plots":153,"../../traces/pie/style_one":173,"../../traces/scatter/subtypes":194,"../color":20,"../drawing":43,"d3":10}],65:[function(require,module,exports){ ++},{"../../lib":99,"../../plots/plots":153,"../../traces/pie/style_one":173,"../../traces/scatter/subtypes":194,"../color":20,"../drawing":43,"d3":8}],65:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -20583,7 +20916,7 @@ function createModeBar(gd, buttons) { + + module.exports = createModeBar; + +-},{"../../../build/ploticon":2,"../../lib":99,"d3":10}],67:[function(require,module,exports){ ++},{"../../../build/ploticon":2,"../../lib":99,"d3":8}],67:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -21337,7 +21670,7 @@ function reposition(gd, buttons, opts, axName) { + }); + } + +-},{"../../lib/svg_text_utils":110,"../../plotly":118,"../../plots/cartesian/axis_ids":123,"../../plots/plots":153,"../color":20,"../drawing":43,"../legend/anchor_utils":56,"./constants":70,"./get_update_object":73,"d3":10}],73:[function(require,module,exports){ ++},{"../../lib/svg_text_utils":110,"../../plotly":118,"../../plots/cartesian/axis_ids":123,"../../plots/plots":153,"../color":20,"../drawing":43,"../legend/anchor_utils":56,"./constants":70,"./get_update_object":73,"d3":8}],73:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -21395,7 +21728,7 @@ function getXRange(axisLayout, buttonLayout) { + return [range0, range1]; + } + +-},{"d3":10}],74:[function(require,module,exports){ ++},{"d3":8}],74:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -22084,7 +22417,7 @@ function makeScatter(trace, pointPairs, w, h) { + return [line, markers, fill]; + } + +-},{"../../constants/xmlns_namespaces":89,"../../lib":99,"../drawing":43,"../drawing/symbol_defs":44,"./helpers":78,"d3":10}],81:[function(require,module,exports){ ++},{"../../constants/xmlns_namespaces":89,"../../lib":99,"../drawing":43,"../drawing/symbol_defs":44,"./helpers":78,"d3":8}],81:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -22965,7 +23298,7 @@ function shapeBounds(ax, v0, v1, path, paramsToUse) { + if(max >= min) return [min, max]; + } + +-},{"../../lib":99,"../../lib/setcursor":108,"../../plotly":118,"../../plots/cartesian/axes":121,"../color":20,"../dragelement":41,"../drawing":43,"./attributes":81,"fast-isnumeric":12}],83:[function(require,module,exports){ ++},{"../../lib":99,"../../lib/setcursor":108,"../../plotly":118,"../../plots/cartesian/axes":121,"../color":20,"../dragelement":41,"../drawing":43,"./attributes":81,"fast-isnumeric":11}],83:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -23195,7 +23528,7 @@ Titles.draw = function(gd, titleClass, options) { + el.classed('js-placeholder', isplaceholder); + }; + +-},{"../../lib":99,"../../lib/svg_text_utils":110,"../../plotly":118,"../../plots/plots":153,"../color":20,"../drawing":43,"d3":10,"fast-isnumeric":12}],84:[function(require,module,exports){ ++},{"../../lib":99,"../../lib/svg_text_utils":110,"../../plotly":118,"../../plots/plots":153,"../color":20,"../drawing":43,"d3":8,"fast-isnumeric":11}],84:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -23943,7 +24276,7 @@ function clearPushMargins(gd) { + } + } + +-},{"../../lib":99,"../../lib/svg_text_utils":110,"../../plotly":118,"../../plots/plots":153,"../color":20,"../drawing":43,"../legend/anchor_utils":56,"./constants":85,"d3":10}],88:[function(require,module,exports){ ++},{"../../lib":99,"../../lib/svg_text_utils":110,"../../plotly":118,"../../plots/plots":153,"../color":20,"../drawing":43,"../legend/anchor_utils":56,"./constants":85,"d3":8}],88:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -24036,7 +24369,7 @@ exports.Queue = Plotly.Queue; + // export d3 used in the bundle + exports.d3 = require('d3'); + +-},{"../build/ploticon":2,"./plot_api/set_plot_config":115,"./plot_api/to_image":116,"./plot_api/validate":117,"./plotly":118,"./snapshot/download":161,"d3":10}],91:[function(require,module,exports){ ++},{"../build/ploticon":2,"./plot_api/set_plot_config":115,"./plot_api/to_image":116,"./plot_api/validate":117,"./plotly":118,"./snapshot/download":161,"d3":8}],91:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -24396,7 +24729,7 @@ exports.validate = function(value, opts) { + return out !== failed; + }; + +-},{"../components/colorscale/get_scale":32,"../components/colorscale/scales":38,"./nested_property":103,"fast-isnumeric":12,"tinycolor2":14}],94:[function(require,module,exports){ ++},{"../components/colorscale/get_scale":32,"../components/colorscale/scales":38,"./nested_property":103,"fast-isnumeric":11,"tinycolor2":14}],94:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -24735,7 +25068,7 @@ exports.parseDate = function(v) { + return out; + }; + +-},{"../lib":99,"d3":10,"fast-isnumeric":12}],95:[function(require,module,exports){ ++},{"../lib":99,"d3":8,"fast-isnumeric":11}],95:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -24869,7 +25202,7 @@ var Events = { + + module.exports = Events; + +-},{"events":7}],96:[function(require,module,exports){ ++},{"events":10}],96:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -25066,7 +25399,7 @@ function countryNameToISO3(countryName) { + Lib.warn('Unrecognized country name: ' + countryName + '.'); + } + +-},{"../lib":99,"country-regex":9}],99:[function(require,module,exports){ ++},{"../lib":99,"country-regex":7}],99:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -25686,7 +26019,7 @@ lib.numSeparate = function(value, separators) { + return x1 + x2; + }; + +-},{"./coerce":93,"./dates":94,"./extend":96,"./is_plain_object":100,"./loggers":101,"./matrix":102,"./nested_property":103,"./notifier":104,"./search":107,"./stats":109,"d3":10}],100:[function(require,module,exports){ ++},{"./coerce":93,"./dates":94,"./extend":96,"./is_plain_object":100,"./loggers":101,"./matrix":102,"./nested_property":103,"./notifier":104,"./search":107,"./stats":109,"d3":8}],100:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -26148,7 +26481,7 @@ function badContainer(container, propStr, propParts) { + }; + } + +-},{"fast-isnumeric":12}],104:[function(require,module,exports){ ++},{"fast-isnumeric":11}],104:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -26225,7 +26558,7 @@ module.exports = function(text, displayLength) { + }); + }; + +-},{"d3":10,"fast-isnumeric":12}],105:[function(require,module,exports){ ++},{"d3":8,"fast-isnumeric":11}],105:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -26788,7 +27121,7 @@ exports.roundUp = function(val, arrayIn, reverse) { + return arrayIn[low]; + }; + +-},{"../lib":99,"fast-isnumeric":12}],108:[function(require,module,exports){ ++},{"../lib":99,"fast-isnumeric":11}],108:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -26907,7 +27240,7 @@ exports.interp = function(arr, n) { + return frac * arr[Math.ceil(n)] + (1 - frac) * arr[Math.floor(n)]; + }; + +-},{"fast-isnumeric":12}],110:[function(require,module,exports){ ++},{"fast-isnumeric":11}],110:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -27408,7 +27741,7 @@ util.makeEditable = function(context, _delegate, options) { + return d3.rebind(this, dispatch, 'on'); + }; + +-},{"../constants/xmlns_namespaces":89,"../lib":99,"../plotly":118,"d3":10}],111:[function(require,module,exports){ ++},{"../constants/xmlns_namespaces":89,"../lib":99,"../plotly":118,"d3":8}],111:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -30559,7 +30892,7 @@ function drawMainTitle(gd) { + }); + } + +-},{"../components/color":20,"../components/drawing":43,"../components/errorbars":49,"../components/images":55,"../components/legend":63,"../components/modebar/manage":67,"../components/rangeselector":74,"../components/rangeslider":79,"../components/shapes":82,"../components/titles":83,"../components/updatemenus":88,"../constants/xmlns_namespaces":89,"../lib":99,"../lib/events":95,"../lib/queue":106,"../plotly":118,"../plots/cartesian/graph_interact":128,"../plots/plots":153,"d3":10,"fast-isnumeric":12,"gl-mat4/fromQuat":13}],113:[function(require,module,exports){ ++},{"../components/color":20,"../components/drawing":43,"../components/errorbars":49,"../components/images":55,"../components/legend":63,"../components/modebar/manage":67,"../components/rangeselector":74,"../components/rangeslider":79,"../components/shapes":82,"../components/titles":83,"../components/updatemenus":88,"../constants/xmlns_namespaces":89,"../lib":99,"../lib/events":95,"../lib/queue":106,"../plotly":118,"../plots/cartesian/graph_interact":128,"../plots/plots":153,"d3":8,"fast-isnumeric":11,"gl-mat4/fromQuat":12}],113:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -31147,7 +31480,7 @@ function toImage(gd, opts) { + + module.exports = toImage; + +-},{"../lib":99,"../plotly":118,"../snapshot":163,"fast-isnumeric":12}],117:[function(require,module,exports){ ++},{"../lib":99,"../plotly":118,"../snapshot":163,"fast-isnumeric":11}],117:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -31635,7 +31968,7 @@ exports.PlotSchema = require('./plot_api/plot_schema'); + // imaging routines + exports.Snapshot = require('./snapshot'); + +-},{"../build/plotcss":1,"./components/annotations":18,"./components/color":20,"./components/colorbar":25,"./components/colorscale":34,"./components/drawing":43,"./components/errorbars":49,"./components/images":55,"./components/legend":63,"./components/modebar":66,"./components/shapes":82,"./components/updatemenus":88,"./fonts/mathjax_config":91,"./lib":99,"./lib/queue":106,"./lib/svg_text_utils":110,"./plot_api/plot_api":112,"./plot_api/plot_config":113,"./plot_api/plot_schema":114,"./plots/cartesian/axes":121,"./plots/cartesian/graph_interact":128,"./plots/plots":153,"./plots/polar/micropolar":156,"./snapshot":163,"./traces/scatter":185,"es6-promise":11}],119:[function(require,module,exports){ ++},{"../build/plotcss":1,"./components/annotations":18,"./components/color":20,"./components/colorbar":25,"./components/colorscale":34,"./components/drawing":43,"./components/errorbars":49,"./components/images":55,"./components/legend":63,"./components/modebar":66,"./components/shapes":82,"./components/updatemenus":88,"./fonts/mathjax_config":91,"./lib":99,"./lib/queue":106,"./lib/svg_text_utils":110,"./plot_api/plot_api":112,"./plot_api/plot_config":113,"./plot_api/plot_schema":114,"./plots/cartesian/axes":121,"./plots/cartesian/graph_interact":128,"./plots/plots":153,"./plots/polar/micropolar":156,"./snapshot":163,"./traces/scatter":185,"es6-promise":9}],119:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -31918,14 +32251,27 @@ axes.getAutoRange = function(ax) { + } + + if(minmin === maxmax) { +- newRange = axReverse ? +- [minmin + 1, ax.rangemode !== 'normal' ? 0 : minmin - 1] : +- [ax.rangemode !== 'normal' ? 0 : minmin - 1, minmin + 1]; ++ var lower = minmin - 1; ++ var upper = minmin + 1; ++ if(ax.rangemode === 'tozero') { ++ newRange = minmin < 0 ? [lower, 0] : [0, upper]; ++ } ++ else if(ax.rangemode === 'nonnegative') { ++ newRange = [Math.max(0, lower), Math.max(0, upper)]; ++ } ++ else { ++ newRange = [lower, upper]; ++ } + } + else if(mbest) { + if(ax.type === 'linear' || ax.type === '-') { +- if(ax.rangemode === 'tozero' && minbest.val >= 0) { +- minbest = {val: 0, pad: 0}; ++ if(ax.rangemode === 'tozero') { ++ if(minbest.val >= 0) { ++ minbest = {val: 0, pad: 0}; ++ } ++ if(maxbest.val <= 0) { ++ maxbest = {val: 0, pad: 0}; ++ } + } + else if(ax.rangemode === 'nonnegative') { + if(minbest.val - mbest * minbest.pad < 0) { +@@ -31939,22 +32285,39 @@ axes.getAutoRange = function(ax) { + // in case it changed again... + mbest = (maxbest.val - minbest.val) / + (ax._length - minbest.pad - maxbest.pad); ++ + } + + newRange = [ + minbest.val - mbest * minbest.pad, + maxbest.val + mbest * maxbest.pad + ]; ++ } + +- // don't let axis have zero size +- if(newRange[0] === newRange[1]) { ++ // don't let axis have zero size, while still respecting tozero and nonnegative ++ if(newRange[0] === newRange[1]) { ++ if(ax.rangemode === 'tozero') { ++ if(newRange[0] < 0) { ++ newRange = [newRange[0], 0]; ++ } ++ else if(newRange[0] > 0) { ++ newRange = [0, newRange[0]]; ++ } ++ else { ++ newRange = [0, 1]; ++ } ++ } ++ else { + newRange = [newRange[0] - 1, newRange[0] + 1]; ++ if(ax.rangemode === 'nonnegative') { ++ newRange[0] = Math.max(0, newRange[0]); ++ } + } ++ } + +- // maintain reversal +- if(axReverse) { +- newRange.reverse(); +- } ++ // maintain reversal ++ if(axReverse) { ++ newRange.reverse(); + } + + return newRange; +@@ -33737,7 +34100,7 @@ function swapAxisAttrs(layout, key, xFullAxes, yFullAxes) { + // rather than built-in % which gives a negative value for negative v + function mod(v, d) { return ((v % d) + d) % d; } + +-},{"../../components/color":20,"../../components/drawing":43,"../../components/titles":83,"../../lib":99,"../../lib/svg_text_utils":110,"../../plotly":118,"./axis_ids":123,"./layout_attributes":130,"./layout_defaults":131,"./set_convert":135,"d3":10,"fast-isnumeric":12}],122:[function(require,module,exports){ ++},{"../../components/color":20,"../../components/drawing":43,"../../components/titles":83,"../../lib":99,"../../lib/svg_text_utils":110,"../../plotly":118,"./axis_ids":123,"./layout_attributes":130,"./layout_defaults":131,"./set_convert":135,"d3":8,"fast-isnumeric":11}],122:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -34020,7 +34383,7 @@ function category(a) { + return curvecats > curvenums * 2; + } + +-},{"../../components/color/attributes":19,"../../lib":99,"../plots":153,"./axis_ids":123,"./category_order_defaults":124,"./clean_datum":125,"./layout_attributes":130,"./ordered_categories":132,"./set_convert":135,"./tick_label_defaults":136,"./tick_mark_defaults":137,"./tick_value_defaults":138,"fast-isnumeric":12,"tinycolor2":14}],123:[function(require,module,exports){ ++},{"../../components/color/attributes":19,"../../lib":99,"../plots":153,"./axis_ids":123,"./category_order_defaults":124,"./clean_datum":125,"./layout_attributes":130,"./ordered_categories":132,"./set_convert":135,"./tick_label_defaults":136,"./tick_mark_defaults":137,"./tick_value_defaults":138,"fast-isnumeric":11,"tinycolor2":14}],123:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -34214,7 +34577,7 @@ module.exports = function cleanDatum(c) { + return c; + }; + +-},{"../../lib":99,"fast-isnumeric":12}],126:[function(require,module,exports){ ++},{"../../lib":99,"fast-isnumeric":11}],126:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -34981,7 +35344,7 @@ function isSelectOrLasso(dragmode) { + return modes.indexOf(dragmode) !== -1; + } + +-},{"../../components/color":20,"../../components/dragelement":41,"../../components/drawing":43,"../../lib":99,"../../lib/setcursor":108,"../../lib/svg_text_utils":110,"../../plotly":118,"./axes":121,"./constants":126,"./select":134,"d3":10,"tinycolor2":14}],128:[function(require,module,exports){ ++},{"../../components/color":20,"../../components/dragelement":41,"../../components/drawing":43,"../../lib":99,"../../lib/setcursor":108,"../../lib/svg_text_utils":110,"../../plotly":118,"./axes":121,"./constants":126,"./select":134,"d3":8,"tinycolor2":14}],128:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -36323,7 +36686,7 @@ fx.inbox = function(v0, v1) { + return Infinity; + }; + +-},{"../../components/color":20,"../../components/dragelement":41,"../../components/drawing":43,"../../lib":99,"../../lib/events":95,"../../lib/svg_text_utils":110,"./axes":121,"./constants":126,"./dragbox":127,"d3":10,"fast-isnumeric":12,"tinycolor2":14}],129:[function(require,module,exports){ ++},{"../../components/color":20,"../../components/dragelement":41,"../../components/drawing":43,"../../lib":99,"../../lib/events":95,"../../lib/svg_text_utils":110,"./axes":121,"./constants":126,"./dragbox":127,"d3":8,"fast-isnumeric":11,"tinycolor2":14}],129:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -37007,7 +37370,7 @@ module.exports = function orderedCategories(axisLetter, categoryorder, categorya + } + }; + +-},{"d3":10}],133:[function(require,module,exports){ ++},{"d3":8}],133:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -37072,7 +37435,7 @@ module.exports = function handlePositionDefaults(containerIn, containerOut, coer + return containerOut; + }; + +-},{"../../lib":99,"fast-isnumeric":12}],134:[function(require,module,exports){ ++},{"../../lib":99,"fast-isnumeric":11}],134:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -37516,7 +37879,7 @@ module.exports = function setConvert(ax) { + ax._forceTick0 = null; + }; + +-},{"../../lib":99,"./axis_ids":123,"./clean_datum":125,"./constants":126,"d3":10,"fast-isnumeric":12}],136:[function(require,module,exports){ ++},{"../../lib":99,"./axis_ids":123,"./clean_datum":125,"./constants":126,"d3":8,"fast-isnumeric":11}],136:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -37673,7 +38036,7 @@ module.exports = function handleTickValueDefaults(containerIn, containerOut, coe + } + }; + +-},{"fast-isnumeric":12}],139:[function(require,module,exports){ ++},{"fast-isnumeric":11}],139:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -38356,7 +38719,7 @@ function createMockAxis(fullLayout) { + return mockAxis; + } + +-},{"../../components/color":20,"../../components/drawing":43,"../../constants/xmlns_namespaces":89,"../../lib/filter_visible":97,"../../lib/topojson_utils":111,"../../plots/cartesian/axes":121,"./constants":140,"./projections":148,"./set_scale":149,"./zoom":150,"./zoom_reset":151,"d3":10,"topojson":15}],142:[function(require,module,exports){ ++},{"../../components/color":20,"../../components/drawing":43,"../../constants/xmlns_namespaces":89,"../../lib/filter_visible":97,"../../lib/topojson_utils":111,"../../plots/cartesian/axes":121,"./constants":140,"./projections":148,"./set_scale":149,"./zoom":150,"./zoom_reset":151,"d3":8,"topojson":15}],142:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -39561,7 +39924,7 @@ function getBounds(projection, rangeBox) { + return d3.geo.path().projection(projection).bounds(rangeBox); + } + +-},{"./constants":140,"d3":10}],150:[function(require,module,exports){ ++},{"./constants":140,"d3":8}],150:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -39988,7 +40351,7 @@ function d3_eventDispatch(target) { + return dispatch; + } + +-},{"d3":10}],151:[function(require,module,exports){ ++},{"d3":8}],151:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -41379,7 +41742,7 @@ plots.graphJson = function(gd, dataonly, mode, output, useDefaults) { + return (output === 'object') ? obj : JSON.stringify(obj); + }; + +-},{"../components/color":20,"../lib":99,"../plotly":118,"./attributes":119,"./font_attributes":139,"./layout_attributes":152,"d3":10,"fast-isnumeric":12}],154:[function(require,module,exports){ ++},{"../components/color":20,"../lib":99,"../plotly":118,"./attributes":119,"./font_attributes":139,"./layout_attributes":152,"d3":8,"fast-isnumeric":11}],154:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -42942,7 +43305,7 @@ var extendDeepAll = Plotly.Lib.extendDeepAll; + return exports; + }; + +-},{"../../plotly":118,"./micropolar_manager":157,"d3":10}],157:[function(require,module,exports){ ++},{"../../plotly":118,"./micropolar_manager":157,"d3":8}],157:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -43025,7 +43388,7 @@ manager.fillLayout = function(_gd) { + _gd._fullLayout = extendDeepAll(dflts, _gd.layout); + }; + +-},{"../../plotly":118,"./undo_manager":158,"d3":10}],158:[function(require,module,exports){ ++},{"../../plotly":118,"./undo_manager":158,"d3":8}],158:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -43632,7 +43995,7 @@ function svgToImg(opts) { + + module.exports = svgToImg; + +-},{"../lib":99,"events":7}],165:[function(require,module,exports){ ++},{"../lib":99,"events":10}],165:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -43711,7 +44074,7 @@ function toImage(gd, opts) { + + module.exports = toImage; + +-},{"../lib":99,"../plotly":118,"events":7}],166:[function(require,module,exports){ ++},{"../lib":99,"../plotly":118,"events":10}],166:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -43823,7 +44186,7 @@ module.exports = function toSVG(gd, format) { + return s; + }; + +-},{"../components/color":20,"../components/drawing":43,"../constants/xmlns_namespaces":89,"../lib/svg_text_utils":110,"d3":10}],167:[function(require,module,exports){ ++},{"../components/color":20,"../components/drawing":43,"../constants/xmlns_namespaces":89,"../lib/svg_text_utils":110,"d3":8}],167:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -44196,7 +44559,7 @@ function makeEventDataFunc(trace) { + }; + } + +-},{"../../components/color":20,"../../components/colorscale/get_scale":32,"../../components/colorscale/make_scale_function":37,"../../components/drawing":43,"../../lib/array_to_calc_item":92,"../../lib/geo_location_utils":98,"../../lib/topojson_utils":111,"../../plots/cartesian/axes":121,"../../plots/cartesian/graph_interact":128,"../../plots/geo/constants":140,"./attributes":167,"d3":10}],172:[function(require,module,exports){ ++},{"../../components/color":20,"../../components/colorscale/get_scale":32,"../../components/colorscale/make_scale_function":37,"../../components/drawing":43,"../../lib/array_to_calc_item":92,"../../lib/geo_location_utils":98,"../../lib/topojson_utils":111,"../../plots/cartesian/axes":121,"../../plots/cartesian/graph_interact":128,"../../plots/geo/constants":140,"./attributes":167,"d3":8}],172:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -44242,7 +44605,7 @@ module.exports = function colorbar(gd, cd) { + .options(trace.colorbar)(); + }; + +-},{"../../components/colorbar/draw":23,"../../components/colorscale/get_scale":32,"../../lib":99,"../../plots/plots":153,"d3":10,"fast-isnumeric":12}],173:[function(require,module,exports){ ++},{"../../components/colorbar/draw":23,"../../components/colorscale/get_scale":32,"../../lib":99,"../../plots/plots":153,"d3":8,"fast-isnumeric":11}],173:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -44684,7 +45047,7 @@ module.exports = function calc(gd, trace) { + return cd; + }; + +-},{"../../lib":99,"../../plots/cartesian/axes":121,"./colorscale_calc":179,"./subtypes":194,"fast-isnumeric":12}],177:[function(require,module,exports){ ++},{"../../lib":99,"../../plots/cartesian/axes":121,"./colorscale_calc":179,"./subtypes":194,"fast-isnumeric":11}],177:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -44778,7 +45141,7 @@ module.exports = function colorbar(gd, cd) { + .options(marker.colorbar)(); + }; + +-},{"../../components/colorbar/draw":23,"../../components/colorscale/get_scale":32,"../../lib":99,"../../plots/plots":153,"d3":10,"fast-isnumeric":12}],179:[function(require,module,exports){ ++},{"../../components/colorbar/draw":23,"../../components/colorscale/get_scale":32,"../../lib":99,"../../plots/plots":153,"d3":8,"fast-isnumeric":11}],179:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -45472,7 +45835,7 @@ module.exports = function makeBubbleSizeFn(trace) { + }; + }; + +-},{"fast-isnumeric":12}],190:[function(require,module,exports){ ++},{"fast-isnumeric":11}],190:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -45825,7 +46188,7 @@ function selectMarkers(gd, plotinfo, cdscatter) { + }); + } + +-},{"../../components/drawing":43,"../../components/errorbars":49,"../../lib":99,"../../lib/polygon":105,"./arrays_to_calcdata":174,"./line_points":187,"./subtypes":194,"d3":10}],192:[function(require,module,exports){ ++},{"../../components/drawing":43,"../../components/errorbars":49,"../../lib":99,"../../lib/polygon":105,"./arrays_to_calcdata":174,"./line_points":187,"./subtypes":194,"d3":8}],192:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -45938,7 +46301,7 @@ module.exports = function style(gd) { + s.call(ErrorBars.style); + }; + +-},{"../../components/drawing":43,"../../components/errorbars":49,"d3":10}],194:[function(require,module,exports){ ++},{"../../components/drawing":43,"../../components/errorbars":49,"d3":8}],194:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -46542,5 +46905,5 @@ function makeEventDataFunc(trace) { + }; + } + +-},{"../../components/color":20,"../../components/drawing":43,"../../lib/array_to_calc_item":92,"../../lib/geo_location_utils":98,"../../lib/topojson_utils":111,"../../plots/cartesian/axes":121,"../../plots/cartesian/graph_interact":128,"../scatter/subtypes":194,"./attributes":197,"d3":10}]},{},[5])(5) ++},{"../../components/color":20,"../../components/drawing":43,"../../lib/array_to_calc_item":92,"../../lib/geo_location_utils":98,"../../lib/topojson_utils":111,"../../plots/cartesian/axes":121,"../../plots/cartesian/graph_interact":128,"../scatter/subtypes":194,"./attributes":197,"d3":8}]},{},[5])(5) + }); +\ No newline at end of file +diff --git a/dist/plotly-geo.min.js b/dist/plotly-geo.min.js +index 67f63b3..002ce48 100644 +--- a/dist/plotly-geo.min.js ++++ b/dist/plotly-geo.min.js +@@ -4,22 +4,22 @@ + * All rights reserved. + * Licensed under the MIT license + */ +-!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.Plotly=t()}}(function(){var t;return function e(t,n,r){function a(i,l){if(!n[i]){if(!t[i]){var s="function"==typeof require&&require;if(!l&&s)return s(i,!0);if(o)return o(i,!0);var c=new Error("Cannot find module '"+i+"'");throw c.code="MODULE_NOT_FOUND",c}var u=n[i]={exports:{}};t[i][0].call(u.exports,function(e){var n=t[i][1][e];return a(n?n:e)},u,u.exports,e,t,n,r)}return n[i].exports}for(var o="function"==typeof require&&require,i=0;it||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},r.prototype.emit=function(t){var e,n,r,o,s,c;if(this._events||(this._events={}),"error"===t&&(!this._events.error||i(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;throw TypeError('Uncaught, unspecified "error" event.')}if(n=this._events[t],l(n))return!1;if(a(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:o=Array.prototype.slice.call(arguments,1),n.apply(this,o)}else if(i(n))for(o=Array.prototype.slice.call(arguments,1),c=n.slice(),r=c.length,s=0;r>s;s++)c[s].apply(this,o);return!0},r.prototype.addListener=function(t,e){var n;if(!a(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,a(e.listener)?e.listener:e),this._events[t]?i(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,i(this._events[t])&&!this._events[t].warned&&(n=l(this._maxListeners)?r.defaultMaxListeners:this._maxListeners,n&&n>0&&this._events[t].length>n&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(t,e){function n(){this.removeListener(t,n),r||(r=!0,e.apply(this,arguments))}if(!a(e))throw TypeError("listener must be a function");var r=!1;return n.listener=e,this.on(t,n),this},r.prototype.removeListener=function(t,e){var n,r,o,l;if(!a(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(n=this._events[t],o=n.length,r=-1,n===e||a(n.listener)&&n.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(i(n)){for(l=o;l-- >0;)if(n[l]===e||n[l].listener&&n[l].listener===e){r=l;break}if(0>r)return this;1===n.length?(n.length=0,delete this._events[t]):n.splice(r,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},r.prototype.removeAllListeners=function(t){var e,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[t],a(n))this.removeListener(t,n);else if(n)for(;n.length;)this.removeListener(t,n[n.length-1]);return delete this._events[t],this},r.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?a(this._events[t])?[this._events[t]]:this._events[t].slice():[]},r.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(a(e))return 1;if(e)return e.length}return 0},r.listenerCount=function(t,e){return t.listenerCount(e)}},{}],8:[function(t,e,n){function r(){u=!1,l.length?c=l.concat(c):f=-1,c.length&&a()}function a(){if(!u){var t=setTimeout(r);u=!0;for(var e=c.length;e;){for(l=c,c=[];++f1)for(var n=1;nt?-1:t>e?1:t>=e?0:NaN}function o(t){return null===t?NaN:+t}function i(t){return!isNaN(t)}function l(t){return{left:function(e,n,r,a){for(arguments.length<3&&(r=0),arguments.length<4&&(a=e.length);a>r;){var o=r+a>>>1;t(e[o],n)<0?r=o+1:a=o}return r},right:function(e,n,r,a){for(arguments.length<3&&(r=0),arguments.length<4&&(a=e.length);a>r;){var o=r+a>>>1;t(e[o],n)>0?a=o:r=o+1}return r}}}function s(t){return t.length}function c(t){for(var e=1;t*e%1;)e*=10;return e}function u(t,e){for(var n in e)Object.defineProperty(t.prototype,n,{value:e[n],enumerable:!1})}function f(){this._=Object.create(null)}function d(t){return(t+="")===ki||t[0]===Mi?Mi+t:t}function h(t){return(t+="")[0]===Mi?t.slice(1):t}function p(t){return d(t)in this._}function g(t){return(t=d(t))in this._&&delete this._[t]}function v(){var t=[];for(var e in this._)t.push(h(e));return t}function m(){var t=0;for(var e in this._)++t;return t}function y(){for(var t in this._)return!1;return!0}function x(){this._=Object.create(null)}function b(t){return t}function _(t,e,n){return function(){var r=n.apply(e,arguments);return r===e?t:r}}function w(t,e){if(e in t)return e;e=e.charAt(0).toUpperCase()+e.slice(1);for(var n=0,r=Ai.length;r>n;++n){var a=Ai[n]+e;if(a in t)return a}}function k(){}function M(){}function A(t){function e(){for(var e,r=n,a=-1,o=r.length;++an;n++)for(var a,o=t[n],i=0,l=o.length;l>i;i++)(a=o[i])&&e(a,i,n);return t}function Z(t){return Li(t,Pi),t}function Y(t){var e,n;return function(r,a,o){var i,l=t[o].update,s=l.length;for(o!=n&&(n=o,e=0),a>=e&&(e=a+1);!(i=l[e])&&++e0&&(t=t.slice(0,l));var c=ji.get(t);return c&&(t=c,s=$),l?e?a:r:e?k:o}function Q(t,e){return function(n){var r=ui.event;ui.event=n,e[0]=this.__data__;try{t.apply(this,e)}finally{ui.event=r}}}function $(t,e){var n=Q(t,e);return function(t){var e=this,r=t.relatedTarget;r&&(r===e||8&r.compareDocumentPosition(e))||n.call(e,t)}}function W(t){var n=".dragsuppress-"+ ++Ri,a="click"+n,o=ui.select(r(t)).on("touchmove"+n,T).on("dragstart"+n,T).on("selectstart"+n,T);if(null==Di&&(Di="onselectstart"in t?!1:w(t.style,"userSelect")),Di){var i=e(t).style,l=i[Di];i[Di]="none"}return function(t){if(o.on(n,null),Di&&(i[Di]=l),t){var e=function(){o.on(a,null)};o.on(a,function(){T(),e()},!0),setTimeout(e,0)}}}function J(t,e){e.changedTouches&&(e=e.changedTouches[0]);var n=t.ownerSVGElement||t;if(n.createSVGPoint){var a=n.createSVGPoint();if(0>Ii){var o=r(t);if(o.scrollX||o.scrollY){n=ui.select("body").append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important");var i=n[0][0].getScreenCTM();Ii=!(i.f||i.e),n.remove()}}return Ii?(a.x=e.pageX,a.y=e.pageY):(a.x=e.clientX,a.y=e.clientY),a=a.matrixTransform(t.getScreenCTM().inverse()),[a.x,a.y]}var l=t.getBoundingClientRect();return[e.clientX-l.left-t.clientLeft,e.clientY-l.top-t.clientTop]}function K(){return ui.event.changedTouches[0].identifier}function tt(t){return t>0?1:0>t?-1:0}function et(t,e,n){return(e[0]-t[0])*(n[1]-t[1])-(e[1]-t[1])*(n[0]-t[0])}function nt(t){return t>1?0:-1>t?Bi:Math.acos(t)}function rt(t){return t>1?Ui:-1>t?-Ui:Math.asin(t)}function at(t){return((t=Math.exp(t))-1/t)/2}function ot(t){return((t=Math.exp(t))+1/t)/2}function it(t){return((t=Math.exp(2*t))-1)/(t+1)}function lt(t){return(t=Math.sin(t/2))*t}function st(){}function ct(t,e,n){return this instanceof ct?(this.h=+t,this.s=+e,void(this.l=+n)):arguments.length<2?t instanceof ct?new ct(t.h,t.s,t.l):kt(""+t,Mt,ct):new ct(t,e,n)}function ut(t,e,n){function r(t){return t>360?t-=360:0>t&&(t+=360),60>t?o+(i-o)*t/60:180>t?i:240>t?o+(i-o)*(240-t)/60:o}function a(t){return Math.round(255*r(t))}var o,i;return t=isNaN(t)?0:(t%=360)<0?t+360:t,e=isNaN(e)?0:0>e?0:e>1?1:e,n=0>n?0:n>1?1:n,i=.5>=n?n*(1+e):n+e-n*e,o=2*n-i,new xt(a(t+120),a(t),a(t-120))}function ft(t,e,n){return this instanceof ft?(this.h=+t,this.c=+e,void(this.l=+n)):arguments.length<2?t instanceof ft?new ft(t.h,t.c,t.l):t instanceof ht?gt(t.l,t.a,t.b):gt((t=At((t=ui.rgb(t)).r,t.g,t.b)).l,t.a,t.b):new ft(t,e,n)}function dt(t,e,n){return isNaN(t)&&(t=0),isNaN(e)&&(e=0),new ht(n,Math.cos(t*=Gi)*e,Math.sin(t)*e)}function ht(t,e,n){return this instanceof ht?(this.l=+t,this.a=+e,void(this.b=+n)):arguments.length<2?t instanceof ht?new ht(t.l,t.a,t.b):t instanceof ft?dt(t.h,t.c,t.l):At((t=xt(t)).r,t.g,t.b):new ht(t,e,n)}function pt(t,e,n){var r=(t+16)/116,a=r+e/500,o=r-n/200;return a=vt(a)*nl,r=vt(r)*rl,o=vt(o)*al,new xt(yt(3.2404542*a-1.5371385*r-.4985314*o),yt(-.969266*a+1.8760108*r+.041556*o),yt(.0556434*a-.2040259*r+1.0572252*o))}function gt(t,e,n){return t>0?new ft(Math.atan2(n,e)*Zi,Math.sqrt(e*e+n*n),t):new ft(NaN,NaN,t)}function vt(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function mt(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function yt(t){return Math.round(255*(.00304>=t?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}function xt(t,e,n){return this instanceof xt?(this.r=~~t,this.g=~~e,void(this.b=~~n)):arguments.length<2?t instanceof xt?new xt(t.r,t.g,t.b):kt(""+t,xt,ut):new xt(t,e,n)}function bt(t){return new xt(t>>16,t>>8&255,255&t)}function _t(t){return bt(t)+""}function wt(t){return 16>t?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function kt(t,e,n){var r,a,o,i=0,l=0,s=0;if(r=/([a-z]+)\((.*)\)/.exec(t=t.toLowerCase()))switch(a=r[2].split(","),r[1]){case"hsl":return n(parseFloat(a[0]),parseFloat(a[1])/100,parseFloat(a[2])/100);case"rgb":return e(Lt(a[0]),Lt(a[1]),Lt(a[2]))}return(o=ll.get(t))?e(o.r,o.g,o.b):(null==t||"#"!==t.charAt(0)||isNaN(o=parseInt(t.slice(1),16))||(4===t.length?(i=(3840&o)>>4,i=i>>4|i,l=240&o,l=l>>4|l,s=15&o,s=s<<4|s):7===t.length&&(i=(16711680&o)>>16, +-l=(65280&o)>>8,s=255&o)),e(i,l,s))}function Mt(t,e,n){var r,a,o=Math.min(t/=255,e/=255,n/=255),i=Math.max(t,e,n),l=i-o,s=(i+o)/2;return l?(a=.5>s?l/(i+o):l/(2-i-o),r=t==i?(e-n)/l+(n>e?6:0):e==i?(n-t)/l+2:(t-e)/l+4,r*=60):(r=NaN,a=s>0&&1>s?0:r),new ct(r,a,s)}function At(t,e,n){t=Tt(t),e=Tt(e),n=Tt(n);var r=mt((.4124564*t+.3575761*e+.1804375*n)/nl),a=mt((.2126729*t+.7151522*e+.072175*n)/rl),o=mt((.0193339*t+.119192*e+.9503041*n)/al);return ht(116*a-16,500*(r-a),200*(a-o))}function Tt(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Lt(t){var e=parseFloat(t);return"%"===t.charAt(t.length-1)?Math.round(2.55*e):e}function zt(t){return"function"==typeof t?t:function(){return t}}function St(t){return function(e,n,r){return 2===arguments.length&&"function"==typeof n&&(r=n,n=null),Ct(e,n,t,r)}}function Ct(t,e,n,r){function a(){var t,e=s.status;if(!e&&Ot(s)||e>=200&&300>e||304===e){try{t=n.call(o,s)}catch(r){return void i.error.call(o,r)}i.load.call(o,t)}else i.error.call(o,s)}var o={},i=ui.dispatch("beforesend","progress","load","error"),l={},s=new XMLHttpRequest,c=null;return!this.XDomainRequest||"withCredentials"in s||!/^(http(s)?:)?\/\//.test(t)||(s=new XDomainRequest),"onload"in s?s.onload=s.onerror=a:s.onreadystatechange=function(){s.readyState>3&&a()},s.onprogress=function(t){var e=ui.event;ui.event=t;try{i.progress.call(o,s)}finally{ui.event=e}},o.header=function(t,e){return t=(t+"").toLowerCase(),arguments.length<2?l[t]:(null==e?delete l[t]:l[t]=e+"",o)},o.mimeType=function(t){return arguments.length?(e=null==t?null:t+"",o):e},o.responseType=function(t){return arguments.length?(c=t,o):c},o.response=function(t){return n=t,o},["get","post"].forEach(function(t){o[t]=function(){return o.send.apply(o,[t].concat(di(arguments)))}}),o.send=function(n,r,a){if(2===arguments.length&&"function"==typeof r&&(a=r,r=null),s.open(n,t,!0),null==e||"accept"in l||(l.accept=e+",*/*"),s.setRequestHeader)for(var u in l)s.setRequestHeader(u,l[u]);return null!=e&&s.overrideMimeType&&s.overrideMimeType(e),null!=c&&(s.responseType=c),null!=a&&o.on("error",a).on("load",function(t){a(null,t)}),i.beforesend.call(o,s),s.send(null==r?null:r),o},o.abort=function(){return s.abort(),o},ui.rebind(o,i,"on"),null==r?o:o.get(Et(r))}function Et(t){return 1===t.length?function(e,n){t(null==e?n:null)}:t}function Ot(t){var e=t.responseType;return e&&"text"!==e?t.response:t.responseText}function Nt(t,e,n){var r=arguments.length;2>r&&(e=0),3>r&&(n=Date.now());var a=n+e,o={c:t,t:a,n:null};return cl?cl.n=o:sl=o,cl=o,ul||(fl=clearTimeout(fl),ul=1,dl(Pt)),o}function Pt(){var t=jt(),e=Dt()-t;e>24?(isFinite(e)&&(clearTimeout(fl),fl=setTimeout(Pt,e)),ul=0):(ul=1,dl(Pt))}function jt(){for(var t=Date.now(),e=sl;e;)t>=e.t&&e.c(t-e.t)&&(e.c=null),e=e.n;return t}function Dt(){for(var t,e=sl,n=1/0;e;)e.c?(e.t8?function(t){return t/n}:function(t){return t*n},symbol:t}}function qt(t){var e=t.decimal,n=t.thousands,r=t.grouping,a=t.currency,o=r&&n?function(t,e){for(var a=t.length,o=[],i=0,l=r[0],s=0;a>0&&l>0&&(s+l+1>e&&(l=Math.max(1,e-s)),o.push(t.substring(a-=l,a+l)),!((s+=l+1)>e));)l=r[i=(i+1)%r.length];return o.reverse().join(n)}:b;return function(t){var n=pl.exec(t),r=n[1]||" ",i=n[2]||">",l=n[3]||"-",s=n[4]||"",c=n[5],u=+n[6],f=n[7],d=n[8],h=n[9],p=1,g="",v="",m=!1,y=!0;switch(d&&(d=+d.substring(1)),(c||"0"===r&&"="===i)&&(c=r="0",i="="),h){case"n":f=!0,h="g";break;case"%":p=100,v="%",h="f";break;case"p":p=100,v="%",h="r";break;case"b":case"o":case"x":case"X":"#"===s&&(g="0"+h.toLowerCase());case"c":y=!1;case"d":m=!0,d=0;break;case"s":p=-1,h="r"}"$"===s&&(g=a[0],v=a[1]),"r"!=h||d||(h="g"),null!=d&&("g"==h?d=Math.max(1,Math.min(21,d)):"e"!=h&&"f"!=h||(d=Math.max(0,Math.min(20,d)))),h=gl.get(h)||Ft;var x=c&&f;return function(t){var n=v;if(m&&t%1)return"";var a=0>t||0===t&&0>1/t?(t=-t,"-"):"-"===l?"":l;if(0>p){var s=ui.formatPrefix(t,d);t=s.scale(t),n=s.symbol+v}else t*=p;t=h(t,d);var b,_,w=t.lastIndexOf(".");if(0>w){var k=y?t.lastIndexOf("e"):-1;0>k?(b=t,_=""):(b=t.substring(0,k),_=t.substring(k))}else b=t.substring(0,w),_=e+t.substring(w+1);!c&&f&&(b=o(b,1/0));var M=g.length+b.length+_.length+(x?0:a.length),A=u>M?new Array(M=u-M+1).join(r):"";return x&&(b=o(A+b,A.length?u-_.length:1/0)),a+=g,t=b+_,("<"===i?a+t+A:">"===i?A+a+t:"^"===i?A.substring(0,M>>=1)+a+t+A.substring(M):a+(x?t:A+t))+n}}}function Ft(t){return t+""}function Bt(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}function Ht(t,e,n){function r(e){var n=t(e),r=o(n,1);return r-e>e-n?n:r}function a(n){return e(n=t(new ml(n-1)),1),n}function o(t,n){return e(t=new ml(+t),n),t}function i(t,r,o){var i=a(t),l=[];if(o>1)for(;r>i;)n(i)%o||l.push(new Date(+i)),e(i,1);else for(;r>i;)l.push(new Date(+i)),e(i,1);return l}function l(t,e,n){try{ml=Bt;var r=new Bt;return r._=t,i(r,e,n)}finally{ml=Date}}t.floor=t,t.round=r,t.ceil=a,t.offset=o,t.range=i;var s=t.utc=Vt(t);return s.floor=s,s.round=Vt(r),s.ceil=Vt(a),s.offset=Vt(o),s.range=l,t}function Vt(t){return function(e,n){try{ml=Bt;var r=new Bt;return r._=e,t(r,n)._}finally{ml=Date}}}function Ut(t){function e(t){function e(e){for(var n,a,o,i=[],l=-1,s=0;++ll;){if(r>=c)return-1;if(a=e.charCodeAt(l++),37===a){if(i=e.charAt(l++),o=S[i in xl?e.charAt(l++):i],!o||(r=o(t,n,r))<0)return-1}else if(a!=n.charCodeAt(r++))return-1}return r}function r(t,e,n){w.lastIndex=0;var r=w.exec(e.slice(n));return r?(t.w=k.get(r[0].toLowerCase()),n+r[0].length):-1}function a(t,e,n){b.lastIndex=0;var r=b.exec(e.slice(n));return r?(t.w=_.get(r[0].toLowerCase()),n+r[0].length):-1}function o(t,e,n){T.lastIndex=0;var r=T.exec(e.slice(n));return r?(t.m=L.get(r[0].toLowerCase()),n+r[0].length):-1}function i(t,e,n){M.lastIndex=0;var r=M.exec(e.slice(n));return r?(t.m=A.get(r[0].toLowerCase()),n+r[0].length):-1}function l(t,e,r){return n(t,z.c.toString(),e,r)}function s(t,e,r){return n(t,z.x.toString(),e,r)}function c(t,e,r){return n(t,z.X.toString(),e,r)}function u(t,e,n){var r=x.get(e.slice(n,n+=2).toLowerCase());return null==r?-1:(t.p=r,n)}var f=t.dateTime,d=t.date,h=t.time,p=t.periods,g=t.days,v=t.shortDays,m=t.months,y=t.shortMonths;e.utc=function(t){function n(t){try{ml=Bt;var e=new ml;return e._=t,r(e)}finally{ml=Date}}var r=e(t);return n.parse=function(t){try{ml=Bt;var e=r.parse(t);return e&&e._}finally{ml=Date}},n.toString=r.toString,n},e.multi=e.utc.multi=ue;var x=ui.map(),b=Zt(g),_=Yt(g),w=Zt(v),k=Yt(v),M=Zt(m),A=Yt(m),T=Zt(y),L=Yt(y);p.forEach(function(t,e){x.set(t.toLowerCase(),e)});var z={a:function(t){return v[t.getDay()]},A:function(t){return g[t.getDay()]},b:function(t){return y[t.getMonth()]},B:function(t){return m[t.getMonth()]},c:e(f),d:function(t,e){return Gt(t.getDate(),e,2)},e:function(t,e){return Gt(t.getDate(),e,2)},H:function(t,e){return Gt(t.getHours(),e,2)},I:function(t,e){return Gt(t.getHours()%12||12,e,2)},j:function(t,e){return Gt(1+vl.dayOfYear(t),e,3)},L:function(t,e){return Gt(t.getMilliseconds(),e,3)},m:function(t,e){return Gt(t.getMonth()+1,e,2)},M:function(t,e){return Gt(t.getMinutes(),e,2)},p:function(t){return p[+(t.getHours()>=12)]},S:function(t,e){return Gt(t.getSeconds(),e,2)},U:function(t,e){return Gt(vl.sundayOfYear(t),e,2)},w:function(t){return t.getDay()},W:function(t,e){return Gt(vl.mondayOfYear(t),e,2)},x:e(d),X:e(h),y:function(t,e){return Gt(t.getFullYear()%100,e,2)},Y:function(t,e){return Gt(t.getFullYear()%1e4,e,4)},Z:se,"%":function(){return"%"}},S={a:r,A:a,b:o,B:i,c:l,d:ne,e:ne,H:ae,I:ae,j:re,L:le,m:ee,M:oe,p:u,S:ie,U:Qt,w:Xt,W:$t,x:s,X:c,y:Jt,Y:Wt,Z:Kt,"%":ce};return e}function Gt(t,e,n){var r=0>t?"-":"",a=(r?-t:t)+"",o=a.length;return r+(n>o?new Array(n-o+1).join(e)+a:a)}function Zt(t){return new RegExp("^(?:"+t.map(ui.requote).join("|")+")","i")}function Yt(t){for(var e=new f,n=-1,r=t.length;++n68?1900:2e3)}function ee(t,e,n){bl.lastIndex=0;var r=bl.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function ne(t,e,n){bl.lastIndex=0;var r=bl.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function re(t,e,n){bl.lastIndex=0;var r=bl.exec(e.slice(n,n+3));return r?(t.j=+r[0],n+r[0].length):-1}function ae(t,e,n){bl.lastIndex=0;var r=bl.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function oe(t,e,n){bl.lastIndex=0;var r=bl.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function ie(t,e,n){bl.lastIndex=0;var r=bl.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function le(t,e,n){bl.lastIndex=0;var r=bl.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function se(t){var e=t.getTimezoneOffset(),n=e>0?"-":"+",r=wi(e)/60|0,a=wi(e)%60;return n+Gt(r,"0",2)+Gt(a,"0",2)}function ce(t,e,n){_l.lastIndex=0;var r=_l.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function ue(t){for(var e=t.length,n=-1;++n=0?1:-1,l=i*n,s=Math.cos(e),c=Math.sin(e),u=o*c,f=a*s+u*Math.cos(l),d=u*i*Math.sin(l);Ll.add(Math.atan2(d,f)),r=t,a=s,o=c}var e,n,r,a,o;zl.point=function(i,l){zl.point=t,r=(e=i)*Gi,a=Math.cos(l=(n=l)*Gi/2+Bi/4),o=Math.sin(l)},zl.lineEnd=function(){t(e,n)}}function me(t){var e=t[0],n=t[1],r=Math.cos(n);return[r*Math.cos(e),r*Math.sin(e),Math.sin(n)]}function ye(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function xe(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function be(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function _e(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function we(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function ke(t){return[Math.atan2(t[1],t[0]),rt(t[2])]}function Me(t,e){return wi(t[0]-e[0])l;++l)a.point((n=t[l])[0],n[1]);return void a.lineEnd()}var s=new Pe(n,t,null,!0),c=new Pe(n,null,s,!1);s.o=c,o.push(s),i.push(c),s=new Pe(r,t,null,!1),c=new Pe(r,null,s,!0),s.o=c,o.push(s),i.push(c)}}),i.sort(e),Ne(o),Ne(i),o.length){for(var l=0,s=n,c=i.length;c>l;++l)i[l].e=s=!s;for(var u,f,d=o[0];;){for(var h=d,p=!0;h.v;)if((h=h.n)===d)return;u=h.z,a.lineStart();do{if(h.v=h.o.v=!0,h.e){if(p)for(var l=0,c=u.length;c>l;++l)a.point((f=u[l])[0],f[1]);else r(h.x,h.n.x,1,a);h=h.n}else{if(p){u=h.p.z;for(var l=u.length-1;l>=0;--l)a.point((f=u[l])[0],f[1])}else r(h.x,h.p.x,-1,a);h=h.p}h=h.o,u=h.z,p=!p}while(!h.v);a.lineEnd()}}}function Ne(t){if(e=t.length){for(var e,n,r=0,a=t[0];++r0){for(_||(o.polygonStart(),_=!0),o.lineStart();++i1&&2&e&&n.push(n.pop().concat(n.shift())),h.push(n.filter(De))}var h,p,g,v=e(o),m=a.invert(r[0],r[1]),y={point:i,lineStart:s,lineEnd:c,polygonStart:function(){y.point=u,y.lineStart=f,y.lineEnd=d,h=[],p=[]},polygonEnd:function(){y.point=i,y.lineStart=s,y.lineEnd=c,h=ui.merge(h);var t=He(m,p);h.length?(_||(o.polygonStart(),_=!0),Oe(h,Ie,t,n,o)):t&&(_||(o.polygonStart(),_=!0),o.lineStart(),n(null,null,1,o),o.lineEnd()),_&&(o.polygonEnd(),_=!1),h=p=null},sphere:function(){o.polygonStart(),o.lineStart(),n(null,null,1,o),o.lineEnd(),o.polygonEnd()}},x=Re(),b=e(x),_=!1;return y}}function De(t){return t.length>1}function Re(){var t,e=[];return{lineStart:function(){e.push(t=[])},point:function(e,n){t.push([e,n])},lineEnd:k,buffer:function(){var n=e;return e=[],t=null,n},rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))}}}function Ie(t,e){return((t=t.x)[0]<0?t[1]-Ui-qi:Ui-t[1])-((e=e.x)[0]<0?e[1]-Ui-qi:Ui-e[1])}function qe(t){var e,n=NaN,r=NaN,a=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(o,i){var l=o>0?Bi:-Bi,s=wi(o-n);wi(s-Bi)0?Ui:-Ui),t.point(a,r),t.lineEnd(),t.lineStart(),t.point(l,r),t.point(o,r),e=0):a!==l&&s>=Bi&&(wi(n-a)qi?Math.atan((Math.sin(e)*(o=Math.cos(r))*Math.sin(n)-Math.sin(r)*(a=Math.cos(e))*Math.sin(t))/(a*o*i)):(e+r)/2}function Be(t,e,n,r){var a;if(null==t)a=n*Ui,r.point(-Bi,a),r.point(0,a),r.point(Bi,a),r.point(Bi,0),r.point(Bi,-a),r.point(0,-a),r.point(-Bi,-a),r.point(-Bi,0),r.point(-Bi,a);else if(wi(t[0]-e[0])>qi){var o=t[0]l;++l){var c=e[l],u=c.length;if(u)for(var f=c[0],d=f[0],h=f[1]/2+Bi/4,p=Math.sin(h),g=Math.cos(h),v=1;;){v===u&&(v=0),t=c[v];var m=t[0],y=t[1]/2+Bi/4,x=Math.sin(y),b=Math.cos(y),_=m-d,w=_>=0?1:-1,k=w*_,M=k>Bi,A=p*x;if(Ll.add(Math.atan2(A*w*Math.sin(k),g*b+A*Math.cos(k))),o+=M?_+w*Hi:_,M^d>=n^m>=n){var T=xe(me(f),me(t));we(T);var L=xe(a,T);we(L);var z=(M^_>=0?-1:1)*rt(L[2]);(r>z||r===z&&(T[0]||T[1]))&&(i+=M^_>=0?1:-1)}if(!v++)break;d=m,p=x,g=b,f=t}}return(-qi>o||qi>o&&0>Ll)^1&i}function Ve(t){function e(t,e){return Math.cos(t)*Math.cos(e)>o}function n(t){var n,o,s,c,u;return{lineStart:function(){c=s=!1,u=1},point:function(f,d){var h,p=[f,d],g=e(f,d),v=i?g?0:a(f,d):g?a(f+(0>f?Bi:-Bi),d):0;if(!n&&(c=s=g)&&t.lineStart(),g!==s&&(h=r(n,p),(Me(n,h)||Me(p,h))&&(p[0]+=qi,p[1]+=qi,g=e(p[0],p[1]))),g!==s)u=0,g?(t.lineStart(),h=r(p,n),t.point(h[0],h[1])):(h=r(n,p),t.point(h[0],h[1]),t.lineEnd()),n=h;else if(l&&n&&i^g){var m;v&o||!(m=r(p,n,!0))||(u=0,i?(t.lineStart(),t.point(m[0][0],m[0][1]),t.point(m[1][0],m[1][1]),t.lineEnd()):(t.point(m[1][0],m[1][1]),t.lineEnd(),t.lineStart(),t.point(m[0][0],m[0][1])))}!g||n&&Me(n,p)||t.point(p[0],p[1]),n=p,s=g,o=v},lineEnd:function(){s&&t.lineEnd(),n=null},clean:function(){return u|(c&&s)<<1}}}function r(t,e,n){var r=me(t),a=me(e),i=[1,0,0],l=xe(r,a),s=ye(l,l),c=l[0],u=s-c*c;if(!u)return!n&&t;var f=o*s/u,d=-o*c/u,h=xe(i,l),p=_e(i,f),g=_e(l,d);be(p,g);var v=h,m=ye(p,v),y=ye(v,v),x=m*m-y*(ye(p,p)-1);if(!(0>x)){var b=Math.sqrt(x),_=_e(v,(-m-b)/y);if(be(_,p),_=ke(_),!n)return _;var w,k=t[0],M=e[0],A=t[1],T=e[1];k>M&&(w=k,k=M,M=w);var L=M-k,z=wi(L-Bi)L;if(!z&&A>T&&(w=A,A=T,T=w),S?z?A+T>0^_[1]<(wi(_[0]-k)Bi^(k<=_[0]&&_[0]<=M)){var C=_e(v,(-m+b)/y);return be(C,p),[_,ke(C)]}}}function a(e,n){var r=i?t:Bi-t,a=0;return-r>e?a|=1:e>r&&(a|=2),-r>n?a|=4:n>r&&(a|=8),a}var o=Math.cos(t),i=o>0,l=wi(o)>qi,s=mn(t,6*Gi);return je(e,n,s,i?[0,-t]:[-Bi,t-Bi])}function Ue(t,e,n,r){return function(a){var o,i=a.a,l=a.b,s=i.x,c=i.y,u=l.x,f=l.y,d=0,h=1,p=u-s,g=f-c;if(o=t-s,p||!(o>0)){if(o/=p,0>p){if(d>o)return;h>o&&(h=o)}else if(p>0){if(o>h)return;o>d&&(d=o)}if(o=n-s,p||!(0>o)){if(o/=p,0>p){if(o>h)return;o>d&&(d=o)}else if(p>0){if(d>o)return;h>o&&(h=o)}if(o=e-c,g||!(o>0)){if(o/=g,0>g){if(d>o)return;h>o&&(h=o)}else if(g>0){if(o>h)return;o>d&&(d=o)}if(o=r-c,g||!(0>o)){if(o/=g,0>g){if(o>h)return;o>d&&(d=o)}else if(g>0){if(d>o)return;h>o&&(h=o)}return d>0&&(a.a={x:s+d*p,y:c+d*g}),1>h&&(a.b={x:s+h*p,y:c+h*g}),a}}}}}}function Ge(t,e,n,r){function a(r,a){return wi(r[0]-t)0?0:3:wi(r[0]-n)0?2:1:wi(r[1]-e)0?1:0:a>0?3:2}function o(t,e){return i(t.x,e.x)}function i(t,e){var n=a(t,1),r=a(e,1);return n!==r?n-r:0===n?e[1]-t[1]:1===n?t[0]-e[0]:2===n?t[1]-e[1]:e[0]-t[0]}return function(l){function s(t){for(var e=0,n=v.length,r=t[1],a=0;n>a;++a)for(var o,i=1,l=v[a],s=l.length,c=l[0];s>i;++i)o=l[i],c[1]<=r?o[1]>r&&et(c,o,t)>0&&++e:o[1]<=r&&et(c,o,t)<0&&--e,c=o;return 0!==e}function c(o,l,s,c){var u=0,f=0;if(null==o||(u=a(o,s))!==(f=a(l,s))||i(o,l)<0^s>0){do c.point(0===u||3===u?t:n,u>1?r:e);while((u=(u+s+4)%4)!==f)}else c.point(l[0],l[1])}function u(a,o){return a>=t&&n>=a&&o>=e&&r>=o}function f(t,e){u(t,e)&&l.point(t,e)}function d(){S.point=p,v&&v.push(m=[]),M=!0,k=!1,_=w=NaN}function h(){g&&(p(y,x),b&&k&&L.rejoin(),g.push(L.buffer())),S.point=f,k&&l.lineEnd()}function p(t,e){t=Math.max(-Hl,Math.min(Hl,t)),e=Math.max(-Hl,Math.min(Hl,e));var n=u(t,e);if(v&&m.push([t,e]),M)y=t,x=e,b=n,M=!1,n&&(l.lineStart(),l.point(t,e));else if(n&&k)l.point(t,e);else{var r={a:{x:_,y:w},b:{x:t,y:e}};z(r)?(k||(l.lineStart(),l.point(r.a.x,r.a.y)),l.point(r.b.x,r.b.y),n||l.lineEnd(),A=!1):n&&(l.lineStart(),l.point(t,e),A=!1)}_=t,w=e,k=n}var g,v,m,y,x,b,_,w,k,M,A,T=l,L=Re(),z=Ue(t,e,n,r),S={point:f,lineStart:d,lineEnd:h,polygonStart:function(){l=L,g=[],v=[],A=!0},polygonEnd:function(){l=T,g=ui.merge(g);var e=s([t,r]),n=A&&e,a=g.length;(n||a)&&(l.polygonStart(),n&&(l.lineStart(),c(null,null,1,l),l.lineEnd()),a&&Oe(g,o,e,c,l),l.polygonEnd()),g=v=m=null}};return S}}function Ze(t){var e=0,n=Bi/3,r=cn(t),a=r(e,n);return a.parallels=function(t){return arguments.length?r(e=t[0]*Bi/180,n=t[1]*Bi/180):[e/Bi*180,n/Bi*180]},a}function Ye(t,e){function n(t,e){var n=Math.sqrt(o-2*a*Math.sin(e))/a;return[n*Math.sin(t*=a),i-n*Math.cos(t)]}var r=Math.sin(t),a=(r+Math.sin(e))/2,o=1+r*(2*a-r),i=Math.sqrt(o)/a;return n.invert=function(t,e){var n=i-e;return[Math.atan2(t,n)/a,rt((o-(t*t+n*n)*a*a)/(2*a))]},n}function Xe(){function t(t,e){Ul+=a*t-r*e,r=t,a=e}var e,n,r,a;Ql.point=function(o,i){Ql.point=t,e=r=o,n=a=i},Ql.lineEnd=function(){t(e,n)}}function Qe(t,e){Gl>t&&(Gl=t),t>Yl&&(Yl=t),Zl>e&&(Zl=e),e>Xl&&(Xl=e)}function $e(){function t(t,e){i.push("M",t,",",e,o)}function e(t,e){i.push("M",t,",",e),l.point=n}function n(t,e){i.push("L",t,",",e)}function r(){l.point=t}function a(){i.push("Z")}var o=We(4.5),i=[],l={point:t,lineStart:function(){l.point=e},lineEnd:r,polygonStart:function(){l.lineEnd=a},polygonEnd:function(){l.lineEnd=r,l.point=t},pointRadius:function(t){return o=We(t),l},result:function(){if(i.length){var t=i.join("");return i=[],t}}};return l}function We(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}function Je(t,e){El+=t,Ol+=e,++Nl}function Ke(){function t(t,r){var a=t-e,o=r-n,i=Math.sqrt(a*a+o*o);Pl+=i*(e+t)/2,jl+=i*(n+r)/2,Dl+=i,Je(e=t,n=r)}var e,n;Wl.point=function(r,a){Wl.point=t,Je(e=r,n=a)}}function tn(){Wl.point=Je}function en(){function t(t,e){var n=t-r,o=e-a,i=Math.sqrt(n*n+o*o);Pl+=i*(r+t)/2,jl+=i*(a+e)/2,Dl+=i,i=a*t-r*e,Rl+=i*(r+t),Il+=i*(a+e),ql+=3*i,Je(r=t,a=e)}var e,n,r,a;Wl.point=function(o,i){Wl.point=t,Je(e=r=o,n=a=i)},Wl.lineEnd=function(){t(e,n)}}function nn(t){function e(e,n){t.moveTo(e+i,n),t.arc(e,n,i,0,Hi)}function n(e,n){t.moveTo(e,n),l.point=r}function r(e,n){t.lineTo(e,n)}function a(){l.point=e}function o(){t.closePath()}var i=4.5,l={point:e,lineStart:function(){l.point=n},lineEnd:a,polygonStart:function(){l.lineEnd=o},polygonEnd:function(){l.lineEnd=a,l.point=e},pointRadius:function(t){return i=t,l},result:k};return l}function rn(t){function e(t){return(l?r:n)(t)}function n(e){return ln(e,function(n,r){n=t(n,r),e.point(n[0],n[1])})}function r(e){function n(n,r){n=t(n,r),e.point(n[0],n[1])}function r(){x=NaN,M.point=o,e.lineStart()}function o(n,r){var o=me([n,r]),i=t(n,r);a(x,b,y,_,w,k,x=i[0],b=i[1],y=n,_=o[0],w=o[1],k=o[2],l,e),e.point(x,b)}function i(){M.point=n,e.lineEnd()}function s(){r(),M.point=c,M.lineEnd=u}function c(t,e){o(f=t,d=e),h=x,p=b,g=_,v=w,m=k,M.point=o}function u(){a(x,b,y,_,w,k,h,p,f,g,v,m,l,e),M.lineEnd=i,i()}var f,d,h,p,g,v,m,y,x,b,_,w,k,M={point:n,lineStart:r,lineEnd:i,polygonStart:function(){e.polygonStart(),M.lineStart=s},polygonEnd:function(){e.polygonEnd(),M.lineStart=r}};return M}function a(e,n,r,l,s,c,u,f,d,h,p,g,v,m){var y=u-e,x=f-n,b=y*y+x*x;if(b>4*o&&v--){var _=l+h,w=s+p,k=c+g,M=Math.sqrt(_*_+w*w+k*k),A=Math.asin(k/=M),T=wi(wi(k)-1)o||wi((y*C+x*E)/b-.5)>.3||i>l*h+s*p+c*g)&&(a(e,n,r,l,s,c,z,S,T,_/=M,w/=M,k,v,m),m.point(z,S),a(z,S,T,_,w,k,u,f,d,h,p,g,v,m))}}var o=.5,i=Math.cos(30*Gi),l=16;return e.precision=function(t){return arguments.length?(l=(o=t*t)>0&&16,e):Math.sqrt(o)},e}function an(t){var e=rn(function(e,n){return t([e*Zi,n*Zi])});return function(t){return un(e(t))}}function on(t){this.stream=t}function ln(t,e){return{point:e,sphere:function(){t.sphere()},lineStart:function(){t.lineStart()},lineEnd:function(){t.lineEnd()},polygonStart:function(){t.polygonStart()},polygonEnd:function(){t.polygonEnd()}}}function sn(t){return cn(function(){return t})()}function cn(t){function e(t){return t=l(t[0]*Gi,t[1]*Gi),[t[0]*d+s,c-t[1]*d]}function n(t){return t=l.invert((t[0]-s)/d,(c-t[1])/d),t&&[t[0]*Zi,t[1]*Zi]}function r(){l=Ce(i=hn(m,y,x),o);var t=o(g,v);return s=h-t[0]*d,c=p+t[1]*d,a()}function a(){return u&&(u.valid=!1,u=null),e}var o,i,l,s,c,u,f=rn(function(t,e){return t=o(t,e),[t[0]*d+s,c-t[1]*d]}),d=150,h=480,p=250,g=0,v=0,m=0,y=0,x=0,_=Bl,w=b,k=null,M=null;return e.stream=function(t){return u&&(u.valid=!1),u=un(_(i,f(w(t)))),u.valid=!0,u},e.clipAngle=function(t){return arguments.length?(_=null==t?(k=t,Bl):Ve((k=+t)*Gi),a()):k},e.clipExtent=function(t){return arguments.length?(M=t,w=t?Ge(t[0][0],t[0][1],t[1][0],t[1][1]):b,a()):M},e.scale=function(t){return arguments.length?(d=+t,r()):d},e.translate=function(t){return arguments.length?(h=+t[0],p=+t[1],r()):[h,p]},e.center=function(t){return arguments.length?(g=t[0]%360*Gi,v=t[1]%360*Gi,r()):[g*Zi,v*Zi]},e.rotate=function(t){return arguments.length?(m=t[0]%360*Gi,y=t[1]%360*Gi,x=t.length>2?t[2]%360*Gi:0,r()):[m*Zi,y*Zi,x*Zi]},ui.rebind(e,f,"precision"),function(){return o=t.apply(this,arguments),e.invert=o.invert&&n,r()}}function un(t){return ln(t,function(e,n){t.point(e*Gi,n*Gi)})}function fn(t,e){return[t,e]}function dn(t,e){return[t>Bi?t-Hi:-Bi>t?t+Hi:t,e]}function hn(t,e,n){return t?e||n?Ce(gn(t),vn(e,n)):gn(t):e||n?vn(e,n):dn}function pn(t){return function(e,n){return e+=t,[e>Bi?e-Hi:-Bi>e?e+Hi:e,n]}}function gn(t){var e=pn(t);return e.invert=pn(-t),e}function vn(t,e){function n(t,e){var n=Math.cos(e),l=Math.cos(t)*n,s=Math.sin(t)*n,c=Math.sin(e),u=c*r+l*a;return[Math.atan2(s*o-u*i,l*r-c*a),rt(u*o+s*i)]}var r=Math.cos(t),a=Math.sin(t),o=Math.cos(e),i=Math.sin(e);return n.invert=function(t,e){var n=Math.cos(e),l=Math.cos(t)*n,s=Math.sin(t)*n,c=Math.sin(e),u=c*o-s*i;return[Math.atan2(s*o+c*i,l*r+u*a),rt(u*r-l*a)]},n}function mn(t,e){var n=Math.cos(t),r=Math.sin(t);return function(a,o,i,l){var s=i*e;null!=a?(a=yn(n,a),o=yn(n,o),(i>0?o>a:a>o)&&(a+=i*Hi)):(a=t+i*Hi,o=t-.5*s);for(var c,u=a;i>0?u>o:o>u;u-=s)l.point((c=ke([n,-r*Math.cos(u),-r*Math.sin(u)]))[0],c[1])}}function yn(t,e){var n=me(e);n[0]-=t,we(n);var r=nt(-n[1]);return((-n[2]<0?-r:r)+2*Math.PI-qi)%(2*Math.PI)}function xn(t,e,n){var r=ui.range(t,e-qi,n).concat(e);return function(t){return r.map(function(e){return[t,e]})}}function bn(t,e,n){var r=ui.range(t,e-qi,n).concat(e);return function(t){return r.map(function(e){return[e,t]})}}function _n(t){return t.source}function wn(t){return t.target}function kn(t,e,n,r){var a=Math.cos(e),o=Math.sin(e),i=Math.cos(r),l=Math.sin(r),s=a*Math.cos(t),c=a*Math.sin(t),u=i*Math.cos(n),f=i*Math.sin(n),d=2*Math.asin(Math.sqrt(lt(r-e)+a*i*lt(n-t))),h=1/Math.sin(d),p=d?function(t){var e=Math.sin(t*=d)*h,n=Math.sin(d-t)*h,r=n*s+e*u,a=n*c+e*f,i=n*o+e*l;return[Math.atan2(a,r)*Zi,Math.atan2(i,Math.sqrt(r*r+a*a))*Zi]}:function(){return[t*Zi,e*Zi]};return p.distance=d,p}function Mn(){function t(t,a){var o=Math.sin(a*=Gi),i=Math.cos(a),l=wi((t*=Gi)-e),s=Math.cos(l);Jl+=Math.atan2(Math.sqrt((l=i*Math.sin(l))*l+(l=r*o-n*i*s)*l),n*o+r*i*s),e=t,n=o,r=i}var e,n,r;Kl.point=function(a,o){e=a*Gi,n=Math.sin(o*=Gi),r=Math.cos(o),Kl.point=t},Kl.lineEnd=function(){Kl.point=Kl.lineEnd=k}}function An(t,e){function n(e,n){var r=Math.cos(e),a=Math.cos(n),o=t(r*a);return[o*a*Math.sin(e),o*Math.sin(n)]}return n.invert=function(t,n){var r=Math.sqrt(t*t+n*n),a=e(r),o=Math.sin(a),i=Math.cos(a);return[Math.atan2(t*o,r*i),Math.asin(r&&n*o/r)]},n}function Tn(t,e){function n(t,e){i>0?-Ui+qi>e&&(e=-Ui+qi):e>Ui-qi&&(e=Ui-qi);var n=i/Math.pow(a(e),o);return[n*Math.sin(o*t),i-n*Math.cos(o*t)]}var r=Math.cos(t),a=function(t){return Math.tan(Bi/4+t/2)},o=t===e?Math.sin(t):Math.log(r/Math.cos(e))/Math.log(a(e)/a(t)),i=r*Math.pow(a(t),o)/o;return o?(n.invert=function(t,e){var n=i-e,r=tt(o)*Math.sqrt(t*t+n*n);return[Math.atan2(t,n)/o,2*Math.atan(Math.pow(i/r,1/o))-Ui]},n):zn}function Ln(t,e){function n(t,e){var n=o-e;return[n*Math.sin(a*t),o-n*Math.cos(a*t)]}var r=Math.cos(t),a=t===e?Math.sin(t):(r-Math.cos(e))/(e-t),o=r/a+t;return wi(a)a;a++){for(;r>1&&et(t[n[r-2]],t[n[r-1]],t[a])<=0;)--r;n[r++]=a}return n.slice(0,r)}function Pn(t,e){return t[0]-e[0]||t[1]-e[1]}function jn(t,e,n){return(n[0]-e[0])*(t[1]-e[1])<(n[1]-e[1])*(t[0]-e[0])}function Dn(t,e,n,r){var a=t[0],o=n[0],i=e[0]-a,l=r[0]-o,s=t[1],c=n[1],u=e[1]-s,f=r[1]-c,d=(l*(s-c)-f*(a-o))/(f*i-l*u);return[a+d*i,s+d*u]}function Rn(t){var e=t[0],n=t[t.length-1];return!(e[0]-n[0]||e[1]-n[1])}function In(){or(this),this.edge=this.site=this.circle=null}function qn(t){var e=fs.pop()||new In;return e.site=t,e}function Fn(t){$n(t),ss.remove(t),fs.push(t),or(t)}function Bn(t){var e=t.circle,n=e.x,r=e.cy,a={x:n,y:r},o=t.P,i=t.N,l=[t];Fn(t);for(var s=o;s.circle&&wi(n-s.circle.x)u;++u)c=l[u],s=l[u-1],nr(c.edge,s.site,c.site,a);s=l[0],c=l[f-1],c.edge=tr(s.site,c.site,null,a),Qn(s),Qn(c)}function Hn(t){for(var e,n,r,a,o=t.x,i=t.y,l=ss._;l;)if(r=Vn(l,i)-o,r>qi)l=l.L;else{if(a=o-Un(l,i),!(a>qi)){r>-qi?(e=l.P,n=l):a>-qi?(e=l,n=l.N):e=n=l;break}if(!l.R){e=l;break}l=l.R}var s=qn(t);if(ss.insert(e,s),e||n){if(e===n)return $n(e),n=qn(e.site),ss.insert(s,n),s.edge=n.edge=tr(e.site,s.site),Qn(e),void Qn(n);if(!n)return void(s.edge=tr(e.site,s.site));$n(e),$n(n);var c=e.site,u=c.x,f=c.y,d=t.x-u,h=t.y-f,p=n.site,g=p.x-u,v=p.y-f,m=2*(d*v-h*g),y=d*d+h*h,x=g*g+v*v,b={x:(v*y-h*x)/m+u,y:(d*x-g*y)/m+f};nr(n.edge,c,p,b),s.edge=tr(c,t,null,b),n.edge=tr(t,p,null,b),Qn(e),Qn(n)}}function Vn(t,e){var n=t.site,r=n.x,a=n.y,o=a-e;if(!o)return r;var i=t.P;if(!i)return-(1/0);n=i.site;var l=n.x,s=n.y,c=s-e;if(!c)return l;var u=l-r,f=1/o-1/c,d=u/c;return f?(-d+Math.sqrt(d*d-2*f*(u*u/(-2*c)-s+c/2+a-o/2)))/f+r:(r+l)/2}function Un(t,e){var n=t.N;if(n)return Vn(n,e);var r=t.site;return r.y===e?r.x:1/0}function Gn(t){this.site=t,this.edges=[]}function Zn(t){for(var e,n,r,a,o,i,l,s,c,u,f=t[0][0],d=t[1][0],h=t[0][1],p=t[1][1],g=ls,v=g.length;v--;)if(o=g[v],o&&o.prepare())for(l=o.edges,s=l.length,i=0;s>i;)u=l[i].end(),r=u.x,a=u.y,c=l[++i%s].start(),e=c.x,n=c.y,(wi(r-e)>qi||wi(a-n)>qi)&&(l.splice(i,0,new rr(er(o.site,u,wi(r-f)qi?{x:f,y:wi(e-f)qi?{x:wi(n-p)qi?{x:d,y:wi(e-d)qi?{x:wi(n-h)=-Fi)){var h=s*s+c*c,p=u*u+f*f,g=(f*h-c*p)/d,v=(s*p-u*h)/d,f=v+l,m=ds.pop()||new Xn;m.arc=t,m.site=a,m.x=g+i,m.y=f+Math.sqrt(g*g+v*v),m.cy=f,t.circle=m;for(var y=null,x=us._;x;)if(m.yv||v>=l)return;if(d>p){if(o){if(o.y>=c)return}else o={x:v,y:s};n={x:v,y:c}}else{if(o){if(o.yr||r>1)if(d>p){if(o){if(o.y>=c)return}else o={x:(s-a)/r,y:s};n={x:(c-a)/r,y:c}}else{if(o){if(o.yh){if(o){if(o.x>=l)return}else o={x:i,y:r*i+a};n={x:l,y:r*l+a}}else{if(o){if(o.xo||f>i||r>d||a>h)){if(p=t.point){var p,g=e-t.x,v=n-t.y,m=g*g+v*v;if(s>m){var y=Math.sqrt(s=m);r=e-y,a=n-y,o=e+y,i=n+y,l=p}}for(var x=t.nodes,b=.5*(u+d),_=.5*(f+h),w=e>=b,k=n>=_,M=k<<1|w,A=M+4;A>M;++M)if(t=x[3&M])switch(3&M){case 0:c(t,u,f,b,_);break;case 1:c(t,b,f,d,_);break;case 2:c(t,u,_,b,h);break;case 3:c(t,b,_,d,h)}}}(t,r,a,o,i),l}function mr(t,e){t=ui.rgb(t),e=ui.rgb(e);var n=t.r,r=t.g,a=t.b,o=e.r-n,i=e.g-r,l=e.b-a;return function(t){return"#"+wt(Math.round(n+o*t))+wt(Math.round(r+i*t))+wt(Math.round(a+l*t))}}function yr(t,e){var n,r={},a={};for(n in t)n in e?r[n]=_r(t[n],e[n]):a[n]=t[n];for(n in e)n in t||(a[n]=e[n]);return function(t){for(n in r)a[n]=r[n](t);return a}}function xr(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function br(t,e){var n,r,a,o=ps.lastIndex=gs.lastIndex=0,i=-1,l=[],s=[];for(t+="",e+="";(n=ps.exec(t))&&(r=gs.exec(e));)(a=r.index)>o&&(a=e.slice(o,a),l[i]?l[i]+=a:l[++i]=a),(n=n[0])===(r=r[0])?l[i]?l[i]+=r:l[++i]=r:(l[++i]=null,s.push({i:i,x:xr(n,r)})),o=gs.lastIndex;return or;++r)l[(n=s[r]).i]=n.x(t);return l.join("")})}function _r(t,e){for(var n,r=ui.interpolators.length;--r>=0&&!(n=ui.interpolators[r](t,e)););return n}function wr(t,e){var n,r=[],a=[],o=t.length,i=e.length,l=Math.min(t.length,e.length);for(n=0;l>n;++n)r.push(_r(t[n],e[n]));for(;o>n;++n)a[n]=t[n];for(;i>n;++n)a[n]=e[n];return function(t){for(n=0;l>n;++n)a[n]=r[n](t);return a}}function kr(t){return function(e){return 0>=e?0:e>=1?1:t(e)}}function Mr(t){return function(e){return 1-t(1-e)}}function Ar(t){return function(e){return.5*(.5>e?t(2*e):2-t(2-2*e))}}function Tr(t){return t*t}function Lr(t){return t*t*t}function zr(t){if(0>=t)return 0;if(t>=1)return 1;var e=t*t,n=e*t;return 4*(.5>t?n:3*(t-e)+n-.75)}function Sr(t){return function(e){return Math.pow(e,t)}}function Cr(t){return 1-Math.cos(t*Ui)}function Er(t){return Math.pow(2,10*(t-1))}function Or(t){return 1-Math.sqrt(1-t*t)}function Nr(t,e){var n;return arguments.length<2&&(e=.45),arguments.length?n=e/Hi*Math.asin(1/t):(t=1,n=e/4),function(r){return 1+t*Math.pow(2,-10*r)*Math.sin((r-n)*Hi/e)}}function Pr(t){return t||(t=1.70158),function(e){return e*e*((t+1)*e-t)}}function jr(t){return 1/2.75>t?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}function Dr(t,e){t=ui.hcl(t),e=ui.hcl(e);var n=t.h,r=t.c,a=t.l,o=e.h-n,i=e.c-r,l=e.l-a;return isNaN(i)&&(i=0,r=isNaN(r)?e.c:r),isNaN(o)?(o=0,n=isNaN(n)?e.h:n):o>180?o-=360:-180>o&&(o+=360),function(t){return dt(n+o*t,r+i*t,a+l*t)+""}}function Rr(t,e){t=ui.hsl(t),e=ui.hsl(e);var n=t.h,r=t.s,a=t.l,o=e.h-n,i=e.s-r,l=e.l-a;return isNaN(i)&&(i=0,r=isNaN(r)?e.s:r),isNaN(o)?(o=0,n=isNaN(n)?e.h:n):o>180?o-=360:-180>o&&(o+=360),function(t){return ut(n+o*t,r+i*t,a+l*t)+""}}function Ir(t,e){t=ui.lab(t),e=ui.lab(e);var n=t.l,r=t.a,a=t.b,o=e.l-n,i=e.a-r,l=e.b-a;return function(t){return pt(n+o*t,r+i*t,a+l*t)+""}}function qr(t,e){return e-=t,function(n){return Math.round(t+e*n)}}function Fr(t){var e=[t.a,t.b],n=[t.c,t.d],r=Hr(e),a=Br(e,n),o=Hr(Vr(n,e,-a))||0;e[0]*n[1]180?e+=360:e-t>180&&(t+=360),r.push({i:n.push(Ur(n)+"rotate(",null,")")-2,x:xr(t,e)})):e&&n.push(Ur(n)+"rotate("+e+")")}function Yr(t,e,n,r){t!==e?r.push({i:n.push(Ur(n)+"skewX(",null,")")-2,x:xr(t,e)}):e&&n.push(Ur(n)+"skewX("+e+")")}function Xr(t,e,n,r){if(t[0]!==e[0]||t[1]!==e[1]){var a=n.push(Ur(n)+"scale(",null,",",null,")");r.push({i:a-4,x:xr(t[0],e[0])},{i:a-2,x:xr(t[1],e[1])})}else 1===e[0]&&1===e[1]||n.push(Ur(n)+"scale("+e+")")}function Qr(t,e){var n=[],r=[];return t=ui.transform(t),e=ui.transform(e),Gr(t.translate,e.translate,n,r),Zr(t.rotate,e.rotate,n,r),Yr(t.skew,e.skew,n,r),Xr(t.scale,e.scale,n,r),t=e=null,function(t){for(var e,a=-1,o=r.length;++a=0;)n.push(a[r])}function sa(t,e){for(var n=[t],r=[];null!=(t=n.pop());)if(r.push(t),(o=t.children)&&(a=o.length))for(var a,o,i=-1;++in;++n)(e=t[n][1])>a&&(r=n,a=e);return r}function xa(t){return t.reduce(ba,0)}function ba(t,e){return t+e[1]}function _a(t,e){return wa(t,Math.ceil(Math.log(e.length)/Math.LN2+1))}function wa(t,e){for(var n=-1,r=+t[0],a=(t[1]-r)/e,o=[];++n<=e;)o[n]=a*n+r;return o}function ka(t){return[ui.min(t),ui.max(t)]}function Ma(t,e){return t.value-e.value}function Aa(t,e){var n=t._pack_next;t._pack_next=e,e._pack_prev=t,e._pack_next=n,n._pack_prev=e}function Ta(t,e){t._pack_next=e,e._pack_prev=t}function La(t,e){var n=e.x-t.x,r=e.y-t.y,a=t.r+e.r;return.999*a*a>n*n+r*r}function za(t){function e(t){u=Math.min(t.x-t.r,u),f=Math.max(t.x+t.r,f),d=Math.min(t.y-t.r,d),h=Math.max(t.y+t.r,h)}if((n=t.children)&&(c=n.length)){var n,r,a,o,i,l,s,c,u=1/0,f=-(1/0),d=1/0,h=-(1/0);if(n.forEach(Sa),r=n[0],r.x=-r.r,r.y=0,e(r),c>1&&(a=n[1],a.x=a.r,a.y=0,e(a),c>2))for(o=n[2],Oa(r,a,o),e(o),Aa(r,o),r._pack_prev=o,Aa(o,a),a=r._pack_next,i=3;c>i;i++){Oa(r,a,o=n[i]);var p=0,g=1,v=1;for(l=a._pack_next;l!==a;l=l._pack_next,g++)if(La(l,o)){p=1;break}if(1==p)for(s=r._pack_prev;s!==l._pack_prev&&!La(s,o);s=s._pack_prev,v++);p?(v>g||g==v&&a.ri;i++)o=n[i],o.x-=m,o.y-=y,x=Math.max(x,o.r+Math.sqrt(o.x*o.x+o.y*o.y));t.r=x,n.forEach(Ca)}}function Sa(t){t._pack_next=t._pack_prev=t}function Ca(t){delete t._pack_next,delete t._pack_prev}function Ea(t,e,n,r){var a=t.children;if(t.x=e+=r*t.x,t.y=n+=r*t.y,t.r*=r,a)for(var o=-1,i=a.length;++o=0;)e=a[o],e.z+=n,e.m+=n,n+=e.s+(r+=e.c)}function Ia(t,e,n){return t.a.parent===e.parent?t.a:n}function qa(t){return 1+ui.max(t,function(t){return t.y})}function Fa(t){return t.reduce(function(t,e){return t+e.x},0)/t.length}function Ba(t){var e=t.children;return e&&e.length?Ba(e[0]):t}function Ha(t){var e,n=t.children;return n&&(e=n.length)?Ha(n[e-1]):t}function Va(t){return{x:t.x,y:t.y,dx:t.dx,dy:t.dy}}function Ua(t,e){var n=t.x+e[3],r=t.y+e[0],a=t.dx-e[1]-e[3],o=t.dy-e[0]-e[2];return 0>a&&(n+=a/2,a=0),0>o&&(r+=o/2,o=0),{x:n,y:r,dx:a,dy:o}}function Ga(t){var e=t[0],n=t[t.length-1];return n>e?[e,n]:[n,e]}function Za(t){return t.rangeExtent?t.rangeExtent():Ga(t.range())}function Ya(t,e,n,r){var a=n(t[0],t[1]),o=r(e[0],e[1]);return function(t){return o(a(t))}}function Xa(t,e){var n,r=0,a=t.length-1,o=t[r],i=t[a];return o>i&&(n=r,r=a,a=n,n=o,o=i,i=n),t[r]=e.floor(o),t[a]=e.ceil(i),t}function Qa(t){return t?{floor:function(e){return Math.floor(e/t)*t},ceil:function(e){return Math.ceil(e/t)*t}}:Ts}function $a(t,e,n,r){var a=[],o=[],i=0,l=Math.min(t.length,e.length)-1;for(t[l]2?$a:Ya,s=r?Wr:$r;return i=a(t,e,s,n),l=a(e,t,s,_r),o}function o(t){return i(t)}var i,l;return o.invert=function(t){return l(t)},o.domain=function(e){return arguments.length?(t=e.map(Number),a()):t},o.range=function(t){return arguments.length?(e=t,a()):e},o.rangeRound=function(t){return o.range(t).interpolate(qr)},o.clamp=function(t){return arguments.length?(r=t,a()):r},o.interpolate=function(t){return arguments.length?(n=t,a()):n},o.ticks=function(e){return eo(t,e)},o.tickFormat=function(e,n){return no(t,e,n)},o.nice=function(e){return Ka(t,e),a()},o.copy=function(){return Wa(t,e,n,r)},a()}function Ja(t,e){return ui.rebind(t,e,"range","rangeRound","interpolate","clamp")}function Ka(t,e){return Xa(t,Qa(to(t,e)[2])),Xa(t,Qa(to(t,e)[2])),t}function to(t,e){null==e&&(e=10);var n=Ga(t),r=n[1]-n[0],a=Math.pow(10,Math.floor(Math.log(r/e)/Math.LN10)),o=e/r*a;return.15>=o?a*=10:.35>=o?a*=5:.75>=o&&(a*=2),n[0]=Math.ceil(n[0]/a)*a,n[1]=Math.floor(n[1]/a)*a+.5*a,n[2]=a,n}function eo(t,e){return ui.range.apply(ui,to(t,e))}function no(t,e,n){var r=to(t,e);if(n){var a=pl.exec(n);if(a.shift(),"s"===a[8]){var o=ui.formatPrefix(Math.max(wi(r[0]),wi(r[1])));return a[7]||(a[7]="."+ro(o.scale(r[2]))),a[8]="f",n=ui.format(a.join("")),function(t){return n(o.scale(t))+o.symbol}}a[7]||(a[7]="."+ao(a[8],r)),n=a.join("")}else n=",."+ro(r[2])+"f";return ui.format(n)}function ro(t){return-Math.floor(Math.log(t)/Math.LN10+.01)}function ao(t,e){var n=ro(e[2]);return t in Ls?Math.abs(n-ro(Math.max(wi(e[0]),wi(e[1]))))+ +("e"!==t):n-2*("%"===t)}function oo(t,e,n,r){function a(t){return(n?Math.log(0>t?0:t):-Math.log(t>0?0:-t))/Math.log(e)}function o(t){return n?Math.pow(e,t):-Math.pow(e,-t)}function i(e){return t(a(e))}return i.invert=function(e){return o(t.invert(e))},i.domain=function(e){return arguments.length?(n=e[0]>=0,t.domain((r=e.map(Number)).map(a)),i):r},i.base=function(n){return arguments.length?(e=+n,t.domain(r.map(a)),i):e},i.nice=function(){var e=Xa(r.map(a),n?Math:Ss);return t.domain(e),r=e.map(o),i},i.ticks=function(){var t=Ga(r),i=[],l=t[0],s=t[1],c=Math.floor(a(l)),u=Math.ceil(a(s)),f=e%1?2:e;if(isFinite(u-c)){if(n){for(;u>c;c++)for(var d=1;f>d;d++)i.push(o(c)*d);i.push(o(c))}else for(i.push(o(c));c++0;d--)i.push(o(c)*d);for(c=0;i[c]s;u--);i=i.slice(c,u)}return i},i.tickFormat=function(t,n){if(!arguments.length)return zs;arguments.length<2?n=zs:"function"!=typeof n&&(n=ui.format(n));var r=Math.max(1,e*t/i.ticks().length);return function(t){var i=t/o(Math.round(a(t)));return e-.5>i*e&&(i*=e),r>=i?n(t):""}},i.copy=function(){return oo(t.copy(),e,n,r)},Ja(i,t)}function io(t,e,n){function r(e){return t(a(e))}var a=lo(e),o=lo(1/e);return r.invert=function(e){return o(t.invert(e))},r.domain=function(e){return arguments.length?(t.domain((n=e.map(Number)).map(a)),r):n},r.ticks=function(t){return eo(n,t)},r.tickFormat=function(t,e){return no(n,t,e)},r.nice=function(t){return r.domain(Ka(n,t))},r.exponent=function(i){return arguments.length?(a=lo(e=i),o=lo(1/e),t.domain(n.map(a)),r):e},r.copy=function(){return io(t.copy(),e,n)},Ja(r,t)}function lo(t){return function(e){return 0>e?-Math.pow(-e,t):Math.pow(e,t)}}function so(t,e){function n(n){return o[((a.get(n)||("range"===e.t?a.set(n,t.push(n)):NaN))-1)%o.length]}function r(e,n){return ui.range(t.length).map(function(t){return e+n*t})}var a,o,i;return n.domain=function(r){if(!arguments.length)return t;t=[],a=new f;for(var o,i=-1,l=r.length;++in?[NaN,NaN]:[n>0?l[n-1]:t[0],ne?NaN:e/o+t,[e,e+1/o]},r.copy=function(){return uo(t,e,n)},a()}function fo(t,e){function n(n){return n>=n?e[ui.bisect(t,n)]:void 0}return n.domain=function(e){return arguments.length?(t=e,n):t},n.range=function(t){return arguments.length?(e=t,n):e},n.invertExtent=function(n){return n=e.indexOf(n),[t[n-1],t[n]]},n.copy=function(){return fo(t,e)},n}function ho(t){function e(t){return+t}return e.invert=e,e.domain=e.range=function(n){return arguments.length?(t=n.map(e),e):t},e.ticks=function(e){return eo(t,e)},e.tickFormat=function(e,n){return no(t,e,n)},e.copy=function(){return ho(t)},e}function po(){return 0}function go(t){return t.innerRadius}function vo(t){return t.outerRadius}function mo(t){return t.startAngle}function yo(t){return t.endAngle}function xo(t){return t&&t.padAngle}function bo(t,e,n,r){return(t-n)*e-(e-r)*t>0?0:1}function _o(t,e,n,r,a){var o=t[0]-e[0],i=t[1]-e[1],l=(a?r:-r)/Math.sqrt(o*o+i*i),s=l*i,c=-l*o,u=t[0]+s,f=t[1]+c,d=e[0]+s,h=e[1]+c,p=(u+d)/2,g=(f+h)/2,v=d-u,m=h-f,y=v*v+m*m,x=n-r,b=u*h-d*f,_=(0>m?-1:1)*Math.sqrt(Math.max(0,x*x*y-b*b)),w=(b*m-v*_)/y,k=(-b*v-m*_)/y,M=(b*m+v*_)/y,A=(-b*v+m*_)/y,T=w-p,L=k-g,z=M-p,S=A-g;return T*T+L*L>z*z+S*S&&(w=M,k=A),[[w-s,k-c],[w*n/x,k*n/x]]}function wo(t){function e(e){function i(){c.push("M",o(t(u),l))}for(var s,c=[],u=[],f=-1,d=e.length,h=zt(n),p=zt(r);++f1?t.join("L"):t+"Z"}function Mo(t){return t.join("L")+"Z"}function Ao(t){for(var e=0,n=t.length,r=t[0],a=[r[0],",",r[1]];++e1&&a.push("H",r[0]),a.join("")}function To(t){for(var e=0,n=t.length,r=t[0],a=[r[0],",",r[1]];++e1){l=e[1],o=t[s],s++,r+="C"+(a[0]+i[0])+","+(a[1]+i[1])+","+(o[0]-l[0])+","+(o[1]-l[1])+","+o[0]+","+o[1];for(var c=2;c9&&(a=3*e/Math.sqrt(a),i[l]=a*n,i[l+1]=a*r));for(l=-1;++l<=s;)a=(t[Math.min(s,l+1)][0]-t[Math.max(0,l-1)][0])/(6*(1+i[l]*i[l])),o.push([a||0,i[l]*a||0]);return o}function Ho(t){return t.length<3?ko(t):t[0]+Eo(t,Bo(t))}function Vo(t){for(var e,n,r,a=-1,o=t.length;++a=e?i(t-e):void(c.c=i)}function i(n){var a=p.active,o=p[a];o&&(o.timer.c=null,o.timer.t=NaN,--p.count,delete p[a],o.event&&o.event.interrupt.call(t,t.__data__,o.index));for(var i in p)if(r>+i){var f=p[i];f.timer.c=null,f.timer.t=NaN,--p.count,delete p[i]}c.c=l,Nt(function(){return c.c&&l(n||1)&&(c.c=null,c.t=NaN),1},0,s),p.active=r,g.event&&g.event.start.call(t,t.__data__,e),h=[],g.tween.forEach(function(n,r){(r=r.call(t,t.__data__,e))&&h.push(r)}),d=g.ease,u=g.duration}function l(a){for(var o=a/u,i=d(o),l=h.length;l>0;)h[--l].call(t,i);return o>=1?(g.event&&g.event.end.call(t,t.__data__,e),--p.count?delete p[r]:delete t[n],1):void 0}var s,c,u,d,h,p=t[n]||(t[n]={active:0,count:0}),g=p[r];g||(s=a.time,c=Nt(o,0,s),g=p[r]={tween:new f,time:s,timer:c,delay:a.delay,duration:a.duration,ease:a.ease,index:e},a=null,++p.count)}function ri(t,e,n){t.attr("transform",function(t){var r=e(t);return"translate("+(isFinite(r)?r:n(t))+",0)"})}function ai(t,e,n){t.attr("transform",function(t){var r=e(t);return"translate(0,"+(isFinite(r)?r:n(t))+")"})}function oi(t){return t.toISOString()}function ii(t,e,n){function r(e){return t(e)}function a(t,n){var r=t[1]-t[0],a=r/n,o=ui.bisect(tc,a);return o==tc.length?[e.year,to(t.map(function(t){return t/31536e6}),n)[2]]:o?e[a/tc[o-1]1?{floor:function(e){for(;n(e=t.floor(e));)e=li(e-1);return e},ceil:function(e){for(;n(e=t.ceil(e));)e=li(+e+1);return e}}:t))},r.ticks=function(t,e){var n=Ga(r.domain()),o=null==t?a(n,10):"number"==typeof t?a(n,t):!t.range&&[{range:t},e];return o&&(t=o[0],e=o[1]),t.range(n[0],li(+n[1]+1),1>e?1:e)},r.tickFormat=function(){return n},r.copy=function(){return ii(t.copy(),e,n)},Ja(r,t)}function li(t){return new Date(t)}function si(t){return JSON.parse(t.responseText)}function ci(t){var e=hi.createRange();return e.selectNode(hi.body),e.createContextualFragment(t.responseText)}var ui={version:"3.5.16"},fi=[].slice,di=function(t){return fi.call(t)},hi=this.document;if(hi)try{di(hi.documentElement.childNodes)[0].nodeType}catch(pi){di=function(t){for(var e=t.length,n=new Array(e);e--;)n[e]=t[e];return n}}if(Date.now||(Date.now=function(){return+new Date}),hi)try{hi.createElement("DIV").style.setProperty("opacity",0,"")}catch(gi){var vi=this.Element.prototype,mi=vi.setAttribute,yi=vi.setAttributeNS,xi=this.CSSStyleDeclaration.prototype,bi=xi.setProperty;vi.setAttribute=function(t,e){mi.call(this,t,e+"")},vi.setAttributeNS=function(t,e,n){yi.call(this,t,e,n+"")},xi.setProperty=function(t,e,n){bi.call(this,t,e+"",n)}}ui.ascending=a,ui.descending=function(t,e){return t>e?-1:e>t?1:e>=t?0:NaN},ui.min=function(t,e){var n,r,a=-1,o=t.length;if(1===arguments.length){for(;++a=r){n=r;break}for(;++ar&&(n=r)}else{for(;++a=r){n=r;break}for(;++ar&&(n=r)}return n},ui.max=function(t,e){var n,r,a=-1,o=t.length;if(1===arguments.length){for(;++a=r){n=r;break}for(;++an&&(n=r)}else{for(;++a=r){n=r;break}for(;++an&&(n=r)}return n},ui.extent=function(t,e){var n,r,a,o=-1,i=t.length;if(1===arguments.length){for(;++o=r){n=a=r;break}for(;++or&&(n=r),r>a&&(a=r))}else{for(;++o=r){n=a=r;break}for(;++or&&(n=r),r>a&&(a=r))}return[n,a]},ui.sum=function(t,e){var n,r=0,a=t.length,o=-1;if(1===arguments.length)for(;++o1?s/(u-1):void 0},ui.deviation=function(){var t=ui.variance.apply(this,arguments);return t?Math.sqrt(t):t};var _i=l(a);ui.bisectLeft=_i.left,ui.bisect=ui.bisectRight=_i.right,ui.bisector=function(t){return l(1===t.length?function(e,n){return a(t(e),n)}:t)},ui.shuffle=function(t,e,n){(o=arguments.length)<3&&(n=t.length,2>o&&(e=0));for(var r,a,o=n-e;o;)a=Math.random()*o--|0,r=t[o+e],t[o+e]=t[a+e],t[a+e]=r;return t},ui.permute=function(t,e){for(var n=e.length,r=new Array(n);n--;)r[n]=t[e[n]];return r},ui.pairs=function(t){for(var e,n=0,r=t.length-1,a=t[0],o=new Array(0>r?0:r);r>n;)o[n]=[e=a,a=t[++n]];return o},ui.transpose=function(t){if(!(a=t.length))return[];for(var e=-1,n=ui.min(t,s),r=new Array(n);++e=0;)for(r=t[a],e=r.length;--e>=0;)n[--i]=r[e];return n};var wi=Math.abs;ui.range=function(t,e,n){if(arguments.length<3&&(n=1,arguments.length<2&&(e=t,t=0)),(e-t)/n===1/0)throw new Error("infinite range");var r,a=[],o=c(wi(n)),i=-1;if(t*=o,e*=o,n*=o,0>n)for(;(r=t+n*++i)>e;)a.push(r/o);else for(;(r=t+n*++i)=o.length)return r?r.call(a,i):n?i.sort(n):i;for(var s,c,u,d,h=-1,p=i.length,g=o[l++],v=new f;++h=o.length)return t;var r=[],a=i[n++];return t.forEach(function(t,a){r.push({key:t, +-values:e(a,n)})}),a?r.sort(function(t,e){return a(t.key,e.key)}):r}var n,r,a={},o=[],i=[];return a.map=function(e,n){return t(n,e,0)},a.entries=function(n){return e(t(ui.map,n,0),0)},a.key=function(t){return o.push(t),a},a.sortKeys=function(t){return i[o.length-1]=t,a},a.sortValues=function(t){return n=t,a},a.rollup=function(t){return r=t,a},a},ui.set=function(t){var e=new x;if(t)for(var n=0,r=t.length;r>n;++n)e.add(t[n]);return e},u(x,{has:p,add:function(t){return this._[d(t+="")]=!0,t},remove:g,values:v,size:m,empty:y,forEach:function(t){for(var e in this._)t.call(this,h(e))}}),ui.behavior={},ui.rebind=function(t,e){for(var n,r=1,a=arguments.length;++r=0&&(r=t.slice(n+1),t=t.slice(0,n)),t)return arguments.length<2?this[t].on(r):this[t].on(r,e);if(2===arguments.length){if(null==e)for(t in this)this.hasOwnProperty(t)&&this[t].on(r,null);return this}},ui.event=null,ui.requote=function(t){return t.replace(Ti,"\\$&")};var Ti=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,Li={}.__proto__?function(t,e){t.__proto__=e}:function(t,e){for(var n in e)t[n]=e[n]},zi=function(t,e){return e.querySelector(t)},Si=function(t,e){return e.querySelectorAll(t)},Ci=function(t,e){var n=t.matches||t[w(t,"matchesSelector")];return(Ci=function(t,e){return n.call(t,e)})(t,e)};"function"==typeof Sizzle&&(zi=function(t,e){return Sizzle(t,e)[0]||null},Si=Sizzle,Ci=Sizzle.matchesSelector),ui.selection=function(){return ui.select(hi.documentElement)};var Ei=ui.selection.prototype=[];Ei.select=function(t){var e,n,r,a,o=[];t=C(t);for(var i=-1,l=this.length;++i=0&&"xmlns"!==(n=t.slice(0,e))&&(t=t.slice(e+1)),Ni.hasOwnProperty(n)?{space:Ni[n],local:t}:t}},Ei.attr=function(t,e){if(arguments.length<2){if("string"==typeof t){var n=this.node();return t=ui.ns.qualify(t),t.local?n.getAttributeNS(t.space,t.local):n.getAttribute(t)}for(e in t)this.each(O(e,t[e]));return this}return this.each(O(t,e))},Ei.classed=function(t,e){if(arguments.length<2){if("string"==typeof t){var n=this.node(),r=(t=j(t)).length,a=-1;if(e=n.classList){for(;++aa){if("string"!=typeof t){2>a&&(e="");for(n in t)this.each(I(n,t[n],e));return this}if(2>a){var o=this.node();return r(o).getComputedStyle(o,null).getPropertyValue(t)}n=""}return this.each(I(t,e,n))},Ei.property=function(t,e){if(arguments.length<2){if("string"==typeof t)return this.node()[t];for(e in t)this.each(q(e,t[e]));return this}return this.each(q(t,e))},Ei.text=function(t){return arguments.length?this.each("function"==typeof t?function(){var e=t.apply(this,arguments);this.textContent=null==e?"":e}:null==t?function(){this.textContent=""}:function(){this.textContent=t}):this.node().textContent},Ei.html=function(t){return arguments.length?this.each("function"==typeof t?function(){var e=t.apply(this,arguments);this.innerHTML=null==e?"":e}:null==t?function(){this.innerHTML=""}:function(){this.innerHTML=t}):this.node().innerHTML},Ei.append=function(t){return t=F(t),this.select(function(){return this.appendChild(t.apply(this,arguments))})},Ei.insert=function(t,e){return t=F(t),e=C(e),this.select(function(){return this.insertBefore(t.apply(this,arguments),e.apply(this,arguments)||null)})},Ei.remove=function(){return this.each(B)},Ei.data=function(t,e){function n(t,n){var r,a,o,i=t.length,u=n.length,d=Math.min(i,u),h=new Array(u),p=new Array(u),g=new Array(i);if(e){var v,m=new f,y=new Array(i);for(r=-1;++rr;++r)p[r]=H(n[r]);for(;i>r;++r)g[r]=t[r]}p.update=h,p.parentNode=h.parentNode=g.parentNode=t.parentNode,l.push(p),s.push(h),c.push(g)}var r,a,o=-1,i=this.length;if(!arguments.length){for(t=new Array(i=(r=this[0]).length);++oo;o++){a.push(e=[]),e.parentNode=(n=this[o]).parentNode;for(var l=0,s=n.length;s>l;l++)(r=n[l])&&t.call(r,r.__data__,l,o)&&e.push(r)}return S(a)},Ei.order=function(){for(var t=-1,e=this.length;++t=0;)(n=r[a])&&(o&&o!==n.nextSibling&&o.parentNode.insertBefore(n,o),o=n);return this},Ei.sort=function(t){t=U.apply(this,arguments);for(var e=-1,n=this.length;++et;t++)for(var n=this[t],r=0,a=n.length;a>r;r++){var o=n[r];if(o)return o}return null},Ei.size=function(){var t=0;return G(this,function(){++t}),t};var Pi=[];ui.selection.enter=Z,ui.selection.enter.prototype=Pi,Pi.append=Ei.append,Pi.empty=Ei.empty,Pi.node=Ei.node,Pi.call=Ei.call,Pi.size=Ei.size,Pi.select=function(t){for(var e,n,r,a,o,i=[],l=-1,s=this.length;++lr){if("string"!=typeof t){2>r&&(e=!1);for(n in t)this.each(X(n,t[n],e));return this}if(2>r)return(r=this.node()["__on"+t])&&r._;n=!1}return this.each(X(t,e,n))};var ji=ui.map({mouseenter:"mouseover",mouseleave:"mouseout"});hi&&ji.forEach(function(t){"on"+t in hi&&ji.remove(t)});var Di,Ri=0;ui.mouse=function(t){return J(t,L())};var Ii=this.navigator&&/WebKit/.test(this.navigator.userAgent)?-1:0;ui.touch=function(t,e,n){if(arguments.length<3&&(n=e,e=L().changedTouches),e)for(var r,a=0,o=e.length;o>a;++a)if((r=e[a]).identifier===n)return J(t,r)},ui.behavior.drag=function(){function t(){this.on("mousedown.drag",o).on("touchstart.drag",i)}function e(t,e,r,o,i){return function(){function l(){var t,n,r=e(d,g);r&&(t=r[0]-x[0],n=r[1]-x[1],p|=t|n,x=r,h({type:"drag",x:r[0]+c[0],y:r[1]+c[1],dx:t,dy:n}))}function s(){e(d,g)&&(m.on(o+v,null).on(i+v,null),y(p),h({type:"dragend"}))}var c,u=this,f=ui.event.target.correspondingElement||ui.event.target,d=u.parentNode,h=n.of(u,arguments),p=0,g=t(),v=".drag"+(null==g?"":"-"+g),m=ui.select(r(f)).on(o+v,l).on(i+v,s),y=W(f),x=e(d,g);a?(c=a.apply(u,arguments),c=[c.x-x[0],c.y-x[1]]):c=[0,0],h({type:"dragstart"})}}var n=z(t,"drag","dragstart","dragend"),a=null,o=e(k,ui.mouse,r,"mousemove","mouseup"),i=e(K,ui.touch,b,"touchmove","touchend");return t.origin=function(e){return arguments.length?(a=e,t):a},ui.rebind(t,n,"on")},ui.touches=function(t,e){return arguments.length<2&&(e=L().touches),e?di(e).map(function(e){var n=J(t,e);return n.identifier=e.identifier,n}):[]};var qi=1e-6,Fi=qi*qi,Bi=Math.PI,Hi=2*Bi,Vi=Hi-qi,Ui=Bi/2,Gi=Bi/180,Zi=180/Bi,Yi=Math.SQRT2,Xi=2,Qi=4;ui.interpolateZoom=function(t,e){var n,r,a=t[0],o=t[1],i=t[2],l=e[0],s=e[1],c=e[2],u=l-a,f=s-o,d=u*u+f*f;if(Fi>d)r=Math.log(c/i)/Yi,n=function(t){return[a+t*u,o+t*f,i*Math.exp(Yi*t*r)]};else{var h=Math.sqrt(d),p=(c*c-i*i+Qi*d)/(2*i*Xi*h),g=(c*c-i*i-Qi*d)/(2*c*Xi*h),v=Math.log(Math.sqrt(p*p+1)-p),m=Math.log(Math.sqrt(g*g+1)-g);r=(m-v)/Yi,n=function(t){var e=t*r,n=ot(v),l=i/(Xi*h)*(n*it(Yi*e+v)-at(v));return[a+l*u,o+l*f,i*n/ot(Yi*e+v)]}}return n.duration=1e3*r,n},ui.behavior.zoom=function(){function t(t){t.on(E,f).on(Wi+".zoom",h).on("dblclick.zoom",p).on(P,d)}function e(t){return[(t[0]-M.x)/M.k,(t[1]-M.y)/M.k]}function n(t){return[t[0]*M.k+M.x,t[1]*M.k+M.y]}function a(t){M.k=Math.max(L[0],Math.min(L[1],t))}function o(t,e){e=n(e),M.x+=t[0]-e[0],M.y+=t[1]-e[1]}function i(e,n,r,i){e.__chart__={x:M.x,y:M.y,k:M.k},a(Math.pow(2,i)),o(v=n,r),e=ui.select(e),S>0&&(e=e.transition().duration(S)),e.call(t.event)}function l(){_&&_.domain(b.range().map(function(t){return(t-M.x)/M.k}).map(b.invert)),k&&k.domain(w.range().map(function(t){return(t-M.y)/M.k}).map(w.invert))}function s(t){C++||t({type:"zoomstart"})}function c(t){l(),t({type:"zoom",scale:M.k,translate:[M.x,M.y]})}function u(t){--C||(t({type:"zoomend"}),v=null)}function f(){function t(){l=1,o(ui.mouse(a),d),c(i)}function n(){f.on(O,null).on(N,null),h(l),u(i)}var a=this,i=j.of(a,arguments),l=0,f=ui.select(r(a)).on(O,t).on(N,n),d=e(ui.mouse(a)),h=W(a);Us.call(a),s(i)}function d(){function t(){var t=ui.touches(p);return h=M.k,t.forEach(function(t){t.identifier in v&&(v[t.identifier]=e(t))}),t}function n(){var e=ui.event.target;ui.select(e).on(b,r).on(_,l),w.push(e);for(var n=ui.event.changedTouches,a=0,o=n.length;o>a;++a)v[n[a].identifier]=null;var s=t(),c=Date.now();if(1===s.length){if(500>c-x){var u=s[0];i(p,u,v[u.identifier],Math.floor(Math.log(M.k)/Math.LN2)+1),T()}x=c}else if(s.length>1){var u=s[0],f=s[1],d=u[0]-f[0],h=u[1]-f[1];m=d*d+h*h}}function r(){var t,e,n,r,i=ui.touches(p);Us.call(p);for(var l=0,s=i.length;s>l;++l,r=null)if(n=i[l],r=v[n.identifier]){if(e)break;t=n,e=r}if(r){var u=(u=n[0]-t[0])*u+(u=n[1]-t[1])*u,f=m&&Math.sqrt(u/m);t=[(t[0]+n[0])/2,(t[1]+n[1])/2],e=[(e[0]+r[0])/2,(e[1]+r[1])/2],a(f*h)}x=null,o(t,e),c(g)}function l(){if(ui.event.touches.length){for(var e=ui.event.changedTouches,n=0,r=e.length;r>n;++n)delete v[e[n].identifier];for(var a in v)return void t()}ui.selectAll(w).on(y,null),k.on(E,f).on(P,d),A(),u(g)}var h,p=this,g=j.of(p,arguments),v={},m=0,y=".zoom-"+ui.event.changedTouches[0].identifier,b="touchmove"+y,_="touchend"+y,w=[],k=ui.select(p),A=W(p);n(),s(g),k.on(E,null).on(P,n)}function h(){var t=j.of(this,arguments);y?clearTimeout(y):(Us.call(this),g=e(v=m||ui.mouse(this)),s(t)),y=setTimeout(function(){y=null,u(t)},50),T(),a(Math.pow(2,.002*$i())*M.k),o(v,g),c(t)}function p(){var t=ui.mouse(this),n=Math.log(M.k)/Math.LN2;i(this,t,e(t),ui.event.shiftKey?Math.ceil(n)-1:Math.floor(n)+1)}var g,v,m,y,x,b,_,w,k,M={x:0,y:0,k:1},A=[960,500],L=Ji,S=250,C=0,E="mousedown.zoom",O="mousemove.zoom",N="mouseup.zoom",P="touchstart.zoom",j=z(t,"zoomstart","zoom","zoomend");return Wi||(Wi="onwheel"in hi?($i=function(){return-ui.event.deltaY*(ui.event.deltaMode?120:1)},"wheel"):"onmousewheel"in hi?($i=function(){return ui.event.wheelDelta},"mousewheel"):($i=function(){return-ui.event.detail},"MozMousePixelScroll")),t.event=function(t){t.each(function(){var t=j.of(this,arguments),e=M;Hs?ui.select(this).transition().each("start.zoom",function(){M=this.__chart__||{x:0,y:0,k:1},s(t)}).tween("zoom:zoom",function(){var n=A[0],r=A[1],a=v?v[0]:n/2,o=v?v[1]:r/2,i=ui.interpolateZoom([(a-M.x)/M.k,(o-M.y)/M.k,n/M.k],[(a-e.x)/e.k,(o-e.y)/e.k,n/e.k]);return function(e){var r=i(e),l=n/r[2];this.__chart__=M={x:a-r[0]*l,y:o-r[1]*l,k:l},c(t)}}).each("interrupt.zoom",function(){u(t)}).each("end.zoom",function(){u(t)}):(this.__chart__=M,s(t),c(t),u(t))})},t.translate=function(e){return arguments.length?(M={x:+e[0],y:+e[1],k:M.k},l(),t):[M.x,M.y]},t.scale=function(e){return arguments.length?(M={x:M.x,y:M.y,k:null},a(+e),l(),t):M.k},t.scaleExtent=function(e){return arguments.length?(L=null==e?Ji:[+e[0],+e[1]],t):L},t.center=function(e){return arguments.length?(m=e&&[+e[0],+e[1]],t):m},t.size=function(e){return arguments.length?(A=e&&[+e[0],+e[1]],t):A},t.duration=function(e){return arguments.length?(S=+e,t):S},t.x=function(e){return arguments.length?(_=e,b=e.copy(),M={x:0,y:0,k:1},t):_},t.y=function(e){return arguments.length?(k=e,w=e.copy(),M={x:0,y:0,k:1},t):k},ui.rebind(t,j,"on")};var $i,Wi,Ji=[0,1/0];ui.color=st,st.prototype.toString=function(){return this.rgb()+""},ui.hsl=ct;var Ki=ct.prototype=new st;Ki.brighter=function(t){return t=Math.pow(.7,arguments.length?t:1),new ct(this.h,this.s,this.l/t)},Ki.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new ct(this.h,this.s,t*this.l)},Ki.rgb=function(){return ut(this.h,this.s,this.l)},ui.hcl=ft;var tl=ft.prototype=new st;tl.brighter=function(t){return new ft(this.h,this.c,Math.min(100,this.l+el*(arguments.length?t:1)))},tl.darker=function(t){return new ft(this.h,this.c,Math.max(0,this.l-el*(arguments.length?t:1)))},tl.rgb=function(){return dt(this.h,this.c,this.l).rgb()},ui.lab=ht;var el=18,nl=.95047,rl=1,al=1.08883,ol=ht.prototype=new st;ol.brighter=function(t){return new ht(Math.min(100,this.l+el*(arguments.length?t:1)),this.a,this.b)},ol.darker=function(t){return new ht(Math.max(0,this.l-el*(arguments.length?t:1)),this.a,this.b)},ol.rgb=function(){return pt(this.l,this.a,this.b)},ui.rgb=xt;var il=xt.prototype=new st;il.brighter=function(t){t=Math.pow(.7,arguments.length?t:1);var e=this.r,n=this.g,r=this.b,a=30;return e||n||r?(e&&a>e&&(e=a),n&&a>n&&(n=a),r&&a>r&&(r=a),new xt(Math.min(255,e/t),Math.min(255,n/t),Math.min(255,r/t))):new xt(a,a,a)},il.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new xt(t*this.r,t*this.g,t*this.b)},il.hsl=function(){return Mt(this.r,this.g,this.b)},il.toString=function(){return"#"+wt(this.r)+wt(this.g)+wt(this.b)};var ll=ui.map({aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074});ll.forEach(function(t,e){ll.set(t,bt(e))}),ui.functor=zt,ui.xhr=St(b),ui.dsv=function(t,e){function n(t,n,o){arguments.length<3&&(o=n,n=null);var i=Ct(t,e,null==n?r:a(n),o);return i.row=function(t){return arguments.length?i.response(null==(n=t)?r:a(t)):n},i}function r(t){return n.parse(t.responseText)}function a(t){return function(e){return n.parse(e.responseText,t)}}function o(e){return e.map(i).join(t)}function i(t){return l.test(t)?'"'+t.replace(/\"/g,'""')+'"':t}var l=new RegExp('["'+t+"\n]"),s=t.charCodeAt(0);return n.parse=function(t,e){var r;return n.parseRows(t,function(t,n){if(r)return r(t,n-1);var a=new Function("d","return {"+t.map(function(t,e){return JSON.stringify(t)+": d["+e+"]"}).join(",")+"}");r=e?function(t,n){return e(a(t),n)}:a})},n.parseRows=function(t,e){function n(){if(u>=c)return i;if(a)return a=!1,o;var e=u;if(34===t.charCodeAt(e)){for(var n=e;n++u;){var r=t.charCodeAt(u++),l=1;if(10===r)a=!0;else if(13===r)a=!0,10===t.charCodeAt(u)&&(++u,++l);else if(r!==s)continue;return t.slice(e,u-l)}return t.slice(e)}for(var r,a,o={},i={},l=[],c=t.length,u=0,f=0;(r=n())!==i;){for(var d=[];r!==o&&r!==i;)d.push(r),r=n();e&&null==(d=e(d,f++))||l.push(d)}return l},n.format=function(e){if(Array.isArray(e[0]))return n.formatRows(e);var r=new x,a=[];return e.forEach(function(t){for(var e in t)r.has(e)||a.push(r.add(e))}),[a.map(i).join(t)].concat(e.map(function(e){return a.map(function(t){return i(e[t])}).join(t)})).join("\n")},n.formatRows=function(t){return t.map(o).join("\n")},n},ui.csv=ui.dsv(",","text/csv"),ui.tsv=ui.dsv(" ","text/tab-separated-values");var sl,cl,ul,fl,dl=this[w(this,"requestAnimationFrame")]||function(t){setTimeout(t,17)};ui.timer=function(){Nt.apply(this,arguments)},ui.timer.flush=function(){jt(),Dt()},ui.round=function(t,e){return e?Math.round(t*(e=Math.pow(10,e)))/e:Math.round(t)};var hl=["y","z","a","f","p","n","\xb5","m","","k","M","G","T","P","E","Z","Y"].map(It);ui.formatPrefix=function(t,e){var n=0;return(t=+t)&&(0>t&&(t*=-1),e&&(t=ui.round(t,Rt(t,e))),n=1+Math.floor(1e-12+Math.log(t)/Math.LN10),n=Math.max(-24,Math.min(24,3*Math.floor((n-1)/3)))),hl[8+n/3]};var pl=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,gl=ui.map({b:function(t){return t.toString(2)},c:function(t){return String.fromCharCode(t)},o:function(t){return t.toString(8)},x:function(t){return t.toString(16)},X:function(t){return t.toString(16).toUpperCase()},g:function(t,e){return t.toPrecision(e)},e:function(t,e){return t.toExponential(e)},f:function(t,e){return t.toFixed(e)},r:function(t,e){return(t=ui.round(t,Rt(t,e))).toFixed(Math.max(0,Math.min(20,Rt(t*(1+1e-15),e))))}}),vl=ui.time={},ml=Date;Bt.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){yl.setUTCDate.apply(this._,arguments)},setDay:function(){yl.setUTCDay.apply(this._,arguments)},setFullYear:function(){yl.setUTCFullYear.apply(this._,arguments)},setHours:function(){yl.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){yl.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){yl.setUTCMinutes.apply(this._,arguments)},setMonth:function(){yl.setUTCMonth.apply(this._,arguments)},setSeconds:function(){yl.setUTCSeconds.apply(this._,arguments)},setTime:function(){yl.setTime.apply(this._,arguments)}};var yl=Date.prototype;vl.year=Ht(function(t){return t=vl.day(t),t.setMonth(0,1),t},function(t,e){t.setFullYear(t.getFullYear()+e)},function(t){return t.getFullYear()}),vl.years=vl.year.range,vl.years.utc=vl.year.utc.range,vl.day=Ht(function(t){var e=new ml(2e3,0);return e.setFullYear(t.getFullYear(),t.getMonth(),t.getDate()),e},function(t,e){t.setDate(t.getDate()+e)},function(t){return t.getDate()-1}),vl.days=vl.day.range,vl.days.utc=vl.day.utc.range,vl.dayOfYear=function(t){var e=vl.year(t);return Math.floor((t-e-6e4*(t.getTimezoneOffset()-e.getTimezoneOffset()))/864e5)},["sunday","monday","tuesday","wednesday","thursday","friday","saturday"].forEach(function(t,e){e=7-e;var n=vl[t]=Ht(function(t){return(t=vl.day(t)).setDate(t.getDate()-(t.getDay()+e)%7),t},function(t,e){t.setDate(t.getDate()+7*Math.floor(e))},function(t){var n=vl.year(t).getDay();return Math.floor((vl.dayOfYear(t)+(n+e)%7)/7)-(n!==e)});vl[t+"s"]=n.range,vl[t+"s"].utc=n.utc.range,vl[t+"OfYear"]=function(t){var n=vl.year(t).getDay();return Math.floor((vl.dayOfYear(t)+(n+e)%7)/7)}}),vl.week=vl.sunday,vl.weeks=vl.sunday.range,vl.weeks.utc=vl.sunday.utc.range,vl.weekOfYear=vl.sundayOfYear;var xl={"-":"",_:" ",0:"0"},bl=/^\s*\d+/,_l=/^%/;ui.locale=function(t){return{numberFormat:qt(t),timeFormat:Ut(t)}};var wl=ui.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});ui.format=wl.numberFormat,ui.geo={},fe.prototype={s:0,t:0,add:function(t){de(t,this.t,kl),de(kl.s,this.s,this),this.s?this.t+=kl.t:this.s=kl.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var kl=new fe;ui.geo.stream=function(t,e){t&&Ml.hasOwnProperty(t.type)?Ml[t.type](t,e):he(t,e)};var Ml={Feature:function(t,e){he(t.geometry,e)},FeatureCollection:function(t,e){for(var n=t.features,r=-1,a=n.length;++rt?4*Bi+t:t,zl.lineStart=zl.lineEnd=zl.point=k}};ui.geo.bounds=function(){function t(t,e){x.push(b=[u=t,d=t]),f>e&&(f=e),e>h&&(h=e)}function e(e,n){var r=me([e*Gi,n*Gi]);if(m){var a=xe(m,r),o=[a[1],-a[0],0],i=xe(o,a);we(i),i=ke(i);var s=e-p,c=s>0?1:-1,g=i[0]*Zi*c,v=wi(s)>180;if(v^(g>c*p&&c*e>g)){var y=i[1]*Zi;y>h&&(h=y)}else if(g=(g+360)%360-180,v^(g>c*p&&c*e>g)){var y=-i[1]*Zi;f>y&&(f=y)}else f>n&&(f=n),n>h&&(h=n);v?p>e?l(u,e)>l(u,d)&&(d=e):l(e,d)>l(u,d)&&(u=e):d>=u?(u>e&&(u=e),e>d&&(d=e)):e>p?l(u,e)>l(u,d)&&(d=e):l(e,d)>l(u,d)&&(u=e)}else t(e,n);m=r,p=e}function n(){_.point=e}function r(){b[0]=u,b[1]=d,_.point=t,m=null}function a(t,n){if(m){var r=t-p;y+=wi(r)>180?r+(r>0?360:-360):r}else g=t,v=n;zl.point(t,n),e(t,n)}function o(){zl.lineStart()}function i(){a(g,v),zl.lineEnd(),wi(y)>qi&&(u=-(d=180)),b[0]=u,b[1]=d,m=null}function l(t,e){return(e-=t)<0?e+360:e}function s(t,e){return t[0]-e[0]}function c(t,e){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:tLl?(u=-(d=180),f=-(h=90)):y>qi?h=90:-qi>y&&(f=-90),b[0]=u,b[1]=d}};return function(t){h=d=-(u=f=1/0),x=[],ui.geo.stream(t,_);var e=x.length;if(e){x.sort(s);for(var n,r=1,a=x[0],o=[a];e>r;++r)n=x[r],c(n[0],a)||c(n[1],a)?(l(a[0],n[1])>l(a[0],a[1])&&(a[1]=n[1]),l(n[0],a[1])>l(a[0],a[1])&&(a[0]=n[0])):o.push(a=n);for(var i,n,p=-(1/0),e=o.length-1,r=0,a=o[e];e>=r;a=n,++r)n=o[r],(i=l(a[1],n[0]))>p&&(p=i,u=n[0],d=a[1])}return x=b=null,u===1/0||f===1/0?[[NaN,NaN],[NaN,NaN]]:[[u,f],[d,h]]}}(),ui.geo.centroid=function(t){Sl=Cl=El=Ol=Nl=Pl=jl=Dl=Rl=Il=ql=0,ui.geo.stream(t,Fl);var e=Rl,n=Il,r=ql,a=e*e+n*n+r*r;return Fi>a&&(e=Pl,n=jl,r=Dl,qi>Cl&&(e=El,n=Ol,r=Nl),a=e*e+n*n+r*r,Fi>a)?[NaN,NaN]:[Math.atan2(n,e)*Zi,rt(r/Math.sqrt(a))*Zi]};var Sl,Cl,El,Ol,Nl,Pl,jl,Dl,Rl,Il,ql,Fl={sphere:k,point:Ae,lineStart:Le,lineEnd:ze,polygonStart:function(){Fl.lineStart=Se},polygonEnd:function(){Fl.lineStart=Le}},Bl=je(Ee,qe,Be,[-Bi,-Bi/2]),Hl=1e9;ui.geo.clipExtent=function(){var t,e,n,r,a,o,i={stream:function(t){return a&&(a.valid=!1),a=o(t),a.valid=!0,a},extent:function(l){return arguments.length?(o=Ge(t=+l[0][0],e=+l[0][1],n=+l[1][0],r=+l[1][1]),a&&(a.valid=!1,a=null),i):[[t,e],[n,r]]}};return i.extent([[0,0],[960,500]])},(ui.geo.conicEqualArea=function(){return Ze(Ye)}).raw=Ye,ui.geo.albers=function(){return ui.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},ui.geo.albersUsa=function(){function t(t){var o=t[0],i=t[1];return e=null,n(o,i),e||(r(o,i),e)||a(o,i),e}var e,n,r,a,o=ui.geo.albers(),i=ui.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),l=ui.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),s={point:function(t,n){e=[t,n]}};return t.invert=function(t){var e=o.scale(),n=o.translate(),r=(t[0]-n[0])/e,a=(t[1]-n[1])/e;return(a>=.12&&.234>a&&r>=-.425&&-.214>r?i:a>=.166&&.234>a&&r>=-.214&&-.115>r?l:o).invert(t)},t.stream=function(t){var e=o.stream(t),n=i.stream(t),r=l.stream(t);return{point:function(t,a){e.point(t,a),n.point(t,a),r.point(t,a)},sphere:function(){e.sphere(),n.sphere(),r.sphere()},lineStart:function(){e.lineStart(),n.lineStart(),r.lineStart()},lineEnd:function(){e.lineEnd(),n.lineEnd(),r.lineEnd()},polygonStart:function(){e.polygonStart(),n.polygonStart(),r.polygonStart()},polygonEnd:function(){e.polygonEnd(),n.polygonEnd(),r.polygonEnd()}}},t.precision=function(e){return arguments.length?(o.precision(e),i.precision(e),l.precision(e),t):o.precision()},t.scale=function(e){return arguments.length?(o.scale(e),i.scale(.35*e),l.scale(e),t.translate(o.translate())):o.scale()},t.translate=function(e){if(!arguments.length)return o.translate();var c=o.scale(),u=+e[0],f=+e[1];return n=o.translate(e).clipExtent([[u-.455*c,f-.238*c],[u+.455*c,f+.238*c]]).stream(s).point,r=i.translate([u-.307*c,f+.201*c]).clipExtent([[u-.425*c+qi,f+.12*c+qi],[u-.214*c-qi,f+.234*c-qi]]).stream(s).point,a=l.translate([u-.205*c,f+.212*c]).clipExtent([[u-.214*c+qi,f+.166*c+qi],[u-.115*c-qi,f+.234*c-qi]]).stream(s).point,t},t.scale(1070)};var Vl,Ul,Gl,Zl,Yl,Xl,Ql={point:k,lineStart:k,lineEnd:k,polygonStart:function(){Ul=0,Ql.lineStart=Xe},polygonEnd:function(){Ql.lineStart=Ql.lineEnd=Ql.point=k,Vl+=wi(Ul/2)}},$l={point:Qe,lineStart:k,lineEnd:k,polygonStart:k,polygonEnd:k},Wl={point:Je,lineStart:Ke,lineEnd:tn,polygonStart:function(){Wl.lineStart=en},polygonEnd:function(){Wl.point=Je,Wl.lineStart=Ke,Wl.lineEnd=tn}};ui.geo.path=function(){function t(t){return t&&("function"==typeof l&&o.pointRadius(+l.apply(this,arguments)),i&&i.valid||(i=a(o)),ui.geo.stream(t,i)),o.result()}function e(){return i=null,t}var n,r,a,o,i,l=4.5;return t.area=function(t){return Vl=0,ui.geo.stream(t,a(Ql)),Vl},t.centroid=function(t){return El=Ol=Nl=Pl=jl=Dl=Rl=Il=ql=0,ui.geo.stream(t,a(Wl)),ql?[Rl/ql,Il/ql]:Dl?[Pl/Dl,jl/Dl]:Nl?[El/Nl,Ol/Nl]:[NaN,NaN]},t.bounds=function(t){return Yl=Xl=-(Gl=Zl=1/0),ui.geo.stream(t,a($l)),[[Gl,Zl],[Yl,Xl]]},t.projection=function(t){return arguments.length?(a=(n=t)?t.stream||an(t):b,e()):n},t.context=function(t){return arguments.length?(o=null==(r=t)?new $e:new nn(t),"function"!=typeof l&&o.pointRadius(l),e()):r},t.pointRadius=function(e){return arguments.length?(l="function"==typeof e?e:(o.pointRadius(+e),+e),t):l},t.projection(ui.geo.albersUsa()).context(null)},ui.geo.transform=function(t){return{stream:function(e){var n=new on(e);for(var r in t)n[r]=t[r];return n}}},on.prototype={point:function(t,e){this.stream.point(t,e)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}},ui.geo.projection=sn,ui.geo.projectionMutator=cn,(ui.geo.equirectangular=function(){return sn(fn)}).raw=fn.invert=fn,ui.geo.rotation=function(t){function e(e){return e=t(e[0]*Gi,e[1]*Gi),e[0]*=Zi,e[1]*=Zi,e}return t=hn(t[0]%360*Gi,t[1]*Gi,t.length>2?t[2]*Gi:0),e.invert=function(e){return e=t.invert(e[0]*Gi,e[1]*Gi),e[0]*=Zi,e[1]*=Zi,e},e},dn.invert=fn,ui.geo.circle=function(){function t(){var t="function"==typeof r?r.apply(this,arguments):r,e=hn(-t[0]*Gi,-t[1]*Gi,0).invert,a=[];return n(null,null,1,{point:function(t,n){a.push(t=e(t,n)),t[0]*=Zi,t[1]*=Zi}}),{type:"Polygon",coordinates:[a]}}var e,n,r=[0,0],a=6;return t.origin=function(e){return arguments.length?(r=e,t):r},t.angle=function(r){return arguments.length?(n=mn((e=+r)*Gi,a*Gi),t):e},t.precision=function(r){return arguments.length?(n=mn(e*Gi,(a=+r)*Gi),t):a},t.angle(90)},ui.geo.distance=function(t,e){var n,r=(e[0]-t[0])*Gi,a=t[1]*Gi,o=e[1]*Gi,i=Math.sin(r),l=Math.cos(r),s=Math.sin(a),c=Math.cos(a),u=Math.sin(o),f=Math.cos(o);return Math.atan2(Math.sqrt((n=f*i)*n+(n=c*u-s*f*l)*n),s*u+c*f*l)},ui.geo.graticule=function(){function t(){return{type:"MultiLineString",coordinates:e()}}function e(){return ui.range(Math.ceil(o/v)*v,a,v).map(d).concat(ui.range(Math.ceil(c/m)*m,s,m).map(h)).concat(ui.range(Math.ceil(r/p)*p,n,p).filter(function(t){return wi(t%v)>qi}).map(u)).concat(ui.range(Math.ceil(l/g)*g,i,g).filter(function(t){return wi(t%m)>qi}).map(f))}var n,r,a,o,i,l,s,c,u,f,d,h,p=10,g=p,v=90,m=360,y=2.5;return t.lines=function(){return e().map(function(t){return{type:"LineString",coordinates:t}})},t.outline=function(){return{type:"Polygon",coordinates:[d(o).concat(h(s).slice(1),d(a).reverse().slice(1),h(c).reverse().slice(1))] +-}},t.extent=function(e){return arguments.length?t.majorExtent(e).minorExtent(e):t.minorExtent()},t.majorExtent=function(e){return arguments.length?(o=+e[0][0],a=+e[1][0],c=+e[0][1],s=+e[1][1],o>a&&(e=o,o=a,a=e),c>s&&(e=c,c=s,s=e),t.precision(y)):[[o,c],[a,s]]},t.minorExtent=function(e){return arguments.length?(r=+e[0][0],n=+e[1][0],l=+e[0][1],i=+e[1][1],r>n&&(e=r,r=n,n=e),l>i&&(e=l,l=i,i=e),t.precision(y)):[[r,l],[n,i]]},t.step=function(e){return arguments.length?t.majorStep(e).minorStep(e):t.minorStep()},t.majorStep=function(e){return arguments.length?(v=+e[0],m=+e[1],t):[v,m]},t.minorStep=function(e){return arguments.length?(p=+e[0],g=+e[1],t):[p,g]},t.precision=function(e){return arguments.length?(y=+e,u=xn(l,i,90),f=bn(r,n,y),d=xn(c,s,90),h=bn(o,a,y),t):y},t.majorExtent([[-180,-90+qi],[180,90-qi]]).minorExtent([[-180,-80-qi],[180,80+qi]])},ui.geo.greatArc=function(){function t(){return{type:"LineString",coordinates:[e||r.apply(this,arguments),n||a.apply(this,arguments)]}}var e,n,r=_n,a=wn;return t.distance=function(){return ui.geo.distance(e||r.apply(this,arguments),n||a.apply(this,arguments))},t.source=function(n){return arguments.length?(r=n,e="function"==typeof n?null:n,t):r},t.target=function(e){return arguments.length?(a=e,n="function"==typeof e?null:e,t):a},t.precision=function(){return arguments.length?t:0},t},ui.geo.interpolate=function(t,e){return kn(t[0]*Gi,t[1]*Gi,e[0]*Gi,e[1]*Gi)},ui.geo.length=function(t){return Jl=0,ui.geo.stream(t,Kl),Jl};var Jl,Kl={sphere:k,point:k,lineStart:Mn,lineEnd:k,polygonStart:k,polygonEnd:k},ts=An(function(t){return Math.sqrt(2/(1+t))},function(t){return 2*Math.asin(t/2)});(ui.geo.azimuthalEqualArea=function(){return sn(ts)}).raw=ts;var es=An(function(t){var e=Math.acos(t);return e&&e/Math.sin(e)},b);(ui.geo.azimuthalEquidistant=function(){return sn(es)}).raw=es,(ui.geo.conicConformal=function(){return Ze(Tn)}).raw=Tn,(ui.geo.conicEquidistant=function(){return Ze(Ln)}).raw=Ln;var ns=An(function(t){return 1/t},Math.atan);(ui.geo.gnomonic=function(){return sn(ns)}).raw=ns,zn.invert=function(t,e){return[t,2*Math.atan(Math.exp(e))-Ui]},(ui.geo.mercator=function(){return Sn(zn)}).raw=zn;var rs=An(function(){return 1},Math.asin);(ui.geo.orthographic=function(){return sn(rs)}).raw=rs;var as=An(function(t){return 1/(1+t)},function(t){return 2*Math.atan(t)});(ui.geo.stereographic=function(){return sn(as)}).raw=as,Cn.invert=function(t,e){return[-e,2*Math.atan(Math.exp(t))-Ui]},(ui.geo.transverseMercator=function(){var t=Sn(Cn),e=t.center,n=t.rotate;return t.center=function(t){return t?e([-t[1],t[0]]):(t=e(),[t[1],-t[0]])},t.rotate=function(t){return t?n([t[0],t[1],t.length>2?t[2]+90:90]):(t=n(),[t[0],t[1],t[2]-90])},n([0,0,90])}).raw=Cn,ui.geom={},ui.geom.hull=function(t){function e(t){if(t.length<3)return[];var e,a=zt(n),o=zt(r),i=t.length,l=[],s=[];for(e=0;i>e;e++)l.push([+a.call(this,t[e],e),+o.call(this,t[e],e),e]);for(l.sort(Pn),e=0;i>e;e++)s.push([l[e][0],-l[e][1]]);var c=Nn(l),u=Nn(s),f=u[0]===c[0],d=u[u.length-1]===c[c.length-1],h=[];for(e=c.length-1;e>=0;--e)h.push(t[l[c[e]][2]]);for(e=+f;e=r&&c.x<=o&&c.y>=a&&c.y<=i?[[r,i],[o,i],[o,a],[r,a]]:[];u.point=t[l]}),e}function n(t){return t.map(function(t,e){return{x:Math.round(o(t,e)/qi)*qi,y:Math.round(i(t,e)/qi)*qi,i:e}})}var r=En,a=On,o=r,i=a,l=hs;return t?e(t):(e.links=function(t){return cr(n(t)).edges.filter(function(t){return t.l&&t.r}).map(function(e){return{source:t[e.l.i],target:t[e.r.i]}})},e.triangles=function(t){var e=[];return cr(n(t)).cells.forEach(function(n,r){for(var a,o,i=n.site,l=n.edges.sort(Yn),s=-1,c=l.length,u=l[c-1].edge,f=u.l===i?u.r:u.l;++s=c,d=r>=u,h=d<<1|f;t.leaf=!1,t=t.nodes[h]||(t.nodes[h]=pr()),f?a=c:l=c,d?i=u:s=u,o(t,e,n,r,a,i,l,s)}var u,f,d,h,p,g,v,m,y,x=zt(l),b=zt(s);if(null!=e)g=e,v=n,m=r,y=a;else if(m=y=-(g=v=1/0),f=[],d=[],p=t.length,i)for(h=0;p>h;++h)u=t[h],u.xm&&(m=u.x),u.y>y&&(y=u.y),f.push(u.x),d.push(u.y);else for(h=0;p>h;++h){var _=+x(u=t[h],h),w=+b(u,h);g>_&&(g=_),v>w&&(v=w),_>m&&(m=_),w>y&&(y=w),f.push(_),d.push(w)}var k=m-g,M=y-v;k>M?y=v+k:m=g+M;var A=pr();if(A.add=function(t){o(A,t,+x(t,++h),+b(t,h),g,v,m,y)},A.visit=function(t){gr(t,A,g,v,m,y)},A.find=function(t){return vr(A,t[0],t[1],g,v,m,y)},h=-1,null==e){for(;++h=0?t.slice(0,e):t,r=e>=0?t.slice(e+1):"in";return n=ms.get(n)||vs,r=ys.get(r)||b,kr(r(n.apply(null,fi.call(arguments,1))))},ui.interpolateHcl=Dr,ui.interpolateHsl=Rr,ui.interpolateLab=Ir,ui.interpolateRound=qr,ui.transform=function(t){var e=hi.createElementNS(ui.ns.prefix.svg,"g");return(ui.transform=function(t){if(null!=t){e.setAttribute("transform",t);var n=e.transform.baseVal.consolidate()}return new Fr(n?n.matrix:xs)})(t)},Fr.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var xs={a:1,b:0,c:0,d:1,e:0,f:0};ui.interpolateTransform=Qr,ui.layout={},ui.layout.bundle=function(){return function(t){for(var e=[],n=-1,r=t.length;++nl*l/m){if(g>s){var c=e.charge/s;t.px-=o*c,t.py-=i*c}return!0}if(e.point&&s&&g>s){var c=e.pointCharge/s;t.px-=o*c,t.py-=i*c}}return!e.charge}}function e(t){t.px=ui.event.x,t.py=ui.event.y,s.resume()}var n,r,a,o,i,l,s={},c=ui.dispatch("start","tick","end"),u=[1,1],f=.9,d=bs,h=_s,p=-30,g=ws,v=.1,m=.64,y=[],x=[];return s.tick=function(){if((a*=.99)<.005)return n=null,c.end({type:"end",alpha:a=0}),!0;var e,r,s,d,h,g,m,b,_,w=y.length,k=x.length;for(r=0;k>r;++r)s=x[r],d=s.source,h=s.target,b=h.x-d.x,_=h.y-d.y,(g=b*b+_*_)&&(g=a*i[r]*((g=Math.sqrt(g))-o[r])/g,b*=g,_*=g,h.x-=b*(m=d.weight+h.weight?d.weight/(d.weight+h.weight):.5),h.y-=_*m,d.x+=b*(m=1-m),d.y+=_*m);if((m=a*v)&&(b=u[0]/2,_=u[1]/2,r=-1,m))for(;++r0?a=t:(n.c=null,n.t=NaN,n=null,c.end({type:"end",alpha:a=0})):t>0&&(c.start({type:"start",alpha:a=t}),n=Nt(s.tick)),s):a},s.start=function(){function t(t,r){if(!n){for(n=new Array(a),s=0;a>s;++s)n[s]=[];for(s=0;c>s;++s){var o=x[s];n[o.source.index].push(o.target),n[o.target.index].push(o.source)}}for(var i,l=n[e],s=-1,u=l.length;++se;++e)(r=y[e]).index=e,r.weight=0;for(e=0;c>e;++e)r=x[e],"number"==typeof r.source&&(r.source=y[r.source]),"number"==typeof r.target&&(r.target=y[r.target]),++r.source.weight,++r.target.weight;for(e=0;a>e;++e)r=y[e],isNaN(r.x)&&(r.x=t("x",f)),isNaN(r.y)&&(r.y=t("y",g)),isNaN(r.px)&&(r.px=r.x),isNaN(r.py)&&(r.py=r.y);if(o=[],"function"==typeof d)for(e=0;c>e;++e)o[e]=+d.call(this,x[e],e);else for(e=0;c>e;++e)o[e]=d;if(i=[],"function"==typeof h)for(e=0;c>e;++e)i[e]=+h.call(this,x[e],e);else for(e=0;c>e;++e)i[e]=h;if(l=[],"function"==typeof p)for(e=0;a>e;++e)l[e]=+p.call(this,y[e],e);else for(e=0;a>e;++e)l[e]=p;return s.resume()},s.resume=function(){return s.alpha(.1)},s.stop=function(){return s.alpha(0)},s.drag=function(){return r||(r=ui.behavior.drag().origin(b).on("dragstart.force",ea).on("drag.force",e).on("dragend.force",na)),arguments.length?void this.on("mouseover.force",ra).on("mouseout.force",aa).call(r):r},ui.rebind(s,c,"on")};var bs=20,_s=1,ws=1/0;ui.layout.hierarchy=function(){function t(a){var o,i=[a],l=[];for(a.depth=0;null!=(o=i.pop());)if(l.push(o),(c=n.call(t,o,o.depth))&&(s=c.length)){for(var s,c,u;--s>=0;)i.push(u=c[s]),u.parent=o,u.depth=o.depth+1;r&&(o.value=0),o.children=c}else r&&(o.value=+r.call(t,o,o.depth)||0),delete o.children;return sa(a,function(t){var n,a;e&&(n=t.children)&&n.sort(e),r&&(a=t.parent)&&(a.value+=t.value)}),l}var e=fa,n=ca,r=ua;return t.sort=function(n){return arguments.length?(e=n,t):e},t.children=function(e){return arguments.length?(n=e,t):n},t.value=function(e){return arguments.length?(r=e,t):r},t.revalue=function(e){return r&&(la(e,function(t){t.children&&(t.value=0)}),sa(e,function(e){var n;e.children||(e.value=+r.call(t,e,e.depth)||0),(n=e.parent)&&(n.value+=e.value)})),e},t},ui.layout.partition=function(){function t(e,n,r,a){var o=e.children;if(e.x=n,e.y=e.depth*a,e.dx=r,e.dy=a,o&&(i=o.length)){var i,l,s,c=-1;for(r=e.value?r/e.value:0;++cf?-1:1),p=ui.sum(c),g=p?(f-s*h)/p:0,v=ui.range(s),m=[];return null!=n&&v.sort(n===ks?function(t,e){return c[e]-c[t]}:function(t,e){return n(i[t],i[e])}),v.forEach(function(t){m[t]={data:i[t],value:l=c[t],startAngle:u,endAngle:u+=l*g+h,padAngle:d}}),m}var e=Number,n=ks,r=0,a=Hi,o=0;return t.value=function(n){return arguments.length?(e=n,t):e},t.sort=function(e){return arguments.length?(n=e,t):n},t.startAngle=function(e){return arguments.length?(r=e,t):r},t.endAngle=function(e){return arguments.length?(a=e,t):a},t.padAngle=function(e){return arguments.length?(o=e,t):o},t};var ks={};ui.layout.stack=function(){function t(l,s){if(!(d=l.length))return l;var c=l.map(function(n,r){return e.call(t,n,r)}),u=c.map(function(e){return e.map(function(e,n){return[o.call(t,e,n),i.call(t,e,n)]})}),f=n.call(t,u,s);c=ui.permute(c,f),u=ui.permute(u,f);var d,h,p,g,v=r.call(t,u,s),m=c[0].length;for(p=0;m>p;++p)for(a.call(t,c[0][p],g=v[p],u[0][p][1]),h=1;d>h;++h)a.call(t,c[h][p],g+=u[h-1][p][1],u[h][p][1]);return l}var e=b,n=va,r=ma,a=ga,o=ha,i=pa;return t.values=function(n){return arguments.length?(e=n,t):e},t.order=function(e){return arguments.length?(n="function"==typeof e?e:Ms.get(e)||va,t):n},t.offset=function(e){return arguments.length?(r="function"==typeof e?e:As.get(e)||ma,t):r},t.x=function(e){return arguments.length?(o=e,t):o},t.y=function(e){return arguments.length?(i=e,t):i},t.out=function(e){return arguments.length?(a=e,t):a},t};var Ms=ui.map({"inside-out":function(t){var e,n,r=t.length,a=t.map(ya),o=t.map(xa),i=ui.range(r).sort(function(t,e){return a[t]-a[e]}),l=0,s=0,c=[],u=[];for(e=0;r>e;++e)n=i[e],s>l?(l+=o[n],c.push(n)):(s+=o[n],u.push(n));return u.reverse().concat(c)},reverse:function(t){return ui.range(t.length).reverse()},"default":va}),As=ui.map({silhouette:function(t){var e,n,r,a=t.length,o=t[0].length,i=[],l=0,s=[];for(n=0;o>n;++n){for(e=0,r=0;a>e;e++)r+=t[e][n][1];r>l&&(l=r),i.push(r)}for(n=0;o>n;++n)s[n]=(l-i[n])/2;return s},wiggle:function(t){var e,n,r,a,o,i,l,s,c,u=t.length,f=t[0],d=f.length,h=[];for(h[0]=s=c=0,n=1;d>n;++n){for(e=0,a=0;u>e;++e)a+=t[e][n][1];for(e=0,o=0,l=f[n][0]-f[n-1][0];u>e;++e){for(r=0,i=(t[e][n][1]-t[e][n-1][1])/(2*l);e>r;++r)i+=(t[r][n][1]-t[r][n-1][1])/l;o+=i*t[e][n][1]}h[n]=s-=a?o/a*l:0,c>s&&(c=s)}for(n=0;d>n;++n)h[n]-=c;return h},expand:function(t){var e,n,r,a=t.length,o=t[0].length,i=1/a,l=[];for(n=0;o>n;++n){for(e=0,r=0;a>e;e++)r+=t[e][n][1];if(r)for(e=0;a>e;e++)t[e][n][1]/=r;else for(e=0;a>e;e++)t[e][n][1]=i}for(n=0;o>n;++n)l[n]=0;return l},zero:ma});ui.layout.histogram=function(){function t(t,o){for(var i,l,s=[],c=t.map(n,this),u=r.call(this,c,o),f=a.call(this,u,c,o),o=-1,d=c.length,h=f.length-1,p=e?1:1/d;++o0)for(o=-1;++o=u[0]&&l<=u[1]&&(i=s[ui.bisect(f,l,1,h)-1],i.y+=p,i.push(t[o]));return s}var e=!0,n=Number,r=ka,a=_a;return t.value=function(e){return arguments.length?(n=e,t):n},t.range=function(e){return arguments.length?(r=zt(e),t):r},t.bins=function(e){return arguments.length?(a="number"==typeof e?function(t){return wa(t,e)}:zt(e),t):a},t.frequency=function(n){return arguments.length?(e=!!n,t):e},t},ui.layout.pack=function(){function t(t,o){var i=n.call(this,t,o),l=i[0],s=a[0],c=a[1],u=null==e?Math.sqrt:"function"==typeof e?e:function(){return e};if(l.x=l.y=0,sa(l,function(t){t.r=+u(t.value)}),sa(l,za),r){var f=r*(e?1:Math.max(2*l.r/s,2*l.r/c))/2;sa(l,function(t){t.r+=f}),sa(l,za),sa(l,function(t){t.r-=f})}return Ea(l,s/2,c/2,e?1:1/Math.max(2*l.r/s,2*l.r/c)),i}var e,n=ui.layout.hierarchy().sort(Ma),r=0,a=[1,1];return t.size=function(e){return arguments.length?(a=e,t):a},t.radius=function(n){return arguments.length?(e=null==n||"function"==typeof n?n:+n,t):e},t.padding=function(e){return arguments.length?(r=+e,t):r},ia(t,n)},ui.layout.tree=function(){function t(t,a){var u=i.call(this,t,a),f=u[0],d=e(f);if(sa(d,n),d.parent.m=-d.z,la(d,r),c)la(f,o);else{var h=f,p=f,g=f;la(f,function(t){t.xp.x&&(p=t),t.depth>g.depth&&(g=t)});var v=l(h,p)/2-h.x,m=s[0]/(p.x+l(p,h)/2+v),y=s[1]/(g.depth||1);la(f,function(t){t.x=(t.x+v)*m,t.y=t.depth*y})}return u}function e(t){for(var e,n={A:null,children:[t]},r=[n];null!=(e=r.pop());)for(var a,o=e.children,i=0,l=o.length;l>i;++i)r.push((o[i]=a={_:o[i],parent:e,children:(a=o[i].children)&&a.slice()||[],A:null,a:null,z:0,m:0,c:0,s:0,t:null,i:i}).a=a);return n.children[0]}function n(t){var e=t.children,n=t.parent.children,r=t.i?n[t.i-1]:null;if(e.length){Ra(t);var o=(e[0].z+e[e.length-1].z)/2;r?(t.z=r.z+l(t._,r._),t.m=t.z-o):t.z=o}else r&&(t.z=r.z+l(t._,r._));t.parent.A=a(t,r,t.parent.A||n[0])}function r(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function a(t,e,n){if(e){for(var r,a=t,o=t,i=e,s=a.parent.children[0],c=a.m,u=o.m,f=i.m,d=s.m;i=ja(i),a=Pa(a),i&&a;)s=Pa(s),o=ja(o),o.a=t,r=i.z+f-a.z-c+l(i._,a._),r>0&&(Da(Ia(i,t,n),t,r),c+=r,u+=r),f+=i.m,c+=a.m,d+=s.m,u+=o.m;i&&!ja(o)&&(o.t=i,o.m+=f-u),a&&!Pa(s)&&(s.t=a,s.m+=c-d,n=t)}return n}function o(t){t.x*=s[0],t.y=t.depth*s[1]}var i=ui.layout.hierarchy().sort(null).value(null),l=Na,s=[1,1],c=null;return t.separation=function(e){return arguments.length?(l=e,t):l},t.size=function(e){return arguments.length?(c=null==(s=e)?o:null,t):c?null:s},t.nodeSize=function(e){return arguments.length?(c=null==(s=e)?null:o,t):c?s:null},ia(t,i)},ui.layout.cluster=function(){function t(t,o){var i,l=e.call(this,t,o),s=l[0],c=0;sa(s,function(t){var e=t.children;e&&e.length?(t.x=Fa(e),t.y=qa(e)):(t.x=i?c+=n(t,i):0,t.y=0,i=t)});var u=Ba(s),f=Ha(s),d=u.x-n(u,f)/2,h=f.x+n(f,u)/2;return sa(s,a?function(t){t.x=(t.x-s.x)*r[0],t.y=(s.y-t.y)*r[1]}:function(t){t.x=(t.x-d)/(h-d)*r[0],t.y=(1-(s.y?t.y/s.y:1))*r[1]}),l}var e=ui.layout.hierarchy().sort(null).value(null),n=Na,r=[1,1],a=!1;return t.separation=function(e){return arguments.length?(n=e,t):n},t.size=function(e){return arguments.length?(a=null==(r=e),t):a?null:r},t.nodeSize=function(e){return arguments.length?(a=null!=(r=e),t):a?r:null},ia(t,e)},ui.layout.treemap=function(){function t(t,e){for(var n,r,a=-1,o=t.length;++ae?0:e),n.area=isNaN(r)||0>=r?0:r}function e(n){var o=n.children;if(o&&o.length){var i,l,s,c=f(n),u=[],d=o.slice(),p=1/0,g="slice"===h?c.dx:"dice"===h?c.dy:"slice-dice"===h?1&n.depth?c.dy:c.dx:Math.min(c.dx,c.dy);for(t(d,c.dx*c.dy/n.value),u.area=0;(s=d.length)>0;)u.push(i=d[s-1]),u.area+=i.area,"squarify"!==h||(l=r(u,g))<=p?(d.pop(),p=l):(u.area-=u.pop().area,a(u,g,c,!1),g=Math.min(c.dx,c.dy),u.length=u.area=0,p=1/0);u.length&&(a(u,g,c,!0),u.length=u.area=0),o.forEach(e)}}function n(e){var r=e.children;if(r&&r.length){var o,i=f(e),l=r.slice(),s=[];for(t(l,i.dx*i.dy/e.value),s.area=0;o=l.pop();)s.push(o),s.area+=o.area,null!=o.z&&(a(s,o.z?i.dx:i.dy,i,!l.length),s.length=s.area=0);r.forEach(n)}}function r(t,e){for(var n,r=t.area,a=0,o=1/0,i=-1,l=t.length;++in&&(o=n),n>a&&(a=n));return r*=r,e*=e,r?Math.max(e*a*p/r,r/(e*o*p)):1/0}function a(t,e,n,r){var a,o=-1,i=t.length,l=n.x,c=n.y,u=e?s(t.area/e):0;if(e==n.dx){for((r||u>n.dy)&&(u=n.dy);++on.dx)&&(u=n.dx);++on&&(e=1),1>n&&(t=0),function(){var n,r,a;do n=2*Math.random()-1,r=2*Math.random()-1,a=n*n+r*r;while(!a||a>1);return t+e*n*Math.sqrt(-2*Math.log(a)/a)}},logNormal:function(){var t=ui.random.normal.apply(ui,arguments);return function(){return Math.exp(t())}},bates:function(t){var e=ui.random.irwinHall(t);return function(){return e()/t}},irwinHall:function(t){return function(){for(var e=0,n=0;t>n;n++)e+=Math.random();return e}}},ui.scale={};var Ts={floor:b,ceil:b};ui.scale.linear=function(){return Wa([0,1],[0,1],_r,!1)};var Ls={s:1,g:1,p:1,r:1,e:1};ui.scale.log=function(){return oo(ui.scale.linear().domain([0,1]),10,!0,[1,10])};var zs=ui.format(".0e"),Ss={floor:function(t){return-Math.ceil(-t)},ceil:function(t){return-Math.floor(-t)}};ui.scale.pow=function(){return io(ui.scale.linear(),1,[0,1])},ui.scale.sqrt=function(){return ui.scale.pow().exponent(.5)},ui.scale.ordinal=function(){return so([],{t:"range",a:[[]]})},ui.scale.category10=function(){return ui.scale.ordinal().range(Cs)},ui.scale.category20=function(){return ui.scale.ordinal().range(Es)},ui.scale.category20b=function(){return ui.scale.ordinal().range(Os)},ui.scale.category20c=function(){return ui.scale.ordinal().range(Ns)};var Cs=[2062260,16744206,2924588,14034728,9725885,9197131,14907330,8355711,12369186,1556175].map(_t),Es=[2062260,11454440,16744206,16759672,2924588,10018698,14034728,16750742,9725885,12955861,9197131,12885140,14907330,16234194,8355711,13092807,12369186,14408589,1556175,10410725].map(_t),Os=[3750777,5395619,7040719,10264286,6519097,9216594,11915115,13556636,9202993,12426809,15186514,15190932,8666169,11356490,14049643,15177372,8077683,10834324,13528509,14589654].map(_t),Ns=[3244733,7057110,10406625,13032431,15095053,16616764,16625259,16634018,3253076,7652470,10607003,13101504,7695281,10394312,12369372,14342891,6513507,9868950,12434877,14277081].map(_t);ui.scale.quantile=function(){return co([],[])},ui.scale.quantize=function(){return uo(0,1,[0,1])},ui.scale.threshold=function(){return fo([.5],[0,1])},ui.scale.identity=function(){return ho([0,1])},ui.svg={},ui.svg.arc=function(){function t(){var t=Math.max(0,+n.apply(this,arguments)),c=Math.max(0,+r.apply(this,arguments)),u=i.apply(this,arguments)-Ui,f=l.apply(this,arguments)-Ui,d=Math.abs(f-u),h=u>f?0:1;if(t>c&&(p=c,c=t,t=p),d>=Vi)return e(c,h)+(t?e(t,1-h):"")+"Z";var p,g,v,m,y,x,b,_,w,k,M,A,T=0,L=0,z=[];if((m=(+s.apply(this,arguments)||0)/2)&&(v=o===Ps?Math.sqrt(t*t+c*c):+o.apply(this,arguments),h||(L*=-1),c&&(L=rt(v/c*Math.sin(m))),t&&(T=rt(v/t*Math.sin(m)))),c){y=c*Math.cos(u+L),x=c*Math.sin(u+L),b=c*Math.cos(f-L),_=c*Math.sin(f-L);var S=Math.abs(f-u-2*L)<=Bi?0:1;if(L&&bo(y,x,b,_)===h^S){var C=(u+f)/2;y=c*Math.cos(C),x=c*Math.sin(C),b=_=null}}else y=x=0;if(t){w=t*Math.cos(f-T),k=t*Math.sin(f-T),M=t*Math.cos(u+T),A=t*Math.sin(u+T);var E=Math.abs(u-f+2*T)<=Bi?0:1;if(T&&bo(w,k,M,A)===1-h^E){var O=(u+f)/2;w=t*Math.cos(O),k=t*Math.sin(O),M=A=null}}else w=k=0;if(d>qi&&(p=Math.min(Math.abs(c-t)/2,+a.apply(this,arguments)))>.001){g=c>t^h?0:1;var N=p,P=p;if(Bi>d){var j=null==M?[w,k]:null==b?[y,x]:Dn([y,x],[M,A],[b,_],[w,k]),D=y-j[0],R=x-j[1],I=b-j[0],q=_-j[1],F=1/Math.sin(Math.acos((D*I+R*q)/(Math.sqrt(D*D+R*R)*Math.sqrt(I*I+q*q)))/2),B=Math.sqrt(j[0]*j[0]+j[1]*j[1]);P=Math.min(p,(t-B)/(F-1)),N=Math.min(p,(c-B)/(F+1))}if(null!=b){var H=_o(null==M?[w,k]:[M,A],[y,x],c,N,h),V=_o([b,_],[w,k],c,N,h);p===N?z.push("M",H[0],"A",N,",",N," 0 0,",g," ",H[1],"A",c,",",c," 0 ",1-h^bo(H[1][0],H[1][1],V[1][0],V[1][1]),",",h," ",V[1],"A",N,",",N," 0 0,",g," ",V[0]):z.push("M",H[0],"A",N,",",N," 0 1,",g," ",V[0])}else z.push("M",y,",",x);if(null!=M){var U=_o([y,x],[M,A],t,-P,h),G=_o([w,k],null==b?[y,x]:[b,_],t,-P,h);p===P?z.push("L",G[0],"A",P,",",P," 0 0,",g," ",G[1],"A",t,",",t," 0 ",h^bo(G[1][0],G[1][1],U[1][0],U[1][1]),",",1-h," ",U[1],"A",P,",",P," 0 0,",g," ",U[0]):z.push("L",G[0],"A",P,",",P," 0 0,",g," ",U[0])}else z.push("L",w,",",k)}else z.push("M",y,",",x),null!=b&&z.push("A",c,",",c," 0 ",S,",",h," ",b,",",_),z.push("L",w,",",k),null!=M&&z.push("A",t,",",t," 0 ",E,",",1-h," ",M,",",A);return z.push("Z"),z.join("")}function e(t,e){return"M0,"+t+"A"+t+","+t+" 0 1,"+e+" 0,"+-t+"A"+t+","+t+" 0 1,"+e+" 0,"+t}var n=go,r=vo,a=po,o=Ps,i=mo,l=yo,s=xo;return t.innerRadius=function(e){return arguments.length?(n=zt(e),t):n},t.outerRadius=function(e){return arguments.length?(r=zt(e),t):r},t.cornerRadius=function(e){return arguments.length?(a=zt(e),t):a},t.padRadius=function(e){return arguments.length?(o=e==Ps?Ps:zt(e),t):o},t.startAngle=function(e){return arguments.length?(i=zt(e),t):i},t.endAngle=function(e){return arguments.length?(l=zt(e),t):l},t.padAngle=function(e){return arguments.length?(s=zt(e),t):s},t.centroid=function(){var t=(+n.apply(this,arguments)+ +r.apply(this,arguments))/2,e=(+i.apply(this,arguments)+ +l.apply(this,arguments))/2-Ui;return[Math.cos(e)*t,Math.sin(e)*t]},t};var Ps="auto";ui.svg.line=function(){return wo(b)};var js=ui.map({linear:ko,"linear-closed":Mo,step:Ao,"step-before":To,"step-after":Lo,basis:No,"basis-open":Po,"basis-closed":jo,bundle:Do,cardinal:Co,"cardinal-open":zo,"cardinal-closed":So,monotone:Ho});js.forEach(function(t,e){e.key=t,e.closed=/-closed$/.test(t)});var Ds=[0,2/3,1/3,0],Rs=[0,1/3,2/3,0],Is=[0,1/6,2/3,1/6];ui.svg.line.radial=function(){var t=wo(Vo);return t.radius=t.x,delete t.x,t.angle=t.y,delete t.y,t},To.reverse=Lo,Lo.reverse=To,ui.svg.area=function(){return Uo(b)},ui.svg.area.radial=function(){var t=Uo(Vo);return t.radius=t.x,delete t.x,t.innerRadius=t.x0,delete t.x0,t.outerRadius=t.x1,delete t.x1,t.angle=t.y,delete t.y,t.startAngle=t.y0,delete t.y0,t.endAngle=t.y1,delete t.y1,t},ui.svg.chord=function(){function t(t,l){var s=e(this,o,t,l),c=e(this,i,t,l);return"M"+s.p0+r(s.r,s.p1,s.a1-s.a0)+(n(s,c)?a(s.r,s.p1,s.r,s.p0):a(s.r,s.p1,c.r,c.p0)+r(c.r,c.p1,c.a1-c.a0)+a(c.r,c.p1,s.r,s.p0))+"Z"}function e(t,e,n,r){var a=e.call(t,n,r),o=l.call(t,a,r),i=s.call(t,a,r)-Ui,u=c.call(t,a,r)-Ui;return{r:o,a0:i,a1:u,p0:[o*Math.cos(i),o*Math.sin(i)],p1:[o*Math.cos(u),o*Math.sin(u)]}}function n(t,e){return t.a0==e.a0&&t.a1==e.a1}function r(t,e,n){return"A"+t+","+t+" 0 "+ +(n>Bi)+",1 "+e}function a(t,e,n,r){return"Q 0,0 "+r}var o=_n,i=wn,l=Go,s=mo,c=yo;return t.radius=function(e){return arguments.length?(l=zt(e),t):l},t.source=function(e){return arguments.length?(o=zt(e),t):o},t.target=function(e){return arguments.length?(i=zt(e),t):i},t.startAngle=function(e){return arguments.length?(s=zt(e),t):s},t.endAngle=function(e){return arguments.length?(c=zt(e),t):c},t},ui.svg.diagonal=function(){function t(t,a){var o=e.call(this,t,a),i=n.call(this,t,a),l=(o.y+i.y)/2,s=[o,{x:o.x,y:l},{x:i.x,y:l},i];return s=s.map(r),"M"+s[0]+"C"+s[1]+" "+s[2]+" "+s[3]}var e=_n,n=wn,r=Zo;return t.source=function(n){return arguments.length?(e=zt(n),t):e},t.target=function(e){return arguments.length?(n=zt(e),t):n},t.projection=function(e){return arguments.length?(r=e,t):r},t},ui.svg.diagonal.radial=function(){var t=ui.svg.diagonal(),e=Zo,n=t.projection;return t.projection=function(t){return arguments.length?n(Yo(e=t)):e},t},ui.svg.symbol=function(){function t(t,r){return(qs.get(e.call(this,t,r))||$o)(n.call(this,t,r))}var e=Qo,n=Xo;return t.type=function(n){return arguments.length?(e=zt(n),t):e},t.size=function(e){return arguments.length?(n=zt(e),t):n},t};var qs=ui.map({circle:$o,cross:function(t){var e=Math.sqrt(t/5)/2;return"M"+-3*e+","+-e+"H"+-e+"V"+-3*e+"H"+e+"V"+-e+"H"+3*e+"V"+e+"H"+e+"V"+3*e+"H"+-e+"V"+e+"H"+-3*e+"Z"},diamond:function(t){var e=Math.sqrt(t/(2*Bs)),n=e*Bs;return"M0,"+-e+"L"+n+",0 0,"+e+" "+-n+",0Z"},square:function(t){var e=Math.sqrt(t)/2;return"M"+-e+","+-e+"L"+e+","+-e+" "+e+","+e+" "+-e+","+e+"Z"},"triangle-down":function(t){var e=Math.sqrt(t/Fs),n=e*Fs/2;return"M0,"+n+"L"+e+","+-n+" "+-e+","+-n+"Z"},"triangle-up":function(t){var e=Math.sqrt(t/Fs),n=e*Fs/2; +-return"M0,"+-n+"L"+e+","+n+" "+-e+","+n+"Z"}});ui.svg.symbolTypes=qs.keys();var Fs=Math.sqrt(3),Bs=Math.tan(30*Gi);Ei.transition=function(t){for(var e,n,r=Hs||++Zs,a=ei(t),o=[],i=Vs||{time:Date.now(),ease:zr,delay:0,duration:250},l=-1,s=this.length;++lo;o++){a.push(e=[]);for(var n=this[o],l=0,s=n.length;s>l;l++)(r=n[l])&&t.call(r,r.__data__,l,o)&&e.push(r)}return Jo(a,this.namespace,this.id)},Gs.tween=function(t,e){var n=this.id,r=this.namespace;return arguments.length<2?this.node()[r][n].tween.get(t):G(this,null==e?function(e){e[r][n].tween.remove(t)}:function(a){a[r][n].tween.set(t,e)})},Gs.attr=function(t,e){function n(){this.removeAttribute(l)}function r(){this.removeAttributeNS(l.space,l.local)}function a(t){return null==t?n:(t+="",function(){var e,n=this.getAttribute(l);return n!==t&&(e=i(n,t),function(t){this.setAttribute(l,e(t))})})}function o(t){return null==t?r:(t+="",function(){var e,n=this.getAttributeNS(l.space,l.local);return n!==t&&(e=i(n,t),function(t){this.setAttributeNS(l.space,l.local,e(t))})})}if(arguments.length<2){for(e in t)this.attr(e,t[e]);return this}var i="transform"==t?Qr:_r,l=ui.ns.qualify(t);return Ko(this,"attr."+t,e,l.local?o:a)},Gs.attrTween=function(t,e){function n(t,n){var r=e.call(this,t,n,this.getAttribute(a));return r&&function(t){this.setAttribute(a,r(t))}}function r(t,n){var r=e.call(this,t,n,this.getAttributeNS(a.space,a.local));return r&&function(t){this.setAttributeNS(a.space,a.local,r(t))}}var a=ui.ns.qualify(t);return this.tween("attr."+t,a.local?r:n)},Gs.style=function(t,e,n){function a(){this.style.removeProperty(t)}function o(e){return null==e?a:(e+="",function(){var a,o=r(this).getComputedStyle(this,null).getPropertyValue(t);return o!==e&&(a=_r(o,e),function(e){this.style.setProperty(t,a(e),n)})})}var i=arguments.length;if(3>i){if("string"!=typeof t){2>i&&(e="");for(n in t)this.style(n,t[n],e);return this}n=""}return Ko(this,"style."+t,e,o)},Gs.styleTween=function(t,e,n){function a(a,o){var i=e.call(this,a,o,r(this).getComputedStyle(this,null).getPropertyValue(t));return i&&function(e){this.style.setProperty(t,i(e),n)}}return arguments.length<3&&(n=""),this.tween("style."+t,a)},Gs.text=function(t){return Ko(this,"text",t,ti)},Gs.remove=function(){var t=this.namespace;return this.each("end.transition",function(){var e;this[t].count<2&&(e=this.parentNode)&&e.removeChild(this)})},Gs.ease=function(t){var e=this.id,n=this.namespace;return arguments.length<1?this.node()[n][e].ease:("function"!=typeof t&&(t=ui.ease.apply(ui,arguments)),G(this,function(r){r[n][e].ease=t}))},Gs.delay=function(t){var e=this.id,n=this.namespace;return arguments.length<1?this.node()[n][e].delay:G(this,"function"==typeof t?function(r,a,o){r[n][e].delay=+t.call(r,r.__data__,a,o)}:(t=+t,function(r){r[n][e].delay=t}))},Gs.duration=function(t){var e=this.id,n=this.namespace;return arguments.length<1?this.node()[n][e].duration:G(this,"function"==typeof t?function(r,a,o){r[n][e].duration=Math.max(1,t.call(r,r.__data__,a,o))}:(t=Math.max(1,t),function(r){r[n][e].duration=t}))},Gs.each=function(t,e){var n=this.id,r=this.namespace;if(arguments.length<2){var a=Vs,o=Hs;try{Hs=n,G(this,function(e,a,o){Vs=e[r][n],t.call(e,e.__data__,a,o)})}finally{Vs=a,Hs=o}}else G(this,function(a){var o=a[r][n];(o.event||(o.event=ui.dispatch("start","end","interrupt"))).on(t,e)});return this},Gs.transition=function(){for(var t,e,n,r,a=this.id,o=++Zs,i=this.namespace,l=[],s=0,c=this.length;c>s;s++){l.push(t=[]);for(var e=this[s],u=0,f=e.length;f>u;u++)(n=e[u])&&(r=n[i][a],ni(n,u,i,o,{time:r.time,ease:r.ease,delay:r.delay+r.duration,duration:r.duration})),t.push(n)}return Jo(l,i,o)},ui.svg.axis=function(){function t(t){t.each(function(){var t,c=ui.select(this),u=this.__chart__||n,f=this.__chart__=n.copy(),d=null==s?f.ticks?f.ticks.apply(f,l):f.domain():s,h=null==e?f.tickFormat?f.tickFormat.apply(f,l):b:e,p=c.selectAll(".tick").data(d,f),g=p.enter().insert("g",".domain").attr("class","tick").style("opacity",qi),v=ui.transition(p.exit()).style("opacity",qi).remove(),m=ui.transition(p.order()).style("opacity",1),y=Math.max(a,0)+i,x=Za(f),_=c.selectAll(".domain").data([0]),w=(_.enter().append("path").attr("class","domain"),ui.transition(_));g.append("line"),g.append("text");var k,M,A,T,L=g.select("line"),z=m.select("line"),S=p.select("text").text(h),C=g.select("text"),E=m.select("text"),O="top"===r||"left"===r?-1:1;if("bottom"===r||"top"===r?(t=ri,k="x",A="y",M="x2",T="y2",S.attr("dy",0>O?"0em":".71em").style("text-anchor","middle"),w.attr("d","M"+x[0]+","+O*o+"V0H"+x[1]+"V"+O*o)):(t=ai,k="y",A="x",M="y2",T="x2",S.attr("dy",".32em").style("text-anchor",0>O?"end":"start"),w.attr("d","M"+O*o+","+x[0]+"H0V"+x[1]+"H"+O*o)),L.attr(T,O*a),C.attr(A,O*y),z.attr(M,0).attr(T,O*a),E.attr(k,0).attr(A,O*y),f.rangeBand){var N=f,P=N.rangeBand()/2;u=f=function(t){return N(t)+P}}else u.rangeBand?u=f:v.call(t,f,u);g.call(t,u,f),m.call(t,f,f)})}var e,n=ui.scale.linear(),r=Ys,a=6,o=6,i=3,l=[10],s=null;return t.scale=function(e){return arguments.length?(n=e,t):n},t.orient=function(e){return arguments.length?(r=e in Xs?e+"":Ys,t):r},t.ticks=function(){return arguments.length?(l=di(arguments),t):l},t.tickValues=function(e){return arguments.length?(s=e,t):s},t.tickFormat=function(n){return arguments.length?(e=n,t):e},t.tickSize=function(e){var n=arguments.length;return n?(a=+e,o=+arguments[n-1],t):a},t.innerTickSize=function(e){return arguments.length?(a=+e,t):a},t.outerTickSize=function(e){return arguments.length?(o=+e,t):o},t.tickPadding=function(e){return arguments.length?(i=+e,t):i},t.tickSubdivide=function(){return arguments.length&&t},t};var Ys="bottom",Xs={top:1,right:1,bottom:1,left:1};ui.svg.brush=function(){function t(r){r.each(function(){var r=ui.select(this).style("pointer-events","all").style("-webkit-tap-highlight-color","rgba(0,0,0,0)").on("mousedown.brush",o).on("touchstart.brush",o),i=r.selectAll(".background").data([0]);i.enter().append("rect").attr("class","background").style("visibility","hidden").style("cursor","crosshair"),r.selectAll(".extent").data([0]).enter().append("rect").attr("class","extent").style("cursor","move");var l=r.selectAll(".resize").data(g,b);l.exit().remove(),l.enter().append("g").attr("class",function(t){return"resize "+t}).style("cursor",function(t){return Qs[t]}).append("rect").attr("x",function(t){return/[ew]$/.test(t)?-3:null}).attr("y",function(t){return/^[ns]/.test(t)?-3:null}).attr("width",6).attr("height",6).style("visibility","hidden"),l.style("display",t.empty()?"none":null);var s,f=ui.transition(r),d=ui.transition(i);c&&(s=Za(c),d.attr("x",s[0]).attr("width",s[1]-s[0]),n(f)),u&&(s=Za(u),d.attr("y",s[0]).attr("height",s[1]-s[0]),a(f)),e(f)})}function e(t){t.selectAll(".resize").attr("transform",function(t){return"translate("+f[+/e$/.test(t)]+","+d[+/^s/.test(t)]+")"})}function n(t){t.select(".extent").attr("x",f[0]),t.selectAll(".extent,.n>rect,.s>rect").attr("width",f[1]-f[0])}function a(t){t.select(".extent").attr("y",d[0]),t.selectAll(".extent,.e>rect,.w>rect").attr("height",d[1]-d[0])}function o(){function o(){32==ui.event.keyCode&&(S||(x=null,E[0]-=f[1],E[1]-=d[1],S=2),T())}function g(){32==ui.event.keyCode&&2==S&&(E[0]+=f[1],E[1]+=d[1],S=0,T())}function v(){var t=ui.mouse(_),r=!1;b&&(t[0]+=b[0],t[1]+=b[1]),S||(ui.event.altKey?(x||(x=[(f[0]+f[1])/2,(d[0]+d[1])/2]),E[0]=f[+(t[0]u?(a=r,r=u):a=u),g[0]!=r||g[1]!=a?(n?l=null:i=null,g[0]=r,g[1]=a,!0):void 0}function y(){v(),M.style("pointer-events","all").selectAll(".resize").style("display",t.empty()?"none":null),ui.select("body").style("cursor",null),O.on("mousemove.brush",null).on("mouseup.brush",null).on("touchmove.brush",null).on("touchend.brush",null).on("keydown.brush",null).on("keyup.brush",null),C(),k({type:"brushend"})}var x,b,_=this,w=ui.select(ui.event.target),k=s.of(_,arguments),M=ui.select(_),A=w.datum(),L=!/^(n|s)$/.test(A)&&c,z=!/^(e|w)$/.test(A)&&u,S=w.classed("extent"),C=W(_),E=ui.mouse(_),O=ui.select(r(_)).on("keydown.brush",o).on("keyup.brush",g);if(ui.event.changedTouches?O.on("touchmove.brush",v).on("touchend.brush",y):O.on("mousemove.brush",v).on("mouseup.brush",y),M.interrupt().selectAll("*").interrupt(),S)E[0]=f[0]-E[0],E[1]=d[0]-E[1];else if(A){var N=+/w$/.test(A),P=+/^n/.test(A);b=[f[1-N]-E[0],d[1-P]-E[1]],E[0]=f[N],E[1]=d[P]}else ui.event.altKey&&(x=E.slice());M.style("pointer-events","none").selectAll(".resize").style("display",null),ui.select("body").style("cursor",w.style("cursor")),k({type:"brushstart"}),v()}var i,l,s=z(t,"brushstart","brush","brushend"),c=null,u=null,f=[0,0],d=[0,0],h=!0,p=!0,g=$s[0];return t.event=function(t){t.each(function(){var t=s.of(this,arguments),e={x:f,y:d,i:i,j:l},n=this.__chart__||e;this.__chart__=e,Hs?ui.select(this).transition().each("start.brush",function(){i=n.i,l=n.j,f=n.x,d=n.y,t({type:"brushstart"})}).tween("brush:brush",function(){var n=wr(f,e.x),r=wr(d,e.y);return i=l=null,function(a){f=e.x=n(a),d=e.y=r(a),t({type:"brush",mode:"resize"})}}).each("end.brush",function(){i=e.i,l=e.j,t({type:"brush",mode:"resize"}),t({type:"brushend"})}):(t({type:"brushstart"}),t({type:"brush",mode:"resize"}),t({type:"brushend"}))})},t.x=function(e){return arguments.length?(c=e,g=$s[!c<<1|!u],t):c},t.y=function(e){return arguments.length?(u=e,g=$s[!c<<1|!u],t):u},t.clamp=function(e){return arguments.length?(c&&u?(h=!!e[0],p=!!e[1]):c?h=!!e:u&&(p=!!e),t):c&&u?[h,p]:c?h:u?p:null},t.extent=function(e){var n,r,a,o,s;return arguments.length?(c&&(n=e[0],r=e[1],u&&(n=n[0],r=r[0]),i=[n,r],c.invert&&(n=c(n),r=c(r)),n>r&&(s=n,n=r,r=s),n==f[0]&&r==f[1]||(f=[n,r])),u&&(a=e[0],o=e[1],c&&(a=a[1],o=o[1]),l=[a,o],u.invert&&(a=u(a),o=u(o)),a>o&&(s=a,a=o,o=s),a==d[0]&&o==d[1]||(d=[a,o])),t):(c&&(i?(n=i[0],r=i[1]):(n=f[0],r=f[1],c.invert&&(n=c.invert(n),r=c.invert(r)),n>r&&(s=n,n=r,r=s))),u&&(l?(a=l[0],o=l[1]):(a=d[0],o=d[1],u.invert&&(a=u.invert(a),o=u.invert(o)),a>o&&(s=a,a=o,o=s))),c&&u?[[n,a],[r,o]]:c?[n,r]:u&&[a,o])},t.clear=function(){return t.empty()||(f=[0,0],d=[0,0],i=l=null),t},t.empty=function(){return!!c&&f[0]==f[1]||!!u&&d[0]==d[1]},ui.rebind(t,s,"on")};var Qs={n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},$s=[["n","e","s","w","nw","ne","se","sw"],["e","w"],["n","s"],[]],Ws=vl.format=wl.timeFormat,Js=Ws.utc,Ks=Js("%Y-%m-%dT%H:%M:%S.%LZ");Ws.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?oi:Ks,oi.parse=function(t){var e=new Date(t);return isNaN(e)?null:e},oi.toString=Ks.toString,vl.second=Ht(function(t){return new ml(1e3*Math.floor(t/1e3))},function(t,e){t.setTime(t.getTime()+1e3*Math.floor(e))},function(t){return t.getSeconds()}),vl.seconds=vl.second.range,vl.seconds.utc=vl.second.utc.range,vl.minute=Ht(function(t){return new ml(6e4*Math.floor(t/6e4))},function(t,e){t.setTime(t.getTime()+6e4*Math.floor(e))},function(t){return t.getMinutes()}),vl.minutes=vl.minute.range,vl.minutes.utc=vl.minute.utc.range,vl.hour=Ht(function(t){var e=t.getTimezoneOffset()/60;return new ml(36e5*(Math.floor(t/36e5-e)+e))},function(t,e){t.setTime(t.getTime()+36e5*Math.floor(e))},function(t){return t.getHours()}),vl.hours=vl.hour.range,vl.hours.utc=vl.hour.utc.range,vl.month=Ht(function(t){return t=vl.day(t),t.setDate(1),t},function(t,e){t.setMonth(t.getMonth()+e)},function(t){return t.getMonth()}),vl.months=vl.month.range,vl.months.utc=vl.month.utc.range;var tc=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],ec=[[vl.second,1],[vl.second,5],[vl.second,15],[vl.second,30],[vl.minute,1],[vl.minute,5],[vl.minute,15],[vl.minute,30],[vl.hour,1],[vl.hour,3],[vl.hour,6],[vl.hour,12],[vl.day,1],[vl.day,2],[vl.week,1],[vl.month,1],[vl.month,3],[vl.year,1]],nc=Ws.multi([[".%L",function(t){return t.getMilliseconds()}],[":%S",function(t){return t.getSeconds()}],["%I:%M",function(t){return t.getMinutes()}],["%I %p",function(t){return t.getHours()}],["%a %d",function(t){return t.getDay()&&1!=t.getDate()}],["%b %d",function(t){return 1!=t.getDate()}],["%B",function(t){return t.getMonth()}],["%Y",Ee]]),rc={range:function(t,e,n){return ui.range(Math.ceil(t/n)*n,+e,n).map(li)},floor:b,ceil:b};ec.year=vl.year,vl.scale=function(){return ii(ui.scale.linear(),ec,nc)};var ac=ec.map(function(t){return[t[0].utc,t[1]]}),oc=Js.multi([[".%L",function(t){return t.getUTCMilliseconds()}],[":%S",function(t){return t.getUTCSeconds()}],["%I:%M",function(t){return t.getUTCMinutes()}],["%I %p",function(t){return t.getUTCHours()}],["%a %d",function(t){return t.getUTCDay()&&1!=t.getUTCDate()}],["%b %d",function(t){return 1!=t.getUTCDate()}],["%B",function(t){return t.getUTCMonth()}],["%Y",Ee]]);ac.year=vl.year.utc,vl.scale.utc=function(){return ii(ui.scale.linear(),ac,oc)},ui.text=St(function(t){return t.responseText}),ui.json=function(t,e){return Ct(t,"application/json",si,e)},ui.html=function(t,e){return Ct(t,"text/html",ci,e)},ui.xml=St(function(t){return t.responseXML}),"function"==typeof t&&t.amd?(this.d3=ui,t(ui)):"object"==typeof n&&n.exports?n.exports=ui:this.d3=ui}()},{}],11:[function(e,n,r){(function(r,a){(function(){"use strict";function o(t){return"function"==typeof t||"object"==typeof t&&null!==t}function i(t){return"function"==typeof t}function l(t){Z=t}function s(t){$=t}function c(){return function(){r.nextTick(p)}}function u(){return function(){G(p)}}function f(){var t=0,e=new K(p),n=document.createTextNode("");return e.observe(n,{characterData:!0}),function(){n.data=t=++t%2}}function d(){var t=new MessageChannel;return t.port1.onmessage=p,function(){t.port2.postMessage(0)}}function h(){return function(){setTimeout(p,1)}}function p(){for(var t=0;Q>t;t+=2){var e=nt[t],n=nt[t+1];e(n),nt[t]=void 0,nt[t+1]=void 0}Q=0}function g(){try{var t=e,n=t("vertx");return G=n.runOnLoop||n.runOnContext,u()}catch(r){return h()}}function v(t,e){var n=this,r=n._state;if(r===it&&!t||r===lt&&!e)return this;var a=new this.constructor(y),o=n._result;if(r){var i=arguments[r-1];$(function(){P(r,a,i,o)})}else C(n,a,t,e);return a}function m(t){var e=this;if(t&&"object"==typeof t&&t.constructor===e)return t;var n=new e(y);return T(n,t),n}function y(){}function x(){return new TypeError("You cannot resolve a promise with itself")}function b(){return new TypeError("A promises callback cannot return that same promise.")}function _(t){try{return t.then}catch(e){return st.error=e,st}}function w(t,e,n,r){try{t.call(e,n,r)}catch(a){return a}}function k(t,e,n){$(function(t){var r=!1,a=w(n,e,function(n){r||(r=!0,e!==n?T(t,n):z(t,n))},function(e){r||(r=!0,S(t,e))},"Settle: "+(t._label||" unknown promise"));!r&&a&&(r=!0,S(t,a))},t)}function M(t,e){e._state===it?z(t,e._result):e._state===lt?S(t,e._result):C(e,void 0,function(e){T(t,e)},function(e){S(t,e)})}function A(t,e,n){e.constructor===t.constructor&&n===rt&&constructor.resolve===at?M(t,e):n===st?S(t,st.error):void 0===n?z(t,e):i(n)?k(t,e,n):z(t,e)}function T(t,e){t===e?S(t,x()):o(e)?A(t,e,_(e)):z(t,e)}function L(t){t._onerror&&t._onerror(t._result),E(t)}function z(t,e){t._state===ot&&(t._result=e,t._state=it,0!==t._subscribers.length&&$(E,t))}function S(t,e){t._state===ot&&(t._state=lt,t._result=e,$(L,t))}function C(t,e,n,r){var a=t._subscribers,o=a.length;t._onerror=null,a[o]=e,a[o+it]=n,a[o+lt]=r,0===o&&t._state&&$(E,t)}function E(t){var e=t._subscribers,n=t._state;if(0!==e.length){for(var r,a,o=t._result,i=0;ii;i++)C(r.resolve(t[i]),void 0,e,n);return a}function I(t){var e=this,n=new e(y);return S(n,t),n}function q(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function F(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function B(t){this._id=ht++,this._state=void 0,this._result=void 0,this._subscribers=[],y!==t&&("function"!=typeof t&&q(),this instanceof B?j(this,t):F())}function H(t,e){this._instanceConstructor=t,this.promise=new t(y),Array.isArray(e)?(this._input=e,this.length=e.length,this._remaining=e.length,this._result=new Array(this.length),0===this.length?z(this.promise,this._result):(this.length=this.length||0,this._enumerate(),0===this._remaining&&z(this.promise,this._result))):S(this.promise,this._validationError())}function V(){var t;if("undefined"!=typeof a)t=a;else if("undefined"!=typeof self)t=self;else try{t=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var n=t.Promise;n&&"[object Promise]"===Object.prototype.toString.call(n.resolve())&&!n.cast||(t.Promise=pt)}var U;U=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)};var G,Z,Y,X=U,Q=0,$=function(t,e){nt[Q]=t,nt[Q+1]=e,Q+=2,2===Q&&(Z?Z(p):Y())},W="undefined"!=typeof window?window:void 0,J=W||{},K=J.MutationObserver||J.WebKitMutationObserver,tt="undefined"!=typeof r&&"[object process]"==={}.toString.call(r),et="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,nt=new Array(1e3);Y=tt?c():K?f():et?d():void 0===W&&"function"==typeof e?g():h();var rt=v,at=m,ot=void 0,it=1,lt=2,st=new O,ct=new O,ut=D,ft=R,dt=I,ht=0,pt=B;B.all=ut,B.race=ft,B.resolve=at,B.reject=dt,B._setScheduler=l,B._setAsap=s,B._asap=$,B.prototype={constructor:B,then:rt,"catch":function(t){return this.then(null,t)}};var gt=H;H.prototype._validationError=function(){return new Error("Array Methods must be provided an Array")},H.prototype._enumerate=function(){for(var t=this.length,e=this._input,n=0;this._state===ot&&t>n;n++)this._eachEntry(e[n],n)},H.prototype._eachEntry=function(t,e){var n=this._instanceConstructor,r=n.resolve;if(r===at){var a=_(t);if(a===rt&&t._state!==ot)this._settledAt(t._state,e,t._result);else if("function"!=typeof a)this._remaining--,this._result[e]=t;else if(n===pt){var o=new n(y);A(o,t,a),this._willSettleAt(o,e)}else this._willSettleAt(new n(function(e){e(t)}),e)}else this._willSettleAt(r(t),e)},H.prototype._settledAt=function(t,e,n){var r=this.promise;r._state===ot&&(this._remaining--,t===lt?S(r,n):this._result[e]=n),0===this._remaining&&z(r,this._result)},H.prototype._willSettleAt=function(t,e){var n=this;C(t,void 0,function(t){n._settledAt(it,e,t)},function(t){n._settledAt(lt,e,t)})};var vt=V,mt={Promise:pt,polyfill:vt};"function"==typeof t&&t.amd?t(function(){return mt}):"undefined"!=typeof n&&n.exports?n.exports=mt:"undefined"!=typeof this&&(this.ES6Promise=mt),vt()}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:8}],12:[function(t,e,n){"use strict";function r(t){for(var e,n=t.length,r=0;n>r;r++)if(e=t.charCodeAt(r),(9>e||e>13)&&32!==e&&133!==e&&160!==e&&5760!==e&&6158!==e&&(8192>e||e>8205)&&8232!==e&&8233!==e&&8239!==e&&8287!==e&&8288!==e&&12288!==e&&65279!==e)return!1;return!0}e.exports=function(t){var e=typeof t;if("string"===e){var n=t;if(t=+t,0===t&&r(n))return!1}else if("number"!==e)return!1;return 1>t-t}},{}],13:[function(t,e,n){function r(t,e){var n=e[0],r=e[1],a=e[2],o=e[3],i=n+n,l=r+r,s=a+a,c=n*i,u=r*i,f=r*l,d=a*i,h=a*l,p=a*s,g=o*i,v=o*l,m=o*s;return t[0]=1-f-p,t[1]=u+m,t[2]=d-v,t[3]=0,t[4]=u-m,t[5]=1-c-p,t[6]=h+g,t[7]=0,t[8]=d+v,t[9]=h-g,t[10]=1-c-f,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}e.exports=r},{}],14:[function(e,n,r){!function(){function e(t,n){if(t=t?t:"",n=n||{},t instanceof e)return t;if(!(this instanceof e))return new e(t,n);var a=r(t);this._originalInput=t,this._r=a.r,this._g=a.g,this._b=a.b,this._a=a.a,this._roundA=B(100*this._a)/100,this._format=n.format||a.format,this._gradientType=n.gradientType,this._r<1&&(this._r=B(this._r)),this._g<1&&(this._g=B(this._g)),this._b<1&&(this._b=B(this._b)),this._ok=a.ok,this._tc_id=q++}function r(t){var e={r:0,g:0,b:0},n=1,r=!1,o=!1;return"string"==typeof t&&(t=j(t)),"object"==typeof t&&(t.hasOwnProperty("r")&&t.hasOwnProperty("g")&&t.hasOwnProperty("b")?(e=a(t.r,t.g,t.b),r=!0,o="%"===String(t.r).substr(-1)?"prgb":"rgb"):t.hasOwnProperty("h")&&t.hasOwnProperty("s")&&t.hasOwnProperty("v")?(t.s=O(t.s),t.v=O(t.v),e=s(t.h,t.s,t.v),r=!0,o="hsv"):t.hasOwnProperty("h")&&t.hasOwnProperty("s")&&t.hasOwnProperty("l")&&(t.s=O(t.s),t.l=O(t.l),e=i(t.h,t.s,t.l),r=!0,o="hsl"),t.hasOwnProperty("a")&&(n=t.a)),n=A(n),{ok:r,format:t.format||o,r:H(255,V(e.r,0)),g:H(255,V(e.g,0)),b:H(255,V(e.b,0)),a:n}}function a(t,e,n){return{r:255*T(t,255),g:255*T(e,255),b:255*T(n,255)}}function o(t,e,n){t=T(t,255),e=T(e,255),n=T(n,255);var r,a,o=V(t,e,n),i=H(t,e,n),l=(o+i)/2;if(o==i)r=a=0;else{var s=o-i;switch(a=l>.5?s/(2-o-i):s/(o+i),o){case t:r=(e-n)/s+(n>e?6:0);break;case e:r=(n-t)/s+2;break;case n:r=(t-e)/s+4}r/=6}return{h:r,s:a,l:l}}function i(t,e,n){function r(t,e,n){return 0>n&&(n+=1),n>1&&(n-=1),1/6>n?t+6*(e-t)*n:.5>n?e:2/3>n?t+(e-t)*(2/3-n)*6:t}var a,o,i;if(t=T(t,360),e=T(e,100),n=T(n,100),0===e)a=o=i=n;else{var l=.5>n?n*(1+e):n+e-n*e,s=2*n-l;a=r(s,l,t+1/3),o=r(s,l,t),i=r(s,l,t-1/3)}return{r:255*a,g:255*o,b:255*i}}function l(t,e,n){t=T(t,255),e=T(e,255),n=T(n,255);var r,a,o=V(t,e,n),i=H(t,e,n),l=o,s=o-i;if(a=0===o?0:s/o,o==i)r=0;else{switch(o){case t:r=(e-n)/s+(n>e?6:0);break;case e:r=(n-t)/s+2;break;case n:r=(t-e)/s+4}r/=6}return{h:r,s:a,v:l}}function s(t,e,n){t=6*T(t,360),e=T(e,100),n=T(n,100);var r=F.floor(t),a=t-r,o=n*(1-e),i=n*(1-a*e),l=n*(1-(1-a)*e),s=r%6,c=[n,i,o,o,l,n][s],u=[l,n,n,i,o,o][s],f=[o,o,l,n,n,i][s];return{r:255*c,g:255*u,b:255*f}}function c(t,e,n,r){var a=[E(B(t).toString(16)),E(B(e).toString(16)),E(B(n).toString(16))];return r&&a[0].charAt(0)==a[0].charAt(1)&&a[1].charAt(0)==a[1].charAt(1)&&a[2].charAt(0)==a[2].charAt(1)?a[0].charAt(0)+a[1].charAt(0)+a[2].charAt(0):a.join("")}function u(t,e,n,r){var a=[E(N(r)),E(B(t).toString(16)),E(B(e).toString(16)),E(B(n).toString(16))];return a.join("")}function f(t,n){n=0===n?0:n||10;var r=e(t).toHsl();return r.s-=n/100,r.s=L(r.s),e(r)}function d(t,n){n=0===n?0:n||10;var r=e(t).toHsl();return r.s+=n/100,r.s=L(r.s),e(r)}function h(t){return e(t).desaturate(100)}function p(t,n){n=0===n?0:n||10;var r=e(t).toHsl();return r.l+=n/100,r.l=L(r.l),e(r)}function g(t,n){n=0===n?0:n||10;var r=e(t).toRgb();return r.r=V(0,H(255,r.r-B(255*-(n/100)))),r.g=V(0,H(255,r.g-B(255*-(n/100)))),r.b=V(0,H(255,r.b-B(255*-(n/100)))),e(r)}function v(t,n){n=0===n?0:n||10;var r=e(t).toHsl();return r.l-=n/100,r.l=L(r.l),e(r)}function m(t,n){var r=e(t).toHsl(),a=(B(r.h)+n)%360;return r.h=0>a?360+a:a,e(r)}function y(t){var n=e(t).toHsl();return n.h=(n.h+180)%360,e(n)}function x(t){var n=e(t).toHsl(),r=n.h;return[e(t),e({h:(r+120)%360,s:n.s,l:n.l}),e({h:(r+240)%360,s:n.s,l:n.l})]}function b(t){var n=e(t).toHsl(),r=n.h;return[e(t),e({h:(r+90)%360,s:n.s,l:n.l}),e({h:(r+180)%360,s:n.s,l:n.l}),e({h:(r+270)%360,s:n.s,l:n.l})]}function _(t){var n=e(t).toHsl(),r=n.h;return[e(t),e({h:(r+72)%360,s:n.s,l:n.l}),e({h:(r+216)%360,s:n.s,l:n.l})]}function w(t,n,r){n=n||6,r=r||30;var a=e(t).toHsl(),o=360/r,i=[e(t)];for(a.h=(a.h-(o*n>>1)+720)%360;--n;)a.h=(a.h+o)%360,i.push(e(a));return i}function k(t,n){n=n||6;for(var r=e(t).toHsv(),a=r.h,o=r.s,i=r.v,l=[],s=1/n;n--;)l.push(e({h:a,s:o,v:i})),i=(i+s)%1;return l}function M(t){var e={};for(var n in t)t.hasOwnProperty(n)&&(e[t[n]]=n);return e}function A(t){return t=parseFloat(t),(isNaN(t)||0>t||t>1)&&(t=1),t}function T(t,e){S(t)&&(t="100%");var n=C(t);return t=H(e,V(0,parseFloat(t))),n&&(t=parseInt(t*e,10)/100),F.abs(t-e)<1e-6?1:t%e/parseFloat(e)}function L(t){return H(1,V(0,t))}function z(t){return parseInt(t,16)}function S(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)}function C(t){return"string"==typeof t&&-1!=t.indexOf("%")}function E(t){return 1==t.length?"0"+t:""+t}function O(t){return 1>=t&&(t=100*t+"%"),t}function N(t){return Math.round(255*parseFloat(t)).toString(16)}function P(t){return z(t)/255}function j(t){t=t.replace(R,"").replace(I,"").toLowerCase();var e=!1;if(G[t])t=G[t],e=!0;else if("transparent"==t)return{r:0,g:0,b:0,a:0,format:"name"};var n;return(n=Y.rgb.exec(t))?{r:n[1],g:n[2],b:n[3]}:(n=Y.rgba.exec(t))?{r:n[1],g:n[2],b:n[3],a:n[4]}:(n=Y.hsl.exec(t))?{h:n[1],s:n[2],l:n[3]}:(n=Y.hsla.exec(t))?{h:n[1],s:n[2],l:n[3],a:n[4]}:(n=Y.hsv.exec(t))?{h:n[1],s:n[2],v:n[3]}:(n=Y.hsva.exec(t))?{h:n[1],s:n[2],v:n[3],a:n[4]}:(n=Y.hex8.exec(t))?{a:P(n[1]),r:z(n[2]),g:z(n[3]),b:z(n[4]),format:e?"name":"hex8"}:(n=Y.hex6.exec(t))?{r:z(n[1]),g:z(n[2]),b:z(n[3]),format:e?"name":"hex"}:(n=Y.hex3.exec(t))?{r:z(n[1]+""+n[1]),g:z(n[2]+""+n[2]),b:z(n[3]+""+n[3]),format:e?"name":"hex"}:!1}function D(t){var e,n;return t=t||{level:"AA",size:"small"},e=(t.level||"AA").toUpperCase(),n=(t.size||"small").toLowerCase(),"AA"!==e&&"AAA"!==e&&(e="AA"),"small"!==n&&"large"!==n&&(n="small"),{level:e,size:n}}var R=/^\s+/,I=/\s+$/,q=0,F=Math,B=F.round,H=F.min,V=F.max,U=F.random;e.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var t,e,n,r,a,o,i=this.toRgb();return t=i.r/255,e=i.g/255,n=i.b/255,r=.03928>=t?t/12.92:Math.pow((t+.055)/1.055,2.4),a=.03928>=e?e/12.92:Math.pow((e+.055)/1.055,2.4),o=.03928>=n?n/12.92:Math.pow((n+.055)/1.055,2.4),.2126*r+.7152*a+.0722*o},setAlpha:function(t){return this._a=A(t),this._roundA=B(100*this._a)/100,this},toHsv:function(){var t=l(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=l(this._r,this._g,this._b),e=B(360*t.h),n=B(100*t.s),r=B(100*t.v);return 1==this._a?"hsv("+e+", "+n+"%, "+r+"%)":"hsva("+e+", "+n+"%, "+r+"%, "+this._roundA+")"},toHsl:function(){var t=o(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=o(this._r,this._g,this._b),e=B(360*t.h),n=B(100*t.s),r=B(100*t.l);return 1==this._a?"hsl("+e+", "+n+"%, "+r+"%)":"hsla("+e+", "+n+"%, "+r+"%, "+this._roundA+")"},toHex:function(t){return c(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(){return u(this._r,this._g,this._b,this._a)},toHex8String:function(){return"#"+this.toHex8()},toRgb:function(){return{r:B(this._r),g:B(this._g),b:B(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+B(this._r)+", "+B(this._g)+", "+B(this._b)+")":"rgba("+B(this._r)+", "+B(this._g)+", "+B(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:B(100*T(this._r,255))+"%",g:B(100*T(this._g,255))+"%",b:B(100*T(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+B(100*T(this._r,255))+"%, "+B(100*T(this._g,255))+"%, "+B(100*T(this._b,255))+"%)":"rgba("+B(100*T(this._r,255))+"%, "+B(100*T(this._g,255))+"%, "+B(100*T(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":this._a<1?!1:Z[c(this._r,this._g,this._b,!0)]||!1},toFilter:function(t){var n="#"+u(this._r,this._g,this._b,this._a),r=n,a=this._gradientType?"GradientType = 1, ":"";if(t){var o=e(t);r=o.toHex8String()}return"progid:DXImageTransform.Microsoft.gradient("+a+"startColorstr="+n+",endColorstr="+r+")"},toString:function(t){var e=!!t;t=t||this._format;var n=!1,r=this._a<1&&this._a>=0,a=!e&&r&&("hex"===t||"hex6"===t||"hex3"===t||"name"===t);return a?"name"===t&&0===this._a?this.toName():this.toRgbString():("rgb"===t&&(n=this.toRgbString()),"prgb"===t&&(n=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(n=this.toHexString()),"hex3"===t&&(n=this.toHexString(!0)),"hex8"===t&&(n=this.toHex8String()),"name"===t&&(n=this.toName()),"hsl"===t&&(n=this.toHslString()),"hsv"===t&&(n=this.toHsvString()),n||this.toHexString())},clone:function(){return e(this.toString())},_applyModification:function(t,e){var n=t.apply(null,[this].concat([].slice.call(e)));return this._r=n._r,this._g=n._g,this._b=n._b,this.setAlpha(n._a),this},lighten:function(){return this._applyModification(p,arguments)},brighten:function(){return this._applyModification(g,arguments)},darken:function(){return this._applyModification(v,arguments)},desaturate:function(){return this._applyModification(f,arguments)},saturate:function(){return this._applyModification(d,arguments)},greyscale:function(){return this._applyModification(h,arguments)},spin:function(){return this._applyModification(m,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(w,arguments)},complement:function(){return this._applyCombination(y,arguments)},monochromatic:function(){return this._applyCombination(k,arguments)},splitcomplement:function(){return this._applyCombination(_,arguments)},triad:function(){return this._applyCombination(x,arguments)},tetrad:function(){return this._applyCombination(b,arguments)}},e.fromRatio=function(t,n){if("object"==typeof t){var r={};for(var a in t)t.hasOwnProperty(a)&&("a"===a?r[a]=t[a]:r[a]=O(t[a]));t=r}return e(t,n)},e.equals=function(t,n){return t&&n?e(t).toRgbString()==e(n).toRgbString():!1},e.random=function(){return e.fromRatio({r:U(),g:U(),b:U()})},e.mix=function(t,n,r){r=0===r?0:r||50;var a,o=e(t).toRgb(),i=e(n).toRgb(),l=r/100,s=2*l-1,c=i.a-o.a;a=s*c==-1?s:(s+c)/(1+s*c),a=(a+1)/2;var u=1-a,f={r:i.r*a+o.r*u,g:i.g*a+o.g*u,b:i.b*a+o.b*u,a:i.a*l+o.a*(1-l)};return e(f)},e.readability=function(t,n){var r=e(t),a=e(n);return(Math.max(r.getLuminance(),a.getLuminance())+.05)/(Math.min(r.getLuminance(),a.getLuminance())+.05)},e.isReadable=function(t,n,r){var a,o,i=e.readability(t,n);switch(o=!1,a=D(r),a.level+a.size){case"AAsmall":case"AAAlarge":o=i>=4.5;break;case"AAlarge":o=i>=3;break;case"AAAsmall":o=i>=7}return o},e.mostReadable=function(t,n,r){var a,o,i,l,s=null,c=0;r=r||{},o=r.includeFallbackColors,i=r.level,l=r.size;for(var u=0;uc&&(c=a,s=e(n[u]));return e.isReadable(t,s,{level:i,size:l})||!o?s:(r.includeFallbackColors=!1,e.mostReadable(t,["#fff","#000"],r))};var G=e.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},Z=e.hexNames=M(G),Y=function(){var t="[-\\+]?\\d+%?",e="[-\\+]?\\d*\\.\\d+%?",n="(?:"+e+")|(?:"+t+")",r="[\\s|\\(]+("+n+")[,|\\s]+("+n+")[,|\\s]+("+n+")\\s*\\)?",a="[\\s|\\(]+("+n+")[,|\\s]+("+n+")[,|\\s]+("+n+")[,|\\s]+("+n+")\\s*\\)?";return{rgb:new RegExp("rgb"+r),rgba:new RegExp("rgba"+a),hsl:new RegExp("hsl"+r),hsla:new RegExp("hsla"+a),hsv:new RegExp("hsv"+r),hsva:new RegExp("hsva"+a),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();"undefined"!=typeof n&&n.exports?n.exports=e:"function"==typeof t&&t.amd?t(function(){return e}):window.tinycolor=e}()},{}],15:[function(e,n,r){!function(e,a){"object"==typeof r&&"undefined"!=typeof n?a(r):"function"==typeof t&&t.amd?t(["exports"],a):a(e.topojson={})}(this,function(t){"use strict";function e(){}function n(t){if(!t)return e;var n,r,a=t.scale[0],o=t.scale[1],i=t.translate[0],l=t.translate[1];return function(t,e){e||(n=r=0),t[0]=(n+=t[0])*a+i,t[1]=(r+=t[1])*o+l}}function r(t){if(!t)return e;var n,r,a=t.scale[0],o=t.scale[1],i=t.translate[0],l=t.translate[1];return function(t,e){e||(n=r=0);var s=(t[0]-i)/a|0,c=(t[1]-l)/o|0;t[0]=s-n,t[1]=c-r,n=s,r=c}}function a(t,e){for(var n,r=t.length,a=r-e;a<--r;)n=t[a],t[a++]=t[r],t[r]=n}function o(t,e){for(var n=0,r=t.length;r>n;){var a=n+r>>>1;t[a]t?~t:t],o=0,i=r.length;i>o;++o)e.push(n=r[o].slice()),u(n,o);0>t&&a(e,i)}function o(t){return t=t.slice(),u(t,0),t}function i(t){for(var e=[],n=0,a=t.length;a>n;++n)r(t[n],e);return e.length<2&&e.push(e[0].slice()),e}function l(t){for(var e=i(t);e.length<4;)e.push(e[0].slice());return e}function s(t){return t.map(l)}function c(t){var e=t.type;return"GeometryCollection"===e?{type:e,geometries:t.geometries.map(c)}:e in d?{type:e,coordinates:d[e](t)}:null}var u=n(t.transform),f=t.arcs,d={Point:function(t){return o(t.coordinates)},MultiPoint:function(t){return t.coordinates.map(o)},LineString:function(t){return i(t.arcs)},MultiLineString:function(t){return t.arcs.map(i)},Polygon:function(t){return s(t.arcs)},MultiPolygon:function(t){return t.arcs.map(s)}};return c(e)}function c(t,e){function n(e){var n,r=t.arcs[0>e?~e:e],a=r[0];return t.transform?(n=[0,0],r.forEach(function(t){n[0]+=t[0],n[1]+=t[1]})):n=r[r.length-1],0>e?[n,a]:[a,n]}function r(t,e){for(var n in t){var r=t[n];delete e[r.start],delete r.start,delete r.end,r.forEach(function(t){a[0>t?~t:t]=1}),l.push(r)}}var a={},o={},i={},l=[],s=-1;return e.forEach(function(n,r){var a,o=t.arcs[0>n?~n:n];o.length<3&&!o[1][0]&&!o[1][1]&&(a=e[++s],e[s]=n,e[r]=a)}),e.forEach(function(t){var e,r,a=n(t),l=a[0],s=a[1];if(e=i[l])if(delete i[e.end],e.push(t),e.end=s,r=o[s]){delete o[r.start];var c=r===e?e:e.concat(r);o[c.start=e.start]=i[c.end=r.end]=c}else o[e.start]=i[e.end]=e;else if(e=o[s])if(delete o[e.start],e.unshift(t),e.start=l,r=i[l]){delete i[r.end];var u=r===e?e:r.concat(e);o[u.start=r.start]=i[u.end=e.end]=u}else o[e.start]=i[e.end]=e;else e=[t],o[e.start=l]=i[e.end=s]=e}),r(i,o),r(o,i),e.forEach(function(t){a[0>t?~t:t]||l.push([t])}),l}function u(t){return s(t,f.apply(this,arguments))}function f(t,e,n){function r(t){var e=0>t?~t:t;(u[e]||(u[e]=[])).push({i:t,g:s})}function a(t){t.forEach(r)}function o(t){t.forEach(a)}function i(t){"GeometryCollection"===t.type?t.geometries.forEach(i):t.type in f&&(s=t,f[t.type](t.arcs))}var l=[];if(arguments.length>1){var s,u=[],f={LineString:a,MultiLineString:o,Polygon:o,MultiPolygon:function(t){t.forEach(o)}};i(e),u.forEach(arguments.length<3?function(t){l.push(t[0].i)}:function(t){n(t[0].g,t[t.length-1].g)&&l.push(t[0].i)})}else for(var d=0,h=t.arcs.length;h>d;++d)l.push(d);return{type:"MultiLineString",arcs:c(t,l)}}function d(t){var e=t[0],n=t[1],r=t[2];return Math.abs((e[0]-r[0])*(n[1]-e[1])-(e[0]-n[0])*(r[1]-e[1]))}function h(t){for(var e,n=-1,r=t.length,a=t[r-1],o=0;++ne?~e:e]||(a[e]=[])).push(t)})}),o.push(t)}function r(e){return h(s(t,{type:"Polygon",arcs:[e]}).coordinates[0])>0}var a={},o=[],i=[];return e.forEach(function(t){"Polygon"===t.type?n(t.arcs):"MultiPolygon"===t.type&&t.arcs.forEach(n)}),o.forEach(function(t){if(!t._){var e=[],n=[t];for(t._=1,i.push(e);t=n.pop();)e.push(t),t.forEach(function(t){t.forEach(function(t){a[0>t?~t:t].forEach(function(t){t._||(t._=1,n.push(t))})})})}}),o.forEach(function(t){delete t._}),{type:"MultiPolygon",arcs:i.map(function(e){var n,o=[];if(e.forEach(function(t){t.forEach(function(t){t.forEach(function(t){a[0>t?~t:t].length<2&&o.push(t)})})}),o=c(t,o),(n=o.length)>1)for(var i,l=r(e[0][0]),s=0;n>s;++s)if(l===r(o[s])){i=o[0],o[0]=o[s],o[s]=i;break}return o})}}function v(t){function e(t,e){t.forEach(function(t){0>t&&(t=~t);var n=a[t];n?n.push(e):a[t]=[e]})}function n(t,n){t.forEach(function(t){e(t,n)})}function r(t,e){"GeometryCollection"===t.type?t.geometries.forEach(function(t){r(t,e)}):t.type in l&&l[t.type](t.arcs,e)}var a={},i=t.map(function(){return[]}),l={LineString:e,MultiLineString:n,Polygon:n,MultiPolygon:function(t,e){t.forEach(function(t){n(t,e)})}};t.forEach(r);for(var s in a)for(var c=a[s],u=c.length,f=0;u>f;++f)for(var d=f+1;u>d;++d){var h,p=c[f],g=c[d];(h=i[p])[s=o(h,g)]!==g&&h.splice(s,0,g),(h=i[g])[s=o(h,p)]!==p&&h.splice(s,0,p)}return i}function m(t,e){return t[1][2]-e[1][2]}function y(){function t(t,e){for(;e>0;){var n=(e+1>>1)-1,a=r[n];if(m(t,a)>=0)break;r[a._=e]=a,r[t._=e=n]=t}}function e(t,e){for(;;){var n=e+1<<1,o=n-1,i=e,l=r[i];if(a>o&&m(r[o],l)<0&&(l=r[i=o]),a>n&&m(r[n],l)<0&&(l=r[i=n]),i===e)break;r[l._=e]=l,r[t._=e=i]=t}}var n={},r=[],a=0;return n.push=function(e){return t(r[e._=a]=e,a++),a},n.pop=function(){if(!(0>=a)){var t,n=r[0];return--a>0&&(t=r[a],e(r[t._=0]=t,0)),n}},n.remove=function(n){var o,i=n._;if(r[i]===n)return i!==--a&&(o=r[a],(m(o,n)<0?t:e)(r[o._=i]=o,i)),i},n}function x(t,e){function a(t){l.remove(t),t[1][2]=e(t),l.push(t)}var o=n(t.transform),i=r(t.transform),l=y();return e||(e=d),t.arcs.forEach(function(t){var n,r,s,c,u=[],f=0;for(r=0,s=t.length;s>r;++r)c=t[r],o(t[r]=[c[0],c[1],1/0],r);for(r=1,s=t.length-1;s>r;++r)n=t.slice(r-1,r+2),n[1][2]=e(n),u.push(n),l.push(n);for(r=0,s=u.length;s>r;++r)n=u[r],n.previous=u[r-1],n.next=u[r+1];for(;n=l.pop();){var d=n.previous,h=n.next;n[1][2]d;d++){var h=s[d],p={_fullLayout:e},g=u.coerceRef(t,r,p,h),m=u.coerceARef(t,r,p,h),y=.5;if("paper"!==g){var x=u.getFromId(p,g);if(y=x.range[0]+y*(x.range[1]-x.range[0]),-1!==["date","category"].indexOf(x.type)&&"string"==typeof t[h]){var b;if("date"===x.type){if(b=c.dateTime2ms(t[h]),b!==!1&&(t[h]=b),m===g){var _=c.dateTime2ms(t["a"+h]);_!==!1&&(t["a"+h]=_)}}else(x._categories||[]).length&&(b=x._categories.indexOf(t[h]),-1!==b&&(t[h]=b))}}n(h,y),l||n(h+"anchor")}return c.noneOrAll(t,r,["x","y"]),r}function a(t){var e=t._fullLayout;e.annotations.forEach(function(e){var n=u.getFromId(t,e.xref),r=u.getFromId(t,e.yref);if(n||r){var a=(e._xsize||0)/2,o=e._xshift||0,i=(e._ysize||0)/2,l=e._yshift||0,s=a-o,c=a+o,f=i-l,d=i+l;if(e.showarrow){var h=3*e.arrowsize*e.arrowwidth;s=Math.max(s,h),c=Math.max(c,h),f=Math.max(f,h),d=Math.max(d,h)}n&&n.autorange&&u.expand(n,[n.l2c(e.x)],{ppadplus:c,ppadminus:s}),r&&r.autorange&&u.expand(r,[r.l2c(e.y)],{ppadplus:d,ppadminus:f})}})}function o(t,e,n,r,a,o,i,l){var s=n-t,c=a-t,u=i-a,f=r-e,d=o-e,h=l-o,p=s*h-u*f;if(0===p)return null;var g=(c*h-u*d)/p,v=(c*f-s*d)/p;return 0>v||v>1||0>g||g>1?null:{x:t+s*g,y:e+f*g}}var i=t("d3"),l=t("fast-isnumeric"),s=t("../../plotly"),c=t("../../lib"),u=t("../../plots/cartesian/axes"),f=t("../color"),d=t("../drawing"),h=t("../../lib/svg_text_utils"),p=t("../../lib/setcursor"),g=t("../dragelement"),v=e.exports={};v.ARROWPATHS=t("./arrow_paths"),v.layoutAttributes=t("./attributes"),v.supplyLayoutDefaults=function(t,e){for(var n=t.annotations||[],a=e.annotations=[],o=0;ot?"left":t>2/3?"right":"center"),{center:0,middle:0,left:.5,bottom:-.5,right:-.5,top:.5}[e]}tt.selectAll("tspan.line").attr({y:0,x:0});var r=X.select(".annotation-math-group"),a=!r.empty(),l=d.bBox((a?r:tt).node()),h=l.width,m=l.height,y=Math.round(h+2*W),x=Math.round(m+2*W);B._w=h,B._h=m;var b=!1;if(["x","y"].forEach(function(e){var r,a=B[e+"ref"]||e,o=u.getFromId(t,a),i=(G+("x"===e?0:90))*Math.PI/180,l=y*Math.abs(Math.cos(i))+x*Math.abs(Math.sin(i)),s=B[e+"anchor"];if(o){if(!o.autorange&&(B[e]-o.range[0])*(B[e]-o.range[1])>0&&(B["a"+e+"ref"]===a?(B["a"+e]-o.range[0])*(B["a"+e]-o.range[1])>0&&(b=!0):b=!0,b))return;U[e]=o._offset+o.l2p(B[e]),r=.5}else r=B[e],"y"===e&&(r=1-r),U[e]="x"===e?S.l+S.w*r:S.t+S.h*r;var c=0;B["a"+e+"ref"]===a?U["aa"+e]=o._offset+o.l2p(B["a"+e]):(c=B.showarrow?B["a"+e]:l*n(r,s),U[e]+=c),B["_"+e+"type"]=o&&o.type,B["_"+e+"size"]=l,B["_"+e+"shift"]=c}),b)return void X.remove();var w,k;B.showarrow&&(w=B.axref===B.xref?U.x:c.constrain(U.x-B.ax,1,_.width-1),k=B.ayref===B.yref?U.y:c.constrain(U.y-B.ay,1,_.height-1)),U.x=c.constrain(U.x,1,_.width-1),U.y=c.constrain(U.y,1,_.height-1);var M=W-l.top,A=W-l.left;a?r.select("svg").attr({x:W-1,y:W}):(tt.attr({x:A,y:M}),tt.selectAll("tspan.line").attr({y:M,x:A})),J.call(d.setRect,Q/2,Q/2,y-Q,x-Q);var T=0,L=0;T=B.axref===B.xref?Math.round(U.aax-y/2):Math.round(U.x-y/2),L=B.ayref===B.yref?Math.round(U.aay-x/2):Math.round(U.y-x/2),X.call(c.setTranslate,T,L);var z="annotations["+e+"]",C=function(n,r){i.select(t).selectAll('.annotation-arrow-g[data-index="'+e+'"]').remove();var a,l;a=B.axref===B.xref?U.aax+n:U.x+n,l=B.ayref===B.yref?U.aay+r:U.y+r;var u=c.rotationXYMatrix(G,a,l),d=c.apply2DTransform(u),h=c.apply2DTransform2(u),p=J.attr("width")/2,m=J.attr("height")/2,y=[[a-p,l-m,a-p,l+m],[a-p,l+m,a+p,l+m],[a+p,l+m,a+p,l-m],[a+p,l-m,a-p,l-m]].map(h);if(!y.reduce(function(t,e){return t^!!o(w,k,w+1e6,k+1e6,e[0],e[1],e[2],e[3])},!1)){y.forEach(function(t){var e=o(a,l,w,k,t[0],t[1],t[2],t[3]);e&&(a=e.x,l=e.y)});var x=B.arrowwidth,b=B.arrowcolor,_=Z.append("g").style({opacity:f.opacity(b)}).classed("annotation-arrow-g",!0).attr("data-index",String(e)),M=_.append("path").attr("d","M"+a+","+l+"L"+w+","+k).style("stroke-width",x+"px").call(f.stroke,f.rgb(b));v.arrowhead(M,B.arrowhead,"end",B.arrowsize);var A=_.append("path").classed("annotation",!0).classed("anndrag",!0).attr({"data-index":String(e),d:"M3,3H-3V-3H3ZM0,0L"+(a-w)+","+(l-k),transform:"translate("+w+","+k+")"}).style("stroke-width",x+6+"px").call(f.stroke,"rgba(0,0,0,0)").call(f.fill,"rgba(0,0,0,0)");if(t._context.editable){var T,L,C;g.init({element:A.node(),prepFn:function(){var t=c.getTranslate(X);L=t.x,C=t.y,T={},H&&H.autorange&&(T[H._name+".autorange"]=!0),V&&V.autorange&&(T[V._name+".autorange"]=!0)},moveFn:function(t,e){_.attr("transform","translate("+t+","+e+")");var n=d(L,C),r=n[0]+t,a=n[1]+e;X.call(c.setTranslate,r,a),T[z+".x"]=H?B.x+t/H._m:(w+t-S.l)/S.w,T[z+".y"]=V?B.y+e/V._m:1-(k+e-S.t)/S.h,B.axref===B.xref&&(T[z+".ax"]=H?B.ax+t/H._m:(w+t-S.l)/S.w),B.ayref===B.yref&&(T[z+".ay"]=V?B.ay+e/V._m:1-(k+e-S.t)/S.h),Y.attr({transform:"rotate("+G+","+r+","+a+")"})},doneFn:function(e){if(e){s.relayout(t,T);var n=document.querySelector(".js-notes-box-panel");n&&n.redraw(n.selectedObj)}}})}}};B.showarrow&&C(0,0);var E=c.rotationXYMatrix(G,U.x,U.y),O=c.apply2DTransform(E);if(t._context.editable){var N,P,j;g.init({element:X.node(),prepFn:function(){var t=c.getTranslate(X);N=t.x,P=t.y,j={}},moveFn:function(t,e){X.call(c.setTranslate,N+t,P+e);var n="pointer";if(B.showarrow)B.axref===B.xref?j[z+".ax"]=H.p2l(H.l2p(B.ax)+t):j[z+".ax"]=B.ax+t,B.ayref===B.yref?j[z+".ay"]=V.p2l(V.l2p(B.ay)+e):j[z+".ay"]=B.ay+e,C(t,e);else{if(H)j[z+".x"]=B.x+t/H._m;else{var r=B._xsize/S.w,a=B.x+B._xshift/S.w-r/2;j[z+".x"]=g.align(a+t/S.w,r,0,1,B.xanchor)}if(V)j[z+".y"]=B.y+e/V._m;else{var o=B._ysize/S.h,i=B.y-B._yshift/S.h-o/2;j[z+".y"]=g.align(i-e/S.h,o,0,1,B.yanchor)}H&&V||(n=g.getCursor(H?.5:j[z+".x"],V?.5:j[z+".y"],B.xanchor,B.yanchor))}var l=O(N,P),s=l[0]+t,u=l[1]+e;X.call(c.setTranslate,N+t,P+e),Y.attr({transform:"rotate("+G+","+s+","+u+")"}),p(X,n)},doneFn:function(e){if(p(X),e){s.relayout(t,j);var n=document.querySelector(".js-notes-box-panel");n&&n.redraw(n.selectedObj)}}})}}var x,b=t.layout,_=t._fullLayout;if(!l(e)||-1===e){if(!e&&Array.isArray(a))return b.annotations=a,v.supplyLayoutDefaults(b,_),void v.drawAll(t);if("remove"===a)return delete b.annotations,_.annotations=[],void v.drawAll(t);if(n&&"add"!==a){for(x=0;x<_.annotations.length;x++)v.draw(t,x,n,a);return}e=_.annotations.length,_.annotations.push({})}if(!n&&a){if("remove"===a){for(_._infolayer.selectAll('.annotation[data-index="'+e+'"]').remove(),_.annotations.splice(e,1),b.annotations.splice(e,1),x=e;x<_.annotations.length;x++)_._infolayer.selectAll('.annotation[data-index="'+(x+1)+'"]').attr("data-index",String(x)),v.draw(t,x);return}if("add"===a||c.isPlainObject(a)){_.annotations.splice(e,0,{});var w=c.isPlainObject(a)?c.extendFlat({},a):{text:"New text"};for(b.annotations?b.annotations.splice(e,0,w):b.annotations=[w],x=_.annotations.length-1;x>e;x--)_._infolayer.selectAll('.annotation[data-index="'+(x-1)+'"]').attr("data-index",String(x)),v.draw(t,x)}}_._infolayer.selectAll('.annotation[data-index="'+e+'"]').remove();var k=b.annotations[e],M=_.annotations[e];if(k){var A={xref:k.xref,yref:k.yref},T={};"string"==typeof n&&n?T[n]=a:c.isPlainObject(n)&&(T=n);var L=Object.keys(T);for(x=0;xx;x++){var E=C[x];if(void 0===T[E]&&void 0!==k[E]){var O=u.getFromId(t,u.coerceRef(A,{},t,E)),N=u.getFromId(t,u.coerceRef(k,{},t,E)),P=k[E],j=M["_"+E+"type"];if(void 0!==T[E+"ref"]){var D="auto"===k[E+"anchor"],R="x"===E?S.w:S.h,I=(M["_"+E+"size"]||0)/(2*R);if(O&&N)P=(P-O.range[0])/(O.range[1]-O.range[0]),P=N.range[0]+P*(N.range[1]-N.range[0]);else if(O){if(P=(P-O.range[0])/(O.range[1]-O.range[0]),P=O.domain[0]+P*(O.domain[1]-O.domain[0]),D){var q=P+I,F=P-I;2/3>P+F?P=F:P+q>4/3&&(P=q)}}else N&&(D&&(1/3>P?P+=I:P>2/3&&(P-=I)),P=(P-N.domain[0])/(N.domain[1]-N.domain[0]),P=N.range[0]+P*(N.range[1]-N.range[0]))}N&&N===O&&j&&("log"===j&&"log"!==N.type?P=Math.pow(10,P):"log"!==j&&"log"===N.type&&(P=P>0?Math.log(P)/Math.LN10:void 0)),k[E]=P}}var B=r(k,_);_.annotations[e]=B;var H=u.getFromId(t,B.xref),V=u.getFromId(t,B.yref),U={x:0,y:0},G=+B.textangle||0,Z=_._infolayer.append("g").classed("annotation",!0).attr("data-index",String(e)).style("opacity",B.opacity).on("click",function(){t._dragging=!1,t.emit("plotly_clickannotation",{index:e,annotation:k,fullAnnotation:B})}),Y=Z.append("g").classed("annotation-text-g",!0).attr("data-index",String(e)),X=Y.append("g"),Q=B.borderwidth,$=B.borderpad,W=Q+$,J=X.append("rect").attr("class","bg").style("stroke-width",Q+"px").call(f.stroke,B.bordercolor).call(f.fill,B.bgcolor),K=B.font,tt=X.append("text").classed("annotation",!0).attr("data-unformatted",B.text).text(B.text);t._context.editable?tt.call(h.makeEditable,X).call(m).on("edit",function(n){B.text=n,this.attr({"data-unformatted":B.text}),this.call(m);var r={};r["annotations["+e+"].text"]=B.text,H&&H.autorange&&(r[H._name+".autorange"]=!0),V&&V.autorange&&(r[V._name+".autorange"]=!0),s.relayout(t,r)}):tt.call(m),Y.attr({transform:"rotate("+G+","+U.x+","+U.y+")"}).call(d.setPosition,U.x,U.y)}},v.arrowhead=function(t,e,n,r){l(r)||(r=1);var a=t.node(),o=v.ARROWPATHS[e||0];if(o){"string"==typeof n&&n||(n="end");var s,c,u,h,p=(d.getPx(t,"stroke-width")||1)*r,g=t.style("stroke")||f.defaultLine,m=t.style("stroke-opacity")||1,y=n.indexOf("start")>=0,x=n.indexOf("end")>=0,b=o.backoff*p;if("line"===a.nodeName){if(s={x:+t.attr("x1"),y:+t.attr("y1")},c={x:+t.attr("x2"),y:+t.attr("y2")},u=Math.atan2(s.y-c.y,s.x-c.x),h=u+Math.PI,b){var _=b*Math.cos(u),w=b*Math.sin(u);y&&(s.x-=_,s.y-=w,t.attr({x1:s.x,y1:s.y})),x&&(c.x+=_,c.y+=w,t.attr({x2:c.x,y2:c.y}))}}else if("path"===a.nodeName){var k=a.getTotalLength(),M="";if(y){var A=a.getPointAtLength(0),T=a.getPointAtLength(.1);u=Math.atan2(A.y-T.y,A.x-T.x),s=a.getPointAtLength(Math.min(b,k)),b&&(M="0px,"+b+"px,")}if(x){var L=a.getPointAtLength(k),z=a.getPointAtLength(k-.1);if(h=Math.atan2(L.y-z.y,L.x-z.x),c=a.getPointAtLength(Math.max(0,k-b)),b){var S=M?2*b:b;M+=k-S+"px,"+k+"px"}}else M&&(M+=k+"px");M&&t.style("stroke-dasharray",M)}var C=function(n,r){e>5&&(r=0),i.select(a.parentElement).append("path").attr({"class":t.attr("class"),d:o.path,transform:"translate("+n.x+","+n.y+")rotate("+180*r/Math.PI+")scale("+p+")"}).style({fill:g,opacity:m,"stroke-width":0})};y&&C(s,u),x&&C(c,h)}},v.calcAutorange=function(t){var e=t._fullLayout,n=e.annotations;if(n.length&&t._fullData.length){var r={};n.forEach(function(t){r[t.xref]=!0,r[t.yref]=!0});var o=u.list(t).filter(function(t){return t.autorange&&r[t._id]});if(o.length)return c.syncOrAsync([v.drawAll,a],t)}}},{"../../lib":99,"../../lib/setcursor":108,"../../lib/svg_text_utils":110,"../../plotly":118,"../../plots/cartesian/axes":121,"../color":20,"../dragelement":41,"../drawing":43,"./arrow_paths":16,"./attributes":17,d3:10,"fast-isnumeric":12}],19:[function(t,e,n){"use strict";n.defaults=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],n.defaultLine="#444",n.lightLine="#eee",n.background="#fff",n.borderLine="#BEC8D9",n.lightFraction=1e3/11},{}],20:[function(t,e,n){"use strict";function r(t){if(o(t)||"string"!=typeof t)return t;var e=t.trim();if("rgb"!==e.substr(0,3))return t;var n=e.match(/^rgba?\s*\(([^()]*)\)$/);if(!n)return t;var r=n[1].trim().split(/\s*[\s,]\s*/),a="a"===e.charAt(3)&&4===r.length;if(!a&&3!==r.length)return t;for(var i=0;i=0))return t;if(3===i)r[i]>1&&(r[i]=1);else if(r[i]>=1)return t}var l=Math.round(255*r[0])+", "+Math.round(255*r[1])+", "+Math.round(255*r[2]);return a?"rgba("+l+", "+r[3]+")":"rgb("+l+")"}var a=t("tinycolor2"),o=t("fast-isnumeric"),i=e.exports={},l=t("./attributes");i.defaults=l.defaults,i.defaultLine=l.defaultLine,i.lightLine=l.lightLine,i.background=l.background,i.tinyRGB=function(t){var e=t.toRgb();return"rgb("+Math.round(e.r)+", "+Math.round(e.g)+", "+Math.round(e.b)+")"},i.rgb=function(t){return i.tinyRGB(a(t))},i.opacity=function(t){return t?a(t).getAlpha():0},i.addOpacity=function(t,e){var n=a(t).toRgb();return"rgba("+Math.round(n.r)+", "+Math.round(n.g)+", "+Math.round(n.b)+", "+e+")"},i.combine=function(t,e){var n=a(t).toRgb();if(1===n.a)return a(t).toRgbString();var r=a(e||i.background).toRgb(),o=1===r.a?r:{r:255*(1-r.a)+r.r*r.a,g:255*(1-r.a)+r.g*r.a,b:255*(1-r.a)+r.b*r.a},l={r:o.r*(1-n.a)+n.r*n.a,g:o.g*(1-n.a)+n.g*n.a,b:o.b*(1-n.a)+n.b*n.a};return a(l).toRgbString()},i.contrast=function(t,e,n){var r=a(t),o=r.isLight()?r.darken(n):r.lighten(e);return o.toString()},i.stroke=function(t,e){var n=a(e);t.style({stroke:i.tinyRGB(n),"stroke-opacity":n.getAlpha()})},i.fill=function(t,e){var n=a(e);t.style({fill:i.tinyRGB(n),"fill-opacity":n.getAlpha()})},i.clean=function(t){if(t&&"object"==typeof t){var e,n,a,o,l=Object.keys(t);for(e=0;es&&(o[1]-=(it-s)/2)):n.node()&&!n.classed("js-placeholder")&&(it=d.bBox(e.node()).height),it){if(it+=5,"top"===b.titleside)J.domain[1]-=it/A.h,o[1]*=-1;else{J.domain[0]+=it/A.h;var u=Math.max(1,n.selectAll("tspan.line").size());o[1]+=(1-u)*s}e.attr("transform","translate("+o+")"),J.setScale()}}at.selectAll(".cbfills,.cblines,.cbaxis").attr("transform","translate(0,"+Math.round(A.h*(1-J.domain[1]))+")");var f=at.select(".cbfills").selectAll("rect.cbfill").data(S);f.enter().append("rect").classed("cbfill",!0).style("stroke","none"),f.exit().remove(),f.each(function(t,e){var n=[0===e?L[0]:(S[e]+S[e-1])/2,e===S.length-1?L[1]:(S[e]+S[e+1])/2].map(J.c2p).map(Math.round);e!==S.length-1&&(n[1]+=n[1]>n[0]?1:-1);var o=E(t).replace("e-",""),i=a(o).toHexString();r.select(this).attr({x:Z,width:Math.max(q,2),y:r.min(n),height:Math.max(r.max(n)-r.min(n),2),fill:i})});var h=at.select(".cblines").selectAll("path.cbline").data(b.line.color&&b.line.width?z:[]);return h.enter().append("path").classed("cbline",!0),h.exit().remove(),h.each(function(t){r.select(this).attr("d","M"+Z+","+(Math.round(J.c2p(t))+b.line.width/2%1)+"h"+q).call(d.lineGroupStyle,b.line.width,C(t),b.line.dash)}),J._axislayer.selectAll("g."+J._id+"tick,path").remove(),J._pos=Z+q+(b.outlinewidth||0)/2-("outside"===b.ticks?1:0),J.side="right",c.syncOrAsync([function(){return l.doTicks(t,J,!0)},function(){if(-1===["top","bottom"].indexOf(b.titleside)){var e=J.titlefont.size,n=J._offset+J._length/2,a=A.l+(J.position||0)*A.w+("right"===J.side?10+e*(J.showticklabels?1:.5):-10-e*(J.showticklabels?.5:0));w("h"+J._id+"title",{avoid:{selection:r.select(t).selectAll("g."+J._id+"tick"),side:b.titleside,offsetLeft:A.l,offsetTop:A.t,maxShift:M.width},attributes:{x:a,y:n,"text-anchor":"middle"},transform:{rotate:"-90",offset:0}})}}])}function w(e,n){var r,a=x();r=i.traceIs(a,"markerColorscale")?"marker.colorbar.title":"colorbar.title";var o={propContainer:J,propName:r,traceIndex:a.index,dfltName:"colorscale",containerGroup:at.select(".cbtitle")},l="h"===e.charAt(0)?e.substr(1):"h"+e;at.selectAll("."+l+",."+l+"-math-group").remove(),p.draw(t,e,u(o,n||{}))}function k(){var n=q+b.outlinewidth/2+d.bBox(J._axislayer.node()).width;if(D=ot.select("text"),D.node()&&!D.classed("js-placeholder")){var r,a=ot.select(".h"+J._id+"title-math-group").node();r=a&&-1!==["top","bottom"].indexOf(b.titleside)?d.bBox(a).width:d.bBox(ot.node()).right-Z-A.l,n=Math.max(n,r)}var o=2*b.xpad+n+b.borderwidth+b.outlinewidth/2,l=Q-$;at.select(".cbbg").attr({ +-x:Z-b.xpad-(b.borderwidth+b.outlinewidth)/2,y:$-U,width:Math.max(o,2),height:Math.max(l+2*U,2)}).call(h.fill,b.bgcolor).call(h.stroke,b.bordercolor).style({"stroke-width":b.borderwidth}),at.selectAll(".cboutline").attr({x:Z,y:$+b.ypad+("top"===b.titleside?it:0),width:Math.max(q,2),height:Math.max(l-2*b.ypad-it,2)}).call(h.stroke,b.outlinecolor).style({fill:"None","stroke-width":b.outlinewidth});var s=({center:.5,right:1}[b.xanchor]||0)*o;at.attr("transform","translate("+(A.l-s)+","+A.t+")"),i.autoMargin(t,e,{x:b.x,y:b.y,l:o*({right:1,center:.5}[b.xanchor]||0),r:o*({left:1,center:.5}[b.xanchor]||0),t:l*({bottom:1,middle:.5}[b.yanchor]||0),b:l*({top:1,middle:.5}[b.yanchor]||0)})}var M=t._fullLayout,A=M._size;if("function"!=typeof b.fillcolor&&"function"!=typeof b.line.color)return void M._infolayer.selectAll("g."+e).remove();var T,L=r.extent(("function"==typeof b.fillcolor?b.fillcolor:b.line.color).domain()),z=[],S=[],C="function"==typeof b.line.color?b.line.color:function(){return b.line.color},E="function"==typeof b.fillcolor?b.fillcolor:function(){return b.fillcolor},O=b.levels.end+b.levels.size/100,N=b.levels.size,P=1.001*L[0]-.001*L[1],j=1.001*L[1]-.001*L[0];for(T=b.levels.start;0>(T-O)*N;T+=N)T>P&&j>T&&z.push(T);if("function"==typeof b.fillcolor)if(b.filllevels)for(O=b.filllevels.end+b.filllevels.size/100,N=b.filllevels.size,T=b.filllevels.start;0>(T-O)*N;T+=N)T>L[0]&&T1){var rt=Math.pow(10,Math.floor(Math.log(nt)/Math.LN10));tt*=rt*c.roundUp(nt/rt,[2,5,10]),(Math.abs(b.levels.start)/b.levels.size+1e-6)%1<2e-6&&(J.tick0=0)}J.dtick=tt}J.domain=[X+G,X+H-G],J.setScale();var at=M._infolayer.selectAll("g."+e).data([0]);at.enter().append("g").classed(e,!0).each(function(){var t=r.select(this);t.append("rect").classed("cbbg",!0),t.append("g").classed("cbfills",!0),t.append("g").classed("cblines",!0),t.append("g").classed("cbaxis",!0).classed("crisp",!0),t.append("g").classed("cbtitleunshift",!0).append("g").classed("cbtitle",!0),t.append("rect").classed("cboutline",!0),t.select(".cbtitle").datum(0)}),at.attr("transform","translate("+Math.round(A.l)+","+Math.round(A.t)+")");var ot=at.select(".cbtitleunshift").attr("transform","translate(-"+Math.round(A.l)+",-"+Math.round(A.t)+")");J._axislayer=at.select(".cbaxis");var it=0;if(-1!==["top","bottom"].indexOf(b.titleside)){var lt,st=A.l+(b.x+V)*A.w,ct=J.titlefont.size;lt="top"===b.titleside?(1-(X+H-G))*A.h+A.t+3+.75*ct:(1-(X+G))*A.h+A.t-3-.25*ct,w(J._id+"title",{attributes:{x:st,y:lt,"text-anchor":"start"}})}var ut=c.syncOrAsync([i.previousPromises,_,i.previousPromises,k],t);if(ut&&ut.then&&(t._promises||[]).push(ut),t._context.editable){var ft,dt,ht;s.init({element:at.node(),prepFn:function(){ft=at.attr("transform"),f(at)},moveFn:function(t,e){at.attr("transform",ft+" translate("+t+","+e+")"),dt=s.align(Y+t/A.w,F,0,1,b.xanchor),ht=s.align(X-e/A.h,H,0,1,b.yanchor);var n=s.getCursor(dt,ht,b.xanchor,b.yanchor);f(at,n)},doneFn:function(e){f(at),e&&void 0!==dt&&void 0!==ht&&o.restyle(t,{"colorbar.x":dt,"colorbar.y":ht},x().index)}})}return ut}function x(){var n,r,a=e.substr(2);for(n=0;nu*f?a.RdBu:u>=0?a.Reds:a.Blues,s.colorscale=d,l.reversescale&&(d=o(d)),l.colorscale=d)}},{"../../lib":99,"./flip_scale":31,"./scales":38}],28:[function(t,e,n){"use strict";var r=t("./attributes"),a=t("../../lib/extend").extendDeep;t("./scales.js");e.exports=function(t){return{color:{valType:"color",arrayOk:!0},colorscale:a({},r.colorscale,{}),cauto:a({},r.zauto,{}),cmax:a({},r.zmax,{}),cmin:a({},r.zmin,{}),autocolorscale:a({},r.autocolorscale,{}),reversescale:a({},r.reversescale,{})}}},{"../../lib/extend":96,"./attributes":26,"./scales.js":38}],29:[function(t,e,n){"use strict";var r=t("./scales");e.exports=r.RdBu},{"./scales":38}],30:[function(t,e,n){"use strict";var r=t("fast-isnumeric"),a=t("../../lib"),o=t("../colorbar/has_colorbar"),i=t("../colorbar/defaults"),l=t("./is_valid_scale"),s=t("./flip_scale");e.exports=function(t,e,n,c,u){var f=u.prefix,d=u.cLetter,h=f.slice(0,f.length-1),p=f?a.nestedProperty(t,h).get()||{}:t,g=f?a.nestedProperty(e,h).get()||{}:e,v=p[d+"min"],m=p[d+"max"],y=p.colorscale,x=r(v)&&r(m)&&m>v;c(f+d+"auto",!x),c(f+d+"min"),c(f+d+"max");var b;void 0!==y&&(b=!l(y)),c(f+"autocolorscale",b);var _=c(f+"colorscale"),w=c(f+"reversescale");if(w&&(g.colorscale=s(_)),"marker.line."!==f){var k;f&&(k=o(p));var M=c(f+"showscale",k);M&&i(p,g,n)}}},{"../../lib":99,"../colorbar/defaults":22,"../colorbar/has_colorbar":24,"./flip_scale":31,"./is_valid_scale":35,"fast-isnumeric":12}],31:[function(t,e,n){"use strict";e.exports=function(t){for(var e,n=t.length,r=new Array(n),a=n-1,o=0;a>=0;a--,o++)e=t[a],r[o]=[1-e[0],e[1]];return r}},{}],32:[function(t,e,n){"use strict";var r=t("./scales"),a=t("./default_scale"),o=t("./is_valid_scale_array");e.exports=function(t,e){function n(){try{t=r[t]||JSON.parse(t)}catch(n){t=e}}return e||(e=a),t?("string"==typeof t&&(n(),"string"==typeof t&&n()),o(t)?t:e):e}},{"./default_scale":29,"./is_valid_scale_array":36,"./scales":38}],33:[function(t,e,n){"use strict";var r=t("fast-isnumeric"),a=t("../../lib"),o=t("./is_valid_scale");e.exports=function(t,e){var n=e?a.nestedProperty(t,e).get()||{}:t,i=n.color,l=!1;if(Array.isArray(i))for(var s=0;sd;d++)s=t[d],u[d]=e+s[0]*(n-e),f[d]=a(s[1]).toRgb();var h=r.scale.linear().domain(u).interpolate(r.interpolateObject).range(f);return function(t){if(o(t)){var r=i.constrain(t,e,n),s=h(r);return a(s).toRgbString()}return a(t).isValid()?t:l.defaultLine}}},{"../../lib":99,"../color":20,d3:10,"fast-isnumeric":12,tinycolor2:14}],38:[function(t,e,n){"use strict";e.exports={Greys:[[0,"rgb(0,0,0)"],[1,"rgb(255,255,255)"]],YlGnBu:[[0,"rgb(8,29,88)"],[.125,"rgb(37,52,148)"],[.25,"rgb(34,94,168)"],[.375,"rgb(29,145,192)"],[.5,"rgb(65,182,196)"],[.625,"rgb(127,205,187)"],[.75,"rgb(199,233,180)"],[.875,"rgb(237,248,217)"],[1,"rgb(255,255,217)"]],Greens:[[0,"rgb(0,68,27)"],[.125,"rgb(0,109,44)"],[.25,"rgb(35,139,69)"],[.375,"rgb(65,171,93)"],[.5,"rgb(116,196,118)"],[.625,"rgb(161,217,155)"],[.75,"rgb(199,233,192)"],[.875,"rgb(229,245,224)"],[1,"rgb(247,252,245)"]],YlOrRd:[[0,"rgb(128,0,38)"],[.125,"rgb(189,0,38)"],[.25,"rgb(227,26,28)"],[.375,"rgb(252,78,42)"],[.5,"rgb(253,141,60)"],[.625,"rgb(254,178,76)"],[.75,"rgb(254,217,118)"],[.875,"rgb(255,237,160)"],[1,"rgb(255,255,204)"]],Bluered:[[0,"rgb(0,0,255)"],[1,"rgb(255,0,0)"]],RdBu:[[0,"rgb(5,10,172)"],[.35,"rgb(106,137,247)"],[.5,"rgb(190,190,190)"],[.6,"rgb(220,170,132)"],[.7,"rgb(230,145,90)"],[1,"rgb(178,10,28)"]],Reds:[[0,"rgb(220,220,220)"],[.2,"rgb(245,195,157)"],[.4,"rgb(245,160,105)"],[1,"rgb(178,10,28)"]],Blues:[[0,"rgb(5,10,172)"],[.35,"rgb(40,60,190)"],[.5,"rgb(70,100,245)"],[.6,"rgb(90,120,245)"],[.7,"rgb(106,137,247)"],[1,"rgb(220,220,220)"]],Picnic:[[0,"rgb(0,0,255)"],[.1,"rgb(51,153,255)"],[.2,"rgb(102,204,255)"],[.3,"rgb(153,204,255)"],[.4,"rgb(204,204,255)"],[.5,"rgb(255,255,255)"],[.6,"rgb(255,204,255)"],[.7,"rgb(255,153,255)"],[.8,"rgb(255,102,204)"],[.9,"rgb(255,102,102)"],[1,"rgb(255,0,0)"]],Rainbow:[[0,"rgb(150,0,90)"],[.125,"rgb(0,0,200)"],[.25,"rgb(0,25,255)"],[.375,"rgb(0,152,255)"],[.5,"rgb(44,255,150)"],[.625,"rgb(151,255,0)"],[.75,"rgb(255,234,0)"],[.875,"rgb(255,111,0)"],[1,"rgb(255,0,0)"]],Portland:[[0,"rgb(12,51,131)"],[.25,"rgb(10,136,186)"],[.5,"rgb(242,211,56)"],[.75,"rgb(242,143,56)"],[1,"rgb(217,30,30)"]],Jet:[[0,"rgb(0,0,131)"],[.125,"rgb(0,60,170)"],[.375,"rgb(5,255,255)"],[.625,"rgb(255,255,0)"],[.875,"rgb(250,0,0)"],[1,"rgb(128,0,0)"]],Hot:[[0,"rgb(0,0,0)"],[.3,"rgb(230,0,0)"],[.6,"rgb(255,210,0)"],[1,"rgb(255,255,255)"]],Blackbody:[[0,"rgb(0,0,0)"],[.2,"rgb(230,0,0)"],[.4,"rgb(230,210,0)"],[.7,"rgb(255,255,255)"],[1,"rgb(160,200,255)"]],Earth:[[0,"rgb(0,0,130)"],[.1,"rgb(0,180,180)"],[.2,"rgb(40,210,40)"],[.4,"rgb(230,230,50)"],[.6,"rgb(120,70,20)"],[1,"rgb(255,255,255)"]],Electric:[[0,"rgb(0,0,0)"],[.15,"rgb(30,0,100)"],[.4,"rgb(120,0,100)"],[.6,"rgb(160,90,0)"],[.8,"rgb(230,200,0)"],[1,"rgb(255,250,220)"]],Viridis:[[0,"#440154"],[.06274509803921569,"#48186a"],[.12549019607843137,"#472d7b"],[.18823529411764706,"#424086"],[.25098039215686274,"#3b528b"],[.3137254901960784,"#33638d"],[.3764705882352941,"#2c728e"],[.4392156862745098,"#26828e"],[.5019607843137255,"#21918c"],[.5647058823529412,"#1fa088"],[.6274509803921569,"#28ae80"],[.6901960784313725,"#3fbc73"],[.7529411764705882,"#5ec962"],[.8156862745098039,"#84d44b"],[.8784313725490196,"#addc30"],[.9411764705882353,"#d8e219"],[1,"#fde725"]]}},{}],39:[function(t,e,n){"use strict";e.exports=function(t,e,n,r,a){var o=(t-n)/(r-n),i=o+e/(r-n),l=(o+i)/2;return"left"===a||"bottom"===a?o:"center"===a||"middle"===a?l:"right"===a||"top"===a?i:2/3-l>o?o:i>4/3-l?i:l}},{}],40:[function(t,e,n){"use strict";var r=t("../../lib"),a=[["sw-resize","s-resize","se-resize"],["w-resize","move","e-resize"],["nw-resize","n-resize","ne-resize"]];e.exports=function(t,e,n,o){return t="left"===n?0:"center"===n?1:"right"===n?2:r.constrain(Math.floor(3*t),0,2),e="bottom"===o?0:"middle"===o?1:"top"===o?2:r.constrain(Math.floor(3*e),0,2),a[e][t]}},{"../../lib":99}],41:[function(t,e,n){"use strict";function r(){var t=document.createElement("div");t.className="dragcover";var e=t.style;return e.position="fixed",e.left=0,e.right=0,e.top=0,e.bottom=0,e.zIndex=999999999,e.background="none",document.body.appendChild(t),t}function a(t){t._dragging=!1,t._replotPending&&o.plot(t)}var o=t("../../plotly"),i=t("../../lib"),l=t("../../plots/cartesian/constants"),s=e.exports={};s.align=t("./align"),s.getCursor=t("./cursor");var c=t("./unhover");s.unhover=c.wrapped,s.unhoverRaw=c.raw,s.init=function(t){function e(e){return t.element.onmousemove=p,g._dragged=!1,g._dragging=!0,c=e.clientX,u=e.clientY,h=e.target,f=(new Date).getTime(),f-g._mouseDownTimem&&(v=Math.max(v-1,1)),t.doneFn&&t.doneFn(g._dragged,v),!g._dragged){var n=document.createEvent("MouseEvents");n.initEvent("click",!0,!0),h.dispatchEvent(n)}return a(g),g._dragged=!1,i.pauseEvent(e)}var c,u,f,d,h,p,g=i.getPlotDiv(t.element)||{},v=1,m=l.DBLCLICKDELAY;g._mouseDownTime||(g._mouseDownTime=0),p=t.element.onmousemove,t.setCursor&&(t.element.onmousemove=t.setCursor),t.element.onmousedown=e,t.element.style.pointerEvents="all"}},{"../../lib":99,"../../plotly":118,"../../plots/cartesian/constants":126,"./align":39,"./cursor":40,"./unhover":42}],42:[function(t,e,n){"use strict";var r=t("../../lib/events"),a=e.exports={};a.wrapped=function(t,e,n){"string"==typeof t&&(t=document.getElementById(t)),t._hoverTimer&&(clearTimeout(t._hoverTimer),t._hoverTimer=void 0),a.raw(t,e,n)},a.raw=function(t,e){var n=t._fullLayout;e||(e={}),e.target&&r.triggerHandler(t,"plotly_beforehover",e)===!1||(n._hoverlayer.selectAll("g").remove(),e.target&&t._hoverdata&&t.emit("plotly_unhover",{points:t._hoverdata}),t._hoverdata=void 0)}},{"../../lib/events":95}],43:[function(t,e,n){"use strict";function r(t,e,n,r){var o=t[0]-e[0],i=t[1]-e[1],l=n[0]-e[0],s=n[1]-e[1],c=Math.pow(o*o+i*i,b/2),u=Math.pow(l*l+s*s,b/2),f=(u*u*o-c*c*l)*r,d=(u*u*i-c*c*s)*r,h=3*u*(c+u),p=3*c*(c+u);return[[a.round(e[0]+(h&&f/h),2),a.round(e[1]+(h&&d/h),2)],[a.round(e[0]-(p&&f/p),2),a.round(e[1]-(p&&d/p),2)]]}var a=t("d3"),o=t("fast-isnumeric"),i=t("../../plots/plots"),l=t("../color"),s=t("../colorscale"),c=t("../../lib"),u=t("../../lib/svg_text_utils"),f=t("../../constants/xmlns_namespaces"),d=t("../../traces/scatter/subtypes"),h=t("../../traces/scatter/make_bubble_size_func"),p=e.exports={};p.font=function(t,e,n,r){e&&e.family&&(r=e.color,n=e.size,e=e.family),e&&t.style("font-family",e),n+1&&t.style("font-size",n+"px"),r&&t.call(l.fill,r)},p.setPosition=function(t,e,n){t.attr("x",e).attr("y",n)},p.setSize=function(t,e,n){t.attr("width",e).attr("height",n)},p.setRect=function(t,e,n,r,a){t.call(p.setPosition,e,n).call(p.setSize,r,a)},p.translatePoints=function(t,e,n){t.each(function(t){var r=t.xp||e.c2p(t.x),i=t.yp||n.c2p(t.y),l=a.select(this);o(r)&&o(i)?"text"===this.nodeName?l.attr("x",r).attr("y",i):l.attr("transform","translate("+r+","+i+")"):l.remove()})},p.getPx=function(t,e){return Number(t.style(e).replace(/px$/,""))},p.crispRound=function(t,e,n){return e&&o(e)?t._context.staticPlot?e:1>e?1:Math.round(e):n||0},p.lineGroupStyle=function(t,e,n,r){t.style("fill","none").each(function(t){var o=(((t||[])[0]||{}).trace||{}).line||{},i=e||o.width||0,s=r||o.dash||"";a.select(this).call(l.stroke,n||o.color).call(p.dashLine,s,i)})},p.dashLine=function(t,e,n){var r=Math.max(n,3);"solid"===e?e="":"dot"===e?e=r+"px,"+r+"px":"dash"===e?e=3*r+"px,"+3*r+"px":"longdash"===e?e=5*r+"px,"+5*r+"px":"dashdot"===e?e=3*r+"px,"+r+"px,"+r+"px,"+r+"px":"longdashdot"===e&&(e=5*r+"px,"+2*r+"px,"+r+"px,"+2*r+"px"),t.style({"stroke-dasharray":e,"stroke-width":n+"px"})},p.fillGroupStyle=function(t){t.style("stroke-width",0).each(function(e){var n=a.select(this);try{n.call(l.fill,e[0].trace.fillcolor)}catch(r){c.error(r,t),n.remove()}})};var g=t("./symbol_defs");p.symbolNames=[],p.symbolFuncs=[],p.symbolNeedLines={},p.symbolNoDot={},p.symbolList=[],Object.keys(g).forEach(function(t){var e=g[t];p.symbolList=p.symbolList.concat([e.n,t,e.n+100,t+"-open"]),p.symbolNames[e.n]=t,p.symbolFuncs[e.n]=e.f,e.needLine&&(p.symbolNeedLines[e.n]=!0),e.noDot?p.symbolNoDot[e.n]=!0:p.symbolList=p.symbolList.concat([e.n+200,t+"-dot",e.n+300,t+"-open-dot"])});var v=p.symbolNames.length,m="M0,0.5L0.5,0L0,-0.5L-0.5,0Z";p.symbolNumber=function(t){if("string"==typeof t){var e=0;t.indexOf("-open")>0&&(e=100,t=t.replace("-open","")),t.indexOf("-dot")>0&&(e+=200,t=t.replace("-dot","")),t=p.symbolNames.indexOf(t),t>=0&&(t+=e)}return t%100>=v||t>=400?0:Math.floor(Math.max(t,0))},p.pointStyle=function(t,e){if(t.size()){var n=e.marker,r=n.line;if(i.traceIs(e,"symbols")){var o=h(e);t.attr("d",function(t){var r;r="various"===t.ms||"various"===n.size?3:d.isBubble(e)?o(t.ms):(n.size||6)/2,t.mrc=r;var a=p.symbolNumber(t.mx||n.symbol)||0,i=a%100;return t.om=a%200>=100,p.symbolFuncs[i](r)+(a>=200?m:"")}).style("opacity",function(t){return(t.mo+1||n.opacity+1)-1})}var s=(e._input||{}).marker||{},c=p.tryColorscale(n,s,""),u=p.tryColorscale(n,s,"line.");t.each(function(t){var e,o,i;t.so?(i=r.outlierwidth,o=r.outliercolor,e=n.outliercolor):(i=(t.mlw+1||r.width+1||(t.trace?t.trace.marker.line.width:0)+1)-1,o="mlc"in t?t.mlcc=u(t.mlc):Array.isArray(r.color)?l.defaultLine:r.color,e="mc"in t?t.mcc=c(t.mc):Array.isArray(n.color)?l.defaultLine:n.color||"rgba(0,0,0,0)");var s=a.select(this);t.om?s.call(l.stroke,e).style({"stroke-width":(i||1)+"px",fill:"none"}):(s.style("stroke-width",i+"px").call(l.fill,e),i&&s.call(l.stroke,o))})}},p.tryColorscale=function(t,e,n){var r=c.nestedProperty(t,n+"color").get(),a=c.nestedProperty(t,n+"colorscale").get(),i=c.nestedProperty(t,n+"cauto").get(),l=c.nestedProperty(t,n+"cmin"),u=c.nestedProperty(t,n+"cmax"),f=l.get(),d=u.get();return a&&Array.isArray(r)?(!i&&o(f)&&o(d)||(f=1/0,d=-(1/0),r.forEach(function(t){o(t)&&(f>t&&(f=+t),t>d&&(d=+t))}),f>d&&(f=0,d=1),l.set(f),u.set(d),c.nestedProperty(e,n+"cmin").set(f),c.nestedProperty(e,n+"cmax").set(d)),s.makeScaleFunction(a,f,d)):c.identity};var y={start:1,end:-1,middle:0,bottom:1,top:-1},x=1.3;p.textPointStyle=function(t,e){t.each(function(t){var n=a.select(this),r=t.tx||e.text;if(!r||Array.isArray(r))return void n.remove();var i=t.tp||e.textposition,l=-1!==i.indexOf("top")?"top":-1!==i.indexOf("bottom")?"bottom":"middle",s=-1!==i.indexOf("left")?"end":-1!==i.indexOf("right")?"start":"middle",c=t.ts||e.textfont.size,f=t.mrc?t.mrc/.8+1:0;c=o(c)&&c>0?c:0,n.call(p.font,t.tf||e.textfont.family,c,t.tc||e.textfont.color).attr("text-anchor",s).text(r).call(u.convertToTspans);var d=a.select(this.parentNode),h=n.selectAll("tspan.line"),g=((h[0].length||1)-1)*x+1,v=y[s]*f,m=.75*c+y[l]*f+(y[l]-1)*g*c/2;d.attr("transform","translate("+v+","+m+")"),g>1&&h.attr({x:n.attr("x"),y:n.attr("y")})})};var b=.5;p.smoothopen=function(t,e){if(t.length<3)return"M"+t.join("L");var n,a="M"+t[0],o=[];for(n=1;nn;n++)i.push(r(t[n-1],t[n],t[n+1],e));for(i.push(r(t[o-1],t[o],t[0],e)),n=1;o>=n;n++)a+="C"+i[n-1][1]+" "+i[n][0]+" "+t[n];return a+="C"+i[o][1]+" "+i[0][0]+" "+t[0]+"Z"};var _={hv:function(t,e){return"H"+a.round(e[0],2)+"V"+a.round(e[1],2)},vh:function(t,e){return"V"+a.round(e[1],2)+"H"+a.round(e[0],2)},hvh:function(t,e){return"H"+a.round((t[0]+e[0])/2,2)+"V"+a.round(e[1],2)+"H"+a.round(e[0],2)},vhv:function(t,e){return"V"+a.round((t[1]+e[1])/2,2)+"H"+a.round(e[0],2)+"V"+a.round(e[1],2)}},w=function(t,e){return"L"+a.round(e[0],2)+","+a.round(e[1],2)};p.steps=function(t){var e=_[t]||w;return function(t){for(var n="M"+a.round(t[0][0],2)+","+a.round(t[0][1],2),r=1;r=M&&(a.selectAll("[data-bb]").attr("data-bb",null),k=[]),t.setAttribute("data-bb",k.length),k.push(s),c.extendFlat({},s)},p.setClipUrl=function(t,e){if(!e)return void t.attr("clip-path",null);var n="#"+e,r=a.select("base");r.size()&&r.attr("href")&&(n=window.location.href+n),t.attr("clip-path","url("+n+")")}},{"../../constants/xmlns_namespaces":89,"../../lib":99,"../../lib/svg_text_utils":110,"../../plots/plots":153,"../../traces/scatter/make_bubble_size_func":189,"../../traces/scatter/subtypes":194,"../color":20,"../colorscale":34,"./symbol_defs":44,d3:10,"fast-isnumeric":12}],44:[function(t,e,n){"use strict";var r=t("d3");e.exports={circle:{n:0,f:function(t){var e=r.round(t,2);return"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"}},square:{n:1,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"}},diamond:{n:2,f:function(t){var e=r.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"Z"}},cross:{n:3,f:function(t){var e=r.round(.4*t,2),n=r.round(1.2*t,2);return"M"+n+","+e+"H"+e+"V"+n+"H-"+e+"V"+e+"H-"+n+"V-"+e+"H-"+e+"V-"+n+"H"+e+"V-"+e+"H"+n+"Z"}},x:{n:4,f:function(t){var e=r.round(.8*t/Math.sqrt(2),2),n="l"+e+","+e,a="l"+e+",-"+e,o="l-"+e+",-"+e,i="l-"+e+","+e;return"M0,"+e+n+a+o+a+o+i+o+i+n+i+n+"Z"}},"triangle-up":{n:5,f:function(t){var e=r.round(2*t/Math.sqrt(3),2),n=r.round(t/2,2),a=r.round(t,2);return"M-"+e+","+n+"H"+e+"L0,-"+a+"Z"}},"triangle-down":{n:6,f:function(t){var e=r.round(2*t/Math.sqrt(3),2),n=r.round(t/2,2),a=r.round(t,2);return"M-"+e+",-"+n+"H"+e+"L0,"+a+"Z"}},"triangle-left":{n:7,f:function(t){var e=r.round(2*t/Math.sqrt(3),2),n=r.round(t/2,2),a=r.round(t,2);return"M"+n+",-"+e+"V"+e+"L-"+a+",0Z"}},"triangle-right":{n:8,f:function(t){var e=r.round(2*t/Math.sqrt(3),2),n=r.round(t/2,2),a=r.round(t,2);return"M-"+n+",-"+e+"V"+e+"L"+a+",0Z"}},"triangle-ne":{n:9,f:function(t){var e=r.round(.6*t,2),n=r.round(1.2*t,2);return"M-"+n+",-"+e+"H"+e+"V"+n+"Z"}},"triangle-se":{n:10,f:function(t){var e=r.round(.6*t,2),n=r.round(1.2*t,2);return"M"+e+",-"+n+"V"+e+"H-"+n+"Z"}},"triangle-sw":{n:11,f:function(t){var e=r.round(.6*t,2),n=r.round(1.2*t,2);return"M"+n+","+e+"H-"+e+"V-"+n+"Z"}},"triangle-nw":{n:12,f:function(t){var e=r.round(.6*t,2),n=r.round(1.2*t,2);return"M-"+e+","+n+"V-"+e+"H"+n+"Z"}},pentagon:{n:13,f:function(t){var e=r.round(.951*t,2),n=r.round(.588*t,2),a=r.round(-t,2),o=r.round(t*-.309,2),i=r.round(.809*t,2);return"M"+e+","+o+"L"+n+","+i+"H-"+n+"L-"+e+","+o+"L0,"+a+"Z"}},hexagon:{n:14,f:function(t){var e=r.round(t,2),n=r.round(t/2,2),a=r.round(t*Math.sqrt(3)/2,2);return"M"+a+",-"+n+"V"+n+"L0,"+e+"L-"+a+","+n+"V-"+n+"L0,-"+e+"Z"}},hexagon2:{n:15,f:function(t){var e=r.round(t,2),n=r.round(t/2,2),a=r.round(t*Math.sqrt(3)/2,2);return"M-"+n+","+a+"H"+n+"L"+e+",0L"+n+",-"+a+"H-"+n+"L-"+e+",0Z"}},octagon:{n:16,f:function(t){var e=r.round(.924*t,2),n=r.round(.383*t,2);return"M-"+n+",-"+e+"H"+n+"L"+e+",-"+n+"V"+n+"L"+n+","+e+"H-"+n+"L-"+e+","+n+"V-"+n+"Z"}},star:{n:17,f:function(t){var e=1.4*t,n=r.round(.225*e,2),a=r.round(.951*e,2),o=r.round(.363*e,2),i=r.round(.588*e,2),l=r.round(-e,2),s=r.round(e*-.309,2),c=r.round(.118*e,2),u=r.round(.809*e,2),f=r.round(.382*e,2);return"M"+n+","+s+"H"+a+"L"+o+","+c+"L"+i+","+u+"L0,"+f+"L-"+i+","+u+"L-"+o+","+c+"L-"+a+","+s+"H-"+n+"L0,"+l+"Z"}},hexagram:{n:18,f:function(t){var e=r.round(.66*t,2),n=r.round(.38*t,2),a=r.round(.76*t,2);return"M-"+a+",0l-"+n+",-"+e+"h"+a+"l"+n+",-"+e+"l"+n+","+e+"h"+a+"l-"+n+","+e+"l"+n+","+e+"h-"+a+"l-"+n+","+e+"l-"+n+",-"+e+"h-"+a+"Z"}},"star-triangle-up":{n:19,f:function(t){var e=r.round(t*Math.sqrt(3)*.8,2),n=r.round(.8*t,2),a=r.round(1.6*t,2),o=r.round(4*t,2),i="A "+o+","+o+" 0 0 1 ";return"M-"+e+","+n+i+e+","+n+i+"0,-"+a+i+"-"+e+","+n+"Z"}},"star-triangle-down":{n:20,f:function(t){var e=r.round(t*Math.sqrt(3)*.8,2),n=r.round(.8*t,2),a=r.round(1.6*t,2),o=r.round(4*t,2),i="A "+o+","+o+" 0 0 1 ";return"M"+e+",-"+n+i+"-"+e+",-"+n+i+"0,"+a+i+e+",-"+n+"Z"}},"star-square":{n:21,f:function(t){var e=r.round(1.1*t,2),n=r.round(2*t,2),a="A "+n+","+n+" 0 0 1 ";return"M-"+e+",-"+e+a+"-"+e+","+e+a+e+","+e+a+e+",-"+e+a+"-"+e+",-"+e+"Z"}},"star-diamond":{n:22,f:function(t){var e=r.round(1.4*t,2),n=r.round(1.9*t,2),a="A "+n+","+n+" 0 0 1 ";return"M-"+e+",0"+a+"0,"+e+a+e+",0"+a+"0,-"+e+a+"-"+e+",0Z"}},"diamond-tall":{n:23,f:function(t){var e=r.round(.7*t,2),n=r.round(1.4*t,2);return"M0,"+n+"L"+e+",0L0,-"+n+"L-"+e+",0Z"}},"diamond-wide":{n:24,f:function(t){var e=r.round(1.4*t,2),n=r.round(.7*t,2);return"M0,"+n+"L"+e+",0L0,-"+n+"L-"+e+",0Z"}},hourglass:{n:25,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"H-"+e+"L"+e+",-"+e+"H-"+e+"Z"},noDot:!0},bowtie:{n:26,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"V-"+e+"L-"+e+","+e+"V-"+e+"Z"},noDot:!0},"circle-cross":{n:27,f:function(t){var e=r.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"circle-x":{n:28,f:function(t){var e=r.round(t,2),n=r.round(t/Math.sqrt(2),2);return"M"+n+","+n+"L-"+n+",-"+n+"M"+n+",-"+n+"L-"+n+","+n+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"square-cross":{n:29,f:function(t){var e=r.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"square-x":{n:30,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"diamond-cross":{n:31,f:function(t){var e=r.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM0,-"+e+"V"+e+"M-"+e+",0H"+e},needLine:!0,noDot:!0},"diamond-x":{n:32,f:function(t){var e=r.round(1.3*t,2),n=r.round(.65*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM-"+n+",-"+n+"L"+n+","+n+"M-"+n+","+n+"L"+n+",-"+n},needLine:!0,noDot:!0},"cross-thin":{n:33,f:function(t){var e=r.round(1.4*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e},needLine:!0,noDot:!0},"x-thin":{n:34,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0},asterisk:{n:35,f:function(t){var e=r.round(1.2*t,2),n=r.round(.85*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+n+","+n+"L-"+n+",-"+n+"M"+n+",-"+n+"L-"+n+","+n},needLine:!0,noDot:!0},hash:{n:36,f:function(t){var e=r.round(t/2,2),n=r.round(t,2);return"M"+e+","+n+"V-"+n+"m-"+n+",0V"+n+"M"+n+","+e+"H-"+n+"m0,-"+n+"H"+n},needLine:!0},"y-up":{n:37,f:function(t){var e=r.round(1.2*t,2),n=r.round(1.6*t,2),a=r.round(.8*t,2);return"M-"+e+","+a+"L0,0M"+e+","+a+"L0,0M0,-"+n+"L0,0"},needLine:!0,noDot:!0},"y-down":{n:38,f:function(t){var e=r.round(1.2*t,2),n=r.round(1.6*t,2),a=r.round(.8*t,2);return"M-"+e+",-"+a+"L0,0M"+e+",-"+a+"L0,0M0,"+n+"L0,0"},needLine:!0,noDot:!0},"y-left":{n:39,f:function(t){var e=r.round(1.2*t,2),n=r.round(1.6*t,2),a=r.round(.8*t,2);return"M"+a+","+e+"L0,0M"+a+",-"+e+"L0,0M-"+n+",0L0,0"},needLine:!0,noDot:!0},"y-right":{n:40,f:function(t){var e=r.round(1.2*t,2),n=r.round(1.6*t,2),a=r.round(.8*t,2);return"M-"+a+","+e+"L0,0M-"+a+",-"+e+"L0,0M"+n+",0L0,0"},needLine:!0,noDot:!0},"line-ew":{n:41,f:function(t){var e=r.round(1.4*t,2);return"M"+e+",0H-"+e},needLine:!0,noDot:!0},"line-ns":{n:42,f:function(t){var e=r.round(1.4*t,2);return"M0,"+e+"V-"+e},needLine:!0,noDot:!0},"line-ne":{n:43,f:function(t){var e=r.round(t,2);return"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0},"line-nw":{n:44,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e},needLine:!0,noDot:!0}}},{d3:10}],45:[function(t,e,n){"use strict";e.exports={visible:{valType:"boolean"},type:{valType:"enumerated",values:["percent","constant","sqrt","data"]},symmetric:{valType:"boolean"},array:{valType:"data_array"},arrayminus:{valType:"data_array"},value:{valType:"number",min:0,dflt:10},valueminus:{valType:"number",min:0,dflt:10},traceref:{valType:"integer",min:0,dflt:0},tracerefminus:{valType:"integer",min:0,dflt:0},copy_ystyle:{valType:"boolean"},copy_zstyle:{valType:"boolean"},color:{valType:"color"},thickness:{valType:"number",min:0,dflt:2},width:{valType:"number",min:0},_deprecated:{opacity:{valType:"number"}}}},{}],46:[function(t,e,n){"use strict";function r(t,e,n,r){var o=e["error_"+r]||{},s=o.visible&&-1!==["linear","log"].indexOf(n.type),c=[];if(s){for(var u=l(o),f=0;fl;l++)i[l]={x:n[l],y:a[l]};return i[0].trace=t,r.calc({calcdata:[i],_fullLayout:e}),i},r.plot=t("./plot"),r.style=t("./style"),r.hoverInfo=function(t,e,n){(e.error_y||{}).visible&&(n.yerr=t.yh-t.y,e.error_y.symmetric||(n.yerrneg=t.y-t.ys)),(e.error_x||{}).visible&&(n.xerr=t.xh-t.x,e.error_x.symmetric||(n.xerrneg=t.x-t.xs))}},{"./attributes":45,"./calc":46,"./defaults":48,"./plot":50,"./style":51}],50:[function(t,e,n){"use strict";function r(t,e,n){var r={x:e.c2p(t.x),y:n.c2p(t.y)};return void 0!==t.yh&&(r.yh=n.c2p(t.yh),r.ys=n.c2p(t.ys),o(r.ys)||(r.noYS=!0,r.ys=n.c2p(t.ys,!0))),void 0!==t.xh&&(r.xh=e.c2p(t.xh),r.xs=e.c2p(t.xs),o(r.xs)||(r.noXS=!0,r.xs=e.c2p(t.xs,!0))),r}var a=t("d3"),o=t("fast-isnumeric"),i=t("../../lib"),l=t("../../traces/scatter/subtypes");e.exports=function(t,e){var n=e.x(),s=e.y();t.each(function(t){var e=t[0].trace,c=e.error_x||{},u=e.error_y||{},f=l.hasMarkers(e)&&e.marker.maxdisplayed>0;if(u.visible||c.visible){var d=a.select(this).selectAll("g.errorbar").data(i.identity);d.enter().append("g").classed("errorbar",!0),d.each(function(t){var e=a.select(this),i=r(t,n,s);if(!f||t.vis){var l;if(u.visible&&o(i.x)&&o(i.yh)&&o(i.ys)){var d=u.width;l="M"+(i.x-d)+","+i.yh+"h"+2*d+"m-"+d+",0V"+i.ys,i.noYS||(l+="m-"+d+",0h"+2*d),e.append("path").classed("yerror",!0).attr("d",l)}if(c.visible&&o(i.y)&&o(i.xh)&&o(i.xs)){var h=(c.copy_ystyle?u:c).width;l="M"+i.xh+","+(i.y-h)+"v"+2*h+"m0,-"+h+"H"+i.xs,i.noXS||(l+="m0,-"+h+"v"+2*h),e.append("path").classed("xerror",!0).attr("d",l)}}})}})}},{"../../lib":99,"../../traces/scatter/subtypes":194,d3:10,"fast-isnumeric":12}],51:[function(t,e,n){"use strict";var r=t("d3"),a=t("../color");e.exports=function(t){t.each(function(t){var e=t[0].trace,n=e.error_y||{},o=e.error_x||{},i=r.select(this);i.selectAll("path.yerror").style("stroke-width",n.thickness+"px").call(a.stroke,n.color),o.copy_ystyle&&(o=n),i.selectAll("path.xerror").style("stroke-width",o.thickness+"px").call(a.stroke,o.color)})}},{"../color":20,d3:10}],52:[function(t,e,n){"use strict";var r=t("../../plots/cartesian/constants");e.exports={_isLinkedToArray:!0,source:{valType:"string"},layer:{valType:"enumerated",values:["below","above"],dflt:"above"},sizex:{valType:"number",dflt:0},sizey:{valType:"number",dflt:0},sizing:{valType:"enumerated",values:["fill","contain","stretch"],dflt:"contain"},opacity:{valType:"number",min:0,max:1,dflt:1},x:{valType:"number",dflt:0},y:{valType:"number",dflt:0},xanchor:{valType:"enumerated",values:["left","center","right"],dflt:"left"},yanchor:{valType:"enumerated",values:["top","middle","bottom"],dflt:"top"},xref:{valType:"enumerated",values:["paper",r.idRegex.x.toString()],dflt:"paper"},yref:{valType:"enumerated",values:["paper",r.idRegex.y.toString()],dflt:"paper"}}},{"../../plots/cartesian/constants":126}],53:[function(t,e,n){"use strict";function r(t,e,n){function r(n,r){return o.coerce(t,e,i,n,r)}e=e||{},r("source"),r("layer"),r("x"),r("y"),r("xanchor"),r("yanchor"),r("sizex"),r("sizey"),r("sizing"),r("opacity");for(var l=0;2>l;l++){var s={_fullLayout:n},c=["x","y"][l];a.coerceRef(t,e,s,c,"paper")}return e}var a=t("../../plots/cartesian/axes"),o=t("../../lib"),i=t("./attributes");e.exports=function(t,e){if(t.images&&Array.isArray(t.images))for(var n=t.images,a=e.images=[],o=0;o=2/3},n.isCenterAnchor=function(t){return"center"===t.xanchor||"auto"===t.xanchor&&t.x>1/3&&t.x<2/3},n.isBottomAnchor=function(t){return"bottom"===t.yanchor||"auto"===t.yanchor&&t.y<=1/3},n.isMiddleAnchor=function(t){return"middle"===t.yanchor||"auto"===t.yanchor&&t.y>1/3&&t.y<2/3}},{}],57:[function(t,e,n){"use strict";var r=t("../../plots/font_attributes"),a=t("../color/attributes"),o=t("../../lib/extend").extendFlat;e.exports={bgcolor:{valType:"color"},bordercolor:{valType:"color",dflt:a.defaultLine},borderwidth:{valType:"number",min:0,dflt:0},font:o({},r,{}),orientation:{valType:"enumerated",values:["v","h"],dflt:"v"},traceorder:{valType:"flaglist",flags:["reversed","grouped"],extras:["normal"]},tracegroupgap:{valType:"number",min:0,dflt:10},x:{valType:"number",min:-2,max:3,dflt:1.02},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"left"},y:{valType:"number",min:-2,max:3,dflt:1},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto"}}},{"../../lib/extend":96,"../../plots/font_attributes":139,"../color/attributes":19}],58:[function(t,e,n){"use strict";e.exports={scrollBarWidth:4,scrollBarHeight:20,scrollBarColor:"#808BA4",scrollBarMargin:4}},{}],59:[function(t,e,n){"use strict";var r=t("../../lib"),a=t("../../plots/plots"),o=t("./attributes"),i=t("./helpers");e.exports=function(t,e,n){function l(t,e){return r.coerce(d,h,o,t,e)}for(var s,c,u,f,d=t.legend||{},h=e.legend={},p=0,g="normal",v=0;v1);if(y!==!1){if(l("bgcolor",e.paper_bgcolor),l("bordercolor"),l("borderwidth"),r.coerceFont(l,"font",e.font),l("orientation"),"h"===h.orientation){var x=t.xaxis;x&&x.rangeslider&&x.rangeslider.visible?(s=0,u="left",c=1.1,f="bottom"):(s=0,u="left",c=-.1,f="top")}l("traceorder",g),i.isGrouped(e.legend)&&l("tracegroupgap"),l("x",s),l("xanchor",u),l("y",c),l("yanchor",f),r.noneOrAll(d,h,["x","y"])}}},{"../../lib":99,"../../plots/plots":153,"./attributes":57,"./helpers":62}],60:[function(t,e,n){"use strict";function r(t,e){function n(n){u.util.convertToTspans(n,function(){n.selectAll("tspan.line").attr({x:n.attr("x")}),t.call(o,e)})}var r=t.data()[0][0],a=e._fullLayout,i=r.trace,l=d.traceIs(i,"pie"),s=i.index,c=l?r.label:i.name,f=t.selectAll("text.legendtext").data([0]);f.enter().append("text").classed("legendtext",!0),f.attr({x:40,y:0,"data-unformatted":c}).style("text-anchor","start").classed("user-select-none",!0).call(p.font,a.legend.font).text(c),e._context.editable&&!l?f.call(u.util.makeEditable).call(n).on("edit",function(t){this.attr({"data-unformatted":t}),this.text(t).call(n),this.text()||(t=" "),u.restyle(e,"name",t,s)}):f.call(n)}function a(t,e){var n=e._fullLayout.hiddenlabels?e._fullLayout.hiddenlabels.slice():[],r=t.selectAll("rect").data([0]);r.enter().append("rect").classed("legendtoggle",!0).style("cursor","pointer").attr("pointer-events","all").call(g.fill,"rgba(0,0,0,0)"),r.on("click",function(){if(!e._dragged){var r,a,o=t.data()[0][0],i=e._fullData,l=o.trace,s=l.legendgroup,c=[];if(d.traceIs(l,"pie")){var f=o.label,h=n.indexOf(f);-1===h?n.push(f):n.splice(h,1),u.relayout(e,"hiddenlabels",n)}else{if(""===s)c=[l.index];else for(var p=0;ptspan"),h=d[0].length||1;n=s*h,r=u.node()&&p.bBox(u.node()).width;var g=s*(.3+(1-h)/2);u.attr("y",g),d.attr("y",g)}n=Math.max(n,16)+3,o.attr({x:0,y:-n/2,height:n}),a.height=n,a.width=r}function i(t,e,n){var r=t._fullLayout,a=r.legend,o=a.borderwidth,i=x.isGrouped(a);if(x.isVertical(a))i&&e.each(function(t,e){f.setTranslate(this,0,e*a.tracegroupgap)}),a.width=0,a.height=0,n.each(function(t){var e=t[0],n=e.height,r=e.width;f.setTranslate(this,o,5+o+a.height+n/2),a.height+=n,a.width=Math.max(a.width,r)}),a.width+=45+2*o,a.height+=10+2*o,i&&(a.height+=(a._lgroupsLength-1)*a.tracegroupgap),n.selectAll(".legendtoggle").attr("width",(t._context.editable?0:a.width)+40),a.width=Math.ceil(a.width),a.height=Math.ceil(a.height);else if(i){a.width=0,a.height=0;for(var l=[a.width],s=e.data(),u=0,d=s.length;d>u;u++){var h=s[u].map(function(t){return t[0].width}),p=40+Math.max.apply(null,h);a.width+=a.tracegroupgap+p,l.push(a.width)}e.each(function(t,e){f.setTranslate(this,l[e],0)}),e.each(function(){var t=c.select(this),e=t.selectAll("g.traces"),n=0;e.each(function(t){var e=t[0],r=e.height;f.setTranslate(this,0,5+o+n+r/2),n+=r}),a.height=Math.max(a.height,n)}),a.height+=10+2*o,a.width+=2*o,a.width=Math.ceil(a.width),a.height=Math.ceil(a.height),n.selectAll(".legendtoggle").attr("width",t._context.editable?0:a.width)}else{a.width=0,a.height=0;var g=0,v=0,m=0,y=0;n.each(function(t){m=Math.max(40+t[0].width,m)}),n.each(function(t){var e=t[0],n=m,i=a.tracegroupgap||5;o+y+i+n>r.width-(r.margin.r+r.margin.l)&&(y=0,g+=v,a.height=a.height+v,v=0),f.setTranslate(this,o+y,5+o+e.height/2+g),a.width+=i+n,a.height=Math.max(a.height,e.height),y+=i+n,v=Math.max(e.height,v)}),a.width+=2*o,a.height+=10+2*o,a.width=Math.ceil(a.width),a.height=Math.ceil(a.height),n.selectAll(".legendtoggle").attr("width",t._context.editable?0:a.width)}}function l(t){var e=t._fullLayout,n=e.legend,r="left";b.isRightAnchor(n)?r="right":b.isCenterAnchor(n)&&(r="center");var a="top";b.isBottomAnchor(n)?a="bottom":b.isMiddleAnchor(n)&&(a="middle"),d.autoMargin(t,"legend",{x:n.x,y:n.y,l:n.width*({right:1,center:.5}[r]||0),r:n.width*({left:1,center:.5}[r]||0),b:n.height*({top:1,middle:.5}[a]||0),t:n.height*({bottom:1,middle:.5}[a]||0)})}function s(t){var e=t._fullLayout,n=e.legend,r="left";b.isRightAnchor(n)?r="right":b.isCenterAnchor(n)&&(r="center"),d.autoMargin(t,"legend",{x:n.x,y:.5,l:n.width*({right:1,center:.5}[r]||0),r:n.width*({left:1,center:.5}[r]||0),b:0,t:0})}var c=t("d3"),u=t("../../plotly"),f=t("../../lib"),d=t("../../plots/plots"),h=t("../dragelement"),p=t("../drawing"),g=t("../color"),v=t("./constants"),m=t("./get_legend_data"),y=t("./style"),x=t("./helpers"),b=t("./anchor_utils");e.exports=function(t){function e(t,e){T.attr("data-scroll",e).call(f.setTranslate,0,e),L.call(p.setRect,I,t,v.scrollBarWidth,v.scrollBarHeight),M.select("rect").attr({y:x.borderwidth-e})}var n=t._fullLayout,o="legend"+n._uid;if(n._infolayer&&t.calcdata){var x=n.legend,_=n.showlegend&&m(t.calcdata,x),w=n.hiddenlabels||[];if(!n.showlegend||!_.length)return n._infolayer.selectAll(".legend").remove(),n._topdefs.select("#"+o).remove(),void d.autoMargin(t,"legend");var k=n._infolayer.selectAll("g.legend").data([0]);k.enter().append("g").attr({"class":"legend","pointer-events":"all"});var M=n._topdefs.selectAll("#"+o).data([0]);M.enter().append("clipPath").attr("id",o).append("rect");var A=k.selectAll("rect.bg").data([0]);A.enter().append("rect").attr({"class":"bg","shape-rendering":"crispEdges"}),A.call(g.stroke,x.bordercolor),A.call(g.fill,x.bgcolor),A.style("stroke-width",x.borderwidth+"px");var T=k.selectAll("g.scrollbox").data([0]);T.enter().append("g").attr("class","scrollbox");var L=k.selectAll("rect.scrollbar").data([0]);L.enter().append("rect").attr({"class":"scrollbar",rx:20,ry:2,width:0,height:0}).call(g.fill,"#808BA4");var z=T.selectAll("g.groups").data(_);z.enter().append("g").attr("class","groups"),z.exit().remove();var S=z.selectAll("g.traces").data(f.identity);S.enter().append("g").attr("class","traces"),S.exit().remove(),S.call(y).style("opacity",function(t){var e=t[0].trace;return d.traceIs(e,"pie")?-1!==w.indexOf(t[0].label)?.5:1:"legendonly"===e.visible?.5:1}).each(function(){c.select(this).call(r,t).call(a,t)});var C=0!==k.enter().size();C&&(i(t,z,S),l(t));var E=0,O=n.width,N=0,P=n.height;i(t,z,S),x.height>P?s(t):l(t);var j=n._size,D=j.l+j.w*x.x,R=j.t+j.h*(1-x.y);b.isRightAnchor(x)?D-=x.width:b.isCenterAnchor(x)&&(D-=x.width/2),b.isBottomAnchor(x)?R-=x.height:b.isMiddleAnchor(x)&&(R-=x.height/2);var I=x.width,q=j.w;I>q?(D=j.l,I=q):(D+I>O&&(D=O-I),E>D&&(D=E),I=Math.min(O-D,x.width));var F=x.height,B=j.h;F>B?(R=j.t,F=B):(R+F>P&&(R=P-F),N>R&&(R=N),F=Math.min(P-R,x.height)),f.setTranslate(k,D,R);var H,V,U=F-v.scrollBarHeight-2*v.scrollBarMargin,G=x.height-F;if(x.height<=F||t._context.staticPlot)A.attr({width:I-x.borderwidth,height:F-x.borderwidth,x:x.borderwidth/2,y:x.borderwidth/2}),f.setTranslate(T,0,0),M.select("rect").attr({width:I-2*x.borderwidth,height:F-2*x.borderwidth,x:x.borderwidth,y:x.borderwidth}),T.call(p.setClipUrl,o);else{H=v.scrollBarMargin,V=T.attr("data-scroll")||0,A.attr({width:I-2*x.borderwidth+v.scrollBarWidth+v.scrollBarMargin,height:F-x.borderwidth,x:x.borderwidth/2,y:x.borderwidth/2}),M.select("rect").attr({width:I-2*x.borderwidth+v.scrollBarWidth+v.scrollBarMargin,height:F-2*x.borderwidth,x:x.borderwidth,y:x.borderwidth-V}),T.call(p.setClipUrl,o),C&&e(H,V),k.on("wheel",null),k.on("wheel",function(){V=f.constrain(T.attr("data-scroll")-c.event.deltaY/U*G,-G,0),H=v.scrollBarMargin-V/G*U,e(H,V),c.event.preventDefault()}),L.on(".drag",null),T.on(".drag",null);var Z=c.behavior.drag().on("drag",function(){H=f.constrain(c.event.y-v.scrollBarHeight/2,v.scrollBarMargin,v.scrollBarMargin+U),V=-(H-v.scrollBarMargin)/U*G,e(H,V)});L.call(Z),T.call(Z)}if(t._context.editable){var Y,X,Q,$;k.classed("cursor-move",!0),h.init({element:k.node(),prepFn:function(){var t=f.getTranslate(k);Q=t.x,$=t.y},moveFn:function(t,e){var n=Q+t,r=$+e;f.setTranslate(k,n,r),Y=h.align(n,0,j.l,j.l+j.w,x.xanchor),X=h.align(r,0,j.t+j.h,j.t,x.yanchor)},doneFn:function(e){e&&void 0!==Y&&void 0!==X&&u.relayout(t,{"legend.x":Y,"legend.y":X})}})}}}},{"../../lib":99,"../../plotly":118,"../../plots/plots":153,"../color":20,"../dragelement":41,"../drawing":43,"./anchor_utils":56,"./constants":58,"./get_legend_data":61,"./helpers":62,"./style":64,d3:10}],61:[function(t,e,n){"use strict";var r=t("../../plots/plots"),a=t("./helpers");e.exports=function(t,e){function n(t,n){if(""!==t&&a.isGrouped(e))-1===s.indexOf(t)?(s.push(t),c=!0,l[t]=[[n]]):l[t].push([n]);else{var r="~~i"+f;s.push(r),l[r]=[[n]],f++}}var o,i,l={},s=[],c=!1,u={},f=0;for(o=0;oo;o++)m=l[s[o]],y[o]=a.isReversed(e)?m.reverse():m;else{for(y=[new Array(x)],o=0;x>o;o++)m=l[s[o]][0],y[0][a.isReversed(e)?x-o-1:o]=m;x=1}return e._lgroupsLength=x,y}},{"../../plots/plots":153,"./helpers":62}],62:[function(t,e,n){"use strict";var r=t("../../plots/plots");n.legendGetsTrace=function(t){return t.visible&&r.traceIs(t,"showLegend")},n.isGrouped=function(t){return-1!==(t.traceorder||"").indexOf("grouped")},n.isVertical=function(t){return"h"!==t.orientation},n.isReversed=function(t){return-1!==(t.traceorder||"").indexOf("reversed")}},{"../../plots/plots":153}],63:[function(t,e,n){"use strict";var r=e.exports={};r.layoutAttributes=t("./attributes"),r.supplyLayoutDefaults=t("./defaults"),r.draw=t("./draw"),r.style=t("./style")},{"./attributes":57,"./defaults":59,"./draw":60,"./style":64}],64:[function(t,e,n){"use strict";function r(t){var e=t[0].trace,n=e.visible&&e.fill&&"none"!==e.fill,r=h.hasLines(e),a=s.select(this).select(".legendfill").selectAll("path").data(n?[t]:[]);a.enter().append("path").classed("js-fill",!0),a.exit().remove(),a.attr("d","M5,0h30v6h-30z").call(f.fillGroupStyle);var o=s.select(this).select(".legendlines").selectAll("path").data(r?[t]:[]);o.enter().append("path").classed("js-line",!0).attr("d","M5,0h30"),o.exit().remove(),o.call(f.lineGroupStyle)}function a(t){function e(t,e,n){var r=c.nestedProperty(i,t).get(),a=Array.isArray(r)&&e?e(r):r;if(n){if(an[1])return n[1]}return a}function n(t){return t[0]}var r,a,o=t[0],i=o.trace,l=h.hasMarkers(i),u=h.hasText(i),d=h.hasLines(i);if(l||u||d){var p={},g={};l&&(p.mc=e("marker.color",n),p.mo=e("marker.opacity",c.mean,[.2,1]),p.ms=e("marker.size",c.mean,[2,16]),p.mlc=e("marker.line.color",n),p.mlw=e("marker.line.width",c.mean,[0,5]),g.marker={sizeref:1,sizemin:1,sizemode:"diameter"}),d&&(g.line={width:e("line.width",n,[0,10])}),u&&(p.tx="Aa",p.tp=e("textposition",n),p.ts=10,p.tc=e("textfont.color",n),p.tf=e("textfont.family",n)),r=[c.minExtend(o,p)],a=c.minExtend(i,g)}var v=s.select(this).select("g.legendpoints"),m=v.selectAll("path.scatterpts").data(l?r:[]);m.enter().append("path").classed("scatterpts",!0).attr("transform","translate(20,0)"),m.exit().remove(),m.call(f.pointStyle,a),l&&(r[0].mrc=3);var y=v.selectAll("g.pointtext").data(u?r:[]);y.enter().append("g").classed("pointtext",!0).append("text").attr("transform","translate(20,0)"),y.exit().remove(),y.selectAll("text").call(f.textPointStyle,a)}function o(t){var e=t[0].trace,n=e.marker||{},r=n.line||{},a=s.select(this).select("g.legendpoints").selectAll("path.legendbar").data(u.traceIs(e,"bar")?[t]:[]);a.enter().append("path").classed("legendbar",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),a.exit().remove(),a.each(function(t){var e=(t.mlw+1||r.width+1)-1,a=s.select(this);a.style("stroke-width",e+"px").call(d.fill,t.mc||n.color),e&&a.call(d.stroke,t.mlc||r.color)})}function i(t){var e=t[0].trace,n=s.select(this).select("g.legendpoints").selectAll("path.legendbox").data(u.traceIs(e,"box")&&e.visible?[t]:[]);n.enter().append("path").classed("legendbox",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),n.exit().remove(),n.each(function(t){var n=(t.lw+1||e.line.width+1)-1,r=s.select(this);r.style("stroke-width",n+"px").call(d.fill,t.fc||e.fillcolor),n&&r.call(d.stroke,t.lc||e.line.color)})}function l(t){var e=t[0].trace,n=s.select(this).select("g.legendpoints").selectAll("path.legendpie").data(u.traceIs(e,"pie")&&e.visible?[t]:[]);n.enter().append("path").classed("legendpie",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),n.exit().remove(),n.size()&&n.call(p,t[0],e)}var s=t("d3"),c=t("../../lib"),u=t("../../plots/plots"),f=t("../drawing"),d=t("../color"),h=t("../../traces/scatter/subtypes"),p=t("../../traces/pie/style_one");e.exports=function(t){t.each(function(t){var e=s.select(this),n=e.selectAll("g.legendfill").data([t]);n.enter().append("g").classed("legendfill",!0);var r=e.selectAll("g.legendlines").data([t]);r.enter().append("g").classed("legendlines",!0);var a=e.selectAll("g.legendsymbols").data([t]);a.enter().append("g").classed("legendsymbols",!0),a.style("opacity",t[0].trace.opacity),a.selectAll("g.legendpoints").data([t]).enter().append("g").classed("legendpoints",!0)}).each(o).each(i).each(l).each(r).each(a)}},{"../../lib":99,"../../plots/plots":153,"../../traces/pie/style_one":173,"../../traces/scatter/subtypes":194,"../color":20,"../drawing":43,d3:10}],65:[function(t,e,n){"use strict";function r(t,e){var n=e.currentTarget,r=n.getAttribute("data-attr"),a=n.getAttribute("data-val")||!0,o=t._fullLayout,i={};if("zoom"===r){for(var l,s,u="in"===a?.5:2,f=(1+u)/2,d=(1-u)/2,h=c.Axes.list(t,null,!0),p=0;py;y++){var x=l[y];d=m[x]={};for(var b=0;b1)return r(["resetViews","toggleHover"]),i(v,n);u&&(r(["zoom3d","pan3d","orbitRotation","tableRotation"]),r(["resetCameraDefault3d","resetCameraLastSave3d"]),r(["hoverClosest3d"])),d&&(r(["zoomInGeo","zoomOutGeo","resetGeo"]),r(["hoverClosestGeo"]));var m=a(l),y=[];return((c||p)&&!m||g)&&(y=["zoom2d","pan2d"]),(c||g)&&o(s)&&(y.push("select2d"),y.push("lasso2d")),y.length&&r(y),!c&&!p||m||g||r(["zoomIn2d","zoomOut2d","autoScale2d","resetScale2d"]),c&&h?r(["toggleHover"]):p?r(["hoverClosestGl2d"]):c?r(["hoverClosestCartesian","hoverCompareCartesian"]):h&&r(["hoverClosestPie"]),i(v,n)}function a(t){for(var e=s.Axes.list({_fullLayout:t},null,!0),n=!0,r=0;r0);if(p){var g=a(e,n,s);u("x",g[0]),u("y",g[1]),o.noneOrAll(t,e,["x","y"]),u("xanchor"),u("yanchor"),o.coerceFont(u,"font",n.font);var v=u("bgcolor");u("activecolor",i.contrast(v,c.lightAmount,c.darkAmount)),u("bordercolor"),u("borderwidth")}}},{"../../lib":99,"../color":20,"./attributes":68,"./button_attributes":69,"./constants":70}],72:[function(t,e,n){"use strict";function r(t){for(var e=m.list(t,"x",!0),n=[],r=0;re){var n=e;e=t,t=n}l.setAttributes(w,{"data-min":t,"data-max":e}),l.setAttributes(N,{x:t,width:e-t}),l.setAttributes(A,{width:t}),l.setAttributes(T,{x:e,width:p-e}),l.setAttributes(L,{transform:"translate("+(t-v-1)+")"}),l.setAttributes(C,{transform:"translate("+e+")"})}var f=t._fullLayout,d=f._infolayer.selectAll("g.range-slider"),h=f.xaxis.rangeslider,p=f._size.w,g=(f.height-f.margin.b-f.margin.t)*h.thickness,v=2,m=Math.floor(h.borderwidth/2),y=f.margin.l,x=f.height-g-f.margin.b,b=0,_=p,w=document.createElementNS(i,"g");l.setAttributes(w,{"class":"range-slider","data-min":b,"data-max":_,"pointer-events":"all",transform:"translate("+y+","+x+")"});var k=document.createElementNS(i,"rect"),M=h.borderwidth%2===0?h.borderwidth:h.borderwidth-1;l.setAttributes(k,{fill:h.bgcolor,stroke:h.bordercolor,"stroke-width":h.borderwidth,height:g+M,width:p+M,transform:"translate(-"+m+", -"+m+")","shape-rendering":"crispEdges"});var A=document.createElementNS(i,"rect");l.setAttributes(A,{x:0,width:b,height:g,fill:"rgba(0,0,0,0.4)"});var T=document.createElementNS(i,"rect");l.setAttributes(T,{x:_,width:p-_,height:g,fill:"rgba(0,0,0,0.4)"});var L=document.createElementNS(i,"g"),z=document.createElementNS(i,"rect"),S=document.createElementNS(i,"rect");l.setAttributes(L,{transform:"translate("+(b-v-1)+")"}),l.setAttributes(z,{width:10,height:g,x:-6,fill:"transparent",cursor:"col-resize"}),l.setAttributes(S,{width:v,height:g/2,y:g/4,rx:1,fill:"white",stroke:"#666","shape-rendering":"crispEdges"}),l.appendChildren(L,[S,z]);var C=document.createElementNS(i,"g"),E=document.createElementNS(i,"rect"),O=document.createElementNS(i,"rect");l.setAttributes(C,{transform:"translate("+_+")"}),l.setAttributes(E,{width:10,height:g,x:-2,fill:"transparent",cursor:"col-resize"}),l.setAttributes(O,{width:v,height:g/2,y:g/4,rx:1,fill:"white",stroke:"#666","shape-rendering":"crispEdges"}),l.appendChildren(C,[O,E]);var N=document.createElementNS(i,"rect");l.setAttributes(N,{x:b,width:_-b,height:g,cursor:"ew-resize",fill:"transparent"}),w.addEventListener("mousedown",function(t){function n(t){var n,r,f=+t.clientX-o;switch(a){case N:w.style.cursor="ew-resize",n=+l+f,r=+s+f,u(n,r),c(e(n),e(r));break;case z:w.style.cursor="col-resize",n=+l+f,r=+s,u(n,r),c(e(n),e(r));break;case E:w.style.cursor="col-resize",n=+l,r=+s+f,u(n,r),c(e(n),e(r));break;default:w.style.cursor="ew-resize",n=i,r=i+f,u(n,r),c(e(n),e(r))}}function r(){window.removeEventListener("mousemove",n),window.removeEventListener("mouseup",r),w.style.cursor="auto"}var a=t.target,o=t.clientX,i=o-w.getBoundingClientRect().left,l=w.getAttribute("data-min"),s=w.getAttribute("data-max");window.addEventListener("mousemove",n),window.addEventListener("mouseup",r)}),h.range||(h.range=a.getAutoRange(f.xaxis));var P=s(t,p,g);l.appendChildren(w,[k,P,A,T,N,L,C]),n(f.xaxis.range[0],f.xaxis.range[1]),d.data([0]).enter().append(function(){return h.setRange=n,w})}},{"../../constants/xmlns_namespaces":89,"../../lib":99,"../../plotly":118,"../../plots/cartesian/axes":121,"./helpers":78,"./range_plot":80}],77:[function(t,e,n){"use strict";var r=t("../../lib"),a=t("./attributes");e.exports=function(t,e,n,o){function i(t,e){return r.coerce(l,s,a,t,e)}if(t[n].rangeslider){var l=r.isPlainObject(t[n].rangeslider)?t[n].rangeslider:{},s=e[n].rangeslider={};if(i("bgcolor"),i("bordercolor"),i("borderwidth"),i("thickness"),i("visible"),i("range"),s.range&&!e[n].autorange){var c=s.range,u=e[n].range;c[0]=Math.min(c[0],u[0]),c[1]=Math.max(c[1],u[1])}else e[n]._needsExpand=!0;s.visible&&o.forEach(function(t){var n=e[t]||{};n.fixedrange=!0,e[t]=n})}}},{"../../lib":99,"./attributes":75}],78:[function(t,e,n){"use strict";n.setAttributes=function(t,e){for(var n in e)t.setAttribute(n,e[n])},n.appendChildren=function(t,e){for(var n=0;ns;s++){var c=l[s],u={_fullLayout:e},f=A.coerceRef(t,r,u,c);if("path"!==i){var d=.25,h=.75;if("paper"!==f){var p=A.getFromId(u,f),g=o(p);d=g(p.range[0]+d*(p.range[1]-p.range[0])),h=g(p.range[0]+h*(p.range[1]-p.range[0]))}n(c+"0",d),n(c+"1",h)}}return"path"===i?n("path"):M.noneOrAll(t,r,["x0","x1","y0","y1"]),r}function a(t){return"category"===t.type?t.c2l:t.d2l}function o(t){return"category"===t.type?t.l2c:t.l2d}function i(t,e){t.layout.shapes=e,C.supplyLayoutDefaults(t.layout,t._fullLayout),C.drawAll(t)}function l(t){delete t.layout.shapes,t._fullLayout.shapes=[],C.drawAll(t)}function s(t,e,n){for(var r=0;re;a--)h(t,a).selectAll('[data-index="'+(a-1)+'"]').attr("data-index",a),C.draw(t,a)}function f(t,e,n,i){function l(n){var r={"data-index":e,"fill-rule":"evenodd",d:x(t,C)},a=C.line.width?C.line.color:"rgba(0,0,0,0)",o=n.append("path").attr(r).style("opacity",C.opacity).call(T.stroke,a).call(T.fill,C.fillcolor).call(L.dashLine,C.line.dash,C.line.width);E&&o.call(L.setClipUrl,"clip"+t._fullLayout._uid+E),t._context.editable&&d(t,o,C,e)}var s,c;h(t,e).selectAll('[data-index="'+e+'"]').remove();var u=t.layout.shapes[e];if(u){var f={xref:u.xref,yref:u.yref},g={};"string"==typeof n&&n?g[n]=i:M.isPlainObject(n)&&(g=n);var v=Object.keys(g);for(s=0;ss;s++){var b=y[s];if(void 0===g[b]&&void 0!==u[b]){var _,w=b.charAt(0),k=A.getFromId(t,A.coerceRef(f,{},t,w)),z=A.getFromId(t,A.coerceRef(u,{},t,w)),S=u[b];void 0!==g[w+"ref"]&&(k?(_=a(k)(S),S=(_-k.range[0])/(k.range[1]-k.range[0])):S=(S-z.domain[0])/(z.domain[1]-z.domain[0]),z?(_=z.range[0]+S*(z.range[1]-z.range[0]),S=o(z)(_)):S=k.domain[0]+S*(k.domain[1]-k.domain[0])),u[b]=S}}var C=r(u,t._fullLayout);t._fullLayout.shapes[e]=C;var E;if("below"!==C.layer)E=(C.xref+C.yref).replace(/paper/g,""),l(t._fullLayout._shapeUpperLayer);else if("paper"===C.xref&&"paper"===C.yref)E="",l(t._fullLayout._shapeLowerLayer);else{var O,N=t._fullLayout._plots||{},P=Object.keys(N);for(s=0,c=P.length;c>s;s++)O=N[P[s]],E=P[s],p(t,C,O)&&l(O.shapelayer)}}}function d(t,e,n,r){function a(t){var n=W.right-W.left,r=W.bottom-W.top,a=t.clientX-W.left,o=t.clientY-W.top,i=n>X&&r>Q&&!t.shiftKey?z.getCursor(a/n,1-o/r):"move";S(e,i),Y=i.split("-")[0]}function o(e){B=A.getFromId(t,n.xref),H=A.getFromId(t,n.yref),V=m(t,B),U=m(t,H,!0),G=y(t,B),Z=y(t,H,!0);var o="shapes["+r+"]";"path"===n.type?(q=n.path,F=o+".path"):(u=V(n.x0),f=U(n.y0),d=V(n.x1),h=U(n.y1),p=o+".x0",g=o+".y0",_=o+".x1",w=o+".y1"),d>u?(L=u,N=o+".x0",R="x0",C=d,P=o+".x1",I="x1"):(L=d,N=o+".x1",R="x1",C=u,P=o+".x0",I="x0"),h>f?(M=f,E=o+".y0",j="y0",T=h,O=o+".y1",D="y1"):(M=h,E=o+".y1",j="y1",T=f,O=o+".y0",D="y0"),c={},a(e),$.moveFn="move"===Y?l:s}function i(n){S(e),n&&k.relayout(t,c)}function l(r,a){if("path"===n.type){var o=function(t){return G(V(t)+r)};B&&"date"===B.type&&(o=v(o));var i=function(t){return Z(U(t)+a)};H&&"date"===H.type&&(i=v(i)),n.path=b(q,o,i),c[F]=n.path}else c[p]=n.x0=G(u+r),c[g]=n.y0=Z(f+a),c[_]=n.x1=G(d+r),c[w]=n.y1=Z(h+a);e.attr("d",x(t,n))}function s(r,a){if("path"===n.type){var o=function(t){return G(V(t)+r)};B&&"date"===B.type&&(o=v(o));var i=function(t){return Z(U(t)+a)};H&&"date"===H.type&&(i=v(i)),n.path=b(q,o,i),c[F]=n.path}else{var l=~Y.indexOf("n")?M+a:M,s=~Y.indexOf("s")?T+a:T,u=~Y.indexOf("w")?L+r:L,f=~Y.indexOf("e")?C+r:C;s-l>Q&&(c[E]=n[j]=Z(l),c[O]=n[D]=Z(s)),f-u>X&&(c[N]=n[R]=G(u),c[P]=n[I]=G(f))}e.attr("d",x(t,n))}var c,u,f,d,h,p,g,_,w,M,T,L,C,E,O,N,P,j,D,R,I,q,F,B,H,V,U,G,Z,Y,X=10,Q=10,$={setCursor:a,element:e.node(),prepFn:o,doneFn:i},W=$.element.getBoundingClientRect();z.init($)}function h(t,e){var n=t._fullLayout.shapes[e],r=t._fullLayout._shapeUpperLayer;return n?"below"===n.layer&&(r="paper"===n.xref&&"paper"===n.yref?t._fullLayout._shapeLowerLayer:t._fullLayout._shapeSubplotLayer):M.log("getShapeLayer: undefined shape: index",e),r}function p(t,e,n){var r=k.Axes.getFromId(t,n.id,"x")._id,a=k.Axes.getFromId(t,n.id,"y")._id,o="below"===e.layer,i=r===e.xref||a===e.yref,l=!!n.shapelayer;return o&&i&&l}function g(t){return function(e){return e.replace&&(e=e.replace("_"," ")),t(e)}}function v(t){return function(e){return t(e).replace(" ","_")}}function m(t,e,n){var r,o=t._fullLayout._size;if(e){var i=a(e);r=function(t){return e._offset+e.l2p(i(t,!0))},"date"===e.type&&(r=g(r))}else r=n?function(t){return o.t+o.h*(1-t)}:function(t){return o.l+o.w*t};return r}function y(t,e,n){var r,a=t._fullLayout._size;if(e){var i=o(e);r=function(t){return i(e.p2l(t-e._offset))}}else r=n?function(t){return 1-(t-a.t)/a.h}:function(t){return(t-a.l)/a.w};return r}function x(t,e){var n,r,o,i,l=e.type,s=A.getFromId(t,e.xref),c=A.getFromId(t,e.yref),u=t._fullLayout._size;if(s?(n=a(s),r=function(t){return s._offset+s.l2p(n(t,!0))}):r=function(t){return u.l+u.w*t},c?(o=a(c),i=function(t){return c._offset+c.l2p(o(t,!0))}):i=function(t){return u.t+u.h*(1-t)},"path"===l)return s&&"date"===s.type&&(r=g(r)),c&&"date"===c.type&&(i=g(i)),C.convertPath(e.path,r,i);var f=r(e.x0),d=r(e.x1),h=i(e.y0),p=i(e.y1);if("line"===l)return"M"+f+","+h+"L"+d+","+p;if("rect"===l)return"M"+f+","+h+"H"+d+"V"+p+"H"+f+"Z";var v=(f+d)/2,m=(h+p)/2,y=Math.abs(v-f),x=Math.abs(m-h),b="A"+y+","+x,_=v+y+","+m,w=v+","+(m-x);return"M"+_+b+" 0 1,1 "+w+b+" 0 0,1 "+_+"Z"}function b(t,e,n){return t.replace(E,function(t){var r=0,a=t.charAt(0),o=N[a],i=P[a],l=j[a],s=t.substr(1).replace(O,function(t){return r>=l?t:(o[r]?t=e(t):i[r]&&(t=n(t)),r++,t)});return a+s})}function _(t,e,n,r,a){var o="category"===t.type?Number:t.d2c;if(void 0!==e)return[o(e),o(n)];if(r){var i,l,s,c,u,f=1/0,d=-(1/0),h=r.match(E);for("date"===t.type&&(o=g(o)),i=0;iu&&(f=u),u>d&&(d=u)));return d>=f?[f,d]:void 0}}var w=t("fast-isnumeric"),k=t("../../plotly"),M=t("../../lib"),A=t("../../plots/cartesian/axes"),T=t("../color"),L=t("../drawing"),z=t("../dragelement"),S=t("../../lib/setcursor"),C=e.exports={};C.layoutAttributes=t("./attributes"),C.supplyLayoutDefaults=function(t,e){for(var n=t.shapes||[],a=e.shapes=[],o=0;ol&&(t="X"),t});return r>l&&(s=s.replace(/[\s,]*X.*/,""),M.log("Ignoring extra params in segment "+t)),a+s})},C.calcAutorange=function(t){var e,n,r,a,o,i=t._fullLayout,l=i.shapes;if(l.length&&t._fullData.length)for(e=0;ed?n=d:(u.left-=x.offsetLeft,u.right-=x.offsetLeft,u.top-=x.offsetTop,u.bottom-=x.offsetTop,x.selection.each(function(){var t=s.bBox(this);l.bBoxIntersect(u,t,c)&&(n=Math.max(n,i*(t[x.side]-u[o])+c))}),n=Math.min(d,n)),n>0||0>d){var h={left:[-n,0],right:[n,0],top:[0,-n],bottom:[0,n]}[x.side];e.attr("transform","translate("+h+")")}}}function p(){L=0,z=!0,S=E,k._infolayer.select("."+e).attr({"data-unformatted":S}).text(S).on("mouseover.opacity",function(){r.select(this).transition().duration(100).style("opacity",1)}).on("mouseout.opacity",function(){r.select(this).transition().duration(1e3).style("opacity",0)})}var g=n.propContainer,v=n.propName,m=n.traceIndex,y=n.dfltName,x=n.avoid||{},b=n.attributes,_=n.transform,w=n.containerGroup,k=t._fullLayout,M=g.titlefont.family,A=g.titlefont.size,T=g.titlefont.color,L=1,z=!1,S=g.title.trim();""===S&&(L=0),S.match(/Click to enter .+ title/)&&(L=.2,z=!0),w||(w=k._infolayer.selectAll(".g-"+e).data([0]),w.enter().append("g").classed("g-"+e,!0));var C=w.selectAll("text").data([0]);C.enter().append("text"),C.text(S).attr("class",e),C.attr({"data-unformatted":S}).call(f);var E="Click to enter "+y+" title";t._context.editable?(S||p(),C.call(u.makeEditable).on("edit",function(e){void 0!==m?o.restyle(t,v,e,m):o.relayout(t,v,e)}).on("cancel",function(){this.text(this.attr("data-unformatted")).call(f)}).on("input",function(t){this.text(t||" ").attr(b).selectAll("tspan.line").attr(b)})):S&&!S.match(/Click to enter .+ title/)||C.remove(),C.classed("js-placeholder",z)}},{"../../lib":99,"../../lib/svg_text_utils":110,"../../plotly":118,"../../plots/plots":153,"../color":20,"../drawing":43,d3:10,"fast-isnumeric":12}],84:[function(t,e,n){"use strict";var r=t("../../plots/font_attributes"),a=t("../color/attributes"),o=t("../../lib/extend").extendFlat,i={_isLinkedToArray:!0,method:{valType:"enumerated",values:["restyle","relayout"],dflt:"restyle"},args:{valType:"info_array",freeLength:!0,items:[{valType:"any"},{valType:"any"},{valType:"any"}]},label:{valType:"string",dflt:""}};e.exports={_isLinkedToArray:!0,visible:{valType:"boolean"},active:{valType:"integer",min:-1,dflt:0},buttons:i,x:{valType:"number",min:-2,max:3,dflt:-.05},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"right"},y:{valType:"number",min:-2,max:3,dflt:1},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"bottom"},font:o({},r,{}),bgcolor:{valType:"color"},bordercolor:{valType:"color",dflt:a.borderLine},borderwidth:{valType:"number",min:0,dflt:1}}},{"../../lib/extend":96,"../../plots/font_attributes":139,"../color/attributes":19}],85:[function(t,e,n){"use strict";e.exports={name:"updatemenus",itemName:"updatemenu",containerClassName:"updatemenu-container",headerGroupClassName:"updatemenu-header-group",headerClassName:"updatemenu-header",headerArrowClassName:"updatemenu-header-arrow",buttonGroupClassName:"updatemenu-button-group",buttonClassName:"updatemenu-button",itemRectClassName:"updatemenu-item-rect",itemTextClassName:"updatemenu-item-text",menuIndexAttrName:"updatemenu-active-index",autoMarginIdRoot:"updatemenu-",blankHeaderOpts:{label:" "},minWidth:30,minHeight:30,textPadX:40,fontSizeToHeight:1.3,rx:2,ry:2,textOffsetX:12,textOffsetY:3,arrowOffsetX:4,gapButtonHeader:5,gapButton:2,activeColor:"#F4FAFF",hoverColor:"#F4FAFF"}},{}],86:[function(t,e,n){"use strict";function r(t,e,n){function r(n,r){return o.coerce(t,e,i,n,r)}var l=a(t,e),s=r("visible",l.length>0);s&&(r("active"),r("x"),r("y"),o.noneOrAll(t,e,["x","y"]),r("xanchor"),r("yanchor"),o.coerceFont(r,"font",n.font),r("bgcolor",n.paper_bgcolor),r("bordercolor"),r("borderwidth"))}function a(t,e){function n(t,e){return o.coerce(r,a,c,t,e)}for(var r,a,i=t.buttons||[],l=e.buttons=[],s=0;s0?[0]:[]);if(s.enter().append("g").classed(T.containerClassName,!0).style("cursor","pointer"),s.exit().remove(),s.exit().size()&&m(t),0!==n.length){var c=s.selectAll("g."+T.headerGroupClassName).data(n,a);c.enter().append("g").classed(T.headerGroupClassName,!0);var u=s.selectAll("g."+T.buttonGroupClassName).data([0]);u.enter().append("g").classed(T.buttonGroupClassName,!0).style("pointer-events","all"),c.enter().size()&&u.call(v).attr(T.menuIndexAttrName,"-1"),c.exit().each(function(e){y.select(this).remove(),u.call(v).attr(T.menuIndexAttrName,"-1"),b.autoMargin(t,T.autoMarginIdRoot+e._index)});for(var f=0;fa.max?e.set(n):e.set(+t)}},integer:{coerceFunction:function(t,e,n,a){t%1||!r(t)||void 0!==a.min&&ta.max?e.set(n):e.set(+t)}},string:{coerceFunction:function(t,e,n,r){if("string"!=typeof t){var a="number"==typeof t;r.strict!==!0&&a?e.set(String(t)):e.set(n)}else r.noBlank&&!t?e.set(n):e.set(t)}},color:{coerceFunction:function(t,e,n){a(t).isValid()?e.set(t):e.set(n)}},colorscale:{coerceFunction:function(t,e,n){e.set(i(t,n))}},angle:{coerceFunction:function(t,e,n){"auto"===t?e.set("auto"):r(t)?(Math.abs(t)>180&&(t-=360*Math.round(t/360)),e.set(+t)):e.set(n)}},subplotid:{coerceFunction:function(t,e,n){var r=n.length;return"string"==typeof t&&t.substr(0,r)===n&&l.test(t.substr(r))?void e.set(t):void e.set(n)},validateFunction:function(t,e){var n=e.dflt,r=n.length;return t===n?!0:"string"!=typeof t?!1:!(t.substr(0,r)!==n||!l.test(t.substr(r)))}},flaglist:{coerceFunction:function(t,e,n,r){if("string"!=typeof t)return void e.set(n);if(-1!==(r.extras||[]).indexOf(t))return void e.set(t);for(var a=t.split("+"),o=0;o2)return!1;var s=i[0].split("-");if(s.length>3||3!==s.length&&i[1])return!1;if(4===s[0].length)n=Number(s[0]);else{if(2!==s[0].length)return!1;var c=(new Date).getFullYear();n=((Number(s[0])-c+70)%100+200)%100+c-70}return l(n)?1===s.length?new Date(n,0,1).getTime():(r=Number(s[1])-1,s[1].length>2||!(r>=0&&11>=r)?!1:2===s.length?new Date(n,r,1).getTime():(a=Number(s[2]),s[2].length>2||!(a>=1&&31>=a)?!1:(a=new Date(n,r,a).getTime(),i[1]?(s=i[1].split(":"),s.length>3?!1:(o=Number(s[0]),s[0].length>2||!(o>=0&&23>=o)?!1:(a+=36e5*o,1===s.length?a:(r=Number(s[1]),s[1].length>2||!(r>=0&&59>=r)?!1:(a+=6e4*r,2===s.length?a:(t=Number(s[2]),t>=0&&60>t?a+1e3*t:!1)))))):a))):!1},n.isDateTime=function(t){return n.dateTime2ms(t)!==!1},n.ms2DateTime=function(t,e){if("undefined"==typeof i)return void s.error("d3 is not defined.");e||(e=0);var n=new Date(t),a=i.time.format("%Y-%m-%d")(n);return 7776e6>e?(a+=" "+r(n.getHours(),2),432e6>e&&(a+=":"+r(n.getMinutes(),2),108e5>e&&(a+=":"+r(n.getSeconds(),2),3e5>e&&(a+="."+r(n.getMilliseconds(),3)))),a.replace(/([:\s]00)*\.?[0]*$/,"")):a};var c={H:["%H:%M:%S~%L","%H:%M:%S","%H:%M"],I:["%I:%M:%S~%L%p","%I:%M:%S%p","%I:%M%p"],D:["%H","%I%p","%Hh"]},u={Y:["%Y~%m~%d","%Y%m%d","%y%m%d","%m~%d~%Y","%d~%m~%Y"],Yb:["%b~%d~%Y","%d~%b~%Y","%Y~%d~%b","%Y~%b~%d"],y:["%m~%d~%y","%d~%m~%y","%y~%m~%d"],yb:["%b~%d~%y","%d~%b~%y","%y~%d~%b","%y~%b~%d"]},f=i.time.format.utc,d={Y:{H:["%Y~%m~%dT%H:%M:%S","%Y~%m~%dT%H:%M:%S~%L"].map(f),I:[],D:["%Y%m%d%H%M%S","%Y~%m","%m~%Y"].map(f)},Yb:{H:[],I:[],D:["%Y~%b","%b~%Y"].map(f)},y:{H:[],I:[],D:[]},yb:{H:[],I:[],D:[]}};["Y","Yb","y","yb"].forEach(function(t){u[t].forEach(function(e){d[t].D.push(f(e)),["H","I","D"].forEach(function(n){c[n].forEach(function(r){var a=d[t][n];a.push(f(e+"~"+r)),a.push(f(r+"~"+e))})})})});var h=/[a-z]*/g,p=function(t){return t.substr(0,3)},g=/(mon|tue|wed|thu|fri|sat|sun|the|of|st|nd|rd|th)/g,v=/[\s,\/\-\.\(\)]+/g,m=/~?([ap])~?m(~|$)/,y=function(t,e){return e+"m "},x=/\d\d\d\d/,b=/(^|~)[a-z]{3}/,_=/[ap]m/,w=/:/,k=/q([1-4])/,M=["31~mar","30~jun","30~sep","31~dec"],A=function(t,e){return M[e-1]},T=/ ?([+\-]\d\d:?\d\d|Z)$/;n.parseDate=function(t){if(t.getTime)return t;if("string"!=typeof t)return!1;t=t.toLowerCase().replace(h,p).replace(g,"").replace(v,"~").replace(m,y).replace(k,A).trim().replace(T,"");var e,n,r=null,i=a(t),l=o(t);e=d[i][l],n=e.length;for(var s=0;n>s&&!(r=e[s].parse(t));s++);if(!(r instanceof Date))return!1;var c=r.getTimezoneOffset();return r.setTime(r.getTime()+60*c*1e3),r}},{"../lib":99,d3:10,"fast-isnumeric":12}],95:[function(t,e,n){"use strict";var r=t("events").EventEmitter,a={init:function(t){if(t._ev instanceof r)return t;var e=new r;return t._ev=e,t.on=e.on.bind(e),t.once=e.once.bind(e),t.removeListener=e.removeListener.bind(e),t.removeAllListeners=e.removeAllListeners.bind(e),t.emit=function(n,r){"undefined"!=typeof jQuery&&jQuery(t).trigger(n,r),e.emit(n,r)},t},triggerHandler:function(t,e,n){var r,a;"undefined"!=typeof jQuery&&(r=jQuery(t).triggerHandler(e,n));var o=t._ev;if(!o)return r;var i=o._events[e];if(!i)return r;"function"==typeof i&&(i=[i]);for(var l=i.pop(),s=0;sm;m++){s=t[m];for(c in s)u=g[c],f=s[c],l&&i(f)?g[c]=f:e&&f&&(o(f)||(d=i(f)))?(d?(d=!1,h=u&&i(u)?u:[]):h=u&&o(u)?u:{},g[c]=a([h,f],e,n,l)):("undefined"!=typeof f||n)&&(g[c]=f)}return g}var o=t("./is_plain_object.js"),i=Array.isArray;n.extendFlat=function(){return a(arguments,!1,!1,!1)},n.extendDeep=function(){return a(arguments,!0,!1,!1)},n.extendDeepAll=function(){return a(arguments,!0,!0,!1)},n.extendDeepNoArrays=function(){return a(arguments,!0,!1,!0)}},{"./is_plain_object.js":100}],97:[function(t,e,n){"use strict";e.exports=function(t){for(var e=[],n=0;nn?Math.max(n,Math.min(e,t)):Math.max(e,Math.min(n,t))},a.bBoxIntersect=function(t,e,n){return n=n||0,t.left<=e.right+n&&e.left<=t.right+n&&t.top<=e.bottom+n&&e.top<=t.bottom+n},a.identity=function(t){return t},a.randstr=function d(t,e,n){if(n||(n=16),void 0===e&&(e=24),0>=e)return"0";var r,a,o,i=Math.log(Math.pow(2,e))/Math.log(n),l="";for(r=2;i===1/0;r*=2)i=Math.log(Math.pow(2,e/r))/Math.log(n)*r;var s=i-Math.floor(i);for(r=0;r-1||c!==1/0&&c>=Math.pow(2,e)?d(t,e,n):l},a.OptionControl=function(t,e){t||(t={}),e||(e="opt");var n={};return n.optionList=[],n._newoption=function(r){r[e]=t,n[r.name]=r,n.optionList.push(r)},n["_"+e]=t,n},a.smooth=function(t,e){if(e=Math.round(e)||0,2>e)return t;var n,r,a,o,i=t.length,l=2*i,s=2*e-1,c=new Array(s),u=new Array(i);for(n=0;s>n;n++)c[n]=(1-Math.cos(Math.PI*(n+1)/e))/(2*e);for(n=0;i>n;n++){for(o=0,r=0;s>r;r++)a=n+r+1-e,-i>a?a-=l*Math.round(a/l):a>=l&&(a-=l*Math.floor(a/l)),0>a?a=-1-a:a>=i&&(a=l-1-a),o+=t[a]*c[r];u[n]=o}return u},a.syncOrAsync=function(t,e,n){function r(){return a.syncOrAsync(t,e,n)}for(var o,i;t.length;)if(i=t.splice(0,1)[0],o=i(e),o&&o.then)return o.then(r).then(void 0,a.promiseError);return n&&n(e)},a.stripTrailingSlash=function(t){return"/"===t.substr(-1)?t.substr(0,t.length-1):t},a.noneOrAll=function(t,e,n){if(t){var r,a,o=!1,i=!0;for(r=0;ra;a++)e[a][n]=t[a]},a.minExtend=function(t,e){var n={};"object"!=typeof e&&(e={});var r,o,i,l=3,s=Object.keys(t);for(r=0;r1?r+o[1]:"";if(a&&(o.length>1||i.length>4))for(;n.test(i);)i=i.replace(n,"$1"+a+"$2");return i+l}},{"./coerce":93,"./dates":94,"./extend":96,"./is_plain_object":100,"./loggers":101,"./matrix":102,"./nested_property":103,"./notifier":104,"./search":107,"./stats":109,d3:10}],100:[function(t,e,n){"use strict";e.exports=function(t){return window&&window.process&&window.process.versions?"[object Object]"===Object.prototype.toString.call(t):"[object Object]"===Object.prototype.toString.call(t)&&Object.getPrototypeOf(t)===Object.prototype}},{}],101:[function(t,e,n){"use strict";var r=t("../plot_api/plot_config"),a=e.exports={};a.log=function(){if(r.logging>1){for(var t=["LOG:"],e=0;e0){for(var t=["WARN:"],e=0;e0){for(var t=["ERROR:"],e=0;er;r++)n[r]=new Array(e);return n},n.transposeRagged=function(t){var e,n,r=0,a=t.length;for(e=0;a>e;e++)r=Math.max(r,t[e].length);var o=new Array(r);for(e=0;r>e;e++)for(o[e]=new Array(a),n=0;a>n;n++)o[e][n]=t[n][e];return o},n.dot=function(t,e){if(!t.length||!e.length||t.length!==e.length)return null;var r,a,o=t.length;if(t[0].length)for(r=new Array(o),a=0;o>a;a++)r[a]=n.dot(t[a],e);else if(e[0].length){var i=n.transposeRagged(e);for(r=new Array(i.length),a=0;aa;a++)r+=t[a]*e[a];return r},n.translationMatrix=function(t,e){return[[1,0,t],[0,1,e],[0,0,1]]},n.rotationMatrix=function(t){var e=t*Math.PI/180;return[[Math.cos(e),-Math.sin(e),0],[Math.sin(e),Math.cos(e),0],[0,0,1]]},n.rotationXYMatrix=function(t,e,r){return n.dot(n.dot(n.translationMatrix(e,r),n.rotationMatrix(t)),n.translationMatrix(-e,-r))},n.apply2DTransform=function(t){return function(){var e=arguments;3===e.length&&(e=e[0]);var r=1===arguments.length?e[0]:[e[0],e[1]];return n.dot(t,[r[0],r[1],1]).slice(0,2)}},n.apply2DTransform2=function(t){var e=n.apply2DTransform(t);return function(t){return e(t.slice(0,2)).concat(e(t.slice(2,4)))}}},{}],103:[function(t,e,n){"use strict";function r(t,e){return function(){var n,a,o,i,l,s=t;for(i=0;i=0;e--){if(r=t[e],i=!1,Array.isArray(r))for(n=r.length-1;n>=0;n--)c(r[n])?i?r[n]=void 0:r.pop():i=!0;else if("object"==typeof r&&null!==r)for(o=Object.keys(r),i=!1,n=o.length-1;n>=0;n--)c(r[o[n]])&&!a(r[o[n]],o[n])?delete r[o[n]]:i=!0;if(i)return}}function c(t){return void 0===t||null===t?!0:"object"!=typeof t?!1:Array.isArray(t)?!t.length:!Object.keys(t).length}function u(t,e,n){return{set:function(){throw"bad container"},get:function(){},astr:e,parts:n,obj:t}}var f=t("fast-isnumeric");e.exports=function(t,e){if(f(e))e=String(e);else if("string"!=typeof e||"[-1]"===e.substr(e.length-4))throw"bad property string";for(var n,a,i,l=0,s=e.split(".");ln||n>o||i>r||r>l?!1:!e||!c(t)}function n(t,e){var n=t[0],s=t[1];if(a>n||n>o||i>s||s>l)return!1;var c,u,f,d,h,p=r.length,g=r[0][0],v=r[0][1],m=0;for(c=1;p>c;c++)if(u=g,f=v,g=r[c][0],v=r[c][1],d=Math.min(u,g),!(d>n||n>Math.max(u,g)||s>Math.max(f,v)))if(s=s&&n!==d&&m++}return m%2===1}var r=t.slice(),a=r[0][0],o=a,i=r[0][1],l=i;r.push(r[0]);for(var s=1;so;o++)if(i=[t[o][0]-s[0],t[o][1]-s[1]],l=r(i,c),0>l||l>u||Math.abs(r(i,d))>a)return!0;return!1};a.filter=function(t,e){function n(n){t.push(n);var l=r.length,s=a;r.splice(i+1);for(var c=s+1;c1){var l=t.pop();n(l)}return{addPt:n,raw:t,filtered:r}}},{"./matrix":102}],106:[function(t,e,n){"use strict";function r(t,e){for(var n,r=[],o=0;oo.queueLength&&(t.undoQueue.queue.shift(),t.undoQueue.index--)))},i.startSequence=function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!0,t.undoQueue.beginSequence=!0},i.stopSequence=function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!1,t.undoQueue.beginSequence=!1},i.undo=function(t){var e,n;if(t.framework&&t.framework.isPolar)return void t.framework.undo();if(!(void 0===t.undoQueue||isNaN(t.undoQueue.index)||t.undoQueue.index<=0)){for(t.undoQueue.index--,e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,n=0;n=t.undoQueue.queue.length)){for(e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,n=0;nt}function a(t,e){return e>=t}function o(t,e){return t>e}function i(t,e){return t>=e}var l=t("fast-isnumeric"),s=t("../lib");n.findBin=function(t,e,n){if(l(e.start))return n?Math.ceil((t-e.start)/e.size)-1:Math.floor((t-e.start)/e.size);var c,u,f=0,d=e.length,h=0;for(u=e[e.length-1]>=e[0]?n?r:a:n?i:o;d>f&&h++<100;)c=Math.floor((f+d)/2),u(e[c],t)?f=c+1:d=c;return h>90&&s.log("Long binary search..."),f-1},n.sorterAsc=function(t,e){return t-e},n.sorterDes=function(t,e){return e-t},n.distinctVals=function(t){var e=t.slice();e.sort(n.sorterAsc);for(var r=e.length-1,a=e[r]-e[0]||1,o=a/(r||1)/1e4,i=[e[0]],l=0;r>l;l++)e[l+1]>e[l]+o&&(a=Math.min(a,e[l+1]-e[l]),i.push(e[l+1]));return{vals:i,minDiff:a}},n.roundUp=function(t,e,n){for(var r,a=0,o=e.length-1,i=0,l=n?0:1,s=n?1:0,c=n?Math.ceil:Math.floor;o>a&&i++<100;)r=c((a+o)/2),e[r]<=t?a=r+l:o=r-s;return e[a]}},{"../lib":99,"fast-isnumeric":12}],108:[function(t,e,n){"use strict";e.exports=function(t,e){(t.attr("class")||"").split(" ").forEach(function(e){0===e.indexOf("cursor-")&&t.classed(e,!1)}),e&&t.classed("cursor-"+e,!0); +-}},{}],109:[function(t,e,n){"use strict";var r=t("fast-isnumeric");n.aggNums=function(t,e,a,o){var i,l;if(o||(o=a.length),r(e)||(e=!1),Array.isArray(a[0])){for(l=new Array(o),i=0;o>i;i++)l[i]=n.aggNums(t,e,a[i]);a=l}for(i=0;o>i;i++)r(e)?r(a[i])&&(e=t(+e,+a[i])):e=a[i];return e},n.len=function(t){return n.aggNums(function(t){return t+1},0,t)},n.mean=function(t,e){return e||(e=n.len(t)),n.aggNums(function(t,e){return t+e},0,t)/e},n.variance=function(t,e,a){return e||(e=n.len(t)),r(a)||(a=n.mean(t,e)),n.aggNums(function(t,e){return t+Math.pow(e-a,2)},0,t)/e},n.stdev=function(t,e,r){return Math.sqrt(n.variance(t,e,r))},n.interp=function(t,e){if(!r(e))throw"n should be a finite number";if(e=e*t.length-.5,0>e)return t[0];if(e>t.length-1)return t[t.length-1];var n=e%1;return n*t[Math.ceil(e)]+(1-n)*t[Math.floor(e)]}},{"fast-isnumeric":12}],110:[function(t,e,n){"use strict";function r(t,e){return t.node().getBoundingClientRect()[e]}function a(t){return t.replace(/(<|<|<)/g,"\\lt ").replace(/(>|>|>)/g,"\\gt ")}function o(t,e,n){var r="math-output-"+c.Lib.randstr([],64),o=u.select("body").append("div").attr({id:r}).style({visibility:"hidden",position:"absolute"}).style({"font-size":e.fontSize+"px"}).text(a(t));MathJax.Hub.Queue(["Typeset",MathJax.Hub,o.node()],function(){var e=u.select("body").select("#MathJax_SVG_glyphs");if(o.select(".MathJax_SVG").empty()||!o.select("svg").node())f.log("There was an error in the tex syntax.",t),n();else{var r=o.select("svg").node().getBoundingClientRect();n(o.select(".MathJax_SVG"),e,r)}o.remove()})}function i(t){return(t||"").replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")}function l(t){for(var e=t.split(/(<[^<>]*>)/).map(function(t){var e=t.match(/<(\/?)([^ >]*)\s*(.*)>/i),n=e&&e[2].toLowerCase(),r=p[n];if(void 0!==r){var a=e[1],o=e[3],l=o.match(/^style\s*=\s*"([^"]+)"\s*/i);if("a"===n){if(a)return"
";if("href"!==o.substr(0,4).toLowerCase())return"";var s=o.substr(4).replace(/["']/g,"").replace(/=/,""),u=document.createElement("a");return u.href=s,-1===g.indexOf(u.protocol)?"":''}if("br"===n)return"
";if(a)return"sup"===n?'':"sub"===n?'':"";var f=""}return c.util.xml_entity_encode(t).replace(/");r>0;r=e.indexOf("
",r+1))n.push(r);var a=0;n.forEach(function(t){for(var n=t+a,r=e.slice(0,n),o="",i=r.length-1;i>=0;i--){var l=r[i].match(/<(\/?).*>/i);if(l&&"
"!==r[i]){l[1]||(o=r[i]);break}}o&&(e.splice(n+1,0,o),e.splice(n,0,""),a+=2)});var o=e.join(""),l=o.split(/
/gi);return l.length>1&&(e=l.map(function(t,e){return''+t+""})),e.join("")}function s(t,e,n){var r,a,o,i=n.horizontalAlign,l=n.verticalAlign||"top",s=t.node().getBoundingClientRect(),c=e.node().getBoundingClientRect();return a="bottom"===l?function(){return s.bottom-r.height}:"middle"===l?function(){return s.top+(s.height-r.height)/2}:function(){return s.top},o="right"===i?function(){return s.right-r.width}:"center"===i?function(){return s.left+(s.width-r.width)/2}:function(){return s.left},function(){return r=this.node().getBoundingClientRect(),this.style({top:a()-c.top+"px",left:o()-c.left+"px","z-index":1e3}),this}}var c=t("../plotly"),u=t("d3"),f=t("../lib"),d=t("../constants/xmlns_namespaces"),h=e.exports={};u.selection.prototype.appendSVG=function(t){for(var e=['',t,""].join(""),n=(new DOMParser).parseFromString(e,"application/xml"),r=n.documentElement.firstChild;r;)this.node().appendChild(this.node().ownerDocument.importNode(r,!0)),r=r.nextSibling;return n.querySelector("parsererror")?(f.log(n.querySelector("parsererror div").textContent),null):u.select(this.node().lastChild)},h.html_entity_decode=function(t){var e=u.select("body").append("div").style({display:"none"}).html(""),n=t.replace(/(&[^;]*;)/gi,function(t){return"<"===t?"<":"&rt;"===t?">":e.html(t).text()});return e.remove(),n},h.xml_entity_encode=function(t){return t.replace(/&(?!\w+;|\#[0-9]+;| \#x[0-9A-F]+;)/g,"&")},h.convertToTspans=function(t,e){function n(){h.empty()||(p=s.attr("class")+"-math",h.select("svg."+p).remove()),t.text("").style({visibility:"visible","white-space":"pre"}),d=t.appendSVG(i),d||t.text(a),t.select("a").size()&&t.style("pointer-events","all"),e&&e.call(s)}var a=t.text(),i=l(a),s=t,f=!s.attr("data-notex")&&i.match(/([^$]*)([$]+[^$]*[$]+)([^$]*)/),d=a,h=u.select(s.node().parentNode);if(!h.empty()){var p=s.attr("class")?s.attr("class").split(" ")[0]:"text";p+="-math",h.selectAll("svg."+p).remove(),h.selectAll("g."+p+"-group").remove(),t.style({visibility:null});for(var g=t.node();g&&g.removeAttribute;g=g.parentNode)g.removeAttribute("data-bb");if(f){var v=c.Lib.getPlotDiv(s.node());(v&&v._promises||[]).push(new Promise(function(t){s.style({visibility:"hidden"});var a={fontSize:parseInt(s.style("font-size"),10)};o(f[2],a,function(a,o,i){h.selectAll("svg."+p).remove(),h.selectAll("g."+p+"-group").remove();var l=a&&a.select("svg");if(!l||!l.node())return n(),void t();var c=h.append("g").classed(p+"-group",!0).attr({"pointer-events":"none"});c.node().appendChild(l.node()),o&&o.node()&&l.node().insertBefore(o.node().cloneNode(!0),l.node().firstChild),l.attr({"class":p,height:i.height,preserveAspectRatio:"xMinYMin meet"}).style({overflow:"visible","pointer-events":"none"});var u=s.style("fill")||"black";l.select("g").attr({fill:u,stroke:u});var f=r(l,"width"),d=r(l,"height"),g=+s.attr("x")-f*{start:0,middle:.5,end:1}[s.attr("text-anchor")||"start"],v=parseInt(s.style("font-size"),10)||r(s,"height"),m=-v/4;"y"===p[0]?(c.attr({transform:"rotate("+[-90,+s.attr("x"),+s.attr("y")]+") translate("+[-f/2,m-d/2]+")"}),l.attr({x:+s.attr("x"),y:+s.attr("y")})):"l"===p[0]?l.attr({x:s.attr("x"),y:m-d/2}):"a"===p[0]?l.attr({x:0,y:m}):l.attr({x:g,y:+s.attr("y")+m-d/2}),e&&e.call(s,c),t(c)})}))}else n();return t}};var p={sup:'font-size:70%" dy="-0.6em',sub:'font-size:70%" dy="0.3em',b:"font-weight:bold",i:"font-style:italic",a:"",span:"",br:"",em:"font-style:italic;font-weight:bold"},g=["http:","https:","mailto:"],v=new RegExp("]*)?/?>","g");h.plainText=function(t){return(t||"").replace(v," ")},h.makeEditable=function(t,e,n){function r(){o(),i.style({opacity:0});var t,e=d.attr("class");t=e?"."+e.split(" ")[0]+"-math-group":"[class*=-math-group]",t&&u.select(i.node().parentNode).select(t).style({opacity:0})}function a(t){var e=t.node(),n=document.createRange();n.selectNodeContents(e);var r=window.getSelection();r.removeAllRanges(),r.addRange(n),e.focus()}function o(){var t=u.select(c.Lib.getPlotDiv(i.node())),e=t.select(".svg-container"),r=e.append("div");r.classed("plugin-editable editable",!0).style({position:"absolute","font-family":i.style("font-family")||"Arial","font-size":i.style("font-size")||12,color:n.fill||i.style("fill")||"black",opacity:1,"background-color":n.background||"transparent",outline:"#ffffff33 1px solid",margin:[-parseFloat(i.style("font-size"))/8+1,0,0,-1].join("px ")+"px",padding:"0","box-sizing":"border-box"}).attr({contenteditable:!0}).text(n.text||i.attr("data-unformatted")).call(s(i,e,n)).on("blur",function(){i.text(this.textContent).style({opacity:1});var t,e=u.select(this).attr("class");t=e?"."+e.split(" ")[0]+"-math-group":"[class*=-math-group]",t&&u.select(i.node().parentNode).select(t).style({opacity:0});var n=this.textContent;u.select(this).transition().duration(0).remove(),u.select(document).on("mouseup",null),l.edit.call(i,n)}).on("focus",function(){var t=this;u.select(document).on("mouseup",function(){return u.event.target===t?!1:void(document.activeElement===r.node()&&r.node().blur())})}).on("keyup",function(){27===u.event.which?(i.style({opacity:1}),u.select(this).style({opacity:0}).on("blur",function(){return!1}).transition().remove(),l.cancel.call(i,this.textContent)):(l.input.call(i,this.textContent),u.select(this).call(s(i,e,n)))}).on("keydown",function(){13===u.event.which&&this.blur()}).call(a)}n||(n={});var i=this,l=u.dispatch("edit","input","cancel"),f=u.select(this.node()).style({"pointer-events":"all"}),d=e||f;return e&&f.style({"pointer-events":"none"}),n.immediate?r():d.on("click",r),u.rebind(this,l,"on")}},{"../constants/xmlns_namespaces":89,"../lib":99,"../plotly":118,d3:10}],111:[function(t,e,n){"use strict";var r=e.exports={},a=t("../plots/geo/constants").locationmodeToLayer,o=t("topojson").feature;r.getTopojsonName=function(t){return[t.scope.replace(/ /g,"-"),"_",t.resolution.toString(),"m"].join("")},r.getTopojsonPath=function(t,e){return t+e+".json"},r.getTopojsonFeatures=function(t,e){var n=a[t.locationmode],r=e.objects[n];return o(e,r).features}},{"../plots/geo/constants":140,topojson:15}],112:[function(t,e,n){"use strict";function r(t){var e;if("string"==typeof t){if(e=document.getElementById(t),null===e)throw new Error("No DOM element with id '"+t+"' exists on the page.");return e}if(null===t||void 0===t)throw new Error("DOM element provided is null or undefined");return t}function a(t){Array.isArray(t._promises)&&t._promises.length>0&&P.log("Clearing previous rejected promises from queue."),t._promises=[]}function o(t,e){t._fullLayout._paperdiv.style("background","white"),N.defaultConfig.setBackground(t,e)}function i(t,e){t._context||(t._context=P.extendFlat({},N.defaultConfig));var n=t._context;e&&(Object.keys(e).forEach(function(t){t in n&&("setBackground"===t&&"opaque"===e[t]?n[t]=o:n[t]=e[t])}),e.plot3dPixelRatio&&!n.plotGlPixelRatio&&(n.plotGlPixelRatio=n.plot3dPixelRatio)),n.staticPlot&&(n.editable=!1,n.autosizable=!1,n.scrollZoom=!1,n.doubleClick=!1,n.showTips=!1,n.showLink=!1,n.displayModeBar=!1)}function l(t,e,n){var r=C.select(t).selectAll(".plot-container").data([0]);r.enter().insert("div",":first-child").classed("plot-container plotly",!0);var a=r.selectAll(".svg-container").data([0]);a.enter().append("div").classed("svg-container",!0).style("position","relative"),a.html(""),e&&(t.data=e),n&&(t.layout=n),N.micropolar.manager.fillLayout(t),"initial"===t._fullLayout.autosize&&t._context.autosizable&&(k(t,{}),t._fullLayout.autosize=n.autosize=!0),a.style({width:t._fullLayout.width+"px",height:t._fullLayout.height+"px"}),t.framework=N.micropolar.manager.framework(t),t.framework({data:t.data,layout:t.layout},a.node()),t.framework.setUndoPoint();var o=t.framework.svg(),i=1,l=t._fullLayout.title;""!==l&&l||(i=0);var s="Click to enter title",c=function(){this.call(N.util.convertToTspans)},u=o.select(".title-group text").call(c);if(t._context.editable){u.attr({"data-unformatted":l}),l&&l!==s||(i=.2,u.attr({"data-unformatted":s}).text(s).style({opacity:i}).on("mouseover.opacity",function(){C.select(this).transition().duration(100).style("opacity",1)}).on("mouseout.opacity",function(){C.select(this).transition().duration(1e3).style("opacity",0)}));var f=function(){this.call(N.util.makeEditable).on("edit",function(e){t.framework({layout:{title:e}}),this.attr({"data-unformatted":e}).text(e).call(c),this.call(f)}).on("cancel",function(){var t=this.attr("data-unformatted");this.text(t).call(c)})};u.call(f)}return t._context.setBackground(t,t._fullLayout.paper_bgcolor),R.addLinks(t),Promise.resolve()}function s(t){var e,n;t||(t={}),t.xaxis1&&(t.xaxis||(t.xaxis=t.xaxis1),delete t.xaxis1),t.yaxis1&&(t.yaxis||(t.yaxis=t.yaxis1),delete t.yaxis1);var r=N.Axes.list({_fullLayout:t});for(e=0;ee;e++){var i=t.annotations[e];i.ref&&("paper"===i.ref?(i.xref="paper",i.yref="paper"):"data"===i.ref&&(i.xref="x",i.yref="y"),delete i.ref),c(i,"xref"),c(i,"yref")}void 0===t.shapes||Array.isArray(t.shapes)||(P.warn("Shapes must be an array."),delete t.shapes);var l=(t.shapes||[]).length;for(e=0;l>e;e++){var s=t.shapes[e];c(s,"xref"),c(s,"yref")}var u=t.legend;u&&(u.x>3?(u.x=1.02,u.xanchor="left"):u.x<-2&&(u.x=-.02,u.xanchor="right"),u.y>3?(u.y=1.02,u.yanchor="bottom"):u.y<-2&&(u.y=-.02,u.yanchor="top")),"rotate"===t.dragmode&&(t.dragmode="orbit"),t.scene1&&(t.scene||(t.scene=t.scene1),delete t.scene1);var f=R.getSubplotIds(t,"gl3d");for(e=0;en;++n)x[n]=v[e]+m*y[2+4*n];h.camera={eye:{x:x[0],y:x[1],z:x[2]},center:{x:v[0],y:v[1],z:v[2]},up:{x:y[1],y:y[5],z:y[9]}},delete h.cameraposition}}return q.clean(t),t}function c(t,e){var n=t[e],r=e.charAt(0);n&&"paper"!==n&&(t[e]=N.Axes.cleanId(n,r))}function u(t,e){for(var n=[],r=(t.concat(Array.isArray(e)?e:[]).filter(function(t){return"uid"in t}).map(function(t){return t.uid})),a=0;ao&&(l=P.randstr(r),-1!==n.indexOf(l));o++);i.uid=P.randstr(r),r.push(i.uid)}if(n.push(i.uid),"histogramy"===i.type&&"xbins"in i&&!("ybins"in i)&&(i.ybins=i.xbins,delete i.xbins),i.error_y&&"opacity"in i.error_y){var s=q.defaults,c=i.error_y.color||(R.traceIs(i,"bar")?q.defaultLine:s[a%s.length]);i.error_y.color=q.addOpacity(q.rgb(c),q.opacity(c)*i.error_y.opacity),delete i.error_y.opacity}if("bardir"in i&&("h"!==i.bardir||!R.traceIs(i,"bar")&&"histogram"!==i.type.substr(0,9)||(i.orientation="h",_(i)),delete i.bardir),"histogramy"===i.type&&_(i),"histogramx"!==i.type&&"histogramy"!==i.type||(i.type="histogram"),"scl"in i&&(i.colorscale=i.scl,delete i.scl),"reversescl"in i&&(i.reversescale=i.reversescl,delete i.reversescl),i.xaxis&&(i.xaxis=N.Axes.cleanId(i.xaxis,"x")),i.yaxis&&(i.yaxis=N.Axes.cleanId(i.yaxis,"y")),R.traceIs(i,"gl3d")&&i.scene&&(i.scene=R.subplotsRegistry.gl3d.cleanId(i.scene)),R.traceIs(i,"pie")||(Array.isArray(i.textposition)?i.textposition=i.textposition.map(f):i.textposition&&(i.textposition=f(i.textposition))),R.traceIs(i,"2dMap")&&("YIGnBu"===i.colorscale&&(i.colorscale="YlGnBu"),"YIOrRd"===i.colorscale&&(i.colorscale="YlOrRd")),R.traceIs(i,"markerColorscale")&&i.marker){var u=i.marker;"YIGnBu"===u.colorscale&&(u.colorscale="YlGnBu"),"YIOrRd"===u.colorscale&&(u.colorscale="YlOrRd")}if("surface"===i.type&&P.isPlainObject(i.contours)){var h=["x","y","z"];for(o=0;or?o.push(a+r):o.push(r);return o}function g(t,e,n){var r,a;for(r=0;r=t.data.length||a<-t.data.length)throw new Error(n+" must be valid indices for gd.data.");if(e.indexOf(a,r+1)>-1||a>=0&&e.indexOf(-t.data.length+a)>-1||0>a&&e.indexOf(t.data.length+a)>-1)throw new Error("each index in "+n+" must be unique.")}}function v(t,e,n){if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("currentIndices is a required argument.");if(Array.isArray(e)||(e=[e]),g(t,e,"currentIndices"),"undefined"==typeof n||Array.isArray(n)||(n=[n]),"undefined"!=typeof n&&g(t,n,"newIndices"),"undefined"!=typeof n&&e.length!==n.length)throw new Error("current and new indices must be of equal length.")}function m(t,e,n){var r,a;if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("traces must be defined.");for(Array.isArray(e)||(e=[e]),r=0;r=0&&s0){var l=w(t._boundingBoxMargins),s=l.left+l.right,c=l.bottom+l.top,u=o._container.node().getBoundingClientRect(),f=1-2*i.frameMargins;a=Math.round(f*(u.width-s)),r=Math.round(f*(u.height-c))}else n=window.getComputedStyle(t),r=parseFloat(n.height)||o.height,a=parseFloat(n.width)||o.width;return Math.abs(o.width-a)>1||Math.abs(o.height-r)>1?(o.height=t.layout.height=r,o.width=t.layout.width=a):"initial"!==o.autosize&&(delete e.autosize,o.autosize=t.layout.autosize=!0),R.sanitizeMargins(o),e}function M(t){var e=C.select(t),n=t._fullLayout;if(n._container=e.selectAll(".plot-container").data([0]),n._container.enter().insert("div",":first-child").classed("plot-container",!0).classed("plotly",!0),n._paperdiv=n._container.selectAll(".svg-container").data([0]),n._paperdiv.enter().append("div").classed("svg-container",!0).style("position","relative"),"initial"===n.autosize&&(k(t,{}),n.autosize=!0,t.layout.autosize=!0),n._glcontainer=n._paperdiv.selectAll(".gl-container").data([0]),n._glcontainer.enter().append("div").classed("gl-container",!0),n._geocontainer=n._paperdiv.selectAll(".geo-container").data([0]),n._geocontainer.enter().append("div").classed("geo-container",!0),n._paperdiv.selectAll(".main-svg").remove(),n._paper=n._paperdiv.insert("svg",":first-child").classed("main-svg",!0),n._toppaper=n._paperdiv.append("svg").classed("main-svg",!0),!n._uid){var r=[];C.selectAll("defs").each(function(){this.id&&r.push(this.id.split("-")[1])}),n._uid=P.randstr(r)}n._paperdiv.selectAll(".main-svg").attr($.svgAttrs),n._defs=n._paper.append("defs").attr("id","defs-"+n._uid),n._topdefs=n._toppaper.append("defs").attr("id","topdefs-"+n._uid),n._draggers=n._paper.append("g").classed("draglayer",!0);var a=n._paper.append("g").classed("layer-below",!0);n._imageLowerLayer=a.append("g").classed("imagelayer",!0),n._shapeLowerLayer=a.append("g").classed("shapelayer",!0);var o=N.Axes.getSubplots(t);o.join("")!==Object.keys(t._fullLayout._plots||{}).join("")&&A(t,o),n._has("cartesian")&&T(t,o),n._ternarylayer=n._paper.append("g").classed("ternarylayer",!0);var i=n._paper.selectAll(".layer-subplot");n._imageSubplotLayer=i.selectAll(".imagelayer"),n._shapeSubplotLayer=i.selectAll(".shapelayer");var l=n._paper.append("g").classed("layer-above",!0);n._imageUpperLayer=l.append("g").classed("imagelayer",!0),n._shapeUpperLayer=l.append("g").classed("shapelayer",!0),n._pielayer=n._paper.append("g").classed("pielayer",!0),n._glimages=n._paper.append("g").classed("glimages",!0),n._geoimages=n._paper.append("g").classed("geoimages",!0),n._infolayer=n._toppaper.append("g").classed("infolayer",!0),n._zoomlayer=n._toppaper.append("g").classed("zoomlayer",!0),n._hoverlayer=n._toppaper.append("g").classed("hoverlayer",!0),t.emit("plotly_framework");var s=P.syncOrAsync([L,function(){return N.Axes.doTicks(t,"redraw")},I.init],t);return s&&s.then&&t._promises.push(s),s}function A(t,e){function n(e,n){return function(){return N.Axes.getFromId(t,e,n)}}for(var r,a,o=t._fullLayout._plots={},i=0;i0,_=N.Axes.getSubplots(t).join(""),w=Object.keys(t._fullLayout._plots||{}).join(""),k=w===_;b?t.framework===M&&!x&&k||(t.framework=M,M(t)):k?x&&M(t):(t.framework=M,M(t)),x&&N.Axes.saveRangeInitial(t);var A=t._fullLayout,T=!t.calcdata||t.calcdata.length!==(t.data||[]).length;T&&h(t);for(var z=0;zX.range[0]?[1,2]:[2,1]);else{var $=X.range[0],W=X.range[1];"log"===I?(0>=$&&0>=W&&o(G+".autorange",!0),0>=$?$=W/1e6:0>=W&&(W=$/1e6),o(G+".range[0]",Math.log($)/Math.LN10),o(G+".range[1]",Math.log(W)/Math.LN10)):(o(G+".range[0]",Math.pow(10,$)),o(G+".range[1]",Math.pow(10,W)))}else o(G+".autorange",!0)}if("reverse"===B)Z.range?Z.range.reverse():(o(G+".autorange",!0),Z.range=[1,0]),Y.autorange?w=!0:_=!0;else if("annotations"===j.parts[0]||"shapes"===j.parts[0]){var J=j.parts[1],K=j.parts[0],tt=g[K]||[],et=N[P.titleCase(K)],nt=tt[J]||{};2===j.parts.length&&("add"===m[E]||P.isPlainObject(m[E])?z[E]="remove":"remove"===m[E]?-1===J?(z[K]=tt,delete z[E]):z[E]=nt:P.log("???",m)),!i(nt,"x")&&!i(nt,"y")||P.containsAny(E,["color","opacity","align","dash"])||(w=!0),et.draw(t,J,j.parts.slice(2).join("."),m[E]),delete m[E]}else if("images"===j.parts[0]){var at=P.objectFromPath(E,I);P.extendDeepAll(t.layout,at),H.supplyLayoutDefaults(t.layout,t._fullLayout),H.draw(t)}else if("mapbox"===j.parts[0]&&"layers"===j.parts[1]){P.extendDeepAll(t.layout,P.objectFromPath(E,I));var ot=(t._fullLayout.mapbox||{}).layers||[];for(O=j.parts[2]+1-ot.length,p=0;O>p;p++)ot.push({});_=!0}else if("updatemenus"===j.parts[0]){P.extendDeepAll(t.layout,P.objectFromPath(E,I));var it=t._fullLayout.updatemenus||[];for(O=j.parts[2]+1-it.length,p=0;O>p;p++)it.push({});_=!0}else 0===j.parts[0].indexOf("scene")?_=!0:0===j.parts[0].indexOf("geo")?_=!0:0===j.parts[0].indexOf("ternary")?_=!0:!v._has("gl2d")||-1===E.indexOf("axis")&&"plot_bgcolor"!==j.parts[0]?"hiddenlabels"===E?w=!0:-1!==j.parts[0].indexOf("legend")?y=!0:-1!==E.indexOf("title")?x=!0:-1!==j.parts[0].indexOf("bgcolor")?b=!0:j.parts.length>1&&P.containsAny(j.parts[1],["tick","exponent","grid","zeroline"])?x=!0:-1!==E.indexOf(".linewidth")&&-1!==E.indexOf("axis")?x=b=!0:j.parts.length>1&&-1!==j.parts[1].indexOf("line")?b=!0:j.parts.length>1&&"mirror"===j.parts[1]?x=b=!0:"margin.pad"===E?x=b=!0:"margin"===j.parts[0]||"autorange"===j.parts[1]||"rangemode"===j.parts[1]||"type"===j.parts[1]||"domain"===j.parts[1]||E.match(/^(bar|box|font)/)?w=!0:-1!==["hovermode","dragmode"].indexOf(E)?M=!0:-1===["hovermode","dragmode","height","width","autosize"].indexOf(E)&&(_=!0):_=!0,j.set(I)}D.add(t,rt,[t,z],rt,[t,T]),m.autosize&&(m=k(t,m)),(m.height||m.width||m.autosize)&&(w=!0);var lt=Object.keys(m),st=[R.previousPromises];if(_||w)st.push(function(){return t.layout=void 0,w&&(t.calcdata=void 0),N.plot(t,"",g)});else if(lt.length&&(R.supplyDefaults(t),v=t._fullLayout,y&&st.push(function(){return V.draw(t),R.previousPromises(t)}),b&&st.push(L),x&&st.push(function(){return N.Axes.doTicks(t,"redraw"),S(t),R.previousPromises(t)}),M)){var ct;for(Q(t),N.Fx.supplyLayoutDefaults(t.layout,v,t._fullData),N.Fx.init(t),ct=R.getSubplotIds(v,"gl3d"),p=0;p1)};c(n.width)&&c(n.height)||l(new Error("Height and width should be pixel values."));var u=r.clone(e,{format:"png",height:n.height,width:n.width}),f=u.td;f.style.position="absolute",f.style.left="-5000px",document.body.appendChild(f);var d=r.getRedrawFunc(f);o.plot(f,u.data,u.layout,u.config).then(d).then(s).then(function(e){t(e)}).catch(function(t){l(t)})});return l}var a=t("fast-isnumeric"),o=t("../plotly"),i=t("../lib");e.exports=r},{"../lib":99,"../plotly":118,"../snapshot":163,"fast-isnumeric":12}],117:[function(t,e,n){"use strict";function r(t,e,n,a,o,c){c=c||[];for(var u=Object.keys(t),d=0;d1&&s.push(i("object","layout"))),d.supplyDefaults(c);for(var u=c._fullData,v=n.length,m=0;v>m;m++){var y=n[m],x=["data",m];if(p(y)){var b=u[m],_=b.type,w=l.traces[_].attributes;w.type={valType:"enumerated",values:[_]},b.visible===!1&&y.visible!==!1&&s.push(i("invisible",x)),r(y,b,w,s,x);var k=y.transforms,M=b.transforms;if(k){g(k)||s.push(i("array",x,["transforms"])),x.push("transforms");for(var A=0;Ac&&u>e&&(void 0===a[n]?o[f]=T.tickText(t,e):o[f]=l(t,e,String(a[n])),f++);return f=864e5?t._tickround="d":n>=36e5?t._tickround="H":n>=6e4?t._tickround="M":n>=1e3?t._tickround="S":t._tickround=3-Math.round(Math.log(n/2)/Math.LN10);else{x(n)||(n=Number(n.substr(1))),t._tickround=2-Math.floor(Math.log(n)/Math.LN10+.01),e="log"===t.type?Math.pow(10,Math.max(t.range[0],t.range[1])):Math.max(Math.abs(t.range[0]),Math.abs(t.range[1]));var r=Math.floor(Math.log(e)/Math.LN10+.01);Math.abs(r)>3&&("SI"===t.exponentformat||"B"===t.exponentformat?t._tickexponent=3*Math.round((r-1)/3):t._tickexponent=r)}else"M"===n.charAt(0)?t._tickround=2===n.length?"m":"y":t._tickround=null}function i(t,e){var n=t.match(B),r=new Date(e);if(n){var a=Math.min(+n[1]||6,6),o=String(e/1e3%1+2.0000005).substr(2,a).replace(/0+$/,"")||"0";return y.time.format(t.replace(B,o))(r)}return y.time.format(t)(r)}function l(t,e,n){var r=t.tickfont||t._gd._fullLayout.font;return{x:e,dx:0,dy:0,text:n||"",fontSize:r.size,font:r.family,fontColor:r.color}}function s(t,e,n,r){var a,o=e.x,l=t._tickround,s=new Date(o),c="";n&&t.hoverformat?a=i(t.hoverformat,o):t.tickformat?a=i(t.tickformat,o):(r&&(x(l)?l+=2:l={y:"m",m:"d",d:"H",H:"M",M:"S",S:2}[l]),"y"===l?a=j(s):"m"===l?a=D(s):(o!==t._tmin||n||(c="
"+j(s)),"d"===l?a=R(s):"H"===l?a=I(s):(o!==t._tmin||n||(c="
"+R(s)+", "+j(s)),a=q(s),"M"!==l&&(a+=F(s),"S"!==l&&(a+=d(m(o/1e3,1),t,"none",n).substr(1)))))),e.text=a+c}function c(t,e,n,r,a){var o=t.dtick,i=e.x;if(!r||"string"==typeof o&&"L"===o.charAt(0)||(o="L3"),t.tickformat||"string"==typeof o&&"L"===o.charAt(0))e.text=d(Math.pow(10,i),t,a,r);else if(x(o)||"D"===o.charAt(0)&&m(i+.01,1)<.1)if(-1!==["e","E","power"].indexOf(t.exponentformat)){var l=Math.round(i);0===l?e.text=1:1===l?e.text="10":l>1?e.text="10"+l+"":e.text="10\u2212"+-l+"",e.fontSize*=1.25}else e.text=d(Math.pow(10,i),t,"","fakehover"),"D1"===o&&"y"===t._id.charAt(0)&&(e.dy-=e.fontSize/6);else{if("D"!==o.charAt(0))throw"unrecognized dtick "+String(o);e.text=String(Math.round(Math.pow(10,m(i,1)))),e.fontSize*=.75}if("D1"===t.dtick){var s=String(e.text).charAt(0);"0"!==s&&"1"!==s||("y"===t._id.charAt(0)?e.dx-=e.fontSize/4:(e.dy+=e.fontSize/2,e.dx+=(t.range[1]>t.range[0]?1:-1)*e.fontSize*(0>i?.5:.25)))}}function u(t,e){var n=t._categories[Math.round(e.x)];void 0===n&&(n=""),e.text=String(n)}function f(t,e,n,r,a){"all"===t.showexponent&&Math.abs(e.x/t.dtick)<1e-6&&(a="hide"),e.text=d(e.x,t,a,r)}function d(t,e,n,r){var a=0>t,i=e._tickround,l=n||e.exponentformat||"B",s=e._tickexponent,c=e.tickformat;if(r){var u={exponentformat:e.exponentformat,dtick:"none"===e.showexponent?e.dtick:x(t)?Math.abs(t)||1:1,range:"none"===e.showexponent?e.range:[0,t||1]};o(u),i=(Number(u._tickround)||0)+4,s=u._tickexponent,e.hoverformat&&(c=e.hoverformat)}if(c)return y.format(c)(t).replace(/-/g,"\u2212");var f=Math.pow(10,-i)/2;if("none"===l&&(s=0),t=Math.abs(t),f>t)t="0",a=!1;else{if(t+=f,s&&(t*=Math.pow(10,-s),i+=s),0===i)t=String(Math.floor(t));else if(0>i){t=String(Math.round(t)),t=t.substr(0,t.length+i);for(var d=i;0>d;d++)t+="0"}else{t=String(t);var h=t.indexOf(".")+1;h&&(t=t.substr(0,h+i).replace(/\.?0+$/,""))}t=_.numSeparate(t,e._gd._fullLayout.separators)}if(s&&"hide"!==l){var p;p=0>s?"\u2212"+-s:"power"!==l?"+"+s:String(s),"e"===l||("SI"===l||"B"===l)&&(s>12||-15>s)?t+="e"+p:"E"===l?t+="E"+p:"power"===l?t+="\xd710"+p+"":"B"===l&&9===s?t+="B":"SI"!==l&&"B"!==l||(t+=H[s/3+5])}return a?"\u2212"+t:t}function h(t,e){var n,r,a=[];for(n=0;n1)for(r=1;r2e-6||((n-t._forceTick0)/t._minDtick%1+1.000001)%1>2e-6)&&(t._minDtick=0)):t._minDtick=0},T.getAutoRange=function(t){var e,n=[],r=t._min[0].val,a=t._max[0].val;for(e=1;e0&&u>0&&f/u>d&&(s=i,c=l,d=f/u);return r===a?n=h?[r+1,"normal"!==t.rangemode?0:r-1]:["normal"!==t.rangemode?0:r-1,r+1]:d&&("linear"!==t.type&&"-"!==t.type||("tozero"===t.rangemode&&s.val>=0?s={val:0,pad:0}:"nonnegative"===t.rangemode&&(s.val-d*s.pad<0&&(s={val:0,pad:0}),c.val<0&&(c={val:1,pad:0})),d=(c.val-s.val)/(t._length-s.pad-c.pad)),n=[s.val-d*s.pad,c.val+d*c.pad],n[0]===n[1]&&(n=[n[0]-1,n[0]+1]),h&&n.reverse()),n},T.doAutoRange=function(t){t._length||t.setScale();var e=t._min&&t._max&&t._min.length&&t._max.length;if(t.autorange&&e){t.range=T.getAutoRange(t);var n=t._gd.layout[t._name];n||(t._gd.layout[t._name]=n={}),n!==t&&(n.range=t.range.slice(),n.autorange=t.autorange)}},T.saveRangeInitial=function(t,e){for(var n=T.list(t,"",!0),r=!1,a=0;ap&&(p=g/10),c=t.c2l(p),u=t.c2l(g),y&&(c=Math.min(0,c),u=Math.max(0,u)),r(c)){for(h=!0,i=0;i=d?h=!1:l.val>=c&&l.pad<=d&&(t._min.splice(i,1),i--);h&&t._min.push({val:c,pad:y&&0===c?0:d})}if(r(u)){for(h=!0,i=0;i=u&&l.pad>=f?h=!1:l.val<=u&&l.pad<=f&&(t._max.splice(i,1),i--);h&&t._max.push({val:u,pad:y&&0===u?0:f})}}}if((t.autorange||t._needsExpand)&&e){t._min||(t._min=[]),t._max||(t._max=[]),n||(n={}),t._m||t.setScale();var o,i,l,s,c,u,f,d,h,p,g,v=e.length,m=n.padded?.05*t._length:0,y=n.tozero&&("linear"===t.type||"-"===t.type),b=r((t._m>0?n.ppadplus:n.ppadminus)||n.ppad||0),_=r((t._m>0?n.ppadminus:n.ppadplus)||n.ppad||0),w=r(n.vpadplus||n.vpad),k=r(n.vpadminus||n.vpad);for(o=0;6>o;o++)a(o);for(o=v-1;o>5;o--)a(o)}},T.autoBin=function(t,e,n,r){function a(t){return(1+100*(t-h)/f.dtick)%100<2}var o=_.aggNums(Math.min,null,t),i=_.aggNums(Math.max,null,t);if("category"===e.type)return{start:o-.5,end:i+.5,size:1};var l;if(n)l=(i-o)/n;else{var s=_.distinctVals(t),c=Math.pow(10,Math.floor(Math.log(s.minDiff)/Math.LN10)),u=c*_.roundUp(s.minDiff/c,[.9,1.9,4.9,9.9],!0);l=Math.max(u,2*_.stdev(t)/Math.pow(t.length,r?.25:.4))}var f={type:"log"===e.type?"linear":e.type,range:[o,i]};T.autoTicks(f,l);var d,h=T.tickIncrement(T.tickFirst(f),f.dtick,"reverse");if("number"==typeof f.dtick){for(var p=0,g=0,v=0,m=0,y=0;yg&&(p>.3*b||a(o)||a(i))){var w=f.dtick/2;h+=o>h+w?w:-w}var k=1+Math.floor((i-h)/f.dtick);d=h+k*f.dtick}else for(d=h;i>=d;)d=T.tickIncrement(d,f.dtick);return{start:h,end:d,size:f.dtick}},T.calcTicks=function(t){if("array"===t.tickmode)return r(t);if("auto"===t.tickmode||!t.dtick){var e,n=t.nticks;n||("category"===t.type?(e=t.tickfont?1.2*(t.tickfont.size||12):15,n=t._length/e):(e="y"===t._id.charAt(0)?40:80,n=_.constrain(t._length/e,4,9)+1)),T.autoTicks(t,Math.abs(t.range[1]-t.range[0])/n),t._minDtick>0&&t.dtick<2*t._minDtick&&(t.dtick=t._minDtick,t.tick0=t._forceTick0)}t.tick0||(t.tick0="date"===t.type?new Date(2e3,0,1).getTime():0),o(t),t._tmin=T.tickFirst(t);var a=t.range[1]=l:l>=s)&&(i.push(s),!(i.length>1e3));s=T.tickIncrement(s,t.dtick,a));t._tmax=i[i.length-1];for(var c=new Array(i.length),u=0;u157788e5?(e/=315576e5,n=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick="M"+12*a(e,n,S)):e>12096e5?(e/=26298e5,t.dtick="M"+a(e,1,C)):e>432e5?(t.dtick=a(e,864e5,O),t.tick0=new Date(2e3,0,2).getTime()):e>18e5?t.dtick=a(e,36e5,C):e>3e4?t.dtick=a(e,6e4,E):e>500?t.dtick=a(e,1e3,E):(n=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick=a(e,n,S));else if("log"===t.type)if(t.tick0=0,e>.7)t.dtick=Math.ceil(e);else if(Math.abs(t.range[1]-t.range[0])<1){var r=1.5*Math.abs((t.range[1]-t.range[0])/e);e=Math.abs(Math.pow(10,t.range[1])-Math.pow(10,t.range[0]))/r,n=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick="L"+a(e,n,S)}else t.dtick=e>.3?"D2":"D1";else"category"===t.type?(t.tick0=0,t.dtick=Math.ceil(Math.max(e,1))):(t.tick0=0,n=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick=a(e,n,S));if(0===t.dtick&&(t.dtick=1),!x(t.dtick)&&"string"!=typeof t.dtick){var o=t.dtick;throw t.dtick=1,"ax.dtick error: "+String(o)}},T.tickIncrement=function(t,e,n){var r=n?-1:1;if(x(e))return t+r*e;var a=e.charAt(0),o=r*Number(e.substr(1));if("M"===a){var i=new Date(t);return i.setMonth(i.getMonth()+o)}if("L"===a)return Math.log(Math.pow(10,t)+o)/Math.LN10;if("D"===a){var l="D2"===e?P:N,s=t+.01*r,c=_.roundUp(m(s,1),l,n);return Math.floor(s)+Math.log(y.round(Math.pow(10,c),1))/Math.LN10}throw"unrecognized dtick "+String(e)},T.tickFirst=function(t){var e=t.range[1]r:r>c;)c=T.tickIncrement(c,a,e);return c}if("L"===u)return Math.log(n((Math.pow(10,r)-o)/f)*f+o)/Math.LN10;if("D"===u){var d="D2"===a?P:N,h=_.roundUp(m(r,1),d,e);return Math.floor(r)+Math.log(y.round(Math.pow(10,h),1))/Math.LN10}throw"unrecognized dtick "+String(a)};var j=y.time.format("%Y"),D=y.time.format("%b %Y"),R=y.time.format("%b %-d"),I=y.time.format("%b %-d %Hh"),q=y.time.format("%H:%M"),F=y.time.format(":%S"),B=/%(\d?)f/g;T.tickText=function(t,e,n){function r(r){var a;return void 0===r?!0:n?"none"===r:(a={first:t._tmin,last:t._tmax}[r],"all"!==r&&e!==a)}var a,o,i=l(t,e),d="array"===t.tickmode,h=n||d;if(d&&Array.isArray(t.ticktext)){var p=Math.abs(t.range[1]-t.range[0])/1e4;for(o=0;o1&&en&&(M=90),a(u,M)}c._lastangle=M}return i(e),e+" done"}function s(){c._boundingBox=n.node().getBoundingClientRect()}var u=n.selectAll("g."+C).data(z,S);if(!c.showticklabels||!x(r))return u.remove(),void i(e);var f,d,p,m,b;"x"===v?(b="bottom"===F?1:-1,f=function(t){return t.dx+j*b},m=r+(P+N)*b,d=function(t){return t.dy+m+t.fontSize*("bottom"===F?1:-.5)},p=function(t){return x(t)&&0!==t&&180!==t?0>t*b?"end":"start":"middle"}):(b="right"===F?1:-1,d=function(t){return t.dy+t.fontSize/2-j*b},f=function(t){return t.dx+r+(P+N+(90===Math.abs(c.tickangle)?t.fontSize/2:0))*b},p=function(t){return x(t)&&90===Math.abs(t)?"middle":"right"===F?"start":"end"});var k=0,M=0,T=[];u.enter().append("g").classed(C,1).append("text").attr("text-anchor","middle").each(function(e){var n=y.select(this),r=t._promises.length;n.call(A.setPosition,f(e),d(e)).call(A.font,e.font,e.fontSize,e.fontColor).text(e.text).call(w.convertToTspans),r=t._promises[r],r?T.push(t._promises.pop().then(function(){a(n,c.tickangle)})):a(n,c.tickangle)}),u.exit().remove(),u.each(function(t){k=Math.max(k,t.fontSize)}),a(u,c._lastangle||c.tickangle);var L=_.syncOrAsync([o,l,s]);return L&&L.then&&t._promises.push(L),L}function i(e){if(!n){var r,a,o,i,l=L.getFromId(t,e),s=y.select(t).selectAll("g."+e+"tick"),c={selection:s,side:l.side},f=e.charAt(0),d=t._fullLayout._size,h=1.5,p=l.titlefont.size;if(s.size()){var g=y.select(s.node().parentNode).attr("transform").match(/translate\(([-\.\d]+),([-\.\d]+)\)/);g&&(c.offsetLeft=+g[1],c.offsetTop=+g[2])}"x"===f?(a="free"===l.anchor?{_offset:d.t+(1-(l.position||0))*d.h,_length:0}:L.getFromId(t,l.anchor),o=l._offset+l._length/2,i=a._offset+("top"===l.side?-10-p*(h+(l.showticklabels?1:0)):a._length+10+p*(h+(l.showticklabels?1.5:.5))),l.rangeslider&&l.rangeslider.visible&&l._boundingBox&&(i+=(u.height-u.margin.b-u.margin.t)*l.rangeslider.thickness+l._boundingBox.height),c.side||(c.side="bottom")):(a="free"===l.anchor?{_offset:d.l+(l.position||0)*d.w,_length:0}:L.getFromId(t,l.anchor),i=l._offset+l._length/2,o=a._offset+("right"===l.side?a._length+10+p*(h+(l.showticklabels?1:.5)):-10-p*(h+(l.showticklabels?.5:0))),r={rotate:"-90",offset:0},c.side||(c.side="left")),k.draw(t,e+"title",{propContainer:l,propName:l._name+".title",dfltName:f.toUpperCase()+" axis",avoid:c,transform:r,attributes:{x:o,y:i,"text-anchor":"middle"}})}}function l(t,e){return t.visible!==!0||t.xaxis+t.yaxis!==e?!1:b.Plots.traceIs(t,"bar")&&t.orientation==={x:"h",y:"v"}[v]?!0:t.fill&&t.fill.charAt(t.fill.length-1)===v}function s(e,n,a){var o=e.gridlayer,i=e.zerolinelayer,s=e["hidegrid"+v]?[]:H,u=c._gridpath||"M0,0"+("x"===v?"v":"h")+n._length,f=o.selectAll("path."+E).data(c.showgrid===!1?[]:s,S);if(f.enter().append("path").classed(E,1).classed("crisp",1).attr("d",u).each(function(t){c.zeroline&&("linear"===c.type||"-"===c.type)&&Math.abs(t.x)g;g++){var y=c.mirrors[i._id+d[g]];"ticks"!==y&&"labels"!==y||(f[g]=!0)}return void 0!==r[2]&&(f[2]=!0),f.forEach(function(t,e){var n=r[e],a=B[e];t&&x(n)&&(h+=p(n+N*a,a*c.ticklen))}),a(n,h),s(e,i,t),o(n,r[3])}}).filter(function(t){return t&&t.then});return U.length?Promise.all(U):0},T.swap=function(t,e){for(var n=h(t,e),r=0;r2*r}function u(t){for(var e,n=Math.max(1,(t.length-1)/1e3),r=0,a=0,o=0;o2*r}var f=t("fast-isnumeric"),d=t("tinycolor2").mix,h=t("../../lib"),p=t("../plots"),g=t("../../components/color/attributes").lightFraction,v=t("./layout_attributes"),m=t("./tick_value_defaults"),y=t("./tick_mark_defaults"),x=t("./tick_label_defaults"),b=t("./category_order_defaults"),_=t("./set_convert"),w=t("./ordered_categories"),k=t("./clean_datum"),M=t("./axis_ids");e.exports=function(t,e,n,a){function o(n,r){return h.coerce2(t,e,v,n,r)}var i=a.letter,l=a.font||{},s="Click to enter "+(a.title||i.toUpperCase()+" axis")+" title";a.name&&(e._name=a.name,e._id=M.name2id(a.name));var c=n("type");"-"===c&&(r(e,a.data),"-"===e.type?e.type="linear":c=t.type=e.type),_(e);var u=n("color"),p=u===t.color?u:l.color;n("title",s),h.coerceFont(n,"titlefont",{family:l.family,size:Math.round(1.2*l.size),color:p});var k=2===(t.range||[]).length&&f(t.range[0])&&f(t.range[1]),A=n("autorange",!k);A&&n("rangemode");var T=n("range",[-1,"x"===i?6:4]);T[0]===T[1]&&(e.range=[T[0]-1,T[0]+1]),h.noneOrAll(t.range,e.range,[0,1]),n("fixedrange"),m(t,e,n,c),x(t,e,n,c,a),y(t,e,n,a),b(t,e,n);var L=o("linecolor",u),z=o("linewidth"),S=n("showline",!!L||!!z);S||(delete e.linecolor,delete e.linewidth),(S||e.ticks)&&n("mirror");var C=o("gridcolor",d(u,a.bgColor,g).toRgbString()),E=o("gridwidth"),O=n("showgrid",a.showGrid||!!C||!!E);O||(delete e.gridcolor,delete e.gridwidth);var N=o("zerolinecolor",u),P=o("zerolinewidth"),j=n("zeroline",a.showGrid||!!N||!!P);return j||(delete e.zerolinecolor,delete e.zerolinewidth),e._initialCategories="category"===c?w(i,e.categoryorder,e.categoryarray,a.data):[],e}},{"../../components/color/attributes":19,"../../lib":99,"../plots":153,"./axis_ids":123,"./category_order_defaults":124,"./clean_datum":125,"./layout_attributes":130,"./ordered_categories":132,"./set_convert":135,"./tick_label_defaults":136,"./tick_mark_defaults":137,"./tick_value_defaults":138,"fast-isnumeric":12,tinycolor2:14}],123:[function(t,e,n){"use strict";function r(t,e,n){function r(t,n){for(var r=Object.keys(t),a=/^[xyz]axis[0-9]*/,o=[],i=0;i0;o&&(r="array");var i=n("categoryorder",r);"array"===i&&n("categoryarray"),o||"array"!==i||(e.categoryorder="trace")}}},{}],125:[function(t,e,n){"use strict";var r=t("fast-isnumeric"),a=t("../../lib");e.exports=function(t){try{if("object"==typeof t&&null!==t&&t.getTime)return a.ms2DateTime(t);if("string"!=typeof t&&!r(t))return"";t=t.toString().replace(/['"%,$# ]/g,"")}catch(e){a.error(e,t)}return t}},{"../../lib":99,"fast-isnumeric":12}],126:[function(t,e,n){"use strict";e.exports={idRegex:{x:/^x([2-9]|[1-9][0-9]+)?$/,y:/^y([2-9]|[1-9][0-9]+)?$/},attrRegex:{x:/^xaxis([2-9]|[1-9][0-9]+)?$/,y:/^yaxis([2-9]|[1-9][0-9]+)?$/},BADNUM:void 0,xAxisMatch:/^xaxis[0-9]*$/,yAxisMatch:/^yaxis[0-9]*$/,AX_ID_PATTERN:/^[xyz][0-9]*$/,AX_NAME_PATTERN:/^[xyz]axis[0-9]*$/,DBLCLICKDELAY:300,MINDRAG:8,MINSELECT:12,MINZOOM:20,DRAGGERSIZE:20,MAXDIST:20,YANGLE:60,HOVERARROWSIZE:6,HOVERTEXTPAD:3,HOVERFONTSIZE:13,HOVERFONT:"Arial, sans-serif",HOVERMINTIME:50,BENDPX:1.5,REDRAWDELAY:50}},{}],127:[function(t,e,n){"use strict";function r(t,e){var n,r=t.range[e],a=Math.abs(r-t.range[1-e]);return"date"===t.type?u.ms2DateTime(r,a):"log"===t.type?(n=Math.ceil(Math.max(0,-Math.log(a)/Math.LN10))+3,l.format("."+n+"g")(Math.pow(10,r))):(n=Math.floor(Math.log(Math.abs(r))/Math.LN10)-Math.floor(Math.log(a)/Math.LN10)+4,l.format("."+String(n)+"g")(r))}function a(t,e){return t?"nsew"===t?"pan"===e?"move":"crosshair":t.toLowerCase()+"-resize":"pointer"}function o(t){l.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}function i(t){var e=["lasso","select"];return-1!==e.indexOf(t)}var l=t("d3"),s=t("tinycolor2"),c=t("../../plotly"),u=t("../../lib"),f=t("../../lib/svg_text_utils"),d=t("../../components/color"),h=t("../../components/drawing"),p=t("../../lib/setcursor"),g=t("../../components/dragelement"),v=t("./axes"),m=t("./select"),y=t("./constants"),x=!0;e.exports=function(t,e,n,l,b,_,w,k){function M(t,e){for(var n=0;n.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("transform","translate("+pt+", "+gt+")").attr("d",st+"Z"),dt=ht.append("path").attr("class","zoombox-corners").style({fill:d.background,stroke:d.defaultLine,"stroke-width":1,opacity:0}).attr("transform","translate("+pt+", "+gt+")").attr("d","M0,0Z"),L();for(var o=0;o<$.length;o++)A($[o].range)}function L(){ht.selectAll(".select-outline").remove()}function z(t,e){var n=Math.max(0,Math.min(H,t+at)),r=Math.max(0,Math.min(V,e+ot)),a=Math.abs(n-at),o=Math.abs(r-ot),i=Math.floor(Math.min(o,a,G)/2);it.l=Math.min(at,n),it.r=Math.max(at,n),it.t=Math.min(ot,r),it.b=Math.max(ot,r),!J||oa?(ut="",it.r=it.l,it.t=it.b,dt.attr("d","M0,0Z")):(it.t=0,it.b=V,ut="x",dt.attr("d","M"+(it.l-.5)+","+(ot-G-.5)+"h-3v"+(2*G+1)+"h3ZM"+(it.r+.5)+","+(ot-G-.5)+"h3v"+(2*G+1)+"h-3Z")):!W||a.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),dt.transition().style("opacity",1).duration(200),ct=!0)}function S(t,e,n){var r,a,o;for(r=0;rzoom back out","long"),x=!1)))}function E(e,n){var a=1===(w+k).length;if(e)D();else if(2!==n||a){if(1===n&&a){var o=w?B[0]:F[0],i="s"===w||"w"===k?0:1,l=o._name+".range["+i+"]",s=r(o,i),u="left",d="middle";if(o.fixedrange)return;w?(d="n"===w?"top":"bottom","right"===o.side&&(u="right")):"e"===k&&(u="right"),et.call(f.makeEditable,null,{immediate:!0,background:I.paper_bgcolor,text:String(s),fill:o.tickfont?o.tickfont.color:"#444",horizontalAlign:u,verticalAlign:d}).on("edit",function(e){var n="category"===o.type?o.c2l(e):o.d2l(e);void 0!==n&&c.relayout(t,l,n)})}}else j()}function O(e){function n(t,e,n){if(!t.fixedrange){A(t.range);var r=t.range,a=r[0]+(r[1]-r[0])*e;t.range=[a+(r[0]-a)*n,a+(r[1]-a)*n]}}if(t._context.scrollZoom||I._enablescrollzoom){var r=t.querySelector(".plotly");if(!(r.scrollHeight-r.clientHeight>10||r.scrollWidth-r.clientWidth>10)){clearTimeout(mt);var a=-e.deltaY;if(isFinite(a)||(a=e.wheelDelta/10),!isFinite(a))return void u.log("Did not find wheel motion attributes: ",e);var o,i=Math.exp(-Math.min(Math.max(a,-20),20)/100),l=xt.draglayer.select(".nsewdrag").node().getBoundingClientRect(),s=(e.clientX-l.left)/l.width,c=vt[0]+vt[2]*s,f=(l.bottom-e.clientY)/l.height,d=vt[1]+vt[3]*(1-f);if(k){for(o=0;o=0?Math.min(t,.9):1/(1/Math.max(t,-.3)+3.222))}function a(t,e,n){for(var a=1-e,o=0,i=0;i0;r--)n.push(e);return n}function a(t,e){for(var n=[],r=0;rT;T++){var L=o[T],z=h[L];if(z)M[T]=w.getFromId(t,z.xaxis._id),A[T]=w.getFromId(t,z.yaxis._id);else{var S=i[L]._subplot;M[T]=S.xaxis,A[T]=S.yaxis}}var C=e.hovermode||i.hovermode;if(-1===["x","y","closest"].indexOf(C)||!t.calcdata||t.querySelector(".zoombox")||t._dragging)return _.unhoverRaw(t,e);var E,O,N,P,j,D,R,I,q,F,B,H,V=[],U=[];if(Array.isArray(e))for(C="array",N=0;NG||G>Y.width||0>Z||Z>Y.height)return _.unhoverRaw(t,e)}else G="xpx"in e?e.xpx:M[0]._length/2,Z="ypx"in e?e.ypx:A[0]._length/2;if(E="xval"in e?r(o,e.xval):a(M,G),O="yval"in e?r(o,e.yval):a(A,Z),!g(E[0])||!g(O[0]))return v.warn("Plotly.Fx.hover failed",e,t),_.unhoverRaw(t,e)}var X=1/0;for(P=0;P1||-1!==D.hoverinfo.indexOf("name")?D.name:void 0,index:!1,distance:Math.min(X,k.MAXDIST),color:x.defaultLine,x0:void 0,x1:void 0,y0:void 0,y1:void 0,xLabelVal:void 0,yLabelVal:void 0,zLabelVal:void 0,text:void 0},H=V.length,"array"===I){var Q=e[P];"pointNumber"in Q?(B.index=Q.pointNumber,I="closest"):(I="","xval"in Q&&(q=Q.xval,I="x"),"yval"in Q&&(F=Q.yval,I=I?"closest":"y"))}else q=E[R],F=O[R];if(D._module&&D._module.hoverPoints){var $=D._module.hoverPoints(B,q,F,I);if($)for(var W,J=0;J<$.length;J++)W=$[J],g(W.x0)&&g(W.y0)&&V.push(s(W,C))}else v.log("Unrecognized trace type in hover:",D);"closest"===C&&V.length>H&&(V.splice(0,H),X=V[0].distance)}if(0===V.length)return _.unhoverRaw(t,e);var K="y"===C&&U.length>1;V.sort(function(t,e){return t.distance-e.distance});var tt=x.combine(i.plot_bgcolor||x.background,i.paper_bgcolor),et={hovermode:C,rotateLabels:K,bgColor:tt,container:i._hoverlayer,outerContainer:i._paperdiv},nt=c(V,et);u(V,K?"xa":"ya"),f(nt,K);var rt=t._hoverdata,at=[];for(N=0;N128?"#000":x.background;if(t.name&&void 0===t.zLabelVal){var u=document.createElement("p");u.innerHTML=t.name,n=u.textContent||"",n.length>15&&(n=n.substr(0,12)+"...")}void 0!==t.extraText&&(r+=t.extraText),void 0!==t.zLabel?(void 0!==t.xLabel&&(r+="x: "+t.xLabel+"
"),void 0!==t.yLabel&&(r+="y: "+t.yLabel+"
"),r+=(r?"z: ":"")+t.zLabel):A&&t[a+"Label"]===g?r=t[("x"===a?"y":"x")+"Label"]||"":void 0===t.xLabel?void 0!==t.yLabel&&(r=t.yLabel):r=void 0===t.yLabel?t.xLabel:"("+t.xLabel+", "+t.yLabel+")",t.text&&!Array.isArray(t.text)&&(r+=(r?"
":"")+t.text),""===r&&(""===n&&e.remove(),r=n);var f=e.select("text.nums").style("fill",c).call(b.setPosition,0,0).text(r).attr("data-notex",1).call(y.convertToTspans);f.selectAll("tspan.line").call(b.setPosition,0,0);var d=e.select("text.name"),v=0;n&&n!==r?(d.style("fill",s).text(n).call(b.setPosition,0,0).attr("data-notex",1).call(y.convertToTspans),d.selectAll("tspan.line").call(b.setPosition,0,0),v=d.node().getBoundingClientRect().width+2*O):(d.remove(),e.select("rect").remove()),e.select("path").style({fill:s,stroke:c});var m,k,L=f.node().getBoundingClientRect(),z=t.xa._offset+(t.x0+t.x1)/2,S=t.ya._offset+(t.y0+t.y1)/2,C=Math.abs(t.x1-t.x0),N=Math.abs(t.y1-t.y0),P=L.width+E+O+v;t.ty0=_-L.top,t.bx=L.width+2*O,t.by=L.height+2*O,t.anchor="start",t.txwidth=L.width,t.tx2width=v,t.offset=0,o?(t.pos=z,m=M>=S+N/2+P,k=S-N/2-P>=0,"top"!==t.idealAlign&&m||!k?m?(S+=N/2,t.anchor="start"):t.anchor="middle":(S-=N/2,t.anchor="end")):(t.pos=S,m=w>=z+C/2+P,k=z-C/2-P>=0,"left"!==t.idealAlign&&m||!k?m?(z+=C/2,t.anchor="start"):t.anchor="middle":(z-=C/2,t.anchor="end")),f.attr("text-anchor",t.anchor),v&&d.attr("text-anchor",t.anchor),e.attr("transform","translate("+z+","+S+")"+(o?"rotate("+T+")":""))}),S}function u(t,e){function n(t){var e=t[0],n=t[t.length-1];if(a=e.pmin-e.pos-e.dp+e.size,o=n.pos+n.dp+n.size-e.pmax,a>.01){for(l=t.length-1;l>=0;l--)t[l].dp+=a;r=!1}if(!(.01>o)){if(-.01>a){for(l=t.length-1;l>=0;l--)t[l].dp-=o;r=!1}if(r){var c=0;for(i=0;ie.pmax&&c++;for(i=t.length-1;i>=0&&!(0>=c);i--)s=t[i],s.pos>e.pmax-1&&(s.del=!0,c--);for(i=0;i=c);i++)if(s=t[i],s.pos=0;l--)t[l].dp-=o;for(i=t.length-1;i>=0&&!(0>=c);i--)s=t[i],s.pos+s.dp+s.size>e.pmax&&(s.del=!0,c--)}}}for(var r,a,o,i,l,s,c,u=0,f=t.map(function(t,n){var r=t[e];return[{i:n,dp:0,pos:t.pos,posref:t.posref,size:t.by*("x"===r._id.charAt(0)?z:1)/2,pmin:r._offset,pmax:r._offset+r._length}]}).sort(function(t,e){return t[0].posref-e[0].posref});!r&&u<=t.length;){for(u++,r=!0,i=0;i.01&&p.pmin===g.pmin&&p.pmax===g.pmax){for(l=h.length-1;l>=0;l--)h[l].dp+=a;for(d.push.apply(d,h),f.splice(i+1,1),c=0,l=d.length-1;l>=0;l--)c+=d[l].dp;for(o=c/d.length,l=d.length-1;l>=0;l--)d[l].dp-=o;r=!1}else i++}f.forEach(n)}for(i=f.length-1;i>=0;i--){var v=f[i];for(l=v.length-1;l>=0;l--){var m=v[l],y=t[m.i];y.offset=m.dp,y.del=m.del}}}function f(t,e){t.each(function(t){var n=h.select(this);if(t.del)return void n.remove();var r="end"===t.anchor?-1:1,a=n.select("text.nums"),o={start:1,end:-1,middle:0}[t.anchor],i=o*(E+O),l=i+o*(t.txwidth+O),s=0,c=t.offset;"middle"===t.anchor&&(i-=t.tx2width/2,l-=t.tx2width/2),e&&(c*=-C,s=t.offset*S),n.select("path").attr("d","middle"===t.anchor?"M-"+t.bx/2+",-"+t.by/2+"h"+t.bx+"v"+t.by+"h-"+t.bx+"Z":"M0,0L"+(r*E+s)+","+(E+c)+"v"+(t.by/2-E)+"h"+r*t.bx+"v-"+t.by+"H"+(r*E+s)+"V"+(c-E)+"Z"),a.call(b.setPosition,i+s,c+t.ty0-t.by/2+O).selectAll("tspan.line").attr({x:a.attr("x"),y:a.attr("y")}),t.tx2width&&(n.select("text.name, text.name tspan.line").call(b.setPosition,l+o*O+s,c+t.ty0-t.by/2+O),n.select("rect").call(b.setRect,l+(o-1)*t.tx2width/2+s,c-t.by/2-1,t.tx2width,t.by+2))})}function d(t,e,n){if(!e.target)return!1;if(!n||n.length!==t._hoverdata.length)return!0;for(var r=n.length-1;r>=0;r--){var a=n[r],o=t._hoverdata[r];if(a.curveNumber!==o.curveNumber||String(a.pointNumber)!==String(o.pointNumber))return!0}return!1}var h=t("d3"),p=t("tinycolor2"),g=t("fast-isnumeric"),v=t("../../lib"),m=t("../../lib/events"),y=t("../../lib/svg_text_utils"),x=t("../../components/color"),b=t("../../components/drawing"),_=t("../../components/dragelement"),w=t("./axes"),k=t("./constants"),M=t("./dragbox"),A=e.exports={};A.unhover=_.unhover,A.layoutAttributes={dragmode:{valType:"enumerated",values:["zoom","pan","select","lasso","orbit","turntable"],dflt:"zoom"},hovermode:{valType:"enumerated",values:["x","y","closest",!1]}},A.supplyLayoutDefaults=function(t,e,n){function r(n,r){return v.coerce(t,e,A.layoutAttributes,n,r)}r("dragmode");var a;if(e._has("cartesian")){var o=e._isHoriz=A.isHoriz(n);a=o?"y":"x"}else a="closest";r("hovermode",a)},A.isHoriz=function(t){for(var e=!0,n=0;nt._lastHoverTime+k.HOVERMINTIME?(i(t,e,n),void(t._lastHoverTime=Date.now())):void(t._hoverTimer=setTimeout(function(){i(t,e,n),t._lastHoverTime=Date.now(),t._hoverTimer=void 0},k.HOVERMINTIME))},A.getDistanceFunction=function(t,e,n,r){return"closest"===t?r||o(e,n):"x"===t?e:n},A.getClosest=function(t,e,n){if(n.index!==!1)n.index>=0&&n.indext*e||0===t?k.MAXDIST*(.6-.3/Math.max(3,Math.abs(t-e))):1/0}},{"../../components/color":20,"../../components/dragelement":41,"../../components/drawing":43,"../../lib":99,"../../lib/events":95,"../../lib/svg_text_utils":110,"./axes":121,"./constants":126,"./dragbox":127,d3:10,"fast-isnumeric":12,tinycolor2:14}],129:[function(t,e,n){"use strict";var r=t("../plots"),a=t("./constants");n.name="cartesian",n.attr=["xaxis","yaxis"],n.idRoot=["x","y"],n.idRegex=a.idRegex,n.attrRegex=a.attrRegex,n.attributes=t("./attributes"),n.plot=function(t){function e(t,e){for(var n=[],r=0;rf[1]-.01&&(e.domain=[0,1]),a.noneOrAll(t.domain,e.domain,[0,1])}return e}},{"../../lib":99,"fast-isnumeric":12}],134:[function(t,e,n){"use strict";function r(t){return t._id}var a=t("../../lib/polygon"),o=t("../../components/color"),i=t("./axes"),l=t("./constants"),s=a.filter,c=a.tester,u=l.MINSELECT;e.exports=function(t,e,n,a,f){function d(t){var e="y"===t._id.charAt(0)?1:0;return function(n){return t.p2d(n[e])}}function h(t,e){return t-e}var p,g=a.gd._fullLayout._zoomlayer,v=a.element.getBoundingClientRect(),m=a.plotinfo.x()._offset,y=a.plotinfo.y()._offset,x=e-v.left,b=n-v.top,_=x,w=b,k="M"+x+","+b,M=a.xaxes[0]._length,A=a.yaxes[0]._length,T=a.xaxes.map(r),L=a.yaxes.map(r),z=a.xaxes.concat(a.yaxes);"lasso"===f&&(p=s([[x,b]],l.BENDPX));var S=g.selectAll("path.select-outline").data([1,2]);S.enter().append("path").attr("class",function(t){return"select-outline select-outline-"+t}).attr("transform","translate("+m+", "+y+")").attr("d",k+"Z");var C,E,O,N,P,j=g.append("path").attr("class","zoombox-corners").style({fill:o.background,stroke:o.defaultLine,"stroke-width":1}).attr("transform","translate("+m+", "+y+")").attr("d","M0,0Z"),D=[],R=a.gd,I=[];for(C=0;C0)return Math.log(e)/Math.LN10;if(0>=e&&n&&t.range&&2===t.range.length){var r=t.range[0],a=t.range[1];return.5*(r+a-3*u*Math.abs(r-a))}return i.BADNUM}function n(t){return Math.pow(10,t)}function c(t){return a(t)?Number(t):i.BADNUM}var u=10;if(t.c2l="log"===t.type?e:c,t.l2c="log"===t.type?n:c,t.l2d=function(e){return t.c2d(t.l2c(e))},t.p2d=function(e){return t.l2d(t.p2l(e))},t.setScale=function(){var e,n=t._gd._fullLayout._size;if(t._categories||(t._categories=[]),t.overlaying){var r=s.getFromId(t._gd,t.overlaying);t.domain=r.domain}for(t.range&&2===t.range.length&&t.range[0]!==t.range[1]||(t.range=[-1,1]),e=0;2>e;e++)a(t.range[e])||(t.range[e]=a(t.range[1-e])?t.range[1-e]*(e?10:.1):e?1:-1),t.range[e]<-(Number.MAX_VALUE/2)?t.range[e]=-(Number.MAX_VALUE/2):t.range[e]>Number.MAX_VALUE/2&&(t.range[e]=Number.MAX_VALUE/2);if("y"===t._id.charAt(0)?(t._offset=n.t+(1-t.domain[1])*n.h,t._length=n.h*(t.domain[1]-t.domain[0]),t._m=t._length/(t.range[0]-t.range[1]),t._b=-t._m*t.range[1]):(t._offset=n.l+t.domain[0]*n.w,t._length=n.w*(t.domain[1]-t.domain[0]),t._m=t._length/(t.range[1]-t.range[0]),t._b=-t._m*t.range[0]),!isFinite(t._m)||!isFinite(t._b))throw o.notifier("Something went wrong with axis scaling","long"),t._gd._replotting=!1,new Error("axis scaling")},t.l2p=function(e){return a(e)?r.round(t._b+t._m*e,2):i.BADNUM},t.p2l=function(e){return(e-t._b)/t._m},t.c2p=function(e,n){return t.l2p(t.c2l(e,n))},t.p2c=function(e){return t.l2c(t.p2l(e))},-1!==["linear","log","-"].indexOf(t.type))t.c2d=c,t.d2c=function(t){return t=l(t),a(t)?Number(t):i.BADNUM},t.d2l=function(e,n){return"log"===t.type?t.c2l(t.d2c(e),n):t.d2c(e)};else if("date"===t.type){if(t.c2d=function(t){return a(t)?o.ms2DateTime(t):i.BADNUM},t.d2c=function(t){return a(t)?Number(t):o.dateTime2ms(t)},t.d2l=t.d2c,t.range&&t.range.length>1)try{var f=t.range.map(o.dateTime2ms);!a(t.range[0])&&a(f[0])&&(t.range[0]=f[0]),!a(t.range[1])&&a(f[1])&&(t.range[1]=f[1])}catch(d){o.error(d,t.range)}}else"category"===t.type&&(t.c2d=function(e){return t._categories[Math.round(e)]},t.d2c=function(e){null!==e&&void 0!==e&&-1===t._categories.indexOf(e)&&t._categories.push(e);var n=t._categories.indexOf(e);return-1===n?i.BADNUM:n},t.d2l=t.d2c);t.makeCalcdata=function(e,n){var r,a,o;if(n in e)for(r=e[n],a=new Array(r.length),o=0;or?"0":"1.0"}var n=this.framework,r=n.select("g.choroplethlayer"),a=n.select("g.scattergeolayer"),o=this.projection,i=this.path,l=this.clipAngle;n.selectAll("path.basepath").attr("d",i),n.selectAll("path.graticulepath").attr("d",i),r.selectAll("path.choroplethlocation").attr("d",i),r.selectAll("path.basepath").attr("d",i),a.selectAll("path.js-line").attr("d",i),null!==l?(a.selectAll("path.point").style("opacity",e).attr("transform",t),a.selectAll("text").style("opacity",e).attr("transform",t)):(a.selectAll("path.point").attr("transform",t),a.selectAll("text").attr("transform",t))}},{"../../components/color":20,"../../components/drawing":43,"../../constants/xmlns_namespaces":89,"../../lib/filter_visible":97,"../../lib/topojson_utils":111,"../../plots/cartesian/axes":121,"./constants":140,"./projections":148,"./set_scale":149,"./zoom":150,"./zoom_reset":151,d3:10,topojson:15}],142:[function(t,e,n){"use strict";var r=t("./geo"),a=t("../../plots/plots");n.name="geo",n.attr="geo",n.idRoot="geo",n.idRegex=/^geo([2-9]|[1-9][0-9]+)?$/,n.attrRegex=/^geo([2-9]|[1-9][0-9]+)?$/,n.attributes=t("./layout/attributes"),n.layoutAttributes=t("./layout/layout_attributes"),n.supplyLayoutDefaults=t("./layout/defaults"),n.plot=function(t){var e=t._fullLayout,n=t._fullData,o=a.getSubplotIds(e,"geo");void 0===window.PlotlyGeoAssets&&(window.PlotlyGeoAssets={topojson:{}});for(var i=0;i=r}function o(t,e){for(var n=e[0],r=e[1],a=!1,o=0,i=t.length,l=i-1;i>o;l=o++){var s=t[o],c=s[0],u=s[1],f=t[l],d=f[0],h=f[1];u>r^h>r&&(d-c)*(r-u)/(h-u)+c>n&&(a=!a)}return a}function i(t){return t?t/Math.sin(t):1}function l(t){return t>1?O:-1>t?-O:Math.asin(t)}function s(t){return t>1?0:-1>t?E:Math.acos(t)}function c(t,e){var n=(2+O)*Math.sin(e);e/=2;for(var r=0,a=1/0;10>r&&Math.abs(a)>S;r++){var o=Math.cos(e);e-=a=(e+Math.sin(e)*(o+2)-n)/(2*o*(1+o))}return[2/Math.sqrt(E*(4+E))*t*(1+Math.cos(e)),2*Math.sqrt(E/(4+E))*Math.sin(e)]}function u(t,e){function n(n,r){var a=R(n/e,r);return a[0]*=t,a}return arguments.length<2&&(e=t),1===e?R:e===1/0?d:(n.invert=function(n,r){var a=R.invert(n/t,r);return a[0]*=e,a},n)}function f(){var t=2,e=D(u),n=e(t);return n.coefficient=function(n){return arguments.length?e(t=+n):t},n}function d(t,e){return[t*Math.cos(e)/Math.cos(e/=2),2*Math.sin(e)]}function h(t,e){return[3*t/(2*E)*Math.sqrt(E*E/3-e*e),e]}function p(t,e){return[t,1.25*Math.log(Math.tan(E/4+.4*e))]}function g(t){return function(e){var n,r=t*Math.sin(e),a=30;do e-=n=(e+Math.sin(e)-r)/(1+Math.cos(e));while(Math.abs(n)>S&&--a>0);return e/2}}function v(t,e,n){function r(n,r){return[t*n*Math.cos(r=a(r)),e*Math.sin(r)]}var a=g(n);return r.invert=function(r,a){var o=l(a/e);return[r/(t*Math.cos(o)),l((2*o+Math.sin(2*o))/n)]},r}function m(t,e){var n=e*e,r=n*n;return[t*(.8707-.131979*n+r*(-.013791+r*(.003971*n-.001529*r))),e*(1.007226+n*(.015085+r*(-.044475+.028874*n-.005916*r)))]}function y(t,e){var n,r=Math.min(18,36*Math.abs(e)/E),a=Math.floor(r),o=r-a,i=(n=q[a])[0],l=n[1],s=(n=q[++a])[0],c=n[1],u=(n=q[Math.min(19,++a)])[0],f=n[1];return[t*(s+o*(u-i)/2+o*o*(u-2*s+i)/2),(e>0?O:-O)*(c+o*(f-l)/2+o*o*(f-2*c+l)/2)]}function x(t,e){return[t*Math.cos(e),e]}function b(t,e){var n=Math.cos(e),r=i(s(n*Math.cos(t/=2)));return[2*n*Math.sin(t)*r,Math.sin(e)*r]}function _(t,e){var n=b(t,e);return[(n[0]+t/O)/2,(n[1]+e)/2]}t.geo.project=function(t,e){var r=e.stream;if(!r)throw new Error("not yet supported");return(t&&w.hasOwnProperty(t.type)?w[t.type]:n)(t,r)};var w={Feature:e,FeatureCollection:function(t,n){return{type:"FeatureCollection",features:t.features.map(function(t){return e(t,n)})}}},k=[],M=[],A={point:function(t,e){k.push([t,e])},result:function(){var t=k.length?k.length<2?{type:"Point",coordinates:k[0]}:{type:"MultiPoint",coordinates:k}:null;return k=[],t}},T={lineStart:r,point:function(t,e){k.push([t,e])},lineEnd:function(){k.length&&(M.push(k),k=[])},result:function(){var t=M.length?M.length<2?{type:"LineString",coordinates:M[0]}:{type:"MultiLineString",coordinates:M}:null;return M=[],t}},L={polygonStart:r,lineStart:r,point:function(t,e){k.push([t,e])},lineEnd:function(){var t=k.length;if(t){do k.push(k[0].slice());while(++t<4);M.push(k),k=[]}},polygonEnd:r,result:function(){if(!M.length)return null;var t=[],e=[];return M.forEach(function(n){a(n)?t.push([n]):e.push(n)}),e.forEach(function(e){var n=e[0];t.some(function(t){return o(t[0],n)?(t.push(e),!0):void 0})||t.push([e])}),M=[],t.length?t.length>1?{type:"MultiPolygon",coordinates:t}:{type:"Polygon",coordinates:t[0]}:null}},z={Point:A,MultiPoint:A,LineString:T,MultiLineString:T,Polygon:L,MultiPolygon:L,Sphere:L},S=1e-6,C=S*S,E=Math.PI,O=E/2,N=(Math.sqrt(E),E/180),P=180/E,j=t.geo.projection,D=t.geo.projectionMutator;t.geo.interrupt=function(e){function n(t,n){for(var r=0>n?-1:1,a=s[+(0>n)],o=0,i=a.length-1;i>o&&t>a[o][2][0];++o);var l=e(t-a[o][1][0],n);return l[0]+=e(a[o][1][0],r*n>r*a[o][0][1]?a[o][0][1]:n)[0],l}function r(){l=s.map(function(t){return t.map(function(t){var n,r=e(t[0][0],t[0][1])[0],a=e(t[2][0],t[2][1])[0],o=e(t[1][0],t[0][1])[1],i=e(t[1][0],t[1][1])[1];return o>i&&(n=o,o=i,i=n),[[r,o],[a,i]]})})}function a(){for(var e=1e-6,n=[],r=0,a=s[0].length;a>r;++r){var i=s[0][r],l=180*i[0][0]/E,c=180*i[0][1]/E,u=180*i[1][1]/E,f=180*i[2][0]/E,d=180*i[2][1]/E;n.push(o([[l+e,c+e],[l+e,u-e],[f-e,u-e],[f-e,d+e]],30))}for(var r=s[1].length-1;r>=0;--r){var i=s[1][r],l=180*i[0][0]/E,c=180*i[0][1]/E,u=180*i[1][1]/E,f=180*i[2][0]/E,d=180*i[2][1]/E;n.push(o([[f-e,d-e],[f-e,u+e],[l+e,u+e],[l+e,c-e]],30))}return{type:"Polygon",coordinates:[t.merge(n)]}}function o(t,e){for(var n,r,a,o=-1,i=t.length,l=t[0],s=[];++oc;++c)s.push([l[0]+c*r,l[1]+c*a]);l=n}return s.push(n),s}function i(t,e){return Math.abs(t[0]-e[0])r)],o=s[+(0>r)],c=0,u=a.length;u>c;++c){var f=a[c];if(f[0][0]<=t&&tS&&--a>0);return[t/(.8707+(o=r*r)*(-.131979+o*(-.013791+o*o*o*(.003971-.001529*o)))),r]},(t.geo.naturalEarth=function(){return j(m)}).raw=m;var q=[[.9986,-.062],[1,0],[.9986,.062],[.9954,.124],[.99,.186],[.9822,.248],[.973,.31],[.96,.372],[.9427,.434],[.9216,.4958],[.8962,.5571],[.8679,.6176],[.835,.6769],[.7986,.7346],[.7597,.7903],[.7186,.8435],[.6732,.8936],[.6213,.9394],[.5722,.9761],[.5322,1]];q.forEach(function(t){t[1]*=1.0144}),y.invert=function(t,e){var n=e/O,r=90*n,a=Math.min(18,Math.abs(r/5)),o=Math.max(0,Math.floor(a));do{var i=q[o][1],l=q[o+1][1],s=q[Math.min(19,o+2)][1],c=s-i,u=s-2*l+i,f=2*(Math.abs(n)-l)/c,d=u/c,h=f*(1-d*f*(1-2*d*f));if(h>=0||1===o){r=(e>=0?5:-5)*(h+a);var p,g=50;do a=Math.min(18,Math.abs(r)/5),o=Math.floor(a),h=a-o,i=q[o][1],l=q[o+1][1],s=q[Math.min(19,o+2)][1],r-=(p=(e>=0?O:-O)*(l+h*(s-i)/2+h*h*(s-2*l+i)/2)-e)*P;while(Math.abs(p)>C&&--g>0);break}}while(--o>=0);var v=q[o][0],m=q[o+1][0],y=q[Math.min(19,o+2)][0];return[t/(m+h*(y-v)/2+h*h*(y-2*m+v)/2),r*N]},(t.geo.robinson=function(){return j(y)}).raw=y,x.invert=function(t,e){return[t/Math.cos(e),e]},(t.geo.sinusoidal=function(){return j(x)}).raw=x,b.invert=function(t,e){if(!(t*t+4*e*e>E*E+S)){var n=t,r=e,a=25;do{var o,i=Math.sin(n),l=Math.sin(n/2),c=Math.cos(n/2),u=Math.sin(r),f=Math.cos(r),d=Math.sin(2*r),h=u*u,p=f*f,g=l*l,v=1-p*c*c,m=v?s(f*c)*Math.sqrt(o=1/v):o=0,y=2*m*f*l-t,x=m*u-e,b=o*(p*g+m*f*c*h),_=o*(.5*i*d-2*m*u*l),w=.25*o*(d*l-m*u*p*i),k=o*(h*c+m*g*f),M=_*w-k*b;if(!M)break;var A=(x*_-y*k)/M,T=(y*w-x*b)/M;n-=A,r-=T}while((Math.abs(A)>S||Math.abs(T)>S)&&--a>0);return[n,r]}},(t.geo.aitoff=function(){return j(b)}).raw=b,_.invert=function(t,e){var n=t,r=e,a=25;do{var o,i=Math.cos(r),l=Math.sin(r),c=Math.sin(2*r),u=l*l,f=i*i,d=Math.sin(n),h=Math.cos(n/2),p=Math.sin(n/2),g=p*p,v=1-f*h*h,m=v?s(i*h)*Math.sqrt(o=1/v):o=0,y=.5*(2*m*i*p+n/O)-t,x=.5*(m*l+r)-e,b=.5*o*(f*g+m*i*h*u)+.5/O,_=o*(d*c/4-m*l*p),w=.125*o*(c*p-m*l*f*d),k=.5*o*(u*h+m*g*i)+.5,M=_*w-k*b,A=(x*_-y*k)/M,T=(y*w-x*b)/M;n-=A,r-=T}while((Math.abs(A)>S||Math.abs(T)>S)&&--a>0);return[n,r]},(t.geo.winkel3=function(){return j(_)}).raw=_}e.exports=r},{}],149:[function(t,e,n){"use strict";function r(t,e){var n=t.projection,r=t.lonaxis,i=t.lataxis,s=t.domain,c=t.framewidth||0,u=e.w*(s.x[1]-s.x[0]),f=e.h*(s.y[1]-s.y[0]),d=r.range[0]+l,h=r.range[1]-l,p=i.range[0]+l,g=i.range[1]-l,v=r._fullRange[0]+l,m=r._fullRange[1]-l,y=i._fullRange[0]+l,x=i._fullRange[1]-l;n._translate0=[e.l+u/2,e.t+f/2];var b=h-d,_=g-p,w=[d+b/2,p+_/2],k=n._rotate;n._center=[w[0]+k[0],w[1]+k[1]];var M=function(e){function r(t){return Math.min(_*u/(t[1][0]-t[0][0]),_*f/(t[1][1]-t[0][1]))}var i,l,s,b,_=e.scale(),w=n._translate0,k=a(d,p,h,g),M=a(v,y,m,x);s=o(e,k),i=r(s),b=o(e,M),n._fullScale=r(b),e.scale(i),s=o(e,k),l=[w[0]-s[0][0]+c,w[1]-s[0][1]+c],n._translate=l,e.translate(l),s=o(e,k),t._isAlbersUsa||e.clipExtent(s),i=n.scale*i,n._scale=i,t._width=Math.round(s[1][0])+c,t._height=Math.round(s[1][1])+c,t._marginX=(u-Math.round(s[1][0]))/2,t._marginY=(f-Math.round(s[1][1]))/2};return M}function a(t,e,n,r){var a=(n-t)/4;return{type:"Polygon",coordinates:[[[t,e],[t,r],[t+a,r],[t+2*a,r],[t+3*a,r],[n,r],[n,e],[n-a,e],[n-2*a,e],[n-3*a,e],[t,e]]]}}function o(t,e){return i.geo.path().projection(t).bounds(e)}var i=t("d3"),l=t("./constants").clipPad;e.exports=r},{"./constants":140,d3:10}],150:[function(t,e,n){"use strict";function r(t,e){var n;return(n=e._isScoped?o:e._clipAngle?l:i)(t,e.projection)}function a(t,e){var n=e._fullScale;return _.behavior.zoom().translate(t.translate()).scale(t.scale()).scaleExtent([.5*n,100*n])}function o(t,e){function n(){_.select(this).style(M)}function r(){i.scale(_.event.scale).translate(_.event.translate),t.render()}function o(){_.select(this).style(A)}var i=t.projection,l=a(i,e);return l.on("zoomstart",n).on("zoom",r).on("zoomend",o),l}function i(t,e){function n(t){return v.invert(t)}function r(t){var e=v(n(t));return Math.abs(e[0]-t[0])>y||Math.abs(e[1]-t[1])>y}function o(){_.select(this).style(M),s=_.mouse(this),c=v.rotate(),u=v.translate(),f=c,d=n(s)}function i(){return h=_.mouse(this),r(s)?(m.scale(v.scale()),void m.translate(v.translate())):(v.scale(_.event.scale),v.translate([u[0],_.event.translate[1]]),d?n(h)&&(g=n(h),p=[f[0]+(g[0]-d[0]),c[1],c[2]],v.rotate(p),f=p):(s=h,d=n(s)),void t.render())}function l(){_.select(this).style(A)}var s,c,u,f,d,h,p,g,v=t.projection,m=a(v,e),y=2;return m.on("zoomstart",o).on("zoom",i).on("zoomend",l),m}function l(t,e){function n(t){m++||t({type:"zoomstart"})}function r(t){t({type:"zoom"})}function o(t){--m||t({type:"zoomend"})}var i,l=t.projection,h={r:l.rotate(),k:l.scale()},p=a(l,e),g=b(p,"zoomstart","zoom","zoomend"),m=0,y=p.on;return p.on("zoomstart",function(){_.select(this).style(M);var t=_.mouse(this),e=l.rotate(),a=e,o=l.translate(),m=c(e);i=s(l,t),y.call(p,"zoom",function(){var n=_.mouse(this);if(l.scale(h.k=_.event.scale),i){if(s(l,n)){l.rotate(e).translate(o);var c=s(l,n),p=f(i,c),y=v(u(m,p)),x=h.r=d(y,i,a);isFinite(x[0])&&isFinite(x[1])&&isFinite(x[2])||(x=a),l.rotate(x),a=x}}else t=n,i=s(l,t);r(g.of(this,arguments))}),n(g.of(this,arguments))}).on("zoomend",function(){_.select(this).style(A),y.call(p,"zoom",null),o(g.of(this,arguments))}).on("zoom.redraw",function(){t.render()}),_.rebind(p,g,"on")}function s(t,e){var n=t.invert(e);return n&&isFinite(n[0])&&isFinite(n[1])&&m(n)}function c(t){var e=.5*t[0]*w,n=.5*t[1]*w,r=.5*t[2]*w,a=Math.sin(e),o=Math.cos(e),i=Math.sin(n),l=Math.cos(n),s=Math.sin(r),c=Math.cos(r);return[o*l*c+a*i*s,a*l*c-o*i*s,o*i*c+a*l*s,o*l*s-a*i*c]}function u(t,e){var n=t[0],r=t[1],a=t[2],o=t[3],i=e[0],l=e[1],s=e[2],c=e[3];return[n*i-r*l-a*s-o*c,n*l+r*i+a*c-o*s,n*s-r*c+a*i+o*l,n*c+r*s-a*l+o*i]}function f(t,e){if(t&&e){var n=x(t,e),r=Math.sqrt(y(n,n)),a=.5*Math.acos(Math.max(-1,Math.min(1,y(t,e)))),o=Math.sin(a)/r;return r&&[Math.cos(a),n[2]*o,-n[1]*o,n[0]*o]}}function d(t,e,n){var r=g(e,2,t[0]);r=g(r,1,t[1]),r=g(r,0,t[2]-n[2]);var a,o,i=e[0],l=e[1],s=e[2],c=r[0],u=r[1],f=r[2],d=Math.atan2(l,i)*k,p=Math.sqrt(i*i+l*l);Math.abs(u)>p?(o=(u>0?90:-90)-d,a=0):(o=Math.asin(u/p)*k-d,a=Math.sqrt(p*p-u*u));var v=180-o-2*d,m=(Math.atan2(f,c)-Math.atan2(s,a))*k,y=(Math.atan2(f,c)-Math.atan2(s,-a))*k,x=h(n[0],n[1],o,m),b=h(n[0],n[1],v,y);return b>=x?[o,m,n[2]]:[v,y,n[2]]}function h(t,e,n,r){var a=p(n-t),o=p(r-e);return Math.sqrt(a*a+o*o)}function p(t){return(t%360+540)%360-180}function g(t,e,n){var r=n*w,a=t.slice(),o=0===e?1:0,i=2===e?1:2,l=Math.cos(r),s=Math.sin(r);return a[o]=t[o]*l-t[i]*s,a[i]=t[i]*l+t[o]*s,a}function v(t){return[Math.atan2(2*(t[0]*t[1]+t[2]*t[3]),1-2*(t[1]*t[1]+t[2]*t[2]))*k,Math.asin(Math.max(-1,Math.min(1,2*(t[0]*t[2]-t[3]*t[1]))))*k,Math.atan2(2*(t[0]*t[3]+t[1]*t[2]),1-2*(t[2]*t[2]+t[3]*t[3]))*k]}function m(t){var e=t[0]*w,n=t[1]*w,r=Math.cos(n);return[r*Math.cos(e),r*Math.sin(e),Math.sin(n)]}function y(t,e){for(var n=0,r=0,a=t.length;a>r;++r)n+=t[r]*e[r];return n}function x(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function b(t){for(var e=0,n=arguments.length,r=[];++e=e.width-20?(o["text-anchor"]="start",o.x=5):(o["text-anchor"]="end",o.x=e._paper.attr("width")-7),n.attr(o);var i=n.select(".js-link-to-tool"),l=n.select(".js-link-spacer"),c=n.select(".js-sourcelinks");t._context.showSources&&t._context.showSources(t),t._context.showLink&&a(t,i),l.text(i.text()&&c.text()?" - ":"")},h.sendDataToCloud=function(t){t.emit("plotly_beforeexport");var e=window.PLOTLYENV&&window.PLOTLYENV.BASE_URL||"https://plot.ly",n=s.select(t).append("div").attr("id","hiddenform").style("display","none"),r=n.append("form").attr({action:e+"/external",method:"post",target:"_blank"}),a=r.append("input").attr({type:"text",name:"data"});return a.node().value=h.graphJson(t,!1,"keepdata"),r.node().submit(),n.remove(),t.emit("plotly_afterexport"),!1},h.supplyDefaults=function(t){var e,n=t._fullLayout||{},r=t._fullLayout={},a=t.layout||{},i=t._fullData||[],l=t._fullData=[],s=t.data||[];h.supplyLayoutGlobalDefaults(a,r),r._dataLength=s.length,h.supplyDataDefaults(s,l,r),r._has=h._hasPlotType.bind(r);var c=r._modules;for(e=0;eo&&(e=(n-1)/(a.l+a.r),a.l=Math.floor(e*a.l),a.r=Math.floor(e*a.r)),0>i&&(e=(r-1)/(a.t+a.b),a.t=Math.floor(e*a.t),a.b=Math.floor(e*a.b))}},h.autoMargin=function(t,e,n){var r=t._fullLayout;if(r._pushmargin||(r._pushmargin={}),r.margin.autoexpand!==!1){if(n){var a=void 0===n.pad?12:n.pad;n.l+n.r>.5*r.width&&(n.l=n.r=0),n.b+n.t>.5*r.height&&(n.b=n.t=0),r._pushmargin[e]={l:{val:n.x,size:n.l+a},r:{val:n.x,size:n.r+a},b:{val:n.y,size:n.b+a},t:{val:n.y,size:n.t+a}}}else delete r._pushmargin[e];t._replotting||h.doAutoMargin(t)}},h.doAutoMargin=function(t){var e=t._fullLayout;e._size||(e._size={}),e._pushmargin||(e._pushmargin={});var n=e._size,r=JSON.stringify(n),a=Math.max(e.margin.l||0,0),o=Math.max(e.margin.r||0,0),i=Math.max(e.margin.t||0,0),l=Math.max(e.margin.b||0,0),s=e._pushmargin;return e.margin.autoexpand!==!1&&(s.base={l:{val:0,size:a},r:{val:1,size:o},t:{val:1,size:i},b:{val:0,size:l}},Object.keys(s).forEach(function(t){var n=s[t].l||{},r=s[t].b||{},u=n.val,f=n.size,d=r.val,h=r.size;Object.keys(s).forEach(function(t){if(c(f)&&s[t].r){var n=s[t].r.val,r=s[t].r.size;if(n>u){var p=(f*n+(r-e.width)*u)/(n-u),g=(r*(1-u)+(f-e.width)*(1-n))/(n-u);p>=0&&g>=0&&p+g>a+o&&(a=p,o=g)}}if(c(h)&&s[t].t){var v=s[t].t.val,m=s[t].t.size;if(v>d){var y=(h*v+(m-e.height)*d)/(v-d),x=(m*(1-d)+(h-e.height)*(1-v))/(v-d);y>=0&&x>=0&&y+x>l+i&&(l=y,i=x)}}})})),n.l=Math.round(a),n.r=Math.round(o),n.t=Math.round(i),n.b=Math.round(l),n.p=Math.round(e.margin.pad),n.w=Math.round(e.width)-n.l-n.r,n.h=Math.round(e.height)-n.t-n.b,t._replotting||"{}"===r||r===JSON.stringify(e._size)?void 0:u.plot(t)},h.graphJson=function(t,e,n,r,a){function o(t){if("function"==typeof t)return null;if(f.isPlainObject(t)){var e,r,a={};for(e in t)if("function"!=typeof t[e]&&-1===["_","["].indexOf(e.charAt(0))){if("keepdata"===n){if("src"===e.substr(e.length-3))continue}else if("keepstream"===n){if(r=t[e+"src"],"string"==typeof r&&r.indexOf(":")>0&&!f.isPlainObject(t.stream))continue}else if("keepall"!==n&&(r=t[e+"src"],"string"==typeof r&&r.indexOf(":")>0))continue;a[e]=o(t[e])}return a}return Array.isArray(t)?t.map(o):t&&t.getTime?f.ms2DateTime(t):t}(a&&e&&!t._fullData||a&&!e&&!t._fullLayout)&&h.supplyDefaults(t);var i=a?t._fullData:t.data,l=a?t._fullLayout:t.layout,s={data:(i||[]).map(function(t){var n=o(t);return e&&delete n.fit,n})};return e||(s.layout=o(l)),t.framework&&t.framework.isPolar&&(s=t.framework.getConfig()),"object"===r?s:JSON.stringify(s)}},{"../components/color":20,"../lib":99,"../plotly":118,"./attributes":119,"./font_attributes":139,"./layout_attributes":152,d3:10,"fast-isnumeric":12}],154:[function(t,e,n){"use strict";var r=t("../../traces/scatter/attributes"),a=r.marker;e.exports={r:r.r,t:r.t,marker:{color:a.color,size:a.size,symbol:a.symbol,opacity:a.opacity}}},{"../../traces/scatter/attributes":175}],155:[function(t,e,n){"use strict";function r(t,e){var n={showline:{valType:"boolean"},showticklabels:{valType:"boolean"},tickorientation:{valType:"enumerated",values:["horizontal","vertical"]},ticklen:{valType:"number",min:0},tickcolor:{valType:"color"},ticksuffix:{valType:"string"},endpadding:{valType:"number"},visible:{valType:"boolean"}};return o({},e,n)}var a=t("../cartesian/layout_attributes"),o=t("../../lib/extend").extendFlat,i=o({},a.domain,{});e.exports={radialaxis:r("radial",{range:{valType:"info_array",items:[{valType:"number"},{valType:"number"}]},domain:i,orientation:{valType:"number"}}),angularaxis:r("angular",{range:{valType:"info_array",items:[{valType:"number",dflt:0},{valType:"number",dflt:360}]},domain:i}),layout:{direction:{valType:"enumerated",values:["clockwise","counterclockwise"]},orientation:{valType:"angle"}}}},{"../../lib/extend":96,"../cartesian/layout_attributes":130}],156:[function(t,e,n){var r=t("../../plotly"),a=t("d3"),o=e.exports={version:"0.2.2",manager:t("./micropolar_manager")},i=r.Lib.extendDeepAll;o.Axis=function(){function t(t){n=t||n;var c=s.data,f=s.layout;return("string"==typeof n||n.nodeName)&&(n=a.select(n)),n.datum(c).each(function(t,n){function s(t,e){return l(t)%360+f.orientation}var c=t.slice();u={data:o.util.cloneJson(c),layout:o.util.cloneJson(f)};var d=0;c.forEach(function(t,e){t.color||(t.color=f.defaultColorRange[d],d=(d+1)%f.defaultColorRange.length),t.strokeColor||(t.strokeColor="LinePlot"===t.geometry?t.color:a.rgb(t.color).darker().toString()),u.data[e].color=t.color,u.data[e].strokeColor=t.strokeColor,u.data[e].strokeDash=t.strokeDash,u.data[e].strokeSize=t.strokeSize});var h=c.filter(function(t,e){var n=t.visible;return"undefined"==typeof n||n===!0}),p=!1,g=h.map(function(t,e){return p=p||"undefined"!=typeof t.groupId,t});if(p){var v=a.nest().key(function(t,e){return"undefined"!=typeof t.groupId?t.groupId:"unstacked"}).entries(g),m=[],y=v.map(function(t,e){if("unstacked"===t.key)return t.values;var n=t.values[0].r.map(function(t,e){return 0});return t.values.forEach(function(t,e,r){t.yStack=[n],m.push(n),n=o.util.sumArrays(t.r,n)}),t.values});h=a.merge(y)}h.forEach(function(t,e){t.t=Array.isArray(t.t[0])?t.t:[t.t],t.r=Array.isArray(t.r[0])?t.r:[t.r]});var x=Math.min(f.width-f.margin.left-f.margin.right,f.height-f.margin.top-f.margin.bottom)/2;x=Math.max(10,x);var b,_=[f.margin.left+x,f.margin.top+x];if(p){var w=a.max(o.util.sumArrays(o.util.arrayLast(h).r[0],o.util.arrayLast(m)));b=[0,w]}else b=a.extent(o.util.flattenArray(h.map(function(t,e){return t.r})));f.radialAxis.domain!=o.DATAEXTENT&&(b[0]=0),r=a.scale.linear().domain(f.radialAxis.domain!=o.DATAEXTENT&&f.radialAxis.domain?f.radialAxis.domain:b).range([0,x]),u.layout.radialAxis.domain=r.domain();var k,M=o.util.flattenArray(h.map(function(t,e){return t.t})),A="string"==typeof M[0];A&&(M=o.util.deduplicate(M),k=M.slice(),M=a.range(M.length),h=h.map(function(t,e){var n=t;return t.t=[M],p&&(n.yStack=t.yStack),n}));var T=h.filter(function(t,e){return"LinePlot"===t.geometry||"DotPlot"===t.geometry}).length===h.length,L=null===f.needsEndSpacing?A||!T:f.needsEndSpacing,z=f.angularAxis.domain&&f.angularAxis.domain!=o.DATAEXTENT&&!A&&f.angularAxis.domain[0]>=0,S=z?f.angularAxis.domain:a.extent(M),C=Math.abs(M[1]-M[0]);T&&!A&&(C=0);var E=S.slice();L&&A&&(E[1]+=C);var O=f.angularAxis.ticksCount||4;O>8&&(O=O/(O/8)+O%8),f.angularAxis.ticksStep&&(O=(E[1]-E[0])/O);var N=f.angularAxis.ticksStep||(E[1]-E[0])/(O*(f.minorTicks+1));k&&(N=Math.max(Math.round(N),1)),E[2]||(E[2]=N);var P=a.range.apply(this,E);if(P=P.map(function(t,e){return parseFloat(t.toPrecision(12))}),l=a.scale.linear().domain(E.slice(0,2)).range("clockwise"===f.direction?[0,360]:[360,0]),u.layout.angularAxis.domain=l.domain(),u.layout.angularAxis.endPadding=L?C:0,e=a.select(this).select("svg.chart-root"),"undefined"==typeof e||e.empty()){var j="' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '",D=(new DOMParser).parseFromString(j,"application/xml"),R=this.appendChild(this.ownerDocument.importNode(D.documentElement,!0));e=a.select(R)}e.select(".guides-group").style({"pointer-events":"none"}),e.select(".angular.axis-group").style({"pointer-events":"none"}),e.select(".radial.axis-group").style({"pointer-events":"none"});var I,q=e.select(".chart-group"),F={fill:"none",stroke:f.tickColor},B={"font-size":f.font.size,"font-family":f.font.family,fill:f.font.color,"text-shadow":["-1px 0px","1px -1px","-1px 1px","1px 1px"].map(function(t,e){return" "+t+" 0 "+f.font.outlineColor}).join(",")};if(f.showLegend){I=e.select(".legend-group").attr({transform:"translate("+[x,f.margin.top]+")"}).style({display:"block"});var H=h.map(function(t,e){var n=o.util.cloneJson(t);return n.symbol="DotPlot"===t.geometry?t.dotType||"circle":"LinePlot"!=t.geometry?"square":"line",n.visibleInLegend="undefined"==typeof t.visibleInLegend||t.visibleInLegend,n.color="LinePlot"===t.geometry?t.strokeColor:t.color,n});o.Legend().config({data:h.map(function(t,e){return t.name||"Element"+e}),legendConfig:i({},o.Legend.defaultConfig().legendConfig,{container:I,elements:H,reverseOrder:f.legend.reverseOrder})})();var V=I.node().getBBox();x=Math.min(f.width-V.width-f.margin.left-f.margin.right,f.height-f.margin.top-f.margin.bottom)/2,x=Math.max(10,x),_=[f.margin.left+x,f.margin.top+x],r.range([0,x]),u.layout.radialAxis.domain=r.domain(),I.attr("transform","translate("+[_[0]+x,_[1]-x]+")")}else I=e.select(".legend-group").style({display:"none"});e.attr({width:f.width,height:f.height}).style({opacity:f.opacity}),q.attr("transform","translate("+_+")").style({cursor:"crosshair"});var U=[(f.width-(f.margin.left+f.margin.right+2*x+(V?V.width:0)))/2,(f.height-(f.margin.top+f.margin.bottom+2*x))/2];if(U[0]=Math.max(0,U[0]),U[1]=Math.max(0,U[1]),e.select(".outer-group").attr("transform","translate("+U+")"),f.title){var G=e.select("g.title-group text").style(B).text(f.title),Z=G.node().getBBox();G.attr({x:_[0]-Z.width/2,y:_[1]-x-20})}var Y=e.select(".radial.axis-group");if(f.radialAxis.gridLinesVisible){var X=Y.selectAll("circle.grid-circle").data(r.ticks(5));X.enter().append("circle").attr({"class":"grid-circle"}).style(F),X.attr("r",r),X.exit().remove()}Y.select("circle.outside-circle").attr({r:x}).style(F);var Q=e.select("circle.background-circle").attr({r:x}).style({fill:f.backgroundColor,stroke:f.stroke});if(f.radialAxis.visible){var $=a.svg.axis().scale(r).ticks(5).tickSize(5);Y.call($).attr({transform:"rotate("+f.radialAxis.orientation+")"}),Y.selectAll(".domain").style(F),Y.selectAll("g>text").text(function(t,e){return this.textContent+f.radialAxis.ticksSuffix}).style(B).style({"text-anchor":"start"}).attr({x:0,y:0,dx:0,dy:0,transform:function(t,e){return"horizontal"===f.radialAxis.tickOrientation?"rotate("+-f.radialAxis.orientation+") translate("+[0,B["font-size"]]+")":"translate("+[0,B["font-size"]]+")"}}),Y.selectAll("g>line").style({stroke:"black"})}var W=e.select(".angular.axis-group").selectAll("g.angular-tick").data(P),J=W.enter().append("g").classed("angular-tick",!0);W.attr({transform:function(t,e){return"rotate("+s(t,e)+")"}}).style({display:f.angularAxis.visible?"block":"none"}),W.exit().remove(),J.append("line").classed("grid-line",!0).classed("major",function(t,e){return e%(f.minorTicks+1)==0}).classed("minor",function(t,e){return!(e%(f.minorTicks+1)==0)}).style(F),J.selectAll(".minor").style({stroke:f.minorTickColor}),W.select("line.grid-line").attr({x1:f.tickLength?x-f.tickLength:0,x2:x}).style({display:f.angularAxis.gridLinesVisible?"block":"none"}),J.append("text").classed("axis-text",!0).style(B);var K=W.select("text.axis-text").attr({x:x+f.labelOffset,dy:".35em",transform:function(t,e){var n=s(t,e),r=x+f.labelOffset,a=f.angularAxis.tickOrientation;return"horizontal"==a?"rotate("+-n+" "+r+" 0)":"radial"==a?270>n&&n>90?"rotate(180 "+r+" 0)":null:"rotate("+(180>=n&&n>0?-90:90)+" "+r+" 0)"}}).style({"text-anchor":"middle",display:f.angularAxis.labelsVisible?"block":"none"}).text(function(t,e){return e%(f.minorTicks+1)!=0?"":k?k[t]+f.angularAxis.ticksSuffix:t+f.angularAxis.ticksSuffix}).style(B);f.angularAxis.rewriteTicks&&K.text(function(t,e){return e%(f.minorTicks+1)!=0?"":f.angularAxis.rewriteTicks(this.textContent,e)});var tt=a.max(q.selectAll(".angular-tick text")[0].map(function(t,e){return t.getCTM().e+t.getBBox().width}));I.attr({transform:"translate("+[x+tt,f.margin.top]+")"});var et=e.select("g.geometry-group").selectAll("g").size()>0,nt=e.select("g.geometry-group").selectAll("g.geometry").data(h);if(nt.enter().append("g").attr({"class":function(t,e){return"geometry geometry"+e}}),nt.exit().remove(),h[0]||et){var rt=[];h.forEach(function(t,e){var n={};n.radialScale=r,n.angularScale=l,n.container=nt.filter(function(t,n){return n==e}),n.geometry=t.geometry,n.orientation=f.orientation,n.direction=f.direction,n.index=e,rt.push({data:t,geometryConfig:n})});var at=a.nest().key(function(t,e){return"undefined"!=typeof t.data.groupId||"unstacked"}).entries(rt),ot=[];at.forEach(function(t,e){"unstacked"===t.key?ot=ot.concat(t.values.map(function(t,e){return[t]})):ot.push(t.values)}),ot.forEach(function(t,e){var n;n=Array.isArray(t)?t[0].geometryConfig.geometry:t.geometryConfig.geometry;var r=t.map(function(t,e){return i(o[n].defaultConfig(),t)});o[n]().config(r)()})}var it,lt,st=e.select(".guides-group"),ct=e.select(".tooltips-group"),ut=o.tooltipPanel().config({container:ct,fontSize:8})(),ft=o.tooltipPanel().config({container:ct,fontSize:8})(),dt=o.tooltipPanel().config({container:ct,hasTick:!0})();if(!A){var ht=st.select("line").attr({x1:0,y1:0,y2:0}).style({stroke:"grey","pointer-events":"none"});q.on("mousemove.angular-guide",function(t,e){var n=o.util.getMousePos(Q).angle;ht.attr({x2:-x,transform:"rotate("+n+")"}).style({opacity:.5});var r=(n+180+360-f.orientation)%360;it=l.invert(r);var a=o.util.convertToCartesian(x+12,n+180);ut.text(o.util.round(it)).move([a[0]+_[0],a[1]+_[1]])}).on("mouseout.angular-guide",function(t,e){st.select("line").style({opacity:0})})}var pt=st.select("circle").style({stroke:"grey",fill:"none"});q.on("mousemove.radial-guide",function(t,e){var n=o.util.getMousePos(Q).radius;pt.attr({r:n}).style({opacity:.5}),lt=r.invert(o.util.getMousePos(Q).radius);var a=o.util.convertToCartesian(n,f.radialAxis.orientation);ft.text(o.util.round(lt)).move([a[0]+_[0],a[1]+_[1]])}).on("mouseout.radial-guide",function(t,e){pt.style({opacity:0}),dt.hide(),ut.hide(),ft.hide()}),e.selectAll(".geometry-group .mark").on("mouseover.tooltip",function(t,n){var r=a.select(this),i=r.style("fill"),l="black",s=r.style("opacity")||1;if(r.attr({"data-opacity":s}),"none"!=i){r.attr({"data-fill":i}),l=a.hsl(i).darker().toString(),r.style({fill:l,opacity:1});var c={t:o.util.round(t[0]),r:o.util.round(t[1])};A&&(c.t=k[t[0]]);var u="t: "+c.t+", r: "+c.r,f=this.getBoundingClientRect(),d=e.node().getBoundingClientRect(),h=[f.left+f.width/2-U[0]-d.left,f.top+f.height/2-U[1]-d.top];dt.config({color:l}).text(u),dt.move(h)}else i=r.style("stroke"),r.attr({"data-stroke":i}),l=a.hsl(i).darker().toString(),r.style({stroke:l,opacity:1})}).on("mousemove.tooltip",function(t,e){return 0!=a.event.which?!1:void(a.select(this).attr("data-fill")&&dt.show())}).on("mouseout.tooltip",function(t,e){dt.hide();var n=a.select(this),r=n.attr("data-fill");r?n.style({fill:r,opacity:n.attr("data-opacity")}):n.style({stroke:n.attr("data-stroke"),opacity:n.attr("data-opacity")})})}),d}var e,n,r,l,s={data:[],layout:{}},c={},u={},f=a.dispatch("hover"),d={};return d.render=function(e){return t(e),this},d.config=function(t){if(!arguments.length)return s;var e=o.util.cloneJson(t);return e.data.forEach(function(t,e){s.data[e]||(s.data[e]={}),i(s.data[e],o.Axis.defaultConfig().data[0]),i(s.data[e],t)}),i(s.layout,o.Axis.defaultConfig().layout),i(s.layout,e.layout),this},d.getLiveConfig=function(){return u},d.getinputConfig=function(){return c},d.radialScale=function(t){return r},d.angularScale=function(t){return l},d.svg=function(){return e},a.rebind(d,f,"on"),d},o.Axis.defaultConfig=function(t,e){var n={data:[{t:[1,2,3,4],r:[10,11,12,13],name:"Line1",geometry:"LinePlot",color:null,strokeDash:"solid",strokeColor:null,strokeSize:"1",visibleInLegend:!0,opacity:1}],layout:{defaultColorRange:a.scale.category10().range(),title:null,height:450,width:500,margin:{top:40,right:40,bottom:40,left:40},font:{size:12,color:"gray",outlineColor:"white",family:"Tahoma, sans-serif"},direction:"clockwise",orientation:0,labelOffset:10,radialAxis:{domain:null,orientation:-45,ticksSuffix:"",visible:!0,gridLinesVisible:!0,tickOrientation:"horizontal",rewriteTicks:null},angularAxis:{domain:[0,360],ticksSuffix:"",visible:!0,gridLinesVisible:!0,labelsVisible:!0,tickOrientation:"horizontal",rewriteTicks:null,ticksCount:null,ticksStep:null},minorTicks:0,tickLength:null,tickColor:"silver",minorTickColor:"#eee",backgroundColor:"none",needsEndSpacing:null,showLegend:!0,legend:{reverseOrder:!1},opacity:1}};return n},o.util={},o.DATAEXTENT="dataExtent",o.AREA="AreaChart",o.LINE="LinePlot",o.DOT="DotPlot",o.BAR="BarChart",o.util._override=function(t,e){for(var n in t)n in e&&(e[n]=t[n])},o.util._extend=function(t,e){for(var n in t)e[n]=t[n]},o.util._rndSnd=function(){return 2*Math.random()-1+(2*Math.random()-1)+(2*Math.random()-1)},o.util.dataFromEquation2=function(t,e){var n=e||6,r=a.range(0,360+n,n).map(function(e,n){var r=e*Math.PI/180,a=t(r);return[e,a]});return r},o.util.dataFromEquation=function(t,e,n){var r=e||6,o=[],i=[];a.range(0,360+r,r).forEach(function(e,n){var r=e*Math.PI/180,a=t(r);o.push(e),i.push(a)});var l={t:o,r:i};return n&&(l.name=n),l},o.util.ensureArray=function(t,e){if("undefined"==typeof t)return null;var n=[].concat(t);return a.range(e).map(function(t,e){return n[e]||n[0]})},o.util.fillArrays=function(t,e,n){return e.forEach(function(e,r){t[e]=o.util.ensureArray(t[e],n)}),t},o.util.cloneJson=function(t){return JSON.parse(JSON.stringify(t))},o.util.validateKeys=function(t,e){"string"==typeof e&&(e=e.split("."));var n=e.shift();return t[n]&&(!e.length||objHasKeys(t[n],e))},o.util.sumArrays=function(t,e){return a.zip(t,e).map(function(t,e){return a.sum(t)})},o.util.arrayLast=function(t){return t[t.length-1]},o.util.arrayEqual=function(t,e){for(var n=Math.max(t.length,e.length,1);n-- >=0&&t[n]===e[n];);return-2===n},o.util.flattenArray=function(t){for(var e=[];!o.util.arrayEqual(e,t);)e=t,t=[].concat.apply([],t);return t},o.util.deduplicate=function(t){return t.filter(function(t,e,n){return n.indexOf(t)==e})},o.util.convertToCartesian=function(t,e){var n=e*Math.PI/180,r=t*Math.cos(n),a=t*Math.sin(n);return[r,a]},o.util.round=function(t,e){var n=e||2,r=Math.pow(10,n);return Math.round(t*r)/r},o.util.getMousePos=function(t){var e=a.mouse(t.node()),n=e[0],r=e[1],o={};return o.x=n,o.y=r,o.pos=e,o.angle=180*(Math.atan2(r,n)+Math.PI)/Math.PI,o.radius=Math.sqrt(n*n+r*r),o},o.util.duplicatesCount=function(t){for(var e,n={},r={},a=0,o=t.length;o>a;a++)e=t[a],e in n?(n[e]++,r[e]=n[e]):n[e]=1;return r},o.util.duplicates=function(t){return Object.keys(o.util.duplicatesCount(t))},o.util.translator=function(t,e,n,r){if(r){var a=n.slice();n=e,e=a}var o=e.reduce(function(t,e){return"undefined"!=typeof t?t[e]:void 0},t);"undefined"!=typeof o&&(e.reduce(function(t,n,r){return"undefined"!=typeof t?(r===e.length-1&&delete t[n],t[n]):void 0},t),n.reduce(function(t,e,r){return"undefined"==typeof t[e]&&(t[e]={}),r===n.length-1&&(t[e]=o),t[e]},t))},o.PolyChart=function(){function t(){var t=n[0].geometryConfig,e=t.container;"string"==typeof e&&(e=a.select(e)),e.datum(n).each(function(e,n){function r(e,n){var r=t.radialScale(e[1]),a=(t.angularScale(e[0])+t.orientation)*Math.PI/180;return{r:r,t:a}}function o(t){var e=t.r*Math.cos(t.t),n=t.r*Math.sin(t.t);return{x:e,y:n}}var i=!!e[0].data.yStack,s=e.map(function(t,e){return i?a.zip(t.data.t[0],t.data.r[0],t.data.yStack[0]):a.zip(t.data.t[0],t.data.r[0])}),c=t.angularScale,u=t.radialScale.domain()[0],f={};f.bar=function(n,r,o){var i=e[o].data,l=t.radialScale(n[1])-t.radialScale(0),s=t.radialScale(n[2]||0),u=i.barWidth;a.select(this).attr({"class":"mark bar",d:"M"+[[l+s,-u/2],[l+s,u/2],[s,u/2],[s,-u/2]].join("L")+"Z",transform:function(e,n){return"rotate("+(t.orientation+c(e[0]))+")"}})},f.dot=function(t,n,i){var l=t[2]?[t[0],t[1]+t[2]]:t,s=a.svg.symbol().size(e[i].data.dotSize).type(e[i].data.dotType)(t,n);a.select(this).attr({"class":"mark dot",d:s,transform:function(t,e){var n=o(r(l));return"translate("+[n.x,n.y]+")"}})};var d=a.svg.line.radial().interpolate(e[0].data.lineInterpolation).radius(function(e){return t.radialScale(e[1])}).angle(function(e){return t.angularScale(e[0])*Math.PI/180});f.line=function(n,r,o){var i=n[2]?s[o].map(function(t,e){return[t[0],t[1]+t[2]]}):s[o];if(a.select(this).each(f.dot).style({opacity:function(t,n){return+e[o].data.dotVisible},fill:v.stroke(n,r,o)}).attr({"class":"mark dot"}),!(r>0)){var l=a.select(this.parentNode).selectAll("path.line").data([0]);l.enter().insert("path"),l.attr({"class":"line",d:d(i),transform:function(e,n){return"rotate("+(t.orientation+90)+")"},"pointer-events":"none"}).style({fill:function(t,e){return v.fill(n,r,o)},"fill-opacity":0,stroke:function(t,e){return v.stroke(n,r,o)},"stroke-width":function(t,e){return v["stroke-width"](n,r,o)},"stroke-dasharray":function(t,e){return v["stroke-dasharray"](n,r,o)},opacity:function(t,e){return v.opacity(n,r,o)},display:function(t,e){return v.display(n,r,o)}})}};var h=t.angularScale.range(),p=Math.abs(h[1]-h[0])/s[0].length*Math.PI/180,g=a.svg.arc().startAngle(function(t){return-p/2}).endAngle(function(t){return p/2}).innerRadius(function(e){return t.radialScale(u+(e[2]||0))}).outerRadius(function(e){return t.radialScale(u+(e[2]||0))+t.radialScale(e[1])});f.arc=function(e,n,r){a.select(this).attr({"class":"mark arc",d:g,transform:function(e,n){return"rotate("+(t.orientation+c(e[0])+90)+")"}})};var v={fill:function(t,n,r){return e[r].data.color},stroke:function(t,n,r){return e[r].data.strokeColor},"stroke-width":function(t,n,r){return e[r].data.strokeSize+"px"},"stroke-dasharray":function(t,n,r){return l[e[r].data.strokeDash]},opacity:function(t,n,r){return e[r].data.opacity},display:function(t,n,r){return"undefined"==typeof e[r].data.visible||e[r].data.visible?"block":"none"}},m=a.select(this).selectAll("g.layer").data(s);m.enter().append("g").attr({"class":"layer"});var y=m.selectAll("path.mark").data(function(t,e){return t});y.enter().append("path").attr({"class":"mark"}),y.style(v).each(f[t.geometryType]),y.exit().remove(),m.exit().remove()})}var e,n=[o.PolyChart.defaultConfig()],r=a.dispatch("hover"),l={solid:"none",dash:[5,2],dot:[2,5]};return t.config=function(t){return arguments.length?(t.forEach(function(t,e){n[e]||(n[e]={}),i(n[e],o.PolyChart.defaultConfig()),i(n[e],t)}),this):n},t.getColorScale=function(){return e},a.rebind(t,r,"on"),t},o.PolyChart.defaultConfig=function(){var t={data:{name:"geom1",t:[[1,2,3,4]],r:[[1,2,3,4]],dotType:"circle",dotSize:64,dotVisible:!1,barWidth:20,color:"#ffa500",strokeSize:1,strokeColor:"silver",strokeDash:"solid",opacity:1,index:0,visible:!0,visibleInLegend:!0},geometryConfig:{geometry:"LinePlot",geometryType:"arc",direction:"clockwise",orientation:0,container:"body",radialScale:null,angularScale:null,colorScale:a.scale.category20()}};return t},o.BarChart=function(){return o.PolyChart()},o.BarChart.defaultConfig=function(){var t={geometryConfig:{geometryType:"bar"}};return t},o.AreaChart=function(){return o.PolyChart()},o.AreaChart.defaultConfig=function(){var t={geometryConfig:{geometryType:"arc"}};return t},o.DotPlot=function(){return o.PolyChart()},o.DotPlot.defaultConfig=function(){var t={geometryConfig:{geometryType:"dot",dotType:"circle"}};return t},o.LinePlot=function(){return o.PolyChart()},o.LinePlot.defaultConfig=function(){var t={geometryConfig:{geometryType:"line"}};return t},o.Legend=function(){function t(){var n=e.legendConfig,r=e.data.map(function(t,e){return[].concat(t).map(function(t,r){var a=i({},n.elements[e]);return a.name=t,a.color=[].concat(n.elements[e].color)[r],a})}),o=a.merge(r);o=o.filter(function(t,e){return n.elements[e]&&(n.elements[e].visibleInLegend||"undefined"==typeof n.elements[e].visibleInLegend)}),n.reverseOrder&&(o=o.reverse());var l=n.container;("string"==typeof l||l.nodeName)&&(l=a.select(l));var s=o.map(function(t,e){return t.color}),c=n.fontSize,u=null==n.isContinuous?"number"==typeof o[0]:n.isContinuous,f=u?n.height:c*o.length,d=l.classed("legend-group",!0),h=d.selectAll("svg").data([0]),p=h.enter().append("svg").attr({width:300,height:f+c,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"});p.append("g").classed("legend-axis",!0),p.append("g").classed("legend-marks",!0);var g=a.range(o.length),v=a.scale[u?"linear":"ordinal"]().domain(g).range(s),m=a.scale[u?"linear":"ordinal"]().domain(g)[u?"range":"rangePoints"]([0,f]),y=function(t,e){var n=3*e;return"line"===t?"M"+[[-e/2,-e/12],[e/2,-e/12],[e/2,e/12],[-e/2,e/12]]+"Z":-1!=a.svg.symbolTypes.indexOf(t)?a.svg.symbol().type(t).size(n)():a.svg.symbol().type("square").size(n)()};if(u){var x=h.select(".legend-marks").append("defs").append("linearGradient").attr({id:"grad1",x1:"0%",y1:"0%",x2:"0%",y2:"100%"}).selectAll("stop").data(s);x.enter().append("stop"),x.attr({offset:function(t,e){return e/(s.length-1)*100+"%"}}).style({"stop-color":function(t,e){return t}}),h.append("rect").classed("legend-mark",!0).attr({height:n.height,width:n.colorBandWidth,fill:"url(#grad1)"})}else{var b=h.select(".legend-marks").selectAll("path.legend-mark").data(o);b.enter().append("path").classed("legend-mark",!0), +-b.attr({transform:function(t,e){return"translate("+[c/2,m(e)+c/2]+")"},d:function(t,e){var n=t.symbol;return y(n,c)},fill:function(t,e){return v(e)}}),b.exit().remove()}var _=a.svg.axis().scale(m).orient("right"),w=h.select("g.legend-axis").attr({transform:"translate("+[u?n.colorBandWidth:c,c/2]+")"}).call(_);return w.selectAll(".domain").style({fill:"none",stroke:"none"}),w.selectAll("line").style({fill:"none",stroke:u?n.textColor:"none"}),w.selectAll("text").style({fill:n.textColor,"font-size":n.fontSize}).text(function(t,e){return o[e].name}),t}var e=o.Legend.defaultConfig(),n=a.dispatch("hover");return t.config=function(t){return arguments.length?(i(e,t),this):e},a.rebind(t,n,"on"),t},o.Legend.defaultConfig=function(t,e){var n={data:["a","b","c"],legendConfig:{elements:[{symbol:"line",color:"red"},{symbol:"square",color:"yellow"},{symbol:"diamond",color:"limegreen"}],height:150,colorBandWidth:30,fontSize:12,container:"body",isContinuous:null,textColor:"grey",reverseOrder:!1}};return n},o.tooltipPanel=function(){var t,e,n,r={container:null,hasTick:!1,fontSize:12,color:"white",padding:5},l="tooltip-"+o.tooltipPanel.uid++,s=10,c=function(){t=r.container.selectAll("g."+l).data([0]);var a=t.enter().append("g").classed(l,!0).style({"pointer-events":"none",display:"none"});return n=a.append("path").style({fill:"white","fill-opacity":.9}).attr({d:"M0 0"}),e=a.append("text").attr({dx:r.padding+s,dy:.3*+r.fontSize}),c};return c.text=function(o){var i=a.hsl(r.color).l,l=i>=.5?"#aaa":"white",u=i>=.5?"black":"white",f=o||"";e.style({fill:u,"font-size":r.fontSize+"px"}).text(f);var d=r.padding,h=e.node().getBBox(),p={fill:r.color,stroke:l,"stroke-width":"2px"},g=h.width+2*d+s,v=h.height+2*d;return n.attr({d:"M"+[[s,-v/2],[s,-v/4],[r.hasTick?0:s,0],[s,v/4],[s,v/2],[g,v/2],[g,-v/2]].join("L")+"Z"}).style(p),t.attr({transform:"translate("+[s,-v/2+2*d]+")"}),t.style({display:"block"}),c},c.move=function(e){return t?(t.attr({transform:"translate("+[e[0],e[1]]+")"}).style({display:"block"}),c):void 0},c.hide=function(){return t?(t.style({display:"none"}),c):void 0},c.show=function(){return t?(t.style({display:"block"}),c):void 0},c.config=function(t){return i(r,t),c},c},o.tooltipPanel.uid=1,o.adapter={},o.adapter.plotly=function(){var t={};return t.convert=function(t,e){var n={};if(t.data&&(n.data=t.data.map(function(t,n){var r=i({},t),a=[[r,["marker","color"],["color"]],[r,["marker","opacity"],["opacity"]],[r,["marker","line","color"],["strokeColor"]],[r,["marker","line","dash"],["strokeDash"]],[r,["marker","line","width"],["strokeSize"]],[r,["marker","symbol"],["dotType"]],[r,["marker","size"],["dotSize"]],[r,["marker","barWidth"],["barWidth"]],[r,["line","interpolation"],["lineInterpolation"]],[r,["showlegend"],["visibleInLegend"]]];return a.forEach(function(t,n){o.util.translator.apply(null,t.concat(e))}),e||delete r.marker,e&&delete r.groupId,e?("LinePlot"===r.geometry?(r.type="scatter",r.dotVisible===!0?(delete r.dotVisible,r.mode="lines+markers"):r.mode="lines"):"DotPlot"===r.geometry?(r.type="scatter",r.mode="markers"):"AreaChart"===r.geometry?r.type="area":"BarChart"===r.geometry&&(r.type="bar"),delete r.geometry):("scatter"===r.type?"lines"===r.mode?r.geometry="LinePlot":"markers"===r.mode?r.geometry="DotPlot":"lines+markers"===r.mode&&(r.geometry="LinePlot",r.dotVisible=!0):"area"===r.type?r.geometry="AreaChart":"bar"===r.type&&(r.geometry="BarChart"),delete r.mode,delete r.type),r}),!e&&t.layout&&"stack"===t.layout.barmode)){var r=o.util.duplicates(n.data.map(function(t,e){return t.geometry}));n.data.forEach(function(t,e){var a=r.indexOf(t.geometry);-1!=a&&(n.data[e].groupId=a)})}if(t.layout){var l=i({},t.layout),s=[[l,["plot_bgcolor"],["backgroundColor"]],[l,["showlegend"],["showLegend"]],[l,["radialaxis"],["radialAxis"]],[l,["angularaxis"],["angularAxis"]],[l.angularaxis,["showline"],["gridLinesVisible"]],[l.angularaxis,["showticklabels"],["labelsVisible"]],[l.angularaxis,["nticks"],["ticksCount"]],[l.angularaxis,["tickorientation"],["tickOrientation"]],[l.angularaxis,["ticksuffix"],["ticksSuffix"]],[l.angularaxis,["range"],["domain"]],[l.angularaxis,["endpadding"],["endPadding"]],[l.radialaxis,["showline"],["gridLinesVisible"]],[l.radialaxis,["tickorientation"],["tickOrientation"]],[l.radialaxis,["ticksuffix"],["ticksSuffix"]],[l.radialaxis,["range"],["domain"]],[l.angularAxis,["showline"],["gridLinesVisible"]],[l.angularAxis,["showticklabels"],["labelsVisible"]],[l.angularAxis,["nticks"],["ticksCount"]],[l.angularAxis,["tickorientation"],["tickOrientation"]],[l.angularAxis,["ticksuffix"],["ticksSuffix"]],[l.angularAxis,["range"],["domain"]],[l.angularAxis,["endpadding"],["endPadding"]],[l.radialAxis,["showline"],["gridLinesVisible"]],[l.radialAxis,["tickorientation"],["tickOrientation"]],[l.radialAxis,["ticksuffix"],["ticksSuffix"]],[l.radialAxis,["range"],["domain"]],[l.font,["outlinecolor"],["outlineColor"]],[l.legend,["traceorder"],["reverseOrder"]],[l,["labeloffset"],["labelOffset"]],[l,["defaultcolorrange"],["defaultColorRange"]]];if(s.forEach(function(t,n){o.util.translator.apply(null,t.concat(e))}),e?("undefined"!=typeof l.tickLength&&(l.angularaxis.ticklen=l.tickLength,delete l.tickLength),l.tickColor&&(l.angularaxis.tickcolor=l.tickColor,delete l.tickColor)):(l.angularAxis&&"undefined"!=typeof l.angularAxis.ticklen&&(l.tickLength=l.angularAxis.ticklen),l.angularAxis&&"undefined"!=typeof l.angularAxis.tickcolor&&(l.tickColor=l.angularAxis.tickcolor)),l.legend&&"boolean"!=typeof l.legend.reverseOrder&&(l.legend.reverseOrder="normal"!=l.legend.reverseOrder),l.legend&&"boolean"==typeof l.legend.traceorder&&(l.legend.traceorder=l.legend.traceorder?"reversed":"normal",delete l.legend.reverseOrder),l.margin&&"undefined"!=typeof l.margin.t){var c=["t","r","b","l","pad"],u=["top","right","bottom","left","pad"],f={};a.entries(l.margin).forEach(function(t,e){f[u[c.indexOf(t.key)]]=t.value}),l.margin=f}e&&(delete l.needsEndSpacing,delete l.minorTickColor,delete l.minorTicks,delete l.angularaxis.ticksCount,delete l.angularaxis.ticksCount,delete l.angularaxis.ticksStep,delete l.angularaxis.rewriteTicks,delete l.angularaxis.nticks,delete l.radialaxis.ticksCount,delete l.radialaxis.ticksCount,delete l.radialaxis.ticksStep,delete l.radialaxis.rewriteTicks,delete l.radialaxis.nticks),n.layout=l}return n},t}},{"../../plotly":118,"./micropolar_manager":157,d3:10}],157:[function(t,e,n){"use strict";var r=t("../../plotly"),a=t("d3"),o=t("./undo_manager"),i=e.exports={},l=r.Lib.extendDeepAll;i.framework=function(t){function e(e,o){return o&&(f=o),a.select(a.select(f).node().parentNode).selectAll(".svg-container>*:not(.chart-root)").remove(),n=n?l(n,e):e,c||(c=r.micropolar.Axis()),u=r.micropolar.adapter.plotly().convert(n),c.config(u).render(f),t.data=n.data,t.layout=n.layout,i.fillLayout(t),n}var n,s,c,u,f,d=new o;return e.isPolar=!0,e.svg=function(){return c.svg()},e.getConfig=function(){return n},e.getLiveConfig=function(){return r.micropolar.adapter.plotly().convert(c.getLiveConfig(),!0)},e.getLiveScales=function(){return{t:c.angularScale(),r:c.radialScale()}},e.setUndoPoint=function(){var t=this,e=r.micropolar.util.cloneJson(n);!function(e,n){d.add({undo:function(){n&&t(n)},redo:function(){t(e)}})}(e,s),s=r.micropolar.util.cloneJson(e)},e.undo=function(){d.undo()},e.redo=function(){d.redo()},e},i.fillLayout=function(t){var e=a.select(t).selectAll(".plot-container"),n=e.selectAll(".svg-container"),o=t.framework&&t.framework.svg&&t.framework.svg(),i={width:800,height:600,paper_bgcolor:r.Color.background,_container:e,_paperdiv:n,_paper:o};t._fullLayout=l(i,t.layout)}},{"../../plotly":118,"./undo_manager":158,d3:10}],158:[function(t,e,n){"use strict";e.exports=function(){function t(t,e){return t?(a=!0,t[e](),a=!1,this):this}var e,n=[],r=-1,a=!1;return{add:function(t){return a?this:(n.splice(r+1,n.length-r),n.push(t),r=n.length-1,this)},setCallback:function(t){e=t},undo:function(){var a=n[r];return a?(t(a,"undo"),r-=1,e&&e(a.undo),this):this},redo:function(){var a=n[r+1];return a?(t(a,"redo"),r+=1,e&&e(a.redo),this):this},clear:function(){n=[],r=-1},hasUndo:function(){return-1!==r},hasRedo:function(){return rg;g++){var v=h[g];l=t[v]?t[v]:t[v]={},e[v]=s={},i("domain."+d,[g/p,(g+1)/p]),i("domain."+{x:"y",y:"x"}[d]),o.id=v,f(l,s,i,o)}}},{"../lib":99,"./plots":153}],160:[function(t,e,n){"use strict";function r(t){var e;switch(t){case"themes__thumb":e={autosize:!0,width:150,height:150,title:"",showlegend:!1,margin:{l:5,r:5,t:5,b:5,pad:0},annotations:[]};break;case"thumbnail":e={title:"",hidesources:!0,showlegend:!1,borderwidth:0,bordercolor:"",margin:{l:1,r:1,t:1,b:1,pad:0},annotations:[]};break;default:e={}}return e}function a(t){var e=["xaxis","yaxis","zaxis"];return e.indexOf(t.slice(0,5))>-1}var o=t("../plotly"),i=o.Lib.extendFlat,l=o.Lib.extendDeep;e.exports=function(t,e){t.framework&&t.framework.isPolar&&(t=t.framework.getConfig());var n,s=t.data,c=t.layout,u=l([],s),f=l({},c,r(e.tileClass));if(e.width&&(f.width=e.width),e.height&&(f.height=e.height),"thumbnail"===e.tileClass||"themes__thumb"===e.tileClass){f.annotations=[];var d=Object.keys(f);for(n=0;ns&&(e.z=u.slice(0,s)),l("locationmode"),l("text"),l("marker.line.color"),l("marker.line.width"),a(t,e,i,l,{prefix:"",cLetter:"z"}),void l("hoverinfo",1===i._dataLength?"location+z+text":void 0)):void(e.visible=!1)}},{"../../components/colorscale/defaults":30,"../../lib":99,"./attributes":167}],170:[function(t,e,n){"use strict";var r={};r.attributes=t("./attributes"),r.supplyDefaults=t("./defaults"),r.colorbar=t("../heatmap/colorbar"),r.calc=t("./calc"),r.plot=t("./plot").plot,r.moduleType="trace",r.name="choropleth",r.basePlotModule=t("../../plots/geo"),r.categories=["geo","noOpacity"],r.meta={},e.exports=r},{"../../plots/geo":142,"../heatmap/colorbar":172,"./attributes":167,"./calc":168,"./defaults":169,"./plot":171}],171:[function(t,e,n){"use strict";function r(t,e){function n(e){var n=t.mockAxis;return i.tickText(n,n.c2l(e),"hover").text}var r=e.hoverinfo;if("none"===r)return function(t){delete t.nameLabel,delete t.textLabel};var a="all"===r?v.hoverinfo.flags:r.split("+"),o=-1!==a.indexOf("name"),l=-1!==a.indexOf("location"),s=-1!==a.indexOf("z"),c=-1!==a.indexOf("text"),u=!o&&l;return function(t){var r=[];u?t.nameLabel=t.id:(o&&(t.nameLabel=e.name),l&&r.push(t.id)),s&&r.push(n(t.z)),c&&r.push(t.tx),t.textLabel=r.join("
")}}function a(t){return function(e,n){return{points:[{data:t._input,fullData:t,curveNumber:t.index,pointNumber:n,location:e.id,z:e.z}]}}}var o=t("d3"),i=t("../../plots/cartesian/axes"),l=t("../../plots/cartesian/graph_interact"),s=t("../../components/color"),c=t("../../components/drawing"),u=t("../../components/colorscale/get_scale"),f=t("../../components/colorscale/make_scale_function"),d=t("../../lib/topojson_utils").getTopojsonFeatures,h=t("../../lib/geo_location_utils").locationToFeature,p=t("../../lib/array_to_calc_item"),g=t("../../plots/geo/constants"),v=t("./attributes"),m=e.exports={};m.calcGeoJSON=function(t,e){for(var n,r=[],a=t.locations,o=a.length,i=d(t,e),l=(t.marker||{}).line||{},s=0;o>s;s++)n=h(t.locationmode,a[s],i),void 0!==n&&(n.z=t.z[s],void 0!==t.text&&(n.tx=t.text[s]),p(l.color,n,"mlc",s),p(l.width,n,"mlw",s),r.push(n));return r.length>0&&(r[0].trace=t),r},m.plot=function(t,e,n){var i,s=t.framework,c=s.select("g.choroplethlayer"),u=s.select("g.baselayer"),f=s.select("g.baselayeroverchoropleth"),d=g.baseLayersOverChoropleth,h=c.selectAll("g.trace.choropleth").data(e,function(t){return t.uid});h.enter().append("g").attr("class","trace choropleth"),h.exit().remove(),h.each(function(e){function n(e,n){if(t.showHover){var r=t.projection(e.properties.ct);c(e),l.loneHover({x:r[0],y:r[1],name:e.nameLabel,text:e.textLabel},{container:t.hoverContainer.node()}),f=u(e,n),t.graphDiv.emit("plotly_hover",f)}}function i(e,n){t.graphDiv.emit("plotly_click",u(e,n))}var s=m.calcGeoJSON(e,t.topojson),c=r(t,e),u=a(e),f=null,d=o.select(this).selectAll("path.choroplethlocation").data(s);d.enter().append("path").classed("choroplethlocation",!0).on("mouseover",n).on("click",i).on("mouseout",function(){l.loneUnhover(t.hoverContainer),t.graphDiv.emit("plotly_unhover",f)}).on("mousedown",function(){l.loneUnhover(t.hoverContainer)}).on("mouseup",n),d.exit().remove()}),f.selectAll("*").remove();for(var p=0;pp&&d.splice(p,d.length-p),h.length>p&&h.splice(p,h.length-p);var g={padded:!0},v={padded:!0};if(i.hasMarkers(e)){if(n=e.marker,s=n.size,Array.isArray(s)){var m={type:"linear"};a.setConvert(m),s=m.makeCalcdata(e.marker,"size"),s.length>p&&s.splice(p,s.length-p)}var y,x=1.6*(e.marker.sizeref||1);y="area"===e.marker.sizemode?function(t){return Math.max(Math.sqrt((t||0)/x),3)}:function(t){return Math.max((t||0)/x,3)},g.ppad=v.ppad=Array.isArray(s)?s.map(y):y(s)}l(e),!("tozerox"===e.fill||"tonextx"===e.fill&&t.firstscatter)||d[0]===d[p-1]&&h[0]===h[p-1]?e.error_y.visible||-1===["tonexty","tozeroy"].indexOf(e.fill)&&(i.hasMarkers(e)||i.hasText(e))||(g.padded=!1,g.ppad=0):g.tozero=!0,!("tozeroy"===e.fill||"tonexty"===e.fill&&t.firstscatter)||d[0]===d[p-1]&&h[0]===h[p-1]?-1!==["tonextx","tozerox"].indexOf(e.fill)&&(v.padded=!1):v.tozero=!0,a.expand(u,d,g),a.expand(f,h,v);var b=new Array(p);for(c=0;p>c;c++)b[c]=r(d[c])&&r(h[c])?{x:d[c],y:h[c]}:{x:!1,y:!1};return void 0!==typeof s&&o.mergeArray(s,b,"ms"),t.firstscatter=!1,b}},{"../../lib":99,"../../plots/cartesian/axes":121,"./colorscale_calc":179,"./subtypes":194,"fast-isnumeric":12}],177:[function(t,e,n){"use strict";e.exports=function(t){var e,n,r,a,o;for(e=0;e=0;a--)if(o=t[a],"scatter"===o.type&&o.xaxis===n.xaxis&&o.yaxis===n.yaxis){o.opacity=void 0;break}}},{}],178:[function(t,e,n){"use strict";var r=t("d3"),a=t("fast-isnumeric"),o=t("../../lib"),i=t("../../plots/plots"),l=t("../../components/colorscale/get_scale"),s=t("../../components/colorbar/draw");e.exports=function(t,e){var n=e[0].trace,c=n.marker,u="cb"+n.uid;if(t._fullLayout._infolayer.selectAll("."+u).remove(),void 0===c||!c.showscale)return void i.autoMargin(t,u);var f=l(c.colorscale),d=c.color,h=c.cmin,p=c.cmax;a(h)||(h=o.aggNums(Math.min,null,d)),a(p)||(p=o.aggNums(Math.max,null,d));var g=e[0].t.cb=s(t,u);g.fillcolor(r.scale.linear().domain(f.map(function(t){return h+t[0]*(p-h)})).range(f.map(function(t){return t[1]}))).filllevels({start:h,end:p,size:(p-h)/254}).options(c.colorbar)()}},{"../../components/colorbar/draw":23,"../../components/colorscale/get_scale":32,"../../lib":99,"../../plots/plots":153,d3:10,"fast-isnumeric":12}],179:[function(t,e,n){"use strict";var r=t("../../components/colorscale/has_colorscale"),a=t("../../components/colorscale/calc"),o=t("./subtypes");e.exports=function(t){o.hasLines(t)&&r(t,"line")&&a(t,t.line.color,"line","c"),o.hasMarkers(t)&&(r(t,"marker")&&a(t,t.marker.color,"marker","c"),r(t,"marker.line")&&a(t,t.marker.line.color,"marker.line","c"))}},{"../../components/colorscale/calc":27,"../../components/colorscale/has_colorscale":33,"./subtypes":194}],180:[function(t,e,n){"use strict";e.exports={PTS_LINESONLY:20}},{}],181:[function(t,e,n){"use strict";var r=t("../../lib"),a=t("./attributes"),o=t("./constants"),i=t("./subtypes"),l=t("./xy_defaults"),s=t("./marker_defaults"),c=t("./line_defaults"),u=t("./line_shape_defaults"),f=t("./text_defaults"),d=t("./fillcolor_defaults"),h=t("../../components/errorbars/defaults");e.exports=function(t,e,n,p){function g(n,o){return r.coerce(t,e,a,n,o)}var v=l(t,e,g),m=vB!=N>=B&&(C=z[T-1][0],E=z[T][0],S=C+(E-C)*(B-O)/(N-O),R=Math.min(R,S),I=Math.max(I,S));R=Math.max(R,0),I=Math.min(I,d._length);var H=s.defaultLine;return s.opacity(f.fillcolor)?H=f.fillcolor:s.opacity((f.line||{}).color)&&(H=f.line.color),r.extendFlat(t,{distance:o.MAXDIST+10,x0:R,x1:I,y0:B,y1:B,color:H}),delete t.index,f.text&&!Array.isArray(f.text)?t.text=String(f.text):t.text=f.name,[t]}}}},{"../../components/color":20,"../../components/errorbars":49,"../../lib":99,"../../plots/cartesian/constants":126,"../../plots/cartesian/graph_interact":128,"./get_trace_color":183}],185:[function(t,e,n){"use strict";var r={},a=t("./subtypes");r.hasLines=a.hasLines,r.hasMarkers=a.hasMarkers,r.hasText=a.hasText,r.isBubble=a.isBubble,r.attributes=t("./attributes"),r.supplyDefaults=t("./defaults"),r.cleanData=t("./clean_data"),r.calc=t("./calc"),r.arraysToCalcdata=t("./arrays_to_calcdata"),r.plot=t("./plot"),r.colorbar=t("./colorbar"),r.style=t("./style"),r.hoverPoints=t("./hover"),r.selectPoints=t("./select"),r.moduleType="trace",r.name="scatter",r.basePlotModule=t("../../plots/cartesian"), +-r.categories=["cartesian","symbols","markerColorscale","errorBarsOK","showLegend"],r.meta={},e.exports=r},{"../../plots/cartesian":129,"./arrays_to_calcdata":174,"./attributes":175,"./calc":176,"./clean_data":177,"./colorbar":178,"./defaults":181,"./hover":184,"./plot":191,"./select":192,"./style":193,"./subtypes":194}],186:[function(t,e,n){"use strict";var r=t("../../components/colorscale/has_colorscale"),a=t("../../components/colorscale/defaults");e.exports=function(t,e,n,o,i){var l=(t.marker||{}).color;if(i("line.color",n),r(t,"line"))a(t,e,o,i,{prefix:"line.",cLetter:"c"});else{var s=(Array.isArray(l)?!1:l)||n;i("line.color",s)}i("line.width"),i("line.dash")}},{"../../components/colorscale/defaults":30,"../../components/colorscale/has_colorscale":33}],187:[function(t,e,n){"use strict";var r=t("../../plots/cartesian/axes");e.exports=function(t,e){function n(e){var n=w.c2p(t[e].x),r=k.c2p(t[e].y);return n===z||r===z?!1:[n,r]}function a(t){var e=t[0]/w._length,n=t[1]/k._length;return(1+10*Math.max(0,-e,e-1,-n,n-1))*A}function o(t,e){var n=t[0]-e[0],r=t[1]-e[1];return Math.sqrt(n*n+r*r)}var i,l,s,c,u,f,d,h,p,g,v,m,y,x,b,_,w=e.xaxis,k=e.yaxis,M=e.connectGaps,A=e.baseTolerance,T=e.linear,L=[],z=r.BADNUM,S=.2,C=new Array(t.length),E=0;for(i=0;ia(f))break;s=f,y=g[0]*p[0]+g[1]*p[1],y>v?(v=y,c=f,h=!1):m>y&&(m=y,u=f,h=!0)}if(h?(C[E++]=c,s!==u&&(C[E++]=u)):(u!==l&&(C[E++]=u),s!==c&&(C[E++]=c)),C[E++]=s,i>=t.length||!f)break;C[E++]=f,l=f}}else C[E++]=c}L.push(C.slice(0,E))}return L}},{"../../plots/cartesian/axes":121}],188:[function(t,e,n){"use strict";e.exports=function(t,e,n){var r=n("line.shape");"spline"===r&&n("line.smoothing")}},{}],189:[function(t,e,n){"use strict";var r=t("fast-isnumeric");e.exports=function(t){var e=t.marker,n=e.sizeref||1,a=e.sizemin||0,o="area"===e.sizemode?function(t){return Math.sqrt(t/n)}:function(t){return t/n};return function(t){var e=o(t/2);return r(e)&&e>0?Math.max(e,a):0}}},{"fast-isnumeric":12}],190:[function(t,e,n){"use strict";var r=t("../../components/color"),a=t("../../components/colorscale/has_colorscale"),o=t("../../components/colorscale/defaults"),i=t("./subtypes");e.exports=function(t,e,n,l,s){var c,u=i.isBubble(t),f=(t.line||{}).color;f&&(n=f),s("marker.symbol"),s("marker.opacity",u?.7:1),s("marker.size"),s("marker.color",n),a(t,"marker")&&o(t,e,l,s,{prefix:"marker.",cLetter:"c"}),c=f&&!Array.isArray(f)&&e.marker.color!==f?f:u?r.background:r.defaultLine,s("marker.line.color",c),a(t,"marker.line")&&o(t,e,l,s,{prefix:"marker.line.",cLetter:"c"}),s("marker.line.width",u?1:0),u&&(s("marker.sizeref"),s("marker.sizemin"),s("marker.sizemode"))}},{"../../components/color":20,"../../components/colorscale/defaults":30,"../../components/colorscale/has_colorscale":33,"./subtypes":194}],191:[function(t,e,n){"use strict";function r(t,e,n){var r=e.x(),o=e.y(),i=a.extent(r.range.map(r.l2c)),l=a.extent(o.range.map(o.l2c));n.forEach(function(t,e){var r=t[0].trace;if(c.hasMarkers(r)){var a=r.marker.maxdisplayed;if(0!==a){var o=t.filter(function(t){return t.x>=i[0]&&t.x<=i[1]&&t.y>=l[0]&&t.y<=l[1]}),s=Math.ceil(o.length/a),u=0;n.forEach(function(t,n){var r=t[0].trace;c.hasMarkers(r)&&r.marker.maxdisplayed>0&&e>n&&u++});var f=Math.round(u*s/3+Math.floor(u/3)*s/7.1);t.forEach(function(t){delete t.vis}),o.forEach(function(t,e){0===Math.round((e+f)%s)&&(t.vis=!0)})}}})}var a=t("d3"),o=t("../../lib"),i=t("../../components/drawing"),l=t("../../components/errorbars"),s=t("../../lib/polygon").tester,c=t("./subtypes"),u=t("./arrays_to_calcdata"),f=t("./line_points");e.exports=function(t,e,n){function d(t){return t.filter(function(t){return t.vis})}r(t,e,n);var h=e.x(),p=e.y(),g=e.plot.select(".scatterlayer").selectAll("g.trace.scatter").data(n);g.enter().append("g").attr("class","trace scatter").style("stroke-miterlimit",2),g.call(l.plot,e);var v,m,y,x,b="",_=[];g.each(function(t){var e=t[0].trace,n=e.line,r=a.select(this);if(e.visible===!0&&(m=e.fill.charAt(e.fill.length-1),"x"!==m&&"y"!==m&&(m=""),t[0].node3=r,u(t),c.hasLines(e)||"none"!==e.fill)){var o,l,d,g,w,k="",M="";v="tozero"===e.fill.substr(0,6)||"toself"===e.fill||"to"===e.fill.substr(0,2)&&!b?r.append("path").classed("js-fill",!0):null,x&&(y=x.datum(t)),x=r.append("path").classed("js-fill",!0),-1!==["hv","vh","hvh","vhv"].indexOf(n.shape)?(d=i.steps(n.shape),g=i.steps(n.shape.split("").reverse().join(""))):d=g="spline"===n.shape?function(t){var e=t[t.length-1];return t[0][0]===e[0]&&t[0][1]===e[1]?i.smoothclosed(t.slice(1),n.smoothing):i.smoothopen(t,n.smoothing)}:function(t){return"M"+t.join("L")},w=function(t){return g(t.reverse())};var A,T=f(t,{xaxis:h,yaxis:p,connectGaps:e.connectgaps,baseTolerance:Math.max(n.width||1,3)/4,linear:"linear"===n.shape}),L=e._polygons=new Array(T.length);for(A=0;A1&&r.append("path").classed("js-line",!0).style("vector-effect","non-scaling-stroke").attr("d",o)}v?z&&C&&(m?("y"===m?z[1]=C[1]=p.c2p(0,!0):"x"===m&&(z[0]=C[0]=h.c2p(0,!0)),v.attr("d",k+"L"+C+"L"+z+"Z")):v.attr("d",k+"Z")):"tonext"===e.fill.substr(0,6)&&k&&b&&("tonext"===e.fill?y.attr("d",k+"Z"+b+"Z"):y.attr("d",k+"L"+b.substr(1)+"Z"),e._polygons=e._polygons.concat(_)),b=M,_=L}}}),g.selectAll("path:not([d])").remove(),g.append("g").attr("class","points").each(function(t){var e=t[0].trace,n=a.select(this),r=c.hasMarkers(e),l=c.hasText(e);!r&&!l||e.visible!==!0?n.remove():(r&&n.selectAll("path.point").data(e.marker.maxdisplayed?d:o.identity).enter().append("path").classed("point",!0).call(i.translatePoints,h,p),l&&n.selectAll("g").data(e.marker.maxdisplayed?d:o.identity).enter().append("g").append("text").call(i.translatePoints,h,p))})}},{"../../components/drawing":43,"../../components/errorbars":49,"../../lib":99,"../../lib/polygon":105,"./arrays_to_calcdata":174,"./line_points":187,"./subtypes":194,d3:10}],192:[function(t,e,n){"use strict";var r=t("./subtypes"),a=.2;e.exports=function(t,e){var n,o,i,l,s=t.cd,c=t.xaxis,u=t.yaxis,f=[],d=s[0].trace,h=d.index,p=d.marker,g=!r.hasMarkers(d)&&!r.hasText(d);if(d.visible===!0&&!g){var v=Array.isArray(p.opacity)?1:p.opacity;if(e===!1)for(n=0;nr;r++)n[r]=[t.lon[r],t.lat[r]];return{type:"LineString",coordinates:n,trace:t}}function o(t,e){function n(e){var n=t.mockAxis;return c.tickText(n,n.c2l(e),"hover").text+"\xb0"}var r=e.hoverinfo;if("none"===r)return function(t){delete t.textLabel};var a="all"===r?v.hoverinfo.flags:r.split("+"),o=-1!==a.indexOf("location")&&Array.isArray(e.locations),i=-1!==a.indexOf("lon"),l=-1!==a.indexOf("lat"),s=-1!==a.indexOf("text");return function(t){var r=[];o?r.push(t.location):i&&l?r.push("("+n(t.lon)+", "+n(t.lat)+")"):i?r.push("lon: "+n(t.lon)):l&&r.push("lat: "+n(t.lat)),s&&r.push(t.tx||e.text),t.textLabel=r.join("
")}}function i(t){var e=Array.isArray(t.locations);return function(n,r){return{points:[{data:t._input,fullData:t,curveNumber:t.index,pointNumber:r,lon:n.lon,lat:n.lat,location:e?n.location:null}]}}}var l=t("d3"),s=t("../../plots/cartesian/graph_interact"),c=t("../../plots/cartesian/axes"),u=t("../../lib/topojson_utils").getTopojsonFeatures,f=t("../../lib/geo_location_utils").locationToFeature,d=t("../../lib/array_to_calc_item"),h=t("../../components/color"),p=t("../../components/drawing"),g=t("../scatter/subtypes"),v=t("./attributes"),m=e.exports={};m.calcGeoJSON=function(t,e){var n,a,o,i,l=[],s=Array.isArray(t.locations);s?(i=t.locations,n=i.length,a=u(t,e),o=function(t,e){var n=f(t.locationmode,i[e],a);return void 0!==n?n.properties.ct:void 0}):(n=t.lon.length,o=function(t,e){return[t.lon[e],t.lat[e]]});for(var c=0;n>c;c++){var d=o(t,c);if(d){var h={lon:d[0],lat:d[1],location:s?t.locations[c]:null};r(t,h,c),l.push(h)}}return l.length>0&&(l[0].trace=t),l},m.plot=function(t,e){var n=t.framework.select(".scattergeolayer").selectAll("g.trace.scattergeo").data(e,function(t){return t.uid});n.enter().append("g").attr("class","trace scattergeo"),n.exit().remove(),n.selectAll("*").remove(),n.each(function(t){var e=l.select(this);g.hasLines(t)&&e.selectAll("path.js-line").data([a(t)]).enter().append("path").classed("js-line",!0)}),n.each(function(e){function n(n,r){if(t.showHover){var a=t.projection([n.lon,n.lat]);d(n),s.loneHover({x:a[0],y:a[1],name:v?e.name:void 0,text:n.textLabel,color:n.mc||(e.marker||{}).color},{container:t.hoverContainer.node()}),y=h(n,r),t.graphDiv.emit("plotly_hover",y)}}function r(e,n){t.graphDiv.emit("plotly_click",h(e,n))}var a=l.select(this),c=g.hasMarkers(e),u=g.hasText(e);if(c||u){var f=m.calcGeoJSON(e,t.topojson),d=o(t,e),h=i(e),p=e.hoverinfo,v="all"===p||-1!==p.indexOf("name"),y=null;c&&a.selectAll("path.point").data(f).enter().append("path").classed("point",!0).on("mouseover",n).on("click",r).on("mouseout",function(){s.loneUnhover(t.hoverContainer),t.graphDiv.emit("plotly_unhover",y)}).on("mousedown",function(){s.loneUnhover(t.hoverContainer)}).on("mouseup",n),u&&a.selectAll("g").data(f).enter().append("g").append("text")}}),m.style(t)},m.style=function(t){var e=t.framework.selectAll("g.trace.scattergeo");e.style("opacity",function(t){return t.opacity}),e.each(function(t){l.select(this).selectAll("path.point").call(p.pointStyle,t),l.select(this).selectAll("text").call(p.textPointStyle,t)}),e.selectAll("path.js-line").style("fill","none").each(function(t){var e=t.trace,n=e.line||{};l.select(this).call(h.stroke,n.color).call(p.dashLine,n.dash||"",n.width||0)})}},{"../../components/color":20,"../../components/drawing":43,"../../lib/array_to_calc_item":92,"../../lib/geo_location_utils":98,"../../lib/topojson_utils":111,"../../plots/cartesian/axes":121,"../../plots/cartesian/graph_interact":128,"../scatter/subtypes":194,"./attributes":197,d3:10}]},{},[5])(5)}); +\ No newline at end of file ++!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.Plotly=t()}}(function(){var t;return function t(e,n,r){function a(i,l){if(!n[i]){if(!e[i]){var s="function"==typeof require&&require;if(!l&&s)return s(i,!0);if(o)return o(i,!0);var c=new Error("Cannot find module '"+i+"'");throw c.code="MODULE_NOT_FOUND",c}var u=n[i]={exports:{}};e[i][0].call(u.exports,function(t){var n=e[i][1][t];return a(n?n:t)},u,u.exports,t,e,n,r)}return n[i].exports}for(var o="function"==typeof require&&require,i=0;ie?1:t>=e?0:NaN}function o(t){return null===t?NaN:+t}function i(t){return!isNaN(t)}function l(t){return{left:function(e,n,r,a){for(arguments.length<3&&(r=0),arguments.length<4&&(a=e.length);r>>1;t(e[o],n)<0?r=o+1:a=o}return r},right:function(e,n,r,a){for(arguments.length<3&&(r=0),arguments.length<4&&(a=e.length);r>>1;t(e[o],n)>0?a=o:r=o+1}return r}}}function s(t){return t.length}function c(t){for(var e=1;t*e%1;)e*=10;return e}function u(t,e){for(var n in e)Object.defineProperty(t.prototype,n,{value:e[n],enumerable:!1})}function f(){this._=Object.create(null)}function d(t){return(t+="")===_i||t[0]===wi?wi+t:t}function h(t){return(t+="")[0]===wi?t.slice(1):t}function p(t){return d(t)in this._}function g(t){return(t=d(t))in this._&&delete this._[t]}function v(){var t=[];for(var e in this._)t.push(h(e));return t}function m(){var t=0;for(var e in this._)++t;return t}function y(){for(var t in this._)return!1;return!0}function x(){this._=Object.create(null)}function b(t){return t}function _(t,e,n){return function(){var r=n.apply(e,arguments);return r===e?t:r}}function w(t,e){if(e in t)return e;e=e.charAt(0).toUpperCase()+e.slice(1);for(var n=0,r=ki.length;n=e&&(e=a+1);!(i=l[e])&&++e0&&(t=t.slice(0,l));var c=Oi.get(t);return c&&(t=c,s=$),l?e?a:r:e?k:o}function Q(t,e){return function(n){var r=ui.event;ui.event=n,e[0]=this.__data__;try{t.apply(this,e)}finally{ui.event=r}}}function $(t,e){var n=Q(t,e);return function(t){var e=this,r=t.relatedTarget;r&&(r===e||8&r.compareDocumentPosition(e))||n.call(e,t)}}function W(t){var n=".dragsuppress-"+ ++ji,a="click"+n,o=ui.select(r(t)).on("touchmove"+n,T).on("dragstart"+n,T).on("selectstart"+n,T);if(null==Pi&&(Pi=!("onselectstart"in t)&&w(t.style,"userSelect")),Pi){var i=e(t).style,l=i[Pi];i[Pi]="none"}return function(t){if(o.on(n,null),Pi&&(i[Pi]=l),t){var e=function(){o.on(a,null)};o.on(a,function(){T(),e()},!0),setTimeout(e,0)}}}function J(t,e){e.changedTouches&&(e=e.changedTouches[0]);var n=t.ownerSVGElement||t;if(n.createSVGPoint){var a=n.createSVGPoint();if(Di<0){var o=r(t);if(o.scrollX||o.scrollY){n=ui.select("body").append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important");var i=n[0][0].getScreenCTM();Di=!(i.f||i.e),n.remove()}}return Di?(a.x=e.pageX,a.y=e.pageY):(a.x=e.clientX,a.y=e.clientY),a=a.matrixTransform(t.getScreenCTM().inverse()),[a.x,a.y]}var l=t.getBoundingClientRect();return[e.clientX-l.left-t.clientLeft,e.clientY-l.top-t.clientTop]}function K(){return ui.event.changedTouches[0].identifier}function tt(t){return t>0?1:t<0?-1:0}function et(t,e,n){return(e[0]-t[0])*(n[1]-t[1])-(e[1]-t[1])*(n[0]-t[0])}function nt(t){return t>1?0:t<-1?Fi:Math.acos(t)}function rt(t){return t>1?Hi:t<-1?-Hi:Math.asin(t)}function at(t){return((t=Math.exp(t))-1/t)/2}function ot(t){return((t=Math.exp(t))+1/t)/2}function it(t){return((t=Math.exp(2*t))-1)/(t+1)}function lt(t){return(t=Math.sin(t/2))*t}function st(){}function ct(t,e,n){return this instanceof ct?(this.h=+t,this.s=+e,void(this.l=+n)):arguments.length<2?t instanceof ct?new ct(t.h,t.s,t.l):kt(""+t,Mt,ct):new ct(t,e,n)}function ut(t,e,n){function r(t){return t>360?t-=360:t<0&&(t+=360),t<60?o+(i-o)*t/60:t<180?i:t<240?o+(i-o)*(240-t)/60:o}function a(t){return Math.round(255*r(t))}var o,i;return t=isNaN(t)?0:(t%=360)<0?t+360:t,e=isNaN(e)?0:e<0?0:e>1?1:e,n=n<0?0:n>1?1:n,i=n<=.5?n*(1+e):n+e-n*e,o=2*n-i,new xt(a(t+120),a(t),a(t-120))}function ft(t,e,n){return this instanceof ft?(this.h=+t,this.c=+e,void(this.l=+n)):arguments.length<2?t instanceof ft?new ft(t.h,t.c,t.l):t instanceof ht?gt(t.l,t.a,t.b):gt((t=At((t=ui.rgb(t)).r,t.g,t.b)).l,t.a,t.b):new ft(t,e,n)}function dt(t,e,n){return isNaN(t)&&(t=0),isNaN(e)&&(e=0),new ht(n,Math.cos(t*=Vi)*e,Math.sin(t)*e)}function ht(t,e,n){return this instanceof ht?(this.l=+t,this.a=+e,void(this.b=+n)):arguments.length<2?t instanceof ht?new ht(t.l,t.a,t.b):t instanceof ft?dt(t.h,t.c,t.l):At((t=xt(t)).r,t.g,t.b):new ht(t,e,n)}function pt(t,e,n){var r=(t+16)/116,a=r+e/500,o=r-n/200;return a=vt(a)*tl,r=vt(r)*el,o=vt(o)*nl,new xt(yt(3.2404542*a-1.5371385*r-.4985314*o),yt(-.969266*a+1.8760108*r+.041556*o),yt(.0556434*a-.2040259*r+1.0572252*o))}function gt(t,e,n){return t>0?new ft(Math.atan2(n,e)*Ui,Math.sqrt(e*e+n*n),t):new ft(NaN,NaN,t)}function vt(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function mt(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function yt(t){return Math.round(255*(t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}function xt(t,e,n){return this instanceof xt?(this.r=~~t,this.g=~~e,void(this.b=~~n)):arguments.length<2?t instanceof xt?new xt(t.r,t.g,t.b):kt(""+t,xt,ut):new xt(t,e,n)}function bt(t){return new xt(t>>16,t>>8&255,255&t)}function _t(t){return bt(t)+""}function wt(t){return t<16?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function kt(t,e,n){var r,a,o,i=0,l=0,s=0;if(r=/([a-z]+)\((.*)\)/.exec(t=t.toLowerCase()))switch(a=r[2].split(","),r[1]){case"hsl":return n(parseFloat(a[0]),parseFloat(a[1])/100,parseFloat(a[2])/100);case"rgb":return e(Lt(a[0]),Lt(a[1]),Lt(a[2]))}return(o=ol.get(t))?e(o.r,o.g,o.b):(null==t||"#"!==t.charAt(0)||isNaN(o=parseInt(t.slice(1),16))||(4===t.length?(i=(3840&o)>>4,i=i>>4|i,l=240&o,l=l>>4|l,s=15&o,s=s<<4|s):7===t.length&&(i=(16711680&o)>>16,l=(65280&o)>>8,s=255&o)),e(i,l,s))}function Mt(t,e,n){var r,a,o=Math.min(t/=255,e/=255,n/=255),i=Math.max(t,e,n),l=i-o,s=(i+o)/2;return l?(a=s<.5?l/(i+o):l/(2-i-o),r=t==i?(e-n)/l+(e0&&s<1?0:r),new ct(r,a,s)}function At(t,e,n){t=Tt(t),e=Tt(e),n=Tt(n);var r=mt((.4124564*t+.3575761*e+.1804375*n)/tl),a=mt((.2126729*t+.7151522*e+.072175*n)/el),o=mt((.0193339*t+.119192*e+.9503041*n)/nl);return ht(116*a-16,500*(r-a),200*(a-o))}function Tt(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Lt(t){var e=parseFloat(t);return"%"===t.charAt(t.length-1)?Math.round(2.55*e):e}function zt(t){return"function"==typeof t?t:function(){return t}}function St(t){return function(e,n,r){return 2===arguments.length&&"function"==typeof n&&(r=n,n=null),Ct(e,n,t,r)}}function Ct(t,e,n,r){function a(){var t,e=s.status;if(!e&&Nt(s)||e>=200&&e<300||304===e){try{t=n.call(o,s)}catch(t){return void i.error.call(o,t)}i.load.call(o,t)}else i.error.call(o,s)}var o={},i=ui.dispatch("beforesend","progress","load","error"),l={},s=new XMLHttpRequest,c=null;return!this.XDomainRequest||"withCredentials"in s||!/^(http(s)?:)?\/\//.test(t)||(s=new XDomainRequest),"onload"in s?s.onload=s.onerror=a:s.onreadystatechange=function(){s.readyState>3&&a()},s.onprogress=function(t){var e=ui.event;ui.event=t;try{i.progress.call(o,s)}finally{ui.event=e}},o.header=function(t,e){return t=(t+"").toLowerCase(),arguments.length<2?l[t]:(null==e?delete l[t]:l[t]=e+"",o)},o.mimeType=function(t){return arguments.length?(e=null==t?null:t+"",o):e},o.responseType=function(t){return arguments.length?(c=t,o):c},o.response=function(t){return n=t,o},["get","post"].forEach(function(t){o[t]=function(){return o.send.apply(o,[t].concat(di(arguments)))}}),o.send=function(n,r,a){if(2===arguments.length&&"function"==typeof r&&(a=r,r=null),s.open(n,t,!0),null==e||"accept"in l||(l.accept=e+",*/*"),s.setRequestHeader)for(var u in l)s.setRequestHeader(u,l[u]);return null!=e&&s.overrideMimeType&&s.overrideMimeType(e),null!=c&&(s.responseType=c),null!=a&&o.on("error",a).on("load",function(t){a(null,t)}),i.beforesend.call(o,s),s.send(null==r?null:r),o},o.abort=function(){return s.abort(),o},ui.rebind(o,i,"on"),null==r?o:o.get(Et(r))}function Et(t){return 1===t.length?function(e,n){t(null==e?n:null)}:t}function Nt(t){var e=t.responseType;return e&&"text"!==e?t.response:t.responseText}function Ot(t,e,n){var r=arguments.length;r<2&&(e=0),r<3&&(n=Date.now());var a=n+e,o={c:t,t:a,n:null};return ll?ll.n=o:il=o,ll=o,sl||(cl=clearTimeout(cl),sl=1,ul(Pt)),o}function Pt(){var t=jt(),e=Dt()-t;e>24?(isFinite(e)&&(clearTimeout(cl),cl=setTimeout(Pt,e)),sl=0):(sl=1,ul(Pt))}function jt(){for(var t=Date.now(),e=il;e;)t>=e.t&&e.c(t-e.t)&&(e.c=null),e=e.n;return t}function Dt(){for(var t,e=il,n=1/0;e;)e.c?(e.t8?function(t){return t/n}:function(t){return t*n},symbol:t}}function Ft(t){var e=t.decimal,n=t.thousands,r=t.grouping,a=t.currency,o=r&&n?function(t,e){for(var a=t.length,o=[],i=0,l=r[0],s=0;a>0&&l>0&&(s+l+1>e&&(l=Math.max(1,e-s)),o.push(t.substring(a-=l,a+l)),!((s+=l+1)>e));)l=r[i=(i+1)%r.length];return o.reverse().join(n)}:b;return function(t){var n=dl.exec(t),r=n[1]||" ",i=n[2]||">",l=n[3]||"-",s=n[4]||"",c=n[5],u=+n[6],f=n[7],d=n[8],h=n[9],p=1,g="",v="",m=!1,y=!0;switch(d&&(d=+d.substring(1)),(c||"0"===r&&"="===i)&&(c=r="0",i="="),h){case"n":f=!0,h="g";break;case"%":p=100,v="%",h="f";break;case"p":p=100,v="%",h="r";break;case"b":case"o":case"x":case"X":"#"===s&&(g="0"+h.toLowerCase());case"c":y=!1;case"d":m=!0,d=0;break;case"s":p=-1,h="r"}"$"===s&&(g=a[0],v=a[1]),"r"!=h||d||(h="g"),null!=d&&("g"==h?d=Math.max(1,Math.min(21,d)):"e"!=h&&"f"!=h||(d=Math.max(0,Math.min(20,d)))),h=hl.get(h)||qt;var x=c&&f;return function(t){var n=v;if(m&&t%1)return"";var a=t<0||0===t&&1/t<0?(t=-t,"-"):"-"===l?"":l;if(p<0){var s=ui.formatPrefix(t,d);t=s.scale(t),n=s.symbol+v}else t*=p;t=h(t,d);var b,_,w=t.lastIndexOf(".");if(w<0){var k=y?t.lastIndexOf("e"):-1;k<0?(b=t,_=""):(b=t.substring(0,k),_=t.substring(k))}else b=t.substring(0,w),_=e+t.substring(w+1);!c&&f&&(b=o(b,1/0));var M=g.length+b.length+_.length+(x?0:a.length),A=M"===i?A+a+t:"^"===i?A.substring(0,M>>=1)+a+t+A.substring(M):a+(x?t:A+t))+n}}}function qt(t){return t+""}function Bt(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}function Ht(t,e,n){function r(e){var n=t(e),r=o(n,1);return e-n1)for(;i=c)return-1;if(a=e.charCodeAt(l++),37===a){if(i=e.charAt(l++),o=S[i in ml?e.charAt(l++):i],!o||(r=o(t,n,r))<0)return-1}else if(a!=n.charCodeAt(r++))return-1}return r}function r(t,e,n){w.lastIndex=0;var r=w.exec(e.slice(n));return r?(t.w=k.get(r[0].toLowerCase()),n+r[0].length):-1}function a(t,e,n){b.lastIndex=0;var r=b.exec(e.slice(n));return r?(t.w=_.get(r[0].toLowerCase()),n+r[0].length):-1}function o(t,e,n){T.lastIndex=0;var r=T.exec(e.slice(n));return r?(t.m=L.get(r[0].toLowerCase()),n+r[0].length):-1}function i(t,e,n){M.lastIndex=0;var r=M.exec(e.slice(n));return r?(t.m=A.get(r[0].toLowerCase()),n+r[0].length):-1}function l(t,e,r){return n(t,z.c.toString(),e,r)}function s(t,e,r){return n(t,z.x.toString(),e,r)}function c(t,e,r){return n(t,z.X.toString(),e,r)}function u(t,e,n){var r=x.get(e.slice(n,n+=2).toLowerCase());return null==r?-1:(t.p=r,n)}var f=t.dateTime,d=t.date,h=t.time,p=t.periods,g=t.days,v=t.shortDays,m=t.months,y=t.shortMonths;e.utc=function(t){function n(t){try{gl=Bt;var e=new gl;return e._=t,r(e)}finally{gl=Date}}var r=e(t);return n.parse=function(t){try{gl=Bt;var e=r.parse(t);return e&&e._}finally{gl=Date}},n.toString=r.toString,n},e.multi=e.utc.multi=ue;var x=ui.map(),b=Zt(g),_=Yt(g),w=Zt(v),k=Yt(v),M=Zt(m),A=Yt(m),T=Zt(y),L=Yt(y);p.forEach(function(t,e){x.set(t.toLowerCase(),e)});var z={a:function(t){return v[t.getDay()]},A:function(t){return g[t.getDay()]},b:function(t){return y[t.getMonth()]},B:function(t){return m[t.getMonth()]},c:e(f),d:function(t,e){return Gt(t.getDate(),e,2)},e:function(t,e){return Gt(t.getDate(),e,2)},H:function(t,e){return Gt(t.getHours(),e,2)},I:function(t,e){return Gt(t.getHours()%12||12,e,2)},j:function(t,e){return Gt(1+pl.dayOfYear(t),e,3)},L:function(t,e){return Gt(t.getMilliseconds(),e,3)},m:function(t,e){return Gt(t.getMonth()+1,e,2)},M:function(t,e){return Gt(t.getMinutes(),e,2)},p:function(t){return p[+(t.getHours()>=12)]},S:function(t,e){return Gt(t.getSeconds(),e,2)},U:function(t,e){return Gt(pl.sundayOfYear(t),e,2)},w:function(t){return t.getDay()},W:function(t,e){return Gt(pl.mondayOfYear(t),e,2)},x:e(d),X:e(h),y:function(t,e){return Gt(t.getFullYear()%100,e,2)},Y:function(t,e){return Gt(t.getFullYear()%1e4,e,4)},Z:se,"%":function(){return"%"}},S={a:r,A:a,b:o,B:i,c:l,d:ne,e:ne,H:ae,I:ae,j:re,L:le,m:ee,M:oe,p:u,S:ie,U:Qt,w:Xt,W:$t,x:s,X:c,y:Jt,Y:Wt,Z:Kt,"%":ce};return e}function Gt(t,e,n){var r=t<0?"-":"",a=(r?-t:t)+"",o=a.length;return r+(o68?1900:2e3)}function ee(t,e,n){yl.lastIndex=0;var r=yl.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function ne(t,e,n){yl.lastIndex=0;var r=yl.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function re(t,e,n){yl.lastIndex=0;var r=yl.exec(e.slice(n,n+3));return r?(t.j=+r[0],n+r[0].length):-1}function ae(t,e,n){yl.lastIndex=0;var r=yl.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function oe(t,e,n){yl.lastIndex=0;var r=yl.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function ie(t,e,n){yl.lastIndex=0;var r=yl.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function le(t,e,n){yl.lastIndex=0;var r=yl.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function se(t){var e=t.getTimezoneOffset(),n=e>0?"-":"+",r=bi(e)/60|0,a=bi(e)%60;return n+Gt(r,"0",2)+Gt(a,"0",2)}function ce(t,e,n){xl.lastIndex=0;var r=xl.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function ue(t){for(var e=t.length,n=-1;++n=0?1:-1,l=i*n,s=Math.cos(e),c=Math.sin(e),u=o*c,f=a*s+u*Math.cos(l),d=u*i*Math.sin(l);Al.add(Math.atan2(d,f)),r=t,a=s,o=c}var e,n,r,a,o;Tl.point=function(i,l){Tl.point=t,r=(e=i)*Vi,a=Math.cos(l=(n=l)*Vi/2+Fi/4),o=Math.sin(l)},Tl.lineEnd=function(){t(e,n)}}function me(t){var e=t[0],n=t[1],r=Math.cos(n);return[r*Math.cos(e),r*Math.sin(e),Math.sin(n)]}function ye(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function xe(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function be(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function _e(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function we(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function ke(t){return[Math.atan2(t[1],t[0]),rt(t[2])]}function Me(t,e){return bi(t[0]-e[0])=0;--l)a.point((f=u[l])[0],f[1])}else r(h.x,h.p.x,-1,a);h=h.p}h=h.o,u=h.z,p=!p}while(!h.v);a.lineEnd()}}}function Oe(t){if(e=t.length){for(var e,n,r=0,a=t[0];++r0){for(_||(o.polygonStart(),_=!0),o.lineStart();++i1&&2&e&&n.push(n.pop().concat(n.shift())),h.push(n.filter(De))}var h,p,g,v=e(o),m=a.invert(r[0],r[1]),y={point:i,lineStart:s,lineEnd:c,polygonStart:function(){y.point=u,y.lineStart=f,y.lineEnd=d,h=[],p=[]},polygonEnd:function(){y.point=i,y.lineStart=s,y.lineEnd=c,h=ui.merge(h);var t=He(m,p);h.length?(_||(o.polygonStart(),_=!0),Ne(h,Ie,t,n,o)):t&&(_||(o.polygonStart(),_=!0),o.lineStart(),n(null,null,1,o),o.lineEnd()),_&&(o.polygonEnd(),_=!1),h=p=null},sphere:function(){o.polygonStart(),o.lineStart(),n(null,null,1,o),o.lineEnd(),o.polygonEnd()}},x=Re(),b=e(x),_=!1;return y}}function De(t){return t.length>1}function Re(){var t,e=[];return{lineStart:function(){e.push(t=[])},point:function(e,n){t.push([e,n])},lineEnd:k,buffer:function(){var n=e;return e=[],t=null,n},rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))}}}function Ie(t,e){return((t=t.x)[0]<0?t[1]-Hi-Ri:Hi-t[1])-((e=e.x)[0]<0?e[1]-Hi-Ri:Hi-e[1])}function Fe(t){var e,n=NaN,r=NaN,a=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(o,i){var l=o>0?Fi:-Fi,s=bi(o-n);bi(s-Fi)0?Hi:-Hi),t.point(a,r),t.lineEnd(),t.lineStart(),t.point(l,r),t.point(o,r),e=0):a!==l&&s>=Fi&&(bi(n-a)Ri?Math.atan((Math.sin(e)*(o=Math.cos(r))*Math.sin(n)-Math.sin(r)*(a=Math.cos(e))*Math.sin(t))/(a*o*i)):(e+r)/2}function Be(t,e,n,r){var a;if(null==t)a=n*Hi,r.point(-Fi,a),r.point(0,a),r.point(Fi,a),r.point(Fi,0),r.point(Fi,-a),r.point(0,-a),r.point(-Fi,-a),r.point(-Fi,0),r.point(-Fi,a);else if(bi(t[0]-e[0])>Ri){var o=t[0]=0?1:-1,k=w*_,M=k>Fi,A=p*x;if(Al.add(Math.atan2(A*w*Math.sin(k),g*b+A*Math.cos(k))),o+=M?_+w*qi:_,M^d>=n^m>=n){var T=xe(me(f),me(t));we(T);var L=xe(a,T);we(L);var z=(M^_>=0?-1:1)*rt(L[2]);(r>z||r===z&&(T[0]||T[1]))&&(i+=M^_>=0?1:-1)}if(!v++)break;d=m,p=x,g=b,f=t}}return(o<-Ri||oo}function n(t){var n,o,s,c,u;return{lineStart:function(){c=s=!1,u=1},point:function(f,d){var h,p=[f,d],g=e(f,d),v=i?g?0:a(f,d):g?a(f+(f<0?Fi:-Fi),d):0;if(!n&&(c=s=g)&&t.lineStart(),g!==s&&(h=r(n,p),(Me(n,h)||Me(p,h))&&(p[0]+=Ri,p[1]+=Ri,g=e(p[0],p[1]))),g!==s)u=0,g?(t.lineStart(),h=r(p,n),t.point(h[0],h[1])):(h=r(n,p),t.point(h[0],h[1]),t.lineEnd()),n=h;else if(l&&n&&i^g){var m;v&o||!(m=r(p,n,!0))||(u=0,i?(t.lineStart(),t.point(m[0][0],m[0][1]),t.point(m[1][0],m[1][1]),t.lineEnd()):(t.point(m[1][0],m[1][1]),t.lineEnd(),t.lineStart(),t.point(m[0][0],m[0][1])))}!g||n&&Me(n,p)||t.point(p[0],p[1]),n=p,s=g,o=v},lineEnd:function(){s&&t.lineEnd(),n=null},clean:function(){return u|(c&&s)<<1}}}function r(t,e,n){var r=me(t),a=me(e),i=[1,0,0],l=xe(r,a),s=ye(l,l),c=l[0],u=s-c*c;if(!u)return!n&&t;var f=o*s/u,d=-o*c/u,h=xe(i,l),p=_e(i,f),g=_e(l,d);be(p,g);var v=h,m=ye(p,v),y=ye(v,v),x=m*m-y*(ye(p,p)-1);if(!(x<0)){var b=Math.sqrt(x),_=_e(v,(-m-b)/y);if(be(_,p),_=ke(_),!n)return _;var w,k=t[0],M=e[0],A=t[1],T=e[1];M0^_[1]<(bi(_[0]-k)Fi^(k<=_[0]&&_[0]<=M)){var C=_e(v,(-m+b)/y);return be(C,p),[_,ke(C)]}}}function a(e,n){var r=i?t:Fi-t,a=0;return e<-r?a|=1:e>r&&(a|=2),n<-r?a|=4:n>r&&(a|=8),a}var o=Math.cos(t),i=o>0,l=bi(o)>Ri,s=mn(t,6*Vi);return je(e,n,s,i?[0,-t]:[-Fi,t-Fi])}function Ue(t,e,n,r){return function(a){var o,i=a.a,l=a.b,s=i.x,c=i.y,u=l.x,f=l.y,d=0,h=1,p=u-s,g=f-c;if(o=t-s,p||!(o>0)){if(o/=p,p<0){if(o0){if(o>h)return;o>d&&(d=o)}if(o=n-s,p||!(o<0)){if(o/=p,p<0){if(o>h)return;o>d&&(d=o)}else if(p>0){if(o0)){if(o/=g,g<0){if(o0){if(o>h)return;o>d&&(d=o)}if(o=r-c,g||!(o<0)){if(o/=g,g<0){if(o>h)return;o>d&&(d=o)}else if(g>0){if(o0&&(a.a={x:s+d*p,y:c+d*g}),h<1&&(a.b={x:s+h*p,y:c+h*g}),a}}}}}}function Ge(t,e,n,r){function a(r,a){return bi(r[0]-t)0?0:3:bi(r[0]-n)0?2:1:bi(r[1]-e)0?1:0:a>0?3:2}function o(t,e){return i(t.x,e.x)}function i(t,e){var n=a(t,1),r=a(e,1);return n!==r?n-r:0===n?e[1]-t[1]:1===n?t[0]-e[0]:2===n?t[1]-e[1]:e[0]-t[0]}return function(l){function s(t){for(var e=0,n=v.length,r=t[1],a=0;ar&&et(c,o,t)>0&&++e:o[1]<=r&&et(c,o,t)<0&&--e,c=o;return 0!==e}function c(o,l,s,c){var u=0,f=0;if(null==o||(u=a(o,s))!==(f=a(l,s))||i(o,l)<0^s>0){do c.point(0===u||3===u?t:n,u>1?r:e);while((u=(u+s+4)%4)!==f)}else c.point(l[0],l[1])}function u(a,o){return t<=a&&a<=n&&e<=o&&o<=r}function f(t,e){u(t,e)&&l.point(t,e)}function d(){S.point=p,v&&v.push(m=[]),M=!0,k=!1,_=w=NaN}function h(){g&&(p(y,x),b&&k&&L.rejoin(),g.push(L.buffer())),S.point=f,k&&l.lineEnd()}function p(t,e){t=Math.max(-ql,Math.min(ql,t)),e=Math.max(-ql,Math.min(ql,e));var n=u(t,e);if(v&&m.push([t,e]),M)y=t,x=e,b=n,M=!1,n&&(l.lineStart(),l.point(t,e));else if(n&&k)l.point(t,e);else{var r={a:{x:_,y:w},b:{x:t,y:e}};z(r)?(k||(l.lineStart(),l.point(r.a.x,r.a.y)),l.point(r.b.x,r.b.y),n||l.lineEnd(),A=!1):n&&(l.lineStart(),l.point(t,e),A=!1)}_=t,w=e,k=n}var g,v,m,y,x,b,_,w,k,M,A,T=l,L=Re(),z=Ue(t,e,n,r),S={point:f,lineStart:d,lineEnd:h,polygonStart:function(){l=L,g=[],v=[],A=!0},polygonEnd:function(){l=T,g=ui.merge(g);var e=s([t,r]),n=A&&e,a=g.length;(n||a)&&(l.polygonStart(),n&&(l.lineStart(),c(null,null,1,l),l.lineEnd()),a&&Ne(g,o,e,c,l),l.polygonEnd()),g=v=m=null}};return S}}function Ze(t){var e=0,n=Fi/3,r=cn(t),a=r(e,n);return a.parallels=function(t){return arguments.length?r(e=t[0]*Fi/180,n=t[1]*Fi/180):[e/Fi*180,n/Fi*180]},a}function Ye(t,e){function n(t,e){var n=Math.sqrt(o-2*a*Math.sin(e))/a;return[n*Math.sin(t*=a),i-n*Math.cos(t)]}var r=Math.sin(t),a=(r+Math.sin(e))/2,o=1+r*(2*a-r),i=Math.sqrt(o)/a;return n.invert=function(t,e){var n=i-e;return[Math.atan2(t,n)/a,rt((o-(t*t+n*n)*a*a)/(2*a))]},n}function Xe(){function t(t,e){Hl+=a*t-r*e,r=t,a=e}var e,n,r,a;Yl.point=function(o,i){Yl.point=t,e=r=o,n=a=i},Yl.lineEnd=function(){t(e,n)}}function Qe(t,e){tGl&&(Gl=t),eZl&&(Zl=e)}function $e(){function t(t,e){i.push("M",t,",",e,o)}function e(t,e){i.push("M",t,",",e),l.point=n}function n(t,e){i.push("L",t,",",e)}function r(){l.point=t}function a(){i.push("Z")}var o=We(4.5),i=[],l={point:t,lineStart:function(){l.point=e},lineEnd:r,polygonStart:function(){l.lineEnd=a},polygonEnd:function(){l.lineEnd=r,l.point=t},pointRadius:function(t){return o=We(t),l},result:function(){if(i.length){var t=i.join("");return i=[],t}}};return l}function We(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}function Je(t,e){Sl+=t,Cl+=e,++El}function Ke(){function t(t,r){var a=t-e,o=r-n,i=Math.sqrt(a*a+o*o);Nl+=i*(e+t)/2,Ol+=i*(n+r)/2,Pl+=i,Je(e=t,n=r)}var e,n;Ql.point=function(r,a){Ql.point=t,Je(e=r,n=a)}}function tn(){Ql.point=Je}function en(){function t(t,e){var n=t-r,o=e-a,i=Math.sqrt(n*n+o*o);Nl+=i*(r+t)/2,Ol+=i*(a+e)/2,Pl+=i,i=a*t-r*e,jl+=i*(r+t),Dl+=i*(a+e),Rl+=3*i,Je(r=t,a=e)}var e,n,r,a;Ql.point=function(o,i){Ql.point=t,Je(e=r=o,n=a=i)},Ql.lineEnd=function(){t(e,n)}}function nn(t){function e(e,n){t.moveTo(e+i,n),t.arc(e,n,i,0,qi)}function n(e,n){t.moveTo(e,n),l.point=r}function r(e,n){t.lineTo(e,n)}function a(){l.point=e}function o(){t.closePath()}var i=4.5,l={point:e,lineStart:function(){l.point=n},lineEnd:a,polygonStart:function(){l.lineEnd=o},polygonEnd:function(){l.lineEnd=a,l.point=e},pointRadius:function(t){return i=t,l},result:k};return l}function rn(t){function e(t){return(l?r:n)(t)}function n(e){return ln(e,function(n,r){n=t(n,r),e.point(n[0],n[1])})}function r(e){function n(n,r){n=t(n,r),e.point(n[0],n[1])}function r(){x=NaN,M.point=o,e.lineStart()}function o(n,r){var o=me([n,r]),i=t(n,r);a(x,b,y,_,w,k,x=i[0],b=i[1],y=n,_=o[0],w=o[1],k=o[2],l,e),e.point(x,b)}function i(){M.point=n,e.lineEnd()}function s(){r(),M.point=c,M.lineEnd=u}function c(t,e){o(f=t,d=e),h=x,p=b,g=_,v=w,m=k,M.point=o}function u(){a(x,b,y,_,w,k,h,p,f,g,v,m,l,e),M.lineEnd=i,i()}var f,d,h,p,g,v,m,y,x,b,_,w,k,M={point:n,lineStart:r,lineEnd:i,polygonStart:function(){e.polygonStart(),M.lineStart=s},polygonEnd:function(){e.polygonEnd(),M.lineStart=r}};return M}function a(e,n,r,l,s,c,u,f,d,h,p,g,v,m){var y=u-e,x=f-n,b=y*y+x*x;if(b>4*o&&v--){var _=l+h,w=s+p,k=c+g,M=Math.sqrt(_*_+w*w+k*k),A=Math.asin(k/=M),T=bi(bi(k)-1)o||bi((y*C+x*E)/b-.5)>.3||l*h+s*p+c*g0&&16,e):Math.sqrt(o)},e}function an(t){var e=rn(function(e,n){return t([e*Ui,n*Ui])});return function(t){return un(e(t))}}function on(t){this.stream=t}function ln(t,e){return{point:e,sphere:function(){t.sphere()},lineStart:function(){t.lineStart()},lineEnd:function(){t.lineEnd()},polygonStart:function(){t.polygonStart()},polygonEnd:function(){t.polygonEnd()}}}function sn(t){return cn(function(){return t})()}function cn(t){function e(t){return t=l(t[0]*Vi,t[1]*Vi),[t[0]*d+s,c-t[1]*d]}function n(t){return t=l.invert((t[0]-s)/d,(c-t[1])/d),t&&[t[0]*Ui,t[1]*Ui]}function r(){l=Ce(i=hn(m,y,x),o);var t=o(g,v);return s=h-t[0]*d,c=p+t[1]*d,a()}function a(){return u&&(u.valid=!1,u=null),e}var o,i,l,s,c,u,f=rn(function(t,e){return t=o(t,e),[t[0]*d+s,c-t[1]*d]}),d=150,h=480,p=250,g=0,v=0,m=0,y=0,x=0,_=Fl,w=b,k=null,M=null;return e.stream=function(t){return u&&(u.valid=!1),u=un(_(i,f(w(t)))),u.valid=!0,u},e.clipAngle=function(t){return arguments.length?(_=null==t?(k=t,Fl):Ve((k=+t)*Vi),a()):k},e.clipExtent=function(t){return arguments.length?(M=t,w=t?Ge(t[0][0],t[0][1],t[1][0],t[1][1]):b,a()):M},e.scale=function(t){return arguments.length?(d=+t,r()):d},e.translate=function(t){return arguments.length?(h=+t[0],p=+t[1],r()):[h,p]},e.center=function(t){return arguments.length?(g=t[0]%360*Vi,v=t[1]%360*Vi,r()):[g*Ui,v*Ui]},e.rotate=function(t){return arguments.length?(m=t[0]%360*Vi,y=t[1]%360*Vi,x=t.length>2?t[2]%360*Vi:0,r()):[m*Ui,y*Ui,x*Ui]},ui.rebind(e,f,"precision"),function(){return o=t.apply(this,arguments),e.invert=o.invert&&n,r()}}function un(t){return ln(t,function(e,n){t.point(e*Vi,n*Vi)})}function fn(t,e){return[t,e]}function dn(t,e){return[t>Fi?t-qi:t<-Fi?t+qi:t,e]}function hn(t,e,n){return t?e||n?Ce(gn(t),vn(e,n)):gn(t):e||n?vn(e,n):dn}function pn(t){return function(e,n){return e+=t,[e>Fi?e-qi:e<-Fi?e+qi:e,n]}}function gn(t){var e=pn(t);return e.invert=pn(-t),e}function vn(t,e){function n(t,e){var n=Math.cos(e),l=Math.cos(t)*n,s=Math.sin(t)*n,c=Math.sin(e),u=c*r+l*a;return[Math.atan2(s*o-u*i,l*r-c*a),rt(u*o+s*i)]}var r=Math.cos(t),a=Math.sin(t),o=Math.cos(e),i=Math.sin(e);return n.invert=function(t,e){var n=Math.cos(e),l=Math.cos(t)*n,s=Math.sin(t)*n,c=Math.sin(e),u=c*o-s*i;return[Math.atan2(s*o+c*i,l*r+u*a),rt(u*r-l*a)]},n}function mn(t,e){var n=Math.cos(t),r=Math.sin(t);return function(a,o,i,l){var s=i*e;null!=a?(a=yn(n,a),o=yn(n,o),(i>0?ao)&&(a+=i*qi)):(a=t+i*qi,o=t-.5*s);for(var c,u=a;i>0?u>o:u0?e<-Hi+Ri&&(e=-Hi+Ri):e>Hi-Ri&&(e=Hi-Ri);var n=i/Math.pow(a(e),o);return[n*Math.sin(o*t),i-n*Math.cos(o*t)]}var r=Math.cos(t),a=function(t){return Math.tan(Fi/4+t/2)},o=t===e?Math.sin(t):Math.log(r/Math.cos(e))/Math.log(a(e)/a(t)),i=r*Math.pow(a(t),o)/o;return o?(n.invert=function(t,e){var n=i-e,r=tt(o)*Math.sqrt(t*t+n*n);return[Math.atan2(t,n)/o,2*Math.atan(Math.pow(i/r,1/o))-Hi]},n):zn}function Ln(t,e){function n(t,e){var n=o-e;return[n*Math.sin(a*t),o-n*Math.cos(a*t)]}var r=Math.cos(t),a=t===e?Math.sin(t):(r-Math.cos(e))/(e-t),o=r/a+t;return bi(a)1&&et(t[n[r-2]],t[n[r-1]],t[a])<=0;)--r;n[r++]=a}return n.slice(0,r)}function Pn(t,e){return t[0]-e[0]||t[1]-e[1]}function jn(t,e,n){return(n[0]-e[0])*(t[1]-e[1])<(n[1]-e[1])*(t[0]-e[0])}function Dn(t,e,n,r){var a=t[0],o=n[0],i=e[0]-a,l=r[0]-o,s=t[1],c=n[1],u=e[1]-s,f=r[1]-c,d=(l*(s-c)-f*(a-o))/(f*i-l*u);return[a+d*i,s+d*u]}function Rn(t){var e=t[0],n=t[t.length-1];return!(e[0]-n[0]||e[1]-n[1])}function In(){or(this),this.edge=this.site=this.circle=null}function Fn(t){var e=cs.pop()||new In;return e.site=t,e}function qn(t){$n(t),is.remove(t),cs.push(t),or(t)}function Bn(t){var e=t.circle,n=e.x,r=e.cy,a={x:n,y:r},o=t.P,i=t.N,l=[t];qn(t);for(var s=o;s.circle&&bi(n-s.circle.x)Ri)l=l.L;else{if(a=o-Un(l,i),!(a>Ri)){r>-Ri?(e=l.P,n=l):a>-Ri?(e=l,n=l.N):e=n=l;break}if(!l.R){e=l;break}l=l.R}var s=Fn(t);if(is.insert(e,s),e||n){if(e===n)return $n(e),n=Fn(e.site),is.insert(s,n),s.edge=n.edge=tr(e.site,s.site),Qn(e),void Qn(n);if(!n)return void(s.edge=tr(e.site,s.site));$n(e),$n(n);var c=e.site,u=c.x,f=c.y,d=t.x-u,h=t.y-f,p=n.site,g=p.x-u,v=p.y-f,m=2*(d*v-h*g),y=d*d+h*h,x=g*g+v*v,b={x:(v*y-h*x)/m+u,y:(d*x-g*y)/m+f};nr(n.edge,c,p,b),s.edge=tr(c,t,null,b),n.edge=tr(t,p,null,b),Qn(e),Qn(n)}}function Vn(t,e){var n=t.site,r=n.x,a=n.y,o=a-e;if(!o)return r;var i=t.P;if(!i)return-(1/0);n=i.site;var l=n.x,s=n.y,c=s-e;if(!c)return l;var u=l-r,f=1/o-1/c,d=u/c;return f?(-d+Math.sqrt(d*d-2*f*(u*u/(-2*c)-s+c/2+a-o/2)))/f+r:(r+l)/2}function Un(t,e){var n=t.N;if(n)return Vn(n,e);var r=t.site;return r.y===e?r.x:1/0}function Gn(t){this.site=t,this.edges=[]}function Zn(t){for(var e,n,r,a,o,i,l,s,c,u,f=t[0][0],d=t[1][0],h=t[0][1],p=t[1][1],g=os,v=g.length;v--;)if(o=g[v],o&&o.prepare())for(l=o.edges,s=l.length,i=0;iRi||bi(a-n)>Ri)&&(l.splice(i,0,new rr(er(o.site,u,bi(r-f)Ri?{x:f,y:bi(e-f)Ri?{x:bi(n-p)Ri?{x:d,y:bi(e-d)Ri?{x:bi(n-h)=-Ii)){var h=s*s+c*c,p=u*u+f*f,g=(f*h-c*p)/d,v=(s*p-u*h)/d,f=v+l,m=us.pop()||new Xn;m.arc=t,m.site=a,m.x=g+i,m.y=f+Math.sqrt(g*g+v*v),m.cy=f,t.circle=m;for(var y=null,x=ss._;x;)if(m.y=l)return;if(d>p){if(o){if(o.y>=c)return}else o={x:v,y:s};n={x:v,y:c}}else{if(o){if(o.y1)if(d>p){if(o){if(o.y>=c)return}else o={x:(s-a)/r,y:s};n={x:(c-a)/r,y:c}}else{if(o){if(o.y=l)return}else o={x:i,y:r*i+a};n={x:l,y:r*l+a}}else{if(o){if(o.xo||f>i||d=b,k=n>=_,M=k<<1|w,A=M+4;Mo&&(a=e.slice(o,a),l[i]?l[i]+=a:l[++i]=a),(n=n[0])===(r=r[0])?l[i]?l[i]+=r:l[++i]=r:(l[++i]=null,s.push({i:i,x:xr(n,r)})),o=hs.lastIndex;return o=0&&!(n=ui.interpolators[r](t,e)););return n}function wr(t,e){var n,r=[],a=[],o=t.length,i=e.length,l=Math.min(t.length,e.length);for(n=0;n=1?1:t(e)}}function Mr(t){return function(e){return 1-t(1-e)}}function Ar(t){return function(e){return.5*(e<.5?t(2*e):2-t(2-2*e))}}function Tr(t){return t*t}function Lr(t){return t*t*t}function zr(t){if(t<=0)return 0;if(t>=1)return 1;var e=t*t,n=e*t;return 4*(t<.5?n:3*(t-e)+n-.75)}function Sr(t){return function(e){return Math.pow(e,t)}}function Cr(t){return 1-Math.cos(t*Hi)}function Er(t){return Math.pow(2,10*(t-1)); ++}function Nr(t){return 1-Math.sqrt(1-t*t)}function Or(t,e){var n;return arguments.length<2&&(e=.45),arguments.length?n=e/qi*Math.asin(1/t):(t=1,n=e/4),function(r){return 1+t*Math.pow(2,-10*r)*Math.sin((r-n)*qi/e)}}function Pr(t){return t||(t=1.70158),function(e){return e*e*((t+1)*e-t)}}function jr(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}function Dr(t,e){t=ui.hcl(t),e=ui.hcl(e);var n=t.h,r=t.c,a=t.l,o=e.h-n,i=e.c-r,l=e.l-a;return isNaN(i)&&(i=0,r=isNaN(r)?e.c:r),isNaN(o)?(o=0,n=isNaN(n)?e.h:n):o>180?o-=360:o<-180&&(o+=360),function(t){return dt(n+o*t,r+i*t,a+l*t)+""}}function Rr(t,e){t=ui.hsl(t),e=ui.hsl(e);var n=t.h,r=t.s,a=t.l,o=e.h-n,i=e.s-r,l=e.l-a;return isNaN(i)&&(i=0,r=isNaN(r)?e.s:r),isNaN(o)?(o=0,n=isNaN(n)?e.h:n):o>180?o-=360:o<-180&&(o+=360),function(t){return ut(n+o*t,r+i*t,a+l*t)+""}}function Ir(t,e){t=ui.lab(t),e=ui.lab(e);var n=t.l,r=t.a,a=t.b,o=e.l-n,i=e.a-r,l=e.b-a;return function(t){return pt(n+o*t,r+i*t,a+l*t)+""}}function Fr(t,e){return e-=t,function(n){return Math.round(t+e*n)}}function qr(t){var e=[t.a,t.b],n=[t.c,t.d],r=Hr(e),a=Br(e,n),o=Hr(Vr(n,e,-a))||0;e[0]*n[1]180?e+=360:e-t>180&&(t+=360),r.push({i:n.push(Ur(n)+"rotate(",null,")")-2,x:xr(t,e)})):e&&n.push(Ur(n)+"rotate("+e+")")}function Yr(t,e,n,r){t!==e?r.push({i:n.push(Ur(n)+"skewX(",null,")")-2,x:xr(t,e)}):e&&n.push(Ur(n)+"skewX("+e+")")}function Xr(t,e,n,r){if(t[0]!==e[0]||t[1]!==e[1]){var a=n.push(Ur(n)+"scale(",null,",",null,")");r.push({i:a-4,x:xr(t[0],e[0])},{i:a-2,x:xr(t[1],e[1])})}else 1===e[0]&&1===e[1]||n.push(Ur(n)+"scale("+e+")")}function Qr(t,e){var n=[],r=[];return t=ui.transform(t),e=ui.transform(e),Gr(t.translate,e.translate,n,r),Zr(t.rotate,e.rotate,n,r),Yr(t.skew,e.skew,n,r),Xr(t.scale,e.scale,n,r),t=e=null,function(t){for(var e,a=-1,o=r.length;++a=0;)n.push(a[r])}function sa(t,e){for(var n=[t],r=[];null!=(t=n.pop());)if(r.push(t),(o=t.children)&&(a=o.length))for(var a,o,i=-1;++ia&&(r=n,a=e);return r}function xa(t){return t.reduce(ba,0)}function ba(t,e){return t+e[1]}function _a(t,e){return wa(t,Math.ceil(Math.log(e.length)/Math.LN2+1))}function wa(t,e){for(var n=-1,r=+t[0],a=(t[1]-r)/e,o=[];++n<=e;)o[n]=a*n+r;return o}function ka(t){return[ui.min(t),ui.max(t)]}function Ma(t,e){return t.value-e.value}function Aa(t,e){var n=t._pack_next;t._pack_next=e,e._pack_prev=t,e._pack_next=n,n._pack_prev=e}function Ta(t,e){t._pack_next=e,e._pack_prev=t}function La(t,e){var n=e.x-t.x,r=e.y-t.y,a=t.r+e.r;return.999*a*a>n*n+r*r}function za(t){function e(t){u=Math.min(t.x-t.r,u),f=Math.max(t.x+t.r,f),d=Math.min(t.y-t.r,d),h=Math.max(t.y+t.r,h)}if((n=t.children)&&(c=n.length)){var n,r,a,o,i,l,s,c,u=1/0,f=-(1/0),d=1/0,h=-(1/0);if(n.forEach(Sa),r=n[0],r.x=-r.r,r.y=0,e(r),c>1&&(a=n[1],a.x=a.r,a.y=0,e(a),c>2))for(o=n[2],Na(r,a,o),e(o),Aa(r,o),r._pack_prev=o,Aa(o,a),a=r._pack_next,i=3;i=0;)e=a[o],e.z+=n,e.m+=n,n+=e.s+(r+=e.c)}function Ia(t,e,n){return t.a.parent===e.parent?t.a:n}function Fa(t){return 1+ui.max(t,function(t){return t.y})}function qa(t){return t.reduce(function(t,e){return t+e.x},0)/t.length}function Ba(t){var e=t.children;return e&&e.length?Ba(e[0]):t}function Ha(t){var e,n=t.children;return n&&(e=n.length)?Ha(n[e-1]):t}function Va(t){return{x:t.x,y:t.y,dx:t.dx,dy:t.dy}}function Ua(t,e){var n=t.x+e[3],r=t.y+e[0],a=t.dx-e[1]-e[3],o=t.dy-e[0]-e[2];return a<0&&(n+=a/2,a=0),o<0&&(r+=o/2,o=0),{x:n,y:r,dx:a,dy:o}}function Ga(t){var e=t[0],n=t[t.length-1];return e2?$a:Ya,s=r?Wr:$r;return i=a(t,e,s,n),l=a(e,t,s,_r),o}function o(t){return i(t)}var i,l;return o.invert=function(t){return l(t)},o.domain=function(e){return arguments.length?(t=e.map(Number),a()):t},o.range=function(t){return arguments.length?(e=t,a()):e},o.rangeRound=function(t){return o.range(t).interpolate(Fr)},o.clamp=function(t){return arguments.length?(r=t,a()):r},o.interpolate=function(t){return arguments.length?(n=t,a()):n},o.ticks=function(e){return eo(t,e)},o.tickFormat=function(e,n){return no(t,e,n)},o.nice=function(e){return Ka(t,e),a()},o.copy=function(){return Wa(t,e,n,r)},a()}function Ja(t,e){return ui.rebind(t,e,"range","rangeRound","interpolate","clamp")}function Ka(t,e){return Xa(t,Qa(to(t,e)[2])),Xa(t,Qa(to(t,e)[2])),t}function to(t,e){null==e&&(e=10);var n=Ga(t),r=n[1]-n[0],a=Math.pow(10,Math.floor(Math.log(r/e)/Math.LN10)),o=e/r*a;return o<=.15?a*=10:o<=.35?a*=5:o<=.75&&(a*=2),n[0]=Math.ceil(n[0]/a)*a,n[1]=Math.floor(n[1]/a)*a+.5*a,n[2]=a,n}function eo(t,e){return ui.range.apply(ui,to(t,e))}function no(t,e,n){var r=to(t,e);if(n){var a=dl.exec(n);if(a.shift(),"s"===a[8]){var o=ui.formatPrefix(Math.max(bi(r[0]),bi(r[1])));return a[7]||(a[7]="."+ro(o.scale(r[2]))),a[8]="f",n=ui.format(a.join("")),function(t){return n(o.scale(t))+o.symbol}}a[7]||(a[7]="."+ao(a[8],r)),n=a.join("")}else n=",."+ro(r[2])+"f";return ui.format(n)}function ro(t){return-Math.floor(Math.log(t)/Math.LN10+.01)}function ao(t,e){var n=ro(e[2]);return t in As?Math.abs(n-ro(Math.max(bi(e[0]),bi(e[1]))))+ +("e"!==t):n-2*("%"===t)}function oo(t,e,n,r){function a(t){return(n?Math.log(t<0?0:t):-Math.log(t>0?0:-t))/Math.log(e)}function o(t){return n?Math.pow(e,t):-Math.pow(e,-t)}function i(e){return t(a(e))}return i.invert=function(e){return o(t.invert(e))},i.domain=function(e){return arguments.length?(n=e[0]>=0,t.domain((r=e.map(Number)).map(a)),i):r},i.base=function(n){return arguments.length?(e=+n,t.domain(r.map(a)),i):e},i.nice=function(){var e=Xa(r.map(a),n?Math:Ls);return t.domain(e),r=e.map(o),i},i.ticks=function(){var t=Ga(r),i=[],l=t[0],s=t[1],c=Math.floor(a(l)),u=Math.ceil(a(s)),f=e%1?2:e;if(isFinite(u-c)){if(n){for(;c0;d--)i.push(o(c)*d);for(c=0;i[c]s;u--);i=i.slice(c,u)}return i},i.tickFormat=function(t,n){if(!arguments.length)return Ts;arguments.length<2?n=Ts:"function"!=typeof n&&(n=ui.format(n));var r=Math.max(1,e*t/i.ticks().length);return function(t){var i=t/o(Math.round(a(t)));return i*e0?l[n-1]:t[0],n0?0:1}function _o(t,e,n,r,a){var o=t[0]-e[0],i=t[1]-e[1],l=(a?r:-r)/Math.sqrt(o*o+i*i),s=l*i,c=-l*o,u=t[0]+s,f=t[1]+c,d=e[0]+s,h=e[1]+c,p=(u+d)/2,g=(f+h)/2,v=d-u,m=h-f,y=v*v+m*m,x=n-r,b=u*h-d*f,_=(m<0?-1:1)*Math.sqrt(Math.max(0,x*x*y-b*b)),w=(b*m-v*_)/y,k=(-b*v-m*_)/y,M=(b*m+v*_)/y,A=(-b*v+m*_)/y,T=w-p,L=k-g,z=M-p,S=A-g;return T*T+L*L>z*z+S*S&&(w=M,k=A),[[w-s,k-c],[w*n/x,k*n/x]]}function wo(t){function e(e){function i(){c.push("M",o(t(u),l))}for(var s,c=[],u=[],f=-1,d=e.length,h=zt(n),p=zt(r);++f1?t.join("L"):t+"Z"}function Mo(t){return t.join("L")+"Z"}function Ao(t){for(var e=0,n=t.length,r=t[0],a=[r[0],",",r[1]];++e1&&a.push("H",r[0]),a.join("")}function To(t){for(var e=0,n=t.length,r=t[0],a=[r[0],",",r[1]];++e1){l=e[1],o=t[s],s++,r+="C"+(a[0]+i[0])+","+(a[1]+i[1])+","+(o[0]-l[0])+","+(o[1]-l[1])+","+o[0]+","+o[1];for(var c=2;c9&&(a=3*e/Math.sqrt(a),i[l]=a*n,i[l+1]=a*r));for(l=-1;++l<=s;)a=(t[Math.min(s,l+1)][0]-t[Math.max(0,l-1)][0])/(6*(1+i[l]*i[l])),o.push([a||0,i[l]*a||0]);return o}function Ho(t){return t.length<3?ko(t):t[0]+Eo(t,Bo(t))}function Vo(t){for(var e,n,r,a=-1,o=t.length;++a0;)h[--l].call(t,i);if(o>=1)return g.event&&g.event.end.call(t,t.__data__,e),--p.count?delete p[r]:delete t[n],1}var s,c,u,d,h,p=t[n]||(t[n]={active:0,count:0}),g=p[r];g||(s=a.time,c=Ot(o,0,s),g=p[r]={tween:new f,time:s,timer:c,delay:a.delay,duration:a.duration,ease:a.ease,index:e},a=null,++p.count)}function ri(t,e,n){t.attr("transform",function(t){var r=e(t);return"translate("+(isFinite(r)?r:n(t))+",0)"})}function ai(t,e,n){t.attr("transform",function(t){var r=e(t);return"translate(0,"+(isFinite(r)?r:n(t))+")"})}function oi(t){return t.toISOString()}function ii(t,e,n){function r(e){return t(e)}function a(t,n){var r=t[1]-t[0],a=r/n,o=ui.bisect(Js,a);return o==Js.length?[e.year,to(t.map(function(t){return t/31536e6}),n)[2]]:o?e[a/Js[o-1]1?{floor:function(e){for(;n(e=t.floor(e));)e=li(e-1);return e},ceil:function(e){for(;n(e=t.ceil(e));)e=li(+e+1);return e}}:t))},r.ticks=function(t,e){var n=Ga(r.domain()),o=null==t?a(n,10):"number"==typeof t?a(n,t):!t.range&&[{range:t},e];return o&&(t=o[0],e=o[1]),t.range(n[0],li(+n[1]+1),e<1?1:e)},r.tickFormat=function(){return n},r.copy=function(){return ii(t.copy(),e,n)},Ja(r,t)}function li(t){return new Date(t)}function si(t){return JSON.parse(t.responseText)}function ci(t){var e=hi.createRange();return e.selectNode(hi.body),e.createContextualFragment(t.responseText)}var ui={version:"3.5.17"},fi=[].slice,di=function(t){return fi.call(t)},hi=this.document;if(hi)try{di(hi.documentElement.childNodes)[0].nodeType}catch(t){di=function(t){for(var e=t.length,n=new Array(e);e--;)n[e]=t[e];return n}}if(Date.now||(Date.now=function(){return+new Date}),hi)try{hi.createElement("DIV").style.setProperty("opacity",0,"")}catch(t){var pi=this.Element.prototype,gi=pi.setAttribute,vi=pi.setAttributeNS,mi=this.CSSStyleDeclaration.prototype,yi=mi.setProperty;pi.setAttribute=function(t,e){gi.call(this,t,e+"")},pi.setAttributeNS=function(t,e,n){vi.call(this,t,e,n+"")},mi.setProperty=function(t,e,n){yi.call(this,t,e+"",n)}}ui.ascending=a,ui.descending=function(t,e){return et?1:e>=t?0:NaN},ui.min=function(t,e){var n,r,a=-1,o=t.length;if(1===arguments.length){for(;++a=r){n=r;break}for(;++ar&&(n=r)}else{for(;++a=r){n=r;break}for(;++ar&&(n=r)}return n},ui.max=function(t,e){var n,r,a=-1,o=t.length;if(1===arguments.length){for(;++a=r){n=r;break}for(;++an&&(n=r)}else{for(;++a=r){n=r;break}for(;++an&&(n=r)}return n},ui.extent=function(t,e){var n,r,a,o=-1,i=t.length;if(1===arguments.length){for(;++o=r){n=a=r;break}for(;++or&&(n=r),a=r){n=a=r;break}for(;++or&&(n=r),a1)return s/(u-1)},ui.deviation=function(){var t=ui.variance.apply(this,arguments);return t?Math.sqrt(t):t};var xi=l(a);ui.bisectLeft=xi.left,ui.bisect=ui.bisectRight=xi.right,ui.bisector=function(t){return l(1===t.length?function(e,n){return a(t(e),n)}:t)},ui.shuffle=function(t,e,n){(o=arguments.length)<3&&(n=t.length,o<2&&(e=0));for(var r,a,o=n-e;o;)a=Math.random()*o--|0,r=t[o+e],t[o+e]=t[a+e],t[a+e]=r;return t},ui.permute=function(t,e){for(var n=e.length,r=new Array(n);n--;)r[n]=t[e[n]];return r},ui.pairs=function(t){for(var e,n=0,r=t.length-1,a=t[0],o=new Array(r<0?0:r);n=0;)for(r=t[a],e=r.length;--e>=0;)n[--i]=r[e];return n};var bi=Math.abs;ui.range=function(t,e,n){if(arguments.length<3&&(n=1,arguments.length<2&&(e=t,t=0)),(e-t)/n===1/0)throw new Error("infinite range");var r,a=[],o=c(bi(n)),i=-1;if(t*=o,e*=o,n*=o,n<0)for(;(r=t+n*++i)>e;)a.push(r/o);else for(;(r=t+n*++i)=o.length)return r?r.call(a,i):n?i.sort(n):i;for(var s,c,u,d,h=-1,p=i.length,g=o[l++],v=new f;++h=o.length)return t;var r=[],a=i[n++];return t.forEach(function(t,a){r.push({key:t,values:e(a,n)})}),a?r.sort(function(t,e){return a(t.key,e.key)}):r}var n,r,a={},o=[],i=[];return a.map=function(e,n){return t(n,e,0)},a.entries=function(n){return e(t(ui.map,n,0),0)},a.key=function(t){return o.push(t),a},a.sortKeys=function(t){return i[o.length-1]=t,a},a.sortValues=function(t){return n=t,a},a.rollup=function(t){return r=t,a},a},ui.set=function(t){var e=new x;if(t)for(var n=0,r=t.length;n=0&&(r=t.slice(n+1),t=t.slice(0,n)),t)return arguments.length<2?this[t].on(r):this[t].on(r,e);if(2===arguments.length){if(null==e)for(t in this)this.hasOwnProperty(t)&&this[t].on(r,null);return this}},ui.event=null,ui.requote=function(t){return t.replace(Mi,"\\$&")};var Mi=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,Ai={}.__proto__?function(t,e){t.__proto__=e}:function(t,e){for(var n in e)t[n]=e[n]},Ti=function(t,e){return e.querySelector(t)},Li=function(t,e){return e.querySelectorAll(t)},zi=function(t,e){var n=t.matches||t[w(t,"matchesSelector")];return(zi=function(t,e){return n.call(t,e)})(t,e)};"function"==typeof Sizzle&&(Ti=function(t,e){return Sizzle(t,e)[0]||null},Li=Sizzle,zi=Sizzle.matchesSelector),ui.selection=function(){return ui.select(hi.documentElement)};var Si=ui.selection.prototype=[];Si.select=function(t){var e,n,r,a,o=[];t=C(t);for(var i=-1,l=this.length;++i=0&&"xmlns"!==(n=t.slice(0,e))&&(t=t.slice(e+1)),Ei.hasOwnProperty(n)?{space:Ei[n],local:t}:t}},Si.attr=function(t,e){if(arguments.length<2){if("string"==typeof t){var n=this.node();return t=ui.ns.qualify(t),t.local?n.getAttributeNS(t.space,t.local):n.getAttribute(t)}for(e in t)this.each(N(e,t[e]));return this}return this.each(N(t,e))},Si.classed=function(t,e){if(arguments.length<2){if("string"==typeof t){var n=this.node(),r=(t=j(t)).length,a=-1;if(e=n.classList){for(;++a=0;)(n=r[a])&&(o&&o!==n.nextSibling&&o.parentNode.insertBefore(n,o),o=n);return this},Si.sort=function(t){t=U.apply(this,arguments);for(var e=-1,n=this.length;++e0&&(e=e.transition().duration(S)),e.call(t.event)}function l(){_&&_.domain(b.range().map(function(t){return(t-M.x)/M.k}).map(b.invert)),k&&k.domain(w.range().map(function(t){return(t-M.y)/M.k}).map(w.invert))}function s(t){C++||t({type:"zoomstart"})}function c(t){l(),t({type:"zoom",scale:M.k,translate:[M.x,M.y]})}function u(t){--C||(t({type:"zoomend"}),v=null)}function f(){function t(){l=1,o(ui.mouse(a),d),c(i)}function n(){f.on(N,null).on(O,null),h(l),u(i)}var a=this,i=j.of(a,arguments),l=0,f=ui.select(r(a)).on(N,t).on(O,n),d=e(ui.mouse(a)),h=W(a);Hs.call(a),s(i)}function d(){function t(){var t=ui.touches(p);return h=M.k,t.forEach(function(t){t.identifier in v&&(v[t.identifier]=e(t))}),t}function n(){var e=ui.event.target;ui.select(e).on(b,r).on(_,l),w.push(e);for(var n=ui.event.changedTouches,a=0,o=n.length;a1){var u=s[0],f=s[1],d=u[0]-f[0],h=u[1]-f[1];m=d*d+h*h}}function r(){var t,e,n,r,i=ui.touches(p);Hs.call(p);for(var l=0,s=i.length;l=c)return i;if(a)return a=!1,o;var e=u;if(34===t.charCodeAt(e)){for(var n=e;n++=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,hl=ui.map({b:function(t){return t.toString(2)},c:function(t){return String.fromCharCode(t)},o:function(t){return t.toString(8)},x:function(t){return t.toString(16)},X:function(t){return t.toString(16).toUpperCase()},g:function(t,e){return t.toPrecision(e)},e:function(t,e){return t.toExponential(e)},f:function(t,e){return t.toFixed(e)},r:function(t,e){return(t=ui.round(t,Rt(t,e))).toFixed(Math.max(0,Math.min(20,Rt(t*(1+1e-15),e))))}}),pl=ui.time={},gl=Date;Bt.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){vl.setUTCDate.apply(this._,arguments)},setDay:function(){vl.setUTCDay.apply(this._,arguments)},setFullYear:function(){vl.setUTCFullYear.apply(this._,arguments)},setHours:function(){vl.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){vl.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){vl.setUTCMinutes.apply(this._,arguments)},setMonth:function(){vl.setUTCMonth.apply(this._,arguments)},setSeconds:function(){vl.setUTCSeconds.apply(this._,arguments)},setTime:function(){vl.setTime.apply(this._,arguments)}};var vl=Date.prototype;pl.year=Ht(function(t){return t=pl.day(t),t.setMonth(0,1),t},function(t,e){t.setFullYear(t.getFullYear()+e)},function(t){return t.getFullYear()}),pl.years=pl.year.range,pl.years.utc=pl.year.utc.range,pl.day=Ht(function(t){var e=new gl(2e3,0);return e.setFullYear(t.getFullYear(),t.getMonth(),t.getDate()),e},function(t,e){t.setDate(t.getDate()+e)},function(t){return t.getDate()-1}),pl.days=pl.day.range,pl.days.utc=pl.day.utc.range,pl.dayOfYear=function(t){var e=pl.year(t);return Math.floor((t-e-6e4*(t.getTimezoneOffset()-e.getTimezoneOffset()))/864e5)},["sunday","monday","tuesday","wednesday","thursday","friday","saturday"].forEach(function(t,e){e=7-e;var n=pl[t]=Ht(function(t){return(t=pl.day(t)).setDate(t.getDate()-(t.getDay()+e)%7),t},function(t,e){t.setDate(t.getDate()+7*Math.floor(e))},function(t){var n=pl.year(t).getDay();return Math.floor((pl.dayOfYear(t)+(n+e)%7)/7)-(n!==e)});pl[t+"s"]=n.range,pl[t+"s"].utc=n.utc.range,pl[t+"OfYear"]=function(t){var n=pl.year(t).getDay();return Math.floor((pl.dayOfYear(t)+(n+e)%7)/7)}}),pl.week=pl.sunday,pl.weeks=pl.sunday.range,pl.weeks.utc=pl.sunday.utc.range,pl.weekOfYear=pl.sundayOfYear;var ml={"-":"",_:" ",0:"0"},yl=/^\s*\d+/,xl=/^%/;ui.locale=function(t){return{numberFormat:Ft(t),timeFormat:Ut(t)}};var bl=ui.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});ui.format=bl.numberFormat,ui.geo={},fe.prototype={s:0,t:0,add:function(t){de(t,this.t,_l),de(_l.s,this.s,this),this.s?this.t+=_l.t:this.s=_l.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var _l=new fe;ui.geo.stream=function(t,e){t&&wl.hasOwnProperty(t.type)?wl[t.type](t,e):he(t,e)};var wl={Feature:function(t,e){he(t.geometry,e)},FeatureCollection:function(t,e){for(var n=t.features,r=-1,a=n.length;++rh&&(h=e)}function e(e,n){var r=me([e*Vi,n*Vi]);if(m){var a=xe(m,r),o=[a[1],-a[0],0],i=xe(o,a);we(i),i=ke(i);var s=e-p,c=s>0?1:-1,g=i[0]*Ui*c,v=bi(s)>180;if(v^(c*ph&&(h=y)}else if(g=(g+360)%360-180,v^(c*ph&&(h=n);v?el(u,d)&&(d=e):l(e,d)>l(u,d)&&(u=e):d>=u?(ed&&(d=e)):e>p?l(u,e)>l(u,d)&&(d=e):l(e,d)>l(u,d)&&(u=e)}else t(e,n);m=r,p=e}function n(){_.point=e}function r(){b[0]=u,b[1]=d,_.point=t,m=null}function a(t,n){if(m){var r=t-p;y+=bi(r)>180?r+(r>0?360:-360):r}else g=t,v=n;Tl.point(t,n),e(t,n)}function o(){Tl.lineStart()}function i(){a(g,v),Tl.lineEnd(),bi(y)>Ri&&(u=-(d=180)),b[0]=u,b[1]=d,m=null}function l(t,e){return(e-=t)<0?e+360:e}function s(t,e){return t[0]-e[0]}function c(t,e){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:tRi?h=90:y<-Ri&&(f=-90),b[0]=u,b[1]=d}};return function(t){h=d=-(u=f=1/0),x=[],ui.geo.stream(t,_);var e=x.length;if(e){x.sort(s);for(var n,r=1,a=x[0],o=[a];rl(a[0],a[1])&&(a[1]=n[1]),l(n[0],a[1])>l(a[0],a[1])&&(a[0]=n[0])):o.push(a=n);for(var i,n,p=-(1/0),e=o.length-1,r=0,a=o[e];r<=e;a=n,++r)n=o[r],(i=l(a[1],n[0]))>p&&(p=i,u=n[0],d=a[1])}return x=b=null,u===1/0||f===1/0?[[NaN,NaN],[NaN,NaN]]:[[u,f],[d,h]]}}(),ui.geo.centroid=function(t){Ll=zl=Sl=Cl=El=Nl=Ol=Pl=jl=Dl=Rl=0,ui.geo.stream(t,Il);var e=jl,n=Dl,r=Rl,a=e*e+n*n+r*r;return a=.12&&a<.234&&r>=-.425&&r<-.214?i:a>=.166&&a<.234&&r>=-.214&&r<-.115?l:o).invert(t)},t.stream=function(t){var e=o.stream(t),n=i.stream(t),r=l.stream(t);return{point:function(t,a){e.point(t,a),n.point(t,a),r.point(t,a)},sphere:function(){e.sphere(),n.sphere(),r.sphere()},lineStart:function(){e.lineStart(),n.lineStart(),r.lineStart()},lineEnd:function(){e.lineEnd(),n.lineEnd(),r.lineEnd()},polygonStart:function(){e.polygonStart(),n.polygonStart(),r.polygonStart()},polygonEnd:function(){e.polygonEnd(),n.polygonEnd(),r.polygonEnd()}}},t.precision=function(e){return arguments.length?(o.precision(e),i.precision(e),l.precision(e),t):o.precision()},t.scale=function(e){return arguments.length?(o.scale(e),i.scale(.35*e),l.scale(e),t.translate(o.translate())):o.scale()},t.translate=function(e){if(!arguments.length)return o.translate();var c=o.scale(),u=+e[0],f=+e[1];return n=o.translate(e).clipExtent([[u-.455*c,f-.238*c],[u+.455*c,f+.238*c]]).stream(s).point,r=i.translate([u-.307*c,f+.201*c]).clipExtent([[u-.425*c+Ri,f+.12*c+Ri],[u-.214*c-Ri,f+.234*c-Ri]]).stream(s).point,a=l.translate([u-.205*c,f+.212*c]).clipExtent([[u-.214*c+Ri,f+.166*c+Ri],[u-.115*c-Ri,f+.234*c-Ri]]).stream(s).point,t},t.scale(1070)};var Bl,Hl,Vl,Ul,Gl,Zl,Yl={point:k,lineStart:k,lineEnd:k,polygonStart:function(){Hl=0,Yl.lineStart=Xe},polygonEnd:function(){Yl.lineStart=Yl.lineEnd=Yl.point=k,Bl+=bi(Hl/2)}},Xl={point:Qe,lineStart:k,lineEnd:k,polygonStart:k,polygonEnd:k},Ql={point:Je,lineStart:Ke,lineEnd:tn,polygonStart:function(){Ql.lineStart=en},polygonEnd:function(){Ql.point=Je,Ql.lineStart=Ke,Ql.lineEnd=tn}};ui.geo.path=function(){function t(t){return t&&("function"==typeof l&&o.pointRadius(+l.apply(this,arguments)),i&&i.valid||(i=a(o)),ui.geo.stream(t,i)),o.result()}function e(){return i=null,t}var n,r,a,o,i,l=4.5;return t.area=function(t){return Bl=0,ui.geo.stream(t,a(Yl)),Bl},t.centroid=function(t){return Sl=Cl=El=Nl=Ol=Pl=jl=Dl=Rl=0,ui.geo.stream(t,a(Ql)),Rl?[jl/Rl,Dl/Rl]:Pl?[Nl/Pl,Ol/Pl]:El?[Sl/El,Cl/El]:[NaN,NaN]},t.bounds=function(t){return Gl=Zl=-(Vl=Ul=1/0),ui.geo.stream(t,a(Xl)),[[Vl,Ul],[Gl,Zl]]},t.projection=function(t){return arguments.length?(a=(n=t)?t.stream||an(t):b,e()):n},t.context=function(t){return arguments.length?(o=null==(r=t)?new $e:new nn(t),"function"!=typeof l&&o.pointRadius(l),e()):r},t.pointRadius=function(e){return arguments.length?(l="function"==typeof e?e:(o.pointRadius(+e),+e),t):l},t.projection(ui.geo.albersUsa()).context(null)},ui.geo.transform=function(t){return{stream:function(e){var n=new on(e);for(var r in t)n[r]=t[r];return n}}},on.prototype={point:function(t,e){this.stream.point(t,e)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}},ui.geo.projection=sn,ui.geo.projectionMutator=cn,(ui.geo.equirectangular=function(){return sn(fn)}).raw=fn.invert=fn,ui.geo.rotation=function(t){function e(e){return e=t(e[0]*Vi,e[1]*Vi),e[0]*=Ui,e[1]*=Ui,e}return t=hn(t[0]%360*Vi,t[1]*Vi,t.length>2?t[2]*Vi:0),e.invert=function(e){return e=t.invert(e[0]*Vi,e[1]*Vi),e[0]*=Ui,e[1]*=Ui,e},e},dn.invert=fn,ui.geo.circle=function(){function t(){var t="function"==typeof r?r.apply(this,arguments):r,e=hn(-t[0]*Vi,-t[1]*Vi,0).invert,a=[];return n(null,null,1,{point:function(t,n){a.push(t=e(t,n)),t[0]*=Ui,t[1]*=Ui}}),{type:"Polygon",coordinates:[a]}}var e,n,r=[0,0],a=6;return t.origin=function(e){return arguments.length?(r=e,t):r},t.angle=function(r){return arguments.length?(n=mn((e=+r)*Vi,a*Vi),t):e},t.precision=function(r){return arguments.length?(n=mn(e*Vi,(a=+r)*Vi),t):a},t.angle(90)},ui.geo.distance=function(t,e){var n,r=(e[0]-t[0])*Vi,a=t[1]*Vi,o=e[1]*Vi,i=Math.sin(r),l=Math.cos(r),s=Math.sin(a),c=Math.cos(a),u=Math.sin(o),f=Math.cos(o);return Math.atan2(Math.sqrt((n=f*i)*n+(n=c*u-s*f*l)*n),s*u+c*f*l)},ui.geo.graticule=function(){function t(){return{type:"MultiLineString",coordinates:e()}}function e(){return ui.range(Math.ceil(o/v)*v,a,v).map(d).concat(ui.range(Math.ceil(c/m)*m,s,m).map(h)).concat(ui.range(Math.ceil(r/p)*p,n,p).filter(function(t){return bi(t%v)>Ri}).map(u)).concat(ui.range(Math.ceil(l/g)*g,i,g).filter(function(t){return bi(t%m)>Ri}).map(f))}var n,r,a,o,i,l,s,c,u,f,d,h,p=10,g=p,v=90,m=360,y=2.5;return t.lines=function(){return e().map(function(t){return{type:"LineString",coordinates:t}})},t.outline=function(){return{type:"Polygon",coordinates:[d(o).concat(h(s).slice(1),d(a).reverse().slice(1),h(c).reverse().slice(1))]}},t.extent=function(e){return arguments.length?t.majorExtent(e).minorExtent(e):t.minorExtent()},t.majorExtent=function(e){return arguments.length?(o=+e[0][0],a=+e[1][0],c=+e[0][1],s=+e[1][1],o>a&&(e=o,o=a,a=e),c>s&&(e=c,c=s,s=e),t.precision(y)):[[o,c],[a,s]]},t.minorExtent=function(e){return arguments.length?(r=+e[0][0],n=+e[1][0],l=+e[0][1],i=+e[1][1],r>n&&(e=r,r=n,n=e),l>i&&(e=l,l=i,i=e),t.precision(y)):[[r,l],[n,i]]},t.step=function(e){return arguments.length?t.majorStep(e).minorStep(e):t.minorStep()},t.majorStep=function(e){return arguments.length?(v=+e[0],m=+e[1],t):[v,m]},t.minorStep=function(e){return arguments.length?(p=+e[0],g=+e[1],t):[p,g]},t.precision=function(e){return arguments.length?(y=+e,u=xn(l,i,90),f=bn(r,n,y),d=xn(c,s,90),h=bn(o,a,y),t):y},t.majorExtent([[-180,-90+Ri],[180,90-Ri]]).minorExtent([[-180,-80-Ri],[180,80+Ri]])},ui.geo.greatArc=function(){function t(){return{type:"LineString",coordinates:[e||r.apply(this,arguments),n||a.apply(this,arguments)]}}var e,n,r=_n,a=wn;return t.distance=function(){return ui.geo.distance(e||r.apply(this,arguments),n||a.apply(this,arguments))},t.source=function(n){return arguments.length?(r=n,e="function"==typeof n?null:n,t):r},t.target=function(e){return arguments.length?(a=e,n="function"==typeof e?null:e,t):a},t.precision=function(){return arguments.length?t:0},t},ui.geo.interpolate=function(t,e){return kn(t[0]*Vi,t[1]*Vi,e[0]*Vi,e[1]*Vi)},ui.geo.length=function(t){return $l=0,ui.geo.stream(t,Wl),$l};var $l,Wl={sphere:k,point:k,lineStart:Mn,lineEnd:k,polygonStart:k,polygonEnd:k},Jl=An(function(t){return Math.sqrt(2/(1+t))},function(t){return 2*Math.asin(t/2)});(ui.geo.azimuthalEqualArea=function(){return sn(Jl)}).raw=Jl;var Kl=An(function(t){var e=Math.acos(t);return e&&e/Math.sin(e)},b);(ui.geo.azimuthalEquidistant=function(){return sn(Kl)}).raw=Kl,(ui.geo.conicConformal=function(){return Ze(Tn)}).raw=Tn,(ui.geo.conicEquidistant=function(){return Ze(Ln)}).raw=Ln;var ts=An(function(t){return 1/t},Math.atan);(ui.geo.gnomonic=function(){return sn(ts)}).raw=ts,zn.invert=function(t,e){return[t,2*Math.atan(Math.exp(e))-Hi]},(ui.geo.mercator=function(){return Sn(zn)}).raw=zn;var es=An(function(){return 1},Math.asin);(ui.geo.orthographic=function(){return sn(es)}).raw=es;var ns=An(function(t){return 1/(1+t)},function(t){return 2*Math.atan(t)});(ui.geo.stereographic=function(){return sn(ns)}).raw=ns,Cn.invert=function(t,e){return[-e,2*Math.atan(Math.exp(t))-Hi]},(ui.geo.transverseMercator=function(){var t=Sn(Cn),e=t.center,n=t.rotate;return t.center=function(t){return t?e([-t[1],t[0]]):(t=e(),[t[1],-t[0]])},t.rotate=function(t){return t?n([t[0],t[1],t.length>2?t[2]+90:90]):(t=n(),[t[0],t[1],t[2]-90])},n([0,0,90])}).raw=Cn,ui.geom={},ui.geom.hull=function(t){function e(t){if(t.length<3)return[];var e,a=zt(n),o=zt(r),i=t.length,l=[],s=[];for(e=0;e=0;--e)h.push(t[l[c[e]][2]]);for(e=+f;e=r&&c.x<=o&&c.y>=a&&c.y<=i?[[r,i],[o,i],[o,a],[r,a]]:[];u.point=t[l]}),e}function n(t){return t.map(function(t,e){return{x:Math.round(o(t,e)/Ri)*Ri,y:Math.round(i(t,e)/Ri)*Ri,i:e}})}var r=En,a=Nn,o=r,i=a,l=fs;return t?e(t):(e.links=function(t){return cr(n(t)).edges.filter(function(t){return t.l&&t.r}).map(function(e){return{source:t[e.l.i],target:t[e.r.i]}})},e.triangles=function(t){var e=[];return cr(n(t)).cells.forEach(function(n,r){for(var a,o,i=n.site,l=n.edges.sort(Yn),s=-1,c=l.length,u=l[c-1].edge,f=u.l===i?u.r:u.l;++s=c,d=r>=u,h=d<<1|f;t.leaf=!1,t=t.nodes[h]||(t.nodes[h]=pr()),f?a=c:l=c,d?i=u:s=u,o(t,e,n,r,a,i,l,s)}var u,f,d,h,p,g,v,m,y,x=zt(l),b=zt(s);if(null!=e)g=e,v=n,m=r,y=a;else if(m=y=-(g=v=1/0),f=[],d=[],p=t.length,i)for(h=0;hm&&(m=u.x),u.y>y&&(y=u.y),f.push(u.x),d.push(u.y);else for(h=0;hm&&(m=_),w>y&&(y=w),f.push(_),d.push(w)}var k=m-g,M=y-v;k>M?y=v+k:m=g+M;var A=pr();if(A.add=function(t){o(A,t,+x(t,++h),+b(t,h),g,v,m,y)},A.visit=function(t){gr(t,A,g,v,m,y)},A.find=function(t){return vr(A,t[0],t[1],g,v,m,y)},h=-1,null==e){for(;++h=0?t.slice(0,e):t,r=e>=0?t.slice(e+1):"in";return n=gs.get(n)||ps,r=vs.get(r)||b,kr(r(n.apply(null,fi.call(arguments,1))))},ui.interpolateHcl=Dr,ui.interpolateHsl=Rr,ui.interpolateLab=Ir,ui.interpolateRound=Fr,ui.transform=function(t){var e=hi.createElementNS(ui.ns.prefix.svg,"g");return(ui.transform=function(t){if(null!=t){e.setAttribute("transform",t);var n=e.transform.baseVal.consolidate()}return new qr(n?n.matrix:ms)})(t)},qr.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var ms={a:1,b:0,c:0,d:1,e:0,f:0};ui.interpolateTransform=Qr,ui.layout={},ui.layout.bundle=function(){return function(t){for(var e=[],n=-1,r=t.length;++n0?a=t:(n.c=null,n.t=NaN,n=null,c.end({type:"end",alpha:a=0})):t>0&&(c.start({type:"start",alpha:a=t}),n=Ot(s.tick)),s):a},s.start=function(){function t(t,r){if(!n){for(n=new Array(a),s=0;s=0;)i.push(u=c[s]),u.parent=o,u.depth=o.depth+1;r&&(o.value=0),o.children=c}else r&&(o.value=+r.call(t,o,o.depth)||0),delete o.children;return sa(a,function(t){var n,a;e&&(n=t.children)&&n.sort(e),r&&(a=t.parent)&&(a.value+=t.value)}),l}var e=fa,n=ca,r=ua;return t.sort=function(n){return arguments.length?(e=n,t):e},t.children=function(e){return arguments.length?(n=e,t):n},t.value=function(e){return arguments.length?(r=e,t):r},t.revalue=function(e){return r&&(la(e,function(t){t.children&&(t.value=0)}),sa(e,function(e){var n;e.children||(e.value=+r.call(t,e,e.depth)||0),(n=e.parent)&&(n.value+=e.value)})),e},t},ui.layout.partition=function(){function t(e,n,r,a){var o=e.children;if(e.x=n,e.y=e.depth*a,e.dx=r,e.dy=a,o&&(i=o.length)){var i,l,s,c=-1;for(r=e.value?r/e.value:0;++cl&&(l=r),i.push(r)}for(n=0;n0)for(o=-1;++o=u[0]&&l<=u[1]&&(i=s[ui.bisect(f,l,1,h)-1],i.y+=p,i.push(t[o]));return s}var e=!0,n=Number,r=ka,a=_a;return t.value=function(e){return arguments.length?(n=e,t):n},t.range=function(e){return arguments.length?(r=zt(e),t):r},t.bins=function(e){return arguments.length?(a="number"==typeof e?function(t){return wa(t,e)}:zt(e),t):a},t.frequency=function(n){return arguments.length?(e=!!n,t):e},t},ui.layout.pack=function(){function t(t,o){var i=n.call(this,t,o),l=i[0],s=a[0],c=a[1],u=null==e?Math.sqrt:"function"==typeof e?e:function(){return e};if(l.x=l.y=0,sa(l,function(t){t.r=+u(t.value)}),sa(l,za),r){var f=r*(e?1:Math.max(2*l.r/s,2*l.r/c))/2;sa(l,function(t){t.r+=f}),sa(l,za),sa(l,function(t){t.r-=f})}return Ea(l,s/2,c/2,e?1:1/Math.max(2*l.r/s,2*l.r/c)),i}var e,n=ui.layout.hierarchy().sort(Ma),r=0,a=[1,1];return t.size=function(e){return arguments.length?(a=e,t):a},t.radius=function(n){return arguments.length?(e=null==n||"function"==typeof n?n:+n,t):e},t.padding=function(e){return arguments.length?(r=+e,t):r},ia(t,n)},ui.layout.tree=function(){function t(t,a){var u=i.call(this,t,a),f=u[0],d=e(f);if(sa(d,n),d.parent.m=-d.z,la(d,r),c)la(f,o);else{var h=f,p=f,g=f;la(f,function(t){t.xp.x&&(p=t),t.depth>g.depth&&(g=t)});var v=l(h,p)/2-h.x,m=s[0]/(p.x+l(p,h)/2+v),y=s[1]/(g.depth||1);la(f,function(t){t.x=(t.x+v)*m,t.y=t.depth*y})}return u}function e(t){for(var e,n={A:null,children:[t]},r=[n];null!=(e=r.pop());)for(var a,o=e.children,i=0,l=o.length;i0&&(Da(Ia(i,t,n),t,r),c+=r,u+=r),f+=i.m,c+=a.m,d+=s.m,u+=o.m;i&&!ja(o)&&(o.t=i,o.m+=f-u),a&&!Pa(s)&&(s.t=a,s.m+=c-d,n=t)}return n}function o(t){t.x*=s[0],t.y=t.depth*s[1]}var i=ui.layout.hierarchy().sort(null).value(null),l=Oa,s=[1,1],c=null;return t.separation=function(e){return arguments.length?(l=e,t):l},t.size=function(e){return arguments.length?(c=null==(s=e)?o:null,t):c?null:s},t.nodeSize=function(e){return arguments.length?(c=null==(s=e)?null:o,t):c?s:null},ia(t,i)},ui.layout.cluster=function(){function t(t,o){var i,l=e.call(this,t,o),s=l[0],c=0;sa(s,function(t){var e=t.children;e&&e.length?(t.x=qa(e),t.y=Fa(e)):(t.x=i?c+=n(t,i):0,t.y=0,i=t)});var u=Ba(s),f=Ha(s),d=u.x-n(u,f)/2,h=f.x+n(f,u)/2;return sa(s,a?function(t){t.x=(t.x-s.x)*r[0],t.y=(s.y-t.y)*r[1]}:function(t){t.x=(t.x-d)/(h-d)*r[0],t.y=(1-(s.y?t.y/s.y:1))*r[1]}),l}var e=ui.layout.hierarchy().sort(null).value(null),n=Oa,r=[1,1],a=!1;return t.separation=function(e){return arguments.length?(n=e,t):n},t.size=function(e){return arguments.length?(a=null==(r=e),t):a?null:r},t.nodeSize=function(e){return arguments.length?(a=null!=(r=e),t):a?r:null},ia(t,e)},ui.layout.treemap=function(){function t(t,e){for(var n,r,a=-1,o=t.length;++a0;)u.push(i=d[s-1]),u.area+=i.area,"squarify"!==h||(l=r(u,g))<=p?(d.pop(),p=l):(u.area-=u.pop().area,a(u,g,c,!1),g=Math.min(c.dx,c.dy),u.length=u.area=0,p=1/0);u.length&&(a(u,g,c,!0),u.length=u.area=0),o.forEach(e)}}function n(e){var r=e.children;if(r&&r.length){var o,i=f(e),l=r.slice(),s=[];for(t(l,i.dx*i.dy/e.value),s.area=0;o=l.pop();)s.push(o),s.area+=o.area,null!=o.z&&(a(s,o.z?i.dx:i.dy,i,!l.length),s.length=s.area=0);r.forEach(n)}}function r(t,e){for(var n,r=t.area,a=0,o=1/0,i=-1,l=t.length;++ia&&(a=n));return r*=r,e*=e,r?Math.max(e*a*p/r,r/(e*o*p)):1/0}function a(t,e,n,r){var a,o=-1,i=t.length,l=n.x,c=n.y,u=e?s(t.area/e):0;if(e==n.dx){for((r||u>n.dy)&&(u=n.dy);++on.dx)&&(u=n.dx);++o1);return t+e*n*Math.sqrt(-2*Math.log(a)/a)}},logNormal:function(){var t=ui.random.normal.apply(ui,arguments);return function(){return Math.exp(t())}},bates:function(t){var e=ui.random.irwinHall(t);return function(){return e()/t}},irwinHall:function(t){return function(){for(var e=0,n=0;nf?0:1;if(c=Bi)return e(c,h)+(t?e(t,1-h):"")+"Z";var p,g,v,m,y,x,b,_,w,k,M,A,T=0,L=0,z=[];if((m=(+s.apply(this,arguments)||0)/2)&&(v=o===Ns?Math.sqrt(t*t+c*c):+o.apply(this,arguments),h||(L*=-1),c&&(L=rt(v/c*Math.sin(m))),t&&(T=rt(v/t*Math.sin(m)))),c){y=c*Math.cos(u+L),x=c*Math.sin(u+L),b=c*Math.cos(f-L),_=c*Math.sin(f-L);var S=Math.abs(f-u-2*L)<=Fi?0:1;if(L&&bo(y,x,b,_)===h^S){var C=(u+f)/2;y=c*Math.cos(C),x=c*Math.sin(C),b=_=null}}else y=x=0;if(t){w=t*Math.cos(f-T),k=t*Math.sin(f-T),M=t*Math.cos(u+T),A=t*Math.sin(u+T);var E=Math.abs(u-f+2*T)<=Fi?0:1;if(T&&bo(w,k,M,A)===1-h^E){var N=(u+f)/2;w=t*Math.cos(N),k=t*Math.sin(N),M=A=null}}else w=k=0;if(d>Ri&&(p=Math.min(Math.abs(c-t)/2,+a.apply(this,arguments)))>.001){g=tFi)+",1 "+e}function a(t,e,n,r){return"Q 0,0 "+r}var o=_n,i=wn,l=Go,s=mo,c=yo;return t.radius=function(e){return arguments.length?(l=zt(e),t):l},t.source=function(e){return arguments.length?(o=zt(e),t):o},t.target=function(e){return arguments.length?(i=zt(e),t):i},t.startAngle=function(e){return arguments.length?(s=zt(e),t):s},t.endAngle=function(e){return arguments.length?(c=zt(e),t):c},t},ui.svg.diagonal=function(){function t(t,a){var o=e.call(this,t,a),i=n.call(this,t,a),l=(o.y+i.y)/2,s=[o,{x:o.x,y:l},{x:i.x,y:l},i];return s=s.map(r),"M"+s[0]+"C"+s[1]+" "+s[2]+" "+s[3]}var e=_n,n=wn,r=Zo;return t.source=function(n){return arguments.length?(e=zt(n),t):e},t.target=function(e){return arguments.length?(n=zt(e),t):n},t.projection=function(e){return arguments.length?(r=e,t):r},t},ui.svg.diagonal.radial=function(){var t=ui.svg.diagonal(),e=Zo,n=t.projection;return t.projection=function(t){return arguments.length?n(Yo(e=t)):e},t},ui.svg.symbol=function(){function t(t,r){return(Rs.get(e.call(this,t,r))||$o)(n.call(this,t,r))}var e=Qo,n=Xo;return t.type=function(n){return arguments.length?(e=zt(n),t):e},t.size=function(e){return arguments.length?(n=zt(e),t):n},t};var Rs=ui.map({circle:$o,cross:function(t){var e=Math.sqrt(t/5)/2;return"M"+-3*e+","+-e+"H"+-e+"V"+-3*e+"H"+e+"V"+-e+"H"+3*e+"V"+e+"H"+e+"V"+3*e+"H"+-e+"V"+e+"H"+-3*e+"Z"},diamond:function(t){var e=Math.sqrt(t/(2*Fs)),n=e*Fs;return"M0,"+-e+"L"+n+",0 0,"+e+" "+-n+",0Z"},square:function(t){var e=Math.sqrt(t)/2;return"M"+-e+","+-e+"L"+e+","+-e+" "+e+","+e+" "+-e+","+e+"Z"},"triangle-down":function(t){var e=Math.sqrt(t/Is),n=e*Is/2;return"M0,"+n+"L"+e+","+-n+" "+-e+","+-n+"Z"},"triangle-up":function(t){var e=Math.sqrt(t/Is),n=e*Is/2;return"M0,"+-n+"L"+e+","+n+" "+-e+","+n+"Z"}});ui.svg.symbolTypes=Rs.keys();var Is=Math.sqrt(3),Fs=Math.tan(30*Vi);Si.transition=function(t){for(var e,n,r=qs||++Us,a=ei(t),o=[],i=Bs||{time:Date.now(),ease:zr,delay:0,duration:250},l=-1,s=this.length;++lrect,.s>rect").attr("width",f[1]-f[0])}function a(t){t.select(".extent").attr("y",d[0]),t.selectAll(".extent,.e>rect,.w>rect").attr("height",d[1]-d[0])}function o(){function o(){32==ui.event.keyCode&&(S||(x=null,E[0]-=f[1],E[1]-=d[1],S=2),T())}function g(){32==ui.event.keyCode&&2==S&&(E[0]+=f[1],E[1]+=d[1],S=0,T())}function v(){var t=ui.mouse(_),r=!1;b&&(t[0]+=b[0],t[1]+=b[1]),S||(ui.event.altKey?(x||(x=[(f[0]+f[1])/2,(d[0]+d[1])/2]),E[0]=f[+(t[0]0&&this._events[t].length>n&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(t,e){function n(){this.removeListener(t,n),r||(r=!0,e.apply(this,arguments))}if(!a(e))throw TypeError("listener must be a function");var r=!1;return n.listener=e,this.on(t,n),this},r.prototype.removeListener=function(t,e){var n,r,o,l;if(!a(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(n=this._events[t],o=n.length,r=-1,n===e||a(n.listener)&&n.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(i(n)){for(l=o;l-- >0;)if(n[l]===e||n[l].listener&&n[l].listener===e){r=l;break}if(r<0)return this;1===n.length?(n.length=0,delete this._events[t]):n.splice(r,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},r.prototype.removeAllListeners=function(t){var e,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[t],a(n))this.removeListener(t,n);else if(n)for(;n.length;)this.removeListener(t,n[n.length-1]);return delete this._events[t],this},r.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?a(this._events[t])?[this._events[t]]:this._events[t].slice():[]},r.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(a(e))return 1;if(e)return e.length}return 0},r.listenerCount=function(t,e){return t.listenerCount(e)}},{}],11:[function(t,e,n){"use strict";function r(t){for(var e,n=t.length,r=0;r13)&&32!==e&&133!==e&&160!==e&&5760!==e&&6158!==e&&(e<8192||e>8205)&&8232!==e&&8233!==e&&8239!==e&&8287!==e&&8288!==e&&12288!==e&&65279!==e)return!1;return!0}e.exports=function(t){var e=typeof t;if("string"===e){var n=t;if(t=+t,0===t&&r(n))return!1}else if("number"!==e)return!1;return t-t<1}},{}],12:[function(t,e,n){function r(t,e){var n=e[0],r=e[1],a=e[2],o=e[3],i=n+n,l=r+r,s=a+a,c=n*i,u=r*i,f=r*l,d=a*i,h=a*l,p=a*s,g=o*i,v=o*l,m=o*s;return t[0]=1-f-p,t[1]=u+m,t[2]=d-v,t[3]=0,t[4]=u-m,t[5]=1-c-p,t[6]=h+g,t[7]=0,t[8]=d+v,t[9]=h-g,t[10]=1-c-f,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}e.exports=r},{}],13:[function(t,e,n){function r(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function o(t){if(f===setTimeout)return setTimeout(t,0);if((f===r||!f)&&setTimeout)return f=setTimeout,setTimeout(t,0);try{return f(t,0)}catch(e){try{return f.call(null,t,0)}catch(e){return f.call(this,t,0)}}}function i(t){if(d===clearTimeout)return clearTimeout(t);if((d===a||!d)&&clearTimeout)return d=clearTimeout,clearTimeout(t);try{return d(t)}catch(e){try{return d.call(null,t)}catch(e){return d.call(this,t)}}}function l(){v&&p&&(v=!1,p.length?g=p.concat(g):m=-1,g.length&&s())}function s(){if(!v){var t=o(l);v=!0;for(var e=g.length;e;){for(p=g,g=[];++m1)for(var n=1;n.5?s/(2-o-i):s/(o+i),o){case t:r=(e-n)/s+(e1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+(e-t)*(2/3-n)*6:t}var a,o,i;if(t=z(t,360),e=z(e,100),n=z(n,100),0===e)a=o=i=n;else{var l=n<.5?n*(1+e):n+e-n*e,s=2*n-l;a=r(s,l,t+1/3),o=r(s,l,t),i=r(s,l,t-1/3)}return{r:255*a,g:255*o,b:255*i}}function s(t,e,n){t=z(t,255),e=z(e,255),n=z(n,255);var r,a,o=G(t,e,n),i=U(t,e,n),l=o,s=o-i;if(a=0===o?0:s/o,o==i)r=0;else{switch(o){case t:r=(e-n)/s+(e>1)+720)%360;--e;)a.h=(a.h+o)%360,i.push(r(a));return i}function A(t,e){e=e||6;for(var n=r(t).toHsv(),a=n.h,o=n.s,i=n.v,l=[],s=1/e;e--;)l.push(r({h:a,s:o,v:i})),i=(i+s)%1;return l}function T(t){var e={};for(var n in t)t.hasOwnProperty(n)&&(e[t[n]]=n);return e}function L(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function z(t,n){E(t)&&(t="100%");var r=N(t);return t=U(n,G(0,parseFloat(t))),r&&(t=parseInt(t*n,10)/100),e.abs(t-n)<1e-6?1:t%n/parseFloat(n)}function S(t){return U(1,G(0,t))}function C(t){return parseInt(t,16)}function E(t){return"string"==typeof t&&t.indexOf(".")!=-1&&1===parseFloat(t)}function N(t){return"string"==typeof t&&t.indexOf("%")!=-1}function O(t){return 1==t.length?"0"+t:""+t}function P(t){return t<=1&&(t=100*t+"%"),t}function j(t){return e.round(255*parseFloat(t)).toString(16)}function D(t){return C(t)/255}function R(t){return!!Q.CSS_UNIT.exec(t)}function I(t){t=t.replace(q,"").replace(B,"").toLowerCase();var e=!1;if(Y[t])t=Y[t],e=!0;else if("transparent"==t)return{r:0,g:0,b:0,a:0,format:"name"};var n;return(n=Q.rgb.exec(t))?{r:n[1],g:n[2],b:n[3]}:(n=Q.rgba.exec(t))?{r:n[1],g:n[2],b:n[3],a:n[4]}:(n=Q.hsl.exec(t))?{h:n[1],s:n[2],l:n[3]}:(n=Q.hsla.exec(t))?{h:n[1],s:n[2],l:n[3],a:n[4]}:(n=Q.hsv.exec(t))?{h:n[1],s:n[2],v:n[3]}:(n=Q.hsva.exec(t))?{h:n[1],s:n[2],v:n[3],a:n[4]}:(n=Q.hex8.exec(t))?{r:C(n[1]),g:C(n[2]),b:C(n[3]),a:D(n[4]),format:e?"name":"hex8"}:(n=Q.hex6.exec(t))?{r:C(n[1]),g:C(n[2]),b:C(n[3]),format:e?"name":"hex"}:(n=Q.hex4.exec(t))?{r:C(n[1]+""+n[1]),g:C(n[2]+""+n[2]),b:C(n[3]+""+n[3]),a:D(n[4]+""+n[4]),format:e?"name":"hex8"}:!!(n=Q.hex3.exec(t))&&{r:C(n[1]+""+n[1]),g:C(n[2]+""+n[2]),b:C(n[3]+""+n[3]),format:e?"name":"hex"}}function F(t){var e,n;return t=t||{level:"AA",size:"small"},e=(t.level||"AA").toUpperCase(),n=(t.size||"small").toLowerCase(),"AA"!==e&&"AAA"!==e&&(e="AA"),"small"!==n&&"large"!==n&&(n="small"),{level:e,size:n}}var q=/^\s+/,B=/\s+$/,H=0,V=e.round,U=e.min,G=e.max,Z=e.random;r.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var t,n,r,a,o,i,l=this.toRgb();return t=l.r/255,n=l.g/255,r=l.b/255,a=t<=.03928?t/12.92:e.pow((t+.055)/1.055,2.4),o=n<=.03928?n/12.92:e.pow((n+.055)/1.055,2.4),i=r<=.03928?r/12.92:e.pow((r+.055)/1.055,2.4),.2126*a+.7152*o+.0722*i},setAlpha:function(t){return this._a=L(t),this._roundA=V(100*this._a)/100,this},toHsv:function(){var t=s(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=s(this._r,this._g,this._b),e=V(360*t.h),n=V(100*t.s),r=V(100*t.v);return 1==this._a?"hsv("+e+", "+n+"%, "+r+"%)":"hsva("+e+", "+n+"%, "+r+"%, "+this._roundA+")"},toHsl:function(){var t=i(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=i(this._r,this._g,this._b),e=V(360*t.h),n=V(100*t.s),r=V(100*t.l);return 1==this._a?"hsl("+e+", "+n+"%, "+r+"%)":"hsla("+e+", "+n+"%, "+r+"%, "+this._roundA+")"},toHex:function(t){return u(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return f(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:V(this._r),g:V(this._g),b:V(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+V(this._r)+", "+V(this._g)+", "+V(this._b)+")":"rgba("+V(this._r)+", "+V(this._g)+", "+V(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:V(100*z(this._r,255))+"%",g:V(100*z(this._g,255))+"%",b:V(100*z(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+V(100*z(this._r,255))+"%, "+V(100*z(this._g,255))+"%, "+V(100*z(this._b,255))+"%)":"rgba("+V(100*z(this._r,255))+"%, "+V(100*z(this._g,255))+"%, "+V(100*z(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(X[u(this._r,this._g,this._b,!0)]||!1)},toFilter:function(t){var e="#"+d(this._r,this._g,this._b,this._a),n=e,a=this._gradientType?"GradientType = 1, ":"";if(t){var o=r(t);n="#"+d(o._r,o._g,o._b,o._a)}return"progid:DXImageTransform.Microsoft.gradient("+a+"startColorstr="+e+",endColorstr="+n+")"},toString:function(t){var e=!!t;t=t||this._format;var n=!1,r=this._a<1&&this._a>=0,a=!e&&r&&("hex"===t||"hex6"===t||"hex3"===t||"hex4"===t||"hex8"===t||"name"===t);return a?"name"===t&&0===this._a?this.toName():this.toRgbString():("rgb"===t&&(n=this.toRgbString()),"prgb"===t&&(n=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(n=this.toHexString()),"hex3"===t&&(n=this.toHexString(!0)),"hex4"===t&&(n=this.toHex8String(!0)),"hex8"===t&&(n=this.toHex8String()),"name"===t&&(n=this.toName()),"hsl"===t&&(n=this.toHslString()),"hsv"===t&&(n=this.toHsvString()),n||this.toHexString())},clone:function(){return r(this.toString())},_applyModification:function(t,e){var n=t.apply(null,[this].concat([].slice.call(e)));return this._r=n._r,this._g=n._g,this._b=n._b,this.setAlpha(n._a),this},lighten:function(){return this._applyModification(v,arguments)},brighten:function(){return this._applyModification(m,arguments)},darken:function(){return this._applyModification(y,arguments)},desaturate:function(){return this._applyModification(h,arguments)},saturate:function(){return this._applyModification(p,arguments)},greyscale:function(){return this._applyModification(g,arguments)},spin:function(){return this._applyModification(x,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(M,arguments); ++},complement:function(){return this._applyCombination(b,arguments)},monochromatic:function(){return this._applyCombination(A,arguments)},splitcomplement:function(){return this._applyCombination(k,arguments)},triad:function(){return this._applyCombination(_,arguments)},tetrad:function(){return this._applyCombination(w,arguments)}},r.fromRatio=function(t,e){if("object"==typeof t){var n={};for(var a in t)t.hasOwnProperty(a)&&("a"===a?n[a]=t[a]:n[a]=P(t[a]));t=n}return r(t,e)},r.equals=function(t,e){return!(!t||!e)&&r(t).toRgbString()==r(e).toRgbString()},r.random=function(){return r.fromRatio({r:Z(),g:Z(),b:Z()})},r.mix=function(t,e,n){n=0===n?0:n||50;var a=r(t).toRgb(),o=r(e).toRgb(),i=n/100,l={r:(o.r-a.r)*i+a.r,g:(o.g-a.g)*i+a.g,b:(o.b-a.b)*i+a.b,a:(o.a-a.a)*i+a.a};return r(l)},r.readability=function(t,n){var a=r(t),o=r(n);return(e.max(a.getLuminance(),o.getLuminance())+.05)/(e.min(a.getLuminance(),o.getLuminance())+.05)},r.isReadable=function(t,e,n){var a,o,i=r.readability(t,e);switch(o=!1,a=F(n),a.level+a.size){case"AAsmall":case"AAAlarge":o=i>=4.5;break;case"AAlarge":o=i>=3;break;case"AAAsmall":o=i>=7}return o},r.mostReadable=function(t,e,n){var a,o,i,l,s=null,c=0;n=n||{},o=n.includeFallbackColors,i=n.level,l=n.size;for(var u=0;uc&&(c=a,s=r(e[u]));return r.isReadable(t,s,{level:i,size:l})||!o?s:(n.includeFallbackColors=!1,r.mostReadable(t,["#fff","#000"],n))};var Y=r.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},X=r.hexNames=T(Y),Q=function(){var t="[-\\+]?\\d+%?",e="[-\\+]?\\d*\\.\\d+%?",n="(?:"+e+")|(?:"+t+")",r="[\\s|\\(]+("+n+")[,|\\s]+("+n+")[,|\\s]+("+n+")\\s*\\)?",a="[\\s|\\(]+("+n+")[,|\\s]+("+n+")[,|\\s]+("+n+")[,|\\s]+("+n+")\\s*\\)?";return{CSS_UNIT:new RegExp(n),rgb:new RegExp("rgb"+r),rgba:new RegExp("rgba"+a),hsl:new RegExp("hsl"+r),hsla:new RegExp("hsla"+a),hsv:new RegExp("hsv"+r),hsva:new RegExp("hsva"+a),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();"undefined"!=typeof n&&n.exports?n.exports=r:"function"==typeof t&&t.amd?t(function(){return r}):window.tinycolor=r}(Math)},{}],15:[function(e,n,r){!function(e,a){"object"==typeof r&&"undefined"!=typeof n?a(r):"function"==typeof t&&t.amd?t(["exports"],a):a(e.topojson=e.topojson||{})}(this,function(t){"use strict";function e(){}function n(t){if(!t)return e;var n,r,a=t.scale[0],o=t.scale[1],i=t.translate[0],l=t.translate[1];return function(t,e){e||(n=r=0),t[0]=(n+=t[0])*a+i,t[1]=(r+=t[1])*o+l}}function r(t){if(!t)return e;var n,r,a=t.scale[0],o=t.scale[1],i=t.translate[0],l=t.translate[1];return function(t,e){e||(n=r=0);var s=Math.round((t[0]-i)/a),c=Math.round((t[1]-l)/o);t[0]=s-n,t[1]=c-r,n=s,r=c}}function a(t,e){for(var n,r=t.length,a=r-e;a<--r;)n=t[a],t[a++]=t[r],t[r]=n}function o(t,e){for(var n=0,r=t.length;n>>1;t[a]1){var s,u=[],f={LineString:a,MultiLineString:o,Polygon:o,MultiPolygon:function(t){t.forEach(o)}};i(e),u.forEach(arguments.length<3?function(t){l.push(t[0].i)}:function(t){n(t[0].g,t[t.length-1].g)&&l.push(t[0].i)})}else for(var d=0,h=t.arcs.length;d1)for(var i,l,s=1,u=r(o[0]);su&&(l=o[0],o[0]=o[s],o[s]=l,u=i);return o})}}function v(t){function e(t,e){t.forEach(function(t){t<0&&(t=~t);var n=a[t];n?n.push(e):a[t]=[e]})}function n(t,n){t.forEach(function(t){e(t,n)})}function r(t,e){"GeometryCollection"===t.type?t.geometries.forEach(function(t){r(t,e)}):t.type in l&&l[t.type](t.arcs,e)}var a={},i=t.map(function(){return[]}),l={LineString:e,MultiLineString:n,Polygon:n,MultiPolygon:function(t,e){t.forEach(function(t){n(t,e)})}};t.forEach(r);for(var s in a)for(var c=a[s],u=c.length,f=0;f0;){var n=(e+1>>1)-1,a=r[n];if(m(t,a)>=0)break;r[a._=e]=a,r[t._=e=n]=t}}function e(t,e){for(;;){var n=e+1<<1,o=n-1,i=e,l=r[i];if(o0&&(t=r[a],e(r[t._=0]=t,0)),n}},n.remove=function(n){var o,i=n._;if(r[i]===n)return i!==--a&&(o=r[a],(m(o,n)<0?t:e)(r[o._=i]=o,i)),i},n}function x(t,e){function a(t){l.remove(t),t[1][2]=e(t),l.push(t)}var o=n(t.transform),i=r(t.transform),l=y();return e||(e=d),t.arcs.forEach(function(t){var n,r,s,c,u=[],f=0;for(r=0,s=t.length;r1||g<0||g>1?null:{x:t+s*g,y:e+f*g}}var i=t("d3"),l=t("fast-isnumeric"),s=t("../../plotly"),c=t("../../lib"),u=t("../../plots/cartesian/axes"),f=t("../color"),d=t("../drawing"),h=t("../../lib/svg_text_utils"),p=t("../../lib/setcursor"),g=t("../dragelement"),v=e.exports={};v.ARROWPATHS=t("./arrow_paths"),v.layoutAttributes=t("./attributes"),v.supplyLayoutDefaults=function(t,e){for(var n=t.annotations||[],a=e.annotations=[],o=0;o2/3?"right":"center"),{center:0,middle:0,left:.5,bottom:-.5,right:-.5,top:.5}[e]}tt.selectAll("tspan.line").attr({y:0,x:0});var r=X.select(".annotation-math-group"),a=!r.empty(),l=d.bBox((a?r:tt).node()),h=l.width,m=l.height,y=Math.round(h+2*W),x=Math.round(m+2*W);B._w=h,B._h=m;var b=!1;if(["x","y"].forEach(function(e){var r,a=B[e+"ref"]||e,o=u.getFromId(t,a),i=(G+("x"===e?0:90))*Math.PI/180,l=y*Math.abs(Math.cos(i))+x*Math.abs(Math.sin(i)),s=B[e+"anchor"];if(o){if(!o.autorange&&(B[e]-o.range[0])*(B[e]-o.range[1])>0&&(B["a"+e+"ref"]===a?(B["a"+e]-o.range[0])*(B["a"+e]-o.range[1])>0&&(b=!0):b=!0,b))return;U[e]=o._offset+o.l2p(B[e]),r=.5}else r=B[e],"y"===e&&(r=1-r),U[e]="x"===e?S.l+S.w*r:S.t+S.h*r;var c=0;B["a"+e+"ref"]===a?U["aa"+e]=o._offset+o.l2p(B["a"+e]):(c=B.showarrow?B["a"+e]:l*n(r,s),U[e]+=c),B["_"+e+"type"]=o&&o.type,B["_"+e+"size"]=l,B["_"+e+"shift"]=c}),b)return void X.remove();var w,k;B.showarrow&&(w=B.axref===B.xref?U.x:c.constrain(U.x-B.ax,1,_.width-1),k=B.ayref===B.yref?U.y:c.constrain(U.y-B.ay,1,_.height-1)),U.x=c.constrain(U.x,1,_.width-1),U.y=c.constrain(U.y,1,_.height-1);var M=W-l.top,A=W-l.left;a?r.select("svg").attr({x:W-1,y:W}):(tt.attr({x:A,y:M}),tt.selectAll("tspan.line").attr({y:M,x:A})),J.call(d.setRect,Q/2,Q/2,y-Q,x-Q);var T=0,L=0;T=B.axref===B.xref?Math.round(U.aax-y/2):Math.round(U.x-y/2),L=B.ayref===B.yref?Math.round(U.aay-x/2):Math.round(U.y-x/2),X.call(c.setTranslate,T,L);var z="annotations["+e+"]",C=function(n,r){i.select(t).selectAll('.annotation-arrow-g[data-index="'+e+'"]').remove();var a,l;a=B.axref===B.xref?U.aax+n:U.x+n,l=B.ayref===B.yref?U.aay+r:U.y+r;var u=c.rotationXYMatrix(G,a,l),d=c.apply2DTransform(u),h=c.apply2DTransform2(u),p=J.attr("width")/2,m=J.attr("height")/2,y=[[a-p,l-m,a-p,l+m],[a-p,l+m,a+p,l+m],[a+p,l+m,a+p,l-m],[a+p,l-m,a-p,l-m]].map(h);if(!y.reduce(function(t,e){return t^!!o(w,k,w+1e6,k+1e6,e[0],e[1],e[2],e[3])},!1)){y.forEach(function(t){var e=o(a,l,w,k,t[0],t[1],t[2],t[3]);e&&(a=e.x,l=e.y)});var x=B.arrowwidth,b=B.arrowcolor,_=Z.append("g").style({opacity:f.opacity(b)}).classed("annotation-arrow-g",!0).attr("data-index",String(e)),M=_.append("path").attr("d","M"+a+","+l+"L"+w+","+k).style("stroke-width",x+"px").call(f.stroke,f.rgb(b));v.arrowhead(M,B.arrowhead,"end",B.arrowsize);var A=_.append("path").classed("annotation",!0).classed("anndrag",!0).attr({"data-index":String(e),d:"M3,3H-3V-3H3ZM0,0L"+(a-w)+","+(l-k),transform:"translate("+w+","+k+")"}).style("stroke-width",x+6+"px").call(f.stroke,"rgba(0,0,0,0)").call(f.fill,"rgba(0,0,0,0)");if(t._context.editable){var T,L,C;g.init({element:A.node(),prepFn:function(){var t=c.getTranslate(X);L=t.x,C=t.y,T={},H&&H.autorange&&(T[H._name+".autorange"]=!0),V&&V.autorange&&(T[V._name+".autorange"]=!0)},moveFn:function(t,e){_.attr("transform","translate("+t+","+e+")");var n=d(L,C),r=n[0]+t,a=n[1]+e;X.call(c.setTranslate,r,a),T[z+".x"]=H?B.x+t/H._m:(w+t-S.l)/S.w,T[z+".y"]=V?B.y+e/V._m:1-(k+e-S.t)/S.h,B.axref===B.xref&&(T[z+".ax"]=H?B.ax+t/H._m:(w+t-S.l)/S.w),B.ayref===B.yref&&(T[z+".ay"]=V?B.ay+e/V._m:1-(k+e-S.t)/S.h),Y.attr({transform:"rotate("+G+","+r+","+a+")"})},doneFn:function(e){if(e){s.relayout(t,T);var n=document.querySelector(".js-notes-box-panel");n&&n.redraw(n.selectedObj)}}})}}};B.showarrow&&C(0,0);var E=c.rotationXYMatrix(G,U.x,U.y),N=c.apply2DTransform(E);if(t._context.editable){var O,P,j;g.init({element:X.node(),prepFn:function(){var t=c.getTranslate(X);O=t.x,P=t.y,j={}},moveFn:function(t,e){X.call(c.setTranslate,O+t,P+e);var n="pointer";if(B.showarrow)B.axref===B.xref?j[z+".ax"]=H.p2l(H.l2p(B.ax)+t):j[z+".ax"]=B.ax+t,B.ayref===B.yref?j[z+".ay"]=V.p2l(V.l2p(B.ay)+e):j[z+".ay"]=B.ay+e,C(t,e);else{if(H)j[z+".x"]=B.x+t/H._m;else{var r=B._xsize/S.w,a=B.x+B._xshift/S.w-r/2;j[z+".x"]=g.align(a+t/S.w,r,0,1,B.xanchor)}if(V)j[z+".y"]=B.y+e/V._m;else{var o=B._ysize/S.h,i=B.y-B._yshift/S.h-o/2;j[z+".y"]=g.align(i-e/S.h,o,0,1,B.yanchor)}H&&V||(n=g.getCursor(H?.5:j[z+".x"],V?.5:j[z+".y"],B.xanchor,B.yanchor))}var l=N(O,P),s=l[0]+t,u=l[1]+e;X.call(c.setTranslate,O+t,P+e),Y.attr({transform:"rotate("+G+","+s+","+u+")"}),p(X,n)},doneFn:function(e){if(p(X),e){s.relayout(t,j);var n=document.querySelector(".js-notes-box-panel");n&&n.redraw(n.selectedObj)}}})}}var x,b=t.layout,_=t._fullLayout;if(!l(e)||e===-1){if(!e&&Array.isArray(a))return b.annotations=a,v.supplyLayoutDefaults(b,_),void v.drawAll(t);if("remove"===a)return delete b.annotations,_.annotations=[],void v.drawAll(t);if(n&&"add"!==a){for(x=0;x<_.annotations.length;x++)v.draw(t,x,n,a);return}e=_.annotations.length,_.annotations.push({})}if(!n&&a){if("remove"===a){for(_._infolayer.selectAll('.annotation[data-index="'+e+'"]').remove(),_.annotations.splice(e,1),b.annotations.splice(e,1),x=e;x<_.annotations.length;x++)_._infolayer.selectAll('.annotation[data-index="'+(x+1)+'"]').attr("data-index",String(x)),v.draw(t,x);return}if("add"===a||c.isPlainObject(a)){_.annotations.splice(e,0,{});var w=c.isPlainObject(a)?c.extendFlat({},a):{text:"New text"};for(b.annotations?b.annotations.splice(e,0,w):b.annotations=[w],x=_.annotations.length-1;x>e;x--)_._infolayer.selectAll('.annotation[data-index="'+(x-1)+'"]').attr("data-index",String(x)),v.draw(t,x)}}_._infolayer.selectAll('.annotation[data-index="'+e+'"]').remove();var k=b.annotations[e],M=_.annotations[e];if(k){var A={xref:k.xref,yref:k.yref},T={};"string"==typeof n&&n?T[n]=a:c.isPlainObject(n)&&(T=n);var L=Object.keys(T);for(x=0;x4/3&&(P=F)}}else O&&(D&&(P<1/3?P+=I:P>2/3&&(P-=I)),P=(P-O.domain[0])/(O.domain[1]-O.domain[0]),P=O.range[0]+P*(O.range[1]-O.range[0]))}O&&O===N&&j&&("log"===j&&"log"!==O.type?P=Math.pow(10,P):"log"!==j&&"log"===O.type&&(P=P>0?Math.log(P)/Math.LN10:void 0)),k[E]=P}}var B=r(k,_);_.annotations[e]=B;var H=u.getFromId(t,B.xref),V=u.getFromId(t,B.yref),U={x:0,y:0},G=+B.textangle||0,Z=_._infolayer.append("g").classed("annotation",!0).attr("data-index",String(e)).style("opacity",B.opacity).on("click",function(){t._dragging=!1,t.emit("plotly_clickannotation",{index:e,annotation:k,fullAnnotation:B})}),Y=Z.append("g").classed("annotation-text-g",!0).attr("data-index",String(e)),X=Y.append("g"),Q=B.borderwidth,$=B.borderpad,W=Q+$,J=X.append("rect").attr("class","bg").style("stroke-width",Q+"px").call(f.stroke,B.bordercolor).call(f.fill,B.bgcolor),K=B.font,tt=X.append("text").classed("annotation",!0).attr("data-unformatted",B.text).text(B.text);t._context.editable?tt.call(h.makeEditable,X).call(m).on("edit",function(n){B.text=n,this.attr({"data-unformatted":B.text}),this.call(m);var r={};r["annotations["+e+"].text"]=B.text,H&&H.autorange&&(r[H._name+".autorange"]=!0),V&&V.autorange&&(r[V._name+".autorange"]=!0),s.relayout(t,r)}):tt.call(m),Y.attr({transform:"rotate("+G+","+U.x+","+U.y+")"}).call(d.setPosition,U.x,U.y)}},v.arrowhead=function(t,e,n,r){l(r)||(r=1);var a=t.node(),o=v.ARROWPATHS[e||0];if(o){"string"==typeof n&&n||(n="end");var s,c,u,h,p=(d.getPx(t,"stroke-width")||1)*r,g=t.style("stroke")||f.defaultLine,m=t.style("stroke-opacity")||1,y=n.indexOf("start")>=0,x=n.indexOf("end")>=0,b=o.backoff*p;if("line"===a.nodeName){if(s={x:+t.attr("x1"),y:+t.attr("y1")},c={x:+t.attr("x2"),y:+t.attr("y2")},u=Math.atan2(s.y-c.y,s.x-c.x),h=u+Math.PI,b){var _=b*Math.cos(u),w=b*Math.sin(u);y&&(s.x-=_,s.y-=w,t.attr({x1:s.x,y1:s.y})),x&&(c.x+=_,c.y+=w,t.attr({x2:c.x,y2:c.y}))}}else if("path"===a.nodeName){var k=a.getTotalLength(),M="";if(y){var A=a.getPointAtLength(0),T=a.getPointAtLength(.1);u=Math.atan2(A.y-T.y,A.x-T.x),s=a.getPointAtLength(Math.min(b,k)),b&&(M="0px,"+b+"px,")}if(x){var L=a.getPointAtLength(k),z=a.getPointAtLength(k-.1);if(h=Math.atan2(L.y-z.y,L.x-z.x),c=a.getPointAtLength(Math.max(0,k-b)),b){var S=M?2*b:b;M+=k-S+"px,"+k+"px"}}else M&&(M+=k+"px");M&&t.style("stroke-dasharray",M)}var C=function(n,r){e>5&&(r=0),i.select(a.parentElement).append("path").attr({class:t.attr("class"),d:o.path,transform:"translate("+n.x+","+n.y+")rotate("+180*r/Math.PI+")scale("+p+")"}).style({fill:g,opacity:m,"stroke-width":0})};y&&C(s,u),x&&C(c,h)}},v.calcAutorange=function(t){var e=t._fullLayout,n=e.annotations;if(n.length&&t._fullData.length){var r={};n.forEach(function(t){r[t.xref]=!0,r[t.yref]=!0});var o=u.list(t).filter(function(t){return t.autorange&&r[t._id]});if(o.length)return c.syncOrAsync([v.drawAll,a],t)}}},{"../../lib":99,"../../lib/setcursor":108,"../../lib/svg_text_utils":110,"../../plotly":118,"../../plots/cartesian/axes":121,"../color":20,"../dragelement":41,"../drawing":43,"./arrow_paths":16,"./attributes":17,d3:8,"fast-isnumeric":11}],19:[function(t,e,n){"use strict";n.defaults=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],n.defaultLine="#444",n.lightLine="#eee",n.background="#fff",n.borderLine="#BEC8D9",n.lightFraction=1e3/11},{}],20:[function(t,e,n){"use strict";function r(t){if(o(t)||"string"!=typeof t)return t;var e=t.trim();if("rgb"!==e.substr(0,3))return t;var n=e.match(/^rgba?\s*\(([^()]*)\)$/);if(!n)return t;var r=n[1].trim().split(/\s*[\s,]\s*/),a="a"===e.charAt(3)&&4===r.length;if(!a&&3!==r.length)return t;for(var i=0;i=0))return t;if(3===i)r[i]>1&&(r[i]=1);else if(r[i]>=1)return t}var l=Math.round(255*r[0])+", "+Math.round(255*r[1])+", "+Math.round(255*r[2]);return a?"rgba("+l+", "+r[3]+")":"rgb("+l+")"}var a=t("tinycolor2"),o=t("fast-isnumeric"),i=e.exports={},l=t("./attributes");i.defaults=l.defaults,i.defaultLine=l.defaultLine,i.lightLine=l.lightLine,i.background=l.background,i.tinyRGB=function(t){var e=t.toRgb();return"rgb("+Math.round(e.r)+", "+Math.round(e.g)+", "+Math.round(e.b)+")"},i.rgb=function(t){return i.tinyRGB(a(t))},i.opacity=function(t){return t?a(t).getAlpha():0},i.addOpacity=function(t,e){var n=a(t).toRgb();return"rgba("+Math.round(n.r)+", "+Math.round(n.g)+", "+Math.round(n.b)+", "+e+")"},i.combine=function(t,e){var n=a(t).toRgb();if(1===n.a)return a(t).toRgbString();var r=a(e||i.background).toRgb(),o=1===r.a?r:{r:255*(1-r.a)+r.r*r.a,g:255*(1-r.a)+r.g*r.a,b:255*(1-r.a)+r.b*r.a},l={r:o.r*(1-n.a)+n.r*n.a,g:o.g*(1-n.a)+n.g*n.a,b:o.b*(1-n.a)+n.b*n.a};return a(l).toRgbString()},i.contrast=function(t,e,n){var r=a(t),o=r.isLight()?r.darken(n):r.lighten(e);return o.toString()},i.stroke=function(t,e){var n=a(e);t.style({stroke:i.tinyRGB(n),"stroke-opacity":n.getAlpha()})},i.fill=function(t,e){var n=a(e);t.style({fill:i.tinyRGB(n),"fill-opacity":n.getAlpha()})},i.clean=function(t){if(t&&"object"==typeof t){var e,n,a,o,l=Object.keys(t);for(e=0;es&&(o[1]-=(it-s)/2)):n.node()&&!n.classed("js-placeholder")&&(it=d.bBox(e.node()).height),it){if(it+=5,"top"===b.titleside)J.domain[1]-=it/A.h,o[1]*=-1;else{J.domain[0]+=it/A.h;var u=Math.max(1,n.selectAll("tspan.line").size());o[1]+=(1-u)*s}e.attr("transform","translate("+o+")"),J.setScale()}}at.selectAll(".cbfills,.cblines,.cbaxis").attr("transform","translate(0,"+Math.round(A.h*(1-J.domain[1]))+")");var f=at.select(".cbfills").selectAll("rect.cbfill").data(S);f.enter().append("rect").classed("cbfill",!0).style("stroke","none"),f.exit().remove(),f.each(function(t,e){var n=[0===e?L[0]:(S[e]+S[e-1])/2,e===S.length-1?L[1]:(S[e]+S[e+1])/2].map(J.c2p).map(Math.round);e!==S.length-1&&(n[1]+=n[1]>n[0]?1:-1);var o=E(t).replace("e-",""),i=a(o).toHexString();r.select(this).attr({x:Z,width:Math.max(F,2),y:r.min(n),height:Math.max(r.max(n)-r.min(n),2),fill:i})});var h=at.select(".cblines").selectAll("path.cbline").data(b.line.color&&b.line.width?z:[]);return h.enter().append("path").classed("cbline",!0),h.exit().remove(), ++h.each(function(t){r.select(this).attr("d","M"+Z+","+(Math.round(J.c2p(t))+b.line.width/2%1)+"h"+F).call(d.lineGroupStyle,b.line.width,C(t),b.line.dash)}),J._axislayer.selectAll("g."+J._id+"tick,path").remove(),J._pos=Z+F+(b.outlinewidth||0)/2-("outside"===b.ticks?1:0),J.side="right",c.syncOrAsync([function(){return l.doTicks(t,J,!0)},function(){if(["top","bottom"].indexOf(b.titleside)===-1){var e=J.titlefont.size,n=J._offset+J._length/2,a=A.l+(J.position||0)*A.w+("right"===J.side?10+e*(J.showticklabels?1:.5):-10-e*(J.showticklabels?.5:0));w("h"+J._id+"title",{avoid:{selection:r.select(t).selectAll("g."+J._id+"tick"),side:b.titleside,offsetLeft:A.l,offsetTop:A.t,maxShift:M.width},attributes:{x:a,y:n,"text-anchor":"middle"},transform:{rotate:"-90",offset:0}})}}])}function w(e,n){var r,a=x();r=i.traceIs(a,"markerColorscale")?"marker.colorbar.title":"colorbar.title";var o={propContainer:J,propName:r,traceIndex:a.index,dfltName:"colorscale",containerGroup:at.select(".cbtitle")},l="h"===e.charAt(0)?e.substr(1):"h"+e;at.selectAll("."+l+",."+l+"-math-group").remove(),p.draw(t,e,u(o,n||{}))}function k(){var n=F+b.outlinewidth/2+d.bBox(J._axislayer.node()).width;if(D=ot.select("text"),D.node()&&!D.classed("js-placeholder")){var r,a=ot.select(".h"+J._id+"title-math-group").node();r=a&&["top","bottom"].indexOf(b.titleside)!==-1?d.bBox(a).width:d.bBox(ot.node()).right-Z-A.l,n=Math.max(n,r)}var o=2*b.xpad+n+b.borderwidth+b.outlinewidth/2,l=Q-$;at.select(".cbbg").attr({x:Z-b.xpad-(b.borderwidth+b.outlinewidth)/2,y:$-U,width:Math.max(o,2),height:Math.max(l+2*U,2)}).call(h.fill,b.bgcolor).call(h.stroke,b.bordercolor).style({"stroke-width":b.borderwidth}),at.selectAll(".cboutline").attr({x:Z,y:$+b.ypad+("top"===b.titleside?it:0),width:Math.max(F,2),height:Math.max(l-2*b.ypad-it,2)}).call(h.stroke,b.outlinecolor).style({fill:"None","stroke-width":b.outlinewidth});var s=({center:.5,right:1}[b.xanchor]||0)*o;at.attr("transform","translate("+(A.l-s)+","+A.t+")"),i.autoMargin(t,e,{x:b.x,y:b.y,l:o*({right:1,center:.5}[b.xanchor]||0),r:o*({left:1,center:.5}[b.xanchor]||0),t:l*({bottom:1,middle:.5}[b.yanchor]||0),b:l*({top:1,middle:.5}[b.yanchor]||0)})}var M=t._fullLayout,A=M._size;if("function"!=typeof b.fillcolor&&"function"!=typeof b.line.color)return void M._infolayer.selectAll("g."+e).remove();var T,L=r.extent(("function"==typeof b.fillcolor?b.fillcolor:b.line.color).domain()),z=[],S=[],C="function"==typeof b.line.color?b.line.color:function(){return b.line.color},E="function"==typeof b.fillcolor?b.fillcolor:function(){return b.fillcolor},N=b.levels.end+b.levels.size/100,O=b.levels.size,P=1.001*L[0]-.001*L[1],j=1.001*L[1]-.001*L[0];for(T=b.levels.start;(T-N)*O<0;T+=O)T>P&&TL[0]&&T1){var rt=Math.pow(10,Math.floor(Math.log(nt)/Math.LN10));tt*=rt*c.roundUp(nt/rt,[2,5,10]),(Math.abs(b.levels.start)/b.levels.size+1e-6)%1<2e-6&&(J.tick0=0)}J.dtick=tt}J.domain=[X+G,X+H-G],J.setScale();var at=M._infolayer.selectAll("g."+e).data([0]);at.enter().append("g").classed(e,!0).each(function(){var t=r.select(this);t.append("rect").classed("cbbg",!0),t.append("g").classed("cbfills",!0),t.append("g").classed("cblines",!0),t.append("g").classed("cbaxis",!0).classed("crisp",!0),t.append("g").classed("cbtitleunshift",!0).append("g").classed("cbtitle",!0),t.append("rect").classed("cboutline",!0),t.select(".cbtitle").datum(0)}),at.attr("transform","translate("+Math.round(A.l)+","+Math.round(A.t)+")");var ot=at.select(".cbtitleunshift").attr("transform","translate(-"+Math.round(A.l)+",-"+Math.round(A.t)+")");J._axislayer=at.select(".cbaxis");var it=0;if(["top","bottom"].indexOf(b.titleside)!==-1){var lt,st=A.l+(b.x+V)*A.w,ct=J.titlefont.size;lt="top"===b.titleside?(1-(X+H-G))*A.h+A.t+3+.75*ct:(1-(X+G))*A.h+A.t-3-.25*ct,w(J._id+"title",{attributes:{x:st,y:lt,"text-anchor":"start"}})}var ut=c.syncOrAsync([i.previousPromises,_,i.previousPromises,k],t);if(ut&&ut.then&&(t._promises||[]).push(ut),t._context.editable){var ft,dt,ht;s.init({element:at.node(),prepFn:function(){ft=at.attr("transform"),f(at)},moveFn:function(t,e){at.attr("transform",ft+" translate("+t+","+e+")"),dt=s.align(Y+t/A.w,q,0,1,b.xanchor),ht=s.align(X-e/A.h,H,0,1,b.yanchor);var n=s.getCursor(dt,ht,b.xanchor,b.yanchor);f(at,n)},doneFn:function(e){f(at),e&&void 0!==dt&&void 0!==ht&&o.restyle(t,{"colorbar.x":dt,"colorbar.y":ht},x().index)}})}return ut}function x(){var n,r,a=e.substr(2);for(n=0;n=0?a.Reds:a.Blues,s.colorscale=d,l.reversescale&&(d=o(d)),l.colorscale=d)}},{"../../lib":99,"./flip_scale":31,"./scales":38}],28:[function(t,e,n){"use strict";var r=t("./attributes"),a=t("../../lib/extend").extendDeep;t("./scales.js");e.exports=function(t){return{color:{valType:"color",arrayOk:!0},colorscale:a({},r.colorscale,{}),cauto:a({},r.zauto,{}),cmax:a({},r.zmax,{}),cmin:a({},r.zmin,{}),autocolorscale:a({},r.autocolorscale,{}),reversescale:a({},r.reversescale,{})}}},{"../../lib/extend":96,"./attributes":26,"./scales.js":38}],29:[function(t,e,n){"use strict";var r=t("./scales");e.exports=r.RdBu},{"./scales":38}],30:[function(t,e,n){"use strict";var r=t("fast-isnumeric"),a=t("../../lib"),o=t("../colorbar/has_colorbar"),i=t("../colorbar/defaults"),l=t("./is_valid_scale"),s=t("./flip_scale");e.exports=function(t,e,n,c,u){var f=u.prefix,d=u.cLetter,h=f.slice(0,f.length-1),p=f?a.nestedProperty(t,h).get()||{}:t,g=f?a.nestedProperty(e,h).get()||{}:e,v=p[d+"min"],m=p[d+"max"],y=p.colorscale,x=r(v)&&r(m)&&v=0;a--,o++)e=t[a],r[o]=[1-e[0],e[1]];return r}},{}],32:[function(t,e,n){"use strict";var r=t("./scales"),a=t("./default_scale"),o=t("./is_valid_scale_array");e.exports=function(t,e){function n(){try{t=r[t]||JSON.parse(t)}catch(n){t=e}}return e||(e=a),t?("string"==typeof t&&(n(),"string"==typeof t&&n()),o(t)?t:e):e}},{"./default_scale":29,"./is_valid_scale_array":36,"./scales":38}],33:[function(t,e,n){"use strict";var r=t("fast-isnumeric"),a=t("../../lib"),o=t("./is_valid_scale");e.exports=function(t,e){var n=e?a.nestedProperty(t,e).get()||{}:t,i=n.color,l=!1;if(Array.isArray(i))for(var s=0;s4/3-l?i:l}},{}],40:[function(t,e,n){"use strict";var r=t("../../lib"),a=[["sw-resize","s-resize","se-resize"],["w-resize","move","e-resize"],["nw-resize","n-resize","ne-resize"]];e.exports=function(t,e,n,o){return t="left"===n?0:"center"===n?1:"right"===n?2:r.constrain(Math.floor(3*t),0,2),e="bottom"===o?0:"middle"===o?1:"top"===o?2:r.constrain(Math.floor(3*e),0,2),a[e][t]}},{"../../lib":99}],41:[function(t,e,n){"use strict";function r(){var t=document.createElement("div");t.className="dragcover";var e=t.style;return e.position="fixed",e.left=0,e.right=0,e.top=0,e.bottom=0,e.zIndex=999999999,e.background="none",document.body.appendChild(t),t}function a(t){t._dragging=!1,t._replotPending&&o.plot(t)}var o=t("../../plotly"),i=t("../../lib"),l=t("../../plots/cartesian/constants"),s=e.exports={};s.align=t("./align"),s.getCursor=t("./cursor");var c=t("./unhover");s.unhover=c.wrapped,s.unhoverRaw=c.raw,s.init=function(t){function e(e){return t.element.onmousemove=p,g._dragged=!1,g._dragging=!0,c=e.clientX,u=e.clientY,h=e.target,f=(new Date).getTime(),f-g._mouseDownTimem&&(v=Math.max(v-1,1)),t.doneFn&&t.doneFn(g._dragged,v),!g._dragged){var n=document.createEvent("MouseEvents");n.initEvent("click",!0,!0),h.dispatchEvent(n)}return a(g),g._dragged=!1,i.pauseEvent(e)}var c,u,f,d,h,p,g=i.getPlotDiv(t.element)||{},v=1,m=l.DBLCLICKDELAY;g._mouseDownTime||(g._mouseDownTime=0),p=t.element.onmousemove,t.setCursor&&(t.element.onmousemove=t.setCursor),t.element.onmousedown=e,t.element.style.pointerEvents="all"}},{"../../lib":99,"../../plotly":118,"../../plots/cartesian/constants":126,"./align":39,"./cursor":40,"./unhover":42}],42:[function(t,e,n){"use strict";var r=t("../../lib/events"),a=e.exports={};a.wrapped=function(t,e,n){"string"==typeof t&&(t=document.getElementById(t)),t._hoverTimer&&(clearTimeout(t._hoverTimer),t._hoverTimer=void 0),a.raw(t,e,n)},a.raw=function(t,e){var n=t._fullLayout;e||(e={}),e.target&&r.triggerHandler(t,"plotly_beforehover",e)===!1||(n._hoverlayer.selectAll("g").remove(),e.target&&t._hoverdata&&t.emit("plotly_unhover",{points:t._hoverdata}),t._hoverdata=void 0)}},{"../../lib/events":95}],43:[function(t,e,n){"use strict";function r(t,e,n,r){var o=t[0]-e[0],i=t[1]-e[1],l=n[0]-e[0],s=n[1]-e[1],c=Math.pow(o*o+i*i,b/2),u=Math.pow(l*l+s*s,b/2),f=(u*u*o-c*c*l)*r,d=(u*u*i-c*c*s)*r,h=3*u*(c+u),p=3*c*(c+u);return[[a.round(e[0]+(h&&f/h),2),a.round(e[1]+(h&&d/h),2)],[a.round(e[0]-(p&&f/p),2),a.round(e[1]-(p&&d/p),2)]]}var a=t("d3"),o=t("fast-isnumeric"),i=t("../../plots/plots"),l=t("../color"),s=t("../colorscale"),c=t("../../lib"),u=t("../../lib/svg_text_utils"),f=t("../../constants/xmlns_namespaces"),d=t("../../traces/scatter/subtypes"),h=t("../../traces/scatter/make_bubble_size_func"),p=e.exports={};p.font=function(t,e,n,r){e&&e.family&&(r=e.color,n=e.size,e=e.family),e&&t.style("font-family",e),n+1&&t.style("font-size",n+"px"),r&&t.call(l.fill,r)},p.setPosition=function(t,e,n){t.attr("x",e).attr("y",n)},p.setSize=function(t,e,n){t.attr("width",e).attr("height",n)},p.setRect=function(t,e,n,r,a){t.call(p.setPosition,e,n).call(p.setSize,r,a)},p.translatePoints=function(t,e,n){t.each(function(t){var r=t.xp||e.c2p(t.x),i=t.yp||n.c2p(t.y),l=a.select(this);o(r)&&o(i)?"text"===this.nodeName?l.attr("x",r).attr("y",i):l.attr("transform","translate("+r+","+i+")"):l.remove()})},p.getPx=function(t,e){return Number(t.style(e).replace(/px$/,""))},p.crispRound=function(t,e,n){return e&&o(e)?t._context.staticPlot?e:e<1?1:Math.round(e):n||0},p.lineGroupStyle=function(t,e,n,r){t.style("fill","none").each(function(t){var o=(((t||[])[0]||{}).trace||{}).line||{},i=e||o.width||0,s=r||o.dash||"";a.select(this).call(l.stroke,n||o.color).call(p.dashLine,s,i)})},p.dashLine=function(t,e,n){var r=Math.max(n,3);"solid"===e?e="":"dot"===e?e=r+"px,"+r+"px":"dash"===e?e=3*r+"px,"+3*r+"px":"longdash"===e?e=5*r+"px,"+5*r+"px":"dashdot"===e?e=3*r+"px,"+r+"px,"+r+"px,"+r+"px":"longdashdot"===e&&(e=5*r+"px,"+2*r+"px,"+r+"px,"+2*r+"px"),t.style({"stroke-dasharray":e,"stroke-width":n+"px"})},p.fillGroupStyle=function(t){t.style("stroke-width",0).each(function(e){var n=a.select(this);try{n.call(l.fill,e[0].trace.fillcolor)}catch(e){c.error(e,t),n.remove()}})};var g=t("./symbol_defs");p.symbolNames=[],p.symbolFuncs=[],p.symbolNeedLines={},p.symbolNoDot={},p.symbolList=[],Object.keys(g).forEach(function(t){var e=g[t];p.symbolList=p.symbolList.concat([e.n,t,e.n+100,t+"-open"]),p.symbolNames[e.n]=t,p.symbolFuncs[e.n]=e.f,e.needLine&&(p.symbolNeedLines[e.n]=!0),e.noDot?p.symbolNoDot[e.n]=!0:p.symbolList=p.symbolList.concat([e.n+200,t+"-dot",e.n+300,t+"-open-dot"])});var v=p.symbolNames.length,m="M0,0.5L0.5,0L0,-0.5L-0.5,0Z";p.symbolNumber=function(t){if("string"==typeof t){var e=0;t.indexOf("-open")>0&&(e=100,t=t.replace("-open","")),t.indexOf("-dot")>0&&(e+=200,t=t.replace("-dot","")),t=p.symbolNames.indexOf(t),t>=0&&(t+=e)}return t%100>=v||t>=400?0:Math.floor(Math.max(t,0))},p.pointStyle=function(t,e){if(t.size()){var n=e.marker,r=n.line;if(i.traceIs(e,"symbols")){var o=h(e);t.attr("d",function(t){var r;r="various"===t.ms||"various"===n.size?3:d.isBubble(e)?o(t.ms):(n.size||6)/2,t.mrc=r;var a=p.symbolNumber(t.mx||n.symbol)||0,i=a%100;return t.om=a%200>=100,p.symbolFuncs[i](r)+(a>=200?m:"")}).style("opacity",function(t){return(t.mo+1||n.opacity+1)-1})}var s=(e._input||{}).marker||{},c=p.tryColorscale(n,s,""),u=p.tryColorscale(n,s,"line.");t.each(function(t){var e,o,i;t.so?(i=r.outlierwidth,o=r.outliercolor,e=n.outliercolor):(i=(t.mlw+1||r.width+1||(t.trace?t.trace.marker.line.width:0)+1)-1,o="mlc"in t?t.mlcc=u(t.mlc):Array.isArray(r.color)?l.defaultLine:r.color,e="mc"in t?t.mcc=c(t.mc):Array.isArray(n.color)?l.defaultLine:n.color||"rgba(0,0,0,0)");var s=a.select(this);t.om?s.call(l.stroke,e).style({"stroke-width":(i||1)+"px",fill:"none"}):(s.style("stroke-width",i+"px").call(l.fill,e),i&&s.call(l.stroke,o))})}},p.tryColorscale=function(t,e,n){var r=c.nestedProperty(t,n+"color").get(),a=c.nestedProperty(t,n+"colorscale").get(),i=c.nestedProperty(t,n+"cauto").get(),l=c.nestedProperty(t,n+"cmin"),u=c.nestedProperty(t,n+"cmax"),f=l.get(),d=u.get();return a&&Array.isArray(r)?(!i&&o(f)&&o(d)||(f=1/0,d=-(1/0),r.forEach(function(t){o(t)&&(f>t&&(f=+t),dd&&(f=0,d=1),l.set(f),u.set(d),c.nestedProperty(e,n+"cmin").set(f),c.nestedProperty(e,n+"cmax").set(d)),s.makeScaleFunction(a,f,d)):c.identity};var y={start:1,end:-1,middle:0,bottom:1,top:-1},x=1.3;p.textPointStyle=function(t,e){t.each(function(t){var n=a.select(this),r=t.tx||e.text;if(!r||Array.isArray(r))return void n.remove();var i=t.tp||e.textposition,l=i.indexOf("top")!==-1?"top":i.indexOf("bottom")!==-1?"bottom":"middle",s=i.indexOf("left")!==-1?"end":i.indexOf("right")!==-1?"start":"middle",c=t.ts||e.textfont.size,f=t.mrc?t.mrc/.8+1:0;c=o(c)&&c>0?c:0,n.call(p.font,t.tf||e.textfont.family,c,t.tc||e.textfont.color).attr("text-anchor",s).text(r).call(u.convertToTspans);var d=a.select(this.parentNode),h=n.selectAll("tspan.line"),g=((h[0].length||1)-1)*x+1,v=y[s]*f,m=.75*c+y[l]*f+(y[l]-1)*g*c/2;d.attr("transform","translate("+v+","+m+")"),g>1&&h.attr({x:n.attr("x"),y:n.attr("y")})})};var b=.5;p.smoothopen=function(t,e){if(t.length<3)return"M"+t.join("L");var n,a="M"+t[0],o=[];for(n=1;n=M&&(a.selectAll("[data-bb]").attr("data-bb",null),k=[]),t.setAttribute("data-bb",k.length),k.push(s),c.extendFlat({},s)},p.setClipUrl=function(t,e){if(!e)return void t.attr("clip-path",null);var n="#"+e,r=a.select("base");r.size()&&r.attr("href")&&(n=window.location.href+n),t.attr("clip-path","url("+n+")")}},{"../../constants/xmlns_namespaces":89,"../../lib":99,"../../lib/svg_text_utils":110,"../../plots/plots":153,"../../traces/scatter/make_bubble_size_func":189,"../../traces/scatter/subtypes":194,"../color":20,"../colorscale":34,"./symbol_defs":44,d3:8,"fast-isnumeric":11}],44:[function(t,e,n){"use strict";var r=t("d3");e.exports={circle:{n:0,f:function(t){var e=r.round(t,2);return"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"}},square:{n:1,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"}},diamond:{n:2,f:function(t){var e=r.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"Z"}},cross:{n:3,f:function(t){var e=r.round(.4*t,2),n=r.round(1.2*t,2);return"M"+n+","+e+"H"+e+"V"+n+"H-"+e+"V"+e+"H-"+n+"V-"+e+"H-"+e+"V-"+n+"H"+e+"V-"+e+"H"+n+"Z"}},x:{n:4,f:function(t){var e=r.round(.8*t/Math.sqrt(2),2),n="l"+e+","+e,a="l"+e+",-"+e,o="l-"+e+",-"+e,i="l-"+e+","+e;return"M0,"+e+n+a+o+a+o+i+o+i+n+i+n+"Z"}},"triangle-up":{n:5,f:function(t){var e=r.round(2*t/Math.sqrt(3),2),n=r.round(t/2,2),a=r.round(t,2);return"M-"+e+","+n+"H"+e+"L0,-"+a+"Z"}},"triangle-down":{n:6,f:function(t){var e=r.round(2*t/Math.sqrt(3),2),n=r.round(t/2,2),a=r.round(t,2);return"M-"+e+",-"+n+"H"+e+"L0,"+a+"Z"}},"triangle-left":{n:7,f:function(t){var e=r.round(2*t/Math.sqrt(3),2),n=r.round(t/2,2),a=r.round(t,2);return"M"+n+",-"+e+"V"+e+"L-"+a+",0Z"}},"triangle-right":{n:8,f:function(t){var e=r.round(2*t/Math.sqrt(3),2),n=r.round(t/2,2),a=r.round(t,2);return"M-"+n+",-"+e+"V"+e+"L"+a+",0Z"}},"triangle-ne":{n:9,f:function(t){var e=r.round(.6*t,2),n=r.round(1.2*t,2);return"M-"+n+",-"+e+"H"+e+"V"+n+"Z"}},"triangle-se":{n:10,f:function(t){var e=r.round(.6*t,2),n=r.round(1.2*t,2);return"M"+e+",-"+n+"V"+e+"H-"+n+"Z"}},"triangle-sw":{n:11,f:function(t){var e=r.round(.6*t,2),n=r.round(1.2*t,2);return"M"+n+","+e+"H-"+e+"V-"+n+"Z"}},"triangle-nw":{n:12,f:function(t){var e=r.round(.6*t,2),n=r.round(1.2*t,2);return"M-"+e+","+n+"V-"+e+"H"+n+"Z"}},pentagon:{n:13,f:function(t){var e=r.round(.951*t,2),n=r.round(.588*t,2),a=r.round(-t,2),o=r.round(t*-.309,2),i=r.round(.809*t,2);return"M"+e+","+o+"L"+n+","+i+"H-"+n+"L-"+e+","+o+"L0,"+a+"Z"}},hexagon:{n:14,f:function(t){var e=r.round(t,2),n=r.round(t/2,2),a=r.round(t*Math.sqrt(3)/2,2);return"M"+a+",-"+n+"V"+n+"L0,"+e+"L-"+a+","+n+"V-"+n+"L0,-"+e+"Z"}},hexagon2:{n:15,f:function(t){var e=r.round(t,2),n=r.round(t/2,2),a=r.round(t*Math.sqrt(3)/2,2);return"M-"+n+","+a+"H"+n+"L"+e+",0L"+n+",-"+a+"H-"+n+"L-"+e+",0Z"}},octagon:{n:16,f:function(t){var e=r.round(.924*t,2),n=r.round(.383*t,2);return"M-"+n+",-"+e+"H"+n+"L"+e+",-"+n+"V"+n+"L"+n+","+e+"H-"+n+"L-"+e+","+n+"V-"+n+"Z"}},star:{n:17,f:function(t){var e=1.4*t,n=r.round(.225*e,2),a=r.round(.951*e,2),o=r.round(.363*e,2),i=r.round(.588*e,2),l=r.round(-e,2),s=r.round(e*-.309,2),c=r.round(.118*e,2),u=r.round(.809*e,2),f=r.round(.382*e,2);return"M"+n+","+s+"H"+a+"L"+o+","+c+"L"+i+","+u+"L0,"+f+"L-"+i+","+u+"L-"+o+","+c+"L-"+a+","+s+"H-"+n+"L0,"+l+"Z"}},hexagram:{n:18,f:function(t){var e=r.round(.66*t,2),n=r.round(.38*t,2),a=r.round(.76*t,2);return"M-"+a+",0l-"+n+",-"+e+"h"+a+"l"+n+",-"+e+"l"+n+","+e+"h"+a+"l-"+n+","+e+"l"+n+","+e+"h-"+a+"l-"+n+","+e+"l-"+n+",-"+e+"h-"+a+"Z"}},"star-triangle-up":{n:19,f:function(t){var e=r.round(t*Math.sqrt(3)*.8,2),n=r.round(.8*t,2),a=r.round(1.6*t,2),o=r.round(4*t,2),i="A "+o+","+o+" 0 0 1 ";return"M-"+e+","+n+i+e+","+n+i+"0,-"+a+i+"-"+e+","+n+"Z"}},"star-triangle-down":{n:20,f:function(t){var e=r.round(t*Math.sqrt(3)*.8,2),n=r.round(.8*t,2),a=r.round(1.6*t,2),o=r.round(4*t,2),i="A "+o+","+o+" 0 0 1 ";return"M"+e+",-"+n+i+"-"+e+",-"+n+i+"0,"+a+i+e+",-"+n+"Z"}},"star-square":{n:21,f:function(t){var e=r.round(1.1*t,2),n=r.round(2*t,2),a="A "+n+","+n+" 0 0 1 ";return"M-"+e+",-"+e+a+"-"+e+","+e+a+e+","+e+a+e+",-"+e+a+"-"+e+",-"+e+"Z"}},"star-diamond":{n:22,f:function(t){var e=r.round(1.4*t,2),n=r.round(1.9*t,2),a="A "+n+","+n+" 0 0 1 ";return"M-"+e+",0"+a+"0,"+e+a+e+",0"+a+"0,-"+e+a+"-"+e+",0Z"}},"diamond-tall":{n:23,f:function(t){var e=r.round(.7*t,2),n=r.round(1.4*t,2);return"M0,"+n+"L"+e+",0L0,-"+n+"L-"+e+",0Z"}},"diamond-wide":{n:24,f:function(t){var e=r.round(1.4*t,2),n=r.round(.7*t,2);return"M0,"+n+"L"+e+",0L0,-"+n+"L-"+e+",0Z"}},hourglass:{n:25,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"H-"+e+"L"+e+",-"+e+"H-"+e+"Z"},noDot:!0},bowtie:{n:26,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"V-"+e+"L-"+e+","+e+"V-"+e+"Z"},noDot:!0},"circle-cross":{n:27,f:function(t){var e=r.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"circle-x":{n:28,f:function(t){var e=r.round(t,2),n=r.round(t/Math.sqrt(2),2);return"M"+n+","+n+"L-"+n+",-"+n+"M"+n+",-"+n+"L-"+n+","+n+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"square-cross":{n:29,f:function(t){var e=r.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"square-x":{n:30,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"diamond-cross":{n:31,f:function(t){var e=r.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM0,-"+e+"V"+e+"M-"+e+",0H"+e},needLine:!0,noDot:!0},"diamond-x":{n:32,f:function(t){var e=r.round(1.3*t,2),n=r.round(.65*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM-"+n+",-"+n+"L"+n+","+n+"M-"+n+","+n+"L"+n+",-"+n},needLine:!0,noDot:!0},"cross-thin":{n:33,f:function(t){var e=r.round(1.4*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e},needLine:!0,noDot:!0},"x-thin":{n:34,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0},asterisk:{n:35,f:function(t){var e=r.round(1.2*t,2),n=r.round(.85*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+n+","+n+"L-"+n+",-"+n+"M"+n+",-"+n+"L-"+n+","+n},needLine:!0,noDot:!0},hash:{n:36,f:function(t){var e=r.round(t/2,2),n=r.round(t,2);return"M"+e+","+n+"V-"+n+"m-"+n+",0V"+n+"M"+n+","+e+"H-"+n+"m0,-"+n+"H"+n},needLine:!0},"y-up":{n:37,f:function(t){var e=r.round(1.2*t,2),n=r.round(1.6*t,2),a=r.round(.8*t,2);return"M-"+e+","+a+"L0,0M"+e+","+a+"L0,0M0,-"+n+"L0,0"},needLine:!0,noDot:!0},"y-down":{n:38,f:function(t){var e=r.round(1.2*t,2),n=r.round(1.6*t,2),a=r.round(.8*t,2);return"M-"+e+",-"+a+"L0,0M"+e+",-"+a+"L0,0M0,"+n+"L0,0"},needLine:!0,noDot:!0},"y-left":{n:39,f:function(t){var e=r.round(1.2*t,2),n=r.round(1.6*t,2),a=r.round(.8*t,2);return"M"+a+","+e+"L0,0M"+a+",-"+e+"L0,0M-"+n+",0L0,0"},needLine:!0,noDot:!0},"y-right":{n:40,f:function(t){var e=r.round(1.2*t,2),n=r.round(1.6*t,2),a=r.round(.8*t,2); ++return"M-"+a+","+e+"L0,0M-"+a+",-"+e+"L0,0M"+n+",0L0,0"},needLine:!0,noDot:!0},"line-ew":{n:41,f:function(t){var e=r.round(1.4*t,2);return"M"+e+",0H-"+e},needLine:!0,noDot:!0},"line-ns":{n:42,f:function(t){var e=r.round(1.4*t,2);return"M0,"+e+"V-"+e},needLine:!0,noDot:!0},"line-ne":{n:43,f:function(t){var e=r.round(t,2);return"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0},"line-nw":{n:44,f:function(t){var e=r.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e},needLine:!0,noDot:!0}}},{d3:8}],45:[function(t,e,n){"use strict";e.exports={visible:{valType:"boolean"},type:{valType:"enumerated",values:["percent","constant","sqrt","data"]},symmetric:{valType:"boolean"},array:{valType:"data_array"},arrayminus:{valType:"data_array"},value:{valType:"number",min:0,dflt:10},valueminus:{valType:"number",min:0,dflt:10},traceref:{valType:"integer",min:0,dflt:0},tracerefminus:{valType:"integer",min:0,dflt:0},copy_ystyle:{valType:"boolean"},copy_zstyle:{valType:"boolean"},color:{valType:"color"},thickness:{valType:"number",min:0,dflt:2},width:{valType:"number",min:0},_deprecated:{opacity:{valType:"number"}}}},{}],46:[function(t,e,n){"use strict";function r(t,e,n,r){var o=e["error_"+r]||{},s=o.visible&&["linear","log"].indexOf(n.type)!==-1,c=[];if(s){for(var u=l(o),f=0;f0;if(u.visible||c.visible){var d=a.select(this).selectAll("g.errorbar").data(i.identity);d.enter().append("g").classed("errorbar",!0),d.each(function(t){var e=a.select(this),i=r(t,n,s);if(!f||t.vis){var l;if(u.visible&&o(i.x)&&o(i.yh)&&o(i.ys)){var d=u.width;l="M"+(i.x-d)+","+i.yh+"h"+2*d+"m-"+d+",0V"+i.ys,i.noYS||(l+="m-"+d+",0h"+2*d),e.append("path").classed("yerror",!0).attr("d",l)}if(c.visible&&o(i.y)&&o(i.xh)&&o(i.xs)){var h=(c.copy_ystyle?u:c).width;l="M"+i.xh+","+(i.y-h)+"v"+2*h+"m0,-"+h+"H"+i.xs,i.noXS||(l+="m0,-"+h+"v"+2*h),e.append("path").classed("xerror",!0).attr("d",l)}}})}})}},{"../../lib":99,"../../traces/scatter/subtypes":194,d3:8,"fast-isnumeric":11}],51:[function(t,e,n){"use strict";var r=t("d3"),a=t("../color");e.exports=function(t){t.each(function(t){var e=t[0].trace,n=e.error_y||{},o=e.error_x||{},i=r.select(this);i.selectAll("path.yerror").style("stroke-width",n.thickness+"px").call(a.stroke,n.color),o.copy_ystyle&&(o=n),i.selectAll("path.xerror").style("stroke-width",o.thickness+"px").call(a.stroke,o.color)})}},{"../color":20,d3:8}],52:[function(t,e,n){"use strict";var r=t("../../plots/cartesian/constants");e.exports={_isLinkedToArray:!0,source:{valType:"string"},layer:{valType:"enumerated",values:["below","above"],dflt:"above"},sizex:{valType:"number",dflt:0},sizey:{valType:"number",dflt:0},sizing:{valType:"enumerated",values:["fill","contain","stretch"],dflt:"contain"},opacity:{valType:"number",min:0,max:1,dflt:1},x:{valType:"number",dflt:0},y:{valType:"number",dflt:0},xanchor:{valType:"enumerated",values:["left","center","right"],dflt:"left"},yanchor:{valType:"enumerated",values:["top","middle","bottom"],dflt:"top"},xref:{valType:"enumerated",values:["paper",r.idRegex.x.toString()],dflt:"paper"},yref:{valType:"enumerated",values:["paper",r.idRegex.y.toString()],dflt:"paper"}}},{"../../plots/cartesian/constants":126}],53:[function(t,e,n){"use strict";function r(t,e,n){function r(n,r){return o.coerce(t,e,i,n,r)}e=e||{},r("source"),r("layer"),r("x"),r("y"),r("xanchor"),r("yanchor"),r("sizex"),r("sizey"),r("sizing"),r("opacity");for(var l=0;l<2;l++){var s={_fullLayout:n},c=["x","y"][l];a.coerceRef(t,e,s,c,"paper")}return e}var a=t("../../plots/cartesian/axes"),o=t("../../lib"),i=t("./attributes");e.exports=function(t,e){if(t.images&&Array.isArray(t.images))for(var n=t.images,a=e.images=[],o=0;o=2/3},n.isCenterAnchor=function(t){return"center"===t.xanchor||"auto"===t.xanchor&&t.x>1/3&&t.x<2/3},n.isBottomAnchor=function(t){return"bottom"===t.yanchor||"auto"===t.yanchor&&t.y<=1/3},n.isMiddleAnchor=function(t){return"middle"===t.yanchor||"auto"===t.yanchor&&t.y>1/3&&t.y<2/3}},{}],57:[function(t,e,n){"use strict";var r=t("../../plots/font_attributes"),a=t("../color/attributes"),o=t("../../lib/extend").extendFlat;e.exports={bgcolor:{valType:"color"},bordercolor:{valType:"color",dflt:a.defaultLine},borderwidth:{valType:"number",min:0,dflt:0},font:o({},r,{}),orientation:{valType:"enumerated",values:["v","h"],dflt:"v"},horizontalspacing:{valType:"enumerated",values:["column","wrapped"],dflt:["column"]},traceorder:{valType:"flaglist",flags:["reversed","grouped"],extras:["normal"]},tracegroupgap:{valType:"number",min:0,dflt:10},x:{valType:"number",min:-2,max:3,dflt:1.02},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"left"},y:{valType:"number",min:-2,max:3,dflt:1},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto"}}},{"../../lib/extend":96,"../../plots/font_attributes":139,"../color/attributes":19}],58:[function(t,e,n){"use strict";e.exports={scrollBarWidth:4,scrollBarHeight:20,scrollBarColor:"#808BA4",scrollBarMargin:4}},{}],59:[function(t,e,n){"use strict";var r=t("../../lib"),a=t("../../plots/plots"),o=t("./attributes"),i=t("./helpers");e.exports=function(t,e,n){function l(t,e){return r.coerce(d,h,o,t,e)}for(var s,c,u,f,d=t.legend||{},h=e.legend={},p=0,g="normal",v="column",m=0;m1);if(x!==!1){if(l("bgcolor",e.paper_bgcolor),l("bordercolor"),l("borderwidth"),r.coerceFont(l,"font",e.font),l("orientation"),"h"===h.orientation){var b=t.xaxis;b&&b.rangeslider&&b.rangeslider.visible?(s=0,u="left",c=1.1,f="bottom"):(s=0,u="left",c=-.1,f="top")}l("traceorder",g),i.isGrouped(e.legend)&&l("tracegroupgap"),l("x",s),l("xanchor",u),l("y",c),l("yanchor",f),l("horizontalspacing",v),r.noneOrAll(d,h,["x","y"])}}},{"../../lib":99,"../../plots/plots":153,"./attributes":57,"./helpers":62}],60:[function(t,e,n){"use strict";function r(t,e){function n(n){u.util.convertToTspans(n,function(){n.selectAll("tspan.line").attr({x:n.attr("x")}),t.call(o,e)})}var r=t.data()[0][0],a=e._fullLayout,i=r.trace,l=d.traceIs(i,"pie"),s=i.index,c=l?r.label:i.name,f=t.selectAll("text.legendtext").data([0]);f.enter().append("text").classed("legendtext",!0),f.attr({x:40,y:0,"data-unformatted":c}).style("text-anchor","start").classed("user-select-none",!0).call(p.font,a.legend.font).text(c),e._context.editable&&!l?f.call(u.util.makeEditable).call(n).on("edit",function(t){this.attr({"data-unformatted":t}),this.text(t).call(n),this.text()||(t=" "),u.restyle(e,"name",t,s)}):f.call(n)}function a(t,e){var n=e._fullLayout.hiddenlabels?e._fullLayout.hiddenlabels.slice():[],r=t.selectAll("rect").data([0]);r.enter().append("rect").classed("legendtoggle",!0).style("cursor","pointer").attr("pointer-events","all").call(g.fill,"rgba(0,0,0,0)"),r.on("click",function(){if(!e._dragged){var r,a,o=t.data()[0][0],i=e._fullData,l=o.trace,s=l.legendgroup,c=[];if(d.traceIs(l,"pie")){var f=o.label,h=n.indexOf(f);h===-1?n.push(f):n.splice(h,1),u.relayout(e,"hiddenlabels",n)}else{if(""===s)c=[l.index];else for(var p=0;ptspan"),h=d[0].length||1;n=s*h,r=u.node()&&p.bBox(u.node()).width;var g=s*(.3+(1-h)/2);u.attr("y",g),d.attr("y",g)}n=Math.max(n,16)+3,o.attr({x:0,y:-n/2,height:n}),a.height=n,a.width=r}function i(t,e,n){var r=t._fullLayout,a=r.legend,o=a.borderwidth,i=x.isGrouped(a),l=x.isHorizontalColumn(a);if(x.isVertical(a))i&&e.each(function(t,e){f.setTranslate(this,0,e*a.tracegroupgap)}),a.width=0,a.height=0,n.each(function(t){var e=t[0],n=e.height,r=e.width;f.setTranslate(this,o,5+o+a.height+n/2),a.height+=n,a.width=Math.max(a.width,r)}),a.width+=45+2*o,a.height+=10+2*o,i&&(a.height+=(a._lgroupsLength-1)*a.tracegroupgap),n.selectAll(".legendtoggle").attr("width",(t._context.editable?0:a.width)+40),a.width=Math.ceil(a.width),a.height=Math.ceil(a.height);else if(i){a.width=0,a.height=0;for(var s=[a.width],u=e.data(),d=0,h=u.length;dr.width-(r.margin.r+r.margin.l)&&(b=0,v+=m,a.height=a.height+m,m=0),f.setTranslate(this,o+b,5+o+e.height/2+v),a.width+=i+n,a.height=Math.max(a.height,e.height),b+=i+n,m=Math.max(e.height,m)}),a.width+=2*o,a.height+=10+2*o,a.width=Math.ceil(a.width),a.height=Math.ceil(a.height),n.selectAll(".legendtoggle").attr("width",t._context.editable?0:a.width)}}function l(t){var e=t._fullLayout,n=e.legend,r="left";b.isRightAnchor(n)?r="right":b.isCenterAnchor(n)&&(r="center");var a="top";b.isBottomAnchor(n)?a="bottom":b.isMiddleAnchor(n)&&(a="middle"),d.autoMargin(t,"legend",{x:n.x,y:n.y,l:n.width*({right:1,center:.5}[r]||0),r:n.width*({left:1,center:.5}[r]||0),b:n.height*({top:1,middle:.5}[a]||0),t:n.height*({bottom:1,middle:.5}[a]||0)})}function s(t){var e=t._fullLayout,n=e.legend,r="left";b.isRightAnchor(n)?r="right":b.isCenterAnchor(n)&&(r="center"),d.autoMargin(t,"legend",{x:n.x,y:.5,l:n.width*({right:1,center:.5}[r]||0),r:n.width*({left:1,center:.5}[r]||0),b:0,t:0})}var c=t("d3"),u=t("../../plotly"),f=t("../../lib"),d=t("../../plots/plots"),h=t("../dragelement"),p=t("../drawing"),g=t("../color"),v=t("./constants"),m=t("./get_legend_data"),y=t("./style"),x=t("./helpers"),b=t("./anchor_utils");e.exports=function(t){function e(t,e){T.attr("data-scroll",e).call(f.setTranslate,0,e),L.call(p.setRect,I,t,v.scrollBarWidth,v.scrollBarHeight),M.select("rect").attr({y:x.borderwidth-e})}var n=t._fullLayout,o="legend"+n._uid;if(n._infolayer&&t.calcdata){var x=n.legend,_=n.showlegend&&m(t.calcdata,x),w=n.hiddenlabels||[];if(!n.showlegend||!_.length)return n._infolayer.selectAll(".legend").remove(),n._topdefs.select("#"+o).remove(),void d.autoMargin(t,"legend");var k=n._infolayer.selectAll("g.legend").data([0]);k.enter().append("g").attr({class:"legend","pointer-events":"all"});var M=n._topdefs.selectAll("#"+o).data([0]);M.enter().append("clipPath").attr("id",o).append("rect");var A=k.selectAll("rect.bg").data([0]);A.enter().append("rect").attr({class:"bg","shape-rendering":"crispEdges"}),A.call(g.stroke,x.bordercolor),A.call(g.fill,x.bgcolor),A.style("stroke-width",x.borderwidth+"px");var T=k.selectAll("g.scrollbox").data([0]);T.enter().append("g").attr("class","scrollbox");var L=k.selectAll("rect.scrollbar").data([0]);L.enter().append("rect").attr({class:"scrollbar",rx:20,ry:2,width:0,height:0}).call(g.fill,"#808BA4");var z=T.selectAll("g.groups").data(_);z.enter().append("g").attr("class","groups"),z.exit().remove();var S=z.selectAll("g.traces").data(f.identity);S.enter().append("g").attr("class","traces"),S.exit().remove(),S.call(y).style("opacity",function(t){var e=t[0].trace;return d.traceIs(e,"pie")?w.indexOf(t[0].label)!==-1?.5:1:"legendonly"===e.visible?.5:1}).each(function(){c.select(this).call(r,t).call(a,t)});var C=0!==k.enter().size();C&&(i(t,z,S),l(t));var E=0,N=n.width,O=0,P=n.height;i(t,z,S),x.height>P?s(t):l(t);var j=n._size,D=j.l+j.w*x.x,R=j.t+j.h*(1-x.y);b.isRightAnchor(x)?D-=x.width:b.isCenterAnchor(x)&&(D-=x.width/2),b.isBottomAnchor(x)?R-=x.height:b.isMiddleAnchor(x)&&(R-=x.height/2);var I=x.width,F=j.w;I>F?(D=j.l,I=F):(D+I>N&&(D=N-I),DB?(R=j.t,q=B):(R+q>P&&(R=P-q),Rn[1])return n[1]}return a}function n(t){return t[0]}var r,a,o=t[0],i=o.trace,l=h.hasMarkers(i),u=h.hasText(i),d=h.hasLines(i);if(l||u||d){var p={},g={};l&&(p.mc=e("marker.color",n),p.mo=e("marker.opacity",c.mean,[.2,1]),p.ms=e("marker.size",c.mean,[2,16]),p.mlc=e("marker.line.color",n),p.mlw=e("marker.line.width",c.mean,[0,5]),g.marker={sizeref:1,sizemin:1,sizemode:"diameter"}),d&&(g.line={width:e("line.width",n,[0,10])}),u&&(p.tx="Aa",p.tp=e("textposition",n),p.ts=10,p.tc=e("textfont.color",n),p.tf=e("textfont.family",n)),r=[c.minExtend(o,p)],a=c.minExtend(i,g)}var v=s.select(this).select("g.legendpoints"),m=v.selectAll("path.scatterpts").data(l?r:[]);m.enter().append("path").classed("scatterpts",!0).attr("transform","translate(20,0)"),m.exit().remove(),m.call(f.pointStyle,a),l&&(r[0].mrc=3);var y=v.selectAll("g.pointtext").data(u?r:[]);y.enter().append("g").classed("pointtext",!0).append("text").attr("transform","translate(20,0)"),y.exit().remove(),y.selectAll("text").call(f.textPointStyle,a)}function o(t){var e=t[0].trace,n=e.marker||{},r=n.line||{},a=s.select(this).select("g.legendpoints").selectAll("path.legendbar").data(u.traceIs(e,"bar")?[t]:[]);a.enter().append("path").classed("legendbar",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),a.exit().remove(),a.each(function(t){var e=(t.mlw+1||r.width+1)-1,a=s.select(this);a.style("stroke-width",e+"px").call(d.fill,t.mc||n.color),e&&a.call(d.stroke,t.mlc||r.color)})}function i(t){var e=t[0].trace,n=s.select(this).select("g.legendpoints").selectAll("path.legendbox").data(u.traceIs(e,"box")&&e.visible?[t]:[]);n.enter().append("path").classed("legendbox",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),n.exit().remove(),n.each(function(t){var n=(t.lw+1||e.line.width+1)-1,r=s.select(this);r.style("stroke-width",n+"px").call(d.fill,t.fc||e.fillcolor),n&&r.call(d.stroke,t.lc||e.line.color)})}function l(t){var e=t[0].trace,n=s.select(this).select("g.legendpoints").selectAll("path.legendpie").data(u.traceIs(e,"pie")&&e.visible?[t]:[]);n.enter().append("path").classed("legendpie",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),n.exit().remove(),n.size()&&n.call(p,t[0],e)}var s=t("d3"),c=t("../../lib"),u=t("../../plots/plots"),f=t("../drawing"),d=t("../color"),h=t("../../traces/scatter/subtypes"),p=t("../../traces/pie/style_one");e.exports=function(t){t.each(function(t){var e=s.select(this),n=e.selectAll("g.legendfill").data([t]);n.enter().append("g").classed("legendfill",!0);var r=e.selectAll("g.legendlines").data([t]);r.enter().append("g").classed("legendlines",!0);var a=e.selectAll("g.legendsymbols").data([t]);a.enter().append("g").classed("legendsymbols",!0),a.style("opacity",t[0].trace.opacity),a.selectAll("g.legendpoints").data([t]).enter().append("g").classed("legendpoints",!0)}).each(o).each(i).each(l).each(r).each(a)}},{"../../lib":99,"../../plots/plots":153,"../../traces/pie/style_one":173,"../../traces/scatter/subtypes":194,"../color":20,"../drawing":43,d3:8}],65:[function(t,e,n){"use strict";function r(t,e){var n=e.currentTarget,r=n.getAttribute("data-attr"),a=n.getAttribute("data-val")||!0,o=t._fullLayout,i={};if("zoom"===r){for(var l,s,u="in"===a?.5:2,f=(1+u)/2,d=(1-u)/2,h=c.Axes.list(t,null,!0),p=0;p1)return r(["resetViews","toggleHover"]),i(v,n);u&&(r(["zoom3d","pan3d","orbitRotation","tableRotation"]),r(["resetCameraDefault3d","resetCameraLastSave3d"]),r(["hoverClosest3d"])),d&&(r(["zoomInGeo","zoomOutGeo","resetGeo"]),r(["hoverClosestGeo"]));var m=a(l),y=[];return((c||p)&&!m||g)&&(y=["zoom2d","pan2d"]),(c||g)&&o(s)&&(y.push("select2d"),y.push("lasso2d")),y.length&&r(y),!c&&!p||m||g||r(["zoomIn2d","zoomOut2d","autoScale2d","resetScale2d"]),c&&h?r(["toggleHover"]):p?r(["hoverClosestGl2d"]):c?r(["hoverClosestCartesian","hoverCompareCartesian"]):h&&r(["hoverClosestPie"]),i(v,n)}function a(t){for(var e=s.Axes.list({_fullLayout:t},null,!0),n=!0,r=0;r0);if(p){var g=a(e,n,s);u("x",g[0]),u("y",g[1]),o.noneOrAll(t,e,["x","y"]),u("xanchor"),u("yanchor"),o.coerceFont(u,"font",n.font);var v=u("bgcolor");u("activecolor",i.contrast(v,c.lightAmount,c.darkAmount)),u("bordercolor"),u("borderwidth")}}},{"../../lib":99,"../color":20,"./attributes":68,"./button_attributes":69,"./constants":70}],72:[function(t,e,n){"use strict";function r(t){for(var e=m.list(t,"x",!0),n=[],r=0;re;a--)h(t,a).selectAll('[data-index="'+(a-1)+'"]').attr("data-index",a),C.draw(t,a)}function f(t,e,n,i){function l(n){var r={"data-index":e,"fill-rule":"evenodd",d:x(t,C)},a=C.line.width?C.line.color:"rgba(0,0,0,0)",o=n.append("path").attr(r).style("opacity",C.opacity).call(T.stroke,a).call(T.fill,C.fillcolor).call(L.dashLine,C.line.dash,C.line.width);E&&o.call(L.setClipUrl,"clip"+t._fullLayout._uid+E),t._context.editable&&d(t,o,C,e)}var s,c;h(t,e).selectAll('[data-index="'+e+'"]').remove();var u=t.layout.shapes[e];if(u){var f={xref:u.xref,yref:u.yref},g={};"string"==typeof n&&n?g[n]=i:M.isPlainObject(n)&&(g=n);var v=Object.keys(g);for(s=0;sX&&r>Q&&!t.shiftKey?z.getCursor(a/n,1-o/r):"move";S(e,i),Y=i.split("-")[0]}function o(e){B=A.getFromId(t,n.xref),H=A.getFromId(t,n.yref),V=m(t,B),U=m(t,H,!0),G=y(t,B),Z=y(t,H,!0);var o="shapes["+r+"]";"path"===n.type?(F=n.path,q=o+".path"):(u=V(n.x0),f=U(n.y0),d=V(n.x1),h=U(n.y1),p=o+".x0",g=o+".y0",_=o+".x1",w=o+".y1"),uQ&&(c[E]=n[j]=Z(l),c[N]=n[D]=Z(s)),f-u>X&&(c[O]=n[R]=G(u),c[P]=n[I]=G(f))}e.attr("d",x(t,n))}var c,u,f,d,h,p,g,_,w,M,T,L,C,E,N,O,P,j,D,R,I,F,q,B,H,V,U,G,Z,Y,X=10,Q=10,$={setCursor:a,element:e.node(),prepFn:o,doneFn:i},W=$.element.getBoundingClientRect();z.init($)}function h(t,e){var n=t._fullLayout.shapes[e],r=t._fullLayout._shapeUpperLayer;return n?"below"===n.layer&&(r="paper"===n.xref&&"paper"===n.yref?t._fullLayout._shapeLowerLayer:t._fullLayout._shapeSubplotLayer):M.log("getShapeLayer: undefined shape: index",e),r}function p(t,e,n){var r=k.Axes.getFromId(t,n.id,"x")._id,a=k.Axes.getFromId(t,n.id,"y")._id,o="below"===e.layer,i=r===e.xref||a===e.yref,l=!!n.shapelayer;return o&&i&&l}function g(t){return function(e){return e.replace&&(e=e.replace("_"," ")),t(e)}}function v(t){return function(e){return t(e).replace(" ","_")}}function m(t,e,n){var r,o=t._fullLayout._size;if(e){var i=a(e);r=function(t){return e._offset+e.l2p(i(t,!0))},"date"===e.type&&(r=g(r))}else r=n?function(t){return o.t+o.h*(1-t)}:function(t){return o.l+o.w*t};return r}function y(t,e,n){var r,a=t._fullLayout._size;if(e){var i=o(e);r=function(t){return i(e.p2l(t-e._offset))}}else r=n?function(t){return 1-(t-a.t)/a.h}:function(t){return(t-a.l)/a.w};return r}function x(t,e){var n,r,o,i,l=e.type,s=A.getFromId(t,e.xref),c=A.getFromId(t,e.yref),u=t._fullLayout._size;if(s?(n=a(s),r=function(t){return s._offset+s.l2p(n(t,!0))}):r=function(t){return u.l+u.w*t},c?(o=a(c),i=function(t){return c._offset+c.l2p(o(t,!0))}):i=function(t){return u.t+u.h*(1-t)},"path"===l)return s&&"date"===s.type&&(r=g(r)),c&&"date"===c.type&&(i=g(i)),C.convertPath(e.path,r,i);var f=r(e.x0),d=r(e.x1),h=i(e.y0),p=i(e.y1);if("line"===l)return"M"+f+","+h+"L"+d+","+p;if("rect"===l)return"M"+f+","+h+"H"+d+"V"+p+"H"+f+"Z";var v=(f+d)/2,m=(h+p)/2,y=Math.abs(v-f),x=Math.abs(m-h),b="A"+y+","+x,_=v+y+","+m,w=v+","+(m-x);return"M"+_+b+" 0 1,1 "+w+b+" 0 0,1 "+_+"Z"}function b(t,e,n){return t.replace(E,function(t){var r=0,a=t.charAt(0),o=O[a],i=P[a],l=j[a],s=t.substr(1).replace(N,function(t){return r>=l?t:(o[r]?t=e(t):i[r]&&(t=n(t)),r++,t)});return a+s})}function _(t,e,n,r,a){var o="category"===t.type?Number:t.d2c;if(void 0!==e)return[o(e),o(n)];if(r){var i,l,s,c,u,f=1/0,d=-(1/0),h=r.match(E);for("date"===t.type&&(o=g(o)),i=0;id&&(d=u)));return d>=f?[f,d]:void 0}}var w=t("fast-isnumeric"),k=t("../../plotly"),M=t("../../lib"),A=t("../../plots/cartesian/axes"),T=t("../color"),L=t("../drawing"),z=t("../dragelement"),S=t("../../lib/setcursor"),C=e.exports={};C.layoutAttributes=t("./attributes"),C.supplyLayoutDefaults=function(t,e){for(var n=t.shapes||[],a=e.shapes=[],o=0;ol&&(t="X"),t});return r>l&&(s=s.replace(/[\s,]*X.*/,""),M.log("Ignoring extra params in segment "+t)),a+s})},C.calcAutorange=function(t){var e,n,r,a,o,i=t._fullLayout,l=i.shapes;if(l.length&&t._fullData.length)for(e=0;e0||d<0){var h={left:[-n,0],right:[n,0],top:[0,-n],bottom:[0,n]}[x.side];e.attr("transform","translate("+h+")")}}}function p(){L=0,z=!0,S=E,k._infolayer.select("."+e).attr({"data-unformatted":S}).text(S).on("mouseover.opacity",function(){r.select(this).transition().duration(100).style("opacity",1)}).on("mouseout.opacity",function(){r.select(this).transition().duration(1e3).style("opacity",0)})}var g=n.propContainer,v=n.propName,m=n.traceIndex,y=n.dfltName,x=n.avoid||{},b=n.attributes,_=n.transform,w=n.containerGroup,k=t._fullLayout,M=g.titlefont.family,A=g.titlefont.size,T=g.titlefont.color,L=1,z=!1,S=g.title.trim();""===S&&(L=0),S.match(/Click to enter .+ title/)&&(L=.2,z=!0),w||(w=k._infolayer.selectAll(".g-"+e).data([0]),w.enter().append("g").classed("g-"+e,!0));var C=w.selectAll("text").data([0]);C.enter().append("text"),C.text(S).attr("class",e),C.attr({"data-unformatted":S}).call(f);var E="Click to enter "+y+" title";t._context.editable?(S||p(),C.call(u.makeEditable).on("edit",function(e){void 0!==m?o.restyle(t,v,e,m):o.relayout(t,v,e)}).on("cancel",function(){this.text(this.attr("data-unformatted")).call(f)}).on("input",function(t){this.text(t||" ").attr(b).selectAll("tspan.line").attr(b)})):S&&!S.match(/Click to enter .+ title/)||C.remove(),C.classed("js-placeholder",z)}},{"../../lib":99,"../../lib/svg_text_utils":110,"../../plotly":118,"../../plots/plots":153,"../color":20,"../drawing":43,d3:8,"fast-isnumeric":11}],84:[function(t,e,n){"use strict";var r=t("../../plots/font_attributes"),a=t("../color/attributes"),o=t("../../lib/extend").extendFlat,i={_isLinkedToArray:!0,method:{valType:"enumerated",values:["restyle","relayout"],dflt:"restyle"},args:{valType:"info_array",freeLength:!0,items:[{valType:"any"},{valType:"any"},{valType:"any"}]},label:{ ++valType:"string",dflt:""}};e.exports={_isLinkedToArray:!0,visible:{valType:"boolean"},active:{valType:"integer",min:-1,dflt:0},buttons:i,x:{valType:"number",min:-2,max:3,dflt:-.05},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"right"},y:{valType:"number",min:-2,max:3,dflt:1},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"bottom"},font:o({},r,{}),bgcolor:{valType:"color"},bordercolor:{valType:"color",dflt:a.borderLine},borderwidth:{valType:"number",min:0,dflt:1}}},{"../../lib/extend":96,"../../plots/font_attributes":139,"../color/attributes":19}],85:[function(t,e,n){"use strict";e.exports={name:"updatemenus",itemName:"updatemenu",containerClassName:"updatemenu-container",headerGroupClassName:"updatemenu-header-group",headerClassName:"updatemenu-header",headerArrowClassName:"updatemenu-header-arrow",buttonGroupClassName:"updatemenu-button-group",buttonClassName:"updatemenu-button",itemRectClassName:"updatemenu-item-rect",itemTextClassName:"updatemenu-item-text",menuIndexAttrName:"updatemenu-active-index",autoMarginIdRoot:"updatemenu-",blankHeaderOpts:{label:" "},minWidth:30,minHeight:30,textPadX:40,fontSizeToHeight:1.3,rx:2,ry:2,textOffsetX:12,textOffsetY:3,arrowOffsetX:4,gapButtonHeader:5,gapButton:2,activeColor:"#F4FAFF",hoverColor:"#F4FAFF"}},{}],86:[function(t,e,n){"use strict";function r(t,e,n){function r(n,r){return o.coerce(t,e,i,n,r)}var l=a(t,e),s=r("visible",l.length>0);s&&(r("active"),r("x"),r("y"),o.noneOrAll(t,e,["x","y"]),r("xanchor"),r("yanchor"),o.coerceFont(r,"font",n.font),r("bgcolor",n.paper_bgcolor),r("bordercolor"),r("borderwidth"))}function a(t,e){function n(t,e){return o.coerce(r,a,c,t,e)}for(var r,a,i=t.buttons||[],l=e.buttons=[],s=0;s0?[0]:[]);if(s.enter().append("g").classed(T.containerClassName,!0).style("cursor","pointer"),s.exit().remove(),s.exit().size()&&m(t),0!==n.length){var c=s.selectAll("g."+T.headerGroupClassName).data(n,a);c.enter().append("g").classed(T.headerGroupClassName,!0);var u=s.selectAll("g."+T.buttonGroupClassName).data([0]);u.enter().append("g").classed(T.buttonGroupClassName,!0).style("pointer-events","all"),c.enter().size()&&u.call(v).attr(T.menuIndexAttrName,"-1"),c.exit().each(function(e){y.select(this).remove(),u.call(v).attr(T.menuIndexAttrName,"-1"),b.autoMargin(t,T.autoMarginIdRoot+e._index)});for(var f=0;fa.max?e.set(n):e.set(+t)}},integer:{coerceFunction:function(t,e,n,a){t%1||!r(t)||void 0!==a.min&&ta.max?e.set(n):e.set(+t)}},string:{coerceFunction:function(t,e,n,r){if("string"!=typeof t){var a="number"==typeof t;r.strict!==!0&&a?e.set(String(t)):e.set(n)}else r.noBlank&&!t?e.set(n):e.set(t)}},color:{coerceFunction:function(t,e,n){a(t).isValid()?e.set(t):e.set(n)}},colorscale:{coerceFunction:function(t,e,n){e.set(i(t,n))}},angle:{coerceFunction:function(t,e,n){"auto"===t?e.set("auto"):r(t)?(Math.abs(t)>180&&(t-=360*Math.round(t/360)),e.set(+t)):e.set(n)}},subplotid:{coerceFunction:function(t,e,n){var r=n.length;return"string"==typeof t&&t.substr(0,r)===n&&l.test(t.substr(r))?void e.set(t):void e.set(n)},validateFunction:function(t,e){var n=e.dflt,r=n.length;return t===n||"string"==typeof t&&!(t.substr(0,r)!==n||!l.test(t.substr(r)))}},flaglist:{coerceFunction:function(t,e,n,r){if("string"!=typeof t)return void e.set(n);if((r.extras||[]).indexOf(t)!==-1)return void e.set(t);for(var a=t.split("+"),o=0;o2)return!1;var i=o[0].split("-");if(i.length>3||3!==i.length&&o[1])return!1;if(4===i[0].length)e=Number(i[0]);else{if(2!==i[0].length)return!1;var s=(new Date).getFullYear();e=((Number(i[0])-s+70)%100+200)%100+s-70}return!!l(e)&&(1===i.length?new Date(e,0,1).getTime():(n=Number(i[1])-1,!(i[1].length>2)&&n>=0&&n<=11&&(2===i.length?new Date(e,n,1).getTime():(r=Number(i[2]),!(i[2].length>2)&&r>=1&&r<=31&&(r=new Date(e,n,r).getTime(),o[1]?(i=o[1].split(":"),!(i.length>3)&&(a=Number(i[0]),!(i[0].length>2)&&a>=0&&a<=23&&(r+=36e5*a,1===i.length?r:(n=Number(i[1]),!(i[1].length>2)&&n>=0&&n<=59&&(r+=6e4*n,2===i.length?r:(t=Number(i[2]),t>=0&&t<60&&r+1e3*t)))))):r)))))},n.isDateTime=function(t){return n.dateTime2ms(t)!==!1},n.ms2DateTime=function(t,e){if("undefined"==typeof i)return void s.error("d3 is not defined.");e||(e=0);var n=new Date(t),a=i.time.format("%Y-%m-%d")(n);return e<7776e6?(a+=" "+r(n.getHours(),2),e<432e6&&(a+=":"+r(n.getMinutes(),2),e<108e5&&(a+=":"+r(n.getSeconds(),2),e<3e5&&(a+="."+r(n.getMilliseconds(),3)))),a.replace(/([:\s]00)*\.?[0]*$/,"")):a};var c={H:["%H:%M:%S~%L","%H:%M:%S","%H:%M"],I:["%I:%M:%S~%L%p","%I:%M:%S%p","%I:%M%p"],D:["%H","%I%p","%Hh"]},u={Y:["%Y~%m~%d","%Y%m%d","%y%m%d","%m~%d~%Y","%d~%m~%Y"],Yb:["%b~%d~%Y","%d~%b~%Y","%Y~%d~%b","%Y~%b~%d"],y:["%m~%d~%y","%d~%m~%y","%y~%m~%d"],yb:["%b~%d~%y","%d~%b~%y","%y~%d~%b","%y~%b~%d"]},f=i.time.format.utc,d={Y:{H:["%Y~%m~%dT%H:%M:%S","%Y~%m~%dT%H:%M:%S~%L"].map(f),I:[],D:["%Y%m%d%H%M%S","%Y~%m","%m~%Y"].map(f)},Yb:{H:[],I:[],D:["%Y~%b","%b~%Y"].map(f)},y:{H:[],I:[],D:[]},yb:{H:[],I:[],D:[]}};["Y","Yb","y","yb"].forEach(function(t){u[t].forEach(function(e){d[t].D.push(f(e)),["H","I","D"].forEach(function(n){c[n].forEach(function(r){var a=d[t][n];a.push(f(e+"~"+r)),a.push(f(r+"~"+e))})})})});var h=/[a-z]*/g,p=function(t){return t.substr(0,3)},g=/(mon|tue|wed|thu|fri|sat|sun|the|of|st|nd|rd|th)/g,v=/[\s,\/\-\.\(\)]+/g,m=/~?([ap])~?m(~|$)/,y=function(t,e){return e+"m "},x=/\d\d\d\d/,b=/(^|~)[a-z]{3}/,_=/[ap]m/,w=/:/,k=/q([1-4])/,M=["31~mar","30~jun","30~sep","31~dec"],A=function(t,e){return M[e-1]},T=/ ?([+\-]\d\d:?\d\d|Z)$/;n.parseDate=function(t){if(t.getTime)return t;if("string"!=typeof t)return!1;t=t.toLowerCase().replace(h,p).replace(g,"").replace(v,"~").replace(m,y).replace(k,A).trim().replace(T,"");var e,n,r=null,i=a(t),l=o(t);e=d[i][l],n=e.length;for(var s=0;sn?Math.max(n,Math.min(e,t)):Math.max(e,Math.min(n,t))},a.bBoxIntersect=function(t,e,n){return n=n||0,t.left<=e.right+n&&e.left<=t.right+n&&t.top<=e.bottom+n&&e.top<=t.bottom+n},a.identity=function(t){return t},a.randstr=function t(e,n,r){if(r||(r=16),void 0===n&&(n=24),n<=0)return"0";var a,o,i,l=Math.log(Math.pow(2,n))/Math.log(r),s="";for(a=2;l===1/0;a*=2)l=Math.log(Math.pow(2,n/a))/Math.log(r)*a;var c=l-Math.floor(l);for(a=0;a-1||u!==1/0&&u>=Math.pow(2,n)?t(e,n,r):s},a.OptionControl=function(t,e){t||(t={}),e||(e="opt");var n={};return n.optionList=[],n._newoption=function(r){r[e]=t,n[r.name]=r,n.optionList.push(r)},n["_"+e]=t,n},a.smooth=function(t,e){if(e=Math.round(e)||0,e<2)return t;var n,r,a,o,i=t.length,l=2*i,s=2*e-1,c=new Array(s),u=new Array(i);for(n=0;n=l&&(a-=l*Math.floor(a/l)),a<0?a=-1-a:a>=i&&(a=l-1-a),o+=t[a]*c[r];u[n]=o}return u},a.syncOrAsync=function(t,e,n){function r(){return a.syncOrAsync(t,e,n)}for(var o,i;t.length;)if(i=t.splice(0,1)[0],o=i(e),o&&o.then)return o.then(r).then(void 0,a.promiseError);return n&&n(e)},a.stripTrailingSlash=function(t){return"/"===t.substr(-1)?t.substr(0,t.length-1):t},a.noneOrAll=function(t,e,n){if(t){var r,a,o=!1,i=!0;for(r=0;r1?r+o[1]:"";if(a&&(o.length>1||i.length>4))for(;n.test(i);)i=i.replace(n,"$1"+a+"$2");return i+l}},{"./coerce":93,"./dates":94,"./extend":96,"./is_plain_object":100,"./loggers":101,"./matrix":102,"./nested_property":103,"./notifier":104,"./search":107,"./stats":109,d3:8}],100:[function(t,e,n){"use strict";e.exports=function(t){return window&&window.process&&window.process.versions?"[object Object]"===Object.prototype.toString.call(t):"[object Object]"===Object.prototype.toString.call(t)&&Object.getPrototypeOf(t)===Object.prototype}},{}],101:[function(t,e,n){"use strict";var r=t("../plot_api/plot_config"),a=e.exports={};a.log=function(){if(r.logging>1){for(var t=["LOG:"],e=0;e0){for(var t=["WARN:"],e=0;e0){for(var t=["ERROR:"],e=0;e=0;e--){if(r=t[e],i=!1,Array.isArray(r))for(n=r.length-1;n>=0;n--)c(r[n])?i?r[n]=void 0:r.pop():i=!0;else if("object"==typeof r&&null!==r)for(o=Object.keys(r),i=!1,n=o.length-1;n>=0;n--)c(r[o[n]])&&!a(r[o[n]],o[n])?delete r[o[n]]:i=!0;if(i)return}}function c(t){return void 0===t||null===t||"object"==typeof t&&(Array.isArray(t)?!t.length:!Object.keys(t).length)}function u(t,e,n){return{set:function(){throw"bad container"},get:function(){},astr:e,parts:n,obj:t}}var f=t("fast-isnumeric");e.exports=function(t,e){if(f(e))e=String(e);else if("string"!=typeof e||"[-1]"===e.substr(e.length-4))throw"bad property string";for(var n,a,i,l=0,s=e.split(".");lo||rl)&&(!e||!c(t))}function n(t,e){var n=t[0],s=t[1];if(no||sl)return!1;var c,u,f,d,h,p=r.length,g=r[0][0],v=r[0][1],m=0;for(c=1;cMath.max(u,g)||s>Math.max(f,v)))if(su||Math.abs(r(i,d))>a)return!0;return!1};a.filter=function(t,e){function n(n){t.push(n);var l=r.length,s=a;r.splice(i+1);for(var c=s+1;c1){var l=t.pop();n(l)}return{addPt:n,raw:t,filtered:r}}},{"./matrix":102}],106:[function(t,e,n){"use strict";function r(t,e){for(var n,r=[],o=0;oo.queueLength&&(t.undoQueue.queue.shift(),t.undoQueue.index--)))},i.startSequence=function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!0,t.undoQueue.beginSequence=!0},i.stopSequence=function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!1,t.undoQueue.beginSequence=!1},i.undo=function(t){var e,n;if(t.framework&&t.framework.isPolar)return void t.framework.undo();if(!(void 0===t.undoQueue||isNaN(t.undoQueue.index)||t.undoQueue.index<=0)){for(t.undoQueue.index--,e=t.undoQueue.queue[t.undoQueue.index], ++t.undoQueue.inSequence=!0,n=0;n=t.undoQueue.queue.length)){for(e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,n=0;ne}function i(t,e){return t>=e}var l=t("fast-isnumeric"),s=t("../lib");n.findBin=function(t,e,n){if(l(e.start))return n?Math.ceil((t-e.start)/e.size)-1:Math.floor((t-e.start)/e.size);var c,u,f=0,d=e.length,h=0;for(u=e[e.length-1]>=e[0]?n?r:a:n?i:o;f90&&s.log("Long binary search..."),f-1},n.sorterAsc=function(t,e){return t-e},n.sorterDes=function(t,e){return e-t},n.distinctVals=function(t){var e=t.slice();e.sort(n.sorterAsc);for(var r=e.length-1,a=e[r]-e[0]||1,o=a/(r||1)/1e4,i=[e[0]],l=0;le[l]+o&&(a=Math.min(a,e[l+1]-e[l]),i.push(e[l+1]));return{vals:i,minDiff:a}},n.roundUp=function(t,e,n){for(var r,a=0,o=e.length-1,i=0,l=n?0:1,s=n?1:0,c=n?Math.ceil:Math.floor;at.length-1)return t[t.length-1];var n=e%1;return n*t[Math.ceil(e)]+(1-n)*t[Math.floor(e)]}},{"fast-isnumeric":11}],110:[function(t,e,n){"use strict";function r(t,e){return t.node().getBoundingClientRect()[e]}function a(t){return t.replace(/(<|<|<)/g,"\\lt ").replace(/(>|>|>)/g,"\\gt ")}function o(t,e,n){var r="math-output-"+c.Lib.randstr([],64),o=u.select("body").append("div").attr({id:r}).style({visibility:"hidden",position:"absolute"}).style({"font-size":e.fontSize+"px"}).text(a(t));MathJax.Hub.Queue(["Typeset",MathJax.Hub,o.node()],function(){var e=u.select("body").select("#MathJax_SVG_glyphs");if(o.select(".MathJax_SVG").empty()||!o.select("svg").node())f.log("There was an error in the tex syntax.",t),n();else{var r=o.select("svg").node().getBoundingClientRect();n(o.select(".MathJax_SVG"),e,r)}o.remove()})}function i(t){return(t||"").replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")}function l(t){for(var e=t.split(/(<[^<>]*>)/).map(function(t){var e=t.match(/<(\/?)([^ >]*)\s*(.*)>/i),n=e&&e[2].toLowerCase(),r=p[n];if(void 0!==r){var a=e[1],o=e[3],l=o.match(/^style\s*=\s*"([^"]+)"\s*/i);if("a"===n){if(a)return"
";if("href"!==o.substr(0,4).toLowerCase())return"";var s=o.substr(4).replace(/["']/g,"").replace(/=/,""),u=document.createElement("a");return u.href=s,g.indexOf(u.protocol)===-1?"":''}if("br"===n)return"
";if(a)return"sup"===n?'':"sub"===n?'':"";var f=""}return c.util.xml_entity_encode(t).replace(/");r>0;r=e.indexOf("
",r+1))n.push(r);var a=0;n.forEach(function(t){for(var n=t+a,r=e.slice(0,n),o="",i=r.length-1;i>=0;i--){var l=r[i].match(/<(\/?).*>/i);if(l&&"
"!==r[i]){l[1]||(o=r[i]);break}}o&&(e.splice(n+1,0,o),e.splice(n,0,""),a+=2)});var o=e.join(""),l=o.split(/
/gi);return l.length>1&&(e=l.map(function(t,e){return''+t+""})),e.join("")}function s(t,e,n){var r,a,o,i=n.horizontalAlign,l=n.verticalAlign||"top",s=t.node().getBoundingClientRect(),c=e.node().getBoundingClientRect();return a="bottom"===l?function(){return s.bottom-r.height}:"middle"===l?function(){return s.top+(s.height-r.height)/2}:function(){return s.top},o="right"===i?function(){return s.right-r.width}:"center"===i?function(){return s.left+(s.width-r.width)/2}:function(){return s.left},function(){return r=this.node().getBoundingClientRect(),this.style({top:a()-c.top+"px",left:o()-c.left+"px","z-index":1e3}),this}}var c=t("../plotly"),u=t("d3"),f=t("../lib"),d=t("../constants/xmlns_namespaces"),h=e.exports={};u.selection.prototype.appendSVG=function(t){for(var e=['',t,""].join(""),n=(new DOMParser).parseFromString(e,"application/xml"),r=n.documentElement.firstChild;r;)this.node().appendChild(this.node().ownerDocument.importNode(r,!0)),r=r.nextSibling;return n.querySelector("parsererror")?(f.log(n.querySelector("parsererror div").textContent),null):u.select(this.node().lastChild)},h.html_entity_decode=function(t){var e=u.select("body").append("div").style({display:"none"}).html(""),n=t.replace(/(&[^;]*;)/gi,function(t){return"<"===t?"<":"&rt;"===t?">":e.html(t).text()});return e.remove(),n},h.xml_entity_encode=function(t){return t.replace(/&(?!\w+;|\#[0-9]+;| \#x[0-9A-F]+;)/g,"&")},h.convertToTspans=function(t,e){function n(){h.empty()||(p=s.attr("class")+"-math",h.select("svg."+p).remove()),t.text("").style({visibility:"visible","white-space":"pre"}),d=t.appendSVG(i),d||t.text(a),t.select("a").size()&&t.style("pointer-events","all"),e&&e.call(s)}var a=t.text(),i=l(a),s=t,f=!s.attr("data-notex")&&i.match(/([^$]*)([$]+[^$]*[$]+)([^$]*)/),d=a,h=u.select(s.node().parentNode);if(!h.empty()){var p=s.attr("class")?s.attr("class").split(" ")[0]:"text";p+="-math",h.selectAll("svg."+p).remove(),h.selectAll("g."+p+"-group").remove(),t.style({visibility:null});for(var g=t.node();g&&g.removeAttribute;g=g.parentNode)g.removeAttribute("data-bb");if(f){var v=c.Lib.getPlotDiv(s.node());(v&&v._promises||[]).push(new Promise(function(t){s.style({visibility:"hidden"});var a={fontSize:parseInt(s.style("font-size"),10)};o(f[2],a,function(a,o,i){h.selectAll("svg."+p).remove(),h.selectAll("g."+p+"-group").remove();var l=a&&a.select("svg");if(!l||!l.node())return n(),void t();var c=h.append("g").classed(p+"-group",!0).attr({"pointer-events":"none"});c.node().appendChild(l.node()),o&&o.node()&&l.node().insertBefore(o.node().cloneNode(!0),l.node().firstChild),l.attr({class:p,height:i.height,preserveAspectRatio:"xMinYMin meet"}).style({overflow:"visible","pointer-events":"none"});var u=s.style("fill")||"black";l.select("g").attr({fill:u,stroke:u});var f=r(l,"width"),d=r(l,"height"),g=+s.attr("x")-f*{start:0,middle:.5,end:1}[s.attr("text-anchor")||"start"],v=parseInt(s.style("font-size"),10)||r(s,"height"),m=-v/4;"y"===p[0]?(c.attr({transform:"rotate("+[-90,+s.attr("x"),+s.attr("y")]+") translate("+[-f/2,m-d/2]+")"}),l.attr({x:+s.attr("x"),y:+s.attr("y")})):"l"===p[0]?l.attr({x:s.attr("x"),y:m-d/2}):"a"===p[0]?l.attr({x:0,y:m}):l.attr({x:g,y:+s.attr("y")+m-d/2}),e&&e.call(s,c),t(c)})}))}else n();return t}};var p={sup:'font-size:70%" dy="-0.6em',sub:'font-size:70%" dy="0.3em',b:"font-weight:bold",i:"font-style:italic",a:"",span:"",br:"",em:"font-style:italic;font-weight:bold"},g=["http:","https:","mailto:"],v=new RegExp("]*)?/?>","g");h.plainText=function(t){return(t||"").replace(v," ")},h.makeEditable=function(t,e,n){function r(){o(),i.style({opacity:0});var t,e=d.attr("class");t=e?"."+e.split(" ")[0]+"-math-group":"[class*=-math-group]",t&&u.select(i.node().parentNode).select(t).style({opacity:0})}function a(t){var e=t.node(),n=document.createRange();n.selectNodeContents(e);var r=window.getSelection();r.removeAllRanges(),r.addRange(n),e.focus()}function o(){var t=u.select(c.Lib.getPlotDiv(i.node())),e=t.select(".svg-container"),r=e.append("div");r.classed("plugin-editable editable",!0).style({position:"absolute","font-family":i.style("font-family")||"Arial","font-size":i.style("font-size")||12,color:n.fill||i.style("fill")||"black",opacity:1,"background-color":n.background||"transparent",outline:"#ffffff33 1px solid",margin:[-parseFloat(i.style("font-size"))/8+1,0,0,-1].join("px ")+"px",padding:"0","box-sizing":"border-box"}).attr({contenteditable:!0}).text(n.text||i.attr("data-unformatted")).call(s(i,e,n)).on("blur",function(){i.text(this.textContent).style({opacity:1});var t,e=u.select(this).attr("class");t=e?"."+e.split(" ")[0]+"-math-group":"[class*=-math-group]",t&&u.select(i.node().parentNode).select(t).style({opacity:0});var n=this.textContent;u.select(this).transition().duration(0).remove(),u.select(document).on("mouseup",null),l.edit.call(i,n)}).on("focus",function(){var t=this;u.select(document).on("mouseup",function(){return u.event.target!==t&&void(document.activeElement===r.node()&&r.node().blur())})}).on("keyup",function(){27===u.event.which?(i.style({opacity:1}),u.select(this).style({opacity:0}).on("blur",function(){return!1}).transition().remove(),l.cancel.call(i,this.textContent)):(l.input.call(i,this.textContent),u.select(this).call(s(i,e,n)))}).on("keydown",function(){13===u.event.which&&this.blur()}).call(a)}n||(n={});var i=this,l=u.dispatch("edit","input","cancel"),f=u.select(this.node()).style({"pointer-events":"all"}),d=e||f;return e&&f.style({"pointer-events":"none"}),n.immediate?r():d.on("click",r),u.rebind(this,l,"on")}},{"../constants/xmlns_namespaces":89,"../lib":99,"../plotly":118,d3:8}],111:[function(t,e,n){"use strict";var r=e.exports={},a=t("../plots/geo/constants").locationmodeToLayer,o=t("topojson").feature;r.getTopojsonName=function(t){return[t.scope.replace(/ /g,"-"),"_",t.resolution.toString(),"m"].join("")},r.getTopojsonPath=function(t,e){return t+e+".json"},r.getTopojsonFeatures=function(t,e){var n=a[t.locationmode],r=e.objects[n];return o(e,r).features}},{"../plots/geo/constants":140,topojson:15}],112:[function(t,e,n){"use strict";function r(t){var e;if("string"==typeof t){if(e=document.getElementById(t),null===e)throw new Error("No DOM element with id '"+t+"' exists on the page.");return e}if(null===t||void 0===t)throw new Error("DOM element provided is null or undefined");return t}function a(t){Array.isArray(t._promises)&&t._promises.length>0&&P.log("Clearing previous rejected promises from queue."),t._promises=[]}function o(t,e){t._fullLayout._paperdiv.style("background","white"),O.defaultConfig.setBackground(t,e)}function i(t,e){t._context||(t._context=P.extendFlat({},O.defaultConfig));var n=t._context;e&&(Object.keys(e).forEach(function(t){t in n&&("setBackground"===t&&"opaque"===e[t]?n[t]=o:n[t]=e[t])}),e.plot3dPixelRatio&&!n.plotGlPixelRatio&&(n.plotGlPixelRatio=n.plot3dPixelRatio)),n.staticPlot&&(n.editable=!1,n.autosizable=!1,n.scrollZoom=!1,n.doubleClick=!1,n.showTips=!1,n.showLink=!1,n.displayModeBar=!1)}function l(t,e,n){var r=C.select(t).selectAll(".plot-container").data([0]);r.enter().insert("div",":first-child").classed("plot-container plotly",!0);var a=r.selectAll(".svg-container").data([0]);a.enter().append("div").classed("svg-container",!0).style("position","relative"),a.html(""),e&&(t.data=e),n&&(t.layout=n),O.micropolar.manager.fillLayout(t),"initial"===t._fullLayout.autosize&&t._context.autosizable&&(k(t,{}),t._fullLayout.autosize=n.autosize=!0),a.style({width:t._fullLayout.width+"px",height:t._fullLayout.height+"px"}),t.framework=O.micropolar.manager.framework(t),t.framework({data:t.data,layout:t.layout},a.node()),t.framework.setUndoPoint();var o=t.framework.svg(),i=1,l=t._fullLayout.title;""!==l&&l||(i=0);var s="Click to enter title",c=function(){this.call(O.util.convertToTspans)},u=o.select(".title-group text").call(c);if(t._context.editable){u.attr({"data-unformatted":l}),l&&l!==s||(i=.2,u.attr({"data-unformatted":s}).text(s).style({opacity:i}).on("mouseover.opacity",function(){C.select(this).transition().duration(100).style("opacity",1)}).on("mouseout.opacity",function(){C.select(this).transition().duration(1e3).style("opacity",0)}));var f=function(){this.call(O.util.makeEditable).on("edit",function(e){t.framework({layout:{title:e}}),this.attr({"data-unformatted":e}).text(e).call(c),this.call(f)}).on("cancel",function(){var t=this.attr("data-unformatted");this.text(t).call(c)})};u.call(f)}return t._context.setBackground(t,t._fullLayout.paper_bgcolor),R.addLinks(t),Promise.resolve()}function s(t){var e,n;t||(t={}),t.xaxis1&&(t.xaxis||(t.xaxis=t.xaxis1),delete t.xaxis1),t.yaxis1&&(t.yaxis||(t.yaxis=t.yaxis1),delete t.yaxis1);var r=O.Axes.list({_fullLayout:t});for(e=0;e3?(u.x=1.02,u.xanchor="left"):u.x<-2&&(u.x=-.02,u.xanchor="right"),u.y>3?(u.y=1.02,u.yanchor="bottom"):u.y<-2&&(u.y=-.02,u.yanchor="top")),"rotate"===t.dragmode&&(t.dragmode="orbit"),t.scene1&&(t.scene||(t.scene=t.scene1),delete t.scene1);var f=R.getSubplotIds(t,"gl3d");for(e=0;e=t.data.length||a<-t.data.length)throw new Error(n+" must be valid indices for gd.data.");if(e.indexOf(a,r+1)>-1||a>=0&&e.indexOf(-t.data.length+a)>-1||a<0&&e.indexOf(t.data.length+a)>-1)throw new Error("each index in "+n+" must be unique.")}}function v(t,e,n){if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("currentIndices is a required argument.");if(Array.isArray(e)||(e=[e]),g(t,e,"currentIndices"),"undefined"==typeof n||Array.isArray(n)||(n=[n]),"undefined"!=typeof n&&g(t,n,"newIndices"),"undefined"!=typeof n&&e.length!==n.length)throw new Error("current and new indices must be of equal length.")}function m(t,e,n){var r,a;if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("traces must be defined.");for(Array.isArray(e)||(e=[e]),r=0;r=0&&s0){var l=w(t._boundingBoxMargins),s=l.left+l.right,c=l.bottom+l.top,u=o._container.node().getBoundingClientRect(),f=1-2*i.frameMargins;a=Math.round(f*(u.width-s)),r=Math.round(f*(u.height-c))}else n=window.getComputedStyle(t),r=parseFloat(n.height)||o.height,a=parseFloat(n.width)||o.width;return Math.abs(o.width-a)>1||Math.abs(o.height-r)>1?(o.height=t.layout.height=r,o.width=t.layout.width=a):"initial"!==o.autosize&&(delete e.autosize,o.autosize=t.layout.autosize=!0),R.sanitizeMargins(o),e}function M(t){var e=C.select(t),n=t._fullLayout;if(n._container=e.selectAll(".plot-container").data([0]),n._container.enter().insert("div",":first-child").classed("plot-container",!0).classed("plotly",!0),n._paperdiv=n._container.selectAll(".svg-container").data([0]),n._paperdiv.enter().append("div").classed("svg-container",!0).style("position","relative"),"initial"===n.autosize&&(k(t,{}),n.autosize=!0,t.layout.autosize=!0),n._glcontainer=n._paperdiv.selectAll(".gl-container").data([0]),n._glcontainer.enter().append("div").classed("gl-container",!0),n._geocontainer=n._paperdiv.selectAll(".geo-container").data([0]),n._geocontainer.enter().append("div").classed("geo-container",!0),n._paperdiv.selectAll(".main-svg").remove(),n._paper=n._paperdiv.insert("svg",":first-child").classed("main-svg",!0),n._toppaper=n._paperdiv.append("svg").classed("main-svg",!0),!n._uid){var r=[];C.selectAll("defs").each(function(){this.id&&r.push(this.id.split("-")[1])}),n._uid=P.randstr(r)}n._paperdiv.selectAll(".main-svg").attr($.svgAttrs),n._defs=n._paper.append("defs").attr("id","defs-"+n._uid),n._topdefs=n._toppaper.append("defs").attr("id","topdefs-"+n._uid),n._draggers=n._paper.append("g").classed("draglayer",!0);var a=n._paper.append("g").classed("layer-below",!0);n._imageLowerLayer=a.append("g").classed("imagelayer",!0),n._shapeLowerLayer=a.append("g").classed("shapelayer",!0);var o=O.Axes.getSubplots(t);o.join("")!==Object.keys(t._fullLayout._plots||{}).join("")&&A(t,o),n._has("cartesian")&&T(t,o),n._ternarylayer=n._paper.append("g").classed("ternarylayer",!0);var i=n._paper.selectAll(".layer-subplot");n._imageSubplotLayer=i.selectAll(".imagelayer"),n._shapeSubplotLayer=i.selectAll(".shapelayer");var l=n._paper.append("g").classed("layer-above",!0);n._imageUpperLayer=l.append("g").classed("imagelayer",!0),n._shapeUpperLayer=l.append("g").classed("shapelayer",!0),n._pielayer=n._paper.append("g").classed("pielayer",!0),n._glimages=n._paper.append("g").classed("glimages",!0),n._geoimages=n._paper.append("g").classed("geoimages",!0),n._infolayer=n._toppaper.append("g").classed("infolayer",!0),n._zoomlayer=n._toppaper.append("g").classed("zoomlayer",!0),n._hoverlayer=n._toppaper.append("g").classed("hoverlayer",!0),t.emit("plotly_framework");var s=P.syncOrAsync([L,function(){return O.Axes.doTicks(t,"redraw")},I.init],t);return s&&s.then&&t._promises.push(s),s}function A(t,e){function n(e,n){return function(){return O.Axes.getFromId(t,e,n)}}for(var r,a,o=t._fullLayout._plots={},i=0;i0,_=O.Axes.getSubplots(t).join(""),w=Object.keys(t._fullLayout._plots||{}).join(""),k=w===_;b?t.framework===M&&!x&&k||(t.framework=M,M(t)):k?x&&M(t):(t.framework=M,M(t)),x&&O.Axes.saveRangeInitial(t);var A=t._fullLayout,T=!t.calcdata||t.calcdata.length!==(t.data||[]).length;T&&h(t);for(var z=0;z$.range[0]?[1,2]:[2,1]);else{var W=$.range[0],J=$.range[1];"log"===F?(W<=0&&J<=0&&i(Z+".autorange",!0),W<=0?W=J/1e6:J<=0&&(J=W/1e6),i(Z+".range[0]",Math.log(W)/Math.LN10),i(Z+".range[1]",Math.log(J)/Math.LN10)):(i(Z+".range[0]",Math.pow(10,W)),i(Z+".range[1]",Math.pow(10,J)))}else i(Z+".autorange",!0)}if("reverse"===U)Y.range?Y.range.reverse():(i(Z+".autorange",!0),Y.range=[1,0]),X.autorange?M=!0:w=!0;else if("annotations"===I.parts[0]||"shapes"===I.parts[0]){var K=I.parts[1],tt=I.parts[0],et=v[tt]||[],nt=O[P.titleCase(tt)],rt=et[K]||{};2===I.parts.length&&("add"===y[N]||P.isPlainObject(y[N])?C[N]="remove":"remove"===y[N]?K===-1?(C[tt]=et,delete C[N]):C[N]=rt:P.log("???",y)),!l(rt,"x")&&!l(rt,"y")||P.containsAny(N,["color","opacity","align","dash"])||(M=!0),nt.draw(e,K,I.parts.slice(2).join("."),y[N]),delete y[N]}else if("images"===I.parts[0]){var at=P.objectFromPath(N,F);P.extendDeepAll(e.layout,at),H.supplyLayoutDefaults(e.layout,e._fullLayout),H.draw(e)}else if("mapbox"===I.parts[0]&&"layers"===I.parts[1]){P.extendDeepAll(e.layout,P.objectFromPath(N,F));var ot=(e._fullLayout.mapbox||{}).layers||[];for(j=I.parts[2]+1-ot.length,g=0;g1&&P.containsAny(I.parts[1],["tick","exponent","grid","zeroline"])?b=!0:N.indexOf(".linewidth")!==-1&&N.indexOf("axis")!==-1?b=_=!0:I.parts.length>1&&I.parts[1].indexOf("line")!==-1?_=!0:I.parts.length>1&&"mirror"===I.parts[1]?b=_=!0:"margin.pad"===N?b=_=!0:"margin"===I.parts[0]||"autorange"===I.parts[1]||"rangemode"===I.parts[1]||"type"===I.parts[1]||"domain"===I.parts[1]||N.match(/^(bar|box|font)/)?M=!0:["hovermode","dragmode"].indexOf(N)!==-1?A=!0:["hovermode","dragmode","height","width","autosize"].indexOf(N)===-1&&(w=!0):w=!0,I.set(F)}D.add(e,t,[e,C],t,[e,z]),y.autosize&&(y=k(e,y)),(y.height||y.width||y.autosize)&&(M=!0);var lt=Object.keys(y),st=[R.previousPromises];if(w||M)st.push(function(){return e.layout=void 0,M&&(e.calcdata=void 0),O.plot(e,"",v)});else if(lt.length&&(R.supplyDefaults(e),m=e._fullLayout,x&&st.push(function(){return V.draw(e),R.previousPromises(e)}),_&&st.push(L),b&&st.push(function(){return O.Axes.doTicks(e,"redraw"),S(e),R.previousPromises(e)}),A)){var ct;for(Q(e),O.Fx.supplyLayoutDefaults(e.layout,m,e._fullData),O.Fx.init(e),ct=R.getSubplotIds(m,"gl3d"),g=0;g1)};c(n.width)&&c(n.height)||l(new Error("Height and width should be pixel values."));var u=r.clone(e,{format:"png",height:n.height,width:n.width}),f=u.td;f.style.position="absolute",f.style.left="-5000px",document.body.appendChild(f);var d=r.getRedrawFunc(f);o.plot(f,u.data,u.layout,u.config).then(d).then(s).then(function(e){t(e)}).catch(function(t){l(t)})});return l}var a=t("fast-isnumeric"),o=t("../plotly"),i=t("../lib");e.exports=r},{"../lib":99,"../plotly":118,"../snapshot":163,"fast-isnumeric":11}],117:[function(t,e,n){"use strict";function r(t,e,n,a,o,c){c=c||[];for(var u=Object.keys(t),d=0;d1&&s.push(i("object","layout"))),d.supplyDefaults(c);for(var u=c._fullData,v=n.length,m=0;mc&&e=864e5?t._tickround="d":n>=36e5?t._tickround="H":n>=6e4?t._tickround="M":n>=1e3?t._tickround="S":t._tickround=3-Math.round(Math.log(n/2)/Math.LN10);else{x(n)||(n=Number(n.substr(1))),t._tickround=2-Math.floor(Math.log(n)/Math.LN10+.01),e="log"===t.type?Math.pow(10,Math.max(t.range[0],t.range[1])):Math.max(Math.abs(t.range[0]),Math.abs(t.range[1]));var r=Math.floor(Math.log(e)/Math.LN10+.01);Math.abs(r)>3&&("SI"===t.exponentformat||"B"===t.exponentformat?t._tickexponent=3*Math.round((r-1)/3):t._tickexponent=r)}else"M"===n.charAt(0)?t._tickround=2===n.length?"m":"y":t._tickround=null}function i(t,e){var n=t.match(B),r=new Date(e);if(n){var a=Math.min(+n[1]||6,6),o=String(e/1e3%1+2.0000005).substr(2,a).replace(/0+$/,"")||"0";return y.time.format(t.replace(B,o))(r)}return y.time.format(t)(r)}function l(t,e,n){var r=t.tickfont||t._gd._fullLayout.font;return{x:e,dx:0,dy:0,text:n||"",fontSize:r.size,font:r.family,fontColor:r.color}}function s(t,e,n,r){var a,o=e.x,l=t._tickround,s=new Date(o),c="";n&&t.hoverformat?a=i(t.hoverformat,o):t.tickformat?a=i(t.tickformat,o):(r&&(x(l)?l+=2:l={y:"m",m:"d",d:"H",H:"M",M:"S",S:2}[l]),"y"===l?a=j(s):"m"===l?a=D(s):(o!==t._tmin||n||(c="
"+j(s)),"d"===l?a=R(s):"H"===l?a=I(s):(o!==t._tmin||n||(c="
"+R(s)+", "+j(s)),a=F(s),"M"!==l&&(a+=q(s),"S"!==l&&(a+=d(m(o/1e3,1),t,"none",n).substr(1)))))),e.text=a+c}function c(t,e,n,r,a){var o=t.dtick,i=e.x;if(!r||"string"==typeof o&&"L"===o.charAt(0)||(o="L3"),t.tickformat||"string"==typeof o&&"L"===o.charAt(0))e.text=d(Math.pow(10,i),t,a,r);else if(x(o)||"D"===o.charAt(0)&&m(i+.01,1)<.1)if(["e","E","power"].indexOf(t.exponentformat)!==-1){var l=Math.round(i);0===l?e.text=1:1===l?e.text="10":l>1?e.text="10"+l+"":e.text="10\u2212"+-l+"",e.fontSize*=1.25}else e.text=d(Math.pow(10,i),t,"","fakehover"),"D1"===o&&"y"===t._id.charAt(0)&&(e.dy-=e.fontSize/6);else{if("D"!==o.charAt(0))throw"unrecognized dtick "+String(o);e.text=String(Math.round(Math.pow(10,m(i,1)))),e.fontSize*=.75}if("D1"===t.dtick){var s=String(e.text).charAt(0);"0"!==s&&"1"!==s||("y"===t._id.charAt(0)?e.dx-=e.fontSize/4:(e.dy+=e.fontSize/2,e.dx+=(t.range[1]>t.range[0]?1:-1)*e.fontSize*(i<0?.5:.25)))}}function u(t,e){var n=t._categories[Math.round(e.x)];void 0===n&&(n=""),e.text=String(n)}function f(t,e,n,r,a){"all"===t.showexponent&&Math.abs(e.x/t.dtick)<1e-6&&(a="hide"),e.text=d(e.x,t,a,r)}function d(t,e,n,r){var a=t<0,i=e._tickround,l=n||e.exponentformat||"B",s=e._tickexponent,c=e.tickformat;if(r){var u={exponentformat:e.exponentformat,dtick:"none"===e.showexponent?e.dtick:x(t)?Math.abs(t)||1:1,range:"none"===e.showexponent?e.range:[0,t||1]};o(u),i=(Number(u._tickround)||0)+4,s=u._tickexponent,e.hoverformat&&(c=e.hoverformat)}if(c)return y.format(c)(t).replace(/-/g,"\u2212"); ++var f=Math.pow(10,-i)/2;if("none"===l&&(s=0),t=Math.abs(t),t12||s<-15)?t+="e"+p:"E"===l?t+="E"+p:"power"===l?t+="\xd710"+p+"":"B"===l&&9===s?t+="B":"SI"!==l&&"B"!==l||(t+=H[s/3+5])}return a?"\u2212"+t:t}function h(t,e){var n,r,a=[];for(n=0;n1)for(r=1;r2e-6||((n-t._forceTick0)/t._minDtick%1+1.000001)%1>2e-6)&&(t._minDtick=0)):t._minDtick=0},T.getAutoRange=function(t){var e,n=[],r=t._min[0].val,a=t._max[0].val;for(e=1;e0&&u>0&&f/u>d&&(s=i,c=l,d=f/u);if(r===a){var p=r-1,g=r+1;n="tozero"===t.rangemode?r<0?[p,0]:[0,g]:"nonnegative"===t.rangemode?[Math.max(0,p),Math.max(0,g)]:[p,g]}else d&&("linear"!==t.type&&"-"!==t.type||("tozero"===t.rangemode?(s.val>=0&&(s={val:0,pad:0}),c.val<=0&&(c={val:0,pad:0})):"nonnegative"===t.rangemode&&(s.val-d*s.pad<0&&(s={val:0,pad:0}),c.val<0&&(c={val:1,pad:0})),d=(c.val-s.val)/(t._length-s.pad-c.pad)),n=[s.val-d*s.pad,c.val+d*c.pad]);return n[0]===n[1]&&("tozero"===t.rangemode?n=n[0]<0?[n[0],0]:n[0]>0?[0,n[0]]:[0,1]:(n=[n[0]-1,n[0]+1],"nonnegative"===t.rangemode&&(n[0]=Math.max(0,n[0])))),h&&n.reverse(),n},T.doAutoRange=function(t){t._length||t.setScale();var e=t._min&&t._max&&t._min.length&&t._max.length;if(t.autorange&&e){t.range=T.getAutoRange(t);var n=t._gd.layout[t._name];n||(t._gd.layout[t._name]=n={}),n!==t&&(n.range=t.range.slice(),n.autorange=t.autorange)}},T.saveRangeInitial=function(t,e){for(var n=T.list(t,"",!0),r=!1,a=0;a=d?h=!1:l.val>=c&&l.pad<=d&&(t._min.splice(i,1),i--);h&&t._min.push({val:c,pad:y&&0===c?0:d})}if(r(u)){for(h=!0,i=0;i=u&&l.pad>=f?h=!1:l.val<=u&&l.pad<=f&&(t._max.splice(i,1),i--);h&&t._max.push({val:u,pad:y&&0===u?0:f})}}}if((t.autorange||t._needsExpand)&&e){t._min||(t._min=[]),t._max||(t._max=[]),n||(n={}),t._m||t.setScale();var o,i,l,s,c,u,f,d,h,p,g,v=e.length,m=n.padded?.05*t._length:0,y=n.tozero&&("linear"===t.type||"-"===t.type),b=r((t._m>0?n.ppadplus:n.ppadminus)||n.ppad||0),_=r((t._m>0?n.ppadminus:n.ppadplus)||n.ppad||0),w=r(n.vpadplus||n.vpad),k=r(n.vpadminus||n.vpad);for(o=0;o<6;o++)a(o);for(o=v-1;o>5;o--)a(o)}},T.autoBin=function(t,e,n,r){function a(t){return(1+100*(t-h)/f.dtick)%100<2}var o=_.aggNums(Math.min,null,t),i=_.aggNums(Math.max,null,t);if("category"===e.type)return{start:o-.5,end:i+.5,size:1};var l;if(n)l=(i-o)/n;else{var s=_.distinctVals(t),c=Math.pow(10,Math.floor(Math.log(s.minDiff)/Math.LN10)),u=c*_.roundUp(s.minDiff/c,[.9,1.9,4.9,9.9],!0);l=Math.max(u,2*_.stdev(t)/Math.pow(t.length,r?.25:.4))}var f={type:"log"===e.type?"linear":e.type,range:[o,i]};T.autoTicks(f,l);var d,h=T.tickIncrement(T.tickFirst(f),f.dtick,"reverse");if("number"==typeof f.dtick){for(var p=0,g=0,v=0,m=0,y=0;y.3*b||a(o)||a(i))){var w=f.dtick/2;h+=h+w0&&t.dtick<2*t._minDtick&&(t.dtick=t._minDtick,t.tick0=t._forceTick0)}t.tick0||(t.tick0="date"===t.type?new Date(2e3,0,1).getTime():0),o(t),t._tmin=T.tickFirst(t);var a=t.range[1]=l:s<=l)&&(i.push(s),!(i.length>1e3));s=T.tickIncrement(s,t.dtick,a));t._tmax=i[i.length-1];for(var c=new Array(i.length),u=0;u157788e5?(e/=315576e5,n=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick="M"+12*a(e,n,S)):e>12096e5?(e/=26298e5,t.dtick="M"+a(e,1,C)):e>432e5?(t.dtick=a(e,864e5,N),t.tick0=new Date(2e3,0,2).getTime()):e>18e5?t.dtick=a(e,36e5,C):e>3e4?t.dtick=a(e,6e4,E):e>500?t.dtick=a(e,1e3,E):(n=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick=a(e,n,S));else if("log"===t.type)if(t.tick0=0,e>.7)t.dtick=Math.ceil(e);else if(Math.abs(t.range[1]-t.range[0])<1){var r=1.5*Math.abs((t.range[1]-t.range[0])/e);e=Math.abs(Math.pow(10,t.range[1])-Math.pow(10,t.range[0]))/r,n=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick="L"+a(e,n,S)}else t.dtick=e>.3?"D2":"D1";else"category"===t.type?(t.tick0=0,t.dtick=Math.ceil(Math.max(e,1))):(t.tick0=0,n=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick=a(e,n,S));if(0===t.dtick&&(t.dtick=1),!x(t.dtick)&&"string"!=typeof t.dtick){var o=t.dtick;throw t.dtick=1,"ax.dtick error: "+String(o)}},T.tickIncrement=function(t,e,n){var r=n?-1:1;if(x(e))return t+r*e;var a=e.charAt(0),o=r*Number(e.substr(1));if("M"===a){var i=new Date(t);return i.setMonth(i.getMonth()+o)}if("L"===a)return Math.log(Math.pow(10,t)+o)/Math.LN10;if("D"===a){var l="D2"===e?P:O,s=t+.01*r,c=_.roundUp(m(s,1),l,n);return Math.floor(s)+Math.log(y.round(Math.pow(10,c),1))/Math.LN10}throw"unrecognized dtick "+String(e)},T.tickFirst=function(t){var e=t.range[1]r:c1&&e2*r}function u(t){for(var e,n=Math.max(1,(t.length-1)/1e3),r=0,a=0,o=0;o2*r}var f=t("fast-isnumeric"),d=t("tinycolor2").mix,h=t("../../lib"),p=t("../plots"),g=t("../../components/color/attributes").lightFraction,v=t("./layout_attributes"),m=t("./tick_value_defaults"),y=t("./tick_mark_defaults"),x=t("./tick_label_defaults"),b=t("./category_order_defaults"),_=t("./set_convert"),w=t("./ordered_categories"),k=t("./clean_datum"),M=t("./axis_ids");e.exports=function(t,e,n,a){function o(n,r){return h.coerce2(t,e,v,n,r)}var i=a.letter,l=a.font||{},s="Click to enter "+(a.title||i.toUpperCase()+" axis")+" title";a.name&&(e._name=a.name,e._id=M.name2id(a.name));var c=n("type");"-"===c&&(r(e,a.data),"-"===e.type?e.type="linear":c=t.type=e.type),_(e);var u=n("color"),p=u===t.color?u:l.color;n("title",s),h.coerceFont(n,"titlefont",{family:l.family,size:Math.round(1.2*l.size),color:p});var k=2===(t.range||[]).length&&f(t.range[0])&&f(t.range[1]),A=n("autorange",!k);A&&n("rangemode");var T=n("range",[-1,"x"===i?6:4]);T[0]===T[1]&&(e.range=[T[0]-1,T[0]+1]),h.noneOrAll(t.range,e.range,[0,1]),n("fixedrange"),m(t,e,n,c),x(t,e,n,c,a),y(t,e,n,a),b(t,e,n);var L=o("linecolor",u),z=o("linewidth"),S=n("showline",!!L||!!z);S||(delete e.linecolor,delete e.linewidth),(S||e.ticks)&&n("mirror");var C=o("gridcolor",d(u,a.bgColor,g).toRgbString()),E=o("gridwidth"),N=n("showgrid",a.showGrid||!!C||!!E);N||(delete e.gridcolor,delete e.gridwidth);var O=o("zerolinecolor",u),P=o("zerolinewidth"),j=n("zeroline",a.showGrid||!!O||!!P);return j||(delete e.zerolinecolor,delete e.zerolinewidth),e._initialCategories="category"===c?w(i,e.categoryorder,e.categoryarray,a.data):[],e}},{"../../components/color/attributes":19,"../../lib":99,"../plots":153,"./axis_ids":123,"./category_order_defaults":124,"./clean_datum":125,"./layout_attributes":130,"./ordered_categories":132,"./set_convert":135,"./tick_label_defaults":136,"./tick_mark_defaults":137,"./tick_value_defaults":138,"fast-isnumeric":11,tinycolor2:14}],123:[function(t,e,n){"use strict";function r(t,e,n){function r(t,n){for(var r=Object.keys(t),a=/^[xyz]axis[0-9]*/,o=[],i=0;i0;o&&(r="array");var i=n("categoryorder",r);"array"===i&&n("categoryarray"),o||"array"!==i||(e.categoryorder="trace")}}},{}],125:[function(t,e,n){"use strict";var r=t("fast-isnumeric"),a=t("../../lib");e.exports=function(t){try{if("object"==typeof t&&null!==t&&t.getTime)return a.ms2DateTime(t);if("string"!=typeof t&&!r(t))return"";t=t.toString().replace(/['"%,$# ]/g,"")}catch(e){a.error(e,t)}return t}},{"../../lib":99,"fast-isnumeric":11}],126:[function(t,e,n){"use strict";e.exports={idRegex:{x:/^x([2-9]|[1-9][0-9]+)?$/,y:/^y([2-9]|[1-9][0-9]+)?$/},attrRegex:{x:/^xaxis([2-9]|[1-9][0-9]+)?$/,y:/^yaxis([2-9]|[1-9][0-9]+)?$/},BADNUM:void 0,xAxisMatch:/^xaxis[0-9]*$/,yAxisMatch:/^yaxis[0-9]*$/,AX_ID_PATTERN:/^[xyz][0-9]*$/,AX_NAME_PATTERN:/^[xyz]axis[0-9]*$/,DBLCLICKDELAY:300,MINDRAG:8,MINSELECT:12,MINZOOM:20,DRAGGERSIZE:20,MAXDIST:20,YANGLE:60,HOVERARROWSIZE:6,HOVERTEXTPAD:3,HOVERFONTSIZE:13,HOVERFONT:"Arial, sans-serif",HOVERMINTIME:50,BENDPX:1.5,REDRAWDELAY:50}},{}],127:[function(t,e,n){"use strict";function r(t,e){var n,r=t.range[e],a=Math.abs(r-t.range[1-e]);return"date"===t.type?u.ms2DateTime(r,a):"log"===t.type?(n=Math.ceil(Math.max(0,-Math.log(a)/Math.LN10))+3,l.format("."+n+"g")(Math.pow(10,r))):(n=Math.floor(Math.log(Math.abs(r))/Math.LN10)-Math.floor(Math.log(a)/Math.LN10)+4,l.format("."+String(n)+"g")(r))}function a(t,e){return t?"nsew"===t?"pan"===e?"move":"crosshair":t.toLowerCase()+"-resize":"pointer"}function o(t){l.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}function i(t){var e=["lasso","select"];return e.indexOf(t)!==-1}var l=t("d3"),s=t("tinycolor2"),c=t("../../plotly"),u=t("../../lib"),f=t("../../lib/svg_text_utils"),d=t("../../components/color"),h=t("../../components/drawing"),p=t("../../lib/setcursor"),g=t("../../components/dragelement"),v=t("./axes"),m=t("./select"),y=t("./constants"),x=!0;e.exports=function(t,e,n,l,b,_,w,k){function M(t,e){for(var n=0;n.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("transform","translate("+pt+", "+gt+")").attr("d",st+"Z"),dt=ht.append("path").attr("class","zoombox-corners").style({fill:d.background,stroke:d.defaultLine,"stroke-width":1,opacity:0}).attr("transform","translate("+pt+", "+gt+")").attr("d","M0,0Z"),L();for(var o=0;o<$.length;o++)A($[o].range)}function L(){ht.selectAll(".select-outline").remove()}function z(t,e){var n=Math.max(0,Math.min(H,t+at)),r=Math.max(0,Math.min(V,e+ot)),a=Math.abs(n-at),o=Math.abs(r-ot),i=Math.floor(Math.min(o,a,G)/2);it.l=Math.min(at,n),it.r=Math.max(at,n),it.t=Math.min(ot,r),it.b=Math.max(ot,r),!J||o.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),dt.transition().style("opacity",1).duration(200),ct=!0)}function S(t,e,n){var r,a,o;for(r=0;rzoom back out","long"),x=!1)))}function E(e,n){var a=1===(w+k).length;if(e)D();else if(2!==n||a){if(1===n&&a){var o=w?B[0]:q[0],i="s"===w||"w"===k?0:1,l=o._name+".range["+i+"]",s=r(o,i),u="left",d="middle";if(o.fixedrange)return;w?(d="n"===w?"top":"bottom","right"===o.side&&(u="right")):"e"===k&&(u="right"),et.call(f.makeEditable,null,{immediate:!0,background:I.paper_bgcolor,text:String(s),fill:o.tickfont?o.tickfont.color:"#444",horizontalAlign:u,verticalAlign:d}).on("edit",function(e){var n="category"===o.type?o.c2l(e):o.d2l(e);void 0!==n&&c.relayout(t,l,n)})}}else j()}function N(e){function n(t,e,n){if(!t.fixedrange){A(t.range);var r=t.range,a=r[0]+(r[1]-r[0])*e;t.range=[a+(r[0]-a)*n,a+(r[1]-a)*n]}}if(t._context.scrollZoom||I._enablescrollzoom){var r=t.querySelector(".plotly");if(!(r.scrollHeight-r.clientHeight>10||r.scrollWidth-r.clientWidth>10)){clearTimeout(mt);var a=-e.deltaY;if(isFinite(a)||(a=e.wheelDelta/10),!isFinite(a))return void u.log("Did not find wheel motion attributes: ",e);var o,i=Math.exp(-Math.min(Math.max(a,-20),20)/100),l=xt.draglayer.select(".nsewdrag").node().getBoundingClientRect(),s=(e.clientX-l.left)/l.width,c=vt[0]+vt[2]*s,f=(l.bottom-e.clientY)/l.height,d=vt[1]+vt[3]*(1-f);if(k){for(o=0;o=0?Math.min(t,.9):1/(1/Math.max(t,-.3)+3.222))}function a(t,e,n){for(var a=1-e,o=0,i=0;i0;r--)n.push(e);return n}function a(t,e){for(var n=[],r=0;rY.width||Z<0||Z>Y.height)return _.unhoverRaw(t,e)}else G="xpx"in e?e.xpx:M[0]._length/2,Z="ypx"in e?e.ypx:A[0]._length/2;if(E="xval"in e?r(o,e.xval):a(M,G),N="yval"in e?r(o,e.yval):a(A,Z),!g(E[0])||!g(N[0]))return v.warn("Plotly.Fx.hover failed",e,t),_.unhoverRaw(t,e)}var X=1/0;for(P=0;P1||D.hoverinfo.indexOf("name")!==-1?D.name:void 0,index:!1,distance:Math.min(X,k.MAXDIST),color:x.defaultLine,x0:void 0,x1:void 0,y0:void 0,y1:void 0,xLabelVal:void 0,yLabelVal:void 0,zLabelVal:void 0,text:void 0},H=V.length,"array"===I){var Q=e[P];"pointNumber"in Q?(B.index=Q.pointNumber,I="closest"):(I="","xval"in Q&&(F=Q.xval,I="x"),"yval"in Q&&(q=Q.yval,I=I?"closest":"y"))}else F=E[R],q=N[R];if(D._module&&D._module.hoverPoints){var $=D._module.hoverPoints(B,F,q,I);if($)for(var W,J=0;J<$.length;J++)W=$[J],g(W.x0)&&g(W.y0)&&V.push(s(W,C))}else v.log("Unrecognized trace type in hover:",D);"closest"===C&&V.length>H&&(V.splice(0,H),X=V[0].distance)}if(0===V.length)return _.unhoverRaw(t,e);var K="y"===C&&U.length>1;V.sort(function(t,e){return t.distance-e.distance});var tt=x.combine(i.plot_bgcolor||x.background,i.paper_bgcolor),et={hovermode:C,rotateLabels:K,bgColor:tt,container:i._hoverlayer,outerContainer:i._paperdiv},nt=c(V,et);u(V,K?"xa":"ya"),f(nt,K);var rt=t._hoverdata,at=[];for(O=0;O128?"#000":x.background;if(t.name&&void 0===t.zLabelVal){var u=document.createElement("p");u.innerHTML=t.name,n=u.textContent||"",n.length>15&&(n=n.substr(0,12)+"...")}void 0!==t.extraText&&(r+=t.extraText),void 0!==t.zLabel?(void 0!==t.xLabel&&(r+="x: "+t.xLabel+"
"),void 0!==t.yLabel&&(r+="y: "+t.yLabel+"
"),r+=(r?"z: ":"")+t.zLabel):A&&t[a+"Label"]===g?r=t[("x"===a?"y":"x")+"Label"]||"":void 0===t.xLabel?void 0!==t.yLabel&&(r=t.yLabel):r=void 0===t.yLabel?t.xLabel:"("+t.xLabel+", "+t.yLabel+")",t.text&&!Array.isArray(t.text)&&(r+=(r?"
":"")+t.text),""===r&&(""===n&&e.remove(),r=n);var f=e.select("text.nums").style("fill",c).call(b.setPosition,0,0).text(r).attr("data-notex",1).call(y.convertToTspans);f.selectAll("tspan.line").call(b.setPosition,0,0);var d=e.select("text.name"),v=0;n&&n!==r?(d.style("fill",s).text(n).call(b.setPosition,0,0).attr("data-notex",1).call(y.convertToTspans),d.selectAll("tspan.line").call(b.setPosition,0,0),v=d.node().getBoundingClientRect().width+2*N):(d.remove(),e.select("rect").remove()),e.select("path").style({fill:s,stroke:c});var m,k,L=f.node().getBoundingClientRect(),z=t.xa._offset+(t.x0+t.x1)/2,S=t.ya._offset+(t.y0+t.y1)/2,C=Math.abs(t.x1-t.x0),O=Math.abs(t.y1-t.y0),P=L.width+E+N+v;t.ty0=_-L.top,t.bx=L.width+2*N,t.by=L.height+2*N,t.anchor="start",t.txwidth=L.width,t.tx2width=v,t.offset=0,o?(t.pos=z,m=S+O/2+P<=M,k=S-O/2-P>=0,"top"!==t.idealAlign&&m||!k?m?(S+=O/2,t.anchor="start"):t.anchor="middle":(S-=O/2,t.anchor="end")):(t.pos=S,m=z+C/2+P<=w,k=z-C/2-P>=0,"left"!==t.idealAlign&&m||!k?m?(z+=C/2,t.anchor="start"):t.anchor="middle":(z-=C/2,t.anchor="end")),f.attr("text-anchor",t.anchor),v&&d.attr("text-anchor",t.anchor),e.attr("transform","translate("+z+","+S+")"+(o?"rotate("+T+")":""))}),S}function u(t,e){function n(t){var e=t[0],n=t[t.length-1];if(a=e.pmin-e.pos-e.dp+e.size,o=n.pos+n.dp+n.size-e.pmax,a>.01){for(l=t.length-1;l>=0;l--)t[l].dp+=a;r=!1}if(!(o<.01)){if(a<-.01){for(l=t.length-1;l>=0;l--)t[l].dp-=o;r=!1}if(r){var c=0;for(i=0;ie.pmax&&c++;for(i=t.length-1;i>=0&&!(c<=0);i--)s=t[i],s.pos>e.pmax-1&&(s.del=!0,c--);for(i=0;i=0;l--)t[l].dp-=o;for(i=t.length-1;i>=0&&!(c<=0);i--)s=t[i],s.pos+s.dp+s.size>e.pmax&&(s.del=!0,c--)}}}for(var r,a,o,i,l,s,c,u=0,f=t.map(function(t,n){var r=t[e];return[{i:n,dp:0,pos:t.pos,posref:t.posref,size:t.by*("x"===r._id.charAt(0)?z:1)/2,pmin:r._offset,pmax:r._offset+r._length}]}).sort(function(t,e){return t[0].posref-e[0].posref});!r&&u<=t.length;){for(u++,r=!0,i=0;i.01&&p.pmin===g.pmin&&p.pmax===g.pmax){for(l=h.length-1;l>=0;l--)h[l].dp+=a;for(d.push.apply(d,h),f.splice(i+1,1),c=0,l=d.length-1;l>=0;l--)c+=d[l].dp;for(o=c/d.length,l=d.length-1;l>=0;l--)d[l].dp-=o;r=!1}else i++}f.forEach(n)}for(i=f.length-1;i>=0;i--){var v=f[i];for(l=v.length-1;l>=0;l--){var m=v[l],y=t[m.i];y.offset=m.dp,y.del=m.del}}}function f(t,e){t.each(function(t){var n=h.select(this);if(t.del)return void n.remove();var r="end"===t.anchor?-1:1,a=n.select("text.nums"),o={start:1,end:-1,middle:0}[t.anchor],i=o*(E+N),l=i+o*(t.txwidth+N),s=0,c=t.offset;"middle"===t.anchor&&(i-=t.tx2width/2,l-=t.tx2width/2),e&&(c*=-C,s=t.offset*S),n.select("path").attr("d","middle"===t.anchor?"M-"+t.bx/2+",-"+t.by/2+"h"+t.bx+"v"+t.by+"h-"+t.bx+"Z":"M0,0L"+(r*E+s)+","+(E+c)+"v"+(t.by/2-E)+"h"+r*t.bx+"v-"+t.by+"H"+(r*E+s)+"V"+(c-E)+"Z"),a.call(b.setPosition,i+s,c+t.ty0-t.by/2+N).selectAll("tspan.line").attr({x:a.attr("x"),y:a.attr("y")}),t.tx2width&&(n.select("text.name, text.name tspan.line").call(b.setPosition,l+o*N+s,c+t.ty0-t.by/2+N),n.select("rect").call(b.setRect,l+(o-1)*t.tx2width/2+s,c-t.by/2-1,t.tx2width,t.by+2))})}function d(t,e,n){if(!e.target)return!1;if(!n||n.length!==t._hoverdata.length)return!0;for(var r=n.length-1;r>=0;r--){var a=n[r],o=t._hoverdata[r];if(a.curveNumber!==o.curveNumber||String(a.pointNumber)!==String(o.pointNumber))return!0}return!1}var h=t("d3"),p=t("tinycolor2"),g=t("fast-isnumeric"),v=t("../../lib"),m=t("../../lib/events"),y=t("../../lib/svg_text_utils"),x=t("../../components/color"),b=t("../../components/drawing"),_=t("../../components/dragelement"),w=t("./axes"),k=t("./constants"),M=t("./dragbox"),A=e.exports={};A.unhover=_.unhover,A.layoutAttributes={dragmode:{valType:"enumerated",values:["zoom","pan","select","lasso","orbit","turntable"],dflt:"zoom"},hovermode:{valType:"enumerated",values:["x","y","closest",!1]}},A.supplyLayoutDefaults=function(t,e,n){function r(n,r){return v.coerce(t,e,A.layoutAttributes,n,r)}r("dragmode");var a;if(e._has("cartesian")){var o=e._isHoriz=A.isHoriz(n);a=o?"y":"x"}else a="closest";r("hovermode",a)},A.isHoriz=function(t){for(var e=!0,n=0;nt._lastHoverTime+k.HOVERMINTIME?(i(t,e,n),void(t._lastHoverTime=Date.now())):void(t._hoverTimer=setTimeout(function(){i(t,e,n),t._lastHoverTime=Date.now(),t._hoverTimer=void 0},k.HOVERMINTIME))},A.getDistanceFunction=function(t,e,n,r){return"closest"===t?r||o(e,n):"x"===t?e:n},A.getClosest=function(t,e,n){if(n.index!==!1)n.index>=0&&n.indexf[1]-.01&&(e.domain=[0,1]),a.noneOrAll(t.domain,e.domain,[0,1])}return e}},{"../../lib":99,"fast-isnumeric":11}],134:[function(t,e,n){"use strict";function r(t){return t._id}var a=t("../../lib/polygon"),o=t("../../components/color"),i=t("./axes"),l=t("./constants"),s=a.filter,c=a.tester,u=l.MINSELECT;e.exports=function(t,e,n,a,f){function d(t){var e="y"===t._id.charAt(0)?1:0;return function(n){return t.p2d(n[e])}}function h(t,e){return t-e}var p,g=a.gd._fullLayout._zoomlayer,v=a.element.getBoundingClientRect(),m=a.plotinfo.x()._offset,y=a.plotinfo.y()._offset,x=e-v.left,b=n-v.top,_=x,w=b,k="M"+x+","+b,M=a.xaxes[0]._length,A=a.yaxes[0]._length,T=a.xaxes.map(r),L=a.yaxes.map(r),z=a.xaxes.concat(a.yaxes);"lasso"===f&&(p=s([[x,b]],l.BENDPX));var S=g.selectAll("path.select-outline").data([1,2]);S.enter().append("path").attr("class",function(t){return"select-outline select-outline-"+t}).attr("transform","translate("+m+", "+y+")").attr("d",k+"Z");var C,E,N,O,P,j=g.append("path").attr("class","zoombox-corners").style({fill:o.background,stroke:o.defaultLine,"stroke-width":1}).attr("transform","translate("+m+", "+y+")").attr("d","M0,0Z"),D=[],R=a.gd,I=[];for(C=0;C0)return Math.log(e)/Math.LN10;if(e<=0&&n&&t.range&&2===t.range.length){var r=t.range[0],a=t.range[1];return.5*(r+a-3*u*Math.abs(r-a))}return i.BADNUM}function n(t){return Math.pow(10,t)}function c(t){return a(t)?Number(t):i.BADNUM}var u=10;if(t.c2l="log"===t.type?e:c,t.l2c="log"===t.type?n:c,t.l2d=function(e){return t.c2d(t.l2c(e))},t.p2d=function(e){return t.l2d(t.p2l(e))},t.setScale=function(){var e,n=t._gd._fullLayout._size;if(t._categories||(t._categories=[]),t.overlaying){var r=s.getFromId(t._gd,t.overlaying);t.domain=r.domain}for(t.range&&2===t.range.length&&t.range[0]!==t.range[1]||(t.range=[-1,1]),e=0;e<2;e++)a(t.range[e])||(t.range[e]=a(t.range[1-e])?t.range[1-e]*(e?10:.1):e?1:-1),t.range[e]<-(Number.MAX_VALUE/2)?t.range[e]=-(Number.MAX_VALUE/2):t.range[e]>Number.MAX_VALUE/2&&(t.range[e]=Number.MAX_VALUE/2);if("y"===t._id.charAt(0)?(t._offset=n.t+(1-t.domain[1])*n.h,t._length=n.h*(t.domain[1]-t.domain[0]),t._m=t._length/(t.range[0]-t.range[1]),t._b=-t._m*t.range[1]):(t._offset=n.l+t.domain[0]*n.w,t._length=n.w*(t.domain[1]-t.domain[0]),t._m=t._length/(t.range[1]-t.range[0]),t._b=-t._m*t.range[0]),!isFinite(t._m)||!isFinite(t._b))throw o.notifier("Something went wrong with axis scaling","long"),t._gd._replotting=!1,new Error("axis scaling")},t.l2p=function(e){return a(e)?r.round(t._b+t._m*e,2):i.BADNUM},t.p2l=function(e){return(e-t._b)/t._m},t.c2p=function(e,n){return t.l2p(t.c2l(e,n))},t.p2c=function(e){return t.l2c(t.p2l(e))},["linear","log","-"].indexOf(t.type)!==-1)t.c2d=c,t.d2c=function(t){return t=l(t),a(t)?Number(t):i.BADNUM},t.d2l=function(e,n){return"log"===t.type?t.c2l(t.d2c(e),n):t.d2c(e)};else if("date"===t.type){if(t.c2d=function(t){return a(t)?o.ms2DateTime(t):i.BADNUM},t.d2c=function(t){return a(t)?Number(t):o.dateTime2ms(t)},t.d2l=t.d2c,t.range&&t.range.length>1)try{var f=t.range.map(o.dateTime2ms);!a(t.range[0])&&a(f[0])&&(t.range[0]=f[0]),!a(t.range[1])&&a(f[1])&&(t.range[1]=f[1])}catch(e){o.error(e,t.range)}}else"category"===t.type&&(t.c2d=function(e){return t._categories[Math.round(e)]},t.d2c=function(e){null!==e&&void 0!==e&&t._categories.indexOf(e)===-1&&t._categories.push(e);var n=t._categories.indexOf(e);return n===-1?i.BADNUM:n},t.d2l=t.d2c);t.makeCalcdata=function(e,n){var r,a,o;if(n in e)for(r=e[n],a=new Array(r.length),o=0;or?"0":"1.0"}var n=this.framework,r=n.select("g.choroplethlayer"),a=n.select("g.scattergeolayer"),o=this.projection,i=this.path,l=this.clipAngle;n.selectAll("path.basepath").attr("d",i),n.selectAll("path.graticulepath").attr("d",i),r.selectAll("path.choroplethlocation").attr("d",i),r.selectAll("path.basepath").attr("d",i),a.selectAll("path.js-line").attr("d",i),null!==l?(a.selectAll("path.point").style("opacity",e).attr("transform",t),a.selectAll("text").style("opacity",e).attr("transform",t)):(a.selectAll("path.point").attr("transform",t),a.selectAll("text").attr("transform",t))}},{"../../components/color":20,"../../components/drawing":43,"../../constants/xmlns_namespaces":89,"../../lib/filter_visible":97,"../../lib/topojson_utils":111,"../../plots/cartesian/axes":121,"./constants":140,"./projections":148,"./set_scale":149,"./zoom":150,"./zoom_reset":151,d3:8,topojson:15}],142:[function(t,e,n){"use strict";var r=t("./geo"),a=t("../../plots/plots");n.name="geo",n.attr="geo",n.idRoot="geo",n.idRegex=/^geo([2-9]|[1-9][0-9]+)?$/,n.attrRegex=/^geo([2-9]|[1-9][0-9]+)?$/,n.attributes=t("./layout/attributes"),n.layoutAttributes=t("./layout/layout_attributes"),n.supplyLayoutDefaults=t("./layout/defaults"),n.plot=function(t){var e=t._fullLayout,n=t._fullData,o=a.getSubplotIds(e,"geo");void 0===window.PlotlyGeoAssets&&(window.PlotlyGeoAssets={topojson:{}});for(var i=0;ir^h>r&&n<(d-c)*(r-u)/(h-u)+c&&(a=!a)}return a}function i(t){return t?t/Math.sin(t):1}function l(t){return t>1?N:t<-1?-N:Math.asin(t)}function s(t){return t>1?0:t<-1?E:Math.acos(t)}function c(t,e){var n=(2+N)*Math.sin(e);e/=2;for(var r=0,a=1/0;r<10&&Math.abs(a)>S;r++){var o=Math.cos(e);e-=a=(e+Math.sin(e)*(o+2)-n)/(2*o*(1+o))}return[2/Math.sqrt(E*(4+E))*t*(1+Math.cos(e)),2*Math.sqrt(E/(4+E))*Math.sin(e)]}function u(t,e){function n(n,r){var a=R(n/e,r);return a[0]*=t,a}return arguments.length<2&&(e=t),1===e?R:e===1/0?d:(n.invert=function(n,r){var a=R.invert(n/t,r);return a[0]*=e,a},n)}function f(){var t=2,e=D(u),n=e(t);return n.coefficient=function(n){return arguments.length?e(t=+n):t},n}function d(t,e){return[t*Math.cos(e)/Math.cos(e/=2),2*Math.sin(e)]}function h(t,e){return[3*t/(2*E)*Math.sqrt(E*E/3-e*e),e]}function p(t,e){return[t,1.25*Math.log(Math.tan(E/4+.4*e))]}function g(t){return function(e){var n,r=t*Math.sin(e),a=30;do e-=n=(e+Math.sin(e)-r)/(1+Math.cos(e));while(Math.abs(n)>S&&--a>0);return e/2}}function v(t,e,n){function r(n,r){return[t*n*Math.cos(r=a(r)),e*Math.sin(r)]}var a=g(n);return r.invert=function(r,a){var o=l(a/e);return[r/(t*Math.cos(o)),l((2*o+Math.sin(2*o))/n)]},r}function m(t,e){var n=e*e,r=n*n;return[t*(.8707-.131979*n+r*(-.013791+r*(.003971*n-.001529*r))),e*(1.007226+n*(.015085+r*(-.044475+.028874*n-.005916*r)))]}function y(t,e){var n,r=Math.min(18,36*Math.abs(e)/E),a=Math.floor(r),o=r-a,i=(n=F[a])[0],l=n[1],s=(n=F[++a])[0],c=n[1],u=(n=F[Math.min(19,++a)])[0],f=n[1];return[t*(s+o*(u-i)/2+o*o*(u-2*s+i)/2),(e>0?N:-N)*(c+o*(f-l)/2+o*o*(f-2*c+l)/2)]}function x(t,e){return[t*Math.cos(e),e]}function b(t,e){var n=Math.cos(e),r=i(s(n*Math.cos(t/=2)));return[2*n*Math.sin(t)*r,Math.sin(e)*r]}function _(t,e){var n=b(t,e);return[(n[0]+t/N)/2,(n[1]+e)/2]}t.geo.project=function(t,e){var r=e.stream;if(!r)throw new Error("not yet supported");return(t&&w.hasOwnProperty(t.type)?w[t.type]:n)(t,r)};var w={Feature:e,FeatureCollection:function(t,n){return{type:"FeatureCollection",features:t.features.map(function(t){return e(t,n)})}}},k=[],M=[],A={point:function(t,e){k.push([t,e])},result:function(){var t=k.length?k.length<2?{type:"Point",coordinates:k[0]}:{type:"MultiPoint",coordinates:k}:null;return k=[],t}},T={lineStart:r,point:function(t,e){k.push([t,e])},lineEnd:function(){k.length&&(M.push(k),k=[])},result:function(){var t=M.length?M.length<2?{type:"LineString",coordinates:M[0]}:{type:"MultiLineString",coordinates:M}:null;return M=[],t}},L={polygonStart:r,lineStart:r,point:function(t,e){k.push([t,e])},lineEnd:function(){var t=k.length;if(t){do k.push(k[0].slice());while(++t<4);M.push(k),k=[]}},polygonEnd:r,result:function(){if(!M.length)return null;var t=[],e=[];return M.forEach(function(n){a(n)?t.push([n]):e.push(n)}),e.forEach(function(e){var n=e[0];t.some(function(t){if(o(t[0],n))return t.push(e),!0})||t.push([e])}),M=[],t.length?t.length>1?{type:"MultiPolygon",coordinates:t}:{type:"Polygon",coordinates:t[0]}:null}},z={Point:A,MultiPoint:A,LineString:T,MultiLineString:T,Polygon:L,MultiPolygon:L,Sphere:L},S=1e-6,C=S*S,E=Math.PI,N=E/2,O=(Math.sqrt(E),E/180),P=180/E,j=t.geo.projection,D=t.geo.projectionMutator;t.geo.interrupt=function(e){function n(t,n){for(var r=n<0?-1:1,a=s[+(n<0)],o=0,i=a.length-1;oa[o][2][0];++o);var l=e(t-a[o][1][0],n);return l[0]+=e(a[o][1][0],r*n>r*a[o][0][1]?a[o][0][1]:n)[0],l}function r(){l=s.map(function(t){return t.map(function(t){var n,r=e(t[0][0],t[0][1])[0],a=e(t[2][0],t[2][1])[0],o=e(t[1][0],t[0][1])[1],i=e(t[1][0],t[1][1])[1];return o>i&&(n=o,o=i,i=n),[[r,o],[a,i]]})})}function a(){for(var e=1e-6,n=[],r=0,a=s[0].length;r=0;--r){var i=s[1][r],l=180*i[0][0]/E,c=180*i[0][1]/E,u=180*i[1][1]/E,f=180*i[2][0]/E,d=180*i[2][1]/E;n.push(o([[f-e,d-e],[f-e,u+e],[l+e,u+e],[l+e,c-e]],30))}return{type:"Polygon",coordinates:[t.merge(n)]}}function o(t,e){for(var n,r,a,o=-1,i=t.length,l=t[0],s=[];++oS&&--a>0);return[t/(.8707+(o=r*r)*(-.131979+o*(-.013791+o*o*o*(.003971-.001529*o)))),r]},(t.geo.naturalEarth=function(){return j(m)}).raw=m;var F=[[.9986,-.062],[1,0],[.9986,.062],[.9954,.124],[.99,.186],[.9822,.248],[.973,.31],[.96,.372],[.9427,.434],[.9216,.4958],[.8962,.5571],[.8679,.6176],[.835,.6769],[.7986,.7346],[.7597,.7903],[.7186,.8435],[.6732,.8936],[.6213,.9394],[.5722,.9761],[.5322,1]];F.forEach(function(t){t[1]*=1.0144}),y.invert=function(t,e){var n=e/N,r=90*n,a=Math.min(18,Math.abs(r/5)),o=Math.max(0,Math.floor(a));do{var i=F[o][1],l=F[o+1][1],s=F[Math.min(19,o+2)][1],c=s-i,u=s-2*l+i,f=2*(Math.abs(n)-l)/c,d=u/c,h=f*(1-d*f*(1-2*d*f));if(h>=0||1===o){r=(e>=0?5:-5)*(h+a);var p,g=50;do a=Math.min(18,Math.abs(r)/5),o=Math.floor(a),h=a-o,i=F[o][1],l=F[o+1][1],s=F[Math.min(19,o+2)][1],r-=(p=(e>=0?N:-N)*(l+h*(s-i)/2+h*h*(s-2*l+i)/2)-e)*P;while(Math.abs(p)>C&&--g>0);break}}while(--o>=0);var v=F[o][0],m=F[o+1][0],y=F[Math.min(19,o+2)][0];return[t/(m+h*(y-v)/2+h*h*(y-2*m+v)/2),r*O]},(t.geo.robinson=function(){return j(y)}).raw=y,x.invert=function(t,e){return[t/Math.cos(e),e]},(t.geo.sinusoidal=function(){return j(x)}).raw=x,b.invert=function(t,e){if(!(t*t+4*e*e>E*E+S)){var n=t,r=e,a=25;do{var o,i=Math.sin(n),l=Math.sin(n/2),c=Math.cos(n/2),u=Math.sin(r),f=Math.cos(r),d=Math.sin(2*r),h=u*u,p=f*f,g=l*l,v=1-p*c*c,m=v?s(f*c)*Math.sqrt(o=1/v):o=0,y=2*m*f*l-t,x=m*u-e,b=o*(p*g+m*f*c*h),_=o*(.5*i*d-2*m*u*l),w=.25*o*(d*l-m*u*p*i),k=o*(h*c+m*g*f),M=_*w-k*b;if(!M)break;var A=(x*_-y*k)/M,T=(y*w-x*b)/M;n-=A,r-=T}while((Math.abs(A)>S||Math.abs(T)>S)&&--a>0);return[n,r]}},(t.geo.aitoff=function(){return j(b)}).raw=b,_.invert=function(t,e){var n=t,r=e,a=25;do{var o,i=Math.cos(r),l=Math.sin(r),c=Math.sin(2*r),u=l*l,f=i*i,d=Math.sin(n),h=Math.cos(n/2),p=Math.sin(n/2),g=p*p,v=1-f*h*h,m=v?s(i*h)*Math.sqrt(o=1/v):o=0,y=.5*(2*m*i*p+n/N)-t,x=.5*(m*l+r)-e,b=.5*o*(f*g+m*i*h*u)+.5/N,_=o*(d*c/4-m*l*p),w=.125*o*(c*p-m*l*f*d),k=.5*o*(u*h+m*g*i)+.5,M=_*w-k*b,A=(x*_-y*k)/M,T=(y*w-x*b)/M;n-=A,r-=T}while((Math.abs(A)>S||Math.abs(T)>S)&&--a>0);return[n,r]},(t.geo.winkel3=function(){return j(_)}).raw=_}e.exports=r},{}],149:[function(t,e,n){"use strict";function r(t,e){var n=t.projection,r=t.lonaxis,i=t.lataxis,s=t.domain,c=t.framewidth||0,u=e.w*(s.x[1]-s.x[0]),f=e.h*(s.y[1]-s.y[0]),d=r.range[0]+l,h=r.range[1]-l,p=i.range[0]+l,g=i.range[1]-l,v=r._fullRange[0]+l,m=r._fullRange[1]-l,y=i._fullRange[0]+l,x=i._fullRange[1]-l;n._translate0=[e.l+u/2,e.t+f/2];var b=h-d,_=g-p,w=[d+b/2,p+_/2],k=n._rotate;n._center=[w[0]+k[0],w[1]+k[1]];var M=function(e){function r(t){return Math.min(_*u/(t[1][0]-t[0][0]),_*f/(t[1][1]-t[0][1]))}var i,l,s,b,_=e.scale(),w=n._translate0,k=a(d,p,h,g),M=a(v,y,m,x);s=o(e,k),i=r(s),b=o(e,M),n._fullScale=r(b),e.scale(i),s=o(e,k),l=[w[0]-s[0][0]+c,w[1]-s[0][1]+c],n._translate=l,e.translate(l),s=o(e,k),t._isAlbersUsa||e.clipExtent(s),i=n.scale*i,n._scale=i,t._width=Math.round(s[1][0])+c,t._height=Math.round(s[1][1])+c,t._marginX=(u-Math.round(s[1][0]))/2,t._marginY=(f-Math.round(s[1][1]))/2};return M}function a(t,e,n,r){var a=(n-t)/4;return{type:"Polygon",coordinates:[[[t,e],[t,r],[t+a,r],[t+2*a,r],[t+3*a,r],[n,r],[n,e],[n-a,e],[n-2*a,e],[n-3*a,e],[t,e]]]}}function o(t,e){return i.geo.path().projection(t).bounds(e)}var i=t("d3"),l=t("./constants").clipPad;e.exports=r},{"./constants":140,d3:8}],150:[function(t,e,n){"use strict";function r(t,e){var n;return(n=e._isScoped?o:e._clipAngle?l:i)(t,e.projection)}function a(t,e){var n=e._fullScale;return _.behavior.zoom().translate(t.translate()).scale(t.scale()).scaleExtent([.5*n,100*n])}function o(t,e){function n(){_.select(this).style(M)}function r(){i.scale(_.event.scale).translate(_.event.translate),t.render()}function o(){_.select(this).style(A)}var i=t.projection,l=a(i,e);return l.on("zoomstart",n).on("zoom",r).on("zoomend",o),l}function i(t,e){function n(t){return v.invert(t)}function r(t){var e=v(n(t));return Math.abs(e[0]-t[0])>y||Math.abs(e[1]-t[1])>y}function o(){_.select(this).style(M),s=_.mouse(this),c=v.rotate(),u=v.translate(),f=c,d=n(s)}function i(){return h=_.mouse(this),r(s)?(m.scale(v.scale()),void m.translate(v.translate())):(v.scale(_.event.scale),v.translate([u[0],_.event.translate[1]]),d?n(h)&&(g=n(h),p=[f[0]+(g[0]-d[0]),c[1],c[2]],v.rotate(p),f=p):(s=h,d=n(s)),void t.render())}function l(){_.select(this).style(A)}var s,c,u,f,d,h,p,g,v=t.projection,m=a(v,e),y=2;return m.on("zoomstart",o).on("zoom",i).on("zoomend",l),m}function l(t,e){function n(t){m++||t({type:"zoomstart"})}function r(t){t({type:"zoom"})}function o(t){--m||t({type:"zoomend"})}var i,l=t.projection,h={r:l.rotate(),k:l.scale()},p=a(l,e),g=b(p,"zoomstart","zoom","zoomend"),m=0,y=p.on;return p.on("zoomstart",function(){_.select(this).style(M);var t=_.mouse(this),e=l.rotate(),a=e,o=l.translate(),m=c(e);i=s(l,t),y.call(p,"zoom",function(){var n=_.mouse(this);if(l.scale(h.k=_.event.scale),i){if(s(l,n)){l.rotate(e).translate(o);var c=s(l,n),p=f(i,c),y=v(u(m,p)),x=h.r=d(y,i,a);isFinite(x[0])&&isFinite(x[1])&&isFinite(x[2])||(x=a),l.rotate(x),a=x}}else t=n,i=s(l,t);r(g.of(this,arguments))}),n(g.of(this,arguments))}).on("zoomend",function(){_.select(this).style(A),y.call(p,"zoom",null),o(g.of(this,arguments))}).on("zoom.redraw",function(){t.render()}),_.rebind(p,g,"on")}function s(t,e){var n=t.invert(e);return n&&isFinite(n[0])&&isFinite(n[1])&&m(n)}function c(t){var e=.5*t[0]*w,n=.5*t[1]*w,r=.5*t[2]*w,a=Math.sin(e),o=Math.cos(e),i=Math.sin(n),l=Math.cos(n),s=Math.sin(r),c=Math.cos(r);return[o*l*c+a*i*s,a*l*c-o*i*s,o*i*c+a*l*s,o*l*s-a*i*c]}function u(t,e){var n=t[0],r=t[1],a=t[2],o=t[3],i=e[0],l=e[1],s=e[2],c=e[3];return[n*i-r*l-a*s-o*c,n*l+r*i+a*c-o*s,n*s-r*c+a*i+o*l,n*c+r*s-a*l+o*i]}function f(t,e){if(t&&e){var n=x(t,e),r=Math.sqrt(y(n,n)),a=.5*Math.acos(Math.max(-1,Math.min(1,y(t,e)))),o=Math.sin(a)/r;return r&&[Math.cos(a),n[2]*o,-n[1]*o,n[0]*o]}}function d(t,e,n){var r=g(e,2,t[0]);r=g(r,1,t[1]),r=g(r,0,t[2]-n[2]);var a,o,i=e[0],l=e[1],s=e[2],c=r[0],u=r[1],f=r[2],d=Math.atan2(l,i)*k,p=Math.sqrt(i*i+l*l);Math.abs(u)>p?(o=(u>0?90:-90)-d,a=0):(o=Math.asin(u/p)*k-d,a=Math.sqrt(p*p-u*u));var v=180-o-2*d,m=(Math.atan2(f,c)-Math.atan2(s,a))*k,y=(Math.atan2(f,c)-Math.atan2(s,-a))*k,x=h(n[0],n[1],o,m),b=h(n[0],n[1],v,y);return x<=b?[o,m,n[2]]:[v,y,n[2]]}function h(t,e,n,r){var a=p(n-t),o=p(r-e);return Math.sqrt(a*a+o*o)}function p(t){return(t%360+540)%360-180}function g(t,e,n){var r=n*w,a=t.slice(),o=0===e?1:0,i=2===e?1:2,l=Math.cos(r),s=Math.sin(r);return a[o]=t[o]*l-t[i]*s,a[i]=t[i]*l+t[o]*s,a}function v(t){return[Math.atan2(2*(t[0]*t[1]+t[2]*t[3]),1-2*(t[1]*t[1]+t[2]*t[2]))*k,Math.asin(Math.max(-1,Math.min(1,2*(t[0]*t[2]-t[3]*t[1]))))*k,Math.atan2(2*(t[0]*t[3]+t[1]*t[2]),1-2*(t[2]*t[2]+t[3]*t[3]))*k]}function m(t){var e=t[0]*w,n=t[1]*w,r=Math.cos(n);return[r*Math.cos(e),r*Math.sin(e),Math.sin(n)]}function y(t,e){for(var n=0,r=0,a=t.length;r=e.width-20?(o["text-anchor"]="start",o.x=5):(o["text-anchor"]="end",o.x=e._paper.attr("width")-7),n.attr(o);var i=n.select(".js-link-to-tool"),l=n.select(".js-link-spacer"),c=n.select(".js-sourcelinks");t._context.showSources&&t._context.showSources(t),t._context.showLink&&a(t,i),l.text(i.text()&&c.text()?" - ":"")},h.sendDataToCloud=function(t){t.emit("plotly_beforeexport");var e=window.PLOTLYENV&&window.PLOTLYENV.BASE_URL||"https://plot.ly",n=s.select(t).append("div").attr("id","hiddenform").style("display","none"),r=n.append("form").attr({action:e+"/external",method:"post",target:"_blank"}),a=r.append("input").attr({type:"text",name:"data"});return a.node().value=h.graphJson(t,!1,"keepdata"),r.node().submit(),n.remove(),t.emit("plotly_afterexport"),!1},h.supplyDefaults=function(t){var e,n=t._fullLayout||{},r=t._fullLayout={},a=t.layout||{},i=t._fullData||[],l=t._fullData=[],s=t.data||[];h.supplyLayoutGlobalDefaults(a,r),r._dataLength=s.length,h.supplyDataDefaults(s,l,r),r._has=h._hasPlotType.bind(r);var c=r._modules;for(e=0;e.5*r.width&&(n.l=n.r=0),n.b+n.t>.5*r.height&&(n.b=n.t=0),r._pushmargin[e]={l:{val:n.x,size:n.l+a},r:{val:n.x,size:n.r+a},b:{val:n.y,size:n.b+a},t:{val:n.y,size:n.t+a}}}else delete r._pushmargin[e];t._replotting||h.doAutoMargin(t)}},h.doAutoMargin=function(t){var e=t._fullLayout;e._size||(e._size={}),e._pushmargin||(e._pushmargin={});var n=e._size,r=JSON.stringify(n),a=Math.max(e.margin.l||0,0),o=Math.max(e.margin.r||0,0),i=Math.max(e.margin.t||0,0),l=Math.max(e.margin.b||0,0),s=e._pushmargin;if(e.margin.autoexpand!==!1&&(s.base={l:{val:0,size:a},r:{val:1,size:o},t:{val:1,size:i},b:{val:0,size:l}},Object.keys(s).forEach(function(t){var n=s[t].l||{},r=s[t].b||{},u=n.val,f=n.size,d=r.val,h=r.size;Object.keys(s).forEach(function(t){if(c(f)&&s[t].r){var n=s[t].r.val,r=s[t].r.size;if(n>u){var p=(f*n+(r-e.width)*u)/(n-u),g=(r*(1-u)+(f-e.width)*(1-n))/(n-u);p>=0&&g>=0&&p+g>a+o&&(a=p,o=g)}}if(c(h)&&s[t].t){var v=s[t].t.val,m=s[t].t.size;if(v>d){var y=(h*v+(m-e.height)*d)/(v-d),x=(m*(1-d)+(h-e.height)*(1-v))/(v-d);y>=0&&x>=0&&y+x>l+i&&(l=y,i=x)}}})})),n.l=Math.round(a),n.r=Math.round(o),n.t=Math.round(i),n.b=Math.round(l),n.p=Math.round(e.margin.pad),n.w=Math.round(e.width)-n.l-n.r,n.h=Math.round(e.height)-n.t-n.b,!t._replotting&&"{}"!==r&&r!==JSON.stringify(e._size))return u.plot(t)},h.graphJson=function(t,e,n,r,a){function o(t){if("function"==typeof t)return null;if(f.isPlainObject(t)){var e,r,a={};for(e in t)if("function"!=typeof t[e]&&["_","["].indexOf(e.charAt(0))===-1){if("keepdata"===n){if("src"===e.substr(e.length-3))continue}else if("keepstream"===n){if(r=t[e+"src"],"string"==typeof r&&r.indexOf(":")>0&&!f.isPlainObject(t.stream))continue}else if("keepall"!==n&&(r=t[e+"src"],"string"==typeof r&&r.indexOf(":")>0))continue;a[e]=o(t[e])}return a}return Array.isArray(t)?t.map(o):t&&t.getTime?f.ms2DateTime(t):t}(a&&e&&!t._fullData||a&&!e&&!t._fullLayout)&&h.supplyDefaults(t);var i=a?t._fullData:t.data,l=a?t._fullLayout:t.layout,s={data:(i||[]).map(function(t){var n=o(t);return e&&delete n.fit,n})};return e||(s.layout=o(l)),t.framework&&t.framework.isPolar&&(s=t.framework.getConfig()),"object"===r?s:JSON.stringify(s)}},{"../components/color":20,"../lib":99,"../plotly":118,"./attributes":119,"./font_attributes":139,"./layout_attributes":152,d3:8,"fast-isnumeric":11}],154:[function(t,e,n){"use strict";var r=t("../../traces/scatter/attributes"),a=r.marker;e.exports={r:r.r,t:r.t,marker:{color:a.color,size:a.size,symbol:a.symbol,opacity:a.opacity}}},{"../../traces/scatter/attributes":175}],155:[function(t,e,n){"use strict";function r(t,e){var n={showline:{valType:"boolean"},showticklabels:{valType:"boolean"},tickorientation:{valType:"enumerated",values:["horizontal","vertical"]},ticklen:{valType:"number",min:0},tickcolor:{valType:"color"},ticksuffix:{valType:"string"},endpadding:{valType:"number"},visible:{valType:"boolean"}};return o({},e,n)}var a=t("../cartesian/layout_attributes"),o=t("../../lib/extend").extendFlat,i=o({},a.domain,{});e.exports={radialaxis:r("radial",{range:{valType:"info_array",items:[{valType:"number"},{valType:"number"}]},domain:i,orientation:{valType:"number"}}),angularaxis:r("angular",{range:{valType:"info_array",items:[{valType:"number",dflt:0},{valType:"number",dflt:360}]},domain:i}),layout:{direction:{valType:"enumerated",values:["clockwise","counterclockwise"]},orientation:{valType:"angle"}}}},{"../../lib/extend":96,"../cartesian/layout_attributes":130}],156:[function(t,e,n){var r=t("../../plotly"),a=t("d3"),o=e.exports={version:"0.2.2",manager:t("./micropolar_manager")},i=r.Lib.extendDeepAll;o.Axis=function(){function t(t){n=t||n;var c=s.data,f=s.layout;return("string"==typeof n||n.nodeName)&&(n=a.select(n)),n.datum(c).each(function(t,n){function s(t,e){return l(t)%360+f.orientation}var c=t.slice();u={data:o.util.cloneJson(c),layout:o.util.cloneJson(f)};var d=0;c.forEach(function(t,e){t.color||(t.color=f.defaultColorRange[d],d=(d+1)%f.defaultColorRange.length),t.strokeColor||(t.strokeColor="LinePlot"===t.geometry?t.color:a.rgb(t.color).darker().toString()),u.data[e].color=t.color,u.data[e].strokeColor=t.strokeColor,u.data[e].strokeDash=t.strokeDash,u.data[e].strokeSize=t.strokeSize});var h=c.filter(function(t,e){var n=t.visible;return"undefined"==typeof n||n===!0}),p=!1,g=h.map(function(t,e){return p=p||"undefined"!=typeof t.groupId,t});if(p){var v=a.nest().key(function(t,e){return"undefined"!=typeof t.groupId?t.groupId:"unstacked"}).entries(g),m=[],y=v.map(function(t,e){if("unstacked"===t.key)return t.values;var n=t.values[0].r.map(function(t,e){return 0});return t.values.forEach(function(t,e,r){t.yStack=[n],m.push(n),n=o.util.sumArrays(t.r,n)}),t.values});h=a.merge(y)}h.forEach(function(t,e){t.t=Array.isArray(t.t[0])?t.t:[t.t],t.r=Array.isArray(t.r[0])?t.r:[t.r]});var x=Math.min(f.width-f.margin.left-f.margin.right,f.height-f.margin.top-f.margin.bottom)/2;x=Math.max(10,x);var b,_=[f.margin.left+x,f.margin.top+x];if(p){var w=a.max(o.util.sumArrays(o.util.arrayLast(h).r[0],o.util.arrayLast(m)));b=[0,w]}else b=a.extent(o.util.flattenArray(h.map(function(t,e){return t.r})));f.radialAxis.domain!=o.DATAEXTENT&&(b[0]=0),r=a.scale.linear().domain(f.radialAxis.domain!=o.DATAEXTENT&&f.radialAxis.domain?f.radialAxis.domain:b).range([0,x]),u.layout.radialAxis.domain=r.domain();var k,M=o.util.flattenArray(h.map(function(t,e){return t.t})),A="string"==typeof M[0];A&&(M=o.util.deduplicate(M),k=M.slice(),M=a.range(M.length),h=h.map(function(t,e){var n=t;return t.t=[M],p&&(n.yStack=t.yStack),n}));var T=h.filter(function(t,e){return"LinePlot"===t.geometry||"DotPlot"===t.geometry}).length===h.length,L=null===f.needsEndSpacing?A||!T:f.needsEndSpacing,z=f.angularAxis.domain&&f.angularAxis.domain!=o.DATAEXTENT&&!A&&f.angularAxis.domain[0]>=0,S=z?f.angularAxis.domain:a.extent(M),C=Math.abs(M[1]-M[0]);T&&!A&&(C=0);var E=S.slice();L&&A&&(E[1]+=C);var N=f.angularAxis.ticksCount||4;N>8&&(N=N/(N/8)+N%8),f.angularAxis.ticksStep&&(N=(E[1]-E[0])/N);var O=f.angularAxis.ticksStep||(E[1]-E[0])/(N*(f.minorTicks+1));k&&(O=Math.max(Math.round(O),1)),E[2]||(E[2]=O);var P=a.range.apply(this,E);if(P=P.map(function(t,e){return parseFloat(t.toPrecision(12))}),l=a.scale.linear().domain(E.slice(0,2)).range("clockwise"===f.direction?[0,360]:[360,0]),u.layout.angularAxis.domain=l.domain(),u.layout.angularAxis.endPadding=L?C:0,e=a.select(this).select("svg.chart-root"),"undefined"==typeof e||e.empty()){var j="' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '",D=(new DOMParser).parseFromString(j,"application/xml"),R=this.appendChild(this.ownerDocument.importNode(D.documentElement,!0));e=a.select(R)}e.select(".guides-group").style({"pointer-events":"none"}),e.select(".angular.axis-group").style({"pointer-events":"none"}),e.select(".radial.axis-group").style({"pointer-events":"none"});var I,F=e.select(".chart-group"),q={fill:"none",stroke:f.tickColor},B={"font-size":f.font.size,"font-family":f.font.family,fill:f.font.color,"text-shadow":["-1px 0px","1px -1px","-1px 1px","1px 1px"].map(function(t,e){return" "+t+" 0 "+f.font.outlineColor}).join(",")};if(f.showLegend){I=e.select(".legend-group").attr({transform:"translate("+[x,f.margin.top]+")"}).style({display:"block"});var H=h.map(function(t,e){var n=o.util.cloneJson(t);return n.symbol="DotPlot"===t.geometry?t.dotType||"circle":"LinePlot"!=t.geometry?"square":"line",n.visibleInLegend="undefined"==typeof t.visibleInLegend||t.visibleInLegend,n.color="LinePlot"===t.geometry?t.strokeColor:t.color,n});o.Legend().config({data:h.map(function(t,e){return t.name||"Element"+e}),legendConfig:i({},o.Legend.defaultConfig().legendConfig,{container:I,elements:H,reverseOrder:f.legend.reverseOrder})})();var V=I.node().getBBox();x=Math.min(f.width-V.width-f.margin.left-f.margin.right,f.height-f.margin.top-f.margin.bottom)/2,x=Math.max(10,x),_=[f.margin.left+x,f.margin.top+x],r.range([0,x]),u.layout.radialAxis.domain=r.domain(),I.attr("transform","translate("+[_[0]+x,_[1]-x]+")")}else I=e.select(".legend-group").style({display:"none"});e.attr({width:f.width,height:f.height}).style({opacity:f.opacity}),F.attr("transform","translate("+_+")").style({cursor:"crosshair"});var U=[(f.width-(f.margin.left+f.margin.right+2*x+(V?V.width:0)))/2,(f.height-(f.margin.top+f.margin.bottom+2*x))/2];if(U[0]=Math.max(0,U[0]),U[1]=Math.max(0,U[1]),e.select(".outer-group").attr("transform","translate("+U+")"),f.title){var G=e.select("g.title-group text").style(B).text(f.title),Z=G.node().getBBox();G.attr({x:_[0]-Z.width/2,y:_[1]-x-20})}var Y=e.select(".radial.axis-group");if(f.radialAxis.gridLinesVisible){var X=Y.selectAll("circle.grid-circle").data(r.ticks(5));X.enter().append("circle").attr({class:"grid-circle"}).style(q),X.attr("r",r),X.exit().remove()}Y.select("circle.outside-circle").attr({r:x}).style(q);var Q=e.select("circle.background-circle").attr({r:x}).style({fill:f.backgroundColor,stroke:f.stroke});if(f.radialAxis.visible){var $=a.svg.axis().scale(r).ticks(5).tickSize(5);Y.call($).attr({transform:"rotate("+f.radialAxis.orientation+")"}),Y.selectAll(".domain").style(q),Y.selectAll("g>text").text(function(t,e){return this.textContent+f.radialAxis.ticksSuffix}).style(B).style({"text-anchor":"start"}).attr({x:0,y:0,dx:0,dy:0,transform:function(t,e){return"horizontal"===f.radialAxis.tickOrientation?"rotate("+-f.radialAxis.orientation+") translate("+[0,B["font-size"]]+")":"translate("+[0,B["font-size"]]+")"}}),Y.selectAll("g>line").style({stroke:"black"})}var W=e.select(".angular.axis-group").selectAll("g.angular-tick").data(P),J=W.enter().append("g").classed("angular-tick",!0);W.attr({transform:function(t,e){return"rotate("+s(t,e)+")"}}).style({display:f.angularAxis.visible?"block":"none"}),W.exit().remove(),J.append("line").classed("grid-line",!0).classed("major",function(t,e){return e%(f.minorTicks+1)==0}).classed("minor",function(t,e){return!(e%(f.minorTicks+1)==0)}).style(q),J.selectAll(".minor").style({stroke:f.minorTickColor}),W.select("line.grid-line").attr({x1:f.tickLength?x-f.tickLength:0,x2:x}).style({display:f.angularAxis.gridLinesVisible?"block":"none"}),J.append("text").classed("axis-text",!0).style(B);var K=W.select("text.axis-text").attr({x:x+f.labelOffset,dy:".35em",transform:function(t,e){var n=s(t,e),r=x+f.labelOffset,a=f.angularAxis.tickOrientation;return"horizontal"==a?"rotate("+-n+" "+r+" 0)":"radial"==a?n<270&&n>90?"rotate(180 "+r+" 0)":null:"rotate("+(n<=180&&n>0?-90:90)+" "+r+" 0)"}}).style({"text-anchor":"middle",display:f.angularAxis.labelsVisible?"block":"none"}).text(function(t,e){return e%(f.minorTicks+1)!=0?"":k?k[t]+f.angularAxis.ticksSuffix:t+f.angularAxis.ticksSuffix}).style(B);f.angularAxis.rewriteTicks&&K.text(function(t,e){return e%(f.minorTicks+1)!=0?"":f.angularAxis.rewriteTicks(this.textContent,e)});var tt=a.max(F.selectAll(".angular-tick text")[0].map(function(t,e){return t.getCTM().e+t.getBBox().width}));I.attr({transform:"translate("+[x+tt,f.margin.top]+")"});var et=e.select("g.geometry-group").selectAll("g").size()>0,nt=e.select("g.geometry-group").selectAll("g.geometry").data(h);if(nt.enter().append("g").attr({class:function(t,e){return"geometry geometry"+e}}),nt.exit().remove(),h[0]||et){var rt=[];h.forEach(function(t,e){var n={};n.radialScale=r,n.angularScale=l,n.container=nt.filter(function(t,n){return n==e}),n.geometry=t.geometry,n.orientation=f.orientation,n.direction=f.direction,n.index=e,rt.push({data:t,geometryConfig:n})});var at=a.nest().key(function(t,e){return"undefined"!=typeof t.data.groupId||"unstacked"}).entries(rt),ot=[];at.forEach(function(t,e){"unstacked"===t.key?ot=ot.concat(t.values.map(function(t,e){return[t]})):ot.push(t.values)}),ot.forEach(function(t,e){var n;n=Array.isArray(t)?t[0].geometryConfig.geometry:t.geometryConfig.geometry;var r=t.map(function(t,e){return i(o[n].defaultConfig(),t)});o[n]().config(r)()})}var it,lt,st=e.select(".guides-group"),ct=e.select(".tooltips-group"),ut=o.tooltipPanel().config({container:ct,fontSize:8})(),ft=o.tooltipPanel().config({container:ct,fontSize:8})(),dt=o.tooltipPanel().config({container:ct,hasTick:!0})();if(!A){var ht=st.select("line").attr({x1:0,y1:0,y2:0}).style({stroke:"grey","pointer-events":"none"});F.on("mousemove.angular-guide",function(t,e){var n=o.util.getMousePos(Q).angle;ht.attr({x2:-x,transform:"rotate("+n+")"}).style({opacity:.5});var r=(n+180+360-f.orientation)%360;it=l.invert(r);var a=o.util.convertToCartesian(x+12,n+180);ut.text(o.util.round(it)).move([a[0]+_[0],a[1]+_[1]])}).on("mouseout.angular-guide",function(t,e){st.select("line").style({opacity:0})})}var pt=st.select("circle").style({stroke:"grey",fill:"none"});F.on("mousemove.radial-guide",function(t,e){var n=o.util.getMousePos(Q).radius;pt.attr({r:n}).style({opacity:.5}),lt=r.invert(o.util.getMousePos(Q).radius);var a=o.util.convertToCartesian(n,f.radialAxis.orientation);ft.text(o.util.round(lt)).move([a[0]+_[0],a[1]+_[1]])}).on("mouseout.radial-guide",function(t,e){pt.style({opacity:0}),dt.hide(),ut.hide(),ft.hide()}),e.selectAll(".geometry-group .mark").on("mouseover.tooltip",function(t,n){var r=a.select(this),i=r.style("fill"),l="black",s=r.style("opacity")||1;if(r.attr({"data-opacity":s}),"none"!=i){r.attr({"data-fill":i}),l=a.hsl(i).darker().toString(),r.style({fill:l,opacity:1});var c={t:o.util.round(t[0]),r:o.util.round(t[1])};A&&(c.t=k[t[0]]);var u="t: "+c.t+", r: "+c.r,f=this.getBoundingClientRect(),d=e.node().getBoundingClientRect(),h=[f.left+f.width/2-U[0]-d.left,f.top+f.height/2-U[1]-d.top];dt.config({color:l}).text(u),dt.move(h)}else i=r.style("stroke"),r.attr({"data-stroke":i}),l=a.hsl(i).darker().toString(),r.style({stroke:l,opacity:1})}).on("mousemove.tooltip",function(t,e){return 0==a.event.which&&void(a.select(this).attr("data-fill")&&dt.show())}).on("mouseout.tooltip",function(t,e){dt.hide();var n=a.select(this),r=n.attr("data-fill");r?n.style({fill:r,opacity:n.attr("data-opacity")}):n.style({stroke:n.attr("data-stroke"),opacity:n.attr("data-opacity")})})}),d}var e,n,r,l,s={data:[],layout:{}},c={},u={},f=a.dispatch("hover"),d={};return d.render=function(e){return t(e),this},d.config=function(t){if(!arguments.length)return s;var e=o.util.cloneJson(t);return e.data.forEach(function(t,e){s.data[e]||(s.data[e]={}),i(s.data[e],o.Axis.defaultConfig().data[0]),i(s.data[e],t)}),i(s.layout,o.Axis.defaultConfig().layout),i(s.layout,e.layout),this},d.getLiveConfig=function(){return u},d.getinputConfig=function(){return c},d.radialScale=function(t){return r},d.angularScale=function(t){return l},d.svg=function(){return e},a.rebind(d,f,"on"),d},o.Axis.defaultConfig=function(t,e){var n={data:[{t:[1,2,3,4],r:[10,11,12,13],name:"Line1",geometry:"LinePlot",color:null,strokeDash:"solid",strokeColor:null,strokeSize:"1",visibleInLegend:!0,opacity:1}],layout:{defaultColorRange:a.scale.category10().range(),title:null,height:450,width:500,margin:{top:40,right:40,bottom:40,left:40},font:{size:12,color:"gray",outlineColor:"white",family:"Tahoma, sans-serif"},direction:"clockwise",orientation:0,labelOffset:10,radialAxis:{domain:null,orientation:-45,ticksSuffix:"",visible:!0,gridLinesVisible:!0,tickOrientation:"horizontal",rewriteTicks:null},angularAxis:{domain:[0,360],ticksSuffix:"",visible:!0,gridLinesVisible:!0,labelsVisible:!0,tickOrientation:"horizontal",rewriteTicks:null,ticksCount:null,ticksStep:null},minorTicks:0,tickLength:null,tickColor:"silver",minorTickColor:"#eee",backgroundColor:"none",needsEndSpacing:null,showLegend:!0,legend:{reverseOrder:!1},opacity:1}};return n},o.util={},o.DATAEXTENT="dataExtent",o.AREA="AreaChart",o.LINE="LinePlot",o.DOT="DotPlot",o.BAR="BarChart",o.util._override=function(t,e){for(var n in t)n in e&&(e[n]=t[n])},o.util._extend=function(t,e){for(var n in t)e[n]=t[n]},o.util._rndSnd=function(){return 2*Math.random()-1+(2*Math.random()-1)+(2*Math.random()-1)},o.util.dataFromEquation2=function(t,e){var n=e||6,r=a.range(0,360+n,n).map(function(e,n){var r=e*Math.PI/180,a=t(r);return[e,a]});return r},o.util.dataFromEquation=function(t,e,n){var r=e||6,o=[],i=[];a.range(0,360+r,r).forEach(function(e,n){var r=e*Math.PI/180,a=t(r);o.push(e),i.push(a)});var l={t:o,r:i};return n&&(l.name=n),l},o.util.ensureArray=function(t,e){if("undefined"==typeof t)return null;var n=[].concat(t);return a.range(e).map(function(t,e){return n[e]||n[0]})},o.util.fillArrays=function(t,e,n){return e.forEach(function(e,r){t[e]=o.util.ensureArray(t[e],n)}),t},o.util.cloneJson=function(t){return JSON.parse(JSON.stringify(t))},o.util.validateKeys=function(t,e){"string"==typeof e&&(e=e.split("."));var n=e.shift();return t[n]&&(!e.length||objHasKeys(t[n],e))},o.util.sumArrays=function(t,e){return a.zip(t,e).map(function(t,e){return a.sum(t)})},o.util.arrayLast=function(t){return t[t.length-1]},o.util.arrayEqual=function(t,e){for(var n=Math.max(t.length,e.length,1);n-- >=0&&t[n]===e[n];);return n===-2},o.util.flattenArray=function(t){for(var e=[];!o.util.arrayEqual(e,t);)e=t,t=[].concat.apply([],t);return t},o.util.deduplicate=function(t){return t.filter(function(t,e,n){return n.indexOf(t)==e})},o.util.convertToCartesian=function(t,e){var n=e*Math.PI/180,r=t*Math.cos(n),a=t*Math.sin(n);return[r,a]},o.util.round=function(t,e){var n=e||2,r=Math.pow(10,n);return Math.round(t*r)/r},o.util.getMousePos=function(t){var e=a.mouse(t.node()),n=e[0],r=e[1],o={};return o.x=n,o.y=r,o.pos=e,o.angle=180*(Math.atan2(r,n)+Math.PI)/Math.PI,o.radius=Math.sqrt(n*n+r*r),o},o.util.duplicatesCount=function(t){for(var e,n={},r={},a=0,o=t.length;a0)){var l=a.select(this.parentNode).selectAll("path.line").data([0]);l.enter().insert("path"),l.attr({class:"line",d:d(i),transform:function(e,n){return"rotate("+(t.orientation+90)+")"},"pointer-events":"none"}).style({fill:function(t,e){return v.fill(n,r,o)},"fill-opacity":0,stroke:function(t,e){return v.stroke(n,r,o)},"stroke-width":function(t,e){return v["stroke-width"](n,r,o)},"stroke-dasharray":function(t,e){return v["stroke-dasharray"](n,r,o)},opacity:function(t,e){return v.opacity(n,r,o)},display:function(t,e){return v.display(n,r,o)}})}};var h=t.angularScale.range(),p=Math.abs(h[1]-h[0])/s[0].length*Math.PI/180,g=a.svg.arc().startAngle(function(t){return-p/2}).endAngle(function(t){return p/2}).innerRadius(function(e){return t.radialScale(u+(e[2]||0))}).outerRadius(function(e){return t.radialScale(u+(e[2]||0))+t.radialScale(e[1])});f.arc=function(e,n,r){a.select(this).attr({class:"mark arc",d:g,transform:function(e,n){return"rotate("+(t.orientation+c(e[0])+90)+")"}})};var v={fill:function(t,n,r){return e[r].data.color},stroke:function(t,n,r){return e[r].data.strokeColor},"stroke-width":function(t,n,r){return e[r].data.strokeSize+"px"},"stroke-dasharray":function(t,n,r){return l[e[r].data.strokeDash]},opacity:function(t,n,r){return e[r].data.opacity},display:function(t,n,r){return"undefined"==typeof e[r].data.visible||e[r].data.visible?"block":"none"}},m=a.select(this).selectAll("g.layer").data(s);m.enter().append("g").attr({class:"layer"});var y=m.selectAll("path.mark").data(function(t,e){return t});y.enter().append("path").attr({class:"mark"}),y.style(v).each(f[t.geometryType]),y.exit().remove(),m.exit().remove()})}var e,n=[o.PolyChart.defaultConfig()],r=a.dispatch("hover"),l={solid:"none",dash:[5,2],dot:[2,5]};return t.config=function(t){return arguments.length?(t.forEach(function(t,e){n[e]||(n[e]={}),i(n[e],o.PolyChart.defaultConfig()),i(n[e],t)}),this):n},t.getColorScale=function(){return e},a.rebind(t,r,"on"),t},o.PolyChart.defaultConfig=function(){var t={data:{name:"geom1",t:[[1,2,3,4]],r:[[1,2,3,4]],dotType:"circle",dotSize:64,dotVisible:!1,barWidth:20,color:"#ffa500",strokeSize:1,strokeColor:"silver",strokeDash:"solid",opacity:1,index:0,visible:!0,visibleInLegend:!0},geometryConfig:{geometry:"LinePlot",geometryType:"arc",direction:"clockwise",orientation:0,container:"body",radialScale:null,angularScale:null,colorScale:a.scale.category20()}};return t},o.BarChart=function(){return o.PolyChart()},o.BarChart.defaultConfig=function(){var t={geometryConfig:{geometryType:"bar"}};return t},o.AreaChart=function(){return o.PolyChart()},o.AreaChart.defaultConfig=function(){var t={geometryConfig:{geometryType:"arc"}};return t},o.DotPlot=function(){return o.PolyChart()}, ++o.DotPlot.defaultConfig=function(){var t={geometryConfig:{geometryType:"dot",dotType:"circle"}};return t},o.LinePlot=function(){return o.PolyChart()},o.LinePlot.defaultConfig=function(){var t={geometryConfig:{geometryType:"line"}};return t},o.Legend=function(){function t(){var n=e.legendConfig,r=e.data.map(function(t,e){return[].concat(t).map(function(t,r){var a=i({},n.elements[e]);return a.name=t,a.color=[].concat(n.elements[e].color)[r],a})}),o=a.merge(r);o=o.filter(function(t,e){return n.elements[e]&&(n.elements[e].visibleInLegend||"undefined"==typeof n.elements[e].visibleInLegend)}),n.reverseOrder&&(o=o.reverse());var l=n.container;("string"==typeof l||l.nodeName)&&(l=a.select(l));var s=o.map(function(t,e){return t.color}),c=n.fontSize,u=null==n.isContinuous?"number"==typeof o[0]:n.isContinuous,f=u?n.height:c*o.length,d=l.classed("legend-group",!0),h=d.selectAll("svg").data([0]),p=h.enter().append("svg").attr({width:300,height:f+c,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"});p.append("g").classed("legend-axis",!0),p.append("g").classed("legend-marks",!0);var g=a.range(o.length),v=a.scale[u?"linear":"ordinal"]().domain(g).range(s),m=a.scale[u?"linear":"ordinal"]().domain(g)[u?"range":"rangePoints"]([0,f]),y=function(t,e){var n=3*e;return"line"===t?"M"+[[-e/2,-e/12],[e/2,-e/12],[e/2,e/12],[-e/2,e/12]]+"Z":a.svg.symbolTypes.indexOf(t)!=-1?a.svg.symbol().type(t).size(n)():a.svg.symbol().type("square").size(n)()};if(u){var x=h.select(".legend-marks").append("defs").append("linearGradient").attr({id:"grad1",x1:"0%",y1:"0%",x2:"0%",y2:"100%"}).selectAll("stop").data(s);x.enter().append("stop"),x.attr({offset:function(t,e){return e/(s.length-1)*100+"%"}}).style({"stop-color":function(t,e){return t}}),h.append("rect").classed("legend-mark",!0).attr({height:n.height,width:n.colorBandWidth,fill:"url(#grad1)"})}else{var b=h.select(".legend-marks").selectAll("path.legend-mark").data(o);b.enter().append("path").classed("legend-mark",!0),b.attr({transform:function(t,e){return"translate("+[c/2,m(e)+c/2]+")"},d:function(t,e){var n=t.symbol;return y(n,c)},fill:function(t,e){return v(e)}}),b.exit().remove()}var _=a.svg.axis().scale(m).orient("right"),w=h.select("g.legend-axis").attr({transform:"translate("+[u?n.colorBandWidth:c,c/2]+")"}).call(_);return w.selectAll(".domain").style({fill:"none",stroke:"none"}),w.selectAll("line").style({fill:"none",stroke:u?n.textColor:"none"}),w.selectAll("text").style({fill:n.textColor,"font-size":n.fontSize}).text(function(t,e){return o[e].name}),t}var e=o.Legend.defaultConfig(),n=a.dispatch("hover");return t.config=function(t){return arguments.length?(i(e,t),this):e},a.rebind(t,n,"on"),t},o.Legend.defaultConfig=function(t,e){var n={data:["a","b","c"],legendConfig:{elements:[{symbol:"line",color:"red"},{symbol:"square",color:"yellow"},{symbol:"diamond",color:"limegreen"}],height:150,colorBandWidth:30,fontSize:12,container:"body",isContinuous:null,textColor:"grey",reverseOrder:!1}};return n},o.tooltipPanel=function(){var t,e,n,r={container:null,hasTick:!1,fontSize:12,color:"white",padding:5},l="tooltip-"+o.tooltipPanel.uid++,s=10,c=function(){t=r.container.selectAll("g."+l).data([0]);var a=t.enter().append("g").classed(l,!0).style({"pointer-events":"none",display:"none"});return n=a.append("path").style({fill:"white","fill-opacity":.9}).attr({d:"M0 0"}),e=a.append("text").attr({dx:r.padding+s,dy:.3*+r.fontSize}),c};return c.text=function(o){var i=a.hsl(r.color).l,l=i>=.5?"#aaa":"white",u=i>=.5?"black":"white",f=o||"";e.style({fill:u,"font-size":r.fontSize+"px"}).text(f);var d=r.padding,h=e.node().getBBox(),p={fill:r.color,stroke:l,"stroke-width":"2px"},g=h.width+2*d+s,v=h.height+2*d;return n.attr({d:"M"+[[s,-v/2],[s,-v/4],[r.hasTick?0:s,0],[s,v/4],[s,v/2],[g,v/2],[g,-v/2]].join("L")+"Z"}).style(p),t.attr({transform:"translate("+[s,-v/2+2*d]+")"}),t.style({display:"block"}),c},c.move=function(e){if(t)return t.attr({transform:"translate("+[e[0],e[1]]+")"}).style({display:"block"}),c},c.hide=function(){if(t)return t.style({display:"none"}),c},c.show=function(){if(t)return t.style({display:"block"}),c},c.config=function(t){return i(r,t),c},c},o.tooltipPanel.uid=1,o.adapter={},o.adapter.plotly=function(){var t={};return t.convert=function(t,e){var n={};if(t.data&&(n.data=t.data.map(function(t,n){var r=i({},t),a=[[r,["marker","color"],["color"]],[r,["marker","opacity"],["opacity"]],[r,["marker","line","color"],["strokeColor"]],[r,["marker","line","dash"],["strokeDash"]],[r,["marker","line","width"],["strokeSize"]],[r,["marker","symbol"],["dotType"]],[r,["marker","size"],["dotSize"]],[r,["marker","barWidth"],["barWidth"]],[r,["line","interpolation"],["lineInterpolation"]],[r,["showlegend"],["visibleInLegend"]]];return a.forEach(function(t,n){o.util.translator.apply(null,t.concat(e))}),e||delete r.marker,e&&delete r.groupId,e?("LinePlot"===r.geometry?(r.type="scatter",r.dotVisible===!0?(delete r.dotVisible,r.mode="lines+markers"):r.mode="lines"):"DotPlot"===r.geometry?(r.type="scatter",r.mode="markers"):"AreaChart"===r.geometry?r.type="area":"BarChart"===r.geometry&&(r.type="bar"),delete r.geometry):("scatter"===r.type?"lines"===r.mode?r.geometry="LinePlot":"markers"===r.mode?r.geometry="DotPlot":"lines+markers"===r.mode&&(r.geometry="LinePlot",r.dotVisible=!0):"area"===r.type?r.geometry="AreaChart":"bar"===r.type&&(r.geometry="BarChart"),delete r.mode,delete r.type),r}),!e&&t.layout&&"stack"===t.layout.barmode)){var r=o.util.duplicates(n.data.map(function(t,e){return t.geometry}));n.data.forEach(function(t,e){var a=r.indexOf(t.geometry);a!=-1&&(n.data[e].groupId=a)})}if(t.layout){var l=i({},t.layout),s=[[l,["plot_bgcolor"],["backgroundColor"]],[l,["showlegend"],["showLegend"]],[l,["radialaxis"],["radialAxis"]],[l,["angularaxis"],["angularAxis"]],[l.angularaxis,["showline"],["gridLinesVisible"]],[l.angularaxis,["showticklabels"],["labelsVisible"]],[l.angularaxis,["nticks"],["ticksCount"]],[l.angularaxis,["tickorientation"],["tickOrientation"]],[l.angularaxis,["ticksuffix"],["ticksSuffix"]],[l.angularaxis,["range"],["domain"]],[l.angularaxis,["endpadding"],["endPadding"]],[l.radialaxis,["showline"],["gridLinesVisible"]],[l.radialaxis,["tickorientation"],["tickOrientation"]],[l.radialaxis,["ticksuffix"],["ticksSuffix"]],[l.radialaxis,["range"],["domain"]],[l.angularAxis,["showline"],["gridLinesVisible"]],[l.angularAxis,["showticklabels"],["labelsVisible"]],[l.angularAxis,["nticks"],["ticksCount"]],[l.angularAxis,["tickorientation"],["tickOrientation"]],[l.angularAxis,["ticksuffix"],["ticksSuffix"]],[l.angularAxis,["range"],["domain"]],[l.angularAxis,["endpadding"],["endPadding"]],[l.radialAxis,["showline"],["gridLinesVisible"]],[l.radialAxis,["tickorientation"],["tickOrientation"]],[l.radialAxis,["ticksuffix"],["ticksSuffix"]],[l.radialAxis,["range"],["domain"]],[l.font,["outlinecolor"],["outlineColor"]],[l.legend,["traceorder"],["reverseOrder"]],[l,["labeloffset"],["labelOffset"]],[l,["defaultcolorrange"],["defaultColorRange"]]];if(s.forEach(function(t,n){o.util.translator.apply(null,t.concat(e))}),e?("undefined"!=typeof l.tickLength&&(l.angularaxis.ticklen=l.tickLength,delete l.tickLength),l.tickColor&&(l.angularaxis.tickcolor=l.tickColor,delete l.tickColor)):(l.angularAxis&&"undefined"!=typeof l.angularAxis.ticklen&&(l.tickLength=l.angularAxis.ticklen),l.angularAxis&&"undefined"!=typeof l.angularAxis.tickcolor&&(l.tickColor=l.angularAxis.tickcolor)),l.legend&&"boolean"!=typeof l.legend.reverseOrder&&(l.legend.reverseOrder="normal"!=l.legend.reverseOrder),l.legend&&"boolean"==typeof l.legend.traceorder&&(l.legend.traceorder=l.legend.traceorder?"reversed":"normal",delete l.legend.reverseOrder),l.margin&&"undefined"!=typeof l.margin.t){var c=["t","r","b","l","pad"],u=["top","right","bottom","left","pad"],f={};a.entries(l.margin).forEach(function(t,e){f[u[c.indexOf(t.key)]]=t.value}),l.margin=f}e&&(delete l.needsEndSpacing,delete l.minorTickColor,delete l.minorTicks,delete l.angularaxis.ticksCount,delete l.angularaxis.ticksCount,delete l.angularaxis.ticksStep,delete l.angularaxis.rewriteTicks,delete l.angularaxis.nticks,delete l.radialaxis.ticksCount,delete l.radialaxis.ticksCount,delete l.radialaxis.ticksStep,delete l.radialaxis.rewriteTicks,delete l.radialaxis.nticks),n.layout=l}return n},t}},{"../../plotly":118,"./micropolar_manager":157,d3:8}],157:[function(t,e,n){"use strict";var r=t("../../plotly"),a=t("d3"),o=t("./undo_manager"),i=e.exports={},l=r.Lib.extendDeepAll;i.framework=function(t){function e(e,o){return o&&(f=o),a.select(a.select(f).node().parentNode).selectAll(".svg-container>*:not(.chart-root)").remove(),n=n?l(n,e):e,c||(c=r.micropolar.Axis()),u=r.micropolar.adapter.plotly().convert(n),c.config(u).render(f),t.data=n.data,t.layout=n.layout,i.fillLayout(t),n}var n,s,c,u,f,d=new o;return e.isPolar=!0,e.svg=function(){return c.svg()},e.getConfig=function(){return n},e.getLiveConfig=function(){return r.micropolar.adapter.plotly().convert(c.getLiveConfig(),!0)},e.getLiveScales=function(){return{t:c.angularScale(),r:c.radialScale()}},e.setUndoPoint=function(){var t=this,e=r.micropolar.util.cloneJson(n);!function(e,n){d.add({undo:function(){n&&t(n)},redo:function(){t(e)}})}(e,s),s=r.micropolar.util.cloneJson(e)},e.undo=function(){d.undo()},e.redo=function(){d.redo()},e},i.fillLayout=function(t){var e=a.select(t).selectAll(".plot-container"),n=e.selectAll(".svg-container"),o=t.framework&&t.framework.svg&&t.framework.svg(),i={width:800,height:600,paper_bgcolor:r.Color.background,_container:e,_paperdiv:n,_paper:o};t._fullLayout=l(i,t.layout)}},{"../../plotly":118,"./undo_manager":158,d3:8}],158:[function(t,e,n){"use strict";e.exports=function(){function t(t,e){return t?(a=!0,t[e](),a=!1,this):this}var e,n=[],r=-1,a=!1;return{add:function(t){return a?this:(n.splice(r+1,n.length-r),n.push(t),r=n.length-1,this)},setCallback:function(t){e=t},undo:function(){var a=n[r];return a?(t(a,"undo"),r-=1,e&&e(a.undo),this):this},redo:function(){var a=n[r+1];return a?(t(a,"redo"),r+=1,e&&e(a.redo),this):this},clear:function(){n=[],r=-1},hasUndo:function(){return r!==-1},hasRedo:function(){return r-1}var o=t("../plotly"),i=o.Lib.extendFlat,l=o.Lib.extendDeep;e.exports=function(t,e){t.framework&&t.framework.isPolar&&(t=t.framework.getConfig());var n,s=t.data,c=t.layout,u=l([],s),f=l({},c,r(e.tileClass));if(e.width&&(f.width=e.width),e.height&&(f.height=e.height),"thumbnail"===e.tileClass||"themes__thumb"===e.tileClass){f.annotations=[];var d=Object.keys(f);for(n=0;ns&&(e.z=u.slice(0,s)),l("locationmode"),l("text"),l("marker.line.color"),l("marker.line.width"),a(t,e,i,l,{prefix:"",cLetter:"z"}),void l("hoverinfo",1===i._dataLength?"location+z+text":void 0)):void(e.visible=!1)}},{"../../components/colorscale/defaults":30,"../../lib":99,"./attributes":167}],170:[function(t,e,n){"use strict";var r={};r.attributes=t("./attributes"),r.supplyDefaults=t("./defaults"),r.colorbar=t("../heatmap/colorbar"),r.calc=t("./calc"),r.plot=t("./plot").plot,r.moduleType="trace",r.name="choropleth",r.basePlotModule=t("../../plots/geo"),r.categories=["geo","noOpacity"],r.meta={},e.exports=r},{"../../plots/geo":142,"../heatmap/colorbar":172,"./attributes":167,"./calc":168,"./defaults":169,"./plot":171}],171:[function(t,e,n){"use strict";function r(t,e){function n(e){var n=t.mockAxis;return i.tickText(n,n.c2l(e),"hover").text}var r=e.hoverinfo;if("none"===r)return function(t){delete t.nameLabel,delete t.textLabel};var a="all"===r?v.hoverinfo.flags:r.split("+"),o=a.indexOf("name")!==-1,l=a.indexOf("location")!==-1,s=a.indexOf("z")!==-1,c=a.indexOf("text")!==-1,u=!o&&l;return function(t){var r=[];u?t.nameLabel=t.id:(o&&(t.nameLabel=e.name),l&&r.push(t.id)),s&&r.push(n(t.z)),c&&r.push(t.tx),t.textLabel=r.join("
")}}function a(t){return function(e,n){return{points:[{data:t._input,fullData:t,curveNumber:t.index,pointNumber:n,location:e.id,z:e.z}]}}}var o=t("d3"),i=t("../../plots/cartesian/axes"),l=t("../../plots/cartesian/graph_interact"),s=t("../../components/color"),c=t("../../components/drawing"),u=t("../../components/colorscale/get_scale"),f=t("../../components/colorscale/make_scale_function"),d=t("../../lib/topojson_utils").getTopojsonFeatures,h=t("../../lib/geo_location_utils").locationToFeature,p=t("../../lib/array_to_calc_item"),g=t("../../plots/geo/constants"),v=t("./attributes"),m=e.exports={};m.calcGeoJSON=function(t,e){for(var n,r=[],a=t.locations,o=a.length,i=d(t,e),l=(t.marker||{}).line||{},s=0;s0&&(r[0].trace=t),r},m.plot=function(t,e,n){var i,s=t.framework,c=s.select("g.choroplethlayer"),u=s.select("g.baselayer"),f=s.select("g.baselayeroverchoropleth"),d=g.baseLayersOverChoropleth,h=c.selectAll("g.trace.choropleth").data(e,function(t){return t.uid});h.enter().append("g").attr("class","trace choropleth"),h.exit().remove(),h.each(function(e){function n(e,n){if(t.showHover){var r=t.projection(e.properties.ct);c(e),l.loneHover({x:r[0],y:r[1],name:e.nameLabel,text:e.textLabel},{container:t.hoverContainer.node()}),f=u(e,n),t.graphDiv.emit("plotly_hover",f)}}function i(e,n){t.graphDiv.emit("plotly_click",u(e,n))}var s=m.calcGeoJSON(e,t.topojson),c=r(t,e),u=a(e),f=null,d=o.select(this).selectAll("path.choroplethlocation").data(s);d.enter().append("path").classed("choroplethlocation",!0).on("mouseover",n).on("click",i).on("mouseout",function(){l.loneUnhover(t.hoverContainer),t.graphDiv.emit("plotly_unhover",f)}).on("mousedown",function(){l.loneUnhover(t.hoverContainer)}).on("mouseup",n),d.exit().remove()}),f.selectAll("*").remove();for(var p=0;pp&&d.splice(p,d.length-p),h.length>p&&h.splice(p,h.length-p);var g={padded:!0},v={padded:!0};if(i.hasMarkers(e)){if(n=e.marker,s=n.size,Array.isArray(s)){var m={type:"linear"};a.setConvert(m),s=m.makeCalcdata(e.marker,"size"),s.length>p&&s.splice(p,s.length-p)}var y,x=1.6*(e.marker.sizeref||1);y="area"===e.marker.sizemode?function(t){return Math.max(Math.sqrt((t||0)/x),3)}:function(t){return Math.max((t||0)/x,3)},g.ppad=v.ppad=Array.isArray(s)?s.map(y):y(s)}l(e),!("tozerox"===e.fill||"tonextx"===e.fill&&t.firstscatter)||d[0]===d[p-1]&&h[0]===h[p-1]?e.error_y.visible||["tonexty","tozeroy"].indexOf(e.fill)===-1&&(i.hasMarkers(e)||i.hasText(e))||(g.padded=!1,g.ppad=0):g.tozero=!0,!("tozeroy"===e.fill||"tonexty"===e.fill&&t.firstscatter)||d[0]===d[p-1]&&h[0]===h[p-1]?["tonextx","tozerox"].indexOf(e.fill)!==-1&&(v.padded=!1):v.tozero=!0,a.expand(u,d,g),a.expand(f,h,v);var b=new Array(p);for(c=0;c=0;a--)if(o=t[a],"scatter"===o.type&&o.xaxis===n.xaxis&&o.yaxis===n.yaxis){o.opacity=void 0;break}}},{}],178:[function(t,e,n){"use strict";var r=t("d3"),a=t("fast-isnumeric"),o=t("../../lib"),i=t("../../plots/plots"),l=t("../../components/colorscale/get_scale"),s=t("../../components/colorbar/draw");e.exports=function(t,e){var n=e[0].trace,c=n.marker,u="cb"+n.uid;if(t._fullLayout._infolayer.selectAll("."+u).remove(),void 0===c||!c.showscale)return void i.autoMargin(t,u);var f=l(c.colorscale),d=c.color,h=c.cmin,p=c.cmax;a(h)||(h=o.aggNums(Math.min,null,d)),a(p)||(p=o.aggNums(Math.max,null,d));var g=e[0].t.cb=s(t,u);g.fillcolor(r.scale.linear().domain(f.map(function(t){return h+t[0]*(p-h)})).range(f.map(function(t){return t[1]}))).filllevels({start:h,end:p,size:(p-h)/254}).options(c.colorbar)()}},{"../../components/colorbar/draw":23,"../../components/colorscale/get_scale":32,"../../lib":99,"../../plots/plots":153,d3:8,"fast-isnumeric":11}],179:[function(t,e,n){"use strict";var r=t("../../components/colorscale/has_colorscale"),a=t("../../components/colorscale/calc"),o=t("./subtypes");e.exports=function(t){o.hasLines(t)&&r(t,"line")&&a(t,t.line.color,"line","c"),o.hasMarkers(t)&&(r(t,"marker")&&a(t,t.marker.color,"marker","c"),r(t,"marker.line")&&a(t,t.marker.line.color,"marker.line","c"))}},{"../../components/colorscale/calc":27,"../../components/colorscale/has_colorscale":33,"./subtypes":194}],180:[function(t,e,n){"use strict";e.exports={PTS_LINESONLY:20}},{}],181:[function(t,e,n){"use strict";var r=t("../../lib"),a=t("./attributes"),o=t("./constants"),i=t("./subtypes"),l=t("./xy_defaults"),s=t("./marker_defaults"),c=t("./line_defaults"),u=t("./line_shape_defaults"),f=t("./text_defaults"),d=t("./fillcolor_defaults"),h=t("../../components/errorbars/defaults");e.exports=function(t,e,n,p){function g(n,o){return r.coerce(t,e,a,n,o)}var v=l(t,e,g),m=vB!=O>=B&&(C=z[T-1][0],E=z[T][0],S=C+(E-C)*(B-N)/(O-N),R=Math.min(R,S),I=Math.max(I,S));R=Math.max(R,0),I=Math.min(I,d._length);var H=s.defaultLine;return s.opacity(f.fillcolor)?H=f.fillcolor:s.opacity((f.line||{}).color)&&(H=f.line.color),r.extendFlat(t,{distance:o.MAXDIST+10,x0:R,x1:I,y0:B,y1:B,color:H}),delete t.index,f.text&&!Array.isArray(f.text)?t.text=String(f.text):t.text=f.name,[t]}}}},{"../../components/color":20,"../../components/errorbars":49,"../../lib":99,"../../plots/cartesian/constants":126,"../../plots/cartesian/graph_interact":128,"./get_trace_color":183}],185:[function(t,e,n){"use strict";var r={},a=t("./subtypes");r.hasLines=a.hasLines,r.hasMarkers=a.hasMarkers,r.hasText=a.hasText,r.isBubble=a.isBubble,r.attributes=t("./attributes"),r.supplyDefaults=t("./defaults"),r.cleanData=t("./clean_data"),r.calc=t("./calc"),r.arraysToCalcdata=t("./arrays_to_calcdata"),r.plot=t("./plot"),r.colorbar=t("./colorbar"),r.style=t("./style"),r.hoverPoints=t("./hover"),r.selectPoints=t("./select"),r.moduleType="trace",r.name="scatter",r.basePlotModule=t("../../plots/cartesian"),r.categories=["cartesian","symbols","markerColorscale","errorBarsOK","showLegend"],r.meta={},e.exports=r},{"../../plots/cartesian":129,"./arrays_to_calcdata":174,"./attributes":175,"./calc":176,"./clean_data":177,"./colorbar":178,"./defaults":181,"./hover":184,"./plot":191,"./select":192,"./style":193,"./subtypes":194}],186:[function(t,e,n){"use strict";var r=t("../../components/colorscale/has_colorscale"),a=t("../../components/colorscale/defaults");e.exports=function(t,e,n,o,i){var l=(t.marker||{}).color;if(i("line.color",n),r(t,"line"))a(t,e,o,i,{prefix:"line.",cLetter:"c"});else{var s=!Array.isArray(l)&&l||n;i("line.color",s)}i("line.width"),i("line.dash")}},{"../../components/colorscale/defaults":30,"../../components/colorscale/has_colorscale":33}],187:[function(t,e,n){"use strict";var r=t("../../plots/cartesian/axes");e.exports=function(t,e){function n(e){var n=w.c2p(t[e].x),r=k.c2p(t[e].y);return n!==z&&r!==z&&[n,r]}function a(t){var e=t[0]/w._length,n=t[1]/k._length;return(1+10*Math.max(0,-e,e-1,-n,n-1))*A}function o(t,e){var n=t[0]-e[0],r=t[1]-e[1];return Math.sqrt(n*n+r*r)}var i,l,s,c,u,f,d,h,p,g,v,m,y,x,b,_,w=e.xaxis,k=e.yaxis,M=e.connectGaps,A=e.baseTolerance,T=e.linear,L=[],z=r.BADNUM,S=.2,C=new Array(t.length),E=0;for(i=0;ia(f))break;s=f,y=g[0]*p[0]+g[1]*p[1],y>v?(v=y,c=f,h=!1):y=t.length||!f)break;C[E++]=f,l=f}}else C[E++]=c}L.push(C.slice(0,E))}return L}},{"../../plots/cartesian/axes":121}],188:[function(t,e,n){"use strict";e.exports=function(t,e,n){var r=n("line.shape");"spline"===r&&n("line.smoothing")}},{}],189:[function(t,e,n){"use strict";var r=t("fast-isnumeric");e.exports=function(t){var e=t.marker,n=e.sizeref||1,a=e.sizemin||0,o="area"===e.sizemode?function(t){return Math.sqrt(t/n)}:function(t){return t/n};return function(t){var e=o(t/2);return r(e)&&e>0?Math.max(e,a):0}}},{"fast-isnumeric":11}],190:[function(t,e,n){"use strict";var r=t("../../components/color"),a=t("../../components/colorscale/has_colorscale"),o=t("../../components/colorscale/defaults"),i=t("./subtypes");e.exports=function(t,e,n,l,s){var c,u=i.isBubble(t),f=(t.line||{}).color;f&&(n=f),s("marker.symbol"),s("marker.opacity",u?.7:1),s("marker.size"),s("marker.color",n),a(t,"marker")&&o(t,e,l,s,{prefix:"marker.",cLetter:"c"}),c=f&&!Array.isArray(f)&&e.marker.color!==f?f:u?r.background:r.defaultLine,s("marker.line.color",c),a(t,"marker.line")&&o(t,e,l,s,{prefix:"marker.line.",cLetter:"c"}),s("marker.line.width",u?1:0),u&&(s("marker.sizeref"),s("marker.sizemin"),s("marker.sizemode"))}},{"../../components/color":20,"../../components/colorscale/defaults":30,"../../components/colorscale/has_colorscale":33,"./subtypes":194}],191:[function(t,e,n){"use strict";function r(t,e,n){var r=e.x(),o=e.y(),i=a.extent(r.range.map(r.l2c)),l=a.extent(o.range.map(o.l2c));n.forEach(function(t,e){var r=t[0].trace;if(c.hasMarkers(r)){var a=r.marker.maxdisplayed;if(0!==a){var o=t.filter(function(t){return t.x>=i[0]&&t.x<=i[1]&&t.y>=l[0]&&t.y<=l[1]}),s=Math.ceil(o.length/a),u=0;n.forEach(function(t,n){var r=t[0].trace;c.hasMarkers(r)&&r.marker.maxdisplayed>0&&n1&&r.append("path").classed("js-line",!0).style("vector-effect","non-scaling-stroke").attr("d",o)}v?z&&C&&(m?("y"===m?z[1]=C[1]=p.c2p(0,!0):"x"===m&&(z[0]=C[0]=h.c2p(0,!0)),v.attr("d",k+"L"+C+"L"+z+"Z")):v.attr("d",k+"Z")):"tonext"===e.fill.substr(0,6)&&k&&b&&("tonext"===e.fill?y.attr("d",k+"Z"+b+"Z"):y.attr("d",k+"L"+b.substr(1)+"Z"),e._polygons=e._polygons.concat(_)),b=M,_=L}}}),g.selectAll("path:not([d])").remove(),g.append("g").attr("class","points").each(function(t){var e=t[0].trace,n=a.select(this),r=c.hasMarkers(e),l=c.hasText(e);!r&&!l||e.visible!==!0?n.remove():(r&&n.selectAll("path.point").data(e.marker.maxdisplayed?d:o.identity).enter().append("path").classed("point",!0).call(i.translatePoints,h,p),l&&n.selectAll("g").data(e.marker.maxdisplayed?d:o.identity).enter().append("g").append("text").call(i.translatePoints,h,p))})}},{"../../components/drawing":43,"../../components/errorbars":49,"../../lib":99,"../../lib/polygon":105,"./arrays_to_calcdata":174,"./line_points":187,"./subtypes":194,d3:8}],192:[function(t,e,n){"use strict";var r=t("./subtypes"),a=.2;e.exports=function(t,e){var n,o,i,l,s=t.cd,c=t.xaxis,u=t.yaxis,f=[],d=s[0].trace,h=d.index,p=d.marker,g=!r.hasMarkers(d)&&!r.hasText(d);if(d.visible===!0&&!g){var v=Array.isArray(p.opacity)?1:p.opacity;if(e===!1)for(n=0;n")}}function i(t){var e=Array.isArray(t.locations);return function(n,r){return{points:[{data:t._input,fullData:t,curveNumber:t.index,pointNumber:r,lon:n.lon,lat:n.lat,location:e?n.location:null}]}}}var l=t("d3"),s=t("../../plots/cartesian/graph_interact"),c=t("../../plots/cartesian/axes"),u=t("../../lib/topojson_utils").getTopojsonFeatures,f=t("../../lib/geo_location_utils").locationToFeature,d=t("../../lib/array_to_calc_item"),h=t("../../components/color"),p=t("../../components/drawing"),g=t("../scatter/subtypes"),v=t("./attributes"),m=e.exports={};m.calcGeoJSON=function(t,e){var n,a,o,i,l=[],s=Array.isArray(t.locations);s?(i=t.locations,n=i.length,a=u(t,e),o=function(t,e){var n=f(t.locationmode,i[e],a);return void 0!==n?n.properties.ct:void 0}):(n=t.lon.length,o=function(t,e){return[t.lon[e],t.lat[e]]});for(var c=0;c0&&(l[0].trace=t),l},m.plot=function(t,e){var n=t.framework.select(".scattergeolayer").selectAll("g.trace.scattergeo").data(e,function(t){return t.uid});n.enter().append("g").attr("class","trace scattergeo"),n.exit().remove(),n.selectAll("*").remove(),n.each(function(t){var e=l.select(this);g.hasLines(t)&&e.selectAll("path.js-line").data([a(t)]).enter().append("path").classed("js-line",!0)}),n.each(function(e){function n(n,r){if(t.showHover){var a=t.projection([n.lon,n.lat]);d(n),s.loneHover({x:a[0],y:a[1],name:v?e.name:void 0,text:n.textLabel,color:n.mc||(e.marker||{}).color},{container:t.hoverContainer.node()}),y=h(n,r),t.graphDiv.emit("plotly_hover",y)}}function r(e,n){t.graphDiv.emit("plotly_click",h(e,n))}var a=l.select(this),c=g.hasMarkers(e),u=g.hasText(e);if(c||u){var f=m.calcGeoJSON(e,t.topojson),d=o(t,e),h=i(e),p=e.hoverinfo,v="all"===p||p.indexOf("name")!==-1,y=null;c&&a.selectAll("path.point").data(f).enter().append("path").classed("point",!0).on("mouseover",n).on("click",r).on("mouseout",function(){s.loneUnhover(t.hoverContainer),t.graphDiv.emit("plotly_unhover",y)}).on("mousedown",function(){s.loneUnhover(t.hoverContainer)}).on("mouseup",n),u&&a.selectAll("g").data(f).enter().append("g").append("text")}}),m.style(t)},m.style=function(t){var e=t.framework.selectAll("g.trace.scattergeo");e.style("opacity",function(t){return t.opacity}),e.each(function(t){l.select(this).selectAll("path.point").call(p.pointStyle,t),l.select(this).selectAll("text").call(p.textPointStyle,t)}),e.selectAll("path.js-line").style("fill","none").each(function(t){var e=t.trace,n=e.line||{};l.select(this).call(h.stroke,n.color).call(p.dashLine,n.dash||"",n.width||0)})}},{"../../components/color":20,"../../components/drawing":43,"../../lib/array_to_calc_item":92,"../../lib/geo_location_utils":98,"../../lib/topojson_utils":111,"../../plots/cartesian/axes":121,"../../plots/cartesian/graph_interact":128,"../scatter/subtypes":194,"./attributes":197,d3:8}]},{},[5])(5)}); +\ No newline at end of file +diff --git a/dist/plotly-gl2d.js b/dist/plotly-gl2d.js +index f190f77..4de4838 100644 +--- a/dist/plotly-gl2d.js ++++ b/dist/plotly-gl2d.js +@@ -254,6 +254,24 @@ module.exports = Plotly; + module.exports = require('../src/traces/scattergl'); + + },{"../src/traces/scattergl":367}],8:[function(require,module,exports){ ++var padLeft = require('pad-left') ++ ++module.exports = addLineNumbers ++function addLineNumbers (string, start, delim) { ++ start = typeof start === 'number' ? start : 1 ++ delim = delim || ': ' ++ ++ var lines = string.split(/\r?\n/) ++ var totalDigits = String(lines.length + start - 1).length ++ return lines.map(function (line, i) { ++ var c = i + start ++ var digits = String(c).length ++ var prefix = padLeft(c, totalDigits - digits) ++ return prefix + delim + line ++ }).join('\n') ++} ++ ++},{"pad-left":125}],9:[function(require,module,exports){ + 'use strict'; + + var arraytools = function () { +@@ -442,7 +460,381 @@ var arraytools = function () { + + module.exports = arraytools(); + +-},{}],9:[function(require,module,exports){ ++},{}],10:[function(require,module,exports){ ++module.exports = function _atob(str) { ++ return atob(str) ++} ++ ++},{}],11:[function(require,module,exports){ ++'use strict' ++ ++var rationalize = require('./lib/rationalize') ++ ++module.exports = add ++ ++function add(a, b) { ++ return rationalize( ++ a[0].mul(b[1]).add(b[0].mul(a[1])), ++ a[1].mul(b[1])) ++} ++ ++},{"./lib/rationalize":21}],12:[function(require,module,exports){ ++'use strict' ++ ++module.exports = cmp ++ ++function cmp(a, b) { ++ return a[0].mul(b[1]).cmp(b[0].mul(a[1])) ++} ++ ++},{}],13:[function(require,module,exports){ ++'use strict' ++ ++var rationalize = require('./lib/rationalize') ++ ++module.exports = div ++ ++function div(a, b) { ++ return rationalize(a[0].mul(b[1]), a[1].mul(b[0])) ++} ++ ++},{"./lib/rationalize":21}],14:[function(require,module,exports){ ++'use strict' ++ ++var isRat = require('./is-rat') ++var isBN = require('./lib/is-bn') ++var num2bn = require('./lib/num-to-bn') ++var str2bn = require('./lib/str-to-bn') ++var rationalize = require('./lib/rationalize') ++var div = require('./div') ++ ++module.exports = makeRational ++ ++function makeRational(numer, denom) { ++ if(isRat(numer)) { ++ if(denom) { ++ return div(numer, makeRational(denom)) ++ } ++ return [numer[0].clone(), numer[1].clone()] ++ } ++ var shift = 0 ++ var a, b ++ if(isBN(numer)) { ++ a = numer.clone() ++ } else if(typeof numer === 'string') { ++ a = str2bn(numer) ++ } else if(numer === 0) { ++ return [num2bn(0), num2bn(1)] ++ } else if(numer === Math.floor(numer)) { ++ a = num2bn(numer) ++ } else { ++ while(numer !== Math.floor(numer)) { ++ numer = numer * Math.pow(2, 256) ++ shift -= 256 ++ } ++ a = num2bn(numer) ++ } ++ if(isRat(denom)) { ++ a.mul(denom[1]) ++ b = denom[0].clone() ++ } else if(isBN(denom)) { ++ b = denom.clone() ++ } else if(typeof denom === 'string') { ++ b = str2bn(denom) ++ } else if(!denom) { ++ b = num2bn(1) ++ } else if(denom === Math.floor(denom)) { ++ b = num2bn(denom) ++ } else { ++ while(denom !== Math.floor(denom)) { ++ denom = denom * Math.pow(2, 256) ++ shift += 256 ++ } ++ b = num2bn(denom) ++ } ++ if(shift > 0) { ++ a = a.shln(shift) ++ } else if(shift < 0) { ++ b = b.shln(-shift) ++ } ++ return rationalize(a, b) ++} ++ ++},{"./div":13,"./is-rat":15,"./lib/is-bn":19,"./lib/num-to-bn":20,"./lib/rationalize":21,"./lib/str-to-bn":22}],15:[function(require,module,exports){ ++'use strict' ++ ++var isBN = require('./lib/is-bn') ++ ++module.exports = isRat ++ ++function isRat(x) { ++ return Array.isArray(x) && x.length === 2 && isBN(x[0]) && isBN(x[1]) ++} ++ ++},{"./lib/is-bn":19}],16:[function(require,module,exports){ ++'use strict' ++ ++var bn = require('bn.js') ++ ++module.exports = sign ++ ++function sign(x) { ++ return x.cmp(new bn(0)) ++} ++ ++},{"bn.js":29}],17:[function(require,module,exports){ ++'use strict' ++ ++module.exports = bn2num ++ ++//TODO: Make this better ++function bn2num(b) { ++ var l = b.length ++ var words = b.words ++ var out = 0 ++ if (l === 1) { ++ out = words[0] ++ } else if (l === 2) { ++ out = words[0] + (words[1] * 0x4000000) ++ } else { ++ var out = 0 ++ for (var i = 0; i < l; i++) { ++ var w = words[i] ++ out += w * Math.pow(0x4000000, i) ++ } ++ } ++ return b.sign ? -out : out ++} ++ ++},{}],18:[function(require,module,exports){ ++'use strict' ++ ++var db = require('double-bits') ++var ctz = require('bit-twiddle').countTrailingZeros ++ ++module.exports = ctzNumber ++ ++//Counts the number of trailing zeros ++function ctzNumber(x) { ++ var l = ctz(db.lo(x)) ++ if(l < 32) { ++ return l ++ } ++ var h = ctz(db.hi(x)) ++ if(h > 20) { ++ return 52 ++ } ++ return h + 32 ++} ++ ++},{"bit-twiddle":28,"double-bits":55}],19:[function(require,module,exports){ ++'use strict' ++ ++var BN = require('bn.js') ++ ++module.exports = isBN ++ ++//Test if x is a bignumber ++//FIXME: obviously this is the wrong way to do it ++function isBN(x) { ++ return x && typeof x === 'object' && Boolean(x.words) ++} ++ ++},{"bn.js":29}],20:[function(require,module,exports){ ++'use strict' ++ ++var BN = require('bn.js') ++var db = require('double-bits') ++ ++module.exports = num2bn ++ ++function num2bn(x) { ++ var e = db.exponent(x) ++ if(e < 52) { ++ return new BN(x) ++ } else { ++ return (new BN(x * Math.pow(2, 52-e))).shln(e-52) ++ } ++} ++ ++},{"bn.js":29,"double-bits":55}],21:[function(require,module,exports){ ++'use strict' ++ ++var num2bn = require('./num-to-bn') ++var sign = require('./bn-sign') ++ ++module.exports = rationalize ++ ++function rationalize(numer, denom) { ++ var snumer = sign(numer) ++ var sdenom = sign(denom) ++ if(snumer === 0) { ++ return [num2bn(0), num2bn(1)] ++ } ++ if(sdenom === 0) { ++ return [num2bn(0), num2bn(0)] ++ } ++ if(sdenom < 0) { ++ numer = numer.neg() ++ denom = denom.neg() ++ } ++ var d = numer.gcd(denom) ++ if(d.cmpn(1)) { ++ return [ numer.div(d), denom.div(d) ] ++ } ++ return [ numer, denom ] ++} ++ ++},{"./bn-sign":16,"./num-to-bn":20}],22:[function(require,module,exports){ ++'use strict' ++ ++var BN = require('bn.js') ++ ++module.exports = str2BN ++ ++function str2BN(x) { ++ return new BN(x) ++} ++ ++},{"bn.js":29}],23:[function(require,module,exports){ ++'use strict' ++ ++var rationalize = require('./lib/rationalize') ++ ++module.exports = mul ++ ++function mul(a, b) { ++ return rationalize(a[0].mul(b[0]), a[1].mul(b[1])) ++} ++ ++},{"./lib/rationalize":21}],24:[function(require,module,exports){ ++'use strict' ++ ++var bnsign = require('./lib/bn-sign') ++ ++module.exports = sign ++ ++function sign(x) { ++ return bnsign(x[0]) * bnsign(x[1]) ++} ++ ++},{"./lib/bn-sign":16}],25:[function(require,module,exports){ ++'use strict' ++ ++var rationalize = require('./lib/rationalize') ++ ++module.exports = sub ++ ++function sub(a, b) { ++ return rationalize(a[0].mul(b[1]).sub(a[1].mul(b[0])), a[1].mul(b[1])) ++} ++ ++},{"./lib/rationalize":21}],26:[function(require,module,exports){ ++'use strict' ++ ++var bn2num = require('./lib/bn-to-num') ++var ctz = require('./lib/ctz') ++ ++module.exports = roundRat ++ ++//Round a rational to the closest float ++function roundRat(f) { ++ var a = f[0] ++ var b = f[1] ++ if(a.cmpn(0) === 0) { ++ return 0 ++ } ++ var h = a.divmod(b) ++ var iv = h.div ++ var x = bn2num(iv) ++ var ir = h.mod ++ if(ir.cmpn(0) === 0) { ++ return x ++ } ++ if(x) { ++ var s = ctz(x) + 4 ++ var y = bn2num(ir.shln(s).divRound(b)) ++ ++ // flip the sign of y if x is negative ++ if (x<0) { ++ y = -y; ++ } ++ ++ return x + y * Math.pow(2, -s) ++ } else { ++ var ybits = b.bitLength() - ir.bitLength() + 53 ++ var y = bn2num(ir.shln(ybits).divRound(b)) ++ if(ybits < 1023) { ++ return y * Math.pow(2, -ybits) ++ } ++ y *= Math.pow(2, -1023) ++ return y * Math.pow(2, 1023-ybits) ++ } ++} ++ ++},{"./lib/bn-to-num":17,"./lib/ctz":18}],27:[function(require,module,exports){ ++"use strict" ++ ++function compileSearch(funcName, predicate, reversed, extraArgs, useNdarray, earlyOut) { ++ var code = [ ++ "function ", funcName, "(a,l,h,", extraArgs.join(","), "){", ++earlyOut ? "" : "var i=", (reversed ? "l-1" : "h+1"), ++";while(l<=h){\ ++var m=(l+h)>>>1,x=a", useNdarray ? ".get(m)" : "[m]"] ++ if(earlyOut) { ++ if(predicate.indexOf("c") < 0) { ++ code.push(";if(x===y){return m}else if(x<=y){") ++ } else { ++ code.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){") ++ } ++ } else { ++ code.push(";if(", predicate, "){i=m;") ++ } ++ if(reversed) { ++ code.push("l=m+1}else{h=m-1}") ++ } else { ++ code.push("h=m-1}else{l=m+1}") ++ } ++ code.push("}") ++ if(earlyOut) { ++ code.push("return -1};") ++ } else { ++ code.push("return i};") ++ } ++ return code.join("") ++} ++ ++function compileBoundsSearch(predicate, reversed, suffix, earlyOut) { ++ var result = new Function([ ++ compileSearch("A", "x" + predicate + "y", reversed, ["y"], false, earlyOut), ++ compileSearch("B", "x" + predicate + "y", reversed, ["y"], true, earlyOut), ++ compileSearch("P", "c(x,y)" + predicate + "0", reversed, ["y", "c"], false, earlyOut), ++ compileSearch("Q", "c(x,y)" + predicate + "0", reversed, ["y", "c"], true, earlyOut), ++"function dispatchBsearch", suffix, "(a,y,c,l,h){\ ++if(a.shape){\ ++if(typeof(c)==='function'){\ ++return Q(a,(l===undefined)?0:l|0,(h===undefined)?a.shape[0]-1:h|0,y,c)\ ++}else{\ ++return B(a,(c===undefined)?0:c|0,(l===undefined)?a.shape[0]-1:l|0,y)\ ++}}else{\ ++if(typeof(c)==='function'){\ ++return P(a,(l===undefined)?0:l|0,(h===undefined)?a.length-1:h|0,y,c)\ ++}else{\ ++return A(a,(c===undefined)?0:c|0,(l===undefined)?a.length-1:l|0,y)\ ++}}}\ ++return dispatchBsearch", suffix].join("")) ++ return result() ++} ++ ++module.exports = { ++ ge: compileBoundsSearch(">=", false, "GE"), ++ gt: compileBoundsSearch(">", false, "GT"), ++ lt: compileBoundsSearch("<", true, "LT"), ++ le: compileBoundsSearch("<=", true, "LE"), ++ eq: compileBoundsSearch("-", true, "EQ", true) ++} ++ ++},{}],28:[function(require,module,exports){ + /** + * Bit twiddling hacks for JavaScript. + * +@@ -648,9475 +1040,8606 @@ exports.nextCombination = function(v) { + } + + +-},{}],10:[function(require,module,exports){ +-(function (global){ +-/*! +- * The buffer module from node.js, for the browser. +- * +- * @author Feross Aboukhadijeh +- * @license MIT +- */ +-/* eslint-disable no-proto */ +- +-'use strict' +- +-var base64 = require('base64-js') +-var ieee754 = require('ieee754') +-var isArray = require('isarray') +- +-exports.Buffer = Buffer +-exports.SlowBuffer = SlowBuffer +-exports.INSPECT_MAX_BYTES = 50 +-Buffer.poolSize = 8192 // not used by this implementation +- +-var rootParent = {} ++},{}],29:[function(require,module,exports){ ++(function (module, exports) { + +-/** +- * If `Buffer.TYPED_ARRAY_SUPPORT`: +- * === true Use Uint8Array implementation (fastest) +- * === false Use Object implementation (most compatible, even IE6) +- * +- * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, +- * Opera 11.6+, iOS 4.2+. +- * +- * Due to various browser bugs, sometimes the Object implementation will be used even +- * when the browser supports typed arrays. +- * +- * Note: +- * +- * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances, +- * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. +- * +- * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. +- * +- * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of +- * incorrect length in some situations. ++'use strict'; + +- * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they +- * get the Object implementation, which is slower but behaves correctly. +- */ +-Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined +- ? global.TYPED_ARRAY_SUPPORT +- : typedArraySupport() ++// Utils + +-function typedArraySupport () { +- try { +- var arr = new Uint8Array(1) +- arr.foo = function () { return 42 } +- return arr.foo() === 42 && // typed array instances can be augmented +- typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray` +- arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` +- } catch (e) { +- return false +- } ++function assert(val, msg) { ++ if (!val) ++ throw new Error(msg || 'Assertion failed'); + } + +-function kMaxLength () { +- return Buffer.TYPED_ARRAY_SUPPORT +- ? 0x7fffffff +- : 0x3fffffff ++// Could use `inherits` module, but don't want to move from single file ++// architecture yet. ++function inherits(ctor, superCtor) { ++ ctor.super_ = superCtor; ++ var TempCtor = function () {}; ++ TempCtor.prototype = superCtor.prototype; ++ ctor.prototype = new TempCtor(); ++ ctor.prototype.constructor = ctor; + } + +-/** +- * The Buffer constructor returns instances of `Uint8Array` that have their +- * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of +- * `Uint8Array`, so the returned instances will have all the node `Buffer` methods +- * and the `Uint8Array` methods. Square bracket notation works as expected -- it +- * returns a single octet. +- * +- * The `Uint8Array` prototype remains unmodified. +- */ +-function Buffer (arg) { +- if (!(this instanceof Buffer)) { +- // Avoid going through an ArgumentsAdaptorTrampoline in the common case. +- if (arguments.length > 1) return new Buffer(arg, arguments[1]) +- return new Buffer(arg) +- } ++// BN + +- if (!Buffer.TYPED_ARRAY_SUPPORT) { +- this.length = 0 +- this.parent = undefined ++function BN(number, base, endian) { ++ // May be `new BN(bn)` ? ++ if (number !== null && ++ typeof number === 'object' && ++ Array.isArray(number.words)) { ++ return number; + } + +- // Common case. +- if (typeof arg === 'number') { +- return fromNumber(this, arg) +- } ++ this.sign = false; ++ this.words = null; ++ this.length = 0; ++ ++ // Reduction context ++ this.red = null; + +- // Slightly less common case. +- if (typeof arg === 'string') { +- return fromString(this, arg, arguments.length > 1 ? arguments[1] : 'utf8') ++ if (base === 'le' || base === 'be') { ++ endian = base; ++ base = 10; + } + +- // Unusual. +- return fromObject(this, arg) ++ if (number !== null) ++ this._init(number || 0, base || 10, endian || 'be'); + } ++if (typeof module === 'object') ++ module.exports = BN; ++else ++ exports.BN = BN; + +-// TODO: Legacy, not needed anymore. Remove in next major version. +-Buffer._augment = function (arr) { +- arr.__proto__ = Buffer.prototype +- return arr +-} ++BN.BN = BN; ++BN.wordSize = 26; + +-function fromNumber (that, length) { +- that = allocate(that, length < 0 ? 0 : checked(length) | 0) +- if (!Buffer.TYPED_ARRAY_SUPPORT) { +- for (var i = 0; i < length; i++) { +- that[i] = 0 +- } ++BN.prototype._init = function init(number, base, endian) { ++ if (typeof number === 'number') { ++ return this._initNumber(number, base, endian); ++ } else if (typeof number === 'object') { ++ return this._initArray(number, base, endian); + } +- return that +-} +- +-function fromString (that, string, encoding) { +- if (typeof encoding !== 'string' || encoding === '') encoding = 'utf8' ++ if (base === 'hex') ++ base = 16; ++ assert(base === (base | 0) && base >= 2 && base <= 36); + +- // Assumption: byteLength() return value is always < kMaxLength. +- var length = byteLength(string, encoding) | 0 +- that = allocate(that, length) ++ number = number.toString().replace(/\s+/g, ''); ++ var start = 0; ++ if (number[0] === '-') ++ start++; + +- that.write(string, encoding) +- return that +-} ++ if (base === 16) ++ this._parseHex(number, start); ++ else ++ this._parseBase(number, base, start); ++ ++ if (number[0] === '-') ++ this.sign = true; ++ ++ this.strip(); ++ ++ if (endian !== 'le') ++ return; ++ ++ this._initArray(this.toArray(), base, endian); ++}; ++ ++BN.prototype._initNumber = function _initNumber(number, base, endian) { ++ if (number < 0) { ++ this.sign = true; ++ number = -number; ++ } ++ if (number < 0x4000000) { ++ this.words = [ number & 0x3ffffff ]; ++ this.length = 1; ++ } else if (number < 0x10000000000000) { ++ this.words = [ ++ number & 0x3ffffff, ++ (number / 0x4000000) & 0x3ffffff ++ ]; ++ this.length = 2; ++ } else { ++ assert(number < 0x20000000000000); // 2 ^ 53 (unsafe) ++ this.words = [ ++ number & 0x3ffffff, ++ (number / 0x4000000) & 0x3ffffff, ++ 1 ++ ]; ++ this.length = 3; ++ } + +-function fromObject (that, object) { +- if (Buffer.isBuffer(object)) return fromBuffer(that, object) ++ if (endian !== 'le') ++ return; + +- if (isArray(object)) return fromArray(that, object) ++ // Reverse the bytes ++ this._initArray(this.toArray(), base, endian); ++}; + +- if (object == null) { +- throw new TypeError('must start with number, buffer, array or string') ++BN.prototype._initArray = function _initArray(number, base, endian) { ++ // Perhaps a Uint8Array ++ assert(typeof number.length === 'number'); ++ if (number.length <= 0) { ++ this.words = [ 0 ]; ++ this.length = 1; ++ return this; + } + +- if (typeof ArrayBuffer !== 'undefined') { +- if (object.buffer instanceof ArrayBuffer) { +- return fromTypedArray(that, object) ++ this.length = Math.ceil(number.length / 3); ++ this.words = new Array(this.length); ++ for (var i = 0; i < this.length; i++) ++ this.words[i] = 0; ++ ++ var off = 0; ++ if (endian === 'be') { ++ for (var i = number.length - 1, j = 0; i >= 0; i -= 3) { ++ var w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16); ++ this.words[j] |= (w << off) & 0x3ffffff; ++ this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; ++ off += 24; ++ if (off >= 26) { ++ off -= 26; ++ j++; ++ } + } +- if (object instanceof ArrayBuffer) { +- return fromArrayBuffer(that, object) ++ } else if (endian === 'le') { ++ for (var i = 0, j = 0; i < number.length; i += 3) { ++ var w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16); ++ this.words[j] |= (w << off) & 0x3ffffff; ++ this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; ++ off += 24; ++ if (off >= 26) { ++ off -= 26; ++ j++; ++ } + } + } ++ return this.strip(); ++}; + +- if (object.length) return fromArrayLike(that, object) ++function parseHex(str, start, end) { ++ var r = 0; ++ var len = Math.min(str.length, end); ++ for (var i = start; i < len; i++) { ++ var c = str.charCodeAt(i) - 48; + +- return fromJsonObject(that, object) +-} ++ r <<= 4; + +-function fromBuffer (that, buffer) { +- var length = checked(buffer.length) | 0 +- that = allocate(that, length) +- buffer.copy(that, 0, 0, length) +- return that +-} ++ // 'a' - 'f' ++ if (c >= 49 && c <= 54) ++ r |= c - 49 + 0xa; + +-function fromArray (that, array) { +- var length = checked(array.length) | 0 +- that = allocate(that, length) +- for (var i = 0; i < length; i += 1) { +- that[i] = array[i] & 255 +- } +- return that +-} ++ // 'A' - 'F' ++ else if (c >= 17 && c <= 22) ++ r |= c - 17 + 0xa; + +-// Duplicate of fromArray() to keep fromArray() monomorphic. +-function fromTypedArray (that, array) { +- var length = checked(array.length) | 0 +- that = allocate(that, length) +- // Truncating the elements is probably not what people expect from typed +- // arrays with BYTES_PER_ELEMENT > 1 but it's compatible with the behavior +- // of the old Buffer constructor. +- for (var i = 0; i < length; i += 1) { +- that[i] = array[i] & 255 ++ // '0' - '9' ++ else ++ r |= c & 0xf; + } +- return that ++ return r; + } + +-function fromArrayBuffer (that, array) { +- array.byteLength // this throws if `array` is not a valid ArrayBuffer ++BN.prototype._parseHex = function _parseHex(number, start) { ++ // Create possibly bigger array to ensure that it fits the number ++ this.length = Math.ceil((number.length - start) / 6); ++ this.words = new Array(this.length); ++ for (var i = 0; i < this.length; i++) ++ this.words[i] = 0; + +- if (Buffer.TYPED_ARRAY_SUPPORT) { +- // Return an augmented `Uint8Array` instance, for best performance +- that = new Uint8Array(array) +- that.__proto__ = Buffer.prototype +- } else { +- // Fallback: Return an object instance of the Buffer class +- that = fromTypedArray(that, new Uint8Array(array)) ++ // Scan 24-bit chunks and add them to the number ++ var off = 0; ++ for (var i = number.length - 6, j = 0; i >= start; i -= 6) { ++ var w = parseHex(number, i, i + 6); ++ this.words[j] |= (w << off) & 0x3ffffff; ++ this.words[j + 1] |= w >>> (26 - off) & 0x3fffff; ++ off += 24; ++ if (off >= 26) { ++ off -= 26; ++ j++; ++ } + } +- return that +-} +- +-function fromArrayLike (that, array) { +- var length = checked(array.length) | 0 +- that = allocate(that, length) +- for (var i = 0; i < length; i += 1) { +- that[i] = array[i] & 255 ++ if (i + 6 !== start) { ++ var w = parseHex(number, start, i + 6); ++ this.words[j] |= (w << off) & 0x3ffffff; ++ this.words[j + 1] |= w >>> (26 - off) & 0x3fffff; + } +- return that +-} ++ this.strip(); ++}; + +-// Deserialize { type: 'Buffer', data: [1,2,3,...] } into a Buffer object. +-// Returns a zero-length buffer for inputs that don't conform to the spec. +-function fromJsonObject (that, object) { +- var array +- var length = 0 ++function parseBase(str, start, end, mul) { ++ var r = 0; ++ var len = Math.min(str.length, end); ++ for (var i = start; i < len; i++) { ++ var c = str.charCodeAt(i) - 48; + +- if (object.type === 'Buffer' && isArray(object.data)) { +- array = object.data +- length = checked(array.length) | 0 +- } +- that = allocate(that, length) ++ r *= mul; + +- for (var i = 0; i < length; i += 1) { +- that[i] = array[i] & 255 +- } +- return that +-} ++ // 'a' ++ if (c >= 49) ++ r += c - 49 + 0xa; + +-if (Buffer.TYPED_ARRAY_SUPPORT) { +- Buffer.prototype.__proto__ = Uint8Array.prototype +- Buffer.__proto__ = Uint8Array +- if (typeof Symbol !== 'undefined' && Symbol.species && +- Buffer[Symbol.species] === Buffer) { +- // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 +- Object.defineProperty(Buffer, Symbol.species, { +- value: null, +- configurable: true +- }) ++ // 'A' ++ else if (c >= 17) ++ r += c - 17 + 0xa; ++ ++ // '0' - '9' ++ else ++ r += c; + } +-} else { +- // pre-set for values that may exist in the future +- Buffer.prototype.length = undefined +- Buffer.prototype.parent = undefined ++ return r; + } + +-function allocate (that, length) { +- if (Buffer.TYPED_ARRAY_SUPPORT) { +- // Return an augmented `Uint8Array` instance, for best performance +- that = new Uint8Array(length) +- that.__proto__ = Buffer.prototype +- } else { +- // Fallback: Return an object instance of the Buffer class +- that.length = length +- } ++BN.prototype._parseBase = function _parseBase(number, base, start) { ++ // Initialize as zero ++ this.words = [ 0 ]; ++ this.length = 1; ++ ++ // Find length of limb in base ++ for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) ++ limbLen++; ++ limbLen--; ++ limbPow = (limbPow / base) | 0; + +- var fromPool = length !== 0 && length <= Buffer.poolSize >>> 1 +- if (fromPool) that.parent = rootParent ++ var total = number.length - start; ++ var mod = total % limbLen; ++ var end = Math.min(total, total - mod) + start; + +- return that +-} ++ var word = 0; ++ for (var i = start; i < end; i += limbLen) { ++ word = parseBase(number, i, i + limbLen, base); + +-function checked (length) { +- // Note: cannot use `length < kMaxLength` here because that fails when +- // length is NaN (which is otherwise coerced to zero.) +- if (length >= kMaxLength()) { +- throw new RangeError('Attempt to allocate Buffer larger than maximum ' + +- 'size: 0x' + kMaxLength().toString(16) + ' bytes') ++ this.imuln(limbPow); ++ if (this.words[0] + word < 0x4000000) ++ this.words[0] += word; ++ else ++ this._iaddn(word); + } +- return length | 0 +-} + +-function SlowBuffer (subject, encoding) { +- if (!(this instanceof SlowBuffer)) return new SlowBuffer(subject, encoding) ++ if (mod !== 0) { ++ var pow = 1; ++ var word = parseBase(number, i, number.length, base); + +- var buf = new Buffer(subject, encoding) +- delete buf.parent +- return buf +-} ++ for (var i = 0; i < mod; i++) ++ pow *= base; ++ this.imuln(pow); ++ if (this.words[0] + word < 0x4000000) ++ this.words[0] += word; ++ else ++ this._iaddn(word); ++ } ++}; + +-Buffer.isBuffer = function isBuffer (b) { +- return !!(b != null && b._isBuffer) +-} ++BN.prototype.copy = function copy(dest) { ++ dest.words = new Array(this.length); ++ for (var i = 0; i < this.length; i++) ++ dest.words[i] = this.words[i]; ++ dest.length = this.length; ++ dest.sign = this.sign; ++ dest.red = this.red; ++}; + +-Buffer.compare = function compare (a, b) { +- if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { +- throw new TypeError('Arguments must be Buffers') +- } ++BN.prototype.clone = function clone() { ++ var r = new BN(null); ++ this.copy(r); ++ return r; ++}; + +- if (a === b) return 0 ++// Remove leading `0` from `this` ++BN.prototype.strip = function strip() { ++ while (this.length > 1 && this.words[this.length - 1] === 0) ++ this.length--; ++ return this._normSign(); ++}; + +- var x = a.length +- var y = b.length ++BN.prototype._normSign = function _normSign() { ++ // -0 = 0 ++ if (this.length === 1 && this.words[0] === 0) ++ this.sign = false; ++ return this; ++}; + +- var i = 0 +- var len = Math.min(x, y) +- while (i < len) { +- if (a[i] !== b[i]) break ++BN.prototype.inspect = function inspect() { ++ return (this.red ? ''; ++}; + +- ++i +- } ++/* + +- if (i !== len) { +- x = a[i] +- y = b[i] +- } ++var zeros = []; ++var groupSizes = []; ++var groupBases = []; + +- if (x < y) return -1 +- if (y < x) return 1 +- return 0 ++var s = ''; ++var i = -1; ++while (++i < BN.wordSize) { ++ zeros[i] = s; ++ s += '0'; + } +- +-Buffer.isEncoding = function isEncoding (encoding) { +- switch (String(encoding).toLowerCase()) { +- case 'hex': +- case 'utf8': +- case 'utf-8': +- case 'ascii': +- case 'binary': +- case 'base64': +- case 'raw': +- case 'ucs2': +- case 'ucs-2': +- case 'utf16le': +- case 'utf-16le': +- return true +- default: +- return false ++groupSizes[0] = 0; ++groupSizes[1] = 0; ++groupBases[0] = 0; ++groupBases[1] = 0; ++var base = 2 - 1; ++while (++base < 36 + 1) { ++ var groupSize = 0; ++ var groupBase = 1; ++ while (groupBase < (1 << BN.wordSize) / base) { ++ groupBase *= base; ++ groupSize += 1; + } ++ groupSizes[base] = groupSize; ++ groupBases[base] = groupBase; + } + +-Buffer.concat = function concat (list, length) { +- if (!isArray(list)) throw new TypeError('list argument must be an Array of Buffers.') +- +- if (list.length === 0) { +- return new Buffer(0) +- } ++*/ + +- var i +- if (length === undefined) { +- length = 0 +- for (i = 0; i < list.length; i++) { +- length += list[i].length +- } +- } ++var zeros = [ ++ '', ++ '0', ++ '00', ++ '000', ++ '0000', ++ '00000', ++ '000000', ++ '0000000', ++ '00000000', ++ '000000000', ++ '0000000000', ++ '00000000000', ++ '000000000000', ++ '0000000000000', ++ '00000000000000', ++ '000000000000000', ++ '0000000000000000', ++ '00000000000000000', ++ '000000000000000000', ++ '0000000000000000000', ++ '00000000000000000000', ++ '000000000000000000000', ++ '0000000000000000000000', ++ '00000000000000000000000', ++ '000000000000000000000000', ++ '0000000000000000000000000' ++]; + +- var buf = new Buffer(length) +- var pos = 0 +- for (i = 0; i < list.length; i++) { +- var item = list[i] +- item.copy(buf, pos) +- pos += item.length +- } +- return buf +-} ++var groupSizes = [ ++ 0, 0, ++ 25, 16, 12, 11, 10, 9, 8, ++ 8, 7, 7, 7, 7, 6, 6, ++ 6, 6, 6, 6, 6, 5, 5, ++ 5, 5, 5, 5, 5, 5, 5, ++ 5, 5, 5, 5, 5, 5, 5 ++]; + +-function byteLength (string, encoding) { +- if (typeof string !== 'string') string = '' + string ++var groupBases = [ ++ 0, 0, ++ 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, ++ 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625, ++ 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632, ++ 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, ++ 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176 ++]; + +- var len = string.length +- if (len === 0) return 0 ++BN.prototype.toString = function toString(base, padding) { ++ base = base || 10; ++ if (base === 16 || base === 'hex') { ++ var out = ''; ++ var off = 0; ++ var padding = padding | 0 || 1; ++ var carry = 0; ++ for (var i = 0; i < this.length; i++) { ++ var w = this.words[i]; ++ var word = (((w << off) | carry) & 0xffffff).toString(16); ++ carry = (w >>> (24 - off)) & 0xffffff; ++ if (carry !== 0 || i !== this.length - 1) ++ out = zeros[6 - word.length] + word + out; ++ else ++ out = word + out; ++ off += 2; ++ if (off >= 26) { ++ off -= 26; ++ i--; ++ } ++ } ++ if (carry !== 0) ++ out = carry.toString(16) + out; ++ while (out.length % padding !== 0) ++ out = '0' + out; ++ if (this.sign) ++ out = '-' + out; ++ return out; ++ } else if (base === (base | 0) && base >= 2 && base <= 36) { ++ // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base)); ++ var groupSize = groupSizes[base]; ++ // var groupBase = Math.pow(base, groupSize); ++ var groupBase = groupBases[base]; ++ var out = ''; ++ var c = this.clone(); ++ c.sign = false; ++ while (c.cmpn(0) !== 0) { ++ var r = c.modn(groupBase).toString(base); ++ c = c.idivn(groupBase); + +- // Use a for loop to avoid recursion +- var loweredCase = false +- for (;;) { +- switch (encoding) { +- case 'ascii': +- case 'binary': +- // Deprecated +- case 'raw': +- case 'raws': +- return len +- case 'utf8': +- case 'utf-8': +- return utf8ToBytes(string).length +- case 'ucs2': +- case 'ucs-2': +- case 'utf16le': +- case 'utf-16le': +- return len * 2 +- case 'hex': +- return len >>> 1 +- case 'base64': +- return base64ToBytes(string).length +- default: +- if (loweredCase) return utf8ToBytes(string).length // assume utf8 +- encoding = ('' + encoding).toLowerCase() +- loweredCase = true ++ if (c.cmpn(0) !== 0) ++ out = zeros[groupSize - r.length] + r + out; ++ else ++ out = r + out; + } ++ if (this.cmpn(0) === 0) ++ out = '0' + out; ++ if (this.sign) ++ out = '-' + out; ++ return out; ++ } else { ++ assert(false, 'Base should be between 2 and 36'); + } +-} +-Buffer.byteLength = byteLength +- +-function slowToString (encoding, start, end) { +- var loweredCase = false +- +- start = start | 0 +- end = end === undefined || end === Infinity ? this.length : end | 0 +- +- if (!encoding) encoding = 'utf8' +- if (start < 0) start = 0 +- if (end > this.length) end = this.length +- if (end <= start) return '' +- +- while (true) { +- switch (encoding) { +- case 'hex': +- return hexSlice(this, start, end) +- +- case 'utf8': +- case 'utf-8': +- return utf8Slice(this, start, end) ++}; + +- case 'ascii': +- return asciiSlice(this, start, end) ++BN.prototype.toJSON = function toJSON() { ++ return this.toString(16); ++}; + +- case 'binary': +- return binarySlice(this, start, end) ++BN.prototype.toArray = function toArray(endian) { ++ this.strip(); ++ var res = new Array(this.byteLength()); ++ res[0] = 0; + +- case 'base64': +- return base64Slice(this, start, end) ++ var q = this.clone(); ++ if (endian !== 'le') { ++ // Assume big-endian ++ for (var i = 0; q.cmpn(0) !== 0; i++) { ++ var b = q.andln(0xff); ++ q.ishrn(8); + +- case 'ucs2': +- case 'ucs-2': +- case 'utf16le': +- case 'utf-16le': +- return utf16leSlice(this, start, end) ++ res[res.length - i - 1] = b; ++ } ++ } else { ++ // Assume little-endian ++ for (var i = 0; q.cmpn(0) !== 0; i++) { ++ var b = q.andln(0xff); ++ q.ishrn(8); + +- default: +- if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) +- encoding = (encoding + '').toLowerCase() +- loweredCase = true ++ res[i] = b; + } + } +-} + +-// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect +-// Buffer instances. +-Buffer.prototype._isBuffer = true ++ return res; ++}; + +-Buffer.prototype.toString = function toString () { +- var length = this.length | 0 +- if (length === 0) return '' +- if (arguments.length === 0) return utf8Slice(this, 0, length) +- return slowToString.apply(this, arguments) ++if (Math.clz32) { ++ BN.prototype._countBits = function _countBits(w) { ++ return 32 - Math.clz32(w); ++ }; ++} else { ++ BN.prototype._countBits = function _countBits(w) { ++ var t = w; ++ var r = 0; ++ if (t >= 0x1000) { ++ r += 13; ++ t >>>= 13; ++ } ++ if (t >= 0x40) { ++ r += 7; ++ t >>>= 7; ++ } ++ if (t >= 0x8) { ++ r += 4; ++ t >>>= 4; ++ } ++ if (t >= 0x02) { ++ r += 2; ++ t >>>= 2; ++ } ++ return r + t; ++ }; + } + +-Buffer.prototype.equals = function equals (b) { +- if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') +- if (this === b) return true +- return Buffer.compare(this, b) === 0 +-} ++BN.prototype._zeroBits = function _zeroBits(w) { ++ // Short-cut ++ if (w === 0) ++ return 26; + +-Buffer.prototype.inspect = function inspect () { +- var str = '' +- var max = exports.INSPECT_MAX_BYTES +- if (this.length > 0) { +- str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') +- if (this.length > max) str += ' ... ' ++ var t = w; ++ var r = 0; ++ if ((t & 0x1fff) === 0) { ++ r += 13; ++ t >>>= 13; + } +- return '' +-} +- +-Buffer.prototype.compare = function compare (b) { +- if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') +- if (this === b) return 0 +- return Buffer.compare(this, b) +-} +- +-Buffer.prototype.indexOf = function indexOf (val, byteOffset) { +- if (byteOffset > 0x7fffffff) byteOffset = 0x7fffffff +- else if (byteOffset < -0x80000000) byteOffset = -0x80000000 +- byteOffset >>= 0 +- +- if (this.length === 0) return -1 +- if (byteOffset >= this.length) return -1 +- +- // Negative offsets start from the end of the buffer +- if (byteOffset < 0) byteOffset = Math.max(this.length + byteOffset, 0) +- +- if (typeof val === 'string') { +- if (val.length === 0) return -1 // special case: looking for empty string always fails +- return String.prototype.indexOf.call(this, val, byteOffset) ++ if ((t & 0x7f) === 0) { ++ r += 7; ++ t >>>= 7; + } +- if (Buffer.isBuffer(val)) { +- return arrayIndexOf(this, val, byteOffset) ++ if ((t & 0xf) === 0) { ++ r += 4; ++ t >>>= 4; + } +- if (typeof val === 'number') { +- if (Buffer.TYPED_ARRAY_SUPPORT && Uint8Array.prototype.indexOf === 'function') { +- return Uint8Array.prototype.indexOf.call(this, val, byteOffset) +- } +- return arrayIndexOf(this, [ val ], byteOffset) ++ if ((t & 0x3) === 0) { ++ r += 2; ++ t >>>= 2; + } ++ if ((t & 0x1) === 0) ++ r++; ++ return r; ++}; + +- function arrayIndexOf (arr, val, byteOffset) { +- var foundIndex = -1 +- for (var i = 0; byteOffset + i < arr.length; i++) { +- if (arr[byteOffset + i] === val[foundIndex === -1 ? 0 : i - foundIndex]) { +- if (foundIndex === -1) foundIndex = i +- if (i - foundIndex + 1 === val.length) return byteOffset + foundIndex +- } else { +- foundIndex = -1 +- } +- } +- return -1 +- } ++// Return number of used bits in a BN ++BN.prototype.bitLength = function bitLength() { ++ var hi = 0; ++ var w = this.words[this.length - 1]; ++ var hi = this._countBits(w); ++ return (this.length - 1) * 26 + hi; ++}; + +- throw new TypeError('val must be string, number or Buffer') +-} ++// Number of trailing zero bits ++BN.prototype.zeroBits = function zeroBits() { ++ if (this.cmpn(0) === 0) ++ return 0; + +-function hexWrite (buf, string, offset, length) { +- offset = Number(offset) || 0 +- var remaining = buf.length - offset +- if (!length) { +- length = remaining +- } else { +- length = Number(length) +- if (length > remaining) { +- length = remaining +- } ++ var r = 0; ++ for (var i = 0; i < this.length; i++) { ++ var b = this._zeroBits(this.words[i]); ++ r += b; ++ if (b !== 26) ++ break; + } ++ return r; ++}; + +- // must be an even number of digits +- var strLen = string.length +- if (strLen % 2 !== 0) throw new Error('Invalid hex string') ++BN.prototype.byteLength = function byteLength() { ++ return Math.ceil(this.bitLength() / 8); ++}; + +- if (length > strLen / 2) { +- length = strLen / 2 +- } +- for (var i = 0; i < length; i++) { +- var parsed = parseInt(string.substr(i * 2, 2), 16) +- if (isNaN(parsed)) throw new Error('Invalid hex string') +- buf[offset + i] = parsed +- } +- return i +-} ++// Return negative clone of `this` ++BN.prototype.neg = function neg() { ++ if (this.cmpn(0) === 0) ++ return this.clone(); + +-function utf8Write (buf, string, offset, length) { +- return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) +-} ++ var r = this.clone(); ++ r.sign = !this.sign; ++ return r; ++}; + +-function asciiWrite (buf, string, offset, length) { +- return blitBuffer(asciiToBytes(string), buf, offset, length) +-} + +-function binaryWrite (buf, string, offset, length) { +- return asciiWrite(buf, string, offset, length) +-} ++// Or `num` with `this` in-place ++BN.prototype.ior = function ior(num) { ++ this.sign = this.sign || num.sign; + +-function base64Write (buf, string, offset, length) { +- return blitBuffer(base64ToBytes(string), buf, offset, length) +-} ++ while (this.length < num.length) ++ this.words[this.length++] = 0; + +-function ucs2Write (buf, string, offset, length) { +- return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) +-} ++ for (var i = 0; i < num.length; i++) ++ this.words[i] = this.words[i] | num.words[i]; + +-Buffer.prototype.write = function write (string, offset, length, encoding) { +- // Buffer#write(string) +- if (offset === undefined) { +- encoding = 'utf8' +- length = this.length +- offset = 0 +- // Buffer#write(string, encoding) +- } else if (length === undefined && typeof offset === 'string') { +- encoding = offset +- length = this.length +- offset = 0 +- // Buffer#write(string, offset[, length][, encoding]) +- } else if (isFinite(offset)) { +- offset = offset | 0 +- if (isFinite(length)) { +- length = length | 0 +- if (encoding === undefined) encoding = 'utf8' +- } else { +- encoding = length +- length = undefined +- } +- // legacy write(string, encoding, offset, length) - remove in v0.13 +- } else { +- var swap = encoding +- encoding = offset +- offset = length | 0 +- length = swap +- } ++ return this.strip(); ++}; + +- var remaining = this.length - offset +- if (length === undefined || length > remaining) length = remaining + +- if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { +- throw new RangeError('attempt to write outside buffer bounds') +- } ++// Or `num` with `this` ++BN.prototype.or = function or(num) { ++ if (this.length > num.length) ++ return this.clone().ior(num); ++ else ++ return num.clone().ior(this); ++}; + +- if (!encoding) encoding = 'utf8' + +- var loweredCase = false +- for (;;) { +- switch (encoding) { +- case 'hex': +- return hexWrite(this, string, offset, length) ++// And `num` with `this` in-place ++BN.prototype.iand = function iand(num) { ++ this.sign = this.sign && num.sign; + +- case 'utf8': +- case 'utf-8': +- return utf8Write(this, string, offset, length) ++ // b = min-length(num, this) ++ var b; ++ if (this.length > num.length) ++ b = num; ++ else ++ b = this; + +- case 'ascii': +- return asciiWrite(this, string, offset, length) ++ for (var i = 0; i < b.length; i++) ++ this.words[i] = this.words[i] & num.words[i]; + +- case 'binary': +- return binaryWrite(this, string, offset, length) ++ this.length = b.length; + +- case 'base64': +- // Warning: maxLength not taken into account in base64Write +- return base64Write(this, string, offset, length) ++ return this.strip(); ++}; + +- case 'ucs2': +- case 'ucs-2': +- case 'utf16le': +- case 'utf-16le': +- return ucs2Write(this, string, offset, length) + +- default: +- if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) +- encoding = ('' + encoding).toLowerCase() +- loweredCase = true +- } +- } +-} ++// And `num` with `this` ++BN.prototype.and = function and(num) { ++ if (this.length > num.length) ++ return this.clone().iand(num); ++ else ++ return num.clone().iand(this); ++}; + +-Buffer.prototype.toJSON = function toJSON () { +- return { +- type: 'Buffer', +- data: Array.prototype.slice.call(this._arr || this, 0) +- } +-} + +-function base64Slice (buf, start, end) { +- if (start === 0 && end === buf.length) { +- return base64.fromByteArray(buf) ++// Xor `num` with `this` in-place ++BN.prototype.ixor = function ixor(num) { ++ this.sign = this.sign || num.sign; ++ ++ // a.length > b.length ++ var a; ++ var b; ++ if (this.length > num.length) { ++ a = this; ++ b = num; + } else { +- return base64.fromByteArray(buf.slice(start, end)) ++ a = num; ++ b = this; + } +-} + +-function utf8Slice (buf, start, end) { +- end = Math.min(buf.length, end) +- var res = [] ++ for (var i = 0; i < b.length; i++) ++ this.words[i] = a.words[i] ^ b.words[i]; + +- var i = start +- while (i < end) { +- var firstByte = buf[i] +- var codePoint = null +- var bytesPerSequence = (firstByte > 0xEF) ? 4 +- : (firstByte > 0xDF) ? 3 +- : (firstByte > 0xBF) ? 2 +- : 1 ++ if (this !== a) ++ for (; i < a.length; i++) ++ this.words[i] = a.words[i]; + +- if (i + bytesPerSequence <= end) { +- var secondByte, thirdByte, fourthByte, tempCodePoint ++ this.length = a.length; + +- switch (bytesPerSequence) { +- case 1: +- if (firstByte < 0x80) { +- codePoint = firstByte +- } +- break +- case 2: +- secondByte = buf[i + 1] +- if ((secondByte & 0xC0) === 0x80) { +- tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) +- if (tempCodePoint > 0x7F) { +- codePoint = tempCodePoint +- } +- } +- break +- case 3: +- secondByte = buf[i + 1] +- thirdByte = buf[i + 2] +- if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { +- tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) +- if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { +- codePoint = tempCodePoint +- } +- } +- break +- case 4: +- secondByte = buf[i + 1] +- thirdByte = buf[i + 2] +- fourthByte = buf[i + 3] +- if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { +- tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) +- if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { +- codePoint = tempCodePoint +- } +- } +- } +- } ++ return this.strip(); ++}; + +- if (codePoint === null) { +- // we did not generate a valid codePoint so insert a +- // replacement char (U+FFFD) and advance only 1 byte +- codePoint = 0xFFFD +- bytesPerSequence = 1 +- } else if (codePoint > 0xFFFF) { +- // encode to utf16 (surrogate pair dance) +- codePoint -= 0x10000 +- res.push(codePoint >>> 10 & 0x3FF | 0xD800) +- codePoint = 0xDC00 | codePoint & 0x3FF +- } + +- res.push(codePoint) +- i += bytesPerSequence +- } ++// Xor `num` with `this` ++BN.prototype.xor = function xor(num) { ++ if (this.length > num.length) ++ return this.clone().ixor(num); ++ else ++ return num.clone().ixor(this); ++}; + +- return decodeCodePointsArray(res) +-} + +-// Based on http://stackoverflow.com/a/22747272/680742, the browser with +-// the lowest limit is Chrome, with 0x10000 args. +-// We go 1 magnitude less, for safety +-var MAX_ARGUMENTS_LENGTH = 0x1000 ++// Set `bit` of `this` ++BN.prototype.setn = function setn(bit, val) { ++ assert(typeof bit === 'number' && bit >= 0); + +-function decodeCodePointsArray (codePoints) { +- var len = codePoints.length +- if (len <= MAX_ARGUMENTS_LENGTH) { +- return String.fromCharCode.apply(String, codePoints) // avoid extra slice() +- } ++ var off = (bit / 26) | 0; ++ var wbit = bit % 26; + +- // Decode in chunks to avoid "call stack size exceeded". +- var res = '' +- var i = 0 +- while (i < len) { +- res += String.fromCharCode.apply( +- String, +- codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) +- ) +- } +- return res +-} ++ while (this.length <= off) ++ this.words[this.length++] = 0; + +-function asciiSlice (buf, start, end) { +- var ret = '' +- end = Math.min(buf.length, end) ++ if (val) ++ this.words[off] = this.words[off] | (1 << wbit); ++ else ++ this.words[off] = this.words[off] & ~(1 << wbit); + +- for (var i = start; i < end; i++) { +- ret += String.fromCharCode(buf[i] & 0x7F) +- } +- return ret +-} ++ return this.strip(); ++}; + +-function binarySlice (buf, start, end) { +- var ret = '' +- end = Math.min(buf.length, end) + +- for (var i = start; i < end; i++) { +- ret += String.fromCharCode(buf[i]) +- } +- return ret +-} ++// Add `num` to `this` in-place ++BN.prototype.iadd = function iadd(num) { ++ // negative + positive ++ if (this.sign && !num.sign) { ++ this.sign = false; ++ var r = this.isub(num); ++ this.sign = !this.sign; ++ return this._normSign(); + +-function hexSlice (buf, start, end) { +- var len = buf.length ++ // positive + negative ++ } else if (!this.sign && num.sign) { ++ num.sign = false; ++ var r = this.isub(num); ++ num.sign = true; ++ return r._normSign(); ++ } + +- if (!start || start < 0) start = 0 +- if (!end || end < 0 || end > len) end = len ++ // a.length > b.length ++ var a; ++ var b; ++ if (this.length > num.length) { ++ a = this; ++ b = num; ++ } else { ++ a = num; ++ b = this; ++ } + +- var out = '' +- for (var i = start; i < end; i++) { +- out += toHex(buf[i]) ++ var carry = 0; ++ for (var i = 0; i < b.length; i++) { ++ var r = a.words[i] + b.words[i] + carry; ++ this.words[i] = r & 0x3ffffff; ++ carry = r >>> 26; ++ } ++ for (; carry !== 0 && i < a.length; i++) { ++ var r = a.words[i] + carry; ++ this.words[i] = r & 0x3ffffff; ++ carry = r >>> 26; + } +- return out +-} + +-function utf16leSlice (buf, start, end) { +- var bytes = buf.slice(start, end) +- var res = '' +- for (var i = 0; i < bytes.length; i += 2) { +- res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256) ++ this.length = a.length; ++ if (carry !== 0) { ++ this.words[this.length] = carry; ++ this.length++; ++ // Copy the rest of the words ++ } else if (a !== this) { ++ for (; i < a.length; i++) ++ this.words[i] = a.words[i]; + } +- return res +-} + +-Buffer.prototype.slice = function slice (start, end) { +- var len = this.length +- start = ~~start +- end = end === undefined ? len : ~~end ++ return this; ++}; + +- if (start < 0) { +- start += len +- if (start < 0) start = 0 +- } else if (start > len) { +- start = len ++// Add `num` to `this` ++BN.prototype.add = function add(num) { ++ if (num.sign && !this.sign) { ++ num.sign = false; ++ var res = this.sub(num); ++ num.sign = true; ++ return res; ++ } else if (!num.sign && this.sign) { ++ this.sign = false; ++ var res = num.sub(this); ++ this.sign = true; ++ return res; + } + +- if (end < 0) { +- end += len +- if (end < 0) end = 0 +- } else if (end > len) { +- end = len +- } ++ if (this.length > num.length) ++ return this.clone().iadd(num); ++ else ++ return num.clone().iadd(this); ++}; + +- if (end < start) end = start ++// Subtract `num` from `this` in-place ++BN.prototype.isub = function isub(num) { ++ // this - (-num) = this + num ++ if (num.sign) { ++ num.sign = false; ++ var r = this.iadd(num); ++ num.sign = true; ++ return r._normSign(); + +- var newBuf +- if (Buffer.TYPED_ARRAY_SUPPORT) { +- newBuf = this.subarray(start, end) +- newBuf.__proto__ = Buffer.prototype +- } else { +- var sliceLen = end - start +- newBuf = new Buffer(sliceLen, undefined) +- for (var i = 0; i < sliceLen; i++) { +- newBuf[i] = this[i + start] +- } ++ // -this - num = -(this + num) ++ } else if (this.sign) { ++ this.sign = false; ++ this.iadd(num); ++ this.sign = true; ++ return this._normSign(); + } + +- if (newBuf.length) newBuf.parent = this.parent || this +- +- return newBuf +-} ++ // At this point both numbers are positive ++ var cmp = this.cmp(num); + +-/* +- * Need to make sure that buffer isn't trying to write out of bounds. +- */ +-function checkOffset (offset, ext, length) { +- if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') +- if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') +-} +- +-Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { +- offset = offset | 0 +- byteLength = byteLength | 0 +- if (!noAssert) checkOffset(offset, byteLength, this.length) +- +- var val = this[offset] +- var mul = 1 +- var i = 0 +- while (++i < byteLength && (mul *= 0x100)) { +- val += this[offset + i] * mul ++ // Optimization - zeroify ++ if (cmp === 0) { ++ this.sign = false; ++ this.length = 1; ++ this.words[0] = 0; ++ return this; + } + +- return val +-} +- +-Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { +- offset = offset | 0 +- byteLength = byteLength | 0 +- if (!noAssert) { +- checkOffset(offset, byteLength, this.length) ++ // a > b ++ var a; ++ var b; ++ if (cmp > 0) { ++ a = this; ++ b = num; ++ } else { ++ a = num; ++ b = this; + } + +- var val = this[offset + --byteLength] +- var mul = 1 +- while (byteLength > 0 && (mul *= 0x100)) { +- val += this[offset + --byteLength] * mul ++ var carry = 0; ++ for (var i = 0; i < b.length; i++) { ++ var r = a.words[i] - b.words[i] + carry; ++ carry = r >> 26; ++ this.words[i] = r & 0x3ffffff; ++ } ++ for (; carry !== 0 && i < a.length; i++) { ++ var r = a.words[i] + carry; ++ carry = r >> 26; ++ this.words[i] = r & 0x3ffffff; + } + +- return val +-} ++ // Copy rest of the words ++ if (carry === 0 && i < a.length && a !== this) ++ for (; i < a.length; i++) ++ this.words[i] = a.words[i]; ++ this.length = Math.max(this.length, i); + +-Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { +- if (!noAssert) checkOffset(offset, 1, this.length) +- return this[offset] +-} ++ if (a !== this) ++ this.sign = true; + +-Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { +- if (!noAssert) checkOffset(offset, 2, this.length) +- return this[offset] | (this[offset + 1] << 8) +-} ++ return this.strip(); ++}; + +-Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { +- if (!noAssert) checkOffset(offset, 2, this.length) +- return (this[offset] << 8) | this[offset + 1] +-} ++// Subtract `num` from `this` ++BN.prototype.sub = function sub(num) { ++ return this.clone().isub(num); ++}; + +-Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { +- if (!noAssert) checkOffset(offset, 4, this.length) ++/* ++// NOTE: This could be potentionally used to generate loop-less multiplications ++function _genCombMulTo(alen, blen) { ++ var len = alen + blen - 1; ++ var src = [ ++ 'var a = this.words, b = num.words, o = out.words, c = 0, w, ' + ++ 'mask = 0x3ffffff, shift = 0x4000000;', ++ 'out.length = ' + len + ';' ++ ]; ++ for (var k = 0; k < len; k++) { ++ var minJ = Math.max(0, k - alen + 1); ++ var maxJ = Math.min(k, blen - 1); + +- return ((this[offset]) | +- (this[offset + 1] << 8) | +- (this[offset + 2] << 16)) + +- (this[offset + 3] * 0x1000000) +-} ++ for (var j = minJ; j <= maxJ; j++) { ++ var i = k - j; ++ var mul = 'a[' + i + '] * b[' + j + ']'; + +-Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { +- if (!noAssert) checkOffset(offset, 4, this.length) ++ if (j === minJ) { ++ src.push('w = ' + mul + ' + c;'); ++ src.push('c = (w / shift) | 0;'); ++ } else { ++ src.push('w += ' + mul + ';'); ++ src.push('c += (w / shift) | 0;'); ++ } ++ src.push('w &= mask;'); ++ } ++ src.push('o[' + k + '] = w;'); ++ } ++ src.push('if (c !== 0) {', ++ ' o[' + k + '] = c;', ++ ' out.length++;', ++ '}', ++ 'return out;'); + +- return (this[offset] * 0x1000000) + +- ((this[offset + 1] << 16) | +- (this[offset + 2] << 8) | +- this[offset + 3]) ++ return src.join('\n'); + } ++*/ + +-Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { +- offset = offset | 0 +- byteLength = byteLength | 0 +- if (!noAssert) checkOffset(offset, byteLength, this.length) ++BN.prototype._smallMulTo = function _smallMulTo(num, out) { ++ out.sign = num.sign !== this.sign; ++ out.length = this.length + num.length; + +- var val = this[offset] +- var mul = 1 +- var i = 0 +- while (++i < byteLength && (mul *= 0x100)) { +- val += this[offset + i] * mul ++ var carry = 0; ++ for (var k = 0; k < out.length - 1; k++) { ++ // Sum all words with the same `i + j = k` and accumulate `ncarry`, ++ // note that ncarry could be >= 0x3ffffff ++ var ncarry = carry >>> 26; ++ var rword = carry & 0x3ffffff; ++ var maxJ = Math.min(k, num.length - 1); ++ for (var j = Math.max(0, k - this.length + 1); j <= maxJ; j++) { ++ var i = k - j; ++ var a = this.words[i] | 0; ++ var b = num.words[j] | 0; ++ var r = a * b; ++ ++ var lo = r & 0x3ffffff; ++ ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0; ++ lo = (lo + rword) | 0; ++ rword = lo & 0x3ffffff; ++ ncarry = (ncarry + (lo >>> 26)) | 0; ++ } ++ out.words[k] = rword; ++ carry = ncarry; ++ } ++ if (carry !== 0) { ++ out.words[k] = carry; ++ } else { ++ out.length--; + } +- mul *= 0x80 + +- if (val >= mul) val -= Math.pow(2, 8 * byteLength) ++ return out.strip(); ++}; + +- return val +-} ++BN.prototype._bigMulTo = function _bigMulTo(num, out) { ++ out.sign = num.sign !== this.sign; ++ out.length = this.length + num.length; + +-Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { +- offset = offset | 0 +- byteLength = byteLength | 0 +- if (!noAssert) checkOffset(offset, byteLength, this.length) ++ var carry = 0; ++ var hncarry = 0; ++ for (var k = 0; k < out.length - 1; k++) { ++ // Sum all words with the same `i + j = k` and accumulate `ncarry`, ++ // note that ncarry could be >= 0x3ffffff ++ var ncarry = hncarry; ++ hncarry = 0; ++ var rword = carry & 0x3ffffff; ++ var maxJ = Math.min(k, num.length - 1); ++ for (var j = Math.max(0, k - this.length + 1); j <= maxJ; j++) { ++ var i = k - j; ++ var a = this.words[i] | 0; ++ var b = num.words[j] | 0; ++ var r = a * b; + +- var i = byteLength +- var mul = 1 +- var val = this[offset + --i] +- while (i > 0 && (mul *= 0x100)) { +- val += this[offset + --i] * mul ++ var lo = r & 0x3ffffff; ++ ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0; ++ lo = (lo + rword) | 0; ++ rword = lo & 0x3ffffff; ++ ncarry = (ncarry + (lo >>> 26)) | 0; ++ ++ hncarry += ncarry >>> 26; ++ ncarry &= 0x3ffffff; ++ } ++ out.words[k] = rword; ++ carry = ncarry; ++ ncarry = hncarry; ++ } ++ if (carry !== 0) { ++ out.words[k] = carry; ++ } else { ++ out.length--; + } +- mul *= 0x80 + +- if (val >= mul) val -= Math.pow(2, 8 * byteLength) ++ return out.strip(); ++}; + +- return val +-} ++BN.prototype.mulTo = function mulTo(num, out) { ++ var res; ++ if (this.length + num.length < 63) ++ res = this._smallMulTo(num, out); ++ else ++ res = this._bigMulTo(num, out); ++ return res; ++}; + +-Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { +- if (!noAssert) checkOffset(offset, 1, this.length) +- if (!(this[offset] & 0x80)) return (this[offset]) +- return ((0xff - this[offset] + 1) * -1) +-} ++// Multiply `this` by `num` ++BN.prototype.mul = function mul(num) { ++ var out = new BN(null); ++ out.words = new Array(this.length + num.length); ++ return this.mulTo(num, out); ++}; + +-Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { +- if (!noAssert) checkOffset(offset, 2, this.length) +- var val = this[offset] | (this[offset + 1] << 8) +- return (val & 0x8000) ? val | 0xFFFF0000 : val +-} ++// In-place Multiplication ++BN.prototype.imul = function imul(num) { ++ if (this.cmpn(0) === 0 || num.cmpn(0) === 0) { ++ this.words[0] = 0; ++ this.length = 1; ++ return this; ++ } + +-Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { +- if (!noAssert) checkOffset(offset, 2, this.length) +- var val = this[offset + 1] | (this[offset] << 8) +- return (val & 0x8000) ? val | 0xFFFF0000 : val +-} ++ var tlen = this.length; ++ var nlen = num.length; + +-Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { +- if (!noAssert) checkOffset(offset, 4, this.length) ++ this.sign = num.sign !== this.sign; ++ this.length = this.length + num.length; ++ this.words[this.length - 1] = 0; + +- return (this[offset]) | +- (this[offset + 1] << 8) | +- (this[offset + 2] << 16) | +- (this[offset + 3] << 24) +-} ++ for (var k = this.length - 2; k >= 0; k--) { ++ // Sum all words with the same `i + j = k` and accumulate `carry`, ++ // note that carry could be >= 0x3ffffff ++ var carry = 0; ++ var rword = 0; ++ var maxJ = Math.min(k, nlen - 1); ++ for (var j = Math.max(0, k - tlen + 1); j <= maxJ; j++) { ++ var i = k - j; ++ var a = this.words[i]; ++ var b = num.words[j]; ++ var r = a * b; + +-Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { +- if (!noAssert) checkOffset(offset, 4, this.length) ++ var lo = r & 0x3ffffff; ++ carry += (r / 0x4000000) | 0; ++ lo += rword; ++ rword = lo & 0x3ffffff; ++ carry += lo >>> 26; ++ } ++ this.words[k] = rword; ++ this.words[k + 1] += carry; ++ carry = 0; ++ } + +- return (this[offset] << 24) | +- (this[offset + 1] << 16) | +- (this[offset + 2] << 8) | +- (this[offset + 3]) +-} ++ // Propagate overflows ++ var carry = 0; ++ for (var i = 1; i < this.length; i++) { ++ var w = this.words[i] + carry; ++ this.words[i] = w & 0x3ffffff; ++ carry = w >>> 26; ++ } + +-Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { +- if (!noAssert) checkOffset(offset, 4, this.length) +- return ieee754.read(this, offset, true, 23, 4) +-} ++ return this.strip(); ++}; + +-Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { +- if (!noAssert) checkOffset(offset, 4, this.length) +- return ieee754.read(this, offset, false, 23, 4) +-} ++BN.prototype.imuln = function imuln(num) { ++ assert(typeof num === 'number'); + +-Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { +- if (!noAssert) checkOffset(offset, 8, this.length) +- return ieee754.read(this, offset, true, 52, 8) +-} ++ // Carry ++ var carry = 0; ++ for (var i = 0; i < this.length; i++) { ++ var w = this.words[i] * num; ++ var lo = (w & 0x3ffffff) + (carry & 0x3ffffff); ++ carry >>= 26; ++ carry += (w / 0x4000000) | 0; ++ // NOTE: lo is 27bit maximum ++ carry += lo >>> 26; ++ this.words[i] = lo & 0x3ffffff; ++ } + +-Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { +- if (!noAssert) checkOffset(offset, 8, this.length) +- return ieee754.read(this, offset, false, 52, 8) +-} ++ if (carry !== 0) { ++ this.words[i] = carry; ++ this.length++; ++ } + +-function checkInt (buf, value, offset, ext, max, min) { +- if (!Buffer.isBuffer(buf)) throw new TypeError('buffer must be a Buffer instance') +- if (value > max || value < min) throw new RangeError('value is out of bounds') +- if (offset + ext > buf.length) throw new RangeError('index out of range') +-} ++ return this; ++}; + +-Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { +- value = +value +- offset = offset | 0 +- byteLength = byteLength | 0 +- if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0) ++BN.prototype.muln = function muln(num) { ++ return this.clone().imuln(num); ++}; + +- var mul = 1 +- var i = 0 +- this[offset] = value & 0xFF +- while (++i < byteLength && (mul *= 0x100)) { +- this[offset + i] = (value / mul) & 0xFF +- } ++// `this` * `this` ++BN.prototype.sqr = function sqr() { ++ return this.mul(this); ++}; + +- return offset + byteLength +-} ++// `this` * `this` in-place ++BN.prototype.isqr = function isqr() { ++ return this.mul(this); ++}; + +-Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { +- value = +value +- offset = offset | 0 +- byteLength = byteLength | 0 +- if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0) ++// Shift-left in-place ++BN.prototype.ishln = function ishln(bits) { ++ assert(typeof bits === 'number' && bits >= 0); ++ var r = bits % 26; ++ var s = (bits - r) / 26; ++ var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r); + +- var i = byteLength - 1 +- var mul = 1 +- this[offset + i] = value & 0xFF +- while (--i >= 0 && (mul *= 0x100)) { +- this[offset + i] = (value / mul) & 0xFF ++ if (r !== 0) { ++ var carry = 0; ++ for (var i = 0; i < this.length; i++) { ++ var newCarry = this.words[i] & carryMask; ++ var c = (this.words[i] - newCarry) << r; ++ this.words[i] = c | carry; ++ carry = newCarry >>> (26 - r); ++ } ++ if (carry) { ++ this.words[i] = carry; ++ this.length++; ++ } + } + +- return offset + byteLength +-} ++ if (s !== 0) { ++ for (var i = this.length - 1; i >= 0; i--) ++ this.words[i + s] = this.words[i]; ++ for (var i = 0; i < s; i++) ++ this.words[i] = 0; ++ this.length += s; ++ } + +-Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { +- value = +value +- offset = offset | 0 +- if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) +- if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) +- this[offset] = (value & 0xff) +- return offset + 1 +-} ++ return this.strip(); ++}; + +-function objectWriteUInt16 (buf, value, offset, littleEndian) { +- if (value < 0) value = 0xffff + value + 1 +- for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; i++) { +- buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> +- (littleEndian ? i : 1 - i) * 8 +- } +-} ++// Shift-right in-place ++// NOTE: `hint` is a lowest bit before trailing zeroes ++// NOTE: if `extended` is present - it will be filled with destroyed bits ++BN.prototype.ishrn = function ishrn(bits, hint, extended) { ++ assert(typeof bits === 'number' && bits >= 0); ++ var h; ++ if (hint) ++ h = (hint - (hint % 26)) / 26; ++ else ++ h = 0; + +-Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { +- value = +value +- offset = offset | 0 +- if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) +- if (Buffer.TYPED_ARRAY_SUPPORT) { +- this[offset] = (value & 0xff) +- this[offset + 1] = (value >>> 8) +- } else { +- objectWriteUInt16(this, value, offset, true) +- } +- return offset + 2 +-} ++ var r = bits % 26; ++ var s = Math.min((bits - r) / 26, this.length); ++ var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); ++ var maskedWords = extended; + +-Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { +- value = +value +- offset = offset | 0 +- if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) +- if (Buffer.TYPED_ARRAY_SUPPORT) { +- this[offset] = (value >>> 8) +- this[offset + 1] = (value & 0xff) +- } else { +- objectWriteUInt16(this, value, offset, false) +- } +- return offset + 2 +-} ++ h -= s; ++ h = Math.max(0, h); + +-function objectWriteUInt32 (buf, value, offset, littleEndian) { +- if (value < 0) value = 0xffffffff + value + 1 +- for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; i++) { +- buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff ++ // Extended mode, copy masked part ++ if (maskedWords) { ++ for (var i = 0; i < s; i++) ++ maskedWords.words[i] = this.words[i]; ++ maskedWords.length = s; + } +-} + +-Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { +- value = +value +- offset = offset | 0 +- if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) +- if (Buffer.TYPED_ARRAY_SUPPORT) { +- this[offset + 3] = (value >>> 24) +- this[offset + 2] = (value >>> 16) +- this[offset + 1] = (value >>> 8) +- this[offset] = (value & 0xff) ++ if (s === 0) { ++ // No-op, we should not move anything at all ++ } else if (this.length > s) { ++ this.length -= s; ++ for (var i = 0; i < this.length; i++) ++ this.words[i] = this.words[i + s]; + } else { +- objectWriteUInt32(this, value, offset, true) ++ this.words[0] = 0; ++ this.length = 1; + } +- return offset + 4 +-} + +-Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { +- value = +value +- offset = offset | 0 +- if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) +- if (Buffer.TYPED_ARRAY_SUPPORT) { +- this[offset] = (value >>> 24) +- this[offset + 1] = (value >>> 16) +- this[offset + 2] = (value >>> 8) +- this[offset + 3] = (value & 0xff) +- } else { +- objectWriteUInt32(this, value, offset, false) ++ var carry = 0; ++ for (var i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) { ++ var word = this.words[i]; ++ this.words[i] = (carry << (26 - r)) | (word >>> r); ++ carry = word & mask; + } +- return offset + 4 +-} + +-Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { +- value = +value +- offset = offset | 0 +- if (!noAssert) { +- var limit = Math.pow(2, 8 * byteLength - 1) ++ // Push carried bits as a mask ++ if (maskedWords && carry !== 0) ++ maskedWords.words[maskedWords.length++] = carry; + +- checkInt(this, value, offset, byteLength, limit - 1, -limit) ++ if (this.length === 0) { ++ this.words[0] = 0; ++ this.length = 1; + } + +- var i = 0 +- var mul = 1 +- var sub = value < 0 ? 1 : 0 +- this[offset] = value & 0xFF +- while (++i < byteLength && (mul *= 0x100)) { +- this[offset + i] = ((value / mul) >> 0) - sub & 0xFF +- } ++ this.strip(); + +- return offset + byteLength +-} ++ return this; ++}; + +-Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { +- value = +value +- offset = offset | 0 +- if (!noAssert) { +- var limit = Math.pow(2, 8 * byteLength - 1) ++// Shift-left ++BN.prototype.shln = function shln(bits) { ++ return this.clone().ishln(bits); ++}; + +- checkInt(this, value, offset, byteLength, limit - 1, -limit) +- } ++// Shift-right ++BN.prototype.shrn = function shrn(bits) { ++ return this.clone().ishrn(bits); ++}; + +- var i = byteLength - 1 +- var mul = 1 +- var sub = value < 0 ? 1 : 0 +- this[offset + i] = value & 0xFF +- while (--i >= 0 && (mul *= 0x100)) { +- this[offset + i] = ((value / mul) >> 0) - sub & 0xFF ++// Test if n bit is set ++BN.prototype.testn = function testn(bit) { ++ assert(typeof bit === 'number' && bit >= 0); ++ var r = bit % 26; ++ var s = (bit - r) / 26; ++ var q = 1 << r; ++ ++ // Fast case: bit is much higher than all existing words ++ if (this.length <= s) { ++ return false; + } + +- return offset + byteLength +-} ++ // Check bit and return ++ var w = this.words[s]; + +-Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { +- value = +value +- offset = offset | 0 +- if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) +- if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) +- if (value < 0) value = 0xff + value + 1 +- this[offset] = (value & 0xff) +- return offset + 1 +-} ++ return !!(w & q); ++}; + +-Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { +- value = +value +- offset = offset | 0 +- if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) +- if (Buffer.TYPED_ARRAY_SUPPORT) { +- this[offset] = (value & 0xff) +- this[offset + 1] = (value >>> 8) +- } else { +- objectWriteUInt16(this, value, offset, true) +- } +- return offset + 2 +-} ++// Return only lowers bits of number (in-place) ++BN.prototype.imaskn = function imaskn(bits) { ++ assert(typeof bits === 'number' && bits >= 0); ++ var r = bits % 26; ++ var s = (bits - r) / 26; + +-Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { +- value = +value +- offset = offset | 0 +- if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) +- if (Buffer.TYPED_ARRAY_SUPPORT) { +- this[offset] = (value >>> 8) +- this[offset + 1] = (value & 0xff) +- } else { +- objectWriteUInt16(this, value, offset, false) +- } +- return offset + 2 +-} ++ assert(!this.sign, 'imaskn works only with positive numbers'); + +-Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { +- value = +value +- offset = offset | 0 +- if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) +- if (Buffer.TYPED_ARRAY_SUPPORT) { +- this[offset] = (value & 0xff) +- this[offset + 1] = (value >>> 8) +- this[offset + 2] = (value >>> 16) +- this[offset + 3] = (value >>> 24) +- } else { +- objectWriteUInt32(this, value, offset, true) +- } +- return offset + 4 +-} ++ if (r !== 0) ++ s++; ++ this.length = Math.min(s, this.length); + +-Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { +- value = +value +- offset = offset | 0 +- if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) +- if (value < 0) value = 0xffffffff + value + 1 +- if (Buffer.TYPED_ARRAY_SUPPORT) { +- this[offset] = (value >>> 24) +- this[offset + 1] = (value >>> 16) +- this[offset + 2] = (value >>> 8) +- this[offset + 3] = (value & 0xff) +- } else { +- objectWriteUInt32(this, value, offset, false) ++ if (r !== 0) { ++ var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); ++ this.words[this.length - 1] &= mask; + } +- return offset + 4 +-} + +-function checkIEEE754 (buf, value, offset, ext, max, min) { +- if (offset + ext > buf.length) throw new RangeError('index out of range') +- if (offset < 0) throw new RangeError('index out of range') +-} ++ return this.strip(); ++}; + +-function writeFloat (buf, value, offset, littleEndian, noAssert) { +- if (!noAssert) { +- checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) +- } +- ieee754.write(buf, value, offset, littleEndian, 23, 4) +- return offset + 4 +-} ++// Return only lowers bits of number ++BN.prototype.maskn = function maskn(bits) { ++ return this.clone().imaskn(bits); ++}; + +-Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { +- return writeFloat(this, value, offset, true, noAssert) +-} ++// Add plain number `num` to `this` ++BN.prototype.iaddn = function iaddn(num) { ++ assert(typeof num === 'number'); ++ if (num < 0) ++ return this.isubn(-num); + +-Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { +- return writeFloat(this, value, offset, false, noAssert) +-} ++ // Possible sign change ++ if (this.sign) { ++ if (this.length === 1 && this.words[0] < num) { ++ this.words[0] = num - this.words[0]; ++ this.sign = false; ++ return this; ++ } + +-function writeDouble (buf, value, offset, littleEndian, noAssert) { +- if (!noAssert) { +- checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) ++ this.sign = false; ++ this.isubn(num); ++ this.sign = true; ++ return this; + } +- ieee754.write(buf, value, offset, littleEndian, 52, 8) +- return offset + 8 +-} + +-Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { +- return writeDouble(this, value, offset, true, noAssert) +-} ++ // Add without checks ++ return this._iaddn(num); ++}; + +-Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { +- return writeDouble(this, value, offset, false, noAssert) +-} ++BN.prototype._iaddn = function _iaddn(num) { ++ this.words[0] += num; + +-// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) +-Buffer.prototype.copy = function copy (target, targetStart, start, end) { +- if (!start) start = 0 +- if (!end && end !== 0) end = this.length +- if (targetStart >= target.length) targetStart = target.length +- if (!targetStart) targetStart = 0 +- if (end > 0 && end < start) end = start ++ // Carry ++ for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) { ++ this.words[i] -= 0x4000000; ++ if (i === this.length - 1) ++ this.words[i + 1] = 1; ++ else ++ this.words[i + 1]++; ++ } ++ this.length = Math.max(this.length, i + 1); + +- // Copy 0 bytes; we're done +- if (end === start) return 0 +- if (target.length === 0 || this.length === 0) return 0 ++ return this; ++}; + +- // Fatal error conditions +- if (targetStart < 0) { +- throw new RangeError('targetStart out of bounds') +- } +- if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds') +- if (end < 0) throw new RangeError('sourceEnd out of bounds') ++// Subtract plain number `num` from `this` ++BN.prototype.isubn = function isubn(num) { ++ assert(typeof num === 'number'); ++ if (num < 0) ++ return this.iaddn(-num); + +- // Are we oob? +- if (end > this.length) end = this.length +- if (target.length - targetStart < end - start) { +- end = target.length - targetStart + start ++ if (this.sign) { ++ this.sign = false; ++ this.iaddn(num); ++ this.sign = true; ++ return this; + } + +- var len = end - start +- var i ++ this.words[0] -= num; + +- if (this === target && start < targetStart && targetStart < end) { +- // descending copy from end +- for (i = len - 1; i >= 0; i--) { +- target[i + targetStart] = this[i + start] +- } +- } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { +- // ascending copy from start +- for (i = 0; i < len; i++) { +- target[i + targetStart] = this[i + start] +- } +- } else { +- Uint8Array.prototype.set.call( +- target, +- this.subarray(start, start + len), +- targetStart +- ) ++ // Carry ++ for (var i = 0; i < this.length && this.words[i] < 0; i++) { ++ this.words[i] += 0x4000000; ++ this.words[i + 1] -= 1; + } + +- return len +-} ++ return this.strip(); ++}; + +-// fill(value, start=0, end=buffer.length) +-Buffer.prototype.fill = function fill (value, start, end) { +- if (!value) value = 0 +- if (!start) start = 0 +- if (!end) end = this.length ++BN.prototype.addn = function addn(num) { ++ return this.clone().iaddn(num); ++}; + +- if (end < start) throw new RangeError('end < start') ++BN.prototype.subn = function subn(num) { ++ return this.clone().isubn(num); ++}; + +- // Fill 0 bytes; we're done +- if (end === start) return +- if (this.length === 0) return ++BN.prototype.iabs = function iabs() { ++ this.sign = false; + +- if (start < 0 || start >= this.length) throw new RangeError('start out of bounds') +- if (end < 0 || end > this.length) throw new RangeError('end out of bounds') ++ return this; ++}; + +- var i +- if (typeof value === 'number') { +- for (i = start; i < end; i++) { +- this[i] = value +- } ++BN.prototype.abs = function abs() { ++ return this.clone().iabs(); ++}; ++ ++BN.prototype._ishlnsubmul = function _ishlnsubmul(num, mul, shift) { ++ // Bigger storage is needed ++ var len = num.length + shift; ++ var i; ++ if (this.words.length < len) { ++ var t = new Array(len); ++ for (var i = 0; i < this.length; i++) ++ t[i] = this.words[i]; ++ this.words = t; + } else { +- var bytes = utf8ToBytes(value.toString()) +- var len = bytes.length +- for (i = start; i < end; i++) { +- this[i] = bytes[i % len] +- } ++ i = this.length; + } + +- return this +-} ++ // Zeroify rest ++ this.length = Math.max(this.length, len); ++ for (; i < this.length; i++) ++ this.words[i] = 0; + +-// HELPER FUNCTIONS +-// ================ ++ var carry = 0; ++ for (var i = 0; i < num.length; i++) { ++ var w = this.words[i + shift] + carry; ++ var right = num.words[i] * mul; ++ w -= right & 0x3ffffff; ++ carry = (w >> 26) - ((right / 0x4000000) | 0); ++ this.words[i + shift] = w & 0x3ffffff; ++ } ++ for (; i < this.length - shift; i++) { ++ var w = this.words[i + shift] + carry; ++ carry = w >> 26; ++ this.words[i + shift] = w & 0x3ffffff; ++ } + +-var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g ++ if (carry === 0) ++ return this.strip(); + +-function base64clean (str) { +- // Node strips out invalid characters like \n and \t from the string, base64-js does not +- str = stringtrim(str).replace(INVALID_BASE64_RE, '') +- // Node converts strings with length < 2 to '' +- if (str.length < 2) return '' +- // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not +- while (str.length % 4 !== 0) { +- str = str + '=' ++ // Subtraction overflow ++ assert(carry === -1); ++ carry = 0; ++ for (var i = 0; i < this.length; i++) { ++ var w = -this.words[i] + carry; ++ carry = w >> 26; ++ this.words[i] = w & 0x3ffffff; + } +- return str +-} +- +-function stringtrim (str) { +- if (str.trim) return str.trim() +- return str.replace(/^\s+|\s+$/g, '') +-} ++ this.sign = true; + +-function toHex (n) { +- if (n < 16) return '0' + n.toString(16) +- return n.toString(16) +-} ++ return this.strip(); ++}; + +-function utf8ToBytes (string, units) { +- units = units || Infinity +- var codePoint +- var length = string.length +- var leadSurrogate = null +- var bytes = [] ++BN.prototype._wordDiv = function _wordDiv(num, mode) { ++ var shift = this.length - num.length; + +- for (var i = 0; i < length; i++) { +- codePoint = string.charCodeAt(i) ++ var a = this.clone(); ++ var b = num; + +- // is surrogate component +- if (codePoint > 0xD7FF && codePoint < 0xE000) { +- // last char was a lead +- if (!leadSurrogate) { +- // no lead yet +- if (codePoint > 0xDBFF) { +- // unexpected trail +- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) +- continue +- } else if (i + 1 === length) { +- // unpaired lead +- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) +- continue +- } ++ // Normalize ++ var bhi = b.words[b.length - 1]; ++ var bhiBits = this._countBits(bhi); ++ shift = 26 - bhiBits; ++ if (shift !== 0) { ++ b = b.shln(shift); ++ a.ishln(shift); ++ bhi = b.words[b.length - 1]; ++ } + +- // valid lead +- leadSurrogate = codePoint ++ // Initialize quotient ++ var m = a.length - b.length; ++ var q; + +- continue +- } ++ if (mode !== 'mod') { ++ q = new BN(null); ++ q.length = m + 1; ++ q.words = new Array(q.length); ++ for (var i = 0; i < q.length; i++) ++ q.words[i] = 0; ++ } + +- // 2 leads in a row +- if (codePoint < 0xDC00) { +- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) +- leadSurrogate = codePoint +- continue +- } ++ var diff = a.clone()._ishlnsubmul(b, 1, m); ++ if (!diff.sign) { ++ a = diff; ++ if (q) ++ q.words[m] = 1; ++ } + +- // valid surrogate pair +- codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 +- } else if (leadSurrogate) { +- // valid bmp char, but last char was a lead +- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) +- } ++ for (var j = m - 1; j >= 0; j--) { ++ var qj = a.words[b.length + j] * 0x4000000 + a.words[b.length + j - 1]; + +- leadSurrogate = null ++ // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max ++ // (0x7ffffff) ++ qj = Math.min((qj / bhi) | 0, 0x3ffffff); + +- // encode utf8 +- if (codePoint < 0x80) { +- if ((units -= 1) < 0) break +- bytes.push(codePoint) +- } else if (codePoint < 0x800) { +- if ((units -= 2) < 0) break +- bytes.push( +- codePoint >> 0x6 | 0xC0, +- codePoint & 0x3F | 0x80 +- ) +- } else if (codePoint < 0x10000) { +- if ((units -= 3) < 0) break +- bytes.push( +- codePoint >> 0xC | 0xE0, +- codePoint >> 0x6 & 0x3F | 0x80, +- codePoint & 0x3F | 0x80 +- ) +- } else if (codePoint < 0x110000) { +- if ((units -= 4) < 0) break +- bytes.push( +- codePoint >> 0x12 | 0xF0, +- codePoint >> 0xC & 0x3F | 0x80, +- codePoint >> 0x6 & 0x3F | 0x80, +- codePoint & 0x3F | 0x80 +- ) +- } else { +- throw new Error('Invalid code point') ++ a._ishlnsubmul(b, qj, j); ++ while (a.sign) { ++ qj--; ++ a.sign = false; ++ a._ishlnsubmul(b, 1, j); ++ if (a.cmpn(0) !== 0) ++ a.sign = !a.sign; + } ++ if (q) ++ q.words[j] = qj; + } ++ if (q) ++ q.strip(); ++ a.strip(); + +- return bytes +-} +- +-function asciiToBytes (str) { +- var byteArray = [] +- for (var i = 0; i < str.length; i++) { +- // Node's code seems to be doing this and not & 0x7F.. +- byteArray.push(str.charCodeAt(i) & 0xFF) +- } +- return byteArray +-} ++ // Denormalize ++ if (mode !== 'div' && shift !== 0) ++ a.ishrn(shift); ++ return { div: q ? q : null, mod: a }; ++}; + +-function utf16leToBytes (str, units) { +- var c, hi, lo +- var byteArray = [] +- for (var i = 0; i < str.length; i++) { +- if ((units -= 2) < 0) break ++BN.prototype.divmod = function divmod(num, mode) { ++ assert(num.cmpn(0) !== 0); + +- c = str.charCodeAt(i) +- hi = c >> 8 +- lo = c % 256 +- byteArray.push(lo) +- byteArray.push(hi) ++ if (this.sign && !num.sign) { ++ var res = this.neg().divmod(num, mode); ++ var div; ++ var mod; ++ if (mode !== 'mod') ++ div = res.div.neg(); ++ if (mode !== 'div') ++ mod = res.mod.cmpn(0) === 0 ? res.mod : num.sub(res.mod); ++ return { ++ div: div, ++ mod: mod ++ }; ++ } else if (!this.sign && num.sign) { ++ var res = this.divmod(num.neg(), mode); ++ var div; ++ if (mode !== 'mod') ++ div = res.div.neg(); ++ return { div: div, mod: res.mod }; ++ } else if (this.sign && num.sign) { ++ return this.neg().divmod(num.neg(), mode); + } + +- return byteArray +-} ++ // Both numbers are positive at this point + +-function base64ToBytes (str) { +- return base64.toByteArray(base64clean(str)) +-} ++ // Strip both numbers to approximate shift value ++ if (num.length > this.length || this.cmp(num) < 0) ++ return { div: new BN(0), mod: this }; + +-function blitBuffer (src, dst, offset, length) { +- for (var i = 0; i < length; i++) { +- if ((i + offset >= dst.length) || (i >= src.length)) break +- dst[i + offset] = src[i] ++ // Very short reduction ++ if (num.length === 1) { ++ if (mode === 'div') ++ return { div: this.divn(num.words[0]), mod: null }; ++ else if (mode === 'mod') ++ return { div: null, mod: new BN(this.modn(num.words[0])) }; ++ return { ++ div: this.divn(num.words[0]), ++ mod: new BN(this.modn(num.words[0])) ++ }; + } +- return i +-} + +-}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +-},{"base64-js":11,"ieee754":12,"isarray":13}],11:[function(require,module,exports){ +-'use strict' ++ return this._wordDiv(num, mode); ++}; + +-exports.toByteArray = toByteArray +-exports.fromByteArray = fromByteArray +- +-var lookup = [] +-var revLookup = [] +-var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array +- +-function init () { +- var i +- var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' +- var len = code.length +- +- for (i = 0; i < len; i++) { +- lookup[i] = code[i] +- } +- +- for (i = 0; i < len; ++i) { +- revLookup[code.charCodeAt(i)] = i +- } +- revLookup['-'.charCodeAt(0)] = 62 +- revLookup['_'.charCodeAt(0)] = 63 +-} ++// Find `this` / `num` ++BN.prototype.div = function div(num) { ++ return this.divmod(num, 'div').div; ++}; + +-init() ++// Find `this` % `num` ++BN.prototype.mod = function mod(num) { ++ return this.divmod(num, 'mod').mod; ++}; + +-function toByteArray (b64) { +- var i, j, l, tmp, placeHolders, arr +- var len = b64.length ++// Find Round(`this` / `num`) ++BN.prototype.divRound = function divRound(num) { ++ var dm = this.divmod(num); + +- if (len % 4 > 0) { +- throw new Error('Invalid string. Length must be a multiple of 4') +- } ++ // Fast case - exact division ++ if (dm.mod.cmpn(0) === 0) ++ return dm.div; + +- // the number of equal signs (place holders) +- // if there are two placeholders, than the two characters before it +- // represent one byte +- // if there is only one, then the three characters before it represent 2 bytes +- // this is just a cheap hack to not do indexOf twice +- placeHolders = b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0 ++ var mod = dm.div.sign ? dm.mod.isub(num) : dm.mod; + +- // base64 is 4/3 + up to two characters of the original data +- arr = new Arr(len * 3 / 4 - placeHolders) ++ var half = num.shrn(1); ++ var r2 = num.andln(1); ++ var cmp = mod.cmp(half); + +- // if there are placeholders, only get up to the last complete 4 chars +- l = placeHolders > 0 ? len - 4 : len ++ // Round down ++ if (cmp < 0 || r2 === 1 && cmp === 0) ++ return dm.div; + +- var L = 0 ++ // Round up ++ return dm.div.sign ? dm.div.isubn(1) : dm.div.iaddn(1); ++}; + +- for (i = 0, j = 0; i < l; i += 4, j += 3) { +- tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)] +- arr[L++] = (tmp & 0xFF0000) >> 16 +- arr[L++] = (tmp & 0xFF00) >> 8 +- arr[L++] = tmp & 0xFF +- } ++BN.prototype.modn = function modn(num) { ++ assert(num <= 0x3ffffff); ++ var p = (1 << 26) % num; + +- if (placeHolders === 2) { +- tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4) +- arr[L++] = tmp & 0xFF +- } else if (placeHolders === 1) { +- tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2) +- arr[L++] = (tmp >> 8) & 0xFF +- arr[L++] = tmp & 0xFF +- } ++ var acc = 0; ++ for (var i = this.length - 1; i >= 0; i--) ++ acc = (p * acc + this.words[i]) % num; + +- return arr +-} ++ return acc; ++}; + +-function tripletToBase64 (num) { +- return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F] +-} ++// In-place division by number ++BN.prototype.idivn = function idivn(num) { ++ assert(num <= 0x3ffffff); + +-function encodeChunk (uint8, start, end) { +- var tmp +- var output = [] +- for (var i = start; i < end; i += 3) { +- tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]) +- output.push(tripletToBase64(tmp)) ++ var carry = 0; ++ for (var i = this.length - 1; i >= 0; i--) { ++ var w = this.words[i] + carry * 0x4000000; ++ this.words[i] = (w / num) | 0; ++ carry = w % num; + } +- return output.join('') +-} +- +-function fromByteArray (uint8) { +- var tmp +- var len = uint8.length +- var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes +- var output = '' +- var parts = [] +- var maxChunkLength = 16383 // must be multiple of 3 + +- // go through the array every three bytes, we'll deal with trailing stuff later +- for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { +- parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))) +- } ++ return this.strip(); ++}; + +- // pad the end with zeros, but make sure to not forget the extra bytes +- if (extraBytes === 1) { +- tmp = uint8[len - 1] +- output += lookup[tmp >> 2] +- output += lookup[(tmp << 4) & 0x3F] +- output += '==' +- } else if (extraBytes === 2) { +- tmp = (uint8[len - 2] << 8) + (uint8[len - 1]) +- output += lookup[tmp >> 10] +- output += lookup[(tmp >> 4) & 0x3F] +- output += lookup[(tmp << 2) & 0x3F] +- output += '=' +- } ++BN.prototype.divn = function divn(num) { ++ return this.clone().idivn(num); ++}; + +- parts.push(output) ++BN.prototype.egcd = function egcd(p) { ++ assert(!p.sign); ++ assert(p.cmpn(0) !== 0); + +- return parts.join('') +-} ++ var x = this; ++ var y = p.clone(); + +-},{}],12:[function(require,module,exports){ +-exports.read = function (buffer, offset, isLE, mLen, nBytes) { +- var e, m +- var eLen = nBytes * 8 - mLen - 1 +- var eMax = (1 << eLen) - 1 +- var eBias = eMax >> 1 +- var nBits = -7 +- var i = isLE ? (nBytes - 1) : 0 +- var d = isLE ? -1 : 1 +- var s = buffer[offset + i] ++ if (x.sign) ++ x = x.mod(p); ++ else ++ x = x.clone(); + +- i += d ++ // A * x + B * y = x ++ var A = new BN(1); ++ var B = new BN(0); + +- e = s & ((1 << (-nBits)) - 1) +- s >>= (-nBits) +- nBits += eLen +- for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {} ++ // C * x + D * y = y ++ var C = new BN(0); ++ var D = new BN(1); + +- m = e & ((1 << (-nBits)) - 1) +- e >>= (-nBits) +- nBits += mLen +- for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {} ++ var g = 0; + +- if (e === 0) { +- e = 1 - eBias +- } else if (e === eMax) { +- return m ? NaN : ((s ? -1 : 1) * Infinity) +- } else { +- m = m + Math.pow(2, mLen) +- e = e - eBias ++ while (x.isEven() && y.isEven()) { ++ x.ishrn(1); ++ y.ishrn(1); ++ ++g; + } +- return (s ? -1 : 1) * m * Math.pow(2, e - mLen) +-} +- +-exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { +- var e, m, c +- var eLen = nBytes * 8 - mLen - 1 +- var eMax = (1 << eLen) - 1 +- var eBias = eMax >> 1 +- var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) +- var i = isLE ? 0 : (nBytes - 1) +- var d = isLE ? 1 : -1 +- var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 + +- value = Math.abs(value) ++ var yp = y.clone(); ++ var xp = x.clone(); + +- if (isNaN(value) || value === Infinity) { +- m = isNaN(value) ? 1 : 0 +- e = eMax +- } else { +- e = Math.floor(Math.log(value) / Math.LN2) +- if (value * (c = Math.pow(2, -e)) < 1) { +- e-- +- c *= 2 +- } +- if (e + eBias >= 1) { +- value += rt / c +- } else { +- value += rt * Math.pow(2, 1 - eBias) ++ while (x.cmpn(0) !== 0) { ++ while (x.isEven()) { ++ x.ishrn(1); ++ if (A.isEven() && B.isEven()) { ++ A.ishrn(1); ++ B.ishrn(1); ++ } else { ++ A.iadd(yp).ishrn(1); ++ B.isub(xp).ishrn(1); ++ } + } +- if (value * c >= 2) { +- e++ +- c /= 2 ++ ++ while (y.isEven()) { ++ y.ishrn(1); ++ if (C.isEven() && D.isEven()) { ++ C.ishrn(1); ++ D.ishrn(1); ++ } else { ++ C.iadd(yp).ishrn(1); ++ D.isub(xp).ishrn(1); ++ } + } + +- if (e + eBias >= eMax) { +- m = 0 +- e = eMax +- } else if (e + eBias >= 1) { +- m = (value * c - 1) * Math.pow(2, mLen) +- e = e + eBias ++ if (x.cmp(y) >= 0) { ++ x.isub(y); ++ A.isub(C); ++ B.isub(D); + } else { +- m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) +- e = 0 ++ y.isub(x); ++ C.isub(A); ++ D.isub(B); + } + } + +- for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} +- +- e = (e << mLen) | m +- eLen += mLen +- for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} +- +- buffer[offset + i - d] |= s * 128 +-} +- +-},{}],13:[function(require,module,exports){ +-var toString = {}.toString; +- +-module.exports = Array.isArray || function (arr) { +- return toString.call(arr) == '[object Array]'; ++ return { ++ a: C, ++ b: D, ++ gcd: y.ishln(g) ++ }; + }; + +-},{}],14:[function(require,module,exports){ +-// Copyright Joyent, Inc. and other Node contributors. +-// +-// Permission is hereby granted, free of charge, to any person obtaining a +-// copy of this software and associated documentation files (the +-// "Software"), to deal in the Software without restriction, including +-// without limitation the rights to use, copy, modify, merge, publish, +-// distribute, sublicense, and/or sell copies of the Software, and to permit +-// persons to whom the Software is furnished to do so, subject to the +-// following conditions: +-// +-// The above copyright notice and this permission notice shall be included +-// in all copies or substantial portions of the Software. +-// +-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +-// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +-// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +-// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +-// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +-// USE OR OTHER DEALINGS IN THE SOFTWARE. ++// This is reduced incarnation of the binary EEA ++// above, designated to invert members of the ++// _prime_ fields F(p) at a maximal speed ++BN.prototype._invmp = function _invmp(p) { ++ assert(!p.sign); ++ assert(p.cmpn(0) !== 0); + +-function EventEmitter() { +- this._events = this._events || {}; +- this._maxListeners = this._maxListeners || undefined; +-} +-module.exports = EventEmitter; ++ var a = this; ++ var b = p.clone(); + +-// Backwards-compat with node 0.10.x +-EventEmitter.EventEmitter = EventEmitter; ++ if (a.sign) ++ a = a.mod(p); ++ else ++ a = a.clone(); + +-EventEmitter.prototype._events = undefined; +-EventEmitter.prototype._maxListeners = undefined; ++ var x1 = new BN(1); ++ var x2 = new BN(0); + +-// By default EventEmitters will print a warning if more than 10 listeners are +-// added to it. This is a useful default which helps finding memory leaks. +-EventEmitter.defaultMaxListeners = 10; ++ var delta = b.clone(); + +-// Obviously not all Emitters should be limited to 10. This function allows +-// that to be increased. Set to zero for unlimited. +-EventEmitter.prototype.setMaxListeners = function(n) { +- if (!isNumber(n) || n < 0 || isNaN(n)) +- throw TypeError('n must be a positive number'); +- this._maxListeners = n; +- return this; ++ while (a.cmpn(1) > 0 && b.cmpn(1) > 0) { ++ while (a.isEven()) { ++ a.ishrn(1); ++ if (x1.isEven()) ++ x1.ishrn(1); ++ else ++ x1.iadd(delta).ishrn(1); ++ } ++ while (b.isEven()) { ++ b.ishrn(1); ++ if (x2.isEven()) ++ x2.ishrn(1); ++ else ++ x2.iadd(delta).ishrn(1); ++ } ++ if (a.cmp(b) >= 0) { ++ a.isub(b); ++ x1.isub(x2); ++ } else { ++ b.isub(a); ++ x2.isub(x1); ++ } ++ } ++ if (a.cmpn(1) === 0) ++ return x1; ++ else ++ return x2; + }; + +-EventEmitter.prototype.emit = function(type) { +- var er, handler, len, args, i, listeners; ++BN.prototype.gcd = function gcd(num) { ++ if (this.cmpn(0) === 0) ++ return num.clone(); ++ if (num.cmpn(0) === 0) ++ return this.clone(); + +- if (!this._events) +- this._events = {}; ++ var a = this.clone(); ++ var b = num.clone(); ++ a.sign = false; ++ b.sign = false; + +- // If there is no 'error' event listener then throw. +- if (type === 'error') { +- if (!this._events.error || +- (isObject(this._events.error) && !this._events.error.length)) { +- er = arguments[1]; +- if (er instanceof Error) { +- throw er; // Unhandled 'error' event +- } +- throw TypeError('Uncaught, unspecified "error" event.'); +- } ++ // Remove common factor of two ++ for (var shift = 0; a.isEven() && b.isEven(); shift++) { ++ a.ishrn(1); ++ b.ishrn(1); + } + +- handler = this._events[type]; +- +- if (isUndefined(handler)) +- return false; ++ do { ++ while (a.isEven()) ++ a.ishrn(1); ++ while (b.isEven()) ++ b.ishrn(1); + +- if (isFunction(handler)) { +- switch (arguments.length) { +- // fast cases +- case 1: +- handler.call(this); +- break; +- case 2: +- handler.call(this, arguments[1]); +- break; +- case 3: +- handler.call(this, arguments[1], arguments[2]); +- break; +- // slower +- default: +- args = Array.prototype.slice.call(arguments, 1); +- handler.apply(this, args); ++ var r = a.cmp(b); ++ if (r < 0) { ++ // Swap `a` and `b` to make `a` always bigger than `b` ++ var t = a; ++ a = b; ++ b = t; ++ } else if (r === 0 || b.cmpn(1) === 0) { ++ break; + } +- } else if (isObject(handler)) { +- args = Array.prototype.slice.call(arguments, 1); +- listeners = handler.slice(); +- len = listeners.length; +- for (i = 0; i < len; i++) +- listeners[i].apply(this, args); +- } + +- return true; +-}; ++ a.isub(b); ++ } while (true); + +-EventEmitter.prototype.addListener = function(type, listener) { +- var m; ++ return b.ishln(shift); ++}; + +- if (!isFunction(listener)) +- throw TypeError('listener must be a function'); ++// Invert number in the field F(num) ++BN.prototype.invm = function invm(num) { ++ return this.egcd(num).a.mod(num); ++}; + +- if (!this._events) +- this._events = {}; ++BN.prototype.isEven = function isEven() { ++ return (this.words[0] & 1) === 0; ++}; + +- // To avoid recursion in the case that type === "newListener"! Before +- // adding it to the listeners, first emit "newListener". +- if (this._events.newListener) +- this.emit('newListener', type, +- isFunction(listener.listener) ? +- listener.listener : listener); ++BN.prototype.isOdd = function isOdd() { ++ return (this.words[0] & 1) === 1; ++}; + +- if (!this._events[type]) +- // Optimize the case of one listener. Don't need the extra array object. +- this._events[type] = listener; +- else if (isObject(this._events[type])) +- // If we've already got an array, just append. +- this._events[type].push(listener); +- else +- // Adding the second element, need to change to array. +- this._events[type] = [this._events[type], listener]; ++// And first word and num ++BN.prototype.andln = function andln(num) { ++ return this.words[0] & num; ++}; + +- // Check for listener leak +- if (isObject(this._events[type]) && !this._events[type].warned) { +- if (!isUndefined(this._maxListeners)) { +- m = this._maxListeners; +- } else { +- m = EventEmitter.defaultMaxListeners; +- } ++// Increment at the bit position in-line ++BN.prototype.bincn = function bincn(bit) { ++ assert(typeof bit === 'number'); ++ var r = bit % 26; ++ var s = (bit - r) / 26; ++ var q = 1 << r; + +- if (m && m > 0 && this._events[type].length > m) { +- this._events[type].warned = true; +- console.error('(node) warning: possible EventEmitter memory ' + +- 'leak detected. %d listeners added. ' + +- 'Use emitter.setMaxListeners() to increase limit.', +- this._events[type].length); +- if (typeof console.trace === 'function') { +- // not supported in IE 10 +- console.trace(); +- } +- } ++ // Fast case: bit is much higher than all existing words ++ if (this.length <= s) { ++ for (var i = this.length; i < s + 1; i++) ++ this.words[i] = 0; ++ this.words[s] |= q; ++ this.length = s + 1; ++ return this; + } + ++ // Add bit and propagate, if needed ++ var carry = q; ++ for (var i = s; carry !== 0 && i < this.length; i++) { ++ var w = this.words[i]; ++ w += carry; ++ carry = w >>> 26; ++ w &= 0x3ffffff; ++ this.words[i] = w; ++ } ++ if (carry !== 0) { ++ this.words[i] = carry; ++ this.length++; ++ } + return this; + }; + +-EventEmitter.prototype.on = EventEmitter.prototype.addListener; ++BN.prototype.cmpn = function cmpn(num) { ++ var sign = num < 0; ++ if (sign) ++ num = -num; + +-EventEmitter.prototype.once = function(type, listener) { +- if (!isFunction(listener)) +- throw TypeError('listener must be a function'); ++ if (this.sign && !sign) ++ return -1; ++ else if (!this.sign && sign) ++ return 1; + +- var fired = false; ++ num &= 0x3ffffff; ++ this.strip(); + +- function g() { +- this.removeListener(type, g); +- +- if (!fired) { +- fired = true; +- listener.apply(this, arguments); +- } ++ var res; ++ if (this.length > 1) { ++ res = 1; ++ } else { ++ var w = this.words[0]; ++ res = w === num ? 0 : w < num ? -1 : 1; + } +- +- g.listener = listener; +- this.on(type, g); +- +- return this; ++ if (this.sign) ++ res = -res; ++ return res; + }; + +-// emits a 'removeListener' event iff the listener was removed +-EventEmitter.prototype.removeListener = function(type, listener) { +- var list, position, length, i; +- +- if (!isFunction(listener)) +- throw TypeError('listener must be a function'); +- +- if (!this._events || !this._events[type]) +- return this; +- +- list = this._events[type]; +- length = list.length; +- position = -1; +- +- if (list === listener || +- (isFunction(list.listener) && list.listener === listener)) { +- delete this._events[type]; +- if (this._events.removeListener) +- this.emit('removeListener', type, listener); +- +- } else if (isObject(list)) { +- for (i = length; i-- > 0;) { +- if (list[i] === listener || +- (list[i].listener && list[i].listener === listener)) { +- position = i; +- break; +- } +- } +- +- if (position < 0) +- return this; +- +- if (list.length === 1) { +- list.length = 0; +- delete this._events[type]; +- } else { +- list.splice(position, 1); +- } +- +- if (this._events.removeListener) +- this.emit('removeListener', type, listener); +- } ++// Compare two numbers and return: ++// 1 - if `this` > `num` ++// 0 - if `this` == `num` ++// -1 - if `this` < `num` ++BN.prototype.cmp = function cmp(num) { ++ if (this.sign && !num.sign) ++ return -1; ++ else if (!this.sign && num.sign) ++ return 1; + +- return this; ++ var res = this.ucmp(num); ++ if (this.sign) ++ return -res; ++ else ++ return res; + }; + +-EventEmitter.prototype.removeAllListeners = function(type) { +- var key, listeners; ++// Unsigned comparison ++BN.prototype.ucmp = function ucmp(num) { ++ // At this point both numbers have the same sign ++ if (this.length > num.length) ++ return 1; ++ else if (this.length < num.length) ++ return -1; + +- if (!this._events) +- return this; ++ var res = 0; ++ for (var i = this.length - 1; i >= 0; i--) { ++ var a = this.words[i]; ++ var b = num.words[i]; + +- // not listening for removeListener, no need to emit +- if (!this._events.removeListener) { +- if (arguments.length === 0) +- this._events = {}; +- else if (this._events[type]) +- delete this._events[type]; +- return this; ++ if (a === b) ++ continue; ++ if (a < b) ++ res = -1; ++ else if (a > b) ++ res = 1; ++ break; + } ++ return res; ++}; + +- // emit removeListener for all listeners on all events +- if (arguments.length === 0) { +- for (key in this._events) { +- if (key === 'removeListener') continue; +- this.removeAllListeners(key); +- } +- this.removeAllListeners('removeListener'); +- this._events = {}; +- return this; +- } ++// ++// A reduce context, could be using montgomery or something better, depending ++// on the `m` itself. ++// ++BN.red = function red(num) { ++ return new Red(num); ++}; + +- listeners = this._events[type]; ++BN.prototype.toRed = function toRed(ctx) { ++ assert(!this.red, 'Already a number in reduction context'); ++ assert(!this.sign, 'red works only with positives'); ++ return ctx.convertTo(this)._forceRed(ctx); ++}; + +- if (isFunction(listeners)) { +- this.removeListener(type, listeners); +- } else if (listeners) { +- // LIFO order +- while (listeners.length) +- this.removeListener(type, listeners[listeners.length - 1]); +- } +- delete this._events[type]; ++BN.prototype.fromRed = function fromRed() { ++ assert(this.red, 'fromRed works only with numbers in reduction context'); ++ return this.red.convertFrom(this); ++}; + ++BN.prototype._forceRed = function _forceRed(ctx) { ++ this.red = ctx; + return this; + }; + +-EventEmitter.prototype.listeners = function(type) { +- var ret; +- if (!this._events || !this._events[type]) +- ret = []; +- else if (isFunction(this._events[type])) +- ret = [this._events[type]]; +- else +- ret = this._events[type].slice(); +- return ret; ++BN.prototype.forceRed = function forceRed(ctx) { ++ assert(!this.red, 'Already a number in reduction context'); ++ return this._forceRed(ctx); + }; + +-EventEmitter.prototype.listenerCount = function(type) { +- if (this._events) { +- var evlistener = this._events[type]; +- +- if (isFunction(evlistener)) +- return 1; +- else if (evlistener) +- return evlistener.length; +- } +- return 0; ++BN.prototype.redAdd = function redAdd(num) { ++ assert(this.red, 'redAdd works only with red numbers'); ++ return this.red.add(this, num); + }; + +-EventEmitter.listenerCount = function(emitter, type) { +- return emitter.listenerCount(type); ++BN.prototype.redIAdd = function redIAdd(num) { ++ assert(this.red, 'redIAdd works only with red numbers'); ++ return this.red.iadd(this, num); + }; + +-function isFunction(arg) { +- return typeof arg === 'function'; +-} +- +-function isNumber(arg) { +- return typeof arg === 'number'; +-} +- +-function isObject(arg) { +- return typeof arg === 'object' && arg !== null; +-} +- +-function isUndefined(arg) { +- return arg === void 0; +-} +- +-},{}],15:[function(require,module,exports){ +-// shim for using process in browser +- +-var process = module.exports = {}; +-var queue = []; +-var draining = false; +-var currentQueue; +-var queueIndex = -1; +- +-function cleanUpNextTick() { +- draining = false; +- if (currentQueue.length) { +- queue = currentQueue.concat(queue); +- } else { +- queueIndex = -1; +- } +- if (queue.length) { +- drainQueue(); +- } +-} ++BN.prototype.redSub = function redSub(num) { ++ assert(this.red, 'redSub works only with red numbers'); ++ return this.red.sub(this, num); ++}; + +-function drainQueue() { +- if (draining) { +- return; +- } +- var timeout = setTimeout(cleanUpNextTick); +- draining = true; ++BN.prototype.redISub = function redISub(num) { ++ assert(this.red, 'redISub works only with red numbers'); ++ return this.red.isub(this, num); ++}; + +- var len = queue.length; +- while(len) { +- currentQueue = queue; +- queue = []; +- while (++queueIndex < len) { +- if (currentQueue) { +- currentQueue[queueIndex].run(); +- } +- } +- queueIndex = -1; +- len = queue.length; +- } +- currentQueue = null; +- draining = false; +- clearTimeout(timeout); +-} ++BN.prototype.redShl = function redShl(num) { ++ assert(this.red, 'redShl works only with red numbers'); ++ return this.red.shl(this, num); ++}; + +-process.nextTick = function (fun) { +- var args = new Array(arguments.length - 1); +- if (arguments.length > 1) { +- for (var i = 1; i < arguments.length; i++) { +- args[i - 1] = arguments[i]; +- } +- } +- queue.push(new Item(fun, args)); +- if (queue.length === 1 && !draining) { +- setTimeout(drainQueue, 0); +- } ++BN.prototype.redMul = function redMul(num) { ++ assert(this.red, 'redMul works only with red numbers'); ++ this.red._verify2(this, num); ++ return this.red.mul(this, num); + }; + +-// v8 likes predictible objects +-function Item(fun, array) { +- this.fun = fun; +- this.array = array; +-} +-Item.prototype.run = function () { +- this.fun.apply(null, this.array); ++BN.prototype.redIMul = function redIMul(num) { ++ assert(this.red, 'redMul works only with red numbers'); ++ this.red._verify2(this, num); ++ return this.red.imul(this, num); + }; +-process.title = 'browser'; +-process.browser = true; +-process.env = {}; +-process.argv = []; +-process.version = ''; // empty string to avoid regexp issues +-process.versions = {}; + +-function noop() {} ++BN.prototype.redSqr = function redSqr() { ++ assert(this.red, 'redSqr works only with red numbers'); ++ this.red._verify1(this); ++ return this.red.sqr(this); ++}; + +-process.on = noop; +-process.addListener = noop; +-process.once = noop; +-process.off = noop; +-process.removeListener = noop; +-process.removeAllListeners = noop; +-process.emit = noop; ++BN.prototype.redISqr = function redISqr() { ++ assert(this.red, 'redISqr works only with red numbers'); ++ this.red._verify1(this); ++ return this.red.isqr(this); ++}; + +-process.binding = function (name) { +- throw new Error('process.binding is not supported'); ++// Square root over p ++BN.prototype.redSqrt = function redSqrt() { ++ assert(this.red, 'redSqrt works only with red numbers'); ++ this.red._verify1(this); ++ return this.red.sqrt(this); + }; + +-process.cwd = function () { return '/' }; +-process.chdir = function (dir) { +- throw new Error('process.chdir is not supported'); ++BN.prototype.redInvm = function redInvm() { ++ assert(this.red, 'redInvm works only with red numbers'); ++ this.red._verify1(this); ++ return this.red.invm(this); + }; +-process.umask = function() { return 0; }; + +-},{}],16:[function(require,module,exports){ +-'use strict' ++// Return negative clone of `this` % `red modulo` ++BN.prototype.redNeg = function redNeg() { ++ assert(this.red, 'redNeg works only with red numbers'); ++ this.red._verify1(this); ++ return this.red.neg(this); ++}; + +-var monotoneTriangulate = require('./lib/monotone') +-var makeIndex = require('./lib/triangulation') +-var delaunayFlip = require('./lib/delaunay') +-var filterTriangulation = require('./lib/filter') ++BN.prototype.redPow = function redPow(num) { ++ assert(this.red && !num.red, 'redPow(normalNum)'); ++ this.red._verify1(this); ++ return this.red.pow(this, num); ++}; + +-module.exports = cdt2d ++// Prime numbers with efficient reduction ++var primes = { ++ k256: null, ++ p224: null, ++ p192: null, ++ p25519: null ++}; + +-function canonicalizeEdge(e) { +- return [Math.min(e[0], e[1]), Math.max(e[0], e[1])] +-} ++// Pseudo-Mersenne prime ++function MPrime(name, p) { ++ // P = 2 ^ N - K ++ this.name = name; ++ this.p = new BN(p, 16); ++ this.n = this.p.bitLength(); ++ this.k = new BN(1).ishln(this.n).isub(this.p); + +-function compareEdge(a, b) { +- return a[0]-b[0] || a[1]-b[1] ++ this.tmp = this._tmp(); + } + +-function canonicalizeEdges(edges) { +- return edges.map(canonicalizeEdge).sort(compareEdge) +-} ++MPrime.prototype._tmp = function _tmp() { ++ var tmp = new BN(null); ++ tmp.words = new Array(Math.ceil(this.n / 13)); ++ return tmp; ++}; + +-function getDefault(options, property, dflt) { +- if(property in options) { +- return options[property] +- } +- return dflt +-} ++MPrime.prototype.ireduce = function ireduce(num) { ++ // Assumes that `num` is less than `P^2` ++ // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P) ++ var r = num; ++ var rlen; + +-function cdt2d(points, edges, options) { ++ do { ++ this.split(r, this.tmp); ++ r = this.imulK(r); ++ r = r.iadd(this.tmp); ++ rlen = r.bitLength(); ++ } while (rlen > this.n); + +- if(!Array.isArray(edges)) { +- options = edges || {} +- edges = [] ++ var cmp = rlen < this.n ? -1 : r.ucmp(this.p); ++ if (cmp === 0) { ++ r.words[0] = 0; ++ r.length = 1; ++ } else if (cmp > 0) { ++ r.isub(this.p); + } else { +- options = options || {} +- edges = edges || [] ++ r.strip(); + } + +- //Parse out options +- var delaunay = !!getDefault(options, 'delaunay', true) +- var interior = !!getDefault(options, 'interior', true) +- var exterior = !!getDefault(options, 'exterior', true) +- var infinity = !!getDefault(options, 'infinity', false) ++ return r; ++}; + +- //Handle trivial case +- if((!interior && !exterior) || points.length === 0) { +- return [] +- } ++MPrime.prototype.split = function split(input, out) { ++ input.ishrn(this.n, 0, out); ++}; + +- //Construct initial triangulation +- var cells = monotoneTriangulate(points, edges) ++MPrime.prototype.imulK = function imulK(num) { ++ return num.imul(this.k); ++}; + +- //If delaunay refinement needed, then improve quality by edge flipping +- if(delaunay || interior !== exterior || infinity) { ++function K256() { ++ MPrime.call( ++ this, ++ 'k256', ++ 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f'); ++} ++inherits(K256, MPrime); + +- //Index all of the cells to support fast neighborhood queries +- var triangulation = makeIndex(points.length, canonicalizeEdges(edges)) +- for(var i=0; i>> 22); ++ prev = next; ++ } ++ input.words[i - 10] = prev >>> 22; ++ input.length -= 9; ++}; + +-module.exports = delaunayRefine ++K256.prototype.imulK = function imulK(num) { ++ // K = 0x1000003d1 = [ 0x40, 0x3d1 ] ++ num.words[num.length] = 0; ++ num.words[num.length + 1] = 0; ++ num.length += 2; + +-function testFlip(points, triangulation, stack, a, b, x) { +- var y = triangulation.opposite(a, b) ++ // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390 ++ var hi; ++ var lo = 0; ++ for (var i = 0; i < num.length; i++) { ++ var w = num.words[i]; ++ hi = w * 0x40; ++ lo += w * 0x3d1; ++ hi += (lo / 0x4000000) | 0; ++ lo &= 0x3ffffff; + +- //Test boundary edge +- if(y < 0) { +- return +- } ++ num.words[i] = lo; + +- //Swap edge if order flipped +- if(b < a) { +- var tmp = a +- a = b +- b = tmp +- tmp = x +- x = y +- y = tmp ++ lo = hi; + } + +- //Test if edge is constrained +- if(triangulation.isConstraint(a, b)) { +- return ++ // Fast length reduction ++ if (num.words[num.length - 1] === 0) { ++ num.length--; ++ if (num.words[num.length - 1] === 0) ++ num.length--; + } ++ return num; ++}; + +- //Test if edge is delaunay +- if(inCircle(points[a], points[b], points[x], points[y]) < 0) { +- stack.push(a, b) +- } ++function P224() { ++ MPrime.call( ++ this, ++ 'p224', ++ 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001'); + } ++inherits(P224, MPrime); + +-//Assume edges are sorted lexicographically +-function delaunayRefine(points, triangulation) { +- var stack = [] ++function P192() { ++ MPrime.call( ++ this, ++ 'p192', ++ 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff'); ++} ++inherits(P192, MPrime); + +- var numPoints = points.length +- var stars = triangulation.stars +- for(var a=0; a>>= 26; + +- //Check if edge is constrained +- if(triangulation.isConstraint(a, b)) { +- continue +- } ++ num.words[i] = lo; ++ carry = hi; ++ } ++ if (carry !== 0) ++ num.words[num.length++] = carry; ++ return num; ++}; + +- //Find opposite edge +- var x = star[j-1], y = -1 +- for(var k=1; k 0) { +- var b = stack.pop() +- var a = stack.pop() ++Red.prototype._verify1 = function _verify1(a) { ++ assert(!a.sign, 'red works only with positives'); ++ assert(a.red, 'red works only with red numbers'); ++}; + +- //Find opposite pairs +- var x = -1, y = -1 +- var star = stars[a] +- for(var i=1; i= 0) { +- continue +- } ++Red.prototype.neg = function neg(a) { ++ var r = a.clone(); ++ r.sign = !r.sign; ++ return r.iadd(this.m)._forceRed(this); ++}; + +- //Flip the edge +- triangulation.flip(a, b) ++Red.prototype.add = function add(a, b) { ++ this._verify2(a, b); + +- //Test flipping neighboring edges +- testFlip(points, triangulation, stack, x, a, y) +- testFlip(points, triangulation, stack, a, y, x) +- testFlip(points, triangulation, stack, y, b, x) +- testFlip(points, triangulation, stack, b, x, y) +- } +-} ++ var res = a.add(b); ++ if (res.cmp(this.m) >= 0) ++ res.isub(this.m); ++ return res._forceRed(this); ++}; + +-},{"binary-search-bounds":21,"robust-in-sphere":22}],18:[function(require,module,exports){ +-'use strict' ++Red.prototype.iadd = function iadd(a, b) { ++ this._verify2(a, b); + +-var bsearch = require('binary-search-bounds') ++ var res = a.iadd(b); ++ if (res.cmp(this.m) >= 0) ++ res.isub(this.m); ++ return res; ++}; + +-module.exports = classifyFaces ++Red.prototype.sub = function sub(a, b) { ++ this._verify2(a, b); + +-function FaceIndex(cells, neighbor, constraint, flags, active, next, boundary) { +- this.cells = cells +- this.neighbor = neighbor +- this.flags = flags +- this.constraint = constraint +- this.active = active +- this.next = next +- this.boundary = boundary +-} ++ var res = a.sub(b); ++ if (res.cmpn(0) < 0) ++ res.iadd(this.m); ++ return res._forceRed(this); ++}; + +-var proto = FaceIndex.prototype ++Red.prototype.isub = function isub(a, b) { ++ this._verify2(a, b); + +-function compareCell(a, b) { +- return a[0] - b[0] || +- a[1] - b[1] || +- a[2] - b[2] +-} ++ var res = a.isub(b); ++ if (res.cmpn(0) < 0) ++ res.iadd(this.m); ++ return res; ++}; + +-proto.locate = (function() { +- var key = [0,0,0] +- return function(a, b, c) { +- var x = a, y = b, z = c +- if(b < c) { +- if(b < a) { +- x = b +- y = c +- z = a +- } +- } else if(c < a) { +- x = c +- y = a +- z = b +- } +- if(x < 0) { +- return -1 +- } +- key[0] = x +- key[1] = y +- key[2] = z +- return bsearch.eq(this.cells, key, compareCell) +- } +-})() ++Red.prototype.shl = function shl(a, num) { ++ this._verify1(a); ++ return this.imod(a.shln(num)); ++}; + +-function indexCells(triangulation, infinity) { +- //First get cells and canonicalize +- var cells = triangulation.cells() +- var nc = cells.length +- for(var i=0; i 0 || next.length > 0) { +- while(active.length > 0) { +- var t = active.pop() +- if(flags[t] === -side) { +- continue +- } +- flags[t] = side +- var c = cells[t] +- for(var j=0; j<3; ++j) { +- var f = neighbor[3*t+j] +- if(f >= 0 && flags[f] === 0) { +- if(constraint[3*t+j]) { +- next.push(f) +- } else { +- active.push(f) +- flags[f] = side +- } +- } +- } +- } ++ if (num.cmpn(0) === 0) ++ return new BN(1); + +- //Swap arrays and loop +- var tmp = next +- next = active +- active = tmp +- next.length = 0 +- side = -side ++ var q = num.clone(); ++ ++ while (q.cmpn(0) !== 0) { ++ w.push(q.andln(1)); ++ q.ishrn(1); + } + +- var result = filterCells(cells, flags, target) +- if(infinity) { +- return result.concat(index.boundary) ++ // Skip leading zeroes ++ var res = a; ++ for (var i = 0; i < w.length; i++, res = this.sqr(res)) ++ if (w[i] !== 0) ++ break; ++ ++ if (++i < w.length) { ++ for (var q = this.sqr(res); i < w.length; i++, q = this.sqr(q)) { ++ if (w[i] === 0) ++ continue; ++ res = this.mul(res, q); ++ } + } +- return result +-} + +-},{"binary-search-bounds":21}],19:[function(require,module,exports){ +-'use strict' ++ return res; ++}; + +-var bsearch = require('binary-search-bounds') +-var orient = require('robust-orientation')[3] ++Red.prototype.convertTo = function convertTo(num) { ++ var r = num.mod(this.m); ++ if (r === num) ++ return r.clone(); ++ else ++ return r; ++}; + +-var EVENT_POINT = 0 +-var EVENT_END = 1 +-var EVENT_START = 2 ++Red.prototype.convertFrom = function convertFrom(num) { ++ var res = num.clone(); ++ res.red = null; ++ return res; ++}; + +-module.exports = monotoneTriangulate ++// ++// Montgomery method engine ++// + +-//A partial convex hull fragment, made of two unimonotone polygons +-function PartialHull(a, b, idx, lowerIds, upperIds) { +- this.a = a +- this.b = b +- this.idx = idx +- this.lowerIds = lowerIds +- this.upperIds = upperIds +-} ++BN.mont = function mont(num) { ++ return new Mont(num); ++}; + +-//An event in the sweep line procedure +-function Event(a, b, type, idx) { +- this.a = a +- this.b = b +- this.type = type +- this.idx = idx +-} ++function Mont(m) { ++ Red.call(this, m); + +-//This is used to compare events for the sweep line procedure +-// Points are: +-// 1. sorted lexicographically +-// 2. sorted by type (point < end < start) +-// 3. segments sorted by winding order +-// 4. sorted by index +-function compareEvent(a, b) { +- var d = +- (a.a[0] - b.a[0]) || +- (a.a[1] - b.a[1]) || +- (a.type - b.type) +- if(d) { return d } +- if(a.type !== EVENT_POINT) { +- d = orient(a.a, a.b, b.b) +- if(d) { return d } +- } +- return a.idx - b.idx +-} ++ this.shift = this.m.bitLength(); ++ if (this.shift % 26 !== 0) ++ this.shift += 26 - (this.shift % 26); ++ this.r = new BN(1).ishln(this.shift); ++ this.r2 = this.imod(this.r.sqr()); ++ this.rinv = this.r._invmp(this.m); + +-function testPoint(hull, p) { +- return orient(hull.a, hull.b, p) ++ this.minv = this.rinv.mul(this.r).isubn(1).div(this.m); ++ this.minv.sign = true; ++ this.minv = this.minv.mod(this.r); + } ++inherits(Mont, Red); + +-function addPoint(cells, hulls, points, p, idx) { +- var lo = bsearch.lt(hulls, p, testPoint) +- var hi = bsearch.gt(hulls, p, testPoint) +- for(var i=lo; i 1 && orient( +- points[lowerIds[m-2]], +- points[lowerIds[m-1]], +- p) > 0) { +- cells.push( +- [lowerIds[m-1], +- lowerIds[m-2], +- idx]) +- m -= 1 +- } +- lowerIds.length = m +- lowerIds.push(idx) ++Mont.prototype.convertFrom = function convertFrom(num) { ++ var r = this.imod(num.mul(this.rinv)); ++ r.red = null; ++ return r; ++}; + +- //Insert p into upper hull +- var upperIds = hull.upperIds +- var m = upperIds.length +- while(m > 1 && orient( +- points[upperIds[m-2]], +- points[upperIds[m-1]], +- p) < 0) { +- cells.push( +- [upperIds[m-2], +- upperIds[m-1], +- idx]) +- m -= 1 +- } +- upperIds.length = m +- upperIds.push(idx) ++Mont.prototype.imul = function imul(a, b) { ++ if (a.cmpn(0) === 0 || b.cmpn(0) === 0) { ++ a.words[0] = 0; ++ a.length = 1; ++ return a; + } +-} + +-function findSplit(hull, edge) { +- var d +- if(hull.a[0] < edge.a[0]) { +- d = orient(hull.a, hull.b, edge.a) +- } else { +- d = orient(edge.b, edge.a, hull.a) +- } +- if(d) { return d } +- if(edge.b[0] < hull.b[0]) { +- d = orient(hull.a, hull.b, edge.b) +- } else { +- d = orient(edge.b, edge.a, hull.b) +- } +- return d || hull.idx - edge.idx +-} ++ var t = a.imul(b); ++ var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); ++ var u = t.isub(c).ishrn(this.shift); ++ var res = u; ++ if (u.cmp(this.m) >= 0) ++ res = u.isub(this.m); ++ else if (u.cmpn(0) < 0) ++ res = u.iadd(this.m); + +-function splitHulls(hulls, points, event) { +- var splitIdx = bsearch.le(hulls, event, findSplit) +- var hull = hulls[splitIdx] +- var upperIds = hull.upperIds +- var x = upperIds[upperIds.length-1] +- hull.upperIds = [x] +- hulls.splice(splitIdx+1, 0, +- new PartialHull(event.a, event.b, event.idx, [x], upperIds)) +-} ++ return res._forceRed(this); ++}; + ++Mont.prototype.mul = function mul(a, b) { ++ if (a.cmpn(0) === 0 || b.cmpn(0) === 0) ++ return new BN(0)._forceRed(this); + +-function mergeHulls(hulls, points, event) { +- //Swap pointers for merge search +- var tmp = event.a +- event.a = event.b +- event.b = tmp +- var mergeIdx = bsearch.eq(hulls, event, findSplit) +- var upper = hulls[mergeIdx] +- var lower = hulls[mergeIdx-1] +- lower.upperIds = upper.upperIds +- hulls.splice(mergeIdx, 1) +-} ++ var t = a.mul(b); ++ var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); ++ var u = t.isub(c).ishrn(this.shift); ++ var res = u; ++ if (u.cmp(this.m) >= 0) ++ res = u.isub(this.m); ++ else if (u.cmpn(0) < 0) ++ res = u.iadd(this.m); + ++ return res._forceRed(this); ++}; + +-function monotoneTriangulate(points, edges) { ++Mont.prototype.invm = function invm(a) { ++ // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R ++ var res = this.imod(a._invmp(this.m).mul(this.r2)); ++ return res._forceRed(this); ++}; + +- var numPoints = points.length +- var numEdges = edges.length ++})(typeof module === 'undefined' || module, this); + +- var events = [] ++},{}],30:[function(require,module,exports){ ++'use strict' + +- //Create point events +- for(var i=0; i b[0]) { +- events.push( +- new Event(b, a, EVENT_START, i), +- new Event(a, b, EVENT_END, i)) ++//Unpack boxes into a flat typed array, remove empty boxes ++function convertBoxes(boxes, d, data, ids) { ++ var ptr = 0 ++ var count = 0 ++ for(var i=0, n=boxes.length; i>>1 ++ if(d <= 0) { ++ return + } + +- //Return triangulation +- return cells +-} ++ var retval + +-},{"binary-search-bounds":21,"robust-orientation":133}],20:[function(require,module,exports){ +-'use strict' ++ //Convert red boxes ++ var redList = pool.mallocDouble(2*d*n) ++ var redIds = pool.mallocInt32(n) ++ n = convertBoxes(red, d, redList, redIds) + +-var bsearch = require('binary-search-bounds') ++ if(n > 0) { ++ if(d === 1 && full) { ++ //Special case: 1d complete ++ sweep.init(n) ++ retval = sweep.sweepComplete( ++ d, visit, ++ 0, n, redList, redIds, ++ 0, n, redList, redIds) ++ } else { + +-module.exports = createTriangulation ++ //Convert blue boxes ++ var blueList = pool.mallocDouble(2*d*m) ++ var blueIds = pool.mallocInt32(m) ++ m = convertBoxes(blue, d, blueList, blueIds) + +-function Triangulation(stars, edges) { +- this.stars = stars +- this.edges = edges +-} ++ if(m > 0) { ++ sweep.init(n+m) + +-var proto = Triangulation.prototype ++ if(d === 1) { ++ //Special case: 1d bipartite ++ retval = sweep.sweepBipartite( ++ d, visit, ++ 0, n, redList, redIds, ++ 0, m, blueList, blueIds) ++ } else { ++ //General case: d>1 ++ retval = boxIntersectIter( ++ d, visit, full, ++ n, redList, redIds, ++ m, blueList, blueIds) ++ } + +-function removePair(list, j, k) { +- for(var i=1, n=list.length; i= 0 ++ pool.free(redList) ++ pool.free(redIds) + } +-})() + +-proto.removeTriangle = function(i, j, k) { +- var stars = this.stars +- removePair(stars[i], j, k) +- removePair(stars[j], k, i) +- removePair(stars[k], i, j) ++ return retval + } + +-proto.addTriangle = function(i, j, k) { +- var stars = this.stars +- stars[i].push(j, k) +- stars[j].push(k, i) +- stars[k].push(i, j) +-} + +-proto.opposite = function(j, i) { +- var list = this.stars[i] +- for(var k=1, n=list.length; k>>1,x=a[m]"] +- if(earlyOut) { +- if(predicate.indexOf("c") < 0) { +- code.push(";if(x===y){return m}else if(x<=y){") +- } else { +- code.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){") +- } +- } else { +- code.push(";if(", predicate, "){i=m;") +- } +- if(reversed) { +- code.push("l=m+1}else{h=m-1}") +- } else { +- code.push("h=m-1}else{l=m+1}") +- } +- code.push("}") +- if(earlyOut) { +- code.push("return -1};") +- } else { +- code.push("return i};") +- } +- return code.join("") +-} ++var RED_START = 'rs' ++var RED_END = 're' ++var RED_BOXES = 'rb' ++var RED_INDEX = 'ri' ++var RED_PTR = 'rp' + +-function compileBoundsSearch(predicate, reversed, suffix, earlyOut) { +- var result = new Function([ +- compileSearch("A", "x" + predicate + "y", reversed, ["y"], earlyOut), +- compileSearch("P", "c(x,y)" + predicate + "0", reversed, ["y", "c"], earlyOut), +-"function dispatchBsearch", suffix, "(a,y,c,l,h){\ +-if(typeof(c)==='function'){\ +-return P(a,(l===void 0)?0:l|0,(h===void 0)?a.length-1:h|0,y,c)\ +-}else{\ +-return A(a,(c===void 0)?0:c|0,(l===void 0)?a.length-1:l|0,y)\ +-}}\ +-return dispatchBsearch", suffix].join("")) +- return result() +-} ++var BLUE_START = 'bs' ++var BLUE_END = 'be' ++var BLUE_BOXES = 'bb' ++var BLUE_INDEX = 'bi' ++var BLUE_PTR = 'bp' + +-module.exports = { +- ge: compileBoundsSearch(">=", false, "GE"), +- gt: compileBoundsSearch(">", false, "GT"), +- lt: compileBoundsSearch("<", true, "LT"), +- le: compileBoundsSearch("<=", true, "LE"), +- eq: compileBoundsSearch("-", true, "EQ", true) +-} ++var RETVAL = 'rv' + +-},{}],22:[function(require,module,exports){ +-"use strict" ++var INNER_LABEL = 'Q' + +-var twoProduct = require("two-product") +-var robustSum = require("robust-sum") +-var robustDiff = require("robust-subtract") +-var robustScale = require("robust-scale") ++var ARGS = [ ++ DIMENSION, ++ AXIS, ++ VISIT, ++ RED_START, ++ RED_END, ++ RED_BOXES, ++ RED_INDEX, ++ BLUE_START, ++ BLUE_END, ++ BLUE_BOXES, ++ BLUE_INDEX ++] + +-var NUM_EXPAND = 6 ++function generateBruteForce(redMajor, flip, full) { ++ var funcName = 'bruteForce' + ++ (redMajor ? 'Red' : 'Blue') + ++ (flip ? 'Flip' : '') + ++ (full ? 'Full' : '') + +-function cofactor(m, c) { +- var result = new Array(m.length-1) +- for(var i=1; i>1 +- return ["sum(", generateSum(expr.slice(0, m)), ",", generateSum(expr.slice(m)), ")"].join("") ++ code.push(blueLoop, INNER_LABEL, ':', redLoop) + } +-} + +-function makeProduct(a, b) { +- if(a.charAt(0) === "m") { +- if(b.charAt(0) === "w") { +- var toks = a.split("[") +- return ["w", b.substr(1), "m", toks[0].substr(1)].join("") +- } else { +- return ["prod(", a, ",", b, ")"].join("") +- } ++ if(full) { ++ code.push('if(y1' + ++ BLUE_END + '-' + BLUE_START + '){') ++ ++ if(full) { ++ invoke(true, false) ++ code.push('}else{') ++ invoke(false, false) ++ } else { ++ code.push('if(' + FLIP + '){') ++ invoke(true, true) ++ code.push('}else{') ++ invoke(true, false) ++ code.push('}}else{if(' + FLIP + '){') ++ invoke(false, true) ++ code.push('}else{') ++ invoke(false, false) ++ code.push('}') + } +- code.push("var p=", posExpr, ",n=", negExpr, ",d=diff(p,n);return d[d.length-1];}return ", funcName) +- var proc = new Function("sum", "diff", "prod", "scale", code.join("")) +- return proc(robustSum, robustDiff, twoProduct, robustScale) ++ code.push('}}return ' + funcName) ++ ++ var codeStr = prefix.join('') + code.join('') ++ var proc = new Function(codeStr) ++ return proc() + } + +-function inSphere0() { return 0 } +-function inSphere1() { return 0 } +-function inSphere2() { return 0 } + +-var CACHED = [ +- inSphere0, +- inSphere1, +- inSphere2 +-] ++exports.partial = bruteForcePlanner(false) ++exports.full = bruteForcePlanner(true) ++},{}],32:[function(require,module,exports){ ++'use strict' + +-function slowInSphere(args) { +- var proc = CACHED[args.length] +- if(!proc) { +- proc = CACHED[args.length] = orientation(args.length) +- } +- return proc.apply(undefined, args) +-} ++module.exports = boxIntersectIter + +-function generateInSphereTest() { +- while(CACHED.length <= NUM_EXPAND) { +- CACHED.push(orientation(CACHED.length)) +- } +- var args = [] +- var procArgs = ["slow"] +- for(var i=0; i<=NUM_EXPAND; ++i) { +- args.push("a" + i) +- procArgs.push("o" + i) +- } +- var code = [ +- "function testInSphere(", args.join(), "){switch(arguments.length){case 0:case 1:return 0;" +- ] +- for(var i=2; i<=NUM_EXPAND; ++i) { +- code.push("case ", i, ":return o", i, "(", args.slice(0, i).join(), ");") +- } +- code.push("}var s=new Array(arguments.length);for(var i=0;i=p0)&&!(p1>=hi)', ++ ['p0', 'p1']) + +-generateInSphereTest() +-},{"robust-scale":134,"robust-subtract":135,"robust-sum":136,"two-product":149}],23:[function(require,module,exports){ +-'use strict' ++var partitionStartEqual = genPartition( ++ 'lo===p0', ++ ['p0']) + +-module.exports = cleanPSLG ++var partitionStartLessThan = genPartition( ++ 'lo 0) { +- return [nextafter(f, -Infinity), f] +- } else { +- return [f, f] +- } +-} ++var partitionContainsPointProper = genPartition( ++ 'lo= floatPoints.length) { +- return ratPoints[idx-floatPoints.length] ++ if(flip && blueX === r0) { ++ continue + } +- var p = floatPoints[idx] +- return [ rat(p[0]), rat(p[1]) ] +- } +- junctions.sort(function(a, b) { +- if(a[0] !== b[0]) { +- return a[0] - b[0] ++ var redId = redIndex[i] ++ for(var j=axis+1; j=0; --i) { +- var junction = junctions[i] +- var e = junction[0] ++//Special case: Intersect one point with list of intervals ++function onePointFull( ++ d, axis, visit, ++ redStart, redEnd, red, redIndex, ++ blueOffset, blue, blueId) { + +- var edge = edges[e] +- var s = edge[0] +- var t = edge[1] ++ var elemSize = 2 * d ++ var bluePtr = blueOffset * elemSize ++ var blueX = blue[bluePtr + axis] + +- //Check if edge is not lexicographically sorted +- var a = floatPoints[s] +- var b = floatPoints[t] +- if(((a[0] - b[0]) || (a[1] - b[1])) < 0) { +- var tmp = s +- s = t +- t = tmp ++red_loop: ++ for(var i=redStart, redPtr=redStart*elemSize; i 0 && junctions[i-1][0] === e) { +- var junction = junctions[--i] +- var next = junction[1] +- if(useColor) { +- edges.push([last, next, color]) +- } else { +- edges.push([last, next]) ++ for(var j=axis+1; j 0) { ++ top -= 1 + +- //Do a second pass to fix up missing labels +- for(var i=0; i b[2]) { +- return 1 +- } +- return 0 +-} ++ //Unpack state info ++ var flip = (state & 1) ++ var full = !!(state & 16) + +-//Remove duplicate edge labels +-function dedupEdges(edges, labels, useColor) { +- if(edges.length === 0) { +- return +- } +- if(labels) { +- for(var i=0; i= redEnd) { ++ continue ++ } + } +- } +- if(useColor) { +- edges.sort(compareLex3) +- } else { +- edges.sort(compareLex2) +- } +- var ptr = 1 +- for(var i=1; i= redEnd) { ++ continue ++ } + } +- edges[ptr++] = next +- } +- edges.length = ptr +-} +- +-//Repeat until convergence +-function snapRound(points, edges, useColor) { +- +- // 1. find edge crossings +- var edgeBounds = boundEdges(points, edges) +- var crossings = getCrossings(points, edges, edgeBounds) +- +- // 2. find t-junctions +- var vertBounds = boundPoints(points) +- var tjunctions = getTJunctions(points, edges, edgeBounds, vertBounds) ++ ++ var redCount = redEnd - redStart ++ var blueCount = blueEnd - blueStart + +- // 3. cut edges, construct rational points +- var ratPoints = cutEdges(points, edges, crossings, tjunctions, useColor) ++ if(full) { ++ if(d * redCount * (redCount + blueCount) < SCAN_COMPLETE_CUTOFF) { ++ retval = sweep.scanComplete( ++ d, axis, visit, ++ redStart, redEnd, red, redIndex, ++ blueStart, blueEnd, blue, blueIndex) ++ if(retval !== void 0) { ++ return retval ++ } ++ continue ++ } ++ } else { ++ if(d * Math.min(redCount, blueCount) < BRUTE_FORCE_CUTOFF) { ++ //If input small, then use brute force ++ retval = bruteForcePartial( ++ d, axis, visit, flip, ++ redStart, redEnd, red, redIndex, ++ blueStart, blueEnd, blue, blueIndex) ++ if(retval !== void 0) { ++ return retval ++ } ++ continue ++ } else if(d * redCount * blueCount < SCAN_CUTOFF) { ++ //If input medium sized, then use sweep and prune ++ retval = sweep.scanBipartite( ++ d, axis, visit, flip, ++ redStart, redEnd, red, redIndex, ++ blueStart, blueEnd, blue, blueIndex) ++ if(retval !== void 0) { ++ return retval ++ } ++ continue ++ } ++ } ++ ++ //First, find all red intervals whose interior contains (lo,hi) ++ var red0 = partitionInteriorContainsInterval( ++ d, axis, ++ redStart, redEnd, red, redIndex, ++ lo, hi) + +- // 4. dedupe verts +- var labels = dedupPoints(points, ratPoints, vertBounds) ++ //Lower dimensional case ++ if(redStart < red0) { + +- // 6. dedupe edges +- dedupEdges(edges, labels, useColor) ++ if(d * (red0 - redStart) < BRUTE_FORCE_CUTOFF) { ++ //Special case for small inputs: use brute force ++ retval = bruteForceFull( ++ d, axis+1, visit, ++ redStart, red0, red, redIndex, ++ blueStart, blueEnd, blue, blueIndex) ++ if(retval !== void 0) { ++ return retval ++ } ++ } else if(axis === d-2) { ++ if(flip) { ++ retval = sweep.sweepBipartite( ++ d, visit, ++ blueStart, blueEnd, blue, blueIndex, ++ redStart, red0, red, redIndex) ++ } else { ++ retval = sweep.sweepBipartite( ++ d, visit, ++ redStart, red0, red, redIndex, ++ blueStart, blueEnd, blue, blueIndex) ++ } ++ if(retval !== void 0) { ++ return retval ++ } ++ } else { ++ iterPush(top++, ++ axis+1, ++ redStart, red0, ++ blueStart, blueEnd, ++ flip, ++ -Infinity, Infinity) ++ iterPush(top++, ++ axis+1, ++ blueStart, blueEnd, ++ redStart, red0, ++ flip^1, ++ -Infinity, Infinity) ++ } ++ } + +- // 5. check termination +- if(!labels) { +- return (crossings.length > 0 || tjunctions.length > 0) +- } ++ //Divide and conquer phase ++ if(red0 < redEnd) { + +- // More iterations necessary +- return true +-} ++ //Cut blue into 3 parts: ++ // ++ // Points < mid point ++ // Points = mid point ++ // Points > mid point ++ // ++ var blue0 = findMedian( ++ d, axis, ++ blueStart, blueEnd, blue, blueIndex) ++ var mid = blue[elemSize * blue0 + axis] ++ var blue1 = partitionStartEqual( ++ d, axis, ++ blue0, blueEnd, blue, blueIndex, ++ mid) + +-//Main loop, runs PSLG clean up until completion +-function cleanPSLG(points, edges, colors) { +- var modified = false ++ //Right case ++ if(blue1 < blueEnd) { ++ iterPush(top++, ++ axis, ++ red0, redEnd, ++ blue1, blueEnd, ++ (flip|4) + (full ? 16 : 0), ++ mid, hi) ++ } + +- //If using colors, augment edges with color data +- var prevEdges +- if(colors) { +- prevEdges = edges +- var augEdges = new Array(edges.length) +- for(var i=0; istart && boxes[ptr+axis] > x; ++ --j, ptr-=elemSize) { ++ //Swap ++ var aPtr = ptr ++ var bPtr = ptr+elemSize ++ for(var k=0; k>> 1) ++ var elemSize = 2*d ++ var pivot = mid ++ var value = boxes[elemSize*mid+axis] ++ ++ while(lo < hi) { ++ if(hi - lo < PARTITION_THRESHOLD) { ++ insertionSort(d, axis, lo, hi, boxes, ids) ++ value = boxes[elemSize*mid+axis] ++ break ++ } ++ ++ //Select pivot using median-of-3 ++ var count = hi - lo ++ var pivot0 = (Math.random()*count+lo)|0 ++ var value0 = boxes[elemSize*pivot0 + axis] ++ var pivot1 = (Math.random()*count+lo)|0 ++ var value1 = boxes[elemSize*pivot1 + axis] ++ var pivot2 = (Math.random()*count+lo)|0 ++ var value2 = boxes[elemSize*pivot2 + axis] ++ if(value0 <= value1) { ++ if(value2 >= value1) { ++ pivot = pivot1 ++ value = value1 ++ } else if(value0 >= value2) { ++ pivot = pivot0 ++ value = value0 ++ } else { ++ pivot = pivot2 ++ value = value2 ++ } ++ } else { ++ if(value1 >= value2) { ++ pivot = pivot1 ++ value = value1 ++ } else if(value2 >= value0) { ++ pivot = pivot0 ++ value = value0 ++ } else { ++ pivot = pivot2 ++ value = value2 ++ } ++ } + +-},{"./lib/rationalize":35}],26:[function(require,module,exports){ +-'use strict' ++ //Swap pivot to end of array ++ var aPtr = elemSize * (hi-1) ++ var bPtr = elemSize * pivot ++ for(var i=0; i= 0) { ++ reads.push('lo=e[k+n]') + } +- if(shift > 0) { +- a = a.shln(shift) +- } else if(shift < 0) { +- b = b.shln(-shift) ++ if(predicate.indexOf('hi') >= 0) { ++ reads.push('hi=e[k+o]') + } +- return rationalize(a, b) ++ fargs.push( ++ code.replace('_', reads.join()) ++ .replace('$', predicate)) ++ return Function.apply(void 0, fargs) + } ++},{}],35:[function(require,module,exports){ ++'use strict'; + +-},{"./div":27,"./is-rat":29,"./lib/is-bn":33,"./lib/num-to-bn":34,"./lib/rationalize":35,"./lib/str-to-bn":36}],29:[function(require,module,exports){ +-'use strict' ++//This code is extracted from ndarray-sort ++//It is inlined here as a temporary workaround + +-var isBN = require('./lib/is-bn') ++module.exports = wrapper; + +-module.exports = isRat ++var INSERT_SORT_CUTOFF = 32 + +-function isRat(x) { +- return Array.isArray(x) && x.length === 2 && isBN(x[0]) && isBN(x[1]) ++function wrapper(data, n0) { ++ if (n0 <= 4*INSERT_SORT_CUTOFF) { ++ insertionSort(0, n0 - 1, data); ++ } else { ++ quickSort(0, n0 - 1, data); ++ } + } + +-},{"./lib/is-bn":33}],30:[function(require,module,exports){ +-'use strict' ++function insertionSort(left, right, data) { ++ var ptr = 2*(left+1) ++ for(var i=left+1; i<=right; ++i) { ++ var a = data[ptr++] ++ var b = data[ptr++] ++ var j = i ++ var jptr = ptr-2 ++ while(j-- > left) { ++ var x = data[jptr-2] ++ var y = data[jptr-1] ++ if(x < a) { ++ break ++ } else if(x === a && y < b) { ++ break ++ } ++ data[jptr] = x ++ data[jptr+1] = y ++ jptr -= 2 ++ } ++ data[jptr] = a ++ data[jptr+1] = b ++ } ++} + +-var bn = require('bn.js') ++function swap(i, j, data) { ++ i *= 2 ++ j *= 2 ++ var x = data[i] ++ var y = data[i+1] ++ data[i] = data[j] ++ data[i+1] = data[j+1] ++ data[j] = x ++ data[j+1] = y ++} + +-module.exports = sign ++function move(i, j, data) { ++ i *= 2 ++ j *= 2 ++ data[i] = data[j] ++ data[i+1] = data[j+1] ++} + +-function sign(x) { +- return x.cmp(new bn(0)) ++function rotate(i, j, k, data) { ++ i *= 2 ++ j *= 2 ++ k *= 2 ++ var x = data[i] ++ var y = data[i+1] ++ data[i] = data[j] ++ data[i+1] = data[j+1] ++ data[j] = data[k] ++ data[j+1] = data[k+1] ++ data[k] = x ++ data[k+1] = y + } + +-},{"bn.js":38}],31:[function(require,module,exports){ +-'use strict' ++function shufflePivot(i, j, px, py, data) { ++ i *= 2 ++ j *= 2 ++ data[i] = data[j] ++ data[j] = px ++ data[i+1] = data[j+1] ++ data[j+1] = py ++} + +-module.exports = bn2num ++function compare(i, j, data) { ++ i *= 2 ++ j *= 2 ++ var x = data[i], ++ y = data[j] ++ if(x < y) { ++ return false ++ } else if(x === y) { ++ return data[i+1] > data[j+1] ++ } ++ return true ++} + +-//TODO: Make this better +-function bn2num(b) { +- var l = b.length +- var words = b.words +- var out = 0 +- if (l === 1) { +- out = words[0] +- } else if (l === 2) { +- out = words[0] + (words[1] * 0x4000000) +- } else { +- var out = 0 +- for (var i = 0; i < l; i++) { +- var w = words[i] +- out += w * Math.pow(0x4000000, i) +- } ++function comparePivot(i, y, b, data) { ++ i *= 2 ++ var x = data[i] ++ if(x < y) { ++ return true ++ } else if(x === y) { ++ return data[i+1] < b + } +- return b.sign ? -out : out ++ return false + } + +-},{}],32:[function(require,module,exports){ +-'use strict' ++function quickSort(left, right, data) { ++ var sixth = (right - left + 1) / 6 | 0, ++ index1 = left + sixth, ++ index5 = right - sixth, ++ index3 = left + right >> 1, ++ index2 = index3 - sixth, ++ index4 = index3 + sixth, ++ el1 = index1, ++ el2 = index2, ++ el3 = index3, ++ el4 = index4, ++ el5 = index5, ++ less = left + 1, ++ great = right - 1, ++ tmp = 0 ++ if(compare(el1, el2, data)) { ++ tmp = el1 ++ el1 = el2 ++ el2 = tmp ++ } ++ if(compare(el4, el5, data)) { ++ tmp = el4 ++ el4 = el5 ++ el5 = tmp ++ } ++ if(compare(el1, el3, data)) { ++ tmp = el1 ++ el1 = el3 ++ el3 = tmp ++ } ++ if(compare(el2, el3, data)) { ++ tmp = el2 ++ el2 = el3 ++ el3 = tmp ++ } ++ if(compare(el1, el4, data)) { ++ tmp = el1 ++ el1 = el4 ++ el4 = tmp ++ } ++ if(compare(el3, el4, data)) { ++ tmp = el3 ++ el3 = el4 ++ el4 = tmp ++ } ++ if(compare(el2, el5, data)) { ++ tmp = el2 ++ el2 = el5 ++ el5 = tmp ++ } ++ if(compare(el2, el3, data)) { ++ tmp = el2 ++ el2 = el3 ++ el3 = tmp ++ } ++ if(compare(el4, el5, data)) { ++ tmp = el4 ++ el4 = el5 ++ el5 = tmp ++ } + +-var db = require('double-bits') +-var ctz = require('bit-twiddle').countTrailingZeros ++ var pivot1X = data[2*el2] ++ var pivot1Y = data[2*el2+1] ++ var pivot2X = data[2*el4] ++ var pivot2Y = data[2*el4+1] + +-module.exports = ctzNumber ++ var ptr0 = 2 * el1; ++ var ptr2 = 2 * el3; ++ var ptr4 = 2 * el5; ++ var ptr5 = 2 * index1; ++ var ptr6 = 2 * index3; ++ var ptr7 = 2 * index5; ++ for (var i1 = 0; i1 < 2; ++i1) { ++ var x = data[ptr0+i1]; ++ var y = data[ptr2+i1]; ++ var z = data[ptr4+i1]; ++ data[ptr5+i1] = x; ++ data[ptr6+i1] = y; ++ data[ptr7+i1] = z; ++ } + +-//Counts the number of trailing zeros +-function ctzNumber(x) { +- var l = ctz(db.lo(x)) +- if(l < 32) { +- return l ++ move(index2, left, data) ++ move(index4, right, data) ++ for (var k = less; k <= great; ++k) { ++ if (comparePivot(k, pivot1X, pivot1Y, data)) { ++ if (k !== less) { ++ swap(k, less, data) ++ } ++ ++less; ++ } else { ++ if (!comparePivot(k, pivot2X, pivot2Y, data)) { ++ while (true) { ++ if (!comparePivot(great, pivot2X, pivot2Y, data)) { ++ if (--great < k) { ++ break; ++ } ++ continue; ++ } else { ++ if (comparePivot(great, pivot1X, pivot1Y, data)) { ++ rotate(k, less, great, data) ++ ++less; ++ --great; ++ } else { ++ swap(k, great, data) ++ --great; ++ } ++ break; ++ } ++ } ++ } ++ } + } +- var h = ctz(db.hi(x)) +- if(h > 20) { +- return 52 ++ shufflePivot(left, less-1, pivot1X, pivot1Y, data) ++ shufflePivot(right, great+1, pivot2X, pivot2Y, data) ++ if (less - 2 - left <= INSERT_SORT_CUTOFF) { ++ insertionSort(left, less - 2, data); ++ } else { ++ quickSort(left, less - 2, data); ++ } ++ if (right - (great + 2) <= INSERT_SORT_CUTOFF) { ++ insertionSort(great + 2, right, data); ++ } else { ++ quickSort(great + 2, right, data); ++ } ++ if (great - less <= INSERT_SORT_CUTOFF) { ++ insertionSort(less, great, data); ++ } else { ++ quickSort(less, great, data); + } +- return h + 32 + } +- +-},{"bit-twiddle":9,"double-bits":49}],33:[function(require,module,exports){ ++},{}],36:[function(require,module,exports){ + 'use strict' + +-var BN = require('bn.js') +- +-module.exports = isBN +- +-//Test if x is a bignumber +-//FIXME: obviously this is the wrong way to do it +-function isBN(x) { +- return x && typeof x === 'object' && Boolean(x.words) ++module.exports = { ++ init: sqInit, ++ sweepBipartite: sweepBipartite, ++ sweepComplete: sweepComplete, ++ scanBipartite: scanBipartite, ++ scanComplete: scanComplete + } + +-},{"bn.js":38}],34:[function(require,module,exports){ +-'use strict' ++var pool = require('typedarray-pool') ++var bits = require('bit-twiddle') ++var isort = require('./sort') + +-var BN = require('bn.js') +-var db = require('double-bits') ++//Flag for blue ++var BLUE_FLAG = (1<<28) + +-module.exports = num2bn ++//1D sweep event queue stuff (use pool to save space) ++var INIT_CAPACITY = 1024 ++var RED_SWEEP_QUEUE = pool.mallocInt32(INIT_CAPACITY) ++var RED_SWEEP_INDEX = pool.mallocInt32(INIT_CAPACITY) ++var BLUE_SWEEP_QUEUE = pool.mallocInt32(INIT_CAPACITY) ++var BLUE_SWEEP_INDEX = pool.mallocInt32(INIT_CAPACITY) ++var COMMON_SWEEP_QUEUE = pool.mallocInt32(INIT_CAPACITY) ++var COMMON_SWEEP_INDEX = pool.mallocInt32(INIT_CAPACITY) ++var SWEEP_EVENTS = pool.mallocDouble(INIT_CAPACITY * 8) + +-function num2bn(x) { +- var e = db.exponent(x) +- if(e < 52) { +- return new BN(x) +- } else { +- return (new BN(x * Math.pow(2, 52-e))).shln(e-52) ++//Reserves memory for the 1D sweep data structures ++function sqInit(count) { ++ var rcount = bits.nextPow2(count) ++ if(RED_SWEEP_QUEUE.length < rcount) { ++ pool.free(RED_SWEEP_QUEUE) ++ RED_SWEEP_QUEUE = pool.mallocInt32(rcount) + } +-} +- +-},{"bn.js":38,"double-bits":49}],35:[function(require,module,exports){ +-'use strict' +- +-var num2bn = require('./num-to-bn') +-var sign = require('./bn-sign') +- +-module.exports = rationalize +- +-function rationalize(numer, denom) { +- var snumer = sign(numer) +- var sdenom = sign(denom) +- if(snumer === 0) { +- return [num2bn(0), num2bn(1)] ++ if(RED_SWEEP_INDEX.length < rcount) { ++ pool.free(RED_SWEEP_INDEX) ++ RED_SWEEP_INDEX = pool.mallocInt32(rcount) + } +- if(sdenom === 0) { +- return [num2bn(0), num2bn(0)] ++ if(BLUE_SWEEP_QUEUE.length < rcount) { ++ pool.free(BLUE_SWEEP_QUEUE) ++ BLUE_SWEEP_QUEUE = pool.mallocInt32(rcount) + } +- if(sdenom < 0) { +- numer = numer.neg() +- denom = denom.neg() ++ if(BLUE_SWEEP_INDEX.length < rcount) { ++ pool.free(BLUE_SWEEP_INDEX) ++ BLUE_SWEEP_INDEX = pool.mallocInt32(rcount) + } +- var d = numer.gcd(denom) +- if(d.cmpn(1)) { +- return [ numer.div(d), denom.div(d) ] ++ if(COMMON_SWEEP_QUEUE.length < rcount) { ++ pool.free(COMMON_SWEEP_QUEUE) ++ COMMON_SWEEP_QUEUE = pool.mallocInt32(rcount) ++ } ++ if(COMMON_SWEEP_INDEX.length < rcount) { ++ pool.free(COMMON_SWEEP_INDEX) ++ COMMON_SWEEP_INDEX = pool.mallocInt32(rcount) ++ } ++ var eventLength = 8 * rcount ++ if(SWEEP_EVENTS.length < eventLength) { ++ pool.free(SWEEP_EVENTS) ++ SWEEP_EVENTS = pool.mallocDouble(eventLength) + } +- return [ numer, denom ] + } + +-},{"./bn-sign":30,"./num-to-bn":34}],36:[function(require,module,exports){ +-'use strict' +- +-var BN = require('bn.js') +- +-module.exports = str2BN +- +-function str2BN(x) { +- return new BN(x) ++//Remove an item from the active queue in O(1) ++function sqPop(queue, index, count, item) { ++ var idx = index[item] ++ var top = queue[count-1] ++ queue[idx] = top ++ index[top] = idx + } + +-},{"bn.js":38}],37:[function(require,module,exports){ +-'use strict' +- +-var rationalize = require('./lib/rationalize') +- +-module.exports = mul +- +-function mul(a, b) { +- return rationalize(a[0].mul(b[0]), a[1].mul(b[1])) ++//Insert an item into the active queue in O(1) ++function sqPush(queue, index, count, item) { ++ queue[count] = item ++ index[item] = count + } + +-},{"./lib/rationalize":35}],38:[function(require,module,exports){ +-(function (module, exports) { ++//Recursion base case: use 1D sweep algorithm ++function sweepBipartite( ++ d, visit, ++ redStart, redEnd, red, redIndex, ++ blueStart, blueEnd, blue, blueIndex) { + +-'use strict'; ++ //store events as pairs [coordinate, idx] ++ // ++ // red create: -(idx+1) ++ // red destroy: idx ++ // blue create: -(idx+BLUE_FLAG) ++ // blue destroy: idx+BLUE_FLAG ++ // ++ var ptr = 0 ++ var elemSize = 2*d ++ var istart = d-1 ++ var iend = elemSize-1 + +-// Utils ++ for(var i=redStart; iright ++ var n = ptr >>> 1 ++ isort(SWEEP_EVENTS, n) ++ ++ var redActive = 0 ++ var blueActive = 0 ++ for(var i=0; i= BLUE_FLAG) { ++ //blue destroy event ++ e = (e-BLUE_FLAG)|0 ++ sqPop(BLUE_SWEEP_QUEUE, BLUE_SWEEP_INDEX, blueActive--, e) ++ } else if(e >= 0) { ++ //red destroy event ++ sqPop(RED_SWEEP_QUEUE, RED_SWEEP_INDEX, redActive--, e) ++ } else if(e <= -BLUE_FLAG) { ++ //blue create event ++ e = (-e-BLUE_FLAG)|0 ++ for(var j=0; j= 2 && base <= 36); + +- number = number.toString().replace(/\s+/g, ''); +- var start = 0; +- if (number[0] === '-') +- start++; ++ //process events from left->right ++ var n = ptr >>> 1 ++ isort(SWEEP_EVENTS, n) ++ ++ var redActive = 0 ++ var blueActive = 0 ++ var commonActive = 0 ++ for(var i=0; i>1) === (SWEEP_EVENTS[2*i+3]>>1)) { ++ color = 2 ++ i += 1 ++ } ++ ++ if(e < 0) { ++ //Create event ++ var id = -(e>>1) - 1 + +- if (base === 16) +- this._parseHex(number, start); +- else +- this._parseBase(number, base, start); ++ //Intersect with common ++ for(var j=0; j>1) - 1 ++ if(color === 0) { ++ //Red ++ sqPop(RED_SWEEP_QUEUE, RED_SWEEP_INDEX, redActive--, id) ++ } else if(color === 1) { ++ //Blue ++ sqPop(BLUE_SWEEP_QUEUE, BLUE_SWEEP_INDEX, blueActive--, id) ++ } else if(color === 2) { ++ //Both ++ sqPop(COMMON_SWEEP_QUEUE, COMMON_SWEEP_INDEX, commonActive--, id) ++ } ++ } ++ } ++} + +- this._initArray(this.toArray(), base, endian); +-}; ++//Sweep and prune/scanline algorithm: ++// Scan along axis, detect intersections ++// Brute force all boxes along axis ++function scanBipartite( ++ d, axis, visit, flip, ++ redStart, redEnd, red, redIndex, ++ blueStart, blueEnd, blue, blueIndex) { ++ ++ var ptr = 0 ++ var elemSize = 2*d ++ var istart = axis ++ var iend = axis+d + +-BN.prototype._initNumber = function _initNumber(number, base, endian) { +- if (number < 0) { +- this.sign = true; +- number = -number; +- } +- if (number < 0x4000000) { +- this.words = [ number & 0x3ffffff ]; +- this.length = 1; +- } else if (number < 0x10000000000000) { +- this.words = [ +- number & 0x3ffffff, +- (number / 0x4000000) & 0x3ffffff +- ]; +- this.length = 2; ++ var redShift = 1 ++ var blueShift = 1 ++ if(flip) { ++ blueShift = BLUE_FLAG + } else { +- assert(number < 0x20000000000000); // 2 ^ 53 (unsafe) +- this.words = [ +- number & 0x3ffffff, +- (number / 0x4000000) & 0x3ffffff, +- 1 +- ]; +- this.length = 3; ++ redShift = BLUE_FLAG + } + +- if (endian !== 'le') +- return; +- +- // Reverse the bytes +- this._initArray(this.toArray(), base, endian); +-}; +- +-BN.prototype._initArray = function _initArray(number, base, endian) { +- // Perhaps a Uint8Array +- assert(typeof number.length === 'number'); +- if (number.length <= 0) { +- this.words = [ 0 ]; +- this.length = 1; +- return this; ++ for(var i=redStart; i= 0; i -= 3) { +- var w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16); +- this.words[j] |= (w << off) & 0x3ffffff; +- this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; +- off += 24; +- if (off >= 26) { +- off -= 26; +- j++; +- } +- } +- } else if (endian === 'le') { +- for (var i = 0, j = 0; i < number.length; i += 3) { +- var w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16); +- this.words[j] |= (w << off) & 0x3ffffff; +- this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; +- off += 24; +- if (off >= 26) { +- off -= 26; +- j++; +- } +- } ++ for(var i=blueStart; iright ++ var n = ptr >>> 1 ++ isort(SWEEP_EVENTS, n) ++ ++ var redActive = 0 ++ for(var i=0; i= BLUE_FLAG) { ++ isRed = !flip ++ idx -= BLUE_FLAG ++ } else { ++ isRed = !!flip ++ idx -= 1 ++ } ++ if(isRed) { ++ sqPush(RED_SWEEP_QUEUE, RED_SWEEP_INDEX, redActive++, idx) ++ } else { ++ var blueId = blueIndex[idx] ++ var bluePtr = elemSize * idx ++ ++ var b0 = blue[bluePtr+axis+1] ++ var b1 = blue[bluePtr+axis+1+d] + +- r <<= 4; ++red_loop: ++ for(var j=0; j= 49 && c <= 54) +- r |= c - 49 + 0xa; ++ if(b1 < red[redPtr+axis+1] || ++ red[redPtr+axis+1+d] < b0) { ++ continue ++ } + +- // 'A' - 'F' +- else if (c >= 17 && c <= 22) +- r |= c - 17 + 0xa; ++ for(var k=axis+2; k= start; i -= 6) { +- var w = parseHex(number, i, i + 6); +- this.words[j] |= (w << off) & 0x3ffffff; +- this.words[j + 1] |= w >>> (26 - off) & 0x3fffff; +- off += 24; +- if (off >= 26) { +- off -= 26; +- j++; +- } ++ var ptr = 0 ++ var elemSize = 2*d ++ var istart = axis ++ var iend = axis+d ++ ++ for(var i=redStart; i>> (26 - off) & 0x3fffff; ++ for(var i=blueStart; iright ++ var n = ptr >>> 1 ++ isort(SWEEP_EVENTS, n) ++ ++ var redActive = 0 ++ for(var i=0; i= BLUE_FLAG) { ++ RED_SWEEP_QUEUE[redActive++] = idx - BLUE_FLAG ++ } else { ++ idx -= 1 ++ var blueId = blueIndex[idx] ++ var bluePtr = elemSize * idx + +- r *= mul; ++ var b0 = blue[bluePtr+axis+1] ++ var b1 = blue[bluePtr+axis+1+d] + +- // 'a' +- if (c >= 49) +- r += c - 49 + 0xa; ++red_loop: ++ for(var j=0; j= 17) +- r += c - 17 + 0xa; ++ if(redId === blueId) { ++ break ++ } + +- // '0' - '9' +- else +- r += c; ++ var redPtr = elemSize * oidx ++ if(b1 < red[redPtr+axis+1] || ++ red[redPtr+axis+1+d] < b0) { ++ continue ++ } ++ for(var k=axis+2; k=0; --j) { ++ if(RED_SWEEP_QUEUE[j] === idx) { ++ for(var k=j+1; k ++ * @license MIT ++ */ ++/* eslint-disable no-proto */ + +-BN.prototype._parseBase = function _parseBase(number, base, start) { +- // Initialize as zero +- this.words = [ 0 ]; +- this.length = 1; ++'use strict' + +- // Find length of limb in base +- for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) +- limbLen++; +- limbLen--; +- limbPow = (limbPow / base) | 0; ++var base64 = require('base64-js') ++var ieee754 = require('ieee754') ++var isArray = require('isarray') + +- var total = number.length - start; +- var mod = total % limbLen; +- var end = Math.min(total, total - mod) + start; ++exports.Buffer = Buffer ++exports.SlowBuffer = SlowBuffer ++exports.INSPECT_MAX_BYTES = 50 + +- var word = 0; +- for (var i = start; i < end; i += limbLen) { +- word = parseBase(number, i, i + limbLen, base); ++/** ++ * If `Buffer.TYPED_ARRAY_SUPPORT`: ++ * === true Use Uint8Array implementation (fastest) ++ * === false Use Object implementation (most compatible, even IE6) ++ * ++ * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, ++ * Opera 11.6+, iOS 4.2+. ++ * ++ * Due to various browser bugs, sometimes the Object implementation will be used even ++ * when the browser supports typed arrays. ++ * ++ * Note: ++ * ++ * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances, ++ * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. ++ * ++ * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. ++ * ++ * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of ++ * incorrect length in some situations. + +- this.imuln(limbPow); +- if (this.words[0] + word < 0x4000000) +- this.words[0] += word; +- else +- this._iaddn(word); +- } ++ * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they ++ * get the Object implementation, which is slower but behaves correctly. ++ */ ++Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined ++ ? global.TYPED_ARRAY_SUPPORT ++ : typedArraySupport() + +- if (mod !== 0) { +- var pow = 1; +- var word = parseBase(number, i, number.length, base); ++/* ++ * Export kMaxLength after typed array support is determined. ++ */ ++exports.kMaxLength = kMaxLength() + +- for (var i = 0; i < mod; i++) +- pow *= base; +- this.imuln(pow); +- if (this.words[0] + word < 0x4000000) +- this.words[0] += word; +- else +- this._iaddn(word); ++function typedArraySupport () { ++ try { ++ var arr = new Uint8Array(1) ++ arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }} ++ return arr.foo() === 42 && // typed array instances can be augmented ++ typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray` ++ arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` ++ } catch (e) { ++ return false + } +-}; +- +-BN.prototype.copy = function copy(dest) { +- dest.words = new Array(this.length); +- for (var i = 0; i < this.length; i++) +- dest.words[i] = this.words[i]; +- dest.length = this.length; +- dest.sign = this.sign; +- dest.red = this.red; +-}; +- +-BN.prototype.clone = function clone() { +- var r = new BN(null); +- this.copy(r); +- return r; +-}; ++} + +-// Remove leading `0` from `this` +-BN.prototype.strip = function strip() { +- while (this.length > 1 && this.words[this.length - 1] === 0) +- this.length--; +- return this._normSign(); +-}; ++function kMaxLength () { ++ return Buffer.TYPED_ARRAY_SUPPORT ++ ? 0x7fffffff ++ : 0x3fffffff ++} + +-BN.prototype._normSign = function _normSign() { +- // -0 = 0 +- if (this.length === 1 && this.words[0] === 0) +- this.sign = false; +- return this; +-}; ++function createBuffer (that, length) { ++ if (kMaxLength() < length) { ++ throw new RangeError('Invalid typed array length') ++ } ++ if (Buffer.TYPED_ARRAY_SUPPORT) { ++ // Return an augmented `Uint8Array` instance, for best performance ++ that = new Uint8Array(length) ++ that.__proto__ = Buffer.prototype ++ } else { ++ // Fallback: Return an object instance of the Buffer class ++ if (that === null) { ++ that = new Buffer(length) ++ } ++ that.length = length ++ } + +-BN.prototype.inspect = function inspect() { +- return (this.red ? ''; +-}; ++ return that ++} + +-/* ++/** ++ * The Buffer constructor returns instances of `Uint8Array` that have their ++ * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of ++ * `Uint8Array`, so the returned instances will have all the node `Buffer` methods ++ * and the `Uint8Array` methods. Square bracket notation works as expected -- it ++ * returns a single octet. ++ * ++ * The `Uint8Array` prototype remains unmodified. ++ */ + +-var zeros = []; +-var groupSizes = []; +-var groupBases = []; ++function Buffer (arg, encodingOrOffset, length) { ++ if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) { ++ return new Buffer(arg, encodingOrOffset, length) ++ } + +-var s = ''; +-var i = -1; +-while (++i < BN.wordSize) { +- zeros[i] = s; +- s += '0'; +-} +-groupSizes[0] = 0; +-groupSizes[1] = 0; +-groupBases[0] = 0; +-groupBases[1] = 0; +-var base = 2 - 1; +-while (++base < 36 + 1) { +- var groupSize = 0; +- var groupBase = 1; +- while (groupBase < (1 << BN.wordSize) / base) { +- groupBase *= base; +- groupSize += 1; ++ // Common case. ++ if (typeof arg === 'number') { ++ if (typeof encodingOrOffset === 'string') { ++ throw new Error( ++ 'If encoding is specified then the first argument must be a string' ++ ) ++ } ++ return allocUnsafe(this, arg) + } +- groupSizes[base] = groupSize; +- groupBases[base] = groupBase; ++ return from(this, arg, encodingOrOffset, length) + } + +-*/ +- +-var zeros = [ +- '', +- '0', +- '00', +- '000', +- '0000', +- '00000', +- '000000', +- '0000000', +- '00000000', +- '000000000', +- '0000000000', +- '00000000000', +- '000000000000', +- '0000000000000', +- '00000000000000', +- '000000000000000', +- '0000000000000000', +- '00000000000000000', +- '000000000000000000', +- '0000000000000000000', +- '00000000000000000000', +- '000000000000000000000', +- '0000000000000000000000', +- '00000000000000000000000', +- '000000000000000000000000', +- '0000000000000000000000000' +-]; ++Buffer.poolSize = 8192 // not used by this implementation + +-var groupSizes = [ +- 0, 0, +- 25, 16, 12, 11, 10, 9, 8, +- 8, 7, 7, 7, 7, 6, 6, +- 6, 6, 6, 6, 6, 5, 5, +- 5, 5, 5, 5, 5, 5, 5, +- 5, 5, 5, 5, 5, 5, 5 +-]; ++// TODO: Legacy, not needed anymore. Remove in next major version. ++Buffer._augment = function (arr) { ++ arr.__proto__ = Buffer.prototype ++ return arr ++} + +-var groupBases = [ +- 0, 0, +- 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, +- 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625, +- 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632, +- 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, +- 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176 +-]; ++function from (that, value, encodingOrOffset, length) { ++ if (typeof value === 'number') { ++ throw new TypeError('"value" argument must not be a number') ++ } + +-BN.prototype.toString = function toString(base, padding) { +- base = base || 10; +- if (base === 16 || base === 'hex') { +- var out = ''; +- var off = 0; +- var padding = padding | 0 || 1; +- var carry = 0; +- for (var i = 0; i < this.length; i++) { +- var w = this.words[i]; +- var word = (((w << off) | carry) & 0xffffff).toString(16); +- carry = (w >>> (24 - off)) & 0xffffff; +- if (carry !== 0 || i !== this.length - 1) +- out = zeros[6 - word.length] + word + out; +- else +- out = word + out; +- off += 2; +- if (off >= 26) { +- off -= 26; +- i--; +- } +- } +- if (carry !== 0) +- out = carry.toString(16) + out; +- while (out.length % padding !== 0) +- out = '0' + out; +- if (this.sign) +- out = '-' + out; +- return out; +- } else if (base === (base | 0) && base >= 2 && base <= 36) { +- // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base)); +- var groupSize = groupSizes[base]; +- // var groupBase = Math.pow(base, groupSize); +- var groupBase = groupBases[base]; +- var out = ''; +- var c = this.clone(); +- c.sign = false; +- while (c.cmpn(0) !== 0) { +- var r = c.modn(groupBase).toString(base); +- c = c.idivn(groupBase); ++ if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) { ++ return fromArrayBuffer(that, value, encodingOrOffset, length) ++ } + +- if (c.cmpn(0) !== 0) +- out = zeros[groupSize - r.length] + r + out; +- else +- out = r + out; +- } +- if (this.cmpn(0) === 0) +- out = '0' + out; +- if (this.sign) +- out = '-' + out; +- return out; +- } else { +- assert(false, 'Base should be between 2 and 36'); ++ if (typeof value === 'string') { ++ return fromString(that, value, encodingOrOffset) + } +-}; + +-BN.prototype.toJSON = function toJSON() { +- return this.toString(16); +-}; ++ return fromObject(that, value) ++} + +-BN.prototype.toArray = function toArray(endian) { +- this.strip(); +- var res = new Array(this.byteLength()); +- res[0] = 0; ++/** ++ * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError ++ * if value is a number. ++ * Buffer.from(str[, encoding]) ++ * Buffer.from(array) ++ * Buffer.from(buffer) ++ * Buffer.from(arrayBuffer[, byteOffset[, length]]) ++ **/ ++Buffer.from = function (value, encodingOrOffset, length) { ++ return from(null, value, encodingOrOffset, length) ++} + +- var q = this.clone(); +- if (endian !== 'le') { +- // Assume big-endian +- for (var i = 0; q.cmpn(0) !== 0; i++) { +- var b = q.andln(0xff); +- q.ishrn(8); ++if (Buffer.TYPED_ARRAY_SUPPORT) { ++ Buffer.prototype.__proto__ = Uint8Array.prototype ++ Buffer.__proto__ = Uint8Array ++ if (typeof Symbol !== 'undefined' && Symbol.species && ++ Buffer[Symbol.species] === Buffer) { ++ // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 ++ Object.defineProperty(Buffer, Symbol.species, { ++ value: null, ++ configurable: true ++ }) ++ } ++} + +- res[res.length - i - 1] = b; +- } +- } else { +- // Assume little-endian +- for (var i = 0; q.cmpn(0) !== 0; i++) { +- var b = q.andln(0xff); +- q.ishrn(8); ++function assertSize (size) { ++ if (typeof size !== 'number') { ++ throw new TypeError('"size" argument must be a number') ++ } else if (size < 0) { ++ throw new RangeError('"size" argument must not be negative') ++ } ++} + +- res[i] = b; +- } ++function alloc (that, size, fill, encoding) { ++ assertSize(size) ++ if (size <= 0) { ++ return createBuffer(that, size) + } ++ if (fill !== undefined) { ++ // Only pay attention to encoding if it's a string. This ++ // prevents accidentally sending in a number that would ++ // be interpretted as a start offset. ++ return typeof encoding === 'string' ++ ? createBuffer(that, size).fill(fill, encoding) ++ : createBuffer(that, size).fill(fill) ++ } ++ return createBuffer(that, size) ++} + +- return res; +-}; ++/** ++ * Creates a new filled Buffer instance. ++ * alloc(size[, fill[, encoding]]) ++ **/ ++Buffer.alloc = function (size, fill, encoding) { ++ return alloc(null, size, fill, encoding) ++} + +-if (Math.clz32) { +- BN.prototype._countBits = function _countBits(w) { +- return 32 - Math.clz32(w); +- }; +-} else { +- BN.prototype._countBits = function _countBits(w) { +- var t = w; +- var r = 0; +- if (t >= 0x1000) { +- r += 13; +- t >>>= 13; +- } +- if (t >= 0x40) { +- r += 7; +- t >>>= 7; +- } +- if (t >= 0x8) { +- r += 4; +- t >>>= 4; +- } +- if (t >= 0x02) { +- r += 2; +- t >>>= 2; ++function allocUnsafe (that, size) { ++ assertSize(size) ++ that = createBuffer(that, size < 0 ? 0 : checked(size) | 0) ++ if (!Buffer.TYPED_ARRAY_SUPPORT) { ++ for (var i = 0; i < size; ++i) { ++ that[i] = 0 + } +- return r + t; +- }; ++ } ++ return that + } + +-BN.prototype._zeroBits = function _zeroBits(w) { +- // Short-cut +- if (w === 0) +- return 26; ++/** ++ * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. ++ * */ ++Buffer.allocUnsafe = function (size) { ++ return allocUnsafe(null, size) ++} ++/** ++ * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. ++ */ ++Buffer.allocUnsafeSlow = function (size) { ++ return allocUnsafe(null, size) ++} + +- var t = w; +- var r = 0; +- if ((t & 0x1fff) === 0) { +- r += 13; +- t >>>= 13; +- } +- if ((t & 0x7f) === 0) { +- r += 7; +- t >>>= 7; +- } +- if ((t & 0xf) === 0) { +- r += 4; +- t >>>= 4; ++function fromString (that, string, encoding) { ++ if (typeof encoding !== 'string' || encoding === '') { ++ encoding = 'utf8' + } +- if ((t & 0x3) === 0) { +- r += 2; +- t >>>= 2; ++ ++ if (!Buffer.isEncoding(encoding)) { ++ throw new TypeError('"encoding" must be a valid string encoding') + } +- if ((t & 0x1) === 0) +- r++; +- return r; +-}; + +-// Return number of used bits in a BN +-BN.prototype.bitLength = function bitLength() { +- var hi = 0; +- var w = this.words[this.length - 1]; +- var hi = this._countBits(w); +- return (this.length - 1) * 26 + hi; +-}; ++ var length = byteLength(string, encoding) | 0 ++ that = createBuffer(that, length) + +-// Number of trailing zero bits +-BN.prototype.zeroBits = function zeroBits() { +- if (this.cmpn(0) === 0) +- return 0; ++ var actual = that.write(string, encoding) + +- var r = 0; +- for (var i = 0; i < this.length; i++) { +- var b = this._zeroBits(this.words[i]); +- r += b; +- if (b !== 26) +- break; ++ if (actual !== length) { ++ // Writing a hex string, for example, that contains invalid characters will ++ // cause everything after the first invalid character to be ignored. (e.g. ++ // 'abxxcd' will be treated as 'ab') ++ that = that.slice(0, actual) + } +- return r; +-}; + +-BN.prototype.byteLength = function byteLength() { +- return Math.ceil(this.bitLength() / 8); +-}; ++ return that ++} + +-// Return negative clone of `this` +-BN.prototype.neg = function neg() { +- if (this.cmpn(0) === 0) +- return this.clone(); ++function fromArrayLike (that, array) { ++ var length = array.length < 0 ? 0 : checked(array.length) | 0 ++ that = createBuffer(that, length) ++ for (var i = 0; i < length; i += 1) { ++ that[i] = array[i] & 255 ++ } ++ return that ++} + +- var r = this.clone(); +- r.sign = !this.sign; +- return r; +-}; ++function fromArrayBuffer (that, array, byteOffset, length) { ++ array.byteLength // this throws if `array` is not a valid ArrayBuffer + ++ if (byteOffset < 0 || array.byteLength < byteOffset) { ++ throw new RangeError('\'offset\' is out of bounds') ++ } + +-// Or `num` with `this` in-place +-BN.prototype.ior = function ior(num) { +- this.sign = this.sign || num.sign; ++ if (array.byteLength < byteOffset + (length || 0)) { ++ throw new RangeError('\'length\' is out of bounds') ++ } + +- while (this.length < num.length) +- this.words[this.length++] = 0; ++ if (byteOffset === undefined && length === undefined) { ++ array = new Uint8Array(array) ++ } else if (length === undefined) { ++ array = new Uint8Array(array, byteOffset) ++ } else { ++ array = new Uint8Array(array, byteOffset, length) ++ } + +- for (var i = 0; i < num.length; i++) +- this.words[i] = this.words[i] | num.words[i]; ++ if (Buffer.TYPED_ARRAY_SUPPORT) { ++ // Return an augmented `Uint8Array` instance, for best performance ++ that = array ++ that.__proto__ = Buffer.prototype ++ } else { ++ // Fallback: Return an object instance of the Buffer class ++ that = fromArrayLike(that, array) ++ } ++ return that ++} + +- return this.strip(); +-}; ++function fromObject (that, obj) { ++ if (Buffer.isBuffer(obj)) { ++ var len = checked(obj.length) | 0 ++ that = createBuffer(that, len) + ++ if (that.length === 0) { ++ return that ++ } + +-// Or `num` with `this` +-BN.prototype.or = function or(num) { +- if (this.length > num.length) +- return this.clone().ior(num); +- else +- return num.clone().ior(this); +-}; ++ obj.copy(that, 0, 0, len) ++ return that ++ } + ++ if (obj) { ++ if ((typeof ArrayBuffer !== 'undefined' && ++ obj.buffer instanceof ArrayBuffer) || 'length' in obj) { ++ if (typeof obj.length !== 'number' || isnan(obj.length)) { ++ return createBuffer(that, 0) ++ } ++ return fromArrayLike(that, obj) ++ } + +-// And `num` with `this` in-place +-BN.prototype.iand = function iand(num) { +- this.sign = this.sign && num.sign; ++ if (obj.type === 'Buffer' && isArray(obj.data)) { ++ return fromArrayLike(that, obj.data) ++ } ++ } + +- // b = min-length(num, this) +- var b; +- if (this.length > num.length) +- b = num; +- else +- b = this; ++ throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.') ++} + +- for (var i = 0; i < b.length; i++) +- this.words[i] = this.words[i] & num.words[i]; ++function checked (length) { ++ // Note: cannot use `length < kMaxLength()` here because that fails when ++ // length is NaN (which is otherwise coerced to zero.) ++ if (length >= kMaxLength()) { ++ throw new RangeError('Attempt to allocate Buffer larger than maximum ' + ++ 'size: 0x' + kMaxLength().toString(16) + ' bytes') ++ } ++ return length | 0 ++} + +- this.length = b.length; ++function SlowBuffer (length) { ++ if (+length != length) { // eslint-disable-line eqeqeq ++ length = 0 ++ } ++ return Buffer.alloc(+length) ++} + +- return this.strip(); +-}; ++Buffer.isBuffer = function isBuffer (b) { ++ return !!(b != null && b._isBuffer) ++} + ++Buffer.compare = function compare (a, b) { ++ if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { ++ throw new TypeError('Arguments must be Buffers') ++ } + +-// And `num` with `this` +-BN.prototype.and = function and(num) { +- if (this.length > num.length) +- return this.clone().iand(num); +- else +- return num.clone().iand(this); +-}; ++ if (a === b) return 0 ++ ++ var x = a.length ++ var y = b.length + ++ for (var i = 0, len = Math.min(x, y); i < len; ++i) { ++ if (a[i] !== b[i]) { ++ x = a[i] ++ y = b[i] ++ break ++ } ++ } + +-// Xor `num` with `this` in-place +-BN.prototype.ixor = function ixor(num) { +- this.sign = this.sign || num.sign; ++ if (x < y) return -1 ++ if (y < x) return 1 ++ return 0 ++} + +- // a.length > b.length +- var a; +- var b; +- if (this.length > num.length) { +- a = this; +- b = num; +- } else { +- a = num; +- b = this; ++Buffer.isEncoding = function isEncoding (encoding) { ++ switch (String(encoding).toLowerCase()) { ++ case 'hex': ++ case 'utf8': ++ case 'utf-8': ++ case 'ascii': ++ case 'latin1': ++ case 'binary': ++ case 'base64': ++ case 'ucs2': ++ case 'ucs-2': ++ case 'utf16le': ++ case 'utf-16le': ++ return true ++ default: ++ return false + } ++} + +- for (var i = 0; i < b.length; i++) +- this.words[i] = a.words[i] ^ b.words[i]; ++Buffer.concat = function concat (list, length) { ++ if (!isArray(list)) { ++ throw new TypeError('"list" argument must be an Array of Buffers') ++ } + +- if (this !== a) +- for (; i < a.length; i++) +- this.words[i] = a.words[i]; ++ if (list.length === 0) { ++ return Buffer.alloc(0) ++ } + +- this.length = a.length; ++ var i ++ if (length === undefined) { ++ length = 0 ++ for (i = 0; i < list.length; ++i) { ++ length += list[i].length ++ } ++ } + +- return this.strip(); +-}; ++ var buffer = Buffer.allocUnsafe(length) ++ var pos = 0 ++ for (i = 0; i < list.length; ++i) { ++ var buf = list[i] ++ if (!Buffer.isBuffer(buf)) { ++ throw new TypeError('"list" argument must be an Array of Buffers') ++ } ++ buf.copy(buffer, pos) ++ pos += buf.length ++ } ++ return buffer ++} + ++function byteLength (string, encoding) { ++ if (Buffer.isBuffer(string)) { ++ return string.length ++ } ++ if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' && ++ (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) { ++ return string.byteLength ++ } ++ if (typeof string !== 'string') { ++ string = '' + string ++ } + +-// Xor `num` with `this` +-BN.prototype.xor = function xor(num) { +- if (this.length > num.length) +- return this.clone().ixor(num); +- else +- return num.clone().ixor(this); +-}; +- ++ var len = string.length ++ if (len === 0) return 0 + +-// Set `bit` of `this` +-BN.prototype.setn = function setn(bit, val) { +- assert(typeof bit === 'number' && bit >= 0); ++ // Use a for loop to avoid recursion ++ var loweredCase = false ++ for (;;) { ++ switch (encoding) { ++ case 'ascii': ++ case 'latin1': ++ case 'binary': ++ return len ++ case 'utf8': ++ case 'utf-8': ++ case undefined: ++ return utf8ToBytes(string).length ++ case 'ucs2': ++ case 'ucs-2': ++ case 'utf16le': ++ case 'utf-16le': ++ return len * 2 ++ case 'hex': ++ return len >>> 1 ++ case 'base64': ++ return base64ToBytes(string).length ++ default: ++ if (loweredCase) return utf8ToBytes(string).length // assume utf8 ++ encoding = ('' + encoding).toLowerCase() ++ loweredCase = true ++ } ++ } ++} ++Buffer.byteLength = byteLength + +- var off = (bit / 26) | 0; +- var wbit = bit % 26; ++function slowToString (encoding, start, end) { ++ var loweredCase = false + +- while (this.length <= off) +- this.words[this.length++] = 0; ++ // No need to verify that "this.length <= MAX_UINT32" since it's a read-only ++ // property of a typed array. + +- if (val) +- this.words[off] = this.words[off] | (1 << wbit); +- else +- this.words[off] = this.words[off] & ~(1 << wbit); ++ // This behaves neither like String nor Uint8Array in that we set start/end ++ // to their upper/lower bounds if the value passed is out of range. ++ // undefined is handled specially as per ECMA-262 6th Edition, ++ // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. ++ if (start === undefined || start < 0) { ++ start = 0 ++ } ++ // Return early if start > this.length. Done here to prevent potential uint32 ++ // coercion fail below. ++ if (start > this.length) { ++ return '' ++ } + +- return this.strip(); +-}; ++ if (end === undefined || end > this.length) { ++ end = this.length ++ } + ++ if (end <= 0) { ++ return '' ++ } + +-// Add `num` to `this` in-place +-BN.prototype.iadd = function iadd(num) { +- // negative + positive +- if (this.sign && !num.sign) { +- this.sign = false; +- var r = this.isub(num); +- this.sign = !this.sign; +- return this._normSign(); ++ // Force coersion to uint32. This will also coerce falsey/NaN values to 0. ++ end >>>= 0 ++ start >>>= 0 + +- // positive + negative +- } else if (!this.sign && num.sign) { +- num.sign = false; +- var r = this.isub(num); +- num.sign = true; +- return r._normSign(); ++ if (end <= start) { ++ return '' + } + +- // a.length > b.length +- var a; +- var b; +- if (this.length > num.length) { +- a = this; +- b = num; +- } else { +- a = num; +- b = this; ++ if (!encoding) encoding = 'utf8' ++ ++ while (true) { ++ switch (encoding) { ++ case 'hex': ++ return hexSlice(this, start, end) ++ ++ case 'utf8': ++ case 'utf-8': ++ return utf8Slice(this, start, end) ++ ++ case 'ascii': ++ return asciiSlice(this, start, end) ++ ++ case 'latin1': ++ case 'binary': ++ return latin1Slice(this, start, end) ++ ++ case 'base64': ++ return base64Slice(this, start, end) ++ ++ case 'ucs2': ++ case 'ucs-2': ++ case 'utf16le': ++ case 'utf-16le': ++ return utf16leSlice(this, start, end) ++ ++ default: ++ if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) ++ encoding = (encoding + '').toLowerCase() ++ loweredCase = true ++ } + } ++} + +- var carry = 0; +- for (var i = 0; i < b.length; i++) { +- var r = a.words[i] + b.words[i] + carry; +- this.words[i] = r & 0x3ffffff; +- carry = r >>> 26; ++// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect ++// Buffer instances. ++Buffer.prototype._isBuffer = true ++ ++function swap (b, n, m) { ++ var i = b[n] ++ b[n] = b[m] ++ b[m] = i ++} ++ ++Buffer.prototype.swap16 = function swap16 () { ++ var len = this.length ++ if (len % 2 !== 0) { ++ throw new RangeError('Buffer size must be a multiple of 16-bits') + } +- for (; carry !== 0 && i < a.length; i++) { +- var r = a.words[i] + carry; +- this.words[i] = r & 0x3ffffff; +- carry = r >>> 26; ++ for (var i = 0; i < len; i += 2) { ++ swap(this, i, i + 1) + } ++ return this ++} + +- this.length = a.length; +- if (carry !== 0) { +- this.words[this.length] = carry; +- this.length++; +- // Copy the rest of the words +- } else if (a !== this) { +- for (; i < a.length; i++) +- this.words[i] = a.words[i]; ++Buffer.prototype.swap32 = function swap32 () { ++ var len = this.length ++ if (len % 4 !== 0) { ++ throw new RangeError('Buffer size must be a multiple of 32-bits') + } ++ for (var i = 0; i < len; i += 4) { ++ swap(this, i, i + 3) ++ swap(this, i + 1, i + 2) ++ } ++ return this ++} + +- return this; +-}; +- +-// Add `num` to `this` +-BN.prototype.add = function add(num) { +- if (num.sign && !this.sign) { +- num.sign = false; +- var res = this.sub(num); +- num.sign = true; +- return res; +- } else if (!num.sign && this.sign) { +- this.sign = false; +- var res = num.sub(this); +- this.sign = true; +- return res; ++Buffer.prototype.swap64 = function swap64 () { ++ var len = this.length ++ if (len % 8 !== 0) { ++ throw new RangeError('Buffer size must be a multiple of 64-bits') ++ } ++ for (var i = 0; i < len; i += 8) { ++ swap(this, i, i + 7) ++ swap(this, i + 1, i + 6) ++ swap(this, i + 2, i + 5) ++ swap(this, i + 3, i + 4) + } ++ return this ++} + +- if (this.length > num.length) +- return this.clone().iadd(num); +- else +- return num.clone().iadd(this); +-}; ++Buffer.prototype.toString = function toString () { ++ var length = this.length | 0 ++ if (length === 0) return '' ++ if (arguments.length === 0) return utf8Slice(this, 0, length) ++ return slowToString.apply(this, arguments) ++} + +-// Subtract `num` from `this` in-place +-BN.prototype.isub = function isub(num) { +- // this - (-num) = this + num +- if (num.sign) { +- num.sign = false; +- var r = this.iadd(num); +- num.sign = true; +- return r._normSign(); ++Buffer.prototype.equals = function equals (b) { ++ if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') ++ if (this === b) return true ++ return Buffer.compare(this, b) === 0 ++} + +- // -this - num = -(this + num) +- } else if (this.sign) { +- this.sign = false; +- this.iadd(num); +- this.sign = true; +- return this._normSign(); ++Buffer.prototype.inspect = function inspect () { ++ var str = '' ++ var max = exports.INSPECT_MAX_BYTES ++ if (this.length > 0) { ++ str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') ++ if (this.length > max) str += ' ... ' + } ++ return '' ++} + +- // At this point both numbers are positive +- var cmp = this.cmp(num); ++Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { ++ if (!Buffer.isBuffer(target)) { ++ throw new TypeError('Argument must be a Buffer') ++ } + +- // Optimization - zeroify +- if (cmp === 0) { +- this.sign = false; +- this.length = 1; +- this.words[0] = 0; +- return this; ++ if (start === undefined) { ++ start = 0 ++ } ++ if (end === undefined) { ++ end = target ? target.length : 0 ++ } ++ if (thisStart === undefined) { ++ thisStart = 0 ++ } ++ if (thisEnd === undefined) { ++ thisEnd = this.length + } + +- // a > b +- var a; +- var b; +- if (cmp > 0) { +- a = this; +- b = num; +- } else { +- a = num; +- b = this; ++ if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { ++ throw new RangeError('out of range index') + } + +- var carry = 0; +- for (var i = 0; i < b.length; i++) { +- var r = a.words[i] - b.words[i] + carry; +- carry = r >> 26; +- this.words[i] = r & 0x3ffffff; ++ if (thisStart >= thisEnd && start >= end) { ++ return 0 + } +- for (; carry !== 0 && i < a.length; i++) { +- var r = a.words[i] + carry; +- carry = r >> 26; +- this.words[i] = r & 0x3ffffff; ++ if (thisStart >= thisEnd) { ++ return -1 ++ } ++ if (start >= end) { ++ return 1 + } + +- // Copy rest of the words +- if (carry === 0 && i < a.length && a !== this) +- for (; i < a.length; i++) +- this.words[i] = a.words[i]; +- this.length = Math.max(this.length, i); ++ start >>>= 0 ++ end >>>= 0 ++ thisStart >>>= 0 ++ thisEnd >>>= 0 + +- if (a !== this) +- this.sign = true; ++ if (this === target) return 0 + +- return this.strip(); +-}; ++ var x = thisEnd - thisStart ++ var y = end - start ++ var len = Math.min(x, y) + +-// Subtract `num` from `this` +-BN.prototype.sub = function sub(num) { +- return this.clone().isub(num); +-}; ++ var thisCopy = this.slice(thisStart, thisEnd) ++ var targetCopy = target.slice(start, end) + +-/* +-// NOTE: This could be potentionally used to generate loop-less multiplications +-function _genCombMulTo(alen, blen) { +- var len = alen + blen - 1; +- var src = [ +- 'var a = this.words, b = num.words, o = out.words, c = 0, w, ' + +- 'mask = 0x3ffffff, shift = 0x4000000;', +- 'out.length = ' + len + ';' +- ]; +- for (var k = 0; k < len; k++) { +- var minJ = Math.max(0, k - alen + 1); +- var maxJ = Math.min(k, blen - 1); ++ for (var i = 0; i < len; ++i) { ++ if (thisCopy[i] !== targetCopy[i]) { ++ x = thisCopy[i] ++ y = targetCopy[i] ++ break ++ } ++ } + +- for (var j = minJ; j <= maxJ; j++) { +- var i = k - j; +- var mul = 'a[' + i + '] * b[' + j + ']'; ++ if (x < y) return -1 ++ if (y < x) return 1 ++ return 0 ++} + +- if (j === minJ) { +- src.push('w = ' + mul + ' + c;'); +- src.push('c = (w / shift) | 0;'); ++// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, ++// OR the last index of `val` in `buffer` at offset <= `byteOffset`. ++// ++// Arguments: ++// - buffer - a Buffer to search ++// - val - a string, Buffer, or number ++// - byteOffset - an index into `buffer`; will be clamped to an int32 ++// - encoding - an optional encoding, relevant is val is a string ++// - dir - true for indexOf, false for lastIndexOf ++function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { ++ // Empty buffer means no match ++ if (buffer.length === 0) return -1 ++ ++ // Normalize byteOffset ++ if (typeof byteOffset === 'string') { ++ encoding = byteOffset ++ byteOffset = 0 ++ } else if (byteOffset > 0x7fffffff) { ++ byteOffset = 0x7fffffff ++ } else if (byteOffset < -0x80000000) { ++ byteOffset = -0x80000000 ++ } ++ byteOffset = +byteOffset // Coerce to Number. ++ if (isNaN(byteOffset)) { ++ // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer ++ byteOffset = dir ? 0 : (buffer.length - 1) ++ } ++ ++ // Normalize byteOffset: negative offsets start from the end of the buffer ++ if (byteOffset < 0) byteOffset = buffer.length + byteOffset ++ if (byteOffset >= buffer.length) { ++ if (dir) return -1 ++ else byteOffset = buffer.length - 1 ++ } else if (byteOffset < 0) { ++ if (dir) byteOffset = 0 ++ else return -1 ++ } ++ ++ // Normalize val ++ if (typeof val === 'string') { ++ val = Buffer.from(val, encoding) ++ } ++ ++ // Finally, search either indexOf (if dir is true) or lastIndexOf ++ if (Buffer.isBuffer(val)) { ++ // Special case: looking for empty string/buffer always fails ++ if (val.length === 0) { ++ return -1 ++ } ++ return arrayIndexOf(buffer, val, byteOffset, encoding, dir) ++ } else if (typeof val === 'number') { ++ val = val & 0xFF // Search for a byte value [0-255] ++ if (Buffer.TYPED_ARRAY_SUPPORT && ++ typeof Uint8Array.prototype.indexOf === 'function') { ++ if (dir) { ++ return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) + } else { +- src.push('w += ' + mul + ';'); +- src.push('c += (w / shift) | 0;'); ++ return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) + } +- src.push('w &= mask;'); + } +- src.push('o[' + k + '] = w;'); ++ return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) + } +- src.push('if (c !== 0) {', +- ' o[' + k + '] = c;', +- ' out.length++;', +- '}', +- 'return out;'); + +- return src.join('\n'); ++ throw new TypeError('val must be string, number or Buffer') + } +-*/ + +-BN.prototype._smallMulTo = function _smallMulTo(num, out) { +- out.sign = num.sign !== this.sign; +- out.length = this.length + num.length; ++function arrayIndexOf (arr, val, byteOffset, encoding, dir) { ++ var indexSize = 1 ++ var arrLength = arr.length ++ var valLength = val.length + +- var carry = 0; +- for (var k = 0; k < out.length - 1; k++) { +- // Sum all words with the same `i + j = k` and accumulate `ncarry`, +- // note that ncarry could be >= 0x3ffffff +- var ncarry = carry >>> 26; +- var rword = carry & 0x3ffffff; +- var maxJ = Math.min(k, num.length - 1); +- for (var j = Math.max(0, k - this.length + 1); j <= maxJ; j++) { +- var i = k - j; +- var a = this.words[i] | 0; +- var b = num.words[j] | 0; +- var r = a * b; ++ if (encoding !== undefined) { ++ encoding = String(encoding).toLowerCase() ++ if (encoding === 'ucs2' || encoding === 'ucs-2' || ++ encoding === 'utf16le' || encoding === 'utf-16le') { ++ if (arr.length < 2 || val.length < 2) { ++ return -1 ++ } ++ indexSize = 2 ++ arrLength /= 2 ++ valLength /= 2 ++ byteOffset /= 2 ++ } ++ } + +- var lo = r & 0x3ffffff; +- ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0; +- lo = (lo + rword) | 0; +- rword = lo & 0x3ffffff; +- ncarry = (ncarry + (lo >>> 26)) | 0; ++ function read (buf, i) { ++ if (indexSize === 1) { ++ return buf[i] ++ } else { ++ return buf.readUInt16BE(i * indexSize) + } +- out.words[k] = rword; +- carry = ncarry; + } +- if (carry !== 0) { +- out.words[k] = carry; ++ ++ var i ++ if (dir) { ++ var foundIndex = -1 ++ for (i = byteOffset; i < arrLength; i++) { ++ if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { ++ if (foundIndex === -1) foundIndex = i ++ if (i - foundIndex + 1 === valLength) return foundIndex * indexSize ++ } else { ++ if (foundIndex !== -1) i -= i - foundIndex ++ foundIndex = -1 ++ } ++ } + } else { +- out.length--; ++ if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength ++ for (i = byteOffset; i >= 0; i--) { ++ var found = true ++ for (var j = 0; j < valLength; j++) { ++ if (read(arr, i + j) !== read(val, j)) { ++ found = false ++ break ++ } ++ } ++ if (found) return i ++ } + } + +- return out.strip(); +-}; ++ return -1 ++} + +-BN.prototype._bigMulTo = function _bigMulTo(num, out) { +- out.sign = num.sign !== this.sign; +- out.length = this.length + num.length; ++Buffer.prototype.includes = function includes (val, byteOffset, encoding) { ++ return this.indexOf(val, byteOffset, encoding) !== -1 ++} + +- var carry = 0; +- var hncarry = 0; +- for (var k = 0; k < out.length - 1; k++) { +- // Sum all words with the same `i + j = k` and accumulate `ncarry`, +- // note that ncarry could be >= 0x3ffffff +- var ncarry = hncarry; +- hncarry = 0; +- var rword = carry & 0x3ffffff; +- var maxJ = Math.min(k, num.length - 1); +- for (var j = Math.max(0, k - this.length + 1); j <= maxJ; j++) { +- var i = k - j; +- var a = this.words[i] | 0; +- var b = num.words[j] | 0; +- var r = a * b; ++Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { ++ return bidirectionalIndexOf(this, val, byteOffset, encoding, true) ++} + +- var lo = r & 0x3ffffff; +- ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0; +- lo = (lo + rword) | 0; +- rword = lo & 0x3ffffff; +- ncarry = (ncarry + (lo >>> 26)) | 0; ++Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { ++ return bidirectionalIndexOf(this, val, byteOffset, encoding, false) ++} + +- hncarry += ncarry >>> 26; +- ncarry &= 0x3ffffff; +- } +- out.words[k] = rword; +- carry = ncarry; +- ncarry = hncarry; +- } +- if (carry !== 0) { +- out.words[k] = carry; ++function hexWrite (buf, string, offset, length) { ++ offset = Number(offset) || 0 ++ var remaining = buf.length - offset ++ if (!length) { ++ length = remaining + } else { +- out.length--; ++ length = Number(length) ++ if (length > remaining) { ++ length = remaining ++ } + } + +- return out.strip(); +-}; ++ // must be an even number of digits ++ var strLen = string.length ++ if (strLen % 2 !== 0) throw new TypeError('Invalid hex string') + +-BN.prototype.mulTo = function mulTo(num, out) { +- var res; +- if (this.length + num.length < 63) +- res = this._smallMulTo(num, out); +- else +- res = this._bigMulTo(num, out); +- return res; +-}; ++ if (length > strLen / 2) { ++ length = strLen / 2 ++ } ++ for (var i = 0; i < length; ++i) { ++ var parsed = parseInt(string.substr(i * 2, 2), 16) ++ if (isNaN(parsed)) return i ++ buf[offset + i] = parsed ++ } ++ return i ++} + +-// Multiply `this` by `num` +-BN.prototype.mul = function mul(num) { +- var out = new BN(null); +- out.words = new Array(this.length + num.length); +- return this.mulTo(num, out); +-}; ++function utf8Write (buf, string, offset, length) { ++ return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) ++} + +-// In-place Multiplication +-BN.prototype.imul = function imul(num) { +- if (this.cmpn(0) === 0 || num.cmpn(0) === 0) { +- this.words[0] = 0; +- this.length = 1; +- return this; +- } ++function asciiWrite (buf, string, offset, length) { ++ return blitBuffer(asciiToBytes(string), buf, offset, length) ++} + +- var tlen = this.length; +- var nlen = num.length; ++function latin1Write (buf, string, offset, length) { ++ return asciiWrite(buf, string, offset, length) ++} + +- this.sign = num.sign !== this.sign; +- this.length = this.length + num.length; +- this.words[this.length - 1] = 0; ++function base64Write (buf, string, offset, length) { ++ return blitBuffer(base64ToBytes(string), buf, offset, length) ++} + +- for (var k = this.length - 2; k >= 0; k--) { +- // Sum all words with the same `i + j = k` and accumulate `carry`, +- // note that carry could be >= 0x3ffffff +- var carry = 0; +- var rword = 0; +- var maxJ = Math.min(k, nlen - 1); +- for (var j = Math.max(0, k - tlen + 1); j <= maxJ; j++) { +- var i = k - j; +- var a = this.words[i]; +- var b = num.words[j]; +- var r = a * b; ++function ucs2Write (buf, string, offset, length) { ++ return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) ++} + +- var lo = r & 0x3ffffff; +- carry += (r / 0x4000000) | 0; +- lo += rword; +- rword = lo & 0x3ffffff; +- carry += lo >>> 26; ++Buffer.prototype.write = function write (string, offset, length, encoding) { ++ // Buffer#write(string) ++ if (offset === undefined) { ++ encoding = 'utf8' ++ length = this.length ++ offset = 0 ++ // Buffer#write(string, encoding) ++ } else if (length === undefined && typeof offset === 'string') { ++ encoding = offset ++ length = this.length ++ offset = 0 ++ // Buffer#write(string, offset[, length][, encoding]) ++ } else if (isFinite(offset)) { ++ offset = offset | 0 ++ if (isFinite(length)) { ++ length = length | 0 ++ if (encoding === undefined) encoding = 'utf8' ++ } else { ++ encoding = length ++ length = undefined + } +- this.words[k] = rword; +- this.words[k + 1] += carry; +- carry = 0; +- } +- +- // Propagate overflows +- var carry = 0; +- for (var i = 1; i < this.length; i++) { +- var w = this.words[i] + carry; +- this.words[i] = w & 0x3ffffff; +- carry = w >>> 26; ++ // legacy write(string, encoding, offset, length) - remove in v0.13 ++ } else { ++ throw new Error( ++ 'Buffer.write(string, encoding, offset[, length]) is no longer supported' ++ ) + } + +- return this.strip(); +-}; +- +-BN.prototype.imuln = function imuln(num) { +- assert(typeof num === 'number'); ++ var remaining = this.length - offset ++ if (length === undefined || length > remaining) length = remaining + +- // Carry +- var carry = 0; +- for (var i = 0; i < this.length; i++) { +- var w = this.words[i] * num; +- var lo = (w & 0x3ffffff) + (carry & 0x3ffffff); +- carry >>= 26; +- carry += (w / 0x4000000) | 0; +- // NOTE: lo is 27bit maximum +- carry += lo >>> 26; +- this.words[i] = lo & 0x3ffffff; ++ if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { ++ throw new RangeError('Attempt to write outside buffer bounds') + } + +- if (carry !== 0) { +- this.words[i] = carry; +- this.length++; +- } ++ if (!encoding) encoding = 'utf8' + +- return this; +-}; ++ var loweredCase = false ++ for (;;) { ++ switch (encoding) { ++ case 'hex': ++ return hexWrite(this, string, offset, length) + +-BN.prototype.muln = function muln(num) { +- return this.clone().imuln(num); +-}; ++ case 'utf8': ++ case 'utf-8': ++ return utf8Write(this, string, offset, length) + +-// `this` * `this` +-BN.prototype.sqr = function sqr() { +- return this.mul(this); +-}; ++ case 'ascii': ++ return asciiWrite(this, string, offset, length) + +-// `this` * `this` in-place +-BN.prototype.isqr = function isqr() { +- return this.mul(this); +-}; ++ case 'latin1': ++ case 'binary': ++ return latin1Write(this, string, offset, length) + +-// Shift-left in-place +-BN.prototype.ishln = function ishln(bits) { +- assert(typeof bits === 'number' && bits >= 0); +- var r = bits % 26; +- var s = (bits - r) / 26; +- var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r); ++ case 'base64': ++ // Warning: maxLength not taken into account in base64Write ++ return base64Write(this, string, offset, length) + +- if (r !== 0) { +- var carry = 0; +- for (var i = 0; i < this.length; i++) { +- var newCarry = this.words[i] & carryMask; +- var c = (this.words[i] - newCarry) << r; +- this.words[i] = c | carry; +- carry = newCarry >>> (26 - r); +- } +- if (carry) { +- this.words[i] = carry; +- this.length++; ++ case 'ucs2': ++ case 'ucs-2': ++ case 'utf16le': ++ case 'utf-16le': ++ return ucs2Write(this, string, offset, length) ++ ++ default: ++ if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) ++ encoding = ('' + encoding).toLowerCase() ++ loweredCase = true + } + } ++} + +- if (s !== 0) { +- for (var i = this.length - 1; i >= 0; i--) +- this.words[i + s] = this.words[i]; +- for (var i = 0; i < s; i++) +- this.words[i] = 0; +- this.length += s; ++Buffer.prototype.toJSON = function toJSON () { ++ return { ++ type: 'Buffer', ++ data: Array.prototype.slice.call(this._arr || this, 0) + } ++} + +- return this.strip(); +-}; ++function base64Slice (buf, start, end) { ++ if (start === 0 && end === buf.length) { ++ return base64.fromByteArray(buf) ++ } else { ++ return base64.fromByteArray(buf.slice(start, end)) ++ } ++} + +-// Shift-right in-place +-// NOTE: `hint` is a lowest bit before trailing zeroes +-// NOTE: if `extended` is present - it will be filled with destroyed bits +-BN.prototype.ishrn = function ishrn(bits, hint, extended) { +- assert(typeof bits === 'number' && bits >= 0); +- var h; +- if (hint) +- h = (hint - (hint % 26)) / 26; +- else +- h = 0; ++function utf8Slice (buf, start, end) { ++ end = Math.min(buf.length, end) ++ var res = [] + +- var r = bits % 26; +- var s = Math.min((bits - r) / 26, this.length); +- var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); +- var maskedWords = extended; ++ var i = start ++ while (i < end) { ++ var firstByte = buf[i] ++ var codePoint = null ++ var bytesPerSequence = (firstByte > 0xEF) ? 4 ++ : (firstByte > 0xDF) ? 3 ++ : (firstByte > 0xBF) ? 2 ++ : 1 + +- h -= s; +- h = Math.max(0, h); ++ if (i + bytesPerSequence <= end) { ++ var secondByte, thirdByte, fourthByte, tempCodePoint + +- // Extended mode, copy masked part +- if (maskedWords) { +- for (var i = 0; i < s; i++) +- maskedWords.words[i] = this.words[i]; +- maskedWords.length = s; +- } ++ switch (bytesPerSequence) { ++ case 1: ++ if (firstByte < 0x80) { ++ codePoint = firstByte ++ } ++ break ++ case 2: ++ secondByte = buf[i + 1] ++ if ((secondByte & 0xC0) === 0x80) { ++ tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) ++ if (tempCodePoint > 0x7F) { ++ codePoint = tempCodePoint ++ } ++ } ++ break ++ case 3: ++ secondByte = buf[i + 1] ++ thirdByte = buf[i + 2] ++ if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { ++ tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) ++ if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { ++ codePoint = tempCodePoint ++ } ++ } ++ break ++ case 4: ++ secondByte = buf[i + 1] ++ thirdByte = buf[i + 2] ++ fourthByte = buf[i + 3] ++ if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { ++ tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) ++ if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { ++ codePoint = tempCodePoint ++ } ++ } ++ } ++ } + +- if (s === 0) { +- // No-op, we should not move anything at all +- } else if (this.length > s) { +- this.length -= s; +- for (var i = 0; i < this.length; i++) +- this.words[i] = this.words[i + s]; +- } else { +- this.words[0] = 0; +- this.length = 1; +- } ++ if (codePoint === null) { ++ // we did not generate a valid codePoint so insert a ++ // replacement char (U+FFFD) and advance only 1 byte ++ codePoint = 0xFFFD ++ bytesPerSequence = 1 ++ } else if (codePoint > 0xFFFF) { ++ // encode to utf16 (surrogate pair dance) ++ codePoint -= 0x10000 ++ res.push(codePoint >>> 10 & 0x3FF | 0xD800) ++ codePoint = 0xDC00 | codePoint & 0x3FF ++ } + +- var carry = 0; +- for (var i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) { +- var word = this.words[i]; +- this.words[i] = (carry << (26 - r)) | (word >>> r); +- carry = word & mask; ++ res.push(codePoint) ++ i += bytesPerSequence + } + +- // Push carried bits as a mask +- if (maskedWords && carry !== 0) +- maskedWords.words[maskedWords.length++] = carry; ++ return decodeCodePointsArray(res) ++} + +- if (this.length === 0) { +- this.words[0] = 0; +- this.length = 1; +- } ++// Based on http://stackoverflow.com/a/22747272/680742, the browser with ++// the lowest limit is Chrome, with 0x10000 args. ++// We go 1 magnitude less, for safety ++var MAX_ARGUMENTS_LENGTH = 0x1000 + +- this.strip(); ++function decodeCodePointsArray (codePoints) { ++ var len = codePoints.length ++ if (len <= MAX_ARGUMENTS_LENGTH) { ++ return String.fromCharCode.apply(String, codePoints) // avoid extra slice() ++ } + +- return this; +-}; ++ // Decode in chunks to avoid "call stack size exceeded". ++ var res = '' ++ var i = 0 ++ while (i < len) { ++ res += String.fromCharCode.apply( ++ String, ++ codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) ++ ) ++ } ++ return res ++} + +-// Shift-left +-BN.prototype.shln = function shln(bits) { +- return this.clone().ishln(bits); +-}; ++function asciiSlice (buf, start, end) { ++ var ret = '' ++ end = Math.min(buf.length, end) + +-// Shift-right +-BN.prototype.shrn = function shrn(bits) { +- return this.clone().ishrn(bits); +-}; ++ for (var i = start; i < end; ++i) { ++ ret += String.fromCharCode(buf[i] & 0x7F) ++ } ++ return ret ++} + +-// Test if n bit is set +-BN.prototype.testn = function testn(bit) { +- assert(typeof bit === 'number' && bit >= 0); +- var r = bit % 26; +- var s = (bit - r) / 26; +- var q = 1 << r; ++function latin1Slice (buf, start, end) { ++ var ret = '' ++ end = Math.min(buf.length, end) + +- // Fast case: bit is much higher than all existing words +- if (this.length <= s) { +- return false; ++ for (var i = start; i < end; ++i) { ++ ret += String.fromCharCode(buf[i]) + } ++ return ret ++} + +- // Check bit and return +- var w = this.words[s]; ++function hexSlice (buf, start, end) { ++ var len = buf.length + +- return !!(w & q); +-}; ++ if (!start || start < 0) start = 0 ++ if (!end || end < 0 || end > len) end = len + +-// Return only lowers bits of number (in-place) +-BN.prototype.imaskn = function imaskn(bits) { +- assert(typeof bits === 'number' && bits >= 0); +- var r = bits % 26; +- var s = (bits - r) / 26; ++ var out = '' ++ for (var i = start; i < end; ++i) { ++ out += toHex(buf[i]) ++ } ++ return out ++} + +- assert(!this.sign, 'imaskn works only with positive numbers'); ++function utf16leSlice (buf, start, end) { ++ var bytes = buf.slice(start, end) ++ var res = '' ++ for (var i = 0; i < bytes.length; i += 2) { ++ res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256) ++ } ++ return res ++} + +- if (r !== 0) +- s++; +- this.length = Math.min(s, this.length); ++Buffer.prototype.slice = function slice (start, end) { ++ var len = this.length ++ start = ~~start ++ end = end === undefined ? len : ~~end + +- if (r !== 0) { +- var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); +- this.words[this.length - 1] &= mask; ++ if (start < 0) { ++ start += len ++ if (start < 0) start = 0 ++ } else if (start > len) { ++ start = len + } + +- return this.strip(); +-}; +- +-// Return only lowers bits of number +-BN.prototype.maskn = function maskn(bits) { +- return this.clone().imaskn(bits); +-}; ++ if (end < 0) { ++ end += len ++ if (end < 0) end = 0 ++ } else if (end > len) { ++ end = len ++ } + +-// Add plain number `num` to `this` +-BN.prototype.iaddn = function iaddn(num) { +- assert(typeof num === 'number'); +- if (num < 0) +- return this.isubn(-num); ++ if (end < start) end = start + +- // Possible sign change +- if (this.sign) { +- if (this.length === 1 && this.words[0] < num) { +- this.words[0] = num - this.words[0]; +- this.sign = false; +- return this; ++ var newBuf ++ if (Buffer.TYPED_ARRAY_SUPPORT) { ++ newBuf = this.subarray(start, end) ++ newBuf.__proto__ = Buffer.prototype ++ } else { ++ var sliceLen = end - start ++ newBuf = new Buffer(sliceLen, undefined) ++ for (var i = 0; i < sliceLen; ++i) { ++ newBuf[i] = this[i + start] + } +- +- this.sign = false; +- this.isubn(num); +- this.sign = true; +- return this; + } + +- // Add without checks +- return this._iaddn(num); +-}; ++ return newBuf ++} + +-BN.prototype._iaddn = function _iaddn(num) { +- this.words[0] += num; ++/* ++ * Need to make sure that buffer isn't trying to write out of bounds. ++ */ ++function checkOffset (offset, ext, length) { ++ if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') ++ if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') ++} + +- // Carry +- for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) { +- this.words[i] -= 0x4000000; +- if (i === this.length - 1) +- this.words[i + 1] = 1; +- else +- this.words[i + 1]++; ++Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { ++ offset = offset | 0 ++ byteLength = byteLength | 0 ++ if (!noAssert) checkOffset(offset, byteLength, this.length) ++ ++ var val = this[offset] ++ var mul = 1 ++ var i = 0 ++ while (++i < byteLength && (mul *= 0x100)) { ++ val += this[offset + i] * mul + } +- this.length = Math.max(this.length, i + 1); + +- return this; +-}; ++ return val ++} + +-// Subtract plain number `num` from `this` +-BN.prototype.isubn = function isubn(num) { +- assert(typeof num === 'number'); +- if (num < 0) +- return this.iaddn(-num); ++Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { ++ offset = offset | 0 ++ byteLength = byteLength | 0 ++ if (!noAssert) { ++ checkOffset(offset, byteLength, this.length) ++ } + +- if (this.sign) { +- this.sign = false; +- this.iaddn(num); +- this.sign = true; +- return this; ++ var val = this[offset + --byteLength] ++ var mul = 1 ++ while (byteLength > 0 && (mul *= 0x100)) { ++ val += this[offset + --byteLength] * mul + } + +- this.words[0] -= num; ++ return val ++} + +- // Carry +- for (var i = 0; i < this.length && this.words[i] < 0; i++) { +- this.words[i] += 0x4000000; +- this.words[i + 1] -= 1; +- } ++Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { ++ if (!noAssert) checkOffset(offset, 1, this.length) ++ return this[offset] ++} + +- return this.strip(); +-}; ++Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { ++ if (!noAssert) checkOffset(offset, 2, this.length) ++ return this[offset] | (this[offset + 1] << 8) ++} + +-BN.prototype.addn = function addn(num) { +- return this.clone().iaddn(num); +-}; ++Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { ++ if (!noAssert) checkOffset(offset, 2, this.length) ++ return (this[offset] << 8) | this[offset + 1] ++} + +-BN.prototype.subn = function subn(num) { +- return this.clone().isubn(num); +-}; ++Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { ++ if (!noAssert) checkOffset(offset, 4, this.length) + +-BN.prototype.iabs = function iabs() { +- this.sign = false; ++ return ((this[offset]) | ++ (this[offset + 1] << 8) | ++ (this[offset + 2] << 16)) + ++ (this[offset + 3] * 0x1000000) ++} + +- return this; +-}; ++Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { ++ if (!noAssert) checkOffset(offset, 4, this.length) + +-BN.prototype.abs = function abs() { +- return this.clone().iabs(); +-}; ++ return (this[offset] * 0x1000000) + ++ ((this[offset + 1] << 16) | ++ (this[offset + 2] << 8) | ++ this[offset + 3]) ++} + +-BN.prototype._ishlnsubmul = function _ishlnsubmul(num, mul, shift) { +- // Bigger storage is needed +- var len = num.length + shift; +- var i; +- if (this.words.length < len) { +- var t = new Array(len); +- for (var i = 0; i < this.length; i++) +- t[i] = this.words[i]; +- this.words = t; +- } else { +- i = this.length; ++Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { ++ offset = offset | 0 ++ byteLength = byteLength | 0 ++ if (!noAssert) checkOffset(offset, byteLength, this.length) ++ ++ var val = this[offset] ++ var mul = 1 ++ var i = 0 ++ while (++i < byteLength && (mul *= 0x100)) { ++ val += this[offset + i] * mul + } ++ mul *= 0x80 + +- // Zeroify rest +- this.length = Math.max(this.length, len); +- for (; i < this.length; i++) +- this.words[i] = 0; ++ if (val >= mul) val -= Math.pow(2, 8 * byteLength) + +- var carry = 0; +- for (var i = 0; i < num.length; i++) { +- var w = this.words[i + shift] + carry; +- var right = num.words[i] * mul; +- w -= right & 0x3ffffff; +- carry = (w >> 26) - ((right / 0x4000000) | 0); +- this.words[i + shift] = w & 0x3ffffff; +- } +- for (; i < this.length - shift; i++) { +- var w = this.words[i + shift] + carry; +- carry = w >> 26; +- this.words[i + shift] = w & 0x3ffffff; +- } ++ return val ++} + +- if (carry === 0) +- return this.strip(); ++Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { ++ offset = offset | 0 ++ byteLength = byteLength | 0 ++ if (!noAssert) checkOffset(offset, byteLength, this.length) + +- // Subtraction overflow +- assert(carry === -1); +- carry = 0; +- for (var i = 0; i < this.length; i++) { +- var w = -this.words[i] + carry; +- carry = w >> 26; +- this.words[i] = w & 0x3ffffff; ++ var i = byteLength ++ var mul = 1 ++ var val = this[offset + --i] ++ while (i > 0 && (mul *= 0x100)) { ++ val += this[offset + --i] * mul + } +- this.sign = true; ++ mul *= 0x80 + +- return this.strip(); +-}; ++ if (val >= mul) val -= Math.pow(2, 8 * byteLength) + +-BN.prototype._wordDiv = function _wordDiv(num, mode) { +- var shift = this.length - num.length; ++ return val ++} + +- var a = this.clone(); +- var b = num; ++Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { ++ if (!noAssert) checkOffset(offset, 1, this.length) ++ if (!(this[offset] & 0x80)) return (this[offset]) ++ return ((0xff - this[offset] + 1) * -1) ++} + +- // Normalize +- var bhi = b.words[b.length - 1]; +- var bhiBits = this._countBits(bhi); +- shift = 26 - bhiBits; +- if (shift !== 0) { +- b = b.shln(shift); +- a.ishln(shift); +- bhi = b.words[b.length - 1]; +- } ++Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { ++ if (!noAssert) checkOffset(offset, 2, this.length) ++ var val = this[offset] | (this[offset + 1] << 8) ++ return (val & 0x8000) ? val | 0xFFFF0000 : val ++} + +- // Initialize quotient +- var m = a.length - b.length; +- var q; ++Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { ++ if (!noAssert) checkOffset(offset, 2, this.length) ++ var val = this[offset + 1] | (this[offset] << 8) ++ return (val & 0x8000) ? val | 0xFFFF0000 : val ++} + +- if (mode !== 'mod') { +- q = new BN(null); +- q.length = m + 1; +- q.words = new Array(q.length); +- for (var i = 0; i < q.length; i++) +- q.words[i] = 0; ++Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { ++ if (!noAssert) checkOffset(offset, 4, this.length) ++ ++ return (this[offset]) | ++ (this[offset + 1] << 8) | ++ (this[offset + 2] << 16) | ++ (this[offset + 3] << 24) ++} ++ ++Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { ++ if (!noAssert) checkOffset(offset, 4, this.length) ++ ++ return (this[offset] << 24) | ++ (this[offset + 1] << 16) | ++ (this[offset + 2] << 8) | ++ (this[offset + 3]) ++} ++ ++Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { ++ if (!noAssert) checkOffset(offset, 4, this.length) ++ return ieee754.read(this, offset, true, 23, 4) ++} ++ ++Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { ++ if (!noAssert) checkOffset(offset, 4, this.length) ++ return ieee754.read(this, offset, false, 23, 4) ++} ++ ++Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { ++ if (!noAssert) checkOffset(offset, 8, this.length) ++ return ieee754.read(this, offset, true, 52, 8) ++} ++ ++Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { ++ if (!noAssert) checkOffset(offset, 8, this.length) ++ return ieee754.read(this, offset, false, 52, 8) ++} ++ ++function checkInt (buf, value, offset, ext, max, min) { ++ if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') ++ if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') ++ if (offset + ext > buf.length) throw new RangeError('Index out of range') ++} ++ ++Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { ++ value = +value ++ offset = offset | 0 ++ byteLength = byteLength | 0 ++ if (!noAssert) { ++ var maxBytes = Math.pow(2, 8 * byteLength) - 1 ++ checkInt(this, value, offset, byteLength, maxBytes, 0) + } + +- var diff = a.clone()._ishlnsubmul(b, 1, m); +- if (!diff.sign) { +- a = diff; +- if (q) +- q.words[m] = 1; ++ var mul = 1 ++ var i = 0 ++ this[offset] = value & 0xFF ++ while (++i < byteLength && (mul *= 0x100)) { ++ this[offset + i] = (value / mul) & 0xFF + } + +- for (var j = m - 1; j >= 0; j--) { +- var qj = a.words[b.length + j] * 0x4000000 + a.words[b.length + j - 1]; ++ return offset + byteLength ++} + +- // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max +- // (0x7ffffff) +- qj = Math.min((qj / bhi) | 0, 0x3ffffff); ++Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { ++ value = +value ++ offset = offset | 0 ++ byteLength = byteLength | 0 ++ if (!noAssert) { ++ var maxBytes = Math.pow(2, 8 * byteLength) - 1 ++ checkInt(this, value, offset, byteLength, maxBytes, 0) ++ } + +- a._ishlnsubmul(b, qj, j); +- while (a.sign) { +- qj--; +- a.sign = false; +- a._ishlnsubmul(b, 1, j); +- if (a.cmpn(0) !== 0) +- a.sign = !a.sign; +- } +- if (q) +- q.words[j] = qj; ++ var i = byteLength - 1 ++ var mul = 1 ++ this[offset + i] = value & 0xFF ++ while (--i >= 0 && (mul *= 0x100)) { ++ this[offset + i] = (value / mul) & 0xFF + } +- if (q) +- q.strip(); +- a.strip(); + +- // Denormalize +- if (mode !== 'div' && shift !== 0) +- a.ishrn(shift); +- return { div: q ? q : null, mod: a }; +-}; ++ return offset + byteLength ++} + +-BN.prototype.divmod = function divmod(num, mode) { +- assert(num.cmpn(0) !== 0); ++Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { ++ value = +value ++ offset = offset | 0 ++ if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) ++ if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) ++ this[offset] = (value & 0xff) ++ return offset + 1 ++} + +- if (this.sign && !num.sign) { +- var res = this.neg().divmod(num, mode); +- var div; +- var mod; +- if (mode !== 'mod') +- div = res.div.neg(); +- if (mode !== 'div') +- mod = res.mod.cmpn(0) === 0 ? res.mod : num.sub(res.mod); +- return { +- div: div, +- mod: mod +- }; +- } else if (!this.sign && num.sign) { +- var res = this.divmod(num.neg(), mode); +- var div; +- if (mode !== 'mod') +- div = res.div.neg(); +- return { div: div, mod: res.mod }; +- } else if (this.sign && num.sign) { +- return this.neg().divmod(num.neg(), mode); ++function objectWriteUInt16 (buf, value, offset, littleEndian) { ++ if (value < 0) value = 0xffff + value + 1 ++ for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) { ++ buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> ++ (littleEndian ? i : 1 - i) * 8 + } ++} + +- // Both numbers are positive at this point ++Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { ++ value = +value ++ offset = offset | 0 ++ if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) ++ if (Buffer.TYPED_ARRAY_SUPPORT) { ++ this[offset] = (value & 0xff) ++ this[offset + 1] = (value >>> 8) ++ } else { ++ objectWriteUInt16(this, value, offset, true) ++ } ++ return offset + 2 ++} + +- // Strip both numbers to approximate shift value +- if (num.length > this.length || this.cmp(num) < 0) +- return { div: new BN(0), mod: this }; ++Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { ++ value = +value ++ offset = offset | 0 ++ if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) ++ if (Buffer.TYPED_ARRAY_SUPPORT) { ++ this[offset] = (value >>> 8) ++ this[offset + 1] = (value & 0xff) ++ } else { ++ objectWriteUInt16(this, value, offset, false) ++ } ++ return offset + 2 ++} + +- // Very short reduction +- if (num.length === 1) { +- if (mode === 'div') +- return { div: this.divn(num.words[0]), mod: null }; +- else if (mode === 'mod') +- return { div: null, mod: new BN(this.modn(num.words[0])) }; +- return { +- div: this.divn(num.words[0]), +- mod: new BN(this.modn(num.words[0])) +- }; ++function objectWriteUInt32 (buf, value, offset, littleEndian) { ++ if (value < 0) value = 0xffffffff + value + 1 ++ for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) { ++ buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff + } ++} + +- return this._wordDiv(num, mode); +-}; ++Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { ++ value = +value ++ offset = offset | 0 ++ if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) ++ if (Buffer.TYPED_ARRAY_SUPPORT) { ++ this[offset + 3] = (value >>> 24) ++ this[offset + 2] = (value >>> 16) ++ this[offset + 1] = (value >>> 8) ++ this[offset] = (value & 0xff) ++ } else { ++ objectWriteUInt32(this, value, offset, true) ++ } ++ return offset + 4 ++} + +-// Find `this` / `num` +-BN.prototype.div = function div(num) { +- return this.divmod(num, 'div').div; +-}; ++Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { ++ value = +value ++ offset = offset | 0 ++ if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) ++ if (Buffer.TYPED_ARRAY_SUPPORT) { ++ this[offset] = (value >>> 24) ++ this[offset + 1] = (value >>> 16) ++ this[offset + 2] = (value >>> 8) ++ this[offset + 3] = (value & 0xff) ++ } else { ++ objectWriteUInt32(this, value, offset, false) ++ } ++ return offset + 4 ++} + +-// Find `this` % `num` +-BN.prototype.mod = function mod(num) { +- return this.divmod(num, 'mod').mod; +-}; ++Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { ++ value = +value ++ offset = offset | 0 ++ if (!noAssert) { ++ var limit = Math.pow(2, 8 * byteLength - 1) + +-// Find Round(`this` / `num`) +-BN.prototype.divRound = function divRound(num) { +- var dm = this.divmod(num); ++ checkInt(this, value, offset, byteLength, limit - 1, -limit) ++ } + +- // Fast case - exact division +- if (dm.mod.cmpn(0) === 0) +- return dm.div; ++ var i = 0 ++ var mul = 1 ++ var sub = 0 ++ this[offset] = value & 0xFF ++ while (++i < byteLength && (mul *= 0x100)) { ++ if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { ++ sub = 1 ++ } ++ this[offset + i] = ((value / mul) >> 0) - sub & 0xFF ++ } + +- var mod = dm.div.sign ? dm.mod.isub(num) : dm.mod; ++ return offset + byteLength ++} + +- var half = num.shrn(1); +- var r2 = num.andln(1); +- var cmp = mod.cmp(half); ++Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { ++ value = +value ++ offset = offset | 0 ++ if (!noAssert) { ++ var limit = Math.pow(2, 8 * byteLength - 1) + +- // Round down +- if (cmp < 0 || r2 === 1 && cmp === 0) +- return dm.div; ++ checkInt(this, value, offset, byteLength, limit - 1, -limit) ++ } + +- // Round up +- return dm.div.sign ? dm.div.isubn(1) : dm.div.iaddn(1); +-}; ++ var i = byteLength - 1 ++ var mul = 1 ++ var sub = 0 ++ this[offset + i] = value & 0xFF ++ while (--i >= 0 && (mul *= 0x100)) { ++ if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { ++ sub = 1 ++ } ++ this[offset + i] = ((value / mul) >> 0) - sub & 0xFF ++ } + +-BN.prototype.modn = function modn(num) { +- assert(num <= 0x3ffffff); +- var p = (1 << 26) % num; ++ return offset + byteLength ++} + +- var acc = 0; +- for (var i = this.length - 1; i >= 0; i--) +- acc = (p * acc + this.words[i]) % num; ++Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { ++ value = +value ++ offset = offset | 0 ++ if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) ++ if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) ++ if (value < 0) value = 0xff + value + 1 ++ this[offset] = (value & 0xff) ++ return offset + 1 ++} + +- return acc; +-}; ++Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { ++ value = +value ++ offset = offset | 0 ++ if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) ++ if (Buffer.TYPED_ARRAY_SUPPORT) { ++ this[offset] = (value & 0xff) ++ this[offset + 1] = (value >>> 8) ++ } else { ++ objectWriteUInt16(this, value, offset, true) ++ } ++ return offset + 2 ++} + +-// In-place division by number +-BN.prototype.idivn = function idivn(num) { +- assert(num <= 0x3ffffff); ++Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { ++ value = +value ++ offset = offset | 0 ++ if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) ++ if (Buffer.TYPED_ARRAY_SUPPORT) { ++ this[offset] = (value >>> 8) ++ this[offset + 1] = (value & 0xff) ++ } else { ++ objectWriteUInt16(this, value, offset, false) ++ } ++ return offset + 2 ++} + +- var carry = 0; +- for (var i = this.length - 1; i >= 0; i--) { +- var w = this.words[i] + carry * 0x4000000; +- this.words[i] = (w / num) | 0; +- carry = w % num; ++Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { ++ value = +value ++ offset = offset | 0 ++ if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) ++ if (Buffer.TYPED_ARRAY_SUPPORT) { ++ this[offset] = (value & 0xff) ++ this[offset + 1] = (value >>> 8) ++ this[offset + 2] = (value >>> 16) ++ this[offset + 3] = (value >>> 24) ++ } else { ++ objectWriteUInt32(this, value, offset, true) + } ++ return offset + 4 ++} + +- return this.strip(); +-}; ++Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { ++ value = +value ++ offset = offset | 0 ++ if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) ++ if (value < 0) value = 0xffffffff + value + 1 ++ if (Buffer.TYPED_ARRAY_SUPPORT) { ++ this[offset] = (value >>> 24) ++ this[offset + 1] = (value >>> 16) ++ this[offset + 2] = (value >>> 8) ++ this[offset + 3] = (value & 0xff) ++ } else { ++ objectWriteUInt32(this, value, offset, false) ++ } ++ return offset + 4 ++} + +-BN.prototype.divn = function divn(num) { +- return this.clone().idivn(num); +-}; ++function checkIEEE754 (buf, value, offset, ext, max, min) { ++ if (offset + ext > buf.length) throw new RangeError('Index out of range') ++ if (offset < 0) throw new RangeError('Index out of range') ++} + +-BN.prototype.egcd = function egcd(p) { +- assert(!p.sign); +- assert(p.cmpn(0) !== 0); ++function writeFloat (buf, value, offset, littleEndian, noAssert) { ++ if (!noAssert) { ++ checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) ++ } ++ ieee754.write(buf, value, offset, littleEndian, 23, 4) ++ return offset + 4 ++} + +- var x = this; +- var y = p.clone(); ++Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { ++ return writeFloat(this, value, offset, true, noAssert) ++} + +- if (x.sign) +- x = x.mod(p); +- else +- x = x.clone(); ++Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { ++ return writeFloat(this, value, offset, false, noAssert) ++} + +- // A * x + B * y = x +- var A = new BN(1); +- var B = new BN(0); ++function writeDouble (buf, value, offset, littleEndian, noAssert) { ++ if (!noAssert) { ++ checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) ++ } ++ ieee754.write(buf, value, offset, littleEndian, 52, 8) ++ return offset + 8 ++} + +- // C * x + D * y = y +- var C = new BN(0); +- var D = new BN(1); ++Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { ++ return writeDouble(this, value, offset, true, noAssert) ++} + +- var g = 0; ++Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { ++ return writeDouble(this, value, offset, false, noAssert) ++} + +- while (x.isEven() && y.isEven()) { +- x.ishrn(1); +- y.ishrn(1); +- ++g; ++// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) ++Buffer.prototype.copy = function copy (target, targetStart, start, end) { ++ if (!start) start = 0 ++ if (!end && end !== 0) end = this.length ++ if (targetStart >= target.length) targetStart = target.length ++ if (!targetStart) targetStart = 0 ++ if (end > 0 && end < start) end = start ++ ++ // Copy 0 bytes; we're done ++ if (end === start) return 0 ++ if (target.length === 0 || this.length === 0) return 0 ++ ++ // Fatal error conditions ++ if (targetStart < 0) { ++ throw new RangeError('targetStart out of bounds') + } ++ if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds') ++ if (end < 0) throw new RangeError('sourceEnd out of bounds') + +- var yp = y.clone(); +- var xp = x.clone(); ++ // Are we oob? ++ if (end > this.length) end = this.length ++ if (target.length - targetStart < end - start) { ++ end = target.length - targetStart + start ++ } + +- while (x.cmpn(0) !== 0) { +- while (x.isEven()) { +- x.ishrn(1); +- if (A.isEven() && B.isEven()) { +- A.ishrn(1); +- B.ishrn(1); +- } else { +- A.iadd(yp).ishrn(1); +- B.isub(xp).ishrn(1); +- } +- } ++ var len = end - start ++ var i + +- while (y.isEven()) { +- y.ishrn(1); +- if (C.isEven() && D.isEven()) { +- C.ishrn(1); +- D.ishrn(1); +- } else { +- C.iadd(yp).ishrn(1); +- D.isub(xp).ishrn(1); +- } ++ if (this === target && start < targetStart && targetStart < end) { ++ // descending copy from end ++ for (i = len - 1; i >= 0; --i) { ++ target[i + targetStart] = this[i + start] + } +- +- if (x.cmp(y) >= 0) { +- x.isub(y); +- A.isub(C); +- B.isub(D); +- } else { +- y.isub(x); +- C.isub(A); +- D.isub(B); ++ } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { ++ // ascending copy from start ++ for (i = 0; i < len; ++i) { ++ target[i + targetStart] = this[i + start] + } ++ } else { ++ Uint8Array.prototype.set.call( ++ target, ++ this.subarray(start, start + len), ++ targetStart ++ ) + } + +- return { +- a: C, +- b: D, +- gcd: y.ishln(g) +- }; +-}; ++ return len ++} + +-// This is reduced incarnation of the binary EEA +-// above, designated to invert members of the +-// _prime_ fields F(p) at a maximal speed +-BN.prototype._invmp = function _invmp(p) { +- assert(!p.sign); +- assert(p.cmpn(0) !== 0); ++// Usage: ++// buffer.fill(number[, offset[, end]]) ++// buffer.fill(buffer[, offset[, end]]) ++// buffer.fill(string[, offset[, end]][, encoding]) ++Buffer.prototype.fill = function fill (val, start, end, encoding) { ++ // Handle string cases: ++ if (typeof val === 'string') { ++ if (typeof start === 'string') { ++ encoding = start ++ start = 0 ++ end = this.length ++ } else if (typeof end === 'string') { ++ encoding = end ++ end = this.length ++ } ++ if (val.length === 1) { ++ var code = val.charCodeAt(0) ++ if (code < 256) { ++ val = code ++ } ++ } ++ if (encoding !== undefined && typeof encoding !== 'string') { ++ throw new TypeError('encoding must be a string') ++ } ++ if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { ++ throw new TypeError('Unknown encoding: ' + encoding) ++ } ++ } else if (typeof val === 'number') { ++ val = val & 255 ++ } + +- var a = this; +- var b = p.clone(); ++ // Invalid ranges are not set to a default, so can range check early. ++ if (start < 0 || this.length < start || this.length < end) { ++ throw new RangeError('Out of range index') ++ } + +- if (a.sign) +- a = a.mod(p); +- else +- a = a.clone(); ++ if (end <= start) { ++ return this ++ } + +- var x1 = new BN(1); +- var x2 = new BN(0); ++ start = start >>> 0 ++ end = end === undefined ? this.length : end >>> 0 + +- var delta = b.clone(); ++ if (!val) val = 0 + +- while (a.cmpn(1) > 0 && b.cmpn(1) > 0) { +- while (a.isEven()) { +- a.ishrn(1); +- if (x1.isEven()) +- x1.ishrn(1); +- else +- x1.iadd(delta).ishrn(1); ++ var i ++ if (typeof val === 'number') { ++ for (i = start; i < end; ++i) { ++ this[i] = val + } +- while (b.isEven()) { +- b.ishrn(1); +- if (x2.isEven()) +- x2.ishrn(1); +- else +- x2.iadd(delta).ishrn(1); +- } +- if (a.cmp(b) >= 0) { +- a.isub(b); +- x1.isub(x2); +- } else { +- b.isub(a); +- x2.isub(x1); ++ } else { ++ var bytes = Buffer.isBuffer(val) ++ ? val ++ : utf8ToBytes(new Buffer(val, encoding).toString()) ++ var len = bytes.length ++ for (i = 0; i < end - start; ++i) { ++ this[i + start] = bytes[i % len] + } + } +- if (a.cmpn(1) === 0) +- return x1; +- else +- return x2; +-}; + +-BN.prototype.gcd = function gcd(num) { +- if (this.cmpn(0) === 0) +- return num.clone(); +- if (num.cmpn(0) === 0) +- return this.clone(); ++ return this ++} + +- var a = this.clone(); +- var b = num.clone(); +- a.sign = false; +- b.sign = false; ++// HELPER FUNCTIONS ++// ================ + +- // Remove common factor of two +- for (var shift = 0; a.isEven() && b.isEven(); shift++) { +- a.ishrn(1); +- b.ishrn(1); ++var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g ++ ++function base64clean (str) { ++ // Node strips out invalid characters like \n and \t from the string, base64-js does not ++ str = stringtrim(str).replace(INVALID_BASE64_RE, '') ++ // Node converts strings with length < 2 to '' ++ if (str.length < 2) return '' ++ // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not ++ while (str.length % 4 !== 0) { ++ str = str + '=' + } ++ return str ++} + +- do { +- while (a.isEven()) +- a.ishrn(1); +- while (b.isEven()) +- b.ishrn(1); ++function stringtrim (str) { ++ if (str.trim) return str.trim() ++ return str.replace(/^\s+|\s+$/g, '') ++} + +- var r = a.cmp(b); +- if (r < 0) { +- // Swap `a` and `b` to make `a` always bigger than `b` +- var t = a; +- a = b; +- b = t; +- } else if (r === 0 || b.cmpn(1) === 0) { +- break; +- } ++function toHex (n) { ++ if (n < 16) return '0' + n.toString(16) ++ return n.toString(16) ++} + +- a.isub(b); +- } while (true); ++function utf8ToBytes (string, units) { ++ units = units || Infinity ++ var codePoint ++ var length = string.length ++ var leadSurrogate = null ++ var bytes = [] + +- return b.ishln(shift); +-}; ++ for (var i = 0; i < length; ++i) { ++ codePoint = string.charCodeAt(i) + +-// Invert number in the field F(num) +-BN.prototype.invm = function invm(num) { +- return this.egcd(num).a.mod(num); +-}; ++ // is surrogate component ++ if (codePoint > 0xD7FF && codePoint < 0xE000) { ++ // last char was a lead ++ if (!leadSurrogate) { ++ // no lead yet ++ if (codePoint > 0xDBFF) { ++ // unexpected trail ++ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) ++ continue ++ } else if (i + 1 === length) { ++ // unpaired lead ++ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) ++ continue ++ } + +-BN.prototype.isEven = function isEven() { +- return (this.words[0] & 1) === 0; +-}; ++ // valid lead ++ leadSurrogate = codePoint + +-BN.prototype.isOdd = function isOdd() { +- return (this.words[0] & 1) === 1; +-}; ++ continue ++ } + +-// And first word and num +-BN.prototype.andln = function andln(num) { +- return this.words[0] & num; +-}; ++ // 2 leads in a row ++ if (codePoint < 0xDC00) { ++ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) ++ leadSurrogate = codePoint ++ continue ++ } + +-// Increment at the bit position in-line +-BN.prototype.bincn = function bincn(bit) { +- assert(typeof bit === 'number'); +- var r = bit % 26; +- var s = (bit - r) / 26; +- var q = 1 << r; ++ // valid surrogate pair ++ codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 ++ } else if (leadSurrogate) { ++ // valid bmp char, but last char was a lead ++ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) ++ } + +- // Fast case: bit is much higher than all existing words +- if (this.length <= s) { +- for (var i = this.length; i < s + 1; i++) +- this.words[i] = 0; +- this.words[s] |= q; +- this.length = s + 1; +- return this; +- } ++ leadSurrogate = null + +- // Add bit and propagate, if needed +- var carry = q; +- for (var i = s; carry !== 0 && i < this.length; i++) { +- var w = this.words[i]; +- w += carry; +- carry = w >>> 26; +- w &= 0x3ffffff; +- this.words[i] = w; +- } +- if (carry !== 0) { +- this.words[i] = carry; +- this.length++; ++ // encode utf8 ++ if (codePoint < 0x80) { ++ if ((units -= 1) < 0) break ++ bytes.push(codePoint) ++ } else if (codePoint < 0x800) { ++ if ((units -= 2) < 0) break ++ bytes.push( ++ codePoint >> 0x6 | 0xC0, ++ codePoint & 0x3F | 0x80 ++ ) ++ } else if (codePoint < 0x10000) { ++ if ((units -= 3) < 0) break ++ bytes.push( ++ codePoint >> 0xC | 0xE0, ++ codePoint >> 0x6 & 0x3F | 0x80, ++ codePoint & 0x3F | 0x80 ++ ) ++ } else if (codePoint < 0x110000) { ++ if ((units -= 4) < 0) break ++ bytes.push( ++ codePoint >> 0x12 | 0xF0, ++ codePoint >> 0xC & 0x3F | 0x80, ++ codePoint >> 0x6 & 0x3F | 0x80, ++ codePoint & 0x3F | 0x80 ++ ) ++ } else { ++ throw new Error('Invalid code point') ++ } + } +- return this; +-}; + +-BN.prototype.cmpn = function cmpn(num) { +- var sign = num < 0; +- if (sign) +- num = -num; ++ return bytes ++} + +- if (this.sign && !sign) +- return -1; +- else if (!this.sign && sign) +- return 1; ++function asciiToBytes (str) { ++ var byteArray = [] ++ for (var i = 0; i < str.length; ++i) { ++ // Node's code seems to be doing this and not & 0x7F.. ++ byteArray.push(str.charCodeAt(i) & 0xFF) ++ } ++ return byteArray ++} + +- num &= 0x3ffffff; +- this.strip(); ++function utf16leToBytes (str, units) { ++ var c, hi, lo ++ var byteArray = [] ++ for (var i = 0; i < str.length; ++i) { ++ if ((units -= 2) < 0) break + +- var res; +- if (this.length > 1) { +- res = 1; +- } else { +- var w = this.words[0]; +- res = w === num ? 0 : w < num ? -1 : 1; ++ c = str.charCodeAt(i) ++ hi = c >> 8 ++ lo = c % 256 ++ byteArray.push(lo) ++ byteArray.push(hi) + } +- if (this.sign) +- res = -res; +- return res; +-}; + +-// Compare two numbers and return: +-// 1 - if `this` > `num` +-// 0 - if `this` == `num` +-// -1 - if `this` < `num` +-BN.prototype.cmp = function cmp(num) { +- if (this.sign && !num.sign) +- return -1; +- else if (!this.sign && num.sign) +- return 1; ++ return byteArray ++} + +- var res = this.ucmp(num); +- if (this.sign) +- return -res; +- else +- return res; +-}; ++function base64ToBytes (str) { ++ return base64.toByteArray(base64clean(str)) ++} + +-// Unsigned comparison +-BN.prototype.ucmp = function ucmp(num) { +- // At this point both numbers have the same sign +- if (this.length > num.length) +- return 1; +- else if (this.length < num.length) +- return -1; ++function blitBuffer (src, dst, offset, length) { ++ for (var i = 0; i < length; ++i) { ++ if ((i + offset >= dst.length) || (i >= src.length)) break ++ dst[i + offset] = src[i] ++ } ++ return i ++} + +- var res = 0; +- for (var i = this.length - 1; i >= 0; i--) { +- var a = this.words[i]; +- var b = num.words[i]; ++function isnan (val) { ++ return val !== val // eslint-disable-line no-self-compare ++} + +- if (a === b) +- continue; +- if (a < b) +- res = -1; +- else if (a > b) +- res = 1; +- break; +- } +- return res; +-}; ++}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) ++},{"base64-js":38,"ieee754":113,"isarray":39}],38:[function(require,module,exports){ ++'use strict' + +-// +-// A reduce context, could be using montgomery or something better, depending +-// on the `m` itself. +-// +-BN.red = function red(num) { +- return new Red(num); +-}; ++exports.toByteArray = toByteArray ++exports.fromByteArray = fromByteArray + +-BN.prototype.toRed = function toRed(ctx) { +- assert(!this.red, 'Already a number in reduction context'); +- assert(!this.sign, 'red works only with positives'); +- return ctx.convertTo(this)._forceRed(ctx); +-}; ++var lookup = [] ++var revLookup = [] ++var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array + +-BN.prototype.fromRed = function fromRed() { +- assert(this.red, 'fromRed works only with numbers in reduction context'); +- return this.red.convertFrom(this); +-}; ++function init () { ++ var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' ++ for (var i = 0, len = code.length; i < len; ++i) { ++ lookup[i] = code[i] ++ revLookup[code.charCodeAt(i)] = i ++ } + +-BN.prototype._forceRed = function _forceRed(ctx) { +- this.red = ctx; +- return this; +-}; ++ revLookup['-'.charCodeAt(0)] = 62 ++ revLookup['_'.charCodeAt(0)] = 63 ++} + +-BN.prototype.forceRed = function forceRed(ctx) { +- assert(!this.red, 'Already a number in reduction context'); +- return this._forceRed(ctx); +-}; ++init() + +-BN.prototype.redAdd = function redAdd(num) { +- assert(this.red, 'redAdd works only with red numbers'); +- return this.red.add(this, num); +-}; ++function toByteArray (b64) { ++ var i, j, l, tmp, placeHolders, arr ++ var len = b64.length + +-BN.prototype.redIAdd = function redIAdd(num) { +- assert(this.red, 'redIAdd works only with red numbers'); +- return this.red.iadd(this, num); +-}; ++ if (len % 4 > 0) { ++ throw new Error('Invalid string. Length must be a multiple of 4') ++ } + +-BN.prototype.redSub = function redSub(num) { +- assert(this.red, 'redSub works only with red numbers'); +- return this.red.sub(this, num); +-}; ++ // the number of equal signs (place holders) ++ // if there are two placeholders, than the two characters before it ++ // represent one byte ++ // if there is only one, then the three characters before it represent 2 bytes ++ // this is just a cheap hack to not do indexOf twice ++ placeHolders = b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0 + +-BN.prototype.redISub = function redISub(num) { +- assert(this.red, 'redISub works only with red numbers'); +- return this.red.isub(this, num); +-}; ++ // base64 is 4/3 + up to two characters of the original data ++ arr = new Arr(len * 3 / 4 - placeHolders) + +-BN.prototype.redShl = function redShl(num) { +- assert(this.red, 'redShl works only with red numbers'); +- return this.red.shl(this, num); +-}; ++ // if there are placeholders, only get up to the last complete 4 chars ++ l = placeHolders > 0 ? len - 4 : len + +-BN.prototype.redMul = function redMul(num) { +- assert(this.red, 'redMul works only with red numbers'); +- this.red._verify2(this, num); +- return this.red.mul(this, num); +-}; ++ var L = 0 + +-BN.prototype.redIMul = function redIMul(num) { +- assert(this.red, 'redMul works only with red numbers'); +- this.red._verify2(this, num); +- return this.red.imul(this, num); +-}; ++ for (i = 0, j = 0; i < l; i += 4, j += 3) { ++ tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)] ++ arr[L++] = (tmp >> 16) & 0xFF ++ arr[L++] = (tmp >> 8) & 0xFF ++ arr[L++] = tmp & 0xFF ++ } + +-BN.prototype.redSqr = function redSqr() { +- assert(this.red, 'redSqr works only with red numbers'); +- this.red._verify1(this); +- return this.red.sqr(this); +-}; ++ if (placeHolders === 2) { ++ tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4) ++ arr[L++] = tmp & 0xFF ++ } else if (placeHolders === 1) { ++ tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2) ++ arr[L++] = (tmp >> 8) & 0xFF ++ arr[L++] = tmp & 0xFF ++ } + +-BN.prototype.redISqr = function redISqr() { +- assert(this.red, 'redISqr works only with red numbers'); +- this.red._verify1(this); +- return this.red.isqr(this); +-}; ++ return arr ++} + +-// Square root over p +-BN.prototype.redSqrt = function redSqrt() { +- assert(this.red, 'redSqrt works only with red numbers'); +- this.red._verify1(this); +- return this.red.sqrt(this); +-}; ++function tripletToBase64 (num) { ++ return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F] ++} + +-BN.prototype.redInvm = function redInvm() { +- assert(this.red, 'redInvm works only with red numbers'); +- this.red._verify1(this); +- return this.red.invm(this); +-}; ++function encodeChunk (uint8, start, end) { ++ var tmp ++ var output = [] ++ for (var i = start; i < end; i += 3) { ++ tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]) ++ output.push(tripletToBase64(tmp)) ++ } ++ return output.join('') ++} + +-// Return negative clone of `this` % `red modulo` +-BN.prototype.redNeg = function redNeg() { +- assert(this.red, 'redNeg works only with red numbers'); +- this.red._verify1(this); +- return this.red.neg(this); +-}; ++function fromByteArray (uint8) { ++ var tmp ++ var len = uint8.length ++ var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes ++ var output = '' ++ var parts = [] ++ var maxChunkLength = 16383 // must be multiple of 3 + +-BN.prototype.redPow = function redPow(num) { +- assert(this.red && !num.red, 'redPow(normalNum)'); +- this.red._verify1(this); +- return this.red.pow(this, num); +-}; ++ // go through the array every three bytes, we'll deal with trailing stuff later ++ for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { ++ parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))) ++ } + +-// Prime numbers with efficient reduction +-var primes = { +- k256: null, +- p224: null, +- p192: null, +- p25519: null +-}; ++ // pad the end with zeros, but make sure to not forget the extra bytes ++ if (extraBytes === 1) { ++ tmp = uint8[len - 1] ++ output += lookup[tmp >> 2] ++ output += lookup[(tmp << 4) & 0x3F] ++ output += '==' ++ } else if (extraBytes === 2) { ++ tmp = (uint8[len - 2] << 8) + (uint8[len - 1]) ++ output += lookup[tmp >> 10] ++ output += lookup[(tmp >> 4) & 0x3F] ++ output += lookup[(tmp << 2) & 0x3F] ++ output += '=' ++ } + +-// Pseudo-Mersenne prime +-function MPrime(name, p) { +- // P = 2 ^ N - K +- this.name = name; +- this.p = new BN(p, 16); +- this.n = this.p.bitLength(); +- this.k = new BN(1).ishln(this.n).isub(this.p); ++ parts.push(output) + +- this.tmp = this._tmp(); ++ return parts.join('') + } + +-MPrime.prototype._tmp = function _tmp() { +- var tmp = new BN(null); +- tmp.words = new Array(Math.ceil(this.n / 13)); +- return tmp; ++},{}],39:[function(require,module,exports){ ++var toString = {}.toString; ++ ++module.exports = Array.isArray || function (arr) { ++ return toString.call(arr) == '[object Array]'; + }; + +-MPrime.prototype.ireduce = function ireduce(num) { +- // Assumes that `num` is less than `P^2` +- // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P) +- var r = num; +- var rlen; ++},{}],40:[function(require,module,exports){ ++'use strict' + +- do { +- this.split(r, this.tmp); +- r = this.imulK(r); +- r = r.iadd(this.tmp); +- rlen = r.bitLength(); +- } while (rlen > this.n); ++var monotoneTriangulate = require('./lib/monotone') ++var makeIndex = require('./lib/triangulation') ++var delaunayFlip = require('./lib/delaunay') ++var filterTriangulation = require('./lib/filter') + +- var cmp = rlen < this.n ? -1 : r.ucmp(this.p); +- if (cmp === 0) { +- r.words[0] = 0; +- r.length = 1; +- } else if (cmp > 0) { +- r.isub(this.p); +- } else { +- r.strip(); +- } ++module.exports = cdt2d + +- return r; +-}; ++function canonicalizeEdge(e) { ++ return [Math.min(e[0], e[1]), Math.max(e[0], e[1])] ++} + +-MPrime.prototype.split = function split(input, out) { +- input.ishrn(this.n, 0, out); +-}; ++function compareEdge(a, b) { ++ return a[0]-b[0] || a[1]-b[1] ++} + +-MPrime.prototype.imulK = function imulK(num) { +- return num.imul(this.k); +-}; ++function canonicalizeEdges(edges) { ++ return edges.map(canonicalizeEdge).sort(compareEdge) ++} + +-function K256() { +- MPrime.call( +- this, +- 'k256', +- 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f'); ++function getDefault(options, property, dflt) { ++ if(property in options) { ++ return options[property] ++ } ++ return dflt + } +-inherits(K256, MPrime); + +-K256.prototype.split = function split(input, output) { +- // 256 = 9 * 26 + 22 +- var mask = 0x3fffff; ++function cdt2d(points, edges, options) { + +- var outLen = Math.min(input.length, 9); +- for (var i = 0; i < outLen; i++) +- output.words[i] = input.words[i]; +- output.length = outLen; +- +- if (input.length <= 9) { +- input.words[0] = 0; +- input.length = 1; +- return; ++ if(!Array.isArray(edges)) { ++ options = edges || {} ++ edges = [] ++ } else { ++ options = options || {} ++ edges = edges || [] + } + +- // Shift by 9 limbs +- var prev = input.words[9]; +- output.words[output.length++] = prev & mask; ++ //Parse out options ++ var delaunay = !!getDefault(options, 'delaunay', true) ++ var interior = !!getDefault(options, 'interior', true) ++ var exterior = !!getDefault(options, 'exterior', true) ++ var infinity = !!getDefault(options, 'infinity', false) + +- for (var i = 10; i < input.length; i++) { +- var next = input.words[i]; +- input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22); +- prev = next; ++ //Handle trivial case ++ if((!interior && !exterior) || points.length === 0) { ++ return [] + } +- input.words[i - 10] = prev >>> 22; +- input.length -= 9; +-}; + +-K256.prototype.imulK = function imulK(num) { +- // K = 0x1000003d1 = [ 0x40, 0x3d1 ] +- num.words[num.length] = 0; +- num.words[num.length + 1] = 0; +- num.length += 2; ++ //Construct initial triangulation ++ var cells = monotoneTriangulate(points, edges) + +- // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390 +- var hi; +- var lo = 0; +- for (var i = 0; i < num.length; i++) { +- var w = num.words[i]; +- hi = w * 0x40; +- lo += w * 0x3d1; +- hi += (lo / 0x4000000) | 0; +- lo &= 0x3ffffff; ++ //If delaunay refinement needed, then improve quality by edge flipping ++ if(delaunay || interior !== exterior || infinity) { + +- num.words[i] = lo; ++ //Index all of the cells to support fast neighborhood queries ++ var triangulation = makeIndex(points.length, canonicalizeEdges(edges)) ++ for(var i=0; i>>= 26; ++module.exports = delaunayRefine + +- num.words[i] = lo; +- carry = hi; +- } +- if (carry !== 0) +- num.words[num.length++] = carry; +- return num; +-}; ++function testFlip(points, triangulation, stack, a, b, x) { ++ var y = triangulation.opposite(a, b) + +-// Exported mostly for testing purposes, use plain name instead +-BN._prime = function prime(name) { +- // Cached version of prime +- if (primes[name]) +- return primes[name]; ++ //Test boundary edge ++ if(y < 0) { ++ return ++ } + +- var prime; +- if (name === 'k256') +- prime = new K256(); +- else if (name === 'p224') +- prime = new P224(); +- else if (name === 'p192') +- prime = new P192(); +- else if (name === 'p25519') +- prime = new P25519(); +- else +- throw new Error('Unknown prime ' + name); +- primes[name] = prime; ++ //Swap edge if order flipped ++ if(b < a) { ++ var tmp = a ++ a = b ++ b = tmp ++ tmp = x ++ x = y ++ y = tmp ++ } + +- return prime; +-}; ++ //Test if edge is constrained ++ if(triangulation.isConstraint(a, b)) { ++ return ++ } + +-// +-// Base reduction engine +-// +-function Red(m) { +- if (typeof m === 'string') { +- var prime = BN._prime(m); +- this.m = prime.p; +- this.prime = prime; +- } else { +- this.m = m; +- this.prime = null; ++ //Test if edge is delaunay ++ if(inCircle(points[a], points[b], points[x], points[y]) < 0) { ++ stack.push(a, b) + } + } + +-Red.prototype._verify1 = function _verify1(a) { +- assert(!a.sign, 'red works only with positives'); +- assert(a.red, 'red works only with red numbers'); +-}; ++//Assume edges are sorted lexicographically ++function delaunayRefine(points, triangulation) { ++ var stack = [] + +-Red.prototype._verify2 = function _verify2(a, b) { +- assert(!a.sign && !b.sign, 'red works only with positives'); +- assert(a.red && a.red === b.red, +- 'red works only with red numbers'); +-}; ++ var numPoints = points.length ++ var stars = triangulation.stars ++ for(var a=0; a= 0) +- res.isub(this.m); +- return res._forceRed(this); +-}; ++ //If this is a boundary edge, don't flip it ++ if(y < 0) { ++ continue ++ } + +-Red.prototype.iadd = function iadd(a, b) { +- this._verify2(a, b); ++ //If edge is in circle, flip it ++ if(inCircle(points[a], points[b], points[x], points[y]) < 0) { ++ stack.push(a, b) ++ } ++ } ++ } + +- var res = a.iadd(b); +- if (res.cmp(this.m) >= 0) +- res.isub(this.m); +- return res; +-}; ++ while(stack.length > 0) { ++ var b = stack.pop() ++ var a = stack.pop() + +-Red.prototype.sub = function sub(a, b) { +- this._verify2(a, b); ++ //Find opposite pairs ++ var x = -1, y = -1 ++ var star = stars[a] ++ for(var i=1; i= 0) { ++ continue ++ } + +- var res = a.isub(b); +- if (res.cmpn(0) < 0) +- res.iadd(this.m); +- return res; +-}; ++ //Flip the edge ++ triangulation.flip(a, b) + +-Red.prototype.shl = function shl(a, num) { +- this._verify1(a); +- return this.imod(a.shln(num)); +-}; ++ //Test flipping neighboring edges ++ testFlip(points, triangulation, stack, x, a, y) ++ testFlip(points, triangulation, stack, a, y, x) ++ testFlip(points, triangulation, stack, y, b, x) ++ testFlip(points, triangulation, stack, b, x, y) ++ } ++} + +-Red.prototype.imul = function imul(a, b) { +- this._verify2(a, b); +- return this.imod(a.imul(b)); +-}; ++},{"binary-search-bounds":45,"robust-in-sphere":139}],42:[function(require,module,exports){ ++'use strict' + +-Red.prototype.mul = function mul(a, b) { +- this._verify2(a, b); +- return this.imod(a.mul(b)); +-}; ++var bsearch = require('binary-search-bounds') + +-Red.prototype.isqr = function isqr(a) { +- return this.imul(a, a); +-}; ++module.exports = classifyFaces + +-Red.prototype.sqr = function sqr(a) { +- return this.mul(a, a); +-}; ++function FaceIndex(cells, neighbor, constraint, flags, active, next, boundary) { ++ this.cells = cells ++ this.neighbor = neighbor ++ this.flags = flags ++ this.constraint = constraint ++ this.active = active ++ this.next = next ++ this.boundary = boundary ++} + +-Red.prototype.sqrt = function sqrt(a) { +- if (a.cmpn(0) === 0) +- return a.clone(); ++var proto = FaceIndex.prototype + +- var mod3 = this.m.andln(3); +- assert(mod3 % 2 === 1); ++function compareCell(a, b) { ++ return a[0] - b[0] || ++ a[1] - b[1] || ++ a[2] - b[2] ++} + +- // Fast case +- if (mod3 === 3) { +- var pow = this.m.add(new BN(1)).ishrn(2); +- var r = this.pow(a, pow); +- return r; ++proto.locate = (function() { ++ var key = [0,0,0] ++ return function(a, b, c) { ++ var x = a, y = b, z = c ++ if(b < c) { ++ if(b < a) { ++ x = b ++ y = c ++ z = a ++ } ++ } else if(c < a) { ++ x = c ++ y = a ++ z = b ++ } ++ if(x < 0) { ++ return -1 ++ } ++ key[0] = x ++ key[1] = y ++ key[2] = z ++ return bsearch.eq(this.cells, key, compareCell) + } ++})() + +- // Tonelli-Shanks algorithm (Totally unoptimized and slow) +- // +- // Find Q and S, that Q * 2 ^ S = (P - 1) +- var q = this.m.subn(1); +- var s = 0; +- while (q.cmpn(0) !== 0 && q.andln(1) === 0) { +- s++; +- q.ishrn(1); ++function indexCells(triangulation, infinity) { ++ //First get cells and canonicalize ++ var cells = triangulation.cells() ++ var nc = cells.length ++ for(var i=0; i 0 || next.length > 0) { ++ while(active.length > 0) { ++ var t = active.pop() ++ if(flags[t] === -side) { ++ continue ++ } ++ flags[t] = side ++ var c = cells[t] ++ for(var j=0; j<3; ++j) { ++ var f = neighbor[3*t+j] ++ if(f >= 0 && flags[f] === 0) { ++ if(constraint[3*t+j]) { ++ next.push(f) ++ } else { ++ active.push(f) ++ flags[f] = side ++ } ++ } ++ } ++ } + +-Mont.prototype.convertFrom = function convertFrom(num) { +- var r = this.imod(num.mul(this.rinv)); +- r.red = null; +- return r; +-}; ++ //Swap arrays and loop ++ var tmp = next ++ next = active ++ active = tmp ++ next.length = 0 ++ side = -side ++ } + +-Mont.prototype.imul = function imul(a, b) { +- if (a.cmpn(0) === 0 || b.cmpn(0) === 0) { +- a.words[0] = 0; +- a.length = 1; +- return a; ++ var result = filterCells(cells, flags, target) ++ if(infinity) { ++ return result.concat(index.boundary) + } ++ return result ++} + +- var t = a.imul(b); +- var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); +- var u = t.isub(c).ishrn(this.shift); +- var res = u; +- if (u.cmp(this.m) >= 0) +- res = u.isub(this.m); +- else if (u.cmpn(0) < 0) +- res = u.iadd(this.m); ++},{"binary-search-bounds":45}],43:[function(require,module,exports){ ++'use strict' + +- return res._forceRed(this); +-}; ++var bsearch = require('binary-search-bounds') ++var orient = require('robust-orientation')[3] + +-Mont.prototype.mul = function mul(a, b) { +- if (a.cmpn(0) === 0 || b.cmpn(0) === 0) +- return new BN(0)._forceRed(this); ++var EVENT_POINT = 0 ++var EVENT_END = 1 ++var EVENT_START = 2 + +- var t = a.mul(b); +- var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); +- var u = t.isub(c).ishrn(this.shift); +- var res = u; +- if (u.cmp(this.m) >= 0) +- res = u.isub(this.m); +- else if (u.cmpn(0) < 0) +- res = u.iadd(this.m); ++module.exports = monotoneTriangulate + +- return res._forceRed(this); +-}; ++//A partial convex hull fragment, made of two unimonotone polygons ++function PartialHull(a, b, idx, lowerIds, upperIds) { ++ this.a = a ++ this.b = b ++ this.idx = idx ++ this.lowerIds = lowerIds ++ this.upperIds = upperIds ++} + +-Mont.prototype.invm = function invm(a) { +- // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R +- var res = this.imod(a._invmp(this.m).mul(this.r2)); +- return res._forceRed(this); +-}; ++//An event in the sweep line procedure ++function Event(a, b, type, idx) { ++ this.a = a ++ this.b = b ++ this.type = type ++ this.idx = idx ++} + +-})(typeof module === 'undefined' || module, this); ++//This is used to compare events for the sweep line procedure ++// Points are: ++// 1. sorted lexicographically ++// 2. sorted by type (point < end < start) ++// 3. segments sorted by winding order ++// 4. sorted by index ++function compareEvent(a, b) { ++ var d = ++ (a.a[0] - b.a[0]) || ++ (a.a[1] - b.a[1]) || ++ (a.type - b.type) ++ if(d) { return d } ++ if(a.type !== EVENT_POINT) { ++ d = orient(a.a, a.b, b.b) ++ if(d) { return d } ++ } ++ return a.idx - b.idx ++} + +-},{}],39:[function(require,module,exports){ +-'use strict' ++function testPoint(hull, p) { ++ return orient(hull.a, hull.b, p) ++} + +-var bnsign = require('./lib/bn-sign') ++function addPoint(cells, hulls, points, p, idx) { ++ var lo = bsearch.lt(hulls, p, testPoint) ++ var hi = bsearch.gt(hulls, p, testPoint) ++ for(var i=lo; i 1 && orient( ++ points[lowerIds[m-2]], ++ points[lowerIds[m-1]], ++ p) > 0) { ++ cells.push( ++ [lowerIds[m-1], ++ lowerIds[m-2], ++ idx]) ++ m -= 1 ++ } ++ lowerIds.length = m ++ lowerIds.push(idx) + +-function sign(x) { +- return bnsign(x[0]) * bnsign(x[1]) ++ //Insert p into upper hull ++ var upperIds = hull.upperIds ++ var m = upperIds.length ++ while(m > 1 && orient( ++ points[upperIds[m-2]], ++ points[upperIds[m-1]], ++ p) < 0) { ++ cells.push( ++ [upperIds[m-2], ++ upperIds[m-1], ++ idx]) ++ m -= 1 ++ } ++ upperIds.length = m ++ upperIds.push(idx) ++ } + } + +-},{"./lib/bn-sign":30}],40:[function(require,module,exports){ +-'use strict' ++function findSplit(hull, edge) { ++ var d ++ if(hull.a[0] < edge.a[0]) { ++ d = orient(hull.a, hull.b, edge.a) ++ } else { ++ d = orient(edge.b, edge.a, hull.a) ++ } ++ if(d) { return d } ++ if(edge.b[0] < hull.b[0]) { ++ d = orient(hull.a, hull.b, edge.b) ++ } else { ++ d = orient(edge.b, edge.a, hull.b) ++ } ++ return d || hull.idx - edge.idx ++} + +-var rationalize = require('./lib/rationalize') ++function splitHulls(hulls, points, event) { ++ var splitIdx = bsearch.le(hulls, event, findSplit) ++ var hull = hulls[splitIdx] ++ var upperIds = hull.upperIds ++ var x = upperIds[upperIds.length-1] ++ hull.upperIds = [x] ++ hulls.splice(splitIdx+1, 0, ++ new PartialHull(event.a, event.b, event.idx, [x], upperIds)) ++} + +-module.exports = sub + +-function sub(a, b) { +- return rationalize(a[0].mul(b[1]).sub(a[1].mul(b[0])), a[1].mul(b[1])) ++function mergeHulls(hulls, points, event) { ++ //Swap pointers for merge search ++ var tmp = event.a ++ event.a = event.b ++ event.b = tmp ++ var mergeIdx = bsearch.eq(hulls, event, findSplit) ++ var upper = hulls[mergeIdx] ++ var lower = hulls[mergeIdx-1] ++ lower.upperIds = upper.upperIds ++ hulls.splice(mergeIdx, 1) + } + +-},{"./lib/rationalize":35}],41:[function(require,module,exports){ +-'use strict' + +-var bn2num = require('./lib/bn-to-num') +-var ctz = require('./lib/ctz') ++function monotoneTriangulate(points, edges) { + +-module.exports = roundRat ++ var numPoints = points.length ++ var numEdges = edges.length + +-//Round a rational to the closest float +-function roundRat(f) { +- var a = f[0] +- var b = f[1] +- if(a.cmpn(0) === 0) { +- return 0 +- } +- var h = a.divmod(b) +- var iv = h.div +- var x = bn2num(iv) +- var ir = h.mod +- if(ir.cmpn(0) === 0) { +- return x ++ var events = [] ++ ++ //Create point events ++ for(var i=0; i b[0]) { ++ events.push( ++ new Event(b, a, EVENT_START, i), ++ new Event(a, b, EVENT_END, i)) + } ++ } + +- return x + y * Math.pow(2, -s) +- } else { +- var ybits = b.bitLength() - ir.bitLength() + 53 +- var y = bn2num(ir.shln(ybits).divRound(b)) +- if(ybits < 1023) { +- return y * Math.pow(2, -ybits) ++ //Sort events ++ events.sort(compareEvent) ++ ++ //Initialize hull ++ var minX = events[0].a[0] - (1 + Math.abs(events[0].a[0])) * Math.pow(2, -52) ++ var hull = [ new PartialHull([minX, 1], [minX, 0], -1, [], [], [], []) ] ++ ++ //Process events in order ++ var cells = [] ++ for(var i=0, numEvents=events.length; i>>1 +- if(d <= 0) { +- return ++ return function(i, j) { ++ e[0] = Math.min(i,j) ++ e[1] = Math.max(i,j) ++ return bsearch.eq(this.edges, e, compareLex) >= 0 + } ++})() + +- var retval +- +- //Convert red boxes +- var redList = pool.mallocDouble(2*d*n) +- var redIds = pool.mallocInt32(n) +- n = convertBoxes(red, d, redList, redIds) +- +- if(n > 0) { +- if(d === 1 && full) { +- //Special case: 1d complete +- sweep.init(n) +- retval = sweep.sweepComplete( +- d, visit, +- 0, n, redList, redIds, +- 0, n, redList, redIds) +- } else { +- +- //Convert blue boxes +- var blueList = pool.mallocDouble(2*d*m) +- var blueIds = pool.mallocInt32(m) +- m = convertBoxes(blue, d, blueList, blueIds) +- +- if(m > 0) { +- sweep.init(n+m) ++proto.removeTriangle = function(i, j, k) { ++ var stars = this.stars ++ removePair(stars[i], j, k) ++ removePair(stars[j], k, i) ++ removePair(stars[k], i, j) ++} + +- if(d === 1) { +- //Special case: 1d bipartite +- retval = sweep.sweepBipartite( +- d, visit, +- 0, n, redList, redIds, +- 0, m, blueList, blueIds) +- } else { +- //General case: d>1 +- retval = boxIntersectIter( +- d, visit, full, +- n, redList, redIds, +- m, blueList, blueIds) +- } ++proto.addTriangle = function(i, j, k) { ++ var stars = this.stars ++ stars[i].push(j, k) ++ stars[j].push(k, i) ++ stars[k].push(i, j) ++} + +- pool.free(blueList) +- pool.free(blueIds) +- } ++proto.opposite = function(j, i) { ++ var list = this.stars[i] ++ for(var k=1, n=list.length; k>>1,x=a[m]"] ++ if(earlyOut) { ++ if(predicate.indexOf("c") < 0) { ++ code.push(";if(x===y){return m}else if(x<=y){") ++ } else { ++ code.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){") ++ } + } else { +- code.push(blueLoop, INNER_LABEL, ':', redLoop) ++ code.push(";if(", predicate, "){i=m;") + } +- +- if(full) { +- code.push('if(y1=", false, "GE"), ++ gt: compileBoundsSearch(">", false, "GT"), ++ lt: compileBoundsSearch("<", true, "LT"), ++ le: compileBoundsSearch("<=", true, "LE"), ++ eq: compileBoundsSearch("-", true, "EQ", true) + } + +-function bruteForcePlanner(full) { +- var funcName = 'bruteForce' + (full ? 'Full' : 'Partial') +- var prefix = [] +- var fargs = ARGS.slice() +- if(!full) { +- fargs.splice(3, 0, FLIP) +- } ++},{}],46:[function(require,module,exports){ ++'use strict' + +- var code = ['function ' + funcName + '(' + fargs.join() + '){'] ++module.exports = cleanPSLG + +- function invoke(redMajor, flip) { +- var res = generateBruteForce(redMajor, flip, full) +- prefix.push(res.code) +- code.push('return ' + res.name + '(' + ARGS.join() + ');') +- } ++var UnionFind = require('union-find') ++var boxIntersect = require('box-intersect') ++var compareCell = require('compare-cell') ++var segseg = require('robust-segment-intersect') ++var rat = require('big-rat') ++var ratCmp = require('big-rat/cmp') ++var ratToFloat = require('big-rat/to-float') ++var ratVec = require('rat-vec') ++var nextafter = require('nextafter') + +- code.push('if(' + RED_END + '-' + RED_START + '>' + +- BLUE_END + '-' + BLUE_START + '){') ++var solveIntersection = require('./lib/rat-seg-intersect') + +- if(full) { +- invoke(true, false) +- code.push('}else{') +- invoke(false, false) ++//Bounds on a rational number when rounded to a float ++function boundRat(r) { ++ var f = ratToFloat(r) ++ var cmp = ratCmp(rat(f), r) ++ if(cmp < 0) { ++ return [f, nextafter(f, Infinity)] ++ } else if(cmp > 0) { ++ return [nextafter(f, -Infinity), f] + } else { +- code.push('if(' + FLIP + '){') +- invoke(true, true) +- code.push('}else{') +- invoke(true, false) +- code.push('}}else{if(' + FLIP + '){') +- invoke(false, true) +- code.push('}else{') +- invoke(false, false) +- code.push('}') ++ return [f, f] + } +- code.push('}}return ' + funcName) +- +- var codeStr = prefix.join('') + code.join('') +- var proc = new Function(codeStr) +- return proc() + } + +- +-exports.partial = bruteForcePlanner(false) +-exports.full = bruteForcePlanner(true) +-},{}],44:[function(require,module,exports){ +-'use strict' +- +-module.exports = boxIntersectIter +- +-var pool = require('typedarray-pool') +-var bits = require('bit-twiddle') +-var bruteForce = require('./brute') +-var bruteForcePartial = bruteForce.partial +-var bruteForceFull = bruteForce.full +-var sweep = require('./sweep') +-var findMedian = require('./median') +-var genPartition = require('./partition') +- +-//Twiddle parameters +-var BRUTE_FORCE_CUTOFF = 128 //Cut off for brute force search +-var SCAN_CUTOFF = (1<<22) //Cut off for two way scan +-var SCAN_COMPLETE_CUTOFF = (1<<22) +- +-//Partition functions +-var partitionInteriorContainsInterval = genPartition( +- '!(lo>=p0)&&!(p1>=hi)', +- ['p0', 'p1']) +- +-var partitionStartEqual = genPartition( +- 'lo===p0', +- ['p0']) +- +-var partitionStartLessThan = genPartition( +- 'lo= floatPoints.length) { ++ return ratPoints[idx-floatPoints.length] + } ++ var p = floatPoints[idx] ++ return [ rat(p[0]), rat(p[1]) ] + } +-} ++ junctions.sort(function(a, b) { ++ if(a[0] !== b[0]) { ++ return a[0] - b[0] ++ } ++ var u = getPoint(a[1]) ++ var v = getPoint(b[1]) ++ return ratCmp(u[0], v[0]) || ratCmp(u[1], v[1]) ++ }) + +-//Special case: Intersect one point with list of intervals +-function onePointFull( +- d, axis, visit, +- redStart, redEnd, red, redIndex, +- blueOffset, blue, blueId) { ++ //Split edges along junctions ++ for(var i=junctions.length-1; i>=0; --i) { ++ var junction = junctions[i] ++ var e = junction[0] + +- var elemSize = 2 * d +- var bluePtr = blueOffset * elemSize +- var blueX = blue[bluePtr + axis] ++ var edge = edges[e] ++ var s = edge[0] ++ var t = edge[1] + +-red_loop: +- for(var i=redStart, redPtr=redStart*elemSize; i 0 && junctions[i-1][0] === e) { ++ var junction = junctions[--i] ++ var next = junction[1] ++ if(useColor) { ++ edges.push([last, next, color]) ++ } else { ++ edges.push([last, next]) + } ++ last = next + } +- var retval = visit(redId, blueId) +- if(retval !== void 0) { +- return retval ++ ++ //Add final edge ++ if(useColor) { ++ edges.push([last, t, color]) ++ } else { ++ edges.push([last, t]) + } + } ++ ++ //Return constructed rational points ++ return ratPoints + } + +-//The main box intersection routine +-function boxIntersectIter( +- d, visit, initFull, +- xSize, xBoxes, xIndex, +- ySize, yBoxes, yIndex) { ++//Merge overlapping points ++function dedupPoints(floatPoints, ratPoints, floatBounds) { ++ var numPoints = floatPoints.length + ratPoints.length ++ var uf = new UnionFind(numPoints) + +- //Reserve memory for stack +- iterInit(d, xSize + ySize) ++ //Compute rational bounds ++ var bounds = floatBounds ++ for(var i=0; i 0) { +- top -= 1 ++ //If no duplicates, return null to signal termination ++ if(noDupes) { ++ return null ++ } + +- var iptr = top * IFRAME_SIZE +- var axis = BOX_ISTACK[iptr] +- var redStart = BOX_ISTACK[iptr+1] +- var redEnd = BOX_ISTACK[iptr+2] +- var blueStart = BOX_ISTACK[iptr+3] +- var blueEnd = BOX_ISTACK[iptr+4] +- var state = BOX_ISTACK[iptr+5] ++ //Do a second pass to fix up missing labels ++ for(var i=0; i b[2]) { ++ return 1 ++ } ++ return 0 ++} + +- //Unpack indices +- var red = xBoxes +- var redIndex = xIndex +- var blue = yBoxes +- var blueIndex = yIndex +- if(flip) { +- red = yBoxes +- redIndex = yIndex +- blue = xBoxes +- blueIndex = xIndex ++//Remove duplicate edge labels ++function dedupEdges(edges, labels, useColor) { ++ if(edges.length === 0) { ++ return ++ } ++ if(labels) { ++ for(var i=0; i= redEnd) { +- continue +- } ++ } else { ++ for(var i=0; i= redEnd) { +- continue +- } ++ } ++ if(useColor) { ++ edges.sort(compareLex3) ++ } else { ++ edges.sort(compareLex2) ++ } ++ var ptr = 1 ++ for(var i=1; i mid point +- // +- var blue0 = findMedian( +- d, axis, +- blueStart, blueEnd, blue, blueIndex) +- var mid = blue[elemSize * blue0 + axis] +- var blue1 = partitionStartEqual( +- d, axis, +- blue0, blueEnd, blue, blueIndex, +- mid) ++ // 4. dedupe verts ++ var labels = dedupPoints(points, ratPoints, vertBounds) + +- //Right case +- if(blue1 < blueEnd) { +- iterPush(top++, +- axis, +- red0, redEnd, +- blue1, blueEnd, +- (flip|4) + (full ? 16 : 0), +- mid, hi) +- } ++ // 6. dedupe edges ++ dedupEdges(edges, labels, useColor) + +- //Left case +- if(blueStart < blue0) { +- iterPush(top++, +- axis, +- red0, redEnd, +- blueStart, blue0, +- (flip|2) + (full ? 16 : 0), +- lo, mid) +- } ++ // 5. check termination ++ if(!labels) { ++ return (crossings.length > 0 || tjunctions.length > 0) ++ } + +- //Center case (the hard part) +- if(blue0 + 1 === blue1) { +- //Optimization: Range with exactly 1 point, use a brute force scan +- if(full) { +- retval = onePointFull( +- d, axis, visit, +- red0, redEnd, red, redIndex, +- blue0, blue, blueIndex[blue0]) +- } else { +- retval = onePointPartial( +- d, axis, visit, flip, +- red0, redEnd, red, redIndex, +- blue0, blue, blueIndex[blue0]) +- } +- if(retval !== void 0) { +- return retval +- } +- } else if(blue0 < blue1) { +- var red1 +- if(full) { +- //If full intersection, need to handle special case +- red1 = partitionContainsPoint( +- d, axis, +- red0, redEnd, red, redIndex, +- mid) +- if(red0 < red1) { +- var redX = partitionStartEqual( +- d, axis, +- red0, red1, red, redIndex, +- mid) +- if(axis === d-2) { +- //Degenerate sweep intersection: +- // [red0, redX] with [blue0, blue1] +- if(red0 < redX) { +- retval = sweep.sweepComplete( +- d, visit, +- red0, redX, red, redIndex, +- blue0, blue1, blue, blueIndex) +- if(retval !== void 0) { +- return retval +- } +- } ++ // More iterations necessary ++ return true ++} + +- //Normal sweep intersection: +- // [redX, red1] with [blue0, blue1] +- if(redX < red1) { +- retval = sweep.sweepBipartite( +- d, visit, +- redX, red1, red, redIndex, +- blue0, blue1, blue, blueIndex) +- if(retval !== void 0) { +- return retval +- } +- } +- } else { +- if(red0 < redX) { +- iterPush(top++, +- axis+1, +- red0, redX, +- blue0, blue1, +- 16, +- -Infinity, Infinity) +- } +- if(redX < red1) { +- iterPush(top++, +- axis+1, +- redX, red1, +- blue0, blue1, +- 0, +- -Infinity, Infinity) +- iterPush(top++, +- axis+1, +- blue0, blue1, +- redX, red1, +- 1, +- -Infinity, Infinity) +- } +- } +- } +- } else { +- if(flip) { +- red1 = partitionContainsPointProper( +- d, axis, +- red0, redEnd, red, redIndex, +- mid) +- } else { +- red1 = partitionContainsPoint( +- d, axis, +- red0, redEnd, red, redIndex, +- mid) +- } +- if(red0 < red1) { +- if(axis === d-2) { +- if(flip) { +- retval = sweep.sweepBipartite( +- d, visit, +- blue0, blue1, blue, blueIndex, +- red0, red1, red, redIndex) +- } else { +- retval = sweep.sweepBipartite( +- d, visit, +- red0, red1, red, redIndex, +- blue0, blue1, blue, blueIndex) +- } +- } else { +- iterPush(top++, +- axis+1, +- red0, red1, +- blue0, blue1, +- flip, +- -Infinity, Infinity) +- iterPush(top++, +- axis+1, +- blue0, blue1, +- red0, red1, +- flip^1, +- -Infinity, Infinity) +- } +- } +- } +- } ++//Main loop, runs PSLG clean up until completion ++function cleanPSLG(points, edges, colors) { ++ var modified = false ++ ++ //If using colors, augment edges with color data ++ var prevEdges ++ if(colors) { ++ prevEdges = edges ++ var augEdges = new Array(edges.length) ++ for(var i=0; istart && boxes[ptr+axis] > x; +- --j, ptr-=elemSize) { +- //Swap +- var aPtr = ptr +- var bPtr = ptr+elemSize +- for(var k=0; k>> 1) +- var elemSize = 2*d +- var pivot = mid +- var value = boxes[elemSize*mid+axis] +- +- while(lo < hi) { +- if(hi - lo < PARTITION_THRESHOLD) { +- insertionSort(d, axis, lo, hi, boxes, ids) +- value = boxes[elemSize*mid+axis] +- break +- } +- +- //Select pivot using median-of-3 +- var count = hi - lo +- var pivot0 = (Math.random()*count+lo)|0 +- var value0 = boxes[elemSize*pivot0 + axis] +- var pivot1 = (Math.random()*count+lo)|0 +- var value1 = boxes[elemSize*pivot1 + axis] +- var pivot2 = (Math.random()*count+lo)|0 +- var value2 = boxes[elemSize*pivot2 + axis] +- if(value0 <= value1) { +- if(value2 >= value1) { +- pivot = pivot1 +- value = value1 +- } else if(value0 >= value2) { +- pivot = pivot0 +- value = value0 +- } else { +- pivot = pivot2 +- value = value2 +- } +- } else { +- if(value1 >= value2) { +- pivot = pivot1 +- value = value1 +- } else if(value2 >= value0) { +- pivot = pivot0 +- value = value0 +- } else { +- pivot = pivot2 +- value = value2 +- } +- } ++function solveIntersection(a, b, c, d) { ++ var ba = rvSub(b, a) ++ var dc = rvSub(d, c) + +- //Swap pivot to end of array +- var aPtr = elemSize * (hi-1) +- var bPtr = elemSize * pivot +- for(var i=0; i= 0) { +- reads.push('lo=e[k+n]') +- } +- if(predicate.indexOf('hi') >= 0) { +- reads.push('hi=e[k+o]') +- } +- fargs.push( +- code.replace('_', reads.join()) +- .replace('$', predicate)) +- return Function.apply(void 0, fargs) +-} +-},{}],47:[function(require,module,exports){ +-'use strict'; ++module.exports = compareAngle + +-//This code is extracted from ndarray-sort +-//It is inlined here as a temporary workaround ++var orient = require("robust-orientation") ++var sgn = require("signum") ++var twoSum = require("two-sum") ++var robustProduct = require("robust-product") ++var robustSum = require("robust-sum") + +-module.exports = wrapper; ++function testInterior(a, b, c) { ++ var x0 = twoSum(a[0], -b[0]) ++ var y0 = twoSum(a[1], -b[1]) ++ var x1 = twoSum(c[0], -b[0]) ++ var y1 = twoSum(c[1], -b[1]) + +-var INSERT_SORT_CUTOFF = 32 ++ var d = robustSum( ++ robustProduct(x0, x1), ++ robustProduct(y0, y1)) + +-function wrapper(data, n0) { +- if (n0 <= 4*INSERT_SORT_CUTOFF) { +- insertionSort(0, n0 - 1, data); +- } else { +- quickSort(0, n0 - 1, data); +- } ++ return d[d.length-1] >= 0 + } + +-function insertionSort(left, right, data) { +- var ptr = 2*(left+1) +- for(var i=left+1; i<=right; ++i) { +- var a = data[ptr++] +- var b = data[ptr++] +- var j = i +- var jptr = ptr-2 +- while(j-- > left) { +- var x = data[jptr-2] +- var y = data[jptr-1] +- if(x < a) { +- break +- } else if(x === a && y < b) { +- break ++function compareAngle(a, b, c, d) { ++ var bcd = orient(b, c, d) ++ if(bcd === 0) { ++ //Handle degenerate cases ++ var sabc = sgn(orient(a, b, c)) ++ var sabd = sgn(orient(a, b, d)) ++ if(sabc === sabd) { ++ if(sabc === 0) { ++ var ic = testInterior(a, b, c) ++ var id = testInterior(a, b, d) ++ if(ic === id) { ++ return 0 ++ } else if(ic) { ++ return 1 ++ } else { ++ return -1 ++ } ++ } ++ return 0 ++ } else if(sabd === 0) { ++ if(sabc > 0) { ++ return -1 ++ } else if(testInterior(a, b, d)) { ++ return -1 ++ } else { ++ return 1 ++ } ++ } else if(sabc === 0) { ++ if(sabd > 0) { ++ return 1 ++ } else if(testInterior(a, b, c)) { ++ return 1 ++ } else { ++ return -1 + } +- data[jptr] = x +- data[jptr+1] = y +- jptr -= 2 + } +- data[jptr] = a +- data[jptr+1] = b +- } +-} +- +-function swap(i, j, data) { +- i *= 2 +- j *= 2 +- var x = data[i] +- var y = data[i+1] +- data[i] = data[j] +- data[i+1] = data[j+1] +- data[j] = x +- data[j+1] = y +-} +- +-function move(i, j, data) { +- i *= 2 +- j *= 2 +- data[i] = data[j] +- data[i+1] = data[j+1] +-} +- +-function rotate(i, j, k, data) { +- i *= 2 +- j *= 2 +- k *= 2 +- var x = data[i] +- var y = data[i+1] +- data[i] = data[j] +- data[i+1] = data[j+1] +- data[j] = data[k] +- data[j+1] = data[k+1] +- data[k] = x +- data[k+1] = y +-} +- +-function shufflePivot(i, j, px, py, data) { +- i *= 2 +- j *= 2 +- data[i] = data[j] +- data[j] = px +- data[i+1] = data[j+1] +- data[j+1] = py +-} +- +-function compare(i, j, data) { +- i *= 2 +- j *= 2 +- var x = data[i], +- y = data[j] +- if(x < y) { +- return false +- } else if(x === y) { +- return data[i+1] > data[j+1] ++ return sgn(sabd - sabc) + } +- return true +-} +- +-function comparePivot(i, y, b, data) { +- i *= 2 +- var x = data[i] +- if(x < y) { +- return true +- } else if(x === y) { +- return data[i+1] < b ++ var abc = orient(a, b, c) ++ if(abc > 0) { ++ if(bcd > 0 && orient(a, b, d) > 0) { ++ return 1 ++ } ++ return -1 ++ } else if(abc < 0) { ++ if(bcd > 0 || orient(a, b, d) > 0) { ++ return 1 ++ } ++ return -1 ++ } else { ++ var abd = orient(a, b, d) ++ if(abd > 0) { ++ return 1 ++ } else { ++ if(testInterior(a, b, c)) { ++ return 1 ++ } else { ++ return -1 ++ } ++ } + } +- return false + } ++},{"robust-orientation":140,"robust-product":141,"robust-sum":145,"signum":146,"two-sum":161}],49:[function(require,module,exports){ ++module.exports = compareCells + +-function quickSort(left, right, data) { +- var sixth = (right - left + 1) / 6 | 0, +- index1 = left + sixth, +- index5 = right - sixth, +- index3 = left + right >> 1, +- index2 = index3 - sixth, +- index4 = index3 + sixth, +- el1 = index1, +- el2 = index2, +- el3 = index3, +- el4 = index4, +- el5 = index5, +- less = left + 1, +- great = right - 1, +- tmp = 0 +- if(compare(el1, el2, data)) { +- tmp = el1 +- el1 = el2 +- el2 = tmp +- } +- if(compare(el4, el5, data)) { +- tmp = el4 +- el4 = el5 +- el5 = tmp +- } +- if(compare(el1, el3, data)) { +- tmp = el1 +- el1 = el3 +- el3 = tmp +- } +- if(compare(el2, el3, data)) { +- tmp = el2 +- el2 = el3 +- el3 = tmp +- } +- if(compare(el1, el4, data)) { +- tmp = el1 +- el1 = el4 +- el4 = tmp +- } +- if(compare(el3, el4, data)) { +- tmp = el3 +- el3 = el4 +- el4 = tmp +- } +- if(compare(el2, el5, data)) { +- tmp = el2 +- el2 = el5 +- el5 = tmp +- } +- if(compare(el2, el3, data)) { +- tmp = el2 +- el2 = el3 +- el3 = tmp +- } +- if(compare(el4, el5, data)) { +- tmp = el4 +- el4 = el5 +- el5 = tmp +- } ++var min = Math.min + +- var pivot1X = data[2*el2] +- var pivot1Y = data[2*el2+1] +- var pivot2X = data[2*el4] +- var pivot2Y = data[2*el4+1] ++function compareInt(a, b) { ++ return a - b ++} + +- var ptr0 = 2 * el1; +- var ptr2 = 2 * el3; +- var ptr4 = 2 * el5; +- var ptr5 = 2 * index1; +- var ptr6 = 2 * index3; +- var ptr7 = 2 * index5; +- for (var i1 = 0; i1 < 2; ++i1) { +- var x = data[ptr0+i1]; +- var y = data[ptr2+i1]; +- var z = data[ptr4+i1]; +- data[ptr5+i1] = x; +- data[ptr6+i1] = y; +- data[ptr7+i1] = z; ++function compareCells(a, b) { ++ var n = a.length ++ , t = a.length - b.length ++ if(t) { ++ return t + } +- +- move(index2, left, data) +- move(index4, right, data) +- for (var k = less; k <= great; ++k) { +- if (comparePivot(k, pivot1X, pivot1Y, data)) { +- if (k !== less) { +- swap(k, less, data) ++ switch(n) { ++ case 0: ++ return 0 ++ case 1: ++ return a[0] - b[0] ++ case 2: ++ return (a[0]+a[1]-b[0]-b[1]) || ++ min(a[0],a[1]) - min(b[0],b[1]) ++ case 3: ++ var l1 = a[0]+a[1] ++ , m1 = b[0]+b[1] ++ t = l1+a[2] - (m1+b[2]) ++ if(t) { ++ return t + } +- ++less; +- } else { +- if (!comparePivot(k, pivot2X, pivot2Y, data)) { +- while (true) { +- if (!comparePivot(great, pivot2X, pivot2Y, data)) { +- if (--great < k) { +- break; +- } +- continue; +- } else { +- if (comparePivot(great, pivot1X, pivot1Y, data)) { +- rotate(k, less, great, data) +- ++less; +- --great; +- } else { +- swap(k, great, data) +- --great; +- } +- break; +- } ++ var l0 = min(a[0], a[1]) ++ , m0 = min(b[0], b[1]) ++ return min(l0, a[2]) - min(m0, b[2]) || ++ min(l0+a[2], l1) - min(m0+b[2], m1) ++ case 4: ++ var aw=a[0], ax=a[1], ay=a[2], az=a[3] ++ , bw=b[0], bx=b[1], by=b[2], bz=b[3] ++ return (aw+ax+ay+az)-(bw+bx+by+bz) || ++ min(aw,ax,ay,az)-min(bw,bx,by,bz,bw) || ++ min(aw+ax,aw+ay,aw+az,ax+ay,ax+az,ay+az) - ++ min(bw+bx,bw+by,bw+bz,bx+by,bx+bz,by+bz) || ++ min(aw+ax+ay,aw+ax+az,aw+ay+az,ax+ay+az) - ++ min(bw+bx+by,bw+bx+bz,bw+by+bz,bx+by+bz) ++ default: ++ var as = a.slice().sort(compareInt) ++ var bs = b.slice().sort(compareInt) ++ for(var i=0; i0) { ++ throw new Error("cwise: pre() block may not reference array args") ++ } ++ if(i < proc.post.args.length && proc.post.args[i].count>0) { ++ throw new Error("cwise: post() block may not reference array args") ++ } ++ } else if(arg_type === "scalar") { ++ proc.scalarArgs.push(i) ++ proc.shimArgs.push("scalar" + i) ++ } else if(arg_type === "index") { ++ proc.indexArgs.push(i) ++ if(i < proc.pre.args.length && proc.pre.args[i].count > 0) { ++ throw new Error("cwise: pre() block may not reference array index") ++ } ++ if(i < proc.body.args.length && proc.body.args[i].lvalue) { ++ throw new Error("cwise: body() block may not write to array index") ++ } ++ if(i < proc.post.args.length && proc.post.args[i].count > 0) { ++ throw new Error("cwise: post() block may not reference array index") ++ } ++ } else if(arg_type === "shape") { ++ proc.shapeArgs.push(i) ++ if(i < proc.pre.args.length && proc.pre.args[i].lvalue) { ++ throw new Error("cwise: pre() block may not write to array shape") ++ } ++ if(i < proc.body.args.length && proc.body.args[i].lvalue) { ++ throw new Error("cwise: body() block may not write to array shape") ++ } ++ if(i < proc.post.args.length && proc.post.args[i].lvalue) { ++ throw new Error("cwise: post() block may not write to array shape") ++ } ++ } else if(typeof arg_type === "object" && arg_type.offset) { ++ proc.argTypes[i] = "offset" ++ proc.offsetArgs.push({ array: arg_type.array, offset:arg_type.offset }) ++ proc.offsetArgIndex.push(i) ++ } else { ++ throw new Error("cwise: Unknown argument type " + proc_args[i]) ++ } ++ } ++ ++ //Make sure at least one array argument was specified ++ if(proc.arrayArgs.length <= 0) { ++ throw new Error("cwise: No array arguments specified") ++ } ++ ++ //Make sure arguments are correct ++ if(proc.pre.args.length > proc_args.length) { ++ throw new Error("cwise: Too many arguments in pre() block") ++ } ++ if(proc.body.args.length > proc_args.length) { ++ throw new Error("cwise: Too many arguments in body() block") ++ } ++ if(proc.post.args.length > proc_args.length) { ++ throw new Error("cwise: Too many arguments in post() block") ++ } ++ ++ //Check debug flag ++ proc.debug = !!user_args.printCode || !!user_args.debug ++ ++ //Retrieve name ++ proc.funcName = user_args.funcName || "cwise" ++ ++ //Read in block size ++ proc.blockSize = user_args.blockSize || 64 ++ ++ return createThunk(proc) ++} ++ ++module.exports = compileCwise + +-//Flag for blue +-var BLUE_FLAG = (1<<28) ++},{"./lib/thunk.js":52}],51:[function(require,module,exports){ ++"use strict" ++ ++var uniq = require("uniq") ++ ++// This function generates very simple loops analogous to how you typically traverse arrays (the outermost loop corresponds to the slowest changing index, the innermost loop to the fastest changing index) ++// TODO: If two arrays have the same strides (and offsets) there is potential for decreasing the number of "pointers" and related variables. The drawback is that the type signature would become more specific and that there would thus be less potential for caching, but it might still be worth it, especially when dealing with large numbers of arguments. ++function innerFill(order, proc, body) { ++ var dimension = order.length ++ , nargs = proc.arrayArgs.length ++ , has_index = proc.indexArgs.length>0 ++ , code = [] ++ , vars = [] ++ , idx=0, pidx=0, i, j ++ for(i=0; i=0; --i) { // Start at largest stride and work your way inwards ++ idx = order[i] ++ code.push(["for(i",i,"=0;i",i," 0) { ++ code.push(["index[",pidx,"]-=s",pidx].join("")) ++ } ++ code.push(["++index[",idx,"]"].join("")) ++ } ++ code.push("}") ++ } ++ return code.join("\n") ++} ++ ++// Generate "outer" loops that loop over blocks of data, applying "inner" loops to the blocks by manipulating the local variables in such a way that the inner loop only "sees" the current block. ++// TODO: If this is used, then the previous declaration (done by generateCwiseOp) of s* is essentially unnecessary. ++// I believe the s* are not used elsewhere (in particular, I don't think they're used in the pre/post parts and "shape" is defined independently), so it would be possible to make defining the s* dependent on what loop method is being used. ++function outerFill(matched, order, proc, body) { ++ var dimension = order.length ++ , nargs = proc.arrayArgs.length ++ , blockSize = proc.blockSize ++ , has_index = proc.indexArgs.length > 0 ++ , code = [] ++ for(var i=0; i0;){"].join("")) // Iterate back to front ++ code.push(["if(j",i,"<",blockSize,"){"].join("")) // Either decrease j by blockSize (s = blockSize), or set it to zero (after setting s = j). ++ code.push(["s",order[i],"=j",i].join("")) ++ code.push(["j",i,"=0"].join("")) ++ code.push(["}else{s",order[i],"=",blockSize].join("")) ++ code.push(["j",i,"-=",blockSize,"}"].join("")) ++ if(has_index) { ++ code.push(["index[",order[i],"]=j",i].join("")) ++ } ++ } ++ for(var i=0; i 0) { ++ allEqual = allEqual && summary[i] === summary[i-1] ++ } ++ } ++ if(allEqual) { ++ return summary[0] ++ } ++ return summary.join("") ++} ++ ++//Generates a cwise operator ++function generateCWiseOp(proc, typesig) { ++ ++ //Compute dimension ++ // Arrays get put first in typesig, and there are two entries per array (dtype and order), so this gets the number of dimensions in the first array arg. ++ var dimension = (typesig[1].length - Math.abs(proc.arrayBlockIndices[0]))|0 ++ var orders = new Array(proc.arrayArgs.length) ++ var dtypes = new Array(proc.arrayArgs.length) ++ for(var i=0; i 0) { ++ vars.push("shape=SS.slice(0)") // Makes the shape over which we iterate available to the user defined functions (so you can use width/height for example) ++ } ++ if(proc.indexArgs.length > 0) { ++ // Prepare an array to keep track of the (logical) indices, initialized to dimension zeroes. ++ var zeros = new Array(dimension) ++ for(var i=0; i 3) { ++ code.push(processBlock(proc.pre, proc, dtypes)) ++ } ++ ++ //Process body ++ var body = processBlock(proc.body, proc, dtypes) ++ var matched = countMatches(loopOrders) ++ if(matched < dimension) { ++ code.push(outerFill(matched, loopOrders[0], proc, body)) // TODO: Rather than passing loopOrders[0], it might be interesting to look at passing an order that represents the majority of the arguments for example. ++ } else { ++ code.push(innerFill(loopOrders[0], proc, body)) ++ } ++ ++ //Inline epilog ++ if(proc.post.body.length > 3) { ++ code.push(processBlock(proc.post, proc, dtypes)) ++ } ++ ++ if(proc.debug) { ++ console.log("-----Generated cwise routine for ", typesig, ":\n" + code.join("\n") + "\n----------") ++ } ++ ++ var loopName = [(proc.funcName||"unnamed"), "_cwise_loop_", orders[0].join("s"),"m",matched,typeSummary(dtypes)].join("") ++ var f = new Function(["function ",loopName,"(", arglist.join(","),"){", code.join("\n"),"} return ", loopName].join("")) ++ return f() ++} ++module.exports = generateCWiseOp + +-//1D sweep event queue stuff (use pool to save space) +-var INIT_CAPACITY = 1024 +-var RED_SWEEP_QUEUE = pool.mallocInt32(INIT_CAPACITY) +-var RED_SWEEP_INDEX = pool.mallocInt32(INIT_CAPACITY) +-var BLUE_SWEEP_QUEUE = pool.mallocInt32(INIT_CAPACITY) +-var BLUE_SWEEP_INDEX = pool.mallocInt32(INIT_CAPACITY) +-var COMMON_SWEEP_QUEUE = pool.mallocInt32(INIT_CAPACITY) +-var COMMON_SWEEP_INDEX = pool.mallocInt32(INIT_CAPACITY) +-var SWEEP_EVENTS = pool.mallocDouble(INIT_CAPACITY * 8) ++},{"uniq":164}],52:[function(require,module,exports){ ++"use strict" ++ ++// The function below is called when constructing a cwise function object, and does the following: ++// A function object is constructed which accepts as argument a compilation function and returns another function. ++// It is this other function that is eventually returned by createThunk, and this function is the one that actually ++// checks whether a certain pattern of arguments has already been used before and compiles new loops as needed. ++// The compilation passed to the first function object is used for compiling new functions. ++// Once this function object is created, it is called with compile as argument, where the first argument of compile ++// is bound to "proc" (essentially containing a preprocessed version of the user arguments to cwise). ++// So createThunk roughly works like this: ++// function createThunk(proc) { ++// var thunk = function(compileBound) { ++// var CACHED = {} ++// return function(arrays and scalars) { ++// if (dtype and order of arrays in CACHED) { ++// var func = CACHED[dtype and order of arrays] ++// } else { ++// var func = CACHED[dtype and order of arrays] = compileBound(dtype and order of arrays) ++// } ++// return func(arrays and scalars) ++// } ++// } ++// return thunk(compile.bind1(proc)) ++// } ++ ++var compile = require("./compile.js") ++ ++function createThunk(proc) { ++ var code = ["'use strict'", "var CACHED={}"] ++ var vars = [] ++ var thunkName = proc.funcName + "_cwise_thunk" ++ ++ //Build thunk ++ code.push(["return function ", thunkName, "(", proc.shimArgs.join(","), "){"].join("")) ++ var typesig = [] ++ var string_typesig = [] ++ var proc_args = [["array",proc.arrayArgs[0],".shape.slice(", // Slice shape so that we only retain the shape over which we iterate (which gets passed to the cwise operator as SS). ++ Math.max(0,proc.arrayBlockIndices[0]),proc.arrayBlockIndices[0]<0?(","+proc.arrayBlockIndices[0]+")"):")"].join("")] ++ var shapeLengthConditions = [], shapeConditions = [] ++ // Process array arguments ++ for(var i=0; i0) { // Gather conditions to check for shape equality (ignoring block indices) ++ shapeLengthConditions.push("array" + proc.arrayArgs[0] + ".shape.length===array" + j + ".shape.length+" + (Math.abs(proc.arrayBlockIndices[0])-Math.abs(proc.arrayBlockIndices[i]))) ++ shapeConditions.push("array" + proc.arrayArgs[0] + ".shape[shapeIndex+" + Math.max(0,proc.arrayBlockIndices[0]) + "]===array" + j + ".shape[shapeIndex+" + Math.max(0,proc.arrayBlockIndices[i]) + "]") ++ } ++ } ++ // Check for shape equality ++ if (proc.arrayArgs.length > 1) { ++ code.push("if (!(" + shapeLengthConditions.join(" && ") + ")) throw new Error('cwise: Arrays do not all have the same dimensionality!')") ++ code.push("for(var shapeIndex=array" + proc.arrayArgs[0] + ".shape.length-" + Math.abs(proc.arrayBlockIndices[0]) + "; shapeIndex-->0;) {") ++ code.push("if (!(" + shapeConditions.join(" && ") + ")) throw new Error('cwise: Arrays do not all have the same shape!')") ++ code.push("}") ++ } ++ // Process scalar arguments ++ for(var i=0; i b ? 1 : a >= b ? 0 : NaN; + } +- if(COMMON_SWEEP_INDEX.length < rcount) { +- pool.free(COMMON_SWEEP_INDEX) +- COMMON_SWEEP_INDEX = pool.mallocInt32(rcount) +- } +- var eventLength = 8 * rcount +- if(SWEEP_EVENTS.length < eventLength) { +- pool.free(SWEEP_EVENTS) +- SWEEP_EVENTS = pool.mallocDouble(eventLength) +- } +-} +- +-//Remove an item from the active queue in O(1) +-function sqPop(queue, index, count, item) { +- var idx = index[item] +- var top = queue[count-1] +- queue[idx] = top +- index[top] = idx +-} +- +-//Insert an item into the active queue in O(1) +-function sqPush(queue, index, count, item) { +- queue[count] = item +- index[item] = count +-} +- +-//Recursion base case: use 1D sweep algorithm +-function sweepBipartite( +- d, visit, +- redStart, redEnd, red, redIndex, +- blueStart, blueEnd, blue, blueIndex) { +- +- //store events as pairs [coordinate, idx] +- // +- // red create: -(idx+1) +- // red destroy: idx +- // blue create: -(idx+BLUE_FLAG) +- // blue destroy: idx+BLUE_FLAG +- // +- var ptr = 0 +- var elemSize = 2*d +- var istart = d-1 +- var iend = elemSize-1 +- +- for(var i=redStart; iright +- var n = ptr >>> 1 +- isort(SWEEP_EVENTS, n) +- +- var redActive = 0 +- var blueActive = 0 +- for(var i=0; i= BLUE_FLAG) { +- //blue destroy event +- e = (e-BLUE_FLAG)|0 +- sqPop(BLUE_SWEEP_QUEUE, BLUE_SWEEP_INDEX, blueActive--, e) +- } else if(e >= 0) { +- //red destroy event +- sqPop(RED_SWEEP_QUEUE, RED_SWEEP_INDEX, redActive--, e) +- } else if(e <= -BLUE_FLAG) { +- //blue create event +- e = (-e-BLUE_FLAG)|0 +- for(var j=0; j a ? 1 : b >= a ? 0 : NaN; ++ }; ++ d3.min = function(array, f) { ++ var i = -1, n = array.length, a, b; ++ if (arguments.length === 1) { ++ while (++i < n) if ((b = array[i]) != null && b >= b) { ++ a = b; ++ break; + } +- sqPush(BLUE_SWEEP_QUEUE, BLUE_SWEEP_INDEX, blueActive++, e) ++ while (++i < n) if ((b = array[i]) != null && a > b) a = b; + } else { +- //red create event +- e = (-e-1)|0 +- for(var j=0; j= b) { ++ a = b; ++ break; + } +- sqPush(RED_SWEEP_QUEUE, RED_SWEEP_INDEX, redActive++, e) +- } +- } +-} +- +-//Complete sweep +-function sweepComplete(d, visit, +- redStart, redEnd, red, redIndex, +- blueStart, blueEnd, blue, blueIndex) { +- +- var ptr = 0 +- var elemSize = 2*d +- var istart = d-1 +- var iend = elemSize-1 +- +- for(var i=redStart; iright +- var n = ptr >>> 1 +- isort(SWEEP_EVENTS, n) +- +- var redActive = 0 +- var blueActive = 0 +- var commonActive = 0 +- for(var i=0; i>1) === (SWEEP_EVENTS[2*i+3]>>1)) { +- color = 2 +- i += 1 ++ while (++i < n) if ((b = f.call(array, array[i], i)) != null && a > b) a = b; + } +- +- if(e < 0) { +- //Create event +- var id = -(e>>1) - 1 +- +- //Intersect with common +- for(var j=0; j= b) { ++ a = b; ++ break; + } +- +- if(color !== 0) { +- //Intersect with red +- for(var j=0; j a) a = b; ++ } else { ++ while (++i < n) if ((b = f.call(array, array[i], i)) != null && b >= b) { ++ a = b; ++ break; + } +- +- if(color !== 1) { +- //Intersect with blue +- for(var j=0; j a) a = b; ++ } ++ return a; ++ }; ++ d3.extent = function(array, f) { ++ var i = -1, n = array.length, a, b, c; ++ if (arguments.length === 1) { ++ while (++i < n) if ((b = array[i]) != null && b >= b) { ++ a = c = b; ++ break; + } +- +- if(color === 0) { +- //Red +- sqPush(RED_SWEEP_QUEUE, RED_SWEEP_INDEX, redActive++, id) +- } else if(color === 1) { +- //Blue +- sqPush(BLUE_SWEEP_QUEUE, BLUE_SWEEP_INDEX, blueActive++, id) +- } else if(color === 2) { +- //Both +- sqPush(COMMON_SWEEP_QUEUE, COMMON_SWEEP_INDEX, commonActive++, id) ++ while (++i < n) if ((b = array[i]) != null) { ++ if (a > b) a = b; ++ if (c < b) c = b; + } + } else { +- //Destroy event +- var id = (e>>1) - 1 +- if(color === 0) { +- //Red +- sqPop(RED_SWEEP_QUEUE, RED_SWEEP_INDEX, redActive--, id) +- } else if(color === 1) { +- //Blue +- sqPop(BLUE_SWEEP_QUEUE, BLUE_SWEEP_INDEX, blueActive--, id) +- } else if(color === 2) { +- //Both +- sqPop(COMMON_SWEEP_QUEUE, COMMON_SWEEP_INDEX, commonActive--, id) ++ while (++i < n) if ((b = f.call(array, array[i], i)) != null && b >= b) { ++ a = c = b; ++ break; ++ } ++ while (++i < n) if ((b = f.call(array, array[i], i)) != null) { ++ if (a > b) a = b; ++ if (c < b) c = b; + } + } ++ return [ a, c ]; ++ }; ++ function d3_number(x) { ++ return x === null ? NaN : +x; + } +-} +- +-//Sweep and prune/scanline algorithm: +-// Scan along axis, detect intersections +-// Brute force all boxes along axis +-function scanBipartite( +- d, axis, visit, flip, +- redStart, redEnd, red, redIndex, +- blueStart, blueEnd, blue, blueIndex) { +- +- var ptr = 0 +- var elemSize = 2*d +- var istart = axis +- var iend = axis+d +- +- var redShift = 1 +- var blueShift = 1 +- if(flip) { +- blueShift = BLUE_FLAG +- } else { +- redShift = BLUE_FLAG +- } +- +- for(var i=redStart; iright +- var n = ptr >>> 1 +- isort(SWEEP_EVENTS, n) +- +- var redActive = 0 +- for(var i=0; i= BLUE_FLAG) { +- isRed = !flip +- idx -= BLUE_FLAG +- } else { +- isRed = !!flip +- idx -= 1 +- } +- if(isRed) { +- sqPush(RED_SWEEP_QUEUE, RED_SWEEP_INDEX, redActive++, idx) +- } else { +- var blueId = blueIndex[idx] +- var bluePtr = elemSize * idx +- +- var b0 = blue[bluePtr+axis+1] +- var b1 = blue[bluePtr+axis+1+d] +- +-red_loop: +- for(var j=0; jright +- var n = ptr >>> 1 +- isort(SWEEP_EVENTS, n) +- +- var redActive = 0 +- for(var i=0; i= BLUE_FLAG) { +- RED_SWEEP_QUEUE[redActive++] = idx - BLUE_FLAG +- } else { +- idx -= 1 +- var blueId = blueIndex[idx] +- var bluePtr = elemSize * idx +- +- var b0 = blue[bluePtr+axis+1] +- var b1 = blue[bluePtr+axis+1+d] +- +-red_loop: +- for(var j=0; j=0; --j) { +- if(RED_SWEEP_QUEUE[j] === idx) { +- for(var k=j+1; k 1) return s / (j - 1); ++ }; ++ d3.deviation = function() { ++ var v = d3.variance.apply(this, arguments); ++ return v ? Math.sqrt(v) : v; ++ }; ++ function d3_bisector(compare) { ++ return { ++ left: function(a, x, lo, hi) { ++ if (arguments.length < 3) lo = 0; ++ if (arguments.length < 4) hi = a.length; ++ while (lo < hi) { ++ var mid = lo + hi >>> 1; ++ if (compare(a[mid], x) < 0) lo = mid + 1; else hi = mid; ++ } ++ return lo; ++ }, ++ right: function(a, x, lo, hi) { ++ if (arguments.length < 3) lo = 0; ++ if (arguments.length < 4) hi = a.length; ++ while (lo < hi) { ++ var mid = lo + hi >>> 1; ++ if (compare(a[mid], x) > 0) hi = mid; else lo = mid + 1; ++ } ++ return lo; ++ } ++ }; + } +-} +-},{"./sort":47,"bit-twiddle":9,"typedarray-pool":151}],49:[function(require,module,exports){ +-(function (Buffer){ +-var hasTypedArrays = false +-if(typeof Float64Array !== "undefined") { +- var DOUBLE_VIEW = new Float64Array(1) +- , UINT_VIEW = new Uint32Array(DOUBLE_VIEW.buffer) +- DOUBLE_VIEW[0] = 1.0 +- hasTypedArrays = true +- if(UINT_VIEW[1] === 0x3ff00000) { +- //Use little endian +- module.exports = function doubleBitsLE(n) { +- DOUBLE_VIEW[0] = n +- return [ UINT_VIEW[0], UINT_VIEW[1] ] +- } +- function toDoubleLE(lo, hi) { +- UINT_VIEW[0] = lo +- UINT_VIEW[1] = hi +- return DOUBLE_VIEW[0] ++ var d3_bisect = d3_bisector(d3_ascending); ++ d3.bisectLeft = d3_bisect.left; ++ d3.bisect = d3.bisectRight = d3_bisect.right; ++ d3.bisector = function(f) { ++ return d3_bisector(f.length === 1 ? function(d, x) { ++ return d3_ascending(f(d), x); ++ } : f); ++ }; ++ d3.shuffle = function(array, i0, i1) { ++ if ((m = arguments.length) < 3) { ++ i1 = array.length; ++ if (m < 2) i0 = 0; + } +- module.exports.pack = toDoubleLE +- function lowUintLE(n) { +- DOUBLE_VIEW[0] = n +- return UINT_VIEW[0] +- } +- module.exports.lo = lowUintLE +- function highUintLE(n) { +- DOUBLE_VIEW[0] = n +- return UINT_VIEW[1] ++ var m = i1 - i0, t, i; ++ while (m) { ++ i = Math.random() * m-- | 0; ++ t = array[m + i0], array[m + i0] = array[i + i0], array[i + i0] = t; + } +- module.exports.hi = highUintLE +- } else if(UINT_VIEW[0] === 0x3ff00000) { +- //Use big endian +- module.exports = function doubleBitsBE(n) { +- DOUBLE_VIEW[0] = n +- return [ UINT_VIEW[1], UINT_VIEW[0] ] ++ return array; ++ }; ++ d3.permute = function(array, indexes) { ++ var i = indexes.length, permutes = new Array(i); ++ while (i--) permutes[i] = array[indexes[i]]; ++ return permutes; ++ }; ++ d3.pairs = function(array) { ++ var i = 0, n = array.length - 1, p0, p1 = array[0], pairs = new Array(n < 0 ? 0 : n); ++ while (i < n) pairs[i] = [ p0 = p1, p1 = array[++i] ]; ++ return pairs; ++ }; ++ d3.transpose = function(matrix) { ++ if (!(n = matrix.length)) return []; ++ for (var i = -1, m = d3.min(matrix, d3_transposeLength), transpose = new Array(m); ++i < m; ) { ++ for (var j = -1, n, row = transpose[i] = new Array(n); ++j < n; ) { ++ row[j] = matrix[j][i]; ++ } + } +- function toDoubleBE(lo, hi) { +- UINT_VIEW[1] = lo +- UINT_VIEW[0] = hi +- return DOUBLE_VIEW[0] ++ return transpose; ++ }; ++ function d3_transposeLength(d) { ++ return d.length; ++ } ++ d3.zip = function() { ++ return d3.transpose(arguments); ++ }; ++ d3.keys = function(map) { ++ var keys = []; ++ for (var key in map) keys.push(key); ++ return keys; ++ }; ++ d3.values = function(map) { ++ var values = []; ++ for (var key in map) values.push(map[key]); ++ return values; ++ }; ++ d3.entries = function(map) { ++ var entries = []; ++ for (var key in map) entries.push({ ++ key: key, ++ value: map[key] ++ }); ++ return entries; ++ }; ++ d3.merge = function(arrays) { ++ var n = arrays.length, m, i = -1, j = 0, merged, array; ++ while (++i < n) j += arrays[i].length; ++ merged = new Array(j); ++ while (--n >= 0) { ++ array = arrays[n]; ++ m = array.length; ++ while (--m >= 0) { ++ merged[--j] = array[m]; ++ } + } +- module.exports.pack = toDoubleBE +- function lowUintBE(n) { +- DOUBLE_VIEW[0] = n +- return UINT_VIEW[1] ++ return merged; ++ }; ++ var abs = Math.abs; ++ d3.range = function(start, stop, step) { ++ if (arguments.length < 3) { ++ step = 1; ++ if (arguments.length < 2) { ++ stop = start; ++ start = 0; ++ } + } +- module.exports.lo = lowUintBE +- function highUintBE(n) { +- DOUBLE_VIEW[0] = n +- return UINT_VIEW[0] ++ if ((stop - start) / step === Infinity) throw new Error("infinite range"); ++ var range = [], k = d3_range_integerScale(abs(step)), i = -1, j; ++ start *= k, stop *= k, step *= k; ++ if (step < 0) while ((j = start + step * ++i) > stop) range.push(j / k); else while ((j = start + step * ++i) < stop) range.push(j / k); ++ return range; ++ }; ++ function d3_range_integerScale(x) { ++ var k = 1; ++ while (x * k % 1) k *= 10; ++ return k; ++ } ++ function d3_class(ctor, properties) { ++ for (var key in properties) { ++ Object.defineProperty(ctor.prototype, key, { ++ value: properties[key], ++ enumerable: false ++ }); + } +- module.exports.hi = highUintBE +- } else { +- hasTypedArrays = false + } +-} +-if(!hasTypedArrays) { +- var buffer = new Buffer(8) +- module.exports = function doubleBits(n) { +- buffer.writeDoubleLE(n, 0, true) +- return [ buffer.readUInt32LE(0, true), buffer.readUInt32LE(4, true) ] ++ d3.map = function(object, f) { ++ var map = new d3_Map(); ++ if (object instanceof d3_Map) { ++ object.forEach(function(key, value) { ++ map.set(key, value); ++ }); ++ } else if (Array.isArray(object)) { ++ var i = -1, n = object.length, o; ++ if (arguments.length === 1) while (++i < n) map.set(i, object[i]); else while (++i < n) map.set(f.call(object, o = object[i], i), o); ++ } else { ++ for (var key in object) map.set(key, object[key]); ++ } ++ return map; ++ }; ++ function d3_Map() { ++ this._ = Object.create(null); + } +- function toDouble(lo, hi) { +- buffer.writeUInt32LE(lo, 0, true) +- buffer.writeUInt32LE(hi, 4, true) +- return buffer.readDoubleLE(0, true) ++ var d3_map_proto = "__proto__", d3_map_zero = "\x00"; ++ d3_class(d3_Map, { ++ has: d3_map_has, ++ get: function(key) { ++ return this._[d3_map_escape(key)]; ++ }, ++ set: function(key, value) { ++ return this._[d3_map_escape(key)] = value; ++ }, ++ remove: d3_map_remove, ++ keys: d3_map_keys, ++ values: function() { ++ var values = []; ++ for (var key in this._) values.push(this._[key]); ++ return values; ++ }, ++ entries: function() { ++ var entries = []; ++ for (var key in this._) entries.push({ ++ key: d3_map_unescape(key), ++ value: this._[key] ++ }); ++ return entries; ++ }, ++ size: d3_map_size, ++ empty: d3_map_empty, ++ forEach: function(f) { ++ for (var key in this._) f.call(this, d3_map_unescape(key), this._[key]); ++ } ++ }); ++ function d3_map_escape(key) { ++ return (key += "") === d3_map_proto || key[0] === d3_map_zero ? d3_map_zero + key : key; + } +- module.exports.pack = toDouble +- function lowUint(n) { +- buffer.writeDoubleLE(n, 0, true) +- return buffer.readUInt32LE(0, true) ++ function d3_map_unescape(key) { ++ return (key += "")[0] === d3_map_zero ? key.slice(1) : key; + } +- module.exports.lo = lowUint +- function highUint(n) { +- buffer.writeDoubleLE(n, 0, true) +- return buffer.readUInt32LE(4, true) ++ function d3_map_has(key) { ++ return d3_map_escape(key) in this._; + } +- module.exports.hi = highUint +-} +- +-module.exports.sign = function(n) { +- return module.exports.hi(n) >>> 31 +-} +- +-module.exports.exponent = function(n) { +- var b = module.exports.hi(n) +- return ((b<<1) >>> 21) - 1023 +-} +- +-module.exports.fraction = function(n) { +- var lo = module.exports.lo(n) +- var hi = module.exports.hi(n) +- var b = hi & ((1<<20) - 1) +- if(hi & 0x7ff00000) { +- b += (1<<20) ++ function d3_map_remove(key) { ++ return (key = d3_map_escape(key)) in this._ && delete this._[key]; + } +- return [lo, b] +-} +- +-module.exports.denormalized = function(n) { +- var hi = module.exports.hi(n) +- return !(hi & 0x7ff00000) +-} +-}).call(this,require("buffer").Buffer) +-},{"buffer":10}],50:[function(require,module,exports){ +-"use strict" +- +-var doubleBits = require("double-bits") +- +-var SMALLEST_DENORM = Math.pow(2, -1074) +-var UINT_MAX = (-1)>>>0 +- +-module.exports = nextafter +- +-function nextafter(x, y) { +- if(isNaN(x) || isNaN(y)) { +- return NaN ++ function d3_map_keys() { ++ var keys = []; ++ for (var key in this._) keys.push(d3_map_unescape(key)); ++ return keys; + } +- if(x === y) { +- return x ++ function d3_map_size() { ++ var size = 0; ++ for (var key in this._) ++size; ++ return size; + } +- if(x === 0) { +- if(y < 0) { +- return -SMALLEST_DENORM +- } else { +- return SMALLEST_DENORM +- } ++ function d3_map_empty() { ++ for (var key in this._) return false; ++ return true; + } +- var hi = doubleBits.hi(x) +- var lo = doubleBits.lo(x) +- if((y > x) === (x > 0)) { +- if(lo === UINT_MAX) { +- hi += 1 +- lo = 0 +- } else { +- lo += 1 ++ d3.nest = function() { ++ var nest = {}, keys = [], sortKeys = [], sortValues, rollup; ++ function map(mapType, array, depth) { ++ if (depth >= keys.length) return rollup ? rollup.call(nest, array) : sortValues ? array.sort(sortValues) : array; ++ var i = -1, n = array.length, key = keys[depth++], keyValue, object, setter, valuesByKey = new d3_Map(), values; ++ while (++i < n) { ++ if (values = valuesByKey.get(keyValue = key(object = array[i]))) { ++ values.push(object); ++ } else { ++ valuesByKey.set(keyValue, [ object ]); ++ } ++ } ++ if (mapType) { ++ object = mapType(); ++ setter = function(keyValue, values) { ++ object.set(keyValue, map(mapType, values, depth)); ++ }; ++ } else { ++ object = {}; ++ setter = function(keyValue, values) { ++ object[keyValue] = map(mapType, values, depth); ++ }; ++ } ++ valuesByKey.forEach(setter); ++ return object; + } +- } else { +- if(lo === 0) { +- lo = UINT_MAX +- hi -= 1 +- } else { +- lo -= 1 ++ function entries(map, depth) { ++ if (depth >= keys.length) return map; ++ var array = [], sortKey = sortKeys[depth++]; ++ map.forEach(function(key, keyMap) { ++ array.push({ ++ key: key, ++ values: entries(keyMap, depth) ++ }); ++ }); ++ return sortKey ? array.sort(function(a, b) { ++ return sortKey(a.key, b.key); ++ }) : array; + } ++ nest.map = function(array, mapType) { ++ return map(mapType, array, 0); ++ }; ++ nest.entries = function(array) { ++ return entries(map(d3.map, array, 0), 0); ++ }; ++ nest.key = function(d) { ++ keys.push(d); ++ return nest; ++ }; ++ nest.sortKeys = function(order) { ++ sortKeys[keys.length - 1] = order; ++ return nest; ++ }; ++ nest.sortValues = function(order) { ++ sortValues = order; ++ return nest; ++ }; ++ nest.rollup = function(f) { ++ rollup = f; ++ return nest; ++ }; ++ return nest; ++ }; ++ d3.set = function(array) { ++ var set = new d3_Set(); ++ if (array) for (var i = 0, n = array.length; i < n; ++i) set.add(array[i]); ++ return set; ++ }; ++ function d3_Set() { ++ this._ = Object.create(null); + } +- return doubleBits.pack(lo, hi) +-} +-},{"double-bits":49}],51:[function(require,module,exports){ +-'use strict' +- +-var bnadd = require('big-rat/add') +- +-module.exports = add +- +-function add(a, b) { +- var n = a.length +- var r = new Array(n) +- for(var i=0; i 0 && y0 > 0) || (x0 < 0 && y0 < 0)) { +- return false ++ var d3_vendorPrefixes = [ "webkit", "ms", "moz", "Moz", "o", "O" ]; ++ function d3_noop() {} ++ d3.dispatch = function() { ++ var dispatch = new d3_dispatch(), i = -1, n = arguments.length; ++ while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch); ++ return dispatch; ++ }; ++ function d3_dispatch() {} ++ d3_dispatch.prototype.on = function(type, listener) { ++ var i = type.indexOf("."), name = ""; ++ if (i >= 0) { ++ name = type.slice(i + 1); ++ type = type.slice(0, i); ++ } ++ if (type) return arguments.length < 2 ? this[type].on(name) : this[type].on(name, listener); ++ if (arguments.length === 2) { ++ if (listener == null) for (type in this) { ++ if (this.hasOwnProperty(type)) this[type].on(name, null); ++ } ++ return this; ++ } ++ }; ++ function d3_dispatch_event(dispatch) { ++ var listeners = [], listenerByName = new d3_Map(); ++ function event() { ++ var z = listeners, i = -1, n = z.length, l; ++ while (++i < n) if (l = z[i].on) l.apply(this, arguments); ++ return dispatch; ++ } ++ event.on = function(name, listener) { ++ var l = listenerByName.get(name), i; ++ if (arguments.length < 2) return l && l.on; ++ if (l) { ++ l.on = null; ++ listeners = listeners.slice(0, i = listeners.indexOf(l)).concat(listeners.slice(i + 1)); ++ listenerByName.remove(name); ++ } ++ if (listener) listeners.push(listenerByName.set(name, { ++ on: listener ++ })); ++ return dispatch; ++ }; ++ return event; + } +- +- var x1 = orient(b0, a0, a1) +- var y1 = orient(b1, a0, a1) +- if((x1 > 0 && y1 > 0) || (x1 < 0 && y1 < 0)) { +- return false ++ d3.event = null; ++ function d3_eventPreventDefault() { ++ d3.event.preventDefault(); + } +- +- //Check for degenerate collinear case +- if(x0 === 0 && y0 === 0 && x1 === 0 && y1 === 0) { +- return checkCollinear(a0, a1, b0, b1) ++ function d3_eventSource() { ++ var e = d3.event, s; ++ while (s = e.sourceEvent) e = s; ++ return e; + } +- +- return true +-} +-},{"robust-orientation":133}],56:[function(require,module,exports){ +-"use strict"; "use restrict"; +- +-module.exports = UnionFind; +- +-function UnionFind(count) { +- this.roots = new Array(count); +- this.ranks = new Array(count); +- +- for(var i=0; i= 0 && (prefix = name.slice(0, i)) !== "xmlns") name = name.slice(i + 1); ++ return d3_nsPrefix.hasOwnProperty(prefix) ? { ++ space: d3_nsPrefix[prefix], ++ local: name ++ } : name; ++ } ++ }; ++ d3_selectionPrototype.attr = function(name, value) { ++ if (arguments.length < 2) { ++ if (typeof name === "string") { ++ var node = this.node(); ++ name = d3.ns.qualify(name); ++ return name.local ? node.getAttributeNS(name.space, name.local) : node.getAttribute(name); ++ } ++ for (value in name) this.each(d3_selection_attr(value, name[value])); ++ return this; ++ } ++ return this.each(d3_selection_attr(name, value)); ++ }; ++ function d3_selection_attr(name, value) { ++ name = d3.ns.qualify(name); ++ function attrNull() { ++ this.removeAttribute(name); ++ } ++ function attrNullNS() { ++ this.removeAttributeNS(name.space, name.local); ++ } ++ function attrConstant() { ++ this.setAttribute(name, value); ++ } ++ function attrConstantNS() { ++ this.setAttributeNS(name.space, name.local, value); ++ } ++ function attrFunction() { ++ var x = value.apply(this, arguments); ++ if (x == null) this.removeAttribute(name); else this.setAttribute(name, x); ++ } ++ function attrFunctionNS() { ++ var x = value.apply(this, arguments); ++ if (x == null) this.removeAttributeNS(name.space, name.local); else this.setAttributeNS(name.space, name.local, x); ++ } ++ return value == null ? name.local ? attrNullNS : attrNull : typeof value === "function" ? name.local ? attrFunctionNS : attrFunction : name.local ? attrConstantNS : attrConstant; + } +-} +-},{}],57:[function(require,module,exports){ +-module.exports = compareCells +- +-var min = Math.min +- +-function compareInt(a, b) { +- return a - b +-} +- +-function compareCells(a, b) { +- var n = a.length +- , t = a.length - b.length +- if(t) { +- return t ++ function d3_collapse(s) { ++ return s.trim().replace(/\s+/g, " "); + } +- switch(n) { +- case 0: +- return 0 +- case 1: +- return a[0] - b[0] +- case 2: +- return (a[0]+a[1]-b[0]-b[1]) || +- min(a[0],a[1]) - min(b[0],b[1]) +- case 3: +- var l1 = a[0]+a[1] +- , m1 = b[0]+b[1] +- t = l1+a[2] - (m1+b[2]) +- if(t) { +- return t ++ d3_selectionPrototype.classed = function(name, value) { ++ if (arguments.length < 2) { ++ if (typeof name === "string") { ++ var node = this.node(), n = (name = d3_selection_classes(name)).length, i = -1; ++ if (value = node.classList) { ++ while (++i < n) if (!value.contains(name[i])) return false; ++ } else { ++ value = node.getAttribute("class"); ++ while (++i < n) if (!d3_selection_classedRe(name[i]).test(value)) return false; ++ } ++ return true; + } +- var l0 = min(a[0], a[1]) +- , m0 = min(b[0], b[1]) +- return min(l0, a[2]) - min(m0, b[2]) || +- min(l0+a[2], l1) - min(m0+b[2], m1) +- case 4: +- var aw=a[0], ax=a[1], ay=a[2], az=a[3] +- , bw=b[0], bx=b[1], by=b[2], bz=b[3] +- return (aw+ax+ay+az)-(bw+bx+by+bz) || +- min(aw,ax,ay,az)-min(bw,bx,by,bz,bw) || +- min(aw+ax,aw+ay,aw+az,ax+ay,ax+az,ay+az) - +- min(bw+bx,bw+by,bw+bz,bx+by,bx+bz,by+bz) || +- min(aw+ax+ay,aw+ax+az,aw+ay+az,ax+ay+az) - +- min(bw+bx+by,bw+bx+bz,bw+by+bz,bx+by+bz) +- default: +- var as = a.slice().sort(compareInt) +- var bs = b.slice().sort(compareInt) +- for(var i=0; i0) { +- throw new Error("cwise: pre() block may not reference array args") +- } +- if(i < proc.post.args.length && proc.post.args[i].count>0) { +- throw new Error("cwise: post() block may not reference array args") +- } +- } else if(arg_type === "scalar") { +- proc.scalarArgs.push(i) +- proc.shimArgs.push("scalar" + i) +- } else if(arg_type === "index") { +- proc.indexArgs.push(i) +- if(i < proc.pre.args.length && proc.pre.args[i].count > 0) { +- throw new Error("cwise: pre() block may not reference array index") +- } +- if(i < proc.body.args.length && proc.body.args[i].lvalue) { +- throw new Error("cwise: body() block may not write to array index") +- } +- if(i < proc.post.args.length && proc.post.args[i].count > 0) { +- throw new Error("cwise: post() block may not reference array index") +- } +- } else if(arg_type === "shape") { +- proc.shapeArgs.push(i) +- if(i < proc.pre.args.length && proc.pre.args[i].lvalue) { +- throw new Error("cwise: pre() block may not write to array shape") +- } +- if(i < proc.body.args.length && proc.body.args[i].lvalue) { +- throw new Error("cwise: body() block may not write to array shape") +- } +- if(i < proc.post.args.length && proc.post.args[i].lvalue) { +- throw new Error("cwise: post() block may not write to array shape") +- } +- } else if(typeof arg_type === "object" && arg_type.offset) { +- proc.argTypes[i] = "offset" +- proc.offsetArgs.push({ array: arg_type.array, offset:arg_type.offset }) +- proc.offsetArgIndex.push(i) +- } else { +- throw new Error("cwise: Unknown argument type " + proc_args[i]) +- } +- } +- +- //Make sure at least one array argument was specified +- if(proc.arrayArgs.length <= 0) { +- throw new Error("cwise: No array arguments specified") +- } +- +- //Make sure arguments are correct +- if(proc.pre.args.length > proc_args.length) { +- throw new Error("cwise: Too many arguments in pre() block") +- } +- if(proc.body.args.length > proc_args.length) { +- throw new Error("cwise: Too many arguments in body() block") +- } +- if(proc.post.args.length > proc_args.length) { +- throw new Error("cwise: Too many arguments in post() block") +- } +- +- //Check debug flag +- proc.debug = !!user_args.printCode || !!user_args.debug +- +- //Retrieve name +- proc.funcName = user_args.funcName || "cwise" +- +- //Read in block size +- proc.blockSize = user_args.blockSize || 64 +- +- return createThunk(proc) +-} +- +-module.exports = compileCwise +- +-},{"./lib/thunk.js":60}],59:[function(require,module,exports){ +-"use strict" +- +-var uniq = require("uniq") +- +-// This function generates very simple loops analogous to how you typically traverse arrays (the outermost loop corresponds to the slowest changing index, the innermost loop to the fastest changing index) +-// TODO: If two arrays have the same strides (and offsets) there is potential for decreasing the number of "pointers" and related variables. The drawback is that the type signature would become more specific and that there would thus be less potential for caching, but it might still be worth it, especially when dealing with large numbers of arguments. +-function innerFill(order, proc, body) { +- var dimension = order.length +- , nargs = proc.arrayArgs.length +- , has_index = proc.indexArgs.length>0 +- , code = [] +- , vars = [] +- , idx=0, pidx=0, i, j +- for(i=0; i=0; --i) { // Start at largest stride and work your way inwards +- idx = order[i] +- code.push(["for(i",i,"=0;i",i," 0) { +- code.push(["index[",pidx,"]-=s",pidx].join("")) +- } +- code.push(["++index[",idx,"]"].join("")) +- } +- code.push("}") +- } +- return code.join("\n") +-} +- +-// Generate "outer" loops that loop over blocks of data, applying "inner" loops to the blocks by manipulating the local variables in such a way that the inner loop only "sees" the current block. +-// TODO: If this is used, then the previous declaration (done by generateCwiseOp) of s* is essentially unnecessary. +-// I believe the s* are not used elsewhere (in particular, I don't think they're used in the pre/post parts and "shape" is defined independently), so it would be possible to make defining the s* dependent on what loop method is being used. +-function outerFill(matched, order, proc, body) { +- var dimension = order.length +- , nargs = proc.arrayArgs.length +- , blockSize = proc.blockSize +- , has_index = proc.indexArgs.length > 0 +- , code = [] +- for(var i=0; i0;){"].join("")) // Iterate back to front +- code.push(["if(j",i,"<",blockSize,"){"].join("")) // Either decrease j by blockSize (s = blockSize), or set it to zero (after setting s = j). +- code.push(["s",order[i],"=j",i].join("")) +- code.push(["j",i,"=0"].join("")) +- code.push(["}else{s",order[i],"=",blockSize].join("")) +- code.push(["j",i,"-=",blockSize,"}"].join("")) +- if(has_index) { +- code.push(["index[",order[i],"]=j",i].join("")) +- } +- } +- for(var i=0; i 0) { +- allEqual = allEqual && summary[i] === summary[i-1] +- } +- } +- if(allEqual) { +- return summary[0] +- } +- return summary.join("") +-} +- +-//Generates a cwise operator +-function generateCWiseOp(proc, typesig) { +- +- //Compute dimension +- // Arrays get put first in typesig, and there are two entries per array (dtype and order), so this gets the number of dimensions in the first array arg. +- var dimension = (typesig[1].length - Math.abs(proc.arrayBlockIndices[0]))|0 +- var orders = new Array(proc.arrayArgs.length) +- var dtypes = new Array(proc.arrayArgs.length) +- for(var i=0; i 0) { +- vars.push("shape=SS.slice(0)") // Makes the shape over which we iterate available to the user defined functions (so you can use width/height for example) +- } +- if(proc.indexArgs.length > 0) { +- // Prepare an array to keep track of the (logical) indices, initialized to dimension zeroes. +- var zeros = new Array(dimension) +- for(var i=0; i 3) { +- code.push(processBlock(proc.pre, proc, dtypes)) +- } +- +- //Process body +- var body = processBlock(proc.body, proc, dtypes) +- var matched = countMatches(loopOrders) +- if(matched < dimension) { +- code.push(outerFill(matched, loopOrders[0], proc, body)) // TODO: Rather than passing loopOrders[0], it might be interesting to look at passing an order that represents the majority of the arguments for example. +- } else { +- code.push(innerFill(loopOrders[0], proc, body)) +- } +- +- //Inline epilog +- if(proc.post.body.length > 3) { +- code.push(processBlock(proc.post, proc, dtypes)) +- } +- +- if(proc.debug) { +- console.log("-----Generated cwise routine for ", typesig, ":\n" + code.join("\n") + "\n----------") +- } +- +- var loopName = [(proc.funcName||"unnamed"), "_cwise_loop_", orders[0].join("s"),"m",matched,typeSummary(dtypes)].join("") +- var f = new Function(["function ",loopName,"(", arglist.join(","),"){", code.join("\n"),"} return ", loopName].join("")) +- return f() +-} +-module.exports = generateCWiseOp +- +-},{"uniq":152}],60:[function(require,module,exports){ +-"use strict" +- +-// The function below is called when constructing a cwise function object, and does the following: +-// A function object is constructed which accepts as argument a compilation function and returns another function. +-// It is this other function that is eventually returned by createThunk, and this function is the one that actually +-// checks whether a certain pattern of arguments has already been used before and compiles new loops as needed. +-// The compilation passed to the first function object is used for compiling new functions. +-// Once this function object is created, it is called with compile as argument, where the first argument of compile +-// is bound to "proc" (essentially containing a preprocessed version of the user arguments to cwise). +-// So createThunk roughly works like this: +-// function createThunk(proc) { +-// var thunk = function(compileBound) { +-// var CACHED = {} +-// return function(arrays and scalars) { +-// if (dtype and order of arrays in CACHED) { +-// var func = CACHED[dtype and order of arrays] +-// } else { +-// var func = CACHED[dtype and order of arrays] = compileBound(dtype and order of arrays) +-// } +-// return func(arrays and scalars) +-// } +-// } +-// return thunk(compile.bind1(proc)) +-// } +- +-var compile = require("./compile.js") +- +-function createThunk(proc) { +- var code = ["'use strict'", "var CACHED={}"] +- var vars = [] +- var thunkName = proc.funcName + "_cwise_thunk" +- +- //Build thunk +- code.push(["return function ", thunkName, "(", proc.shimArgs.join(","), "){"].join("")) +- var typesig = [] +- var string_typesig = [] +- var proc_args = [["array",proc.arrayArgs[0],".shape.slice(", // Slice shape so that we only retain the shape over which we iterate (which gets passed to the cwise operator as SS). +- Math.max(0,proc.arrayBlockIndices[0]),proc.arrayBlockIndices[0]<0?(","+proc.arrayBlockIndices[0]+")"):")"].join("")] +- var shapeLengthConditions = [], shapeConditions = [] +- // Process array arguments +- for(var i=0; i0) { // Gather conditions to check for shape equality (ignoring block indices) +- shapeLengthConditions.push("array" + proc.arrayArgs[0] + ".shape.length===array" + j + ".shape.length+" + (Math.abs(proc.arrayBlockIndices[0])-Math.abs(proc.arrayBlockIndices[i]))) +- shapeConditions.push("array" + proc.arrayArgs[0] + ".shape[shapeIndex+" + Math.max(0,proc.arrayBlockIndices[0]) + "]===array" + j + ".shape[shapeIndex+" + Math.max(0,proc.arrayBlockIndices[i]) + "]") +- } +- } +- // Check for shape equality +- if (proc.arrayArgs.length > 1) { +- code.push("if (!(" + shapeLengthConditions.join(" && ") + ")) throw new Error('cwise: Arrays do not all have the same dimensionality!')") +- code.push("for(var shapeIndex=array" + proc.arrayArgs[0] + ".shape.length-" + Math.abs(proc.arrayBlockIndices[0]) + "; shapeIndex-->0;) {") +- code.push("if (!(" + shapeConditions.join(" && ") + ")) throw new Error('cwise: Arrays do not all have the same shape!')") +- code.push("}") +- } +- // Process scalar arguments +- for(var i=0; i b ? 1 : a >= b ? 0 : NaN; +- } +- d3.descending = function(a, b) { +- return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN; +- }; +- d3.min = function(array, f) { +- var i = -1, n = array.length, a, b; +- if (arguments.length === 1) { +- while (++i < n) if ((b = array[i]) != null && b >= b) { +- a = b; +- break; +- } +- while (++i < n) if ((b = array[i]) != null && a > b) a = b; +- } else { +- while (++i < n) if ((b = f.call(array, array[i], i)) != null && b >= b) { +- a = b; +- break; +- } +- while (++i < n) if ((b = f.call(array, array[i], i)) != null && a > b) a = b; +- } +- return a; +- }; +- d3.max = function(array, f) { +- var i = -1, n = array.length, a, b; +- if (arguments.length === 1) { +- while (++i < n) if ((b = array[i]) != null && b >= b) { +- a = b; +- break; +- } +- while (++i < n) if ((b = array[i]) != null && b > a) a = b; +- } else { +- while (++i < n) if ((b = f.call(array, array[i], i)) != null && b >= b) { +- a = b; +- break; +- } +- while (++i < n) if ((b = f.call(array, array[i], i)) != null && b > a) a = b; +- } +- return a; +- }; +- d3.extent = function(array, f) { +- var i = -1, n = array.length, a, b, c; +- if (arguments.length === 1) { +- while (++i < n) if ((b = array[i]) != null && b >= b) { +- a = c = b; +- break; +- } +- while (++i < n) if ((b = array[i]) != null) { +- if (a > b) a = b; +- if (c < b) c = b; +- } +- } else { +- while (++i < n) if ((b = f.call(array, array[i], i)) != null && b >= b) { +- a = c = b; +- break; +- } +- while (++i < n) if ((b = f.call(array, array[i], i)) != null) { +- if (a > b) a = b; +- if (c < b) c = b; +- } +- } +- return [ a, c ]; +- }; +- function d3_number(x) { +- return x === null ? NaN : +x; +- } +- function d3_numeric(x) { +- return !isNaN(x); +- } +- d3.sum = function(array, f) { +- var s = 0, n = array.length, a, i = -1; +- if (arguments.length === 1) { +- while (++i < n) if (d3_numeric(a = +array[i])) s += a; +- } else { +- while (++i < n) if (d3_numeric(a = +f.call(array, array[i], i))) s += a; +- } +- return s; +- }; +- d3.mean = function(array, f) { +- var s = 0, n = array.length, a, i = -1, j = n; +- if (arguments.length === 1) { +- while (++i < n) if (d3_numeric(a = d3_number(array[i]))) s += a; else --j; +- } else { +- while (++i < n) if (d3_numeric(a = d3_number(f.call(array, array[i], i)))) s += a; else --j; +- } +- if (j) return s / j; +- }; +- d3.quantile = function(values, p) { +- var H = (values.length - 1) * p + 1, h = Math.floor(H), v = +values[h - 1], e = H - h; +- return e ? v + e * (values[h] - v) : v; +- }; +- d3.median = function(array, f) { +- var numbers = [], n = array.length, a, i = -1; +- if (arguments.length === 1) { +- while (++i < n) if (d3_numeric(a = d3_number(array[i]))) numbers.push(a); +- } else { +- while (++i < n) if (d3_numeric(a = d3_number(f.call(array, array[i], i)))) numbers.push(a); +- } +- if (numbers.length) return d3.quantile(numbers.sort(d3_ascending), .5); +- }; +- d3.variance = function(array, f) { +- var n = array.length, m = 0, a, d, s = 0, i = -1, j = 0; +- if (arguments.length === 1) { +- while (++i < n) { +- if (d3_numeric(a = d3_number(array[i]))) { +- d = a - m; +- m += d / ++j; +- s += d * (a - m); +- } +- } +- } else { +- while (++i < n) { +- if (d3_numeric(a = d3_number(f.call(array, array[i], i)))) { +- d = a - m; +- m += d / ++j; +- s += d * (a - m); +- } +- } +- } +- if (j > 1) return s / (j - 1); +- }; +- d3.deviation = function() { +- var v = d3.variance.apply(this, arguments); +- return v ? Math.sqrt(v) : v; +- }; +- function d3_bisector(compare) { +- return { +- left: function(a, x, lo, hi) { +- if (arguments.length < 3) lo = 0; +- if (arguments.length < 4) hi = a.length; +- while (lo < hi) { +- var mid = lo + hi >>> 1; +- if (compare(a[mid], x) < 0) lo = mid + 1; else hi = mid; +- } +- return lo; +- }, +- right: function(a, x, lo, hi) { +- if (arguments.length < 3) lo = 0; +- if (arguments.length < 4) hi = a.length; +- while (lo < hi) { +- var mid = lo + hi >>> 1; +- if (compare(a[mid], x) > 0) hi = mid; else lo = mid + 1; +- } +- return lo; +- } +- }; +- } +- var d3_bisect = d3_bisector(d3_ascending); +- d3.bisectLeft = d3_bisect.left; +- d3.bisect = d3.bisectRight = d3_bisect.right; +- d3.bisector = function(f) { +- return d3_bisector(f.length === 1 ? function(d, x) { +- return d3_ascending(f(d), x); +- } : f); +- }; +- d3.shuffle = function(array, i0, i1) { +- if ((m = arguments.length) < 3) { +- i1 = array.length; +- if (m < 2) i0 = 0; +- } +- var m = i1 - i0, t, i; +- while (m) { +- i = Math.random() * m-- | 0; +- t = array[m + i0], array[m + i0] = array[i + i0], array[i + i0] = t; +- } +- return array; +- }; +- d3.permute = function(array, indexes) { +- var i = indexes.length, permutes = new Array(i); +- while (i--) permutes[i] = array[indexes[i]]; +- return permutes; +- }; +- d3.pairs = function(array) { +- var i = 0, n = array.length - 1, p0, p1 = array[0], pairs = new Array(n < 0 ? 0 : n); +- while (i < n) pairs[i] = [ p0 = p1, p1 = array[++i] ]; +- return pairs; +- }; +- d3.transpose = function(matrix) { +- if (!(n = matrix.length)) return []; +- for (var i = -1, m = d3.min(matrix, d3_transposeLength), transpose = new Array(m); ++i < m; ) { +- for (var j = -1, n, row = transpose[i] = new Array(n); ++j < n; ) { +- row[j] = matrix[j][i]; +- } +- } +- return transpose; +- }; +- function d3_transposeLength(d) { +- return d.length; +- } +- d3.zip = function() { +- return d3.transpose(arguments); +- }; +- d3.keys = function(map) { +- var keys = []; +- for (var key in map) keys.push(key); +- return keys; +- }; +- d3.values = function(map) { +- var values = []; +- for (var key in map) values.push(map[key]); +- return values; +- }; +- d3.entries = function(map) { +- var entries = []; +- for (var key in map) entries.push({ +- key: key, +- value: map[key] +- }); +- return entries; +- }; +- d3.merge = function(arrays) { +- var n = arrays.length, m, i = -1, j = 0, merged, array; +- while (++i < n) j += arrays[i].length; +- merged = new Array(j); +- while (--n >= 0) { +- array = arrays[n]; +- m = array.length; +- while (--m >= 0) { +- merged[--j] = array[m]; +- } +- } +- return merged; +- }; +- var abs = Math.abs; +- d3.range = function(start, stop, step) { +- if (arguments.length < 3) { +- step = 1; +- if (arguments.length < 2) { +- stop = start; +- start = 0; +- } +- } +- if ((stop - start) / step === Infinity) throw new Error("infinite range"); +- var range = [], k = d3_range_integerScale(abs(step)), i = -1, j; +- start *= k, stop *= k, step *= k; +- if (step < 0) while ((j = start + step * ++i) > stop) range.push(j / k); else while ((j = start + step * ++i) < stop) range.push(j / k); +- return range; +- }; +- function d3_range_integerScale(x) { +- var k = 1; +- while (x * k % 1) k *= 10; +- return k; +- } +- function d3_class(ctor, properties) { +- for (var key in properties) { +- Object.defineProperty(ctor.prototype, key, { +- value: properties[key], +- enumerable: false +- }); +- } +- } +- d3.map = function(object, f) { +- var map = new d3_Map(); +- if (object instanceof d3_Map) { +- object.forEach(function(key, value) { +- map.set(key, value); +- }); +- } else if (Array.isArray(object)) { +- var i = -1, n = object.length, o; +- if (arguments.length === 1) while (++i < n) map.set(i, object[i]); else while (++i < n) map.set(f.call(object, o = object[i], i), o); +- } else { +- for (var key in object) map.set(key, object[key]); +- } +- return map; +- }; +- function d3_Map() { +- this._ = Object.create(null); +- } +- var d3_map_proto = "__proto__", d3_map_zero = "\x00"; +- d3_class(d3_Map, { +- has: d3_map_has, +- get: function(key) { +- return this._[d3_map_escape(key)]; +- }, +- set: function(key, value) { +- return this._[d3_map_escape(key)] = value; +- }, +- remove: d3_map_remove, +- keys: d3_map_keys, +- values: function() { +- var values = []; +- for (var key in this._) values.push(this._[key]); +- return values; +- }, +- entries: function() { +- var entries = []; +- for (var key in this._) entries.push({ +- key: d3_map_unescape(key), +- value: this._[key] +- }); +- return entries; +- }, +- size: d3_map_size, +- empty: d3_map_empty, +- forEach: function(f) { +- for (var key in this._) f.call(this, d3_map_unescape(key), this._[key]); +- } +- }); +- function d3_map_escape(key) { +- return (key += "") === d3_map_proto || key[0] === d3_map_zero ? d3_map_zero + key : key; +- } +- function d3_map_unescape(key) { +- return (key += "")[0] === d3_map_zero ? key.slice(1) : key; +- } +- function d3_map_has(key) { +- return d3_map_escape(key) in this._; +- } +- function d3_map_remove(key) { +- return (key = d3_map_escape(key)) in this._ && delete this._[key]; +- } +- function d3_map_keys() { +- var keys = []; +- for (var key in this._) keys.push(d3_map_unescape(key)); +- return keys; +- } +- function d3_map_size() { +- var size = 0; +- for (var key in this._) ++size; +- return size; +- } +- function d3_map_empty() { +- for (var key in this._) return false; +- return true; +- } +- d3.nest = function() { +- var nest = {}, keys = [], sortKeys = [], sortValues, rollup; +- function map(mapType, array, depth) { +- if (depth >= keys.length) return rollup ? rollup.call(nest, array) : sortValues ? array.sort(sortValues) : array; +- var i = -1, n = array.length, key = keys[depth++], keyValue, object, setter, valuesByKey = new d3_Map(), values; +- while (++i < n) { +- if (values = valuesByKey.get(keyValue = key(object = array[i]))) { +- values.push(object); +- } else { +- valuesByKey.set(keyValue, [ object ]); +- } +- } +- if (mapType) { +- object = mapType(); +- setter = function(keyValue, values) { +- object.set(keyValue, map(mapType, values, depth)); +- }; +- } else { +- object = {}; +- setter = function(keyValue, values) { +- object[keyValue] = map(mapType, values, depth); +- }; +- } +- valuesByKey.forEach(setter); +- return object; +- } +- function entries(map, depth) { +- if (depth >= keys.length) return map; +- var array = [], sortKey = sortKeys[depth++]; +- map.forEach(function(key, keyMap) { +- array.push({ +- key: key, +- values: entries(keyMap, depth) +- }); +- }); +- return sortKey ? array.sort(function(a, b) { +- return sortKey(a.key, b.key); +- }) : array; +- } +- nest.map = function(array, mapType) { +- return map(mapType, array, 0); +- }; +- nest.entries = function(array) { +- return entries(map(d3.map, array, 0), 0); +- }; +- nest.key = function(d) { +- keys.push(d); +- return nest; +- }; +- nest.sortKeys = function(order) { +- sortKeys[keys.length - 1] = order; +- return nest; +- }; +- nest.sortValues = function(order) { +- sortValues = order; +- return nest; +- }; +- nest.rollup = function(f) { +- rollup = f; +- return nest; +- }; +- return nest; +- }; +- d3.set = function(array) { +- var set = new d3_Set(); +- if (array) for (var i = 0, n = array.length; i < n; ++i) set.add(array[i]); +- return set; +- }; +- function d3_Set() { +- this._ = Object.create(null); +- } +- d3_class(d3_Set, { +- has: d3_map_has, +- add: function(key) { +- this._[d3_map_escape(key += "")] = true; +- return key; +- }, +- remove: d3_map_remove, +- values: d3_map_keys, +- size: d3_map_size, +- empty: d3_map_empty, +- forEach: function(f) { +- for (var key in this._) f.call(this, d3_map_unescape(key)); +- } +- }); +- d3.behavior = {}; +- function d3_identity(d) { +- return d; +- } +- d3.rebind = function(target, source) { +- var i = 1, n = arguments.length, method; +- while (++i < n) target[method = arguments[i]] = d3_rebind(target, source, source[method]); +- return target; +- }; +- function d3_rebind(target, source, method) { +- return function() { +- var value = method.apply(source, arguments); +- return value === source ? target : value; +- }; +- } +- function d3_vendorSymbol(object, name) { +- if (name in object) return name; +- name = name.charAt(0).toUpperCase() + name.slice(1); +- for (var i = 0, n = d3_vendorPrefixes.length; i < n; ++i) { +- var prefixName = d3_vendorPrefixes[i] + name; +- if (prefixName in object) return prefixName; +- } +- } +- var d3_vendorPrefixes = [ "webkit", "ms", "moz", "Moz", "o", "O" ]; +- function d3_noop() {} +- d3.dispatch = function() { +- var dispatch = new d3_dispatch(), i = -1, n = arguments.length; +- while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch); +- return dispatch; +- }; +- function d3_dispatch() {} +- d3_dispatch.prototype.on = function(type, listener) { +- var i = type.indexOf("."), name = ""; +- if (i >= 0) { +- name = type.slice(i + 1); +- type = type.slice(0, i); +- } +- if (type) return arguments.length < 2 ? this[type].on(name) : this[type].on(name, listener); +- if (arguments.length === 2) { +- if (listener == null) for (type in this) { +- if (this.hasOwnProperty(type)) this[type].on(name, null); +- } +- return this; +- } +- }; +- function d3_dispatch_event(dispatch) { +- var listeners = [], listenerByName = new d3_Map(); +- function event() { +- var z = listeners, i = -1, n = z.length, l; +- while (++i < n) if (l = z[i].on) l.apply(this, arguments); +- return dispatch; +- } +- event.on = function(name, listener) { +- var l = listenerByName.get(name), i; +- if (arguments.length < 2) return l && l.on; +- if (l) { +- l.on = null; +- listeners = listeners.slice(0, i = listeners.indexOf(l)).concat(listeners.slice(i + 1)); +- listenerByName.remove(name); +- } +- if (listener) listeners.push(listenerByName.set(name, { +- on: listener +- })); +- return dispatch; +- }; +- return event; +- } +- d3.event = null; +- function d3_eventPreventDefault() { +- d3.event.preventDefault(); +- } +- function d3_eventSource() { +- var e = d3.event, s; +- while (s = e.sourceEvent) e = s; +- return e; +- } +- function d3_eventDispatch(target) { +- var dispatch = new d3_dispatch(), i = 0, n = arguments.length; +- while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch); +- dispatch.of = function(thiz, argumentz) { +- return function(e1) { +- try { +- var e0 = e1.sourceEvent = d3.event; +- e1.target = target; +- d3.event = e1; +- dispatch[e1.type].apply(thiz, argumentz); +- } finally { +- d3.event = e0; +- } +- }; +- }; +- return dispatch; +- } +- d3.requote = function(s) { +- return s.replace(d3_requote_re, "\\$&"); +- }; +- var d3_requote_re = /[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g; +- var d3_subclass = {}.__proto__ ? function(object, prototype) { +- object.__proto__ = prototype; +- } : function(object, prototype) { +- for (var property in prototype) object[property] = prototype[property]; +- }; +- function d3_selection(groups) { +- d3_subclass(groups, d3_selectionPrototype); +- return groups; +- } +- var d3_select = function(s, n) { +- return n.querySelector(s); +- }, d3_selectAll = function(s, n) { +- return n.querySelectorAll(s); +- }, d3_selectMatches = function(n, s) { +- var d3_selectMatcher = n.matches || n[d3_vendorSymbol(n, "matchesSelector")]; +- d3_selectMatches = function(n, s) { +- return d3_selectMatcher.call(n, s); +- }; +- return d3_selectMatches(n, s); +- }; +- if (typeof Sizzle === "function") { +- d3_select = function(s, n) { +- return Sizzle(s, n)[0] || null; +- }; +- d3_selectAll = Sizzle; +- d3_selectMatches = Sizzle.matchesSelector; +- } +- d3.selection = function() { +- return d3.select(d3_document.documentElement); +- }; +- var d3_selectionPrototype = d3.selection.prototype = []; +- d3_selectionPrototype.select = function(selector) { +- var subgroups = [], subgroup, subnode, group, node; +- selector = d3_selection_selector(selector); +- for (var j = -1, m = this.length; ++j < m; ) { +- subgroups.push(subgroup = []); +- subgroup.parentNode = (group = this[j]).parentNode; +- for (var i = -1, n = group.length; ++i < n; ) { +- if (node = group[i]) { +- subgroup.push(subnode = selector.call(node, node.__data__, i, j)); +- if (subnode && "__data__" in node) subnode.__data__ = node.__data__; +- } else { +- subgroup.push(null); +- } +- } +- } +- return d3_selection(subgroups); +- }; +- function d3_selection_selector(selector) { +- return typeof selector === "function" ? selector : function() { +- return d3_select(selector, this); +- }; +- } +- d3_selectionPrototype.selectAll = function(selector) { +- var subgroups = [], subgroup, node; +- selector = d3_selection_selectorAll(selector); +- for (var j = -1, m = this.length; ++j < m; ) { +- for (var group = this[j], i = -1, n = group.length; ++i < n; ) { +- if (node = group[i]) { +- subgroups.push(subgroup = d3_array(selector.call(node, node.__data__, i, j))); +- subgroup.parentNode = node; +- } +- } +- } +- return d3_selection(subgroups); +- }; +- function d3_selection_selectorAll(selector) { +- return typeof selector === "function" ? selector : function() { +- return d3_selectAll(selector, this); +- }; +- } +- var d3_nsXhtml = "http://www.w3.org/1999/xhtml"; +- var d3_nsPrefix = { +- svg: "http://www.w3.org/2000/svg", +- xhtml: d3_nsXhtml, +- xlink: "http://www.w3.org/1999/xlink", +- xml: "http://www.w3.org/XML/1998/namespace", +- xmlns: "http://www.w3.org/2000/xmlns/" +- }; +- d3.ns = { +- prefix: d3_nsPrefix, +- qualify: function(name) { +- var i = name.indexOf(":"), prefix = name; +- if (i >= 0 && (prefix = name.slice(0, i)) !== "xmlns") name = name.slice(i + 1); +- return d3_nsPrefix.hasOwnProperty(prefix) ? { +- space: d3_nsPrefix[prefix], +- local: name +- } : name; +- } +- }; +- d3_selectionPrototype.attr = function(name, value) { +- if (arguments.length < 2) { +- if (typeof name === "string") { +- var node = this.node(); +- name = d3.ns.qualify(name); +- return name.local ? node.getAttributeNS(name.space, name.local) : node.getAttribute(name); +- } +- for (value in name) this.each(d3_selection_attr(value, name[value])); +- return this; +- } +- return this.each(d3_selection_attr(name, value)); +- }; +- function d3_selection_attr(name, value) { +- name = d3.ns.qualify(name); +- function attrNull() { +- this.removeAttribute(name); +- } +- function attrNullNS() { +- this.removeAttributeNS(name.space, name.local); +- } +- function attrConstant() { +- this.setAttribute(name, value); +- } +- function attrConstantNS() { +- this.setAttributeNS(name.space, name.local, value); +- } +- function attrFunction() { +- var x = value.apply(this, arguments); +- if (x == null) this.removeAttribute(name); else this.setAttribute(name, x); +- } +- function attrFunctionNS() { +- var x = value.apply(this, arguments); +- if (x == null) this.removeAttributeNS(name.space, name.local); else this.setAttributeNS(name.space, name.local, x); +- } +- return value == null ? name.local ? attrNullNS : attrNull : typeof value === "function" ? name.local ? attrFunctionNS : attrFunction : name.local ? attrConstantNS : attrConstant; +- } +- function d3_collapse(s) { +- return s.trim().replace(/\s+/g, " "); +- } +- d3_selectionPrototype.classed = function(name, value) { +- if (arguments.length < 2) { +- if (typeof name === "string") { +- var node = this.node(), n = (name = d3_selection_classes(name)).length, i = -1; +- if (value = node.classList) { +- while (++i < n) if (!value.contains(name[i])) return false; +- } else { +- value = node.getAttribute("class"); +- while (++i < n) if (!d3_selection_classedRe(name[i]).test(value)) return false; +- } +- return true; +- } +- for (value in name) this.each(d3_selection_classed(value, name[value])); +- return this; +- } +- return this.each(d3_selection_classed(name, value)); +- }; +- function d3_selection_classedRe(name) { +- return new RegExp("(?:^|\\s+)" + d3.requote(name) + "(?:\\s+|$)", "g"); +- } +- function d3_selection_classes(name) { +- return (name + "").trim().split(/^|\s+/); +- } +- function d3_selection_classed(name, value) { +- name = d3_selection_classes(name).map(d3_selection_classedName); +- var n = name.length; +- function classedConstant() { +- var i = -1; +- while (++i < n) name[i](this, value); +- } +- function classedFunction() { +- var i = -1, x = value.apply(this, arguments); +- while (++i < n) name[i](this, x); +- } +- return typeof value === "function" ? classedFunction : classedConstant; +- } +- function d3_selection_classedName(name) { +- var re = d3_selection_classedRe(name); +- return function(node, value) { +- if (c = node.classList) return value ? c.add(name) : c.remove(name); +- var c = node.getAttribute("class") || ""; +- if (value) { +- re.lastIndex = 0; +- if (!re.test(c)) node.setAttribute("class", d3_collapse(c + " " + name)); +- } else { +- node.setAttribute("class", d3_collapse(c.replace(re, " "))); +- } +- }; +- } +- d3_selectionPrototype.style = function(name, value, priority) { +- var n = arguments.length; +- if (n < 3) { +- if (typeof name !== "string") { +- if (n < 2) value = ""; +- for (priority in name) this.each(d3_selection_style(priority, name[priority], value)); +- return this; +- } +- if (n < 2) { +- var node = this.node(); +- return d3_window(node).getComputedStyle(node, null).getPropertyValue(name); +- } +- priority = ""; +- } +- return this.each(d3_selection_style(name, value, priority)); +- }; +- function d3_selection_style(name, value, priority) { +- function styleNull() { +- this.style.removeProperty(name); +- } +- function styleConstant() { +- this.style.setProperty(name, value, priority); +- } +- function styleFunction() { +- var x = value.apply(this, arguments); +- if (x == null) this.style.removeProperty(name); else this.style.setProperty(name, x, priority); +- } +- return value == null ? styleNull : typeof value === "function" ? styleFunction : styleConstant; +- } +- d3_selectionPrototype.property = function(name, value) { +- if (arguments.length < 2) { +- if (typeof name === "string") return this.node()[name]; +- for (value in name) this.each(d3_selection_property(value, name[value])); +- return this; +- } +- return this.each(d3_selection_property(name, value)); +- }; +- function d3_selection_property(name, value) { +- function propertyNull() { +- delete this[name]; +- } +- function propertyConstant() { +- this[name] = value; +- } +- function propertyFunction() { +- var x = value.apply(this, arguments); +- if (x == null) delete this[name]; else this[name] = x; +- } +- return value == null ? propertyNull : typeof value === "function" ? propertyFunction : propertyConstant; +- } +- d3_selectionPrototype.text = function(value) { +- return arguments.length ? this.each(typeof value === "function" ? function() { +- var v = value.apply(this, arguments); +- this.textContent = v == null ? "" : v; +- } : value == null ? function() { +- this.textContent = ""; +- } : function() { +- this.textContent = value; +- }) : this.node().textContent; +- }; +- d3_selectionPrototype.html = function(value) { +- return arguments.length ? this.each(typeof value === "function" ? function() { +- var v = value.apply(this, arguments); +- this.innerHTML = v == null ? "" : v; +- } : value == null ? function() { +- this.innerHTML = ""; +- } : function() { +- this.innerHTML = value; +- }) : this.node().innerHTML; +- }; +- d3_selectionPrototype.append = function(name) { +- name = d3_selection_creator(name); +- return this.select(function() { +- return this.appendChild(name.apply(this, arguments)); +- }); +- }; +- function d3_selection_creator(name) { +- function create() { +- var document = this.ownerDocument, namespace = this.namespaceURI; +- return namespace === d3_nsXhtml && document.documentElement.namespaceURI === d3_nsXhtml ? document.createElement(name) : document.createElementNS(namespace, name); +- } +- function createNS() { +- return this.ownerDocument.createElementNS(name.space, name.local); +- } +- return typeof name === "function" ? name : (name = d3.ns.qualify(name)).local ? createNS : create; +- } +- d3_selectionPrototype.insert = function(name, before) { +- name = d3_selection_creator(name); +- before = d3_selection_selector(before); +- return this.select(function() { +- return this.insertBefore(name.apply(this, arguments), before.apply(this, arguments) || null); +- }); +- }; +- d3_selectionPrototype.remove = function() { +- return this.each(d3_selectionRemove); +- }; +- function d3_selectionRemove() { +- var parent = this.parentNode; +- if (parent) parent.removeChild(this); +- } +- d3_selectionPrototype.data = function(value, key) { +- var i = -1, n = this.length, group, node; +- if (!arguments.length) { +- value = new Array(n = (group = this[0]).length); +- while (++i < n) { +- if (node = group[i]) { +- value[i] = node.__data__; +- } +- } +- return value; +- } +- function bind(group, groupData) { +- var i, n = group.length, m = groupData.length, n0 = Math.min(n, m), updateNodes = new Array(m), enterNodes = new Array(m), exitNodes = new Array(n), node, nodeData; +- if (key) { +- var nodeByKeyValue = new d3_Map(), keyValues = new Array(n), keyValue; +- for (i = -1; ++i < n; ) { +- if (node = group[i]) { +- if (nodeByKeyValue.has(keyValue = key.call(node, node.__data__, i))) { +- exitNodes[i] = node; +- } else { +- nodeByKeyValue.set(keyValue, node); +- } +- keyValues[i] = keyValue; +- } +- } +- for (i = -1; ++i < m; ) { +- if (!(node = nodeByKeyValue.get(keyValue = key.call(groupData, nodeData = groupData[i], i)))) { +- enterNodes[i] = d3_selection_dataNode(nodeData); +- } else if (node !== true) { +- updateNodes[i] = node; +- node.__data__ = nodeData; +- } +- nodeByKeyValue.set(keyValue, true); +- } +- for (i = -1; ++i < n; ) { +- if (i in keyValues && nodeByKeyValue.get(keyValues[i]) !== true) { +- exitNodes[i] = group[i]; +- } +- } +- } else { +- for (i = -1; ++i < n0; ) { +- node = group[i]; +- nodeData = groupData[i]; +- if (node) { +- node.__data__ = nodeData; +- updateNodes[i] = node; +- } else { +- enterNodes[i] = d3_selection_dataNode(nodeData); +- } +- } +- for (;i < m; ++i) { +- enterNodes[i] = d3_selection_dataNode(groupData[i]); +- } +- for (;i < n; ++i) { +- exitNodes[i] = group[i]; +- } +- } +- enterNodes.update = updateNodes; +- enterNodes.parentNode = updateNodes.parentNode = exitNodes.parentNode = group.parentNode; +- enter.push(enterNodes); +- update.push(updateNodes); +- exit.push(exitNodes); +- } +- var enter = d3_selection_enter([]), update = d3_selection([]), exit = d3_selection([]); +- if (typeof value === "function") { +- while (++i < n) { +- bind(group = this[i], value.call(group, group.parentNode.__data__, i)); +- } +- } else { +- while (++i < n) { +- bind(group = this[i], value); +- } +- } +- update.enter = function() { +- return enter; +- }; +- update.exit = function() { +- return exit; +- }; +- return update; +- }; +- function d3_selection_dataNode(data) { +- return { +- __data__: data +- }; ++ return value; ++ } ++ function bind(group, groupData) { ++ var i, n = group.length, m = groupData.length, n0 = Math.min(n, m), updateNodes = new Array(m), enterNodes = new Array(m), exitNodes = new Array(n), node, nodeData; ++ if (key) { ++ var nodeByKeyValue = new d3_Map(), keyValues = new Array(n), keyValue; ++ for (i = -1; ++i < n; ) { ++ if (node = group[i]) { ++ if (nodeByKeyValue.has(keyValue = key.call(node, node.__data__, i))) { ++ exitNodes[i] = node; ++ } else { ++ nodeByKeyValue.set(keyValue, node); ++ } ++ keyValues[i] = keyValue; ++ } ++ } ++ for (i = -1; ++i < m; ) { ++ if (!(node = nodeByKeyValue.get(keyValue = key.call(groupData, nodeData = groupData[i], i)))) { ++ enterNodes[i] = d3_selection_dataNode(nodeData); ++ } else if (node !== true) { ++ updateNodes[i] = node; ++ node.__data__ = nodeData; ++ } ++ nodeByKeyValue.set(keyValue, true); ++ } ++ for (i = -1; ++i < n; ) { ++ if (i in keyValues && nodeByKeyValue.get(keyValues[i]) !== true) { ++ exitNodes[i] = group[i]; ++ } ++ } ++ } else { ++ for (i = -1; ++i < n0; ) { ++ node = group[i]; ++ nodeData = groupData[i]; ++ if (node) { ++ node.__data__ = nodeData; ++ updateNodes[i] = node; ++ } else { ++ enterNodes[i] = d3_selection_dataNode(nodeData); ++ } ++ } ++ for (;i < m; ++i) { ++ enterNodes[i] = d3_selection_dataNode(groupData[i]); ++ } ++ for (;i < n; ++i) { ++ exitNodes[i] = group[i]; ++ } ++ } ++ enterNodes.update = updateNodes; ++ enterNodes.parentNode = updateNodes.parentNode = exitNodes.parentNode = group.parentNode; ++ enter.push(enterNodes); ++ update.push(updateNodes); ++ exit.push(exitNodes); ++ } ++ var enter = d3_selection_enter([]), update = d3_selection([]), exit = d3_selection([]); ++ if (typeof value === "function") { ++ while (++i < n) { ++ bind(group = this[i], value.call(group, group.parentNode.__data__, i)); ++ } ++ } else { ++ while (++i < n) { ++ bind(group = this[i], value); ++ } ++ } ++ update.enter = function() { ++ return enter; ++ }; ++ update.exit = function() { ++ return exit; ++ }; ++ return update; ++ }; ++ function d3_selection_dataNode(data) { ++ return { ++ __data__: data ++ }; + } + d3_selectionPrototype.datum = function(value) { + return arguments.length ? this.property("__data__", value) : this.property("__data__"); +@@ -12730,7 +12253,7 @@ module.exports = require("cwise-compiler") + λ0 = λ, sinφ0 = sinφ, cosφ0 = cosφ, point0 = point; + } + } +- return (polarAngle < -ε || polarAngle < ε && d3_geo_areaRingSum < 0) ^ winding & 1; ++ return (polarAngle < -ε || polarAngle < ε && d3_geo_areaRingSum < -ε) ^ winding & 1; + } + function d3_geo_clipCircle(radius) { + var cr = Math.cos(radius), smallRadius = cr > 0, notHemisphere = abs(cr) > ε, interpolate = d3_geo_circleInterpolate(radius, 6 * d3_radians); +@@ -18757,7 +18280,111 @@ module.exports = require("cwise-compiler") + }); + if (typeof define === "function" && define.amd) this.d3 = d3, define(d3); else if (typeof module === "object" && module.exports) module.exports = d3; else this.d3 = d3; + }(); +-},{}],63:[function(require,module,exports){ ++},{}],55:[function(require,module,exports){ ++(function (Buffer){ ++var hasTypedArrays = false ++if(typeof Float64Array !== "undefined") { ++ var DOUBLE_VIEW = new Float64Array(1) ++ , UINT_VIEW = new Uint32Array(DOUBLE_VIEW.buffer) ++ DOUBLE_VIEW[0] = 1.0 ++ hasTypedArrays = true ++ if(UINT_VIEW[1] === 0x3ff00000) { ++ //Use little endian ++ module.exports = function doubleBitsLE(n) { ++ DOUBLE_VIEW[0] = n ++ return [ UINT_VIEW[0], UINT_VIEW[1] ] ++ } ++ function toDoubleLE(lo, hi) { ++ UINT_VIEW[0] = lo ++ UINT_VIEW[1] = hi ++ return DOUBLE_VIEW[0] ++ } ++ module.exports.pack = toDoubleLE ++ function lowUintLE(n) { ++ DOUBLE_VIEW[0] = n ++ return UINT_VIEW[0] ++ } ++ module.exports.lo = lowUintLE ++ function highUintLE(n) { ++ DOUBLE_VIEW[0] = n ++ return UINT_VIEW[1] ++ } ++ module.exports.hi = highUintLE ++ } else if(UINT_VIEW[0] === 0x3ff00000) { ++ //Use big endian ++ module.exports = function doubleBitsBE(n) { ++ DOUBLE_VIEW[0] = n ++ return [ UINT_VIEW[1], UINT_VIEW[0] ] ++ } ++ function toDoubleBE(lo, hi) { ++ UINT_VIEW[1] = lo ++ UINT_VIEW[0] = hi ++ return DOUBLE_VIEW[0] ++ } ++ module.exports.pack = toDoubleBE ++ function lowUintBE(n) { ++ DOUBLE_VIEW[0] = n ++ return UINT_VIEW[1] ++ } ++ module.exports.lo = lowUintBE ++ function highUintBE(n) { ++ DOUBLE_VIEW[0] = n ++ return UINT_VIEW[0] ++ } ++ module.exports.hi = highUintBE ++ } else { ++ hasTypedArrays = false ++ } ++} ++if(!hasTypedArrays) { ++ var buffer = new Buffer(8) ++ module.exports = function doubleBits(n) { ++ buffer.writeDoubleLE(n, 0, true) ++ return [ buffer.readUInt32LE(0, true), buffer.readUInt32LE(4, true) ] ++ } ++ function toDouble(lo, hi) { ++ buffer.writeUInt32LE(lo, 0, true) ++ buffer.writeUInt32LE(hi, 4, true) ++ return buffer.readDoubleLE(0, true) ++ } ++ module.exports.pack = toDouble ++ function lowUint(n) { ++ buffer.writeDoubleLE(n, 0, true) ++ return buffer.readUInt32LE(0, true) ++ } ++ module.exports.lo = lowUint ++ function highUint(n) { ++ buffer.writeDoubleLE(n, 0, true) ++ return buffer.readUInt32LE(4, true) ++ } ++ module.exports.hi = highUint ++} ++ ++module.exports.sign = function(n) { ++ return module.exports.hi(n) >>> 31 ++} ++ ++module.exports.exponent = function(n) { ++ var b = module.exports.hi(n) ++ return ((b<<1) >>> 21) - 1023 ++} ++ ++module.exports.fraction = function(n) { ++ var lo = module.exports.lo(n) ++ var hi = module.exports.hi(n) ++ var b = hi & ((1<<20) - 1) ++ if(hi & 0x7ff00000) { ++ b += (1<<20) ++ } ++ return [lo, b] ++} ++ ++module.exports.denormalized = function(n) { ++ var hi = module.exports.hi(n) ++ return !(hi & 0x7ff00000) ++} ++}).call(this,require("buffer").Buffer) ++},{"buffer":37}],56:[function(require,module,exports){ + "use strict" + + function dupe_array(count, value, i) { +@@ -18807,10941 +18434,11163 @@ function dupe(count, value) { + } + + module.exports = dupe +-},{}],64:[function(require,module,exports){ ++},{}],57:[function(require,module,exports){ ++"use strict" ++ ++module.exports = edgeToAdjacency ++ ++var uniq = require("uniq") ++ ++function edgeToAdjacency(edges, numVertices) { ++ var numEdges = edges.length ++ if(typeof numVertices !== "number") { ++ numVertices = 0 ++ for(var i=0; i postsJSON +- values[1] // => commentsJSON ++function handleOwnThenable(promise, thenable) { ++ if (thenable._state === FULFILLED) { ++ fulfill(promise, thenable._result); ++ } else if (thenable._state === REJECTED) { ++ _reject(promise, thenable._result); ++ } else { ++ subscribe(thenable, undefined, function (value) { ++ return _resolve(promise, value); ++ }, function (reason) { ++ return _reject(promise, reason); ++ }); ++ } ++} + +- return values; +- }); +- ``` +- +- @class Promise +- @param {function} resolver +- Useful for tooling. +- @constructor +- */ +- function lib$es6$promise$promise$$Promise(resolver) { +- this._id = lib$es6$promise$promise$$counter++; +- this._state = undefined; +- this._result = undefined; +- this._subscribers = []; +- +- if (lib$es6$promise$$internal$$noop !== resolver) { +- typeof resolver !== 'function' && lib$es6$promise$promise$$needsResolver(); +- this instanceof lib$es6$promise$promise$$Promise ? lib$es6$promise$$internal$$initializePromise(this, resolver) : lib$es6$promise$promise$$needsNew(); +- } ++function handleMaybeThenable(promise, maybeThenable, then$$) { ++ if (maybeThenable.constructor === promise.constructor && then$$ === then && maybeThenable.constructor.resolve === resolve) { ++ handleOwnThenable(promise, maybeThenable); ++ } else { ++ if (then$$ === GET_THEN_ERROR) { ++ _reject(promise, GET_THEN_ERROR.error); ++ } else if (then$$ === undefined) { ++ fulfill(promise, maybeThenable); ++ } else if (isFunction(then$$)) { ++ handleForeignThenable(promise, maybeThenable, then$$); ++ } else { ++ fulfill(promise, maybeThenable); + } ++ } ++} + +- lib$es6$promise$promise$$Promise.all = lib$es6$promise$promise$all$$default; +- lib$es6$promise$promise$$Promise.race = lib$es6$promise$promise$race$$default; +- lib$es6$promise$promise$$Promise.resolve = lib$es6$promise$promise$resolve$$default; +- lib$es6$promise$promise$$Promise.reject = lib$es6$promise$promise$reject$$default; +- lib$es6$promise$promise$$Promise._setScheduler = lib$es6$promise$asap$$setScheduler; +- lib$es6$promise$promise$$Promise._setAsap = lib$es6$promise$asap$$setAsap; +- lib$es6$promise$promise$$Promise._asap = lib$es6$promise$asap$$asap; +- +- lib$es6$promise$promise$$Promise.prototype = { +- constructor: lib$es6$promise$promise$$Promise, +- +- /** +- The primary way of interacting with a promise is through its `then` method, +- which registers callbacks to receive either a promise's eventual value or the +- reason why the promise cannot be fulfilled. +- +- ```js +- findUser().then(function(user){ +- // user is available +- }, function(reason){ +- // user is unavailable, and you are given the reason why +- }); +- ``` +- +- Chaining +- -------- +- +- The return value of `then` is itself a promise. This second, 'downstream' +- promise is resolved with the return value of the first promise's fulfillment +- or rejection handler, or rejected if the handler throws an exception. +- +- ```js +- findUser().then(function (user) { +- return user.name; +- }, function (reason) { +- return 'default name'; +- }).then(function (userName) { +- // If `findUser` fulfilled, `userName` will be the user's name, otherwise it +- // will be `'default name'` +- }); +- +- findUser().then(function (user) { +- throw new Error('Found user, but still unhappy'); +- }, function (reason) { +- throw new Error('`findUser` rejected and we're unhappy'); +- }).then(function (value) { +- // never reached +- }, function (reason) { +- // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'. +- // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'. +- }); +- ``` +- If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream. +- +- ```js +- findUser().then(function (user) { +- throw new PedagogicalException('Upstream error'); +- }).then(function (value) { +- // never reached +- }).then(function (value) { +- // never reached +- }, function (reason) { +- // The `PedgagocialException` is propagated all the way down to here +- }); +- ``` +- +- Assimilation +- ------------ +- +- Sometimes the value you want to propagate to a downstream promise can only be +- retrieved asynchronously. This can be achieved by returning a promise in the +- fulfillment or rejection handler. The downstream promise will then be pending +- until the returned promise is settled. This is called *assimilation*. +- +- ```js +- findUser().then(function (user) { +- return findCommentsByAuthor(user); +- }).then(function (comments) { +- // The user's comments are now available +- }); +- ``` +- +- If the assimliated promise rejects, then the downstream promise will also reject. +- +- ```js +- findUser().then(function (user) { +- return findCommentsByAuthor(user); +- }).then(function (comments) { +- // If `findCommentsByAuthor` fulfills, we'll have the value here +- }, function (reason) { +- // If `findCommentsByAuthor` rejects, we'll have the reason here +- }); +- ``` +- +- Simple Example +- -------------- +- +- Synchronous Example +- +- ```javascript +- var result; +- +- try { +- result = findResult(); +- // success +- } catch(reason) { +- // failure +- } +- ``` ++function _resolve(promise, value) { ++ if (promise === value) { ++ _reject(promise, selfFulfillment()); ++ } else if (objectOrFunction(value)) { ++ handleMaybeThenable(promise, value, getThen(value)); ++ } else { ++ fulfill(promise, value); ++ } ++} + +- Errback Example ++function publishRejection(promise) { ++ if (promise._onerror) { ++ promise._onerror(promise._result); ++ } + +- ```js +- findResult(function(result, err){ +- if (err) { +- // failure +- } else { +- // success +- } +- }); +- ``` ++ publish(promise); ++} + +- Promise Example; ++function fulfill(promise, value) { ++ if (promise._state !== PENDING) { ++ return; ++ } + +- ```javascript +- findResult().then(function(result){ +- // success +- }, function(reason){ +- // failure +- }); +- ``` ++ promise._result = value; ++ promise._state = FULFILLED; + +- Advanced Example +- -------------- ++ if (promise._subscribers.length !== 0) { ++ asap(publish, promise); ++ } ++} + +- Synchronous Example ++function _reject(promise, reason) { ++ if (promise._state !== PENDING) { ++ return; ++ } ++ promise._state = REJECTED; ++ promise._result = reason; + +- ```javascript +- var author, books; ++ asap(publishRejection, promise); ++} + +- try { +- author = findAuthor(); +- books = findBooksByAuthor(author); +- // success +- } catch(reason) { +- // failure +- } +- ``` ++function subscribe(parent, child, onFulfillment, onRejection) { ++ var _subscribers = parent._subscribers; ++ var length = _subscribers.length; + +- Errback Example ++ parent._onerror = null; + +- ```js ++ _subscribers[length] = child; ++ _subscribers[length + FULFILLED] = onFulfillment; ++ _subscribers[length + REJECTED] = onRejection; + +- function foundBooks(books) { ++ if (length === 0 && parent._state) { ++ asap(publish, parent); ++ } ++} + +- } ++function publish(promise) { ++ var subscribers = promise._subscribers; ++ var settled = promise._state; + +- function failure(reason) { ++ if (subscribers.length === 0) { ++ return; ++ } + +- } ++ var child = undefined, ++ callback = undefined, ++ detail = promise._result; + +- findAuthor(function(author, err){ +- if (err) { +- failure(err); +- // failure +- } else { +- try { +- findBoooksByAuthor(author, function(books, err) { +- if (err) { +- failure(err); +- } else { +- try { +- foundBooks(books); +- } catch(reason) { +- failure(reason); +- } +- } +- }); +- } catch(error) { +- failure(err); +- } +- // success +- } +- }); +- ``` ++ for (var i = 0; i < subscribers.length; i += 3) { ++ child = subscribers[i]; ++ callback = subscribers[i + settled]; + +- Promise Example; ++ if (child) { ++ invokeCallback(settled, child, callback, detail); ++ } else { ++ callback(detail); ++ } ++ } + +- ```javascript +- findAuthor(). +- then(findBooksByAuthor). +- then(function(books){ +- // found books +- }).catch(function(reason){ +- // something went wrong +- }); +- ``` ++ promise._subscribers.length = 0; ++} + +- @method then +- @param {Function} onFulfilled +- @param {Function} onRejected +- Useful for tooling. +- @return {Promise} +- */ +- then: lib$es6$promise$then$$default, ++function ErrorObject() { ++ this.error = null; ++} + +- /** +- `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same +- as the catch block of a try/catch statement. ++var TRY_CATCH_ERROR = new ErrorObject(); + +- ```js +- function findAuthor(){ +- throw new Error('couldn't find that author'); +- } ++function tryCatch(callback, detail) { ++ try { ++ return callback(detail); ++ } catch (e) { ++ TRY_CATCH_ERROR.error = e; ++ return TRY_CATCH_ERROR; ++ } ++} + +- // synchronous +- try { +- findAuthor(); +- } catch(reason) { +- // something went wrong +- } ++function invokeCallback(settled, promise, callback, detail) { ++ var hasCallback = isFunction(callback), ++ value = undefined, ++ error = undefined, ++ succeeded = undefined, ++ failed = undefined; + +- // async with promises +- findAuthor().catch(function(reason){ +- // something went wrong +- }); +- ``` +- +- @method catch +- @param {Function} onRejection +- Useful for tooling. +- @return {Promise} +- */ +- 'catch': function(onRejection) { +- return this.then(null, onRejection); +- } +- }; +- var lib$es6$promise$enumerator$$default = lib$es6$promise$enumerator$$Enumerator; +- function lib$es6$promise$enumerator$$Enumerator(Constructor, input) { +- this._instanceConstructor = Constructor; +- this.promise = new Constructor(lib$es6$promise$$internal$$noop); ++ if (hasCallback) { ++ value = tryCatch(callback, detail); + +- if (Array.isArray(input)) { +- this._input = input; +- this.length = input.length; +- this._remaining = input.length; ++ if (value === TRY_CATCH_ERROR) { ++ failed = true; ++ error = value.error; ++ value = null; ++ } else { ++ succeeded = true; ++ } + +- this._result = new Array(this.length); ++ if (promise === value) { ++ _reject(promise, cannotReturnOwn()); ++ return; ++ } ++ } else { ++ value = detail; ++ succeeded = true; ++ } + +- if (this.length === 0) { +- lib$es6$promise$$internal$$fulfill(this.promise, this._result); +- } else { +- this.length = this.length || 0; +- this._enumerate(); +- if (this._remaining === 0) { +- lib$es6$promise$$internal$$fulfill(this.promise, this._result); +- } +- } +- } else { +- lib$es6$promise$$internal$$reject(this.promise, this._validationError()); +- } ++ if (promise._state !== PENDING) { ++ // noop ++ } else if (hasCallback && succeeded) { ++ _resolve(promise, value); ++ } else if (failed) { ++ _reject(promise, error); ++ } else if (settled === FULFILLED) { ++ fulfill(promise, value); ++ } else if (settled === REJECTED) { ++ _reject(promise, value); + } ++} + +- lib$es6$promise$enumerator$$Enumerator.prototype._validationError = function() { +- return new Error('Array Methods must be provided an Array'); +- }; ++function initializePromise(promise, resolver) { ++ try { ++ resolver(function resolvePromise(value) { ++ _resolve(promise, value); ++ }, function rejectPromise(reason) { ++ _reject(promise, reason); ++ }); ++ } catch (e) { ++ _reject(promise, e); ++ } ++} + +- lib$es6$promise$enumerator$$Enumerator.prototype._enumerate = function() { +- var length = this.length; +- var input = this._input; ++var id = 0; ++function nextId() { ++ return id++; ++} + +- for (var i = 0; this._state === lib$es6$promise$$internal$$PENDING && i < length; i++) { +- this._eachEntry(input[i], i); +- } +- }; ++function makePromise(promise) { ++ promise[PROMISE_ID] = id++; ++ promise._state = undefined; ++ promise._result = undefined; ++ promise._subscribers = []; ++} + +- lib$es6$promise$enumerator$$Enumerator.prototype._eachEntry = function(entry, i) { +- var c = this._instanceConstructor; +- var resolve = c.resolve; +- +- if (resolve === lib$es6$promise$promise$resolve$$default) { +- var then = lib$es6$promise$$internal$$getThen(entry); +- +- if (then === lib$es6$promise$then$$default && +- entry._state !== lib$es6$promise$$internal$$PENDING) { +- this._settledAt(entry._state, i, entry._result); +- } else if (typeof then !== 'function') { +- this._remaining--; +- this._result[i] = entry; +- } else if (c === lib$es6$promise$promise$$default) { +- var promise = new c(lib$es6$promise$$internal$$noop); +- lib$es6$promise$$internal$$handleMaybeThenable(promise, entry, then); +- this._willSettleAt(promise, i); +- } else { +- this._willSettleAt(new c(function(resolve) { resolve(entry); }), i); +- } +- } else { +- this._willSettleAt(resolve(entry), i); +- } +- }; ++function Enumerator(Constructor, input) { ++ this._instanceConstructor = Constructor; ++ this.promise = new Constructor(noop); + +- lib$es6$promise$enumerator$$Enumerator.prototype._settledAt = function(state, i, value) { +- var promise = this.promise; ++ if (!this.promise[PROMISE_ID]) { ++ makePromise(this.promise); ++ } + +- if (promise._state === lib$es6$promise$$internal$$PENDING) { +- this._remaining--; ++ if (isArray(input)) { ++ this._input = input; ++ this.length = input.length; ++ this._remaining = input.length; + +- if (state === lib$es6$promise$$internal$$REJECTED) { +- lib$es6$promise$$internal$$reject(promise, value); +- } else { +- this._result[i] = value; +- } +- } ++ this._result = new Array(this.length); + ++ if (this.length === 0) { ++ fulfill(this.promise, this._result); ++ } else { ++ this.length = this.length || 0; ++ this._enumerate(); + if (this._remaining === 0) { +- lib$es6$promise$$internal$$fulfill(promise, this._result); ++ fulfill(this.promise, this._result); + } +- }; ++ } ++ } else { ++ _reject(this.promise, validationError()); ++ } ++} + +- lib$es6$promise$enumerator$$Enumerator.prototype._willSettleAt = function(promise, i) { +- var enumerator = this; ++function validationError() { ++ return new Error('Array Methods must be provided an Array'); ++}; + +- lib$es6$promise$$internal$$subscribe(promise, undefined, function(value) { +- enumerator._settledAt(lib$es6$promise$$internal$$FULFILLED, i, value); +- }, function(reason) { +- enumerator._settledAt(lib$es6$promise$$internal$$REJECTED, i, reason); +- }); +- }; +- function lib$es6$promise$polyfill$$polyfill() { +- var local; ++Enumerator.prototype._enumerate = function () { ++ var length = this.length; ++ var _input = this._input; + +- if (typeof global !== 'undefined') { +- local = global; +- } else if (typeof self !== 'undefined') { +- local = self; +- } else { +- try { +- local = Function('return this')(); +- } catch (e) { +- throw new Error('polyfill failed because global object is unavailable in this environment'); +- } +- } ++ for (var i = 0; this._state === PENDING && i < length; i++) { ++ this._eachEntry(_input[i], i); ++ } ++}; + +- var P = local.Promise; ++Enumerator.prototype._eachEntry = function (entry, i) { ++ var c = this._instanceConstructor; ++ var resolve$$ = c.resolve; + +- if (P && Object.prototype.toString.call(P.resolve()) === '[object Promise]' && !P.cast) { +- return; +- } ++ if (resolve$$ === resolve) { ++ var _then = getThen(entry); + +- local.Promise = lib$es6$promise$promise$$default; ++ if (_then === then && entry._state !== PENDING) { ++ this._settledAt(entry._state, i, entry._result); ++ } else if (typeof _then !== 'function') { ++ this._remaining--; ++ this._result[i] = entry; ++ } else if (c === Promise) { ++ var promise = new c(noop); ++ handleMaybeThenable(promise, entry, _then); ++ this._willSettleAt(promise, i); ++ } else { ++ this._willSettleAt(new c(function (resolve$$) { ++ return resolve$$(entry); ++ }), i); + } +- var lib$es6$promise$polyfill$$default = lib$es6$promise$polyfill$$polyfill; ++ } else { ++ this._willSettleAt(resolve$$(entry), i); ++ } ++}; + +- var lib$es6$promise$umd$$ES6Promise = { +- 'Promise': lib$es6$promise$promise$$default, +- 'polyfill': lib$es6$promise$polyfill$$default +- }; ++Enumerator.prototype._settledAt = function (state, i, value) { ++ var promise = this.promise; + +- /* global define:true module:true window: true */ +- if (typeof define === 'function' && define['amd']) { +- define(function() { return lib$es6$promise$umd$$ES6Promise; }); +- } else if (typeof module !== 'undefined' && module['exports']) { +- module['exports'] = lib$es6$promise$umd$$ES6Promise; +- } else if (typeof this !== 'undefined') { +- this['ES6Promise'] = lib$es6$promise$umd$$ES6Promise; +- } ++ if (promise._state === PENDING) { ++ this._remaining--; + +- lib$es6$promise$polyfill$$default(); +-}).call(this); ++ if (state === REJECTED) { ++ _reject(promise, value); ++ } else { ++ this._result[i] = value; ++ } ++ } + ++ if (this._remaining === 0) { ++ fulfill(promise, this._result); ++ } ++}; + +-}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +-},{"_process":15}],65:[function(require,module,exports){ +-/** +- * inspired by is-number +- * but significantly simplified and sped up by ignoring number and string constructors +- * ie these return false: +- * new Number(1) +- * new String('1') +- */ ++Enumerator.prototype._willSettleAt = function (promise, i) { ++ var enumerator = this; + +-'use strict'; ++ subscribe(promise, undefined, function (value) { ++ return enumerator._settledAt(FULFILLED, i, value); ++ }, function (reason) { ++ return enumerator._settledAt(REJECTED, i, reason); ++ }); ++}; + + /** +- * Is this string all whitespace? +- * This solution kind of makes my brain hurt, but it's significantly faster +- * than !str.trim() or any other solution I could find. +- * +- * whitespace codes from: http://en.wikipedia.org/wiki/Whitespace_character +- * and verified with: +- * +- * for(var i = 0; i < 65536; i++) { +- * var s = String.fromCharCode(i); +- * if(+s===0 && !s.trim()) console.log(i, s); +- * } +- * +- * which counts a couple of these as *not* whitespace, but finds nothing else +- * that *is* whitespace. Note that charCodeAt stops at 16 bits, but it appears +- * that there are no whitespace characters above this, and code points above +- * this do not map onto white space characters. +- */ +-function allBlankCharCodes(str){ +- var l = str.length, +- a; +- for(var i = 0; i < l; i++) { +- a = str.charCodeAt(i); +- if((a < 9 || a > 13) && (a !== 32) && (a !== 133) && (a !== 160) && +- (a !== 5760) && (a !== 6158) && (a < 8192 || a > 8205) && +- (a !== 8232) && (a !== 8233) && (a !== 8239) && (a !== 8287) && +- (a !== 8288) && (a !== 12288) && (a !== 65279)) { +- return false; +- } +- } +- return true; +-} ++ `Promise.all` accepts an array of promises, and returns a new promise which ++ is fulfilled with an array of fulfillment values for the passed promises, or ++ rejected with the reason of the first passed promise to be rejected. It casts all ++ elements of the passed iterable to promises as it runs this algorithm. + +-module.exports = function(n) { +- var type = typeof n; +- if(type === 'string') { +- var original = n; +- n = +n; +- // whitespace strings cast to zero - filter them out +- if(n===0 && allBlankCharCodes(original)) return false; +- } +- else if(type !== 'number') return false; ++ Example: + +- return n - n < 1; +-}; ++ ```javascript ++ let promise1 = resolve(1); ++ let promise2 = resolve(2); ++ let promise3 = resolve(3); ++ let promises = [ promise1, promise2, promise3 ]; + +-},{}],66:[function(require,module,exports){ +-"use strict" ++ Promise.all(promises).then(function(array){ ++ // The array here would be [ 1, 2, 3 ]; ++ }); ++ ``` + +-var pool = require("typedarray-pool") +-var ops = require("ndarray-ops") +-var ndarray = require("ndarray") ++ If any of the `promises` given to `all` are rejected, the first promise ++ that is rejected will be given as an argument to the returned promises's ++ rejection handler. For example: + +-var SUPPORTED_TYPES = [ +- "uint8", +- "uint8_clamped", +- "uint16", +- "uint32", +- "int8", +- "int16", +- "int32", +- "float32" ] ++ Example: + +-function GLBuffer(gl, type, handle, length, usage) { +- this.gl = gl +- this.type = type +- this.handle = handle +- this.length = length +- this.usage = usage ++ ```javascript ++ let promise1 = resolve(1); ++ let promise2 = reject(new Error("2")); ++ let promise3 = reject(new Error("3")); ++ let promises = [ promise1, promise2, promise3 ]; ++ ++ Promise.all(promises).then(function(array){ ++ // Code here never runs because there are rejected promises! ++ }, function(error) { ++ // error.message === "2" ++ }); ++ ``` ++ ++ @method all ++ @static ++ @param {Array} entries array of promises ++ @param {String} label optional string for labeling the promise. ++ Useful for tooling. ++ @return {Promise} promise that is fulfilled when all `promises` have been ++ fulfilled, or rejected if any of them become rejected. ++ @static ++*/ ++function all(entries) { ++ return new Enumerator(this, entries).promise; + } + +-var proto = GLBuffer.prototype ++/** ++ `Promise.race` returns a new promise which is settled in the same way as the ++ first passed promise to settle. + +-proto.bind = function() { +- this.gl.bindBuffer(this.type, this.handle) +-} ++ Example: + +-proto.unbind = function() { +- this.gl.bindBuffer(this.type, null) +-} ++ ```javascript ++ let promise1 = new Promise(function(resolve, reject){ ++ setTimeout(function(){ ++ resolve('promise 1'); ++ }, 200); ++ }); + +-proto.dispose = function() { +- this.gl.deleteBuffer(this.handle) +-} ++ let promise2 = new Promise(function(resolve, reject){ ++ setTimeout(function(){ ++ resolve('promise 2'); ++ }, 100); ++ }); + +-function updateTypeArray(gl, type, len, usage, data, offset) { +- var dataLen = data.length * data.BYTES_PER_ELEMENT +- if(offset < 0) { +- gl.bufferData(type, data, usage) +- return dataLen +- } +- if(dataLen + offset > len) { +- throw new Error("gl-buffer: If resizing buffer, must not specify offset") +- } +- gl.bufferSubData(type, offset, data) +- return len +-} ++ Promise.race([promise1, promise2]).then(function(result){ ++ // result === 'promise 2' because it was resolved before promise1 ++ // was resolved. ++ }); ++ ``` ++ ++ `Promise.race` is deterministic in that only the state of the first ++ settled promise matters. For example, even if other promises given to the ++ `promises` array argument are resolved, but the first settled promise has ++ become rejected before the other promises became fulfilled, the returned ++ promise will become rejected: ++ ++ ```javascript ++ let promise1 = new Promise(function(resolve, reject){ ++ setTimeout(function(){ ++ resolve('promise 1'); ++ }, 200); ++ }); + +-function makeScratchTypeArray(array, dtype) { +- var res = pool.malloc(array.length, dtype) +- var n = array.length +- for(var i=0; i=0; --i) { +- if(stride[i] !== n) { +- return false +- } +- n *= shape[i] +- } +- return true +-} ++ Promise.race([promise1, promise2]).then(function(result){ ++ // Code here never runs ++ }, function(reason){ ++ // reason.message === 'promise 2' because promise 2 became rejected before ++ // promise 1 became fulfilled ++ }); ++ ``` + +-proto.update = function(array, offset) { +- if(typeof offset !== "number") { +- offset = -1 +- } +- this.bind() +- if(typeof array === "object" && typeof array.shape !== "undefined") { //ndarray +- var dtype = array.dtype +- if(SUPPORTED_TYPES.indexOf(dtype) < 0) { +- dtype = "float32" +- } +- if(this.type === this.gl.ELEMENT_ARRAY_BUFFER) { +- var ext = gl.getExtension('OES_element_index_uint') +- if(ext && dtype !== "uint16") { +- dtype = "uint32" +- } else { +- dtype = "uint16" +- } +- } +- if(dtype === array.dtype && isPacked(array.shape, array.stride)) { +- if(array.offset === 0 && array.data.length === array.shape[0]) { +- this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, array.data, offset) +- } else { +- this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, array.data.subarray(array.offset, array.shape[0]), offset) +- } +- } else { +- var tmp = pool.malloc(array.size, dtype) +- var ndt = ndarray(tmp, array.shape) +- ops.assign(ndt, array) +- if(offset < 0) { +- this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, tmp, offset) +- } else { +- this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, tmp.subarray(0, array.size), offset) ++ An example real-world use case is implementing timeouts: ++ ++ ```javascript ++ Promise.race([ajax('foo.json'), timeout(5000)]) ++ ``` ++ ++ @method race ++ @static ++ @param {Array} promises array of promises to observe ++ Useful for tooling. ++ @return {Promise} a promise which settles in the same way as the first passed ++ promise to settle. ++*/ ++function race(entries) { ++ /*jshint validthis:true */ ++ var Constructor = this; ++ ++ if (!isArray(entries)) { ++ return new Constructor(function (_, reject) { ++ return reject(new TypeError('You must pass an array to race.')); ++ }); ++ } else { ++ return new Constructor(function (resolve, reject) { ++ var length = entries.length; ++ for (var i = 0; i < length; i++) { ++ Constructor.resolve(entries[i]).then(resolve, reject); + } +- pool.free(tmp) +- } +- } else if(Array.isArray(array)) { //Vanilla array +- var t +- if(this.type === this.gl.ELEMENT_ARRAY_BUFFER) { +- t = makeScratchTypeArray(array, "uint16") +- } else { +- t = makeScratchTypeArray(array, "float32") +- } +- if(offset < 0) { +- this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, t, offset) +- } else { +- this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, t.subarray(0, array.length), offset) +- } +- pool.free(t) +- } else if(typeof array === "object" && typeof array.length === "number") { //Typed array +- this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, array, offset) +- } else if(typeof array === "number" || array === undefined) { //Number/default +- if(offset >= 0) { +- throw new Error("gl-buffer: Cannot specify offset when resizing buffer") +- } +- array = array | 0 +- if(array <= 0) { +- array = 1 +- } +- this.gl.bufferData(this.type, array|0, this.usage) +- this.length = array +- } else { //Error, case should not happen +- throw new Error("gl-buffer: Invalid data type") ++ }); + } + } + +-function createBuffer(gl, data, type, usage) { +- type = type || gl.ARRAY_BUFFER +- usage = usage || gl.DYNAMIC_DRAW +- if(type !== gl.ARRAY_BUFFER && type !== gl.ELEMENT_ARRAY_BUFFER) { +- throw new Error("gl-buffer: Invalid type for webgl buffer, must be either gl.ARRAY_BUFFER or gl.ELEMENT_ARRAY_BUFFER") +- } +- if(usage !== gl.DYNAMIC_DRAW && usage !== gl.STATIC_DRAW && usage !== gl.STREAM_DRAW) { +- throw new Error("gl-buffer: Invalid usage for buffer, must be either gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW") +- } +- var handle = gl.createBuffer() +- var result = new GLBuffer(gl, type, handle, 0, usage) +- result.update(data) +- return result +-} ++/** ++ `Promise.reject` returns a promise rejected with the passed `reason`. ++ It is shorthand for the following: + +-module.exports = createBuffer ++ ```javascript ++ let promise = new Promise(function(resolve, reject){ ++ reject(new Error('WHOOPS')); ++ }); + +-},{"ndarray":131,"ndarray-ops":130,"typedarray-pool":151}],67:[function(require,module,exports){ +-'use strict' ++ promise.then(function(value){ ++ // Code here doesn't run because the promise is rejected! ++ }, function(reason){ ++ // reason.message === 'WHOOPS' ++ }); ++ ``` + +-module.exports = createContour2D ++ Instead of writing the above, your code now simply becomes the following: + +-var iota = require('iota-array') +-var createShader = require('gl-shader') +-var createBuffer = require('gl-buffer') +-var ndarray = require('ndarray') +-var surfaceNets = require('surface-nets') +-var cdt2d = require('cdt2d') +-var cleanPSLG = require('clean-pslg') +-var bsearch = require('binary-search-bounds') ++ ```javascript ++ let promise = Promise.reject(new Error('WHOOPS')); + +-var shaders = require('./lib/shaders') ++ promise.then(function(value){ ++ // Code here doesn't run because the promise is rejected! ++ }, function(reason){ ++ // reason.message === 'WHOOPS' ++ }); ++ ``` + +-function GLContour2D ( +- plot, +- shader, +- fillShader, +- pickShader, +- positionBuffer, +- colorBuffer, +- idBuffer, +- fillPositionBuffer, +- fillColorBuffer) { +- this.plot = plot +- this.shader = shader +- this.fillShader = fillShader +- this.pickShader = pickShader +- this.positionBuffer = positionBuffer +- this.colorBuffer = colorBuffer +- this.idBuffer = idBuffer +- this.fillPositionBuffer = fillPositionBuffer +- this.fillColorBuffer = fillColorBuffer +- this.fillVerts = 0 +- this.xData = [] +- this.yData = [] +- this.shape = [0, 0] +- this.bounds = [Infinity, Infinity, -Infinity, -Infinity] +- this.pickOffset = 0 +- this.numVertices = 0 +- this.lineWidth = 1 ++ @method reject ++ @static ++ @param {Any} reason value that the returned promise will be rejected with. ++ Useful for tooling. ++ @return {Promise} a promise rejected with the given `reason`. ++*/ ++function reject(reason) { ++ /*jshint validthis:true */ ++ var Constructor = this; ++ var promise = new Constructor(noop); ++ _reject(promise, reason); ++ return promise; + } + +-var proto = GLContour2D.prototype ++function needsResolver() { ++ throw new TypeError('You must pass a resolver function as the first argument to the promise constructor'); ++} + +-var WEIGHTS = [ +- 1, 0, +- 0, 0, +- 0, 1, +- 1, 0, +- 1, 1, +- 0, 1 +-] ++function needsNew() { ++ throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function."); ++} + +-proto.draw = (function () { +- var MATRIX = [ +- 1, 0, 0, +- 0, 1, 0, +- 0, 0, 1 +- ] ++/** ++ Promise objects represent the eventual result of an asynchronous operation. The ++ primary way of interacting with a promise is through its `then` method, which ++ registers callbacks to receive either a promise's eventual value or the reason ++ why the promise cannot be fulfilled. + +- var SCREEN_SHAPE = [0, 0] ++ Terminology ++ ----------- + +- return function () { +- var plot = this.plot +- var shader = this.shader +- var fillShader = this.fillShader +- var bounds = this.bounds +- var numVertices = this.numVertices +- var fillVerts = this.fillVerts ++ - `promise` is an object or function with a `then` method whose behavior conforms to this specification. ++ - `thenable` is an object or function that defines a `then` method. ++ - `value` is any legal JavaScript value (including undefined, a thenable, or a promise). ++ - `exception` is a value that is thrown using the throw statement. ++ - `reason` is a value that indicates why a promise was rejected. ++ - `settled` the final resting state of a promise, fulfilled or rejected. + +- var uniforms, attributes ++ A promise can be in one of three states: pending, fulfilled, or rejected. + +- var gl = plot.gl +- var viewBox = plot.viewBox +- var dataBox = plot.dataBox ++ Promises that are fulfilled have a fulfillment value and are in the fulfilled ++ state. Promises that are rejected have a rejection reason and are in the ++ rejected state. A fulfillment value is never a thenable. + +- var boundX = bounds[2] - bounds[0] +- var boundY = bounds[3] - bounds[1] +- var dataX = dataBox[2] - dataBox[0] +- var dataY = dataBox[3] - dataBox[1] ++ Promises can also be said to *resolve* a value. If this value is also a ++ promise, then the original promise's settled state will match the value's ++ settled state. So a promise that *resolves* a promise that rejects will ++ itself reject, and a promise that *resolves* a promise that fulfills will ++ itself fulfill. + +- MATRIX[0] = 2.0 * boundX / dataX +- MATRIX[4] = 2.0 * boundY / dataY +- MATRIX[6] = 2.0 * (bounds[0] - dataBox[0]) / dataX - 1.0 +- MATRIX[7] = 2.0 * (bounds[1] - dataBox[1]) / dataY - 1.0 + +- SCREEN_SHAPE[0] = viewBox[2] - viewBox[0] +- SCREEN_SHAPE[1] = viewBox[3] - viewBox[1] ++ Basic Usage: ++ ------------ + +- if (fillVerts > 0) { +- fillShader.bind() ++ ```js ++ let promise = new Promise(function(resolve, reject) { ++ // on success ++ resolve(value); + +- uniforms = fillShader.uniforms +- uniforms.viewTransform = MATRIX +- uniforms.screenShape = SCREEN_SHAPE ++ // on failure ++ reject(reason); ++ }); + +- attributes = shader.attributes +- this.fillPositionBuffer.bind() +- attributes.position.pointer() ++ promise.then(function(value) { ++ // on fulfillment ++ }, function(reason) { ++ // on rejection ++ }); ++ ``` + +- this.fillColorBuffer.bind() +- attributes.color.pointer(gl.UNSIGNED_BYTE, true) ++ Advanced Usage: ++ --------------- + +- gl.drawArrays(gl.TRIANGLES, 0, fillVerts) +- } ++ Promises shine when abstracting away asynchronous interactions such as ++ `XMLHttpRequest`s. + +- if (numVertices > 0) { +- shader.bind() ++ ```js ++ function getJSON(url) { ++ return new Promise(function(resolve, reject){ ++ let xhr = new XMLHttpRequest(); + +- var lineWidth = this.lineWidth * plot.pixelRatio ++ xhr.open('GET', url); ++ xhr.onreadystatechange = handler; ++ xhr.responseType = 'json'; ++ xhr.setRequestHeader('Accept', 'application/json'); ++ xhr.send(); + +- uniforms = shader.uniforms +- uniforms.viewTransform = MATRIX +- uniforms.screenShape = SCREEN_SHAPE +- uniforms.lineWidth = lineWidth +- uniforms.pointSize = 1000 ++ function handler() { ++ if (this.readyState === this.DONE) { ++ if (this.status === 200) { ++ resolve(this.response); ++ } else { ++ reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']')); ++ } ++ } ++ }; ++ }); ++ } + +- attributes = shader.attributes ++ getJSON('/posts.json').then(function(json) { ++ // on fulfillment ++ }, function(reason) { ++ // on rejection ++ }); ++ ``` + +- // Draw lines +- this.positionBuffer.bind() +- attributes.position.pointer(gl.FLOAT, false, 16, 0) +- attributes.tangent.pointer(gl.FLOAT, false, 16, 8) ++ Unlike callbacks, promises are great composable primitives. + +- this.colorBuffer.bind() +- attributes.color.pointer(gl.UNSIGNED_BYTE, true) ++ ```js ++ Promise.all([ ++ getJSON('/posts'), ++ getJSON('/comments') ++ ]).then(function(values){ ++ values[0] // => postsJSON ++ values[1] // => commentsJSON + +- gl.drawArrays(gl.TRIANGLES, 0, numVertices) ++ return values; ++ }); ++ ``` + +- // Draw end caps +- uniforms.lineWidth = 0 +- uniforms.pointSize = lineWidth ++ @class Promise ++ @param {function} resolver ++ Useful for tooling. ++ @constructor ++*/ ++function Promise(resolver) { ++ this[PROMISE_ID] = nextId(); ++ this._result = this._state = undefined; ++ this._subscribers = []; + +- this.positionBuffer.bind() +- attributes.position.pointer(gl.FLOAT, false, 16 * 3, 0) +- attributes.tangent.pointer(gl.FLOAT, false, 16 * 3, 8) ++ if (noop !== resolver) { ++ typeof resolver !== 'function' && needsResolver(); ++ this instanceof Promise ? initializePromise(this, resolver) : needsNew(); ++ } ++} ++ ++Promise.all = all; ++Promise.race = race; ++Promise.resolve = resolve; ++Promise.reject = reject; ++Promise._setScheduler = setScheduler; ++Promise._setAsap = setAsap; ++Promise._asap = asap; ++ ++Promise.prototype = { ++ constructor: Promise, ++ ++ /** ++ The primary way of interacting with a promise is through its `then` method, ++ which registers callbacks to receive either a promise's eventual value or the ++ reason why the promise cannot be fulfilled. ++ ++ ```js ++ findUser().then(function(user){ ++ // user is available ++ }, function(reason){ ++ // user is unavailable, and you are given the reason why ++ }); ++ ``` ++ ++ Chaining ++ -------- ++ ++ The return value of `then` is itself a promise. This second, 'downstream' ++ promise is resolved with the return value of the first promise's fulfillment ++ or rejection handler, or rejected if the handler throws an exception. ++ ++ ```js ++ findUser().then(function (user) { ++ return user.name; ++ }, function (reason) { ++ return 'default name'; ++ }).then(function (userName) { ++ // If `findUser` fulfilled, `userName` will be the user's name, otherwise it ++ // will be `'default name'` ++ }); ++ ++ findUser().then(function (user) { ++ throw new Error('Found user, but still unhappy'); ++ }, function (reason) { ++ throw new Error('`findUser` rejected and we're unhappy'); ++ }).then(function (value) { ++ // never reached ++ }, function (reason) { ++ // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'. ++ // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'. ++ }); ++ ``` ++ If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream. ++ ++ ```js ++ findUser().then(function (user) { ++ throw new PedagogicalException('Upstream error'); ++ }).then(function (value) { ++ // never reached ++ }).then(function (value) { ++ // never reached ++ }, function (reason) { ++ // The `PedgagocialException` is propagated all the way down to here ++ }); ++ ``` ++ ++ Assimilation ++ ------------ ++ ++ Sometimes the value you want to propagate to a downstream promise can only be ++ retrieved asynchronously. This can be achieved by returning a promise in the ++ fulfillment or rejection handler. The downstream promise will then be pending ++ until the returned promise is settled. This is called *assimilation*. ++ ++ ```js ++ findUser().then(function (user) { ++ return findCommentsByAuthor(user); ++ }).then(function (comments) { ++ // The user's comments are now available ++ }); ++ ``` ++ ++ If the assimliated promise rejects, then the downstream promise will also reject. ++ ++ ```js ++ findUser().then(function (user) { ++ return findCommentsByAuthor(user); ++ }).then(function (comments) { ++ // If `findCommentsByAuthor` fulfills, we'll have the value here ++ }, function (reason) { ++ // If `findCommentsByAuthor` rejects, we'll have the reason here ++ }); ++ ``` ++ ++ Simple Example ++ -------------- ++ ++ Synchronous Example ++ ++ ```javascript ++ let result; ++ ++ try { ++ result = findResult(); ++ // success ++ } catch(reason) { ++ // failure ++ } ++ ``` ++ ++ Errback Example ++ ++ ```js ++ findResult(function(result, err){ ++ if (err) { ++ // failure ++ } else { ++ // success ++ } ++ }); ++ ``` ++ ++ Promise Example; ++ ++ ```javascript ++ findResult().then(function(result){ ++ // success ++ }, function(reason){ ++ // failure ++ }); ++ ``` ++ ++ Advanced Example ++ -------------- ++ ++ Synchronous Example ++ ++ ```javascript ++ let author, books; ++ ++ try { ++ author = findAuthor(); ++ books = findBooksByAuthor(author); ++ // success ++ } catch(reason) { ++ // failure ++ } ++ ``` ++ ++ Errback Example ++ ++ ```js ++ ++ function foundBooks(books) { ++ ++ } ++ ++ function failure(reason) { ++ ++ } ++ ++ findAuthor(function(author, err){ ++ if (err) { ++ failure(err); ++ // failure ++ } else { ++ try { ++ findBoooksByAuthor(author, function(books, err) { ++ if (err) { ++ failure(err); ++ } else { ++ try { ++ foundBooks(books); ++ } catch(reason) { ++ failure(reason); ++ } ++ } ++ }); ++ } catch(error) { ++ failure(err); ++ } ++ // success ++ } ++ }); ++ ``` ++ ++ Promise Example; ++ ++ ```javascript ++ findAuthor(). ++ then(findBooksByAuthor). ++ then(function(books){ ++ // found books ++ }).catch(function(reason){ ++ // something went wrong ++ }); ++ ``` ++ ++ @method then ++ @param {Function} onFulfilled ++ @param {Function} onRejected ++ Useful for tooling. ++ @return {Promise} ++ */ ++ then: then, ++ ++ /** ++ `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same ++ as the catch block of a try/catch statement. ++ ++ ```js ++ function findAuthor(){ ++ throw new Error('couldn't find that author'); ++ } ++ ++ // synchronous ++ try { ++ findAuthor(); ++ } catch(reason) { ++ // something went wrong ++ } ++ ++ // async with promises ++ findAuthor().catch(function(reason){ ++ // something went wrong ++ }); ++ ``` ++ ++ @method catch ++ @param {Function} onRejection ++ Useful for tooling. ++ @return {Promise} ++ */ ++ 'catch': function _catch(onRejection) { ++ return this.then(null, onRejection); ++ } ++}; + +- this.colorBuffer.bind() +- attributes.color.pointer(gl.UNSIGNED_BYTE, true, 4 * 3, 0) ++function polyfill() { ++ var local = undefined; + +- gl.drawArrays(gl.POINTS, 0, numVertices / 3) ++ if (typeof global !== 'undefined') { ++ local = global; ++ } else if (typeof self !== 'undefined') { ++ local = self; ++ } else { ++ try { ++ local = Function('return this')(); ++ } catch (e) { ++ throw new Error('polyfill failed because global object is unavailable in this environment'); ++ } + } +- } +-})() + +-proto.drawPick = (function () { +- return function (pickOffset) { +- return pickOffset +- } +-})() ++ var P = local.Promise; + +-proto.pick = function (x, y, value) { +- return null +-} ++ if (P) { ++ var promiseToString = null; ++ try { ++ promiseToString = Object.prototype.toString.call(P.resolve()); ++ } catch (e) { ++ // silently ignored ++ } + +-function interpolate (array, point) { +- var idx = Math.floor(point) +- if (idx < 0) { +- return array[0] +- } else if (idx >= array.length - 1) { +- return array[array.length - 1] +- } +- var t = point - idx +- return (1.0 - t) * array[idx] + t * array[idx + 1] +-} ++ if (promiseToString === '[object Promise]' && !P.cast) { ++ return; ++ } ++ } + +-proto.update = function (options) { +- options = options || {} ++ local.Promise = Promise; ++} + +- var shape = options.shape || [0, 0] ++polyfill(); ++// Strange compat.. ++Promise.polyfill = polyfill; ++Promise.Promise = Promise; + +- var x = options.x || iota(shape[0]) +- var y = options.y || iota(shape[1]) +- var z = options.z || new Float32Array(shape[0] * shape[1]) ++return Promise; + +- var levels = options.levels || [] +- var levelColors = options.levelColors || [] ++}))); + +- var bounds = this.bounds +- var lox = bounds[0] = x[0] +- var loy = bounds[1] = y[0] +- var hix = bounds[2] = x[x.length - 1] +- var hiy = bounds[3] = y[y.length - 1] ++}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) ++},{"_process":133}],59:[function(require,module,exports){ ++// Copyright Joyent, Inc. and other Node contributors. ++// ++// Permission is hereby granted, free of charge, to any person obtaining a ++// copy of this software and associated documentation files (the ++// "Software"), to deal in the Software without restriction, including ++// without limitation the rights to use, copy, modify, merge, publish, ++// distribute, sublicense, and/or sell copies of the Software, and to permit ++// persons to whom the Software is furnished to do so, subject to the ++// following conditions: ++// ++// The above copyright notice and this permission notice shall be included ++// in all copies or substantial portions of the Software. ++// ++// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ++// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ++// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN ++// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, ++// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR ++// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE ++// USE OR OTHER DEALINGS IN THE SOFTWARE. + +- if (lox === hix) { +- bounds[2] += 1 +- hix += 1 +- } +- if (loy === hiy) { +- bounds[3] += 1 +- hiy += 1 +- } ++function EventEmitter() { ++ this._events = this._events || {}; ++ this._maxListeners = this._maxListeners || undefined; ++} ++module.exports = EventEmitter; + +- var xs = 1.0 / (hix - lox) +- var ys = 1.0 / (hiy - loy) ++// Backwards-compat with node 0.10.x ++EventEmitter.EventEmitter = EventEmitter; + +- this.xData = x +- this.yData = y ++EventEmitter.prototype._events = undefined; ++EventEmitter.prototype._maxListeners = undefined; + +- this.lineWidth = options.lineWidth || 1 ++// By default EventEmitters will print a warning if more than 10 listeners are ++// added to it. This is a useful default which helps finding memory leaks. ++EventEmitter.defaultMaxListeners = 10; + +- var zarray = ndarray(z, shape) ++// Obviously not all Emitters should be limited to 10. This function allows ++// that to be increased. Set to zero for unlimited. ++EventEmitter.prototype.setMaxListeners = function(n) { ++ if (!isNumber(n) || n < 0 || isNaN(n)) ++ throw TypeError('n must be a positive number'); ++ this._maxListeners = n; ++ return this; ++}; + +- var positions = [] +- var colors = [] +- var ids = [] ++EventEmitter.prototype.emit = function(type) { ++ var er, handler, len, args, i, listeners; + +- var fillCells = [] +- var fillPositions = [ +- [0, 0], +- [shape[0] - 1, 0], +- [0, shape[1] - 1], +- [shape[0] - 1, shape[1] - 1] +- ] ++ if (!this._events) ++ this._events = {}; + +- function intersect (level, x, a, b) { +- var d = (b - a) +- if (Math.abs(d) < 1e-6) { +- return x ++ // If there is no 'error' event listener then throw. ++ if (type === 'error') { ++ if (!this._events.error || ++ (isObject(this._events.error) && !this._events.error.length)) { ++ er = arguments[1]; ++ if (er instanceof Error) { ++ throw er; // Unhandled 'error' event ++ } else { ++ // At least give some kind of context to the user ++ var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); ++ err.context = er; ++ throw err; ++ } + } +- return Math.floor(x) + Math.max(0.001, Math.min(0.999, (level - a) / d)) + } + +- for (var i = 0; i < levels.length; ++i) { +- var level = levels[i] +- if (i > 0 && level === levels[i - 1]) { +- continue +- } +- var contour = surfaceNets(zarray, level) +- +- var c_r = (255 * levelColors[4 * i]) | 0 +- var c_g = (255 * levelColors[4 * i + 1]) | 0 +- var c_b = (255 * levelColors[4 * i + 2]) | 0 +- var c_a = (255 * levelColors[4 * i + 3]) | 0 +- +- var c_cells = contour.cells +- var c_positions = contour.positions ++ handler = this._events[type]; + +- // Fix boundaries +- var in_degree = Array(c_positions.length) +- for (var j = 0; j < in_degree.length; ++j) { +- in_degree[j] = 0 +- } +- for (j = 0; j < c_cells.length; ++j) { +- var edge = c_cells[j] +- in_degree[edge[0]] += 1 +- in_degree[edge[1]] += 1 +- } ++ if (isUndefined(handler)) ++ return false; + +- for (j = 0; j < in_degree.length; ++j) { +- var deg = in_degree[j] +- if (deg === 0) { +- continue +- } +- var pp = c_positions[j] +- in_degree[j] = fillPositions.length +- fillPositions.push(pp) +- if (deg > 1) { +- continue +- } +- var ppx = pp[0] +- var ppy = pp[1] +- var z00 = zarray.get(Math.floor(ppx), Math.floor(ppy)) +- var z01 = zarray.get(Math.floor(ppx), Math.ceil(ppy)) +- var z10 = zarray.get(Math.ceil(ppx), Math.floor(ppy)) +- var z11 = zarray.get(Math.ceil(ppx), Math.ceil(ppy)) +- var intercept +- if (Math.floor(pp[0]) === 0 && +- ((z00 <= level) !== (z01 < level))) { +- intercept = [0, intersect(level, pp[1], z00, z01)] +- } else if (Math.ceil(pp[0]) === shape[0] - 1 && +- ((z10 <= level) !== (z11 < level))) { +- intercept = [shape[0] - 1, intersect(level, pp[1], z10, z11)] +- } else if (Math.floor(pp[1]) === 0 && +- ((z00 <= level) !== (z10 < level))) { +- intercept = [intersect(level, pp[0], z00, z10), 0] +- } else if (Math.ceil(pp[1]) === shape[1] - 1 && +- ((z01 <= level) !== (z11 < level))) { +- intercept = [intersect(level, pp[0], z01, z11), shape[1] - 1] +- } +- if (intercept) { +- c_cells.push([j, c_positions.length]) +- in_degree.push(fillPositions.length) +- c_positions.push(intercept) +- } ++ if (isFunction(handler)) { ++ switch (arguments.length) { ++ // fast cases ++ case 1: ++ handler.call(this); ++ break; ++ case 2: ++ handler.call(this, arguments[1]); ++ break; ++ case 3: ++ handler.call(this, arguments[1], arguments[2]); ++ break; ++ // slower ++ default: ++ args = Array.prototype.slice.call(arguments, 1); ++ handler.apply(this, args); + } ++ } else if (isObject(handler)) { ++ args = Array.prototype.slice.call(arguments, 1); ++ listeners = handler.slice(); ++ len = listeners.length; ++ for (i = 0; i < len; i++) ++ listeners[i].apply(this, args); ++ } + +- for (j = 0; j < c_cells.length; ++j) { +- var e = c_cells[j] +- var a = c_positions[e[0]] +- var b = c_positions[e[1]] ++ return true; ++}; + +- fillCells.push([in_degree[e[0]], in_degree[e[1]]]) ++EventEmitter.prototype.addListener = function(type, listener) { ++ var m; + +- var pointId = Math.round(a[0]) + shape[0] * Math.round(a[1]) ++ if (!isFunction(listener)) ++ throw TypeError('listener must be a function'); + +- var ax = interpolate(x, a[0]) +- var ay = interpolate(y, a[1]) +- var bx = interpolate(x, b[0]) +- var by = interpolate(y, b[1]) ++ if (!this._events) ++ this._events = {}; + +- ax = xs * (ax - lox) +- ay = ys * (ay - loy) +- bx = xs * (bx - lox) +- by = ys * (by - loy) ++ // To avoid recursion in the case that type === "newListener"! Before ++ // adding it to the listeners, first emit "newListener". ++ if (this._events.newListener) ++ this.emit('newListener', type, ++ isFunction(listener.listener) ? ++ listener.listener : listener); + +- var dx = ax - bx +- var dy = ay - by ++ if (!this._events[type]) ++ // Optimize the case of one listener. Don't need the extra array object. ++ this._events[type] = listener; ++ else if (isObject(this._events[type])) ++ // If we've already got an array, just append. ++ this._events[type].push(listener); ++ else ++ // Adding the second element, need to change to array. ++ this._events[type] = [this._events[type], listener]; + +- for (var k = 0; k < WEIGHTS.length; k += 2) { +- var wx = WEIGHTS[k] +- var wix = 1.0 - wx +- var wy = 2.0 * WEIGHTS[k + 1] - 1.0 ++ // Check for listener leak ++ if (isObject(this._events[type]) && !this._events[type].warned) { ++ if (!isUndefined(this._maxListeners)) { ++ m = this._maxListeners; ++ } else { ++ m = EventEmitter.defaultMaxListeners; ++ } + +- positions.push( +- wix * ax + wx * bx, wix * ay + wx * by, +- wy * dx, wy * dy) +- colors.push(c_r, c_g, c_b, c_a) +- ids.push(pointId) ++ if (m && m > 0 && this._events[type].length > m) { ++ this._events[type].warned = true; ++ console.error('(node) warning: possible EventEmitter memory ' + ++ 'leak detected. %d listeners added. ' + ++ 'Use emitter.setMaxListeners() to increase limit.', ++ this._events[type].length); ++ if (typeof console.trace === 'function') { ++ // not supported in IE 10 ++ console.trace(); + } + } + } + +- this.positionBuffer.update(new Float32Array(positions)) +- this.colorBuffer.update(new Uint8Array(colors)) +- this.idBuffer.update(new Uint32Array(ids)) +- this.numVertices = ids.length +- +- var fillColors = options.fillColors +- var fillCellColors = [] +- var fillCellPositions = [] +- var fillVerts = 0 +- +- if (fillColors) { +- cleanPSLG(fillPositions, fillCells) +- var fillMesh = cdt2d(fillPositions, fillCells, { +- delaunay: false +- }) +- for (i = 0; i < fillMesh.length; ++i) { +- var cell = fillMesh[i] +- var cx = 0 +- var cy = 0 +- +- for (j = 0; j < 3; ++j) { +- var p = fillPositions[cell[j]] +- var px = interpolate(x, p[0]) +- var py = interpolate(y, p[1]) +- cx += p[0] +- cy += p[1] +- fillCellPositions.push( +- xs * (px - lox), +- ys * (py - loy)) +- } +- +- // Compute centroid of triangle +- cx /= 3 +- cy /= 3 +- +- // Sample height field at triangle centroid +- var cxi = Math.floor(cx) +- var cyi = Math.floor(cy) +- var cxf = cx - cxi +- var cyf = cy - cyi ++ return this; ++}; + +- var c00 = zarray.get(cxi, cyi) +- var c01 = zarray.get(cxi, cyi + 1) +- var c10 = zarray.get(cxi + 1, cyi) +- var c11 = zarray.get(cxi + 1, cyi + 1) ++EventEmitter.prototype.on = EventEmitter.prototype.addListener; + +- var zlevel = +- (1 - cyf) * ((1 - cxf) * c00 + cxf * c10) + +- cyf * ((1 - cxf) * c01 + cxf * c11) ++EventEmitter.prototype.once = function(type, listener) { ++ if (!isFunction(listener)) ++ throw TypeError('listener must be a function'); + +- // Color triangle using centroid data +- var l = bsearch.le(levels, zlevel) + 1 +- var cr = (255 * fillColors[4 * l + 0]) | 0 +- var cg = (255 * fillColors[4 * l + 1]) | 0 +- var cb = (255 * fillColors[4 * l + 2]) | 0 +- var ca = (255 * fillColors[4 * l + 3]) | 0 ++ var fired = false; + +- fillCellColors.push( +- cr, cg, cb, ca, +- cr, cg, cb, ca, +- cr, cg, cb, ca) ++ function g() { ++ this.removeListener(type, g); + +- fillVerts += 3 ++ if (!fired) { ++ fired = true; ++ listener.apply(this, arguments); + } +- +- this.fillPositionBuffer.update(new Float32Array(fillCellPositions)) +- this.fillColorBuffer.update(new Uint8Array(fillCellColors)) +- +- this.fillVerts = fillVerts + } +-} +- +-proto.dispose = function () { +- this.plot.removeObject(this) +-} +- +-function createContour2D (plot, options) { +- var gl = plot.gl +- +- var shader = createShader(gl, shaders.vertex, shaders.fragment) +- var pickShader = createShader(gl, shaders.pickVertex, shaders.pickFragment) +- var fillShader = createShader(gl, shaders.fillVertex, shaders.fragment) +- +- var positionBuffer = createBuffer(gl) +- var colorBuffer = createBuffer(gl) +- var idBuffer = createBuffer(gl) +- +- var fillPositionBuffer = createBuffer(gl) +- var fillColorBuffer = createBuffer(gl) +- +- var contours = new GLContour2D( +- plot, +- shader, +- fillShader, +- pickShader, +- positionBuffer, +- colorBuffer, +- idBuffer, +- fillPositionBuffer, +- fillColorBuffer) +- +- contours.update(options) +- plot.addObject(contours) + +- return contours +-} ++ g.listener = listener; ++ this.on(type, g); + +-},{"./lib/shaders":68,"binary-search-bounds":69,"cdt2d":16,"clean-pslg":23,"gl-buffer":66,"gl-shader":96,"iota-array":123,"ndarray":131,"surface-nets":146}],68:[function(require,module,exports){ +-'use strict' ++ return this; ++}; + ++// emits a 'removeListener' event iff the listener was removed ++EventEmitter.prototype.removeListener = function(type, listener) { ++ var list, position, length, i; + ++ if (!isFunction(listener)) ++ throw TypeError('listener must be a function'); + +-module.exports = { +- fragment: "precision lowp float;\n#define GLSLIFY 1\nvarying vec4 fragColor;\nvoid main() {\n gl_FragColor = vec4(fragColor.rgb * fragColor.a, fragColor.a);\n}\n", +- vertex: "precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec2 tangent;\nattribute vec4 color;\n\nuniform mat3 viewTransform;\nuniform vec2 screenShape;\nuniform float lineWidth;\nuniform float pointSize;\n\nvarying vec4 fragColor;\n\nvoid main() {\n fragColor = color;\n\n vec3 vPosition = viewTransform * vec3(position, 1.0);\n vec2 vTangent = normalize(viewTransform * vec3(tangent, 0)).xy;\n vec2 offset = vec2(vTangent.y, -vTangent.x) / screenShape;\n\n gl_Position = vec4(\n vPosition.xy + offset * lineWidth * vPosition.z,\n 0,\n vPosition.z);\n\n gl_PointSize = pointSize;\n}\n", +- pickFragment: "precision lowp float;\n#define GLSLIFY 1\nvarying vec4 fragId;\nvoid main() {\n gl_FragColor = fragId;\n}\n", +- pickVertex: "precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec4 pickId;\n\nuniform mat3 viewTransform;\nuniform vec4 pickOffset;\n\nvarying vec4 fragId;\n\nvoid main() {\n vec4 id = pickId + pickOffset;\n id.y += floor(id.x / 256.0);\n id.x -= floor(id.x / 256.0) * 256.0;\n\n id.z += floor(id.y / 256.0);\n id.y -= floor(id.y / 256.0) * 256.0;\n\n id.w += floor(id.z / 256.0);\n id.z -= floor(id.z / 256.0) * 256.0;\n\n fragId = id / 255.0;\n\n vec3 vPosition = viewTransform * vec3(position, 1.0);\n gl_Position = vec4(vPosition.xy, 0, vPosition.z);\n}\n", +- fillVertex: "precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec4 color;\n\nuniform mat3 viewTransform;\n\nvarying vec4 fragColor;\n\nvoid main() {\n fragColor = color;\n vec3 vPosition = viewTransform * vec3(position, 1.0);\n gl_Position = vec4(vPosition.xy, 0, vPosition.z);\n}\n" +-} ++ if (!this._events || !this._events[type]) ++ return this; + +-},{}],69:[function(require,module,exports){ +-arguments[4][21][0].apply(exports,arguments) +-},{"dup":21}],70:[function(require,module,exports){ +-'use strict' ++ list = this._events[type]; ++ length = list.length; ++ position = -1; + +-var createShader = require('gl-shader') +-var createBuffer = require('gl-buffer') +-var pool = require('typedarray-pool') +-var shaders = require('./lib/shaders') ++ if (list === listener || ++ (isFunction(list.listener) && list.listener === listener)) { ++ delete this._events[type]; ++ if (this._events.removeListener) ++ this.emit('removeListener', type, listener); + +-module.exports = createError2D ++ } else if (isObject(list)) { ++ for (i = length; i-- > 0;) { ++ if (list[i] === listener || ++ (list[i].listener && list[i].listener === listener)) { ++ position = i; ++ break; ++ } ++ } + +-var WEIGHTS = [ +- // x-error bar +- [1, 0, 0, 1, 0, 0], +- [1, 0, 0, -1, 0, 0], +- [-1, 0, 0, -1, 0, 0], ++ if (position < 0) ++ return this; + +- [-1, 0, 0, -1, 0, 0], +- [-1, 0, 0, 1, 0, 0], +- [1, 0, 0, 1, 0, 0], ++ if (list.length === 1) { ++ list.length = 0; ++ delete this._events[type]; ++ } else { ++ list.splice(position, 1); ++ } + +- // x-error right cap +- [1, 0, -1, 0, 0, 1], +- [1, 0, -1, 0, 0, -1], +- [1, 0, 1, 0, 0, -1], ++ if (this._events.removeListener) ++ this.emit('removeListener', type, listener); ++ } + +- [1, 0, 1, 0, 0, -1], +- [1, 0, 1, 0, 0, 1], +- [1, 0, -1, 0, 0, 1], ++ return this; ++}; + +- // x-error left cap +- [-1, 0, -1, 0, 0, 1], +- [-1, 0, -1, 0, 0, -1], +- [-1, 0, 1, 0, 0, -1], ++EventEmitter.prototype.removeAllListeners = function(type) { ++ var key, listeners; + +- [-1, 0, 1, 0, 0, -1], +- [-1, 0, 1, 0, 0, 1], +- [-1, 0, -1, 0, 0, 1], ++ if (!this._events) ++ return this; + +- // y-error bar +- [0, 1, 1, 0, 0, 0], +- [0, 1, -1, 0, 0, 0], +- [0, -1, -1, 0, 0, 0], ++ // not listening for removeListener, no need to emit ++ if (!this._events.removeListener) { ++ if (arguments.length === 0) ++ this._events = {}; ++ else if (this._events[type]) ++ delete this._events[type]; ++ return this; ++ } + +- [0, -1, -1, 0, 0, 0], +- [0, 1, 1, 0, 0, 0], +- [0, -1, 1, 0, 0, 0], ++ // emit removeListener for all listeners on all events ++ if (arguments.length === 0) { ++ for (key in this._events) { ++ if (key === 'removeListener') continue; ++ this.removeAllListeners(key); ++ } ++ this.removeAllListeners('removeListener'); ++ this._events = {}; ++ return this; ++ } + +- // y-error top cap +- [0, 1, 0, -1, 1, 0], +- [0, 1, 0, -1, -1, 0], +- [0, 1, 0, 1, -1, 0], ++ listeners = this._events[type]; + +- [0, 1, 0, 1, 1, 0], +- [0, 1, 0, -1, 1, 0], +- [0, 1, 0, 1, -1, 0], ++ if (isFunction(listeners)) { ++ this.removeListener(type, listeners); ++ } else if (listeners) { ++ // LIFO order ++ while (listeners.length) ++ this.removeListener(type, listeners[listeners.length - 1]); ++ } ++ delete this._events[type]; + +- // y-error bottom cap +- [0, -1, 0, -1, 1, 0], +- [0, -1, 0, -1, -1, 0], +- [0, -1, 0, 1, -1, 0], ++ return this; ++}; + +- [0, -1, 0, 1, 1, 0], +- [0, -1, 0, -1, 1, 0], +- [0, -1, 0, 1, -1, 0] +-] ++EventEmitter.prototype.listeners = function(type) { ++ var ret; ++ if (!this._events || !this._events[type]) ++ ret = []; ++ else if (isFunction(this._events[type])) ++ ret = [this._events[type]]; ++ else ++ ret = this._events[type].slice(); ++ return ret; ++}; + +-function GLError2D (plot, shader, buffer) { +- this.plot = plot ++EventEmitter.prototype.listenerCount = function(type) { ++ if (this._events) { ++ var evlistener = this._events[type]; + +- this.shader = shader +- this.buffer = buffer ++ if (isFunction(evlistener)) ++ return 1; ++ else if (evlistener) ++ return evlistener.length; ++ } ++ return 0; ++}; + +- this.bounds = [Infinity, Infinity, -Infinity, -Infinity] ++EventEmitter.listenerCount = function(emitter, type) { ++ return emitter.listenerCount(type); ++}; + +- this.numPoints = 0 ++function isFunction(arg) { ++ return typeof arg === 'function'; ++} + +- this.color = [0, 0, 0, 1] ++function isNumber(arg) { ++ return typeof arg === 'number'; + } + +-var proto = GLError2D.prototype ++function isObject(arg) { ++ return typeof arg === 'object' && arg !== null; ++} + +-proto.draw = (function () { +- var MATRIX = [ +- 1, 0, 0, +- 0, 1, 0, +- 0, 0, 1 +- ] ++function isUndefined(arg) { ++ return arg === void 0; ++} + +- var PIXEL_SCALE = [1, 1] ++},{}],60:[function(require,module,exports){ ++/** ++ * inspired by is-number ++ * but significantly simplified and sped up by ignoring number and string constructors ++ * ie these return false: ++ * new Number(1) ++ * new String('1') ++ */ + +- return function () { +- var plot = this.plot +- var shader = this.shader +- var buffer = this.buffer +- var bounds = this.bounds +- var numPoints = this.numPoints ++'use strict'; + +- if (!numPoints) { +- return ++/** ++ * Is this string all whitespace? ++ * This solution kind of makes my brain hurt, but it's significantly faster ++ * than !str.trim() or any other solution I could find. ++ * ++ * whitespace codes from: http://en.wikipedia.org/wiki/Whitespace_character ++ * and verified with: ++ * ++ * for(var i = 0; i < 65536; i++) { ++ * var s = String.fromCharCode(i); ++ * if(+s===0 && !s.trim()) console.log(i, s); ++ * } ++ * ++ * which counts a couple of these as *not* whitespace, but finds nothing else ++ * that *is* whitespace. Note that charCodeAt stops at 16 bits, but it appears ++ * that there are no whitespace characters above this, and code points above ++ * this do not map onto white space characters. ++ */ ++function allBlankCharCodes(str){ ++ var l = str.length, ++ a; ++ for(var i = 0; i < l; i++) { ++ a = str.charCodeAt(i); ++ if((a < 9 || a > 13) && (a !== 32) && (a !== 133) && (a !== 160) && ++ (a !== 5760) && (a !== 6158) && (a < 8192 || a > 8205) && ++ (a !== 8232) && (a !== 8233) && (a !== 8239) && (a !== 8287) && ++ (a !== 8288) && (a !== 12288) && (a !== 65279)) { ++ return false; ++ } + } ++ return true; ++} + +- var gl = plot.gl +- var dataBox = plot.dataBox +- var viewBox = plot.viewBox +- var pixelRatio = plot.pixelRatio +- +- var boundX = bounds[2] - bounds[0] +- var boundY = bounds[3] - bounds[1] +- var dataX = dataBox[2] - dataBox[0] +- var dataY = dataBox[3] - dataBox[1] ++module.exports = function(n) { ++ var type = typeof n; ++ if(type === 'string') { ++ var original = n; ++ n = +n; ++ // whitespace strings cast to zero - filter them out ++ if(n===0 && allBlankCharCodes(original)) return false; ++ } ++ else if(type !== 'number') return false; + +- MATRIX[0] = 2.0 * boundX / dataX +- MATRIX[4] = 2.0 * boundY / dataY +- MATRIX[6] = 2.0 * (bounds[0] - dataBox[0]) / dataX - 1.0 +- MATRIX[7] = 2.0 * (bounds[1] - dataBox[1]) / dataY - 1.0 ++ return n - n < 1; ++}; + +- var screenX = viewBox[2] - viewBox[0] +- var screenY = viewBox[3] - viewBox[1] ++},{}],61:[function(require,module,exports){ ++"use strict" + +- PIXEL_SCALE[0] = 2.0 * pixelRatio / screenX +- PIXEL_SCALE[1] = 2.0 * pixelRatio / screenY ++module.exports = createRBTree + +- buffer.bind() +- shader.bind() ++var RED = 0 ++var BLACK = 1 + +- shader.uniforms.viewTransform = MATRIX +- shader.uniforms.pixelScale = PIXEL_SCALE +- shader.uniforms.color = this.color ++function RBNode(color, key, value, left, right, count) { ++ this._color = color ++ this.key = key ++ this.value = value ++ this.left = left ++ this.right = right ++ this._count = count ++} + +- shader.attributes.position.pointer( +- gl.FLOAT, +- false, +- 16, +- 0) ++function cloneNode(node) { ++ return new RBNode(node._color, node.key, node.value, node.left, node.right, node._count) ++} + +- shader.attributes.pixelOffset.pointer( +- gl.FLOAT, +- false, +- 16, +- 8) ++function repaint(color, node) { ++ return new RBNode(color, node.key, node.value, node.left, node.right, node._count) ++} + +- gl.drawArrays(gl.TRIANGLES, 0, numPoints * WEIGHTS.length) +- } +-})() ++function recount(node) { ++ node._count = 1 + (node.left ? node.left._count : 0) + (node.right ? node.right._count : 0) ++} + +-proto.drawPick = function (offset) { return offset } +-proto.pick = function (x, y) { +- return null ++function RedBlackTree(compare, root) { ++ this._compare = compare ++ this.root = root + } + +-proto.update = function (options) { +- options = options || {} ++var proto = RedBlackTree.prototype + +- var i, x, y ++Object.defineProperty(proto, "keys", { ++ get: function() { ++ var result = [] ++ this.forEach(function(k,v) { ++ result.push(k) ++ }) ++ return result ++ } ++}) + +- var positions = options.positions || [] +- var errors = options.errors || [] ++Object.defineProperty(proto, "values", { ++ get: function() { ++ var result = [] ++ this.forEach(function(k,v) { ++ result.push(v) ++ }) ++ return result ++ } ++}) + +- var lineWidth = 1 +- if ('lineWidth' in options) { +- lineWidth = +options.lineWidth ++//Returns the number of nodes in the tree ++Object.defineProperty(proto, "length", { ++ get: function() { ++ if(this.root) { ++ return this.root._count ++ } ++ return 0 + } ++}) + +- var capSize = 5 +- if ('capSize' in options) { +- capSize = +options.capSize ++//Insert a new item into the tree ++proto.insert = function(key, value) { ++ var cmp = this._compare ++ //Find point to insert new node at ++ var n = this.root ++ var n_stack = [] ++ var d_stack = [] ++ while(n) { ++ var d = cmp(key, n.key) ++ n_stack.push(n) ++ d_stack.push(d) ++ if(d <= 0) { ++ n = n.left ++ } else { ++ n = n.right ++ } ++ } ++ //Rebuild path to leaf node ++ n_stack.push(new RBNode(RED, key, value, null, null, 1)) ++ for(var s=n_stack.length-2; s>=0; --s) { ++ var n = n_stack[s] ++ if(d_stack[s] <= 0) { ++ n_stack[s] = new RBNode(n._color, n.key, n.value, n_stack[s+1], n.right, n._count+1) ++ } else { ++ n_stack[s] = new RBNode(n._color, n.key, n.value, n.left, n_stack[s+1], n._count+1) ++ } ++ } ++ //Rebalance tree using rotations ++ //console.log("start insert", key, d_stack) ++ for(var s=n_stack.length-1; s>1; --s) { ++ var p = n_stack[s-1] ++ var n = n_stack[s] ++ if(p._color === BLACK || n._color === BLACK) { ++ break ++ } ++ var pp = n_stack[s-2] ++ if(pp.left === p) { ++ if(p.left === n) { ++ var y = pp.right ++ if(y && y._color === RED) { ++ //console.log("LLr") ++ p._color = BLACK ++ pp.right = repaint(BLACK, y) ++ pp._color = RED ++ s -= 1 ++ } else { ++ //console.log("LLb") ++ pp._color = RED ++ pp.left = p.right ++ p._color = BLACK ++ p.right = pp ++ n_stack[s-2] = p ++ n_stack[s-1] = n ++ recount(pp) ++ recount(p) ++ if(s >= 3) { ++ var ppp = n_stack[s-3] ++ if(ppp.left === pp) { ++ ppp.left = p ++ } else { ++ ppp.right = p ++ } ++ } ++ break ++ } ++ } else { ++ var y = pp.right ++ if(y && y._color === RED) { ++ //console.log("LRr") ++ p._color = BLACK ++ pp.right = repaint(BLACK, y) ++ pp._color = RED ++ s -= 1 ++ } else { ++ //console.log("LRb") ++ p.right = n.left ++ pp._color = RED ++ pp.left = n.right ++ n._color = BLACK ++ n.left = p ++ n.right = pp ++ n_stack[s-2] = n ++ n_stack[s-1] = p ++ recount(pp) ++ recount(p) ++ recount(n) ++ if(s >= 3) { ++ var ppp = n_stack[s-3] ++ if(ppp.left === pp) { ++ ppp.left = n ++ } else { ++ ppp.right = n ++ } ++ } ++ break ++ } ++ } ++ } else { ++ if(p.right === n) { ++ var y = pp.left ++ if(y && y._color === RED) { ++ //console.log("RRr", y.key) ++ p._color = BLACK ++ pp.left = repaint(BLACK, y) ++ pp._color = RED ++ s -= 1 ++ } else { ++ //console.log("RRb") ++ pp._color = RED ++ pp.right = p.left ++ p._color = BLACK ++ p.left = pp ++ n_stack[s-2] = p ++ n_stack[s-1] = n ++ recount(pp) ++ recount(p) ++ if(s >= 3) { ++ var ppp = n_stack[s-3] ++ if(ppp.right === pp) { ++ ppp.right = p ++ } else { ++ ppp.left = p ++ } ++ } ++ break ++ } ++ } else { ++ var y = pp.left ++ if(y && y._color === RED) { ++ //console.log("RLr") ++ p._color = BLACK ++ pp.left = repaint(BLACK, y) ++ pp._color = RED ++ s -= 1 ++ } else { ++ //console.log("RLb") ++ p.left = n.right ++ pp._color = RED ++ pp.right = n.left ++ n._color = BLACK ++ n.right = p ++ n.left = pp ++ n_stack[s-2] = n ++ n_stack[s-1] = p ++ recount(pp) ++ recount(p) ++ recount(n) ++ if(s >= 3) { ++ var ppp = n_stack[s-3] ++ if(ppp.right === pp) { ++ ppp.right = n ++ } else { ++ ppp.left = n ++ } ++ } ++ break ++ } ++ } ++ } + } ++ //Return new tree ++ n_stack[0]._color = BLACK ++ return new RedBlackTree(cmp, n_stack[0]) ++} + +- this.color = (options.color || [0, 0, 0, 1]).slice() + +- var bounds = this.bounds = [Infinity, Infinity, -Infinity, -Infinity] ++//Visit all nodes inorder ++function doVisitFull(visit, node) { ++ if(node.left) { ++ var v = doVisitFull(visit, node.left) ++ if(v) { return v } ++ } ++ var v = visit(node.key, node.value) ++ if(v) { return v } ++ if(node.right) { ++ return doVisitFull(visit, node.right) ++ } ++} + +- var numPoints = this.numPoints = positions.length >> 1 +- for (i = 0; i < numPoints; ++i) { +- x = positions[i * 2] +- y = positions[i * 2 + 1] ++//Visit half nodes in order ++function doVisitHalf(lo, compare, visit, node) { ++ var l = compare(lo, node.key) ++ if(l <= 0) { ++ if(node.left) { ++ var v = doVisitHalf(lo, compare, visit, node.left) ++ if(v) { return v } ++ } ++ var v = visit(node.key, node.value) ++ if(v) { return v } ++ } ++ if(node.right) { ++ return doVisitHalf(lo, compare, visit, node.right) ++ } ++} + +- bounds[0] = Math.min(x, bounds[0]) +- bounds[1] = Math.min(y, bounds[1]) +- bounds[2] = Math.max(x, bounds[2]) +- bounds[3] = Math.max(y, bounds[3]) ++//Visit all nodes within a range ++function doVisit(lo, hi, compare, visit, node) { ++ var l = compare(lo, node.key) ++ var h = compare(hi, node.key) ++ var v ++ if(l <= 0) { ++ if(node.left) { ++ v = doVisit(lo, hi, compare, visit, node.left) ++ if(v) { return v } ++ } ++ if(h > 0) { ++ v = visit(node.key, node.value) ++ if(v) { return v } ++ } + } +- if (bounds[2] === bounds[0]) { +- bounds[2] += 1 ++ if(h > 0 && node.right) { ++ return doVisit(lo, hi, compare, visit, node.right) + } +- if (bounds[3] === bounds[1]) { +- bounds[3] += 1 ++} ++ ++ ++proto.forEach = function rbTreeForEach(visit, lo, hi) { ++ if(!this.root) { ++ return + } +- var sx = 1.0 / (bounds[2] - bounds[0]) +- var sy = 1.0 / (bounds[3] - bounds[1]) +- var tx = bounds[0] +- var ty = bounds[1] ++ switch(arguments.length) { ++ case 1: ++ return doVisitFull(visit, this.root) ++ break + +- var bufferData = pool.mallocFloat32(numPoints * WEIGHTS.length * 4) +- var ptr = 0 +- for (i = 0; i < numPoints; ++i) { +- x = positions[2 * i] +- y = positions[2 * i + 1] +- var ex0 = errors[4 * i] +- var ex1 = errors[4 * i + 1] +- var ey0 = errors[4 * i + 2] +- var ey1 = errors[4 * i + 3] ++ case 2: ++ return doVisitHalf(lo, this._compare, visit, this.root) ++ break + +- for (var j = 0; j < WEIGHTS.length; ++j) { +- var w = WEIGHTS[j] ++ case 3: ++ if(this._compare(lo, hi) >= 0) { ++ return ++ } ++ return doVisit(lo, hi, this._compare, visit, this.root) ++ break ++ } ++} + +- var dx = w[0] +- var dy = w[1] ++//First item in list ++Object.defineProperty(proto, "begin", { ++ get: function() { ++ var stack = [] ++ var n = this.root ++ while(n) { ++ stack.push(n) ++ n = n.left ++ } ++ return new RedBlackTreeIterator(this, stack) ++ } ++}) + +- if (dx < 0) { +- dx *= ex0 +- } else if (dx > 0) { +- dx *= ex1 ++//Last item in list ++Object.defineProperty(proto, "end", { ++ get: function() { ++ var stack = [] ++ var n = this.root ++ while(n) { ++ stack.push(n) ++ n = n.right ++ } ++ return new RedBlackTreeIterator(this, stack) ++ } ++}) ++ ++//Find the ith item in the tree ++proto.at = function(idx) { ++ if(idx < 0) { ++ return new RedBlackTreeIterator(this, []) ++ } ++ var n = this.root ++ var stack = [] ++ while(true) { ++ stack.push(n) ++ if(n.left) { ++ if(idx < n.left._count) { ++ n = n.left ++ continue + } +- +- if (dy < 0) { +- dy *= ey0 +- } else if (dy > 0) { +- dy *= ey1 ++ idx -= n.left._count ++ } ++ if(!idx) { ++ return new RedBlackTreeIterator(this, stack) ++ } ++ idx -= 1 ++ if(n.right) { ++ if(idx >= n.right._count) { ++ break + } +- +- bufferData[ptr++] = sx * ((x - tx) + dx) +- bufferData[ptr++] = sy * ((y - ty) + dy) +- bufferData[ptr++] = lineWidth * w[2] + (capSize + lineWidth) * w[4] +- bufferData[ptr++] = lineWidth * w[3] + (capSize + lineWidth) * w[5] ++ n = n.right ++ } else { ++ break + } + } +- this.buffer.update(bufferData) +- pool.free(bufferData) +-} +- +-proto.dispose = function () { +- this.plot.removeObject(this) +- this.shader.dispose() +- this.buffer.dispose() ++ return new RedBlackTreeIterator(this, []) + } + +-function createError2D (plot, options) { +- var shader = createShader(plot.gl, shaders.vertex, shaders.fragment) +- var buffer = createBuffer(plot.gl) +- +- var errorbars = new GLError2D(plot, shader, buffer) +- +- errorbars.update(options) +- +- plot.addObject(errorbars) +- +- return errorbars ++proto.ge = function(key) { ++ var cmp = this._compare ++ var n = this.root ++ var stack = [] ++ var last_ptr = 0 ++ while(n) { ++ var d = cmp(key, n.key) ++ stack.push(n) ++ if(d <= 0) { ++ last_ptr = stack.length ++ } ++ if(d <= 0) { ++ n = n.left ++ } else { ++ n = n.right ++ } ++ } ++ stack.length = last_ptr ++ return new RedBlackTreeIterator(this, stack) + } + +-},{"./lib/shaders":71,"gl-buffer":66,"gl-shader":96,"typedarray-pool":151}],71:[function(require,module,exports){ +- +- +-module.exports = { +- vertex: "precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec2 pixelOffset;\n\nuniform mat3 viewTransform;\nuniform vec2 pixelScale;\n\nvoid main() {\n vec3 scrPosition = viewTransform * vec3(position, 1);\n gl_Position = vec4(\n scrPosition.xy + scrPosition.z * pixelScale * pixelOffset,\n 0,\n scrPosition.z);\n}\n", +- fragment: "precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 color;\n\nvoid main() {\n gl_FragColor = vec4(color.rgb * color.a, color.a);\n}\n" ++proto.gt = function(key) { ++ var cmp = this._compare ++ var n = this.root ++ var stack = [] ++ var last_ptr = 0 ++ while(n) { ++ var d = cmp(key, n.key) ++ stack.push(n) ++ if(d < 0) { ++ last_ptr = stack.length ++ } ++ if(d < 0) { ++ n = n.left ++ } else { ++ n = n.right ++ } ++ } ++ stack.length = last_ptr ++ return new RedBlackTreeIterator(this, stack) + } + +-},{}],72:[function(require,module,exports){ +-'use strict' +- +-var createTexture = require('gl-texture2d') +- +-module.exports = createFBO +- +-var colorAttachmentArrays = null +-var FRAMEBUFFER_UNSUPPORTED +-var FRAMEBUFFER_INCOMPLETE_ATTACHMENT +-var FRAMEBUFFER_INCOMPLETE_DIMENSIONS +-var FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT +- +-function saveFBOState(gl) { +- var fbo = gl.getParameter(gl.FRAMEBUFFER_BINDING) +- var rbo = gl.getParameter(gl.RENDERBUFFER_BINDING) +- var tex = gl.getParameter(gl.TEXTURE_BINDING_2D) +- return [fbo, rbo, tex] ++proto.lt = function(key) { ++ var cmp = this._compare ++ var n = this.root ++ var stack = [] ++ var last_ptr = 0 ++ while(n) { ++ var d = cmp(key, n.key) ++ stack.push(n) ++ if(d > 0) { ++ last_ptr = stack.length ++ } ++ if(d <= 0) { ++ n = n.left ++ } else { ++ n = n.right ++ } ++ } ++ stack.length = last_ptr ++ return new RedBlackTreeIterator(this, stack) + } + +-function restoreFBOState(gl, data) { +- gl.bindFramebuffer(gl.FRAMEBUFFER, data[0]) +- gl.bindRenderbuffer(gl.RENDERBUFFER, data[1]) +- gl.bindTexture(gl.TEXTURE_2D, data[2]) ++proto.le = function(key) { ++ var cmp = this._compare ++ var n = this.root ++ var stack = [] ++ var last_ptr = 0 ++ while(n) { ++ var d = cmp(key, n.key) ++ stack.push(n) ++ if(d >= 0) { ++ last_ptr = stack.length ++ } ++ if(d < 0) { ++ n = n.left ++ } else { ++ n = n.right ++ } ++ } ++ stack.length = last_ptr ++ return new RedBlackTreeIterator(this, stack) + } + +-function lazyInitColorAttachments(gl, ext) { +- var maxColorAttachments = gl.getParameter(ext.MAX_COLOR_ATTACHMENTS_WEBGL) +- colorAttachmentArrays = new Array(maxColorAttachments + 1) +- for(var i=0; i<=maxColorAttachments; ++i) { +- var x = new Array(maxColorAttachments) +- for(var j=0; j 0 ++ } ++}) + +- var gl = fbo.gl +- var handle = fbo.handle = gl.createFramebuffer() +- var width = fbo._shape[0] +- var height = fbo._shape[1] +- var numColors = fbo.color.length +- var ext = fbo._ext +- var useStencil = fbo._useStencil +- var useDepth = fbo._useDepth +- var colorType = fbo._colorType ++//Node of the iterator ++Object.defineProperty(iproto, "node", { ++ get: function() { ++ if(this._stack.length > 0) { ++ return this._stack[this._stack.length-1] ++ } ++ return null ++ }, ++ enumerable: true ++}) + +- //Bind the fbo +- gl.bindFramebuffer(gl.FRAMEBUFFER, handle) ++//Makes a copy of an iterator ++iproto.clone = function() { ++ return new RedBlackTreeIterator(this.tree, this._stack.slice()) ++} + +- //Allocate color buffers +- for(var i=0; i=0; --i) { ++ n = stack[i] ++ if(i === 0) { ++ n._color = BLACK ++ return ++ } ++ //console.log("visit node:", n.key, i, stack[i].key, stack[i-1].key) ++ p = stack[i-1] ++ if(p.left === n) { ++ //console.log("left child") ++ s = p.right ++ if(s.right && s.right._color === RED) { ++ //console.log("case 1: right sibling child red") ++ s = p.right = cloneNode(s) ++ z = s.right = cloneNode(s.right) ++ p.right = s.left ++ s.left = p ++ s.right = z ++ s._color = p._color ++ n._color = BLACK ++ p._color = BLACK ++ z._color = BLACK ++ recount(p) ++ recount(s) ++ if(i > 1) { ++ var pp = stack[i-2] ++ if(pp.left === p) { ++ pp.left = s ++ } else { ++ pp.right = s ++ } ++ } ++ stack[i-1] = s ++ return ++ } else if(s.left && s.left._color === RED) { ++ //console.log("case 1: left sibling child red") ++ s = p.right = cloneNode(s) ++ z = s.left = cloneNode(s.left) ++ p.right = z.left ++ s.left = z.right ++ z.left = p ++ z.right = s ++ z._color = p._color ++ p._color = BLACK ++ s._color = BLACK ++ n._color = BLACK ++ recount(p) ++ recount(s) ++ recount(z) ++ if(i > 1) { ++ var pp = stack[i-2] ++ if(pp.left === p) { ++ pp.left = z ++ } else { ++ pp.right = z ++ } ++ } ++ stack[i-1] = z ++ return ++ } ++ if(s._color === BLACK) { ++ if(p._color === RED) { ++ //console.log("case 2: black sibling, red parent", p.right.value) ++ p._color = BLACK ++ p.right = repaint(RED, s) ++ return ++ } else { ++ //console.log("case 2: black sibling, black parent", p.right.value) ++ p.right = repaint(RED, s) ++ continue ++ } ++ } else { ++ //console.log("case 3: red sibling") ++ s = cloneNode(s) ++ p.right = s.left ++ s.left = p ++ s._color = p._color ++ p._color = RED ++ recount(p) ++ recount(s) ++ if(i > 1) { ++ var pp = stack[i-2] ++ if(pp.left === p) { ++ pp.left = s ++ } else { ++ pp.right = s ++ } ++ } ++ stack[i-1] = s ++ stack[i] = p ++ if(i+1 < stack.length) { ++ stack[i+1] = n ++ } else { ++ stack.push(n) ++ } ++ i = i+2 ++ } ++ } else { ++ //console.log("right child") ++ s = p.left ++ if(s.left && s.left._color === RED) { ++ //console.log("case 1: left sibling child red", p.value, p._color) ++ s = p.left = cloneNode(s) ++ z = s.left = cloneNode(s.left) ++ p.left = s.right ++ s.right = p ++ s.left = z ++ s._color = p._color ++ n._color = BLACK ++ p._color = BLACK ++ z._color = BLACK ++ recount(p) ++ recount(s) ++ if(i > 1) { ++ var pp = stack[i-2] ++ if(pp.right === p) { ++ pp.right = s ++ } else { ++ pp.left = s ++ } ++ } ++ stack[i-1] = s ++ return ++ } else if(s.right && s.right._color === RED) { ++ //console.log("case 1: right sibling child red") ++ s = p.left = cloneNode(s) ++ z = s.right = cloneNode(s.right) ++ p.left = z.right ++ s.right = z.left ++ z.right = p ++ z.left = s ++ z._color = p._color ++ p._color = BLACK ++ s._color = BLACK ++ n._color = BLACK ++ recount(p) ++ recount(s) ++ recount(z) ++ if(i > 1) { ++ var pp = stack[i-2] ++ if(pp.right === p) { ++ pp.right = z ++ } else { ++ pp.left = z ++ } ++ } ++ stack[i-1] = z ++ return ++ } ++ if(s._color === BLACK) { ++ if(p._color === RED) { ++ //console.log("case 2: black sibling, red parent") ++ p._color = BLACK ++ p.left = repaint(RED, s) ++ return ++ } else { ++ //console.log("case 2: black sibling, black parent") ++ p.left = repaint(RED, s) ++ continue ++ } ++ } else { ++ //console.log("case 3: red sibling") ++ s = cloneNode(s) ++ p.left = s.right ++ s.right = p ++ s._color = p._color ++ p._color = RED ++ recount(p) ++ recount(s) ++ if(i > 1) { ++ var pp = stack[i-2] ++ if(pp.right === p) { ++ pp.right = s ++ } else { ++ pp.left = s ++ } ++ } ++ stack[i-1] = s ++ stack[i] = p ++ if(i+1 < stack.length) { ++ stack[i+1] = n ++ } else { ++ stack.push(n) ++ } ++ i = i+2 ++ } + } +- } else if(numColors > 1) { +- ext.drawBuffersWEBGL(colorAttachmentArrays[numColors]) + } ++} + +- //Allocate depth/stencil buffers +- var WEBGL_depth_texture = gl.getExtension('WEBGL_depth_texture') +- if(WEBGL_depth_texture) { +- if(useStencil) { +- fbo.depth = initTexture(gl, width, height, +- WEBGL_depth_texture.UNSIGNED_INT_24_8_WEBGL, +- gl.DEPTH_STENCIL, +- gl.DEPTH_STENCIL_ATTACHMENT) +- } else if(useDepth) { +- fbo.depth = initTexture(gl, width, height, +- gl.UNSIGNED_SHORT, +- gl.DEPTH_COMPONENT, +- gl.DEPTH_ATTACHMENT) +- } +- } else { +- if(useDepth && useStencil) { +- fbo._depth_rb = initRenderBuffer(gl, width, height, gl.DEPTH_STENCIL, gl.DEPTH_STENCIL_ATTACHMENT) +- } else if(useDepth) { +- fbo._depth_rb = initRenderBuffer(gl, width, height, gl.DEPTH_COMPONENT16, gl.DEPTH_ATTACHMENT) +- } else if(useStencil) { +- fbo._depth_rb = initRenderBuffer(gl, width, height, gl.STENCIL_INDEX, gl.STENCIL_ATTACHMENT) ++//Removes item at iterator from tree ++iproto.remove = function() { ++ var stack = this._stack ++ if(stack.length === 0) { ++ return this.tree ++ } ++ //First copy path to node ++ var cstack = new Array(stack.length) ++ var n = stack[stack.length-1] ++ cstack[cstack.length-1] = new RBNode(n._color, n.key, n.value, n.left, n.right, n._count) ++ for(var i=stack.length-2; i>=0; --i) { ++ var n = stack[i] ++ if(n.left === stack[i+1]) { ++ cstack[i] = new RBNode(n._color, n.key, n.value, cstack[i+1], n.right, n._count) ++ } else { ++ cstack[i] = new RBNode(n._color, n.key, n.value, n.left, cstack[i+1], n._count) + } + } + +- //Check frame buffer state +- var status = gl.checkFramebufferStatus(gl.FRAMEBUFFER) +- if(status !== gl.FRAMEBUFFER_COMPLETE) { ++ //Get node ++ n = cstack[cstack.length-1] ++ //console.log("start remove: ", n.value) + +- //Release all partially allocated resources +- fbo._destroyed = true ++ //If not leaf, then swap with previous node ++ if(n.left && n.right) { ++ //console.log("moving to leaf") + +- //Release all resources +- gl.bindFramebuffer(gl.FRAMEBUFFER, null) +- gl.deleteFramebuffer(fbo.handle) +- fbo.handle = null +- if(fbo.depth) { +- fbo.depth.dispose() +- fbo.depth = null ++ //First walk to previous leaf ++ var split = cstack.length ++ n = n.left ++ while(n.right) { ++ cstack.push(n) ++ n = n.right + } +- if(fbo._depth_rb) { +- gl.deleteRenderbuffer(fbo._depth_rb) +- fbo._depth_rb = null ++ //Copy path to leaf ++ var v = cstack[split-1] ++ cstack.push(new RBNode(n._color, v.key, v.value, n.left, n.right, n._count)) ++ cstack[split-1].key = n.key ++ cstack[split-1].value = n.value ++ ++ //Fix up stack ++ for(var i=cstack.length-2; i>=split; --i) { ++ n = cstack[i] ++ cstack[i] = new RBNode(n._color, n.key, n.value, n.left, cstack[i+1], n._count) + } +- for(var i=0; i 0) { ++ return this._stack[this._stack.length-1].key ++ } ++ return ++ }, ++ enumerable: true ++}) + +- //Allocate buffers +- this.color = new Array(numColors) +- for(var i=0; i 0) { ++ return this._stack[this._stack.length-1].value ++ } ++ return ++ }, ++ enumerable: true ++}) + +- //Save depth and stencil flags +- this._colorType = colorType +- this._useDepth = useDepth +- this._useStencil = useStencil + +- //Shape vector for resizing +- var parent = this +- var shapeVector = [width|0, height|0] +- Object.defineProperties(shapeVector, { +- 0: { +- get: function() { +- return parent._shape[0] +- }, +- set: function(w) { +- return parent.width = w ++//Returns the position of this iterator in the sorted list ++Object.defineProperty(iproto, "index", { ++ get: function() { ++ var idx = 0 ++ var stack = this._stack ++ if(stack.length === 0) { ++ var r = this.tree.root ++ if(r) { ++ return r._count + } +- }, +- 1: { +- get: function() { +- return parent._shape[1] +- }, +- set: function(h) { +- return parent.height = h ++ return 0 ++ } else if(stack[stack.length-1].left) { ++ idx = stack[stack.length-1].left._count ++ } ++ for(var s=stack.length-2; s>=0; --s) { ++ if(stack[s+1] === stack[s].right) { ++ ++idx ++ if(stack[s].left) { ++ idx += stack[s].left._count ++ } + } + } +- }) +- this._shapeVector = shapeVector ++ return idx ++ }, ++ enumerable: true ++}) + +- //Initialize all attachments +- rebuildFBO(this) ++//Advances iterator to next element in list ++iproto.next = function() { ++ var stack = this._stack ++ if(stack.length === 0) { ++ return ++ } ++ var n = stack[stack.length-1] ++ if(n.right) { ++ n = n.right ++ while(n) { ++ stack.push(n) ++ n = n.left ++ } ++ } else { ++ stack.pop() ++ while(stack.length > 0 && stack[stack.length-1].right === n) { ++ n = stack[stack.length-1] ++ stack.pop() ++ } ++ } + } + +-var proto = Framebuffer.prototype ++//Checks if iterator is at end of tree ++Object.defineProperty(iproto, "hasNext", { ++ get: function() { ++ var stack = this._stack ++ if(stack.length === 0) { ++ return false ++ } ++ if(stack[stack.length-1].right) { ++ return true ++ } ++ for(var s=stack.length-1; s>0; --s) { ++ if(stack[s-1].left === stack[s]) { ++ return true ++ } ++ } ++ return false ++ } ++}) + +-function reshapeFBO(fbo, w, h) { +- //If fbo is invalid, just skip this +- if(fbo._destroyed) { +- throw new Error('gl-fbo: Can\'t resize destroyed FBO') ++//Update value ++iproto.update = function(value) { ++ var stack = this._stack ++ if(stack.length === 0) { ++ throw new Error("Can't update empty node!") ++ } ++ var cstack = new Array(stack.length) ++ var n = stack[stack.length-1] ++ cstack[cstack.length-1] = new RBNode(n._color, n.key, value, n.left, n.right, n._count) ++ for(var i=stack.length-2; i>=0; --i) { ++ n = stack[i] ++ if(n.left === stack[i+1]) { ++ cstack[i] = new RBNode(n._color, n.key, n.value, cstack[i+1], n.right, n._count) ++ } else { ++ cstack[i] = new RBNode(n._color, n.key, n.value, n.left, cstack[i+1], n._count) ++ } + } ++ return new RedBlackTree(this.tree._compare, cstack[0]) ++} + +- //Don't resize if no change in shape +- if( (fbo._shape[0] === w) && +- (fbo._shape[1] === h) ) { ++//Moves iterator backward one element ++iproto.prev = function() { ++ var stack = this._stack ++ if(stack.length === 0) { + return + } ++ var n = stack[stack.length-1] ++ if(n.left) { ++ n = n.left ++ while(n) { ++ stack.push(n) ++ n = n.right ++ } ++ } else { ++ stack.pop() ++ while(stack.length > 0 && stack[stack.length-1].left === n) { ++ n = stack[stack.length-1] ++ stack.pop() ++ } ++ } ++} + +- var gl = fbo.gl ++//Checks if iterator is at start of tree ++Object.defineProperty(iproto, "hasPrev", { ++ get: function() { ++ var stack = this._stack ++ if(stack.length === 0) { ++ return false ++ } ++ if(stack[stack.length-1].left) { ++ return true ++ } ++ for(var s=stack.length-1; s>0; --s) { ++ if(stack[s-1].right === stack[s]) { ++ return true ++ } ++ } ++ return false ++ } ++}) + +- //Check parameter ranges +- var maxFBOSize = gl.getParameter(gl.MAX_RENDERBUFFER_SIZE) +- if( w < 0 || w > maxFBOSize || +- h < 0 || h > maxFBOSize) { +- throw new Error('gl-fbo: Can\'t resize FBO, invalid dimensions') ++//Default comparison function ++function defaultCompare(a, b) { ++ if(a < b) { ++ return -1 ++ } ++ if(a > b) { ++ return 1 + } ++ return 0 ++} + +- //Update shape +- fbo._shape[0] = w +- fbo._shape[1] = h ++//Build a tree ++function createRBTree(compare) { ++ return new RedBlackTree(compare || defaultCompare, null) ++} ++},{}],62:[function(require,module,exports){ ++// transliterated from the python snippet here: ++// http://en.wikipedia.org/wiki/Lanczos_approximation + +- //Save framebuffer state +- var state = saveFBOState(gl) ++var g = 7; ++var p = [ ++ 0.99999999999980993, ++ 676.5203681218851, ++ -1259.1392167224028, ++ 771.32342877765313, ++ -176.61502916214059, ++ 12.507343278686905, ++ -0.13857109526572012, ++ 9.9843695780195716e-6, ++ 1.5056327351493116e-7 ++]; + +- //Resize framebuffer attachments +- for(var i=0; i 0; --i) x += p_ln[i] / (z + i); ++ var t = z + g_ln + 0.5; ++ return .5*Math.log(2*Math.PI)+(z+.5)*Math.log(t)-t+Math.log(x)-Math.log(z); + } + +-Object.defineProperties(proto, { +- 'shape': { +- get: function() { +- if(this._destroyed) { +- return [0,0] +- } +- return this._shapeVector +- }, +- set: function(x) { +- if(!Array.isArray(x)) { +- x = [x|0, x|0] +- } +- if(x.length !== 2) { +- throw new Error('gl-fbo: Shape vector must be length 2') +- } ++module.exports = function gamma (z) { ++ if (z < 0.5) { ++ return Math.PI / (Math.sin(Math.PI * z) * gamma(1 - z)); ++ } ++ else if(z > 100) return Math.exp(lngamma(z)); ++ else { ++ z -= 1; ++ var x = p[0]; ++ for (var i = 1; i < g + 2; i++) { ++ x += p[i] / (z + i); ++ } ++ var t = z + g + 0.5; + +- var w = x[0]|0 +- var h = x[1]|0 +- reshapeFBO(this, w, h) ++ return Math.sqrt(2 * Math.PI) ++ * Math.pow(t, z + 0.5) ++ * Math.exp(-t) ++ * x ++ ; ++ } ++}; + +- return [w, h] +- }, +- enumerable: false +- }, +- 'width': { +- get: function() { +- if(this._destroyed) { +- return 0 +- } +- return this._shape[0] +- }, +- set: function(w) { +- w = w|0 +- reshapeFBO(this, w, this._shape[1]) +- return w +- }, +- enumerable: false +- }, +- 'height': { +- get: function() { +- if(this._destroyed) { +- return 0 +- } +- return this._shape[1] +- }, +- set: function(h) { +- h = h|0 +- reshapeFBO(this, this._shape[0], h) +- return h +- }, +- enumerable: false +- } +-}) ++module.exports.log = lngamma; + +-proto.bind = function() { +- if(this._destroyed) { +- return +- } +- var gl = this.gl +- gl.bindFramebuffer(gl.FRAMEBUFFER, this.handle) +- gl.viewport(0, 0, this._shape[0], this._shape[1]) ++},{}],63:[function(require,module,exports){ ++"use strict" ++ ++var pool = require("typedarray-pool") ++var ops = require("ndarray-ops") ++var ndarray = require("ndarray") ++ ++var SUPPORTED_TYPES = [ ++ "uint8", ++ "uint8_clamped", ++ "uint16", ++ "uint32", ++ "int8", ++ "int16", ++ "int32", ++ "float32" ] ++ ++function GLBuffer(gl, type, handle, length, usage) { ++ this.gl = gl ++ this.type = type ++ this.handle = handle ++ this.length = length ++ this.usage = usage + } + +-proto.dispose = function() { +- if(this._destroyed) { +- return +- } +- this._destroyed = true +- var gl = this.gl +- gl.deleteFramebuffer(this.handle) +- this.handle = null +- if(this.depth) { +- this.depth.dispose() +- this.depth = null +- } +- if(this._depth_rb) { +- gl.deleteRenderbuffer(this._depth_rb) +- this._depth_rb = null +- } +- for(var i=0; i len) { ++ throw new Error("gl-buffer: If resizing buffer, must not specify offset") + } ++ gl.bufferSubData(type, offset, data) ++ return len ++} + +- if(typeof width !== 'number') { +- throw new Error('gl-fbo: Missing shape parameter') ++function makeScratchTypeArray(array, dtype) { ++ var res = pool.malloc(array.length, dtype) ++ var n = array.length ++ for(var i=0; i maxFBOSize || height < 0 || height > maxFBOSize) { +- throw new Error('gl-fbo: Parameters are too large for FBO') ++function isPacked(shape, stride) { ++ var n = 1 ++ for(var i=stride.length-1; i>=0; --i) { ++ if(stride[i] !== n) { ++ return false ++ } ++ n *= shape[i] + } ++ return true ++} + +- //Handle each option type +- options = options || {} +- +- //Figure out number of color buffers to use +- var numColors = 1 +- if('color' in options) { +- numColors = Math.max(options.color|0, 0) +- if(numColors < 0) { +- throw new Error('gl-fbo: Must specify a nonnegative number of colors') ++proto.update = function(array, offset) { ++ if(typeof offset !== "number") { ++ offset = -1 ++ } ++ this.bind() ++ if(typeof array === "object" && typeof array.shape !== "undefined") { //ndarray ++ var dtype = array.dtype ++ if(SUPPORTED_TYPES.indexOf(dtype) < 0) { ++ dtype = "float32" + } +- if(numColors > 1) { +- //Check if multiple render targets supported +- if(!WEBGL_draw_buffers) { +- throw new Error('gl-fbo: Multiple draw buffer extension not supported') +- } else if(numColors > gl.getParameter(WEBGL_draw_buffers.MAX_COLOR_ATTACHMENTS_WEBGL)) { +- throw new Error('gl-fbo: Context does not support ' + numColors + ' draw buffers') ++ if(this.type === this.gl.ELEMENT_ARRAY_BUFFER) { ++ var ext = gl.getExtension('OES_element_index_uint') ++ if(ext && dtype !== "uint16") { ++ dtype = "uint32" ++ } else { ++ dtype = "uint16" + } + } +- } +- +- //Determine whether to use floating point textures +- var colorType = gl.UNSIGNED_BYTE +- var OES_texture_float = gl.getExtension('OES_texture_float') +- if(options.float && numColors > 0) { +- if(!OES_texture_float) { +- throw new Error('gl-fbo: Context does not support floating point textures') ++ if(dtype === array.dtype && isPacked(array.shape, array.stride)) { ++ if(array.offset === 0 && array.data.length === array.shape[0]) { ++ this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, array.data, offset) ++ } else { ++ this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, array.data.subarray(array.offset, array.shape[0]), offset) ++ } ++ } else { ++ var tmp = pool.malloc(array.size, dtype) ++ var ndt = ndarray(tmp, array.shape) ++ ops.assign(ndt, array) ++ if(offset < 0) { ++ this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, tmp, offset) ++ } else { ++ this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, tmp.subarray(0, array.size), offset) ++ } ++ pool.free(tmp) + } +- colorType = gl.FLOAT +- } else if(options.preferFloat && numColors > 0) { +- if(OES_texture_float) { +- colorType = gl.FLOAT ++ } else if(Array.isArray(array)) { //Vanilla array ++ var t ++ if(this.type === this.gl.ELEMENT_ARRAY_BUFFER) { ++ t = makeScratchTypeArray(array, "uint16") ++ } else { ++ t = makeScratchTypeArray(array, "float32") ++ } ++ if(offset < 0) { ++ this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, t, offset) ++ } else { ++ this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, t.subarray(0, array.length), offset) ++ } ++ pool.free(t) ++ } else if(typeof array === "object" && typeof array.length === "number") { //Typed array ++ this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, array, offset) ++ } else if(typeof array === "number" || array === undefined) { //Number/default ++ if(offset >= 0) { ++ throw new Error("gl-buffer: Cannot specify offset when resizing buffer") ++ } ++ array = array | 0 ++ if(array <= 0) { ++ array = 1 + } ++ this.gl.bufferData(this.type, array|0, this.usage) ++ this.length = array ++ } else { //Error, case should not happen ++ throw new Error("gl-buffer: Invalid data type") + } ++} + +- //Check if we should use depth buffer +- var useDepth = true +- if('depth' in options) { +- useDepth = !!options.depth ++function createBuffer(gl, data, type, usage) { ++ type = type || gl.ARRAY_BUFFER ++ usage = usage || gl.DYNAMIC_DRAW ++ if(type !== gl.ARRAY_BUFFER && type !== gl.ELEMENT_ARRAY_BUFFER) { ++ throw new Error("gl-buffer: Invalid type for webgl buffer, must be either gl.ARRAY_BUFFER or gl.ELEMENT_ARRAY_BUFFER") + } +- +- //Check if we should use a stencil buffer +- var useStencil = false +- if('stencil' in options) { +- useStencil = !!options.stencil ++ if(usage !== gl.DYNAMIC_DRAW && usage !== gl.STATIC_DRAW && usage !== gl.STREAM_DRAW) { ++ throw new Error("gl-buffer: Invalid usage for buffer, must be either gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW") + } ++ var handle = gl.createBuffer() ++ var result = new GLBuffer(gl, type, handle, 0, usage) ++ result.update(data) ++ return result ++} + +- return new Framebuffer( +- gl, +- width, +- height, +- colorType, +- numColors, +- useDepth, +- useStencil, +- WEBGL_draw_buffers) ++module.exports = createBuffer ++ ++},{"ndarray":123,"ndarray-ops":122,"typedarray-pool":162}],64:[function(require,module,exports){ ++module.exports = { ++ 0: 'NONE', ++ 1: 'ONE', ++ 2: 'LINE_LOOP', ++ 3: 'LINE_STRIP', ++ 4: 'TRIANGLES', ++ 5: 'TRIANGLE_STRIP', ++ 6: 'TRIANGLE_FAN', ++ 256: 'DEPTH_BUFFER_BIT', ++ 512: 'NEVER', ++ 513: 'LESS', ++ 514: 'EQUAL', ++ 515: 'LEQUAL', ++ 516: 'GREATER', ++ 517: 'NOTEQUAL', ++ 518: 'GEQUAL', ++ 519: 'ALWAYS', ++ 768: 'SRC_COLOR', ++ 769: 'ONE_MINUS_SRC_COLOR', ++ 770: 'SRC_ALPHA', ++ 771: 'ONE_MINUS_SRC_ALPHA', ++ 772: 'DST_ALPHA', ++ 773: 'ONE_MINUS_DST_ALPHA', ++ 774: 'DST_COLOR', ++ 775: 'ONE_MINUS_DST_COLOR', ++ 776: 'SRC_ALPHA_SATURATE', ++ 1024: 'STENCIL_BUFFER_BIT', ++ 1028: 'FRONT', ++ 1029: 'BACK', ++ 1032: 'FRONT_AND_BACK', ++ 1280: 'INVALID_ENUM', ++ 1281: 'INVALID_VALUE', ++ 1282: 'INVALID_OPERATION', ++ 1285: 'OUT_OF_MEMORY', ++ 1286: 'INVALID_FRAMEBUFFER_OPERATION', ++ 2304: 'CW', ++ 2305: 'CCW', ++ 2849: 'LINE_WIDTH', ++ 2884: 'CULL_FACE', ++ 2885: 'CULL_FACE_MODE', ++ 2886: 'FRONT_FACE', ++ 2928: 'DEPTH_RANGE', ++ 2929: 'DEPTH_TEST', ++ 2930: 'DEPTH_WRITEMASK', ++ 2931: 'DEPTH_CLEAR_VALUE', ++ 2932: 'DEPTH_FUNC', ++ 2960: 'STENCIL_TEST', ++ 2961: 'STENCIL_CLEAR_VALUE', ++ 2962: 'STENCIL_FUNC', ++ 2963: 'STENCIL_VALUE_MASK', ++ 2964: 'STENCIL_FAIL', ++ 2965: 'STENCIL_PASS_DEPTH_FAIL', ++ 2966: 'STENCIL_PASS_DEPTH_PASS', ++ 2967: 'STENCIL_REF', ++ 2968: 'STENCIL_WRITEMASK', ++ 2978: 'VIEWPORT', ++ 3024: 'DITHER', ++ 3042: 'BLEND', ++ 3088: 'SCISSOR_BOX', ++ 3089: 'SCISSOR_TEST', ++ 3106: 'COLOR_CLEAR_VALUE', ++ 3107: 'COLOR_WRITEMASK', ++ 3317: 'UNPACK_ALIGNMENT', ++ 3333: 'PACK_ALIGNMENT', ++ 3379: 'MAX_TEXTURE_SIZE', ++ 3386: 'MAX_VIEWPORT_DIMS', ++ 3408: 'SUBPIXEL_BITS', ++ 3410: 'RED_BITS', ++ 3411: 'GREEN_BITS', ++ 3412: 'BLUE_BITS', ++ 3413: 'ALPHA_BITS', ++ 3414: 'DEPTH_BITS', ++ 3415: 'STENCIL_BITS', ++ 3553: 'TEXTURE_2D', ++ 4352: 'DONT_CARE', ++ 4353: 'FASTEST', ++ 4354: 'NICEST', ++ 5120: 'BYTE', ++ 5121: 'UNSIGNED_BYTE', ++ 5122: 'SHORT', ++ 5123: 'UNSIGNED_SHORT', ++ 5124: 'INT', ++ 5125: 'UNSIGNED_INT', ++ 5126: 'FLOAT', ++ 5386: 'INVERT', ++ 5890: 'TEXTURE', ++ 6401: 'STENCIL_INDEX', ++ 6402: 'DEPTH_COMPONENT', ++ 6406: 'ALPHA', ++ 6407: 'RGB', ++ 6408: 'RGBA', ++ 6409: 'LUMINANCE', ++ 6410: 'LUMINANCE_ALPHA', ++ 7680: 'KEEP', ++ 7681: 'REPLACE', ++ 7682: 'INCR', ++ 7683: 'DECR', ++ 7936: 'VENDOR', ++ 7937: 'RENDERER', ++ 7938: 'VERSION', ++ 9728: 'NEAREST', ++ 9729: 'LINEAR', ++ 9984: 'NEAREST_MIPMAP_NEAREST', ++ 9985: 'LINEAR_MIPMAP_NEAREST', ++ 9986: 'NEAREST_MIPMAP_LINEAR', ++ 9987: 'LINEAR_MIPMAP_LINEAR', ++ 10240: 'TEXTURE_MAG_FILTER', ++ 10241: 'TEXTURE_MIN_FILTER', ++ 10242: 'TEXTURE_WRAP_S', ++ 10243: 'TEXTURE_WRAP_T', ++ 10497: 'REPEAT', ++ 10752: 'POLYGON_OFFSET_UNITS', ++ 16384: 'COLOR_BUFFER_BIT', ++ 32769: 'CONSTANT_COLOR', ++ 32770: 'ONE_MINUS_CONSTANT_COLOR', ++ 32771: 'CONSTANT_ALPHA', ++ 32772: 'ONE_MINUS_CONSTANT_ALPHA', ++ 32773: 'BLEND_COLOR', ++ 32774: 'FUNC_ADD', ++ 32777: 'BLEND_EQUATION_RGB', ++ 32778: 'FUNC_SUBTRACT', ++ 32779: 'FUNC_REVERSE_SUBTRACT', ++ 32819: 'UNSIGNED_SHORT_4_4_4_4', ++ 32820: 'UNSIGNED_SHORT_5_5_5_1', ++ 32823: 'POLYGON_OFFSET_FILL', ++ 32824: 'POLYGON_OFFSET_FACTOR', ++ 32854: 'RGBA4', ++ 32855: 'RGB5_A1', ++ 32873: 'TEXTURE_BINDING_2D', ++ 32926: 'SAMPLE_ALPHA_TO_COVERAGE', ++ 32928: 'SAMPLE_COVERAGE', ++ 32936: 'SAMPLE_BUFFERS', ++ 32937: 'SAMPLES', ++ 32938: 'SAMPLE_COVERAGE_VALUE', ++ 32939: 'SAMPLE_COVERAGE_INVERT', ++ 32968: 'BLEND_DST_RGB', ++ 32969: 'BLEND_SRC_RGB', ++ 32970: 'BLEND_DST_ALPHA', ++ 32971: 'BLEND_SRC_ALPHA', ++ 33071: 'CLAMP_TO_EDGE', ++ 33170: 'GENERATE_MIPMAP_HINT', ++ 33189: 'DEPTH_COMPONENT16', ++ 33306: 'DEPTH_STENCIL_ATTACHMENT', ++ 33635: 'UNSIGNED_SHORT_5_6_5', ++ 33648: 'MIRRORED_REPEAT', ++ 33901: 'ALIASED_POINT_SIZE_RANGE', ++ 33902: 'ALIASED_LINE_WIDTH_RANGE', ++ 33984: 'TEXTURE0', ++ 33985: 'TEXTURE1', ++ 33986: 'TEXTURE2', ++ 33987: 'TEXTURE3', ++ 33988: 'TEXTURE4', ++ 33989: 'TEXTURE5', ++ 33990: 'TEXTURE6', ++ 33991: 'TEXTURE7', ++ 33992: 'TEXTURE8', ++ 33993: 'TEXTURE9', ++ 33994: 'TEXTURE10', ++ 33995: 'TEXTURE11', ++ 33996: 'TEXTURE12', ++ 33997: 'TEXTURE13', ++ 33998: 'TEXTURE14', ++ 33999: 'TEXTURE15', ++ 34000: 'TEXTURE16', ++ 34001: 'TEXTURE17', ++ 34002: 'TEXTURE18', ++ 34003: 'TEXTURE19', ++ 34004: 'TEXTURE20', ++ 34005: 'TEXTURE21', ++ 34006: 'TEXTURE22', ++ 34007: 'TEXTURE23', ++ 34008: 'TEXTURE24', ++ 34009: 'TEXTURE25', ++ 34010: 'TEXTURE26', ++ 34011: 'TEXTURE27', ++ 34012: 'TEXTURE28', ++ 34013: 'TEXTURE29', ++ 34014: 'TEXTURE30', ++ 34015: 'TEXTURE31', ++ 34016: 'ACTIVE_TEXTURE', ++ 34024: 'MAX_RENDERBUFFER_SIZE', ++ 34041: 'DEPTH_STENCIL', ++ 34055: 'INCR_WRAP', ++ 34056: 'DECR_WRAP', ++ 34067: 'TEXTURE_CUBE_MAP', ++ 34068: 'TEXTURE_BINDING_CUBE_MAP', ++ 34069: 'TEXTURE_CUBE_MAP_POSITIVE_X', ++ 34070: 'TEXTURE_CUBE_MAP_NEGATIVE_X', ++ 34071: 'TEXTURE_CUBE_MAP_POSITIVE_Y', ++ 34072: 'TEXTURE_CUBE_MAP_NEGATIVE_Y', ++ 34073: 'TEXTURE_CUBE_MAP_POSITIVE_Z', ++ 34074: 'TEXTURE_CUBE_MAP_NEGATIVE_Z', ++ 34076: 'MAX_CUBE_MAP_TEXTURE_SIZE', ++ 34338: 'VERTEX_ATTRIB_ARRAY_ENABLED', ++ 34339: 'VERTEX_ATTRIB_ARRAY_SIZE', ++ 34340: 'VERTEX_ATTRIB_ARRAY_STRIDE', ++ 34341: 'VERTEX_ATTRIB_ARRAY_TYPE', ++ 34342: 'CURRENT_VERTEX_ATTRIB', ++ 34373: 'VERTEX_ATTRIB_ARRAY_POINTER', ++ 34466: 'NUM_COMPRESSED_TEXTURE_FORMATS', ++ 34467: 'COMPRESSED_TEXTURE_FORMATS', ++ 34660: 'BUFFER_SIZE', ++ 34661: 'BUFFER_USAGE', ++ 34816: 'STENCIL_BACK_FUNC', ++ 34817: 'STENCIL_BACK_FAIL', ++ 34818: 'STENCIL_BACK_PASS_DEPTH_FAIL', ++ 34819: 'STENCIL_BACK_PASS_DEPTH_PASS', ++ 34877: 'BLEND_EQUATION_ALPHA', ++ 34921: 'MAX_VERTEX_ATTRIBS', ++ 34922: 'VERTEX_ATTRIB_ARRAY_NORMALIZED', ++ 34930: 'MAX_TEXTURE_IMAGE_UNITS', ++ 34962: 'ARRAY_BUFFER', ++ 34963: 'ELEMENT_ARRAY_BUFFER', ++ 34964: 'ARRAY_BUFFER_BINDING', ++ 34965: 'ELEMENT_ARRAY_BUFFER_BINDING', ++ 34975: 'VERTEX_ATTRIB_ARRAY_BUFFER_BINDING', ++ 35040: 'STREAM_DRAW', ++ 35044: 'STATIC_DRAW', ++ 35048: 'DYNAMIC_DRAW', ++ 35632: 'FRAGMENT_SHADER', ++ 35633: 'VERTEX_SHADER', ++ 35660: 'MAX_VERTEX_TEXTURE_IMAGE_UNITS', ++ 35661: 'MAX_COMBINED_TEXTURE_IMAGE_UNITS', ++ 35663: 'SHADER_TYPE', ++ 35664: 'FLOAT_VEC2', ++ 35665: 'FLOAT_VEC3', ++ 35666: 'FLOAT_VEC4', ++ 35667: 'INT_VEC2', ++ 35668: 'INT_VEC3', ++ 35669: 'INT_VEC4', ++ 35670: 'BOOL', ++ 35671: 'BOOL_VEC2', ++ 35672: 'BOOL_VEC3', ++ 35673: 'BOOL_VEC4', ++ 35674: 'FLOAT_MAT2', ++ 35675: 'FLOAT_MAT3', ++ 35676: 'FLOAT_MAT4', ++ 35678: 'SAMPLER_2D', ++ 35680: 'SAMPLER_CUBE', ++ 35712: 'DELETE_STATUS', ++ 35713: 'COMPILE_STATUS', ++ 35714: 'LINK_STATUS', ++ 35715: 'VALIDATE_STATUS', ++ 35716: 'INFO_LOG_LENGTH', ++ 35717: 'ATTACHED_SHADERS', ++ 35718: 'ACTIVE_UNIFORMS', ++ 35719: 'ACTIVE_UNIFORM_MAX_LENGTH', ++ 35720: 'SHADER_SOURCE_LENGTH', ++ 35721: 'ACTIVE_ATTRIBUTES', ++ 35722: 'ACTIVE_ATTRIBUTE_MAX_LENGTH', ++ 35724: 'SHADING_LANGUAGE_VERSION', ++ 35725: 'CURRENT_PROGRAM', ++ 36003: 'STENCIL_BACK_REF', ++ 36004: 'STENCIL_BACK_VALUE_MASK', ++ 36005: 'STENCIL_BACK_WRITEMASK', ++ 36006: 'FRAMEBUFFER_BINDING', ++ 36007: 'RENDERBUFFER_BINDING', ++ 36048: 'FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE', ++ 36049: 'FRAMEBUFFER_ATTACHMENT_OBJECT_NAME', ++ 36050: 'FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL', ++ 36051: 'FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE', ++ 36053: 'FRAMEBUFFER_COMPLETE', ++ 36054: 'FRAMEBUFFER_INCOMPLETE_ATTACHMENT', ++ 36055: 'FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT', ++ 36057: 'FRAMEBUFFER_INCOMPLETE_DIMENSIONS', ++ 36061: 'FRAMEBUFFER_UNSUPPORTED', ++ 36064: 'COLOR_ATTACHMENT0', ++ 36096: 'DEPTH_ATTACHMENT', ++ 36128: 'STENCIL_ATTACHMENT', ++ 36160: 'FRAMEBUFFER', ++ 36161: 'RENDERBUFFER', ++ 36162: 'RENDERBUFFER_WIDTH', ++ 36163: 'RENDERBUFFER_HEIGHT', ++ 36164: 'RENDERBUFFER_INTERNAL_FORMAT', ++ 36168: 'STENCIL_INDEX8', ++ 36176: 'RENDERBUFFER_RED_SIZE', ++ 36177: 'RENDERBUFFER_GREEN_SIZE', ++ 36178: 'RENDERBUFFER_BLUE_SIZE', ++ 36179: 'RENDERBUFFER_ALPHA_SIZE', ++ 36180: 'RENDERBUFFER_DEPTH_SIZE', ++ 36181: 'RENDERBUFFER_STENCIL_SIZE', ++ 36194: 'RGB565', ++ 36336: 'LOW_FLOAT', ++ 36337: 'MEDIUM_FLOAT', ++ 36338: 'HIGH_FLOAT', ++ 36339: 'LOW_INT', ++ 36340: 'MEDIUM_INT', ++ 36341: 'HIGH_INT', ++ 36346: 'SHADER_COMPILER', ++ 36347: 'MAX_VERTEX_UNIFORM_VECTORS', ++ 36348: 'MAX_VARYING_VECTORS', ++ 36349: 'MAX_FRAGMENT_UNIFORM_VECTORS', ++ 37440: 'UNPACK_FLIP_Y_WEBGL', ++ 37441: 'UNPACK_PREMULTIPLY_ALPHA_WEBGL', ++ 37442: 'CONTEXT_LOST_WEBGL', ++ 37443: 'UNPACK_COLORSPACE_CONVERSION_WEBGL', ++ 37444: 'BROWSER_DEFAULT_WEBGL' ++} ++ ++},{}],65:[function(require,module,exports){ ++var gl10 = require('./1.0/numbers') ++ ++module.exports = function lookupConstant (number) { ++ return gl10[number] + } + +-},{"gl-texture2d":115}],73:[function(require,module,exports){ ++},{"./1.0/numbers":64}],66:[function(require,module,exports){ + 'use strict' + +-module.exports = createHeatmap2D ++module.exports = createContour2D + +-var bsearch = require('binary-search-bounds') + var iota = require('iota-array') +-var pool = require('typedarray-pool') + var createShader = require('gl-shader') + var createBuffer = require('gl-buffer') ++var ndarray = require('ndarray') ++var surfaceNets = require('surface-nets') ++var cdt2d = require('cdt2d') ++var cleanPSLG = require('clean-pslg') ++var bsearch = require('binary-search-bounds') + + var shaders = require('./lib/shaders') + +-function GLHeatmap2D( ++function GLContour2D ( + plot, + shader, ++ fillShader, + pickShader, + positionBuffer, + colorBuffer, +- idBuffer) { +- this.plot = plot +- this.shader = shader +- this.pickShader = pickShader ++ idBuffer, ++ fillPositionBuffer, ++ fillColorBuffer) { ++ this.plot = plot ++ this.shader = shader ++ this.fillShader = fillShader ++ this.pickShader = pickShader + this.positionBuffer = positionBuffer +- this.colorBuffer = colorBuffer +- this.idBuffer = idBuffer +- this.xData = [] +- this.yData = [] +- this.shape = [0,0] +- this.bounds = [Infinity, Infinity, -Infinity, -Infinity] +- this.pickOffset = 0 ++ this.colorBuffer = colorBuffer ++ this.idBuffer = idBuffer ++ this.fillPositionBuffer = fillPositionBuffer ++ this.fillColorBuffer = fillColorBuffer ++ this.fillVerts = 0 ++ this.xData = [] ++ this.yData = [] ++ this.shape = [0, 0] ++ this.bounds = [Infinity, Infinity, -Infinity, -Infinity] ++ this.pickOffset = 0 ++ this.numVertices = 0 ++ this.lineWidth = 1 + } + +-var proto = GLHeatmap2D.prototype ++var proto = GLContour2D.prototype + + var WEIGHTS = [ +- 0, 0, + 1, 0, ++ 0, 0, + 0, 1, + 1, 0, + 1, 1, + 0, 1 + ] + +-proto.draw = (function() { ++proto.draw = (function () { + var MATRIX = [ + 1, 0, 0, + 0, 1, 0, + 0, 0, 1 + ] + +- return function() { +- var plot = this.plot +- var shader = this.shader +- var bounds = this.bounds +- var numVertices = this.numVertices ++ var SCREEN_SHAPE = [0, 0] + +- var gl = plot.gl +- var viewBox = plot.viewBox +- var dataBox = plot.dataBox ++ return function () { ++ var plot = this.plot ++ var shader = this.shader ++ var fillShader = this.fillShader ++ var bounds = this.bounds ++ var numVertices = this.numVertices ++ var fillVerts = this.fillVerts + +- var boundX = bounds[2] - bounds[0] +- var boundY = bounds[3] - bounds[1] +- var dataX = dataBox[2] - dataBox[0] +- var dataY = dataBox[3] - dataBox[1] ++ var uniforms, attributes ++ ++ var gl = plot.gl ++ var viewBox = plot.viewBox ++ var dataBox = plot.dataBox ++ ++ var boundX = bounds[2] - bounds[0] ++ var boundY = bounds[3] - bounds[1] ++ var dataX = dataBox[2] - dataBox[0] ++ var dataY = dataBox[3] - dataBox[1] + + MATRIX[0] = 2.0 * boundX / dataX + MATRIX[4] = 2.0 * boundY / dataY + MATRIX[6] = 2.0 * (bounds[0] - dataBox[0]) / dataX - 1.0 + MATRIX[7] = 2.0 * (bounds[1] - dataBox[1]) / dataY - 1.0 + +- shader.bind() +- +- var uniforms = shader.uniforms +- uniforms.viewTransform = MATRIX +- +- var attributes = shader.attributes +- this.positionBuffer.bind() +- attributes.position.pointer() ++ SCREEN_SHAPE[0] = viewBox[2] - viewBox[0] ++ SCREEN_SHAPE[1] = viewBox[3] - viewBox[1] + +- this.colorBuffer.bind() +- attributes.color.pointer(gl.UNSIGNED_BYTE, true) ++ if (fillVerts > 0) { ++ fillShader.bind() + +- gl.drawArrays(gl.TRIANGLES, 0, this.numVertices) +- } +-})() ++ uniforms = fillShader.uniforms ++ uniforms.viewTransform = MATRIX ++ uniforms.screenShape = SCREEN_SHAPE + +-proto.drawPick = (function() { +- var MATRIX = [ +- 1, 0, 0, +- 0, 1, 0, +- 0, 0, 1 +- ] ++ attributes = shader.attributes ++ this.fillPositionBuffer.bind() ++ attributes.position.pointer() + +- var PICK_VECTOR = [0,0,0,0] ++ this.fillColorBuffer.bind() ++ attributes.color.pointer(gl.UNSIGNED_BYTE, true) + +- return function(pickOffset) { +- var plot = this.plot +- var shader = this.pickShader +- var bounds = this.bounds +- var numVertices = this.numVertices ++ gl.drawArrays(gl.TRIANGLES, 0, fillVerts) ++ } + +- var gl = plot.gl +- var viewBox = plot.viewBox +- var dataBox = plot.dataBox ++ if (numVertices > 0) { ++ shader.bind() + +- var boundX = bounds[2] - bounds[0] +- var boundY = bounds[3] - bounds[1] +- var dataX = dataBox[2] - dataBox[0] +- var dataY = dataBox[3] - dataBox[1] ++ var lineWidth = this.lineWidth * plot.pixelRatio + +- MATRIX[0] = 2.0 * boundX / dataX +- MATRIX[4] = 2.0 * boundY / dataY +- MATRIX[6] = 2.0 * (bounds[0] - dataBox[0]) / dataX - 1.0 +- MATRIX[7] = 2.0 * (bounds[1] - dataBox[1]) / dataY - 1.0 ++ uniforms = shader.uniforms ++ uniforms.viewTransform = MATRIX ++ uniforms.screenShape = SCREEN_SHAPE ++ uniforms.lineWidth = lineWidth ++ uniforms.pointSize = 1000 + +- for(var i=0; i<4; ++i) { +- PICK_VECTOR[i] = (pickOffset>>(i*8)) & 0xff +- } ++ attributes = shader.attributes + +- this.pickOffset = pickOffset ++ // Draw lines ++ this.positionBuffer.bind() ++ attributes.position.pointer(gl.FLOAT, false, 16, 0) ++ attributes.tangent.pointer(gl.FLOAT, false, 16, 8) + +- shader.bind() ++ this.colorBuffer.bind() ++ attributes.color.pointer(gl.UNSIGNED_BYTE, true) + +- var uniforms = shader.uniforms +- uniforms.viewTransform = MATRIX +- uniforms.pickOffset = PICK_VECTOR ++ gl.drawArrays(gl.TRIANGLES, 0, numVertices) + +- var attributes = shader.attributes +- this.positionBuffer.bind() +- attributes.position.pointer() ++ // Draw end caps ++ uniforms.lineWidth = 0 ++ uniforms.pointSize = lineWidth + +- this.idBuffer.bind() +- attributes.pickId.pointer(gl.UNSIGNED_BYTE, false) ++ this.positionBuffer.bind() ++ attributes.position.pointer(gl.FLOAT, false, 16 * 3, 0) ++ attributes.tangent.pointer(gl.FLOAT, false, 16 * 3, 8) + +- gl.drawArrays(gl.TRIANGLES, 0, this.numVertices) ++ this.colorBuffer.bind() ++ attributes.color.pointer(gl.UNSIGNED_BYTE, true, 4 * 3, 0) + +- return pickOffset + this.shape[0] * this.shape[1] ++ gl.drawArrays(gl.POINTS, 0, numVertices / 3) ++ } + } + })() + +-proto.pick = function(x, y, value) { +- var pickOffset = this.pickOffset +- var pointCount = this.shape[0] * this.shape[1] +- if(value < pickOffset || value >= pickOffset + pointCount) { +- return null ++proto.drawPick = (function () { ++ return function (pickOffset) { ++ return pickOffset + } +- var pointId = value - pickOffset +- var xData = this.xData +- var yData = this.yData +- return { +- object: this, +- pointId: pointId, +- dataCoord: [ +- xData[pointId%this.shape[0]], +- yData[(pointId/this.shape[0])|0] ] ++})() ++ ++proto.pick = function (x, y, value) { ++ return null ++} ++ ++function interpolate (array, point) { ++ var idx = Math.floor(point) ++ if (idx < 0) { ++ return array[0] ++ } else if (idx >= array.length - 1) { ++ return array[array.length - 1] + } ++ var t = point - idx ++ return (1.0 - t) * array[idx] + t * array[idx + 1] + } + +-proto.update = function(options) { ++proto.update = function (options) { + options = options || {} + +- var shape = options.shape || [0,0] ++ var shape = options.shape || [0, 0] + + var x = options.x || iota(shape[0]) + var y = options.y || iota(shape[1]) + var z = options.z || new Float32Array(shape[0] * shape[1]) + +- this.xData = x +- this.yData = y +- +- var colorLevels = options.colorLevels || [0] +- var colorValues = options.colorValues || [0, 0, 0, 1] +- var colorCount = colorLevels.length ++ var levels = options.levels || [] ++ var levelColors = options.levelColors || [] + + var bounds = this.bounds + var lox = bounds[0] = x[0] + var loy = bounds[1] = y[0] +- var hix = bounds[2] = x[x.length-1] +- var hiy = bounds[3] = y[y.length-1] ++ var hix = bounds[2] = x[x.length - 1] ++ var hiy = bounds[3] = y[y.length - 1] ++ ++ if (lox === hix) { ++ bounds[2] += 1 ++ hix += 1 ++ } ++ if (loy === hiy) { ++ bounds[3] += 1 ++ hiy += 1 ++ } + + var xs = 1.0 / (hix - lox) + var ys = 1.0 / (hiy - loy) + +- var numVerts = shape[0] * shape[1] * (WEIGHTS.length>>>1) ++ this.xData = x ++ this.yData = y + +- this.numVertices = numVerts ++ this.lineWidth = options.lineWidth || 1 + +- var colors = pool.mallocUint8 (numVerts * 4) +- var positions = pool.mallocFloat32(numVerts * 2) +- var ids = pool.mallocUint32 (numVerts) ++ var zarray = ndarray(z, shape) + +- var numX = shape[0] +- var numY = shape[1] ++ var positions = [] ++ var colors = [] ++ var ids = [] + +- this.shape = [numX, numY] ++ var fillCells = [] ++ var fillPositions = [ ++ [0, 0], ++ [shape[0] - 1, 0], ++ [0, shape[1] - 1], ++ [shape[0] - 1, shape[1] - 1] ++ ] + +- var ptr = 0 ++ function intersect (level, x, a, b) { ++ var d = (b - a) ++ if (Math.abs(d) < 1e-6) { ++ return x ++ } ++ return Math.floor(x) + Math.max(0.001, Math.min(0.999, (level - a) / d)) ++ } + +- for(var j=0; j 0 && level === levels[i - 1]) { ++ continue ++ } ++ var contour = surfaceNets(zarray, level) + +- for(var dd=0; dd 1) { ++ continue ++ } ++ var ppx = pp[0] ++ var ppy = pp[1] ++ var z00 = zarray.get(Math.floor(ppx), Math.floor(ppy)) ++ var z01 = zarray.get(Math.floor(ppx), Math.ceil(ppy)) ++ var z10 = zarray.get(Math.ceil(ppx), Math.floor(ppy)) ++ var z11 = zarray.get(Math.ceil(ppx), Math.ceil(ppy)) ++ var intercept ++ if (Math.floor(pp[0]) === 0 && ++ ((z00 <= level) !== (z01 < level))) { ++ intercept = [0, intersect(level, pp[1], z00, z01)] ++ } else if (Math.ceil(pp[0]) === shape[0] - 1 && ++ ((z10 <= level) !== (z11 < level))) { ++ intercept = [shape[0] - 1, intersect(level, pp[1], z10, z11)] ++ } else if (Math.floor(pp[1]) === 0 && ++ ((z00 <= level) !== (z10 < level))) { ++ intercept = [intersect(level, pp[0], z00, z10), 0] ++ } else if (Math.ceil(pp[1]) === shape[1] - 1 && ++ ((z01 <= level) !== (z11 < level))) { ++ intercept = [intersect(level, pp[0], z01, z11), shape[1] - 1] ++ } ++ if (intercept) { ++ c_cells.push([j, c_positions.length]) ++ in_degree.push(fillPositions.length) ++ c_positions.push(intercept) ++ } ++ } ++ ++ for (j = 0; j < c_cells.length; ++j) { ++ var e = c_cells[j] ++ var a = c_positions[e[0]] ++ var b = c_positions[e[1]] ++ ++ fillCells.push([in_degree[e[0]], in_degree[e[1]]]) ++ ++ var pointId = Math.round(a[0]) + shape[0] * Math.round(a[1]) ++ ++ var ax = interpolate(x, a[0]) ++ var ay = interpolate(y, a[1]) ++ var bx = interpolate(x, b[0]) ++ var by = interpolate(y, b[1]) ++ ++ ax = xs * (ax - lox) ++ ay = ys * (ay - loy) ++ bx = xs * (bx - lox) ++ by = ys * (by - loy) ++ ++ var dx = ax - bx ++ var dy = ay - by ++ ++ for (var k = 0; k < WEIGHTS.length; k += 2) { ++ var wx = WEIGHTS[k] ++ var wix = 1.0 - wx ++ var wy = 2.0 * WEIGHTS[k + 1] - 1.0 ++ ++ positions.push( ++ wix * ax + wx * bx, wix * ay + wx * by, ++ wy * dx, wy * dy) ++ colors.push(c_r, c_g, c_b, c_a) ++ ids.push(pointId) ++ } ++ } ++ } ++ ++ this.positionBuffer.update(new Float32Array(positions)) ++ this.colorBuffer.update(new Uint8Array(colors)) ++ this.idBuffer.update(new Uint32Array(ids)) ++ this.numVertices = ids.length ++ ++ var fillColors = options.fillColors ++ var fillCellColors = [] ++ var fillCellPositions = [] ++ var fillVerts = 0 ++ ++ if (fillColors) { ++ cleanPSLG(fillPositions, fillCells) ++ var fillMesh = cdt2d(fillPositions, fillCells, { ++ delaunay: false ++ }) ++ for (i = 0; i < fillMesh.length; ++i) { ++ var cell = fillMesh[i] ++ var cx = 0 ++ var cy = 0 ++ ++ for (j = 0; j < 3; ++j) { ++ var p = fillPositions[cell[j]] ++ var px = interpolate(x, p[0]) ++ var py = interpolate(y, p[1]) ++ cx += p[0] ++ cy += p[1] ++ fillCellPositions.push( ++ xs * (px - lox), ++ ys * (py - loy)) ++ } ++ ++ // Compute centroid of triangle ++ cx /= 3 ++ cy /= 3 ++ ++ // Sample height field at triangle centroid ++ var cxi = Math.floor(cx) ++ var cyi = Math.floor(cy) ++ var cxf = cx - cxi ++ var cyf = cy - cyi ++ ++ var c00 = zarray.get(cxi, cyi) ++ var c01 = zarray.get(cxi, cyi + 1) ++ var c10 = zarray.get(cxi + 1, cyi) ++ var c11 = zarray.get(cxi + 1, cyi + 1) ++ ++ var zlevel = ++ (1 - cyf) * ((1 - cxf) * c00 + cxf * c10) + ++ cyf * ((1 - cxf) * c01 + cxf * c11) ++ ++ // Color triangle using centroid data ++ var l = bsearch.le(levels, zlevel) + 1 ++ var cr = (255 * fillColors[4 * l + 0]) | 0 ++ var cg = (255 * fillColors[4 * l + 1]) | 0 ++ var cb = (255 * fillColors[4 * l + 2]) | 0 ++ var ca = (255 * fillColors[4 * l + 3]) | 0 ++ ++ fillCellColors.push( ++ cr, cg, cb, ca, ++ cr, cg, cb, ca, ++ cr, cg, cb, ca) ++ ++ fillVerts += 3 ++ } ++ ++ this.fillPositionBuffer.update(new Float32Array(fillCellPositions)) ++ this.fillColorBuffer.update(new Uint8Array(fillCellColors)) ++ ++ this.fillVerts = fillVerts ++ } ++} ++ ++proto.dispose = function () { ++ this.plot.removeObject(this) ++} ++ ++function createContour2D (plot, options) { ++ var gl = plot.gl ++ ++ var shader = createShader(gl, shaders.vertex, shaders.fragment) ++ var pickShader = createShader(gl, shaders.pickVertex, shaders.pickFragment) ++ var fillShader = createShader(gl, shaders.fillVertex, shaders.fragment) ++ ++ var positionBuffer = createBuffer(gl) ++ var colorBuffer = createBuffer(gl) ++ var idBuffer = createBuffer(gl) ++ ++ var fillPositionBuffer = createBuffer(gl) ++ var fillColorBuffer = createBuffer(gl) ++ ++ var contours = new GLContour2D( ++ plot, ++ shader, ++ fillShader, ++ pickShader, ++ positionBuffer, ++ colorBuffer, ++ idBuffer, ++ fillPositionBuffer, ++ fillColorBuffer) ++ ++ contours.update(options) ++ plot.addObject(contours) ++ ++ return contours ++} ++ ++},{"./lib/shaders":67,"binary-search-bounds":68,"cdt2d":40,"clean-pslg":46,"gl-buffer":63,"gl-shader":96,"iota-array":116,"ndarray":123,"surface-nets":155}],67:[function(require,module,exports){ ++'use strict' ++ ++ ++ ++module.exports = { ++ fragment: "precision lowp float;\n#define GLSLIFY 1\nvarying vec4 fragColor;\nvoid main() {\n gl_FragColor = vec4(fragColor.rgb * fragColor.a, fragColor.a);\n}\n", ++ vertex: "precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec2 tangent;\nattribute vec4 color;\n\nuniform mat3 viewTransform;\nuniform vec2 screenShape;\nuniform float lineWidth;\nuniform float pointSize;\n\nvarying vec4 fragColor;\n\nvoid main() {\n fragColor = color;\n\n vec3 vPosition = viewTransform * vec3(position, 1.0);\n vec2 vTangent = normalize(viewTransform * vec3(tangent, 0)).xy;\n vec2 offset = vec2(vTangent.y, -vTangent.x) / screenShape;\n\n gl_Position = vec4(\n vPosition.xy + offset * lineWidth * vPosition.z,\n 0,\n vPosition.z);\n\n gl_PointSize = pointSize;\n}\n", ++ pickFragment: "precision lowp float;\n#define GLSLIFY 1\nvarying vec4 fragId;\nvoid main() {\n gl_FragColor = fragId;\n}\n", ++ pickVertex: "precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec4 pickId;\n\nuniform mat3 viewTransform;\nuniform vec4 pickOffset;\n\nvarying vec4 fragId;\n\nvoid main() {\n vec4 id = pickId + pickOffset;\n id.y += floor(id.x / 256.0);\n id.x -= floor(id.x / 256.0) * 256.0;\n\n id.z += floor(id.y / 256.0);\n id.y -= floor(id.y / 256.0) * 256.0;\n\n id.w += floor(id.z / 256.0);\n id.z -= floor(id.z / 256.0) * 256.0;\n\n fragId = id / 255.0;\n\n vec3 vPosition = viewTransform * vec3(position, 1.0);\n gl_Position = vec4(vPosition.xy, 0, vPosition.z);\n}\n", ++ fillVertex: "precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec4 color;\n\nuniform mat3 viewTransform;\n\nvarying vec4 fragColor;\n\nvoid main() {\n fragColor = color;\n vec3 vPosition = viewTransform * vec3(position, 1.0);\n gl_Position = vec4(vPosition.xy, 0, vPosition.z);\n}\n" ++} ++ ++},{}],68:[function(require,module,exports){ ++arguments[4][45][0].apply(exports,arguments) ++},{"dup":45}],69:[function(require,module,exports){ ++'use strict' ++ ++var createShader = require('gl-shader') ++var createBuffer = require('gl-buffer') ++var pool = require('typedarray-pool') ++var shaders = require('./lib/shaders') ++ ++module.exports = createError2D ++ ++var WEIGHTS = [ ++ // x-error bar ++ [1, 0, 0, 1, 0, 0], ++ [1, 0, 0, -1, 0, 0], ++ [-1, 0, 0, -1, 0, 0], ++ ++ [-1, 0, 0, -1, 0, 0], ++ [-1, 0, 0, 1, 0, 0], ++ [1, 0, 0, 1, 0, 0], ++ ++ // x-error right cap ++ [1, 0, -1, 0, 0, 1], ++ [1, 0, -1, 0, 0, -1], ++ [1, 0, 1, 0, 0, -1], ++ ++ [1, 0, 1, 0, 0, -1], ++ [1, 0, 1, 0, 0, 1], ++ [1, 0, -1, 0, 0, 1], ++ ++ // x-error left cap ++ [-1, 0, -1, 0, 0, 1], ++ [-1, 0, -1, 0, 0, -1], ++ [-1, 0, 1, 0, 0, -1], ++ ++ [-1, 0, 1, 0, 0, -1], ++ [-1, 0, 1, 0, 0, 1], ++ [-1, 0, -1, 0, 0, 1], ++ ++ // y-error bar ++ [0, 1, 1, 0, 0, 0], ++ [0, 1, -1, 0, 0, 0], ++ [0, -1, -1, 0, 0, 0], + +- colors[4*ptr] = 255*r +- colors[4*ptr+1] = 255*g +- colors[4*ptr+2] = 255*b +- colors[4*ptr+3] = 255*a ++ [0, -1, -1, 0, 0, 0], ++ [0, 1, 1, 0, 0, 0], ++ [0, -1, 1, 0, 0, 0], + +- positions[2*ptr] = (1 - dx) * xc0 + dx * xc1 +- positions[2*ptr+1] = (1 - dy) * yc0 + dy * yc1 ++ // y-error top cap ++ [0, 1, 0, -1, 1, 0], ++ [0, 1, 0, -1, -1, 0], ++ [0, 1, 0, 1, -1, 0], + +- ids[ptr] = j*numX + i ++ [0, 1, 0, 1, 1, 0], ++ [0, 1, 0, -1, 1, 0], ++ [0, 1, 0, 1, -1, 0], + +- ptr += 1 +- } +- } +- } ++ // y-error bottom cap ++ [0, -1, 0, -1, 1, 0], ++ [0, -1, 0, -1, -1, 0], ++ [0, -1, 0, 1, -1, 0], + +- this.positionBuffer.update(positions) +- this.colorBuffer. update(colors) +- this.idBuffer. update(ids) ++ [0, -1, 0, 1, 1, 0], ++ [0, -1, 0, -1, 1, 0], ++ [0, -1, 0, 1, -1, 0] ++] + +- pool.free(positions) +- pool.free(colors) +- pool.free(ids) +-} ++function GLError2D (plot, shader, buffer) { ++ this.plot = plot + +-proto.dispose = function() { +- this.shader.dispose() +- this.pickShader.dispose() +- this.positionBuffer.dispose() +- this.colorBuffer.dispose() +- this.idBuffer.dispose() +- this.plot.removeObject(this) +-} ++ this.shader = shader ++ this.buffer = buffer + +-function createHeatmap2D(plot, options) { +- var gl = plot.gl ++ this.bounds = [Infinity, Infinity, -Infinity, -Infinity] + +- var shader = createShader(gl, shaders.vertex, shaders.fragment) +- var pickShader = createShader(gl, shaders.pickVertex, shaders.pickFragment) ++ this.numPoints = 0 + +- var positionBuffer = createBuffer(gl) +- var colorBuffer = createBuffer(gl) +- var idBuffer = createBuffer(gl) ++ this.color = [0, 0, 0, 1] ++} + +- var heatmap = new GLHeatmap2D( +- plot, +- shader, +- pickShader, +- positionBuffer, +- colorBuffer, +- idBuffer) ++var proto = GLError2D.prototype + +- heatmap.update(options) +- plot.addObject(heatmap) ++proto.draw = (function () { ++ var MATRIX = [ ++ 1, 0, 0, ++ 0, 1, 0, ++ 0, 0, 1 ++ ] + +- return heatmap +-} ++ var PIXEL_SCALE = [1, 1] + +-},{"./lib/shaders":74,"binary-search-bounds":75,"gl-buffer":66,"gl-shader":96,"iota-array":123,"typedarray-pool":151}],74:[function(require,module,exports){ +-'use strict' ++ return function () { ++ var plot = this.plot ++ var shader = this.shader ++ var buffer = this.buffer ++ var bounds = this.bounds ++ var numPoints = this.numPoints + ++ if (!numPoints) { ++ return ++ } + ++ var gl = plot.gl ++ var dataBox = plot.dataBox ++ var viewBox = plot.viewBox ++ var pixelRatio = plot.pixelRatio + +-module.exports = { +- fragment: "precision lowp float;\n#define GLSLIFY 1\nvarying vec4 fragColor;\nvoid main() {\n gl_FragColor = vec4(fragColor.rgb * fragColor.a, fragColor.a);\n}\n", +- vertex: "precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec4 color;\n\nuniform mat3 viewTransform;\n\nvarying vec4 fragColor;\n\nvoid main() {\n vec3 vPosition = viewTransform * vec3(position, 1.0);\n fragColor = color;\n gl_Position = vec4(vPosition.xy, 0, vPosition.z);\n}\n", +- pickFragment: "precision lowp float;\n#define GLSLIFY 1\nvarying vec4 fragId;\nvoid main() {\n gl_FragColor = fragId;\n}\n", +- pickVertex: "precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec4 pickId;\n\nuniform mat3 viewTransform;\nuniform vec4 pickOffset;\n\nvarying vec4 fragId;\n\nvoid main() {\n vec4 id = pickId + pickOffset;\n id.y += floor(id.x / 256.0);\n id.x -= floor(id.x / 256.0) * 256.0;\n\n id.z += floor(id.y / 256.0);\n id.y -= floor(id.y / 256.0) * 256.0;\n\n id.w += floor(id.z / 256.0);\n id.z -= floor(id.z / 256.0) * 256.0;\n\n fragId = id / 255.0;\n\n vec3 vPosition = viewTransform * vec3(position, 1.0);\n gl_Position = vec4(vPosition.xy, 0, vPosition.z);\n}\n" +-} ++ var boundX = bounds[2] - bounds[0] ++ var boundY = bounds[3] - bounds[1] ++ var dataX = dataBox[2] - dataBox[0] ++ var dataY = dataBox[3] - dataBox[1] + +-},{}],75:[function(require,module,exports){ +-arguments[4][21][0].apply(exports,arguments) +-},{"dup":21}],76:[function(require,module,exports){ ++ MATRIX[0] = 2.0 * boundX / dataX ++ MATRIX[4] = 2.0 * boundY / dataY ++ MATRIX[6] = 2.0 * (bounds[0] - dataBox[0]) / dataX - 1.0 ++ MATRIX[7] = 2.0 * (bounds[1] - dataBox[1]) / dataY - 1.0 + ++ var screenX = viewBox[2] - viewBox[0] ++ var screenY = viewBox[3] - viewBox[1] + +-exports.lineVertex = "precision mediump float;\n#define GLSLIFY 1\n\nfloat inverse_1_0(float m) {\n return 1.0 / m;\n}\n\nmat2 inverse_1_0(mat2 m) {\n return mat2(m[1][1],-m[0][1],\n -m[1][0], m[0][0]) / (m[0][0]*m[1][1] - m[0][1]*m[1][0]);\n}\n\nmat3 inverse_1_0(mat3 m) {\n float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];\n float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];\n float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];\n\n float b01 = a22 * a11 - a12 * a21;\n float b11 = -a22 * a10 + a12 * a20;\n float b21 = a21 * a10 - a11 * a20;\n\n float det = a00 * b01 + a01 * b11 + a02 * b21;\n\n return mat3(b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11),\n b11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10),\n b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)) / det;\n}\n\nmat4 inverse_1_0(mat4 m) {\n float\n a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],\n a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],\n a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],\n a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3],\n\n b00 = a00 * a11 - a01 * a10,\n b01 = a00 * a12 - a02 * a10,\n b02 = a00 * a13 - a03 * a10,\n b03 = a01 * a12 - a02 * a11,\n b04 = a01 * a13 - a03 * a11,\n b05 = a02 * a13 - a03 * a12,\n b06 = a20 * a31 - a21 * a30,\n b07 = a20 * a32 - a22 * a30,\n b08 = a20 * a33 - a23 * a30,\n b09 = a21 * a32 - a22 * a31,\n b10 = a21 * a33 - a23 * a31,\n b11 = a22 * a33 - a23 * a32,\n\n det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\n return mat4(\n a11 * b11 - a12 * b10 + a13 * b09,\n a02 * b10 - a01 * b11 - a03 * b09,\n a31 * b05 - a32 * b04 + a33 * b03,\n a22 * b04 - a21 * b05 - a23 * b03,\n a12 * b08 - a10 * b11 - a13 * b07,\n a00 * b11 - a02 * b08 + a03 * b07,\n a32 * b02 - a30 * b05 - a33 * b01,\n a20 * b05 - a22 * b02 + a23 * b01,\n a10 * b10 - a11 * b08 + a13 * b06,\n a01 * b08 - a00 * b10 - a03 * b06,\n a30 * b04 - a31 * b02 + a33 * b00,\n a21 * b02 - a20 * b04 - a23 * b00,\n a11 * b07 - a10 * b09 - a12 * b06,\n a00 * b09 - a01 * b07 + a02 * b06,\n a31 * b01 - a30 * b03 - a32 * b00,\n a20 * b03 - a21 * b01 + a22 * b00) / det;\n}\n\n\n\nattribute vec2 a, d;\n\nuniform mat3 matrix;\nuniform vec2 screenShape;\nuniform float width;\n\nvarying vec2 direction;\n\nvoid main() {\n vec2 dir = (matrix * vec3(d, 0)).xy;\n vec3 base = matrix * vec3(a, 1);\n vec2 n = 0.5 * width *\n normalize(screenShape.yx * vec2(dir.y, -dir.x)) / screenShape.xy;\n vec2 tangent = normalize(screenShape.xy * dir);\n if(dir.x < 0.0 || (dir.x == 0.0 && dir.y < 0.0)) {\n direction = -tangent;\n } else {\n direction = tangent;\n }\n gl_Position = vec4(base.xy/base.z + n, 0, 1);\n}\n" +-exports.lineFragment = "precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 color;\nuniform vec2 screenShape;\nuniform sampler2D dashPattern;\nuniform float dashLength;\n\nvarying vec2 direction;\n\nvoid main() {\n float t = fract(dot(direction, gl_FragCoord.xy) / dashLength);\n vec4 pcolor = color * texture2D(dashPattern, vec2(t, 0.0)).r;\n gl_FragColor = vec4(pcolor.rgb * pcolor.a, pcolor.a);\n}\n" +-exports.mitreVertex = "precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 p;\n\nuniform mat3 matrix;\nuniform vec2 screenShape;\nuniform float radius;\n\nvoid main() {\n vec3 pp = matrix * vec3(p, 1);\n gl_Position = vec4(pp.xy, 0, pp.z);\n gl_PointSize = radius;\n}\n" +-exports.mitreFragment = "precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 color;\n\nvoid main() {\n if(length(gl_PointCoord.xy - 0.5) > 0.25) {\n discard;\n }\n gl_FragColor = vec4(color.rgb, color.a);\n}\n" +-exports.pickVertex = "precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 a, d;\nattribute vec4 pick0, pick1;\n\nuniform mat3 matrix;\nuniform vec2 screenShape;\nuniform float width;\n\nvarying vec4 pickA, pickB;\n\nfloat inverse_1_0(float m) {\n return 1.0 / m;\n}\n\nmat2 inverse_1_0(mat2 m) {\n return mat2(m[1][1],-m[0][1],\n -m[1][0], m[0][0]) / (m[0][0]*m[1][1] - m[0][1]*m[1][0]);\n}\n\nmat3 inverse_1_0(mat3 m) {\n float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];\n float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];\n float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];\n\n float b01 = a22 * a11 - a12 * a21;\n float b11 = -a22 * a10 + a12 * a20;\n float b21 = a21 * a10 - a11 * a20;\n\n float det = a00 * b01 + a01 * b11 + a02 * b21;\n\n return mat3(b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11),\n b11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10),\n b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)) / det;\n}\n\nmat4 inverse_1_0(mat4 m) {\n float\n a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],\n a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],\n a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],\n a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3],\n\n b00 = a00 * a11 - a01 * a10,\n b01 = a00 * a12 - a02 * a10,\n b02 = a00 * a13 - a03 * a10,\n b03 = a01 * a12 - a02 * a11,\n b04 = a01 * a13 - a03 * a11,\n b05 = a02 * a13 - a03 * a12,\n b06 = a20 * a31 - a21 * a30,\n b07 = a20 * a32 - a22 * a30,\n b08 = a20 * a33 - a23 * a30,\n b09 = a21 * a32 - a22 * a31,\n b10 = a21 * a33 - a23 * a31,\n b11 = a22 * a33 - a23 * a32,\n\n det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\n return mat4(\n a11 * b11 - a12 * b10 + a13 * b09,\n a02 * b10 - a01 * b11 - a03 * b09,\n a31 * b05 - a32 * b04 + a33 * b03,\n a22 * b04 - a21 * b05 - a23 * b03,\n a12 * b08 - a10 * b11 - a13 * b07,\n a00 * b11 - a02 * b08 + a03 * b07,\n a32 * b02 - a30 * b05 - a33 * b01,\n a20 * b05 - a22 * b02 + a23 * b01,\n a10 * b10 - a11 * b08 + a13 * b06,\n a01 * b08 - a00 * b10 - a03 * b06,\n a30 * b04 - a31 * b02 + a33 * b00,\n a21 * b02 - a20 * b04 - a23 * b00,\n a11 * b07 - a10 * b09 - a12 * b06,\n a00 * b09 - a01 * b07 + a02 * b06,\n a31 * b01 - a30 * b03 - a32 * b00,\n a20 * b03 - a21 * b01 + a22 * b00) / det;\n}\n\n\n\nvoid main() {\n vec3 base = matrix * vec3(a, 1);\n vec2 n = width *\n normalize(screenShape.yx * vec2(d.y, -d.x)) / screenShape.xy;\n gl_Position = vec4(base.xy/base.z + n, 0, 1);\n pickA = pick0;\n pickB = pick1;\n}\n" +-exports.pickFragment = "precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 pickOffset;\n\nvarying vec4 pickA, pickB;\n\nvoid main() {\n vec4 fragId = vec4(pickA.xyz, 0.0);\n if(pickB.w > pickA.w) {\n fragId.xyz = pickB.xyz;\n }\n\n fragId += pickOffset;\n\n fragId.y += floor(fragId.x / 256.0);\n fragId.x -= floor(fragId.x / 256.0) * 256.0;\n\n fragId.z += floor(fragId.y / 256.0);\n fragId.y -= floor(fragId.y / 256.0) * 256.0;\n\n fragId.w += floor(fragId.z / 256.0);\n fragId.z -= floor(fragId.z / 256.0) * 256.0;\n\n gl_FragColor = fragId / 255.0;\n}\n" +-exports.fillVertex = "precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 a, d;\n\nuniform mat3 matrix;\nuniform vec2 projectAxis;\nuniform float projectValue;\nuniform float depth;\n\nvoid main() {\n vec3 base = matrix * vec3(a, 1);\n vec2 p = base.xy / base.z;\n if(d.y < 0.0 || (d.y == 0.0 && d.x < 0.0)) {\n if(dot(p, projectAxis) < projectValue) {\n p = p * (1.0 - abs(projectAxis)) + projectAxis * projectValue;\n }\n }\n gl_Position = vec4(p, depth, 1);\n}\n" +-exports.fillFragment = "precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 color;\n\nvoid main() {\n gl_FragColor = vec4(color.rgb * color.a, color.a);\n}\n" ++ PIXEL_SCALE[0] = 2.0 * pixelRatio / screenX ++ PIXEL_SCALE[1] = 2.0 * pixelRatio / screenY + +-},{}],77:[function(require,module,exports){ +-'use strict' ++ buffer.bind() ++ shader.bind() + +-module.exports = createLinePlot ++ shader.uniforms.viewTransform = MATRIX ++ shader.uniforms.pixelScale = PIXEL_SCALE ++ shader.uniforms.color = this.color + +-var createShader = require('gl-shader') +-var createBuffer = require('gl-buffer') +-var createTexture = require('gl-texture2d') +-var ndarray = require('ndarray') +-var pool = require('typedarray-pool') ++ shader.attributes.position.pointer( ++ gl.FLOAT, ++ false, ++ 16, ++ 0) + +-var SHADERS = require('./lib/shaders') ++ shader.attributes.pixelOffset.pointer( ++ gl.FLOAT, ++ false, ++ 16, ++ 8) + +-function GLLine2D( +- plot, +- dashPattern, +- lineBuffer, +- pickBuffer, +- lineShader, +- mitreShader, +- fillShader, +- pickShader) { ++ gl.drawArrays(gl.TRIANGLES, 0, numPoints * WEIGHTS.length) ++ } ++})() + +- this.plot = plot +- this.dashPattern = dashPattern +- this.lineBuffer = lineBuffer +- this.pickBuffer = pickBuffer +- this.lineShader = lineShader +- this.mitreShader = mitreShader +- this.fillShader = fillShader +- this.pickShader = pickShader +- this.usingDashes = false ++proto.drawPick = function (offset) { return offset } ++proto.pick = function (x, y) { ++ return null ++} + +- this.bounds = [Infinity, Infinity, -Infinity, -Infinity] ++proto.update = function (options) { ++ options = options || {} + +- this.width = 1 +- this.color = [0,0,1,1] ++ var i, x, y + +- //Fill to axes +- this.fill = [false, false, false, false] +- this.fillColor = [[0,0,0,1], +- [0,0,0,1], +- [0,0,0,1], +- [0,0,0,1]] ++ var positions = options.positions || [] ++ var errors = options.errors || [] + +- this.data = null +- this.numPoints = 0 +- this.vertCount = 0 ++ var lineWidth = 1 ++ if ('lineWidth' in options) { ++ lineWidth = +options.lineWidth ++ } + +- this.pickOffset = 0 ++ var capSize = 5 ++ if ('capSize' in options) { ++ capSize = +options.capSize ++ } + +- this.lodBuffer = [] +-} ++ this.color = (options.color || [0, 0, 0, 1]).slice() + +-var proto = GLLine2D.prototype ++ var bounds = this.bounds = [Infinity, Infinity, -Infinity, -Infinity] + +-proto.draw = (function() { +-var MATRIX = [1, 0, 0, +- 0, 1, 0, +- 0, 0, 1] +-var SCREEN_SHAPE = [0,0] +-var PX_AXIS = [1,0] +-var NX_AXIS = [-1,0] +-var PY_AXIS = [0,1] +-var NY_AXIS = [0,-1] +-return function() { +- var plot = this.plot +- var color = this.color +- var width = this.width +- var numPoints = this.numPoints +- var bounds = this.bounds +- var count = this.vertCount ++ var numPoints = this.numPoints = positions.length >> 1 ++ for (i = 0; i < numPoints; ++i) { ++ x = positions[i * 2] ++ y = positions[i * 2 + 1] + +- if(!count) { +- return ++ bounds[0] = Math.min(x, bounds[0]) ++ bounds[1] = Math.min(y, bounds[1]) ++ bounds[2] = Math.max(x, bounds[2]) ++ bounds[3] = Math.max(y, bounds[3]) ++ } ++ if (bounds[2] === bounds[0]) { ++ bounds[2] += 1 + } ++ if (bounds[3] === bounds[1]) { ++ bounds[3] += 1 ++ } ++ var sx = 1.0 / (bounds[2] - bounds[0]) ++ var sy = 1.0 / (bounds[3] - bounds[1]) ++ var tx = bounds[0] ++ var ty = bounds[1] + +- var gl = plot.gl +- var viewBox = plot.viewBox +- var dataBox = plot.dataBox +- var pixelRatio = plot.pixelRatio ++ var bufferData = pool.mallocFloat32(numPoints * WEIGHTS.length * 4) ++ var ptr = 0 ++ for (i = 0; i < numPoints; ++i) { ++ x = positions[2 * i] ++ y = positions[2 * i + 1] ++ var ex0 = errors[4 * i] ++ var ex1 = errors[4 * i + 1] ++ var ey0 = errors[4 * i + 2] ++ var ey1 = errors[4 * i + 3] + +- var boundX = bounds[2] - bounds[0] +- var boundY = bounds[3] - bounds[1] +- var dataX = dataBox[2] - dataBox[0] +- var dataY = dataBox[3] - dataBox[1] +- var screenX = viewBox[2] - viewBox[0] +- var screenY = viewBox[3] - viewBox[1] ++ for (var j = 0; j < WEIGHTS.length; ++j) { ++ var w = WEIGHTS[j] + +- MATRIX[0] = 2.0 * boundX / dataX +- MATRIX[4] = 2.0 * boundY / dataY +- MATRIX[6] = 2.0 * (bounds[0] - dataBox[0]) / dataX - 1.0 +- MATRIX[7] = 2.0 * (bounds[1] - dataBox[1]) / dataY - 1.0 ++ var dx = w[0] ++ var dy = w[1] + +- SCREEN_SHAPE[0] = screenX +- SCREEN_SHAPE[1] = screenY ++ if (dx < 0) { ++ dx *= ex0 ++ } else if (dx > 0) { ++ dx *= ex1 ++ } + +- var buffer = this.lineBuffer +- buffer.bind() ++ if (dy < 0) { ++ dy *= ey0 ++ } else if (dy > 0) { ++ dy *= ey1 ++ } + +- var fill = this.fill ++ bufferData[ptr++] = sx * ((x - tx) + dx) ++ bufferData[ptr++] = sy * ((y - ty) + dy) ++ bufferData[ptr++] = lineWidth * w[2] + (capSize + lineWidth) * w[4] ++ bufferData[ptr++] = lineWidth * w[3] + (capSize + lineWidth) * w[5] ++ } ++ } ++ this.buffer.update(bufferData) ++ pool.free(bufferData) ++} + +- if(fill[0] || fill[1] || fill[2] || fill[3]) { ++proto.dispose = function () { ++ this.plot.removeObject(this) ++ this.shader.dispose() ++ this.buffer.dispose() ++} + +- var fillShader = this.fillShader +- fillShader.bind() ++function createError2D (plot, options) { ++ var shader = createShader(plot.gl, shaders.vertex, shaders.fragment) ++ var buffer = createBuffer(plot.gl) + +- var fillUniforms = fillShader.uniforms +- fillUniforms.matrix = MATRIX +- fillUniforms.depth = plot.nextDepthValue() ++ var errorbars = new GLError2D(plot, shader, buffer) + +- var fillAttributes = fillShader.attributes +- fillAttributes.a.pointer(gl.FLOAT, false, 16, 0) +- fillAttributes.d.pointer(gl.FLOAT, false, 16, 8) ++ errorbars.update(options) + +- gl.depthMask(true) +- gl.enable(gl.DEPTH_TEST) ++ plot.addObject(errorbars) + +- var fillColor = this.fillColor +- if(fill[0]) { +- fillUniforms.color = fillColor[0] +- fillUniforms.projectAxis = NX_AXIS +- fillUniforms.projectValue = 1 +- gl.drawArrays(gl.TRIANGLES, 0, count) +- } ++ return errorbars ++} + +- if(fill[1]) { +- fillUniforms.color = fillColor[1] +- fillUniforms.projectAxis = NY_AXIS +- fillUniforms.projectValue = 1 +- gl.drawArrays(gl.TRIANGLES, 0, count) +- } ++},{"./lib/shaders":70,"gl-buffer":63,"gl-shader":96,"typedarray-pool":162}],70:[function(require,module,exports){ + +- if(fill[2]) { +- fillUniforms.color = fillColor[2] +- fillUniforms.projectAxis = PX_AXIS +- fillUniforms.projectValue = 1 +- gl.drawArrays(gl.TRIANGLES, 0, count) +- } + +- if(fill[3]) { +- fillUniforms.color = fillColor[3] +- fillUniforms.projectAxis = PY_AXIS +- fillUniforms.projectValue = 1 +- gl.drawArrays(gl.TRIANGLES, 0, count) +- } ++module.exports = { ++ vertex: "precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec2 pixelOffset;\n\nuniform mat3 viewTransform;\nuniform vec2 pixelScale;\n\nvoid main() {\n vec3 scrPosition = viewTransform * vec3(position, 1);\n gl_Position = vec4(\n scrPosition.xy + scrPosition.z * pixelScale * pixelOffset,\n 0,\n scrPosition.z);\n}\n", ++ fragment: "precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 color;\n\nvoid main() {\n gl_FragColor = vec4(color.rgb * color.a, color.a);\n}\n" ++} + +- gl.depthMask(false) +- gl.disable(gl.DEPTH_TEST) +- } ++},{}],71:[function(require,module,exports){ ++'use strict' + +- var shader = this.lineShader +- shader.bind() ++var createTexture = require('gl-texture2d') + +- var uniforms = shader.uniforms +- uniforms.matrix = MATRIX +- uniforms.color = color +- uniforms.width = width * pixelRatio +- uniforms.screenShape = SCREEN_SHAPE +- uniforms.dashPattern = this.dashPattern.bind() +- uniforms.dashLength = this.dashLength * pixelRatio ++module.exports = createFBO + +- var attributes = shader.attributes +- attributes.a.pointer(gl.FLOAT, false, 16, 0) +- attributes.d.pointer(gl.FLOAT, false, 16, 8) ++var colorAttachmentArrays = null ++var FRAMEBUFFER_UNSUPPORTED ++var FRAMEBUFFER_INCOMPLETE_ATTACHMENT ++var FRAMEBUFFER_INCOMPLETE_DIMENSIONS ++var FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT + +- gl.drawArrays(gl.TRIANGLES, 0, count) ++function saveFBOState(gl) { ++ var fbo = gl.getParameter(gl.FRAMEBUFFER_BINDING) ++ var rbo = gl.getParameter(gl.RENDERBUFFER_BINDING) ++ var tex = gl.getParameter(gl.TEXTURE_BINDING_2D) ++ return [fbo, rbo, tex] ++} + +- //Draw mitres +- if(width > 2 && !this.usingDashes) { +- var mshader = this.mitreShader +- mshader.bind() ++function restoreFBOState(gl, data) { ++ gl.bindFramebuffer(gl.FRAMEBUFFER, data[0]) ++ gl.bindRenderbuffer(gl.RENDERBUFFER, data[1]) ++ gl.bindTexture(gl.TEXTURE_2D, data[2]) ++} + +- var muniforms = mshader.uniforms +- muniforms.matrix = MATRIX +- muniforms.color = color +- muniforms.screenShape = SCREEN_SHAPE +- muniforms.radius = width * pixelRatio ++function lazyInitColorAttachments(gl, ext) { ++ var maxColorAttachments = gl.getParameter(ext.MAX_COLOR_ATTACHMENTS_WEBGL) ++ colorAttachmentArrays = new Array(maxColorAttachments + 1) ++ for(var i=0; i<=maxColorAttachments; ++i) { ++ var x = new Array(maxColorAttachments) ++ for(var j=0; j 1) { ++ ext.drawBuffersWEBGL(colorAttachmentArrays[numColors]) ++ } + +- MATRIX[0] = 2.0 * boundX / dataX +- MATRIX[4] = 2.0 * boundY / dataY +- MATRIX[6] = 2.0 * (bounds[0] - dataBox[0]) / dataX - 1.0 +- MATRIX[7] = 2.0 * (bounds[1] - dataBox[1]) / dataY - 1.0 ++ //Allocate depth/stencil buffers ++ var WEBGL_depth_texture = gl.getExtension('WEBGL_depth_texture') ++ if(WEBGL_depth_texture) { ++ if(useStencil) { ++ fbo.depth = initTexture(gl, width, height, ++ WEBGL_depth_texture.UNSIGNED_INT_24_8_WEBGL, ++ gl.DEPTH_STENCIL, ++ gl.DEPTH_STENCIL_ATTACHMENT) ++ } else if(useDepth) { ++ fbo.depth = initTexture(gl, width, height, ++ gl.UNSIGNED_SHORT, ++ gl.DEPTH_COMPONENT, ++ gl.DEPTH_ATTACHMENT) ++ } ++ } else { ++ if(useDepth && useStencil) { ++ fbo._depth_rb = initRenderBuffer(gl, width, height, gl.DEPTH_STENCIL, gl.DEPTH_STENCIL_ATTACHMENT) ++ } else if(useDepth) { ++ fbo._depth_rb = initRenderBuffer(gl, width, height, gl.DEPTH_COMPONENT16, gl.DEPTH_ATTACHMENT) ++ } else if(useStencil) { ++ fbo._depth_rb = initRenderBuffer(gl, width, height, gl.STENCIL_INDEX, gl.STENCIL_ATTACHMENT) ++ } ++ } + +- SCREEN_SHAPE[0] = screenX +- SCREEN_SHAPE[1] = screenY ++ //Check frame buffer state ++ var status = gl.checkFramebufferStatus(gl.FRAMEBUFFER) ++ if(status !== gl.FRAMEBUFFER_COMPLETE) { + +- PICK_OFFSET[0] = pickOffset & 0xff +- PICK_OFFSET[1] = (pickOffset>>>8) & 0xff +- PICK_OFFSET[2] = (pickOffset>>>16) & 0xff +- PICK_OFFSET[3] = pickOffset>>>24 ++ //Release all partially allocated resources ++ fbo._destroyed = true + +- shader.bind() ++ //Release all resources ++ gl.bindFramebuffer(gl.FRAMEBUFFER, null) ++ gl.deleteFramebuffer(fbo.handle) ++ fbo.handle = null ++ if(fbo.depth) { ++ fbo.depth.dispose() ++ fbo.depth = null ++ } ++ if(fbo._depth_rb) { ++ gl.deleteRenderbuffer(fbo._depth_rb) ++ fbo._depth_rb = null ++ } ++ for(var i=0; i= pickOffset + pointCount) { +- return null +- } +- var pointId = value - pickOffset +- var points = this.data +- return { +- object: this, +- pointId: pointId, +- dataCoord: [ points[2*pointId], points[2*pointId+1] ] +- } +-} ++ //Save depth and stencil flags ++ this._colorType = colorType ++ this._useDepth = useDepth ++ this._useStencil = useStencil + +-function deepCopy(arr) { +- return arr.map(function(x) { +- return x.slice() ++ //Shape vector for resizing ++ var parent = this ++ var shapeVector = [width|0, height|0] ++ Object.defineProperties(shapeVector, { ++ 0: { ++ get: function() { ++ return parent._shape[0] ++ }, ++ set: function(w) { ++ return parent.width = w ++ } ++ }, ++ 1: { ++ get: function() { ++ return parent._shape[1] ++ }, ++ set: function(h) { ++ return parent.height = h ++ } ++ } + }) +-} ++ this._shapeVector = shapeVector + +-proto.update = function(options) { +- options = options || {} ++ //Initialize all attachments ++ rebuildFBO(this) ++} + +- var gl = this.plot.gl ++var proto = Framebuffer.prototype + +- var connectGaps = !!options.connectGaps ++function reshapeFBO(fbo, w, h) { ++ //If fbo is invalid, just skip this ++ if(fbo._destroyed) { ++ throw new Error('gl-fbo: Can\'t resize destroyed FBO') ++ } + +- this.color = (options.color || [0,0,1,1]).slice() +- this.width = +(options.width || 1) ++ //Don't resize if no change in shape ++ if( (fbo._shape[0] === w) && ++ (fbo._shape[1] === h) ) { ++ return ++ } + +- this.fill = (options.fill || [false,false,false,false]).slice() +- this.fillColor = deepCopy(options.fillColor || [[0,0,0,1], +- [0,0,0,1], +- [0,0,0,1], +- [0,0,0,1]]) ++ var gl = fbo.gl + +- var dashes = options.dashes || [1] +- var dashLength = 0 +- for(var i=0; i maxFBOSize || ++ h < 0 || h > maxFBOSize) { ++ throw new Error('gl-fbo: Can\'t resize FBO, invalid dimensions') + } +- this.dashPattern.dispose() +- this.usingDashes = dashes.length > 1 +- +- this.dashPattern = createTexture(gl, +- ndarray(dashData, [dashLength, 1, 4], [1, 0, 0])) +- this.dashPattern.minFilter = gl.NEAREST +- this.dashPattern.magFilter = gl.NEAREST +- this.dashLength = dashLength +- pool.free(dashData) + +- var data = options.positions +- this.data = data ++ //Update shape ++ fbo._shape[0] = w ++ fbo._shape[1] = h + +- var bounds = this.bounds +- bounds[0] = bounds[1] = Infinity +- bounds[2] = bounds[3] = -Infinity ++ //Save framebuffer state ++ var state = saveFBOState(gl) + +- var numPoints = this.numPoints = data.length>>>1 +- if(numPoints === 0) { +- return ++ //Resize framebuffer attachments ++ for(var i=0; i 1) { +- var id = --ptr +- var ax = data[2*ptr] +- var ay = data[2*ptr+1] ++ var w = x[0]|0 ++ var h = x[1]|0 ++ reshapeFBO(this, w, h) + +- var next = id-1 +- var bx = data[2*next] +- var by = data[2*next+1] ++ return [w, h] ++ }, ++ enumerable: false ++ }, ++ 'width': { ++ get: function() { ++ if(this._destroyed) { ++ return 0 ++ } ++ return this._shape[0] ++ }, ++ set: function(w) { ++ w = w|0 ++ reshapeFBO(this, w, this._shape[1]) ++ return w ++ }, ++ enumerable: false ++ }, ++ 'height': { ++ get: function() { ++ if(this._destroyed) { ++ return 0 ++ } ++ return this._shape[1] ++ }, ++ set: function(h) { ++ h = h|0 ++ reshapeFBO(this, this._shape[0], h) ++ return h ++ }, ++ enumerable: false ++ } ++}) + +- if (isNaN(ax) || isNaN(ay) || isNaN(bx) || isNaN(by)) { +- continue +- } ++proto.bind = function() { ++ if(this._destroyed) { ++ return ++ } ++ var gl = this.gl ++ gl.bindFramebuffer(gl.FRAMEBUFFER, this.handle) ++ gl.viewport(0, 0, this._shape[0], this._shape[1]) ++} + +- count += 1 ++proto.dispose = function() { ++ if(this._destroyed) { ++ return ++ } ++ this._destroyed = true ++ var gl = this.gl ++ gl.deleteFramebuffer(this.handle) ++ this.handle = null ++ if(this.depth) { ++ this.depth.dispose() ++ this.depth = null ++ } ++ if(this._depth_rb) { ++ gl.deleteRenderbuffer(this._depth_rb) ++ this._depth_rb = null ++ } ++ for(var i=0; i maxFBOSize || height < 0 || height > maxFBOSize) { ++ throw new Error('gl-fbo: Parameters are too large for FBO') ++ } + +- lineData[--lineDataPtr] = -dy +- lineData[--lineDataPtr] = -dx +- lineData[--lineDataPtr] = by +- lineData[--lineDataPtr] = bx +- pickData[--pickDataPtr] = bkey0 +- pickData[--pickDataPtr] = bkey1 ++ //Handle each option type ++ options = options || {} + +- lineData[--lineDataPtr] = dy +- lineData[--lineDataPtr] = dx +- lineData[--lineDataPtr] = by +- lineData[--lineDataPtr] = bx +- pickData[--pickDataPtr] = bkey0 +- pickData[--pickDataPtr] = bkey1 ++ //Figure out number of color buffers to use ++ var numColors = 1 ++ if('color' in options) { ++ numColors = Math.max(options.color|0, 0) ++ if(numColors < 0) { ++ throw new Error('gl-fbo: Must specify a nonnegative number of colors') ++ } ++ if(numColors > 1) { ++ //Check if multiple render targets supported ++ if(!WEBGL_draw_buffers) { ++ throw new Error('gl-fbo: Multiple draw buffer extension not supported') ++ } else if(numColors > gl.getParameter(WEBGL_draw_buffers.MAX_COLOR_ATTACHMENTS_WEBGL)) { ++ throw new Error('gl-fbo: Context does not support ' + numColors + ' draw buffers') ++ } ++ } ++ } + +- lineData[--lineDataPtr] = -dy +- lineData[--lineDataPtr] = -dx +- lineData[--lineDataPtr] = ay +- lineData[--lineDataPtr] = ax +- pickData[--pickDataPtr] = akey0 +- pickData[--pickDataPtr] = akey1 ++ //Determine whether to use floating point textures ++ var colorType = gl.UNSIGNED_BYTE ++ var OES_texture_float = gl.getExtension('OES_texture_float') ++ if(options.float && numColors > 0) { ++ if(!OES_texture_float) { ++ throw new Error('gl-fbo: Context does not support floating point textures') ++ } ++ colorType = gl.FLOAT ++ } else if(options.preferFloat && numColors > 0) { ++ if(OES_texture_float) { ++ colorType = gl.FLOAT ++ } ++ } + +- lineData[--lineDataPtr] = dy +- lineData[--lineDataPtr] = dx +- lineData[--lineDataPtr] = ay +- lineData[--lineDataPtr] = ax +- pickData[--pickDataPtr] = akey0 +- pickData[--pickDataPtr] = akey1 ++ //Check if we should use depth buffer ++ var useDepth = true ++ if('depth' in options) { ++ useDepth = !!options.depth + } + +- this.vertCount = 6 * count +- this.lineBuffer.update(lineData.subarray(lineDataPtr)) +- this.pickBuffer.update(pickData.subarray(pickDataPtr)) ++ //Check if we should use a stencil buffer ++ var useStencil = false ++ if('stencil' in options) { ++ useStencil = !!options.stencil ++ } + +- pool.free(lineData) +- pool.free(pickData) ++ return new Framebuffer( ++ gl, ++ width, ++ height, ++ colorType, ++ numColors, ++ useDepth, ++ useStencil, ++ WEBGL_draw_buffers) + } + +-proto.dispose = function() { +- this.plot.removeObject(this) +- this.lineBuffer.dispose() +- this.pickBuffer.dispose() +- this.lineShader.dispose() +- this.mitreShader.dispose() +- this.fillShader.dispose() +- this.pickShader.dispose() +- this.dashPattern.dispose() +-} ++},{"gl-texture2d":104}],72:[function(require,module,exports){ + +-function createLinePlot(plot, options) { +- var gl = plot.gl +- var lineBuffer = createBuffer(gl) +- var pickBuffer = createBuffer(gl) +- var dashPattern = createTexture(gl, [1,1]) +- var lineShader = createShader(gl, SHADERS.lineVertex, SHADERS.lineFragment) +- var mitreShader = createShader(gl, SHADERS.mitreVertex, SHADERS.mitreFragment) +- var fillShader = createShader(gl, SHADERS.fillVertex, SHADERS.fillFragment) +- var pickShader = createShader(gl, SHADERS.pickVertex, SHADERS.pickFragment) +- var linePlot = new GLLine2D( +- plot, +- dashPattern, +- lineBuffer, +- pickBuffer, +- lineShader, +- mitreShader, +- fillShader, +- pickShader) +- plot.addObject(linePlot) +- linePlot.update(options) +- return linePlot +-} ++var sprintf = require('sprintf-js').sprintf; ++var glConstants = require('gl-constants/lookup'); ++var shaderName = require('glsl-shader-name'); ++var addLineNumbers = require('add-line-numbers'); + +-},{"./lib/shaders":76,"gl-buffer":66,"gl-shader":96,"gl-texture2d":115,"ndarray":131,"typedarray-pool":151}],78:[function(require,module,exports){ +-module.exports = fromQuat; ++module.exports = formatCompilerError; + +-/** +- * Creates a matrix from a quaternion rotation. +- * +- * @param {mat4} out mat4 receiving operation result +- * @param {quat4} q Rotation quaternion +- * @returns {mat4} out +- */ +-function fromQuat(out, q) { +- var x = q[0], y = q[1], z = q[2], w = q[3], +- x2 = x + x, +- y2 = y + y, +- z2 = z + z, ++function formatCompilerError(errLog, src, type) { ++ "use strict"; ++ ++ var name = shaderName(src) || 'of unknown name (see npm glsl-shader-name)'; ++ ++ var typeName = 'unknown type'; ++ if (type !== undefined) { ++ typeName = type === glConstants.FRAGMENT_SHADER ? 'fragment' : 'vertex' ++ } + +- xx = x * x2, +- yx = y * x2, +- yy = y * y2, +- zx = z * x2, +- zy = z * y2, +- zz = z * z2, +- wx = w * x2, +- wy = w * y2, +- wz = w * z2; ++ var longForm = sprintf('Error compiling %s shader %s:\n', typeName, name); ++ var shortForm = sprintf("%s%s", longForm, errLog); + +- out[0] = 1 - yy - zz; +- out[1] = yx + wz; +- out[2] = zx - wy; +- out[3] = 0; ++ var errorStrings = errLog.split('\n'); ++ var errors = {}; + +- out[4] = yx - wz; +- out[5] = 1 - xx - zz; +- out[6] = zy + wx; +- out[7] = 0; ++ for (var i = 0; i < errorStrings.length; i++) { ++ var errorString = errorStrings[i]; ++ if (errorString === '') continue; ++ var lineNo = parseInt(errorString.split(':')[2]); ++ if (isNaN(lineNo)) { ++ throw new Error(sprintf('Could not parse error: %s', errorString)); ++ } ++ errors[lineNo] = errorString; ++ } + +- out[8] = zx + wy; +- out[9] = zy - wx; +- out[10] = 1 - xx - yy; +- out[11] = 0; ++ var lines = addLineNumbers(src).split('\n'); + +- out[12] = 0; +- out[13] = 0; +- out[14] = 0; +- out[15] = 1; ++ for (var i = 0; i < lines.length; i++) { ++ if (!errors[i+3] && !errors[i+2] && !errors[i+1]) continue; ++ var line = lines[i]; ++ longForm += line + '\n'; ++ if (errors[i+1]) { ++ var e = errors[i+1]; ++ e = e.substr(e.split(':', 3).join(':').length + 1).trim(); ++ longForm += sprintf('^^^ %s\n\n', e); ++ } ++ } + +- return out; +-}; +-},{}],79:[function(require,module,exports){ ++ return { ++ long: longForm.trim(), ++ short: shortForm.trim() ++ }; ++} ++ ++ ++},{"add-line-numbers":8,"gl-constants/lookup":65,"glsl-shader-name":105,"sprintf-js":153}],73:[function(require,module,exports){ + 'use strict' + +-module.exports = createBoxes ++module.exports = createHeatmap2D + +-var createBuffer = require('gl-buffer') ++var bsearch = require('binary-search-bounds') ++var iota = require('iota-array') ++var pool = require('typedarray-pool') + var createShader = require('gl-shader') ++var createBuffer = require('gl-buffer') + +-var shaders = require('./shaders') ++var shaders = require('./lib/shaders') + +-function Boxes(plot, vbo, shader) { +- this.plot = plot +- this.vbo = vbo +- this.shader = shader ++function GLHeatmap2D( ++ plot, ++ shader, ++ pickShader, ++ positionBuffer, ++ colorBuffer, ++ idBuffer) { ++ this.plot = plot ++ this.shader = shader ++ this.pickShader = pickShader ++ this.positionBuffer = positionBuffer ++ this.colorBuffer = colorBuffer ++ this.idBuffer = idBuffer ++ this.xData = [] ++ this.yData = [] ++ this.shape = [0,0] ++ this.bounds = [Infinity, Infinity, -Infinity, -Infinity] ++ this.pickOffset = 0 + } + +-var proto = Boxes.prototype ++var proto = GLHeatmap2D.prototype + +-proto.bind = function() { +- var shader = this.shader +- this.vbo.bind() +- this.shader.bind() +- shader.attributes.coord.pointer() +- shader.uniforms.screenBox = this.plot.screenBox +-} ++var WEIGHTS = [ ++ 0, 0, ++ 1, 0, ++ 0, 1, ++ 1, 0, ++ 1, 1, ++ 0, 1 ++] + +-proto.drawBox = (function() { +- var lo = [0,0] +- var hi = [0,0] +- return function(loX, loY, hiX, hiY, color) { +- var plot = this.plot +- var shader = this.shader +- var gl = plot.gl ++proto.draw = (function() { ++ var MATRIX = [ ++ 1, 0, 0, ++ 0, 1, 0, ++ 0, 0, 1 ++ ] + +- lo[0] = loX +- lo[1] = loY +- hi[0] = hiX +- hi[1] = hiY ++ return function() { ++ var plot = this.plot ++ var shader = this.shader ++ var bounds = this.bounds ++ var numVertices = this.numVertices + +- shader.uniforms.lo = lo +- shader.uniforms.hi = hi +- shader.uniforms.color = color ++ var gl = plot.gl ++ var viewBox = plot.viewBox ++ var dataBox = plot.dataBox + +- gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4) +- } +-}()) ++ var boundX = bounds[2] - bounds[0] ++ var boundY = bounds[3] - bounds[1] ++ var dataX = dataBox[2] - dataBox[0] ++ var dataY = dataBox[3] - dataBox[1] + +-proto.dispose = function() { +- this.vbo.dispose() +- this.shader.dispose() +-} ++ MATRIX[0] = 2.0 * boundX / dataX ++ MATRIX[4] = 2.0 * boundY / dataY ++ MATRIX[6] = 2.0 * (bounds[0] - dataBox[0]) / dataX - 1.0 ++ MATRIX[7] = 2.0 * (bounds[1] - dataBox[1]) / dataY - 1.0 + +-function createBoxes(plot) { +- var gl = plot.gl +- var vbo = createBuffer(gl, [ +- 0,0, +- 0,1, +- 1,0, +- 1,1]) +- var shader = createShader(gl, shaders.boxVert, shaders.lineFrag) +- return new Boxes(plot, vbo, shader) +-} ++ shader.bind() + +-},{"./shaders":82,"gl-buffer":66,"gl-shader":96}],80:[function(require,module,exports){ +-'use strict' ++ var uniforms = shader.uniforms ++ uniforms.viewTransform = MATRIX + +-module.exports = createGrid ++ var attributes = shader.attributes ++ this.positionBuffer.bind() ++ attributes.position.pointer() + +-var createBuffer = require('gl-buffer') +-var createShader = require('gl-shader') +-var bsearch = require('binary-search-bounds') +-var shaders = require('./shaders') ++ this.colorBuffer.bind() ++ attributes.color.pointer(gl.UNSIGNED_BYTE, true) + +-function Grid(plot, vbo, shader, tickShader) { +- this.plot = plot +- this.vbo = vbo +- this.shader = shader +- this.tickShader = tickShader +- this.ticks = [[], []] +-} ++ gl.drawArrays(gl.TRIANGLES, 0, this.numVertices) ++ } ++})() + +-function compareTickNum(a, b) { +- return a - b +-} ++proto.drawPick = (function() { ++ var MATRIX = [ ++ 1, 0, 0, ++ 0, 1, 0, ++ 0, 0, 1 ++ ] + +-var proto = Grid.prototype ++ var PICK_VECTOR = [0,0,0,0] + +-proto.draw = (function() { ++ return function(pickOffset) { ++ var plot = this.plot ++ var shader = this.pickShader ++ var bounds = this.bounds ++ var numVertices = this.numVertices + +- var DATA_SHIFT = [0,0] +- var DATA_SCALE = [0,0] +- var DATA_AXIS = [0,0] ++ var gl = plot.gl ++ var viewBox = plot.viewBox ++ var dataBox = plot.dataBox + +- return function() { +- var plot = this.plot +- var vbo = this.vbo +- var shader = this.shader +- var ticks = this.ticks +- var gl = plot.gl +- var bounds = plot._tickBounds +- var dataBox = plot.dataBox +- var viewPixels = plot.viewBox +- var lineWidth = plot.gridLineWidth +- var gridColor = plot.gridLineColor +- var gridEnable = plot.gridLineEnable +- var pixelRatio = plot.pixelRatio ++ var boundX = bounds[2] - bounds[0] ++ var boundY = bounds[3] - bounds[1] ++ var dataX = dataBox[2] - dataBox[0] ++ var dataY = dataBox[3] - dataBox[1] + +- for(var i=0; i<2; ++i) { +- var lo = bounds[i] +- var hi = bounds[i+2] +- var boundScale = hi - lo +- var dataCenter = 0.5 * (dataBox[i+2] + dataBox[i]) +- var dataWidth = dataBox[i+2] - dataBox[i] +- DATA_SCALE[i] = 2.0 * boundScale / dataWidth +- DATA_SHIFT[i] = 2.0 * (lo - dataCenter) / dataWidth ++ MATRIX[0] = 2.0 * boundX / dataX ++ MATRIX[4] = 2.0 * boundY / dataY ++ MATRIX[6] = 2.0 * (bounds[0] - dataBox[0]) / dataX - 1.0 ++ MATRIX[7] = 2.0 * (bounds[1] - dataBox[1]) / dataY - 1.0 ++ ++ for(var i=0; i<4; ++i) { ++ PICK_VECTOR[i] = (pickOffset>>(i*8)) & 0xff + } + ++ this.pickOffset = pickOffset ++ + shader.bind() +- vbo.bind() +- shader.attributes.dataCoord.pointer() +- shader.uniforms.dataShift = DATA_SHIFT +- shader.uniforms.dataScale = DATA_SCALE + +- var offset = 0 +- for(var i=0; i<2; ++i) { +- DATA_AXIS[0] = DATA_AXIS[1] = 0 +- DATA_AXIS[i] = 1 +- shader.uniforms.dataAxis = DATA_AXIS +- shader.uniforms.lineWidth = lineWidth[i] / (viewPixels[i+2] - viewPixels[i]) * pixelRatio +- shader.uniforms.color = gridColor[i] ++ var uniforms = shader.uniforms ++ uniforms.viewTransform = MATRIX ++ uniforms.pickOffset = PICK_VECTOR + +- var size = ticks[i].length * 6 +- if(gridEnable[i] && size) { +- gl.drawArrays(gl.TRIANGLES, offset, size) +- } +- offset += size +- } ++ var attributes = shader.attributes ++ this.positionBuffer.bind() ++ attributes.position.pointer() ++ ++ this.idBuffer.bind() ++ attributes.pickId.pointer(gl.UNSIGNED_BYTE, false) ++ ++ gl.drawArrays(gl.TRIANGLES, 0, this.numVertices) ++ ++ return pickOffset + this.shape[0] * this.shape[1] + } + })() + +-proto.drawTickMarks = (function() { +- var DATA_SHIFT = [0,0] +- var DATA_SCALE = [0,0] +- var X_AXIS = [1,0] +- var Y_AXIS = [0,1] +- var SCR_OFFSET = [0,0] +- var TICK_SCALE = [0,0] +- +- return function() { +- var plot = this.plot +- var vbo = this.vbo +- var shader = this.tickShader +- var ticks = this.ticks +- var gl = plot.gl +- var bounds = plot._tickBounds +- var dataBox = plot.dataBox +- var viewBox = plot.viewBox +- var pixelRatio = plot.pixelRatio +- var screenBox = plot.screenBox ++proto.pick = function(x, y, value) { ++ var pickOffset = this.pickOffset ++ var pointCount = this.shape[0] * this.shape[1] ++ if(value < pickOffset || value >= pickOffset + pointCount) { ++ return null ++ } ++ var pointId = value - pickOffset ++ var xData = this.xData ++ var yData = this.yData ++ return { ++ object: this, ++ pointId: pointId, ++ dataCoord: [ ++ xData[pointId%this.shape[0]], ++ yData[(pointId/this.shape[0])|0] ] ++ } ++} + +- var screenWidth = screenBox[2] - screenBox[0] +- var screenHeight = screenBox[3] - screenBox[1] +- var viewWidth = viewBox[2] - viewBox[0] +- var viewHeight = viewBox[3] - viewBox[1] ++proto.update = function(options) { ++ options = options || {} + +- for(var i=0; i<2; ++i) { +- var lo = bounds[i] +- var hi = bounds[i+2] +- var boundScale = hi - lo +- var dataCenter = 0.5 * (dataBox[i+2] + dataBox[i]) +- var dataWidth = (dataBox[i+2] - dataBox[i]) +- DATA_SCALE[i] = 2.0 * boundScale / dataWidth +- DATA_SHIFT[i] = 2.0 * (lo - dataCenter) / dataWidth +- } ++ var shape = options.shape || [0,0] + +- DATA_SCALE[0] *= viewWidth / screenWidth +- DATA_SHIFT[0] *= viewWidth / screenWidth ++ var x = options.x || iota(shape[0]) ++ var y = options.y || iota(shape[1]) ++ var z = options.z || new Float32Array(shape[0] * shape[1]) + +- DATA_SCALE[1] *= viewHeight / screenHeight +- DATA_SHIFT[1] *= viewHeight / screenHeight ++ this.xData = x ++ this.yData = y + +- shader.bind() +- vbo.bind() ++ var colorLevels = options.colorLevels || [0] ++ var colorValues = options.colorValues || [0, 0, 0, 1] ++ var colorCount = colorLevels.length + +- shader.attributes.dataCoord.pointer() ++ var bounds = this.bounds ++ var lox = bounds[0] = x[0] ++ var loy = bounds[1] = y[0] ++ var hix = bounds[2] = x[x.length-1] ++ var hiy = bounds[3] = y[y.length-1] + +- var uniforms = shader.uniforms +- uniforms.dataShift = DATA_SHIFT +- uniforms.dataScale = DATA_SCALE ++ var xs = 1.0 / (hix - lox) ++ var ys = 1.0 / (hiy - loy) + +- var tickMarkLength = plot.tickMarkLength +- var tickMarkWidth = plot.tickMarkWidth +- var tickMarkColor = plot.tickMarkColor ++ var numVerts = shape[0] * shape[1] * (WEIGHTS.length>>>1) + +- var xTicksOffset = 0 +- var yTicksOffset = ticks[0].length * 6 ++ this.numVertices = numVerts + +- var xStart = Math.min(bsearch.ge(ticks[0], (dataBox[0] - bounds[0]) / (bounds[2] - bounds[0]), compareTickNum), ticks[0].length) +- var xEnd = Math.min(bsearch.gt(ticks[0], (dataBox[2] - bounds[0]) / (bounds[2] - bounds[0]), compareTickNum), ticks[0].length) +- var xOffset = xTicksOffset + 6 * xStart +- var xCount = 6 * Math.max(0, xEnd - xStart) ++ var colors = pool.mallocUint8 (numVerts * 4) ++ var positions = pool.mallocFloat32(numVerts * 2) ++ var ids = pool.mallocUint32 (numVerts) + +- var yStart = Math.min(bsearch.ge(ticks[1], (dataBox[1] - bounds[1]) / (bounds[3] - bounds[1]), compareTickNum), ticks[1].length) +- var yEnd = Math.min(bsearch.gt(ticks[1], (dataBox[3] - bounds[1]) / (bounds[3] - bounds[1]), compareTickNum), ticks[1].length) +- var yOffset = yTicksOffset + 6 * yStart +- var yCount = 6 * Math.max(0, yEnd - yStart) ++ var numX = shape[0] ++ var numY = shape[1] + +- SCR_OFFSET[0] = 2.0 * (viewBox[0] - tickMarkLength[1]) / screenWidth - 1.0 +- SCR_OFFSET[1] = (viewBox[3] + viewBox[1]) / screenHeight - 1.0 +- TICK_SCALE[0] = tickMarkLength[1] * pixelRatio / screenWidth +- TICK_SCALE[1] = tickMarkWidth[1] * pixelRatio / screenHeight ++ this.shape = [numX, numY] + +- if(yCount) { +- uniforms.color = tickMarkColor[1] +- uniforms.tickScale = TICK_SCALE +- uniforms.dataAxis = Y_AXIS +- uniforms.screenOffset = SCR_OFFSET +- gl.drawArrays(gl.TRIANGLES, yOffset, yCount) +- } ++ var ptr = 0 + +- SCR_OFFSET[0] = (viewBox[2] + viewBox[0]) / screenWidth - 1.0 +- SCR_OFFSET[1] = 2.0 * (viewBox[1] - tickMarkLength[0]) / screenHeight - 1.0 +- TICK_SCALE[0] = tickMarkWidth[0] * pixelRatio / screenWidth +- TICK_SCALE[1] = tickMarkLength[0] * pixelRatio / screenHeight ++ for(var j=0; j tickOffset[start]) { +- shader.uniforms.dataAxis = DATA_AXIS +- shader.uniforms.screenOffset = SCREEN_OFFSET +- shader.uniforms.color = textColor[axis] +- shader.uniforms.angle = textAngle[axis] +- gl.drawArrays( +- gl.TRIANGLES, +- tickOffset[start], +- tickOffset[end] - tickOffset[start]) +- } ++ var fillAttributes = fillShader.attributes ++ fillAttributes.a.pointer(gl.FLOAT, false, 16, 0) ++ fillAttributes.d.pointer(gl.FLOAT, false, 16, 8) ++ ++ gl.depthMask(true) ++ gl.enable(gl.DEPTH_TEST) ++ ++ var fillColor = this.fillColor ++ if(fill[0]) { ++ fillUniforms.color = fillColor[0] ++ fillUniforms.projectAxis = NX_AXIS ++ fillUniforms.projectValue = 1 ++ gl.drawArrays(gl.TRIANGLES, 0, count) + } +- if(labelEnable[axis] && labelCount) { +- SCREEN_OFFSET[axis^1] -= screenScale * pixelRatio * labelPad[axis] +- shader.uniforms.dataAxis = ZERO_2 +- shader.uniforms.screenOffset = SCREEN_OFFSET +- shader.uniforms.color = labelColor[axis] +- shader.uniforms.angle = labelAngle[axis] +- gl.drawArrays( +- gl.TRIANGLES, +- labelOffset, +- labelCount) ++ ++ if(fill[1]) { ++ fillUniforms.color = fillColor[1] ++ fillUniforms.projectAxis = NY_AXIS ++ fillUniforms.projectValue = 1 ++ gl.drawArrays(gl.TRIANGLES, 0, count) + } + +- SCREEN_OFFSET[axis^1] = screenScale * viewBox[2+(axis^1)] - 1.0 +- if(tickEnable[axis+2]) { +- SCREEN_OFFSET[axis^1] += screenScale * pixelRatio * tickPad[axis+2] +- if(start < end && tickOffset[end] > tickOffset[start]) { +- shader.uniforms.dataAxis = DATA_AXIS +- shader.uniforms.screenOffset = SCREEN_OFFSET +- shader.uniforms.color = textColor[axis+2] +- shader.uniforms.angle = textAngle[axis+2] +- gl.drawArrays( +- gl.TRIANGLES, +- tickOffset[start], +- tickOffset[end] - tickOffset[start]) +- } ++ if(fill[2]) { ++ fillUniforms.color = fillColor[2] ++ fillUniforms.projectAxis = PX_AXIS ++ fillUniforms.projectValue = 1 ++ gl.drawArrays(gl.TRIANGLES, 0, count) + } +- if(labelEnable[axis+2] && labelCount) { +- SCREEN_OFFSET[axis^1] += screenScale * pixelRatio * labelPad[axis+2] +- shader.uniforms.dataAxis = ZERO_2 +- shader.uniforms.screenOffset = SCREEN_OFFSET +- shader.uniforms.color = labelColor[axis+2] +- shader.uniforms.angle = labelAngle[axis+2] +- gl.drawArrays( +- gl.TRIANGLES, +- labelOffset, +- labelCount) ++ ++ if(fill[3]) { ++ fillUniforms.color = fillColor[3] ++ fillUniforms.projectAxis = PY_AXIS ++ fillUniforms.projectValue = 1 ++ gl.drawArrays(gl.TRIANGLES, 0, count) + } + ++ gl.depthMask(false) ++ gl.disable(gl.DEPTH_TEST) + } +-})() + +-proto.drawTitle = (function() { +- var DATA_AXIS = [0,0] +- var SCREEN_OFFSET = [0,0] ++ var shader = this.lineShader ++ shader.bind() + +- return function() { +- var plot = this.plot +- var shader = this.shader +- var gl = plot.gl +- var screenBox = plot.screenBox +- var titleCenter = plot.titleCenter +- var titleAngle = plot.titleAngle +- var titleColor = plot.titleColor +- var titleCenter = plot.titleCenter +- var pixelRatio = plot.pixelRatio ++ var uniforms = shader.uniforms ++ uniforms.matrix = MATRIX ++ uniforms.color = color ++ uniforms.width = width * pixelRatio ++ uniforms.screenShape = SCREEN_SHAPE ++ uniforms.dashPattern = this.dashPattern.bind() ++ uniforms.dashLength = this.dashLength * pixelRatio + +- if(!this.titleCount) { +- return +- } ++ var attributes = shader.attributes ++ attributes.a.pointer(gl.FLOAT, false, 16, 0) ++ attributes.d.pointer(gl.FLOAT, false, 16, 8) + +- for(var i=0; i<2; ++i) { +- SCREEN_OFFSET[i] = 2.0 * (titleCenter[i]*pixelRatio - screenBox[i]) / +- (screenBox[2+i] - screenBox[i]) - 1 +- } ++ gl.drawArrays(gl.TRIANGLES, 0, count) + +- shader.bind() +- shader.uniforms.dataAxis = DATA_AXIS +- shader.uniforms.screenOffset = SCREEN_OFFSET +- shader.uniforms.angle = titleAngle +- shader.uniforms.color = titleColor ++ //Draw mitres ++ if(width > 2 && !this.usingDashes) { ++ var mshader = this.mitreShader ++ mshader.bind() + +- gl.drawArrays(gl.TRIANGLES, this.titleOffset, this.titleCount) ++ var muniforms = mshader.uniforms ++ muniforms.matrix = MATRIX ++ muniforms.color = color ++ muniforms.screenShape = SCREEN_SHAPE ++ muniforms.radius = width * pixelRatio ++ ++ mshader.attributes.p.pointer(gl.FLOAT, false, 48, 0) ++ gl.drawArrays(gl.POINTS, 0, (count/3)|0) + } ++} + })() + +-proto.bind = (function() { +- var DATA_SHIFT = [0,0] +- var DATA_SCALE = [0,0] +- var TEXT_SCALE = [0,0] +- +- return function() { ++proto.drawPick = (function() { ++ var MATRIX = [1, 0, 0, ++ 0, 1, 0, ++ 0, 0, 1] ++ var SCREEN_SHAPE = [0,0] ++ var PICK_OFFSET = [0,0,0,0] ++ return function(pickOffset) { + var plot = this.plot +- var shader = this.shader +- var bounds = plot._tickBounds +- var dataBox = plot.dataBox +- var screenBox = plot.screenBox +- var viewBox = plot.viewBox +- +- shader.bind() ++ var shader = this.pickShader ++ var buffer = this.lineBuffer ++ var pickBuffer= this.pickBuffer ++ var width = this.width ++ var numPoints = this.numPoints ++ var bounds = this.bounds ++ var count = this.vertCount + +- //Set up coordinate scaling uniforms +- for(var i=0; i<2; ++i) { ++ var gl = plot.gl ++ var viewBox = plot.viewBox ++ var dataBox = plot.dataBox ++ var pixelRatio = plot.pickPixelRatio + +- var lo = bounds[i] +- var hi = bounds[i+2] +- var boundScale = hi - lo +- var dataCenter = 0.5 * (dataBox[i+2] + dataBox[i]) +- var dataWidth = (dataBox[i+2] - dataBox[i]) ++ var boundX = bounds[2] - bounds[0] ++ var boundY = bounds[3] - bounds[1] ++ var dataX = dataBox[2] - dataBox[0] ++ var dataY = dataBox[3] - dataBox[1] ++ var screenX = viewBox[2] - viewBox[0] ++ var screenY = viewBox[3] - viewBox[1] + +- var viewLo = viewBox[i] +- var viewHi = viewBox[i+2] +- var viewScale = viewHi - viewLo +- var screenLo = screenBox[i] +- var screenHi = screenBox[i+2] +- var screenScale = screenHi - screenLo ++ this.pickOffset = pickOffset + +- DATA_SCALE[i] = 2.0 * boundScale / dataWidth * viewScale / screenScale +- DATA_SHIFT[i] = 2.0 * (lo - dataCenter) / dataWidth * viewScale / screenScale ++ if(!count) { ++ return pickOffset + numPoints + } + +- TEXT_SCALE[1] = 2.0 * plot.pixelRatio / (screenBox[3] - screenBox[1]) +- TEXT_SCALE[0] = TEXT_SCALE[1] * (screenBox[3] - screenBox[1]) / (screenBox[2] - screenBox[0]) +- +- shader.uniforms.dataScale = DATA_SCALE +- shader.uniforms.dataShift = DATA_SHIFT +- shader.uniforms.textScale = TEXT_SCALE ++ MATRIX[0] = 2.0 * boundX / dataX ++ MATRIX[4] = 2.0 * boundY / dataY ++ MATRIX[6] = 2.0 * (bounds[0] - dataBox[0]) / dataX - 1.0 ++ MATRIX[7] = 2.0 * (bounds[1] - dataBox[1]) / dataY - 1.0 + +- //Set attributes +- this.vbo.bind() +- shader.attributes.textCoordinate.pointer() +- } +-})() ++ SCREEN_SHAPE[0] = screenX ++ SCREEN_SHAPE[1] = screenY + +-proto.update = function(options) { +- var vertices = [] +- var axesTicks = options.ticks +- var bounds = options.bounds ++ PICK_OFFSET[0] = pickOffset & 0xff ++ PICK_OFFSET[1] = (pickOffset>>>8) & 0xff ++ PICK_OFFSET[2] = (pickOffset>>>16) & 0xff ++ PICK_OFFSET[3] = pickOffset>>>24 + +- for(var dimension=0; dimension<2; ++dimension) { +- var offsets = [Math.floor(vertices.length/3)], tickX = [-Infinity] ++ shader.bind() + +- //Copy vertices over to buffer +- var ticks = axesTicks[dimension] +- for(var i=0; i= pickOffset + pointCount) { ++ return null + } +- +- //Add title +- this.titleOffset = Math.floor(vertices.length/3) +- var data = getText(options.titleFont, options.title).data +- var scale = options.titleSize +- for(var i=0; i 1 + +- this.gridLineEnable = [true,true] +- this.gridLineWidth = [1,1] +- this.gridLineColor = [[0,0,0,1], +- [0,0,0,1]] ++ this.dashPattern = createTexture(gl, ++ ndarray(dashData, [dashLength, 1, 4], [1, 0, 0])) ++ this.dashPattern.minFilter = gl.NEAREST ++ this.dashPattern.magFilter = gl.NEAREST ++ this.dashLength = dashLength ++ pool.free(dashData) + +- this.pixelRatio = 1 ++ var data = options.positions ++ this.data = data + +- this.tickMarkLength = [0,0,0,0] +- this.tickMarkWidth = [0,0,0,0] +- this.tickMarkColor = [[0,0,0,1], +- [0,0,0,1], +- [0,0,0,1], +- [0,0,0,1]] ++ var bounds = this.bounds ++ bounds[0] = bounds[1] = Infinity ++ bounds[2] = bounds[3] = -Infinity + +- this.tickPad = [15,15,15,15] +- this.tickAngle = [0,0,0,0] +- this.tickEnable = [true,true,true,true] +- this.tickColor = [[0,0,0,1], +- [0,0,0,1], +- [0,0,0,1], +- [0,0,0,1]] ++ var numPoints = this.numPoints = data.length>>>1 ++ if(numPoints === 0) { ++ return ++ } + +- this.labelPad = [15,15,15,15] +- this.labelAngle = [0,Math.PI/2,0,3.0*Math.PI/2] +- this.labelEnable = [true,true,true,true] +- this.labelColor = [[0,0,0,1], +- [0,0,0,1], +- [0,0,0,1], +- [0,0,0,1]] ++ for(var i=0; i 1) { ++ var id = --ptr ++ var ax = data[2*ptr] ++ var ay = data[2*ptr+1] + +- this.dirty = false +- this.pickDirty = false +- this.pickDelay = 120 +- this.pickRadius = 10 +- this._pickTimeout = null +- this._drawPick = this.drawPick.bind(this) ++ var next = id-1 ++ var bx = data[2*next] ++ var by = data[2*next+1] + +- this._depthCounter = 0 +-} ++ if (isNaN(ax) || isNaN(ay) || isNaN(bx) || isNaN(by)) { ++ continue ++ } + +-var proto = GLPlot2D.prototype ++ count += 1 + +-proto.setDirty = function() { +- this.dirty = this.pickDirty = true +-} ++ ax = (ax - bounds[0]) / (bounds[2] - bounds[0]) ++ ay = (ay - bounds[1]) / (bounds[3] - bounds[1]) + +-proto.setOverlayDirty = function() { +- this.dirty = true +-} ++ bx = (bx - bounds[0]) / (bounds[2] - bounds[0]) ++ by = (by - bounds[1]) / (bounds[3] - bounds[1]) + +-proto.nextDepthValue = function() { +- return (this._depthCounter++) / 65536.0 +-} ++ var dx = bx - ax ++ var dy = by - ay + +-function lerp(a, b, t) { +- var s = 0.5 * (t + 1.0) +- return Math.floor((1.0-s)*a + s*b)|0 +-} ++ var akey0 = id | (1<<24) ++ var akey1 = (id-1) ++ var bkey0 = id ++ var bkey1 = (id-1) | (1<<24) + +-proto.draw = (function() { +-var TICK_MARK_BOX = [0,0,0,0] +-return function() { +- var gl = this.gl +- var screenBox = this.screenBox +- var viewPixels = this.viewBox +- var dataBox = this.dataBox +- var pixelRatio = this.pixelRatio +- var grid = this.grid +- var line = this.line +- var text = this.text +- var objects = this.objects ++ lineData[--lineDataPtr] = -dy ++ lineData[--lineDataPtr] = -dx ++ lineData[--lineDataPtr] = ay ++ lineData[--lineDataPtr] = ax ++ pickData[--pickDataPtr] = akey0 ++ pickData[--pickDataPtr] = akey1 + +- this._depthCounter = 0 ++ lineData[--lineDataPtr] = dy ++ lineData[--lineDataPtr] = dx ++ lineData[--lineDataPtr] = by ++ lineData[--lineDataPtr] = bx ++ pickData[--pickDataPtr] = bkey0 ++ pickData[--pickDataPtr] = bkey1 + +- if(this.pickDirty) { +- if(this._pickTimeout) { +- clearTimeout(this._pickTimeout) +- } +- this.pickDirty = false +- this._pickTimeout = setTimeout(this._drawPick, this.pickDelay) +- } ++ lineData[--lineDataPtr] = -dy ++ lineData[--lineDataPtr] = -dx ++ lineData[--lineDataPtr] = by ++ lineData[--lineDataPtr] = bx ++ pickData[--pickDataPtr] = bkey0 ++ pickData[--pickDataPtr] = bkey1 + +- if(!this.dirty) { +- return +- } +- this.dirty = false ++ lineData[--lineDataPtr] = dy ++ lineData[--lineDataPtr] = dx ++ lineData[--lineDataPtr] = by ++ lineData[--lineDataPtr] = bx ++ pickData[--pickDataPtr] = bkey0 ++ pickData[--pickDataPtr] = bkey1 + +- gl.bindFramebuffer(gl.FRAMEBUFFER, null) ++ lineData[--lineDataPtr] = -dy ++ lineData[--lineDataPtr] = -dx ++ lineData[--lineDataPtr] = ay ++ lineData[--lineDataPtr] = ax ++ pickData[--pickDataPtr] = akey0 ++ pickData[--pickDataPtr] = akey1 + +- //Turn on scissor +- gl.enable(gl.SCISSOR_TEST) ++ lineData[--lineDataPtr] = dy ++ lineData[--lineDataPtr] = dx ++ lineData[--lineDataPtr] = ay ++ lineData[--lineDataPtr] = ax ++ pickData[--pickDataPtr] = akey0 ++ pickData[--pickDataPtr] = akey1 ++ } + +- //Turn off depth buffer +- gl.disable(gl.DEPTH_TEST) +- gl.depthFunc(gl.LESS) +- gl.depthMask(false) ++ this.vertCount = 6 * count ++ this.lineBuffer.update(lineData.subarray(lineDataPtr)) ++ this.pickBuffer.update(pickData.subarray(pickDataPtr)) + +- //Configure premultiplied alpha blending +- gl.enable(gl.BLEND) +- gl.blendEquation(gl.FUNC_ADD, gl.FUNC_ADD); +- gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA); ++ pool.free(lineData) ++ pool.free(pickData) ++} + +- //Draw border +- gl.scissor( +- screenBox[0], +- screenBox[1], +- screenBox[2]-screenBox[0], +- screenBox[3]-screenBox[1]) +- var borderColor = this.borderColor +- gl.clearColor( +- borderColor[0]*borderColor[3], +- borderColor[1]*borderColor[3], +- borderColor[2]*borderColor[3], +- borderColor[3]) +- gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT) ++proto.dispose = function() { ++ this.plot.removeObject(this) ++ this.lineBuffer.dispose() ++ this.pickBuffer.dispose() ++ this.lineShader.dispose() ++ this.mitreShader.dispose() ++ this.fillShader.dispose() ++ this.pickShader.dispose() ++ this.dashPattern.dispose() ++} + +- //Draw center pane +- gl.scissor( +- viewPixels[0], +- viewPixels[1], +- viewPixels[2]-viewPixels[0], +- viewPixels[3]-viewPixels[1]) +- gl.viewport( +- viewPixels[0], +- viewPixels[1], +- viewPixels[2]-viewPixels[0], +- viewPixels[3]-viewPixels[1]) +- var backgroundColor = this.backgroundColor +- gl.clearColor( +- backgroundColor[0]*backgroundColor[3], +- backgroundColor[1]*backgroundColor[3], +- backgroundColor[2]*backgroundColor[3], +- backgroundColor[3]) +- gl.clear(gl.COLOR_BUFFER_BIT) ++function createLinePlot(plot, options) { ++ var gl = plot.gl ++ var lineBuffer = createBuffer(gl) ++ var pickBuffer = createBuffer(gl) ++ var dashPattern = createTexture(gl, [1,1]) ++ var lineShader = createShader(gl, SHADERS.lineVertex, SHADERS.lineFragment) ++ var mitreShader = createShader(gl, SHADERS.mitreVertex, SHADERS.mitreFragment) ++ var fillShader = createShader(gl, SHADERS.fillVertex, SHADERS.fillFragment) ++ var pickShader = createShader(gl, SHADERS.pickVertex, SHADERS.pickFragment) ++ var linePlot = new GLLine2D( ++ plot, ++ dashPattern, ++ lineBuffer, ++ pickBuffer, ++ lineShader, ++ mitreShader, ++ fillShader, ++ pickShader) ++ plot.addObject(linePlot) ++ linePlot.update(options) ++ return linePlot ++} + +- //Draw grid +- grid.draw() ++},{"./lib/shaders":76,"gl-buffer":63,"gl-shader":96,"gl-texture2d":104,"ndarray":123,"typedarray-pool":162}],78:[function(require,module,exports){ ++module.exports = fromQuat; + +- //Draw zero lines separately +- var zeroLineEnable = this.zeroLineEnable +- var zeroLineColor = this.zeroLineColor +- var zeroLineWidth = this.zeroLineWidth +- if(zeroLineEnable[0] || zeroLineEnable[1]) { +- line.bind() +- for(var i=0; i<2; ++i) { +- if(!zeroLineEnable[i] || +- !(dataBox[i] <= 0 && dataBox[i+2] >= 0)) { +- continue +- } ++/** ++ * Creates a matrix from a quaternion rotation. ++ * ++ * @param {mat4} out mat4 receiving operation result ++ * @param {quat4} q Rotation quaternion ++ * @returns {mat4} out ++ */ ++function fromQuat(out, q) { ++ var x = q[0], y = q[1], z = q[2], w = q[3], ++ x2 = x + x, ++ y2 = y + y, ++ z2 = z + z, + +- var zeroIntercept = screenBox[i] - +- dataBox[i] * (screenBox[i+2] - screenBox[i]) / (dataBox[i+2] - dataBox[i]) ++ xx = x * x2, ++ yx = y * x2, ++ yy = y * y2, ++ zx = z * x2, ++ zy = z * y2, ++ zz = z * z2, ++ wx = w * x2, ++ wy = w * y2, ++ wz = w * z2; + +- if(i === 0) { +- line.drawLine( +- zeroIntercept, screenBox[1], zeroIntercept, screenBox[3], +- zeroLineWidth[i], +- zeroLineColor[i]) +- } else { +- line.drawLine( +- screenBox[0], zeroIntercept, screenBox[2], zeroIntercept, +- zeroLineWidth[i], +- zeroLineColor[i]) +- } +- } +- } ++ out[0] = 1 - yy - zz; ++ out[1] = yx + wz; ++ out[2] = zx - wy; ++ out[3] = 0; + +- //Draw traces +- for(var i=0; i=0; --i) { +- this.objects[i].dispose() +- } +- this.objects.length = 0 +- for(var i=this.overlays.length-1; i>=0; --i) { +- this.overlays[i].dispose() +- } +- this.overlays.length = 0 ++ SCR_OFFSET[0] = 2.0 * (viewBox[2] + tickMarkLength[3]) / screenWidth - 1.0 ++ SCR_OFFSET[1] = (viewBox[3] + viewBox[1]) / screenHeight - 1.0 ++ TICK_SCALE[0] = tickMarkLength[3] * pixelRatio / screenWidth ++ TICK_SCALE[1] = tickMarkWidth[3] * pixelRatio / screenHeight + +- this.gl = null +-} ++ if(yCount) { ++ uniforms.color = tickMarkColor[3] ++ uniforms.tickScale = TICK_SCALE ++ uniforms.dataAxis = Y_AXIS ++ uniforms.screenOffset = SCR_OFFSET ++ gl.drawArrays(gl.TRIANGLES, yOffset, yCount) ++ } + +-proto.addObject = function(object) { +- if(this.objects.indexOf(object) < 0) { +- this.objects.push(object) +- this.setDirty() +- } +-} ++ SCR_OFFSET[0] = (viewBox[2] + viewBox[0]) / screenWidth - 1.0 ++ SCR_OFFSET[1] = 2.0 * (viewBox[3] + tickMarkLength[2]) / screenHeight - 1.0 ++ TICK_SCALE[0] = tickMarkWidth[2] * pixelRatio / screenWidth ++ TICK_SCALE[1] = tickMarkLength[2] * pixelRatio / screenHeight + +-proto.removeObject = function(object) { +- var objects = this.objects +- for(var i=0; i tickOffset[start]) { ++ shader.uniforms.dataAxis = DATA_AXIS ++ shader.uniforms.screenOffset = SCREEN_OFFSET ++ shader.uniforms.color = textColor[axis] ++ shader.uniforms.angle = textAngle[axis] ++ gl.drawArrays( ++ gl.TRIANGLES, ++ tickOffset[start], ++ tickOffset[end] - tickOffset[start]) ++ } ++ } ++ if(labelEnable[axis] && labelCount) { ++ SCREEN_OFFSET[axis^1] -= screenScale * pixelRatio * labelPad[axis] ++ shader.uniforms.dataAxis = ZERO_2 ++ shader.uniforms.screenOffset = SCREEN_OFFSET ++ shader.uniforms.color = labelColor[axis] ++ shader.uniforms.angle = labelAngle[axis] ++ gl.drawArrays( ++ gl.TRIANGLES, ++ labelOffset, ++ labelCount) + } + +- var gl = plot.gl ++ SCREEN_OFFSET[axis^1] = screenScale * viewBox[2+(axis^1)] - 1.0 ++ if(tickEnable[axis+2]) { ++ SCREEN_OFFSET[axis^1] += screenScale * pixelRatio * tickPad[axis+2] ++ if(start < end && tickOffset[end] > tickOffset[start]) { ++ shader.uniforms.dataAxis = DATA_AXIS ++ shader.uniforms.screenOffset = SCREEN_OFFSET ++ shader.uniforms.color = textColor[axis+2] ++ shader.uniforms.angle = textAngle[axis+2] ++ gl.drawArrays( ++ gl.TRIANGLES, ++ tickOffset[start], ++ tickOffset[end] - tickOffset[start]) ++ } ++ } ++ if(labelEnable[axis+2] && labelCount) { ++ SCREEN_OFFSET[axis^1] += screenScale * pixelRatio * labelPad[axis+2] ++ shader.uniforms.dataAxis = ZERO_2 ++ shader.uniforms.screenOffset = SCREEN_OFFSET ++ shader.uniforms.color = labelColor[axis+2] ++ shader.uniforms.angle = labelAngle[axis+2] ++ gl.drawArrays( ++ gl.TRIANGLES, ++ labelOffset, ++ labelCount) ++ } + +- calcScales.call(this) ++ } ++})() + +- shader.bind() ++proto.drawTitle = (function() { ++ var DATA_AXIS = [0,0] ++ var SCREEN_OFFSET = [0,0] + +- shader.uniforms.pixelScale = PIXEL_SCALE +- shader.uniforms.viewTransform = MATRIX ++ return function() { ++ var plot = this.plot ++ var shader = this.shader ++ var gl = plot.gl ++ var screenBox = plot.screenBox ++ var titleCenter = plot.titleCenter ++ var titleAngle = plot.titleAngle ++ var titleColor = plot.titleColor ++ var titleCenter = plot.titleCenter ++ var pixelRatio = plot.pixelRatio + +- this.positionBuffer.bind() +- shader.attributes.position.pointer() ++ if(!this.titleCount) { ++ return ++ } + +- this.offsetBuffer.bind() +- shader.attributes.offset.pointer() ++ for(var i=0; i<2; ++i) { ++ SCREEN_OFFSET[i] = 2.0 * (titleCenter[i]*pixelRatio - screenBox[i]) / ++ (screenBox[2+i] - screenBox[i]) - 1 ++ } + +- this.colorBuffer.bind() +- shader.attributes.color.pointer(gl.UNSIGNED_BYTE, true) ++ shader.bind() ++ shader.uniforms.dataAxis = DATA_AXIS ++ shader.uniforms.screenOffset = SCREEN_OFFSET ++ shader.uniforms.angle = titleAngle ++ shader.uniforms.color = titleColor + +- gl.drawArrays(gl.TRIANGLES, 0, numVertices) ++ gl.drawArrays(gl.TRIANGLES, this.titleOffset, this.titleCount) + } ++})() + +- var PICK_OFFSET = [0,0,0,0] ++proto.bind = (function() { ++ var DATA_SHIFT = [0,0] ++ var DATA_SCALE = [0,0] ++ var TEXT_SCALE = [0,0] + +- proto.drawPick = function(offset) { +- var plot = this.plot +- var shader = this.pickShader +- var numVertices = this.numVertices ++ return function() { ++ var plot = this.plot ++ var shader = this.shader ++ var bounds = plot._tickBounds ++ var dataBox = plot.dataBox ++ var screenBox = plot.screenBox ++ var viewBox = plot.viewBox + +- var gl = plot.gl ++ shader.bind() + +- this.pickOffset = offset ++ //Set up coordinate scaling uniforms ++ for(var i=0; i<2; ++i) { + +- if(!numVertices) { +- return offset +- } ++ var lo = bounds[i] ++ var hi = bounds[i+2] ++ var boundScale = hi - lo ++ var dataCenter = 0.5 * (dataBox[i+2] + dataBox[i]) ++ var dataWidth = (dataBox[i+2] - dataBox[i]) + +- for(var i=0; i<4; ++i) { +- PICK_OFFSET[i] = ((offset>>(i*8)) & 0xff) ++ var viewLo = viewBox[i] ++ var viewHi = viewBox[i+2] ++ var viewScale = viewHi - viewLo ++ var screenLo = screenBox[i] ++ var screenHi = screenBox[i+2] ++ var screenScale = screenHi - screenLo ++ ++ DATA_SCALE[i] = 2.0 * boundScale / dataWidth * viewScale / screenScale ++ DATA_SHIFT[i] = 2.0 * (lo - dataCenter) / dataWidth * viewScale / screenScale + } + +- calcScales.call(this) ++ TEXT_SCALE[1] = 2.0 * plot.pixelRatio / (screenBox[3] - screenBox[1]) ++ TEXT_SCALE[0] = TEXT_SCALE[1] * (screenBox[3] - screenBox[1]) / (screenBox[2] - screenBox[0]) + +- shader.bind() ++ shader.uniforms.dataScale = DATA_SCALE ++ shader.uniforms.dataShift = DATA_SHIFT ++ shader.uniforms.textScale = TEXT_SCALE + +- shader.uniforms.pixelScale = PIXEL_SCALE +- shader.uniforms.viewTransform = MATRIX +- shader.uniforms.pickOffset = PICK_OFFSET ++ //Set attributes ++ this.vbo.bind() ++ shader.attributes.textCoordinate.pointer() ++ } ++})() + +- this.positionBuffer.bind() +- shader.attributes.position.pointer() ++proto.update = function(options) { ++ var vertices = [] ++ var axesTicks = options.ticks ++ var bounds = options.bounds + +- this.offsetBuffer.bind() +- shader.attributes.offset.pointer() ++ for(var dimension=0; dimension<2; ++dimension) { ++ var offsets = [Math.floor(vertices.length/3)], tickX = [-Infinity] + +- this.idBuffer.bind() +- shader.attributes.id.pointer(gl.UNSIGNED_BYTE, false) ++ //Copy vertices over to buffer ++ var ticks = axesTicks[dimension] ++ for(var i=0; i= pickOffset + pointCount) { +- return null +- } +- var pointId = value - pickOffset +- var points = this.points +- return { +- object: this, +- pointId: pointId, +- dataCoord: [ points[2*pointId], points[2*pointId+1] ] +- } +-} ++ for(var j=0; j> 1 +- for(var j=0; j<2; ++j) { +- bounds[j] = Math.min(bounds[j], positions[2*i+j]) +- bounds[2+j] = Math.max(bounds[2+j], positions[2*i+j]) ++ var data = getText(options.labelFont[dimension], options.labels[dimension]).data ++ var scale = options.labelSize[dimension] ++ for(var i=0; i left) { +- var b_level = data_levels[j-1] +- var b_x = data_points[2*(j-1)] +- if(((b_level - a_level) || (a_x - b_x)) >= 0) { +- break +- } +- data_levels[j] = b_level +- data_points[2*j] = b_x +- data_points[2*j+1] = data_points[2*j-1] +- data_ids[j] = data_ids[j-1] +- data_weights[j] = data_weights[j-1] +- j -= 1 ++ this._depthCounter = 0 ++ ++ if(this.pickDirty) { ++ if(this._pickTimeout) { ++ clearTimeout(this._pickTimeout) + } ++ this.pickDirty = false ++ this._pickTimeout = setTimeout(this._drawPick, this.pickDelay) ++ } + +- data_levels[j] = a_level +- data_points[2*j] = a_x +- data_points[2*j+1] = a_y +- data_ids[j] = a_id +- data_weights[j] = a_weight ++ if(!this.dirty) { ++ return + } +-} ++ this.dirty = false + +-function swap(i, j, data_levels, data_points, data_ids, data_weights) { +- var a_level = data_levels[i] +- var a_x = data_points[2*i] +- var a_y = data_points[2*i+1] +- var a_id = data_ids[i] +- var a_weight = data_weights[i] ++ gl.bindFramebuffer(gl.FRAMEBUFFER, null) + +- data_levels[i] = data_levels[j] +- data_points[2*i] = data_points[2*j] +- data_points[2*i+1] = data_points[2*j+1] +- data_ids[i] = data_ids[j] +- data_weights[i] = data_weights[j] ++ //Turn on scissor ++ gl.enable(gl.SCISSOR_TEST) + +- data_levels[j] = a_level +- data_points[2*j] = a_x +- data_points[2*j+1] = a_y +- data_ids[j] = a_id +- data_weights[j] = a_weight +-} ++ //Turn off depth buffer ++ gl.disable(gl.DEPTH_TEST) ++ gl.depthFunc(gl.LESS) ++ gl.depthMask(false) + +-function move(i, j, data_levels, data_points, data_ids, data_weights) { +- data_levels[i] = data_levels[j] +- data_points[2*i] = data_points[2*j] +- data_points[2*i+1] = data_points[2*j+1] +- data_ids[i] = data_ids[j] +- data_weights[i] = data_weights[j] +-} ++ //Configure premultiplied alpha blending ++ gl.enable(gl.BLEND) ++ gl.blendEquation(gl.FUNC_ADD, gl.FUNC_ADD); ++ gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA); + +-function rotate(i, j, k, data_levels, data_points, data_ids, data_weights) { +- var a_level = data_levels[i] +- var a_x = data_points[2*i] +- var a_y = data_points[2*i+1] +- var a_id = data_ids[i] +- var a_weight = data_weights[i] ++ //Draw border ++ gl.scissor( ++ screenBox[0], ++ screenBox[1], ++ screenBox[2]-screenBox[0], ++ screenBox[3]-screenBox[1]) ++ var borderColor = this.borderColor ++ gl.clearColor( ++ borderColor[0]*borderColor[3], ++ borderColor[1]*borderColor[3], ++ borderColor[2]*borderColor[3], ++ borderColor[3]) ++ gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT) + +- data_levels[i] = data_levels[j] +- data_points[2*i] = data_points[2*j] +- data_points[2*i+1] = data_points[2*j+1] +- data_ids[i] = data_ids[j] +- data_weights[i] = data_weights[j] ++ //Draw center pane ++ gl.scissor( ++ viewPixels[0], ++ viewPixels[1], ++ viewPixels[2]-viewPixels[0], ++ viewPixels[3]-viewPixels[1]) ++ gl.viewport( ++ viewPixels[0], ++ viewPixels[1], ++ viewPixels[2]-viewPixels[0], ++ viewPixels[3]-viewPixels[1]) ++ var backgroundColor = this.backgroundColor ++ gl.clearColor( ++ backgroundColor[0]*backgroundColor[3], ++ backgroundColor[1]*backgroundColor[3], ++ backgroundColor[2]*backgroundColor[3], ++ backgroundColor[3]) ++ gl.clear(gl.COLOR_BUFFER_BIT) + +- data_levels[j] = data_levels[k] +- data_points[2*j] = data_points[2*k] +- data_points[2*j+1] = data_points[2*k+1] +- data_ids[j] = data_ids[k] +- data_weights[j] = data_weights[k] ++ //Draw grid ++ grid.draw() + +- data_levels[k] = a_level +- data_points[2*k] = a_x +- data_points[2*k+1] = a_y +- data_ids[k] = a_id +- data_weights[k] = a_weight +-} ++ //Draw zero lines separately ++ var zeroLineEnable = this.zeroLineEnable ++ var zeroLineColor = this.zeroLineColor ++ var zeroLineWidth = this.zeroLineWidth ++ if(zeroLineEnable[0] || zeroLineEnable[1]) { ++ line.bind() ++ for(var i=0; i<2; ++i) { ++ if(!zeroLineEnable[i] || ++ !(dataBox[i] <= 0 && dataBox[i+2] >= 0)) { ++ continue ++ } + +-function shufflePivot( +- i, j, +- a_level, a_x, a_y, a_id, a_weight, +- data_levels, data_points, data_ids, data_weights) { ++ var zeroIntercept = screenBox[i] - ++ dataBox[i] * (screenBox[i+2] - screenBox[i]) / (dataBox[i+2] - dataBox[i]) + +- data_levels[i] = data_levels[j] +- data_points[2*i] = data_points[2*j] +- data_points[2*i+1] = data_points[2*j+1] +- data_ids[i] = data_ids[j] +- data_weights[i] = data_weights[j] ++ if(i === 0) { ++ line.drawLine( ++ zeroIntercept, screenBox[1], zeroIntercept, screenBox[3], ++ zeroLineWidth[i], ++ zeroLineColor[i]) ++ } else { ++ line.drawLine( ++ screenBox[0], zeroIntercept, screenBox[2], zeroIntercept, ++ zeroLineWidth[i], ++ zeroLineColor[i]) ++ } ++ } ++ } + +- data_levels[j] = a_level +- data_points[2*j] = a_x +- data_points[2*j+1] = a_y +- data_ids[j] = a_id +- data_weights[j] = a_weight +-} ++ //Draw traces ++ for(var i=0; i> 1, +- index2 = index3 - sixth, +- index4 = index3 + sixth, +- el1 = index1, +- el2 = index2, +- el3 = index3, +- el4 = index4, +- el5 = index5, +- less = left + 1, +- great = right - 1, +- tmp = 0 +- if(compare(el1, el2, data_levels, data_points, data_ids, data_weights)) { +- tmp = el1 +- el1 = el2 +- el2 = tmp +- } +- if(compare(el4, el5, data_levels, data_points, data_ids, data_weights)) { +- tmp = el4 +- el4 = el5 +- el5 = tmp +- } +- if(compare(el1, el3, data_levels, data_points, data_ids, data_weights)) { +- tmp = el1 +- el1 = el3 +- el3 = tmp ++ //Draw line elements ++ line.bind() ++ ++ //Draw border lines ++ var borderLineEnable = this.borderLineEnable ++ var borderLineWidth = this.borderLineWidth ++ var borderLineColor = this.borderLineColor ++ if(borderLineEnable[1]) { ++ line.drawLine( ++ viewPixels[0], viewPixels[1] - 0.5*borderLineWidth[1]*pixelRatio, ++ viewPixels[0], viewPixels[3] + 0.5*borderLineWidth[3]*pixelRatio, ++ borderLineWidth[1], borderLineColor[1]) + } +- if(compare(el2, el3, data_levels, data_points, data_ids, data_weights)) { +- tmp = el2 +- el2 = el3 +- el3 = tmp ++ if(borderLineEnable[0]) { ++ line.drawLine( ++ viewPixels[0] - 0.5*borderLineWidth[0]*pixelRatio, viewPixels[1], ++ viewPixels[2] + 0.5*borderLineWidth[2]*pixelRatio, viewPixels[1], ++ borderLineWidth[0], borderLineColor[0]) + } +- if(compare(el1, el4, data_levels, data_points, data_ids, data_weights)) { +- tmp = el1 +- el1 = el4 +- el4 = tmp ++ if(borderLineEnable[3]) { ++ line.drawLine( ++ viewPixels[2], viewPixels[1] - 0.5*borderLineWidth[1]*pixelRatio, ++ viewPixels[2], viewPixels[3] + 0.5*borderLineWidth[3]*pixelRatio, ++ borderLineWidth[3], borderLineColor[3]) + } +- if(compare(el3, el4, data_levels, data_points, data_ids, data_weights)) { +- tmp = el3 +- el3 = el4 +- el4 = tmp ++ if(borderLineEnable[2]) { ++ line.drawLine( ++ viewPixels[0] - 0.5*borderLineWidth[0]*pixelRatio, viewPixels[3], ++ viewPixels[2] + 0.5*borderLineWidth[2]*pixelRatio, viewPixels[3], ++ borderLineWidth[2], borderLineColor[2]) + } +- if(compare(el2, el5, data_levels, data_points, data_ids, data_weights)) { +- tmp = el2 +- el2 = el5 +- el5 = tmp ++ ++ //Draw text elements ++ text.bind() ++ for(var i=0; i<2; ++i) { ++ text.drawTicks(i) + } +- if(compare(el2, el3, data_levels, data_points, data_ids, data_weights)) { +- tmp = el2 +- el2 = el3 +- el3 = tmp ++ if(this.titleEnable) { ++ text.drawTitle() + } +- if(compare(el4, el5, data_levels, data_points, data_ids, data_weights)) { +- tmp = el4 +- el4 = el5 +- el5 = tmp ++ ++ //Draw other overlay elements (select boxes, etc.) ++ var overlays = this.overlays ++ for(var i=0; i>> 1 +- if(n < 1) { +- return [] +- } ++proto.update = function(options) { ++ options = options || {} + +- var lox = Infinity, loy = Infinity +- var hix = -Infinity, hiy = -Infinity +- for(var i=0; i= Math.max(0.9 * count, 32)) { +- var mid = (end + start)>>>1 +- snapRec(nx, ny, diam_2, offset, mid, level+1) +- offset = mid +- } +- snapRec(nx, ny, diam_2, offset, nextOffset, level+1) +- offset = nextOffset +- } +- } +- } +- snapRec(lox, loy, diam, 0, n, 0) +- sortLevels(levels, points, ids, weights, n) ++ this.borderColor = (options.borderColor || [0,0,0,0]).slice() ++ this.backgroundColor = (options.backgroundColor || [0,0,0,0]).slice() + +- var lod = [] +- var lastLevel = 0 +- var prevOffset = n +- for(var ptr=n-1; ptr>=0; --ptr) { +- points[2*ptr] = (points[2*ptr] - lox) * scaleX +- points[2*ptr+1] = (points[2*ptr+1] - loy) * scaleY ++ this.gridLineEnable = (options.gridLineEnable || [true,true]).slice() ++ this.gridLineWidth = (options.gridLineWidth || [1,1]).slice() ++ this.gridLineColor = deepClone(options.gridLineColor || ++ [[0.5,0.5,0.5,1],[0.5,0.5,0.5,1]]) + +- var level = levels[ptr] +- if(level === lastLevel) { +- continue +- } ++ this.zeroLineEnable = (options.zeroLineEnable || [true, true]).slice() ++ this.zeroLineWidth = (options.zeroLineWidth || [4, 4]).slice() ++ this.zeroLineColor = deepClone(options.zeroLineColor || ++ [[0, 0, 0, 1],[0, 0, 0, 1]]) + +- lod.push(new SnapInterval( +- diam * Math.pow(0.5, level), +- ptr+1, +- prevOffset - (ptr+1) +- )) +- prevOffset = ptr+1 ++ this.tickMarkLength = (options.tickMarkLength || [0,0,0,0]).slice() ++ this.tickMarkWidth = (options.tickMarkWidth || [0,0,0,0]).slice() ++ this.tickMarkColor = deepClone(options.tickMarkColor || ++ [[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]]) + +- lastLevel = level +- } ++ this.titleCenter = (options.titleCenter || [ ++ 0.5*(viewBox[0]+viewBox[2])/pixelRatio,(viewBox[3]+120)/pixelRatio]).slice() ++ this.titleEnable = !('titleEnable' in options) || !!options.titleEnable ++ this.titleAngle = options.titleAngle || 0 ++ this.titleColor = (options.titleColor || [0,0,0,1]).slice() + +- lod.push(new SnapInterval(diam * Math.pow(0.5, level+1), 0, prevOffset)) +- pool.free(levels) ++ this.labelPad = (options.labelPad || [15,15,15,15]).slice() ++ this.labelAngle = (options.labelAngle || ++ [0,Math.PI/2,0,3.0*Math.PI/2]).slice() ++ this.labelEnable = (options.labelEnable || [true,true,true,true]).slice() ++ this.labelColor = deepClone(options.labelColor || ++ [[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]]) + +- return lod +-} ++ this.tickPad = (options.tickPad || [15,15,15,15]).slice() ++ this.tickAngle = (options.tickAngle || [0,0,0,0]).slice() ++ this.tickEnable = (options.tickEnable || [true,true,true,true]).slice() ++ this.tickColor = deepClone(options.tickColor || ++ [[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]]) + +-},{"./lib/sort":90,"typedarray-pool":151}],92:[function(require,module,exports){ +-'use strict' ++ this.borderLineEnable = (options.borderLineEnable || ++ [true,true,true,true]).slice() ++ this.borderLineWidth = (options.borderLineWidth || [2,2,2,2]).slice() ++ this.borderLineColor = deepClone(options.borderLineColor || ++ [[0,0,0,1], ++ [0,0,0,1], ++ [0,0,0,1], ++ [0,0,0,1]]) + +-var createShader = require('gl-shader') +-var createBuffer = require('gl-buffer') +-var bsearch = require('binary-search-bounds') +-var snapPoints = require('snap-points-2d') ++ var ticks = options.ticks || [ [], [] ] + +-var pool = require('typedarray-pool') ++ //Compute bounds on ticks ++ var bounds = this._tickBounds ++ bounds[0] = bounds[1] = Infinity ++ bounds[2] = bounds[3] = -Infinity ++ for(var i=0; i<2; ++i) { ++ var axisTicks = ticks[i].slice(0) ++ if(axisTicks.length === 0) { ++ continue ++ } ++ axisTicks.sort(compareTicks) ++ bounds[i] = Math.min(bounds[i], axisTicks[0].x) ++ bounds[i+2] = Math.max(bounds[i+2], axisTicks[axisTicks.length-1].x) ++ } + +-var SHADERS = require('./lib/shader') ++ //Update grid ++ this.grid.update({ ++ bounds: bounds, ++ ticks: ticks ++ }) + +-module.exports = createScatter2D ++ //Update text ++ this.text.update({ ++ bounds: bounds, ++ ticks: ticks, ++ labels: options.labels || ['x', 'y'], ++ labelSize: options.labelSize || [12,12], ++ labelFont: options.labelFont || ['sans-serif', 'sans-serif'], ++ title: options.title || '', ++ titleSize: options.titleSize || 18, ++ titleFont: options.titleFont || 'sans-serif' ++ }) + +-function Scatter2D(plot, offsetBuffer, pickBuffer, weightBuffer, shader, pickShader) { +- this.plot = plot +- this.offsetBuffer = offsetBuffer +- this.pickBuffer = pickBuffer +- this.weightBuffer = weightBuffer +- this.shader = shader +- this.pickShader = pickShader +- this.scales = [] +- this.size = 12.0 +- this.borderSize = 1.0 +- this.pointCount = 0 +- this.color = [1,0,0,1] +- this.borderColor = [0,0,0,1] +- this.bounds = [Infinity,Infinity,-Infinity,-Infinity] +- this.pickOffset = 0 +- this.points = null +- this.xCoords = null ++ this.setDirty() + } + +-var proto = Scatter2D.prototype +- + proto.dispose = function() { +- this.shader.dispose() +- this.pickShader.dispose() +- this.offsetBuffer.dispose() +- this.pickBuffer.dispose() +- if(this.xCoords) { +- pool.free(this.xCoords) ++ this.box.dispose() ++ this.grid.dispose() ++ this.text.dispose() ++ this.line.dispose() ++ for(var i=this.objects.length-1; i>=0; --i) { ++ this.objects[i].dispose() + } +- this.plot.removeObject(this) ++ this.objects.length = 0 ++ for(var i=this.overlays.length-1; i>=0; --i) { ++ this.overlays[i].dispose() ++ } ++ this.overlays.length = 0 ++ ++ this.gl = null + } + +-proto.update = function(options) { +- options = options || {} ++proto.addObject = function(object) { ++ if(this.objects.indexOf(object) < 0) { ++ this.objects.push(object) ++ this.setDirty() ++ } ++} + +- function dflt(opt, value) { +- if(opt in options) { +- return options[opt] ++proto.removeObject = function(object) { ++ var objects = this.objects ++ for(var i=0; i>>1) +- packed.set(data) +- var packedW = pool.mallocFloat32(data.length) +- this.points = data +- this.scales = snapPoints(packed, packedId, packedW, this.bounds) +- this.offsetBuffer.update(packed) +- this.pickBuffer.update(packedId) +- this.weightBuffer.update(packedW) +- var xCoords = pool.mallocFloat32(data.length>>>1) +- for(var i=0,j=0; i>> 1 +- this.pickOffset = 0 ++},{"./lib/box":79,"./lib/grid":80,"./lib/line":81,"./lib/text":83,"gl-select-static":95}],86:[function(require,module,exports){ ++'use strict' ++ ++ ++ ++module.exports = { ++ vertex: "precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec2 offset;\nattribute vec4 color;\n\nuniform mat3 viewTransform;\nuniform vec2 pixelScale;\n\nvarying vec4 fragColor;\n\nvec4 computePosition_1_0(vec2 position, vec2 offset, mat3 view, vec2 scale) {\n vec3 xposition = view * vec3(position, 1.0);\n return vec4(\n xposition.xy + scale * offset * xposition.z,\n 0,\n xposition.z);\n}\n\n\n\n\nvoid main() {\n fragColor = color;\n\n gl_Position = computePosition_1_0(\n position,\n offset,\n viewTransform,\n pixelScale);\n}\n", ++ fragment: "precision lowp float;\n#define GLSLIFY 1\nvarying vec4 fragColor;\nvoid main() {\n gl_FragColor = vec4(fragColor.rgb * fragColor.a, fragColor.a);\n}\n", ++ pickVertex: "precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec2 offset;\nattribute vec4 id;\n\nuniform mat3 viewTransform;\nuniform vec2 pixelScale;\nuniform vec4 pickOffset;\n\nvarying vec4 fragColor;\n\nvec4 computePosition_1_0(vec2 position, vec2 offset, mat3 view, vec2 scale) {\n vec3 xposition = view * vec3(position, 1.0);\n return vec4(\n xposition.xy + scale * offset * xposition.z,\n 0,\n xposition.z);\n}\n\n\n\n\nvoid main() {\n vec4 fragId = id + pickOffset;\n\n fragId.y += floor(fragId.x / 256.0);\n fragId.x -= floor(fragId.x / 256.0) * 256.0;\n\n fragId.z += floor(fragId.y / 256.0);\n fragId.y -= floor(fragId.y / 256.0) * 256.0;\n\n fragId.w += floor(fragId.z / 256.0);\n fragId.z -= floor(fragId.z / 256.0) * 256.0;\n\n fragColor = fragId / 255.0;\n\n gl_Position = computePosition_1_0(\n position,\n offset,\n viewTransform,\n pixelScale);\n}\n", ++ pickFragment: "precision lowp float;\n#define GLSLIFY 1\nvarying vec4 fragColor;\nvoid main() {\n gl_FragColor = fragColor;\n}\n" + } + +-proto.drawPick = (function() { +- var MATRIX = [1,0,0, +- 0,1,0, +- 0,0,1] +- var PICK_VEC4 = [0,0,0,0] +-return function(pickOffset) { +- var plot = this.plot +- var shader = this.pickShader +- var scales = this.scales +- var offsetBuffer = this.offsetBuffer +- var pickBuffer = this.pickBuffer +- var bounds = this.bounds +- var size = this.size +- var borderSize = this.borderSize +- var gl = plot.gl +- var pixelRatio = plot.pickPixelRatio +- var viewBox = plot.viewBox +- var dataBox = plot.dataBox ++},{}],87:[function(require,module,exports){ ++'use strict' + +- if(this.pointCount === 0) { +- return pickOffset ++module.exports = createFancyScatter2D ++ ++var createShader = require('gl-shader') ++var createBuffer = require('gl-buffer') ++var textCache = require('text-cache') ++var pool = require('typedarray-pool') ++var vectorizeText = require('vectorize-text') ++var shaders = require('./lib/shaders') ++ ++var BOUNDARIES = {} ++ ++function getBoundary(glyph) { ++ if(glyph in BOUNDARIES) { ++ return BOUNDARIES[glyph] + } + +- var boundX = bounds[2] - bounds[0] +- var boundY = bounds[3] - bounds[1] +- var dataX = dataBox[2] - dataBox[0] +- var dataY = dataBox[3] - dataBox[1] +- var screenX = (viewBox[2] - viewBox[0]) * pixelRatio / plot.pixelRatio +- var screenY = (viewBox[3] - viewBox[1]) * pixelRatio / plot.pixelRatio ++ var polys = vectorizeText(glyph, { ++ polygons: true, ++ font: 'sans-serif', ++ textAlign: 'left', ++ textBaseline: 'alphabetic' ++ }) + +- var pixelSize = Math.min(dataX / screenX, dataY / screenY) +- var targetScale = pixelSize ++ var coords = [] ++ var normals = [] + ++ polys.forEach(function(loops) { ++ loops.forEach(function(loop) { ++ for(var i=0; i>8) & 0xff) +- PICK_VEC4[2] = ((pickOffset>>16) & 0xff) +- PICK_VEC4[3] = ((pickOffset>>24) & 0xff) ++ coords.push(a[0], a[1] + 1.4) ++ normals.push(dy, -dx) ++ coords.push(a[0], a[1] + 1.4) ++ normals.push(-dy, dx) ++ coords.push(b[0], b[1] + 1.4) ++ normals.push(-dy, dx) + +- shader.bind() +- shader.uniforms.matrix = MATRIX +- shader.uniforms.color = this.color +- shader.uniforms.borderColor = this.borderColor +- shader.uniforms.pointSize = pixelRatio * (size + borderSize) +- shader.uniforms.pickOffset = PICK_VEC4 ++ coords.push(b[0], b[1] + 1.4) ++ normals.push(-dy, dx) ++ coords.push(a[0], a[1] + 1.4) ++ normals.push(dy, -dx) ++ coords.push(b[0], b[1] + 1.4) ++ normals.push(dy, -dx) + +- if(this.borderSize === 0) { +- shader.uniforms.centerFraction = 2.0; +- } else { +- shader.uniforms.centerFraction = size / (size + borderSize + 1.25) +- } ++ var ex = d[0] - c[0] ++ var ey = d[1] - c[1] ++ var el = Math.sqrt(ex*ex + ey*ey) ++ ex /= el ++ ey /= el + +- offsetBuffer.bind() +- shader.attributes.position.pointer() +- pickBuffer.bind() +- shader.attributes.pickId.pointer(gl.UNSIGNED_BYTE) ++ coords.push(b[0], b[1]+1.4) ++ normals.push(dy, -dx) ++ coords.push(b[0], b[1]+1.4) ++ normals.push(-dy, dx) ++ coords.push(c[0], c[1]+1.4) ++ normals.push(-ey, ex) + +- var xCoords = this.xCoords +- var xStart = (dataBox[0] - bounds[0] - pixelSize * size * pixelRatio) / boundX +- var xEnd = (dataBox[2] - bounds[0] + pixelSize * size * pixelRatio) / boundX ++ coords.push(c[0], c[1]+1.4) ++ normals.push(-ey, ex) ++ coords.push(b[0], b[1]+1.4) ++ normals.push(ey, -ex) ++ coords.push(c[0], c[1]+1.4) ++ normals.push(ey, -ex) ++ } ++ }) ++ }) + +- for(var scaleNum = scales.length-1; scaleNum >= 0; --scaleNum) { +- var lod = scales[scaleNum] +- if(lod.pixelSize < pixelSize && scaleNum > 1) { +- continue ++ var bounds = [Infinity, Infinity, -Infinity, -Infinity] ++ for(var i=0; i startOffset) { +- gl.drawArrays(gl.POINTS, startOffset, endOffset - startOffset) +- } +- } ++var VERTEX_SIZE = 9 ++var VERTEX_SIZE_BYTES = VERTEX_SIZE * 4 + +- return pickOffset + this.pointCount ++function GLScatterFancy( ++ plot, ++ shader, ++ pickShader, ++ positionBuffer, ++ offsetBuffer, ++ colorBuffer, ++ idBuffer) { ++ this.plot = plot ++ this.shader = shader ++ this.pickShader = pickShader ++ this.positionBuffer = positionBuffer ++ this.offsetBuffer = offsetBuffer ++ this.colorBuffer = colorBuffer ++ this.idBuffer = idBuffer ++ this.bounds = [Infinity, Infinity, -Infinity, -Infinity] ++ this.numPoints = 0 ++ this.numVertices = 0 ++ this.pickOffset = 0 ++ this.points = null + } +-})() + +-proto.draw = (function() { +- var MATRIX = [1, 0, 0, +- 0, 1, 0, +- 0, 0, 1] ++var proto = GLScatterFancy.prototype + +- return function() { ++;(function() { ++ var MATRIX = [ ++ 1, 0, 0, ++ 0, 1, 0, ++ 0, 0, 1 ++ ]; ++ ++ var PIXEL_SCALE = [1, 1] ++ ++ function calcScales() { + var plot = this.plot +- var shader = this.shader +- var scales = this.scales +- var offsetBuffer = this.offsetBuffer + var bounds = this.bounds +- var size = this.size +- var borderSize = this.borderSize +- var gl = plot.gl +- var pixelRatio = plot.pixelRatio +- var viewBox = plot.viewBox +- var dataBox = plot.dataBox + +- if(this.pointCount === 0) { +- return +- } ++ var viewBox = plot.viewBox ++ var dataBox = plot.dataBox ++ var pixelRatio = plot.pixelRatio + + var boundX = bounds[2] - bounds[0] + var boundY = bounds[3] - bounds[1] + var dataX = dataBox[2] - dataBox[0] + var dataY = dataBox[3] - dataBox[1] +- var screenX = viewBox[2] - viewBox[0] +- var screenY = viewBox[3] - viewBox[1] +- +- var pixelSize = Math.min(dataX / screenX, dataY / screenY) +- var targetScale = pixelSize + + MATRIX[0] = 2.0 * boundX / dataX + MATRIX[4] = 2.0 * boundY / dataY + MATRIX[6] = 2.0 * (bounds[0] - dataBox[0]) / dataX - 1.0 + MATRIX[7] = 2.0 * (bounds[1] - dataBox[1]) / dataY - 1.0 + +- shader.bind() +- shader.uniforms.matrix = MATRIX +- shader.uniforms.color = this.color +- shader.uniforms.borderColor = this.borderColor +- shader.uniforms.pointSize = pixelRatio * (size + borderSize) +- shader.uniforms.useWeight = 1 ++ var screenX = (viewBox[2] - viewBox[0]) ++ var screenY = (viewBox[3] - viewBox[1]) + +- if(this.borderSize === 0) { +- shader.uniforms.centerFraction = 2.0; +- } else { +- shader.uniforms.centerFraction = size / (size + borderSize + 1.25) +- } ++ PIXEL_SCALE[0] = 2.0 * pixelRatio / screenX ++ PIXEL_SCALE[1] = 2.0 * pixelRatio / screenY ++ } + +- offsetBuffer.bind() +- shader.attributes.position.pointer() ++ proto.draw = function() { ++ var plot = this.plot ++ var shader = this.shader ++ var numVertices = this.numVertices + +- this.weightBuffer.bind() +- shader.attributes.weight.pointer() ++ if(!numVertices) { ++ return ++ } + +- var xCoords = this.xCoords +- var xStart = (dataBox[0] - bounds[0] - pixelSize * size * pixelRatio) / boundX +- var xEnd = (dataBox[2] - bounds[0] + pixelSize * size * pixelRatio) / boundX ++ var gl = plot.gl + +- var firstLevel = true ++ calcScales.call(this) + +- for(var scaleNum = scales.length-1; scaleNum >= 0; --scaleNum) { +- var lod = scales[scaleNum] +- if(lod.pixelSize < pixelSize && scaleNum > 1) { +- continue +- } ++ shader.bind() + +- var intervalStart = lod.offset +- var intervalEnd = lod.count + intervalStart ++ shader.uniforms.pixelScale = PIXEL_SCALE ++ shader.uniforms.viewTransform = MATRIX + +- var startOffset = bsearch.ge(xCoords, xStart, intervalStart, intervalEnd-1) +- var endOffset = bsearch.lt(xCoords, xEnd, startOffset, intervalEnd-1)+1 ++ this.positionBuffer.bind() ++ shader.attributes.position.pointer() + +- if(endOffset > startOffset) { +- gl.drawArrays(gl.POINTS, startOffset, endOffset - startOffset) +- } ++ this.offsetBuffer.bind() ++ shader.attributes.offset.pointer() + +- if(firstLevel) { +- firstLevel = false +- shader.uniforms.useWeight = 0 +- } +- } +- } +-})() ++ this.colorBuffer.bind() ++ shader.attributes.color.pointer(gl.UNSIGNED_BYTE, true) + +-proto.pick = function(x, y, value) { +- var pickOffset = this.pickOffset +- var pointCount = this.pointCount +- if(value < pickOffset || value >= pickOffset + pointCount) { +- return null +- } +- var pointId = value - pickOffset +- var points = this.points +- return { +- object: this, +- pointId: pointId, +- dataCoord: [ points[2*pointId], points[2*pointId+1] ] ++ gl.drawArrays(gl.TRIANGLES, 0, numVertices) + } +-} +- +-function createScatter2D(plot, options) { +- var gl = plot.gl +- var buffer = createBuffer(gl) +- var pickBuffer = createBuffer(gl) +- var weightBuffer = createBuffer(gl) +- var shader = createShader(gl, SHADERS.pointVertex, SHADERS.pointFragment) +- var pickShader = createShader(gl, SHADERS.pickVertex, SHADERS.pickFragment) +- +- var result = new Scatter2D( +- plot, buffer, pickBuffer, weightBuffer, shader, pickShader) +- result.update(options) + +- //Register with plot +- plot.addObject(result) +- +- return result +-} +- +-},{"./lib/shader":88,"binary-search-bounds":89,"gl-buffer":66,"gl-shader":96,"snap-points-2d":91,"typedarray-pool":151}],93:[function(require,module,exports){ +-'use strict' ++ var PICK_OFFSET = [0,0,0,0] + ++ proto.drawPick = function(offset) { ++ var plot = this.plot ++ var shader = this.pickShader ++ var numVertices = this.numVertices + ++ var gl = plot.gl + +-exports.boxVertex = "precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 vertex;\n\nuniform vec2 cornerA, cornerB;\n\nvoid main() {\n gl_Position = vec4(mix(cornerA, cornerB, vertex), 0, 1);\n}\n" +-exports.boxFragment = "precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 color;\n\nvoid main() {\n gl_FragColor = color;\n}\n" ++ this.pickOffset = offset + +-},{}],94:[function(require,module,exports){ +-'use strict' ++ if(!numVertices) { ++ return offset ++ } + +-var createShader = require('gl-shader') +-var createBuffer = require('gl-buffer') ++ for(var i=0; i<4; ++i) { ++ PICK_OFFSET[i] = ((offset>>(i*8)) & 0xff) ++ } + +-var SHADERS = require('./lib/shaders') ++ calcScales.call(this) + +-module.exports = createSelectBox ++ shader.bind() + +-function SelectBox(plot, boxBuffer, boxShader) { +- this.plot = plot +- this.boxBuffer = boxBuffer +- this.boxShader = boxShader ++ shader.uniforms.pixelScale = PIXEL_SCALE ++ shader.uniforms.viewTransform = MATRIX ++ shader.uniforms.pickOffset = PICK_OFFSET + +- this.enabled = true ++ this.positionBuffer.bind() ++ shader.attributes.position.pointer() + +- this.selectBox = [Infinity,Infinity,-Infinity,-Infinity] ++ this.offsetBuffer.bind() ++ shader.attributes.offset.pointer() + +- this.borderColor = [0,0,0,1] +- this.innerFill = false +- this.innerColor = [0,0,0,0.25] +- this.outerFill = true +- this.outerColor = [0,0,0,0.5] +- this.borderWidth = 10 +-} ++ this.idBuffer.bind() ++ shader.attributes.id.pointer(gl.UNSIGNED_BYTE, false) + +-var proto = SelectBox.prototype ++ gl.drawArrays(gl.TRIANGLES, 0, numVertices) + +-proto.draw = function() { +- if(!this.enabled) { +- return ++ return offset + this.numPoints + } ++})() + +- var plot = this.plot +- var selectBox = this.selectBox +- var lineWidth = this.borderWidth +- +- var innerFill = this.innerFill +- var innerColor = this.innerColor +- var outerFill = this.outerFill +- var outerColor = this.outerColor +- var borderColor = this.borderColor ++proto.pick = function(x, y, value) { ++ var pickOffset = this.pickOffset ++ var pointCount = this.numPoints ++ if(value < pickOffset || value >= pickOffset + pointCount) { ++ return null ++ } ++ var pointId = value - pickOffset ++ var points = this.points ++ return { ++ object: this, ++ pointId: pointId, ++ dataCoord: [ points[2*pointId], points[2*pointId+1] ] ++ } ++} + +- var boxes = plot.box +- var screenBox = plot.screenBox +- var dataBox = plot.dataBox +- var viewBox = plot.viewBox +- var pixelRatio = plot.pixelRatio ++proto.update = function(options) { ++ options = options || {} + +- //Map select box into pixel coordinates +- var loX = (selectBox[0]-dataBox[0])*(viewBox[2]-viewBox[0])/(dataBox[2]-dataBox[0])+viewBox[0] +- var loY = (selectBox[1]-dataBox[1])*(viewBox[3]-viewBox[1])/(dataBox[3]-dataBox[1])+viewBox[1] +- var hiX = (selectBox[2]-dataBox[0])*(viewBox[2]-viewBox[0])/(dataBox[2]-dataBox[0])+viewBox[0] +- var hiY = (selectBox[3]-dataBox[1])*(viewBox[3]-viewBox[1])/(dataBox[3]-dataBox[1])+viewBox[1] ++ var positions = options.positions || [] ++ var colors = options.colors || [] ++ var glyphs = options.glyphs || [] ++ var sizes = options.sizes || [] ++ var borderWidths = options.borderWidths || [] ++ var borderColors = options.borderColors || [] + +- loX = Math.max(loX, viewBox[0]) +- loY = Math.max(loY, viewBox[1]) +- hiX = Math.min(hiX, viewBox[2]) +- hiY = Math.min(hiY, viewBox[3]) ++ this.points = positions + +- if(hiX < loX || hiY < loY) { +- return ++ var bounds = this.bounds = [Infinity, Infinity, -Infinity, -Infinity] ++ var numVertices = 0 ++ for(var i=0; i> 1 ++ for(var j=0; j<2; ++j) { ++ bounds[j] = Math.min(bounds[j], positions[2*i+j]) ++ bounds[2+j] = Math.max(bounds[2+j], positions[2*i+j]) ++ } + } + +- boxes.bind() +- +- //Draw box +- var screenWidth = screenBox[2] - screenBox[0] +- var screenHeight = screenBox[3] - screenBox[1] +- +- if(this.outerFill) { +- boxes.drawBox(0, 0, screenWidth, loY, outerColor) +- boxes.drawBox(0, loY, loX, hiY, outerColor) +- boxes.drawBox(0, hiY, screenWidth, screenHeight, outerColor) +- boxes.drawBox(hiX, loY, screenWidth, hiY, outerColor) ++ if(bounds[0] === bounds[2]) { ++ bounds[2] += 1 + } +- +- if(this.innerFill) { +- boxes.drawBox(loX, loY, hiX, hiY, innerColor) ++ if(bounds[3] === bounds[1]) { ++ bounds[3] += 1 + } + +- //Draw border +- if(lineWidth > 0) { ++ var sx = 1/(bounds[2] - bounds[0]) ++ var sy = 1/(bounds[3] - bounds[1]) ++ var tx = bounds[0] ++ var ty = bounds[1] + +- //Draw border +- var w = lineWidth * pixelRatio +- boxes.drawBox(loX-w, loY-w, hiX+w, loY+w, borderColor) +- boxes.drawBox(loX-w, hiY-w, hiX+w, hiY+w, borderColor) +- boxes.drawBox(loX-w, loY-w, loX+w, hiY+w, borderColor) +- boxes.drawBox(hiX-w, loY-w, hiX+w, hiY+w, borderColor) +- } +-} ++ var v_position = pool.mallocFloat32(2 * numVertices) ++ var v_offset = pool.mallocFloat32(2 * numVertices) ++ var v_color = pool.mallocUint8(4 * numVertices) ++ var v_ids = pool.mallocUint32(numVertices) ++ var ptr = 0 + +-proto.update = function(options) { +- options = options || {} ++ for(var i=0; i_inline_52_arg0_||255>_inline_52_arg1_||255>_inline_52_arg2_||255>_inline_52_arg3_){var _inline_52_l=_inline_52_arg4_-_inline_52_arg6_[0],_inline_52_a=_inline_52_arg5_-_inline_52_arg6_[1],_inline_52_f=_inline_52_l*_inline_52_l+_inline_52_a*_inline_52_a;_inline_52_f this.buffer.length) { +- pool.free(this.buffer) +- var buffer = this.buffer = pool.mallocUint8(nextPow2(r*c*4)) +- for(var i=0; i left) { ++ var b_level = data_levels[j-1] ++ var b_x = data_points[2*(j-1)] ++ if(((b_level - a_level) || (a_x - b_x)) >= 0) { ++ break ++ } ++ data_levels[j] = b_level ++ data_points[2*j] = b_x ++ data_points[2*j+1] = data_points[2*j-1] ++ data_ids[j] = data_ids[j-1] ++ data_weights[j] = data_weights[j-1] ++ j -= 1 ++ } + +-proto.dispose = function() { +- if(!this.gl) { +- return +- } +- this.fbo.dispose() +- pool.free(this.buffer) +- this.gl = null +- if(this._readTimeout) { +- clearTimeout(this._readTimeout) ++ data_levels[j] = a_level ++ data_points[2*j] = a_x ++ data_points[2*j+1] = a_y ++ data_ids[j] = a_id ++ data_weights[j] = a_weight + } + } + +-function createSelectBuffer(gl, shape) { +- var fbo = createFBO(gl, shape) +- var buffer = pool.mallocUint8(shape[0]*shape[1]*4) +- return new SelectBuffer(gl, fbo, buffer) ++function swap(i, j, data_levels, data_points, data_ids, data_weights) { ++ var a_level = data_levels[i] ++ var a_x = data_points[2*i] ++ var a_y = data_points[2*i+1] ++ var a_id = data_ids[i] ++ var a_weight = data_weights[i] ++ ++ data_levels[i] = data_levels[j] ++ data_points[2*i] = data_points[2*j] ++ data_points[2*i+1] = data_points[2*j+1] ++ data_ids[i] = data_ids[j] ++ data_weights[i] = data_weights[j] ++ ++ data_levels[j] = a_level ++ data_points[2*j] = a_x ++ data_points[2*j+1] = a_y ++ data_ids[j] = a_id ++ data_weights[j] = a_weight + } + +-},{"bit-twiddle":9,"cwise/lib/wrapper":61,"gl-fbo":72,"ndarray":131,"typedarray-pool":151}],96:[function(require,module,exports){ +-'use strict' ++function move(i, j, data_levels, data_points, data_ids, data_weights) { ++ data_levels[i] = data_levels[j] ++ data_points[2*i] = data_points[2*j] ++ data_points[2*i+1] = data_points[2*j+1] ++ data_ids[i] = data_ids[j] ++ data_weights[i] = data_weights[j] ++} + +-var createUniformWrapper = require('./lib/create-uniforms') +-var createAttributeWrapper = require('./lib/create-attributes') +-var makeReflect = require('./lib/reflect') +-var shaderCache = require('./lib/shader-cache') +-var runtime = require('./lib/runtime-reflect') +-var GLError = require("./lib/GLError") ++function rotate(i, j, k, data_levels, data_points, data_ids, data_weights) { ++ var a_level = data_levels[i] ++ var a_x = data_points[2*i] ++ var a_y = data_points[2*i+1] ++ var a_id = data_ids[i] ++ var a_weight = data_weights[i] + +-//Shader object +-function Shader(gl) { +- this.gl = gl ++ data_levels[i] = data_levels[j] ++ data_points[2*i] = data_points[2*j] ++ data_points[2*i+1] = data_points[2*j+1] ++ data_ids[i] = data_ids[j] ++ data_weights[i] = data_weights[j] + +- //Default initialize these to null +- this._vref = +- this._fref = +- this._relink = +- this.vertShader = +- this.fragShader = +- this.program = +- this.attributes = +- this.uniforms = +- this.types = null ++ data_levels[j] = data_levels[k] ++ data_points[2*j] = data_points[2*k] ++ data_points[2*j+1] = data_points[2*k+1] ++ data_ids[j] = data_ids[k] ++ data_weights[j] = data_weights[k] ++ ++ data_levels[k] = a_level ++ data_points[2*k] = a_x ++ data_points[2*k+1] = a_y ++ data_ids[k] = a_id ++ data_weights[k] = a_weight + } + +-var proto = Shader.prototype ++function shufflePivot( ++ i, j, ++ a_level, a_x, a_y, a_id, a_weight, ++ data_levels, data_points, data_ids, data_weights) { + +-proto.bind = function() { +- if(!this.program) { +- this._relink() +- } +- this.gl.useProgram(this.program) +-} ++ data_levels[i] = data_levels[j] ++ data_points[2*i] = data_points[2*j] ++ data_points[2*i+1] = data_points[2*j+1] ++ data_ids[i] = data_ids[j] ++ data_weights[i] = data_weights[j] + +-proto.dispose = function() { +- if(this._fref) { +- this._fref.dispose() +- } +- if(this._vref) { +- this._vref.dispose() +- } +- this.attributes = +- this.types = +- this.vertShader = +- this.fragShader = +- this.program = +- this._relink = +- this._fref = +- this._vref = null ++ data_levels[j] = a_level ++ data_points[2*j] = a_x ++ data_points[2*j+1] = a_y ++ data_ids[j] = a_id ++ data_weights[j] = a_weight + } + +-function compareAttributes(a, b) { +- if(a.name < b.name) { +- return -1 +- } +- return 1 ++function compare(i, j, data_levels, data_points, data_ids) { ++ return ((data_levels[i] - data_levels[j]) || ++ (data_points[2*j] - data_points[2*i]) || ++ (data_ids[i] - data_ids[j])) < 0 + } + +-//Update export hook for glslify-live +-proto.update = function( +- vertSource +- , fragSource +- , uniforms +- , attributes) { ++function comparePivot(i, level, x, y, id, data_levels, data_points, data_ids) { ++ return ((level - data_levels[i]) || ++ (data_points[2*i] - x) || ++ (id - data_ids[i])) < 0 ++} + +- //If only one object passed, assume glslify style output +- if(!fragSource || arguments.length === 1) { +- var obj = vertSource +- vertSource = obj.vertex +- fragSource = obj.fragment +- uniforms = obj.uniforms +- attributes = obj.attributes ++function quickSort(left, right, data_levels, data_points, data_ids, data_weights) { ++ var sixth = (right - left + 1) / 6 | 0, ++ index1 = left + sixth, ++ index5 = right - sixth, ++ index3 = left + right >> 1, ++ index2 = index3 - sixth, ++ index4 = index3 + sixth, ++ el1 = index1, ++ el2 = index2, ++ el3 = index3, ++ el4 = index4, ++ el5 = index5, ++ less = left + 1, ++ great = right - 1, ++ tmp = 0 ++ if(compare(el1, el2, data_levels, data_points, data_ids, data_weights)) { ++ tmp = el1 ++ el1 = el2 ++ el2 = tmp + } +- +- var wrapper = this +- var gl = wrapper.gl +- +- //Compile vertex and fragment shaders +- var pvref = wrapper._vref +- wrapper._vref = shaderCache.shader(gl, gl.VERTEX_SHADER, vertSource) +- if(pvref) { +- pvref.dispose() ++ if(compare(el4, el5, data_levels, data_points, data_ids, data_weights)) { ++ tmp = el4 ++ el4 = el5 ++ el5 = tmp + } +- wrapper.vertShader = wrapper._vref.shader +- var pfref = this._fref +- wrapper._fref = shaderCache.shader(gl, gl.FRAGMENT_SHADER, fragSource) +- if(pfref) { +- pfref.dispose() ++ if(compare(el1, el3, data_levels, data_points, data_ids, data_weights)) { ++ tmp = el1 ++ el1 = el3 ++ el3 = tmp ++ } ++ if(compare(el2, el3, data_levels, data_points, data_ids, data_weights)) { ++ tmp = el2 ++ el2 = el3 ++ el3 = tmp ++ } ++ if(compare(el1, el4, data_levels, data_points, data_ids, data_weights)) { ++ tmp = el1 ++ el1 = el4 ++ el4 = tmp ++ } ++ if(compare(el3, el4, data_levels, data_points, data_ids, data_weights)) { ++ tmp = el3 ++ el3 = el4 ++ el4 = tmp ++ } ++ if(compare(el2, el5, data_levels, data_points, data_ids, data_weights)) { ++ tmp = el2 ++ el2 = el5 ++ el5 = tmp ++ } ++ if(compare(el2, el3, data_levels, data_points, data_ids, data_weights)) { ++ tmp = el2 ++ el2 = el3 ++ el3 = tmp ++ } ++ if(compare(el4, el5, data_levels, data_points, data_ids, data_weights)) { ++ tmp = el4 ++ el4 = el5 ++ el5 = tmp + } +- wrapper.fragShader = wrapper._fref.shader + +- //If uniforms/attributes is not specified, use RT reflection +- if(!uniforms || !attributes) { ++ var pivot1_level = data_levels[el2] ++ var pivot1_x = data_points[2*el2] ++ var pivot1_y = data_points[2*el2+1] ++ var pivot1_id = data_ids[el2] ++ var pivot1_weight = data_weights[el2] + +- //Create initial test program +- var testProgram = gl.createProgram() +- gl.attachShader(testProgram, wrapper.fragShader) +- gl.attachShader(testProgram, wrapper.vertShader) +- gl.linkProgram(testProgram) +- if(!gl.getProgramParameter(testProgram, gl.LINK_STATUS)) { +- var errLog = gl.getProgramInfoLog(testProgram) +- throw new GLError(errLog, 'Error linking program:' + errLog) +- } ++ var pivot2_level = data_levels[el4] ++ var pivot2_x = data_points[2*el4] ++ var pivot2_y = data_points[2*el4+1] ++ var pivot2_id = data_ids[el4] ++ var pivot2_weight = data_weights[el4] + +- //Load data from runtime +- uniforms = uniforms || runtime.uniforms(gl, testProgram) +- attributes = attributes || runtime.attributes(gl, testProgram) ++ var ptr0 = el1 ++ var ptr2 = el3 ++ var ptr4 = el5 ++ var ptr5 = index1 ++ var ptr6 = index3 ++ var ptr7 = index5 + +- //Release test program +- gl.deleteProgram(testProgram) ++ var level_x = data_levels[ptr0] ++ var level_y = data_levels[ptr2] ++ var level_z = data_levels[ptr4] ++ data_levels[ptr5] = level_x ++ data_levels[ptr6] = level_y ++ data_levels[ptr7] = level_z ++ ++ for (var i1 = 0; i1 < 2; ++i1) { ++ var x = data_points[2*ptr0+i1] ++ var y = data_points[2*ptr2+i1] ++ var z = data_points[2*ptr4+i1] ++ data_points[2*ptr5+i1] = x ++ data_points[2*ptr6+i1] = y ++ data_points[2*ptr7+i1] = z + } + +- //Sort attributes lexicographically +- // overrides undefined WebGL behavior for attribute locations +- attributes = attributes.slice() +- attributes.sort(compareAttributes) ++ var id_x = data_ids[ptr0] ++ var id_y = data_ids[ptr2] ++ var id_z = data_ids[ptr4] ++ data_ids[ptr5] = id_x ++ data_ids[ptr6] = id_y ++ data_ids[ptr7] = id_z + +- //Convert attribute types, read out locations +- var attributeUnpacked = [] +- var attributeNames = [] +- var attributeLocations = [] +- for(var i=0; i= 0) { +- var size = attr.type.charAt(attr.type.length-1)|0 +- var locVector = new Array(size) +- for(var j=0; j= 0) { +- curLocation += 1 ++},{}],91:[function(require,module,exports){ ++'use strict' ++ ++var pool = require('typedarray-pool') ++ ++var sortLevels = require('./lib/sort') ++ ++module.exports = snapPoints ++ ++function partition(points, ids, start, end, lox, loy, hix, hiy) { ++ var mid = start ++ for(var i=start; i>> 1 ++ if(n < 1) { ++ return [] ++ } ++ ++ var lox = Infinity, loy = Infinity ++ var hix = -Infinity, hiy = -Infinity ++ for(var i=0; i= Math.max(0.9 * count, 32)) { ++ var mid = (end + start)>>>1 ++ snapRec(nx, ny, diam_2, offset, mid, level+1) ++ offset = mid ++ } ++ snapRec(nx, ny, diam_2, offset, nextOffset, level+1) ++ offset = nextOffset ++ } ++ } ++ } ++ snapRec(lox, loy, diam, 0, n, 0) ++ sortLevels(levels, points, ids, weights, n) + +-//Compiles and links a shader program with the given attribute and vertex list +-function createShader( +- gl +- , vertSource +- , fragSource +- , uniforms +- , attributes) { ++ var lod = [] ++ var lastLevel = 0 ++ var prevOffset = n ++ for(var ptr=n-1; ptr>=0; --ptr) { ++ points[2*ptr] = (points[2*ptr] - lox) * scaleX ++ points[2*ptr+1] = (points[2*ptr+1] - loy) * scaleY + +- var shader = new Shader(gl) ++ var level = levels[ptr] ++ if(level === lastLevel) { ++ continue ++ } + +- shader.update( +- vertSource +- , fragSource +- , uniforms +- , attributes) ++ lod.push(new SnapInterval( ++ diam * Math.pow(0.5, level), ++ ptr+1, ++ prevOffset - (ptr+1) ++ )) ++ prevOffset = ptr+1 + +- return shader +-} ++ lastLevel = level ++ } + +-module.exports = createShader ++ lod.push(new SnapInterval(diam * Math.pow(0.5, level+1), 0, prevOffset)) ++ pool.free(levels) + +-},{"./lib/GLError":97,"./lib/create-attributes":98,"./lib/create-uniforms":99,"./lib/reflect":100,"./lib/runtime-reflect":101,"./lib/shader-cache":102}],97:[function(require,module,exports){ +-function GLError (rawError, shortMessage, longMessage) { +- this.shortMessage = shortMessage || '' +- this.longMessage = longMessage || '' +- this.rawError = rawError || '' +- this.message = +- 'gl-shader: ' + (shortMessage || rawError || '') + +- (longMessage ? '\n'+longMessage : '') +- this.stack = (new Error()).stack ++ return lod + } +-GLError.prototype = new Error +-GLError.prototype.name = 'GLError' +-GLError.prototype.constructor = GLError +-module.exports = GLError + +-},{}],98:[function(require,module,exports){ ++},{"./lib/sort":90,"typedarray-pool":162}],92:[function(require,module,exports){ + 'use strict' + +-module.exports = createAttributeWrapper ++var createShader = require('gl-shader') ++var createBuffer = require('gl-buffer') ++var bsearch = require('binary-search-bounds') ++var snapPoints = require('snap-points-2d') + +-var GLError = require("./GLError") ++var pool = require('typedarray-pool') + +-function ShaderAttribute( +- gl +- , wrapper +- , index +- , locations +- , dimension +- , constFunc) { +- this._gl = gl +- this._wrapper = wrapper +- this._index = index +- this._locations = locations +- this._dimension = dimension +- this._constFunc = constFunc +-} ++var SHADERS = require('./lib/shader') + +-var proto = ShaderAttribute.prototype ++module.exports = createScatter2D + +-proto.pointer = function setAttribPointer( +- type +- , normalized +- , stride +- , offset) { ++function Scatter2D(plot, offsetBuffer, pickBuffer, weightBuffer, shader, pickShader) { ++ this.plot = plot ++ this.offsetBuffer = offsetBuffer ++ this.pickBuffer = pickBuffer ++ this.weightBuffer = weightBuffer ++ this.shader = shader ++ this.pickShader = pickShader ++ this.scales = [] ++ this.size = 12.0 ++ this.borderSize = 1.0 ++ this.pointCount = 0 ++ this.color = [1,0,0,1] ++ this.borderColor = [0,0,0,1] ++ this.bounds = [Infinity,Infinity,-Infinity,-Infinity] ++ this.pickOffset = 0 ++ this.points = null ++ this.xCoords = null ++} + +- var self = this +- var gl = self._gl +- var location = self._locations[self._index] ++var proto = Scatter2D.prototype + +- gl.vertexAttribPointer( +- location +- , self._dimension +- , type || gl.FLOAT +- , !!normalized +- , stride || 0 +- , offset || 0) +- gl.enableVertexAttribArray(location) ++proto.dispose = function() { ++ this.shader.dispose() ++ this.pickShader.dispose() ++ this.offsetBuffer.dispose() ++ this.pickBuffer.dispose() ++ if(this.xCoords) { ++ pool.free(this.xCoords) ++ } ++ this.plot.removeObject(this) + } + +-proto.set = function(x0, x1, x2, x3) { +- return this._constFunc(this._locations[this._index], x0, x1, x2, x3) +-} ++proto.update = function(options) { ++ options = options || {} + +-Object.defineProperty(proto, 'location', { +- get: function() { +- return this._locations[this._index] +- } +- , set: function(v) { +- if(v !== this._locations[this._index]) { +- this._locations[this._index] = v|0 +- this._wrapper.program = null ++ function dflt(opt, value) { ++ if(opt in options) { ++ return options[opt] + } +- return v|0 ++ return value + } +-}) + +-//Adds a vector attribute to obj +-function addVectorAttribute( +- gl +- , wrapper +- , index +- , locations +- , dimension +- , obj +- , name) { ++ this.size = dflt('size', 12.0) ++ this.color = dflt('color', [1,0,0,1]).slice() ++ this.borderSize = dflt('borderSize', 1) ++ this.borderColor = dflt('borderColor', [0,0,0,1]).slice() + +- //Construct constant function +- var constFuncArgs = [ 'gl', 'v' ] +- var varNames = [] +- for(var i=0; i>>1) ++ packed.set(data) ++ var packedW = pool.mallocFloat32(data.length) ++ this.points = data ++ this.scales = snapPoints(packed, packedId, packedW, this.bounds) ++ this.offsetBuffer.update(packed) ++ this.pickBuffer.update(packedId) ++ this.weightBuffer.update(packedW) ++ var xCoords = pool.mallocFloat32(data.length>>>1) ++ for(var i=0,j=0; i>> 1 ++ this.pickOffset = 0 + } + +-function addMatrixAttribute( +- gl +- , wrapper +- , index +- , locations +- , dimension +- , obj +- , name) { +- +- var parts = new Array(dimension) +- var attrs = new Array(dimension) +- for(var i=0; i>8) & 0xff) ++ PICK_VEC4[2] = ((pickOffset>>16) & 0xff) ++ PICK_VEC4[3] = ((pickOffset>>24) & 0xff) + +- switch(type) { +- case 'bool': +- case 'int': +- case 'float': +- addVectorAttribute( +- gl +- , wrapper +- , locs[0] +- , locations +- , 1 +- , obj +- , name) +- break ++ shader.bind() ++ shader.uniforms.matrix = MATRIX ++ shader.uniforms.color = this.color ++ shader.uniforms.borderColor = this.borderColor ++ shader.uniforms.pointSize = pixelRatio * (size + borderSize) ++ shader.uniforms.pickOffset = PICK_VEC4 + +- default: +- if(type.indexOf('vec') >= 0) { +- var d = type.charCodeAt(type.length-1) - 48 +- if(d < 2 || d > 4) { +- throw new GLError('', 'Invalid data type for attribute ' + name + ': ' + type) +- } +- addVectorAttribute( +- gl +- , wrapper +- , locs[0] +- , locations +- , d +- , obj +- , name) +- } else if(type.indexOf('mat') >= 0) { +- var d = type.charCodeAt(type.length-1) - 48 +- if(d < 2 || d > 4) { +- throw new GLError('', 'Invalid data type for attribute ' + name + ': ' + type) +- } +- addMatrixAttribute( +- gl +- , wrapper +- , locs +- , locations +- , d +- , obj +- , name) +- } else { +- throw new GLError('', 'Unknown data type for attribute ' + name + ': ' + type) +- } +- break +- } ++ if(this.borderSize === 0) { ++ shader.uniforms.centerFraction = 2.0; ++ } else { ++ shader.uniforms.centerFraction = size / (size + borderSize + 1.25) + } +- return obj +-} + +-},{"./GLError":97}],99:[function(require,module,exports){ +-'use strict' ++ offsetBuffer.bind() ++ shader.attributes.position.pointer() ++ pickBuffer.bind() ++ shader.attributes.pickId.pointer(gl.UNSIGNED_BYTE) + +-var coallesceUniforms = require('./reflect') +-var GLError = require("./GLError") ++ var xCoords = this.xCoords ++ var xStart = (dataBox[0] - bounds[0] - pixelSize * size * pixelRatio) / boundX ++ var xEnd = (dataBox[2] - bounds[0] + pixelSize * size * pixelRatio) / boundX + +-module.exports = createUniformWrapper ++ for(var scaleNum = scales.length-1; scaleNum >= 0; --scaleNum) { ++ var lod = scales[scaleNum] ++ if(lod.pixelSize < pixelSize && scaleNum > 1) { ++ continue ++ } + +-//Binds a function and returns a value +-function identity(x) { +- var c = new Function('y', 'return function(){return y}') +- return c(x) +-} ++ var intervalStart = lod.offset ++ var intervalEnd = lod.count + intervalStart + +-function makeVector(length, fill) { +- var result = new Array(length) +- for(var i=0; i startOffset) { ++ gl.drawArrays(gl.POINTS, startOffset, endOffset - startOffset) ++ } + } +- return result ++ ++ return pickOffset + this.pointCount + } ++})() + +-//Create shims for uniforms +-function createUniformWrapper(gl, wrapper, uniforms, locations) { ++proto.draw = (function() { ++ var MATRIX = [1, 0, 0, ++ 0, 1, 0, ++ 0, 0, 1] + +- function makeGetter(index) { +- var proc = new Function( +- 'gl' +- , 'wrapper' +- , 'locations' +- , 'return function(){return gl.getUniform(wrapper.program,locations[' + index + '])}') +- return proc(gl, wrapper, locations) +- } ++ return function() { ++ var plot = this.plot ++ var shader = this.shader ++ var scales = this.scales ++ var offsetBuffer = this.offsetBuffer ++ var bounds = this.bounds ++ var size = this.size ++ var borderSize = this.borderSize ++ var gl = plot.gl ++ var pixelRatio = plot.pixelRatio ++ var viewBox = plot.viewBox ++ var dataBox = plot.dataBox + +- function makePropSetter(path, index, type) { +- switch(type) { +- case 'bool': +- case 'int': +- case 'sampler2D': +- case 'samplerCube': +- return 'gl.uniform1i(locations[' + index + '],obj' + path + ')' +- case 'float': +- return 'gl.uniform1f(locations[' + index + '],obj' + path + ')' +- default: +- var vidx = type.indexOf('vec') +- if(0 <= vidx && vidx <= 1 && type.length === 4 + vidx) { +- var d = type.charCodeAt(type.length-1) - 48 +- if(d < 2 || d > 4) { +- throw new GLError('', 'Invalid data type') +- } +- switch(type.charAt(0)) { +- case 'b': +- case 'i': +- return 'gl.uniform' + d + 'iv(locations[' + index + '],obj' + path + ')' +- case 'v': +- return 'gl.uniform' + d + 'fv(locations[' + index + '],obj' + path + ')' +- default: +- throw new GLError('', 'Unrecognized data type for vector ' + name + ': ' + type) +- } +- } else if(type.indexOf('mat') === 0 && type.length === 4) { +- var d = type.charCodeAt(type.length-1) - 48 +- if(d < 2 || d > 4) { +- throw new GLError('', 'Invalid uniform dimension type for matrix ' + name + ': ' + type) +- } +- return 'gl.uniformMatrix' + d + 'fv(locations[' + index + '],false,obj' + path + ')' +- } else { +- throw new GLError('', 'Unknown uniform data type for ' + name + ': ' + type) +- } +- break ++ if(this.pointCount === 0) { ++ return + } +- } + +- function enumerateIndices(prefix, type) { +- if(typeof type !== 'object') { +- return [ [prefix, type] ] +- } +- var indices = [] +- for(var id in type) { +- var prop = type[id] +- var tprefix = prefix +- if(parseInt(id) + '' === id) { +- tprefix += '[' + id + ']' +- } else { +- tprefix += '.' + id +- } +- if(typeof prop === 'object') { +- indices.push.apply(indices, enumerateIndices(tprefix, prop)) +- } else { +- indices.push([tprefix, prop]) +- } +- } +- return indices +- } ++ var boundX = bounds[2] - bounds[0] ++ var boundY = bounds[3] - bounds[1] ++ var dataX = dataBox[2] - dataBox[0] ++ var dataY = dataBox[3] - dataBox[1] ++ var screenX = viewBox[2] - viewBox[0] ++ var screenY = viewBox[3] - viewBox[1] + +- function makeSetter(type) { +- var code = [ 'return function updateProperty(obj){' ] +- var indices = enumerateIndices('', type) +- for(var i=0; i 4) { +- throw new GLError('', 'Invalid data type') +- } +- if(type.charAt(0) === 'b') { +- return makeVector(d, false) +- } +- return makeVector(d, 0) +- } else if(type.indexOf('mat') === 0 && type.length === 4) { +- var d = type.charCodeAt(type.length-1) - 48 +- if(d < 2 || d > 4) { +- throw new GLError('', 'Invalid uniform dimension type for matrix ' + name + ': ' + type) +- } +- return makeVector(d*d, 0) +- } else { +- throw new GLError('', 'Unknown uniform data type for ' + name + ': ' + type) +- } +- break +- } +- } ++ MATRIX[0] = 2.0 * boundX / dataX ++ MATRIX[4] = 2.0 * boundY / dataY ++ MATRIX[6] = 2.0 * (bounds[0] - dataBox[0]) / dataX - 1.0 ++ MATRIX[7] = 2.0 * (bounds[1] - dataBox[1]) / dataY - 1.0 + +- function storeProperty(obj, prop, type) { +- if(typeof type === 'object') { +- var child = processObject(type) +- Object.defineProperty(obj, prop, { +- get: identity(child), +- set: makeSetter(type), +- enumerable: true, +- configurable: false +- }) +- } else { +- if(locations[type]) { +- Object.defineProperty(obj, prop, { +- get: makeGetter(type), +- set: makeSetter(type), +- enumerable: true, +- configurable: false +- }) +- } else { +- obj[prop] = defaultValue(uniforms[type].type) +- } +- } +- } ++ shader.bind() ++ shader.uniforms.matrix = MATRIX ++ shader.uniforms.color = this.color ++ shader.uniforms.borderColor = this.borderColor ++ shader.uniforms.pointSize = pixelRatio * (size + borderSize) ++ shader.uniforms.useWeight = 1 + +- function processObject(obj) { +- var result +- if(Array.isArray(obj)) { +- result = new Array(obj.length) +- for(var i=0; i 1) { +- if(!(x[0] in o)) { +- o[x[0]] = [] +- } +- o = o[x[0]] +- for(var k=1; k= 0; --scaleNum) { ++ var lod = scales[scaleNum] ++ if(lod.pixelSize < pixelSize && scaleNum > 1) { ++ continue + } +- } +- } +- return obj +-} +-},{}],101:[function(require,module,exports){ +-'use strict' + +-exports.uniforms = runtimeUniforms +-exports.attributes = runtimeAttributes ++ var intervalStart = lod.offset ++ var intervalEnd = lod.count + intervalStart + +-var GL_TO_GLSL_TYPES = { +- 'FLOAT': 'float', +- 'FLOAT_VEC2': 'vec2', +- 'FLOAT_VEC3': 'vec3', +- 'FLOAT_VEC4': 'vec4', +- 'INT': 'int', +- 'INT_VEC2': 'ivec2', +- 'INT_VEC3': 'ivec3', +- 'INT_VEC4': 'ivec4', +- 'BOOL': 'bool', +- 'BOOL_VEC2': 'bvec2', +- 'BOOL_VEC3': 'bvec3', +- 'BOOL_VEC4': 'bvec4', +- 'FLOAT_MAT2': 'mat2', +- 'FLOAT_MAT3': 'mat3', +- 'FLOAT_MAT4': 'mat4', +- 'SAMPLER_2D': 'sampler2D', +- 'SAMPLER_CUBE':'samplerCube' +-} ++ var startOffset = bsearch.ge(xCoords, xStart, intervalStart, intervalEnd-1) ++ var endOffset = bsearch.lt(xCoords, xEnd, startOffset, intervalEnd-1)+1 + +-var GL_TABLE = null ++ if(endOffset > startOffset) { ++ gl.drawArrays(gl.POINTS, startOffset, endOffset - startOffset) ++ } + +-function getType(gl, type) { +- if(!GL_TABLE) { +- var typeNames = Object.keys(GL_TO_GLSL_TYPES) +- GL_TABLE = {} +- for(var i=0; i 1) { +- for(var j=0; j= pickOffset + pointCount) { ++ return null ++ } ++ var pointId = value - pickOffset ++ var points = this.points ++ return { ++ object: this, ++ pointId: pointId, ++ dataCoord: [ points[2*pointId], points[2*pointId+1] ] + } +- return result + } + +-function runtimeAttributes(gl, program) { +- var numAttributes = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES) +- var result = [] +- for(var i=0; i 0) { + +-function formatCompilerError(errLog, src, type) { +- "use strict"; ++ //Draw border ++ var w = lineWidth * pixelRatio ++ boxes.drawBox(loX-w, loY-w, hiX+w, loY+w, borderColor) ++ boxes.drawBox(loX-w, hiY-w, hiX+w, hiY+w, borderColor) ++ boxes.drawBox(loX-w, loY-w, loX+w, hiY+w, borderColor) ++ boxes.drawBox(hiX-w, loY-w, hiX+w, hiY+w, borderColor) ++ } ++} + +- var name = shaderName(src) || 'of unknown name (see npm glsl-shader-name)'; ++proto.update = function(options) { ++ options = options || {} + +- var typeName = 'unknown type'; +- if (type !== undefined) { +- typeName = type === glConstants.FRAGMENT_SHADER ? 'fragment' : 'vertex' +- } ++ this.innerFill = !!options.innerFill ++ this.outerFill = !!options.outerFill ++ this.innerColor = (options.innerColor || [0,0,0,0.5]).slice() ++ this.outerColor = (options.outerColor || [0,0,0,0.5]).slice() ++ this.borderColor = (options.borderColor || [0,0,0,1]).slice() ++ this.borderWidth = options.borderWidth || 0 ++ this.selectBox = (options.selectBox || this.selectBox).slice() ++} + +- var longForm = sprintf('Error compiling %s shader %s:\n', typeName, name); +- var shortForm = sprintf("%s%s", longForm, errLog); ++proto.dispose = function() { ++ this.boxBuffer.dispose() ++ this.boxShader.dispose() ++ this.plot.removeOverlay(this) ++} + +- var errorStrings = errLog.split('\n'); +- var errors = {}; ++function createSelectBox(plot, options) { ++ var gl = plot.gl ++ var buffer = createBuffer(gl, [ ++ 0, 0, ++ 0, 1, ++ 1, 0, ++ 1, 1 ]) ++ var shader = createShader(gl, SHADERS.boxVertex, SHADERS.boxFragment) ++ var selectBox = new SelectBox(plot, buffer, shader) ++ selectBox.update(options) ++ plot.addOverlay(selectBox) ++ return selectBox ++} + +- for (var i = 0; i < errorStrings.length; i++) { +- var errorString = errorStrings[i]; +- if (errorString === '') continue; +- var lineNo = parseInt(errorString.split(':')[2]); +- if (isNaN(lineNo)) { +- throw new Error(sprintf('Could not parse error: %s', errorString)); +- } +- errors[lineNo] = errorString; +- } ++},{"./lib/shaders":93,"gl-buffer":63,"gl-shader":96}],95:[function(require,module,exports){ ++'use strict' + +- var lines = addLineNumbers(src).split('\n'); ++module.exports = createSelectBuffer + +- for (var i = 0; i < lines.length; i++) { +- if (!errors[i+3] && !errors[i+2] && !errors[i+1]) continue; +- var line = lines[i]; +- longForm += line + '\n'; +- if (errors[i+1]) { +- var e = errors[i+1]; +- e = e.substr(e.split(':', 3).join(':').length + 1).trim(); +- longForm += sprintf('^^^ %s\n\n', e); +- } +- } ++var createFBO = require('gl-fbo') ++var pool = require('typedarray-pool') ++var ndarray = require('ndarray') + +- return { +- long: longForm.trim(), +- short: shortForm.trim() +- }; +-} ++var nextPow2 = require('bit-twiddle').nextPow2 + ++var selectRange = require('cwise/lib/wrapper')({"args":["array",{"offset":[0,0,1],"array":0},{"offset":[0,0,2],"array":0},{"offset":[0,0,3],"array":0},"scalar","scalar","index"],"pre":{"body":"{this_closestD2=1e8,this_closestX=-1,this_closestY=-1}","args":[],"thisVars":["this_closestD2","this_closestX","this_closestY"],"localVars":[]},"body":{"body":"{if(_inline_55_arg0_<255||_inline_55_arg1_<255||_inline_55_arg2_<255||_inline_55_arg3_<255){var _inline_55_l=_inline_55_arg4_-_inline_55_arg6_[0],_inline_55_a=_inline_55_arg5_-_inline_55_arg6_[1],_inline_55_f=_inline_55_l*_inline_55_l+_inline_55_a*_inline_55_a;_inline_55_f +- * +- * Copyright (c) 2014-2015, Jon Schlinkert. +- * Licensed under the MIT license. +- */ ++var proto = SelectBuffer.prototype + +-'use strict'; ++Object.defineProperty(proto, 'shape', { ++ get: function() { ++ if(!this.gl) { ++ return [0,0] ++ } ++ return this.fbo.shape.slice() ++ }, ++ set: function(v) { ++ if(!this.gl) { ++ return ++ } ++ this.fbo.shape = v ++ var c = this.fbo.shape[0] ++ var r = this.fbo.shape[1] ++ if(r*c*4 > this.buffer.length) { ++ pool.free(this.buffer) ++ var buffer = this.buffer = pool.mallocUint8(nextPow2(r*c*4)) ++ for(var i=0; i= 0 +- } ++},{"bit-twiddle":28,"cwise/lib/wrapper":53,"gl-fbo":71,"ndarray":123,"typedarray-pool":162}],96:[function(require,module,exports){ ++'use strict' + +- switch (match[8]) { +- case "b": +- arg = arg.toString(2) +- break +- case "c": +- arg = String.fromCharCode(arg) +- break +- case "d": +- case "i": +- arg = parseInt(arg, 10) +- break +- case "j": +- arg = JSON.stringify(arg, null, match[6] ? parseInt(match[6]) : 0) +- break +- case "e": +- arg = match[7] ? arg.toExponential(match[7]) : arg.toExponential() +- break +- case "f": +- arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg) +- break +- case "g": +- arg = match[7] ? parseFloat(arg).toPrecision(match[7]) : parseFloat(arg) +- break +- case "o": +- arg = arg.toString(8) +- break +- case "s": +- arg = ((arg = String(arg)) && match[7] ? arg.substring(0, match[7]) : arg) +- break +- case "u": +- arg = arg >>> 0 +- break +- case "x": +- arg = arg.toString(16) +- break +- case "X": +- arg = arg.toString(16).toUpperCase() +- break +- } +- if (re.json.test(match[8])) { +- output[output.length] = arg +- } +- else { +- if (re.number.test(match[8]) && (!is_positive || match[3])) { +- sign = is_positive ? "+" : "-" +- arg = arg.toString().replace(re.sign, "") +- } +- else { +- sign = "" +- } +- pad_character = match[4] ? match[4] === "0" ? "0" : match[4].charAt(1) : " " +- pad_length = match[6] - (sign + arg).length +- pad = match[6] ? (pad_length > 0 ? str_repeat(pad_character, pad_length) : "") : "" +- output[output.length] = match[5] ? sign + arg + pad : (pad_character === "0" ? sign + pad + arg : pad + sign + arg) +- } +- } +- } +- return output.join("") +- } ++var createUniformWrapper = require('./lib/create-uniforms') ++var createAttributeWrapper = require('./lib/create-attributes') ++var makeReflect = require('./lib/reflect') ++var shaderCache = require('./lib/shader-cache') ++var runtime = require('./lib/runtime-reflect') ++var GLError = require("./lib/GLError") + +- sprintf.cache = {} ++//Shader object ++function Shader(gl) { ++ this.gl = gl ++ this.gl.lastAttribCount = 0 // fixme where else should we store info, safe but not nice on the gl object + +- sprintf.parse = function(fmt) { +- var _fmt = fmt, match = [], parse_tree = [], arg_names = 0 +- while (_fmt) { +- if ((match = re.text.exec(_fmt)) !== null) { +- parse_tree[parse_tree.length] = match[0] +- } +- else if ((match = re.modulo.exec(_fmt)) !== null) { +- parse_tree[parse_tree.length] = "%" +- } +- else if ((match = re.placeholder.exec(_fmt)) !== null) { +- if (match[2]) { +- arg_names |= 1 +- var field_list = [], replacement_field = match[2], field_match = [] +- if ((field_match = re.key.exec(replacement_field)) !== null) { +- field_list[field_list.length] = field_match[1] +- while ((replacement_field = replacement_field.substring(field_match[0].length)) !== "") { +- if ((field_match = re.key_access.exec(replacement_field)) !== null) { +- field_list[field_list.length] = field_match[1] +- } +- else if ((field_match = re.index_access.exec(replacement_field)) !== null) { +- field_list[field_list.length] = field_match[1] +- } +- else { +- throw new SyntaxError("[sprintf] failed to parse named argument key") +- } +- } +- } +- else { +- throw new SyntaxError("[sprintf] failed to parse named argument key") +- } +- match[2] = field_list +- } +- else { +- arg_names |= 2 +- } +- if (arg_names === 3) { +- throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported") +- } +- parse_tree[parse_tree.length] = match +- } +- else { +- throw new SyntaxError("[sprintf] unexpected placeholder") +- } +- _fmt = _fmt.substring(match[0].length) +- } +- return parse_tree +- } ++ //Default initialize these to null ++ this._vref = ++ this._fref = ++ this._relink = ++ this.vertShader = ++ this.fragShader = ++ this.program = ++ this.attributes = ++ this.uniforms = ++ this.types = null ++} + +- var vsprintf = function(fmt, argv, _argv) { +- _argv = (argv || []).slice(0) +- _argv.splice(0, 0, fmt) +- return sprintf.apply(null, _argv) +- } ++var proto = Shader.prototype + +- /** +- * helpers +- */ +- function get_type(variable) { +- return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase() +- } ++proto.bind = function() { ++ if(!this.program) { ++ this._relink() ++ } + +- function str_repeat(input, multiplier) { +- return Array(multiplier + 1).join(input) ++ // ensuring that we have the right number of enabled vertex attributes ++ var i ++ var newAttribCount = this.gl.getProgramParameter(this.program, this.gl.ACTIVE_ATTRIBUTES) // more robust approach ++ //var newAttribCount = Object.keys(this.attributes).length // avoids the probably immaterial introspection slowdown ++ var oldAttribCount = this.gl.lastAttribCount ++ if(newAttribCount > oldAttribCount) { ++ for(i = oldAttribCount; i < newAttribCount; i++) { ++ this.gl.enableVertexAttribArray(i) + } +- +- /** +- * export to either browser or node.js +- */ +- if (typeof exports !== "undefined") { +- exports.sprintf = sprintf +- exports.vsprintf = vsprintf ++ } else if(oldAttribCount > newAttribCount) { ++ for(i = newAttribCount; i < oldAttribCount; i++) { ++ this.gl.disableVertexAttribArray(i) + } +- else { +- window.sprintf = sprintf +- window.vsprintf = vsprintf ++ } + +- if (typeof define === "function" && define.amd) { +- define(function() { +- return { +- sprintf: sprintf, +- vsprintf: vsprintf +- } +- }) +- } +- } +-})(typeof window === "undefined" ? this : window); ++ this.gl.lastAttribCount = newAttribCount + +-},{}],111:[function(require,module,exports){ +-var hiddenStore = require('./hidden-store.js'); ++ this.gl.useProgram(this.program) ++} + +-module.exports = createStore; ++proto.dispose = function() { + +-function createStore() { +- var key = {}; ++ // disabling vertex attributes so new shader starts with zero ++ // and it's also useful if all shaders are disposed but the ++ // gl context is reused for subsequent replotting ++ var oldAttribCount = this.gl.lastAttribCount ++ for (var i = 0; i < oldAttribCount; i++) { ++ this.gl.disableVertexAttribArray(i) ++ } ++ this.gl.lastAttribCount = 0 + +- return function (obj) { +- if ((typeof obj !== 'object' || obj === null) && +- typeof obj !== 'function' +- ) { +- throw new Error('Weakmap-shim: Key must be object') +- } ++ if(this._fref) { ++ this._fref.dispose() ++ } ++ if(this._vref) { ++ this._vref.dispose() ++ } ++ this.attributes = ++ this.types = ++ this.vertShader = ++ this.fragShader = ++ this.program = ++ this._relink = ++ this._fref = ++ this._vref = null ++} + +- var store = obj.valueOf(key); +- return store && store.identity === key ? +- store : hiddenStore(obj, key); +- }; ++function compareAttributes(a, b) { ++ if(a.name < b.name) { ++ return -1 ++ } ++ return 1 + } + +-},{"./hidden-store.js":112}],112:[function(require,module,exports){ +-module.exports = hiddenStore; ++//Update export hook for glslify-live ++proto.update = function( ++ vertSource ++ , fragSource ++ , uniforms ++ , attributes) { + +-function hiddenStore(obj, key) { +- var store = { identity: key }; +- var valueOf = obj.valueOf; ++ //If only one object passed, assume glslify style output ++ if(!fragSource || arguments.length === 1) { ++ var obj = vertSource ++ vertSource = obj.vertex ++ fragSource = obj.fragment ++ uniforms = obj.uniforms ++ attributes = obj.attributes ++ } + +- Object.defineProperty(obj, "valueOf", { +- value: function (value) { +- return value !== key ? +- valueOf.apply(this, arguments) : store; +- }, +- writable: true +- }); ++ var wrapper = this ++ var gl = wrapper.gl + +- return store; +-} ++ //Compile vertex and fragment shaders ++ var pvref = wrapper._vref ++ wrapper._vref = shaderCache.shader(gl, gl.VERTEX_SHADER, vertSource) ++ if(pvref) { ++ pvref.dispose() ++ } ++ wrapper.vertShader = wrapper._vref.shader ++ var pfref = this._fref ++ wrapper._fref = shaderCache.shader(gl, gl.FRAGMENT_SHADER, fragSource) ++ if(pfref) { ++ pfref.dispose() ++ } ++ wrapper.fragShader = wrapper._fref.shader + +-},{}],113:[function(require,module,exports){ +-// Original - @Gozola. +-// https://gist.github.com/Gozala/1269991 +-// This is a reimplemented version (with a few bug fixes). ++ //If uniforms/attributes is not specified, use RT reflection ++ if(!uniforms || !attributes) { + +-var createStore = require('./create-store.js'); ++ //Create initial test program ++ var testProgram = gl.createProgram() ++ gl.attachShader(testProgram, wrapper.fragShader) ++ gl.attachShader(testProgram, wrapper.vertShader) ++ gl.linkProgram(testProgram) ++ if(!gl.getProgramParameter(testProgram, gl.LINK_STATUS)) { ++ var errLog = gl.getProgramInfoLog(testProgram) ++ throw new GLError(errLog, 'Error linking program:' + errLog) ++ } + +-module.exports = weakMap; ++ //Load data from runtime ++ uniforms = uniforms || runtime.uniforms(gl, testProgram) ++ attributes = attributes || runtime.attributes(gl, testProgram) + +-function weakMap() { +- var privates = createStore(); ++ //Release test program ++ gl.deleteProgram(testProgram) ++ } + +- return { +- 'get': function (key, fallback) { +- var store = privates(key) +- return store.hasOwnProperty('value') ? +- store.value : fallback +- }, +- 'set': function (key, value) { +- privates(key).value = value; +- }, +- 'has': function(key) { +- return 'value' in privates(key); +- }, +- 'delete': function (key) { +- return delete privates(key).value; ++ //Sort attributes lexicographically ++ // overrides undefined WebGL behavior for attribute locations ++ attributes = attributes.slice() ++ attributes.sort(compareAttributes) ++ ++ //Convert attribute types, read out locations ++ var attributeUnpacked = [] ++ var attributeNames = [] ++ var attributeLocations = [] ++ var i ++ for(i=0; i= 0) { ++ var size = attr.type.charAt(attr.type.length-1)|0 ++ var locVector = new Array(size) ++ for(var j=0; j= 0) { ++ curLocation += 1 ++ } ++ attributeLocations[i] = curLocation ++ } ++ } + +-module.exports = createSpikes2D ++ //Rebuild program and recompute all uniform locations ++ var uniformLocations = new Array(uniforms.length) ++ function relink() { ++ wrapper.program = shaderCache.program( ++ gl ++ , wrapper._vref ++ , wrapper._fref ++ , attributeNames ++ , attributeLocations) + +-function GLSpikes2D(plot) { +- this.plot = plot +- this.enable = [true, true, false, false] +- this.width = [1, 1, 1, 1] +- this.color = [[0,0,0,1], +- [0,0,0,1], +- [0,0,0,1], +- [0,0,0,1]] +- this.center = [Infinity, Infinity] +-} ++ for(var i=0; i maxSize || h < 0 || h > maxSize) { +- throw new Error('gl-texture2d: Invalid texture size') ++Object.defineProperty(proto, 'location', { ++ get: function() { ++ return this._locations[this._index] + } +- tex._shape = [w, h] +- tex.bind() +- gl.texImage2D(gl.TEXTURE_2D, 0, tex.format, w, h, 0, tex.format, tex.type, null) +- tex._mipLevels = [0] +- return tex +-} ++ , set: function(v) { ++ if(v !== this._locations[this._index]) { ++ this._locations[this._index] = v|0 ++ this._wrapper.program = null ++ } ++ return v|0 ++ } ++}) + +-function Texture2D(gl, handle, width, height, format, type) { +- this.gl = gl +- this.handle = handle +- this.format = format +- this.type = type +- this._shape = [width, height] +- this._mipLevels = [0] +- this._magFilter = gl.NEAREST +- this._minFilter = gl.NEAREST +- this._wrapS = gl.CLAMP_TO_EDGE +- this._wrapT = gl.CLAMP_TO_EDGE +- this._anisoSamples = 1 ++//Adds a vector attribute to obj ++function addVectorAttribute( ++ gl ++ , wrapper ++ , index ++ , locations ++ , dimension ++ , obj ++ , name) { + +- var parent = this +- var wrapVector = [this._wrapS, this._wrapT] +- Object.defineProperties(wrapVector, [ +- { +- get: function() { +- return parent._wrapS +- }, +- set: function(v) { +- return parent.wrapS = v +- } +- }, +- { +- get: function() { +- return parent._wrapT +- }, +- set: function(v) { +- return parent.wrapT = v +- } +- } +- ]) +- this._wrapVector = wrapVector ++ //Construct constant function ++ var constFuncArgs = [ 'gl', 'v' ] ++ var varNames = [] ++ for(var i=0; i= 0) { +- if(!gl.getExtension('OES_texture_float_linear')) { +- v = gl.NEAREST +- } +- } +- if(filterTypes.indexOf(v) < 0) { +- throw new Error('gl-texture2d: Unknown filter mode ' + v) +- } +- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, v) +- return this._minFilter = v +- } +- }, +- magFilter: { +- get: function() { +- return this._magFilter +- }, ++ var parts = new Array(dimension) ++ var attrs = new Array(dimension) ++ for(var i=0; i= 0) { +- if(!gl.getExtension('OES_texture_float_linear')) { +- v = gl.NEAREST ++ if(Array.isArray(v)) { ++ for(var i=0; i= 0) { ++ var d = type.charCodeAt(type.length-1) - 48 ++ if(d < 2 || d > 4) { ++ throw new GLError('', 'Invalid data type for attribute ' + name + ': ' + type) ++ } ++ addVectorAttribute( ++ gl ++ , wrapper ++ , locs[0] ++ , locations ++ , d ++ , obj ++ , name) ++ } else if(type.indexOf('mat') >= 0) { ++ var d = type.charCodeAt(type.length-1) - 48 ++ if(d < 2 || d > 4) { ++ throw new GLError('', 'Invalid data type for attribute ' + name + ': ' + type) ++ } ++ addMatrixAttribute( ++ gl ++ , wrapper ++ , locs ++ , locations ++ , d ++ , obj ++ , name) ++ } else { ++ throw new GLError('', 'Unknown data type for attribute ' + name + ': ' + type) + } +- } +- reshapeTexture(this, x[0]|0, x[1]|0) +- return [x[0]|0, x[1]|0] +- } +- }, +- width: { +- get: function() { +- return this._shape[0] +- }, +- set: function(w) { +- w = w|0 +- reshapeTexture(this, w, this._shape[1]) +- return w +- } +- }, +- height: { +- get: function() { +- return this._shape[1] +- }, +- set: function(h) { +- h = h|0 +- reshapeTexture(this, this._shape[0], h) +- return h ++ break + } + } +-}) +- +-proto.bind = function(unit) { +- var gl = this.gl +- if(unit !== undefined) { +- gl.activeTexture(gl.TEXTURE0 + (unit|0)) +- } +- gl.bindTexture(gl.TEXTURE_2D, this.handle) +- if(unit !== undefined) { +- return (unit|0) +- } +- return gl.getParameter(gl.ACTIVE_TEXTURE) - gl.TEXTURE0 ++ return obj + } + +-proto.dispose = function() { +- this.gl.deleteTexture(this.handle) +-} ++},{"./GLError":97}],99:[function(require,module,exports){ ++'use strict' + +-proto.generateMipmap = function() { +- this.bind() +- this.gl.generateMipmap(this.gl.TEXTURE_2D) ++var coallesceUniforms = require('./reflect') ++var GLError = require("./GLError") + +- //Update mip levels +- var l = Math.min(this._shape[0], this._shape[1]) +- for(var i=0; l>0; ++i, l>>>=1) { +- if(this._mipLevels.indexOf(i) < 0) { +- this._mipLevels.push(i) +- } +- } ++module.exports = createUniformWrapper ++ ++//Binds a function and returns a value ++function identity(x) { ++ var c = new Function('y', 'return function(){return y}') ++ return c(x) + } + +-proto.setPixels = function(data, x_off, y_off, mip_level) { +- var gl = this.gl +- this.bind() +- if(Array.isArray(x_off)) { +- mip_level = y_off +- y_off = x_off[1]|0 +- x_off = x_off[0]|0 +- } else { +- x_off = x_off || 0 +- y_off = y_off || 0 +- } +- mip_level = mip_level || 0 +- if(data instanceof HTMLCanvasElement || +- data instanceof ImageData || +- data instanceof HTMLImageElement || +- data instanceof HTMLVideoElement) { +- var needsMip = this._mipLevels.indexOf(mip_level) < 0 +- if(needsMip) { +- gl.texImage2D(gl.TEXTURE_2D, 0, this.format, this.format, this.type, data) +- this._mipLevels.push(mip_level) +- } else { +- gl.texSubImage2D(gl.TEXTURE_2D, mip_level, x_off, y_off, this.format, this.type, data) +- } +- } else if(data.shape && data.stride && data.data) { +- if(data.shape.length < 2 || +- x_off + data.shape[1] > this._shape[1]>>>mip_level || +- y_off + data.shape[0] > this._shape[0]>>>mip_level || +- x_off < 0 || +- y_off < 0) { +- throw new Error('gl-texture2d: Texture dimensions are out of bounds') +- } +- texSubImageArray(gl, x_off, y_off, mip_level, this.format, this.type, this._mipLevels, data) +- } else { +- throw new Error('gl-texture2d: Unsupported data type') ++function makeVector(length, fill) { ++ var result = new Array(length) ++ for(var i=0; i 3) { +- throw new Error('gl-texture2d: Invalid ndarray, must be 2d or 3d') +- } +- var type = 0, format = 0 +- var packed = isPacked(shape, array.stride.slice()) +- if(dtype === 'float32') { +- type = gl.FLOAT +- } else if(dtype === 'float64') { +- type = gl.FLOAT +- packed = false +- dtype = 'float32' +- } else if(dtype === 'uint8') { +- type = gl.UNSIGNED_BYTE +- } else { +- type = gl.UNSIGNED_BYTE +- packed = false +- dtype = 'uint8' +- } +- var channels = 1 +- if(shape.length === 2) { +- format = gl.LUMINANCE +- shape = [shape[0], shape[1], 1] +- array = ndarray(array.data, shape, [array.stride[0], array.stride[1], 1], array.offset) +- } else if(shape.length === 3) { +- if(shape[2] === 1) { +- format = gl.ALPHA +- } else if(shape[2] === 2) { +- format = gl.LUMINANCE_ALPHA +- } else if(shape[2] === 3) { +- format = gl.RGB +- } else if(shape[2] === 4) { +- format = gl.RGBA +- } else { +- throw new Error('gl-texture2d: Invalid shape for pixel coords') ++ function makePropSetter(path, index, type) { ++ switch(type) { ++ case 'bool': ++ case 'int': ++ case 'sampler2D': ++ case 'samplerCube': ++ return 'gl.uniform1i(locations[' + index + '],obj' + path + ')' ++ case 'float': ++ return 'gl.uniform1f(locations[' + index + '],obj' + path + ')' ++ default: ++ var vidx = type.indexOf('vec') ++ if(0 <= vidx && vidx <= 1 && type.length === 4 + vidx) { ++ var d = type.charCodeAt(type.length-1) - 48 ++ if(d < 2 || d > 4) { ++ throw new GLError('', 'Invalid data type') ++ } ++ switch(type.charAt(0)) { ++ case 'b': ++ case 'i': ++ return 'gl.uniform' + d + 'iv(locations[' + index + '],obj' + path + ')' ++ case 'v': ++ return 'gl.uniform' + d + 'fv(locations[' + index + '],obj' + path + ')' ++ default: ++ throw new GLError('', 'Unrecognized data type for vector ' + name + ': ' + type) ++ } ++ } else if(type.indexOf('mat') === 0 && type.length === 4) { ++ var d = type.charCodeAt(type.length-1) - 48 ++ if(d < 2 || d > 4) { ++ throw new GLError('', 'Invalid uniform dimension type for matrix ' + name + ': ' + type) ++ } ++ return 'gl.uniformMatrix' + d + 'fv(locations[' + index + '],false,obj' + path + ')' ++ } else { ++ throw new GLError('', 'Unknown uniform data type for ' + name + ': ' + type) ++ } ++ break + } +- channels = shape[2] +- } else { +- throw new Error('gl-texture2d: Invalid shape for texture') +- } +- //For 1-channel textures allow conversion between formats +- if((format === gl.LUMINANCE || format === gl.ALPHA) && +- (cformat === gl.LUMINANCE || cformat === gl.ALPHA)) { +- format = cformat +- } +- if(format !== cformat) { +- throw new Error('gl-texture2d: Incompatible texture format for setPixels') +- } +- var size = array.size +- var needsMip = mipLevels.indexOf(mip_level) < 0 +- if(needsMip) { +- mipLevels.push(mip_level) + } +- if(type === ctype && packed) { +- //Array data types are compatible, can directly copy into texture +- if(array.offset === 0 && array.data.length === size) { +- if(needsMip) { +- gl.texImage2D(gl.TEXTURE_2D, mip_level, cformat, shape[0], shape[1], 0, cformat, ctype, array.data) ++ ++ function enumerateIndices(prefix, type) { ++ if(typeof type !== 'object') { ++ return [ [prefix, type] ] ++ } ++ var indices = [] ++ for(var id in type) { ++ var prop = type[id] ++ var tprefix = prefix ++ if(parseInt(id) + '' === id) { ++ tprefix += '[' + id + ']' + } else { +- gl.texSubImage2D(gl.TEXTURE_2D, mip_level, x_off, y_off, shape[0], shape[1], cformat, ctype, array.data) ++ tprefix += '.' + id + } +- } else { +- if(needsMip) { +- gl.texImage2D(gl.TEXTURE_2D, mip_level, cformat, shape[0], shape[1], 0, cformat, ctype, array.data.subarray(array.offset, array.offset+size)) ++ if(typeof prop === 'object') { ++ indices.push.apply(indices, enumerateIndices(tprefix, prop)) + } else { +- gl.texSubImage2D(gl.TEXTURE_2D, mip_level, x_off, y_off, shape[0], shape[1], cformat, ctype, array.data.subarray(array.offset, array.offset+size)) ++ indices.push([tprefix, prop]) + } + } +- } else { +- //Need to do type conversion to pack data into buffer +- var pack_buffer +- if(ctype === gl.FLOAT) { +- pack_buffer = pool.mallocFloat32(size) +- } else { +- pack_buffer = pool.mallocUint8(size) ++ return indices ++ } ++ ++ function makeSetter(type) { ++ var code = [ 'return function updateProperty(obj){' ] ++ var indices = enumerateIndices('', type) ++ for(var i=0; i 4) { ++ throw new GLError('', 'Invalid data type') ++ } ++ if(type.charAt(0) === 'b') { ++ return makeVector(d, false) ++ } ++ return makeVector(d, 0) ++ } else if(type.indexOf('mat') === 0 && type.length === 4) { ++ var d = type.charCodeAt(type.length-1) - 48 ++ if(d < 2 || d > 4) { ++ throw new GLError('', 'Invalid uniform dimension type for matrix ' + name + ': ' + type) ++ } ++ return makeVector(d*d, 0) ++ } else { ++ throw new GLError('', 'Unknown uniform data type for ' + name + ': ' + type) ++ } ++ break + } +- if(needsMip) { +- gl.texImage2D(gl.TEXTURE_2D, mip_level, cformat, shape[0], shape[1], 0, cformat, ctype, pack_buffer.subarray(0, size)) ++ } ++ ++ function storeProperty(obj, prop, type) { ++ if(typeof type === 'object') { ++ var child = processObject(type) ++ Object.defineProperty(obj, prop, { ++ get: identity(child), ++ set: makeSetter(type), ++ enumerable: true, ++ configurable: false ++ }) + } else { +- gl.texSubImage2D(gl.TEXTURE_2D, mip_level, x_off, y_off, shape[0], shape[1], cformat, ctype, pack_buffer.subarray(0, size)) ++ if(locations[type]) { ++ Object.defineProperty(obj, prop, { ++ get: makeGetter(type), ++ set: makeSetter(type), ++ enumerable: true, ++ configurable: false ++ }) ++ } else { ++ obj[prop] = defaultValue(uniforms[type].type) ++ } + } +- if(ctype === gl.FLOAT) { +- pool.freeFloat32(pack_buffer) ++ } ++ ++ function processObject(obj) { ++ var result ++ if(Array.isArray(obj)) { ++ result = new Array(obj.length) ++ for(var i=0; i maxTextureSize || height < 0 || height > maxTextureSize) { +- throw new Error('gl-texture2d: Invalid texture shape') +- } +- if(type === gl.FLOAT && !gl.getExtension('OES_texture_float')) { +- throw new Error('gl-texture2d: Floating point textures not supported on this platform') ++},{"./GLError":97,"./reflect":100}],100:[function(require,module,exports){ ++'use strict' ++ ++module.exports = makeReflectTypes ++ ++//Construct type info for reflection. ++// ++// This iterates over the flattened list of uniform type values and smashes them into a JSON object. ++// ++// The leaves of the resulting object are either indices or type strings representing primitive glslify types ++function makeReflectTypes(uniforms, useIndex) { ++ var obj = {} ++ for(var i=0; i 1) { ++ if(!(x[0] in o)) { ++ o[x[0]] = [] ++ } ++ o = o[x[0]] ++ for(var k=1; k maxSize || shape[1] < 0 || shape[1] > maxSize) { +- throw new Error('gl-texture2d: Invalid texture size') +- } +- var packed = isPacked(shape, array.stride.slice()) +- var type = 0 +- if(dtype === 'float32') { +- type = gl.FLOAT +- } else if(dtype === 'float64') { +- type = gl.FLOAT +- packed = false +- dtype = 'float32' +- } else if(dtype === 'uint8') { +- type = gl.UNSIGNED_BYTE +- } else { +- type = gl.UNSIGNED_BYTE +- packed = false +- dtype = 'uint8' +- } +- var format = 0 +- if(shape.length === 2) { +- format = gl.LUMINANCE +- shape = [shape[0], shape[1], 1] +- array = ndarray(array.data, shape, [array.stride[0], array.stride[1], 1], array.offset) +- } else if(shape.length === 3) { +- if(shape[2] === 1) { +- format = gl.ALPHA +- } else if(shape[2] === 2) { +- format = gl.LUMINANCE_ALPHA +- } else if(shape[2] === 3) { +- format = gl.RGB +- } else if(shape[2] === 4) { +- format = gl.RGBA +- } else { +- throw new Error('gl-texture2d: Invalid shape for pixel coords') ++var GL_TABLE = null ++ ++function getType(gl, type) { ++ if(!GL_TABLE) { ++ var typeNames = Object.keys(GL_TO_GLSL_TYPES) ++ GL_TABLE = {} ++ for(var i=0; i 1) { ++ for(var j=0; j 0) continue +- res = buf.slice(0, 1).join('') +- } ++module.exports = createTexture2D ++ ++var linearTypes = null ++var filterTypes = null ++var wrapTypes = null ++ ++function lazyInitLinearTypes(gl) { ++ linearTypes = [ ++ gl.LINEAR, ++ gl.NEAREST_MIPMAP_LINEAR, ++ gl.LINEAR_MIPMAP_NEAREST, ++ gl.LINEAR_MIPMAP_NEAREST ++ ] ++ filterTypes = [ ++ gl.NEAREST, ++ gl.LINEAR, ++ gl.NEAREST_MIPMAP_NEAREST, ++ gl.NEAREST_MIPMAP_LINEAR, ++ gl.LINEAR_MIPMAP_NEAREST, ++ gl.LINEAR_MIPMAP_LINEAR ++ ] ++ wrapTypes = [ ++ gl.REPEAT, ++ gl.CLAMP_TO_EDGE, ++ gl.MIRRORED_REPEAT ++ ] ++} + +- token(res) ++var convertFloatToUint8 = function(out, inp) { ++ ops.muls(out, inp, 255.0) ++} + +- start += res.length +- content = content.slice(res.length) +- return content.length +- } while(1) ++function reshapeTexture(tex, w, h) { ++ var gl = tex.gl ++ var maxSize = gl.getParameter(gl.MAX_TEXTURE_SIZE) ++ if(w < 0 || w > maxSize || h < 0 || h > maxSize) { ++ throw new Error('gl-texture2d: Invalid texture size') + } ++ tex._shape = [w, h] ++ tex.bind() ++ gl.texImage2D(gl.TEXTURE_2D, 0, tex.format, w, h, 0, tex.format, tex.type, null) ++ tex._mipLevels = [0] ++ return tex ++} + +- function hex() { +- if(/[^a-fA-F0-9]/.test(c)) { +- token(content.join('')) +- mode = NORMAL +- return i +- } +- +- content.push(c) +- last = c +- return i + 1 +- } ++function Texture2D(gl, handle, width, height, format, type) { ++ this.gl = gl ++ this.handle = handle ++ this.format = format ++ this.type = type ++ this._shape = [width, height] ++ this._mipLevels = [0] ++ this._magFilter = gl.NEAREST ++ this._minFilter = gl.NEAREST ++ this._wrapS = gl.CLAMP_TO_EDGE ++ this._wrapT = gl.CLAMP_TO_EDGE ++ this._anisoSamples = 1 + +- function integer() { +- if(c === '.') { +- content.push(c) +- mode = FLOAT +- last = c +- return i + 1 ++ var parent = this ++ var wrapVector = [this._wrapS, this._wrapT] ++ Object.defineProperties(wrapVector, [ ++ { ++ get: function() { ++ return parent._wrapS ++ }, ++ set: function(v) { ++ return parent.wrapS = v ++ } ++ }, ++ { ++ get: function() { ++ return parent._wrapT ++ }, ++ set: function(v) { ++ return parent.wrapT = v ++ } + } ++ ]) ++ this._wrapVector = wrapVector + +- if(/[eE]/.test(c)) { +- content.push(c) +- mode = FLOAT +- last = c +- return i + 1 ++ var shapeVector = [this._shape[0], this._shape[1]] ++ Object.defineProperties(shapeVector, [ ++ { ++ get: function() { ++ return parent._shape[0] ++ }, ++ set: function(v) { ++ return parent.width = v ++ } ++ }, ++ { ++ get: function() { ++ return parent._shape[1] ++ }, ++ set: function(v) { ++ return parent.height = v ++ } + } ++ ]) ++ this._shapeVector = shapeVector ++} + +- if(c === 'x' && content.length === 1 && content[0] === '0') { +- mode = HEX +- content.push(c) +- last = c +- return i + 1 +- } ++var proto = Texture2D.prototype + +- if(/[^\d]/.test(c)) { +- token(content.join('')) +- mode = NORMAL +- return i ++Object.defineProperties(proto, { ++ minFilter: { ++ get: function() { ++ return this._minFilter ++ }, ++ set: function(v) { ++ this.bind() ++ var gl = this.gl ++ if(this.type === gl.FLOAT && linearTypes.indexOf(v) >= 0) { ++ if(!gl.getExtension('OES_texture_float_linear')) { ++ v = gl.NEAREST ++ } ++ } ++ if(filterTypes.indexOf(v) < 0) { ++ throw new Error('gl-texture2d: Unknown filter mode ' + v) ++ } ++ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, v) ++ return this._minFilter = v + } +- +- content.push(c) +- last = c +- return i + 1 +- } +- +- function decimal() { +- if(c === 'f') { +- content.push(c) +- last = c +- i += 1 ++ }, ++ magFilter: { ++ get: function() { ++ return this._magFilter ++ }, ++ set: function(v) { ++ this.bind() ++ var gl = this.gl ++ if(this.type === gl.FLOAT && linearTypes.indexOf(v) >= 0) { ++ if(!gl.getExtension('OES_texture_float_linear')) { ++ v = gl.NEAREST ++ } ++ } ++ if(filterTypes.indexOf(v) < 0) { ++ throw new Error('gl-texture2d: Unknown filter mode ' + v) ++ } ++ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, v) ++ return this._magFilter = v + } +- +- if(/[eE]/.test(c)) { +- content.push(c) +- last = c +- return i + 1 ++ }, ++ mipSamples: { ++ get: function() { ++ return this._anisoSamples ++ }, ++ set: function(i) { ++ var psamples = this._anisoSamples ++ this._anisoSamples = Math.max(i, 1)|0 ++ if(psamples !== this._anisoSamples) { ++ var ext = this.gl.getExtension('EXT_texture_filter_anisotropic') ++ if(ext) { ++ this.gl.texParameterf(this.gl.TEXTURE_2D, ext.TEXTURE_MAX_ANISOTROPY_EXT, this._anisoSamples) ++ } ++ } ++ return this._anisoSamples + } +- +- if (c === '-' && /[eE]/.test(last)) { +- content.push(c) +- last = c +- return i + 1 ++ }, ++ wrapS: { ++ get: function() { ++ return this._wrapS ++ }, ++ set: function(v) { ++ this.bind() ++ if(wrapTypes.indexOf(v) < 0) { ++ throw new Error('gl-texture2d: Unknown wrap mode ' + v) ++ } ++ this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_S, v) ++ return this._wrapS = v + } +- +- if(/[^\d]/.test(c)) { +- token(content.join('')) +- mode = NORMAL +- return i ++ }, ++ wrapT: { ++ get: function() { ++ return this._wrapT ++ }, ++ set: function(v) { ++ this.bind() ++ if(wrapTypes.indexOf(v) < 0) { ++ throw new Error('gl-texture2d: Unknown wrap mode ' + v) ++ } ++ this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_T, v) ++ return this._wrapT = v + } ++ }, ++ wrap: { ++ get: function() { ++ return this._wrapVector ++ }, ++ set: function(v) { ++ if(!Array.isArray(v)) { ++ v = [v,v] ++ } ++ if(v.length !== 2) { ++ throw new Error('gl-texture2d: Must specify wrap mode for rows and columns') ++ } ++ for(var i=0; i<2; ++i) { ++ if(wrapTypes.indexOf(v[i]) < 0) { ++ throw new Error('gl-texture2d: Unknown wrap mode ' + v) ++ } ++ } ++ this._wrapS = v[0] ++ this._wrapT = v[1] + +- content.push(c) +- last = c +- return i + 1 +- } ++ var gl = this.gl ++ this.bind() ++ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, this._wrapS) ++ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, this._wrapT) + +- function readtoken() { +- if(/[^\d\w_]/.test(c)) { +- var contentstr = content.join('') +- if(allLiterals.indexOf(contentstr) > -1) { +- mode = KEYWORD +- } else if(allBuiltins.indexOf(contentstr) > -1) { +- mode = BUILTIN ++ return v ++ } ++ }, ++ shape: { ++ get: function() { ++ return this._shapeVector ++ }, ++ set: function(x) { ++ if(!Array.isArray(x)) { ++ x = [x|0,x|0] + } else { +- mode = IDENT ++ if(x.length !== 2) { ++ throw new Error('gl-texture2d: Invalid texture shape') ++ } + } +- token(content.join('')) +- mode = NORMAL +- return i ++ reshapeTexture(this, x[0]|0, x[1]|0) ++ return [x[0]|0, x[1]|0] + } +- content.push(c) +- last = c +- return i + 1 +- } +-} +- +-},{"./lib/builtins":118,"./lib/builtins-300es":117,"./lib/literals":120,"./lib/literals-300es":119,"./lib/operators":121}],117:[function(require,module,exports){ +-// 300es builtins/reserved words that were previously valid in v100 +-var v100 = require('./builtins') +- +-// The texture2D|Cube functions have been removed +-// And the gl_ features are updated +-v100 = v100.slice().filter(function (b) { +- return !/^(gl\_|texture)/.test(b) +-}) +- +-module.exports = v100.concat([ +- // the updated gl_ constants +- 'gl_VertexID' +- , 'gl_InstanceID' +- , 'gl_Position' +- , 'gl_PointSize' +- , 'gl_FragCoord' +- , 'gl_FrontFacing' +- , 'gl_FragDepth' +- , 'gl_PointCoord' +- , 'gl_MaxVertexAttribs' +- , 'gl_MaxVertexUniformVectors' +- , 'gl_MaxVertexOutputVectors' +- , 'gl_MaxFragmentInputVectors' +- , 'gl_MaxVertexTextureImageUnits' +- , 'gl_MaxCombinedTextureImageUnits' +- , 'gl_MaxTextureImageUnits' +- , 'gl_MaxFragmentUniformVectors' +- , 'gl_MaxDrawBuffers' +- , 'gl_MinProgramTexelOffset' +- , 'gl_MaxProgramTexelOffset' +- , 'gl_DepthRangeParameters' +- , 'gl_DepthRange' +- +- // other builtins +- , 'trunc' +- , 'round' +- , 'roundEven' +- , 'isnan' +- , 'isinf' +- , 'floatBitsToInt' +- , 'floatBitsToUint' +- , 'intBitsToFloat' +- , 'uintBitsToFloat' +- , 'packSnorm2x16' +- , 'unpackSnorm2x16' +- , 'packUnorm2x16' +- , 'unpackUnorm2x16' +- , 'packHalf2x16' +- , 'unpackHalf2x16' +- , 'outerProduct' +- , 'transpose' +- , 'determinant' +- , 'inverse' +- , 'texture' +- , 'textureSize' +- , 'textureProj' +- , 'textureLod' +- , 'textureOffset' +- , 'texelFetch' +- , 'texelFetchOffset' +- , 'textureProjOffset' +- , 'textureLodOffset' +- , 'textureProjLod' +- , 'textureProjLodOffset' +- , 'textureGrad' +- , 'textureGradOffset' +- , 'textureProjGrad' +- , 'textureProjGradOffset' +-]) +- +-},{"./builtins":118}],118:[function(require,module,exports){ +-module.exports = [ +- // Keep this list sorted +- 'abs' +- , 'acos' +- , 'all' +- , 'any' +- , 'asin' +- , 'atan' +- , 'ceil' +- , 'clamp' +- , 'cos' +- , 'cross' +- , 'dFdx' +- , 'dFdy' +- , 'degrees' +- , 'distance' +- , 'dot' +- , 'equal' +- , 'exp' +- , 'exp2' +- , 'faceforward' +- , 'floor' +- , 'fract' +- , 'gl_BackColor' +- , 'gl_BackLightModelProduct' +- , 'gl_BackLightProduct' +- , 'gl_BackMaterial' +- , 'gl_BackSecondaryColor' +- , 'gl_ClipPlane' +- , 'gl_ClipVertex' +- , 'gl_Color' +- , 'gl_DepthRange' +- , 'gl_DepthRangeParameters' +- , 'gl_EyePlaneQ' +- , 'gl_EyePlaneR' +- , 'gl_EyePlaneS' +- , 'gl_EyePlaneT' +- , 'gl_Fog' +- , 'gl_FogCoord' +- , 'gl_FogFragCoord' +- , 'gl_FogParameters' +- , 'gl_FragColor' +- , 'gl_FragCoord' +- , 'gl_FragData' +- , 'gl_FragDepth' +- , 'gl_FragDepthEXT' +- , 'gl_FrontColor' +- , 'gl_FrontFacing' +- , 'gl_FrontLightModelProduct' +- , 'gl_FrontLightProduct' +- , 'gl_FrontMaterial' +- , 'gl_FrontSecondaryColor' +- , 'gl_LightModel' +- , 'gl_LightModelParameters' +- , 'gl_LightModelProducts' +- , 'gl_LightProducts' +- , 'gl_LightSource' +- , 'gl_LightSourceParameters' +- , 'gl_MaterialParameters' +- , 'gl_MaxClipPlanes' +- , 'gl_MaxCombinedTextureImageUnits' +- , 'gl_MaxDrawBuffers' +- , 'gl_MaxFragmentUniformComponents' +- , 'gl_MaxLights' +- , 'gl_MaxTextureCoords' +- , 'gl_MaxTextureImageUnits' +- , 'gl_MaxTextureUnits' +- , 'gl_MaxVaryingFloats' +- , 'gl_MaxVertexAttribs' +- , 'gl_MaxVertexTextureImageUnits' +- , 'gl_MaxVertexUniformComponents' +- , 'gl_ModelViewMatrix' +- , 'gl_ModelViewMatrixInverse' +- , 'gl_ModelViewMatrixInverseTranspose' +- , 'gl_ModelViewMatrixTranspose' +- , 'gl_ModelViewProjectionMatrix' +- , 'gl_ModelViewProjectionMatrixInverse' +- , 'gl_ModelViewProjectionMatrixInverseTranspose' +- , 'gl_ModelViewProjectionMatrixTranspose' +- , 'gl_MultiTexCoord0' +- , 'gl_MultiTexCoord1' +- , 'gl_MultiTexCoord2' +- , 'gl_MultiTexCoord3' +- , 'gl_MultiTexCoord4' +- , 'gl_MultiTexCoord5' +- , 'gl_MultiTexCoord6' +- , 'gl_MultiTexCoord7' +- , 'gl_Normal' +- , 'gl_NormalMatrix' +- , 'gl_NormalScale' +- , 'gl_ObjectPlaneQ' +- , 'gl_ObjectPlaneR' +- , 'gl_ObjectPlaneS' +- , 'gl_ObjectPlaneT' +- , 'gl_Point' +- , 'gl_PointCoord' +- , 'gl_PointParameters' +- , 'gl_PointSize' +- , 'gl_Position' +- , 'gl_ProjectionMatrix' +- , 'gl_ProjectionMatrixInverse' +- , 'gl_ProjectionMatrixInverseTranspose' +- , 'gl_ProjectionMatrixTranspose' +- , 'gl_SecondaryColor' +- , 'gl_TexCoord' +- , 'gl_TextureEnvColor' +- , 'gl_TextureMatrix' +- , 'gl_TextureMatrixInverse' +- , 'gl_TextureMatrixInverseTranspose' +- , 'gl_TextureMatrixTranspose' +- , 'gl_Vertex' +- , 'greaterThan' +- , 'greaterThanEqual' +- , 'inversesqrt' +- , 'length' +- , 'lessThan' +- , 'lessThanEqual' +- , 'log' +- , 'log2' +- , 'matrixCompMult' +- , 'max' +- , 'min' +- , 'mix' +- , 'mod' +- , 'normalize' +- , 'not' +- , 'notEqual' +- , 'pow' +- , 'radians' +- , 'reflect' +- , 'refract' +- , 'sign' +- , 'sin' +- , 'smoothstep' +- , 'sqrt' +- , 'step' +- , 'tan' +- , 'texture2D' +- , 'texture2DLod' +- , 'texture2DProj' +- , 'texture2DProjLod' +- , 'textureCube' +- , 'textureCubeLod' +- , 'texture2DLodEXT' +- , 'texture2DProjLodEXT' +- , 'textureCubeLodEXT' +- , 'texture2DGradEXT' +- , 'texture2DProjGradEXT' +- , 'textureCubeGradEXT' +-] ++ }, ++ width: { ++ get: function() { ++ return this._shape[0] ++ }, ++ set: function(w) { ++ w = w|0 ++ reshapeTexture(this, w, this._shape[1]) ++ return w ++ } ++ }, ++ height: { ++ get: function() { ++ return this._shape[1] ++ }, ++ set: function(h) { ++ h = h|0 ++ reshapeTexture(this, this._shape[0], h) ++ return h ++ } ++ } ++}) + +-},{}],119:[function(require,module,exports){ +-var v100 = require('./literals') ++proto.bind = function(unit) { ++ var gl = this.gl ++ if(unit !== undefined) { ++ gl.activeTexture(gl.TEXTURE0 + (unit|0)) ++ } ++ gl.bindTexture(gl.TEXTURE_2D, this.handle) ++ if(unit !== undefined) { ++ return (unit|0) ++ } ++ return gl.getParameter(gl.ACTIVE_TEXTURE) - gl.TEXTURE0 ++} + +-module.exports = v100.slice().concat([ +- 'layout' +- , 'centroid' +- , 'smooth' +- , 'case' +- , 'mat2x2' +- , 'mat2x3' +- , 'mat2x4' +- , 'mat3x2' +- , 'mat3x3' +- , 'mat3x4' +- , 'mat4x2' +- , 'mat4x3' +- , 'mat4x4' +- , 'uint' +- , 'uvec2' +- , 'uvec3' +- , 'uvec4' +- , 'samplerCubeShadow' +- , 'sampler2DArray' +- , 'sampler2DArrayShadow' +- , 'isampler2D' +- , 'isampler3D' +- , 'isamplerCube' +- , 'isampler2DArray' +- , 'usampler2D' +- , 'usampler3D' +- , 'usamplerCube' +- , 'usampler2DArray' +- , 'coherent' +- , 'restrict' +- , 'readonly' +- , 'writeonly' +- , 'resource' +- , 'atomic_uint' +- , 'noperspective' +- , 'patch' +- , 'sample' +- , 'subroutine' +- , 'common' +- , 'partition' +- , 'active' +- , 'filter' +- , 'image1D' +- , 'image2D' +- , 'image3D' +- , 'imageCube' +- , 'iimage1D' +- , 'iimage2D' +- , 'iimage3D' +- , 'iimageCube' +- , 'uimage1D' +- , 'uimage2D' +- , 'uimage3D' +- , 'uimageCube' +- , 'image1DArray' +- , 'image2DArray' +- , 'iimage1DArray' +- , 'iimage2DArray' +- , 'uimage1DArray' +- , 'uimage2DArray' +- , 'image1DShadow' +- , 'image2DShadow' +- , 'image1DArrayShadow' +- , 'image2DArrayShadow' +- , 'imageBuffer' +- , 'iimageBuffer' +- , 'uimageBuffer' +- , 'sampler1DArray' +- , 'sampler1DArrayShadow' +- , 'isampler1D' +- , 'isampler1DArray' +- , 'usampler1D' +- , 'usampler1DArray' +- , 'isampler2DRect' +- , 'usampler2DRect' +- , 'samplerBuffer' +- , 'isamplerBuffer' +- , 'usamplerBuffer' +- , 'sampler2DMS' +- , 'isampler2DMS' +- , 'usampler2DMS' +- , 'sampler2DMSArray' +- , 'isampler2DMSArray' +- , 'usampler2DMSArray' +-]) ++proto.dispose = function() { ++ this.gl.deleteTexture(this.handle) ++} + +-},{"./literals":120}],120:[function(require,module,exports){ +-module.exports = [ +- // current +- 'precision' +- , 'highp' +- , 'mediump' +- , 'lowp' +- , 'attribute' +- , 'const' +- , 'uniform' +- , 'varying' +- , 'break' +- , 'continue' +- , 'do' +- , 'for' +- , 'while' +- , 'if' +- , 'else' +- , 'in' +- , 'out' +- , 'inout' +- , 'float' +- , 'int' +- , 'void' +- , 'bool' +- , 'true' +- , 'false' +- , 'discard' +- , 'return' +- , 'mat2' +- , 'mat3' +- , 'mat4' +- , 'vec2' +- , 'vec3' +- , 'vec4' +- , 'ivec2' +- , 'ivec3' +- , 'ivec4' +- , 'bvec2' +- , 'bvec3' +- , 'bvec4' +- , 'sampler1D' +- , 'sampler2D' +- , 'sampler3D' +- , 'samplerCube' +- , 'sampler1DShadow' +- , 'sampler2DShadow' +- , 'struct' ++proto.generateMipmap = function() { ++ this.bind() ++ this.gl.generateMipmap(this.gl.TEXTURE_2D) + +- // future +- , 'asm' +- , 'class' +- , 'union' +- , 'enum' +- , 'typedef' +- , 'template' +- , 'this' +- , 'packed' +- , 'goto' +- , 'switch' +- , 'default' +- , 'inline' +- , 'noinline' +- , 'volatile' +- , 'public' +- , 'static' +- , 'extern' +- , 'external' +- , 'interface' +- , 'long' +- , 'short' +- , 'double' +- , 'half' +- , 'fixed' +- , 'unsigned' +- , 'input' +- , 'output' +- , 'hvec2' +- , 'hvec3' +- , 'hvec4' +- , 'dvec2' +- , 'dvec3' +- , 'dvec4' +- , 'fvec2' +- , 'fvec3' +- , 'fvec4' +- , 'sampler2DRect' +- , 'sampler3DRect' +- , 'sampler2DRectShadow' +- , 'sizeof' +- , 'cast' +- , 'namespace' +- , 'using' +-] ++ //Update mip levels ++ var l = Math.min(this._shape[0], this._shape[1]) ++ for(var i=0; l>0; ++i, l>>>=1) { ++ if(this._mipLevels.indexOf(i) < 0) { ++ this._mipLevels.push(i) ++ } ++ } ++} + +-},{}],121:[function(require,module,exports){ +-module.exports = [ +- '<<=' +- , '>>=' +- , '++' +- , '--' +- , '<<' +- , '>>' +- , '<=' +- , '>=' +- , '==' +- , '!=' +- , '&&' +- , '||' +- , '+=' +- , '-=' +- , '*=' +- , '/=' +- , '%=' +- , '&=' +- , '^^' +- , '^=' +- , '|=' +- , '(' +- , ')' +- , '[' +- , ']' +- , '.' +- , '!' +- , '~' +- , '*' +- , '/' +- , '%' +- , '+' +- , '-' +- , '<' +- , '>' +- , '&' +- , '^' +- , '|' +- , '?' +- , ':' +- , '=' +- , ',' +- , ';' +- , '{' +- , '}' +-] ++proto.setPixels = function(data, x_off, y_off, mip_level) { ++ var gl = this.gl ++ this.bind() ++ if(Array.isArray(x_off)) { ++ mip_level = y_off ++ y_off = x_off[1]|0 ++ x_off = x_off[0]|0 ++ } else { ++ x_off = x_off || 0 ++ y_off = y_off || 0 ++ } ++ mip_level = mip_level || 0 ++ if(data instanceof HTMLCanvasElement || ++ data instanceof ImageData || ++ data instanceof HTMLImageElement || ++ data instanceof HTMLVideoElement) { ++ var needsMip = this._mipLevels.indexOf(mip_level) < 0 ++ if(needsMip) { ++ gl.texImage2D(gl.TEXTURE_2D, 0, this.format, this.format, this.type, data) ++ this._mipLevels.push(mip_level) ++ } else { ++ gl.texSubImage2D(gl.TEXTURE_2D, mip_level, x_off, y_off, this.format, this.type, data) ++ } ++ } else if(data.shape && data.stride && data.data) { ++ if(data.shape.length < 2 || ++ x_off + data.shape[1] > this._shape[1]>>>mip_level || ++ y_off + data.shape[0] > this._shape[0]>>>mip_level || ++ x_off < 0 || ++ y_off < 0) { ++ throw new Error('gl-texture2d: Texture dimensions are out of bounds') ++ } ++ texSubImageArray(gl, x_off, y_off, mip_level, this.format, this.type, this._mipLevels, data) ++ } else { ++ throw new Error('gl-texture2d: Unsupported data type') ++ } ++} + +-},{}],122:[function(require,module,exports){ +-var tokenize = require('./index') + +-module.exports = tokenizeString ++function isPacked(shape, stride) { ++ if(shape.length === 3) { ++ return (stride[2] === 1) && ++ (stride[1] === shape[0]*shape[2]) && ++ (stride[0] === shape[2]) ++ } ++ return (stride[0] === 1) && ++ (stride[1] === shape[0]) ++} ++ ++function texSubImageArray(gl, x_off, y_off, mip_level, cformat, ctype, mipLevels, array) { ++ var dtype = array.dtype ++ var shape = array.shape.slice() ++ if(shape.length < 2 || shape.length > 3) { ++ throw new Error('gl-texture2d: Invalid ndarray, must be 2d or 3d') ++ } ++ var type = 0, format = 0 ++ var packed = isPacked(shape, array.stride.slice()) ++ if(dtype === 'float32') { ++ type = gl.FLOAT ++ } else if(dtype === 'float64') { ++ type = gl.FLOAT ++ packed = false ++ dtype = 'float32' ++ } else if(dtype === 'uint8') { ++ type = gl.UNSIGNED_BYTE ++ } else { ++ type = gl.UNSIGNED_BYTE ++ packed = false ++ dtype = 'uint8' ++ } ++ var channels = 1 ++ if(shape.length === 2) { ++ format = gl.LUMINANCE ++ shape = [shape[0], shape[1], 1] ++ array = ndarray(array.data, shape, [array.stride[0], array.stride[1], 1], array.offset) ++ } else if(shape.length === 3) { ++ if(shape[2] === 1) { ++ format = gl.ALPHA ++ } else if(shape[2] === 2) { ++ format = gl.LUMINANCE_ALPHA ++ } else if(shape[2] === 3) { ++ format = gl.RGB ++ } else if(shape[2] === 4) { ++ format = gl.RGBA ++ } else { ++ throw new Error('gl-texture2d: Invalid shape for pixel coords') ++ } ++ channels = shape[2] ++ } else { ++ throw new Error('gl-texture2d: Invalid shape for texture') ++ } ++ //For 1-channel textures allow conversion between formats ++ if((format === gl.LUMINANCE || format === gl.ALPHA) && ++ (cformat === gl.LUMINANCE || cformat === gl.ALPHA)) { ++ format = cformat ++ } ++ if(format !== cformat) { ++ throw new Error('gl-texture2d: Incompatible texture format for setPixels') ++ } ++ var size = array.size ++ var needsMip = mipLevels.indexOf(mip_level) < 0 ++ if(needsMip) { ++ mipLevels.push(mip_level) ++ } ++ if(type === ctype && packed) { ++ //Array data types are compatible, can directly copy into texture ++ if(array.offset === 0 && array.data.length === size) { ++ if(needsMip) { ++ gl.texImage2D(gl.TEXTURE_2D, mip_level, cformat, shape[0], shape[1], 0, cformat, ctype, array.data) ++ } else { ++ gl.texSubImage2D(gl.TEXTURE_2D, mip_level, x_off, y_off, shape[0], shape[1], cformat, ctype, array.data) ++ } ++ } else { ++ if(needsMip) { ++ gl.texImage2D(gl.TEXTURE_2D, mip_level, cformat, shape[0], shape[1], 0, cformat, ctype, array.data.subarray(array.offset, array.offset+size)) ++ } else { ++ gl.texSubImage2D(gl.TEXTURE_2D, mip_level, x_off, y_off, shape[0], shape[1], cformat, ctype, array.data.subarray(array.offset, array.offset+size)) ++ } ++ } ++ } else { ++ //Need to do type conversion to pack data into buffer ++ var pack_buffer ++ if(ctype === gl.FLOAT) { ++ pack_buffer = pool.mallocFloat32(size) ++ } else { ++ pack_buffer = pool.mallocUint8(size) ++ } ++ var pack_view = ndarray(pack_buffer, shape, [shape[2], shape[2]*shape[0], 1]) ++ if(type === gl.FLOAT && ctype === gl.UNSIGNED_BYTE) { ++ convertFloatToUint8(pack_view, array) ++ } else { ++ ops.assign(pack_view, array) ++ } ++ if(needsMip) { ++ gl.texImage2D(gl.TEXTURE_2D, mip_level, cformat, shape[0], shape[1], 0, cformat, ctype, pack_buffer.subarray(0, size)) ++ } else { ++ gl.texSubImage2D(gl.TEXTURE_2D, mip_level, x_off, y_off, shape[0], shape[1], cformat, ctype, pack_buffer.subarray(0, size)) ++ } ++ if(ctype === gl.FLOAT) { ++ pool.freeFloat32(pack_buffer) ++ } else { ++ pool.freeUint8(pack_buffer) ++ } ++ } ++} ++ ++function initTexture(gl) { ++ var tex = gl.createTexture() ++ gl.bindTexture(gl.TEXTURE_2D, tex) ++ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST) ++ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST) ++ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE) ++ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE) ++ return tex ++} ++ ++function createTextureShape(gl, width, height, format, type) { ++ var maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE) ++ if(width < 0 || width > maxTextureSize || height < 0 || height > maxTextureSize) { ++ throw new Error('gl-texture2d: Invalid texture shape') ++ } ++ if(type === gl.FLOAT && !gl.getExtension('OES_texture_float')) { ++ throw new Error('gl-texture2d: Floating point textures not supported on this platform') ++ } ++ var tex = initTexture(gl) ++ gl.texImage2D(gl.TEXTURE_2D, 0, format, width, height, 0, format, type, null) ++ return new Texture2D(gl, tex, width, height, format, type) ++} ++ ++function createTextureDOM(gl, element, format, type) { ++ var tex = initTexture(gl) ++ gl.texImage2D(gl.TEXTURE_2D, 0, format, format, type, element) ++ return new Texture2D(gl, tex, element.width|0, element.height|0, format, type) ++} ++ ++//Creates a texture from an ndarray ++function createTextureArray(gl, array) { ++ var dtype = array.dtype ++ var shape = array.shape.slice() ++ var maxSize = gl.getParameter(gl.MAX_TEXTURE_SIZE) ++ if(shape[0] < 0 || shape[0] > maxSize || shape[1] < 0 || shape[1] > maxSize) { ++ throw new Error('gl-texture2d: Invalid texture size') ++ } ++ var packed = isPacked(shape, array.stride.slice()) ++ var type = 0 ++ if(dtype === 'float32') { ++ type = gl.FLOAT ++ } else if(dtype === 'float64') { ++ type = gl.FLOAT ++ packed = false ++ dtype = 'float32' ++ } else if(dtype === 'uint8') { ++ type = gl.UNSIGNED_BYTE ++ } else { ++ type = gl.UNSIGNED_BYTE ++ packed = false ++ dtype = 'uint8' ++ } ++ var format = 0 ++ if(shape.length === 2) { ++ format = gl.LUMINANCE ++ shape = [shape[0], shape[1], 1] ++ array = ndarray(array.data, shape, [array.stride[0], array.stride[1], 1], array.offset) ++ } else if(shape.length === 3) { ++ if(shape[2] === 1) { ++ format = gl.ALPHA ++ } else if(shape[2] === 2) { ++ format = gl.LUMINANCE_ALPHA ++ } else if(shape[2] === 3) { ++ format = gl.RGB ++ } else if(shape[2] === 4) { ++ format = gl.RGBA ++ } else { ++ throw new Error('gl-texture2d: Invalid shape for pixel coords') ++ } ++ } else { ++ throw new Error('gl-texture2d: Invalid shape for texture') ++ } ++ if(type === gl.FLOAT && !gl.getExtension('OES_texture_float')) { ++ type = gl.UNSIGNED_BYTE ++ packed = false ++ } ++ var buffer, buf_store ++ var size = array.size ++ if(!packed) { ++ var stride = [shape[2], shape[2]*shape[0], 1] ++ buf_store = pool.malloc(size, dtype) ++ var buf_array = ndarray(buf_store, shape, stride, 0) ++ if((dtype === 'float32' || dtype === 'float64') && type === gl.UNSIGNED_BYTE) { ++ convertFloatToUint8(buf_array, array) ++ } else { ++ ops.assign(buf_array, array) ++ } ++ buffer = buf_store.subarray(0, size) ++ } else if (array.offset === 0 && array.data.length === size) { ++ buffer = array.data ++ } else { ++ buffer = array.data.subarray(array.offset, array.offset + size) ++ } ++ var tex = initTexture(gl) ++ gl.texImage2D(gl.TEXTURE_2D, 0, format, shape[0], shape[1], 0, format, type, buffer) ++ if(!packed) { ++ pool.free(buf_store) ++ } ++ return new Texture2D(gl, tex, shape[0], shape[1], format, type) ++} ++ ++function createTexture2D(gl) { ++ if(arguments.length <= 1) { ++ throw new Error('gl-texture2d: Missing arguments for texture2d constructor') ++ } ++ if(!linearTypes) { ++ lazyInitLinearTypes(gl) ++ } ++ if(typeof arguments[1] === 'number') { ++ return createTextureShape(gl, arguments[1], arguments[2], arguments[3]||gl.RGBA, arguments[4]||gl.UNSIGNED_BYTE) ++ } ++ if(Array.isArray(arguments[1])) { ++ return createTextureShape(gl, arguments[1][0]|0, arguments[1][1]|0, arguments[2]||gl.RGBA, arguments[3]||gl.UNSIGNED_BYTE) ++ } ++ if(typeof arguments[1] === 'object') { ++ var obj = arguments[1] ++ if(obj instanceof HTMLCanvasElement || ++ obj instanceof HTMLImageElement || ++ obj instanceof HTMLVideoElement || ++ obj instanceof ImageData) { ++ return createTextureDOM(gl, obj, arguments[2]||gl.RGBA, arguments[3]||gl.UNSIGNED_BYTE) ++ } else if(obj.shape && obj.data && obj.stride) { ++ return createTextureArray(gl, obj) ++ } ++ } ++ throw new Error('gl-texture2d: Invalid arguments for texture2d constructor') ++} ++ ++},{"ndarray":123,"ndarray-ops":122,"typedarray-pool":162}],105:[function(require,module,exports){ ++var tokenize = require('glsl-tokenizer') ++var atob = require('atob-lite') + +-function tokenizeString(str, opt) { +- var generator = tokenize(opt) +- var tokens = [] ++module.exports = getName + +- tokens = tokens.concat(generator(str)) +- tokens = tokens.concat(generator(null)) ++function getName(src) { ++ var tokens = Array.isArray(src) ++ ? src ++ : tokenize(src) + +- return tokens +-} ++ for (var i = 0; i < tokens.length; i++) { ++ var token = tokens[i] ++ if (token.type !== 'preprocessor') continue ++ var match = token.data.match(/\#define\s+SHADER_NAME(_B64)?\s+(.+)$/) ++ if (!match) continue ++ if (!match[2]) continue + +-},{"./index":116}],123:[function(require,module,exports){ +-"use strict" ++ var b64 = match[1] ++ var name = match[2] + +-function iota(n) { +- var result = new Array(n) +- for(var i=0; i +- * License: MIT +- * +- * `npm install is-buffer` +- */ +- +-module.exports = function (obj) { +- return !!(obj != null && +- (obj._isBuffer || // For Safari 5-7 (missing Object.prototype.constructor) +- (obj.constructor && +- typeof obj.constructor.isBuffer === 'function' && +- obj.constructor.isBuffer(obj)) +- )) +-} ++},{"atob-lite":10,"glsl-tokenizer":112}],106:[function(require,module,exports){ ++module.exports = tokenize + +-},{}],125:[function(require,module,exports){ +-'use strict' ++var literals100 = require('./lib/literals') ++ , operators = require('./lib/operators') ++ , builtins100 = require('./lib/builtins') ++ , literals300es = require('./lib/literals-300es') ++ , builtins300es = require('./lib/builtins-300es') + +-module.exports = mouseListen ++var NORMAL = 999 // <-- never emitted ++ , TOKEN = 9999 // <-- never emitted ++ , BLOCK_COMMENT = 0 ++ , LINE_COMMENT = 1 ++ , PREPROCESSOR = 2 ++ , OPERATOR = 3 ++ , INTEGER = 4 ++ , FLOAT = 5 ++ , IDENT = 6 ++ , BUILTIN = 7 ++ , KEYWORD = 8 ++ , WHITESPACE = 9 ++ , EOF = 10 ++ , HEX = 11 + +-var mouse = require('mouse-event') ++var map = [ ++ 'block-comment' ++ , 'line-comment' ++ , 'preprocessor' ++ , 'operator' ++ , 'integer' ++ , 'float' ++ , 'ident' ++ , 'builtin' ++ , 'keyword' ++ , 'whitespace' ++ , 'eof' ++ , 'integer' ++] + +-function mouseListen(element, callback) { ++function tokenize(opt) { ++ var i = 0 ++ , total = 0 ++ , mode = NORMAL ++ , c ++ , last ++ , content = [] ++ , tokens = [] ++ , token_idx = 0 ++ , token_offs = 0 ++ , line = 1 ++ , col = 0 ++ , start = 0 ++ , isnum = false ++ , isoperator = false ++ , input = '' ++ , len + +- if(!callback) { +- callback = element +- element = window ++ opt = opt || {} ++ var allBuiltins = builtins100 ++ var allLiterals = literals100 ++ if (opt.version === '300 es') { ++ allBuiltins = builtins300es ++ allLiterals = literals300es + } + +- var buttonState = 0 +- var x = 0 +- var y = 0 +- var mods = { +- shift: false, +- alt: false, +- control: false, +- meta: false ++ return function(data) { ++ tokens = [] ++ if (data !== null) return write(data.replace ? data.replace(/\r\n/g, '\n') : data) ++ return end() + } +- var attached = false + +- function updateMods(ev) { +- var changed = false +- if('altKey' in ev) { +- changed = changed || ev.altKey !== mods.alt +- mods.alt = !!ev.altKey +- } +- if('shiftKey' in ev) { +- changed = changed || ev.shiftKey !== mods.shift +- mods.shift = !!ev.shiftKey +- } +- if('ctrlKey' in ev) { +- changed = changed || ev.ctrlKey !== mods.control +- mods.control = !!ev.ctrlKey +- } +- if('metaKey' in ev) { +- changed = changed || ev.metaKey !== mods.meta +- mods.meta = !!ev.metaKey ++ function token(data) { ++ if (data.length) { ++ tokens.push({ ++ type: map[mode] ++ , data: data ++ , position: start ++ , line: line ++ , column: col ++ }) + } +- return changed + } + +- function handleEvent(nextButtons, ev) { +- var nextX = mouse.x(ev) +- var nextY = mouse.y(ev) +- if('buttons' in ev) { +- nextButtons = ev.buttons|0 +- } +- if(nextButtons !== buttonState || +- nextX !== x || +- nextY !== y || +- updateMods(ev)) { +- buttonState = nextButtons|0 +- x = nextX||0 +- y = nextY||0 +- callback(buttonState, x, y, mods) +- } +- } ++ function write(chunk) { ++ i = 0 ++ input += chunk ++ len = input.length + +- function clearState(ev) { +- handleEvent(0, ev) +- } ++ var last + +- function handleBlur() { +- if(buttonState || +- x || +- y || +- mods.shift || +- mods.alt || +- mods.meta || +- mods.control) { ++ while(c = input[i], i < len) { ++ last = i + +- x = y = 0 +- buttonState = 0 +- mods.shift = mods.alt = mods.control = mods.meta = false +- callback(0, 0, 0, mods) +- } +- } ++ switch(mode) { ++ case BLOCK_COMMENT: i = block_comment(); break ++ case LINE_COMMENT: i = line_comment(); break ++ case PREPROCESSOR: i = preprocessor(); break ++ case OPERATOR: i = operator(); break ++ case INTEGER: i = integer(); break ++ case HEX: i = hex(); break ++ case FLOAT: i = decimal(); break ++ case TOKEN: i = readtoken(); break ++ case WHITESPACE: i = whitespace(); break ++ case NORMAL: i = normal(); break ++ } + +- function handleMods(ev) { +- if(updateMods(ev)) { +- callback(buttonState, x, y, mods) ++ if(last !== i) { ++ switch(input[last]) { ++ case '\n': col = 0; ++line; break ++ default: ++col; break ++ } ++ } + } ++ ++ total += i ++ input = input.slice(i) ++ return tokens + } + +- function handleMouseMove(ev) { +- if(mouse.buttons(ev) === 0) { +- handleEvent(0, ev) +- } else { +- handleEvent(buttonState, ev) ++ function end(chunk) { ++ if(content.length) { ++ token(content.join('')) + } +- } + +- function handleMouseDown(ev) { +- handleEvent(buttonState | mouse.buttons(ev), ev) ++ mode = EOF ++ token('(eof)') ++ return tokens + } + +- function handleMouseUp(ev) { +- handleEvent(buttonState & ~mouse.buttons(ev), ev) +- } ++ function normal() { ++ content = content.length ? [] : content + +- function attachListeners() { +- if(attached) { +- return ++ if(last === '/' && c === '*') { ++ start = total + i - 1 ++ mode = BLOCK_COMMENT ++ last = c ++ return i + 1 + } +- attached = true +- +- element.addEventListener('mousemove', handleMouseMove) +- +- element.addEventListener('mousedown', handleMouseDown) +- +- element.addEventListener('mouseup', handleMouseUp) +- +- element.addEventListener('mouseleave', clearState) +- element.addEventListener('mouseenter', clearState) +- element.addEventListener('mouseout', clearState) +- element.addEventListener('mouseover', clearState) + +- element.addEventListener('blur', handleBlur) +- +- element.addEventListener('keyup', handleMods) +- element.addEventListener('keydown', handleMods) +- element.addEventListener('keypress', handleMods) +- +- if(element !== window) { +- window.addEventListener('blur', handleBlur) +- +- window.addEventListener('keyup', handleMods) +- window.addEventListener('keydown', handleMods) +- window.addEventListener('keypress', handleMods) ++ if(last === '/' && c === '/') { ++ start = total + i - 1 ++ mode = LINE_COMMENT ++ last = c ++ return i + 1 + } +- } + +- function detachListeners() { +- if(!attached) { +- return ++ if(c === '#') { ++ mode = PREPROCESSOR ++ start = total + i ++ return i + } +- attached = false +- +- element.removeEventListener('mousemove', handleMouseMove) +- +- element.removeEventListener('mousedown', handleMouseDown) +- +- element.removeEventListener('mouseup', handleMouseUp) + +- element.removeEventListener('mouseleave', clearState) +- element.removeEventListener('mouseenter', clearState) +- element.removeEventListener('mouseout', clearState) +- element.removeEventListener('mouseover', clearState) +- +- element.removeEventListener('blur', handleBlur) +- +- element.removeEventListener('keyup', handleMods) +- element.removeEventListener('keydown', handleMods) +- element.removeEventListener('keypress', handleMods) +- +- if(element !== window) { +- window.removeEventListener('blur', handleBlur) +- +- window.removeEventListener('keyup', handleMods) +- window.removeEventListener('keydown', handleMods) +- window.removeEventListener('keypress', handleMods) ++ if(/\s/.test(c)) { ++ mode = WHITESPACE ++ start = total + i ++ return i + } +- } + +- //Attach listeners +- attachListeners() ++ isnum = /\d/.test(c) ++ isoperator = /[^\w_]/.test(c) + +- var result = { +- element: element ++ start = total + i ++ mode = isnum ? INTEGER : isoperator ? OPERATOR : TOKEN ++ return i + } + +- Object.defineProperties(result, { +- enabled: { +- get: function() { return attached }, +- set: function(f) { +- if(f) { +- attachListeners() +- } else { +- detachListeners +- } +- }, +- enumerable: true +- }, +- buttons: { +- get: function() { return buttonState }, +- enumerable: true +- }, +- x: { +- get: function() { return x }, +- enumerable: true +- }, +- y: { +- get: function() { return y }, +- enumerable: true +- }, +- mods: { +- get: function() { return mods }, +- enumerable: true +- } +- }) +- +- return result +-} +- +-},{"mouse-event":126}],126:[function(require,module,exports){ +-'use strict' +- +-function mouseButtons(ev) { +- if(typeof ev === 'object') { +- if('buttons' in ev) { +- return ev.buttons +- } else if('which' in ev) { +- var b = ev.which +- if(b === 2) { +- return 4 +- } else if(b === 3) { +- return 2 +- } else if(b > 0) { +- return 1<<(b-1) +- } +- } else if('button' in ev) { +- var b = ev.button +- if(b === 1) { +- return 4 +- } else if(b === 2) { +- return 2 +- } else if(b >= 0) { +- return 1< 0) continue ++ res = buf.slice(0, 1).join('') ++ } + +-function fixup(x) { +- if(!x) { +- return EmptyProc +- } +- for(var i=0; i>", +- rrshift: ">>>" +-} +-;(function(){ +- for(var id in assign_ops) { +- var op = assign_ops[id] +- exports[id] = makeOp({ +- args: ["array","array","array"], +- body: {args:["a","b","c"], +- body: "a=b"+op+"c"}, +- funcName: id +- }) +- exports[id+"eq"] = makeOp({ +- args: ["array","array"], +- body: {args:["a","b"], +- body:"a"+op+"=b"}, +- rvalue: true, +- funcName: id+"eq" +- }) +- exports[id+"s"] = makeOp({ +- args: ["array", "array", "scalar"], +- body: {args:["a","b","s"], +- body:"a=b"+op+"s"}, +- funcName: id+"s" +- }) +- exports[id+"seq"] = makeOp({ +- args: ["array","scalar"], +- body: {args:["a","s"], +- body:"a"+op+"=s"}, +- rvalue: true, +- funcName: id+"seq" +- }) +- } +-})(); ++ function integer() { ++ if(c === '.') { ++ content.push(c) ++ mode = FLOAT ++ last = c ++ return i + 1 ++ } + +-var unary_ops = { +- not: "!", +- bnot: "~", +- neg: "-", +- recip: "1.0/" +-} +-;(function(){ +- for(var id in unary_ops) { +- var op = unary_ops[id] +- exports[id] = makeOp({ +- args: ["array", "array"], +- body: {args:["a","b"], +- body:"a="+op+"b"}, +- funcName: id +- }) +- exports[id+"eq"] = makeOp({ +- args: ["array"], +- body: {args:["a"], +- body:"a="+op+"a"}, +- rvalue: true, +- count: 2, +- funcName: id+"eq" +- }) +- } +-})(); ++ if(/[eE]/.test(c)) { ++ content.push(c) ++ mode = FLOAT ++ last = c ++ return i + 1 ++ } + +-var binary_ops = { +- and: "&&", +- or: "||", +- eq: "===", +- neq: "!==", +- lt: "<", +- gt: ">", +- leq: "<=", +- geq: ">=" +-} +-;(function() { +- for(var id in binary_ops) { +- var op = binary_ops[id] +- exports[id] = makeOp({ +- args: ["array","array","array"], +- body: {args:["a", "b", "c"], +- body:"a=b"+op+"c"}, +- funcName: id +- }) +- exports[id+"s"] = makeOp({ +- args: ["array","array","scalar"], +- body: {args:["a", "b", "s"], +- body:"a=b"+op+"s"}, +- funcName: id+"s" +- }) +- exports[id+"eq"] = makeOp({ +- args: ["array", "array"], +- body: {args:["a", "b"], +- body:"a=a"+op+"b"}, +- rvalue:true, +- count:2, +- funcName: id+"eq" +- }) +- exports[id+"seq"] = makeOp({ +- args: ["array", "scalar"], +- body: {args:["a","s"], +- body:"a=a"+op+"s"}, +- rvalue:true, +- count:2, +- funcName: id+"seq" +- }) +- } +-})(); ++ if(c === 'x' && content.length === 1 && content[0] === '0') { ++ mode = HEX ++ content.push(c) ++ last = c ++ return i + 1 ++ } + +-var math_unary = [ +- "abs", +- "acos", +- "asin", +- "atan", +- "ceil", +- "cos", +- "exp", +- "floor", +- "log", +- "round", +- "sin", +- "sqrt", +- "tan" +-] +-;(function() { +- for(var i=0; i -1) { ++ mode = KEYWORD ++ } else if(allBuiltins.indexOf(contentstr) > -1) { ++ mode = BUILTIN ++ } else { ++ mode = IDENT ++ } ++ token(content.join('')) ++ mode = NORMAL ++ return i ++ } ++ content.push(c) ++ last = c ++ return i + 1 ++ } ++} + +-exports.norminf = compile({ +- args:["array"], +- pre: {args:[], localVars:[], thisVars:["this_s"], body:"this_s=0"}, +- body: {args:[{name:"a", lvalue:false, rvalue:true, count:4}], body:"if(-a>this_s){this_s=-a}else if(a>this_s){this_s=a}", localVars: [], thisVars: ["this_s"]}, +- post: {args:[], localVars:[], thisVars:["this_s"], body:"return this_s"}, +- funcName: "norminf" +-}) ++},{"./lib/builtins":108,"./lib/builtins-300es":107,"./lib/literals":110,"./lib/literals-300es":109,"./lib/operators":111}],107:[function(require,module,exports){ ++// 300es builtins/reserved words that were previously valid in v100 ++var v100 = require('./builtins') + +-exports.norm1 = compile({ +- args:["array"], +- pre: {args:[], localVars:[], thisVars:["this_s"], body:"this_s=0"}, +- body: {args:[{name:"a", lvalue:false, rvalue:true, count:3}], body: "this_s+=a<0?-a:a", localVars: [], thisVars: ["this_s"]}, +- post: {args:[], localVars:[], thisVars:["this_s"], body:"return this_s"}, +- funcName: "norm1" ++// The texture2D|Cube functions have been removed ++// And the gl_ features are updated ++v100 = v100.slice().filter(function (b) { ++ return !/^(gl\_|texture)/.test(b) + }) + +-exports.sup = compile({ +- args: [ "array" ], +- pre: +- { body: "this_h=-Infinity", +- args: [], +- thisVars: [ "this_h" ], +- localVars: [] }, +- body: +- { body: "if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_", +- args: [{"name":"_inline_1_arg0_","lvalue":false,"rvalue":true,"count":2} ], +- thisVars: [ "this_h" ], +- localVars: [] }, +- post: +- { body: "return this_h", +- args: [], +- thisVars: [ "this_h" ], +- localVars: [] } +- }) ++module.exports = v100.concat([ ++ // the updated gl_ constants ++ 'gl_VertexID' ++ , 'gl_InstanceID' ++ , 'gl_Position' ++ , 'gl_PointSize' ++ , 'gl_FragCoord' ++ , 'gl_FrontFacing' ++ , 'gl_FragDepth' ++ , 'gl_PointCoord' ++ , 'gl_MaxVertexAttribs' ++ , 'gl_MaxVertexUniformVectors' ++ , 'gl_MaxVertexOutputVectors' ++ , 'gl_MaxFragmentInputVectors' ++ , 'gl_MaxVertexTextureImageUnits' ++ , 'gl_MaxCombinedTextureImageUnits' ++ , 'gl_MaxTextureImageUnits' ++ , 'gl_MaxFragmentUniformVectors' ++ , 'gl_MaxDrawBuffers' ++ , 'gl_MinProgramTexelOffset' ++ , 'gl_MaxProgramTexelOffset' ++ , 'gl_DepthRangeParameters' ++ , 'gl_DepthRange' + +-exports.inf = compile({ +- args: [ "array" ], +- pre: +- { body: "this_h=Infinity", +- args: [], +- thisVars: [ "this_h" ], +- localVars: [] }, +- body: +- { body: "if(_inline_1_arg0_this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}", +- args:[ +- {name:"_inline_1_arg0_",lvalue:false,rvalue:true,count:2}, +- {name:"_inline_1_arg1_",lvalue:false,rvalue:true,count:2}], +- thisVars:["this_i","this_v"], +- localVars:["_inline_1_k"]}, +- post:{ +- body:"{return this_i}", +- args:[], +- thisVars:["this_i"], +- localVars:[]} +-}) ++},{}],109:[function(require,module,exports){ ++var v100 = require('./literals') + +-exports.random = makeOp({ +- args: ["array"], +- pre: {args:[], body:"this_f=Math.random", thisVars:["this_f"]}, +- body: {args: ["a"], body:"a=this_f()", thisVars:["this_f"]}, +- funcName: "random" +-}) ++module.exports = v100.slice().concat([ ++ 'layout' ++ , 'centroid' ++ , 'smooth' ++ , 'case' ++ , 'mat2x2' ++ , 'mat2x3' ++ , 'mat2x4' ++ , 'mat3x2' ++ , 'mat3x3' ++ , 'mat3x4' ++ , 'mat4x2' ++ , 'mat4x3' ++ , 'mat4x4' ++ , 'uint' ++ , 'uvec2' ++ , 'uvec3' ++ , 'uvec4' ++ , 'samplerCubeShadow' ++ , 'sampler2DArray' ++ , 'sampler2DArrayShadow' ++ , 'isampler2D' ++ , 'isampler3D' ++ , 'isamplerCube' ++ , 'isampler2DArray' ++ , 'usampler2D' ++ , 'usampler3D' ++ , 'usamplerCube' ++ , 'usampler2DArray' ++ , 'coherent' ++ , 'restrict' ++ , 'readonly' ++ , 'writeonly' ++ , 'resource' ++ , 'atomic_uint' ++ , 'noperspective' ++ , 'patch' ++ , 'sample' ++ , 'subroutine' ++ , 'common' ++ , 'partition' ++ , 'active' ++ , 'filter' ++ , 'image1D' ++ , 'image2D' ++ , 'image3D' ++ , 'imageCube' ++ , 'iimage1D' ++ , 'iimage2D' ++ , 'iimage3D' ++ , 'iimageCube' ++ , 'uimage1D' ++ , 'uimage2D' ++ , 'uimage3D' ++ , 'uimageCube' ++ , 'image1DArray' ++ , 'image2DArray' ++ , 'iimage1DArray' ++ , 'iimage2DArray' ++ , 'uimage1DArray' ++ , 'uimage2DArray' ++ , 'image1DShadow' ++ , 'image2DShadow' ++ , 'image1DArrayShadow' ++ , 'image2DArrayShadow' ++ , 'imageBuffer' ++ , 'iimageBuffer' ++ , 'uimageBuffer' ++ , 'sampler1DArray' ++ , 'sampler1DArrayShadow' ++ , 'isampler1D' ++ , 'isampler1DArray' ++ , 'usampler1D' ++ , 'usampler1DArray' ++ , 'isampler2DRect' ++ , 'usampler2DRect' ++ , 'samplerBuffer' ++ , 'isamplerBuffer' ++ , 'usamplerBuffer' ++ , 'sampler2DMS' ++ , 'isampler2DMS' ++ , 'usampler2DMS' ++ , 'sampler2DMSArray' ++ , 'isampler2DMSArray' ++ , 'usampler2DMSArray' ++]) + +-exports.assign = makeOp({ +- args:["array", "array"], +- body: {args:["a", "b"], body:"a=b"}, +- funcName: "assign" }) ++},{"./literals":110}],110:[function(require,module,exports){ ++module.exports = [ ++ // current ++ 'precision' ++ , 'highp' ++ , 'mediump' ++ , 'lowp' ++ , 'attribute' ++ , 'const' ++ , 'uniform' ++ , 'varying' ++ , 'break' ++ , 'continue' ++ , 'do' ++ , 'for' ++ , 'while' ++ , 'if' ++ , 'else' ++ , 'in' ++ , 'out' ++ , 'inout' ++ , 'float' ++ , 'int' ++ , 'void' ++ , 'bool' ++ , 'true' ++ , 'false' ++ , 'discard' ++ , 'return' ++ , 'mat2' ++ , 'mat3' ++ , 'mat4' ++ , 'vec2' ++ , 'vec3' ++ , 'vec4' ++ , 'ivec2' ++ , 'ivec3' ++ , 'ivec4' ++ , 'bvec2' ++ , 'bvec3' ++ , 'bvec4' ++ , 'sampler1D' ++ , 'sampler2D' ++ , 'sampler3D' ++ , 'samplerCube' ++ , 'sampler1DShadow' ++ , 'sampler2DShadow' ++ , 'struct' + +-exports.assigns = makeOp({ +- args:["array", "scalar"], +- body: {args:["a", "b"], body:"a=b"}, +- funcName: "assigns" }) ++ // future ++ , 'asm' ++ , 'class' ++ , 'union' ++ , 'enum' ++ , 'typedef' ++ , 'template' ++ , 'this' ++ , 'packed' ++ , 'goto' ++ , 'switch' ++ , 'default' ++ , 'inline' ++ , 'noinline' ++ , 'volatile' ++ , 'public' ++ , 'static' ++ , 'extern' ++ , 'external' ++ , 'interface' ++ , 'long' ++ , 'short' ++ , 'double' ++ , 'half' ++ , 'fixed' ++ , 'unsigned' ++ , 'input' ++ , 'output' ++ , 'hvec2' ++ , 'hvec3' ++ , 'hvec4' ++ , 'dvec2' ++ , 'dvec3' ++ , 'dvec4' ++ , 'fvec2' ++ , 'fvec3' ++ , 'fvec4' ++ , 'sampler2DRect' ++ , 'sampler3DRect' ++ , 'sampler2DRectShadow' ++ , 'sizeof' ++ , 'cast' ++ , 'namespace' ++ , 'using' ++] ++ ++},{}],111:[function(require,module,exports){ ++module.exports = [ ++ '<<=' ++ , '>>=' ++ , '++' ++ , '--' ++ , '<<' ++ , '>>' ++ , '<=' ++ , '>=' ++ , '==' ++ , '!=' ++ , '&&' ++ , '||' ++ , '+=' ++ , '-=' ++ , '*=' ++ , '/=' ++ , '%=' ++ , '&=' ++ , '^^' ++ , '^=' ++ , '|=' ++ , '(' ++ , ')' ++ , '[' ++ , ']' ++ , '.' ++ , '!' ++ , '~' ++ , '*' ++ , '/' ++ , '%' ++ , '+' ++ , '-' ++ , '<' ++ , '>' ++ , '&' ++ , '^' ++ , '|' ++ , '?' ++ , ':' ++ , '=' ++ , ',' ++ , ';' ++ , '{' ++ , '}' ++] + ++},{}],112:[function(require,module,exports){ ++var tokenize = require('./index') + +-exports.equals = compile({ +- args:["array", "array"], +- pre: EmptyProc, +- body: {args:[{name:"x", lvalue:false, rvalue:true, count:1}, +- {name:"y", lvalue:false, rvalue:true, count:1}], +- body: "if(x!==y){return false}", +- localVars: [], +- thisVars: []}, +- post: {args:[], localVars:[], thisVars:[], body:"return true"}, +- funcName: "equals" +-}) ++module.exports = tokenizeString + ++function tokenizeString(str, opt) { ++ var generator = tokenize(opt) ++ var tokens = [] + ++ tokens = tokens.concat(generator(str)) ++ tokens = tokens.concat(generator(null)) + +-},{"cwise-compiler":58}],131:[function(require,module,exports){ +-var iota = require("iota-array") +-var isBuffer = require("is-buffer") ++ return tokens ++} + +-var hasTypedArrays = ((typeof Float64Array) !== "undefined") ++},{"./index":106}],113:[function(require,module,exports){ ++exports.read = function (buffer, offset, isLE, mLen, nBytes) { ++ var e, m ++ var eLen = nBytes * 8 - mLen - 1 ++ var eMax = (1 << eLen) - 1 ++ var eBias = eMax >> 1 ++ var nBits = -7 ++ var i = isLE ? (nBytes - 1) : 0 ++ var d = isLE ? -1 : 1 ++ var s = buffer[offset + i] + +-function compare1st(a, b) { +- return a[0] - b[0] +-} ++ i += d + +-function order() { +- var stride = this.stride +- var terms = new Array(stride.length) +- var i +- for(i=0; i>= (-nBits) ++ nBits += eLen ++ for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {} + +-function compileConstructor(dtype, dimension) { +- var className = ["View", dimension, "d", dtype].join("") +- if(dimension < 0) { +- className = "View_Nil" + dtype +- } +- var useGetters = (dtype === "generic") ++ m = e & ((1 << (-nBits)) - 1) ++ e >>= (-nBits) ++ nBits += mLen ++ for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {} + +- if(dimension === -1) { +- //Special case for trivial arrays +- var code = +- "function "+className+"(a){this.data=a;};\ +-var proto="+className+".prototype;\ +-proto.dtype='"+dtype+"';\ +-proto.index=function(){return -1};\ +-proto.size=0;\ +-proto.dimension=-1;\ +-proto.shape=proto.stride=proto.order=[];\ +-proto.lo=proto.hi=proto.transpose=proto.step=\ +-function(){return new "+className+"(this.data);};\ +-proto.get=proto.set=function(){};\ +-proto.pick=function(){return null};\ +-return function construct_"+className+"(a){return new "+className+"(a);}" +- var procedure = new Function(code) +- return procedure() +- } else if(dimension === 0) { +- //Special case for 0d arrays +- var code = +- "function "+className+"(a,d) {\ +-this.data = a;\ +-this.offset = d\ +-};\ +-var proto="+className+".prototype;\ +-proto.dtype='"+dtype+"';\ +-proto.index=function(){return this.offset};\ +-proto.dimension=0;\ +-proto.size=1;\ +-proto.shape=\ +-proto.stride=\ +-proto.order=[];\ +-proto.lo=\ +-proto.hi=\ +-proto.transpose=\ +-proto.step=function "+className+"_copy() {\ +-return new "+className+"(this.data,this.offset)\ +-};\ +-proto.pick=function "+className+"_pick(){\ +-return TrivialArray(this.data);\ +-};\ +-proto.valueOf=proto.get=function "+className+"_get(){\ +-return "+(useGetters ? "this.data.get(this.offset)" : "this.data[this.offset]")+ +-"};\ +-proto.set=function "+className+"_set(v){\ +-return "+(useGetters ? "this.data.set(this.offset,v)" : "this.data[this.offset]=v")+"\ +-};\ +-return function construct_"+className+"(a,b,c,d){return new "+className+"(a,d)}" +- var procedure = new Function("TrivialArray", code) +- return procedure(CACHED_CONSTRUCTORS[dtype][0]) ++ if (e === 0) { ++ e = 1 - eBias ++ } else if (e === eMax) { ++ return m ? NaN : ((s ? -1 : 1) * Infinity) ++ } else { ++ m = m + Math.pow(2, mLen) ++ e = e - eBias + } ++ return (s ? -1 : 1) * m * Math.pow(2, e - mLen) ++} + +- var code = ["'use strict'"] +- +- //Create constructor for view +- var indices = iota(dimension) +- var args = indices.map(function(i) { return "i"+i }) +- var index_str = "this.offset+" + indices.map(function(i) { +- return "this.stride[" + i + "]*i" + i +- }).join("+") +- var shapeArg = indices.map(function(i) { +- return "b"+i +- }).join(",") +- var strideArg = indices.map(function(i) { +- return "c"+i +- }).join(",") +- code.push( +- "function "+className+"(a," + shapeArg + "," + strideArg + ",d){this.data=a", +- "this.shape=[" + shapeArg + "]", +- "this.stride=[" + strideArg + "]", +- "this.offset=d|0}", +- "var proto="+className+".prototype", +- "proto.dtype='"+dtype+"'", +- "proto.dimension="+dimension) ++exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { ++ var e, m, c ++ var eLen = nBytes * 8 - mLen - 1 ++ var eMax = (1 << eLen) - 1 ++ var eBias = eMax >> 1 ++ var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) ++ var i = isLE ? 0 : (nBytes - 1) ++ var d = isLE ? 1 : -1 ++ var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 + +- //view.size: +- code.push("Object.defineProperty(proto,'size',{get:function "+className+"_size(){\ +-return "+indices.map(function(i) { return "this.shape["+i+"]" }).join("*"), +-"}})") ++ value = Math.abs(value) + +- //view.order: +- if(dimension === 1) { +- code.push("proto.order=[0]") ++ if (isNaN(value) || value === Infinity) { ++ m = isNaN(value) ? 1 : 0 ++ e = eMax + } else { +- code.push("Object.defineProperty(proto,'order',{get:") +- if(dimension < 4) { +- code.push("function "+className+"_order(){") +- if(dimension === 2) { +- code.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})") +- } else if(dimension === 3) { +- code.push( +-"var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);\ +-if(s0>s1){\ +-if(s1>s2){\ +-return [2,1,0];\ +-}else if(s0>s2){\ +-return [1,2,0];\ +-}else{\ +-return [1,0,2];\ +-}\ +-}else if(s0>s2){\ +-return [2,0,1];\ +-}else if(s2>s1){\ +-return [0,1,2];\ +-}else{\ +-return [0,2,1];\ +-}}})") +- } ++ e = Math.floor(Math.log(value) / Math.LN2) ++ if (value * (c = Math.pow(2, -e)) < 1) { ++ e-- ++ c *= 2 ++ } ++ if (e + eBias >= 1) { ++ value += rt / c + } else { +- code.push("ORDER})") ++ value += rt * Math.pow(2, 1 - eBias) ++ } ++ if (value * c >= 2) { ++ e++ ++ c /= 2 + } +- } + +- //view.set(i0, ..., v): +- code.push( +-"proto.set=function "+className+"_set("+args.join(",")+",v){") +- if(useGetters) { +- code.push("return this.data.set("+index_str+",v)}") +- } else { +- code.push("return this.data["+index_str+"]=v}") ++ if (e + eBias >= eMax) { ++ m = 0 ++ e = eMax ++ } else if (e + eBias >= 1) { ++ m = (value * c - 1) * Math.pow(2, mLen) ++ e = e + eBias ++ } else { ++ m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) ++ e = 0 ++ } + } + +- //view.get(i0, ...): +- code.push("proto.get=function "+className+"_get("+args.join(",")+"){") +- if(useGetters) { +- code.push("return this.data.get("+index_str+")}") +- } else { +- code.push("return this.data["+index_str+"]}") +- } ++ for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} + +- //view.index: +- code.push( +- "proto.index=function "+className+"_index(", args.join(), "){return "+index_str+"}") ++ e = (e << mLen) | m ++ eLen += mLen ++ for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} + +- //view.hi(): +- code.push("proto.hi=function "+className+"_hi("+args.join(",")+"){return new "+className+"(this.data,"+ +- indices.map(function(i) { +- return ["(typeof i",i,"!=='number'||i",i,"<0)?this.shape[", i, "]:i", i,"|0"].join("") +- }).join(",")+","+ +- indices.map(function(i) { +- return "this.stride["+i + "]" +- }).join(",")+",this.offset)}") ++ buffer[offset + i - d] |= s * 128 ++} + +- //view.lo(): +- var a_vars = indices.map(function(i) { return "a"+i+"=this.shape["+i+"]" }) +- var c_vars = indices.map(function(i) { return "c"+i+"=this.stride["+i+"]" }) +- code.push("proto.lo=function "+className+"_lo("+args.join(",")+"){var b=this.offset,d=0,"+a_vars.join(",")+","+c_vars.join(",")) +- for(var i=0; i=0){\ +-d=i"+i+"|0;\ +-b+=c"+i+"*d;\ +-a"+i+"-=d}") +- } +- code.push("return new "+className+"(this.data,"+ +- indices.map(function(i) { +- return "a"+i +- }).join(",")+","+ +- indices.map(function(i) { +- return "c"+i +- }).join(",")+",b)}") ++},{}],114:[function(require,module,exports){ ++"use strict" + +- //view.step(): +- code.push("proto.step=function "+className+"_step("+args.join(",")+"){var "+ +- indices.map(function(i) { +- return "a"+i+"=this.shape["+i+"]" +- }).join(",")+","+ +- indices.map(function(i) { +- return "b"+i+"=this.stride["+i+"]" +- }).join(",")+",c=this.offset,d=0,ceil=Math.ceil") +- for(var i=0; i=0){c=(c+this.stride["+i+"]*i"+i+")|0}else{a.push(this.shape["+i+"]);b.push(this.stride["+i+"])}") +- } +- code.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}") ++module.exports = createWrapper + +- //Add return statement +- code.push("return function construct_"+className+"(data,shape,stride,offset){return new "+className+"(data,"+ +- indices.map(function(i) { +- return "shape["+i+"]" +- }).join(",")+","+ +- indices.map(function(i) { +- return "stride["+i+"]" +- }).join(",")+",offset)}") ++function IntervalTreeNode(mid, left, right, leftPoints, rightPoints) { ++ this.mid = mid ++ this.left = left ++ this.right = right ++ this.leftPoints = leftPoints ++ this.rightPoints = rightPoints ++ this.count = (left ? left.count : 0) + (right ? right.count : 0) + leftPoints.length ++} + +- //Compile procedure +- var procedure = new Function("CTOR_LIST", "ORDER", code.join("\n")) +- return procedure(CACHED_CONSTRUCTORS[dtype], order) ++var proto = IntervalTreeNode.prototype ++ ++function copy(a, b) { ++ a.mid = b.mid ++ a.left = b.left ++ a.right = b.right ++ a.leftPoints = b.leftPoints ++ a.rightPoints = b.rightPoints ++ a.count = b.count + } + +-function arrayDType(data) { +- if(isBuffer(data)) { +- return "buffer" +- } +- if(hasTypedArrays) { +- switch(Object.prototype.toString.call(data)) { +- case "[object Float64Array]": +- return "float64" +- case "[object Float32Array]": +- return "float32" +- case "[object Int8Array]": +- return "int8" +- case "[object Int16Array]": +- return "int16" +- case "[object Int32Array]": +- return "int32" +- case "[object Uint8Array]": +- return "uint8" +- case "[object Uint16Array]": +- return "uint16" +- case "[object Uint32Array]": +- return "uint32" +- case "[object Uint8ClampedArray]": +- return "uint8_clamped" +- } +- } +- if(Array.isArray(data)) { +- return "array" +- } +- return "generic" ++function rebuild(node, intervals) { ++ var ntree = createIntervalTree(intervals) ++ node.mid = ntree.mid ++ node.left = ntree.left ++ node.right = ntree.right ++ node.leftPoints = ntree.leftPoints ++ node.rightPoints = ntree.rightPoints ++ node.count = ntree.count + } + +-var CACHED_CONSTRUCTORS = { +- "float32":[], +- "float64":[], +- "int8":[], +- "int16":[], +- "int32":[], +- "uint8":[], +- "uint16":[], +- "uint32":[], +- "array":[], +- "uint8_clamped":[], +- "buffer":[], +- "generic":[] ++function rebuildWithInterval(node, interval) { ++ var intervals = node.intervals([]) ++ intervals.push(interval) ++ rebuild(node, intervals) + } + +-;(function() { +- for(var id in CACHED_CONSTRUCTORS) { +- CACHED_CONSTRUCTORS[id].push(compileConstructor(id, -1)) ++function rebuildWithoutInterval(node, interval) { ++ var intervals = node.intervals([]) ++ var idx = intervals.indexOf(interval) ++ if(idx < 0) { ++ return NOT_FOUND + } +-}); ++ intervals.splice(idx, 1) ++ rebuild(node, intervals) ++ return SUCCESS ++} + +-function wrappedNDArrayCtor(data, shape, stride, offset) { +- if(data === undefined) { +- var ctor = CACHED_CONSTRUCTORS.array[0] +- return ctor([]) +- } else if(typeof data === "number") { +- data = [data] ++proto.intervals = function(result) { ++ result.push.apply(result, this.leftPoints) ++ if(this.left) { ++ this.left.intervals(result) + } +- if(shape === undefined) { +- shape = [ data.length ] ++ if(this.right) { ++ this.right.intervals(result) + } +- var d = shape.length +- if(stride === undefined) { +- stride = new Array(d) +- for(var i=d-1, sz=1; i>=0; --i) { +- stride[i] = sz +- sz *= shape[i] ++ return result ++} ++ ++proto.insert = function(interval) { ++ var weight = this.count - this.leftPoints.length ++ this.count += 1 ++ if(interval[1] < this.mid) { ++ if(this.left) { ++ if(4*(this.left.count+1) > 3*(weight+1)) { ++ rebuildWithInterval(this, interval) ++ } else { ++ this.left.insert(interval) ++ } ++ } else { ++ this.left = createIntervalTree([interval]) ++ } ++ } else if(interval[0] > this.mid) { ++ if(this.right) { ++ if(4*(this.right.count+1) > 3*(weight+1)) { ++ rebuildWithInterval(this, interval) ++ } else { ++ this.right.insert(interval) ++ } ++ } else { ++ this.right = createIntervalTree([interval]) ++ } ++ } else { ++ var l = bounds.ge(this.leftPoints, interval, compareBegin) ++ var r = bounds.ge(this.rightPoints, interval, compareEnd) ++ this.leftPoints.splice(l, 0, interval) ++ this.rightPoints.splice(r, 0, interval) ++ } ++} ++ ++proto.remove = function(interval) { ++ var weight = this.count - this.leftPoints ++ if(interval[1] < this.mid) { ++ if(!this.left) { ++ return NOT_FOUND ++ } ++ var rw = this.right ? this.right.count : 0 ++ if(4 * rw > 3 * (weight-1)) { ++ return rebuildWithoutInterval(this, interval) ++ } ++ var r = this.left.remove(interval) ++ if(r === EMPTY) { ++ this.left = null ++ this.count -= 1 ++ return SUCCESS ++ } else if(r === SUCCESS) { ++ this.count -= 1 ++ } ++ return r ++ } else if(interval[0] > this.mid) { ++ if(!this.right) { ++ return NOT_FOUND ++ } ++ var lw = this.left ? this.left.count : 0 ++ if(4 * lw > 3 * (weight-1)) { ++ return rebuildWithoutInterval(this, interval) ++ } ++ var r = this.right.remove(interval) ++ if(r === EMPTY) { ++ this.right = null ++ this.count -= 1 ++ return SUCCESS ++ } else if(r === SUCCESS) { ++ this.count -= 1 ++ } ++ return r ++ } else { ++ if(this.count === 1) { ++ if(this.leftPoints[0] === interval) { ++ return EMPTY ++ } else { ++ return NOT_FOUND ++ } ++ } ++ if(this.leftPoints.length === 1 && this.leftPoints[0] === interval) { ++ if(this.left && this.right) { ++ var p = this ++ var n = this.left ++ while(n.right) { ++ p = n ++ n = n.right ++ } ++ if(p === this) { ++ n.right = this.right ++ } else { ++ var l = this.left ++ var r = this.right ++ p.count -= n.count ++ p.right = n.left ++ n.left = l ++ n.right = r ++ } ++ copy(this, n) ++ this.count = (this.left?this.left.count:0) + (this.right?this.right.count:0) + this.leftPoints.length ++ } else if(this.left) { ++ copy(this, this.left) ++ } else { ++ copy(this, this.right) ++ } ++ return SUCCESS + } +- } +- if(offset === undefined) { +- offset = 0 +- for(var i=0; i +- * +- * Copyright (c) 2014-2015, Jon Schlinkert. +- * Licensed under the MIT License. +- */ +- +-'use strict'; +- +-/** +- * Results cache +- */ +- +-var res = ''; +-var cache; +- +-/** +- * Expose `repeat` +- */ +- +-module.exports = repeat; +- +-/** +- * Repeat the given `string` the specified `number` +- * of times. +- * +- * **Example:** +- * +- * ```js +- * var repeat = require('repeat-string'); +- * repeat('A', 5); +- * //=> AAAAA +- * ``` +- * +- * @param {String} `string` The string to repeat +- * @param {Number} `number` The number of times to repeat the string +- * @return {String} Repeated string +- * @api public +- */ +- +-function repeat(str, num) { +- if (typeof str !== 'string') { +- throw new TypeError('repeat-string expects a string.'); ++function reportLeftRange(arr, hi, cb) { ++ for(var i=0; i=0 && arr[i][1] >= lo; --i) { ++ var r = cb(arr[i]) ++ if(r) { return r } ++ } ++} + +- var max = str.length * num; +- if (cache !== str || typeof cache === 'undefined') { +- cache = str; +- res = ''; ++function reportRange(arr, cb) { ++ for(var i=0; i res.length && num > 0) { +- if (num & 1) { +- res += str; ++proto.queryPoint = function(x, cb) { ++ if(x < this.mid) { ++ if(this.left) { ++ var r = this.left.queryPoint(x, cb) ++ if(r) { return r } + } +- +- num >>= 1; +- if (!num) break; +- str += str; ++ return reportLeftRange(this.leftPoints, x, cb) ++ } else if(x > this.mid) { ++ if(this.right) { ++ var r = this.right.queryPoint(x, cb) ++ if(r) { return r } ++ } ++ return reportRightRange(this.rightPoints, x, cb) ++ } else { ++ return reportRange(this.leftPoints, cb) + } ++} + +- return res.substr(0, max); ++proto.queryInterval = function(lo, hi, cb) { ++ if(lo < this.mid && this.left) { ++ var r = this.left.queryInterval(lo, hi, cb) ++ if(r) { return r } ++ } ++ if(hi > this.mid && this.right) { ++ var r = this.right.queryInterval(lo, hi, cb) ++ if(r) { return r } ++ } ++ if(hi < this.mid) { ++ return reportLeftRange(this.leftPoints, hi, cb) ++ } else if(lo > this.mid) { ++ return reportRightRange(this.rightPoints, lo, cb) ++ } else { ++ return reportRange(this.leftPoints, cb) ++ } + } + ++function compareNumbers(a, b) { ++ return a - b ++} + +-},{}],133:[function(require,module,exports){ +-"use strict" ++function compareBegin(a, b) { ++ var d = a[0] - b[0] ++ if(d) { return d } ++ return a[1] - b[1] ++} + +-var twoProduct = require("two-product") +-var robustSum = require("robust-sum") +-var robustScale = require("robust-scale") +-var robustSubtract = require("robust-subtract") ++function compareEnd(a, b) { ++ var d = a[1] - b[1] ++ if(d) { return d } ++ return a[0] - b[0] ++} + +-var NUM_EXPAND = 5 ++function createIntervalTree(intervals) { ++ if(intervals.length === 0) { ++ return null ++ } ++ var pts = [] ++ for(var i=0; i>1] + +-function cofactor(m, c) { +- var result = new Array(m.length-1) +- for(var i=1; i>1 +- return ["sum(", generateSum(expr.slice(0, m)), ",", generateSum(expr.slice(m)), ")"].join("") ++ this.root = new IntervalTreeNode(interval[0], null, null, [interval], [interval]) + } + } + +-function determinant(m) { +- if(m.length === 2) { +- return [["sum(prod(", m[0][0], ",", m[1][1], "),prod(-", m[0][1], ",", m[1][0], "))"].join("")] +- } else { +- var expr = [] +- for(var i=0; i 0) { +- if(r <= 0) { +- return det +- } else { +- s = l + r +- } +- } else if(l < 0) { +- if(r >= 0) { +- return det +- } else { +- s = -(l + r) +- } +- } else { +- return det +- } +- var tol = ERRBOUND3 * s +- if(det >= tol || det <= -tol) { +- return det ++Object.defineProperty(tproto, "count", { ++ get: function() { ++ if(this.root) { ++ return this.root.count + } +- return orientation3Exact(a, b, c) +- }, +- function orientation4(a,b,c,d) { +- var adx = a[0] - d[0] +- var bdx = b[0] - d[0] +- var cdx = c[0] - d[0] +- var ady = a[1] - d[1] +- var bdy = b[1] - d[1] +- var cdy = c[1] - d[1] +- var adz = a[2] - d[2] +- var bdz = b[2] - d[2] +- var cdz = c[2] - d[2] +- var bdxcdy = bdx * cdy +- var cdxbdy = cdx * bdy +- var cdxady = cdx * ady +- var adxcdy = adx * cdy +- var adxbdy = adx * bdy +- var bdxady = bdx * ady +- var det = adz * (bdxcdy - cdxbdy) +- + bdz * (cdxady - adxcdy) +- + cdz * (adxbdy - bdxady) +- var permanent = (Math.abs(bdxcdy) + Math.abs(cdxbdy)) * Math.abs(adz) +- + (Math.abs(cdxady) + Math.abs(adxcdy)) * Math.abs(bdz) +- + (Math.abs(adxbdy) + Math.abs(bdxady)) * Math.abs(cdz) +- var tol = ERRBOUND4 * permanent +- if ((det > tol) || (-det > tol)) { +- return det ++ return 0 ++ } ++}) ++ ++Object.defineProperty(tproto, "intervals", { ++ get: function() { ++ if(this.root) { ++ return this.root.intervals([]) + } +- return orientation4Exact(a,b,c,d) ++ return [] + } +-] ++}) + +-function slowOrient(args) { +- var proc = CACHED[args.length] +- if(!proc) { +- proc = CACHED[args.length] = orientation(args.length) ++function createWrapper(intervals) { ++ if(!intervals || intervals.length === 0) { ++ return new IntervalTree(null) + } +- return proc.apply(undefined, args) ++ return new IntervalTree(createIntervalTree(intervals)) + } + +-function generateOrientationProc() { +- while(CACHED.length <= NUM_EXPAND) { +- CACHED.push(orientation(CACHED.length)) +- } +- var args = [] +- var procArgs = ["slow"] +- for(var i=0; i<=NUM_EXPAND; ++i) { +- args.push("a" + i) +- procArgs.push("o" + i) +- } +- var code = [ +- "function getOrientation(", args.join(), "){switch(arguments.length){case 0:case 1:return 0;" +- ] +- for(var i=2; i<=NUM_EXPAND; ++i) { +- code.push("case ", i, ":return o", i, "(", args.slice(0, i).join(), ");") +- } +- code.push("}var s=new Array(arguments.length);for(var i=0;i ++ * @license MIT ++ */ + +-function scaleLinearExpansion(e, scale) { +- var n = e.length +- if(n === 1) { +- var ts = twoProduct(e[0], scale) +- if(ts[0]) { +- return ts +- } +- return [ ts[1] ] +- } +- var g = new Array(2 * n) +- var q = [0.1, 0.1] +- var t = [0.1, 0.1] +- var count = 0 +- twoProduct(e[0], scale, q) +- if(q[0]) { +- g[count++] = q[0] +- } +- for(var i=1; i= nf)) { +- a = ei +- eptr += 1 +- if(eptr < ne) { +- ei = e[eptr] +- ea = abs(ei) ++ var attached = false ++ ++ function updateMods(ev) { ++ var changed = false ++ if('altKey' in ev) { ++ changed = changed || ev.altKey !== mods.alt ++ mods.alt = !!ev.altKey + } +- } else { +- a = fi +- fptr += 1 +- if(fptr < nf) { +- fi = -f[fptr] +- fa = abs(fi) ++ if('shiftKey' in ev) { ++ changed = changed || ev.shiftKey !== mods.shift ++ mods.shift = !!ev.shiftKey + } +- } +- var x = a + b +- var bv = x - a +- var y = b - bv +- var q0 = y +- var q1 = x +- var _x, _bv, _av, _br, _ar +- while(eptr < ne && fptr < nf) { +- if(ea < fa) { +- a = ei +- eptr += 1 +- if(eptr < ne) { +- ei = e[eptr] +- ea = abs(ei) +- } +- } else { +- a = fi +- fptr += 1 +- if(fptr < nf) { +- fi = -f[fptr] +- fa = abs(fi) +- } ++ if('ctrlKey' in ev) { ++ changed = changed || ev.ctrlKey !== mods.control ++ mods.control = !!ev.ctrlKey + } +- b = q0 +- x = a + b +- bv = x - a +- y = b - bv +- if(y) { +- g[count++] = y ++ if('metaKey' in ev) { ++ changed = changed || ev.metaKey !== mods.meta ++ mods.meta = !!ev.metaKey + } +- _x = q1 + x +- _bv = _x - q1 +- _av = _x - _bv +- _br = x - _bv +- _ar = q1 - _av +- q0 = _ar + _br +- q1 = _x ++ return changed + } +- while(eptr < ne) { +- a = ei +- b = q0 +- x = a + b +- bv = x - a +- y = b - bv +- if(y) { +- g[count++] = y +- } +- _x = q1 + x +- _bv = _x - q1 +- _av = _x - _bv +- _br = x - _bv +- _ar = q1 - _av +- q0 = _ar + _br +- q1 = _x +- eptr += 1 +- if(eptr < ne) { +- ei = e[eptr] ++ ++ function handleEvent(nextButtons, ev) { ++ var nextX = mouse.x(ev) ++ var nextY = mouse.y(ev) ++ if('buttons' in ev) { ++ nextButtons = ev.buttons|0 + } +- } +- while(fptr < nf) { +- a = fi +- b = q0 +- x = a + b +- bv = x - a +- y = b - bv +- if(y) { +- g[count++] = y +- } +- _x = q1 + x +- _bv = _x - q1 +- _av = _x - _bv +- _br = x - _bv +- _ar = q1 - _av +- q0 = _ar + _br +- q1 = _x +- fptr += 1 +- if(fptr < nf) { +- fi = -f[fptr] ++ if(nextButtons !== buttonState || ++ nextX !== x || ++ nextY !== y || ++ updateMods(ev)) { ++ buttonState = nextButtons|0 ++ x = nextX||0 ++ y = nextY||0 ++ callback && callback(buttonState, x, y, mods) + } + } +- if(q0) { +- g[count++] = q0 ++ ++ function clearState(ev) { ++ handleEvent(0, ev) + } +- if(q1) { +- g[count++] = q1 ++ ++ function handleBlur() { ++ if(buttonState || ++ x || ++ y || ++ mods.shift || ++ mods.alt || ++ mods.meta || ++ mods.control) { ++ ++ x = y = 0 ++ buttonState = 0 ++ mods.shift = mods.alt = mods.control = mods.meta = false ++ callback && callback(0, 0, 0, mods) ++ } + } +- if(!count) { +- g[count++] = 0.0 ++ ++ function handleMods(ev) { ++ if(updateMods(ev)) { ++ callback && callback(buttonState, x, y, mods) ++ } + } +- g.length = count +- return g +-} +-},{}],136:[function(require,module,exports){ +-"use strict" + +-module.exports = linearExpansionSum ++ function handleMouseMove(ev) { ++ if(mouse.buttons(ev) === 0) { ++ handleEvent(0, ev) ++ } else { ++ handleEvent(buttonState, ev) ++ } ++ } + +-//Easy case: Add two scalars +-function scalarScalar(a, b) { +- var x = a + b +- var bv = x - a +- var av = x - bv +- var br = b - bv +- var ar = a - av +- var y = ar + br +- if(y) { +- return [y, x] ++ function handleMouseDown(ev) { ++ handleEvent(buttonState | mouse.buttons(ev), ev) + } +- return [x] +-} + +-function linearExpansionSum(e, f) { +- var ne = e.length|0 +- var nf = f.length|0 +- if(ne === 1 && nf === 1) { +- return scalarScalar(e[0], f[0]) ++ function handleMouseUp(ev) { ++ handleEvent(buttonState & ~mouse.buttons(ev), ev) + } +- var n = ne + nf +- var g = new Array(n) +- var count = 0 +- var eptr = 0 +- var fptr = 0 +- var abs = Math.abs +- var ei = e[eptr] +- var ea = abs(ei) +- var fi = f[fptr] +- var fa = abs(fi) +- var a, b +- if(ea < fa) { +- b = ei +- eptr += 1 +- if(eptr < ne) { +- ei = e[eptr] +- ea = abs(ei) ++ ++ function attachListeners() { ++ if(attached) { ++ return + } +- } else { +- b = fi +- fptr += 1 +- if(fptr < nf) { +- fi = f[fptr] +- fa = abs(fi) ++ attached = true ++ ++ element.addEventListener('mousemove', handleMouseMove) ++ ++ element.addEventListener('mousedown', handleMouseDown) ++ ++ element.addEventListener('mouseup', handleMouseUp) ++ ++ element.addEventListener('mouseleave', clearState) ++ element.addEventListener('mouseenter', clearState) ++ element.addEventListener('mouseout', clearState) ++ element.addEventListener('mouseover', clearState) ++ ++ element.addEventListener('blur', handleBlur) ++ ++ element.addEventListener('keyup', handleMods) ++ element.addEventListener('keydown', handleMods) ++ element.addEventListener('keypress', handleMods) ++ ++ if(element !== window) { ++ window.addEventListener('blur', handleBlur) ++ ++ window.addEventListener('keyup', handleMods) ++ window.addEventListener('keydown', handleMods) ++ window.addEventListener('keypress', handleMods) + } + } +- if((eptr < ne && ea < fa) || (fptr >= nf)) { +- a = ei +- eptr += 1 +- if(eptr < ne) { +- ei = e[eptr] +- ea = abs(ei) ++ ++ function detachListeners() { ++ if(!attached) { ++ return + } +- } else { +- a = fi +- fptr += 1 +- if(fptr < nf) { +- fi = f[fptr] +- fa = abs(fi) ++ attached = false ++ ++ element.removeEventListener('mousemove', handleMouseMove) ++ ++ element.removeEventListener('mousedown', handleMouseDown) ++ ++ element.removeEventListener('mouseup', handleMouseUp) ++ ++ element.removeEventListener('mouseleave', clearState) ++ element.removeEventListener('mouseenter', clearState) ++ element.removeEventListener('mouseout', clearState) ++ element.removeEventListener('mouseover', clearState) ++ ++ element.removeEventListener('blur', handleBlur) ++ ++ element.removeEventListener('keyup', handleMods) ++ element.removeEventListener('keydown', handleMods) ++ element.removeEventListener('keypress', handleMods) ++ ++ if(element !== window) { ++ window.removeEventListener('blur', handleBlur) ++ ++ window.removeEventListener('keyup', handleMods) ++ window.removeEventListener('keydown', handleMods) ++ window.removeEventListener('keypress', handleMods) + } + } +- var x = a + b +- var bv = x - a +- var y = b - bv +- var q0 = y +- var q1 = x +- var _x, _bv, _av, _br, _ar +- while(eptr < ne && fptr < nf) { +- if(ea < fa) { +- a = ei +- eptr += 1 +- if(eptr < ne) { +- ei = e[eptr] +- ea = abs(ei) ++ ++ //Attach listeners ++ attachListeners() ++ ++ var result = { ++ element: element ++ } ++ ++ Object.defineProperties(result, { ++ enabled: { ++ get: function() { return attached }, ++ set: function(f) { ++ if(f) { ++ attachListeners() ++ } else { ++ detachListeners ++ } ++ }, ++ enumerable: true ++ }, ++ buttons: { ++ get: function() { return buttonState }, ++ enumerable: true ++ }, ++ x: { ++ get: function() { return x }, ++ enumerable: true ++ }, ++ y: { ++ get: function() { return y }, ++ enumerable: true ++ }, ++ mods: { ++ get: function() { return mods }, ++ enumerable: true ++ } ++ }) ++ ++ return result ++} ++ ++},{"mouse-event":119}],119:[function(require,module,exports){ ++'use strict' ++ ++function mouseButtons(ev) { ++ if(typeof ev === 'object') { ++ if('buttons' in ev) { ++ return ev.buttons ++ } else if('which' in ev) { ++ var b = ev.which ++ if(b === 2) { ++ return 4 ++ } else if(b === 3) { ++ return 2 ++ } else if(b > 0) { ++ return 1<<(b-1) + } +- } else { +- a = fi +- fptr += 1 +- if(fptr < nf) { +- fi = f[fptr] +- fa = abs(fi) ++ } else if('button' in ev) { ++ var b = ev.button ++ if(b === 1) { ++ return 4 ++ } else if(b === 2) { ++ return 2 ++ } else if(b >= 0) { ++ return 1<0){", +- index(order[i]), "=1;") +- createLoop(i-1, mask|(1<0){", ++ index(order[i]), "=1;") ++ createLoop(i-1, mask|(1< 0") ++ } ++ if(typeof args.vertex !== "function") { ++ error("Must specify vertex creation function") ++ } ++ if(typeof args.cell !== "function") { ++ error("Must specify cell creation function") ++ } ++ if(typeof args.phase !== "function") { ++ error("Must specify phase function") ++ } ++ var getters = args.getters || [] ++ var typesig = new Array(arrays) ++ for(var i=0; i= 0) { ++ typesig[i] = true ++ } else { ++ typesig[i] = false ++ } ++ } ++ return compileSurfaceProcedure( ++ args.vertex, ++ args.cell, ++ args.phase, ++ scalars, ++ order, ++ typesig) ++} ++},{"typedarray-pool":162}],122:[function(require,module,exports){ ++"use strict" ++ ++var compile = require("cwise-compiler") ++ ++var EmptyProc = { ++ body: "", ++ args: [], ++ thisVars: [], ++ localVars: [] ++} ++ ++function fixup(x) { ++ if(!x) { ++ return EmptyProc ++ } ++ for(var i=0; i>", ++ rrshift: ">>>" ++} ++;(function(){ ++ for(var id in assign_ops) { ++ var op = assign_ops[id] ++ exports[id] = makeOp({ ++ args: ["array","array","array"], ++ body: {args:["a","b","c"], ++ body: "a=b"+op+"c"}, ++ funcName: id ++ }) ++ exports[id+"eq"] = makeOp({ ++ args: ["array","array"], ++ body: {args:["a","b"], ++ body:"a"+op+"=b"}, ++ rvalue: true, ++ funcName: id+"eq" ++ }) ++ exports[id+"s"] = makeOp({ ++ args: ["array", "array", "scalar"], ++ body: {args:["a","b","s"], ++ body:"a=b"+op+"s"}, ++ funcName: id+"s" ++ }) ++ exports[id+"seq"] = makeOp({ ++ args: ["array","scalar"], ++ body: {args:["a","s"], ++ body:"a"+op+"=s"}, ++ rvalue: true, ++ funcName: id+"seq" ++ }) ++ } ++})(); ++ ++var unary_ops = { ++ not: "!", ++ bnot: "~", ++ neg: "-", ++ recip: "1.0/" ++} ++;(function(){ ++ for(var id in unary_ops) { ++ var op = unary_ops[id] ++ exports[id] = makeOp({ ++ args: ["array", "array"], ++ body: {args:["a","b"], ++ body:"a="+op+"b"}, ++ funcName: id ++ }) ++ exports[id+"eq"] = makeOp({ ++ args: ["array"], ++ body: {args:["a"], ++ body:"a="+op+"a"}, ++ rvalue: true, ++ count: 2, ++ funcName: id+"eq" ++ }) ++ } ++})(); ++ ++var binary_ops = { ++ and: "&&", ++ or: "||", ++ eq: "===", ++ neq: "!==", ++ lt: "<", ++ gt: ">", ++ leq: "<=", ++ geq: ">=" ++} ++;(function() { ++ for(var id in binary_ops) { ++ var op = binary_ops[id] ++ exports[id] = makeOp({ ++ args: ["array","array","array"], ++ body: {args:["a", "b", "c"], ++ body:"a=b"+op+"c"}, ++ funcName: id ++ }) ++ exports[id+"s"] = makeOp({ ++ args: ["array","array","scalar"], ++ body: {args:["a", "b", "s"], ++ body:"a=b"+op+"s"}, ++ funcName: id+"s" ++ }) ++ exports[id+"eq"] = makeOp({ ++ args: ["array", "array"], ++ body: {args:["a", "b"], ++ body:"a=a"+op+"b"}, ++ rvalue:true, ++ count:2, ++ funcName: id+"eq" ++ }) ++ exports[id+"seq"] = makeOp({ ++ args: ["array", "scalar"], ++ body: {args:["a","s"], ++ body:"a=a"+op+"s"}, ++ rvalue:true, ++ count:2, ++ funcName: id+"seq" ++ }) ++ } ++})(); ++ ++var math_unary = [ ++ "abs", ++ "acos", ++ "asin", ++ "atan", ++ "ceil", ++ "cos", ++ "exp", ++ "floor", ++ "log", ++ "round", ++ "sin", ++ "sqrt", ++ "tan" ++] ++;(function() { ++ for(var i=0; ithis_s){this_s=-a}else if(a>this_s){this_s=a}", localVars: [], thisVars: ["this_s"]}, ++ post: {args:[], localVars:[], thisVars:["this_s"], body:"return this_s"}, ++ funcName: "norminf" ++}) ++ ++exports.norm1 = compile({ ++ args:["array"], ++ pre: {args:[], localVars:[], thisVars:["this_s"], body:"this_s=0"}, ++ body: {args:[{name:"a", lvalue:false, rvalue:true, count:3}], body: "this_s+=a<0?-a:a", localVars: [], thisVars: ["this_s"]}, ++ post: {args:[], localVars:[], thisVars:["this_s"], body:"return this_s"}, ++ funcName: "norm1" ++}) ++ ++exports.sup = compile({ ++ args: [ "array" ], ++ pre: ++ { body: "this_h=-Infinity", ++ args: [], ++ thisVars: [ "this_h" ], ++ localVars: [] }, ++ body: ++ { body: "if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_", ++ args: [{"name":"_inline_1_arg0_","lvalue":false,"rvalue":true,"count":2} ], ++ thisVars: [ "this_h" ], ++ localVars: [] }, ++ post: ++ { body: "return this_h", ++ args: [], ++ thisVars: [ "this_h" ], ++ localVars: [] } ++ }) ++ ++exports.inf = compile({ ++ args: [ "array" ], ++ pre: ++ { body: "this_h=Infinity", ++ args: [], ++ thisVars: [ "this_h" ], ++ localVars: [] }, ++ body: ++ { body: "if(_inline_1_arg0_this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}", ++ args:[ ++ {name:"_inline_1_arg0_",lvalue:false,rvalue:true,count:2}, ++ {name:"_inline_1_arg1_",lvalue:false,rvalue:true,count:2}], ++ thisVars:["this_i","this_v"], ++ localVars:["_inline_1_k"]}, ++ post:{ ++ body:"{return this_i}", ++ args:[], ++ thisVars:["this_i"], ++ localVars:[]} ++}) + +- for(var j=0; j 0") +- } +- if(typeof args.vertex !== "function") { +- error("Must specify vertex creation function") +- } +- if(typeof args.cell !== "function") { +- error("Must specify cell creation function") +- } +- if(typeof args.phase !== "function") { +- error("Must specify phase function") +- } +- var getters = args.getters || [] +- var typesig = new Array(arrays) +- for(var i=0; i= 0) { +- typesig[i] = true +- } else { +- typesig[i] = false +- } +- } +- return compileSurfaceProcedure( +- args.vertex, +- args.cell, +- args.phase, +- scalars, +- order, +- typesig) +-} +-},{"typedarray-pool":151}],139:[function(require,module,exports){ +-// transliterated from the python snippet here: +-// http://en.wikipedia.org/wiki/Lanczos_approximation + +-var g = 7; +-var p = [ +- 0.99999999999980993, +- 676.5203681218851, +- -1259.1392167224028, +- 771.32342877765313, +- -176.61502916214059, +- 12.507343278686905, +- -0.13857109526572012, +- 9.9843695780195716e-6, +- 1.5056327351493116e-7 +-]; + +-var g_ln = 607/128; +-var p_ln = [ +- 0.99999999999999709182, +- 57.156235665862923517, +- -59.597960355475491248, +- 14.136097974741747174, +- -0.49191381609762019978, +- 0.33994649984811888699e-4, +- 0.46523628927048575665e-4, +- -0.98374475304879564677e-4, +- 0.15808870322491248884e-3, +- -0.21026444172410488319e-3, +- 0.21743961811521264320e-3, +- -0.16431810653676389022e-3, +- 0.84418223983852743293e-4, +- -0.26190838401581408670e-4, +- 0.36899182659531622704e-5 +-]; ++},{"cwise-compiler":50}],123:[function(require,module,exports){ ++var iota = require("iota-array") ++var isBuffer = require("is-buffer") + +-// Spouge approximation (suitable for large arguments) +-function lngamma(z) { ++var hasTypedArrays = ((typeof Float64Array) !== "undefined") + +- if(z < 0) return Number('0/0'); +- var x = p_ln[0]; +- for(var i = p_ln.length - 1; i > 0; --i) x += p_ln[i] / (z + i); +- var t = z + g_ln + 0.5; +- return .5*Math.log(2*Math.PI)+(z+.5)*Math.log(t)-t+Math.log(x)-Math.log(z); ++function compare1st(a, b) { ++ return a[0] - b[0] + } + +-module.exports = function gamma (z) { +- if (z < 0.5) { +- return Math.PI / (Math.sin(Math.PI * z) * gamma(1 - z)); +- } +- else if(z > 100) return Math.exp(lngamma(z)); +- else { +- z -= 1; +- var x = p[0]; +- for (var i = 1; i < g + 2; i++) { +- x += p[i] / (z + i); +- } +- var t = z + g + 0.5; +- +- return Math.sqrt(2 * Math.PI) +- * Math.pow(t, z + 0.5) +- * Math.exp(-t) +- * x +- ; +- } +-}; ++function order() { ++ var stride = this.stride ++ var terms = new Array(stride.length) ++ var i ++ for(i=0; iMath.abs(this.stride[1]))?[1,0]:[0,1]}})") ++ } else if(dimension === 3) { ++ code.push( ++"var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);\ ++if(s0>s1){\ ++if(s1>s2){\ ++return [2,1,0];\ ++}else if(s0>s2){\ ++return [1,2,0];\ ++}else{\ ++return [1,0,2];\ ++}\ ++}else if(s0>s2){\ ++return [2,0,1];\ ++}else if(s2>s1){\ ++return [0,1,2];\ ++}else{\ ++return [0,2,1];\ ++}}})") + } ++ } else { ++ code.push("ORDER})") + } +- pool.freeUint8(visited) +- return sgn + } +-} +-},{"typedarray-pool":151}],141:[function(require,module,exports){ +-"use strict" +- +-var pool = require("typedarray-pool") +-var inverse = require("invert-permutation") + +-function rank(permutation) { +- var n = permutation.length +- switch(n) { +- case 0: +- case 1: +- return 0 +- case 2: +- return permutation[1] +- default: +- break +- } +- var p = pool.mallocUint32(n) +- var pinv = pool.mallocUint32(n) +- var r = 0, s, t, i +- inverse(permutation, pinv) +- for(i=0; i0; --i) { +- t = pinv[i] +- s = p[i] +- p[i] = p[t] +- p[t] = s +- pinv[i] = pinv[s] +- pinv[s] = t +- r = (r + s) * i ++ //view.set(i0, ..., v): ++ code.push( ++"proto.set=function "+className+"_set("+args.join(",")+",v){") ++ if(useGetters) { ++ code.push("return this.data.set("+index_str+",v)}") ++ } else { ++ code.push("return this.data["+index_str+"]=v}") + } +- pool.freeUint32(pinv) +- pool.freeUint32(p) +- return r +-} + +-function unrank(n, r, p) { +- switch(n) { +- case 0: +- if(p) { return p } +- return [] +- case 1: +- if(p) { +- p[0] = 0 +- return p +- } else { +- return [0] +- } +- case 2: +- if(p) { +- if(r) { +- p[0] = 0 +- p[1] = 1 +- } else { +- p[0] = 1 +- p[1] = 0 +- } +- return p +- } else { +- return r ? [0,1] : [1,0] +- } +- default: +- break +- } +- p = p || new Array(n) +- var s, t, i, nf=1 +- p[0] = 0 +- for(i=1; i0; --i) { +- s = (r / nf)|0 +- r = (r - s * nf)|0 +- nf = (nf / i)|0 +- t = p[i]|0 +- p[i] = p[s]|0 +- p[s] = t|0 ++ //view.get(i0, ...): ++ code.push("proto.get=function "+className+"_get("+args.join(",")+"){") ++ if(useGetters) { ++ code.push("return this.data.get("+index_str+")}") ++ } else { ++ code.push("return this.data["+index_str+"]}") + } +- return p +-} + +-exports.rank = rank +-exports.unrank = unrank ++ //view.index: ++ code.push( ++ "proto.index=function "+className+"_index(", args.join(), "){return "+index_str+"}") ++ ++ //view.hi(): ++ code.push("proto.hi=function "+className+"_hi("+args.join(",")+"){return new "+className+"(this.data,"+ ++ indices.map(function(i) { ++ return ["(typeof i",i,"!=='number'||i",i,"<0)?this.shape[", i, "]:i", i,"|0"].join("") ++ }).join(",")+","+ ++ indices.map(function(i) { ++ return "this.stride["+i + "]" ++ }).join(",")+",this.offset)}") ++ ++ //view.lo(): ++ var a_vars = indices.map(function(i) { return "a"+i+"=this.shape["+i+"]" }) ++ var c_vars = indices.map(function(i) { return "c"+i+"=this.stride["+i+"]" }) ++ code.push("proto.lo=function "+className+"_lo("+args.join(",")+"){var b=this.offset,d=0,"+a_vars.join(",")+","+c_vars.join(",")) ++ for(var i=0; i=0){\ ++d=i"+i+"|0;\ ++b+=c"+i+"*d;\ ++a"+i+"-=d}") ++ } ++ code.push("return new "+className+"(this.data,"+ ++ indices.map(function(i) { ++ return "a"+i ++ }).join(",")+","+ ++ indices.map(function(i) { ++ return "c"+i ++ }).join(",")+",b)}") + +-},{"invert-permutation":142,"typedarray-pool":151}],142:[function(require,module,exports){ +-"use strict" ++ //view.step(): ++ code.push("proto.step=function "+className+"_step("+args.join(",")+"){var "+ ++ indices.map(function(i) { ++ return "a"+i+"=this.shape["+i+"]" ++ }).join(",")+","+ ++ indices.map(function(i) { ++ return "b"+i+"=this.stride["+i+"]" ++ }).join(",")+",c=this.offset,d=0,ceil=Math.ceil") ++ for(var i=0; i=0){c=(c+this.stride["+i+"]*i"+i+")|0}else{a.push(this.shape["+i+"]);b.push(this.stride["+i+"])}") ++ } ++ code.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}") + +-module.exports = triangulateCube ++ //Add return statement ++ code.push("return function construct_"+className+"(data,shape,stride,offset){return new "+className+"(data,"+ ++ indices.map(function(i) { ++ return "shape["+i+"]" ++ }).join(",")+","+ ++ indices.map(function(i) { ++ return "stride["+i+"]" ++ }).join(",")+",offset)}") + +-var perm = require("permutation-rank") +-var sgn = require("permutation-parity") +-var gamma = require("gamma") ++ //Compile procedure ++ var procedure = new Function("CTOR_LIST", "ORDER", code.join("\n")) ++ return procedure(CACHED_CONSTRUCTORS[dtype], order) ++} + +-function triangulateCube(dimension) { +- if(dimension < 0) { +- return [ ] +- } +- if(dimension === 0) { +- return [ [0] ] ++function arrayDType(data) { ++ if(isBuffer(data)) { ++ return "buffer" + } +- var dfactorial = Math.round(gamma(dimension+1))|0 +- var result = [] +- for(var i=0; i= 0) !== (_inline_1_db >= 0)) {\n _inline_1_arg2_.push(_inline_1_arg4_[0] + 0.5 + 0.5 * (_inline_1_da + _inline_1_db) / (_inline_1_da - _inline_1_db))\n }\n }", +- "args": [{ +- "name": "_inline_1_arg0_", +- "lvalue": false, +- "rvalue": true, +- "count": 1 +- }, { +- "name": "_inline_1_arg1_", +- "lvalue": false, +- "rvalue": true, +- "count": 1 +- }, { +- "name": "_inline_1_arg2_", +- "lvalue": false, +- "rvalue": true, +- "count": 1 +- }, { +- "name": "_inline_1_arg3_", +- "lvalue": false, +- "rvalue": true, +- "count": 2 +- }, { +- "name": "_inline_1_arg4_", +- "lvalue": false, +- "rvalue": true, +- "count": 1 +- }], +- "thisVars": [], +- "localVars": ["_inline_1_da", "_inline_1_db"] +- }, +- funcName: 'zeroCrossings' +-}) +- +-},{"cwise-compiler":58}],145:[function(require,module,exports){ +-"use strict" + +-module.exports = findZeroCrossings +- +-var core = require("./lib/zc-core") +- +-function findZeroCrossings(array, level) { +- var cross = [] +- level = +level || 0.0 +- core(array.hi(array.shape[0]-1), cross, level) +- return cross ++var CACHED_CONSTRUCTORS = { ++ "float32":[], ++ "float64":[], ++ "int8":[], ++ "int16":[], ++ "int32":[], ++ "uint8":[], ++ "uint16":[], ++ "uint32":[], ++ "array":[], ++ "uint8_clamped":[], ++ "buffer":[], ++ "generic":[] + } +-},{"./lib/zc-core":144}],146:[function(require,module,exports){ +-"use strict" +- +-module.exports = surfaceNets +- +-var generateContourExtractor = require("ndarray-extract-contour") +-var triangulateCube = require("triangulate-hypercube") +-var zeroCrossings = require("zero-crossings") +- +-function buildSurfaceNets(order, dtype) { +- var dimension = order.length +- var code = ["'use strict';"] +- var funcName = "surfaceNets" + order.join("_") + "d" + dtype + +- //Contour extraction function +- code.push( +- "var contour=genContour({", +- "order:[", order.join(), "],", +- "scalarArguments: 3,", +- "phase:function phaseFunc(p,a,b,c) { return (p > c)|0 },") +- if(dtype === "generic") { +- code.push("getters:[0],") ++;(function() { ++ for(var id in CACHED_CONSTRUCTORS) { ++ CACHED_CONSTRUCTORS[id].push(compileConstructor(id, -1)) + } ++}); + +- //Generate vertex function +- var cubeArgs = [] +- var extraArgs = [] +- for(var i=0; i>>7){") ++ if(shape === undefined) { ++ shape = [ data.length ] + } +- for(var i=0; i<1<<(1< 128) { +- if((i%128)===0) { +- if(extraFuncs.length > 0) { +- currentFunc.push("}}") +- } +- var efName = "vExtra" + extraFuncs.length +- code.push("case ", (i>>>7), ":", efName, "(m&0x7f,", extraArgs.join(), ");break;") +- currentFunc = [ +- "function ", efName, "(m,", extraArgs.join(), "){switch(m){" +- ] +- extraFuncs.push(currentFunc) +- } +- } +- currentFunc.push("case ", (i&0x7f), ":") +- var crossings = new Array(dimension) +- var denoms = new Array(dimension) +- var crossingCount = new Array(dimension) +- var bias = new Array(dimension) +- var totalCrossings = 0 +- for(var j=0; j j) { +- continue +- } +- if(!(i&(1<=0; --i) { ++ stride[i] = sz ++ sz *= shape[i] + } +- var vertexStr = [] +- for(var k=0; k 0) { +- cStr = "+" + crossingCount[k] + "*c" +- } +- var weight = 0.5 * (crossings[k].length / totalCrossings) +- var shift = 0.5 + 0.5 * (bias[k] / totalCrossings) +- vertexStr.push("d" + k + "-" + shift + "-" + weight + "*(" + crossings[k].join("+") + cStr + ")/(" + denoms[k].join("+") + ")") +- ++ } ++ if(offset === undefined) { ++ offset = 0 ++ for(var i=0; i 0) { +- currentFunc.push("}}") + } +- +- //Create face function +- var faceArgs = [] +- for(var i=0; i<(1<<(dimension-1)); ++i) { +- faceArgs.push("v" + i) ++ var dtype = arrayDType(data) ++ var ctor_list = CACHED_CONSTRUCTORS[dtype] ++ while(ctor_list.length <= d+1) { ++ ctor_list.push(compileConstructor(dtype, ctor_list.length-1)) + } +- faceArgs.push("c0", "c1", "p0", "p1", "a", "b", "c") +- code.push("cell:function cellFunc(", faceArgs.join(), "){") ++ var ctor = ctor_list[d+1] ++ return ctor(data, shape, stride, offset) ++} + +- var facets = triangulateCube(dimension-1) +- code.push("if(p0){b.push(", +- facets.map(function(f) { +- return "[" + f.map(function(v) { +- return "v" + v +- }) + "]" +- }).join(), ")}else{b.push(", +- facets.map(function(f) { +- var e = f.slice() +- e.reverse() +- return "[" + e.map(function(v) { +- return "v" + v +- }) + "]" +- }).join(), +- ")}}});function ", funcName, "(array,level){var verts=[],cells=[];contour(array,verts,cells,level);return {positions:verts,cells:cells};} return ", funcName, ";") ++module.exports = wrappedNDArrayCtor + +- for(var i=0; i>>0 + +-var CACHE = {} ++module.exports = nextafter + +-function surfaceNets(array,level) { +- if(array.dimension <= 0) { +- return { positions: [], cells: [] } +- } else if(array.dimension === 1) { +- return mesh1D(array, level) ++function nextafter(x, y) { ++ if(isNaN(x) || isNaN(y)) { ++ return NaN + } +- var typesig = array.order.join() + "-" + array.dtype +- var proc = CACHE[typesig] +- var level = (+level) || 0.0 +- if(!proc) { +- proc = CACHE[typesig] = buildSurfaceNets(array.order, array.dtype) ++ if(x === y) { ++ return x + } +- return proc(array,level) +-} +-},{"ndarray-extract-contour":138,"triangulate-hypercube":143,"zero-crossings":145}],147:[function(require,module,exports){ +-(function (process){ +-'use strict' +- +-module.exports = textGet +- +-var vectorizeText = require('vectorize-text') +- +-var globals = window || process.global || {} +-var __TEXT_CACHE = globals.__TEXT_CACHE || {} +-globals.__TEXT_CACHE = {} +- +-function unwrap(mesh) { +- var cells = mesh.cells +- var positions = mesh.positions +- var data = new Float32Array(cells.length * 6) +- var ptr = 0 +- var shapeX = 0 +- for(var i=0; i0) { +- shapeX += 0.02 +- } +- } +- +- var data = new Float32Array(bufferSize) +- var ptr = 0 +- var xOffset = -0.5 * shapeX +- for(var i=0; i x) === (x > 0)) { ++ if(lo === UINT_MAX) { ++ hi += 1 ++ lo = 0 ++ } else { ++ lo += 1 ++ } ++ } else { ++ if(lo === 0) { ++ lo = UINT_MAX ++ hi -= 1 ++ } else { ++ lo -= 1 ++ } ++ } ++ return doubleBits.pack(lo, hi) ++} ++},{"double-bits":55}],125:[function(require,module,exports){ ++/*! ++ * pad-left ++ * ++ * Copyright (c) 2014-2015, Jon Schlinkert. ++ * Licensed under the MIT license. ++ */ + +- mesh = fontcache[text] = { +- data: data, +- shape: shapeX +- } +- } +- } ++'use strict'; + +- return mesh +-} ++var repeat = require('repeat-string'); + +-}).call(this,require('_process')) +-},{"_process":15,"vectorize-text":153}],148:[function(require,module,exports){ +-// TinyColor v1.3.0 +-// https://github.com/bgrins/TinyColor +-// Brian Grinstead, MIT License ++module.exports = function padLeft(str, num, ch) { ++ ch = typeof ch !== 'undefined' ? (ch + '') : ' '; ++ return repeat(ch, num) + str; ++}; ++},{"repeat-string":138}],126:[function(require,module,exports){ ++module.exports = function parseUnit(str, out) { ++ if (!out) ++ out = [ 0, '' ] + +-(function() { ++ str = String(str) ++ var num = parseFloat(str, 10) ++ out[0] = num ++ out[1] = str.match(/[\d.\-\+]*\s*(.*)/)[1] || '' ++ return out ++} ++},{}],127:[function(require,module,exports){ ++"use strict" + +-var trimLeft = /^\s+/, +- trimRight = /\s+$/, +- tinyCounter = 0, +- math = Math, +- mathRound = math.round, +- mathMin = math.min, +- mathMax = math.max, +- mathRandom = math.random; ++module.exports = permutationSign + +-function tinycolor (color, opts) { ++var BRUTE_FORCE_CUTOFF = 32 + +- color = (color) ? color : ''; +- opts = opts || { }; ++var pool = require("typedarray-pool") + +- // If input is already a tinycolor, return itself +- if (color instanceof tinycolor) { +- return color; ++function permutationSign(p) { ++ var n = p.length ++ if(n < BRUTE_FORCE_CUTOFF) { ++ //Use quadratic algorithm for small n ++ var sgn = 1 ++ for(var i=0; i0; --i) { ++ t = pinv[i] ++ s = p[i] ++ p[i] = p[t] ++ p[t] = s ++ pinv[i] = pinv[s] ++ pinv[s] = t ++ r = (r + s) * i ++ } ++ pool.freeUint32(pinv) ++ pool.freeUint32(p) ++ return r ++} + +- this._ok = rgb.ok; +- this._tc_id = tinyCounter++; ++function unrank(n, r, p) { ++ switch(n) { ++ case 0: ++ if(p) { return p } ++ return [] ++ case 1: ++ if(p) { ++ p[0] = 0 ++ return p ++ } else { ++ return [0] ++ } ++ case 2: ++ if(p) { ++ if(r) { ++ p[0] = 0 ++ p[1] = 1 ++ } else { ++ p[0] = 1 ++ p[1] = 0 ++ } ++ return p ++ } else { ++ return r ? [0,1] : [1,0] ++ } ++ default: ++ break ++ } ++ p = p || new Array(n) ++ var s, t, i, nf=1 ++ p[0] = 0 ++ for(i=1; i0; --i) { ++ s = (r / nf)|0 ++ r = (r - s * nf)|0 ++ nf = (nf / i)|0 ++ t = p[i]|0 ++ p[i] = p[s]|0 ++ p[s] = t|0 ++ } ++ return p + } + +-tinycolor.prototype = { +- isDark: function() { +- return this.getBrightness() < 128; +- }, +- isLight: function() { +- return !this.isDark(); +- }, +- isValid: function() { +- return this._ok; +- }, +- getOriginalInput: function() { +- return this._originalInput; +- }, +- getFormat: function() { +- return this._format; +- }, +- getAlpha: function() { +- return this._a; +- }, +- getBrightness: function() { +- //http://www.w3.org/TR/AERT#color-contrast +- var rgb = this.toRgb(); +- return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000; +- }, +- getLuminance: function() { +- //http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef +- var rgb = this.toRgb(); +- var RsRGB, GsRGB, BsRGB, R, G, B; +- RsRGB = rgb.r/255; +- GsRGB = rgb.g/255; +- BsRGB = rgb.b/255; ++exports.rank = rank ++exports.unrank = unrank + +- if (RsRGB <= 0.03928) {R = RsRGB / 12.92;} else {R = Math.pow(((RsRGB + 0.055) / 1.055), 2.4);} +- if (GsRGB <= 0.03928) {G = GsRGB / 12.92;} else {G = Math.pow(((GsRGB + 0.055) / 1.055), 2.4);} +- if (BsRGB <= 0.03928) {B = BsRGB / 12.92;} else {B = Math.pow(((BsRGB + 0.055) / 1.055), 2.4);} +- return (0.2126 * R) + (0.7152 * G) + (0.0722 * B); +- }, +- setAlpha: function(value) { +- this._a = boundAlpha(value); +- this._roundA = mathRound(100*this._a) / 100; +- return this; +- }, +- toHsv: function() { +- var hsv = rgbToHsv(this._r, this._g, this._b); +- return { h: hsv.h * 360, s: hsv.s, v: hsv.v, a: this._a }; +- }, +- toHsvString: function() { +- var hsv = rgbToHsv(this._r, this._g, this._b); +- var h = mathRound(hsv.h * 360), s = mathRound(hsv.s * 100), v = mathRound(hsv.v * 100); +- return (this._a == 1) ? +- "hsv(" + h + ", " + s + "%, " + v + "%)" : +- "hsva(" + h + ", " + s + "%, " + v + "%, "+ this._roundA + ")"; +- }, +- toHsl: function() { +- var hsl = rgbToHsl(this._r, this._g, this._b); +- return { h: hsl.h * 360, s: hsl.s, l: hsl.l, a: this._a }; +- }, +- toHslString: function() { +- var hsl = rgbToHsl(this._r, this._g, this._b); +- var h = mathRound(hsl.h * 360), s = mathRound(hsl.s * 100), l = mathRound(hsl.l * 100); +- return (this._a == 1) ? +- "hsl(" + h + ", " + s + "%, " + l + "%)" : +- "hsla(" + h + ", " + s + "%, " + l + "%, "+ this._roundA + ")"; +- }, +- toHex: function(allow3Char) { +- return rgbToHex(this._r, this._g, this._b, allow3Char); +- }, +- toHexString: function(allow3Char) { +- return '#' + this.toHex(allow3Char); +- }, +- toHex8: function() { +- return rgbaToHex(this._r, this._g, this._b, this._a); +- }, +- toHex8String: function() { +- return '#' + this.toHex8(); +- }, +- toRgb: function() { +- return { r: mathRound(this._r), g: mathRound(this._g), b: mathRound(this._b), a: this._a }; +- }, +- toRgbString: function() { +- return (this._a == 1) ? +- "rgb(" + mathRound(this._r) + ", " + mathRound(this._g) + ", " + mathRound(this._b) + ")" : +- "rgba(" + mathRound(this._r) + ", " + mathRound(this._g) + ", " + mathRound(this._b) + ", " + this._roundA + ")"; +- }, +- toPercentageRgb: function() { +- return { r: mathRound(bound01(this._r, 255) * 100) + "%", g: mathRound(bound01(this._g, 255) * 100) + "%", b: mathRound(bound01(this._b, 255) * 100) + "%", a: this._a }; +- }, +- toPercentageRgbString: function() { +- return (this._a == 1) ? +- "rgb(" + mathRound(bound01(this._r, 255) * 100) + "%, " + mathRound(bound01(this._g, 255) * 100) + "%, " + mathRound(bound01(this._b, 255) * 100) + "%)" : +- "rgba(" + mathRound(bound01(this._r, 255) * 100) + "%, " + mathRound(bound01(this._g, 255) * 100) + "%, " + mathRound(bound01(this._b, 255) * 100) + "%, " + this._roundA + ")"; +- }, +- toName: function() { +- if (this._a === 0) { +- return "transparent"; +- } ++},{"invert-permutation":115,"typedarray-pool":162}],129:[function(require,module,exports){ ++"use strict" + +- if (this._a < 1) { +- return false; +- } ++module.exports = planarDual + +- return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false; +- }, +- toFilter: function(secondColor) { +- var hex8String = '#' + rgbaToHex(this._r, this._g, this._b, this._a); +- var secondHex8String = hex8String; +- var gradientType = this._gradientType ? "GradientType = 1, " : ""; ++var compareAngle = require("compare-angle") + +- if (secondColor) { +- var s = tinycolor(secondColor); +- secondHex8String = s.toHex8String(); +- } ++function planarDual(cells, positions) { + +- return "progid:DXImageTransform.Microsoft.gradient("+gradientType+"startColorstr="+hex8String+",endColorstr="+secondHex8String+")"; +- }, +- toString: function(format) { +- var formatSet = !!format; +- format = format || this._format; ++ var numVertices = positions.length|0 ++ var numEdges = cells.length ++ var adj = [new Array(numVertices), new Array(numVertices)] ++ for(var i=0; i= 0; +- var needsAlphaFormat = !formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "name"); ++ var cycles = [] + +- if (needsAlphaFormat) { +- // Special case for "transparent", all other non-alpha formats +- // will return rgba when there is transparency. +- if (format === "name" && this._a === 0) { +- return this.toName(); +- } +- return this.toRgbString(); +- } +- if (format === "rgb") { +- formattedString = this.toRgbString(); +- } +- if (format === "prgb") { +- formattedString = this.toPercentageRgbString(); +- } +- if (format === "hex" || format === "hex6") { +- formattedString = this.toHexString(); +- } +- if (format === "hex3") { +- formattedString = this.toHexString(true); +- } +- if (format === "hex8") { +- formattedString = this.toHex8String(); +- } +- if (format === "name") { +- formattedString = this.toName(); +- } +- if (format === "hsl") { +- formattedString = this.toHslString(); +- } +- if (format === "hsv") { +- formattedString = this.toHsvString(); +- } ++ //Add isolated vertices as trivial case ++ for(var i=0; i 0) { ++ nextCell = adj[i][b][0] ++ nextDir = i ++ break ++ } ++ } ++ nextVertex = nextCell[nextDir^1] + +- _applyCombination: function(fn, args) { +- return fn.apply(null, [this].concat([].slice.call(args))); +- }, +- analogous: function() { +- return this._applyCombination(analogous, arguments); +- }, +- complement: function() { +- return this._applyCombination(complement, arguments); +- }, +- monochromatic: function() { +- return this._applyCombination(monochromatic, arguments); +- }, +- splitcomplement: function() { +- return this._applyCombination(splitcomplement, arguments); +- }, +- triad: function() { +- return this._applyCombination(triad, arguments); +- }, +- tetrad: function() { +- return this._applyCombination(tetrad, arguments); ++ for(var dir=0; dir<2; ++dir) { ++ var nbhd = adj[dir][b] ++ for(var k=0; k 0) { ++ nextCell = e ++ nextVertex = p ++ nextDir = dir ++ } ++ } + } +-}; ++ if(noCut) { ++ return nextVertex ++ } ++ if(nextCell) { ++ cut(nextCell, nextDir) ++ } ++ return nextVertex ++ } + +-// If input is an object, force 1 into "1.0" to handle ratios properly +-// String input requires "1.0" as input, so 1 will be treated as 1 +-tinycolor.fromRatio = function(color, opts) { +- if (typeof color == "object") { +- var newColor = {}; +- for (var i in color) { +- if (color.hasOwnProperty(i)) { +- if (i === "a") { +- newColor[i] = color[i]; +- } +- else { +- newColor[i] = convertToPercentage(color[i]); +- } +- } ++ function extractCycle(v, dir) { ++ var e0 = adj[dir][v][0] ++ var cycle = [v] ++ cut(e0, dir) ++ var u = e0[dir^1] ++ var d0 = dir ++ while(true) { ++ while(u !== v) { ++ cycle.push(u) ++ u = next(cycle[cycle.length-2], u, false) ++ } ++ if(adj[0][v].length + adj[1][v].length === 0) { ++ break ++ } ++ var a = cycle[cycle.length-1] ++ var b = v ++ var c = cycle[1] ++ var d = next(a, b, true) ++ if(compareAngle(positions[a], positions[b], positions[c], positions[d]) < 0) { ++ break ++ } ++ cycle.push(v) ++ u = next(a, b) ++ } ++ return cycle ++ } ++ ++ function shouldGlue(pcycle, ncycle) { ++ return (ncycle[1] === ncycle[ncycle.length-1]) ++ } ++ ++ for(var i=0; i 0) { ++ var ni = adj[0][i].length ++ var ncycle = extractCycle(i,j) ++ if(shouldGlue(pcycle, ncycle)) { ++ //Glue together trivial cycles ++ pcycle.push.apply(pcycle, ncycle) ++ } else { ++ if(pcycle.length > 0) { ++ cycles.push(pcycle) ++ } ++ pcycle = ncycle + } +- color = newColor; ++ } ++ if(pcycle.length > 0) { ++ cycles.push(pcycle) ++ } + } ++ } + +- return tinycolor(color, opts); +-}; ++ //Combine paths and loops together ++ return cycles ++} ++},{"compare-angle":48}],130:[function(require,module,exports){ ++'use strict' + +-// Given a string or object, convert that input to RGB +-// Possible string inputs: +-// +-// "red" +-// "#f00" or "f00" +-// "#ff0000" or "ff0000" +-// "#ff000000" or "ff000000" +-// "rgb 255 0 0" or "rgb (255, 0, 0)" +-// "rgb 1.0 0 0" or "rgb (1, 0, 0)" +-// "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1" +-// "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1" +-// "hsl(0, 100%, 50%)" or "hsl 0 100% 50%" +-// "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1" +-// "hsv(0, 100%, 100%)" or "hsv 0 100% 100%" +-// +-function inputToRGB(color) { ++module.exports = trimLeaves + +- var rgb = { r: 0, g: 0, b: 0 }; +- var a = 1; +- var ok = false; +- var format = false; ++var e2a = require('edges-to-adjacency-list') + +- if (typeof color == "string") { +- color = stringInputToObject(color); +- } ++function trimLeaves(edges, positions) { ++ var adj = e2a(edges, positions.length) ++ var live = new Array(positions.length) ++ var nbhd = new Array(positions.length) + +- if (typeof color == "object") { +- if (color.hasOwnProperty("r") && color.hasOwnProperty("g") && color.hasOwnProperty("b")) { +- rgb = rgbToRgb(color.r, color.g, color.b); +- ok = true; +- format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb"; +- } +- else if (color.hasOwnProperty("h") && color.hasOwnProperty("s") && color.hasOwnProperty("v")) { +- color.s = convertToPercentage(color.s); +- color.v = convertToPercentage(color.v); +- rgb = hsvToRgb(color.h, color.s, color.v); +- ok = true; +- format = "hsv"; +- } +- else if (color.hasOwnProperty("h") && color.hasOwnProperty("s") && color.hasOwnProperty("l")) { +- color.s = convertToPercentage(color.s); +- color.l = convertToPercentage(color.l); +- rgb = hslToRgb(color.h, color.s, color.l); +- ok = true; +- format = "hsl"; +- } ++ var dead = [] ++ for(var i=0; i 0) { ++ var v = dead.pop() ++ live[v] = false ++ var n = adj[v] ++ for(var i=0; i ++function makeArray(length, fill) { ++ var result = new Array(length) ++ for(var i=0; i +-// *Assumes:* r, g, b in [0, 255] or [0, 1] +-// *Returns:* { r, g, b } in [0, 255] +-function rgbToRgb(r, g, b){ +- return { +- r: bound01(r, 255) * 255, +- g: bound01(g, 255) * 255, +- b: bound01(b, 255) * 255 +- }; ++function makeArrayOfArrays(length) { ++ var result = new Array(length) ++ for(var i=0; i 0.5 ? d / (2 - max - min) : d / (max + min); +- switch(max) { +- case r: h = (g - b) / d + (g < b ? 6 : 0); break; +- case g: h = (b - r) / d + 2; break; +- case b: h = (r - g) / d + 4; break; +- } ++ var numVertices = positions.length ++ var numEdges = edges.length + +- h /= 6; ++ //Calculate adjacency list, check manifold ++ var adj = e2a(edges, positions.length) ++ for(var i=0; i 1) t -= 1; +- if(t < 1/6) return p + (q - p) * 6 * t; +- if(t < 1/2) return q; +- if(t < 2/3) return p + (q - p) * (2/3 - t) * 6; +- return p; ++ //Check orientation of a polygon using exact arithmetic ++ function ccw(c) { ++ var n = c.length ++ var area = [0] ++ for(var j=0; j 0 ++ } + +- if(s === 0) { +- r = g = b = l; // achromatic ++ //Extract all clockwise faces ++ faces = faces.filter(ccw) ++ ++ //Detect which loops are contained in one another to handle parent-of relation ++ var numFaces = faces.length ++ var parent = new Array(numFaces) ++ var containment = new Array(numFaces) ++ for(var i=0; i 0) { ++ var top = toVisit.pop() ++ var nbhd = fadj[top] ++ uniq(nbhd, function(a,b) { ++ return a-b ++ }) ++ var nnbhr = nbhd.length ++ var p = parity[top] ++ var polyline ++ if(p === 0) { ++ var c = faces[top] ++ polyline = [c] + } +- else { +- switch(max) { +- case r: h = (g - b) / d + (g < b ? 6 : 0); break; +- case g: h = (b - r) / d + 2; break; +- case b: h = (r - g) / d + 4; break; ++ for(var i=0; i= 0) { ++ continue ++ } ++ parity[f] = p^1 ++ toVisit.push(f) ++ if(p === 0) { ++ var c = faces[f] ++ if(!sharedBoundary(c)) { ++ c.reverse() ++ polyline.push(c) + } +- h /= 6; ++ } + } +- return { h: h, s: s, v: v }; +-} +- +-// `hsvToRgb` +-// Converts an HSV color value to RGB. +-// *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100] +-// *Returns:* { r, g, b } in the set [0, 255] +- function hsvToRgb(h, s, v) { +- +- h = bound01(h, 360) * 6; +- s = bound01(s, 100); +- v = bound01(v, 100); +- +- var i = math.floor(h), +- f = h - i, +- p = v * (1 - s), +- q = v * (1 - f * s), +- t = v * (1 - (1 - f) * s), +- mod = i % 6, +- r = [v, q, p, p, t, v][mod], +- g = [t, v, v, q, p, p][mod], +- b = [p, p, t, v, v, q][mod]; ++ if(p === 0) { ++ result.push(polyline) ++ } ++ } + +- return { r: r * 255, g: g * 255, b: b * 255 }; ++ return result + } ++},{"./lib/trim-leaves":130,"edges-to-adjacency-list":57,"planar-dual":129,"point-in-big-polygon":132,"robust-sum":145,"two-product":160,"uniq":164}],132:[function(require,module,exports){ ++module.exports = preprocessPolygon + +-// `rgbToHex` +-// Converts an RGB color to hex +-// Assumes r, g, and b are contained in the set [0, 255] +-// Returns a 3 or 6 character hex +-function rgbToHex(r, g, b, allow3Char) { ++var orient = require('robust-orientation')[3] ++var makeSlabs = require('slab-decomposition') ++var makeIntervalTree = require('interval-tree-1d') ++var bsearch = require('binary-search-bounds') + +- var hex = [ +- pad2(mathRound(r).toString(16)), +- pad2(mathRound(g).toString(16)), +- pad2(mathRound(b).toString(16)) +- ]; ++function visitInterval() { ++ return true ++} + +- // Return a 3 character hex if possible +- if (allow3Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1)) { +- return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0); ++function intervalSearch(table) { ++ return function(x, y) { ++ var tree = table[x] ++ if(tree) { ++ return !!tree.queryPoint(y, visitInterval) + } +- +- return hex.join(""); ++ return false ++ } + } + +-// `rgbaToHex` +-// Converts an RGBA color plus alpha transparency to hex +-// Assumes r, g, b and a are contained in the set [0, 255] +-// Returns an 8 character hex +-function rgbaToHex(r, g, b, a) { +- +- var hex = [ +- pad2(convertDecimalToHex(a)), +- pad2(mathRound(r).toString(16)), +- pad2(mathRound(g).toString(16)), +- pad2(mathRound(b).toString(16)) +- ]; +- +- return hex.join(""); ++function buildVerticalIndex(segments) { ++ var table = {} ++ for(var i=0; i +- +-function desaturate(color, amount) { +- amount = (amount === 0) ? 0 : (amount || 10); +- var hsl = tinycolor(color).toHsl(); +- hsl.s -= amount / 100; +- hsl.s = clamp01(hsl.s); +- return tinycolor(hsl); ++function buildSlabSearch(slabs, coordinates) { ++ return function(p) { ++ var bucket = bsearch.le(coordinates, p[0]) ++ if(bucket < 0) { ++ return 1 ++ } ++ var root = slabs[bucket] ++ if(!root) { ++ if(bucket > 0 && coordinates[bucket] === p[0]) { ++ root = slabs[bucket-1] ++ } else { ++ return 1 ++ } ++ } ++ var lastOrientation = 1 ++ while(root) { ++ var s = root.key ++ var o = orient(p, s[0], s[1]) ++ if(s[0][0] < s[1][0]) { ++ if(o < 0) { ++ root = root.left ++ } else if(o > 0) { ++ lastOrientation = -1 ++ root = root.right ++ } else { ++ return 0 ++ } ++ } else { ++ if(o > 0) { ++ root = root.left ++ } else if(o < 0) { ++ lastOrientation = 1 ++ root = root.right ++ } else { ++ return 0 ++ } ++ } ++ } ++ return lastOrientation ++ } + } + +-function saturate(color, amount) { +- amount = (amount === 0) ? 0 : (amount || 10); +- var hsl = tinycolor(color).toHsl(); +- hsl.s += amount / 100; +- hsl.s = clamp01(hsl.s); +- return tinycolor(hsl); ++function classifyEmpty(p) { ++ return 1 + } + +-function greyscale(color) { +- return tinycolor(color).desaturate(100); ++function createClassifyVertical(testVertical) { ++ return function classify(p) { ++ if(testVertical(p[0], p[1])) { ++ return 0 ++ } ++ return 1 ++ } + } + +-function lighten (color, amount) { +- amount = (amount === 0) ? 0 : (amount || 10); +- var hsl = tinycolor(color).toHsl(); +- hsl.l += amount / 100; +- hsl.l = clamp01(hsl.l); +- return tinycolor(hsl); ++function createClassifyPointDegen(testVertical, testNormal) { ++ return function classify(p) { ++ if(testVertical(p[0], p[1])) { ++ return 0 ++ } ++ return testNormal(p) ++ } + } + +-function brighten(color, amount) { +- amount = (amount === 0) ? 0 : (amount || 10); +- var rgb = tinycolor(color).toRgb(); +- rgb.r = mathMax(0, mathMin(255, rgb.r - mathRound(255 * - (amount / 100)))); +- rgb.g = mathMax(0, mathMin(255, rgb.g - mathRound(255 * - (amount / 100)))); +- rgb.b = mathMax(0, mathMin(255, rgb.b - mathRound(255 * - (amount / 100)))); +- return tinycolor(rgb); +-} ++function preprocessPolygon(loops) { ++ //Compute number of loops ++ var numLoops = loops.length + +-function darken (color, amount) { +- amount = (amount === 0) ? 0 : (amount || 10); +- var hsl = tinycolor(color).toHsl(); +- hsl.l -= amount / 100; +- hsl.l = clamp01(hsl.l); +- return tinycolor(hsl); +-} ++ //Unpack segments ++ var segments = [] ++ var vsegments = [] ++ var ptr = 0 ++ for(var i=0; i ++ //Build slab decomposition ++ var slabs = makeSlabs(segments) ++ var testSlab = buildSlabSearch(slabs.slabs, slabs.coordinates) + +-function complement(color) { +- var hsl = tinycolor(color).toHsl(); +- hsl.h = (hsl.h + 180) % 360; +- return tinycolor(hsl); ++ if(vsegments.length === 0) { ++ return testSlab ++ } else { ++ return createClassifyPointDegen( ++ buildVerticalIndex(vsegments), ++ testSlab) ++ } + } ++},{"binary-search-bounds":27,"interval-tree-1d":114,"robust-orientation":140,"slab-decomposition":152}],133:[function(require,module,exports){ ++// shim for using process in browser ++var process = module.exports = {}; + +-function triad(color) { +- var hsl = tinycolor(color).toHsl(); +- var h = hsl.h; +- return [ +- tinycolor(color), +- tinycolor({ h: (h + 120) % 360, s: hsl.s, l: hsl.l }), +- tinycolor({ h: (h + 240) % 360, s: hsl.s, l: hsl.l }) +- ]; +-} ++// cached from whatever global is present so that test runners that stub it ++// don't break things. But we need to wrap it in a try catch in case it is ++// wrapped in strict mode code which doesn't define any globals. It's inside a ++// function because try/catches deoptimize in certain engines. + +-function tetrad(color) { +- var hsl = tinycolor(color).toHsl(); +- var h = hsl.h; +- return [ +- tinycolor(color), +- tinycolor({ h: (h + 90) % 360, s: hsl.s, l: hsl.l }), +- tinycolor({ h: (h + 180) % 360, s: hsl.s, l: hsl.l }), +- tinycolor({ h: (h + 270) % 360, s: hsl.s, l: hsl.l }) +- ]; +-} ++var cachedSetTimeout; ++var cachedClearTimeout; + +-function splitcomplement(color) { +- var hsl = tinycolor(color).toHsl(); +- var h = hsl.h; +- return [ +- tinycolor(color), +- tinycolor({ h: (h + 72) % 360, s: hsl.s, l: hsl.l}), +- tinycolor({ h: (h + 216) % 360, s: hsl.s, l: hsl.l}) +- ]; ++function defaultSetTimout() { ++ throw new Error('setTimeout has not been defined'); + } +- +-function analogous(color, results, slices) { +- results = results || 6; +- slices = slices || 30; +- +- var hsl = tinycolor(color).toHsl(); +- var part = 360 / slices; +- var ret = [tinycolor(color)]; +- +- for (hsl.h = ((hsl.h - (part * results >> 1)) + 720) % 360; --results; ) { +- hsl.h = (hsl.h + part) % 360; +- ret.push(tinycolor(hsl)); +- } +- return ret; ++function defaultClearTimeout () { ++ throw new Error('clearTimeout has not been defined'); + } +- +-function monochromatic(color, results) { +- results = results || 6; +- var hsv = tinycolor(color).toHsv(); +- var h = hsv.h, s = hsv.s, v = hsv.v; +- var ret = []; +- var modification = 1 / results; +- +- while (results--) { +- ret.push(tinycolor({ h: h, s: s, v: v})); +- v = (v + modification) % 1; ++(function () { ++ try { ++ if (typeof setTimeout === 'function') { ++ cachedSetTimeout = setTimeout; ++ } else { ++ cachedSetTimeout = defaultSetTimout; ++ } ++ } catch (e) { ++ cachedSetTimeout = defaultSetTimout; ++ } ++ try { ++ if (typeof clearTimeout === 'function') { ++ cachedClearTimeout = clearTimeout; ++ } else { ++ cachedClearTimeout = defaultClearTimeout; ++ } ++ } catch (e) { ++ cachedClearTimeout = defaultClearTimeout; ++ } ++} ()) ++function runTimeout(fun) { ++ if (cachedSetTimeout === setTimeout) { ++ //normal enviroments in sane situations ++ return setTimeout(fun, 0); ++ } ++ // if setTimeout wasn't available but was latter defined ++ if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { ++ cachedSetTimeout = setTimeout; ++ return setTimeout(fun, 0); ++ } ++ try { ++ // when when somebody has screwed with setTimeout but no I.E. maddness ++ return cachedSetTimeout(fun, 0); ++ } catch(e){ ++ try { ++ // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally ++ return cachedSetTimeout.call(null, fun, 0); ++ } catch(e){ ++ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error ++ return cachedSetTimeout.call(this, fun, 0); ++ } + } + +- return ret; +-} +- +-// Utility Functions +-// --------------------- + +-tinycolor.mix = function(color1, color2, amount) { +- amount = (amount === 0) ? 0 : (amount || 50); ++} ++function runClearTimeout(marker) { ++ if (cachedClearTimeout === clearTimeout) { ++ //normal enviroments in sane situations ++ return clearTimeout(marker); ++ } ++ // if clearTimeout wasn't available but was latter defined ++ if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { ++ cachedClearTimeout = clearTimeout; ++ return clearTimeout(marker); ++ } ++ try { ++ // when when somebody has screwed with setTimeout but no I.E. maddness ++ return cachedClearTimeout(marker); ++ } catch (e){ ++ try { ++ // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally ++ return cachedClearTimeout.call(null, marker); ++ } catch (e){ ++ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. ++ // Some versions of I.E. have different rules for clearTimeout vs setTimeout ++ return cachedClearTimeout.call(this, marker); ++ } ++ } + +- var rgb1 = tinycolor(color1).toRgb(); +- var rgb2 = tinycolor(color2).toRgb(); + +- var p = amount / 100; +- var w = p * 2 - 1; +- var a = rgb2.a - rgb1.a; + +- var w1; ++} ++var queue = []; ++var draining = false; ++var currentQueue; ++var queueIndex = -1; + +- if (w * a == -1) { +- w1 = w; ++function cleanUpNextTick() { ++ if (!draining || !currentQueue) { ++ return; ++ } ++ draining = false; ++ if (currentQueue.length) { ++ queue = currentQueue.concat(queue); + } else { +- w1 = (w + a) / (1 + w * a); ++ queueIndex = -1; ++ } ++ if (queue.length) { ++ drainQueue(); + } ++} + +- w1 = (w1 + 1) / 2; ++function drainQueue() { ++ if (draining) { ++ return; ++ } ++ var timeout = runTimeout(cleanUpNextTick); ++ draining = true; + +- var w2 = 1 - w1; ++ var len = queue.length; ++ while(len) { ++ currentQueue = queue; ++ queue = []; ++ while (++queueIndex < len) { ++ if (currentQueue) { ++ currentQueue[queueIndex].run(); ++ } ++ } ++ queueIndex = -1; ++ len = queue.length; ++ } ++ currentQueue = null; ++ draining = false; ++ runClearTimeout(timeout); ++} + +- var rgba = { +- r: rgb2.r * w1 + rgb1.r * w2, +- g: rgb2.g * w1 + rgb1.g * w2, +- b: rgb2.b * w1 + rgb1.b * w2, +- a: rgb2.a * p + rgb1.a * (1 - p) +- }; ++process.nextTick = function (fun) { ++ var args = new Array(arguments.length - 1); ++ if (arguments.length > 1) { ++ for (var i = 1; i < arguments.length; i++) { ++ args[i - 1] = arguments[i]; ++ } ++ } ++ queue.push(new Item(fun, args)); ++ if (queue.length === 1 && !draining) { ++ runTimeout(drainQueue); ++ } ++}; + +- return tinycolor(rgba); ++// v8 likes predictible objects ++function Item(fun, array) { ++ this.fun = fun; ++ this.array = array; ++} ++Item.prototype.run = function () { ++ this.fun.apply(null, this.array); + }; ++process.title = 'browser'; ++process.browser = true; ++process.env = {}; ++process.argv = []; ++process.version = ''; // empty string to avoid regexp issues ++process.versions = {}; + ++function noop() {} + +-// Readability Functions +-// --------------------- +-// false +-// tinycolor.isReadable("#000", "#111",{level:"AA",size:"large"}) => false +-tinycolor.isReadable = function(color1, color2, wcag2) { +- var readability = tinycolor.readability(color1, color2); +- var wcag2Parms, out; ++process.cwd = function () { return '/' }; ++process.chdir = function (dir) { ++ throw new Error('process.chdir is not supported'); ++}; ++process.umask = function() { return 0; }; + +- out = false; ++},{}],134:[function(require,module,exports){ ++'use strict' + +- wcag2Parms = validateWCAG2Parms(wcag2); +- switch (wcag2Parms.level + wcag2Parms.size) { +- case "AAsmall": +- case "AAAlarge": +- out = readability >= 4.5; +- break; +- case "AAlarge": +- out = readability >= 3; +- break; +- case "AAAsmall": +- out = readability >= 7; +- break; +- } +- return out; ++var bnadd = require('big-rat/add') + +-}; ++module.exports = add + +-// `mostReadable` +-// Given a base color and a list of possible foreground or background +-// colors for that base, returns the most readable color. +-// Optionally returns Black or White if the most readable color is unreadable. +-// *Example* +-// tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:false}).toHexString(); // "#112255" +-// tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:true}).toHexString(); // "#ffffff" +-// tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"large"}).toHexString(); // "#faf3f3" +-// tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"small"}).toHexString(); // "#ffffff" +-tinycolor.mostReadable = function(baseColor, colorList, args) { +- var bestColor = null; +- var bestScore = 0; +- var readability; +- var includeFallbackColors, level, size ; +- args = args || {}; +- includeFallbackColors = args.includeFallbackColors ; +- level = args.level; +- size = args.size; ++function add(a, b) { ++ var n = a.length ++ var r = new Array(n) ++ for(var i=0; i bestScore) { +- bestScore = readability; +- bestColor = tinycolor(colorList[i]); +- } +- } ++},{"big-rat/add":11}],135:[function(require,module,exports){ ++'use strict' + +- if (tinycolor.isReadable(baseColor, bestColor, {"level":level,"size":size}) || !includeFallbackColors) { +- return bestColor; +- } +- else { +- args.includeFallbackColors=false; +- return tinycolor.mostReadable(baseColor,["#fff", "#000"],args); +- } +-}; ++module.exports = float2rat + ++var rat = require('big-rat') + +-// Big List of Colors +-// ------------------ +-// +-var names = tinycolor.names = { +- aliceblue: "f0f8ff", +- antiquewhite: "faebd7", +- aqua: "0ff", +- aquamarine: "7fffd4", +- azure: "f0ffff", +- beige: "f5f5dc", +- bisque: "ffe4c4", +- black: "000", +- blanchedalmond: "ffebcd", +- blue: "00f", +- blueviolet: "8a2be2", +- brown: "a52a2a", +- burlywood: "deb887", +- burntsienna: "ea7e5d", +- cadetblue: "5f9ea0", +- chartreuse: "7fff00", +- chocolate: "d2691e", +- coral: "ff7f50", +- cornflowerblue: "6495ed", +- cornsilk: "fff8dc", +- crimson: "dc143c", +- cyan: "0ff", +- darkblue: "00008b", +- darkcyan: "008b8b", +- darkgoldenrod: "b8860b", +- darkgray: "a9a9a9", +- darkgreen: "006400", +- darkgrey: "a9a9a9", +- darkkhaki: "bdb76b", +- darkmagenta: "8b008b", +- darkolivegreen: "556b2f", +- darkorange: "ff8c00", +- darkorchid: "9932cc", +- darkred: "8b0000", +- darksalmon: "e9967a", +- darkseagreen: "8fbc8f", +- darkslateblue: "483d8b", +- darkslategray: "2f4f4f", +- darkslategrey: "2f4f4f", +- darkturquoise: "00ced1", +- darkviolet: "9400d3", +- deeppink: "ff1493", +- deepskyblue: "00bfff", +- dimgray: "696969", +- dimgrey: "696969", +- dodgerblue: "1e90ff", +- firebrick: "b22222", +- floralwhite: "fffaf0", +- forestgreen: "228b22", +- fuchsia: "f0f", +- gainsboro: "dcdcdc", +- ghostwhite: "f8f8ff", +- gold: "ffd700", +- goldenrod: "daa520", +- gray: "808080", +- green: "008000", +- greenyellow: "adff2f", +- grey: "808080", +- honeydew: "f0fff0", +- hotpink: "ff69b4", +- indianred: "cd5c5c", +- indigo: "4b0082", +- ivory: "fffff0", +- khaki: "f0e68c", +- lavender: "e6e6fa", +- lavenderblush: "fff0f5", +- lawngreen: "7cfc00", +- lemonchiffon: "fffacd", +- lightblue: "add8e6", +- lightcoral: "f08080", +- lightcyan: "e0ffff", +- lightgoldenrodyellow: "fafad2", +- lightgray: "d3d3d3", +- lightgreen: "90ee90", +- lightgrey: "d3d3d3", +- lightpink: "ffb6c1", +- lightsalmon: "ffa07a", +- lightseagreen: "20b2aa", +- lightskyblue: "87cefa", +- lightslategray: "789", +- lightslategrey: "789", +- lightsteelblue: "b0c4de", +- lightyellow: "ffffe0", +- lime: "0f0", +- limegreen: "32cd32", +- linen: "faf0e6", +- magenta: "f0f", +- maroon: "800000", +- mediumaquamarine: "66cdaa", +- mediumblue: "0000cd", +- mediumorchid: "ba55d3", +- mediumpurple: "9370db", +- mediumseagreen: "3cb371", +- mediumslateblue: "7b68ee", +- mediumspringgreen: "00fa9a", +- mediumturquoise: "48d1cc", +- mediumvioletred: "c71585", +- midnightblue: "191970", +- mintcream: "f5fffa", +- mistyrose: "ffe4e1", +- moccasin: "ffe4b5", +- navajowhite: "ffdead", +- navy: "000080", +- oldlace: "fdf5e6", +- olive: "808000", +- olivedrab: "6b8e23", +- orange: "ffa500", +- orangered: "ff4500", +- orchid: "da70d6", +- palegoldenrod: "eee8aa", +- palegreen: "98fb98", +- paleturquoise: "afeeee", +- palevioletred: "db7093", +- papayawhip: "ffefd5", +- peachpuff: "ffdab9", +- peru: "cd853f", +- pink: "ffc0cb", +- plum: "dda0dd", +- powderblue: "b0e0e6", +- purple: "800080", +- rebeccapurple: "663399", +- red: "f00", +- rosybrown: "bc8f8f", +- royalblue: "4169e1", +- saddlebrown: "8b4513", +- salmon: "fa8072", +- sandybrown: "f4a460", +- seagreen: "2e8b57", +- seashell: "fff5ee", +- sienna: "a0522d", +- silver: "c0c0c0", +- skyblue: "87ceeb", +- slateblue: "6a5acd", +- slategray: "708090", +- slategrey: "708090", +- snow: "fffafa", +- springgreen: "00ff7f", +- steelblue: "4682b4", +- tan: "d2b48c", +- teal: "008080", +- thistle: "d8bfd8", +- tomato: "ff6347", +- turquoise: "40e0d0", +- violet: "ee82ee", +- wheat: "f5deb3", +- white: "fff", +- whitesmoke: "f5f5f5", +- yellow: "ff0", +- yellowgreen: "9acd32" +-}; ++function float2rat(v) { ++ var result = new Array(v.length) ++ for(var i=0; i 1) { +- a = 1; +- } ++var bnsub = require('big-rat/sub') + +- return a; ++module.exports = sub ++ ++function sub(a, b) { ++ var n = a.length ++ var r = new Array(n) ++ for(var i=0; i ++ * ++ * Copyright (c) 2014-2015, Jon Schlinkert. ++ * Licensed under the MIT License. ++ */ + +- var processPercent = isPercentage(n); +- n = mathMin(max, mathMax(0, parseFloat(n))); ++'use strict'; + +- // Automatically convert percentage into number +- if (processPercent) { +- n = parseInt(n * max, 10) / 100; +- } ++/** ++ * Results cache ++ */ + +- // Handle floating point rounding errors +- if ((math.abs(n - max) < 0.000001)) { +- return 1; ++var res = ''; ++var cache; ++ ++/** ++ * Expose `repeat` ++ */ ++ ++module.exports = repeat; ++ ++/** ++ * Repeat the given `string` the specified `number` ++ * of times. ++ * ++ * **Example:** ++ * ++ * ```js ++ * var repeat = require('repeat-string'); ++ * repeat('A', 5); ++ * //=> AAAAA ++ * ``` ++ * ++ * @param {String} `string` The string to repeat ++ * @param {Number} `number` The number of times to repeat the string ++ * @return {String} Repeated string ++ * @api public ++ */ ++ ++function repeat(str, num) { ++ if (typeof str !== 'string') { ++ throw new TypeError('repeat-string expects a string.'); ++ } ++ ++ // cover common, quick use cases ++ if (num === 1) return str; ++ if (num === 2) return str + str; ++ ++ var max = str.length * num; ++ if (cache !== str || typeof cache === 'undefined') { ++ cache = str; ++ res = ''; ++ } ++ ++ while (max > res.length && num > 0) { ++ if (num & 1) { ++ res += str; + } + +- // Convert into [0, 1] range if it isn't already +- return (n % max) / parseFloat(max); ++ num >>= 1; ++ if (!num) break; ++ str += str; ++ } ++ ++ return res.substr(0, max); + } + +-// Force a number between 0 and 1 +-function clamp01(val) { +- return mathMin(1, mathMax(0, val)); ++ ++},{}],139:[function(require,module,exports){ ++"use strict" ++ ++var twoProduct = require("two-product") ++var robustSum = require("robust-sum") ++var robustDiff = require("robust-subtract") ++var robustScale = require("robust-scale") ++ ++var NUM_EXPAND = 6 ++ ++function cofactor(m, c) { ++ var result = new Array(m.length-1) ++ for(var i=1; i +-function isOnePointZero(n) { +- return typeof n == "string" && n.indexOf('.') != -1 && parseFloat(n) === 1; ++function generateSum(expr) { ++ if(expr.length === 1) { ++ return expr[0] ++ } else if(expr.length === 2) { ++ return ["sum(", expr[0], ",", expr[1], ")"].join("") ++ } else { ++ var m = expr.length>>1 ++ return ["sum(", generateSum(expr.slice(0, m)), ",", generateSum(expr.slice(m)), ")"].join("") ++ } + } + +-// Check to see if string passed in is a percentage +-function isPercentage(n) { +- return typeof n === "string" && n.indexOf('%') != -1; ++function makeProduct(a, b) { ++ if(a.charAt(0) === "m") { ++ if(b.charAt(0) === "w") { ++ var toks = a.split("[") ++ return ["w", b.substr(1), "m", toks[0].substr(1)].join("") ++ } else { ++ return ["prod(", a, ",", b, ")"].join("") ++ } ++ } else { ++ return makeProduct(b, a) ++ } + } + +-// Force a hex value to have 2 characters +-function pad2(c) { +- return c.length == 1 ? '0' + c : '' + c; ++function sign(s) { ++ if(s & 1 !== 0) { ++ return "-" ++ } ++ return "" + } + +-// Replace a decimal with it's percentage value +-function convertToPercentage(n) { +- if (n <= 1) { +- n = (n * 100) + "%"; ++function determinant(m) { ++ if(m.length === 2) { ++ return [["diff(", makeProduct(m[0][0], m[1][1]), ",", makeProduct(m[1][0], m[0][1]), ")"].join("")] ++ } else { ++ var expr = [] ++ for(var i=0; i +- var CSS_INTEGER = "[-\\+]?\\d+%?"; ++ var proc = Function.apply(undefined, procArgs) + +- // +- var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?"; ++ module.exports = proc.apply(undefined, [slowInSphere].concat(CACHED)) ++ for(var i=0; i<=NUM_EXPAND; ++i) { ++ module.exports[i] = CACHED[i] ++ } ++} + +- // Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome. +- var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")"; ++generateInSphereTest() ++},{"robust-scale":142,"robust-subtract":144,"robust-sum":145,"two-product":160}],140:[function(require,module,exports){ ++"use strict" + +- // Actual matching. +- // Parentheses and commas are optional, but not required. +- // Whitespace can take the place of commas or opening paren +- var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?"; +- var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?"; ++var twoProduct = require("two-product") ++var robustSum = require("robust-sum") ++var robustScale = require("robust-scale") ++var robustSubtract = require("robust-subtract") + +- return { +- rgb: new RegExp("rgb" + PERMISSIVE_MATCH3), +- rgba: new RegExp("rgba" + PERMISSIVE_MATCH4), +- hsl: new RegExp("hsl" + PERMISSIVE_MATCH3), +- hsla: new RegExp("hsla" + PERMISSIVE_MATCH4), +- hsv: new RegExp("hsv" + PERMISSIVE_MATCH3), +- hsva: new RegExp("hsva" + PERMISSIVE_MATCH4), +- hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/, +- hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/, +- hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/ +- }; +-})(); ++var NUM_EXPAND = 5 + +-// `stringInputToObject` +-// Permissive string parsing. Take in a number of formats, and output an object +-// based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}` +-function stringInputToObject(color) { ++var EPSILON = 1.1102230246251565e-16 ++var ERRBOUND3 = (3.0 + 16.0 * EPSILON) * EPSILON ++var ERRBOUND4 = (7.0 + 56.0 * EPSILON) * EPSILON + +- color = color.replace(trimLeft,'').replace(trimRight, '').toLowerCase(); +- var named = false; +- if (names[color]) { +- color = names[color]; +- named = true; +- } +- else if (color == 'transparent') { +- return { r: 0, g: 0, b: 0, a: 0, format: "name" }; ++function cofactor(m, c) { ++ var result = new Array(m.length-1) ++ for(var i=1; i>1 ++ return ["sum(", generateSum(expr.slice(0, m)), ",", generateSum(expr.slice(m)), ")"].join("") ++ } ++} ++ ++function determinant(m) { ++ if(m.length === 2) { ++ return [["sum(prod(", m[0][0], ",", m[1][1], "),prod(-", m[0][1], ",", m[1][0], "))"].join("")] ++ } else { ++ var expr = [] ++ for(var i=0; i 0) { ++ if(r <= 0) { ++ return det ++ } else { ++ s = l + r ++ } ++ } else if(l < 0) { ++ if(r >= 0) { ++ return det ++ } else { ++ s = -(l + r) ++ } ++ } else { ++ return det + } +- if ((match = matchers.hex6.exec(color))) { +- return { +- r: parseIntFromHex(match[1]), +- g: parseIntFromHex(match[2]), +- b: parseIntFromHex(match[3]), +- format: named ? "name" : "hex" +- }; ++ var tol = ERRBOUND3 * s ++ if(det >= tol || det <= -tol) { ++ return det + } +- if ((match = matchers.hex3.exec(color))) { +- return { +- r: parseIntFromHex(match[1] + '' + match[1]), +- g: parseIntFromHex(match[2] + '' + match[2]), +- b: parseIntFromHex(match[3] + '' + match[3]), +- format: named ? "name" : "hex" +- }; ++ return orientation3Exact(a, b, c) ++ }, ++ function orientation4(a,b,c,d) { ++ var adx = a[0] - d[0] ++ var bdx = b[0] - d[0] ++ var cdx = c[0] - d[0] ++ var ady = a[1] - d[1] ++ var bdy = b[1] - d[1] ++ var cdy = c[1] - d[1] ++ var adz = a[2] - d[2] ++ var bdz = b[2] - d[2] ++ var cdz = c[2] - d[2] ++ var bdxcdy = bdx * cdy ++ var cdxbdy = cdx * bdy ++ var cdxady = cdx * ady ++ var adxcdy = adx * cdy ++ var adxbdy = adx * bdy ++ var bdxady = bdx * ady ++ var det = adz * (bdxcdy - cdxbdy) ++ + bdz * (cdxady - adxcdy) ++ + cdz * (adxbdy - bdxady) ++ var permanent = (Math.abs(bdxcdy) + Math.abs(cdxbdy)) * Math.abs(adz) ++ + (Math.abs(cdxady) + Math.abs(adxcdy)) * Math.abs(bdz) ++ + (Math.abs(adxbdy) + Math.abs(bdxady)) * Math.abs(cdz) ++ var tol = ERRBOUND4 * permanent ++ if ((det > tol) || (-det > tol)) { ++ return det + } ++ return orientation4Exact(a,b,c,d) ++ } ++] + +- return false; ++function slowOrient(args) { ++ var proc = CACHED[args.length] ++ if(!proc) { ++ proc = CACHED[args.length] = orientation(args.length) ++ } ++ return proc.apply(undefined, args) + } + +-function validateWCAG2Parms(parms) { +- // return valid WCAG2 parms for isReadable. +- // If input parms are invalid, return {"level":"AA", "size":"small"} +- var level, size; +- parms = parms || {"level":"AA", "size":"small"}; +- level = (parms.level || "AA").toUpperCase(); +- size = (parms.size || "small").toLowerCase(); +- if (level !== "AA" && level !== "AAA") { +- level = "AA"; +- } +- if (size !== "small" && size !== "large") { +- size = "small"; +- } +- return {"level":level, "size":size}; +-} ++function generateOrientationProc() { ++ while(CACHED.length <= NUM_EXPAND) { ++ CACHED.push(orientation(CACHED.length)) ++ } ++ var args = [] ++ var procArgs = ["slow"] ++ for(var i=0; i<=NUM_EXPAND; ++i) { ++ args.push("a" + i) ++ procArgs.push("o" + i) ++ } ++ var code = [ ++ "function getOrientation(", args.join(), "){switch(arguments.length){case 0:case 1:return 0;" ++ ] ++ for(var i=2; i<=NUM_EXPAND; ++i) { ++ code.push("case ", i, ":return o", i, "(", args.slice(0, i).join(), ");") ++ } ++ code.push("}var s=new Array(arguments.length);for(var i=0;i 0) { +- return d.pop() +- } +- return new ArrayBuffer(n) +-} +-exports.mallocArrayBuffer = mallocArrayBuffer +- +-function mallocUint8(n) { +- return new Uint8Array(mallocArrayBuffer(n), 0, n) +-} +-exports.mallocUint8 = mallocUint8 + +-function mallocUint16(n) { +- return new Uint16Array(mallocArrayBuffer(2*n), 0, n) +-} +-exports.mallocUint16 = mallocUint16 +- +-function mallocUint32(n) { +- return new Uint32Array(mallocArrayBuffer(4*n), 0, n) ++ return true + } +-exports.mallocUint32 = mallocUint32 + +-function mallocInt8(n) { +- return new Int8Array(mallocArrayBuffer(n), 0, n) +-} +-exports.mallocInt8 = mallocInt8 ++function segmentsIntersect(a0, a1, b0, b1) { ++ var x0 = orient(a0, b0, b1) ++ var y0 = orient(a1, b0, b1) ++ if((x0 > 0 && y0 > 0) || (x0 < 0 && y0 < 0)) { ++ return false ++ } + +-function mallocInt16(n) { +- return new Int16Array(mallocArrayBuffer(2*n), 0, n) +-} +-exports.mallocInt16 = mallocInt16 ++ var x1 = orient(b0, a0, a1) ++ var y1 = orient(b1, a0, a1) ++ if((x1 > 0 && y1 > 0) || (x1 < 0 && y1 < 0)) { ++ return false ++ } + +-function mallocInt32(n) { +- return new Int32Array(mallocArrayBuffer(4*n), 0, n) +-} +-exports.mallocInt32 = mallocInt32 ++ //Check for degenerate collinear case ++ if(x0 === 0 && y0 === 0 && x1 === 0 && y1 === 0) { ++ return checkCollinear(a0, a1, b0, b1) ++ } + +-function mallocFloat(n) { +- return new Float32Array(mallocArrayBuffer(4*n), 0, n) ++ return true + } +-exports.mallocFloat32 = exports.mallocFloat = mallocFloat ++},{"robust-orientation":140}],144:[function(require,module,exports){ ++"use strict" + +-function mallocDouble(n) { +- return new Float64Array(mallocArrayBuffer(8*n), 0, n) +-} +-exports.mallocFloat64 = exports.mallocDouble = mallocDouble ++module.exports = robustSubtract + +-function mallocUint8Clamped(n) { +- if(hasUint8C) { +- return new Uint8ClampedArray(mallocArrayBuffer(n), 0, n) +- } else { +- return mallocUint8(n) ++//Easy case: Add two scalars ++function scalarScalar(a, b) { ++ var x = a + b ++ var bv = x - a ++ var av = x - bv ++ var br = b - bv ++ var ar = a - av ++ var y = ar + br ++ if(y) { ++ return [y, x] + } ++ return [x] + } +-exports.mallocUint8Clamped = mallocUint8Clamped +- +-function mallocDataView(n) { +- return new DataView(mallocArrayBuffer(n), 0, n) +-} +-exports.mallocDataView = mallocDataView + +-function mallocBuffer(n) { +- n = bits.nextPow2(n) +- var log_n = bits.log2(n) +- var cache = BUFFER[log_n] +- if(cache.length > 0) { +- return cache.pop() ++function robustSubtract(e, f) { ++ var ne = e.length|0 ++ var nf = f.length|0 ++ if(ne === 1 && nf === 1) { ++ return scalarScalar(e[0], -f[0]) + } +- return new Buffer(n) +-} +-exports.mallocBuffer = mallocBuffer +- +-exports.clearCache = function clearCache() { +- for(var i=0; i<32; ++i) { +- POOL.UINT8[i].length = 0 +- POOL.UINT16[i].length = 0 +- POOL.UINT32[i].length = 0 +- POOL.INT8[i].length = 0 +- POOL.INT16[i].length = 0 +- POOL.INT32[i].length = 0 +- POOL.FLOAT[i].length = 0 +- POOL.DOUBLE[i].length = 0 +- POOL.UINT8C[i].length = 0 +- DATA[i].length = 0 +- BUFFER[i].length = 0 ++ var n = ne + nf ++ var g = new Array(n) ++ var count = 0 ++ var eptr = 0 ++ var fptr = 0 ++ var abs = Math.abs ++ var ei = e[eptr] ++ var ea = abs(ei) ++ var fi = -f[fptr] ++ var fa = abs(fi) ++ var a, b ++ if(ea < fa) { ++ b = ei ++ eptr += 1 ++ if(eptr < ne) { ++ ei = e[eptr] ++ ea = abs(ei) ++ } ++ } else { ++ b = fi ++ fptr += 1 ++ if(fptr < nf) { ++ fi = -f[fptr] ++ fa = abs(fi) ++ } + } +-} +-}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer) +-},{"bit-twiddle":9,"buffer":10,"dup":63}],152:[function(require,module,exports){ +-"use strict" +- +-function unique_pred(list, compare) { +- var ptr = 1 +- , len = list.length +- , a=list[0], b=list[0] +- for(var i=1; i= nf)) { ++ a = ei ++ eptr += 1 ++ if(eptr < ne) { ++ ei = e[eptr] ++ ea = abs(ei) ++ } ++ } else { ++ a = fi ++ fptr += 1 ++ if(fptr < nf) { ++ fi = -f[fptr] ++ fa = abs(fi) + } + } +- list.length = ptr +- return list +-} +- +-function unique_eq(list) { +- var ptr = 1 +- , len = list.length +- , a=list[0], b = list[0] +- for(var i=1; i= nf)) { ++ a = ei ++ eptr += 1 ++ if(eptr < ne) { ++ ei = e[eptr] ++ ea = abs(ei) ++ } ++ } else { ++ a = fi ++ fptr += 1 ++ if(fptr < nf) { ++ fi = f[fptr] ++ fa = abs(fi) ++ } + } +- +- var yShift = 0 +- switch(baseline) { +- case "hanging": +- case "top": +- yShift = -lo[1] +- break +- +- case "middle": +- yShift = -0.5 * (lo[1] + hi[1]) +- break +- +- case "alphabetic": +- case "ideographic": +- yShift = -3 * size +- break +- +- case "bottom": +- yShift = -hi[1] +- break +- +- default: +- throw new Error("vectorize-text: Unrecoginized textBaseline: '" + baseline + "'") ++ var x = a + b ++ var bv = x - a ++ var y = b - bv ++ var q0 = y ++ var q1 = x ++ var _x, _bv, _av, _br, _ar ++ while(eptr < ne && fptr < nf) { ++ if(ea < fa) { ++ a = ei ++ eptr += 1 ++ if(eptr < ne) { ++ ei = e[eptr] ++ ea = abs(ei) ++ } ++ } else { ++ a = fi ++ fptr += 1 ++ if(fptr < nf) { ++ fi = f[fptr] ++ fa = abs(fi) ++ } ++ } ++ b = q0 ++ x = a + b ++ bv = x - a ++ y = b - bv ++ if(y) { ++ g[count++] = y ++ } ++ _x = q1 + x ++ _bv = _x - q1 ++ _av = _x - _bv ++ _br = x - _bv ++ _ar = q1 - _av ++ q0 = _ar + _br ++ q1 = _x + } +- +- var scale = 1.0 / size +- if("lineHeight" in options) { +- scale *= +options.lineHeight +- } else if("width" in options) { +- scale = options.width / (hi[0] - lo[0]) +- } else if("height" in options) { +- scale = options.height / (hi[1] - lo[1]) ++ while(eptr < ne) { ++ a = ei ++ b = q0 ++ x = a + b ++ bv = x - a ++ y = b - bv ++ if(y) { ++ g[count++] = y ++ } ++ _x = q1 + x ++ _bv = _x - q1 ++ _av = _x - _bv ++ _br = x - _bv ++ _ar = q1 - _av ++ q0 = _ar + _br ++ q1 = _x ++ eptr += 1 ++ if(eptr < ne) { ++ ei = e[eptr] ++ } + } +- +- return positions.map(function(p) { +- return [ scale * (p[0] + xShift), scale * (p[1] + yShift) ] +- }) +-} +- +-function getPixels(canvas, context, str, size) { +- var width = Math.ceil(context.measureText(str).width + 2*size)|0 +- if(width > 8192) { +- throw new Error("vectorize-text: String too long (sorry, this will get fixed later)") ++ while(fptr < nf) { ++ a = fi ++ b = q0 ++ x = a + b ++ bv = x - a ++ y = b - bv ++ if(y) { ++ g[count++] = y ++ } ++ _x = q1 + x ++ _bv = _x - q1 ++ _av = _x - _bv ++ _br = x - _bv ++ _ar = q1 - _av ++ q0 = _ar + _br ++ q1 = _x ++ fptr += 1 ++ if(fptr < nf) { ++ fi = f[fptr] ++ } + } +- var height = 3 * size +- if(canvas.height < height) { +- canvas.height = height ++ if(q0) { ++ g[count++] = q0 + } +- +- context.fillStyle = "#000" +- context.fillRect(0, 0, canvas.width, canvas.height) +- +- context.fillStyle = "#fff" +- context.fillText(str, size, 2*size) +- +- //Cut pixels from image +- var pixelData = context.getImageData(0, 0, width, height) +- var pixels = ndarray(pixelData.data, [height, width, 4]) +- +- return pixels.pick(-1,-1,0).transpose(1,0) +-} +- +-function getContour(pixels, doSimplify) { +- var contour = surfaceNets(pixels, 128) +- if(doSimplify) { +- return simplify(contour.cells, contour.positions, 0.25) ++ if(q1) { ++ g[count++] = q1 + } +- return { +- edges: contour.cells, +- positions: contour.positions ++ if(!count) { ++ g[count++] = 0.0 + } ++ g.length = count ++ return g + } ++},{}],146:[function(require,module,exports){ ++"use strict" + +-function processPixelsImpl(pixels, options, size, simplify) { +- //Extract contour +- var contour = getContour(pixels, simplify) ++module.exports = function signum(x) { ++ if(x < 0) { return -1 } ++ if(x > 0) { return 1 } ++ return 0.0 ++} ++},{}],147:[function(require,module,exports){ ++arguments[4][28][0].apply(exports,arguments) ++},{"dup":28}],148:[function(require,module,exports){ ++"use strict"; "use restrict"; + +- //Apply warp to positions +- var positions = transformPositions(contour.positions, options, size) +- var edges = contour.edges +- var flip = "ccw" === options.orientation ++var bits = require("bit-twiddle") ++ , UnionFind = require("union-find") + +- //Clean up the PSLG, resolve self intersections, etc. +- cleanPSLG(positions, edges) ++//Returns the dimension of a cell complex ++function dimension(cells) { ++ var d = 0 ++ , max = Math.max ++ for(var i=0, il=cells.length; i 0) { +- var v = dead.pop() +- live[v] = false +- var n = adj[v] +- for(var i=0; i> 1 ++ , s = compareCells(cells[mid], c) ++ if(s <= 0) { ++ if(s === 0) { ++ r = mid ++ } ++ lo = mid + 1 ++ } else if(s > 0) { ++ hi = mid - 1 + } + } ++ return r ++} ++exports.findCell = findCell; + +- var nedges = [] +- for(var i=0; i= from_cells.length || compareCells(from_cells[idx], b) !== 0) { ++ break ++ } ++ } + } + } +- +- return [ nedges, npositions ] ++ return index + } +-},{"edges-to-adjacency-list":156}],156:[function(require,module,exports){ +-"use strict" +- +-module.exports = edgeToAdjacency +- +-var uniq = require("uniq") ++exports.incidence = incidence + +-function edgeToAdjacency(edges, numVertices) { +- var numEdges = edges.length +- if(typeof numVertices !== "number") { +- numVertices = 0 +- for(var i=0; i>> k) & 1) { ++ b.push(c[k]) ++ } ++ } ++ result.push(b) + } + } ++ return normalize(result) ++} ++exports.explode = explode + +- //Remove a half edge +- function cut(c, i) { +- var a = adj[i][c[i]] +- a.splice(a.indexOf(c), 1) ++//Enumerates all of the n-cells of a cell complex ++function skeleton(cells, n) { ++ if(n < 0) { ++ return [] + } +- +- //Find next vertex and cut edge +- function next(a, b, noCut) { +- var nextCell, nextVertex, nextDir +- for(var i=0; i<2; ++i) { +- if(adj[i][b].length > 0) { +- nextCell = adj[i][b][0] +- nextDir = i +- break ++ var result = [] ++ , k0 = (1<<(n+1))-1 ++ for(var i=0; i 0) { +- nextCell = e +- nextVertex = p +- nextDir = dir ++//Computes the boundary of all cells, does not remove duplicates ++function boundary(cells) { ++ var res = [] ++ for(var i=0,il=cells.length; i 0) { +- var ni = adj[0][i].length +- var ncycle = extractCycle(i,j) +- if(shouldGlue(pcycle, ncycle)) { +- //Glue together trivial cycles +- pcycle.push.apply(pcycle, ncycle) +- } else { +- if(pcycle.length > 0) { +- cycles.push(pcycle) +- } +- pcycle = ncycle +- } +- } +- if(pcycle.length > 0) { +- cycles.push(pcycle) +- } ++ for(var i=0; i= 0 ++ return components + } + +-function compareAngle(a, b, c, d) { +- var bcd = orient(b, c, d) +- if(bcd === 0) { +- //Handle degenerate cases +- var sabc = sgn(orient(a, b, c)) +- var sabd = sgn(orient(a, b, d)) +- if(sabc === sabd) { +- if(sabc === 0) { +- var ic = testInterior(a, b, c) +- var id = testInterior(a, b, d) +- if(ic === id) { +- return 0 +- } else if(ic) { +- return 1 +- } else { +- return -1 +- } +- } +- return 0 +- } else if(sabd === 0) { +- if(sabc > 0) { +- return -1 +- } else if(testInterior(a, b, d)) { +- return -1 +- } else { +- return 1 +- } +- } else if(sabc === 0) { +- if(sabd > 0) { +- return 1 +- } else if(testInterior(a, b, c)) { +- return 1 +- } else { +- return -1 ++//Computes connected components for a sparse graph ++function connectedComponents_sparse(cells) { ++ var vertices = unique(normalize(skeleton(cells, 0))) ++ , labels = new UnionFind(vertices.length) ++ for(var i=0; i 0) { +- if(bcd > 0 && orient(a, b, d) > 0) { +- return 1 +- } +- return -1 +- } else if(abc < 0) { +- if(bcd > 0 || orient(a, b, d) > 0) { +- return 1 +- } +- return -1 +- } else { +- var abd = orient(a, b, d) +- if(abd > 0) { +- return 1 ++ var components = [] ++ , component_labels = labels.ranks ++ for(var i=0; i 0) { return 1 } +- return 0.0 ++UnionFind.prototype.length = function() { ++ return this.roots.length; + } +-},{}],161:[function(require,module,exports){ +-"use strict" + +-function compileSearch(funcName, predicate, reversed, extraArgs, useNdarray, earlyOut) { +- var code = [ +- "function ", funcName, "(a,l,h,", extraArgs.join(","), "){", +-earlyOut ? "" : "var i=", (reversed ? "l-1" : "h+1"), +-";while(l<=h){\ +-var m=(l+h)>>>1,x=a", useNdarray ? ".get(m)" : "[m]"] +- if(earlyOut) { +- if(predicate.indexOf("c") < 0) { +- code.push(";if(x===y){return m}else if(x<=y){") +- } else { +- code.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){") +- } +- } else { +- code.push(";if(", predicate, "){i=m;") ++UnionFind.prototype.makeSet = function() { ++ var n = this.roots.length; ++ this.roots.push(n); ++ this.ranks.push(0); ++ return n; ++} ++ ++UnionFind.prototype.find = function(x) { ++ var roots = this.roots; ++ while(roots[x] !== x) { ++ var y = roots[x]; ++ roots[x] = roots[y]; ++ x = y; + } +- if(reversed) { +- code.push("l=m+1}else{h=m-1}") +- } else { +- code.push("h=m-1}else{l=m+1}") ++ return x; ++} ++ ++UnionFind.prototype.link = function(x, y) { ++ var xr = this.find(x) ++ , yr = this.find(y); ++ if(xr === yr) { ++ return; + } +- code.push("}") +- if(earlyOut) { +- code.push("return -1};") ++ var ranks = this.ranks ++ , roots = this.roots ++ , xd = ranks[xr] ++ , yd = ranks[yr]; ++ if(xd < yd) { ++ roots[xr] = yr; ++ } else if(yd < xd) { ++ roots[yr] = xr; + } else { +- code.push("return i};") ++ roots[yr] = xr; ++ ++ranks[xr]; + } +- return code.join("") +-} +- +-function compileBoundsSearch(predicate, reversed, suffix, earlyOut) { +- var result = new Function([ +- compileSearch("A", "x" + predicate + "y", reversed, ["y"], false, earlyOut), +- compileSearch("B", "x" + predicate + "y", reversed, ["y"], true, earlyOut), +- compileSearch("P", "c(x,y)" + predicate + "0", reversed, ["y", "c"], false, earlyOut), +- compileSearch("Q", "c(x,y)" + predicate + "0", reversed, ["y", "c"], true, earlyOut), +-"function dispatchBsearch", suffix, "(a,y,c,l,h){\ +-if(a.shape){\ +-if(typeof(c)==='function'){\ +-return Q(a,(l===undefined)?0:l|0,(h===undefined)?a.shape[0]-1:h|0,y,c)\ +-}else{\ +-return B(a,(c===undefined)?0:c|0,(l===undefined)?a.shape[0]-1:l|0,y)\ +-}}else{\ +-if(typeof(c)==='function'){\ +-return P(a,(l===undefined)?0:l|0,(h===undefined)?a.length-1:h|0,y,c)\ +-}else{\ +-return A(a,(c===undefined)?0:c|0,(l===undefined)?a.length-1:l|0,y)\ +-}}}\ +-return dispatchBsearch", suffix].join("")) +- return result() + } + +-module.exports = { +- ge: compileBoundsSearch(">=", false, "GE"), +- gt: compileBoundsSearch(">", false, "GT"), +- lt: compileBoundsSearch("<", true, "LT"), +- le: compileBoundsSearch("<=", true, "LE"), +- eq: compileBoundsSearch("-", true, "EQ", true) +-} + +-},{}],162:[function(require,module,exports){ ++},{}],150:[function(require,module,exports){ + "use strict" + +-var bounds = require("binary-search-bounds") +- +-var NOT_FOUND = 0 +-var SUCCESS = 1 +-var EMPTY = 2 ++module.exports = simplifyPolygon + +-module.exports = createWrapper ++var orient = require("robust-orientation") ++var sc = require("simplicial-complex") + +-function IntervalTreeNode(mid, left, right, leftPoints, rightPoints) { +- this.mid = mid +- this.left = left +- this.right = right +- this.leftPoints = leftPoints +- this.rightPoints = rightPoints +- this.count = (left ? left.count : 0) + (right ? right.count : 0) + leftPoints.length ++function errorWeight(base, a, b) { ++ var area = Math.abs(orient(base, a, b)) ++ var perim = Math.sqrt(Math.pow(a[0] - b[0], 2) + Math.pow(a[1]-b[1], 2)) ++ return area / perim + } + +-var proto = IntervalTreeNode.prototype ++function simplifyPolygon(cells, positions, minArea) { + +-function copy(a, b) { +- a.mid = b.mid +- a.left = b.left +- a.right = b.right +- a.leftPoints = b.leftPoints +- a.rightPoints = b.rightPoints +- a.count = b.count +-} ++ var n = positions.length ++ var nc = cells.length ++ var inv = new Array(n) ++ var outv = new Array(n) ++ var weights = new Array(n) ++ var dead = new Array(n) ++ ++ //Initialize tables ++ for(var i=0; i> 1 ++ } ++ return (i >> 1) - 1 + } +- return result +-} + +-proto.insert = function(interval) { +- var weight = this.count - this.leftPoints.length +- this.count += 1 +- if(interval[1] < this.mid) { +- if(this.left) { +- if(4*(this.left.count+1) > 3*(weight+1)) { +- rebuildWithInterval(this, interval) +- } else { +- this.left.insert(interval) ++ //Bubble element i down the heap ++ function heapDown(i) { ++ var w = heapWeight(i) ++ while(true) { ++ var tw = w ++ var left = 2*i + 1 ++ var right = 2*(i + 1) ++ var next = i ++ if(left < heapCount) { ++ var lw = heapWeight(left) ++ if(lw < tw) { ++ next = left ++ tw = lw ++ } + } +- } else { +- this.left = createIntervalTree([interval]) ++ if(right < heapCount) { ++ var rw = heapWeight(right) ++ if(rw < tw) { ++ next = right ++ } ++ } ++ if(next === i) { ++ return i ++ } ++ heapSwap(i, next) ++ i = next + } +- } else if(interval[0] > this.mid) { +- if(this.right) { +- if(4*(this.right.count+1) > 3*(weight+1)) { +- rebuildWithInterval(this, interval) +- } else { +- this.right.insert(interval) ++ } ++ ++ //Bubbles element i up the heap ++ function heapUp(i) { ++ var w = heapWeight(i) ++ while(i > 0) { ++ var parent = heapParent(i) ++ if(parent >= 0) { ++ var pw = heapWeight(parent) ++ if(w < pw) { ++ heapSwap(i, parent) ++ i = parent ++ continue ++ } + } +- } else { +- this.right = createIntervalTree([interval]) ++ return i + } +- } else { +- var l = bounds.ge(this.leftPoints, interval, compareBegin) +- var r = bounds.ge(this.rightPoints, interval, compareEnd) +- this.leftPoints.splice(l, 0, interval) +- this.rightPoints.splice(r, 0, interval) + } +-} + +-proto.remove = function(interval) { +- var weight = this.count - this.leftPoints +- if(interval[1] < this.mid) { +- if(!this.left) { +- return NOT_FOUND ++ //Pop minimum element ++ function heapPop() { ++ if(heapCount > 0) { ++ var head = heap[0] ++ heapSwap(0, heapCount-1) ++ heapCount -= 1 ++ heapDown(0) ++ return head + } +- var rw = this.right ? this.right.count : 0 +- if(4 * rw > 3 * (weight-1)) { +- return rebuildWithoutInterval(this, interval) ++ return -1 ++ } ++ ++ //Update heap item i ++ function heapUpdate(i, w) { ++ var a = heap[i] ++ if(weights[a] === w) { ++ return i + } +- var r = this.left.remove(interval) +- if(r === EMPTY) { +- this.left = null +- this.count -= 1 +- return SUCCESS +- } else if(r === SUCCESS) { +- this.count -= 1 ++ weights[a] = -Infinity ++ heapUp(i) ++ heapPop() ++ weights[a] = w ++ heapCount += 1 ++ return heapUp(heapCount-1) ++ } ++ ++ //Kills a vertex (assume vertex already removed from heap) ++ function kill(i) { ++ if(dead[i]) { ++ return + } +- return r +- } else if(interval[0] > this.mid) { +- if(!this.right) { +- return NOT_FOUND ++ //Kill vertex ++ dead[i] = true ++ //Fixup topology ++ var s = inv[i] ++ var t = outv[i] ++ if(inv[t] >= 0) { ++ inv[t] = s + } +- var lw = this.left ? this.left.count : 0 +- if(4 * lw > 3 * (weight-1)) { +- return rebuildWithoutInterval(this, interval) ++ if(outv[s] >= 0) { ++ outv[s] = t + } +- var r = this.right.remove(interval) +- if(r === EMPTY) { +- this.right = null +- this.count -= 1 +- return SUCCESS +- } else if(r === SUCCESS) { +- this.count -= 1 ++ ++ //Update weights on s and t ++ if(index[s] >= 0) { ++ heapUpdate(index[s], computeWeight(s)) + } +- return r +- } else { +- if(this.count === 1) { +- if(this.leftPoints[0] === interval) { +- return EMPTY +- } else { +- return NOT_FOUND +- } ++ if(index[t] >= 0) { ++ heapUpdate(index[t], computeWeight(t)) + } +- if(this.leftPoints.length === 1 && this.leftPoints[0] === interval) { +- if(this.left && this.right) { +- var p = this +- var n = this.left +- while(n.right) { +- p = n +- n = n.right +- } +- if(p === this) { +- n.right = this.right +- } else { +- var l = this.left +- var r = this.right +- p.count -= n.count +- p.right = n.left +- n.left = l +- n.right = r +- } +- copy(this, n) +- this.count = (this.left?this.left.count:0) + (this.right?this.right.count:0) + this.leftPoints.length +- } else if(this.left) { +- copy(this, this.left) +- } else { +- copy(this, this.right) +- } +- return SUCCESS ++ } ++ ++ //Initialize weights and heap ++ var heap = [] ++ var index = new Array(n) ++ for(var i=0; i>1; i>=0; --i) { ++ heapDown(i) ++ } ++ ++ //Kill vertices ++ while(true) { ++ var hmin = heapPop() ++ if((hmin < 0) || (weights[hmin] > minArea)) { ++ break ++ } ++ kill(hmin) ++ } ++ ++ //Build collapsed vertex table ++ var npositions = [] ++ for(var i=0; i= 0 && tout >= 0 && tin !== tout) { ++ var cin = index[tin] ++ var cout = index[tout] ++ if(cin !== cout) { ++ ncells.push([ cin, cout ]) ++ } ++ } ++ }) + +-function reportRightRange(arr, lo, cb) { +- for(var i=arr.length-1; i>=0 && arr[i][1] >= lo; --i) { +- var r = cb(arr[i]) +- if(r) { return r } +- } +-} ++ //Normalize result ++ sc.unique(sc.normalize(ncells)) + +-function reportRange(arr, cb) { +- for(var i=0; i b[1][0]) { ++ bl = b[1] ++ br = b[0] ++ } else { ++ var alo = Math.min(a[0][1], a[1][1]) ++ var ahi = Math.max(a[0][1], a[1][1]) ++ var blo = Math.min(b[0][1], b[1][1]) ++ var bhi = Math.max(b[0][1], b[1][1]) ++ if(ahi < blo) { ++ return ahi - blo + } +- return reportLeftRange(this.leftPoints, x, cb) +- } else if(x > this.mid) { +- if(this.right) { +- var r = this.right.queryPoint(x, cb) +- if(r) { return r } ++ if(alo > bhi) { ++ return alo - bhi + } +- return reportRightRange(this.rightPoints, x, cb) ++ return ahi - bhi ++ } ++ var al, ar ++ if(a[0][1] < a[1][1]) { ++ al = a[0] ++ ar = a[1] ++ } else { ++ al = a[1] ++ ar = a[0] ++ } ++ var d = orient(br, bl, al) ++ if(d) { ++ return d ++ } ++ d = orient(br, bl, ar) ++ if(d) { ++ return d ++ } ++ return ar - br ++} ++ ++function orderSegments(b, a) { ++ var al, ar ++ if(a[0][0] < a[1][0]) { ++ al = a[0] ++ ar = a[1] ++ } else if(a[0][0] > a[1][0]) { ++ al = a[1] ++ ar = a[0] + } else { +- return reportRange(this.leftPoints, cb) ++ return horizontalOrder(a, b) + } +-} +- +-proto.queryInterval = function(lo, hi, cb) { +- if(lo < this.mid && this.left) { +- var r = this.left.queryInterval(lo, hi, cb) +- if(r) { return r } ++ var bl, br ++ if(b[0][0] < b[1][0]) { ++ bl = b[0] ++ br = b[1] ++ } else if(b[0][0] > b[1][0]) { ++ bl = b[1] ++ br = b[0] ++ } else { ++ return -horizontalOrder(b, a) + } +- if(hi > this.mid && this.right) { +- var r = this.right.queryInterval(lo, hi, cb) +- if(r) { return r } ++ var d1 = orient(al, ar, br) ++ var d2 = orient(al, ar, bl) ++ if(d1 < 0) { ++ if(d2 <= 0) { ++ return d1 ++ } ++ } else if(d1 > 0) { ++ if(d2 >= 0) { ++ return d1 ++ } ++ } else if(d2) { ++ return d2 + } +- if(hi < this.mid) { +- return reportLeftRange(this.leftPoints, hi, cb) +- } else if(lo > this.mid) { +- return reportRightRange(this.rightPoints, lo, cb) +- } else { +- return reportRange(this.leftPoints, cb) ++ d1 = orient(br, bl, ar) ++ d2 = orient(br, bl, al) ++ if(d1 < 0) { ++ if(d2 <= 0) { ++ return d1 ++ } ++ } else if(d1 > 0) { ++ if(d2 >= 0) { ++ return d1 ++ } ++ } else if(d2) { ++ return d2 + } ++ return ar[0] - br[0] + } ++},{"robust-orientation":140}],152:[function(require,module,exports){ ++"use strict" + +-function compareNumbers(a, b) { +- return a - b +-} ++module.exports = createSlabDecomposition + +-function compareBegin(a, b) { +- var d = a[0] - b[0] +- if(d) { return d } +- return a[1] - b[1] +-} ++var bounds = require("binary-search-bounds") ++var createRBTree = require("functional-red-black-tree") ++var orient = require("robust-orientation") ++var orderSegments = require("./lib/order-segments") + +-function compareEnd(a, b) { +- var d = a[1] - b[1] +- if(d) { return d } +- return a[0] - b[0] ++function SlabDecomposition(slabs, coordinates, horizontal) { ++ this.slabs = slabs ++ this.coordinates = coordinates ++ this.horizontal = horizontal + } + +-function createIntervalTree(intervals) { +- if(intervals.length === 0) { +- return null +- } +- var pts = [] +- for(var i=0; i>1] ++function compareHorizontal(e, y) { ++ return e.y - y ++} + +- var leftIntervals = [] +- var rightIntervals = [] +- var centerIntervals = [] +- for(var i=0; i 0) { ++ if(p[0] !== seg[1][0]) { ++ lastNode = root ++ root = root.right ++ } else { ++ var val = searchBucket(root.right, p) ++ if(val) { ++ return val ++ } ++ root = root.left ++ } ++ } else { ++ if(p[0] !== seg[1][0]) { ++ return root ++ } else { ++ var val = searchBucket(root.right, p) ++ if(val) { ++ return val ++ } ++ root = root.left ++ } + } + } +- +- //Split center intervals +- var leftPoints = centerIntervals +- var rightPoints = centerIntervals.slice() +- leftPoints.sort(compareBegin) +- rightPoints.sort(compareEnd) +- +- return new IntervalTreeNode(mid, +- createIntervalTree(leftIntervals), +- createIntervalTree(rightIntervals), +- leftPoints, +- rightPoints) +-} +- +-//User friendly wrapper that makes it possible to support empty trees +-function IntervalTree(root) { +- this.root = root ++ return lastNode + } + +-var tproto = IntervalTree.prototype +- +-tproto.insert = function(interval) { +- if(this.root) { +- this.root.insert(interval) +- } else { +- this.root = new IntervalTreeNode(interval[0], null, null, [interval], [interval]) ++proto.castUp = function(p) { ++ var bucket = bounds.le(this.coordinates, p[0]) ++ if(bucket < 0) { ++ return -1 + } +-} +- +-tproto.remove = function(interval) { +- if(this.root) { +- var r = this.root.remove(interval) +- if(r === EMPTY) { +- this.root = null ++ var root = this.slabs[bucket] ++ var hitNode = searchBucket(this.slabs[bucket], p) ++ var lastHit = -1 ++ if(hitNode) { ++ lastHit = hitNode.value ++ } ++ //Edge case: need to handle horizontal segments (sucks) ++ if(this.coordinates[bucket] === p[0]) { ++ var lastSegment = null ++ if(hitNode) { ++ lastSegment = hitNode.key ++ } ++ if(bucket > 0) { ++ var otherHitNode = searchBucket(this.slabs[bucket-1], p) ++ if(otherHitNode) { ++ if(lastSegment) { ++ if(orderSegments(otherHitNode.key, lastSegment) > 0) { ++ lastSegment = otherHitNode.key ++ lastHit = otherHitNode.value ++ } ++ } else { ++ lastHit = otherHitNode.value ++ lastSegment = otherHitNode.key ++ } ++ } ++ } ++ var horiz = this.horizontal[bucket] ++ if(horiz.length > 0) { ++ var hbucket = bounds.ge(horiz, p[1], compareHorizontal) ++ if(hbucket < horiz.length) { ++ var e = horiz[hbucket] ++ if(p[1] === e.y) { ++ if(e.closed) { ++ return e.index ++ } else { ++ while(hbucket < horiz.length-1 && horiz[hbucket+1].y === p[1]) { ++ hbucket = hbucket+1 ++ e = horiz[hbucket] ++ if(e.closed) { ++ return e.index ++ } ++ } ++ if(e.y === p[1] && !e.start) { ++ hbucket = hbucket+1 ++ if(hbucket >= horiz.length) { ++ return lastHit ++ } ++ e = horiz[hbucket] ++ } ++ } ++ } ++ //Check if e is above/below last segment ++ if(e.start) { ++ if(lastSegment) { ++ var o = orient(lastSegment[0], lastSegment[1], [p[0], e.y]) ++ if(lastSegment[0][0] > lastSegment[1][0]) { ++ o = -o ++ } ++ if(o > 0) { ++ lastHit = e.index ++ } ++ } else { ++ lastHit = e.index ++ } ++ } else if(e.y !== p[1]) { ++ lastHit = e.index ++ } ++ } + } +- return r !== NOT_FOUND + } +- return false ++ return lastHit + } + +-tproto.queryPoint = function(p, cb) { +- if(this.root) { +- return this.root.queryPoint(p, cb) +- } ++function IntervalSegment(y, index, start, closed) { ++ this.y = y ++ this.index = index ++ this.start = start ++ this.closed = closed + } + +-tproto.queryInterval = function(lo, hi, cb) { +- if(lo <= hi && this.root) { +- return this.root.queryInterval(lo, hi, cb) +- } ++function Event(x, segment, create, index) { ++ this.x = x ++ this.segment = segment ++ this.create = create ++ this.index = index + } + +-Object.defineProperty(tproto, "count", { +- get: function() { +- if(this.root) { +- return this.root.count ++ ++function createSlabDecomposition(segments) { ++ var numSegments = segments.length ++ var numEvents = 2 * numSegments ++ var events = new Array(numEvents) ++ for(var i=0; i= 0 ++ } + +-function horizontalOrder(a, b) { +- var bl, br +- if(b[0][0] < b[1][0]) { +- bl = b[0] +- br = b[1] +- } else if(b[0][0] > b[1][0]) { +- bl = b[1] +- br = b[0] +- } else { +- var alo = Math.min(a[0][1], a[1][1]) +- var ahi = Math.max(a[0][1], a[1][1]) +- var blo = Math.min(b[0][1], b[1][1]) +- var bhi = Math.max(b[0][1], b[1][1]) +- if(ahi < blo) { +- return ahi - blo ++ switch (match[8]) { ++ case "b": ++ arg = arg.toString(2) ++ break ++ case "c": ++ arg = String.fromCharCode(arg) ++ break ++ case "d": ++ case "i": ++ arg = parseInt(arg, 10) ++ break ++ case "j": ++ arg = JSON.stringify(arg, null, match[6] ? parseInt(match[6]) : 0) ++ break ++ case "e": ++ arg = match[7] ? arg.toExponential(match[7]) : arg.toExponential() ++ break ++ case "f": ++ arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg) ++ break ++ case "g": ++ arg = match[7] ? parseFloat(arg).toPrecision(match[7]) : parseFloat(arg) ++ break ++ case "o": ++ arg = arg.toString(8) ++ break ++ case "s": ++ arg = ((arg = String(arg)) && match[7] ? arg.substring(0, match[7]) : arg) ++ break ++ case "u": ++ arg = arg >>> 0 ++ break ++ case "x": ++ arg = arg.toString(16) ++ break ++ case "X": ++ arg = arg.toString(16).toUpperCase() ++ break ++ } ++ if (re.json.test(match[8])) { ++ output[output.length] = arg ++ } ++ else { ++ if (re.number.test(match[8]) && (!is_positive || match[3])) { ++ sign = is_positive ? "+" : "-" ++ arg = arg.toString().replace(re.sign, "") ++ } ++ else { ++ sign = "" ++ } ++ pad_character = match[4] ? match[4] === "0" ? "0" : match[4].charAt(1) : " " ++ pad_length = match[6] - (sign + arg).length ++ pad = match[6] ? (pad_length > 0 ? str_repeat(pad_character, pad_length) : "") : "" ++ output[output.length] = match[5] ? sign + arg + pad : (pad_character === "0" ? sign + pad + arg : pad + sign + arg) ++ } ++ } ++ } ++ return output.join("") ++ } ++ ++ sprintf.cache = {} ++ ++ sprintf.parse = function(fmt) { ++ var _fmt = fmt, match = [], parse_tree = [], arg_names = 0 ++ while (_fmt) { ++ if ((match = re.text.exec(_fmt)) !== null) { ++ parse_tree[parse_tree.length] = match[0] ++ } ++ else if ((match = re.modulo.exec(_fmt)) !== null) { ++ parse_tree[parse_tree.length] = "%" ++ } ++ else if ((match = re.placeholder.exec(_fmt)) !== null) { ++ if (match[2]) { ++ arg_names |= 1 ++ var field_list = [], replacement_field = match[2], field_match = [] ++ if ((field_match = re.key.exec(replacement_field)) !== null) { ++ field_list[field_list.length] = field_match[1] ++ while ((replacement_field = replacement_field.substring(field_match[0].length)) !== "") { ++ if ((field_match = re.key_access.exec(replacement_field)) !== null) { ++ field_list[field_list.length] = field_match[1] ++ } ++ else if ((field_match = re.index_access.exec(replacement_field)) !== null) { ++ field_list[field_list.length] = field_match[1] ++ } ++ else { ++ throw new SyntaxError("[sprintf] failed to parse named argument key") ++ } ++ } ++ } ++ else { ++ throw new SyntaxError("[sprintf] failed to parse named argument key") ++ } ++ match[2] = field_list ++ } ++ else { ++ arg_names |= 2 ++ } ++ if (arg_names === 3) { ++ throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported") ++ } ++ parse_tree[parse_tree.length] = match ++ } ++ else { ++ throw new SyntaxError("[sprintf] unexpected placeholder") ++ } ++ _fmt = _fmt.substring(match[0].length) ++ } ++ return parse_tree + } +- if(alo > bhi) { +- return alo - bhi ++ ++ var vsprintf = function(fmt, argv, _argv) { ++ _argv = (argv || []).slice(0) ++ _argv.splice(0, 0, fmt) ++ return sprintf.apply(null, _argv) + } +- return ahi - bhi +- } +- var al, ar +- if(a[0][1] < a[1][1]) { +- al = a[0] +- ar = a[1] +- } else { +- al = a[1] +- ar = a[0] +- } +- var d = orient(br, bl, al) +- if(d) { +- return d +- } +- d = orient(br, bl, ar) +- if(d) { +- return d +- } +- return ar - br +-} + +-function orderSegments(b, a) { +- var al, ar +- if(a[0][0] < a[1][0]) { +- al = a[0] +- ar = a[1] +- } else if(a[0][0] > a[1][0]) { +- al = a[1] +- ar = a[0] +- } else { +- return horizontalOrder(a, b) +- } +- var bl, br +- if(b[0][0] < b[1][0]) { +- bl = b[0] +- br = b[1] +- } else if(b[0][0] > b[1][0]) { +- bl = b[1] +- br = b[0] +- } else { +- return -horizontalOrder(b, a) +- } +- var d1 = orient(al, ar, br) +- var d2 = orient(al, ar, bl) +- if(d1 < 0) { +- if(d2 <= 0) { +- return d1 ++ /** ++ * helpers ++ */ ++ function get_type(variable) { ++ return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase() + } +- } else if(d1 > 0) { +- if(d2 >= 0) { +- return d1 ++ ++ function str_repeat(input, multiplier) { ++ return Array(multiplier + 1).join(input) + } +- } else if(d2) { +- return d2 +- } +- d1 = orient(br, bl, ar) +- d2 = orient(br, bl, al) +- if(d1 < 0) { +- if(d2 <= 0) { +- return d1 ++ ++ /** ++ * export to either browser or node.js ++ */ ++ if (typeof exports !== "undefined") { ++ exports.sprintf = sprintf ++ exports.vsprintf = vsprintf + } +- } else if(d1 > 0) { +- if(d2 >= 0) { +- return d1 ++ else { ++ window.sprintf = sprintf ++ window.vsprintf = vsprintf ++ ++ if (typeof define === "function" && define.amd) { ++ define(function() { ++ return { ++ sprintf: sprintf, ++ vsprintf: vsprintf ++ } ++ }) ++ } + } +- } else if(d2) { +- return d2 +- } +- return ar[0] - br[0] +-} +-},{"robust-orientation":133}],164:[function(require,module,exports){ +-"use strict" ++})(typeof window === "undefined" ? this : window); + +-module.exports = createRBTree ++},{}],154:[function(require,module,exports){ ++'use strict' + +-var RED = 0 +-var BLACK = 1 ++module.exports = toSuperScript + +-function RBNode(color, key, value, left, right, count) { +- this._color = color +- this.key = key +- this.value = value +- this.left = left +- this.right = right +- this._count = count ++var SUPERSCRIPTS = { ++ ' ': ' ', ++ '0': '⁰', ++ '1': '¹', ++ '2': '²', ++ '3': '³', ++ '4': '⁴', ++ '5': '⁵', ++ '6': '⁶', ++ '7': '⁷', ++ '8': '⁸', ++ '9': '⁹', ++ '+': '⁺', ++ '-': '⁻', ++ 'a': 'ᵃ', ++ 'b': 'ᵇ', ++ 'c': 'ᶜ', ++ 'd': 'ᵈ', ++ 'e': 'ᵉ', ++ 'f': 'ᶠ', ++ 'g': 'ᵍ', ++ 'h': 'ʰ', ++ 'i': 'ⁱ', ++ 'j': 'ʲ', ++ 'k': 'ᵏ', ++ 'l': 'ˡ', ++ 'm': 'ᵐ', ++ 'n': 'ⁿ', ++ 'o': 'ᵒ', ++ 'p': 'ᵖ', ++ 'r': 'ʳ', ++ 's': 'ˢ', ++ 't': 'ᵗ', ++ 'u': 'ᵘ', ++ 'v': 'ᵛ', ++ 'w': 'ʷ', ++ 'x': 'ˣ', ++ 'y': 'ʸ', ++ 'z': 'ᶻ' + } + +-function cloneNode(node) { +- return new RBNode(node._color, node.key, node.value, node.left, node.right, node._count) ++function toSuperScript(x) { ++ return x.split('').map(function(c) { ++ if(c in SUPERSCRIPTS) { ++ return SUPERSCRIPTS[c] ++ } ++ return '' ++ }).join('') + } + +-function repaint(color, node) { +- return new RBNode(color, node.key, node.value, node.left, node.right, node._count) +-} ++},{}],155:[function(require,module,exports){ ++"use strict" + +-function recount(node) { +- node._count = 1 + (node.left ? node.left._count : 0) + (node.right ? node.right._count : 0) +-} ++module.exports = surfaceNets + +-function RedBlackTree(compare, root) { +- this._compare = compare +- this.root = root +-} ++var generateContourExtractor = require("ndarray-extract-contour") ++var triangulateCube = require("triangulate-hypercube") ++var zeroCrossings = require("zero-crossings") + +-var proto = RedBlackTree.prototype ++function buildSurfaceNets(order, dtype) { ++ var dimension = order.length ++ var code = ["'use strict';"] ++ var funcName = "surfaceNets" + order.join("_") + "d" + dtype + +-Object.defineProperty(proto, "keys", { +- get: function() { +- var result = [] +- this.forEach(function(k,v) { +- result.push(k) +- }) +- return result ++ //Contour extraction function ++ code.push( ++ "var contour=genContour({", ++ "order:[", order.join(), "],", ++ "scalarArguments: 3,", ++ "phase:function phaseFunc(p,a,b,c) { return (p > c)|0 },") ++ if(dtype === "generic") { ++ code.push("getters:[0],") + } +-}) + +-Object.defineProperty(proto, "values", { +- get: function() { +- var result = [] +- this.forEach(function(k,v) { +- result.push(v) +- }) +- return result ++ //Generate vertex function ++ var cubeArgs = [] ++ var extraArgs = [] ++ for(var i=0; i=0; --s) { +- var n = n_stack[s] +- if(d_stack[s] <= 0) { +- n_stack[s] = new RBNode(n._color, n.key, n.value, n_stack[s+1], n.right, n._count+1) +- } else { +- n_stack[s] = new RBNode(n._color, n.key, n.value, n.left, n_stack[s+1], n._count+1) +- } ++ cubeArgs.push("a", "b", "c") ++ extraArgs.push("a", "c") ++ code.push("vertex:function vertexFunc(", cubeArgs.join(), "){") ++ //Mask args together ++ var maskStr = [] ++ for(var i=0; i<(1<1; --s) { +- var p = n_stack[s-1] +- var n = n_stack[s] +- if(p._color === BLACK || n._color === BLACK) { +- break ++ //Generate variables and giganto switch statement ++ code.push("var m=(", maskStr.join("+"), ")|0;if(m===0||m===", (1<<(1<>>7){") ++ } ++ for(var i=0; i<1<<(1< 128) { ++ if((i%128)===0) { ++ if(extraFuncs.length > 0) { ++ currentFunc.push("}}") ++ } ++ var efName = "vExtra" + extraFuncs.length ++ code.push("case ", (i>>>7), ":", efName, "(m&0x7f,", extraArgs.join(), ");break;") ++ currentFunc = [ ++ "function ", efName, "(m,", extraArgs.join(), "){switch(m){" ++ ] ++ extraFuncs.push(currentFunc) ++ } + } +- var pp = n_stack[s-2] +- if(pp.left === p) { +- if(p.left === n) { +- var y = pp.right +- if(y && y._color === RED) { +- //console.log("LLr") +- p._color = BLACK +- pp.right = repaint(BLACK, y) +- pp._color = RED +- s -= 1 +- } else { +- //console.log("LLb") +- pp._color = RED +- pp.left = p.right +- p._color = BLACK +- p.right = pp +- n_stack[s-2] = p +- n_stack[s-1] = n +- recount(pp) +- recount(p) +- if(s >= 3) { +- var ppp = n_stack[s-3] +- if(ppp.left === pp) { +- ppp.left = p +- } else { +- ppp.right = p +- } +- } +- break ++ currentFunc.push("case ", (i&0x7f), ":") ++ var crossings = new Array(dimension) ++ var denoms = new Array(dimension) ++ var crossingCount = new Array(dimension) ++ var bias = new Array(dimension) ++ var totalCrossings = 0 ++ for(var j=0; j j) { ++ continue + } +- } else { +- var y = pp.right +- if(y && y._color === RED) { +- //console.log("LRr") +- p._color = BLACK +- pp.right = repaint(BLACK, y) +- pp._color = RED +- s -= 1 +- } else { +- //console.log("LRb") +- p.right = n.left +- pp._color = RED +- pp.left = n.right +- n._color = BLACK +- n.left = p +- n.right = pp +- n_stack[s-2] = n +- n_stack[s-1] = p +- recount(pp) +- recount(p) +- recount(n) +- if(s >= 3) { +- var ppp = n_stack[s-3] +- if(ppp.left === pp) { +- ppp.left = n +- } else { +- ppp.right = n +- } ++ if(!(i&(1<= 3) { +- var ppp = n_stack[s-3] +- if(ppp.right === pp) { +- ppp.right = p ++ if(sign < 0) { ++ crossings[k].push("-v" + j + "-v" + u) ++ crossingCount[k] += 2 ++ } else { ++ crossings[k].push("v" + j + "+v" + u) ++ crossingCount[k] -= 2 ++ } ++ totalCrossings += 1 ++ for(var l=0; l= 3) { +- var ppp = n_stack[s-3] +- if(ppp.right === pp) { +- ppp.right = n +- } else { +- ppp.left = n +- } +- } +- break ++ var cStr = "" ++ if(crossingCount[k] < 0) { ++ cStr = crossingCount[k] + "*c" ++ } else if(crossingCount[k] > 0) { ++ cStr = "+" + crossingCount[k] + "*c" + } ++ var weight = 0.5 * (crossings[k].length / totalCrossings) ++ var shift = 0.5 + 0.5 * (bias[k] / totalCrossings) ++ vertexStr.push("d" + k + "-" + shift + "-" + weight + "*(" + crossings[k].join("+") + cStr + ")/(" + denoms[k].join("+") + ")") ++ + } + } ++ currentFunc.push("a.push([", vertexStr.join(), "]);", ++ "break;") ++ } ++ code.push("}},") ++ if(extraFuncs.length > 0) { ++ currentFunc.push("}}") ++ } ++ ++ //Create face function ++ var faceArgs = [] ++ for(var i=0; i<(1<<(dimension-1)); ++i) { ++ faceArgs.push("v" + i) ++ } ++ faceArgs.push("c0", "c1", "p0", "p1", "a", "b", "c") ++ code.push("cell:function cellFunc(", faceArgs.join(), "){") ++ ++ var facets = triangulateCube(dimension-1) ++ code.push("if(p0){b.push(", ++ facets.map(function(f) { ++ return "[" + f.map(function(v) { ++ return "v" + v ++ }) + "]" ++ }).join(), ")}else{b.push(", ++ facets.map(function(f) { ++ var e = f.slice() ++ e.reverse() ++ return "[" + e.map(function(v) { ++ return "v" + v ++ }) + "]" ++ }).join(), ++ ")}}});function ", funcName, "(array,level){var verts=[],cells=[];contour(array,verts,cells,level);return {positions:verts,cells:cells};} return ", funcName, ";") ++ ++ for(var i=0; i 0) { +- v = visit(node.key, node.value) +- if(v) { return v } ++module.exports = textGet ++ ++var vectorizeText = require('vectorize-text') ++ ++var globals = window || process.global || {} ++var __TEXT_CACHE = globals.__TEXT_CACHE || {} ++globals.__TEXT_CACHE = {} ++ ++function unwrap(mesh) { ++ var cells = mesh.cells ++ var positions = mesh.positions ++ var data = new Float32Array(cells.length * 6) ++ var ptr = 0 ++ var shapeX = 0 ++ for(var i=0; i 0 && node.right) { +- return doVisit(lo, hi, compare, visit, node.right) ++ return { ++ data: data, ++ shape: shapeX + } + } + ++function textGet(font, text) { ++ var fontcache = __TEXT_CACHE[font] ++ if(!fontcache) { ++ fontcache = __TEXT_CACHE[font] = { ++ ' ': { ++ data: new Float32Array(0), ++ shape: 0.2 ++ } ++ } ++ } ++ var mesh = fontcache[text] ++ if(!mesh) { ++ if(text.length <= 1 || !/\d/.test(text)) { ++ mesh = fontcache[text] = unwrap(vectorizeText(text, { ++ triangles: true, ++ font: font, ++ textAlign: 'left', ++ textBaseline: 'alphabetic' ++ })) ++ } else { ++ var parts = text.split(/(\d|\s)/) ++ var buffer = new Array(parts.length) ++ var bufferSize = 0 ++ var shapeX = 0 ++ for(var i=0; i0) { ++ shapeX += 0.02 ++ } ++ } + +-proto.forEach = function rbTreeForEach(visit, lo, hi) { +- if(!this.root) { +- return +- } +- switch(arguments.length) { +- case 1: +- return doVisitFull(visit, this.root) +- break ++ var data = new Float32Array(bufferSize) ++ var ptr = 0 ++ var xOffset = -0.5 * shapeX ++ for(var i=0; i= 0) { +- return +- } +- return doVisit(lo, hi, this._compare, visit, this.root) +- break +- } ++ return mesh + } + +-//First item in list +-Object.defineProperty(proto, "begin", { +- get: function() { +- var stack = [] +- var n = this.root +- while(n) { +- stack.push(n) +- n = n.left ++}).call(this,require('_process')) ++},{"_process":133,"vectorize-text":165}],157:[function(require,module,exports){ ++// TinyColor v1.4.1 ++// https://github.com/bgrins/TinyColor ++// Brian Grinstead, MIT License ++ ++(function(Math) { ++ ++var trimLeft = /^\s+/, ++ trimRight = /\s+$/, ++ tinyCounter = 0, ++ mathRound = Math.round, ++ mathMin = Math.min, ++ mathMax = Math.max, ++ mathRandom = Math.random; ++ ++function tinycolor (color, opts) { ++ ++ color = (color) ? color : ''; ++ opts = opts || { }; ++ ++ // If input is already a tinycolor, return itself ++ if (color instanceof tinycolor) { ++ return color; ++ } ++ // If we are called as a function, call using new instead ++ if (!(this instanceof tinycolor)) { ++ return new tinycolor(color, opts); + } +- return new RedBlackTreeIterator(this, stack) +- } +-}) + +-//Last item in list +-Object.defineProperty(proto, "end", { +- get: function() { +- var stack = [] +- var n = this.root +- while(n) { +- stack.push(n) +- n = n.right ++ var rgb = inputToRGB(color); ++ this._originalInput = color, ++ this._r = rgb.r, ++ this._g = rgb.g, ++ this._b = rgb.b, ++ this._a = rgb.a, ++ this._roundA = mathRound(100*this._a) / 100, ++ this._format = opts.format || rgb.format; ++ this._gradientType = opts.gradientType; ++ ++ // Don't let the range of [0,255] come back in [0,1]. ++ // Potentially lose a little bit of precision here, but will fix issues where ++ // .5 gets interpreted as half of the total, instead of half of 1 ++ // If it was supposed to be 128, this was already taken care of by `inputToRgb` ++ if (this._r < 1) { this._r = mathRound(this._r); } ++ if (this._g < 1) { this._g = mathRound(this._g); } ++ if (this._b < 1) { this._b = mathRound(this._b); } ++ ++ this._ok = rgb.ok; ++ this._tc_id = tinyCounter++; ++} ++ ++tinycolor.prototype = { ++ isDark: function() { ++ return this.getBrightness() < 128; ++ }, ++ isLight: function() { ++ return !this.isDark(); ++ }, ++ isValid: function() { ++ return this._ok; ++ }, ++ getOriginalInput: function() { ++ return this._originalInput; ++ }, ++ getFormat: function() { ++ return this._format; ++ }, ++ getAlpha: function() { ++ return this._a; ++ }, ++ getBrightness: function() { ++ //http://www.w3.org/TR/AERT#color-contrast ++ var rgb = this.toRgb(); ++ return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000; ++ }, ++ getLuminance: function() { ++ //http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef ++ var rgb = this.toRgb(); ++ var RsRGB, GsRGB, BsRGB, R, G, B; ++ RsRGB = rgb.r/255; ++ GsRGB = rgb.g/255; ++ BsRGB = rgb.b/255; ++ ++ if (RsRGB <= 0.03928) {R = RsRGB / 12.92;} else {R = Math.pow(((RsRGB + 0.055) / 1.055), 2.4);} ++ if (GsRGB <= 0.03928) {G = GsRGB / 12.92;} else {G = Math.pow(((GsRGB + 0.055) / 1.055), 2.4);} ++ if (BsRGB <= 0.03928) {B = BsRGB / 12.92;} else {B = Math.pow(((BsRGB + 0.055) / 1.055), 2.4);} ++ return (0.2126 * R) + (0.7152 * G) + (0.0722 * B); ++ }, ++ setAlpha: function(value) { ++ this._a = boundAlpha(value); ++ this._roundA = mathRound(100*this._a) / 100; ++ return this; ++ }, ++ toHsv: function() { ++ var hsv = rgbToHsv(this._r, this._g, this._b); ++ return { h: hsv.h * 360, s: hsv.s, v: hsv.v, a: this._a }; ++ }, ++ toHsvString: function() { ++ var hsv = rgbToHsv(this._r, this._g, this._b); ++ var h = mathRound(hsv.h * 360), s = mathRound(hsv.s * 100), v = mathRound(hsv.v * 100); ++ return (this._a == 1) ? ++ "hsv(" + h + ", " + s + "%, " + v + "%)" : ++ "hsva(" + h + ", " + s + "%, " + v + "%, "+ this._roundA + ")"; ++ }, ++ toHsl: function() { ++ var hsl = rgbToHsl(this._r, this._g, this._b); ++ return { h: hsl.h * 360, s: hsl.s, l: hsl.l, a: this._a }; ++ }, ++ toHslString: function() { ++ var hsl = rgbToHsl(this._r, this._g, this._b); ++ var h = mathRound(hsl.h * 360), s = mathRound(hsl.s * 100), l = mathRound(hsl.l * 100); ++ return (this._a == 1) ? ++ "hsl(" + h + ", " + s + "%, " + l + "%)" : ++ "hsla(" + h + ", " + s + "%, " + l + "%, "+ this._roundA + ")"; ++ }, ++ toHex: function(allow3Char) { ++ return rgbToHex(this._r, this._g, this._b, allow3Char); ++ }, ++ toHexString: function(allow3Char) { ++ return '#' + this.toHex(allow3Char); ++ }, ++ toHex8: function(allow4Char) { ++ return rgbaToHex(this._r, this._g, this._b, this._a, allow4Char); ++ }, ++ toHex8String: function(allow4Char) { ++ return '#' + this.toHex8(allow4Char); ++ }, ++ toRgb: function() { ++ return { r: mathRound(this._r), g: mathRound(this._g), b: mathRound(this._b), a: this._a }; ++ }, ++ toRgbString: function() { ++ return (this._a == 1) ? ++ "rgb(" + mathRound(this._r) + ", " + mathRound(this._g) + ", " + mathRound(this._b) + ")" : ++ "rgba(" + mathRound(this._r) + ", " + mathRound(this._g) + ", " + mathRound(this._b) + ", " + this._roundA + ")"; ++ }, ++ toPercentageRgb: function() { ++ return { r: mathRound(bound01(this._r, 255) * 100) + "%", g: mathRound(bound01(this._g, 255) * 100) + "%", b: mathRound(bound01(this._b, 255) * 100) + "%", a: this._a }; ++ }, ++ toPercentageRgbString: function() { ++ return (this._a == 1) ? ++ "rgb(" + mathRound(bound01(this._r, 255) * 100) + "%, " + mathRound(bound01(this._g, 255) * 100) + "%, " + mathRound(bound01(this._b, 255) * 100) + "%)" : ++ "rgba(" + mathRound(bound01(this._r, 255) * 100) + "%, " + mathRound(bound01(this._g, 255) * 100) + "%, " + mathRound(bound01(this._b, 255) * 100) + "%, " + this._roundA + ")"; ++ }, ++ toName: function() { ++ if (this._a === 0) { ++ return "transparent"; ++ } ++ ++ if (this._a < 1) { ++ return false; ++ } ++ ++ return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false; ++ }, ++ toFilter: function(secondColor) { ++ var hex8String = '#' + rgbaToArgbHex(this._r, this._g, this._b, this._a); ++ var secondHex8String = hex8String; ++ var gradientType = this._gradientType ? "GradientType = 1, " : ""; ++ ++ if (secondColor) { ++ var s = tinycolor(secondColor); ++ secondHex8String = '#' + rgbaToArgbHex(s._r, s._g, s._b, s._a); ++ } ++ ++ return "progid:DXImageTransform.Microsoft.gradient("+gradientType+"startColorstr="+hex8String+",endColorstr="+secondHex8String+")"; ++ }, ++ toString: function(format) { ++ var formatSet = !!format; ++ format = format || this._format; ++ ++ var formattedString = false; ++ var hasAlpha = this._a < 1 && this._a >= 0; ++ var needsAlphaFormat = !formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "hex4" || format === "hex8" || format === "name"); ++ ++ if (needsAlphaFormat) { ++ // Special case for "transparent", all other non-alpha formats ++ // will return rgba when there is transparency. ++ if (format === "name" && this._a === 0) { ++ return this.toName(); ++ } ++ return this.toRgbString(); ++ } ++ if (format === "rgb") { ++ formattedString = this.toRgbString(); ++ } ++ if (format === "prgb") { ++ formattedString = this.toPercentageRgbString(); ++ } ++ if (format === "hex" || format === "hex6") { ++ formattedString = this.toHexString(); ++ } ++ if (format === "hex3") { ++ formattedString = this.toHexString(true); ++ } ++ if (format === "hex4") { ++ formattedString = this.toHex8String(true); ++ } ++ if (format === "hex8") { ++ formattedString = this.toHex8String(); ++ } ++ if (format === "name") { ++ formattedString = this.toName(); ++ } ++ if (format === "hsl") { ++ formattedString = this.toHslString(); ++ } ++ if (format === "hsv") { ++ formattedString = this.toHsvString(); ++ } ++ ++ return formattedString || this.toHexString(); ++ }, ++ clone: function() { ++ return tinycolor(this.toString()); ++ }, ++ ++ _applyModification: function(fn, args) { ++ var color = fn.apply(null, [this].concat([].slice.call(args))); ++ this._r = color._r; ++ this._g = color._g; ++ this._b = color._b; ++ this.setAlpha(color._a); ++ return this; ++ }, ++ lighten: function() { ++ return this._applyModification(lighten, arguments); ++ }, ++ brighten: function() { ++ return this._applyModification(brighten, arguments); ++ }, ++ darken: function() { ++ return this._applyModification(darken, arguments); ++ }, ++ desaturate: function() { ++ return this._applyModification(desaturate, arguments); ++ }, ++ saturate: function() { ++ return this._applyModification(saturate, arguments); ++ }, ++ greyscale: function() { ++ return this._applyModification(greyscale, arguments); ++ }, ++ spin: function() { ++ return this._applyModification(spin, arguments); ++ }, ++ ++ _applyCombination: function(fn, args) { ++ return fn.apply(null, [this].concat([].slice.call(args))); ++ }, ++ analogous: function() { ++ return this._applyCombination(analogous, arguments); ++ }, ++ complement: function() { ++ return this._applyCombination(complement, arguments); ++ }, ++ monochromatic: function() { ++ return this._applyCombination(monochromatic, arguments); ++ }, ++ splitcomplement: function() { ++ return this._applyCombination(splitcomplement, arguments); ++ }, ++ triad: function() { ++ return this._applyCombination(triad, arguments); ++ }, ++ tetrad: function() { ++ return this._applyCombination(tetrad, arguments); + } +- return new RedBlackTreeIterator(this, stack) +- } +-}) ++}; + +-//Find the ith item in the tree +-proto.at = function(idx) { +- if(idx < 0) { +- return new RedBlackTreeIterator(this, []) +- } +- var n = this.root +- var stack = [] +- while(true) { +- stack.push(n) +- if(n.left) { +- if(idx < n.left._count) { +- n = n.left +- continue +- } +- idx -= n.left._count ++// If input is an object, force 1 into "1.0" to handle ratios properly ++// String input requires "1.0" as input, so 1 will be treated as 1 ++tinycolor.fromRatio = function(color, opts) { ++ if (typeof color == "object") { ++ var newColor = {}; ++ for (var i in color) { ++ if (color.hasOwnProperty(i)) { ++ if (i === "a") { ++ newColor[i] = color[i]; ++ } ++ else { ++ newColor[i] = convertToPercentage(color[i]); ++ } ++ } ++ } ++ color = newColor; + } +- if(!idx) { +- return new RedBlackTreeIterator(this, stack) ++ ++ return tinycolor(color, opts); ++}; ++ ++// Given a string or object, convert that input to RGB ++// Possible string inputs: ++// ++// "red" ++// "#f00" or "f00" ++// "#ff0000" or "ff0000" ++// "#ff000000" or "ff000000" ++// "rgb 255 0 0" or "rgb (255, 0, 0)" ++// "rgb 1.0 0 0" or "rgb (1, 0, 0)" ++// "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1" ++// "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1" ++// "hsl(0, 100%, 50%)" or "hsl 0 100% 50%" ++// "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1" ++// "hsv(0, 100%, 100%)" or "hsv 0 100% 100%" ++// ++function inputToRGB(color) { ++ ++ var rgb = { r: 0, g: 0, b: 0 }; ++ var a = 1; ++ var s = null; ++ var v = null; ++ var l = null; ++ var ok = false; ++ var format = false; ++ ++ if (typeof color == "string") { ++ color = stringInputToObject(color); + } +- idx -= 1 +- if(n.right) { +- if(idx >= n.right._count) { +- break +- } +- n = n.right +- } else { +- break ++ ++ if (typeof color == "object") { ++ if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) { ++ rgb = rgbToRgb(color.r, color.g, color.b); ++ ok = true; ++ format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb"; ++ } ++ else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) { ++ s = convertToPercentage(color.s); ++ v = convertToPercentage(color.v); ++ rgb = hsvToRgb(color.h, s, v); ++ ok = true; ++ format = "hsv"; ++ } ++ else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) { ++ s = convertToPercentage(color.s); ++ l = convertToPercentage(color.l); ++ rgb = hslToRgb(color.h, s, l); ++ ok = true; ++ format = "hsl"; ++ } ++ ++ if (color.hasOwnProperty("a")) { ++ a = color.a; ++ } + } +- } +- return new RedBlackTreeIterator(this, []) ++ ++ a = boundAlpha(a); ++ ++ return { ++ ok: ok, ++ format: color.format || format, ++ r: mathMin(255, mathMax(rgb.r, 0)), ++ g: mathMin(255, mathMax(rgb.g, 0)), ++ b: mathMin(255, mathMax(rgb.b, 0)), ++ a: a ++ }; + } + +-proto.ge = function(key) { +- var cmp = this._compare +- var n = this.root +- var stack = [] +- var last_ptr = 0 +- while(n) { +- var d = cmp(key, n.key) +- stack.push(n) +- if(d <= 0) { +- last_ptr = stack.length +- } +- if(d <= 0) { +- n = n.left +- } else { +- n = n.right +- } +- } +- stack.length = last_ptr +- return new RedBlackTreeIterator(this, stack) ++ ++// Conversion Functions ++// -------------------- ++ ++// `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from: ++// ++ ++// `rgbToRgb` ++// Handle bounds / percentage checking to conform to CSS color spec ++// ++// *Assumes:* r, g, b in [0, 255] or [0, 1] ++// *Returns:* { r, g, b } in [0, 255] ++function rgbToRgb(r, g, b){ ++ return { ++ r: bound01(r, 255) * 255, ++ g: bound01(g, 255) * 255, ++ b: bound01(b, 255) * 255 ++ }; + } + +-proto.gt = function(key) { +- var cmp = this._compare +- var n = this.root +- var stack = [] +- var last_ptr = 0 +- while(n) { +- var d = cmp(key, n.key) +- stack.push(n) +- if(d < 0) { +- last_ptr = stack.length ++// `rgbToHsl` ++// Converts an RGB color value to HSL. ++// *Assumes:* r, g, and b are contained in [0, 255] or [0, 1] ++// *Returns:* { h, s, l } in [0,1] ++function rgbToHsl(r, g, b) { ++ ++ r = bound01(r, 255); ++ g = bound01(g, 255); ++ b = bound01(b, 255); ++ ++ var max = mathMax(r, g, b), min = mathMin(r, g, b); ++ var h, s, l = (max + min) / 2; ++ ++ if(max == min) { ++ h = s = 0; // achromatic + } +- if(d < 0) { +- n = n.left +- } else { +- n = n.right ++ else { ++ var d = max - min; ++ s = l > 0.5 ? d / (2 - max - min) : d / (max + min); ++ switch(max) { ++ case r: h = (g - b) / d + (g < b ? 6 : 0); break; ++ case g: h = (b - r) / d + 2; break; ++ case b: h = (r - g) / d + 4; break; ++ } ++ ++ h /= 6; + } +- } +- stack.length = last_ptr +- return new RedBlackTreeIterator(this, stack) ++ ++ return { h: h, s: s, l: l }; + } + +-proto.lt = function(key) { +- var cmp = this._compare +- var n = this.root +- var stack = [] +- var last_ptr = 0 +- while(n) { +- var d = cmp(key, n.key) +- stack.push(n) +- if(d > 0) { +- last_ptr = stack.length +- } +- if(d <= 0) { +- n = n.left +- } else { +- n = n.right ++// `hslToRgb` ++// Converts an HSL color value to RGB. ++// *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100] ++// *Returns:* { r, g, b } in the set [0, 255] ++function hslToRgb(h, s, l) { ++ var r, g, b; ++ ++ h = bound01(h, 360); ++ s = bound01(s, 100); ++ l = bound01(l, 100); ++ ++ function hue2rgb(p, q, t) { ++ if(t < 0) t += 1; ++ if(t > 1) t -= 1; ++ if(t < 1/6) return p + (q - p) * 6 * t; ++ if(t < 1/2) return q; ++ if(t < 2/3) return p + (q - p) * (2/3 - t) * 6; ++ return p; + } +- } +- stack.length = last_ptr +- return new RedBlackTreeIterator(this, stack) +-} + +-proto.le = function(key) { +- var cmp = this._compare +- var n = this.root +- var stack = [] +- var last_ptr = 0 +- while(n) { +- var d = cmp(key, n.key) +- stack.push(n) +- if(d >= 0) { +- last_ptr = stack.length ++ if(s === 0) { ++ r = g = b = l; // achromatic + } +- if(d < 0) { +- n = n.left +- } else { +- n = n.right ++ else { ++ var q = l < 0.5 ? l * (1 + s) : l + s - l * s; ++ var p = 2 * l - q; ++ r = hue2rgb(p, q, h + 1/3); ++ g = hue2rgb(p, q, h); ++ b = hue2rgb(p, q, h - 1/3); + } +- } +- stack.length = last_ptr +- return new RedBlackTreeIterator(this, stack) ++ ++ return { r: r * 255, g: g * 255, b: b * 255 }; + } + +-//Finds the item with key if it exists +-proto.find = function(key) { +- var cmp = this._compare +- var n = this.root +- var stack = [] +- while(n) { +- var d = cmp(key, n.key) +- stack.push(n) +- if(d === 0) { +- return new RedBlackTreeIterator(this, stack) ++// `rgbToHsv` ++// Converts an RGB color value to HSV ++// *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1] ++// *Returns:* { h, s, v } in [0,1] ++function rgbToHsv(r, g, b) { ++ ++ r = bound01(r, 255); ++ g = bound01(g, 255); ++ b = bound01(b, 255); ++ ++ var max = mathMax(r, g, b), min = mathMin(r, g, b); ++ var h, s, v = max; ++ ++ var d = max - min; ++ s = max === 0 ? 0 : d / max; ++ ++ if(max == min) { ++ h = 0; // achromatic + } +- if(d <= 0) { +- n = n.left +- } else { +- n = n.right ++ else { ++ switch(max) { ++ case r: h = (g - b) / d + (g < b ? 6 : 0); break; ++ case g: h = (b - r) / d + 2; break; ++ case b: h = (r - g) / d + 4; break; ++ } ++ h /= 6; + } +- } +- return new RedBlackTreeIterator(this, []) ++ return { h: h, s: s, v: v }; + } + +-//Removes item with key from tree +-proto.remove = function(key) { +- var iter = this.find(key) +- if(iter) { +- return iter.remove() +- } +- return this ++// `hsvToRgb` ++// Converts an HSV color value to RGB. ++// *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100] ++// *Returns:* { r, g, b } in the set [0, 255] ++ function hsvToRgb(h, s, v) { ++ ++ h = bound01(h, 360) * 6; ++ s = bound01(s, 100); ++ v = bound01(v, 100); ++ ++ var i = Math.floor(h), ++ f = h - i, ++ p = v * (1 - s), ++ q = v * (1 - f * s), ++ t = v * (1 - (1 - f) * s), ++ mod = i % 6, ++ r = [v, q, p, p, t, v][mod], ++ g = [t, v, v, q, p, p][mod], ++ b = [p, p, t, v, v, q][mod]; ++ ++ return { r: r * 255, g: g * 255, b: b * 255 }; + } + +-//Returns the item at `key` +-proto.get = function(key) { +- var cmp = this._compare +- var n = this.root +- while(n) { +- var d = cmp(key, n.key) +- if(d === 0) { +- return n.value +- } +- if(d <= 0) { +- n = n.left +- } else { +- n = n.right ++// `rgbToHex` ++// Converts an RGB color to hex ++// Assumes r, g, and b are contained in the set [0, 255] ++// Returns a 3 or 6 character hex ++function rgbToHex(r, g, b, allow3Char) { ++ ++ var hex = [ ++ pad2(mathRound(r).toString(16)), ++ pad2(mathRound(g).toString(16)), ++ pad2(mathRound(b).toString(16)) ++ ]; ++ ++ // Return a 3 character hex if possible ++ if (allow3Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1)) { ++ return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0); + } +- } +- return +-} + +-//Iterator for red black tree +-function RedBlackTreeIterator(tree, stack) { +- this.tree = tree +- this._stack = stack ++ return hex.join(""); + } + +-var iproto = RedBlackTreeIterator.prototype ++// `rgbaToHex` ++// Converts an RGBA color plus alpha transparency to hex ++// Assumes r, g, b are contained in the set [0, 255] and ++// a in [0, 1]. Returns a 4 or 8 character rgba hex ++function rgbaToHex(r, g, b, a, allow4Char) { + +-//Test if iterator is valid +-Object.defineProperty(iproto, "valid", { +- get: function() { +- return this._stack.length > 0 +- } +-}) ++ var hex = [ ++ pad2(mathRound(r).toString(16)), ++ pad2(mathRound(g).toString(16)), ++ pad2(mathRound(b).toString(16)), ++ pad2(convertDecimalToHex(a)) ++ ]; + +-//Node of the iterator +-Object.defineProperty(iproto, "node", { +- get: function() { +- if(this._stack.length > 0) { +- return this._stack[this._stack.length-1] ++ // Return a 4 character hex if possible ++ if (allow4Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1) && hex[3].charAt(0) == hex[3].charAt(1)) { ++ return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0); + } +- return null +- }, +- enumerable: true +-}) + +-//Makes a copy of an iterator +-iproto.clone = function() { +- return new RedBlackTreeIterator(this.tree, this._stack.slice()) ++ return hex.join(""); + } + +-//Swaps two nodes +-function swapNode(n, v) { +- n.key = v.key +- n.value = v.value +- n.left = v.left +- n.right = v.right +- n._color = v._color +- n._count = v._count ++// `rgbaToArgbHex` ++// Converts an RGBA color to an ARGB Hex8 string ++// Rarely used, but required for "toFilter()" ++function rgbaToArgbHex(r, g, b, a) { ++ ++ var hex = [ ++ pad2(convertDecimalToHex(a)), ++ pad2(mathRound(r).toString(16)), ++ pad2(mathRound(g).toString(16)), ++ pad2(mathRound(b).toString(16)) ++ ]; ++ ++ return hex.join(""); + } + +-//Fix up a double black node in a tree +-function fixDoubleBlack(stack) { +- var n, p, s, z +- for(var i=stack.length-1; i>=0; --i) { +- n = stack[i] +- if(i === 0) { +- n._color = BLACK +- return +- } +- //console.log("visit node:", n.key, i, stack[i].key, stack[i-1].key) +- p = stack[i-1] +- if(p.left === n) { +- //console.log("left child") +- s = p.right +- if(s.right && s.right._color === RED) { +- //console.log("case 1: right sibling child red") +- s = p.right = cloneNode(s) +- z = s.right = cloneNode(s.right) +- p.right = s.left +- s.left = p +- s.right = z +- s._color = p._color +- n._color = BLACK +- p._color = BLACK +- z._color = BLACK +- recount(p) +- recount(s) +- if(i > 1) { +- var pp = stack[i-2] +- if(pp.left === p) { +- pp.left = s +- } else { +- pp.right = s +- } +- } +- stack[i-1] = s +- return +- } else if(s.left && s.left._color === RED) { +- //console.log("case 1: left sibling child red") +- s = p.right = cloneNode(s) +- z = s.left = cloneNode(s.left) +- p.right = z.left +- s.left = z.right +- z.left = p +- z.right = s +- z._color = p._color +- p._color = BLACK +- s._color = BLACK +- n._color = BLACK +- recount(p) +- recount(s) +- recount(z) +- if(i > 1) { +- var pp = stack[i-2] +- if(pp.left === p) { +- pp.left = z +- } else { +- pp.right = z +- } +- } +- stack[i-1] = z +- return +- } +- if(s._color === BLACK) { +- if(p._color === RED) { +- //console.log("case 2: black sibling, red parent", p.right.value) +- p._color = BLACK +- p.right = repaint(RED, s) +- return +- } else { +- //console.log("case 2: black sibling, black parent", p.right.value) +- p.right = repaint(RED, s) +- continue +- } +- } else { +- //console.log("case 3: red sibling") +- s = cloneNode(s) +- p.right = s.left +- s.left = p +- s._color = p._color +- p._color = RED +- recount(p) +- recount(s) +- if(i > 1) { +- var pp = stack[i-2] +- if(pp.left === p) { +- pp.left = s +- } else { +- pp.right = s +- } +- } +- stack[i-1] = s +- stack[i] = p +- if(i+1 < stack.length) { +- stack[i+1] = n +- } else { +- stack.push(n) +- } +- i = i+2 +- } +- } else { +- //console.log("right child") +- s = p.left +- if(s.left && s.left._color === RED) { +- //console.log("case 1: left sibling child red", p.value, p._color) +- s = p.left = cloneNode(s) +- z = s.left = cloneNode(s.left) +- p.left = s.right +- s.right = p +- s.left = z +- s._color = p._color +- n._color = BLACK +- p._color = BLACK +- z._color = BLACK +- recount(p) +- recount(s) +- if(i > 1) { +- var pp = stack[i-2] +- if(pp.right === p) { +- pp.right = s +- } else { +- pp.left = s +- } +- } +- stack[i-1] = s +- return +- } else if(s.right && s.right._color === RED) { +- //console.log("case 1: right sibling child red") +- s = p.left = cloneNode(s) +- z = s.right = cloneNode(s.right) +- p.left = z.right +- s.right = z.left +- z.right = p +- z.left = s +- z._color = p._color +- p._color = BLACK +- s._color = BLACK +- n._color = BLACK +- recount(p) +- recount(s) +- recount(z) +- if(i > 1) { +- var pp = stack[i-2] +- if(pp.right === p) { +- pp.right = z +- } else { +- pp.left = z +- } +- } +- stack[i-1] = z +- return +- } +- if(s._color === BLACK) { +- if(p._color === RED) { +- //console.log("case 2: black sibling, red parent") +- p._color = BLACK +- p.left = repaint(RED, s) +- return +- } else { +- //console.log("case 2: black sibling, black parent") +- p.left = repaint(RED, s) +- continue +- } +- } else { +- //console.log("case 3: red sibling") +- s = cloneNode(s) +- p.left = s.right +- s.right = p +- s._color = p._color +- p._color = RED +- recount(p) +- recount(s) +- if(i > 1) { +- var pp = stack[i-2] +- if(pp.right === p) { +- pp.right = s +- } else { +- pp.left = s +- } +- } +- stack[i-1] = s +- stack[i] = p +- if(i+1 < stack.length) { +- stack[i+1] = n +- } else { +- stack.push(n) +- } +- i = i+2 +- } ++// `equals` ++// Can be called with any tinycolor input ++tinycolor.equals = function (color1, color2) { ++ if (!color1 || !color2) { return false; } ++ return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString(); ++}; ++ ++tinycolor.random = function() { ++ return tinycolor.fromRatio({ ++ r: mathRandom(), ++ g: mathRandom(), ++ b: mathRandom() ++ }); ++}; ++ ++ ++// Modification Functions ++// ---------------------- ++// Thanks to less.js for some of the basics here ++// ++ ++function desaturate(color, amount) { ++ amount = (amount === 0) ? 0 : (amount || 10); ++ var hsl = tinycolor(color).toHsl(); ++ hsl.s -= amount / 100; ++ hsl.s = clamp01(hsl.s); ++ return tinycolor(hsl); ++} ++ ++function saturate(color, amount) { ++ amount = (amount === 0) ? 0 : (amount || 10); ++ var hsl = tinycolor(color).toHsl(); ++ hsl.s += amount / 100; ++ hsl.s = clamp01(hsl.s); ++ return tinycolor(hsl); ++} ++ ++function greyscale(color) { ++ return tinycolor(color).desaturate(100); ++} ++ ++function lighten (color, amount) { ++ amount = (amount === 0) ? 0 : (amount || 10); ++ var hsl = tinycolor(color).toHsl(); ++ hsl.l += amount / 100; ++ hsl.l = clamp01(hsl.l); ++ return tinycolor(hsl); ++} ++ ++function brighten(color, amount) { ++ amount = (amount === 0) ? 0 : (amount || 10); ++ var rgb = tinycolor(color).toRgb(); ++ rgb.r = mathMax(0, mathMin(255, rgb.r - mathRound(255 * - (amount / 100)))); ++ rgb.g = mathMax(0, mathMin(255, rgb.g - mathRound(255 * - (amount / 100)))); ++ rgb.b = mathMax(0, mathMin(255, rgb.b - mathRound(255 * - (amount / 100)))); ++ return tinycolor(rgb); ++} ++ ++function darken (color, amount) { ++ amount = (amount === 0) ? 0 : (amount || 10); ++ var hsl = tinycolor(color).toHsl(); ++ hsl.l -= amount / 100; ++ hsl.l = clamp01(hsl.l); ++ return tinycolor(hsl); ++} ++ ++// Spin takes a positive or negative amount within [-360, 360] indicating the change of hue. ++// Values outside of this range will be wrapped into this range. ++function spin(color, amount) { ++ var hsl = tinycolor(color).toHsl(); ++ var hue = (hsl.h + amount) % 360; ++ hsl.h = hue < 0 ? 360 + hue : hue; ++ return tinycolor(hsl); ++} ++ ++// Combination Functions ++// --------------------- ++// Thanks to jQuery xColor for some of the ideas behind these ++// ++ ++function complement(color) { ++ var hsl = tinycolor(color).toHsl(); ++ hsl.h = (hsl.h + 180) % 360; ++ return tinycolor(hsl); ++} ++ ++function triad(color) { ++ var hsl = tinycolor(color).toHsl(); ++ var h = hsl.h; ++ return [ ++ tinycolor(color), ++ tinycolor({ h: (h + 120) % 360, s: hsl.s, l: hsl.l }), ++ tinycolor({ h: (h + 240) % 360, s: hsl.s, l: hsl.l }) ++ ]; ++} ++ ++function tetrad(color) { ++ var hsl = tinycolor(color).toHsl(); ++ var h = hsl.h; ++ return [ ++ tinycolor(color), ++ tinycolor({ h: (h + 90) % 360, s: hsl.s, l: hsl.l }), ++ tinycolor({ h: (h + 180) % 360, s: hsl.s, l: hsl.l }), ++ tinycolor({ h: (h + 270) % 360, s: hsl.s, l: hsl.l }) ++ ]; ++} ++ ++function splitcomplement(color) { ++ var hsl = tinycolor(color).toHsl(); ++ var h = hsl.h; ++ return [ ++ tinycolor(color), ++ tinycolor({ h: (h + 72) % 360, s: hsl.s, l: hsl.l}), ++ tinycolor({ h: (h + 216) % 360, s: hsl.s, l: hsl.l}) ++ ]; ++} ++ ++function analogous(color, results, slices) { ++ results = results || 6; ++ slices = slices || 30; ++ ++ var hsl = tinycolor(color).toHsl(); ++ var part = 360 / slices; ++ var ret = [tinycolor(color)]; ++ ++ for (hsl.h = ((hsl.h - (part * results >> 1)) + 720) % 360; --results; ) { ++ hsl.h = (hsl.h + part) % 360; ++ ret.push(tinycolor(hsl)); + } +- } ++ return ret; + } + +-//Removes item at iterator from tree +-iproto.remove = function() { +- var stack = this._stack +- if(stack.length === 0) { +- return this.tree +- } +- //First copy path to node +- var cstack = new Array(stack.length) +- var n = stack[stack.length-1] +- cstack[cstack.length-1] = new RBNode(n._color, n.key, n.value, n.left, n.right, n._count) +- for(var i=stack.length-2; i>=0; --i) { +- var n = stack[i] +- if(n.left === stack[i+1]) { +- cstack[i] = new RBNode(n._color, n.key, n.value, cstack[i+1], n.right, n._count) +- } else { +- cstack[i] = new RBNode(n._color, n.key, n.value, n.left, cstack[i+1], n._count) ++function monochromatic(color, results) { ++ results = results || 6; ++ var hsv = tinycolor(color).toHsv(); ++ var h = hsv.h, s = hsv.s, v = hsv.v; ++ var ret = []; ++ var modification = 1 / results; ++ ++ while (results--) { ++ ret.push(tinycolor({ h: h, s: s, v: v})); ++ v = (v + modification) % 1; + } +- } + +- //Get node +- n = cstack[cstack.length-1] +- //console.log("start remove: ", n.value) ++ return ret; ++} + +- //If not leaf, then swap with previous node +- if(n.left && n.right) { +- //console.log("moving to leaf") ++// Utility Functions ++// --------------------- + +- //First walk to previous leaf +- var split = cstack.length +- n = n.left +- while(n.right) { +- cstack.push(n) +- n = n.right +- } +- //Copy path to leaf +- var v = cstack[split-1] +- cstack.push(new RBNode(n._color, v.key, v.value, n.left, n.right, n._count)) +- cstack[split-1].key = n.key +- cstack[split-1].value = n.value ++tinycolor.mix = function(color1, color2, amount) { ++ amount = (amount === 0) ? 0 : (amount || 50); + +- //Fix up stack +- for(var i=cstack.length-2; i>=split; --i) { +- n = cstack[i] +- cstack[i] = new RBNode(n._color, n.key, n.value, n.left, cstack[i+1], n._count) ++ var rgb1 = tinycolor(color1).toRgb(); ++ var rgb2 = tinycolor(color2).toRgb(); ++ ++ var p = amount / 100; ++ ++ var rgba = { ++ r: ((rgb2.r - rgb1.r) * p) + rgb1.r, ++ g: ((rgb2.g - rgb1.g) * p) + rgb1.g, ++ b: ((rgb2.b - rgb1.b) * p) + rgb1.b, ++ a: ((rgb2.a - rgb1.a) * p) + rgb1.a ++ }; ++ ++ return tinycolor(rgba); ++}; ++ ++ ++// Readability Functions ++// --------------------- ++// false ++// tinycolor.isReadable("#000", "#111",{level:"AA",size:"large"}) => false ++tinycolor.isReadable = function(color1, color2, wcag2) { ++ var readability = tinycolor.readability(color1, color2); ++ var wcag2Parms, out; ++ ++ out = false; ++ ++ wcag2Parms = validateWCAG2Parms(wcag2); ++ switch (wcag2Parms.level + wcag2Parms.size) { ++ case "AAsmall": ++ case "AAAlarge": ++ out = readability >= 4.5; ++ break; ++ case "AAlarge": ++ out = readability >= 3; ++ break; ++ case "AAAsmall": ++ out = readability >= 7; ++ break; + } +- cstack[split-1].left = cstack[split] +- } +- //console.log("stack=", cstack.map(function(v) { return v.value })) ++ return out; + +- //Remove leaf node +- n = cstack[cstack.length-1] +- if(n._color === RED) { +- //Easy case: removing red leaf +- //console.log("RED leaf") +- var p = cstack[cstack.length-2] +- if(p.left === n) { +- p.left = null +- } else if(p.right === n) { +- p.right = null ++}; ++ ++// `mostReadable` ++// Given a base color and a list of possible foreground or background ++// colors for that base, returns the most readable color. ++// Optionally returns Black or White if the most readable color is unreadable. ++// *Example* ++// tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:false}).toHexString(); // "#112255" ++// tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:true}).toHexString(); // "#ffffff" ++// tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"large"}).toHexString(); // "#faf3f3" ++// tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"small"}).toHexString(); // "#ffffff" ++tinycolor.mostReadable = function(baseColor, colorList, args) { ++ var bestColor = null; ++ var bestScore = 0; ++ var readability; ++ var includeFallbackColors, level, size ; ++ args = args || {}; ++ includeFallbackColors = args.includeFallbackColors ; ++ level = args.level; ++ size = args.size; ++ ++ for (var i= 0; i < colorList.length ; i++) { ++ readability = tinycolor.readability(baseColor, colorList[i]); ++ if (readability > bestScore) { ++ bestScore = readability; ++ bestColor = tinycolor(colorList[i]); ++ } + } +- cstack.pop() +- for(var i=0; i 0) { +- return this._stack[this._stack.length-1].key +- } +- return +- }, +- enumerable: true +-}) + +-//Returns value +-Object.defineProperty(iproto, "value", { +- get: function() { +- if(this._stack.length > 0) { +- return this._stack[this._stack.length-1].value +- } +- return +- }, +- enumerable: true +-}) ++// Big List of Colors ++// ------------------ ++// ++var names = tinycolor.names = { ++ aliceblue: "f0f8ff", ++ antiquewhite: "faebd7", ++ aqua: "0ff", ++ aquamarine: "7fffd4", ++ azure: "f0ffff", ++ beige: "f5f5dc", ++ bisque: "ffe4c4", ++ black: "000", ++ blanchedalmond: "ffebcd", ++ blue: "00f", ++ blueviolet: "8a2be2", ++ brown: "a52a2a", ++ burlywood: "deb887", ++ burntsienna: "ea7e5d", ++ cadetblue: "5f9ea0", ++ chartreuse: "7fff00", ++ chocolate: "d2691e", ++ coral: "ff7f50", ++ cornflowerblue: "6495ed", ++ cornsilk: "fff8dc", ++ crimson: "dc143c", ++ cyan: "0ff", ++ darkblue: "00008b", ++ darkcyan: "008b8b", ++ darkgoldenrod: "b8860b", ++ darkgray: "a9a9a9", ++ darkgreen: "006400", ++ darkgrey: "a9a9a9", ++ darkkhaki: "bdb76b", ++ darkmagenta: "8b008b", ++ darkolivegreen: "556b2f", ++ darkorange: "ff8c00", ++ darkorchid: "9932cc", ++ darkred: "8b0000", ++ darksalmon: "e9967a", ++ darkseagreen: "8fbc8f", ++ darkslateblue: "483d8b", ++ darkslategray: "2f4f4f", ++ darkslategrey: "2f4f4f", ++ darkturquoise: "00ced1", ++ darkviolet: "9400d3", ++ deeppink: "ff1493", ++ deepskyblue: "00bfff", ++ dimgray: "696969", ++ dimgrey: "696969", ++ dodgerblue: "1e90ff", ++ firebrick: "b22222", ++ floralwhite: "fffaf0", ++ forestgreen: "228b22", ++ fuchsia: "f0f", ++ gainsboro: "dcdcdc", ++ ghostwhite: "f8f8ff", ++ gold: "ffd700", ++ goldenrod: "daa520", ++ gray: "808080", ++ green: "008000", ++ greenyellow: "adff2f", ++ grey: "808080", ++ honeydew: "f0fff0", ++ hotpink: "ff69b4", ++ indianred: "cd5c5c", ++ indigo: "4b0082", ++ ivory: "fffff0", ++ khaki: "f0e68c", ++ lavender: "e6e6fa", ++ lavenderblush: "fff0f5", ++ lawngreen: "7cfc00", ++ lemonchiffon: "fffacd", ++ lightblue: "add8e6", ++ lightcoral: "f08080", ++ lightcyan: "e0ffff", ++ lightgoldenrodyellow: "fafad2", ++ lightgray: "d3d3d3", ++ lightgreen: "90ee90", ++ lightgrey: "d3d3d3", ++ lightpink: "ffb6c1", ++ lightsalmon: "ffa07a", ++ lightseagreen: "20b2aa", ++ lightskyblue: "87cefa", ++ lightslategray: "789", ++ lightslategrey: "789", ++ lightsteelblue: "b0c4de", ++ lightyellow: "ffffe0", ++ lime: "0f0", ++ limegreen: "32cd32", ++ linen: "faf0e6", ++ magenta: "f0f", ++ maroon: "800000", ++ mediumaquamarine: "66cdaa", ++ mediumblue: "0000cd", ++ mediumorchid: "ba55d3", ++ mediumpurple: "9370db", ++ mediumseagreen: "3cb371", ++ mediumslateblue: "7b68ee", ++ mediumspringgreen: "00fa9a", ++ mediumturquoise: "48d1cc", ++ mediumvioletred: "c71585", ++ midnightblue: "191970", ++ mintcream: "f5fffa", ++ mistyrose: "ffe4e1", ++ moccasin: "ffe4b5", ++ navajowhite: "ffdead", ++ navy: "000080", ++ oldlace: "fdf5e6", ++ olive: "808000", ++ olivedrab: "6b8e23", ++ orange: "ffa500", ++ orangered: "ff4500", ++ orchid: "da70d6", ++ palegoldenrod: "eee8aa", ++ palegreen: "98fb98", ++ paleturquoise: "afeeee", ++ palevioletred: "db7093", ++ papayawhip: "ffefd5", ++ peachpuff: "ffdab9", ++ peru: "cd853f", ++ pink: "ffc0cb", ++ plum: "dda0dd", ++ powderblue: "b0e0e6", ++ purple: "800080", ++ rebeccapurple: "663399", ++ red: "f00", ++ rosybrown: "bc8f8f", ++ royalblue: "4169e1", ++ saddlebrown: "8b4513", ++ salmon: "fa8072", ++ sandybrown: "f4a460", ++ seagreen: "2e8b57", ++ seashell: "fff5ee", ++ sienna: "a0522d", ++ silver: "c0c0c0", ++ skyblue: "87ceeb", ++ slateblue: "6a5acd", ++ slategray: "708090", ++ slategrey: "708090", ++ snow: "fffafa", ++ springgreen: "00ff7f", ++ steelblue: "4682b4", ++ tan: "d2b48c", ++ teal: "008080", ++ thistle: "d8bfd8", ++ tomato: "ff6347", ++ turquoise: "40e0d0", ++ violet: "ee82ee", ++ wheat: "f5deb3", ++ white: "fff", ++ whitesmoke: "f5f5f5", ++ yellow: "ff0", ++ yellowgreen: "9acd32" ++}; + ++// Make it easy to access colors via `hexNames[hex]` ++var hexNames = tinycolor.hexNames = flip(names); + +-//Returns the position of this iterator in the sorted list +-Object.defineProperty(iproto, "index", { +- get: function() { +- var idx = 0 +- var stack = this._stack +- if(stack.length === 0) { +- var r = this.tree.root +- if(r) { +- return r._count +- } +- return 0 +- } else if(stack[stack.length-1].left) { +- idx = stack[stack.length-1].left._count +- } +- for(var s=stack.length-2; s>=0; --s) { +- if(stack[s+1] === stack[s].right) { +- ++idx +- if(stack[s].left) { +- idx += stack[s].left._count ++ ++// Utilities ++// --------- ++ ++// `{ 'name1': 'val1' }` becomes `{ 'val1': 'name1' }` ++function flip(o) { ++ var flipped = { }; ++ for (var i in o) { ++ if (o.hasOwnProperty(i)) { ++ flipped[o[i]] = i; + } +- } + } +- return idx +- }, +- enumerable: true +-}) ++ return flipped; ++} + +-//Advances iterator to next element in list +-iproto.next = function() { +- var stack = this._stack +- if(stack.length === 0) { +- return +- } +- var n = stack[stack.length-1] +- if(n.right) { +- n = n.right +- while(n) { +- stack.push(n) +- n = n.left +- } +- } else { +- stack.pop() +- while(stack.length > 0 && stack[stack.length-1].right === n) { +- n = stack[stack.length-1] +- stack.pop() ++// Return a valid alpha value [0,1] with all invalid values being set to 1 ++function boundAlpha(a) { ++ a = parseFloat(a); ++ ++ if (isNaN(a) || a < 0 || a > 1) { ++ a = 1; + } +- } ++ ++ return a; + } + +-//Checks if iterator is at end of tree +-Object.defineProperty(iproto, "hasNext", { +- get: function() { +- var stack = this._stack +- if(stack.length === 0) { +- return false +- } +- if(stack[stack.length-1].right) { +- return true +- } +- for(var s=stack.length-1; s>0; --s) { +- if(stack[s-1].left === stack[s]) { +- return true +- } ++// Take input from [0, n] and return it as [0, 1] ++function bound01(n, max) { ++ if (isOnePointZero(n)) { n = "100%"; } ++ ++ var processPercent = isPercentage(n); ++ n = mathMin(max, mathMax(0, parseFloat(n))); ++ ++ // Automatically convert percentage into number ++ if (processPercent) { ++ n = parseInt(n * max, 10) / 100; + } +- return false +- } +-}) + +-//Update value +-iproto.update = function(value) { +- var stack = this._stack +- if(stack.length === 0) { +- throw new Error("Can't update empty node!") +- } +- var cstack = new Array(stack.length) +- var n = stack[stack.length-1] +- cstack[cstack.length-1] = new RBNode(n._color, n.key, value, n.left, n.right, n._count) +- for(var i=stack.length-2; i>=0; --i) { +- n = stack[i] +- if(n.left === stack[i+1]) { +- cstack[i] = new RBNode(n._color, n.key, n.value, cstack[i+1], n.right, n._count) +- } else { +- cstack[i] = new RBNode(n._color, n.key, n.value, n.left, cstack[i+1], n._count) ++ // Handle floating point rounding errors ++ if ((Math.abs(n - max) < 0.000001)) { ++ return 1; + } +- } +- return new RedBlackTree(this.tree._compare, cstack[0]) ++ ++ // Convert into [0, 1] range if it isn't already ++ return (n % max) / parseFloat(max); + } + +-//Moves iterator backward one element +-iproto.prev = function() { +- var stack = this._stack +- if(stack.length === 0) { +- return +- } +- var n = stack[stack.length-1] +- if(n.left) { +- n = n.left +- while(n) { +- stack.push(n) +- n = n.right +- } +- } else { +- stack.pop() +- while(stack.length > 0 && stack[stack.length-1].left === n) { +- n = stack[stack.length-1] +- stack.pop() +- } +- } ++// Force a number between 0 and 1 ++function clamp01(val) { ++ return mathMin(1, mathMax(0, val)); + } + +-//Checks if iterator is at start of tree +-Object.defineProperty(iproto, "hasPrev", { +- get: function() { +- var stack = this._stack +- if(stack.length === 0) { +- return false +- } +- if(stack[stack.length-1].left) { +- return true +- } +- for(var s=stack.length-1; s>0; --s) { +- if(stack[s-1].right === stack[s]) { +- return true +- } +- } +- return false +- } +-}) ++// Parse a base-16 hex value into a base-10 integer ++function parseIntFromHex(val) { ++ return parseInt(val, 16); ++} + +-//Default comparison function +-function defaultCompare(a, b) { +- if(a < b) { +- return -1 +- } +- if(a > b) { +- return 1 +- } +- return 0 ++// Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1 ++// ++function isOnePointZero(n) { ++ return typeof n == "string" && n.indexOf('.') != -1 && parseFloat(n) === 1; + } + +-//Build a tree +-function createRBTree(compare) { +- return new RedBlackTree(compare || defaultCompare, null) ++// Check to see if string passed in is a percentage ++function isPercentage(n) { ++ return typeof n === "string" && n.indexOf('%') != -1; + } +-},{}],165:[function(require,module,exports){ +-"use strict" + +-module.exports = createSlabDecomposition ++// Force a hex value to have 2 characters ++function pad2(c) { ++ return c.length == 1 ? '0' + c : '' + c; ++} + +-var bounds = require("binary-search-bounds") +-var createRBTree = require("functional-red-black-tree") +-var orient = require("robust-orientation") +-var orderSegments = require("./lib/order-segments") ++// Replace a decimal with it's percentage value ++function convertToPercentage(n) { ++ if (n <= 1) { ++ n = (n * 100) + "%"; ++ } + +-function SlabDecomposition(slabs, coordinates, horizontal) { +- this.slabs = slabs +- this.coordinates = coordinates +- this.horizontal = horizontal ++ return n; + } + +-var proto = SlabDecomposition.prototype ++// Converts a decimal to a hex value ++function convertDecimalToHex(d) { ++ return Math.round(parseFloat(d) * 255).toString(16); ++} ++// Converts a hex value to a decimal ++function convertHexToDecimal(h) { ++ return (parseIntFromHex(h) / 255); ++} + +-function compareHorizontal(e, y) { +- return e.y - y ++var matchers = (function() { ++ ++ // ++ var CSS_INTEGER = "[-\\+]?\\d+%?"; ++ ++ // ++ var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?"; ++ ++ // Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome. ++ var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")"; ++ ++ // Actual matching. ++ // Parentheses and commas are optional, but not required. ++ // Whitespace can take the place of commas or opening paren ++ var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?"; ++ var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?"; ++ ++ return { ++ CSS_UNIT: new RegExp(CSS_UNIT), ++ rgb: new RegExp("rgb" + PERMISSIVE_MATCH3), ++ rgba: new RegExp("rgba" + PERMISSIVE_MATCH4), ++ hsl: new RegExp("hsl" + PERMISSIVE_MATCH3), ++ hsla: new RegExp("hsla" + PERMISSIVE_MATCH4), ++ hsv: new RegExp("hsv" + PERMISSIVE_MATCH3), ++ hsva: new RegExp("hsva" + PERMISSIVE_MATCH4), ++ hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/, ++ hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/, ++ hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/, ++ hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/ ++ }; ++})(); ++ ++// `isValidCSSUnit` ++// Take in a single string / number and check to see if it looks like a CSS unit ++// (see `matchers` above for definition). ++function isValidCSSUnit(color) { ++ return !!matchers.CSS_UNIT.exec(color); + } + +-function searchBucket(root, p) { +- var lastNode = null +- while(root) { +- var seg = root.key +- var l, r +- if(seg[0][0] < seg[1][0]) { +- l = seg[0] +- r = seg[1] +- } else { +- l = seg[1] +- r = seg[0] ++// `stringInputToObject` ++// Permissive string parsing. Take in a number of formats, and output an object ++// based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}` ++function stringInputToObject(color) { ++ ++ color = color.replace(trimLeft,'').replace(trimRight, '').toLowerCase(); ++ var named = false; ++ if (names[color]) { ++ color = names[color]; ++ named = true; + } +- var o = orient(l, r, p) +- if(o < 0) { +- root = root.left +- } else if(o > 0) { +- if(p[0] !== seg[1][0]) { +- lastNode = root +- root = root.right +- } else { +- var val = searchBucket(root.right, p) +- if(val) { +- return val +- } +- root = root.left +- } +- } else { +- if(p[0] !== seg[1][0]) { +- return root +- } else { +- var val = searchBucket(root.right, p) +- if(val) { +- return val +- } +- root = root.left +- } ++ else if (color == 'transparent') { ++ return { r: 0, g: 0, b: 0, a: 0, format: "name" }; + } +- } +- return lastNode +-} + +-proto.castUp = function(p) { +- var bucket = bounds.le(this.coordinates, p[0]) +- if(bucket < 0) { +- return -1 +- } +- var root = this.slabs[bucket] +- var hitNode = searchBucket(this.slabs[bucket], p) +- var lastHit = -1 +- if(hitNode) { +- lastHit = hitNode.value +- } +- //Edge case: need to handle horizontal segments (sucks) +- if(this.coordinates[bucket] === p[0]) { +- var lastSegment = null +- if(hitNode) { +- lastSegment = hitNode.key ++ // Try to match string input using regular expressions. ++ // Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360] ++ // Just return an object and let the conversion functions handle that. ++ // This way the result will be the same whether the tinycolor is initialized with string or object. ++ var match; ++ if ((match = matchers.rgb.exec(color))) { ++ return { r: match[1], g: match[2], b: match[3] }; + } +- if(bucket > 0) { +- var otherHitNode = searchBucket(this.slabs[bucket-1], p) +- if(otherHitNode) { +- if(lastSegment) { +- if(orderSegments(otherHitNode.key, lastSegment) > 0) { +- lastSegment = otherHitNode.key +- lastHit = otherHitNode.value +- } +- } else { +- lastHit = otherHitNode.value +- lastSegment = otherHitNode.key +- } +- } ++ if ((match = matchers.rgba.exec(color))) { ++ return { r: match[1], g: match[2], b: match[3], a: match[4] }; + } +- var horiz = this.horizontal[bucket] +- if(horiz.length > 0) { +- var hbucket = bounds.ge(horiz, p[1], compareHorizontal) +- if(hbucket < horiz.length) { +- var e = horiz[hbucket] +- if(p[1] === e.y) { +- if(e.closed) { +- return e.index +- } else { +- while(hbucket < horiz.length-1 && horiz[hbucket+1].y === p[1]) { +- hbucket = hbucket+1 +- e = horiz[hbucket] +- if(e.closed) { +- return e.index +- } +- } +- if(e.y === p[1] && !e.start) { +- hbucket = hbucket+1 +- if(hbucket >= horiz.length) { +- return lastHit +- } +- e = horiz[hbucket] +- } +- } +- } +- //Check if e is above/below last segment +- if(e.start) { +- if(lastSegment) { +- var o = orient(lastSegment[0], lastSegment[1], [p[0], e.y]) +- if(lastSegment[0][0] > lastSegment[1][0]) { +- o = -o +- } +- if(o > 0) { +- lastHit = e.index +- } +- } else { +- lastHit = e.index +- } +- } else if(e.y !== p[1]) { +- lastHit = e.index +- } +- } ++ if ((match = matchers.hsl.exec(color))) { ++ return { h: match[1], s: match[2], l: match[3] }; + } +- } +- return lastHit ++ if ((match = matchers.hsla.exec(color))) { ++ return { h: match[1], s: match[2], l: match[3], a: match[4] }; ++ } ++ if ((match = matchers.hsv.exec(color))) { ++ return { h: match[1], s: match[2], v: match[3] }; ++ } ++ if ((match = matchers.hsva.exec(color))) { ++ return { h: match[1], s: match[2], v: match[3], a: match[4] }; ++ } ++ if ((match = matchers.hex8.exec(color))) { ++ return { ++ r: parseIntFromHex(match[1]), ++ g: parseIntFromHex(match[2]), ++ b: parseIntFromHex(match[3]), ++ a: convertHexToDecimal(match[4]), ++ format: named ? "name" : "hex8" ++ }; ++ } ++ if ((match = matchers.hex6.exec(color))) { ++ return { ++ r: parseIntFromHex(match[1]), ++ g: parseIntFromHex(match[2]), ++ b: parseIntFromHex(match[3]), ++ format: named ? "name" : "hex" ++ }; ++ } ++ if ((match = matchers.hex4.exec(color))) { ++ return { ++ r: parseIntFromHex(match[1] + '' + match[1]), ++ g: parseIntFromHex(match[2] + '' + match[2]), ++ b: parseIntFromHex(match[3] + '' + match[3]), ++ a: convertHexToDecimal(match[4] + '' + match[4]), ++ format: named ? "name" : "hex8" ++ }; ++ } ++ if ((match = matchers.hex3.exec(color))) { ++ return { ++ r: parseIntFromHex(match[1] + '' + match[1]), ++ g: parseIntFromHex(match[2] + '' + match[2]), ++ b: parseIntFromHex(match[3] + '' + match[3]), ++ format: named ? "name" : "hex" ++ }; ++ } ++ ++ return false; + } + +-function IntervalSegment(y, index, start, closed) { +- this.y = y +- this.index = index +- this.start = start +- this.closed = closed ++function validateWCAG2Parms(parms) { ++ // return valid WCAG2 parms for isReadable. ++ // If input parms are invalid, return {"level":"AA", "size":"small"} ++ var level, size; ++ parms = parms || {"level":"AA", "size":"small"}; ++ level = (parms.level || "AA").toUpperCase(); ++ size = (parms.size || "small").toLowerCase(); ++ if (level !== "AA" && level !== "AAA") { ++ level = "AA"; ++ } ++ if (size !== "small" && size !== "large") { ++ size = "small"; ++ } ++ return {"level":level, "size":size}; + } + +-function Event(x, segment, create, index) { +- this.x = x +- this.segment = segment +- this.create = create +- this.index = index ++// Node: Export function ++if (typeof module !== "undefined" && module.exports) { ++ module.exports = tinycolor; ++} ++// AMD/requirejs: Define the module ++else if (typeof define === 'function' && define.amd) { ++ define(function () {return tinycolor;}); ++} ++// Browser: Expose to window ++else { ++ window.tinycolor = tinycolor; + } + ++})(Math); + +-function createSlabDecomposition(segments) { +- var numSegments = segments.length +- var numEvents = 2 * numSegments +- var events = new Array(numEvents) +- for(var i=0; i 0 && coordinates[bucket] === p[0]) { +- root = slabs[bucket-1] +- } else { +- return 1 +- } ++module.exports = triangulateCube ++ ++var perm = require("permutation-rank") ++var sgn = require("permutation-parity") ++var gamma = require("gamma") ++ ++function triangulateCube(dimension) { ++ if(dimension < 0) { ++ return [ ] ++ } ++ if(dimension === 0) { ++ return [ [0] ] ++ } ++ var dfactorial = Math.round(gamma(dimension+1))|0 ++ var result = [] ++ for(var i=0; i 0) { +- lastOrientation = -1 +- root = root.right +- } else { +- return 0 +- } +- } else { +- if(o > 0) { +- root = root.left +- } else if(o < 0) { +- lastOrientation = 1 +- root = root.right +- } else { +- return 0 +- } +- } ++ if(sgn(p) < 1) { ++ cell[0] = v ++ cell[dimension] = 0 + } +- return lastOrientation ++ result.push(cell) + } ++ return result + } ++},{"gamma":62,"permutation-parity":127,"permutation-rank":128}],160:[function(require,module,exports){ ++"use strict" + +-function classifyEmpty(p) { +- return 1 +-} ++module.exports = twoProduct + +-function createClassifyVertical(testVertical) { +- return function classify(p) { +- if(testVertical(p[0], p[1])) { +- return 0 +- } +- return 1 ++var SPLITTER = +(Math.pow(2, 27) + 1.0) ++ ++function twoProduct(a, b, result) { ++ var x = a * b ++ ++ var c = SPLITTER * a ++ var abig = c - a ++ var ahi = c - abig ++ var alo = a - ahi ++ ++ var d = SPLITTER * b ++ var bbig = d - b ++ var bhi = d - bbig ++ var blo = b - bhi ++ ++ var err1 = x - (ahi * bhi) ++ var err2 = err1 - (alo * bhi) ++ var err3 = err2 - (ahi * blo) ++ ++ var y = alo * blo - err3 ++ ++ if(result) { ++ result[0] = y ++ result[1] = x ++ return result + } ++ ++ return [ y, x ] + } ++},{}],161:[function(require,module,exports){ ++"use strict" + +-function createClassifyPointDegen(testVertical, testNormal) { +- return function classify(p) { +- if(testVertical(p[0], p[1])) { +- return 0 +- } +- return testNormal(p) +- } ++module.exports = fastTwoSum ++ ++function fastTwoSum(a, b, result) { ++ var x = a + b ++ var bv = x - a ++ var av = x - bv ++ var br = b - bv ++ var ar = a - av ++ if(result) { ++ result[0] = ar + br ++ result[1] = x ++ return result ++ } ++ return [ar+br, x] + } ++},{}],162:[function(require,module,exports){ ++(function (global,Buffer){ ++'use strict' + +-function preprocessPolygon(loops) { +- //Compute number of loops +- var numLoops = loops.length ++var bits = require('bit-twiddle') ++var dup = require('dup') + +- //Unpack segments +- var segments = [] +- var vsegments = [] +- var ptr = 0 +- for(var i=0; i 0 ++function mallocArrayBuffer(n) { ++ var n = bits.nextPow2(n) ++ var log_n = bits.log2(n) ++ var d = DATA[log_n] ++ if(d.length > 0) { ++ return d.pop() + } ++ return new ArrayBuffer(n) ++} ++exports.mallocArrayBuffer = mallocArrayBuffer + +- //Extract all clockwise faces +- faces = faces.filter(ccw) ++function mallocUint8(n) { ++ return new Uint8Array(mallocArrayBuffer(n), 0, n) ++} ++exports.mallocUint8 = mallocUint8 + +- //Detect which loops are contained in one another to handle parent-of relation +- var numFaces = faces.length +- var parent = new Array(numFaces) +- var containment = new Array(numFaces) +- for(var i=0; i 0) { ++ return cache.pop() + } ++ return new Buffer(n) ++} ++exports.mallocBuffer = mallocBuffer + +- //Using face adjacency, classify faces as in/out +- var result = [] +- while(toVisit.length > 0) { +- var top = toVisit.pop() +- var nbhd = fadj[top] +- uniq(nbhd, function(a,b) { +- return a-b +- }) +- var nnbhr = nbhd.length +- var p = parity[top] +- var polyline +- if(p === 0) { +- var c = faces[top] +- polyline = [c] +- } +- for(var i=0; i= 0) { +- continue +- } +- parity[f] = p^1 +- toVisit.push(f) +- if(p === 0) { +- var c = faces[f] +- if(!sharedBoundary(c)) { +- c.reverse() +- polyline.push(c) +- } +- } +- } +- if(p === 0) { +- result.push(polyline) +- } ++exports.clearCache = function clearCache() { ++ for(var i=0; i<32; ++i) { ++ POOL.UINT8[i].length = 0 ++ POOL.UINT16[i].length = 0 ++ POOL.UINT32[i].length = 0 ++ POOL.INT8[i].length = 0 ++ POOL.INT16[i].length = 0 ++ POOL.INT32[i].length = 0 ++ POOL.FLOAT[i].length = 0 ++ POOL.DOUBLE[i].length = 0 ++ POOL.UINT8C[i].length = 0 ++ DATA[i].length = 0 ++ BUFFER[i].length = 0 + } +- +- return result + } +-},{"./lib/trim-leaves":155,"edges-to-adjacency-list":156,"planar-dual":157,"point-in-big-polygon":166,"robust-sum":136,"two-product":149,"uniq":152}],168:[function(require,module,exports){ +-arguments[4][9][0].apply(exports,arguments) +-},{"dup":9}],169:[function(require,module,exports){ ++}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer) ++},{"bit-twiddle":28,"buffer":37,"dup":56}],163:[function(require,module,exports){ + "use strict"; "use restrict"; + + module.exports = UnionFind; +@@ -34974,28 +35834,36 @@ function UnionFind(count) { + } + } + +-UnionFind.prototype.length = function() { +- return this.roots.length; +-} ++var proto = UnionFind.prototype + +-UnionFind.prototype.makeSet = function() { ++Object.defineProperty(proto, "length", { ++ "get": function() { ++ return this.roots.length ++ } ++}) ++ ++proto.makeSet = function() { + var n = this.roots.length; + this.roots.push(n); + this.ranks.push(0); + return n; + } + +-UnionFind.prototype.find = function(x) { ++proto.find = function(x) { ++ var x0 = x + var roots = this.roots; + while(roots[x] !== x) { +- var y = roots[x]; +- roots[x] = roots[y]; +- x = y; ++ x = roots[x] ++ } ++ while(roots[x0] !== x) { ++ var y = roots[x0] ++ roots[x0] = x ++ x0 = y + } + return x; + } + +-UnionFind.prototype.link = function(x, y) { ++proto.link = function(x, y) { + var xr = this.find(x) + , yr = this.find(y); + if(xr === yr) { +@@ -35014,625 +35882,433 @@ UnionFind.prototype.link = function(x, y) { + ++ranks[xr]; + } + } ++},{}],164:[function(require,module,exports){ ++"use strict" + +- +-},{}],170:[function(require,module,exports){ +-"use strict"; "use restrict"; +- +-var bits = require("bit-twiddle") +- , UnionFind = require("union-find") +- +-//Returns the dimension of a cell complex +-function dimension(cells) { +- var d = 0 +- , max = Math.max +- for(var i=0, il=cells.length; i> 1 +- , s = compareCells(cells[mid], c) +- if(s <= 0) { +- if(s === 0) { +- r = mid ++function unique_eq(list) { ++ var ptr = 1 ++ , len = list.length ++ , a=list[0], b = list[0] ++ for(var i=1; i 0) { +- hi = mid - 1 ++ list[ptr++] = a + } + } +- return r ++ list.length = ptr ++ return list + } +-exports.findCell = findCell; + +-//Builds an index for an n-cell. This is more general than dual, but less efficient +-function incidence(from_cells, to_cells) { +- var index = new Array(from_cells.length) +- for(var i=0, il=index.length; i= from_cells.length || compareCells(from_cells[idx], b) !== 0) { +- break +- } +- } ++ if(compare) { ++ if(!sorted) { ++ list.sort(compare) + } ++ return unique_pred(list, compare) + } +- return index ++ if(!sorted) { ++ list.sort() ++ } ++ return unique_eq(list) + } +-exports.incidence = incidence + +-//Computes the dual of the mesh. This is basically an optimized version of buildIndex for the situation where from_cells is just the list of vertices +-function dual(cells, vertex_count) { +- if(!vertex_count) { +- return incidence(unique(skeleton(cells, 0)), cells, 0) +- } +- var res = new Array(vertex_count) +- for(var i=0; i>> k) & 1) { +- b.push(c[k]) +- } +- } +- result.push(b) ++},{"./lib/vtext":166}],166:[function(require,module,exports){ ++"use strict" ++ ++module.exports = vectorizeText ++module.exports.processPixels = processPixels ++ ++var surfaceNets = require('surface-nets') ++var ndarray = require('ndarray') ++var simplify = require('simplify-planar-graph') ++var cleanPSLG = require('clean-pslg') ++var cdt2d = require('cdt2d') ++var toPolygonCrappy = require('planar-graph-to-polyline') ++ ++function transformPositions(positions, options, size) { ++ var align = options.textAlign || "start" ++ var baseline = options.textBaseline || "alphabetic" ++ ++ var lo = [1<<30, 1<<30] ++ var hi = [0,0] ++ var n = positions.length ++ for(var i=0; i 8192) { ++ throw new Error("vectorize-text: String too long (sorry, this will get fixed later)") + } +- return normalize(res) ++ var height = 3 * size ++ if(canvas.height < height) { ++ canvas.height = height ++ } ++ ++ context.fillStyle = "#000" ++ context.fillRect(0, 0, canvas.width, canvas.height) ++ ++ context.fillStyle = "#fff" ++ context.fillText(str, size, 2*size) ++ ++ //Cut pixels from image ++ var pixelData = context.getImageData(0, 0, width, height) ++ var pixels = ndarray(pixelData.data, [height, width, 4]) ++ ++ return pixels.pick(-1,-1,0).transpose(1,0) + } +-exports.boundary = boundary; + +-//Computes connected components for a dense cell complex +-function connectedComponents_dense(cells, vertex_count) { +- var labels = new UnionFind(vertex_count) +- for(var i=0; i> 1 +- } +- return (i >> 1) - 1 +- } ++},{"./hidden-store.js":168}],168:[function(require,module,exports){ ++module.exports = hiddenStore; + +- //Bubble element i down the heap +- function heapDown(i) { +- var w = heapWeight(i) +- while(true) { +- var tw = w +- var left = 2*i + 1 +- var right = 2*(i + 1) +- var next = i +- if(left < heapCount) { +- var lw = heapWeight(left) +- if(lw < tw) { +- next = left +- tw = lw +- } +- } +- if(right < heapCount) { +- var rw = heapWeight(right) +- if(rw < tw) { +- next = right +- } +- } +- if(next === i) { +- return i +- } +- heapSwap(i, next) +- i = next +- } +- } ++function hiddenStore(obj, key) { ++ var store = { identity: key }; ++ var valueOf = obj.valueOf; + +- //Bubbles element i up the heap +- function heapUp(i) { +- var w = heapWeight(i) +- while(i > 0) { +- var parent = heapParent(i) +- if(parent >= 0) { +- var pw = heapWeight(parent) +- if(w < pw) { +- heapSwap(i, parent) +- i = parent +- continue +- } +- } +- return i +- } +- } ++ Object.defineProperty(obj, "valueOf", { ++ value: function (value) { ++ return value !== key ? ++ valueOf.apply(this, arguments) : store; ++ }, ++ writable: true ++ }); + +- //Pop minimum element +- function heapPop() { +- if(heapCount > 0) { +- var head = heap[0] +- heapSwap(0, heapCount-1) +- heapCount -= 1 +- heapDown(0) +- return head +- } +- return -1 +- } ++ return store; ++} + +- //Update heap item i +- function heapUpdate(i, w) { +- var a = heap[i] +- if(weights[a] === w) { +- return i +- } +- weights[a] = -Infinity +- heapUp(i) +- heapPop() +- weights[a] = w +- heapCount += 1 +- return heapUp(heapCount-1) +- } ++},{}],169:[function(require,module,exports){ ++// Original - @Gozola. ++// https://gist.github.com/Gozala/1269991 ++// This is a reimplemented version (with a few bug fixes). + +- //Kills a vertex (assume vertex already removed from heap) +- function kill(i) { +- if(dead[i]) { +- return +- } +- //Kill vertex +- dead[i] = true +- //Fixup topology +- var s = inv[i] +- var t = outv[i] +- if(inv[t] >= 0) { +- inv[t] = s +- } +- if(outv[s] >= 0) { +- outv[s] = t +- } ++var createStore = require('./create-store.js'); + +- //Update weights on s and t +- if(index[s] >= 0) { +- heapUpdate(index[s], computeWeight(s)) +- } +- if(index[t] >= 0) { +- heapUpdate(index[t], computeWeight(t)) +- } +- } ++module.exports = weakMap; + +- //Initialize weights and heap +- var heap = [] +- var index = new Array(n) +- for(var i=0; i>1; i>=0; --i) { +- heapDown(i) +- } +- +- //Kill vertices +- while(true) { +- var hmin = heapPop() +- if((hmin < 0) || (weights[hmin] > minArea)) { +- break +- } +- kill(hmin) +- } ++function weakMap() { ++ var privates = createStore(); + +- //Build collapsed vertex table +- var npositions = [] +- for(var i=0; i= 0) !== (_inline_1_db >= 0)) {\n _inline_1_arg2_.push(_inline_1_arg4_[0] + 0.5 + 0.5 * (_inline_1_da + _inline_1_db) / (_inline_1_da - _inline_1_db))\n }\n }", ++ "args": [{ ++ "name": "_inline_1_arg0_", ++ "lvalue": false, ++ "rvalue": true, ++ "count": 1 ++ }, { ++ "name": "_inline_1_arg1_", ++ "lvalue": false, ++ "rvalue": true, ++ "count": 1 ++ }, { ++ "name": "_inline_1_arg2_", ++ "lvalue": false, ++ "rvalue": true, ++ "count": 1 ++ }, { ++ "name": "_inline_1_arg3_", ++ "lvalue": false, ++ "rvalue": true, ++ "count": 2 ++ }, { ++ "name": "_inline_1_arg4_", ++ "lvalue": false, ++ "rvalue": true, ++ "count": 1 ++ }], ++ "thisVars": [], ++ "localVars": ["_inline_1_da", "_inline_1_db"] ++ }, ++ funcName: 'zeroCrossings' ++}) + +- //Walk one step with t +- t = seq[t] +- } while(t !== h) +- //Compress cycles +- for(var v=start; v!==h; v = seq[v]) { +- seq[v] = h +- } +- return h +- } ++},{"cwise-compiler":50}],171:[function(require,module,exports){ ++"use strict" + +- var ncells = [] +- cells.forEach(function(c) { +- var tin = tortoiseHare(inv, c[0]) +- var tout = tortoiseHare(outv, c[1]) +- if(tin >= 0 && tout >= 0 && tin !== tout) { +- var cin = index[tin] +- var cout = index[tout] +- if(cin !== cout) { +- ncells.push([ cin, cout ]) +- } +- } +- }) ++module.exports = findZeroCrossings + +- //Normalize result +- sc.unique(sc.normalize(ncells)) ++var core = require("./lib/zc-core") + +- //Return final list of cells +- return { +- positions: npositions, +- edges: ncells +- } ++function findZeroCrossings(array, level) { ++ var cross = [] ++ level = +level || 0.0 ++ core(array.hi(array.shape[0]-1), cross, level) ++ return cross + } +-},{"robust-orientation":133,"simplicial-complex":170}],172:[function(require,module,exports){ ++},{"./lib/zc-core":170}],172:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -36896,7 +37572,7 @@ function lineIntersect(x1, y1, x2, y2, x3, y3, x4, y4) { + return {x: x1 + a * t, y: y1 + d * t}; + } + +-},{"../../lib":256,"../../lib/setcursor":265,"../../lib/svg_text_utils":269,"../../plotly":276,"../../plots/cartesian/axes":279,"../color":176,"../dragelement":197,"../drawing":199,"./arrow_paths":172,"./attributes":173,"d3":62,"fast-isnumeric":65}],175:[function(require,module,exports){ ++},{"../../lib":256,"../../lib/setcursor":265,"../../lib/svg_text_utils":269,"../../plotly":276,"../../plots/cartesian/axes":279,"../color":176,"../dragelement":197,"../drawing":199,"./arrow_paths":172,"./attributes":173,"d3":54,"fast-isnumeric":60}],175:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -37090,7 +37766,7 @@ function cleanOne(val) { + return 'rgb(' + rgbStr + ')'; + } + +-},{"./attributes":175,"fast-isnumeric":65,"tinycolor2":148}],177:[function(require,module,exports){ ++},{"./attributes":175,"fast-isnumeric":60,"tinycolor2":157}],177:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -37942,7 +38618,7 @@ module.exports = function draw(gd, id) { + return component; + }; + +-},{"../../lib":256,"../../lib/extend":253,"../../lib/setcursor":265,"../../plotly":276,"../../plots/cartesian/axes":279,"../../plots/cartesian/axis_defaults":280,"../../plots/cartesian/layout_attributes":288,"../../plots/cartesian/position_defaults":291,"../../plots/plots":303,"../color":176,"../dragelement":197,"../drawing":199,"../titles":239,"./attributes":177,"d3":62,"tinycolor2":148}],180:[function(require,module,exports){ ++},{"../../lib":256,"../../lib/extend":253,"../../lib/setcursor":265,"../../plotly":276,"../../plots/cartesian/axes":279,"../../plots/cartesian/axis_defaults":280,"../../plots/cartesian/layout_attributes":288,"../../plots/cartesian/position_defaults":291,"../../plots/plots":303,"../color":176,"../dragelement":197,"../drawing":199,"../titles":239,"./attributes":177,"d3":54,"tinycolor2":157}],180:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -38227,7 +38903,7 @@ module.exports = function colorScaleDefaults(traceIn, traceOut, layout, coerce, + if(showScale) colorbarDefaults(containerIn, containerOut, layout); + }; + +-},{"../../lib":256,"../colorbar/defaults":178,"../colorbar/has_colorbar":180,"./flip_scale":187,"./is_valid_scale":191,"fast-isnumeric":65}],187:[function(require,module,exports){ ++},{"../../lib":256,"../colorbar/defaults":178,"../colorbar/has_colorbar":180,"./flip_scale":187,"./is_valid_scale":191,"fast-isnumeric":60}],187:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -38338,7 +39014,7 @@ module.exports = function hasColorscale(trace, containerStr) { + ); + }; + +-},{"../../lib":256,"./is_valid_scale":191,"fast-isnumeric":65}],190:[function(require,module,exports){ ++},{"../../lib":256,"./is_valid_scale":191,"fast-isnumeric":60}],190:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -38428,7 +39104,7 @@ module.exports = function isValidScaleArray(scl) { + return true; + }; + +-},{"tinycolor2":148}],193:[function(require,module,exports){ ++},{"tinycolor2":157}],193:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -38477,7 +39153,7 @@ module.exports = function makeScaleFunction(scl, cmin, cmax) { + }; + }; + +-},{"../../lib":256,"../color":176,"d3":62,"fast-isnumeric":65,"tinycolor2":148}],194:[function(require,module,exports){ ++},{"../../lib":256,"../color":176,"d3":54,"fast-isnumeric":60,"tinycolor2":157}],194:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -39479,7 +40155,7 @@ drawing.setClipUrl = function(s, localId) { + s.attr('clip-path', 'url(' + url + ')'); + }; + +-},{"../../constants/xmlns_namespaces":247,"../../lib":256,"../../lib/svg_text_utils":269,"../../plots/plots":303,"../../traces/scatter/make_bubble_size_func":355,"../../traces/scatter/subtypes":360,"../color":176,"../colorscale":190,"./symbol_defs":200,"d3":62,"fast-isnumeric":65}],200:[function(require,module,exports){ ++},{"../../constants/xmlns_namespaces":247,"../../lib":256,"../../lib/svg_text_utils":269,"../../plots/plots":303,"../../traces/scatter/make_bubble_size_func":355,"../../traces/scatter/subtypes":360,"../color":176,"../colorscale":190,"./symbol_defs":200,"d3":54,"fast-isnumeric":60}],200:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -39955,7 +40631,7 @@ module.exports = { + } + }; + +-},{"d3":62}],201:[function(require,module,exports){ ++},{"d3":54}],201:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -40117,7 +40793,7 @@ function calcOneAxis(calcTrace, trace, axis, coord) { + Axes.expand(axis, vals, {padded: true}); + } + +-},{"../../plots/cartesian/axes":279,"../../plots/plots":303,"./compute_error":203,"fast-isnumeric":65}],203:[function(require,module,exports){ ++},{"../../plots/cartesian/axes":279,"../../plots/plots":303,"./compute_error":203,"fast-isnumeric":60}],203:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -40290,7 +40966,7 @@ module.exports = function(traceIn, traceOut, defaultColor, opts) { + } + }; + +-},{"../../lib":256,"../../plots/plots":303,"./attributes":201,"fast-isnumeric":65}],205:[function(require,module,exports){ ++},{"../../lib":256,"../../plots/plots":303,"./attributes":201,"fast-isnumeric":60}],205:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -40470,7 +41146,7 @@ function errorCoords(d, xa, ya) { + return out; + } + +-},{"../../lib":256,"../../traces/scatter/subtypes":360,"d3":62,"fast-isnumeric":65}],207:[function(require,module,exports){ ++},{"../../lib":256,"../../traces/scatter/subtypes":360,"d3":54,"fast-isnumeric":60}],207:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -40507,7 +41183,7 @@ module.exports = function style(traces) { + }); + }; + +-},{"../color":176,"d3":62}],208:[function(require,module,exports){ ++},{"../color":176,"d3":54}],208:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -40861,7 +41537,7 @@ module.exports = function draw(gd) { + imagesAbove.each(applyAttributes); + }; + +-},{"../../plots/cartesian/axes":279,"../drawing":199,"d3":62}],211:[function(require,module,exports){ ++},{"../../plots/cartesian/axes":279,"../drawing":199,"d3":54}],211:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -40978,6 +41654,13 @@ module.exports = { + + + }, ++ horizontalspacing: { ++ valType: 'enumerated', ++ values: ['column', 'wrapped'], ++ dflt: ['column'], ++ ++ ++ }, + traceorder: { + valType: 'flaglist', + flags: ['reversed', 'grouped'], +@@ -41067,6 +41750,7 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { + + var visibleTraces = 0, + defaultOrder = 'normal', ++ defaultHorizontalSpacing = 'column', + defaultX, + defaultY, + defaultXAnchor, +@@ -41131,6 +41815,7 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { + coerce('xanchor', defaultXAnchor); + coerce('y', defaultY); + coerce('yanchor', defaultYAnchor); ++ coerce('horizontalspacing', defaultHorizontalSpacing); + Lib.noneOrAll(containerIn, containerOut, ['x', 'y']); + }; + +@@ -41611,7 +42296,8 @@ function computeLegendDimensions(gd, groups, traces) { + var fullLayout = gd._fullLayout, + opts = fullLayout.legend, + borderwidth = opts.borderwidth, +- isGrouped = helpers.isGrouped(opts); ++ isGrouped = helpers.isGrouped(opts), ++ isHorizontalColumn = helpers.isHorizontalColumn(opts); + + if(helpers.isVertical(opts)) { + if(isGrouped) { +@@ -41718,7 +42404,7 @@ function computeLegendDimensions(gd, groups, traces) { + traces.each(function(d) { + + var legendItem = d[0], +- traceWidth = maxTraceWidth, ++ traceWidth = isHorizontalColumn ? maxTraceWidth : 40 + d[0], + traceGap = opts.tracegroupgap || 5; + + if((borderwidth + offsetX + traceGap + traceWidth) > (fullLayout.width - (fullLayout.margin.r + fullLayout.margin.l))) { +@@ -41807,7 +42493,7 @@ function expandHorizontalMargin(gd) { + }); + } + +-},{"../../lib":256,"../../plotly":276,"../../plots/plots":303,"../color":176,"../dragelement":197,"../drawing":199,"./anchor_utils":212,"./constants":214,"./get_legend_data":217,"./helpers":218,"./style":220,"d3":62}],217:[function(require,module,exports){ ++},{"../../lib":256,"../../plotly":276,"../../plots/plots":303,"../color":176,"../dragelement":197,"../drawing":199,"./anchor_utils":212,"./constants":214,"./get_legend_data":217,"./helpers":218,"./style":220,"d3":54}],217:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -41944,6 +42630,9 @@ exports.isReversed = function isReversed(legendLayout) { + return (legendLayout.traceorder || '').indexOf('reversed') !== -1; + }; + ++exports.isHorizontalColumn = function isReversed(legendLayout) { ++ return legendLayout.horizontalspacing === 'column'; ++}; + },{"../../plots/plots":303}],219:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. +@@ -42189,7 +42878,7 @@ function stylePies(d) { + if(pts.size()) pts.call(stylePie, d[0], trace); + } + +-},{"../../lib":256,"../../plots/plots":303,"../../traces/pie/style_one":339,"../../traces/scatter/subtypes":360,"../color":176,"../drawing":199,"d3":62}],221:[function(require,module,exports){ ++},{"../../lib":256,"../../plots/plots":303,"../../traces/pie/style_one":339,"../../traces/scatter/subtypes":360,"../color":176,"../drawing":199,"d3":54}],221:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -42987,7 +43676,7 @@ function createModeBar(gd, buttons) { + + module.exports = createModeBar; + +-},{"../../../build/ploticon":2,"../../lib":256,"d3":62}],223:[function(require,module,exports){ ++},{"../../../build/ploticon":2,"../../lib":256,"d3":54}],223:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -43741,7 +44430,7 @@ function reposition(gd, buttons, opts, axName) { + }); + } + +-},{"../../lib/svg_text_utils":269,"../../plotly":276,"../../plots/cartesian/axis_ids":281,"../../plots/plots":303,"../color":176,"../drawing":199,"../legend/anchor_utils":212,"./constants":226,"./get_update_object":229,"d3":62}],229:[function(require,module,exports){ ++},{"../../lib/svg_text_utils":269,"../../plotly":276,"../../plots/cartesian/axis_ids":281,"../../plots/plots":303,"../color":176,"../drawing":199,"../legend/anchor_utils":212,"./constants":226,"./get_update_object":229,"d3":54}],229:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -43799,7 +44488,7 @@ function getXRange(axisLayout, buttonLayout) { + return [range0, range1]; + } + +-},{"d3":62}],230:[function(require,module,exports){ ++},{"d3":54}],230:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -44488,7 +45177,7 @@ function makeScatter(trace, pointPairs, w, h) { + return [line, markers, fill]; + } + +-},{"../../constants/xmlns_namespaces":247,"../../lib":256,"../drawing":199,"../drawing/symbol_defs":200,"./helpers":234,"d3":62}],237:[function(require,module,exports){ ++},{"../../constants/xmlns_namespaces":247,"../../lib":256,"../drawing":199,"../drawing/symbol_defs":200,"./helpers":234,"d3":54}],237:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -45369,7 +46058,7 @@ function shapeBounds(ax, v0, v1, path, paramsToUse) { + if(max >= min) return [min, max]; + } + +-},{"../../lib":256,"../../lib/setcursor":265,"../../plotly":276,"../../plots/cartesian/axes":279,"../color":176,"../dragelement":197,"../drawing":199,"./attributes":237,"fast-isnumeric":65}],239:[function(require,module,exports){ ++},{"../../lib":256,"../../lib/setcursor":265,"../../plotly":276,"../../plots/cartesian/axes":279,"../color":176,"../dragelement":197,"../drawing":199,"./attributes":237,"fast-isnumeric":60}],239:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -45599,7 +46288,7 @@ Titles.draw = function(gd, titleClass, options) { + el.classed('js-placeholder', isplaceholder); + }; + +-},{"../../lib":256,"../../lib/svg_text_utils":269,"../../plotly":276,"../../plots/plots":303,"../color":176,"../drawing":199,"d3":62,"fast-isnumeric":65}],240:[function(require,module,exports){ ++},{"../../lib":256,"../../lib/svg_text_utils":269,"../../plotly":276,"../../plots/plots":303,"../color":176,"../drawing":199,"d3":54,"fast-isnumeric":60}],240:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -46347,7 +47036,7 @@ function clearPushMargins(gd) { + } + } + +-},{"../../lib":256,"../../lib/svg_text_utils":269,"../../plotly":276,"../../plots/plots":303,"../color":176,"../drawing":199,"../legend/anchor_utils":212,"./constants":241,"d3":62}],244:[function(require,module,exports){ ++},{"../../lib":256,"../../lib/svg_text_utils":269,"../../plotly":276,"../../plots/plots":303,"../color":176,"../drawing":199,"../legend/anchor_utils":212,"./constants":241,"d3":54}],244:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -46484,7 +47173,7 @@ exports.Queue = Plotly.Queue; + // export d3 used in the bundle + exports.d3 = require('d3'); + +-},{"../build/ploticon":2,"./plot_api/set_plot_config":273,"./plot_api/to_image":274,"./plot_api/validate":275,"./plotly":276,"./snapshot/download":310,"d3":62}],249:[function(require,module,exports){ ++},{"../build/ploticon":2,"./plot_api/set_plot_config":273,"./plot_api/to_image":274,"./plot_api/validate":275,"./plotly":276,"./snapshot/download":310,"d3":54}],249:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -46827,7 +47516,7 @@ exports.validate = function(value, opts) { + return out !== failed; + }; + +-},{"../components/colorscale/get_scale":188,"../components/colorscale/scales":194,"./nested_property":260,"fast-isnumeric":65,"tinycolor2":148}],251:[function(require,module,exports){ ++},{"../components/colorscale/get_scale":188,"../components/colorscale/scales":194,"./nested_property":260,"fast-isnumeric":60,"tinycolor2":157}],251:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -47166,7 +47855,7 @@ exports.parseDate = function(v) { + return out; + }; + +-},{"../lib":256,"d3":62,"fast-isnumeric":65}],252:[function(require,module,exports){ ++},{"../lib":256,"d3":54,"fast-isnumeric":60}],252:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -47300,7 +47989,7 @@ var Events = { + + module.exports = Events; + +-},{"events":14}],253:[function(require,module,exports){ ++},{"events":59}],253:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -47493,7 +48182,7 @@ function formatColor(containerIn, opacityIn, len) { + + module.exports = formatColor; + +-},{"../components/color/attributes":175,"../components/colorscale/make_scale_function":193,"./str2rgbarray":268,"fast-isnumeric":65,"tinycolor2":148}],255:[function(require,module,exports){ ++},{"../components/color/attributes":175,"../components/colorscale/make_scale_function":193,"./str2rgbarray":268,"fast-isnumeric":60,"tinycolor2":157}],255:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -47567,7 +48256,7 @@ function convertHTMLToUnicode(html) { + + module.exports = convertHTMLToUnicode; + +-},{"superscript-text":137}],256:[function(require,module,exports){ ++},{"superscript-text":154}],256:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -48187,7 +48876,7 @@ lib.numSeparate = function(value, separators) { + return x1 + x2; + }; + +-},{"./coerce":250,"./dates":251,"./extend":253,"./is_plain_object":257,"./loggers":258,"./matrix":259,"./nested_property":260,"./notifier":261,"./search":264,"./stats":267,"d3":62}],257:[function(require,module,exports){ ++},{"./coerce":250,"./dates":251,"./extend":253,"./is_plain_object":257,"./loggers":258,"./matrix":259,"./nested_property":260,"./notifier":261,"./search":264,"./stats":267,"d3":54}],257:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -48649,7 +49338,7 @@ function badContainer(container, propStr, propParts) { + }; + } + +-},{"fast-isnumeric":65}],261:[function(require,module,exports){ ++},{"fast-isnumeric":60}],261:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -48726,7 +49415,7 @@ module.exports = function(text, displayLength) { + }); + }; + +-},{"d3":62,"fast-isnumeric":65}],262:[function(require,module,exports){ ++},{"d3":54,"fast-isnumeric":60}],262:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -49289,7 +49978,7 @@ exports.roundUp = function(val, arrayIn, reverse) { + return arrayIn[low]; + }; + +-},{"../lib":256,"fast-isnumeric":65}],265:[function(require,module,exports){ ++},{"../lib":256,"fast-isnumeric":60}],265:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -49457,7 +50146,7 @@ exports.interp = function(arr, n) { + return frac * arr[Math.ceil(n)] + (1 - frac) * arr[Math.floor(n)]; + }; + +-},{"fast-isnumeric":65}],268:[function(require,module,exports){ ++},{"fast-isnumeric":60}],268:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -49479,7 +50168,7 @@ function str2RgbaArray(color) { + + module.exports = str2RgbaArray; + +-},{"arraytools":8,"tinycolor2":148}],269:[function(require,module,exports){ ++},{"arraytools":9,"tinycolor2":157}],269:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -49980,7 +50669,7 @@ util.makeEditable = function(context, _delegate, options) { + return d3.rebind(this, dispatch, 'on'); + }; + +-},{"../constants/xmlns_namespaces":247,"../lib":256,"../plotly":276,"d3":62}],270:[function(require,module,exports){ ++},{"../constants/xmlns_namespaces":247,"../lib":256,"../plotly":276,"d3":54}],270:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -53095,7 +53784,7 @@ function drawMainTitle(gd) { + }); + } + +-},{"../components/color":176,"../components/drawing":199,"../components/errorbars":205,"../components/images":211,"../components/legend":219,"../components/modebar/manage":223,"../components/rangeselector":230,"../components/rangeslider":235,"../components/shapes":238,"../components/titles":239,"../components/updatemenus":244,"../constants/xmlns_namespaces":247,"../lib":256,"../lib/events":252,"../lib/queue":263,"../plotly":276,"../plots/cartesian/graph_interact":286,"../plots/plots":303,"d3":62,"fast-isnumeric":65,"gl-mat4/fromQuat":78}],271:[function(require,module,exports){ ++},{"../components/color":176,"../components/drawing":199,"../components/errorbars":205,"../components/images":211,"../components/legend":219,"../components/modebar/manage":223,"../components/rangeselector":230,"../components/rangeslider":235,"../components/shapes":238,"../components/titles":239,"../components/updatemenus":244,"../constants/xmlns_namespaces":247,"../lib":256,"../lib/events":252,"../lib/queue":263,"../plotly":276,"../plots/cartesian/graph_interact":286,"../plots/plots":303,"d3":54,"fast-isnumeric":60,"gl-mat4/fromQuat":78}],271:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -53683,7 +54372,7 @@ function toImage(gd, opts) { + + module.exports = toImage; + +-},{"../lib":256,"../plotly":276,"../snapshot":312,"fast-isnumeric":65}],275:[function(require,module,exports){ ++},{"../lib":256,"../plotly":276,"../snapshot":312,"fast-isnumeric":60}],275:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -54171,7 +54860,7 @@ exports.PlotSchema = require('./plot_api/plot_schema'); + // imaging routines + exports.Snapshot = require('./snapshot'); + +-},{"../build/plotcss":1,"./components/annotations":174,"./components/color":176,"./components/colorbar":181,"./components/colorscale":190,"./components/drawing":199,"./components/errorbars":205,"./components/images":211,"./components/legend":219,"./components/modebar":222,"./components/shapes":238,"./components/updatemenus":244,"./fonts/mathjax_config":249,"./lib":256,"./lib/queue":263,"./lib/svg_text_utils":269,"./plot_api/plot_api":270,"./plot_api/plot_config":271,"./plot_api/plot_schema":272,"./plots/cartesian/axes":279,"./plots/cartesian/graph_interact":286,"./plots/plots":303,"./plots/polar/micropolar":306,"./snapshot":312,"./traces/scatter":351,"es6-promise":64}],277:[function(require,module,exports){ ++},{"../build/plotcss":1,"./components/annotations":174,"./components/color":176,"./components/colorbar":181,"./components/colorscale":190,"./components/drawing":199,"./components/errorbars":205,"./components/images":211,"./components/legend":219,"./components/modebar":222,"./components/shapes":238,"./components/updatemenus":244,"./fonts/mathjax_config":249,"./lib":256,"./lib/queue":263,"./lib/svg_text_utils":269,"./plot_api/plot_api":270,"./plot_api/plot_config":271,"./plot_api/plot_schema":272,"./plots/cartesian/axes":279,"./plots/cartesian/graph_interact":286,"./plots/plots":303,"./plots/polar/micropolar":306,"./snapshot":312,"./traces/scatter":351,"es6-promise":58}],277:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -54454,14 +55143,27 @@ axes.getAutoRange = function(ax) { + } + + if(minmin === maxmax) { +- newRange = axReverse ? +- [minmin + 1, ax.rangemode !== 'normal' ? 0 : minmin - 1] : +- [ax.rangemode !== 'normal' ? 0 : minmin - 1, minmin + 1]; ++ var lower = minmin - 1; ++ var upper = minmin + 1; ++ if(ax.rangemode === 'tozero') { ++ newRange = minmin < 0 ? [lower, 0] : [0, upper]; ++ } ++ else if(ax.rangemode === 'nonnegative') { ++ newRange = [Math.max(0, lower), Math.max(0, upper)]; ++ } ++ else { ++ newRange = [lower, upper]; ++ } + } + else if(mbest) { + if(ax.type === 'linear' || ax.type === '-') { +- if(ax.rangemode === 'tozero' && minbest.val >= 0) { +- minbest = {val: 0, pad: 0}; ++ if(ax.rangemode === 'tozero') { ++ if(minbest.val >= 0) { ++ minbest = {val: 0, pad: 0}; ++ } ++ if(maxbest.val <= 0) { ++ maxbest = {val: 0, pad: 0}; ++ } + } + else if(ax.rangemode === 'nonnegative') { + if(minbest.val - mbest * minbest.pad < 0) { +@@ -54475,22 +55177,39 @@ axes.getAutoRange = function(ax) { + // in case it changed again... + mbest = (maxbest.val - minbest.val) / + (ax._length - minbest.pad - maxbest.pad); ++ + } + + newRange = [ + minbest.val - mbest * minbest.pad, + maxbest.val + mbest * maxbest.pad + ]; ++ } + +- // don't let axis have zero size +- if(newRange[0] === newRange[1]) { ++ // don't let axis have zero size, while still respecting tozero and nonnegative ++ if(newRange[0] === newRange[1]) { ++ if(ax.rangemode === 'tozero') { ++ if(newRange[0] < 0) { ++ newRange = [newRange[0], 0]; ++ } ++ else if(newRange[0] > 0) { ++ newRange = [0, newRange[0]]; ++ } ++ else { ++ newRange = [0, 1]; ++ } ++ } ++ else { + newRange = [newRange[0] - 1, newRange[0] + 1]; ++ if(ax.rangemode === 'nonnegative') { ++ newRange[0] = Math.max(0, newRange[0]); ++ } + } ++ } + +- // maintain reversal +- if(axReverse) { +- newRange.reverse(); +- } ++ // maintain reversal ++ if(axReverse) { ++ newRange.reverse(); + } + + return newRange; +@@ -56273,7 +56992,7 @@ function swapAxisAttrs(layout, key, xFullAxes, yFullAxes) { + // rather than built-in % which gives a negative value for negative v + function mod(v, d) { return ((v % d) + d) % d; } + +-},{"../../components/color":176,"../../components/drawing":199,"../../components/titles":239,"../../lib":256,"../../lib/svg_text_utils":269,"../../plotly":276,"./axis_ids":281,"./layout_attributes":288,"./layout_defaults":289,"./set_convert":293,"d3":62,"fast-isnumeric":65}],280:[function(require,module,exports){ ++},{"../../components/color":176,"../../components/drawing":199,"../../components/titles":239,"../../lib":256,"../../lib/svg_text_utils":269,"../../plotly":276,"./axis_ids":281,"./layout_attributes":288,"./layout_defaults":289,"./set_convert":293,"d3":54,"fast-isnumeric":60}],280:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -56556,7 +57275,7 @@ function category(a) { + return curvecats > curvenums * 2; + } + +-},{"../../components/color/attributes":175,"../../lib":256,"../plots":303,"./axis_ids":281,"./category_order_defaults":282,"./clean_datum":283,"./layout_attributes":288,"./ordered_categories":290,"./set_convert":293,"./tick_label_defaults":294,"./tick_mark_defaults":295,"./tick_value_defaults":296,"fast-isnumeric":65,"tinycolor2":148}],281:[function(require,module,exports){ ++},{"../../components/color/attributes":175,"../../lib":256,"../plots":303,"./axis_ids":281,"./category_order_defaults":282,"./clean_datum":283,"./layout_attributes":288,"./ordered_categories":290,"./set_convert":293,"./tick_label_defaults":294,"./tick_mark_defaults":295,"./tick_value_defaults":296,"fast-isnumeric":60,"tinycolor2":157}],281:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -56750,7 +57469,7 @@ module.exports = function cleanDatum(c) { + return c; + }; + +-},{"../../lib":256,"fast-isnumeric":65}],284:[function(require,module,exports){ ++},{"../../lib":256,"fast-isnumeric":60}],284:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -57517,7 +58236,7 @@ function isSelectOrLasso(dragmode) { + return modes.indexOf(dragmode) !== -1; + } + +-},{"../../components/color":176,"../../components/dragelement":197,"../../components/drawing":199,"../../lib":256,"../../lib/setcursor":265,"../../lib/svg_text_utils":269,"../../plotly":276,"./axes":279,"./constants":284,"./select":292,"d3":62,"tinycolor2":148}],286:[function(require,module,exports){ ++},{"../../components/color":176,"../../components/dragelement":197,"../../components/drawing":199,"../../lib":256,"../../lib/setcursor":265,"../../lib/svg_text_utils":269,"../../plotly":276,"./axes":279,"./constants":284,"./select":292,"d3":54,"tinycolor2":157}],286:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -58859,7 +59578,7 @@ fx.inbox = function(v0, v1) { + return Infinity; + }; + +-},{"../../components/color":176,"../../components/dragelement":197,"../../components/drawing":199,"../../lib":256,"../../lib/events":252,"../../lib/svg_text_utils":269,"./axes":279,"./constants":284,"./dragbox":285,"d3":62,"fast-isnumeric":65,"tinycolor2":148}],287:[function(require,module,exports){ ++},{"../../components/color":176,"../../components/dragelement":197,"../../components/drawing":199,"../../lib":256,"../../lib/events":252,"../../lib/svg_text_utils":269,"./axes":279,"./constants":284,"./dragbox":285,"d3":54,"fast-isnumeric":60,"tinycolor2":157}],287:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -59543,7 +60262,7 @@ module.exports = function orderedCategories(axisLetter, categoryorder, categorya + } + }; + +-},{"d3":62}],291:[function(require,module,exports){ ++},{"d3":54}],291:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -59608,7 +60327,7 @@ module.exports = function handlePositionDefaults(containerIn, containerOut, coer + return containerOut; + }; + +-},{"../../lib":256,"fast-isnumeric":65}],292:[function(require,module,exports){ ++},{"../../lib":256,"fast-isnumeric":60}],292:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -60052,7 +60771,7 @@ module.exports = function setConvert(ax) { + ax._forceTick0 = null; + }; + +-},{"../../lib":256,"./axis_ids":281,"./clean_datum":283,"./constants":284,"d3":62,"fast-isnumeric":65}],294:[function(require,module,exports){ ++},{"../../lib":256,"./axis_ids":281,"./clean_datum":283,"./constants":284,"d3":54,"fast-isnumeric":60}],294:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -60209,7 +60928,7 @@ module.exports = function handleTickValueDefaults(containerIn, containerOut, coe + } + }; + +-},{"fast-isnumeric":65}],297:[function(require,module,exports){ ++},{"fast-isnumeric":60}],297:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -60395,7 +61114,7 @@ function createCamera(scene) { + return result; + } + +-},{"mouse-change":125,"mouse-wheel":129}],299:[function(require,module,exports){ ++},{"mouse-change":118,"mouse-wheel":120}],299:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -61299,7 +62018,7 @@ proto.hoverFormatter = function(axisName, val) { + return Axes.tickText(axis, axis.c2l(val), 'hover').text; + }; + +-},{"../../lib/html2unicode":255,"../../lib/show_no_webgl_msg":266,"../../plots/cartesian/axes":279,"../../plots/cartesian/graph_interact":286,"./camera":298,"./convert":299,"gl-plot2d":85,"gl-select-box":94,"gl-spikes2d":114}],302:[function(require,module,exports){ ++},{"../../lib/html2unicode":255,"../../lib/show_no_webgl_msg":266,"../../plots/cartesian/axes":279,"../../plots/cartesian/graph_interact":286,"./camera":298,"./convert":299,"gl-plot2d":85,"gl-select-box":94,"gl-spikes2d":103}],302:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -62655,7 +63374,7 @@ plots.graphJson = function(gd, dataonly, mode, output, useDefaults) { + return (output === 'object') ? obj : JSON.stringify(obj); + }; + +-},{"../components/color":176,"../lib":256,"../plotly":276,"./attributes":277,"./font_attributes":297,"./layout_attributes":302,"d3":62,"fast-isnumeric":65}],304:[function(require,module,exports){ ++},{"../components/color":176,"../lib":256,"../plotly":276,"./attributes":277,"./font_attributes":297,"./layout_attributes":302,"d3":54,"fast-isnumeric":60}],304:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -64218,7 +64937,7 @@ var extendDeepAll = Plotly.Lib.extendDeepAll; + return exports; + }; + +-},{"../../plotly":276,"./micropolar_manager":307,"d3":62}],307:[function(require,module,exports){ ++},{"../../plotly":276,"./micropolar_manager":307,"d3":54}],307:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -64301,7 +65020,7 @@ manager.fillLayout = function(_gd) { + _gd._fullLayout = extendDeepAll(dflts, _gd.layout); + }; + +-},{"../../plotly":276,"./undo_manager":308,"d3":62}],308:[function(require,module,exports){ ++},{"../../plotly":276,"./undo_manager":308,"d3":54}],308:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -64833,7 +65552,7 @@ function svgToImg(opts) { + + module.exports = svgToImg; + +-},{"../lib":256,"events":14}],314:[function(require,module,exports){ ++},{"../lib":256,"events":59}],314:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -64912,7 +65631,7 @@ function toImage(gd, opts) { + + module.exports = toImage; + +-},{"../lib":256,"../plotly":276,"events":14}],315:[function(require,module,exports){ ++},{"../lib":256,"../plotly":276,"events":59}],315:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -65024,7 +65743,7 @@ module.exports = function toSVG(gd, format) { + return s; + }; + +-},{"../components/color":176,"../components/drawing":199,"../constants/xmlns_namespaces":247,"../lib/svg_text_utils":269,"d3":62}],316:[function(require,module,exports){ ++},{"../components/color":176,"../components/drawing":199,"../constants/xmlns_namespaces":247,"../lib/svg_text_utils":269,"d3":54}],316:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -65362,7 +66081,7 @@ module.exports = function makeColorMap(trace) { + return colorMap; + }; + +-},{"../../components/colorscale/get_scale":188,"d3":62}],321:[function(require,module,exports){ ++},{"../../components/colorscale/get_scale":188,"d3":54}],321:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -65576,7 +66295,7 @@ function createContour(scene, fullTrace, calcTrace) { + + module.exports = createContour; + +-},{"../../lib/str2rgbarray":268,"../contour/make_color_map":320,"gl-contour2d":67,"gl-heatmap2d":73}],323:[function(require,module,exports){ ++},{"../../lib/str2rgbarray":268,"../contour/make_color_map":320,"gl-contour2d":66,"gl-heatmap2d":73}],323:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -66125,7 +66844,7 @@ function iterateInterp2d(z, emptyPoints, overshoot) { + return maxFractionalChange; + } + +-},{"../../components/colorscale/calc":183,"../../lib":256,"../../plots/cartesian/axes":279,"../../plots/plots":303,"../histogram2d/calc":338,"./convert_column_xyz":327,"./has_columns":329,"./max_row_length":330,"fast-isnumeric":65}],326:[function(require,module,exports){ ++},{"../../components/colorscale/calc":183,"../../lib":256,"../../plots/cartesian/axes":279,"../../plots/plots":303,"../histogram2d/calc":338,"./convert_column_xyz":327,"./has_columns":329,"./max_row_length":330,"fast-isnumeric":60}],326:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -66171,7 +66890,7 @@ module.exports = function colorbar(gd, cd) { + .options(trace.colorbar)(); + }; + +-},{"../../components/colorbar/draw":179,"../../components/colorscale/get_scale":188,"../../lib":256,"../../plots/plots":303,"d3":62,"fast-isnumeric":65}],327:[function(require,module,exports){ ++},{"../../components/colorbar/draw":179,"../../components/colorscale/get_scale":188,"../../lib":256,"../../plots/plots":303,"d3":54,"fast-isnumeric":60}],327:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -66393,7 +67112,7 @@ function isValidZ(z) { + return (allRowsAreArrays && oneRowIsFilled && hasOneNumber); + } + +-},{"./has_columns":329,"fast-isnumeric":65}],332:[function(require,module,exports){ ++},{"./has_columns":329,"fast-isnumeric":60}],332:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -66670,7 +67389,7 @@ module.exports = { + } + }; + +-},{"fast-isnumeric":65}],337:[function(require,module,exports){ ++},{"fast-isnumeric":60}],337:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -67313,7 +68032,7 @@ module.exports = function calc(gd, trace) { + return cd; + }; + +-},{"../../lib":256,"../../plots/cartesian/axes":279,"./colorscale_calc":345,"./subtypes":360,"fast-isnumeric":65}],343:[function(require,module,exports){ ++},{"../../lib":256,"../../plots/cartesian/axes":279,"./colorscale_calc":345,"./subtypes":360,"fast-isnumeric":60}],343:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -67407,7 +68126,7 @@ module.exports = function colorbar(gd, cd) { + .options(marker.colorbar)(); + }; + +-},{"../../components/colorbar/draw":179,"../../components/colorscale/get_scale":188,"../../lib":256,"../../plots/plots":303,"d3":62,"fast-isnumeric":65}],345:[function(require,module,exports){ ++},{"../../components/colorbar/draw":179,"../../components/colorscale/get_scale":188,"../../lib":256,"../../plots/plots":303,"d3":54,"fast-isnumeric":60}],345:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -68101,7 +68820,7 @@ module.exports = function makeBubbleSizeFn(trace) { + }; + }; + +-},{"fast-isnumeric":65}],356:[function(require,module,exports){ ++},{"fast-isnumeric":60}],356:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -68454,7 +69173,7 @@ function selectMarkers(gd, plotinfo, cdscatter) { + }); + } + +-},{"../../components/drawing":199,"../../components/errorbars":205,"../../lib":256,"../../lib/polygon":262,"./arrays_to_calcdata":340,"./line_points":353,"./subtypes":360,"d3":62}],358:[function(require,module,exports){ ++},{"../../components/drawing":199,"../../components/errorbars":205,"../../lib":256,"../../lib/polygon":262,"./arrays_to_calcdata":340,"./line_points":353,"./subtypes":360,"d3":54}],358:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -68567,7 +69286,7 @@ module.exports = function style(gd) { + s.call(ErrorBars.style); + }; + +-},{"../../components/drawing":199,"../../components/errorbars":205,"d3":62}],360:[function(require,module,exports){ ++},{"../../components/drawing":199,"../../components/errorbars":205,"d3":54}],360:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +@@ -69372,7 +70091,7 @@ function createLineWithMarkers(scene, data) { + + module.exports = createLineWithMarkers; + +-},{"../../components/errorbars":205,"../../constants/gl2d_dashes":245,"../../constants/gl_markers":246,"../../lib":256,"../../lib/gl_format_color":254,"../../lib/str2rgbarray":268,"../../plots/cartesian/axes":279,"../scatter/get_trace_color":349,"../scatter/make_bubble_size_func":355,"../scatter/subtypes":360,"fast-isnumeric":65,"gl-error2d":70,"gl-line2d":77,"gl-scatter2d":92,"gl-scatter2d-fancy":87}],366:[function(require,module,exports){ ++},{"../../components/errorbars":205,"../../constants/gl2d_dashes":245,"../../constants/gl_markers":246,"../../lib":256,"../../lib/gl_format_color":254,"../../lib/str2rgbarray":268,"../../plots/cartesian/axes":279,"../scatter/get_trace_color":349,"../scatter/make_bubble_size_func":355,"../scatter/subtypes":360,"fast-isnumeric":60,"gl-error2d":69,"gl-line2d":77,"gl-scatter2d":92,"gl-scatter2d-fancy":87}],366:[function(require,module,exports){ + /** + * Copyright 2012-2016, Plotly, Inc. + * All rights reserved. +diff --git a/dist/plotly-gl2d.min.js b/dist/plotly-gl2d.min.js +index 7d78c53..3aadb66 100644 +--- a/dist/plotly-gl2d.min.js ++++ b/dist/plotly-gl2d.min.js +@@ -4,31 +4,31 @@ + * All rights reserved. + * Licensed under the MIT license + */ +-!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.Plotly=t()}}(function(){var t;return function e(t,r,n){function i(o,s){if(!r[o]){if(!t[o]){var l="function"==typeof require&&require;if(!s&&l)return l(o,!0);if(a)return a(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var c=r[o]={exports:{}};t[o][0].call(c.exports,function(e){var r=t[o][1][e];return i(r?r:e)},c,c.exports,e,t,r,n)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;oa;a++)i.push(t+a*n);return i}function r(){for(var t=[].slice.call(arguments),e=t.map(function(t){return t.length}),r=Math.min.apply(null,e),n=[],i=0;r>i;i++){n[i]=[];for(var a=0;aa;a++)i.push([t[a],e[a],r[a]]);return i}function i(t){function e(t){for(var n=0;n>16&255,r[1]=n>>8&255,r[2]=255&n):f.test(t)&&(n=t.match(h),r[0]=parseInt(n[1]),r[1]=parseInt(n[2]),r[2]=parseInt(n[3])),!e)for(var i=0;3>i;++i)r[i]=r[i]/255;return r}function u(t,e){var r,n;if("string"!=typeof t)return t;if(r=[],"#"===t[0]?(t=t.substr(1),3===t.length&&(t+=t),n=parseInt(t,16),r[0]=n>>16&255,r[1]=n>>8&255,r[2]=255&n):f.test(t)&&(n=t.match(h),r[0]=parseInt(n[1]),r[1]=parseInt(n[2]),r[2]=parseInt(n[3]),n[4]?r[3]=parseFloat(n[4]):r[3]=1),!e)for(var i=0;3>i;++i)r[i]=r[i]/255;return r}var c={},f=/^rgba?\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*(,.*)?\)$/,h=/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,?\s*(.*)?\)$/;return c.isPlainObject=t,c.linspace=e,c.zip3=n,c.sum=i,c.zip=r,c.isEqual=s,c.copy2D=a,c.copy1D=o,c.str2RgbArray=l,c.str2RgbaArray=u,c};e.exports=n()},{}],9:[function(t,e,r){"use strict";"use restrict";function n(t){var e=32;return t&=-t,t&&e--,65535&t&&(e-=16),16711935&t&&(e-=8),252645135&t&&(e-=4),858993459&t&&(e-=2),1431655765&t&&(e-=1),e}var i=32;r.INT_BITS=i,r.INT_MAX=2147483647,r.INT_MIN=-1<0)-(0>t)},r.abs=function(t){var e=t>>i-1;return(t^e)-e},r.min=function(t,e){return e^(t^e)&-(e>t)},r.max=function(t,e){return t^(t^e)&-(e>t)},r.isPow2=function(t){return!(t&t-1||!t)},r.log2=function(t){var e,r;return e=(t>65535)<<4,t>>>=e,r=(t>255)<<3,t>>>=r,e|=r,r=(t>15)<<2,t>>>=r,e|=r,r=(t>3)<<1,t>>>=r,e|=r,e|t>>1},r.log10=function(t){return t>=1e9?9:t>=1e8?8:t>=1e7?7:t>=1e6?6:t>=1e5?5:t>=1e4?4:t>=1e3?3:t>=100?2:t>=10?1:0},r.popCount=function(t){return t-=t>>>1&1431655765,t=(858993459&t)+(t>>>2&858993459),16843009*(t+(t>>>4)&252645135)>>>24},r.countTrailingZeros=n,r.nextPow2=function(t){return t+=0===t,--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t+1},r.prevPow2=function(t){return t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t-(t>>>1)},r.parity=function(t){return t^=t>>>16,t^=t>>>8,t^=t>>>4,t&=15,27030>>>t&1};var a=new Array(256);!function(t){for(var e=0;256>e;++e){var r=e,n=e,i=7;for(r>>>=1;r;r>>>=1)n<<=1,n|=1&r,--i;t[e]=n<>>8&255]<<16|a[t>>>16&255]<<8|a[t>>>24&255]},r.interleave2=function(t,e){return t&=65535,t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e&=65535,e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t|e<<1},r.deinterleave2=function(t,e){return t=t>>>e&1431655765,t=858993459&(t|t>>>1),t=252645135&(t|t>>>2),t=16711935&(t|t>>>4),t=65535&(t|t>>>16),t<<16>>16},r.interleave3=function(t,e,r){return t&=1023,t=4278190335&(t|t<<16),t=251719695&(t|t<<8),t=3272356035&(t|t<<4),t=1227133513&(t|t<<2),e&=1023,e=4278190335&(e|e<<16),e=251719695&(e|e<<8),e=3272356035&(e|e<<4),e=1227133513&(e|e<<2),t|=e<<1,r&=1023,r=4278190335&(r|r<<16),r=251719695&(r|r<<8),r=3272356035&(r|r<<4),r=1227133513&(r|r<<2),t|r<<2},r.deinterleave3=function(t,e){return t=t>>>e&1227133513,t=3272356035&(t|t>>>2),t=251719695&(t|t>>>4),t=4278190335&(t|t>>>8),t=1023&(t|t>>>16),t<<22>>22},r.nextCombination=function(t){var e=t|t-1;return e+1|(~e&-~e)-1>>>n(t)+1}},{}],10:[function(t,e,r){(function(e){"use strict";function n(){try{var t=new Uint8Array(1);return t.foo=function(){return 42},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(e){return!1}}function i(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t){return this instanceof a?(a.TYPED_ARRAY_SUPPORT||(this.length=0,this.parent=void 0),"number"==typeof t?o(this,t):"string"==typeof t?s(this,t,arguments.length>1?arguments[1]:"utf8"):l(this,t)):arguments.length>1?new a(t,arguments[1]):new a(t)}function o(t,e){if(t=g(t,0>e?0:0|v(e)),!a.TYPED_ARRAY_SUPPORT)for(var r=0;e>r;r++)t[r]=0;return t}function s(t,e,r){"string"==typeof r&&""!==r||(r="utf8");var n=0|y(e,r);return t=g(t,n),t.write(e,r),t}function l(t,e){if(a.isBuffer(e))return u(t,e);if(Q(e))return c(t,e);if(null==e)throw new TypeError("must start with number, buffer, array or string");if("undefined"!=typeof ArrayBuffer){if(e.buffer instanceof ArrayBuffer)return f(t,e);if(e instanceof ArrayBuffer)return h(t,e)}return e.length?d(t,e):p(t,e)}function u(t,e){var r=0|v(e.length);return t=g(t,r),e.copy(t,0,0,r),t}function c(t,e){var r=0|v(e.length);t=g(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function f(t,e){var r=0|v(e.length);t=g(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function h(t,e){return e.byteLength,a.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e),t.__proto__=a.prototype):t=f(t,new Uint8Array(e)),t}function d(t,e){var r=0|v(e.length);t=g(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function p(t,e){var r,n=0;"Buffer"===e.type&&Q(e.data)&&(r=e.data,n=0|v(r.length)),t=g(t,n);for(var i=0;n>i;i+=1)t[i]=255&r[i];return t}function g(t,e){a.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e),t.__proto__=a.prototype):t.length=e;var r=0!==e&&e<=a.poolSize>>>1;return r&&(t.parent=$),t}function v(t){if(t>=i())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i().toString(16)+" bytes");return 0|t}function m(t,e){if(!(this instanceof m))return new m(t,e);var r=new a(t,e);return delete r.parent,r}function y(t,e){"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"binary":case"raw":case"raws":return r;case"utf8":case"utf-8":return q(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return X(t).length;default:if(n)return q(t).length;e=(""+e).toLowerCase(),n=!0}}function b(t,e,r){var n=!1;if(e=0|e,r=void 0===r||r===1/0?this.length:0|r,t||(t="utf8"),0>e&&(e=0),r>this.length&&(r=this.length),e>=r)return"";for(;;)switch(t){case"hex":return R(this,e,r);case"utf8":case"utf-8":return T(this,e,r);case"ascii":return S(this,e,r);case"binary":return C(this,e,r);case"base64":return E(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function x(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;var a=e.length;if(a%2!==0)throw new Error("Invalid hex string");n>a/2&&(n=a/2);for(var o=0;n>o;o++){var s=parseInt(e.substr(2*o,2),16);if(isNaN(s))throw new Error("Invalid hex string");t[r+o]=s}return o}function _(t,e,r,n){return Y(q(e,t.length-r),t,r,n)}function w(t,e,r,n){return Y(H(e),t,r,n)}function A(t,e,r,n){return w(t,e,r,n)}function k(t,e,r,n){return Y(X(e),t,r,n)}function M(t,e,r,n){return Y(G(e,t.length-r),t,r,n)}function E(t,e,r){return 0===e&&r===t.length?W.fromByteArray(t):W.fromByteArray(t.slice(e,r))}function T(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;r>i;){var a=t[i],o=null,s=a>239?4:a>223?3:a>191?2:1;if(r>=i+s){var l,u,c,f;switch(s){case 1:128>a&&(o=a);break;case 2:l=t[i+1],128===(192&l)&&(f=(31&a)<<6|63&l,f>127&&(o=f));break;case 3:l=t[i+1],u=t[i+2],128===(192&l)&&128===(192&u)&&(f=(15&a)<<12|(63&l)<<6|63&u,f>2047&&(55296>f||f>57343)&&(o=f));break;case 4:l=t[i+1],u=t[i+2],c=t[i+3],128===(192&l)&&128===(192&u)&&128===(192&c)&&(f=(15&a)<<18|(63&l)<<12|(63&u)<<6|63&c,f>65535&&1114112>f&&(o=f))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=s}return L(n)}function L(t){var e=t.length;if(K>=e)return String.fromCharCode.apply(String,t);for(var r="",n=0;e>n;)r+=String.fromCharCode.apply(String,t.slice(n,n+=K));return r}function S(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;r>i;i++)n+=String.fromCharCode(127&t[i]);return n}function C(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;r>i;i++)n+=String.fromCharCode(t[i]);return n}function R(t,e,r){var n=t.length;(!e||0>e)&&(e=0),(!r||0>r||r>n)&&(r=n);for(var i="",a=e;r>a;a++)i+=V(t[a]);return i}function I(t,e,r){for(var n=t.slice(e,r),i="",a=0;at)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,r,n,i,o){if(!a.isBuffer(t))throw new TypeError("buffer must be a Buffer instance");if(e>i||o>e)throw new RangeError("value is out of bounds");if(r+n>t.length)throw new RangeError("index out of range")}function N(t,e,r,n){0>e&&(e=65535+e+1);for(var i=0,a=Math.min(t.length-r,2);a>i;i++)t[r+i]=(e&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function z(t,e,r,n){0>e&&(e=4294967295+e+1);for(var i=0,a=Math.min(t.length-r,4);a>i;i++)t[r+i]=e>>>8*(n?i:3-i)&255}function D(t,e,r,n,i,a){if(r+n>t.length)throw new RangeError("index out of range");if(0>r)throw new RangeError("index out of range")}function F(t,e,r,n,i){return i||D(t,e,r,4,3.4028234663852886e38,-3.4028234663852886e38),Z.write(t,e,r,n,23,4),r+4}function B(t,e,r,n,i){return i||D(t,e,r,8,1.7976931348623157e308,-1.7976931348623157e308),Z.write(t,e,r,n,52,8),r+8}function j(t){if(t=U(t).replace(J,""),t.length<2)return"";for(;t.length%4!==0;)t+="=";return t}function U(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function V(t){return 16>t?"0"+t.toString(16):t.toString(16)}function q(t,e){e=e||1/0;for(var r,n=t.length,i=null,a=[],o=0;n>o;o++){if(r=t.charCodeAt(o),r>55295&&57344>r){if(!i){if(r>56319){(e-=3)>-1&&a.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&a.push(239,191,189);continue}i=r;continue}if(56320>r){(e-=3)>-1&&a.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&a.push(239,191,189);if(i=null,128>r){if((e-=1)<0)break;a.push(r)}else if(2048>r){if((e-=2)<0)break;a.push(r>>6|192,63&r|128)}else if(65536>r){if((e-=3)<0)break;a.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(1114112>r))throw new Error("Invalid code point");if((e-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return a}function H(t){for(var e=[],r=0;r>8,i=r%256,a.push(i),a.push(n);return a}function X(t){return W.toByteArray(j(t))}function Y(t,e,r,n){for(var i=0;n>i&&!(i+r>=e.length||i>=t.length);i++)e[i+r]=t[i];return i}var W=t("base64-js"),Z=t("ieee754"),Q=t("isarray");r.Buffer=a,r.SlowBuffer=m,r.INSPECT_MAX_BYTES=50,a.poolSize=8192;var $={};a.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:n(),a._augment=function(t){return t.__proto__=a.prototype,t},a.TYPED_ARRAY_SUPPORT?(a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&a[Symbol.species]===a&&Object.defineProperty(a,Symbol.species,{value:null,configurable:!0})):(a.prototype.length=void 0,a.prototype.parent=void 0),a.isBuffer=function(t){return!(null==t||!t._isBuffer)},a.compare=function(t,e){if(!a.isBuffer(t)||!a.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,i=0,o=Math.min(r,n);o>i&&t[i]===e[i];)++i;return i!==o&&(r=t[i],n=e[i]),n>r?-1:r>n?1:0},a.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(t,e){if(!Q(t))throw new TypeError("list argument must be an Array of Buffers.");if(0===t.length)return new a(0);var r;if(void 0===e)for(e=0,r=0;r0&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(t+=" ... ")),""},a.prototype.compare=function(t){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?0:a.compare(this,t)},a.prototype.indexOf=function(t,e){function r(t,e,r){for(var n=-1,i=0;r+i2147483647?e=2147483647:-2147483648>e&&(e=-2147483648),e>>=0,0===this.length)return-1;if(e>=this.length)return-1;if(0>e&&(e=Math.max(this.length+e,0)),"string"==typeof t)return 0===t.length?-1:String.prototype.indexOf.call(this,t,e);if(a.isBuffer(t))return r(this,t,e);if("number"==typeof t)return a.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,t,e):r(this,[t],e);throw new TypeError("val must be string, number or Buffer")},a.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else if(isFinite(e))e=0|e,isFinite(r)?(r=0|r,void 0===n&&(n="utf8")):(n=r,r=void 0);else{var i=n;n=e,e=0|r,r=i}var a=this.length-e;if((void 0===r||r>a)&&(r=a),t.length>0&&(0>r||0>e)||e>this.length)throw new RangeError("attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return x(this,t,e,r);case"utf8":case"utf-8":return _(this,t,e,r);case"ascii":return w(this,t,e,r);case"binary":return A(this,t,e,r);case"base64":return k(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return M(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var K=4096;a.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,0>t?(t+=r,0>t&&(t=0)):t>r&&(t=r),0>e?(e+=r,0>e&&(e=0)):e>r&&(e=r),t>e&&(e=t);var n;if(a.TYPED_ARRAY_SUPPORT)n=this.subarray(t,e),n.__proto__=a.prototype;else{var i=e-t;n=new a(i,void 0);for(var o=0;i>o;o++)n[o]=this[o+t]}return n.length&&(n.parent=this.parent||this),n},a.prototype.readUIntLE=function(t,e,r){t=0|t,e=0|e,r||P(t,e,this.length);for(var n=this[t],i=1,a=0;++a0&&(i*=256);)n+=this[t+--e]*i;return n},a.prototype.readUInt8=function(t,e){return e||P(t,1,this.length),this[t]},a.prototype.readUInt16LE=function(t,e){return e||P(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUInt16BE=function(t,e){return e||P(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUInt32LE=function(t,e){return e||P(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},a.prototype.readUInt32BE=function(t,e){return e||P(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readIntLE=function(t,e,r){t=0|t,e=0|e,r||P(t,e,this.length);for(var n=this[t],i=1,a=0;++a=i&&(n-=Math.pow(2,8*e)),n},a.prototype.readIntBE=function(t,e,r){t=0|t,e=0|e,r||P(t,e,this.length);for(var n=e,i=1,a=this[t+--n];n>0&&(i*=256);)a+=this[t+--n]*i;return i*=128,a>=i&&(a-=Math.pow(2,8*e)),a},a.prototype.readInt8=function(t,e){return e||P(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},a.prototype.readInt16LE=function(t,e){e||P(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt16BE=function(t,e){e||P(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt32LE=function(t,e){return e||P(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,e){return e||P(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readFloatLE=function(t,e){return e||P(t,4,this.length),Z.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,e){return e||P(t,4,this.length),Z.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,e){return e||P(t,8,this.length),Z.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,e){return e||P(t,8,this.length),Z.read(this,t,!1,52,8)},a.prototype.writeUIntLE=function(t,e,r,n){t=+t,e=0|e,r=0|r,n||O(this,t,e,r,Math.pow(2,8*r),0);var i=1,a=0;for(this[e]=255&t;++a=0&&(a*=256);)this[e+i]=t/a&255;return e+r},a.prototype.writeUInt8=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,1,255,0),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},a.prototype.writeUInt16LE=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):N(this,t,e,!0),e+2},a.prototype.writeUInt16BE=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):N(this,t,e,!1),e+2},a.prototype.writeUInt32LE=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):z(this,t,e,!0),e+4},a.prototype.writeUInt32BE=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):z(this,t,e,!1),e+4},a.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e=0|e,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var a=0,o=1,s=0>t?1:0;for(this[e]=255&t;++a>0)-s&255;return e+r},a.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e=0|e,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var a=r-1,o=1,s=0>t?1:0;for(this[e+a]=255&t;--a>=0&&(o*=256);)this[e+a]=(t/o>>0)-s&255;return e+r},a.prototype.writeInt8=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,1,127,-128),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),0>t&&(t=255+t+1),this[e]=255&t,e+1},a.prototype.writeInt16LE=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):N(this,t,e,!0),e+2},a.prototype.writeInt16BE=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):N(this,t,e,!1),e+2},a.prototype.writeInt32LE=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,4,2147483647,-2147483648),a.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):z(this,t,e,!0),e+4},a.prototype.writeInt32BE=function(t,e,r){return t=+t,e=0|e,r||O(this,t,e,4,2147483647,-2147483648),0>t&&(t=4294967295+t+1),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):z(this,t,e,!1),e+4},a.prototype.writeFloatLE=function(t,e,r){return F(this,t,e,!0,r)},a.prototype.writeFloatBE=function(t,e,r){ +-return F(this,t,e,!1,r)},a.prototype.writeDoubleLE=function(t,e,r){return B(this,t,e,!0,r)},a.prototype.writeDoubleBE=function(t,e,r){return B(this,t,e,!1,r)},a.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&r>n&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(0>e)throw new RangeError("targetStart out of bounds");if(0>r||r>=this.length)throw new RangeError("sourceStart out of bounds");if(0>n)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-er&&n>e)for(i=o-1;i>=0;i--)t[i+e]=this[i+r];else if(1e3>o||!a.TYPED_ARRAY_SUPPORT)for(i=0;o>i;i++)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+o),e);return o},a.prototype.fill=function(t,e,r){if(t||(t=0),e||(e=0),r||(r=this.length),e>r)throw new RangeError("end < start");if(r!==e&&0!==this.length){if(0>e||e>=this.length)throw new RangeError("start out of bounds");if(0>r||r>this.length)throw new RangeError("end out of bounds");var n;if("number"==typeof t)for(n=e;r>n;n++)this[n]=t;else{var i=q(t.toString()),a=i.length;for(n=e;r>n;n++)this[n]=i[n%a]}return this}};var J=/[^+\/0-9A-Za-z-_]/g}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"base64-js":11,ieee754:12,isarray:13}],11:[function(t,e,r){"use strict";function n(){var t,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=e.length;for(t=0;r>t;t++)l[t]=e[t];for(t=0;r>t;++t)u[e.charCodeAt(t)]=t;u["-".charCodeAt(0)]=62,u["_".charCodeAt(0)]=63}function i(t){var e,r,n,i,a,o,s=t.length;if(s%4>0)throw new Error("Invalid string. Length must be a multiple of 4");a="="===t[s-2]?2:"="===t[s-1]?1:0,o=new c(3*s/4-a),n=a>0?s-4:s;var l=0;for(e=0,r=0;n>e;e+=4,r+=3)i=u[t.charCodeAt(e)]<<18|u[t.charCodeAt(e+1)]<<12|u[t.charCodeAt(e+2)]<<6|u[t.charCodeAt(e+3)],o[l++]=(16711680&i)>>16,o[l++]=(65280&i)>>8,o[l++]=255&i;return 2===a?(i=u[t.charCodeAt(e)]<<2|u[t.charCodeAt(e+1)]>>4,o[l++]=255&i):1===a&&(i=u[t.charCodeAt(e)]<<10|u[t.charCodeAt(e+1)]<<4|u[t.charCodeAt(e+2)]>>2,o[l++]=i>>8&255,o[l++]=255&i),o}function a(t){return l[t>>18&63]+l[t>>12&63]+l[t>>6&63]+l[63&t]}function o(t,e,r){for(var n,i=[],o=e;r>o;o+=3)n=(t[o]<<16)+(t[o+1]<<8)+t[o+2],i.push(a(n));return i.join("")}function s(t){for(var e,r=t.length,n=r%3,i="",a=[],s=16383,u=0,c=r-n;c>u;u+=s)a.push(o(t,u,u+s>c?c:u+s));return 1===n?(e=t[r-1],i+=l[e>>2],i+=l[e<<4&63],i+="=="):2===n&&(e=(t[r-2]<<8)+t[r-1],i+=l[e>>10],i+=l[e>>4&63],i+=l[e<<2&63],i+="="),a.push(i),a.join("")}r.toByteArray=i,r.fromByteArray=s;var l=[],u=[],c="undefined"!=typeof Uint8Array?Uint8Array:Array;n()},{}],12:[function(t,e,r){r.read=function(t,e,r,n,i){var a,o,s=8*i-n-1,l=(1<>1,c=-7,f=r?i-1:0,h=r?-1:1,d=t[e+f];for(f+=h,a=d&(1<<-c)-1,d>>=-c,c+=s;c>0;a=256*a+t[e+f],f+=h,c-=8);for(o=a&(1<<-c)-1,a>>=-c,c+=n;c>0;o=256*o+t[e+f],f+=h,c-=8);if(0===a)a=1-u;else{if(a===l)return o?NaN:(d?-1:1)*(1/0);o+=Math.pow(2,n),a-=u}return(d?-1:1)*o*Math.pow(2,a-n)},r.write=function(t,e,r,n,i,a){var o,s,l,u=8*a-i-1,c=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:a-1,p=n?1:-1,g=0>e||0===e&&0>1/e?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,o=c):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),e+=o+f>=1?h/l:h*Math.pow(2,1-f),e*l>=2&&(o++,l/=2),o+f>=c?(s=0,o=c):o+f>=1?(s=(e*l-1)*Math.pow(2,i),o+=f):(s=e*Math.pow(2,f-1)*Math.pow(2,i),o=0));i>=8;t[r+d]=255&s,d+=p,s/=256,i-=8);for(o=o<0;t[r+d]=255&o,d+=p,o/=256,u-=8);t[r+d-p]|=128*g}},{}],13:[function(t,e,r){var n={}.toString;e.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},{}],14:[function(t,e,r){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(t){return"function"==typeof t}function a(t){return"number"==typeof t}function o(t){return"object"==typeof t&&null!==t}function s(t){return void 0===t}e.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(t){if(!a(t)||0>t||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},n.prototype.emit=function(t){var e,r,n,a,l,u;if(this._events||(this._events={}),"error"===t&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;throw TypeError('Uncaught, unspecified "error" event.')}if(r=this._events[t],s(r))return!1;if(i(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),r.apply(this,a)}else if(o(r))for(a=Array.prototype.slice.call(arguments,1),u=r.slice(),n=u.length,l=0;n>l;l++)u[l].apply(this,a);return!0},n.prototype.addListener=function(t,e){var r;if(!i(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,i(e.listener)?e.listener:e),this._events[t]?o(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,o(this._events[t])&&!this._events[t].warned&&(r=s(this._maxListeners)?n.defaultMaxListeners:this._maxListeners,r&&r>0&&this._events[t].length>r&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(t,e){function r(){this.removeListener(t,r),n||(n=!0,e.apply(this,arguments))}if(!i(e))throw TypeError("listener must be a function");var n=!1;return r.listener=e,this.on(t,r),this},n.prototype.removeListener=function(t,e){var r,n,a,s;if(!i(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],a=r.length,n=-1,r===e||i(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(r)){for(s=a;s-- >0;)if(r[s]===e||r[s].listener&&r[s].listener===e){n=s;break}if(0>n)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},n.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],i(r))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},n.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?i(this._events[t])?[this._events[t]]:this._events[t].slice():[]},n.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(i(e))return 1;if(e)return e.length}return 0},n.listenerCount=function(t,e){return t.listenerCount(e)}},{}],15:[function(t,e,r){function n(){c=!1,s.length?u=s.concat(u):f=-1,u.length&&i()}function i(){if(!c){var t=setTimeout(n);c=!0;for(var e=u.length;e;){for(s=u,u=[];++f1)for(var r=1;rs)){if(n>i){var l=n;n=i,i=l,l=o,o=s,s=l}e.isConstraint(n,i)||a(t[n],t[i],t[o],t[s])<0&&r.push(n,i)}}function i(t,e){for(var r=[],i=t.length,o=e.stars,s=0;i>s;++s)for(var l=o[s],u=1;uc||e.isConstraint(s,c))){for(var f=l[u-1],h=-1,d=1;dh||a(t[s],t[c],t[f],t[h])<0&&r.push(s,c)}}for(;r.length>0;){for(var c=r.pop(),s=r.pop(),f=-1,h=-1,l=o[s],p=1;pf||0>h||a(t[s],t[c],t[f],t[h])>=0||(e.flip(s,c),n(t,e,r,f,s,h),n(t,e,r,s,h,f),n(t,e,r,h,c,f),n(t,e,r,c,f,h))}}var a=t("robust-in-sphere")[4];t("binary-search-bounds");e.exports=i},{"binary-search-bounds":21,"robust-in-sphere":22}],18:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o){this.cells=t,this.neighbor=e,this.flags=n,this.constraint=r,this.active=i,this.next=a,this.boundary=o}function i(t,e){return t[0]-e[0]||t[1]-e[1]||t[2]-e[2]}function a(t,e){for(var r=t.cells(),a=r.length,o=0;a>o;++o){var s=r[o],l=s[0],u=s[1],c=s[2];c>u?l>u&&(s[0]=u,s[1]=c,s[2]=l):l>c&&(s[0]=c,s[1]=l,s[2]=u)}r.sort(i);for(var f=new Array(a),o=0;oo;++o)for(var s=r[o],y=0;3>y;++y){var l=s[y],u=s[(y+1)%3],b=p[3*o+y]=m.locate(u,l,t.opposite(u,l)),x=g[3*o+y]=t.isConstraint(l,u);0>b&&(x?d.push(o):(h.push(o),f[o]=1),e&&v.push([u,l,-1]))}return m}function o(t,e,r){for(var n=0,i=0;i0||l.length>0;){for(;s.length>0;){var d=s.pop();if(u[d]!==-i){u[d]=i;for(var p=(c[d],0);3>p;++p){var g=h[3*d+p];g>=0&&0===u[g]&&(f[3*d+p]?l.push(g):(s.push(g),u[g]=i))}}}var v=l;l=s,s=v,l.length=0,i=-i}var m=o(c,u,e);return r?m.concat(n.boundary):m}var l=t("binary-search-bounds");e.exports=s;var u=n.prototype;u.locate=function(){var t=[0,0,0];return function(e,r,n){var a=e,o=r,s=n;return n>r?e>r&&(a=r,o=n,s=e):e>n&&(a=n,o=e,s=r),0>a?-1:(t[0]=a,t[1]=o,t[2]=s,l.eq(this.cells,t,i))}}()},{"binary-search-bounds":21}],19:[function(t,e,r){"use strict";function n(t,e,r,n,i){this.a=t,this.b=e,this.idx=r,this.lowerIds=n,this.upperIds=i}function i(t,e,r,n){this.a=t,this.b=e,this.type=r,this.idx=n}function a(t,e){var r=t.a[0]-e.a[0]||t.a[1]-e.a[1]||t.type-e.type;return r?r:t.type!==p&&(r=d(t.a,t.b,e.b))?r:t.idx-e.idx}function o(t,e){return d(t.a,t.b,e)}function s(t,e,r,n,i){for(var a=h.lt(e,n,o),s=h.gt(e,n,o),l=a;s>l;++l){for(var u=e[l],c=u.lowerIds,f=c.length;f>1&&d(r[c[f-2]],r[c[f-1]],n)>0;)t.push([c[f-1],c[f-2],i]),f-=1;c.length=f,c.push(i);for(var p=u.upperIds,f=p.length;f>1&&d(r[p[f-2]],r[p[f-1]],n)<0;)t.push([p[f-2],p[f-1],i]),f-=1;p.length=f,p.push(i)}}function l(t,e){var r;return(r=t.a[0]f;++f)l.push(new i(t[f],null,p,f));for(var f=0;o>f;++f){var h=e[f],d=t[h[0]],m=t[h[1]];d[0]m[0]&&l.push(new i(m,d,v,f),new i(d,m,g,f))}l.sort(a);for(var y=l[0].a[0]-(1+Math.abs(l[0].a[0]))*Math.pow(2,-52),b=[new n([y,1],[y,0],-1,[],[],[],[])],x=[],f=0,_=l.length;_>f;++f){var w=l[f],A=w.type;A===p?s(x,b,t,w.a,w.idx):A===v?u(b,t,w):c(b,t,w)}return x}var h=t("binary-search-bounds"),d=t("robust-orientation")[3],p=0,g=1,v=2;e.exports=f},{"binary-search-bounds":21,"robust-orientation":133}],20:[function(t,e,r){"use strict";function n(t,e){this.stars=t,this.edges=e}function i(t,e,r){for(var n=1,i=t.length;i>n;n+=2)if(t[n-1]===e&&t[n]===r)return t[n-1]=t[i-2],t[n]=t[i-1],void(t.length=i-2)}function a(t,e){for(var r=new Array(t),i=0;t>i;++i)r[i]=[];return new n(r,e)}var o=t("binary-search-bounds");e.exports=a;var s=n.prototype;s.isConstraint=function(){function t(t,e){return t[0]-e[0]||t[1]-e[1]}var e=[0,0];return function(r,n){return e[0]=Math.min(r,n),e[1]=Math.max(r,n),o.eq(this.edges,e,t)>=0}}(),s.removeTriangle=function(t,e,r){var n=this.stars;i(n[t],e,r),i(n[e],r,t),i(n[r],t,e)},s.addTriangle=function(t,e,r){var n=this.stars;n[t].push(e,r),n[e].push(r,t),n[r].push(t,e)},s.opposite=function(t,e){for(var r=this.stars[e],n=1,i=r.length;i>n;n+=2)if(r[n]===t)return r[n-1];return-1},s.flip=function(t,e){var r=this.opposite(t,e),n=this.opposite(e,t);this.removeTriangle(t,e,r),this.removeTriangle(e,t,n),this.addTriangle(t,n,r),this.addTriangle(e,r,n)},s.edges=function(){for(var t=this.stars,e=[],r=0,n=t.length;n>r;++r)for(var i=t[r],a=0,o=i.length;o>a;a+=2)e.push([i[a],i[a+1]]);return e},s.cells=function(){for(var t=this.stars,e=[],r=0,n=t.length;n>r;++r)for(var i=t[r],a=0,o=i.length;o>a;a+=2){var s=i[a],l=i[a+1];r>>1,x=a[m]"];return i?e.indexOf("c")<0?a.push(";if(x===y){return m}else if(x<=y){"):a.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){"):a.push(";if(",e,"){i=m;"),r?a.push("l=m+1}else{h=m-1}"):a.push("h=m-1}else{l=m+1}"),a.push("}"),i?a.push("return -1};"):a.push("return i};"),a.join("")}function i(t,e,r,i){var a=new Function([n("A","x"+t+"y",e,["y"],i),n("P","c(x,y)"+t+"0",e,["y","c"],i),"function dispatchBsearch",r,"(a,y,c,l,h){if(typeof(c)==='function'){return P(a,(l===void 0)?0:l|0,(h===void 0)?a.length-1:h|0,y,c)}else{return A(a,(c===void 0)?0:c|0,(l===void 0)?a.length-1:l|0,y)}}return dispatchBsearch",r].join(""));return a()}e.exports={ge:i(">=",!1,"GE"),gt:i(">",!1,"GT"),lt:i("<",!0,"LT"),le:i("<=",!0,"LE"),eq:i("-",!0,"EQ",!0)}},{}],22:[function(t,e,r){"use strict";function n(t,e){for(var r=new Array(t.length-1),n=1;nr;++r){e[r]=new Array(t);for(var n=0;t>n;++n)e[r][n]=["m",n,"[",t-r-2,"]"].join("")}return e}function a(t){if(1===t.length)return t[0];if(2===t.length)return["sum(",t[0],",",t[1],")"].join("");var e=t.length>>1;return["sum(",a(t.slice(0,e)),",",a(t.slice(e)),")"].join("")}function o(t,e){if("m"===t.charAt(0)){if("w"===e.charAt(0)){var r=t.split("[");return["w",e.substr(1),"m",r[0].substr(1)].join("")}return["prod(",t,",",e,")"].join("")}return o(e,t)}function s(t){return t&!0?"-":""}function l(t){if(2===t.length)return[["diff(",o(t[0][0],t[1][1]),",",o(t[1][0],t[0][1]),")"].join("")];for(var e=[],r=0;rn;++n)r.push(["prod(m",t,"[",n,"],m",t,"[",n,"])"].join(""));return a(r)}function c(t){for(var e=[],r=[],o=i(t),s=0;t>s;++s)o[0][s]="1",o[t-1][s]="w"+s;for(var s=0;t>s;++s)0===(1&s)?e.push.apply(e,l(n(o,s))):r.push.apply(r,l(n(o,s)));for(var c=a(e),f=a(r),h="exactInSphere"+t,d=[],s=0;t>s;++s)d.push("m"+s);for(var p=["function ",h,"(",d.join(),"){"],s=0;t>s;++s){p.push("var w",s,"=",u(s,t),";");for(var g=0;t>g;++g)g!==s&&p.push("var w",s,"m",g,"=scale(w",s,",m",g,"[0]);")}p.push("var p=",c,",n=",f,",d=diff(p,n);return d[d.length-1];}return ",h);var x=new Function("sum","diff","prod","scale",p.join(""));return x(m,y,v,b)}function f(){return 0}function h(){return 0}function d(){return 0}function p(t){var e=_[t.length];return e||(e=_[t.length]=c(t.length)),e.apply(void 0,t)}function g(){for(;_.length<=x;)_.push(c(_.length));for(var t=[],r=["slow"],n=0;x>=n;++n)t.push("a"+n),r.push("o"+n);for(var i=["function testInSphere(",t.join(),"){switch(arguments.length){case 0:case 1:return 0;"],n=2;x>=n;++n)i.push("case ",n,":return o",n,"(",t.slice(0,n).join(),");");i.push("}var s=new Array(arguments.length);for(var i=0;i=n;++n)e.exports[n]=_[n]}var v=t("two-product"),m=t("robust-sum"),y=t("robust-subtract"),b=t("robust-scale"),x=6,_=[f,h,d];g()},{"robust-scale":134,"robust-subtract":135,"robust-sum":136,"two-product":149}],23:[function(t,e,r){"use strict";function n(t){var e=x(t),r=b(y(e),t);return 0>r?[e,w(e,1/0)]:r>0?[w(e,-(1/0)),e]:[e,e]}function i(t,e){for(var r=new Array(e.length),n=0;n=t.length)return o[e-t.length];var r=t[e];return[y(r[0]),y(r[1])]}for(var o=[],s=0;s=0;--s){var g=n[s],u=g[0],v=e[u],m=v[0],x=v[1],w=t[m],k=t[x];if((w[0]-k[0]||w[1]-k[1])<0){var M=m;m=x,x=M}v[0]=m;var E,T=v[1]=g[1];for(i&&(E=v[2]);s>0&&n[s-1][0]===u;){var g=n[--s],L=g[1];i?e.push([T,L,E]):e.push([T,L]),T=L}i?e.push([T,x,E]):e.push([T,x])}return o}function u(t,e,r){for(var i=t.length+e.length,a=new g(i),o=r,s=0;ss;++s){var p=a.find(s);p===s?(d[s]=f,t[f++]=t[s]):(h=!1,d[s]=-1)}if(t.length=f,h)return null;for(var s=0;i>s;++s)d[s]<0&&(d[s]=d[a.find(s)]);return d}function c(t,e){return t[0]-e[0]||t[1]-e[1]}function f(t,e){var r=t[0]-e[0]||t[1]-e[1];return r?r:t[2]e[2]?1:0}function h(t,e,r){if(0!==t.length){if(e)for(var n=0;n0||d.length>0}function p(t,e,r){var n,i=!1;if(r){n=e;for(var a=new Array(e.length),o=0;o0?r=r.shln(f):0>f&&(c=c.shln(-f)),l(r,c)}var i=t("./is-rat"),a=t("./lib/is-bn"),o=t("./lib/num-to-bn"),s=t("./lib/str-to-bn"),l=t("./lib/rationalize"),u=t("./div");e.exports=n},{"./div":27,"./is-rat":29,"./lib/is-bn":33,"./lib/num-to-bn":34,"./lib/rationalize":35,"./lib/str-to-bn":36}],29:[function(t,e,r){"use strict";function n(t){return Array.isArray(t)&&2===t.length&&i(t[0])&&i(t[1])}var i=t("./lib/is-bn");e.exports=n},{"./lib/is-bn":33}],30:[function(t,e,r){"use strict";function n(t){return t.cmp(new i(0))}var i=t("bn.js");e.exports=n},{"bn.js":38}],31:[function(t,e,r){"use strict";function n(t){var e=t.length,r=t.words,n=0;if(1===e)n=r[0];else if(2===e)n=r[0]+67108864*r[1];else for(var n=0,i=0;e>i;i++){var a=r[i];n+=a*Math.pow(67108864,i)}return t.sign?-n:n}e.exports=n},{}],32:[function(t,e,r){"use strict";function n(t){var e=a(i.lo(t));if(32>e)return e;var r=a(i.hi(t));return r>20?52:r+32}var i=t("double-bits"),a=t("bit-twiddle").countTrailingZeros;e.exports=n},{"bit-twiddle":9,"double-bits":49}],33:[function(t,e,r){"use strict";function n(t){return t&&"object"==typeof t&&Boolean(t.words)}t("bn.js");e.exports=n},{"bn.js":38}],34:[function(t,e,r){"use strict";function n(t){var e=a.exponent(t);return 52>e?new i(t):new i(t*Math.pow(2,52-e)).shln(e-52)}var i=t("bn.js"),a=t("double-bits");e.exports=n},{"bn.js":38,"double-bits":49}],35:[function(t,e,r){"use strict";function n(t,e){var r=a(t),n=a(e);if(0===r)return[i(0),i(1)];if(0===n)return[i(0),i(0)];0>n&&(t=t.neg(),e=e.neg());var o=t.gcd(e);return o.cmpn(1)?[t.div(o),e.div(o)]:[t,e]}var i=t("./num-to-bn"),a=t("./bn-sign");e.exports=n},{"./bn-sign":30,"./num-to-bn":34}],36:[function(t,e,r){"use strict";function n(t){return new i(t)}var i=t("bn.js");e.exports=n},{"bn.js":38}],37:[function(t,e,r){"use strict";function n(t,e){return i(t[0].mul(e[0]),t[1].mul(e[1]))}var i=t("./lib/rationalize");e.exports=n},{"./lib/rationalize":35}],38:[function(t,e,r){!function(t,e){"use strict";function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function i(t,e,r){return null!==t&&"object"==typeof t&&Array.isArray(t.words)?t:(this.sign=!1,this.words=null,this.length=0,this.red=null,"le"!==e&&"be"!==e||(r=e,e=10),void(null!==t&&this._init(t||0,e||10,r||"be")))}function a(t,e,r){for(var n=0,i=Math.min(t.length,r),a=e;i>a;a++){var o=t.charCodeAt(a)-48;n<<=4,n|=o>=49&&54>=o?o-49+10:o>=17&&22>=o?o-17+10:15&o}return n}function o(t,e,r,n){for(var i=0,a=Math.min(t.length,r),o=e;a>o;o++){var s=t.charCodeAt(o)-48;i*=n,i+=s>=49?s-49+10:s>=17?s-17+10:s}return i}function s(t,e){this.name=t,this.p=new i(e,16),this.n=this.p.bitLength(),this.k=new i(1).ishln(this.n).isub(this.p),this.tmp=this._tmp()}function l(){s.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function u(){s.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function c(){s.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function f(){s.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function h(t){if("string"==typeof t){var e=i._prime(t);this.m=e.p,this.prime=e}else this.m=t,this.prime=null}function d(t){h.call(this,t),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new i(1).ishln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv.sign=!0,this.minv=this.minv.mod(this.r)}"object"==typeof t?t.exports=i:e.BN=i,i.BN=i,i.wordSize=26,i.prototype._init=function(t,e,n){if("number"==typeof t)return this._initNumber(t,e,n);if("object"==typeof t)return this._initArray(t,e,n);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&36>=e),t=t.toString().replace(/\s+/g,"");var i=0;"-"===t[0]&&i++,16===e?this._parseHex(t,i):this._parseBase(t,e,i),"-"===t[0]&&(this.sign=!0),this.strip(),"le"===n&&this._initArray(this.toArray(),e,n)},i.prototype._initNumber=function(t,e,n){0>t&&(this.sign=!0,t=-t),67108864>t?(this.words=[67108863&t],this.length=1):4503599627370496>t?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(9007199254740992>t),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),e,n)},i.prototype._initArray=function(t,e,n){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3){var s=t[i]|t[i-1]<<8|t[i-2]<<16;this.words[o]|=s<>>26-a&67108863,a+=24,a>=26&&(a-=26,o++)}else if("le"===n)for(var i=0,o=0;i>>26-a&67108863,a+=24,a>=26&&(a-=26,o++)}return this.strip()},i.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var r=0;r=e;r-=6){var o=a(t,r,r+6);this.words[i]|=o<>>26-n&4194303,n+=24,n>=26&&(n-=26,i++)}if(r+6!==e){var o=a(t,e,r+6);this.words[i]|=o<>>26-n&4194303}this.strip()},i.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;67108863>=i;i*=e)n++;n--,i=i/e|0;for(var a=t.length-r,s=a%n,l=Math.min(a,a-s)+r,u=0,c=r;l>c;c+=n)u=o(t,c,c+n,e),this.imuln(i),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==s){for(var f=1,u=o(t,c,t.length,e),c=0;s>c;c++)f*=e;this.imuln(f),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}},i.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.sign=!1),this},i.prototype.inspect=function(){return(this.red?""};var p=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],g=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],v=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];i.prototype.toString=function(t,e){if(t=t||10,16===t||"hex"===t){for(var n="",i=0,e=0|e||1,a=0,o=0;o>>24-i&16777215,n=0!==a||o!==this.length-1?p[6-l.length]+l+n:l+n,i+=2,i>=26&&(i-=26,o--)}for(0!==a&&(n=a.toString(16)+n);n.length%e!==0;)n="0"+n;return this.sign&&(n="-"+n),n}if(t===(0|t)&&t>=2&&36>=t){var u=g[t],c=v[t],n="",f=this.clone();for(f.sign=!1;0!==f.cmpn(0);){var h=f.modn(c).toString(t);f=f.idivn(c),n=0!==f.cmpn(0)?p[u-h.length]+h+n:h+n}return 0===this.cmpn(0)&&(n="0"+n),this.sign&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toArray=function(t){this.strip();var e=new Array(this.byteLength());e[0]=0;var r=this.clone();if("le"!==t)for(var n=0;0!==r.cmpn(0);n++){var i=r.andln(255);r.ishrn(8),e[e.length-n-1]=i}else for(var n=0;0!==r.cmpn(0);n++){var i=r.andln(255);r.ishrn(8),e[n]=i}return e},Math.clz32?i.prototype._countBits=function(t){return 32-Math.clz32(t)}:i.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},i.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0===(8191&e)&&(r+=13,e>>>=13),0===(127&e)&&(r+=7,e>>>=7),0===(15&e)&&(r+=4,e>>>=4),0===(3&e)&&(r+=2,e>>>=2),0===(1&e)&&r++,r},i.prototype.bitLength=function(){var t=0,e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},i.prototype.zeroBits=function(){if(0===this.cmpn(0))return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},i.prototype.iand=function(t){this.sign=this.sign&&t.sign;var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},i.prototype.ixor=function(t){this.sign=this.sign||t.sign;var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;nt.length?this.clone().ixor(t):t.clone().ixor(this)},i.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);for(var n=t/26|0,i=t%26;this.length<=n;)this.words[this.length++]=0;return e?this.words[n]=this.words[n]|1<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,a=0;a>>26}for(;0!==i&&a>>26}if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;at.length?this.clone().iadd(t):t.clone().iadd(this)},i.prototype.isub=function(t){if(t.sign){t.sign=!1;var e=this.iadd(t);return t.sign=!0,e._normSign()}if(this.sign)return this.sign=!1,this.iadd(t),this.sign=!0,this._normSign();var r=this.cmp(t);if(0===r)return this.sign=!1,this.length=1,this.words[0]=0,this;var n,i;r>0?(n=this,i=t):(n=t,i=this);for(var a=0,o=0;o>26,this.words[o]=67108863&e}for(;0!==a&&o>26,this.words[o]=67108863&e}if(0===a&&o>>26,a=67108863&r,o=Math.min(n,t.length-1),s=Math.max(0,n-this.length+1);o>=s;s++){var l=n-s,u=0|this.words[l],c=0|t.words[s],f=u*c,h=67108863&f;i=i+(f/67108864|0)|0,h=h+a|0,a=67108863&h,i=i+(h>>>26)|0}e.words[n]=a,r=i}return 0!==r?e.words[n]=r:e.length--,e.strip()},i.prototype._bigMulTo=function(t,e){e.sign=t.sign!==this.sign,e.length=this.length+t.length;for(var r=0,n=0,i=0;i=l;l++){var u=i-l,c=0|this.words[u],f=0|t.words[l],h=c*f,d=67108863&h;a=a+(h/67108864|0)|0,d=d+o|0,o=67108863&d,a=a+(d>>>26)|0,n+=a>>>26,a&=67108863}e.words[i]=o,r=a,a=n}return 0!==r?e.words[i]=r:e.length--,e.strip()},i.prototype.mulTo=function(t,e){var r;return r=this.length+t.length<63?this._smallMulTo(t,e):this._bigMulTo(t,e)},i.prototype.mul=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},i.prototype.imul=function(t){if(0===this.cmpn(0)||0===t.cmpn(0))return this.words[0]=0,this.length=1,this;var e=this.length,r=t.length;this.sign=t.sign!==this.sign,this.length=this.length+t.length,this.words[this.length-1]=0;for(var n=this.length-2;n>=0;n--){for(var i=0,a=0,o=Math.min(n,r-1),s=Math.max(0,n-e+1);o>=s;s++){var l=n-s,u=this.words[l],c=t.words[s],f=u*c,h=67108863&f;i+=f/67108864|0,h+=a,a=67108863&h,i+=h>>>26}this.words[n]=a,this.words[n+1]+=i,i=0}for(var i=0,l=1;l>>26}return this.strip()},i.prototype.imuln=function(t){r("number"==typeof t);for(var e=0,n=0;n>=26,e+=i/67108864|0,e+=a>>>26,this.words[n]=67108863&a}return 0!==e&&(this.words[n]=e,this.length++),this},i.prototype.muln=function(t){return this.clone().imuln(t)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.mul(this)},i.prototype.ishln=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,i=67108863>>>26-e<<26-e;if(0!==e){for(var a=0,o=0;o>>26-e}a&&(this.words[o]=a,this.length++)}if(0!==n){for(var o=this.length-1;o>=0;o--)this.words[o+n]=this.words[o];for(var o=0;n>o;o++)this.words[o]=0;this.length+=n}return this.strip()},i.prototype.ishrn=function(t,e,n){r("number"==typeof t&&t>=0);var i;i=e?(e-e%26)/26:0;var a=t%26,o=Math.min((t-a)/26,this.length),s=67108863^67108863>>>a<u;u++)l.words[u]=this.words[u];l.length=o}if(0===o);else if(this.length>o){this.length-=o;for(var u=0;u=0&&(0!==c||u>=i);u--){var f=this.words[u];this.words[u]=c<<26-a|f>>>a,c=f&s}return l&&0!==c&&(l.words[l.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this.strip(),this},i.prototype.shln=function(t){return this.clone().ishln(t)},i.prototype.shrn=function(t){return this.clone().ishrn(t)},i.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,i=1<=0);var e=t%26,n=(t-e)/26;if(r(!this.sign,"imaskn works only with positive numbers"),0!==e&&n++,this.length=Math.min(n,this.length),0!==e){var i=67108863^67108863>>>e<t?this.isubn(-t):this.sign?1===this.length&&this.words[0]=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},i.prototype.isubn=function(t){if(r("number"==typeof t),0>t)return this.iaddn(-t);if(this.sign)return this.sign=!1,this.iaddn(t),this.sign=!0,this;this.words[0]-=t;for(var e=0;e>26)-(u/67108864|0),this.words[i+n]=67108863&l}for(;i>26,this.words[i+n]=67108863&l}if(0===s)return this.strip();r(-1===s),s=0;for(var i=0;i>26,this.words[i]=67108863&l}return this.sign=!0,this.strip()},i.prototype._wordDiv=function(t,e){var r=this.length-t.length,n=this.clone(),a=t,o=a.words[a.length-1],s=this._countBits(o);r=26-s,0!==r&&(a=a.shln(r),n.ishln(r),o=a.words[a.length-1]);var l,u=n.length-a.length;if("mod"!==e){l=new i(null),l.length=u+1,l.words=new Array(l.length);for(var c=0;c=0;h--){var d=67108864*n.words[a.length+h]+n.words[a.length+h-1];for(d=Math.min(d/o|0,67108863),n._ishlnsubmul(a,d,h);n.sign;)d--,n.sign=!1,n._ishlnsubmul(a,1,h),0!==n.cmpn(0)&&(n.sign=!n.sign);l&&(l.words[h]=d)}return l&&l.strip(),n.strip(),"div"!==e&&0!==r&&n.ishrn(r),{div:l?l:null,mod:n}},i.prototype.divmod=function(t,e){if(r(0!==t.cmpn(0)),this.sign&&!t.sign){var n,a,o=this.neg().divmod(t,e);return"mod"!==e&&(n=o.div.neg()),"div"!==e&&(a=0===o.mod.cmpn(0)?o.mod:t.sub(o.mod)),{div:n,mod:a}}if(!this.sign&&t.sign){var n,o=this.divmod(t.neg(),e);return"mod"!==e&&(n=o.div.neg()),{div:n,mod:o.mod}}return this.sign&&t.sign?this.neg().divmod(t.neg(),e):t.length>this.length||this.cmp(t)<0?{div:new i(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new i(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new i(this.modn(t.words[0]))}:this._wordDiv(t,e)},i.prototype.div=function(t){return this.divmod(t,"div").div},i.prototype.mod=function(t){return this.divmod(t,"mod").mod},i.prototype.divRound=function(t){var e=this.divmod(t);if(0===e.mod.cmpn(0))return e.div;var r=e.div.sign?e.mod.isub(t):e.mod,n=t.shrn(1),i=t.andln(1),a=r.cmp(n);return 0>a||1===i&&0===a?e.div:e.div.sign?e.div.isubn(1):e.div.iaddn(1)},i.prototype.modn=function(t){r(67108863>=t);for(var e=(1<<26)%t,n=0,i=this.length-1;i>=0;i--)n=(e*n+this.words[i])%t;return n},i.prototype.idivn=function(t){r(67108863>=t);for(var e=0,n=this.length-1;n>=0;n--){var i=this.words[n]+67108864*e;this.words[n]=i/t|0,e=i%t}return this.strip()},i.prototype.divn=function(t){return this.clone().idivn(t)},i.prototype.egcd=function(t){r(!t.sign),r(0!==t.cmpn(0));var e=this,n=t.clone();e=e.sign?e.mod(t):e.clone();for(var a=new i(1),o=new i(0),s=new i(0),l=new i(1),u=0;e.isEven()&&n.isEven();)e.ishrn(1),n.ishrn(1),++u;for(var c=n.clone(),f=e.clone();0!==e.cmpn(0);){for(;e.isEven();)e.ishrn(1),a.isEven()&&o.isEven()?(a.ishrn(1),o.ishrn(1)):(a.iadd(c).ishrn(1),o.isub(f).ishrn(1));for(;n.isEven();)n.ishrn(1),s.isEven()&&l.isEven()?(s.ishrn(1),l.ishrn(1)):(s.iadd(c).ishrn(1),l.isub(f).ishrn(1));e.cmp(n)>=0?(e.isub(n),a.isub(s),o.isub(l)):(n.isub(e),s.isub(a),l.isub(o))}return{a:s,b:l,gcd:n.ishln(u)}},i.prototype._invmp=function(t){r(!t.sign),r(0!==t.cmpn(0));var e=this,n=t.clone();e=e.sign?e.mod(t):e.clone();for(var a=new i(1),o=new i(0),s=n.clone();e.cmpn(1)>0&&n.cmpn(1)>0;){for(;e.isEven();)e.ishrn(1),a.isEven()?a.ishrn(1):a.iadd(s).ishrn(1);for(;n.isEven();)n.ishrn(1),o.isEven()?o.ishrn(1):o.iadd(s).ishrn(1);e.cmp(n)>=0?(e.isub(n),a.isub(o)):(n.isub(e),o.isub(a))}return 0===e.cmpn(1)?a:o},i.prototype.gcd=function(t){if(0===this.cmpn(0))return t.clone();if(0===t.cmpn(0))return this.clone();var e=this.clone(),r=t.clone();e.sign=!1,r.sign=!1;for(var n=0;e.isEven()&&r.isEven();n++)e.ishrn(1),r.ishrn(1);for(;;){for(;e.isEven();)e.ishrn(1);for(;r.isEven();)r.ishrn(1);var i=e.cmp(r);if(0>i){var a=e;e=r,r=a}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.ishln(n)},i.prototype.invm=function(t){return this.egcd(t).a.mod(t)},i.prototype.isEven=function(){return 0===(1&this.words[0])},i.prototype.isOdd=function(){return 1===(1&this.words[0])},i.prototype.andln=function(t){return this.words[0]&t},i.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,n=(t-e)/26,i=1<a;a++)this.words[a]=0;return this.words[n]|=i,this.length=n+1,this}for(var o=i,a=n;0!==o&&a>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},i.prototype.cmpn=function(t){var e=0>t;if(e&&(t=-t),this.sign&&!e)return-1;if(!this.sign&&e)return 1;t&=67108863,this.strip();var r;if(this.length>1)r=1;else{var n=this.words[0];r=n===t?0:t>n?-1:1}return this.sign&&(r=-r),r},i.prototype.cmp=function(t){if(this.sign&&!t.sign)return-1;if(!this.sign&&t.sign)return 1;var e=this.ucmp(t);return this.sign?-e:e},i.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length=0;r--){var n=this.words[r],i=t.words[r];if(n!==i){i>n?e=-1:n>i&&(e=1);break}}return e},i.red=function(t){return new h(t)},i.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(!this.sign,"red works only with positives"),t.convertTo(this)._forceRed(t)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(t){return this.red=t,this},i.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},i.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},i.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},i.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},i.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},i.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},i.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},i.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var m={k256:null,p224:null,p192:null,p25519:null};s.prototype._tmp=function(){var t=new i(null);return t.words=new Array(Math.ceil(this.n/13)),t},s.prototype.ireduce=function(t){var e,r=t;do this.split(r,this.tmp),r=this.imulK(r),r=r.iadd(this.tmp),e=r.bitLength();while(e>this.n);var n=e0?r.isub(this.p):r.strip(),r},s.prototype.split=function(t,e){t.ishrn(this.n,0,e)},s.prototype.imulK=function(t){return t.imul(this.k)},n(l,s),l.prototype.split=function(t,e){for(var r=4194303,n=Math.min(t.length,9),i=0;n>i;i++)e.words[i]=t.words[i];if(e.length=n,t.length<=9)return t.words[0]=0,void(t.length=1);var a=t.words[9];e.words[e.length++]=a&r;for(var i=10;i>>22,a=o}t.words[i-10]=a>>>22,t.length-=9},l.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e,r=0,n=0;n>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},i._prime=function y(t){if(m[t])return m[t];var y;if("k256"===t)y=new l;else if("p224"===t)y=new u;else if("p192"===t)y=new c;else{if("p25519"!==t)throw new Error("Unknown prime "+t);y=new f}return m[t]=y,y},h.prototype._verify1=function(t){r(!t.sign,"red works only with positives"),r(t.red,"red works only with red numbers")},h.prototype._verify2=function(t,e){r(!t.sign&&!e.sign,"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},h.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.mod(this.m)._forceRed(this)},h.prototype.neg=function(t){var e=t.clone();return e.sign=!e.sign,e.iadd(this.m)._forceRed(this)},h.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},h.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},h.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},h.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},h.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.shln(e))},h.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},h.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},h.prototype.isqr=function(t){return this.imul(t,t)},h.prototype.sqr=function(t){return this.mul(t,t)},h.prototype.sqrt=function(t){if(0===t.cmpn(0))return t.clone();var e=this.m.andln(3);if(r(e%2===1),3===e){var n=this.m.add(new i(1)).ishrn(2),a=this.pow(t,n);return a}for(var o=this.m.subn(1),s=0;0!==o.cmpn(0)&&0===o.andln(1);)s++,o.ishrn(1);r(0!==o.cmpn(0));var l=new i(1).toRed(this),u=l.redNeg(),c=this.m.subn(1).ishrn(1),f=this.m.bitLength();for(f=new i(2*f*f).toRed(this);0!==this.pow(f,c).cmp(u);)f.redIAdd(u);for(var h=this.pow(f,o),a=this.pow(t,o.addn(1).ishrn(1)),d=this.pow(t,o),p=s;0!==d.cmp(l);){for(var g=d,v=0;0!==g.cmp(l);v++)g=g.redSqr();r(p>v);var m=this.pow(h,new i(1).ishln(p-v-1));a=a.redMul(m),h=m.redSqr(),d=d.redMul(h),p=v}return a},h.prototype.invm=function(t){var e=t._invmp(this.m);return e.sign?(e.sign=!1,this.imod(e).redNeg()):this.imod(e)},h.prototype.pow=function(t,e){var r=[];if(0===e.cmpn(0))return new i(1);for(var n=e.clone();0!==n.cmpn(0);)r.push(n.andln(1)),n.ishrn(1);for(var a=t,o=0;o=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},d.prototype.mul=function(t,e){if(0===t.cmpn(0)||0===e.cmpn(0))return new i(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),a=r.isub(n).ishrn(this.shift),o=a;return a.cmp(this.m)>=0?o=a.isub(this.m):a.cmpn(0)<0&&(o=a.iadd(this.m)),o._forceRed(this)},d.prototype.invm=function(t){var e=this.imod(t._invmp(this.m).mul(this.r2));return e._forceRed(this)}}("undefined"==typeof e||e,this)},{}],39:[function(t,e,r){"use strict";function n(t){return i(t[0])*i(t[1])}var i=t("./lib/bn-sign");e.exports=n},{"./lib/bn-sign":30}],40:[function(t,e,r){"use strict";function n(t,e){return i(t[0].mul(e[1]).sub(t[1].mul(e[0])),t[1].mul(e[1]))}var i=t("./lib/rationalize");e.exports=n},{"./lib/rationalize":35}],41:[function(t,e,r){"use strict";function n(t){var e=t[0],r=t[1];if(0===e.cmpn(0))return 0;var n=e.divmod(r),o=n.div,s=i(o),l=n.mod;if(0===l.cmpn(0))return s;if(s){var u=a(s)+4,c=i(l.shln(u).divRound(r));return 0>s&&(c=-c),s+c*Math.pow(2,-u)}var f=r.bitLength()-l.bitLength()+53,c=i(l.shln(f).divRound(r));return 1023>f?c*Math.pow(2,-f):(c*=Math.pow(2,-1023),c*Math.pow(2,1023-f))}var i=t("./lib/bn-to-num"),a=t("./lib/ctz");e.exports=n},{"./lib/bn-to-num":31,"./lib/ctz":32}],42:[function(t,e,r){"use strict";function n(t,e){for(var r=0;t>r;++r)if(!(e[r]<=e[r+t]))return!0;return!1}function i(t,e,r,i){for(var a=0,o=0,s=0,l=t.length;l>s;++s){var u=t[s];if(!n(e,u)){for(var c=0;2*e>c;++c)r[a++]=u[c];i[o++]=s}}return o}function a(t,e,r,n){var a=t.length,o=e.length;if(!(0>=a||0>=o)){var s=t[0].length>>>1;if(!(0>=s)){var l,u=f.mallocDouble(2*s*a),c=f.mallocInt32(a);if(a=i(t,s,u,c),a>0){if(1===s&&n)h.init(a),l=h.sweepComplete(s,r,0,a,u,c,0,a,u,c);else{var p=f.mallocDouble(2*s*o),g=f.mallocInt32(o);o=i(e,s,p,g),o>0&&(h.init(a+o),l=1===s?h.sweepBipartite(s,r,0,a,u,c,0,o,p,g):d(s,r,n,a,u,c,o,p,g),f.free(p),f.free(g))}f.free(u),f.free(c)}return l}}}function o(t,e){c.push([t,e])}function s(t){return c=[],a(t,t,o,!0),c}function l(t,e){return c=[],a(t,e,o,!1),c}function u(t,e,r){switch(arguments.length){case 1:return s(t);case 2:return"function"==typeof e?a(t,t,e,!0):l(t,e);case 3:return a(t,e,r,!1);default:throw new Error("box-intersect: Invalid arguments")}}e.exports=u;var c,f=t("typedarray-pool"),h=t("./lib/sweep"),d=t("./lib/intersect")},{"./lib/intersect":44,"./lib/sweep":48,"typedarray-pool":151}],43:[function(t,e,r){"use strict";function n(t,e,r){var n="bruteForce"+(t?"Red":"Blue")+(e?"Flip":"")+(r?"Full":""),i=["function ",n,"(",w.join(),"){","var ",u,"=2*",a,";"],l="for(var i="+c+","+p+"="+u+"*"+c+";i<"+f+";++i,"+p+"+="+u+"){var x0="+h+"["+o+"+"+p+"],x1="+h+"["+o+"+"+p+"+"+a+"],xi="+d+"[i];",A="for(var j="+g+","+b+"="+u+"*"+g+";j<"+v+";++j,"+b+"+="+u+"){var y0="+m+"["+o+"+"+b+"],"+(r?"y1="+m+"["+o+"+"+b+"+"+a+"],":"")+"yi="+y+"[j];";return t?i.push(l,_,":",A):i.push(A,_,":",l),r?i.push("if(y1"+v+"-"+g+"){"),t?(e(!0,!1),o.push("}else{"),e(!1,!1)):(o.push("if("+l+"){"),e(!0,!0),o.push("}else{"),e(!0,!1),o.push("}}else{if("+l+"){"),e(!1,!0),o.push("}else{"),e(!1,!1),o.push("}")),o.push("}}return "+r);var s=i.join("")+o.join(""),u=new Function(s);return u()}var a="d",o="ax",s="vv",l="fp",u="es",c="rs",f="re",h="rb",d="ri",p="rp",g="bs",v="be",m="bb",y="bi",b="bp",x="rv",_="Q",w=[a,o,s,c,f,h,d,g,v,m,y];r.partial=i(!1),r.full=i(!0)},{}],44:[function(t,e,r){"use strict";function n(t,e){var r=8*u.log2(e+1)*(t+1)|0,n=u.nextPow2(M*r);L.lengthS&&(l.free(S),S=l.mallocDouble(i))}function i(t,e,r,n,i,a,o,s,l){var u=M*t;L[u]=e,L[u+1]=r,L[u+2]=n,L[u+3]=i,L[u+4]=a,L[u+5]=o;var c=E*t;S[c]=s,S[c+1]=l}function a(t,e,r,n,i,a,o,s,l,u,c){var f=2*t,h=l*f,d=u[h+e];t:for(var p=i,g=i*f;a>p;++p,g+=f){var v=o[g+e],m=o[g+e+t];if(!(v>d||d>m||n&&d===v)){for(var y=s[p],b=e+1;t>b;++b){var v=o[g+b],m=o[g+b+t],x=u[h+b],_=u[h+b+t];if(x>m||v>_)continue t}var w;if(w=n?r(c,y):r(y,c),void 0!==w)return w}}}function o(t,e,r,n,i,a,o,s,l,u){var c=2*t,f=s*c,h=l[f+e];t:for(var d=n,p=n*c;i>d;++d,p+=c){var g=o[d];if(g!==u){var v=a[p+e],m=a[p+e+t];if(!(v>h||h>m)){for(var y=e+1;t>y;++y){var v=a[p+y],m=a[p+y+t],b=l[f+y],x=l[f+y+t];if(b>m||v>x)continue t}var _=r(g,u);if(void 0!==_)return _}}}}function s(t,e,r,s,l,u,c,g,T){n(t,s+c);var C,R=0,I=2*t;for(i(R++,0,0,s,0,c,r?16:0,-(1/0),1/0),r||i(R++,0,0,c,0,s,1,-(1/0),1/0);R>0;){R-=1;var P=R*M,O=L[P],N=L[P+1],z=L[P+2],D=L[P+3],F=L[P+4],B=L[P+5],j=R*E,U=S[j],V=S[j+1],q=1&B,H=!!(16&B),G=l,X=u,Y=g,W=T;if(q&&(G=g,X=T,Y=l,W=u),!(2&B&&(z=_(t,O,N,z,G,X,V),N>=z)||4&B&&(N=w(t,O,N,z,G,X,U),N>=z))){var Z=z-N,Q=F-D;if(H){if(y>t*Z*(Z+Q)){if(C=d.scanComplete(t,O,e,N,z,G,X,D,F,Y,W),void 0!==C)return C;continue}}else{if(t*Math.min(Z,Q)t*Z*Q){if(C=d.scanBipartite(t,O,e,q,N,z,G,X,D,F,Y,W),void 0!==C)return C;continue}}var $=b(t,O,N,z,G,X,U,V);if($>N)if(v>t*($-N)){if(C=h(t,O+1,e,N,$,G,X,D,F,Y,W),void 0!==C)return C}else if(O===t-2){if(C=q?d.sweepBipartite(t,e,D,F,Y,W,N,$,G,X):d.sweepBipartite(t,e,N,$,G,X,D,F,Y,W),void 0!==C)return C}else i(R++,O+1,N,$,D,F,q,-(1/0),1/0),i(R++,O+1,D,F,N,$,1^q,-(1/0),1/0);if(z>$){var K=p(t,O,D,F,Y,W),J=Y[I*K+O],tt=x(t,O,K,F,Y,W,J);if(F>tt&&i(R++,O,$,z,tt,F,(4|q)+(H?16:0),J,V),K>D&&i(R++,O,$,z,D,K,(2|q)+(H?16:0),U,J),K+1===tt){if(C=H?o(t,O,e,$,z,G,X,K,Y,W[K]):a(t,O,e,q,$,z,G,X,K,Y,W[K]),void 0!==C)return C}else if(tt>K){var et;if(H){if(et=A(t,O,$,z,G,X,J),et>$){var rt=x(t,O,$,et,G,X,J);if(O===t-2){if(rt>$&&(C=d.sweepComplete(t,e,$,rt,G,X,K,tt,Y,W),void 0!==C))return C;if(et>rt&&(C=d.sweepBipartite(t,e,rt,et,G,X,K,tt,Y,W),void 0!==C))return C}else rt>$&&i(R++,O+1,$,rt,K,tt,16,-(1/0),1/0),et>rt&&(i(R++,O+1,rt,et,K,tt,0,-(1/0),1/0),i(R++,O+1,K,tt,rt,et,1,-(1/0),1/0))}}else et=q?k(t,O,$,z,G,X,J):A(t,O,$,z,G,X,J),et>$&&(O===t-2?C=q?d.sweepBipartite(t,e,K,tt,Y,W,$,et,G,X):d.sweepBipartite(t,e,$,et,G,X,K,tt,Y,W):(i(R++,O+1,$,et,K,tt,q,-(1/0),1/0),i(R++,O+1,K,tt,$,et,1^q,-(1/0),1/0)))}}}}}e.exports=s;var l=t("typedarray-pool"),u=t("bit-twiddle"),c=t("./brute"),f=c.partial,h=c.full,d=t("./sweep"),p=t("./median"),g=t("./partition"),v=128,m=1<<22,y=1<<22,b=g("!(lo>=p0)&&!(p1>=hi)",["p0","p1"]),x=g("lo===p0",["p0"]),_=g("lol;++l,s+=o)for(var u=i[s],c=l,f=o*(l-1);c>r&&i[f+e]>u;--c,f-=o){for(var h=f,d=f+o,p=0;o>p;++p,++h,++d){var g=i[h];i[h]=i[d],i[d]=g}var v=a[c];a[c]=a[c-1],a[c-1]=v}}function i(t,e,r,i,a,l){if(r+1>=i)return r;for(var u=r,c=i,f=i+r>>>1,h=2*t,d=f,p=a[h*f+e];c>u;){if(s>c-u){n(t,e,u,c,a,l),p=a[h*f+e];break}var g=c-u,v=Math.random()*g+u|0,m=a[h*v+e],y=Math.random()*g+u|0,b=a[h*y+e],x=Math.random()*g+u|0,_=a[h*x+e];b>=m?_>=b?(d=y,p=b):m>=_?(d=v,p=m):(d=x,p=_):b>=_?(d=y,p=b):_>=m?(d=v,p=m):(d=x,p=_);for(var w=h*(c-1),A=h*d,k=0;h>k;++k,++w,++A){var M=a[w];a[w]=a[A],a[A]=M}var E=l[c-1];l[c-1]=l[d],l[d]=E,d=o(t,e,u,c-1,a,l,p);for(var w=h*(c-1),A=h*d,k=0;h>k;++k,++w,++A){var M=a[w];a[w]=a[A],a[A]=M}var E=l[c-1];if(l[c-1]=l[d],l[d]=E,d>f){for(c=d-1;c>u&&a[h*(c-1)+e]===p;)c-=1;c+=1}else{if(!(f>d))break;for(u=d+1;c>u&&a[h*u+e]===p;)u+=1}}return o(t,e,r,f,a,l,a[h*f+e])}e.exports=i;var a=t("./partition"),o=a("lo=0&&n.push("lo=e[k+n]"),t.indexOf("hi")>=0&&n.push("hi=e[k+o]"),r.push(i.replace("_",n.join()).replace("$",t)),Function.apply(void 0,r)}e.exports=n;var i="for(var j=2*a,k=j*c,l=k,m=c,n=b,o=a+b,p=c;d>p;++p,k+=j){var _;if($)if(m===p)m+=1,l+=j;else{for(var s=0;j>s;++s){var t=e[k+s];e[k+s]=e[l],e[l++]=t}var u=f[p];f[p]=f[m],f[m++]=u}}return m"},{}],47:[function(t,e,r){"use strict";function n(t,e){4*h>=e?i(0,e-1,t):f(0,e-1,t)}function i(t,e,r){for(var n=2*(t+1),i=t+1;e>=i;++i){for(var a=r[n++],o=r[n++],s=i,l=n-2;s-- >t;){var u=r[l-2],c=r[l-1];if(a>u)break;if(u===a&&o>c)break;r[l]=u,r[l+1]=c,l-=2}r[l]=a,r[l+1]=o}}function a(t,e,r){t*=2,e*=2;var n=r[t],i=r[t+1];r[t]=r[e],r[t+1]=r[e+1],r[e]=n,r[e+1]=i}function o(t,e,r){t*=2,e*=2,r[t]=r[e],r[t+1]=r[e+1]}function s(t,e,r,n){t*=2,e*=2,r*=2;var i=n[t],a=n[t+1];n[t]=n[e],n[t+1]=n[e+1],n[e]=n[r],n[e+1]=n[r+1],n[r]=i,n[r+1]=a}function l(t,e,r,n,i){t*=2,e*=2,i[t]=i[e],i[e]=r,i[t+1]=i[e+1],i[e+1]=n}function u(t,e,r){t*=2,e*=2;var n=r[t],i=r[e];return i>n?!1:n===i?r[t+1]>r[e+1]:!0}function c(t,e,r,n){t*=2;var i=n[t];return e>i?!0:i===e?n[t+1]>1,v=g-n,m=g+n,y=d,b=v,x=g,_=m,w=p,A=t+1,k=e-1,M=0;u(y,b,r)&&(M=y,y=b,b=M),u(_,w,r)&&(M=_,_=w,w=M),u(y,x,r)&&(M=y,y=x,x=M),u(b,x,r)&&(M=b,b=x,x=M),u(y,_,r)&&(M=y,y=_,_=M),u(x,_,r)&&(M=x,x=_,_=M),u(b,w,r)&&(M=b,b=w,w=M),u(b,x,r)&&(M=b,b=x,x=M),u(_,w,r)&&(M=_,_=w,w=M);for(var E=r[2*b],T=r[2*b+1],L=r[2*_],S=r[2*_+1],C=2*y,R=2*x,I=2*w,P=2*d,O=2*g,N=2*p,z=0;2>z;++z){var D=r[C+z],F=r[R+z],B=r[I+z];r[P+z]=D,r[O+z]=F,r[N+z]=B}o(v,t,r),o(m,e,r);for(var j=A;k>=j;++j)if(c(j,E,T,r))j!==A&&a(j,A,r),++A;else if(!c(j,L,S,r))for(;;){if(c(k,L,S,r)){c(k,E,T,r)?(s(j,A,k,r),++A,--k):(a(j,k,r),--k);break}if(--k=A-2-t?i(t,A-2,r):f(t,A-2,r),h>=e-(k+2)?i(k+2,e,r):f(k+2,e,r),h>=k-A?i(A,k,r):f(A,k,r)}e.exports=n;var h=32},{}],48:[function(t,e,r){"use strict";function n(t){var e=f.nextPow2(t);g.lengthA;++A){var k=s[A],M=b*A;_[p++]=o[M+x],_[p++]=-(k+1),_[p++]=o[M+w],_[p++]=k}for(var A=l;u>A;++A){var k=f[A]+d,E=b*A;_[p++]=c[E+x],_[p++]=-k,_[p++]=c[E+w],_[p++]=k}var T=p>>>1;h(_,T);for(var L=0,S=0,A=0;T>A;++A){var C=0|_[2*A+1];if(C>=d)C=C-d|0,i(m,y,S--,C);else if(C>=0)i(g,v,L--,C);else if(-d>=C){C=-C-d|0;for(var R=0;L>R;++R){var I=e(g[R],C);if(void 0!==I)return I}a(m,y,S++,C)}else{C=-C-1|0;for(var R=0;S>R;++R){var I=e(C,m[R]);if(void 0!==I)return I}a(g,v,L++,C)}}}function s(t,e,r,n,o,s,l,u,c,f){for(var d=0,p=2*t,w=t-1,A=p-1,k=r;n>k;++k){var M=s[k]+1<<1,E=p*k;_[d++]=o[E+w],_[d++]=-M,_[d++]=o[E+A],_[d++]=M}for(var k=l;u>k;++k){var M=f[k]+1<<1,T=p*k;_[d++]=c[T+w],_[d++]=1|-M,_[d++]=c[T+A],_[d++]=1|M}var L=d>>>1;h(_,L);for(var S=0,C=0,R=0,k=0;L>k;++k){var I=0|_[2*k+1],P=1&I;if(L-1>k&&I>>1===_[2*k+3]>>1&&(P=2,k+=1),0>I){for(var O=-(I>>1)-1,N=0;R>N;++N){var z=e(b[N],O);if(void 0!==z)return z}if(0!==P)for(var N=0;S>N;++N){var z=e(g[N],O);if(void 0!==z)return z}if(1!==P)for(var N=0;C>N;++N){var z=e(m[N],O);if(void 0!==z)return z}0===P?a(g,v,S++,O):1===P?a(m,y,C++,O):2===P&&a(b,x,R++,O)}else{var O=(I>>1)-1;0===P?i(g,v,S--,O):1===P?i(m,y,C--,O):2===P&&i(b,x,R--,O)}}}function l(t,e,r,n,o,s,l,u,c,f,p,m){var y=0,b=2*t,x=e,w=e+t,A=1,k=1;n?k=d:A=d;for(var M=o;s>M;++M){var E=M+A,T=b*M;_[y++]=l[T+x],_[y++]=-E,_[y++]=l[T+w],_[y++]=E}for(var M=c;f>M;++M){var E=M+k,L=b*M;_[y++]=p[L+x],_[y++]=-E}var S=y>>>1;h(_,S);for(var C=0,M=0;S>M;++M){var R=0|_[2*M+1];if(0>R){var E=-R,I=!1;if(E>=d?(I=!n,E-=d):(I=!!n,E-=1),I)a(g,v,C++,E);else{var P=m[E],O=b*E,N=p[O+e+1],z=p[O+e+1+t];t:for(var D=0;C>D;++D){var F=g[D],B=b*F;if(!(zj;++j)if(p[O+j+t]y;++y){var b=y+d,x=p*y;_[f++]=a[x+v],_[f++]=-b,_[f++]=a[x+m],_[f++]=b}for(var y=s;l>y;++y){var b=y+1,w=p*y;_[f++]=u[w+v],_[f++]=-b}var A=f>>>1;h(_,A);for(var k=0,y=0;A>y;++y){var M=0|_[2*y+1];if(0>M){var b=-M;if(b>=d)g[k++]=b-d;else{b-=1;var E=c[b],T=p*b,L=u[T+e+1],S=u[T+e+1+t];t:for(var C=0;k>C;++C){var R=g[C],I=o[R];if(I===E)break;var P=p*R;if(!(SO;++O)if(u[T+O+t]=0;--C)if(g[C]===b){for(var O=C+1;k>O;++O)g[O-1]=g[O];break}--k}}}e.exports={init:n,sweepBipartite:o,sweepComplete:s,scanBipartite:l,scanComplete:u};var c=t("typedarray-pool"),f=t("bit-twiddle"),h=t("./sort"),d=1<<28,p=1024,g=c.mallocInt32(p),v=c.mallocInt32(p),m=c.mallocInt32(p),y=c.mallocInt32(p),b=c.mallocInt32(p),x=c.mallocInt32(p),_=c.mallocDouble(8*p)},{"./sort":47,"bit-twiddle":9,"typedarray-pool":151}],49:[function(t,e,r){(function(t){function r(t,e){return d[0]=t,d[1]=e,h[0]}function n(t){return h[0]=t,d[0]}function i(t){return h[0]=t,d[1]}function a(t,e){return d[1]=t,d[0]=e,h[0]}function o(t){return h[0]=t,d[1]}function s(t){ +-return h[0]=t,d[0]}function l(t,e){return p.writeUInt32LE(t,0,!0),p.writeUInt32LE(e,4,!0),p.readDoubleLE(0,!0)}function u(t){return p.writeDoubleLE(t,0,!0),p.readUInt32LE(0,!0)}function c(t){return p.writeDoubleLE(t,0,!0),p.readUInt32LE(4,!0)}var f=!1;if("undefined"!=typeof Float64Array){var h=new Float64Array(1),d=new Uint32Array(h.buffer);h[0]=1,f=!0,1072693248===d[1]?(e.exports=function(t){return h[0]=t,[d[0],d[1]]},e.exports.pack=r,e.exports.lo=n,e.exports.hi=i):1072693248===d[0]?(e.exports=function(t){return h[0]=t,[d[1],d[0]]},e.exports.pack=a,e.exports.lo=o,e.exports.hi=s):f=!1}if(!f){var p=new t(8);e.exports=function(t){return p.writeDoubleLE(t,0,!0),[p.readUInt32LE(0,!0),p.readUInt32LE(4,!0)]},e.exports.pack=l,e.exports.lo=u,e.exports.hi=c}e.exports.sign=function(t){return e.exports.hi(t)>>>31},e.exports.exponent=function(t){var r=e.exports.hi(t);return(r<<1>>>21)-1023},e.exports.fraction=function(t){var r=e.exports.lo(t),n=e.exports.hi(t),i=1048575&n;return 2146435072&n&&(i+=1<<20),[r,i]},e.exports.denormalized=function(t){var r=e.exports.hi(t);return!(2146435072&r)}}).call(this,t("buffer").Buffer)},{buffer:10}],50:[function(t,e,r){"use strict";function n(t,e){if(isNaN(t)||isNaN(e))return NaN;if(t===e)return t;if(0===t)return 0>e?-a:a;var r=i.hi(t),n=i.lo(t);return e>t==t>0?n===o?(r+=1,n=0):n+=1:0===n?(n=o,r-=1):n-=1,i.pack(n,r)}var i=t("double-bits"),a=Math.pow(2,-1074),o=-1>>>0;e.exports=n},{"double-bits":49}],51:[function(t,e,r){"use strict";function n(t,e){for(var r=t.length,n=new Array(r),a=0;r>a;++a)n[a]=i(t[a],e[a]);return n}var i=t("big-rat/add");e.exports=n},{"big-rat/add":25}],52:[function(t,e,r){"use strict";function n(t){for(var e=new Array(t.length),r=0;rs;++s)o[s]=a(t[s],r);return o}var i=t("big-rat"),a=t("big-rat/mul");e.exports=n},{"big-rat":28,"big-rat/mul":37}],54:[function(t,e,r){"use strict";function n(t,e){for(var r=t.length,n=new Array(r),a=0;r>a;++a)n[a]=i(t[a],e[a]);return n}var i=t("big-rat/sub");e.exports=n},{"big-rat/sub":40}],55:[function(t,e,r){"use strict";function n(t,e,r,n){for(var i=0;2>i;++i){var a=t[i],o=e[i],s=Math.min(a,o),l=Math.max(a,o),u=r[i],c=n[i],f=Math.min(u,c),h=Math.max(u,c);if(s>h||f>l)return!1}return!0}function i(t,e,r,i){var o=a(t,r,i),s=a(e,r,i);if(o>0&&s>0||0>o&&0>s)return!1;var l=a(r,t,e),u=a(i,t,e);return l>0&&u>0||0>l&&0>u?!1:0===o&&0===s&&0===l&&0===u?n(t,e,r,i):!0}e.exports=i;var a=t("robust-orientation")[3]},{"robust-orientation":133}],56:[function(t,e,r){"use strict";"use restrict";function n(t){this.roots=new Array(t),this.ranks=new Array(t);for(var e=0;t>e;++e)this.roots[e]=e,this.ranks[e]=0}e.exports=n;var i=n.prototype;Object.defineProperty(i,"length",{get:function(){return this.roots.length}}),i.makeSet=function(){var t=this.roots.length;return this.roots.push(t),this.ranks.push(0),t},i.find=function(t){for(var e=t,r=this.roots;r[t]!==t;)t=r[t];for(;r[e]!==t;){var n=r[e];r[e]=t,e=n}return t},i.link=function(t,e){var r=this.find(t),n=this.find(e);if(r!==n){var i=this.ranks,a=this.roots,o=i[r],s=i[n];s>o?a[r]=n:o>s?a[n]=r:(a[n]=r,++i[r])}}},{}],57:[function(t,e,r){function n(t,e){return t-e}function i(t,e){var r=t.length,i=t.length-e.length;if(i)return i;switch(r){case 0:return 0;case 1:return t[0]-e[0];case 2:return t[0]+t[1]-e[0]-e[1]||a(t[0],t[1])-a(e[0],e[1]);case 3:var o=t[0]+t[1],s=e[0]+e[1];if(i=o+t[2]-(s+e[2]))return i;var l=a(t[0],t[1]),u=a(e[0],e[1]);return a(l,t[2])-a(u,e[2])||a(l+t[2],o)-a(u+e[2],s);case 4:var c=t[0],f=t[1],h=t[2],d=t[3],p=e[0],g=e[1],v=e[2],m=e[3];return c+f+h+d-(p+g+v+m)||a(c,f,h,d)-a(p,g,v,m,p)||a(c+f,c+h,c+d,f+h,f+d,h+d)-a(p+g,p+v,p+m,g+v,g+m,v+m)||a(c+f+h,c+f+d,c+h+d,f+h+d)-a(p+g+v,p+g+m,p+v+m,g+v+m);default:for(var y=t.slice().sort(n),b=e.slice().sort(n),x=0;r>x;++x)if(i=y[x]-b[x])return i;return 0}}e.exports=i;var a=Math.min},{}],58:[function(t,e,r){"use strict";function n(){this.argTypes=[],this.shimArgs=[],this.arrayArgs=[],this.arrayBlockIndices=[],this.scalarArgs=[],this.offsetArgs=[],this.offsetArgIndex=[],this.indexArgs=[],this.shapeArgs=[],this.funcName="",this.pre=null,this.body=null,this.post=null,this.debug=!1}function i(t){var e=new n;e.pre=t.pre,e.body=t.body,e.post=t.post;var r=t.args.slice(0);e.argTypes=r;for(var i=0;i0)throw new Error("cwise: pre() block may not reference array args");if(i0)throw new Error("cwise: post() block may not reference array args")}else if("scalar"===o)e.scalarArgs.push(i),e.shimArgs.push("scalar"+i);else if("index"===o){if(e.indexArgs.push(i),i0)throw new Error("cwise: pre() block may not reference array index");if(i0)throw new Error("cwise: post() block may not reference array index")}else if("shape"===o){if(e.shapeArgs.push(i),ir.length)throw new Error("cwise: Too many arguments in pre() block");if(e.body.args.length>r.length)throw new Error("cwise: Too many arguments in body() block");if(e.post.args.length>r.length)throw new Error("cwise: Too many arguments in post() block");return e.debug=!!t.printCode||!!t.debug,e.funcName=t.funcName||"cwise",e.blockSize=t.blockSize||64,a(e)}var a=t("./lib/thunk.js");e.exports=i},{"./lib/thunk.js":60}],59:[function(t,e,r){"use strict";function n(t,e,r){var n,i,a=t.length,o=e.arrayArgs.length,s=e.indexArgs.length>0,l=[],u=[],c=0,f=0;for(n=0;a>n;++n)u.push(["i",n,"=0"].join(""));for(i=0;o>i;++i)for(n=0;a>n;++n)f=c,c=t[n],0===n?u.push(["d",i,"s",n,"=t",i,"p",c].join("")):u.push(["d",i,"s",n,"=(t",i,"p",c,"-s",f,"*t",i,"p",f,")"].join(""));for(l.push("var "+u.join(",")),n=a-1;n>=0;--n)c=t[n],l.push(["for(i",n,"=0;i",n,"n;++n){for(f=c,c=t[n],i=0;o>i;++i)l.push(["p",i,"+=d",i,"s",n].join(""));s&&(n>0&&l.push(["index[",f,"]-=s",f].join("")),l.push(["++index[",c,"]"].join(""))),l.push("}")}return l.join("\n")}function i(t,e,r,i){for(var a=e.length,o=r.arrayArgs.length,s=r.blockSize,l=r.indexArgs.length>0,u=[],c=0;o>c;++c)u.push(["var offset",c,"=p",c].join(""));for(var c=t;a>c;++c)u.push(["for(var j"+c+"=SS[",e[c],"]|0;j",c,">0;){"].join("")),u.push(["if(j",c,"<",s,"){"].join("")),u.push(["s",e[c],"=j",c].join("")),u.push(["j",c,"=0"].join("")),u.push(["}else{s",e[c],"=",s].join("")),u.push(["j",c,"-=",s,"}"].join("")),l&&u.push(["index[",e[c],"]=j",c].join(""));for(var c=0;o>c;++c){for(var f=["offset"+c],h=t;a>h;++h)f.push(["j",h,"*t",c,"p",e[h]].join(""));u.push(["p",c,"=(",f.join("+"),")"].join(""))}u.push(n(e,r,i));for(var c=t;a>c;++c)u.push("}");return u.join("\n")}function a(t){for(var e=0,r=t[0].length;r>e;){for(var n=1;n0&&(r=r&&e[n]===e[n-1])}return r?e[0]:e.join("")}function l(t,e){for(var r=e[1].length-Math.abs(t.arrayBlockIndices[0])|0,l=new Array(t.arrayArgs.length),c=new Array(t.arrayArgs.length),f=0;fy;++y)_.push(["s",y,"=SS[",y,"]"].join(""));for(var f=0;fy;++y)_.push(["t",f,"p",y,"=t",f,"[",p[f]+y,"]"].join(""));for(var y=0;y0&&_.push("shape=SS.slice(0)"),t.indexArgs.length>0){for(var w=new Array(r),f=0;r>f;++f)w[f]="0";_.push(["index=[",w.join(","),"]"].join(""))}for(var f=0;f3&&x.push(o(t.pre,t,c));var E=o(t.body,t,c),T=a(v);r>T?x.push(i(T,v[0],t,E)):x.push(n(v[0],t,E)),t.post.body.length>3&&x.push(o(t.post,t,c)),t.debug&&console.log("-----Generated cwise routine for ",e,":\n"+x.join("\n")+"\n----------");var L=[t.funcName||"unnamed","_cwise_loop_",l[0].join("s"),"m",T,s(c)].join(""),S=new Function(["function ",L,"(",b.join(","),"){",x.join("\n"),"} return ",L].join(""));return S()}var u=t("uniq");e.exports=l},{uniq:152}],60:[function(t,e,r){"use strict";function n(t){var e=["'use strict'","var CACHED={}"],r=[],n=t.funcName+"_cwise_thunk";e.push(["return function ",n,"(",t.shimArgs.join(","),"){"].join(""));for(var a=[],o=[],s=[["array",t.arrayArgs[0],".shape.slice(",Math.max(0,t.arrayBlockIndices[0]),t.arrayBlockIndices[0]<0?","+t.arrayBlockIndices[0]+")":")"].join("")],l=[],u=[],c=0;c0&&(l.push("array"+t.arrayArgs[0]+".shape.length===array"+f+".shape.length+"+(Math.abs(t.arrayBlockIndices[0])-Math.abs(t.arrayBlockIndices[c]))),u.push("array"+t.arrayArgs[0]+".shape[shapeIndex+"+Math.max(0,t.arrayBlockIndices[0])+"]===array"+f+".shape[shapeIndex+"+Math.max(0,t.arrayBlockIndices[c])+"]"))}t.arrayArgs.length>1&&(e.push("if (!("+l.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same dimensionality!')"),e.push("for(var shapeIndex=array"+t.arrayArgs[0]+".shape.length-"+Math.abs(t.arrayBlockIndices[0])+"; shapeIndex-->0;) {"),e.push("if (!("+u.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same shape!')"),e.push("}"));for(var c=0;ct?-1:t>e?1:t>=e?0:NaN}function a(t){return null===t?NaN:+t}function o(t){return!isNaN(t)}function s(t){return{left:function(e,r,n,i){for(arguments.length<3&&(n=0),arguments.length<4&&(i=e.length);i>n;){var a=n+i>>>1;t(e[a],r)<0?n=a+1:i=a}return n},right:function(e,r,n,i){for(arguments.length<3&&(n=0),arguments.length<4&&(i=e.length);i>n;){var a=n+i>>>1;t(e[a],r)>0?i=a:n=a+1}return n}}}function l(t){return t.length}function u(t){for(var e=1;t*e%1;)e*=10;return e}function c(t,e){for(var r in e)Object.defineProperty(t.prototype,r,{value:e[r],enumerable:!1})}function f(){this._=Object.create(null)}function h(t){return(t+="")===Ao||t[0]===ko?ko+t:t}function d(t){return(t+="")[0]===ko?t.slice(1):t}function p(t){return h(t)in this._}function g(t){return(t=h(t))in this._&&delete this._[t]}function v(){var t=[];for(var e in this._)t.push(d(e));return t}function m(){var t=0;for(var e in this._)++t;return t}function y(){for(var t in this._)return!1;return!0}function b(){this._=Object.create(null)}function x(t){return t}function _(t,e,r){return function(){var n=r.apply(e,arguments);return n===e?t:n}}function w(t,e){if(e in t)return e;e=e.charAt(0).toUpperCase()+e.slice(1);for(var r=0,n=Mo.length;n>r;++r){var i=Mo[r]+e;if(i in t)return i}}function A(){}function k(){}function M(t){function e(){for(var e,n=r,i=-1,a=n.length;++ir;r++)for(var i,a=t[r],o=0,s=a.length;s>o;o++)(i=a[o])&&e(i,o,r);return t}function X(t){return To(t,Oo),t}function Y(t){var e,r;return function(n,i,a){var o,s=t[a].update,l=s.length;for(a!=r&&(r=a,e=0),i>=e&&(e=i+1);!(o=s[e])&&++e0&&(t=t.slice(0,s));var u=No.get(t);return u&&(t=u,l=Q),s?e?i:n:e?A:a}function Z(t,e){return function(r){var n=uo.event;uo.event=r,e[0]=this.__data__;try{t.apply(this,e)}finally{uo.event=n}}}function Q(t,e){var r=Z(t,e);return function(t){var e=this,n=t.relatedTarget;n&&(n===e||8&n.compareDocumentPosition(e))||r.call(e,t)}}function $(t){var r=".dragsuppress-"+ ++Do,i="click"+r,a=uo.select(n(t)).on("touchmove"+r,E).on("dragstart"+r,E).on("selectstart"+r,E);if(null==zo&&(zo="onselectstart"in t?!1:w(t.style,"userSelect")),zo){var o=e(t).style,s=o[zo];o[zo]="none"}return function(t){if(a.on(r,null),zo&&(o[zo]=s),t){var e=function(){a.on(i,null)};a.on(i,function(){E(),e()},!0),setTimeout(e,0)}}}function K(t,e){e.changedTouches&&(e=e.changedTouches[0]);var r=t.ownerSVGElement||t;if(r.createSVGPoint){var i=r.createSVGPoint();if(0>Fo){var a=n(t);if(a.scrollX||a.scrollY){r=uo.select("body").append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important");var o=r[0][0].getScreenCTM();Fo=!(o.f||o.e),r.remove()}}return Fo?(i.x=e.pageX,i.y=e.pageY):(i.x=e.clientX,i.y=e.clientY),i=i.matrixTransform(t.getScreenCTM().inverse()),[i.x,i.y]}var s=t.getBoundingClientRect();return[e.clientX-s.left-t.clientLeft,e.clientY-s.top-t.clientTop]}function J(){return uo.event.changedTouches[0].identifier}function tt(t){return t>0?1:0>t?-1:0}function et(t,e,r){return(e[0]-t[0])*(r[1]-t[1])-(e[1]-t[1])*(r[0]-t[0])}function rt(t){return t>1?0:-1>t?Uo:Math.acos(t)}function nt(t){return t>1?Ho:-1>t?-Ho:Math.asin(t)}function it(t){return((t=Math.exp(t))-1/t)/2}function at(t){return((t=Math.exp(t))+1/t)/2}function ot(t){return((t=Math.exp(2*t))-1)/(t+1)}function st(t){return(t=Math.sin(t/2))*t}function lt(){}function ut(t,e,r){return this instanceof ut?(this.h=+t,this.s=+e,void(this.l=+r)):arguments.length<2?t instanceof ut?new ut(t.h,t.s,t.l):At(""+t,kt,ut):new ut(t,e,r)}function ct(t,e,r){function n(t){return t>360?t-=360:0>t&&(t+=360),60>t?a+(o-a)*t/60:180>t?o:240>t?a+(o-a)*(240-t)/60:a}function i(t){return Math.round(255*n(t))}var a,o;return t=isNaN(t)?0:(t%=360)<0?t+360:t,e=isNaN(e)?0:0>e?0:e>1?1:e,r=0>r?0:r>1?1:r,o=.5>=r?r*(1+e):r+e-r*e,a=2*r-o,new bt(i(t+120),i(t),i(t-120))}function ft(t,e,r){return this instanceof ft?(this.h=+t,this.c=+e,void(this.l=+r)):arguments.length<2?t instanceof ft?new ft(t.h,t.c,t.l):t instanceof dt?gt(t.l,t.a,t.b):gt((t=Mt((t=uo.rgb(t)).r,t.g,t.b)).l,t.a,t.b):new ft(t,e,r)}function ht(t,e,r){return isNaN(t)&&(t=0),isNaN(e)&&(e=0),new dt(r,Math.cos(t*=Go)*e,Math.sin(t)*e)}function dt(t,e,r){return this instanceof dt?(this.l=+t,this.a=+e,void(this.b=+r)):arguments.length<2?t instanceof dt?new dt(t.l,t.a,t.b):t instanceof ft?ht(t.h,t.c,t.l):Mt((t=bt(t)).r,t.g,t.b):new dt(t,e,r)}function pt(t,e,r){var n=(t+16)/116,i=n+e/500,a=n-r/200;return i=vt(i)*rs,n=vt(n)*ns,a=vt(a)*is,new bt(yt(3.2404542*i-1.5371385*n-.4985314*a),yt(-.969266*i+1.8760108*n+.041556*a),yt(.0556434*i-.2040259*n+1.0572252*a))}function gt(t,e,r){return t>0?new ft(Math.atan2(r,e)*Xo,Math.sqrt(e*e+r*r),t):new ft(NaN,NaN,t)}function vt(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function mt(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function yt(t){return Math.round(255*(.00304>=t?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}function bt(t,e,r){return this instanceof bt?(this.r=~~t,this.g=~~e,void(this.b=~~r)):arguments.length<2?t instanceof bt?new bt(t.r,t.g,t.b):At(""+t,bt,ct):new bt(t,e,r)}function xt(t){return new bt(t>>16,t>>8&255,255&t)}function _t(t){return xt(t)+""}function wt(t){return 16>t?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function At(t,e,r){var n,i,a,o=0,s=0,l=0;if(n=/([a-z]+)\((.*)\)/.exec(t=t.toLowerCase()))switch(i=n[2].split(","),n[1]){case"hsl":return r(parseFloat(i[0]),parseFloat(i[1])/100,parseFloat(i[2])/100);case"rgb":return e(Tt(i[0]),Tt(i[1]),Tt(i[2]))}return(a=ss.get(t))?e(a.r,a.g,a.b):(null==t||"#"!==t.charAt(0)||isNaN(a=parseInt(t.slice(1),16))||(4===t.length?(o=(3840&a)>>4,o=o>>4|o,s=240&a,s=s>>4|s,l=15&a,l=l<<4|l):7===t.length&&(o=(16711680&a)>>16,s=(65280&a)>>8,l=255&a)),e(o,s,l))}function kt(t,e,r){var n,i,a=Math.min(t/=255,e/=255,r/=255),o=Math.max(t,e,r),s=o-a,l=(o+a)/2;return s?(i=.5>l?s/(o+a):s/(2-o-a),n=t==o?(e-r)/s+(r>e?6:0):e==o?(r-t)/s+2:(t-e)/s+4,n*=60):(n=NaN,i=l>0&&1>l?0:n),new ut(n,i,l)}function Mt(t,e,r){t=Et(t),e=Et(e),r=Et(r);var n=mt((.4124564*t+.3575761*e+.1804375*r)/rs),i=mt((.2126729*t+.7151522*e+.072175*r)/ns),a=mt((.0193339*t+.119192*e+.9503041*r)/is);return dt(116*i-16,500*(n-i),200*(i-a))}function Et(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Tt(t){var e=parseFloat(t);return"%"===t.charAt(t.length-1)?Math.round(2.55*e):e}function Lt(t){return"function"==typeof t?t:function(){return t}}function St(t){return function(e,r,n){return 2===arguments.length&&"function"==typeof r&&(n=r,r=null),Ct(e,r,t,n)}}function Ct(t,e,r,n){function i(){var t,e=l.status;if(!e&&It(l)||e>=200&&300>e||304===e){try{t=r.call(a,l)}catch(n){return void o.error.call(a,n)}o.load.call(a,t)}else o.error.call(a,l)}var a={},o=uo.dispatch("beforesend","progress","load","error"),s={},l=new XMLHttpRequest,u=null;return!this.XDomainRequest||"withCredentials"in l||!/^(http(s)?:)?\/\//.test(t)||(l=new XDomainRequest),"onload"in l?l.onload=l.onerror=i:l.onreadystatechange=function(){l.readyState>3&&i()},l.onprogress=function(t){var e=uo.event;uo.event=t;try{o.progress.call(a,l)}finally{uo.event=e}},a.header=function(t,e){return t=(t+"").toLowerCase(),arguments.length<2?s[t]:(null==e?delete s[t]:s[t]=e+"",a)},a.mimeType=function(t){return arguments.length?(e=null==t?null:t+"",a):e},a.responseType=function(t){return arguments.length?(u=t,a):u},a.response=function(t){return r=t,a},["get","post"].forEach(function(t){a[t]=function(){return a.send.apply(a,[t].concat(fo(arguments)))}}),a.send=function(r,n,i){if(2===arguments.length&&"function"==typeof n&&(i=n,n=null),l.open(r,t,!0),null==e||"accept"in s||(s.accept=e+",*/*"),l.setRequestHeader)for(var c in s)l.setRequestHeader(c,s[c]);return null!=e&&l.overrideMimeType&&l.overrideMimeType(e),null!=u&&(l.responseType=u),null!=i&&a.on("error",i).on("load",function(t){i(null,t)}),o.beforesend.call(a,l),l.send(null==n?null:n),a},a.abort=function(){return l.abort(),a},uo.rebind(a,o,"on"),null==n?a:a.get(Rt(n))}function Rt(t){return 1===t.length?function(e,r){t(null==e?r:null)}:t}function It(t){var e=t.responseType;return e&&"text"!==e?t.response:t.responseText}function Pt(t,e,r){var n=arguments.length;2>n&&(e=0),3>n&&(r=Date.now());var i=r+e,a={c:t,t:i,n:null};return us?us.n=a:ls=a,us=a,cs||(fs=clearTimeout(fs),cs=1,hs(Ot)),a}function Ot(){var t=Nt(),e=zt()-t;e>24?(isFinite(e)&&(clearTimeout(fs),fs=setTimeout(Ot,e)),cs=0):(cs=1,hs(Ot))}function Nt(){for(var t=Date.now(),e=ls;e;)t>=e.t&&e.c(t-e.t)&&(e.c=null),e=e.n;return t}function zt(){for(var t,e=ls,r=1/0;e;)e.c?(e.t8?function(t){return t/r}:function(t){return t*r},symbol:t}}function Bt(t){var e=t.decimal,r=t.thousands,n=t.grouping,i=t.currency,a=n&&r?function(t,e){for(var i=t.length,a=[],o=0,s=n[0],l=0;i>0&&s>0&&(l+s+1>e&&(s=Math.max(1,e-l)),a.push(t.substring(i-=s,i+s)),!((l+=s+1)>e));)s=n[o=(o+1)%n.length];return a.reverse().join(r)}:x;return function(t){var r=ps.exec(t),n=r[1]||" ",o=r[2]||">",s=r[3]||"-",l=r[4]||"",u=r[5],c=+r[6],f=r[7],h=r[8],d=r[9],p=1,g="",v="",m=!1,y=!0;switch(h&&(h=+h.substring(1)),(u||"0"===n&&"="===o)&&(u=n="0",o="="),d){case"n":f=!0,d="g";break;case"%":p=100,v="%",d="f";break;case"p":p=100,v="%",d="r";break;case"b":case"o":case"x":case"X":"#"===l&&(g="0"+d.toLowerCase());case"c":y=!1;case"d":m=!0,h=0;break;case"s":p=-1,d="r"}"$"===l&&(g=i[0],v=i[1]),"r"!=d||h||(d="g"),null!=h&&("g"==d?h=Math.max(1,Math.min(21,h)):"e"!=d&&"f"!=d||(h=Math.max(0,Math.min(20,h)))),d=gs.get(d)||jt;var b=u&&f;return function(t){var r=v;if(m&&t%1)return"";var i=0>t||0===t&&0>1/t?(t=-t,"-"):"-"===s?"":s;if(0>p){var l=uo.formatPrefix(t,h);t=l.scale(t),r=l.symbol+v}else t*=p;t=d(t,h);var x,_,w=t.lastIndexOf(".");if(0>w){var A=y?t.lastIndexOf("e"):-1;0>A?(x=t,_=""):(x=t.substring(0,A),_=t.substring(A))}else x=t.substring(0,w),_=e+t.substring(w+1);!u&&f&&(x=a(x,1/0));var k=g.length+x.length+_.length+(b?0:i.length),M=c>k?new Array(k=c-k+1).join(n):"";return b&&(x=a(M+x,M.length?c-_.length:1/0)),i+=g,t=x+_,("<"===o?i+t+M:">"===o?M+i+t:"^"===o?M.substring(0,k>>=1)+i+t+M.substring(k):i+(b?t:M+t))+r}}}function jt(t){return t+""}function Ut(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}function Vt(t,e,r){function n(e){var r=t(e),n=a(r,1);return n-e>e-r?r:n}function i(r){return e(r=t(new ms(r-1)),1),r}function a(t,r){return e(t=new ms(+t),r),t}function o(t,n,a){var o=i(t),s=[];if(a>1)for(;n>o;)r(o)%a||s.push(new Date(+o)),e(o,1);else for(;n>o;)s.push(new Date(+o)),e(o,1);return s}function s(t,e,r){try{ms=Ut;var n=new Ut;return n._=t,o(n,e,r)}finally{ms=Date}}t.floor=t,t.round=n,t.ceil=i,t.offset=a,t.range=o;var l=t.utc=qt(t);return l.floor=l,l.round=qt(n),l.ceil=qt(i),l.offset=qt(a),l.range=s,t}function qt(t){return function(e,r){try{ms=Ut;var n=new Ut;return n._=e,t(n,r)._}finally{ms=Date}}}function Ht(t){function e(t){function e(e){for(var r,i,a,o=[],s=-1,l=0;++ss;){if(n>=u)return-1;if(i=e.charCodeAt(s++),37===i){if(o=e.charAt(s++),a=S[o in bs?e.charAt(s++):o],!a||(n=a(t,r,n))<0)return-1}else if(i!=r.charCodeAt(n++))return-1}return n}function n(t,e,r){w.lastIndex=0;var n=w.exec(e.slice(r));return n?(t.w=A.get(n[0].toLowerCase()),r+n[0].length):-1}function i(t,e,r){x.lastIndex=0;var n=x.exec(e.slice(r));return n?(t.w=_.get(n[0].toLowerCase()),r+n[0].length):-1}function a(t,e,r){E.lastIndex=0;var n=E.exec(e.slice(r));return n?(t.m=T.get(n[0].toLowerCase()),r+n[0].length):-1}function o(t,e,r){k.lastIndex=0;var n=k.exec(e.slice(r));return n?(t.m=M.get(n[0].toLowerCase()),r+n[0].length):-1}function s(t,e,n){return r(t,L.c.toString(),e,n)}function l(t,e,n){return r(t,L.x.toString(),e,n)}function u(t,e,n){return r(t,L.X.toString(),e,n)}function c(t,e,r){var n=b.get(e.slice(r,r+=2).toLowerCase());return null==n?-1:(t.p=n,r)}var f=t.dateTime,h=t.date,d=t.time,p=t.periods,g=t.days,v=t.shortDays,m=t.months,y=t.shortMonths;e.utc=function(t){function r(t){try{ms=Ut;var e=new ms;return e._=t,n(e)}finally{ms=Date}}var n=e(t);return r.parse=function(t){try{ms=Ut;var e=n.parse(t);return e&&e._}finally{ms=Date}},r.toString=n.toString,r},e.multi=e.utc.multi=ce;var b=uo.map(),x=Xt(g),_=Yt(g),w=Xt(v),A=Yt(v),k=Xt(m),M=Yt(m),E=Xt(y),T=Yt(y);p.forEach(function(t,e){b.set(t.toLowerCase(),e)});var L={a:function(t){return v[t.getDay()]},A:function(t){return g[t.getDay()]},b:function(t){return y[t.getMonth()]},B:function(t){return m[t.getMonth()]},c:e(f),d:function(t,e){return Gt(t.getDate(),e,2)},e:function(t,e){return Gt(t.getDate(),e,2)},H:function(t,e){return Gt(t.getHours(),e,2)},I:function(t,e){return Gt(t.getHours()%12||12,e,2)},j:function(t,e){return Gt(1+vs.dayOfYear(t),e,3)},L:function(t,e){return Gt(t.getMilliseconds(),e,3)},m:function(t,e){return Gt(t.getMonth()+1,e,2)},M:function(t,e){return Gt(t.getMinutes(),e,2)},p:function(t){return p[+(t.getHours()>=12)]},S:function(t,e){return Gt(t.getSeconds(),e,2)},U:function(t,e){return Gt(vs.sundayOfYear(t),e,2)},w:function(t){return t.getDay()},W:function(t,e){return Gt(vs.mondayOfYear(t),e,2)},x:e(h),X:e(d),y:function(t,e){return Gt(t.getFullYear()%100,e,2)},Y:function(t,e){return Gt(t.getFullYear()%1e4,e,4)},Z:le,"%":function(){return"%"}},S={a:n,A:i,b:a,B:o,c:s,d:re,e:re,H:ie,I:ie,j:ne,L:se,m:ee,M:ae,p:c,S:oe,U:Zt,w:Wt,W:Qt,x:l,X:u,y:Kt,Y:$t,Z:Jt,"%":ue};return e}function Gt(t,e,r){var n=0>t?"-":"",i=(n?-t:t)+"",a=i.length;return n+(r>a?new Array(r-a+1).join(e)+i:i)}function Xt(t){return new RegExp("^(?:"+t.map(uo.requote).join("|")+")","i")}function Yt(t){for(var e=new f,r=-1,n=t.length;++r68?1900:2e3)}function ee(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+2));return n?(t.m=n[0]-1,r+n[0].length):-1}function re(t,e,r){ +-xs.lastIndex=0;var n=xs.exec(e.slice(r,r+2));return n?(t.d=+n[0],r+n[0].length):-1}function ne(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+3));return n?(t.j=+n[0],r+n[0].length):-1}function ie(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+2));return n?(t.H=+n[0],r+n[0].length):-1}function ae(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+2));return n?(t.M=+n[0],r+n[0].length):-1}function oe(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+2));return n?(t.S=+n[0],r+n[0].length):-1}function se(t,e,r){xs.lastIndex=0;var n=xs.exec(e.slice(r,r+3));return n?(t.L=+n[0],r+n[0].length):-1}function le(t){var e=t.getTimezoneOffset(),r=e>0?"-":"+",n=wo(e)/60|0,i=wo(e)%60;return r+Gt(n,"0",2)+Gt(i,"0",2)}function ue(t,e,r){_s.lastIndex=0;var n=_s.exec(e.slice(r,r+1));return n?r+n[0].length:-1}function ce(t){for(var e=t.length,r=-1;++r=0?1:-1,s=o*r,l=Math.cos(e),u=Math.sin(e),c=a*u,f=i*l+c*Math.cos(s),h=c*o*Math.sin(s);Ts.add(Math.atan2(h,f)),n=t,i=l,a=u}var e,r,n,i,a;Ls.point=function(o,s){Ls.point=t,n=(e=o)*Go,i=Math.cos(s=(r=s)*Go/2+Uo/4),a=Math.sin(s)},Ls.lineEnd=function(){t(e,r)}}function me(t){var e=t[0],r=t[1],n=Math.cos(r);return[n*Math.cos(e),n*Math.sin(e),Math.sin(r)]}function ye(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function be(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function xe(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function _e(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function we(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function Ae(t){return[Math.atan2(t[1],t[0]),nt(t[2])]}function ke(t,e){return wo(t[0]-e[0])s;++s)i.point((r=t[s])[0],r[1]);return void i.lineEnd()}var l=new Oe(r,t,null,!0),u=new Oe(r,null,l,!1);l.o=u,a.push(l),o.push(u),l=new Oe(n,t,null,!1),u=new Oe(n,null,l,!0),l.o=u,a.push(l),o.push(u)}}),o.sort(e),Pe(a),Pe(o),a.length){for(var s=0,l=r,u=o.length;u>s;++s)o[s].e=l=!l;for(var c,f,h=a[0];;){for(var d=h,p=!0;d.v;)if((d=d.n)===h)return;c=d.z,i.lineStart();do{if(d.v=d.o.v=!0,d.e){if(p)for(var s=0,u=c.length;u>s;++s)i.point((f=c[s])[0],f[1]);else n(d.x,d.n.x,1,i);d=d.n}else{if(p){c=d.p.z;for(var s=c.length-1;s>=0;--s)i.point((f=c[s])[0],f[1])}else n(d.x,d.p.x,-1,i);d=d.p}d=d.o,c=d.z,p=!p}while(!d.v);i.lineEnd()}}}function Pe(t){if(e=t.length){for(var e,r,n=0,i=t[0];++n0){for(_||(a.polygonStart(),_=!0),a.lineStart();++o1&&2&e&&r.push(r.pop().concat(r.shift())),d.push(r.filter(ze))}var d,p,g,v=e(a),m=i.invert(n[0],n[1]),y={point:o,lineStart:l,lineEnd:u,polygonStart:function(){y.point=c,y.lineStart=f,y.lineEnd=h,d=[],p=[]},polygonEnd:function(){y.point=o,y.lineStart=l,y.lineEnd=u,d=uo.merge(d);var t=Ve(m,p);d.length?(_||(a.polygonStart(),_=!0),Ie(d,Fe,t,r,a)):t&&(_||(a.polygonStart(),_=!0),a.lineStart(),r(null,null,1,a),a.lineEnd()),_&&(a.polygonEnd(),_=!1),d=p=null},sphere:function(){a.polygonStart(),a.lineStart(),r(null,null,1,a),a.lineEnd(),a.polygonEnd()}},b=De(),x=e(b),_=!1;return y}}function ze(t){return t.length>1}function De(){var t,e=[];return{lineStart:function(){e.push(t=[])},point:function(e,r){t.push([e,r])},lineEnd:A,buffer:function(){var r=e;return e=[],t=null,r},rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))}}}function Fe(t,e){return((t=t.x)[0]<0?t[1]-Ho-Bo:Ho-t[1])-((e=e.x)[0]<0?e[1]-Ho-Bo:Ho-e[1])}function Be(t){var e,r=NaN,n=NaN,i=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(a,o){var s=a>0?Uo:-Uo,l=wo(a-r);wo(l-Uo)0?Ho:-Ho),t.point(i,n),t.lineEnd(),t.lineStart(),t.point(s,n),t.point(a,n),e=0):i!==s&&l>=Uo&&(wo(r-i)Bo?Math.atan((Math.sin(e)*(a=Math.cos(n))*Math.sin(r)-Math.sin(n)*(i=Math.cos(e))*Math.sin(t))/(i*a*o)):(e+n)/2}function Ue(t,e,r,n){var i;if(null==t)i=r*Ho,n.point(-Uo,i),n.point(0,i),n.point(Uo,i),n.point(Uo,0),n.point(Uo,-i),n.point(0,-i),n.point(-Uo,-i),n.point(-Uo,0),n.point(-Uo,i);else if(wo(t[0]-e[0])>Bo){var a=t[0]s;++s){var u=e[s],c=u.length;if(c)for(var f=u[0],h=f[0],d=f[1]/2+Uo/4,p=Math.sin(d),g=Math.cos(d),v=1;;){v===c&&(v=0),t=u[v];var m=t[0],y=t[1]/2+Uo/4,b=Math.sin(y),x=Math.cos(y),_=m-h,w=_>=0?1:-1,A=w*_,k=A>Uo,M=p*b;if(Ts.add(Math.atan2(M*w*Math.sin(A),g*x+M*Math.cos(A))),a+=k?_+w*Vo:_,k^h>=r^m>=r){var E=be(me(f),me(t));we(E);var T=be(i,E);we(T);var L=(k^_>=0?-1:1)*nt(T[2]);(n>L||n===L&&(E[0]||E[1]))&&(o+=k^_>=0?1:-1)}if(!v++)break;h=m,p=b,g=x,f=t}}return(-Bo>a||Bo>a&&0>Ts)^1&o}function qe(t){function e(t,e){return Math.cos(t)*Math.cos(e)>a}function r(t){var r,a,l,u,c;return{lineStart:function(){u=l=!1,c=1},point:function(f,h){var d,p=[f,h],g=e(f,h),v=o?g?0:i(f,h):g?i(f+(0>f?Uo:-Uo),h):0;if(!r&&(u=l=g)&&t.lineStart(),g!==l&&(d=n(r,p),(ke(r,d)||ke(p,d))&&(p[0]+=Bo,p[1]+=Bo,g=e(p[0],p[1]))),g!==l)c=0,g?(t.lineStart(),d=n(p,r),t.point(d[0],d[1])):(d=n(r,p),t.point(d[0],d[1]),t.lineEnd()),r=d;else if(s&&r&&o^g){var m;v&a||!(m=n(p,r,!0))||(c=0,o?(t.lineStart(),t.point(m[0][0],m[0][1]),t.point(m[1][0],m[1][1]),t.lineEnd()):(t.point(m[1][0],m[1][1]),t.lineEnd(),t.lineStart(),t.point(m[0][0],m[0][1])))}!g||r&&ke(r,p)||t.point(p[0],p[1]),r=p,l=g,a=v},lineEnd:function(){l&&t.lineEnd(),r=null},clean:function(){return c|(u&&l)<<1}}}function n(t,e,r){var n=me(t),i=me(e),o=[1,0,0],s=be(n,i),l=ye(s,s),u=s[0],c=l-u*u;if(!c)return!r&&t;var f=a*l/c,h=-a*u/c,d=be(o,s),p=_e(o,f),g=_e(s,h);xe(p,g);var v=d,m=ye(p,v),y=ye(v,v),b=m*m-y*(ye(p,p)-1);if(!(0>b)){var x=Math.sqrt(b),_=_e(v,(-m-x)/y);if(xe(_,p),_=Ae(_),!r)return _;var w,A=t[0],k=e[0],M=t[1],E=e[1];A>k&&(w=A,A=k,k=w);var T=k-A,L=wo(T-Uo)T;if(!L&&M>E&&(w=M,M=E,E=w),S?L?M+E>0^_[1]<(wo(_[0]-A)Uo^(A<=_[0]&&_[0]<=k)){var C=_e(v,(-m+x)/y);return xe(C,p),[_,Ae(C)]}}}function i(e,r){var n=o?t:Uo-t,i=0;return-n>e?i|=1:e>n&&(i|=2),-n>r?i|=4:r>n&&(i|=8),i}var a=Math.cos(t),o=a>0,s=wo(a)>Bo,l=vr(t,6*Go);return Ne(e,r,l,o?[0,-t]:[-Uo,t-Uo])}function He(t,e,r,n){return function(i){var a,o=i.a,s=i.b,l=o.x,u=o.y,c=s.x,f=s.y,h=0,d=1,p=c-l,g=f-u;if(a=t-l,p||!(a>0)){if(a/=p,0>p){if(h>a)return;d>a&&(d=a)}else if(p>0){if(a>d)return;a>h&&(h=a)}if(a=r-l,p||!(0>a)){if(a/=p,0>p){if(a>d)return;a>h&&(h=a)}else if(p>0){if(h>a)return;d>a&&(d=a)}if(a=e-u,g||!(a>0)){if(a/=g,0>g){if(h>a)return;d>a&&(d=a)}else if(g>0){if(a>d)return;a>h&&(h=a)}if(a=n-u,g||!(0>a)){if(a/=g,0>g){if(a>d)return;a>h&&(h=a)}else if(g>0){if(h>a)return;d>a&&(d=a)}return h>0&&(i.a={x:l+h*p,y:u+h*g}),1>d&&(i.b={x:l+d*p,y:u+d*g}),i}}}}}}function Ge(t,e,r,n){function i(n,i){return wo(n[0]-t)0?0:3:wo(n[0]-r)0?2:1:wo(n[1]-e)0?1:0:i>0?3:2}function a(t,e){return o(t.x,e.x)}function o(t,e){var r=i(t,1),n=i(e,1);return r!==n?r-n:0===r?e[1]-t[1]:1===r?t[0]-e[0]:2===r?t[1]-e[1]:e[0]-t[0]}return function(s){function l(t){for(var e=0,r=v.length,n=t[1],i=0;r>i;++i)for(var a,o=1,s=v[i],l=s.length,u=s[0];l>o;++o)a=s[o],u[1]<=n?a[1]>n&&et(u,a,t)>0&&++e:a[1]<=n&&et(u,a,t)<0&&--e,u=a;return 0!==e}function u(a,s,l,u){var c=0,f=0;if(null==a||(c=i(a,l))!==(f=i(s,l))||o(a,s)<0^l>0){do u.point(0===c||3===c?t:r,c>1?n:e);while((c=(c+l+4)%4)!==f)}else u.point(s[0],s[1])}function c(i,a){return i>=t&&r>=i&&a>=e&&n>=a}function f(t,e){c(t,e)&&s.point(t,e)}function h(){S.point=p,v&&v.push(m=[]),k=!0,A=!1,_=w=NaN}function d(){g&&(p(y,b),x&&A&&T.rejoin(),g.push(T.buffer())),S.point=f,A&&s.lineEnd()}function p(t,e){t=Math.max(-Vs,Math.min(Vs,t)),e=Math.max(-Vs,Math.min(Vs,e));var r=c(t,e);if(v&&m.push([t,e]),k)y=t,b=e,x=r,k=!1,r&&(s.lineStart(),s.point(t,e));else if(r&&A)s.point(t,e);else{var n={a:{x:_,y:w},b:{x:t,y:e}};L(n)?(A||(s.lineStart(),s.point(n.a.x,n.a.y)),s.point(n.b.x,n.b.y),r||s.lineEnd(),M=!1):r&&(s.lineStart(),s.point(t,e),M=!1)}_=t,w=e,A=r}var g,v,m,y,b,x,_,w,A,k,M,E=s,T=De(),L=He(t,e,r,n),S={point:f,lineStart:h,lineEnd:d,polygonStart:function(){s=T,g=[],v=[],M=!0},polygonEnd:function(){s=E,g=uo.merge(g);var e=l([t,n]),r=M&&e,i=g.length;(r||i)&&(s.polygonStart(),r&&(s.lineStart(),u(null,null,1,s),s.lineEnd()),i&&Ie(g,a,e,u,s),s.polygonEnd()),g=v=m=null}};return S}}function Xe(t){var e=0,r=Uo/3,n=lr(t),i=n(e,r);return i.parallels=function(t){return arguments.length?n(e=t[0]*Uo/180,r=t[1]*Uo/180):[e/Uo*180,r/Uo*180]},i}function Ye(t,e){function r(t,e){var r=Math.sqrt(a-2*i*Math.sin(e))/i;return[r*Math.sin(t*=i),o-r*Math.cos(t)]}var n=Math.sin(t),i=(n+Math.sin(e))/2,a=1+n*(2*i-n),o=Math.sqrt(a)/i;return r.invert=function(t,e){var r=o-e;return[Math.atan2(t,r)/i,nt((a-(t*t+r*r)*i*i)/(2*i))]},r}function We(){function t(t,e){Hs+=i*t-n*e,n=t,i=e}var e,r,n,i;Zs.point=function(a,o){Zs.point=t,e=n=a,r=i=o},Zs.lineEnd=function(){t(e,r)}}function Ze(t,e){Gs>t&&(Gs=t),t>Ys&&(Ys=t),Xs>e&&(Xs=e),e>Ws&&(Ws=e)}function Qe(){function t(t,e){o.push("M",t,",",e,a)}function e(t,e){o.push("M",t,",",e),s.point=r}function r(t,e){o.push("L",t,",",e)}function n(){s.point=t}function i(){o.push("Z")}var a=$e(4.5),o=[],s={point:t,lineStart:function(){s.point=e},lineEnd:n,polygonStart:function(){s.lineEnd=i},polygonEnd:function(){s.lineEnd=n,s.point=t},pointRadius:function(t){return a=$e(t),s},result:function(){if(o.length){var t=o.join("");return o=[],t}}};return s}function $e(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}function Ke(t,e){Rs+=t,Is+=e,++Ps}function Je(){function t(t,n){var i=t-e,a=n-r,o=Math.sqrt(i*i+a*a);Os+=o*(e+t)/2,Ns+=o*(r+n)/2,zs+=o,Ke(e=t,r=n)}var e,r;$s.point=function(n,i){$s.point=t,Ke(e=n,r=i)}}function tr(){$s.point=Ke}function er(){function t(t,e){var r=t-n,a=e-i,o=Math.sqrt(r*r+a*a);Os+=o*(n+t)/2,Ns+=o*(i+e)/2,zs+=o,o=i*t-n*e,Ds+=o*(n+t),Fs+=o*(i+e),Bs+=3*o,Ke(n=t,i=e)}var e,r,n,i;$s.point=function(a,o){$s.point=t,Ke(e=n=a,r=i=o)},$s.lineEnd=function(){t(e,r)}}function rr(t){function e(e,r){t.moveTo(e+o,r),t.arc(e,r,o,0,Vo)}function r(e,r){t.moveTo(e,r),s.point=n}function n(e,r){t.lineTo(e,r)}function i(){s.point=e}function a(){t.closePath()}var o=4.5,s={point:e,lineStart:function(){s.point=r},lineEnd:i,polygonStart:function(){s.lineEnd=a},polygonEnd:function(){s.lineEnd=i,s.point=e},pointRadius:function(t){return o=t,s},result:A};return s}function nr(t){function e(t){return(s?n:r)(t)}function r(e){return or(e,function(r,n){r=t(r,n),e.point(r[0],r[1])})}function n(e){function r(r,n){r=t(r,n),e.point(r[0],r[1])}function n(){b=NaN,k.point=a,e.lineStart()}function a(r,n){var a=me([r,n]),o=t(r,n);i(b,x,y,_,w,A,b=o[0],x=o[1],y=r,_=a[0],w=a[1],A=a[2],s,e),e.point(b,x)}function o(){k.point=r,e.lineEnd()}function l(){n(),k.point=u,k.lineEnd=c}function u(t,e){a(f=t,h=e),d=b,p=x,g=_,v=w,m=A,k.point=a}function c(){i(b,x,y,_,w,A,d,p,f,g,v,m,s,e),k.lineEnd=o,o()}var f,h,d,p,g,v,m,y,b,x,_,w,A,k={point:r,lineStart:n,lineEnd:o,polygonStart:function(){e.polygonStart(),k.lineStart=l},polygonEnd:function(){e.polygonEnd(),k.lineStart=n}};return k}function i(e,r,n,s,l,u,c,f,h,d,p,g,v,m){var y=c-e,b=f-r,x=y*y+b*b;if(x>4*a&&v--){var _=s+d,w=l+p,A=u+g,k=Math.sqrt(_*_+w*w+A*A),M=Math.asin(A/=k),E=wo(wo(A)-1)a||wo((y*C+b*R)/x-.5)>.3||o>s*d+l*p+u*g)&&(i(e,r,n,s,l,u,L,S,E,_/=k,w/=k,A,v,m),m.point(L,S),i(L,S,E,_,w,A,c,f,h,d,p,g,v,m))}}var a=.5,o=Math.cos(30*Go),s=16;return e.precision=function(t){return arguments.length?(s=(a=t*t)>0&&16,e):Math.sqrt(a)},e}function ir(t){var e=nr(function(e,r){return t([e*Xo,r*Xo])});return function(t){return ur(e(t))}}function ar(t){this.stream=t}function or(t,e){return{point:e,sphere:function(){t.sphere()},lineStart:function(){t.lineStart()},lineEnd:function(){t.lineEnd()},polygonStart:function(){t.polygonStart()},polygonEnd:function(){t.polygonEnd()}}}function sr(t){return lr(function(){return t})()}function lr(t){function e(t){return t=s(t[0]*Go,t[1]*Go),[t[0]*h+l,u-t[1]*h]}function r(t){return t=s.invert((t[0]-l)/h,(u-t[1])/h),t&&[t[0]*Xo,t[1]*Xo]}function n(){s=Ce(o=hr(m,y,b),a);var t=a(g,v);return l=d-t[0]*h,u=p+t[1]*h,i()}function i(){return c&&(c.valid=!1,c=null),e}var a,o,s,l,u,c,f=nr(function(t,e){return t=a(t,e),[t[0]*h+l,u-t[1]*h]}),h=150,d=480,p=250,g=0,v=0,m=0,y=0,b=0,_=Us,w=x,A=null,k=null;return e.stream=function(t){return c&&(c.valid=!1),c=ur(_(o,f(w(t)))),c.valid=!0,c},e.clipAngle=function(t){return arguments.length?(_=null==t?(A=t,Us):qe((A=+t)*Go),i()):A},e.clipExtent=function(t){return arguments.length?(k=t,w=t?Ge(t[0][0],t[0][1],t[1][0],t[1][1]):x,i()):k},e.scale=function(t){return arguments.length?(h=+t,n()):h},e.translate=function(t){return arguments.length?(d=+t[0],p=+t[1],n()):[d,p]},e.center=function(t){return arguments.length?(g=t[0]%360*Go,v=t[1]%360*Go,n()):[g*Xo,v*Xo]},e.rotate=function(t){return arguments.length?(m=t[0]%360*Go,y=t[1]%360*Go,b=t.length>2?t[2]%360*Go:0,n()):[m*Xo,y*Xo,b*Xo]},uo.rebind(e,f,"precision"),function(){return a=t.apply(this,arguments),e.invert=a.invert&&r,n()}}function ur(t){return or(t,function(e,r){t.point(e*Go,r*Go)})}function cr(t,e){return[t,e]}function fr(t,e){return[t>Uo?t-Vo:-Uo>t?t+Vo:t,e]}function hr(t,e,r){return t?e||r?Ce(pr(t),gr(e,r)):pr(t):e||r?gr(e,r):fr}function dr(t){return function(e,r){return e+=t,[e>Uo?e-Vo:-Uo>e?e+Vo:e,r]}}function pr(t){var e=dr(t);return e.invert=dr(-t),e}function gr(t,e){function r(t,e){var r=Math.cos(e),s=Math.cos(t)*r,l=Math.sin(t)*r,u=Math.sin(e),c=u*n+s*i;return[Math.atan2(l*a-c*o,s*n-u*i),nt(c*a+l*o)]}var n=Math.cos(t),i=Math.sin(t),a=Math.cos(e),o=Math.sin(e);return r.invert=function(t,e){var r=Math.cos(e),s=Math.cos(t)*r,l=Math.sin(t)*r,u=Math.sin(e),c=u*a-l*o;return[Math.atan2(l*a+u*o,s*n+c*i),nt(c*n-s*i)]},r}function vr(t,e){var r=Math.cos(t),n=Math.sin(t);return function(i,a,o,s){var l=o*e;null!=i?(i=mr(r,i),a=mr(r,a),(o>0?a>i:i>a)&&(i+=o*Vo)):(i=t+o*Vo,a=t-.5*l);for(var u,c=i;o>0?c>a:a>c;c-=l)s.point((u=Ae([r,-n*Math.cos(c),-n*Math.sin(c)]))[0],u[1])}}function mr(t,e){var r=me(e);r[0]-=t,we(r);var n=rt(-r[1]);return((-r[2]<0?-n:n)+2*Math.PI-Bo)%(2*Math.PI)}function yr(t,e,r){var n=uo.range(t,e-Bo,r).concat(e);return function(t){return n.map(function(e){return[t,e]})}}function br(t,e,r){var n=uo.range(t,e-Bo,r).concat(e);return function(t){return n.map(function(e){return[e,t]})}}function xr(t){return t.source}function _r(t){return t.target}function wr(t,e,r,n){var i=Math.cos(e),a=Math.sin(e),o=Math.cos(n),s=Math.sin(n),l=i*Math.cos(t),u=i*Math.sin(t),c=o*Math.cos(r),f=o*Math.sin(r),h=2*Math.asin(Math.sqrt(st(n-e)+i*o*st(r-t))),d=1/Math.sin(h),p=h?function(t){var e=Math.sin(t*=h)*d,r=Math.sin(h-t)*d,n=r*l+e*c,i=r*u+e*f,o=r*a+e*s;return[Math.atan2(i,n)*Xo,Math.atan2(o,Math.sqrt(n*n+i*i))*Xo]}:function(){return[t*Xo,e*Xo]};return p.distance=h,p}function Ar(){function t(t,i){var a=Math.sin(i*=Go),o=Math.cos(i),s=wo((t*=Go)-e),l=Math.cos(s);Ks+=Math.atan2(Math.sqrt((s=o*Math.sin(s))*s+(s=n*a-r*o*l)*s),r*a+n*o*l),e=t,r=a,n=o}var e,r,n;Js.point=function(i,a){e=i*Go,r=Math.sin(a*=Go),n=Math.cos(a),Js.point=t},Js.lineEnd=function(){Js.point=Js.lineEnd=A}}function kr(t,e){function r(e,r){var n=Math.cos(e),i=Math.cos(r),a=t(n*i);return[a*i*Math.sin(e),a*Math.sin(r)]}return r.invert=function(t,r){var n=Math.sqrt(t*t+r*r),i=e(n),a=Math.sin(i),o=Math.cos(i);return[Math.atan2(t*a,n*o),Math.asin(n&&r*a/n)]},r}function Mr(t,e){function r(t,e){o>0?-Ho+Bo>e&&(e=-Ho+Bo):e>Ho-Bo&&(e=Ho-Bo);var r=o/Math.pow(i(e),a);return[r*Math.sin(a*t),o-r*Math.cos(a*t)]}var n=Math.cos(t),i=function(t){return Math.tan(Uo/4+t/2)},a=t===e?Math.sin(t):Math.log(n/Math.cos(e))/Math.log(i(e)/i(t)),o=n*Math.pow(i(t),a)/a;return a?(r.invert=function(t,e){var r=o-e,n=tt(a)*Math.sqrt(t*t+r*r);return[Math.atan2(t,r)/a,2*Math.atan(Math.pow(o/n,1/a))-Ho]},r):Tr}function Er(t,e){function r(t,e){var r=a-e;return[r*Math.sin(i*t),a-r*Math.cos(i*t)]}var n=Math.cos(t),i=t===e?Math.sin(t):(n-Math.cos(e))/(e-t),a=n/i+t;return wo(i)i;i++){for(;n>1&&et(t[r[n-2]],t[r[n-1]],t[i])<=0;)--n;r[n++]=i}return r.slice(0,n)}function Pr(t,e){return t[0]-e[0]||t[1]-e[1]}function Or(t,e,r){return(r[0]-e[0])*(t[1]-e[1])<(r[1]-e[1])*(t[0]-e[0])}function Nr(t,e,r,n){var i=t[0],a=r[0],o=e[0]-i,s=n[0]-a,l=t[1],u=r[1],c=e[1]-l,f=n[1]-u,h=(s*(l-u)-f*(i-a))/(f*o-s*c);return[i+h*o,l+h*c]}function zr(t){var e=t[0],r=t[t.length-1];return!(e[0]-r[0]||e[1]-r[1])}function Dr(){an(this),this.edge=this.site=this.circle=null}function Fr(t){var e=fl.pop()||new Dr;return e.site=t,e}function Br(t){Zr(t),ll.remove(t),fl.push(t),an(t)}function jr(t){var e=t.circle,r=e.x,n=e.cy,i={x:r,y:n},a=t.P,o=t.N,s=[t];Br(t);for(var l=a;l.circle&&wo(r-l.circle.x)c;++c)u=s[c],l=s[c-1],en(u.edge,l.site,u.site,i);l=s[0],u=s[f-1],u.edge=Jr(l.site,u.site,null,i),Wr(l),Wr(u)}function Ur(t){for(var e,r,n,i,a=t.x,o=t.y,s=ll._;s;)if(n=Vr(s,o)-a,n>Bo)s=s.L;else{if(i=a-qr(s,o),!(i>Bo)){n>-Bo?(e=s.P,r=s):i>-Bo?(e=s,r=s.N):e=r=s;break}if(!s.R){e=s;break}s=s.R}var l=Fr(t);if(ll.insert(e,l),e||r){if(e===r)return Zr(e),r=Fr(e.site),ll.insert(l,r),l.edge=r.edge=Jr(e.site,l.site),Wr(e),void Wr(r);if(!r)return void(l.edge=Jr(e.site,l.site));Zr(e),Zr(r);var u=e.site,c=u.x,f=u.y,h=t.x-c,d=t.y-f,p=r.site,g=p.x-c,v=p.y-f,m=2*(h*v-d*g),y=h*h+d*d,b=g*g+v*v,x={x:(v*y-d*b)/m+c,y:(h*b-g*y)/m+f};en(r.edge,u,p,x),l.edge=Jr(u,t,null,x),r.edge=Jr(t,p,null,x),Wr(e),Wr(r)}}function Vr(t,e){var r=t.site,n=r.x,i=r.y,a=i-e;if(!a)return n;var o=t.P;if(!o)return-(1/0);r=o.site;var s=r.x,l=r.y,u=l-e;if(!u)return s;var c=s-n,f=1/a-1/u,h=c/u;return f?(-h+Math.sqrt(h*h-2*f*(c*c/(-2*u)-l+u/2+i-a/2)))/f+n:(n+s)/2}function qr(t,e){var r=t.N;if(r)return Vr(r,e);var n=t.site;return n.y===e?n.x:1/0}function Hr(t){this.site=t,this.edges=[]}function Gr(t){for(var e,r,n,i,a,o,s,l,u,c,f=t[0][0],h=t[1][0],d=t[0][1],p=t[1][1],g=sl,v=g.length;v--;)if(a=g[v],a&&a.prepare())for(s=a.edges,l=s.length,o=0;l>o;)c=s[o].end(),n=c.x,i=c.y,u=s[++o%l].start(),e=u.x,r=u.y,(wo(n-e)>Bo||wo(i-r)>Bo)&&(s.splice(o,0,new rn(tn(a.site,c,wo(n-f)Bo?{x:f,y:wo(e-f)Bo?{x:wo(r-p)Bo?{x:h,y:wo(e-h)Bo?{x:wo(r-d)=-jo)){var d=l*l+u*u,p=c*c+f*f,g=(f*d-u*p)/h,v=(l*p-c*d)/h,f=v+s,m=hl.pop()||new Yr;m.arc=t,m.site=i,m.x=g+o,m.y=f+Math.sqrt(g*g+v*v),m.cy=f,t.circle=m;for(var y=null,b=cl._;b;)if(m.yv||v>=s)return;if(h>p){if(a){if(a.y>=u)return}else a={x:v,y:l};r={x:v,y:u}}else{if(a){if(a.yn||n>1)if(h>p){if(a){if(a.y>=u)return}else a={x:(l-i)/n,y:l};r={x:(u-i)/n,y:u}}else{if(a){if(a.yd){if(a){if(a.x>=s)return}else a={x:o,y:n*o+i};r={x:s,y:n*s+i}}else{if(a){if(a.xa||f>o||n>h||i>d)){if(p=t.point){var p,g=e-t.x,v=r-t.y,m=g*g+v*v;if(l>m){var y=Math.sqrt(l=m);n=e-y,i=r-y,a=e+y,o=r+y,s=p}}for(var b=t.nodes,x=.5*(c+h),_=.5*(f+d),w=e>=x,A=r>=_,k=A<<1|w,M=k+4;M>k;++k)if(t=b[3&k])switch(3&k){case 0:u(t,c,f,x,_);break;case 1:u(t,x,f,h,_);break;case 2:u(t,c,_,x,d);break;case 3:u(t,x,_,h,d)}}}(t,n,i,a,o),s}function mn(t,e){t=uo.rgb(t),e=uo.rgb(e);var r=t.r,n=t.g,i=t.b,a=e.r-r,o=e.g-n,s=e.b-i;return function(t){return"#"+wt(Math.round(r+a*t))+wt(Math.round(n+o*t))+wt(Math.round(i+s*t))}}function yn(t,e){var r,n={},i={};for(r in t)r in e?n[r]=_n(t[r],e[r]):i[r]=t[r];for(r in e)r in t||(i[r]=e[r]);return function(t){for(r in n)i[r]=n[r](t);return i}}function bn(t,e){return t=+t,e=+e,function(r){return t*(1-r)+e*r}}function xn(t,e){var r,n,i,a=pl.lastIndex=gl.lastIndex=0,o=-1,s=[],l=[];for(t+="",e+="";(r=pl.exec(t))&&(n=gl.exec(e));)(i=n.index)>a&&(i=e.slice(a,i),s[o]?s[o]+=i:s[++o]=i),(r=r[0])===(n=n[0])?s[o]?s[o]+=n:s[++o]=n:(s[++o]=null,l.push({i:o,x:bn(r,n)})),a=gl.lastIndex;return an;++n)s[(r=l[n]).i]=r.x(t);return s.join("")})}function _n(t,e){for(var r,n=uo.interpolators.length;--n>=0&&!(r=uo.interpolators[n](t,e)););return r}function wn(t,e){var r,n=[],i=[],a=t.length,o=e.length,s=Math.min(t.length,e.length);for(r=0;s>r;++r)n.push(_n(t[r],e[r]));for(;a>r;++r)i[r]=t[r];for(;o>r;++r)i[r]=e[r];return function(t){for(r=0;s>r;++r)i[r]=n[r](t);return i}}function An(t){return function(e){return 0>=e?0:e>=1?1:t(e)}}function kn(t){return function(e){return 1-t(1-e)}}function Mn(t){return function(e){return.5*(.5>e?t(2*e):2-t(2-2*e))}}function En(t){return t*t}function Tn(t){return t*t*t}function Ln(t){if(0>=t)return 0;if(t>=1)return 1;var e=t*t,r=e*t;return 4*(.5>t?r:3*(t-e)+r-.75)}function Sn(t){return function(e){return Math.pow(e,t)}}function Cn(t){return 1-Math.cos(t*Ho)}function Rn(t){return Math.pow(2,10*(t-1))}function In(t){return 1-Math.sqrt(1-t*t)}function Pn(t,e){var r;return arguments.length<2&&(e=.45),arguments.length?r=e/Vo*Math.asin(1/t):(t=1,r=e/4),function(n){return 1+t*Math.pow(2,-10*n)*Math.sin((n-r)*Vo/e)}}function On(t){return t||(t=1.70158),function(e){return e*e*((t+1)*e-t)}}function Nn(t){return 1/2.75>t?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}function zn(t,e){t=uo.hcl(t),e=uo.hcl(e);var r=t.h,n=t.c,i=t.l,a=e.h-r,o=e.c-n,s=e.l-i;return isNaN(o)&&(o=0,n=isNaN(n)?e.c:n),isNaN(a)?(a=0,r=isNaN(r)?e.h:r):a>180?a-=360:-180>a&&(a+=360),function(t){return ht(r+a*t,n+o*t,i+s*t)+""}}function Dn(t,e){t=uo.hsl(t),e=uo.hsl(e);var r=t.h,n=t.s,i=t.l,a=e.h-r,o=e.s-n,s=e.l-i;return isNaN(o)&&(o=0,n=isNaN(n)?e.s:n),isNaN(a)?(a=0,r=isNaN(r)?e.h:r):a>180?a-=360:-180>a&&(a+=360),function(t){return ct(r+a*t,n+o*t,i+s*t)+""}}function Fn(t,e){t=uo.lab(t),e=uo.lab(e);var r=t.l,n=t.a,i=t.b,a=e.l-r,o=e.a-n,s=e.b-i;return function(t){return pt(r+a*t,n+o*t,i+s*t)+""}}function Bn(t,e){return e-=t,function(r){return Math.round(t+e*r)}}function jn(t){var e=[t.a,t.b],r=[t.c,t.d],n=Vn(e),i=Un(e,r),a=Vn(qn(r,e,-i))||0;e[0]*r[1]180?e+=360:e-t>180&&(t+=360),n.push({i:r.push(Hn(r)+"rotate(",null,")")-2,x:bn(t,e)})):e&&r.push(Hn(r)+"rotate("+e+")")}function Yn(t,e,r,n){t!==e?n.push({i:r.push(Hn(r)+"skewX(",null,")")-2,x:bn(t,e)}):e&&r.push(Hn(r)+"skewX("+e+")")}function Wn(t,e,r,n){if(t[0]!==e[0]||t[1]!==e[1]){var i=r.push(Hn(r)+"scale(",null,",",null,")");n.push({i:i-4,x:bn(t[0],e[0])},{i:i-2,x:bn(t[1],e[1])})}else 1===e[0]&&1===e[1]||r.push(Hn(r)+"scale("+e+")")}function Zn(t,e){var r=[],n=[];return t=uo.transform(t),e=uo.transform(e),Gn(t.translate,e.translate,r,n),Xn(t.rotate,e.rotate,r,n),Yn(t.skew,e.skew,r,n),Wn(t.scale,e.scale,r,n),t=e=null,function(t){for(var e,i=-1,a=n.length;++i=0;)r.push(i[n])}function li(t,e){for(var r=[t],n=[];null!=(t=r.pop());)if(n.push(t),(a=t.children)&&(i=a.length))for(var i,a,o=-1;++or;++r)(e=t[r][1])>i&&(n=r,i=e);return n}function bi(t){return t.reduce(xi,0)}function xi(t,e){return t+e[1]}function _i(t,e){return wi(t,Math.ceil(Math.log(e.length)/Math.LN2+1))}function wi(t,e){for(var r=-1,n=+t[0],i=(t[1]-n)/e,a=[];++r<=e;)a[r]=i*r+n;return a}function Ai(t){return[uo.min(t),uo.max(t)]}function ki(t,e){return t.value-e.value}function Mi(t,e){var r=t._pack_next;t._pack_next=e,e._pack_prev=t,e._pack_next=r,r._pack_prev=e}function Ei(t,e){t._pack_next=e,e._pack_prev=t}function Ti(t,e){var r=e.x-t.x,n=e.y-t.y,i=t.r+e.r;return.999*i*i>r*r+n*n}function Li(t){function e(t){c=Math.min(t.x-t.r,c),f=Math.max(t.x+t.r,f),h=Math.min(t.y-t.r,h),d=Math.max(t.y+t.r,d)}if((r=t.children)&&(u=r.length)){ +-var r,n,i,a,o,s,l,u,c=1/0,f=-(1/0),h=1/0,d=-(1/0);if(r.forEach(Si),n=r[0],n.x=-n.r,n.y=0,e(n),u>1&&(i=r[1],i.x=i.r,i.y=0,e(i),u>2))for(a=r[2],Ii(n,i,a),e(a),Mi(n,a),n._pack_prev=a,Mi(a,i),i=n._pack_next,o=3;u>o;o++){Ii(n,i,a=r[o]);var p=0,g=1,v=1;for(s=i._pack_next;s!==i;s=s._pack_next,g++)if(Ti(s,a)){p=1;break}if(1==p)for(l=n._pack_prev;l!==s._pack_prev&&!Ti(l,a);l=l._pack_prev,v++);p?(v>g||g==v&&i.ro;o++)a=r[o],a.x-=m,a.y-=y,b=Math.max(b,a.r+Math.sqrt(a.x*a.x+a.y*a.y));t.r=b,r.forEach(Ci)}}function Si(t){t._pack_next=t._pack_prev=t}function Ci(t){delete t._pack_next,delete t._pack_prev}function Ri(t,e,r,n){var i=t.children;if(t.x=e+=n*t.x,t.y=r+=n*t.y,t.r*=n,i)for(var a=-1,o=i.length;++a=0;)e=i[a],e.z+=r,e.m+=r,r+=e.s+(n+=e.c)}function Fi(t,e,r){return t.a.parent===e.parent?t.a:r}function Bi(t){return 1+uo.max(t,function(t){return t.y})}function ji(t){return t.reduce(function(t,e){return t+e.x},0)/t.length}function Ui(t){var e=t.children;return e&&e.length?Ui(e[0]):t}function Vi(t){var e,r=t.children;return r&&(e=r.length)?Vi(r[e-1]):t}function qi(t){return{x:t.x,y:t.y,dx:t.dx,dy:t.dy}}function Hi(t,e){var r=t.x+e[3],n=t.y+e[0],i=t.dx-e[1]-e[3],a=t.dy-e[0]-e[2];return 0>i&&(r+=i/2,i=0),0>a&&(n+=a/2,a=0),{x:r,y:n,dx:i,dy:a}}function Gi(t){var e=t[0],r=t[t.length-1];return r>e?[e,r]:[r,e]}function Xi(t){return t.rangeExtent?t.rangeExtent():Gi(t.range())}function Yi(t,e,r,n){var i=r(t[0],t[1]),a=n(e[0],e[1]);return function(t){return a(i(t))}}function Wi(t,e){var r,n=0,i=t.length-1,a=t[n],o=t[i];return a>o&&(r=n,n=i,i=r,r=a,a=o,o=r),t[n]=e.floor(a),t[i]=e.ceil(o),t}function Zi(t){return t?{floor:function(e){return Math.floor(e/t)*t},ceil:function(e){return Math.ceil(e/t)*t}}:El}function Qi(t,e,r,n){var i=[],a=[],o=0,s=Math.min(t.length,e.length)-1;for(t[s]2?Qi:Yi,l=n?$n:Qn;return o=i(t,e,l,r),s=i(e,t,l,_n),a}function a(t){return o(t)}var o,s;return a.invert=function(t){return s(t)},a.domain=function(e){return arguments.length?(t=e.map(Number),i()):t},a.range=function(t){return arguments.length?(e=t,i()):e},a.rangeRound=function(t){return a.range(t).interpolate(Bn)},a.clamp=function(t){return arguments.length?(n=t,i()):n},a.interpolate=function(t){return arguments.length?(r=t,i()):r},a.ticks=function(e){return ea(t,e)},a.tickFormat=function(e,r){return ra(t,e,r)},a.nice=function(e){return Ji(t,e),i()},a.copy=function(){return $i(t,e,r,n)},i()}function Ki(t,e){return uo.rebind(t,e,"range","rangeRound","interpolate","clamp")}function Ji(t,e){return Wi(t,Zi(ta(t,e)[2])),Wi(t,Zi(ta(t,e)[2])),t}function ta(t,e){null==e&&(e=10);var r=Gi(t),n=r[1]-r[0],i=Math.pow(10,Math.floor(Math.log(n/e)/Math.LN10)),a=e/n*i;return.15>=a?i*=10:.35>=a?i*=5:.75>=a&&(i*=2),r[0]=Math.ceil(r[0]/i)*i,r[1]=Math.floor(r[1]/i)*i+.5*i,r[2]=i,r}function ea(t,e){return uo.range.apply(uo,ta(t,e))}function ra(t,e,r){var n=ta(t,e);if(r){var i=ps.exec(r);if(i.shift(),"s"===i[8]){var a=uo.formatPrefix(Math.max(wo(n[0]),wo(n[1])));return i[7]||(i[7]="."+na(a.scale(n[2]))),i[8]="f",r=uo.format(i.join("")),function(t){return r(a.scale(t))+a.symbol}}i[7]||(i[7]="."+ia(i[8],n)),r=i.join("")}else r=",."+na(n[2])+"f";return uo.format(r)}function na(t){return-Math.floor(Math.log(t)/Math.LN10+.01)}function ia(t,e){var r=na(e[2]);return t in Tl?Math.abs(r-na(Math.max(wo(e[0]),wo(e[1]))))+ +("e"!==t):r-2*("%"===t)}function aa(t,e,r,n){function i(t){return(r?Math.log(0>t?0:t):-Math.log(t>0?0:-t))/Math.log(e)}function a(t){return r?Math.pow(e,t):-Math.pow(e,-t)}function o(e){return t(i(e))}return o.invert=function(e){return a(t.invert(e))},o.domain=function(e){return arguments.length?(r=e[0]>=0,t.domain((n=e.map(Number)).map(i)),o):n},o.base=function(r){return arguments.length?(e=+r,t.domain(n.map(i)),o):e},o.nice=function(){var e=Wi(n.map(i),r?Math:Sl);return t.domain(e),n=e.map(a),o},o.ticks=function(){var t=Gi(n),o=[],s=t[0],l=t[1],u=Math.floor(i(s)),c=Math.ceil(i(l)),f=e%1?2:e;if(isFinite(c-u)){if(r){for(;c>u;u++)for(var h=1;f>h;h++)o.push(a(u)*h);o.push(a(u))}else for(o.push(a(u));u++0;h--)o.push(a(u)*h);for(u=0;o[u]l;c--);o=o.slice(u,c)}return o},o.tickFormat=function(t,r){if(!arguments.length)return Ll;arguments.length<2?r=Ll:"function"!=typeof r&&(r=uo.format(r));var n=Math.max(1,e*t/o.ticks().length);return function(t){var o=t/a(Math.round(i(t)));return e-.5>o*e&&(o*=e),n>=o?r(t):""}},o.copy=function(){return aa(t.copy(),e,r,n)},Ki(o,t)}function oa(t,e,r){function n(e){return t(i(e))}var i=sa(e),a=sa(1/e);return n.invert=function(e){return a(t.invert(e))},n.domain=function(e){return arguments.length?(t.domain((r=e.map(Number)).map(i)),n):r},n.ticks=function(t){return ea(r,t)},n.tickFormat=function(t,e){return ra(r,t,e)},n.nice=function(t){return n.domain(Ji(r,t))},n.exponent=function(o){return arguments.length?(i=sa(e=o),a=sa(1/e),t.domain(r.map(i)),n):e},n.copy=function(){return oa(t.copy(),e,r)},Ki(n,t)}function sa(t){return function(e){return 0>e?-Math.pow(-e,t):Math.pow(e,t)}}function la(t,e){function r(r){return a[((i.get(r)||("range"===e.t?i.set(r,t.push(r)):NaN))-1)%a.length]}function n(e,r){return uo.range(t.length).map(function(t){return e+r*t})}var i,a,o;return r.domain=function(n){if(!arguments.length)return t;t=[],i=new f;for(var a,o=-1,s=n.length;++or?[NaN,NaN]:[r>0?s[r-1]:t[0],re?NaN:e/a+t,[e,e+1/a]},n.copy=function(){return ca(t,e,r)},i()}function fa(t,e){function r(r){return r>=r?e[uo.bisect(t,r)]:void 0}return r.domain=function(e){return arguments.length?(t=e,r):t},r.range=function(t){return arguments.length?(e=t,r):e},r.invertExtent=function(r){return r=e.indexOf(r),[t[r-1],t[r]]},r.copy=function(){return fa(t,e)},r}function ha(t){function e(t){return+t}return e.invert=e,e.domain=e.range=function(r){return arguments.length?(t=r.map(e),e):t},e.ticks=function(e){return ea(t,e)},e.tickFormat=function(e,r){return ra(t,e,r)},e.copy=function(){return ha(t)},e}function da(){return 0}function pa(t){return t.innerRadius}function ga(t){return t.outerRadius}function va(t){return t.startAngle}function ma(t){return t.endAngle}function ya(t){return t&&t.padAngle}function ba(t,e,r,n){return(t-r)*e-(e-n)*t>0?0:1}function xa(t,e,r,n,i){var a=t[0]-e[0],o=t[1]-e[1],s=(i?n:-n)/Math.sqrt(a*a+o*o),l=s*o,u=-s*a,c=t[0]+l,f=t[1]+u,h=e[0]+l,d=e[1]+u,p=(c+h)/2,g=(f+d)/2,v=h-c,m=d-f,y=v*v+m*m,b=r-n,x=c*d-h*f,_=(0>m?-1:1)*Math.sqrt(Math.max(0,b*b*y-x*x)),w=(x*m-v*_)/y,A=(-x*v-m*_)/y,k=(x*m+v*_)/y,M=(-x*v+m*_)/y,E=w-p,T=A-g,L=k-p,S=M-g;return E*E+T*T>L*L+S*S&&(w=k,A=M),[[w-l,A-u],[w*r/b,A*r/b]]}function _a(t){function e(e){function o(){u.push("M",a(t(c),s))}for(var l,u=[],c=[],f=-1,h=e.length,d=Lt(r),p=Lt(n);++f1?t.join("L"):t+"Z"}function Aa(t){return t.join("L")+"Z"}function ka(t){for(var e=0,r=t.length,n=t[0],i=[n[0],",",n[1]];++e1&&i.push("H",n[0]),i.join("")}function Ma(t){for(var e=0,r=t.length,n=t[0],i=[n[0],",",n[1]];++e1){s=e[1],a=t[l],l++,n+="C"+(i[0]+o[0])+","+(i[1]+o[1])+","+(a[0]-s[0])+","+(a[1]-s[1])+","+a[0]+","+a[1];for(var u=2;u9&&(i=3*e/Math.sqrt(i),o[s]=i*r,o[s+1]=i*n));for(s=-1;++s<=l;)i=(t[Math.min(l,s+1)][0]-t[Math.max(0,s-1)][0])/(6*(1+o[s]*o[s])),a.push([i||0,o[s]*i||0]);return a}function Ua(t){return t.length<3?wa(t):t[0]+Ca(t,ja(t))}function Va(t){for(var e,r,n,i=-1,a=t.length;++i=e?o(t-e):void(u.c=o)}function o(r){var i=p.active,a=p[i];a&&(a.timer.c=null,a.timer.t=NaN,--p.count,delete p[i],a.event&&a.event.interrupt.call(t,t.__data__,a.index));for(var o in p)if(n>+o){var f=p[o];f.timer.c=null,f.timer.t=NaN,--p.count,delete p[o]}u.c=s,Pt(function(){return u.c&&s(r||1)&&(u.c=null,u.t=NaN),1},0,l),p.active=n,g.event&&g.event.start.call(t,t.__data__,e),d=[],g.tween.forEach(function(r,n){(n=n.call(t,t.__data__,e))&&d.push(n)}),h=g.ease,c=g.duration}function s(i){for(var a=i/c,o=h(a),s=d.length;s>0;)d[--s].call(t,o);return a>=1?(g.event&&g.event.end.call(t,t.__data__,e),--p.count?delete p[n]:delete t[r],1):void 0}var l,u,c,h,d,p=t[r]||(t[r]={active:0,count:0}),g=p[n];g||(l=i.time,u=Pt(a,0,l),g=p[n]={tween:new f,time:l,timer:u,delay:i.delay,duration:i.duration,ease:i.ease,index:e},i=null,++p.count)}function ro(t,e,r){t.attr("transform",function(t){var n=e(t);return"translate("+(isFinite(n)?n:r(t))+",0)"})}function no(t,e,r){t.attr("transform",function(t){var n=e(t);return"translate(0,"+(isFinite(n)?n:r(t))+")"})}function io(t){return t.toISOString()}function ao(t,e,r){function n(e){return t(e)}function i(t,r){var n=t[1]-t[0],i=n/r,a=uo.bisect(tu,i);return a==tu.length?[e.year,ta(t.map(function(t){return t/31536e6}),r)[2]]:a?e[i/tu[a-1]1?{floor:function(e){for(;r(e=t.floor(e));)e=oo(e-1);return e},ceil:function(e){for(;r(e=t.ceil(e));)e=oo(+e+1);return e}}:t))},n.ticks=function(t,e){var r=Gi(n.domain()),a=null==t?i(r,10):"number"==typeof t?i(r,t):!t.range&&[{range:t},e];return a&&(t=a[0],e=a[1]),t.range(r[0],oo(+r[1]+1),1>e?1:e)},n.tickFormat=function(){return r},n.copy=function(){return ao(t.copy(),e,r)},Ki(n,t)}function oo(t){return new Date(t)}function so(t){return JSON.parse(t.responseText)}function lo(t){var e=ho.createRange();return e.selectNode(ho.body),e.createContextualFragment(t.responseText)}var uo={version:"3.5.16"},co=[].slice,fo=function(t){return co.call(t)},ho=this.document;if(ho)try{fo(ho.documentElement.childNodes)[0].nodeType}catch(po){fo=function(t){for(var e=t.length,r=new Array(e);e--;)r[e]=t[e];return r}}if(Date.now||(Date.now=function(){return+new Date}),ho)try{ho.createElement("DIV").style.setProperty("opacity",0,"")}catch(go){var vo=this.Element.prototype,mo=vo.setAttribute,yo=vo.setAttributeNS,bo=this.CSSStyleDeclaration.prototype,xo=bo.setProperty;vo.setAttribute=function(t,e){mo.call(this,t,e+"")},vo.setAttributeNS=function(t,e,r){yo.call(this,t,e,r+"")},bo.setProperty=function(t,e,r){xo.call(this,t,e+"",r)}}uo.ascending=i,uo.descending=function(t,e){return t>e?-1:e>t?1:e>=t?0:NaN},uo.min=function(t,e){var r,n,i=-1,a=t.length;if(1===arguments.length){for(;++i=n){r=n;break}for(;++in&&(r=n)}else{for(;++i=n){r=n;break}for(;++in&&(r=n)}return r},uo.max=function(t,e){var r,n,i=-1,a=t.length;if(1===arguments.length){for(;++i=n){r=n;break}for(;++ir&&(r=n)}else{for(;++i=n){r=n;break}for(;++ir&&(r=n)}return r},uo.extent=function(t,e){var r,n,i,a=-1,o=t.length;if(1===arguments.length){for(;++a=n){r=i=n;break}for(;++an&&(r=n),n>i&&(i=n))}else{for(;++a=n){r=i=n;break}for(;++an&&(r=n),n>i&&(i=n))}return[r,i]},uo.sum=function(t,e){var r,n=0,i=t.length,a=-1;if(1===arguments.length)for(;++a1?l/(c-1):void 0},uo.deviation=function(){var t=uo.variance.apply(this,arguments);return t?Math.sqrt(t):t};var _o=s(i);uo.bisectLeft=_o.left,uo.bisect=uo.bisectRight=_o.right,uo.bisector=function(t){return s(1===t.length?function(e,r){return i(t(e),r)}:t)},uo.shuffle=function(t,e,r){(a=arguments.length)<3&&(r=t.length,2>a&&(e=0));for(var n,i,a=r-e;a;)i=Math.random()*a--|0,n=t[a+e],t[a+e]=t[i+e],t[i+e]=n;return t},uo.permute=function(t,e){for(var r=e.length,n=new Array(r);r--;)n[r]=t[e[r]];return n},uo.pairs=function(t){for(var e,r=0,n=t.length-1,i=t[0],a=new Array(0>n?0:n);n>r;)a[r]=[e=i,i=t[++r]];return a},uo.transpose=function(t){if(!(i=t.length))return[];for(var e=-1,r=uo.min(t,l),n=new Array(r);++e=0;)for(n=t[i],e=n.length;--e>=0;)r[--o]=n[e];return r};var wo=Math.abs;uo.range=function(t,e,r){if(arguments.length<3&&(r=1,arguments.length<2&&(e=t,t=0)),(e-t)/r===1/0)throw new Error("infinite range");var n,i=[],a=u(wo(r)),o=-1;if(t*=a,e*=a,r*=a,0>r)for(;(n=t+r*++o)>e;)i.push(n/a);else for(;(n=t+r*++o)=a.length)return n?n.call(i,o):r?o.sort(r):o;for(var l,u,c,h,d=-1,p=o.length,g=a[s++],v=new f;++d=a.length)return t;var n=[],i=o[r++];return t.forEach(function(t,i){n.push({key:t,values:e(i,r)})}),i?n.sort(function(t,e){return i(t.key,e.key)}):n}var r,n,i={},a=[],o=[];return i.map=function(e,r){return t(r,e,0)},i.entries=function(r){return e(t(uo.map,r,0),0)},i.key=function(t){return a.push(t),i},i.sortKeys=function(t){return o[a.length-1]=t,i},i.sortValues=function(t){return r=t,i},i.rollup=function(t){return n=t,i},i},uo.set=function(t){var e=new b;if(t)for(var r=0,n=t.length;n>r;++r)e.add(t[r]);return e},c(b,{has:p,add:function(t){return this._[h(t+="")]=!0,t},remove:g,values:v,size:m,empty:y,forEach:function(t){for(var e in this._)t.call(this,d(e))}}),uo.behavior={},uo.rebind=function(t,e){for(var r,n=1,i=arguments.length;++n=0&&(n=t.slice(r+1),t=t.slice(0,r)),t)return arguments.length<2?this[t].on(n):this[t].on(n,e);if(2===arguments.length){if(null==e)for(t in this)this.hasOwnProperty(t)&&this[t].on(n,null);return this}},uo.event=null,uo.requote=function(t){return t.replace(Eo,"\\$&")};var Eo=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,To={}.__proto__?function(t,e){t.__proto__=e}:function(t,e){for(var r in e)t[r]=e[r]},Lo=function(t,e){return e.querySelector(t)},So=function(t,e){return e.querySelectorAll(t)},Co=function(t,e){var r=t.matches||t[w(t,"matchesSelector")];return(Co=function(t,e){return r.call(t,e)})(t,e)};"function"==typeof Sizzle&&(Lo=function(t,e){return Sizzle(t,e)[0]||null},So=Sizzle,Co=Sizzle.matchesSelector),uo.selection=function(){return uo.select(ho.documentElement)};var Ro=uo.selection.prototype=[];Ro.select=function(t){var e,r,n,i,a=[];t=C(t);for(var o=-1,s=this.length;++o=0&&"xmlns"!==(r=t.slice(0,e))&&(t=t.slice(e+1)),Po.hasOwnProperty(r)?{space:Po[r],local:t}:t}},Ro.attr=function(t,e){if(arguments.length<2){if("string"==typeof t){var r=this.node();return t=uo.ns.qualify(t),t.local?r.getAttributeNS(t.space,t.local):r.getAttribute(t)}for(e in t)this.each(I(e,t[e]));return this}return this.each(I(t,e))},Ro.classed=function(t,e){if(arguments.length<2){if("string"==typeof t){var r=this.node(),n=(t=N(t)).length,i=-1;if(e=r.classList){for(;++ii){if("string"!=typeof t){2>i&&(e="");for(r in t)this.each(F(r,t[r],e));return this}if(2>i){var a=this.node();return n(a).getComputedStyle(a,null).getPropertyValue(t)}r=""}return this.each(F(t,e,r))},Ro.property=function(t,e){if(arguments.length<2){if("string"==typeof t)return this.node()[t];for(e in t)this.each(B(e,t[e]));return this}return this.each(B(t,e))},Ro.text=function(t){return arguments.length?this.each("function"==typeof t?function(){var e=t.apply(this,arguments);this.textContent=null==e?"":e}:null==t?function(){this.textContent=""}:function(){this.textContent=t}):this.node().textContent},Ro.html=function(t){return arguments.length?this.each("function"==typeof t?function(){var e=t.apply(this,arguments);this.innerHTML=null==e?"":e}:null==t?function(){this.innerHTML=""}:function(){this.innerHTML=t}):this.node().innerHTML},Ro.append=function(t){return t=j(t),this.select(function(){return this.appendChild(t.apply(this,arguments))})},Ro.insert=function(t,e){return t=j(t),e=C(e),this.select(function(){return this.insertBefore(t.apply(this,arguments),e.apply(this,arguments)||null)})},Ro.remove=function(){return this.each(U)},Ro.data=function(t,e){function r(t,r){var n,i,a,o=t.length,c=r.length,h=Math.min(o,c),d=new Array(c),p=new Array(c),g=new Array(o);if(e){var v,m=new f,y=new Array(o);for(n=-1;++nn;++n)p[n]=V(r[n]);for(;o>n;++n)g[n]=t[n]}p.update=d,p.parentNode=d.parentNode=g.parentNode=t.parentNode,s.push(p),l.push(d),u.push(g)}var n,i,a=-1,o=this.length;if(!arguments.length){for(t=new Array(o=(n=this[0]).length);++aa;a++){i.push(e=[]),e.parentNode=(r=this[a]).parentNode;for(var s=0,l=r.length;l>s;s++)(n=r[s])&&t.call(n,n.__data__,s,a)&&e.push(n)}return S(i)},Ro.order=function(){for(var t=-1,e=this.length;++t=0;)(r=n[i])&&(a&&a!==r.nextSibling&&a.parentNode.insertBefore(r,a),a=r);return this},Ro.sort=function(t){t=H.apply(this,arguments);for(var e=-1,r=this.length;++et;t++)for(var r=this[t],n=0,i=r.length;i>n;n++){var a=r[n];if(a)return a}return null},Ro.size=function(){var t=0;return G(this,function(){++t}),t};var Oo=[];uo.selection.enter=X,uo.selection.enter.prototype=Oo,Oo.append=Ro.append,Oo.empty=Ro.empty,Oo.node=Ro.node,Oo.call=Ro.call,Oo.size=Ro.size,Oo.select=function(t){for(var e,r,n,i,a,o=[],s=-1,l=this.length;++sn){if("string"!=typeof t){2>n&&(e=!1);for(r in t)this.each(W(r,t[r],e));return this}if(2>n)return(n=this.node()["__on"+t])&&n._;r=!1}return this.each(W(t,e,r))};var No=uo.map({mouseenter:"mouseover",mouseleave:"mouseout"});ho&&No.forEach(function(t){"on"+t in ho&&No.remove(t)});var zo,Do=0;uo.mouse=function(t){return K(t,T())};var Fo=this.navigator&&/WebKit/.test(this.navigator.userAgent)?-1:0;uo.touch=function(t,e,r){if(arguments.length<3&&(r=e,e=T().changedTouches),e)for(var n,i=0,a=e.length;a>i;++i)if((n=e[i]).identifier===r)return K(t,n)},uo.behavior.drag=function(){function t(){this.on("mousedown.drag",a).on("touchstart.drag",o)}function e(t,e,n,a,o){return function(){function s(){var t,r,n=e(h,g);n&&(t=n[0]-b[0],r=n[1]-b[1],p|=t|r,b=n,d({type:"drag",x:n[0]+u[0],y:n[1]+u[1],dx:t,dy:r}))}function l(){e(h,g)&&(m.on(a+v,null).on(o+v,null),y(p),d({type:"dragend"}))}var u,c=this,f=uo.event.target.correspondingElement||uo.event.target,h=c.parentNode,d=r.of(c,arguments),p=0,g=t(),v=".drag"+(null==g?"":"-"+g),m=uo.select(n(f)).on(a+v,s).on(o+v,l),y=$(f),b=e(h,g);i?(u=i.apply(c,arguments),u=[u.x-b[0],u.y-b[1]]):u=[0,0],d({type:"dragstart"})}}var r=L(t,"drag","dragstart","dragend"),i=null,a=e(A,uo.mouse,n,"mousemove","mouseup"),o=e(J,uo.touch,x,"touchmove","touchend");return t.origin=function(e){return arguments.length?(i=e,t):i},uo.rebind(t,r,"on")},uo.touches=function(t,e){return arguments.length<2&&(e=T().touches),e?fo(e).map(function(e){var r=K(t,e);return r.identifier=e.identifier,r}):[]};var Bo=1e-6,jo=Bo*Bo,Uo=Math.PI,Vo=2*Uo,qo=Vo-Bo,Ho=Uo/2,Go=Uo/180,Xo=180/Uo,Yo=Math.SQRT2,Wo=2,Zo=4;uo.interpolateZoom=function(t,e){var r,n,i=t[0],a=t[1],o=t[2],s=e[0],l=e[1],u=e[2],c=s-i,f=l-a,h=c*c+f*f;if(jo>h)n=Math.log(u/o)/Yo,r=function(t){return[i+t*c,a+t*f,o*Math.exp(Yo*t*n)]};else{var d=Math.sqrt(h),p=(u*u-o*o+Zo*h)/(2*o*Wo*d),g=(u*u-o*o-Zo*h)/(2*u*Wo*d),v=Math.log(Math.sqrt(p*p+1)-p),m=Math.log(Math.sqrt(g*g+1)-g);n=(m-v)/Yo,r=function(t){var e=t*n,r=at(v),s=o/(Wo*d)*(r*ot(Yo*e+v)-it(v));return[i+s*c,a+s*f,o*r/at(Yo*e+v)]}}return r.duration=1e3*n,r},uo.behavior.zoom=function(){function t(t){t.on(R,f).on($o+".zoom",d).on("dblclick.zoom",p).on(O,h)}function e(t){return[(t[0]-k.x)/k.k,(t[1]-k.y)/k.k]}function r(t){return[t[0]*k.k+k.x,t[1]*k.k+k.y]}function i(t){k.k=Math.max(T[0],Math.min(T[1],t))}function a(t,e){e=r(e),k.x+=t[0]-e[0], +-k.y+=t[1]-e[1]}function o(e,r,n,o){e.__chart__={x:k.x,y:k.y,k:k.k},i(Math.pow(2,o)),a(v=r,n),e=uo.select(e),S>0&&(e=e.transition().duration(S)),e.call(t.event)}function s(){_&&_.domain(x.range().map(function(t){return(t-k.x)/k.k}).map(x.invert)),A&&A.domain(w.range().map(function(t){return(t-k.y)/k.k}).map(w.invert))}function l(t){C++||t({type:"zoomstart"})}function u(t){s(),t({type:"zoom",scale:k.k,translate:[k.x,k.y]})}function c(t){--C||(t({type:"zoomend"}),v=null)}function f(){function t(){s=1,a(uo.mouse(i),h),u(o)}function r(){f.on(I,null).on(P,null),d(s),c(o)}var i=this,o=N.of(i,arguments),s=0,f=uo.select(n(i)).on(I,t).on(P,r),h=e(uo.mouse(i)),d=$(i);Hl.call(i),l(o)}function h(){function t(){var t=uo.touches(p);return d=k.k,t.forEach(function(t){t.identifier in v&&(v[t.identifier]=e(t))}),t}function r(){var e=uo.event.target;uo.select(e).on(x,n).on(_,s),w.push(e);for(var r=uo.event.changedTouches,i=0,a=r.length;a>i;++i)v[r[i].identifier]=null;var l=t(),u=Date.now();if(1===l.length){if(500>u-b){var c=l[0];o(p,c,v[c.identifier],Math.floor(Math.log(k.k)/Math.LN2)+1),E()}b=u}else if(l.length>1){var c=l[0],f=l[1],h=c[0]-f[0],d=c[1]-f[1];m=h*h+d*d}}function n(){var t,e,r,n,o=uo.touches(p);Hl.call(p);for(var s=0,l=o.length;l>s;++s,n=null)if(r=o[s],n=v[r.identifier]){if(e)break;t=r,e=n}if(n){var c=(c=r[0]-t[0])*c+(c=r[1]-t[1])*c,f=m&&Math.sqrt(c/m);t=[(t[0]+r[0])/2,(t[1]+r[1])/2],e=[(e[0]+n[0])/2,(e[1]+n[1])/2],i(f*d)}b=null,a(t,e),u(g)}function s(){if(uo.event.touches.length){for(var e=uo.event.changedTouches,r=0,n=e.length;n>r;++r)delete v[e[r].identifier];for(var i in v)return void t()}uo.selectAll(w).on(y,null),A.on(R,f).on(O,h),M(),c(g)}var d,p=this,g=N.of(p,arguments),v={},m=0,y=".zoom-"+uo.event.changedTouches[0].identifier,x="touchmove"+y,_="touchend"+y,w=[],A=uo.select(p),M=$(p);r(),l(g),A.on(R,null).on(O,r)}function d(){var t=N.of(this,arguments);y?clearTimeout(y):(Hl.call(this),g=e(v=m||uo.mouse(this)),l(t)),y=setTimeout(function(){y=null,c(t)},50),E(),i(Math.pow(2,.002*Qo())*k.k),a(v,g),u(t)}function p(){var t=uo.mouse(this),r=Math.log(k.k)/Math.LN2;o(this,t,e(t),uo.event.shiftKey?Math.ceil(r)-1:Math.floor(r)+1)}var g,v,m,y,b,x,_,w,A,k={x:0,y:0,k:1},M=[960,500],T=Ko,S=250,C=0,R="mousedown.zoom",I="mousemove.zoom",P="mouseup.zoom",O="touchstart.zoom",N=L(t,"zoomstart","zoom","zoomend");return $o||($o="onwheel"in ho?(Qo=function(){return-uo.event.deltaY*(uo.event.deltaMode?120:1)},"wheel"):"onmousewheel"in ho?(Qo=function(){return uo.event.wheelDelta},"mousewheel"):(Qo=function(){return-uo.event.detail},"MozMousePixelScroll")),t.event=function(t){t.each(function(){var t=N.of(this,arguments),e=k;Vl?uo.select(this).transition().each("start.zoom",function(){k=this.__chart__||{x:0,y:0,k:1},l(t)}).tween("zoom:zoom",function(){var r=M[0],n=M[1],i=v?v[0]:r/2,a=v?v[1]:n/2,o=uo.interpolateZoom([(i-k.x)/k.k,(a-k.y)/k.k,r/k.k],[(i-e.x)/e.k,(a-e.y)/e.k,r/e.k]);return function(e){var n=o(e),s=r/n[2];this.__chart__=k={x:i-n[0]*s,y:a-n[1]*s,k:s},u(t)}}).each("interrupt.zoom",function(){c(t)}).each("end.zoom",function(){c(t)}):(this.__chart__=k,l(t),u(t),c(t))})},t.translate=function(e){return arguments.length?(k={x:+e[0],y:+e[1],k:k.k},s(),t):[k.x,k.y]},t.scale=function(e){return arguments.length?(k={x:k.x,y:k.y,k:null},i(+e),s(),t):k.k},t.scaleExtent=function(e){return arguments.length?(T=null==e?Ko:[+e[0],+e[1]],t):T},t.center=function(e){return arguments.length?(m=e&&[+e[0],+e[1]],t):m},t.size=function(e){return arguments.length?(M=e&&[+e[0],+e[1]],t):M},t.duration=function(e){return arguments.length?(S=+e,t):S},t.x=function(e){return arguments.length?(_=e,x=e.copy(),k={x:0,y:0,k:1},t):_},t.y=function(e){return arguments.length?(A=e,w=e.copy(),k={x:0,y:0,k:1},t):A},uo.rebind(t,N,"on")};var Qo,$o,Ko=[0,1/0];uo.color=lt,lt.prototype.toString=function(){return this.rgb()+""},uo.hsl=ut;var Jo=ut.prototype=new lt;Jo.brighter=function(t){return t=Math.pow(.7,arguments.length?t:1),new ut(this.h,this.s,this.l/t)},Jo.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new ut(this.h,this.s,t*this.l)},Jo.rgb=function(){return ct(this.h,this.s,this.l)},uo.hcl=ft;var ts=ft.prototype=new lt;ts.brighter=function(t){return new ft(this.h,this.c,Math.min(100,this.l+es*(arguments.length?t:1)))},ts.darker=function(t){return new ft(this.h,this.c,Math.max(0,this.l-es*(arguments.length?t:1)))},ts.rgb=function(){return ht(this.h,this.c,this.l).rgb()},uo.lab=dt;var es=18,rs=.95047,ns=1,is=1.08883,as=dt.prototype=new lt;as.brighter=function(t){return new dt(Math.min(100,this.l+es*(arguments.length?t:1)),this.a,this.b)},as.darker=function(t){return new dt(Math.max(0,this.l-es*(arguments.length?t:1)),this.a,this.b)},as.rgb=function(){return pt(this.l,this.a,this.b)},uo.rgb=bt;var os=bt.prototype=new lt;os.brighter=function(t){t=Math.pow(.7,arguments.length?t:1);var e=this.r,r=this.g,n=this.b,i=30;return e||r||n?(e&&i>e&&(e=i),r&&i>r&&(r=i),n&&i>n&&(n=i),new bt(Math.min(255,e/t),Math.min(255,r/t),Math.min(255,n/t))):new bt(i,i,i)},os.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new bt(t*this.r,t*this.g,t*this.b)},os.hsl=function(){return kt(this.r,this.g,this.b)},os.toString=function(){return"#"+wt(this.r)+wt(this.g)+wt(this.b)};var ss=uo.map({aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074});ss.forEach(function(t,e){ss.set(t,xt(e))}),uo.functor=Lt,uo.xhr=St(x),uo.dsv=function(t,e){function r(t,r,a){arguments.length<3&&(a=r,r=null);var o=Ct(t,e,null==r?n:i(r),a);return o.row=function(t){return arguments.length?o.response(null==(r=t)?n:i(t)):r},o}function n(t){return r.parse(t.responseText)}function i(t){return function(e){return r.parse(e.responseText,t)}}function a(e){return e.map(o).join(t)}function o(t){return s.test(t)?'"'+t.replace(/\"/g,'""')+'"':t}var s=new RegExp('["'+t+"\n]"),l=t.charCodeAt(0);return r.parse=function(t,e){var n;return r.parseRows(t,function(t,r){if(n)return n(t,r-1);var i=new Function("d","return {"+t.map(function(t,e){return JSON.stringify(t)+": d["+e+"]"}).join(",")+"}");n=e?function(t,r){return e(i(t),r)}:i})},r.parseRows=function(t,e){function r(){if(c>=u)return o;if(i)return i=!1,a;var e=c;if(34===t.charCodeAt(e)){for(var r=e;r++c;){var n=t.charCodeAt(c++),s=1;if(10===n)i=!0;else if(13===n)i=!0,10===t.charCodeAt(c)&&(++c,++s);else if(n!==l)continue;return t.slice(e,c-s)}return t.slice(e)}for(var n,i,a={},o={},s=[],u=t.length,c=0,f=0;(n=r())!==o;){for(var h=[];n!==a&&n!==o;)h.push(n),n=r();e&&null==(h=e(h,f++))||s.push(h)}return s},r.format=function(e){if(Array.isArray(e[0]))return r.formatRows(e);var n=new b,i=[];return e.forEach(function(t){for(var e in t)n.has(e)||i.push(n.add(e))}),[i.map(o).join(t)].concat(e.map(function(e){return i.map(function(t){return o(e[t])}).join(t)})).join("\n")},r.formatRows=function(t){return t.map(a).join("\n")},r},uo.csv=uo.dsv(",","text/csv"),uo.tsv=uo.dsv(" ","text/tab-separated-values");var ls,us,cs,fs,hs=this[w(this,"requestAnimationFrame")]||function(t){setTimeout(t,17)};uo.timer=function(){Pt.apply(this,arguments)},uo.timer.flush=function(){Nt(),zt()},uo.round=function(t,e){return e?Math.round(t*(e=Math.pow(10,e)))/e:Math.round(t)};var ds=["y","z","a","f","p","n","\xb5","m","","k","M","G","T","P","E","Z","Y"].map(Ft);uo.formatPrefix=function(t,e){var r=0;return(t=+t)&&(0>t&&(t*=-1),e&&(t=uo.round(t,Dt(t,e))),r=1+Math.floor(1e-12+Math.log(t)/Math.LN10),r=Math.max(-24,Math.min(24,3*Math.floor((r-1)/3)))),ds[8+r/3]};var ps=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,gs=uo.map({b:function(t){return t.toString(2)},c:function(t){return String.fromCharCode(t)},o:function(t){return t.toString(8)},x:function(t){return t.toString(16)},X:function(t){return t.toString(16).toUpperCase()},g:function(t,e){return t.toPrecision(e)},e:function(t,e){return t.toExponential(e)},f:function(t,e){return t.toFixed(e)},r:function(t,e){return(t=uo.round(t,Dt(t,e))).toFixed(Math.max(0,Math.min(20,Dt(t*(1+1e-15),e))))}}),vs=uo.time={},ms=Date;Ut.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){ys.setUTCDate.apply(this._,arguments)},setDay:function(){ys.setUTCDay.apply(this._,arguments)},setFullYear:function(){ys.setUTCFullYear.apply(this._,arguments)},setHours:function(){ys.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){ys.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){ys.setUTCMinutes.apply(this._,arguments)},setMonth:function(){ys.setUTCMonth.apply(this._,arguments)},setSeconds:function(){ys.setUTCSeconds.apply(this._,arguments)},setTime:function(){ys.setTime.apply(this._,arguments)}};var ys=Date.prototype;vs.year=Vt(function(t){return t=vs.day(t),t.setMonth(0,1),t},function(t,e){t.setFullYear(t.getFullYear()+e)},function(t){return t.getFullYear()}),vs.years=vs.year.range,vs.years.utc=vs.year.utc.range,vs.day=Vt(function(t){var e=new ms(2e3,0);return e.setFullYear(t.getFullYear(),t.getMonth(),t.getDate()),e},function(t,e){t.setDate(t.getDate()+e)},function(t){return t.getDate()-1}),vs.days=vs.day.range,vs.days.utc=vs.day.utc.range,vs.dayOfYear=function(t){var e=vs.year(t);return Math.floor((t-e-6e4*(t.getTimezoneOffset()-e.getTimezoneOffset()))/864e5)},["sunday","monday","tuesday","wednesday","thursday","friday","saturday"].forEach(function(t,e){e=7-e;var r=vs[t]=Vt(function(t){return(t=vs.day(t)).setDate(t.getDate()-(t.getDay()+e)%7),t},function(t,e){t.setDate(t.getDate()+7*Math.floor(e))},function(t){var r=vs.year(t).getDay();return Math.floor((vs.dayOfYear(t)+(r+e)%7)/7)-(r!==e)});vs[t+"s"]=r.range,vs[t+"s"].utc=r.utc.range,vs[t+"OfYear"]=function(t){var r=vs.year(t).getDay();return Math.floor((vs.dayOfYear(t)+(r+e)%7)/7)}}),vs.week=vs.sunday,vs.weeks=vs.sunday.range,vs.weeks.utc=vs.sunday.utc.range,vs.weekOfYear=vs.sundayOfYear;var bs={"-":"",_:" ",0:"0"},xs=/^\s*\d+/,_s=/^%/;uo.locale=function(t){return{numberFormat:Bt(t),timeFormat:Ht(t)}};var ws=uo.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});uo.format=ws.numberFormat,uo.geo={},fe.prototype={s:0,t:0,add:function(t){he(t,this.t,As),he(As.s,this.s,this),this.s?this.t+=As.t:this.s=As.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var As=new fe;uo.geo.stream=function(t,e){t&&ks.hasOwnProperty(t.type)?ks[t.type](t,e):de(t,e)};var ks={Feature:function(t,e){de(t.geometry,e)},FeatureCollection:function(t,e){for(var r=t.features,n=-1,i=r.length;++nt?4*Uo+t:t,Ls.lineStart=Ls.lineEnd=Ls.point=A}};uo.geo.bounds=function(){function t(t,e){b.push(x=[c=t,h=t]),f>e&&(f=e),e>d&&(d=e)}function e(e,r){var n=me([e*Go,r*Go]);if(m){var i=be(m,n),a=[i[1],-i[0],0],o=be(a,i);we(o),o=Ae(o);var l=e-p,u=l>0?1:-1,g=o[0]*Xo*u,v=wo(l)>180;if(v^(g>u*p&&u*e>g)){var y=o[1]*Xo;y>d&&(d=y)}else if(g=(g+360)%360-180,v^(g>u*p&&u*e>g)){var y=-o[1]*Xo;f>y&&(f=y)}else f>r&&(f=r),r>d&&(d=r);v?p>e?s(c,e)>s(c,h)&&(h=e):s(e,h)>s(c,h)&&(c=e):h>=c?(c>e&&(c=e),e>h&&(h=e)):e>p?s(c,e)>s(c,h)&&(h=e):s(e,h)>s(c,h)&&(c=e)}else t(e,r);m=n,p=e}function r(){_.point=e}function n(){x[0]=c,x[1]=h,_.point=t,m=null}function i(t,r){if(m){var n=t-p;y+=wo(n)>180?n+(n>0?360:-360):n}else g=t,v=r;Ls.point(t,r),e(t,r)}function a(){Ls.lineStart()}function o(){i(g,v),Ls.lineEnd(),wo(y)>Bo&&(c=-(h=180)),x[0]=c,x[1]=h,m=null}function s(t,e){return(e-=t)<0?e+360:e}function l(t,e){return t[0]-e[0]}function u(t,e){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:tTs?(c=-(h=180),f=-(d=90)):y>Bo?d=90:-Bo>y&&(f=-90),x[0]=c,x[1]=h}};return function(t){d=h=-(c=f=1/0),b=[],uo.geo.stream(t,_);var e=b.length;if(e){b.sort(l);for(var r,n=1,i=b[0],a=[i];e>n;++n)r=b[n],u(r[0],i)||u(r[1],i)?(s(i[0],r[1])>s(i[0],i[1])&&(i[1]=r[1]),s(r[0],i[1])>s(i[0],i[1])&&(i[0]=r[0])):a.push(i=r);for(var o,r,p=-(1/0),e=a.length-1,n=0,i=a[e];e>=n;i=r,++n)r=a[n],(o=s(i[1],r[0]))>p&&(p=o,c=r[0],h=i[1])}return b=x=null,c===1/0||f===1/0?[[NaN,NaN],[NaN,NaN]]:[[c,f],[h,d]]}}(),uo.geo.centroid=function(t){Ss=Cs=Rs=Is=Ps=Os=Ns=zs=Ds=Fs=Bs=0,uo.geo.stream(t,js);var e=Ds,r=Fs,n=Bs,i=e*e+r*r+n*n;return jo>i&&(e=Os,r=Ns,n=zs,Bo>Cs&&(e=Rs,r=Is,n=Ps),i=e*e+r*r+n*n,jo>i)?[NaN,NaN]:[Math.atan2(r,e)*Xo,nt(n/Math.sqrt(i))*Xo]};var Ss,Cs,Rs,Is,Ps,Os,Ns,zs,Ds,Fs,Bs,js={sphere:A,point:Me,lineStart:Te,lineEnd:Le,polygonStart:function(){js.lineStart=Se},polygonEnd:function(){js.lineStart=Te}},Us=Ne(Re,Be,Ue,[-Uo,-Uo/2]),Vs=1e9;uo.geo.clipExtent=function(){var t,e,r,n,i,a,o={stream:function(t){return i&&(i.valid=!1),i=a(t),i.valid=!0,i},extent:function(s){return arguments.length?(a=Ge(t=+s[0][0],e=+s[0][1],r=+s[1][0],n=+s[1][1]),i&&(i.valid=!1,i=null),o):[[t,e],[r,n]]}};return o.extent([[0,0],[960,500]])},(uo.geo.conicEqualArea=function(){return Xe(Ye)}).raw=Ye,uo.geo.albers=function(){return uo.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},uo.geo.albersUsa=function(){function t(t){var a=t[0],o=t[1];return e=null,r(a,o),e||(n(a,o),e)||i(a,o),e}var e,r,n,i,a=uo.geo.albers(),o=uo.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),s=uo.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),l={point:function(t,r){e=[t,r]}};return t.invert=function(t){var e=a.scale(),r=a.translate(),n=(t[0]-r[0])/e,i=(t[1]-r[1])/e;return(i>=.12&&.234>i&&n>=-.425&&-.214>n?o:i>=.166&&.234>i&&n>=-.214&&-.115>n?s:a).invert(t)},t.stream=function(t){var e=a.stream(t),r=o.stream(t),n=s.stream(t);return{point:function(t,i){e.point(t,i),r.point(t,i),n.point(t,i)},sphere:function(){e.sphere(),r.sphere(),n.sphere()},lineStart:function(){e.lineStart(),r.lineStart(),n.lineStart()},lineEnd:function(){e.lineEnd(),r.lineEnd(),n.lineEnd()},polygonStart:function(){e.polygonStart(),r.polygonStart(),n.polygonStart()},polygonEnd:function(){e.polygonEnd(),r.polygonEnd(),n.polygonEnd()}}},t.precision=function(e){return arguments.length?(a.precision(e),o.precision(e),s.precision(e),t):a.precision()},t.scale=function(e){return arguments.length?(a.scale(e),o.scale(.35*e),s.scale(e),t.translate(a.translate())):a.scale()},t.translate=function(e){if(!arguments.length)return a.translate();var u=a.scale(),c=+e[0],f=+e[1];return r=a.translate(e).clipExtent([[c-.455*u,f-.238*u],[c+.455*u,f+.238*u]]).stream(l).point,n=o.translate([c-.307*u,f+.201*u]).clipExtent([[c-.425*u+Bo,f+.12*u+Bo],[c-.214*u-Bo,f+.234*u-Bo]]).stream(l).point,i=s.translate([c-.205*u,f+.212*u]).clipExtent([[c-.214*u+Bo,f+.166*u+Bo],[c-.115*u-Bo,f+.234*u-Bo]]).stream(l).point,t},t.scale(1070)};var qs,Hs,Gs,Xs,Ys,Ws,Zs={point:A,lineStart:A,lineEnd:A,polygonStart:function(){Hs=0,Zs.lineStart=We},polygonEnd:function(){Zs.lineStart=Zs.lineEnd=Zs.point=A,qs+=wo(Hs/2)}},Qs={point:Ze,lineStart:A,lineEnd:A,polygonStart:A,polygonEnd:A},$s={point:Ke,lineStart:Je,lineEnd:tr,polygonStart:function(){$s.lineStart=er},polygonEnd:function(){$s.point=Ke,$s.lineStart=Je,$s.lineEnd=tr}};uo.geo.path=function(){function t(t){return t&&("function"==typeof s&&a.pointRadius(+s.apply(this,arguments)),o&&o.valid||(o=i(a)),uo.geo.stream(t,o)),a.result()}function e(){return o=null,t}var r,n,i,a,o,s=4.5;return t.area=function(t){return qs=0,uo.geo.stream(t,i(Zs)),qs},t.centroid=function(t){return Rs=Is=Ps=Os=Ns=zs=Ds=Fs=Bs=0,uo.geo.stream(t,i($s)),Bs?[Ds/Bs,Fs/Bs]:zs?[Os/zs,Ns/zs]:Ps?[Rs/Ps,Is/Ps]:[NaN,NaN]},t.bounds=function(t){return Ys=Ws=-(Gs=Xs=1/0),uo.geo.stream(t,i(Qs)),[[Gs,Xs],[Ys,Ws]]},t.projection=function(t){return arguments.length?(i=(r=t)?t.stream||ir(t):x,e()):r},t.context=function(t){return arguments.length?(a=null==(n=t)?new Qe:new rr(t),"function"!=typeof s&&a.pointRadius(s),e()):n},t.pointRadius=function(e){return arguments.length?(s="function"==typeof e?e:(a.pointRadius(+e),+e),t):s},t.projection(uo.geo.albersUsa()).context(null)},uo.geo.transform=function(t){return{stream:function(e){var r=new ar(e);for(var n in t)r[n]=t[n];return r}}},ar.prototype={point:function(t,e){this.stream.point(t,e)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}},uo.geo.projection=sr,uo.geo.projectionMutator=lr,(uo.geo.equirectangular=function(){return sr(cr)}).raw=cr.invert=cr,uo.geo.rotation=function(t){function e(e){return e=t(e[0]*Go,e[1]*Go),e[0]*=Xo,e[1]*=Xo,e}return t=hr(t[0]%360*Go,t[1]*Go,t.length>2?t[2]*Go:0),e.invert=function(e){return e=t.invert(e[0]*Go,e[1]*Go),e[0]*=Xo,e[1]*=Xo,e},e},fr.invert=cr,uo.geo.circle=function(){function t(){var t="function"==typeof n?n.apply(this,arguments):n,e=hr(-t[0]*Go,-t[1]*Go,0).invert,i=[];return r(null,null,1,{point:function(t,r){i.push(t=e(t,r)),t[0]*=Xo,t[1]*=Xo}}),{type:"Polygon",coordinates:[i]}}var e,r,n=[0,0],i=6;return t.origin=function(e){return arguments.length?(n=e,t):n},t.angle=function(n){return arguments.length?(r=vr((e=+n)*Go,i*Go),t):e},t.precision=function(n){return arguments.length?(r=vr(e*Go,(i=+n)*Go),t):i},t.angle(90)},uo.geo.distance=function(t,e){var r,n=(e[0]-t[0])*Go,i=t[1]*Go,a=e[1]*Go,o=Math.sin(n),s=Math.cos(n),l=Math.sin(i),u=Math.cos(i),c=Math.sin(a),f=Math.cos(a);return Math.atan2(Math.sqrt((r=f*o)*r+(r=u*c-l*f*s)*r),l*c+u*f*s)},uo.geo.graticule=function(){function t(){return{type:"MultiLineString",coordinates:e()}}function e(){return uo.range(Math.ceil(a/v)*v,i,v).map(h).concat(uo.range(Math.ceil(u/m)*m,l,m).map(d)).concat(uo.range(Math.ceil(n/p)*p,r,p).filter(function(t){return wo(t%v)>Bo}).map(c)).concat(uo.range(Math.ceil(s/g)*g,o,g).filter(function(t){return wo(t%m)>Bo}).map(f))}var r,n,i,a,o,s,l,u,c,f,h,d,p=10,g=p,v=90,m=360,y=2.5;return t.lines=function(){return e().map(function(t){return{type:"LineString",coordinates:t}})},t.outline=function(){return{type:"Polygon",coordinates:[h(a).concat(d(l).slice(1),h(i).reverse().slice(1),d(u).reverse().slice(1))]}},t.extent=function(e){return arguments.length?t.majorExtent(e).minorExtent(e):t.minorExtent()},t.majorExtent=function(e){return arguments.length?(a=+e[0][0],i=+e[1][0],u=+e[0][1],l=+e[1][1],a>i&&(e=a,a=i,i=e),u>l&&(e=u,u=l,l=e),t.precision(y)):[[a,u],[i,l]]},t.minorExtent=function(e){return arguments.length?(n=+e[0][0],r=+e[1][0],s=+e[0][1],o=+e[1][1],n>r&&(e=n,n=r,r=e),s>o&&(e=s,s=o,o=e),t.precision(y)):[[n,s],[r,o]]},t.step=function(e){return arguments.length?t.majorStep(e).minorStep(e):t.minorStep()},t.majorStep=function(e){return arguments.length?(v=+e[0],m=+e[1],t):[v,m]},t.minorStep=function(e){return arguments.length?(p=+e[0],g=+e[1],t):[p,g]},t.precision=function(e){return arguments.length?(y=+e,c=yr(s,o,90),f=br(n,r,y),h=yr(u,l,90),d=br(a,i,y),t):y},t.majorExtent([[-180,-90+Bo],[180,90-Bo]]).minorExtent([[-180,-80-Bo],[180,80+Bo]])},uo.geo.greatArc=function(){function t(){return{type:"LineString",coordinates:[e||n.apply(this,arguments),r||i.apply(this,arguments)]}}var e,r,n=xr,i=_r;return t.distance=function(){return uo.geo.distance(e||n.apply(this,arguments),r||i.apply(this,arguments))},t.source=function(r){return arguments.length?(n=r,e="function"==typeof r?null:r,t):n},t.target=function(e){return arguments.length?(i=e,r="function"==typeof e?null:e,t):i},t.precision=function(){return arguments.length?t:0},t},uo.geo.interpolate=function(t,e){return wr(t[0]*Go,t[1]*Go,e[0]*Go,e[1]*Go)},uo.geo.length=function(t){return Ks=0,uo.geo.stream(t,Js),Ks};var Ks,Js={sphere:A,point:A,lineStart:Ar,lineEnd:A,polygonStart:A,polygonEnd:A},tl=kr(function(t){return Math.sqrt(2/(1+t))},function(t){return 2*Math.asin(t/2)});(uo.geo.azimuthalEqualArea=function(){return sr(tl)}).raw=tl;var el=kr(function(t){var e=Math.acos(t);return e&&e/Math.sin(e)},x);(uo.geo.azimuthalEquidistant=function(){return sr(el)}).raw=el,(uo.geo.conicConformal=function(){return Xe(Mr)}).raw=Mr,(uo.geo.conicEquidistant=function(){return Xe(Er)}).raw=Er;var rl=kr(function(t){return 1/t},Math.atan);(uo.geo.gnomonic=function(){return sr(rl)}).raw=rl,Tr.invert=function(t,e){return[t,2*Math.atan(Math.exp(e))-Ho]},(uo.geo.mercator=function(){return Lr(Tr)}).raw=Tr;var nl=kr(function(){return 1},Math.asin);(uo.geo.orthographic=function(){return sr(nl)}).raw=nl;var il=kr(function(t){return 1/(1+t)},function(t){return 2*Math.atan(t)});(uo.geo.stereographic=function(){return sr(il)}).raw=il,Sr.invert=function(t,e){return[-e,2*Math.atan(Math.exp(t))-Ho]},(uo.geo.transverseMercator=function(){var t=Lr(Sr),e=t.center,r=t.rotate;return t.center=function(t){return t?e([-t[1],t[0]]):(t=e(),[t[1],-t[0]])},t.rotate=function(t){return t?r([t[0],t[1],t.length>2?t[2]+90:90]):(t=r(),[t[0],t[1],t[2]-90])},r([0,0,90])}).raw=Sr,uo.geom={},uo.geom.hull=function(t){function e(t){if(t.length<3)return[];var e,i=Lt(r),a=Lt(n),o=t.length,s=[],l=[];for(e=0;o>e;e++)s.push([+i.call(this,t[e],e),+a.call(this,t[e],e),e]);for(s.sort(Pr),e=0;o>e;e++)l.push([s[e][0],-s[e][1]]);var u=Ir(s),c=Ir(l),f=c[0]===u[0],h=c[c.length-1]===u[u.length-1],d=[];for(e=u.length-1;e>=0;--e)d.push(t[s[u[e]][2]]);for(e=+f;e=n&&u.x<=a&&u.y>=i&&u.y<=o?[[n,o],[a,o],[a,i],[n,i]]:[];c.point=t[s]}),e}function r(t){return t.map(function(t,e){return{x:Math.round(a(t,e)/Bo)*Bo,y:Math.round(o(t,e)/Bo)*Bo,i:e}})}var n=Cr,i=Rr,a=n,o=i,s=dl;return t?e(t):(e.links=function(t){return un(r(t)).edges.filter(function(t){return t.l&&t.r}).map(function(e){return{source:t[e.l.i],target:t[e.r.i]}})},e.triangles=function(t){var e=[];return un(r(t)).cells.forEach(function(r,n){for(var i,a,o=r.site,s=r.edges.sort(Xr),l=-1,u=s.length,c=s[u-1].edge,f=c.l===o?c.r:c.l;++l=u,h=n>=c,d=h<<1|f;t.leaf=!1,t=t.nodes[d]||(t.nodes[d]=pn()),f?i=u:s=u,h?o=c:l=c,a(t,e,r,n,i,o,s,l)}var c,f,h,d,p,g,v,m,y,b=Lt(s),x=Lt(l);if(null!=e)g=e,v=r,m=n,y=i;else if(m=y=-(g=v=1/0),f=[],h=[],p=t.length,o)for(d=0;p>d;++d)c=t[d],c.xm&&(m=c.x),c.y>y&&(y=c.y),f.push(c.x),h.push(c.y);else for(d=0;p>d;++d){var _=+b(c=t[d],d),w=+x(c,d);g>_&&(g=_),v>w&&(v=w),_>m&&(m=_),w>y&&(y=w),f.push(_),h.push(w)}var A=m-g,k=y-v;A>k?y=v+A:m=g+k;var M=pn();if(M.add=function(t){a(M,t,+b(t,++d),+x(t,d),g,v,m,y)},M.visit=function(t){gn(t,M,g,v,m,y)},M.find=function(t){return vn(M,t[0],t[1],g,v,m,y)},d=-1,null==e){for(;++d=0?t.slice(0,e):t,n=e>=0?t.slice(e+1):"in";return r=ml.get(r)||vl,n=yl.get(n)||x,An(n(r.apply(null,co.call(arguments,1))))},uo.interpolateHcl=zn,uo.interpolateHsl=Dn,uo.interpolateLab=Fn,uo.interpolateRound=Bn,uo.transform=function(t){var e=ho.createElementNS(uo.ns.prefix.svg,"g");return(uo.transform=function(t){if(null!=t){e.setAttribute("transform",t);var r=e.transform.baseVal.consolidate(); +-}return new jn(r?r.matrix:bl)})(t)},jn.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var bl={a:1,b:0,c:0,d:1,e:0,f:0};uo.interpolateTransform=Zn,uo.layout={},uo.layout.bundle=function(){return function(t){for(var e=[],r=-1,n=t.length;++rs*s/m){if(g>l){var u=e.charge/l;t.px-=a*u,t.py-=o*u}return!0}if(e.point&&l&&g>l){var u=e.pointCharge/l;t.px-=a*u,t.py-=o*u}}return!e.charge}}function e(t){t.px=uo.event.x,t.py=uo.event.y,l.resume()}var r,n,i,a,o,s,l={},u=uo.dispatch("start","tick","end"),c=[1,1],f=.9,h=xl,d=_l,p=-30,g=wl,v=.1,m=.64,y=[],b=[];return l.tick=function(){if((i*=.99)<.005)return r=null,u.end({type:"end",alpha:i=0}),!0;var e,n,l,h,d,g,m,x,_,w=y.length,A=b.length;for(n=0;A>n;++n)l=b[n],h=l.source,d=l.target,x=d.x-h.x,_=d.y-h.y,(g=x*x+_*_)&&(g=i*o[n]*((g=Math.sqrt(g))-a[n])/g,x*=g,_*=g,d.x-=x*(m=h.weight+d.weight?h.weight/(h.weight+d.weight):.5),d.y-=_*m,h.x+=x*(m=1-m),h.y+=_*m);if((m=i*v)&&(x=c[0]/2,_=c[1]/2,n=-1,m))for(;++n0?i=t:(r.c=null,r.t=NaN,r=null,u.end({type:"end",alpha:i=0})):t>0&&(u.start({type:"start",alpha:i=t}),r=Pt(l.tick)),l):i},l.start=function(){function t(t,n){if(!r){for(r=new Array(i),l=0;i>l;++l)r[l]=[];for(l=0;u>l;++l){var a=b[l];r[a.source.index].push(a.target),r[a.target.index].push(a.source)}}for(var o,s=r[e],l=-1,c=s.length;++le;++e)(n=y[e]).index=e,n.weight=0;for(e=0;u>e;++e)n=b[e],"number"==typeof n.source&&(n.source=y[n.source]),"number"==typeof n.target&&(n.target=y[n.target]),++n.source.weight,++n.target.weight;for(e=0;i>e;++e)n=y[e],isNaN(n.x)&&(n.x=t("x",f)),isNaN(n.y)&&(n.y=t("y",g)),isNaN(n.px)&&(n.px=n.x),isNaN(n.py)&&(n.py=n.y);if(a=[],"function"==typeof h)for(e=0;u>e;++e)a[e]=+h.call(this,b[e],e);else for(e=0;u>e;++e)a[e]=h;if(o=[],"function"==typeof d)for(e=0;u>e;++e)o[e]=+d.call(this,b[e],e);else for(e=0;u>e;++e)o[e]=d;if(s=[],"function"==typeof p)for(e=0;i>e;++e)s[e]=+p.call(this,y[e],e);else for(e=0;i>e;++e)s[e]=p;return l.resume()},l.resume=function(){return l.alpha(.1)},l.stop=function(){return l.alpha(0)},l.drag=function(){return n||(n=uo.behavior.drag().origin(x).on("dragstart.force",ei).on("drag.force",e).on("dragend.force",ri)),arguments.length?void this.on("mouseover.force",ni).on("mouseout.force",ii).call(n):n},uo.rebind(l,u,"on")};var xl=20,_l=1,wl=1/0;uo.layout.hierarchy=function(){function t(i){var a,o=[i],s=[];for(i.depth=0;null!=(a=o.pop());)if(s.push(a),(u=r.call(t,a,a.depth))&&(l=u.length)){for(var l,u,c;--l>=0;)o.push(c=u[l]),c.parent=a,c.depth=a.depth+1;n&&(a.value=0),a.children=u}else n&&(a.value=+n.call(t,a,a.depth)||0),delete a.children;return li(i,function(t){var r,i;e&&(r=t.children)&&r.sort(e),n&&(i=t.parent)&&(i.value+=t.value)}),s}var e=fi,r=ui,n=ci;return t.sort=function(r){return arguments.length?(e=r,t):e},t.children=function(e){return arguments.length?(r=e,t):r},t.value=function(e){return arguments.length?(n=e,t):n},t.revalue=function(e){return n&&(si(e,function(t){t.children&&(t.value=0)}),li(e,function(e){var r;e.children||(e.value=+n.call(t,e,e.depth)||0),(r=e.parent)&&(r.value+=e.value)})),e},t},uo.layout.partition=function(){function t(e,r,n,i){var a=e.children;if(e.x=r,e.y=e.depth*i,e.dx=n,e.dy=i,a&&(o=a.length)){var o,s,l,u=-1;for(n=e.value?n/e.value:0;++uf?-1:1),p=uo.sum(u),g=p?(f-l*d)/p:0,v=uo.range(l),m=[];return null!=r&&v.sort(r===Al?function(t,e){return u[e]-u[t]}:function(t,e){return r(o[t],o[e])}),v.forEach(function(t){m[t]={data:o[t],value:s=u[t],startAngle:c,endAngle:c+=s*g+d,padAngle:h}}),m}var e=Number,r=Al,n=0,i=Vo,a=0;return t.value=function(r){return arguments.length?(e=r,t):e},t.sort=function(e){return arguments.length?(r=e,t):r},t.startAngle=function(e){return arguments.length?(n=e,t):n},t.endAngle=function(e){return arguments.length?(i=e,t):i},t.padAngle=function(e){return arguments.length?(a=e,t):a},t};var Al={};uo.layout.stack=function(){function t(s,l){if(!(h=s.length))return s;var u=s.map(function(r,n){return e.call(t,r,n)}),c=u.map(function(e){return e.map(function(e,r){return[a.call(t,e,r),o.call(t,e,r)]})}),f=r.call(t,c,l);u=uo.permute(u,f),c=uo.permute(c,f);var h,d,p,g,v=n.call(t,c,l),m=u[0].length;for(p=0;m>p;++p)for(i.call(t,u[0][p],g=v[p],c[0][p][1]),d=1;h>d;++d)i.call(t,u[d][p],g+=c[d-1][p][1],c[d][p][1]);return s}var e=x,r=vi,n=mi,i=gi,a=di,o=pi;return t.values=function(r){return arguments.length?(e=r,t):e},t.order=function(e){return arguments.length?(r="function"==typeof e?e:kl.get(e)||vi,t):r},t.offset=function(e){return arguments.length?(n="function"==typeof e?e:Ml.get(e)||mi,t):n},t.x=function(e){return arguments.length?(a=e,t):a},t.y=function(e){return arguments.length?(o=e,t):o},t.out=function(e){return arguments.length?(i=e,t):i},t};var kl=uo.map({"inside-out":function(t){var e,r,n=t.length,i=t.map(yi),a=t.map(bi),o=uo.range(n).sort(function(t,e){return i[t]-i[e]}),s=0,l=0,u=[],c=[];for(e=0;n>e;++e)r=o[e],l>s?(s+=a[r],u.push(r)):(l+=a[r],c.push(r));return c.reverse().concat(u)},reverse:function(t){return uo.range(t.length).reverse()},"default":vi}),Ml=uo.map({silhouette:function(t){var e,r,n,i=t.length,a=t[0].length,o=[],s=0,l=[];for(r=0;a>r;++r){for(e=0,n=0;i>e;e++)n+=t[e][r][1];n>s&&(s=n),o.push(n)}for(r=0;a>r;++r)l[r]=(s-o[r])/2;return l},wiggle:function(t){var e,r,n,i,a,o,s,l,u,c=t.length,f=t[0],h=f.length,d=[];for(d[0]=l=u=0,r=1;h>r;++r){for(e=0,i=0;c>e;++e)i+=t[e][r][1];for(e=0,a=0,s=f[r][0]-f[r-1][0];c>e;++e){for(n=0,o=(t[e][r][1]-t[e][r-1][1])/(2*s);e>n;++n)o+=(t[n][r][1]-t[n][r-1][1])/s;a+=o*t[e][r][1]}d[r]=l-=i?a/i*s:0,u>l&&(u=l)}for(r=0;h>r;++r)d[r]-=u;return d},expand:function(t){var e,r,n,i=t.length,a=t[0].length,o=1/i,s=[];for(r=0;a>r;++r){for(e=0,n=0;i>e;e++)n+=t[e][r][1];if(n)for(e=0;i>e;e++)t[e][r][1]/=n;else for(e=0;i>e;e++)t[e][r][1]=o}for(r=0;a>r;++r)s[r]=0;return s},zero:mi});uo.layout.histogram=function(){function t(t,a){for(var o,s,l=[],u=t.map(r,this),c=n.call(this,u,a),f=i.call(this,c,u,a),a=-1,h=u.length,d=f.length-1,p=e?1:1/h;++a0)for(a=-1;++a=c[0]&&s<=c[1]&&(o=l[uo.bisect(f,s,1,d)-1],o.y+=p,o.push(t[a]));return l}var e=!0,r=Number,n=Ai,i=_i;return t.value=function(e){return arguments.length?(r=e,t):r},t.range=function(e){return arguments.length?(n=Lt(e),t):n},t.bins=function(e){return arguments.length?(i="number"==typeof e?function(t){return wi(t,e)}:Lt(e),t):i},t.frequency=function(r){return arguments.length?(e=!!r,t):e},t},uo.layout.pack=function(){function t(t,a){var o=r.call(this,t,a),s=o[0],l=i[0],u=i[1],c=null==e?Math.sqrt:"function"==typeof e?e:function(){return e};if(s.x=s.y=0,li(s,function(t){t.r=+c(t.value)}),li(s,Li),n){var f=n*(e?1:Math.max(2*s.r/l,2*s.r/u))/2;li(s,function(t){t.r+=f}),li(s,Li),li(s,function(t){t.r-=f})}return Ri(s,l/2,u/2,e?1:1/Math.max(2*s.r/l,2*s.r/u)),o}var e,r=uo.layout.hierarchy().sort(ki),n=0,i=[1,1];return t.size=function(e){return arguments.length?(i=e,t):i},t.radius=function(r){return arguments.length?(e=null==r||"function"==typeof r?r:+r,t):e},t.padding=function(e){return arguments.length?(n=+e,t):n},oi(t,r)},uo.layout.tree=function(){function t(t,i){var c=o.call(this,t,i),f=c[0],h=e(f);if(li(h,r),h.parent.m=-h.z,si(h,n),u)si(f,a);else{var d=f,p=f,g=f;si(f,function(t){t.xp.x&&(p=t),t.depth>g.depth&&(g=t)});var v=s(d,p)/2-d.x,m=l[0]/(p.x+s(p,d)/2+v),y=l[1]/(g.depth||1);si(f,function(t){t.x=(t.x+v)*m,t.y=t.depth*y})}return c}function e(t){for(var e,r={A:null,children:[t]},n=[r];null!=(e=n.pop());)for(var i,a=e.children,o=0,s=a.length;s>o;++o)n.push((a[o]=i={_:a[o],parent:e,children:(i=a[o].children)&&i.slice()||[],A:null,a:null,z:0,m:0,c:0,s:0,t:null,i:o}).a=i);return r.children[0]}function r(t){var e=t.children,r=t.parent.children,n=t.i?r[t.i-1]:null;if(e.length){Di(t);var a=(e[0].z+e[e.length-1].z)/2;n?(t.z=n.z+s(t._,n._),t.m=t.z-a):t.z=a}else n&&(t.z=n.z+s(t._,n._));t.parent.A=i(t,n,t.parent.A||r[0])}function n(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function i(t,e,r){if(e){for(var n,i=t,a=t,o=e,l=i.parent.children[0],u=i.m,c=a.m,f=o.m,h=l.m;o=Ni(o),i=Oi(i),o&&i;)l=Oi(l),a=Ni(a),a.a=t,n=o.z+f-i.z-u+s(o._,i._),n>0&&(zi(Fi(o,t,r),t,n),u+=n,c+=n),f+=o.m,u+=i.m,h+=l.m,c+=a.m;o&&!Ni(a)&&(a.t=o,a.m+=f-c),i&&!Oi(l)&&(l.t=i,l.m+=u-h,r=t)}return r}function a(t){t.x*=l[0],t.y=t.depth*l[1]}var o=uo.layout.hierarchy().sort(null).value(null),s=Pi,l=[1,1],u=null;return t.separation=function(e){return arguments.length?(s=e,t):s},t.size=function(e){return arguments.length?(u=null==(l=e)?a:null,t):u?null:l},t.nodeSize=function(e){return arguments.length?(u=null==(l=e)?null:a,t):u?l:null},oi(t,o)},uo.layout.cluster=function(){function t(t,a){var o,s=e.call(this,t,a),l=s[0],u=0;li(l,function(t){var e=t.children;e&&e.length?(t.x=ji(e),t.y=Bi(e)):(t.x=o?u+=r(t,o):0,t.y=0,o=t)});var c=Ui(l),f=Vi(l),h=c.x-r(c,f)/2,d=f.x+r(f,c)/2;return li(l,i?function(t){t.x=(t.x-l.x)*n[0],t.y=(l.y-t.y)*n[1]}:function(t){t.x=(t.x-h)/(d-h)*n[0],t.y=(1-(l.y?t.y/l.y:1))*n[1]}),s}var e=uo.layout.hierarchy().sort(null).value(null),r=Pi,n=[1,1],i=!1;return t.separation=function(e){return arguments.length?(r=e,t):r},t.size=function(e){return arguments.length?(i=null==(n=e),t):i?null:n},t.nodeSize=function(e){return arguments.length?(i=null!=(n=e),t):i?n:null},oi(t,e)},uo.layout.treemap=function(){function t(t,e){for(var r,n,i=-1,a=t.length;++ie?0:e),r.area=isNaN(n)||0>=n?0:n}function e(r){var a=r.children;if(a&&a.length){var o,s,l,u=f(r),c=[],h=a.slice(),p=1/0,g="slice"===d?u.dx:"dice"===d?u.dy:"slice-dice"===d?1&r.depth?u.dy:u.dx:Math.min(u.dx,u.dy);for(t(h,u.dx*u.dy/r.value),c.area=0;(l=h.length)>0;)c.push(o=h[l-1]),c.area+=o.area,"squarify"!==d||(s=n(c,g))<=p?(h.pop(),p=s):(c.area-=c.pop().area,i(c,g,u,!1),g=Math.min(u.dx,u.dy),c.length=c.area=0,p=1/0);c.length&&(i(c,g,u,!0),c.length=c.area=0),a.forEach(e)}}function r(e){var n=e.children;if(n&&n.length){var a,o=f(e),s=n.slice(),l=[];for(t(s,o.dx*o.dy/e.value),l.area=0;a=s.pop();)l.push(a),l.area+=a.area,null!=a.z&&(i(l,a.z?o.dx:o.dy,o,!s.length),l.length=l.area=0);n.forEach(r)}}function n(t,e){for(var r,n=t.area,i=0,a=1/0,o=-1,s=t.length;++or&&(a=r),r>i&&(i=r));return n*=n,e*=e,n?Math.max(e*i*p/n,n/(e*a*p)):1/0}function i(t,e,r,n){var i,a=-1,o=t.length,s=r.x,u=r.y,c=e?l(t.area/e):0;if(e==r.dx){for((n||c>r.dy)&&(c=r.dy);++ar.dx)&&(c=r.dx);++ar&&(e=1),1>r&&(t=0),function(){var r,n,i;do r=2*Math.random()-1,n=2*Math.random()-1,i=r*r+n*n;while(!i||i>1);return t+e*r*Math.sqrt(-2*Math.log(i)/i)}},logNormal:function(){var t=uo.random.normal.apply(uo,arguments);return function(){return Math.exp(t())}},bates:function(t){var e=uo.random.irwinHall(t);return function(){return e()/t}},irwinHall:function(t){return function(){for(var e=0,r=0;t>r;r++)e+=Math.random();return e}}},uo.scale={};var El={floor:x,ceil:x};uo.scale.linear=function(){return $i([0,1],[0,1],_n,!1)};var Tl={s:1,g:1,p:1,r:1,e:1};uo.scale.log=function(){return aa(uo.scale.linear().domain([0,1]),10,!0,[1,10])};var Ll=uo.format(".0e"),Sl={floor:function(t){return-Math.ceil(-t)},ceil:function(t){return-Math.floor(-t)}};uo.scale.pow=function(){return oa(uo.scale.linear(),1,[0,1])},uo.scale.sqrt=function(){return uo.scale.pow().exponent(.5)},uo.scale.ordinal=function(){return la([],{t:"range",a:[[]]})},uo.scale.category10=function(){return uo.scale.ordinal().range(Cl)},uo.scale.category20=function(){return uo.scale.ordinal().range(Rl)},uo.scale.category20b=function(){return uo.scale.ordinal().range(Il)},uo.scale.category20c=function(){return uo.scale.ordinal().range(Pl)};var Cl=[2062260,16744206,2924588,14034728,9725885,9197131,14907330,8355711,12369186,1556175].map(_t),Rl=[2062260,11454440,16744206,16759672,2924588,10018698,14034728,16750742,9725885,12955861,9197131,12885140,14907330,16234194,8355711,13092807,12369186,14408589,1556175,10410725].map(_t),Il=[3750777,5395619,7040719,10264286,6519097,9216594,11915115,13556636,9202993,12426809,15186514,15190932,8666169,11356490,14049643,15177372,8077683,10834324,13528509,14589654].map(_t),Pl=[3244733,7057110,10406625,13032431,15095053,16616764,16625259,16634018,3253076,7652470,10607003,13101504,7695281,10394312,12369372,14342891,6513507,9868950,12434877,14277081].map(_t);uo.scale.quantile=function(){return ua([],[])},uo.scale.quantize=function(){return ca(0,1,[0,1])},uo.scale.threshold=function(){return fa([.5],[0,1])},uo.scale.identity=function(){return ha([0,1])},uo.svg={},uo.svg.arc=function(){function t(){var t=Math.max(0,+r.apply(this,arguments)),u=Math.max(0,+n.apply(this,arguments)),c=o.apply(this,arguments)-Ho,f=s.apply(this,arguments)-Ho,h=Math.abs(f-c),d=c>f?0:1;if(t>u&&(p=u,u=t,t=p),h>=qo)return e(u,d)+(t?e(t,1-d):"")+"Z";var p,g,v,m,y,b,x,_,w,A,k,M,E=0,T=0,L=[];if((m=(+l.apply(this,arguments)||0)/2)&&(v=a===Ol?Math.sqrt(t*t+u*u):+a.apply(this,arguments),d||(T*=-1),u&&(T=nt(v/u*Math.sin(m))),t&&(E=nt(v/t*Math.sin(m)))),u){y=u*Math.cos(c+T),b=u*Math.sin(c+T),x=u*Math.cos(f-T),_=u*Math.sin(f-T);var S=Math.abs(f-c-2*T)<=Uo?0:1;if(T&&ba(y,b,x,_)===d^S){var C=(c+f)/2;y=u*Math.cos(C),b=u*Math.sin(C),x=_=null}}else y=b=0;if(t){w=t*Math.cos(f-E),A=t*Math.sin(f-E),k=t*Math.cos(c+E),M=t*Math.sin(c+E);var R=Math.abs(c-f+2*E)<=Uo?0:1;if(E&&ba(w,A,k,M)===1-d^R){var I=(c+f)/2;w=t*Math.cos(I),A=t*Math.sin(I),k=M=null}}else w=A=0;if(h>Bo&&(p=Math.min(Math.abs(u-t)/2,+i.apply(this,arguments)))>.001){g=u>t^d?0:1;var P=p,O=p;if(Uo>h){var N=null==k?[w,A]:null==x?[y,b]:Nr([y,b],[k,M],[x,_],[w,A]),z=y-N[0],D=b-N[1],F=x-N[0],B=_-N[1],j=1/Math.sin(Math.acos((z*F+D*B)/(Math.sqrt(z*z+D*D)*Math.sqrt(F*F+B*B)))/2),U=Math.sqrt(N[0]*N[0]+N[1]*N[1]);O=Math.min(p,(t-U)/(j-1)),P=Math.min(p,(u-U)/(j+1))}if(null!=x){var V=xa(null==k?[w,A]:[k,M],[y,b],u,P,d),q=xa([x,_],[w,A],u,P,d);p===P?L.push("M",V[0],"A",P,",",P," 0 0,",g," ",V[1],"A",u,",",u," 0 ",1-d^ba(V[1][0],V[1][1],q[1][0],q[1][1]),",",d," ",q[1],"A",P,",",P," 0 0,",g," ",q[0]):L.push("M",V[0],"A",P,",",P," 0 1,",g," ",q[0])}else L.push("M",y,",",b);if(null!=k){var H=xa([y,b],[k,M],t,-O,d),G=xa([w,A],null==x?[y,b]:[x,_],t,-O,d);p===O?L.push("L",G[0],"A",O,",",O," 0 0,",g," ",G[1],"A",t,",",t," 0 ",d^ba(G[1][0],G[1][1],H[1][0],H[1][1]),",",1-d," ",H[1],"A",O,",",O," 0 0,",g," ",H[0]):L.push("L",G[0],"A",O,",",O," 0 0,",g," ",H[0])}else L.push("L",w,",",A)}else L.push("M",y,",",b),null!=x&&L.push("A",u,",",u," 0 ",S,",",d," ",x,",",_),L.push("L",w,",",A),null!=k&&L.push("A",t,",",t," 0 ",R,",",1-d," ",k,",",M);return L.push("Z"),L.join("")}function e(t,e){return"M0,"+t+"A"+t+","+t+" 0 1,"+e+" 0,"+-t+"A"+t+","+t+" 0 1,"+e+" 0,"+t}var r=pa,n=ga,i=da,a=Ol,o=va,s=ma,l=ya;return t.innerRadius=function(e){return arguments.length?(r=Lt(e),t):r},t.outerRadius=function(e){return arguments.length?(n=Lt(e),t):n},t.cornerRadius=function(e){return arguments.length?(i=Lt(e),t):i},t.padRadius=function(e){return arguments.length?(a=e==Ol?Ol:Lt(e),t):a},t.startAngle=function(e){return arguments.length?(o=Lt(e),t):o},t.endAngle=function(e){return arguments.length?(s=Lt(e),t):s},t.padAngle=function(e){return arguments.length?(l=Lt(e),t):l},t.centroid=function(){var t=(+r.apply(this,arguments)+ +n.apply(this,arguments))/2,e=(+o.apply(this,arguments)+ +s.apply(this,arguments))/2-Ho;return[Math.cos(e)*t,Math.sin(e)*t]},t};var Ol="auto";uo.svg.line=function(){return _a(x)};var Nl=uo.map({linear:wa,"linear-closed":Aa,step:ka,"step-before":Ma,"step-after":Ea,basis:Ia,"basis-open":Pa,"basis-closed":Oa,bundle:Na,cardinal:Sa,"cardinal-open":Ta,"cardinal-closed":La,monotone:Ua});Nl.forEach(function(t,e){e.key=t,e.closed=/-closed$/.test(t)});var zl=[0,2/3,1/3,0],Dl=[0,1/3,2/3,0],Fl=[0,1/6,2/3,1/6];uo.svg.line.radial=function(){var t=_a(Va);return t.radius=t.x,delete t.x,t.angle=t.y,delete t.y,t},Ma.reverse=Ea,Ea.reverse=Ma,uo.svg.area=function(){return qa(x)},uo.svg.area.radial=function(){var t=qa(Va);return t.radius=t.x,delete t.x,t.innerRadius=t.x0,delete t.x0,t.outerRadius=t.x1,delete t.x1,t.angle=t.y,delete t.y,t.startAngle=t.y0,delete t.y0,t.endAngle=t.y1,delete t.y1,t},uo.svg.chord=function(){function t(t,s){var l=e(this,a,t,s),u=e(this,o,t,s);return"M"+l.p0+n(l.r,l.p1,l.a1-l.a0)+(r(l,u)?i(l.r,l.p1,l.r,l.p0):i(l.r,l.p1,u.r,u.p0)+n(u.r,u.p1,u.a1-u.a0)+i(u.r,u.p1,l.r,l.p0))+"Z"}function e(t,e,r,n){var i=e.call(t,r,n),a=s.call(t,i,n),o=l.call(t,i,n)-Ho,c=u.call(t,i,n)-Ho;return{r:a,a0:o,a1:c,p0:[a*Math.cos(o),a*Math.sin(o)],p1:[a*Math.cos(c),a*Math.sin(c)]}}function r(t,e){return t.a0==e.a0&&t.a1==e.a1}function n(t,e,r){return"A"+t+","+t+" 0 "+ +(r>Uo)+",1 "+e}function i(t,e,r,n){return"Q 0,0 "+n}var a=xr,o=_r,s=Ha,l=va,u=ma;return t.radius=function(e){return arguments.length?(s=Lt(e),t):s},t.source=function(e){return arguments.length?(a=Lt(e),t):a},t.target=function(e){return arguments.length?(o=Lt(e),t):o},t.startAngle=function(e){return arguments.length?(l=Lt(e),t):l},t.endAngle=function(e){return arguments.length?(u=Lt(e),t):u},t},uo.svg.diagonal=function(){function t(t,i){var a=e.call(this,t,i),o=r.call(this,t,i),s=(a.y+o.y)/2,l=[a,{x:a.x,y:s},{x:o.x,y:s},o];return l=l.map(n),"M"+l[0]+"C"+l[1]+" "+l[2]+" "+l[3]}var e=xr,r=_r,n=Ga;return t.source=function(r){return arguments.length?(e=Lt(r),t):e},t.target=function(e){return arguments.length?(r=Lt(e),t):r},t.projection=function(e){return arguments.length?(n=e,t):n},t},uo.svg.diagonal.radial=function(){var t=uo.svg.diagonal(),e=Ga,r=t.projection;return t.projection=function(t){return arguments.length?r(Xa(e=t)):e},t},uo.svg.symbol=function(){function t(t,n){return(Bl.get(e.call(this,t,n))||Za)(r.call(this,t,n))}var e=Wa,r=Ya;return t.type=function(r){return arguments.length?(e=Lt(r),t):e},t.size=function(e){return arguments.length?(r=Lt(e),t):r},t};var Bl=uo.map({circle:Za,cross:function(t){var e=Math.sqrt(t/5)/2;return"M"+-3*e+","+-e+"H"+-e+"V"+-3*e+"H"+e+"V"+-e+"H"+3*e+"V"+e+"H"+e+"V"+3*e+"H"+-e+"V"+e+"H"+-3*e+"Z"},diamond:function(t){var e=Math.sqrt(t/(2*Ul)),r=e*Ul;return"M0,"+-e+"L"+r+",0 0,"+e+" "+-r+",0Z"},square:function(t){var e=Math.sqrt(t)/2;return"M"+-e+","+-e+"L"+e+","+-e+" "+e+","+e+" "+-e+","+e+"Z"},"triangle-down":function(t){var e=Math.sqrt(t/jl),r=e*jl/2;return"M0,"+r+"L"+e+","+-r+" "+-e+","+-r+"Z"},"triangle-up":function(t){var e=Math.sqrt(t/jl),r=e*jl/2;return"M0,"+-r+"L"+e+","+r+" "+-e+","+r+"Z"}});uo.svg.symbolTypes=Bl.keys();var jl=Math.sqrt(3),Ul=Math.tan(30*Go);Ro.transition=function(t){for(var e,r,n=Vl||++Xl,i=to(t),a=[],o=ql||{time:Date.now(),ease:Ln,delay:0,duration:250},s=-1,l=this.length;++sa;a++){i.push(e=[]);for(var r=this[a],s=0,l=r.length;l>s;s++)(n=r[s])&&t.call(n,n.__data__,s,a)&&e.push(n)}return $a(i,this.namespace,this.id)},Gl.tween=function(t,e){var r=this.id,n=this.namespace;return arguments.length<2?this.node()[n][r].tween.get(t):G(this,null==e?function(e){e[n][r].tween.remove(t)}:function(i){i[n][r].tween.set(t,e)})},Gl.attr=function(t,e){function r(){this.removeAttribute(s)}function n(){this.removeAttributeNS(s.space,s.local)}function i(t){return null==t?r:(t+="",function(){var e,r=this.getAttribute(s);return r!==t&&(e=o(r,t),function(t){this.setAttribute(s,e(t))})})}function a(t){return null==t?n:(t+="",function(){var e,r=this.getAttributeNS(s.space,s.local);return r!==t&&(e=o(r,t),function(t){this.setAttributeNS(s.space,s.local,e(t))})})}if(arguments.length<2){for(e in t)this.attr(e,t[e]);return this}var o="transform"==t?Zn:_n,s=uo.ns.qualify(t);return Ka(this,"attr."+t,e,s.local?a:i)},Gl.attrTween=function(t,e){function r(t,r){var n=e.call(this,t,r,this.getAttribute(i));return n&&function(t){this.setAttribute(i,n(t))}}function n(t,r){var n=e.call(this,t,r,this.getAttributeNS(i.space,i.local));return n&&function(t){this.setAttributeNS(i.space,i.local,n(t))}}var i=uo.ns.qualify(t);return this.tween("attr."+t,i.local?n:r)},Gl.style=function(t,e,r){function i(){this.style.removeProperty(t)}function a(e){return null==e?i:(e+="",function(){var i,a=n(this).getComputedStyle(this,null).getPropertyValue(t);return a!==e&&(i=_n(a,e),function(e){this.style.setProperty(t,i(e),r)})})}var o=arguments.length;if(3>o){if("string"!=typeof t){2>o&&(e="");for(r in t)this.style(r,t[r],e);return this}r=""}return Ka(this,"style."+t,e,a)},Gl.styleTween=function(t,e,r){function i(i,a){var o=e.call(this,i,a,n(this).getComputedStyle(this,null).getPropertyValue(t));return o&&function(e){this.style.setProperty(t,o(e),r)}}return arguments.length<3&&(r=""),this.tween("style."+t,i)},Gl.text=function(t){return Ka(this,"text",t,Ja)},Gl.remove=function(){var t=this.namespace;return this.each("end.transition",function(){var e;this[t].count<2&&(e=this.parentNode)&&e.removeChild(this)})},Gl.ease=function(t){var e=this.id,r=this.namespace;return arguments.length<1?this.node()[r][e].ease:("function"!=typeof t&&(t=uo.ease.apply(uo,arguments)),G(this,function(n){n[r][e].ease=t}))},Gl.delay=function(t){var e=this.id,r=this.namespace;return arguments.length<1?this.node()[r][e].delay:G(this,"function"==typeof t?function(n,i,a){n[r][e].delay=+t.call(n,n.__data__,i,a)}:(t=+t,function(n){n[r][e].delay=t}))},Gl.duration=function(t){var e=this.id,r=this.namespace;return arguments.length<1?this.node()[r][e].duration:G(this,"function"==typeof t?function(n,i,a){n[r][e].duration=Math.max(1,t.call(n,n.__data__,i,a))}:(t=Math.max(1,t),function(n){n[r][e].duration=t}))},Gl.each=function(t,e){var r=this.id,n=this.namespace;if(arguments.length<2){var i=ql,a=Vl;try{Vl=r,G(this,function(e,i,a){ql=e[n][r],t.call(e,e.__data__,i,a)})}finally{ql=i,Vl=a}}else G(this,function(i){var a=i[n][r];(a.event||(a.event=uo.dispatch("start","end","interrupt"))).on(t,e)});return this},Gl.transition=function(){for(var t,e,r,n,i=this.id,a=++Xl,o=this.namespace,s=[],l=0,u=this.length;u>l;l++){s.push(t=[]);for(var e=this[l],c=0,f=e.length;f>c;c++)(r=e[c])&&(n=r[o][i],eo(r,c,o,a,{time:n.time,ease:n.ease,delay:n.delay+n.duration,duration:n.duration})),t.push(r)}return $a(s,o,a)},uo.svg.axis=function(){function t(t){t.each(function(){var t,u=uo.select(this),c=this.__chart__||r,f=this.__chart__=r.copy(),h=null==l?f.ticks?f.ticks.apply(f,s):f.domain():l,d=null==e?f.tickFormat?f.tickFormat.apply(f,s):x:e,p=u.selectAll(".tick").data(h,f),g=p.enter().insert("g",".domain").attr("class","tick").style("opacity",Bo),v=uo.transition(p.exit()).style("opacity",Bo).remove(),m=uo.transition(p.order()).style("opacity",1),y=Math.max(i,0)+o,b=Xi(f),_=u.selectAll(".domain").data([0]),w=(_.enter().append("path").attr("class","domain"),uo.transition(_));g.append("line"),g.append("text");var A,k,M,E,T=g.select("line"),L=m.select("line"),S=p.select("text").text(d),C=g.select("text"),R=m.select("text"),I="top"===n||"left"===n?-1:1;if("bottom"===n||"top"===n?(t=ro,A="x",M="y",k="x2",E="y2",S.attr("dy",0>I?"0em":".71em").style("text-anchor","middle"),w.attr("d","M"+b[0]+","+I*a+"V0H"+b[1]+"V"+I*a)):(t=no,A="y",M="x",k="y2",E="x2",S.attr("dy",".32em").style("text-anchor",0>I?"end":"start"),w.attr("d","M"+I*a+","+b[0]+"H0V"+b[1]+"H"+I*a)),T.attr(E,I*i),C.attr(M,I*y),L.attr(k,0).attr(E,I*i),R.attr(A,0).attr(M,I*y),f.rangeBand){var P=f,O=P.rangeBand()/2;c=f=function(t){return P(t)+O}}else c.rangeBand?c=f:v.call(t,f,c);g.call(t,c,f),m.call(t,f,f)})}var e,r=uo.scale.linear(),n=Yl,i=6,a=6,o=3,s=[10],l=null;return t.scale=function(e){return arguments.length?(r=e,t):r},t.orient=function(e){return arguments.length?(n=e in Wl?e+"":Yl,t):n},t.ticks=function(){return arguments.length?(s=fo(arguments),t):s},t.tickValues=function(e){return arguments.length?(l=e,t):l},t.tickFormat=function(r){return arguments.length?(e=r,t):e},t.tickSize=function(e){var r=arguments.length;return r?(i=+e,a=+arguments[r-1],t):i},t.innerTickSize=function(e){return arguments.length?(i=+e,t):i},t.outerTickSize=function(e){return arguments.length?(a=+e,t):a},t.tickPadding=function(e){return arguments.length?(o=+e,t):o},t.tickSubdivide=function(){return arguments.length&&t},t};var Yl="bottom",Wl={top:1,right:1,bottom:1,left:1};uo.svg.brush=function(){function t(n){n.each(function(){var n=uo.select(this).style("pointer-events","all").style("-webkit-tap-highlight-color","rgba(0,0,0,0)").on("mousedown.brush",a).on("touchstart.brush",a),o=n.selectAll(".background").data([0]);o.enter().append("rect").attr("class","background").style("visibility","hidden").style("cursor","crosshair"),n.selectAll(".extent").data([0]).enter().append("rect").attr("class","extent").style("cursor","move");var s=n.selectAll(".resize").data(g,x);s.exit().remove(),s.enter().append("g").attr("class",function(t){return"resize "+t}).style("cursor",function(t){return Zl[t]}).append("rect").attr("x",function(t){return/[ew]$/.test(t)?-3:null}).attr("y",function(t){return/^[ns]/.test(t)?-3:null}).attr("width",6).attr("height",6).style("visibility","hidden"),s.style("display",t.empty()?"none":null);var l,f=uo.transition(n),h=uo.transition(o);u&&(l=Xi(u),h.attr("x",l[0]).attr("width",l[1]-l[0]),r(f)),c&&(l=Xi(c),h.attr("y",l[0]).attr("height",l[1]-l[0]),i(f)),e(f)})}function e(t){t.selectAll(".resize").attr("transform",function(t){return"translate("+f[+/e$/.test(t)]+","+h[+/^s/.test(t)]+")"})}function r(t){t.select(".extent").attr("x",f[0]),t.selectAll(".extent,.n>rect,.s>rect").attr("width",f[1]-f[0])}function i(t){t.select(".extent").attr("y",h[0]),t.selectAll(".extent,.e>rect,.w>rect").attr("height",h[1]-h[0])}function a(){function a(){32==uo.event.keyCode&&(S||(b=null,R[0]-=f[1],R[1]-=h[1],S=2),E())}function g(){32==uo.event.keyCode&&2==S&&(R[0]+=f[1],R[1]+=h[1],S=0,E())}function v(){var t=uo.mouse(_),n=!1;x&&(t[0]+=x[0],t[1]+=x[1]),S||(uo.event.altKey?(b||(b=[(f[0]+f[1])/2,(h[0]+h[1])/2]),R[0]=f[+(t[0]c?(i=n,n=c):i=c),g[0]!=n||g[1]!=i?(r?s=null:o=null,g[0]=n,g[1]=i,!0):void 0}function y(){v(),k.style("pointer-events","all").selectAll(".resize").style("display",t.empty()?"none":null),uo.select("body").style("cursor",null),I.on("mousemove.brush",null).on("mouseup.brush",null).on("touchmove.brush",null).on("touchend.brush",null).on("keydown.brush",null).on("keyup.brush",null),C(),A({type:"brushend"})}var b,x,_=this,w=uo.select(uo.event.target),A=l.of(_,arguments),k=uo.select(_),M=w.datum(),T=!/^(n|s)$/.test(M)&&u,L=!/^(e|w)$/.test(M)&&c,S=w.classed("extent"),C=$(_),R=uo.mouse(_),I=uo.select(n(_)).on("keydown.brush",a).on("keyup.brush",g);if(uo.event.changedTouches?I.on("touchmove.brush",v).on("touchend.brush",y):I.on("mousemove.brush",v).on("mouseup.brush",y), +-k.interrupt().selectAll("*").interrupt(),S)R[0]=f[0]-R[0],R[1]=h[0]-R[1];else if(M){var P=+/w$/.test(M),O=+/^n/.test(M);x=[f[1-P]-R[0],h[1-O]-R[1]],R[0]=f[P],R[1]=h[O]}else uo.event.altKey&&(b=R.slice());k.style("pointer-events","none").selectAll(".resize").style("display",null),uo.select("body").style("cursor",w.style("cursor")),A({type:"brushstart"}),v()}var o,s,l=L(t,"brushstart","brush","brushend"),u=null,c=null,f=[0,0],h=[0,0],d=!0,p=!0,g=Ql[0];return t.event=function(t){t.each(function(){var t=l.of(this,arguments),e={x:f,y:h,i:o,j:s},r=this.__chart__||e;this.__chart__=e,Vl?uo.select(this).transition().each("start.brush",function(){o=r.i,s=r.j,f=r.x,h=r.y,t({type:"brushstart"})}).tween("brush:brush",function(){var r=wn(f,e.x),n=wn(h,e.y);return o=s=null,function(i){f=e.x=r(i),h=e.y=n(i),t({type:"brush",mode:"resize"})}}).each("end.brush",function(){o=e.i,s=e.j,t({type:"brush",mode:"resize"}),t({type:"brushend"})}):(t({type:"brushstart"}),t({type:"brush",mode:"resize"}),t({type:"brushend"}))})},t.x=function(e){return arguments.length?(u=e,g=Ql[!u<<1|!c],t):u},t.y=function(e){return arguments.length?(c=e,g=Ql[!u<<1|!c],t):c},t.clamp=function(e){return arguments.length?(u&&c?(d=!!e[0],p=!!e[1]):u?d=!!e:c&&(p=!!e),t):u&&c?[d,p]:u?d:c?p:null},t.extent=function(e){var r,n,i,a,l;return arguments.length?(u&&(r=e[0],n=e[1],c&&(r=r[0],n=n[0]),o=[r,n],u.invert&&(r=u(r),n=u(n)),r>n&&(l=r,r=n,n=l),r==f[0]&&n==f[1]||(f=[r,n])),c&&(i=e[0],a=e[1],u&&(i=i[1],a=a[1]),s=[i,a],c.invert&&(i=c(i),a=c(a)),i>a&&(l=i,i=a,a=l),i==h[0]&&a==h[1]||(h=[i,a])),t):(u&&(o?(r=o[0],n=o[1]):(r=f[0],n=f[1],u.invert&&(r=u.invert(r),n=u.invert(n)),r>n&&(l=r,r=n,n=l))),c&&(s?(i=s[0],a=s[1]):(i=h[0],a=h[1],c.invert&&(i=c.invert(i),a=c.invert(a)),i>a&&(l=i,i=a,a=l))),u&&c?[[r,i],[n,a]]:u?[r,n]:c&&[i,a])},t.clear=function(){return t.empty()||(f=[0,0],h=[0,0],o=s=null),t},t.empty=function(){return!!u&&f[0]==f[1]||!!c&&h[0]==h[1]},uo.rebind(t,l,"on")};var Zl={n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},Ql=[["n","e","s","w","nw","ne","se","sw"],["e","w"],["n","s"],[]],$l=vs.format=ws.timeFormat,Kl=$l.utc,Jl=Kl("%Y-%m-%dT%H:%M:%S.%LZ");$l.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?io:Jl,io.parse=function(t){var e=new Date(t);return isNaN(e)?null:e},io.toString=Jl.toString,vs.second=Vt(function(t){return new ms(1e3*Math.floor(t/1e3))},function(t,e){t.setTime(t.getTime()+1e3*Math.floor(e))},function(t){return t.getSeconds()}),vs.seconds=vs.second.range,vs.seconds.utc=vs.second.utc.range,vs.minute=Vt(function(t){return new ms(6e4*Math.floor(t/6e4))},function(t,e){t.setTime(t.getTime()+6e4*Math.floor(e))},function(t){return t.getMinutes()}),vs.minutes=vs.minute.range,vs.minutes.utc=vs.minute.utc.range,vs.hour=Vt(function(t){var e=t.getTimezoneOffset()/60;return new ms(36e5*(Math.floor(t/36e5-e)+e))},function(t,e){t.setTime(t.getTime()+36e5*Math.floor(e))},function(t){return t.getHours()}),vs.hours=vs.hour.range,vs.hours.utc=vs.hour.utc.range,vs.month=Vt(function(t){return t=vs.day(t),t.setDate(1),t},function(t,e){t.setMonth(t.getMonth()+e)},function(t){return t.getMonth()}),vs.months=vs.month.range,vs.months.utc=vs.month.utc.range;var tu=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],eu=[[vs.second,1],[vs.second,5],[vs.second,15],[vs.second,30],[vs.minute,1],[vs.minute,5],[vs.minute,15],[vs.minute,30],[vs.hour,1],[vs.hour,3],[vs.hour,6],[vs.hour,12],[vs.day,1],[vs.day,2],[vs.week,1],[vs.month,1],[vs.month,3],[vs.year,1]],ru=$l.multi([[".%L",function(t){return t.getMilliseconds()}],[":%S",function(t){return t.getSeconds()}],["%I:%M",function(t){return t.getMinutes()}],["%I %p",function(t){return t.getHours()}],["%a %d",function(t){return t.getDay()&&1!=t.getDate()}],["%b %d",function(t){return 1!=t.getDate()}],["%B",function(t){return t.getMonth()}],["%Y",Re]]),nu={range:function(t,e,r){return uo.range(Math.ceil(t/r)*r,+e,r).map(oo)},floor:x,ceil:x};eu.year=vs.year,vs.scale=function(){return ao(uo.scale.linear(),eu,ru)};var iu=eu.map(function(t){return[t[0].utc,t[1]]}),au=Kl.multi([[".%L",function(t){return t.getUTCMilliseconds()}],[":%S",function(t){return t.getUTCSeconds()}],["%I:%M",function(t){return t.getUTCMinutes()}],["%I %p",function(t){return t.getUTCHours()}],["%a %d",function(t){return t.getUTCDay()&&1!=t.getUTCDate()}],["%b %d",function(t){return 1!=t.getUTCDate()}],["%B",function(t){return t.getUTCMonth()}],["%Y",Re]]);iu.year=vs.year.utc,vs.scale.utc=function(){return ao(uo.scale.linear(),iu,au)},uo.text=St(function(t){return t.responseText}),uo.json=function(t,e){return Ct(t,"application/json",so,e)},uo.html=function(t,e){return Ct(t,"text/html",lo,e)},uo.xml=St(function(t){return t.responseXML}),"function"==typeof t&&t.amd?(this.d3=uo,t(uo)):"object"==typeof r&&r.exports?r.exports=uo:this.d3=uo}()},{}],63:[function(t,e,r){"use strict";function n(t,e,r){var i=0|t[r];if(0>=i)return[];var a,o=new Array(i);if(r===t.length-1)for(a=0;i>a;++a)o[a]=e;else for(a=0;i>a;++a)o[a]=n(t,e,r+1);return o}function i(t,e){var r,n;for(r=new Array(t),n=0;t>n;++n)r[n]=e;return r}function a(t,e){switch("undefined"==typeof e&&(e=0),typeof t){case"number":if(t>0)return i(0|t,e);break;case"object":if("number"==typeof t.length)return n(t,e,0)}return[]}e.exports=a},{}],64:[function(e,r,n){(function(n,i){(function(){"use strict";function a(t){return"function"==typeof t||"object"==typeof t&&null!==t}function o(t){return"function"==typeof t}function s(t){X=t}function l(t){Q=t}function u(){return function(){n.nextTick(p)}}function c(){return function(){G(p)}}function f(){var t=0,e=new J(p),r=document.createTextNode("");return e.observe(r,{characterData:!0}),function(){r.data=t=++t%2}}function h(){var t=new MessageChannel;return t.port1.onmessage=p,function(){t.port2.postMessage(0)}}function d(){return function(){setTimeout(p,1)}}function p(){for(var t=0;Z>t;t+=2){var e=rt[t],r=rt[t+1];e(r),rt[t]=void 0,rt[t+1]=void 0}Z=0}function g(){try{var t=e,r=t("vertx");return G=r.runOnLoop||r.runOnContext,c()}catch(n){return d()}}function v(t,e){var r=this,n=r._state;if(n===ot&&!t||n===st&&!e)return this;var i=new this.constructor(y),a=r._result;if(n){var o=arguments[n-1];Q(function(){O(n,i,o,a)})}else C(r,i,t,e);return i}function m(t){var e=this;if(t&&"object"==typeof t&&t.constructor===e)return t;var r=new e(y);return E(r,t),r}function y(){}function b(){return new TypeError("You cannot resolve a promise with itself")}function x(){return new TypeError("A promises callback cannot return that same promise.")}function _(t){try{return t.then}catch(e){return lt.error=e,lt}}function w(t,e,r,n){try{t.call(e,r,n)}catch(i){return i}}function A(t,e,r){Q(function(t){var n=!1,i=w(r,e,function(r){n||(n=!0,e!==r?E(t,r):L(t,r))},function(e){n||(n=!0,S(t,e))},"Settle: "+(t._label||" unknown promise"));!n&&i&&(n=!0,S(t,i))},t)}function k(t,e){e._state===ot?L(t,e._result):e._state===st?S(t,e._result):C(e,void 0,function(e){E(t,e)},function(e){S(t,e)})}function M(t,e,r){e.constructor===t.constructor&&r===nt&&constructor.resolve===it?k(t,e):r===lt?S(t,lt.error):void 0===r?L(t,e):o(r)?A(t,e,r):L(t,e)}function E(t,e){t===e?S(t,b()):a(e)?M(t,e,_(e)):L(t,e)}function T(t){t._onerror&&t._onerror(t._result),R(t)}function L(t,e){t._state===at&&(t._result=e,t._state=ot,0!==t._subscribers.length&&Q(R,t))}function S(t,e){t._state===at&&(t._state=st,t._result=e,Q(T,t))}function C(t,e,r,n){var i=t._subscribers,a=i.length;t._onerror=null,i[a]=e,i[a+ot]=r,i[a+st]=n,0===a&&t._state&&Q(R,t)}function R(t){var e=t._subscribers,r=t._state;if(0!==e.length){for(var n,i,a=t._result,o=0;oo;o++)C(n.resolve(t[o]),void 0,e,r);return i}function F(t){var e=this,r=new e(y);return S(r,t),r}function B(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function j(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function U(t){this._id=dt++,this._state=void 0,this._result=void 0,this._subscribers=[],y!==t&&("function"!=typeof t&&B(),this instanceof U?N(this,t):j())}function V(t,e){this._instanceConstructor=t,this.promise=new t(y),Array.isArray(e)?(this._input=e,this.length=e.length,this._remaining=e.length,this._result=new Array(this.length),0===this.length?L(this.promise,this._result):(this.length=this.length||0,this._enumerate(),0===this._remaining&&L(this.promise,this._result))):S(this.promise,this._validationError())}function q(){var t;if("undefined"!=typeof i)t=i;else if("undefined"!=typeof self)t=self;else try{t=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var r=t.Promise;r&&"[object Promise]"===Object.prototype.toString.call(r.resolve())&&!r.cast||(t.Promise=pt)}var H;H=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)};var G,X,Y,W=H,Z=0,Q=function(t,e){rt[Z]=t,rt[Z+1]=e,Z+=2,2===Z&&(X?X(p):Y())},$="undefined"!=typeof window?window:void 0,K=$||{},J=K.MutationObserver||K.WebKitMutationObserver,tt="undefined"!=typeof n&&"[object process]"==={}.toString.call(n),et="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,rt=new Array(1e3);Y=tt?u():J?f():et?h():void 0===$&&"function"==typeof e?g():d();var nt=v,it=m,at=void 0,ot=1,st=2,lt=new I,ut=new I,ct=z,ft=D,ht=F,dt=0,pt=U;U.all=ct,U.race=ft,U.resolve=it,U.reject=ht,U._setScheduler=s,U._setAsap=l,U._asap=Q,U.prototype={constructor:U,then:nt,"catch":function(t){return this.then(null,t)}};var gt=V;V.prototype._validationError=function(){return new Error("Array Methods must be provided an Array")},V.prototype._enumerate=function(){for(var t=this.length,e=this._input,r=0;this._state===at&&t>r;r++)this._eachEntry(e[r],r)},V.prototype._eachEntry=function(t,e){var r=this._instanceConstructor,n=r.resolve;if(n===it){var i=_(t);if(i===nt&&t._state!==at)this._settledAt(t._state,e,t._result);else if("function"!=typeof i)this._remaining--,this._result[e]=t;else if(r===pt){var a=new r(y);M(a,t,i),this._willSettleAt(a,e)}else this._willSettleAt(new r(function(e){e(t)}),e)}else this._willSettleAt(n(t),e)},V.prototype._settledAt=function(t,e,r){var n=this.promise;n._state===at&&(this._remaining--,t===st?S(n,r):this._result[e]=r),0===this._remaining&&L(n,this._result)},V.prototype._willSettleAt=function(t,e){var r=this;C(t,void 0,function(t){r._settledAt(ot,e,t)},function(t){r._settledAt(st,e,t)})};var vt=q,mt={Promise:pt,polyfill:vt};"function"==typeof t&&t.amd?t(function(){return mt}):"undefined"!=typeof r&&r.exports?r.exports=mt:"undefined"!=typeof this&&(this.ES6Promise=mt),vt()}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:15}],65:[function(t,e,r){"use strict";function n(t){for(var e,r=t.length,n=0;r>n;n++)if(e=t.charCodeAt(n),(9>e||e>13)&&32!==e&&133!==e&&160!==e&&5760!==e&&6158!==e&&(8192>e||e>8205)&&8232!==e&&8233!==e&&8239!==e&&8287!==e&&8288!==e&&12288!==e&&65279!==e)return!1;return!0}e.exports=function(t){var e=typeof t;if("string"===e){var r=t;if(t=+t,0===t&&n(r))return!1}else if("number"!==e)return!1;return 1>t-t}},{}],66:[function(t,e,r){"use strict";function n(t,e,r,n,i){this.gl=t,this.type=e,this.handle=r,this.length=n,this.usage=i}function i(t,e,r,n,i,a){var o=i.length*i.BYTES_PER_ELEMENT;if(0>a)return t.bufferData(e,i,n),o;if(o+a>r)throw new Error("gl-buffer: If resizing buffer, must not specify offset");return t.bufferSubData(e,a,i),r}function a(t,e){for(var r=l.malloc(t.length,e),n=t.length,i=0;n>i;++i)r[i]=t[i];return r}function o(t,e){for(var r=1,n=e.length-1;n>=0;--n){if(e[n]!==r)return!1;r*=t[n]}return!0}function s(t,e,r,i){if(r=r||t.ARRAY_BUFFER,i=i||t.DYNAMIC_DRAW,r!==t.ARRAY_BUFFER&&r!==t.ELEMENT_ARRAY_BUFFER)throw new Error("gl-buffer: Invalid type for webgl buffer, must be either gl.ARRAY_BUFFER or gl.ELEMENT_ARRAY_BUFFER");if(i!==t.DYNAMIC_DRAW&&i!==t.STATIC_DRAW&&i!==t.STREAM_DRAW)throw new Error("gl-buffer: Invalid usage for buffer, must be either gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW");var a=t.createBuffer(),o=new n(t,r,a,0,i);return o.update(e),o}var l=t("typedarray-pool"),u=t("ndarray-ops"),c=t("ndarray"),f=["uint8","uint8_clamped","uint16","uint32","int8","int16","int32","float32"],h=n.prototype;h.bind=function(){this.gl.bindBuffer(this.type,this.handle)},h.unbind=function(){this.gl.bindBuffer(this.type,null)},h.dispose=function(){this.gl.deleteBuffer(this.handle)},h.update=function(t,e){if("number"!=typeof e&&(e=-1),this.bind(),"object"==typeof t&&"undefined"!=typeof t.shape){var r=t.dtype;if(f.indexOf(r)<0&&(r="float32"),this.type===this.gl.ELEMENT_ARRAY_BUFFER){var n=gl.getExtension("OES_element_index_uint");r=n&&"uint16"!==r?"uint32":"uint16"}if(r===t.dtype&&o(t.shape,t.stride))0===t.offset&&t.data.length===t.shape[0]?this.length=i(this.gl,this.type,this.length,this.usage,t.data,e):this.length=i(this.gl,this.type,this.length,this.usage,t.data.subarray(t.offset,t.shape[0]),e);else{var s=l.malloc(t.size,r),h=c(s,t.shape);u.assign(h,t),0>e?this.length=i(this.gl,this.type,this.length,this.usage,s,e):this.length=i(this.gl,this.type,this.length,this.usage,s.subarray(0,t.size),e),l.free(s)}}else if(Array.isArray(t)){var d;d=this.type===this.gl.ELEMENT_ARRAY_BUFFER?a(t,"uint16"):a(t,"float32"),0>e?this.length=i(this.gl,this.type,this.length,this.usage,d,e):this.length=i(this.gl,this.type,this.length,this.usage,d.subarray(0,t.length),e),l.free(d)}else if("object"==typeof t&&"number"==typeof t.length)this.length=i(this.gl,this.type,this.length,this.usage,t,e);else{if("number"!=typeof t&&void 0!==t)throw new Error("gl-buffer: Invalid data type");if(e>=0)throw new Error("gl-buffer: Cannot specify offset when resizing buffer");t=0|t,0>=t&&(t=1),this.gl.bufferData(this.type,0|t,this.usage),this.length=t}},e.exports=s},{ndarray:131,"ndarray-ops":130,"typedarray-pool":151}],67:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o,s,l){this.plot=t,this.shader=e,this.fillShader=r,this.pickShader=n,this.positionBuffer=i,this.colorBuffer=a,this.idBuffer=o,this.fillPositionBuffer=s,this.fillColorBuffer=l,this.fillVerts=0,this.xData=[],this.yData=[],this.shape=[0,0],this.bounds=[1/0,1/0,-(1/0),-(1/0)],this.pickOffset=0,this.numVertices=0,this.lineWidth=1}function i(t,e){var r=Math.floor(e);if(0>r)return t[0];if(r>=t.length-1)return t[t.length-1];var n=e-r;return(1-n)*t[r]+n*t[r+1]}function a(t,e){var r=t.gl,i=s(r,p.vertex,p.fragment),a=s(r,p.pickVertex,p.pickFragment),o=s(r,p.fillVertex,p.fragment),u=l(r),c=l(r),f=l(r),h=l(r),d=l(r),g=new n(t,i,o,a,u,c,f,h,d);return g.update(e),t.addObject(g),g}e.exports=a;var o=t("iota-array"),s=t("gl-shader"),l=t("gl-buffer"),u=t("ndarray"),c=t("surface-nets"),f=t("cdt2d"),h=t("clean-pslg"),d=t("binary-search-bounds"),p=t("./lib/shaders"),g=n.prototype,v=[1,0,0,0,0,1,1,0,1,1,0,1];g.draw=function(){var t=[1,0,0,0,1,0,0,0,1],e=[0,0];return function(){var r,n,i=this.plot,a=this.shader,o=this.fillShader,s=this.bounds,l=this.numVertices,u=this.fillVerts,c=i.gl,f=i.viewBox,h=i.dataBox,d=s[2]-s[0],p=s[3]-s[1],g=h[2]-h[0],v=h[3]-h[1];if(t[0]=2*d/g,t[4]=2*p/v,t[6]=2*(s[0]-h[0])/g-1,t[7]=2*(s[1]-h[1])/v-1,e[0]=f[2]-f[0],e[1]=f[3]-f[1],u>0&&(o.bind(),r=o.uniforms,r.viewTransform=t,r.screenShape=e,n=a.attributes,this.fillPositionBuffer.bind(),n.position.pointer(),this.fillColorBuffer.bind(),n.color.pointer(c.UNSIGNED_BYTE,!0),c.drawArrays(c.TRIANGLES,0,u)),l>0){a.bind();var m=this.lineWidth*i.pixelRatio;r=a.uniforms,r.viewTransform=t,r.screenShape=e,r.lineWidth=m,r.pointSize=1e3,n=a.attributes,this.positionBuffer.bind(),n.position.pointer(c.FLOAT,!1,16,0),n.tangent.pointer(c.FLOAT,!1,16,8),this.colorBuffer.bind(),n.color.pointer(c.UNSIGNED_BYTE,!0),c.drawArrays(c.TRIANGLES,0,l),r.lineWidth=0,r.pointSize=m,this.positionBuffer.bind(),n.position.pointer(c.FLOAT,!1,48,0),n.tangent.pointer(c.FLOAT,!1,48,8),this.colorBuffer.bind(),n.color.pointer(c.UNSIGNED_BYTE,!0,12,0),c.drawArrays(c.POINTS,0,l/3)}}}(),g.drawPick=function(){return function(t){return t}}(),g.pick=function(t,e,r){return null},g.update=function(t){function e(t,e,r,n){var i=n-r;return Math.abs(i)<1e-6?e:Math.floor(e)+Math.max(.001,Math.min(.999,(t-r)/i))}t=t||{};var r=t.shape||[0,0],n=t.x||o(r[0]),a=t.y||o(r[1]),s=t.z||new Float32Array(r[0]*r[1]),l=t.levels||[],p=t.levelColors||[],g=this.bounds,m=g[0]=n[0],y=g[1]=a[0],b=g[2]=n[n.length-1],x=g[3]=a[a.length-1];m===b&&(g[2]+=1,b+=1),y===x&&(g[3]+=1,x+=1);var _=1/(b-m),w=1/(x-y);this.xData=n,this.yData=a,this.lineWidth=t.lineWidth||1;for(var A=u(s,r),k=[],M=[],E=[],T=[],L=[[0,0],[r[0]-1,0],[0,r[1]-1],[r[0]-1,r[1]-1]],S=0;S0&&C===l[S-1])){for(var R=c(A,C),I=255*p[4*S]|0,P=255*p[4*S+1]|0,O=255*p[4*S+2]|0,N=255*p[4*S+3]|0,z=R.cells,D=R.positions,F=Array(D.length),B=0;B1)){var q,H=V[0],G=V[1],X=A.get(Math.floor(H),Math.floor(G)),Y=A.get(Math.floor(H),Math.ceil(G)),W=A.get(Math.ceil(H),Math.floor(G)),Z=A.get(Math.ceil(H),Math.ceil(G));0===Math.floor(V[0])&&C>=X!=C>Y?q=[0,e(C,V[1],X,Y)]:Math.ceil(V[0])===r[0]-1&&C>=W!=C>Z?q=[r[0]-1,e(C,V[1],W,Z)]:0===Math.floor(V[1])&&C>=X!=C>W?q=[e(C,V[0],X,W),0]:Math.ceil(V[1])===r[1]-1&&C>=Y!=C>Z&&(q=[e(C,V[0],Y,Z),r[1]-1]),q&&(z.push([B,D.length]),F.push(L.length),D.push(q))}}}for(B=0;BB;++B){var yt=L[gt[B]],bt=i(n,yt[0]),xt=i(a,yt[1]);vt+=yt[0],mt+=yt[1],ht.push(_*(bt-m),w*(xt-y))}vt/=3,mt/=3;var _t=Math.floor(vt),wt=Math.floor(mt),At=vt-_t,kt=mt-wt,Mt=A.get(_t,wt),Et=A.get(_t,wt+1),Tt=A.get(_t+1,wt),Lt=A.get(_t+1,wt+1),St=(1-kt)*((1-At)*Mt+At*Tt)+kt*((1-At)*Et+At*Lt),Ct=d.le(l,St)+1,Rt=255*ct[4*Ct+0]|0,It=255*ct[4*Ct+1]|0,Pt=255*ct[4*Ct+2]|0,Ot=255*ct[4*Ct+3]|0;ft.push(Rt,It,Pt,Ot,Rt,It,Pt,Ot,Rt,It,Pt,Ot),dt+=3}this.fillPositionBuffer.update(new Float32Array(ht)),this.fillColorBuffer.update(new Uint8Array(ft)),this.fillVerts=dt}},g.dispose=function(){this.plot.removeObject(this)}},{"./lib/shaders":68,"binary-search-bounds":69,cdt2d:16,"clean-pslg":23,"gl-buffer":66,"gl-shader":96,"iota-array":123,ndarray:131,"surface-nets":146}],68:[function(t,e,r){"use strict";e.exports={fragment:"precision lowp float;\n#define GLSLIFY 1\nvarying vec4 fragColor;\nvoid main() {\n gl_FragColor = vec4(fragColor.rgb * fragColor.a, fragColor.a);\n}\n",vertex:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec2 tangent;\nattribute vec4 color;\n\nuniform mat3 viewTransform;\nuniform vec2 screenShape;\nuniform float lineWidth;\nuniform float pointSize;\n\nvarying vec4 fragColor;\n\nvoid main() {\n fragColor = color;\n\n vec3 vPosition = viewTransform * vec3(position, 1.0);\n vec2 vTangent = normalize(viewTransform * vec3(tangent, 0)).xy;\n vec2 offset = vec2(vTangent.y, -vTangent.x) / screenShape;\n\n gl_Position = vec4(\n vPosition.xy + offset * lineWidth * vPosition.z,\n 0,\n vPosition.z);\n\n gl_PointSize = pointSize;\n}\n",pickFragment:"precision lowp float;\n#define GLSLIFY 1\nvarying vec4 fragId;\nvoid main() {\n gl_FragColor = fragId;\n}\n",pickVertex:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec4 pickId;\n\nuniform mat3 viewTransform;\nuniform vec4 pickOffset;\n\nvarying vec4 fragId;\n\nvoid main() {\n vec4 id = pickId + pickOffset;\n id.y += floor(id.x / 256.0);\n id.x -= floor(id.x / 256.0) * 256.0;\n\n id.z += floor(id.y / 256.0);\n id.y -= floor(id.y / 256.0) * 256.0;\n\n id.w += floor(id.z / 256.0);\n id.z -= floor(id.z / 256.0) * 256.0;\n\n fragId = id / 255.0;\n\n vec3 vPosition = viewTransform * vec3(position, 1.0);\n gl_Position = vec4(vPosition.xy, 0, vPosition.z);\n}\n",fillVertex:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec4 color;\n\nuniform mat3 viewTransform;\n\nvarying vec4 fragColor;\n\nvoid main() {\n fragColor = color;\n vec3 vPosition = viewTransform * vec3(position, 1.0);\n gl_Position = vec4(vPosition.xy, 0, vPosition.z);\n}\n"}},{}],69:[function(t,e,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],70:[function(t,e,r){"use strict";function n(t,e,r){this.plot=t,this.shader=e,this.buffer=r,this.bounds=[1/0,1/0,-(1/0),-(1/0)],this.numPoints=0,this.color=[0,0,0,1]}function i(t,e){var r=a(t.gl,l.vertex,l.fragment),i=o(t.gl),s=new n(t,r,i);return s.update(e),t.addObject(s),s}var a=t("gl-shader"),o=t("gl-buffer"),s=t("typedarray-pool"),l=t("./lib/shaders");e.exports=i;var u=[[1,0,0,1,0,0],[1,0,0,-1,0,0],[-1,0,0,-1,0,0],[-1,0,0,-1,0,0],[-1,0,0,1,0,0],[1,0,0,1,0,0],[1,0,-1,0,0,1],[1,0,-1,0,0,-1],[1,0,1,0,0,-1],[1,0,1,0,0,-1],[1,0,1,0,0,1],[1,0,-1,0,0,1],[-1,0,-1,0,0,1],[-1,0,-1,0,0,-1],[-1,0,1,0,0,-1],[-1,0,1,0,0,-1],[-1,0,1,0,0,1],[-1,0,-1,0,0,1],[0,1,1,0,0,0],[0,1,-1,0,0,0],[0,-1,-1,0,0,0],[0,-1,-1,0,0,0],[0,1,1,0,0,0],[0,-1,1,0,0,0],[0,1,0,-1,1,0],[0,1,0,-1,-1,0],[0,1,0,1,-1,0],[0,1,0,1,1,0],[0,1,0,-1,1,0],[0,1,0,1,-1,0],[0,-1,0,-1,1,0],[0,-1,0,-1,-1,0],[0,-1,0,1,-1,0],[0,-1,0,1,1,0],[0,-1,0,-1,1,0],[0,-1,0,1,-1,0]],c=n.prototype;c.draw=function(){var t=[1,0,0,0,1,0,0,0,1],e=[1,1];return function(){var r=this.plot,n=this.shader,i=this.buffer,a=this.bounds,o=this.numPoints;if(o){var s=r.gl,l=r.dataBox,c=r.viewBox,f=r.pixelRatio,h=a[2]-a[0],d=a[3]-a[1],p=l[2]-l[0],g=l[3]-l[1];t[0]=2*h/p,t[4]=2*d/g,t[6]=2*(a[0]-l[0])/p-1,t[7]=2*(a[1]-l[1])/g-1;var v=c[2]-c[0],m=c[3]-c[1];e[0]=2*f/v,e[1]=2*f/m,i.bind(),n.bind(),n.uniforms.viewTransform=t,n.uniforms.pixelScale=e,n.uniforms.color=this.color,n.attributes.position.pointer(s.FLOAT,!1,16,0),n.attributes.pixelOffset.pointer(s.FLOAT,!1,16,8),s.drawArrays(s.TRIANGLES,0,o*u.length)}}}(),c.drawPick=function(t){return t},c.pick=function(t,e){return null},c.update=function(t){t=t||{};var e,r,n,i=t.positions||[],a=t.errors||[],o=1;"lineWidth"in t&&(o=+t.lineWidth);var l=5;"capSize"in t&&(l=+t.capSize),this.color=(t.color||[0,0,0,1]).slice();var c=this.bounds=[1/0,1/0,-(1/0),-(1/0)],f=this.numPoints=i.length>>1;for(e=0;f>e;++e)r=i[2*e],n=i[2*e+1],c[0]=Math.min(r,c[0]),c[1]=Math.min(n,c[1]),c[2]=Math.max(r,c[2]),c[3]=Math.max(n,c[3]);c[2]===c[0]&&(c[2]+=1),c[3]===c[1]&&(c[3]+=1);var h=1/(c[2]-c[0]),d=1/(c[3]-c[1]),p=c[0],g=c[1],v=s.mallocFloat32(f*u.length*4),m=0;for(e=0;f>e;++e){r=i[2*e],n=i[2*e+1];for(var y=a[4*e],b=a[4*e+1],x=a[4*e+2],_=a[4*e+3],w=0;wk?k*=y:k>0&&(k*=b),0>M?M*=x:M>0&&(M*=_),v[m++]=h*(r-p+k),v[m++]=d*(n-g+M),v[m++]=o*A[2]+(l+o)*A[4],v[m++]=o*A[3]+(l+o)*A[5]}}this.buffer.update(v),s.free(v)},c.dispose=function(){this.plot.removeObject(this),this.shader.dispose(),this.buffer.dispose()}},{"./lib/shaders":71,"gl-buffer":66,"gl-shader":96,"typedarray-pool":151}],71:[function(t,e,r){e.exports={vertex:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec2 pixelOffset;\n\nuniform mat3 viewTransform;\nuniform vec2 pixelScale;\n\nvoid main() {\n vec3 scrPosition = viewTransform * vec3(position, 1);\n gl_Position = vec4(\n scrPosition.xy + scrPosition.z * pixelScale * pixelOffset,\n 0,\n scrPosition.z);\n}\n",fragment:"precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 color;\n\nvoid main() {\n gl_FragColor = vec4(color.rgb * color.a, color.a);\n}\n"}},{}],72:[function(t,e,r){"use strict";function n(t){var e=t.getParameter(t.FRAMEBUFFER_BINDING),r=t.getParameter(t.RENDERBUFFER_BINDING),n=t.getParameter(t.TEXTURE_BINDING_2D);return[e,r,n]}function i(t,e){t.bindFramebuffer(t.FRAMEBUFFER,e[0]),t.bindRenderbuffer(t.RENDERBUFFER,e[1]),t.bindTexture(t.TEXTURE_2D,e[2])}function a(t,e){var r=t.getParameter(e.MAX_COLOR_ATTACHMENTS_WEBGL);y=new Array(r+1);for(var n=0;r>=n;++n){for(var i=new Array(r),a=0;n>a;++a)i[a]=t.COLOR_ATTACHMENT0+a;for(var a=n;r>a;++a)i[a]=t.NONE;y[n]=i}}function o(t){switch(t){case p:throw new Error("gl-fbo: Framebuffer unsupported");case g:throw new Error("gl-fbo: Framebuffer incomplete attachment");case v:throw new Error("gl-fbo: Framebuffer incomplete dimensions");case m:throw new Error("gl-fbo: Framebuffer incomplete missing attachment");default:throw new Error("gl-fbo: Framebuffer failed for unspecified reason")}}function s(t,e,r,n,i,a){if(!n)return null;var o=d(t,e,r,i,n);return o.magFilter=t.NEAREST,o.minFilter=t.NEAREST,o.mipSamples=1,o.bind(),t.framebufferTexture2D(t.FRAMEBUFFER,a,t.TEXTURE_2D,o.handle,0),o}function l(t,e,r,n,i){var a=t.createRenderbuffer();return t.bindRenderbuffer(t.RENDERBUFFER,a),t.renderbufferStorage(t.RENDERBUFFER,n,e,r),t.framebufferRenderbuffer(t.FRAMEBUFFER,i,t.RENDERBUFFER,a),a}function u(t){var e=n(t.gl),r=t.gl,a=t.handle=r.createFramebuffer(),u=t._shape[0],c=t._shape[1],f=t.color.length,h=t._ext,d=t._useStencil,p=t._useDepth,g=t._colorType;r.bindFramebuffer(r.FRAMEBUFFER,a);for(var v=0;f>v;++v)t.color[v]=s(r,u,c,g,r.RGBA,r.COLOR_ATTACHMENT0+v);0===f?(t._color_rb=l(r,u,c,r.RGBA4,r.COLOR_ATTACHMENT0),h&&h.drawBuffersWEBGL(y[0])):f>1&&h.drawBuffersWEBGL(y[f]);var m=r.getExtension("WEBGL_depth_texture");m?d?t.depth=s(r,u,c,m.UNSIGNED_INT_24_8_WEBGL,r.DEPTH_STENCIL,r.DEPTH_STENCIL_ATTACHMENT):p&&(t.depth=s(r,u,c,r.UNSIGNED_SHORT,r.DEPTH_COMPONENT,r.DEPTH_ATTACHMENT)):p&&d?t._depth_rb=l(r,u,c,r.DEPTH_STENCIL,r.DEPTH_STENCIL_ATTACHMENT):p?t._depth_rb=l(r,u,c,r.DEPTH_COMPONENT16,r.DEPTH_ATTACHMENT):d&&(t._depth_rb=l(r,u,c,r.STENCIL_INDEX,r.STENCIL_ATTACHMENT));var b=r.checkFramebufferStatus(r.FRAMEBUFFER);if(b!==r.FRAMEBUFFER_COMPLETE){t._destroyed=!0,r.bindFramebuffer(r.FRAMEBUFFER,null),r.deleteFramebuffer(t.handle),t.handle=null,t.depth&&(t.depth.dispose(),t.depth=null),t._depth_rb&&(r.deleteRenderbuffer(t._depth_rb),t._depth_rb=null);for(var v=0;vl;++l)this.color[l]=null;this._color_rb=null,this.depth=null,this._depth_rb=null,this._colorType=n,this._useDepth=a,this._useStencil=o;var c=this,f=[0|e,0|r];Object.defineProperties(f,{0:{get:function(){return c._shape[0]},set:function(t){return c.width=t}},1:{get:function(){return c._shape[1]},set:function(t){return c.height=t}}}),this._shapeVector=f,u(this)}function f(t,e,r){if(t._destroyed)throw new Error("gl-fbo: Can't resize destroyed FBO");if(t._shape[0]!==e||t._shape[1]!==r){var a=t.gl,s=a.getParameter(a.MAX_RENDERBUFFER_SIZE);if(0>e||e>s||0>r||r>s)throw new Error("gl-fbo: Can't resize FBO, invalid dimensions");t._shape[0]=e,t._shape[1]=r;for(var l=n(a),u=0;ue||e>o||0>r||r>o)throw new Error("gl-fbo: Parameters are too large for FBO");n=n||{};var s=1;if("color"in n){if(s=Math.max(0|n.color,0),0>s)throw new Error("gl-fbo: Must specify a nonnegative number of colors");if(s>1){if(!i)throw new Error("gl-fbo: Multiple draw buffer extension not supported");if(s>t.getParameter(i.MAX_COLOR_ATTACHMENTS_WEBGL))throw new Error("gl-fbo: Context does not support "+s+" draw buffers")}}var l=t.UNSIGNED_BYTE,u=t.getExtension("OES_texture_float");if(n.float&&s>0){if(!u)throw new Error("gl-fbo: Context does not support floating point textures");l=t.FLOAT}else n.preferFloat&&s>0&&u&&(l=t.FLOAT);var f=!0;"depth"in n&&(f=!!n.depth);var h=!1;return"stencil"in n&&(h=!!n.stencil),new c(t,e,r,l,s,f,h,i)}var d=t("gl-texture2d");e.exports=h;var p,g,v,m,y=null,b=c.prototype;Object.defineProperties(b,{shape:{get:function(){return this._destroyed?[0,0]:this._shapeVector},set:function(t){if(Array.isArray(t)||(t=[0|t,0|t]),2!==t.length)throw new Error("gl-fbo: Shape vector must be length 2");var e=0|t[0],r=0|t[1];return f(this,e,r),[e,r]},enumerable:!1},width:{get:function(){return this._destroyed?0:this._shape[0]},set:function(t){return t=0|t,f(this,t,this._shape[1]),t},enumerable:!1},height:{get:function(){return this._destroyed?0:this._shape[1]},set:function(t){return t=0|t,f(this,this._shape[0],t),t},enumerable:!1}}),b.bind=function(){if(!this._destroyed){var t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,this.handle),t.viewport(0,0,this._shape[0],this._shape[1])}},b.dispose=function(){if(!this._destroyed){this._destroyed=!0;var t=this.gl;t.deleteFramebuffer(this.handle),this.handle=null,this.depth&&(this.depth.dispose(),this.depth=null),this._depth_rb&&(t.deleteRenderbuffer(this._depth_rb),this._depth_rb=null);for(var e=0;eh;++h)e[h]=r>>8*h&255;this.pickOffset=r,i.bind();var d=i.uniforms;d.viewTransform=t,d.pickOffset=e;var p=i.attributes;return this.positionBuffer.bind(),p.position.pointer(),this.idBuffer.bind(),p.pickId.pointer(o.UNSIGNED_BYTE,!1),o.drawArrays(o.TRIANGLES,0,this.numVertices),r+this.shape[0]*this.shape[1]}}(),f.pick=function(t,e,r){var n=this.pickOffset,i=this.shape[0]*this.shape[1];if(n>r||r>=n+i)return null;var a=r-n,o=this.xData,s=this.yData;return{object:this,pointId:a,dataCoord:[o[a%this.shape[0]],s[a/this.shape[0]|0]]}},f.update=function(t){t=t||{};var e=t.shape||[0,0],r=t.x||o(e[0]),n=t.y||o(e[1]),i=t.z||new Float32Array(e[0]*e[1]);this.xData=r,this.yData=n;var l=t.colorLevels||[0],u=t.colorValues||[0,0,0,1],c=l.length,f=this.bounds,d=f[0]=r[0],p=f[1]=n[0],g=f[2]=r[r.length-1],v=f[3]=n[n.length-1],m=1/(g-d),y=1/(v-p),b=e[0]*e[1]*(h.length>>>1);this.numVertices=b;var x=s.mallocUint8(4*b),_=s.mallocFloat32(2*b),w=s.mallocUint32(b),A=e[0],k=e[1];this.shape=[A,k];for(var M=0,E=0;k-1>E;++E)for(var T=y*(n[E]-p),L=y*(n[E+1]-p),S=0;A-1>S;++S)for(var C=m*(r[S]-d),R=m*(r[S+1]-d),I=0;IU)P=u[0],O=u[1],N=u[2],z=u[3];else if(U===c-1)P=u[4*c-4],O=u[4*c-3],N=u[4*c-2],z=u[4*c-1];else{var V=(j-l[U])/(l[U+1]-l[U]),q=1-V,H=4*U,G=4*(U+1);P=q*u[H]+V*u[G],O=q*u[H+1]+V*u[G+1],N=q*u[H+2]+V*u[G+2],z=q*u[H+3]+V*u[G+3]}x[4*M]=255*P,x[4*M+1]=255*O,x[4*M+2]=255*N,x[4*M+3]=255*z,_[2*M]=(1-D)*C+D*R,_[2*M+1]=(1-F)*T+F*L,w[M]=E*A+S,M+=1}this.positionBuffer.update(_),this.colorBuffer.update(x),this.idBuffer.update(w),s.free(_),s.free(x),s.free(w)},f.dispose=function(){this.shader.dispose(),this.pickShader.dispose(),this.positionBuffer.dispose(),this.colorBuffer.dispose(),this.idBuffer.dispose(),this.plot.removeObject(this)}},{"./lib/shaders":74,"binary-search-bounds":75,"gl-buffer":66,"gl-shader":96,"iota-array":123,"typedarray-pool":151}],74:[function(t,e,r){"use strict";e.exports={fragment:"precision lowp float;\n#define GLSLIFY 1\nvarying vec4 fragColor;\nvoid main() {\n gl_FragColor = vec4(fragColor.rgb * fragColor.a, fragColor.a);\n}\n",vertex:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec4 color;\n\nuniform mat3 viewTransform;\n\nvarying vec4 fragColor;\n\nvoid main() {\n vec3 vPosition = viewTransform * vec3(position, 1.0);\n fragColor = color;\n gl_Position = vec4(vPosition.xy, 0, vPosition.z);\n}\n",pickFragment:"precision lowp float;\n#define GLSLIFY 1\nvarying vec4 fragId;\nvoid main() {\n gl_FragColor = fragId;\n}\n",pickVertex:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec4 pickId;\n\nuniform mat3 viewTransform;\nuniform vec4 pickOffset;\n\nvarying vec4 fragId;\n\nvoid main() {\n vec4 id = pickId + pickOffset;\n id.y += floor(id.x / 256.0);\n id.x -= floor(id.x / 256.0) * 256.0;\n\n id.z += floor(id.y / 256.0);\n id.y -= floor(id.y / 256.0) * 256.0;\n\n id.w += floor(id.z / 256.0);\n id.z -= floor(id.z / 256.0) * 256.0;\n\n fragId = id / 255.0;\n\n vec3 vPosition = viewTransform * vec3(position, 1.0);\n gl_Position = vec4(vPosition.xy, 0, vPosition.z);\n}\n"}},{}],75:[function(t,e,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],76:[function(t,e,r){r.lineVertex="precision mediump float;\n#define GLSLIFY 1\n\nfloat inverse_1_0(float m) {\n return 1.0 / m;\n}\n\nmat2 inverse_1_0(mat2 m) {\n return mat2(m[1][1],-m[0][1],\n -m[1][0], m[0][0]) / (m[0][0]*m[1][1] - m[0][1]*m[1][0]);\n}\n\nmat3 inverse_1_0(mat3 m) {\n float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];\n float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];\n float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];\n\n float b01 = a22 * a11 - a12 * a21;\n float b11 = -a22 * a10 + a12 * a20;\n float b21 = a21 * a10 - a11 * a20;\n\n float det = a00 * b01 + a01 * b11 + a02 * b21;\n\n return mat3(b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11),\n b11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10),\n b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)) / det;\n}\n\nmat4 inverse_1_0(mat4 m) {\n float\n a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],\n a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],\n a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],\n a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3],\n\n b00 = a00 * a11 - a01 * a10,\n b01 = a00 * a12 - a02 * a10,\n b02 = a00 * a13 - a03 * a10,\n b03 = a01 * a12 - a02 * a11,\n b04 = a01 * a13 - a03 * a11,\n b05 = a02 * a13 - a03 * a12,\n b06 = a20 * a31 - a21 * a30,\n b07 = a20 * a32 - a22 * a30,\n b08 = a20 * a33 - a23 * a30,\n b09 = a21 * a32 - a22 * a31,\n b10 = a21 * a33 - a23 * a31,\n b11 = a22 * a33 - a23 * a32,\n\n det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\n return mat4(\n a11 * b11 - a12 * b10 + a13 * b09,\n a02 * b10 - a01 * b11 - a03 * b09,\n a31 * b05 - a32 * b04 + a33 * b03,\n a22 * b04 - a21 * b05 - a23 * b03,\n a12 * b08 - a10 * b11 - a13 * b07,\n a00 * b11 - a02 * b08 + a03 * b07,\n a32 * b02 - a30 * b05 - a33 * b01,\n a20 * b05 - a22 * b02 + a23 * b01,\n a10 * b10 - a11 * b08 + a13 * b06,\n a01 * b08 - a00 * b10 - a03 * b06,\n a30 * b04 - a31 * b02 + a33 * b00,\n a21 * b02 - a20 * b04 - a23 * b00,\n a11 * b07 - a10 * b09 - a12 * b06,\n a00 * b09 - a01 * b07 + a02 * b06,\n a31 * b01 - a30 * b03 - a32 * b00,\n a20 * b03 - a21 * b01 + a22 * b00) / det;\n}\n\n\n\nattribute vec2 a, d;\n\nuniform mat3 matrix;\nuniform vec2 screenShape;\nuniform float width;\n\nvarying vec2 direction;\n\nvoid main() {\n vec2 dir = (matrix * vec3(d, 0)).xy;\n vec3 base = matrix * vec3(a, 1);\n vec2 n = 0.5 * width *\n normalize(screenShape.yx * vec2(dir.y, -dir.x)) / screenShape.xy;\n vec2 tangent = normalize(screenShape.xy * dir);\n if(dir.x < 0.0 || (dir.x == 0.0 && dir.y < 0.0)) {\n direction = -tangent;\n } else {\n direction = tangent;\n }\n gl_Position = vec4(base.xy/base.z + n, 0, 1);\n}\n",r.lineFragment="precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 color;\nuniform vec2 screenShape;\nuniform sampler2D dashPattern;\nuniform float dashLength;\n\nvarying vec2 direction;\n\nvoid main() {\n float t = fract(dot(direction, gl_FragCoord.xy) / dashLength);\n vec4 pcolor = color * texture2D(dashPattern, vec2(t, 0.0)).r;\n gl_FragColor = vec4(pcolor.rgb * pcolor.a, pcolor.a);\n}\n",r.mitreVertex="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 p;\n\nuniform mat3 matrix;\nuniform vec2 screenShape;\nuniform float radius;\n\nvoid main() {\n vec3 pp = matrix * vec3(p, 1);\n gl_Position = vec4(pp.xy, 0, pp.z);\n gl_PointSize = radius;\n}\n",r.mitreFragment="precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 color;\n\nvoid main() {\n if(length(gl_PointCoord.xy - 0.5) > 0.25) {\n discard;\n }\n gl_FragColor = vec4(color.rgb, color.a);\n}\n",r.pickVertex="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 a, d;\nattribute vec4 pick0, pick1;\n\nuniform mat3 matrix;\nuniform vec2 screenShape;\nuniform float width;\n\nvarying vec4 pickA, pickB;\n\nfloat inverse_1_0(float m) {\n return 1.0 / m;\n}\n\nmat2 inverse_1_0(mat2 m) {\n return mat2(m[1][1],-m[0][1],\n -m[1][0], m[0][0]) / (m[0][0]*m[1][1] - m[0][1]*m[1][0]);\n}\n\nmat3 inverse_1_0(mat3 m) {\n float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];\n float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];\n float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];\n\n float b01 = a22 * a11 - a12 * a21;\n float b11 = -a22 * a10 + a12 * a20;\n float b21 = a21 * a10 - a11 * a20;\n\n float det = a00 * b01 + a01 * b11 + a02 * b21;\n\n return mat3(b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11),\n b11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10),\n b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)) / det;\n}\n\nmat4 inverse_1_0(mat4 m) {\n float\n a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],\n a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],\n a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],\n a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3],\n\n b00 = a00 * a11 - a01 * a10,\n b01 = a00 * a12 - a02 * a10,\n b02 = a00 * a13 - a03 * a10,\n b03 = a01 * a12 - a02 * a11,\n b04 = a01 * a13 - a03 * a11,\n b05 = a02 * a13 - a03 * a12,\n b06 = a20 * a31 - a21 * a30,\n b07 = a20 * a32 - a22 * a30,\n b08 = a20 * a33 - a23 * a30,\n b09 = a21 * a32 - a22 * a31,\n b10 = a21 * a33 - a23 * a31,\n b11 = a22 * a33 - a23 * a32,\n\n det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\n return mat4(\n a11 * b11 - a12 * b10 + a13 * b09,\n a02 * b10 - a01 * b11 - a03 * b09,\n a31 * b05 - a32 * b04 + a33 * b03,\n a22 * b04 - a21 * b05 - a23 * b03,\n a12 * b08 - a10 * b11 - a13 * b07,\n a00 * b11 - a02 * b08 + a03 * b07,\n a32 * b02 - a30 * b05 - a33 * b01,\n a20 * b05 - a22 * b02 + a23 * b01,\n a10 * b10 - a11 * b08 + a13 * b06,\n a01 * b08 - a00 * b10 - a03 * b06,\n a30 * b04 - a31 * b02 + a33 * b00,\n a21 * b02 - a20 * b04 - a23 * b00,\n a11 * b07 - a10 * b09 - a12 * b06,\n a00 * b09 - a01 * b07 + a02 * b06,\n a31 * b01 - a30 * b03 - a32 * b00,\n a20 * b03 - a21 * b01 + a22 * b00) / det;\n}\n\n\n\nvoid main() {\n vec3 base = matrix * vec3(a, 1);\n vec2 n = width *\n normalize(screenShape.yx * vec2(d.y, -d.x)) / screenShape.xy;\n gl_Position = vec4(base.xy/base.z + n, 0, 1);\n pickA = pick0;\n pickB = pick1;\n}\n",r.pickFragment="precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 pickOffset;\n\nvarying vec4 pickA, pickB;\n\nvoid main() {\n vec4 fragId = vec4(pickA.xyz, 0.0);\n if(pickB.w > pickA.w) {\n fragId.xyz = pickB.xyz;\n }\n\n fragId += pickOffset;\n\n fragId.y += floor(fragId.x / 256.0);\n fragId.x -= floor(fragId.x / 256.0) * 256.0;\n\n fragId.z += floor(fragId.y / 256.0);\n fragId.y -= floor(fragId.y / 256.0) * 256.0;\n\n fragId.w += floor(fragId.z / 256.0);\n fragId.z -= floor(fragId.z / 256.0) * 256.0;\n\n gl_FragColor = fragId / 255.0;\n}\n",r.fillVertex="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 a, d;\n\nuniform mat3 matrix;\nuniform vec2 projectAxis;\nuniform float projectValue;\nuniform float depth;\n\nvoid main() {\n vec3 base = matrix * vec3(a, 1);\n vec2 p = base.xy / base.z;\n if(d.y < 0.0 || (d.y == 0.0 && d.x < 0.0)) {\n if(dot(p, projectAxis) < projectValue) {\n p = p * (1.0 - abs(projectAxis)) + projectAxis * projectValue;\n }\n }\n gl_Position = vec4(p, depth, 1);\n}\n",r.fillFragment="precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 color;\n\nvoid main() {\n gl_FragColor = vec4(color.rgb * color.a, color.a);\n}\n"},{}],77:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o,s){this.plot=t,this.dashPattern=e,this.lineBuffer=r,this.pickBuffer=n,this.lineShader=i,this.mitreShader=a,this.fillShader=o,this.pickShader=s,this.usingDashes=!1,this.bounds=[1/0,1/0,-(1/0),-(1/0)],this.width=1,this.color=[0,0,1,1],this.fill=[!1,!1,!1,!1],this.fillColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.data=null,this.numPoints=0,this.vertCount=0,this.pickOffset=0,this.lodBuffer=[]}function i(t){return t.map(function(t){return t.slice()})}function a(t,e){var r=t.gl,i=s(r),a=s(r),u=l(r,[1,1]),c=o(r,f.lineVertex,f.lineFragment),h=o(r,f.mitreVertex,f.mitreFragment),d=o(r,f.fillVertex,f.fillFragment),p=o(r,f.pickVertex,f.pickFragment),g=new n(t,u,i,a,c,h,d,p);return t.addObject(g),g.update(e),g}e.exports=a;var o=t("gl-shader"),s=t("gl-buffer"),l=t("gl-texture2d"),u=t("ndarray"),c=t("typedarray-pool"),f=t("./lib/shaders"),h=n.prototype;h.draw=function(){var t=[1,0,0,0,1,0,0,0,1],e=[0,0],r=[1,0],n=[-1,0],i=[0,1],a=[0,-1];return function(){var o=this.plot,s=this.color,l=this.width,u=(this.numPoints,this.bounds),c=this.vertCount;if(c){var f=o.gl,h=o.viewBox,d=o.dataBox,p=o.pixelRatio,g=u[2]-u[0],v=u[3]-u[1],m=d[2]-d[0],y=d[3]-d[1],b=h[2]-h[0],x=h[3]-h[1];t[0]=2*g/m,t[4]=2*v/y,t[6]=2*(u[0]-d[0])/m-1,t[7]=2*(u[1]-d[1])/y-1,e[0]=b,e[1]=x;var _=this.lineBuffer;_.bind();var w=this.fill;if(w[0]||w[1]||w[2]||w[3]){var A=this.fillShader;A.bind();var k=A.uniforms;k.matrix=t,k.depth=o.nextDepthValue();var M=A.attributes;M.a.pointer(f.FLOAT,!1,16,0),M.d.pointer(f.FLOAT,!1,16,8),f.depthMask(!0),f.enable(f.DEPTH_TEST);var E=this.fillColor;w[0]&&(k.color=E[0],k.projectAxis=n,k.projectValue=1,f.drawArrays(f.TRIANGLES,0,c)),w[1]&&(k.color=E[1],k.projectAxis=a,k.projectValue=1,f.drawArrays(f.TRIANGLES,0,c)),w[2]&&(k.color=E[2],k.projectAxis=r,k.projectValue=1,f.drawArrays(f.TRIANGLES,0,c)),w[3]&&(k.color=E[3],k.projectAxis=i,k.projectValue=1,f.drawArrays(f.TRIANGLES,0,c)),f.depthMask(!1),f.disable(f.DEPTH_TEST)}var T=this.lineShader;T.bind();var L=T.uniforms;L.matrix=t,L.color=s,L.width=l*p,L.screenShape=e,L.dashPattern=this.dashPattern.bind(),L.dashLength=this.dashLength*p;var S=T.attributes;if(S.a.pointer(f.FLOAT,!1,16,0),S.d.pointer(f.FLOAT,!1,16,8),f.drawArrays(f.TRIANGLES,0,c),l>2&&!this.usingDashes){var C=this.mitreShader;C.bind();var R=C.uniforms;R.matrix=t,R.color=s,R.screenShape=e,R.radius=l*p,C.attributes.p.pointer(f.FLOAT,!1,48,0),f.drawArrays(f.POINTS,0,c/3|0)}}}}(),h.drawPick=function(){var t=[1,0,0,0,1,0,0,0,1],e=[0,0],r=[0,0,0,0];return function(n){var i=this.plot,a=this.pickShader,o=this.lineBuffer,s=this.pickBuffer,l=this.width,u=this.numPoints,c=this.bounds,f=this.vertCount,h=i.gl,d=i.viewBox,p=i.dataBox,g=i.pickPixelRatio,v=c[2]-c[0],m=c[3]-c[1],y=p[2]-p[0],b=p[3]-p[1],x=d[2]-d[0],_=d[3]-d[1];if(this.pickOffset=n,!f)return n+u;t[0]=2*v/y,t[4]=2*m/b,t[6]=2*(c[0]-p[0])/y-1,t[7]=2*(c[1]-p[1])/b-1,e[0]=x,e[1]=_,r[0]=255&n,r[1]=n>>>8&255,r[2]=n>>>16&255,r[3]=n>>>24,a.bind();var w=a.uniforms;w.matrix=t,w.width=l*g,w.pickOffset=r,w.screenShape=e;var A=a.attributes;return o.bind(),A.a.pointer(h.FLOAT,!1,16,0),A.d.pointer(h.FLOAT,!1,16,8),s.bind(),A.pick0.pointer(h.UNSIGNED_BYTE,!1,8,0),A.pick1.pointer(h.UNSIGNED_BYTE,!1,8,4),h.drawArrays(h.TRIANGLES,0,f),n+u}}(),h.pick=function(t,e,r){var n=this.pickOffset,i=this.numPoints;if(n>r||r>=n+i)return null;var a=r-n,o=this.data;return{object:this,pointId:a,dataCoord:[o[2*a],o[2*a+1]]}},h.update=function(t){t=t||{};var e=this.plot.gl;!!t.connectGaps;this.color=(t.color||[0,0,1,1]).slice(),this.width=+(t.width||1),this.fill=(t.fill||[!1,!1,!1,!1]).slice(),this.fillColor=i(t.fillColor||[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]]);for(var r=t.dashes||[1],n=0,a=0;a1,this.dashPattern=l(e,u(o,[n,1,4],[1,0,0])),this.dashPattern.minFilter=e.NEAREST,this.dashPattern.magFilter=e.NEAREST,this.dashLength=n,c.free(o);var d=t.positions;this.data=d;var p=this.bounds;p[0]=p[1]=1/0,p[2]=p[3]=-(1/0);var g=this.numPoints=d.length>>>1;if(0!==g){for(var a=0;g>a;++a){var v=d[2*a],m=d[2*a+1];isNaN(v)||isNaN(m)||(p[0]=Math.min(p[0],v),p[1]=Math.min(p[1],m),p[2]=Math.max(p[2],v),p[3]=Math.max(p[3],m))}p[0]===p[2]&&(p[2]+=1),p[3]===p[1]&&(p[3]+=1);for(var y=c.mallocFloat32(24*(g-1)),b=c.mallocUint32(12*(g-1)),x=y.length,_=b.length,s=g,w=0;s>1;){var A=--s,v=d[2*s],m=d[2*s+1],k=A-1,M=d[2*k],E=d[2*k+1];if(!(isNaN(v)||isNaN(m)||isNaN(M)||isNaN(E))){w+=1,v=(v-p[0])/(p[2]-p[0]),m=(m-p[1])/(p[3]-p[1]),M=(M-p[0])/(p[2]-p[0]),E=(E-p[1])/(p[3]-p[1]);var T=M-v,L=E-m,S=A|1<<24,C=A-1,R=A,I=A-1|1<<24;y[--x]=-L,y[--x]=-T,y[--x]=m,y[--x]=v,b[--_]=S,b[--_]=C,y[--x]=L,y[--x]=T,y[--x]=E,y[--x]=M,b[--_]=R,b[--_]=I,y[--x]=-L,y[--x]=-T,y[--x]=E,y[--x]=M,b[--_]=R,b[--_]=I,y[--x]=L,y[--x]=T,y[--x]=E,y[--x]=M,b[--_]=R,b[--_]=I,y[--x]=-L,y[--x]=-T,y[--x]=m,y[--x]=v,b[--_]=S,b[--_]=C,y[--x]=L,y[--x]=T,y[--x]=m,y[--x]=v,b[--_]=S,b[--_]=C}}this.vertCount=6*w,this.lineBuffer.update(y.subarray(x)),this.pickBuffer.update(b.subarray(_)),c.free(y),c.free(b)}},h.dispose=function(){this.plot.removeObject(this),this.lineBuffer.dispose(),this.pickBuffer.dispose(),this.lineShader.dispose(),this.mitreShader.dispose(),this.fillShader.dispose(),this.pickShader.dispose(),this.dashPattern.dispose()}},{"./lib/shaders":76,"gl-buffer":66,"gl-shader":96,"gl-texture2d":115,ndarray:131,"typedarray-pool":151}],78:[function(t,e,r){function n(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=r+r,s=n+n,l=i+i,u=r*o,c=n*o,f=n*s,h=i*o,d=i*s,p=i*l,g=a*o,v=a*s,m=a*l;return t[0]=1-f-p,t[1]=c+m,t[2]=h-v,t[3]=0,t[4]=c-m,t[5]=1-u-p,t[6]=d+g,t[7]=0,t[8]=h+v,t[9]=d-g,t[10]=1-u-f,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}e.exports=n},{}],79:[function(t,e,r){"use strict";function n(t,e,r){this.plot=t,this.vbo=e,this.shader=r}function i(t){var e=t.gl,r=a(e,[0,0,0,1,1,0,1,1]),i=o(e,s.boxVert,s.lineFrag);return new n(t,r,i)}e.exports=i;var a=t("gl-buffer"),o=t("gl-shader"),s=t("./shaders"),l=n.prototype;l.bind=function(){var t=this.shader;this.vbo.bind(),this.shader.bind(),t.attributes.coord.pointer(),t.uniforms.screenBox=this.plot.screenBox},l.drawBox=function(){var t=[0,0],e=[0,0];return function(r,n,i,a,o){var s=this.plot,l=this.shader,u=s.gl;t[0]=r,t[1]=n,e[0]=i,e[1]=a,l.uniforms.lo=t,l.uniforms.hi=e,l.uniforms.color=o,u.drawArrays(u.TRIANGLE_STRIP,0,4)}}(),l.dispose=function(){this.vbo.dispose(),this.shader.dispose()}},{"./shaders":82,"gl-buffer":66,"gl-shader":96}],80:[function(t,e,r){"use strict";function n(t,e,r,n){this.plot=t,this.vbo=e,this.shader=r,this.tickShader=n,this.ticks=[[],[]]}function i(t,e){return t-e}function a(t){var e=t.gl,r=o(e),i=s(e,u.gridVert,u.gridFrag),a=s(e,u.tickVert,u.gridFrag),l=new n(t,r,i,a);return l}e.exports=a;var o=t("gl-buffer"),s=t("gl-shader"),l=t("binary-search-bounds"),u=t("./shaders"),c=n.prototype;c.draw=function(){var t=[0,0],e=[0,0],r=[0,0];return function(){for(var n=this.plot,i=this.vbo,a=this.shader,o=this.ticks,s=n.gl,l=n._tickBounds,u=n.dataBox,c=n.viewBox,f=n.gridLineWidth,h=n.gridLineColor,d=n.gridLineEnable,p=n.pixelRatio,g=0;2>g;++g){var v=l[g],m=l[g+2],y=m-v,b=.5*(u[g+2]+u[g]),x=u[g+2]-u[g];e[g]=2*y/x,t[g]=2*(v-b)/x}a.bind(),i.bind(),a.attributes.dataCoord.pointer(),a.uniforms.dataShift=t,a.uniforms.dataScale=e;for(var _=0,g=0;2>g;++g){r[0]=r[1]=0,r[g]=1,a.uniforms.dataAxis=r,a.uniforms.lineWidth=f[g]/(c[g+2]-c[g])*p,a.uniforms.color=h[g];var w=6*o[g].length;d[g]&&w&&s.drawArrays(s.TRIANGLES,_,w),_+=w}}}(),c.drawTickMarks=function(){var t=[0,0],e=[0,0],r=[1,0],n=[0,1],a=[0,0],o=[0,0];return function(){for(var s=this.plot,u=this.vbo,c=this.tickShader,f=this.ticks,h=s.gl,d=s._tickBounds,p=s.dataBox,g=s.viewBox,v=s.pixelRatio,m=s.screenBox,y=m[2]-m[0],b=m[3]-m[1],x=g[2]-g[0],_=g[3]-g[1],w=0;2>w;++w){var A=d[w],k=d[w+2],M=k-A,E=.5*(p[w+2]+p[w]),T=p[w+2]-p[w];e[w]=2*M/T,t[w]=2*(A-E)/T}e[0]*=x/y,t[0]*=x/y,e[1]*=_/b,t[1]*=_/b,c.bind(),u.bind(),c.attributes.dataCoord.pointer();var L=c.uniforms;L.dataShift=t,L.dataScale=e;var S=s.tickMarkLength,C=s.tickMarkWidth,R=s.tickMarkColor,I=0,P=6*f[0].length,O=Math.min(l.ge(f[0],(p[0]-d[0])/(d[2]-d[0]),i),f[0].length),N=Math.min(l.gt(f[0],(p[2]-d[0])/(d[2]-d[0]),i),f[0].length),z=I+6*O,D=6*Math.max(0,N-O),F=Math.min(l.ge(f[1],(p[1]-d[1])/(d[3]-d[1]),i),f[1].length),B=Math.min(l.gt(f[1],(p[3]-d[1])/(d[3]-d[1]),i),f[1].length),j=P+6*F,U=6*Math.max(0,B-F);a[0]=2*(g[0]-S[1])/y-1,a[1]=(g[3]+g[1])/b-1,o[0]=S[1]*v/y,o[1]=C[1]*v/b,U&&(L.color=R[1],L.tickScale=o,L.dataAxis=n,L.screenOffset=a,h.drawArrays(h.TRIANGLES,j,U)),a[0]=(g[2]+g[0])/y-1,a[1]=2*(g[1]-S[0])/b-1,o[0]=C[0]*v/y,o[1]=S[0]*v/b,D&&(L.color=R[0],L.tickScale=o,L.dataAxis=r,L.screenOffset=a,h.drawArrays(h.TRIANGLES,z,D)),a[0]=2*(g[2]+S[3])/y-1,a[1]=(g[3]+g[1])/b-1,o[0]=S[3]*v/y,o[1]=C[3]*v/b,U&&(L.color=R[3],L.tickScale=o,L.dataAxis=n,L.screenOffset=a,h.drawArrays(h.TRIANGLES,j,U)),a[0]=(g[2]+g[0])/y-1,a[1]=2*(g[3]+S[2])/b-1,o[0]=C[2]*v/y,o[1]=S[2]*v/b,D&&(L.color=R[2],L.tickScale=o,L.dataAxis=r,L.screenOffset=a,h.drawArrays(h.TRIANGLES,z,D))}}(),c.update=function(){var t=[1,1,-1,-1,1,-1],e=[1,-1,1,1,-1,-1];return function(r){for(var n=r.ticks,i=r.bounds,a=new Float32Array(18*(n[0].length+n[1].length)),o=(this.plot.zeroLineEnable,0),s=[[],[]],l=0;2>l;++l)for(var u=s[l],c=n[l],f=i[l],h=i[l+2],d=0;dg;++g)a[o++]=p,a[o++]=t[g],a[o++]=e[g]}this.ticks=s,this.vbo.update(a)}}(),c.dispose=function(){this.vbo.dispose(),this.shader.dispose(),this.tickShader.dispose()}},{"./shaders":82,"binary-search-bounds":84,"gl-buffer":66,"gl-shader":96}],81:[function(t,e,r){"use strict";function n(t,e,r){this.plot=t,this.vbo=e,this.shader=r}function i(t){var e=t.gl,r=a(e,[-1,-1,-1,1,1,-1,1,1]),i=o(e,s.lineVert,s.lineFrag),l=new n(t,r,i);return l}e.exports=i;var a=t("gl-buffer"),o=t("gl-shader"),s=t("./shaders"),l=n.prototype;l.bind=function(){var t=this.shader;this.vbo.bind(),this.shader.bind(),t.attributes.coord.pointer(),t.uniforms.screenBox=this.plot.screenBox},l.drawLine=function(){var t=[0,0],e=[0,0];return function(r,n,i,a,o,s){var l=this.plot,u=this.shader,c=l.gl;t[0]=r,t[1]=n,e[0]=i,e[1]=a,u.uniforms.start=t,u.uniforms.end=e,u.uniforms.width=o*l.pixelRatio,u.uniforms.color=s,c.drawArrays(c.TRIANGLE_STRIP,0,4)}}(),l.dispose=function(){this.vbo.dispose(),this.shader.dispose()}},{"./shaders":82,"gl-buffer":66,"gl-shader":96}],82:[function(t,e,r){"use strict";var n="precision lowp float;\n#define GLSLIFY 1\nuniform vec4 color;\nvoid main() {\n gl_FragColor = vec4(color.xyz * color.w, color.w);\n}\n";e.exports={lineVert:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 coord;\n\nuniform vec4 screenBox;\nuniform vec2 start, end;\nuniform float width;\n\nvec2 perp(vec2 v) {\n return vec2(v.y, -v.x);\n}\n\nvec2 screen(vec2 v) {\n return 2.0 * (v - screenBox.xy) / (screenBox.zw - screenBox.xy) - 1.0;\n}\n\nvoid main() {\n vec2 delta = normalize(perp(start - end));\n vec2 offset = mix(start, end, 0.5 * (coord.y+1.0));\n gl_Position = vec4(screen(offset + 0.5 * width * delta * coord.x), 0, 1);\n}\n",lineFrag:n,textVert:"#define GLSLIFY 1\nattribute vec3 textCoordinate;\n\nuniform vec2 dataScale, dataShift, dataAxis, screenOffset, textScale;\nuniform float angle;\n\nvoid main() {\n float dataOffset = textCoordinate.z;\n vec2 glyphOffset = textCoordinate.xy;\n mat2 glyphMatrix = mat2(cos(angle), sin(angle), -sin(angle), cos(angle));\n vec2 screenCoordinate = dataAxis * (dataScale * dataOffset + dataShift) +\n glyphMatrix * glyphOffset * textScale + screenOffset;\n gl_Position = vec4(screenCoordinate, 0, 1);\n}\n",textFrag:n,gridVert:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 dataCoord;\n\nuniform vec2 dataAxis, dataShift, dataScale;\nuniform float lineWidth;\n\nvoid main() {\n vec2 pos = dataAxis * (dataScale * dataCoord.x + dataShift);\n pos += 10.0 * dataCoord.y * vec2(dataAxis.y, -dataAxis.x) + dataCoord.z * lineWidth;\n gl_Position = vec4(pos, 0, 1);\n}\n",gridFrag:n,boxVert:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 coord;\n\nuniform vec4 screenBox;\nuniform vec2 lo, hi;\n\nvec2 screen(vec2 v) {\n return 2.0 * (v - screenBox.xy) / (screenBox.zw - screenBox.xy) - 1.0;\n}\n\nvoid main() {\n gl_Position = vec4(screen(mix(lo, hi, coord)), 0, 1);\n}\n",tickVert:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 dataCoord;\n\nuniform vec2 dataAxis, dataShift, dataScale, screenOffset, tickScale;\n\nvoid main() {\n vec2 pos = dataAxis * (dataScale * dataCoord.x + dataShift);\n gl_Position = vec4(pos + tickScale*dataCoord.yz + screenOffset, 0, 1);\n}\n"}},{}],83:[function(t,e,r){"use strict";function n(t,e,r){this.plot=t,this.vbo=e,this.shader=r,this.tickOffset=[[],[]],this.tickX=[[],[]],this.labelOffset=[0,0],this.labelCount=[0,0]}function i(t){var e=t.gl,r=a(e),i=o(e,u.textVert,u.textFrag),s=new n(t,r,i);return s}e.exports=i;var a=t("gl-buffer"),o=t("gl-shader"),s=t("text-cache"),l=t("binary-search-bounds"),u=t("./shaders"),c=n.prototype;c.drawTicks=function(){var t=[0,0],e=[0,0],r=[0,0];return function(n){var i=this.plot,a=this.shader,o=this.tickX[n],s=this.tickOffset[n],u=i.gl,c=i.viewBox,f=i.dataBox,h=i.screenBox,d=i.pixelRatio,p=i.tickEnable,g=i.tickPad,v=i.tickColor,m=i.tickAngle,y=(i.tickMarkLength,i.labelEnable),b=i.labelPad,x=i.labelColor,_=i.labelAngle,w=this.labelOffset[n],A=this.labelCount[n],k=l.lt(o,f[n]),M=l.le(o,f[n+2]);t[0]=t[1]=0,t[n]=1,e[n]=(c[2+n]+c[n])/(h[2+n]-h[n])-1;var E=2/h[2+(1^n)]-h[1^n];e[1^n]=E*c[1^n]-1,p[n]&&(e[1^n]-=E*d*g[n],M>k&&s[M]>s[k]&&(a.uniforms.dataAxis=t,a.uniforms.screenOffset=e,a.uniforms.color=v[n],a.uniforms.angle=m[n],u.drawArrays(u.TRIANGLES,s[k],s[M]-s[k]))),y[n]&&A&&(e[1^n]-=E*d*b[n],a.uniforms.dataAxis=r,a.uniforms.screenOffset=e,a.uniforms.color=x[n],a.uniforms.angle=_[n],u.drawArrays(u.TRIANGLES,w,A)),e[1^n]=E*c[2+(1^n)]-1,p[n+2]&&(e[1^n]+=E*d*g[n+2],M>k&&s[M]>s[k]&&(a.uniforms.dataAxis=t,a.uniforms.screenOffset=e,a.uniforms.color=v[n+2],a.uniforms.angle=m[n+2],u.drawArrays(u.TRIANGLES,s[k],s[M]-s[k]))),y[n+2]&&A&&(e[1^n]+=E*d*b[n+2],a.uniforms.dataAxis=r,a.uniforms.screenOffset=e,a.uniforms.color=x[n+2],a.uniforms.angle=_[n+2],u.drawArrays(u.TRIANGLES,w,A))}}(),c.drawTitle=function(){var t=[0,0],e=[0,0];return function(){var r=this.plot,n=this.shader,i=r.gl,a=r.screenBox,o=r.titleCenter,s=r.titleAngle,l=r.titleColor,o=r.titleCenter,u=r.pixelRatio;if(this.titleCount){for(var c=0;2>c;++c)e[c]=2*(o[c]*u-a[c])/(a[2+c]-a[c])-1;n.bind(),n.uniforms.dataAxis=t,n.uniforms.screenOffset=e,n.uniforms.angle=s,n.uniforms.color=l,i.drawArrays(i.TRIANGLES,this.titleOffset,this.titleCount)}}}(),c.bind=function(){var t=[0,0],e=[0,0],r=[0,0];return function(){var n=this.plot,i=this.shader,a=n._tickBounds,o=n.dataBox,s=n.screenBox,l=n.viewBox;i.bind();for(var u=0;2>u;++u){var c=a[u],f=a[u+2],h=f-c,d=.5*(o[u+2]+o[u]),p=o[u+2]-o[u],g=l[u],v=l[u+2],m=v-g,y=s[u],b=s[u+2],x=b-y;e[u]=2*h/p*m/x,t[u]=2*(c-d)/p*m/x}r[1]=2*n.pixelRatio/(s[3]-s[1]),r[0]=r[1]*(s[3]-s[1])/(s[2]-s[0]),i.uniforms.dataScale=e,i.uniforms.dataShift=t,i.uniforms.textScale=r,this.vbo.bind(),i.attributes.textCoordinate.pointer()}}(),c.update=function(t){for(var e=[],r=t.ticks,n=t.bounds,i=0;2>i;++i){for(var a=[Math.floor(e.length/3)],o=[-(1/0)],l=r[i],u=0;ui;++i){this.labelOffset[i]=Math.floor(e.length/3);for(var g=s(t.labelFont[i],t.labels[i]).data,p=t.labelSize[i],u=0;up;++p)if(f[p]&&n[p]<=0&&n[p+2]>=0){var g=e[p]-n[p]*(e[p+2]-e[p])/(n[p+2]-n[p]);0===p?o.drawLine(g,e[1],g,e[3],d[p],h[p]):o.drawLine(e[0],g,e[2],g,d[p],h[p])}}for(var p=0;pp;++p)s.drawTicks(p);this.titleEnable&&s.drawTitle();for(var b=this.overlays,p=0;pu;++u){var c=s[u].slice(0);0!==c.length&&(c.sort(a),l[u]=Math.min(l[u],c[0].x),l[u+2]=Math.max(l[u+2],c[c.length-1].x))}this.grid.update({bounds:l,ticks:s}),this.text.update({bounds:l,ticks:s,labels:t.labels||["x","y"],labelSize:t.labelSize||[12,12],labelFont:t.labelFont||["sans-serif","sans-serif"],title:t.title||"",titleSize:t.titleSize||18,titleFont:t.titleFont||"sans-serif"}),this.setDirty()},h.dispose=function(){this.box.dispose(),this.grid.dispose(),this.text.dispose(),this.line.dispose();for(var t=this.objects.length-1;t>=0;--t)this.objects[t].dispose();this.objects.length=0;for(var t=this.overlays.length-1;t>=0;--t)this.overlays[t].dispose();this.overlays.length=0,this.gl=null},h.addObject=function(t){this.objects.indexOf(t)<0&&(this.objects.push(t),this.setDirty())},h.removeObject=function(t){for(var e=this.objects,r=0;ro;++o)i[o]=Math.min(i[o],r[a+o]),i[2+o]=Math.max(i[2+o],r[a+o]);return h[t]={coords:r,normals:n,bounds:i}}function i(t,e,r,n,i,a,o){this.plot=t,this.shader=e,this.pickShader=r,this.positionBuffer=n,this.offsetBuffer=i,this.colorBuffer=a,this.idBuffer=o,this.bounds=[1/0,1/0,-(1/0),-(1/0)],this.numPoints=0,this.numVertices=0,this.pickOffset=0,this.points=null}function a(t,e){var r=t.gl,n=o(r,f.vertex,f.fragment),a=o(r,f.pickVertex,f.pickFragment),l=s(r),u=s(r),c=s(r),h=s(r),d=new i(t,n,a,l,u,c,h);return d.update(e),t.addObject(d),d}e.exports=a;var o=t("gl-shader"),s=t("gl-buffer"),l=t("text-cache"),u=t("typedarray-pool"),c=t("vectorize-text"),f=t("./lib/shaders"),h={},d=i.prototype;!function(){function t(){var t=this.plot,n=this.bounds,i=t.viewBox,a=t.dataBox,o=t.pixelRatio,s=n[2]-n[0],l=n[3]-n[1],u=a[2]-a[0],c=a[3]-a[1];e[0]=2*s/u,e[4]=2*l/c,e[6]=2*(n[0]-a[0])/u-1,e[7]=2*(n[1]-a[1])/c-1;var f=i[2]-i[0],h=i[3]-i[1];r[0]=2*o/f,r[1]=2*o/h}var e=[1,0,0,0,1,0,0,0,1],r=[1,1];d.draw=function(){var n=this.plot,i=this.shader,a=this.numVertices;if(a){var o=n.gl;t.call(this),i.bind(),i.uniforms.pixelScale=r,i.uniforms.viewTransform=e,this.positionBuffer.bind(),i.attributes.position.pointer(),this.offsetBuffer.bind(),i.attributes.offset.pointer(),this.colorBuffer.bind(),i.attributes.color.pointer(o.UNSIGNED_BYTE,!0),o.drawArrays(o.TRIANGLES,0,a)}};var n=[0,0,0,0];d.drawPick=function(i){var a=this.plot,o=this.pickShader,s=this.numVertices,l=a.gl;if(this.pickOffset=i,!s)return i;for(var u=0;4>u;++u)n[u]=i>>8*u&255;return t.call(this),o.bind(),o.uniforms.pixelScale=r,o.uniforms.viewTransform=e,o.uniforms.pickOffset=n,this.positionBuffer.bind(),o.attributes.position.pointer(),this.offsetBuffer.bind(),o.attributes.offset.pointer(),this.idBuffer.bind(),o.attributes.id.pointer(l.UNSIGNED_BYTE,!1),l.drawArrays(l.TRIANGLES,0,s),i+this.numPoints}}(),d.pick=function(t,e,r){var n=this.pickOffset,i=this.numPoints;if(n>r||r>=n+i)return null;var a=r-n,o=this.points;return{object:this,pointId:a,dataCoord:[o[2*a],o[2*a+1]]}},d.update=function(t){t=t||{};var e=t.positions||[],r=t.colors||[],i=t.glyphs||[],a=t.sizes||[],o=t.borderWidths||[],s=t.borderColors||[];this.points=e;for(var c=this.bounds=[1/0,1/0,-(1/0),-(1/0)],f=0,h=0;h>1;for(var d=0;2>d;++d)c[d]=Math.min(c[d],e[2*h+d]),c[2+d]=Math.max(c[2+d],e[2*h+d])}c[0]===c[2]&&(c[2]+=1),c[3]===c[1]&&(c[3]+=1);for(var p=1/(c[2]-c[0]),g=1/(c[3]-c[1]),v=c[0],m=c[1],y=u.mallocFloat32(2*f),b=u.mallocFloat32(2*f),x=u.mallocUint8(4*f),_=u.mallocUint32(f),w=0,h=0;h=a?i(0,a-1,t,e,r,n):f(0,a-1,t,e,r,n)}function i(t,e,r,n,i,a){for(var o=t+1;e>=o;++o){for(var s=r[o],l=n[2*o],u=n[2*o+1],c=i[o],f=a[o],h=o;h>t;){var d=r[h-1],p=n[2*(h-1)];if((d-s||l-p)>=0)break;r[h]=d,n[2*h]=p,n[2*h+1]=n[2*h-1],i[h]=i[h-1],a[h]=a[h-1],h-=1}r[h]=s,n[2*h]=l,n[2*h+1]=u,i[h]=c,a[h]=f}}function a(t,e,r,n,i,a){var o=r[t],s=n[2*t],l=n[2*t+1],u=i[t],c=a[t];r[t]=r[e],n[2*t]=n[2*e],n[2*t+1]=n[2*e+1],i[t]=i[e],a[t]=a[e],r[e]=o,n[2*e]=s,n[2*e+1]=l,i[e]=u,a[e]=c}function o(t,e,r,n,i,a){r[t]=r[e],n[2*t]=n[2*e],n[2*t+1]=n[2*e+1],i[t]=i[e],a[t]=a[e]}function s(t,e,r,n,i,a,o){var s=n[t],l=i[2*t],u=i[2*t+1],c=a[t],f=o[t];n[t]=n[e],i[2*t]=i[2*e],i[2*t+1]=i[2*e+1],a[t]=a[e],o[t]=o[e],n[e]=n[r],i[2*e]=i[2*r],i[2*e+1]=i[2*r+1],a[e]=a[r],o[e]=o[r],n[r]=s,i[2*r]=l,i[2*r+1]=u,a[r]=c,o[r]=f}function l(t,e,r,n,i,a,o,s,l,u,c){s[t]=s[e],l[2*t]=l[2*e],l[2*t+1]=l[2*e+1],u[t]=u[e],c[t]=c[e],s[e]=r,l[2*e]=n,l[2*e+1]=i,u[e]=a,c[e]=o}function u(t,e,r,n,i){return(r[t]-r[e]||n[2*e]-n[2*t]||i[t]-i[e])<0}function c(t,e,r,n,i,a,o,s){return(e-a[t]||o[2*t]-r||i-s[t])<0}function f(t,e,r,n,d,p){var g=(e-t+1)/6|0,v=t+g,m=e-g,y=t+e>>1,b=y-g,x=y+g,_=v,w=b,A=y,k=x,M=m,E=t+1,T=e-1,L=0;u(_,w,r,n,d,p)&&(L=_,_=w,w=L),u(k,M,r,n,d,p)&&(L=k,k=M,M=L),u(_,A,r,n,d,p)&&(L=_,_=A,A=L),u(w,A,r,n,d,p)&&(L=w,w=A,A=L),u(_,k,r,n,d,p)&&(L=_,_=k,k=L),u(A,k,r,n,d,p)&&(L=A,A=k,k=L),u(w,M,r,n,d,p)&&(L=w,w=M,M=L),u(w,A,r,n,d,p)&&(L=w,w=A,A=L),u(k,M,r,n,d,p)&&(L=k,k=M,M=L);var S=r[w],C=n[2*w],R=n[2*w+1],I=d[w],P=p[w],O=r[k],N=n[2*k],z=n[2*k+1],D=d[k],F=p[k],B=_,j=A,U=M,V=v,q=y,H=m,G=r[B],X=r[j],Y=r[U];r[V]=G,r[q]=X,r[H]=Y;for(var W=0;2>W;++W){var Z=n[2*B+W],Q=n[2*j+W],$=n[2*U+W];n[2*V+W]=Z,n[2*q+W]=Q,n[2*H+W]=$}var K=d[B],J=d[j],tt=d[U];d[V]=K,d[q]=J,d[H]=tt;var et=p[B],rt=p[j],nt=p[U];p[V]=et,p[q]=rt,p[H]=nt,o(b,t,r,n,d,p),o(x,e,r,n,d,p);for(var it=E;T>=it;++it)if(c(it,S,C,R,I,r,n,d))it!==E&&a(it,E,r,n,d,p),++E;else if(!c(it,O,N,z,D,r,n,d))for(;;){if(c(T,O,N,z,D,r,n,d)){c(T,S,C,R,I,r,n,d)?(s(it,E,T,r,n,d,p),++E,--T):(a(it,T,r,n,d,p),--T);break}if(--T=E-2-t?i(t,E-2,r,n,d,p):f(t,E-2,r,n,d,p),h>=e-(T+2)?i(T+2,e,r,n,d,p):f(T+2,e,r,n,d,p),h>=T-E?i(E,T,r,n,d,p):f(E,T,r,n,d,p)}e.exports=n;var h=32},{}],91:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o,s){for(var l=r,u=r;n>u;++u){var c=t[2*u],f=t[2*u+1],h=e[u];c>=i&&o>=c&&f>=a&&s>=f&&(u===l?l+=1:(t[2*u]=t[2*l],t[2*u+1]=t[2*l+1],e[u]=e[l],t[2*l]=c,t[2*l+1]=f,e[l]=h,l+=1))}return l}function i(t,e,r){this.pixelSize=t,this.offset=e,this.count=r}function a(t,e,r,a){function l(i,a,o,s,u,c){var f=.5*o,h=s+1,d=u-s;r[_]=d,x[_++]=c;for(var p=0;2>p;++p)for(var g=0;2>g;++g){var v=i+p*f,m=a+g*f,y=n(t,e,h,u,v,m,v+f,m+f);if(y!==h){if(y-h>=Math.max(.9*d,32)){var b=u+s>>>1;l(v,m,f,h,b,c+1),h=b}l(v,m,f,h,y,c+1),h=y}}}var u=t.length>>>1;if(1>u)return[];for(var c=1/0,f=1/0,h=-(1/0),d=-(1/0),p=0;u>p;++p){var g=t[2*p],v=t[2*p+1];c=Math.min(c,g),h=Math.max(h,g),f=Math.min(f,v),d=Math.max(d,v),e[p]=p}c===h&&(h+=1+Math.abs(h)),f===d&&(d+=1+Math.abs(h));var m=1/(h-c),y=1/(d-f),b=Math.max(h-c,d-f);a=a||[0,0,0,0],a[0]=c,a[1]=f,a[2]=h,a[3]=d;var x=o.mallocInt32(u),_=0;l(c,f,b,0,u,0),s(x,t,e,r,u);for(var w=[],A=0,k=u,_=u-1;_>=0;--_){t[2*_]=(t[2*_]-c)*m,t[2*_+1]=(t[2*_+1]-f)*y;var M=x[_];M!==A&&(w.push(new i(b*Math.pow(.5,M),_+1,k-(_+1))),k=_+1,A=M)}return w.push(new i(b*Math.pow(.5,M+1),0,k)),o.free(x),w}var o=t("typedarray-pool"),s=t("./lib/sort");e.exports=a},{"./lib/sort":90,"typedarray-pool":151}],92:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){this.plot=t,this.offsetBuffer=e,this.pickBuffer=r,this.weightBuffer=n,this.shader=i,this.pickShader=a,this.scales=[],this.size=12,this.borderSize=1,this.pointCount=0,this.color=[1,0,0,1],this.borderColor=[0,0,0,1],this.bounds=[1/0,1/0,-(1/0),-(1/0)],this.pickOffset=0,this.points=null,this.xCoords=null}function i(t,e){var r=t.gl,i=o(r),s=o(r),l=o(r),u=a(r,c.pointVertex,c.pointFragment),f=a(r,c.pickVertex,c.pickFragment),h=new n(t,i,s,l,u,f);return h.update(e),t.addObject(h),h}var a=t("gl-shader"),o=t("gl-buffer"),s=t("binary-search-bounds"),l=t("snap-points-2d"),u=t("typedarray-pool"),c=t("./lib/shader");e.exports=i;var f=n.prototype;f.dispose=function(){this.shader.dispose(),this.pickShader.dispose(),this.offsetBuffer.dispose(),this.pickBuffer.dispose(),this.xCoords&&u.free(this.xCoords),this.plot.removeObject(this)},f.update=function(t){function e(e,r){return e in t?t[e]:r}t=t||{},this.size=e("size",12),this.color=e("color",[1,0,0,1]).slice(),this.borderSize=e("borderSize",1),this.borderColor=e("borderColor",[0,0,0,1]).slice(),this.xCoords&&u.free(this.xCoords);var r=t.positions,n=u.mallocFloat32(r.length),i=u.mallocInt32(r.length>>>1);n.set(r);var a=u.mallocFloat32(r.length);this.points=r,this.scales=l(n,i,a,this.bounds),this.offsetBuffer.update(n),this.pickBuffer.update(i),this.weightBuffer.update(a);for(var o=u.mallocFloat32(r.length>>>1),s=0,c=0;s>>1,this.pickOffset=0},f.drawPick=function(){var t=[1,0,0,0,1,0,0,0,1],e=[0,0,0,0];return function(r){var n=this.plot,i=this.pickShader,a=this.scales,o=this.offsetBuffer,l=this.pickBuffer,u=this.bounds,c=this.size,f=this.borderSize,h=n.gl,d=n.pickPixelRatio,p=n.viewBox,g=n.dataBox;if(0===this.pointCount)return r;var v=u[2]-u[0],m=u[3]-u[1],y=g[2]-g[0],b=g[3]-g[1],x=(p[2]-p[0])*d/n.pixelRatio,_=(p[3]-p[1])*d/n.pixelRatio,w=Math.min(y/x,b/_);t[0]=2*v/y,t[4]=2*m/b,t[6]=2*(u[0]-g[0])/y-1,t[7]=2*(u[1]-g[1])/b-1,this.pickOffset=r,e[0]=255&r,e[1]=r>>8&255,e[2]=r>>16&255,e[3]=r>>24&255,i.bind(),i.uniforms.matrix=t,i.uniforms.color=this.color,i.uniforms.borderColor=this.borderColor,i.uniforms.pointSize=d*(c+f),i.uniforms.pickOffset=e,0===this.borderSize?i.uniforms.centerFraction=2:i.uniforms.centerFraction=c/(c+f+1.25),o.bind(),i.attributes.position.pointer(),l.bind(),i.attributes.pickId.pointer(h.UNSIGNED_BYTE);for(var A=this.xCoords,k=(g[0]-u[0]-w*c*d)/v,M=(g[2]-u[0]+w*c*d)/v,E=a.length-1;E>=0;--E){var T=a[E];if(!(T.pixelSize1)){var L=T.offset,S=T.count+L,C=s.ge(A,k,L,S-1),R=s.lt(A,M,C,S-1)+1;R>C&&h.drawArrays(h.POINTS,C,R-C)}}return r+this.pointCount}}(),f.draw=function(){var t=[1,0,0,0,1,0,0,0,1];return function(){var e=this.plot,r=this.shader,n=this.scales,i=this.offsetBuffer,a=this.bounds,o=this.size,l=this.borderSize,u=e.gl,c=e.pixelRatio,f=e.viewBox,h=e.dataBox;if(0!==this.pointCount){var d=a[2]-a[0],p=a[3]-a[1],g=h[2]-h[0],v=h[3]-h[1],m=f[2]-f[0],y=f[3]-f[1],b=Math.min(g/m,v/y);t[0]=2*d/g,t[4]=2*p/v,t[6]=2*(a[0]-h[0])/g-1,t[7]=2*(a[1]-h[1])/v-1,r.bind(),r.uniforms.matrix=t,r.uniforms.color=this.color,r.uniforms.borderColor=this.borderColor,r.uniforms.pointSize=c*(o+l),r.uniforms.useWeight=1,0===this.borderSize?r.uniforms.centerFraction=2:r.uniforms.centerFraction=o/(o+l+1.25),i.bind(),r.attributes.position.pointer(),this.weightBuffer.bind(),r.attributes.weight.pointer();for(var x=this.xCoords,_=(h[0]-a[0]-b*o*c)/d,w=(h[2]-a[0]+b*o*c)/d,A=!0,k=n.length-1;k>=0;--k){var M=n[k];if(!(M.pixelSize1)){var E=M.offset,T=M.count+E,L=s.ge(x,_,E,T-1),S=s.lt(x,w,L,T-1)+1;S>L&&u.drawArrays(u.POINTS,L,S-L),A&&(A=!1,r.uniforms.useWeight=0)}}}}}(),f.pick=function(t,e,r){var n=this.pickOffset,i=this.pointCount;if(n>r||r>=n+i)return null;var a=r-n,o=this.points;return{object:this,pointId:a,dataCoord:[o[2*a],o[2*a+1]]}}},{"./lib/shader":88,"binary-search-bounds":89,"gl-buffer":66,"gl-shader":96,"snap-points-2d":91,"typedarray-pool":151}],93:[function(t,e,r){"use strict";r.boxVertex="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 vertex;\n\nuniform vec2 cornerA, cornerB;\n\nvoid main() {\n gl_Position = vec4(mix(cornerA, cornerB, vertex), 0, 1);\n}\n",r.boxFragment="precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 color;\n\nvoid main() {\n gl_FragColor = color;\n}\n"},{}],94:[function(t,e,r){"use strict";function n(t,e,r){this.plot=t,this.boxBuffer=e,this.boxShader=r,this.enabled=!0,this.selectBox=[1/0,1/0,-(1/0),-(1/0)],this.borderColor=[0,0,0,1],this.innerFill=!1,this.innerColor=[0,0,0,.25],this.outerFill=!0,this.outerColor=[0,0,0,.5],this.borderWidth=10}function i(t,e){var r=t.gl,i=o(r,[0,0,0,1,1,0,1,1]),l=a(r,s.boxVertex,s.boxFragment),u=new n(t,i,l);return u.update(e),t.addOverlay(u),u}var a=t("gl-shader"),o=t("gl-buffer"),s=t("./lib/shaders");e.exports=i;var l=n.prototype;l.draw=function(){if(this.enabled){var t=this.plot,e=this.selectBox,r=this.borderWidth,n=(this.innerFill,this.innerColor),i=(this.outerFill,this.outerColor),a=this.borderColor,o=t.box,s=t.screenBox,l=t.dataBox,u=t.viewBox,c=t.pixelRatio,f=(e[0]-l[0])*(u[2]-u[0])/(l[2]-l[0])+u[0],h=(e[1]-l[1])*(u[3]-u[1])/(l[3]-l[1])+u[1],d=(e[2]-l[0])*(u[2]-u[0])/(l[2]-l[0])+u[0],p=(e[3]-l[1])*(u[3]-u[1])/(l[3]-l[1])+u[1];if(f=Math.max(f,u[0]),h=Math.max(h,u[1]),d=Math.min(d,u[2]),p=Math.min(p,u[3]),!(f>d||h>p)){o.bind();var g=s[2]-s[0],v=s[3]-s[1];if(this.outerFill&&(o.drawBox(0,0,g,h,i),o.drawBox(0,h,f,p,i),o.drawBox(0,p,g,v,i),o.drawBox(d,h,g,p,i)),this.innerFill&&o.drawBox(f,h,d,p,n),r>0){var m=r*c;o.drawBox(f-m,h-m,d+m,h+m,a),o.drawBox(f-m,p-m,d+m,p+m,a),o.drawBox(f-m,h-m,f+m,p+m,a),o.drawBox(d-m,h-m,d+m,p+m,a)}}}},l.update=function(t){t=t||{},this.innerFill=!!t.innerFill,this.outerFill=!!t.outerFill,this.innerColor=(t.innerColor||[0,0,0,.5]).slice(),this.outerColor=(t.outerColor||[0,0,0,.5]).slice(),this.borderColor=(t.borderColor||[0,0,0,1]).slice(),this.borderWidth=t.borderWidth||0,this.selectBox=(t.selectBox||this.selectBox).slice()},l.dispose=function(){this.boxBuffer.dispose(),this.boxShader.dispose(),this.plot.removeOverlay(this)}},{"./lib/shaders":93,"gl-buffer":66,"gl-shader":96}],95:[function(t,e,r){"use strict";function n(t,e,r,n,i){this.coord=[t,e],this.id=r,this.value=n,this.distance=i}function i(t,e,r){this.gl=t,this.fbo=e,this.buffer=r,this._readTimeout=null;var n=this;this._readCallback=function(){n.gl&&(e.bind(),t.readPixels(0,0,e.shape[0],e.shape[1],t.RGBA,t.UNSIGNED_BYTE,n.buffer),n._readTimeout=null)}}function a(t,e){var r=o(t,e),n=s.mallocUint8(e[0]*e[1]*4);return new i(t,r,n)}e.exports=a;var o=t("gl-fbo"),s=t("typedarray-pool"),l=t("ndarray"),u=t("bit-twiddle").nextPow2,c=t("cwise/lib/wrapper")({args:["array",{offset:[0,0,1],array:0},{offset:[0,0,2],array:0},{offset:[0,0,3],array:0},"scalar","scalar","index"],pre:{body:"{this_closestD2=1e8,this_closestX=-1,this_closestY=-1}",args:[],thisVars:["this_closestD2","this_closestX","this_closestY"],localVars:[]},body:{body:"{if(255>_inline_52_arg0_||255>_inline_52_arg1_||255>_inline_52_arg2_||255>_inline_52_arg3_){var _inline_52_l=_inline_52_arg4_-_inline_52_arg6_[0],_inline_52_a=_inline_52_arg5_-_inline_52_arg6_[1],_inline_52_f=_inline_52_l*_inline_52_l+_inline_52_a*_inline_52_a;_inline_52_fthis.buffer.length){s.free(this.buffer);for(var n=this.buffer=s.mallocUint8(u(r*e*4)),i=0;r*e*4>i;++i)n[i]=255}return t}}}),f.begin=function(){var t=this.gl;this.shape;t&&(this.fbo.bind(),t.clearColor(1,1,1,1),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT))},f.end=function(){var t=this.gl;t&&(t.bindFramebuffer(t.FRAMEBUFFER,null),this._readTimeout||clearTimeout(this._readTimeout),this._readTimeout=setTimeout(this._readCallback,1))},f.query=function(t,e,r){if(!this.gl)return null;var i=this.fbo.shape.slice();t=0|t,e=0|e,"number"!=typeof r&&(r=1);var a=0|Math.min(Math.max(t-r,0),i[0]),o=0|Math.min(Math.max(t+r,0),i[0]),s=0|Math.min(Math.max(e-r,0),i[1]),u=0|Math.min(Math.max(e+r,0),i[1]);if(a>=o||s>=u)return null;var f=[o-a,u-s],h=l(this.buffer,[f[0],f[1],4],[4,4*i[0],1],4*(a+i[0]*s)),d=c(h.hi(f[0],f[1],1),r,r),p=d[0],g=d[1];if(0>p||Math.pow(this.radius,2)=0){for(var k=0|A.type.charAt(A.type.length-1),M=new Array(k),E=0;k>E;++E)M[E]=_.length,x.push(A.name+"["+E+"]"),"number"==typeof A.location?_.push(A.location+E):Array.isArray(A.location)&&A.location.length===k&&"number"==typeof A.location[E]?_.push(0|A.location[E]):_.push(-1);b.push({name:A.name,type:A.type,locations:M})}else b.push({name:A.name,type:A.type,locations:[_.length]}),x.push(A.name),"number"==typeof A.location?_.push(0|A.location):_.push(-1)}for(var T=0,w=0;w<_.length;++w)if(_[w]<0){for(;_.indexOf(T)>=0;)T+=1;_[w]=T}var L=new Array(r.length);a(),d._relink=a,d.types={uniforms:l(r),attributes:l(n)},d.attributes=s(p,d,b,_),Object.defineProperty(d,"uniforms",o(p,d,r,L))},e.exports=a},{"./lib/GLError":97,"./lib/create-attributes":98,"./lib/create-uniforms":99,"./lib/reflect":100,"./lib/runtime-reflect":101,"./lib/shader-cache":102}],97:[function(t,e,r){function n(t,e,r){this.shortMessage=e||"",this.longMessage=r||"",this.rawError=t||"",this.message="gl-shader: "+(e||t||"")+(r?"\n"+r:""),this.stack=(new Error).stack}n.prototype=new Error,n.prototype.name="GLError",n.prototype.constructor=n,e.exports=n},{}],98:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){this._gl=t,this._wrapper=e,this._index=r,this._locations=n,this._dimension=i,this._constFunc=a}function i(t,e,r,i,a,o,s){for(var l=["gl","v"],u=[],c=0;a>c;++c)l.push("x"+c),u.push("x"+c);l.push("if(x0.length===void 0){return gl.vertexAttrib"+a+"f(v,"+u.join()+")}else{return gl.vertexAttrib"+a+"fv(v,x0)}");var f=Function.apply(null,l),h=new n(t,e,r,i,a,f);Object.defineProperty(o,s,{set:function(e){return t.disableVertexAttribArray(i[r]),f(t,i[r],e),e},get:function(){return h},enumerable:!0})}function a(t,e,r,n,a,o,s){for(var l=new Array(a),u=new Array(a),c=0;a>c;++c)i(t,e,r[c],n,a,l,c),u[c]=l[c];Object.defineProperty(l,"location",{set:function(t){if(Array.isArray(t))for(var e=0;a>e;++e)u[e].location=t[e];else for(var e=0;a>e;++e)u[e].location=t+e;return t},get:function(){for(var t=new Array(a),e=0;a>e;++e)t[e]=n[r[e]];return t},enumerable:!0}),l.pointer=function(e,i,o,s){e=e||t.FLOAT,i=!!i,o=o||a*a,s=s||0;for(var l=0;a>l;++l){var u=n[r[l]];t.vertexAttribPointer(u,a,e,i,o,s+l*a),t.enableVertexAttribArray(u)}};var f=new Array(a),h=t["vertexAttrib"+a+"fv"];Object.defineProperty(o,s,{set:function(e){for(var i=0;a>i;++i){var o=n[r[i]];if(t.disableVertexAttribArray(o),Array.isArray(e[0]))h.call(t,o,e[i]);else{for(var s=0;a>s;++s)f[s]=e[a*i+s];h.call(t,o,f)}}return e},get:function(){return l},enumerable:!0})}function o(t,e,r,n){for(var o={},l=0,u=r.length;u>l;++l){var c=r[l],f=c.name,h=c.type,d=c.locations;switch(h){case"bool":case"int":case"float":i(t,e,d[0],n,1,o,f);break;default:if(h.indexOf("vec")>=0){var p=h.charCodeAt(h.length-1)-48;if(2>p||p>4)throw new s("","Invalid data type for attribute "+f+": "+h);i(t,e,d[0],n,p,o,f)}else{if(!(h.indexOf("mat")>=0))throw new s("","Unknown data type for attribute "+f+": "+h);var p=h.charCodeAt(h.length-1)-48;if(2>p||p>4)throw new s("","Invalid data type for attribute "+f+": "+h);a(t,e,d,n,p,o,f)}}}return o}e.exports=o;var s=t("./GLError"),l=n.prototype;l.pointer=function(t,e,r,n){var i=this,a=i._gl,o=i._locations[i._index];a.vertexAttribPointer(o,i._dimension,t||a.FLOAT,!!e,r||0,n||0),a.enableVertexAttribArray(o)},l.set=function(t,e,r,n){return this._constFunc(this._locations[this._index],t,e,r,n)},Object.defineProperty(l,"location",{get:function(){return this._locations[this._index]},set:function(t){return t!==this._locations[this._index]&&(this._locations[this._index]=0|t,this._wrapper.program=null),0|t}})},{"./GLError":97}],99:[function(t,e,r){"use strict";function n(t){var e=new Function("y","return function(){return y}");return e(t)}function i(t,e){for(var r=new Array(t),n=0;t>n;++n)r[n]=e;return r}function a(t,e,r,a){function l(r){var n=new Function("gl","wrapper","locations","return function(){return gl.getUniform(wrapper.program,locations["+r+"])}");return n(t,e,a)}function u(t,e,r){switch(r){case"bool":case"int":case"sampler2D":case"samplerCube":return"gl.uniform1i(locations["+e+"],obj"+t+")";case"float":return"gl.uniform1f(locations["+e+"],obj"+t+")";default:var n=r.indexOf("vec");if(!(n>=0&&1>=n&&r.length===4+n)){if(0===r.indexOf("mat")&&4===r.length){var i=r.charCodeAt(r.length-1)-48;if(2>i||i>4)throw new s("","Invalid uniform dimension type for matrix "+name+": "+r);return"gl.uniformMatrix"+i+"fv(locations["+e+"],false,obj"+t+")"}throw new s("","Unknown uniform data type for "+name+": "+r)}var i=r.charCodeAt(r.length-1)-48; +-if(2>i||i>4)throw new s("","Invalid data type");switch(r.charAt(0)){case"b":case"i":return"gl.uniform"+i+"iv(locations["+e+"],obj"+t+")";case"v":return"gl.uniform"+i+"fv(locations["+e+"],obj"+t+")";default:throw new s("","Unrecognized data type for vector "+name+": "+r)}}}function c(t,e){if("object"!=typeof e)return[[t,e]];var r=[];for(var n in e){var i=e[n],a=t;a+=parseInt(n)+""===n?"["+n+"]":"."+n,"object"==typeof i?r.push.apply(r,c(a,i)):r.push([a,i])}return r}function f(e){for(var n=["return function updateProperty(obj){"],i=c("",e),o=0;o=0&&1>=e&&t.length===4+e){var r=t.charCodeAt(t.length-1)-48;if(2>r||r>4)throw new s("","Invalid data type");return"b"===t.charAt(0)?i(r,!1):i(r,0)}if(0===t.indexOf("mat")&&4===t.length){var r=t.charCodeAt(t.length-1)-48;if(2>r||r>4)throw new s("","Invalid uniform dimension type for matrix "+name+": "+t);return i(r*r,0)}throw new s("","Unknown uniform data type for "+name+": "+t)}}function d(t,e,i){if("object"==typeof i){var o=p(i);Object.defineProperty(t,e,{get:n(o),set:f(i),enumerable:!0,configurable:!1})}else a[i]?Object.defineProperty(t,e,{get:l(i),set:f(i),enumerable:!0,configurable:!1}):t[e]=h(r[i].type)}function p(t){var e;if(Array.isArray(t)){e=new Array(t.length);for(var r=0;r1){l[0]in o||(o[l[0]]=[]),o=o[l[0]];for(var u=1;ua;++a){var o=t.getActiveUniform(e,a);if(o){var s=n(t,o.type);if(o.size>1)for(var l=0;la;++a){var o=t.getActiveAttrib(e,a);o&&i.push({name:o.name,type:n(t,o.type)})}return i}r.uniforms=i,r.attributes=a;var o={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube"},s=null},{}],102:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o){this.id=t,this.src=e,this.type=r,this.shader=n,this.count=a,this.programs=[],this.cache=o}function i(t){this.gl=t,this.shaders=[{},{}],this.programs={}}function a(t,e,r){var n=t.createShader(e);if(t.shaderSource(n,r),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS)){var i=t.getShaderInfoLog(n);try{var a=f(i,r,e)}catch(o){throw console.warn("Failed to format compiler error: "+o),new c(i,"Error compiling shader:\n"+i)}throw new c(i,a.short,a.long)}return n}function o(t,e,r,n,i){var a=t.createProgram();t.attachShader(a,e),t.attachShader(a,r);for(var o=0;on;++n){var a=t.programs[r[n]];a&&(delete t.programs[n],e.deleteProgram(a))}e.deleteShader(this.shader),delete t.shaders[this.type===e.FRAGMENT_SHADER|0][this.src]}};var g=i.prototype;g.getShaderReference=function(t,e){var r=this.gl,i=this.shaders[t===r.FRAGMENT_SHADER|0],o=i[e];if(o&&r.isShader(o.shader))o.count+=1;else{var s=a(r,t,e);o=i[e]=new n(p++,e,t,s,[],1,this)}return o},g.getProgram=function(t,e,r,n){var i=[t.id,e.id,r.join(":"),n.join(":")].join("@"),a=this.programs[i];return a&&this.gl.isProgram(a)||(this.programs[i]=a=o(this.gl,t.shader,e.shader,r,n),t.programs.push(i),e.programs.push(i)),a}},{"./GLError":97,"gl-format-compiler-error":103,"weakmap-shim":113}],103:[function(t,e,r){function n(t,e,r){"use strict";var n=o(e)||"of unknown name (see npm glsl-shader-name)",l="unknown type";void 0!==r&&(l=r===a.FRAGMENT_SHADER?"fragment":"vertex");for(var u=i("Error compiling %s shader %s:\n",l,n),c=i("%s%s",u,t),f=t.split("\n"),h={},d=0;ds;s++)if(g=i(t[s]),"string"===g)v[v.length]=t[s];else if("array"===g){if(u=t[s],u[2])for(n=e[d],l=0;l=0),u[8]){case"b":n=n.toString(2);break;case"c":n=String.fromCharCode(n);break;case"d":case"i":n=parseInt(n,10);break;case"j":n=JSON.stringify(n,null,u[6]?parseInt(u[6]):0);break;case"e":n=u[7]?n.toExponential(u[7]):n.toExponential();break;case"f":n=u[7]?parseFloat(n).toFixed(u[7]):parseFloat(n);break;case"g":n=u[7]?parseFloat(n).toPrecision(u[7]):parseFloat(n);break;case"o":n=n.toString(8);break;case"s":n=(n=String(n))&&u[7]?n.substring(0,u[7]):n;break;case"u":n>>>=0;break;case"x":n=n.toString(16);break;case"X":n=n.toString(16).toUpperCase()}o.json.test(u[8])?v[v.length]=n:(!o.number.test(u[8])||m&&!u[3]?y="":(y=m?"+":"-",n=n.toString().replace(o.sign,"")),f=u[4]?"0"===u[4]?"0":u[4].charAt(1):" ",h=u[6]-(y+n).length,c=u[6]&&h>0?a(f,h):"",v[v.length]=u[5]?y+n+c:"0"===f?y+c+n:c+y+n)}return v.join("")},r.cache={},r.parse=function(t){for(var e=t,r=[],n=[],i=0;e;){if(null!==(r=o.text.exec(e)))n[n.length]=r[0];else if(null!==(r=o.modulo.exec(e)))n[n.length]="%";else{if(null===(r=o.placeholder.exec(e)))throw new SyntaxError("[sprintf] unexpected placeholder");if(r[2]){i|=1;var a=[],s=r[2],l=[];if(null===(l=o.key.exec(s)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(a[a.length]=l[1];""!==(s=s.substring(l[0].length));)if(null!==(l=o.key_access.exec(s)))a[a.length]=l[1];else{if(null===(l=o.index_access.exec(s)))throw new SyntaxError("[sprintf] failed to parse named argument key");a[a.length]=l[1]}r[2]=a}else i|=2;if(3===i)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");n[n.length]=r}e=e.substring(r[0].length)}return n};var s=function(t,e,n){return n=(e||[]).slice(0),n.splice(0,0,t),r.apply(null,n)};"undefined"!=typeof n?(n.sprintf=r,n.vsprintf=s):(e.sprintf=r,e.vsprintf=s,"function"==typeof t&&t.amd&&t(function(){return{sprintf:r,vsprintf:s}}))}("undefined"==typeof window?this:window)},{}],111:[function(t,e,r){function n(){var t={};return function(e){if(("object"!=typeof e||null===e)&&"function"!=typeof e)throw new Error("Weakmap-shim: Key must be object");var r=e.valueOf(t);return r&&r.identity===t?r:i(e,t)}}var i=t("./hidden-store.js");e.exports=n},{"./hidden-store.js":112}],112:[function(t,e,r){function n(t,e){var r={identity:e},n=t.valueOf;return Object.defineProperty(t,"valueOf",{value:function(t){return t!==e?n.apply(this,arguments):r},writable:!0}),r}e.exports=n},{}],113:[function(t,e,r){function n(){var t=i();return{get:function(e,r){var n=t(e);return n.hasOwnProperty("value")?n.value:r},set:function(e,r){t(e).value=r},has:function(e){return"value"in t(e)},"delete":function(e){return delete t(e).value}}}var i=t("./create-store.js");e.exports=n},{"./create-store.js":111}],114:[function(t,e,r){"use strict";function n(t){this.plot=t,this.enable=[!0,!0,!1,!1],this.width=[1,1,1,1],this.color=[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.center=[1/0,1/0]}function i(t,e){var r=new n(t);return r.update(e),t.addOverlay(r),r}e.exports=i;var a=n.prototype;a.update=function(t){t=t||{},this.enable=(t.enable||[!0,!0,!1,!1]).slice(),this.width=(t.width||[1,1,1,1]).slice(),this.color=(t.color||[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]]).map(function(t){return t.slice()}),this.center=(t.center||[1/0,1/0]).slice(),this.plot.setOverlayDirty()},a.draw=function(){var t=this.enable,e=this.width,r=this.color,n=this.center,i=this.plot,a=i.line,o=i.dataBox,s=i.viewBox;if(a.bind(),o[0]<=n[0]&&n[0]<=o[2]&&o[1]<=n[1]&&n[1]<=o[3]){var l=s[0]+(n[0]-o[0])/(o[2]-o[0])*(s[2]-s[0]),u=s[1]+(n[1]-o[1])/(o[3]-o[1])*(s[3]-s[1]);t[0]&&a.drawLine(l,u,s[0],u,e[0],r[0]),t[1]&&a.drawLine(l,u,l,s[1],e[1],r[1]),t[2]&&a.drawLine(l,u,s[2],u,e[2],r[2]),t[3]&&a.drawLine(l,u,l,s[3],e[3],r[3])}},a.dispose=function(){this.plot.removeOverlay(this)}},{}],115:[function(t,e,r){"use strict";function n(t){v=[t.LINEAR,t.NEAREST_MIPMAP_LINEAR,t.LINEAR_MIPMAP_NEAREST,t.LINEAR_MIPMAP_NEAREST],m=[t.NEAREST,t.LINEAR,t.NEAREST_MIPMAP_NEAREST,t.NEAREST_MIPMAP_LINEAR,t.LINEAR_MIPMAP_NEAREST,t.LINEAR_MIPMAP_LINEAR],y=[t.REPEAT,t.CLAMP_TO_EDGE,t.MIRRORED_REPEAT]}function i(t,e,r){var n=t.gl,i=n.getParameter(n.MAX_TEXTURE_SIZE);if(0>e||e>i||0>r||r>i)throw new Error("gl-texture2d: Invalid texture size");return t._shape=[e,r],t.bind(),n.texImage2D(n.TEXTURE_2D,0,t.format,e,r,0,t.format,t.type,null),t._mipLevels=[0],t}function a(t,e,r,n,i,a){this.gl=t,this.handle=e,this.format=i,this.type=a,this._shape=[r,n],this._mipLevels=[0],this._magFilter=t.NEAREST,this._minFilter=t.NEAREST,this._wrapS=t.CLAMP_TO_EDGE,this._wrapT=t.CLAMP_TO_EDGE,this._anisoSamples=1;var o=this,s=[this._wrapS,this._wrapT];Object.defineProperties(s,[{get:function(){return o._wrapS},set:function(t){return o.wrapS=t}},{get:function(){return o._wrapT},set:function(t){return o.wrapT=t}}]),this._wrapVector=s;var l=[this._shape[0],this._shape[1]];Object.defineProperties(l,[{get:function(){return o._shape[0]},set:function(t){return o.width=t}},{get:function(){return o._shape[1]},set:function(t){return o.height=t}}]),this._shapeVector=l}function o(t,e){return 3===t.length?1===e[2]&&e[1]===t[0]*t[2]&&e[0]===t[2]:1===e[0]&&e[1]===t[0]}function s(t,e,r,n,i,a,s,l){var u=l.dtype,c=l.shape.slice();if(c.length<2||c.length>3)throw new Error("gl-texture2d: Invalid ndarray, must be 2d or 3d");var f=0,h=0,v=o(c,l.stride.slice());"float32"===u?f=t.FLOAT:"float64"===u?(f=t.FLOAT,v=!1,u="float32"):"uint8"===u?f=t.UNSIGNED_BYTE:(f=t.UNSIGNED_BYTE,v=!1,u="uint8");var m=1;if(2===c.length)h=t.LUMINANCE,c=[c[0],c[1],1],l=d(l.data,c,[l.stride[0],l.stride[1],1],l.offset);else{if(3!==c.length)throw new Error("gl-texture2d: Invalid shape for texture");if(1===c[2])h=t.ALPHA;else if(2===c[2])h=t.LUMINANCE_ALPHA;else if(3===c[2])h=t.RGB;else{if(4!==c[2])throw new Error("gl-texture2d: Invalid shape for pixel coords");h=t.RGBA}m=c[2]}if(h!==t.LUMINANCE&&h!==t.ALPHA||i!==t.LUMINANCE&&i!==t.ALPHA||(h=i),h!==i)throw new Error("gl-texture2d: Incompatible texture format for setPixels");var y=l.size,x=s.indexOf(n)<0;if(x&&s.push(n),f===a&&v)0===l.offset&&l.data.length===y?x?t.texImage2D(t.TEXTURE_2D,n,i,c[0],c[1],0,i,a,l.data):t.texSubImage2D(t.TEXTURE_2D,n,e,r,c[0],c[1],i,a,l.data):x?t.texImage2D(t.TEXTURE_2D,n,i,c[0],c[1],0,i,a,l.data.subarray(l.offset,l.offset+y)):t.texSubImage2D(t.TEXTURE_2D,n,e,r,c[0],c[1],i,a,l.data.subarray(l.offset,l.offset+y));else{var _;_=a===t.FLOAT?g.mallocFloat32(y):g.mallocUint8(y);var w=d(_,c,[c[2],c[2]*c[0],1]);f===t.FLOAT&&a===t.UNSIGNED_BYTE?b(w,l):p.assign(w,l),x?t.texImage2D(t.TEXTURE_2D,n,i,c[0],c[1],0,i,a,_.subarray(0,y)):t.texSubImage2D(t.TEXTURE_2D,n,e,r,c[0],c[1],i,a,_.subarray(0,y)),a===t.FLOAT?g.freeFloat32(_):g.freeUint8(_)}}function l(t){var e=t.createTexture();return t.bindTexture(t.TEXTURE_2D,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),e}function u(t,e,r,n,i){var o=t.getParameter(t.MAX_TEXTURE_SIZE);if(0>e||e>o||0>r||r>o)throw new Error("gl-texture2d: Invalid texture shape");if(i===t.FLOAT&&!t.getExtension("OES_texture_float"))throw new Error("gl-texture2d: Floating point textures not supported on this platform");var s=l(t);return t.texImage2D(t.TEXTURE_2D,0,n,e,r,0,n,i,null),new a(t,s,e,r,n,i)}function c(t,e,r,n){var i=l(t);return t.texImage2D(t.TEXTURE_2D,0,r,r,n,e),new a(t,i,0|e.width,0|e.height,r,n)}function f(t,e){var r=e.dtype,n=e.shape.slice(),i=t.getParameter(t.MAX_TEXTURE_SIZE);if(n[0]<0||n[0]>i||n[1]<0||n[1]>i)throw new Error("gl-texture2d: Invalid texture size");var s=o(n,e.stride.slice()),u=0;"float32"===r?u=t.FLOAT:"float64"===r?(u=t.FLOAT,s=!1,r="float32"):"uint8"===r?u=t.UNSIGNED_BYTE:(u=t.UNSIGNED_BYTE,s=!1,r="uint8");var c=0;if(2===n.length)c=t.LUMINANCE,n=[n[0],n[1],1],e=d(e.data,n,[e.stride[0],e.stride[1],1],e.offset);else{if(3!==n.length)throw new Error("gl-texture2d: Invalid shape for texture");if(1===n[2])c=t.ALPHA;else if(2===n[2])c=t.LUMINANCE_ALPHA;else if(3===n[2])c=t.RGB;else{if(4!==n[2])throw new Error("gl-texture2d: Invalid shape for pixel coords");c=t.RGBA}}u!==t.FLOAT||t.getExtension("OES_texture_float")||(u=t.UNSIGNED_BYTE,s=!1);var f,h,v=e.size;if(s)f=0===e.offset&&e.data.length===v?e.data:e.data.subarray(e.offset,e.offset+v);else{var m=[n[2],n[2]*n[0],1];h=g.malloc(v,r);var y=d(h,n,m,0);"float32"!==r&&"float64"!==r||u!==t.UNSIGNED_BYTE?p.assign(y,e):b(y,e),f=h.subarray(0,v)}var x=l(t);return t.texImage2D(t.TEXTURE_2D,0,c,n[0],n[1],0,c,u,f),s||g.free(h),new a(t,x,n[0],n[1],c,u)}function h(t){if(arguments.length<=1)throw new Error("gl-texture2d: Missing arguments for texture2d constructor");if(v||n(t),"number"==typeof arguments[1])return u(t,arguments[1],arguments[2],arguments[3]||t.RGBA,arguments[4]||t.UNSIGNED_BYTE);if(Array.isArray(arguments[1]))return u(t,0|arguments[1][0],0|arguments[1][1],arguments[2]||t.RGBA,arguments[3]||t.UNSIGNED_BYTE);if("object"==typeof arguments[1]){var e=arguments[1];if(e instanceof HTMLCanvasElement||e instanceof HTMLImageElement||e instanceof HTMLVideoElement||e instanceof ImageData)return c(t,e,arguments[2]||t.RGBA,arguments[3]||t.UNSIGNED_BYTE);if(e.shape&&e.data&&e.stride)return f(t,e)}throw new Error("gl-texture2d: Invalid arguments for texture2d constructor")}var d=t("ndarray"),p=t("ndarray-ops"),g=t("typedarray-pool");e.exports=h;var v=null,m=null,y=null,b=function(t,e){p.muls(t,e,255)},x=a.prototype;Object.defineProperties(x,{minFilter:{get:function(){return this._minFilter},set:function(t){this.bind();var e=this.gl;if(this.type===e.FLOAT&&v.indexOf(t)>=0&&(e.getExtension("OES_texture_float_linear")||(t=e.NEAREST)),m.indexOf(t)<0)throw new Error("gl-texture2d: Unknown filter mode "+t);return e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t),this._minFilter=t}},magFilter:{get:function(){return this._magFilter},set:function(t){this.bind();var e=this.gl;if(this.type===e.FLOAT&&v.indexOf(t)>=0&&(e.getExtension("OES_texture_float_linear")||(t=e.NEAREST)),m.indexOf(t)<0)throw new Error("gl-texture2d: Unknown filter mode "+t);return e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,t),this._magFilter=t}},mipSamples:{get:function(){return this._anisoSamples},set:function(t){var e=this._anisoSamples;if(this._anisoSamples=0|Math.max(t,1),e!==this._anisoSamples){var r=gl.getExtension("EXT_texture_filter_anisotropic");r&&this.gl.texParameterf(this.gl.TEXTURE_2D,r.TEXTURE_MAX_ANISOTROPY_EXT,this._anisoSamples)}return this._anisoSamples}},wrapS:{get:function(){return this._wrapS},set:function(t){if(this.bind(),y.indexOf(t)<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);return this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,t),this._wrapS=t}},wrapT:{get:function(){return this._wrapT},set:function(t){if(this.bind(),y.indexOf(t)<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);return this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,t),this._wrapT=t}},wrap:{get:function(){return this._wrapVector},set:function(t){if(Array.isArray(t)||(t=[t,t]),2!==t.length)throw new Error("gl-texture2d: Must specify wrap mode for rows and columns");for(var e=0;2>e;++e)if(y.indexOf(t[e])<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);this._wrapS=t[0],this._wrapT=t[1];var r=this.gl;return this.bind(),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,this._wrapS),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,this._wrapT),t}},shape:{get:function(){return this._shapeVector},set:function(t){if(Array.isArray(t)){if(2!==t.length)throw new Error("gl-texture2d: Invalid texture shape")}else t=[0|t,0|t];return i(this,0|t[0],0|t[1]),[0|t[0],0|t[1]]}},width:{get:function(){return this._shape[0]},set:function(t){return t=0|t,i(this,t,this._shape[1]),t}},height:{get:function(){return this._shape[1]},set:function(t){return t=0|t,i(this,this._shape[0],t),t}}}),x.bind=function(t){var e=this.gl;return void 0!==t&&e.activeTexture(e.TEXTURE0+(0|t)),e.bindTexture(e.TEXTURE_2D,this.handle),void 0!==t?0|t:e.getParameter(e.ACTIVE_TEXTURE)-e.TEXTURE0},x.dispose=function(){this.gl.deleteTexture(this.handle)},x.generateMipmap=function(){this.bind(),this.gl.generateMipmap(this.gl.TEXTURE_2D);for(var t=Math.min(this._shape[0],this._shape[1]),e=0;t>0;++e,t>>>=1)this._mipLevels.indexOf(e)<0&&this._mipLevels.push(e)},x.setPixels=function(t,e,r,n){var i=this.gl;if(this.bind(),Array.isArray(e)?(n=r,r=0|e[1],e=0|e[0]):(e=e||0,r=r||0),n=n||0,t instanceof HTMLCanvasElement||t instanceof ImageData||t instanceof HTMLImageElement||t instanceof HTMLVideoElement){var a=this._mipLevels.indexOf(n)<0;a?(i.texImage2D(i.TEXTURE_2D,0,this.format,this.format,this.type,t),this._mipLevels.push(n)):i.texSubImage2D(i.TEXTURE_2D,n,e,r,this.format,this.type,t)}else{if(!(t.shape&&t.stride&&t.data))throw new Error("gl-texture2d: Unsupported data type");if(t.shape.length<2||e+t.shape[1]>this._shape[1]>>>n||r+t.shape[0]>this._shape[0]>>>n||0>e||0>r)throw new Error("gl-texture2d: Texture dimensions are out of bounds");s(i,e,r,n,this.format,this.type,this._mipLevels,t)}}},{ndarray:131,"ndarray-ops":130,"typedarray-pool":151}],116:[function(t,e,r){function n(t){function e(t){t.length&&V.push({type:A[j],data:t,position:G,line:q,column:H})}function r(t){F=0,W+=t,D=W.length;for(var e;N=W[F],D>F;){switch(e=F,j){case f:F=L();break;case h:F=T();break;case d:F=E();break;case p:F=S();break;case g:F=I();break;case w:F=R();break;case v:F=P();break;case c:F=O();break;case x:F=M();break;case u:F=k()}if(e!==F)switch(W[e]){case"\n":H=0,++q;break;default:++H}}return B+=F,W=W.slice(F),V}function n(t){return U.length&&e(U.join("")),j=_,e("(eof)"),V}function k(){return U=U.length?[]:U,"/"===z&&"*"===N?(G=B+F-1,j=f,z=N,F+1):"/"===z&&"/"===N?(G=B+F-1,j=h,z=N,F+1):"#"===N?(j=d,G=B+F,F):/\s/.test(N)?(j=x,G=B+F,F):(X=/\d/.test(N),Y=/[^\w_]/.test(N),G=B+F,j=X?g:Y?p:c,F)}function M(){return/[^\s]/g.test(N)?(e(U.join("")),j=u,F):(U.push(N),z=N,F+1)}function E(){return"\n"===N&&"\\"!==z?(e(U.join("")),j=u,F):(U.push(N),z=N,F+1)}function T(){return E()}function L(){return"/"===N&&"*"===z?(U.push(N),e(U.join("")),j=u,F+1):(U.push(N),z=N,F+1)}function S(){if("."===z&&/\d/.test(N))return j=v,F;if("/"===z&&"*"===N)return j=f,F;if("/"===z&&"/"===N)return j=h,F;if("."===N&&U.length){for(;C(U););return j=v,F}if(";"===N||")"===N||"("===N){if(U.length)for(;C(U););return e(N),j=u,F+1}var t=2===U.length&&"="!==N;if(/[\w_\d\s]/.test(N)||t){for(;C(U););return j=u,F}return U.push(N),z=N,F+1}function C(t){for(var r,n,i=0;;){if(r=a.indexOf(t.slice(0,t.length+i).join("")),n=a[r],-1===r){if(i--+t.length>0)continue;n=t.slice(0,1).join("")}return e(n),G+=n.length,U=U.slice(n.length),U.length}}function R(){return/[^a-fA-F0-9]/.test(N)?(e(U.join("")),j=u,F):(U.push(N),z=N,F+1)}function I(){return"."===N?(U.push(N),j=v,z=N,F+1):/[eE]/.test(N)?(U.push(N),j=v,z=N,F+1):"x"===N&&1===U.length&&"0"===U[0]?(j=w,U.push(N),z=N,F+1):/[^\d]/.test(N)?(e(U.join("")),j=u,F):(U.push(N),z=N,F+1)}function P(){return"f"===N&&(U.push(N),z=N,F+=1),/[eE]/.test(N)?(U.push(N),z=N,F+1):"-"===N&&/[eE]/.test(z)?(U.push(N),z=N,F+1):/[^\d]/.test(N)?(e(U.join("")),j=u,F):(U.push(N),z=N,F+1)}function O(){if(/[^\d\w_]/.test(N)){var t=U.join("");return j=Q.indexOf(t)>-1?b:Z.indexOf(t)>-1?y:m,e(U.join("")),j=u,F}return U.push(N),z=N,F+1}var N,z,D,F=0,B=0,j=u,U=[],V=[],q=1,H=0,G=0,X=!1,Y=!1,W="";t=t||{};var Z=o,Q=i;return"300 es"===t.version&&(Z=l,Q=s),function(t){return V=[],null!==t?r(t):n()}}e.exports=n;var i=t("./lib/literals"),a=t("./lib/operators"),o=t("./lib/builtins"),s=t("./lib/literals-300es"),l=t("./lib/builtins-300es"),u=999,c=9999,f=0,h=1,d=2,p=3,g=4,v=5,m=6,y=7,b=8,x=9,_=10,w=11,A=["block-comment","line-comment","preprocessor","operator","integer","float","ident","builtin","keyword","whitespace","eof","integer"]},{"./lib/builtins":118,"./lib/builtins-300es":117,"./lib/literals":120,"./lib/literals-300es":119,"./lib/operators":121}],117:[function(t,e,r){var n=t("./builtins");n=n.slice().filter(function(t){return!/^(gl\_|texture)/.test(t)}),e.exports=n.concat(["gl_VertexID","gl_InstanceID","gl_Position","gl_PointSize","gl_FragCoord","gl_FrontFacing","gl_FragDepth","gl_PointCoord","gl_MaxVertexAttribs","gl_MaxVertexUniformVectors","gl_MaxVertexOutputVectors","gl_MaxFragmentInputVectors","gl_MaxVertexTextureImageUnits","gl_MaxCombinedTextureImageUnits","gl_MaxTextureImageUnits","gl_MaxFragmentUniformVectors","gl_MaxDrawBuffers","gl_MinProgramTexelOffset","gl_MaxProgramTexelOffset","gl_DepthRangeParameters","gl_DepthRange","trunc","round","roundEven","isnan","isinf","floatBitsToInt","floatBitsToUint","intBitsToFloat","uintBitsToFloat","packSnorm2x16","unpackSnorm2x16","packUnorm2x16","unpackUnorm2x16","packHalf2x16","unpackHalf2x16","outerProduct","transpose","determinant","inverse","texture","textureSize","textureProj","textureLod","textureOffset","texelFetch","texelFetchOffset","textureProjOffset","textureLodOffset","textureProjLod","textureProjLodOffset","textureGrad","textureGradOffset","textureProjGrad","textureProjGradOffset"])},{"./builtins":118 +-}],118:[function(t,e,r){e.exports=["abs","acos","all","any","asin","atan","ceil","clamp","cos","cross","dFdx","dFdy","degrees","distance","dot","equal","exp","exp2","faceforward","floor","fract","gl_BackColor","gl_BackLightModelProduct","gl_BackLightProduct","gl_BackMaterial","gl_BackSecondaryColor","gl_ClipPlane","gl_ClipVertex","gl_Color","gl_DepthRange","gl_DepthRangeParameters","gl_EyePlaneQ","gl_EyePlaneR","gl_EyePlaneS","gl_EyePlaneT","gl_Fog","gl_FogCoord","gl_FogFragCoord","gl_FogParameters","gl_FragColor","gl_FragCoord","gl_FragData","gl_FragDepth","gl_FragDepthEXT","gl_FrontColor","gl_FrontFacing","gl_FrontLightModelProduct","gl_FrontLightProduct","gl_FrontMaterial","gl_FrontSecondaryColor","gl_LightModel","gl_LightModelParameters","gl_LightModelProducts","gl_LightProducts","gl_LightSource","gl_LightSourceParameters","gl_MaterialParameters","gl_MaxClipPlanes","gl_MaxCombinedTextureImageUnits","gl_MaxDrawBuffers","gl_MaxFragmentUniformComponents","gl_MaxLights","gl_MaxTextureCoords","gl_MaxTextureImageUnits","gl_MaxTextureUnits","gl_MaxVaryingFloats","gl_MaxVertexAttribs","gl_MaxVertexTextureImageUnits","gl_MaxVertexUniformComponents","gl_ModelViewMatrix","gl_ModelViewMatrixInverse","gl_ModelViewMatrixInverseTranspose","gl_ModelViewMatrixTranspose","gl_ModelViewProjectionMatrix","gl_ModelViewProjectionMatrixInverse","gl_ModelViewProjectionMatrixInverseTranspose","gl_ModelViewProjectionMatrixTranspose","gl_MultiTexCoord0","gl_MultiTexCoord1","gl_MultiTexCoord2","gl_MultiTexCoord3","gl_MultiTexCoord4","gl_MultiTexCoord5","gl_MultiTexCoord6","gl_MultiTexCoord7","gl_Normal","gl_NormalMatrix","gl_NormalScale","gl_ObjectPlaneQ","gl_ObjectPlaneR","gl_ObjectPlaneS","gl_ObjectPlaneT","gl_Point","gl_PointCoord","gl_PointParameters","gl_PointSize","gl_Position","gl_ProjectionMatrix","gl_ProjectionMatrixInverse","gl_ProjectionMatrixInverseTranspose","gl_ProjectionMatrixTranspose","gl_SecondaryColor","gl_TexCoord","gl_TextureEnvColor","gl_TextureMatrix","gl_TextureMatrixInverse","gl_TextureMatrixInverseTranspose","gl_TextureMatrixTranspose","gl_Vertex","greaterThan","greaterThanEqual","inversesqrt","length","lessThan","lessThanEqual","log","log2","matrixCompMult","max","min","mix","mod","normalize","not","notEqual","pow","radians","reflect","refract","sign","sin","smoothstep","sqrt","step","tan","texture2D","texture2DLod","texture2DProj","texture2DProjLod","textureCube","textureCubeLod","texture2DLodEXT","texture2DProjLodEXT","textureCubeLodEXT","texture2DGradEXT","texture2DProjGradEXT","textureCubeGradEXT"]},{}],119:[function(t,e,r){var n=t("./literals");e.exports=n.slice().concat(["layout","centroid","smooth","case","mat2x2","mat2x3","mat2x4","mat3x2","mat3x3","mat3x4","mat4x2","mat4x3","mat4x4","uint","uvec2","uvec3","uvec4","samplerCubeShadow","sampler2DArray","sampler2DArrayShadow","isampler2D","isampler3D","isamplerCube","isampler2DArray","usampler2D","usampler3D","usamplerCube","usampler2DArray","coherent","restrict","readonly","writeonly","resource","atomic_uint","noperspective","patch","sample","subroutine","common","partition","active","filter","image1D","image2D","image3D","imageCube","iimage1D","iimage2D","iimage3D","iimageCube","uimage1D","uimage2D","uimage3D","uimageCube","image1DArray","image2DArray","iimage1DArray","iimage2DArray","uimage1DArray","uimage2DArray","image1DShadow","image2DShadow","image1DArrayShadow","image2DArrayShadow","imageBuffer","iimageBuffer","uimageBuffer","sampler1DArray","sampler1DArrayShadow","isampler1D","isampler1DArray","usampler1D","usampler1DArray","isampler2DRect","usampler2DRect","samplerBuffer","isamplerBuffer","usamplerBuffer","sampler2DMS","isampler2DMS","usampler2DMS","sampler2DMSArray","isampler2DMSArray","usampler2DMSArray"])},{"./literals":120}],120:[function(t,e,r){e.exports=["precision","highp","mediump","lowp","attribute","const","uniform","varying","break","continue","do","for","while","if","else","in","out","inout","float","int","void","bool","true","false","discard","return","mat2","mat3","mat4","vec2","vec3","vec4","ivec2","ivec3","ivec4","bvec2","bvec3","bvec4","sampler1D","sampler2D","sampler3D","samplerCube","sampler1DShadow","sampler2DShadow","struct","asm","class","union","enum","typedef","template","this","packed","goto","switch","default","inline","noinline","volatile","public","static","extern","external","interface","long","short","double","half","fixed","unsigned","input","output","hvec2","hvec3","hvec4","dvec2","dvec3","dvec4","fvec2","fvec3","fvec4","sampler2DRect","sampler3DRect","sampler2DRectShadow","sizeof","cast","namespace","using"]},{}],121:[function(t,e,r){e.exports=["<<=",">>=","++","--","<<",">>","<=",">=","==","!=","&&","||","+=","-=","*=","/=","%=","&=","^^","^=","|=","(",")","[","]",".","!","~","*","/","%","+","-","<",">","&","^","|","?",":","=",",",";","{","}"]},{}],122:[function(t,e,r){function n(t,e){var r=i(e),n=[];return n=n.concat(r(t)),n=n.concat(r(null))}var i=t("./index");e.exports=n},{"./index":116}],123:[function(t,e,r){"use strict";function n(t){for(var e=new Array(t),r=0;t>r;++r)e[r]=r;return e}e.exports=n},{}],124:[function(t,e,r){e.exports=function(t){return!(null==t||!(t._isBuffer||t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)))}},{}],125:[function(t,e,r){"use strict";function n(t,e){function r(t){var e=!1;return"altKey"in t&&(e=e||t.altKey!==g.alt,g.alt=!!t.altKey),"shiftKey"in t&&(e=e||t.shiftKey!==g.shift,g.shift=!!t.shiftKey),"ctrlKey"in t&&(e=e||t.ctrlKey!==g.control,g.control=!!t.ctrlKey),"metaKey"in t&&(e=e||t.metaKey!==g.meta,g.meta=!!t.metaKey),e}function n(t,n){var a=i.x(n),o=i.y(n);"buttons"in n&&(t=0|n.buttons),(t!==h||a!==d||o!==p||r(n))&&(h=0|t,d=a||0,p=o||0,e(h,d,p,g))}function a(t){n(0,t)}function o(){(h||d||p||g.shift||g.alt||g.meta||g.control)&&(d=p=0,h=0,g.shift=g.alt=g.control=g.meta=!1,e(0,0,0,g))}function s(t){r(t)&&e(h,d,p,g)}function l(t){0===i.buttons(t)?n(0,t):n(h,t)}function u(t){n(h|i.buttons(t),t)}function c(t){n(h&~i.buttons(t),t)}function f(){v||(v=!0,t.addEventListener("mousemove",l),t.addEventListener("mousedown",u),t.addEventListener("mouseup",c),t.addEventListener("mouseleave",a),t.addEventListener("mouseenter",a),t.addEventListener("mouseout",a),t.addEventListener("mouseover",a),t.addEventListener("blur",o),t.addEventListener("keyup",s),t.addEventListener("keydown",s),t.addEventListener("keypress",s),t!==window&&(window.addEventListener("blur",o),window.addEventListener("keyup",s),window.addEventListener("keydown",s),window.addEventListener("keypress",s)))}e||(e=t,t=window);var h=0,d=0,p=0,g={shift:!1,alt:!1,control:!1,meta:!1},v=!1;f();var m={element:t};return Object.defineProperties(m,{enabled:{get:function(){return v},set:function(t){t&&f()},enumerable:!0},buttons:{get:function(){return h},enumerable:!0},x:{get:function(){return d},enumerable:!0},y:{get:function(){return p},enumerable:!0},mods:{get:function(){return g},enumerable:!0}}),m}e.exports=n;var i=t("mouse-event")},{"mouse-event":126}],126:[function(t,e,r){"use strict";function n(t){if("object"==typeof t){if("buttons"in t)return t.buttons;if("which"in t){var e=t.which;if(2===e)return 4;if(3===e)return 2;if(e>0)return 1<=0)return 1<>",rrshift:">>>"};!function(){for(var t in l){var e=l[t];r[t]=a({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+e+"c"},funcName:t}),r[t+"eq"]=a({args:["array","array"],body:{args:["a","b"],body:"a"+e+"=b"},rvalue:!0,funcName:t+"eq"}),r[t+"s"]=a({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+e+"s"},funcName:t+"s"}),r[t+"seq"]=a({args:["array","scalar"],body:{args:["a","s"],body:"a"+e+"=s"},rvalue:!0,funcName:t+"seq"})}}();var u={not:"!",bnot:"~",neg:"-",recip:"1.0/"};!function(){for(var t in u){var e=u[t];r[t]=a({args:["array","array"],body:{args:["a","b"],body:"a="+e+"b"},funcName:t}),r[t+"eq"]=a({args:["array"],body:{args:["a"],body:"a="+e+"a"},rvalue:!0,count:2,funcName:t+"eq"})}}();var c={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};!function(){for(var t in c){var e=c[t];r[t]=a({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+e+"c"},funcName:t}),r[t+"s"]=a({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+e+"s"},funcName:t+"s"}),r[t+"eq"]=a({args:["array","array"],body:{args:["a","b"],body:"a=a"+e+"b"},rvalue:!0,count:2,funcName:t+"eq"}),r[t+"seq"]=a({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+e+"s"},rvalue:!0,count:2,funcName:t+"seq"})}}();var f=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];!function(){for(var t=0;tthis_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"}),r.norm1=o({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"}),r.sup=o({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}}),r.inf=o({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}}),r.random=a({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"}),r.assign=a({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"}),r.assigns=a({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"}),r.equals=o({args:["array","array"],pre:s,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})},{"cwise-compiler":58}],131:[function(t,e,r){function n(t,e){return t[0]-e[0]}function i(){var t,e=this.stride,r=new Array(e.length);for(t=0;te&&(r="View_Nil"+t);var n="generic"===t;if(-1===e){var a="function "+r+"(a){this.data=a;};var proto="+r+".prototype;proto.dtype='"+t+"';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new "+r+"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_"+r+"(a){return new "+r+"(a);}",o=new Function(a);return o()}if(0===e){var a="function "+r+"(a,d) {this.data = a;this.offset = d};var proto="+r+".prototype;proto.dtype='"+t+"';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function "+r+"_copy() {return new "+r+"(this.data,this.offset)};proto.pick=function "+r+"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function "+r+"_get(){return "+(n?"this.data.get(this.offset)":"this.data[this.offset]")+"};proto.set=function "+r+"_set(v){return "+(n?"this.data.set(this.offset,v)":"this.data[this.offset]=v")+"};return function construct_"+r+"(a,b,c,d){return new "+r+"(a,d)}",o=new Function("TrivialArray",a);return o(f[t][0])}var a=["'use strict'"],s=l(e),u=s.map(function(t){return"i"+t}),c="this.offset+"+s.map(function(t){return"this.stride["+t+"]*i"+t}).join("+"),h=s.map(function(t){return"b"+t}).join(","),d=s.map(function(t){return"c"+t}).join(",");a.push("function "+r+"(a,"+h+","+d+",d){this.data=a","this.shape=["+h+"]","this.stride=["+d+"]","this.offset=d|0}","var proto="+r+".prototype","proto.dtype='"+t+"'","proto.dimension="+e),a.push("Object.defineProperty(proto,'size',{get:function "+r+"_size(){return "+s.map(function(t){return"this.shape["+t+"]"}).join("*"),"}})"),1===e?a.push("proto.order=[0]"):(a.push("Object.defineProperty(proto,'order',{get:"),4>e?(a.push("function "+r+"_order(){"),2===e?a.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})"):3===e&&a.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):a.push("ORDER})")),a.push("proto.set=function "+r+"_set("+u.join(",")+",v){"),n?a.push("return this.data.set("+c+",v)}"):a.push("return this.data["+c+"]=v}"),a.push("proto.get=function "+r+"_get("+u.join(",")+"){"),n?a.push("return this.data.get("+c+")}"):a.push("return this.data["+c+"]}"),a.push("proto.index=function "+r+"_index(",u.join(),"){return "+c+"}"),a.push("proto.hi=function "+r+"_hi("+u.join(",")+"){return new "+r+"(this.data,"+s.map(function(t){return["(typeof i",t,"!=='number'||i",t,"<0)?this.shape[",t,"]:i",t,"|0"].join("")}).join(",")+","+s.map(function(t){return"this.stride["+t+"]"}).join(",")+",this.offset)}");var p=s.map(function(t){return"a"+t+"=this.shape["+t+"]"}),g=s.map(function(t){return"c"+t+"=this.stride["+t+"]"});a.push("proto.lo=function "+r+"_lo("+u.join(",")+"){var b=this.offset,d=0,"+p.join(",")+","+g.join(","));for(var v=0;e>v;++v)a.push("if(typeof i"+v+"==='number'&&i"+v+">=0){d=i"+v+"|0;b+=c"+v+"*d;a"+v+"-=d}");a.push("return new "+r+"(this.data,"+s.map(function(t){return"a"+t}).join(",")+","+s.map(function(t){return"c"+t}).join(",")+",b)}"),a.push("proto.step=function "+r+"_step("+u.join(",")+"){var "+s.map(function(t){return"a"+t+"=this.shape["+t+"]"}).join(",")+","+s.map(function(t){return"b"+t+"=this.stride["+t+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(var v=0;e>v;++v)a.push("if(typeof i"+v+"==='number'){d=i"+v+"|0;if(d<0){c+=b"+v+"*(a"+v+"-1);a"+v+"=ceil(-a"+v+"/d)}else{a"+v+"=ceil(a"+v+"/d)}b"+v+"*=d}");a.push("return new "+r+"(this.data,"+s.map(function(t){return"a"+t}).join(",")+","+s.map(function(t){return"b"+t}).join(",")+",c)}");for(var m=new Array(e),y=new Array(e),v=0;e>v;++v)m[v]="a[i"+v+"]",y[v]="b[i"+v+"]";a.push("proto.transpose=function "+r+"_transpose("+u+"){"+u.map(function(t,e){return t+"=("+t+"===undefined?"+e+":"+t+"|0)"}).join(";"),"var a=this.shape,b=this.stride;return new "+r+"(this.data,"+m.join(",")+","+y.join(",")+",this.offset)}"),a.push("proto.pick=function "+r+"_pick("+u+"){var a=[],b=[],c=this.offset");for(var v=0;e>v;++v)a.push("if(typeof i"+v+"==='number'&&i"+v+">=0){c=(c+this.stride["+v+"]*i"+v+")|0}else{a.push(this.shape["+v+"]);b.push(this.stride["+v+"])}");a.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),a.push("return function construct_"+r+"(data,shape,stride,offset){return new "+r+"(data,"+s.map(function(t){return"shape["+t+"]"}).join(",")+","+s.map(function(t){return"stride["+t+"]"}).join(",")+",offset)}");var o=new Function("CTOR_LIST","ORDER",a.join("\n"));return o(f[t],i)}function o(t){if(u(t))return"buffer";if(c)switch(Object.prototype.toString.call(t)){case"[object Float64Array]":return"float64";case"[object Float32Array]":return"float32";case"[object Int8Array]":return"int8";case"[object Int16Array]":return"int16";case"[object Int32Array]":return"int32";case"[object Uint8Array]":return"uint8";case"[object Uint16Array]":return"uint16";case"[object Uint32Array]":return"uint32";case"[object Uint8ClampedArray]":return"uint8_clamped"}return Array.isArray(t)?"array":"generic"}function s(t,e,r,n){if(void 0===t){var i=f.array[0];return i([])}"number"==typeof t&&(t=[t]),void 0===e&&(e=[t.length]);var s=e.length;if(void 0===r){r=new Array(s);for(var l=s-1,u=1;l>=0;--l)r[l]=u,u*=e[l]}if(void 0===n){n=0;for(var l=0;s>l;++l)r[l]<0&&(n-=(e[l]-1)*r[l])}for(var c=o(t),h=f[c];h.length<=s+1;)h.push(a(c,h.length-1));var i=h[s+1];return i(t,e,r,n)}var l=t("iota-array"),u=t("is-buffer"),c="undefined"!=typeof Float64Array,f={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],buffer:[],generic:[]};e.exports=s},{"iota-array":123,"is-buffer":124}],132:[function(t,e,r){"use strict";function n(t,e){if("string"!=typeof t)throw new TypeError("repeat-string expects a string.");if(1===e)return t;if(2===e)return t+t;var r=t.length*e;for(i===t&&"undefined"!=typeof i||(i=t,a="");r>a.length&&e>0&&(1&e&&(a+=t),e>>=1);)t+=t;return a.substr(0,r)}var i,a="";e.exports=n},{}],133:[function(t,e,r){"use strict";function n(t,e){for(var r=new Array(t.length-1),n=1;nr;++r){e[r]=new Array(t);for(var n=0;t>n;++n)e[r][n]=["m",n,"[",t-r-1,"]"].join("")}return e}function a(t){return 1&t?"-":""}function o(t){if(1===t.length)return t[0];if(2===t.length)return["sum(",t[0],",",t[1],")"].join("");var e=t.length>>1;return["sum(",o(t.slice(0,e)),",",o(t.slice(e)),")"].join("")}function s(t){if(2===t.length)return[["sum(prod(",t[0][0],",",t[1][1],"),prod(-",t[0][1],",",t[1][0],"))"].join("")];for(var e=[],r=0;ru;++u)0===(1&u)?e.push.apply(e,s(n(a,u))):r.push.apply(r,s(n(a,u))),l.push("m"+u);var c=o(e),g=o(r),v="orientation"+t+"Exact",m=["function ",v,"(",l.join(),"){var p=",c,",n=",g,",d=sub(p,n);return d[d.length-1];};return ",v].join(""),y=new Function("sum","prod","scale","sub",m);return y(h,f,d,p)}function u(t){var e=_[t.length];return e||(e=_[t.length]=l(t.length)),e.apply(void 0,t)}function c(){for(;_.length<=g;)_.push(l(_.length));for(var t=[],r=["slow"],n=0;g>=n;++n)t.push("a"+n),r.push("o"+n);for(var i=["function getOrientation(",t.join(),"){switch(arguments.length){case 0:case 1:return 0;"],n=2;g>=n;++n)i.push("case ",n,":return o",n,"(",t.slice(0,n).join(),");");i.push("}var s=new Array(arguments.length);for(var i=0;i=n;++n)e.exports[n]=_[n]}var f=t("two-product"),h=t("robust-sum"),d=t("robust-scale"),p=t("robust-subtract"),g=5,v=1.1102230246251565e-16,m=(3+16*v)*v,y=(7+56*v)*v,b=l(3),x=l(4),_=[function(){return 0},function(){return 0},function(t,e){return e[0]-t[0]},function(t,e,r){var n,i=(t[1]-r[1])*(e[0]-r[0]),a=(t[0]-r[0])*(e[1]-r[1]),o=i-a;if(i>0){if(0>=a)return o;n=i+a}else{if(!(0>i))return o;if(a>=0)return o;n=-(i+a)}var s=m*n;return o>=s||-s>=o?o:b(t,e,r)},function(t,e,r,n){var i=t[0]-n[0],a=e[0]-n[0],o=r[0]-n[0],s=t[1]-n[1],l=e[1]-n[1],u=r[1]-n[1],c=t[2]-n[2],f=e[2]-n[2],h=r[2]-n[2],d=a*u,p=o*l,g=o*s,v=i*u,m=i*l,b=a*s,_=c*(d-p)+f*(g-v)+h*(m-b),w=(Math.abs(d)+Math.abs(p))*Math.abs(c)+(Math.abs(g)+Math.abs(v))*Math.abs(f)+(Math.abs(m)+Math.abs(b))*Math.abs(h),A=y*w;return _>A||-_>A?_:x(t,e,r,n)}];c()},{"robust-scale":134,"robust-subtract":135,"robust-sum":136,"two-product":149}],134:[function(t,e,r){"use strict";function n(t,e){var r=t.length;if(1===r){var n=i(t[0],e);return n[0]?n:[n[1]]}var o=new Array(2*r),s=[.1,.1],l=[.1,.1],u=0;i(t[0],e,s),s[0]&&(o[u++]=s[0]);for(var c=1;r>c;++c){i(t[c],e,l);var f=s[1];a(f,l[0],s),s[0]&&(o[u++]=s[0]);var h=l[1],d=s[1],p=h+d,g=p-h,v=d-g;s[1]=p,v&&(o[u++]=v)}return s[1]&&(o[u++]=s[1]),0===u&&(o[u++]=0),o.length=u,o}var i=t("two-product"),a=t("two-sum");e.exports=n},{"two-product":149,"two-sum":150}],135:[function(t,e,r){"use strict";function n(t,e){var r=t+e,n=r-t,i=r-n,a=e-n,o=t-i,s=o+a;return s?[s,r]:[r]}function i(t,e){var r=0|t.length,i=0|e.length;if(1===r&&1===i)return n(t[0],-e[0]);var a,o,s=r+i,l=new Array(s),u=0,c=0,f=0,h=Math.abs,d=t[c],p=h(d),g=-e[f],v=h(g);v>p?(o=d,c+=1,r>c&&(d=t[c],p=h(d))):(o=g,f+=1,i>f&&(g=-e[f],v=h(g))),r>c&&v>p||f>=i?(a=d,c+=1,r>c&&(d=t[c],p=h(d))):(a=g,f+=1,i>f&&(g=-e[f],v=h(g)));for(var m,y,b,x,_,w=a+o,A=w-a,k=o-A,M=k,E=w;r>c&&i>f;)v>p?(a=d,c+=1,r>c&&(d=t[c],p=h(d))):(a=g,f+=1,i>f&&(g=-e[f],v=h(g))),o=M,w=a+o,A=w-a,k=o-A,k&&(l[u++]=k),m=E+w,y=m-E,b=m-y,x=w-y,_=E-b,M=_+x,E=m;for(;r>c;)a=d,o=M,w=a+o,A=w-a,k=o-A,k&&(l[u++]=k),m=E+w,y=m-E,b=m-y,x=w-y,_=E-b,M=_+x,E=m,c+=1,r>c&&(d=t[c]);for(;i>f;)a=g,o=M,w=a+o,A=w-a,k=o-A,k&&(l[u++]=k),m=E+w,y=m-E,b=m-y,x=w-y,_=E-b,M=_+x,E=m,f+=1,i>f&&(g=-e[f]);return M&&(l[u++]=M),E&&(l[u++]=E),u||(l[u++]=0),l.length=u,l}e.exports=i},{}],136:[function(t,e,r){"use strict";function n(t,e){var r=t+e,n=r-t,i=r-n,a=e-n,o=t-i,s=o+a;return s?[s,r]:[r]}function i(t,e){var r=0|t.length,i=0|e.length;if(1===r&&1===i)return n(t[0],e[0]);var a,o,s=r+i,l=new Array(s),u=0,c=0,f=0,h=Math.abs,d=t[c],p=h(d),g=e[f],v=h(g);v>p?(o=d,c+=1,r>c&&(d=t[c],p=h(d))):(o=g,f+=1,i>f&&(g=e[f],v=h(g))),r>c&&v>p||f>=i?(a=d,c+=1,r>c&&(d=t[c],p=h(d))):(a=g,f+=1,i>f&&(g=e[f],v=h(g)));for(var m,y,b,x,_,w=a+o,A=w-a,k=o-A,M=k,E=w;r>c&&i>f;)v>p?(a=d,c+=1,r>c&&(d=t[c],p=h(d))):(a=g,f+=1,i>f&&(g=e[f],v=h(g))),o=M,w=a+o,A=w-a,k=o-A,k&&(l[u++]=k),m=E+w,y=m-E,b=m-y,x=w-y,_=E-b,M=_+x,E=m;for(;r>c;)a=d,o=M,w=a+o,A=w-a,k=o-A,k&&(l[u++]=k),m=E+w,y=m-E,b=m-y,x=w-y,_=E-b,M=_+x,E=m,c+=1,r>c&&(d=t[c]);for(;i>f;)a=g,o=M,w=a+o,A=w-a,k=o-A,k&&(l[u++]=k),m=E+w,y=m-E,b=m-y,x=w-y,_=E-b,M=_+x,E=m,f+=1,i>f&&(g=e[f]);return M&&(l[u++]=M),E&&(l[u++]=E),u||(l[u++]=0),l.length=u,l}e.exports=i},{}],137:[function(t,e,r){"use strict";function n(t){return t.split("").map(function(t){return t in i?i[t]:""}).join("")}e.exports=n;var i={" ":" ",0:"\u2070",1:"\xb9",2:"\xb2",3:"\xb3",4:"\u2074",5:"\u2075",6:"\u2076",7:"\u2077",8:"\u2078",9:"\u2079","+":"\u207a","-":"\u207b",a:"\u1d43",b:"\u1d47",c:"\u1d9c",d:"\u1d48",e:"\u1d49",f:"\u1da0",g:"\u1d4d",h:"\u02b0",i:"\u2071",j:"\u02b2",k:"\u1d4f",l:"\u02e1",m:"\u1d50",n:"\u207f",o:"\u1d52",p:"\u1d56",r:"\u02b3",s:"\u02e2",t:"\u1d57",u:"\u1d58",v:"\u1d5b",w:"\u02b7",x:"\u02e3",y:"\u02b8",z:"\u1dbb"}},{}],138:[function(t,e,r){"use strict";function n(t){return"a"+t}function i(t){return"d"+t}function a(t,e){return"c"+t+"_"+e}function o(t){return"s"+t}function s(t,e){return"t"+t+"_"+e}function l(t){return"o"+t}function u(t){return"x"+t}function c(t){return"p"+t}function f(t,e){return"d"+t+"_"+e}function h(t){return"i"+t}function d(t,e){return"u"+t+"_"+e}function p(t){return"b"+t}function g(t){return"y"+t}function v(t){return"e"+t}function m(t){return"v"+t}function y(t,e,r){for(var n=0,i=0;t>i;++i)e&1<e;++e)F.push(c(e),"+=",d(e,x[t]),";");F.push("}")}function R(t){for(var e=t-1;e>=0;--e)S(e,0);for(var r=[],e=0;N>e;++e)L[e]?r.push(i(e)+".get("+c(e)+")"):r.push(i(e)+"["+c(e)+"]");for(var e=0;b>e;++e)r.push(u(e));F.push(A,"[",E,"++]=phase(",r.join(),");");for(var e=0;t>e;++e)C(e);for(var n=0;N>n;++n)F.push(c(n),"+=",d(n,x[t]),";")}function I(t){for(var e=0;N>e;++e)L[e]?F.push(a(e,0),"=",i(e),".get(",c(e),");"):F.push(a(e,0),"=",i(e),"[",c(e),"];");for(var r=[],e=0;N>e;++e)r.push(a(e,0));for(var e=0;b>e;++e)r.push(u(e));F.push(p(0),"=",A,"[",E,"]=phase(",r.join(),");");for(var n=1;1<n;++n)F.push(p(n),"=",A,"[",E,"+",v(n),"];");for(var o=[],n=1;1<n;++n)o.push("("+p(0)+"!=="+p(n)+")");F.push("if(",o.join("||"),"){");for(var s=[],e=0;z>e;++e)s.push(h(e));for(var e=0;N>e;++e){s.push(a(e,0));for(var n=1;1<n;++n)L[e]?F.push(a(e,n),"=",i(e),".get(",c(e),"+",f(e,n),");"):F.push(a(e,n),"=",i(e),"[",c(e),"+",f(e,n),"];"),s.push(a(e,n))}for(var e=0;1<e;++e)s.push(p(e));for(var e=0;b>e;++e)s.push(u(e)); +-F.push("vertex(",s.join(),");",m(0),"=",w,"[",E,"]=",k,"++;");for(var l=(1<n;++n)if(0===(t&~(1<0;_=_-1&g)x.push(w+"["+E+"+"+v(_)+"]");x.push(m(0));for(var _=0;N>_;++_)1&n?x.push(a(_,l),a(_,g)):x.push(a(_,g),a(_,l));1&n?x.push(d,y):x.push(y,d);for(var _=0;b>_;++_)x.push(u(_));F.push("if(",d,"!==",y,"){","face(",x.join(),")}")}F.push("}",E,"+=1;")}function P(){for(var t=1;1<t;++t)F.push(T,"=",v(t),";",v(t),"=",g(t),";",g(t),"=",T,";")}function O(t,e){if(0>t)return void I(e);R(t),F.push("if(",o(x[t]),">0){",h(x[t]),"=1;"),O(t-1,e|1<r;++r)F.push(c(r),"+=",d(r,x[t]),";");t===z-1&&(F.push(E,"=0;"),P()),S(t,2),O(t-1,e),t===z-1&&(F.push("if(",h(x[z-1]),"&1){",E,"=0;}"),P()),C(t),F.push("}")}var N=L.length,z=x.length;if(2>z)throw new Error("ndarray-extract-contour: Dimension must be at least 2");for(var D="extractContour"+x.join("_"),F=[],B=[],j=[],U=0;N>U;++U)j.push(n(U));for(var U=0;b>U;++U)j.push(u(U));for(var U=0;z>U;++U)B.push(o(U)+"="+n(0)+".shape["+U+"]|0");for(var U=0;N>U;++U){B.push(i(U)+"="+n(U)+".data",l(U)+"="+n(U)+".offset|0");for(var V=0;z>V;++V)B.push(s(U,V)+"="+n(U)+".stride["+V+"]|0")}for(var U=0;N>U;++U){B.push(c(U)+"="+l(U)),B.push(a(U,0));for(var V=1;1<V;++V){for(var q=[],H=0;z>H;++H)V&1<U;++U)for(var V=0;z>V;++V){var G=[s(U,x[V])];V>0&&G.push(s(U,x[V-1])+"*"+o(x[V-1])),B.push(d(U,x[V])+"=("+G.join("-")+")|0")}for(var U=0;z>U;++U)B.push(h(U)+"=0");B.push(k+"=0");for(var X=["2"],U=z-2;U>=0;--U)X.push(o(x[U]));B.push(M+"=("+X.join("*")+")|0",A+"=mallocUint32("+M+")",w+"=mallocUint32("+M+")",E+"=0"),B.push(p(0)+"=0");for(var V=1;1<V;++V){for(var Y=[],W=[],H=0;z>H;++H)V&1<n&&e("Must have at least one array argument");var i=t.scalarArguments||0;0>i&&e("Scalar arg count must be > 0"),"function"!=typeof t.vertex&&e("Must specify vertex creation function"),"function"!=typeof t.cell&&e("Must specify cell creation function"),"function"!=typeof t.phase&&e("Must specify phase function");for(var a=t.getters||[],o=new Array(n),s=0;n>s;++s)a.indexOf(s)>=0?o[s]=!0:o[s]=!1;return b(t.vertex,t.cell,t.phase,i,r,o)}var _=t("typedarray-pool");e.exports=x;var w="V",A="P",k="N",M="Q",E="X",T="T"},{"typedarray-pool":151}],139:[function(t,e,r){function n(t){if(0>t)return Number("0/0");for(var e=s[0],r=s.length-1;r>0;--r)e+=s[r]/(t+r);var n=t+o+.5;return.5*Math.log(2*Math.PI)+(t+.5)*Math.log(n)-n+Math.log(e)-Math.log(t)}var i=7,a=[.9999999999998099,676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,1.5056327351493116e-7],o=607/128,s=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22];e.exports=function l(t){if(.5>t)return Math.PI/(Math.sin(Math.PI*t)*l(1-t));if(t>100)return Math.exp(n(t));t-=1;for(var e=a[0],r=1;i+2>r;r++)e+=a[r]/(t+r);var o=t+i+.5;return Math.sqrt(2*Math.PI)*Math.pow(o,t+.5)*Math.exp(-o)*e},e.exports.log=n},{}],140:[function(t,e,r){"use strict";function n(t){var e=t.length;if(i>e){for(var r=1,n=0;e>n;++n)for(var o=0;n>o;++o)if(t[n]n;++n)s[n]=0;for(var r=1,n=0;e>n;++n)if(!s[n]){var l=1;s[n]=1;for(var o=t[n];o!==n;o=t[o]){if(s[o])return a.freeUint8(s),0;l+=1,s[o]=1}1&l||(r=-r)}return a.freeUint8(s),r}e.exports=n;var i=32,a=t("typedarray-pool")},{"typedarray-pool":151}],141:[function(t,e,r){"use strict";function n(t){var e=t.length;switch(e){case 0:case 1:return 0;case 2:return t[1]}var r,n,i,s=a.mallocUint32(e),l=a.mallocUint32(e),u=0;for(o(t,l),i=0;e>i;++i)s[i]=t[i];for(i=e-1;i>0;--i)n=l[i],r=s[i],s[i]=s[n],s[n]=r,l[i]=l[r],l[r]=n,u=(u+r)*i;return a.freeUint32(l),a.freeUint32(s),u}function i(t,e,r){switch(t){case 0:return r?r:[];case 1:return r?(r[0]=0,r):[0];case 2:return r?(e?(r[0]=0,r[1]=1):(r[0]=1,r[1]=0),r):e?[0,1]:[1,0]}r=r||new Array(t);var n,i,a,o=1;for(r[0]=0,a=1;t>a;++a)r[a]=a,o=o*a|0;for(a=t-1;a>0;--a)n=e/o|0,e=e-n*o|0,o=o/a|0,i=0|r[a],r[a]=0|r[n],r[n]=0|i;return r}var a=t("typedarray-pool"),o=t("invert-permutation");r.rank=n,r.unrank=i},{"invert-permutation":142,"typedarray-pool":151}],142:[function(t,e,r){"use strict";function n(t,e){e=e||new Array(t.length);for(var r=0;rt)return[];if(0===t)return[[0]];for(var e=0|Math.round(o(t+1)),r=[],n=0;e>n;++n){for(var s=i.unrank(t,n),l=[0],u=0,c=0;c= 0) !== (_inline_1_db >= 0)) {\n _inline_1_arg2_.push(_inline_1_arg4_[0] + 0.5 + 0.5 * (_inline_1_da + _inline_1_db) / (_inline_1_da - _inline_1_db))\n }\n }",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg3_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:[],localVars:["_inline_1_da","_inline_1_db"]},funcName:"zeroCrossings"})},{"cwise-compiler":58}],145:[function(t,e,r){"use strict";function n(t,e){var r=[];return e=+e||0,i(t.hi(t.shape[0]-1),r,e),r}e.exports=n;var i=t("./lib/zc-core")},{"./lib/zc-core":144}],146:[function(t,e,r){"use strict";function n(t,e){var r=t.length,n=["'use strict';"],i="surfaceNets"+t.join("_")+"d"+e;n.push("var contour=genContour({","order:[",t.join(),"],","scalarArguments: 3,","phase:function phaseFunc(p,a,b,c) { return (p > c)|0 },"),"generic"===e&&n.push("getters:[0],");for(var a=[],l=[],u=0;r>u;++u)a.push("d"+u),l.push("d"+u);for(var u=0;1<u;++u)a.push("v"+u),l.push("v"+u);for(var u=0;1<u;++u)a.push("p"+u),l.push("p"+u);a.push("a","b","c"),l.push("a","c"),n.push("vertex:function vertexFunc(",a.join(),"){");for(var c=[],u=0;1<u;++u)c.push("(p"+u+"<<"+u+")");n.push("var m=(",c.join("+"),")|0;if(m===0||m===",(1<<(1<=1<<(1<>>7){");for(var u=0;1<<(1<u;++u){if(1<<(1<128&&u%128===0){f.length>0&&h.push("}}");var d="vExtra"+f.length;n.push("case ",u>>>7,":",d,"(m&0x7f,",l.join(),");break;"),h=["function ",d,"(m,",l.join(),"){switch(m){"],f.push(h)}h.push("case ",127&u,":");for(var p=new Array(r),g=new Array(r),v=new Array(r),m=new Array(r),y=0,b=0;r>b;++b)p[b]=[],g[b]=[],v[b]=0,m[b]=0;for(var b=0;1<b;++b)for(var x=0;r>x;++x){var _=b^1<b)&&!(u&1<<_)!=!(u&1<w?(p[x].push("-v"+b+"-v"+_),v[x]+=2):(p[x].push("v"+b+"+v"+_),v[x]-=2),y+=1;for(var A=0;r>A;++A)A!==x&&(_&1<x;++x)if(0===p[x].length)k.push("d"+x+"-0.5");else{var M="";v[x]<0?M=v[x]+"*c":v[x]>0&&(M="+"+v[x]+"*c");var E=.5*(p[x].length/y),T=.5+.5*(m[x]/y);k.push("d"+x+"-"+T+"-"+E+"*("+p[x].join("+")+M+")/("+g[x].join("+")+")")}h.push("a.push([",k.join(),"]);","break;")}n.push("}},"),f.length>0&&h.push("}}");for(var L=[],u=0;1<u;++u)L.push("v"+u);L.push("c0","c1","p0","p1","a","b","c"),n.push("cell:function cellFunc(",L.join(),"){");var S=s(r-1);n.push("if(p0){b.push(",S.map(function(t){return"["+t.map(function(t){return"v"+t})+"]"}).join(),")}else{b.push(",S.map(function(t){var e=t.slice();return e.reverse(),"["+e.map(function(t){return"v"+t})+"]"}).join(),")}}});function ",i,"(array,level){var verts=[],cells=[];contour(array,verts,cells,level);return {positions:verts,cells:cells};} return ",i,";");for(var u=0;uo;++o)i[o]=[r[o]],a[o]=[o];return{positions:i,cells:a}}function a(t,e){if(t.dimension<=0)return{positions:[],cells:[]};if(1===t.dimension)return i(t,e);var r=t.order.join()+"-"+t.dtype,a=u[r],e=+e||0;return a||(a=u[r]=n(t.order,t.dtype)),a(t,e)}e.exports=a;var o=t("ndarray-extract-contour"),s=t("triangulate-hypercube"),l=t("zero-crossings"),u={}},{"ndarray-extract-contour":138,"triangulate-hypercube":143,"zero-crossings":145}],147:[function(t,e,r){(function(r){"use strict";function n(t){for(var e=t.cells,r=t.positions,n=new Float32Array(6*e.length),i=0,a=0,o=0;ol;++l){var u=r[s[l]];n[i++]=u[0],n[i++]=u[1]+1.4,a=Math.max(u[0],a)}return{data:n,shape:a}}function i(t,e){var r=s[t];r||(r=s[t]={" ":{data:new Float32Array(0),shape:.2}});var o=r[e];if(!o)if(e.length<=1||!/\d/.test(e))o=r[e]=n(a(e,{triangles:!0,font:t,textAlign:"left",textBaseline:"alphabetic"}));else{for(var l=e.split(/(\d|\s)/),u=new Array(l.length),c=0,f=0,h=0;h0&&(f+=.02);for(var d=new Float32Array(c),p=0,g=-.5*f,h=0;h.5?l/(2-a-o):l/(a+o),a){case t:n=(e-r)/l+(r>e?6:0);break;case e:n=(r-t)/l+2;break;case r:n=(t-e)/l+4}n/=6}return{h:n,s:i,l:s}}function o(t,e,r){function n(t,e,r){return 0>r&&(r+=1),r>1&&(r-=1),1/6>r?t+6*(e-t)*r:.5>r?e:2/3>r?t+(e-t)*(2/3-r)*6:t}var i,a,o;if(t=E(t,360),e=E(e,100),r=E(r,100),0===e)i=a=o=r;else{var s=.5>r?r*(1+e):r+e-r*e,l=2*r-s;i=n(l,s,t+1/3),a=n(l,s,t),o=n(l,s,t-1/3)}return{r:255*i,g:255*a,b:255*o}}function s(t,e,r){t=E(t,255),e=E(e,255),r=E(r,255);var n,i,a=q(t,e,r),o=V(t,e,r),s=a,l=a-o;if(i=0===a?0:l/a,a==o)n=0;else{switch(a){case t:n=(e-r)/l+(r>e?6:0);break;case e:n=(r-t)/l+2;break;case r:n=(t-e)/l+4}n/=6}return{h:n,s:i,v:s}}function l(t,e,r){t=6*E(t,360),e=E(e,100),r=E(r,100);var n=j.floor(t),i=t-n,a=r*(1-e),o=r*(1-i*e),s=r*(1-(1-i)*e),l=n%6,u=[r,o,a,a,s,r][l],c=[s,r,r,o,a,a][l],f=[a,a,s,r,r,o][l];return{r:255*u,g:255*c,b:255*f}}function u(t,e,r,n){var i=[R(U(t).toString(16)),R(U(e).toString(16)),R(U(r).toString(16))];return n&&i[0].charAt(0)==i[0].charAt(1)&&i[1].charAt(0)==i[1].charAt(1)&&i[2].charAt(0)==i[2].charAt(1)?i[0].charAt(0)+i[1].charAt(0)+i[2].charAt(0):i.join("")}function c(t,e,r,n){var i=[R(P(n)),R(U(t).toString(16)),R(U(e).toString(16)),R(U(r).toString(16))];return i.join("")}function f(t,r){r=0===r?0:r||10;var n=e(t).toHsl();return n.s-=r/100,n.s=T(n.s),e(n)}function h(t,r){r=0===r?0:r||10;var n=e(t).toHsl();return n.s+=r/100,n.s=T(n.s),e(n)}function d(t){return e(t).desaturate(100)}function p(t,r){r=0===r?0:r||10;var n=e(t).toHsl();return n.l+=r/100,n.l=T(n.l),e(n)}function g(t,r){r=0===r?0:r||10;var n=e(t).toRgb();return n.r=q(0,V(255,n.r-U(255*-(r/100)))),n.g=q(0,V(255,n.g-U(255*-(r/100)))),n.b=q(0,V(255,n.b-U(255*-(r/100)))),e(n)}function v(t,r){r=0===r?0:r||10;var n=e(t).toHsl();return n.l-=r/100,n.l=T(n.l),e(n)}function m(t,r){var n=e(t).toHsl(),i=(U(n.h)+r)%360;return n.h=0>i?360+i:i,e(n)}function y(t){var r=e(t).toHsl();return r.h=(r.h+180)%360,e(r)}function b(t){var r=e(t).toHsl(),n=r.h;return[e(t),e({h:(n+120)%360,s:r.s,l:r.l}),e({h:(n+240)%360,s:r.s,l:r.l})]}function x(t){var r=e(t).toHsl(),n=r.h;return[e(t),e({h:(n+90)%360,s:r.s,l:r.l}),e({h:(n+180)%360,s:r.s,l:r.l}),e({h:(n+270)%360,s:r.s,l:r.l})]}function _(t){var r=e(t).toHsl(),n=r.h;return[e(t),e({h:(n+72)%360,s:r.s,l:r.l}),e({h:(n+216)%360,s:r.s,l:r.l})]}function w(t,r,n){r=r||6,n=n||30;var i=e(t).toHsl(),a=360/n,o=[e(t)];for(i.h=(i.h-(a*r>>1)+720)%360;--r;)i.h=(i.h+a)%360,o.push(e(i));return o}function A(t,r){r=r||6;for(var n=e(t).toHsv(),i=n.h,a=n.s,o=n.v,s=[],l=1/r;r--;)s.push(e({h:i,s:a,v:o})),o=(o+l)%1;return s}function k(t){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[t[r]]=r);return e}function M(t){return t=parseFloat(t),(isNaN(t)||0>t||t>1)&&(t=1),t}function E(t,e){S(t)&&(t="100%");var r=C(t);return t=V(e,q(0,parseFloat(t))),r&&(t=parseInt(t*e,10)/100),j.abs(t-e)<1e-6?1:t%e/parseFloat(e)}function T(t){return V(1,q(0,t))}function L(t){return parseInt(t,16)}function S(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)}function C(t){return"string"==typeof t&&-1!=t.indexOf("%")}function R(t){return 1==t.length?"0"+t:""+t}function I(t){return 1>=t&&(t=100*t+"%"),t}function P(t){return Math.round(255*parseFloat(t)).toString(16)}function O(t){return L(t)/255}function N(t){t=t.replace(D,"").replace(F,"").toLowerCase();var e=!1;if(G[t])t=G[t],e=!0;else if("transparent"==t)return{r:0,g:0,b:0,a:0,format:"name"};var r;return(r=Y.rgb.exec(t))?{r:r[1],g:r[2],b:r[3]}:(r=Y.rgba.exec(t))?{r:r[1],g:r[2],b:r[3],a:r[4]}:(r=Y.hsl.exec(t))?{h:r[1],s:r[2],l:r[3]}:(r=Y.hsla.exec(t))?{h:r[1],s:r[2],l:r[3],a:r[4]}:(r=Y.hsv.exec(t))?{h:r[1],s:r[2],v:r[3]}:(r=Y.hsva.exec(t))?{h:r[1],s:r[2],v:r[3],a:r[4]}:(r=Y.hex8.exec(t))?{a:O(r[1]),r:L(r[2]),g:L(r[3]),b:L(r[4]),format:e?"name":"hex8"}:(r=Y.hex6.exec(t))?{r:L(r[1]),g:L(r[2]),b:L(r[3]),format:e?"name":"hex"}:(r=Y.hex3.exec(t))?{r:L(r[1]+""+r[1]),g:L(r[2]+""+r[2]),b:L(r[3]+""+r[3]),format:e?"name":"hex"}:!1}function z(t){var e,r;return t=t||{level:"AA",size:"small"},e=(t.level||"AA").toUpperCase(),r=(t.size||"small").toLowerCase(),"AA"!==e&&"AAA"!==e&&(e="AA"),"small"!==r&&"large"!==r&&(r="small"),{level:e,size:r}}var D=/^\s+/,F=/\s+$/,B=0,j=Math,U=j.round,V=j.min,q=j.max,H=j.random;e.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var t,e,r,n,i,a,o=this.toRgb();return t=o.r/255,e=o.g/255,r=o.b/255,n=.03928>=t?t/12.92:Math.pow((t+.055)/1.055,2.4),i=.03928>=e?e/12.92:Math.pow((e+.055)/1.055,2.4),a=.03928>=r?r/12.92:Math.pow((r+.055)/1.055,2.4),.2126*n+.7152*i+.0722*a},setAlpha:function(t){return this._a=M(t),this._roundA=U(100*this._a)/100,this},toHsv:function(){var t=s(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=s(this._r,this._g,this._b),e=U(360*t.h),r=U(100*t.s),n=U(100*t.v);return 1==this._a?"hsv("+e+", "+r+"%, "+n+"%)":"hsva("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHsl:function(){var t=a(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=a(this._r,this._g,this._b),e=U(360*t.h),r=U(100*t.s),n=U(100*t.l);return 1==this._a?"hsl("+e+", "+r+"%, "+n+"%)":"hsla("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHex:function(t){return u(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(){return c(this._r,this._g,this._b,this._a)},toHex8String:function(){return"#"+this.toHex8()},toRgb:function(){return{r:U(this._r),g:U(this._g),b:U(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+U(this._r)+", "+U(this._g)+", "+U(this._b)+")":"rgba("+U(this._r)+", "+U(this._g)+", "+U(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:U(100*E(this._r,255))+"%",g:U(100*E(this._g,255))+"%",b:U(100*E(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+U(100*E(this._r,255))+"%, "+U(100*E(this._g,255))+"%, "+U(100*E(this._b,255))+"%)":"rgba("+U(100*E(this._r,255))+"%, "+U(100*E(this._g,255))+"%, "+U(100*E(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":this._a<1?!1:X[u(this._r,this._g,this._b,!0)]||!1},toFilter:function(t){var r="#"+c(this._r,this._g,this._b,this._a),n=r,i=this._gradientType?"GradientType = 1, ":"";if(t){var a=e(t);n=a.toHex8String()}return"progid:DXImageTransform.Microsoft.gradient("+i+"startColorstr="+r+",endColorstr="+n+")"},toString:function(t){var e=!!t;t=t||this._format;var r=!1,n=this._a<1&&this._a>=0,i=!e&&n&&("hex"===t||"hex6"===t||"hex3"===t||"name"===t);return i?"name"===t&&0===this._a?this.toName():this.toRgbString():("rgb"===t&&(r=this.toRgbString()),"prgb"===t&&(r=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(r=this.toHexString()),"hex3"===t&&(r=this.toHexString(!0)),"hex8"===t&&(r=this.toHex8String()),"name"===t&&(r=this.toName()),"hsl"===t&&(r=this.toHslString()),"hsv"===t&&(r=this.toHsvString()),r||this.toHexString())},clone:function(){return e(this.toString())},_applyModification:function(t,e){var r=t.apply(null,[this].concat([].slice.call(e)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(p,arguments)},brighten:function(){return this._applyModification(g,arguments)},darken:function(){return this._applyModification(v,arguments)},desaturate:function(){return this._applyModification(f,arguments)},saturate:function(){return this._applyModification(h,arguments)},greyscale:function(){return this._applyModification(d,arguments)},spin:function(){return this._applyModification(m,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(w,arguments)},complement:function(){return this._applyCombination(y,arguments)},monochromatic:function(){return this._applyCombination(A,arguments)},splitcomplement:function(){return this._applyCombination(_,arguments)},triad:function(){return this._applyCombination(b,arguments)},tetrad:function(){return this._applyCombination(x,arguments)}},e.fromRatio=function(t,r){if("object"==typeof t){var n={};for(var i in t)t.hasOwnProperty(i)&&("a"===i?n[i]=t[i]:n[i]=I(t[i]));t=n}return e(t,r)},e.equals=function(t,r){return t&&r?e(t).toRgbString()==e(r).toRgbString():!1},e.random=function(){return e.fromRatio({r:H(),g:H(),b:H()})},e.mix=function(t,r,n){n=0===n?0:n||50;var i,a=e(t).toRgb(),o=e(r).toRgb(),s=n/100,l=2*s-1,u=o.a-a.a;i=l*u==-1?l:(l+u)/(1+l*u),i=(i+1)/2;var c=1-i,f={r:o.r*i+a.r*c,g:o.g*i+a.g*c,b:o.b*i+a.b*c,a:o.a*s+a.a*(1-s)};return e(f)},e.readability=function(t,r){var n=e(t),i=e(r);return(Math.max(n.getLuminance(),i.getLuminance())+.05)/(Math.min(n.getLuminance(),i.getLuminance())+.05)},e.isReadable=function(t,r,n){var i,a,o=e.readability(t,r);switch(a=!1,i=z(n),i.level+i.size){case"AAsmall":case"AAAlarge":a=o>=4.5;break;case"AAlarge":a=o>=3;break;case"AAAsmall":a=o>=7}return a},e.mostReadable=function(t,r,n){var i,a,o,s,l=null,u=0;n=n||{},a=n.includeFallbackColors,o=n.level,s=n.size;for(var c=0;cu&&(u=i,l=e(r[c]));return e.isReadable(t,l,{level:o,size:s})||!a?l:(n.includeFallbackColors=!1,e.mostReadable(t,["#fff","#000"],n))};var G=e.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},X=e.hexNames=k(G),Y=function(){var t="[-\\+]?\\d+%?",e="[-\\+]?\\d*\\.\\d+%?",r="(?:"+e+")|(?:"+t+")",n="[\\s|\\(]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")\\s*\\)?",i="[\\s|\\(]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")\\s*\\)?";return{rgb:new RegExp("rgb"+n),rgba:new RegExp("rgba"+i),hsl:new RegExp("hsl"+n),hsla:new RegExp("hsla"+i),hsv:new RegExp("hsv"+n),hsva:new RegExp("hsva"+i),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();"undefined"!=typeof r&&r.exports?r.exports=e:"function"==typeof t&&t.amd?t(function(){return e}):window.tinycolor=e}()},{}],149:[function(t,e,r){"use strict";function n(t,e,r){var n=t*e,a=i*t,o=a-t,s=a-o,l=t-s,u=i*e,c=u-e,f=u-c,h=e-f,d=n-s*f,p=d-l*f,g=p-s*h,v=l*h-g;return r?(r[0]=v,r[1]=n,r):[v,n]}e.exports=n;var i=+(Math.pow(2,27)+1)},{}],150:[function(t,e,r){"use strict";function n(t,e,r){var n=t+e,i=n-t,a=n-i,o=e-i,s=t-a;return r?(r[0]=s+o,r[1]=n,r):[s+o,n]}e.exports=n},{}],151:[function(t,e,r){(function(e,n){"use strict";function i(t){if(t){var e=t.length||t.byteLength,r=y.log2(e);w[r].push(t)}}function a(t){i(t.buffer)}function o(t){var t=y.nextPow2(t),e=y.log2(t),r=w[e];return r.length>0?r.pop():new ArrayBuffer(t)}function s(t){return new Uint8Array(o(t),0,t)}function l(t){return new Uint16Array(o(2*t),0,t)}function u(t){return new Uint32Array(o(4*t),0,t)}function c(t){return new Int8Array(o(t),0,t)}function f(t){return new Int16Array(o(2*t),0,t)}function h(t){return new Int32Array(o(4*t),0,t)}function d(t){return new Float32Array(o(4*t),0,t)}function p(t){return new Float64Array(o(8*t),0,t)}function g(t){return x?new Uint8ClampedArray(o(t),0,t):s(t)}function v(t){return new DataView(o(t),0,t)}function m(t){t=y.nextPow2(t);var e=y.log2(t),r=A[e];return r.length>0?r.pop():new n(t)}var y=t("bit-twiddle"),b=t("dup");e.__TYPEDARRAY_POOL||(e.__TYPEDARRAY_POOL={UINT8:b([32,0]),UINT16:b([32,0]),UINT32:b([32,0]),INT8:b([32,0]),INT16:b([32,0]),INT32:b([32,0]),FLOAT:b([32,0]),DOUBLE:b([32,0]),DATA:b([32,0]),UINT8C:b([32,0]),BUFFER:b([32,0])});var x="undefined"!=typeof Uint8ClampedArray,_=e.__TYPEDARRAY_POOL;_.UINT8C||(_.UINT8C=b([32,0])),_.BUFFER||(_.BUFFER=b([32,0]));var w=_.DATA,A=_.BUFFER;r.free=function(t){if(n.isBuffer(t))A[y.log2(t.length)].push(t);else{if("[object ArrayBuffer]"!==Object.prototype.toString.call(t)&&(t=t.buffer),!t)return;var e=t.length||t.byteLength,r=0|y.log2(e);w[r].push(t)}},r.freeUint8=r.freeUint16=r.freeUint32=r.freeInt8=r.freeInt16=r.freeInt32=r.freeFloat32=r.freeFloat=r.freeFloat64=r.freeDouble=r.freeUint8Clamped=r.freeDataView=a,r.freeArrayBuffer=i,r.freeBuffer=function(t){A[y.log2(t.length)].push(t)},r.malloc=function(t,e){if(void 0===e||"arraybuffer"===e)return o(t);switch(e){case"uint8":return s(t);case"uint16":return l(t);case"uint32":return u(t);case"int8":return c(t);case"int16":return f(t);case"int32":return h(t);case"float":case"float32":return d(t);case"double":case"float64":return p(t);case"uint8_clamped":return g(t);case"buffer":return m(t);case"data":case"dataview":return v(t);default:return null}return null},r.mallocArrayBuffer=o,r.mallocUint8=s,r.mallocUint16=l,r.mallocUint32=u,r.mallocInt8=c,r.mallocInt16=f,r.mallocInt32=h,r.mallocFloat32=r.mallocFloat=d,r.mallocFloat64=r.mallocDouble=p,r.mallocUint8Clamped=g,r.mallocDataView=v,r.mallocBuffer=m,r.clearCache=function(){for(var t=0;32>t;++t)_.UINT8[t].length=0,_.UINT16[t].length=0,_.UINT32[t].length=0,_.INT8[t].length=0,_.INT16[t].length=0,_.INT32[t].length=0,_.FLOAT[t].length=0,_.DOUBLE[t].length=0,_.UINT8C[t].length=0,w[t].length=0,A[t].length=0}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("buffer").Buffer)},{"bit-twiddle":9,buffer:10,dup:63}],152:[function(t,e,r){"use strict";function n(t,e){for(var r=1,n=t.length,i=t[0],a=t[0],o=1;n>o;++o)if(a=i,i=t[o],e(i,a)){if(o===r){r++;continue}t[r++]=i}return t.length=r,t}function i(t){for(var e=1,r=t.length,n=t[0],i=t[0],a=1;r>a;++a,i=n)if(i=n,n=t[a],n!==i){if(a===e){e++;continue}t[e++]=n}return t.length=e,t}function a(t,e,r){return 0===t.length?t:e?(r||t.sort(e),n(t,e)):(r||t.sort(),i(t))}e.exports=a},{}],153:[function(t,e,r){"use strict";function n(t,e){return"object"==typeof e&&null!==e||(e={}),i(t,e.canvas||a,e.context||o,e)}e.exports=n;var i=t("./lib/vtext"),a=null,o=null;"undefined"!=typeof document&&(a=document.createElement("canvas"),a.width=8192,a.height=1024,o=a.getContext("2d"))},{"./lib/vtext":154}],154:[function(t,e,r){"use strict";function n(t,e,r){for(var n=e.textAlign||"start",i=e.textBaseline||"alphabetic",a=[1<<30,1<<30],o=[0,0],s=t.length,l=0;s>l;++l)for(var u=t[l],c=0;2>c;++c)a[c]=0|Math.min(a[c],u[c]),o[c]=0|Math.max(o[c],u[c]);var f=0;switch(n){case"center":f=-.5*(a[0]+o[0]);break;case"right":case"end":f=-o[0];break;case"left":case"start":f=-a[0];break;default:throw new Error("vectorize-text: Unrecognized textAlign: '"+n+"'")}var h=0;switch(i){case"hanging":case"top":h=-a[1];break;case"middle":h=-.5*(a[1]+o[1]);break;case"alphabetic":case"ideographic":h=-3*r;break;case"bottom":h=-o[1];break;default:throw new Error("vectorize-text: Unrecoginized textBaseline: '"+i+"'")}var d=1/r;return"lineHeight"in e?d*=+e.lineHeight:"width"in e?d=e.width/(o[0]-a[0]):"height"in e&&(d=e.height/(o[1]-a[1])),t.map(function(t){return[d*(t[0]+f),d*(t[1]+h)]})}function i(t,e,r,n){var i=0|Math.ceil(e.measureText(r).width+2*n);if(i>8192)throw new Error("vectorize-text: String too long (sorry, this will get fixed later)");var a=3*n;t.height=l&&o.push(s)}for(;o.length>0;){var u=o.pop();n[u]=!1;for(var c=r[u],s=0;sn;++n){var a=t[n];e=Math.max(e,a[0],a[1]); +-}e=(0|e)+1}e=0|e;for(var o=new Array(e),n=0;e>n;++n)o[n]=[];for(var n=0;r>n;++n){var a=t[n];o[a[0]].push(a[1]),o[a[1]].push(a[0])}for(var s=0;e>s;++s)i(o[s],function(t,e){return t-e});return o}e.exports=n;var i=t("uniq")},{uniq:152}],157:[function(t,e,r){"use strict";function n(t,e){function r(t,e){var r=u[e][t[e]];r.splice(r.indexOf(t),1)}function n(t,n,a){for(var o,s,l,c=0;2>c;++c)if(u[c][n].length>0){o=u[c][n][0],l=c;break}s=o[1^l];for(var f=0;2>f;++f)for(var h=u[f][n],d=0;d0&&(o=p,s=g,l=f)}return a?s:(o&&r(o,l),s)}function a(t,a){var o=u[a][t][0],s=[t];r(o,a);for(var l=o[1^a];;){for(;l!==t;)s.push(l),l=n(s[s.length-2],l,!1);if(u[0][t].length+u[1][t].length===0)break;var c=s[s.length-1],f=t,h=s[1],d=n(c,f,!0);if(i(e[c],e[f],e[h],e[d])<0)break;s.push(t),l=n(c,f)}return s}function o(t,e){return e[1]===e[e.length-1]}for(var s=0|e.length,l=t.length,u=[new Array(s),new Array(s)],c=0;s>c;++c)u[0][c]=[],u[1][c]=[];for(var c=0;l>c;++c){var f=t[c];u[0][f[0]].push(f),u[1][f[1]].push(f)}for(var h=[],c=0;s>c;++c)u[0][c].length+u[1][c].length===0&&h.push([c]);for(var c=0;s>c;++c)for(var d=0;2>d;++d){for(var p=[];u[d][c].length>0;){var g=(u[0][c].length,a(c,d));o(p,g)?p.push.apply(p,g):(p.length>0&&h.push(p),p=g)}p.length>0&&h.push(p)}return h}e.exports=n;var i=t("compare-angle")},{"compare-angle":158}],158:[function(t,e,r){"use strict";function n(t,e,r){var n=s(t[0],-e[0]),i=s(t[1],-e[1]),a=s(r[0],-e[0]),o=s(r[1],-e[1]),c=u(l(n,a),l(i,o));return c[c.length-1]>=0}function i(t,e,r,i){var s=a(e,r,i);if(0===s){var l=o(a(t,e,r)),u=o(a(t,e,i));if(l===u){if(0===l){var c=n(t,e,r),f=n(t,e,i);return c===f?0:c?1:-1}return 0}return 0===u?l>0?-1:n(t,e,i)?-1:1:0===l?u>0?1:n(t,e,r)?1:-1:o(u-l)}var h=a(t,e,r);if(h>0)return s>0&&a(t,e,i)>0?1:-1;if(0>h)return s>0||a(t,e,i)>0?1:-1;var d=a(t,e,i);return d>0?1:n(t,e,r)?1:-1}e.exports=i;var a=t("robust-orientation"),o=t("signum"),s=t("two-sum"),l=t("robust-product"),u=t("robust-sum")},{"robust-orientation":133,"robust-product":159,"robust-sum":136,signum:160,"two-sum":150}],159:[function(t,e,r){"use strict";function n(t,e){if(1===t.length)return a(e,t[0]);if(1===e.length)return a(t,e[0]);if(0===t.length||0===e.length)return[0];var r=[0];if(t.lengtht?-1:t>0?1:0}},{}],161:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){var o=["function ",t,"(a,l,h,",n.join(","),"){",a?"":"var i=",r?"l-1":"h+1",";while(l<=h){var m=(l+h)>>>1,x=a",i?".get(m)":"[m]"];return a?e.indexOf("c")<0?o.push(";if(x===y){return m}else if(x<=y){"):o.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){"):o.push(";if(",e,"){i=m;"),r?o.push("l=m+1}else{h=m-1}"):o.push("h=m-1}else{l=m+1}"),o.push("}"),a?o.push("return -1};"):o.push("return i};"),o.join("")}function i(t,e,r,i){var a=new Function([n("A","x"+t+"y",e,["y"],!1,i),n("B","x"+t+"y",e,["y"],!0,i),n("P","c(x,y)"+t+"0",e,["y","c"],!1,i),n("Q","c(x,y)"+t+"0",e,["y","c"],!0,i),"function dispatchBsearch",r,"(a,y,c,l,h){if(a.shape){if(typeof(c)==='function'){return Q(a,(l===undefined)?0:l|0,(h===undefined)?a.shape[0]-1:h|0,y,c)}else{return B(a,(c===undefined)?0:c|0,(l===undefined)?a.shape[0]-1:l|0,y)}}else{if(typeof(c)==='function'){return P(a,(l===undefined)?0:l|0,(h===undefined)?a.length-1:h|0,y,c)}else{return A(a,(c===undefined)?0:c|0,(l===undefined)?a.length-1:l|0,y)}}}return dispatchBsearch",r].join(""));return a()}e.exports={ge:i(">=",!1,"GE"),gt:i(">",!1,"GT"),lt:i("<",!0,"LT"),le:i("<=",!0,"LE"),eq:i("-",!0,"EQ",!0)}},{}],162:[function(t,e,r){"use strict";function n(t,e,r,n,i){this.mid=t,this.left=e,this.right=r,this.leftPoints=n,this.rightPoints=i,this.count=(e?e.count:0)+(r?r.count:0)+n.length}function i(t,e){t.mid=e.mid,t.left=e.left,t.right=e.right,t.leftPoints=e.leftPoints,t.rightPoints=e.rightPoints,t.count=e.count}function a(t,e){var r=p(e);t.mid=r.mid,t.left=r.left,t.right=r.right,t.leftPoints=r.leftPoints,t.rightPoints=r.rightPoints,t.count=r.count}function o(t,e){var r=t.intervals([]);r.push(e),a(t,r)}function s(t,e){var r=t.intervals([]),n=r.indexOf(e);return 0>n?y:(r.splice(n,1),a(t,r),b)}function l(t,e,r){for(var n=0;n=0&&t[n][1]>=e;--n){var i=r(t[n]);if(i)return i}}function c(t,e){for(var r=0;r>1],a=[],o=[],s=[],r=0;r3*(e+1)?o(this,t):this.left.insert(t):this.left=p([t]);else if(t[0]>this.mid)this.right?4*(this.right.count+1)>3*(e+1)?o(this,t):this.right.insert(t):this.right=p([t]);else{var r=m.ge(this.leftPoints,t,h),n=m.ge(this.rightPoints,t,d);this.leftPoints.splice(r,0,t),this.rightPoints.splice(n,0,t)}},_.remove=function(t){var e=this.count-this.leftPoints;if(t[1]3*(e-1))return s(this,t);var n=this.left.remove(t);return n===x?(this.left=null,this.count-=1,b):(n===b&&(this.count-=1),n)}if(t[0]>this.mid){if(!this.right)return y;var a=this.left?this.left.count:0;if(4*a>3*(e-1))return s(this,t);var n=this.right.remove(t);return n===x?(this.right=null,this.count-=1,b):(n===b&&(this.count-=1),n)}if(1===this.count)return this.leftPoints[0]===t?x:y;if(1===this.leftPoints.length&&this.leftPoints[0]===t){if(this.left&&this.right){for(var o=this,l=this.left;l.right;)o=l,l=l.right;if(o===this)l.right=this.right;else{var u=this.left,n=this.right;o.count-=l.count,o.right=l.left,l.left=u,l.right=n}i(this,l),this.count=(this.left?this.left.count:0)+(this.right?this.right.count:0)+this.leftPoints.length}else this.left?i(this,this.left):i(this,this.right);return b}for(var u=m.ge(this.leftPoints,t,h);uthis.mid){if(this.right){var r=this.right.queryPoint(t,e);if(r)return r}return u(this.rightPoints,t,e)}return c(this.leftPoints,e)},_.queryInterval=function(t,e,r){if(tthis.mid&&this.right){var n=this.right.queryInterval(t,e,r);if(n)return n}return ethis.mid?u(this.rightPoints,t,r):c(this.leftPoints,r)};var w=g.prototype;w.insert=function(t){this.root?this.root.insert(t):this.root=new n(t[0],null,null,[t],[t])},w.remove=function(t){if(this.root){var e=this.root.remove(t);return e===x&&(this.root=null),e!==y}return!1},w.queryPoint=function(t,e){return this.root?this.root.queryPoint(t,e):void 0},w.queryInterval=function(t,e,r){return e>=t&&this.root?this.root.queryInterval(t,e,r):void 0},Object.defineProperty(w,"count",{get:function(){return this.root?this.root.count:0}}),Object.defineProperty(w,"intervals",{get:function(){return this.root?this.root.intervals([]):[]}})},{"binary-search-bounds":161}],163:[function(t,e,r){"use strict";function n(t,e){var r,n;if(e[0][0]e[1][0])){var i=Math.min(t[0][1],t[1][1]),o=Math.max(t[0][1],t[1][1]),s=Math.min(e[0][1],e[1][1]),l=Math.max(e[0][1],e[1][1]);return s>o?o-s:i>l?i-l:o-l}r=e[1],n=e[0]}var u,c;t[0][1]e[1][0]))return n(e,t);r=e[1],i=e[0]}var o,s;if(t[0][0]t[1][0]))return-n(t,e);o=t[1],s=t[0]}var l=a(r,i,s),u=a(r,i,o);if(0>l){if(0>=u)return l}else if(l>0){if(u>=0)return l}else if(u)return u;if(l=a(s,o,i),u=a(s,o,r),0>l){if(0>=u)return l}else if(l>0){if(u>=0)return l}else if(u)return u;return i[0]-s[0]}e.exports=i;var a=t("robust-orientation")},{"robust-orientation":133}],164:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){this._color=t,this.key=e,this.value=r,this.left=n,this.right=i,this._count=a}function i(t){return new n(t._color,t.key,t.value,t.left,t.right,t._count)}function a(t,e){return new n(t,e.key,e.value,e.left,e.right,e._count)}function o(t){t._count=1+(t.left?t.left._count:0)+(t.right?t.right._count:0)}function s(t,e){this._compare=t,this.root=e}function l(t,e){if(e.left){var r=l(t,e.left);if(r)return r}var r=t(e.key,e.value);return r?r:e.right?l(t,e.right):void 0}function u(t,e,r,n){var i=e(t,n.key);if(0>=i){if(n.left){var a=u(t,e,r,n.left);if(a)return a}var a=r(n.key,n.value);if(a)return a}return n.right?u(t,e,r,n.right):void 0}function c(t,e,r,n,i){var a,o=r(t,i.key),s=r(e,i.key);if(0>=o){if(i.left&&(a=c(t,e,r,n,i.left)))return a;if(s>0&&(a=n(i.key,i.value)))return a}return s>0&&i.right?c(t,e,r,n,i.right):void 0}function f(t,e){this.tree=t,this._stack=e}function h(t,e){t.key=e.key,t.value=e.value,t.left=e.left,t.right=e.right,t._color=e._color,t._count=e._count}function d(t){for(var e,r,n,s,l=t.length-1;l>=0;--l){if(e=t[l],0===l)return void(e._color=m);if(r=t[l-1],r.left===e){if(n=r.right,n.right&&n.right._color===v){if(n=r.right=i(n),s=n.right=i(n.right),r.right=n.left,n.left=r,n.right=s,n._color=r._color,e._color=m,r._color=m,s._color=m,o(r),o(n),l>1){var u=t[l-2];u.left===r?u.left=n:u.right=n}return void(t[l-1]=n)}if(n.left&&n.left._color===v){if(n=r.right=i(n),s=n.left=i(n.left),r.right=s.left,n.left=s.right,s.left=r,s.right=n,s._color=r._color,r._color=m,n._color=m,e._color=m,o(r),o(n),o(s),l>1){var u=t[l-2];u.left===r?u.left=s:u.right=s}return void(t[l-1]=s)}if(n._color===m){if(r._color===v)return r._color=m,void(r.right=a(v,n));r.right=a(v,n);continue}if(n=i(n),r.right=n.left,n.left=r,n._color=r._color,r._color=v,o(r),o(n),l>1){var u=t[l-2];u.left===r?u.left=n:u.right=n}t[l-1]=n,t[l]=r,l+11){var u=t[l-2];u.right===r?u.right=n:u.left=n}return void(t[l-1]=n)}if(n.right&&n.right._color===v){if(n=r.left=i(n),s=n.right=i(n.right),r.left=s.right,n.right=s.left,s.right=r,s.left=n,s._color=r._color,r._color=m,n._color=m,e._color=m,o(r),o(n),o(s),l>1){var u=t[l-2];u.right===r?u.right=s:u.left=s}return void(t[l-1]=s)}if(n._color===m){if(r._color===v)return r._color=m,void(r.left=a(v,n));r.left=a(v,n);continue}if(n=i(n),r.left=n.right,n.right=r,n._color=r._color,r._color=v,o(r),o(n),l>1){var u=t[l-2];u.right===r?u.right=n:u.left=n}t[l-1]=n,t[l]=r,l+1t?-1:t>e?1:0}function g(t){return new s(t||p,null)}e.exports=g;var v=0,m=1,y=s.prototype;Object.defineProperty(y,"keys",{get:function(){var t=[];return this.forEach(function(e,r){t.push(e)}),t}}),Object.defineProperty(y,"values",{get:function(){var t=[];return this.forEach(function(e,r){t.push(r)}),t}}),Object.defineProperty(y,"length",{get:function(){return this.root?this.root._count:0}}),y.insert=function(t,e){for(var r=this._compare,i=this.root,l=[],u=[];i;){var c=r(t,i.key);l.push(i),u.push(c),i=0>=c?i.left:i.right}l.push(new n(v,t,e,null,null,1));for(var f=l.length-2;f>=0;--f){var i=l[f];u[f]<=0?l[f]=new n(i._color,i.key,i.value,l[f+1],i.right,i._count+1):l[f]=new n(i._color,i.key,i.value,i.left,l[f+1],i._count+1)}for(var f=l.length-1;f>1;--f){var h=l[f-1],i=l[f];if(h._color===m||i._color===m)break;var d=l[f-2];if(d.left===h)if(h.left===i){var p=d.right;if(!p||p._color!==v){if(d._color=v,d.left=h.right,h._color=m,h.right=d,l[f-2]=h,l[f-1]=i,o(d),o(h),f>=3){var g=l[f-3];g.left===d?g.left=h:g.right=h}break}h._color=m,d.right=a(m,p),d._color=v,f-=1}else{var p=d.right;if(!p||p._color!==v){if(h.right=i.left,d._color=v,d.left=i.right,i._color=m,i.left=h,i.right=d,l[f-2]=i,l[f-1]=h,o(d),o(h),o(i),f>=3){var g=l[f-3];g.left===d?g.left=i:g.right=i}break}h._color=m,d.right=a(m,p),d._color=v,f-=1}else if(h.right===i){var p=d.left;if(!p||p._color!==v){if(d._color=v,d.right=h.left,h._color=m,h.left=d,l[f-2]=h,l[f-1]=i,o(d),o(h),f>=3){var g=l[f-3];g.right===d?g.right=h:g.left=h}break}h._color=m,d.left=a(m,p),d._color=v,f-=1}else{var p=d.left;if(!p||p._color!==v){if(h.left=i.right,d._color=v,d.right=i.left,i._color=m,i.right=h,i.left=d,l[f-2]=i,l[f-1]=h,o(d),o(h),o(i),f>=3){var g=l[f-3];g.right===d?g.right=i:g.left=i}break}h._color=m,d.left=a(m,p),d._color=v,f-=1}}return l[0]._color=m,new s(r,l[0])},y.forEach=function(t,e,r){if(this.root)switch(arguments.length){case 1:return l(t,this.root);case 2:return u(e,this._compare,t,this.root);case 3:if(this._compare(e,r)>=0)return;return c(e,r,this._compare,t,this.root)}},Object.defineProperty(y,"begin",{get:function(){for(var t=[],e=this.root;e;)t.push(e),e=e.left;return new f(this,t)}}),Object.defineProperty(y,"end",{get:function(){for(var t=[],e=this.root;e;)t.push(e),e=e.right;return new f(this,t)}}),y.at=function(t){if(0>t)return new f(this,[]);for(var e=this.root,r=[];;){if(r.push(e),e.left){if(t=e.right._count)break;e=e.right}return new f(this,[])},y.ge=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),0>=a&&(i=n.length),r=0>=a?r.left:r.right}return n.length=i,new f(this,n)},y.gt=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),0>a&&(i=n.length),r=0>a?r.left:r.right}return n.length=i,new f(this,n)},y.lt=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),a>0&&(i=n.length),r=0>=a?r.left:r.right}return n.length=i,new f(this,n)},y.le=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),a>=0&&(i=n.length),r=0>a?r.left:r.right}return n.length=i,new f(this,n)},y.find=function(t){for(var e=this._compare,r=this.root,n=[];r;){var i=e(t,r.key);if(n.push(r),0===i)return new f(this,n);r=0>=i?r.left:r.right}return new f(this,[])},y.remove=function(t){var e=this.find(t);return e?e.remove():this},y.get=function(t){for(var e=this._compare,r=this.root;r;){var n=e(t,r.key);if(0===n)return r.value;r=0>=n?r.left:r.right}};var b=f.prototype;Object.defineProperty(b,"valid",{get:function(){return this._stack.length>0}}),Object.defineProperty(b,"node",{get:function(){return this._stack.length>0?this._stack[this._stack.length-1]:null},enumerable:!0}),b.clone=function(){return new f(this.tree,this._stack.slice())},b.remove=function(){var t=this._stack;if(0===t.length)return this.tree;var e=new Array(t.length),r=t[t.length-1];e[e.length-1]=new n(r._color,r.key,r.value,r.left,r.right,r._count);for(var i=t.length-2;i>=0;--i){var r=t[i];r.left===t[i+1]?e[i]=new n(r._color,r.key,r.value,e[i+1],r.right,r._count):e[i]=new n(r._color,r.key,r.value,r.left,e[i+1],r._count)}if(r=e[e.length-1],r.left&&r.right){var a=e.length;for(r=r.left;r.right;)e.push(r),r=r.right;var o=e[a-1];e.push(new n(r._color,o.key,o.value,r.left,r.right,r._count)),e[a-1].key=r.key,e[a-1].value=r.value;for(var i=e.length-2;i>=a;--i)r=e[i],e[i]=new n(r._color,r.key,r.value,r.left,e[i+1],r._count);e[a-1].left=e[a]}if(r=e[e.length-1],r._color===v){var l=e[e.length-2];l.left===r?l.left=null:l.right===r&&(l.right=null),e.pop();for(var i=0;i0?this._stack[this._stack.length-1].key:void 0},enumerable:!0}),Object.defineProperty(b,"value",{get:function(){return this._stack.length>0?this._stack[this._stack.length-1].value:void 0},enumerable:!0}),Object.defineProperty(b,"index",{get:function(){var t=0,e=this._stack;if(0===e.length){var r=this.tree.root;return r?r._count:0}e[e.length-1].left&&(t=e[e.length-1].left._count);for(var n=e.length-2;n>=0;--n)e[n+1]===e[n].right&&(++t,e[n].left&&(t+=e[n].left._count));return t},enumerable:!0}),b.next=function(){var t=this._stack;if(0!==t.length){var e=t[t.length-1];if(e.right)for(e=e.right;e;)t.push(e),e=e.left;else for(t.pop();t.length>0&&t[t.length-1].right===e;)e=t[t.length-1],t.pop()}},Object.defineProperty(b,"hasNext",{get:function(){var t=this._stack;if(0===t.length)return!1;if(t[t.length-1].right)return!0;for(var e=t.length-1;e>0;--e)if(t[e-1].left===t[e])return!0;return!1}}),b.update=function(t){var e=this._stack;if(0===e.length)throw new Error("Can't update empty node!");var r=new Array(e.length),i=e[e.length-1];r[r.length-1]=new n(i._color,i.key,t,i.left,i.right,i._count);for(var a=e.length-2;a>=0;--a)i=e[a],i.left===e[a+1]?r[a]=new n(i._color,i.key,i.value,r[a+1],i.right,i._count):r[a]=new n(i._color,i.key,i.value,i.left,r[a+1],i._count);return new s(this.tree._compare,r[0])},b.prev=function(){var t=this._stack;if(0!==t.length){var e=t[t.length-1];if(e.left)for(e=e.left;e;)t.push(e),e=e.right;else for(t.pop();t.length>0&&t[t.length-1].left===e;)e=t[t.length-1],t.pop()}},Object.defineProperty(b,"hasPrev",{get:function(){var t=this._stack;if(0===t.length)return!1;if(t[t.length-1].left)return!0;for(var e=t.length-1;e>0;--e)if(t[e-1].right===t[e])return!0;return!1}})},{}],165:[function(t,e,r){"use strict";function n(t,e,r){this.slabs=t,this.coordinates=e,this.horizontal=r}function i(t,e){return t.y-e}function a(t,e){for(var r=null;t;){var n,i,o=t.key;o[0][0]s)t=t.left;else if(s>0)if(e[0]!==o[1][0])r=t,t=t.right;else{var l=a(t.right,e);if(l)return l;t=t.left}else{if(e[0]!==o[1][0])return t;var l=a(t.right,e);if(l)return l;t=t.left}}return r}function o(t,e,r,n){this.y=t,this.index=e,this.start=r,this.closed=n}function s(t,e,r,n){this.x=t,this.segment=e,this.create=r,this.index=n}function l(t){for(var e=t.length,r=2*e,i=new Array(r),a=0;e>a;++a){var l=t[a],u=l[0][0]a;){for(var v=i[a].x,m=[];r>a;){var y=i[a];if(y.x!==v)break;a+=1,y.segment[0][0]===y.x&&y.segment[1][0]===y.x?y.create&&(y.segment[0][1]e)return-1;var r=(this.slabs[e],a(this.slabs[e],t)),n=-1;if(r&&(n=r.value),this.coordinates[e]===t[0]){var o=null;if(r&&(o=r.key),e>0){var s=a(this.slabs[e-1],t);s&&(o?h(s.key,o)>0&&(o=s.key,n=s.value):(n=s.value,o=s.key))}var l=this.horizontal[e];if(l.length>0){var c=u.ge(l,t[1],i);if(c=l.length)return n;d=l[c]}}if(d.start)if(o){var p=f(o[0],o[1],[t[0],d.y]);o[0][0]>o[1][0]&&(p=-p),p>0&&(n=d.index)}else n=d.index;else d.y!==t[1]&&(n=d.index)}}}return n}},{"./lib/order-segments":163,"binary-search-bounds":161,"functional-red-black-tree":164,"robust-orientation":133}],166:[function(t,e,r){function n(){return!0}function i(t){return function(e,r){var i=t[e];return i?!!i.queryPoint(r,n):!1}}function a(t){for(var e={},r=0;rn)return 1;var i=t[n];if(!i){if(!(n>0&&e[n]===r[0]))return 1;i=t[n-1]}for(var a=1;i;){var o=i.key,s=f(r,o[0],o[1]);if(o[0][0]s)i=i.left;else{if(!(s>0))return 0;a=-1,i=i.right}else if(s>0)i=i.left;else{if(!(0>s))return 0;a=1,i=i.right}}return a}}function s(t){return 1}function l(t){return function(e){return t(e[0],e[1])?0:1}}function u(t,e){return function(r){return t(r[0],r[1])?0:e(r)}}function c(t){for(var e=t.length,r=[],n=[],i=0;e>i;++i)for(var c=t[i],f=c.length,d=f-1,p=0;f>p;d=p++){var g=c[d],v=c[p];g[0]===v[0]?n.push([g,v]):r.push([g,v])}if(0===r.length)return 0===n.length?s:l(a(n));var m=h(r),y=o(m.slabs,m.coordinates);return 0===n.length?y:u(a(n),y)}e.exports=c;var f=t("robust-orientation")[3],h=t("slab-decomposition"),d=t("interval-tree-1d"),p=t("binary-search-bounds")},{"binary-search-bounds":161,"interval-tree-1d":162,"robust-orientation":133,"slab-decomposition":165}],167:[function(t,e,r){"use strict";function n(t,e){for(var r=new Array(t),n=0;t>n;++n)r[n]=e;return r}function i(t){for(var e=new Array(t),r=0;t>r;++r)e[r]=[];return e}function a(t,e){function r(t){for(var r=t.length,n=[0],i=0;r>i;++i){var a=e[t[i]],o=e[t[(i+1)%r]],s=u(-a[0],a[1]),l=u(-a[0],o[1]),f=u(o[0],a[1]),h=u(o[0],o[1]);n=c(n,c(c(s,l),c(f,h)))}return n[n.length-1]>0}function a(t){for(var e=t.length,r=0;e>r;++r)if(!O[t[r]])return!1;return!0}var d=h(t,e);t=d[0],e=d[1];for(var p=e.length,g=(t.length,o(t,e.length)),v=0;p>v;++v)if(g[v].length%2===1)throw new Error("planar-graph-to-polyline: graph must be manifold");var m=s(t,e);m=m.filter(r);for(var y=m.length,b=new Array(y),x=new Array(y),v=0;y>v;++v){b[v]=v;var _=new Array(y),w=m[v].map(function(t){return e[t]}),A=l([w]),k=0;t:for(var M=0;y>M;++M)if(_[M]=0,v!==M){for(var E=m[M],T=E.length,L=0;T>L;++L){var S=A(e[E[L]]);if(0!==S){0>S&&(_[M]=1,k+=1);continue t}}_[M]=1,k+=1}x[v]=[k,v,_]}x.sort(function(t,e){return e[0]-t[0]});for(var v=0;y>v;++v)for(var _=x[v],C=_[1],R=_[2],M=0;y>M;++M)R[M]&&(b[M]=C);for(var I=i(y),v=0;y>v;++v)I[v].push(b[v]),I[b[v]].push(v);for(var P={},O=n(p,!1),v=0;y>v;++v)for(var E=m[v],T=E.length,M=0;T>M;++M){var N=E[M],z=E[(M+1)%T],D=Math.min(N,z)+":"+Math.max(N,z);if(D in P){var F=P[D];I[F].push(v),I[v].push(F),O[N]=O[z]=!0}else P[D]=v}for(var B=[],j=n(y,-1),v=0;y>v;++v)b[v]!==v||a(m[v])?j[v]=-1:(B.push(v),j[v]=0);for(var d=[];B.length>0;){var U=B.pop(),V=I[U];f(V,function(t,e){return t-e});var q,H=V.length,G=j[U];if(0===G){var E=m[U];q=[E]}for(var v=0;H>v;++v){var X=V[v];if(!(j[X]>=0)&&(j[X]=1^G,B.push(X),0===G)){var E=m[X];a(E)||(E.reverse(),q.push(E))}}0===G&&d.push(q)}return d}e.exports=a;var o=t("edges-to-adjacency-list"),s=t("planar-dual"),l=t("point-in-big-polygon"),u=t("two-product"),c=t("robust-sum"),f=t("uniq"),h=t("./lib/trim-leaves")},{"./lib/trim-leaves":155,"edges-to-adjacency-list":156,"planar-dual":157,"point-in-big-polygon":166,"robust-sum":136,"two-product":149,uniq:152}],168:[function(t,e,r){arguments[4][9][0].apply(r,arguments)},{dup:9}],169:[function(t,e,r){"use strict";"use restrict";function n(t){this.roots=new Array(t),this.ranks=new Array(t);for(var e=0;t>e;++e)this.roots[e]=e,this.ranks[e]=0}e.exports=n,n.prototype.length=function(){return this.roots.length},n.prototype.makeSet=function(){var t=this.roots.length;return this.roots.push(t),this.ranks.push(0),t},n.prototype.find=function(t){for(var e=this.roots;e[t]!==t;){var r=e[t];e[t]=e[r],t=r}return t},n.prototype.link=function(t,e){var r=this.find(t),n=this.find(e);if(r!==n){var i=this.ranks,a=this.roots,o=i[r],s=i[n];s>o?a[r]=n:o>s?a[n]=r:(a[n]=r,++i[r])}}},{}],170:[function(t,e,r){"use strict";"use restrict";function n(t){for(var e=0,r=Math.max,n=0,i=t.length;i>n;++n)e=r(e,t[n].length);return e-1}function i(t){for(var e=-1,r=Math.max,n=0,i=t.length;i>n;++n)for(var a=t[n],o=0,s=a.length;s>o;++o)e=r(e,a[o]);return e+1}function a(t){for(var e=new Array(t.length),r=0,n=t.length;n>r;++r)e[r]=t[r].slice(0);return e}function o(t,e){var r=t.length,n=t.length-e.length,i=Math.min;if(n)return n;switch(r){case 0:return 0;case 1:return t[0]-e[0];case 2:var a=t[0]+t[1]-e[0]-e[1];return a?a:i(t[0],t[1])-i(e[0],e[1]);case 3:var o=t[0]+t[1],s=e[0]+e[1];if(a=o+t[2]-(s+e[2]))return a;var l=i(t[0],t[1]),u=i(e[0],e[1]),a=i(l,t[2])-i(u,e[2]);return a?a:i(l+t[2],o)-i(u+e[2],s);default:var c=t.slice(0);c.sort();var f=e.slice(0);f.sort();for(var h=0;r>h;++h)if(n=c[h]-f[h])return n;return 0}}function s(t,e){return o(t[0],e[0])}function l(t,e){if(e){for(var r=t.length,n=new Array(r),i=0;r>i;++i)n[i]=[t[i],e[i]];n.sort(s);for(var i=0;r>i;++i)t[i]=n[i][0],e[i]=n[i][1];return t}return t.sort(o),t}function u(t){if(0===t.length)return[];for(var e=1,r=t.length,n=1;r>n;++n){var i=t[n];if(o(i,t[n-1])){if(n===e){e++;continue}t[e++]=i}}return t.length=e,t}function c(t,e){for(var r=0,n=t.length-1,i=-1;n>=r;){var a=r+n>>1,s=o(t[a],e);0>=s?(0===s&&(i=a),r=a+1):s>0&&(n=a-1)}return i}function f(t,e){for(var r=new Array(t.length),n=0,i=r.length;i>n;++n)r[n]=[];for(var a=[],n=0,s=e.length;s>n;++n)for(var l=e[n],u=l.length,f=1,h=1<f;++f){a.length=b.popCount(f);for(var d=0,p=0;u>p;++p)f&1<g))for(;;)if(r[g++].push(n),g>=t.length||0!==o(t[g],a))break}return r}function h(t,e){if(!e)return f(u(p(t,0)),t,0);for(var r=new Array(e),n=0;e>n;++n)r[n]=[];for(var n=0,i=t.length;i>n;++n)for(var a=t[n],o=0,s=a.length;s>o;++o)r[a[o]].push(n);return r}function d(t){for(var e=[],r=0,n=t.length;n>r;++r)for(var i=t[r],a=0|i.length,o=1,s=1<o;++o){for(var u=[],c=0;a>c;++c)o>>>c&1&&u.push(i[c]);e.push(u)}return l(e)}function p(t,e){if(0>e)return[];for(var r=[],n=(1<r;++r)for(var i=t[r],a=0,o=i.length;o>a;++a){for(var s=new Array(i.length-1),u=0,c=0;o>u;++u)u!==a&&(s[c++]=i[u]);e.push(s)}return l(e)}function v(t,e){for(var r=new x(e),n=0;nr||0>i?1/0:n(e[t],e[r],e[i])}function a(t,e){var r=M[t],n=M[e];M[t]=n,M[e]=r,E[r]=e,E[n]=t}function s(t){return b[M[t]]}function l(t){return 1&t?t-1>>1:(t>>1)-1}function u(t){for(var e=s(t);;){var r=e,n=2*t+1,i=2*(t+1),o=t;if(L>n){var l=s(n);r>l&&(o=n,r=l)}if(L>i){var u=s(i);r>u&&(o=i)}if(o===t)return t;a(t,o),t=o}}function c(t){for(var e=s(t);t>0;){var r=l(t);if(r>=0){var n=s(r);if(n>e){a(t,r),t=r;continue}}return t}}function f(){if(L>0){var t=M[0];return a(0,L-1),L-=1,u(0),t}return-1}function h(t,e){var r=M[t];return b[r]===e?t:(b[r]=-(1/0),c(t),f(),b[r]=e,L+=1,c(L-1))}function d(t){if(!x[t]){x[t]=!0;var e=m[t],r=y[t];m[r]>=0&&(m[r]=e),y[e]>=0&&(y[e]=r),E[e]>=0&&h(E[e],i(e)),E[r]>=0&&h(E[r],i(r))}}function p(t,e){if(t[e]<0)return e;var r=e,n=e;do{var i=t[n];if(!x[n]||0>i||i===n)break;if(n=i,i=t[n],!x[n]||0>i||i===n)break;n=i,r=t[r]}while(r!==n);for(var a=e;a!==n;a=t[a])t[a]=n;return n}for(var g=e.length,v=t.length,m=new Array(g),y=new Array(g),b=new Array(g),x=new Array(g),_=0;g>_;++_)m[_]=y[_]=-1,b[_]=1/0,x[_]=!1;for(var _=0;v>_;++_){var w=t[_];if(2!==w.length)throw new Error("Input must be a graph");var A=w[1],k=w[0];-1!==y[k]?y[k]=-2:y[k]=A,-1!==m[A]?m[A]=-2:m[A]=k}for(var M=[],E=new Array(g),_=0;g>_;++_){var T=b[_]=i(_);1/0>T?(E[_]=M.length,M.push(_)):E[_]=-1}for(var L=M.length,_=L>>1;_>=0;--_)u(_);for(;;){var S=f();if(0>S||b[S]>r)break;d(S)}for(var C=[],_=0;g>_;++_)x[_]||(E[_]=C.length,C.push(e[_].slice()));var R=(C.length,[]);return t.forEach(function(t){var e=p(m,t[0]),r=p(y,t[1]);if(e>=0&&r>=0&&e!==r){var n=E[e],i=E[r];n!==i&&R.push([n,i])}}),o.unique(o.normalize(R)),{positions:C,edges:R}}e.exports=i;var a=t("robust-orientation"),o=t("simplicial-complex")},{"robust-orientation":133,"simplicial-complex":170}],172:[function(t,e,r){"use strict";e.exports=["",{path:"M-2.4,-3V3L0.6,0Z",backoff:.6},{path:"M-3.7,-2.5V2.5L1.3,0Z",backoff:1.3},{path:"M-4.45,-3L-1.65,-0.2V0.2L-4.45,3L1.55,0Z",backoff:1.55},{path:"M-2.2,-2.2L-0.2,-0.2V0.2L-2.2,2.2L-1.4,3L1.6,0L-1.4,-3Z",backoff:1.6},{path:"M-4.4,-2.1L-0.6,-0.2V0.2L-4.4,2.1L-4,3L2,0L-4,-3Z",backoff:2},{path:"M2,0A2,2 0 1,1 0,-2A2,2 0 0,1 2,0Z",backoff:0},{path:"M2,2V-2H-2V2Z",backoff:0}]},{}],173:[function(t,e,r){"use strict";var n=t("./arrow_paths"),i=t("../../plots/font_attributes"),a=t("../../plots/cartesian/constants"),o=t("../../lib/extend").extendFlat;e.exports={_isLinkedToArray:!0,text:{valType:"string"},textangle:{valType:"angle",dflt:0},font:o({},i,{}),opacity:{valType:"number",min:0,max:1,dflt:1},align:{valType:"enumerated",values:["left","center","right"],dflt:"center"},bgcolor:{valType:"color",dflt:"rgba(0,0,0,0)"},bordercolor:{valType:"color",dflt:"rgba(0,0,0,0)"},borderpad:{valType:"number",min:0,dflt:1},borderwidth:{valType:"number",min:0,dflt:1},showarrow:{valType:"boolean",dflt:!0},arrowcolor:{valType:"color"},arrowhead:{valType:"integer",min:0,max:n.length,dflt:1},arrowsize:{valType:"number",min:.3,dflt:1},arrowwidth:{valType:"number",min:.1},ax:{valType:"number",dflt:-10},ay:{valType:"number",dflt:-30},axref:{valType:"enumerated",dflt:"pixel",values:["pixel",a.idRegex.x.toString()]},ayref:{valType:"enumerated",dflt:"pixel",values:["pixel",a.idRegex.y.toString()]},xref:{valType:"enumerated",values:["paper",a.idRegex.x.toString()]},x:{valType:"number"},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"auto"},yref:{valType:"enumerated",values:["paper",a.idRegex.y.toString()]},y:{valType:"number"},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"], +-dflt:"auto"},_deprecated:{ref:{valType:"string"}}}},{"../../lib/extend":253,"../../plots/cartesian/constants":284,"../../plots/font_attributes":297,"./arrow_paths":172}],174:[function(t,e,r){"use strict";function n(t,e){function r(e,r){return u.coerce(t,n,v.layoutAttributes,e,r)}var n={};r("opacity"),r("align"),r("bgcolor");var i=r("bordercolor"),a=f.opacity(i);r("borderpad");var o=r("borderwidth"),s=r("showarrow");s&&(r("arrowcolor",a?n.bordercolor:f.defaultLine),r("arrowhead"),r("arrowsize"),r("arrowwidth",2*(a&&o||1)),r("ax"),r("ay"),r("axref"),r("ayref"),u.noneOrAll(t,n,["ax","ay"])),r("text",s?" ":"new text"),r("textangle"),u.coerceFont(r,"font",e.font);for(var l=["x","y"],h=0;2>h;h++){var d=l[h],p={_fullLayout:e},g=c.coerceRef(t,n,p,d),m=c.coerceARef(t,n,p,d),y=.5;if("paper"!==g){var b=c.getFromId(p,g);if(y=b.range[0]+y*(b.range[1]-b.range[0]),-1!==["date","category"].indexOf(b.type)&&"string"==typeof t[d]){var x;if("date"===b.type){if(x=u.dateTime2ms(t[d]),x!==!1&&(t[d]=x),m===g){var _=u.dateTime2ms(t["a"+d]);_!==!1&&(t["a"+d]=_)}}else(b._categories||[]).length&&(x=b._categories.indexOf(t[d]),-1!==x&&(t[d]=x))}}r(d,y),s||r(d+"anchor")}return u.noneOrAll(t,n,["x","y"]),n}function i(t){var e=t._fullLayout;e.annotations.forEach(function(e){var r=c.getFromId(t,e.xref),n=c.getFromId(t,e.yref);if(r||n){var i=(e._xsize||0)/2,a=e._xshift||0,o=(e._ysize||0)/2,s=e._yshift||0,l=i-a,u=i+a,f=o-s,h=o+s;if(e.showarrow){var d=3*e.arrowsize*e.arrowwidth;l=Math.max(l,d),u=Math.max(u,d),f=Math.max(f,d),h=Math.max(h,d)}r&&r.autorange&&c.expand(r,[r.l2c(e.x)],{ppadplus:u,ppadminus:l}),n&&n.autorange&&c.expand(n,[n.l2c(e.y)],{ppadplus:h,ppadminus:f})}})}function a(t,e,r,n,i,a,o,s){var l=r-t,u=i-t,c=o-i,f=n-e,h=a-e,d=s-a,p=l*d-c*f;if(0===p)return null;var g=(u*d-c*h)/p,v=(u*f-l*h)/p;return 0>v||v>1||0>g||g>1?null:{x:t+l*g,y:e+f*g}}var o=t("d3"),s=t("fast-isnumeric"),l=t("../../plotly"),u=t("../../lib"),c=t("../../plots/cartesian/axes"),f=t("../color"),h=t("../drawing"),d=t("../../lib/svg_text_utils"),p=t("../../lib/setcursor"),g=t("../dragelement"),v=e.exports={};v.ARROWPATHS=t("./arrow_paths"),v.layoutAttributes=t("./attributes"),v.supplyLayoutDefaults=function(t,e){for(var r=t.annotations||[],i=e.annotations=[],a=0;at?"left":t>2/3?"right":"center"),{center:0,middle:0,left:.5,bottom:-.5,right:-.5,top:.5}[e]}tt.selectAll("tspan.line").attr({y:0,x:0});var n=W.select(".annotation-math-group"),i=!n.empty(),s=h.bBox((i?n:tt).node()),d=s.width,m=s.height,y=Math.round(d+2*$),b=Math.round(m+2*$);U._w=d,U._h=m;var x=!1;if(["x","y"].forEach(function(e){var n,i=U[e+"ref"]||e,a=c.getFromId(t,i),o=(G+("x"===e?0:90))*Math.PI/180,s=y*Math.abs(Math.cos(o))+b*Math.abs(Math.sin(o)),l=U[e+"anchor"];if(a){if(!a.autorange&&(U[e]-a.range[0])*(U[e]-a.range[1])>0&&(U["a"+e+"ref"]===i?(U["a"+e]-a.range[0])*(U["a"+e]-a.range[1])>0&&(x=!0):x=!0,x))return;H[e]=a._offset+a.l2p(U[e]),n=.5}else n=U[e],"y"===e&&(n=1-n),H[e]="x"===e?S.l+S.w*n:S.t+S.h*n;var u=0;U["a"+e+"ref"]===i?H["aa"+e]=a._offset+a.l2p(U["a"+e]):(u=U.showarrow?U["a"+e]:s*r(n,l),H[e]+=u),U["_"+e+"type"]=a&&a.type,U["_"+e+"size"]=s,U["_"+e+"shift"]=u}),x)return void W.remove();var w,A;U.showarrow&&(w=U.axref===U.xref?H.x:u.constrain(H.x-U.ax,1,_.width-1),A=U.ayref===U.yref?H.y:u.constrain(H.y-U.ay,1,_.height-1)),H.x=u.constrain(H.x,1,_.width-1),H.y=u.constrain(H.y,1,_.height-1);var k=$-s.top,M=$-s.left;i?n.select("svg").attr({x:$-1,y:$}):(tt.attr({x:M,y:k}),tt.selectAll("tspan.line").attr({y:k,x:M})),K.call(h.setRect,Z/2,Z/2,y-Z,b-Z);var E=0,T=0;E=U.axref===U.xref?Math.round(H.aax-y/2):Math.round(H.x-y/2),T=U.ayref===U.yref?Math.round(H.aay-b/2):Math.round(H.y-b/2),W.call(u.setTranslate,E,T);var L="annotations["+e+"]",C=function(r,n){o.select(t).selectAll('.annotation-arrow-g[data-index="'+e+'"]').remove();var i,s;i=U.axref===U.xref?H.aax+r:H.x+r,s=U.ayref===U.yref?H.aay+n:H.y+n;var c=u.rotationXYMatrix(G,i,s),h=u.apply2DTransform(c),d=u.apply2DTransform2(c),p=K.attr("width")/2,m=K.attr("height")/2,y=[[i-p,s-m,i-p,s+m],[i-p,s+m,i+p,s+m],[i+p,s+m,i+p,s-m],[i+p,s-m,i-p,s-m]].map(d);if(!y.reduce(function(t,e){return t^!!a(w,A,w+1e6,A+1e6,e[0],e[1],e[2],e[3])},!1)){y.forEach(function(t){var e=a(i,s,w,A,t[0],t[1],t[2],t[3]);e&&(i=e.x,s=e.y)});var b=U.arrowwidth,x=U.arrowcolor,_=X.append("g").style({opacity:f.opacity(x)}).classed("annotation-arrow-g",!0).attr("data-index",String(e)),k=_.append("path").attr("d","M"+i+","+s+"L"+w+","+A).style("stroke-width",b+"px").call(f.stroke,f.rgb(x));v.arrowhead(k,U.arrowhead,"end",U.arrowsize);var M=_.append("path").classed("annotation",!0).classed("anndrag",!0).attr({"data-index":String(e),d:"M3,3H-3V-3H3ZM0,0L"+(i-w)+","+(s-A),transform:"translate("+w+","+A+")"}).style("stroke-width",b+6+"px").call(f.stroke,"rgba(0,0,0,0)").call(f.fill,"rgba(0,0,0,0)");if(t._context.editable){var E,T,C;g.init({element:M.node(),prepFn:function(){var t=u.getTranslate(W);T=t.x,C=t.y,E={},V&&V.autorange&&(E[V._name+".autorange"]=!0),q&&q.autorange&&(E[q._name+".autorange"]=!0)},moveFn:function(t,e){_.attr("transform","translate("+t+","+e+")");var r=h(T,C),n=r[0]+t,i=r[1]+e;W.call(u.setTranslate,n,i),E[L+".x"]=V?U.x+t/V._m:(w+t-S.l)/S.w,E[L+".y"]=q?U.y+e/q._m:1-(A+e-S.t)/S.h,U.axref===U.xref&&(E[L+".ax"]=V?U.ax+t/V._m:(w+t-S.l)/S.w),U.ayref===U.yref&&(E[L+".ay"]=q?U.ay+e/q._m:1-(A+e-S.t)/S.h),Y.attr({transform:"rotate("+G+","+n+","+i+")"})},doneFn:function(e){if(e){l.relayout(t,E);var r=document.querySelector(".js-notes-box-panel");r&&r.redraw(r.selectedObj)}}})}}};U.showarrow&&C(0,0);var R=u.rotationXYMatrix(G,H.x,H.y),I=u.apply2DTransform(R);if(t._context.editable){var P,O,N;g.init({element:W.node(),prepFn:function(){var t=u.getTranslate(W);P=t.x,O=t.y,N={}},moveFn:function(t,e){W.call(u.setTranslate,P+t,O+e);var r="pointer";if(U.showarrow)U.axref===U.xref?N[L+".ax"]=V.p2l(V.l2p(U.ax)+t):N[L+".ax"]=U.ax+t,U.ayref===U.yref?N[L+".ay"]=q.p2l(q.l2p(U.ay)+e):N[L+".ay"]=U.ay+e,C(t,e);else{if(V)N[L+".x"]=U.x+t/V._m;else{var n=U._xsize/S.w,i=U.x+U._xshift/S.w-n/2;N[L+".x"]=g.align(i+t/S.w,n,0,1,U.xanchor)}if(q)N[L+".y"]=U.y+e/q._m;else{var a=U._ysize/S.h,o=U.y-U._yshift/S.h-a/2;N[L+".y"]=g.align(o-e/S.h,a,0,1,U.yanchor)}V&&q||(r=g.getCursor(V?.5:N[L+".x"],q?.5:N[L+".y"],U.xanchor,U.yanchor))}var s=I(P,O),l=s[0]+t,c=s[1]+e;W.call(u.setTranslate,P+t,O+e),Y.attr({transform:"rotate("+G+","+l+","+c+")"}),p(W,r)},doneFn:function(e){if(p(W),e){l.relayout(t,N);var r=document.querySelector(".js-notes-box-panel");r&&r.redraw(r.selectedObj)}}})}}var b,x=t.layout,_=t._fullLayout;if(!s(e)||-1===e){if(!e&&Array.isArray(i))return x.annotations=i,v.supplyLayoutDefaults(x,_),void v.drawAll(t);if("remove"===i)return delete x.annotations,_.annotations=[],void v.drawAll(t);if(r&&"add"!==i){for(b=0;b<_.annotations.length;b++)v.draw(t,b,r,i);return}e=_.annotations.length,_.annotations.push({})}if(!r&&i){if("remove"===i){for(_._infolayer.selectAll('.annotation[data-index="'+e+'"]').remove(),_.annotations.splice(e,1),x.annotations.splice(e,1),b=e;b<_.annotations.length;b++)_._infolayer.selectAll('.annotation[data-index="'+(b+1)+'"]').attr("data-index",String(b)),v.draw(t,b);return}if("add"===i||u.isPlainObject(i)){_.annotations.splice(e,0,{});var w=u.isPlainObject(i)?u.extendFlat({},i):{text:"New text"};for(x.annotations?x.annotations.splice(e,0,w):x.annotations=[w],b=_.annotations.length-1;b>e;b--)_._infolayer.selectAll('.annotation[data-index="'+(b-1)+'"]').attr("data-index",String(b)),v.draw(t,b)}}_._infolayer.selectAll('.annotation[data-index="'+e+'"]').remove();var A=x.annotations[e],k=_.annotations[e];if(A){var M={xref:A.xref,yref:A.yref},E={};"string"==typeof r&&r?E[r]=i:u.isPlainObject(r)&&(E=r);var T=Object.keys(E);for(b=0;bb;b++){var R=C[b];if(void 0===E[R]&&void 0!==A[R]){var I=c.getFromId(t,c.coerceRef(M,{},t,R)),P=c.getFromId(t,c.coerceRef(A,{},t,R)),O=A[R],N=k["_"+R+"type"];if(void 0!==E[R+"ref"]){var z="auto"===A[R+"anchor"],D="x"===R?S.w:S.h,F=(k["_"+R+"size"]||0)/(2*D);if(I&&P)O=(O-I.range[0])/(I.range[1]-I.range[0]),O=P.range[0]+O*(P.range[1]-P.range[0]);else if(I){if(O=(O-I.range[0])/(I.range[1]-I.range[0]),O=I.domain[0]+O*(I.domain[1]-I.domain[0]),z){var B=O+F,j=O-F;2/3>O+j?O=j:O+B>4/3&&(O=B)}}else P&&(z&&(1/3>O?O+=F:O>2/3&&(O-=F)),O=(O-P.domain[0])/(P.domain[1]-P.domain[0]),O=P.range[0]+O*(P.range[1]-P.range[0]))}P&&P===I&&N&&("log"===N&&"log"!==P.type?O=Math.pow(10,O):"log"!==N&&"log"===P.type&&(O=O>0?Math.log(O)/Math.LN10:void 0)),A[R]=O}}var U=n(A,_);_.annotations[e]=U;var V=c.getFromId(t,U.xref),q=c.getFromId(t,U.yref),H={x:0,y:0},G=+U.textangle||0,X=_._infolayer.append("g").classed("annotation",!0).attr("data-index",String(e)).style("opacity",U.opacity).on("click",function(){t._dragging=!1,t.emit("plotly_clickannotation",{index:e,annotation:A,fullAnnotation:U})}),Y=X.append("g").classed("annotation-text-g",!0).attr("data-index",String(e)),W=Y.append("g"),Z=U.borderwidth,Q=U.borderpad,$=Z+Q,K=W.append("rect").attr("class","bg").style("stroke-width",Z+"px").call(f.stroke,U.bordercolor).call(f.fill,U.bgcolor),J=U.font,tt=W.append("text").classed("annotation",!0).attr("data-unformatted",U.text).text(U.text);t._context.editable?tt.call(d.makeEditable,W).call(m).on("edit",function(r){U.text=r,this.attr({"data-unformatted":U.text}),this.call(m);var n={};n["annotations["+e+"].text"]=U.text,V&&V.autorange&&(n[V._name+".autorange"]=!0),q&&q.autorange&&(n[q._name+".autorange"]=!0),l.relayout(t,n)}):tt.call(m),Y.attr({transform:"rotate("+G+","+H.x+","+H.y+")"}).call(h.setPosition,H.x,H.y)}},v.arrowhead=function(t,e,r,n){s(n)||(n=1);var i=t.node(),a=v.ARROWPATHS[e||0];if(a){"string"==typeof r&&r||(r="end");var l,u,c,d,p=(h.getPx(t,"stroke-width")||1)*n,g=t.style("stroke")||f.defaultLine,m=t.style("stroke-opacity")||1,y=r.indexOf("start")>=0,b=r.indexOf("end")>=0,x=a.backoff*p;if("line"===i.nodeName){if(l={x:+t.attr("x1"),y:+t.attr("y1")},u={x:+t.attr("x2"),y:+t.attr("y2")},c=Math.atan2(l.y-u.y,l.x-u.x),d=c+Math.PI,x){var _=x*Math.cos(c),w=x*Math.sin(c);y&&(l.x-=_,l.y-=w,t.attr({x1:l.x,y1:l.y})),b&&(u.x+=_,u.y+=w,t.attr({x2:u.x,y2:u.y}))}}else if("path"===i.nodeName){var A=i.getTotalLength(),k="";if(y){var M=i.getPointAtLength(0),E=i.getPointAtLength(.1);c=Math.atan2(M.y-E.y,M.x-E.x),l=i.getPointAtLength(Math.min(x,A)),x&&(k="0px,"+x+"px,")}if(b){var T=i.getPointAtLength(A),L=i.getPointAtLength(A-.1);if(d=Math.atan2(T.y-L.y,T.x-L.x),u=i.getPointAtLength(Math.max(0,A-x)),x){var S=k?2*x:x;k+=A-S+"px,"+A+"px"}}else k&&(k+=A+"px");k&&t.style("stroke-dasharray",k)}var C=function(r,n){e>5&&(n=0),o.select(i.parentElement).append("path").attr({"class":t.attr("class"),d:a.path,transform:"translate("+r.x+","+r.y+")rotate("+180*n/Math.PI+")scale("+p+")"}).style({fill:g,opacity:m,"stroke-width":0})};y&&C(l,c),b&&C(u,d)}},v.calcAutorange=function(t){var e=t._fullLayout,r=e.annotations;if(r.length&&t._fullData.length){var n={};r.forEach(function(t){n[t.xref]=!0,n[t.yref]=!0});var a=c.list(t).filter(function(t){return t.autorange&&n[t._id]});if(a.length)return u.syncOrAsync([v.drawAll,i],t)}}},{"../../lib":256,"../../lib/setcursor":265,"../../lib/svg_text_utils":269,"../../plotly":276,"../../plots/cartesian/axes":279,"../color":176,"../dragelement":197,"../drawing":199,"./arrow_paths":172,"./attributes":173,d3:62,"fast-isnumeric":65}],175:[function(t,e,r){"use strict";r.defaults=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],r.defaultLine="#444",r.lightLine="#eee",r.background="#fff",r.borderLine="#BEC8D9",r.lightFraction=1e3/11},{}],176:[function(t,e,r){"use strict";function n(t){if(a(t)||"string"!=typeof t)return t;var e=t.trim();if("rgb"!==e.substr(0,3))return t;var r=e.match(/^rgba?\s*\(([^()]*)\)$/);if(!r)return t;var n=r[1].trim().split(/\s*[\s,]\s*/),i="a"===e.charAt(3)&&4===n.length;if(!i&&3!==n.length)return t;for(var o=0;o=0))return t;if(3===o)n[o]>1&&(n[o]=1);else if(n[o]>=1)return t}var s=Math.round(255*n[0])+", "+Math.round(255*n[1])+", "+Math.round(255*n[2]);return i?"rgba("+s+", "+n[3]+")":"rgb("+s+")"}var i=t("tinycolor2"),a=t("fast-isnumeric"),o=e.exports={},s=t("./attributes");o.defaults=s.defaults,o.defaultLine=s.defaultLine,o.lightLine=s.lightLine,o.background=s.background,o.tinyRGB=function(t){var e=t.toRgb();return"rgb("+Math.round(e.r)+", "+Math.round(e.g)+", "+Math.round(e.b)+")"},o.rgb=function(t){return o.tinyRGB(i(t))},o.opacity=function(t){return t?i(t).getAlpha():0},o.addOpacity=function(t,e){var r=i(t).toRgb();return"rgba("+Math.round(r.r)+", "+Math.round(r.g)+", "+Math.round(r.b)+", "+e+")"},o.combine=function(t,e){var r=i(t).toRgb();if(1===r.a)return i(t).toRgbString();var n=i(e||o.background).toRgb(),a=1===n.a?n:{r:255*(1-n.a)+n.r*n.a,g:255*(1-n.a)+n.g*n.a,b:255*(1-n.a)+n.b*n.a},s={r:a.r*(1-r.a)+r.r*r.a,g:a.g*(1-r.a)+r.g*r.a,b:a.b*(1-r.a)+r.b*r.a};return i(s).toRgbString()},o.contrast=function(t,e,r){var n=i(t),a=n.isLight()?n.darken(r):n.lighten(e);return a.toString()},o.stroke=function(t,e){var r=i(e);t.style({stroke:o.tinyRGB(r),"stroke-opacity":r.getAlpha()})},o.fill=function(t,e){var r=i(e);t.style({fill:o.tinyRGB(r),"fill-opacity":r.getAlpha()})},o.clean=function(t){if(t&&"object"==typeof t){var e,r,i,a,s=Object.keys(t);for(e=0;el&&(a[1]-=(ot-l)/2)):r.node()&&!r.classed("js-placeholder")&&(ot=h.bBox(e.node()).height),ot){if(ot+=5,"top"===x.titleside)K.domain[1]-=ot/M.h,a[1]*=-1;else{K.domain[0]+=ot/M.h;var c=Math.max(1,r.selectAll("tspan.line").size());a[1]+=(1-c)*l}e.attr("transform","translate("+a+")"),K.setScale()}}it.selectAll(".cbfills,.cblines,.cbaxis").attr("transform","translate(0,"+Math.round(M.h*(1-K.domain[1]))+")");var f=it.select(".cbfills").selectAll("rect.cbfill").data(S);f.enter().append("rect").classed("cbfill",!0).style("stroke","none"),f.exit().remove(),f.each(function(t,e){var r=[0===e?T[0]:(S[e]+S[e-1])/2,e===S.length-1?T[1]:(S[e]+S[e+1])/2].map(K.c2p).map(Math.round);e!==S.length-1&&(r[1]+=r[1]>r[0]?1:-1);var a=R(t).replace("e-",""),o=i(a).toHexString();n.select(this).attr({x:X,width:Math.max(B,2),y:n.min(r),height:Math.max(n.max(r)-n.min(r),2),fill:o})});var d=it.select(".cblines").selectAll("path.cbline").data(x.line.color&&x.line.width?L:[]);return d.enter().append("path").classed("cbline",!0),d.exit().remove(),d.each(function(t){n.select(this).attr("d","M"+X+","+(Math.round(K.c2p(t))+x.line.width/2%1)+"h"+B).call(h.lineGroupStyle,x.line.width,C(t),x.line.dash)}),K._axislayer.selectAll("g."+K._id+"tick,path").remove(),K._pos=X+B+(x.outlinewidth||0)/2-("outside"===x.ticks?1:0),K.side="right",u.syncOrAsync([function(){return s.doTicks(t,K,!0)},function(){if(-1===["top","bottom"].indexOf(x.titleside)){var e=K.titlefont.size,r=K._offset+K._length/2,i=M.l+(K.position||0)*M.w+("right"===K.side?10+e*(K.showticklabels?1:.5):-10-e*(K.showticklabels?.5:0));w("h"+K._id+"title",{avoid:{selection:n.select(t).selectAll("g."+K._id+"tick"),side:x.titleside,offsetLeft:M.l,offsetTop:M.t,maxShift:k.width},attributes:{x:i,y:r,"text-anchor":"middle"},transform:{rotate:"-90",offset:0}})}}])}function w(e,r){var n,i=b();n=o.traceIs(i,"markerColorscale")?"marker.colorbar.title":"colorbar.title";var a={propContainer:K,propName:n,traceIndex:i.index,dfltName:"colorscale",containerGroup:it.select(".cbtitle")},s="h"===e.charAt(0)?e.substr(1):"h"+e;it.selectAll("."+s+",."+s+"-math-group").remove(),p.draw(t,e,c(a,r||{}))}function A(){var r=B+x.outlinewidth/2+h.bBox(K._axislayer.node()).width;if(z=at.select("text"),z.node()&&!z.classed("js-placeholder")){var n,i=at.select(".h"+K._id+"title-math-group").node();n=i&&-1!==["top","bottom"].indexOf(x.titleside)?h.bBox(i).width:h.bBox(at.node()).right-X-M.l,r=Math.max(r,n)}var a=2*x.xpad+r+x.borderwidth+x.outlinewidth/2,s=Z-Q;it.select(".cbbg").attr({x:X-x.xpad-(x.borderwidth+x.outlinewidth)/2,y:Q-H,width:Math.max(a,2),height:Math.max(s+2*H,2)}).call(d.fill,x.bgcolor).call(d.stroke,x.bordercolor).style({"stroke-width":x.borderwidth}),it.selectAll(".cboutline").attr({x:X,y:Q+x.ypad+("top"===x.titleside?ot:0),width:Math.max(B,2),height:Math.max(s-2*x.ypad-ot,2)}).call(d.stroke,x.outlinecolor).style({fill:"None","stroke-width":x.outlinewidth});var l=({center:.5,right:1}[x.xanchor]||0)*a;it.attr("transform","translate("+(M.l-l)+","+M.t+")"),o.autoMargin(t,e,{x:x.x,y:x.y,l:a*({right:1,center:.5}[x.xanchor]||0),r:a*({left:1,center:.5}[x.xanchor]||0),t:s*({bottom:1,middle:.5}[x.yanchor]||0),b:s*({top:1,middle:.5}[x.yanchor]||0)})}var k=t._fullLayout,M=k._size;if("function"!=typeof x.fillcolor&&"function"!=typeof x.line.color)return void k._infolayer.selectAll("g."+e).remove();var E,T=n.extent(("function"==typeof x.fillcolor?x.fillcolor:x.line.color).domain()),L=[],S=[],C="function"==typeof x.line.color?x.line.color:function(){return x.line.color},R="function"==typeof x.fillcolor?x.fillcolor:function(){return x.fillcolor},I=x.levels.end+x.levels.size/100,P=x.levels.size,O=1.001*T[0]-.001*T[1],N=1.001*T[1]-.001*T[0];for(E=x.levels.start;0>(E-I)*P;E+=P)E>O&&N>E&&L.push(E);if("function"==typeof x.fillcolor)if(x.filllevels)for(I=x.filllevels.end+x.filllevels.size/100,P=x.filllevels.size,E=x.filllevels.start;0>(E-I)*P;E+=P)E>T[0]&&E1){var nt=Math.pow(10,Math.floor(Math.log(rt)/Math.LN10));tt*=nt*u.roundUp(rt/nt,[2,5,10]),(Math.abs(x.levels.start)/x.levels.size+1e-6)%1<2e-6&&(K.tick0=0)}K.dtick=tt}K.domain=[W+G,W+V-G],K.setScale();var it=k._infolayer.selectAll("g."+e).data([0]);it.enter().append("g").classed(e,!0).each(function(){var t=n.select(this);t.append("rect").classed("cbbg",!0),t.append("g").classed("cbfills",!0),t.append("g").classed("cblines",!0),t.append("g").classed("cbaxis",!0).classed("crisp",!0),t.append("g").classed("cbtitleunshift",!0).append("g").classed("cbtitle",!0),t.append("rect").classed("cboutline",!0),t.select(".cbtitle").datum(0)}),it.attr("transform","translate("+Math.round(M.l)+","+Math.round(M.t)+")");var at=it.select(".cbtitleunshift").attr("transform","translate(-"+Math.round(M.l)+",-"+Math.round(M.t)+")");K._axislayer=it.select(".cbaxis");var ot=0;if(-1!==["top","bottom"].indexOf(x.titleside)){var st,lt=M.l+(x.x+q)*M.w,ut=K.titlefont.size;st="top"===x.titleside?(1-(W+V-G))*M.h+M.t+3+.75*ut:(1-(W+G))*M.h+M.t-3-.25*ut,w(K._id+"title",{attributes:{x:lt,y:st,"text-anchor":"start"}})}var ct=u.syncOrAsync([o.previousPromises,_,o.previousPromises,A],t);if(ct&&ct.then&&(t._promises||[]).push(ct),t._context.editable){var ft,ht,dt;l.init({element:it.node(),prepFn:function(){ft=it.attr("transform"),f(it)},moveFn:function(t,e){it.attr("transform",ft+" translate("+t+","+e+")"),ht=l.align(Y+t/M.w,j,0,1,x.xanchor),dt=l.align(W-e/M.h,V,0,1,x.yanchor);var r=l.getCursor(ht,dt,x.xanchor,x.yanchor);f(it,r)},doneFn:function(e){f(it),e&&void 0!==ht&&void 0!==dt&&a.restyle(t,{"colorbar.x":ht,"colorbar.y":dt},b().index)}})}return ct}function b(){var r,n,i=e.substr(2);for(r=0;rc*f?i.RdBu:c>=0?i.Reds:i.Blues,l.colorscale=h,s.reversescale&&(h=a(h)),s.colorscale=h)}},{"../../lib":256,"./flip_scale":187,"./scales":194}],184:[function(t,e,r){"use strict";var n=t("./attributes"),i=t("../../lib/extend").extendDeep;t("./scales.js");e.exports=function(t){return{color:{valType:"color",arrayOk:!0},colorscale:i({},n.colorscale,{}),cauto:i({},n.zauto,{}),cmax:i({},n.zmax,{}),cmin:i({},n.zmin,{}),autocolorscale:i({},n.autocolorscale,{}),reversescale:i({},n.reversescale,{})}}},{"../../lib/extend":253,"./attributes":182,"./scales.js":194}],185:[function(t,e,r){"use strict";var n=t("./scales");e.exports=n.RdBu},{"./scales":194}],186:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib"),a=t("../colorbar/has_colorbar"),o=t("../colorbar/defaults"),s=t("./is_valid_scale"),l=t("./flip_scale");e.exports=function(t,e,r,u,c){var f=c.prefix,h=c.cLetter,d=f.slice(0,f.length-1),p=f?i.nestedProperty(t,d).get()||{}:t,g=f?i.nestedProperty(e,d).get()||{}:e,v=p[h+"min"],m=p[h+"max"],y=p.colorscale,b=n(v)&&n(m)&&m>v;u(f+h+"auto",!b),u(f+h+"min"),u(f+h+"max");var x;void 0!==y&&(x=!s(y)),u(f+"autocolorscale",x);var _=u(f+"colorscale"),w=u(f+"reversescale");if(w&&(g.colorscale=l(_)),"marker.line."!==f){var A;f&&(A=a(p));var k=u(f+"showscale",A);k&&o(p,g,r)}}},{"../../lib":256,"../colorbar/defaults":178,"../colorbar/has_colorbar":180,"./flip_scale":187,"./is_valid_scale":191,"fast-isnumeric":65}],187:[function(t,e,r){"use strict";e.exports=function(t){for(var e,r=t.length,n=new Array(r),i=r-1,a=0;i>=0;i--,a++)e=t[i],n[a]=[1-e[0],e[1]];return n}},{}],188:[function(t,e,r){"use strict";var n=t("./scales"),i=t("./default_scale"),a=t("./is_valid_scale_array");e.exports=function(t,e){function r(){try{t=n[t]||JSON.parse(t)}catch(r){t=e}}return e||(e=i),t?("string"==typeof t&&(r(),"string"==typeof t&&r()),a(t)?t:e):e}},{"./default_scale":185,"./is_valid_scale_array":192,"./scales":194}],189:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib"),a=t("./is_valid_scale");e.exports=function(t,e){var r=e?i.nestedProperty(t,e).get()||{}:t,o=r.color,s=!1;if(Array.isArray(o))for(var l=0;lh;h++)l=t[h],c[h]=e+l[0]*(r-e),f[h]=i(l[1]).toRgb();var d=n.scale.linear().domain(c).interpolate(n.interpolateObject).range(f);return function(t){if(a(t)){var n=o.constrain(t,e,r),l=d(n);return i(l).toRgbString()}return i(t).isValid()?t:s.defaultLine}}},{"../../lib":256,"../color":176,d3:62,"fast-isnumeric":65,tinycolor2:148}],194:[function(t,e,r){"use strict";e.exports={Greys:[[0,"rgb(0,0,0)"],[1,"rgb(255,255,255)"]],YlGnBu:[[0,"rgb(8,29,88)"],[.125,"rgb(37,52,148)"],[.25,"rgb(34,94,168)"],[.375,"rgb(29,145,192)"],[.5,"rgb(65,182,196)"],[.625,"rgb(127,205,187)"],[.75,"rgb(199,233,180)"],[.875,"rgb(237,248,217)"],[1,"rgb(255,255,217)"]],Greens:[[0,"rgb(0,68,27)"],[.125,"rgb(0,109,44)"],[.25,"rgb(35,139,69)"],[.375,"rgb(65,171,93)"],[.5,"rgb(116,196,118)"],[.625,"rgb(161,217,155)"],[.75,"rgb(199,233,192)"],[.875,"rgb(229,245,224)"],[1,"rgb(247,252,245)"]],YlOrRd:[[0,"rgb(128,0,38)"],[.125,"rgb(189,0,38)"],[.25,"rgb(227,26,28)"],[.375,"rgb(252,78,42)"],[.5,"rgb(253,141,60)"],[.625,"rgb(254,178,76)"],[.75,"rgb(254,217,118)"],[.875,"rgb(255,237,160)"],[1,"rgb(255,255,204)"]],Bluered:[[0,"rgb(0,0,255)"],[1,"rgb(255,0,0)"]],RdBu:[[0,"rgb(5,10,172)"],[.35,"rgb(106,137,247)"],[.5,"rgb(190,190,190)"],[.6,"rgb(220,170,132)"],[.7,"rgb(230,145,90)"],[1,"rgb(178,10,28)"]],Reds:[[0,"rgb(220,220,220)"],[.2,"rgb(245,195,157)"],[.4,"rgb(245,160,105)"],[1,"rgb(178,10,28)"]], +-Blues:[[0,"rgb(5,10,172)"],[.35,"rgb(40,60,190)"],[.5,"rgb(70,100,245)"],[.6,"rgb(90,120,245)"],[.7,"rgb(106,137,247)"],[1,"rgb(220,220,220)"]],Picnic:[[0,"rgb(0,0,255)"],[.1,"rgb(51,153,255)"],[.2,"rgb(102,204,255)"],[.3,"rgb(153,204,255)"],[.4,"rgb(204,204,255)"],[.5,"rgb(255,255,255)"],[.6,"rgb(255,204,255)"],[.7,"rgb(255,153,255)"],[.8,"rgb(255,102,204)"],[.9,"rgb(255,102,102)"],[1,"rgb(255,0,0)"]],Rainbow:[[0,"rgb(150,0,90)"],[.125,"rgb(0,0,200)"],[.25,"rgb(0,25,255)"],[.375,"rgb(0,152,255)"],[.5,"rgb(44,255,150)"],[.625,"rgb(151,255,0)"],[.75,"rgb(255,234,0)"],[.875,"rgb(255,111,0)"],[1,"rgb(255,0,0)"]],Portland:[[0,"rgb(12,51,131)"],[.25,"rgb(10,136,186)"],[.5,"rgb(242,211,56)"],[.75,"rgb(242,143,56)"],[1,"rgb(217,30,30)"]],Jet:[[0,"rgb(0,0,131)"],[.125,"rgb(0,60,170)"],[.375,"rgb(5,255,255)"],[.625,"rgb(255,255,0)"],[.875,"rgb(250,0,0)"],[1,"rgb(128,0,0)"]],Hot:[[0,"rgb(0,0,0)"],[.3,"rgb(230,0,0)"],[.6,"rgb(255,210,0)"],[1,"rgb(255,255,255)"]],Blackbody:[[0,"rgb(0,0,0)"],[.2,"rgb(230,0,0)"],[.4,"rgb(230,210,0)"],[.7,"rgb(255,255,255)"],[1,"rgb(160,200,255)"]],Earth:[[0,"rgb(0,0,130)"],[.1,"rgb(0,180,180)"],[.2,"rgb(40,210,40)"],[.4,"rgb(230,230,50)"],[.6,"rgb(120,70,20)"],[1,"rgb(255,255,255)"]],Electric:[[0,"rgb(0,0,0)"],[.15,"rgb(30,0,100)"],[.4,"rgb(120,0,100)"],[.6,"rgb(160,90,0)"],[.8,"rgb(230,200,0)"],[1,"rgb(255,250,220)"]],Viridis:[[0,"#440154"],[.06274509803921569,"#48186a"],[.12549019607843137,"#472d7b"],[.18823529411764706,"#424086"],[.25098039215686274,"#3b528b"],[.3137254901960784,"#33638d"],[.3764705882352941,"#2c728e"],[.4392156862745098,"#26828e"],[.5019607843137255,"#21918c"],[.5647058823529412,"#1fa088"],[.6274509803921569,"#28ae80"],[.6901960784313725,"#3fbc73"],[.7529411764705882,"#5ec962"],[.8156862745098039,"#84d44b"],[.8784313725490196,"#addc30"],[.9411764705882353,"#d8e219"],[1,"#fde725"]]}},{}],195:[function(t,e,r){"use strict";e.exports=function(t,e,r,n,i){var a=(t-r)/(n-r),o=a+e/(n-r),s=(a+o)/2;return"left"===i||"bottom"===i?a:"center"===i||"middle"===i?s:"right"===i||"top"===i?o:2/3-s>a?a:o>4/3-s?o:s}},{}],196:[function(t,e,r){"use strict";var n=t("../../lib"),i=[["sw-resize","s-resize","se-resize"],["w-resize","move","e-resize"],["nw-resize","n-resize","ne-resize"]];e.exports=function(t,e,r,a){return t="left"===r?0:"center"===r?1:"right"===r?2:n.constrain(Math.floor(3*t),0,2),e="bottom"===a?0:"middle"===a?1:"top"===a?2:n.constrain(Math.floor(3*e),0,2),i[e][t]}},{"../../lib":256}],197:[function(t,e,r){"use strict";function n(){var t=document.createElement("div");t.className="dragcover";var e=t.style;return e.position="fixed",e.left=0,e.right=0,e.top=0,e.bottom=0,e.zIndex=999999999,e.background="none",document.body.appendChild(t),t}function i(t){t._dragging=!1,t._replotPending&&a.plot(t)}var a=t("../../plotly"),o=t("../../lib"),s=t("../../plots/cartesian/constants"),l=e.exports={};l.align=t("./align"),l.getCursor=t("./cursor");var u=t("./unhover");l.unhover=u.wrapped,l.unhoverRaw=u.raw,l.init=function(t){function e(e){return t.element.onmousemove=p,g._dragged=!1,g._dragging=!0,u=e.clientX,c=e.clientY,d=e.target,f=(new Date).getTime(),f-g._mouseDownTimem&&(v=Math.max(v-1,1)),t.doneFn&&t.doneFn(g._dragged,v),!g._dragged){var r=document.createEvent("MouseEvents");r.initEvent("click",!0,!0),d.dispatchEvent(r)}return i(g),g._dragged=!1,o.pauseEvent(e)}var u,c,f,h,d,p,g=o.getPlotDiv(t.element)||{},v=1,m=s.DBLCLICKDELAY;g._mouseDownTime||(g._mouseDownTime=0),p=t.element.onmousemove,t.setCursor&&(t.element.onmousemove=t.setCursor),t.element.onmousedown=e,t.element.style.pointerEvents="all"}},{"../../lib":256,"../../plotly":276,"../../plots/cartesian/constants":284,"./align":195,"./cursor":196,"./unhover":198}],198:[function(t,e,r){"use strict";var n=t("../../lib/events"),i=e.exports={};i.wrapped=function(t,e,r){"string"==typeof t&&(t=document.getElementById(t)),t._hoverTimer&&(clearTimeout(t._hoverTimer),t._hoverTimer=void 0),i.raw(t,e,r)},i.raw=function(t,e){var r=t._fullLayout;e||(e={}),e.target&&n.triggerHandler(t,"plotly_beforehover",e)===!1||(r._hoverlayer.selectAll("g").remove(),e.target&&t._hoverdata&&t.emit("plotly_unhover",{points:t._hoverdata}),t._hoverdata=void 0)}},{"../../lib/events":252}],199:[function(t,e,r){"use strict";function n(t,e,r,n){var a=t[0]-e[0],o=t[1]-e[1],s=r[0]-e[0],l=r[1]-e[1],u=Math.pow(a*a+o*o,x/2),c=Math.pow(s*s+l*l,x/2),f=(c*c*a-u*u*s)*n,h=(c*c*o-u*u*l)*n,d=3*c*(u+c),p=3*u*(u+c);return[[i.round(e[0]+(d&&f/d),2),i.round(e[1]+(d&&h/d),2)],[i.round(e[0]-(p&&f/p),2),i.round(e[1]-(p&&h/p),2)]]}var i=t("d3"),a=t("fast-isnumeric"),o=t("../../plots/plots"),s=t("../color"),l=t("../colorscale"),u=t("../../lib"),c=t("../../lib/svg_text_utils"),f=t("../../constants/xmlns_namespaces"),h=t("../../traces/scatter/subtypes"),d=t("../../traces/scatter/make_bubble_size_func"),p=e.exports={};p.font=function(t,e,r,n){e&&e.family&&(n=e.color,r=e.size,e=e.family),e&&t.style("font-family",e),r+1&&t.style("font-size",r+"px"),n&&t.call(s.fill,n)},p.setPosition=function(t,e,r){t.attr("x",e).attr("y",r)},p.setSize=function(t,e,r){t.attr("width",e).attr("height",r)},p.setRect=function(t,e,r,n,i){t.call(p.setPosition,e,r).call(p.setSize,n,i)},p.translatePoints=function(t,e,r){t.each(function(t){var n=t.xp||e.c2p(t.x),o=t.yp||r.c2p(t.y),s=i.select(this);a(n)&&a(o)?"text"===this.nodeName?s.attr("x",n).attr("y",o):s.attr("transform","translate("+n+","+o+")"):s.remove()})},p.getPx=function(t,e){return Number(t.style(e).replace(/px$/,""))},p.crispRound=function(t,e,r){return e&&a(e)?t._context.staticPlot?e:1>e?1:Math.round(e):r||0},p.lineGroupStyle=function(t,e,r,n){t.style("fill","none").each(function(t){var a=(((t||[])[0]||{}).trace||{}).line||{},o=e||a.width||0,l=n||a.dash||"";i.select(this).call(s.stroke,r||a.color).call(p.dashLine,l,o)})},p.dashLine=function(t,e,r){var n=Math.max(r,3);"solid"===e?e="":"dot"===e?e=n+"px,"+n+"px":"dash"===e?e=3*n+"px,"+3*n+"px":"longdash"===e?e=5*n+"px,"+5*n+"px":"dashdot"===e?e=3*n+"px,"+n+"px,"+n+"px,"+n+"px":"longdashdot"===e&&(e=5*n+"px,"+2*n+"px,"+n+"px,"+2*n+"px"),t.style({"stroke-dasharray":e,"stroke-width":r+"px"})},p.fillGroupStyle=function(t){t.style("stroke-width",0).each(function(e){var r=i.select(this);try{r.call(s.fill,e[0].trace.fillcolor)}catch(n){u.error(n,t),r.remove()}})};var g=t("./symbol_defs");p.symbolNames=[],p.symbolFuncs=[],p.symbolNeedLines={},p.symbolNoDot={},p.symbolList=[],Object.keys(g).forEach(function(t){var e=g[t];p.symbolList=p.symbolList.concat([e.n,t,e.n+100,t+"-open"]),p.symbolNames[e.n]=t,p.symbolFuncs[e.n]=e.f,e.needLine&&(p.symbolNeedLines[e.n]=!0),e.noDot?p.symbolNoDot[e.n]=!0:p.symbolList=p.symbolList.concat([e.n+200,t+"-dot",e.n+300,t+"-open-dot"])});var v=p.symbolNames.length,m="M0,0.5L0.5,0L0,-0.5L-0.5,0Z";p.symbolNumber=function(t){if("string"==typeof t){var e=0;t.indexOf("-open")>0&&(e=100,t=t.replace("-open","")),t.indexOf("-dot")>0&&(e+=200,t=t.replace("-dot","")),t=p.symbolNames.indexOf(t),t>=0&&(t+=e)}return t%100>=v||t>=400?0:Math.floor(Math.max(t,0))},p.pointStyle=function(t,e){if(t.size()){var r=e.marker,n=r.line;if(o.traceIs(e,"symbols")){var a=d(e);t.attr("d",function(t){var n;n="various"===t.ms||"various"===r.size?3:h.isBubble(e)?a(t.ms):(r.size||6)/2,t.mrc=n;var i=p.symbolNumber(t.mx||r.symbol)||0,o=i%100;return t.om=i%200>=100,p.symbolFuncs[o](n)+(i>=200?m:"")}).style("opacity",function(t){return(t.mo+1||r.opacity+1)-1})}var l=(e._input||{}).marker||{},u=p.tryColorscale(r,l,""),c=p.tryColorscale(r,l,"line.");t.each(function(t){var e,a,o;t.so?(o=n.outlierwidth,a=n.outliercolor,e=r.outliercolor):(o=(t.mlw+1||n.width+1||(t.trace?t.trace.marker.line.width:0)+1)-1,a="mlc"in t?t.mlcc=c(t.mlc):Array.isArray(n.color)?s.defaultLine:n.color,e="mc"in t?t.mcc=u(t.mc):Array.isArray(r.color)?s.defaultLine:r.color||"rgba(0,0,0,0)");var l=i.select(this);t.om?l.call(s.stroke,e).style({"stroke-width":(o||1)+"px",fill:"none"}):(l.style("stroke-width",o+"px").call(s.fill,e),o&&l.call(s.stroke,a))})}},p.tryColorscale=function(t,e,r){var n=u.nestedProperty(t,r+"color").get(),i=u.nestedProperty(t,r+"colorscale").get(),o=u.nestedProperty(t,r+"cauto").get(),s=u.nestedProperty(t,r+"cmin"),c=u.nestedProperty(t,r+"cmax"),f=s.get(),h=c.get();return i&&Array.isArray(n)?(!o&&a(f)&&a(h)||(f=1/0,h=-(1/0),n.forEach(function(t){a(t)&&(f>t&&(f=+t),t>h&&(h=+t))}),f>h&&(f=0,h=1),s.set(f),c.set(h),u.nestedProperty(e,r+"cmin").set(f),u.nestedProperty(e,r+"cmax").set(h)),l.makeScaleFunction(i,f,h)):u.identity};var y={start:1,end:-1,middle:0,bottom:1,top:-1},b=1.3;p.textPointStyle=function(t,e){t.each(function(t){var r=i.select(this),n=t.tx||e.text;if(!n||Array.isArray(n))return void r.remove();var o=t.tp||e.textposition,s=-1!==o.indexOf("top")?"top":-1!==o.indexOf("bottom")?"bottom":"middle",l=-1!==o.indexOf("left")?"end":-1!==o.indexOf("right")?"start":"middle",u=t.ts||e.textfont.size,f=t.mrc?t.mrc/.8+1:0;u=a(u)&&u>0?u:0,r.call(p.font,t.tf||e.textfont.family,u,t.tc||e.textfont.color).attr("text-anchor",l).text(n).call(c.convertToTspans);var h=i.select(this.parentNode),d=r.selectAll("tspan.line"),g=((d[0].length||1)-1)*b+1,v=y[l]*f,m=.75*u+y[s]*f+(y[s]-1)*g*u/2;h.attr("transform","translate("+v+","+m+")"),g>1&&d.attr({x:r.attr("x"),y:r.attr("y")})})};var x=.5;p.smoothopen=function(t,e){if(t.length<3)return"M"+t.join("L");var r,i="M"+t[0],a=[];for(r=1;rr;r++)o.push(n(t[r-1],t[r],t[r+1],e));for(o.push(n(t[a-1],t[a],t[0],e)),r=1;a>=r;r++)i+="C"+o[r-1][1]+" "+o[r][0]+" "+t[r];return i+="C"+o[a][1]+" "+o[0][0]+" "+t[0]+"Z"};var _={hv:function(t,e){return"H"+i.round(e[0],2)+"V"+i.round(e[1],2)},vh:function(t,e){return"V"+i.round(e[1],2)+"H"+i.round(e[0],2)},hvh:function(t,e){return"H"+i.round((t[0]+e[0])/2,2)+"V"+i.round(e[1],2)+"H"+i.round(e[0],2)},vhv:function(t,e){return"V"+i.round((t[1]+e[1])/2,2)+"H"+i.round(e[0],2)+"V"+i.round(e[1],2)}},w=function(t,e){return"L"+i.round(e[0],2)+","+i.round(e[1],2)};p.steps=function(t){var e=_[t]||w;return function(t){for(var r="M"+i.round(t[0][0],2)+","+i.round(t[0][1],2),n=1;n=k&&(i.selectAll("[data-bb]").attr("data-bb",null),A=[]),t.setAttribute("data-bb",A.length),A.push(l),u.extendFlat({},l)},p.setClipUrl=function(t,e){if(!e)return void t.attr("clip-path",null);var r="#"+e,n=i.select("base");n.size()&&n.attr("href")&&(r=window.location.href+r),t.attr("clip-path","url("+r+")")}},{"../../constants/xmlns_namespaces":247,"../../lib":256,"../../lib/svg_text_utils":269,"../../plots/plots":303,"../../traces/scatter/make_bubble_size_func":355,"../../traces/scatter/subtypes":360,"../color":176,"../colorscale":190,"./symbol_defs":200,d3:62,"fast-isnumeric":65}],200:[function(t,e,r){"use strict";var n=t("d3");e.exports={circle:{n:0,f:function(t){var e=n.round(t,2);return"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"}},square:{n:1,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"}},diamond:{n:2,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"Z"}},cross:{n:3,f:function(t){var e=n.round(.4*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H"+e+"V"+r+"H-"+e+"V"+e+"H-"+r+"V-"+e+"H-"+e+"V-"+r+"H"+e+"V-"+e+"H"+r+"Z"}},x:{n:4,f:function(t){var e=n.round(.8*t/Math.sqrt(2),2),r="l"+e+","+e,i="l"+e+",-"+e,a="l-"+e+",-"+e,o="l-"+e+","+e;return"M0,"+e+r+i+a+i+a+o+a+o+r+o+r+"Z"}},"triangle-up":{n:5,f:function(t){var e=n.round(2*t/Math.sqrt(3),2),r=n.round(t/2,2),i=n.round(t,2);return"M-"+e+","+r+"H"+e+"L0,-"+i+"Z"}},"triangle-down":{n:6,f:function(t){var e=n.round(2*t/Math.sqrt(3),2),r=n.round(t/2,2),i=n.round(t,2);return"M-"+e+",-"+r+"H"+e+"L0,"+i+"Z"}},"triangle-left":{n:7,f:function(t){var e=n.round(2*t/Math.sqrt(3),2),r=n.round(t/2,2),i=n.round(t,2);return"M"+r+",-"+e+"V"+e+"L-"+i+",0Z"}},"triangle-right":{n:8,f:function(t){var e=n.round(2*t/Math.sqrt(3),2),r=n.round(t/2,2),i=n.round(t,2);return"M-"+r+",-"+e+"V"+e+"L"+i+",0Z"}},"triangle-ne":{n:9,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+r+",-"+e+"H"+e+"V"+r+"Z"}},"triangle-se":{n:10,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+e+",-"+r+"V"+e+"H-"+r+"Z"}},"triangle-sw":{n:11,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H-"+e+"V-"+r+"Z"}},"triangle-nw":{n:12,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+e+","+r+"V-"+e+"H"+r+"Z"}},pentagon:{n:13,f:function(t){var e=n.round(.951*t,2),r=n.round(.588*t,2),i=n.round(-t,2),a=n.round(t*-.309,2),o=n.round(.809*t,2);return"M"+e+","+a+"L"+r+","+o+"H-"+r+"L-"+e+","+a+"L0,"+i+"Z"}},hexagon:{n:14,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),i=n.round(t*Math.sqrt(3)/2,2);return"M"+i+",-"+r+"V"+r+"L0,"+e+"L-"+i+","+r+"V-"+r+"L0,-"+e+"Z"}},hexagon2:{n:15,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),i=n.round(t*Math.sqrt(3)/2,2);return"M-"+r+","+i+"H"+r+"L"+e+",0L"+r+",-"+i+"H-"+r+"L-"+e+",0Z"}},octagon:{n:16,f:function(t){var e=n.round(.924*t,2),r=n.round(.383*t,2);return"M-"+r+",-"+e+"H"+r+"L"+e+",-"+r+"V"+r+"L"+r+","+e+"H-"+r+"L-"+e+","+r+"V-"+r+"Z"}},star:{n:17,f:function(t){var e=1.4*t,r=n.round(.225*e,2),i=n.round(.951*e,2),a=n.round(.363*e,2),o=n.round(.588*e,2),s=n.round(-e,2),l=n.round(e*-.309,2),u=n.round(.118*e,2),c=n.round(.809*e,2),f=n.round(.382*e,2);return"M"+r+","+l+"H"+i+"L"+a+","+u+"L"+o+","+c+"L0,"+f+"L-"+o+","+c+"L-"+a+","+u+"L-"+i+","+l+"H-"+r+"L0,"+s+"Z"}},hexagram:{n:18,f:function(t){var e=n.round(.66*t,2),r=n.round(.38*t,2),i=n.round(.76*t,2);return"M-"+i+",0l-"+r+",-"+e+"h"+i+"l"+r+",-"+e+"l"+r+","+e+"h"+i+"l-"+r+","+e+"l"+r+","+e+"h-"+i+"l-"+r+","+e+"l-"+r+",-"+e+"h-"+i+"Z"}},"star-triangle-up":{n:19,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),i=n.round(1.6*t,2),a=n.round(4*t,2),o="A "+a+","+a+" 0 0 1 ";return"M-"+e+","+r+o+e+","+r+o+"0,-"+i+o+"-"+e+","+r+"Z"}},"star-triangle-down":{n:20,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),i=n.round(1.6*t,2),a=n.round(4*t,2),o="A "+a+","+a+" 0 0 1 ";return"M"+e+",-"+r+o+"-"+e+",-"+r+o+"0,"+i+o+e+",-"+r+"Z"}},"star-square":{n:21,f:function(t){var e=n.round(1.1*t,2),r=n.round(2*t,2),i="A "+r+","+r+" 0 0 1 ";return"M-"+e+",-"+e+i+"-"+e+","+e+i+e+","+e+i+e+",-"+e+i+"-"+e+",-"+e+"Z"}},"star-diamond":{n:22,f:function(t){var e=n.round(1.4*t,2),r=n.round(1.9*t,2),i="A "+r+","+r+" 0 0 1 ";return"M-"+e+",0"+i+"0,"+e+i+e+",0"+i+"0,-"+e+i+"-"+e+",0Z"}},"diamond-tall":{n:23,f:function(t){var e=n.round(.7*t,2),r=n.round(1.4*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},"diamond-wide":{n:24,f:function(t){var e=n.round(1.4*t,2),r=n.round(.7*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},hourglass:{n:25,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"L"+e+",-"+e+"H-"+e+"Z"},noDot:!0},bowtie:{n:26,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"V-"+e+"L-"+e+","+e+"V-"+e+"Z"},noDot:!0},"circle-cross":{n:27,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"circle-x":{n:28,f:function(t){var e=n.round(t,2),r=n.round(t/Math.sqrt(2),2);return"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"square-cross":{n:29,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"square-x":{n:30,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"diamond-cross":{n:31,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM0,-"+e+"V"+e+"M-"+e+",0H"+e},needLine:!0,noDot:!0},"diamond-x":{n:32,f:function(t){var e=n.round(1.3*t,2),r=n.round(.65*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM-"+r+",-"+r+"L"+r+","+r+"M-"+r+","+r+"L"+r+",-"+r},needLine:!0,noDot:!0},"cross-thin":{n:33,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e},needLine:!0,noDot:!0},"x-thin":{n:34,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0},asterisk:{n:35,f:function(t){var e=n.round(1.2*t,2),r=n.round(.85*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r},needLine:!0,noDot:!0},hash:{n:36,f:function(t){var e=n.round(t/2,2),r=n.round(t,2);return"M"+e+","+r+"V-"+r+"m-"+r+",0V"+r+"M"+r+","+e+"H-"+r+"m0,-"+r+"H"+r},needLine:!0},"y-up":{n:37,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+e+","+i+"L0,0M"+e+","+i+"L0,0M0,-"+r+"L0,0"},needLine:!0,noDot:!0},"y-down":{n:38,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+e+",-"+i+"L0,0M"+e+",-"+i+"L0,0M0,"+r+"L0,0"},needLine:!0,noDot:!0},"y-left":{n:39,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M"+i+","+e+"L0,0M"+i+",-"+e+"L0,0M-"+r+",0L0,0"},needLine:!0,noDot:!0},"y-right":{n:40,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+i+","+e+"L0,0M-"+i+",-"+e+"L0,0M"+r+",0L0,0"},needLine:!0,noDot:!0},"line-ew":{n:41,f:function(t){var e=n.round(1.4*t,2);return"M"+e+",0H-"+e},needLine:!0,noDot:!0},"line-ns":{n:42,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e},needLine:!0,noDot:!0},"line-ne":{n:43,f:function(t){var e=n.round(t,2);return"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0},"line-nw":{n:44,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e},needLine:!0,noDot:!0}}},{d3:62}],201:[function(t,e,r){"use strict";e.exports={visible:{valType:"boolean"},type:{valType:"enumerated",values:["percent","constant","sqrt","data"]},symmetric:{valType:"boolean"},array:{valType:"data_array"},arrayminus:{valType:"data_array"},value:{valType:"number",min:0,dflt:10},valueminus:{valType:"number",min:0,dflt:10},traceref:{valType:"integer",min:0,dflt:0},tracerefminus:{valType:"integer",min:0,dflt:0},copy_ystyle:{valType:"boolean"},copy_zstyle:{valType:"boolean"},color:{valType:"color"},thickness:{valType:"number",min:0,dflt:2},width:{valType:"number",min:0},_deprecated:{opacity:{valType:"number"}}}},{}],202:[function(t,e,r){"use strict";function n(t,e,r,n){var a=e["error_"+n]||{},l=a.visible&&-1!==["linear","log"].indexOf(r.type),u=[];if(l){for(var c=s(a),f=0;fs;s++)o[s]={x:r[s],y:i[s]};return o[0].trace=t,n.calc({calcdata:[o],_fullLayout:e}),o},n.plot=t("./plot"),n.style=t("./style"),n.hoverInfo=function(t,e,r){(e.error_y||{}).visible&&(r.yerr=t.yh-t.y,e.error_y.symmetric||(r.yerrneg=t.y-t.ys)),(e.error_x||{}).visible&&(r.xerr=t.xh-t.x,e.error_x.symmetric||(r.xerrneg=t.x-t.xs))}},{"./attributes":201,"./calc":202,"./defaults":204,"./plot":206,"./style":207}],206:[function(t,e,r){"use strict";function n(t,e,r){var n={x:e.c2p(t.x),y:r.c2p(t.y)};return void 0!==t.yh&&(n.yh=r.c2p(t.yh),n.ys=r.c2p(t.ys),a(n.ys)||(n.noYS=!0,n.ys=r.c2p(t.ys,!0))),void 0!==t.xh&&(n.xh=e.c2p(t.xh),n.xs=e.c2p(t.xs),a(n.xs)||(n.noXS=!0,n.xs=e.c2p(t.xs,!0))),n}var i=t("d3"),a=t("fast-isnumeric"),o=t("../../lib"),s=t("../../traces/scatter/subtypes");e.exports=function(t,e){var r=e.x(),l=e.y();t.each(function(t){var e=t[0].trace,u=e.error_x||{},c=e.error_y||{},f=s.hasMarkers(e)&&e.marker.maxdisplayed>0;if(c.visible||u.visible){var h=i.select(this).selectAll("g.errorbar").data(o.identity);h.enter().append("g").classed("errorbar",!0),h.each(function(t){var e=i.select(this),o=n(t,r,l);if(!f||t.vis){var s;if(c.visible&&a(o.x)&&a(o.yh)&&a(o.ys)){var h=c.width;s="M"+(o.x-h)+","+o.yh+"h"+2*h+"m-"+h+",0V"+o.ys,o.noYS||(s+="m-"+h+",0h"+2*h),e.append("path").classed("yerror",!0).attr("d",s)}if(u.visible&&a(o.y)&&a(o.xh)&&a(o.xs)){var d=(u.copy_ystyle?c:u).width;s="M"+o.xh+","+(o.y-d)+"v"+2*d+"m0,-"+d+"H"+o.xs,o.noXS||(s+="m0,-"+d+"v"+2*d),e.append("path").classed("xerror",!0).attr("d",s)}}})}})}},{"../../lib":256,"../../traces/scatter/subtypes":360,d3:62,"fast-isnumeric":65}],207:[function(t,e,r){"use strict";var n=t("d3"),i=t("../color");e.exports=function(t){t.each(function(t){var e=t[0].trace,r=e.error_y||{},a=e.error_x||{},o=n.select(this);o.selectAll("path.yerror").style("stroke-width",r.thickness+"px").call(i.stroke,r.color),a.copy_ystyle&&(a=r),o.selectAll("path.xerror").style("stroke-width",a.thickness+"px").call(i.stroke,a.color)})}},{"../color":176,d3:62}],208:[function(t,e,r){"use strict";var n=t("../../plots/cartesian/constants");e.exports={_isLinkedToArray:!0,source:{valType:"string"},layer:{valType:"enumerated",values:["below","above"],dflt:"above"},sizex:{valType:"number",dflt:0},sizey:{valType:"number",dflt:0},sizing:{valType:"enumerated",values:["fill","contain","stretch"],dflt:"contain"},opacity:{valType:"number",min:0,max:1,dflt:1},x:{valType:"number",dflt:0},y:{valType:"number",dflt:0},xanchor:{valType:"enumerated",values:["left","center","right"],dflt:"left"},yanchor:{valType:"enumerated",values:["top","middle","bottom"],dflt:"top"},xref:{valType:"enumerated",values:["paper",n.idRegex.x.toString()],dflt:"paper"},yref:{valType:"enumerated",values:["paper",n.idRegex.y.toString()],dflt:"paper"}}},{"../../plots/cartesian/constants":284}],209:[function(t,e,r){"use strict";function n(t,e,r){function n(r,n){return a.coerce(t,e,o,r,n)}e=e||{},n("source"),n("layer"),n("x"),n("y"),n("xanchor"),n("yanchor"),n("sizex"),n("sizey"),n("sizing"),n("opacity");for(var s=0;2>s;s++){var l={_fullLayout:r},u=["x","y"][s];i.coerceRef(t,e,l,u,"paper")}return e}var i=t("../../plots/cartesian/axes"),a=t("../../lib"),o=t("./attributes");e.exports=function(t,e){if(t.images&&Array.isArray(t.images))for(var r=t.images,i=e.images=[],a=0;a=2/3},r.isCenterAnchor=function(t){return"center"===t.xanchor||"auto"===t.xanchor&&t.x>1/3&&t.x<2/3},r.isBottomAnchor=function(t){return"bottom"===t.yanchor||"auto"===t.yanchor&&t.y<=1/3},r.isMiddleAnchor=function(t){return"middle"===t.yanchor||"auto"===t.yanchor&&t.y>1/3&&t.y<2/3}},{}],213:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes"),i=t("../color/attributes"),a=t("../../lib/extend").extendFlat;e.exports={bgcolor:{valType:"color"},bordercolor:{valType:"color",dflt:i.defaultLine},borderwidth:{valType:"number",min:0,dflt:0},font:a({},n,{}),orientation:{valType:"enumerated",values:["v","h"],dflt:"v"},traceorder:{valType:"flaglist",flags:["reversed","grouped"],extras:["normal"]},tracegroupgap:{valType:"number",min:0,dflt:10},x:{valType:"number",min:-2,max:3,dflt:1.02},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"left"},y:{valType:"number",min:-2,max:3,dflt:1},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto"}}},{"../../lib/extend":253,"../../plots/font_attributes":297,"../color/attributes":175}],214:[function(t,e,r){"use strict";e.exports={scrollBarWidth:4,scrollBarHeight:20,scrollBarColor:"#808BA4",scrollBarMargin:4}},{}],215:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../plots/plots"),a=t("./attributes"),o=t("./helpers");e.exports=function(t,e,r){function s(t,e){return n.coerce(h,d,a,t,e)}for(var l,u,c,f,h=t.legend||{},d=e.legend={},p=0,g="normal",v=0;v1);if(y!==!1){if(s("bgcolor",e.paper_bgcolor),s("bordercolor"),s("borderwidth"),n.coerceFont(s,"font",e.font),s("orientation"),"h"===d.orientation){var b=t.xaxis;b&&b.rangeslider&&b.rangeslider.visible?(l=0,c="left",u=1.1,f="bottom"):(l=0,c="left",u=-.1,f="top")}s("traceorder",g),o.isGrouped(e.legend)&&s("tracegroupgap"),s("x",l),s("xanchor",c),s("y",u),s("yanchor",f),n.noneOrAll(h,d,["x","y"])}}},{"../../lib":256,"../../plots/plots":303,"./attributes":213,"./helpers":218}],216:[function(t,e,r){"use strict";function n(t,e){function r(r){c.util.convertToTspans(r,function(){r.selectAll("tspan.line").attr({x:r.attr("x")}),t.call(a,e)})}var n=t.data()[0][0],i=e._fullLayout,o=n.trace,s=h.traceIs(o,"pie"),l=o.index,u=s?n.label:o.name,f=t.selectAll("text.legendtext").data([0]);f.enter().append("text").classed("legendtext",!0),f.attr({x:40,y:0,"data-unformatted":u}).style("text-anchor","start").classed("user-select-none",!0).call(p.font,i.legend.font).text(u),e._context.editable&&!s?f.call(c.util.makeEditable).call(r).on("edit",function(t){this.attr({"data-unformatted":t}),this.text(t).call(r),this.text()||(t=" "),c.restyle(e,"name",t,l)}):f.call(r)}function i(t,e){var r=e._fullLayout.hiddenlabels?e._fullLayout.hiddenlabels.slice():[],n=t.selectAll("rect").data([0]);n.enter().append("rect").classed("legendtoggle",!0).style("cursor","pointer").attr("pointer-events","all").call(g.fill,"rgba(0,0,0,0)"),n.on("click",function(){if(!e._dragged){var n,i,a=t.data()[0][0],o=e._fullData,s=a.trace,l=s.legendgroup,u=[];if(h.traceIs(s,"pie")){var f=a.label,d=r.indexOf(f);-1===d?r.push(f):r.splice(d,1),c.relayout(e,"hiddenlabels",r)}else{if(""===l)u=[s.index];else for(var p=0;ptspan"),d=h[0].length||1;r=l*d,n=c.node()&&p.bBox(c.node()).width;var g=l*(.3+(1-d)/2);c.attr("y",g),h.attr("y",g)}r=Math.max(r,16)+3,a.attr({x:0,y:-r/2,height:r}),i.height=r,i.width=n}function o(t,e,r){var n=t._fullLayout,i=n.legend,a=i.borderwidth,o=b.isGrouped(i);if(b.isVertical(i))o&&e.each(function(t,e){f.setTranslate(this,0,e*i.tracegroupgap)}),i.width=0,i.height=0,r.each(function(t){var e=t[0],r=e.height,n=e.width;f.setTranslate(this,a,5+a+i.height+r/2),i.height+=r,i.width=Math.max(i.width,n)}),i.width+=45+2*a,i.height+=10+2*a,o&&(i.height+=(i._lgroupsLength-1)*i.tracegroupgap),r.selectAll(".legendtoggle").attr("width",(t._context.editable?0:i.width)+40),i.width=Math.ceil(i.width),i.height=Math.ceil(i.height);else if(o){i.width=0,i.height=0;for(var s=[i.width],l=e.data(),c=0,h=l.length;h>c;c++){var d=l[c].map(function(t){return t[0].width}),p=40+Math.max.apply(null,d);i.width+=i.tracegroupgap+p,s.push(i.width)}e.each(function(t,e){f.setTranslate(this,s[e],0)}),e.each(function(){var t=u.select(this),e=t.selectAll("g.traces"),r=0;e.each(function(t){var e=t[0],n=e.height;f.setTranslate(this,0,5+a+r+n/2),r+=n}),i.height=Math.max(i.height,r)}),i.height+=10+2*a,i.width+=2*a,i.width=Math.ceil(i.width),i.height=Math.ceil(i.height),r.selectAll(".legendtoggle").attr("width",t._context.editable?0:i.width)}else{i.width=0,i.height=0;var g=0,v=0,m=0,y=0;r.each(function(t){m=Math.max(40+t[0].width,m)}),r.each(function(t){var e=t[0],r=m,o=i.tracegroupgap||5;a+y+o+r>n.width-(n.margin.r+n.margin.l)&&(y=0,g+=v,i.height=i.height+v,v=0),f.setTranslate(this,a+y,5+a+e.height/2+g),i.width+=o+r,i.height=Math.max(i.height,e.height),y+=o+r,v=Math.max(e.height,v)}),i.width+=2*a,i.height+=10+2*a,i.width=Math.ceil(i.width),i.height=Math.ceil(i.height),r.selectAll(".legendtoggle").attr("width",t._context.editable?0:i.width)}}function s(t){var e=t._fullLayout,r=e.legend,n="left";x.isRightAnchor(r)?n="right":x.isCenterAnchor(r)&&(n="center");var i="top";x.isBottomAnchor(r)?i="bottom":x.isMiddleAnchor(r)&&(i="middle"),h.autoMargin(t,"legend",{x:r.x,y:r.y,l:r.width*({right:1,center:.5}[n]||0),r:r.width*({left:1,center:.5}[n]||0),b:r.height*({top:1,middle:.5}[i]||0),t:r.height*({bottom:1,middle:.5}[i]||0)})}function l(t){var e=t._fullLayout,r=e.legend,n="left";x.isRightAnchor(r)?n="right":x.isCenterAnchor(r)&&(n="center"),h.autoMargin(t,"legend",{x:r.x,y:.5,l:r.width*({right:1,center:.5}[n]||0),r:r.width*({left:1,center:.5}[n]||0),b:0,t:0})}var u=t("d3"),c=t("../../plotly"),f=t("../../lib"),h=t("../../plots/plots"),d=t("../dragelement"),p=t("../drawing"),g=t("../color"),v=t("./constants"),m=t("./get_legend_data"),y=t("./style"),b=t("./helpers"),x=t("./anchor_utils");e.exports=function(t){function e(t,e){E.attr("data-scroll",e).call(f.setTranslate,0,e),T.call(p.setRect,F,t,v.scrollBarWidth,v.scrollBarHeight),k.select("rect").attr({y:b.borderwidth-e})}var r=t._fullLayout,a="legend"+r._uid;if(r._infolayer&&t.calcdata){var b=r.legend,_=r.showlegend&&m(t.calcdata,b),w=r.hiddenlabels||[];if(!r.showlegend||!_.length)return r._infolayer.selectAll(".legend").remove(),r._topdefs.select("#"+a).remove(),void h.autoMargin(t,"legend");var A=r._infolayer.selectAll("g.legend").data([0]);A.enter().append("g").attr({"class":"legend","pointer-events":"all"});var k=r._topdefs.selectAll("#"+a).data([0]);k.enter().append("clipPath").attr("id",a).append("rect");var M=A.selectAll("rect.bg").data([0]);M.enter().append("rect").attr({"class":"bg","shape-rendering":"crispEdges"}),M.call(g.stroke,b.bordercolor),M.call(g.fill,b.bgcolor),M.style("stroke-width",b.borderwidth+"px");var E=A.selectAll("g.scrollbox").data([0]);E.enter().append("g").attr("class","scrollbox");var T=A.selectAll("rect.scrollbar").data([0]);T.enter().append("rect").attr({"class":"scrollbar",rx:20,ry:2,width:0,height:0}).call(g.fill,"#808BA4");var L=E.selectAll("g.groups").data(_);L.enter().append("g").attr("class","groups"),L.exit().remove();var S=L.selectAll("g.traces").data(f.identity);S.enter().append("g").attr("class","traces"),S.exit().remove(),S.call(y).style("opacity",function(t){var e=t[0].trace;return h.traceIs(e,"pie")?-1!==w.indexOf(t[0].label)?.5:1:"legendonly"===e.visible?.5:1}).each(function(){u.select(this).call(n,t).call(i,t)});var C=0!==A.enter().size();C&&(o(t,L,S),s(t));var R=0,I=r.width,P=0,O=r.height;o(t,L,S),b.height>O?l(t):s(t);var N=r._size,z=N.l+N.w*b.x,D=N.t+N.h*(1-b.y);x.isRightAnchor(b)?z-=b.width:x.isCenterAnchor(b)&&(z-=b.width/2),x.isBottomAnchor(b)?D-=b.height:x.isMiddleAnchor(b)&&(D-=b.height/2);var F=b.width,B=N.w;F>B?(z=N.l,F=B):(z+F>I&&(z=I-F),R>z&&(z=R),F=Math.min(I-z,b.width));var j=b.height,U=N.h;j>U?(D=N.t,j=U):(D+j>O&&(D=O-j),P>D&&(D=P),j=Math.min(O-D,b.height)),f.setTranslate(A,z,D);var V,q,H=j-v.scrollBarHeight-2*v.scrollBarMargin,G=b.height-j;if(b.height<=j||t._context.staticPlot)M.attr({width:F-b.borderwidth,height:j-b.borderwidth,x:b.borderwidth/2,y:b.borderwidth/2}),f.setTranslate(E,0,0),k.select("rect").attr({width:F-2*b.borderwidth,height:j-2*b.borderwidth,x:b.borderwidth,y:b.borderwidth}),E.call(p.setClipUrl,a);else{V=v.scrollBarMargin,q=E.attr("data-scroll")||0,M.attr({width:F-2*b.borderwidth+v.scrollBarWidth+v.scrollBarMargin,height:j-b.borderwidth,x:b.borderwidth/2,y:b.borderwidth/2}),k.select("rect").attr({width:F-2*b.borderwidth+v.scrollBarWidth+v.scrollBarMargin,height:j-2*b.borderwidth,x:b.borderwidth,y:b.borderwidth-q}),E.call(p.setClipUrl,a),C&&e(V,q),A.on("wheel",null),A.on("wheel",function(){q=f.constrain(E.attr("data-scroll")-u.event.deltaY/H*G,-G,0),V=v.scrollBarMargin-q/G*H,e(V,q),u.event.preventDefault()}),T.on(".drag",null),E.on(".drag",null);var X=u.behavior.drag().on("drag",function(){V=f.constrain(u.event.y-v.scrollBarHeight/2,v.scrollBarMargin,v.scrollBarMargin+H),q=-(V-v.scrollBarMargin)/H*G,e(V,q)});T.call(X),E.call(X)}if(t._context.editable){var Y,W,Z,Q;A.classed("cursor-move",!0),d.init({element:A.node(),prepFn:function(){var t=f.getTranslate(A);Z=t.x,Q=t.y},moveFn:function(t,e){var r=Z+t,n=Q+e;f.setTranslate(A,r,n),Y=d.align(r,0,N.l,N.l+N.w,b.xanchor),W=d.align(n,0,N.t+N.h,N.t,b.yanchor)},doneFn:function(e){e&&void 0!==Y&&void 0!==W&&c.relayout(t,{"legend.x":Y,"legend.y":W})}})}}}},{"../../lib":256,"../../plotly":276,"../../plots/plots":303,"../color":176,"../dragelement":197,"../drawing":199,"./anchor_utils":212,"./constants":214,"./get_legend_data":217,"./helpers":218,"./style":220,d3:62}],217:[function(t,e,r){"use strict";var n=t("../../plots/plots"),i=t("./helpers");e.exports=function(t,e){function r(t,r){if(""!==t&&i.isGrouped(e))-1===l.indexOf(t)?(l.push(t),u=!0,s[t]=[[r]]):s[t].push([r]);else{var n="~~i"+f;l.push(n),s[n]=[[r]],f++}}var a,o,s={},l=[],u=!1,c={},f=0;for(a=0;aa;a++)m=s[l[a]],y[a]=i.isReversed(e)?m.reverse():m;else{for(y=[new Array(b)],a=0;b>a;a++)m=s[l[a]][0],y[0][i.isReversed(e)?b-a-1:a]=m;b=1}return e._lgroupsLength=b,y}},{"../../plots/plots":303,"./helpers":218}],218:[function(t,e,r){"use strict";var n=t("../../plots/plots");r.legendGetsTrace=function(t){return t.visible&&n.traceIs(t,"showLegend")},r.isGrouped=function(t){return-1!==(t.traceorder||"").indexOf("grouped")},r.isVertical=function(t){return"h"!==t.orientation},r.isReversed=function(t){return-1!==(t.traceorder||"").indexOf("reversed")}},{"../../plots/plots":303}],219:[function(t,e,r){"use strict";var n=e.exports={};n.layoutAttributes=t("./attributes"),n.supplyLayoutDefaults=t("./defaults"),n.draw=t("./draw"),n.style=t("./style")},{"./attributes":213,"./defaults":215,"./draw":216,"./style":220}],220:[function(t,e,r){"use strict";function n(t){var e=t[0].trace,r=e.visible&&e.fill&&"none"!==e.fill,n=d.hasLines(e),i=l.select(this).select(".legendfill").selectAll("path").data(r?[t]:[]);i.enter().append("path").classed("js-fill",!0),i.exit().remove(),i.attr("d","M5,0h30v6h-30z").call(f.fillGroupStyle);var a=l.select(this).select(".legendlines").selectAll("path").data(n?[t]:[]);a.enter().append("path").classed("js-line",!0).attr("d","M5,0h30"),a.exit().remove(),a.call(f.lineGroupStyle)}function i(t){function e(t,e,r){var n=u.nestedProperty(o,t).get(),i=Array.isArray(n)&&e?e(n):n;if(r){if(ir[1])return r[1]}return i}function r(t){return t[0]}var n,i,a=t[0],o=a.trace,s=d.hasMarkers(o),c=d.hasText(o),h=d.hasLines(o);if(s||c||h){var p={},g={};s&&(p.mc=e("marker.color",r),p.mo=e("marker.opacity",u.mean,[.2,1]),p.ms=e("marker.size",u.mean,[2,16]),p.mlc=e("marker.line.color",r),p.mlw=e("marker.line.width",u.mean,[0,5]),g.marker={sizeref:1,sizemin:1,sizemode:"diameter"}),h&&(g.line={width:e("line.width",r,[0,10])}),c&&(p.tx="Aa",p.tp=e("textposition",r),p.ts=10,p.tc=e("textfont.color",r),p.tf=e("textfont.family",r)),n=[u.minExtend(a,p)],i=u.minExtend(o,g)}var v=l.select(this).select("g.legendpoints"),m=v.selectAll("path.scatterpts").data(s?n:[]);m.enter().append("path").classed("scatterpts",!0).attr("transform","translate(20,0)"),m.exit().remove(),m.call(f.pointStyle,i),s&&(n[0].mrc=3);var y=v.selectAll("g.pointtext").data(c?n:[]);y.enter().append("g").classed("pointtext",!0).append("text").attr("transform","translate(20,0)"),y.exit().remove(),y.selectAll("text").call(f.textPointStyle,i)}function a(t){var e=t[0].trace,r=e.marker||{},n=r.line||{},i=l.select(this).select("g.legendpoints").selectAll("path.legendbar").data(c.traceIs(e,"bar")?[t]:[]);i.enter().append("path").classed("legendbar",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),i.exit().remove(),i.each(function(t){var e=(t.mlw+1||n.width+1)-1,i=l.select(this);i.style("stroke-width",e+"px").call(h.fill,t.mc||r.color),e&&i.call(h.stroke,t.mlc||n.color)})}function o(t){var e=t[0].trace,r=l.select(this).select("g.legendpoints").selectAll("path.legendbox").data(c.traceIs(e,"box")&&e.visible?[t]:[]);r.enter().append("path").classed("legendbox",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),r.exit().remove(),r.each(function(t){var r=(t.lw+1||e.line.width+1)-1,n=l.select(this);n.style("stroke-width",r+"px").call(h.fill,t.fc||e.fillcolor),r&&n.call(h.stroke,t.lc||e.line.color)})}function s(t){var e=t[0].trace,r=l.select(this).select("g.legendpoints").selectAll("path.legendpie").data(c.traceIs(e,"pie")&&e.visible?[t]:[]);r.enter().append("path").classed("legendpie",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),r.exit().remove(),r.size()&&r.call(p,t[0],e)}var l=t("d3"),u=t("../../lib"),c=t("../../plots/plots"),f=t("../drawing"),h=t("../color"),d=t("../../traces/scatter/subtypes"),p=t("../../traces/pie/style_one");e.exports=function(t){t.each(function(t){var e=l.select(this),r=e.selectAll("g.legendfill").data([t]);r.enter().append("g").classed("legendfill",!0);var n=e.selectAll("g.legendlines").data([t]);n.enter().append("g").classed("legendlines",!0);var i=e.selectAll("g.legendsymbols").data([t]);i.enter().append("g").classed("legendsymbols",!0),i.style("opacity",t[0].trace.opacity),i.selectAll("g.legendpoints").data([t]).enter().append("g").classed("legendpoints",!0)}).each(a).each(o).each(s).each(n).each(i)}},{"../../lib":256,"../../plots/plots":303,"../../traces/pie/style_one":339,"../../traces/scatter/subtypes":360,"../color":176,"../drawing":199,d3:62}],221:[function(t,e,r){"use strict";function n(t,e){var r=e.currentTarget,n=r.getAttribute("data-attr"),i=r.getAttribute("data-val")||!0,a=t._fullLayout,o={};if("zoom"===n){for(var s,l,c="in"===i?.5:2,f=(1+c)/2,h=(1-c)/2,d=u.Axes.list(t,null,!0),p=0;py;y++){var b=s[y];h=m[b]={};for(var x=0;x1)return n(["resetViews","toggleHover"]),o(v,r);c&&(n(["zoom3d","pan3d","orbitRotation","tableRotation"]),n(["resetCameraDefault3d","resetCameraLastSave3d"]),n(["hoverClosest3d"])),h&&(n(["zoomInGeo","zoomOutGeo","resetGeo"]),n(["hoverClosestGeo"]));var m=i(s),y=[];return((u||p)&&!m||g)&&(y=["zoom2d","pan2d"]),(u||g)&&a(l)&&(y.push("select2d"),y.push("lasso2d")),y.length&&n(y),!u&&!p||m||g||n(["zoomIn2d","zoomOut2d","autoScale2d","resetScale2d"]),u&&d?n(["toggleHover"]):p?n(["hoverClosestGl2d"]):u?n(["hoverClosestCartesian","hoverCompareCartesian"]):d&&n(["hoverClosestPie"]),o(v,r)}function i(t){for(var e=l.Axes.list({_fullLayout:t},null,!0),r=!0,n=0;n0);if(p){var g=i(e,r,l);c("x",g[0]),c("y",g[1]),a.noneOrAll(t,e,["x","y"]),c("xanchor"),c("yanchor"),a.coerceFont(c,"font",r.font);var v=c("bgcolor");c("activecolor",o.contrast(v,u.lightAmount,u.darkAmount)),c("bordercolor"),c("borderwidth")}}},{"../../lib":256,"../color":176,"./attributes":224,"./button_attributes":225,"./constants":226}],228:[function(t,e,r){"use strict";function n(t){for(var e=m.list(t,"x",!0),r=[],n=0;ne){var r=e;e=t,t=r}s.setAttributes(w,{"data-min":t,"data-max":e}),s.setAttributes(P,{x:t,width:e-t}),s.setAttributes(M,{width:t}),s.setAttributes(E,{x:e,width:p-e}),s.setAttributes(T,{transform:"translate("+(t-v-1)+")"}),s.setAttributes(C,{transform:"translate("+e+")"})}var f=t._fullLayout,h=f._infolayer.selectAll("g.range-slider"),d=f.xaxis.rangeslider,p=f._size.w,g=(f.height-f.margin.b-f.margin.t)*d.thickness,v=2,m=Math.floor(d.borderwidth/2),y=f.margin.l,b=f.height-g-f.margin.b,x=0,_=p,w=document.createElementNS(o,"g");s.setAttributes(w,{"class":"range-slider","data-min":x,"data-max":_,"pointer-events":"all",transform:"translate("+y+","+b+")"});var A=document.createElementNS(o,"rect"),k=d.borderwidth%2===0?d.borderwidth:d.borderwidth-1; +-s.setAttributes(A,{fill:d.bgcolor,stroke:d.bordercolor,"stroke-width":d.borderwidth,height:g+k,width:p+k,transform:"translate(-"+m+", -"+m+")","shape-rendering":"crispEdges"});var M=document.createElementNS(o,"rect");s.setAttributes(M,{x:0,width:x,height:g,fill:"rgba(0,0,0,0.4)"});var E=document.createElementNS(o,"rect");s.setAttributes(E,{x:_,width:p-_,height:g,fill:"rgba(0,0,0,0.4)"});var T=document.createElementNS(o,"g"),L=document.createElementNS(o,"rect"),S=document.createElementNS(o,"rect");s.setAttributes(T,{transform:"translate("+(x-v-1)+")"}),s.setAttributes(L,{width:10,height:g,x:-6,fill:"transparent",cursor:"col-resize"}),s.setAttributes(S,{width:v,height:g/2,y:g/4,rx:1,fill:"white",stroke:"#666","shape-rendering":"crispEdges"}),s.appendChildren(T,[S,L]);var C=document.createElementNS(o,"g"),R=document.createElementNS(o,"rect"),I=document.createElementNS(o,"rect");s.setAttributes(C,{transform:"translate("+_+")"}),s.setAttributes(R,{width:10,height:g,x:-2,fill:"transparent",cursor:"col-resize"}),s.setAttributes(I,{width:v,height:g/2,y:g/4,rx:1,fill:"white",stroke:"#666","shape-rendering":"crispEdges"}),s.appendChildren(C,[I,R]);var P=document.createElementNS(o,"rect");s.setAttributes(P,{x:x,width:_-x,height:g,cursor:"ew-resize",fill:"transparent"}),w.addEventListener("mousedown",function(t){function r(t){var r,n,f=+t.clientX-a;switch(i){case P:w.style.cursor="ew-resize",r=+s+f,n=+l+f,c(r,n),u(e(r),e(n));break;case L:w.style.cursor="col-resize",r=+s+f,n=+l,c(r,n),u(e(r),e(n));break;case R:w.style.cursor="col-resize",r=+s,n=+l+f,c(r,n),u(e(r),e(n));break;default:w.style.cursor="ew-resize",r=o,n=o+f,c(r,n),u(e(r),e(n))}}function n(){window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",n),w.style.cursor="auto"}var i=t.target,a=t.clientX,o=a-w.getBoundingClientRect().left,s=w.getAttribute("data-min"),l=w.getAttribute("data-max");window.addEventListener("mousemove",r),window.addEventListener("mouseup",n)}),d.range||(d.range=i.getAutoRange(f.xaxis));var O=l(t,p,g);s.appendChildren(w,[A,O,M,E,P,T,C]),r(f.xaxis.range[0],f.xaxis.range[1]),h.data([0]).enter().append(function(){return d.setRange=r,w})}},{"../../constants/xmlns_namespaces":247,"../../lib":256,"../../plotly":276,"../../plots/cartesian/axes":279,"./helpers":234,"./range_plot":236}],233:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes");e.exports=function(t,e,r,a){function o(t,e){return n.coerce(s,l,i,t,e)}if(t[r].rangeslider){var s=n.isPlainObject(t[r].rangeslider)?t[r].rangeslider:{},l=e[r].rangeslider={};if(o("bgcolor"),o("bordercolor"),o("borderwidth"),o("thickness"),o("visible"),o("range"),l.range&&!e[r].autorange){var u=l.range,c=e[r].range;u[0]=Math.min(u[0],c[0]),u[1]=Math.max(u[1],c[1])}else e[r]._needsExpand=!0;l.visible&&a.forEach(function(t){var r=e[t]||{};r.fixedrange=!0,e[t]=r})}}},{"../../lib":256,"./attributes":231}],234:[function(t,e,r){"use strict";r.setAttributes=function(t,e){for(var r in e)t.setAttribute(r,e[r])},r.appendChildren=function(t,e){for(var r=0;rl;l++){var u=s[l],c={_fullLayout:e},f=M.coerceRef(t,n,c,u);if("path"!==o){var h=.25,d=.75;if("paper"!==f){var p=M.getFromId(c,f),g=a(p);h=g(p.range[0]+h*(p.range[1]-p.range[0])),d=g(p.range[0]+d*(p.range[1]-p.range[0]))}r(u+"0",h),r(u+"1",d)}}return"path"===o?r("path"):k.noneOrAll(t,n,["x0","x1","y0","y1"]),n}function i(t){return"category"===t.type?t.c2l:t.d2l}function a(t){return"category"===t.type?t.l2c:t.l2d}function o(t,e){t.layout.shapes=e,C.supplyLayoutDefaults(t.layout,t._fullLayout),C.drawAll(t)}function s(t){delete t.layout.shapes,t._fullLayout.shapes=[],C.drawAll(t)}function l(t,e,r){for(var n=0;ne;i--)d(t,i).selectAll('[data-index="'+(i-1)+'"]').attr("data-index",i),C.draw(t,i)}function f(t,e,r,o){function s(r){var n={"data-index":e,"fill-rule":"evenodd",d:b(t,C)},i=C.line.width?C.line.color:"rgba(0,0,0,0)",a=r.append("path").attr(n).style("opacity",C.opacity).call(E.stroke,i).call(E.fill,C.fillcolor).call(T.dashLine,C.line.dash,C.line.width);R&&a.call(T.setClipUrl,"clip"+t._fullLayout._uid+R),t._context.editable&&h(t,a,C,e)}var l,u;d(t,e).selectAll('[data-index="'+e+'"]').remove();var c=t.layout.shapes[e];if(c){var f={xref:c.xref,yref:c.yref},g={};"string"==typeof r&&r?g[r]=o:k.isPlainObject(r)&&(g=r);var v=Object.keys(g);for(l=0;ll;l++){var x=y[l];if(void 0===g[x]&&void 0!==c[x]){var _,w=x.charAt(0),A=M.getFromId(t,M.coerceRef(f,{},t,w)),L=M.getFromId(t,M.coerceRef(c,{},t,w)),S=c[x];void 0!==g[w+"ref"]&&(A?(_=i(A)(S),S=(_-A.range[0])/(A.range[1]-A.range[0])):S=(S-L.domain[0])/(L.domain[1]-L.domain[0]),L?(_=L.range[0]+S*(L.range[1]-L.range[0]),S=a(L)(_)):S=A.domain[0]+S*(A.domain[1]-A.domain[0])),c[x]=S}}var C=n(c,t._fullLayout);t._fullLayout.shapes[e]=C;var R;if("below"!==C.layer)R=(C.xref+C.yref).replace(/paper/g,""),s(t._fullLayout._shapeUpperLayer);else if("paper"===C.xref&&"paper"===C.yref)R="",s(t._fullLayout._shapeLowerLayer);else{var I,P=t._fullLayout._plots||{},O=Object.keys(P);for(l=0,u=O.length;u>l;l++)I=P[O[l]],R=O[l],p(t,C,I)&&s(I.shapelayer)}}}function h(t,e,r,n){function i(t){var r=$.right-$.left,n=$.bottom-$.top,i=t.clientX-$.left,a=t.clientY-$.top,o=r>W&&n>Z&&!t.shiftKey?L.getCursor(i/r,1-a/n):"move";S(e,o),Y=o.split("-")[0]}function a(e){U=M.getFromId(t,r.xref),V=M.getFromId(t,r.yref),q=m(t,U),H=m(t,V,!0),G=y(t,U),X=y(t,V,!0);var a="shapes["+n+"]";"path"===r.type?(B=r.path,j=a+".path"):(c=q(r.x0),f=H(r.y0),h=q(r.x1),d=H(r.y1),p=a+".x0",g=a+".y0",_=a+".x1",w=a+".y1"),h>c?(T=c,P=a+".x0",D="x0",C=h,O=a+".x1",F="x1"):(T=h,P=a+".x1",D="x1",C=c,O=a+".x0",F="x0"),d>f?(k=f,R=a+".y0",N="y0",E=d,I=a+".y1",z="y1"):(k=d,R=a+".y1",N="y1",E=f,I=a+".y0",z="y0"),u={},i(e),Q.moveFn="move"===Y?s:l}function o(r){S(e),r&&A.relayout(t,u)}function s(n,i){if("path"===r.type){var a=function(t){return G(q(t)+n)};U&&"date"===U.type&&(a=v(a));var o=function(t){return X(H(t)+i)};V&&"date"===V.type&&(o=v(o)),r.path=x(B,a,o),u[j]=r.path}else u[p]=r.x0=G(c+n),u[g]=r.y0=X(f+i),u[_]=r.x1=G(h+n),u[w]=r.y1=X(d+i);e.attr("d",b(t,r))}function l(n,i){if("path"===r.type){var a=function(t){return G(q(t)+n)};U&&"date"===U.type&&(a=v(a));var o=function(t){return X(H(t)+i)};V&&"date"===V.type&&(o=v(o)),r.path=x(B,a,o),u[j]=r.path}else{var s=~Y.indexOf("n")?k+i:k,l=~Y.indexOf("s")?E+i:E,c=~Y.indexOf("w")?T+n:T,f=~Y.indexOf("e")?C+n:C;l-s>Z&&(u[R]=r[N]=X(s),u[I]=r[z]=X(l)),f-c>W&&(u[P]=r[D]=G(c),u[O]=r[F]=G(f))}e.attr("d",b(t,r))}var u,c,f,h,d,p,g,_,w,k,E,T,C,R,I,P,O,N,z,D,F,B,j,U,V,q,H,G,X,Y,W=10,Z=10,Q={setCursor:i,element:e.node(),prepFn:a,doneFn:o},$=Q.element.getBoundingClientRect();L.init(Q)}function d(t,e){var r=t._fullLayout.shapes[e],n=t._fullLayout._shapeUpperLayer;return r?"below"===r.layer&&(n="paper"===r.xref&&"paper"===r.yref?t._fullLayout._shapeLowerLayer:t._fullLayout._shapeSubplotLayer):k.log("getShapeLayer: undefined shape: index",e),n}function p(t,e,r){var n=A.Axes.getFromId(t,r.id,"x")._id,i=A.Axes.getFromId(t,r.id,"y")._id,a="below"===e.layer,o=n===e.xref||i===e.yref,s=!!r.shapelayer;return a&&o&&s}function g(t){return function(e){return e.replace&&(e=e.replace("_"," ")),t(e)}}function v(t){return function(e){return t(e).replace(" ","_")}}function m(t,e,r){var n,a=t._fullLayout._size;if(e){var o=i(e);n=function(t){return e._offset+e.l2p(o(t,!0))},"date"===e.type&&(n=g(n))}else n=r?function(t){return a.t+a.h*(1-t)}:function(t){return a.l+a.w*t};return n}function y(t,e,r){var n,i=t._fullLayout._size;if(e){var o=a(e);n=function(t){return o(e.p2l(t-e._offset))}}else n=r?function(t){return 1-(t-i.t)/i.h}:function(t){return(t-i.l)/i.w};return n}function b(t,e){var r,n,a,o,s=e.type,l=M.getFromId(t,e.xref),u=M.getFromId(t,e.yref),c=t._fullLayout._size;if(l?(r=i(l),n=function(t){return l._offset+l.l2p(r(t,!0))}):n=function(t){return c.l+c.w*t},u?(a=i(u),o=function(t){return u._offset+u.l2p(a(t,!0))}):o=function(t){return c.t+c.h*(1-t)},"path"===s)return l&&"date"===l.type&&(n=g(n)),u&&"date"===u.type&&(o=g(o)),C.convertPath(e.path,n,o);var f=n(e.x0),h=n(e.x1),d=o(e.y0),p=o(e.y1);if("line"===s)return"M"+f+","+d+"L"+h+","+p;if("rect"===s)return"M"+f+","+d+"H"+h+"V"+p+"H"+f+"Z";var v=(f+h)/2,m=(d+p)/2,y=Math.abs(v-f),b=Math.abs(m-d),x="A"+y+","+b,_=v+y+","+m,w=v+","+(m-b);return"M"+_+x+" 0 1,1 "+w+x+" 0 0,1 "+_+"Z"}function x(t,e,r){return t.replace(R,function(t){var n=0,i=t.charAt(0),a=P[i],o=O[i],s=N[i],l=t.substr(1).replace(I,function(t){return n>=s?t:(a[n]?t=e(t):o[n]&&(t=r(t)),n++,t)});return i+l})}function _(t,e,r,n,i){var a="category"===t.type?Number:t.d2c;if(void 0!==e)return[a(e),a(r)];if(n){var o,s,l,u,c,f=1/0,h=-(1/0),d=n.match(R);for("date"===t.type&&(a=g(a)),o=0;oc&&(f=c),c>h&&(h=c)));return h>=f?[f,h]:void 0}}var w=t("fast-isnumeric"),A=t("../../plotly"),k=t("../../lib"),M=t("../../plots/cartesian/axes"),E=t("../color"),T=t("../drawing"),L=t("../dragelement"),S=t("../../lib/setcursor"),C=e.exports={};C.layoutAttributes=t("./attributes"),C.supplyLayoutDefaults=function(t,e){for(var r=t.shapes||[],i=e.shapes=[],a=0;as&&(t="X"),t});return n>s&&(l=l.replace(/[\s,]*X.*/,""),k.log("Ignoring extra params in segment "+t)),i+l})},C.calcAutorange=function(t){var e,r,n,i,a,o=t._fullLayout,s=o.shapes;if(s.length&&t._fullData.length)for(e=0;eh?r=h:(c.left-=b.offsetLeft,c.right-=b.offsetLeft,c.top-=b.offsetTop,c.bottom-=b.offsetTop,b.selection.each(function(){var t=l.bBox(this);s.bBoxIntersect(c,t,u)&&(r=Math.max(r,o*(t[b.side]-c[a])+u))}),r=Math.min(h,r)),r>0||0>h){var d={left:[-r,0],right:[r,0],top:[0,-r],bottom:[0,r]}[b.side];e.attr("transform","translate("+d+")")}}}function p(){T=0,L=!0,S=R,A._infolayer.select("."+e).attr({"data-unformatted":S}).text(S).on("mouseover.opacity",function(){n.select(this).transition().duration(100).style("opacity",1)}).on("mouseout.opacity",function(){n.select(this).transition().duration(1e3).style("opacity",0)})}var g=r.propContainer,v=r.propName,m=r.traceIndex,y=r.dfltName,b=r.avoid||{},x=r.attributes,_=r.transform,w=r.containerGroup,A=t._fullLayout,k=g.titlefont.family,M=g.titlefont.size,E=g.titlefont.color,T=1,L=!1,S=g.title.trim();""===S&&(T=0),S.match(/Click to enter .+ title/)&&(T=.2,L=!0),w||(w=A._infolayer.selectAll(".g-"+e).data([0]),w.enter().append("g").classed("g-"+e,!0));var C=w.selectAll("text").data([0]);C.enter().append("text"),C.text(S).attr("class",e),C.attr({"data-unformatted":S}).call(f);var R="Click to enter "+y+" title";t._context.editable?(S||p(),C.call(c.makeEditable).on("edit",function(e){void 0!==m?a.restyle(t,v,e,m):a.relayout(t,v,e)}).on("cancel",function(){this.text(this.attr("data-unformatted")).call(f)}).on("input",function(t){this.text(t||" ").attr(x).selectAll("tspan.line").attr(x)})):S&&!S.match(/Click to enter .+ title/)||C.remove(),C.classed("js-placeholder",L)}},{"../../lib":256,"../../lib/svg_text_utils":269,"../../plotly":276,"../../plots/plots":303,"../color":176,"../drawing":199,d3:62,"fast-isnumeric":65}],240:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes"),i=t("../color/attributes"),a=t("../../lib/extend").extendFlat,o={_isLinkedToArray:!0,method:{valType:"enumerated",values:["restyle","relayout"],dflt:"restyle"},args:{valType:"info_array",freeLength:!0,items:[{valType:"any"},{valType:"any"},{valType:"any"}]},label:{valType:"string",dflt:""}};e.exports={_isLinkedToArray:!0,visible:{valType:"boolean"},active:{valType:"integer",min:-1,dflt:0},buttons:o,x:{valType:"number",min:-2,max:3,dflt:-.05},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"right"},y:{valType:"number",min:-2,max:3,dflt:1},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"bottom"},font:a({},n,{}),bgcolor:{valType:"color"},bordercolor:{valType:"color",dflt:i.borderLine},borderwidth:{valType:"number",min:0,dflt:1}}},{"../../lib/extend":253,"../../plots/font_attributes":297,"../color/attributes":175}],241:[function(t,e,r){"use strict";e.exports={name:"updatemenus",itemName:"updatemenu",containerClassName:"updatemenu-container",headerGroupClassName:"updatemenu-header-group",headerClassName:"updatemenu-header",headerArrowClassName:"updatemenu-header-arrow",buttonGroupClassName:"updatemenu-button-group",buttonClassName:"updatemenu-button",itemRectClassName:"updatemenu-item-rect",itemTextClassName:"updatemenu-item-text",menuIndexAttrName:"updatemenu-active-index",autoMarginIdRoot:"updatemenu-",blankHeaderOpts:{label:" "},minWidth:30,minHeight:30,textPadX:40,fontSizeToHeight:1.3,rx:2,ry:2,textOffsetX:12,textOffsetY:3,arrowOffsetX:4,gapButtonHeader:5,gapButton:2,activeColor:"#F4FAFF",hoverColor:"#F4FAFF"}},{}],242:[function(t,e,r){"use strict";function n(t,e,r){function n(r,n){return a.coerce(t,e,o,r,n)}var s=i(t,e),l=n("visible",s.length>0);l&&(n("active"),n("x"),n("y"),a.noneOrAll(t,e,["x","y"]),n("xanchor"),n("yanchor"),a.coerceFont(n,"font",r.font),n("bgcolor",r.paper_bgcolor),n("bordercolor"),n("borderwidth"))}function i(t,e){function r(t,e){return a.coerce(n,i,u,t,e)}for(var n,i,o=t.buttons||[],s=e.buttons=[],l=0;l0?[0]:[]);if(l.enter().append("g").classed(E.containerClassName,!0).style("cursor","pointer"),l.exit().remove(),l.exit().size()&&m(t),0!==r.length){var u=l.selectAll("g."+E.headerGroupClassName).data(r,i);u.enter().append("g").classed(E.headerGroupClassName,!0);var c=l.selectAll("g."+E.buttonGroupClassName).data([0]);c.enter().append("g").classed(E.buttonGroupClassName,!0).style("pointer-events","all"),u.enter().size()&&c.call(v).attr(E.menuIndexAttrName,"-1"),u.exit().each(function(e){y.select(this).remove(),c.call(v).attr(E.menuIndexAttrName,"-1"),x.autoMargin(t,E.autoMarginIdRoot+e._index)});for(var f=0;fi.max?e.set(r):e.set(+t)}},integer:{coerceFunction:function(t,e,r,i){t%1||!n(t)||void 0!==i.min&&ti.max?e.set(r):e.set(+t)}},string:{coerceFunction:function(t,e,r,n){if("string"!=typeof t){var i="number"==typeof t;n.strict!==!0&&i?e.set(String(t)):e.set(r)}else n.noBlank&&!t?e.set(r):e.set(t)}},color:{coerceFunction:function(t,e,r){i(t).isValid()?e.set(t):e.set(r)}},colorscale:{coerceFunction:function(t,e,r){e.set(o(t,r))}},angle:{coerceFunction:function(t,e,r){"auto"===t?e.set("auto"):n(t)?(Math.abs(t)>180&&(t-=360*Math.round(t/360)),e.set(+t)):e.set(r)}},subplotid:{coerceFunction:function(t,e,r){var n=r.length;return"string"==typeof t&&t.substr(0,n)===r&&s.test(t.substr(n))?void e.set(t):void e.set(r)},validateFunction:function(t,e){var r=e.dflt,n=r.length;return t===r?!0:"string"!=typeof t?!1:!(t.substr(0,n)!==r||!s.test(t.substr(n)))}},flaglist:{coerceFunction:function(t,e,r,n){if("string"!=typeof t)return void e.set(r);if(-1!==(n.extras||[]).indexOf(t))return void e.set(t);for(var i=t.split("+"),a=0;a2)return!1;var l=o[0].split("-");if(l.length>3||3!==l.length&&o[1])return!1;if(4===l[0].length)r=Number(l[0]);else{if(2!==l[0].length)return!1;var u=(new Date).getFullYear();r=((Number(l[0])-u+70)%100+200)%100+u-70}return s(r)?1===l.length?new Date(r,0,1).getTime():(n=Number(l[1])-1,l[1].length>2||!(n>=0&&11>=n)?!1:2===l.length?new Date(r,n,1).getTime():(i=Number(l[2]),l[2].length>2||!(i>=1&&31>=i)?!1:(i=new Date(r,n,i).getTime(),o[1]?(l=o[1].split(":"),l.length>3?!1:(a=Number(l[0]), +-l[0].length>2||!(a>=0&&23>=a)?!1:(i+=36e5*a,1===l.length?i:(n=Number(l[1]),l[1].length>2||!(n>=0&&59>=n)?!1:(i+=6e4*n,2===l.length?i:(t=Number(l[2]),t>=0&&60>t?i+1e3*t:!1)))))):i))):!1},r.isDateTime=function(t){return r.dateTime2ms(t)!==!1},r.ms2DateTime=function(t,e){if("undefined"==typeof o)return void l.error("d3 is not defined.");e||(e=0);var r=new Date(t),i=o.time.format("%Y-%m-%d")(r);return 7776e6>e?(i+=" "+n(r.getHours(),2),432e6>e&&(i+=":"+n(r.getMinutes(),2),108e5>e&&(i+=":"+n(r.getSeconds(),2),3e5>e&&(i+="."+n(r.getMilliseconds(),3)))),i.replace(/([:\s]00)*\.?[0]*$/,"")):i};var u={H:["%H:%M:%S~%L","%H:%M:%S","%H:%M"],I:["%I:%M:%S~%L%p","%I:%M:%S%p","%I:%M%p"],D:["%H","%I%p","%Hh"]},c={Y:["%Y~%m~%d","%Y%m%d","%y%m%d","%m~%d~%Y","%d~%m~%Y"],Yb:["%b~%d~%Y","%d~%b~%Y","%Y~%d~%b","%Y~%b~%d"],y:["%m~%d~%y","%d~%m~%y","%y~%m~%d"],yb:["%b~%d~%y","%d~%b~%y","%y~%d~%b","%y~%b~%d"]},f=o.time.format.utc,h={Y:{H:["%Y~%m~%dT%H:%M:%S","%Y~%m~%dT%H:%M:%S~%L"].map(f),I:[],D:["%Y%m%d%H%M%S","%Y~%m","%m~%Y"].map(f)},Yb:{H:[],I:[],D:["%Y~%b","%b~%Y"].map(f)},y:{H:[],I:[],D:[]},yb:{H:[],I:[],D:[]}};["Y","Yb","y","yb"].forEach(function(t){c[t].forEach(function(e){h[t].D.push(f(e)),["H","I","D"].forEach(function(r){u[r].forEach(function(n){var i=h[t][r];i.push(f(e+"~"+n)),i.push(f(n+"~"+e))})})})});var d=/[a-z]*/g,p=function(t){return t.substr(0,3)},g=/(mon|tue|wed|thu|fri|sat|sun|the|of|st|nd|rd|th)/g,v=/[\s,\/\-\.\(\)]+/g,m=/~?([ap])~?m(~|$)/,y=function(t,e){return e+"m "},b=/\d\d\d\d/,x=/(^|~)[a-z]{3}/,_=/[ap]m/,w=/:/,A=/q([1-4])/,k=["31~mar","30~jun","30~sep","31~dec"],M=function(t,e){return k[e-1]},E=/ ?([+\-]\d\d:?\d\d|Z)$/;r.parseDate=function(t){if(t.getTime)return t;if("string"!=typeof t)return!1;t=t.toLowerCase().replace(d,p).replace(g,"").replace(v,"~").replace(m,y).replace(A,M).trim().replace(E,"");var e,r,n=null,o=i(t),s=a(t);e=h[o][s],r=e.length;for(var l=0;r>l&&!(n=e[l].parse(t));l++);if(!(n instanceof Date))return!1;var u=n.getTimezoneOffset();return n.setTime(n.getTime()+60*u*1e3),n}},{"../lib":256,d3:62,"fast-isnumeric":65}],252:[function(t,e,r){"use strict";var n=t("events").EventEmitter,i={init:function(t){if(t._ev instanceof n)return t;var e=new n;return t._ev=e,t.on=e.on.bind(e),t.once=e.once.bind(e),t.removeListener=e.removeListener.bind(e),t.removeAllListeners=e.removeAllListeners.bind(e),t.emit=function(r,n){"undefined"!=typeof jQuery&&jQuery(t).trigger(r,n),e.emit(r,n)},t},triggerHandler:function(t,e,r){var n,i;"undefined"!=typeof jQuery&&(n=jQuery(t).triggerHandler(e,r));var a=t._ev;if(!a)return n;var o=a._events[e];if(!o)return n;"function"==typeof o&&(o=[o]);for(var s=o.pop(),l=0;lm;m++){l=t[m];for(u in l)c=g[u],f=l[u],s&&o(f)?g[u]=f:e&&f&&(a(f)||(h=o(f)))?(h?(h=!1,d=c&&o(c)?c:[]):d=c&&a(c)?c:{},g[u]=i([d,f],e,r,s)):("undefined"!=typeof f||r)&&(g[u]=f)}return g}var a=t("./is_plain_object.js"),o=Array.isArray;r.extendFlat=function(){return i(arguments,!1,!1,!1)},r.extendDeep=function(){return i(arguments,!0,!1,!1)},r.extendDeepAll=function(){return i(arguments,!0,!0,!1)},r.extendDeepNoArrays=function(){return i(arguments,!0,!1,!0)}},{"./is_plain_object.js":257}],254:[function(t,e,r){"use strict";function n(t,e){var r=f(t);return r[3]*=e,r}function i(t){return s(t).isValid()?t:c}function a(t){return l(t)?t:h}function o(t,e,r){var o,s,l,f,d,p=t.color,g=Array.isArray(p),v=Array.isArray(e),m=[];if(o=void 0!==t.colorscale?u(t.colorscale,t.cmin,t.cmax):i,s=g?function(t,e){return void 0===t[e]?c:o(t[e])}:i,l=v?function(t,e){return void 0===t[e]?h:a(t[e])}:a,g||v)for(var y=0;r>y;y++)f=s(p,y),d=l(e,y),m[y]=n(f,d);else m=n(p,e);return m}var s=t("tinycolor2"),l=t("fast-isnumeric"),u=t("../components/colorscale/make_scale_function"),c=t("../components/color/attributes").defaultLine,f=t("./str2rgbarray"),h=1;e.exports=o},{"../components/color/attributes":175,"../components/colorscale/make_scale_function":193,"./str2rgbarray":268,"fast-isnumeric":65,tinycolor2:148}],255:[function(t,e,r){"use strict";function n(t){for(var e=0;(e=t.indexOf("",e))>=0;){var r=t.indexOf("",e);if(e>r)break;t=t.slice(0,e)+l(t.slice(e+5,r))+t.slice(r+6)}return t}function i(t){return t.replace(/\/g,"\n")}function a(t){return t.replace(/\<.*\>/g,"")}function o(t){for(var e=0;(e=t.indexOf("&",e))>=0;){var r=t.indexOf(";",e);if(e>r)e+=1;else{var n=u[t.slice(e+1,r)];t=n?t.slice(0,e)+n+t.slice(r+1):t.slice(0,e)+t.slice(r+1)}}return t}function s(t){return""+o(a(n(i(t))))}var l=t("superscript-text"),u={mu:"\u03bc",amp:"&",lt:"<",gt:">"};e.exports=s},{"superscript-text":137}],256:[function(t,e,r){"use strict";var n=t("d3"),i=e.exports={};i.nestedProperty=t("./nested_property"),i.isPlainObject=t("./is_plain_object");var a=t("./coerce");i.valObjects=a.valObjects,i.coerce=a.coerce,i.coerce2=a.coerce2,i.coerceFont=a.coerceFont,i.validate=a.validate;var o=t("./dates");i.dateTime2ms=o.dateTime2ms,i.isDateTime=o.isDateTime,i.ms2DateTime=o.ms2DateTime,i.parseDate=o.parseDate;var s=t("./search");i.findBin=s.findBin,i.sorterAsc=s.sorterAsc,i.sorterDes=s.sorterDes,i.distinctVals=s.distinctVals,i.roundUp=s.roundUp;var l=t("./stats");i.aggNums=l.aggNums,i.len=l.len,i.mean=l.mean,i.variance=l.variance,i.stdev=l.stdev,i.interp=l.interp;var u=t("./matrix");i.init2dArray=u.init2dArray,i.transposeRagged=u.transposeRagged,i.dot=u.dot,i.translationMatrix=u.translationMatrix,i.rotationMatrix=u.rotationMatrix,i.rotationXYMatrix=u.rotationXYMatrix,i.apply2DTransform=u.apply2DTransform,i.apply2DTransform2=u.apply2DTransform2;var c=t("./extend");i.extendFlat=c.extendFlat,i.extendDeep=c.extendDeep,i.extendDeepAll=c.extendDeepAll,i.extendDeepNoArrays=c.extendDeepNoArrays;var f=t("./loggers");i.log=f.log,i.warn=f.warn,i.error=f.error,i.notifier=t("./notifier"),i.swapAttrs=function(t,e,r,n){r||(r="x"),n||(n="y");for(var a=0;ar?Math.max(r,Math.min(e,t)):Math.max(e,Math.min(r,t))},i.bBoxIntersect=function(t,e,r){return r=r||0,t.left<=e.right+r&&e.left<=t.right+r&&t.top<=e.bottom+r&&e.top<=t.bottom+r},i.identity=function(t){return t},i.randstr=function h(t,e,r){if(r||(r=16),void 0===e&&(e=24),0>=e)return"0";var n,i,a,o=Math.log(Math.pow(2,e))/Math.log(r),s="";for(n=2;o===1/0;n*=2)o=Math.log(Math.pow(2,e/n))/Math.log(r)*n;var l=o-Math.floor(o);for(n=0;n-1||u!==1/0&&u>=Math.pow(2,e)?h(t,e,r):s},i.OptionControl=function(t,e){t||(t={}),e||(e="opt");var r={};return r.optionList=[],r._newoption=function(n){n[e]=t,r[n.name]=n,r.optionList.push(n)},r["_"+e]=t,r},i.smooth=function(t,e){if(e=Math.round(e)||0,2>e)return t;var r,n,i,a,o=t.length,s=2*o,l=2*e-1,u=new Array(l),c=new Array(o);for(r=0;l>r;r++)u[r]=(1-Math.cos(Math.PI*(r+1)/e))/(2*e);for(r=0;o>r;r++){for(a=0,n=0;l>n;n++)i=r+n+1-e,-o>i?i-=s*Math.round(i/s):i>=s&&(i-=s*Math.floor(i/s)),0>i?i=-1-i:i>=o&&(i=s-1-i),a+=t[i]*u[n];c[r]=a}return c},i.syncOrAsync=function(t,e,r){function n(){return i.syncOrAsync(t,e,r)}for(var a,o;t.length;)if(o=t.splice(0,1)[0],a=o(e),a&&a.then)return a.then(n).then(void 0,i.promiseError);return r&&r(e)},i.stripTrailingSlash=function(t){return"/"===t.substr(-1)?t.substr(0,t.length-1):t},i.noneOrAll=function(t,e,r){if(t){var n,i,a=!1,o=!0;for(n=0;ni;i++)e[i][r]=t[i]},i.minExtend=function(t,e){var r={};"object"!=typeof e&&(e={});var n,a,o,s=3,l=Object.keys(t);for(n=0;n1?n+a[1]:"";if(i&&(a.length>1||o.length>4))for(;r.test(o);)o=o.replace(r,"$1"+i+"$2");return o+s}},{"./coerce":250,"./dates":251,"./extend":253,"./is_plain_object":257,"./loggers":258,"./matrix":259,"./nested_property":260,"./notifier":261,"./search":264,"./stats":267,d3:62}],257:[function(t,e,r){"use strict";e.exports=function(t){return window&&window.process&&window.process.versions?"[object Object]"===Object.prototype.toString.call(t):"[object Object]"===Object.prototype.toString.call(t)&&Object.getPrototypeOf(t)===Object.prototype}},{}],258:[function(t,e,r){"use strict";var n=t("../plot_api/plot_config"),i=e.exports={};i.log=function(){if(n.logging>1){for(var t=["LOG:"],e=0;e0){for(var t=["WARN:"],e=0;e0){for(var t=["ERROR:"],e=0;en;n++)r[n]=new Array(e);return r},r.transposeRagged=function(t){var e,r,n=0,i=t.length;for(e=0;i>e;e++)n=Math.max(n,t[e].length);var a=new Array(n);for(e=0;n>e;e++)for(a[e]=new Array(i),r=0;i>r;r++)a[e][r]=t[r][e];return a},r.dot=function(t,e){if(!t.length||!e.length||t.length!==e.length)return null;var n,i,a=t.length;if(t[0].length)for(n=new Array(a),i=0;a>i;i++)n[i]=r.dot(t[i],e);else if(e[0].length){var o=r.transposeRagged(e);for(n=new Array(o.length),i=0;ii;i++)n+=t[i]*e[i];return n},r.translationMatrix=function(t,e){return[[1,0,t],[0,1,e],[0,0,1]]},r.rotationMatrix=function(t){var e=t*Math.PI/180;return[[Math.cos(e),-Math.sin(e),0],[Math.sin(e),Math.cos(e),0],[0,0,1]]},r.rotationXYMatrix=function(t,e,n){return r.dot(r.dot(r.translationMatrix(e,n),r.rotationMatrix(t)),r.translationMatrix(-e,-n))},r.apply2DTransform=function(t){return function(){var e=arguments;3===e.length&&(e=e[0]);var n=1===arguments.length?e[0]:[e[0],e[1]];return r.dot(t,[n[0],n[1],1]).slice(0,2)}},r.apply2DTransform2=function(t){var e=r.apply2DTransform(t);return function(t){return e(t.slice(0,2)).concat(e(t.slice(2,4)))}}},{}],260:[function(t,e,r){"use strict";function n(t,e){return function(){var r,i,a,o,s,l=t;for(o=0;o=0;e--){if(n=t[e],o=!1,Array.isArray(n))for(r=n.length-1;r>=0;r--)u(n[r])?o?n[r]=void 0:n.pop():o=!0;else if("object"==typeof n&&null!==n)for(a=Object.keys(n),o=!1,r=a.length-1;r>=0;r--)u(n[a[r]])&&!i(n[a[r]],a[r])?delete n[a[r]]:o=!0;if(o)return}}function u(t){return void 0===t||null===t?!0:"object"!=typeof t?!1:Array.isArray(t)?!t.length:!Object.keys(t).length}function c(t,e,r){return{set:function(){throw"bad container"},get:function(){},astr:e,parts:r,obj:t}}var f=t("fast-isnumeric");e.exports=function(t,e){if(f(e))e=String(e);else if("string"!=typeof e||"[-1]"===e.substr(e.length-4))throw"bad property string";for(var r,i,o,s=0,l=e.split(".");sr||r>a||o>n||n>s?!1:!e||!u(t)}function r(t,e){var r=t[0],l=t[1];if(i>r||r>a||o>l||l>s)return!1;var u,c,f,h,d,p=n.length,g=n[0][0],v=n[0][1],m=0;for(u=1;p>u;u++)if(c=g,f=v,g=n[u][0],v=n[u][1],h=Math.min(c,g),!(h>r||r>Math.max(c,g)||l>Math.max(f,v)))if(l=l&&r!==h&&m++}return m%2===1}var n=t.slice(),i=n[0][0],a=i,o=n[0][1],s=o;n.push(n[0]);for(var l=1;la;a++)if(o=[t[a][0]-l[0],t[a][1]-l[1]],s=n(o,u),0>s||s>c||Math.abs(n(o,h))>i)return!0;return!1};i.filter=function(t,e){function r(r){t.push(r);var s=n.length,l=i;n.splice(o+1);for(var u=l+1;u1){var s=t.pop();r(s)}return{addPt:r,raw:t,filtered:n}}},{"./matrix":259}],263:[function(t,e,r){"use strict";function n(t,e){for(var r,n=[],a=0;aa.queueLength&&(t.undoQueue.queue.shift(),t.undoQueue.index--)))},o.startSequence=function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!0,t.undoQueue.beginSequence=!0},o.stopSequence=function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!1,t.undoQueue.beginSequence=!1},o.undo=function(t){var e,r;if(t.framework&&t.framework.isPolar)return void t.framework.undo();if(!(void 0===t.undoQueue||isNaN(t.undoQueue.index)||t.undoQueue.index<=0)){for(t.undoQueue.index--,e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,r=0;r=t.undoQueue.queue.length)){for(e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,r=0;rt}function i(t,e){return e>=t}function a(t,e){return t>e}function o(t,e){return t>=e}var s=t("fast-isnumeric"),l=t("../lib");r.findBin=function(t,e,r){if(s(e.start))return r?Math.ceil((t-e.start)/e.size)-1:Math.floor((t-e.start)/e.size);var u,c,f=0,h=e.length,d=0;for(c=e[e.length-1]>=e[0]?r?n:i:r?o:a;h>f&&d++<100;)u=Math.floor((f+h)/2),c(e[u],t)?f=u+1:h=u;return d>90&&l.log("Long binary search..."),f-1},r.sorterAsc=function(t,e){return t-e},r.sorterDes=function(t,e){return e-t},r.distinctVals=function(t){var e=t.slice();e.sort(r.sorterAsc);for(var n=e.length-1,i=e[n]-e[0]||1,a=i/(n||1)/1e4,o=[e[0]],s=0;n>s;s++)e[s+1]>e[s]+a&&(i=Math.min(i,e[s+1]-e[s]),o.push(e[s+1]));return{vals:o,minDiff:i}},r.roundUp=function(t,e,r){for(var n,i=0,a=e.length-1,o=0,s=r?0:1,l=r?1:0,u=r?Math.ceil:Math.floor;a>i&&o++<100;)n=u((i+a)/2),e[n]<=t?i=n+s:a=n-l;return e[i]}},{"../lib":256,"fast-isnumeric":65}],265:[function(t,e,r){"use strict";e.exports=function(t,e){(t.attr("class")||"").split(" ").forEach(function(e){0===e.indexOf("cursor-")&&t.classed(e,!1)}),e&&t.classed("cursor-"+e,!0)}},{}],266:[function(t,e,r){"use strict";var n=t("../components/color"),i=function(){};e.exports=function(t){for(var e in t)"function"==typeof t[e]&&(t[e]=i);t.destroy=function(){t.container.parentNode.removeChild(t.container)};var r=document.createElement("div");return r.textContent="Webgl is not supported by your browser - visit http://get.webgl.org for more info",r.style.cursor="pointer",r.style.fontSize="24px",r.style.color=n.defaults[0],t.container.appendChild(r),t.container.style.background="#FFFFFF",t.container.onclick=function(){window.open("http://get.webgl.org")},!1}},{"../components/color":176}],267:[function(t,e,r){"use strict";var n=t("fast-isnumeric");r.aggNums=function(t,e,i,a){var o,s;if(a||(a=i.length),n(e)||(e=!1),Array.isArray(i[0])){for(s=new Array(a),o=0;a>o;o++)s[o]=r.aggNums(t,e,i[o]);i=s}for(o=0;a>o;o++)n(e)?n(i[o])&&(e=t(+e,+i[o])):e=i[o];return e},r.len=function(t){return r.aggNums(function(t){return t+1},0,t)},r.mean=function(t,e){return e||(e=r.len(t)),r.aggNums(function(t,e){return t+e},0,t)/e},r.variance=function(t,e,i){return e||(e=r.len(t)),n(i)||(i=r.mean(t,e)),r.aggNums(function(t,e){return t+Math.pow(e-i,2)},0,t)/e},r.stdev=function(t,e,n){return Math.sqrt(r.variance(t,e,n))},r.interp=function(t,e){if(!n(e))throw"n should be a finite number";if(e=e*t.length-.5,0>e)return t[0];if(e>t.length-1)return t[t.length-1];var r=e%1;return r*t[Math.ceil(e)]+(1-r)*t[Math.floor(e)]}},{"fast-isnumeric":65}],268:[function(t,e,r){"use strict";function n(t){return t=i(t),a.str2RgbaArray(t.toRgbString())}var i=t("tinycolor2"),a=t("arraytools");e.exports=n},{arraytools:8,tinycolor2:148}],269:[function(t,e,r){"use strict";function n(t,e){return t.node().getBoundingClientRect()[e]}function i(t){return t.replace(/(<|<|<)/g,"\\lt ").replace(/(>|>|>)/g,"\\gt ")}function a(t,e,r){var n="math-output-"+u.Lib.randstr([],64),a=c.select("body").append("div").attr({id:n}).style({visibility:"hidden",position:"absolute"}).style({"font-size":e.fontSize+"px"}).text(i(t));MathJax.Hub.Queue(["Typeset",MathJax.Hub,a.node()],function(){var e=c.select("body").select("#MathJax_SVG_glyphs");if(a.select(".MathJax_SVG").empty()||!a.select("svg").node())f.log("There was an error in the tex syntax.",t),r();else{var n=a.select("svg").node().getBoundingClientRect();r(a.select(".MathJax_SVG"),e,n)}a.remove()})}function o(t){return(t||"").replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")}function s(t){for(var e=t.split(/(<[^<>]*>)/).map(function(t){var e=t.match(/<(\/?)([^ >]*)\s*(.*)>/i),r=e&&e[2].toLowerCase(),n=p[r];if(void 0!==n){var i=e[1],a=e[3],s=a.match(/^style\s*=\s*"([^"]+)"\s*/i);if("a"===r){if(i)return"
";if("href"!==a.substr(0,4).toLowerCase())return"";var l=a.substr(4).replace(/["']/g,"").replace(/=/,""),c=document.createElement("a");return c.href=l,-1===g.indexOf(c.protocol)?"":''}if("br"===r)return"
";if(i)return"sup"===r?'':"sub"===r?'':"";var f=""}return u.util.xml_entity_encode(t).replace(/");n>0;n=e.indexOf("
",n+1))r.push(n);var i=0;r.forEach(function(t){for(var r=t+i,n=e.slice(0,r),a="",o=n.length-1;o>=0;o--){var s=n[o].match(/<(\/?).*>/i);if(s&&"
"!==n[o]){s[1]||(a=n[o]);break}}a&&(e.splice(r+1,0,a),e.splice(r,0,""),i+=2)});var a=e.join(""),s=a.split(/
/gi);return s.length>1&&(e=s.map(function(t,e){return''+t+""})),e.join("")}function l(t,e,r){var n,i,a,o=r.horizontalAlign,s=r.verticalAlign||"top",l=t.node().getBoundingClientRect(),u=e.node().getBoundingClientRect();return i="bottom"===s?function(){return l.bottom-n.height}:"middle"===s?function(){return l.top+(l.height-n.height)/2}:function(){return l.top},a="right"===o?function(){return l.right-n.width}:"center"===o?function(){return l.left+(l.width-n.width)/2}:function(){return l.left},function(){return n=this.node().getBoundingClientRect(),this.style({top:i()-u.top+"px",left:a()-u.left+"px","z-index":1e3}),this}}var u=t("../plotly"),c=t("d3"),f=t("../lib"),h=t("../constants/xmlns_namespaces"),d=e.exports={};c.selection.prototype.appendSVG=function(t){for(var e=['',t,""].join(""),r=(new DOMParser).parseFromString(e,"application/xml"),n=r.documentElement.firstChild;n;)this.node().appendChild(this.node().ownerDocument.importNode(n,!0)),n=n.nextSibling;return r.querySelector("parsererror")?(f.log(r.querySelector("parsererror div").textContent),null):c.select(this.node().lastChild)},d.html_entity_decode=function(t){var e=c.select("body").append("div").style({display:"none"}).html(""),r=t.replace(/(&[^;]*;)/gi,function(t){return"<"===t?"<":"&rt;"===t?">":e.html(t).text()});return e.remove(),r},d.xml_entity_encode=function(t){return t.replace(/&(?!\w+;|\#[0-9]+;| \#x[0-9A-F]+;)/g,"&")},d.convertToTspans=function(t,e){function r(){d.empty()||(p=l.attr("class")+"-math",d.select("svg."+p).remove()),t.text("").style({visibility:"visible","white-space":"pre"}),h=t.appendSVG(o),h||t.text(i),t.select("a").size()&&t.style("pointer-events","all"),e&&e.call(l)}var i=t.text(),o=s(i),l=t,f=!l.attr("data-notex")&&o.match(/([^$]*)([$]+[^$]*[$]+)([^$]*)/),h=i,d=c.select(l.node().parentNode);if(!d.empty()){var p=l.attr("class")?l.attr("class").split(" ")[0]:"text";p+="-math",d.selectAll("svg."+p).remove(),d.selectAll("g."+p+"-group").remove(),t.style({visibility:null});for(var g=t.node();g&&g.removeAttribute;g=g.parentNode)g.removeAttribute("data-bb");if(f){var v=u.Lib.getPlotDiv(l.node());(v&&v._promises||[]).push(new Promise(function(t){l.style({visibility:"hidden"});var i={fontSize:parseInt(l.style("font-size"),10)};a(f[2],i,function(i,a,o){d.selectAll("svg."+p).remove(),d.selectAll("g."+p+"-group").remove();var s=i&&i.select("svg");if(!s||!s.node())return r(),void t();var u=d.append("g").classed(p+"-group",!0).attr({"pointer-events":"none"});u.node().appendChild(s.node()),a&&a.node()&&s.node().insertBefore(a.node().cloneNode(!0),s.node().firstChild),s.attr({"class":p,height:o.height,preserveAspectRatio:"xMinYMin meet"}).style({overflow:"visible","pointer-events":"none"});var c=l.style("fill")||"black";s.select("g").attr({fill:c,stroke:c});var f=n(s,"width"),h=n(s,"height"),g=+l.attr("x")-f*{start:0,middle:.5,end:1}[l.attr("text-anchor")||"start"],v=parseInt(l.style("font-size"),10)||n(l,"height"),m=-v/4;"y"===p[0]?(u.attr({transform:"rotate("+[-90,+l.attr("x"),+l.attr("y")]+") translate("+[-f/2,m-h/2]+")"}),s.attr({x:+l.attr("x"),y:+l.attr("y")})):"l"===p[0]?s.attr({x:l.attr("x"),y:m-h/2}):"a"===p[0]?s.attr({x:0,y:m}):s.attr({x:g,y:+l.attr("y")+m-h/2}),e&&e.call(l,u),t(u)})}))}else r();return t}};var p={sup:'font-size:70%" dy="-0.6em',sub:'font-size:70%" dy="0.3em',b:"font-weight:bold",i:"font-style:italic",a:"",span:"",br:"",em:"font-style:italic;font-weight:bold"},g=["http:","https:","mailto:"],v=new RegExp("]*)?/?>","g");d.plainText=function(t){return(t||"").replace(v," ")},d.makeEditable=function(t,e,r){function n(){a(),o.style({opacity:0});var t,e=h.attr("class");t=e?"."+e.split(" ")[0]+"-math-group":"[class*=-math-group]",t&&c.select(o.node().parentNode).select(t).style({opacity:0})}function i(t){var e=t.node(),r=document.createRange();r.selectNodeContents(e);var n=window.getSelection();n.removeAllRanges(),n.addRange(r),e.focus()}function a(){var t=c.select(u.Lib.getPlotDiv(o.node())),e=t.select(".svg-container"),n=e.append("div");n.classed("plugin-editable editable",!0).style({position:"absolute","font-family":o.style("font-family")||"Arial","font-size":o.style("font-size")||12,color:r.fill||o.style("fill")||"black",opacity:1,"background-color":r.background||"transparent",outline:"#ffffff33 1px solid",margin:[-parseFloat(o.style("font-size"))/8+1,0,0,-1].join("px ")+"px",padding:"0","box-sizing":"border-box"}).attr({contenteditable:!0}).text(r.text||o.attr("data-unformatted")).call(l(o,e,r)).on("blur",function(){o.text(this.textContent).style({opacity:1});var t,e=c.select(this).attr("class");t=e?"."+e.split(" ")[0]+"-math-group":"[class*=-math-group]",t&&c.select(o.node().parentNode).select(t).style({opacity:0});var r=this.textContent;c.select(this).transition().duration(0).remove(),c.select(document).on("mouseup",null),s.edit.call(o,r)}).on("focus",function(){var t=this;c.select(document).on("mouseup",function(){return c.event.target===t?!1:void(document.activeElement===n.node()&&n.node().blur())})}).on("keyup",function(){27===c.event.which?(o.style({opacity:1}),c.select(this).style({opacity:0}).on("blur",function(){return!1}).transition().remove(),s.cancel.call(o,this.textContent)):(s.input.call(o,this.textContent),c.select(this).call(l(o,e,r)))}).on("keydown",function(){13===c.event.which&&this.blur()}).call(i)}r||(r={});var o=this,s=c.dispatch("edit","input","cancel"),f=c.select(this.node()).style({"pointer-events":"all"}),h=e||f;return e&&f.style({"pointer-events":"none"}),r.immediate?n():h.on("click",n),c.rebind(this,s,"on")}},{"../constants/xmlns_namespaces":247,"../lib":256,"../plotly":276,d3:62}],270:[function(t,e,r){"use strict";function n(t){var e;if("string"==typeof t){if(e=document.getElementById(t),null===e)throw new Error("No DOM element with id '"+t+"' exists on the page.");return e}if(null===t||void 0===t)throw new Error("DOM element provided is null or undefined");return t}function i(t){Array.isArray(t._promises)&&t._promises.length>0&&O.log("Clearing previous rejected promises from queue."),t._promises=[]}function a(t,e){t._fullLayout._paperdiv.style("background","white"),P.defaultConfig.setBackground(t,e)}function o(t,e){t._context||(t._context=O.extendFlat({},P.defaultConfig));var r=t._context;e&&(Object.keys(e).forEach(function(t){t in r&&("setBackground"===t&&"opaque"===e[t]?r[t]=a:r[t]=e[t])}),e.plot3dPixelRatio&&!r.plotGlPixelRatio&&(r.plotGlPixelRatio=r.plot3dPixelRatio)),r.staticPlot&&(r.editable=!1,r.autosizable=!1,r.scrollZoom=!1,r.doubleClick=!1,r.showTips=!1,r.showLink=!1,r.displayModeBar=!1)}function s(t,e,r){var n=C.select(t).selectAll(".plot-container").data([0]);n.enter().insert("div",":first-child").classed("plot-container plotly",!0); +-var i=n.selectAll(".svg-container").data([0]);i.enter().append("div").classed("svg-container",!0).style("position","relative"),i.html(""),e&&(t.data=e),r&&(t.layout=r),P.micropolar.manager.fillLayout(t),"initial"===t._fullLayout.autosize&&t._context.autosizable&&(A(t,{}),t._fullLayout.autosize=r.autosize=!0),i.style({width:t._fullLayout.width+"px",height:t._fullLayout.height+"px"}),t.framework=P.micropolar.manager.framework(t),t.framework({data:t.data,layout:t.layout},i.node()),t.framework.setUndoPoint();var a=t.framework.svg(),o=1,s=t._fullLayout.title;""!==s&&s||(o=0);var l="Click to enter title",u=function(){this.call(P.util.convertToTspans)},c=a.select(".title-group text").call(u);if(t._context.editable){c.attr({"data-unformatted":s}),s&&s!==l||(o=.2,c.attr({"data-unformatted":l}).text(l).style({opacity:o}).on("mouseover.opacity",function(){C.select(this).transition().duration(100).style("opacity",1)}).on("mouseout.opacity",function(){C.select(this).transition().duration(1e3).style("opacity",0)}));var f=function(){this.call(P.util.makeEditable).on("edit",function(e){t.framework({layout:{title:e}}),this.attr({"data-unformatted":e}).text(e).call(u),this.call(f)}).on("cancel",function(){var t=this.attr("data-unformatted");this.text(t).call(u)})};c.call(f)}return t._context.setBackground(t,t._fullLayout.paper_bgcolor),D.addLinks(t),Promise.resolve()}function l(t){var e,r;t||(t={}),t.xaxis1&&(t.xaxis||(t.xaxis=t.xaxis1),delete t.xaxis1),t.yaxis1&&(t.yaxis||(t.yaxis=t.yaxis1),delete t.yaxis1);var n=P.Axes.list({_fullLayout:t});for(e=0;ee;e++){var o=t.annotations[e];o.ref&&("paper"===o.ref?(o.xref="paper",o.yref="paper"):"data"===o.ref&&(o.xref="x",o.yref="y"),delete o.ref),u(o,"xref"),u(o,"yref")}void 0===t.shapes||Array.isArray(t.shapes)||(O.warn("Shapes must be an array."),delete t.shapes);var s=(t.shapes||[]).length;for(e=0;s>e;e++){var l=t.shapes[e];u(l,"xref"),u(l,"yref")}var c=t.legend;c&&(c.x>3?(c.x=1.02,c.xanchor="left"):c.x<-2&&(c.x=-.02,c.xanchor="right"),c.y>3?(c.y=1.02,c.yanchor="bottom"):c.y<-2&&(c.y=-.02,c.yanchor="top")),"rotate"===t.dragmode&&(t.dragmode="orbit"),t.scene1&&(t.scene||(t.scene=t.scene1),delete t.scene1);var f=D.getSubplotIds(t,"gl3d");for(e=0;er;++r)b[r]=v[e]+m*y[2+4*r];d.camera={eye:{x:b[0],y:b[1],z:b[2]},center:{x:v[0],y:v[1],z:v[2]},up:{x:y[1],y:y[5],z:y[9]}},delete d.cameraposition}}return B.clean(t),t}function u(t,e){var r=t[e],n=e.charAt(0);r&&"paper"!==r&&(t[e]=P.Axes.cleanId(r,n))}function c(t,e){for(var r=[],n=(t.concat(Array.isArray(e)?e:[]).filter(function(t){return"uid"in t}).map(function(t){return t.uid})),i=0;ia&&(s=O.randstr(n),-1!==r.indexOf(s));a++);o.uid=O.randstr(n),n.push(o.uid)}if(r.push(o.uid),"histogramy"===o.type&&"xbins"in o&&!("ybins"in o)&&(o.ybins=o.xbins,delete o.xbins),o.error_y&&"opacity"in o.error_y){var l=B.defaults,u=o.error_y.color||(D.traceIs(o,"bar")?B.defaultLine:l[i%l.length]);o.error_y.color=B.addOpacity(B.rgb(u),B.opacity(u)*o.error_y.opacity),delete o.error_y.opacity}if("bardir"in o&&("h"!==o.bardir||!D.traceIs(o,"bar")&&"histogram"!==o.type.substr(0,9)||(o.orientation="h",_(o)),delete o.bardir),"histogramy"===o.type&&_(o),"histogramx"!==o.type&&"histogramy"!==o.type||(o.type="histogram"),"scl"in o&&(o.colorscale=o.scl,delete o.scl),"reversescl"in o&&(o.reversescale=o.reversescl,delete o.reversescl),o.xaxis&&(o.xaxis=P.Axes.cleanId(o.xaxis,"x")),o.yaxis&&(o.yaxis=P.Axes.cleanId(o.yaxis,"y")),D.traceIs(o,"gl3d")&&o.scene&&(o.scene=D.subplotsRegistry.gl3d.cleanId(o.scene)),D.traceIs(o,"pie")||(Array.isArray(o.textposition)?o.textposition=o.textposition.map(f):o.textposition&&(o.textposition=f(o.textposition))),D.traceIs(o,"2dMap")&&("YIGnBu"===o.colorscale&&(o.colorscale="YlGnBu"),"YIOrRd"===o.colorscale&&(o.colorscale="YlOrRd")),D.traceIs(o,"markerColorscale")&&o.marker){var c=o.marker;"YIGnBu"===c.colorscale&&(c.colorscale="YlGnBu"),"YIOrRd"===c.colorscale&&(c.colorscale="YlOrRd")}if("surface"===o.type&&O.isPlainObject(o.contours)){var d=["x","y","z"];for(a=0;an?a.push(i+n):a.push(n);return a}function g(t,e,r){var n,i;for(n=0;n=t.data.length||i<-t.data.length)throw new Error(r+" must be valid indices for gd.data.");if(e.indexOf(i,n+1)>-1||i>=0&&e.indexOf(-t.data.length+i)>-1||0>i&&e.indexOf(t.data.length+i)>-1)throw new Error("each index in "+r+" must be unique.")}}function v(t,e,r){if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("currentIndices is a required argument.");if(Array.isArray(e)||(e=[e]),g(t,e,"currentIndices"),"undefined"==typeof r||Array.isArray(r)||(r=[r]),"undefined"!=typeof r&&g(t,r,"newIndices"),"undefined"!=typeof r&&e.length!==r.length)throw new Error("current and new indices must be of equal length.")}function m(t,e,r){var n,i;if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("traces must be defined.");for(Array.isArray(e)||(e=[e]),n=0;n=0&&l0){var s=w(t._boundingBoxMargins),l=s.left+s.right,u=s.bottom+s.top,c=a._container.node().getBoundingClientRect(),f=1-2*o.frameMargins;i=Math.round(f*(c.width-l)),n=Math.round(f*(c.height-u))}else r=window.getComputedStyle(t),n=parseFloat(r.height)||a.height,i=parseFloat(r.width)||a.width;return Math.abs(a.width-i)>1||Math.abs(a.height-n)>1?(a.height=t.layout.height=n,a.width=t.layout.width=i):"initial"!==a.autosize&&(delete e.autosize,a.autosize=t.layout.autosize=!0),D.sanitizeMargins(a),e}function k(t){var e=C.select(t),r=t._fullLayout;if(r._container=e.selectAll(".plot-container").data([0]),r._container.enter().insert("div",":first-child").classed("plot-container",!0).classed("plotly",!0),r._paperdiv=r._container.selectAll(".svg-container").data([0]),r._paperdiv.enter().append("div").classed("svg-container",!0).style("position","relative"),"initial"===r.autosize&&(A(t,{}),r.autosize=!0,t.layout.autosize=!0),r._glcontainer=r._paperdiv.selectAll(".gl-container").data([0]),r._glcontainer.enter().append("div").classed("gl-container",!0),r._geocontainer=r._paperdiv.selectAll(".geo-container").data([0]),r._geocontainer.enter().append("div").classed("geo-container",!0),r._paperdiv.selectAll(".main-svg").remove(),r._paper=r._paperdiv.insert("svg",":first-child").classed("main-svg",!0),r._toppaper=r._paperdiv.append("svg").classed("main-svg",!0),!r._uid){var n=[];C.selectAll("defs").each(function(){this.id&&n.push(this.id.split("-")[1])}),r._uid=O.randstr(n)}r._paperdiv.selectAll(".main-svg").attr(Q.svgAttrs),r._defs=r._paper.append("defs").attr("id","defs-"+r._uid),r._topdefs=r._toppaper.append("defs").attr("id","topdefs-"+r._uid),r._draggers=r._paper.append("g").classed("draglayer",!0);var i=r._paper.append("g").classed("layer-below",!0);r._imageLowerLayer=i.append("g").classed("imagelayer",!0),r._shapeLowerLayer=i.append("g").classed("shapelayer",!0);var a=P.Axes.getSubplots(t);a.join("")!==Object.keys(t._fullLayout._plots||{}).join("")&&M(t,a),r._has("cartesian")&&E(t,a),r._ternarylayer=r._paper.append("g").classed("ternarylayer",!0);var o=r._paper.selectAll(".layer-subplot");r._imageSubplotLayer=o.selectAll(".imagelayer"),r._shapeSubplotLayer=o.selectAll(".shapelayer");var s=r._paper.append("g").classed("layer-above",!0);r._imageUpperLayer=s.append("g").classed("imagelayer",!0),r._shapeUpperLayer=s.append("g").classed("shapelayer",!0),r._pielayer=r._paper.append("g").classed("pielayer",!0),r._glimages=r._paper.append("g").classed("glimages",!0),r._geoimages=r._paper.append("g").classed("geoimages",!0),r._infolayer=r._toppaper.append("g").classed("infolayer",!0),r._zoomlayer=r._toppaper.append("g").classed("zoomlayer",!0),r._hoverlayer=r._toppaper.append("g").classed("hoverlayer",!0),t.emit("plotly_framework");var l=O.syncOrAsync([T,function(){return P.Axes.doTicks(t,"redraw")},F.init],t);return l&&l.then&&t._promises.push(l),l}function M(t,e){function r(e,r){return function(){return P.Axes.getFromId(t,e,r)}}for(var n,i,a=t._fullLayout._plots={},o=0;o0,_=P.Axes.getSubplots(t).join(""),w=Object.keys(t._fullLayout._plots||{}).join(""),A=w===_;x?t.framework===k&&!b&&A||(t.framework=k,k(t)):A?b&&k(t):(t.framework=k,k(t)),b&&P.Axes.saveRangeInitial(t);var M=t._fullLayout,E=!t.calcdata||t.calcdata.length!==(t.data||[]).length;E&&d(t);for(var L=0;LW.range[0]?[1,2]:[2,1]);else{var Q=W.range[0],$=W.range[1];"log"===F?(0>=Q&&0>=$&&a(G+".autorange",!0),0>=Q?Q=$/1e6:0>=$&&($=Q/1e6),a(G+".range[0]",Math.log(Q)/Math.LN10),a(G+".range[1]",Math.log($)/Math.LN10)):(a(G+".range[0]",Math.pow(10,Q)),a(G+".range[1]",Math.pow(10,$)))}else a(G+".autorange",!0)}if("reverse"===U)X.range?X.range.reverse():(a(G+".autorange",!0),X.range=[1,0]),Y.autorange?w=!0:_=!0;else if("annotations"===N.parts[0]||"shapes"===N.parts[0]){var K=N.parts[1],J=N.parts[0],tt=g[J]||[],et=P[O.titleCase(J)],rt=tt[K]||{};2===N.parts.length&&("add"===m[R]||O.isPlainObject(m[R])?L[R]="remove":"remove"===m[R]?-1===K?(L[J]=tt,delete L[R]):L[R]=rt:O.log("???",m)),!o(rt,"x")&&!o(rt,"y")||O.containsAny(R,["color","opacity","align","dash"])||(w=!0),et.draw(t,K,N.parts.slice(2).join("."),m[R]),delete m[R]}else if("images"===N.parts[0]){var it=O.objectFromPath(R,F);O.extendDeepAll(t.layout,it),V.supplyLayoutDefaults(t.layout,t._fullLayout),V.draw(t)}else if("mapbox"===N.parts[0]&&"layers"===N.parts[1]){O.extendDeepAll(t.layout,O.objectFromPath(R,F));var at=(t._fullLayout.mapbox||{}).layers||[];for(I=N.parts[2]+1-at.length,p=0;I>p;p++)at.push({});_=!0}else if("updatemenus"===N.parts[0]){O.extendDeepAll(t.layout,O.objectFromPath(R,F));var ot=t._fullLayout.updatemenus||[];for(I=N.parts[2]+1-ot.length,p=0;I>p;p++)ot.push({});_=!0}else 0===N.parts[0].indexOf("scene")?_=!0:0===N.parts[0].indexOf("geo")?_=!0:0===N.parts[0].indexOf("ternary")?_=!0:!v._has("gl2d")||-1===R.indexOf("axis")&&"plot_bgcolor"!==N.parts[0]?"hiddenlabels"===R?w=!0:-1!==N.parts[0].indexOf("legend")?y=!0:-1!==R.indexOf("title")?b=!0:-1!==N.parts[0].indexOf("bgcolor")?x=!0:N.parts.length>1&&O.containsAny(N.parts[1],["tick","exponent","grid","zeroline"])?b=!0:-1!==R.indexOf(".linewidth")&&-1!==R.indexOf("axis")?b=x=!0:N.parts.length>1&&-1!==N.parts[1].indexOf("line")?x=!0:N.parts.length>1&&"mirror"===N.parts[1]?b=x=!0:"margin.pad"===R?b=x=!0:"margin"===N.parts[0]||"autorange"===N.parts[1]||"rangemode"===N.parts[1]||"type"===N.parts[1]||"domain"===N.parts[1]||R.match(/^(bar|box|font)/)?w=!0:-1!==["hovermode","dragmode"].indexOf(R)?k=!0:-1===["hovermode","dragmode","height","width","autosize"].indexOf(R)&&(_=!0):_=!0,N.set(F)}z.add(t,nt,[t,L],nt,[t,E]),m.autosize&&(m=A(t,m)),(m.height||m.width||m.autosize)&&(w=!0);var st=Object.keys(m),lt=[D.previousPromises];if(_||w)lt.push(function(){return t.layout=void 0,w&&(t.calcdata=void 0),P.plot(t,"",g)});else if(st.length&&(D.supplyDefaults(t),v=t._fullLayout,y&<.push(function(){return q.draw(t),D.previousPromises(t)}),x&<.push(T),b&<.push(function(){return P.Axes.doTicks(t,"redraw"),S(t),D.previousPromises(t)}),k)){var ut;for(Z(t),P.Fx.supplyLayoutDefaults(t.layout,v,t._fullData),P.Fx.init(t),ut=D.getSubplotIds(v,"gl3d"),p=0;p1)};u(r.width)&&u(r.height)||s(new Error("Height and width should be pixel values."));var c=n.clone(e,{format:"png",height:r.height,width:r.width}),f=c.td;f.style.position="absolute",f.style.left="-5000px",document.body.appendChild(f);var h=n.getRedrawFunc(f);a.plot(f,c.data,c.layout,c.config).then(h).then(l).then(function(e){t(e)}).catch(function(t){s(t)})});return s}var i=t("fast-isnumeric"),a=t("../plotly"),o=t("../lib");e.exports=n},{"../lib":256,"../plotly":276,"../snapshot":312,"fast-isnumeric":65}],275:[function(t,e,r){"use strict";function n(t,e,r,i,a,u){u=u||[];for(var c=Object.keys(t),h=0;h1&&l.push(o("object","layout"))),h.supplyDefaults(u);for(var c=u._fullData,v=r.length,m=0;v>m;m++){var y=r[m],b=["data",m];if(p(y)){var x=c[m],_=x.type,w=s.traces[_].attributes;w.type={valType:"enumerated",values:[_]},x.visible===!1&&y.visible!==!1&&l.push(o("invisible",b)),n(y,x,w,l,b);var A=y.transforms,k=x.transforms;if(A){g(A)||l.push(o("array",b,["transforms"])),b.push("transforms");for(var M=0;Mu&&c>e&&(void 0===i[r]?a[f]=E.tickText(t,e):a[f]=s(t,e,String(i[r])),f++);return f=864e5?t._tickround="d":r>=36e5?t._tickround="H":r>=6e4?t._tickround="M":r>=1e3?t._tickround="S":t._tickround=3-Math.round(Math.log(r/2)/Math.LN10);else{b(r)||(r=Number(r.substr(1))),t._tickround=2-Math.floor(Math.log(r)/Math.LN10+.01),e="log"===t.type?Math.pow(10,Math.max(t.range[0],t.range[1])):Math.max(Math.abs(t.range[0]),Math.abs(t.range[1]));var n=Math.floor(Math.log(e)/Math.LN10+.01);Math.abs(n)>3&&("SI"===t.exponentformat||"B"===t.exponentformat?t._tickexponent=3*Math.round((n-1)/3):t._tickexponent=n)}else"M"===r.charAt(0)?t._tickround=2===r.length?"m":"y":t._tickround=null}function o(t,e){var r=t.match(U),n=new Date(e);if(r){var i=Math.min(+r[1]||6,6),a=String(e/1e3%1+2.0000005).substr(2,i).replace(/0+$/,"")||"0";return y.time.format(t.replace(U,a))(n)}return y.time.format(t)(n)}function s(t,e,r){var n=t.tickfont||t._gd._fullLayout.font;return{x:e,dx:0,dy:0,text:r||"",fontSize:n.size,font:n.family,fontColor:n.color}}function l(t,e,r,n){var i,a=e.x,s=t._tickround,l=new Date(a),u="";r&&t.hoverformat?i=o(t.hoverformat,a):t.tickformat?i=o(t.tickformat,a):(n&&(b(s)?s+=2:s={y:"m",m:"d",d:"H",H:"M",M:"S",S:2}[s]),"y"===s?i=N(l):"m"===s?i=z(l):(a!==t._tmin||r||(u="
"+N(l)),"d"===s?i=D(l):"H"===s?i=F(l):(a!==t._tmin||r||(u="
"+D(l)+", "+N(l)),i=B(l),"M"!==s&&(i+=j(l),"S"!==s&&(i+=h(m(a/1e3,1),t,"none",r).substr(1)))))),e.text=i+u}function u(t,e,r,n,i){var a=t.dtick,o=e.x;if(!n||"string"==typeof a&&"L"===a.charAt(0)||(a="L3"),t.tickformat||"string"==typeof a&&"L"===a.charAt(0))e.text=h(Math.pow(10,o),t,i,n);else if(b(a)||"D"===a.charAt(0)&&m(o+.01,1)<.1)if(-1!==["e","E","power"].indexOf(t.exponentformat)){var s=Math.round(o);0===s?e.text=1:1===s?e.text="10":s>1?e.text="10"+s+"":e.text="10\u2212"+-s+"",e.fontSize*=1.25}else e.text=h(Math.pow(10,o),t,"","fakehover"),"D1"===a&&"y"===t._id.charAt(0)&&(e.dy-=e.fontSize/6);else{if("D"!==a.charAt(0))throw"unrecognized dtick "+String(a);e.text=String(Math.round(Math.pow(10,m(o,1)))),e.fontSize*=.75}if("D1"===t.dtick){var l=String(e.text).charAt(0);"0"!==l&&"1"!==l||("y"===t._id.charAt(0)?e.dx-=e.fontSize/4:(e.dy+=e.fontSize/2,e.dx+=(t.range[1]>t.range[0]?1:-1)*e.fontSize*(0>o?.5:.25)))}}function c(t,e){var r=t._categories[Math.round(e.x)];void 0===r&&(r=""),e.text=String(r)}function f(t,e,r,n,i){"all"===t.showexponent&&Math.abs(e.x/t.dtick)<1e-6&&(i="hide"),e.text=h(e.x,t,i,n)}function h(t,e,r,n){var i=0>t,o=e._tickround,s=r||e.exponentformat||"B",l=e._tickexponent,u=e.tickformat;if(n){var c={exponentformat:e.exponentformat,dtick:"none"===e.showexponent?e.dtick:b(t)?Math.abs(t)||1:1,range:"none"===e.showexponent?e.range:[0,t||1]};a(c),o=(Number(c._tickround)||0)+4,l=c._tickexponent,e.hoverformat&&(u=e.hoverformat)}if(u)return y.format(u)(t).replace(/-/g,"\u2212");var f=Math.pow(10,-o)/2;if("none"===s&&(l=0),t=Math.abs(t),f>t)t="0",i=!1;else{if(t+=f,l&&(t*=Math.pow(10,-l),o+=l),0===o)t=String(Math.floor(t));else if(0>o){t=String(Math.round(t)),t=t.substr(0,t.length+o);for(var h=o;0>h;h++)t+="0"}else{t=String(t);var d=t.indexOf(".")+1;d&&(t=t.substr(0,d+o).replace(/\.?0+$/,""))}t=_.numSeparate(t,e._gd._fullLayout.separators)}if(l&&"hide"!==s){var p;p=0>l?"\u2212"+-l:"power"!==s?"+"+l:String(l),"e"===s||("SI"===s||"B"===s)&&(l>12||-15>l)?t+="e"+p:"E"===s?t+="E"+p:"power"===s?t+="\xd710"+p+"":"B"===s&&9===l?t+="B":"SI"!==s&&"B"!==s||(t+=V[l/3+5])}return i?"\u2212"+t:t}function d(t,e){var r,n,i=[];for(r=0;r1)for(n=1;n2e-6||((r-t._forceTick0)/t._minDtick%1+1.000001)%1>2e-6)&&(t._minDtick=0)):t._minDtick=0},E.getAutoRange=function(t){var e,r=[],n=t._min[0].val,i=t._max[0].val;for(e=1;e0&&c>0&&f/c>h&&(l=o,u=s,h=f/c);return n===i?r=d?[n+1,"normal"!==t.rangemode?0:n-1]:["normal"!==t.rangemode?0:n-1,n+1]:h&&("linear"!==t.type&&"-"!==t.type||("tozero"===t.rangemode&&l.val>=0?l={val:0,pad:0}:"nonnegative"===t.rangemode&&(l.val-h*l.pad<0&&(l={val:0,pad:0}),u.val<0&&(u={val:1,pad:0})),h=(u.val-l.val)/(t._length-l.pad-u.pad)),r=[l.val-h*l.pad,u.val+h*u.pad],r[0]===r[1]&&(r=[r[0]-1,r[0]+1]),d&&r.reverse()),r},E.doAutoRange=function(t){t._length||t.setScale();var e=t._min&&t._max&&t._min.length&&t._max.length;if(t.autorange&&e){t.range=E.getAutoRange(t);var r=t._gd.layout[t._name];r||(t._gd.layout[t._name]=r={}),r!==t&&(r.range=t.range.slice(),r.autorange=t.autorange)}},E.saveRangeInitial=function(t,e){for(var r=E.list(t,"",!0),n=!1,i=0;ip&&(p=g/10),u=t.c2l(p),c=t.c2l(g),y&&(u=Math.min(0,u),c=Math.max(0,c)),n(u)){for(d=!0,o=0;o=h?d=!1:s.val>=u&&s.pad<=h&&(t._min.splice(o,1),o--);d&&t._min.push({val:u,pad:y&&0===u?0:h})}if(n(c)){for(d=!0,o=0;o=c&&s.pad>=f?d=!1:s.val<=c&&s.pad<=f&&(t._max.splice(o,1),o--);d&&t._max.push({val:c,pad:y&&0===c?0:f})}}}if((t.autorange||t._needsExpand)&&e){t._min||(t._min=[]),t._max||(t._max=[]),r||(r={}),t._m||t.setScale();var a,o,s,l,u,c,f,h,d,p,g,v=e.length,m=r.padded?.05*t._length:0,y=r.tozero&&("linear"===t.type||"-"===t.type),x=n((t._m>0?r.ppadplus:r.ppadminus)||r.ppad||0),_=n((t._m>0?r.ppadminus:r.ppadplus)||r.ppad||0),w=n(r.vpadplus||r.vpad),A=n(r.vpadminus||r.vpad);for(a=0;6>a;a++)i(a);for(a=v-1;a>5;a--)i(a)}},E.autoBin=function(t,e,r,n){function i(t){return(1+100*(t-d)/f.dtick)%100<2}var a=_.aggNums(Math.min,null,t),o=_.aggNums(Math.max,null,t);if("category"===e.type)return{start:a-.5,end:o+.5,size:1};var s;if(r)s=(o-a)/r;else{var l=_.distinctVals(t),u=Math.pow(10,Math.floor(Math.log(l.minDiff)/Math.LN10)),c=u*_.roundUp(l.minDiff/u,[.9,1.9,4.9,9.9],!0);s=Math.max(c,2*_.stdev(t)/Math.pow(t.length,n?.25:.4))}var f={type:"log"===e.type?"linear":e.type,range:[a,o]};E.autoTicks(f,s);var h,d=E.tickIncrement(E.tickFirst(f),f.dtick,"reverse");if("number"==typeof f.dtick){for(var p=0,g=0,v=0,m=0,y=0;yg&&(p>.3*x||i(a)||i(o))){var w=f.dtick/2;d+=a>d+w?w:-w}var A=1+Math.floor((o-d)/f.dtick);h=d+A*f.dtick}else for(h=d;o>=h;)h=E.tickIncrement(h,f.dtick);return{start:d,end:h,size:f.dtick}},E.calcTicks=function(t){if("array"===t.tickmode)return n(t);if("auto"===t.tickmode||!t.dtick){var e,r=t.nticks;r||("category"===t.type?(e=t.tickfont?1.2*(t.tickfont.size||12):15,r=t._length/e):(e="y"===t._id.charAt(0)?40:80,r=_.constrain(t._length/e,4,9)+1)),E.autoTicks(t,Math.abs(t.range[1]-t.range[0])/r),t._minDtick>0&&t.dtick<2*t._minDtick&&(t.dtick=t._minDtick,t.tick0=t._forceTick0)}t.tick0||(t.tick0="date"===t.type?new Date(2e3,0,1).getTime():0),a(t),t._tmin=E.tickFirst(t);var i=t.range[1]=s:s>=l)&&(o.push(l),!(o.length>1e3));l=E.tickIncrement(l,t.dtick,i));t._tmax=o[o.length-1];for(var u=new Array(o.length),c=0;c157788e5?(e/=315576e5,r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick="M"+12*i(e,r,S)):e>12096e5?(e/=26298e5,t.dtick="M"+i(e,1,C)):e>432e5?(t.dtick=i(e,864e5,I),t.tick0=new Date(2e3,0,2).getTime()):e>18e5?t.dtick=i(e,36e5,C):e>3e4?t.dtick=i(e,6e4,R):e>500?t.dtick=i(e,1e3,R):(r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick=i(e,r,S));else if("log"===t.type)if(t.tick0=0,e>.7)t.dtick=Math.ceil(e);else if(Math.abs(t.range[1]-t.range[0])<1){var n=1.5*Math.abs((t.range[1]-t.range[0])/e);e=Math.abs(Math.pow(10,t.range[1])-Math.pow(10,t.range[0]))/n,r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick="L"+i(e,r,S)}else t.dtick=e>.3?"D2":"D1";else"category"===t.type?(t.tick0=0,t.dtick=Math.ceil(Math.max(e,1))):(t.tick0=0,r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick=i(e,r,S));if(0===t.dtick&&(t.dtick=1),!b(t.dtick)&&"string"!=typeof t.dtick){var a=t.dtick;throw t.dtick=1,"ax.dtick error: "+String(a)}},E.tickIncrement=function(t,e,r){var n=r?-1:1;if(b(e))return t+n*e;var i=e.charAt(0),a=n*Number(e.substr(1));if("M"===i){var o=new Date(t);return o.setMonth(o.getMonth()+a)}if("L"===i)return Math.log(Math.pow(10,t)+a)/Math.LN10;if("D"===i){var s="D2"===e?O:P,l=t+.01*n,u=_.roundUp(m(l,1),s,r);return Math.floor(l)+Math.log(y.round(Math.pow(10,u),1))/Math.LN10}throw"unrecognized dtick "+String(e)},E.tickFirst=function(t){var e=t.range[1]n:n>u;)u=E.tickIncrement(u,i,e);return u}if("L"===c)return Math.log(r((Math.pow(10,n)-a)/f)*f+a)/Math.LN10;if("D"===c){var h="D2"===i?O:P,d=_.roundUp(m(n,1),h,e);return Math.floor(n)+Math.log(y.round(Math.pow(10,d),1))/Math.LN10}throw"unrecognized dtick "+String(i)};var N=y.time.format("%Y"),z=y.time.format("%b %Y"),D=y.time.format("%b %-d"),F=y.time.format("%b %-d %Hh"),B=y.time.format("%H:%M"),j=y.time.format(":%S"),U=/%(\d?)f/g;E.tickText=function(t,e,r){function n(n){var i;return void 0===n?!0:r?"none"===n:(i={first:t._tmin,last:t._tmax}[n],"all"!==n&&e!==i)}var i,a,o=s(t,e),h="array"===t.tickmode,d=r||h;if(h&&Array.isArray(t.ticktext)){var p=Math.abs(t.range[1]-t.range[0])/1e4;for(a=0;a1&&er&&(k=90),i(c,k)}u._lastangle=k}return o(e),e+" done"}function l(){u._boundingBox=r.node().getBoundingClientRect()}var c=r.selectAll("g."+C).data(L,S);if(!u.showticklabels||!b(n))return c.remove(),void o(e);var f,h,p,m,x;"x"===v?(x="bottom"===j?1:-1,f=function(t){return t.dx+N*x},m=n+(O+P)*x,h=function(t){return t.dy+m+t.fontSize*("bottom"===j?1:-.5)},p=function(t){return b(t)&&0!==t&&180!==t?0>t*x?"end":"start":"middle"}):(x="right"===j?1:-1,h=function(t){return t.dy+t.fontSize/2-N*x},f=function(t){return t.dx+n+(O+P+(90===Math.abs(u.tickangle)?t.fontSize/2:0))*x},p=function(t){return b(t)&&90===Math.abs(t)?"middle":"right"===j?"start":"end"});var A=0,k=0,E=[];c.enter().append("g").classed(C,1).append("text").attr("text-anchor","middle").each(function(e){var r=y.select(this),n=t._promises.length;r.call(M.setPosition,f(e),h(e)).call(M.font,e.font,e.fontSize,e.fontColor).text(e.text).call(w.convertToTspans),n=t._promises[n],n?E.push(t._promises.pop().then(function(){i(r,u.tickangle)})):i(r,u.tickangle)}),c.exit().remove(),c.each(function(t){A=Math.max(A,t.fontSize)}),i(c,u._lastangle||u.tickangle);var T=_.syncOrAsync([a,s,l]);return T&&T.then&&t._promises.push(T),T}function o(e){if(!r){var n,i,a,o,s=T.getFromId(t,e),l=y.select(t).selectAll("g."+e+"tick"),u={selection:l,side:s.side},f=e.charAt(0),h=t._fullLayout._size,d=1.5,p=s.titlefont.size;if(l.size()){var g=y.select(l.node().parentNode).attr("transform").match(/translate\(([-\.\d]+),([-\.\d]+)\)/);g&&(u.offsetLeft=+g[1],u.offsetTop=+g[2])}"x"===f?(i="free"===s.anchor?{_offset:h.t+(1-(s.position||0))*h.h,_length:0}:T.getFromId(t,s.anchor),a=s._offset+s._length/2,o=i._offset+("top"===s.side?-10-p*(d+(s.showticklabels?1:0)):i._length+10+p*(d+(s.showticklabels?1.5:.5))),s.rangeslider&&s.rangeslider.visible&&s._boundingBox&&(o+=(c.height-c.margin.b-c.margin.t)*s.rangeslider.thickness+s._boundingBox.height),u.side||(u.side="bottom")):(i="free"===s.anchor?{_offset:h.l+(s.position||0)*h.w,_length:0}:T.getFromId(t,s.anchor),o=s._offset+s._length/2,a=i._offset+("right"===s.side?i._length+10+p*(d+(s.showticklabels?1:.5)):-10-p*(d+(s.showticklabels?.5:0))),n={rotate:"-90",offset:0},u.side||(u.side="left")),A.draw(t,e+"title",{propContainer:s,propName:s._name+".title",dfltName:f.toUpperCase()+" axis",avoid:u,transform:n,attributes:{x:a,y:o,"text-anchor":"middle"}})}}function s(t,e){return t.visible!==!0||t.xaxis+t.yaxis!==e?!1:x.Plots.traceIs(t,"bar")&&t.orientation==={x:"h",y:"v"}[v]?!0:t.fill&&t.fill.charAt(t.fill.length-1)===v}function l(e,r,i){var a=e.gridlayer,o=e.zerolinelayer,l=e["hidegrid"+v]?[]:V,c=u._gridpath||"M0,0"+("x"===v?"v":"h")+r._length,f=a.selectAll("path."+R).data(u.showgrid===!1?[]:l,S);if(f.enter().append("path").classed(R,1).classed("crisp",1).attr("d",c).each(function(t){u.zeroline&&("linear"===u.type||"-"===u.type)&&Math.abs(t.x)g;g++){var y=u.mirrors[o._id+h[g]];"ticks"!==y&&"labels"!==y||(f[g]=!0)}return void 0!==n[2]&&(f[2]=!0),f.forEach(function(t,e){var r=n[e],i=U[e];t&&b(r)&&(d+=p(r+P*i,i*u.ticklen))}),i(r,d),l(e,o,t),a(r,n[3])}}).filter(function(t){return t&&t.then});return H.length?Promise.all(H):0},E.swap=function(t,e){for(var r=d(t,e),n=0;n2*n}function c(t){for(var e,r=Math.max(1,(t.length-1)/1e3),n=0,i=0,a=0;a2*n}var f=t("fast-isnumeric"),h=t("tinycolor2").mix,d=t("../../lib"),p=t("../plots"),g=t("../../components/color/attributes").lightFraction,v=t("./layout_attributes"),m=t("./tick_value_defaults"),y=t("./tick_mark_defaults"),b=t("./tick_label_defaults"),x=t("./category_order_defaults"),_=t("./set_convert"),w=t("./ordered_categories"),A=t("./clean_datum"),k=t("./axis_ids");e.exports=function(t,e,r,i){function a(r,n){return d.coerce2(t,e,v,r,n)}var o=i.letter,s=i.font||{},l="Click to enter "+(i.title||o.toUpperCase()+" axis")+" title";i.name&&(e._name=i.name,e._id=k.name2id(i.name));var u=r("type");"-"===u&&(n(e,i.data),"-"===e.type?e.type="linear":u=t.type=e.type),_(e);var c=r("color"),p=c===t.color?c:s.color;r("title",l),d.coerceFont(r,"titlefont",{family:s.family,size:Math.round(1.2*s.size),color:p});var A=2===(t.range||[]).length&&f(t.range[0])&&f(t.range[1]),M=r("autorange",!A);M&&r("rangemode");var E=r("range",[-1,"x"===o?6:4]);E[0]===E[1]&&(e.range=[E[0]-1,E[0]+1]),d.noneOrAll(t.range,e.range,[0,1]),r("fixedrange"),m(t,e,r,u),b(t,e,r,u,i),y(t,e,r,i),x(t,e,r);var T=a("linecolor",c),L=a("linewidth"),S=r("showline",!!T||!!L);S||(delete e.linecolor,delete e.linewidth),(S||e.ticks)&&r("mirror");var C=a("gridcolor",h(c,i.bgColor,g).toRgbString()),R=a("gridwidth"),I=r("showgrid",i.showGrid||!!C||!!R);I||(delete e.gridcolor,delete e.gridwidth);var P=a("zerolinecolor",c),O=a("zerolinewidth"),N=r("zeroline",i.showGrid||!!P||!!O);return N||(delete e.zerolinecolor,delete e.zerolinewidth),e._initialCategories="category"===u?w(o,e.categoryorder,e.categoryarray,i.data):[],e}},{"../../components/color/attributes":175,"../../lib":256,"../plots":303,"./axis_ids":281,"./category_order_defaults":282,"./clean_datum":283,"./layout_attributes":288,"./ordered_categories":290,"./set_convert":293,"./tick_label_defaults":294,"./tick_mark_defaults":295,"./tick_value_defaults":296,"fast-isnumeric":65,tinycolor2:148}],281:[function(t,e,r){"use strict";function n(t,e,r){function n(t,r){for(var n=Object.keys(t),i=/^[xyz]axis[0-9]*/,a=[],o=0;o0;a&&(n="array");var o=r("categoryorder",n);"array"===o&&r("categoryarray"),a||"array"!==o||(e.categoryorder="trace")}}},{}],283:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib");e.exports=function(t){try{if("object"==typeof t&&null!==t&&t.getTime)return i.ms2DateTime(t);if("string"!=typeof t&&!n(t))return"";t=t.toString().replace(/['"%,$# ]/g,"")}catch(e){i.error(e,t)}return t}},{"../../lib":256,"fast-isnumeric":65}],284:[function(t,e,r){"use strict";e.exports={idRegex:{x:/^x([2-9]|[1-9][0-9]+)?$/,y:/^y([2-9]|[1-9][0-9]+)?$/},attrRegex:{x:/^xaxis([2-9]|[1-9][0-9]+)?$/,y:/^yaxis([2-9]|[1-9][0-9]+)?$/},BADNUM:void 0,xAxisMatch:/^xaxis[0-9]*$/,yAxisMatch:/^yaxis[0-9]*$/,AX_ID_PATTERN:/^[xyz][0-9]*$/,AX_NAME_PATTERN:/^[xyz]axis[0-9]*$/,DBLCLICKDELAY:300,MINDRAG:8,MINSELECT:12,MINZOOM:20,DRAGGERSIZE:20,MAXDIST:20,YANGLE:60,HOVERARROWSIZE:6,HOVERTEXTPAD:3,HOVERFONTSIZE:13,HOVERFONT:"Arial, sans-serif",HOVERMINTIME:50,BENDPX:1.5,REDRAWDELAY:50}},{}],285:[function(t,e,r){"use strict";function n(t,e){var r,n=t.range[e],i=Math.abs(n-t.range[1-e]);return"date"===t.type?c.ms2DateTime(n,i):"log"===t.type?(r=Math.ceil(Math.max(0,-Math.log(i)/Math.LN10))+3,s.format("."+r+"g")(Math.pow(10,n))):(r=Math.floor(Math.log(Math.abs(n))/Math.LN10)-Math.floor(Math.log(i)/Math.LN10)+4,s.format("."+String(r)+"g")(n))}function i(t,e){return t?"nsew"===t?"pan"===e?"move":"crosshair":t.toLowerCase()+"-resize":"pointer"}function a(t){s.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}function o(t){var e=["lasso","select"];return-1!==e.indexOf(t)}var s=t("d3"),l=t("tinycolor2"),u=t("../../plotly"),c=t("../../lib"),f=t("../../lib/svg_text_utils"),h=t("../../components/color"),d=t("../../components/drawing"),p=t("../../lib/setcursor"),g=t("../../components/dragelement"),v=t("./axes"),m=t("./select"),y=t("./constants"),b=!0;e.exports=function(t,e,r,s,x,_,w,A){function k(t,e){for(var r=0;r.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("transform","translate("+pt+", "+gt+")").attr("d",lt+"Z"),ht=dt.append("path").attr("class","zoombox-corners").style({fill:h.background,stroke:h.defaultLine,"stroke-width":1,opacity:0}).attr("transform","translate("+pt+", "+gt+")").attr("d","M0,0Z"),T();for(var a=0;ai?(ct="",ot.r=ot.l,ot.t=ot.b,ht.attr("d","M0,0Z")):(ot.t=0,ot.b=q,ct="x",ht.attr("d","M"+(ot.l-.5)+","+(at-G-.5)+"h-3v"+(2*G+1)+"h3ZM"+(ot.r+.5)+","+(at-G-.5)+"h3v"+(2*G+1)+"h-3Z")):!$||i.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),ht.transition().style("opacity",1).duration(200),ut=!0)}function S(t,e,r){var n,i,a;for(n=0;nzoom back out","long"),b=!1)))}function R(e,r){var i=1===(w+A).length;if(e)z();else if(2!==r||i){if(1===r&&i){var a=w?U[0]:j[0],o="s"===w||"w"===A?0:1,s=a._name+".range["+o+"]",l=n(a,o),c="left",h="middle";if(a.fixedrange)return;w?(h="n"===w?"top":"bottom","right"===a.side&&(c="right")):"e"===A&&(c="right"),et.call(f.makeEditable,null,{immediate:!0,background:F.paper_bgcolor,text:String(l),fill:a.tickfont?a.tickfont.color:"#444",horizontalAlign:c,verticalAlign:h}).on("edit",function(e){var r="category"===a.type?a.c2l(e):a.d2l(e);void 0!==r&&u.relayout(t,s,r)})}}else N()}function I(e){function r(t,e,r){if(!t.fixedrange){M(t.range);var n=t.range,i=n[0]+(n[1]-n[0])*e;t.range=[i+(n[0]-i)*r,i+(n[1]-i)*r]}}if(t._context.scrollZoom||F._enablescrollzoom){var n=t.querySelector(".plotly");if(!(n.scrollHeight-n.clientHeight>10||n.scrollWidth-n.clientWidth>10)){clearTimeout(mt);var i=-e.deltaY;if(isFinite(i)||(i=e.wheelDelta/10),!isFinite(i))return void c.log("Did not find wheel motion attributes: ",e);var a,o=Math.exp(-Math.min(Math.max(i,-20),20)/100),s=bt.draglayer.select(".nsewdrag").node().getBoundingClientRect(),l=(e.clientX-s.left)/s.width,u=vt[0]+vt[2]*l,f=(s.bottom-e.clientY)/s.height,h=vt[1]+vt[3]*(1-f);if(A){for(a=0;a=0?Math.min(t,.9):1/(1/Math.max(t,-.3)+3.222))}function i(t,e,r){for(var i=1-e,a=0,o=0;o0;n--)r.push(e);return r}function i(t,e){for(var r=[],n=0;nE;E++){var T=a[E],L=d[T];if(L)k[E]=w.getFromId(t,L.xaxis._id),M[E]=w.getFromId(t,L.yaxis._id);else{var S=o[T]._subplot;k[E]=S.xaxis,M[E]=S.yaxis}}var C=e.hovermode||o.hovermode;if(-1===["x","y","closest"].indexOf(C)||!t.calcdata||t.querySelector(".zoombox")||t._dragging)return _.unhoverRaw(t,e);var R,I,P,O,N,z,D,F,B,j,U,V,q=[],H=[];if(Array.isArray(e))for(C="array",P=0;PG||G>Y.width||0>X||X>Y.height)return _.unhoverRaw(t,e)}else G="xpx"in e?e.xpx:k[0]._length/2,X="ypx"in e?e.ypx:M[0]._length/2;if(R="xval"in e?n(a,e.xval):i(k,G),I="yval"in e?n(a,e.yval):i(M,X),!g(R[0])||!g(I[0]))return v.warn("Plotly.Fx.hover failed",e,t),_.unhoverRaw(t,e)}var W=1/0;for(O=0;O1||-1!==z.hoverinfo.indexOf("name")?z.name:void 0,index:!1,distance:Math.min(W,A.MAXDIST),color:b.defaultLine,x0:void 0,x1:void 0,y0:void 0,y1:void 0,xLabelVal:void 0,yLabelVal:void 0,zLabelVal:void 0,text:void 0},V=q.length,"array"===F){var Z=e[O];"pointNumber"in Z?(U.index=Z.pointNumber,F="closest"):(F="","xval"in Z&&(B=Z.xval,F="x"),"yval"in Z&&(j=Z.yval,F=F?"closest":"y"))}else B=R[D],j=I[D];if(z._module&&z._module.hoverPoints){var Q=z._module.hoverPoints(U,B,j,F);if(Q)for(var $,K=0;KV&&(q.splice(0,V),W=q[0].distance)}if(0===q.length)return _.unhoverRaw(t,e);var J="y"===C&&H.length>1;q.sort(function(t,e){return t.distance-e.distance});var tt=b.combine(o.plot_bgcolor||b.background,o.paper_bgcolor),et={hovermode:C,rotateLabels:J,bgColor:tt,container:o._hoverlayer,outerContainer:o._paperdiv},rt=u(q,et);c(q,J?"xa":"ya"),f(rt,J);var nt=t._hoverdata,it=[];for(P=0;P128?"#000":b.background;if(t.name&&void 0===t.zLabelVal){var c=document.createElement("p");c.innerHTML=t.name,r=c.textContent||"",r.length>15&&(r=r.substr(0,12)+"...")}void 0!==t.extraText&&(n+=t.extraText),void 0!==t.zLabel?(void 0!==t.xLabel&&(n+="x: "+t.xLabel+"
"),void 0!==t.yLabel&&(n+="y: "+t.yLabel+"
"),n+=(n?"z: ":"")+t.zLabel):M&&t[i+"Label"]===g?n=t[("x"===i?"y":"x")+"Label"]||"":void 0===t.xLabel?void 0!==t.yLabel&&(n=t.yLabel):n=void 0===t.yLabel?t.xLabel:"("+t.xLabel+", "+t.yLabel+")",t.text&&!Array.isArray(t.text)&&(n+=(n?"
":"")+t.text),""===n&&(""===r&&e.remove(),n=r);var f=e.select("text.nums").style("fill",u).call(x.setPosition,0,0).text(n).attr("data-notex",1).call(y.convertToTspans);f.selectAll("tspan.line").call(x.setPosition,0,0);var h=e.select("text.name"),v=0;r&&r!==n?(h.style("fill",l).text(r).call(x.setPosition,0,0).attr("data-notex",1).call(y.convertToTspans),h.selectAll("tspan.line").call(x.setPosition,0,0),v=h.node().getBoundingClientRect().width+2*I):(h.remove(),e.select("rect").remove()),e.select("path").style({fill:l,stroke:u});var m,A,T=f.node().getBoundingClientRect(),L=t.xa._offset+(t.x0+t.x1)/2,S=t.ya._offset+(t.y0+t.y1)/2,C=Math.abs(t.x1-t.x0),P=Math.abs(t.y1-t.y0),O=T.width+R+I+v;t.ty0=_-T.top,t.bx=T.width+2*I,t.by=T.height+2*I,t.anchor="start",t.txwidth=T.width,t.tx2width=v,t.offset=0,a?(t.pos=L,m=k>=S+P/2+O,A=S-P/2-O>=0,"top"!==t.idealAlign&&m||!A?m?(S+=P/2,t.anchor="start"):t.anchor="middle":(S-=P/2,t.anchor="end")):(t.pos=S,m=w>=L+C/2+O,A=L-C/2-O>=0,"left"!==t.idealAlign&&m||!A?m?(L+=C/2,t.anchor="start"):t.anchor="middle":(L-=C/2, +-t.anchor="end")),f.attr("text-anchor",t.anchor),v&&h.attr("text-anchor",t.anchor),e.attr("transform","translate("+L+","+S+")"+(a?"rotate("+E+")":""))}),S}function c(t,e){function r(t){var e=t[0],r=t[t.length-1];if(i=e.pmin-e.pos-e.dp+e.size,a=r.pos+r.dp+r.size-e.pmax,i>.01){for(s=t.length-1;s>=0;s--)t[s].dp+=i;n=!1}if(!(.01>a)){if(-.01>i){for(s=t.length-1;s>=0;s--)t[s].dp-=a;n=!1}if(n){var u=0;for(o=0;oe.pmax&&u++;for(o=t.length-1;o>=0&&!(0>=u);o--)l=t[o],l.pos>e.pmax-1&&(l.del=!0,u--);for(o=0;o=u);o++)if(l=t[o],l.pos=0;s--)t[s].dp-=a;for(o=t.length-1;o>=0&&!(0>=u);o--)l=t[o],l.pos+l.dp+l.size>e.pmax&&(l.del=!0,u--)}}}for(var n,i,a,o,s,l,u,c=0,f=t.map(function(t,r){var n=t[e];return[{i:r,dp:0,pos:t.pos,posref:t.posref,size:t.by*("x"===n._id.charAt(0)?L:1)/2,pmin:n._offset,pmax:n._offset+n._length}]}).sort(function(t,e){return t[0].posref-e[0].posref});!n&&c<=t.length;){for(c++,n=!0,o=0;o.01&&p.pmin===g.pmin&&p.pmax===g.pmax){for(s=d.length-1;s>=0;s--)d[s].dp+=i;for(h.push.apply(h,d),f.splice(o+1,1),u=0,s=h.length-1;s>=0;s--)u+=h[s].dp;for(a=u/h.length,s=h.length-1;s>=0;s--)h[s].dp-=a;n=!1}else o++}f.forEach(r)}for(o=f.length-1;o>=0;o--){var v=f[o];for(s=v.length-1;s>=0;s--){var m=v[s],y=t[m.i];y.offset=m.dp,y.del=m.del}}}function f(t,e){t.each(function(t){var r=d.select(this);if(t.del)return void r.remove();var n="end"===t.anchor?-1:1,i=r.select("text.nums"),a={start:1,end:-1,middle:0}[t.anchor],o=a*(R+I),s=o+a*(t.txwidth+I),l=0,u=t.offset;"middle"===t.anchor&&(o-=t.tx2width/2,s-=t.tx2width/2),e&&(u*=-C,l=t.offset*S),r.select("path").attr("d","middle"===t.anchor?"M-"+t.bx/2+",-"+t.by/2+"h"+t.bx+"v"+t.by+"h-"+t.bx+"Z":"M0,0L"+(n*R+l)+","+(R+u)+"v"+(t.by/2-R)+"h"+n*t.bx+"v-"+t.by+"H"+(n*R+l)+"V"+(u-R)+"Z"),i.call(x.setPosition,o+l,u+t.ty0-t.by/2+I).selectAll("tspan.line").attr({x:i.attr("x"),y:i.attr("y")}),t.tx2width&&(r.select("text.name, text.name tspan.line").call(x.setPosition,s+a*I+l,u+t.ty0-t.by/2+I),r.select("rect").call(x.setRect,s+(a-1)*t.tx2width/2+l,u-t.by/2-1,t.tx2width,t.by+2))})}function h(t,e,r){if(!e.target)return!1;if(!r||r.length!==t._hoverdata.length)return!0;for(var n=r.length-1;n>=0;n--){var i=r[n],a=t._hoverdata[n];if(i.curveNumber!==a.curveNumber||String(i.pointNumber)!==String(a.pointNumber))return!0}return!1}var d=t("d3"),p=t("tinycolor2"),g=t("fast-isnumeric"),v=t("../../lib"),m=t("../../lib/events"),y=t("../../lib/svg_text_utils"),b=t("../../components/color"),x=t("../../components/drawing"),_=t("../../components/dragelement"),w=t("./axes"),A=t("./constants"),k=t("./dragbox"),M=e.exports={};M.unhover=_.unhover,M.layoutAttributes={dragmode:{valType:"enumerated",values:["zoom","pan","select","lasso","orbit","turntable"],dflt:"zoom"},hovermode:{valType:"enumerated",values:["x","y","closest",!1]}},M.supplyLayoutDefaults=function(t,e,r){function n(r,n){return v.coerce(t,e,M.layoutAttributes,r,n)}n("dragmode");var i;if(e._has("cartesian")){var a=e._isHoriz=M.isHoriz(r);i=a?"y":"x"}else i="closest";n("hovermode",i)},M.isHoriz=function(t){for(var e=!0,r=0;rt._lastHoverTime+A.HOVERMINTIME?(o(t,e,r),void(t._lastHoverTime=Date.now())):void(t._hoverTimer=setTimeout(function(){o(t,e,r),t._lastHoverTime=Date.now(),t._hoverTimer=void 0},A.HOVERMINTIME))},M.getDistanceFunction=function(t,e,r,n){return"closest"===t?n||a(e,r):"x"===t?e:r},M.getClosest=function(t,e,r){if(r.index!==!1)r.index>=0&&r.indext*e||0===t?A.MAXDIST*(.6-.3/Math.max(3,Math.abs(t-e))):1/0}},{"../../components/color":176,"../../components/dragelement":197,"../../components/drawing":199,"../../lib":256,"../../lib/events":252,"../../lib/svg_text_utils":269,"./axes":279,"./constants":284,"./dragbox":285,d3:62,"fast-isnumeric":65,tinycolor2:148}],287:[function(t,e,r){"use strict";var n=t("../plots"),i=t("./constants");r.name="cartesian",r.attr=["xaxis","yaxis"],r.idRoot=["x","y"],r.idRegex=i.idRegex,r.attrRegex=i.attrRegex,r.attributes=t("./attributes"),r.plot=function(t){function e(t,e){for(var r=[],n=0;nf[1]-.01&&(e.domain=[0,1]),i.noneOrAll(t.domain,e.domain,[0,1])}return e}},{"../../lib":256,"fast-isnumeric":65}],292:[function(t,e,r){"use strict";function n(t){return t._id}var i=t("../../lib/polygon"),a=t("../../components/color"),o=t("./axes"),s=t("./constants"),l=i.filter,u=i.tester,c=s.MINSELECT;e.exports=function(t,e,r,i,f){function h(t){var e="y"===t._id.charAt(0)?1:0;return function(r){return t.p2d(r[e])}}function d(t,e){return t-e}var p,g=i.gd._fullLayout._zoomlayer,v=i.element.getBoundingClientRect(),m=i.plotinfo.x()._offset,y=i.plotinfo.y()._offset,b=e-v.left,x=r-v.top,_=b,w=x,A="M"+b+","+x,k=i.xaxes[0]._length,M=i.yaxes[0]._length,E=i.xaxes.map(n),T=i.yaxes.map(n),L=i.xaxes.concat(i.yaxes);"lasso"===f&&(p=l([[b,x]],s.BENDPX));var S=g.selectAll("path.select-outline").data([1,2]);S.enter().append("path").attr("class",function(t){return"select-outline select-outline-"+t}).attr("transform","translate("+m+", "+y+")").attr("d",A+"Z");var C,R,I,P,O,N=g.append("path").attr("class","zoombox-corners").style({fill:a.background,stroke:a.defaultLine,"stroke-width":1}).attr("transform","translate("+m+", "+y+")").attr("d","M0,0Z"),z=[],D=i.gd,F=[];for(C=0;C0)return Math.log(e)/Math.LN10;if(0>=e&&r&&t.range&&2===t.range.length){var n=t.range[0],i=t.range[1];return.5*(n+i-3*c*Math.abs(n-i))}return o.BADNUM}function r(t){return Math.pow(10,t)}function u(t){return i(t)?Number(t):o.BADNUM}var c=10;if(t.c2l="log"===t.type?e:u,t.l2c="log"===t.type?r:u,t.l2d=function(e){return t.c2d(t.l2c(e))},t.p2d=function(e){return t.l2d(t.p2l(e))},t.setScale=function(){var e,r=t._gd._fullLayout._size;if(t._categories||(t._categories=[]),t.overlaying){var n=l.getFromId(t._gd,t.overlaying);t.domain=n.domain}for(t.range&&2===t.range.length&&t.range[0]!==t.range[1]||(t.range=[-1,1]),e=0;2>e;e++)i(t.range[e])||(t.range[e]=i(t.range[1-e])?t.range[1-e]*(e?10:.1):e?1:-1),t.range[e]<-(Number.MAX_VALUE/2)?t.range[e]=-(Number.MAX_VALUE/2):t.range[e]>Number.MAX_VALUE/2&&(t.range[e]=Number.MAX_VALUE/2);if("y"===t._id.charAt(0)?(t._offset=r.t+(1-t.domain[1])*r.h,t._length=r.h*(t.domain[1]-t.domain[0]),t._m=t._length/(t.range[0]-t.range[1]),t._b=-t._m*t.range[1]):(t._offset=r.l+t.domain[0]*r.w,t._length=r.w*(t.domain[1]-t.domain[0]),t._m=t._length/(t.range[1]-t.range[0]),t._b=-t._m*t.range[0]),!isFinite(t._m)||!isFinite(t._b))throw a.notifier("Something went wrong with axis scaling","long"),t._gd._replotting=!1,new Error("axis scaling")},t.l2p=function(e){return i(e)?n.round(t._b+t._m*e,2):o.BADNUM},t.p2l=function(e){return(e-t._b)/t._m},t.c2p=function(e,r){return t.l2p(t.c2l(e,r))},t.p2c=function(e){return t.l2c(t.p2l(e))},-1!==["linear","log","-"].indexOf(t.type))t.c2d=u,t.d2c=function(t){return t=s(t),i(t)?Number(t):o.BADNUM},t.d2l=function(e,r){return"log"===t.type?t.c2l(t.d2c(e),r):t.d2c(e)};else if("date"===t.type){if(t.c2d=function(t){return i(t)?a.ms2DateTime(t):o.BADNUM},t.d2c=function(t){return i(t)?Number(t):a.dateTime2ms(t)},t.d2l=t.d2c,t.range&&t.range.length>1)try{var f=t.range.map(a.dateTime2ms);!i(t.range[0])&&i(f[0])&&(t.range[0]=f[0]),!i(t.range[1])&&i(f[1])&&(t.range[1]=f[1])}catch(h){a.error(h,t.range)}}else"category"===t.type&&(t.c2d=function(e){return t._categories[Math.round(e)]},t.d2c=function(e){null!==e&&void 0!==e&&-1===t._categories.indexOf(e)&&t._categories.push(e);var r=t._categories.indexOf(e);return-1===r?o.BADNUM:r},t.d2l=t.d2c);t.makeCalcdata=function(e,r){var n,i,a;if(r in e)for(n=e[r],i=new Array(n.length),a=0;ad;++d){for(e=u[d],r=t[this.scene[e]._name],n=/Click to enter .+ title/.test(r.title)?"":r.title,p=0;2>=p;p+=2)this.labelEnable[d+p]=!1,this.labels[d+p]=o(n),this.labelColor[d+p]=s(r.titlefont.color),this.labelFont[d+p]=r.titlefont.family,this.labelSize[d+p]=r.titlefont.size,this.labelPad[d+p]=this.getLabelPad(e,r),this.tickEnable[d+p]=!1,this.tickColor[d+p]=s((r.tickfont||{}).color),this.tickAngle[d+p]="auto"===r.tickangle?0:Math.PI*-r.tickangle/180,this.tickPad[d+p]=this.getTickPad(r),this.tickMarkLength[d+p]=0,this.tickMarkWidth[d+p]=r.tickwidth||0,this.tickMarkColor[d+p]=s(r.tickcolor),this.borderLineEnable[d+p]=!1,this.borderLineColor[d+p]=s(r.linecolor),this.borderLineWidth[d+p]=r.linewidth||0;c=this.hasSharedAxis(r),a=this.hasAxisInDfltPos(e,r)&&!c,l=this.hasAxisInAltrPos(e,r)&&!c,i=r.mirror||!1,f=c?-1!==String(i).indexOf("all"):!!i,h=c?"allticks"===i:-1!==String(i).indexOf("ticks"),a?this.labelEnable[d]=!0:l&&(this.labelEnable[d+2]=!0),a?this.tickEnable[d]=r.showticklabels:l&&(this.tickEnable[d+2]=r.showticklabels),(a||f)&&(this.borderLineEnable[d]=r.showline),(l||f)&&(this.borderLineEnable[d+2]=r.showline),(a||h)&&(this.tickMarkLength[d]=this.getTickMarkLength(r)),(l||h)&&(this.tickMarkLength[d+2]=this.getTickMarkLength(r)),this.gridLineEnable[d]=r.showgrid,this.gridLineColor[d]=s(r.gridcolor),this.gridLineWidth[d]=r.gridwidth,this.zeroLineEnable[d]=r.zeroline,this.zeroLineColor[d]=s(r.zerolinecolor),this.zeroLineWidth[d]=r.zerolinewidth}},l.hasSharedAxis=function(t){var e=this.scene,r=a.Plots.getSubplotIds(e.fullLayout,"gl2d"),n=a.Axes.findSubplotsWithAxis(r,t);return 0!==n.indexOf(e.id)},l.hasAxisInDfltPos=function(t,e){var r=e.side;return"xaxis"===t?"bottom"===r:"yaxis"===t?"left"===r:void 0},l.hasAxisInAltrPos=function(t,e){var r=e.side;return"xaxis"===t?"top"===r:"yaxis"===t?"right"===r:void 0},l.getLabelPad=function(t,e){var r=1.5,n=e.titlefont.size,i=e.showticklabels;return"xaxis"===t?"top"===e.side?-10+n*(r+(i?1:0)):-10+n*(r+(i?.5:0)):"yaxis"===t?"right"===e.side?10+n*(r+(i?1:.5)):10+n*(r+(i?.5:0)):void 0},l.getTickPad=function(t){return"outside"===t.ticks?10+t.ticklen:15},l.getTickMarkLength=function(t){if(!t.ticks)return 0;var e=t.ticklen;return"inside"===t.ticks?-e:e},e.exports=i},{"../../lib/html2unicode":255,"../../lib/str2rgbarray":268,"../../plotly":276}],300:[function(t,e,r){"use strict";var n=t("./scene2d"),i=t("../plots"),a=t("../../constants/xmlns_namespaces");r.name="gl2d",r.attr=["xaxis","yaxis"],r.idRoot=["x","y"],r.idRegex={x:/^x([2-9]|[1-9][0-9]+)?$/,y:/^y([2-9]|[1-9][0-9]+)?$/},r.attrRegex={x:/^xaxis([2-9]|[1-9][0-9]+)?$/,y:/^yaxis([2-9]|[1-9][0-9]+)?$/},r.attributes=t("../cartesian/attributes"),r.plot=function(t){for(var e=t._fullLayout,r=t._fullData,a=i.getSubplotIds(e,"gl2d"),o=0;or;++r){var n=t[r],i=e[r];if(n.length!==i.length)return!0;for(var a=0;ao;++o,--s)for(var l=0;r>l;++l)for(var u=0;4>u;++u){var c=i[4*(r*o+l)+u];i[4*(r*o+l)+u]=i[4*(r*s+l)+u],i[4*(r*s+l)+u]=c}var f=document.createElement("canvas");f.width=r,f.height=n;var h=f.getContext("2d"),d=h.createImageData(r,n);d.data.set(i),h.putImageData(d,0,0);var p;switch(t){case"jpeg":p=f.toDataURL("image/jpeg");break;case"webp":p=f.toDataURL("image/webp");break;default:p=f.toDataURL("image/png")}return this.staticPlot&&this.container.removeChild(a),p},m.computeTickMarks=function(){this.xaxis._length=this.glplot.viewBox[2]-this.glplot.viewBox[0],this.yaxis._length=this.glplot.viewBox[3]-this.glplot.viewBox[1];for(var t=[s.calcTicks(this.xaxis),s.calcTicks(this.yaxis)],e=0;2>e;++e)for(var r=0;rA;++A)w[A]=Math.min(w[A],a.bounds[A]),w[A+2]=Math.max(w[A+2],a.bounds[A+2])}var k;for(n=0;2>n;++n)w[n]>w[n+2]&&(w[n]=-1,w[n+2]=1),k=this[v[n]],k._length=y.viewBox[n+2]-y.viewBox[n],s.doAutoRange(k);y.ticks=this.computeTickMarks();var M=this.xaxis.range,E=this.yaxis.range;y.dataBox=[M[0],E[0],M[1],E[1]],y.merge(r),o.update(y),this.glplot.draw()},m.draw=function(){if(!this.stopped){requestAnimationFrame(this.redraw);var t=this.glplot,e=this.camera,r=e.mouseListener,n=this.fullLayout;this.cameraChanged();var i=r.x*t.pixelRatio,a=this.canvas.height-t.pixelRatio*r.y;if(e.boxEnabled&&"zoom"===n.dragmode)this.selectBox.enabled=!0,this.selectBox.selectBox=[Math.min(e.boxStart[0],e.boxEnd[0]),Math.min(e.boxStart[1],e.boxEnd[1]),Math.max(e.boxStart[0],e.boxEnd[0]),Math.max(e.boxStart[1],e.boxEnd[1])],t.setDirty();else{this.selectBox.enabled=!1;var o=n._size,s=this.xaxis.domain,u=this.yaxis.domain,c=t.pick(i/t.pixelRatio+o.l+s[0]*o.w,a/t.pixelRatio-(o.t+(1-u[1])*o.h));if(c&&n.hovermode){var f=c.object._trace.handlePick(c);if(f&&(!this.lastPickResult||this.lastPickResult.traceUid!==f.trace.uid||this.lastPickResult.dataCoord[0]!==f.dataCoord[0]||this.lastPickResult.dataCoord[1]!==f.dataCoord[1])){var h=f;this.lastPickResult={traceUid:f.trace?f.trace.uid:null,dataCoord:f.dataCoord.slice()},this.spikes.update({center:c.dataCoord}),h.screenCoord=[((t.viewBox[2]-t.viewBox[0])*(c.dataCoord[0]-t.dataBox[0])/(t.dataBox[2]-t.dataBox[0])+t.viewBox[0])/t.pixelRatio,(this.canvas.height-(t.viewBox[3]-t.viewBox[1])*(c.dataCoord[1]-t.dataBox[1])/(t.dataBox[3]-t.dataBox[1])-t.viewBox[1])/t.pixelRatio];var d=h.hoverinfo;if("all"!==d){var p=d.split("+");-1===p.indexOf("x")&&(h.traceCoord[0]=void 0),-1===p.indexOf("y")&&(h.traceCoord[1]=void 0),-1===p.indexOf("z")&&(h.traceCoord[2]=void 0),-1===p.indexOf("text")&&(h.textLabel=void 0),-1===p.indexOf("name")&&(h.name=void 0)}l.loneHover({x:h.screenCoord[0],y:h.screenCoord[1],xLabel:this.hoverFormatter("xaxis",h.traceCoord[0]),yLabel:this.hoverFormatter("yaxis",h.traceCoord[1]),zLabel:h.traceCoord[2],text:h.textLabel,name:h.name,color:h.color},{container:this.svgContainer})}}else!c&&this.lastPickResult&&(this.spikes.update({}),this.lastPickResult=null,l.loneUnhover(this.svgContainer))}t.draw()}},m.hoverFormatter=function(t,e){if(void 0!==e){var r=this[t];return s.tickText(r,r.c2l(e),"hover").text}}},{"../../lib/html2unicode":255,"../../lib/show_no_webgl_msg":266,"../../plots/cartesian/axes":279,"../../plots/cartesian/graph_interact":286,"./camera":298,"./convert":299,"gl-plot2d":85,"gl-select-box":94,"gl-spikes2d":114}],302:[function(t,e,r){"use strict";var n=t("../plotly"),i=t("./font_attributes"),a=t("../components/color/attributes"),o=n.Lib.extendFlat;e.exports={font:{family:o({},i.family,{dflt:'"Open Sans", verdana, arial, sans-serif'}),size:o({},i.size,{dflt:12}),color:o({},i.color,{dflt:a.defaultLine})},title:{valType:"string",dflt:"Click to enter Plot title"},titlefont:o({},i,{}),autosize:{valType:"enumerated",values:[!0,!1,"initial"]},width:{valType:"number",min:10,dflt:700},height:{valType:"number",min:10,dflt:450},margin:{l:{valType:"number",min:0,dflt:80},r:{valType:"number",min:0,dflt:80},t:{valType:"number",min:0,dflt:100},b:{valType:"number",min:0,dflt:80},pad:{valType:"number",min:0,dflt:0},autoexpand:{valType:"boolean",dflt:!0}},paper_bgcolor:{valType:"color",dflt:a.background},plot_bgcolor:{valType:"color",dflt:a.background},separators:{valType:"string",dflt:".,"},hidesources:{valType:"boolean",dflt:!1},smith:{valType:"enumerated",values:[!1],dflt:!1},showlegend:{valType:"boolean"},_composedModules:{"*":"Fx"},_nestedModules:{xaxis:"Axes",yaxis:"Axes",scene:"gl3d",geo:"geo",legend:"Legend",annotations:"Annotations",shapes:"Shapes",images:"Images",updatemenus:"UpdateMenus",ternary:"ternary",mapbox:"mapbox"}}},{"../components/color/attributes":175,"../plotly":276,"./font_attributes":297}],303:[function(t,e,r){"use strict";function n(t){return"object"==typeof t&&(t=t.type),t}function i(t,e){e.text("");var r=e.append("a").attr({"xlink:xlink:href":"#","class":"link--impt link--embedview","font-weight":"bold"}).text(t._context.linkText+" "+String.fromCharCode(187));if(t._context.sendData)r.on("click",function(){d.sendDataToCloud(t)});else{var n=window.location.pathname.split("/"),i=window.location.search;r.attr({"xlink:xlink:show":"new","xlink:xlink:href":"/"+n[2].split(".")[0]+"/"+n[1]+i})}}function a(t,e){for(var r=f.isPlainObject,n=Array.isArray,i=Object.keys(e),o=0;o=e.width-20?(a["text-anchor"]="start",a.x=5):(a["text-anchor"]="end",a.x=e._paper.attr("width")-7),r.attr(a);var o=r.select(".js-link-to-tool"),s=r.select(".js-link-spacer"),u=r.select(".js-sourcelinks");t._context.showSources&&t._context.showSources(t),t._context.showLink&&i(t,o),s.text(o.text()&&u.text()?" - ":"")},d.sendDataToCloud=function(t){t.emit("plotly_beforeexport");var e=window.PLOTLYENV&&window.PLOTLYENV.BASE_URL||"https://plot.ly",r=l.select(t).append("div").attr("id","hiddenform").style("display","none"),n=r.append("form").attr({action:e+"/external",method:"post",target:"_blank"}),i=n.append("input").attr({type:"text",name:"data"});return i.node().value=d.graphJson(t,!1,"keepdata"),n.node().submit(),r.remove(),t.emit("plotly_afterexport"),!1},d.supplyDefaults=function(t){var e,r=t._fullLayout||{},n=t._fullLayout={},i=t.layout||{},o=t._fullData||[],s=t._fullData=[],l=t.data||[];d.supplyLayoutGlobalDefaults(i,n),n._dataLength=l.length,d.supplyDataDefaults(l,s,n),n._has=d._hasPlotType.bind(n);var u=n._modules;for(e=0;ea&&(e=(r-1)/(i.l+i.r),i.l=Math.floor(e*i.l),i.r=Math.floor(e*i.r)),0>o&&(e=(n-1)/(i.t+i.b),i.t=Math.floor(e*i.t),i.b=Math.floor(e*i.b))}},d.autoMargin=function(t,e,r){var n=t._fullLayout;if(n._pushmargin||(n._pushmargin={}),n.margin.autoexpand!==!1){if(r){var i=void 0===r.pad?12:r.pad;r.l+r.r>.5*n.width&&(r.l=r.r=0),r.b+r.t>.5*n.height&&(r.b=r.t=0),n._pushmargin[e]={l:{val:r.x,size:r.l+i},r:{val:r.x,size:r.r+i},b:{val:r.y,size:r.b+i},t:{val:r.y,size:r.t+i}}}else delete n._pushmargin[e];t._replotting||d.doAutoMargin(t)}},d.doAutoMargin=function(t){var e=t._fullLayout;e._size||(e._size={}),e._pushmargin||(e._pushmargin={});var r=e._size,n=JSON.stringify(r),i=Math.max(e.margin.l||0,0),a=Math.max(e.margin.r||0,0),o=Math.max(e.margin.t||0,0),s=Math.max(e.margin.b||0,0),l=e._pushmargin;return e.margin.autoexpand!==!1&&(l.base={l:{val:0,size:i},r:{val:1,size:a},t:{val:1,size:o},b:{val:0,size:s}},Object.keys(l).forEach(function(t){var r=l[t].l||{},n=l[t].b||{},c=r.val,f=r.size,h=n.val,d=n.size;Object.keys(l).forEach(function(t){if(u(f)&&l[t].r){var r=l[t].r.val,n=l[t].r.size;if(r>c){var p=(f*r+(n-e.width)*c)/(r-c),g=(n*(1-c)+(f-e.width)*(1-r))/(r-c);p>=0&&g>=0&&p+g>i+a&&(i=p,a=g)}}if(u(d)&&l[t].t){var v=l[t].t.val,m=l[t].t.size;if(v>h){var y=(d*v+(m-e.height)*h)/(v-h),b=(m*(1-h)+(d-e.height)*(1-v))/(v-h);y>=0&&b>=0&&y+b>s+o&&(s=y,o=b)}}})})),r.l=Math.round(i),r.r=Math.round(a),r.t=Math.round(o),r.b=Math.round(s),r.p=Math.round(e.margin.pad),r.w=Math.round(e.width)-r.l-r.r,r.h=Math.round(e.height)-r.t-r.b,t._replotting||"{}"===n||n===JSON.stringify(e._size)?void 0:c.plot(t)},d.graphJson=function(t,e,r,n,i){function a(t){if("function"==typeof t)return null;if(f.isPlainObject(t)){var e,n,i={};for(e in t)if("function"!=typeof t[e]&&-1===["_","["].indexOf(e.charAt(0))){if("keepdata"===r){if("src"===e.substr(e.length-3))continue}else if("keepstream"===r){if(n=t[e+"src"],"string"==typeof n&&n.indexOf(":")>0&&!f.isPlainObject(t.stream))continue}else if("keepall"!==r&&(n=t[e+"src"],"string"==typeof n&&n.indexOf(":")>0))continue;i[e]=a(t[e])}return i}return Array.isArray(t)?t.map(a):t&&t.getTime?f.ms2DateTime(t):t}(i&&e&&!t._fullData||i&&!e&&!t._fullLayout)&&d.supplyDefaults(t);var o=i?t._fullData:t.data,s=i?t._fullLayout:t.layout,l={data:(o||[]).map(function(t){var r=a(t);return e&&delete r.fit,r})};return e||(l.layout=a(s)),t.framework&&t.framework.isPolar&&(l=t.framework.getConfig()),"object"===n?l:JSON.stringify(l)}},{"../components/color":176,"../lib":256,"../plotly":276,"./attributes":277,"./font_attributes":297,"./layout_attributes":302,d3:62,"fast-isnumeric":65}],304:[function(t,e,r){"use strict";var n=t("../../traces/scatter/attributes"),i=n.marker;e.exports={r:n.r,t:n.t,marker:{color:i.color,size:i.size,symbol:i.symbol,opacity:i.opacity}}},{"../../traces/scatter/attributes":341}],305:[function(t,e,r){"use strict";function n(t,e){var r={showline:{valType:"boolean"},showticklabels:{valType:"boolean"},tickorientation:{valType:"enumerated",values:["horizontal","vertical"]},ticklen:{valType:"number",min:0},tickcolor:{valType:"color"},ticksuffix:{valType:"string"},endpadding:{valType:"number"},visible:{valType:"boolean"}};return a({},e,r)}var i=t("../cartesian/layout_attributes"),a=t("../../lib/extend").extendFlat,o=a({},i.domain,{});e.exports={radialaxis:n("radial",{range:{valType:"info_array",items:[{valType:"number"},{valType:"number"}]},domain:o,orientation:{valType:"number"}}),angularaxis:n("angular",{range:{valType:"info_array",items:[{valType:"number",dflt:0},{valType:"number",dflt:360}]},domain:o}),layout:{direction:{valType:"enumerated",values:["clockwise","counterclockwise"]},orientation:{valType:"angle"}}}},{"../../lib/extend":253,"../cartesian/layout_attributes":288}],306:[function(t,e,r){var n=t("../../plotly"),i=t("d3"),a=e.exports={version:"0.2.2",manager:t("./micropolar_manager")},o=n.Lib.extendDeepAll;a.Axis=function(){function t(t){r=t||r;var u=l.data,f=l.layout;return("string"==typeof r||r.nodeName)&&(r=i.select(r)),r.datum(u).each(function(t,r){function l(t,e){return s(t)%360+f.orientation}var u=t.slice();c={data:a.util.cloneJson(u),layout:a.util.cloneJson(f)};var h=0;u.forEach(function(t,e){t.color||(t.color=f.defaultColorRange[h],h=(h+1)%f.defaultColorRange.length),t.strokeColor||(t.strokeColor="LinePlot"===t.geometry?t.color:i.rgb(t.color).darker().toString()),c.data[e].color=t.color,c.data[e].strokeColor=t.strokeColor,c.data[e].strokeDash=t.strokeDash,c.data[e].strokeSize=t.strokeSize});var d=u.filter(function(t,e){var r=t.visible;return"undefined"==typeof r||r===!0}),p=!1,g=d.map(function(t,e){return p=p||"undefined"!=typeof t.groupId,t});if(p){var v=i.nest().key(function(t,e){return"undefined"!=typeof t.groupId?t.groupId:"unstacked"}).entries(g),m=[],y=v.map(function(t,e){if("unstacked"===t.key)return t.values;var r=t.values[0].r.map(function(t,e){return 0});return t.values.forEach(function(t,e,n){t.yStack=[r],m.push(r),r=a.util.sumArrays(t.r,r)}),t.values});d=i.merge(y)}d.forEach(function(t,e){t.t=Array.isArray(t.t[0])?t.t:[t.t],t.r=Array.isArray(t.r[0])?t.r:[t.r]});var b=Math.min(f.width-f.margin.left-f.margin.right,f.height-f.margin.top-f.margin.bottom)/2;b=Math.max(10,b);var x,_=[f.margin.left+b,f.margin.top+b];if(p){var w=i.max(a.util.sumArrays(a.util.arrayLast(d).r[0],a.util.arrayLast(m)));x=[0,w]}else x=i.extent(a.util.flattenArray(d.map(function(t,e){return t.r})));f.radialAxis.domain!=a.DATAEXTENT&&(x[0]=0),n=i.scale.linear().domain(f.radialAxis.domain!=a.DATAEXTENT&&f.radialAxis.domain?f.radialAxis.domain:x).range([0,b]),c.layout.radialAxis.domain=n.domain();var A,k=a.util.flattenArray(d.map(function(t,e){return t.t})),M="string"==typeof k[0];M&&(k=a.util.deduplicate(k),A=k.slice(),k=i.range(k.length),d=d.map(function(t,e){var r=t;return t.t=[k],p&&(r.yStack=t.yStack),r}));var E=d.filter(function(t,e){return"LinePlot"===t.geometry||"DotPlot"===t.geometry}).length===d.length,T=null===f.needsEndSpacing?M||!E:f.needsEndSpacing,L=f.angularAxis.domain&&f.angularAxis.domain!=a.DATAEXTENT&&!M&&f.angularAxis.domain[0]>=0,S=L?f.angularAxis.domain:i.extent(k),C=Math.abs(k[1]-k[0]);E&&!M&&(C=0);var R=S.slice();T&&M&&(R[1]+=C);var I=f.angularAxis.ticksCount||4;I>8&&(I=I/(I/8)+I%8),f.angularAxis.ticksStep&&(I=(R[1]-R[0])/I);var P=f.angularAxis.ticksStep||(R[1]-R[0])/(I*(f.minorTicks+1));A&&(P=Math.max(Math.round(P),1)),R[2]||(R[2]=P);var O=i.range.apply(this,R);if(O=O.map(function(t,e){return parseFloat(t.toPrecision(12))}),s=i.scale.linear().domain(R.slice(0,2)).range("clockwise"===f.direction?[0,360]:[360,0]),c.layout.angularAxis.domain=s.domain(),c.layout.angularAxis.endPadding=T?C:0,e=i.select(this).select("svg.chart-root"),"undefined"==typeof e||e.empty()){var N="' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '",z=(new DOMParser).parseFromString(N,"application/xml"),D=this.appendChild(this.ownerDocument.importNode(z.documentElement,!0));e=i.select(D)}e.select(".guides-group").style({"pointer-events":"none"}),e.select(".angular.axis-group").style({"pointer-events":"none"}),e.select(".radial.axis-group").style({"pointer-events":"none"});var F,B=e.select(".chart-group"),j={fill:"none",stroke:f.tickColor},U={"font-size":f.font.size,"font-family":f.font.family,fill:f.font.color,"text-shadow":["-1px 0px","1px -1px","-1px 1px","1px 1px"].map(function(t,e){return" "+t+" 0 "+f.font.outlineColor}).join(",")};if(f.showLegend){F=e.select(".legend-group").attr({transform:"translate("+[b,f.margin.top]+")"}).style({display:"block"});var V=d.map(function(t,e){var r=a.util.cloneJson(t);return r.symbol="DotPlot"===t.geometry?t.dotType||"circle":"LinePlot"!=t.geometry?"square":"line",r.visibleInLegend="undefined"==typeof t.visibleInLegend||t.visibleInLegend,r.color="LinePlot"===t.geometry?t.strokeColor:t.color,r});a.Legend().config({data:d.map(function(t,e){return t.name||"Element"+e}),legendConfig:o({},a.Legend.defaultConfig().legendConfig,{container:F,elements:V,reverseOrder:f.legend.reverseOrder})})();var q=F.node().getBBox();b=Math.min(f.width-q.width-f.margin.left-f.margin.right,f.height-f.margin.top-f.margin.bottom)/2,b=Math.max(10,b),_=[f.margin.left+b,f.margin.top+b],n.range([0,b]),c.layout.radialAxis.domain=n.domain(),F.attr("transform","translate("+[_[0]+b,_[1]-b]+")")}else F=e.select(".legend-group").style({display:"none"});e.attr({width:f.width,height:f.height}).style({opacity:f.opacity}),B.attr("transform","translate("+_+")").style({cursor:"crosshair"});var H=[(f.width-(f.margin.left+f.margin.right+2*b+(q?q.width:0)))/2,(f.height-(f.margin.top+f.margin.bottom+2*b))/2];if(H[0]=Math.max(0,H[0]),H[1]=Math.max(0,H[1]),e.select(".outer-group").attr("transform","translate("+H+")"),f.title){var G=e.select("g.title-group text").style(U).text(f.title),X=G.node().getBBox();G.attr({x:_[0]-X.width/2,y:_[1]-b-20})}var Y=e.select(".radial.axis-group");if(f.radialAxis.gridLinesVisible){var W=Y.selectAll("circle.grid-circle").data(n.ticks(5));W.enter().append("circle").attr({"class":"grid-circle"}).style(j),W.attr("r",n),W.exit().remove()}Y.select("circle.outside-circle").attr({r:b}).style(j);var Z=e.select("circle.background-circle").attr({r:b}).style({fill:f.backgroundColor,stroke:f.stroke});if(f.radialAxis.visible){var Q=i.svg.axis().scale(n).ticks(5).tickSize(5);Y.call(Q).attr({transform:"rotate("+f.radialAxis.orientation+")"}),Y.selectAll(".domain").style(j),Y.selectAll("g>text").text(function(t,e){return this.textContent+f.radialAxis.ticksSuffix}).style(U).style({"text-anchor":"start"}).attr({x:0,y:0,dx:0,dy:0,transform:function(t,e){return"horizontal"===f.radialAxis.tickOrientation?"rotate("+-f.radialAxis.orientation+") translate("+[0,U["font-size"]]+")":"translate("+[0,U["font-size"]]+")"}}),Y.selectAll("g>line").style({stroke:"black"})}var $=e.select(".angular.axis-group").selectAll("g.angular-tick").data(O),K=$.enter().append("g").classed("angular-tick",!0);$.attr({transform:function(t,e){return"rotate("+l(t,e)+")"}}).style({display:f.angularAxis.visible?"block":"none"}),$.exit().remove(),K.append("line").classed("grid-line",!0).classed("major",function(t,e){return e%(f.minorTicks+1)==0}).classed("minor",function(t,e){return!(e%(f.minorTicks+1)==0)}).style(j),K.selectAll(".minor").style({stroke:f.minorTickColor}),$.select("line.grid-line").attr({x1:f.tickLength?b-f.tickLength:0,x2:b}).style({display:f.angularAxis.gridLinesVisible?"block":"none"}),K.append("text").classed("axis-text",!0).style(U);var J=$.select("text.axis-text").attr({x:b+f.labelOffset,dy:".35em",transform:function(t,e){var r=l(t,e),n=b+f.labelOffset,i=f.angularAxis.tickOrientation;return"horizontal"==i?"rotate("+-r+" "+n+" 0)":"radial"==i?270>r&&r>90?"rotate(180 "+n+" 0)":null:"rotate("+(180>=r&&r>0?-90:90)+" "+n+" 0)"}}).style({"text-anchor":"middle",display:f.angularAxis.labelsVisible?"block":"none"}).text(function(t,e){return e%(f.minorTicks+1)!=0?"":A?A[t]+f.angularAxis.ticksSuffix:t+f.angularAxis.ticksSuffix}).style(U);f.angularAxis.rewriteTicks&&J.text(function(t,e){return e%(f.minorTicks+1)!=0?"":f.angularAxis.rewriteTicks(this.textContent,e)});var tt=i.max(B.selectAll(".angular-tick text")[0].map(function(t,e){return t.getCTM().e+t.getBBox().width}));F.attr({transform:"translate("+[b+tt,f.margin.top]+")"});var et=e.select("g.geometry-group").selectAll("g").size()>0,rt=e.select("g.geometry-group").selectAll("g.geometry").data(d);if(rt.enter().append("g").attr({"class":function(t,e){return"geometry geometry"+e}}),rt.exit().remove(),d[0]||et){var nt=[];d.forEach(function(t,e){var r={};r.radialScale=n,r.angularScale=s,r.container=rt.filter(function(t,r){return r==e}),r.geometry=t.geometry,r.orientation=f.orientation,r.direction=f.direction,r.index=e,nt.push({data:t,geometryConfig:r})});var it=i.nest().key(function(t,e){return"undefined"!=typeof t.data.groupId||"unstacked"}).entries(nt),at=[];it.forEach(function(t,e){"unstacked"===t.key?at=at.concat(t.values.map(function(t,e){return[t]})):at.push(t.values)}),at.forEach(function(t,e){var r;r=Array.isArray(t)?t[0].geometryConfig.geometry:t.geometryConfig.geometry;var n=t.map(function(t,e){return o(a[r].defaultConfig(),t)});a[r]().config(n)()})}var ot,st,lt=e.select(".guides-group"),ut=e.select(".tooltips-group"),ct=a.tooltipPanel().config({container:ut,fontSize:8})(),ft=a.tooltipPanel().config({container:ut,fontSize:8})(),ht=a.tooltipPanel().config({container:ut,hasTick:!0})();if(!M){var dt=lt.select("line").attr({x1:0,y1:0,y2:0}).style({stroke:"grey","pointer-events":"none"});B.on("mousemove.angular-guide",function(t,e){var r=a.util.getMousePos(Z).angle;dt.attr({x2:-b,transform:"rotate("+r+")"}).style({opacity:.5});var n=(r+180+360-f.orientation)%360;ot=s.invert(n);var i=a.util.convertToCartesian(b+12,r+180);ct.text(a.util.round(ot)).move([i[0]+_[0],i[1]+_[1]])}).on("mouseout.angular-guide",function(t,e){lt.select("line").style({opacity:0})})}var pt=lt.select("circle").style({stroke:"grey",fill:"none"});B.on("mousemove.radial-guide",function(t,e){var r=a.util.getMousePos(Z).radius;pt.attr({r:r}).style({opacity:.5}),st=n.invert(a.util.getMousePos(Z).radius);var i=a.util.convertToCartesian(r,f.radialAxis.orientation);ft.text(a.util.round(st)).move([i[0]+_[0],i[1]+_[1]])}).on("mouseout.radial-guide",function(t,e){pt.style({opacity:0}),ht.hide(),ct.hide(),ft.hide()}),e.selectAll(".geometry-group .mark").on("mouseover.tooltip",function(t,r){var n=i.select(this),o=n.style("fill"),s="black",l=n.style("opacity")||1;if(n.attr({"data-opacity":l}),"none"!=o){n.attr({"data-fill":o}),s=i.hsl(o).darker().toString(),n.style({fill:s,opacity:1});var u={t:a.util.round(t[0]),r:a.util.round(t[1])};M&&(u.t=A[t[0]]);var c="t: "+u.t+", r: "+u.r,f=this.getBoundingClientRect(),h=e.node().getBoundingClientRect(),d=[f.left+f.width/2-H[0]-h.left,f.top+f.height/2-H[1]-h.top];ht.config({color:s}).text(c),ht.move(d)}else o=n.style("stroke"),n.attr({"data-stroke":o}),s=i.hsl(o).darker().toString(),n.style({stroke:s,opacity:1})}).on("mousemove.tooltip",function(t,e){return 0!=i.event.which?!1:void(i.select(this).attr("data-fill")&&ht.show())}).on("mouseout.tooltip",function(t,e){ht.hide();var r=i.select(this),n=r.attr("data-fill");n?r.style({fill:n,opacity:r.attr("data-opacity")}):r.style({stroke:r.attr("data-stroke"),opacity:r.attr("data-opacity")})})}),h}var e,r,n,s,l={data:[],layout:{}},u={},c={},f=i.dispatch("hover"),h={};return h.render=function(e){return t(e),this},h.config=function(t){if(!arguments.length)return l;var e=a.util.cloneJson(t);return e.data.forEach(function(t,e){l.data[e]||(l.data[e]={}),o(l.data[e],a.Axis.defaultConfig().data[0]),o(l.data[e],t)}),o(l.layout,a.Axis.defaultConfig().layout),o(l.layout,e.layout),this},h.getLiveConfig=function(){return c},h.getinputConfig=function(){return u},h.radialScale=function(t){return n},h.angularScale=function(t){return s},h.svg=function(){return e},i.rebind(h,f,"on"),h},a.Axis.defaultConfig=function(t,e){var r={data:[{t:[1,2,3,4],r:[10,11,12,13],name:"Line1",geometry:"LinePlot",color:null,strokeDash:"solid",strokeColor:null,strokeSize:"1",visibleInLegend:!0,opacity:1}],layout:{defaultColorRange:i.scale.category10().range(),title:null,height:450,width:500,margin:{top:40,right:40,bottom:40,left:40},font:{size:12,color:"gray",outlineColor:"white",family:"Tahoma, sans-serif"},direction:"clockwise",orientation:0,labelOffset:10,radialAxis:{domain:null,orientation:-45,ticksSuffix:"",visible:!0,gridLinesVisible:!0,tickOrientation:"horizontal",rewriteTicks:null},angularAxis:{domain:[0,360],ticksSuffix:"",visible:!0,gridLinesVisible:!0,labelsVisible:!0,tickOrientation:"horizontal",rewriteTicks:null,ticksCount:null,ticksStep:null},minorTicks:0,tickLength:null,tickColor:"silver",minorTickColor:"#eee",backgroundColor:"none",needsEndSpacing:null,showLegend:!0,legend:{reverseOrder:!1},opacity:1}};return r},a.util={},a.DATAEXTENT="dataExtent",a.AREA="AreaChart",a.LINE="LinePlot",a.DOT="DotPlot",a.BAR="BarChart",a.util._override=function(t,e){for(var r in t)r in e&&(e[r]=t[r])},a.util._extend=function(t,e){for(var r in t)e[r]=t[r]},a.util._rndSnd=function(){return 2*Math.random()-1+(2*Math.random()-1)+(2*Math.random()-1)},a.util.dataFromEquation2=function(t,e){var r=e||6,n=i.range(0,360+r,r).map(function(e,r){var n=e*Math.PI/180,i=t(n);return[e,i]});return n},a.util.dataFromEquation=function(t,e,r){var n=e||6,a=[],o=[];i.range(0,360+n,n).forEach(function(e,r){ +-var n=e*Math.PI/180,i=t(n);a.push(e),o.push(i)});var s={t:a,r:o};return r&&(s.name=r),s},a.util.ensureArray=function(t,e){if("undefined"==typeof t)return null;var r=[].concat(t);return i.range(e).map(function(t,e){return r[e]||r[0]})},a.util.fillArrays=function(t,e,r){return e.forEach(function(e,n){t[e]=a.util.ensureArray(t[e],r)}),t},a.util.cloneJson=function(t){return JSON.parse(JSON.stringify(t))},a.util.validateKeys=function(t,e){"string"==typeof e&&(e=e.split("."));var r=e.shift();return t[r]&&(!e.length||objHasKeys(t[r],e))},a.util.sumArrays=function(t,e){return i.zip(t,e).map(function(t,e){return i.sum(t)})},a.util.arrayLast=function(t){return t[t.length-1]},a.util.arrayEqual=function(t,e){for(var r=Math.max(t.length,e.length,1);r-- >=0&&t[r]===e[r];);return-2===r},a.util.flattenArray=function(t){for(var e=[];!a.util.arrayEqual(e,t);)e=t,t=[].concat.apply([],t);return t},a.util.deduplicate=function(t){return t.filter(function(t,e,r){return r.indexOf(t)==e})},a.util.convertToCartesian=function(t,e){var r=e*Math.PI/180,n=t*Math.cos(r),i=t*Math.sin(r);return[n,i]},a.util.round=function(t,e){var r=e||2,n=Math.pow(10,r);return Math.round(t*n)/n},a.util.getMousePos=function(t){var e=i.mouse(t.node()),r=e[0],n=e[1],a={};return a.x=r,a.y=n,a.pos=e,a.angle=180*(Math.atan2(n,r)+Math.PI)/Math.PI,a.radius=Math.sqrt(r*r+n*n),a},a.util.duplicatesCount=function(t){for(var e,r={},n={},i=0,a=t.length;a>i;i++)e=t[i],e in r?(r[e]++,n[e]=r[e]):r[e]=1;return n},a.util.duplicates=function(t){return Object.keys(a.util.duplicatesCount(t))},a.util.translator=function(t,e,r,n){if(n){var i=r.slice();r=e,e=i}var a=e.reduce(function(t,e){return"undefined"!=typeof t?t[e]:void 0},t);"undefined"!=typeof a&&(e.reduce(function(t,r,n){return"undefined"!=typeof t?(n===e.length-1&&delete t[r],t[r]):void 0},t),r.reduce(function(t,e,n){return"undefined"==typeof t[e]&&(t[e]={}),n===r.length-1&&(t[e]=a),t[e]},t))},a.PolyChart=function(){function t(){var t=r[0].geometryConfig,e=t.container;"string"==typeof e&&(e=i.select(e)),e.datum(r).each(function(e,r){function n(e,r){var n=t.radialScale(e[1]),i=(t.angularScale(e[0])+t.orientation)*Math.PI/180;return{r:n,t:i}}function a(t){var e=t.r*Math.cos(t.t),r=t.r*Math.sin(t.t);return{x:e,y:r}}var o=!!e[0].data.yStack,l=e.map(function(t,e){return o?i.zip(t.data.t[0],t.data.r[0],t.data.yStack[0]):i.zip(t.data.t[0],t.data.r[0])}),u=t.angularScale,c=t.radialScale.domain()[0],f={};f.bar=function(r,n,a){var o=e[a].data,s=t.radialScale(r[1])-t.radialScale(0),l=t.radialScale(r[2]||0),c=o.barWidth;i.select(this).attr({"class":"mark bar",d:"M"+[[s+l,-c/2],[s+l,c/2],[l,c/2],[l,-c/2]].join("L")+"Z",transform:function(e,r){return"rotate("+(t.orientation+u(e[0]))+")"}})},f.dot=function(t,r,o){var s=t[2]?[t[0],t[1]+t[2]]:t,l=i.svg.symbol().size(e[o].data.dotSize).type(e[o].data.dotType)(t,r);i.select(this).attr({"class":"mark dot",d:l,transform:function(t,e){var r=a(n(s));return"translate("+[r.x,r.y]+")"}})};var h=i.svg.line.radial().interpolate(e[0].data.lineInterpolation).radius(function(e){return t.radialScale(e[1])}).angle(function(e){return t.angularScale(e[0])*Math.PI/180});f.line=function(r,n,a){var o=r[2]?l[a].map(function(t,e){return[t[0],t[1]+t[2]]}):l[a];if(i.select(this).each(f.dot).style({opacity:function(t,r){return+e[a].data.dotVisible},fill:v.stroke(r,n,a)}).attr({"class":"mark dot"}),!(n>0)){var s=i.select(this.parentNode).selectAll("path.line").data([0]);s.enter().insert("path"),s.attr({"class":"line",d:h(o),transform:function(e,r){return"rotate("+(t.orientation+90)+")"},"pointer-events":"none"}).style({fill:function(t,e){return v.fill(r,n,a)},"fill-opacity":0,stroke:function(t,e){return v.stroke(r,n,a)},"stroke-width":function(t,e){return v["stroke-width"](r,n,a)},"stroke-dasharray":function(t,e){return v["stroke-dasharray"](r,n,a)},opacity:function(t,e){return v.opacity(r,n,a)},display:function(t,e){return v.display(r,n,a)}})}};var d=t.angularScale.range(),p=Math.abs(d[1]-d[0])/l[0].length*Math.PI/180,g=i.svg.arc().startAngle(function(t){return-p/2}).endAngle(function(t){return p/2}).innerRadius(function(e){return t.radialScale(c+(e[2]||0))}).outerRadius(function(e){return t.radialScale(c+(e[2]||0))+t.radialScale(e[1])});f.arc=function(e,r,n){i.select(this).attr({"class":"mark arc",d:g,transform:function(e,r){return"rotate("+(t.orientation+u(e[0])+90)+")"}})};var v={fill:function(t,r,n){return e[n].data.color},stroke:function(t,r,n){return e[n].data.strokeColor},"stroke-width":function(t,r,n){return e[n].data.strokeSize+"px"},"stroke-dasharray":function(t,r,n){return s[e[n].data.strokeDash]},opacity:function(t,r,n){return e[n].data.opacity},display:function(t,r,n){return"undefined"==typeof e[n].data.visible||e[n].data.visible?"block":"none"}},m=i.select(this).selectAll("g.layer").data(l);m.enter().append("g").attr({"class":"layer"});var y=m.selectAll("path.mark").data(function(t,e){return t});y.enter().append("path").attr({"class":"mark"}),y.style(v).each(f[t.geometryType]),y.exit().remove(),m.exit().remove()})}var e,r=[a.PolyChart.defaultConfig()],n=i.dispatch("hover"),s={solid:"none",dash:[5,2],dot:[2,5]};return t.config=function(t){return arguments.length?(t.forEach(function(t,e){r[e]||(r[e]={}),o(r[e],a.PolyChart.defaultConfig()),o(r[e],t)}),this):r},t.getColorScale=function(){return e},i.rebind(t,n,"on"),t},a.PolyChart.defaultConfig=function(){var t={data:{name:"geom1",t:[[1,2,3,4]],r:[[1,2,3,4]],dotType:"circle",dotSize:64,dotVisible:!1,barWidth:20,color:"#ffa500",strokeSize:1,strokeColor:"silver",strokeDash:"solid",opacity:1,index:0,visible:!0,visibleInLegend:!0},geometryConfig:{geometry:"LinePlot",geometryType:"arc",direction:"clockwise",orientation:0,container:"body",radialScale:null,angularScale:null,colorScale:i.scale.category20()}};return t},a.BarChart=function(){return a.PolyChart()},a.BarChart.defaultConfig=function(){var t={geometryConfig:{geometryType:"bar"}};return t},a.AreaChart=function(){return a.PolyChart()},a.AreaChart.defaultConfig=function(){var t={geometryConfig:{geometryType:"arc"}};return t},a.DotPlot=function(){return a.PolyChart()},a.DotPlot.defaultConfig=function(){var t={geometryConfig:{geometryType:"dot",dotType:"circle"}};return t},a.LinePlot=function(){return a.PolyChart()},a.LinePlot.defaultConfig=function(){var t={geometryConfig:{geometryType:"line"}};return t},a.Legend=function(){function t(){var r=e.legendConfig,n=e.data.map(function(t,e){return[].concat(t).map(function(t,n){var i=o({},r.elements[e]);return i.name=t,i.color=[].concat(r.elements[e].color)[n],i})}),a=i.merge(n);a=a.filter(function(t,e){return r.elements[e]&&(r.elements[e].visibleInLegend||"undefined"==typeof r.elements[e].visibleInLegend)}),r.reverseOrder&&(a=a.reverse());var s=r.container;("string"==typeof s||s.nodeName)&&(s=i.select(s));var l=a.map(function(t,e){return t.color}),u=r.fontSize,c=null==r.isContinuous?"number"==typeof a[0]:r.isContinuous,f=c?r.height:u*a.length,h=s.classed("legend-group",!0),d=h.selectAll("svg").data([0]),p=d.enter().append("svg").attr({width:300,height:f+u,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"});p.append("g").classed("legend-axis",!0),p.append("g").classed("legend-marks",!0);var g=i.range(a.length),v=i.scale[c?"linear":"ordinal"]().domain(g).range(l),m=i.scale[c?"linear":"ordinal"]().domain(g)[c?"range":"rangePoints"]([0,f]),y=function(t,e){var r=3*e;return"line"===t?"M"+[[-e/2,-e/12],[e/2,-e/12],[e/2,e/12],[-e/2,e/12]]+"Z":-1!=i.svg.symbolTypes.indexOf(t)?i.svg.symbol().type(t).size(r)():i.svg.symbol().type("square").size(r)()};if(c){var b=d.select(".legend-marks").append("defs").append("linearGradient").attr({id:"grad1",x1:"0%",y1:"0%",x2:"0%",y2:"100%"}).selectAll("stop").data(l);b.enter().append("stop"),b.attr({offset:function(t,e){return e/(l.length-1)*100+"%"}}).style({"stop-color":function(t,e){return t}}),d.append("rect").classed("legend-mark",!0).attr({height:r.height,width:r.colorBandWidth,fill:"url(#grad1)"})}else{var x=d.select(".legend-marks").selectAll("path.legend-mark").data(a);x.enter().append("path").classed("legend-mark",!0),x.attr({transform:function(t,e){return"translate("+[u/2,m(e)+u/2]+")"},d:function(t,e){var r=t.symbol;return y(r,u)},fill:function(t,e){return v(e)}}),x.exit().remove()}var _=i.svg.axis().scale(m).orient("right"),w=d.select("g.legend-axis").attr({transform:"translate("+[c?r.colorBandWidth:u,u/2]+")"}).call(_);return w.selectAll(".domain").style({fill:"none",stroke:"none"}),w.selectAll("line").style({fill:"none",stroke:c?r.textColor:"none"}),w.selectAll("text").style({fill:r.textColor,"font-size":r.fontSize}).text(function(t,e){return a[e].name}),t}var e=a.Legend.defaultConfig(),r=i.dispatch("hover");return t.config=function(t){return arguments.length?(o(e,t),this):e},i.rebind(t,r,"on"),t},a.Legend.defaultConfig=function(t,e){var r={data:["a","b","c"],legendConfig:{elements:[{symbol:"line",color:"red"},{symbol:"square",color:"yellow"},{symbol:"diamond",color:"limegreen"}],height:150,colorBandWidth:30,fontSize:12,container:"body",isContinuous:null,textColor:"grey",reverseOrder:!1}};return r},a.tooltipPanel=function(){var t,e,r,n={container:null,hasTick:!1,fontSize:12,color:"white",padding:5},s="tooltip-"+a.tooltipPanel.uid++,l=10,u=function(){t=n.container.selectAll("g."+s).data([0]);var i=t.enter().append("g").classed(s,!0).style({"pointer-events":"none",display:"none"});return r=i.append("path").style({fill:"white","fill-opacity":.9}).attr({d:"M0 0"}),e=i.append("text").attr({dx:n.padding+l,dy:.3*+n.fontSize}),u};return u.text=function(a){var o=i.hsl(n.color).l,s=o>=.5?"#aaa":"white",c=o>=.5?"black":"white",f=a||"";e.style({fill:c,"font-size":n.fontSize+"px"}).text(f);var h=n.padding,d=e.node().getBBox(),p={fill:n.color,stroke:s,"stroke-width":"2px"},g=d.width+2*h+l,v=d.height+2*h;return r.attr({d:"M"+[[l,-v/2],[l,-v/4],[n.hasTick?0:l,0],[l,v/4],[l,v/2],[g,v/2],[g,-v/2]].join("L")+"Z"}).style(p),t.attr({transform:"translate("+[l,-v/2+2*h]+")"}),t.style({display:"block"}),u},u.move=function(e){return t?(t.attr({transform:"translate("+[e[0],e[1]]+")"}).style({display:"block"}),u):void 0},u.hide=function(){return t?(t.style({display:"none"}),u):void 0},u.show=function(){return t?(t.style({display:"block"}),u):void 0},u.config=function(t){return o(n,t),u},u},a.tooltipPanel.uid=1,a.adapter={},a.adapter.plotly=function(){var t={};return t.convert=function(t,e){var r={};if(t.data&&(r.data=t.data.map(function(t,r){var n=o({},t),i=[[n,["marker","color"],["color"]],[n,["marker","opacity"],["opacity"]],[n,["marker","line","color"],["strokeColor"]],[n,["marker","line","dash"],["strokeDash"]],[n,["marker","line","width"],["strokeSize"]],[n,["marker","symbol"],["dotType"]],[n,["marker","size"],["dotSize"]],[n,["marker","barWidth"],["barWidth"]],[n,["line","interpolation"],["lineInterpolation"]],[n,["showlegend"],["visibleInLegend"]]];return i.forEach(function(t,r){a.util.translator.apply(null,t.concat(e))}),e||delete n.marker,e&&delete n.groupId,e?("LinePlot"===n.geometry?(n.type="scatter",n.dotVisible===!0?(delete n.dotVisible,n.mode="lines+markers"):n.mode="lines"):"DotPlot"===n.geometry?(n.type="scatter",n.mode="markers"):"AreaChart"===n.geometry?n.type="area":"BarChart"===n.geometry&&(n.type="bar"),delete n.geometry):("scatter"===n.type?"lines"===n.mode?n.geometry="LinePlot":"markers"===n.mode?n.geometry="DotPlot":"lines+markers"===n.mode&&(n.geometry="LinePlot",n.dotVisible=!0):"area"===n.type?n.geometry="AreaChart":"bar"===n.type&&(n.geometry="BarChart"),delete n.mode,delete n.type),n}),!e&&t.layout&&"stack"===t.layout.barmode)){var n=a.util.duplicates(r.data.map(function(t,e){return t.geometry}));r.data.forEach(function(t,e){var i=n.indexOf(t.geometry);-1!=i&&(r.data[e].groupId=i)})}if(t.layout){var s=o({},t.layout),l=[[s,["plot_bgcolor"],["backgroundColor"]],[s,["showlegend"],["showLegend"]],[s,["radialaxis"],["radialAxis"]],[s,["angularaxis"],["angularAxis"]],[s.angularaxis,["showline"],["gridLinesVisible"]],[s.angularaxis,["showticklabels"],["labelsVisible"]],[s.angularaxis,["nticks"],["ticksCount"]],[s.angularaxis,["tickorientation"],["tickOrientation"]],[s.angularaxis,["ticksuffix"],["ticksSuffix"]],[s.angularaxis,["range"],["domain"]],[s.angularaxis,["endpadding"],["endPadding"]],[s.radialaxis,["showline"],["gridLinesVisible"]],[s.radialaxis,["tickorientation"],["tickOrientation"]],[s.radialaxis,["ticksuffix"],["ticksSuffix"]],[s.radialaxis,["range"],["domain"]],[s.angularAxis,["showline"],["gridLinesVisible"]],[s.angularAxis,["showticklabels"],["labelsVisible"]],[s.angularAxis,["nticks"],["ticksCount"]],[s.angularAxis,["tickorientation"],["tickOrientation"]],[s.angularAxis,["ticksuffix"],["ticksSuffix"]],[s.angularAxis,["range"],["domain"]],[s.angularAxis,["endpadding"],["endPadding"]],[s.radialAxis,["showline"],["gridLinesVisible"]],[s.radialAxis,["tickorientation"],["tickOrientation"]],[s.radialAxis,["ticksuffix"],["ticksSuffix"]],[s.radialAxis,["range"],["domain"]],[s.font,["outlinecolor"],["outlineColor"]],[s.legend,["traceorder"],["reverseOrder"]],[s,["labeloffset"],["labelOffset"]],[s,["defaultcolorrange"],["defaultColorRange"]]];if(l.forEach(function(t,r){a.util.translator.apply(null,t.concat(e))}),e?("undefined"!=typeof s.tickLength&&(s.angularaxis.ticklen=s.tickLength,delete s.tickLength),s.tickColor&&(s.angularaxis.tickcolor=s.tickColor,delete s.tickColor)):(s.angularAxis&&"undefined"!=typeof s.angularAxis.ticklen&&(s.tickLength=s.angularAxis.ticklen),s.angularAxis&&"undefined"!=typeof s.angularAxis.tickcolor&&(s.tickColor=s.angularAxis.tickcolor)),s.legend&&"boolean"!=typeof s.legend.reverseOrder&&(s.legend.reverseOrder="normal"!=s.legend.reverseOrder),s.legend&&"boolean"==typeof s.legend.traceorder&&(s.legend.traceorder=s.legend.traceorder?"reversed":"normal",delete s.legend.reverseOrder),s.margin&&"undefined"!=typeof s.margin.t){var u=["t","r","b","l","pad"],c=["top","right","bottom","left","pad"],f={};i.entries(s.margin).forEach(function(t,e){f[c[u.indexOf(t.key)]]=t.value}),s.margin=f}e&&(delete s.needsEndSpacing,delete s.minorTickColor,delete s.minorTicks,delete s.angularaxis.ticksCount,delete s.angularaxis.ticksCount,delete s.angularaxis.ticksStep,delete s.angularaxis.rewriteTicks,delete s.angularaxis.nticks,delete s.radialaxis.ticksCount,delete s.radialaxis.ticksCount,delete s.radialaxis.ticksStep,delete s.radialaxis.rewriteTicks,delete s.radialaxis.nticks),r.layout=s}return r},t}},{"../../plotly":276,"./micropolar_manager":307,d3:62}],307:[function(t,e,r){"use strict";var n=t("../../plotly"),i=t("d3"),a=t("./undo_manager"),o=e.exports={},s=n.Lib.extendDeepAll;o.framework=function(t){function e(e,a){return a&&(f=a),i.select(i.select(f).node().parentNode).selectAll(".svg-container>*:not(.chart-root)").remove(),r=r?s(r,e):e,u||(u=n.micropolar.Axis()),c=n.micropolar.adapter.plotly().convert(r),u.config(c).render(f),t.data=r.data,t.layout=r.layout,o.fillLayout(t),r}var r,l,u,c,f,h=new a;return e.isPolar=!0,e.svg=function(){return u.svg()},e.getConfig=function(){return r},e.getLiveConfig=function(){return n.micropolar.adapter.plotly().convert(u.getLiveConfig(),!0)},e.getLiveScales=function(){return{t:u.angularScale(),r:u.radialScale()}},e.setUndoPoint=function(){var t=this,e=n.micropolar.util.cloneJson(r);!function(e,r){h.add({undo:function(){r&&t(r)},redo:function(){t(e)}})}(e,l),l=n.micropolar.util.cloneJson(e)},e.undo=function(){h.undo()},e.redo=function(){h.redo()},e},o.fillLayout=function(t){var e=i.select(t).selectAll(".plot-container"),r=e.selectAll(".svg-container"),a=t.framework&&t.framework.svg&&t.framework.svg(),o={width:800,height:600,paper_bgcolor:n.Color.background,_container:e,_paperdiv:r,_paper:a};t._fullLayout=s(o,t.layout)}},{"../../plotly":276,"./undo_manager":308,d3:62}],308:[function(t,e,r){"use strict";e.exports=function(){function t(t,e){return t?(i=!0,t[e](),i=!1,this):this}var e,r=[],n=-1,i=!1;return{add:function(t){return i?this:(r.splice(n+1,r.length-n),r.push(t),n=r.length-1,this)},setCallback:function(t){e=t},undo:function(){var i=r[n];return i?(t(i,"undo"),n-=1,e&&e(i.undo),this):this},redo:function(){var i=r[n+1];return i?(t(i,"redo"),n+=1,e&&e(i.redo),this):this},clear:function(){r=[],n=-1},hasUndo:function(){return-1!==n},hasRedo:function(){return n-1}var a=t("../plotly"),o=a.Lib.extendFlat,s=a.Lib.extendDeep;e.exports=function(t,e){t.framework&&t.framework.isPolar&&(t=t.framework.getConfig());var r,l=t.data,u=t.layout,c=s([],l),f=s({},u,n(e.tileClass));if(e.width&&(f.width=e.width),e.height&&(f.height=e.height),"thumbnail"===e.tileClass||"themes__thumb"===e.tileClass){f.annotations=[];var h=Object.keys(f);for(r=0;rr;r++)e=f[r],d[r]=e[0]*(t.zmax-t.zmin)+t.zmin,p[r]=e[1];var g=n.extent([t.zmin,t.zmax,a.start,a.start+l*(u-1)]),v=g[t.zminr;r++)e=f[r],d[r]=(e[0]*(u+c-1)-c/2)*l+o,p[r]=e[1];var y=n.scale.linear().interpolate(n.interpolateRgb).domain(d).range(p);return y}},{"../../components/colorscale/get_scale":188,d3:62}],321:[function(t,e,r){"use strict";var n=t("../../components/colorscale/defaults");e.exports=function(t,e,r,i){var a,o=r("contours.coloring");"fill"===o&&(a=r("contours.showlines")),a!==!1&&("lines"!==o&&r("line.color","#000"),r("line.width",.5),r("line.dash")),r("line.smoothing"),"none"!==(e.contours||{}).coloring&&n(t,e,i,r,{prefix:"",cLetter:"z"})}},{"../../components/colorscale/defaults":186}],322:[function(t,e,r){"use strict";function n(t,e){this.scene=t,this.uid=e,this.name="",this.hoverinfo="all",this.xData=[],this.yData=[],this.zData=[],this.textLabels=[],this.idToIndex=[],this.bounds=[0,0,0,0],this.contourOptions={z:new Float32Array(0),x:[],y:[],shape:[0,0],levels:[0],levelColors:[0,0,0,1],lineWidth:1},this.contour=s(t.glplot,this.contourOptions),this.contour._trace=this,this.heatmapOptions={z:new Float32Array(0),x:[],y:[],shape:[0,0],colorLevels:[0],colorValues:[0,0,0,0]},this.heatmap=l(t.glplot,this.heatmapOptions),this.heatmap._trace=this}function i(t,e,r){for(var n=new Float32Array(e*r),i=0,a=0;e>a;a++)for(var o=0;r>o;o++)n[i++]=t[o][a];return n}function a(t,e){for(var r=t.contours,n=r.start,i=r.end,a=r.size||1,o=e.fill,s=u(t),l=Math.floor((i-n)/a)+(o?2:1),f=new Array(l),h=new Array(4*l),d=0;l>d;d++)for(var p=f[d]=n+a*d-(o?a/2:0),g=c(s(p)),v=0;4>v;v++)h[4*d+v]=g[v];return{levels:f,levelColors:h}}function o(t,e,r){var i=new n(t,e.uid);return i.update(e,r),i}var s=t("gl-contour2d"),l=t("gl-heatmap2d"),u=t("../contour/make_color_map"),c=t("../../lib/str2rgbarray"),f=n.prototype;f.handlePick=function(t){var e=t.pointId,r=this.heatmapOptions,n=r.shape;return{trace:this,dataCoord:t.dataCoord,traceCoord:[r.x[e%n[0]],r.y[Math.floor(e/n[0])],r.z[e]],textLabel:this.textLabels[e],name:this.name,hoverinfo:this.hoverinfo}},f.update=function(t,e){var r=e[0];this.name=t.name,this.hoverinfo=t.hoverinfo;var n,o=r.z,s=o[0].length,l=o.length;this.contourOptions.z=i(o,s,l),this.heatmapOptions.z=[].concat.apply([],o),this.contourOptions.shape=this.heatmapOptions.shape=[s,l],this.contourOptions.x=this.heatmapOptions.x=r.x,this.contourOptions.y=this.heatmapOptions.y=r.y,"fill"===t.contours.coloring?(n=a(t,{fill:!0}),this.contourOptions.levels=n.levels.slice(1),this.contourOptions.fillColors=n.levelColors,this.contourOptions.levelColors=[].concat.apply([],this.contourOptions.levels.map(function(){return[.25,.25,.25,1]}))):(n=a(t,{fill:!1}),this.contourOptions.levels=n.levels,this.contourOptions.levelColors=n.levelColors),this.textLabels=[].concat.apply([],t.text),this.contour.update(this.contourOptions),this.heatmap.update(this.heatmapOptions)},f.dispose=function(){this.contour.dispose(),this.heatmap.dispose()},e.exports=o},{"../../lib/str2rgbarray":268,"../contour/make_color_map":320,"gl-contour2d":67,"gl-heatmap2d":73}],323:[function(t,e,r){"use strict";var n={};n.attributes=t("../contour/attributes"),n.supplyDefaults=t("../contour/defaults"),n.colorbar=t("../contour/colorbar"),n.calc=t("../contour/calc"),n.plot=t("./convert"),n.moduleType="trace",n.name="contourgl",n.basePlotModule=t("../../plots/gl2d"),n.categories=["gl2d","2dMap"],n.meta={},e.exports=n},{"../../plots/gl2d":300,"../contour/attributes":316,"../contour/calc":317,"../contour/colorbar":318,"../contour/defaults":319,"./convert":322}],324:[function(t,e,r){"use strict";var n=t("../scatter/attributes"),i=t("../../components/colorscale/attributes"),a=t("../../lib/extend").extendFlat;e.exports=a({},{z:{valType:"data_array"},x:n.x,x0:n.x0,dx:n.dx,y:n.y,y0:n.y0,dy:n.dy,text:{valType:"data_array"},transpose:{valType:"boolean",dflt:!1},xtype:{valType:"enumerated",values:["array","scaled"]},ytype:{valType:"enumerated",values:["array","scaled"]},zsmooth:{valType:"enumerated",values:["fast","best",!1],dflt:!1},connectgaps:{valType:"boolean",dflt:!1},_nestedModules:{colorbar:"Colorbar"}},i,{autocolorscale:a({},i.autocolorscale,{dflt:!1})})},{"../../components/colorscale/attributes":182,"../../lib/extend":253,"../scatter/attributes":341}],325:[function(t,e,r){"use strict";function n(t){function e(t){return u(t)?+t:void 0}var r,n,i,a,o,s,l=t.z;if(t.transpose){for(r=0,o=0;oo;o++)for(n=i(l,o),c[o]=new Array(n),s=0;n>s;s++)c[o][s]=e(a(l,o,s));return c}function i(t,e,r,n,i,a){var o,s,l,u=[],c=h.traceIs(t,"contour"),f=h.traceIs(t,"histogram"),d=h.traceIs(t,"gl2d"),p=Array.isArray(e)&&e.length>1;if(p&&!f&&"category"!==a.type){e=e.map(a.d2c);var g=e.length;if(!(i>=g))return c?e.slice(0,i):e.slice(0,i+1);if(c||d)u=e.slice(0,i);else if(1===i)u=[e[0]-.5,e[0]+.5];else{for(u=[1.5*e[0]-.5*e[1]],l=1;g>l;l++)u.push(.5*(e[l-1]+e[l]));u.push(1.5*e[g-1]-.5*e[g-2])}if(i>g){var v=u[u.length-1],m=v-u[u.length-2];for(l=g;i>l;l++)v+=m,u.push(v)}}else for(s=n||1,o=f||"category"===a.type?r||0:Array.isArray(e)&&1===e.length?e[0]:void 0===r?0:a.d2c(r),l=c||d?0:-.5;i>l;l++)u.push(o+s*l);return u}function a(t){return.5-.25*Math.min(1,.5*t)}function o(t,e,r){var n,i,o=1;if(Array.isArray(r))for(n=0;nn&&o>y;n++)o=l(t,e,a(o));return o>y&&c.log("interp2d didn't converge quickly",o),t}function s(t){var e,r,n,i,a,o,s,l,u=[],c={},f=[],h=t[0],d=[],p=[0,0,0],g=m(t);for(r=0;rn;n++)void 0===d[n]&&(o=(void 0!==d[n-1]?1:0)+(void 0!==d[n+1]?1:0)+(void 0!==e[n]?1:0)+(void 0!==h[n]?1:0),o?(0===r&&o++,0===n&&o++,r===t.length-1&&o++,n===d.length-1&&o++,4>o&&(c[[r,n]]=[r,n,o]),u.push([r,n,o])):f.push([r,n]));for(;f.length;){for(s={},l=!1,a=f.length-1;a>=0;a--)i=f[a],r=i[0],n=i[1],o=((c[[r-1,n]]||p)[2]+(c[[r+1,n]]||p)[2]+(c[[r,n-1]]||p)[2]+(c[[r,n+1]]||p)[2])/20,o&&(s[i]=[r,n,o],f.splice(a,1),l=!0);if(!l)throw"findEmpties iterated with no new neighbors";for(i in s)c[i]=s[i],u.push(s[i])}return u.sort(function(t,e){return e[2]-t[2]})}function l(t,e,r){var n,i,a,o,s,l,u,c,f,h,d,p,g,v=0;for(o=0;os;s++)l=b[s],u=t[i+l[0]],u&&(c=u[a+l[1]],void 0!==c&&(0===h?p=g=c:(p=Math.min(p,c),g=Math.max(g,c)),f++,h+=c));if(0===f)throw"iterateInterp2d order is wrong: no defined neighbors";t[i][a]=h/f,void 0===d?4>f&&(v=1):(t[i][a]=(1+r)*t[i][a]-r*d,g>p&&(v=Math.max(v,Math.abs(t[i][a]-d)/(g-p))))}return v}var u=t("fast-isnumeric"),c=t("../../lib"),f=t("../../plots/cartesian/axes"),h=t("../../plots/plots"),d=t("../histogram2d/calc"),p=t("../../components/colorscale/calc"),g=t("./has_columns"),v=t("./convert_column_xyz"),m=t("./max_row_length");e.exports=function(t,e){function r(t){T=e._input.zsmooth=e.zsmooth=!1,c.notifier("cannot fast-zsmooth: "+t)}var a,l,u,y,b,x,_,w,A=f.getFromId(t,e.xaxis||"x"),k=f.getFromId(t,e.yaxis||"y"),M=h.traceIs(e,"contour"),E=h.traceIs(e,"histogram"),T=M?"best":e.zsmooth;if(A._minDtick=0,k._minDtick=0,E){var L=d(t,e);a=L.x,l=L.x0,u=L.dx,y=L.y,b=L.y0,x=L.dy,_=L.z}else g(e)&&v(e,A,k),a=e.x?A.makeCalcdata(e,"x"):[],y=e.y?k.makeCalcdata(e,"y"):[],l=e.x0||0,u=e.dx||1,b=e.y0||0,x=e.dy||1,_=n(e),(M||e.connectgaps)&&(e._emptypoints=s(_),e._interpz=o(_,e._emptypoints,e._interpz));if("fast"===T)if("log"===A.type||"log"===k.type)r("log axis found");else if(!E){if(a.length){var S=(a[a.length-1]-a[0])/(a.length-1),C=Math.abs(S/100);for(w=0;wC){r("x scale is not linear");break}}if(y.length&&"fast"===T){var R=(y[y.length-1]-y[0])/(y.length-1),I=Math.abs(R/100);for(w=0;wI){r("y scale is not linear");break}}}var P=m(_),O="scaled"===e.xtype?"":e.x,N=i(e,O,l,u,P,A),z="scaled"===e.ytype?"":e.y,D=i(e,z,b,x,_.length,k);f.expand(A,N),f.expand(k,D);var F={x:N,y:D,z:_};if(p(e,_,"","z"),M&&e.contours&&"heatmap"===e.contours.coloring){var B="contour"===e.type?"heatmap":"histogram2d";F.xfill=i(B,O,l,u,P,A),F.yfill=i(B,z,b,x,_.length,k)}return[F]};var y=.01,b=[[-1,0],[1,0],[0,-1],[0,1]]},{"../../components/colorscale/calc":183,"../../lib":256,"../../plots/cartesian/axes":279,"../../plots/plots":303,"../histogram2d/calc":338,"./convert_column_xyz":327,"./has_columns":329,"./max_row_length":330,"fast-isnumeric":65}],326:[function(t,e,r){"use strict";var n=t("d3"),i=t("fast-isnumeric"),a=t("../../lib"),o=t("../../plots/plots"),s=t("../../components/colorscale/get_scale"),l=t("../../components/colorbar/draw");e.exports=function(t,e){var r=e[0].trace,u="cb"+r.uid,c=s(r.colorscale),f=r.zmin,h=r.zmax;if(i(f)||(f=a.aggNums(Math.min,null,r.z)),i(h)||(h=a.aggNums(Math.max,null,r.z)),t._fullLayout._infolayer.selectAll("."+u).remove(),!r.showscale)return void o.autoMargin(t,u);var d=e[0].t.cb=l(t,u);d.fillcolor(n.scale.linear().domain(c.map(function(t){return f+t[0]*(h-f)})).range(c.map(function(t){return t[1]}))).filllevels({start:f,end:h,size:(h-f)/254}).options(r.colorbar)()}},{"../../components/colorbar/draw":179,"../../components/colorscale/get_scale":188,"../../lib":256,"../../plots/plots":303,d3:62,"fast-isnumeric":65}],327:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t,e,r){var i,a=t.x.slice(),o=t.y.slice(),s=t.z,l=t.text,u=Math.min(a.length,o.length,s.length),c=void 0!==l&&!Array.isArray(l[0]);for(ui;i++)a[i]=e.d2c(a[i]),o[i]=r.d2c(o[i]);var f,h,d,p=n.distinctVals(a),g=p.vals,v=n.distinctVals(o),m=v.vals,y=n.init2dArray(m.length,g.length);for(c&&(d=n.init2dArray(m.length,g.length)),i=0;u>i;i++)f=n.findBin(a[i]+p.minDiff/2,g),h=n.findBin(o[i]+v.minDiff/2,m),y[h][f]=s[i],c&&(d[h][f]=l[i]);t.x=g,t.y=m,t.z=y,c&&(t.text=d)}},{"../../lib":256}],328:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./has_columns"),a=t("./xyz_defaults"),o=t("../../components/colorscale/defaults"),s=t("./attributes");e.exports=function(t,e,r,l){function u(r,i){return n.coerce(t,e,s,r,i)}var c=a(t,e,u);return c?(u("text"),u("zsmooth"),u("connectgaps",i(e)&&e.zsmooth!==!1),void o(t,e,l,u,{prefix:"",cLetter:"z"})):void(e.visible=!1)}},{"../../components/colorscale/defaults":186,"../../lib":256,"./attributes":324,"./has_columns":329,"./xyz_defaults":331}],329:[function(t,e,r){"use strict";e.exports=function(t){return!Array.isArray(t.z[0])}},{}],330:[function(t,e,r){"use strict";e.exports=function(t){for(var e=0,r=0;r0&&(n=!0);for(var s=0;sl;l++){var u=e[l],c=s(u[1]);a[l]=r+u[0]*(n-r);for(var f=0;4>f;f++)o[4*l+f]=c[f]}return{colorLevels:a,colorValues:o}}function a(t,e,r){var i=new n(t,e.uid);return i.update(e,r),i}var o=t("gl-heatmap2d"),s=t("../../lib/str2rgbarray"),l=n.prototype;l.handlePick=function(t){var e=t.pointId,r=this.options.shape;return{trace:this,dataCoord:t.dataCoord,traceCoord:[this.options.x[e%r[0]],this.options.y[Math.floor(e/r[0])],this.options.z[e]],textLabel:this.textLabels[e],name:this.name,hoverinfo:this.hoverinfo}},l.update=function(t,e){var r=e[0];this.name=t.name,this.hoverinfo=t.hoverinfo;var n=r.z;this.options.z=[].concat.apply([],n);var a=n[0].length,o=n.length;this.options.shape=[a,o],this.options.x=r.x,this.options.y=r.y;var s=i(t);this.options.colorLevels=s.colorLevels,this.options.colorValues=s.colorValues,this.textLabels=[].concat.apply([],t.text),this.heatmap.update(this.options)},l.dispose=function(){this.heatmap.dispose()},e.exports=a},{"../../lib/str2rgbarray":268,"gl-heatmap2d":73}],334:[function(t,e,r){"use strict";var n={};n.attributes=t("./attributes"),n.supplyDefaults=t("../heatmap/defaults"),n.colorbar=t("../heatmap/colorbar"),n.calc=t("../heatmap/calc"),n.plot=t("./convert"),n.moduleType="trace",n.name="heatmapgl",n.basePlotModule=t("../../plots/gl2d"),n.categories=["gl2d","2dMap"],n.meta={},e.exports=n},{"../../plots/gl2d":300,"../heatmap/calc":325,"../heatmap/colorbar":326,"../heatmap/defaults":328,"./attributes":332,"./convert":333}],335:[function(t,e,r){"use strict";e.exports=function(t,e){for(var r=t.length,n=0,i=0;r>i;i++)e[i]?(t[i]/=e[i],n+=t[i]):t[i]=null;return n}},{}],336:[function(t,e,r){"use strict";var n=t("fast-isnumeric");e.exports={count:function(t,e,r){return r[t]++,1},sum:function(t,e,r,i){var a=i[e];return n(a)?(a=Number(a),r[t]+=a,a):0},avg:function(t,e,r,i,a){var o=i[e];return n(o)&&(o=Number(o),r[t]+=o,a[t]++),0},min:function(t,e,r,i){var a=i[e];if(n(a)){if(a=Number(a),!n(r[t]))return r[t]=a,a;if(r[t]>a)return r[t]=a,a-r[t]}return 0},max:function(t,e,r,i){var a=i[e];if(n(a)){if(a=Number(a),!n(r[t]))return r[t]=a,a;if(r[t]i;i++)t[i]*=n},probability:function(t,e){for(var r=t.length,n=0;r>n;n++)t[n]/=e},density:function(t,e,r,n){var i=t.length;n=n||1;for(var a=0;i>a;a++)t[a]*=r[a]*n},"probability density":function(t,e,r,n){var i=t.length;n&&(e/=n);for(var a=0;i>a;a++)t[a]*=r[a]/e}}},{}],338:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../plots/cartesian/axes"),a=t("../histogram/bin_functions"),o=t("../histogram/norm_functions"),s=t("../histogram/average");e.exports=function(t,e){var r,l,u,c,f,h,d=i.getFromId(t,e.xaxis||"x"),p=e.x?d.makeCalcdata(e,"x"):[],g=i.getFromId(t,e.yaxis||"y"),v=e.y?g.makeCalcdata(e,"y"):[],m=Math.min(p.length,v.length);p.length>m&&p.splice(m,p.length-m),v.length>m&&v.splice(m,v.length-m),!e.autobinx&&"xbins"in e||(e.xbins=i.autoBin(p,d,e.nbinsx,"2d"),"histogram2dcontour"===e.type&&(e.xbins.start-=e.xbins.size,e.xbins.end+=e.xbins.size),e._input.xbins=e.xbins),!e.autobiny&&"ybins"in e||(e.ybins=i.autoBin(v,g,e.nbinsy,"2d"),"histogram2dcontour"===e.type&&(e.ybins.start-=e.ybins.size,e.ybins.end+=e.ybins.size),e._input.ybins=e.ybins),f=[];var y,b,x=[],_=[],w="string"==typeof e.xbins.size?[]:e.xbins,A="string"==typeof e.xbins.size?[]:e.ybins,k=0,M=[],E=e.histnorm,T=e.histfunc,L=-1!==E.indexOf("density"),S="max"===T||"min"===T,C=S?null:0,R=a.count,I=o[E],P=!1,O=[],N=[],z="z"in e?e.z:"marker"in e&&Array.isArray(e.marker.color)?e.marker.color:"";z&&"count"!==T&&(P="avg"===T,R=a[T]);var D=e.xbins,F=D.end+(D.start-i.tickIncrement(D.start,D.size))/1e6;for(h=D.start;F>h;h=i.tickIncrement(h,D.size))x.push(C),Array.isArray(w)&&w.push(h),P&&_.push(0);Array.isArray(w)&&w.push(h);var B=x.length;for(r=e.xbins.start,l=(h-r)/B,r+=l/2,D=e.ybins,F=D.end+(D.start-i.tickIncrement(D.start,D.size))/1e6,h=D.start;F>h;h=i.tickIncrement(h,D.size))f.push(x.concat()),Array.isArray(A)&&A.push(h),P&&M.push(_.concat());Array.isArray(A)&&A.push(h);var j=f.length;for(u=e.ybins.start,c=(h-u)/j,u+=c/2,L&&(O=x.map(function(t,e){return Array.isArray(w)?1/(w[e+1]-w[e]):1/l}),N=f.map(function(t,e){return Array.isArray(A)?1/(A[e+1]-A[e]):1/c})),h=0;m>h;h++)y=n.findBin(p[h],w),b=n.findBin(v[h],A),y>=0&&B>y&&b>=0&&j>b&&(k+=R(y,h,f[b],z,M[b]));if(P)for(b=0;j>b;b++)k+=s(f[b],M[b]);if(I)for(b=0;j>b;b++)I(f[b],k,O,N[b]);return{x:p,x0:r,dx:l,y:v,y0:u,dy:c,z:f}}},{"../../lib":256,"../../plots/cartesian/axes":279,"../histogram/average":335,"../histogram/bin_functions":336,"../histogram/norm_functions":337}],339:[function(t,e,r){"use strict";var n=t("../../components/color");e.exports=function(t,e,r){var i=r.marker.line.color;Array.isArray(i)&&(i=i[e.i]||n.defaultLine);var a=r.marker.line.width||0;Array.isArray(a)&&(a=a[e.i]||0),t.style({"stroke-width":a,fill:e.color}).call(n.stroke,i)}},{"../../components/color":176}],340:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t){var e=t[0].trace,r=e.marker;if(n.mergeArray(e.text,t,"tx"),n.mergeArray(e.textposition,t,"tp"),e.textfont&&(n.mergeArray(e.textfont.size,t,"ts"),n.mergeArray(e.textfont.color,t,"tc"),n.mergeArray(e.textfont.family,t,"tf")),r&&r.line){var i=r.line;n.mergeArray(r.opacity,t,"mo"),n.mergeArray(r.symbol,t,"mx"),n.mergeArray(r.color,t,"mc"),n.mergeArray(i.color,t,"mlc"),n.mergeArray(i.width,t,"mlw")}}},{"../../lib":256}],341:[function(t,e,r){"use strict";var n=t("../../components/colorscale/color_attributes"),i=t("../../components/drawing"),a=(t("./constants"),t("../../lib/extend").extendFlat);e.exports={x:{valType:"data_array"},x0:{valType:"any",dflt:0},dx:{valType:"number",dflt:1},y:{valType:"data_array"},y0:{valType:"any",dflt:0},dy:{valType:"number",dflt:1},text:{valType:"string",dflt:"",arrayOk:!0},mode:{valType:"flaglist",flags:["lines","markers","text"],extras:["none"]},hoveron:{valType:"flaglist",flags:["points","fills"]},line:{color:{valType:"color"},width:{valType:"number",min:0,dflt:2},shape:{valType:"enumerated",values:["linear","spline","hv","vh","hvh","vhv"],dflt:"linear"},smoothing:{valType:"number",min:0,max:1.3,dflt:1},dash:{valType:"string",values:["solid","dot","dash","longdash","dashdot","longdashdot"],dflt:"solid"}},connectgaps:{valType:"boolean",dflt:!1},fill:{valType:"enumerated",values:["none","tozeroy","tozerox","tonexty","tonextx","toself","tonext"],dflt:"none"},fillcolor:{valType:"color"},marker:a({},{symbol:{valType:"enumerated",values:i.symbolList,dflt:"circle",arrayOk:!0},opacity:{valType:"number",min:0,max:1,arrayOk:!0},size:{valType:"number",min:0,dflt:6,arrayOk:!0},maxdisplayed:{valType:"number",min:0,dflt:0},sizeref:{valType:"number",dflt:1},sizemin:{valType:"number",min:0,dflt:0},sizemode:{valType:"enumerated",values:["diameter","area"],dflt:"diameter"},showscale:{valType:"boolean",dflt:!1},line:a({},{width:{valType:"number",min:0,arrayOk:!0}},n("marker.line"))},n("marker")),textposition:{valType:"enumerated",values:["top left","top center","top right","middle left","middle center","middle right","bottom left","bottom center","bottom right"],dflt:"middle center",arrayOk:!0},textfont:{family:{valType:"string",noBlank:!0,strict:!0,arrayOk:!0},size:{valType:"number",min:1,arrayOk:!0},color:{valType:"color",arrayOk:!0}},r:{valType:"data_array"},t:{valType:"data_array"},_nestedModules:{error_y:"ErrorBars",error_x:"ErrorBars","marker.colorbar":"Colorbar"}}},{"../../components/colorscale/color_attributes":184,"../../components/drawing":199,"../../lib/extend":253,"./constants":346}],342:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../plots/cartesian/axes"),a=t("../../lib"),o=t("./subtypes"),s=t("./colorscale_calc");e.exports=function(t,e){var r,l,u,c=i.getFromId(t,e.xaxis||"x"),f=i.getFromId(t,e.yaxis||"y"),h=c.makeCalcdata(e,"x"),d=f.makeCalcdata(e,"y"),p=Math.min(h.length,d.length);c._minDtick=0,f._minDtick=0,h.length>p&&h.splice(p,h.length-p),d.length>p&&d.splice(p,d.length-p);var g={padded:!0},v={padded:!0};if(o.hasMarkers(e)){if(r=e.marker,l=r.size,Array.isArray(l)){var m={type:"linear"};i.setConvert(m),l=m.makeCalcdata(e.marker,"size"),l.length>p&&l.splice(p,l.length-p)}var y,b=1.6*(e.marker.sizeref||1);y="area"===e.marker.sizemode?function(t){return Math.max(Math.sqrt((t||0)/b),3)}:function(t){return Math.max((t||0)/b,3)},g.ppad=v.ppad=Array.isArray(l)?l.map(y):y(l)}s(e),!("tozerox"===e.fill||"tonextx"===e.fill&&t.firstscatter)||h[0]===h[p-1]&&d[0]===d[p-1]?e.error_y.visible||-1===["tonexty","tozeroy"].indexOf(e.fill)&&(o.hasMarkers(e)||o.hasText(e))||(g.padded=!1,g.ppad=0):g.tozero=!0,!("tozeroy"===e.fill||"tonexty"===e.fill&&t.firstscatter)||h[0]===h[p-1]&&d[0]===d[p-1]?-1!==["tonextx","tozerox"].indexOf(e.fill)&&(v.padded=!1):v.tozero=!0,i.expand(c,h,g),i.expand(f,d,v);var x=new Array(p);for(u=0;p>u;u++)x[u]=n(h[u])&&n(d[u])?{x:h[u],y:d[u]}:{x:!1,y:!1};return void 0!==typeof l&&a.mergeArray(l,x,"ms"),t.firstscatter=!1,x}},{"../../lib":256,"../../plots/cartesian/axes":279,"./colorscale_calc":345,"./subtypes":360,"fast-isnumeric":65}],343:[function(t,e,r){"use strict";e.exports=function(t){var e,r,n,i,a;for(e=0;e=0;i--)if(a=t[i],"scatter"===a.type&&a.xaxis===r.xaxis&&a.yaxis===r.yaxis){a.opacity=void 0;break}}},{}],344:[function(t,e,r){"use strict";var n=t("d3"),i=t("fast-isnumeric"),a=t("../../lib"),o=t("../../plots/plots"),s=t("../../components/colorscale/get_scale"),l=t("../../components/colorbar/draw");e.exports=function(t,e){var r=e[0].trace,u=r.marker,c="cb"+r.uid;if(t._fullLayout._infolayer.selectAll("."+c).remove(),void 0===u||!u.showscale)return void o.autoMargin(t,c);var f=s(u.colorscale),h=u.color,d=u.cmin,p=u.cmax;i(d)||(d=a.aggNums(Math.min,null,h)),i(p)||(p=a.aggNums(Math.max,null,h));var g=e[0].t.cb=l(t,c);g.fillcolor(n.scale.linear().domain(f.map(function(t){return d+t[0]*(p-d)})).range(f.map(function(t){return t[1]}))).filllevels({start:d,end:p,size:(p-d)/254}).options(u.colorbar)()}},{"../../components/colorbar/draw":179,"../../components/colorscale/get_scale":188,"../../lib":256,"../../plots/plots":303,d3:62,"fast-isnumeric":65}],345:[function(t,e,r){"use strict";var n=t("../../components/colorscale/has_colorscale"),i=t("../../components/colorscale/calc"),a=t("./subtypes");e.exports=function(t){a.hasLines(t)&&n(t,"line")&&i(t,t.line.color,"line","c"),a.hasMarkers(t)&&(n(t,"marker")&&i(t,t.marker.color,"marker","c"),n(t,"marker.line")&&i(t,t.marker.line.color,"marker.line","c"))}},{"../../components/colorscale/calc":183,"../../components/colorscale/has_colorscale":189,"./subtypes":360}],346:[function(t,e,r){"use strict";e.exports={PTS_LINESONLY:20}},{}],347:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes"),a=t("./constants"),o=t("./subtypes"),s=t("./xy_defaults"),l=t("./marker_defaults"),u=t("./line_defaults"),c=t("./line_shape_defaults"),f=t("./text_defaults"),h=t("./fillcolor_defaults"),d=t("../../components/errorbars/defaults");e.exports=function(t,e,r,p){function g(r,a){return n.coerce(t,e,i,r,a)}var v=s(t,e,g),m=vU!=P>=U&&(C=L[E-1][0],R=L[E][0],S=C+(R-C)*(U-I)/(P-I),D=Math.min(D,S),F=Math.max(F,S));D=Math.max(D,0),F=Math.min(F,h._length);var V=l.defaultLine;return l.opacity(f.fillcolor)?V=f.fillcolor:l.opacity((f.line||{}).color)&&(V=f.line.color),n.extendFlat(t,{distance:a.MAXDIST+10,x0:D,x1:F,y0:U,y1:U,color:V}),delete t.index,f.text&&!Array.isArray(f.text)?t.text=String(f.text):t.text=f.name,[t]}}}},{"../../components/color":176,"../../components/errorbars":205,"../../lib":256,"../../plots/cartesian/constants":284,"../../plots/cartesian/graph_interact":286,"./get_trace_color":349}],351:[function(t,e,r){"use strict";var n={},i=t("./subtypes");n.hasLines=i.hasLines,n.hasMarkers=i.hasMarkers,n.hasText=i.hasText,n.isBubble=i.isBubble,n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.cleanData=t("./clean_data"),n.calc=t("./calc"),n.arraysToCalcdata=t("./arrays_to_calcdata"),n.plot=t("./plot"),n.colorbar=t("./colorbar"),n.style=t("./style"),n.hoverPoints=t("./hover"),n.selectPoints=t("./select"),n.moduleType="trace",n.name="scatter",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","symbols","markerColorscale","errorBarsOK","showLegend"],n.meta={},e.exports=n},{"../../plots/cartesian":287,"./arrays_to_calcdata":340,"./attributes":341,"./calc":342,"./clean_data":343,"./colorbar":344,"./defaults":347,"./hover":350,"./plot":357,"./select":358,"./style":359,"./subtypes":360}],352:[function(t,e,r){"use strict";var n=t("../../components/colorscale/has_colorscale"),i=t("../../components/colorscale/defaults");e.exports=function(t,e,r,a,o){var s=(t.marker||{}).color;if(o("line.color",r),n(t,"line"))i(t,e,a,o,{prefix:"line.",cLetter:"c"});else{var l=(Array.isArray(s)?!1:s)||r;o("line.color",l)}o("line.width"),o("line.dash")}},{"../../components/colorscale/defaults":186,"../../components/colorscale/has_colorscale":189}],353:[function(t,e,r){"use strict";var n=t("../../plots/cartesian/axes");e.exports=function(t,e){function r(e){var r=w.c2p(t[e].x),n=A.c2p(t[e].y);return r===L||n===L?!1:[r,n]}function i(t){var e=t[0]/w._length,r=t[1]/A._length;return(1+10*Math.max(0,-e,e-1,-r,r-1))*M}function a(t,e){var r=t[0]-e[0],n=t[1]-e[1];return Math.sqrt(r*r+n*n)}var o,s,l,u,c,f,h,d,p,g,v,m,y,b,x,_,w=e.xaxis,A=e.yaxis,k=e.connectGaps,M=e.baseTolerance,E=e.linear,T=[],L=n.BADNUM,S=.2,C=new Array(t.length),R=0;for(o=0;oi(f))break;l=f,y=g[0]*p[0]+g[1]*p[1],y>v?(v=y,u=f,d=!1):m>y&&(m=y,c=f,d=!0)}if(d?(C[R++]=u,l!==c&&(C[R++]=c)):(c!==s&&(C[R++]=c),l!==u&&(C[R++]=u)),C[R++]=l,o>=t.length||!f)break;C[R++]=f,s=f}}else C[R++]=u}T.push(C.slice(0,R))}return T}},{"../../plots/cartesian/axes":279}],354:[function(t,e,r){"use strict";e.exports=function(t,e,r){var n=r("line.shape");"spline"===n&&r("line.smoothing")}},{}],355:[function(t,e,r){"use strict";var n=t("fast-isnumeric");e.exports=function(t){var e=t.marker,r=e.sizeref||1,i=e.sizemin||0,a="area"===e.sizemode?function(t){return Math.sqrt(t/r)}:function(t){return t/r};return function(t){var e=a(t/2);return n(e)&&e>0?Math.max(e,i):0}}},{"fast-isnumeric":65}],356:[function(t,e,r){"use strict";var n=t("../../components/color"),i=t("../../components/colorscale/has_colorscale"),a=t("../../components/colorscale/defaults"),o=t("./subtypes");e.exports=function(t,e,r,s,l){var u,c=o.isBubble(t),f=(t.line||{}).color;f&&(r=f),l("marker.symbol"),l("marker.opacity",c?.7:1),l("marker.size"),l("marker.color",r),i(t,"marker")&&a(t,e,s,l,{prefix:"marker.",cLetter:"c"}),u=f&&!Array.isArray(f)&&e.marker.color!==f?f:c?n.background:n.defaultLine,l("marker.line.color",u),i(t,"marker.line")&&a(t,e,s,l,{prefix:"marker.line.",cLetter:"c"}),l("marker.line.width",c?1:0),c&&(l("marker.sizeref"),l("marker.sizemin"),l("marker.sizemode"))}},{"../../components/color":176,"../../components/colorscale/defaults":186,"../../components/colorscale/has_colorscale":189,"./subtypes":360}],357:[function(t,e,r){"use strict";function n(t,e,r){var n=e.x(),a=e.y(),o=i.extent(n.range.map(n.l2c)),s=i.extent(a.range.map(a.l2c));r.forEach(function(t,e){var n=t[0].trace;if(u.hasMarkers(n)){var i=n.marker.maxdisplayed;if(0!==i){var a=t.filter(function(t){return t.x>=o[0]&&t.x<=o[1]&&t.y>=s[0]&&t.y<=s[1]}),l=Math.ceil(a.length/i),c=0;r.forEach(function(t,r){var n=t[0].trace;u.hasMarkers(n)&&n.marker.maxdisplayed>0&&e>r&&c++});var f=Math.round(c*l/3+Math.floor(c/3)*l/7.1);t.forEach(function(t){delete t.vis}),a.forEach(function(t,e){0===Math.round((e+f)%l)&&(t.vis=!0)})}}})}var i=t("d3"),a=t("../../lib"),o=t("../../components/drawing"),s=t("../../components/errorbars"),l=t("../../lib/polygon").tester,u=t("./subtypes"),c=t("./arrays_to_calcdata"),f=t("./line_points");e.exports=function(t,e,r){function h(t){return t.filter(function(t){return t.vis})}n(t,e,r);var d=e.x(),p=e.y(),g=e.plot.select(".scatterlayer").selectAll("g.trace.scatter").data(r);g.enter().append("g").attr("class","trace scatter").style("stroke-miterlimit",2),g.call(s.plot,e);var v,m,y,b,x="",_=[];g.each(function(t){var e=t[0].trace,r=e.line,n=i.select(this);if(e.visible===!0&&(m=e.fill.charAt(e.fill.length-1),"x"!==m&&"y"!==m&&(m=""),t[0].node3=n,c(t),u.hasLines(e)||"none"!==e.fill)){var a,s,h,g,w,A="",k="";v="tozero"===e.fill.substr(0,6)||"toself"===e.fill||"to"===e.fill.substr(0,2)&&!x?n.append("path").classed("js-fill",!0):null,b&&(y=b.datum(t)),b=n.append("path").classed("js-fill",!0),-1!==["hv","vh","hvh","vhv"].indexOf(r.shape)?(h=o.steps(r.shape),g=o.steps(r.shape.split("").reverse().join(""))):h=g="spline"===r.shape?function(t){var e=t[t.length-1];return t[0][0]===e[0]&&t[0][1]===e[1]?o.smoothclosed(t.slice(1),r.smoothing):o.smoothopen(t,r.smoothing)}:function(t){return"M"+t.join("L")},w=function(t){return g(t.reverse())};var M,E=f(t,{xaxis:d,yaxis:p,connectGaps:e.connectgaps,baseTolerance:Math.max(r.width||1,3)/4,linear:"linear"===r.shape}),T=e._polygons=new Array(E.length);for(M=0;M1&&n.append("path").classed("js-line",!0).style("vector-effect","non-scaling-stroke").attr("d",a)}v?L&&C&&(m?("y"===m?L[1]=C[1]=p.c2p(0,!0):"x"===m&&(L[0]=C[0]=d.c2p(0,!0)),v.attr("d",A+"L"+C+"L"+L+"Z")):v.attr("d",A+"Z")):"tonext"===e.fill.substr(0,6)&&A&&x&&("tonext"===e.fill?y.attr("d",A+"Z"+x+"Z"):y.attr("d",A+"L"+x.substr(1)+"Z"),e._polygons=e._polygons.concat(_)),x=k,_=T}}}),g.selectAll("path:not([d])").remove(),g.append("g").attr("class","points").each(function(t){var e=t[0].trace,r=i.select(this),n=u.hasMarkers(e),s=u.hasText(e);!n&&!s||e.visible!==!0?r.remove():(n&&r.selectAll("path.point").data(e.marker.maxdisplayed?h:a.identity).enter().append("path").classed("point",!0).call(o.translatePoints,d,p),s&&r.selectAll("g").data(e.marker.maxdisplayed?h:a.identity).enter().append("g").append("text").call(o.translatePoints,d,p))})}},{"../../components/drawing":199,"../../components/errorbars":205,"../../lib":256,"../../lib/polygon":262,"./arrays_to_calcdata":340,"./line_points":353,"./subtypes":360,d3:62}],358:[function(t,e,r){"use strict";var n=t("./subtypes"),i=.2;e.exports=function(t,e){var r,a,o,s,l=t.cd,u=t.xaxis,c=t.yaxis,f=[],h=l[0].trace,d=h.index,p=h.marker,g=!n.hasMarkers(h)&&!n.hasText(h);if(h.visible===!0&&!g){var v=Array.isArray(p.opacity)?1:p.opacity;if(e===!1)for(r=0;ra;++a)n[a]=t(a>=e.length?i:e[a]);return n}function o(t,e,r){return l(S(t,r),L(e,r),r)}function s(t,e,r,n){var i=x(t,e,n);return i=Array.isArray(i[0])?i:a(v.identity,[i],n),l(i,L(r,n),n)}function l(t,e,r){for(var n=new Array(4*r),i=0;r>i;++i){for(var a=0;3>a;++a)n[4*i+a]=t[i][a];n[4*i+3]=t[i][3]*e[i]}return n}function u(t,e){if(void 0===Float32Array.slice){for(var r=new Float32Array(e),n=0;e>n;n++)r[n]=t[n];return r}return t.slice(0,e)}function c(t,e){var r=new n(t,e.uid);return r.update(e),r}var f=t("gl-scatter2d"),h=t("gl-scatter2d-fancy"),d=t("gl-line2d"),p=t("gl-error2d"),g=t("fast-isnumeric"),v=t("../../lib"),m=t("../../plots/cartesian/axes"),y=t("../../components/errorbars"),b=t("../../lib/str2rgbarray"),x=t("../../lib/gl_format_color"),_=t("../scatter/subtypes"),w=t("../scatter/make_bubble_size_func"),A=t("../scatter/get_trace_color"),k=t("../../constants/gl_markers"),M=t("../../constants/gl2d_dashes"),E=["xaxis","yaxis"],T=n.prototype;T.handlePick=function(t){var e=t.pointId;return(t.object!==this.line||this.connectgaps)&&(e=this.idToIndex[t.pointId]),{trace:this,dataCoord:t.dataCoord,traceCoord:[this.pickXData[e],this.pickYData[e]],textLabel:Array.isArray(this.textLabels)?this.textLabels[e]:this.textLabels,color:Array.isArray(this.color)?this.color[e]:this.color,name:this.name,hoverinfo:this.hoverinfo}},T.isFancy=function(t){if("linear"!==this.scene.xaxis.type)return!0;if("linear"!==this.scene.yaxis.type)return!0;if(!t.x||!t.y)return!0;if(this.hasMarkers){var e=t.marker||{};if(Array.isArray(e.symbol)||"circle"!==e.symbol||Array.isArray(e.size)||Array.isArray(e.color)||Array.isArray(e.line.width)||Array.isArray(e.line.color)||Array.isArray(e.opacity))return!0}return this.hasLines&&!this.connectgaps?!0:this.hasErrorX?!0:!!this.hasErrorY};var L=i.bind(null,function(t){return+t}),S=i.bind(null,b),C=i.bind(null,function(t){return k[t]||"\u25cf"});T.update=function(t){t.visible!==!0?(this.hasLines=!1,this.hasErrorX=!1,this.hasErrorY=!1,this.hasMarkers=!1):(this.hasLines=_.hasLines(t),this.hasErrorX=t.error_x.visible===!0,this.hasErrorY=t.error_y.visible===!0,this.hasMarkers=_.hasMarkers(t)),this.textLabels=t.text,this.name=t.name,this.hoverinfo=t.hoverinfo,this.bounds=[1/0,1/0,-(1/0),-(1/0)],this.connectgaps=!!t.connectgaps,this.isFancy(t)?this.updateFancy(t):this.updateFast(t),this.color=A(t,{})},T.updateFast=function(t){for(var e,r,n=this.xData=this.pickXData=t.x,i=this.yData=this.pickYData=t.y,a=n.length,o=new Array(a),s=new Float32Array(2*a),l=this.bounds,c=0,f=0,h=0;a>h;++h)e=n[h],r=i[h],g(e)&&g(r)&&(o[c++]=h,s[f++]=e,s[f++]=r,l[0]=Math.min(l[0],e),l[1]=Math.min(l[1],r),l[2]=Math.max(l[2],e),l[3]=Math.max(l[3],r));s=u(s,f),this.idToIndex=o,this.updateLines(t,s),this.updateError("X",t),this.updateError("Y",t);var d;if(this.hasMarkers){this.scatterOptions.positions=s;var p=b(t.marker.color),v=b(t.marker.line.color),m=t.opacity*t.marker.opacity;p[3]*=m,this.scatterOptions.color=p,v[3]*=m,this.scatterOptions.borderColor=v,d=t.marker.size,this.scatterOptions.size=d,this.scatterOptions.borderSize=t.marker.line.width,this.scatter.update(this.scatterOptions)}else this.scatterOptions.positions=new Float32Array(0),this.scatterOptions.glyphs=[],this.scatter.update(this.scatterOptions);this.scatterOptions.positions=new Float32Array(0),this.scatterOptions.glyphs=[],this.fancyScatter.update(this.scatterOptions),this.expandAxesFast(l,d)},T.updateFancy=function(t){var e=this.scene,r=e.xaxis,n=e.yaxis,a=this.bounds,o=this.pickXData=r.makeCalcdata(t,"x").slice(),l=this.pickYData=n.makeCalcdata(t,"y").slice();this.xData=o.slice(),this.yData=l.slice();var c,f,h,d,p,g,v,m,b=y.calcFromTrace(t,e.fullLayout),x=o.length,_=new Array(x),A=new Float32Array(2*x),k=new Float32Array(4*x),M=new Float32Array(4*x),E=0,T=0,S=0,R=0,I="log"===r.type?function(t){return r.d2l(t)}:function(t){return t},P="log"===n.type?function(t){return n.d2l(t)}:function(t){return t};for(c=0;x>c;++c)this.xData[c]=h=I(o[c]),this.yData[c]=d=P(l[c]),isNaN(h)||isNaN(d)||(_[E++]=c,A[T++]=h,A[T++]=d,p=k[S++]=h-b[c].xs||0,g=k[S++]=b[c].xh-h||0,k[S++]=0,k[S++]=0,M[R++]=0,M[R++]=0,v=M[R++]=d-b[c].ys||0,m=M[R++]=b[c].yh-d||0,a[0]=Math.min(a[0],h-p),a[1]=Math.min(a[1],d-v),a[2]=Math.max(a[2],h+g),a[3]=Math.max(a[3],d+m));A=u(A,T),this.idToIndex=_,this.updateLines(t,A),this.updateError("X",t,A,k),this.updateError("Y",t,A,M);var O;if(this.hasMarkers){this.scatterOptions.positions=A,this.scatterOptions.sizes=new Array(E),this.scatterOptions.glyphs=new Array(E),this.scatterOptions.borderWidths=new Array(E),this.scatterOptions.colors=new Array(4*E),this.scatterOptions.borderColors=new Array(4*E);var N,z=w(t),D=t.marker,F=D.opacity,B=t.opacity,j=s(D,F,B,x),U=C(D.symbol,x),V=L(D.line.width,x),q=s(D.line,F,B,x);for(O=i(z,D.size,x),c=0;E>c;++c)for(N=_[c],this.scatterOptions.sizes[c]=4*O[N],this.scatterOptions.glyphs[c]=U[N],this.scatterOptions.borderWidths[c]=.5*V[N],f=0;4>f;++f)this.scatterOptions.colors[4*c+f]=j[4*N+f],this.scatterOptions.borderColors[4*c+f]=q[4*N+f];this.fancyScatter.update(this.scatterOptions)}else this.scatterOptions.positions=new Float32Array(0),this.scatterOptions.glyphs=[],this.fancyScatter.update(this.scatterOptions);this.scatterOptions.positions=new Float32Array(0),this.scatterOptions.glyphs=[],this.scatter.update(this.scatterOptions),this.expandAxesFancy(o,l,O)},T.updateLines=function(t,e){var r;if(this.hasLines){var n=e;if(!t.connectgaps){var i=0,a=this.xData,s=this.yData;for(n=new Float32Array(2*a.length),r=0;ro;o++)r=this.scene[E[o]],n=r._min,n||(n=[]),n.push({val:t[o],pad:a}),i=r._max,i||(i=[]),i.push({val:t[o+2],pad:a})},T.expandAxesFancy=function(t,e,r){var n=this.scene,i={padded:!0,ppad:r};m.expand(n.xaxis,t,i),m.expand(n.yaxis,e,i)},T.dispose=function(){this.line.dispose(),this.errorX.dispose(),this.errorY.dispose(),this.scatter.dispose(),this.fancyScatter.dispose()},e.exports=c},{"../../components/errorbars":205,"../../constants/gl2d_dashes":245,"../../constants/gl_markers":246,"../../lib":256,"../../lib/gl_format_color":254,"../../lib/str2rgbarray":268,"../../plots/cartesian/axes":279,"../scatter/get_trace_color":349,"../scatter/make_bubble_size_func":355,"../scatter/subtypes":360,"fast-isnumeric":65,"gl-error2d":70,"gl-line2d":77,"gl-scatter2d":92,"gl-scatter2d-fancy":87}],366:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../scatter/constants"),a=t("../scatter/subtypes"),o=t("../scatter/xy_defaults"),s=t("../scatter/marker_defaults"),l=t("../scatter/line_defaults"),u=t("../scatter/fillcolor_defaults"),c=t("../../components/errorbars/defaults"),f=t("./attributes");e.exports=function(t,e,r,h){function d(r,i){return n.coerce(t,e,f,r,i)}var p=o(t,e,d);return p?(d("text"),d("mode",p>16&255,r[1]=n>>8&255,r[2]=255&n):f.test(t)&&(n=t.match(h),r[0]=parseInt(n[1]),r[1]=parseInt(n[2]),r[2]=parseInt(n[3])),!e)for(var i=0;i<3;++i)r[i]=r[i]/255;return r}function u(t,e){var r,n;if("string"!=typeof t)return t;if(r=[],"#"===t[0]?(t=t.substr(1),3===t.length&&(t+=t),n=parseInt(t,16),r[0]=n>>16&255,r[1]=n>>8&255,r[2]=255&n):f.test(t)&&(n=t.match(h),r[0]=parseInt(n[1]),r[1]=parseInt(n[2]),r[2]=parseInt(n[3]),n[4]?r[3]=parseFloat(n[4]):r[3]=1),!e)for(var i=0;i<3;++i)r[i]=r[i]/255;return r}var c={},f=/^rgba?\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*(,.*)?\)$/,h=/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,?\s*(.*)?\)$/;return c.isPlainObject=t,c.linspace=e,c.zip3=n,c.sum=i,c.zip=r,c.isEqual=s,c.copy2D=a,c.copy1D=o,c.str2RgbArray=l,c.str2RgbaArray=u,c};e.exports=n()},{}],10:[function(t,e,r){e.exports=function(t){return atob(t)}},{}],11:[function(t,e,r){"use strict";function n(t,e){return i(t[0].mul(e[1]).add(e[0].mul(t[1])),t[1].mul(e[1]))}var i=t("./lib/rationalize");e.exports=n},{"./lib/rationalize":21}],12:[function(t,e,r){"use strict";function n(t,e){return t[0].mul(e[1]).cmp(e[0].mul(t[1]))}e.exports=n},{}],13:[function(t,e,r){"use strict";function n(t,e){return i(t[0].mul(e[1]),t[1].mul(e[0]))}var i=t("./lib/rationalize");e.exports=n},{"./lib/rationalize":21}],14:[function(t,e,r){"use strict";function n(t,e){if(i(t))return e?u(t,n(e)):[t[0].clone(),t[1].clone()];var r,c,f=0;if(a(t))r=t.clone();else if("string"==typeof t)r=s(t);else{if(0===t)return[o(0),o(1)];if(t===Math.floor(t))r=o(t);else{for(;t!==Math.floor(t);)t*=Math.pow(2,256),f-=256;r=o(t)}}if(i(e))r.mul(e[1]),c=e[0].clone();else if(a(e))c=e.clone();else if("string"==typeof e)c=s(e);else if(e)if(e===Math.floor(e))c=o(e);else{for(;e!==Math.floor(e);)e*=Math.pow(2,256),f+=256;c=o(e)}else c=o(1);return f>0?r=r.shln(f):f<0&&(c=c.shln(-f)),l(r,c)}var i=t("./is-rat"),a=t("./lib/is-bn"),o=t("./lib/num-to-bn"),s=t("./lib/str-to-bn"),l=t("./lib/rationalize"),u=t("./div");e.exports=n},{"./div":13,"./is-rat":15,"./lib/is-bn":19,"./lib/num-to-bn":20,"./lib/rationalize":21,"./lib/str-to-bn":22}],15:[function(t,e,r){"use strict";function n(t){return Array.isArray(t)&&2===t.length&&i(t[0])&&i(t[1])}var i=t("./lib/is-bn");e.exports=n},{"./lib/is-bn":19}],16:[function(t,e,r){"use strict";function n(t){return t.cmp(new i(0))}var i=t("bn.js");e.exports=n},{"bn.js":29}],17:[function(t,e,r){"use strict";function n(t){var e=t.length,r=t.words,n=0;if(1===e)n=r[0];else if(2===e)n=r[0]+67108864*r[1];else for(var n=0,i=0;i20?52:r+32}var i=t("double-bits"),a=t("bit-twiddle").countTrailingZeros;e.exports=n},{"bit-twiddle":28,"double-bits":55}],19:[function(t,e,r){"use strict";function n(t){return t&&"object"==typeof t&&Boolean(t.words)}t("bn.js");e.exports=n},{"bn.js":29}],20:[function(t,e,r){"use strict";function n(t){var e=a.exponent(t);return e<52?new i(t):new i(t*Math.pow(2,52-e)).shln(e-52)}var i=t("bn.js"),a=t("double-bits");e.exports=n},{"bn.js":29,"double-bits":55}],21:[function(t,e,r){"use strict";function n(t,e){var r=a(t),n=a(e);if(0===r)return[i(0),i(1)];if(0===n)return[i(0),i(0)];n<0&&(t=t.neg(),e=e.neg());var o=t.gcd(e);return o.cmpn(1)?[t.div(o),e.div(o)]:[t,e]}var i=t("./num-to-bn"),a=t("./bn-sign");e.exports=n},{"./bn-sign":16,"./num-to-bn":20}],22:[function(t,e,r){"use strict";function n(t){return new i(t)}var i=t("bn.js");e.exports=n},{"bn.js":29}],23:[function(t,e,r){"use strict";function n(t,e){return i(t[0].mul(e[0]),t[1].mul(e[1]))}var i=t("./lib/rationalize");e.exports=n},{"./lib/rationalize":21}],24:[function(t,e,r){"use strict";function n(t){return i(t[0])*i(t[1])}var i=t("./lib/bn-sign");e.exports=n},{"./lib/bn-sign":16}],25:[function(t,e,r){"use strict";function n(t,e){return i(t[0].mul(e[1]).sub(t[1].mul(e[0])),t[1].mul(e[1]))}var i=t("./lib/rationalize");e.exports=n},{"./lib/rationalize":21}],26:[function(t,e,r){"use strict";function n(t){var e=t[0],r=t[1];if(0===e.cmpn(0))return 0;var n=e.divmod(r),o=n.div,s=i(o),l=n.mod;if(0===l.cmpn(0))return s;if(s){var u=a(s)+4,c=i(l.shln(u).divRound(r));return s<0&&(c=-c),s+c*Math.pow(2,-u)}var f=r.bitLength()-l.bitLength()+53,c=i(l.shln(f).divRound(r));return f<1023?c*Math.pow(2,-f):(c*=Math.pow(2,-1023),c*Math.pow(2,1023-f))}var i=t("./lib/bn-to-num"),a=t("./lib/ctz");e.exports=n},{"./lib/bn-to-num":17,"./lib/ctz":18}],27:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){var o=["function ",t,"(a,l,h,",n.join(","),"){",a?"":"var i=",r?"l-1":"h+1",";while(l<=h){var m=(l+h)>>>1,x=a",i?".get(m)":"[m]"];return a?e.indexOf("c")<0?o.push(";if(x===y){return m}else if(x<=y){"):o.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){"):o.push(";if(",e,"){i=m;"),r?o.push("l=m+1}else{h=m-1}"):o.push("h=m-1}else{l=m+1}"),o.push("}"),a?o.push("return -1};"):o.push("return i};"),o.join("")}function i(t,e,r,i){var a=new Function([n("A","x"+t+"y",e,["y"],!1,i),n("B","x"+t+"y",e,["y"],!0,i),n("P","c(x,y)"+t+"0",e,["y","c"],!1,i),n("Q","c(x,y)"+t+"0",e,["y","c"],!0,i),"function dispatchBsearch",r,"(a,y,c,l,h){if(a.shape){if(typeof(c)==='function'){return Q(a,(l===undefined)?0:l|0,(h===undefined)?a.shape[0]-1:h|0,y,c)}else{return B(a,(c===undefined)?0:c|0,(l===undefined)?a.shape[0]-1:l|0,y)}}else{if(typeof(c)==='function'){return P(a,(l===undefined)?0:l|0,(h===undefined)?a.length-1:h|0,y,c)}else{return A(a,(c===undefined)?0:c|0,(l===undefined)?a.length-1:l|0,y)}}}return dispatchBsearch",r].join(""));return a()}e.exports={ge:i(">=",!1,"GE"),gt:i(">",!1,"GT"),lt:i("<",!0,"LT"),le:i("<=",!0,"LE"),eq:i("-",!0,"EQ",!0)}},{}],28:[function(t,e,r){"use strict";"use restrict";function n(t){var e=32;return t&=-t,t&&e--,65535&t&&(e-=16),16711935&t&&(e-=8),252645135&t&&(e-=4),858993459&t&&(e-=2),1431655765&t&&(e-=1),e}var i=32;r.INT_BITS=i,r.INT_MAX=2147483647,r.INT_MIN=-1<0)-(t<0)},r.abs=function(t){var e=t>>i-1;return(t^e)-e},r.min=function(t,e){return e^(t^e)&-(t65535)<<4,t>>>=e,r=(t>255)<<3,t>>>=r,e|=r,r=(t>15)<<2,t>>>=r,e|=r,r=(t>3)<<1,t>>>=r,e|=r,e|t>>1},r.log10=function(t){return t>=1e9?9:t>=1e8?8:t>=1e7?7:t>=1e6?6:t>=1e5?5:t>=1e4?4:t>=1e3?3:t>=100?2:t>=10?1:0},r.popCount=function(t){return t-=t>>>1&1431655765,t=(858993459&t)+(t>>>2&858993459),16843009*(t+(t>>>4)&252645135)>>>24},r.countTrailingZeros=n,r.nextPow2=function(t){return t+=0===t,--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t+1},r.prevPow2=function(t){return t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t-(t>>>1)},r.parity=function(t){return t^=t>>>16,t^=t>>>8,t^=t>>>4,t&=15,27030>>>t&1};var a=new Array(256);!function(t){for(var e=0;e<256;++e){var r=e,n=e,i=7;for(r>>>=1;r;r>>>=1)n<<=1,n|=1&r,--i;t[e]=n<>>8&255]<<16|a[t>>>16&255]<<8|a[t>>>24&255]},r.interleave2=function(t,e){return t&=65535,t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e&=65535,e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t|e<<1},r.deinterleave2=function(t,e){return t=t>>>e&1431655765,t=858993459&(t|t>>>1),t=252645135&(t|t>>>2),t=16711935&(t|t>>>4),t=65535&(t|t>>>16),t<<16>>16},r.interleave3=function(t,e,r){return t&=1023,t=4278190335&(t|t<<16),t=251719695&(t|t<<8),t=3272356035&(t|t<<4),t=1227133513&(t|t<<2),e&=1023,e=4278190335&(e|e<<16),e=251719695&(e|e<<8),e=3272356035&(e|e<<4),e=1227133513&(e|e<<2),t|=e<<1,r&=1023,r=4278190335&(r|r<<16),r=251719695&(r|r<<8),r=3272356035&(r|r<<4),r=1227133513&(r|r<<2),t|r<<2},r.deinterleave3=function(t,e){return t=t>>>e&1227133513,t=3272356035&(t|t>>>2),t=251719695&(t|t>>>4),t=4278190335&(t|t>>>8),t=1023&(t|t>>>16),t<<22>>22},r.nextCombination=function(t){var e=t|t-1;return e+1|(~e&-~e)-1>>>n(t)+1}},{}],29:[function(t,e,r){!function(t,e){"use strict";function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function i(t,e,r){return null!==t&&"object"==typeof t&&Array.isArray(t.words)?t:(this.sign=!1,this.words=null,this.length=0,this.red=null,"le"!==e&&"be"!==e||(r=e,e=10),void(null!==t&&this._init(t||0,e||10,r||"be")))}function a(t,e,r){for(var n=0,i=Math.min(t.length,r),a=e;a=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return n}function o(t,e,r,n){for(var i=0,a=Math.min(t.length,r),o=e;o=49?s-49+10:s>=17?s-17+10:s}return i}function s(t,e){this.name=t,this.p=new i(e,16),this.n=this.p.bitLength(),this.k=new i(1).ishln(this.n).isub(this.p),this.tmp=this._tmp()}function l(){s.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function u(){s.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function c(){s.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function f(){s.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function h(t){if("string"==typeof t){var e=i._prime(t);this.m=e.p,this.prime=e}else this.m=t,this.prime=null}function d(t){h.call(this,t),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new i(1).ishln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv.sign=!0,this.minv=this.minv.mod(this.r)}"object"==typeof t?t.exports=i:e.BN=i,i.BN=i,i.wordSize=26,i.prototype._init=function(t,e,n){if("number"==typeof t)return this._initNumber(t,e,n);if("object"==typeof t)return this._initArray(t,e,n);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36),t=t.toString().replace(/\s+/g,"");var i=0;"-"===t[0]&&i++,16===e?this._parseHex(t,i):this._parseBase(t,e,i),"-"===t[0]&&(this.sign=!0),this.strip(),"le"===n&&this._initArray(this.toArray(),e,n)},i.prototype._initNumber=function(t,e,n){t<0&&(this.sign=!0,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),e,n)},i.prototype._initArray=function(t,e,n){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3){var s=t[i]|t[i-1]<<8|t[i-2]<<16;this.words[o]|=s<>>26-a&67108863,a+=24,a>=26&&(a-=26,o++)}else if("le"===n)for(var i=0,o=0;i>>26-a&67108863,a+=24,a>=26&&(a-=26,o++)}return this.strip()},i.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var r=0;r=e;r-=6){var o=a(t,r,r+6);this.words[i]|=o<>>26-n&4194303,n+=24,n>=26&&(n-=26,i++)}if(r+6!==e){var o=a(t,e,r+6);this.words[i]|=o<>>26-n&4194303}this.strip()},i.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=e)n++;n--,i=i/e|0;for(var a=t.length-r,s=a%n,l=Math.min(a,a-s)+r,u=0,c=r;c1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.sign=!1),this},i.prototype.inspect=function(){return(this.red?""};var p=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],g=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],v=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];i.prototype.toString=function(t,e){if(t=t||10,16===t||"hex"===t){for(var n="",i=0,e=0|e||1,a=0,o=0;o>>24-i&16777215,n=0!==a||o!==this.length-1?p[6-l.length]+l+n:l+n,i+=2,i>=26&&(i-=26,o--)}for(0!==a&&(n=a.toString(16)+n);n.length%e!==0;)n="0"+n;return this.sign&&(n="-"+n),n}if(t===(0|t)&&t>=2&&t<=36){var u=g[t],c=v[t],n="",f=this.clone();for(f.sign=!1;0!==f.cmpn(0);){var h=f.modn(c).toString(t);f=f.idivn(c),n=0!==f.cmpn(0)?p[u-h.length]+h+n:h+n}return 0===this.cmpn(0)&&(n="0"+n),this.sign&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toArray=function(t){this.strip();var e=new Array(this.byteLength());e[0]=0;var r=this.clone();if("le"!==t)for(var n=0;0!==r.cmpn(0);n++){var i=r.andln(255);r.ishrn(8),e[e.length-n-1]=i}else for(var n=0;0!==r.cmpn(0);n++){var i=r.andln(255);r.ishrn(8),e[n]=i}return e},Math.clz32?i.prototype._countBits=function(t){return 32-Math.clz32(t)}:i.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},i.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0===(8191&e)&&(r+=13,e>>>=13),0===(127&e)&&(r+=7,e>>>=7),0===(15&e)&&(r+=4,e>>>=4),0===(3&e)&&(r+=2,e>>>=2),0===(1&e)&&r++,r},i.prototype.bitLength=function(){var t=0,e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},i.prototype.zeroBits=function(){if(0===this.cmpn(0))return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},i.prototype.iand=function(t){this.sign=this.sign&&t.sign;var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},i.prototype.ixor=function(t){this.sign=this.sign||t.sign;var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;nt.length?this.clone().ixor(t):t.clone().ixor(this)},i.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);for(var n=t/26|0,i=t%26;this.length<=n;)this.words[this.length++]=0;return e?this.words[n]=this.words[n]|1<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,a=0;a>>26}for(;0!==i&&a>>26}if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;at.length?this.clone().iadd(t):t.clone().iadd(this)},i.prototype.isub=function(t){if(t.sign){t.sign=!1;var e=this.iadd(t);return t.sign=!0,e._normSign()}if(this.sign)return this.sign=!1,this.iadd(t),this.sign=!0,this._normSign();var r=this.cmp(t);if(0===r)return this.sign=!1,this.length=1,this.words[0]=0,this;var n,i;r>0?(n=this,i=t):(n=t,i=this);for(var a=0,o=0;o>26,this.words[o]=67108863&e}for(;0!==a&&o>26,this.words[o]=67108863&e}if(0===a&&o>>26,a=67108863&r,o=Math.min(n,t.length-1),s=Math.max(0,n-this.length+1);s<=o;s++){var l=n-s,u=0|this.words[l],c=0|t.words[s],f=u*c,h=67108863&f;i=i+(f/67108864|0)|0,h=h+a|0,a=67108863&h,i=i+(h>>>26)|0}e.words[n]=a,r=i}return 0!==r?e.words[n]=r:e.length--,e.strip()},i.prototype._bigMulTo=function(t,e){e.sign=t.sign!==this.sign,e.length=this.length+t.length;for(var r=0,n=0,i=0;i>>26)|0,n+=a>>>26,a&=67108863}e.words[i]=o,r=a,a=n}return 0!==r?e.words[i]=r:e.length--,e.strip()},i.prototype.mulTo=function(t,e){var r;return r=this.length+t.length<63?this._smallMulTo(t,e):this._bigMulTo(t,e)},i.prototype.mul=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},i.prototype.imul=function(t){if(0===this.cmpn(0)||0===t.cmpn(0))return this.words[0]=0,this.length=1,this;var e=this.length,r=t.length;this.sign=t.sign!==this.sign,this.length=this.length+t.length,this.words[this.length-1]=0;for(var n=this.length-2;n>=0;n--){for(var i=0,a=0,o=Math.min(n,r-1),s=Math.max(0,n-e+1);s<=o;s++){var l=n-s,u=this.words[l],c=t.words[s],f=u*c,h=67108863&f;i+=f/67108864|0,h+=a,a=67108863&h,i+=h>>>26}this.words[n]=a,this.words[n+1]+=i,i=0}for(var i=0,l=1;l>>26}return this.strip()},i.prototype.imuln=function(t){r("number"==typeof t);for(var e=0,n=0;n>=26,e+=i/67108864|0,e+=a>>>26,this.words[n]=67108863&a}return 0!==e&&(this.words[n]=e,this.length++),this},i.prototype.muln=function(t){return this.clone().imuln(t)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.mul(this)},i.prototype.ishln=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,i=67108863>>>26-e<<26-e;if(0!==e){for(var a=0,o=0;o>>26-e}a&&(this.words[o]=a,this.length++)}if(0!==n){for(var o=this.length-1;o>=0;o--)this.words[o+n]=this.words[o];for(var o=0;o=0);var i;i=e?(e-e%26)/26:0;var a=t%26,o=Math.min((t-a)/26,this.length),s=67108863^67108863>>>a<o){this.length-=o;for(var u=0;u=0&&(0!==c||u>=i);u--){var f=this.words[u];this.words[u]=c<<26-a|f>>>a,c=f&s}return l&&0!==c&&(l.words[l.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this.strip(),this},i.prototype.shln=function(t){return this.clone().ishln(t)},i.prototype.shrn=function(t){return this.clone().ishrn(t)},i.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,i=1<=0);var e=t%26,n=(t-e)/26;if(r(!this.sign,"imaskn works only with positive numbers"),0!==e&&n++,this.length=Math.min(n,this.length),0!==e){var i=67108863^67108863>>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},i.prototype.isubn=function(t){if(r("number"==typeof t),t<0)return this.iaddn(-t);if(this.sign)return this.sign=!1,this.iaddn(t),this.sign=!0,this;this.words[0]-=t;for(var e=0;e>26)-(u/67108864|0),this.words[i+n]=67108863&l}for(;i>26,this.words[i+n]=67108863&l}if(0===s)return this.strip();r(s===-1),s=0;for(var i=0;i>26,this.words[i]=67108863&l}return this.sign=!0,this.strip()},i.prototype._wordDiv=function(t,e){var r=this.length-t.length,n=this.clone(),a=t,o=a.words[a.length-1],s=this._countBits(o);r=26-s,0!==r&&(a=a.shln(r),n.ishln(r),o=a.words[a.length-1]);var l,u=n.length-a.length;if("mod"!==e){l=new i(null),l.length=u+1,l.words=new Array(l.length);for(var c=0;c=0;h--){var d=67108864*n.words[a.length+h]+n.words[a.length+h-1];for(d=Math.min(d/o|0,67108863),n._ishlnsubmul(a,d,h);n.sign;)d--,n.sign=!1,n._ishlnsubmul(a,1,h),0!==n.cmpn(0)&&(n.sign=!n.sign);l&&(l.words[h]=d)}return l&&l.strip(),n.strip(),"div"!==e&&0!==r&&n.ishrn(r),{div:l?l:null,mod:n}},i.prototype.divmod=function(t,e){if(r(0!==t.cmpn(0)),this.sign&&!t.sign){var n,a,o=this.neg().divmod(t,e);return"mod"!==e&&(n=o.div.neg()),"div"!==e&&(a=0===o.mod.cmpn(0)?o.mod:t.sub(o.mod)),{div:n,mod:a}}if(!this.sign&&t.sign){var n,o=this.divmod(t.neg(),e);return"mod"!==e&&(n=o.div.neg()),{div:n,mod:o.mod}}return this.sign&&t.sign?this.neg().divmod(t.neg(),e):t.length>this.length||this.cmp(t)<0?{div:new i(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new i(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new i(this.modn(t.words[0]))}:this._wordDiv(t,e)},i.prototype.div=function(t){return this.divmod(t,"div").div},i.prototype.mod=function(t){return this.divmod(t,"mod").mod},i.prototype.divRound=function(t){var e=this.divmod(t);if(0===e.mod.cmpn(0))return e.div;var r=e.div.sign?e.mod.isub(t):e.mod,n=t.shrn(1),i=t.andln(1),a=r.cmp(n);return a<0||1===i&&0===a?e.div:e.div.sign?e.div.isubn(1):e.div.iaddn(1)},i.prototype.modn=function(t){r(t<=67108863);for(var e=(1<<26)%t,n=0,i=this.length-1;i>=0;i--)n=(e*n+this.words[i])%t;return n},i.prototype.idivn=function(t){r(t<=67108863);for(var e=0,n=this.length-1;n>=0;n--){var i=this.words[n]+67108864*e;this.words[n]=i/t|0,e=i%t}return this.strip()},i.prototype.divn=function(t){return this.clone().idivn(t)},i.prototype.egcd=function(t){r(!t.sign),r(0!==t.cmpn(0));var e=this,n=t.clone();e=e.sign?e.mod(t):e.clone();for(var a=new i(1),o=new i(0),s=new i(0),l=new i(1),u=0;e.isEven()&&n.isEven();)e.ishrn(1),n.ishrn(1),++u;for(var c=n.clone(),f=e.clone();0!==e.cmpn(0);){for(;e.isEven();)e.ishrn(1),a.isEven()&&o.isEven()?(a.ishrn(1),o.ishrn(1)):(a.iadd(c).ishrn(1),o.isub(f).ishrn(1));for(;n.isEven();)n.ishrn(1),s.isEven()&&l.isEven()?(s.ishrn(1),l.ishrn(1)):(s.iadd(c).ishrn(1),l.isub(f).ishrn(1));e.cmp(n)>=0?(e.isub(n),a.isub(s),o.isub(l)):(n.isub(e),s.isub(a),l.isub(o))}return{a:s,b:l,gcd:n.ishln(u)}},i.prototype._invmp=function(t){r(!t.sign),r(0!==t.cmpn(0));var e=this,n=t.clone();e=e.sign?e.mod(t):e.clone();for(var a=new i(1),o=new i(0),s=n.clone();e.cmpn(1)>0&&n.cmpn(1)>0;){for(;e.isEven();)e.ishrn(1),a.isEven()?a.ishrn(1):a.iadd(s).ishrn(1);for(;n.isEven();)n.ishrn(1),o.isEven()?o.ishrn(1):o.iadd(s).ishrn(1);e.cmp(n)>=0?(e.isub(n),a.isub(o)):(n.isub(e),o.isub(a))}return 0===e.cmpn(1)?a:o},i.prototype.gcd=function(t){if(0===this.cmpn(0))return t.clone();if(0===t.cmpn(0))return this.clone();var e=this.clone(),r=t.clone();e.sign=!1,r.sign=!1;for(var n=0;e.isEven()&&r.isEven();n++)e.ishrn(1),r.ishrn(1);for(;;){for(;e.isEven();)e.ishrn(1);for(;r.isEven();)r.ishrn(1);var i=e.cmp(r);if(i<0){var a=e;e=r,r=a}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.ishln(n)},i.prototype.invm=function(t){return this.egcd(t).a.mod(t)},i.prototype.isEven=function(){return 0===(1&this.words[0])},i.prototype.isOdd=function(){return 1===(1&this.words[0])},i.prototype.andln=function(t){return this.words[0]&t},i.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,n=(t-e)/26,i=1<>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},i.prototype.cmpn=function(t){var e=t<0;if(e&&(t=-t),this.sign&&!e)return-1;if(!this.sign&&e)return 1;t&=67108863,this.strip();var r;if(this.length>1)r=1;else{var n=this.words[0];r=n===t?0:nt.length)return 1;if(this.length=0;r--){var n=this.words[r],i=t.words[r];if(n!==i){ni&&(e=1);break}}return e},i.red=function(t){return new h(t)},i.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(!this.sign,"red works only with positives"),t.convertTo(this)._forceRed(t)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(t){return this.red=t,this},i.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},i.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},i.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},i.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},i.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},i.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},i.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},i.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var m={k256:null,p224:null,p192:null,p25519:null};s.prototype._tmp=function(){var t=new i(null);return t.words=new Array(Math.ceil(this.n/13)),t},s.prototype.ireduce=function(t){var e,r=t;do this.split(r,this.tmp),r=this.imulK(r),r=r.iadd(this.tmp),e=r.bitLength();while(e>this.n);var n=e0?r.isub(this.p):r.strip(),r},s.prototype.split=function(t,e){t.ishrn(this.n,0,e)},s.prototype.imulK=function(t){return t.imul(this.k)},n(l,s),l.prototype.split=function(t,e){for(var r=4194303,n=Math.min(t.length,9),i=0;i>>22,a=o}t.words[i-10]=a>>>22,t.length-=9},l.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e,r=0,n=0;n>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},i._prime=function t(e){if(m[e])return m[e];var t;if("k256"===e)t=new l;else if("p224"===e)t=new u;else if("p192"===e)t=new c;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new f}return m[e]=t,t},h.prototype._verify1=function(t){r(!t.sign,"red works only with positives"),r(t.red,"red works only with red numbers")},h.prototype._verify2=function(t,e){r(!t.sign&&!e.sign,"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},h.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.mod(this.m)._forceRed(this)},h.prototype.neg=function(t){var e=t.clone();return e.sign=!e.sign,e.iadd(this.m)._forceRed(this)},h.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},h.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},h.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},h.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},h.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.shln(e))},h.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},h.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},h.prototype.isqr=function(t){return this.imul(t,t)},h.prototype.sqr=function(t){return this.mul(t,t)},h.prototype.sqrt=function(t){if(0===t.cmpn(0))return t.clone();var e=this.m.andln(3);if(r(e%2===1),3===e){var n=this.m.add(new i(1)).ishrn(2),a=this.pow(t,n);return a}for(var o=this.m.subn(1),s=0;0!==o.cmpn(0)&&0===o.andln(1);)s++,o.ishrn(1);r(0!==o.cmpn(0));var l=new i(1).toRed(this),u=l.redNeg(),c=this.m.subn(1).ishrn(1),f=this.m.bitLength();for(f=new i(2*f*f).toRed(this);0!==this.pow(f,c).cmp(u);)f.redIAdd(u);for(var h=this.pow(f,o),a=this.pow(t,o.addn(1).ishrn(1)),d=this.pow(t,o),p=s;0!==d.cmp(l);){for(var g=d,v=0;0!==g.cmp(l);v++)g=g.redSqr();r(v=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},d.prototype.mul=function(t,e){if(0===t.cmpn(0)||0===e.cmpn(0))return new i(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),a=r.isub(n).ishrn(this.shift),o=a;return a.cmp(this.m)>=0?o=a.isub(this.m):a.cmpn(0)<0&&(o=a.iadd(this.m)),o._forceRed(this)},d.prototype.invm=function(t){var e=this.imod(t._invmp(this.m).mul(this.r2));return e._forceRed(this)}}("undefined"==typeof e||e,this)},{}],30:[function(t,e,r){"use strict";function n(t,e){for(var r=0;r>>1;if(!(s<=0)){var l,u=f.mallocDouble(2*s*a),c=f.mallocInt32(a);if(a=i(t,s,u,c),a>0){if(1===s&&n)h.init(a),l=h.sweepComplete(s,r,0,a,u,c,0,a,u,c);else{var p=f.mallocDouble(2*s*o),g=f.mallocInt32(o);o=i(e,s,p,g),o>0&&(h.init(a+o),l=1===s?h.sweepBipartite(s,r,0,a,u,c,0,o,p,g):d(s,r,n,a,u,c,o,p,g),f.free(p),f.free(g))}f.free(u),f.free(c)}return l}}}function o(t,e){c.push([t,e])}function s(t){return c=[],a(t,t,o,!0),c}function l(t,e){return c=[],a(t,e,o,!1),c}function u(t,e,r){switch(arguments.length){case 1:return s(t);case 2:return"function"==typeof e?a(t,t,e,!0):l(t,e);case 3:return a(t,e,r,!1);default:throw new Error("box-intersect: Invalid arguments")}}e.exports=u;var c,f=t("typedarray-pool"),h=t("./lib/sweep"),d=t("./lib/intersect")},{"./lib/intersect":32,"./lib/sweep":36,"typedarray-pool":162}],31:[function(t,e,r){"use strict";function n(t,e,r){var n="bruteForce"+(t?"Red":"Blue")+(e?"Flip":"")+(r?"Full":""),i=["function ",n,"(",w.join(),"){","var ",u,"=2*",a,";"],l="for(var i="+c+","+p+"="+u+"*"+c+";i<"+f+";++i,"+p+"+="+u+"){var x0="+h+"["+o+"+"+p+"],x1="+h+"["+o+"+"+p+"+"+a+"],xi="+d+"[i];",A="for(var j="+g+","+b+"="+u+"*"+g+";j<"+v+";++j,"+b+"+="+u+"){var y0="+m+"["+o+"+"+b+"],"+(r?"y1="+m+"["+o+"+"+b+"+"+a+"],":"")+"yi="+y+"[j];";return t?i.push(l,_,":",A):i.push(A,_,":",l),r?i.push("if(y1"+v+"-"+g+"){"),t?(e(!0,!1),o.push("}else{"),e(!1,!1)):(o.push("if("+l+"){"),e(!0,!0),o.push("}else{"),e(!0,!1),o.push("}}else{if("+l+"){"),e(!1,!0),o.push("}else{"),e(!1,!1),o.push("}")),o.push("}}return "+r);var s=i.join("")+o.join(""),u=new Function(s);return u()}var a="d",o="ax",s="vv",l="fp",u="es",c="rs",f="re",h="rb",d="ri",p="rp",g="bs",v="be",m="bb",y="bi",b="bp",x="rv",_="Q",w=[a,o,s,c,f,h,d,g,v,m,y];r.partial=i(!1),r.full=i(!0)},{}],32:[function(t,e,r){"use strict";function n(t,e){var r=8*u.log2(e+1)*(t+1)|0,n=u.nextPow2(M*r);L.length0;){R-=1;var P=R*M,O=L[P],N=L[P+1],z=L[P+2],D=L[P+3],F=L[P+4],B=L[P+5],j=R*E,U=S[j],V=S[j+1],q=1&B,H=!!(16&B),G=l,X=u,Y=g,W=T;if(q&&(G=g,X=T,Y=l,W=u),!(2&B&&(z=_(t,O,N,z,G,X,V),N>=z)||4&B&&(N=w(t,O,N,z,G,X,U),N>=z))){var Z=z-N,Q=F-D;if(H){if(t*Z*(Z+Q)=p0)&&!(p1>=hi)",["p0","p1"]),x=g("lo===p0",["p0"]),_=g("lor&&i[f+e]>u;--c,f-=o){for(var h=f,d=f+o,p=0;p>>1,h=2*t,d=f,p=a[h*f+e];u=b?(d=y,p=b):m>=_?(d=v,p=m):(d=x,p=_):b>=_?(d=y,p=b):_>=m?(d=v,p=m):(d=x,p=_);for(var w=h*(c-1),A=h*d,k=0;k=0&&n.push("lo=e[k+n]"),t.indexOf("hi")>=0&&n.push("hi=e[k+o]"),r.push(i.replace("_",n.join()).replace("$",t)),Function.apply(void 0,r)}e.exports=n;var i="for(var j=2*a,k=j*c,l=k,m=c,n=b,o=a+b,p=c;d>p;++p,k+=j){var _;if($)if(m===p)m+=1,l+=j;else{for(var s=0;j>s;++s){var t=e[k+s];e[k+s]=e[l],e[l++]=t}var u=f[p];f[p]=f[m],f[m++]=u}}return m"},{}],35:[function(t,e,r){"use strict";function n(t,e){e<=4*h?i(0,e-1,t):f(0,e-1,t)}function i(t,e,r){for(var n=2*(t+1),i=t+1;i<=e;++i){for(var a=r[n++],o=r[n++],s=i,l=n-2;s-- >t;){var u=r[l-2],c=r[l-1];if(ur[e+1])}function c(t,e,r,n){t*=2;var i=n[t];return i>1,v=g-n,m=g+n,y=d,b=v,x=g,_=m,w=p,A=t+1,k=e-1,M=0;u(y,b,r)&&(M=y,y=b,b=M),u(_,w,r)&&(M=_,_=w,w=M),u(y,x,r)&&(M=y,y=x,x=M),u(b,x,r)&&(M=b,b=x,x=M),u(y,_,r)&&(M=y,y=_,_=M),u(x,_,r)&&(M=x,x=_,_=M),u(b,w,r)&&(M=b,b=w,w=M),u(b,x,r)&&(M=b,b=x,x=M),u(_,w,r)&&(M=_,_=w,w=M);for(var E=r[2*b],T=r[2*b+1],L=r[2*_],S=r[2*_+1],C=2*y,R=2*x,I=2*w,P=2*d,O=2*g,N=2*p,z=0;z<2;++z){var D=r[C+z],F=r[R+z],B=r[I+z];r[P+z]=D,r[O+z]=F,r[N+z]=B}o(v,t,r),o(m,e,r);for(var j=A;j<=k;++j)if(c(j,E,T,r))j!==A&&a(j,A,r),++A;else if(!c(j,L,S,r))for(;;){if(c(k,L,S,r)){c(k,E,T,r)?(s(j,A,k,r),++A,--k):(a(j,k,r),--k);break}if(--k>>1;h(_,T);for(var L=0,S=0,A=0;A=d)C=C-d|0,i(m,y,S--,C);else if(C>=0)i(g,v,L--,C);else if(C<=-d){C=-C-d|0;for(var R=0;R>>1;h(_,L);for(var S=0,C=0,R=0,k=0;k>1===_[2*k+3]>>1&&(P=2,k+=1),I<0){for(var O=-(I>>1)-1,N=0;N>1)-1;0===P?i(g,v,S--,O):1===P?i(m,y,C--,O):2===P&&i(b,x,R--,O)}}}function l(t,e,r,n,o,s,l,u,c,f,p,m){var y=0,b=2*t,x=e,w=e+t,A=1,k=1;n?k=d:A=d;for(var M=o;M>>1;h(_,S);for(var C=0,M=0;M=d?(I=!n,E-=d):(I=!!n,E-=1),I)a(g,v,C++,E);else{var P=m[E],O=b*E,N=p[O+e+1],z=p[O+e+1+t];t:for(var D=0;D>>1;h(_,A);for(var k=0,y=0;y=d)g[k++]=b-d;else{b-=1;var E=c[b],T=p*b,L=u[T+e+1],S=u[T+e+1+t];t:for(var C=0;C=0;--C)if(g[C]===b){for(var O=C+1;O=i())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i().toString(16)+" bytes");return 0|t}function v(t){return+t!=t&&(t=0),o.alloc(+t)}function m(t,e){if(o.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return G(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return W(t).length;default:if(n)return G(t).length;e=(""+e).toLowerCase(),n=!0}}function y(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if(r>>>=0,e>>>=0,r<=e)return"";for(t||(t="utf8");;)switch(t){case"hex":return P(this,e,r);case"utf8":case"utf-8":return S(this,e,r);case"ascii":return R(this,e,r);case"latin1": ++case"binary":return I(this,e,r);case"base64":return L(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function b(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function x(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=o.from(e,n)),o.isBuffer(e))return 0===e.length?-1:_(t,e,r,n,i);if("number"==typeof e)return e=255&e,o.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):_(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function _(t,e,r,n,i){function a(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}var o=1,s=t.length,l=e.length;if(void 0!==n&&(n=String(n).toLowerCase(),"ucs2"===n||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,s/=2,l/=2,r/=2}var u;if(i){var c=-1;for(u=r;us&&(r=s-l),u=r;u>=0;u--){for(var f=!0,h=0;hi&&(n=i)):n=i;var a=e.length;if(a%2!==0)throw new TypeError("Invalid hex string");n>a/2&&(n=a/2);for(var o=0;o239?4:a>223?3:a>191?2:1;if(i+s<=r){var l,u,c,f;switch(s){case 1:a<128&&(o=a);break;case 2:l=t[i+1],128===(192&l)&&(f=(31&a)<<6|63&l,f>127&&(o=f));break;case 3:l=t[i+1],u=t[i+2],128===(192&l)&&128===(192&u)&&(f=(15&a)<<12|(63&l)<<6|63&u,f>2047&&(f<55296||f>57343)&&(o=f));break;case 4:l=t[i+1],u=t[i+2],c=t[i+3],128===(192&l)&&128===(192&u)&&128===(192&c)&&(f=(15&a)<<18|(63&l)<<12|(63&u)<<6|63&c,f>65535&&f<1114112&&(o=f))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=s}return C(n)}function C(t){var e=t.length;if(e<=tt)return String.fromCharCode.apply(String,t);for(var r="",n=0;nn)&&(r=n);for(var i="",a=e;ar)throw new RangeError("Trying to access beyond buffer length")}function z(t,e,r,n,i,a){if(!o.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function D(t,e,r,n){e<0&&(e=65535+e+1);for(var i=0,a=Math.min(t.length-r,2);i>>8*(n?i:1-i)}function F(t,e,r,n){e<0&&(e=4294967295+e+1);for(var i=0,a=Math.min(t.length-r,4);i>>8*(n?i:3-i)&255}function B(t,e,r,n,i,a){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function j(t,e,r,n,i){return i||B(t,e,r,4,3.4028234663852886e38,-3.4028234663852886e38),K.write(t,e,r,n,23,4),r+4}function U(t,e,r,n,i){return i||B(t,e,r,8,1.7976931348623157e308,-1.7976931348623157e308),K.write(t,e,r,n,52,8),r+8}function V(t){if(t=q(t).replace(et,""),t.length<2)return"";for(;t.length%4!==0;)t+="=";return t}function q(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function H(t){return t<16?"0"+t.toString(16):t.toString(16)}function G(t,e){e=e||1/0;for(var r,n=t.length,i=null,a=[],o=0;o55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&a.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&a.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&a.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&a.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;a.push(r)}else if(r<2048){if((e-=2)<0)break;a.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;a.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return a}function X(t){for(var e=[],r=0;r>8,i=r%256,a.push(i),a.push(n);return a}function W(t){return $.toByteArray(V(t))}function Z(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function Q(t){return t!==t}var $=t("base64-js"),K=t("ieee754"),J=t("isarray");r.Buffer=o,r.SlowBuffer=v,r.INSPECT_MAX_BYTES=50,o.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:n(),r.kMaxLength=i(),o.poolSize=8192,o._augment=function(t){return t.__proto__=o.prototype,t},o.from=function(t,e,r){return s(null,t,e,r)},o.TYPED_ARRAY_SUPPORT&&(o.prototype.__proto__=Uint8Array.prototype,o.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&o[Symbol.species]===o&&Object.defineProperty(o,Symbol.species,{value:null,configurable:!0})),o.alloc=function(t,e,r){return u(null,t,e,r)},o.allocUnsafe=function(t){return c(null,t)},o.allocUnsafeSlow=function(t){return c(null,t)},o.isBuffer=function(t){return!(null==t||!t._isBuffer)},o.compare=function(t,e){if(!o.isBuffer(t)||!o.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,i=0,a=Math.min(r,n);i0&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(t+=" ... ")),""},o.prototype.compare=function(t,e,r,n,i){if(!o.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,i>>>=0,this===t)return 0;for(var a=i-n,s=r-e,l=Math.min(a,s),u=this.slice(n,i),c=t.slice(e,r),f=0;fi)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var a=!1;;)switch(n){case"hex":return w(this,t,e,r);case"utf8":case"utf-8":return A(this,t,e,r);case"ascii":return k(this,t,e,r);case"latin1":case"binary":return M(this,t,e,r);case"base64":return E(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,e,r);default:if(a)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),a=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var tt=4096;o.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r,t<0&&(t=0)):t>r&&(t=r),e<0?(e+=r,e<0&&(e=0)):e>r&&(e=r),e0&&(i*=256);)n+=this[t+--e]*i;return n},o.prototype.readUInt8=function(t,e){return e||N(t,1,this.length),this[t]},o.prototype.readUInt16LE=function(t,e){return e||N(t,2,this.length),this[t]|this[t+1]<<8},o.prototype.readUInt16BE=function(t,e){return e||N(t,2,this.length),this[t]<<8|this[t+1]},o.prototype.readUInt32LE=function(t,e){return e||N(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},o.prototype.readUInt32BE=function(t,e){return e||N(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},o.prototype.readIntLE=function(t,e,r){t=0|t,e=0|e,r||N(t,e,this.length);for(var n=this[t],i=1,a=0;++a=i&&(n-=Math.pow(2,8*e)),n},o.prototype.readIntBE=function(t,e,r){t=0|t,e=0|e,r||N(t,e,this.length);for(var n=e,i=1,a=this[t+--n];n>0&&(i*=256);)a+=this[t+--n]*i;return i*=128,a>=i&&(a-=Math.pow(2,8*e)),a},o.prototype.readInt8=function(t,e){return e||N(t,1,this.length),128&this[t]?(255-this[t]+1)*-1:this[t]},o.prototype.readInt16LE=function(t,e){e||N(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},o.prototype.readInt16BE=function(t,e){e||N(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},o.prototype.readInt32LE=function(t,e){return e||N(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},o.prototype.readInt32BE=function(t,e){return e||N(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},o.prototype.readFloatLE=function(t,e){return e||N(t,4,this.length),K.read(this,t,!0,23,4)},o.prototype.readFloatBE=function(t,e){return e||N(t,4,this.length),K.read(this,t,!1,23,4)},o.prototype.readDoubleLE=function(t,e){return e||N(t,8,this.length),K.read(this,t,!0,52,8)},o.prototype.readDoubleBE=function(t,e){return e||N(t,8,this.length),K.read(this,t,!1,52,8)},o.prototype.writeUIntLE=function(t,e,r,n){if(t=+t,e=0|e,r=0|r,!n){var i=Math.pow(2,8*r)-1;z(this,t,e,r,i,0)}var a=1,o=0;for(this[e]=255&t;++o=0&&(o*=256);)this[e+a]=t/o&255;return e+r},o.prototype.writeUInt8=function(t,e,r){return t=+t,e=0|e,r||z(this,t,e,1,255,0),o.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},o.prototype.writeUInt16LE=function(t,e,r){return t=+t,e=0|e,r||z(this,t,e,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):D(this,t,e,!0),e+2},o.prototype.writeUInt16BE=function(t,e,r){return t=+t,e=0|e,r||z(this,t,e,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):D(this,t,e,!1),e+2},o.prototype.writeUInt32LE=function(t,e,r){return t=+t,e=0|e,r||z(this,t,e,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):F(this,t,e,!0),e+4},o.prototype.writeUInt32BE=function(t,e,r){return t=+t,e=0|e,r||z(this,t,e,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):F(this,t,e,!1),e+4},o.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e=0|e,!n){var i=Math.pow(2,8*r-1);z(this,t,e,r,i-1,-i)}var a=0,o=1,s=0;for(this[e]=255&t;++a>0)-s&255;return e+r},o.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e=0|e,!n){var i=Math.pow(2,8*r-1);z(this,t,e,r,i-1,-i)}var a=r-1,o=1,s=0;for(this[e+a]=255&t;--a>=0&&(o*=256);)t<0&&0===s&&0!==this[e+a+1]&&(s=1),this[e+a]=(t/o>>0)-s&255;return e+r},o.prototype.writeInt8=function(t,e,r){return t=+t,e=0|e,r||z(this,t,e,1,127,-128),o.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},o.prototype.writeInt16LE=function(t,e,r){return t=+t,e=0|e,r||z(this,t,e,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):D(this,t,e,!0),e+2},o.prototype.writeInt16BE=function(t,e,r){return t=+t,e=0|e,r||z(this,t,e,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):D(this,t,e,!1),e+2},o.prototype.writeInt32LE=function(t,e,r){return t=+t,e=0|e,r||z(this,t,e,4,2147483647,-2147483648),o.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):F(this,t,e,!0),e+4},o.prototype.writeInt32BE=function(t,e,r){return t=+t,e=0|e,r||z(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),o.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):F(this,t,e,!1),e+4},o.prototype.writeFloatLE=function(t,e,r){return j(this,t,e,!0,r)},o.prototype.writeFloatBE=function(t,e,r){return j(this,t,e,!1,r)},o.prototype.writeDoubleLE=function(t,e,r){return U(this,t,e,!0,r)},o.prototype.writeDoubleBE=function(t,e,r){return U(this,t,e,!1,r)},o.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--i)t[i+e]=this[i+r];else if(a<1e3||!o.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,t||(t=0);var a;if("number"==typeof t)for(a=e;a0)throw new Error("Invalid string. Length must be a multiple of 4");a="="===t[s-2]?2:"="===t[s-1]?1:0,o=new c(3*s/4-a),n=a>0?s-4:s;var l=0;for(e=0,r=0;e>16&255,o[l++]=i>>8&255,o[l++]=255&i;return 2===a?(i=u[t.charCodeAt(e)]<<2|u[t.charCodeAt(e+1)]>>4,o[l++]=255&i):1===a&&(i=u[t.charCodeAt(e)]<<10|u[t.charCodeAt(e+1)]<<4|u[t.charCodeAt(e+2)]>>2,o[l++]=i>>8&255,o[l++]=255&i),o}function a(t){return l[t>>18&63]+l[t>>12&63]+l[t>>6&63]+l[63&t]}function o(t,e,r){for(var n,i=[],o=e;oc?c:u+s));return 1===n?(e=t[r-1],i+=l[e>>2],i+=l[e<<4&63],i+="=="):2===n&&(e=(t[r-2]<<8)+t[r-1],i+=l[e>>10],i+=l[e>>4&63],i+=l[e<<2&63],i+="="),a.push(i),a.join("")}r.toByteArray=i,r.fromByteArray=s;var l=[],u=[],c="undefined"!=typeof Uint8Array?Uint8Array:Array;n()},{}],39:[function(t,e,r){var n={}.toString;e.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},{}],40:[function(t,e,r){"use strict";function n(t){return[Math.min(t[0],t[1]),Math.max(t[0],t[1])]}function i(t,e){return t[0]-e[0]||t[1]-e[1]}function a(t){return t.map(n).sort(i)}function o(t,e,r){return e in t?t[e]:r}function s(t,e,r){Array.isArray(e)?(r=r||{},e=e||[]):(r=e||{},e=[]);var n=!!o(r,"delaunay",!0),i=!!o(r,"interior",!0),s=!!o(r,"exterior",!0),h=!!o(r,"infinity",!1);if(!i&&!s||0===t.length)return[];var d=l(t,e);if(n||i!==s||h){for(var p=u(t.length,a(e)),g=0;g0;){for(var c=r.pop(),s=r.pop(),f=-1,h=-1,l=o[s],p=1;p=0||(e.flip(s,c),n(t,e,r,f,s,h),n(t,e,r,s,h,f),n(t,e,r,h,c,f),n(t,e,r,c,f,h))}}var a=t("robust-in-sphere")[4];t("binary-search-bounds");e.exports=i},{"binary-search-bounds":45,"robust-in-sphere":139}],42:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o){this.cells=t,this.neighbor=e,this.flags=n,this.constraint=r,this.active=i,this.next=a,this.boundary=o}function i(t,e){return t[0]-e[0]||t[1]-e[1]||t[2]-e[2]}function a(t,e){for(var r=t.cells(),a=r.length,o=0;o0||l.length>0;){for(;s.length>0;){var d=s.pop();if(u[d]!==-i){u[d]=i;for(var p=(c[d],0);p<3;++p){var g=h[3*d+p];g>=0&&0===u[g]&&(f[3*d+p]?l.push(g):(s.push(g),u[g]=i))}}}var v=l;l=s,s=v,l.length=0,i=-i}var m=o(c,u,e);return r?m.concat(n.boundary):m}var l=t("binary-search-bounds");e.exports=s;var u=n.prototype;u.locate=function(){var t=[0,0,0];return function(e,r,n){var a=e,o=r,s=n;return r1&&d(r[c[f-2]],r[c[f-1]],n)>0;)t.push([c[f-1],c[f-2],i]),f-=1;c.length=f,c.push(i);for(var p=u.upperIds,f=p.length;f>1&&d(r[p[f-2]],r[p[f-1]],n)<0;)t.push([p[f-2],p[f-1],i]),f-=1;p.length=f,p.push(i)}}function l(t,e){var r;return(r=t.a[0]m[0]&&l.push(new i(m,d,v,f),new i(d,m,g,f))}l.sort(a);for(var y=l[0].a[0]-(1+Math.abs(l[0].a[0]))*Math.pow(2,-52),b=[new n([y,1],[y,0],-1,[],[],[],[])],x=[],f=0,_=l.length;f<_;++f){var w=l[f],A=w.type;A===p?s(x,b,t,w.a,w.idx):A===v?u(b,t,w):c(b,t,w)}return x}var h=t("binary-search-bounds"),d=t("robust-orientation")[3],p=0,g=1,v=2;e.exports=f},{"binary-search-bounds":45,"robust-orientation":140}],44:[function(t,e,r){"use strict";function n(t,e){this.stars=t,this.edges=e}function i(t,e,r){for(var n=1,i=t.length;n=0}}(),s.removeTriangle=function(t,e,r){var n=this.stars;i(n[t],e,r),i(n[e],r,t),i(n[r],t,e)},s.addTriangle=function(t,e,r){var n=this.stars;n[t].push(e,r),n[e].push(r,t),n[r].push(t,e)},s.opposite=function(t,e){for(var r=this.stars[e],n=1,i=r.length;n>>1,x=a[m]"];return i?e.indexOf("c")<0?a.push(";if(x===y){return m}else if(x<=y){"):a.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){"):a.push(";if(",e,"){i=m;"),r?a.push("l=m+1}else{h=m-1}"):a.push("h=m-1}else{l=m+1}"),a.push("}"),i?a.push("return -1};"):a.push("return i};"),a.join("")}function i(t,e,r,i){var a=new Function([n("A","x"+t+"y",e,["y"],i),n("P","c(x,y)"+t+"0",e,["y","c"],i),"function dispatchBsearch",r,"(a,y,c,l,h){if(typeof(c)==='function'){return P(a,(l===void 0)?0:l|0,(h===void 0)?a.length-1:h|0,y,c)}else{return A(a,(c===void 0)?0:c|0,(l===void 0)?a.length-1:l|0,y)}}return dispatchBsearch",r].join(""));return a()}e.exports={ge:i(">=",!1,"GE"),gt:i(">",!1,"GT"),lt:i("<",!0,"LT"),le:i("<=",!0,"LE"),eq:i("-",!0,"EQ",!0)}},{}],46:[function(t,e,r){"use strict";function n(t){var e=x(t),r=b(y(e),t);return r<0?[e,w(e,1/0)]:r>0?[w(e,-(1/0)),e]:[e,e]}function i(t,e){for(var r=new Array(e.length),n=0;n=t.length)return o[e-t.length];var r=t[e];return[y(r[0]),y(r[1])]}for(var o=[],s=0;s=0;--s){var g=n[s],u=g[0],v=e[u],m=v[0],x=v[1],w=t[m],k=t[x];if((w[0]-k[0]||w[1]-k[1])<0){var M=m;m=x,x=M}v[0]=m;var E,T=v[1]=g[1];for(i&&(E=v[2]);s>0&&n[s-1][0]===u;){var g=n[--s],L=g[1];i?e.push([T,L,E]):e.push([T,L]),T=L}i?e.push([T,x,E]):e.push([T,x])}return o}function u(t,e,r){for(var i=t.length+e.length,a=new g(i),o=r,s=0;se[2]?1:0}function h(t,e,r){if(0!==t.length){if(e)for(var n=0;n0||d.length>0)}function p(t,e,r){var n,i=!1;if(r){n=e;for(var a=new Array(e.length),o=0;o=0}function i(t,e,r,i){var s=a(e,r,i);if(0===s){var l=o(a(t,e,r)),u=o(a(t,e,i));if(l===u){if(0===l){var c=n(t,e,r),f=n(t,e,i);return c===f?0:c?1:-1}return 0}return 0===u?l>0?-1:n(t,e,i)?-1:1:0===l?u>0?1:n(t,e,r)?1:-1:o(u-l)}var h=a(t,e,r);if(h>0)return s>0&&a(t,e,i)>0?1:-1;if(h<0)return s>0||a(t,e,i)>0?1:-1;var d=a(t,e,i);return d>0?1:n(t,e,r)?1:-1}e.exports=i;var a=t("robust-orientation"),o=t("signum"),s=t("two-sum"),l=t("robust-product"),u=t("robust-sum")},{"robust-orientation":140,"robust-product":141,"robust-sum":145,signum:146,"two-sum":161}],49:[function(t,e,r){function n(t,e){return t-e}function i(t,e){var r=t.length,i=t.length-e.length;if(i)return i;switch(r){case 0:return 0;case 1:return t[0]-e[0];case 2:return t[0]+t[1]-e[0]-e[1]||a(t[0],t[1])-a(e[0],e[1]);case 3:var o=t[0]+t[1],s=e[0]+e[1];if(i=o+t[2]-(s+e[2]))return i;var l=a(t[0],t[1]),u=a(e[0],e[1]);return a(l,t[2])-a(u,e[2])||a(l+t[2],o)-a(u+e[2],s);case 4:var c=t[0],f=t[1],h=t[2],d=t[3],p=e[0],g=e[1],v=e[2],m=e[3];return c+f+h+d-(p+g+v+m)||a(c,f,h,d)-a(p,g,v,m,p)||a(c+f,c+h,c+d,f+h,f+d,h+d)-a(p+g,p+v,p+m,g+v,g+m,v+m)||a(c+f+h,c+f+d,c+h+d,f+h+d)-a(p+g+v,p+g+m,p+v+m,g+v+m);default:for(var y=t.slice().sort(n),b=e.slice().sort(n),x=0;x0)throw new Error("cwise: pre() block may not reference array args");if(i0)throw new Error("cwise: post() block may not reference array args")}else if("scalar"===o)e.scalarArgs.push(i),e.shimArgs.push("scalar"+i);else if("index"===o){if(e.indexArgs.push(i),i0)throw new Error("cwise: pre() block may not reference array index");if(i0)throw new Error("cwise: post() block may not reference array index")}else if("shape"===o){if(e.shapeArgs.push(i),ir.length)throw new Error("cwise: Too many arguments in pre() block");if(e.body.args.length>r.length)throw new Error("cwise: Too many arguments in body() block");if(e.post.args.length>r.length)throw new Error("cwise: Too many arguments in post() block");return e.debug=!!t.printCode||!!t.debug,e.funcName=t.funcName||"cwise",e.blockSize=t.blockSize||64,a(e)}var a=t("./lib/thunk.js");e.exports=i},{"./lib/thunk.js":52}],51:[function(t,e,r){"use strict";function n(t,e,r){var n,i,a=t.length,o=e.arrayArgs.length,s=e.indexArgs.length>0,l=[],u=[],c=0,f=0;for(n=0;n=0;--n)c=t[n],l.push(["for(i",n,"=0;i",n,"0&&l.push(["index[",f,"]-=s",f].join("")),l.push(["++index[",c,"]"].join(""))),l.push("}")}return l.join("\n")}function i(t,e,r,i){for(var a=e.length,o=r.arrayArgs.length,s=r.blockSize,l=r.indexArgs.length>0,u=[],c=0;c0;){"].join("")),u.push(["if(j",c,"<",s,"){"].join("")),u.push(["s",e[c],"=j",c].join("")),u.push(["j",c,"=0"].join("")),u.push(["}else{s",e[c],"=",s].join("")),u.push(["j",c,"-=",s,"}"].join("")),l&&u.push(["index[",e[c],"]=j",c].join(""));for(var c=0;c0&&(r=r&&e[n]===e[n-1])}return r?e[0]:e.join("")}function l(t,e){for(var r=e[1].length-Math.abs(t.arrayBlockIndices[0])|0,l=new Array(t.arrayArgs.length),c=new Array(t.arrayArgs.length),f=0;f0&&_.push("shape=SS.slice(0)"),t.indexArgs.length>0){for(var w=new Array(r),f=0;f3&&x.push(o(t.pre,t,c));var E=o(t.body,t,c),T=a(v);T3&&x.push(o(t.post,t,c)),t.debug&&console.log("-----Generated cwise routine for ",e,":\n"+x.join("\n")+"\n----------");var L=[t.funcName||"unnamed","_cwise_loop_",l[0].join("s"),"m",T,s(c)].join(""),S=new Function(["function ",L,"(",b.join(","),"){",x.join("\n"),"} return ",L].join(""));return S()}var u=t("uniq");e.exports=l},{uniq:164}],52:[function(t,e,r){"use strict";function n(t){var e=["'use strict'","var CACHED={}"],r=[],n=t.funcName+"_cwise_thunk";e.push(["return function ",n,"(",t.shimArgs.join(","),"){"].join(""));for(var a=[],o=[],s=[["array",t.arrayArgs[0],".shape.slice(",Math.max(0,t.arrayBlockIndices[0]),t.arrayBlockIndices[0]<0?","+t.arrayBlockIndices[0]+")":")"].join("")],l=[],u=[],c=0;c0&&(l.push("array"+t.arrayArgs[0]+".shape.length===array"+f+".shape.length+"+(Math.abs(t.arrayBlockIndices[0])-Math.abs(t.arrayBlockIndices[c]))),u.push("array"+t.arrayArgs[0]+".shape[shapeIndex+"+Math.max(0,t.arrayBlockIndices[0])+"]===array"+f+".shape[shapeIndex+"+Math.max(0,t.arrayBlockIndices[c])+"]"))}t.arrayArgs.length>1&&(e.push("if (!("+l.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same dimensionality!')"),e.push("for(var shapeIndex=array"+t.arrayArgs[0]+".shape.length-"+Math.abs(t.arrayBlockIndices[0])+"; shapeIndex-->0;) {"),e.push("if (!("+u.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same shape!')"),e.push("}"));for(var c=0;ce?1:t>=e?0:NaN}function a(t){return null===t?NaN:+t}function o(t){return!isNaN(t)}function s(t){return{left:function(e,r,n,i){for(arguments.length<3&&(n=0),arguments.length<4&&(i=e.length);n>>1;t(e[a],r)<0?n=a+1:i=a}return n},right:function(e,r,n,i){for(arguments.length<3&&(n=0),arguments.length<4&&(i=e.length);n>>1;t(e[a],r)>0?i=a:n=a+1}return n}}}function l(t){return t.length}function u(t){for(var e=1;t*e%1;)e*=10;return e}function c(t,e){for(var r in e)Object.defineProperty(t.prototype,r,{value:e[r],enumerable:!1})}function f(){this._=Object.create(null)}function h(t){return(t+="")===_o||t[0]===wo?wo+t:t}function d(t){return(t+="")[0]===wo?t.slice(1):t}function p(t){return h(t)in this._}function g(t){return(t=h(t))in this._&&delete this._[t]}function v(){var t=[];for(var e in this._)t.push(d(e));return t}function m(){var t=0;for(var e in this._)++t;return t}function y(){for(var t in this._)return!1;return!0}function b(){this._=Object.create(null)}function x(t){return t}function _(t,e,r){return function(){var n=r.apply(e,arguments);return n===e?t:n}}function w(t,e){if(e in t)return e;e=e.charAt(0).toUpperCase()+e.slice(1);for(var r=0,n=Ao.length;r=e&&(e=i+1);!(o=s[e])&&++e0&&(t=t.slice(0,s));var u=Po.get(t);return u&&(t=u,l=Q),s?e?i:n:e?A:a}function Z(t,e){return function(r){var n=uo.event;uo.event=r,e[0]=this.__data__;try{t.apply(this,e)}finally{uo.event=n}}}function Q(t,e){var r=Z(t,e);return function(t){var e=this,n=t.relatedTarget;n&&(n===e||8&n.compareDocumentPosition(e))||r.call(e,t)}}function $(t){var r=".dragsuppress-"+ ++No,i="click"+r,a=uo.select(n(t)).on("touchmove"+r,E).on("dragstart"+r,E).on("selectstart"+r,E);if(null==Oo&&(Oo=!("onselectstart"in t)&&w(t.style,"userSelect")),Oo){var o=e(t).style,s=o[Oo];o[Oo]="none"}return function(t){if(a.on(r,null),Oo&&(o[Oo]=s),t){var e=function(){a.on(i,null)};a.on(i,function(){E(),e()},!0),setTimeout(e,0)}}}function K(t,e){e.changedTouches&&(e=e.changedTouches[0]);var r=t.ownerSVGElement||t;if(r.createSVGPoint){var i=r.createSVGPoint();if(zo<0){var a=n(t);if(a.scrollX||a.scrollY){r=uo.select("body").append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important");var o=r[0][0].getScreenCTM();zo=!(o.f||o.e),r.remove()}}return zo?(i.x=e.pageX,i.y=e.pageY):(i.x=e.clientX,i.y=e.clientY),i=i.matrixTransform(t.getScreenCTM().inverse()),[i.x,i.y]}var s=t.getBoundingClientRect();return[e.clientX-s.left-t.clientLeft,e.clientY-s.top-t.clientTop]}function J(){return uo.event.changedTouches[0].identifier}function tt(t){return t>0?1:t<0?-1:0}function et(t,e,r){return(e[0]-t[0])*(r[1]-t[1])-(e[1]-t[1])*(r[0]-t[0])}function rt(t){return t>1?0:t<-1?Bo:Math.acos(t)}function nt(t){return t>1?Vo:t<-1?-Vo:Math.asin(t)}function it(t){return((t=Math.exp(t))-1/t)/2}function at(t){return((t=Math.exp(t))+1/t)/2}function ot(t){return((t=Math.exp(2*t))-1)/(t+1)}function st(t){return(t=Math.sin(t/2))*t}function lt(){}function ut(t,e,r){return this instanceof ut?(this.h=+t,this.s=+e,void(this.l=+r)):arguments.length<2?t instanceof ut?new ut(t.h,t.s,t.l):At(""+t,kt,ut):new ut(t,e,r)}function ct(t,e,r){function n(t){return t>360?t-=360:t<0&&(t+=360),t<60?a+(o-a)*t/60:t<180?o:t<240?a+(o-a)*(240-t)/60:a}function i(t){return Math.round(255*n(t))}var a,o;return t=isNaN(t)?0:(t%=360)<0?t+360:t,e=isNaN(e)?0:e<0?0:e>1?1:e,r=r<0?0:r>1?1:r,o=r<=.5?r*(1+e):r+e-r*e,a=2*r-o,new bt(i(t+120),i(t),i(t-120))}function ft(t,e,r){return this instanceof ft?(this.h=+t,this.c=+e,void(this.l=+r)):arguments.length<2?t instanceof ft?new ft(t.h,t.c,t.l):t instanceof dt?gt(t.l,t.a,t.b):gt((t=Mt((t=uo.rgb(t)).r,t.g,t.b)).l,t.a,t.b):new ft(t,e,r)}function ht(t,e,r){return isNaN(t)&&(t=0),isNaN(e)&&(e=0),new dt(r,Math.cos(t*=qo)*e,Math.sin(t)*e)}function dt(t,e,r){return this instanceof dt?(this.l=+t,this.a=+e,void(this.b=+r)):arguments.length<2?t instanceof dt?new dt(t.l,t.a,t.b):t instanceof ft?ht(t.h,t.c,t.l):Mt((t=bt(t)).r,t.g,t.b):new dt(t,e,r)}function pt(t,e,r){var n=(t+16)/116,i=n+e/500,a=n-r/200;return i=vt(i)*ts,n=vt(n)*es,a=vt(a)*rs,new bt(yt(3.2404542*i-1.5371385*n-.4985314*a),yt(-.969266*i+1.8760108*n+.041556*a),yt(.0556434*i-.2040259*n+1.0572252*a))}function gt(t,e,r){return t>0?new ft(Math.atan2(r,e)*Ho,Math.sqrt(e*e+r*r),t):new ft(NaN,NaN,t)}function vt(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function mt(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function yt(t){return Math.round(255*(t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}function bt(t,e,r){return this instanceof bt?(this.r=~~t,this.g=~~e,void(this.b=~~r)):arguments.length<2?t instanceof bt?new bt(t.r,t.g,t.b):At(""+t,bt,ct):new bt(t,e,r)}function xt(t){return new bt(t>>16,t>>8&255,255&t)}function _t(t){return xt(t)+""}function wt(t){return t<16?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function At(t,e,r){var n,i,a,o=0,s=0,l=0;if(n=/([a-z]+)\((.*)\)/.exec(t=t.toLowerCase()))switch(i=n[2].split(","),n[1]){case"hsl":return r(parseFloat(i[0]),parseFloat(i[1])/100,parseFloat(i[2])/100);case"rgb":return e(Tt(i[0]),Tt(i[1]),Tt(i[2]))}return(a=as.get(t))?e(a.r,a.g,a.b):(null==t||"#"!==t.charAt(0)||isNaN(a=parseInt(t.slice(1),16))||(4===t.length?(o=(3840&a)>>4,o=o>>4|o,s=240&a,s=s>>4|s,l=15&a,l=l<<4|l):7===t.length&&(o=(16711680&a)>>16,s=(65280&a)>>8,l=255&a)),e(o,s,l))}function kt(t,e,r){var n,i,a=Math.min(t/=255,e/=255,r/=255),o=Math.max(t,e,r),s=o-a,l=(o+a)/2;return s?(i=l<.5?s/(o+a):s/(2-o-a),n=t==o?(e-r)/s+(e0&&l<1?0:n),new ut(n,i,l)}function Mt(t,e,r){t=Et(t),e=Et(e),r=Et(r);var n=mt((.4124564*t+.3575761*e+.1804375*r)/ts),i=mt((.2126729*t+.7151522*e+.072175*r)/es),a=mt((.0193339*t+.119192*e+.9503041*r)/rs);return dt(116*i-16,500*(n-i),200*(i-a))}function Et(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Tt(t){var e=parseFloat(t);return"%"===t.charAt(t.length-1)?Math.round(2.55*e):e}function Lt(t){return"function"==typeof t?t:function(){return t}}function St(t){return function(e,r,n){return 2===arguments.length&&"function"==typeof r&&(n=r,r=null),Ct(e,r,t,n)}}function Ct(t,e,r,n){function i(){var t,e=l.status;if(!e&&It(l)||e>=200&&e<300||304===e){try{t=r.call(a,l)}catch(t){return void o.error.call(a,t)}o.load.call(a,t)}else o.error.call(a,l)}var a={},o=uo.dispatch("beforesend","progress","load","error"),s={},l=new XMLHttpRequest,u=null;return!this.XDomainRequest||"withCredentials"in l||!/^(http(s)?:)?\/\//.test(t)||(l=new XDomainRequest),"onload"in l?l.onload=l.onerror=i:l.onreadystatechange=function(){l.readyState>3&&i()},l.onprogress=function(t){var e=uo.event;uo.event=t;try{o.progress.call(a,l)}finally{uo.event=e}},a.header=function(t,e){return t=(t+"").toLowerCase(),arguments.length<2?s[t]:(null==e?delete s[t]:s[t]=e+"",a)},a.mimeType=function(t){return arguments.length?(e=null==t?null:t+"",a):e},a.responseType=function(t){return arguments.length?(u=t,a):u},a.response=function(t){return r=t,a},["get","post"].forEach(function(t){a[t]=function(){return a.send.apply(a,[t].concat(fo(arguments)))}}),a.send=function(r,n,i){if(2===arguments.length&&"function"==typeof n&&(i=n,n=null),l.open(r,t,!0),null==e||"accept"in s||(s.accept=e+",*/*"),l.setRequestHeader)for(var c in s)l.setRequestHeader(c,s[c]);return null!=e&&l.overrideMimeType&&l.overrideMimeType(e),null!=u&&(l.responseType=u),null!=i&&a.on("error",i).on("load",function(t){i(null,t)}),o.beforesend.call(a,l),l.send(null==n?null:n),a},a.abort=function(){return l.abort(),a},uo.rebind(a,o,"on"),null==n?a:a.get(Rt(n))}function Rt(t){return 1===t.length?function(e,r){t(null==e?r:null)}:t}function It(t){var e=t.responseType;return e&&"text"!==e?t.response:t.responseText}function Pt(t,e,r){var n=arguments.length;n<2&&(e=0),n<3&&(r=Date.now());var i=r+e,a={c:t,t:i,n:null};return ss?ss.n=a:os=a,ss=a,ls||(us=clearTimeout(us),ls=1,cs(Ot)),a}function Ot(){var t=Nt(),e=zt()-t;e>24?(isFinite(e)&&(clearTimeout(us),us=setTimeout(Ot,e)),ls=0):(ls=1,cs(Ot))}function Nt(){for(var t=Date.now(),e=os;e;)t>=e.t&&e.c(t-e.t)&&(e.c=null),e=e.n;return t}function zt(){for(var t,e=os,r=1/0;e;)e.c?(e.t8?function(t){return t/r}:function(t){return t*r},symbol:t}}function Bt(t){var e=t.decimal,r=t.thousands,n=t.grouping,i=t.currency,a=n&&r?function(t,e){for(var i=t.length,a=[],o=0,s=n[0],l=0;i>0&&s>0&&(l+s+1>e&&(s=Math.max(1,e-l)),a.push(t.substring(i-=s,i+s)),!((l+=s+1)>e));)s=n[o=(o+1)%n.length];return a.reverse().join(r)}:x;return function(t){var r=hs.exec(t),n=r[1]||" ",o=r[2]||">",s=r[3]||"-",l=r[4]||"",u=r[5],c=+r[6],f=r[7],h=r[8],d=r[9],p=1,g="",v="",m=!1,y=!0;switch(h&&(h=+h.substring(1)),(u||"0"===n&&"="===o)&&(u=n="0",o="="),d){case"n":f=!0,d="g";break;case"%":p=100,v="%",d="f";break;case"p":p=100,v="%",d="r";break;case"b":case"o":case"x":case"X":"#"===l&&(g="0"+d.toLowerCase());case"c":y=!1;case"d":m=!0,h=0;break;case"s":p=-1,d="r"}"$"===l&&(g=i[0],v=i[1]),"r"!=d||h||(d="g"),null!=h&&("g"==d?h=Math.max(1,Math.min(21,h)):"e"!=d&&"f"!=d||(h=Math.max(0,Math.min(20,h)))),d=ds.get(d)||jt;var b=u&&f;return function(t){var r=v;if(m&&t%1)return"";var i=t<0||0===t&&1/t<0?(t=-t,"-"):"-"===s?"":s;if(p<0){var l=uo.formatPrefix(t,h);t=l.scale(t),r=l.symbol+v}else t*=p;t=d(t,h);var x,_,w=t.lastIndexOf(".");if(w<0){var A=y?t.lastIndexOf("e"):-1;A<0?(x=t,_=""):(x=t.substring(0,A),_=t.substring(A))}else x=t.substring(0,w),_=e+t.substring(w+1);!u&&f&&(x=a(x,1/0));var k=g.length+x.length+_.length+(b?0:i.length),M=k"===o?M+i+t:"^"===o?M.substring(0,k>>=1)+i+t+M.substring(k):i+(b?t:M+t))+r}}}function jt(t){return t+""}function Ut(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}function Vt(t,e,r){function n(e){var r=t(e),n=a(r,1);return e-r1)for(;o=u)return-1;if(i=e.charCodeAt(s++),37===i){if(o=e.charAt(s++),a=S[o in ms?e.charAt(s++):o],!a||(n=a(t,r,n))<0)return-1}else if(i!=r.charCodeAt(n++))return-1}return n}function n(t,e,r){w.lastIndex=0;var n=w.exec(e.slice(r));return n?(t.w=A.get(n[0].toLowerCase()),r+n[0].length):-1}function i(t,e,r){x.lastIndex=0;var n=x.exec(e.slice(r));return n?(t.w=_.get(n[0].toLowerCase()),r+n[0].length):-1}function a(t,e,r){E.lastIndex=0;var n=E.exec(e.slice(r));return n?(t.m=T.get(n[0].toLowerCase()),r+n[0].length):-1}function o(t,e,r){k.lastIndex=0;var n=k.exec(e.slice(r));return n?(t.m=M.get(n[0].toLowerCase()),r+n[0].length):-1}function s(t,e,n){return r(t,L.c.toString(),e,n)}function l(t,e,n){return r(t,L.x.toString(),e,n)}function u(t,e,n){return r(t,L.X.toString(),e,n)}function c(t,e,r){var n=b.get(e.slice(r,r+=2).toLowerCase());return null==n?-1:(t.p=n,r)}var f=t.dateTime,h=t.date,d=t.time,p=t.periods,g=t.days,v=t.shortDays,m=t.months,y=t.shortMonths;e.utc=function(t){function r(t){try{gs=Ut;var e=new gs;return e._=t,n(e)}finally{gs=Date}}var n=e(t);return r.parse=function(t){try{gs=Ut;var e=n.parse(t);return e&&e._}finally{gs=Date}},r.toString=n.toString,r},e.multi=e.utc.multi=ce;var b=uo.map(),x=Xt(g),_=Yt(g),w=Xt(v),A=Yt(v),k=Xt(m),M=Yt(m),E=Xt(y),T=Yt(y);p.forEach(function(t,e){b.set(t.toLowerCase(),e)});var L={a:function(t){return v[t.getDay()]},A:function(t){return g[t.getDay()]},b:function(t){return y[t.getMonth()]},B:function(t){return m[t.getMonth()]},c:e(f),d:function(t,e){return Gt(t.getDate(),e,2)},e:function(t,e){return Gt(t.getDate(),e,2)},H:function(t,e){return Gt(t.getHours(),e,2)},I:function(t,e){return Gt(t.getHours()%12||12,e,2)},j:function(t,e){return Gt(1+ps.dayOfYear(t),e,3)},L:function(t,e){return Gt(t.getMilliseconds(),e,3)},m:function(t,e){return Gt(t.getMonth()+1,e,2)},M:function(t,e){return Gt(t.getMinutes(),e,2)},p:function(t){return p[+(t.getHours()>=12)]},S:function(t,e){return Gt(t.getSeconds(),e,2)},U:function(t,e){return Gt(ps.sundayOfYear(t),e,2)},w:function(t){return t.getDay()},W:function(t,e){return Gt(ps.mondayOfYear(t),e,2)},x:e(h),X:e(d),y:function(t,e){return Gt(t.getFullYear()%100,e,2)},Y:function(t,e){return Gt(t.getFullYear()%1e4,e,4)},Z:le,"%":function(){return"%"}},S={a:n,A:i,b:a,B:o,c:s,d:re,e:re,H:ie,I:ie,j:ne,L:se,m:ee,M:ae,p:c,S:oe,U:Zt,w:Wt,W:Qt,x:l,X:u,y:Kt,Y:$t,Z:Jt,"%":ue};return e}function Gt(t,e,r){var n=t<0?"-":"",i=(n?-t:t)+"",a=i.length;return n+(a68?1900:2e3)}function ee(t,e,r){ys.lastIndex=0;var n=ys.exec(e.slice(r,r+2));return n?(t.m=n[0]-1,r+n[0].length):-1}function re(t,e,r){ys.lastIndex=0;var n=ys.exec(e.slice(r,r+2));return n?(t.d=+n[0],r+n[0].length):-1}function ne(t,e,r){ys.lastIndex=0;var n=ys.exec(e.slice(r,r+3));return n?(t.j=+n[0],r+n[0].length):-1}function ie(t,e,r){ys.lastIndex=0;var n=ys.exec(e.slice(r,r+2));return n?(t.H=+n[0],r+n[0].length):-1}function ae(t,e,r){ys.lastIndex=0;var n=ys.exec(e.slice(r,r+2));return n?(t.M=+n[0],r+n[0].length):-1}function oe(t,e,r){ys.lastIndex=0;var n=ys.exec(e.slice(r,r+2));return n?(t.S=+n[0],r+n[0].length):-1}function se(t,e,r){ys.lastIndex=0;var n=ys.exec(e.slice(r,r+3));return n?(t.L=+n[0],r+n[0].length):-1}function le(t){var e=t.getTimezoneOffset(),r=e>0?"-":"+",n=xo(e)/60|0,i=xo(e)%60;return r+Gt(n,"0",2)+Gt(i,"0",2)}function ue(t,e,r){bs.lastIndex=0;var n=bs.exec(e.slice(r,r+1));return n?r+n[0].length:-1}function ce(t){for(var e=t.length,r=-1;++r=0?1:-1,s=o*r,l=Math.cos(e),u=Math.sin(e),c=a*u,f=i*l+c*Math.cos(s),h=c*o*Math.sin(s);Ms.add(Math.atan2(h,f)),n=t,i=l,a=u}var e,r,n,i,a;Es.point=function(o,s){Es.point=t,n=(e=o)*qo,i=Math.cos(s=(r=s)*qo/2+Bo/4),a=Math.sin(s)},Es.lineEnd=function(){t(e,r)}}function me(t){var e=t[0],r=t[1],n=Math.cos(r);return[n*Math.cos(e),n*Math.sin(e),Math.sin(r)]}function ye(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function be(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function xe(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function _e(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function we(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function Ae(t){return[Math.atan2(t[1],t[0]),nt(t[2])]}function ke(t,e){return xo(t[0]-e[0])=0;--s)i.point((f=c[s])[0],f[1])}else n(d.x,d.p.x,-1,i);d=d.p}d=d.o,c=d.z,p=!p}while(!d.v);i.lineEnd()}}}function Pe(t){if(e=t.length){for(var e,r,n=0,i=t[0];++n0){for(_||(a.polygonStart(),_=!0),a.lineStart();++o1&&2&e&&r.push(r.pop().concat(r.shift())),d.push(r.filter(ze))}var d,p,g,v=e(a),m=i.invert(n[0],n[1]),y={point:o,lineStart:l,lineEnd:u,polygonStart:function(){y.point=c,y.lineStart=f,y.lineEnd=h,d=[],p=[]},polygonEnd:function(){y.point=o,y.lineStart=l,y.lineEnd=u,d=uo.merge(d);var t=Ve(m,p);d.length?(_||(a.polygonStart(),_=!0),Ie(d,Fe,t,r,a)):t&&(_||(a.polygonStart(),_=!0),a.lineStart(),r(null,null,1,a),a.lineEnd()),_&&(a.polygonEnd(),_=!1),d=p=null},sphere:function(){a.polygonStart(),a.lineStart(),r(null,null,1,a),a.lineEnd(),a.polygonEnd()}},b=De(),x=e(b),_=!1;return y}}function ze(t){return t.length>1}function De(){var t,e=[];return{lineStart:function(){e.push(t=[])},point:function(e,r){t.push([e,r])},lineEnd:A,buffer:function(){var r=e;return e=[],t=null,r},rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))}}}function Fe(t,e){return((t=t.x)[0]<0?t[1]-Vo-Do:Vo-t[1])-((e=e.x)[0]<0?e[1]-Vo-Do:Vo-e[1])}function Be(t){var e,r=NaN,n=NaN,i=NaN; ++return{lineStart:function(){t.lineStart(),e=1},point:function(a,o){var s=a>0?Bo:-Bo,l=xo(a-r);xo(l-Bo)0?Vo:-Vo),t.point(i,n),t.lineEnd(),t.lineStart(),t.point(s,n),t.point(a,n),e=0):i!==s&&l>=Bo&&(xo(r-i)Do?Math.atan((Math.sin(e)*(a=Math.cos(n))*Math.sin(r)-Math.sin(n)*(i=Math.cos(e))*Math.sin(t))/(i*a*o)):(e+n)/2}function Ue(t,e,r,n){var i;if(null==t)i=r*Vo,n.point(-Bo,i),n.point(0,i),n.point(Bo,i),n.point(Bo,0),n.point(Bo,-i),n.point(0,-i),n.point(-Bo,-i),n.point(-Bo,0),n.point(-Bo,i);else if(xo(t[0]-e[0])>Do){var a=t[0]=0?1:-1,A=w*_,k=A>Bo,M=p*b;if(Ms.add(Math.atan2(M*w*Math.sin(A),g*x+M*Math.cos(A))),a+=k?_+w*jo:_,k^h>=r^m>=r){var E=be(me(f),me(t));we(E);var T=be(i,E);we(T);var L=(k^_>=0?-1:1)*nt(T[2]);(n>L||n===L&&(E[0]||E[1]))&&(o+=k^_>=0?1:-1)}if(!v++)break;h=m,p=b,g=x,f=t}}return(a<-Do||aa}function r(t){var r,a,l,u,c;return{lineStart:function(){u=l=!1,c=1},point:function(f,h){var d,p=[f,h],g=e(f,h),v=o?g?0:i(f,h):g?i(f+(f<0?Bo:-Bo),h):0;if(!r&&(u=l=g)&&t.lineStart(),g!==l&&(d=n(r,p),(ke(r,d)||ke(p,d))&&(p[0]+=Do,p[1]+=Do,g=e(p[0],p[1]))),g!==l)c=0,g?(t.lineStart(),d=n(p,r),t.point(d[0],d[1])):(d=n(r,p),t.point(d[0],d[1]),t.lineEnd()),r=d;else if(s&&r&&o^g){var m;v&a||!(m=n(p,r,!0))||(c=0,o?(t.lineStart(),t.point(m[0][0],m[0][1]),t.point(m[1][0],m[1][1]),t.lineEnd()):(t.point(m[1][0],m[1][1]),t.lineEnd(),t.lineStart(),t.point(m[0][0],m[0][1])))}!g||r&&ke(r,p)||t.point(p[0],p[1]),r=p,l=g,a=v},lineEnd:function(){l&&t.lineEnd(),r=null},clean:function(){return c|(u&&l)<<1}}}function n(t,e,r){var n=me(t),i=me(e),o=[1,0,0],s=be(n,i),l=ye(s,s),u=s[0],c=l-u*u;if(!c)return!r&&t;var f=a*l/c,h=-a*u/c,d=be(o,s),p=_e(o,f),g=_e(s,h);xe(p,g);var v=d,m=ye(p,v),y=ye(v,v),b=m*m-y*(ye(p,p)-1);if(!(b<0)){var x=Math.sqrt(b),_=_e(v,(-m-x)/y);if(xe(_,p),_=Ae(_),!r)return _;var w,A=t[0],k=e[0],M=t[1],E=e[1];k0^_[1]<(xo(_[0]-A)Bo^(A<=_[0]&&_[0]<=k)){var C=_e(v,(-m+x)/y);return xe(C,p),[_,Ae(C)]}}}function i(e,r){var n=o?t:Bo-t,i=0;return e<-n?i|=1:e>n&&(i|=2),r<-n?i|=4:r>n&&(i|=8),i}var a=Math.cos(t),o=a>0,s=xo(a)>Do,l=vr(t,6*qo);return Ne(e,r,l,o?[0,-t]:[-Bo,t-Bo])}function He(t,e,r,n){return function(i){var a,o=i.a,s=i.b,l=o.x,u=o.y,c=s.x,f=s.y,h=0,d=1,p=c-l,g=f-u;if(a=t-l,p||!(a>0)){if(a/=p,p<0){if(a0){if(a>d)return;a>h&&(h=a)}if(a=r-l,p||!(a<0)){if(a/=p,p<0){if(a>d)return;a>h&&(h=a)}else if(p>0){if(a0)){if(a/=g,g<0){if(a0){if(a>d)return;a>h&&(h=a)}if(a=n-u,g||!(a<0)){if(a/=g,g<0){if(a>d)return;a>h&&(h=a)}else if(g>0){if(a0&&(i.a={x:l+h*p,y:u+h*g}),d<1&&(i.b={x:l+d*p,y:u+d*g}),i}}}}}}function Ge(t,e,r,n){function i(n,i){return xo(n[0]-t)0?0:3:xo(n[0]-r)0?2:1:xo(n[1]-e)0?1:0:i>0?3:2}function a(t,e){return o(t.x,e.x)}function o(t,e){var r=i(t,1),n=i(e,1);return r!==n?r-n:0===r?e[1]-t[1]:1===r?t[0]-e[0]:2===r?t[1]-e[1]:e[0]-t[0]}return function(s){function l(t){for(var e=0,r=v.length,n=t[1],i=0;in&&et(u,a,t)>0&&++e:a[1]<=n&&et(u,a,t)<0&&--e,u=a;return 0!==e}function u(a,s,l,u){var c=0,f=0;if(null==a||(c=i(a,l))!==(f=i(s,l))||o(a,s)<0^l>0){do u.point(0===c||3===c?t:r,c>1?n:e);while((c=(c+l+4)%4)!==f)}else u.point(s[0],s[1])}function c(i,a){return t<=i&&i<=r&&e<=a&&a<=n}function f(t,e){c(t,e)&&s.point(t,e)}function h(){S.point=p,v&&v.push(m=[]),k=!0,A=!1,_=w=NaN}function d(){g&&(p(y,b),x&&A&&T.rejoin(),g.push(T.buffer())),S.point=f,A&&s.lineEnd()}function p(t,e){t=Math.max(-js,Math.min(js,t)),e=Math.max(-js,Math.min(js,e));var r=c(t,e);if(v&&m.push([t,e]),k)y=t,b=e,x=r,k=!1,r&&(s.lineStart(),s.point(t,e));else if(r&&A)s.point(t,e);else{var n={a:{x:_,y:w},b:{x:t,y:e}};L(n)?(A||(s.lineStart(),s.point(n.a.x,n.a.y)),s.point(n.b.x,n.b.y),r||s.lineEnd(),M=!1):r&&(s.lineStart(),s.point(t,e),M=!1)}_=t,w=e,A=r}var g,v,m,y,b,x,_,w,A,k,M,E=s,T=De(),L=He(t,e,r,n),S={point:f,lineStart:h,lineEnd:d,polygonStart:function(){s=T,g=[],v=[],M=!0},polygonEnd:function(){s=E,g=uo.merge(g);var e=l([t,n]),r=M&&e,i=g.length;(r||i)&&(s.polygonStart(),r&&(s.lineStart(),u(null,null,1,s),s.lineEnd()),i&&Ie(g,a,e,u,s),s.polygonEnd()),g=v=m=null}};return S}}function Xe(t){var e=0,r=Bo/3,n=lr(t),i=n(e,r);return i.parallels=function(t){return arguments.length?n(e=t[0]*Bo/180,r=t[1]*Bo/180):[e/Bo*180,r/Bo*180]},i}function Ye(t,e){function r(t,e){var r=Math.sqrt(a-2*i*Math.sin(e))/i;return[r*Math.sin(t*=i),o-r*Math.cos(t)]}var n=Math.sin(t),i=(n+Math.sin(e))/2,a=1+n*(2*i-n),o=Math.sqrt(a)/i;return r.invert=function(t,e){var r=o-e;return[Math.atan2(t,r)/i,nt((a-(t*t+r*r)*i*i)/(2*i))]},r}function We(){function t(t,e){Vs+=i*t-n*e,n=t,i=e}var e,r,n,i;Ys.point=function(a,o){Ys.point=t,e=n=a,r=i=o},Ys.lineEnd=function(){t(e,r)}}function Ze(t,e){tGs&&(Gs=t),eXs&&(Xs=e)}function Qe(){function t(t,e){o.push("M",t,",",e,a)}function e(t,e){o.push("M",t,",",e),s.point=r}function r(t,e){o.push("L",t,",",e)}function n(){s.point=t}function i(){o.push("Z")}var a=$e(4.5),o=[],s={point:t,lineStart:function(){s.point=e},lineEnd:n,polygonStart:function(){s.lineEnd=i},polygonEnd:function(){s.lineEnd=n,s.point=t},pointRadius:function(t){return a=$e(t),s},result:function(){if(o.length){var t=o.join("");return o=[],t}}};return s}function $e(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}function Ke(t,e){Ss+=t,Cs+=e,++Rs}function Je(){function t(t,n){var i=t-e,a=n-r,o=Math.sqrt(i*i+a*a);Is+=o*(e+t)/2,Ps+=o*(r+n)/2,Os+=o,Ke(e=t,r=n)}var e,r;Zs.point=function(n,i){Zs.point=t,Ke(e=n,r=i)}}function tr(){Zs.point=Ke}function er(){function t(t,e){var r=t-n,a=e-i,o=Math.sqrt(r*r+a*a);Is+=o*(n+t)/2,Ps+=o*(i+e)/2,Os+=o,o=i*t-n*e,Ns+=o*(n+t),zs+=o*(i+e),Ds+=3*o,Ke(n=t,i=e)}var e,r,n,i;Zs.point=function(a,o){Zs.point=t,Ke(e=n=a,r=i=o)},Zs.lineEnd=function(){t(e,r)}}function rr(t){function e(e,r){t.moveTo(e+o,r),t.arc(e,r,o,0,jo)}function r(e,r){t.moveTo(e,r),s.point=n}function n(e,r){t.lineTo(e,r)}function i(){s.point=e}function a(){t.closePath()}var o=4.5,s={point:e,lineStart:function(){s.point=r},lineEnd:i,polygonStart:function(){s.lineEnd=a},polygonEnd:function(){s.lineEnd=i,s.point=e},pointRadius:function(t){return o=t,s},result:A};return s}function nr(t){function e(t){return(s?n:r)(t)}function r(e){return or(e,function(r,n){r=t(r,n),e.point(r[0],r[1])})}function n(e){function r(r,n){r=t(r,n),e.point(r[0],r[1])}function n(){b=NaN,k.point=a,e.lineStart()}function a(r,n){var a=me([r,n]),o=t(r,n);i(b,x,y,_,w,A,b=o[0],x=o[1],y=r,_=a[0],w=a[1],A=a[2],s,e),e.point(b,x)}function o(){k.point=r,e.lineEnd()}function l(){n(),k.point=u,k.lineEnd=c}function u(t,e){a(f=t,h=e),d=b,p=x,g=_,v=w,m=A,k.point=a}function c(){i(b,x,y,_,w,A,d,p,f,g,v,m,s,e),k.lineEnd=o,o()}var f,h,d,p,g,v,m,y,b,x,_,w,A,k={point:r,lineStart:n,lineEnd:o,polygonStart:function(){e.polygonStart(),k.lineStart=l},polygonEnd:function(){e.polygonEnd(),k.lineStart=n}};return k}function i(e,r,n,s,l,u,c,f,h,d,p,g,v,m){var y=c-e,b=f-r,x=y*y+b*b;if(x>4*a&&v--){var _=s+d,w=l+p,A=u+g,k=Math.sqrt(_*_+w*w+A*A),M=Math.asin(A/=k),E=xo(xo(A)-1)a||xo((y*C+b*R)/x-.5)>.3||s*d+l*p+u*g0&&16,e):Math.sqrt(a)},e}function ir(t){var e=nr(function(e,r){return t([e*Ho,r*Ho])});return function(t){return ur(e(t))}}function ar(t){this.stream=t}function or(t,e){return{point:e,sphere:function(){t.sphere()},lineStart:function(){t.lineStart()},lineEnd:function(){t.lineEnd()},polygonStart:function(){t.polygonStart()},polygonEnd:function(){t.polygonEnd()}}}function sr(t){return lr(function(){return t})()}function lr(t){function e(t){return t=s(t[0]*qo,t[1]*qo),[t[0]*h+l,u-t[1]*h]}function r(t){return t=s.invert((t[0]-l)/h,(u-t[1])/h),t&&[t[0]*Ho,t[1]*Ho]}function n(){s=Ce(o=hr(m,y,b),a);var t=a(g,v);return l=d-t[0]*h,u=p+t[1]*h,i()}function i(){return c&&(c.valid=!1,c=null),e}var a,o,s,l,u,c,f=nr(function(t,e){return t=a(t,e),[t[0]*h+l,u-t[1]*h]}),h=150,d=480,p=250,g=0,v=0,m=0,y=0,b=0,_=Bs,w=x,A=null,k=null;return e.stream=function(t){return c&&(c.valid=!1),c=ur(_(o,f(w(t)))),c.valid=!0,c},e.clipAngle=function(t){return arguments.length?(_=null==t?(A=t,Bs):qe((A=+t)*qo),i()):A},e.clipExtent=function(t){return arguments.length?(k=t,w=t?Ge(t[0][0],t[0][1],t[1][0],t[1][1]):x,i()):k},e.scale=function(t){return arguments.length?(h=+t,n()):h},e.translate=function(t){return arguments.length?(d=+t[0],p=+t[1],n()):[d,p]},e.center=function(t){return arguments.length?(g=t[0]%360*qo,v=t[1]%360*qo,n()):[g*Ho,v*Ho]},e.rotate=function(t){return arguments.length?(m=t[0]%360*qo,y=t[1]%360*qo,b=t.length>2?t[2]%360*qo:0,n()):[m*Ho,y*Ho,b*Ho]},uo.rebind(e,f,"precision"),function(){return a=t.apply(this,arguments),e.invert=a.invert&&r,n()}}function ur(t){return or(t,function(e,r){t.point(e*qo,r*qo)})}function cr(t,e){return[t,e]}function fr(t,e){return[t>Bo?t-jo:t<-Bo?t+jo:t,e]}function hr(t,e,r){return t?e||r?Ce(pr(t),gr(e,r)):pr(t):e||r?gr(e,r):fr}function dr(t){return function(e,r){return e+=t,[e>Bo?e-jo:e<-Bo?e+jo:e,r]}}function pr(t){var e=dr(t);return e.invert=dr(-t),e}function gr(t,e){function r(t,e){var r=Math.cos(e),s=Math.cos(t)*r,l=Math.sin(t)*r,u=Math.sin(e),c=u*n+s*i;return[Math.atan2(l*a-c*o,s*n-u*i),nt(c*a+l*o)]}var n=Math.cos(t),i=Math.sin(t),a=Math.cos(e),o=Math.sin(e);return r.invert=function(t,e){var r=Math.cos(e),s=Math.cos(t)*r,l=Math.sin(t)*r,u=Math.sin(e),c=u*a-l*o;return[Math.atan2(l*a+u*o,s*n+c*i),nt(c*n-s*i)]},r}function vr(t,e){var r=Math.cos(t),n=Math.sin(t);return function(i,a,o,s){var l=o*e;null!=i?(i=mr(r,i),a=mr(r,a),(o>0?ia)&&(i+=o*jo)):(i=t+o*jo,a=t-.5*l);for(var u,c=i;o>0?c>a:c0?e<-Vo+Do&&(e=-Vo+Do):e>Vo-Do&&(e=Vo-Do);var r=o/Math.pow(i(e),a);return[r*Math.sin(a*t),o-r*Math.cos(a*t)]}var n=Math.cos(t),i=function(t){return Math.tan(Bo/4+t/2)},a=t===e?Math.sin(t):Math.log(n/Math.cos(e))/Math.log(i(e)/i(t)),o=n*Math.pow(i(t),a)/a;return a?(r.invert=function(t,e){var r=o-e,n=tt(a)*Math.sqrt(t*t+r*r);return[Math.atan2(t,r)/a,2*Math.atan(Math.pow(o/n,1/a))-Vo]},r):Tr}function Er(t,e){function r(t,e){var r=a-e;return[r*Math.sin(i*t),a-r*Math.cos(i*t)]}var n=Math.cos(t),i=t===e?Math.sin(t):(n-Math.cos(e))/(e-t),a=n/i+t;return xo(i)1&&et(t[r[n-2]],t[r[n-1]],t[i])<=0;)--n;r[n++]=i}return r.slice(0,n)}function Pr(t,e){return t[0]-e[0]||t[1]-e[1]}function Or(t,e,r){return(r[0]-e[0])*(t[1]-e[1])<(r[1]-e[1])*(t[0]-e[0])}function Nr(t,e,r,n){var i=t[0],a=r[0],o=e[0]-i,s=n[0]-a,l=t[1],u=r[1],c=e[1]-l,f=n[1]-u,h=(s*(l-u)-f*(i-a))/(f*o-s*c);return[i+h*o,l+h*c]}function zr(t){var e=t[0],r=t[t.length-1];return!(e[0]-r[0]||e[1]-r[1])}function Dr(){an(this),this.edge=this.site=this.circle=null}function Fr(t){var e=ul.pop()||new Dr;return e.site=t,e}function Br(t){Zr(t),ol.remove(t),ul.push(t),an(t)}function jr(t){var e=t.circle,r=e.x,n=e.cy,i={x:r,y:n},a=t.P,o=t.N,s=[t];Br(t);for(var l=a;l.circle&&xo(r-l.circle.x)Do)s=s.L;else{if(i=a-qr(s,o),!(i>Do)){n>-Do?(e=s.P,r=s):i>-Do?(e=s,r=s.N):e=r=s;break}if(!s.R){e=s;break}s=s.R}var l=Fr(t);if(ol.insert(e,l),e||r){if(e===r)return Zr(e),r=Fr(e.site),ol.insert(l,r),l.edge=r.edge=Jr(e.site,l.site),Wr(e),void Wr(r);if(!r)return void(l.edge=Jr(e.site,l.site));Zr(e),Zr(r);var u=e.site,c=u.x,f=u.y,h=t.x-c,d=t.y-f,p=r.site,g=p.x-c,v=p.y-f,m=2*(h*v-d*g),y=h*h+d*d,b=g*g+v*v,x={x:(v*y-d*b)/m+c,y:(h*b-g*y)/m+f};en(r.edge,u,p,x),l.edge=Jr(u,t,null,x),r.edge=Jr(t,p,null,x),Wr(e),Wr(r)}}function Vr(t,e){var r=t.site,n=r.x,i=r.y,a=i-e;if(!a)return n;var o=t.P;if(!o)return-(1/0);r=o.site;var s=r.x,l=r.y,u=l-e;if(!u)return s;var c=s-n,f=1/a-1/u,h=c/u;return f?(-h+Math.sqrt(h*h-2*f*(c*c/(-2*u)-l+u/2+i-a/2)))/f+n:(n+s)/2}function qr(t,e){var r=t.N;if(r)return Vr(r,e);var n=t.site;return n.y===e?n.x:1/0}function Hr(t){this.site=t,this.edges=[]}function Gr(t){for(var e,r,n,i,a,o,s,l,u,c,f=t[0][0],h=t[1][0],d=t[0][1],p=t[1][1],g=al,v=g.length;v--;)if(a=g[v],a&&a.prepare())for(s=a.edges,l=s.length,o=0;oDo||xo(i-r)>Do)&&(s.splice(o,0,new rn(tn(a.site,c,xo(n-f)Do?{x:f,y:xo(e-f)Do?{x:xo(r-p)Do?{x:h,y:xo(e-h)Do?{x:xo(r-d)=-Fo)){var d=l*l+u*u,p=c*c+f*f,g=(f*d-u*p)/h,v=(l*p-c*d)/h,f=v+s,m=cl.pop()||new Yr;m.arc=t,m.site=i,m.x=g+o,m.y=f+Math.sqrt(g*g+v*v),m.cy=f,t.circle=m;for(var y=null,b=ll._;b;)if(m.y=s)return;if(h>p){if(a){if(a.y>=u)return}else a={x:v,y:l};r={x:v,y:u}}else{if(a){if(a.y1)if(h>p){if(a){if(a.y>=u)return}else a={x:(l-i)/n,y:l};r={x:(u-i)/n,y:u}}else{if(a){if(a.y=s)return}else a={x:o,y:n*o+i};r={x:s,y:n*s+i}}else{if(a){if(a.xa||f>o||h=x,A=r>=_,k=A<<1|w,M=k+4;ka&&(i=e.slice(a,i),s[o]?s[o]+=i:s[++o]=i),(r=r[0])===(n=n[0])?s[o]?s[o]+=n:s[++o]=n:(s[++o]=null,l.push({i:o,x:bn(r,n)})),a=dl.lastIndex;return a=0&&!(r=uo.interpolators[n](t,e)););return r}function wn(t,e){var r,n=[],i=[],a=t.length,o=e.length,s=Math.min(t.length,e.length);for(r=0;r=1?1:t(e)}}function kn(t){return function(e){return 1-t(1-e)}}function Mn(t){return function(e){return.5*(e<.5?t(2*e):2-t(2-2*e))}}function En(t){return t*t}function Tn(t){return t*t*t}function Ln(t){if(t<=0)return 0;if(t>=1)return 1;var e=t*t,r=e*t;return 4*(t<.5?r:3*(t-e)+r-.75)}function Sn(t){return function(e){return Math.pow(e,t)}}function Cn(t){return 1-Math.cos(t*Vo)}function Rn(t){return Math.pow(2,10*(t-1))}function In(t){return 1-Math.sqrt(1-t*t)}function Pn(t,e){var r;return arguments.length<2&&(e=.45),arguments.length?r=e/jo*Math.asin(1/t):(t=1,r=e/4),function(n){return 1+t*Math.pow(2,-10*n)*Math.sin((n-r)*jo/e)}}function On(t){return t||(t=1.70158),function(e){return e*e*((t+1)*e-t)}}function Nn(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}function zn(t,e){t=uo.hcl(t),e=uo.hcl(e);var r=t.h,n=t.c,i=t.l,a=e.h-r,o=e.c-n,s=e.l-i;return isNaN(o)&&(o=0,n=isNaN(n)?e.c:n),isNaN(a)?(a=0,r=isNaN(r)?e.h:r):a>180?a-=360:a<-180&&(a+=360),function(t){return ht(r+a*t,n+o*t,i+s*t)+""}}function Dn(t,e){t=uo.hsl(t),e=uo.hsl(e);var r=t.h,n=t.s,i=t.l,a=e.h-r,o=e.s-n,s=e.l-i;return isNaN(o)&&(o=0,n=isNaN(n)?e.s:n),isNaN(a)?(a=0,r=isNaN(r)?e.h:r):a>180?a-=360:a<-180&&(a+=360),function(t){return ct(r+a*t,n+o*t,i+s*t)+""}}function Fn(t,e){t=uo.lab(t),e=uo.lab(e);var r=t.l,n=t.a,i=t.b,a=e.l-r,o=e.a-n,s=e.b-i;return function(t){return pt(r+a*t,n+o*t,i+s*t)+""}}function Bn(t,e){return e-=t,function(r){return Math.round(t+e*r)}}function jn(t){var e=[t.a,t.b],r=[t.c,t.d],n=Vn(e),i=Un(e,r),a=Vn(qn(r,e,-i))||0;e[0]*r[1]180?e+=360:e-t>180&&(t+=360),n.push({i:r.push(Hn(r)+"rotate(",null,")")-2,x:bn(t,e)})):e&&r.push(Hn(r)+"rotate("+e+")")}function Yn(t,e,r,n){t!==e?n.push({i:r.push(Hn(r)+"skewX(",null,")")-2,x:bn(t,e)}):e&&r.push(Hn(r)+"skewX("+e+")")}function Wn(t,e,r,n){if(t[0]!==e[0]||t[1]!==e[1]){var i=r.push(Hn(r)+"scale(",null,",",null,")");n.push({i:i-4,x:bn(t[0],e[0])},{i:i-2,x:bn(t[1],e[1])})}else 1===e[0]&&1===e[1]||r.push(Hn(r)+"scale("+e+")")}function Zn(t,e){var r=[],n=[];return t=uo.transform(t),e=uo.transform(e),Gn(t.translate,e.translate,r,n),Xn(t.rotate,e.rotate,r,n),Yn(t.skew,e.skew,r,n),Wn(t.scale,e.scale,r,n),t=e=null,function(t){for(var e,i=-1,a=n.length;++i=0;)r.push(i[n])}function li(t,e){for(var r=[t],n=[];null!=(t=r.pop());)if(n.push(t),(a=t.children)&&(i=a.length))for(var i,a,o=-1;++oi&&(n=r,i=e);return n}function bi(t){return t.reduce(xi,0)}function xi(t,e){return t+e[1]}function _i(t,e){return wi(t,Math.ceil(Math.log(e.length)/Math.LN2+1))}function wi(t,e){for(var r=-1,n=+t[0],i=(t[1]-n)/e,a=[];++r<=e;)a[r]=i*r+n;return a}function Ai(t){return[uo.min(t),uo.max(t)]}function ki(t,e){return t.value-e.value}function Mi(t,e){var r=t._pack_next;t._pack_next=e,e._pack_prev=t,e._pack_next=r,r._pack_prev=e}function Ei(t,e){t._pack_next=e,e._pack_prev=t}function Ti(t,e){var r=e.x-t.x,n=e.y-t.y,i=t.r+e.r;return.999*i*i>r*r+n*n}function Li(t){function e(t){c=Math.min(t.x-t.r,c),f=Math.max(t.x+t.r,f),h=Math.min(t.y-t.r,h),d=Math.max(t.y+t.r,d)}if((r=t.children)&&(u=r.length)){var r,n,i,a,o,s,l,u,c=1/0,f=-(1/0),h=1/0,d=-(1/0);if(r.forEach(Si),n=r[0],n.x=-n.r,n.y=0,e(n),u>1&&(i=r[1],i.x=i.r,i.y=0,e(i),u>2))for(a=r[2],Ii(n,i,a),e(a),Mi(n,a),n._pack_prev=a,Mi(a,i),i=n._pack_next,o=3;o=0;)e=i[a],e.z+=r,e.m+=r,r+=e.s+(n+=e.c)}function Fi(t,e,r){return t.a.parent===e.parent?t.a:r}function Bi(t){return 1+uo.max(t,function(t){return t.y})}function ji(t){return t.reduce(function(t,e){return t+e.x},0)/t.length}function Ui(t){var e=t.children;return e&&e.length?Ui(e[0]):t}function Vi(t){var e,r=t.children;return r&&(e=r.length)?Vi(r[e-1]):t}function qi(t){return{x:t.x,y:t.y,dx:t.dx,dy:t.dy}}function Hi(t,e){var r=t.x+e[3],n=t.y+e[0],i=t.dx-e[1]-e[3],a=t.dy-e[0]-e[2];return i<0&&(r+=i/2,i=0),a<0&&(n+=a/2,a=0),{x:r,y:n,dx:i,dy:a}}function Gi(t){var e=t[0],r=t[t.length-1];return e2?Qi:Yi,l=n?$n:Qn;return o=i(t,e,l,r),s=i(e,t,l,_n),a}function a(t){return o(t)}var o,s;return a.invert=function(t){return s(t)},a.domain=function(e){return arguments.length?(t=e.map(Number),i()):t},a.range=function(t){return arguments.length?(e=t,i()):e},a.rangeRound=function(t){return a.range(t).interpolate(Bn)},a.clamp=function(t){return arguments.length?(n=t,i()):n},a.interpolate=function(t){return arguments.length?(r=t,i()):r},a.ticks=function(e){return ea(t,e)},a.tickFormat=function(e,r){return ra(t,e,r)},a.nice=function(e){return Ji(t,e),i()},a.copy=function(){return $i(t,e,r,n)},i()}function Ki(t,e){return uo.rebind(t,e,"range","rangeRound","interpolate","clamp")}function Ji(t,e){return Wi(t,Zi(ta(t,e)[2])),Wi(t,Zi(ta(t,e)[2])),t}function ta(t,e){null==e&&(e=10);var r=Gi(t),n=r[1]-r[0],i=Math.pow(10,Math.floor(Math.log(n/e)/Math.LN10)),a=e/n*i;return a<=.15?i*=10:a<=.35?i*=5:a<=.75&&(i*=2),r[0]=Math.ceil(r[0]/i)*i,r[1]=Math.floor(r[1]/i)*i+.5*i,r[2]=i,r}function ea(t,e){return uo.range.apply(uo,ta(t,e))}function ra(t,e,r){var n=ta(t,e);if(r){var i=hs.exec(r);if(i.shift(),"s"===i[8]){var a=uo.formatPrefix(Math.max(xo(n[0]),xo(n[1])));return i[7]||(i[7]="."+na(a.scale(n[2]))),i[8]="f",r=uo.format(i.join("")),function(t){return r(a.scale(t))+a.symbol}}i[7]||(i[7]="."+ia(i[8],n)),r=i.join("")}else r=",."+na(n[2])+"f";return uo.format(r)}function na(t){return-Math.floor(Math.log(t)/Math.LN10+.01)}function ia(t,e){var r=na(e[2]);return t in Ml?Math.abs(r-na(Math.max(xo(e[0]),xo(e[1]))))+ +("e"!==t):r-2*("%"===t)}function aa(t,e,r,n){function i(t){return(r?Math.log(t<0?0:t):-Math.log(t>0?0:-t))/Math.log(e)}function a(t){return r?Math.pow(e,t):-Math.pow(e,-t)}function o(e){return t(i(e))}return o.invert=function(e){return a(t.invert(e))},o.domain=function(e){return arguments.length?(r=e[0]>=0,t.domain((n=e.map(Number)).map(i)),o):n},o.base=function(r){return arguments.length?(e=+r,t.domain(n.map(i)),o):e},o.nice=function(){var e=Wi(n.map(i),r?Math:Tl);return t.domain(e),n=e.map(a),o},o.ticks=function(){var t=Gi(n),o=[],s=t[0],l=t[1],u=Math.floor(i(s)),c=Math.ceil(i(l)),f=e%1?2:e;if(isFinite(c-u)){if(r){for(;u0;h--)o.push(a(u)*h);for(u=0;o[u]l;c--);o=o.slice(u,c)}return o},o.tickFormat=function(t,r){if(!arguments.length)return El;arguments.length<2?r=El:"function"!=typeof r&&(r=uo.format(r));var n=Math.max(1,e*t/o.ticks().length);return function(t){var o=t/a(Math.round(i(t)));return o*e0?s[r-1]:t[0],r0?0:1}function xa(t,e,r,n,i){var a=t[0]-e[0],o=t[1]-e[1],s=(i?n:-n)/Math.sqrt(a*a+o*o),l=s*o,u=-s*a,c=t[0]+l,f=t[1]+u,h=e[0]+l,d=e[1]+u,p=(c+h)/2,g=(f+d)/2,v=h-c,m=d-f,y=v*v+m*m,b=r-n,x=c*d-h*f,_=(m<0?-1:1)*Math.sqrt(Math.max(0,b*b*y-x*x)),w=(x*m-v*_)/y,A=(-x*v-m*_)/y,k=(x*m+v*_)/y,M=(-x*v+m*_)/y,E=w-p,T=A-g,L=k-p,S=M-g;return E*E+T*T>L*L+S*S&&(w=k,A=M),[[w-l,A-u],[w*r/b,A*r/b]]}function _a(t){function e(e){function o(){u.push("M",a(t(c),s))}for(var l,u=[],c=[],f=-1,h=e.length,d=Lt(r),p=Lt(n);++f1?t.join("L"):t+"Z"}function Aa(t){return t.join("L")+"Z"}function ka(t){for(var e=0,r=t.length,n=t[0],i=[n[0],",",n[1]];++e1&&i.push("H",n[0]),i.join("")}function Ma(t){for(var e=0,r=t.length,n=t[0],i=[n[0],",",n[1]];++e1){s=e[1],a=t[l],l++,n+="C"+(i[0]+o[0])+","+(i[1]+o[1])+","+(a[0]-s[0])+","+(a[1]-s[1])+","+a[0]+","+a[1];for(var u=2;u9&&(i=3*e/Math.sqrt(i),o[s]=i*r,o[s+1]=i*n));for(s=-1;++s<=l;)i=(t[Math.min(l,s+1)][0]-t[Math.max(0,s-1)][0])/(6*(1+o[s]*o[s])),a.push([i||0,o[s]*i||0]);return a}function Ua(t){return t.length<3?wa(t):t[0]+Ca(t,ja(t))}function Va(t){for(var e,r,n,i=-1,a=t.length;++i0;)d[--s].call(t,o);if(a>=1)return g.event&&g.event.end.call(t,t.__data__,e),--p.count?delete p[n]:delete t[r],1}var l,u,c,h,d,p=t[r]||(t[r]={active:0,count:0}),g=p[n];g||(l=i.time,u=Pt(a,0,l),g=p[n]={tween:new f,time:l,timer:u,delay:i.delay,duration:i.duration,ease:i.ease,index:e},i=null,++p.count)}function ro(t,e,r){t.attr("transform",function(t){var n=e(t);return"translate("+(isFinite(n)?n:r(t))+",0)"})}function no(t,e,r){t.attr("transform",function(t){var n=e(t);return"translate(0,"+(isFinite(n)?n:r(t))+")"})}function io(t){return t.toISOString()}function ao(t,e,r){function n(e){return t(e)}function i(t,r){var n=t[1]-t[0],i=n/r,a=uo.bisect(Kl,i);return a==Kl.length?[e.year,ta(t.map(function(t){return t/31536e6}),r)[2]]:a?e[i/Kl[a-1]1?{floor:function(e){for(;r(e=t.floor(e));)e=oo(e-1);return e},ceil:function(e){for(;r(e=t.ceil(e));)e=oo(+e+1);return e}}:t))},n.ticks=function(t,e){var r=Gi(n.domain()),a=null==t?i(r,10):"number"==typeof t?i(r,t):!t.range&&[{range:t},e];return a&&(t=a[0],e=a[1]),t.range(r[0],oo(+r[1]+1),e<1?1:e)},n.tickFormat=function(){return r},n.copy=function(){return ao(t.copy(),e,r)},Ki(n,t)}function oo(t){return new Date(t)}function so(t){return JSON.parse(t.responseText)}function lo(t){var e=ho.createRange();return e.selectNode(ho.body),e.createContextualFragment(t.responseText)}var uo={version:"3.5.17"},co=[].slice,fo=function(t){return co.call(t)},ho=this.document;if(ho)try{fo(ho.documentElement.childNodes)[0].nodeType}catch(t){fo=function(t){for(var e=t.length,r=new Array(e);e--;)r[e]=t[e];return r}}if(Date.now||(Date.now=function(){return+new Date}),ho)try{ho.createElement("DIV").style.setProperty("opacity",0,"")}catch(t){var po=this.Element.prototype,go=po.setAttribute,vo=po.setAttributeNS,mo=this.CSSStyleDeclaration.prototype,yo=mo.setProperty;po.setAttribute=function(t,e){go.call(this,t,e+"")},po.setAttributeNS=function(t,e,r){vo.call(this,t,e,r+"")},mo.setProperty=function(t,e,r){yo.call(this,t,e+"",r)}}uo.ascending=i,uo.descending=function(t,e){return et?1:e>=t?0:NaN},uo.min=function(t,e){var r,n,i=-1,a=t.length;if(1===arguments.length){for(;++i=n){r=n;break}for(;++in&&(r=n)}else{for(;++i=n){r=n;break}for(;++in&&(r=n)}return r},uo.max=function(t,e){var r,n,i=-1,a=t.length;if(1===arguments.length){for(;++i=n){r=n;break}for(;++ir&&(r=n)}else{for(;++i=n){r=n;break}for(;++ir&&(r=n)}return r},uo.extent=function(t,e){var r,n,i,a=-1,o=t.length;if(1===arguments.length){for(;++a=n){r=i=n;break}for(;++an&&(r=n),i=n){r=i=n;break}for(;++an&&(r=n),i1)return l/(c-1)},uo.deviation=function(){var t=uo.variance.apply(this,arguments);return t?Math.sqrt(t):t};var bo=s(i);uo.bisectLeft=bo.left,uo.bisect=uo.bisectRight=bo.right,uo.bisector=function(t){return s(1===t.length?function(e,r){return i(t(e),r)}:t)},uo.shuffle=function(t,e,r){(a=arguments.length)<3&&(r=t.length,a<2&&(e=0));for(var n,i,a=r-e;a;)i=Math.random()*a--|0,n=t[a+e],t[a+e]=t[i+e],t[i+e]=n;return t},uo.permute=function(t,e){for(var r=e.length,n=new Array(r);r--;)n[r]=t[e[r]];return n},uo.pairs=function(t){for(var e,r=0,n=t.length-1,i=t[0],a=new Array(n<0?0:n);r=0;)for(n=t[i],e=n.length;--e>=0;)r[--o]=n[e];return r};var xo=Math.abs;uo.range=function(t,e,r){if(arguments.length<3&&(r=1,arguments.length<2&&(e=t,t=0)),(e-t)/r===1/0)throw new Error("infinite range");var n,i=[],a=u(xo(r)),o=-1;if(t*=a,e*=a,r*=a,r<0)for(;(n=t+r*++o)>e;)i.push(n/a);else for(;(n=t+r*++o)=a.length)return n?n.call(i,o):r?o.sort(r):o;for(var l,u,c,h,d=-1,p=o.length,g=a[s++],v=new f;++d=a.length)return t;var n=[],i=o[r++];return t.forEach(function(t,i){n.push({key:t,values:e(i,r)})}),i?n.sort(function(t,e){return i(t.key,e.key)}):n}var r,n,i={},a=[],o=[];return i.map=function(e,r){return t(r,e,0)},i.entries=function(r){return e(t(uo.map,r,0),0)},i.key=function(t){return a.push(t),i},i.sortKeys=function(t){return o[a.length-1]=t,i},i.sortValues=function(t){return r=t,i},i.rollup=function(t){return n=t,i},i},uo.set=function(t){var e=new b;if(t)for(var r=0,n=t.length;r=0&&(n=t.slice(r+1),t=t.slice(0,r)),t)return arguments.length<2?this[t].on(n):this[t].on(n,e);if(2===arguments.length){if(null==e)for(t in this)this.hasOwnProperty(t)&&this[t].on(n,null);return this}},uo.event=null,uo.requote=function(t){return t.replace(ko,"\\$&")};var ko=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,Mo={}.__proto__?function(t,e){t.__proto__=e}:function(t,e){for(var r in e)t[r]=e[r]},Eo=function(t,e){return e.querySelector(t)},To=function(t,e){return e.querySelectorAll(t)},Lo=function(t,e){var r=t.matches||t[w(t,"matchesSelector")];return(Lo=function(t,e){return r.call(t,e)})(t,e)};"function"==typeof Sizzle&&(Eo=function(t,e){return Sizzle(t,e)[0]||null},To=Sizzle,Lo=Sizzle.matchesSelector),uo.selection=function(){return uo.select(ho.documentElement)};var So=uo.selection.prototype=[];So.select=function(t){var e,r,n,i,a=[];t=C(t);for(var o=-1,s=this.length;++o=0&&"xmlns"!==(r=t.slice(0,e))&&(t=t.slice(e+1)),Ro.hasOwnProperty(r)?{space:Ro[r],local:t}:t}},So.attr=function(t,e){if(arguments.length<2){if("string"==typeof t){var r=this.node();return t=uo.ns.qualify(t),t.local?r.getAttributeNS(t.space,t.local):r.getAttribute(t)}for(e in t)this.each(I(e,t[e]));return this}return this.each(I(t,e))},So.classed=function(t,e){if(arguments.length<2){if("string"==typeof t){var r=this.node(),n=(t=N(t)).length,i=-1;if(e=r.classList){for(;++i=0;)(r=n[i])&&(a&&a!==r.nextSibling&&a.parentNode.insertBefore(r,a),a=r);return this},So.sort=function(t){t=H.apply(this,arguments);for(var e=-1,r=this.length;++e0&&(e=e.transition().duration(S)),e.call(t.event)}function s(){_&&_.domain(x.range().map(function(t){return(t-k.x)/k.k}).map(x.invert)),A&&A.domain(w.range().map(function(t){return(t-k.y)/k.k}).map(w.invert))}function l(t){C++||t({type:"zoomstart"})}function u(t){s(),t({type:"zoom",scale:k.k,translate:[k.x,k.y]})}function c(t){--C||(t({type:"zoomend"}),v=null)}function f(){function t(){s=1,a(uo.mouse(i),h),u(o)}function r(){f.on(I,null).on(P,null),d(s),c(o)}var i=this,o=N.of(i,arguments),s=0,f=uo.select(n(i)).on(I,t).on(P,r),h=e(uo.mouse(i)),d=$(i);Vl.call(i),l(o)}function h(){function t(){var t=uo.touches(p);return d=k.k,t.forEach(function(t){t.identifier in v&&(v[t.identifier]=e(t))}),t}function r(){var e=uo.event.target;uo.select(e).on(x,n).on(_,s),w.push(e);for(var r=uo.event.changedTouches,i=0,a=r.length;i1){var c=l[0],f=l[1],h=c[0]-f[0],d=c[1]-f[1];m=h*h+d*d}}function n(){var t,e,r,n,o=uo.touches(p);Vl.call(p);for(var s=0,l=o.length;s=u)return o;if(i)return i=!1,a;var e=c;if(34===t.charCodeAt(e)){for(var r=e;r++=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,ds=uo.map({b:function(t){return t.toString(2)},c:function(t){return String.fromCharCode(t)},o:function(t){return t.toString(8)},x:function(t){return t.toString(16)},X:function(t){return t.toString(16).toUpperCase()},g:function(t,e){return t.toPrecision(e)},e:function(t,e){return t.toExponential(e)},f:function(t,e){return t.toFixed(e)},r:function(t,e){return(t=uo.round(t,Dt(t,e))).toFixed(Math.max(0,Math.min(20,Dt(t*(1+1e-15),e))))}}),ps=uo.time={},gs=Date;Ut.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){vs.setUTCDate.apply(this._,arguments)},setDay:function(){vs.setUTCDay.apply(this._,arguments)},setFullYear:function(){vs.setUTCFullYear.apply(this._,arguments)},setHours:function(){vs.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){vs.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){vs.setUTCMinutes.apply(this._,arguments)},setMonth:function(){vs.setUTCMonth.apply(this._,arguments)},setSeconds:function(){vs.setUTCSeconds.apply(this._,arguments)},setTime:function(){vs.setTime.apply(this._,arguments)}};var vs=Date.prototype;ps.year=Vt(function(t){return t=ps.day(t),t.setMonth(0,1),t},function(t,e){t.setFullYear(t.getFullYear()+e)},function(t){return t.getFullYear()}),ps.years=ps.year.range,ps.years.utc=ps.year.utc.range,ps.day=Vt(function(t){var e=new gs(2e3,0);return e.setFullYear(t.getFullYear(),t.getMonth(),t.getDate()),e},function(t,e){t.setDate(t.getDate()+e)},function(t){return t.getDate()-1}),ps.days=ps.day.range,ps.days.utc=ps.day.utc.range,ps.dayOfYear=function(t){var e=ps.year(t);return Math.floor((t-e-6e4*(t.getTimezoneOffset()-e.getTimezoneOffset()))/864e5)},["sunday","monday","tuesday","wednesday","thursday","friday","saturday"].forEach(function(t,e){e=7-e;var r=ps[t]=Vt(function(t){return(t=ps.day(t)).setDate(t.getDate()-(t.getDay()+e)%7),t},function(t,e){t.setDate(t.getDate()+7*Math.floor(e))},function(t){var r=ps.year(t).getDay();return Math.floor((ps.dayOfYear(t)+(r+e)%7)/7)-(r!==e)});ps[t+"s"]=r.range,ps[t+"s"].utc=r.utc.range,ps[t+"OfYear"]=function(t){var r=ps.year(t).getDay();return Math.floor((ps.dayOfYear(t)+(r+e)%7)/7)}}),ps.week=ps.sunday,ps.weeks=ps.sunday.range,ps.weeks.utc=ps.sunday.utc.range,ps.weekOfYear=ps.sundayOfYear;var ms={"-":"",_:" ",0:"0"},ys=/^\s*\d+/,bs=/^%/;uo.locale=function(t){return{numberFormat:Bt(t),timeFormat:Ht(t)}};var xs=uo.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});uo.format=xs.numberFormat,uo.geo={},fe.prototype={s:0,t:0,add:function(t){he(t,this.t,_s),he(_s.s,this.s,this),this.s?this.t+=_s.t:this.s=_s.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var _s=new fe;uo.geo.stream=function(t,e){t&&ws.hasOwnProperty(t.type)?ws[t.type](t,e):de(t,e)};var ws={Feature:function(t,e){de(t.geometry,e)},FeatureCollection:function(t,e){for(var r=t.features,n=-1,i=r.length;++nd&&(d=e)}function e(e,r){var n=me([e*qo,r*qo]);if(m){var i=be(m,n),a=[i[1],-i[0],0],o=be(a,i);we(o),o=Ae(o);var l=e-p,u=l>0?1:-1,g=o[0]*Ho*u,v=xo(l)>180;if(v^(u*pd&&(d=y)}else if(g=(g+360)%360-180,v^(u*pd&&(d=r);v?es(c,h)&&(h=e):s(e,h)>s(c,h)&&(c=e):h>=c?(eh&&(h=e)):e>p?s(c,e)>s(c,h)&&(h=e):s(e,h)>s(c,h)&&(c=e)}else t(e,r);m=n,p=e}function r(){_.point=e}function n(){x[0]=c,x[1]=h,_.point=t,m=null}function i(t,r){if(m){var n=t-p;y+=xo(n)>180?n+(n>0?360:-360):n}else g=t,v=r;Es.point(t,r),e(t,r)}function a(){Es.lineStart()}function o(){i(g,v),Es.lineEnd(),xo(y)>Do&&(c=-(h=180)),x[0]=c,x[1]=h,m=null}function s(t,e){return(e-=t)<0?e+360:e}function l(t,e){return t[0]-e[0]}function u(t,e){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:tDo?d=90:y<-Do&&(f=-90),x[0]=c,x[1]=h}};return function(t){d=h=-(c=f=1/0),b=[],uo.geo.stream(t,_);var e=b.length;if(e){b.sort(l);for(var r,n=1,i=b[0],a=[i];ns(i[0],i[1])&&(i[1]=r[1]),s(r[0],i[1])>s(i[0],i[1])&&(i[0]=r[0])):a.push(i=r);for(var o,r,p=-(1/0),e=a.length-1,n=0,i=a[e];n<=e;i=r,++n)r=a[n],(o=s(i[1],r[0]))>p&&(p=o,c=r[0],h=i[1])}return b=x=null,c===1/0||f===1/0?[[NaN,NaN],[NaN,NaN]]:[[c,f],[h,d]]}}(),uo.geo.centroid=function(t){Ts=Ls=Ss=Cs=Rs=Is=Ps=Os=Ns=zs=Ds=0,uo.geo.stream(t,Fs);var e=Ns,r=zs,n=Ds,i=e*e+r*r+n*n;return i=.12&&i<.234&&n>=-.425&&n<-.214?o:i>=.166&&i<.234&&n>=-.214&&n<-.115?s:a).invert(t)},t.stream=function(t){var e=a.stream(t),r=o.stream(t),n=s.stream(t);return{point:function(t,i){e.point(t,i),r.point(t,i),n.point(t,i)},sphere:function(){e.sphere(),r.sphere(),n.sphere()},lineStart:function(){e.lineStart(),r.lineStart(),n.lineStart()},lineEnd:function(){e.lineEnd(),r.lineEnd(),n.lineEnd()},polygonStart:function(){e.polygonStart(),r.polygonStart(),n.polygonStart()},polygonEnd:function(){e.polygonEnd(),r.polygonEnd(),n.polygonEnd()}}},t.precision=function(e){return arguments.length?(a.precision(e),o.precision(e),s.precision(e),t):a.precision()},t.scale=function(e){return arguments.length?(a.scale(e),o.scale(.35*e),s.scale(e),t.translate(a.translate())):a.scale()},t.translate=function(e){if(!arguments.length)return a.translate();var u=a.scale(),c=+e[0],f=+e[1];return r=a.translate(e).clipExtent([[c-.455*u,f-.238*u],[c+.455*u,f+.238*u]]).stream(l).point,n=o.translate([c-.307*u,f+.201*u]).clipExtent([[c-.425*u+Do,f+.12*u+Do],[c-.214*u-Do,f+.234*u-Do]]).stream(l).point,i=s.translate([c-.205*u,f+.212*u]).clipExtent([[c-.214*u+Do,f+.166*u+Do],[c-.115*u-Do,f+.234*u-Do]]).stream(l).point,t},t.scale(1070)};var Us,Vs,qs,Hs,Gs,Xs,Ys={point:A,lineStart:A,lineEnd:A,polygonStart:function(){Vs=0,Ys.lineStart=We},polygonEnd:function(){Ys.lineStart=Ys.lineEnd=Ys.point=A,Us+=xo(Vs/2)}},Ws={point:Ze,lineStart:A,lineEnd:A,polygonStart:A,polygonEnd:A},Zs={point:Ke,lineStart:Je,lineEnd:tr,polygonStart:function(){Zs.lineStart=er},polygonEnd:function(){Zs.point=Ke,Zs.lineStart=Je,Zs.lineEnd=tr}};uo.geo.path=function(){function t(t){return t&&("function"==typeof s&&a.pointRadius(+s.apply(this,arguments)),o&&o.valid||(o=i(a)),uo.geo.stream(t,o)),a.result()}function e(){return o=null,t}var r,n,i,a,o,s=4.5;return t.area=function(t){return Us=0,uo.geo.stream(t,i(Ys)),Us},t.centroid=function(t){return Ss=Cs=Rs=Is=Ps=Os=Ns=zs=Ds=0,uo.geo.stream(t,i(Zs)),Ds?[Ns/Ds,zs/Ds]:Os?[Is/Os,Ps/Os]:Rs?[Ss/Rs,Cs/Rs]:[NaN,NaN]},t.bounds=function(t){return Gs=Xs=-(qs=Hs=1/0),uo.geo.stream(t,i(Ws)),[[qs,Hs],[Gs,Xs]]},t.projection=function(t){return arguments.length?(i=(r=t)?t.stream||ir(t):x,e()):r},t.context=function(t){return arguments.length?(a=null==(n=t)?new Qe:new rr(t),"function"!=typeof s&&a.pointRadius(s),e()):n},t.pointRadius=function(e){return arguments.length?(s="function"==typeof e?e:(a.pointRadius(+e),+e),t):s},t.projection(uo.geo.albersUsa()).context(null)},uo.geo.transform=function(t){return{stream:function(e){var r=new ar(e);for(var n in t)r[n]=t[n];return r}}},ar.prototype={point:function(t,e){this.stream.point(t,e)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}},uo.geo.projection=sr,uo.geo.projectionMutator=lr,(uo.geo.equirectangular=function(){return sr(cr)}).raw=cr.invert=cr,uo.geo.rotation=function(t){function e(e){return e=t(e[0]*qo,e[1]*qo),e[0]*=Ho,e[1]*=Ho,e}return t=hr(t[0]%360*qo,t[1]*qo,t.length>2?t[2]*qo:0),e.invert=function(e){return e=t.invert(e[0]*qo,e[1]*qo),e[0]*=Ho,e[1]*=Ho,e},e},fr.invert=cr,uo.geo.circle=function(){function t(){var t="function"==typeof n?n.apply(this,arguments):n,e=hr(-t[0]*qo,-t[1]*qo,0).invert,i=[];return r(null,null,1,{point:function(t,r){i.push(t=e(t,r)),t[0]*=Ho,t[1]*=Ho}}),{type:"Polygon",coordinates:[i]}}var e,r,n=[0,0],i=6;return t.origin=function(e){return arguments.length?(n=e,t):n},t.angle=function(n){return arguments.length?(r=vr((e=+n)*qo,i*qo),t):e},t.precision=function(n){return arguments.length?(r=vr(e*qo,(i=+n)*qo),t):i},t.angle(90)},uo.geo.distance=function(t,e){var r,n=(e[0]-t[0])*qo,i=t[1]*qo,a=e[1]*qo,o=Math.sin(n),s=Math.cos(n),l=Math.sin(i),u=Math.cos(i),c=Math.sin(a),f=Math.cos(a);return Math.atan2(Math.sqrt((r=f*o)*r+(r=u*c-l*f*s)*r),l*c+u*f*s)},uo.geo.graticule=function(){function t(){return{type:"MultiLineString",coordinates:e()}}function e(){return uo.range(Math.ceil(a/v)*v,i,v).map(h).concat(uo.range(Math.ceil(u/m)*m,l,m).map(d)).concat(uo.range(Math.ceil(n/p)*p,r,p).filter(function(t){return xo(t%v)>Do}).map(c)).concat(uo.range(Math.ceil(s/g)*g,o,g).filter(function(t){return xo(t%m)>Do}).map(f))}var r,n,i,a,o,s,l,u,c,f,h,d,p=10,g=p,v=90,m=360,y=2.5;return t.lines=function(){return e().map(function(t){return{type:"LineString",coordinates:t}})},t.outline=function(){return{type:"Polygon",coordinates:[h(a).concat(d(l).slice(1),h(i).reverse().slice(1),d(u).reverse().slice(1))]}},t.extent=function(e){return arguments.length?t.majorExtent(e).minorExtent(e):t.minorExtent()},t.majorExtent=function(e){return arguments.length?(a=+e[0][0],i=+e[1][0],u=+e[0][1],l=+e[1][1],a>i&&(e=a,a=i,i=e),u>l&&(e=u,u=l,l=e),t.precision(y)):[[a,u],[i,l]]},t.minorExtent=function(e){return arguments.length?(n=+e[0][0],r=+e[1][0],s=+e[0][1],o=+e[1][1],n>r&&(e=n,n=r,r=e),s>o&&(e=s,s=o,o=e),t.precision(y)):[[n,s],[r,o]]},t.step=function(e){return arguments.length?t.majorStep(e).minorStep(e):t.minorStep()},t.majorStep=function(e){return arguments.length?(v=+e[0],m=+e[1],t):[v,m]},t.minorStep=function(e){return arguments.length?(p=+e[0],g=+e[1],t):[p,g]},t.precision=function(e){return arguments.length?(y=+e,c=yr(s,o,90),f=br(n,r,y),h=yr(u,l,90),d=br(a,i,y),t):y},t.majorExtent([[-180,-90+Do],[180,90-Do]]).minorExtent([[-180,-80-Do],[180,80+Do]])},uo.geo.greatArc=function(){function t(){return{type:"LineString",coordinates:[e||n.apply(this,arguments),r||i.apply(this,arguments)]}}var e,r,n=xr,i=_r;return t.distance=function(){return uo.geo.distance(e||n.apply(this,arguments),r||i.apply(this,arguments))},t.source=function(r){return arguments.length?(n=r,e="function"==typeof r?null:r,t):n},t.target=function(e){return arguments.length?(i=e,r="function"==typeof e?null:e,t):i},t.precision=function(){return arguments.length?t:0},t},uo.geo.interpolate=function(t,e){return wr(t[0]*qo,t[1]*qo,e[0]*qo,e[1]*qo)},uo.geo.length=function(t){return Qs=0,uo.geo.stream(t,$s),Qs};var Qs,$s={sphere:A,point:A,lineStart:Ar,lineEnd:A,polygonStart:A,polygonEnd:A},Ks=kr(function(t){return Math.sqrt(2/(1+t))},function(t){return 2*Math.asin(t/2)});(uo.geo.azimuthalEqualArea=function(){return sr(Ks)}).raw=Ks;var Js=kr(function(t){var e=Math.acos(t);return e&&e/Math.sin(e)},x);(uo.geo.azimuthalEquidistant=function(){return sr(Js)}).raw=Js,(uo.geo.conicConformal=function(){return Xe(Mr)}).raw=Mr,(uo.geo.conicEquidistant=function(){return Xe(Er)}).raw=Er;var tl=kr(function(t){return 1/t},Math.atan);(uo.geo.gnomonic=function(){return sr(tl)}).raw=tl,Tr.invert=function(t,e){return[t,2*Math.atan(Math.exp(e))-Vo]},(uo.geo.mercator=function(){return Lr(Tr)}).raw=Tr;var el=kr(function(){return 1},Math.asin);(uo.geo.orthographic=function(){return sr(el)}).raw=el;var rl=kr(function(t){return 1/(1+t)},function(t){return 2*Math.atan(t)});(uo.geo.stereographic=function(){return sr(rl)}).raw=rl,Sr.invert=function(t,e){return[-e,2*Math.atan(Math.exp(t))-Vo]},(uo.geo.transverseMercator=function(){var t=Lr(Sr),e=t.center,r=t.rotate;return t.center=function(t){return t?e([-t[1],t[0]]):(t=e(),[t[1],-t[0]])},t.rotate=function(t){return t?r([t[0],t[1],t.length>2?t[2]+90:90]):(t=r(),[t[0],t[1],t[2]-90])},r([0,0,90])}).raw=Sr,uo.geom={},uo.geom.hull=function(t){function e(t){if(t.length<3)return[];var e,i=Lt(r),a=Lt(n),o=t.length,s=[],l=[];for(e=0;e=0;--e)d.push(t[s[u[e]][2]]);for(e=+f;e=n&&u.x<=a&&u.y>=i&&u.y<=o?[[n,o],[a,o],[a,i],[n,i]]:[];c.point=t[s]}),e}function r(t){return t.map(function(t,e){return{x:Math.round(a(t,e)/Do)*Do,y:Math.round(o(t,e)/Do)*Do,i:e}})}var n=Cr,i=Rr,a=n,o=i,s=fl;return t?e(t):(e.links=function(t){return un(r(t)).edges.filter(function(t){return t.l&&t.r}).map(function(e){return{source:t[e.l.i],target:t[e.r.i]}})},e.triangles=function(t){var e=[];return un(r(t)).cells.forEach(function(r,n){for(var i,a,o=r.site,s=r.edges.sort(Xr),l=-1,u=s.length,c=s[u-1].edge,f=c.l===o?c.r:c.l;++l=u,h=n>=c,d=h<<1|f;t.leaf=!1,t=t.nodes[d]||(t.nodes[d]=pn()),f?i=u:s=u,h?o=c:l=c,a(t,e,r,n,i,o,s,l)}var c,f,h,d,p,g,v,m,y,b=Lt(s),x=Lt(l);if(null!=e)g=e,v=r,m=n,y=i;else if(m=y=-(g=v=1/0),f=[],h=[],p=t.length,o)for(d=0;dm&&(m=c.x),c.y>y&&(y=c.y),f.push(c.x),h.push(c.y);else for(d=0;dm&&(m=_),w>y&&(y=w),f.push(_),h.push(w)}var A=m-g,k=y-v;A>k?y=v+A:m=g+k;var M=pn();if(M.add=function(t){a(M,t,+b(t,++d),+x(t,d),g,v,m,y)},M.visit=function(t){gn(t,M,g,v,m,y)},M.find=function(t){return vn(M,t[0],t[1],g,v,m,y)},d=-1,null==e){for(;++d=0?t.slice(0,e):t,n=e>=0?t.slice(e+1):"in";return r=gl.get(r)||pl,n=vl.get(n)||x,An(n(r.apply(null,co.call(arguments,1))))},uo.interpolateHcl=zn,uo.interpolateHsl=Dn,uo.interpolateLab=Fn,uo.interpolateRound=Bn,uo.transform=function(t){var e=ho.createElementNS(uo.ns.prefix.svg,"g");return(uo.transform=function(t){if(null!=t){e.setAttribute("transform",t);var r=e.transform.baseVal.consolidate()}return new jn(r?r.matrix:ml)})(t)},jn.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var ml={a:1,b:0,c:0,d:1,e:0,f:0};uo.interpolateTransform=Zn,uo.layout={},uo.layout.bundle=function(){return function(t){for(var e=[],r=-1,n=t.length;++r0?i=t:(r.c=null,r.t=NaN,r=null,u.end({type:"end",alpha:i=0})):t>0&&(u.start({type:"start",alpha:i=t}),r=Pt(l.tick)),l):i},l.start=function(){function t(t,n){if(!r){for(r=new Array(i),l=0;l=0;)o.push(c=u[l]),c.parent=a,c.depth=a.depth+1;n&&(a.value=0),a.children=u}else n&&(a.value=+n.call(t,a,a.depth)||0),delete a.children;return li(i,function(t){var r,i;e&&(r=t.children)&&r.sort(e),n&&(i=t.parent)&&(i.value+=t.value)}),s}var e=fi,r=ui,n=ci;return t.sort=function(r){return arguments.length?(e=r,t):e},t.children=function(e){return arguments.length?(r=e,t):r},t.value=function(e){return arguments.length?(n=e,t):n},t.revalue=function(e){return n&&(si(e,function(t){t.children&&(t.value=0)}),li(e,function(e){var r;e.children||(e.value=+n.call(t,e,e.depth)||0),(r=e.parent)&&(r.value+=e.value)})),e},t},uo.layout.partition=function(){function t(e,r,n,i){var a=e.children;if(e.x=r,e.y=e.depth*i,e.dx=n,e.dy=i,a&&(o=a.length)){var o,s,l,u=-1;for(n=e.value?n/e.value:0;++us&&(s=n),o.push(n)}for(r=0;r0)for(a=-1;++a=c[0]&&s<=c[1]&&(o=l[uo.bisect(f,s,1,d)-1],o.y+=p,o.push(t[a]));return l}var e=!0,r=Number,n=Ai,i=_i;return t.value=function(e){return arguments.length?(r=e,t):r},t.range=function(e){return arguments.length?(n=Lt(e),t):n},t.bins=function(e){return arguments.length?(i="number"==typeof e?function(t){return wi(t,e)}:Lt(e),t):i},t.frequency=function(r){return arguments.length?(e=!!r,t):e},t},uo.layout.pack=function(){function t(t,a){var o=r.call(this,t,a),s=o[0],l=i[0],u=i[1],c=null==e?Math.sqrt:"function"==typeof e?e:function(){return e};if(s.x=s.y=0,li(s,function(t){t.r=+c(t.value)}),li(s,Li),n){var f=n*(e?1:Math.max(2*s.r/l,2*s.r/u))/2;li(s,function(t){t.r+=f}),li(s,Li),li(s,function(t){t.r-=f})}return Ri(s,l/2,u/2,e?1:1/Math.max(2*s.r/l,2*s.r/u)),o}var e,r=uo.layout.hierarchy().sort(ki),n=0,i=[1,1];return t.size=function(e){return arguments.length?(i=e,t):i},t.radius=function(r){return arguments.length?(e=null==r||"function"==typeof r?r:+r,t):e},t.padding=function(e){return arguments.length?(n=+e,t):n},oi(t,r)},uo.layout.tree=function(){function t(t,i){var c=o.call(this,t,i),f=c[0],h=e(f);if(li(h,r),h.parent.m=-h.z,si(h,n),u)si(f,a);else{var d=f,p=f,g=f;si(f,function(t){t.xp.x&&(p=t),t.depth>g.depth&&(g=t)});var v=s(d,p)/2-d.x,m=l[0]/(p.x+s(p,d)/2+v),y=l[1]/(g.depth||1);si(f,function(t){t.x=(t.x+v)*m,t.y=t.depth*y})}return c}function e(t){for(var e,r={A:null,children:[t]},n=[r];null!=(e=n.pop());)for(var i,a=e.children,o=0,s=a.length;o0&&(zi(Fi(o,t,r),t,n),u+=n,c+=n),f+=o.m,u+=i.m,h+=l.m,c+=a.m;o&&!Ni(a)&&(a.t=o,a.m+=f-c),i&&!Oi(l)&&(l.t=i,l.m+=u-h,r=t)}return r}function a(t){t.x*=l[0],t.y=t.depth*l[1]}var o=uo.layout.hierarchy().sort(null).value(null),s=Pi,l=[1,1],u=null;return t.separation=function(e){return arguments.length?(s=e,t):s},t.size=function(e){return arguments.length?(u=null==(l=e)?a:null,t):u?null:l},t.nodeSize=function(e){return arguments.length?(u=null==(l=e)?null:a,t):u?l:null},oi(t,o)},uo.layout.cluster=function(){function t(t,a){var o,s=e.call(this,t,a),l=s[0],u=0;li(l,function(t){var e=t.children;e&&e.length?(t.x=ji(e),t.y=Bi(e)):(t.x=o?u+=r(t,o):0,t.y=0,o=t)});var c=Ui(l),f=Vi(l),h=c.x-r(c,f)/2,d=f.x+r(f,c)/2;return li(l,i?function(t){t.x=(t.x-l.x)*n[0],t.y=(l.y-t.y)*n[1]}:function(t){t.x=(t.x-h)/(d-h)*n[0],t.y=(1-(l.y?t.y/l.y:1))*n[1]}),s}var e=uo.layout.hierarchy().sort(null).value(null),r=Pi,n=[1,1],i=!1;return t.separation=function(e){return arguments.length?(r=e,t):r},t.size=function(e){return arguments.length?(i=null==(n=e),t):i?null:n},t.nodeSize=function(e){return arguments.length?(i=null!=(n=e),t):i?n:null},oi(t,e)},uo.layout.treemap=function(){function t(t,e){for(var r,n,i=-1,a=t.length;++i0;)c.push(o=h[l-1]),c.area+=o.area,"squarify"!==d||(s=n(c,g))<=p?(h.pop(),p=s):(c.area-=c.pop().area,i(c,g,u,!1),g=Math.min(u.dx,u.dy),c.length=c.area=0,p=1/0);c.length&&(i(c,g,u,!0),c.length=c.area=0),a.forEach(e)}}function r(e){var n=e.children;if(n&&n.length){var a,o=f(e),s=n.slice(),l=[];for(t(s,o.dx*o.dy/e.value),l.area=0;a=s.pop();)l.push(a),l.area+=a.area,null!=a.z&&(i(l,a.z?o.dx:o.dy,o,!s.length),l.length=l.area=0);n.forEach(r)}}function n(t,e){for(var r,n=t.area,i=0,a=1/0,o=-1,s=t.length;++oi&&(i=r));return n*=n,e*=e,n?Math.max(e*i*p/n,n/(e*a*p)):1/0}function i(t,e,r,n){var i,a=-1,o=t.length,s=r.x,u=r.y,c=e?l(t.area/e):0;if(e==r.dx){for((n||c>r.dy)&&(c=r.dy);++ar.dx)&&(c=r.dx);++a1);return t+e*r*Math.sqrt(-2*Math.log(i)/i)}},logNormal:function(){var t=uo.random.normal.apply(uo,arguments);return function(){return Math.exp(t())}},bates:function(t){var e=uo.random.irwinHall(t);return function(){return e()/t}},irwinHall:function(t){return function(){for(var e=0,r=0;rf?0:1;if(u=Uo)return e(u,d)+(t?e(t,1-d):"")+"Z";var p,g,v,m,y,b,x,_,w,A,k,M,E=0,T=0,L=[];if((m=(+l.apply(this,arguments)||0)/2)&&(v=a===Il?Math.sqrt(t*t+u*u):+a.apply(this,arguments),d||(T*=-1),u&&(T=nt(v/u*Math.sin(m))),t&&(E=nt(v/t*Math.sin(m)))),u){y=u*Math.cos(c+T),b=u*Math.sin(c+T),x=u*Math.cos(f-T),_=u*Math.sin(f-T);var S=Math.abs(f-c-2*T)<=Bo?0:1;if(T&&ba(y,b,x,_)===d^S){var C=(c+f)/2;y=u*Math.cos(C),b=u*Math.sin(C),x=_=null}}else y=b=0;if(t){w=t*Math.cos(f-E),A=t*Math.sin(f-E),k=t*Math.cos(c+E),M=t*Math.sin(c+E);var R=Math.abs(c-f+2*E)<=Bo?0:1;if(E&&ba(w,A,k,M)===1-d^R){var I=(c+f)/2;w=t*Math.cos(I),A=t*Math.sin(I),k=M=null}}else w=A=0;if(h>Do&&(p=Math.min(Math.abs(u-t)/2,+i.apply(this,arguments)))>.001){g=tBo)+",1 "+e}function i(t,e,r,n){return"Q 0,0 "+n}var a=xr,o=_r,s=Ha,l=va,u=ma;return t.radius=function(e){return arguments.length?(s=Lt(e),t):s},t.source=function(e){return arguments.length?(a=Lt(e),t):a},t.target=function(e){return arguments.length?(o=Lt(e),t):o},t.startAngle=function(e){return arguments.length?(l=Lt(e),t):l},t.endAngle=function(e){return arguments.length?(u=Lt(e),t):u},t},uo.svg.diagonal=function(){function t(t,i){var a=e.call(this,t,i),o=r.call(this,t,i),s=(a.y+o.y)/2,l=[a,{x:a.x,y:s},{x:o.x,y:s},o];return l=l.map(n),"M"+l[0]+"C"+l[1]+" "+l[2]+" "+l[3]}var e=xr,r=_r,n=Ga;return t.source=function(r){return arguments.length?(e=Lt(r),t):e},t.target=function(e){return arguments.length?(r=Lt(e),t):r},t.projection=function(e){return arguments.length?(n=e,t):n},t},uo.svg.diagonal.radial=function(){var t=uo.svg.diagonal(),e=Ga,r=t.projection;return t.projection=function(t){return arguments.length?r(Xa(e=t)):e},t},uo.svg.symbol=function(){function t(t,n){return(Dl.get(e.call(this,t,n))||Za)(r.call(this,t,n))}var e=Wa,r=Ya;return t.type=function(r){return arguments.length?(e=Lt(r),t):e},t.size=function(e){return arguments.length?(r=Lt(e),t):r},t};var Dl=uo.map({circle:Za,cross:function(t){var e=Math.sqrt(t/5)/2;return"M"+-3*e+","+-e+"H"+-e+"V"+-3*e+"H"+e+"V"+-e+"H"+3*e+"V"+e+"H"+e+"V"+3*e+"H"+-e+"V"+e+"H"+-3*e+"Z"},diamond:function(t){var e=Math.sqrt(t/(2*Bl)),r=e*Bl;return"M0,"+-e+"L"+r+",0 0,"+e+" "+-r+",0Z"},square:function(t){var e=Math.sqrt(t)/2;return"M"+-e+","+-e+"L"+e+","+-e+" "+e+","+e+" "+-e+","+e+"Z"},"triangle-down":function(t){var e=Math.sqrt(t/Fl),r=e*Fl/2;return"M0,"+r+"L"+e+","+-r+" "+-e+","+-r+"Z"},"triangle-up":function(t){var e=Math.sqrt(t/Fl),r=e*Fl/2;return"M0,"+-r+"L"+e+","+r+" "+-e+","+r+"Z"}});uo.svg.symbolTypes=Dl.keys();var Fl=Math.sqrt(3),Bl=Math.tan(30*qo);So.transition=function(t){for(var e,r,n=jl||++Hl,i=to(t),a=[],o=Ul||{time:Date.now(),ease:Ln,delay:0,duration:250},s=-1,l=this.length;++srect,.s>rect").attr("width",f[1]-f[0])}function i(t){t.select(".extent").attr("y",h[0]),t.selectAll(".extent,.e>rect,.w>rect").attr("height",h[1]-h[0])}function a(){function a(){32==uo.event.keyCode&&(S||(b=null,R[0]-=f[1],R[1]-=h[1],S=2),E())}function g(){32==uo.event.keyCode&&2==S&&(R[0]+=f[1],R[1]+=h[1],S=0,E())}function v(){var t=uo.mouse(_),n=!1;x&&(t[0]+=x[0],t[1]+=x[1]),S||(uo.event.altKey?(b||(b=[(f[0]+f[1])/2,(h[0]+h[1])/2]),R[0]=f[+(t[0]>>31},e.exports.exponent=function(t){var r=e.exports.hi(t);return(r<<1>>>21)-1023},e.exports.fraction=function(t){var r=e.exports.lo(t),n=e.exports.hi(t),i=1048575&n;return 2146435072&n&&(i+=1<<20),[r,i]},e.exports.denormalized=function(t){var r=e.exports.hi(t);return!(2146435072&r)}}).call(this,t("buffer").Buffer)},{buffer:37}],56:[function(t,e,r){"use strict";function n(t,e,r){var i=0|t[r];if(i<=0)return[];var a,o=new Array(i);if(r===t.length-1)for(a=0;a0)return i(0|t,e);break;case"object":if("number"==typeof t.length)return n(t,e,0)}return[]}e.exports=a},{}],57:[function(t,e,r){"use strict";function n(t,e){var r=t.length;if("number"!=typeof e){e=0;for(var n=0;n0&&this._events[t].length>r&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(t,e){function r(){this.removeListener(t,r),n||(n=!0,e.apply(this,arguments))}if(!i(e))throw TypeError("listener must be a function");var n=!1;return r.listener=e,this.on(t,r),this},n.prototype.removeListener=function(t,e){var r,n,a,s;if(!i(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],a=r.length,n=-1,r===e||i(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(r)){for(s=a;s-- >0;)if(r[s]===e||r[s].listener&&r[s].listener===e){n=s;break}if(n<0)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},n.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],i(r))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},n.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?i(this._events[t])?[this._events[t]]:this._events[t].slice():[]},n.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(i(e))return 1;if(e)return e.length}return 0},n.listenerCount=function(t,e){return t.listenerCount(e)}},{}],60:[function(t,e,r){"use strict";function n(t){for(var e,r=t.length,n=0;n13)&&32!==e&&133!==e&&160!==e&&5760!==e&&6158!==e&&(e<8192||e>8205)&&8232!==e&&8233!==e&&8239!==e&&8287!==e&&8288!==e&&12288!==e&&65279!==e)return!1;return!0}e.exports=function(t){var e=typeof t;if("string"===e){var r=t;if(t=+t,0===t&&n(r))return!1}else if("number"!==e)return!1;return t-t<1}},{}],61:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){this._color=t,this.key=e,this.value=r,this.left=n,this.right=i,this._count=a}function i(t){return new n(t._color,t.key,t.value,t.left,t.right,t._count)}function a(t,e){return new n(t,e.key,e.value,e.left,e.right,e._count)}function o(t){t._count=1+(t.left?t.left._count:0)+(t.right?t.right._count:0)}function s(t,e){this._compare=t,this.root=e}function l(t,e){if(e.left){var r=l(t,e.left);if(r)return r}var r=t(e.key,e.value);return r?r:e.right?l(t,e.right):void 0}function u(t,e,r,n){var i=e(t,n.key);if(i<=0){if(n.left){var a=u(t,e,r,n.left);if(a)return a}var a=r(n.key,n.value);if(a)return a}if(n.right)return u(t,e,r,n.right)}function c(t,e,r,n,i){var a,o=r(t,i.key),s=r(e,i.key);if(o<=0){if(i.left&&(a=c(t,e,r,n,i.left)))return a;if(s>0&&(a=n(i.key,i.value)))return a}if(s>0&&i.right)return c(t,e,r,n,i.right)}function f(t,e){this.tree=t,this._stack=e}function h(t,e){t.key=e.key,t.value=e.value,t.left=e.left,t.right=e.right,t._color=e._color,t._count=e._count}function d(t){for(var e,r,n,s,l=t.length-1;l>=0;--l){if(e=t[l],0===l)return void(e._color=m);if(r=t[l-1],r.left===e){if(n=r.right,n.right&&n.right._color===v){if(n=r.right=i(n),s=n.right=i(n.right),r.right=n.left,n.left=r,n.right=s,n._color=r._color,e._color=m,r._color=m,s._color=m,o(r),o(n),l>1){var u=t[l-2];u.left===r?u.left=n:u.right=n}return void(t[l-1]=n)}if(n.left&&n.left._color===v){if(n=r.right=i(n),s=n.left=i(n.left),r.right=s.left,n.left=s.right,s.left=r,s.right=n,s._color=r._color,r._color=m,n._color=m,e._color=m,o(r),o(n),o(s),l>1){var u=t[l-2];u.left===r?u.left=s:u.right=s}return void(t[l-1]=s)}if(n._color===m){if(r._color===v)return r._color=m,void(r.right=a(v,n));r.right=a(v,n);continue}if(n=i(n),r.right=n.left,n.left=r,n._color=r._color,r._color=v,o(r),o(n),l>1){var u=t[l-2];u.left===r?u.left=n:u.right=n}t[l-1]=n,t[l]=r,l+11){var u=t[l-2];u.right===r?u.right=n:u.left=n}return void(t[l-1]=n)}if(n.right&&n.right._color===v){if(n=r.left=i(n),s=n.right=i(n.right),r.left=s.right,n.right=s.left,s.right=r,s.left=n,s._color=r._color,r._color=m,n._color=m,e._color=m,o(r),o(n),o(s),l>1){var u=t[l-2];u.right===r?u.right=s:u.left=s}return void(t[l-1]=s)}if(n._color===m){if(r._color===v)return r._color=m,void(r.left=a(v,n));r.left=a(v,n);continue}if(n=i(n),r.left=n.right,n.right=r,n._color=r._color,r._color=v,o(r),o(n),l>1){var u=t[l-2];u.right===r?u.right=n:u.left=n}t[l-1]=n,t[l]=r,l+1e?1:0}function g(t){return new s(t||p,null)}e.exports=g;var v=0,m=1,y=s.prototype;Object.defineProperty(y,"keys",{get:function(){var t=[];return this.forEach(function(e,r){t.push(e)}),t}}),Object.defineProperty(y,"values",{get:function(){var t=[];return this.forEach(function(e,r){t.push(r)}),t}}),Object.defineProperty(y,"length",{get:function(){return this.root?this.root._count:0}}),y.insert=function(t,e){for(var r=this._compare,i=this.root,l=[],u=[];i;){var c=r(t,i.key);l.push(i),u.push(c),i=c<=0?i.left:i.right}l.push(new n(v,t,e,null,null,1));for(var f=l.length-2;f>=0;--f){var i=l[f];u[f]<=0?l[f]=new n(i._color,i.key,i.value,l[f+1],i.right,i._count+1):l[f]=new n(i._color,i.key,i.value,i.left,l[f+1],i._count+1)}for(var f=l.length-1;f>1;--f){var h=l[f-1],i=l[f];if(h._color===m||i._color===m)break;var d=l[f-2];if(d.left===h)if(h.left===i){var p=d.right;if(!p||p._color!==v){if(d._color=v,d.left=h.right,h._color=m,h.right=d,l[f-2]=h,l[f-1]=i,o(d),o(h),f>=3){var g=l[f-3];g.left===d?g.left=h:g.right=h}break}h._color=m,d.right=a(m,p),d._color=v,f-=1}else{var p=d.right;if(!p||p._color!==v){if(h.right=i.left,d._color=v,d.left=i.right,i._color=m,i.left=h,i.right=d,l[f-2]=i,l[f-1]=h,o(d),o(h),o(i),f>=3){var g=l[f-3];g.left===d?g.left=i:g.right=i}break}h._color=m,d.right=a(m,p),d._color=v,f-=1}else if(h.right===i){var p=d.left;if(!p||p._color!==v){if(d._color=v,d.right=h.left,h._color=m,h.left=d,l[f-2]=h,l[f-1]=i,o(d),o(h),f>=3){var g=l[f-3];g.right===d?g.right=h:g.left=h}break}h._color=m,d.left=a(m,p),d._color=v,f-=1}else{var p=d.left;if(!p||p._color!==v){if(h.left=i.right,d._color=v,d.right=i.left,i._color=m,i.right=h,i.left=d,l[f-2]=i,l[f-1]=h,o(d),o(h),o(i),f>=3){var g=l[f-3];g.right===d?g.right=i:g.left=i}break}h._color=m,d.left=a(m,p),d._color=v,f-=1}}return l[0]._color=m,new s(r,l[0])},y.forEach=function(t,e,r){if(this.root)switch(arguments.length){case 1:return l(t,this.root);case 2:return u(e,this._compare,t,this.root);case 3:if(this._compare(e,r)>=0)return;return c(e,r,this._compare,t,this.root)}},Object.defineProperty(y,"begin",{get:function(){for(var t=[],e=this.root;e;)t.push(e),e=e.left;return new f(this,t)}}),Object.defineProperty(y,"end",{get:function(){for(var t=[],e=this.root;e;)t.push(e),e=e.right;return new f(this,t)}}),y.at=function(t){if(t<0)return new f(this,[]);for(var e=this.root,r=[];;){if(r.push(e),e.left){if(t=e.right._count)break;e=e.right}return new f(this,[])},y.ge=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),a<=0&&(i=n.length),r=a<=0?r.left:r.right}return n.length=i,new f(this,n)},y.gt=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),a<0&&(i=n.length),r=a<0?r.left:r.right}return n.length=i,new f(this,n)},y.lt=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),a>0&&(i=n.length),r=a<=0?r.left:r.right}return n.length=i,new f(this,n)},y.le=function(t){for(var e=this._compare,r=this.root,n=[],i=0;r;){var a=e(t,r.key);n.push(r),a>=0&&(i=n.length),r=a<0?r.left:r.right}return n.length=i,new f(this,n)},y.find=function(t){for(var e=this._compare,r=this.root,n=[];r;){var i=e(t,r.key);if(n.push(r),0===i)return new f(this,n);r=i<=0?r.left:r.right}return new f(this,[])},y.remove=function(t){var e=this.find(t);return e?e.remove():this},y.get=function(t){for(var e=this._compare,r=this.root;r;){var n=e(t,r.key);if(0===n)return r.value;r=n<=0?r.left:r.right}};var b=f.prototype;Object.defineProperty(b,"valid",{get:function(){return this._stack.length>0}}),Object.defineProperty(b,"node",{get:function(){return this._stack.length>0?this._stack[this._stack.length-1]:null},enumerable:!0}),b.clone=function(){return new f(this.tree,this._stack.slice())},b.remove=function(){var t=this._stack;if(0===t.length)return this.tree;var e=new Array(t.length),r=t[t.length-1];e[e.length-1]=new n(r._color,r.key,r.value,r.left,r.right,r._count);for(var i=t.length-2;i>=0;--i){var r=t[i];r.left===t[i+1]?e[i]=new n(r._color,r.key,r.value,e[i+1],r.right,r._count):e[i]=new n(r._color,r.key,r.value,r.left,e[i+1],r._count)}if(r=e[e.length-1],r.left&&r.right){var a=e.length;for(r=r.left;r.right;)e.push(r),r=r.right;var o=e[a-1];e.push(new n(r._color,o.key,o.value,r.left,r.right,r._count)),e[a-1].key=r.key,e[a-1].value=r.value;for(var i=e.length-2;i>=a;--i)r=e[i],e[i]=new n(r._color,r.key,r.value,r.left,e[i+1],r._count);e[a-1].left=e[a]}if(r=e[e.length-1],r._color===v){var l=e[e.length-2];l.left===r?l.left=null:l.right===r&&(l.right=null),e.pop();for(var i=0;i0)return this._stack[this._stack.length-1].key},enumerable:!0}),Object.defineProperty(b,"value",{get:function(){if(this._stack.length>0)return this._stack[this._stack.length-1].value},enumerable:!0}),Object.defineProperty(b,"index",{get:function(){var t=0,e=this._stack;if(0===e.length){var r=this.tree.root;return r?r._count:0}e[e.length-1].left&&(t=e[e.length-1].left._count);for(var n=e.length-2;n>=0;--n)e[n+1]===e[n].right&&(++t,e[n].left&&(t+=e[n].left._count));return t},enumerable:!0}),b.next=function(){var t=this._stack;if(0!==t.length){var e=t[t.length-1];if(e.right)for(e=e.right;e;)t.push(e),e=e.left;else for(t.pop();t.length>0&&t[t.length-1].right===e;)e=t[t.length-1],t.pop()}},Object.defineProperty(b,"hasNext",{get:function(){var t=this._stack;if(0===t.length)return!1;if(t[t.length-1].right)return!0;for(var e=t.length-1;e>0;--e)if(t[e-1].left===t[e])return!0;return!1}}),b.update=function(t){var e=this._stack;if(0===e.length)throw new Error("Can't update empty node!");var r=new Array(e.length),i=e[e.length-1];r[r.length-1]=new n(i._color,i.key,t,i.left,i.right,i._count);for(var a=e.length-2;a>=0;--a)i=e[a],i.left===e[a+1]?r[a]=new n(i._color,i.key,i.value,r[a+1],i.right,i._count):r[a]=new n(i._color,i.key,i.value,i.left,r[a+1],i._count);return new s(this.tree._compare,r[0])},b.prev=function(){var t=this._stack;if(0!==t.length){var e=t[t.length-1];if(e.left)for(e=e.left;e;)t.push(e),e=e.right;else for(t.pop();t.length>0&&t[t.length-1].left===e;)e=t[t.length-1],t.pop()}},Object.defineProperty(b,"hasPrev",{get:function(){var t=this._stack;if(0===t.length)return!1;if(t[t.length-1].left)return!0;for(var e=t.length-1;e>0;--e)if(t[e-1].right===t[e])return!0;return!1}})},{}],62:[function(t,e,r){function n(t){if(t<0)return Number("0/0");for(var e=s[0],r=s.length-1;r>0;--r)e+=s[r]/(t+r);var n=t+o+.5;return.5*Math.log(2*Math.PI)+(t+.5)*Math.log(n)-n+Math.log(e)-Math.log(t)}var i=7,a=[.9999999999998099,676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,1.5056327351493116e-7],o=607/128,s=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22];e.exports=function t(e){if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*t(1-e));if(e>100)return Math.exp(n(e));e-=1;for(var r=a[0],o=1;or)throw new Error("gl-buffer: If resizing buffer, must not specify offset");return t.bufferSubData(e,a,i),r}function a(t,e){for(var r=l.malloc(t.length,e),n=t.length,i=0;i=0;--n){if(e[n]!==r)return!1;r*=t[n]}return!0}function s(t,e,r,i){if(r=r||t.ARRAY_BUFFER,i=i||t.DYNAMIC_DRAW,r!==t.ARRAY_BUFFER&&r!==t.ELEMENT_ARRAY_BUFFER)throw new Error("gl-buffer: Invalid type for webgl buffer, must be either gl.ARRAY_BUFFER or gl.ELEMENT_ARRAY_BUFFER");if(i!==t.DYNAMIC_DRAW&&i!==t.STATIC_DRAW&&i!==t.STREAM_DRAW)throw new Error("gl-buffer: Invalid usage for buffer, must be either gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW");var a=t.createBuffer(),o=new n(t,r,a,0,i);return o.update(e),o}var l=t("typedarray-pool"),u=t("ndarray-ops"),c=t("ndarray"),f=["uint8","uint8_clamped","uint16","uint32","int8","int16","int32","float32"],h=n.prototype;h.bind=function(){this.gl.bindBuffer(this.type,this.handle)},h.unbind=function(){this.gl.bindBuffer(this.type,null)},h.dispose=function(){this.gl.deleteBuffer(this.handle)},h.update=function(t,e){if("number"!=typeof e&&(e=-1),this.bind(),"object"==typeof t&&"undefined"!=typeof t.shape){var r=t.dtype;if(f.indexOf(r)<0&&(r="float32"),this.type===this.gl.ELEMENT_ARRAY_BUFFER){var n=gl.getExtension("OES_element_index_uint");r=n&&"uint16"!==r?"uint32":"uint16"}if(r===t.dtype&&o(t.shape,t.stride))0===t.offset&&t.data.length===t.shape[0]?this.length=i(this.gl,this.type,this.length,this.usage,t.data,e):this.length=i(this.gl,this.type,this.length,this.usage,t.data.subarray(t.offset,t.shape[0]),e);else{var s=l.malloc(t.size,r),h=c(s,t.shape);u.assign(h,t),e<0?this.length=i(this.gl,this.type,this.length,this.usage,s,e):this.length=i(this.gl,this.type,this.length,this.usage,s.subarray(0,t.size),e),l.free(s)}}else if(Array.isArray(t)){var d;d=this.type===this.gl.ELEMENT_ARRAY_BUFFER?a(t,"uint16"):a(t,"float32"),e<0?this.length=i(this.gl,this.type,this.length,this.usage,d,e):this.length=i(this.gl,this.type,this.length,this.usage,d.subarray(0,t.length),e),l.free(d)}else if("object"==typeof t&&"number"==typeof t.length)this.length=i(this.gl,this.type,this.length,this.usage,t,e);else{if("number"!=typeof t&&void 0!==t)throw new Error("gl-buffer: Invalid data type");if(e>=0)throw new Error("gl-buffer: Cannot specify offset when resizing buffer");t=0|t,t<=0&&(t=1),this.gl.bufferData(this.type,0|t,this.usage),this.length=t}},e.exports=s},{ndarray:123,"ndarray-ops":122,"typedarray-pool":162}],64:[function(t,e,r){e.exports={0:"NONE",1:"ONE",2:"LINE_LOOP",3:"LINE_STRIP",4:"TRIANGLES",5:"TRIANGLE_STRIP",6:"TRIANGLE_FAN",256:"DEPTH_BUFFER_BIT",512:"NEVER",513:"LESS",514:"EQUAL",515:"LEQUAL",516:"GREATER",517:"NOTEQUAL",518:"GEQUAL",519:"ALWAYS",768:"SRC_COLOR",769:"ONE_MINUS_SRC_COLOR",770:"SRC_ALPHA",771:"ONE_MINUS_SRC_ALPHA",772:"DST_ALPHA",773:"ONE_MINUS_DST_ALPHA",774:"DST_COLOR",775:"ONE_MINUS_DST_COLOR",776:"SRC_ALPHA_SATURATE",1024:"STENCIL_BUFFER_BIT",1028:"FRONT",1029:"BACK",1032:"FRONT_AND_BACK",1280:"INVALID_ENUM",1281:"INVALID_VALUE",1282:"INVALID_OPERATION",1285:"OUT_OF_MEMORY",1286:"INVALID_FRAMEBUFFER_OPERATION",2304:"CW",2305:"CCW",2849:"LINE_WIDTH",2884:"CULL_FACE",2885:"CULL_FACE_MODE",2886:"FRONT_FACE",2928:"DEPTH_RANGE",2929:"DEPTH_TEST",2930:"DEPTH_WRITEMASK",2931:"DEPTH_CLEAR_VALUE",2932:"DEPTH_FUNC",2960:"STENCIL_TEST",2961:"STENCIL_CLEAR_VALUE",2962:"STENCIL_FUNC",2963:"STENCIL_VALUE_MASK",2964:"STENCIL_FAIL",2965:"STENCIL_PASS_DEPTH_FAIL",2966:"STENCIL_PASS_DEPTH_PASS",2967:"STENCIL_REF",2968:"STENCIL_WRITEMASK",2978:"VIEWPORT",3024:"DITHER",3042:"BLEND",3088:"SCISSOR_BOX",3089:"SCISSOR_TEST",3106:"COLOR_CLEAR_VALUE",3107:"COLOR_WRITEMASK",3317:"UNPACK_ALIGNMENT",3333:"PACK_ALIGNMENT",3379:"MAX_TEXTURE_SIZE",3386:"MAX_VIEWPORT_DIMS",3408:"SUBPIXEL_BITS",3410:"RED_BITS",3411:"GREEN_BITS",3412:"BLUE_BITS",3413:"ALPHA_BITS",3414:"DEPTH_BITS",3415:"STENCIL_BITS",3553:"TEXTURE_2D",4352:"DONT_CARE",4353:"FASTEST",4354:"NICEST",5120:"BYTE",5121:"UNSIGNED_BYTE",5122:"SHORT",5123:"UNSIGNED_SHORT",5124:"INT",5125:"UNSIGNED_INT",5126:"FLOAT",5386:"INVERT",5890:"TEXTURE",6401:"STENCIL_INDEX",6402:"DEPTH_COMPONENT",6406:"ALPHA",6407:"RGB",6408:"RGBA",6409:"LUMINANCE",6410:"LUMINANCE_ALPHA",7680:"KEEP",7681:"REPLACE",7682:"INCR",7683:"DECR",7936:"VENDOR",7937:"RENDERER",7938:"VERSION",9728:"NEAREST",9729:"LINEAR",9984:"NEAREST_MIPMAP_NEAREST",9985:"LINEAR_MIPMAP_NEAREST",9986:"NEAREST_MIPMAP_LINEAR",9987:"LINEAR_MIPMAP_LINEAR",10240:"TEXTURE_MAG_FILTER",10241:"TEXTURE_MIN_FILTER",10242:"TEXTURE_WRAP_S",10243:"TEXTURE_WRAP_T",10497:"REPEAT",10752:"POLYGON_OFFSET_UNITS",16384:"COLOR_BUFFER_BIT",32769:"CONSTANT_COLOR",32770:"ONE_MINUS_CONSTANT_COLOR",32771:"CONSTANT_ALPHA",32772:"ONE_MINUS_CONSTANT_ALPHA",32773:"BLEND_COLOR",32774:"FUNC_ADD",32777:"BLEND_EQUATION_RGB",32778:"FUNC_SUBTRACT",32779:"FUNC_REVERSE_SUBTRACT",32819:"UNSIGNED_SHORT_4_4_4_4",32820:"UNSIGNED_SHORT_5_5_5_1",32823:"POLYGON_OFFSET_FILL",32824:"POLYGON_OFFSET_FACTOR",32854:"RGBA4",32855:"RGB5_A1",32873:"TEXTURE_BINDING_2D",32926:"SAMPLE_ALPHA_TO_COVERAGE",32928:"SAMPLE_COVERAGE",32936:"SAMPLE_BUFFERS",32937:"SAMPLES",32938:"SAMPLE_COVERAGE_VALUE",32939:"SAMPLE_COVERAGE_INVERT",32968:"BLEND_DST_RGB",32969:"BLEND_SRC_RGB",32970:"BLEND_DST_ALPHA",32971:"BLEND_SRC_ALPHA",33071:"CLAMP_TO_EDGE",33170:"GENERATE_MIPMAP_HINT",33189:"DEPTH_COMPONENT16",33306:"DEPTH_STENCIL_ATTACHMENT",33635:"UNSIGNED_SHORT_5_6_5",33648:"MIRRORED_REPEAT",33901:"ALIASED_POINT_SIZE_RANGE",33902:"ALIASED_LINE_WIDTH_RANGE",33984:"TEXTURE0",33985:"TEXTURE1",33986:"TEXTURE2",33987:"TEXTURE3",33988:"TEXTURE4",33989:"TEXTURE5",33990:"TEXTURE6",33991:"TEXTURE7",33992:"TEXTURE8",33993:"TEXTURE9",33994:"TEXTURE10",33995:"TEXTURE11",33996:"TEXTURE12",33997:"TEXTURE13",33998:"TEXTURE14",33999:"TEXTURE15",34e3:"TEXTURE16",34001:"TEXTURE17",34002:"TEXTURE18",34003:"TEXTURE19",34004:"TEXTURE20",34005:"TEXTURE21",34006:"TEXTURE22",34007:"TEXTURE23",34008:"TEXTURE24",34009:"TEXTURE25",34010:"TEXTURE26",34011:"TEXTURE27",34012:"TEXTURE28",34013:"TEXTURE29",34014:"TEXTURE30",34015:"TEXTURE31",34016:"ACTIVE_TEXTURE",34024:"MAX_RENDERBUFFER_SIZE",34041:"DEPTH_STENCIL",34055:"INCR_WRAP",34056:"DECR_WRAP",34067:"TEXTURE_CUBE_MAP",34068:"TEXTURE_BINDING_CUBE_MAP",34069:"TEXTURE_CUBE_MAP_POSITIVE_X",34070:"TEXTURE_CUBE_MAP_NEGATIVE_X",34071:"TEXTURE_CUBE_MAP_POSITIVE_Y",34072:"TEXTURE_CUBE_MAP_NEGATIVE_Y",34073:"TEXTURE_CUBE_MAP_POSITIVE_Z",34074:"TEXTURE_CUBE_MAP_NEGATIVE_Z",34076:"MAX_CUBE_MAP_TEXTURE_SIZE",34338:"VERTEX_ATTRIB_ARRAY_ENABLED",34339:"VERTEX_ATTRIB_ARRAY_SIZE",34340:"VERTEX_ATTRIB_ARRAY_STRIDE",34341:"VERTEX_ATTRIB_ARRAY_TYPE",34342:"CURRENT_VERTEX_ATTRIB",34373:"VERTEX_ATTRIB_ARRAY_POINTER",34466:"NUM_COMPRESSED_TEXTURE_FORMATS",34467:"COMPRESSED_TEXTURE_FORMATS",34660:"BUFFER_SIZE",34661:"BUFFER_USAGE",34816:"STENCIL_BACK_FUNC",34817:"STENCIL_BACK_FAIL",34818:"STENCIL_BACK_PASS_DEPTH_FAIL",34819:"STENCIL_BACK_PASS_DEPTH_PASS",34877:"BLEND_EQUATION_ALPHA",34921:"MAX_VERTEX_ATTRIBS",34922:"VERTEX_ATTRIB_ARRAY_NORMALIZED",34930:"MAX_TEXTURE_IMAGE_UNITS",34962:"ARRAY_BUFFER",34963:"ELEMENT_ARRAY_BUFFER",34964:"ARRAY_BUFFER_BINDING",34965:"ELEMENT_ARRAY_BUFFER_BINDING",34975:"VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",35040:"STREAM_DRAW",35044:"STATIC_DRAW",35048:"DYNAMIC_DRAW",35632:"FRAGMENT_SHADER",35633:"VERTEX_SHADER",35660:"MAX_VERTEX_TEXTURE_IMAGE_UNITS",35661:"MAX_COMBINED_TEXTURE_IMAGE_UNITS",35663:"SHADER_TYPE",35664:"FLOAT_VEC2",35665:"FLOAT_VEC3",35666:"FLOAT_VEC4",35667:"INT_VEC2",35668:"INT_VEC3",35669:"INT_VEC4",35670:"BOOL",35671:"BOOL_VEC2",35672:"BOOL_VEC3",35673:"BOOL_VEC4",35674:"FLOAT_MAT2",35675:"FLOAT_MAT3",35676:"FLOAT_MAT4",35678:"SAMPLER_2D",35680:"SAMPLER_CUBE",35712:"DELETE_STATUS",35713:"COMPILE_STATUS",35714:"LINK_STATUS",35715:"VALIDATE_STATUS",35716:"INFO_LOG_LENGTH",35717:"ATTACHED_SHADERS",35718:"ACTIVE_UNIFORMS",35719:"ACTIVE_UNIFORM_MAX_LENGTH",35720:"SHADER_SOURCE_LENGTH",35721:"ACTIVE_ATTRIBUTES",35722:"ACTIVE_ATTRIBUTE_MAX_LENGTH",35724:"SHADING_LANGUAGE_VERSION",35725:"CURRENT_PROGRAM",36003:"STENCIL_BACK_REF",36004:"STENCIL_BACK_VALUE_MASK",36005:"STENCIL_BACK_WRITEMASK",36006:"FRAMEBUFFER_BINDING",36007:"RENDERBUFFER_BINDING",36048:"FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",36049:"FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",36050:"FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",36051:"FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",36053:"FRAMEBUFFER_COMPLETE",36054:"FRAMEBUFFER_INCOMPLETE_ATTACHMENT",36055:"FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",36057:"FRAMEBUFFER_INCOMPLETE_DIMENSIONS",36061:"FRAMEBUFFER_UNSUPPORTED",36064:"COLOR_ATTACHMENT0",36096:"DEPTH_ATTACHMENT",36128:"STENCIL_ATTACHMENT",36160:"FRAMEBUFFER",36161:"RENDERBUFFER",36162:"RENDERBUFFER_WIDTH",36163:"RENDERBUFFER_HEIGHT",36164:"RENDERBUFFER_INTERNAL_FORMAT",36168:"STENCIL_INDEX8",36176:"RENDERBUFFER_RED_SIZE",36177:"RENDERBUFFER_GREEN_SIZE",36178:"RENDERBUFFER_BLUE_SIZE",36179:"RENDERBUFFER_ALPHA_SIZE",36180:"RENDERBUFFER_DEPTH_SIZE",36181:"RENDERBUFFER_STENCIL_SIZE",36194:"RGB565",36336:"LOW_FLOAT",36337:"MEDIUM_FLOAT",36338:"HIGH_FLOAT",36339:"LOW_INT",36340:"MEDIUM_INT",36341:"HIGH_INT",36346:"SHADER_COMPILER",36347:"MAX_VERTEX_UNIFORM_VECTORS",36348:"MAX_VARYING_VECTORS",36349:"MAX_FRAGMENT_UNIFORM_VECTORS",37440:"UNPACK_FLIP_Y_WEBGL",37441:"UNPACK_PREMULTIPLY_ALPHA_WEBGL",37442:"CONTEXT_LOST_WEBGL",37443:"UNPACK_COLORSPACE_CONVERSION_WEBGL",37444:"BROWSER_DEFAULT_WEBGL"}},{}],65:[function(t,e,r){var n=t("./1.0/numbers");e.exports=function(t){return n[t]}},{"./1.0/numbers":64}],66:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o,s,l){ ++this.plot=t,this.shader=e,this.fillShader=r,this.pickShader=n,this.positionBuffer=i,this.colorBuffer=a,this.idBuffer=o,this.fillPositionBuffer=s,this.fillColorBuffer=l,this.fillVerts=0,this.xData=[],this.yData=[],this.shape=[0,0],this.bounds=[1/0,1/0,-(1/0),-(1/0)],this.pickOffset=0,this.numVertices=0,this.lineWidth=1}function i(t,e){var r=Math.floor(e);if(r<0)return t[0];if(r>=t.length-1)return t[t.length-1];var n=e-r;return(1-n)*t[r]+n*t[r+1]}function a(t,e){var r=t.gl,i=s(r,p.vertex,p.fragment),a=s(r,p.pickVertex,p.pickFragment),o=s(r,p.fillVertex,p.fragment),u=l(r),c=l(r),f=l(r),h=l(r),d=l(r),g=new n(t,i,o,a,u,c,f,h,d);return g.update(e),t.addObject(g),g}e.exports=a;var o=t("iota-array"),s=t("gl-shader"),l=t("gl-buffer"),u=t("ndarray"),c=t("surface-nets"),f=t("cdt2d"),h=t("clean-pslg"),d=t("binary-search-bounds"),p=t("./lib/shaders"),g=n.prototype,v=[1,0,0,0,0,1,1,0,1,1,0,1];g.draw=function(){var t=[1,0,0,0,1,0,0,0,1],e=[0,0];return function(){var r,n,i=this.plot,a=this.shader,o=this.fillShader,s=this.bounds,l=this.numVertices,u=this.fillVerts,c=i.gl,f=i.viewBox,h=i.dataBox,d=s[2]-s[0],p=s[3]-s[1],g=h[2]-h[0],v=h[3]-h[1];if(t[0]=2*d/g,t[4]=2*p/v,t[6]=2*(s[0]-h[0])/g-1,t[7]=2*(s[1]-h[1])/v-1,e[0]=f[2]-f[0],e[1]=f[3]-f[1],u>0&&(o.bind(),r=o.uniforms,r.viewTransform=t,r.screenShape=e,n=a.attributes,this.fillPositionBuffer.bind(),n.position.pointer(),this.fillColorBuffer.bind(),n.color.pointer(c.UNSIGNED_BYTE,!0),c.drawArrays(c.TRIANGLES,0,u)),l>0){a.bind();var m=this.lineWidth*i.pixelRatio;r=a.uniforms,r.viewTransform=t,r.screenShape=e,r.lineWidth=m,r.pointSize=1e3,n=a.attributes,this.positionBuffer.bind(),n.position.pointer(c.FLOAT,!1,16,0),n.tangent.pointer(c.FLOAT,!1,16,8),this.colorBuffer.bind(),n.color.pointer(c.UNSIGNED_BYTE,!0),c.drawArrays(c.TRIANGLES,0,l),r.lineWidth=0,r.pointSize=m,this.positionBuffer.bind(),n.position.pointer(c.FLOAT,!1,48,0),n.tangent.pointer(c.FLOAT,!1,48,8),this.colorBuffer.bind(),n.color.pointer(c.UNSIGNED_BYTE,!0,12,0),c.drawArrays(c.POINTS,0,l/3)}}}(),g.drawPick=function(){return function(t){return t}}(),g.pick=function(t,e,r){return null},g.update=function(t){function e(t,e,r,n){var i=n-r;return Math.abs(i)<1e-6?e:Math.floor(e)+Math.max(.001,Math.min(.999,(t-r)/i))}t=t||{};var r=t.shape||[0,0],n=t.x||o(r[0]),a=t.y||o(r[1]),s=t.z||new Float32Array(r[0]*r[1]),l=t.levels||[],p=t.levelColors||[],g=this.bounds,m=g[0]=n[0],y=g[1]=a[0],b=g[2]=n[n.length-1],x=g[3]=a[a.length-1];m===b&&(g[2]+=1,b+=1),y===x&&(g[3]+=1,x+=1);var _=1/(b-m),w=1/(x-y);this.xData=n,this.yData=a,this.lineWidth=t.lineWidth||1;for(var A=u(s,r),k=[],M=[],E=[],T=[],L=[[0,0],[r[0]-1,0],[0,r[1]-1],[r[0]-1,r[1]-1]],S=0;S0&&C===l[S-1])){for(var R=c(A,C),I=255*p[4*S]|0,P=255*p[4*S+1]|0,O=255*p[4*S+2]|0,N=255*p[4*S+3]|0,z=R.cells,D=R.positions,F=Array(D.length),B=0;B1)){var q,H=V[0],G=V[1],X=A.get(Math.floor(H),Math.floor(G)),Y=A.get(Math.floor(H),Math.ceil(G)),W=A.get(Math.ceil(H),Math.floor(G)),Z=A.get(Math.ceil(H),Math.ceil(G));0===Math.floor(V[0])&&X<=C!=Y>1;for(e=0;e0&&(k*=b),M<0?M*=x:M>0&&(M*=_),v[m++]=h*(r-p+k),v[m++]=d*(n-g+M),v[m++]=o*A[2]+(l+o)*A[4],v[m++]=o*A[3]+(l+o)*A[5]}}this.buffer.update(v),s.free(v)},c.dispose=function(){this.plot.removeObject(this),this.shader.dispose(),this.buffer.dispose()}},{"./lib/shaders":70,"gl-buffer":63,"gl-shader":96,"typedarray-pool":162}],70:[function(t,e,r){e.exports={vertex:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec2 pixelOffset;\n\nuniform mat3 viewTransform;\nuniform vec2 pixelScale;\n\nvoid main() {\n vec3 scrPosition = viewTransform * vec3(position, 1);\n gl_Position = vec4(\n scrPosition.xy + scrPosition.z * pixelScale * pixelOffset,\n 0,\n scrPosition.z);\n}\n",fragment:"precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 color;\n\nvoid main() {\n gl_FragColor = vec4(color.rgb * color.a, color.a);\n}\n"}},{}],71:[function(t,e,r){"use strict";function n(t){var e=t.getParameter(t.FRAMEBUFFER_BINDING),r=t.getParameter(t.RENDERBUFFER_BINDING),n=t.getParameter(t.TEXTURE_BINDING_2D);return[e,r,n]}function i(t,e){t.bindFramebuffer(t.FRAMEBUFFER,e[0]),t.bindRenderbuffer(t.RENDERBUFFER,e[1]),t.bindTexture(t.TEXTURE_2D,e[2])}function a(t,e){var r=t.getParameter(e.MAX_COLOR_ATTACHMENTS_WEBGL);y=new Array(r+1);for(var n=0;n<=r;++n){for(var i=new Array(r),a=0;a1&&h.drawBuffersWEBGL(y[f]);var m=r.getExtension("WEBGL_depth_texture");m?d?t.depth=s(r,u,c,m.UNSIGNED_INT_24_8_WEBGL,r.DEPTH_STENCIL,r.DEPTH_STENCIL_ATTACHMENT):p&&(t.depth=s(r,u,c,r.UNSIGNED_SHORT,r.DEPTH_COMPONENT,r.DEPTH_ATTACHMENT)):p&&d?t._depth_rb=l(r,u,c,r.DEPTH_STENCIL,r.DEPTH_STENCIL_ATTACHMENT):p?t._depth_rb=l(r,u,c,r.DEPTH_COMPONENT16,r.DEPTH_ATTACHMENT):d&&(t._depth_rb=l(r,u,c,r.STENCIL_INDEX,r.STENCIL_ATTACHMENT));var b=r.checkFramebufferStatus(r.FRAMEBUFFER);if(b!==r.FRAMEBUFFER_COMPLETE){t._destroyed=!0,r.bindFramebuffer(r.FRAMEBUFFER,null),r.deleteFramebuffer(t.handle),t.handle=null,t.depth&&(t.depth.dispose(),t.depth=null),t._depth_rb&&(r.deleteRenderbuffer(t._depth_rb),t._depth_rb=null);for(var v=0;vs||r<0||r>s)throw new Error("gl-fbo: Can't resize FBO, invalid dimensions");t._shape[0]=e,t._shape[1]=r;for(var l=n(a),u=0;uo||r<0||r>o)throw new Error("gl-fbo: Parameters are too large for FBO");n=n||{};var s=1;if("color"in n){if(s=Math.max(0|n.color,0),s<0)throw new Error("gl-fbo: Must specify a nonnegative number of colors");if(s>1){if(!i)throw new Error("gl-fbo: Multiple draw buffer extension not supported");if(s>t.getParameter(i.MAX_COLOR_ATTACHMENTS_WEBGL))throw new Error("gl-fbo: Context does not support "+s+" draw buffers")}}var l=t.UNSIGNED_BYTE,u=t.getExtension("OES_texture_float");if(n.float&&s>0){if(!u)throw new Error("gl-fbo: Context does not support floating point textures");l=t.FLOAT}else n.preferFloat&&s>0&&u&&(l=t.FLOAT);var f=!0;"depth"in n&&(f=!!n.depth);var h=!1;return"stencil"in n&&(h=!!n.stencil),new c(t,e,r,l,s,f,h,i)}var d=t("gl-texture2d");e.exports=h;var p,g,v,m,y=null,b=c.prototype;Object.defineProperties(b,{shape:{get:function(){return this._destroyed?[0,0]:this._shapeVector},set:function(t){if(Array.isArray(t)||(t=[0|t,0|t]),2!==t.length)throw new Error("gl-fbo: Shape vector must be length 2");var e=0|t[0],r=0|t[1];return f(this,e,r),[e,r]},enumerable:!1},width:{get:function(){return this._destroyed?0:this._shape[0]},set:function(t){return t=0|t,f(this,t,this._shape[1]),t},enumerable:!1},height:{get:function(){return this._destroyed?0:this._shape[1]},set:function(t){return t=0|t,f(this,this._shape[0],t),t},enumerable:!1}}),b.bind=function(){if(!this._destroyed){var t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,this.handle),t.viewport(0,0,this._shape[0],this._shape[1])}},b.dispose=function(){if(!this._destroyed){this._destroyed=!0;var t=this.gl;t.deleteFramebuffer(this.handle),this.handle=null,this.depth&&(this.depth.dispose(),this.depth=null),this._depth_rb&&(t.deleteRenderbuffer(this._depth_rb),this._depth_rb=null);for(var e=0;e>8*h&255;this.pickOffset=r,i.bind();var d=i.uniforms;d.viewTransform=t,d.pickOffset=e;var p=i.attributes;return this.positionBuffer.bind(),p.position.pointer(),this.idBuffer.bind(),p.pickId.pointer(o.UNSIGNED_BYTE,!1),o.drawArrays(o.TRIANGLES,0,this.numVertices),r+this.shape[0]*this.shape[1]}}(),f.pick=function(t,e,r){var n=this.pickOffset,i=this.shape[0]*this.shape[1];if(r=n+i)return null;var a=r-n,o=this.xData,s=this.yData;return{object:this,pointId:a,dataCoord:[o[a%this.shape[0]],s[a/this.shape[0]|0]]}},f.update=function(t){t=t||{};var e=t.shape||[0,0],r=t.x||o(e[0]),n=t.y||o(e[1]),i=t.z||new Float32Array(e[0]*e[1]);this.xData=r,this.yData=n;var l=t.colorLevels||[0],u=t.colorValues||[0,0,0,1],c=l.length,f=this.bounds,d=f[0]=r[0],p=f[1]=n[0],g=f[2]=r[r.length-1],v=f[3]=n[n.length-1],m=1/(g-d),y=1/(v-p),b=e[0]*e[1]*(h.length>>>1);this.numVertices=b;var x=s.mallocUint8(4*b),_=s.mallocFloat32(2*b),w=s.mallocUint32(b),A=e[0],k=e[1];this.shape=[A,k];for(var M=0,E=0;E2&&!this.usingDashes){ ++var C=this.mitreShader;C.bind();var R=C.uniforms;R.matrix=t,R.color=s,R.screenShape=e,R.radius=l*p,C.attributes.p.pointer(f.FLOAT,!1,48,0),f.drawArrays(f.POINTS,0,c/3|0)}}}}(),h.drawPick=function(){var t=[1,0,0,0,1,0,0,0,1],e=[0,0],r=[0,0,0,0];return function(n){var i=this.plot,a=this.pickShader,o=this.lineBuffer,s=this.pickBuffer,l=this.width,u=this.numPoints,c=this.bounds,f=this.vertCount,h=i.gl,d=i.viewBox,p=i.dataBox,g=i.pickPixelRatio,v=c[2]-c[0],m=c[3]-c[1],y=p[2]-p[0],b=p[3]-p[1],x=d[2]-d[0],_=d[3]-d[1];if(this.pickOffset=n,!f)return n+u;t[0]=2*v/y,t[4]=2*m/b,t[6]=2*(c[0]-p[0])/y-1,t[7]=2*(c[1]-p[1])/b-1,e[0]=x,e[1]=_,r[0]=255&n,r[1]=n>>>8&255,r[2]=n>>>16&255,r[3]=n>>>24,a.bind();var w=a.uniforms;w.matrix=t,w.width=l*g,w.pickOffset=r,w.screenShape=e;var A=a.attributes;return o.bind(),A.a.pointer(h.FLOAT,!1,16,0),A.d.pointer(h.FLOAT,!1,16,8),s.bind(),A.pick0.pointer(h.UNSIGNED_BYTE,!1,8,0),A.pick1.pointer(h.UNSIGNED_BYTE,!1,8,4),h.drawArrays(h.TRIANGLES,0,f),n+u}}(),h.pick=function(t,e,r){var n=this.pickOffset,i=this.numPoints;if(r=n+i)return null;var a=r-n,o=this.data;return{object:this,pointId:a,dataCoord:[o[2*a],o[2*a+1]]}},h.update=function(t){t=t||{};var e=this.plot.gl;!!t.connectGaps;this.color=(t.color||[0,0,1,1]).slice(),this.width=+(t.width||1),this.fill=(t.fill||[!1,!1,!1,!1]).slice(),this.fillColor=i(t.fillColor||[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]]);for(var r=t.dashes||[1],n=0,a=0;a1,this.dashPattern=l(e,u(o,[n,1,4],[1,0,0])),this.dashPattern.minFilter=e.NEAREST,this.dashPattern.magFilter=e.NEAREST,this.dashLength=n,c.free(o);var d=t.positions;this.data=d;var p=this.bounds;p[0]=p[1]=1/0,p[2]=p[3]=-(1/0);var g=this.numPoints=d.length>>>1;if(0!==g){for(var a=0;a1;){var A=--s,v=d[2*s],m=d[2*s+1],k=A-1,M=d[2*k],E=d[2*k+1];if(!(isNaN(v)||isNaN(m)||isNaN(M)||isNaN(E))){w+=1,v=(v-p[0])/(p[2]-p[0]),m=(m-p[1])/(p[3]-p[1]),M=(M-p[0])/(p[2]-p[0]),E=(E-p[1])/(p[3]-p[1]);var T=M-v,L=E-m,S=A|1<<24,C=A-1,R=A,I=A-1|1<<24;y[--x]=-L,y[--x]=-T,y[--x]=m,y[--x]=v,b[--_]=S,b[--_]=C,y[--x]=L,y[--x]=T,y[--x]=E,y[--x]=M,b[--_]=R,b[--_]=I,y[--x]=-L,y[--x]=-T,y[--x]=E,y[--x]=M,b[--_]=R,b[--_]=I,y[--x]=L,y[--x]=T,y[--x]=E,y[--x]=M,b[--_]=R,b[--_]=I,y[--x]=-L,y[--x]=-T,y[--x]=m,y[--x]=v,b[--_]=S,b[--_]=C,y[--x]=L,y[--x]=T,y[--x]=m,y[--x]=v,b[--_]=S,b[--_]=C}}this.vertCount=6*w,this.lineBuffer.update(y.subarray(x)),this.pickBuffer.update(b.subarray(_)),c.free(y),c.free(b)}},h.dispose=function(){this.plot.removeObject(this),this.lineBuffer.dispose(),this.pickBuffer.dispose(),this.lineShader.dispose(),this.mitreShader.dispose(),this.fillShader.dispose(),this.pickShader.dispose(),this.dashPattern.dispose()}},{"./lib/shaders":76,"gl-buffer":63,"gl-shader":96,"gl-texture2d":104,ndarray:123,"typedarray-pool":162}],78:[function(t,e,r){function n(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=r+r,s=n+n,l=i+i,u=r*o,c=n*o,f=n*s,h=i*o,d=i*s,p=i*l,g=a*o,v=a*s,m=a*l;return t[0]=1-f-p,t[1]=c+m,t[2]=h-v,t[3]=0,t[4]=c-m,t[5]=1-u-p,t[6]=d+g,t[7]=0,t[8]=h+v,t[9]=d-g,t[10]=1-u-f,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}e.exports=n},{}],79:[function(t,e,r){"use strict";function n(t,e,r){this.plot=t,this.vbo=e,this.shader=r}function i(t){var e=t.gl,r=a(e,[0,0,0,1,1,0,1,1]),i=o(e,s.boxVert,s.lineFrag);return new n(t,r,i)}e.exports=i;var a=t("gl-buffer"),o=t("gl-shader"),s=t("./shaders"),l=n.prototype;l.bind=function(){var t=this.shader;this.vbo.bind(),this.shader.bind(),t.attributes.coord.pointer(),t.uniforms.screenBox=this.plot.screenBox},l.drawBox=function(){var t=[0,0],e=[0,0];return function(r,n,i,a,o){var s=this.plot,l=this.shader,u=s.gl;t[0]=r,t[1]=n,e[0]=i,e[1]=a,l.uniforms.lo=t,l.uniforms.hi=e,l.uniforms.color=o,u.drawArrays(u.TRIANGLE_STRIP,0,4)}}(),l.dispose=function(){this.vbo.dispose(),this.shader.dispose()}},{"./shaders":82,"gl-buffer":63,"gl-shader":96}],80:[function(t,e,r){"use strict";function n(t,e,r,n){this.plot=t,this.vbo=e,this.shader=r,this.tickShader=n,this.ticks=[[],[]]}function i(t,e){return t-e}function a(t){var e=t.gl,r=o(e),i=s(e,u.gridVert,u.gridFrag),a=s(e,u.tickVert,u.gridFrag),l=new n(t,r,i,a);return l}e.exports=a;var o=t("gl-buffer"),s=t("gl-shader"),l=t("binary-search-bounds"),u=t("./shaders"),c=n.prototype;c.draw=function(){var t=[0,0],e=[0,0],r=[0,0];return function(){for(var n=this.plot,i=this.vbo,a=this.shader,o=this.ticks,s=n.gl,l=n._tickBounds,u=n.dataBox,c=n.viewBox,f=n.gridLineWidth,h=n.gridLineColor,d=n.gridLineEnable,p=n.pixelRatio,g=0;g<2;++g){var v=l[g],m=l[g+2],y=m-v,b=.5*(u[g+2]+u[g]),x=u[g+2]-u[g];e[g]=2*y/x,t[g]=2*(v-b)/x}a.bind(),i.bind(),a.attributes.dataCoord.pointer(),a.uniforms.dataShift=t,a.uniforms.dataScale=e;for(var _=0,g=0;g<2;++g){r[0]=r[1]=0,r[g]=1,a.uniforms.dataAxis=r,a.uniforms.lineWidth=f[g]/(c[g+2]-c[g])*p,a.uniforms.color=h[g];var w=6*o[g].length;d[g]&&w&&s.drawArrays(s.TRIANGLES,_,w),_+=w}}}(),c.drawTickMarks=function(){var t=[0,0],e=[0,0],r=[1,0],n=[0,1],a=[0,0],o=[0,0];return function(){for(var s=this.plot,u=this.vbo,c=this.tickShader,f=this.ticks,h=s.gl,d=s._tickBounds,p=s.dataBox,g=s.viewBox,v=s.pixelRatio,m=s.screenBox,y=m[2]-m[0],b=m[3]-m[1],x=g[2]-g[0],_=g[3]-g[1],w=0;w<2;++w){var A=d[w],k=d[w+2],M=k-A,E=.5*(p[w+2]+p[w]),T=p[w+2]-p[w];e[w]=2*M/T,t[w]=2*(A-E)/T}e[0]*=x/y,t[0]*=x/y,e[1]*=_/b,t[1]*=_/b,c.bind(),u.bind(),c.attributes.dataCoord.pointer();var L=c.uniforms;L.dataShift=t,L.dataScale=e;var S=s.tickMarkLength,C=s.tickMarkWidth,R=s.tickMarkColor,I=0,P=6*f[0].length,O=Math.min(l.ge(f[0],(p[0]-d[0])/(d[2]-d[0]),i),f[0].length),N=Math.min(l.gt(f[0],(p[2]-d[0])/(d[2]-d[0]),i),f[0].length),z=I+6*O,D=6*Math.max(0,N-O),F=Math.min(l.ge(f[1],(p[1]-d[1])/(d[3]-d[1]),i),f[1].length),B=Math.min(l.gt(f[1],(p[3]-d[1])/(d[3]-d[1]),i),f[1].length),j=P+6*F,U=6*Math.max(0,B-F);a[0]=2*(g[0]-S[1])/y-1,a[1]=(g[3]+g[1])/b-1,o[0]=S[1]*v/y,o[1]=C[1]*v/b,U&&(L.color=R[1],L.tickScale=o,L.dataAxis=n,L.screenOffset=a,h.drawArrays(h.TRIANGLES,j,U)),a[0]=(g[2]+g[0])/y-1,a[1]=2*(g[1]-S[0])/b-1,o[0]=C[0]*v/y,o[1]=S[0]*v/b,D&&(L.color=R[0],L.tickScale=o,L.dataAxis=r,L.screenOffset=a,h.drawArrays(h.TRIANGLES,z,D)),a[0]=2*(g[2]+S[3])/y-1,a[1]=(g[3]+g[1])/b-1,o[0]=S[3]*v/y,o[1]=C[3]*v/b,U&&(L.color=R[3],L.tickScale=o,L.dataAxis=n,L.screenOffset=a,h.drawArrays(h.TRIANGLES,j,U)),a[0]=(g[2]+g[0])/y-1,a[1]=2*(g[3]+S[2])/b-1,o[0]=C[2]*v/y,o[1]=S[2]*v/b,D&&(L.color=R[2],L.tickScale=o,L.dataAxis=r,L.screenOffset=a,h.drawArrays(h.TRIANGLES,z,D))}}(),c.update=function(){var t=[1,1,-1,-1,1,-1],e=[1,-1,1,1,-1,-1];return function(r){for(var n=r.ticks,i=r.bounds,a=new Float32Array(18*(n[0].length+n[1].length)),o=(this.plot.zeroLineEnable,0),s=[[],[]],l=0;l<2;++l)for(var u=s[l],c=n[l],f=i[l],h=i[l+2],d=0;ds[k]&&(a.uniforms.dataAxis=t,a.uniforms.screenOffset=e,a.uniforms.color=v[n],a.uniforms.angle=m[n],u.drawArrays(u.TRIANGLES,s[k],s[M]-s[k]))),y[n]&&A&&(e[1^n]-=E*d*b[n],a.uniforms.dataAxis=r,a.uniforms.screenOffset=e,a.uniforms.color=x[n],a.uniforms.angle=_[n],u.drawArrays(u.TRIANGLES,w,A)),e[1^n]=E*c[2+(1^n)]-1,p[n+2]&&(e[1^n]+=E*d*g[n+2],ks[k]&&(a.uniforms.dataAxis=t,a.uniforms.screenOffset=e,a.uniforms.color=v[n+2],a.uniforms.angle=m[n+2],u.drawArrays(u.TRIANGLES,s[k],s[M]-s[k]))),y[n+2]&&A&&(e[1^n]+=E*d*b[n+2],a.uniforms.dataAxis=r,a.uniforms.screenOffset=e,a.uniforms.color=x[n+2],a.uniforms.angle=_[n+2],u.drawArrays(u.TRIANGLES,w,A))}}(),c.drawTitle=function(){var t=[0,0],e=[0,0];return function(){var r=this.plot,n=this.shader,i=r.gl,a=r.screenBox,o=r.titleCenter,s=r.titleAngle,l=r.titleColor,o=r.titleCenter,u=r.pixelRatio;if(this.titleCount){for(var c=0;c<2;++c)e[c]=2*(o[c]*u-a[c])/(a[2+c]-a[c])-1;n.bind(),n.uniforms.dataAxis=t,n.uniforms.screenOffset=e,n.uniforms.angle=s,n.uniforms.color=l,i.drawArrays(i.TRIANGLES,this.titleOffset,this.titleCount)}}}(),c.bind=function(){var t=[0,0],e=[0,0],r=[0,0];return function(){var n=this.plot,i=this.shader,a=n._tickBounds,o=n.dataBox,s=n.screenBox,l=n.viewBox;i.bind();for(var u=0;u<2;++u){var c=a[u],f=a[u+2],h=f-c,d=.5*(o[u+2]+o[u]),p=o[u+2]-o[u],g=l[u],v=l[u+2],m=v-g,y=s[u],b=s[u+2],x=b-y;e[u]=2*h/p*m/x,t[u]=2*(c-d)/p*m/x}r[1]=2*n.pixelRatio/(s[3]-s[1]),r[0]=r[1]*(s[3]-s[1])/(s[2]-s[0]),i.uniforms.dataScale=e,i.uniforms.dataShift=t,i.uniforms.textScale=r,this.vbo.bind(),i.attributes.textCoordinate.pointer()}}(),c.update=function(t){for(var e=[],r=t.ticks,n=t.bounds,i=0;i<2;++i){for(var a=[Math.floor(e.length/3)],o=[-(1/0)],l=r[i],u=0;u=0){var g=e[p]-n[p]*(e[p+2]-e[p])/(n[p+2]-n[p]);0===p?o.drawLine(g,e[1],g,e[3],d[p],h[p]):o.drawLine(e[0],g,e[2],g,d[p],h[p])}}for(var p=0;p=0;--t)this.objects[t].dispose();this.objects.length=0;for(var t=this.overlays.length-1;t>=0;--t)this.overlays[t].dispose();this.overlays.length=0,this.gl=null},h.addObject=function(t){this.objects.indexOf(t)<0&&(this.objects.push(t),this.setDirty())},h.removeObject=function(t){for(var e=this.objects,r=0;r>8*u&255;return t.call(this),o.bind(),o.uniforms.pixelScale=r,o.uniforms.viewTransform=e,o.uniforms.pickOffset=n,this.positionBuffer.bind(),o.attributes.position.pointer(),this.offsetBuffer.bind(),o.attributes.offset.pointer(),this.idBuffer.bind(),o.attributes.id.pointer(l.UNSIGNED_BYTE,!1),l.drawArrays(l.TRIANGLES,0,s),i+this.numPoints}}(),d.pick=function(t,e,r){var n=this.pickOffset,i=this.numPoints;if(r=n+i)return null;var a=r-n,o=this.points;return{object:this,pointId:a,dataCoord:[o[2*a],o[2*a+1]]}},d.update=function(t){t=t||{};var e=t.positions||[],r=t.colors||[],i=t.glyphs||[],a=t.sizes||[],o=t.borderWidths||[],s=t.borderColors||[];this.points=e;for(var c=this.bounds=[1/0,1/0,-(1/0),-(1/0)],f=0,h=0;h>1;for(var d=0;d<2;++d)c[d]=Math.min(c[d],e[2*h+d]),c[2+d]=Math.max(c[2+d],e[2*h+d])}c[0]===c[2]&&(c[2]+=1),c[3]===c[1]&&(c[3]+=1);for(var p=1/(c[2]-c[0]),g=1/(c[3]-c[1]),v=c[0],m=c[1],y=u.mallocFloat32(2*f),b=u.mallocFloat32(2*f),x=u.mallocUint8(4*f),_=u.mallocUint32(f),w=0,h=0;ht;){var d=r[h-1],p=n[2*(h-1)];if((d-s||l-p)>=0)break;r[h]=d,n[2*h]=p,n[2*h+1]=n[2*h-1],i[h]=i[h-1],a[h]=a[h-1],h-=1}r[h]=s,n[2*h]=l,n[2*h+1]=u,i[h]=c,a[h]=f}}function a(t,e,r,n,i,a){var o=r[t],s=n[2*t],l=n[2*t+1],u=i[t],c=a[t];r[t]=r[e],n[2*t]=n[2*e],n[2*t+1]=n[2*e+1],i[t]=i[e],a[t]=a[e],r[e]=o,n[2*e]=s,n[2*e+1]=l,i[e]=u,a[e]=c}function o(t,e,r,n,i,a){r[t]=r[e],n[2*t]=n[2*e],n[2*t+1]=n[2*e+1],i[t]=i[e],a[t]=a[e]}function s(t,e,r,n,i,a,o){var s=n[t],l=i[2*t],u=i[2*t+1],c=a[t],f=o[t];n[t]=n[e],i[2*t]=i[2*e],i[2*t+1]=i[2*e+1],a[t]=a[e],o[t]=o[e],n[e]=n[r],i[2*e]=i[2*r],i[2*e+1]=i[2*r+1],a[e]=a[r],o[e]=o[r],n[r]=s,i[2*r]=l,i[2*r+1]=u,a[r]=c,o[r]=f}function l(t,e,r,n,i,a,o,s,l,u,c){s[t]=s[e],l[2*t]=l[2*e],l[2*t+1]=l[2*e+1],u[t]=u[e],c[t]=c[e],s[e]=r,l[2*e]=n,l[2*e+1]=i,u[e]=a,c[e]=o}function u(t,e,r,n,i){return(r[t]-r[e]||n[2*e]-n[2*t]||i[t]-i[e])<0}function c(t,e,r,n,i,a,o,s){return(e-a[t]||o[2*t]-r||i-s[t])<0}function f(t,e,r,n,d,p){ ++var g=(e-t+1)/6|0,v=t+g,m=e-g,y=t+e>>1,b=y-g,x=y+g,_=v,w=b,A=y,k=x,M=m,E=t+1,T=e-1,L=0;u(_,w,r,n,d,p)&&(L=_,_=w,w=L),u(k,M,r,n,d,p)&&(L=k,k=M,M=L),u(_,A,r,n,d,p)&&(L=_,_=A,A=L),u(w,A,r,n,d,p)&&(L=w,w=A,A=L),u(_,k,r,n,d,p)&&(L=_,_=k,k=L),u(A,k,r,n,d,p)&&(L=A,A=k,k=L),u(w,M,r,n,d,p)&&(L=w,w=M,M=L),u(w,A,r,n,d,p)&&(L=w,w=A,A=L),u(k,M,r,n,d,p)&&(L=k,k=M,M=L);var S=r[w],C=n[2*w],R=n[2*w+1],I=d[w],P=p[w],O=r[k],N=n[2*k],z=n[2*k+1],D=d[k],F=p[k],B=_,j=A,U=M,V=v,q=y,H=m,G=r[B],X=r[j],Y=r[U];r[V]=G,r[q]=X,r[H]=Y;for(var W=0;W<2;++W){var Z=n[2*B+W],Q=n[2*j+W],$=n[2*U+W];n[2*V+W]=Z,n[2*q+W]=Q,n[2*H+W]=$}var K=d[B],J=d[j],tt=d[U];d[V]=K,d[q]=J,d[H]=tt;var et=p[B],rt=p[j],nt=p[U];p[V]=et,p[q]=rt,p[H]=nt,o(b,t,r,n,d,p),o(x,e,r,n,d,p);for(var it=E;it<=T;++it)if(c(it,S,C,R,I,r,n,d))it!==E&&a(it,E,r,n,d,p),++E;else if(!c(it,O,N,z,D,r,n,d))for(;;){if(c(T,O,N,z,D,r,n,d)){c(T,S,C,R,I,r,n,d)?(s(it,E,T,r,n,d,p),++E,--T):(a(it,T,r,n,d,p),--T);break}if(--T=Math.max(.9*d,32)){var b=u+s>>>1;l(v,m,f,h,b,c+1),h=b}l(v,m,f,h,y,c+1),h=y}}}var u=t.length>>>1;if(u<1)return[];for(var c=1/0,f=1/0,h=-(1/0),d=-(1/0),p=0;p=0;--_){t[2*_]=(t[2*_]-c)*m,t[2*_+1]=(t[2*_+1]-f)*y;var M=x[_];M!==A&&(w.push(new i(b*Math.pow(.5,M),_+1,k-(_+1))),k=_+1,A=M)}return w.push(new i(b*Math.pow(.5,M+1),0,k)),o.free(x),w}var o=t("typedarray-pool"),s=t("./lib/sort");e.exports=a},{"./lib/sort":90,"typedarray-pool":162}],92:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){this.plot=t,this.offsetBuffer=e,this.pickBuffer=r,this.weightBuffer=n,this.shader=i,this.pickShader=a,this.scales=[],this.size=12,this.borderSize=1,this.pointCount=0,this.color=[1,0,0,1],this.borderColor=[0,0,0,1],this.bounds=[1/0,1/0,-(1/0),-(1/0)],this.pickOffset=0,this.points=null,this.xCoords=null}function i(t,e){var r=t.gl,i=o(r),s=o(r),l=o(r),u=a(r,c.pointVertex,c.pointFragment),f=a(r,c.pickVertex,c.pickFragment),h=new n(t,i,s,l,u,f);return h.update(e),t.addObject(h),h}var a=t("gl-shader"),o=t("gl-buffer"),s=t("binary-search-bounds"),l=t("snap-points-2d"),u=t("typedarray-pool"),c=t("./lib/shader");e.exports=i;var f=n.prototype;f.dispose=function(){this.shader.dispose(),this.pickShader.dispose(),this.offsetBuffer.dispose(),this.pickBuffer.dispose(),this.xCoords&&u.free(this.xCoords),this.plot.removeObject(this)},f.update=function(t){function e(e,r){return e in t?t[e]:r}t=t||{},this.size=e("size",12),this.color=e("color",[1,0,0,1]).slice(),this.borderSize=e("borderSize",1),this.borderColor=e("borderColor",[0,0,0,1]).slice(),this.xCoords&&u.free(this.xCoords);var r=t.positions,n=u.mallocFloat32(r.length),i=u.mallocInt32(r.length>>>1);n.set(r);var a=u.mallocFloat32(r.length);this.points=r,this.scales=l(n,i,a,this.bounds),this.offsetBuffer.update(n),this.pickBuffer.update(i),this.weightBuffer.update(a);for(var o=u.mallocFloat32(r.length>>>1),s=0,c=0;s>>1,this.pickOffset=0},f.drawPick=function(){var t=[1,0,0,0,1,0,0,0,1],e=[0,0,0,0];return function(r){var n=this.plot,i=this.pickShader,a=this.scales,o=this.offsetBuffer,l=this.pickBuffer,u=this.bounds,c=this.size,f=this.borderSize,h=n.gl,d=n.pickPixelRatio,p=n.viewBox,g=n.dataBox;if(0===this.pointCount)return r;var v=u[2]-u[0],m=u[3]-u[1],y=g[2]-g[0],b=g[3]-g[1],x=(p[2]-p[0])*d/n.pixelRatio,_=(p[3]-p[1])*d/n.pixelRatio,w=Math.min(y/x,b/_);t[0]=2*v/y,t[4]=2*m/b,t[6]=2*(u[0]-g[0])/y-1,t[7]=2*(u[1]-g[1])/b-1,this.pickOffset=r,e[0]=255&r,e[1]=r>>8&255,e[2]=r>>16&255,e[3]=r>>24&255,i.bind(),i.uniforms.matrix=t,i.uniforms.color=this.color,i.uniforms.borderColor=this.borderColor,i.uniforms.pointSize=d*(c+f),i.uniforms.pickOffset=e,0===this.borderSize?i.uniforms.centerFraction=2:i.uniforms.centerFraction=c/(c+f+1.25),o.bind(),i.attributes.position.pointer(),l.bind(),i.attributes.pickId.pointer(h.UNSIGNED_BYTE);for(var A=this.xCoords,k=(g[0]-u[0]-w*c*d)/v,M=(g[2]-u[0]+w*c*d)/v,E=a.length-1;E>=0;--E){var T=a[E];if(!(T.pixelSize1)){var L=T.offset,S=T.count+L,C=s.ge(A,k,L,S-1),R=s.lt(A,M,C,S-1)+1;R>C&&h.drawArrays(h.POINTS,C,R-C)}}return r+this.pointCount}}(),f.draw=function(){var t=[1,0,0,0,1,0,0,0,1];return function(){var e=this.plot,r=this.shader,n=this.scales,i=this.offsetBuffer,a=this.bounds,o=this.size,l=this.borderSize,u=e.gl,c=e.pixelRatio,f=e.viewBox,h=e.dataBox;if(0!==this.pointCount){var d=a[2]-a[0],p=a[3]-a[1],g=h[2]-h[0],v=h[3]-h[1],m=f[2]-f[0],y=f[3]-f[1],b=Math.min(g/m,v/y);t[0]=2*d/g,t[4]=2*p/v,t[6]=2*(a[0]-h[0])/g-1,t[7]=2*(a[1]-h[1])/v-1,r.bind(),r.uniforms.matrix=t,r.uniforms.color=this.color,r.uniforms.borderColor=this.borderColor,r.uniforms.pointSize=c*(o+l),r.uniforms.useWeight=1,0===this.borderSize?r.uniforms.centerFraction=2:r.uniforms.centerFraction=o/(o+l+1.25),i.bind(),r.attributes.position.pointer(),this.weightBuffer.bind(),r.attributes.weight.pointer();for(var x=this.xCoords,_=(h[0]-a[0]-b*o*c)/d,w=(h[2]-a[0]+b*o*c)/d,A=!0,k=n.length-1;k>=0;--k){var M=n[k];if(!(M.pixelSize1)){var E=M.offset,T=M.count+E,L=s.ge(x,_,E,T-1),S=s.lt(x,w,L,T-1)+1;S>L&&u.drawArrays(u.POINTS,L,S-L),A&&(A=!1,r.uniforms.useWeight=0)}}}}}(),f.pick=function(t,e,r){var n=this.pickOffset,i=this.pointCount;if(r=n+i)return null;var a=r-n,o=this.points;return{object:this,pointId:a,dataCoord:[o[2*a],o[2*a+1]]}}},{"./lib/shader":88,"binary-search-bounds":89,"gl-buffer":63,"gl-shader":96,"snap-points-2d":91,"typedarray-pool":162}],93:[function(t,e,r){"use strict";r.boxVertex="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 vertex;\n\nuniform vec2 cornerA, cornerB;\n\nvoid main() {\n gl_Position = vec4(mix(cornerA, cornerB, vertex), 0, 1);\n}\n",r.boxFragment="precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 color;\n\nvoid main() {\n gl_FragColor = color;\n}\n"},{}],94:[function(t,e,r){"use strict";function n(t,e,r){this.plot=t,this.boxBuffer=e,this.boxShader=r,this.enabled=!0,this.selectBox=[1/0,1/0,-(1/0),-(1/0)],this.borderColor=[0,0,0,1],this.innerFill=!1,this.innerColor=[0,0,0,.25],this.outerFill=!0,this.outerColor=[0,0,0,.5],this.borderWidth=10}function i(t,e){var r=t.gl,i=o(r,[0,0,0,1,1,0,1,1]),l=a(r,s.boxVertex,s.boxFragment),u=new n(t,i,l);return u.update(e),t.addOverlay(u),u}var a=t("gl-shader"),o=t("gl-buffer"),s=t("./lib/shaders");e.exports=i;var l=n.prototype;l.draw=function(){if(this.enabled){var t=this.plot,e=this.selectBox,r=this.borderWidth,n=(this.innerFill,this.innerColor),i=(this.outerFill,this.outerColor),a=this.borderColor,o=t.box,s=t.screenBox,l=t.dataBox,u=t.viewBox,c=t.pixelRatio,f=(e[0]-l[0])*(u[2]-u[0])/(l[2]-l[0])+u[0],h=(e[1]-l[1])*(u[3]-u[1])/(l[3]-l[1])+u[1],d=(e[2]-l[0])*(u[2]-u[0])/(l[2]-l[0])+u[0],p=(e[3]-l[1])*(u[3]-u[1])/(l[3]-l[1])+u[1];if(f=Math.max(f,u[0]),h=Math.max(h,u[1]),d=Math.min(d,u[2]),p=Math.min(p,u[3]),!(d0){var m=r*c;o.drawBox(f-m,h-m,d+m,h+m,a),o.drawBox(f-m,p-m,d+m,p+m,a),o.drawBox(f-m,h-m,f+m,p+m,a),o.drawBox(d-m,h-m,d+m,p+m,a)}}}},l.update=function(t){t=t||{},this.innerFill=!!t.innerFill,this.outerFill=!!t.outerFill,this.innerColor=(t.innerColor||[0,0,0,.5]).slice(),this.outerColor=(t.outerColor||[0,0,0,.5]).slice(),this.borderColor=(t.borderColor||[0,0,0,1]).slice(),this.borderWidth=t.borderWidth||0,this.selectBox=(t.selectBox||this.selectBox).slice()},l.dispose=function(){this.boxBuffer.dispose(),this.boxShader.dispose(),this.plot.removeOverlay(this)}},{"./lib/shaders":93,"gl-buffer":63,"gl-shader":96}],95:[function(t,e,r){"use strict";function n(t,e,r,n,i){this.coord=[t,e],this.id=r,this.value=n,this.distance=i}function i(t,e,r){this.gl=t,this.fbo=e,this.buffer=r,this._readTimeout=null;var n=this;this._readCallback=function(){n.gl&&(e.bind(),t.readPixels(0,0,e.shape[0],e.shape[1],t.RGBA,t.UNSIGNED_BYTE,n.buffer),n._readTimeout=null)}}function a(t,e){var r=o(t,e),n=s.mallocUint8(e[0]*e[1]*4);return new i(t,r,n)}e.exports=a;var o=t("gl-fbo"),s=t("typedarray-pool"),l=t("ndarray"),u=t("bit-twiddle").nextPow2,c=t("cwise/lib/wrapper")({args:["array",{offset:[0,0,1],array:0},{offset:[0,0,2],array:0},{offset:[0,0,3],array:0},"scalar","scalar","index"],pre:{body:"{this_closestD2=1e8,this_closestX=-1,this_closestY=-1}",args:[],thisVars:["this_closestD2","this_closestX","this_closestY"],localVars:[]},body:{body:"{if(_inline_55_arg0_<255||_inline_55_arg1_<255||_inline_55_arg2_<255||_inline_55_arg3_<255){var _inline_55_l=_inline_55_arg4_-_inline_55_arg6_[0],_inline_55_a=_inline_55_arg5_-_inline_55_arg6_[1],_inline_55_f=_inline_55_l*_inline_55_l+_inline_55_a*_inline_55_a;_inline_55_fthis.buffer.length){s.free(this.buffer);for(var n=this.buffer=s.mallocUint8(u(r*e*4)),i=0;ir)for(t=r;te)for(t=e;t=0){for(var k=0|A.type.charAt(A.type.length-1),M=new Array(k),E=0;E=0;)T+=1;w[b]=T}var L=new Array(r.length);a(),d._relink=a,d.types={uniforms:l(r),attributes:l(n)},d.attributes=s(p,d,x,w),Object.defineProperty(d,"uniforms",o(p,d,r,L))},e.exports=a},{"./lib/GLError":97,"./lib/create-attributes":98,"./lib/create-uniforms":99,"./lib/reflect":100,"./lib/runtime-reflect":101,"./lib/shader-cache":102}],97:[function(t,e,r){function n(t,e,r){this.shortMessage=e||"",this.longMessage=r||"",this.rawError=t||"",this.message="gl-shader: "+(e||t||"")+(r?"\n"+r:""),this.stack=(new Error).stack}n.prototype=new Error,n.prototype.name="GLError",n.prototype.constructor=n,e.exports=n},{}],98:[function(t,e,r){"use strict";function n(t,e,r,n,i,a){this._gl=t,this._wrapper=e,this._index=r,this._locations=n,this._dimension=i,this._constFunc=a}function i(t,e,r,i,a,o,s){for(var l=["gl","v"],u=[],c=0;c=0){var p=h.charCodeAt(h.length-1)-48;if(p<2||p>4)throw new s("","Invalid data type for attribute "+f+": "+h);i(t,e,d[0],n,p,o,f)}else{if(!(h.indexOf("mat")>=0))throw new s("","Unknown data type for attribute "+f+": "+h);var p=h.charCodeAt(h.length-1)-48;if(p<2||p>4)throw new s("","Invalid data type for attribute "+f+": "+h);a(t,e,d,n,p,o,f)}}}return o}e.exports=o;var s=t("./GLError"),l=n.prototype;l.pointer=function(t,e,r,n){var i=this,a=i._gl,o=i._locations[i._index];a.vertexAttribPointer(o,i._dimension,t||a.FLOAT,!!e,r||0,n||0),a.enableVertexAttribArray(o)},l.set=function(t,e,r,n){return this._constFunc(this._locations[this._index],t,e,r,n)},Object.defineProperty(l,"location",{get:function(){return this._locations[this._index]},set:function(t){return t!==this._locations[this._index]&&(this._locations[this._index]=0|t,this._wrapper.program=null),0|t}})},{"./GLError":97}],99:[function(t,e,r){"use strict";function n(t){var e=new Function("y","return function(){return y}");return e(t)}function i(t,e){for(var r=new Array(t),n=0;n4)throw new s("","Invalid uniform dimension type for matrix "+name+": "+r);return"gl.uniformMatrix"+i+"fv(locations["+e+"],false,obj"+t+")"}throw new s("","Unknown uniform data type for "+name+": "+r)}var i=r.charCodeAt(r.length-1)-48;if(i<2||i>4)throw new s("","Invalid data type");switch(r.charAt(0)){case"b":case"i":return"gl.uniform"+i+"iv(locations["+e+"],obj"+t+")";case"v":return"gl.uniform"+i+"fv(locations["+e+"],obj"+t+")";default:throw new s("","Unrecognized data type for vector "+name+": "+r)}}}function c(t,e){if("object"!=typeof e)return[[t,e]];var r=[];for(var n in e){var i=e[n],a=t;a+=parseInt(n)+""===n?"["+n+"]":"."+n,"object"==typeof i?r.push.apply(r,c(a,i)):r.push([a,i])}return r}function f(e){for(var n=["return function updateProperty(obj){"],i=c("",e),o=0;o4)throw new s("","Invalid data type");return"b"===t.charAt(0)?i(r,!1):i(r,0)}if(0===t.indexOf("mat")&&4===t.length){var r=t.charCodeAt(t.length-1)-48;if(r<2||r>4)throw new s("","Invalid uniform dimension type for matrix "+name+": "+t);return i(r*r,0)}throw new s("","Unknown uniform data type for "+name+": "+t)}}function d(t,e,i){if("object"==typeof i){var o=p(i);Object.defineProperty(t,e,{get:n(o),set:f(i),enumerable:!0,configurable:!1})}else a[i]?Object.defineProperty(t,e,{get:l(i),set:f(i),enumerable:!0,configurable:!1}):t[e]=h(r[i].type)}function p(t){var e;if(Array.isArray(t)){e=new Array(t.length);for(var r=0;r1){l[0]in o||(o[l[0]]=[]),o=o[l[0]];for(var u=1;u1)for(var l=0;li||r<0||r>i)throw new Error("gl-texture2d: Invalid texture size");return t._shape=[e,r],t.bind(),n.texImage2D(n.TEXTURE_2D,0,t.format,e,r,0,t.format,t.type,null),t._mipLevels=[0],t}function a(t,e,r,n,i,a){this.gl=t,this.handle=e,this.format=i,this.type=a,this._shape=[r,n],this._mipLevels=[0],this._magFilter=t.NEAREST,this._minFilter=t.NEAREST,this._wrapS=t.CLAMP_TO_EDGE,this._wrapT=t.CLAMP_TO_EDGE,this._anisoSamples=1;var o=this,s=[this._wrapS,this._wrapT];Object.defineProperties(s,[{get:function(){return o._wrapS},set:function(t){return o.wrapS=t}},{get:function(){return o._wrapT},set:function(t){return o.wrapT=t}}]),this._wrapVector=s;var l=[this._shape[0],this._shape[1]];Object.defineProperties(l,[{get:function(){return o._shape[0]},set:function(t){return o.width=t}},{get:function(){return o._shape[1]},set:function(t){return o.height=t}}]),this._shapeVector=l}function o(t,e){return 3===t.length?1===e[2]&&e[1]===t[0]*t[2]&&e[0]===t[2]:1===e[0]&&e[1]===t[0]}function s(t,e,r,n,i,a,s,l){var u=l.dtype,c=l.shape.slice();if(c.length<2||c.length>3)throw new Error("gl-texture2d: Invalid ndarray, must be 2d or 3d");var f=0,h=0,v=o(c,l.stride.slice());"float32"===u?f=t.FLOAT:"float64"===u?(f=t.FLOAT,v=!1,u="float32"):"uint8"===u?f=t.UNSIGNED_BYTE:(f=t.UNSIGNED_BYTE,v=!1,u="uint8");var m=1;if(2===c.length)h=t.LUMINANCE,c=[c[0],c[1],1],l=d(l.data,c,[l.stride[0],l.stride[1],1],l.offset);else{if(3!==c.length)throw new Error("gl-texture2d: Invalid shape for texture");if(1===c[2])h=t.ALPHA;else if(2===c[2])h=t.LUMINANCE_ALPHA;else if(3===c[2])h=t.RGB;else{if(4!==c[2])throw new Error("gl-texture2d: Invalid shape for pixel coords");h=t.RGBA}m=c[2]}if(h!==t.LUMINANCE&&h!==t.ALPHA||i!==t.LUMINANCE&&i!==t.ALPHA||(h=i),h!==i)throw new Error("gl-texture2d: Incompatible texture format for setPixels");var y=l.size,x=s.indexOf(n)<0;if(x&&s.push(n),f===a&&v)0===l.offset&&l.data.length===y?x?t.texImage2D(t.TEXTURE_2D,n,i,c[0],c[1],0,i,a,l.data):t.texSubImage2D(t.TEXTURE_2D,n,e,r,c[0],c[1],i,a,l.data):x?t.texImage2D(t.TEXTURE_2D,n,i,c[0],c[1],0,i,a,l.data.subarray(l.offset,l.offset+y)):t.texSubImage2D(t.TEXTURE_2D,n,e,r,c[0],c[1],i,a,l.data.subarray(l.offset,l.offset+y));else{var _;_=a===t.FLOAT?g.mallocFloat32(y):g.mallocUint8(y);var w=d(_,c,[c[2],c[2]*c[0],1]);f===t.FLOAT&&a===t.UNSIGNED_BYTE?b(w,l):p.assign(w,l),x?t.texImage2D(t.TEXTURE_2D,n,i,c[0],c[1],0,i,a,_.subarray(0,y)):t.texSubImage2D(t.TEXTURE_2D,n,e,r,c[0],c[1],i,a,_.subarray(0,y)),a===t.FLOAT?g.freeFloat32(_):g.freeUint8(_)}}function l(t){var e=t.createTexture();return t.bindTexture(t.TEXTURE_2D,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),e}function u(t,e,r,n,i){var o=t.getParameter(t.MAX_TEXTURE_SIZE);if(e<0||e>o||r<0||r>o)throw new Error("gl-texture2d: Invalid texture shape");if(i===t.FLOAT&&!t.getExtension("OES_texture_float"))throw new Error("gl-texture2d: Floating point textures not supported on this platform");var s=l(t);return t.texImage2D(t.TEXTURE_2D,0,n,e,r,0,n,i,null),new a(t,s,e,r,n,i)}function c(t,e,r,n){var i=l(t);return t.texImage2D(t.TEXTURE_2D,0,r,r,n,e),new a(t,i,0|e.width,0|e.height,r,n)}function f(t,e){var r=e.dtype,n=e.shape.slice(),i=t.getParameter(t.MAX_TEXTURE_SIZE);if(n[0]<0||n[0]>i||n[1]<0||n[1]>i)throw new Error("gl-texture2d: Invalid texture size");var s=o(n,e.stride.slice()),u=0;"float32"===r?u=t.FLOAT:"float64"===r?(u=t.FLOAT,s=!1,r="float32"):"uint8"===r?u=t.UNSIGNED_BYTE:(u=t.UNSIGNED_BYTE,s=!1,r="uint8");var c=0;if(2===n.length)c=t.LUMINANCE,n=[n[0],n[1],1],e=d(e.data,n,[e.stride[0],e.stride[1],1],e.offset);else{if(3!==n.length)throw new Error("gl-texture2d: Invalid shape for texture");if(1===n[2])c=t.ALPHA;else if(2===n[2])c=t.LUMINANCE_ALPHA;else if(3===n[2])c=t.RGB;else{if(4!==n[2])throw new Error("gl-texture2d: Invalid shape for pixel coords");c=t.RGBA}}u!==t.FLOAT||t.getExtension("OES_texture_float")||(u=t.UNSIGNED_BYTE,s=!1);var f,h,v=e.size;if(s)f=0===e.offset&&e.data.length===v?e.data:e.data.subarray(e.offset,e.offset+v);else{var m=[n[2],n[2]*n[0],1];h=g.malloc(v,r);var y=d(h,n,m,0);"float32"!==r&&"float64"!==r||u!==t.UNSIGNED_BYTE?p.assign(y,e):b(y,e),f=h.subarray(0,v)}var x=l(t);return t.texImage2D(t.TEXTURE_2D,0,c,n[0],n[1],0,c,u,f),s||g.free(h),new a(t,x,n[0],n[1],c,u)}function h(t){if(arguments.length<=1)throw new Error("gl-texture2d: Missing arguments for texture2d constructor");if(v||n(t),"number"==typeof arguments[1])return u(t,arguments[1],arguments[2],arguments[3]||t.RGBA,arguments[4]||t.UNSIGNED_BYTE);if(Array.isArray(arguments[1]))return u(t,0|arguments[1][0],0|arguments[1][1],arguments[2]||t.RGBA,arguments[3]||t.UNSIGNED_BYTE);if("object"==typeof arguments[1]){var e=arguments[1];if(e instanceof HTMLCanvasElement||e instanceof HTMLImageElement||e instanceof HTMLVideoElement||e instanceof ImageData)return c(t,e,arguments[2]||t.RGBA,arguments[3]||t.UNSIGNED_BYTE);if(e.shape&&e.data&&e.stride)return f(t,e)}throw new Error("gl-texture2d: Invalid arguments for texture2d constructor")}var d=t("ndarray"),p=t("ndarray-ops"),g=t("typedarray-pool");e.exports=h;var v=null,m=null,y=null,b=function(t,e){p.muls(t,e,255)},x=a.prototype;Object.defineProperties(x,{minFilter:{get:function(){return this._minFilter},set:function(t){this.bind();var e=this.gl;if(this.type===e.FLOAT&&v.indexOf(t)>=0&&(e.getExtension("OES_texture_float_linear")||(t=e.NEAREST)),m.indexOf(t)<0)throw new Error("gl-texture2d: Unknown filter mode "+t);return e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t),this._minFilter=t}},magFilter:{get:function(){return this._magFilter},set:function(t){this.bind();var e=this.gl;if(this.type===e.FLOAT&&v.indexOf(t)>=0&&(e.getExtension("OES_texture_float_linear")||(t=e.NEAREST)),m.indexOf(t)<0)throw new Error("gl-texture2d: Unknown filter mode "+t);return e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,t),this._magFilter=t}},mipSamples:{get:function(){return this._anisoSamples},set:function(t){var e=this._anisoSamples;if(this._anisoSamples=0|Math.max(t,1),e!==this._anisoSamples){var r=this.gl.getExtension("EXT_texture_filter_anisotropic");r&&this.gl.texParameterf(this.gl.TEXTURE_2D,r.TEXTURE_MAX_ANISOTROPY_EXT,this._anisoSamples)}return this._anisoSamples}},wrapS:{get:function(){return this._wrapS},set:function(t){if(this.bind(),y.indexOf(t)<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);return this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,t),this._wrapS=t}},wrapT:{get:function(){return this._wrapT},set:function(t){if(this.bind(),y.indexOf(t)<0)throw new Error("gl-texture2d: Unknown wrap mode "+t);return this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,t),this._wrapT=t}},wrap:{get:function(){return this._wrapVector},set:function(t){if(Array.isArray(t)||(t=[t,t]),2!==t.length)throw new Error("gl-texture2d: Must specify wrap mode for rows and columns");for(var e=0;e<2;++e)if(y.indexOf(t[e])<0)throw new Error("gl-texture2d: Unknown wrap mode "+t); ++this._wrapS=t[0],this._wrapT=t[1];var r=this.gl;return this.bind(),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,this._wrapS),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,this._wrapT),t}},shape:{get:function(){return this._shapeVector},set:function(t){if(Array.isArray(t)){if(2!==t.length)throw new Error("gl-texture2d: Invalid texture shape")}else t=[0|t,0|t];return i(this,0|t[0],0|t[1]),[0|t[0],0|t[1]]}},width:{get:function(){return this._shape[0]},set:function(t){return t=0|t,i(this,t,this._shape[1]),t}},height:{get:function(){return this._shape[1]},set:function(t){return t=0|t,i(this,this._shape[0],t),t}}}),x.bind=function(t){var e=this.gl;return void 0!==t&&e.activeTexture(e.TEXTURE0+(0|t)),e.bindTexture(e.TEXTURE_2D,this.handle),void 0!==t?0|t:e.getParameter(e.ACTIVE_TEXTURE)-e.TEXTURE0},x.dispose=function(){this.gl.deleteTexture(this.handle)},x.generateMipmap=function(){this.bind(),this.gl.generateMipmap(this.gl.TEXTURE_2D);for(var t=Math.min(this._shape[0],this._shape[1]),e=0;t>0;++e,t>>>=1)this._mipLevels.indexOf(e)<0&&this._mipLevels.push(e)},x.setPixels=function(t,e,r,n){var i=this.gl;if(this.bind(),Array.isArray(e)?(n=r,r=0|e[1],e=0|e[0]):(e=e||0,r=r||0),n=n||0,t instanceof HTMLCanvasElement||t instanceof ImageData||t instanceof HTMLImageElement||t instanceof HTMLVideoElement){var a=this._mipLevels.indexOf(n)<0;a?(i.texImage2D(i.TEXTURE_2D,0,this.format,this.format,this.type,t),this._mipLevels.push(n)):i.texSubImage2D(i.TEXTURE_2D,n,e,r,this.format,this.type,t)}else{if(!(t.shape&&t.stride&&t.data))throw new Error("gl-texture2d: Unsupported data type");if(t.shape.length<2||e+t.shape[1]>this._shape[1]>>>n||r+t.shape[0]>this._shape[0]>>>n||e<0||r<0)throw new Error("gl-texture2d: Texture dimensions are out of bounds");s(i,e,r,n,this.format,this.type,this._mipLevels,t)}}},{ndarray:123,"ndarray-ops":122,"typedarray-pool":162}],105:[function(t,e,r){function n(t){for(var e=Array.isArray(t)?t:i(t),r=0;r0)continue;n=t.slice(0,1).join("")}return e(n),G+=n.length,U=U.slice(n.length),U.length}}function R(){return/[^a-fA-F0-9]/.test(N)?(e(U.join("")),j=u,F):(U.push(N),z=N,F+1)}function I(){return"."===N?(U.push(N),j=v,z=N,F+1):/[eE]/.test(N)?(U.push(N),j=v,z=N,F+1):"x"===N&&1===U.length&&"0"===U[0]?(j=w,U.push(N),z=N,F+1):/[^\d]/.test(N)?(e(U.join("")),j=u,F):(U.push(N),z=N,F+1)}function P(){return"f"===N&&(U.push(N),z=N,F+=1),/[eE]/.test(N)?(U.push(N),z=N,F+1):"-"===N&&/[eE]/.test(z)?(U.push(N),z=N,F+1):/[^\d]/.test(N)?(e(U.join("")),j=u,F):(U.push(N),z=N,F+1)}function O(){if(/[^\d\w_]/.test(N)){var t=U.join("");return j=Q.indexOf(t)>-1?b:Z.indexOf(t)>-1?y:m,e(U.join("")),j=u,F}return U.push(N),z=N,F+1}var N,z,D,F=0,B=0,j=u,U=[],V=[],q=1,H=0,G=0,X=!1,Y=!1,W="";t=t||{};var Z=o,Q=i;return"300 es"===t.version&&(Z=l,Q=s),function(t){return V=[],null!==t?r(t.replace?t.replace(/\r\n/g,"\n"):t):n()}}e.exports=n;var i=t("./lib/literals"),a=t("./lib/operators"),o=t("./lib/builtins"),s=t("./lib/literals-300es"),l=t("./lib/builtins-300es"),u=999,c=9999,f=0,h=1,d=2,p=3,g=4,v=5,m=6,y=7,b=8,x=9,_=10,w=11,A=["block-comment","line-comment","preprocessor","operator","integer","float","ident","builtin","keyword","whitespace","eof","integer"]},{"./lib/builtins":108,"./lib/builtins-300es":107,"./lib/literals":110,"./lib/literals-300es":109,"./lib/operators":111}],107:[function(t,e,r){var n=t("./builtins");n=n.slice().filter(function(t){return!/^(gl\_|texture)/.test(t)}),e.exports=n.concat(["gl_VertexID","gl_InstanceID","gl_Position","gl_PointSize","gl_FragCoord","gl_FrontFacing","gl_FragDepth","gl_PointCoord","gl_MaxVertexAttribs","gl_MaxVertexUniformVectors","gl_MaxVertexOutputVectors","gl_MaxFragmentInputVectors","gl_MaxVertexTextureImageUnits","gl_MaxCombinedTextureImageUnits","gl_MaxTextureImageUnits","gl_MaxFragmentUniformVectors","gl_MaxDrawBuffers","gl_MinProgramTexelOffset","gl_MaxProgramTexelOffset","gl_DepthRangeParameters","gl_DepthRange","trunc","round","roundEven","isnan","isinf","floatBitsToInt","floatBitsToUint","intBitsToFloat","uintBitsToFloat","packSnorm2x16","unpackSnorm2x16","packUnorm2x16","unpackUnorm2x16","packHalf2x16","unpackHalf2x16","outerProduct","transpose","determinant","inverse","texture","textureSize","textureProj","textureLod","textureOffset","texelFetch","texelFetchOffset","textureProjOffset","textureLodOffset","textureProjLod","textureProjLodOffset","textureGrad","textureGradOffset","textureProjGrad","textureProjGradOffset"])},{"./builtins":108}],108:[function(t,e,r){e.exports=["abs","acos","all","any","asin","atan","ceil","clamp","cos","cross","dFdx","dFdy","degrees","distance","dot","equal","exp","exp2","faceforward","floor","fract","gl_BackColor","gl_BackLightModelProduct","gl_BackLightProduct","gl_BackMaterial","gl_BackSecondaryColor","gl_ClipPlane","gl_ClipVertex","gl_Color","gl_DepthRange","gl_DepthRangeParameters","gl_EyePlaneQ","gl_EyePlaneR","gl_EyePlaneS","gl_EyePlaneT","gl_Fog","gl_FogCoord","gl_FogFragCoord","gl_FogParameters","gl_FragColor","gl_FragCoord","gl_FragData","gl_FragDepth","gl_FragDepthEXT","gl_FrontColor","gl_FrontFacing","gl_FrontLightModelProduct","gl_FrontLightProduct","gl_FrontMaterial","gl_FrontSecondaryColor","gl_LightModel","gl_LightModelParameters","gl_LightModelProducts","gl_LightProducts","gl_LightSource","gl_LightSourceParameters","gl_MaterialParameters","gl_MaxClipPlanes","gl_MaxCombinedTextureImageUnits","gl_MaxDrawBuffers","gl_MaxFragmentUniformComponents","gl_MaxLights","gl_MaxTextureCoords","gl_MaxTextureImageUnits","gl_MaxTextureUnits","gl_MaxVaryingFloats","gl_MaxVertexAttribs","gl_MaxVertexTextureImageUnits","gl_MaxVertexUniformComponents","gl_ModelViewMatrix","gl_ModelViewMatrixInverse","gl_ModelViewMatrixInverseTranspose","gl_ModelViewMatrixTranspose","gl_ModelViewProjectionMatrix","gl_ModelViewProjectionMatrixInverse","gl_ModelViewProjectionMatrixInverseTranspose","gl_ModelViewProjectionMatrixTranspose","gl_MultiTexCoord0","gl_MultiTexCoord1","gl_MultiTexCoord2","gl_MultiTexCoord3","gl_MultiTexCoord4","gl_MultiTexCoord5","gl_MultiTexCoord6","gl_MultiTexCoord7","gl_Normal","gl_NormalMatrix","gl_NormalScale","gl_ObjectPlaneQ","gl_ObjectPlaneR","gl_ObjectPlaneS","gl_ObjectPlaneT","gl_Point","gl_PointCoord","gl_PointParameters","gl_PointSize","gl_Position","gl_ProjectionMatrix","gl_ProjectionMatrixInverse","gl_ProjectionMatrixInverseTranspose","gl_ProjectionMatrixTranspose","gl_SecondaryColor","gl_TexCoord","gl_TextureEnvColor","gl_TextureMatrix","gl_TextureMatrixInverse","gl_TextureMatrixInverseTranspose","gl_TextureMatrixTranspose","gl_Vertex","greaterThan","greaterThanEqual","inversesqrt","length","lessThan","lessThanEqual","log","log2","matrixCompMult","max","min","mix","mod","normalize","not","notEqual","pow","radians","reflect","refract","sign","sin","smoothstep","sqrt","step","tan","texture2D","texture2DLod","texture2DProj","texture2DProjLod","textureCube","textureCubeLod","texture2DLodEXT","texture2DProjLodEXT","textureCubeLodEXT","texture2DGradEXT","texture2DProjGradEXT","textureCubeGradEXT"]},{}],109:[function(t,e,r){var n=t("./literals");e.exports=n.slice().concat(["layout","centroid","smooth","case","mat2x2","mat2x3","mat2x4","mat3x2","mat3x3","mat3x4","mat4x2","mat4x3","mat4x4","uint","uvec2","uvec3","uvec4","samplerCubeShadow","sampler2DArray","sampler2DArrayShadow","isampler2D","isampler3D","isamplerCube","isampler2DArray","usampler2D","usampler3D","usamplerCube","usampler2DArray","coherent","restrict","readonly","writeonly","resource","atomic_uint","noperspective","patch","sample","subroutine","common","partition","active","filter","image1D","image2D","image3D","imageCube","iimage1D","iimage2D","iimage3D","iimageCube","uimage1D","uimage2D","uimage3D","uimageCube","image1DArray","image2DArray","iimage1DArray","iimage2DArray","uimage1DArray","uimage2DArray","image1DShadow","image2DShadow","image1DArrayShadow","image2DArrayShadow","imageBuffer","iimageBuffer","uimageBuffer","sampler1DArray","sampler1DArrayShadow","isampler1D","isampler1DArray","usampler1D","usampler1DArray","isampler2DRect","usampler2DRect","samplerBuffer","isamplerBuffer","usamplerBuffer","sampler2DMS","isampler2DMS","usampler2DMS","sampler2DMSArray","isampler2DMSArray","usampler2DMSArray"])},{"./literals":110}],110:[function(t,e,r){e.exports=["precision","highp","mediump","lowp","attribute","const","uniform","varying","break","continue","do","for","while","if","else","in","out","inout","float","int","void","bool","true","false","discard","return","mat2","mat3","mat4","vec2","vec3","vec4","ivec2","ivec3","ivec4","bvec2","bvec3","bvec4","sampler1D","sampler2D","sampler3D","samplerCube","sampler1DShadow","sampler2DShadow","struct","asm","class","union","enum","typedef","template","this","packed","goto","switch","default","inline","noinline","volatile","public","static","extern","external","interface","long","short","double","half","fixed","unsigned","input","output","hvec2","hvec3","hvec4","dvec2","dvec3","dvec4","fvec2","fvec3","fvec4","sampler2DRect","sampler3DRect","sampler2DRectShadow","sizeof","cast","namespace","using"]},{}],111:[function(t,e,r){e.exports=["<<=",">>=","++","--","<<",">>","<=",">=","==","!=","&&","||","+=","-=","*=","/=","%=","&=","^^","^=","|=","(",")","[","]",".","!","~","*","/","%","+","-","<",">","&","^","|","?",":","=",",",";","{","}"]},{}],112:[function(t,e,r){function n(t,e){var r=i(e),n=[];return n=n.concat(r(t)),n=n.concat(r(null))}var i=t("./index");e.exports=n},{"./index":106}],113:[function(t,e,r){r.read=function(t,e,r,n,i){var a,o,s=8*i-n-1,l=(1<>1,c=-7,f=r?i-1:0,h=r?-1:1,d=t[e+f];for(f+=h,a=d&(1<<-c)-1,d>>=-c,c+=s;c>0;a=256*a+t[e+f],f+=h,c-=8);for(o=a&(1<<-c)-1,a>>=-c,c+=n;c>0;o=256*o+t[e+f],f+=h,c-=8);if(0===a)a=1-u;else{if(a===l)return o?NaN:(d?-1:1)*(1/0);o+=Math.pow(2,n),a-=u}return(d?-1:1)*o*Math.pow(2,a-n)},r.write=function(t,e,r,n,i,a){var o,s,l,u=8*a-i-1,c=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:a-1,p=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,o=c):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),e+=o+f>=1?h/l:h*Math.pow(2,1-f),e*l>=2&&(o++,l/=2),o+f>=c?(s=0,o=c):o+f>=1?(s=(e*l-1)*Math.pow(2,i),o+=f):(s=e*Math.pow(2,f-1)*Math.pow(2,i),o=0));i>=8;t[r+d]=255&s,d+=p,s/=256,i-=8);for(o=o<0;t[r+d]=255&o,d+=p,o/=256,u-=8);t[r+d-p]|=128*g}},{}],114:[function(t,e,r){"use strict";function n(t,e,r,n,i){this.mid=t,this.left=e,this.right=r,this.leftPoints=n,this.rightPoints=i,this.count=(e?e.count:0)+(r?r.count:0)+n.length}function i(t,e){t.mid=e.mid,t.left=e.left,t.right=e.right,t.leftPoints=e.leftPoints,t.rightPoints=e.rightPoints,t.count=e.count}function a(t,e){var r=p(e);t.mid=r.mid,t.left=r.left,t.right=r.right,t.leftPoints=r.leftPoints,t.rightPoints=r.rightPoints,t.count=r.count}function o(t,e){var r=t.intervals([]);r.push(e),a(t,r)}function s(t,e){var r=t.intervals([]),n=r.indexOf(e);return n<0?y:(r.splice(n,1),a(t,r),b)}function l(t,e,r){for(var n=0;n=0&&t[n][1]>=e;--n){var i=r(t[n]);if(i)return i}}function c(t,e){for(var r=0;r>1],a=[],o=[],s=[],r=0;r3*(e+1)?o(this,t):this.left.insert(t):this.left=p([t]);else if(t[0]>this.mid)this.right?4*(this.right.count+1)>3*(e+1)?o(this,t):this.right.insert(t):this.right=p([t]);else{var r=m.ge(this.leftPoints,t,h),n=m.ge(this.rightPoints,t,d);this.leftPoints.splice(r,0,t),this.rightPoints.splice(n,0,t)}},_.remove=function(t){var e=this.count-this.leftPoints;if(t[1]3*(e-1))return s(this,t);var n=this.left.remove(t);return n===x?(this.left=null,this.count-=1,b):(n===b&&(this.count-=1),n)}if(t[0]>this.mid){if(!this.right)return y;var a=this.left?this.left.count:0;if(4*a>3*(e-1))return s(this,t);var n=this.right.remove(t);return n===x?(this.right=null,this.count-=1,b):(n===b&&(this.count-=1),n)}if(1===this.count)return this.leftPoints[0]===t?x:y;if(1===this.leftPoints.length&&this.leftPoints[0]===t){if(this.left&&this.right){for(var o=this,l=this.left;l.right;)o=l,l=l.right;if(o===this)l.right=this.right;else{var u=this.left,n=this.right;o.count-=l.count,o.right=l.left,l.left=u,l.right=n}i(this,l),this.count=(this.left?this.left.count:0)+(this.right?this.right.count:0)+this.leftPoints.length}else this.left?i(this,this.left):i(this,this.right);return b}for(var u=m.ge(this.leftPoints,t,h);uthis.mid){if(this.right){var r=this.right.queryPoint(t,e);if(r)return r}return u(this.rightPoints,t,e)}return c(this.leftPoints,e)},_.queryInterval=function(t,e,r){if(tthis.mid&&this.right){var n=this.right.queryInterval(t,e,r);if(n)return n}return ethis.mid?u(this.rightPoints,t,r):c(this.leftPoints,r)};var w=g.prototype;w.insert=function(t){this.root?this.root.insert(t):this.root=new n(t[0],null,null,[t],[t])},w.remove=function(t){if(this.root){var e=this.root.remove(t);return e===x&&(this.root=null),e!==y}return!1},w.queryPoint=function(t,e){if(this.root)return this.root.queryPoint(t,e)},w.queryInterval=function(t,e,r){if(t<=e&&this.root)return this.root.queryInterval(t,e,r)},Object.defineProperty(w,"count",{get:function(){return this.root?this.root.count:0}}),Object.defineProperty(w,"intervals",{get:function(){return this.root?this.root.intervals([]):[]}})},{"binary-search-bounds":27}],115:[function(t,e,r){"use strict";function n(t,e){e=e||new Array(t.length);for(var r=0;r0)return 1<=0)return 1<=0;--e)S(e,0);for(var r=[],e=0;e0;_=_-1&g)x.push(w+"["+E+"+"+v(_)+"]");x.push(m(0));for(var _=0;_0){",h(x[t]),"=1;"),O(t-1,e|1<0&&G.push(s(U,x[V-1])+"*"+o(x[V-1])),B.push(d(U,x[V])+"=("+G.join("-")+")|0")}for(var U=0;U=0;--U)X.push(o(x[U]));B.push(M+"=("+X.join("*")+")|0",A+"=mallocUint32("+M+")",w+"=mallocUint32("+M+")",E+"=0"),B.push(p(0)+"=0");for(var V=1;V<1< 0"),"function"!=typeof t.vertex&&e("Must specify vertex creation function"),"function"!=typeof t.cell&&e("Must specify cell creation function"),"function"!=typeof t.phase&&e("Must specify phase function");for(var a=t.getters||[],o=new Array(n),s=0;s=0?o[s]=!0:o[s]=!1;return b(t.vertex,t.cell,t.phase,i,r,o)}var _=t("typedarray-pool");e.exports=x;var w="V",A="P",k="N",M="Q",E="X",T="T"},{"typedarray-pool":162}],122:[function(t,e,r){"use strict";function n(t){if(!t)return s;for(var e=0;e>",rrshift:">>>"};!function(){for(var t in l){var e=l[t];r[t]=a({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+e+"c"},funcName:t}),r[t+"eq"]=a({args:["array","array"],body:{args:["a","b"],body:"a"+e+"=b"},rvalue:!0,funcName:t+"eq"}),r[t+"s"]=a({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+e+"s"},funcName:t+"s"}),r[t+"seq"]=a({args:["array","scalar"],body:{args:["a","s"],body:"a"+e+"=s"},rvalue:!0,funcName:t+"seq"})}}();var u={not:"!",bnot:"~",neg:"-",recip:"1.0/"};!function(){for(var t in u){var e=u[t];r[t]=a({args:["array","array"],body:{args:["a","b"],body:"a="+e+"b"},funcName:t}),r[t+"eq"]=a({args:["array"],body:{args:["a"],body:"a="+e+"a"},rvalue:!0,count:2,funcName:t+"eq"})}}();var c={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};!function(){for(var t in c){var e=c[t];r[t]=a({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+e+"c"},funcName:t}),r[t+"s"]=a({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+e+"s"},funcName:t+"s"}),r[t+"eq"]=a({args:["array","array"],body:{args:["a","b"],body:"a=a"+e+"b"},rvalue:!0,count:2,funcName:t+"eq"}),r[t+"seq"]=a({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+e+"s"},rvalue:!0,count:2,funcName:t+"seq"})}}();var f=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];!function(){for(var t=0;tthis_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"}),r.norm1=o({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"}),r.sup=o({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}}),r.inf=o({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}}),r.random=a({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"}),r.assign=a({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"}),r.assigns=a({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"}),r.equals=o({args:["array","array"],pre:s,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})},{"cwise-compiler":50}],123:[function(t,e,r){function n(t,e){return t[0]-e[0]}function i(){var t,e=this.stride,r=new Array(e.length);for(t=0;tMath.abs(this.stride[1]))?[1,0]:[0,1]}})"):3===e&&a.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):a.push("ORDER})")),a.push("proto.set=function "+r+"_set("+u.join(",")+",v){"),n?a.push("return this.data.set("+c+",v)}"):a.push("return this.data["+c+"]=v}"),a.push("proto.get=function "+r+"_get("+u.join(",")+"){"),n?a.push("return this.data.get("+c+")}"):a.push("return this.data["+c+"]}"),a.push("proto.index=function "+r+"_index(",u.join(),"){return "+c+"}"),a.push("proto.hi=function "+r+"_hi("+u.join(",")+"){return new "+r+"(this.data,"+s.map(function(t){return["(typeof i",t,"!=='number'||i",t,"<0)?this.shape[",t,"]:i",t,"|0"].join("")}).join(",")+","+s.map(function(t){return"this.stride["+t+"]"}).join(",")+",this.offset)}");var p=s.map(function(t){return"a"+t+"=this.shape["+t+"]"}),g=s.map(function(t){return"c"+t+"=this.stride["+t+"]"});a.push("proto.lo=function "+r+"_lo("+u.join(",")+"){var b=this.offset,d=0,"+p.join(",")+","+g.join(","));for(var v=0;v=0){d=i"+v+"|0;b+=c"+v+"*d;a"+v+"-=d}");a.push("return new "+r+"(this.data,"+s.map(function(t){return"a"+t}).join(",")+","+s.map(function(t){return"c"+t}).join(",")+",b)}"),a.push("proto.step=function "+r+"_step("+u.join(",")+"){var "+s.map(function(t){return"a"+t+"=this.shape["+t+"]"}).join(",")+","+s.map(function(t){return"b"+t+"=this.stride["+t+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(var v=0;v=0){c=(c+this.stride["+v+"]*i"+v+")|0}else{a.push(this.shape["+v+"]);b.push(this.stride["+v+"])}");a.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),a.push("return function construct_"+r+"(data,shape,stride,offset){return new "+r+"(data,"+s.map(function(t){return"shape["+t+"]"}).join(",")+","+s.map(function(t){return"stride["+t+"]"}).join(",")+",offset)}");var o=new Function("CTOR_LIST","ORDER",a.join("\n"));return o(f[t],i)}function o(t){if(u(t))return"buffer";if(c)switch(Object.prototype.toString.call(t)){case"[object Float64Array]":return"float64";case"[object Float32Array]":return"float32";case"[object Int8Array]":return"int8";case"[object Int16Array]":return"int16";case"[object Int32Array]":return"int32";case"[object Uint8Array]":return"uint8";case"[object Uint16Array]":return"uint16";case"[object Uint32Array]":return"uint32";case"[object Uint8ClampedArray]":return"uint8_clamped"}return Array.isArray(t)?"array":"generic"}function s(t,e,r,n){if(void 0===t){var i=f.array[0];return i([])}"number"==typeof t&&(t=[t]),void 0===e&&(e=[t.length]);var s=e.length;if(void 0===r){r=new Array(s);for(var l=s-1,u=1;l>=0;--l)r[l]=u,u*=e[l]}if(void 0===n){n=0;for(var l=0;lt==t>0?n===o?(r+=1,n=0):n+=1:0===n?(n=o,r-=1):n-=1,i.pack(n,r)}var i=t("double-bits"),a=Math.pow(2,-1074),o=-1>>>0;e.exports=n},{"double-bits":55}],125:[function(t,e,r){"use strict";var n=t("repeat-string");e.exports=function(t,e,r){return r="undefined"!=typeof r?r+"":" ",n(r,e)+t}},{"repeat-string":138}],126:[function(t,e,r){e.exports=function(t,e){e||(e=[0,""]),t=String(t);var r=parseFloat(t,10);return e[0]=r,e[1]=t.match(/[\d.\-\+]*\s*(.*)/)[1]||"",e}},{}],127:[function(t,e,r){"use strict";function n(t){var e=t.length;if(e0;--i)n=l[i],r=s[i],s[i]=s[n],s[n]=r,l[i]=l[r],l[r]=n,u=(u+r)*i;return a.freeUint32(l),a.freeUint32(s),u}function i(t,e,r){switch(t){case 0:return r?r:[];case 1:return r?(r[0]=0,r):[0];case 2:return r?(e?(r[0]=0,r[1]=1):(r[0]=1,r[1]=0),r):e?[0,1]:[1,0]}r=r||new Array(t);var n,i,a,o=1;for(r[0]=0,a=1;a0;--a)n=e/o|0,e=e-n*o|0,o=o/a|0,i=0|r[a],r[a]=0|r[n],r[n]=0|i;return r}var a=t("typedarray-pool"),o=t("invert-permutation");r.rank=n,r.unrank=i},{"invert-permutation":115,"typedarray-pool":162}],129:[function(t,e,r){"use strict";function n(t,e){function r(t,e){var r=u[e][t[e]];r.splice(r.indexOf(t),1)}function n(t,n,a){for(var o,s,l,c=0;c<2;++c)if(u[c][n].length>0){o=u[c][n][0],l=c;break}s=o[1^l];for(var f=0;f<2;++f)for(var h=u[f][n],d=0;d0&&(o=p,s=g,l=f)}return a?s:(o&&r(o,l),s)}function a(t,a){var o=u[a][t][0],s=[t];r(o,a);for(var l=o[1^a];;){for(;l!==t;)s.push(l),l=n(s[s.length-2],l,!1);if(u[0][t].length+u[1][t].length===0)break;var c=s[s.length-1],f=t,h=s[1],d=n(c,f,!0);if(i(e[c],e[f],e[h],e[d])<0)break;s.push(t),l=n(c,f)}return s}function o(t,e){return e[1]===e[e.length-1]}for(var s=0|e.length,l=t.length,u=[new Array(s),new Array(s)],c=0;c0;){var g=(u[0][c].length,a(c,d));o(p,g)?p.push.apply(p,g):(p.length>0&&h.push(p),p=g)}p.length>0&&h.push(p)}return h}e.exports=n;var i=t("compare-angle")},{"compare-angle":48}],130:[function(t,e,r){"use strict";function n(t,e){for(var r=i(t,e.length),n=new Array(e.length),a=new Array(e.length),o=[],s=0;s0;){var u=o.pop();n[u]=!1;for(var c=r[u],s=0;s0}function a(t){for(var e=t.length,r=0;r0;){var U=B.pop(),V=I[U];f(V,function(t,e){return t-e});var q,H=V.length,G=j[U];if(0===G){var E=m[U];q=[E]}for(var v=0;v=0)&&(j[X]=1^G,B.push(X),0===G)){var E=m[X];a(E)||(E.reverse(),q.push(E))}}0===G&&d.push(q)}return d}e.exports=a;var o=t("edges-to-adjacency-list"),s=t("planar-dual"),l=t("point-in-big-polygon"),u=t("two-product"),c=t("robust-sum"),f=t("uniq"),h=t("./lib/trim-leaves")},{"./lib/trim-leaves":130,"edges-to-adjacency-list":57,"planar-dual":129,"point-in-big-polygon":132,"robust-sum":145,"two-product":160,uniq:164}],132:[function(t,e,r){function n(){return!0}function i(t){return function(e,r){var i=t[e];return!!i&&!!i.queryPoint(r,n)}}function a(t){for(var e={},r=0;r0&&e[n]===r[0]))return 1;i=t[n-1]}for(var a=1;i;){var o=i.key,s=f(r,o[0],o[1]);if(o[0][0]0))return 0;a=-1,i=i.right}else if(s>0)i=i.left;else{if(!(s<0))return 0;a=1,i=i.right}}return a}}function s(t){return 1}function l(t){return function(e){return t(e[0],e[1])?0:1}}function u(t,e){return function(r){return t(r[0],r[1])?0:e(r)}}function c(t){for(var e=t.length,r=[],n=[],i=0;i1)for(var r=1;ra.length&&e>0&&(1&e&&(a+=t),e>>=1);)t+=t;return a.substr(0,r)}var i,a="";e.exports=n},{}],139:[function(t,e,r){"use strict";function n(t,e){for(var r=new Array(t.length-1),n=1;n>1;return["sum(",a(t.slice(0,e)),",",a(t.slice(e)),")"].join("")}function o(t,e){if("m"===t.charAt(0)){if("w"===e.charAt(0)){var r=t.split("[");return["w",e.substr(1),"m",r[0].substr(1)].join("")}return["prod(",t,",",e,")"].join("")}return o(e,t)}function s(t){return t&!0?"-":""}function l(t){if(2===t.length)return[["diff(",o(t[0][0],t[1][1]),",",o(t[1][0],t[0][1]),")"].join("")];for(var e=[],r=0;r>1;return["sum(",o(t.slice(0,e)),",",o(t.slice(e)),")"].join("")}function s(t){if(2===t.length)return[["sum(prod(",t[0][0],",",t[1][1],"),prod(-",t[0][1],",",t[1][0],"))"].join("")];for(var e=[],r=0;r0){if(a<=0)return o;n=i+a}else{if(!(i<0))return o;if(a>=0)return o;n=-(i+a)}var s=m*n;return o>=s||o<=-s?o:b(t,e,r)},function(t,e,r,n){var i=t[0]-n[0],a=e[0]-n[0],o=r[0]-n[0],s=t[1]-n[1],l=e[1]-n[1],u=r[1]-n[1],c=t[2]-n[2],f=e[2]-n[2],h=r[2]-n[2],d=a*u,p=o*l,g=o*s,v=i*u,m=i*l,b=a*s,_=c*(d-p)+f*(g-v)+h*(m-b),w=(Math.abs(d)+Math.abs(p))*Math.abs(c)+(Math.abs(g)+Math.abs(v))*Math.abs(f)+(Math.abs(m)+Math.abs(b))*Math.abs(h),A=y*w;return _>A||-_>A?_:x(t,e,r,n)}];c()},{"robust-scale":142,"robust-subtract":144,"robust-sum":145,"two-product":160}],141:[function(t,e,r){"use strict";function n(t,e){if(1===t.length)return a(e,t[0]);if(1===e.length)return a(t,e[0]);if(0===t.length||0===e.length)return[0];var r=[0];if(t.length0&&s>0||o<0&&s<0)return!1;var l=a(r,t,e),u=a(i,t,e);return!(l>0&&u>0||l<0&&u<0)&&(0!==o||0!==s||0!==l||0!==u||n(t,e,r,i))}e.exports=i;var a=t("robust-orientation")[3]},{"robust-orientation":140}],144:[function(t,e,r){"use strict";function n(t,e){var r=t+e,n=r-t,i=r-n,a=e-n,o=t-i,s=o+a;return s?[s,r]:[r]}function i(t,e){var r=0|t.length,i=0|e.length;if(1===r&&1===i)return n(t[0],-e[0]);var a,o,s=r+i,l=new Array(s),u=0,c=0,f=0,h=Math.abs,d=t[c],p=h(d),g=-e[f],v=h(g);p=i?(a=d,c+=1,c=i?(a=d,c+=1,c0?1:0}},{}],147:[function(t,e,r){arguments[4][28][0].apply(r,arguments)},{dup:28}],148:[function(t,e,r){"use strict";"use restrict";function n(t){for(var e=0,r=Math.max,n=0,i=t.length;n>1,s=o(t[a],e);s<=0?(0===s&&(i=a),r=a+1):s>0&&(n=a-1)}return i}function f(t,e){for(var r=new Array(t.length),n=0,i=r.length;n=t.length||0!==o(t[g],a))break}return r}function h(t,e){if(!e)return f(u(p(t,0)),t,0);for(var r=new Array(e),n=0;n>>c&1&&u.push(i[c]);e.push(u)}return l(e)}function p(t,e){if(e<0)return[];for(var r=[],n=(1<>1:(t>>1)-1}function u(t){for(var e=s(t);;){var r=e,n=2*t+1,i=2*(t+1),o=t;if(n0;){var r=l(t);if(r>=0){var n=s(r);if(e0){var t=M[0];return a(0,L-1),L-=1,u(0),t}return-1}function h(t,e){var r=M[t];return b[r]===e?t:(b[r]=-(1/0),c(t),f(),b[r]=e,L+=1,c(L-1))}function d(t){if(!x[t]){x[t]=!0;var e=m[t],r=y[t];m[r]>=0&&(m[r]=e),y[e]>=0&&(y[e]=r),E[e]>=0&&h(E[e],i(e)),E[r]>=0&&h(E[r],i(r))}}function p(t,e){if(t[e]<0)return e;var r=e,n=e;do{var i=t[n];if(!x[n]||i<0||i===n)break;if(n=i,i=t[n],!x[n]||i<0||i===n)break;n=i,r=t[r]}while(r!==n);for(var a=e;a!==n;a=t[a])t[a]=n;return n}for(var g=e.length,v=t.length,m=new Array(g),y=new Array(g),b=new Array(g),x=new Array(g),_=0;_>1;_>=0;--_)u(_);for(;;){var S=f();if(S<0||b[S]>r)break;d(S)}for(var C=[],_=0;_=0&&r>=0&&e!==r){var n=E[e],i=E[r];n!==i&&R.push([n,i])}}),o.unique(o.normalize(R)),{positions:C,edges:R}}e.exports=i;var a=t("robust-orientation"),o=t("simplicial-complex")},{"robust-orientation":140,"simplicial-complex":148}],151:[function(t,e,r){"use strict";function n(t,e){var r,n;if(e[0][0]e[1][0])){var i=Math.min(t[0][1],t[1][1]),o=Math.max(t[0][1],t[1][1]),s=Math.min(e[0][1],e[1][1]),l=Math.max(e[0][1],e[1][1]);return ol?i-l:o-l}r=e[1],n=e[0]}var u,c;t[0][1]e[1][0]))return n(e,t);r=e[1],i=e[0]}var o,s;if(t[0][0]t[1][0]))return-n(t,e);o=t[1],s=t[0]}var l=a(r,i,s),u=a(r,i,o);if(l<0){if(u<=0)return l}else if(l>0){if(u>=0)return l}else if(u)return u;if(l=a(s,o,i),u=a(s,o,r),l<0){if(u<=0)return l}else if(l>0){if(u>=0)return l}else if(u)return u;return i[0]-s[0]}e.exports=i;var a=t("robust-orientation")},{"robust-orientation":140}],152:[function(t,e,r){"use strict";function n(t,e,r){this.slabs=t,this.coordinates=e,this.horizontal=r}function i(t,e){return t.y-e}function a(t,e){for(var r=null;t;){var n,i,o=t.key;o[0][0]0)if(e[0]!==o[1][0])r=t,t=t.right;else{var l=a(t.right,e);if(l)return l;t=t.left}else{if(e[0]!==o[1][0])return t;var l=a(t.right,e);if(l)return l;t=t.left}}return r}function o(t,e,r,n){this.y=t,this.index=e,this.start=r,this.closed=n}function s(t,e,r,n){this.x=t,this.segment=e,this.create=r,this.index=n}function l(t){for(var e=t.length,r=2*e,i=new Array(r),a=0;a0){var s=a(this.slabs[e-1],t);s&&(o?h(s.key,o)>0&&(o=s.key,n=s.value):(n=s.value,o=s.key))}var l=this.horizontal[e];if(l.length>0){var c=u.ge(l,t[1],i);if(c=l.length)return n;d=l[c]}}if(d.start)if(o){var p=f(o[0],o[1],[t[0],d.y]);o[0][0]>o[1][0]&&(p=-p),p>0&&(n=d.index)}else n=d.index;else d.y!==t[1]&&(n=d.index)}}}return n}},{"./lib/order-segments":151,"binary-search-bounds":27,"functional-red-black-tree":61,"robust-orientation":140}],153:[function(e,r,n){!function(e){function r(){var t=arguments[0],e=r.cache;return e[t]&&e.hasOwnProperty(t)||(e[t]=r.parse(t)),r.format.call(null,e[t],arguments)}function i(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()}function a(t,e){return Array(e+1).join(t)}var o={not_string:/[^s]/,number:/[diefg]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijosuxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[\+\-]/};r.format=function(t,e){var n,s,l,u,c,f,h,d=1,p=t.length,g="",v=[],m=!0,y="";for(s=0;s=0),u[8]){case"b":n=n.toString(2);break;case"c":n=String.fromCharCode(n);break;case"d":case"i":n=parseInt(n,10);break;case"j":n=JSON.stringify(n,null,u[6]?parseInt(u[6]):0);break;case"e":n=u[7]?n.toExponential(u[7]):n.toExponential();break;case"f":n=u[7]?parseFloat(n).toFixed(u[7]):parseFloat(n);break;case"g":n=u[7]?parseFloat(n).toPrecision(u[7]):parseFloat(n);break;case"o":n=n.toString(8);break;case"s":n=(n=String(n))&&u[7]?n.substring(0,u[7]):n;break;case"u":n>>>=0;break;case"x":n=n.toString(16);break;case"X":n=n.toString(16).toUpperCase()}o.json.test(u[8])?v[v.length]=n:(!o.number.test(u[8])||m&&!u[3]?y="":(y=m?"+":"-",n=n.toString().replace(o.sign,"")),f=u[4]?"0"===u[4]?"0":u[4].charAt(1):" ",h=u[6]-(y+n).length,c=u[6]&&h>0?a(f,h):"",v[v.length]=u[5]?y+n+c:"0"===f?y+c+n:c+y+n)}return v.join("")},r.cache={},r.parse=function(t){for(var e=t,r=[],n=[],i=0;e;){if(null!==(r=o.text.exec(e)))n[n.length]=r[0];else if(null!==(r=o.modulo.exec(e)))n[n.length]="%";else{if(null===(r=o.placeholder.exec(e)))throw new SyntaxError("[sprintf] unexpected placeholder");if(r[2]){i|=1;var a=[],s=r[2],l=[];if(null===(l=o.key.exec(s)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(a[a.length]=l[1];""!==(s=s.substring(l[0].length));)if(null!==(l=o.key_access.exec(s)))a[a.length]=l[1];else{if(null===(l=o.index_access.exec(s)))throw new SyntaxError("[sprintf] failed to parse named argument key");a[a.length]=l[1]}r[2]=a}else i|=2;if(3===i)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");n[n.length]=r}e=e.substring(r[0].length)}return n};var s=function(t,e,n){return n=(e||[]).slice(0),n.splice(0,0,t),r.apply(null,n)};"undefined"!=typeof n?(n.sprintf=r,n.vsprintf=s):(e.sprintf=r,e.vsprintf=s,"function"==typeof t&&t.amd&&t(function(){return{sprintf:r,vsprintf:s}}))}("undefined"==typeof window?this:window)},{}],154:[function(t,e,r){"use strict";function n(t){return t.split("").map(function(t){return t in i?i[t]:""}).join("")}e.exports=n;var i={" ":" ",0:"\u2070",1:"\xb9",2:"\xb2",3:"\xb3",4:"\u2074",5:"\u2075",6:"\u2076",7:"\u2077",8:"\u2078",9:"\u2079","+":"\u207a","-":"\u207b",a:"\u1d43",b:"\u1d47",c:"\u1d9c",d:"\u1d48",e:"\u1d49",f:"\u1da0",g:"\u1d4d",h:"\u02b0",i:"\u2071",j:"\u02b2",k:"\u1d4f",l:"\u02e1",m:"\u1d50",n:"\u207f",o:"\u1d52",p:"\u1d56",r:"\u02b3",s:"\u02e2",t:"\u1d57",u:"\u1d58",v:"\u1d5b",w:"\u02b7",x:"\u02e3",y:"\u02b8",z:"\u1dbb"}},{}],155:[function(t,e,r){"use strict";function n(t,e){var r=t.length,n=["'use strict';"],i="surfaceNets"+t.join("_")+"d"+e;n.push("var contour=genContour({","order:[",t.join(),"],","scalarArguments: 3,","phase:function phaseFunc(p,a,b,c) { return (p > c)|0 },"),"generic"===e&&n.push("getters:[0],");for(var a=[],l=[],u=0;u>>7){");for(var u=0;u<1<<(1<128&&u%128===0){f.length>0&&h.push("}}");var d="vExtra"+f.length;n.push("case ",u>>>7,":",d,"(m&0x7f,",l.join(),");break;"),h=["function ",d,"(m,",l.join(),"){switch(m){"],f.push(h)}h.push("case ",127&u,":");for(var p=new Array(r),g=new Array(r),v=new Array(r),m=new Array(r),y=0,b=0;bb)&&!(u&1<<_)!=!(u&1<0&&(M="+"+v[x]+"*c");var E=.5*(p[x].length/y),T=.5+.5*(m[x]/y);k.push("d"+x+"-"+T+"-"+E+"*("+p[x].join("+")+M+")/("+g[x].join("+")+")")}h.push("a.push([",k.join(),"]);","break;")}n.push("}},"),f.length>0&&h.push("}}");for(var L=[],u=0;u<1<0&&(f+=.02);for(var d=new Float32Array(c),p=0,g=-.5*f,h=0;h.5?l/(2-a-o):l/(a+o),a){case t:n=(e-r)/l+(e1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t}var i,a,o;if(t=L(t,360),e=L(e,100),r=L(r,100),0===e)i=a=o=r;else{var s=r<.5?r*(1+e):r+e-r*e,l=2*r-s;i=n(l,s,t+1/3),a=n(l,s,t),o=n(l,s,t-1/3)}return{r:255*i,g:255*a,b:255*o}}function l(t,e,r){t=L(t,255),e=L(e,255),r=L(r,255);var n,i,a=G(t,e,r),o=H(t,e,r),s=a,l=a-o;if(i=0===a?0:l/a,a==o)n=0;else{switch(a){case t:n=(e-r)/l+(e>1)+720)%360;--e;)i.h=(i.h+a)%360,o.push(n(i));return o}function M(t,e){e=e||6;for(var r=n(t).toHsv(),i=r.h,a=r.s,o=r.v,s=[],l=1/e;e--;)s.push(n({h:i,s:a,v:o})),o=(o+l)%1;return s}function E(t){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[t[r]]=r);return e}function T(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function L(t,r){R(t)&&(t="100%");var n=I(t);return t=H(r,G(0,parseFloat(t))),n&&(t=parseInt(t*r,10)/100),e.abs(t-r)<1e-6?1:t%r/parseFloat(r)}function S(t){return H(1,G(0,t))}function C(t){return parseInt(t,16)}function R(t){return"string"==typeof t&&t.indexOf(".")!=-1&&1===parseFloat(t)}function I(t){return"string"==typeof t&&t.indexOf("%")!=-1}function P(t){return 1==t.length?"0"+t:""+t}function O(t){return t<=1&&(t=100*t+"%"),t}function N(t){return e.round(255*parseFloat(t)).toString(16)}function z(t){return C(t)/255}function D(t){return!!Z.CSS_UNIT.exec(t)}function F(t){t=t.replace(j,"").replace(U,"").toLowerCase();var e=!1;if(Y[t])t=Y[t],e=!0;else if("transparent"==t)return{r:0,g:0,b:0,a:0,format:"name"};var r;return(r=Z.rgb.exec(t))?{r:r[1],g:r[2],b:r[3]}:(r=Z.rgba.exec(t))?{r:r[1],g:r[2],b:r[3],a:r[4]}:(r=Z.hsl.exec(t))?{h:r[1],s:r[2],l:r[3]}:(r=Z.hsla.exec(t))?{h:r[1],s:r[2],l:r[3],a:r[4]}:(r=Z.hsv.exec(t))?{h:r[1],s:r[2],v:r[3]}:(r=Z.hsva.exec(t))?{h:r[1],s:r[2],v:r[3],a:r[4]}:(r=Z.hex8.exec(t))?{r:C(r[1]),g:C(r[2]),b:C(r[3]),a:z(r[4]),format:e?"name":"hex8"}:(r=Z.hex6.exec(t))?{r:C(r[1]),g:C(r[2]),b:C(r[3]),format:e?"name":"hex"}:(r=Z.hex4.exec(t))?{r:C(r[1]+""+r[1]),g:C(r[2]+""+r[2]),b:C(r[3]+""+r[3]),a:z(r[4]+""+r[4]),format:e?"name":"hex8"}:!!(r=Z.hex3.exec(t))&&{r:C(r[1]+""+r[1]),g:C(r[2]+""+r[2]),b:C(r[3]+""+r[3]),format:e?"name":"hex"}}function B(t){var e,r;return t=t||{level:"AA",size:"small"},e=(t.level||"AA").toUpperCase(),r=(t.size||"small").toLowerCase(),"AA"!==e&&"AAA"!==e&&(e="AA"),"small"!==r&&"large"!==r&&(r="small"),{level:e,size:r}}var j=/^\s+/,U=/\s+$/,V=0,q=e.round,H=e.min,G=e.max,X=e.random;n.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var t,r,n,i,a,o,s=this.toRgb();return t=s.r/255,r=s.g/255,n=s.b/255,i=t<=.03928?t/12.92:e.pow((t+.055)/1.055,2.4),a=r<=.03928?r/12.92:e.pow((r+.055)/1.055,2.4),o=n<=.03928?n/12.92:e.pow((n+.055)/1.055,2.4),.2126*i+.7152*a+.0722*o},setAlpha:function(t){return this._a=T(t),this._roundA=q(100*this._a)/100,this},toHsv:function(){var t=l(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=l(this._r,this._g,this._b),e=q(360*t.h),r=q(100*t.s),n=q(100*t.v);return 1==this._a?"hsv("+e+", "+r+"%, "+n+"%)":"hsva("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHsl:function(){var t=o(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=o(this._r,this._g,this._b),e=q(360*t.h),r=q(100*t.s),n=q(100*t.l);return 1==this._a?"hsl("+e+", "+r+"%, "+n+"%)":"hsla("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHex:function(t){return c(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return f(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:q(this._r),g:q(this._g),b:q(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+q(this._r)+", "+q(this._g)+", "+q(this._b)+")":"rgba("+q(this._r)+", "+q(this._g)+", "+q(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:q(100*L(this._r,255))+"%",g:q(100*L(this._g,255))+"%",b:q(100*L(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+q(100*L(this._r,255))+"%, "+q(100*L(this._g,255))+"%, "+q(100*L(this._b,255))+"%)":"rgba("+q(100*L(this._r,255))+"%, "+q(100*L(this._g,255))+"%, "+q(100*L(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(W[c(this._r,this._g,this._b,!0)]||!1)},toFilter:function(t){var e="#"+h(this._r,this._g,this._b,this._a),r=e,i=this._gradientType?"GradientType = 1, ":"";if(t){var a=n(t);r="#"+h(a._r,a._g,a._b,a._a)}return"progid:DXImageTransform.Microsoft.gradient("+i+"startColorstr="+e+",endColorstr="+r+")"},toString:function(t){var e=!!t;t=t||this._format;var r=!1,n=this._a<1&&this._a>=0,i=!e&&n&&("hex"===t||"hex6"===t||"hex3"===t||"hex4"===t||"hex8"===t||"name"===t);return i?"name"===t&&0===this._a?this.toName():this.toRgbString():("rgb"===t&&(r=this.toRgbString()),"prgb"===t&&(r=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(r=this.toHexString()),"hex3"===t&&(r=this.toHexString(!0)),"hex4"===t&&(r=this.toHex8String(!0)),"hex8"===t&&(r=this.toHex8String()),"name"===t&&(r=this.toName()),"hsl"===t&&(r=this.toHslString()),"hsv"===t&&(r=this.toHsvString()),r||this.toHexString())},clone:function(){return n(this.toString())},_applyModification:function(t,e){var r=t.apply(null,[this].concat([].slice.call(e)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(v,arguments)},brighten:function(){return this._applyModification(m,arguments)},darken:function(){return this._applyModification(y,arguments)},desaturate:function(){return this._applyModification(d,arguments)},saturate:function(){return this._applyModification(p,arguments)},greyscale:function(){return this._applyModification(g,arguments)},spin:function(){return this._applyModification(b,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(k,arguments)},complement:function(){return this._applyCombination(x,arguments)},monochromatic:function(){return this._applyCombination(M,arguments)},splitcomplement:function(){return this._applyCombination(A,arguments)},triad:function(){return this._applyCombination(_,arguments)},tetrad:function(){return this._applyCombination(w,arguments)}},n.fromRatio=function(t,e){if("object"==typeof t){var r={};for(var i in t)t.hasOwnProperty(i)&&("a"===i?r[i]=t[i]:r[i]=O(t[i]));t=r}return n(t,e)},n.equals=function(t,e){return!(!t||!e)&&n(t).toRgbString()==n(e).toRgbString()},n.random=function(){return n.fromRatio({r:X(),g:X(),b:X()})},n.mix=function(t,e,r){r=0===r?0:r||50;var i=n(t).toRgb(),a=n(e).toRgb(),o=r/100,s={r:(a.r-i.r)*o+i.r,g:(a.g-i.g)*o+i.g,b:(a.b-i.b)*o+i.b,a:(a.a-i.a)*o+i.a};return n(s)},n.readability=function(t,r){var i=n(t),a=n(r);return(e.max(i.getLuminance(),a.getLuminance())+.05)/(e.min(i.getLuminance(),a.getLuminance())+.05)},n.isReadable=function(t,e,r){var i,a,o=n.readability(t,e);switch(a=!1,i=B(r),i.level+i.size){case"AAsmall":case"AAAlarge":a=o>=4.5;break;case"AAlarge":a=o>=3;break;case"AAAsmall":a=o>=7}return a},n.mostReadable=function(t,e,r){var i,a,o,s,l=null,u=0;r=r||{},a=r.includeFallbackColors,o=r.level,s=r.size;for(var c=0;cu&&(u=i,l=n(e[c]));return n.isReadable(t,l,{level:o,size:s})||!a?l:(r.includeFallbackColors=!1,n.mostReadable(t,["#fff","#000"],r))};var Y=n.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},W=n.hexNames=E(Y),Z=function(){var t="[-\\+]?\\d+%?",e="[-\\+]?\\d*\\.\\d+%?",r="(?:"+e+")|(?:"+t+")",n="[\\s|\\(]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")\\s*\\)?",i="[\\s|\\(]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")\\s*\\)?";return{CSS_UNIT:new RegExp(r),rgb:new RegExp("rgb"+n),rgba:new RegExp("rgba"+i),hsl:new RegExp("hsl"+n),hsla:new RegExp("hsla"+i),hsv:new RegExp("hsv"+n),hsva:new RegExp("hsva"+i),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();"undefined"!=typeof r&&r.exports?r.exports=n:"function"==typeof t&&t.amd?t(function(){return n}):window.tinycolor=n}(Math)},{}],158:[function(t,e,r){"use strict";function n(t,e){var r=o(getComputedStyle(t).getPropertyValue(e));return r[0]*a(r[1],t)}function i(t,e){var r=document.createElement("div");r.style["font-size"]="128"+t,e.appendChild(r);var i=n(r,"font-size")/128;return e.removeChild(r),i}function a(t,e){switch(e=e||document.body,t=(t||"px").trim().toLowerCase(),e!==window&&e!==document||(e=document.body),t){case"%":return e.clientHeight/100;case"ch":case"ex":return i(t,e);case"em":return n(e,"font-size");case"rem":return n(document.body,"font-size");case"vw":return window.innerWidth/100;case"vh":return window.innerHeight/100;case"vmin":return Math.min(window.innerWidth,window.innerHeight)/100;case"vmax":return Math.max(window.innerWidth,window.innerHeight)/100;case"in":return s;case"cm":return s/2.54;case"mm":return s/25.4;case"pt":return s/72;case"pc":return s/6}return 1}var o=t("parse-unit");e.exports=a;var s=96},{"parse-unit":126}],159:[function(t,e,r){"use strict";function n(t){if(t<0)return[];if(0===t)return[[0]];for(var e=0|Math.round(o(t+1)),r=[],n=0;n0?r.pop():new ArrayBuffer(t)}function s(t){return new Uint8Array(o(t),0,t)}function l(t){return new Uint16Array(o(2*t),0,t)}function u(t){return new Uint32Array(o(4*t),0,t)}function c(t){return new Int8Array(o(t),0,t)}function f(t){return new Int16Array(o(2*t),0,t)}function h(t){return new Int32Array(o(4*t),0,t)}function d(t){return new Float32Array(o(4*t),0,t)}function p(t){return new Float64Array(o(8*t),0,t)}function g(t){return x?new Uint8ClampedArray(o(t),0,t):s(t)}function v(t){return new DataView(o(t),0,t)}function m(t){t=y.nextPow2(t);var e=y.log2(t),r=A[e];return r.length>0?r.pop():new n(t)}var y=t("bit-twiddle"),b=t("dup");e.__TYPEDARRAY_POOL||(e.__TYPEDARRAY_POOL={UINT8:b([32,0]),UINT16:b([32,0]),UINT32:b([32,0]),INT8:b([32,0]),INT16:b([32,0]),INT32:b([32,0]),FLOAT:b([32,0]),DOUBLE:b([32,0]),DATA:b([32,0]),UINT8C:b([32,0]),BUFFER:b([32,0])});var x="undefined"!=typeof Uint8ClampedArray,_=e.__TYPEDARRAY_POOL;_.UINT8C||(_.UINT8C=b([32,0])),_.BUFFER||(_.BUFFER=b([32,0]));var w=_.DATA,A=_.BUFFER;r.free=function(t){if(n.isBuffer(t))A[y.log2(t.length)].push(t);else{if("[object ArrayBuffer]"!==Object.prototype.toString.call(t)&&(t=t.buffer),!t)return;var e=t.length||t.byteLength,r=0|y.log2(e);w[r].push(t)}},r.freeUint8=r.freeUint16=r.freeUint32=r.freeInt8=r.freeInt16=r.freeInt32=r.freeFloat32=r.freeFloat=r.freeFloat64=r.freeDouble=r.freeUint8Clamped=r.freeDataView=a,r.freeArrayBuffer=i,r.freeBuffer=function(t){A[y.log2(t.length)].push(t)},r.malloc=function(t,e){if(void 0===e||"arraybuffer"===e)return o(t);switch(e){case"uint8":return s(t);case"uint16":return l(t);case"uint32":return u(t);case"int8":return c(t);case"int16":return f(t);case"int32":return h(t);case"float":case"float32":return d(t);case"double":case"float64":return p(t);case"uint8_clamped":return g(t);case"buffer":return m(t);case"data":case"dataview":return v(t);default:return null}return null},r.mallocArrayBuffer=o,r.mallocUint8=s,r.mallocUint16=l,r.mallocUint32=u,r.mallocInt8=c,r.mallocInt16=f,r.mallocInt32=h,r.mallocFloat32=r.mallocFloat=d,r.mallocFloat64=r.mallocDouble=p,r.mallocUint8Clamped=g,r.mallocDataView=v,r.mallocBuffer=m,r.clearCache=function(){for(var t=0;t<32;++t)_.UINT8[t].length=0,_.UINT16[t].length=0,_.UINT32[t].length=0,_.INT8[t].length=0,_.INT16[t].length=0,_.INT32[t].length=0,_.FLOAT[t].length=0,_.DOUBLE[t].length=0,_.UINT8C[t].length=0,w[t].length=0,A[t].length=0}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("buffer").Buffer)},{"bit-twiddle":28,buffer:37,dup:56}],163:[function(t,e,r){"use strict";"use restrict";function n(t){this.roots=new Array(t),this.ranks=new Array(t);for(var e=0;e8192)throw new Error("vectorize-text: String too long (sorry, this will get fixed later)");var a=3*n;t.height= 0) !== (_inline_1_db >= 0)) {\n _inline_1_arg2_.push(_inline_1_arg4_[0] + 0.5 + 0.5 * (_inline_1_da + _inline_1_db) / (_inline_1_da - _inline_1_db))\n }\n }",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg2_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg3_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg4_",lvalue:!1,rvalue:!0,count:1}],thisVars:[],localVars:["_inline_1_da","_inline_1_db"]},funcName:"zeroCrossings"})},{"cwise-compiler":50}],171:[function(t,e,r){"use strict";function n(t,e){var r=[];return e=+e||0,i(t.hi(t.shape[0]-1),r,e),r}e.exports=n;var i=t("./lib/zc-core")},{"./lib/zc-core":170}],172:[function(t,e,r){"use strict";e.exports=["",{path:"M-2.4,-3V3L0.6,0Z",backoff:.6},{path:"M-3.7,-2.5V2.5L1.3,0Z",backoff:1.3},{path:"M-4.45,-3L-1.65,-0.2V0.2L-4.45,3L1.55,0Z",backoff:1.55},{path:"M-2.2,-2.2L-0.2,-0.2V0.2L-2.2,2.2L-1.4,3L1.6,0L-1.4,-3Z",backoff:1.6},{path:"M-4.4,-2.1L-0.6,-0.2V0.2L-4.4,2.1L-4,3L2,0L-4,-3Z",backoff:2},{path:"M2,0A2,2 0 1,1 0,-2A2,2 0 0,1 2,0Z",backoff:0},{path:"M2,2V-2H-2V2Z",backoff:0}]},{}],173:[function(t,e,r){"use strict";var n=t("./arrow_paths"),i=t("../../plots/font_attributes"),a=t("../../plots/cartesian/constants"),o=t("../../lib/extend").extendFlat;e.exports={_isLinkedToArray:!0,text:{valType:"string"},textangle:{valType:"angle",dflt:0},font:o({},i,{}),opacity:{valType:"number",min:0,max:1,dflt:1},align:{valType:"enumerated",values:["left","center","right"],dflt:"center"},bgcolor:{valType:"color",dflt:"rgba(0,0,0,0)"},bordercolor:{valType:"color",dflt:"rgba(0,0,0,0)"},borderpad:{valType:"number",min:0,dflt:1},borderwidth:{valType:"number",min:0,dflt:1},showarrow:{valType:"boolean",dflt:!0},arrowcolor:{valType:"color"},arrowhead:{valType:"integer",min:0,max:n.length,dflt:1},arrowsize:{valType:"number",min:.3,dflt:1},arrowwidth:{valType:"number",min:.1},ax:{valType:"number",dflt:-10},ay:{valType:"number",dflt:-30},axref:{valType:"enumerated",dflt:"pixel",values:["pixel",a.idRegex.x.toString()]},ayref:{valType:"enumerated",dflt:"pixel",values:["pixel",a.idRegex.y.toString()]},xref:{valType:"enumerated",values:["paper",a.idRegex.x.toString()]},x:{valType:"number"},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"auto"},yref:{valType:"enumerated",values:["paper",a.idRegex.y.toString()]},y:{valType:"number"},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto"},_deprecated:{ref:{valType:"string"}}}},{"../../lib/extend":253,"../../plots/cartesian/constants":284,"../../plots/font_attributes":297,"./arrow_paths":172}],174:[function(t,e,r){"use strict";function n(t,e){function r(e,r){return u.coerce(t,n,v.layoutAttributes,e,r)}var n={};r("opacity"),r("align"),r("bgcolor");var i=r("bordercolor"),a=f.opacity(i);r("borderpad");var o=r("borderwidth"),s=r("showarrow");s&&(r("arrowcolor",a?n.bordercolor:f.defaultLine),r("arrowhead"),r("arrowsize"),r("arrowwidth",2*(a&&o||1)),r("ax"),r("ay"),r("axref"),r("ayref"),u.noneOrAll(t,n,["ax","ay"])),r("text",s?" ":"new text"),r("textangle"),u.coerceFont(r,"font",e.font);for(var l=["x","y"],h=0;h<2;h++){var d=l[h],p={_fullLayout:e},g=c.coerceRef(t,n,p,d),m=c.coerceARef(t,n,p,d),y=.5;if("paper"!==g){var b=c.getFromId(p,g);if(y=b.range[0]+y*(b.range[1]-b.range[0]),["date","category"].indexOf(b.type)!==-1&&"string"==typeof t[d]){var x;if("date"===b.type){if(x=u.dateTime2ms(t[d]),x!==!1&&(t[d]=x),m===g){var _=u.dateTime2ms(t["a"+d]);_!==!1&&(t["a"+d]=_)}}else(b._categories||[]).length&&(x=b._categories.indexOf(t[d]),x!==-1&&(t[d]=x))}}r(d,y),s||r(d+"anchor")}return u.noneOrAll(t,n,["x","y"]),n}function i(t){var e=t._fullLayout;e.annotations.forEach(function(e){var r=c.getFromId(t,e.xref),n=c.getFromId(t,e.yref);if(r||n){var i=(e._xsize||0)/2,a=e._xshift||0,o=(e._ysize||0)/2,s=e._yshift||0,l=i-a,u=i+a,f=o-s,h=o+s;if(e.showarrow){var d=3*e.arrowsize*e.arrowwidth;l=Math.max(l,d),u=Math.max(u,d),f=Math.max(f,d),h=Math.max(h,d)}r&&r.autorange&&c.expand(r,[r.l2c(e.x)],{ppadplus:u,ppadminus:l}),n&&n.autorange&&c.expand(n,[n.l2c(e.y)],{ppadplus:h,ppadminus:f})}})}function a(t,e,r,n,i,a,o,s){var l=r-t,u=i-t,c=o-i,f=n-e,h=a-e,d=s-a,p=l*d-c*f;if(0===p)return null;var g=(u*d-c*h)/p,v=(u*f-l*h)/p;return v<0||v>1||g<0||g>1?null:{x:t+l*g,y:e+f*g}}var o=t("d3"),s=t("fast-isnumeric"),l=t("../../plotly"),u=t("../../lib"),c=t("../../plots/cartesian/axes"),f=t("../color"),h=t("../drawing"),d=t("../../lib/svg_text_utils"),p=t("../../lib/setcursor"),g=t("../dragelement"),v=e.exports={};v.ARROWPATHS=t("./arrow_paths"),v.layoutAttributes=t("./attributes"),v.supplyLayoutDefaults=function(t,e){for(var r=t.annotations||[],i=e.annotations=[],a=0;a2/3?"right":"center"),{center:0,middle:0,left:.5,bottom:-.5,right:-.5,top:.5}[e]}tt.selectAll("tspan.line").attr({y:0,x:0});var n=W.select(".annotation-math-group"),i=!n.empty(),s=h.bBox((i?n:tt).node()),d=s.width,m=s.height,y=Math.round(d+2*$),b=Math.round(m+2*$);U._w=d,U._h=m;var x=!1;if(["x","y"].forEach(function(e){var n,i=U[e+"ref"]||e,a=c.getFromId(t,i),o=(G+("x"===e?0:90))*Math.PI/180,s=y*Math.abs(Math.cos(o))+b*Math.abs(Math.sin(o)),l=U[e+"anchor"];if(a){if(!a.autorange&&(U[e]-a.range[0])*(U[e]-a.range[1])>0&&(U["a"+e+"ref"]===i?(U["a"+e]-a.range[0])*(U["a"+e]-a.range[1])>0&&(x=!0):x=!0,x))return;H[e]=a._offset+a.l2p(U[e]),n=.5}else n=U[e],"y"===e&&(n=1-n),H[e]="x"===e?S.l+S.w*n:S.t+S.h*n;var u=0;U["a"+e+"ref"]===i?H["aa"+e]=a._offset+a.l2p(U["a"+e]):(u=U.showarrow?U["a"+e]:s*r(n,l),H[e]+=u),U["_"+e+"type"]=a&&a.type,U["_"+e+"size"]=s,U["_"+e+"shift"]=u}),x)return void W.remove();var w,A;U.showarrow&&(w=U.axref===U.xref?H.x:u.constrain(H.x-U.ax,1,_.width-1),A=U.ayref===U.yref?H.y:u.constrain(H.y-U.ay,1,_.height-1)),H.x=u.constrain(H.x,1,_.width-1),H.y=u.constrain(H.y,1,_.height-1);var k=$-s.top,M=$-s.left;i?n.select("svg").attr({x:$-1,y:$}):(tt.attr({x:M,y:k}),tt.selectAll("tspan.line").attr({y:k,x:M})),K.call(h.setRect,Z/2,Z/2,y-Z,b-Z);var E=0,T=0;E=U.axref===U.xref?Math.round(H.aax-y/2):Math.round(H.x-y/2),T=U.ayref===U.yref?Math.round(H.aay-b/2):Math.round(H.y-b/2),W.call(u.setTranslate,E,T);var L="annotations["+e+"]",C=function(r,n){o.select(t).selectAll('.annotation-arrow-g[data-index="'+e+'"]').remove();var i,s;i=U.axref===U.xref?H.aax+r:H.x+r,s=U.ayref===U.yref?H.aay+n:H.y+n;var c=u.rotationXYMatrix(G,i,s),h=u.apply2DTransform(c),d=u.apply2DTransform2(c),p=K.attr("width")/2,m=K.attr("height")/2,y=[[i-p,s-m,i-p,s+m],[i-p,s+m,i+p,s+m],[i+p,s+m,i+p,s-m],[i+p,s-m,i-p,s-m]].map(d);if(!y.reduce(function(t,e){return t^!!a(w,A,w+1e6,A+1e6,e[0],e[1],e[2],e[3])},!1)){y.forEach(function(t){var e=a(i,s,w,A,t[0],t[1],t[2],t[3]);e&&(i=e.x,s=e.y)});var b=U.arrowwidth,x=U.arrowcolor,_=X.append("g").style({opacity:f.opacity(x)}).classed("annotation-arrow-g",!0).attr("data-index",String(e)),k=_.append("path").attr("d","M"+i+","+s+"L"+w+","+A).style("stroke-width",b+"px").call(f.stroke,f.rgb(x));v.arrowhead(k,U.arrowhead,"end",U.arrowsize);var M=_.append("path").classed("annotation",!0).classed("anndrag",!0).attr({"data-index":String(e),d:"M3,3H-3V-3H3ZM0,0L"+(i-w)+","+(s-A),transform:"translate("+w+","+A+")"}).style("stroke-width",b+6+"px").call(f.stroke,"rgba(0,0,0,0)").call(f.fill,"rgba(0,0,0,0)");if(t._context.editable){var E,T,C;g.init({element:M.node(),prepFn:function(){var t=u.getTranslate(W);T=t.x,C=t.y,E={},V&&V.autorange&&(E[V._name+".autorange"]=!0),q&&q.autorange&&(E[q._name+".autorange"]=!0)},moveFn:function(t,e){_.attr("transform","translate("+t+","+e+")");var r=h(T,C),n=r[0]+t,i=r[1]+e;W.call(u.setTranslate,n,i),E[L+".x"]=V?U.x+t/V._m:(w+t-S.l)/S.w,E[L+".y"]=q?U.y+e/q._m:1-(A+e-S.t)/S.h,U.axref===U.xref&&(E[L+".ax"]=V?U.ax+t/V._m:(w+t-S.l)/S.w),U.ayref===U.yref&&(E[L+".ay"]=q?U.ay+e/q._m:1-(A+e-S.t)/S.h),Y.attr({transform:"rotate("+G+","+n+","+i+")"})},doneFn:function(e){if(e){l.relayout(t,E);var r=document.querySelector(".js-notes-box-panel");r&&r.redraw(r.selectedObj)}}})}}};U.showarrow&&C(0,0);var R=u.rotationXYMatrix(G,H.x,H.y),I=u.apply2DTransform(R);if(t._context.editable){var P,O,N;g.init({element:W.node(),prepFn:function(){var t=u.getTranslate(W);P=t.x,O=t.y,N={}},moveFn:function(t,e){W.call(u.setTranslate,P+t,O+e);var r="pointer";if(U.showarrow)U.axref===U.xref?N[L+".ax"]=V.p2l(V.l2p(U.ax)+t):N[L+".ax"]=U.ax+t,U.ayref===U.yref?N[L+".ay"]=q.p2l(q.l2p(U.ay)+e):N[L+".ay"]=U.ay+e,C(t,e);else{if(V)N[L+".x"]=U.x+t/V._m;else{var n=U._xsize/S.w,i=U.x+U._xshift/S.w-n/2;N[L+".x"]=g.align(i+t/S.w,n,0,1,U.xanchor)}if(q)N[L+".y"]=U.y+e/q._m;else{var a=U._ysize/S.h,o=U.y-U._yshift/S.h-a/2;N[L+".y"]=g.align(o-e/S.h,a,0,1,U.yanchor)}V&&q||(r=g.getCursor(V?.5:N[L+".x"],q?.5:N[L+".y"],U.xanchor,U.yanchor))}var s=I(P,O),l=s[0]+t,c=s[1]+e;W.call(u.setTranslate,P+t,O+e),Y.attr({transform:"rotate("+G+","+l+","+c+")"}),p(W,r)},doneFn:function(e){if(p(W),e){l.relayout(t,N);var r=document.querySelector(".js-notes-box-panel");r&&r.redraw(r.selectedObj)}}})}}var b,x=t.layout,_=t._fullLayout;if(!s(e)||e===-1){if(!e&&Array.isArray(i))return x.annotations=i,v.supplyLayoutDefaults(x,_),void v.drawAll(t);if("remove"===i)return delete x.annotations,_.annotations=[],void v.drawAll(t);if(r&&"add"!==i){for(b=0;b<_.annotations.length;b++)v.draw(t,b,r,i);return}e=_.annotations.length,_.annotations.push({})}if(!r&&i){if("remove"===i){for(_._infolayer.selectAll('.annotation[data-index="'+e+'"]').remove(),_.annotations.splice(e,1),x.annotations.splice(e,1),b=e;b<_.annotations.length;b++)_._infolayer.selectAll('.annotation[data-index="'+(b+1)+'"]').attr("data-index",String(b)),v.draw(t,b);return}if("add"===i||u.isPlainObject(i)){_.annotations.splice(e,0,{});var w=u.isPlainObject(i)?u.extendFlat({},i):{text:"New text"};for(x.annotations?x.annotations.splice(e,0,w):x.annotations=[w],b=_.annotations.length-1;b>e;b--)_._infolayer.selectAll('.annotation[data-index="'+(b-1)+'"]').attr("data-index",String(b)),v.draw(t,b)}}_._infolayer.selectAll('.annotation[data-index="'+e+'"]').remove();var A=x.annotations[e],k=_.annotations[e];if(A){var M={xref:A.xref,yref:A.yref},E={};"string"==typeof r&&r?E[r]=i:u.isPlainObject(r)&&(E=r);var T=Object.keys(E);for(b=0;b4/3&&(O=B)}}else P&&(z&&(O<1/3?O+=F:O>2/3&&(O-=F)),O=(O-P.domain[0])/(P.domain[1]-P.domain[0]),O=P.range[0]+O*(P.range[1]-P.range[0]))}P&&P===I&&N&&("log"===N&&"log"!==P.type?O=Math.pow(10,O):"log"!==N&&"log"===P.type&&(O=O>0?Math.log(O)/Math.LN10:void 0)),A[R]=O}}var U=n(A,_);_.annotations[e]=U;var V=c.getFromId(t,U.xref),q=c.getFromId(t,U.yref),H={x:0,y:0},G=+U.textangle||0,X=_._infolayer.append("g").classed("annotation",!0).attr("data-index",String(e)).style("opacity",U.opacity).on("click",function(){t._dragging=!1,t.emit("plotly_clickannotation",{index:e,annotation:A,fullAnnotation:U})}),Y=X.append("g").classed("annotation-text-g",!0).attr("data-index",String(e)),W=Y.append("g"),Z=U.borderwidth,Q=U.borderpad,$=Z+Q,K=W.append("rect").attr("class","bg").style("stroke-width",Z+"px").call(f.stroke,U.bordercolor).call(f.fill,U.bgcolor),J=U.font,tt=W.append("text").classed("annotation",!0).attr("data-unformatted",U.text).text(U.text);t._context.editable?tt.call(d.makeEditable,W).call(m).on("edit",function(r){U.text=r,this.attr({"data-unformatted":U.text}),this.call(m);var n={};n["annotations["+e+"].text"]=U.text,V&&V.autorange&&(n[V._name+".autorange"]=!0),q&&q.autorange&&(n[q._name+".autorange"]=!0),l.relayout(t,n)}):tt.call(m),Y.attr({transform:"rotate("+G+","+H.x+","+H.y+")"}).call(h.setPosition,H.x,H.y)}},v.arrowhead=function(t,e,r,n){s(n)||(n=1);var i=t.node(),a=v.ARROWPATHS[e||0];if(a){"string"==typeof r&&r||(r="end");var l,u,c,d,p=(h.getPx(t,"stroke-width")||1)*n,g=t.style("stroke")||f.defaultLine,m=t.style("stroke-opacity")||1,y=r.indexOf("start")>=0,b=r.indexOf("end")>=0,x=a.backoff*p;if("line"===i.nodeName){if(l={x:+t.attr("x1"),y:+t.attr("y1")},u={x:+t.attr("x2"),y:+t.attr("y2")},c=Math.atan2(l.y-u.y,l.x-u.x),d=c+Math.PI,x){var _=x*Math.cos(c),w=x*Math.sin(c);y&&(l.x-=_,l.y-=w,t.attr({x1:l.x,y1:l.y})),b&&(u.x+=_,u.y+=w,t.attr({x2:u.x,y2:u.y}))}}else if("path"===i.nodeName){var A=i.getTotalLength(),k="";if(y){var M=i.getPointAtLength(0),E=i.getPointAtLength(.1);c=Math.atan2(M.y-E.y,M.x-E.x),l=i.getPointAtLength(Math.min(x,A)),x&&(k="0px,"+x+"px,")}if(b){var T=i.getPointAtLength(A),L=i.getPointAtLength(A-.1);if(d=Math.atan2(T.y-L.y,T.x-L.x),u=i.getPointAtLength(Math.max(0,A-x)),x){var S=k?2*x:x;k+=A-S+"px,"+A+"px"}}else k&&(k+=A+"px");k&&t.style("stroke-dasharray",k)}var C=function(r,n){e>5&&(n=0),o.select(i.parentElement).append("path").attr({class:t.attr("class"),d:a.path,transform:"translate("+r.x+","+r.y+")rotate("+180*n/Math.PI+")scale("+p+")"}).style({fill:g,opacity:m,"stroke-width":0})};y&&C(l,c),b&&C(u,d)}},v.calcAutorange=function(t){var e=t._fullLayout,r=e.annotations;if(r.length&&t._fullData.length){var n={};r.forEach(function(t){n[t.xref]=!0,n[t.yref]=!0});var a=c.list(t).filter(function(t){return t.autorange&&n[t._id]});if(a.length)return u.syncOrAsync([v.drawAll,i],t)}}},{"../../lib":256,"../../lib/setcursor":265,"../../lib/svg_text_utils":269,"../../plotly":276,"../../plots/cartesian/axes":279,"../color":176,"../dragelement":197,"../drawing":199,"./arrow_paths":172,"./attributes":173,d3:54,"fast-isnumeric":60}],175:[function(t,e,r){"use strict";r.defaults=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],r.defaultLine="#444",r.lightLine="#eee",r.background="#fff",r.borderLine="#BEC8D9",r.lightFraction=1e3/11},{}],176:[function(t,e,r){"use strict";function n(t){if(a(t)||"string"!=typeof t)return t;var e=t.trim();if("rgb"!==e.substr(0,3))return t;var r=e.match(/^rgba?\s*\(([^()]*)\)$/);if(!r)return t;var n=r[1].trim().split(/\s*[\s,]\s*/),i="a"===e.charAt(3)&&4===n.length;if(!i&&3!==n.length)return t;for(var o=0;o=0))return t;if(3===o)n[o]>1&&(n[o]=1);else if(n[o]>=1)return t}var s=Math.round(255*n[0])+", "+Math.round(255*n[1])+", "+Math.round(255*n[2]);return i?"rgba("+s+", "+n[3]+")":"rgb("+s+")"}var i=t("tinycolor2"),a=t("fast-isnumeric"),o=e.exports={},s=t("./attributes");o.defaults=s.defaults,o.defaultLine=s.defaultLine,o.lightLine=s.lightLine,o.background=s.background,o.tinyRGB=function(t){var e=t.toRgb();return"rgb("+Math.round(e.r)+", "+Math.round(e.g)+", "+Math.round(e.b)+")"},o.rgb=function(t){return o.tinyRGB(i(t))},o.opacity=function(t){return t?i(t).getAlpha():0},o.addOpacity=function(t,e){var r=i(t).toRgb();return"rgba("+Math.round(r.r)+", "+Math.round(r.g)+", "+Math.round(r.b)+", "+e+")"},o.combine=function(t,e){var r=i(t).toRgb();if(1===r.a)return i(t).toRgbString();var n=i(e||o.background).toRgb(),a=1===n.a?n:{r:255*(1-n.a)+n.r*n.a,g:255*(1-n.a)+n.g*n.a,b:255*(1-n.a)+n.b*n.a},s={r:a.r*(1-r.a)+r.r*r.a,g:a.g*(1-r.a)+r.g*r.a,b:a.b*(1-r.a)+r.b*r.a};return i(s).toRgbString()},o.contrast=function(t,e,r){var n=i(t),a=n.isLight()?n.darken(r):n.lighten(e);return a.toString()},o.stroke=function(t,e){var r=i(e);t.style({stroke:o.tinyRGB(r),"stroke-opacity":r.getAlpha()})},o.fill=function(t,e){var r=i(e);t.style({fill:o.tinyRGB(r),"fill-opacity":r.getAlpha()})},o.clean=function(t){if(t&&"object"==typeof t){var e,r,i,a,s=Object.keys(t);for(e=0;el&&(a[1]-=(ot-l)/2)):r.node()&&!r.classed("js-placeholder")&&(ot=h.bBox(e.node()).height),ot){if(ot+=5,"top"===x.titleside)K.domain[1]-=ot/M.h,a[1]*=-1;else{K.domain[0]+=ot/M.h;var c=Math.max(1,r.selectAll("tspan.line").size());a[1]+=(1-c)*l}e.attr("transform","translate("+a+")"),K.setScale()}}it.selectAll(".cbfills,.cblines,.cbaxis").attr("transform","translate(0,"+Math.round(M.h*(1-K.domain[1]))+")");var f=it.select(".cbfills").selectAll("rect.cbfill").data(S);f.enter().append("rect").classed("cbfill",!0).style("stroke","none"),f.exit().remove(),f.each(function(t,e){var r=[0===e?T[0]:(S[e]+S[e-1])/2,e===S.length-1?T[1]:(S[e]+S[e+1])/2].map(K.c2p).map(Math.round);e!==S.length-1&&(r[1]+=r[1]>r[0]?1:-1);var a=R(t).replace("e-",""),o=i(a).toHexString();n.select(this).attr({x:X,width:Math.max(B,2),y:n.min(r),height:Math.max(n.max(r)-n.min(r),2),fill:o})});var d=it.select(".cblines").selectAll("path.cbline").data(x.line.color&&x.line.width?L:[]);return d.enter().append("path").classed("cbline",!0),d.exit().remove(),d.each(function(t){n.select(this).attr("d","M"+X+","+(Math.round(K.c2p(t))+x.line.width/2%1)+"h"+B).call(h.lineGroupStyle,x.line.width,C(t),x.line.dash)}),K._axislayer.selectAll("g."+K._id+"tick,path").remove(),K._pos=X+B+(x.outlinewidth||0)/2-("outside"===x.ticks?1:0),K.side="right",u.syncOrAsync([function(){return s.doTicks(t,K,!0)},function(){if(["top","bottom"].indexOf(x.titleside)===-1){var e=K.titlefont.size,r=K._offset+K._length/2,i=M.l+(K.position||0)*M.w+("right"===K.side?10+e*(K.showticklabels?1:.5):-10-e*(K.showticklabels?.5:0));w("h"+K._id+"title",{avoid:{selection:n.select(t).selectAll("g."+K._id+"tick"),side:x.titleside,offsetLeft:M.l,offsetTop:M.t,maxShift:k.width},attributes:{x:i,y:r,"text-anchor":"middle"},transform:{rotate:"-90",offset:0}})}}])}function w(e,r){var n,i=b();n=o.traceIs(i,"markerColorscale")?"marker.colorbar.title":"colorbar.title";var a={propContainer:K,propName:n,traceIndex:i.index,dfltName:"colorscale",containerGroup:it.select(".cbtitle")},s="h"===e.charAt(0)?e.substr(1):"h"+e;it.selectAll("."+s+",."+s+"-math-group").remove(),p.draw(t,e,c(a,r||{}))}function A(){var r=B+x.outlinewidth/2+h.bBox(K._axislayer.node()).width;if(z=at.select("text"),z.node()&&!z.classed("js-placeholder")){var n,i=at.select(".h"+K._id+"title-math-group").node();n=i&&["top","bottom"].indexOf(x.titleside)!==-1?h.bBox(i).width:h.bBox(at.node()).right-X-M.l,r=Math.max(r,n)}var a=2*x.xpad+r+x.borderwidth+x.outlinewidth/2,s=Z-Q;it.select(".cbbg").attr({x:X-x.xpad-(x.borderwidth+x.outlinewidth)/2,y:Q-H,width:Math.max(a,2),height:Math.max(s+2*H,2)}).call(d.fill,x.bgcolor).call(d.stroke,x.bordercolor).style({"stroke-width":x.borderwidth}),it.selectAll(".cboutline").attr({x:X,y:Q+x.ypad+("top"===x.titleside?ot:0),width:Math.max(B,2),height:Math.max(s-2*x.ypad-ot,2)}).call(d.stroke,x.outlinecolor).style({fill:"None","stroke-width":x.outlinewidth});var l=({center:.5,right:1}[x.xanchor]||0)*a;it.attr("transform","translate("+(M.l-l)+","+M.t+")"),o.autoMargin(t,e,{x:x.x,y:x.y,l:a*({right:1,center:.5}[x.xanchor]||0),r:a*({left:1,center:.5}[x.xanchor]||0),t:s*({bottom:1,middle:.5}[x.yanchor]||0),b:s*({top:1,middle:.5}[x.yanchor]||0)})}var k=t._fullLayout,M=k._size;if("function"!=typeof x.fillcolor&&"function"!=typeof x.line.color)return void k._infolayer.selectAll("g."+e).remove();var E,T=n.extent(("function"==typeof x.fillcolor?x.fillcolor:x.line.color).domain()),L=[],S=[],C="function"==typeof x.line.color?x.line.color:function(){return x.line.color},R="function"==typeof x.fillcolor?x.fillcolor:function(){return x.fillcolor},I=x.levels.end+x.levels.size/100,P=x.levels.size,O=1.001*T[0]-.001*T[1],N=1.001*T[1]-.001*T[0];for(E=x.levels.start;(E-I)*P<0;E+=P)E>O&&ET[0]&&E1){var nt=Math.pow(10,Math.floor(Math.log(rt)/Math.LN10));tt*=nt*u.roundUp(rt/nt,[2,5,10]),(Math.abs(x.levels.start)/x.levels.size+1e-6)%1<2e-6&&(K.tick0=0)}K.dtick=tt}K.domain=[W+G,W+V-G],K.setScale();var it=k._infolayer.selectAll("g."+e).data([0]);it.enter().append("g").classed(e,!0).each(function(){var t=n.select(this);t.append("rect").classed("cbbg",!0),t.append("g").classed("cbfills",!0),t.append("g").classed("cblines",!0),t.append("g").classed("cbaxis",!0).classed("crisp",!0),t.append("g").classed("cbtitleunshift",!0).append("g").classed("cbtitle",!0),t.append("rect").classed("cboutline",!0),t.select(".cbtitle").datum(0)}),it.attr("transform","translate("+Math.round(M.l)+","+Math.round(M.t)+")");var at=it.select(".cbtitleunshift").attr("transform","translate(-"+Math.round(M.l)+",-"+Math.round(M.t)+")");K._axislayer=it.select(".cbaxis");var ot=0;if(["top","bottom"].indexOf(x.titleside)!==-1){var st,lt=M.l+(x.x+q)*M.w,ut=K.titlefont.size;st="top"===x.titleside?(1-(W+V-G))*M.h+M.t+3+.75*ut:(1-(W+G))*M.h+M.t-3-.25*ut,w(K._id+"title",{attributes:{x:lt,y:st,"text-anchor":"start"}})}var ct=u.syncOrAsync([o.previousPromises,_,o.previousPromises,A],t);if(ct&&ct.then&&(t._promises||[]).push(ct),t._context.editable){var ft,ht,dt;l.init({element:it.node(),prepFn:function(){ft=it.attr("transform"),f(it)},moveFn:function(t,e){it.attr("transform",ft+" translate("+t+","+e+")"),ht=l.align(Y+t/M.w,j,0,1,x.xanchor),dt=l.align(W-e/M.h,V,0,1,x.yanchor);var r=l.getCursor(ht,dt,x.xanchor,x.yanchor);f(it,r)},doneFn:function(e){f(it),e&&void 0!==ht&&void 0!==dt&&a.restyle(t,{"colorbar.x":ht,"colorbar.y":dt},b().index)}})}return ct}function b(){var r,n,i=e.substr(2);for(r=0;r=0?i.Reds:i.Blues,l.colorscale=h,s.reversescale&&(h=a(h)), ++s.colorscale=h)}},{"../../lib":256,"./flip_scale":187,"./scales":194}],184:[function(t,e,r){"use strict";var n=t("./attributes"),i=t("../../lib/extend").extendDeep;t("./scales.js");e.exports=function(t){return{color:{valType:"color",arrayOk:!0},colorscale:i({},n.colorscale,{}),cauto:i({},n.zauto,{}),cmax:i({},n.zmax,{}),cmin:i({},n.zmin,{}),autocolorscale:i({},n.autocolorscale,{}),reversescale:i({},n.reversescale,{})}}},{"../../lib/extend":253,"./attributes":182,"./scales.js":194}],185:[function(t,e,r){"use strict";var n=t("./scales");e.exports=n.RdBu},{"./scales":194}],186:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib"),a=t("../colorbar/has_colorbar"),o=t("../colorbar/defaults"),s=t("./is_valid_scale"),l=t("./flip_scale");e.exports=function(t,e,r,u,c){var f=c.prefix,h=c.cLetter,d=f.slice(0,f.length-1),p=f?i.nestedProperty(t,d).get()||{}:t,g=f?i.nestedProperty(e,d).get()||{}:e,v=p[h+"min"],m=p[h+"max"],y=p.colorscale,b=n(v)&&n(m)&&v=0;i--,a++)e=t[i],n[a]=[1-e[0],e[1]];return n}},{}],188:[function(t,e,r){"use strict";var n=t("./scales"),i=t("./default_scale"),a=t("./is_valid_scale_array");e.exports=function(t,e){function r(){try{t=n[t]||JSON.parse(t)}catch(r){t=e}}return e||(e=i),t?("string"==typeof t&&(r(),"string"==typeof t&&r()),a(t)?t:e):e}},{"./default_scale":185,"./is_valid_scale_array":192,"./scales":194}],189:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib"),a=t("./is_valid_scale");e.exports=function(t,e){var r=e?i.nestedProperty(t,e).get()||{}:t,o=r.color,s=!1;if(Array.isArray(o))for(var l=0;l4/3-s?o:s}},{}],196:[function(t,e,r){"use strict";var n=t("../../lib"),i=[["sw-resize","s-resize","se-resize"],["w-resize","move","e-resize"],["nw-resize","n-resize","ne-resize"]];e.exports=function(t,e,r,a){return t="left"===r?0:"center"===r?1:"right"===r?2:n.constrain(Math.floor(3*t),0,2),e="bottom"===a?0:"middle"===a?1:"top"===a?2:n.constrain(Math.floor(3*e),0,2),i[e][t]}},{"../../lib":256}],197:[function(t,e,r){"use strict";function n(){var t=document.createElement("div");t.className="dragcover";var e=t.style;return e.position="fixed",e.left=0,e.right=0,e.top=0,e.bottom=0,e.zIndex=999999999,e.background="none",document.body.appendChild(t),t}function i(t){t._dragging=!1,t._replotPending&&a.plot(t)}var a=t("../../plotly"),o=t("../../lib"),s=t("../../plots/cartesian/constants"),l=e.exports={};l.align=t("./align"),l.getCursor=t("./cursor");var u=t("./unhover");l.unhover=u.wrapped,l.unhoverRaw=u.raw,l.init=function(t){function e(e){return t.element.onmousemove=p,g._dragged=!1,g._dragging=!0,u=e.clientX,c=e.clientY,d=e.target,f=(new Date).getTime(),f-g._mouseDownTimem&&(v=Math.max(v-1,1)),t.doneFn&&t.doneFn(g._dragged,v),!g._dragged){var r=document.createEvent("MouseEvents");r.initEvent("click",!0,!0),d.dispatchEvent(r)}return i(g),g._dragged=!1,o.pauseEvent(e)}var u,c,f,h,d,p,g=o.getPlotDiv(t.element)||{},v=1,m=s.DBLCLICKDELAY;g._mouseDownTime||(g._mouseDownTime=0),p=t.element.onmousemove,t.setCursor&&(t.element.onmousemove=t.setCursor),t.element.onmousedown=e,t.element.style.pointerEvents="all"}},{"../../lib":256,"../../plotly":276,"../../plots/cartesian/constants":284,"./align":195,"./cursor":196,"./unhover":198}],198:[function(t,e,r){"use strict";var n=t("../../lib/events"),i=e.exports={};i.wrapped=function(t,e,r){"string"==typeof t&&(t=document.getElementById(t)),t._hoverTimer&&(clearTimeout(t._hoverTimer),t._hoverTimer=void 0),i.raw(t,e,r)},i.raw=function(t,e){var r=t._fullLayout;e||(e={}),e.target&&n.triggerHandler(t,"plotly_beforehover",e)===!1||(r._hoverlayer.selectAll("g").remove(),e.target&&t._hoverdata&&t.emit("plotly_unhover",{points:t._hoverdata}),t._hoverdata=void 0)}},{"../../lib/events":252}],199:[function(t,e,r){"use strict";function n(t,e,r,n){var a=t[0]-e[0],o=t[1]-e[1],s=r[0]-e[0],l=r[1]-e[1],u=Math.pow(a*a+o*o,x/2),c=Math.pow(s*s+l*l,x/2),f=(c*c*a-u*u*s)*n,h=(c*c*o-u*u*l)*n,d=3*c*(u+c),p=3*u*(u+c);return[[i.round(e[0]+(d&&f/d),2),i.round(e[1]+(d&&h/d),2)],[i.round(e[0]-(p&&f/p),2),i.round(e[1]-(p&&h/p),2)]]}var i=t("d3"),a=t("fast-isnumeric"),o=t("../../plots/plots"),s=t("../color"),l=t("../colorscale"),u=t("../../lib"),c=t("../../lib/svg_text_utils"),f=t("../../constants/xmlns_namespaces"),h=t("../../traces/scatter/subtypes"),d=t("../../traces/scatter/make_bubble_size_func"),p=e.exports={};p.font=function(t,e,r,n){e&&e.family&&(n=e.color,r=e.size,e=e.family),e&&t.style("font-family",e),r+1&&t.style("font-size",r+"px"),n&&t.call(s.fill,n)},p.setPosition=function(t,e,r){t.attr("x",e).attr("y",r)},p.setSize=function(t,e,r){t.attr("width",e).attr("height",r)},p.setRect=function(t,e,r,n,i){t.call(p.setPosition,e,r).call(p.setSize,n,i)},p.translatePoints=function(t,e,r){t.each(function(t){var n=t.xp||e.c2p(t.x),o=t.yp||r.c2p(t.y),s=i.select(this);a(n)&&a(o)?"text"===this.nodeName?s.attr("x",n).attr("y",o):s.attr("transform","translate("+n+","+o+")"):s.remove()})},p.getPx=function(t,e){return Number(t.style(e).replace(/px$/,""))},p.crispRound=function(t,e,r){return e&&a(e)?t._context.staticPlot?e:e<1?1:Math.round(e):r||0},p.lineGroupStyle=function(t,e,r,n){t.style("fill","none").each(function(t){var a=(((t||[])[0]||{}).trace||{}).line||{},o=e||a.width||0,l=n||a.dash||"";i.select(this).call(s.stroke,r||a.color).call(p.dashLine,l,o)})},p.dashLine=function(t,e,r){var n=Math.max(r,3);"solid"===e?e="":"dot"===e?e=n+"px,"+n+"px":"dash"===e?e=3*n+"px,"+3*n+"px":"longdash"===e?e=5*n+"px,"+5*n+"px":"dashdot"===e?e=3*n+"px,"+n+"px,"+n+"px,"+n+"px":"longdashdot"===e&&(e=5*n+"px,"+2*n+"px,"+n+"px,"+2*n+"px"),t.style({"stroke-dasharray":e,"stroke-width":r+"px"})},p.fillGroupStyle=function(t){t.style("stroke-width",0).each(function(e){var r=i.select(this);try{r.call(s.fill,e[0].trace.fillcolor)}catch(e){u.error(e,t),r.remove()}})};var g=t("./symbol_defs");p.symbolNames=[],p.symbolFuncs=[],p.symbolNeedLines={},p.symbolNoDot={},p.symbolList=[],Object.keys(g).forEach(function(t){var e=g[t];p.symbolList=p.symbolList.concat([e.n,t,e.n+100,t+"-open"]),p.symbolNames[e.n]=t,p.symbolFuncs[e.n]=e.f,e.needLine&&(p.symbolNeedLines[e.n]=!0),e.noDot?p.symbolNoDot[e.n]=!0:p.symbolList=p.symbolList.concat([e.n+200,t+"-dot",e.n+300,t+"-open-dot"])});var v=p.symbolNames.length,m="M0,0.5L0.5,0L0,-0.5L-0.5,0Z";p.symbolNumber=function(t){if("string"==typeof t){var e=0;t.indexOf("-open")>0&&(e=100,t=t.replace("-open","")),t.indexOf("-dot")>0&&(e+=200,t=t.replace("-dot","")),t=p.symbolNames.indexOf(t),t>=0&&(t+=e)}return t%100>=v||t>=400?0:Math.floor(Math.max(t,0))},p.pointStyle=function(t,e){if(t.size()){var r=e.marker,n=r.line;if(o.traceIs(e,"symbols")){var a=d(e);t.attr("d",function(t){var n;n="various"===t.ms||"various"===r.size?3:h.isBubble(e)?a(t.ms):(r.size||6)/2,t.mrc=n;var i=p.symbolNumber(t.mx||r.symbol)||0,o=i%100;return t.om=i%200>=100,p.symbolFuncs[o](n)+(i>=200?m:"")}).style("opacity",function(t){return(t.mo+1||r.opacity+1)-1})}var l=(e._input||{}).marker||{},u=p.tryColorscale(r,l,""),c=p.tryColorscale(r,l,"line.");t.each(function(t){var e,a,o;t.so?(o=n.outlierwidth,a=n.outliercolor,e=r.outliercolor):(o=(t.mlw+1||n.width+1||(t.trace?t.trace.marker.line.width:0)+1)-1,a="mlc"in t?t.mlcc=c(t.mlc):Array.isArray(n.color)?s.defaultLine:n.color,e="mc"in t?t.mcc=u(t.mc):Array.isArray(r.color)?s.defaultLine:r.color||"rgba(0,0,0,0)");var l=i.select(this);t.om?l.call(s.stroke,e).style({"stroke-width":(o||1)+"px",fill:"none"}):(l.style("stroke-width",o+"px").call(s.fill,e),o&&l.call(s.stroke,a))})}},p.tryColorscale=function(t,e,r){var n=u.nestedProperty(t,r+"color").get(),i=u.nestedProperty(t,r+"colorscale").get(),o=u.nestedProperty(t,r+"cauto").get(),s=u.nestedProperty(t,r+"cmin"),c=u.nestedProperty(t,r+"cmax"),f=s.get(),h=c.get();return i&&Array.isArray(n)?(!o&&a(f)&&a(h)||(f=1/0,h=-(1/0),n.forEach(function(t){a(t)&&(f>t&&(f=+t),hh&&(f=0,h=1),s.set(f),c.set(h),u.nestedProperty(e,r+"cmin").set(f),u.nestedProperty(e,r+"cmax").set(h)),l.makeScaleFunction(i,f,h)):u.identity};var y={start:1,end:-1,middle:0,bottom:1,top:-1},b=1.3;p.textPointStyle=function(t,e){t.each(function(t){var r=i.select(this),n=t.tx||e.text;if(!n||Array.isArray(n))return void r.remove();var o=t.tp||e.textposition,s=o.indexOf("top")!==-1?"top":o.indexOf("bottom")!==-1?"bottom":"middle",l=o.indexOf("left")!==-1?"end":o.indexOf("right")!==-1?"start":"middle",u=t.ts||e.textfont.size,f=t.mrc?t.mrc/.8+1:0;u=a(u)&&u>0?u:0,r.call(p.font,t.tf||e.textfont.family,u,t.tc||e.textfont.color).attr("text-anchor",l).text(n).call(c.convertToTspans);var h=i.select(this.parentNode),d=r.selectAll("tspan.line"),g=((d[0].length||1)-1)*b+1,v=y[l]*f,m=.75*u+y[s]*f+(y[s]-1)*g*u/2;h.attr("transform","translate("+v+","+m+")"),g>1&&d.attr({x:r.attr("x"),y:r.attr("y")})})};var x=.5;p.smoothopen=function(t,e){if(t.length<3)return"M"+t.join("L");var r,i="M"+t[0],a=[];for(r=1;r=k&&(i.selectAll("[data-bb]").attr("data-bb",null),A=[]),t.setAttribute("data-bb",A.length),A.push(l),u.extendFlat({},l)},p.setClipUrl=function(t,e){if(!e)return void t.attr("clip-path",null);var r="#"+e,n=i.select("base");n.size()&&n.attr("href")&&(r=window.location.href+r),t.attr("clip-path","url("+r+")")}},{"../../constants/xmlns_namespaces":247,"../../lib":256,"../../lib/svg_text_utils":269,"../../plots/plots":303,"../../traces/scatter/make_bubble_size_func":355,"../../traces/scatter/subtypes":360,"../color":176,"../colorscale":190,"./symbol_defs":200,d3:54,"fast-isnumeric":60}],200:[function(t,e,r){"use strict";var n=t("d3");e.exports={circle:{n:0,f:function(t){var e=n.round(t,2);return"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"}},square:{n:1,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"}},diamond:{n:2,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"Z"}},cross:{n:3,f:function(t){var e=n.round(.4*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H"+e+"V"+r+"H-"+e+"V"+e+"H-"+r+"V-"+e+"H-"+e+"V-"+r+"H"+e+"V-"+e+"H"+r+"Z"}},x:{n:4,f:function(t){var e=n.round(.8*t/Math.sqrt(2),2),r="l"+e+","+e,i="l"+e+",-"+e,a="l-"+e+",-"+e,o="l-"+e+","+e;return"M0,"+e+r+i+a+i+a+o+a+o+r+o+r+"Z"}},"triangle-up":{n:5,f:function(t){var e=n.round(2*t/Math.sqrt(3),2),r=n.round(t/2,2),i=n.round(t,2);return"M-"+e+","+r+"H"+e+"L0,-"+i+"Z"}},"triangle-down":{n:6,f:function(t){var e=n.round(2*t/Math.sqrt(3),2),r=n.round(t/2,2),i=n.round(t,2);return"M-"+e+",-"+r+"H"+e+"L0,"+i+"Z"}},"triangle-left":{n:7,f:function(t){var e=n.round(2*t/Math.sqrt(3),2),r=n.round(t/2,2),i=n.round(t,2);return"M"+r+",-"+e+"V"+e+"L-"+i+",0Z"}},"triangle-right":{n:8,f:function(t){var e=n.round(2*t/Math.sqrt(3),2),r=n.round(t/2,2),i=n.round(t,2);return"M-"+r+",-"+e+"V"+e+"L"+i+",0Z"}},"triangle-ne":{n:9,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+r+",-"+e+"H"+e+"V"+r+"Z"}},"triangle-se":{n:10,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+e+",-"+r+"V"+e+"H-"+r+"Z"}},"triangle-sw":{n:11,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M"+r+","+e+"H-"+e+"V-"+r+"Z"}},"triangle-nw":{n:12,f:function(t){var e=n.round(.6*t,2),r=n.round(1.2*t,2);return"M-"+e+","+r+"V-"+e+"H"+r+"Z"}},pentagon:{n:13,f:function(t){var e=n.round(.951*t,2),r=n.round(.588*t,2),i=n.round(-t,2),a=n.round(t*-.309,2),o=n.round(.809*t,2);return"M"+e+","+a+"L"+r+","+o+"H-"+r+"L-"+e+","+a+"L0,"+i+"Z"}},hexagon:{n:14,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),i=n.round(t*Math.sqrt(3)/2,2);return"M"+i+",-"+r+"V"+r+"L0,"+e+"L-"+i+","+r+"V-"+r+"L0,-"+e+"Z"}},hexagon2:{n:15,f:function(t){var e=n.round(t,2),r=n.round(t/2,2),i=n.round(t*Math.sqrt(3)/2,2);return"M-"+r+","+i+"H"+r+"L"+e+",0L"+r+",-"+i+"H-"+r+"L-"+e+",0Z"}},octagon:{n:16,f:function(t){var e=n.round(.924*t,2),r=n.round(.383*t,2);return"M-"+r+",-"+e+"H"+r+"L"+e+",-"+r+"V"+r+"L"+r+","+e+"H-"+r+"L-"+e+","+r+"V-"+r+"Z"}},star:{n:17,f:function(t){var e=1.4*t,r=n.round(.225*e,2),i=n.round(.951*e,2),a=n.round(.363*e,2),o=n.round(.588*e,2),s=n.round(-e,2),l=n.round(e*-.309,2),u=n.round(.118*e,2),c=n.round(.809*e,2),f=n.round(.382*e,2);return"M"+r+","+l+"H"+i+"L"+a+","+u+"L"+o+","+c+"L0,"+f+"L-"+o+","+c+"L-"+a+","+u+"L-"+i+","+l+"H-"+r+"L0,"+s+"Z"}},hexagram:{n:18,f:function(t){var e=n.round(.66*t,2),r=n.round(.38*t,2),i=n.round(.76*t,2);return"M-"+i+",0l-"+r+",-"+e+"h"+i+"l"+r+",-"+e+"l"+r+","+e+"h"+i+"l-"+r+","+e+"l"+r+","+e+"h-"+i+"l-"+r+","+e+"l-"+r+",-"+e+"h-"+i+"Z"}},"star-triangle-up":{n:19,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),i=n.round(1.6*t,2),a=n.round(4*t,2),o="A "+a+","+a+" 0 0 1 ";return"M-"+e+","+r+o+e+","+r+o+"0,-"+i+o+"-"+e+","+r+"Z"}},"star-triangle-down":{n:20,f:function(t){var e=n.round(t*Math.sqrt(3)*.8,2),r=n.round(.8*t,2),i=n.round(1.6*t,2),a=n.round(4*t,2),o="A "+a+","+a+" 0 0 1 ";return"M"+e+",-"+r+o+"-"+e+",-"+r+o+"0,"+i+o+e+",-"+r+"Z"}},"star-square":{n:21,f:function(t){var e=n.round(1.1*t,2),r=n.round(2*t,2),i="A "+r+","+r+" 0 0 1 ";return"M-"+e+",-"+e+i+"-"+e+","+e+i+e+","+e+i+e+",-"+e+i+"-"+e+",-"+e+"Z"}},"star-diamond":{n:22,f:function(t){var e=n.round(1.4*t,2),r=n.round(1.9*t,2),i="A "+r+","+r+" 0 0 1 ";return"M-"+e+",0"+i+"0,"+e+i+e+",0"+i+"0,-"+e+i+"-"+e+",0Z"}},"diamond-tall":{n:23,f:function(t){var e=n.round(.7*t,2),r=n.round(1.4*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},"diamond-wide":{n:24,f:function(t){var e=n.round(1.4*t,2),r=n.round(.7*t,2);return"M0,"+r+"L"+e+",0L0,-"+r+"L-"+e+",0Z"}},hourglass:{n:25,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"H-"+e+"L"+e+",-"+e+"H-"+e+"Z"},noDot:!0},bowtie:{n:26,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"V-"+e+"L-"+e+","+e+"V-"+e+"Z"},noDot:!0},"circle-cross":{n:27,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"circle-x":{n:28,f:function(t){var e=n.round(t,2),r=n.round(t/Math.sqrt(2),2);return"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r+"M"+e+",0A"+e+","+e+" 0 1,1 0,-"+e+"A"+e+","+e+" 0 0,1 "+e+",0Z"},needLine:!0,noDot:!0},"square-cross":{n:29,f:function(t){var e=n.round(t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"square-x":{n:30,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e+"M"+e+","+e+"H-"+e+"V-"+e+"H"+e+"Z"},needLine:!0,noDot:!0},"diamond-cross":{n:31,f:function(t){var e=n.round(1.3*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM0,-"+e+"V"+e+"M-"+e+",0H"+e},needLine:!0,noDot:!0},"diamond-x":{n:32,f:function(t){var e=n.round(1.3*t,2),r=n.round(.65*t,2);return"M"+e+",0L0,"+e+"L-"+e+",0L0,-"+e+"ZM-"+r+",-"+r+"L"+r+","+r+"M-"+r+","+r+"L"+r+",-"+r},needLine:!0,noDot:!0},"cross-thin":{n:33,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e},needLine:!0,noDot:!0},"x-thin":{n:34,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e+"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0},asterisk:{n:35,f:function(t){var e=n.round(1.2*t,2),r=n.round(.85*t,2);return"M0,"+e+"V-"+e+"M"+e+",0H-"+e+"M"+r+","+r+"L-"+r+",-"+r+"M"+r+",-"+r+"L-"+r+","+r},needLine:!0,noDot:!0},hash:{n:36,f:function(t){var e=n.round(t/2,2),r=n.round(t,2);return"M"+e+","+r+"V-"+r+"m-"+r+",0V"+r+"M"+r+","+e+"H-"+r+"m0,-"+r+"H"+r},needLine:!0},"y-up":{n:37,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+e+","+i+"L0,0M"+e+","+i+"L0,0M0,-"+r+"L0,0"},needLine:!0,noDot:!0},"y-down":{n:38,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+e+",-"+i+"L0,0M"+e+",-"+i+"L0,0M0,"+r+"L0,0"},needLine:!0,noDot:!0},"y-left":{n:39,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M"+i+","+e+"L0,0M"+i+",-"+e+"L0,0M-"+r+",0L0,0"},needLine:!0,noDot:!0},"y-right":{n:40,f:function(t){var e=n.round(1.2*t,2),r=n.round(1.6*t,2),i=n.round(.8*t,2);return"M-"+i+","+e+"L0,0M-"+i+",-"+e+"L0,0M"+r+",0L0,0"},needLine:!0,noDot:!0},"line-ew":{n:41,f:function(t){var e=n.round(1.4*t,2);return"M"+e+",0H-"+e},needLine:!0,noDot:!0},"line-ns":{n:42,f:function(t){var e=n.round(1.4*t,2);return"M0,"+e+"V-"+e},needLine:!0,noDot:!0},"line-ne":{n:43,f:function(t){var e=n.round(t,2);return"M"+e+",-"+e+"L-"+e+","+e},needLine:!0,noDot:!0},"line-nw":{n:44,f:function(t){var e=n.round(t,2);return"M"+e+","+e+"L-"+e+",-"+e},needLine:!0,noDot:!0}}},{d3:54}],201:[function(t,e,r){"use strict";e.exports={visible:{valType:"boolean"},type:{valType:"enumerated",values:["percent","constant","sqrt","data"]},symmetric:{valType:"boolean"},array:{valType:"data_array"},arrayminus:{valType:"data_array"},value:{valType:"number",min:0,dflt:10},valueminus:{valType:"number",min:0,dflt:10},traceref:{valType:"integer",min:0,dflt:0},tracerefminus:{valType:"integer",min:0,dflt:0},copy_ystyle:{valType:"boolean"},copy_zstyle:{valType:"boolean"},color:{valType:"color"},thickness:{valType:"number",min:0,dflt:2},width:{valType:"number",min:0},_deprecated:{opacity:{valType:"number"}}}},{}],202:[function(t,e,r){"use strict";function n(t,e,r,n){var a=e["error_"+n]||{},l=a.visible&&["linear","log"].indexOf(r.type)!==-1,u=[];if(l){for(var c=s(a),f=0;f0;if(c.visible||u.visible){var h=i.select(this).selectAll("g.errorbar").data(o.identity);h.enter().append("g").classed("errorbar",!0),h.each(function(t){var e=i.select(this),o=n(t,r,l);if(!f||t.vis){var s;if(c.visible&&a(o.x)&&a(o.yh)&&a(o.ys)){var h=c.width;s="M"+(o.x-h)+","+o.yh+"h"+2*h+"m-"+h+",0V"+o.ys,o.noYS||(s+="m-"+h+",0h"+2*h),e.append("path").classed("yerror",!0).attr("d",s)}if(u.visible&&a(o.y)&&a(o.xh)&&a(o.xs)){var d=(u.copy_ystyle?c:u).width;s="M"+o.xh+","+(o.y-d)+"v"+2*d+"m0,-"+d+"H"+o.xs,o.noXS||(s+="m0,-"+d+"v"+2*d),e.append("path").classed("xerror",!0).attr("d",s)}}})}})}},{"../../lib":256,"../../traces/scatter/subtypes":360,d3:54,"fast-isnumeric":60}],207:[function(t,e,r){"use strict";var n=t("d3"),i=t("../color");e.exports=function(t){t.each(function(t){var e=t[0].trace,r=e.error_y||{},a=e.error_x||{},o=n.select(this);o.selectAll("path.yerror").style("stroke-width",r.thickness+"px").call(i.stroke,r.color),a.copy_ystyle&&(a=r),o.selectAll("path.xerror").style("stroke-width",a.thickness+"px").call(i.stroke,a.color)})}},{"../color":176,d3:54}],208:[function(t,e,r){"use strict";var n=t("../../plots/cartesian/constants");e.exports={_isLinkedToArray:!0,source:{valType:"string"},layer:{valType:"enumerated",values:["below","above"],dflt:"above"},sizex:{valType:"number",dflt:0},sizey:{valType:"number",dflt:0},sizing:{valType:"enumerated",values:["fill","contain","stretch"],dflt:"contain"},opacity:{valType:"number",min:0,max:1,dflt:1},x:{valType:"number",dflt:0},y:{valType:"number",dflt:0},xanchor:{valType:"enumerated",values:["left","center","right"],dflt:"left"},yanchor:{valType:"enumerated",values:["top","middle","bottom"],dflt:"top"},xref:{valType:"enumerated",values:["paper",n.idRegex.x.toString()],dflt:"paper"},yref:{valType:"enumerated",values:["paper",n.idRegex.y.toString()],dflt:"paper"}}},{"../../plots/cartesian/constants":284}],209:[function(t,e,r){"use strict";function n(t,e,r){function n(r,n){return a.coerce(t,e,o,r,n)}e=e||{},n("source"),n("layer"),n("x"),n("y"),n("xanchor"),n("yanchor"),n("sizex"),n("sizey"),n("sizing"),n("opacity");for(var s=0;s<2;s++){var l={_fullLayout:r},u=["x","y"][s];i.coerceRef(t,e,l,u,"paper")}return e}var i=t("../../plots/cartesian/axes"),a=t("../../lib"),o=t("./attributes");e.exports=function(t,e){if(t.images&&Array.isArray(t.images))for(var r=t.images,i=e.images=[],a=0;a=2/3},r.isCenterAnchor=function(t){return"center"===t.xanchor||"auto"===t.xanchor&&t.x>1/3&&t.x<2/3},r.isBottomAnchor=function(t){return"bottom"===t.yanchor||"auto"===t.yanchor&&t.y<=1/3},r.isMiddleAnchor=function(t){return"middle"===t.yanchor||"auto"===t.yanchor&&t.y>1/3&&t.y<2/3}},{}],213:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes"),i=t("../color/attributes"),a=t("../../lib/extend").extendFlat;e.exports={bgcolor:{valType:"color"},bordercolor:{valType:"color",dflt:i.defaultLine},borderwidth:{valType:"number",min:0,dflt:0},font:a({},n,{}),orientation:{valType:"enumerated",values:["v","h"],dflt:"v"},horizontalspacing:{valType:"enumerated",values:["column","wrapped"],dflt:["column"]},traceorder:{valType:"flaglist",flags:["reversed","grouped"],extras:["normal"]},tracegroupgap:{valType:"number",min:0,dflt:10},x:{valType:"number",min:-2,max:3,dflt:1.02},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"left"},y:{valType:"number",min:-2,max:3,dflt:1},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"auto"}}},{"../../lib/extend":253,"../../plots/font_attributes":297,"../color/attributes":175}],214:[function(t,e,r){"use strict";e.exports={scrollBarWidth:4,scrollBarHeight:20,scrollBarColor:"#808BA4",scrollBarMargin:4}},{}],215:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("../../plots/plots"),a=t("./attributes"),o=t("./helpers");e.exports=function(t,e,r){function s(t,e){return n.coerce(h,d,a,t,e)}for(var l,u,c,f,h=t.legend||{},d=e.legend={},p=0,g="normal",v="column",m=0;m1);if(b!==!1){if(s("bgcolor",e.paper_bgcolor),s("bordercolor"),s("borderwidth"),n.coerceFont(s,"font",e.font),s("orientation"),"h"===d.orientation){var x=t.xaxis;x&&x.rangeslider&&x.rangeslider.visible?(l=0,c="left",u=1.1,f="bottom"):(l=0,c="left",u=-.1,f="top")}s("traceorder",g),o.isGrouped(e.legend)&&s("tracegroupgap"),s("x",l),s("xanchor",c),s("y",u),s("yanchor",f),s("horizontalspacing",v),n.noneOrAll(h,d,["x","y"])}}},{"../../lib":256,"../../plots/plots":303,"./attributes":213,"./helpers":218}],216:[function(t,e,r){"use strict";function n(t,e){function r(r){c.util.convertToTspans(r,function(){r.selectAll("tspan.line").attr({x:r.attr("x")}),t.call(a,e)})}var n=t.data()[0][0],i=e._fullLayout,o=n.trace,s=h.traceIs(o,"pie"),l=o.index,u=s?n.label:o.name,f=t.selectAll("text.legendtext").data([0]);f.enter().append("text").classed("legendtext",!0),f.attr({x:40,y:0,"data-unformatted":u}).style("text-anchor","start").classed("user-select-none",!0).call(p.font,i.legend.font).text(u),e._context.editable&&!s?f.call(c.util.makeEditable).call(r).on("edit",function(t){this.attr({"data-unformatted":t}),this.text(t).call(r),this.text()||(t=" "),c.restyle(e,"name",t,l)}):f.call(r)}function i(t,e){var r=e._fullLayout.hiddenlabels?e._fullLayout.hiddenlabels.slice():[],n=t.selectAll("rect").data([0]);n.enter().append("rect").classed("legendtoggle",!0).style("cursor","pointer").attr("pointer-events","all").call(g.fill,"rgba(0,0,0,0)"),n.on("click",function(){if(!e._dragged){var n,i,a=t.data()[0][0],o=e._fullData,s=a.trace,l=s.legendgroup,u=[];if(h.traceIs(s,"pie")){var f=a.label,d=r.indexOf(f);d===-1?r.push(f):r.splice(d,1),c.relayout(e,"hiddenlabels",r)}else{if(""===l)u=[s.index];else for(var p=0;ptspan"),d=h[0].length||1;r=l*d,n=c.node()&&p.bBox(c.node()).width;var g=l*(.3+(1-d)/2);c.attr("y",g),h.attr("y",g)}r=Math.max(r,16)+3,a.attr({x:0,y:-r/2,height:r}),i.height=r,i.width=n}function o(t,e,r){var n=t._fullLayout,i=n.legend,a=i.borderwidth,o=b.isGrouped(i),s=b.isHorizontalColumn(i);if(b.isVertical(i))o&&e.each(function(t,e){f.setTranslate(this,0,e*i.tracegroupgap)}),i.width=0,i.height=0,r.each(function(t){var e=t[0],r=e.height,n=e.width;f.setTranslate(this,a,5+a+i.height+r/2),i.height+=r,i.width=Math.max(i.width,n)}),i.width+=45+2*a,i.height+=10+2*a,o&&(i.height+=(i._lgroupsLength-1)*i.tracegroupgap),r.selectAll(".legendtoggle").attr("width",(t._context.editable?0:i.width)+40),i.width=Math.ceil(i.width),i.height=Math.ceil(i.height);else if(o){i.width=0,i.height=0;for(var l=[i.width],c=e.data(),h=0,d=c.length;hn.width-(n.margin.r+n.margin.l)&&(x=0,v+=m,i.height=i.height+m,m=0),f.setTranslate(this,a+x,5+a+e.height/2+v),i.width+=o+r,i.height=Math.max(i.height,e.height),x+=o+r,m=Math.max(e.height,m)}),i.width+=2*a,i.height+=10+2*a,i.width=Math.ceil(i.width),i.height=Math.ceil(i.height),r.selectAll(".legendtoggle").attr("width",t._context.editable?0:i.width)}}function s(t){var e=t._fullLayout,r=e.legend,n="left";x.isRightAnchor(r)?n="right":x.isCenterAnchor(r)&&(n="center");var i="top";x.isBottomAnchor(r)?i="bottom":x.isMiddleAnchor(r)&&(i="middle"),h.autoMargin(t,"legend",{x:r.x,y:r.y,l:r.width*({right:1,center:.5}[n]||0),r:r.width*({left:1,center:.5}[n]||0),b:r.height*({top:1,middle:.5}[i]||0),t:r.height*({bottom:1,middle:.5}[i]||0)})}function l(t){var e=t._fullLayout,r=e.legend,n="left";x.isRightAnchor(r)?n="right":x.isCenterAnchor(r)&&(n="center"),h.autoMargin(t,"legend",{x:r.x,y:.5,l:r.width*({right:1,center:.5}[n]||0),r:r.width*({left:1,center:.5}[n]||0),b:0,t:0})}var u=t("d3"),c=t("../../plotly"),f=t("../../lib"),h=t("../../plots/plots"),d=t("../dragelement"),p=t("../drawing"),g=t("../color"),v=t("./constants"),m=t("./get_legend_data"),y=t("./style"),b=t("./helpers"),x=t("./anchor_utils");e.exports=function(t){function e(t,e){E.attr("data-scroll",e).call(f.setTranslate,0,e),T.call(p.setRect,F,t,v.scrollBarWidth,v.scrollBarHeight),k.select("rect").attr({y:b.borderwidth-e})}var r=t._fullLayout,a="legend"+r._uid;if(r._infolayer&&t.calcdata){var b=r.legend,_=r.showlegend&&m(t.calcdata,b),w=r.hiddenlabels||[];if(!r.showlegend||!_.length)return r._infolayer.selectAll(".legend").remove(),r._topdefs.select("#"+a).remove(),void h.autoMargin(t,"legend");var A=r._infolayer.selectAll("g.legend").data([0]);A.enter().append("g").attr({class:"legend","pointer-events":"all"});var k=r._topdefs.selectAll("#"+a).data([0]);k.enter().append("clipPath").attr("id",a).append("rect");var M=A.selectAll("rect.bg").data([0]);M.enter().append("rect").attr({class:"bg","shape-rendering":"crispEdges"}),M.call(g.stroke,b.bordercolor),M.call(g.fill,b.bgcolor),M.style("stroke-width",b.borderwidth+"px");var E=A.selectAll("g.scrollbox").data([0]);E.enter().append("g").attr("class","scrollbox");var T=A.selectAll("rect.scrollbar").data([0]);T.enter().append("rect").attr({class:"scrollbar",rx:20,ry:2,width:0,height:0}).call(g.fill,"#808BA4");var L=E.selectAll("g.groups").data(_);L.enter().append("g").attr("class","groups"),L.exit().remove();var S=L.selectAll("g.traces").data(f.identity);S.enter().append("g").attr("class","traces"),S.exit().remove(),S.call(y).style("opacity",function(t){var e=t[0].trace;return h.traceIs(e,"pie")?w.indexOf(t[0].label)!==-1?.5:1:"legendonly"===e.visible?.5:1}).each(function(){u.select(this).call(n,t).call(i,t)});var C=0!==A.enter().size();C&&(o(t,L,S),s(t));var R=0,I=r.width,P=0,O=r.height;o(t,L,S),b.height>O?l(t):s(t);var N=r._size,z=N.l+N.w*b.x,D=N.t+N.h*(1-b.y);x.isRightAnchor(b)?z-=b.width:x.isCenterAnchor(b)&&(z-=b.width/2),x.isBottomAnchor(b)?D-=b.height:x.isMiddleAnchor(b)&&(D-=b.height/2);var F=b.width,B=N.w;F>B?(z=N.l,F=B):(z+F>I&&(z=I-F),zU?(D=N.t,j=U):(D+j>O&&(D=O-j),Dr[1])return r[1]}return i}function r(t){return t[0]}var n,i,a=t[0],o=a.trace,s=d.hasMarkers(o),c=d.hasText(o),h=d.hasLines(o);if(s||c||h){var p={},g={};s&&(p.mc=e("marker.color",r),p.mo=e("marker.opacity",u.mean,[.2,1]),p.ms=e("marker.size",u.mean,[2,16]),p.mlc=e("marker.line.color",r),p.mlw=e("marker.line.width",u.mean,[0,5]),g.marker={sizeref:1,sizemin:1,sizemode:"diameter"}),h&&(g.line={width:e("line.width",r,[0,10])}),c&&(p.tx="Aa",p.tp=e("textposition",r),p.ts=10,p.tc=e("textfont.color",r),p.tf=e("textfont.family",r)),n=[u.minExtend(a,p)],i=u.minExtend(o,g)}var v=l.select(this).select("g.legendpoints"),m=v.selectAll("path.scatterpts").data(s?n:[]);m.enter().append("path").classed("scatterpts",!0).attr("transform","translate(20,0)"),m.exit().remove(),m.call(f.pointStyle,i),s&&(n[0].mrc=3);var y=v.selectAll("g.pointtext").data(c?n:[]);y.enter().append("g").classed("pointtext",!0).append("text").attr("transform","translate(20,0)"),y.exit().remove(),y.selectAll("text").call(f.textPointStyle,i)}function a(t){var e=t[0].trace,r=e.marker||{},n=r.line||{},i=l.select(this).select("g.legendpoints").selectAll("path.legendbar").data(c.traceIs(e,"bar")?[t]:[]);i.enter().append("path").classed("legendbar",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),i.exit().remove(),i.each(function(t){var e=(t.mlw+1||n.width+1)-1,i=l.select(this);i.style("stroke-width",e+"px").call(h.fill,t.mc||r.color),e&&i.call(h.stroke,t.mlc||n.color)})}function o(t){var e=t[0].trace,r=l.select(this).select("g.legendpoints").selectAll("path.legendbox").data(c.traceIs(e,"box")&&e.visible?[t]:[]);r.enter().append("path").classed("legendbox",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),r.exit().remove(),r.each(function(t){var r=(t.lw+1||e.line.width+1)-1,n=l.select(this);n.style("stroke-width",r+"px").call(h.fill,t.fc||e.fillcolor),r&&n.call(h.stroke,t.lc||e.line.color)})}function s(t){var e=t[0].trace,r=l.select(this).select("g.legendpoints").selectAll("path.legendpie").data(c.traceIs(e,"pie")&&e.visible?[t]:[]);r.enter().append("path").classed("legendpie",!0).attr("d","M6,6H-6V-6H6Z").attr("transform","translate(20,0)"),r.exit().remove(),r.size()&&r.call(p,t[0],e)}var l=t("d3"),u=t("../../lib"),c=t("../../plots/plots"),f=t("../drawing"),h=t("../color"),d=t("../../traces/scatter/subtypes"),p=t("../../traces/pie/style_one");e.exports=function(t){t.each(function(t){var e=l.select(this),r=e.selectAll("g.legendfill").data([t]);r.enter().append("g").classed("legendfill",!0);var n=e.selectAll("g.legendlines").data([t]);n.enter().append("g").classed("legendlines",!0);var i=e.selectAll("g.legendsymbols").data([t]);i.enter().append("g").classed("legendsymbols",!0),i.style("opacity",t[0].trace.opacity),i.selectAll("g.legendpoints").data([t]).enter().append("g").classed("legendpoints",!0)}).each(a).each(o).each(s).each(n).each(i)}},{"../../lib":256,"../../plots/plots":303,"../../traces/pie/style_one":339,"../../traces/scatter/subtypes":360,"../color":176,"../drawing":199,d3:54}],221:[function(t,e,r){"use strict";function n(t,e){var r=e.currentTarget,n=r.getAttribute("data-attr"),i=r.getAttribute("data-val")||!0,a=t._fullLayout,o={};if("zoom"===n){for(var s,l,c="in"===i?.5:2,f=(1+c)/2,h=(1-c)/2,d=u.Axes.list(t,null,!0),p=0;p1)return n(["resetViews","toggleHover"]),o(v,r);c&&(n(["zoom3d","pan3d","orbitRotation","tableRotation"]),n(["resetCameraDefault3d","resetCameraLastSave3d"]),n(["hoverClosest3d"])),h&&(n(["zoomInGeo","zoomOutGeo","resetGeo"]),n(["hoverClosestGeo"]));var m=i(s),y=[];return((u||p)&&!m||g)&&(y=["zoom2d","pan2d"]),(u||g)&&a(l)&&(y.push("select2d"),y.push("lasso2d")),y.length&&n(y),!u&&!p||m||g||n(["zoomIn2d","zoomOut2d","autoScale2d","resetScale2d"]),u&&d?n(["toggleHover"]):p?n(["hoverClosestGl2d"]):u?n(["hoverClosestCartesian","hoverCompareCartesian"]):d&&n(["hoverClosestPie"]),o(v,r)}function i(t){for(var e=l.Axes.list({_fullLayout:t},null,!0),r=!0,n=0;n0);if(p){var g=i(e,r,l);c("x",g[0]),c("y",g[1]),a.noneOrAll(t,e,["x","y"]),c("xanchor"),c("yanchor"),a.coerceFont(c,"font",r.font);var v=c("bgcolor");c("activecolor",o.contrast(v,u.lightAmount,u.darkAmount)),c("bordercolor"),c("borderwidth")}}},{"../../lib":256,"../color":176,"./attributes":224,"./button_attributes":225,"./constants":226}],228:[function(t,e,r){"use strict";function n(t){for(var e=m.list(t,"x",!0),r=[],n=0;ne;i--)d(t,i).selectAll('[data-index="'+(i-1)+'"]').attr("data-index",i),C.draw(t,i)}function f(t,e,r,o){function s(r){var n={"data-index":e,"fill-rule":"evenodd",d:b(t,C)},i=C.line.width?C.line.color:"rgba(0,0,0,0)",a=r.append("path").attr(n).style("opacity",C.opacity).call(E.stroke,i).call(E.fill,C.fillcolor).call(T.dashLine,C.line.dash,C.line.width);R&&a.call(T.setClipUrl,"clip"+t._fullLayout._uid+R),t._context.editable&&h(t,a,C,e)}var l,u;d(t,e).selectAll('[data-index="'+e+'"]').remove();var c=t.layout.shapes[e];if(c){var f={xref:c.xref,yref:c.yref},g={};"string"==typeof r&&r?g[r]=o:k.isPlainObject(r)&&(g=r);var v=Object.keys(g);for(l=0;lW&&n>Z&&!t.shiftKey?L.getCursor(i/r,1-a/n):"move";S(e,o),Y=o.split("-")[0]}function a(e){U=M.getFromId(t,r.xref),V=M.getFromId(t,r.yref),q=m(t,U),H=m(t,V,!0),G=y(t,U),X=y(t,V,!0);var a="shapes["+n+"]";"path"===r.type?(B=r.path,j=a+".path"):(c=q(r.x0),f=H(r.y0),h=q(r.x1),d=H(r.y1),p=a+".x0",g=a+".y0",_=a+".x1",w=a+".y1"),cZ&&(u[R]=r[N]=X(s),u[I]=r[z]=X(l)),f-c>W&&(u[P]=r[D]=G(c),u[O]=r[F]=G(f))}e.attr("d",b(t,r))}var u,c,f,h,d,p,g,_,w,k,E,T,C,R,I,P,O,N,z,D,F,B,j,U,V,q,H,G,X,Y,W=10,Z=10,Q={setCursor:i,element:e.node(),prepFn:a,doneFn:o},$=Q.element.getBoundingClientRect();L.init(Q)}function d(t,e){var r=t._fullLayout.shapes[e],n=t._fullLayout._shapeUpperLayer;return r?"below"===r.layer&&(n="paper"===r.xref&&"paper"===r.yref?t._fullLayout._shapeLowerLayer:t._fullLayout._shapeSubplotLayer):k.log("getShapeLayer: undefined shape: index",e),n}function p(t,e,r){var n=A.Axes.getFromId(t,r.id,"x")._id,i=A.Axes.getFromId(t,r.id,"y")._id,a="below"===e.layer,o=n===e.xref||i===e.yref,s=!!r.shapelayer;return a&&o&&s}function g(t){return function(e){return e.replace&&(e=e.replace("_"," ")),t(e)}}function v(t){return function(e){return t(e).replace(" ","_")}}function m(t,e,r){var n,a=t._fullLayout._size;if(e){var o=i(e);n=function(t){return e._offset+e.l2p(o(t,!0))},"date"===e.type&&(n=g(n))}else n=r?function(t){return a.t+a.h*(1-t)}:function(t){return a.l+a.w*t};return n}function y(t,e,r){var n,i=t._fullLayout._size;if(e){var o=a(e);n=function(t){return o(e.p2l(t-e._offset))}}else n=r?function(t){return 1-(t-i.t)/i.h}:function(t){return(t-i.l)/i.w};return n}function b(t,e){var r,n,a,o,s=e.type,l=M.getFromId(t,e.xref),u=M.getFromId(t,e.yref),c=t._fullLayout._size;if(l?(r=i(l),n=function(t){return l._offset+l.l2p(r(t,!0))}):n=function(t){return c.l+c.w*t},u?(a=i(u),o=function(t){return u._offset+u.l2p(a(t,!0))}):o=function(t){return c.t+c.h*(1-t)},"path"===s)return l&&"date"===l.type&&(n=g(n)),u&&"date"===u.type&&(o=g(o)),C.convertPath(e.path,n,o);var f=n(e.x0),h=n(e.x1),d=o(e.y0),p=o(e.y1);if("line"===s)return"M"+f+","+d+"L"+h+","+p;if("rect"===s)return"M"+f+","+d+"H"+h+"V"+p+"H"+f+"Z";var v=(f+h)/2,m=(d+p)/2,y=Math.abs(v-f),b=Math.abs(m-d),x="A"+y+","+b,_=v+y+","+m,w=v+","+(m-b);return"M"+_+x+" 0 1,1 "+w+x+" 0 0,1 "+_+"Z"}function x(t,e,r){return t.replace(R,function(t){var n=0,i=t.charAt(0),a=P[i],o=O[i],s=N[i],l=t.substr(1).replace(I,function(t){return n>=s?t:(a[n]?t=e(t):o[n]&&(t=r(t)),n++,t)});return i+l})}function _(t,e,r,n,i){var a="category"===t.type?Number:t.d2c;if(void 0!==e)return[a(e),a(r)];if(n){var o,s,l,u,c,f=1/0,h=-(1/0),d=n.match(R);for("date"===t.type&&(a=g(a)),o=0;oh&&(h=c)));return h>=f?[f,h]:void 0}}var w=t("fast-isnumeric"),A=t("../../plotly"),k=t("../../lib"),M=t("../../plots/cartesian/axes"),E=t("../color"),T=t("../drawing"),L=t("../dragelement"),S=t("../../lib/setcursor"),C=e.exports={};C.layoutAttributes=t("./attributes"),C.supplyLayoutDefaults=function(t,e){for(var r=t.shapes||[],i=e.shapes=[],a=0;as&&(t="X"),t});return n>s&&(l=l.replace(/[\s,]*X.*/,""),k.log("Ignoring extra params in segment "+t)),i+l})},C.calcAutorange=function(t){var e,r,n,i,a,o=t._fullLayout,s=o.shapes;if(s.length&&t._fullData.length)for(e=0;e0||h<0){var d={left:[-r,0],right:[r,0],top:[0,-r],bottom:[0,r]}[b.side];e.attr("transform","translate("+d+")")}}}function p(){T=0,L=!0,S=R,A._infolayer.select("."+e).attr({"data-unformatted":S}).text(S).on("mouseover.opacity",function(){n.select(this).transition().duration(100).style("opacity",1)}).on("mouseout.opacity",function(){n.select(this).transition().duration(1e3).style("opacity",0)})}var g=r.propContainer,v=r.propName,m=r.traceIndex,y=r.dfltName,b=r.avoid||{},x=r.attributes,_=r.transform,w=r.containerGroup,A=t._fullLayout,k=g.titlefont.family,M=g.titlefont.size,E=g.titlefont.color,T=1,L=!1,S=g.title.trim();""===S&&(T=0),S.match(/Click to enter .+ title/)&&(T=.2,L=!0),w||(w=A._infolayer.selectAll(".g-"+e).data([0]),w.enter().append("g").classed("g-"+e,!0));var C=w.selectAll("text").data([0]);C.enter().append("text"),C.text(S).attr("class",e),C.attr({"data-unformatted":S}).call(f);var R="Click to enter "+y+" title";t._context.editable?(S||p(),C.call(c.makeEditable).on("edit",function(e){void 0!==m?a.restyle(t,v,e,m):a.relayout(t,v,e)}).on("cancel",function(){this.text(this.attr("data-unformatted")).call(f)}).on("input",function(t){this.text(t||" ").attr(x).selectAll("tspan.line").attr(x)})):S&&!S.match(/Click to enter .+ title/)||C.remove(),C.classed("js-placeholder",L)}},{"../../lib":256,"../../lib/svg_text_utils":269,"../../plotly":276,"../../plots/plots":303,"../color":176,"../drawing":199,d3:54,"fast-isnumeric":60}],240:[function(t,e,r){"use strict";var n=t("../../plots/font_attributes"),i=t("../color/attributes"),a=t("../../lib/extend").extendFlat,o={_isLinkedToArray:!0,method:{valType:"enumerated",values:["restyle","relayout"],dflt:"restyle"},args:{valType:"info_array",freeLength:!0,items:[{valType:"any"},{valType:"any"},{valType:"any"}]},label:{valType:"string",dflt:""}};e.exports={_isLinkedToArray:!0,visible:{valType:"boolean"},active:{valType:"integer",min:-1,dflt:0},buttons:o,x:{valType:"number",min:-2,max:3,dflt:-.05},xanchor:{valType:"enumerated",values:["auto","left","center","right"],dflt:"right"},y:{valType:"number",min:-2,max:3,dflt:1},yanchor:{valType:"enumerated",values:["auto","top","middle","bottom"],dflt:"bottom"},font:a({},n,{}),bgcolor:{valType:"color"},bordercolor:{valType:"color",dflt:i.borderLine},borderwidth:{valType:"number",min:0,dflt:1}}},{"../../lib/extend":253,"../../plots/font_attributes":297,"../color/attributes":175}],241:[function(t,e,r){"use strict";e.exports={name:"updatemenus",itemName:"updatemenu",containerClassName:"updatemenu-container",headerGroupClassName:"updatemenu-header-group",headerClassName:"updatemenu-header",headerArrowClassName:"updatemenu-header-arrow",buttonGroupClassName:"updatemenu-button-group",buttonClassName:"updatemenu-button",itemRectClassName:"updatemenu-item-rect",itemTextClassName:"updatemenu-item-text",menuIndexAttrName:"updatemenu-active-index",autoMarginIdRoot:"updatemenu-",blankHeaderOpts:{label:" "},minWidth:30,minHeight:30,textPadX:40,fontSizeToHeight:1.3,rx:2,ry:2,textOffsetX:12,textOffsetY:3,arrowOffsetX:4,gapButtonHeader:5,gapButton:2,activeColor:"#F4FAFF",hoverColor:"#F4FAFF"}},{}],242:[function(t,e,r){"use strict";function n(t,e,r){function n(r,n){return a.coerce(t,e,o,r,n)}var s=i(t,e),l=n("visible",s.length>0);l&&(n("active"),n("x"),n("y"),a.noneOrAll(t,e,["x","y"]),n("xanchor"),n("yanchor"),a.coerceFont(n,"font",r.font),n("bgcolor",r.paper_bgcolor),n("bordercolor"),n("borderwidth"))}function i(t,e){function r(t,e){return a.coerce(n,i,u,t,e)}for(var n,i,o=t.buttons||[],s=e.buttons=[],l=0;l0?[0]:[]);if(l.enter().append("g").classed(E.containerClassName,!0).style("cursor","pointer"),l.exit().remove(),l.exit().size()&&m(t),0!==r.length){var u=l.selectAll("g."+E.headerGroupClassName).data(r,i);u.enter().append("g").classed(E.headerGroupClassName,!0);var c=l.selectAll("g."+E.buttonGroupClassName).data([0]);c.enter().append("g").classed(E.buttonGroupClassName,!0).style("pointer-events","all"),u.enter().size()&&c.call(v).attr(E.menuIndexAttrName,"-1"),u.exit().each(function(e){y.select(this).remove(),c.call(v).attr(E.menuIndexAttrName,"-1"),x.autoMargin(t,E.autoMarginIdRoot+e._index)});for(var f=0;fi.max?e.set(r):e.set(+t)}},integer:{coerceFunction:function(t,e,r,i){t%1||!n(t)||void 0!==i.min&&ti.max?e.set(r):e.set(+t)}},string:{coerceFunction:function(t,e,r,n){if("string"!=typeof t){var i="number"==typeof t;n.strict!==!0&&i?e.set(String(t)):e.set(r)}else n.noBlank&&!t?e.set(r):e.set(t)}},color:{coerceFunction:function(t,e,r){i(t).isValid()?e.set(t):e.set(r)}},colorscale:{coerceFunction:function(t,e,r){e.set(o(t,r))}},angle:{coerceFunction:function(t,e,r){"auto"===t?e.set("auto"):n(t)?(Math.abs(t)>180&&(t-=360*Math.round(t/360)),e.set(+t)):e.set(r)}},subplotid:{coerceFunction:function(t,e,r){var n=r.length;return"string"==typeof t&&t.substr(0,n)===r&&s.test(t.substr(n))?void e.set(t):void e.set(r)},validateFunction:function(t,e){var r=e.dflt,n=r.length;return t===r||"string"==typeof t&&!(t.substr(0,n)!==r||!s.test(t.substr(n)))}},flaglist:{coerceFunction:function(t,e,r,n){if("string"!=typeof t)return void e.set(r);if((n.extras||[]).indexOf(t)!==-1)return void e.set(t);for(var i=t.split("+"),a=0;a2)return!1;var o=a[0].split("-");if(o.length>3||3!==o.length&&a[1])return!1;if(4===o[0].length)e=Number(o[0]);else{if(2!==o[0].length)return!1;var l=(new Date).getFullYear();e=((Number(o[0])-l+70)%100+200)%100+l-70}return!!s(e)&&(1===o.length?new Date(e,0,1).getTime():(r=Number(o[1])-1,!(o[1].length>2)&&r>=0&&r<=11&&(2===o.length?new Date(e,r,1).getTime():(n=Number(o[2]),!(o[2].length>2)&&n>=1&&n<=31&&(n=new Date(e,r,n).getTime(),a[1]?(o=a[1].split(":"),!(o.length>3)&&(i=Number(o[0]),!(o[0].length>2)&&i>=0&&i<=23&&(n+=36e5*i,1===o.length?n:(r=Number(o[1]),!(o[1].length>2)&&r>=0&&r<=59&&(n+=6e4*r,2===o.length?n:(t=Number(o[2]),t>=0&&t<60&&n+1e3*t)))))):n)))))},r.isDateTime=function(t){return r.dateTime2ms(t)!==!1},r.ms2DateTime=function(t,e){if("undefined"==typeof o)return void l.error("d3 is not defined.");e||(e=0);var r=new Date(t),i=o.time.format("%Y-%m-%d")(r);return e<7776e6?(i+=" "+n(r.getHours(),2),e<432e6&&(i+=":"+n(r.getMinutes(),2),e<108e5&&(i+=":"+n(r.getSeconds(),2),e<3e5&&(i+="."+n(r.getMilliseconds(),3)))),i.replace(/([:\s]00)*\.?[0]*$/,"")):i};var u={H:["%H:%M:%S~%L","%H:%M:%S","%H:%M"],I:["%I:%M:%S~%L%p","%I:%M:%S%p","%I:%M%p"],D:["%H","%I%p","%Hh"]},c={Y:["%Y~%m~%d","%Y%m%d","%y%m%d","%m~%d~%Y","%d~%m~%Y"],Yb:["%b~%d~%Y","%d~%b~%Y","%Y~%d~%b","%Y~%b~%d"],y:["%m~%d~%y","%d~%m~%y","%y~%m~%d"],yb:["%b~%d~%y","%d~%b~%y","%y~%d~%b","%y~%b~%d"]},f=o.time.format.utc,h={Y:{H:["%Y~%m~%dT%H:%M:%S","%Y~%m~%dT%H:%M:%S~%L"].map(f),I:[],D:["%Y%m%d%H%M%S","%Y~%m","%m~%Y"].map(f)},Yb:{H:[],I:[],D:["%Y~%b","%b~%Y"].map(f)},y:{H:[],I:[],D:[]},yb:{H:[],I:[],D:[]}};["Y","Yb","y","yb"].forEach(function(t){c[t].forEach(function(e){h[t].D.push(f(e)),["H","I","D"].forEach(function(r){u[r].forEach(function(n){var i=h[t][r];i.push(f(e+"~"+n)),i.push(f(n+"~"+e))})})})});var d=/[a-z]*/g,p=function(t){return t.substr(0,3)},g=/(mon|tue|wed|thu|fri|sat|sun|the|of|st|nd|rd|th)/g,v=/[\s,\/\-\.\(\)]+/g,m=/~?([ap])~?m(~|$)/,y=function(t,e){return e+"m "},b=/\d\d\d\d/,x=/(^|~)[a-z]{3}/,_=/[ap]m/,w=/:/,A=/q([1-4])/,k=["31~mar","30~jun","30~sep","31~dec"],M=function(t,e){return k[e-1]},E=/ ?([+\-]\d\d:?\d\d|Z)$/;r.parseDate=function(t){if(t.getTime)return t;if("string"!=typeof t)return!1;t=t.toLowerCase().replace(d,p).replace(g,"").replace(v,"~").replace(m,y).replace(A,M).trim().replace(E,"");var e,r,n=null,o=i(t),s=a(t);e=h[o][s],r=e.length;for(var l=0;l",e))>=0;){var r=t.indexOf("",e);if(r/g,"\n")}function a(t){return t.replace(/\<.*\>/g,"")}function o(t){for(var e=0;(e=t.indexOf("&",e))>=0;){var r=t.indexOf(";",e);if(r"};e.exports=s},{"superscript-text":154}],256:[function(t,e,r){"use strict";var n=t("d3"),i=e.exports={};i.nestedProperty=t("./nested_property"),i.isPlainObject=t("./is_plain_object");var a=t("./coerce");i.valObjects=a.valObjects,i.coerce=a.coerce,i.coerce2=a.coerce2,i.coerceFont=a.coerceFont,i.validate=a.validate;var o=t("./dates");i.dateTime2ms=o.dateTime2ms,i.isDateTime=o.isDateTime,i.ms2DateTime=o.ms2DateTime,i.parseDate=o.parseDate;var s=t("./search");i.findBin=s.findBin,i.sorterAsc=s.sorterAsc,i.sorterDes=s.sorterDes,i.distinctVals=s.distinctVals,i.roundUp=s.roundUp;var l=t("./stats");i.aggNums=l.aggNums,i.len=l.len,i.mean=l.mean,i.variance=l.variance,i.stdev=l.stdev,i.interp=l.interp;var u=t("./matrix");i.init2dArray=u.init2dArray,i.transposeRagged=u.transposeRagged,i.dot=u.dot,i.translationMatrix=u.translationMatrix,i.rotationMatrix=u.rotationMatrix,i.rotationXYMatrix=u.rotationXYMatrix,i.apply2DTransform=u.apply2DTransform,i.apply2DTransform2=u.apply2DTransform2;var c=t("./extend");i.extendFlat=c.extendFlat,i.extendDeep=c.extendDeep,i.extendDeepAll=c.extendDeepAll,i.extendDeepNoArrays=c.extendDeepNoArrays;var f=t("./loggers");i.log=f.log,i.warn=f.warn,i.error=f.error,i.notifier=t("./notifier"),i.swapAttrs=function(t,e,r,n){r||(r="x"),n||(n="y");for(var a=0;ar?Math.max(r,Math.min(e,t)):Math.max(e,Math.min(r,t))},i.bBoxIntersect=function(t,e,r){return r=r||0,t.left<=e.right+r&&e.left<=t.right+r&&t.top<=e.bottom+r&&e.top<=t.bottom+r},i.identity=function(t){return t},i.randstr=function t(e,r,n){if(n||(n=16),void 0===r&&(r=24),r<=0)return"0";var i,a,o,s=Math.log(Math.pow(2,r))/Math.log(n),l="";for(i=2;s===1/0;i*=2)s=Math.log(Math.pow(2,r/i))/Math.log(n)*i;var u=s-Math.floor(s);for(i=0;i-1||c!==1/0&&c>=Math.pow(2,r)?t(e,r,n):l},i.OptionControl=function(t,e){t||(t={}),e||(e="opt");var r={};return r.optionList=[],r._newoption=function(n){n[e]=t,r[n.name]=n,r.optionList.push(n)},r["_"+e]=t,r},i.smooth=function(t,e){if(e=Math.round(e)||0,e<2)return t;var r,n,i,a,o=t.length,s=2*o,l=2*e-1,u=new Array(l),c=new Array(o);for(r=0;r=s&&(i-=s*Math.floor(i/s)),i<0?i=-1-i:i>=o&&(i=s-1-i),a+=t[i]*u[n];c[r]=a}return c},i.syncOrAsync=function(t,e,r){function n(){return i.syncOrAsync(t,e,r)}for(var a,o;t.length;)if(o=t.splice(0,1)[0],a=o(e),a&&a.then)return a.then(n).then(void 0,i.promiseError);return r&&r(e)},i.stripTrailingSlash=function(t){return"/"===t.substr(-1)?t.substr(0,t.length-1):t},i.noneOrAll=function(t,e,r){if(t){var n,i,a=!1,o=!0;for(n=0;n1?n+a[1]:"";if(i&&(a.length>1||o.length>4))for(;r.test(o);)o=o.replace(r,"$1"+i+"$2");return o+s}},{"./coerce":250,"./dates":251,"./extend":253,"./is_plain_object":257,"./loggers":258,"./matrix":259,"./nested_property":260,"./notifier":261,"./search":264,"./stats":267,d3:54}],257:[function(t,e,r){"use strict";e.exports=function(t){return window&&window.process&&window.process.versions?"[object Object]"===Object.prototype.toString.call(t):"[object Object]"===Object.prototype.toString.call(t)&&Object.getPrototypeOf(t)===Object.prototype}},{}],258:[function(t,e,r){"use strict";var n=t("../plot_api/plot_config"),i=e.exports={};i.log=function(){if(n.logging>1){for(var t=["LOG:"],e=0;e0){for(var t=["WARN:"],e=0;e0){for(var t=["ERROR:"],e=0;e=0;e--){if(n=t[e],o=!1,Array.isArray(n))for(r=n.length-1;r>=0;r--)u(n[r])?o?n[r]=void 0:n.pop():o=!0;else if("object"==typeof n&&null!==n)for(a=Object.keys(n),o=!1,r=a.length-1;r>=0;r--)u(n[a[r]])&&!i(n[a[r]],a[r])?delete n[a[r]]:o=!0;if(o)return}}function u(t){return void 0===t||null===t||"object"==typeof t&&(Array.isArray(t)?!t.length:!Object.keys(t).length)}function c(t,e,r){return{set:function(){throw"bad container"},get:function(){},astr:e,parts:r,obj:t}}var f=t("fast-isnumeric");e.exports=function(t,e){if(f(e))e=String(e);else if("string"!=typeof e||"[-1]"===e.substr(e.length-4))throw"bad property string";for(var r,i,o,s=0,l=e.split(".");sa||ns)&&(!e||!u(t))}function r(t,e){var r=t[0],l=t[1];if(ra||ls)return!1;var u,c,f,h,d,p=n.length,g=n[0][0],v=n[0][1],m=0;for(u=1;uMath.max(c,g)||l>Math.max(f,v)))if(lc||Math.abs(n(o,h))>i)return!0;return!1};i.filter=function(t,e){function r(r){t.push(r);var s=n.length,l=i;n.splice(o+1);for(var u=l+1;u1){var s=t.pop();r(s)}return{addPt:r,raw:t,filtered:n}}},{"./matrix":259}],263:[function(t,e,r){"use strict";function n(t,e){for(var r,n=[],a=0;aa.queueLength&&(t.undoQueue.queue.shift(),t.undoQueue.index--)))},o.startSequence=function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!0,t.undoQueue.beginSequence=!0},o.stopSequence=function(t){t.undoQueue=t.undoQueue||{index:0,queue:[],sequence:!1},t.undoQueue.sequence=!1,t.undoQueue.beginSequence=!1},o.undo=function(t){var e,r;if(t.framework&&t.framework.isPolar)return void t.framework.undo();if(!(void 0===t.undoQueue||isNaN(t.undoQueue.index)||t.undoQueue.index<=0)){for(t.undoQueue.index--,e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,r=0;r=t.undoQueue.queue.length)){for(e=t.undoQueue.queue[t.undoQueue.index],t.undoQueue.inSequence=!0,r=0;re}function o(t,e){return t>=e}var s=t("fast-isnumeric"),l=t("../lib");r.findBin=function(t,e,r){if(s(e.start))return r?Math.ceil((t-e.start)/e.size)-1:Math.floor((t-e.start)/e.size);var u,c,f=0,h=e.length,d=0;for(c=e[e.length-1]>=e[0]?r?n:i:r?o:a;f90&&l.log("Long binary search..."),f-1},r.sorterAsc=function(t,e){return t-e},r.sorterDes=function(t,e){return e-t},r.distinctVals=function(t){var e=t.slice();e.sort(r.sorterAsc);for(var n=e.length-1,i=e[n]-e[0]||1,a=i/(n||1)/1e4,o=[e[0]],s=0;se[s]+a&&(i=Math.min(i,e[s+1]-e[s]),o.push(e[s+1]));return{vals:o,minDiff:i}},r.roundUp=function(t,e,r){for(var n,i=0,a=e.length-1,o=0,s=r?0:1,l=r?1:0,u=r?Math.ceil:Math.floor;it.length-1)return t[t.length-1];var r=e%1;return r*t[Math.ceil(e)]+(1-r)*t[Math.floor(e)]}},{"fast-isnumeric":60}],268:[function(t,e,r){"use strict";function n(t){return t=i(t),a.str2RgbaArray(t.toRgbString())}var i=t("tinycolor2"),a=t("arraytools");e.exports=n},{arraytools:9,tinycolor2:157}],269:[function(t,e,r){"use strict";function n(t,e){return t.node().getBoundingClientRect()[e]}function i(t){return t.replace(/(<|<|<)/g,"\\lt ").replace(/(>|>|>)/g,"\\gt ")}function a(t,e,r){var n="math-output-"+u.Lib.randstr([],64),a=c.select("body").append("div").attr({id:n}).style({visibility:"hidden",position:"absolute"}).style({"font-size":e.fontSize+"px"}).text(i(t));MathJax.Hub.Queue(["Typeset",MathJax.Hub,a.node()],function(){var e=c.select("body").select("#MathJax_SVG_glyphs");if(a.select(".MathJax_SVG").empty()||!a.select("svg").node())f.log("There was an error in the tex syntax.",t),r();else{var n=a.select("svg").node().getBoundingClientRect();r(a.select(".MathJax_SVG"),e,n)}a.remove()})}function o(t){return(t||"").replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")}function s(t){for(var e=t.split(/(<[^<>]*>)/).map(function(t){var e=t.match(/<(\/?)([^ >]*)\s*(.*)>/i),r=e&&e[2].toLowerCase(),n=p[r];if(void 0!==n){var i=e[1],a=e[3],s=a.match(/^style\s*=\s*"([^"]+)"\s*/i);if("a"===r){if(i)return"
";if("href"!==a.substr(0,4).toLowerCase())return"";var l=a.substr(4).replace(/["']/g,"").replace(/=/,""),c=document.createElement("a");return c.href=l,g.indexOf(c.protocol)===-1?"":''}if("br"===r)return"
";if(i)return"sup"===r?'':"sub"===r?'':"";var f=""}return u.util.xml_entity_encode(t).replace(/");n>0;n=e.indexOf("
",n+1))r.push(n);var i=0;r.forEach(function(t){for(var r=t+i,n=e.slice(0,r),a="",o=n.length-1;o>=0;o--){var s=n[o].match(/<(\/?).*>/i);if(s&&"
"!==n[o]){s[1]||(a=n[o]);break}}a&&(e.splice(r+1,0,a),e.splice(r,0,""),i+=2)});var a=e.join(""),s=a.split(/
/gi);return s.length>1&&(e=s.map(function(t,e){return''+t+""})),e.join("")}function l(t,e,r){var n,i,a,o=r.horizontalAlign,s=r.verticalAlign||"top",l=t.node().getBoundingClientRect(),u=e.node().getBoundingClientRect();return i="bottom"===s?function(){return l.bottom-n.height}:"middle"===s?function(){return l.top+(l.height-n.height)/2}:function(){return l.top},a="right"===o?function(){return l.right-n.width}:"center"===o?function(){return l.left+(l.width-n.width)/2}:function(){return l.left},function(){return n=this.node().getBoundingClientRect(),this.style({top:i()-u.top+"px",left:a()-u.left+"px","z-index":1e3}),this}}var u=t("../plotly"),c=t("d3"),f=t("../lib"),h=t("../constants/xmlns_namespaces"),d=e.exports={};c.selection.prototype.appendSVG=function(t){for(var e=['',t,""].join(""),r=(new DOMParser).parseFromString(e,"application/xml"),n=r.documentElement.firstChild;n;)this.node().appendChild(this.node().ownerDocument.importNode(n,!0)),n=n.nextSibling;return r.querySelector("parsererror")?(f.log(r.querySelector("parsererror div").textContent),null):c.select(this.node().lastChild)},d.html_entity_decode=function(t){var e=c.select("body").append("div").style({display:"none"}).html(""),r=t.replace(/(&[^;]*;)/gi,function(t){return"<"===t?"<":"&rt;"===t?">":e.html(t).text()});return e.remove(),r},d.xml_entity_encode=function(t){return t.replace(/&(?!\w+;|\#[0-9]+;| \#x[0-9A-F]+;)/g,"&")},d.convertToTspans=function(t,e){function r(){ ++d.empty()||(p=l.attr("class")+"-math",d.select("svg."+p).remove()),t.text("").style({visibility:"visible","white-space":"pre"}),h=t.appendSVG(o),h||t.text(i),t.select("a").size()&&t.style("pointer-events","all"),e&&e.call(l)}var i=t.text(),o=s(i),l=t,f=!l.attr("data-notex")&&o.match(/([^$]*)([$]+[^$]*[$]+)([^$]*)/),h=i,d=c.select(l.node().parentNode);if(!d.empty()){var p=l.attr("class")?l.attr("class").split(" ")[0]:"text";p+="-math",d.selectAll("svg."+p).remove(),d.selectAll("g."+p+"-group").remove(),t.style({visibility:null});for(var g=t.node();g&&g.removeAttribute;g=g.parentNode)g.removeAttribute("data-bb");if(f){var v=u.Lib.getPlotDiv(l.node());(v&&v._promises||[]).push(new Promise(function(t){l.style({visibility:"hidden"});var i={fontSize:parseInt(l.style("font-size"),10)};a(f[2],i,function(i,a,o){d.selectAll("svg."+p).remove(),d.selectAll("g."+p+"-group").remove();var s=i&&i.select("svg");if(!s||!s.node())return r(),void t();var u=d.append("g").classed(p+"-group",!0).attr({"pointer-events":"none"});u.node().appendChild(s.node()),a&&a.node()&&s.node().insertBefore(a.node().cloneNode(!0),s.node().firstChild),s.attr({class:p,height:o.height,preserveAspectRatio:"xMinYMin meet"}).style({overflow:"visible","pointer-events":"none"});var c=l.style("fill")||"black";s.select("g").attr({fill:c,stroke:c});var f=n(s,"width"),h=n(s,"height"),g=+l.attr("x")-f*{start:0,middle:.5,end:1}[l.attr("text-anchor")||"start"],v=parseInt(l.style("font-size"),10)||n(l,"height"),m=-v/4;"y"===p[0]?(u.attr({transform:"rotate("+[-90,+l.attr("x"),+l.attr("y")]+") translate("+[-f/2,m-h/2]+")"}),s.attr({x:+l.attr("x"),y:+l.attr("y")})):"l"===p[0]?s.attr({x:l.attr("x"),y:m-h/2}):"a"===p[0]?s.attr({x:0,y:m}):s.attr({x:g,y:+l.attr("y")+m-h/2}),e&&e.call(l,u),t(u)})}))}else r();return t}};var p={sup:'font-size:70%" dy="-0.6em',sub:'font-size:70%" dy="0.3em',b:"font-weight:bold",i:"font-style:italic",a:"",span:"",br:"",em:"font-style:italic;font-weight:bold"},g=["http:","https:","mailto:"],v=new RegExp("]*)?/?>","g");d.plainText=function(t){return(t||"").replace(v," ")},d.makeEditable=function(t,e,r){function n(){a(),o.style({opacity:0});var t,e=h.attr("class");t=e?"."+e.split(" ")[0]+"-math-group":"[class*=-math-group]",t&&c.select(o.node().parentNode).select(t).style({opacity:0})}function i(t){var e=t.node(),r=document.createRange();r.selectNodeContents(e);var n=window.getSelection();n.removeAllRanges(),n.addRange(r),e.focus()}function a(){var t=c.select(u.Lib.getPlotDiv(o.node())),e=t.select(".svg-container"),n=e.append("div");n.classed("plugin-editable editable",!0).style({position:"absolute","font-family":o.style("font-family")||"Arial","font-size":o.style("font-size")||12,color:r.fill||o.style("fill")||"black",opacity:1,"background-color":r.background||"transparent",outline:"#ffffff33 1px solid",margin:[-parseFloat(o.style("font-size"))/8+1,0,0,-1].join("px ")+"px",padding:"0","box-sizing":"border-box"}).attr({contenteditable:!0}).text(r.text||o.attr("data-unformatted")).call(l(o,e,r)).on("blur",function(){o.text(this.textContent).style({opacity:1});var t,e=c.select(this).attr("class");t=e?"."+e.split(" ")[0]+"-math-group":"[class*=-math-group]",t&&c.select(o.node().parentNode).select(t).style({opacity:0});var r=this.textContent;c.select(this).transition().duration(0).remove(),c.select(document).on("mouseup",null),s.edit.call(o,r)}).on("focus",function(){var t=this;c.select(document).on("mouseup",function(){return c.event.target!==t&&void(document.activeElement===n.node()&&n.node().blur())})}).on("keyup",function(){27===c.event.which?(o.style({opacity:1}),c.select(this).style({opacity:0}).on("blur",function(){return!1}).transition().remove(),s.cancel.call(o,this.textContent)):(s.input.call(o,this.textContent),c.select(this).call(l(o,e,r)))}).on("keydown",function(){13===c.event.which&&this.blur()}).call(i)}r||(r={});var o=this,s=c.dispatch("edit","input","cancel"),f=c.select(this.node()).style({"pointer-events":"all"}),h=e||f;return e&&f.style({"pointer-events":"none"}),r.immediate?n():h.on("click",n),c.rebind(this,s,"on")}},{"../constants/xmlns_namespaces":247,"../lib":256,"../plotly":276,d3:54}],270:[function(t,e,r){"use strict";function n(t){var e;if("string"==typeof t){if(e=document.getElementById(t),null===e)throw new Error("No DOM element with id '"+t+"' exists on the page.");return e}if(null===t||void 0===t)throw new Error("DOM element provided is null or undefined");return t}function i(t){Array.isArray(t._promises)&&t._promises.length>0&&O.log("Clearing previous rejected promises from queue."),t._promises=[]}function a(t,e){t._fullLayout._paperdiv.style("background","white"),P.defaultConfig.setBackground(t,e)}function o(t,e){t._context||(t._context=O.extendFlat({},P.defaultConfig));var r=t._context;e&&(Object.keys(e).forEach(function(t){t in r&&("setBackground"===t&&"opaque"===e[t]?r[t]=a:r[t]=e[t])}),e.plot3dPixelRatio&&!r.plotGlPixelRatio&&(r.plotGlPixelRatio=r.plot3dPixelRatio)),r.staticPlot&&(r.editable=!1,r.autosizable=!1,r.scrollZoom=!1,r.doubleClick=!1,r.showTips=!1,r.showLink=!1,r.displayModeBar=!1)}function s(t,e,r){var n=C.select(t).selectAll(".plot-container").data([0]);n.enter().insert("div",":first-child").classed("plot-container plotly",!0);var i=n.selectAll(".svg-container").data([0]);i.enter().append("div").classed("svg-container",!0).style("position","relative"),i.html(""),e&&(t.data=e),r&&(t.layout=r),P.micropolar.manager.fillLayout(t),"initial"===t._fullLayout.autosize&&t._context.autosizable&&(A(t,{}),t._fullLayout.autosize=r.autosize=!0),i.style({width:t._fullLayout.width+"px",height:t._fullLayout.height+"px"}),t.framework=P.micropolar.manager.framework(t),t.framework({data:t.data,layout:t.layout},i.node()),t.framework.setUndoPoint();var a=t.framework.svg(),o=1,s=t._fullLayout.title;""!==s&&s||(o=0);var l="Click to enter title",u=function(){this.call(P.util.convertToTspans)},c=a.select(".title-group text").call(u);if(t._context.editable){c.attr({"data-unformatted":s}),s&&s!==l||(o=.2,c.attr({"data-unformatted":l}).text(l).style({opacity:o}).on("mouseover.opacity",function(){C.select(this).transition().duration(100).style("opacity",1)}).on("mouseout.opacity",function(){C.select(this).transition().duration(1e3).style("opacity",0)}));var f=function(){this.call(P.util.makeEditable).on("edit",function(e){t.framework({layout:{title:e}}),this.attr({"data-unformatted":e}).text(e).call(u),this.call(f)}).on("cancel",function(){var t=this.attr("data-unformatted");this.text(t).call(u)})};c.call(f)}return t._context.setBackground(t,t._fullLayout.paper_bgcolor),D.addLinks(t),Promise.resolve()}function l(t){var e,r;t||(t={}),t.xaxis1&&(t.xaxis||(t.xaxis=t.xaxis1),delete t.xaxis1),t.yaxis1&&(t.yaxis||(t.yaxis=t.yaxis1),delete t.yaxis1);var n=P.Axes.list({_fullLayout:t});for(e=0;e3?(c.x=1.02,c.xanchor="left"):c.x<-2&&(c.x=-.02,c.xanchor="right"),c.y>3?(c.y=1.02,c.yanchor="bottom"):c.y<-2&&(c.y=-.02,c.yanchor="top")),"rotate"===t.dragmode&&(t.dragmode="orbit"),t.scene1&&(t.scene||(t.scene=t.scene1),delete t.scene1);var f=D.getSubplotIds(t,"gl3d");for(e=0;e=t.data.length||i<-t.data.length)throw new Error(r+" must be valid indices for gd.data.");if(e.indexOf(i,n+1)>-1||i>=0&&e.indexOf(-t.data.length+i)>-1||i<0&&e.indexOf(t.data.length+i)>-1)throw new Error("each index in "+r+" must be unique.")}}function v(t,e,r){if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("currentIndices is a required argument.");if(Array.isArray(e)||(e=[e]),g(t,e,"currentIndices"),"undefined"==typeof r||Array.isArray(r)||(r=[r]),"undefined"!=typeof r&&g(t,r,"newIndices"),"undefined"!=typeof r&&e.length!==r.length)throw new Error("current and new indices must be of equal length.")}function m(t,e,r){var n,i;if(!Array.isArray(t.data))throw new Error("gd.data must be an array.");if("undefined"==typeof e)throw new Error("traces must be defined.");for(Array.isArray(e)||(e=[e]),n=0;n=0&&l0){var s=w(t._boundingBoxMargins),l=s.left+s.right,u=s.bottom+s.top,c=a._container.node().getBoundingClientRect(),f=1-2*o.frameMargins;i=Math.round(f*(c.width-l)),n=Math.round(f*(c.height-u))}else r=window.getComputedStyle(t),n=parseFloat(r.height)||a.height,i=parseFloat(r.width)||a.width;return Math.abs(a.width-i)>1||Math.abs(a.height-n)>1?(a.height=t.layout.height=n,a.width=t.layout.width=i):"initial"!==a.autosize&&(delete e.autosize,a.autosize=t.layout.autosize=!0),D.sanitizeMargins(a),e}function k(t){var e=C.select(t),r=t._fullLayout;if(r._container=e.selectAll(".plot-container").data([0]),r._container.enter().insert("div",":first-child").classed("plot-container",!0).classed("plotly",!0),r._paperdiv=r._container.selectAll(".svg-container").data([0]),r._paperdiv.enter().append("div").classed("svg-container",!0).style("position","relative"),"initial"===r.autosize&&(A(t,{}),r.autosize=!0,t.layout.autosize=!0),r._glcontainer=r._paperdiv.selectAll(".gl-container").data([0]),r._glcontainer.enter().append("div").classed("gl-container",!0),r._geocontainer=r._paperdiv.selectAll(".geo-container").data([0]),r._geocontainer.enter().append("div").classed("geo-container",!0),r._paperdiv.selectAll(".main-svg").remove(),r._paper=r._paperdiv.insert("svg",":first-child").classed("main-svg",!0),r._toppaper=r._paperdiv.append("svg").classed("main-svg",!0),!r._uid){var n=[];C.selectAll("defs").each(function(){this.id&&n.push(this.id.split("-")[1])}),r._uid=O.randstr(n)}r._paperdiv.selectAll(".main-svg").attr(Q.svgAttrs),r._defs=r._paper.append("defs").attr("id","defs-"+r._uid),r._topdefs=r._toppaper.append("defs").attr("id","topdefs-"+r._uid),r._draggers=r._paper.append("g").classed("draglayer",!0);var i=r._paper.append("g").classed("layer-below",!0);r._imageLowerLayer=i.append("g").classed("imagelayer",!0),r._shapeLowerLayer=i.append("g").classed("shapelayer",!0);var a=P.Axes.getSubplots(t);a.join("")!==Object.keys(t._fullLayout._plots||{}).join("")&&M(t,a),r._has("cartesian")&&E(t,a),r._ternarylayer=r._paper.append("g").classed("ternarylayer",!0);var o=r._paper.selectAll(".layer-subplot");r._imageSubplotLayer=o.selectAll(".imagelayer"),r._shapeSubplotLayer=o.selectAll(".shapelayer");var s=r._paper.append("g").classed("layer-above",!0);r._imageUpperLayer=s.append("g").classed("imagelayer",!0),r._shapeUpperLayer=s.append("g").classed("shapelayer",!0),r._pielayer=r._paper.append("g").classed("pielayer",!0),r._glimages=r._paper.append("g").classed("glimages",!0),r._geoimages=r._paper.append("g").classed("geoimages",!0),r._infolayer=r._toppaper.append("g").classed("infolayer",!0),r._zoomlayer=r._toppaper.append("g").classed("zoomlayer",!0),r._hoverlayer=r._toppaper.append("g").classed("hoverlayer",!0),t.emit("plotly_framework");var l=O.syncOrAsync([T,function(){return P.Axes.doTicks(t,"redraw")},F.init],t);return l&&l.then&&t._promises.push(l),l}function M(t,e){function r(e,r){return function(){return P.Axes.getFromId(t,e,r)}}for(var n,i,a=t._fullLayout._plots={},o=0;o0,_=P.Axes.getSubplots(t).join(""),w=Object.keys(t._fullLayout._plots||{}).join(""),A=w===_;x?t.framework===k&&!b&&A||(t.framework=k,k(t)):A?b&&k(t):(t.framework=k,k(t)),b&&P.Axes.saveRangeInitial(t);var M=t._fullLayout,E=!t.calcdata||t.calcdata.length!==(t.data||[]).length;E&&d(t);for(var L=0;LQ.range[0]?[1,2]:[2,1]);else{var $=Q.range[0],K=Q.range[1];"log"===B?($<=0&&K<=0&&o(X+".autorange",!0),$<=0?$=K/1e6:K<=0&&(K=$/1e6),o(X+".range[0]",Math.log($)/Math.LN10),o(X+".range[1]",Math.log(K)/Math.LN10)):(o(X+".range[0]",Math.pow(10,$)),o(X+".range[1]",Math.pow(10,K)))}else o(X+".autorange",!0)}if("reverse"===H)Y.range?Y.range.reverse():(o(X+".autorange",!0),Y.range=[1,0]),W.autorange?k=!0:w=!0;else if("annotations"===F.parts[0]||"shapes"===F.parts[0]){var J=F.parts[1],tt=F.parts[0],et=v[tt]||[],rt=P[O.titleCase(tt)],nt=et[J]||{};2===F.parts.length&&("add"===y[I]||O.isPlainObject(y[I])?C[I]="remove":"remove"===y[I]?J===-1?(C[tt]=et,delete C[I]):C[I]=nt:O.log("???",y)),!s(nt,"x")&&!s(nt,"y")||O.containsAny(I,["color","opacity","align","dash"])||(k=!0),rt.draw(e,J,F.parts.slice(2).join("."),y[I]),delete y[I]}else if("images"===F.parts[0]){var it=O.objectFromPath(I,B);O.extendDeepAll(e.layout,it),V.supplyLayoutDefaults(e.layout,e._fullLayout),V.draw(e)}else if("mapbox"===F.parts[0]&&"layers"===F.parts[1]){O.extendDeepAll(e.layout,O.objectFromPath(I,B));var at=(e._fullLayout.mapbox||{}).layers||[];for(N=F.parts[2]+1-at.length,g=0;g1&&O.containsAny(F.parts[1],["tick","exponent","grid","zeroline"])?x=!0:I.indexOf(".linewidth")!==-1&&I.indexOf("axis")!==-1?x=_=!0:F.parts.length>1&&F.parts[1].indexOf("line")!==-1?_=!0:F.parts.length>1&&"mirror"===F.parts[1]?x=_=!0:"margin.pad"===I?x=_=!0:"margin"===F.parts[0]||"autorange"===F.parts[1]||"rangemode"===F.parts[1]||"type"===F.parts[1]||"domain"===F.parts[1]||I.match(/^(bar|box|font)/)?k=!0:["hovermode","dragmode"].indexOf(I)!==-1?M=!0:["hovermode","dragmode","height","width","autosize"].indexOf(I)===-1&&(w=!0):w=!0,F.set(B)}z.add(e,t,[e,C],t,[e,L]),y.autosize&&(y=A(e,y)),(y.height||y.width||y.autosize)&&(k=!0);var st=Object.keys(y),lt=[D.previousPromises];if(w||k)lt.push(function(){return e.layout=void 0,k&&(e.calcdata=void 0),P.plot(e,"",v)});else if(st.length&&(D.supplyDefaults(e),m=e._fullLayout,b&<.push(function(){return q.draw(e),D.previousPromises(e)}),_&<.push(T),x&<.push(function(){return P.Axes.doTicks(e,"redraw"),S(e),D.previousPromises(e)}),M)){var ut;for(Z(e),P.Fx.supplyLayoutDefaults(e.layout,m,e._fullData),P.Fx.init(e),ut=D.getSubplotIds(m,"gl3d"),g=0;g1)};u(r.width)&&u(r.height)||s(new Error("Height and width should be pixel values."));var c=n.clone(e,{format:"png",height:r.height,width:r.width}),f=c.td;f.style.position="absolute",f.style.left="-5000px",document.body.appendChild(f);var h=n.getRedrawFunc(f);a.plot(f,c.data,c.layout,c.config).then(h).then(l).then(function(e){t(e)}).catch(function(t){s(t)})});return s}var i=t("fast-isnumeric"),a=t("../plotly"),o=t("../lib");e.exports=n},{"../lib":256,"../plotly":276,"../snapshot":312,"fast-isnumeric":60}],275:[function(t,e,r){"use strict";function n(t,e,r,i,a,u){u=u||[];for(var c=Object.keys(t),h=0;h1&&l.push(o("object","layout"))),h.supplyDefaults(u);for(var c=u._fullData,v=r.length,m=0;mu&&e=864e5?t._tickround="d":r>=36e5?t._tickround="H":r>=6e4?t._tickround="M":r>=1e3?t._tickround="S":t._tickround=3-Math.round(Math.log(r/2)/Math.LN10);else{b(r)||(r=Number(r.substr(1))),t._tickround=2-Math.floor(Math.log(r)/Math.LN10+.01),e="log"===t.type?Math.pow(10,Math.max(t.range[0],t.range[1])):Math.max(Math.abs(t.range[0]),Math.abs(t.range[1]));var n=Math.floor(Math.log(e)/Math.LN10+.01);Math.abs(n)>3&&("SI"===t.exponentformat||"B"===t.exponentformat?t._tickexponent=3*Math.round((n-1)/3):t._tickexponent=n)}else"M"===r.charAt(0)?t._tickround=2===r.length?"m":"y":t._tickround=null}function o(t,e){var r=t.match(U),n=new Date(e);if(r){var i=Math.min(+r[1]||6,6),a=String(e/1e3%1+2.0000005).substr(2,i).replace(/0+$/,"")||"0";return y.time.format(t.replace(U,a))(n)}return y.time.format(t)(n)}function s(t,e,r){var n=t.tickfont||t._gd._fullLayout.font;return{x:e,dx:0,dy:0,text:r||"",fontSize:n.size,font:n.family,fontColor:n.color}}function l(t,e,r,n){var i,a=e.x,s=t._tickround,l=new Date(a),u="";r&&t.hoverformat?i=o(t.hoverformat,a):t.tickformat?i=o(t.tickformat,a):(n&&(b(s)?s+=2:s={y:"m",m:"d",d:"H",H:"M",M:"S",S:2}[s]),"y"===s?i=N(l):"m"===s?i=z(l):(a!==t._tmin||r||(u="
"+N(l)),"d"===s?i=D(l):"H"===s?i=F(l):(a!==t._tmin||r||(u="
"+D(l)+", "+N(l)),i=B(l),"M"!==s&&(i+=j(l),"S"!==s&&(i+=h(m(a/1e3,1),t,"none",r).substr(1)))))),e.text=i+u}function u(t,e,r,n,i){var a=t.dtick,o=e.x;if(!n||"string"==typeof a&&"L"===a.charAt(0)||(a="L3"),t.tickformat||"string"==typeof a&&"L"===a.charAt(0))e.text=h(Math.pow(10,o),t,i,n);else if(b(a)||"D"===a.charAt(0)&&m(o+.01,1)<.1)if(["e","E","power"].indexOf(t.exponentformat)!==-1){var s=Math.round(o);0===s?e.text=1:1===s?e.text="10":s>1?e.text="10"+s+"":e.text="10\u2212"+-s+"",e.fontSize*=1.25}else e.text=h(Math.pow(10,o),t,"","fakehover"),"D1"===a&&"y"===t._id.charAt(0)&&(e.dy-=e.fontSize/6);else{if("D"!==a.charAt(0))throw"unrecognized dtick "+String(a);e.text=String(Math.round(Math.pow(10,m(o,1)))),e.fontSize*=.75}if("D1"===t.dtick){var l=String(e.text).charAt(0);"0"!==l&&"1"!==l||("y"===t._id.charAt(0)?e.dx-=e.fontSize/4:(e.dy+=e.fontSize/2,e.dx+=(t.range[1]>t.range[0]?1:-1)*e.fontSize*(o<0?.5:.25)))}}function c(t,e){var r=t._categories[Math.round(e.x)];void 0===r&&(r=""),e.text=String(r)}function f(t,e,r,n,i){"all"===t.showexponent&&Math.abs(e.x/t.dtick)<1e-6&&(i="hide"),e.text=h(e.x,t,i,n)}function h(t,e,r,n){var i=t<0,o=e._tickround,s=r||e.exponentformat||"B",l=e._tickexponent,u=e.tickformat;if(n){var c={exponentformat:e.exponentformat,dtick:"none"===e.showexponent?e.dtick:b(t)?Math.abs(t)||1:1,range:"none"===e.showexponent?e.range:[0,t||1]};a(c),o=(Number(c._tickround)||0)+4,l=c._tickexponent,e.hoverformat&&(u=e.hoverformat)}if(u)return y.format(u)(t).replace(/-/g,"\u2212");var f=Math.pow(10,-o)/2;if("none"===s&&(l=0),t=Math.abs(t),t12||l<-15)?t+="e"+p:"E"===s?t+="E"+p:"power"===s?t+="\xd710"+p+"":"B"===s&&9===l?t+="B":"SI"!==s&&"B"!==s||(t+=V[l/3+5])}return i?"\u2212"+t:t}function d(t,e){var r,n,i=[];for(r=0;r1)for(n=1;n2e-6||((r-t._forceTick0)/t._minDtick%1+1.000001)%1>2e-6)&&(t._minDtick=0)):t._minDtick=0},E.getAutoRange=function(t){var e,r=[],n=t._min[0].val,i=t._max[0].val;for(e=1;e0&&c>0&&f/c>h&&(l=o,u=s,h=f/c);if(n===i){var p=n-1,g=n+1;r="tozero"===t.rangemode?n<0?[p,0]:[0,g]:"nonnegative"===t.rangemode?[Math.max(0,p),Math.max(0,g)]:[p,g]}else h&&("linear"!==t.type&&"-"!==t.type||("tozero"===t.rangemode?(l.val>=0&&(l={val:0,pad:0}),u.val<=0&&(u={val:0,pad:0})):"nonnegative"===t.rangemode&&(l.val-h*l.pad<0&&(l={val:0,pad:0}),u.val<0&&(u={val:1,pad:0})),h=(u.val-l.val)/(t._length-l.pad-u.pad)),r=[l.val-h*l.pad,u.val+h*u.pad]);return r[0]===r[1]&&("tozero"===t.rangemode?r=r[0]<0?[r[0],0]:r[0]>0?[0,r[0]]:[0,1]:(r=[r[0]-1,r[0]+1],"nonnegative"===t.rangemode&&(r[0]=Math.max(0,r[0])))),d&&r.reverse(),r},E.doAutoRange=function(t){t._length||t.setScale();var e=t._min&&t._max&&t._min.length&&t._max.length;if(t.autorange&&e){t.range=E.getAutoRange(t);var r=t._gd.layout[t._name];r||(t._gd.layout[t._name]=r={}),r!==t&&(r.range=t.range.slice(),r.autorange=t.autorange)}},E.saveRangeInitial=function(t,e){for(var r=E.list(t,"",!0),n=!1,i=0;i=h?d=!1:s.val>=u&&s.pad<=h&&(t._min.splice(o,1),o--);d&&t._min.push({val:u,pad:y&&0===u?0:h})}if(n(c)){for(d=!0,o=0;o=c&&s.pad>=f?d=!1:s.val<=c&&s.pad<=f&&(t._max.splice(o,1),o--);d&&t._max.push({val:c,pad:y&&0===c?0:f})}}}if((t.autorange||t._needsExpand)&&e){t._min||(t._min=[]),t._max||(t._max=[]),r||(r={}),t._m||t.setScale();var a,o,s,l,u,c,f,h,d,p,g,v=e.length,m=r.padded?.05*t._length:0,y=r.tozero&&("linear"===t.type||"-"===t.type),x=n((t._m>0?r.ppadplus:r.ppadminus)||r.ppad||0),_=n((t._m>0?r.ppadminus:r.ppadplus)||r.ppad||0),w=n(r.vpadplus||r.vpad),A=n(r.vpadminus||r.vpad);for(a=0;a<6;a++)i(a);for(a=v-1;a>5;a--)i(a)}},E.autoBin=function(t,e,r,n){function i(t){return(1+100*(t-d)/f.dtick)%100<2}var a=_.aggNums(Math.min,null,t),o=_.aggNums(Math.max,null,t);if("category"===e.type)return{start:a-.5,end:o+.5,size:1};var s;if(r)s=(o-a)/r;else{var l=_.distinctVals(t),u=Math.pow(10,Math.floor(Math.log(l.minDiff)/Math.LN10)),c=u*_.roundUp(l.minDiff/u,[.9,1.9,4.9,9.9],!0);s=Math.max(c,2*_.stdev(t)/Math.pow(t.length,n?.25:.4))}var f={type:"log"===e.type?"linear":e.type,range:[a,o]};E.autoTicks(f,s);var h,d=E.tickIncrement(E.tickFirst(f),f.dtick,"reverse");if("number"==typeof f.dtick){for(var p=0,g=0,v=0,m=0,y=0;y.3*x||i(a)||i(o))){var w=f.dtick/2;d+=d+w0&&t.dtick<2*t._minDtick&&(t.dtick=t._minDtick,t.tick0=t._forceTick0)}t.tick0||(t.tick0="date"===t.type?new Date(2e3,0,1).getTime():0),a(t),t._tmin=E.tickFirst(t);var i=t.range[1]=s:l<=s)&&(o.push(l),!(o.length>1e3));l=E.tickIncrement(l,t.dtick,i));t._tmax=o[o.length-1];for(var u=new Array(o.length),c=0;c157788e5?(e/=315576e5,r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick="M"+12*i(e,r,S)):e>12096e5?(e/=26298e5,t.dtick="M"+i(e,1,C)):e>432e5?(t.dtick=i(e,864e5,I),t.tick0=new Date(2e3,0,2).getTime()):e>18e5?t.dtick=i(e,36e5,C):e>3e4?t.dtick=i(e,6e4,R):e>500?t.dtick=i(e,1e3,R):(r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick=i(e,r,S));else if("log"===t.type)if(t.tick0=0,e>.7)t.dtick=Math.ceil(e);else if(Math.abs(t.range[1]-t.range[0])<1){var n=1.5*Math.abs((t.range[1]-t.range[0])/e);e=Math.abs(Math.pow(10,t.range[1])-Math.pow(10,t.range[0]))/n,r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick="L"+i(e,r,S)}else t.dtick=e>.3?"D2":"D1";else"category"===t.type?(t.tick0=0,t.dtick=Math.ceil(Math.max(e,1))):(t.tick0=0,r=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),t.dtick=i(e,r,S));if(0===t.dtick&&(t.dtick=1),!b(t.dtick)&&"string"!=typeof t.dtick){var a=t.dtick;throw t.dtick=1,"ax.dtick error: "+String(a)}},E.tickIncrement=function(t,e,r){var n=r?-1:1;if(b(e))return t+n*e;var i=e.charAt(0),a=n*Number(e.substr(1));if("M"===i){var o=new Date(t);return o.setMonth(o.getMonth()+a)}if("L"===i)return Math.log(Math.pow(10,t)+a)/Math.LN10;if("D"===i){var s="D2"===e?O:P,l=t+.01*n,u=_.roundUp(m(l,1),s,r);return Math.floor(l)+Math.log(y.round(Math.pow(10,u),1))/Math.LN10}throw"unrecognized dtick "+String(e)},E.tickFirst=function(t){var e=t.range[1]n:u1&&e2*n}function c(t){for(var e,r=Math.max(1,(t.length-1)/1e3),n=0,i=0,a=0;a2*n}var f=t("fast-isnumeric"),h=t("tinycolor2").mix,d=t("../../lib"),p=t("../plots"),g=t("../../components/color/attributes").lightFraction,v=t("./layout_attributes"),m=t("./tick_value_defaults"),y=t("./tick_mark_defaults"),b=t("./tick_label_defaults"),x=t("./category_order_defaults"),_=t("./set_convert"),w=t("./ordered_categories"),A=t("./clean_datum"),k=t("./axis_ids");e.exports=function(t,e,r,i){function a(r,n){return d.coerce2(t,e,v,r,n)}var o=i.letter,s=i.font||{},l="Click to enter "+(i.title||o.toUpperCase()+" axis")+" title";i.name&&(e._name=i.name,e._id=k.name2id(i.name));var u=r("type");"-"===u&&(n(e,i.data),"-"===e.type?e.type="linear":u=t.type=e.type),_(e);var c=r("color"),p=c===t.color?c:s.color;r("title",l),d.coerceFont(r,"titlefont",{family:s.family,size:Math.round(1.2*s.size),color:p});var A=2===(t.range||[]).length&&f(t.range[0])&&f(t.range[1]),M=r("autorange",!A);M&&r("rangemode");var E=r("range",[-1,"x"===o?6:4]);E[0]===E[1]&&(e.range=[E[0]-1,E[0]+1]),d.noneOrAll(t.range,e.range,[0,1]),r("fixedrange"),m(t,e,r,u),b(t,e,r,u,i),y(t,e,r,i),x(t,e,r);var T=a("linecolor",c),L=a("linewidth"),S=r("showline",!!T||!!L);S||(delete e.linecolor,delete e.linewidth),(S||e.ticks)&&r("mirror");var C=a("gridcolor",h(c,i.bgColor,g).toRgbString()),R=a("gridwidth"),I=r("showgrid",i.showGrid||!!C||!!R);I||(delete e.gridcolor,delete e.gridwidth);var P=a("zerolinecolor",c),O=a("zerolinewidth"),N=r("zeroline",i.showGrid||!!P||!!O);return N||(delete e.zerolinecolor,delete e.zerolinewidth),e._initialCategories="category"===u?w(o,e.categoryorder,e.categoryarray,i.data):[],e}},{"../../components/color/attributes":175,"../../lib":256,"../plots":303,"./axis_ids":281,"./category_order_defaults":282,"./clean_datum":283,"./layout_attributes":288,"./ordered_categories":290,"./set_convert":293,"./tick_label_defaults":294,"./tick_mark_defaults":295,"./tick_value_defaults":296,"fast-isnumeric":60,tinycolor2:157}],281:[function(t,e,r){"use strict";function n(t,e,r){function n(t,r){for(var n=Object.keys(t),i=/^[xyz]axis[0-9]*/,a=[],o=0;o0;a&&(n="array");var o=r("categoryorder",n);"array"===o&&r("categoryarray"),a||"array"!==o||(e.categoryorder="trace")}}},{}],283:[function(t,e,r){"use strict";var n=t("fast-isnumeric"),i=t("../../lib");e.exports=function(t){try{if("object"==typeof t&&null!==t&&t.getTime)return i.ms2DateTime(t);if("string"!=typeof t&&!n(t))return"";t=t.toString().replace(/['"%,$# ]/g,"")}catch(e){i.error(e,t)}return t}},{"../../lib":256,"fast-isnumeric":60}],284:[function(t,e,r){"use strict";e.exports={idRegex:{x:/^x([2-9]|[1-9][0-9]+)?$/,y:/^y([2-9]|[1-9][0-9]+)?$/},attrRegex:{x:/^xaxis([2-9]|[1-9][0-9]+)?$/,y:/^yaxis([2-9]|[1-9][0-9]+)?$/},BADNUM:void 0,xAxisMatch:/^xaxis[0-9]*$/,yAxisMatch:/^yaxis[0-9]*$/,AX_ID_PATTERN:/^[xyz][0-9]*$/,AX_NAME_PATTERN:/^[xyz]axis[0-9]*$/,DBLCLICKDELAY:300,MINDRAG:8,MINSELECT:12,MINZOOM:20,DRAGGERSIZE:20,MAXDIST:20,YANGLE:60,HOVERARROWSIZE:6,HOVERTEXTPAD:3,HOVERFONTSIZE:13,HOVERFONT:"Arial, sans-serif",HOVERMINTIME:50,BENDPX:1.5,REDRAWDELAY:50}},{}],285:[function(t,e,r){"use strict";function n(t,e){var r,n=t.range[e],i=Math.abs(n-t.range[1-e]);return"date"===t.type?c.ms2DateTime(n,i):"log"===t.type?(r=Math.ceil(Math.max(0,-Math.log(i)/Math.LN10))+3,s.format("."+r+"g")(Math.pow(10,n))):(r=Math.floor(Math.log(Math.abs(n))/Math.LN10)-Math.floor(Math.log(i)/Math.LN10)+4,s.format("."+String(r)+"g")(n))}function i(t,e){return t?"nsew"===t?"pan"===e?"move":"crosshair":t.toLowerCase()+"-resize":"pointer"}function a(t){s.select(t).selectAll(".zoombox,.js-zoombox-backdrop,.js-zoombox-menu,.zoombox-corners").remove()}function o(t){var e=["lasso","select"];return e.indexOf(t)!==-1}var s=t("d3"),l=t("tinycolor2"),u=t("../../plotly"),c=t("../../lib"),f=t("../../lib/svg_text_utils"),h=t("../../components/color"),d=t("../../components/drawing"),p=t("../../lib/setcursor"),g=t("../../components/dragelement"),v=t("./axes"),m=t("./select"),y=t("./constants"),b=!0;e.exports=function(t,e,r,s,x,_,w,A){function k(t,e){for(var r=0;r.2?"rgba(0,0,0,0)":"rgba(255,255,255,0)","stroke-width":0}).attr("transform","translate("+pt+", "+gt+")").attr("d",lt+"Z"),ht=dt.append("path").attr("class","zoombox-corners").style({fill:h.background,stroke:h.defaultLine,"stroke-width":1,opacity:0}).attr("transform","translate("+pt+", "+gt+")").attr("d","M0,0Z"),T();for(var a=0;a.2?"rgba(0,0,0,0.4)":"rgba(255,255,255,0.3)").duration(200),ht.transition().style("opacity",1).duration(200),ut=!0)}function S(t,e,r){var n,i,a;for(n=0;nzoom back out","long"),b=!1)))}function R(e,r){var i=1===(w+A).length;if(e)z();else if(2!==r||i){if(1===r&&i){var a=w?U[0]:j[0],o="s"===w||"w"===A?0:1,s=a._name+".range["+o+"]",l=n(a,o),c="left",h="middle";if(a.fixedrange)return;w?(h="n"===w?"top":"bottom","right"===a.side&&(c="right")):"e"===A&&(c="right"),et.call(f.makeEditable,null,{immediate:!0,background:F.paper_bgcolor,text:String(l),fill:a.tickfont?a.tickfont.color:"#444",horizontalAlign:c,verticalAlign:h}).on("edit",function(e){var r="category"===a.type?a.c2l(e):a.d2l(e);void 0!==r&&u.relayout(t,s,r)})}}else N()}function I(e){function r(t,e,r){if(!t.fixedrange){M(t.range);var n=t.range,i=n[0]+(n[1]-n[0])*e;t.range=[i+(n[0]-i)*r,i+(n[1]-i)*r]}}if(t._context.scrollZoom||F._enablescrollzoom){var n=t.querySelector(".plotly");if(!(n.scrollHeight-n.clientHeight>10||n.scrollWidth-n.clientWidth>10)){clearTimeout(mt);var i=-e.deltaY;if(isFinite(i)||(i=e.wheelDelta/10),!isFinite(i))return void c.log("Did not find wheel motion attributes: ",e);var a,o=Math.exp(-Math.min(Math.max(i,-20),20)/100),s=bt.draglayer.select(".nsewdrag").node().getBoundingClientRect(),l=(e.clientX-s.left)/s.width,u=vt[0]+vt[2]*l,f=(s.bottom-e.clientY)/s.height,h=vt[1]+vt[3]*(1-f);if(A){for(a=0;a=0?Math.min(t,.9):1/(1/Math.max(t,-.3)+3.222))}function i(t,e,r){for(var i=1-e,a=0,o=0;o0;n--)r.push(e);return r}function i(t,e){for(var r=[],n=0;nY.width||X<0||X>Y.height)return _.unhoverRaw(t,e)}else G="xpx"in e?e.xpx:k[0]._length/2,X="ypx"in e?e.ypx:M[0]._length/2;if(R="xval"in e?n(a,e.xval):i(k,G),I="yval"in e?n(a,e.yval):i(M,X),!g(R[0])||!g(I[0]))return v.warn("Plotly.Fx.hover failed",e,t),_.unhoverRaw(t,e)}var W=1/0;for(O=0;O1||z.hoverinfo.indexOf("name")!==-1?z.name:void 0,index:!1,distance:Math.min(W,A.MAXDIST),color:b.defaultLine,x0:void 0,x1:void 0,y0:void 0,y1:void 0,xLabelVal:void 0,yLabelVal:void 0,zLabelVal:void 0,text:void 0},V=q.length,"array"===F){var Z=e[O];"pointNumber"in Z?(U.index=Z.pointNumber,F="closest"):(F="","xval"in Z&&(B=Z.xval,F="x"),"yval"in Z&&(j=Z.yval,F=F?"closest":"y"))}else B=R[D],j=I[D];if(z._module&&z._module.hoverPoints){var Q=z._module.hoverPoints(U,B,j,F);if(Q)for(var $,K=0;KV&&(q.splice(0,V),W=q[0].distance)}if(0===q.length)return _.unhoverRaw(t,e);var J="y"===C&&H.length>1;q.sort(function(t,e){return t.distance-e.distance});var tt=b.combine(o.plot_bgcolor||b.background,o.paper_bgcolor),et={hovermode:C,rotateLabels:J,bgColor:tt,container:o._hoverlayer,outerContainer:o._paperdiv},rt=u(q,et);c(q,J?"xa":"ya"),f(rt,J);var nt=t._hoverdata,it=[];for(P=0;P128?"#000":b.background;if(t.name&&void 0===t.zLabelVal){var c=document.createElement("p");c.innerHTML=t.name,r=c.textContent||"",r.length>15&&(r=r.substr(0,12)+"...")}void 0!==t.extraText&&(n+=t.extraText),void 0!==t.zLabel?(void 0!==t.xLabel&&(n+="x: "+t.xLabel+"
"),void 0!==t.yLabel&&(n+="y: "+t.yLabel+"
"),n+=(n?"z: ":"")+t.zLabel):M&&t[i+"Label"]===g?n=t[("x"===i?"y":"x")+"Label"]||"":void 0===t.xLabel?void 0!==t.yLabel&&(n=t.yLabel):n=void 0===t.yLabel?t.xLabel:"("+t.xLabel+", "+t.yLabel+")",t.text&&!Array.isArray(t.text)&&(n+=(n?"
":"")+t.text),""===n&&(""===r&&e.remove(),n=r);var f=e.select("text.nums").style("fill",u).call(x.setPosition,0,0).text(n).attr("data-notex",1).call(y.convertToTspans);f.selectAll("tspan.line").call(x.setPosition,0,0);var h=e.select("text.name"),v=0;r&&r!==n?(h.style("fill",l).text(r).call(x.setPosition,0,0).attr("data-notex",1).call(y.convertToTspans),h.selectAll("tspan.line").call(x.setPosition,0,0),v=h.node().getBoundingClientRect().width+2*I):(h.remove(),e.select("rect").remove()),e.select("path").style({fill:l,stroke:u});var m,A,T=f.node().getBoundingClientRect(),L=t.xa._offset+(t.x0+t.x1)/2,S=t.ya._offset+(t.y0+t.y1)/2,C=Math.abs(t.x1-t.x0),P=Math.abs(t.y1-t.y0),O=T.width+R+I+v;t.ty0=_-T.top,t.bx=T.width+2*I,t.by=T.height+2*I,t.anchor="start",t.txwidth=T.width,t.tx2width=v,t.offset=0,a?(t.pos=L,m=S+P/2+O<=k,A=S-P/2-O>=0,"top"!==t.idealAlign&&m||!A?m?(S+=P/2,t.anchor="start"):t.anchor="middle":(S-=P/2,t.anchor="end")):(t.pos=S,m=L+C/2+O<=w,A=L-C/2-O>=0,"left"!==t.idealAlign&&m||!A?m?(L+=C/2,t.anchor="start"):t.anchor="middle":(L-=C/2,t.anchor="end")),f.attr("text-anchor",t.anchor),v&&h.attr("text-anchor",t.anchor),e.attr("transform","translate("+L+","+S+")"+(a?"rotate("+E+")":""))}),S}function c(t,e){function r(t){var e=t[0],r=t[t.length-1];if(i=e.pmin-e.pos-e.dp+e.size,a=r.pos+r.dp+r.size-e.pmax,i>.01){for(s=t.length-1;s>=0;s--)t[s].dp+=i;n=!1}if(!(a<.01)){if(i<-.01){for(s=t.length-1;s>=0;s--)t[s].dp-=a;n=!1}if(n){var u=0;for(o=0;oe.pmax&&u++;for(o=t.length-1;o>=0&&!(u<=0);o--)l=t[o],l.pos>e.pmax-1&&(l.del=!0,u--);for(o=0;o=0;s--)t[s].dp-=a;for(o=t.length-1;o>=0&&!(u<=0);o--)l=t[o],l.pos+l.dp+l.size>e.pmax&&(l.del=!0,u--)}}}for(var n,i,a,o,s,l,u,c=0,f=t.map(function(t,r){var n=t[e];return[{i:r,dp:0,pos:t.pos,posref:t.posref,size:t.by*("x"===n._id.charAt(0)?L:1)/2,pmin:n._offset,pmax:n._offset+n._length}]}).sort(function(t,e){return t[0].posref-e[0].posref});!n&&c<=t.length;){for(c++,n=!0,o=0;o.01&&p.pmin===g.pmin&&p.pmax===g.pmax){for(s=d.length-1;s>=0;s--)d[s].dp+=i;for(h.push.apply(h,d),f.splice(o+1,1),u=0,s=h.length-1;s>=0;s--)u+=h[s].dp;for(a=u/h.length,s=h.length-1;s>=0;s--)h[s].dp-=a;n=!1}else o++}f.forEach(r)}for(o=f.length-1;o>=0;o--){var v=f[o];for(s=v.length-1;s>=0;s--){var m=v[s],y=t[m.i];y.offset=m.dp,y.del=m.del}}}function f(t,e){t.each(function(t){var r=d.select(this);if(t.del)return void r.remove();var n="end"===t.anchor?-1:1,i=r.select("text.nums"),a={start:1,end:-1,middle:0}[t.anchor],o=a*(R+I),s=o+a*(t.txwidth+I),l=0,u=t.offset;"middle"===t.anchor&&(o-=t.tx2width/2,s-=t.tx2width/2),e&&(u*=-C,l=t.offset*S),r.select("path").attr("d","middle"===t.anchor?"M-"+t.bx/2+",-"+t.by/2+"h"+t.bx+"v"+t.by+"h-"+t.bx+"Z":"M0,0L"+(n*R+l)+","+(R+u)+"v"+(t.by/2-R)+"h"+n*t.bx+"v-"+t.by+"H"+(n*R+l)+"V"+(u-R)+"Z"),i.call(x.setPosition,o+l,u+t.ty0-t.by/2+I).selectAll("tspan.line").attr({x:i.attr("x"),y:i.attr("y")}),t.tx2width&&(r.select("text.name, text.name tspan.line").call(x.setPosition,s+a*I+l,u+t.ty0-t.by/2+I),r.select("rect").call(x.setRect,s+(a-1)*t.tx2width/2+l,u-t.by/2-1,t.tx2width,t.by+2))})}function h(t,e,r){if(!e.target)return!1;if(!r||r.length!==t._hoverdata.length)return!0;for(var n=r.length-1;n>=0;n--){var i=r[n],a=t._hoverdata[n];if(i.curveNumber!==a.curveNumber||String(i.pointNumber)!==String(a.pointNumber))return!0}return!1}var d=t("d3"),p=t("tinycolor2"),g=t("fast-isnumeric"),v=t("../../lib"),m=t("../../lib/events"),y=t("../../lib/svg_text_utils"),b=t("../../components/color"),x=t("../../components/drawing"),_=t("../../components/dragelement"),w=t("./axes"),A=t("./constants"),k=t("./dragbox"),M=e.exports={};M.unhover=_.unhover,M.layoutAttributes={dragmode:{valType:"enumerated",values:["zoom","pan","select","lasso","orbit","turntable"],dflt:"zoom"},hovermode:{valType:"enumerated",values:["x","y","closest",!1]}},M.supplyLayoutDefaults=function(t,e,r){function n(r,n){return v.coerce(t,e,M.layoutAttributes,r,n)}n("dragmode");var i;if(e._has("cartesian")){var a=e._isHoriz=M.isHoriz(r);i=a?"y":"x"}else i="closest";n("hovermode",i)},M.isHoriz=function(t){for(var e=!0,r=0;rt._lastHoverTime+A.HOVERMINTIME?(o(t,e,r),void(t._lastHoverTime=Date.now())):void(t._hoverTimer=setTimeout(function(){o(t,e,r),t._lastHoverTime=Date.now(),t._hoverTimer=void 0},A.HOVERMINTIME))},M.getDistanceFunction=function(t,e,r,n){return"closest"===t?n||a(e,r):"x"===t?e:r},M.getClosest=function(t,e,r){if(r.index!==!1)r.index>=0&&r.indexf[1]-.01&&(e.domain=[0,1]),i.noneOrAll(t.domain,e.domain,[0,1])}return e}},{"../../lib":256,"fast-isnumeric":60}],292:[function(t,e,r){"use strict";function n(t){return t._id}var i=t("../../lib/polygon"),a=t("../../components/color"),o=t("./axes"),s=t("./constants"),l=i.filter,u=i.tester,c=s.MINSELECT;e.exports=function(t,e,r,i,f){function h(t){var e="y"===t._id.charAt(0)?1:0;return function(r){return t.p2d(r[e])}}function d(t,e){return t-e}var p,g=i.gd._fullLayout._zoomlayer,v=i.element.getBoundingClientRect(),m=i.plotinfo.x()._offset,y=i.plotinfo.y()._offset,b=e-v.left,x=r-v.top,_=b,w=x,A="M"+b+","+x,k=i.xaxes[0]._length,M=i.yaxes[0]._length,E=i.xaxes.map(n),T=i.yaxes.map(n),L=i.xaxes.concat(i.yaxes);"lasso"===f&&(p=l([[b,x]],s.BENDPX));var S=g.selectAll("path.select-outline").data([1,2]);S.enter().append("path").attr("class",function(t){return"select-outline select-outline-"+t}).attr("transform","translate("+m+", "+y+")").attr("d",A+"Z");var C,R,I,P,O,N=g.append("path").attr("class","zoombox-corners").style({fill:a.background,stroke:a.defaultLine,"stroke-width":1}).attr("transform","translate("+m+", "+y+")").attr("d","M0,0Z"),z=[],D=i.gd,F=[];for(C=0;C0)return Math.log(e)/Math.LN10;if(e<=0&&r&&t.range&&2===t.range.length){var n=t.range[0],i=t.range[1];return.5*(n+i-3*c*Math.abs(n-i))}return o.BADNUM}function r(t){return Math.pow(10,t)}function u(t){return i(t)?Number(t):o.BADNUM}var c=10;if(t.c2l="log"===t.type?e:u,t.l2c="log"===t.type?r:u,t.l2d=function(e){return t.c2d(t.l2c(e))},t.p2d=function(e){return t.l2d(t.p2l(e))},t.setScale=function(){var e,r=t._gd._fullLayout._size;if(t._categories||(t._categories=[]),t.overlaying){var n=l.getFromId(t._gd,t.overlaying);t.domain=n.domain}for(t.range&&2===t.range.length&&t.range[0]!==t.range[1]||(t.range=[-1,1]),e=0;e<2;e++)i(t.range[e])||(t.range[e]=i(t.range[1-e])?t.range[1-e]*(e?10:.1):e?1:-1),t.range[e]<-(Number.MAX_VALUE/2)?t.range[e]=-(Number.MAX_VALUE/2):t.range[e]>Number.MAX_VALUE/2&&(t.range[e]=Number.MAX_VALUE/2);if("y"===t._id.charAt(0)?(t._offset=r.t+(1-t.domain[1])*r.h,t._length=r.h*(t.domain[1]-t.domain[0]),t._m=t._length/(t.range[0]-t.range[1]),t._b=-t._m*t.range[1]):(t._offset=r.l+t.domain[0]*r.w,t._length=r.w*(t.domain[1]-t.domain[0]),t._m=t._length/(t.range[1]-t.range[0]),t._b=-t._m*t.range[0]),!isFinite(t._m)||!isFinite(t._b))throw a.notifier("Something went wrong with axis scaling","long"),t._gd._replotting=!1,new Error("axis scaling")},t.l2p=function(e){return i(e)?n.round(t._b+t._m*e,2):o.BADNUM},t.p2l=function(e){return(e-t._b)/t._m},t.c2p=function(e,r){return t.l2p(t.c2l(e,r))},t.p2c=function(e){return t.l2c(t.p2l(e))},["linear","log","-"].indexOf(t.type)!==-1)t.c2d=u,t.d2c=function(t){return t=s(t),i(t)?Number(t):o.BADNUM},t.d2l=function(e,r){return"log"===t.type?t.c2l(t.d2c(e),r):t.d2c(e)};else if("date"===t.type){if(t.c2d=function(t){return i(t)?a.ms2DateTime(t):o.BADNUM},t.d2c=function(t){return i(t)?Number(t):a.dateTime2ms(t)},t.d2l=t.d2c,t.range&&t.range.length>1)try{var f=t.range.map(a.dateTime2ms);!i(t.range[0])&&i(f[0])&&(t.range[0]=f[0]),!i(t.range[1])&&i(f[1])&&(t.range[1]=f[1])}catch(e){a.error(e,t.range)}}else"category"===t.type&&(t.c2d=function(e){return t._categories[Math.round(e)]},t.d2c=function(e){null!==e&&void 0!==e&&t._categories.indexOf(e)===-1&&t._categories.push(e);var r=t._categories.indexOf(e);return r===-1?o.BADNUM:r},t.d2l=t.d2c);t.makeCalcdata=function(e,r){var n,i,a;if(r in e)for(n=e[r],i=new Array(n.length),a=0;aw[n+2]&&(w[n]=-1,w[n+2]=1),k=this[v[n]],k._length=y.viewBox[n+2]-y.viewBox[n],s.doAutoRange(k);y.ticks=this.computeTickMarks();var M=this.xaxis.range,E=this.yaxis.range;y.dataBox=[M[0],E[0],M[1],E[1]],y.merge(r),o.update(y),this.glplot.draw()},m.draw=function(){if(!this.stopped){requestAnimationFrame(this.redraw);var t=this.glplot,e=this.camera,r=e.mouseListener,n=this.fullLayout;this.cameraChanged();var i=r.x*t.pixelRatio,a=this.canvas.height-t.pixelRatio*r.y;if(e.boxEnabled&&"zoom"===n.dragmode)this.selectBox.enabled=!0,this.selectBox.selectBox=[Math.min(e.boxStart[0],e.boxEnd[0]),Math.min(e.boxStart[1],e.boxEnd[1]),Math.max(e.boxStart[0],e.boxEnd[0]),Math.max(e.boxStart[1],e.boxEnd[1])],t.setDirty();else{this.selectBox.enabled=!1;var o=n._size,s=this.xaxis.domain,u=this.yaxis.domain,c=t.pick(i/t.pixelRatio+o.l+s[0]*o.w,a/t.pixelRatio-(o.t+(1-u[1])*o.h));if(c&&n.hovermode){var f=c.object._trace.handlePick(c);if(f&&(!this.lastPickResult||this.lastPickResult.traceUid!==f.trace.uid||this.lastPickResult.dataCoord[0]!==f.dataCoord[0]||this.lastPickResult.dataCoord[1]!==f.dataCoord[1])){var h=f;this.lastPickResult={traceUid:f.trace?f.trace.uid:null,dataCoord:f.dataCoord.slice()},this.spikes.update({center:c.dataCoord}),h.screenCoord=[((t.viewBox[2]-t.viewBox[0])*(c.dataCoord[0]-t.dataBox[0])/(t.dataBox[2]-t.dataBox[0])+t.viewBox[0])/t.pixelRatio,(this.canvas.height-(t.viewBox[3]-t.viewBox[1])*(c.dataCoord[1]-t.dataBox[1])/(t.dataBox[3]-t.dataBox[1])-t.viewBox[1])/t.pixelRatio];var d=h.hoverinfo;if("all"!==d){var p=d.split("+");p.indexOf("x")===-1&&(h.traceCoord[0]=void 0),p.indexOf("y")===-1&&(h.traceCoord[1]=void 0),p.indexOf("z")===-1&&(h.traceCoord[2]=void 0),p.indexOf("text")===-1&&(h.textLabel=void 0),p.indexOf("name")===-1&&(h.name=void 0)}l.loneHover({x:h.screenCoord[0],y:h.screenCoord[1],xLabel:this.hoverFormatter("xaxis",h.traceCoord[0]),yLabel:this.hoverFormatter("yaxis",h.traceCoord[1]),zLabel:h.traceCoord[2],text:h.textLabel,name:h.name,color:h.color},{container:this.svgContainer})}}else!c&&this.lastPickResult&&(this.spikes.update({}),this.lastPickResult=null,l.loneUnhover(this.svgContainer))}t.draw()}},m.hoverFormatter=function(t,e){if(void 0!==e){var r=this[t];return s.tickText(r,r.c2l(e),"hover").text}}},{"../../lib/html2unicode":255,"../../lib/show_no_webgl_msg":266,"../../plots/cartesian/axes":279,"../../plots/cartesian/graph_interact":286,"./camera":298,"./convert":299,"gl-plot2d":85,"gl-select-box":94,"gl-spikes2d":103}],302:[function(t,e,r){"use strict";var n=t("../plotly"),i=t("./font_attributes"),a=t("../components/color/attributes"),o=n.Lib.extendFlat;e.exports={font:{family:o({},i.family,{dflt:'"Open Sans", verdana, arial, sans-serif'}),size:o({},i.size,{dflt:12}),color:o({},i.color,{dflt:a.defaultLine})},title:{valType:"string",dflt:"Click to enter Plot title"},titlefont:o({},i,{}),autosize:{valType:"enumerated",values:[!0,!1,"initial"]},width:{valType:"number",min:10,dflt:700},height:{valType:"number",min:10,dflt:450},margin:{l:{valType:"number",min:0,dflt:80},r:{valType:"number",min:0,dflt:80},t:{valType:"number",min:0,dflt:100},b:{valType:"number",min:0,dflt:80},pad:{valType:"number",min:0,dflt:0},autoexpand:{valType:"boolean",dflt:!0}},paper_bgcolor:{valType:"color",dflt:a.background},plot_bgcolor:{valType:"color",dflt:a.background},separators:{valType:"string",dflt:".,"},hidesources:{valType:"boolean",dflt:!1},smith:{valType:"enumerated",values:[!1],dflt:!1},showlegend:{valType:"boolean"},_composedModules:{"*":"Fx"},_nestedModules:{xaxis:"Axes",yaxis:"Axes",scene:"gl3d",geo:"geo",legend:"Legend",annotations:"Annotations",shapes:"Shapes",images:"Images",updatemenus:"UpdateMenus",ternary:"ternary",mapbox:"mapbox"}}},{"../components/color/attributes":175,"../plotly":276,"./font_attributes":297}],303:[function(t,e,r){"use strict";function n(t){return"object"==typeof t&&(t=t.type),t}function i(t,e){e.text("");var r=e.append("a").attr({"xlink:xlink:href":"#",class:"link--impt link--embedview","font-weight":"bold"}).text(t._context.linkText+" "+String.fromCharCode(187));if(t._context.sendData)r.on("click",function(){d.sendDataToCloud(t)});else{var n=window.location.pathname.split("/"),i=window.location.search;r.attr({"xlink:xlink:show":"new","xlink:xlink:href":"/"+n[2].split(".")[0]+"/"+n[1]+i})}}function a(t,e){for(var r=f.isPlainObject,n=Array.isArray,i=Object.keys(e),o=0;o=e.width-20?(a["text-anchor"]="start",a.x=5):(a["text-anchor"]="end",a.x=e._paper.attr("width")-7),r.attr(a);var o=r.select(".js-link-to-tool"),s=r.select(".js-link-spacer"),u=r.select(".js-sourcelinks");t._context.showSources&&t._context.showSources(t),t._context.showLink&&i(t,o),s.text(o.text()&&u.text()?" - ":"")},d.sendDataToCloud=function(t){t.emit("plotly_beforeexport");var e=window.PLOTLYENV&&window.PLOTLYENV.BASE_URL||"https://plot.ly",r=l.select(t).append("div").attr("id","hiddenform").style("display","none"),n=r.append("form").attr({action:e+"/external",method:"post",target:"_blank"}),i=n.append("input").attr({type:"text",name:"data"});return i.node().value=d.graphJson(t,!1,"keepdata"),n.node().submit(),r.remove(),t.emit("plotly_afterexport"),!1},d.supplyDefaults=function(t){var e,r=t._fullLayout||{},n=t._fullLayout={},i=t.layout||{},o=t._fullData||[],s=t._fullData=[],l=t.data||[];d.supplyLayoutGlobalDefaults(i,n),n._dataLength=l.length,d.supplyDataDefaults(l,s,n),n._has=d._hasPlotType.bind(n);var u=n._modules;for(e=0;e.5*n.width&&(r.l=r.r=0),r.b+r.t>.5*n.height&&(r.b=r.t=0),n._pushmargin[e]={l:{val:r.x,size:r.l+i},r:{val:r.x,size:r.r+i},b:{val:r.y,size:r.b+i},t:{val:r.y,size:r.t+i}}}else delete n._pushmargin[e];t._replotting||d.doAutoMargin(t)}},d.doAutoMargin=function(t){var e=t._fullLayout;e._size||(e._size={}),e._pushmargin||(e._pushmargin={});var r=e._size,n=JSON.stringify(r),i=Math.max(e.margin.l||0,0),a=Math.max(e.margin.r||0,0),o=Math.max(e.margin.t||0,0),s=Math.max(e.margin.b||0,0),l=e._pushmargin;if(e.margin.autoexpand!==!1&&(l.base={l:{val:0,size:i},r:{val:1,size:a},t:{val:1,size:o},b:{val:0,size:s}},Object.keys(l).forEach(function(t){var r=l[t].l||{},n=l[t].b||{},c=r.val,f=r.size,h=n.val,d=n.size;Object.keys(l).forEach(function(t){if(u(f)&&l[t].r){var r=l[t].r.val,n=l[t].r.size;if(r>c){var p=(f*r+(n-e.width)*c)/(r-c),g=(n*(1-c)+(f-e.width)*(1-r))/(r-c);p>=0&&g>=0&&p+g>i+a&&(i=p,a=g)}}if(u(d)&&l[t].t){var v=l[t].t.val,m=l[t].t.size;if(v>h){var y=(d*v+(m-e.height)*h)/(v-h),b=(m*(1-h)+(d-e.height)*(1-v))/(v-h);y>=0&&b>=0&&y+b>s+o&&(s=y,o=b)}}})})),r.l=Math.round(i),r.r=Math.round(a),r.t=Math.round(o),r.b=Math.round(s),r.p=Math.round(e.margin.pad),r.w=Math.round(e.width)-r.l-r.r,r.h=Math.round(e.height)-r.t-r.b,!t._replotting&&"{}"!==n&&n!==JSON.stringify(e._size))return c.plot(t)},d.graphJson=function(t,e,r,n,i){function a(t){if("function"==typeof t)return null;if(f.isPlainObject(t)){var e,n,i={};for(e in t)if("function"!=typeof t[e]&&["_","["].indexOf(e.charAt(0))===-1){if("keepdata"===r){if("src"===e.substr(e.length-3))continue}else if("keepstream"===r){if(n=t[e+"src"],"string"==typeof n&&n.indexOf(":")>0&&!f.isPlainObject(t.stream))continue}else if("keepall"!==r&&(n=t[e+"src"],"string"==typeof n&&n.indexOf(":")>0))continue;i[e]=a(t[e])}return i}return Array.isArray(t)?t.map(a):t&&t.getTime?f.ms2DateTime(t):t}(i&&e&&!t._fullData||i&&!e&&!t._fullLayout)&&d.supplyDefaults(t);var o=i?t._fullData:t.data,s=i?t._fullLayout:t.layout,l={data:(o||[]).map(function(t){var r=a(t);return e&&delete r.fit,r})};return e||(l.layout=a(s)),t.framework&&t.framework.isPolar&&(l=t.framework.getConfig()),"object"===n?l:JSON.stringify(l)}},{"../components/color":176,"../lib":256,"../plotly":276,"./attributes":277,"./font_attributes":297,"./layout_attributes":302,d3:54,"fast-isnumeric":60}],304:[function(t,e,r){"use strict";var n=t("../../traces/scatter/attributes"),i=n.marker;e.exports={r:n.r,t:n.t,marker:{color:i.color,size:i.size,symbol:i.symbol,opacity:i.opacity}}},{"../../traces/scatter/attributes":341}],305:[function(t,e,r){"use strict";function n(t,e){var r={showline:{valType:"boolean"},showticklabels:{valType:"boolean"},tickorientation:{valType:"enumerated",values:["horizontal","vertical"]},ticklen:{valType:"number",min:0},tickcolor:{valType:"color"},ticksuffix:{valType:"string"},endpadding:{valType:"number"},visible:{valType:"boolean"}};return a({},e,r)}var i=t("../cartesian/layout_attributes"),a=t("../../lib/extend").extendFlat,o=a({},i.domain,{});e.exports={radialaxis:n("radial",{range:{valType:"info_array",items:[{valType:"number"},{valType:"number"}]},domain:o,orientation:{valType:"number"}}),angularaxis:n("angular",{range:{valType:"info_array",items:[{valType:"number",dflt:0},{valType:"number",dflt:360}]},domain:o}),layout:{direction:{valType:"enumerated",values:["clockwise","counterclockwise"]},orientation:{valType:"angle"}}}},{"../../lib/extend":253,"../cartesian/layout_attributes":288}],306:[function(t,e,r){var n=t("../../plotly"),i=t("d3"),a=e.exports={version:"0.2.2",manager:t("./micropolar_manager")},o=n.Lib.extendDeepAll;a.Axis=function(){function t(t){r=t||r;var u=l.data,f=l.layout;return("string"==typeof r||r.nodeName)&&(r=i.select(r)),r.datum(u).each(function(t,r){function l(t,e){return s(t)%360+f.orientation}var u=t.slice();c={data:a.util.cloneJson(u),layout:a.util.cloneJson(f)};var h=0;u.forEach(function(t,e){t.color||(t.color=f.defaultColorRange[h],h=(h+1)%f.defaultColorRange.length),t.strokeColor||(t.strokeColor="LinePlot"===t.geometry?t.color:i.rgb(t.color).darker().toString()),c.data[e].color=t.color,c.data[e].strokeColor=t.strokeColor,c.data[e].strokeDash=t.strokeDash,c.data[e].strokeSize=t.strokeSize});var d=u.filter(function(t,e){var r=t.visible;return"undefined"==typeof r||r===!0}),p=!1,g=d.map(function(t,e){return p=p||"undefined"!=typeof t.groupId,t});if(p){var v=i.nest().key(function(t,e){return"undefined"!=typeof t.groupId?t.groupId:"unstacked"}).entries(g),m=[],y=v.map(function(t,e){if("unstacked"===t.key)return t.values;var r=t.values[0].r.map(function(t,e){return 0});return t.values.forEach(function(t,e,n){t.yStack=[r],m.push(r),r=a.util.sumArrays(t.r,r)}),t.values});d=i.merge(y)}d.forEach(function(t,e){t.t=Array.isArray(t.t[0])?t.t:[t.t],t.r=Array.isArray(t.r[0])?t.r:[t.r]});var b=Math.min(f.width-f.margin.left-f.margin.right,f.height-f.margin.top-f.margin.bottom)/2;b=Math.max(10,b);var x,_=[f.margin.left+b,f.margin.top+b];if(p){var w=i.max(a.util.sumArrays(a.util.arrayLast(d).r[0],a.util.arrayLast(m)));x=[0,w]}else x=i.extent(a.util.flattenArray(d.map(function(t,e){return t.r})));f.radialAxis.domain!=a.DATAEXTENT&&(x[0]=0),n=i.scale.linear().domain(f.radialAxis.domain!=a.DATAEXTENT&&f.radialAxis.domain?f.radialAxis.domain:x).range([0,b]),c.layout.radialAxis.domain=n.domain();var A,k=a.util.flattenArray(d.map(function(t,e){return t.t})),M="string"==typeof k[0];M&&(k=a.util.deduplicate(k),A=k.slice(),k=i.range(k.length),d=d.map(function(t,e){var r=t;return t.t=[k],p&&(r.yStack=t.yStack),r}));var E=d.filter(function(t,e){return"LinePlot"===t.geometry||"DotPlot"===t.geometry}).length===d.length,T=null===f.needsEndSpacing?M||!E:f.needsEndSpacing,L=f.angularAxis.domain&&f.angularAxis.domain!=a.DATAEXTENT&&!M&&f.angularAxis.domain[0]>=0,S=L?f.angularAxis.domain:i.extent(k),C=Math.abs(k[1]-k[0]);E&&!M&&(C=0);var R=S.slice();T&&M&&(R[1]+=C);var I=f.angularAxis.ticksCount||4;I>8&&(I=I/(I/8)+I%8),f.angularAxis.ticksStep&&(I=(R[1]-R[0])/I);var P=f.angularAxis.ticksStep||(R[1]-R[0])/(I*(f.minorTicks+1));A&&(P=Math.max(Math.round(P),1)),R[2]||(R[2]=P);var O=i.range.apply(this,R);if(O=O.map(function(t,e){return parseFloat(t.toPrecision(12))}),s=i.scale.linear().domain(R.slice(0,2)).range("clockwise"===f.direction?[0,360]:[360,0]),c.layout.angularAxis.domain=s.domain(),c.layout.angularAxis.endPadding=T?C:0,e=i.select(this).select("svg.chart-root"),"undefined"==typeof e||e.empty()){var N="' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '",z=(new DOMParser).parseFromString(N,"application/xml"),D=this.appendChild(this.ownerDocument.importNode(z.documentElement,!0));e=i.select(D)}e.select(".guides-group").style({"pointer-events":"none"}),e.select(".angular.axis-group").style({"pointer-events":"none"}),e.select(".radial.axis-group").style({"pointer-events":"none"});var F,B=e.select(".chart-group"),j={fill:"none",stroke:f.tickColor},U={"font-size":f.font.size,"font-family":f.font.family,fill:f.font.color,"text-shadow":["-1px 0px","1px -1px","-1px 1px","1px 1px"].map(function(t,e){return" "+t+" 0 "+f.font.outlineColor}).join(",")};if(f.showLegend){F=e.select(".legend-group").attr({transform:"translate("+[b,f.margin.top]+")"}).style({display:"block"});var V=d.map(function(t,e){var r=a.util.cloneJson(t);return r.symbol="DotPlot"===t.geometry?t.dotType||"circle":"LinePlot"!=t.geometry?"square":"line",r.visibleInLegend="undefined"==typeof t.visibleInLegend||t.visibleInLegend,r.color="LinePlot"===t.geometry?t.strokeColor:t.color,r});a.Legend().config({data:d.map(function(t,e){return t.name||"Element"+e}),legendConfig:o({},a.Legend.defaultConfig().legendConfig,{container:F,elements:V,reverseOrder:f.legend.reverseOrder})})();var q=F.node().getBBox();b=Math.min(f.width-q.width-f.margin.left-f.margin.right,f.height-f.margin.top-f.margin.bottom)/2,b=Math.max(10,b),_=[f.margin.left+b,f.margin.top+b],n.range([0,b]),c.layout.radialAxis.domain=n.domain(),F.attr("transform","translate("+[_[0]+b,_[1]-b]+")")}else F=e.select(".legend-group").style({display:"none"});e.attr({width:f.width,height:f.height}).style({opacity:f.opacity}),B.attr("transform","translate("+_+")").style({cursor:"crosshair"});var H=[(f.width-(f.margin.left+f.margin.right+2*b+(q?q.width:0)))/2,(f.height-(f.margin.top+f.margin.bottom+2*b))/2];if(H[0]=Math.max(0,H[0]),H[1]=Math.max(0,H[1]),e.select(".outer-group").attr("transform","translate("+H+")"),f.title){var G=e.select("g.title-group text").style(U).text(f.title),X=G.node().getBBox();G.attr({x:_[0]-X.width/2,y:_[1]-b-20})}var Y=e.select(".radial.axis-group");if(f.radialAxis.gridLinesVisible){var W=Y.selectAll("circle.grid-circle").data(n.ticks(5));W.enter().append("circle").attr({class:"grid-circle"}).style(j),W.attr("r",n),W.exit().remove()}Y.select("circle.outside-circle").attr({r:b}).style(j);var Z=e.select("circle.background-circle").attr({r:b}).style({fill:f.backgroundColor,stroke:f.stroke});if(f.radialAxis.visible){var Q=i.svg.axis().scale(n).ticks(5).tickSize(5);Y.call(Q).attr({transform:"rotate("+f.radialAxis.orientation+")"}),Y.selectAll(".domain").style(j),Y.selectAll("g>text").text(function(t,e){return this.textContent+f.radialAxis.ticksSuffix}).style(U).style({"text-anchor":"start"}).attr({x:0,y:0,dx:0,dy:0,transform:function(t,e){return"horizontal"===f.radialAxis.tickOrientation?"rotate("+-f.radialAxis.orientation+") translate("+[0,U["font-size"]]+")":"translate("+[0,U["font-size"]]+")"}}),Y.selectAll("g>line").style({stroke:"black"})}var $=e.select(".angular.axis-group").selectAll("g.angular-tick").data(O),K=$.enter().append("g").classed("angular-tick",!0);$.attr({transform:function(t,e){return"rotate("+l(t,e)+")"}}).style({display:f.angularAxis.visible?"block":"none"}),$.exit().remove(),K.append("line").classed("grid-line",!0).classed("major",function(t,e){return e%(f.minorTicks+1)==0}).classed("minor",function(t,e){return!(e%(f.minorTicks+1)==0)}).style(j),K.selectAll(".minor").style({stroke:f.minorTickColor}),$.select("line.grid-line").attr({x1:f.tickLength?b-f.tickLength:0,x2:b}).style({display:f.angularAxis.gridLinesVisible?"block":"none"}),K.append("text").classed("axis-text",!0).style(U);var J=$.select("text.axis-text").attr({x:b+f.labelOffset,dy:".35em",transform:function(t,e){var r=l(t,e),n=b+f.labelOffset,i=f.angularAxis.tickOrientation;return"horizontal"==i?"rotate("+-r+" "+n+" 0)":"radial"==i?r<270&&r>90?"rotate(180 "+n+" 0)":null:"rotate("+(r<=180&&r>0?-90:90)+" "+n+" 0)"}}).style({"text-anchor":"middle",display:f.angularAxis.labelsVisible?"block":"none"}).text(function(t,e){return e%(f.minorTicks+1)!=0?"":A?A[t]+f.angularAxis.ticksSuffix:t+f.angularAxis.ticksSuffix}).style(U);f.angularAxis.rewriteTicks&&J.text(function(t,e){return e%(f.minorTicks+1)!=0?"":f.angularAxis.rewriteTicks(this.textContent,e)});var tt=i.max(B.selectAll(".angular-tick text")[0].map(function(t,e){return t.getCTM().e+t.getBBox().width}));F.attr({transform:"translate("+[b+tt,f.margin.top]+")"});var et=e.select("g.geometry-group").selectAll("g").size()>0,rt=e.select("g.geometry-group").selectAll("g.geometry").data(d);if(rt.enter().append("g").attr({class:function(t,e){return"geometry geometry"+e}}),rt.exit().remove(),d[0]||et){var nt=[];d.forEach(function(t,e){var r={};r.radialScale=n, ++r.angularScale=s,r.container=rt.filter(function(t,r){return r==e}),r.geometry=t.geometry,r.orientation=f.orientation,r.direction=f.direction,r.index=e,nt.push({data:t,geometryConfig:r})});var it=i.nest().key(function(t,e){return"undefined"!=typeof t.data.groupId||"unstacked"}).entries(nt),at=[];it.forEach(function(t,e){"unstacked"===t.key?at=at.concat(t.values.map(function(t,e){return[t]})):at.push(t.values)}),at.forEach(function(t,e){var r;r=Array.isArray(t)?t[0].geometryConfig.geometry:t.geometryConfig.geometry;var n=t.map(function(t,e){return o(a[r].defaultConfig(),t)});a[r]().config(n)()})}var ot,st,lt=e.select(".guides-group"),ut=e.select(".tooltips-group"),ct=a.tooltipPanel().config({container:ut,fontSize:8})(),ft=a.tooltipPanel().config({container:ut,fontSize:8})(),ht=a.tooltipPanel().config({container:ut,hasTick:!0})();if(!M){var dt=lt.select("line").attr({x1:0,y1:0,y2:0}).style({stroke:"grey","pointer-events":"none"});B.on("mousemove.angular-guide",function(t,e){var r=a.util.getMousePos(Z).angle;dt.attr({x2:-b,transform:"rotate("+r+")"}).style({opacity:.5});var n=(r+180+360-f.orientation)%360;ot=s.invert(n);var i=a.util.convertToCartesian(b+12,r+180);ct.text(a.util.round(ot)).move([i[0]+_[0],i[1]+_[1]])}).on("mouseout.angular-guide",function(t,e){lt.select("line").style({opacity:0})})}var pt=lt.select("circle").style({stroke:"grey",fill:"none"});B.on("mousemove.radial-guide",function(t,e){var r=a.util.getMousePos(Z).radius;pt.attr({r:r}).style({opacity:.5}),st=n.invert(a.util.getMousePos(Z).radius);var i=a.util.convertToCartesian(r,f.radialAxis.orientation);ft.text(a.util.round(st)).move([i[0]+_[0],i[1]+_[1]])}).on("mouseout.radial-guide",function(t,e){pt.style({opacity:0}),ht.hide(),ct.hide(),ft.hide()}),e.selectAll(".geometry-group .mark").on("mouseover.tooltip",function(t,r){var n=i.select(this),o=n.style("fill"),s="black",l=n.style("opacity")||1;if(n.attr({"data-opacity":l}),"none"!=o){n.attr({"data-fill":o}),s=i.hsl(o).darker().toString(),n.style({fill:s,opacity:1});var u={t:a.util.round(t[0]),r:a.util.round(t[1])};M&&(u.t=A[t[0]]);var c="t: "+u.t+", r: "+u.r,f=this.getBoundingClientRect(),h=e.node().getBoundingClientRect(),d=[f.left+f.width/2-H[0]-h.left,f.top+f.height/2-H[1]-h.top];ht.config({color:s}).text(c),ht.move(d)}else o=n.style("stroke"),n.attr({"data-stroke":o}),s=i.hsl(o).darker().toString(),n.style({stroke:s,opacity:1})}).on("mousemove.tooltip",function(t,e){return 0==i.event.which&&void(i.select(this).attr("data-fill")&&ht.show())}).on("mouseout.tooltip",function(t,e){ht.hide();var r=i.select(this),n=r.attr("data-fill");n?r.style({fill:n,opacity:r.attr("data-opacity")}):r.style({stroke:r.attr("data-stroke"),opacity:r.attr("data-opacity")})})}),h}var e,r,n,s,l={data:[],layout:{}},u={},c={},f=i.dispatch("hover"),h={};return h.render=function(e){return t(e),this},h.config=function(t){if(!arguments.length)return l;var e=a.util.cloneJson(t);return e.data.forEach(function(t,e){l.data[e]||(l.data[e]={}),o(l.data[e],a.Axis.defaultConfig().data[0]),o(l.data[e],t)}),o(l.layout,a.Axis.defaultConfig().layout),o(l.layout,e.layout),this},h.getLiveConfig=function(){return c},h.getinputConfig=function(){return u},h.radialScale=function(t){return n},h.angularScale=function(t){return s},h.svg=function(){return e},i.rebind(h,f,"on"),h},a.Axis.defaultConfig=function(t,e){var r={data:[{t:[1,2,3,4],r:[10,11,12,13],name:"Line1",geometry:"LinePlot",color:null,strokeDash:"solid",strokeColor:null,strokeSize:"1",visibleInLegend:!0,opacity:1}],layout:{defaultColorRange:i.scale.category10().range(),title:null,height:450,width:500,margin:{top:40,right:40,bottom:40,left:40},font:{size:12,color:"gray",outlineColor:"white",family:"Tahoma, sans-serif"},direction:"clockwise",orientation:0,labelOffset:10,radialAxis:{domain:null,orientation:-45,ticksSuffix:"",visible:!0,gridLinesVisible:!0,tickOrientation:"horizontal",rewriteTicks:null},angularAxis:{domain:[0,360],ticksSuffix:"",visible:!0,gridLinesVisible:!0,labelsVisible:!0,tickOrientation:"horizontal",rewriteTicks:null,ticksCount:null,ticksStep:null},minorTicks:0,tickLength:null,tickColor:"silver",minorTickColor:"#eee",backgroundColor:"none",needsEndSpacing:null,showLegend:!0,legend:{reverseOrder:!1},opacity:1}};return r},a.util={},a.DATAEXTENT="dataExtent",a.AREA="AreaChart",a.LINE="LinePlot",a.DOT="DotPlot",a.BAR="BarChart",a.util._override=function(t,e){for(var r in t)r in e&&(e[r]=t[r])},a.util._extend=function(t,e){for(var r in t)e[r]=t[r]},a.util._rndSnd=function(){return 2*Math.random()-1+(2*Math.random()-1)+(2*Math.random()-1)},a.util.dataFromEquation2=function(t,e){var r=e||6,n=i.range(0,360+r,r).map(function(e,r){var n=e*Math.PI/180,i=t(n);return[e,i]});return n},a.util.dataFromEquation=function(t,e,r){var n=e||6,a=[],o=[];i.range(0,360+n,n).forEach(function(e,r){var n=e*Math.PI/180,i=t(n);a.push(e),o.push(i)});var s={t:a,r:o};return r&&(s.name=r),s},a.util.ensureArray=function(t,e){if("undefined"==typeof t)return null;var r=[].concat(t);return i.range(e).map(function(t,e){return r[e]||r[0]})},a.util.fillArrays=function(t,e,r){return e.forEach(function(e,n){t[e]=a.util.ensureArray(t[e],r)}),t},a.util.cloneJson=function(t){return JSON.parse(JSON.stringify(t))},a.util.validateKeys=function(t,e){"string"==typeof e&&(e=e.split("."));var r=e.shift();return t[r]&&(!e.length||objHasKeys(t[r],e))},a.util.sumArrays=function(t,e){return i.zip(t,e).map(function(t,e){return i.sum(t)})},a.util.arrayLast=function(t){return t[t.length-1]},a.util.arrayEqual=function(t,e){for(var r=Math.max(t.length,e.length,1);r-- >=0&&t[r]===e[r];);return r===-2},a.util.flattenArray=function(t){for(var e=[];!a.util.arrayEqual(e,t);)e=t,t=[].concat.apply([],t);return t},a.util.deduplicate=function(t){return t.filter(function(t,e,r){return r.indexOf(t)==e})},a.util.convertToCartesian=function(t,e){var r=e*Math.PI/180,n=t*Math.cos(r),i=t*Math.sin(r);return[n,i]},a.util.round=function(t,e){var r=e||2,n=Math.pow(10,r);return Math.round(t*n)/n},a.util.getMousePos=function(t){var e=i.mouse(t.node()),r=e[0],n=e[1],a={};return a.x=r,a.y=n,a.pos=e,a.angle=180*(Math.atan2(n,r)+Math.PI)/Math.PI,a.radius=Math.sqrt(r*r+n*n),a},a.util.duplicatesCount=function(t){for(var e,r={},n={},i=0,a=t.length;i0)){var s=i.select(this.parentNode).selectAll("path.line").data([0]);s.enter().insert("path"),s.attr({class:"line",d:h(o),transform:function(e,r){return"rotate("+(t.orientation+90)+")"},"pointer-events":"none"}).style({fill:function(t,e){return v.fill(r,n,a)},"fill-opacity":0,stroke:function(t,e){return v.stroke(r,n,a)},"stroke-width":function(t,e){return v["stroke-width"](r,n,a)},"stroke-dasharray":function(t,e){return v["stroke-dasharray"](r,n,a)},opacity:function(t,e){return v.opacity(r,n,a)},display:function(t,e){return v.display(r,n,a)}})}};var d=t.angularScale.range(),p=Math.abs(d[1]-d[0])/l[0].length*Math.PI/180,g=i.svg.arc().startAngle(function(t){return-p/2}).endAngle(function(t){return p/2}).innerRadius(function(e){return t.radialScale(c+(e[2]||0))}).outerRadius(function(e){return t.radialScale(c+(e[2]||0))+t.radialScale(e[1])});f.arc=function(e,r,n){i.select(this).attr({class:"mark arc",d:g,transform:function(e,r){return"rotate("+(t.orientation+u(e[0])+90)+")"}})};var v={fill:function(t,r,n){return e[n].data.color},stroke:function(t,r,n){return e[n].data.strokeColor},"stroke-width":function(t,r,n){return e[n].data.strokeSize+"px"},"stroke-dasharray":function(t,r,n){return s[e[n].data.strokeDash]},opacity:function(t,r,n){return e[n].data.opacity},display:function(t,r,n){return"undefined"==typeof e[n].data.visible||e[n].data.visible?"block":"none"}},m=i.select(this).selectAll("g.layer").data(l);m.enter().append("g").attr({class:"layer"});var y=m.selectAll("path.mark").data(function(t,e){return t});y.enter().append("path").attr({class:"mark"}),y.style(v).each(f[t.geometryType]),y.exit().remove(),m.exit().remove()})}var e,r=[a.PolyChart.defaultConfig()],n=i.dispatch("hover"),s={solid:"none",dash:[5,2],dot:[2,5]};return t.config=function(t){return arguments.length?(t.forEach(function(t,e){r[e]||(r[e]={}),o(r[e],a.PolyChart.defaultConfig()),o(r[e],t)}),this):r},t.getColorScale=function(){return e},i.rebind(t,n,"on"),t},a.PolyChart.defaultConfig=function(){var t={data:{name:"geom1",t:[[1,2,3,4]],r:[[1,2,3,4]],dotType:"circle",dotSize:64,dotVisible:!1,barWidth:20,color:"#ffa500",strokeSize:1,strokeColor:"silver",strokeDash:"solid",opacity:1,index:0,visible:!0,visibleInLegend:!0},geometryConfig:{geometry:"LinePlot",geometryType:"arc",direction:"clockwise",orientation:0,container:"body",radialScale:null,angularScale:null,colorScale:i.scale.category20()}};return t},a.BarChart=function(){return a.PolyChart()},a.BarChart.defaultConfig=function(){var t={geometryConfig:{geometryType:"bar"}};return t},a.AreaChart=function(){return a.PolyChart()},a.AreaChart.defaultConfig=function(){var t={geometryConfig:{geometryType:"arc"}};return t},a.DotPlot=function(){return a.PolyChart()},a.DotPlot.defaultConfig=function(){var t={geometryConfig:{geometryType:"dot",dotType:"circle"}};return t},a.LinePlot=function(){return a.PolyChart()},a.LinePlot.defaultConfig=function(){var t={geometryConfig:{geometryType:"line"}};return t},a.Legend=function(){function t(){var r=e.legendConfig,n=e.data.map(function(t,e){return[].concat(t).map(function(t,n){var i=o({},r.elements[e]);return i.name=t,i.color=[].concat(r.elements[e].color)[n],i})}),a=i.merge(n);a=a.filter(function(t,e){return r.elements[e]&&(r.elements[e].visibleInLegend||"undefined"==typeof r.elements[e].visibleInLegend)}),r.reverseOrder&&(a=a.reverse());var s=r.container;("string"==typeof s||s.nodeName)&&(s=i.select(s));var l=a.map(function(t,e){return t.color}),u=r.fontSize,c=null==r.isContinuous?"number"==typeof a[0]:r.isContinuous,f=c?r.height:u*a.length,h=s.classed("legend-group",!0),d=h.selectAll("svg").data([0]),p=d.enter().append("svg").attr({width:300,height:f+u,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"});p.append("g").classed("legend-axis",!0),p.append("g").classed("legend-marks",!0);var g=i.range(a.length),v=i.scale[c?"linear":"ordinal"]().domain(g).range(l),m=i.scale[c?"linear":"ordinal"]().domain(g)[c?"range":"rangePoints"]([0,f]),y=function(t,e){var r=3*e;return"line"===t?"M"+[[-e/2,-e/12],[e/2,-e/12],[e/2,e/12],[-e/2,e/12]]+"Z":i.svg.symbolTypes.indexOf(t)!=-1?i.svg.symbol().type(t).size(r)():i.svg.symbol().type("square").size(r)()};if(c){var b=d.select(".legend-marks").append("defs").append("linearGradient").attr({id:"grad1",x1:"0%",y1:"0%",x2:"0%",y2:"100%"}).selectAll("stop").data(l);b.enter().append("stop"),b.attr({offset:function(t,e){return e/(l.length-1)*100+"%"}}).style({"stop-color":function(t,e){return t}}),d.append("rect").classed("legend-mark",!0).attr({height:r.height,width:r.colorBandWidth,fill:"url(#grad1)"})}else{var x=d.select(".legend-marks").selectAll("path.legend-mark").data(a);x.enter().append("path").classed("legend-mark",!0),x.attr({transform:function(t,e){return"translate("+[u/2,m(e)+u/2]+")"},d:function(t,e){var r=t.symbol;return y(r,u)},fill:function(t,e){return v(e)}}),x.exit().remove()}var _=i.svg.axis().scale(m).orient("right"),w=d.select("g.legend-axis").attr({transform:"translate("+[c?r.colorBandWidth:u,u/2]+")"}).call(_);return w.selectAll(".domain").style({fill:"none",stroke:"none"}),w.selectAll("line").style({fill:"none",stroke:c?r.textColor:"none"}),w.selectAll("text").style({fill:r.textColor,"font-size":r.fontSize}).text(function(t,e){return a[e].name}),t}var e=a.Legend.defaultConfig(),r=i.dispatch("hover");return t.config=function(t){return arguments.length?(o(e,t),this):e},i.rebind(t,r,"on"),t},a.Legend.defaultConfig=function(t,e){var r={data:["a","b","c"],legendConfig:{elements:[{symbol:"line",color:"red"},{symbol:"square",color:"yellow"},{symbol:"diamond",color:"limegreen"}],height:150,colorBandWidth:30,fontSize:12,container:"body",isContinuous:null,textColor:"grey",reverseOrder:!1}};return r},a.tooltipPanel=function(){var t,e,r,n={container:null,hasTick:!1,fontSize:12,color:"white",padding:5},s="tooltip-"+a.tooltipPanel.uid++,l=10,u=function(){t=n.container.selectAll("g."+s).data([0]);var i=t.enter().append("g").classed(s,!0).style({"pointer-events":"none",display:"none"});return r=i.append("path").style({fill:"white","fill-opacity":.9}).attr({d:"M0 0"}),e=i.append("text").attr({dx:n.padding+l,dy:.3*+n.fontSize}),u};return u.text=function(a){var o=i.hsl(n.color).l,s=o>=.5?"#aaa":"white",c=o>=.5?"black":"white",f=a||"";e.style({fill:c,"font-size":n.fontSize+"px"}).text(f);var h=n.padding,d=e.node().getBBox(),p={fill:n.color,stroke:s,"stroke-width":"2px"},g=d.width+2*h+l,v=d.height+2*h;return r.attr({d:"M"+[[l,-v/2],[l,-v/4],[n.hasTick?0:l,0],[l,v/4],[l,v/2],[g,v/2],[g,-v/2]].join("L")+"Z"}).style(p),t.attr({transform:"translate("+[l,-v/2+2*h]+")"}),t.style({display:"block"}),u},u.move=function(e){if(t)return t.attr({transform:"translate("+[e[0],e[1]]+")"}).style({display:"block"}),u},u.hide=function(){if(t)return t.style({display:"none"}),u},u.show=function(){if(t)return t.style({display:"block"}),u},u.config=function(t){return o(n,t),u},u},a.tooltipPanel.uid=1,a.adapter={},a.adapter.plotly=function(){var t={};return t.convert=function(t,e){var r={};if(t.data&&(r.data=t.data.map(function(t,r){var n=o({},t),i=[[n,["marker","color"],["color"]],[n,["marker","opacity"],["opacity"]],[n,["marker","line","color"],["strokeColor"]],[n,["marker","line","dash"],["strokeDash"]],[n,["marker","line","width"],["strokeSize"]],[n,["marker","symbol"],["dotType"]],[n,["marker","size"],["dotSize"]],[n,["marker","barWidth"],["barWidth"]],[n,["line","interpolation"],["lineInterpolation"]],[n,["showlegend"],["visibleInLegend"]]];return i.forEach(function(t,r){a.util.translator.apply(null,t.concat(e))}),e||delete n.marker,e&&delete n.groupId,e?("LinePlot"===n.geometry?(n.type="scatter",n.dotVisible===!0?(delete n.dotVisible,n.mode="lines+markers"):n.mode="lines"):"DotPlot"===n.geometry?(n.type="scatter",n.mode="markers"):"AreaChart"===n.geometry?n.type="area":"BarChart"===n.geometry&&(n.type="bar"),delete n.geometry):("scatter"===n.type?"lines"===n.mode?n.geometry="LinePlot":"markers"===n.mode?n.geometry="DotPlot":"lines+markers"===n.mode&&(n.geometry="LinePlot",n.dotVisible=!0):"area"===n.type?n.geometry="AreaChart":"bar"===n.type&&(n.geometry="BarChart"),delete n.mode,delete n.type),n}),!e&&t.layout&&"stack"===t.layout.barmode)){var n=a.util.duplicates(r.data.map(function(t,e){return t.geometry}));r.data.forEach(function(t,e){var i=n.indexOf(t.geometry);i!=-1&&(r.data[e].groupId=i)})}if(t.layout){var s=o({},t.layout),l=[[s,["plot_bgcolor"],["backgroundColor"]],[s,["showlegend"],["showLegend"]],[s,["radialaxis"],["radialAxis"]],[s,["angularaxis"],["angularAxis"]],[s.angularaxis,["showline"],["gridLinesVisible"]],[s.angularaxis,["showticklabels"],["labelsVisible"]],[s.angularaxis,["nticks"],["ticksCount"]],[s.angularaxis,["tickorientation"],["tickOrientation"]],[s.angularaxis,["ticksuffix"],["ticksSuffix"]],[s.angularaxis,["range"],["domain"]],[s.angularaxis,["endpadding"],["endPadding"]],[s.radialaxis,["showline"],["gridLinesVisible"]],[s.radialaxis,["tickorientation"],["tickOrientation"]],[s.radialaxis,["ticksuffix"],["ticksSuffix"]],[s.radialaxis,["range"],["domain"]],[s.angularAxis,["showline"],["gridLinesVisible"]],[s.angularAxis,["showticklabels"],["labelsVisible"]],[s.angularAxis,["nticks"],["ticksCount"]],[s.angularAxis,["tickorientation"],["tickOrientation"]],[s.angularAxis,["ticksuffix"],["ticksSuffix"]],[s.angularAxis,["range"],["domain"]],[s.angularAxis,["endpadding"],["endPadding"]],[s.radialAxis,["showline"],["gridLinesVisible"]],[s.radialAxis,["tickorientation"],["tickOrientation"]],[s.radialAxis,["ticksuffix"],["ticksSuffix"]],[s.radialAxis,["range"],["domain"]],[s.font,["outlinecolor"],["outlineColor"]],[s.legend,["traceorder"],["reverseOrder"]],[s,["labeloffset"],["labelOffset"]],[s,["defaultcolorrange"],["defaultColorRange"]]];if(l.forEach(function(t,r){a.util.translator.apply(null,t.concat(e))}),e?("undefined"!=typeof s.tickLength&&(s.angularaxis.ticklen=s.tickLength,delete s.tickLength),s.tickColor&&(s.angularaxis.tickcolor=s.tickColor,delete s.tickColor)):(s.angularAxis&&"undefined"!=typeof s.angularAxis.ticklen&&(s.tickLength=s.angularAxis.ticklen),s.angularAxis&&"undefined"!=typeof s.angularAxis.tickcolor&&(s.tickColor=s.angularAxis.tickcolor)),s.legend&&"boolean"!=typeof s.legend.reverseOrder&&(s.legend.reverseOrder="normal"!=s.legend.reverseOrder),s.legend&&"boolean"==typeof s.legend.traceorder&&(s.legend.traceorder=s.legend.traceorder?"reversed":"normal",delete s.legend.reverseOrder),s.margin&&"undefined"!=typeof s.margin.t){var u=["t","r","b","l","pad"],c=["top","right","bottom","left","pad"],f={};i.entries(s.margin).forEach(function(t,e){f[c[u.indexOf(t.key)]]=t.value}),s.margin=f}e&&(delete s.needsEndSpacing,delete s.minorTickColor,delete s.minorTicks,delete s.angularaxis.ticksCount,delete s.angularaxis.ticksCount,delete s.angularaxis.ticksStep,delete s.angularaxis.rewriteTicks,delete s.angularaxis.nticks,delete s.radialaxis.ticksCount,delete s.radialaxis.ticksCount,delete s.radialaxis.ticksStep,delete s.radialaxis.rewriteTicks,delete s.radialaxis.nticks),r.layout=s}return r},t}},{"../../plotly":276,"./micropolar_manager":307,d3:54}],307:[function(t,e,r){"use strict";var n=t("../../plotly"),i=t("d3"),a=t("./undo_manager"),o=e.exports={},s=n.Lib.extendDeepAll;o.framework=function(t){function e(e,a){return a&&(f=a),i.select(i.select(f).node().parentNode).selectAll(".svg-container>*:not(.chart-root)").remove(),r=r?s(r,e):e,u||(u=n.micropolar.Axis()),c=n.micropolar.adapter.plotly().convert(r),u.config(c).render(f),t.data=r.data,t.layout=r.layout,o.fillLayout(t),r}var r,l,u,c,f,h=new a;return e.isPolar=!0,e.svg=function(){return u.svg()},e.getConfig=function(){return r},e.getLiveConfig=function(){return n.micropolar.adapter.plotly().convert(u.getLiveConfig(),!0)},e.getLiveScales=function(){return{t:u.angularScale(),r:u.radialScale()}},e.setUndoPoint=function(){var t=this,e=n.micropolar.util.cloneJson(r);!function(e,r){h.add({undo:function(){r&&t(r)},redo:function(){t(e)}})}(e,l),l=n.micropolar.util.cloneJson(e)},e.undo=function(){h.undo()},e.redo=function(){h.redo()},e},o.fillLayout=function(t){var e=i.select(t).selectAll(".plot-container"),r=e.selectAll(".svg-container"),a=t.framework&&t.framework.svg&&t.framework.svg(),o={width:800,height:600,paper_bgcolor:n.Color.background,_container:e,_paperdiv:r,_paper:a};t._fullLayout=s(o,t.layout)}},{"../../plotly":276,"./undo_manager":308,d3:54}],308:[function(t,e,r){"use strict";e.exports=function(){function t(t,e){return t?(i=!0,t[e](),i=!1,this):this}var e,r=[],n=-1,i=!1;return{add:function(t){return i?this:(r.splice(n+1,r.length-n),r.push(t),n=r.length-1,this)},setCallback:function(t){e=t},undo:function(){var i=r[n];return i?(t(i,"undo"),n-=1,e&&e(i.undo),this):this},redo:function(){var i=r[n+1];return i?(t(i,"redo"),n+=1,e&&e(i.redo),this):this},clear:function(){r=[],n=-1},hasUndo:function(){return n!==-1},hasRedo:function(){return n-1}var a=t("../plotly"),o=a.Lib.extendFlat,s=a.Lib.extendDeep;e.exports=function(t,e){t.framework&&t.framework.isPolar&&(t=t.framework.getConfig());var r,l=t.data,u=t.layout,c=s([],l),f=s({},u,n(e.tileClass));if(e.width&&(f.width=e.width),e.height&&(f.height=e.height),"thumbnail"===e.tileClass||"themes__thumb"===e.tileClass){f.annotations=[];var h=Object.keys(f);for(r=0;r1;if(p&&!f&&"category"!==a.type){e=e.map(a.d2c);var g=e.length;if(!(g<=i))return c?e.slice(0,i):e.slice(0,i+1);if(c||d)u=e.slice(0,i);else if(1===i)u=[e[0]-.5,e[0]+.5];else{for(u=[1.5*e[0]-.5*e[1]],l=1;ly;n++)o=l(t,e,a(o));return o>y&&c.log("interp2d didn't converge quickly",o),t}function s(t){var e,r,n,i,a,o,s,l,u=[],c={},f=[],h=t[0],d=[],p=[0,0,0],g=m(t);for(r=0;r=0;a--)i=f[a],r=i[0],n=i[1],o=((c[[r-1,n]]||p)[2]+(c[[r+1,n]]||p)[2]+(c[[r,n-1]]||p)[2]+(c[[r,n+1]]||p)[2])/20,o&&(s[i]=[r,n,o],f.splice(a,1),l=!0);if(!l)throw"findEmpties iterated with no new neighbors";for(i in s)c[i]=s[i],u.push(s[i])}return u.sort(function(t,e){return e[2]-t[2]})}function l(t,e,r){var n,i,a,o,s,l,u,c,f,h,d,p,g,v=0;for(o=0;op&&(v=Math.max(v,Math.abs(t[i][a]-d)/(g-p))))}return v}var u=t("fast-isnumeric"),c=t("../../lib"),f=t("../../plots/cartesian/axes"),h=t("../../plots/plots"),d=t("../histogram2d/calc"),p=t("../../components/colorscale/calc"),g=t("./has_columns"),v=t("./convert_column_xyz"),m=t("./max_row_length");e.exports=function(t,e){function r(t){T=e._input.zsmooth=e.zsmooth=!1,c.notifier("cannot fast-zsmooth: "+t)}var a,l,u,y,b,x,_,w,A=f.getFromId(t,e.xaxis||"x"),k=f.getFromId(t,e.yaxis||"y"),M=h.traceIs(e,"contour"),E=h.traceIs(e,"histogram"),T=M?"best":e.zsmooth;if(A._minDtick=0,k._minDtick=0,E){var L=d(t,e);a=L.x,l=L.x0,u=L.dx,y=L.y,b=L.y0,x=L.dy,_=L.z}else g(e)&&v(e,A,k),a=e.x?A.makeCalcdata(e,"x"):[],y=e.y?k.makeCalcdata(e,"y"):[],l=e.x0||0,u=e.dx||1,b=e.y0||0,x=e.dy||1,_=n(e),(M||e.connectgaps)&&(e._emptypoints=s(_),e._interpz=o(_,e._emptypoints,e._interpz));if("fast"===T)if("log"===A.type||"log"===k.type)r("log axis found");else if(!E){if(a.length){var S=(a[a.length-1]-a[0])/(a.length-1),C=Math.abs(S/100);for(w=0;wC){r("x scale is not linear");break}}if(y.length&&"fast"===T){var R=(y[y.length-1]-y[0])/(y.length-1),I=Math.abs(R/100);for(w=0;wI){r("y scale is not linear");break}}}var P=m(_),O="scaled"===e.xtype?"":e.x,N=i(e,O,l,u,P,A),z="scaled"===e.ytype?"":e.y,D=i(e,z,b,x,_.length,k);f.expand(A,N),f.expand(k,D);var F={x:N,y:D,z:_};if(p(e,_,"","z"),M&&e.contours&&"heatmap"===e.contours.coloring){var B="contour"===e.type?"heatmap":"histogram2d";F.xfill=i(B,O,l,u,P,A),F.yfill=i(B,z,b,x,_.length,k)}return[F]};var y=.01,b=[[-1,0],[1,0],[0,-1],[0,1]]},{"../../components/colorscale/calc":183,"../../lib":256,"../../plots/cartesian/axes":279,"../../plots/plots":303,"../histogram2d/calc":338,"./convert_column_xyz":327,"./has_columns":329,"./max_row_length":330,"fast-isnumeric":60}],326:[function(t,e,r){"use strict";var n=t("d3"),i=t("fast-isnumeric"),a=t("../../lib"),o=t("../../plots/plots"),s=t("../../components/colorscale/get_scale"),l=t("../../components/colorbar/draw");e.exports=function(t,e){var r=e[0].trace,u="cb"+r.uid,c=s(r.colorscale),f=r.zmin,h=r.zmax;if(i(f)||(f=a.aggNums(Math.min,null,r.z)),i(h)||(h=a.aggNums(Math.max,null,r.z)),t._fullLayout._infolayer.selectAll("."+u).remove(),!r.showscale)return void o.autoMargin(t,u);var d=e[0].t.cb=l(t,u);d.fillcolor(n.scale.linear().domain(c.map(function(t){return f+t[0]*(h-f)})).range(c.map(function(t){return t[1]}))).filllevels({start:f,end:h,size:(h-f)/254}).options(r.colorbar)()}},{"../../components/colorbar/draw":179,"../../components/colorscale/get_scale":188,"../../lib":256,"../../plots/plots":303,d3:54,"fast-isnumeric":60}],327:[function(t,e,r){"use strict";var n=t("../../lib");e.exports=function(t,e,r){var i,a=t.x.slice(),o=t.y.slice(),s=t.z,l=t.text,u=Math.min(a.length,o.length,s.length),c=void 0!==l&&!Array.isArray(l[0]);for(u0&&(n=!0);for(var s=0;sa)return r[t]=a,a-r[t]}return 0},max:function(t,e,r,i){var a=i[e];if(n(a)){if(a=Number(a),!n(r[t]))return r[t]=a,a;if(r[t]m&&p.splice(m,p.length-m),v.length>m&&v.splice(m,v.length-m),!e.autobinx&&"xbins"in e||(e.xbins=i.autoBin(p,d,e.nbinsx,"2d"),"histogram2dcontour"===e.type&&(e.xbins.start-=e.xbins.size,e.xbins.end+=e.xbins.size),e._input.xbins=e.xbins),!e.autobiny&&"ybins"in e||(e.ybins=i.autoBin(v,g,e.nbinsy,"2d"),"histogram2dcontour"===e.type&&(e.ybins.start-=e.ybins.size,e.ybins.end+=e.ybins.size),e._input.ybins=e.ybins),f=[];var y,b,x=[],_=[],w="string"==typeof e.xbins.size?[]:e.xbins,A="string"==typeof e.xbins.size?[]:e.ybins,k=0,M=[],E=e.histnorm,T=e.histfunc,L=E.indexOf("density")!==-1,S="max"===T||"min"===T,C=S?null:0,R=a.count,I=o[E],P=!1,O=[],N=[],z="z"in e?e.z:"marker"in e&&Array.isArray(e.marker.color)?e.marker.color:"";z&&"count"!==T&&(P="avg"===T,R=a[T]);var D=e.xbins,F=D.end+(D.start-i.tickIncrement(D.start,D.size))/1e6;for(h=D.start;h=0&&y=0&&bp&&h.splice(p,h.length-p),d.length>p&&d.splice(p,d.length-p);var g={padded:!0},v={padded:!0};if(o.hasMarkers(e)){if(r=e.marker,l=r.size,Array.isArray(l)){var m={type:"linear"};i.setConvert(m),l=m.makeCalcdata(e.marker,"size"),l.length>p&&l.splice(p,l.length-p)}var y,b=1.6*(e.marker.sizeref||1);y="area"===e.marker.sizemode?function(t){return Math.max(Math.sqrt((t||0)/b),3)}:function(t){return Math.max((t||0)/b,3)},g.ppad=v.ppad=Array.isArray(l)?l.map(y):y(l)}s(e),!("tozerox"===e.fill||"tonextx"===e.fill&&t.firstscatter)||h[0]===h[p-1]&&d[0]===d[p-1]?e.error_y.visible||["tonexty","tozeroy"].indexOf(e.fill)===-1&&(o.hasMarkers(e)||o.hasText(e))||(g.padded=!1,g.ppad=0):g.tozero=!0,!("tozeroy"===e.fill||"tonexty"===e.fill&&t.firstscatter)||h[0]===h[p-1]&&d[0]===d[p-1]?["tonextx","tozerox"].indexOf(e.fill)!==-1&&(v.padded=!1):v.tozero=!0,i.expand(c,h,g),i.expand(f,d,v);var x=new Array(p);for(u=0;u=0;i--)if(a=t[i],"scatter"===a.type&&a.xaxis===r.xaxis&&a.yaxis===r.yaxis){a.opacity=void 0;break}}},{}],344:[function(t,e,r){"use strict";var n=t("d3"),i=t("fast-isnumeric"),a=t("../../lib"),o=t("../../plots/plots"),s=t("../../components/colorscale/get_scale"),l=t("../../components/colorbar/draw");e.exports=function(t,e){var r=e[0].trace,u=r.marker,c="cb"+r.uid;if(t._fullLayout._infolayer.selectAll("."+c).remove(),void 0===u||!u.showscale)return void o.autoMargin(t,c);var f=s(u.colorscale),h=u.color,d=u.cmin,p=u.cmax;i(d)||(d=a.aggNums(Math.min,null,h)),i(p)||(p=a.aggNums(Math.max,null,h));var g=e[0].t.cb=l(t,c);g.fillcolor(n.scale.linear().domain(f.map(function(t){return d+t[0]*(p-d)})).range(f.map(function(t){return t[1]}))).filllevels({start:d,end:p,size:(p-d)/254}).options(u.colorbar)()}},{"../../components/colorbar/draw":179,"../../components/colorscale/get_scale":188,"../../lib":256,"../../plots/plots":303,d3:54,"fast-isnumeric":60}],345:[function(t,e,r){"use strict";var n=t("../../components/colorscale/has_colorscale"),i=t("../../components/colorscale/calc"),a=t("./subtypes");e.exports=function(t){a.hasLines(t)&&n(t,"line")&&i(t,t.line.color,"line","c"),a.hasMarkers(t)&&(n(t,"marker")&&i(t,t.marker.color,"marker","c"),n(t,"marker.line")&&i(t,t.marker.line.color,"marker.line","c"))}},{"../../components/colorscale/calc":183,"../../components/colorscale/has_colorscale":189,"./subtypes":360}],346:[function(t,e,r){"use strict";e.exports={PTS_LINESONLY:20}},{}],347:[function(t,e,r){"use strict";var n=t("../../lib"),i=t("./attributes"),a=t("./constants"),o=t("./subtypes"),s=t("./xy_defaults"),l=t("./marker_defaults"),u=t("./line_defaults"),c=t("./line_shape_defaults"),f=t("./text_defaults"),h=t("./fillcolor_defaults"),d=t("../../components/errorbars/defaults");e.exports=function(t,e,r,p){function g(r,a){return n.coerce(t,e,i,r,a)}var v=s(t,e,g),m=vU!=P>=U&&(C=L[E-1][0],R=L[E][0],S=C+(R-C)*(U-I)/(P-I),D=Math.min(D,S),F=Math.max(F,S));D=Math.max(D,0),F=Math.min(F,h._length);var V=l.defaultLine;return l.opacity(f.fillcolor)?V=f.fillcolor:l.opacity((f.line||{}).color)&&(V=f.line.color),n.extendFlat(t,{distance:a.MAXDIST+10,x0:D,x1:F,y0:U,y1:U,color:V}),delete t.index,f.text&&!Array.isArray(f.text)?t.text=String(f.text):t.text=f.name,[t]}}}},{"../../components/color":176,"../../components/errorbars":205,"../../lib":256,"../../plots/cartesian/constants":284,"../../plots/cartesian/graph_interact":286,"./get_trace_color":349}],351:[function(t,e,r){"use strict";var n={},i=t("./subtypes");n.hasLines=i.hasLines,n.hasMarkers=i.hasMarkers,n.hasText=i.hasText,n.isBubble=i.isBubble,n.attributes=t("./attributes"),n.supplyDefaults=t("./defaults"),n.cleanData=t("./clean_data"),n.calc=t("./calc"),n.arraysToCalcdata=t("./arrays_to_calcdata"),n.plot=t("./plot"),n.colorbar=t("./colorbar"),n.style=t("./style"),n.hoverPoints=t("./hover"),n.selectPoints=t("./select"),n.moduleType="trace",n.name="scatter",n.basePlotModule=t("../../plots/cartesian"),n.categories=["cartesian","symbols","markerColorscale","errorBarsOK","showLegend"],n.meta={},e.exports=n},{"../../plots/cartesian":287,"./arrays_to_calcdata":340,"./attributes":341,"./calc":342,"./clean_data":343,"./colorbar":344,"./defaults":347,"./hover":350,"./plot":357,"./select":358,"./style":359,"./subtypes":360}],352:[function(t,e,r){"use strict";var n=t("../../components/colorscale/has_colorscale"),i=t("../../components/colorscale/defaults");e.exports=function(t,e,r,a,o){var s=(t.marker||{}).color;if(o("line.color",r),n(t,"line"))i(t,e,a,o,{prefix:"line.",cLetter:"c"});else{var l=!Array.isArray(s)&&s||r;o("line.color",l)}o("line.width"),o("line.dash")}},{"../../components/colorscale/defaults":186,"../../components/colorscale/has_colorscale":189}],353:[function(t,e,r){"use strict";var n=t("../../plots/cartesian/axes");e.exports=function(t,e){function r(e){var r=w.c2p(t[e].x),n=A.c2p(t[e].y);return r!==L&&n!==L&&[r,n]}function i(t){var e=t[0]/w._length,r=t[1]/A._length;return(1+10*Math.max(0,-e,e-1,-r,r-1))*M}function a(t,e){var r=t[0]-e[0],n=t[1]-e[1];return Math.sqrt(r*r+n*n)}var o,s,l,u,c,f,h,d,p,g,v,m,y,b,x,_,w=e.xaxis,A=e.yaxis,k=e.connectGaps,M=e.baseTolerance,E=e.linear,T=[],L=n.BADNUM,S=.2,C=new Array(t.length),R=0;for(o=0;oi(f))break;l=f,y=g[0]*p[0]+g[1]*p[1],y>v?(v=y,u=f,d=!1):y=t.length||!f)break;C[R++]=f,s=f}}else C[R++]=u}T.push(C.slice(0,R))}return T}},{"../../plots/cartesian/axes":279}],354:[function(t,e,r){"use strict";e.exports=function(t,e,r){var n=r("line.shape");"spline"===n&&r("line.smoothing")}},{}],355:[function(t,e,r){"use strict";var n=t("fast-isnumeric");e.exports=function(t){var e=t.marker,r=e.sizeref||1,i=e.sizemin||0,a="area"===e.sizemode?function(t){return Math.sqrt(t/r)}:function(t){return t/r};return function(t){var e=a(t/2);return n(e)&&e>0?Math.max(e,i):0}}},{"fast-isnumeric":60}],356:[function(t,e,r){"use strict";var n=t("../../components/color"),i=t("../../components/colorscale/has_colorscale"),a=t("../../components/colorscale/defaults"),o=t("./subtypes");e.exports=function(t,e,r,s,l){var u,c=o.isBubble(t),f=(t.line||{}).color;f&&(r=f),l("marker.symbol"),l("marker.opacity",c?.7:1),l("marker.size"),l("marker.color",r),i(t,"marker")&&a(t,e,s,l,{prefix:"marker.",cLetter:"c"}),u=f&&!Array.isArray(f)&&e.marker.color!==f?f:c?n.background:n.defaultLine,l("marker.line.color",u),i(t,"marker.line")&&a(t,e,s,l,{prefix:"marker.line.",cLetter:"c"}),l("marker.line.width",c?1:0),c&&(l("marker.sizeref"),l("marker.sizemin"),l("marker.sizemode"))}},{"../../components/color":176,"../../components/colorscale/defaults":186,"../../components/colorscale/has_colorscale":189,"./subtypes":360}],357:[function(t,e,r){"use strict";function n(t,e,r){var n=e.x(),a=e.y(),o=i.extent(n.range.map(n.l2c)),s=i.extent(a.range.map(a.l2c));r.forEach(function(t,e){var n=t[0].trace;if(u.hasMarkers(n)){var i=n.marker.maxdisplayed;if(0!==i){var a=t.filter(function(t){return t.x>=o[0]&&t.x<=o[1]&&t.y>=s[0]&&t.y<=s[1]}),l=Math.ceil(a.length/i),c=0;r.forEach(function(t,r){var n=t[0].trace;u.hasMarkers(n)&&n.marker.maxdisplayed>0&&r1&&n.append("path").classed("js-line",!0).style("vector-effect","non-scaling-stroke").attr("d",a)}v?L&&C&&(m?("y"===m?L[1]=C[1]=p.c2p(0,!0):"x"===m&&(L[0]=C[0]=d.c2p(0,!0)),v.attr("d",A+"L"+C+"L"+L+"Z")):v.attr("d",A+"Z")):"tonext"===e.fill.substr(0,6)&&A&&x&&("tonext"===e.fill?y.attr("d",A+"Z"+x+"Z"):y.attr("d",A+"L"+x.substr(1)+"Z"), ++e._polygons=e._polygons.concat(_)),x=k,_=T}}}),g.selectAll("path:not([d])").remove(),g.append("g").attr("class","points").each(function(t){var e=t[0].trace,r=i.select(this),n=u.hasMarkers(e),s=u.hasText(e);!n&&!s||e.visible!==!0?r.remove():(n&&r.selectAll("path.point").data(e.marker.maxdisplayed?h:a.identity).enter().append("path").classed("point",!0).call(o.translatePoints,d,p),s&&r.selectAll("g").data(e.marker.maxdisplayed?h:a.identity).enter().append("g").append("text").call(o.translatePoints,d,p))})}},{"../../components/drawing":199,"../../components/errorbars":205,"../../lib":256,"../../lib/polygon":262,"./arrays_to_calcdata":340,"./line_points":353,"./subtypes":360,d3:54}],358:[function(t,e,r){"use strict";var n=t("./subtypes"),i=.2;e.exports=function(t,e){var r,a,o,s,l=t.cd,u=t.xaxis,c=t.yaxis,f=[],h=l[0].trace,d=h.index,p=h.marker,g=!n.hasMarkers(h)&&!n.hasText(h);if(h.visible===!0&&!g){var v=Array.isArray(p.opacity)?1:p.opacity;if(e===!1)for(r=0;r=e.length?i:e[a]);return n}function o(t,e,r){return l(S(t,r),L(e,r),r)}function s(t,e,r,n){var i=x(t,e,n);return i=Array.isArray(i[0])?i:a(v.identity,[i],n),l(i,L(r,n),n)}function l(t,e,r){for(var n=new Array(4*r),i=0;i= n-1) { +- var ptr = state.length-1 +- var tf = t - time[n-1] +- for(var i=0; i= n-1) { +- var ptr = state.length-1 +- var tf = t - time[n-1] +- for(var i=0; i=0; --i) { +- if(velocity[--ptr]) { +- return false ++ mouseWheel(element, function(dx, dy, dz) { ++ var flipX = camera.flipX ? 1 : -1 ++ var flipY = camera.flipY ? 1 : -1 ++ var t = now() ++ if(Math.abs(dx) > Math.abs(dy)) { ++ view.rotate(t, 0, 0, -dx * flipX * Math.PI * camera.rotateSpeed / window.innerWidth) ++ } else { ++ var kzoom = camera.zoomSpeed * flipY * dy / window.innerHeight * (t - view.lastT()) / 100.0 ++ view.pan(t, 0, 0, distance * (Math.exp(kzoom) - 1)) + } +- } +- return true ++ }, true) ++ ++ return camera + } ++},{"3d-view":9,"mouse-change":177,"mouse-wheel":179,"right-now":213}],9:[function(require,module,exports){ ++'use strict' + +-proto.jump = function(t) { +- var t0 = this.lastT() +- var d = this.dimension +- if(t < t0 || arguments.length !== d+1) { +- return +- } +- var state = this._state +- var velocity = this._velocity +- var ptr = state.length-this.dimension +- var bounds = this.bounds +- var lo = bounds[0] +- var hi = bounds[1] +- this._time.push(t0, t) +- for(var j=0; j<2; ++j) { +- for(var i=0; i0; --i) { +- state.push(clamp(lo[i-1], hi[i-1], arguments[i])) +- velocity.push(0) ++module.exports = createViewController ++ ++var createTurntable = require('turntable-camera-controller') ++var createOrbit = require('orbit-camera-controller') ++var createMatrix = require('matrix-camera-controller') ++ ++function ViewController(controllers, mode) { ++ this._controllerNames = Object.keys(controllers) ++ this._controllerList = this._controllerNames.map(function(n) { ++ return controllers[n] ++ }) ++ this._mode = mode ++ this._active = controllers[mode] ++ if(!this._active) { ++ this._mode = 'turntable' ++ this._active = controllers.turntable + } ++ this.modes = this._controllerNames ++ this.computedMatrix = this._active.computedMatrix ++ this.computedEye = this._active.computedEye ++ this.computedUp = this._active.computedUp ++ this.computedCenter = this._active.computedCenter ++ this.computedRadius = this._active.computedRadius + } + +-proto.push = function(t) { +- var t0 = this.lastT() +- var d = this.dimension +- if(t < t0 || arguments.length !== d+1) { +- return +- } +- var state = this._state +- var velocity = this._velocity +- var ptr = state.length-this.dimension +- var dt = t - t0 +- var bounds = this.bounds +- var lo = bounds[0] +- var hi = bounds[1] +- var sf = (dt > 1e-6) ? 1/dt : 0 +- this._time.push(t) +- for(var i=d; i>0; --i) { +- var xc = clamp(lo[i-1], hi[i-1], arguments[i]) +- state.push(xc) +- velocity.push((xc - state[ptr++]) * sf) ++var proto = ViewController.prototype ++ ++var COMMON_METHODS = [ ++ ['flush', 1], ++ ['idle', 1], ++ ['lookAt', 4], ++ ['rotate', 4], ++ ['pan', 4], ++ ['translate', 4], ++ ['setMatrix', 2], ++ ['setDistanceLimits', 2], ++ ['setDistance', 2] ++] ++ ++COMMON_METHODS.forEach(function(method) { ++ var name = method[0] ++ var argNames = [] ++ for(var i=0; i0; --i) { +- state.push(clamp(lo[i-1], hi[i-1], arguments[i])) +- velocity.push(0) +- } ++proto.getDistance = function(t) { ++ return this._active.getDistance(t) ++} ++proto.getDistanceLimits = function(out) { ++ return this._active.getDistanceLimits(out) + } + +-proto.move = function(t) { +- var t0 = this.lastT() +- var d = this.dimension +- if(t <= t0 || arguments.length !== d+1) { +- return +- } +- var state = this._state +- var velocity = this._velocity +- var statePtr = state.length - this.dimension +- var bounds = this.bounds +- var lo = bounds[0] +- var hi = bounds[1] +- var dt = t - t0 +- var sf = (dt > 1e-6) ? 1/dt : 0.0 +- this._time.push(t) +- for(var i=d; i>0; --i) { +- var dx = arguments[i] +- state.push(clamp(lo[i-1], hi[i-1], state[statePtr++] + dx)) +- velocity.push(dx * sf) +- } ++proto.lastT = function() { ++ return this._active.lastT() + } + +-proto.idle = function(t) { +- var t0 = this.lastT() +- if(t < t0) { ++proto.setMode = function(mode) { ++ if(mode === this._mode) { + return + } +- var d = this.dimension +- var state = this._state +- var velocity = this._velocity +- var statePtr = state.length-d +- var bounds = this.bounds +- var lo = bounds[0] +- var hi = bounds[1] +- var dt = t - t0 +- this._time.push(t) +- for(var i=d-1; i>=0; --i) { +- state.push(clamp(lo[i], hi[i], state[statePtr] + dt * velocity[statePtr])) +- velocity.push(0) +- statePtr += 1 ++ var idx = this._controllerNames.indexOf(mode) ++ if(idx < 0) { ++ return + } ++ var prev = this._active ++ var next = this._controllerList[idx] ++ var lastT = Math.max(prev.lastT(), next.lastT()) ++ ++ prev.recalcMatrix(lastT) ++ next.setMatrix(lastT, prev.computedMatrix) ++ ++ this._active = next ++ this._mode = mode ++ ++ //Update matrix properties ++ this.computedMatrix = this._active.computedMatrix ++ this.computedEye = this._active.computedEye ++ this.computedUp = this._active.computedUp ++ this.computedCenter = this._active.computedCenter ++ this.computedRadius = this._active.computedRadius + } + +-function getZero(d) { +- var result = new Array(d) +- for(var i=0; i>>1,x=a", useNdarray ? ".get(m)" : "[m]"] +- if(earlyOut) { +- if(predicate.indexOf("c") < 0) { +- code.push(";if(x===y){return m}else if(x<=y){") +- } else { +- code.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){") +- } +- } else { +- code.push(";if(", predicate, "){i=m;") +- } +- if(reversed) { +- code.push("l=m+1}else{h=m-1}") +- } else { +- code.push("h=m-1}else{l=m+1}") +- } +- code.push("}") +- if(earlyOut) { +- code.push("return -1};") +- } else { +- code.push("return i};") ++var TriangleCache = new weakMap() ++ ++function createABigTriangle(gl) { ++ ++ var triangleVAO = TriangleCache.get(gl) ++ if(!triangleVAO || !gl.isBuffer(triangleVAO._triangleBuffer.buffer)) { ++ var buf = createBuffer(gl, new Float32Array([-1, -1, -1, 4, 4, -1])) ++ triangleVAO = createVAO(gl, [ ++ { buffer: buf, ++ type: gl.FLOAT, ++ size: 2 ++ } ++ ]) ++ triangleVAO._triangleBuffer = buf ++ TriangleCache.set(gl, triangleVAO) + } +- return code.join("") ++ triangleVAO.bind() ++ gl.drawArrays(gl.TRIANGLES, 0, 3) ++ triangleVAO.unbind() + } + +-function compileBoundsSearch(predicate, reversed, suffix, earlyOut) { +- var result = new Function([ +- compileSearch("A", "x" + predicate + "y", reversed, ["y"], false, earlyOut), +- compileSearch("B", "x" + predicate + "y", reversed, ["y"], true, earlyOut), +- compileSearch("P", "c(x,y)" + predicate + "0", reversed, ["y", "c"], false, earlyOut), +- compileSearch("Q", "c(x,y)" + predicate + "0", reversed, ["y", "c"], true, earlyOut), +-"function dispatchBsearch", suffix, "(a,y,c,l,h){\ +-if(a.shape){\ +-if(typeof(c)==='function'){\ +-return Q(a,(l===undefined)?0:l|0,(h===undefined)?a.shape[0]-1:h|0,y,c)\ +-}else{\ +-return B(a,(c===undefined)?0:c|0,(l===undefined)?a.shape[0]-1:l|0,y)\ +-}}else{\ +-if(typeof(c)==='function'){\ +-return P(a,(l===undefined)?0:l|0,(h===undefined)?a.length-1:h|0,y,c)\ +-}else{\ +-return A(a,(c===undefined)?0:c|0,(l===undefined)?a.length-1:l|0,y)\ +-}}}\ +-return dispatchBsearch", suffix].join("")) +- return result() +-} ++module.exports = createABigTriangle + +-module.exports = { +- ge: compileBoundsSearch(">=", false, "GE"), +- gt: compileBoundsSearch(">", false, "GT"), +- lt: compileBoundsSearch("<", true, "LT"), +- le: compileBoundsSearch("<=", true, "LE"), +- eq: compileBoundsSearch("-", true, "EQ", true) ++},{"gl-buffer":94,"gl-vao":148,"weak-map":251}],11:[function(require,module,exports){ ++var padLeft = require('pad-left') ++ ++module.exports = addLineNumbers ++function addLineNumbers (string, start, delim) { ++ start = typeof start === 'number' ? start : 1 ++ delim = delim || ': ' ++ ++ var lines = string.split(/\r?\n/) ++ var totalDigits = String(lines.length + start - 1).length ++ return lines.map(function (line, i) { ++ var c = i + start ++ var digits = String(c).length ++ var prefix = padLeft(c, totalDigits - digits) ++ return prefix + delim + line ++ }).join('\n') + } + +-},{}],10:[function(require,module,exports){ +-"use strict" ++},{"pad-left":196}],12:[function(require,module,exports){ ++'use strict' + +-function dcubicHermite(p0, v0, p1, v1, t, f) { +- var dh00 = 6*t*t-6*t, +- dh10 = 3*t*t-4*t + 1, +- dh01 = -6*t*t+6*t, +- dh11 = 3*t*t-2*t +- if(p0.length) { +- if(!f) { +- f = new Array(p0.length) ++module.exports = affineHull ++ ++var orient = require('robust-orientation') ++ ++function linearlyIndependent(points, d) { ++ var nhull = new Array(d+1) ++ for(var i=0; i=0; --i) { +- f[i] = dh00*p0[i] + dh10*v0[i] + dh01*p1[i] + dh11*v1[i] ++ var o = orient.apply(void 0, nhull) ++ if(o) { ++ return true + } +- return f + } +- return dh00*p0 + dh10*v0 + dh01*p1[i] + dh11*v1 ++ return false + } + +-function cubicHermite(p0, v0, p1, v1, t, f) { +- var ti = (t-1), t2 = t*t, ti2 = ti*ti, +- h00 = (1+2*t)*ti2, +- h10 = t*ti2, +- h01 = t2*(3-2*t), +- h11 = t2*ti +- if(p0.length) { +- if(!f) { +- f = new Array(p0.length) ++function affineHull(points) { ++ var n = points.length ++ if(n === 0) { ++ return [] ++ } ++ if(n === 1) { ++ return [0] ++ } ++ var d = points[0].length ++ var frame = [ points[0] ] ++ var index = [ 0 ] ++ for(var i=1; i=0; --i) { +- f[i] = h00*p0[i] + h10*v0[i] + h01*p1[i] + h11*v1[i] ++ index.push(i) ++ if(index.length === d+1) { ++ return index + } +- return f + } +- return h00*p0 + h10*v0 + h01*p1 + h11*v1 ++ return index + } ++},{"robust-orientation":219}],13:[function(require,module,exports){ ++'use strict' + +-module.exports = cubicHermite +-module.exports.derivative = dcubicHermite +-},{}],11:[function(require,module,exports){ +-module.exports = cross; +- +-/** +- * Computes the cross product of two vec3's +- * +- * @param {vec3} out the receiving vector +- * @param {vec3} a the first operand +- * @param {vec3} b the second operand +- * @returns {vec3} out +- */ +-function cross(out, a, b) { +- var ax = a[0], ay = a[1], az = a[2], +- bx = b[0], by = b[1], bz = b[2] ++module.exports = alphaComplex + +- out[0] = ay * bz - az * by +- out[1] = az * bx - ax * bz +- out[2] = ax * by - ay * bx +- return out +-} +-},{}],12:[function(require,module,exports){ +-module.exports = dot; ++var delaunay = require('delaunay-triangulate') ++var circumradius = require('circumradius') + +-/** +- * Calculates the dot product of two vec3's +- * +- * @param {vec3} a the first operand +- * @param {vec3} b the second operand +- * @returns {Number} dot product of a and b +- */ +-function dot(a, b) { +- return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] ++function alphaComplex(alpha, points) { ++ return delaunay(points).filter(function(cell) { ++ var simplex = new Array(cell.length) ++ for(var i=0; i 0) { +- //TODO: evaluate use of glm_invsqrt here? +- len = 1 / Math.sqrt(len) +- out[0] = a[0] * len +- out[1] = a[1] * len +- out[2] = a[2] * len +- } +- return out +-} +-},{}],16:[function(require,module,exports){ +-'use strict' ++var arraytools = function () { + +-var bsearch = require('binary-search-bounds') +-var m4interp = require('mat4-interpolate') +-var invert44 = require('gl-mat4/invert') +-var rotateX = require('gl-mat4/rotateX') +-var rotateY = require('gl-mat4/rotateY') +-var rotateZ = require('gl-mat4/rotateZ') +-var lookAt = require('gl-mat4/lookAt') +-var translate = require('gl-mat4/translate') +-var scale = require('gl-mat4/scale') +-var normalize = require('gl-vec3/normalize') ++ var that = {}; + +-var DEFAULT_CENTER = [0,0,0] ++ var RGB_REGEX = /^rgba?\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*(,.*)?\)$/; ++ var RGB_GROUP_REGEX = /^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,?\s*(.*)?\)$/; + +-module.exports = createMatrixCameraController ++ function isPlainObject (v) { ++ return !Array.isArray(v) && v !== null && typeof v === 'object'; ++ } + +-function MatrixCameraController(initialMatrix) { +- this._components = initialMatrix.slice() +- this._time = [0] +- this.prevMatrix = initialMatrix.slice() +- this.nextMatrix = initialMatrix.slice() +- this.computedMatrix = initialMatrix.slice() +- this.computedInverse = initialMatrix.slice() +- this.computedEye = [0,0,0] +- this.computedUp = [0,0,0] +- this.computedCenter = [0,0,0] +- this.computedRadius = [0] +- this._limits = [-Infinity, Infinity] +-} ++ function linspace (start, end, num) { ++ var inc = (end - start) / Math.max(num - 1, 1); ++ var a = []; ++ for( var ii = 0; ii < num; ii++) ++ a.push(start + ii*inc); ++ return a; ++ } + +-var proto = MatrixCameraController.prototype ++ function zip () { ++ var arrays = [].slice.call(arguments); ++ var lengths = arrays.map(function (a) {return a.length;}); ++ var len = Math.min.apply(null, lengths); ++ var zipped = []; ++ for (var i = 0; i < len; i++) { ++ zipped[i] = []; ++ for (var j = 0; j < arrays.length; ++j) { ++ zipped[i][j] = arrays[j][i]; ++ } ++ } ++ return zipped; ++ } + +-proto.recalcMatrix = function(t) { +- var time = this._time +- var tidx = bsearch.le(time, t) +- var mat = this.computedMatrix +- if(tidx < 0) { +- return ++ function zip3 (a, b, c) { ++ var len = Math.min.apply(null, [a.length, b.length, c.length]); ++ var result = []; ++ for (var n = 0; n < len; n++) { ++ result.push([a[n], b[n], c[n]]); ++ } ++ return result; + } +- var comps = this._components +- if(tidx === time.length-1) { +- var ptr = 16*tidx +- for(var i=0; i<16; ++i) { +- mat[i] = comps[ptr++] +- } +- } else { +- var dt = (time[tidx+1] - time[tidx]) +- var ptr = 16*tidx +- var prev = this.prevMatrix +- var allEqual = true +- for(var i=0; i<16; ++i) { +- prev[i] = comps[ptr++] +- } +- var next = this.nextMatrix +- for(var i=0; i<16; ++i) { +- next[i] = comps[ptr++] +- allEqual = allEqual && (prev[i] === next[i]) +- } +- if(dt < 1e-6 || allEqual) { +- for(var i=0; i<16; ++i) { +- mat[i] = prev[i] ++ ++ function sum (A) { ++ var acc = 0; ++ accumulate(A, acc); ++ function accumulate(x) { ++ for (var i = 0; i < x.length; i++) { ++ if (Array.isArray(x[i])) ++ accumulate(x[i], acc); ++ else ++ acc += x[i]; + } +- } else { +- m4interp(mat, prev, next, (t - time[tidx])/dt) + } ++ return acc; + } + +- var up = this.computedUp +- up[0] = mat[1] +- up[1] = mat[5] +- up[2] = mat[6] +- normalize(up, up) +- +- var imat = this.computedInverse +- invert44(imat, mat) +- var eye = this.computedEye +- var w = imat[15] +- eye[0] = imat[12]/w +- eye[1] = imat[13]/w +- eye[2] = imat[14]/w ++ function copy2D (arr) { ++ var carr = []; ++ for (var i = 0; i < arr.length; ++i) { ++ carr[i] = []; ++ for (var j = 0; j < arr[i].length; ++j) { ++ carr[i][j] = arr[i][j]; ++ } ++ } + +- var center = this.computedCenter +- var radius = Math.exp(this.computedRadius[0]) +- for(var i=0; i<3; ++i) { +- center[i] = eye[i] - mat[2+4*i] * radius ++ return carr; + } +-} + +-proto.idle = function(t) { +- if(t < this.lastT()) { +- return +- } +- var mc = this._components +- var ptr = mc.length-16 +- for(var i=0; i<16; ++i) { +- mc.push(mc[ptr++]) +- } +- this._time.push(t) +-} + +-proto.flush = function(t) { +- var idx = bsearch.gt(this._time, t) - 2 +- if(idx < 0) { +- return ++ function copy1D (arr) { ++ var carr = []; ++ for (var i = 0; i < arr.length; ++i) { ++ carr[i] = arr[i]; ++ } ++ ++ return carr; + } +- this._time.slice(0, idx) +- this._components.slice(0, 16*idx) +-} + +-proto.lastT = function() { +- return this._time[this._time.length-1] +-} + +-proto.lookAt = function(t, eye, center, up) { +- this.recalcMatrix(t) +- eye = eye || this.computedEye +- center = center || DEFAULT_CENTER +- up = up || this.computedUp +- this.setMatrix(t, lookAt(this.computedMatrix, eye, center, up)) +- var d2 = 0.0 +- for(var i=0; i<3; ++i) { +- d2 += Math.pow(center[i] - eye[i], 2) ++ function isEqual(arr1, arr2) { ++ if(arr1.length !== arr2.length) ++ return false; ++ for(var i = arr1.length; i--;) { ++ if(arr1[i] !== arr2[i]) ++ return false; ++ } ++ ++ return true; + } +- d2 = Math.log(Math.sqrt(d2)) +- this.computedRadius[0] = d2 +-} + +-proto.rotate = function(t, yaw, pitch, roll) { +- this.recalcMatrix(t) +- var mat = this.computedInverse +- if(yaw) rotateY(mat, mat, yaw) +- if(pitch) rotateX(mat, mat, pitch) +- if(roll) rotateZ(mat, mat, roll) +- this.setMatrix(t, invert44(this.computedMatrix, mat)) +-} + +-var tvec = [0,0,0] ++ function str2RgbArray(str, twoFiftySix) { ++ // convert hex or rbg strings to 0->1 or 0->255 rgb array ++ var rgb, ++ match; + +-proto.pan = function(t, dx, dy, dz) { +- tvec[0] = -(dx || 0.0) +- tvec[1] = -(dy || 0.0) +- tvec[2] = -(dz || 0.0) +- this.recalcMatrix(t) +- var mat = this.computedInverse +- translate(mat, mat, tvec) +- this.setMatrix(t, invert44(mat, mat)) +-} ++ if (typeof str !== 'string') return str; + +-proto.translate = function(t, dx, dy, dz) { +- tvec[0] = dx || 0.0 +- tvec[1] = dy || 0.0 +- tvec[2] = dz || 0.0 +- this.recalcMatrix(t) +- var mat = this.computedMatrix +- translate(mat, mat, tvec) +- this.setMatrix(t, mat) +-} ++ rgb = []; ++ // hex notation ++ if (str[0] === '#') { ++ str = str.substr(1) // remove hash ++ if (str.length === 3) str += str // fff -> ffffff ++ match = parseInt(str, 16); ++ rgb[0] = ((match >> 16) & 255); ++ rgb[1] = ((match >> 8) & 255); ++ rgb[2] = (match & 255); ++ } + +-proto.setMatrix = function(t, mat) { +- if(t < this.lastT()) { +- return +- } +- this._time.push(t) +- for(var i=0; i<16; ++i) { +- this._components.push(mat[i]) +- } +-} ++ // rgb(34, 34, 127) or rgba(34, 34, 127, 0.1) notation ++ else if (RGB_REGEX.test(str)) { ++ match = str.match(RGB_GROUP_REGEX); ++ rgb[0] = parseInt(match[1]); ++ rgb[1] = parseInt(match[2]); ++ rgb[2] = parseInt(match[3]); ++ } + +-proto.setDistance = function(t, d) { +- this.computedRadius[0] = d +-} ++ if (!twoFiftySix) { ++ for (var j=0; j<3; ++j) rgb[j] = rgb[j]/255 ++ } + +-proto.setDistanceLimits = function(a,b) { +- var lim = this._limits +- lim[0] = a +- lim[1] = b +-} + +-proto.getDistanceLimits = function(out) { +- var lim = this._limits +- if(out) { +- out[0] = lim[0] +- out[1] = lim[1] +- return out ++ return rgb; + } +- return lim +-} +- +-function createMatrixCameraController(options) { +- options = options || {} +- var matrix = options.matrix || +- [1,0,0,0, +- 0,1,0,0, +- 0,0,1,0, +- 0,0,0,1] +- return new MatrixCameraController(matrix) +-} +-},{"binary-search-bounds":17,"gl-mat4/invert":120,"gl-mat4/lookAt":121,"gl-mat4/rotateX":125,"gl-mat4/rotateY":126,"gl-mat4/rotateZ":127,"gl-mat4/scale":128,"gl-mat4/translate":129,"gl-vec3/normalize":15,"mat4-interpolate":18}],17:[function(require,module,exports){ +-arguments[4][9][0].apply(exports,arguments) +-},{"dup":9}],18:[function(require,module,exports){ +-var lerp = require('gl-vec3/lerp') + +-var recompose = require('mat4-recompose') +-var decompose = require('mat4-decompose') +-var determinant = require('gl-mat4/determinant') +-var slerp = require('quat-slerp') + +-var state0 = state() +-var state1 = state() +-var tmp = state() ++ function str2RgbaArray(str, twoFiftySix) { ++ // convert hex or rbg strings to 0->1 or 0->255 rgb array ++ var rgb, ++ match; + +-module.exports = interpolate +-function interpolate(out, start, end, alpha) { +- if (determinant(start) === 0 || determinant(end) === 0) +- return false ++ if (typeof str !== 'string') return str; + +- //decompose the start and end matrices into individual components +- var r0 = decompose(start, state0.translate, state0.scale, state0.skew, state0.perspective, state0.quaternion) +- var r1 = decompose(end, state1.translate, state1.scale, state1.skew, state1.perspective, state1.quaternion) +- if (!r0 || !r1) +- return false ++ rgb = []; ++ // hex notation ++ if (str[0] === '#') { ++ str = str.substr(1) // remove hash ++ if (str.length === 3) str += str // fff -> ffffff ++ match = parseInt(str, 16); ++ rgb[0] = ((match >> 16) & 255); ++ rgb[1] = ((match >> 8) & 255); ++ rgb[2] = (match & 255); ++ } + ++ // rgb(34, 34, 127) or rgba(34, 34, 127, 0.1) notation ++ else if (RGB_REGEX.test(str)) { ++ match = str.match(RGB_GROUP_REGEX); ++ rgb[0] = parseInt(match[1]); ++ rgb[1] = parseInt(match[2]); ++ rgb[2] = parseInt(match[3]); ++ if (match[4]) rgb[3] = parseFloat(match[4]); ++ else rgb[3] = 1.0; ++ } + +- //now lerp/slerp the start and end components into a temporary lerp(tmptranslate, state0.translate, state1.translate, alpha) +- lerp(tmp.translate, state0.translate, state1.translate, alpha) +- lerp(tmp.skew, state0.skew, state1.skew, alpha) +- lerp(tmp.scale, state0.scale, state1.scale, alpha) +- lerp(tmp.perspective, state0.perspective, state1.perspective, alpha) +- slerp(tmp.quaternion, state0.quaternion, state1.quaternion, alpha) + +- //and recompose into our 'out' matrix +- recompose(out, tmp.translate, tmp.scale, tmp.skew, tmp.perspective, tmp.quaternion) +- return true +-} + +-function state() { +- return { +- translate: vec3(), +- scale: vec3(1), +- skew: vec3(), +- perspective: vec4(), +- quaternion: vec4() ++ if (!twoFiftySix) { ++ for (var j=0; j<3; ++j) rgb[j] = rgb[j]/255 + } +-} + +-function vec3(n) { +- return [n||0,n||0,n||0] +-} + +-function vec4() { +- return [0,0,0,1] +-} +-},{"gl-mat4/determinant":116,"gl-vec3/lerp":14,"mat4-decompose":19,"mat4-recompose":21,"quat-slerp":22}],19:[function(require,module,exports){ +-/*jshint unused:true*/ +-/* +-Input: matrix ; a 4x4 matrix +-Output: translation ; a 3 component vector +- scale ; a 3 component vector +- skew ; skew factors XY,XZ,YZ represented as a 3 component vector +- perspective ; a 4 component vector +- quaternion ; a 4 component vector +-Returns false if the matrix cannot be decomposed, true if it can ++ return rgb; ++ } + + +-References: +-https://github.com/kamicane/matrix3d/blob/master/lib/Matrix3d.js +-https://github.com/ChromiumWebApps/chromium/blob/master/ui/gfx/transform_util.cc +-http://www.w3.org/TR/css3-transforms/#decomposing-a-3d-matrix +-*/ + +-var normalize = require('./normalize') + +-var create = require('gl-mat4/create') +-var clone = require('gl-mat4/clone') +-var determinant = require('gl-mat4/determinant') +-var invert = require('gl-mat4/invert') +-var transpose = require('gl-mat4/transpose') +-var vec3 = { +- length: require('gl-vec3/length'), +- normalize: require('gl-vec3/normalize'), +- dot: require('gl-vec3/dot'), +- cross: require('gl-vec3/cross') +-} + +-var tmp = create() +-var perspectiveMatrix = create() +-var tmpVec4 = [0, 0, 0, 0] +-var row = [ [0,0,0], [0,0,0], [0,0,0] ] +-var pdum3 = [0,0,0] ++ that.isPlainObject = isPlainObject; ++ that.linspace = linspace; ++ that.zip3 = zip3; ++ that.sum = sum; ++ that.zip = zip; ++ that.isEqual = isEqual; ++ that.copy2D = copy2D; ++ that.copy1D = copy1D; ++ that.str2RgbArray = str2RgbArray; ++ that.str2RgbaArray = str2RgbaArray; + +-module.exports = function decomposeMat4(matrix, translation, scale, skew, perspective, quaternion) { +- if (!translation) translation = [0,0,0] +- if (!scale) scale = [0,0,0] +- if (!skew) skew = [0,0,0] +- if (!perspective) perspective = [0,0,0,1] +- if (!quaternion) quaternion = [0,0,0,1] ++ return that + +- //normalize, if not possible then bail out early +- if (!normalize(tmp, matrix)) +- return false ++} + +- // perspectiveMatrix is used to solve for perspective, but it also provides +- // an easy way to test for singularity of the upper 3x3 component. +- clone(perspectiveMatrix, tmp) + +- perspectiveMatrix[3] = 0 +- perspectiveMatrix[7] = 0 +- perspectiveMatrix[11] = 0 +- perspectiveMatrix[15] = 1 ++module.exports = arraytools(); + +- // If the perspectiveMatrix is not invertible, we are also unable to +- // decompose, so we'll bail early. Constant taken from SkMatrix44::invert. +- if (Math.abs(determinant(perspectiveMatrix) < 1e-8)) +- return false ++},{}],16:[function(require,module,exports){ ++module.exports = function _atob(str) { ++ return atob(str) ++} + +- var a03 = tmp[3], a13 = tmp[7], a23 = tmp[11], +- a30 = tmp[12], a31 = tmp[13], a32 = tmp[14], a33 = tmp[15] ++},{}],17:[function(require,module,exports){ ++'use strict' + +- // First, isolate perspective. +- if (a03 !== 0 || a13 !== 0 || a23 !== 0) { +- tmpVec4[0] = a03 +- tmpVec4[1] = a13 +- tmpVec4[2] = a23 +- tmpVec4[3] = a33 ++module.exports = barycentric + +- // Solve the equation by inverting perspectiveMatrix and multiplying +- // rightHandSide by the inverse. +- // resuing the perspectiveMatrix here since it's no longer needed +- var ret = invert(perspectiveMatrix, perspectiveMatrix) +- if (!ret) return false +- transpose(perspectiveMatrix, perspectiveMatrix) ++var solve = require('robust-linear-solve') + +- //multiply by transposed inverse perspective matrix, into perspective vec4 +- vec4multMat4(perspective, tmpVec4, perspectiveMatrix) +- } else { +- //no perspective +- perspective[0] = perspective[1] = perspective[2] = 0 +- perspective[3] = 1 ++function reduce(x) { ++ var r = 0 ++ for(var i=0; i row[1][2]) +- quaternion[0] = -quaternion[0] +- if (row[0][2] > row[2][0]) +- quaternion[1] = -quaternion[1] +- if (row[1][0] > row[0][1]) +- quaternion[2] = -quaternion[2] +- return true +-} ++module.exports = div + +-//will be replaced by gl-vec4 eventually +-function vec4multMat4(out, a, m) { +- var x = a[0], y = a[1], z = a[2], w = a[3]; +- out[0] = m[0] * x + m[4] * y + m[8] * z + m[12] * w; +- out[1] = m[1] * x + m[5] * y + m[9] * z + m[13] * w; +- out[2] = m[2] * x + m[6] * y + m[10] * z + m[14] * w; +- out[3] = m[3] * x + m[7] * y + m[11] * z + m[15] * w; +- return out; ++function div(a, b) { ++ return rationalize(a[0].mul(b[1]), a[1].mul(b[0])) + } + +-//gets upper-left of a 4x4 matrix into a 3x3 of vectors +-function mat3from4(out, mat4x4) { +- out[0][0] = mat4x4[0] +- out[0][1] = mat4x4[1] +- out[0][2] = mat4x4[2] +- +- out[1][0] = mat4x4[4] +- out[1][1] = mat4x4[5] +- out[1][2] = mat4x4[6] ++},{"./lib/rationalize":28}],21:[function(require,module,exports){ ++'use strict' + +- out[2][0] = mat4x4[8] +- out[2][1] = mat4x4[9] +- out[2][2] = mat4x4[10] +-} ++var isRat = require('./is-rat') ++var isBN = require('./lib/is-bn') ++var num2bn = require('./lib/num-to-bn') ++var str2bn = require('./lib/str-to-bn') ++var rationalize = require('./lib/rationalize') ++var div = require('./div') + +-function combine(out, a, b, scale1, scale2) { +- out[0] = a[0] * scale1 + b[0] * scale2 +- out[1] = a[1] * scale1 + b[1] * scale2 +- out[2] = a[2] * scale1 + b[2] * scale2 +-} +-},{"./normalize":20,"gl-mat4/clone":114,"gl-mat4/create":115,"gl-mat4/determinant":116,"gl-mat4/invert":120,"gl-mat4/transpose":130,"gl-vec3/cross":11,"gl-vec3/dot":12,"gl-vec3/length":13,"gl-vec3/normalize":15}],20:[function(require,module,exports){ +-module.exports = function normalize(out, mat) { +- var m44 = mat[15] +- // Cannot normalize. +- if (m44 === 0) +- return false +- var scale = 1 / m44 +- for (var i=0; i<16; i++) +- out[i] = mat[i] * scale +- return true ++module.exports = makeRational ++ ++function makeRational(numer, denom) { ++ if(isRat(numer)) { ++ if(denom) { ++ return div(numer, makeRational(denom)) ++ } ++ return [numer[0].clone(), numer[1].clone()] ++ } ++ var shift = 0 ++ var a, b ++ if(isBN(numer)) { ++ a = numer.clone() ++ } else if(typeof numer === 'string') { ++ a = str2bn(numer) ++ } else if(numer === 0) { ++ return [num2bn(0), num2bn(1)] ++ } else if(numer === Math.floor(numer)) { ++ a = num2bn(numer) ++ } else { ++ while(numer !== Math.floor(numer)) { ++ numer = numer * Math.pow(2, 256) ++ shift -= 256 ++ } ++ a = num2bn(numer) ++ } ++ if(isRat(denom)) { ++ a.mul(denom[1]) ++ b = denom[0].clone() ++ } else if(isBN(denom)) { ++ b = denom.clone() ++ } else if(typeof denom === 'string') { ++ b = str2bn(denom) ++ } else if(!denom) { ++ b = num2bn(1) ++ } else if(denom === Math.floor(denom)) { ++ b = num2bn(denom) ++ } else { ++ while(denom !== Math.floor(denom)) { ++ denom = denom * Math.pow(2, 256) ++ shift += 256 ++ } ++ b = num2bn(denom) ++ } ++ if(shift > 0) { ++ a = a.shln(shift) ++ } else if(shift < 0) { ++ b = b.shln(-shift) ++ } ++ return rationalize(a, b) + } +-},{}],21:[function(require,module,exports){ +-/* +-Input: translation ; a 3 component vector +- scale ; a 3 component vector +- skew ; skew factors XY,XZ,YZ represented as a 3 component vector +- perspective ; a 4 component vector +- quaternion ; a 4 component vector +-Output: matrix ; a 4x4 matrix + +-From: http://www.w3.org/TR/css3-transforms/#recomposing-to-a-3d-matrix +-*/ ++},{"./div":20,"./is-rat":22,"./lib/is-bn":26,"./lib/num-to-bn":27,"./lib/rationalize":28,"./lib/str-to-bn":29}],22:[function(require,module,exports){ ++'use strict' + +-var mat4 = { +- identity: require('gl-mat4/identity'), +- translate: require('gl-mat4/translate'), +- multiply: require('gl-mat4/multiply'), +- create: require('gl-mat4/create'), +- scale: require('gl-mat4/scale'), +- fromRotationTranslation: require('gl-mat4/fromRotationTranslation') ++var isBN = require('./lib/is-bn') ++ ++module.exports = isRat ++ ++function isRat(x) { ++ return Array.isArray(x) && x.length === 2 && isBN(x[0]) && isBN(x[1]) + } + +-var rotationMatrix = mat4.create() +-var temp = mat4.create() ++},{"./lib/is-bn":26}],23:[function(require,module,exports){ ++'use strict' + +-module.exports = function recomposeMat4(matrix, translation, scale, skew, perspective, quaternion) { +- mat4.identity(matrix) ++var bn = require('bn.js') + +- //apply translation & rotation +- mat4.fromRotationTranslation(matrix, quaternion, translation) ++module.exports = sign + +- //apply perspective +- matrix[3] = perspective[0] +- matrix[7] = perspective[1] +- matrix[11] = perspective[2] +- matrix[15] = perspective[3] +- +- // apply skew +- // temp is a identity 4x4 matrix initially +- mat4.identity(temp) ++function sign(x) { ++ return x.cmp(new bn(0)) ++} + +- if (skew[2] !== 0) { +- temp[9] = skew[2] +- mat4.multiply(matrix, matrix, temp) +- } ++},{"bn.js":36}],24:[function(require,module,exports){ ++'use strict' + +- if (skew[1] !== 0) { +- temp[9] = 0 +- temp[8] = skew[1] +- mat4.multiply(matrix, matrix, temp) +- } ++module.exports = bn2num + +- if (skew[0] !== 0) { +- temp[8] = 0 +- temp[4] = skew[0] +- mat4.multiply(matrix, matrix, temp) ++//TODO: Make this better ++function bn2num(b) { ++ var l = b.length ++ var words = b.words ++ var out = 0 ++ if (l === 1) { ++ out = words[0] ++ } else if (l === 2) { ++ out = words[0] + (words[1] * 0x4000000) ++ } else { ++ var out = 0 ++ for (var i = 0; i < l; i++) { ++ var w = words[i] ++ out += w * Math.pow(0x4000000, i) + } +- +- //apply scale +- mat4.scale(matrix, matrix, scale) +- return matrix ++ } ++ return b.sign ? -out : out + } +-},{"gl-mat4/create":115,"gl-mat4/fromRotationTranslation":118,"gl-mat4/identity":119,"gl-mat4/multiply":122,"gl-mat4/scale":128,"gl-mat4/translate":129}],22:[function(require,module,exports){ +-module.exports = require('gl-quat/slerp') +-},{"gl-quat/slerp":23}],23:[function(require,module,exports){ +-module.exports = slerp + +-/** +- * Performs a spherical linear interpolation between two quat +- * +- * @param {quat} out the receiving quaternion +- * @param {quat} a the first operand +- * @param {quat} b the second operand +- * @param {Number} t interpolation amount between the two inputs +- * @returns {quat} out +- */ +-function slerp (out, a, b, t) { +- // benchmarks: +- // http://jsperf.com/quaternion-slerp-implementations ++},{}],25:[function(require,module,exports){ ++'use strict' + +- var ax = a[0], ay = a[1], az = a[2], aw = a[3], +- bx = b[0], by = b[1], bz = b[2], bw = b[3] ++var db = require('double-bits') ++var ctz = require('bit-twiddle').countTrailingZeros + +- var omega, cosom, sinom, scale0, scale1 ++module.exports = ctzNumber + +- // calc cosine +- cosom = ax * bx + ay * by + az * bz + aw * bw +- // adjust signs (if necessary) +- if (cosom < 0.0) { +- cosom = -cosom +- bx = -bx +- by = -by +- bz = -bz +- bw = -bw ++//Counts the number of trailing zeros ++function ctzNumber(x) { ++ var l = ctz(db.lo(x)) ++ if(l < 32) { ++ return l + } +- // calculate coefficients +- if ((1.0 - cosom) > 0.000001) { +- // standard case (slerp) +- omega = Math.acos(cosom) +- sinom = Math.sin(omega) +- scale0 = Math.sin((1.0 - t) * omega) / sinom +- scale1 = Math.sin(t * omega) / sinom +- } else { +- // "from" and "to" quaternions are very close +- // ... so we can do a linear interpolation +- scale0 = 1.0 - t +- scale1 = t ++ var h = ctz(db.hi(x)) ++ if(h > 20) { ++ return 52 + } +- // calculate final values +- out[0] = scale0 * ax + scale1 * bx +- out[1] = scale0 * ay + scale1 * by +- out[2] = scale0 * az + scale1 * bz +- out[3] = scale0 * aw + scale1 * bw +- +- return out ++ return h + 32 + } + +-},{}],24:[function(require,module,exports){ ++},{"bit-twiddle":35,"double-bits":76}],26:[function(require,module,exports){ + 'use strict' + +-module.exports = quatFromFrame ++var BN = require('bn.js') + +-function quatFromFrame( +- out, +- rx, ry, rz, +- ux, uy, uz, +- fx, fy, fz) { +- var tr = rx + uy + fz +- if(l > 0) { +- var l = Math.sqrt(tr + 1.0) +- out[0] = 0.5 * (uz - fy) / l +- out[1] = 0.5 * (fx - rz) / l +- out[2] = 0.5 * (ry - uy) / l +- out[3] = 0.5 * l +- } else { +- var tf = Math.max(rx, uy, fz) +- var l = Math.sqrt(2 * tf - tr + 1.0) +- if(rx >= tf) { +- //x y z order +- out[0] = 0.5 * l +- out[1] = 0.5 * (ux + ry) / l +- out[2] = 0.5 * (fx + rz) / l +- out[3] = 0.5 * (uz - fy) / l +- } else if(uy >= tf) { +- //y z x order +- out[0] = 0.5 * (ry + ux) / l +- out[1] = 0.5 * l +- out[2] = 0.5 * (fy + uz) / l +- out[3] = 0.5 * (fx - rz) / l +- } else { +- //z x y order +- out[0] = 0.5 * (rz + fx) / l +- out[1] = 0.5 * (uz + fy) / l +- out[2] = 0.5 * l +- out[3] = 0.5 * (ry - ux) / l +- } +- } +- return out +-} +-},{}],25:[function(require,module,exports){ +-'use strict' ++module.exports = isBN + +-module.exports = createOrbitController ++//Test if x is a bignumber ++//FIXME: obviously this is the wrong way to do it ++function isBN(x) { ++ return x && typeof x === 'object' && Boolean(x.words) ++} + +-var filterVector = require('filtered-vector') +-var lookAt = require('gl-mat4/lookAt') +-var mat4FromQuat = require('gl-mat4/fromQuat') +-var invert44 = require('gl-mat4/invert') +-var quatFromFrame = require('./lib/quatFromFrame') ++},{"bn.js":36}],27:[function(require,module,exports){ ++'use strict' + +-function len3(x,y,z) { +- return Math.sqrt(Math.pow(x,2) + Math.pow(y,2) + Math.pow(z,2)) +-} ++var BN = require('bn.js') ++var db = require('double-bits') + +-function len4(w,x,y,z) { +- return Math.sqrt(Math.pow(w,2) + Math.pow(x,2) + Math.pow(y,2) + Math.pow(z,2)) +-} ++module.exports = num2bn + +-function normalize4(out, a) { +- var ax = a[0] +- var ay = a[1] +- var az = a[2] +- var aw = a[3] +- var al = len4(ax, ay, az, aw) +- if(al > 1e-6) { +- out[0] = ax/al +- out[1] = ay/al +- out[2] = az/al +- out[3] = aw/al ++function num2bn(x) { ++ var e = db.exponent(x) ++ if(e < 52) { ++ return new BN(x) + } else { +- out[0] = out[1] = out[2] = 0.0 +- out[3] = 1.0 ++ return (new BN(x * Math.pow(2, 52-e))).shln(e-52) + } + } + +-function OrbitCameraController(initQuat, initCenter, initRadius) { +- this.radius = filterVector([initRadius]) +- this.center = filterVector(initCenter) +- this.rotation = filterVector(initQuat) +- +- this.computedRadius = this.radius.curve(0) +- this.computedCenter = this.center.curve(0) +- this.computedRotation = this.rotation.curve(0) +- this.computedUp = [0.1,0,0] +- this.computedEye = [0.1,0,0] +- this.computedMatrix = [0.1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] ++},{"bn.js":36,"double-bits":76}],28:[function(require,module,exports){ ++'use strict' + +- this.recalcMatrix(0) +-} ++var num2bn = require('./num-to-bn') ++var sign = require('./bn-sign') + +-var proto = OrbitCameraController.prototype ++module.exports = rationalize + +-proto.lastT = function() { +- return Math.max( +- this.radius.lastT(), +- this.center.lastT(), +- this.rotation.lastT()) ++function rationalize(numer, denom) { ++ var snumer = sign(numer) ++ var sdenom = sign(denom) ++ if(snumer === 0) { ++ return [num2bn(0), num2bn(1)] ++ } ++ if(sdenom === 0) { ++ return [num2bn(0), num2bn(0)] ++ } ++ if(sdenom < 0) { ++ numer = numer.neg() ++ denom = denom.neg() ++ } ++ var d = numer.gcd(denom) ++ if(d.cmpn(1)) { ++ return [ numer.div(d), denom.div(d) ] ++ } ++ return [ numer, denom ] + } + +-proto.recalcMatrix = function(t) { +- this.radius.curve(t) +- this.center.curve(t) +- this.rotation.curve(t) +- +- var quat = this.computedRotation +- normalize4(quat, quat) +- +- var mat = this.computedMatrix +- mat4FromQuat(mat, quat) ++},{"./bn-sign":23,"./num-to-bn":27}],29:[function(require,module,exports){ ++'use strict' + +- var center = this.computedCenter +- var eye = this.computedEye +- var up = this.computedUp +- var radius = Math.exp(this.computedRadius[0]) ++var BN = require('bn.js') + +- eye[0] = center[0] + radius * mat[2] +- eye[1] = center[1] + radius * mat[6] +- eye[2] = center[2] + radius * mat[10] +- up[0] = mat[1] +- up[1] = mat[5] +- up[2] = mat[9] ++module.exports = str2BN + +- for(var i=0; i<3; ++i) { +- var rr = 0.0 +- for(var j=0; j<3; ++j) { +- rr += mat[i+4*j] * eye[j] +- } +- mat[12+i] = -rr +- } ++function str2BN(x) { ++ return new BN(x) + } + +-proto.getMatrix = function(t, result) { +- this.recalcMatrix(t) +- var m = this.computedMatrix +- if(result) { +- for(var i=0; i<16; ++i) { +- result[i] = m[i] +- } +- return result +- } +- return m +-} ++},{"bn.js":36}],30:[function(require,module,exports){ ++'use strict' + +-proto.idle = function(t) { +- this.center.idle(t) +- this.radius.idle(t) +- this.rotation.idle(t) +-} ++var rationalize = require('./lib/rationalize') + +-proto.flush = function(t) { +- this.center.flush(t) +- this.radius.flush(t) +- this.rotation.flush(t) ++module.exports = mul ++ ++function mul(a, b) { ++ return rationalize(a[0].mul(b[0]), a[1].mul(b[1])) + } + +-proto.pan = function(t, dx, dy, dz) { +- dx = dx || 0.0 +- dy = dy || 0.0 +- dz = dz || 0.0 ++},{"./lib/rationalize":28}],31:[function(require,module,exports){ ++'use strict' + +- this.recalcMatrix(t) +- var mat = this.computedMatrix ++var bnsign = require('./lib/bn-sign') + +- var ux = mat[1] +- var uy = mat[5] +- var uz = mat[9] +- var ul = len3(ux, uy, uz) +- ux /= ul +- uy /= ul +- uz /= ul ++module.exports = sign + +- var rx = mat[0] +- var ry = mat[4] +- var rz = mat[8] +- var ru = rx * ux + ry * uy + rz * uz +- rx -= ux * ru +- ry -= uy * ru +- rz -= uz * ru +- var rl = len3(rx, ry, rz) +- rx /= rl +- ry /= rl +- rz /= rl ++function sign(x) { ++ return bnsign(x[0]) * bnsign(x[1]) ++} + +- var fx = mat[2] +- var fy = mat[6] +- var fz = mat[10] +- var fu = fx * ux + fy * uy + fz * uz +- var fr = fx * rx + fy * ry + fz * rz +- fx -= fu * ux + fr * rx +- fy -= fu * uy + fr * ry +- fz -= fu * uz + fr * rz +- var fl = len3(fx, fy, fz) +- fx /= fl +- fy /= fl +- fz /= fl ++},{"./lib/bn-sign":23}],32:[function(require,module,exports){ ++'use strict' + +- var vx = rx * dx + ux * dy +- var vy = ry * dx + uy * dy +- var vz = rz * dx + uz * dy ++var rationalize = require('./lib/rationalize') + +- this.center.move(t, vx, vy, vz) ++module.exports = sub + +- //Update z-component of radius +- var radius = Math.exp(this.computedRadius[0]) +- radius = Math.max(1e-4, radius + dz) +- this.radius.set(t, Math.log(radius)) ++function sub(a, b) { ++ return rationalize(a[0].mul(b[1]).sub(a[1].mul(b[0])), a[1].mul(b[1])) + } + +-proto.rotate = function(t, dx, dy, dz) { +- this.recalcMatrix(t) +- +- dx = dx||0.0 +- dy = dy||0.0 +- +- var mat = this.computedMatrix ++},{"./lib/rationalize":28}],33:[function(require,module,exports){ ++'use strict' + +- var rx = mat[0] +- var ry = mat[4] +- var rz = mat[8] ++var bn2num = require('./lib/bn-to-num') ++var ctz = require('./lib/ctz') + +- var ux = mat[1] +- var uy = mat[5] +- var uz = mat[9] ++module.exports = roundRat + +- var fx = mat[2] +- var fy = mat[6] +- var fz = mat[10] ++//Round a rational to the closest float ++function roundRat(f) { ++ var a = f[0] ++ var b = f[1] ++ if(a.cmpn(0) === 0) { ++ return 0 ++ } ++ var h = a.divmod(b) ++ var iv = h.div ++ var x = bn2num(iv) ++ var ir = h.mod ++ if(ir.cmpn(0) === 0) { ++ return x ++ } ++ if(x) { ++ var s = ctz(x) + 4 ++ var y = bn2num(ir.shln(s).divRound(b)) + +- var qx = dx * rx + dy * ux +- var qy = dx * ry + dy * uy +- var qz = dx * rz + dy * uz ++ // flip the sign of y if x is negative ++ if (x<0) { ++ y = -y; ++ } + +- var bx = -(fy * qz - fz * qy) +- var by = -(fz * qx - fx * qz) +- var bz = -(fx * qy - fy * qx) +- var bw = Math.sqrt(Math.max(0.0, 1.0 - Math.pow(bx,2) - Math.pow(by,2) - Math.pow(bz,2))) +- var bl = len4(bx, by, bz, bw) +- if(bl > 1e-6) { +- bx /= bl +- by /= bl +- bz /= bl +- bw /= bl ++ return x + y * Math.pow(2, -s) + } else { +- bx = by = bz = 0.0 +- bw = 1.0 ++ var ybits = b.bitLength() - ir.bitLength() + 53 ++ var y = bn2num(ir.shln(ybits).divRound(b)) ++ if(ybits < 1023) { ++ return y * Math.pow(2, -ybits) ++ } ++ y *= Math.pow(2, -1023) ++ return y * Math.pow(2, 1023-ybits) + } ++} + +- var rotation = this.computedRotation +- var ax = rotation[0] +- var ay = rotation[1] +- var az = rotation[2] +- var aw = rotation[3] ++},{"./lib/bn-to-num":24,"./lib/ctz":25}],34:[function(require,module,exports){ ++"use strict" + +- var cx = ax*bw + aw*bx + ay*bz - az*by +- var cy = ay*bw + aw*by + az*bx - ax*bz +- var cz = az*bw + aw*bz + ax*by - ay*bx +- var cw = aw*bw - ax*bx - ay*by - az*bz +- +- //Apply roll +- if(dz) { +- bx = fx +- by = fy +- bz = fz +- var s = Math.sin(dz) / len3(bx, by, bz) +- bx *= s +- by *= s +- bz *= s +- bw = Math.cos(dx) +- cx = cx*bw + cw*bx + cy*bz - cz*by +- cy = cy*bw + cw*by + cz*bx - cx*bz +- cz = cz*bw + cw*bz + cx*by - cy*bx +- cw = cw*bw - cx*bx - cy*by - cz*bz ++function compileSearch(funcName, predicate, reversed, extraArgs, useNdarray, earlyOut) { ++ var code = [ ++ "function ", funcName, "(a,l,h,", extraArgs.join(","), "){", ++earlyOut ? "" : "var i=", (reversed ? "l-1" : "h+1"), ++";while(l<=h){\ ++var m=(l+h)>>>1,x=a", useNdarray ? ".get(m)" : "[m]"] ++ if(earlyOut) { ++ if(predicate.indexOf("c") < 0) { ++ code.push(";if(x===y){return m}else if(x<=y){") ++ } else { ++ code.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){") ++ } ++ } else { ++ code.push(";if(", predicate, "){i=m;") + } +- +- var cl = len4(cx, cy, cz, cw) +- if(cl > 1e-6) { +- cx /= cl +- cy /= cl +- cz /= cl +- cw /= cl ++ if(reversed) { ++ code.push("l=m+1}else{h=m-1}") + } else { +- cx = cy = cz = 0.0 +- cw = 1.0 ++ code.push("h=m-1}else{l=m+1}") ++ } ++ code.push("}") ++ if(earlyOut) { ++ code.push("return -1};") ++ } else { ++ code.push("return i};") + } ++ return code.join("") ++} + +- this.rotation.set(t, cx, cy, cz, cw) ++function compileBoundsSearch(predicate, reversed, suffix, earlyOut) { ++ var result = new Function([ ++ compileSearch("A", "x" + predicate + "y", reversed, ["y"], false, earlyOut), ++ compileSearch("B", "x" + predicate + "y", reversed, ["y"], true, earlyOut), ++ compileSearch("P", "c(x,y)" + predicate + "0", reversed, ["y", "c"], false, earlyOut), ++ compileSearch("Q", "c(x,y)" + predicate + "0", reversed, ["y", "c"], true, earlyOut), ++"function dispatchBsearch", suffix, "(a,y,c,l,h){\ ++if(a.shape){\ ++if(typeof(c)==='function'){\ ++return Q(a,(l===undefined)?0:l|0,(h===undefined)?a.shape[0]-1:h|0,y,c)\ ++}else{\ ++return B(a,(c===undefined)?0:c|0,(l===undefined)?a.shape[0]-1:l|0,y)\ ++}}else{\ ++if(typeof(c)==='function'){\ ++return P(a,(l===undefined)?0:l|0,(h===undefined)?a.length-1:h|0,y,c)\ ++}else{\ ++return A(a,(c===undefined)?0:c|0,(l===undefined)?a.length-1:l|0,y)\ ++}}}\ ++return dispatchBsearch", suffix].join("")) ++ return result() + } + +-proto.lookAt = function(t, eye, center, up) { +- this.recalcMatrix(t) ++module.exports = { ++ ge: compileBoundsSearch(">=", false, "GE"), ++ gt: compileBoundsSearch(">", false, "GT"), ++ lt: compileBoundsSearch("<", true, "LT"), ++ le: compileBoundsSearch("<=", true, "LE"), ++ eq: compileBoundsSearch("-", true, "EQ", true) ++} + +- center = center || this.computedCenter +- eye = eye || this.computedEye +- up = up || this.computedUp ++},{}],35:[function(require,module,exports){ ++/** ++ * Bit twiddling hacks for JavaScript. ++ * ++ * Author: Mikola Lysenko ++ * ++ * Ported from Stanford bit twiddling hack library: ++ * http://graphics.stanford.edu/~seander/bithacks.html ++ */ + +- var mat = this.computedMatrix +- lookAt(mat, eye, center, up) ++"use strict"; "use restrict"; + +- var rotation = this.computedRotation +- quatFromFrame(rotation, +- mat[0], mat[1], mat[2], +- mat[4], mat[5], mat[6], +- mat[8], mat[9], mat[10]) +- normalize4(rotation, rotation) +- this.rotation.set(t, rotation[0], rotation[1], rotation[2], rotation[3]) ++//Number of bits in an integer ++var INT_BITS = 32; + +- var fl = 0.0 +- for(var i=0; i<3; ++i) { +- fl += Math.pow(center[i] - eye[i], 2) +- } +- this.radius.set(t, 0.5 * Math.log(Math.max(fl, 1e-6))) ++//Constants ++exports.INT_BITS = INT_BITS; ++exports.INT_MAX = 0x7fffffff; ++exports.INT_MIN = -1<<(INT_BITS-1); + +- this.center.set(t, center[0], center[1], center[2]) ++//Returns -1, 0, +1 depending on sign of x ++exports.sign = function(v) { ++ return (v > 0) - (v < 0); + } + +-proto.translate = function(t, dx, dy, dz) { +- this.center.move(t, +- dx||0.0, +- dy||0.0, +- dz||0.0) ++//Computes absolute value of integer ++exports.abs = function(v) { ++ var mask = v >> (INT_BITS-1); ++ return (v ^ mask) - mask; + } + +-proto.setMatrix = function(t, matrix) { +- +- var rotation = this.computedRotation +- quatFromFrame(rotation, +- matrix[0], matrix[1], matrix[2], +- matrix[4], matrix[5], matrix[6], +- matrix[8], matrix[9], matrix[10]) +- normalize4(rotation, rotation) +- this.rotation.set(t, rotation[0], rotation[1], rotation[2], rotation[3]) +- +- var mat = this.computedMatrix +- invert44(mat, matrix) +- var w = mat[15] +- if(Math.abs(w) > 1e-6) { +- var cx = mat[12]/w +- var cy = mat[13]/w +- var cz = mat[14]/w ++//Computes minimum of integers x and y ++exports.min = function(x, y) { ++ return y ^ ((x ^ y) & -(x < y)); ++} + +- this.recalcMatrix(t) +- var r = Math.exp(this.computedRadius[0]) +- this.center.set(t, cx-mat[2]*r, cy-mat[6]*r, cz-mat[10]*r) +- this.radius.idle(t) +- } else { +- this.center.idle(t) +- this.radius.idle(t) +- } ++//Computes maximum of integers x and y ++exports.max = function(x, y) { ++ return x ^ ((x ^ y) & -(x < y)); + } + +-proto.setDistance = function(t, d) { +- if(d > 0) { +- this.radius.set(t, Math.log(d)) +- } ++//Checks if a number is a power of two ++exports.isPow2 = function(v) { ++ return !(v & (v-1)) && (!!v); + } + +-proto.setDistanceLimits = function(lo, hi) { +- if(lo > 0) { +- lo = Math.log(lo) +- } else { +- lo = -Infinity +- } +- if(hi > 0) { +- hi = Math.log(hi) +- } else { +- hi = Infinity +- } +- hi = Math.max(hi, lo) +- this.radius.bounds[0][0] = lo +- this.radius.bounds[1][0] = hi ++//Computes log base 2 of v ++exports.log2 = function(v) { ++ var r, shift; ++ r = (v > 0xFFFF) << 4; v >>>= r; ++ shift = (v > 0xFF ) << 3; v >>>= shift; r |= shift; ++ shift = (v > 0xF ) << 2; v >>>= shift; r |= shift; ++ shift = (v > 0x3 ) << 1; v >>>= shift; r |= shift; ++ return r | (v >> 1); + } + +-proto.getDistanceLimits = function(out) { +- var bounds = this.radius.bounds +- if(out) { +- out[0] = Math.exp(bounds[0][0]) +- out[1] = Math.exp(bounds[1][0]) +- return out +- } +- return [ Math.exp(bounds[0][0]), Math.exp(bounds[1][0]) ] ++//Computes log base 10 of v ++exports.log10 = function(v) { ++ return (v >= 1000000000) ? 9 : (v >= 100000000) ? 8 : (v >= 10000000) ? 7 : ++ (v >= 1000000) ? 6 : (v >= 100000) ? 5 : (v >= 10000) ? 4 : ++ (v >= 1000) ? 3 : (v >= 100) ? 2 : (v >= 10) ? 1 : 0; + } + +-proto.toJSON = function() { +- this.recalcMatrix(this.lastT()) +- return { +- center: this.computedCenter.slice(), +- rotation: this.computedRotation.slice(), +- distance: Math.log(this.computedRadius[0]), +- zoomMin: this.radius.bounds[0][0], +- zoomMax: this.radius.bounds[1][0] +- } ++//Counts number of bits ++exports.popCount = function(v) { ++ v = v - ((v >>> 1) & 0x55555555); ++ v = (v & 0x33333333) + ((v >>> 2) & 0x33333333); ++ return ((v + (v >>> 4) & 0xF0F0F0F) * 0x1010101) >>> 24; + } + +-proto.fromJSON = function(options) { +- var t = this.lastT() +- var c = options.center +- if(c) { +- this.center.set(t, c[0], c[1], c[2]) +- } +- var r = options.rotation +- if(r) { +- this.rotation.set(t, r[0], r[1], r[2], r[3]) +- } +- var d = options.distance +- if(d && d > 0) { +- this.radius.set(t, Math.log(d)) +- } +- this.setDistanceLimits(options.zoomMin, options.zoomMax) ++//Counts number of trailing zeros ++function countTrailingZeros(v) { ++ var c = 32; ++ v &= -v; ++ if (v) c--; ++ if (v & 0x0000FFFF) c -= 16; ++ if (v & 0x00FF00FF) c -= 8; ++ if (v & 0x0F0F0F0F) c -= 4; ++ if (v & 0x33333333) c -= 2; ++ if (v & 0x55555555) c -= 1; ++ return c; + } ++exports.countTrailingZeros = countTrailingZeros; + +-function createOrbitController(options) { +- options = options || {} +- var center = options.center || [0,0,0] +- var rotation = options.rotation || [0,0,0,1] +- var radius = options.radius || 1.0 ++//Rounds to next power of 2 ++exports.nextPow2 = function(v) { ++ v += v === 0; ++ --v; ++ v |= v >>> 1; ++ v |= v >>> 2; ++ v |= v >>> 4; ++ v |= v >>> 8; ++ v |= v >>> 16; ++ return v + 1; ++} + +- center = [].slice.call(center, 0, 3) +- rotation = [].slice.call(rotation, 0, 4) +- normalize4(rotation, rotation) ++//Rounds down to previous power of 2 ++exports.prevPow2 = function(v) { ++ v |= v >>> 1; ++ v |= v >>> 2; ++ v |= v >>> 4; ++ v |= v >>> 8; ++ v |= v >>> 16; ++ return v - (v>>>1); ++} + +- var result = new OrbitCameraController( +- rotation, +- center, +- Math.log(radius)) ++//Computes parity of word ++exports.parity = function(v) { ++ v ^= v >>> 16; ++ v ^= v >>> 8; ++ v ^= v >>> 4; ++ v &= 0xf; ++ return (0x6996 >>> v) & 1; ++} + +- result.setDistanceLimits(options.zoomMin, options.zoomMax) ++var REVERSE_TABLE = new Array(256); + +- if('eye' in options || 'up' in options) { +- result.lookAt(0, options.eye, options.center, options.up) ++(function(tab) { ++ for(var i=0; i<256; ++i) { ++ var v = i, r = i, s = 7; ++ for (v >>>= 1; v; v >>>= 1) { ++ r <<= 1; ++ r |= v & 1; ++ --s; ++ } ++ tab[i] = (r << s) & 0xff; + } ++})(REVERSE_TABLE); + +- return result ++//Reverse bits in a 32 bit word ++exports.reverse = function(v) { ++ return (REVERSE_TABLE[ v & 0xff] << 24) | ++ (REVERSE_TABLE[(v >>> 8) & 0xff] << 16) | ++ (REVERSE_TABLE[(v >>> 16) & 0xff] << 8) | ++ REVERSE_TABLE[(v >>> 24) & 0xff]; + } +-},{"./lib/quatFromFrame":24,"filtered-vector":8,"gl-mat4/fromQuat":117,"gl-mat4/invert":120,"gl-mat4/lookAt":121}],26:[function(require,module,exports){ +-'use strict' + +-module.exports = createTurntableController ++//Interleave bits of 2 coordinates with 16 bits. Useful for fast quadtree codes ++exports.interleave2 = function(x, y) { ++ x &= 0xFFFF; ++ x = (x | (x << 8)) & 0x00FF00FF; ++ x = (x | (x << 4)) & 0x0F0F0F0F; ++ x = (x | (x << 2)) & 0x33333333; ++ x = (x | (x << 1)) & 0x55555555; + +-var filterVector = require('filtered-vector') +-var invert44 = require('gl-mat4/invert') +-var rotateM = require('gl-mat4/rotate') +-var cross = require('gl-vec3/cross') +-var normalize3 = require('gl-vec3/normalize') +-var dot3 = require('gl-vec3/dot') ++ y &= 0xFFFF; ++ y = (y | (y << 8)) & 0x00FF00FF; ++ y = (y | (y << 4)) & 0x0F0F0F0F; ++ y = (y | (y << 2)) & 0x33333333; ++ y = (y | (y << 1)) & 0x55555555; + +-function len3(x, y, z) { +- return Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2) + Math.pow(z, 2)) ++ return x | (y << 1); + } + +-function clamp1(x) { +- return Math.min(1.0, Math.max(-1.0, x)) ++//Extracts the nth interleaved component ++exports.deinterleave2 = function(v, n) { ++ v = (v >>> n) & 0x55555555; ++ v = (v | (v >>> 1)) & 0x33333333; ++ v = (v | (v >>> 2)) & 0x0F0F0F0F; ++ v = (v | (v >>> 4)) & 0x00FF00FF; ++ v = (v | (v >>> 16)) & 0x000FFFF; ++ return (v << 16) >> 16; + } + +-function findOrthoPair(v) { +- var vx = Math.abs(v[0]) +- var vy = Math.abs(v[1]) +- var vz = Math.abs(v[2]) + +- var u = [0,0,0] +- if(vx > Math.max(vy, vz)) { +- u[2] = 1 +- } else if(vy > Math.max(vx, vz)) { +- u[0] = 1 +- } else { +- u[1] = 1 +- } ++//Interleave bits of 3 coordinates, each with 10 bits. Useful for fast octree codes ++exports.interleave3 = function(x, y, z) { ++ x &= 0x3FF; ++ x = (x | (x<<16)) & 4278190335; ++ x = (x | (x<<8)) & 251719695; ++ x = (x | (x<<4)) & 3272356035; ++ x = (x | (x<<2)) & 1227133513; + +- var vv = 0 +- var uv = 0 +- for(var i=0; i<3; ++i ) { +- vv += v[i] * v[i] +- uv += u[i] * v[i] +- } +- for(var i=0; i<3; ++i) { +- u[i] -= (uv / vv) * v[i] +- } +- normalize3(u, u) +- return u ++ y &= 0x3FF; ++ y = (y | (y<<16)) & 4278190335; ++ y = (y | (y<<8)) & 251719695; ++ y = (y | (y<<4)) & 3272356035; ++ y = (y | (y<<2)) & 1227133513; ++ x |= (y << 1); ++ ++ z &= 0x3FF; ++ z = (z | (z<<16)) & 4278190335; ++ z = (z | (z<<8)) & 251719695; ++ z = (z | (z<<4)) & 3272356035; ++ z = (z | (z<<2)) & 1227133513; ++ ++ return x | (z << 2); + } + +-function TurntableController(zoomMin, zoomMax, center, up, right, radius, theta, phi) { +- this.center = filterVector(center) +- this.up = filterVector(up) +- this.right = filterVector(right) +- this.radius = filterVector([radius]) +- this.angle = filterVector([theta, phi]) +- this.angle.bounds = [[-Infinity,-Math.PI/2], [Infinity,Math.PI/2]] +- this.setDistanceLimits(zoomMin, zoomMax) +- +- this.computedCenter = this.center.curve(0) +- this.computedUp = this.up.curve(0) +- this.computedRight = this.right.curve(0) +- this.computedRadius = this.radius.curve(0) +- this.computedAngle = this.angle.curve(0) +- this.computedToward = [0,0,0] +- this.computedEye = [0,0,0] +- this.computedMatrix = new Array(16) +- for(var i=0; i<16; ++i) { +- this.computedMatrix[i] = 0.5 +- } ++//Extracts nth interleaved component of a 3-tuple ++exports.deinterleave3 = function(v, n) { ++ v = (v >>> n) & 1227133513; ++ v = (v | (v>>>2)) & 3272356035; ++ v = (v | (v>>>4)) & 251719695; ++ v = (v | (v>>>8)) & 4278190335; ++ v = (v | (v>>>16)) & 0x3FF; ++ return (v<<22)>>22; ++} + +- this.recalcMatrix(0) ++//Computes next combination in colexicographic order (this is mistakenly called nextPermutation on the bit twiddling hacks page) ++exports.nextCombination = function(v) { ++ var t = v | (v - 1); ++ return (t + 1) | (((~t & -~t) - 1) >>> (countTrailingZeros(v) + 1)); + } + +-var proto = TurntableController.prototype + +-proto.setDistanceLimits = function(minDist, maxDist) { +- if(minDist > 0) { +- minDist = Math.log(minDist) +- } else { +- minDist = -Infinity +- } +- if(maxDist > 0) { +- maxDist = Math.log(maxDist) +- } else { +- maxDist = Infinity +- } +- maxDist = Math.max(maxDist, minDist) +- this.radius.bounds[0][0] = minDist +- this.radius.bounds[1][0] = maxDist ++},{}],36:[function(require,module,exports){ ++(function (module, exports) { ++ ++'use strict'; ++ ++// Utils ++ ++function assert(val, msg) { ++ if (!val) ++ throw new Error(msg || 'Assertion failed'); + } + +-proto.getDistanceLimits = function(out) { +- var bounds = this.radius.bounds[0] +- if(out) { +- out[0] = Math.exp(bounds[0][0]) +- out[1] = Math.exp(bounds[1][0]) +- return out +- } +- return [ Math.exp(bounds[0][0]), Math.exp(bounds[1][0]) ] ++// Could use `inherits` module, but don't want to move from single file ++// architecture yet. ++function inherits(ctor, superCtor) { ++ ctor.super_ = superCtor; ++ var TempCtor = function () {}; ++ TempCtor.prototype = superCtor.prototype; ++ ctor.prototype = new TempCtor(); ++ ctor.prototype.constructor = ctor; + } + +-proto.recalcMatrix = function(t) { +- //Recompute curves +- this.center.curve(t) +- this.up.curve(t) +- this.right.curve(t) +- this.radius.curve(t) +- this.angle.curve(t) ++// BN + +- //Compute frame for camera matrix +- var up = this.computedUp +- var right = this.computedRight +- var uu = 0.0 +- var ur = 0.0 +- for(var i=0; i<3; ++i) { +- ur += up[i] * right[i] +- uu += up[i] * up[i] +- } +- var ul = Math.sqrt(uu) +- var rr = 0.0 +- for(var i=0; i<3; ++i) { +- right[i] -= up[i] * ur / uu +- rr += right[i] * right[i] +- up[i] /= ul ++function BN(number, base, endian) { ++ // May be `new BN(bn)` ? ++ if (number !== null && ++ typeof number === 'object' && ++ Array.isArray(number.words)) { ++ return number; + } +- var rl = Math.sqrt(rr) +- for(var i=0; i<3; ++i) { +- right[i] /= rl ++ ++ this.sign = false; ++ this.words = null; ++ this.length = 0; ++ ++ // Reduction context ++ this.red = null; ++ ++ if (base === 'le' || base === 'be') { ++ endian = base; ++ base = 10; + } + +- //Compute toward vector +- var toward = this.computedToward +- cross(toward, up, right) +- normalize3(toward, toward) ++ if (number !== null) ++ this._init(number || 0, base || 10, endian || 'be'); ++} ++if (typeof module === 'object') ++ module.exports = BN; ++else ++ exports.BN = BN; + +- //Compute angular parameters +- var radius = Math.exp(this.computedRadius[0]) +- var theta = this.computedAngle[0] +- var phi = this.computedAngle[1] ++BN.BN = BN; ++BN.wordSize = 26; + +- var ctheta = Math.cos(theta) +- var stheta = Math.sin(theta) +- var cphi = Math.cos(phi) +- var sphi = Math.sin(phi) ++BN.prototype._init = function init(number, base, endian) { ++ if (typeof number === 'number') { ++ return this._initNumber(number, base, endian); ++ } else if (typeof number === 'object') { ++ return this._initArray(number, base, endian); ++ } ++ if (base === 'hex') ++ base = 16; ++ assert(base === (base | 0) && base >= 2 && base <= 36); + +- var center = this.computedCenter ++ number = number.toString().replace(/\s+/g, ''); ++ var start = 0; ++ if (number[0] === '-') ++ start++; + +- var wx = ctheta * cphi +- var wy = stheta * cphi +- var wz = sphi ++ if (base === 16) ++ this._parseHex(number, start); ++ else ++ this._parseBase(number, base, start); + +- var sx = -ctheta * sphi +- var sy = -stheta * sphi +- var sz = cphi ++ if (number[0] === '-') ++ this.sign = true; + +- var eye = this.computedEye +- var mat = this.computedMatrix +- for(var i=0; i<3; ++i) { +- var x = wx * right[i] + wy * toward[i] + wz * up[i] +- mat[4*i+1] = sx * right[i] + sy * toward[i] + sz * up[i] +- mat[4*i+2] = x +- mat[4*i+3] = 0.0 +- } ++ this.strip(); + +- var ax = mat[1] +- var ay = mat[5] +- var az = mat[9] +- var bx = mat[2] +- var by = mat[6] +- var bz = mat[10] +- var cx = ay * bz - az * by +- var cy = az * bx - ax * bz +- var cz = ax * by - ay * bx +- var cl = len3(cx, cy, cz) +- cx /= cl +- cy /= cl +- cz /= cl +- mat[0] = cx +- mat[4] = cy +- mat[8] = cz ++ if (endian !== 'le') ++ return; + +- for(var i=0; i<3; ++i) { +- eye[i] = center[i] + mat[2+4*i]*radius +- } ++ this._initArray(this.toArray(), base, endian); ++}; + +- for(var i=0; i<3; ++i) { +- var rr = 0.0 +- for(var j=0; j<3; ++j) { +- rr += mat[i+4*j] * eye[j] +- } +- mat[12+i] = -rr ++BN.prototype._initNumber = function _initNumber(number, base, endian) { ++ if (number < 0) { ++ this.sign = true; ++ number = -number; + } +- mat[15] = 1.0 +-} +- +-proto.getMatrix = function(t, result) { +- this.recalcMatrix(t) +- var mat = this.computedMatrix +- if(result) { +- for(var i=0; i<16; ++i) { +- result[i] = mat[i] +- } +- return result ++ if (number < 0x4000000) { ++ this.words = [ number & 0x3ffffff ]; ++ this.length = 1; ++ } else if (number < 0x10000000000000) { ++ this.words = [ ++ number & 0x3ffffff, ++ (number / 0x4000000) & 0x3ffffff ++ ]; ++ this.length = 2; ++ } else { ++ assert(number < 0x20000000000000); // 2 ^ 53 (unsafe) ++ this.words = [ ++ number & 0x3ffffff, ++ (number / 0x4000000) & 0x3ffffff, ++ 1 ++ ]; ++ this.length = 3; + } +- return mat +-} + +-var zAxis = [0,0,0] +-proto.rotate = function(t, dtheta, dphi, droll) { +- this.angle.move(t, dtheta, dphi) +- if(droll) { +- this.recalcMatrix(t) ++ if (endian !== 'le') ++ return; + +- var mat = this.computedMatrix +- zAxis[0] = mat[2] +- zAxis[1] = mat[6] +- zAxis[2] = mat[10] ++ // Reverse the bytes ++ this._initArray(this.toArray(), base, endian); ++}; + +- var up = this.computedUp +- var right = this.computedRight +- var toward = this.computedToward ++BN.prototype._initArray = function _initArray(number, base, endian) { ++ // Perhaps a Uint8Array ++ assert(typeof number.length === 'number'); ++ if (number.length <= 0) { ++ this.words = [ 0 ]; ++ this.length = 1; ++ return this; ++ } + +- for(var i=0; i<3; ++i) { +- mat[4*i] = up[i] +- mat[4*i+1] = right[i] +- mat[4*i+2] = toward[i] ++ this.length = Math.ceil(number.length / 3); ++ this.words = new Array(this.length); ++ for (var i = 0; i < this.length; i++) ++ this.words[i] = 0; ++ ++ var off = 0; ++ if (endian === 'be') { ++ for (var i = number.length - 1, j = 0; i >= 0; i -= 3) { ++ var w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16); ++ this.words[j] |= (w << off) & 0x3ffffff; ++ this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; ++ off += 24; ++ if (off >= 26) { ++ off -= 26; ++ j++; ++ } + } +- rotateM(mat, mat, droll, zAxis) +- for(var i=0; i<3; ++i) { +- up[i] = mat[4*i] +- right[i] = mat[4*i+1] ++ } else if (endian === 'le') { ++ for (var i = 0, j = 0; i < number.length; i += 3) { ++ var w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16); ++ this.words[j] |= (w << off) & 0x3ffffff; ++ this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; ++ off += 24; ++ if (off >= 26) { ++ off -= 26; ++ j++; ++ } + } +- +- this.up.set(t, up[0], up[1], up[2]) +- this.right.set(t, right[0], right[1], right[2]) + } +-} ++ return this.strip(); ++}; + +-proto.pan = function(t, dx, dy, dz) { +- dx = dx || 0.0 +- dy = dy || 0.0 +- dz = dz || 0.0 +- +- this.recalcMatrix(t) +- var mat = this.computedMatrix +- +- var dist = Math.exp(this.computedRadius[0]) ++function parseHex(str, start, end) { ++ var r = 0; ++ var len = Math.min(str.length, end); ++ for (var i = start; i < len; i++) { ++ var c = str.charCodeAt(i) - 48; + +- var ux = mat[1] +- var uy = mat[5] +- var uz = mat[9] +- var ul = len3(ux, uy, uz) +- ux /= ul +- uy /= ul +- uz /= ul ++ r <<= 4; + +- var rx = mat[0] +- var ry = mat[4] +- var rz = mat[8] +- var ru = rx * ux + ry * uy + rz * uz +- rx -= ux * ru +- ry -= uy * ru +- rz -= uz * ru +- var rl = len3(rx, ry, rz) +- rx /= rl +- ry /= rl +- rz /= rl ++ // 'a' - 'f' ++ if (c >= 49 && c <= 54) ++ r |= c - 49 + 0xa; + +- var vx = rx * dx + ux * dy +- var vy = ry * dx + uy * dy +- var vz = rz * dx + uz * dy +- this.center.move(t, vx, vy, vz) ++ // 'A' - 'F' ++ else if (c >= 17 && c <= 22) ++ r |= c - 17 + 0xa; + +- //Update z-component of radius +- var radius = Math.exp(this.computedRadius[0]) +- radius = Math.max(1e-4, radius + dz) +- this.radius.set(t, Math.log(radius)) ++ // '0' - '9' ++ else ++ r |= c & 0xf; ++ } ++ return r; + } + +-proto.translate = function(t, dx, dy, dz) { +- this.center.move(t, +- dx||0.0, +- dy||0.0, +- dz||0.0) +-} ++BN.prototype._parseHex = function _parseHex(number, start) { ++ // Create possibly bigger array to ensure that it fits the number ++ this.length = Math.ceil((number.length - start) / 6); ++ this.words = new Array(this.length); ++ for (var i = 0; i < this.length; i++) ++ this.words[i] = 0; + +-//Recenters the coordinate axes +-proto.setMatrix = function(t, mat, axes, noSnap) { +- +- //Get the axes for tare +- var ushift = 1 +- if(typeof axes === 'number') { +- ushift = (axes)|0 +- } +- if(ushift < 0 || ushift > 3) { +- ushift = 1 ++ // Scan 24-bit chunks and add them to the number ++ var off = 0; ++ for (var i = number.length - 6, j = 0; i >= start; i -= 6) { ++ var w = parseHex(number, i, i + 6); ++ this.words[j] |= (w << off) & 0x3ffffff; ++ this.words[j + 1] |= w >>> (26 - off) & 0x3fffff; ++ off += 24; ++ if (off >= 26) { ++ off -= 26; ++ j++; ++ } + } +- var vshift = (ushift + 2) % 3 +- var fshift = (ushift + 1) % 3 +- +- //Recompute state for new t value +- if(!mat) { +- this.recalcMatrix(t) +- mat = this.computedMatrix ++ if (i + 6 !== start) { ++ var w = parseHex(number, start, i + 6); ++ this.words[j] |= (w << off) & 0x3ffffff; ++ this.words[j + 1] |= w >>> (26 - off) & 0x3fffff; + } ++ this.strip(); ++}; + +- //Get right and up vectors +- var ux = mat[ushift] +- var uy = mat[ushift+4] +- var uz = mat[ushift+8] +- if(!noSnap) { +- var ul = len3(ux, uy, uz) +- ux /= ul +- uy /= ul +- uz /= ul +- } else { +- var ax = Math.abs(ux) +- var ay = Math.abs(uy) +- var az = Math.abs(uz) +- var am = Math.max(ax,ay,az) +- if(ax === am) { +- ux = (ux < 0) ? -1 : 1 +- uy = uz = 0 +- } else if(az === am) { +- uz = (uz < 0) ? -1 : 1 +- ux = uy = 0 +- } else { +- uy = (uy < 0) ? -1 : 1 +- ux = uz = 0 +- } +- } ++function parseBase(str, start, end, mul) { ++ var r = 0; ++ var len = Math.min(str.length, end); ++ for (var i = start; i < len; i++) { ++ var c = str.charCodeAt(i) - 48; + +- var rx = mat[vshift] +- var ry = mat[vshift+4] +- var rz = mat[vshift+8] +- var ru = rx * ux + ry * uy + rz * uz +- rx -= ux * ru +- ry -= uy * ru +- rz -= uz * ru +- var rl = len3(rx, ry, rz) +- rx /= rl +- ry /= rl +- rz /= rl +- +- var fx = uy * rz - uz * ry +- var fy = uz * rx - ux * rz +- var fz = ux * ry - uy * rx +- var fl = len3(fx, fy, fz) +- fx /= fl +- fy /= fl +- fz /= fl ++ r *= mul; + +- this.center.jump(t, ex, ey, ez) +- this.radius.idle(t) +- this.up.jump(t, ux, uy, uz) +- this.right.jump(t, rx, ry, rz) ++ // 'a' ++ if (c >= 49) ++ r += c - 49 + 0xa; + +- var phi, theta +- if(ushift === 2) { +- var cx = mat[1] +- var cy = mat[5] +- var cz = mat[9] +- var cr = cx * rx + cy * ry + cz * rz +- var cf = cx * fx + cy * fy + cz * fz +- if(tu < 0) { +- phi = -Math.PI/2 +- } else { +- phi = Math.PI/2 +- } +- theta = Math.atan2(cf, cr) +- } else { +- var tx = mat[2] +- var ty = mat[6] +- var tz = mat[10] +- var tu = tx * ux + ty * uy + tz * uz +- var tr = tx * rx + ty * ry + tz * rz +- var tf = tx * fx + ty * fy + tz * fz ++ // 'A' ++ else if (c >= 17) ++ r += c - 17 + 0xa; + +- phi = Math.asin(clamp1(tu)) +- theta = Math.atan2(tf, tr) ++ // '0' - '9' ++ else ++ r += c; + } +- +- this.angle.jump(t, theta, phi) +- +- this.recalcMatrix(t) +- var dx = mat[2] +- var dy = mat[6] +- var dz = mat[10] +- +- var imat = this.computedMatrix +- invert44(imat, mat) +- var w = imat[15] +- var ex = imat[12] / w +- var ey = imat[13] / w +- var ez = imat[14] / w +- +- var gs = Math.exp(this.computedRadius[0]) +- this.center.jump(t, ex-dx*gs, ey-dy*gs, ez-dz*gs) ++ return r; + } + +-proto.lastT = function() { +- return Math.max( +- this.center.lastT(), +- this.up.lastT(), +- this.right.lastT(), +- this.radius.lastT(), +- this.angle.lastT()) +-} ++BN.prototype._parseBase = function _parseBase(number, base, start) { ++ // Initialize as zero ++ this.words = [ 0 ]; ++ this.length = 1; + +-proto.idle = function(t) { +- this.center.idle(t) +- this.up.idle(t) +- this.right.idle(t) +- this.radius.idle(t) +- this.angle.idle(t) +-} ++ // Find length of limb in base ++ for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) ++ limbLen++; ++ limbLen--; ++ limbPow = (limbPow / base) | 0; + +-proto.flush = function(t) { +- this.center.flush(t) +- this.up.flush(t) +- this.right.flush(t) +- this.radius.flush(t) +- this.angle.flush(t) +-} ++ var total = number.length - start; ++ var mod = total % limbLen; ++ var end = Math.min(total, total - mod) + start; + +-proto.setDistance = function(t, d) { +- if(d > 0) { +- this.radius.set(t, Math.log(d)) +- } +-} ++ var word = 0; ++ for (var i = start; i < end; i += limbLen) { ++ word = parseBase(number, i, i + limbLen, base); + +-proto.lookAt = function(t, eye, center, up) { +- this.recalcMatrix(t) ++ this.imuln(limbPow); ++ if (this.words[0] + word < 0x4000000) ++ this.words[0] += word; ++ else ++ this._iaddn(word); ++ } + +- eye = eye || this.computedEye +- center = center || this.computedCenter +- up = up || this.computedUp ++ if (mod !== 0) { ++ var pow = 1; ++ var word = parseBase(number, i, number.length, base); + +- var ux = up[0] +- var uy = up[1] +- var uz = up[2] +- var ul = len3(ux, uy, uz) +- if(ul < 1e-6) { +- return ++ for (var i = 0; i < mod; i++) ++ pow *= base; ++ this.imuln(pow); ++ if (this.words[0] + word < 0x4000000) ++ this.words[0] += word; ++ else ++ this._iaddn(word); + } +- ux /= ul +- uy /= ul +- uz /= ul ++}; + +- var tx = eye[0] - center[0] +- var ty = eye[1] - center[1] +- var tz = eye[2] - center[2] +- var tl = len3(tx, ty, tz) +- if(tl < 1e-6) { +- return +- } +- tx /= tl +- ty /= tl +- tz /= tl ++BN.prototype.copy = function copy(dest) { ++ dest.words = new Array(this.length); ++ for (var i = 0; i < this.length; i++) ++ dest.words[i] = this.words[i]; ++ dest.length = this.length; ++ dest.sign = this.sign; ++ dest.red = this.red; ++}; + +- var right = this.computedRight +- var rx = right[0] +- var ry = right[1] +- var rz = right[2] +- var ru = ux*rx + uy*ry + uz*rz +- rx -= ru * ux +- ry -= ru * uy +- rz -= ru * uz +- var rl = len3(rx, ry, rz) ++BN.prototype.clone = function clone() { ++ var r = new BN(null); ++ this.copy(r); ++ return r; ++}; + +- if(rl < 0.01) { +- rx = uy * tz - uz * ty +- ry = uz * tx - ux * tz +- rz = ux * ty - uy * tx +- rl = len3(rx, ry, rz) +- if(rl < 1e-6) { +- return +- } +- } +- rx /= rl +- ry /= rl +- rz /= rl ++// Remove leading `0` from `this` ++BN.prototype.strip = function strip() { ++ while (this.length > 1 && this.words[this.length - 1] === 0) ++ this.length--; ++ return this._normSign(); ++}; + +- this.up.set(t, ux, uy, uz) +- this.right.set(t, rx, ry, rz) +- this.center.set(t, center[0], center[1], center[2]) +- this.radius.set(t, Math.log(tl)) ++BN.prototype._normSign = function _normSign() { ++ // -0 = 0 ++ if (this.length === 1 && this.words[0] === 0) ++ this.sign = false; ++ return this; ++}; + +- var fx = uy * rz - uz * ry +- var fy = uz * rx - ux * rz +- var fz = ux * ry - uy * rx +- var fl = len3(fx, fy, fz) +- fx /= fl +- fy /= fl +- fz /= fl ++BN.prototype.inspect = function inspect() { ++ return (this.red ? ''; ++}; + +- var tu = ux*tx + uy*ty + uz*tz +- var tr = rx*tx + ry*ty + rz*tz +- var tf = fx*tx + fy*ty + fz*tz ++/* + +- var phi = Math.asin(clamp1(tu)) +- var theta = Math.atan2(tf, tr) ++var zeros = []; ++var groupSizes = []; ++var groupBases = []; + +- var angleState = this.angle._state +- var lastTheta = angleState[angleState.length-1] +- var lastPhi = angleState[angleState.length-2] +- lastTheta = lastTheta % (2.0 * Math.PI) +- var dp = Math.abs(lastTheta + 2.0 * Math.PI - theta) +- var d0 = Math.abs(lastTheta - theta) +- var dn = Math.abs(lastTheta - 2.0 * Math.PI - theta) +- if(dp < d0) { +- lastTheta += 2.0 * Math.PI +- } +- if(dn < d0) { +- lastTheta -= 2.0 * Math.PI ++var s = ''; ++var i = -1; ++while (++i < BN.wordSize) { ++ zeros[i] = s; ++ s += '0'; ++} ++groupSizes[0] = 0; ++groupSizes[1] = 0; ++groupBases[0] = 0; ++groupBases[1] = 0; ++var base = 2 - 1; ++while (++base < 36 + 1) { ++ var groupSize = 0; ++ var groupBase = 1; ++ while (groupBase < (1 << BN.wordSize) / base) { ++ groupBase *= base; ++ groupSize += 1; + } +- +- this.angle.jump(this.angle.lastT(), lastTheta, lastPhi) +- this.angle.set(t, theta, phi) ++ groupSizes[base] = groupSize; ++ groupBases[base] = groupBase; + } + +-function createTurntableController(options) { +- options = options || {} +- +- var center = options.center || [0,0,0] +- var up = options.up || [0,1,0] +- var right = options.right || findOrthoPair(up) +- var radius = options.radius || 1.0 +- var theta = options.theta || 0.0 +- var phi = options.phi || 0.0 ++*/ + +- center = [].slice.call(center, 0, 3) ++var zeros = [ ++ '', ++ '0', ++ '00', ++ '000', ++ '0000', ++ '00000', ++ '000000', ++ '0000000', ++ '00000000', ++ '000000000', ++ '0000000000', ++ '00000000000', ++ '000000000000', ++ '0000000000000', ++ '00000000000000', ++ '000000000000000', ++ '0000000000000000', ++ '00000000000000000', ++ '000000000000000000', ++ '0000000000000000000', ++ '00000000000000000000', ++ '000000000000000000000', ++ '0000000000000000000000', ++ '00000000000000000000000', ++ '000000000000000000000000', ++ '0000000000000000000000000' ++]; + +- up = [].slice.call(up, 0, 3) +- normalize3(up, up) ++var groupSizes = [ ++ 0, 0, ++ 25, 16, 12, 11, 10, 9, 8, ++ 8, 7, 7, 7, 7, 6, 6, ++ 6, 6, 6, 6, 6, 5, 5, ++ 5, 5, 5, 5, 5, 5, 5, ++ 5, 5, 5, 5, 5, 5, 5 ++]; + +- right = [].slice.call(right, 0, 3) +- normalize3(right, right) ++var groupBases = [ ++ 0, 0, ++ 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, ++ 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625, ++ 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632, ++ 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, ++ 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176 ++]; + +- if('eye' in options) { +- var eye = options.eye +- var toward = [ +- eye[0]-center[0], +- eye[1]-center[1], +- eye[2]-center[2] +- ] +- cross(right, toward, up) +- if(len3(right[0], right[1], right[2]) < 1e-6) { +- right = findOrthoPair(up) +- } else { +- normalize3(right, right) ++BN.prototype.toString = function toString(base, padding) { ++ base = base || 10; ++ if (base === 16 || base === 'hex') { ++ var out = ''; ++ var off = 0; ++ var padding = padding | 0 || 1; ++ var carry = 0; ++ for (var i = 0; i < this.length; i++) { ++ var w = this.words[i]; ++ var word = (((w << off) | carry) & 0xffffff).toString(16); ++ carry = (w >>> (24 - off)) & 0xffffff; ++ if (carry !== 0 || i !== this.length - 1) ++ out = zeros[6 - word.length] + word + out; ++ else ++ out = word + out; ++ off += 2; ++ if (off >= 26) { ++ off -= 26; ++ i--; ++ } + } ++ if (carry !== 0) ++ out = carry.toString(16) + out; ++ while (out.length % padding !== 0) ++ out = '0' + out; ++ if (this.sign) ++ out = '-' + out; ++ return out; ++ } else if (base === (base | 0) && base >= 2 && base <= 36) { ++ // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base)); ++ var groupSize = groupSizes[base]; ++ // var groupBase = Math.pow(base, groupSize); ++ var groupBase = groupBases[base]; ++ var out = ''; ++ var c = this.clone(); ++ c.sign = false; ++ while (c.cmpn(0) !== 0) { ++ var r = c.modn(groupBase).toString(base); ++ c = c.idivn(groupBase); + +- radius = len3(toward[0], toward[1], toward[2]) +- +- var ut = dot3(up, toward) / radius +- var rt = dot3(right, toward) / radius +- phi = Math.acos(ut) +- theta = Math.acos(rt) ++ if (c.cmpn(0) !== 0) ++ out = zeros[groupSize - r.length] + r + out; ++ else ++ out = r + out; ++ } ++ if (this.cmpn(0) === 0) ++ out = '0' + out; ++ if (this.sign) ++ out = '-' + out; ++ return out; ++ } else { ++ assert(false, 'Base should be between 2 and 36'); + } ++}; + +- //Use logarithmic coordinates for radius +- radius = Math.log(radius) +- +- //Return the controller +- return new TurntableController( +- options.zoomMin, +- options.zoomMax, +- center, +- up, +- right, +- radius, +- theta, +- phi) +-} +-},{"filtered-vector":8,"gl-mat4/invert":120,"gl-mat4/rotate":124,"gl-vec3/cross":11,"gl-vec3/dot":12,"gl-vec3/normalize":15}],27:[function(require,module,exports){ +-'use strict' +- +-module.exports = createViewController +- +-var createTurntable = require('turntable-camera-controller') +-var createOrbit = require('orbit-camera-controller') +-var createMatrix = require('matrix-camera-controller') ++BN.prototype.toJSON = function toJSON() { ++ return this.toString(16); ++}; + +-function ViewController(controllers, mode) { +- this._controllerNames = Object.keys(controllers) +- this._controllerList = this._controllerNames.map(function(n) { +- return controllers[n] +- }) +- this._mode = mode +- this._active = controllers[mode] +- if(!this._active) { +- this._mode = 'turntable' +- this._active = controllers.turntable +- } +- this.modes = this._controllerNames +- this.computedMatrix = this._active.computedMatrix +- this.computedEye = this._active.computedEye +- this.computedUp = this._active.computedUp +- this.computedCenter = this._active.computedCenter +- this.computedRadius = this._active.computedRadius +-} ++BN.prototype.toArray = function toArray(endian) { ++ this.strip(); ++ var res = new Array(this.byteLength()); ++ res[0] = 0; + +-var proto = ViewController.prototype ++ var q = this.clone(); ++ if (endian !== 'le') { ++ // Assume big-endian ++ for (var i = 0; q.cmpn(0) !== 0; i++) { ++ var b = q.andln(0xff); ++ q.ishrn(8); + +-var COMMON_METHODS = [ +- ['flush', 1], +- ['idle', 1], +- ['lookAt', 4], +- ['rotate', 4], +- ['pan', 4], +- ['translate', 4], +- ['setMatrix', 2], +- ['setDistanceLimits', 2], +- ['setDistance', 2] +-] ++ res[res.length - i - 1] = b; ++ } ++ } else { ++ // Assume little-endian ++ for (var i = 0; q.cmpn(0) !== 0; i++) { ++ var b = q.andln(0xff); ++ q.ishrn(8); + +-COMMON_METHODS.forEach(function(method) { +- var name = method[0] +- var argNames = [] +- for(var i=0; i= 0x1000) { ++ r += 13; ++ t >>>= 13; ++ } ++ if (t >= 0x40) { ++ r += 7; ++ t >>>= 7; ++ } ++ if (t >= 0x8) { ++ r += 4; ++ t >>>= 4; ++ } ++ if (t >= 0x02) { ++ r += 2; ++ t >>>= 2; ++ } ++ return r + t; ++ }; + } + +-proto.lastT = function() { +- return this._active.lastT() +-} ++BN.prototype._zeroBits = function _zeroBits(w) { ++ // Short-cut ++ if (w === 0) ++ return 26; + +-proto.setMode = function(mode) { +- if(mode === this._mode) { +- return ++ var t = w; ++ var r = 0; ++ if ((t & 0x1fff) === 0) { ++ r += 13; ++ t >>>= 13; + } +- var idx = this._controllerNames.indexOf(mode) +- if(idx < 0) { +- return ++ if ((t & 0x7f) === 0) { ++ r += 7; ++ t >>>= 7; + } +- var prev = this._active +- var next = this._controllerList[idx] +- var lastT = Math.max(prev.lastT(), next.lastT()) +- +- prev.recalcMatrix(lastT) +- next.setMatrix(lastT, prev.computedMatrix) +- +- this._active = next +- this._mode = mode +- +- //Update matrix properties +- this.computedMatrix = this._active.computedMatrix +- this.computedEye = this._active.computedEye +- this.computedUp = this._active.computedUp +- this.computedCenter = this._active.computedCenter +- this.computedRadius = this._active.computedRadius +-} +- +-proto.getMode = function() { +- return this._mode +-} +- +-function createViewController(options) { +- options = options || {} +- +- var eye = options.eye || [0,0,1] +- var center = options.center || [0,0,0] +- var up = options.up || [0,1,0] +- var limits = options.distanceLimits || [0, Infinity] +- var mode = options.mode || 'turntable' ++ if ((t & 0xf) === 0) { ++ r += 4; ++ t >>>= 4; ++ } ++ if ((t & 0x3) === 0) { ++ r += 2; ++ t >>>= 2; ++ } ++ if ((t & 0x1) === 0) ++ r++; ++ return r; ++}; + +- var turntable = createTurntable() +- var orbit = createOrbit() +- var matrix = createMatrix() ++// Return number of used bits in a BN ++BN.prototype.bitLength = function bitLength() { ++ var hi = 0; ++ var w = this.words[this.length - 1]; ++ var hi = this._countBits(w); ++ return (this.length - 1) * 26 + hi; ++}; + +- turntable.setDistanceLimits(limits[0], limits[1]) +- turntable.lookAt(0, eye, center, up) +- orbit.setDistanceLimits(limits[0], limits[1]) +- orbit.lookAt(0, eye, center, up) +- matrix.setDistanceLimits(limits[0], limits[1]) +- matrix.lookAt(0, eye, center, up) ++// Number of trailing zero bits ++BN.prototype.zeroBits = function zeroBits() { ++ if (this.cmpn(0) === 0) ++ return 0; + +- return new ViewController({ +- turntable: turntable, +- orbit: orbit, +- matrix: matrix +- }, mode) +-} +-},{"matrix-camera-controller":16,"orbit-camera-controller":25,"turntable-camera-controller":26}],28:[function(require,module,exports){ +-module.exports = alphaShape ++ var r = 0; ++ for (var i = 0; i < this.length; i++) { ++ var b = this._zeroBits(this.words[i]); ++ r += b; ++ if (b !== 26) ++ break; ++ } ++ return r; ++}; + +-var ac = require('alpha-complex') +-var bnd = require('simplicial-complex-boundary') ++BN.prototype.byteLength = function byteLength() { ++ return Math.ceil(this.bitLength() / 8); ++}; + +-function alphaShape(alpha, points) { +- return bnd(ac(alpha, points)) +-} +-},{"alpha-complex":29,"simplicial-complex-boundary":32}],29:[function(require,module,exports){ +-'use strict' ++// Return negative clone of `this` ++BN.prototype.neg = function neg() { ++ if (this.cmpn(0) === 0) ++ return this.clone(); + +-module.exports = alphaComplex ++ var r = this.clone(); ++ r.sign = !this.sign; ++ return r; ++}; + +-var delaunay = require('delaunay-triangulate') +-var circumradius = require('circumradius') + +-function alphaComplex(alpha, points) { +- return delaunay(points).filter(function(cell) { +- var simplex = new Array(cell.length) +- for(var i=0; i num.length) ++ return this.clone().ior(num); ++ else ++ return num.clone().ior(this); ++}; + +- var denom = 0.0 +- var h = x[N+1] +- for(var i=0; i num.length) ++ b = num; ++ else ++ b = this; + +-function circumcenter(points) { +- if(points.length === 0) { +- return [] +- } +- var D = points[0].length +- var result = dup([D]) +- var weights = barycentricCircumcenter(points) +- for(var i=0; i num.length) ++ return this.clone().iand(num); ++ else ++ return num.clone().iand(this); ++}; + +-},{"boundary-cells":33,"reduce-simplicial-complex":36}],33:[function(require,module,exports){ +-"use strict" + +-module.exports = boundary ++// Xor `num` with `this` in-place ++BN.prototype.ixor = function ixor(num) { ++ this.sign = this.sign || num.sign; + +-function boundary(cells) { +- var n = cells.length +- var sz = 0 +- for(var i=0; i b.length ++ var a; ++ var b; ++ if (this.length > num.length) { ++ a = this; ++ b = num; ++ } else { ++ a = num; ++ b = this; + } +- return result +-} +- +-},{}],34:[function(require,module,exports){ +-'use strict' + +-module.exports = orientation ++ for (var i = 0; i < b.length; i++) ++ this.words[i] = a.words[i] ^ b.words[i]; + +-function orientation(s) { +- var p = 1 +- for(var i=1; i num.length) ++ return this.clone().ixor(num); ++ else ++ return num.clone().ixor(this); ++}; + +-},{"cell-orientation":34,"compare-cell":89}],36:[function(require,module,exports){ +-'use strict' + +-var compareCell = require('compare-cell') +-var compareOrientedCell = require('compare-oriented-cell') +-var orientation = require('cell-orientation') ++// Set `bit` of `this` ++BN.prototype.setn = function setn(bit, val) { ++ assert(typeof bit === 'number' && bit >= 0); + +-module.exports = reduceCellComplex ++ var off = (bit / 26) | 0; ++ var wbit = bit % 26; + +-function reduceCellComplex(cells) { +- cells.sort(compareOrientedCell) +- var n = cells.length +- var ptr = 0 +- for(var i=0; i 0) { +- var f = cells[ptr-1] +- if(compareCell(c, f) === 0 && +- orientation(f) !== o) { +- ptr -= 1 +- continue +- } +- } +- cells[ptr++] = c +- } +- cells.length = ptr +- return cells +-} ++ while (this.length <= off) ++ this.words[this.length++] = 0; + +-},{"cell-orientation":34,"compare-cell":89,"compare-oriented-cell":35}],37:[function(require,module,exports){ +-'use strict'; ++ if (val) ++ this.words[off] = this.words[off] | (1 << wbit); ++ else ++ this.words[off] = this.words[off] & ~(1 << wbit); + +-var arraytools = function () { ++ return this.strip(); ++}; + +- var that = {}; + +- var RGB_REGEX = /^rgba?\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*(,.*)?\)$/; +- var RGB_GROUP_REGEX = /^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,?\s*(.*)?\)$/; ++// Add `num` to `this` in-place ++BN.prototype.iadd = function iadd(num) { ++ // negative + positive ++ if (this.sign && !num.sign) { ++ this.sign = false; ++ var r = this.isub(num); ++ this.sign = !this.sign; ++ return this._normSign(); + +- function isPlainObject (v) { +- return !Array.isArray(v) && v !== null && typeof v === 'object'; ++ // positive + negative ++ } else if (!this.sign && num.sign) { ++ num.sign = false; ++ var r = this.isub(num); ++ num.sign = true; ++ return r._normSign(); + } + +- function linspace (start, end, num) { +- var inc = (end - start) / Math.max(num - 1, 1); +- var a = []; +- for( var ii = 0; ii < num; ii++) +- a.push(start + ii*inc); +- return a; ++ // a.length > b.length ++ var a; ++ var b; ++ if (this.length > num.length) { ++ a = this; ++ b = num; ++ } else { ++ a = num; ++ b = this; + } + +- function zip () { +- var arrays = [].slice.call(arguments); +- var lengths = arrays.map(function (a) {return a.length;}); +- var len = Math.min.apply(null, lengths); +- var zipped = []; +- for (var i = 0; i < len; i++) { +- zipped[i] = []; +- for (var j = 0; j < arrays.length; ++j) { +- zipped[i][j] = arrays[j][i]; +- } +- } +- return zipped; ++ var carry = 0; ++ for (var i = 0; i < b.length; i++) { ++ var r = a.words[i] + b.words[i] + carry; ++ this.words[i] = r & 0x3ffffff; ++ carry = r >>> 26; + } +- +- function zip3 (a, b, c) { +- var len = Math.min.apply(null, [a.length, b.length, c.length]); +- var result = []; +- for (var n = 0; n < len; n++) { +- result.push([a[n], b[n], c[n]]); +- } +- return result; ++ for (; carry !== 0 && i < a.length; i++) { ++ var r = a.words[i] + carry; ++ this.words[i] = r & 0x3ffffff; ++ carry = r >>> 26; + } + +- function sum (A) { +- var acc = 0; +- accumulate(A, acc); +- function accumulate(x) { +- for (var i = 0; i < x.length; i++) { +- if (Array.isArray(x[i])) +- accumulate(x[i], acc); +- else +- acc += x[i]; +- } +- } +- return acc; ++ this.length = a.length; ++ if (carry !== 0) { ++ this.words[this.length] = carry; ++ this.length++; ++ // Copy the rest of the words ++ } else if (a !== this) { ++ for (; i < a.length; i++) ++ this.words[i] = a.words[i]; + } + +- function copy2D (arr) { +- var carr = []; +- for (var i = 0; i < arr.length; ++i) { +- carr[i] = []; +- for (var j = 0; j < arr[i].length; ++j) { +- carr[i][j] = arr[i][j]; +- } +- } ++ return this; ++}; + +- return carr; ++// Add `num` to `this` ++BN.prototype.add = function add(num) { ++ if (num.sign && !this.sign) { ++ num.sign = false; ++ var res = this.sub(num); ++ num.sign = true; ++ return res; ++ } else if (!num.sign && this.sign) { ++ this.sign = false; ++ var res = num.sub(this); ++ this.sign = true; ++ return res; + } + ++ if (this.length > num.length) ++ return this.clone().iadd(num); ++ else ++ return num.clone().iadd(this); ++}; + +- function copy1D (arr) { +- var carr = []; +- for (var i = 0; i < arr.length; ++i) { +- carr[i] = arr[i]; +- } ++// Subtract `num` from `this` in-place ++BN.prototype.isub = function isub(num) { ++ // this - (-num) = this + num ++ if (num.sign) { ++ num.sign = false; ++ var r = this.iadd(num); ++ num.sign = true; ++ return r._normSign(); + +- return carr; ++ // -this - num = -(this + num) ++ } else if (this.sign) { ++ this.sign = false; ++ this.iadd(num); ++ this.sign = true; ++ return this._normSign(); + } + ++ // At this point both numbers are positive ++ var cmp = this.cmp(num); + +- function isEqual(arr1, arr2) { +- if(arr1.length !== arr2.length) +- return false; +- for(var i = arr1.length; i--;) { +- if(arr1[i] !== arr2[i]) +- return false; +- } ++ // Optimization - zeroify ++ if (cmp === 0) { ++ this.sign = false; ++ this.length = 1; ++ this.words[0] = 0; ++ return this; ++ } + +- return true; ++ // a > b ++ var a; ++ var b; ++ if (cmp > 0) { ++ a = this; ++ b = num; ++ } else { ++ a = num; ++ b = this; + } + ++ var carry = 0; ++ for (var i = 0; i < b.length; i++) { ++ var r = a.words[i] - b.words[i] + carry; ++ carry = r >> 26; ++ this.words[i] = r & 0x3ffffff; ++ } ++ for (; carry !== 0 && i < a.length; i++) { ++ var r = a.words[i] + carry; ++ carry = r >> 26; ++ this.words[i] = r & 0x3ffffff; ++ } + +- function str2RgbArray(str, twoFiftySix) { +- // convert hex or rbg strings to 0->1 or 0->255 rgb array +- var rgb, +- match; ++ // Copy rest of the words ++ if (carry === 0 && i < a.length && a !== this) ++ for (; i < a.length; i++) ++ this.words[i] = a.words[i]; ++ this.length = Math.max(this.length, i); + +- if (typeof str !== 'string') return str; ++ if (a !== this) ++ this.sign = true; + +- rgb = []; +- // hex notation +- if (str[0] === '#') { +- str = str.substr(1) // remove hash +- if (str.length === 3) str += str // fff -> ffffff +- match = parseInt(str, 16); +- rgb[0] = ((match >> 16) & 255); +- rgb[1] = ((match >> 8) & 255); +- rgb[2] = (match & 255); +- } ++ return this.strip(); ++}; + +- // rgb(34, 34, 127) or rgba(34, 34, 127, 0.1) notation +- else if (RGB_REGEX.test(str)) { +- match = str.match(RGB_GROUP_REGEX); +- rgb[0] = parseInt(match[1]); +- rgb[1] = parseInt(match[2]); +- rgb[2] = parseInt(match[3]); +- } ++// Subtract `num` from `this` ++BN.prototype.sub = function sub(num) { ++ return this.clone().isub(num); ++}; + +- if (!twoFiftySix) { +- for (var j=0; j<3; ++j) rgb[j] = rgb[j]/255 +- } ++/* ++// NOTE: This could be potentionally used to generate loop-less multiplications ++function _genCombMulTo(alen, blen) { ++ var len = alen + blen - 1; ++ var src = [ ++ 'var a = this.words, b = num.words, o = out.words, c = 0, w, ' + ++ 'mask = 0x3ffffff, shift = 0x4000000;', ++ 'out.length = ' + len + ';' ++ ]; ++ for (var k = 0; k < len; k++) { ++ var minJ = Math.max(0, k - alen + 1); ++ var maxJ = Math.min(k, blen - 1); + ++ for (var j = minJ; j <= maxJ; j++) { ++ var i = k - j; ++ var mul = 'a[' + i + '] * b[' + j + ']'; + +- return rgb; ++ if (j === minJ) { ++ src.push('w = ' + mul + ' + c;'); ++ src.push('c = (w / shift) | 0;'); ++ } else { ++ src.push('w += ' + mul + ';'); ++ src.push('c += (w / shift) | 0;'); ++ } ++ src.push('w &= mask;'); ++ } ++ src.push('o[' + k + '] = w;'); + } ++ src.push('if (c !== 0) {', ++ ' o[' + k + '] = c;', ++ ' out.length++;', ++ '}', ++ 'return out;'); + ++ return src.join('\n'); ++} ++*/ + +- function str2RgbaArray(str, twoFiftySix) { +- // convert hex or rbg strings to 0->1 or 0->255 rgb array +- var rgb, +- match; ++BN.prototype._smallMulTo = function _smallMulTo(num, out) { ++ out.sign = num.sign !== this.sign; ++ out.length = this.length + num.length; + +- if (typeof str !== 'string') return str; ++ var carry = 0; ++ for (var k = 0; k < out.length - 1; k++) { ++ // Sum all words with the same `i + j = k` and accumulate `ncarry`, ++ // note that ncarry could be >= 0x3ffffff ++ var ncarry = carry >>> 26; ++ var rword = carry & 0x3ffffff; ++ var maxJ = Math.min(k, num.length - 1); ++ for (var j = Math.max(0, k - this.length + 1); j <= maxJ; j++) { ++ var i = k - j; ++ var a = this.words[i] | 0; ++ var b = num.words[j] | 0; ++ var r = a * b; + +- rgb = []; +- // hex notation +- if (str[0] === '#') { +- str = str.substr(1) // remove hash +- if (str.length === 3) str += str // fff -> ffffff +- match = parseInt(str, 16); +- rgb[0] = ((match >> 16) & 255); +- rgb[1] = ((match >> 8) & 255); +- rgb[2] = (match & 255); ++ var lo = r & 0x3ffffff; ++ ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0; ++ lo = (lo + rword) | 0; ++ rword = lo & 0x3ffffff; ++ ncarry = (ncarry + (lo >>> 26)) | 0; + } ++ out.words[k] = rword; ++ carry = ncarry; ++ } ++ if (carry !== 0) { ++ out.words[k] = carry; ++ } else { ++ out.length--; ++ } + +- // rgb(34, 34, 127) or rgba(34, 34, 127, 0.1) notation +- else if (RGB_REGEX.test(str)) { +- match = str.match(RGB_GROUP_REGEX); +- rgb[0] = parseInt(match[1]); +- rgb[1] = parseInt(match[2]); +- rgb[2] = parseInt(match[3]); +- if (match[4]) rgb[3] = parseFloat(match[4]); +- else rgb[3] = 1.0; +- } ++ return out.strip(); ++}; ++ ++BN.prototype._bigMulTo = function _bigMulTo(num, out) { ++ out.sign = num.sign !== this.sign; ++ out.length = this.length + num.length; + ++ var carry = 0; ++ var hncarry = 0; ++ for (var k = 0; k < out.length - 1; k++) { ++ // Sum all words with the same `i + j = k` and accumulate `ncarry`, ++ // note that ncarry could be >= 0x3ffffff ++ var ncarry = hncarry; ++ hncarry = 0; ++ var rword = carry & 0x3ffffff; ++ var maxJ = Math.min(k, num.length - 1); ++ for (var j = Math.max(0, k - this.length + 1); j <= maxJ; j++) { ++ var i = k - j; ++ var a = this.words[i] | 0; ++ var b = num.words[j] | 0; ++ var r = a * b; + ++ var lo = r & 0x3ffffff; ++ ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0; ++ lo = (lo + rword) | 0; ++ rword = lo & 0x3ffffff; ++ ncarry = (ncarry + (lo >>> 26)) | 0; + +- if (!twoFiftySix) { +- for (var j=0; j<3; ++j) rgb[j] = rgb[j]/255 ++ hncarry += ncarry >>> 26; ++ ncarry &= 0x3ffffff; + } ++ out.words[k] = rword; ++ carry = ncarry; ++ ncarry = hncarry; ++ } ++ if (carry !== 0) { ++ out.words[k] = carry; ++ } else { ++ out.length--; ++ } + ++ return out.strip(); ++}; + +- return rgb; +- } ++BN.prototype.mulTo = function mulTo(num, out) { ++ var res; ++ if (this.length + num.length < 63) ++ res = this._smallMulTo(num, out); ++ else ++ res = this._bigMulTo(num, out); ++ return res; ++}; + ++// Multiply `this` by `num` ++BN.prototype.mul = function mul(num) { ++ var out = new BN(null); ++ out.words = new Array(this.length + num.length); ++ return this.mulTo(num, out); ++}; + ++// In-place Multiplication ++BN.prototype.imul = function imul(num) { ++ if (this.cmpn(0) === 0 || num.cmpn(0) === 0) { ++ this.words[0] = 0; ++ this.length = 1; ++ return this; ++ } + ++ var tlen = this.length; ++ var nlen = num.length; + ++ this.sign = num.sign !== this.sign; ++ this.length = this.length + num.length; ++ this.words[this.length - 1] = 0; + +- that.isPlainObject = isPlainObject; +- that.linspace = linspace; +- that.zip3 = zip3; +- that.sum = sum; +- that.zip = zip; +- that.isEqual = isEqual; +- that.copy2D = copy2D; +- that.copy1D = copy1D; +- that.str2RgbArray = str2RgbArray; +- that.str2RgbaArray = str2RgbaArray; ++ for (var k = this.length - 2; k >= 0; k--) { ++ // Sum all words with the same `i + j = k` and accumulate `carry`, ++ // note that carry could be >= 0x3ffffff ++ var carry = 0; ++ var rword = 0; ++ var maxJ = Math.min(k, nlen - 1); ++ for (var j = Math.max(0, k - tlen + 1); j <= maxJ; j++) { ++ var i = k - j; ++ var a = this.words[i]; ++ var b = num.words[j]; ++ var r = a * b; + +- return that ++ var lo = r & 0x3ffffff; ++ carry += (r / 0x4000000) | 0; ++ lo += rword; ++ rword = lo & 0x3ffffff; ++ carry += lo >>> 26; ++ } ++ this.words[k] = rword; ++ this.words[k + 1] += carry; ++ carry = 0; ++ } + +-} ++ // Propagate overflows ++ var carry = 0; ++ for (var i = 1; i < this.length; i++) { ++ var w = this.words[i] + carry; ++ this.words[i] = w & 0x3ffffff; ++ carry = w >>> 26; ++ } + ++ return this.strip(); ++}; + +-module.exports = arraytools(); ++BN.prototype.imuln = function imuln(num) { ++ assert(typeof num === 'number'); + +-},{}],38:[function(require,module,exports){ +-/** +- * Bit twiddling hacks for JavaScript. +- * +- * Author: Mikola Lysenko +- * +- * Ported from Stanford bit twiddling hack library: +- * http://graphics.stanford.edu/~seander/bithacks.html +- */ ++ // Carry ++ var carry = 0; ++ for (var i = 0; i < this.length; i++) { ++ var w = this.words[i] * num; ++ var lo = (w & 0x3ffffff) + (carry & 0x3ffffff); ++ carry >>= 26; ++ carry += (w / 0x4000000) | 0; ++ // NOTE: lo is 27bit maximum ++ carry += lo >>> 26; ++ this.words[i] = lo & 0x3ffffff; ++ } + +-"use strict"; "use restrict"; ++ if (carry !== 0) { ++ this.words[i] = carry; ++ this.length++; ++ } + +-//Number of bits in an integer +-var INT_BITS = 32; ++ return this; ++}; + +-//Constants +-exports.INT_BITS = INT_BITS; +-exports.INT_MAX = 0x7fffffff; +-exports.INT_MIN = -1<<(INT_BITS-1); ++BN.prototype.muln = function muln(num) { ++ return this.clone().imuln(num); ++}; + +-//Returns -1, 0, +1 depending on sign of x +-exports.sign = function(v) { +- return (v > 0) - (v < 0); +-} ++// `this` * `this` ++BN.prototype.sqr = function sqr() { ++ return this.mul(this); ++}; + +-//Computes absolute value of integer +-exports.abs = function(v) { +- var mask = v >> (INT_BITS-1); +- return (v ^ mask) - mask; +-} ++// `this` * `this` in-place ++BN.prototype.isqr = function isqr() { ++ return this.mul(this); ++}; + +-//Computes minimum of integers x and y +-exports.min = function(x, y) { +- return y ^ ((x ^ y) & -(x < y)); +-} ++// Shift-left in-place ++BN.prototype.ishln = function ishln(bits) { ++ assert(typeof bits === 'number' && bits >= 0); ++ var r = bits % 26; ++ var s = (bits - r) / 26; ++ var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r); + +-//Computes maximum of integers x and y +-exports.max = function(x, y) { +- return x ^ ((x ^ y) & -(x < y)); +-} ++ if (r !== 0) { ++ var carry = 0; ++ for (var i = 0; i < this.length; i++) { ++ var newCarry = this.words[i] & carryMask; ++ var c = (this.words[i] - newCarry) << r; ++ this.words[i] = c | carry; ++ carry = newCarry >>> (26 - r); ++ } ++ if (carry) { ++ this.words[i] = carry; ++ this.length++; ++ } ++ } + +-//Checks if a number is a power of two +-exports.isPow2 = function(v) { +- return !(v & (v-1)) && (!!v); +-} ++ if (s !== 0) { ++ for (var i = this.length - 1; i >= 0; i--) ++ this.words[i + s] = this.words[i]; ++ for (var i = 0; i < s; i++) ++ this.words[i] = 0; ++ this.length += s; ++ } + +-//Computes log base 2 of v +-exports.log2 = function(v) { +- var r, shift; +- r = (v > 0xFFFF) << 4; v >>>= r; +- shift = (v > 0xFF ) << 3; v >>>= shift; r |= shift; +- shift = (v > 0xF ) << 2; v >>>= shift; r |= shift; +- shift = (v > 0x3 ) << 1; v >>>= shift; r |= shift; +- return r | (v >> 1); +-} ++ return this.strip(); ++}; + +-//Computes log base 10 of v +-exports.log10 = function(v) { +- return (v >= 1000000000) ? 9 : (v >= 100000000) ? 8 : (v >= 10000000) ? 7 : +- (v >= 1000000) ? 6 : (v >= 100000) ? 5 : (v >= 10000) ? 4 : +- (v >= 1000) ? 3 : (v >= 100) ? 2 : (v >= 10) ? 1 : 0; +-} ++// Shift-right in-place ++// NOTE: `hint` is a lowest bit before trailing zeroes ++// NOTE: if `extended` is present - it will be filled with destroyed bits ++BN.prototype.ishrn = function ishrn(bits, hint, extended) { ++ assert(typeof bits === 'number' && bits >= 0); ++ var h; ++ if (hint) ++ h = (hint - (hint % 26)) / 26; ++ else ++ h = 0; + +-//Counts number of bits +-exports.popCount = function(v) { +- v = v - ((v >>> 1) & 0x55555555); +- v = (v & 0x33333333) + ((v >>> 2) & 0x33333333); +- return ((v + (v >>> 4) & 0xF0F0F0F) * 0x1010101) >>> 24; +-} ++ var r = bits % 26; ++ var s = Math.min((bits - r) / 26, this.length); ++ var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); ++ var maskedWords = extended; + +-//Counts number of trailing zeros +-function countTrailingZeros(v) { +- var c = 32; +- v &= -v; +- if (v) c--; +- if (v & 0x0000FFFF) c -= 16; +- if (v & 0x00FF00FF) c -= 8; +- if (v & 0x0F0F0F0F) c -= 4; +- if (v & 0x33333333) c -= 2; +- if (v & 0x55555555) c -= 1; +- return c; +-} +-exports.countTrailingZeros = countTrailingZeros; ++ h -= s; ++ h = Math.max(0, h); + +-//Rounds to next power of 2 +-exports.nextPow2 = function(v) { +- v += v === 0; +- --v; +- v |= v >>> 1; +- v |= v >>> 2; +- v |= v >>> 4; +- v |= v >>> 8; +- v |= v >>> 16; +- return v + 1; +-} +- +-//Rounds down to previous power of 2 +-exports.prevPow2 = function(v) { +- v |= v >>> 1; +- v |= v >>> 2; +- v |= v >>> 4; +- v |= v >>> 8; +- v |= v >>> 16; +- return v - (v>>>1); +-} +- +-//Computes parity of word +-exports.parity = function(v) { +- v ^= v >>> 16; +- v ^= v >>> 8; +- v ^= v >>> 4; +- v &= 0xf; +- return (0x6996 >>> v) & 1; +-} ++ // Extended mode, copy masked part ++ if (maskedWords) { ++ for (var i = 0; i < s; i++) ++ maskedWords.words[i] = this.words[i]; ++ maskedWords.length = s; ++ } + +-var REVERSE_TABLE = new Array(256); ++ if (s === 0) { ++ // No-op, we should not move anything at all ++ } else if (this.length > s) { ++ this.length -= s; ++ for (var i = 0; i < this.length; i++) ++ this.words[i] = this.words[i + s]; ++ } else { ++ this.words[0] = 0; ++ this.length = 1; ++ } + +-(function(tab) { +- for(var i=0; i<256; ++i) { +- var v = i, r = i, s = 7; +- for (v >>>= 1; v; v >>>= 1) { +- r <<= 1; +- r |= v & 1; +- --s; +- } +- tab[i] = (r << s) & 0xff; ++ var carry = 0; ++ for (var i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) { ++ var word = this.words[i]; ++ this.words[i] = (carry << (26 - r)) | (word >>> r); ++ carry = word & mask; + } +-})(REVERSE_TABLE); + +-//Reverse bits in a 32 bit word +-exports.reverse = function(v) { +- return (REVERSE_TABLE[ v & 0xff] << 24) | +- (REVERSE_TABLE[(v >>> 8) & 0xff] << 16) | +- (REVERSE_TABLE[(v >>> 16) & 0xff] << 8) | +- REVERSE_TABLE[(v >>> 24) & 0xff]; +-} ++ // Push carried bits as a mask ++ if (maskedWords && carry !== 0) ++ maskedWords.words[maskedWords.length++] = carry; + +-//Interleave bits of 2 coordinates with 16 bits. Useful for fast quadtree codes +-exports.interleave2 = function(x, y) { +- x &= 0xFFFF; +- x = (x | (x << 8)) & 0x00FF00FF; +- x = (x | (x << 4)) & 0x0F0F0F0F; +- x = (x | (x << 2)) & 0x33333333; +- x = (x | (x << 1)) & 0x55555555; ++ if (this.length === 0) { ++ this.words[0] = 0; ++ this.length = 1; ++ } + +- y &= 0xFFFF; +- y = (y | (y << 8)) & 0x00FF00FF; +- y = (y | (y << 4)) & 0x0F0F0F0F; +- y = (y | (y << 2)) & 0x33333333; +- y = (y | (y << 1)) & 0x55555555; ++ this.strip(); + +- return x | (y << 1); +-} ++ return this; ++}; + +-//Extracts the nth interleaved component +-exports.deinterleave2 = function(v, n) { +- v = (v >>> n) & 0x55555555; +- v = (v | (v >>> 1)) & 0x33333333; +- v = (v | (v >>> 2)) & 0x0F0F0F0F; +- v = (v | (v >>> 4)) & 0x00FF00FF; +- v = (v | (v >>> 16)) & 0x000FFFF; +- return (v << 16) >> 16; +-} ++// Shift-left ++BN.prototype.shln = function shln(bits) { ++ return this.clone().ishln(bits); ++}; + ++// Shift-right ++BN.prototype.shrn = function shrn(bits) { ++ return this.clone().ishrn(bits); ++}; + +-//Interleave bits of 3 coordinates, each with 10 bits. Useful for fast octree codes +-exports.interleave3 = function(x, y, z) { +- x &= 0x3FF; +- x = (x | (x<<16)) & 4278190335; +- x = (x | (x<<8)) & 251719695; +- x = (x | (x<<4)) & 3272356035; +- x = (x | (x<<2)) & 1227133513; ++// Test if n bit is set ++BN.prototype.testn = function testn(bit) { ++ assert(typeof bit === 'number' && bit >= 0); ++ var r = bit % 26; ++ var s = (bit - r) / 26; ++ var q = 1 << r; + +- y &= 0x3FF; +- y = (y | (y<<16)) & 4278190335; +- y = (y | (y<<8)) & 251719695; +- y = (y | (y<<4)) & 3272356035; +- y = (y | (y<<2)) & 1227133513; +- x |= (y << 1); +- +- z &= 0x3FF; +- z = (z | (z<<16)) & 4278190335; +- z = (z | (z<<8)) & 251719695; +- z = (z | (z<<4)) & 3272356035; +- z = (z | (z<<2)) & 1227133513; +- +- return x | (z << 2); +-} ++ // Fast case: bit is much higher than all existing words ++ if (this.length <= s) { ++ return false; ++ } + +-//Extracts nth interleaved component of a 3-tuple +-exports.deinterleave3 = function(v, n) { +- v = (v >>> n) & 1227133513; +- v = (v | (v>>>2)) & 3272356035; +- v = (v | (v>>>4)) & 251719695; +- v = (v | (v>>>8)) & 4278190335; +- v = (v | (v>>>16)) & 0x3FF; +- return (v<<22)>>22; +-} ++ // Check bit and return ++ var w = this.words[s]; + +-//Computes next combination in colexicographic order (this is mistakenly called nextPermutation on the bit twiddling hacks page) +-exports.nextCombination = function(v) { +- var t = v | (v - 1); +- return (t + 1) | (((~t & -~t) - 1) >>> (countTrailingZeros(v) + 1)); +-} ++ return !!(w & q); ++}; + ++// Return only lowers bits of number (in-place) ++BN.prototype.imaskn = function imaskn(bits) { ++ assert(typeof bits === 'number' && bits >= 0); ++ var r = bits % 26; ++ var s = (bits - r) / 26; + +-},{}],39:[function(require,module,exports){ +-(function (global){ +-/*! +- * The buffer module from node.js, for the browser. +- * +- * @author Feross Aboukhadijeh +- * @license MIT +- */ +-/* eslint-disable no-proto */ ++ assert(!this.sign, 'imaskn works only with positive numbers'); + +-'use strict' ++ if (r !== 0) ++ s++; ++ this.length = Math.min(s, this.length); + +-var base64 = require('base64-js') +-var ieee754 = require('ieee754') +-var isArray = require('isarray') ++ if (r !== 0) { ++ var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); ++ this.words[this.length - 1] &= mask; ++ } + +-exports.Buffer = Buffer +-exports.SlowBuffer = SlowBuffer +-exports.INSPECT_MAX_BYTES = 50 +-Buffer.poolSize = 8192 // not used by this implementation ++ return this.strip(); ++}; + +-var rootParent = {} ++// Return only lowers bits of number ++BN.prototype.maskn = function maskn(bits) { ++ return this.clone().imaskn(bits); ++}; + +-/** +- * If `Buffer.TYPED_ARRAY_SUPPORT`: +- * === true Use Uint8Array implementation (fastest) +- * === false Use Object implementation (most compatible, even IE6) +- * +- * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, +- * Opera 11.6+, iOS 4.2+. +- * +- * Due to various browser bugs, sometimes the Object implementation will be used even +- * when the browser supports typed arrays. +- * +- * Note: +- * +- * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances, +- * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. +- * +- * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. +- * +- * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of +- * incorrect length in some situations. ++// Add plain number `num` to `this` ++BN.prototype.iaddn = function iaddn(num) { ++ assert(typeof num === 'number'); ++ if (num < 0) ++ return this.isubn(-num); + +- * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they +- * get the Object implementation, which is slower but behaves correctly. +- */ +-Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined +- ? global.TYPED_ARRAY_SUPPORT +- : typedArraySupport() ++ // Possible sign change ++ if (this.sign) { ++ if (this.length === 1 && this.words[0] < num) { ++ this.words[0] = num - this.words[0]; ++ this.sign = false; ++ return this; ++ } + +-function typedArraySupport () { +- try { +- var arr = new Uint8Array(1) +- arr.foo = function () { return 42 } +- return arr.foo() === 42 && // typed array instances can be augmented +- typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray` +- arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` +- } catch (e) { +- return false ++ this.sign = false; ++ this.isubn(num); ++ this.sign = true; ++ return this; + } +-} + +-function kMaxLength () { +- return Buffer.TYPED_ARRAY_SUPPORT +- ? 0x7fffffff +- : 0x3fffffff +-} ++ // Add without checks ++ return this._iaddn(num); ++}; + +-/** +- * The Buffer constructor returns instances of `Uint8Array` that have their +- * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of +- * `Uint8Array`, so the returned instances will have all the node `Buffer` methods +- * and the `Uint8Array` methods. Square bracket notation works as expected -- it +- * returns a single octet. +- * +- * The `Uint8Array` prototype remains unmodified. +- */ +-function Buffer (arg) { +- if (!(this instanceof Buffer)) { +- // Avoid going through an ArgumentsAdaptorTrampoline in the common case. +- if (arguments.length > 1) return new Buffer(arg, arguments[1]) +- return new Buffer(arg) +- } ++BN.prototype._iaddn = function _iaddn(num) { ++ this.words[0] += num; + +- if (!Buffer.TYPED_ARRAY_SUPPORT) { +- this.length = 0 +- this.parent = undefined ++ // Carry ++ for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) { ++ this.words[i] -= 0x4000000; ++ if (i === this.length - 1) ++ this.words[i + 1] = 1; ++ else ++ this.words[i + 1]++; + } ++ this.length = Math.max(this.length, i + 1); + +- // Common case. +- if (typeof arg === 'number') { +- return fromNumber(this, arg) +- } ++ return this; ++}; + +- // Slightly less common case. +- if (typeof arg === 'string') { +- return fromString(this, arg, arguments.length > 1 ? arguments[1] : 'utf8') +- } ++// Subtract plain number `num` from `this` ++BN.prototype.isubn = function isubn(num) { ++ assert(typeof num === 'number'); ++ if (num < 0) ++ return this.iaddn(-num); + +- // Unusual. +- return fromObject(this, arg) +-} ++ if (this.sign) { ++ this.sign = false; ++ this.iaddn(num); ++ this.sign = true; ++ return this; ++ } + +-// TODO: Legacy, not needed anymore. Remove in next major version. +-Buffer._augment = function (arr) { +- arr.__proto__ = Buffer.prototype +- return arr +-} ++ this.words[0] -= num; + +-function fromNumber (that, length) { +- that = allocate(that, length < 0 ? 0 : checked(length) | 0) +- if (!Buffer.TYPED_ARRAY_SUPPORT) { +- for (var i = 0; i < length; i++) { +- that[i] = 0 +- } ++ // Carry ++ for (var i = 0; i < this.length && this.words[i] < 0; i++) { ++ this.words[i] += 0x4000000; ++ this.words[i + 1] -= 1; + } +- return that +-} + +-function fromString (that, string, encoding) { +- if (typeof encoding !== 'string' || encoding === '') encoding = 'utf8' ++ return this.strip(); ++}; + +- // Assumption: byteLength() return value is always < kMaxLength. +- var length = byteLength(string, encoding) | 0 +- that = allocate(that, length) ++BN.prototype.addn = function addn(num) { ++ return this.clone().iaddn(num); ++}; + +- that.write(string, encoding) +- return that +-} ++BN.prototype.subn = function subn(num) { ++ return this.clone().isubn(num); ++}; + +-function fromObject (that, object) { +- if (Buffer.isBuffer(object)) return fromBuffer(that, object) ++BN.prototype.iabs = function iabs() { ++ this.sign = false; + +- if (isArray(object)) return fromArray(that, object) ++ return this; ++}; + +- if (object == null) { +- throw new TypeError('must start with number, buffer, array or string') +- } ++BN.prototype.abs = function abs() { ++ return this.clone().iabs(); ++}; + +- if (typeof ArrayBuffer !== 'undefined') { +- if (object.buffer instanceof ArrayBuffer) { +- return fromTypedArray(that, object) +- } +- if (object instanceof ArrayBuffer) { +- return fromArrayBuffer(that, object) +- } ++BN.prototype._ishlnsubmul = function _ishlnsubmul(num, mul, shift) { ++ // Bigger storage is needed ++ var len = num.length + shift; ++ var i; ++ if (this.words.length < len) { ++ var t = new Array(len); ++ for (var i = 0; i < this.length; i++) ++ t[i] = this.words[i]; ++ this.words = t; ++ } else { ++ i = this.length; + } + +- if (object.length) return fromArrayLike(that, object) +- +- return fromJsonObject(that, object) +-} +- +-function fromBuffer (that, buffer) { +- var length = checked(buffer.length) | 0 +- that = allocate(that, length) +- buffer.copy(that, 0, 0, length) +- return that +-} ++ // Zeroify rest ++ this.length = Math.max(this.length, len); ++ for (; i < this.length; i++) ++ this.words[i] = 0; + +-function fromArray (that, array) { +- var length = checked(array.length) | 0 +- that = allocate(that, length) +- for (var i = 0; i < length; i += 1) { +- that[i] = array[i] & 255 ++ var carry = 0; ++ for (var i = 0; i < num.length; i++) { ++ var w = this.words[i + shift] + carry; ++ var right = num.words[i] * mul; ++ w -= right & 0x3ffffff; ++ carry = (w >> 26) - ((right / 0x4000000) | 0); ++ this.words[i + shift] = w & 0x3ffffff; + } +- return that +-} +- +-// Duplicate of fromArray() to keep fromArray() monomorphic. +-function fromTypedArray (that, array) { +- var length = checked(array.length) | 0 +- that = allocate(that, length) +- // Truncating the elements is probably not what people expect from typed +- // arrays with BYTES_PER_ELEMENT > 1 but it's compatible with the behavior +- // of the old Buffer constructor. +- for (var i = 0; i < length; i += 1) { +- that[i] = array[i] & 255 ++ for (; i < this.length - shift; i++) { ++ var w = this.words[i + shift] + carry; ++ carry = w >> 26; ++ this.words[i + shift] = w & 0x3ffffff; + } +- return that +-} + +-function fromArrayBuffer (that, array) { +- array.byteLength // this throws if `array` is not a valid ArrayBuffer ++ if (carry === 0) ++ return this.strip(); + +- if (Buffer.TYPED_ARRAY_SUPPORT) { +- // Return an augmented `Uint8Array` instance, for best performance +- that = new Uint8Array(array) +- that.__proto__ = Buffer.prototype +- } else { +- // Fallback: Return an object instance of the Buffer class +- that = fromTypedArray(that, new Uint8Array(array)) ++ // Subtraction overflow ++ assert(carry === -1); ++ carry = 0; ++ for (var i = 0; i < this.length; i++) { ++ var w = -this.words[i] + carry; ++ carry = w >> 26; ++ this.words[i] = w & 0x3ffffff; + } +- return that +-} ++ this.sign = true; + +-function fromArrayLike (that, array) { +- var length = checked(array.length) | 0 +- that = allocate(that, length) +- for (var i = 0; i < length; i += 1) { +- that[i] = array[i] & 255 +- } +- return that +-} ++ return this.strip(); ++}; + +-// Deserialize { type: 'Buffer', data: [1,2,3,...] } into a Buffer object. +-// Returns a zero-length buffer for inputs that don't conform to the spec. +-function fromJsonObject (that, object) { +- var array +- var length = 0 ++BN.prototype._wordDiv = function _wordDiv(num, mode) { ++ var shift = this.length - num.length; + +- if (object.type === 'Buffer' && isArray(object.data)) { +- array = object.data +- length = checked(array.length) | 0 +- } +- that = allocate(that, length) ++ var a = this.clone(); ++ var b = num; + +- for (var i = 0; i < length; i += 1) { +- that[i] = array[i] & 255 ++ // Normalize ++ var bhi = b.words[b.length - 1]; ++ var bhiBits = this._countBits(bhi); ++ shift = 26 - bhiBits; ++ if (shift !== 0) { ++ b = b.shln(shift); ++ a.ishln(shift); ++ bhi = b.words[b.length - 1]; + } +- return that +-} + +-if (Buffer.TYPED_ARRAY_SUPPORT) { +- Buffer.prototype.__proto__ = Uint8Array.prototype +- Buffer.__proto__ = Uint8Array +- if (typeof Symbol !== 'undefined' && Symbol.species && +- Buffer[Symbol.species] === Buffer) { +- // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 +- Object.defineProperty(Buffer, Symbol.species, { +- value: null, +- configurable: true +- }) ++ // Initialize quotient ++ var m = a.length - b.length; ++ var q; ++ ++ if (mode !== 'mod') { ++ q = new BN(null); ++ q.length = m + 1; ++ q.words = new Array(q.length); ++ for (var i = 0; i < q.length; i++) ++ q.words[i] = 0; + } +-} else { +- // pre-set for values that may exist in the future +- Buffer.prototype.length = undefined +- Buffer.prototype.parent = undefined +-} + +-function allocate (that, length) { +- if (Buffer.TYPED_ARRAY_SUPPORT) { +- // Return an augmented `Uint8Array` instance, for best performance +- that = new Uint8Array(length) +- that.__proto__ = Buffer.prototype +- } else { +- // Fallback: Return an object instance of the Buffer class +- that.length = length ++ var diff = a.clone()._ishlnsubmul(b, 1, m); ++ if (!diff.sign) { ++ a = diff; ++ if (q) ++ q.words[m] = 1; + } + +- var fromPool = length !== 0 && length <= Buffer.poolSize >>> 1 +- if (fromPool) that.parent = rootParent ++ for (var j = m - 1; j >= 0; j--) { ++ var qj = a.words[b.length + j] * 0x4000000 + a.words[b.length + j - 1]; + +- return that +-} ++ // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max ++ // (0x7ffffff) ++ qj = Math.min((qj / bhi) | 0, 0x3ffffff); + +-function checked (length) { +- // Note: cannot use `length < kMaxLength` here because that fails when +- // length is NaN (which is otherwise coerced to zero.) +- if (length >= kMaxLength()) { +- throw new RangeError('Attempt to allocate Buffer larger than maximum ' + +- 'size: 0x' + kMaxLength().toString(16) + ' bytes') ++ a._ishlnsubmul(b, qj, j); ++ while (a.sign) { ++ qj--; ++ a.sign = false; ++ a._ishlnsubmul(b, 1, j); ++ if (a.cmpn(0) !== 0) ++ a.sign = !a.sign; ++ } ++ if (q) ++ q.words[j] = qj; + } +- return length | 0 +-} +- +-function SlowBuffer (subject, encoding) { +- if (!(this instanceof SlowBuffer)) return new SlowBuffer(subject, encoding) ++ if (q) ++ q.strip(); ++ a.strip(); + +- var buf = new Buffer(subject, encoding) +- delete buf.parent +- return buf +-} ++ // Denormalize ++ if (mode !== 'div' && shift !== 0) ++ a.ishrn(shift); ++ return { div: q ? q : null, mod: a }; ++}; + +-Buffer.isBuffer = function isBuffer (b) { +- return !!(b != null && b._isBuffer) +-} ++BN.prototype.divmod = function divmod(num, mode) { ++ assert(num.cmpn(0) !== 0); + +-Buffer.compare = function compare (a, b) { +- if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { +- throw new TypeError('Arguments must be Buffers') ++ if (this.sign && !num.sign) { ++ var res = this.neg().divmod(num, mode); ++ var div; ++ var mod; ++ if (mode !== 'mod') ++ div = res.div.neg(); ++ if (mode !== 'div') ++ mod = res.mod.cmpn(0) === 0 ? res.mod : num.sub(res.mod); ++ return { ++ div: div, ++ mod: mod ++ }; ++ } else if (!this.sign && num.sign) { ++ var res = this.divmod(num.neg(), mode); ++ var div; ++ if (mode !== 'mod') ++ div = res.div.neg(); ++ return { div: div, mod: res.mod }; ++ } else if (this.sign && num.sign) { ++ return this.neg().divmod(num.neg(), mode); + } + +- if (a === b) return 0 ++ // Both numbers are positive at this point + +- var x = a.length +- var y = b.length ++ // Strip both numbers to approximate shift value ++ if (num.length > this.length || this.cmp(num) < 0) ++ return { div: new BN(0), mod: this }; + +- var i = 0 +- var len = Math.min(x, y) +- while (i < len) { +- if (a[i] !== b[i]) break +- +- ++i +- } +- +- if (i !== len) { +- x = a[i] +- y = b[i] ++ // Very short reduction ++ if (num.length === 1) { ++ if (mode === 'div') ++ return { div: this.divn(num.words[0]), mod: null }; ++ else if (mode === 'mod') ++ return { div: null, mod: new BN(this.modn(num.words[0])) }; ++ return { ++ div: this.divn(num.words[0]), ++ mod: new BN(this.modn(num.words[0])) ++ }; + } + +- if (x < y) return -1 +- if (y < x) return 1 +- return 0 +-} ++ return this._wordDiv(num, mode); ++}; + +-Buffer.isEncoding = function isEncoding (encoding) { +- switch (String(encoding).toLowerCase()) { +- case 'hex': +- case 'utf8': +- case 'utf-8': +- case 'ascii': +- case 'binary': +- case 'base64': +- case 'raw': +- case 'ucs2': +- case 'ucs-2': +- case 'utf16le': +- case 'utf-16le': +- return true +- default: +- return false +- } +-} ++// Find `this` / `num` ++BN.prototype.div = function div(num) { ++ return this.divmod(num, 'div').div; ++}; + +-Buffer.concat = function concat (list, length) { +- if (!isArray(list)) throw new TypeError('list argument must be an Array of Buffers.') ++// Find `this` % `num` ++BN.prototype.mod = function mod(num) { ++ return this.divmod(num, 'mod').mod; ++}; + +- if (list.length === 0) { +- return new Buffer(0) +- } ++// Find Round(`this` / `num`) ++BN.prototype.divRound = function divRound(num) { ++ var dm = this.divmod(num); + +- var i +- if (length === undefined) { +- length = 0 +- for (i = 0; i < list.length; i++) { +- length += list[i].length +- } +- } ++ // Fast case - exact division ++ if (dm.mod.cmpn(0) === 0) ++ return dm.div; + +- var buf = new Buffer(length) +- var pos = 0 +- for (i = 0; i < list.length; i++) { +- var item = list[i] +- item.copy(buf, pos) +- pos += item.length +- } +- return buf +-} ++ var mod = dm.div.sign ? dm.mod.isub(num) : dm.mod; + +-function byteLength (string, encoding) { +- if (typeof string !== 'string') string = '' + string ++ var half = num.shrn(1); ++ var r2 = num.andln(1); ++ var cmp = mod.cmp(half); + +- var len = string.length +- if (len === 0) return 0 ++ // Round down ++ if (cmp < 0 || r2 === 1 && cmp === 0) ++ return dm.div; + +- // Use a for loop to avoid recursion +- var loweredCase = false +- for (;;) { +- switch (encoding) { +- case 'ascii': +- case 'binary': +- // Deprecated +- case 'raw': +- case 'raws': +- return len +- case 'utf8': +- case 'utf-8': +- return utf8ToBytes(string).length +- case 'ucs2': +- case 'ucs-2': +- case 'utf16le': +- case 'utf-16le': +- return len * 2 +- case 'hex': +- return len >>> 1 +- case 'base64': +- return base64ToBytes(string).length +- default: +- if (loweredCase) return utf8ToBytes(string).length // assume utf8 +- encoding = ('' + encoding).toLowerCase() +- loweredCase = true +- } +- } +-} +-Buffer.byteLength = byteLength ++ // Round up ++ return dm.div.sign ? dm.div.isubn(1) : dm.div.iaddn(1); ++}; + +-function slowToString (encoding, start, end) { +- var loweredCase = false ++BN.prototype.modn = function modn(num) { ++ assert(num <= 0x3ffffff); ++ var p = (1 << 26) % num; + +- start = start | 0 +- end = end === undefined || end === Infinity ? this.length : end | 0 ++ var acc = 0; ++ for (var i = this.length - 1; i >= 0; i--) ++ acc = (p * acc + this.words[i]) % num; + +- if (!encoding) encoding = 'utf8' +- if (start < 0) start = 0 +- if (end > this.length) end = this.length +- if (end <= start) return '' ++ return acc; ++}; + +- while (true) { +- switch (encoding) { +- case 'hex': +- return hexSlice(this, start, end) ++// In-place division by number ++BN.prototype.idivn = function idivn(num) { ++ assert(num <= 0x3ffffff); + +- case 'utf8': +- case 'utf-8': +- return utf8Slice(this, start, end) ++ var carry = 0; ++ for (var i = this.length - 1; i >= 0; i--) { ++ var w = this.words[i] + carry * 0x4000000; ++ this.words[i] = (w / num) | 0; ++ carry = w % num; ++ } + +- case 'ascii': +- return asciiSlice(this, start, end) ++ return this.strip(); ++}; + +- case 'binary': +- return binarySlice(this, start, end) ++BN.prototype.divn = function divn(num) { ++ return this.clone().idivn(num); ++}; + +- case 'base64': +- return base64Slice(this, start, end) ++BN.prototype.egcd = function egcd(p) { ++ assert(!p.sign); ++ assert(p.cmpn(0) !== 0); + +- case 'ucs2': +- case 'ucs-2': +- case 'utf16le': +- case 'utf-16le': +- return utf16leSlice(this, start, end) ++ var x = this; ++ var y = p.clone(); + +- default: +- if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) +- encoding = (encoding + '').toLowerCase() +- loweredCase = true +- } +- } +-} ++ if (x.sign) ++ x = x.mod(p); ++ else ++ x = x.clone(); + +-// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect +-// Buffer instances. +-Buffer.prototype._isBuffer = true ++ // A * x + B * y = x ++ var A = new BN(1); ++ var B = new BN(0); + +-Buffer.prototype.toString = function toString () { +- var length = this.length | 0 +- if (length === 0) return '' +- if (arguments.length === 0) return utf8Slice(this, 0, length) +- return slowToString.apply(this, arguments) +-} ++ // C * x + D * y = y ++ var C = new BN(0); ++ var D = new BN(1); + +-Buffer.prototype.equals = function equals (b) { +- if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') +- if (this === b) return true +- return Buffer.compare(this, b) === 0 +-} ++ var g = 0; + +-Buffer.prototype.inspect = function inspect () { +- var str = '' +- var max = exports.INSPECT_MAX_BYTES +- if (this.length > 0) { +- str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') +- if (this.length > max) str += ' ... ' ++ while (x.isEven() && y.isEven()) { ++ x.ishrn(1); ++ y.ishrn(1); ++ ++g; + } +- return '' +-} +- +-Buffer.prototype.compare = function compare (b) { +- if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') +- if (this === b) return 0 +- return Buffer.compare(this, b) +-} + +-Buffer.prototype.indexOf = function indexOf (val, byteOffset) { +- if (byteOffset > 0x7fffffff) byteOffset = 0x7fffffff +- else if (byteOffset < -0x80000000) byteOffset = -0x80000000 +- byteOffset >>= 0 +- +- if (this.length === 0) return -1 +- if (byteOffset >= this.length) return -1 +- +- // Negative offsets start from the end of the buffer +- if (byteOffset < 0) byteOffset = Math.max(this.length + byteOffset, 0) ++ var yp = y.clone(); ++ var xp = x.clone(); + +- if (typeof val === 'string') { +- if (val.length === 0) return -1 // special case: looking for empty string always fails +- return String.prototype.indexOf.call(this, val, byteOffset) +- } +- if (Buffer.isBuffer(val)) { +- return arrayIndexOf(this, val, byteOffset) +- } +- if (typeof val === 'number') { +- if (Buffer.TYPED_ARRAY_SUPPORT && Uint8Array.prototype.indexOf === 'function') { +- return Uint8Array.prototype.indexOf.call(this, val, byteOffset) ++ while (x.cmpn(0) !== 0) { ++ while (x.isEven()) { ++ x.ishrn(1); ++ if (A.isEven() && B.isEven()) { ++ A.ishrn(1); ++ B.ishrn(1); ++ } else { ++ A.iadd(yp).ishrn(1); ++ B.isub(xp).ishrn(1); ++ } + } +- return arrayIndexOf(this, [ val ], byteOffset) +- } + +- function arrayIndexOf (arr, val, byteOffset) { +- var foundIndex = -1 +- for (var i = 0; byteOffset + i < arr.length; i++) { +- if (arr[byteOffset + i] === val[foundIndex === -1 ? 0 : i - foundIndex]) { +- if (foundIndex === -1) foundIndex = i +- if (i - foundIndex + 1 === val.length) return byteOffset + foundIndex ++ while (y.isEven()) { ++ y.ishrn(1); ++ if (C.isEven() && D.isEven()) { ++ C.ishrn(1); ++ D.ishrn(1); + } else { +- foundIndex = -1 ++ C.iadd(yp).ishrn(1); ++ D.isub(xp).ishrn(1); + } + } +- return -1 +- } + +- throw new TypeError('val must be string, number or Buffer') +-} +- +-function hexWrite (buf, string, offset, length) { +- offset = Number(offset) || 0 +- var remaining = buf.length - offset +- if (!length) { +- length = remaining +- } else { +- length = Number(length) +- if (length > remaining) { +- length = remaining ++ if (x.cmp(y) >= 0) { ++ x.isub(y); ++ A.isub(C); ++ B.isub(D); ++ } else { ++ y.isub(x); ++ C.isub(A); ++ D.isub(B); + } + } + +- // must be an even number of digits +- var strLen = string.length +- if (strLen % 2 !== 0) throw new Error('Invalid hex string') +- +- if (length > strLen / 2) { +- length = strLen / 2 +- } +- for (var i = 0; i < length; i++) { +- var parsed = parseInt(string.substr(i * 2, 2), 16) +- if (isNaN(parsed)) throw new Error('Invalid hex string') +- buf[offset + i] = parsed +- } +- return i +-} ++ return { ++ a: C, ++ b: D, ++ gcd: y.ishln(g) ++ }; ++}; + +-function utf8Write (buf, string, offset, length) { +- return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) +-} ++// This is reduced incarnation of the binary EEA ++// above, designated to invert members of the ++// _prime_ fields F(p) at a maximal speed ++BN.prototype._invmp = function _invmp(p) { ++ assert(!p.sign); ++ assert(p.cmpn(0) !== 0); + +-function asciiWrite (buf, string, offset, length) { +- return blitBuffer(asciiToBytes(string), buf, offset, length) +-} ++ var a = this; ++ var b = p.clone(); + +-function binaryWrite (buf, string, offset, length) { +- return asciiWrite(buf, string, offset, length) +-} ++ if (a.sign) ++ a = a.mod(p); ++ else ++ a = a.clone(); + +-function base64Write (buf, string, offset, length) { +- return blitBuffer(base64ToBytes(string), buf, offset, length) +-} ++ var x1 = new BN(1); ++ var x2 = new BN(0); + +-function ucs2Write (buf, string, offset, length) { +- return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) +-} ++ var delta = b.clone(); + +-Buffer.prototype.write = function write (string, offset, length, encoding) { +- // Buffer#write(string) +- if (offset === undefined) { +- encoding = 'utf8' +- length = this.length +- offset = 0 +- // Buffer#write(string, encoding) +- } else if (length === undefined && typeof offset === 'string') { +- encoding = offset +- length = this.length +- offset = 0 +- // Buffer#write(string, offset[, length][, encoding]) +- } else if (isFinite(offset)) { +- offset = offset | 0 +- if (isFinite(length)) { +- length = length | 0 +- if (encoding === undefined) encoding = 'utf8' ++ while (a.cmpn(1) > 0 && b.cmpn(1) > 0) { ++ while (a.isEven()) { ++ a.ishrn(1); ++ if (x1.isEven()) ++ x1.ishrn(1); ++ else ++ x1.iadd(delta).ishrn(1); ++ } ++ while (b.isEven()) { ++ b.ishrn(1); ++ if (x2.isEven()) ++ x2.ishrn(1); ++ else ++ x2.iadd(delta).ishrn(1); ++ } ++ if (a.cmp(b) >= 0) { ++ a.isub(b); ++ x1.isub(x2); + } else { +- encoding = length +- length = undefined ++ b.isub(a); ++ x2.isub(x1); + } +- // legacy write(string, encoding, offset, length) - remove in v0.13 +- } else { +- var swap = encoding +- encoding = offset +- offset = length | 0 +- length = swap + } ++ if (a.cmpn(1) === 0) ++ return x1; ++ else ++ return x2; ++}; + +- var remaining = this.length - offset +- if (length === undefined || length > remaining) length = remaining ++BN.prototype.gcd = function gcd(num) { ++ if (this.cmpn(0) === 0) ++ return num.clone(); ++ if (num.cmpn(0) === 0) ++ return this.clone(); + +- if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { +- throw new RangeError('attempt to write outside buffer bounds') ++ var a = this.clone(); ++ var b = num.clone(); ++ a.sign = false; ++ b.sign = false; ++ ++ // Remove common factor of two ++ for (var shift = 0; a.isEven() && b.isEven(); shift++) { ++ a.ishrn(1); ++ b.ishrn(1); + } + +- if (!encoding) encoding = 'utf8' ++ do { ++ while (a.isEven()) ++ a.ishrn(1); ++ while (b.isEven()) ++ b.ishrn(1); + +- var loweredCase = false +- for (;;) { +- switch (encoding) { +- case 'hex': +- return hexWrite(this, string, offset, length) ++ var r = a.cmp(b); ++ if (r < 0) { ++ // Swap `a` and `b` to make `a` always bigger than `b` ++ var t = a; ++ a = b; ++ b = t; ++ } else if (r === 0 || b.cmpn(1) === 0) { ++ break; ++ } + +- case 'utf8': +- case 'utf-8': +- return utf8Write(this, string, offset, length) ++ a.isub(b); ++ } while (true); + +- case 'ascii': +- return asciiWrite(this, string, offset, length) ++ return b.ishln(shift); ++}; + +- case 'binary': +- return binaryWrite(this, string, offset, length) ++// Invert number in the field F(num) ++BN.prototype.invm = function invm(num) { ++ return this.egcd(num).a.mod(num); ++}; + +- case 'base64': +- // Warning: maxLength not taken into account in base64Write +- return base64Write(this, string, offset, length) ++BN.prototype.isEven = function isEven() { ++ return (this.words[0] & 1) === 0; ++}; + +- case 'ucs2': +- case 'ucs-2': +- case 'utf16le': +- case 'utf-16le': +- return ucs2Write(this, string, offset, length) ++BN.prototype.isOdd = function isOdd() { ++ return (this.words[0] & 1) === 1; ++}; + +- default: +- if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) +- encoding = ('' + encoding).toLowerCase() +- loweredCase = true +- } ++// And first word and num ++BN.prototype.andln = function andln(num) { ++ return this.words[0] & num; ++}; ++ ++// Increment at the bit position in-line ++BN.prototype.bincn = function bincn(bit) { ++ assert(typeof bit === 'number'); ++ var r = bit % 26; ++ var s = (bit - r) / 26; ++ var q = 1 << r; ++ ++ // Fast case: bit is much higher than all existing words ++ if (this.length <= s) { ++ for (var i = this.length; i < s + 1; i++) ++ this.words[i] = 0; ++ this.words[s] |= q; ++ this.length = s + 1; ++ return this; + } +-} + +-Buffer.prototype.toJSON = function toJSON () { +- return { +- type: 'Buffer', +- data: Array.prototype.slice.call(this._arr || this, 0) ++ // Add bit and propagate, if needed ++ var carry = q; ++ for (var i = s; carry !== 0 && i < this.length; i++) { ++ var w = this.words[i]; ++ w += carry; ++ carry = w >>> 26; ++ w &= 0x3ffffff; ++ this.words[i] = w; + } +-} ++ if (carry !== 0) { ++ this.words[i] = carry; ++ this.length++; ++ } ++ return this; ++}; + +-function base64Slice (buf, start, end) { +- if (start === 0 && end === buf.length) { +- return base64.fromByteArray(buf) ++BN.prototype.cmpn = function cmpn(num) { ++ var sign = num < 0; ++ if (sign) ++ num = -num; ++ ++ if (this.sign && !sign) ++ return -1; ++ else if (!this.sign && sign) ++ return 1; ++ ++ num &= 0x3ffffff; ++ this.strip(); ++ ++ var res; ++ if (this.length > 1) { ++ res = 1; + } else { +- return base64.fromByteArray(buf.slice(start, end)) ++ var w = this.words[0]; ++ res = w === num ? 0 : w < num ? -1 : 1; + } +-} +- +-function utf8Slice (buf, start, end) { +- end = Math.min(buf.length, end) +- var res = [] ++ if (this.sign) ++ res = -res; ++ return res; ++}; + +- var i = start +- while (i < end) { +- var firstByte = buf[i] +- var codePoint = null +- var bytesPerSequence = (firstByte > 0xEF) ? 4 +- : (firstByte > 0xDF) ? 3 +- : (firstByte > 0xBF) ? 2 +- : 1 ++// Compare two numbers and return: ++// 1 - if `this` > `num` ++// 0 - if `this` == `num` ++// -1 - if `this` < `num` ++BN.prototype.cmp = function cmp(num) { ++ if (this.sign && !num.sign) ++ return -1; ++ else if (!this.sign && num.sign) ++ return 1; + +- if (i + bytesPerSequence <= end) { +- var secondByte, thirdByte, fourthByte, tempCodePoint ++ var res = this.ucmp(num); ++ if (this.sign) ++ return -res; ++ else ++ return res; ++}; + +- switch (bytesPerSequence) { +- case 1: +- if (firstByte < 0x80) { +- codePoint = firstByte +- } +- break +- case 2: +- secondByte = buf[i + 1] +- if ((secondByte & 0xC0) === 0x80) { +- tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) +- if (tempCodePoint > 0x7F) { +- codePoint = tempCodePoint +- } +- } +- break +- case 3: +- secondByte = buf[i + 1] +- thirdByte = buf[i + 2] +- if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { +- tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) +- if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { +- codePoint = tempCodePoint +- } +- } +- break +- case 4: +- secondByte = buf[i + 1] +- thirdByte = buf[i + 2] +- fourthByte = buf[i + 3] +- if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { +- tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) +- if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { +- codePoint = tempCodePoint +- } +- } +- } +- } ++// Unsigned comparison ++BN.prototype.ucmp = function ucmp(num) { ++ // At this point both numbers have the same sign ++ if (this.length > num.length) ++ return 1; ++ else if (this.length < num.length) ++ return -1; + +- if (codePoint === null) { +- // we did not generate a valid codePoint so insert a +- // replacement char (U+FFFD) and advance only 1 byte +- codePoint = 0xFFFD +- bytesPerSequence = 1 +- } else if (codePoint > 0xFFFF) { +- // encode to utf16 (surrogate pair dance) +- codePoint -= 0x10000 +- res.push(codePoint >>> 10 & 0x3FF | 0xD800) +- codePoint = 0xDC00 | codePoint & 0x3FF +- } ++ var res = 0; ++ for (var i = this.length - 1; i >= 0; i--) { ++ var a = this.words[i]; ++ var b = num.words[i]; + +- res.push(codePoint) +- i += bytesPerSequence ++ if (a === b) ++ continue; ++ if (a < b) ++ res = -1; ++ else if (a > b) ++ res = 1; ++ break; + } ++ return res; ++}; + +- return decodeCodePointsArray(res) +-} ++// ++// A reduce context, could be using montgomery or something better, depending ++// on the `m` itself. ++// ++BN.red = function red(num) { ++ return new Red(num); ++}; + +-// Based on http://stackoverflow.com/a/22747272/680742, the browser with +-// the lowest limit is Chrome, with 0x10000 args. +-// We go 1 magnitude less, for safety +-var MAX_ARGUMENTS_LENGTH = 0x1000 ++BN.prototype.toRed = function toRed(ctx) { ++ assert(!this.red, 'Already a number in reduction context'); ++ assert(!this.sign, 'red works only with positives'); ++ return ctx.convertTo(this)._forceRed(ctx); ++}; + +-function decodeCodePointsArray (codePoints) { +- var len = codePoints.length +- if (len <= MAX_ARGUMENTS_LENGTH) { +- return String.fromCharCode.apply(String, codePoints) // avoid extra slice() +- } ++BN.prototype.fromRed = function fromRed() { ++ assert(this.red, 'fromRed works only with numbers in reduction context'); ++ return this.red.convertFrom(this); ++}; + +- // Decode in chunks to avoid "call stack size exceeded". +- var res = '' +- var i = 0 +- while (i < len) { +- res += String.fromCharCode.apply( +- String, +- codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) +- ) +- } +- return res +-} ++BN.prototype._forceRed = function _forceRed(ctx) { ++ this.red = ctx; ++ return this; ++}; + +-function asciiSlice (buf, start, end) { +- var ret = '' +- end = Math.min(buf.length, end) ++BN.prototype.forceRed = function forceRed(ctx) { ++ assert(!this.red, 'Already a number in reduction context'); ++ return this._forceRed(ctx); ++}; + +- for (var i = start; i < end; i++) { +- ret += String.fromCharCode(buf[i] & 0x7F) +- } +- return ret +-} ++BN.prototype.redAdd = function redAdd(num) { ++ assert(this.red, 'redAdd works only with red numbers'); ++ return this.red.add(this, num); ++}; + +-function binarySlice (buf, start, end) { +- var ret = '' +- end = Math.min(buf.length, end) ++BN.prototype.redIAdd = function redIAdd(num) { ++ assert(this.red, 'redIAdd works only with red numbers'); ++ return this.red.iadd(this, num); ++}; + +- for (var i = start; i < end; i++) { +- ret += String.fromCharCode(buf[i]) +- } +- return ret +-} ++BN.prototype.redSub = function redSub(num) { ++ assert(this.red, 'redSub works only with red numbers'); ++ return this.red.sub(this, num); ++}; + +-function hexSlice (buf, start, end) { +- var len = buf.length ++BN.prototype.redISub = function redISub(num) { ++ assert(this.red, 'redISub works only with red numbers'); ++ return this.red.isub(this, num); ++}; + +- if (!start || start < 0) start = 0 +- if (!end || end < 0 || end > len) end = len ++BN.prototype.redShl = function redShl(num) { ++ assert(this.red, 'redShl works only with red numbers'); ++ return this.red.shl(this, num); ++}; + +- var out = '' +- for (var i = start; i < end; i++) { +- out += toHex(buf[i]) +- } +- return out +-} ++BN.prototype.redMul = function redMul(num) { ++ assert(this.red, 'redMul works only with red numbers'); ++ this.red._verify2(this, num); ++ return this.red.mul(this, num); ++}; + +-function utf16leSlice (buf, start, end) { +- var bytes = buf.slice(start, end) +- var res = '' +- for (var i = 0; i < bytes.length; i += 2) { +- res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256) +- } +- return res +-} ++BN.prototype.redIMul = function redIMul(num) { ++ assert(this.red, 'redMul works only with red numbers'); ++ this.red._verify2(this, num); ++ return this.red.imul(this, num); ++}; + +-Buffer.prototype.slice = function slice (start, end) { +- var len = this.length +- start = ~~start +- end = end === undefined ? len : ~~end ++BN.prototype.redSqr = function redSqr() { ++ assert(this.red, 'redSqr works only with red numbers'); ++ this.red._verify1(this); ++ return this.red.sqr(this); ++}; + +- if (start < 0) { +- start += len +- if (start < 0) start = 0 +- } else if (start > len) { +- start = len +- } ++BN.prototype.redISqr = function redISqr() { ++ assert(this.red, 'redISqr works only with red numbers'); ++ this.red._verify1(this); ++ return this.red.isqr(this); ++}; + +- if (end < 0) { +- end += len +- if (end < 0) end = 0 +- } else if (end > len) { +- end = len +- } ++// Square root over p ++BN.prototype.redSqrt = function redSqrt() { ++ assert(this.red, 'redSqrt works only with red numbers'); ++ this.red._verify1(this); ++ return this.red.sqrt(this); ++}; + +- if (end < start) end = start ++BN.prototype.redInvm = function redInvm() { ++ assert(this.red, 'redInvm works only with red numbers'); ++ this.red._verify1(this); ++ return this.red.invm(this); ++}; + +- var newBuf +- if (Buffer.TYPED_ARRAY_SUPPORT) { +- newBuf = this.subarray(start, end) +- newBuf.__proto__ = Buffer.prototype +- } else { +- var sliceLen = end - start +- newBuf = new Buffer(sliceLen, undefined) +- for (var i = 0; i < sliceLen; i++) { +- newBuf[i] = this[i + start] +- } +- } ++// Return negative clone of `this` % `red modulo` ++BN.prototype.redNeg = function redNeg() { ++ assert(this.red, 'redNeg works only with red numbers'); ++ this.red._verify1(this); ++ return this.red.neg(this); ++}; + +- if (newBuf.length) newBuf.parent = this.parent || this ++BN.prototype.redPow = function redPow(num) { ++ assert(this.red && !num.red, 'redPow(normalNum)'); ++ this.red._verify1(this); ++ return this.red.pow(this, num); ++}; + +- return newBuf +-} ++// Prime numbers with efficient reduction ++var primes = { ++ k256: null, ++ p224: null, ++ p192: null, ++ p25519: null ++}; + +-/* +- * Need to make sure that buffer isn't trying to write out of bounds. +- */ +-function checkOffset (offset, ext, length) { +- if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') +- if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') +-} ++// Pseudo-Mersenne prime ++function MPrime(name, p) { ++ // P = 2 ^ N - K ++ this.name = name; ++ this.p = new BN(p, 16); ++ this.n = this.p.bitLength(); ++ this.k = new BN(1).ishln(this.n).isub(this.p); + +-Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { +- offset = offset | 0 +- byteLength = byteLength | 0 +- if (!noAssert) checkOffset(offset, byteLength, this.length) ++ this.tmp = this._tmp(); ++} + +- var val = this[offset] +- var mul = 1 +- var i = 0 +- while (++i < byteLength && (mul *= 0x100)) { +- val += this[offset + i] * mul +- } ++MPrime.prototype._tmp = function _tmp() { ++ var tmp = new BN(null); ++ tmp.words = new Array(Math.ceil(this.n / 13)); ++ return tmp; ++}; + +- return val +-} ++MPrime.prototype.ireduce = function ireduce(num) { ++ // Assumes that `num` is less than `P^2` ++ // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P) ++ var r = num; ++ var rlen; + +-Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { +- offset = offset | 0 +- byteLength = byteLength | 0 +- if (!noAssert) { +- checkOffset(offset, byteLength, this.length) +- } ++ do { ++ this.split(r, this.tmp); ++ r = this.imulK(r); ++ r = r.iadd(this.tmp); ++ rlen = r.bitLength(); ++ } while (rlen > this.n); + +- var val = this[offset + --byteLength] +- var mul = 1 +- while (byteLength > 0 && (mul *= 0x100)) { +- val += this[offset + --byteLength] * mul ++ var cmp = rlen < this.n ? -1 : r.ucmp(this.p); ++ if (cmp === 0) { ++ r.words[0] = 0; ++ r.length = 1; ++ } else if (cmp > 0) { ++ r.isub(this.p); ++ } else { ++ r.strip(); + } + +- return val +-} ++ return r; ++}; + +-Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { +- if (!noAssert) checkOffset(offset, 1, this.length) +- return this[offset] +-} ++MPrime.prototype.split = function split(input, out) { ++ input.ishrn(this.n, 0, out); ++}; + +-Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { +- if (!noAssert) checkOffset(offset, 2, this.length) +- return this[offset] | (this[offset + 1] << 8) +-} ++MPrime.prototype.imulK = function imulK(num) { ++ return num.imul(this.k); ++}; + +-Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { +- if (!noAssert) checkOffset(offset, 2, this.length) +- return (this[offset] << 8) | this[offset + 1] ++function K256() { ++ MPrime.call( ++ this, ++ 'k256', ++ 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f'); + } ++inherits(K256, MPrime); + +-Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { +- if (!noAssert) checkOffset(offset, 4, this.length) +- +- return ((this[offset]) | +- (this[offset + 1] << 8) | +- (this[offset + 2] << 16)) + +- (this[offset + 3] * 0x1000000) +-} ++K256.prototype.split = function split(input, output) { ++ // 256 = 9 * 26 + 22 ++ var mask = 0x3fffff; + +-Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { +- if (!noAssert) checkOffset(offset, 4, this.length) ++ var outLen = Math.min(input.length, 9); ++ for (var i = 0; i < outLen; i++) ++ output.words[i] = input.words[i]; ++ output.length = outLen; + +- return (this[offset] * 0x1000000) + +- ((this[offset + 1] << 16) | +- (this[offset + 2] << 8) | +- this[offset + 3]) +-} ++ if (input.length <= 9) { ++ input.words[0] = 0; ++ input.length = 1; ++ return; ++ } + +-Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { +- offset = offset | 0 +- byteLength = byteLength | 0 +- if (!noAssert) checkOffset(offset, byteLength, this.length) ++ // Shift by 9 limbs ++ var prev = input.words[9]; ++ output.words[output.length++] = prev & mask; + +- var val = this[offset] +- var mul = 1 +- var i = 0 +- while (++i < byteLength && (mul *= 0x100)) { +- val += this[offset + i] * mul ++ for (var i = 10; i < input.length; i++) { ++ var next = input.words[i]; ++ input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22); ++ prev = next; + } +- mul *= 0x80 ++ input.words[i - 10] = prev >>> 22; ++ input.length -= 9; ++}; + +- if (val >= mul) val -= Math.pow(2, 8 * byteLength) ++K256.prototype.imulK = function imulK(num) { ++ // K = 0x1000003d1 = [ 0x40, 0x3d1 ] ++ num.words[num.length] = 0; ++ num.words[num.length + 1] = 0; ++ num.length += 2; + +- return val +-} ++ // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390 ++ var hi; ++ var lo = 0; ++ for (var i = 0; i < num.length; i++) { ++ var w = num.words[i]; ++ hi = w * 0x40; ++ lo += w * 0x3d1; ++ hi += (lo / 0x4000000) | 0; ++ lo &= 0x3ffffff; + +-Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { +- offset = offset | 0 +- byteLength = byteLength | 0 +- if (!noAssert) checkOffset(offset, byteLength, this.length) ++ num.words[i] = lo; + +- var i = byteLength +- var mul = 1 +- var val = this[offset + --i] +- while (i > 0 && (mul *= 0x100)) { +- val += this[offset + --i] * mul ++ lo = hi; + } +- mul *= 0x80 + +- if (val >= mul) val -= Math.pow(2, 8 * byteLength) ++ // Fast length reduction ++ if (num.words[num.length - 1] === 0) { ++ num.length--; ++ if (num.words[num.length - 1] === 0) ++ num.length--; ++ } ++ return num; ++}; + +- return val ++function P224() { ++ MPrime.call( ++ this, ++ 'p224', ++ 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001'); + } ++inherits(P224, MPrime); + +-Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { +- if (!noAssert) checkOffset(offset, 1, this.length) +- if (!(this[offset] & 0x80)) return (this[offset]) +- return ((0xff - this[offset] + 1) * -1) ++function P192() { ++ MPrime.call( ++ this, ++ 'p192', ++ 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff'); + } ++inherits(P192, MPrime); + +-Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { +- if (!noAssert) checkOffset(offset, 2, this.length) +- var val = this[offset] | (this[offset + 1] << 8) +- return (val & 0x8000) ? val | 0xFFFF0000 : val ++function P25519() { ++ // 2 ^ 255 - 19 ++ MPrime.call( ++ this, ++ '25519', ++ '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed'); + } ++inherits(P25519, MPrime); + +-Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { +- if (!noAssert) checkOffset(offset, 2, this.length) +- var val = this[offset + 1] | (this[offset] << 8) +- return (val & 0x8000) ? val | 0xFFFF0000 : val +-} ++P25519.prototype.imulK = function imulK(num) { ++ // K = 0x13 ++ var carry = 0; ++ for (var i = 0; i < num.length; i++) { ++ var hi = num.words[i] * 0x13 + carry; ++ var lo = hi & 0x3ffffff; ++ hi >>>= 26; + +-Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { +- if (!noAssert) checkOffset(offset, 4, this.length) ++ num.words[i] = lo; ++ carry = hi; ++ } ++ if (carry !== 0) ++ num.words[num.length++] = carry; ++ return num; ++}; + +- return (this[offset]) | +- (this[offset + 1] << 8) | +- (this[offset + 2] << 16) | +- (this[offset + 3] << 24) +-} ++// Exported mostly for testing purposes, use plain name instead ++BN._prime = function prime(name) { ++ // Cached version of prime ++ if (primes[name]) ++ return primes[name]; + +-Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { +- if (!noAssert) checkOffset(offset, 4, this.length) ++ var prime; ++ if (name === 'k256') ++ prime = new K256(); ++ else if (name === 'p224') ++ prime = new P224(); ++ else if (name === 'p192') ++ prime = new P192(); ++ else if (name === 'p25519') ++ prime = new P25519(); ++ else ++ throw new Error('Unknown prime ' + name); ++ primes[name] = prime; + +- return (this[offset] << 24) | +- (this[offset + 1] << 16) | +- (this[offset + 2] << 8) | +- (this[offset + 3]) +-} ++ return prime; ++}; + +-Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { +- if (!noAssert) checkOffset(offset, 4, this.length) +- return ieee754.read(this, offset, true, 23, 4) ++// ++// Base reduction engine ++// ++function Red(m) { ++ if (typeof m === 'string') { ++ var prime = BN._prime(m); ++ this.m = prime.p; ++ this.prime = prime; ++ } else { ++ this.m = m; ++ this.prime = null; ++ } + } + +-Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { +- if (!noAssert) checkOffset(offset, 4, this.length) +- return ieee754.read(this, offset, false, 23, 4) +-} ++Red.prototype._verify1 = function _verify1(a) { ++ assert(!a.sign, 'red works only with positives'); ++ assert(a.red, 'red works only with red numbers'); ++}; + +-Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { +- if (!noAssert) checkOffset(offset, 8, this.length) +- return ieee754.read(this, offset, true, 52, 8) +-} ++Red.prototype._verify2 = function _verify2(a, b) { ++ assert(!a.sign && !b.sign, 'red works only with positives'); ++ assert(a.red && a.red === b.red, ++ 'red works only with red numbers'); ++}; + +-Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { +- if (!noAssert) checkOffset(offset, 8, this.length) +- return ieee754.read(this, offset, false, 52, 8) +-} ++Red.prototype.imod = function imod(a) { ++ if (this.prime) ++ return this.prime.ireduce(a)._forceRed(this); ++ return a.mod(this.m)._forceRed(this); ++}; + +-function checkInt (buf, value, offset, ext, max, min) { +- if (!Buffer.isBuffer(buf)) throw new TypeError('buffer must be a Buffer instance') +- if (value > max || value < min) throw new RangeError('value is out of bounds') +- if (offset + ext > buf.length) throw new RangeError('index out of range') +-} ++Red.prototype.neg = function neg(a) { ++ var r = a.clone(); ++ r.sign = !r.sign; ++ return r.iadd(this.m)._forceRed(this); ++}; + +-Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { +- value = +value +- offset = offset | 0 +- byteLength = byteLength | 0 +- if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0) ++Red.prototype.add = function add(a, b) { ++ this._verify2(a, b); + +- var mul = 1 +- var i = 0 +- this[offset] = value & 0xFF +- while (++i < byteLength && (mul *= 0x100)) { +- this[offset + i] = (value / mul) & 0xFF +- } ++ var res = a.add(b); ++ if (res.cmp(this.m) >= 0) ++ res.isub(this.m); ++ return res._forceRed(this); ++}; + +- return offset + byteLength +-} ++Red.prototype.iadd = function iadd(a, b) { ++ this._verify2(a, b); + +-Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { +- value = +value +- offset = offset | 0 +- byteLength = byteLength | 0 +- if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0) ++ var res = a.iadd(b); ++ if (res.cmp(this.m) >= 0) ++ res.isub(this.m); ++ return res; ++}; + +- var i = byteLength - 1 +- var mul = 1 +- this[offset + i] = value & 0xFF +- while (--i >= 0 && (mul *= 0x100)) { +- this[offset + i] = (value / mul) & 0xFF +- } ++Red.prototype.sub = function sub(a, b) { ++ this._verify2(a, b); + +- return offset + byteLength +-} ++ var res = a.sub(b); ++ if (res.cmpn(0) < 0) ++ res.iadd(this.m); ++ return res._forceRed(this); ++}; + +-Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { +- value = +value +- offset = offset | 0 +- if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) +- if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) +- this[offset] = (value & 0xff) +- return offset + 1 +-} ++Red.prototype.isub = function isub(a, b) { ++ this._verify2(a, b); + +-function objectWriteUInt16 (buf, value, offset, littleEndian) { +- if (value < 0) value = 0xffff + value + 1 +- for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; i++) { +- buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> +- (littleEndian ? i : 1 - i) * 8 +- } +-} ++ var res = a.isub(b); ++ if (res.cmpn(0) < 0) ++ res.iadd(this.m); ++ return res; ++}; + +-Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { +- value = +value +- offset = offset | 0 +- if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) +- if (Buffer.TYPED_ARRAY_SUPPORT) { +- this[offset] = (value & 0xff) +- this[offset + 1] = (value >>> 8) +- } else { +- objectWriteUInt16(this, value, offset, true) +- } +- return offset + 2 +-} ++Red.prototype.shl = function shl(a, num) { ++ this._verify1(a); ++ return this.imod(a.shln(num)); ++}; + +-Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { +- value = +value +- offset = offset | 0 +- if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) +- if (Buffer.TYPED_ARRAY_SUPPORT) { +- this[offset] = (value >>> 8) +- this[offset + 1] = (value & 0xff) +- } else { +- objectWriteUInt16(this, value, offset, false) +- } +- return offset + 2 +-} ++Red.prototype.imul = function imul(a, b) { ++ this._verify2(a, b); ++ return this.imod(a.imul(b)); ++}; + +-function objectWriteUInt32 (buf, value, offset, littleEndian) { +- if (value < 0) value = 0xffffffff + value + 1 +- for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; i++) { +- buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff +- } +-} ++Red.prototype.mul = function mul(a, b) { ++ this._verify2(a, b); ++ return this.imod(a.mul(b)); ++}; + +-Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { +- value = +value +- offset = offset | 0 +- if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) +- if (Buffer.TYPED_ARRAY_SUPPORT) { +- this[offset + 3] = (value >>> 24) +- this[offset + 2] = (value >>> 16) +- this[offset + 1] = (value >>> 8) +- this[offset] = (value & 0xff) +- } else { +- objectWriteUInt32(this, value, offset, true) +- } +- return offset + 4 +-} ++Red.prototype.isqr = function isqr(a) { ++ return this.imul(a, a); ++}; + +-Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { +- value = +value +- offset = offset | 0 +- if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) +- if (Buffer.TYPED_ARRAY_SUPPORT) { +- this[offset] = (value >>> 24) +- this[offset + 1] = (value >>> 16) +- this[offset + 2] = (value >>> 8) +- this[offset + 3] = (value & 0xff) +- } else { +- objectWriteUInt32(this, value, offset, false) +- } +- return offset + 4 +-} ++Red.prototype.sqr = function sqr(a) { ++ return this.mul(a, a); ++}; + +-Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { +- value = +value +- offset = offset | 0 +- if (!noAssert) { +- var limit = Math.pow(2, 8 * byteLength - 1) ++Red.prototype.sqrt = function sqrt(a) { ++ if (a.cmpn(0) === 0) ++ return a.clone(); + +- checkInt(this, value, offset, byteLength, limit - 1, -limit) ++ var mod3 = this.m.andln(3); ++ assert(mod3 % 2 === 1); ++ ++ // Fast case ++ if (mod3 === 3) { ++ var pow = this.m.add(new BN(1)).ishrn(2); ++ var r = this.pow(a, pow); ++ return r; + } + +- var i = 0 +- var mul = 1 +- var sub = value < 0 ? 1 : 0 +- this[offset] = value & 0xFF +- while (++i < byteLength && (mul *= 0x100)) { +- this[offset + i] = ((value / mul) >> 0) - sub & 0xFF ++ // Tonelli-Shanks algorithm (Totally unoptimized and slow) ++ // ++ // Find Q and S, that Q * 2 ^ S = (P - 1) ++ var q = this.m.subn(1); ++ var s = 0; ++ while (q.cmpn(0) !== 0 && q.andln(1) === 0) { ++ s++; ++ q.ishrn(1); + } ++ assert(q.cmpn(0) !== 0); + +- return offset + byteLength +-} ++ var one = new BN(1).toRed(this); ++ var nOne = one.redNeg(); + +-Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { +- value = +value +- offset = offset | 0 +- if (!noAssert) { +- var limit = Math.pow(2, 8 * byteLength - 1) ++ // Find quadratic non-residue ++ // NOTE: Max is such because of generalized Riemann hypothesis. ++ var lpow = this.m.subn(1).ishrn(1); ++ var z = this.m.bitLength(); ++ z = new BN(2 * z * z).toRed(this); ++ while (this.pow(z, lpow).cmp(nOne) !== 0) ++ z.redIAdd(nOne); + +- checkInt(this, value, offset, byteLength, limit - 1, -limit) +- } ++ var c = this.pow(z, q); ++ var r = this.pow(a, q.addn(1).ishrn(1)); ++ var t = this.pow(a, q); ++ var m = s; ++ while (t.cmp(one) !== 0) { ++ var tmp = t; ++ for (var i = 0; tmp.cmp(one) !== 0; i++) ++ tmp = tmp.redSqr(); ++ assert(i < m); ++ var b = this.pow(c, new BN(1).ishln(m - i - 1)); + +- var i = byteLength - 1 +- var mul = 1 +- var sub = value < 0 ? 1 : 0 +- this[offset + i] = value & 0xFF +- while (--i >= 0 && (mul *= 0x100)) { +- this[offset + i] = ((value / mul) >> 0) - sub & 0xFF ++ r = r.redMul(b); ++ c = b.redSqr(); ++ t = t.redMul(c); ++ m = i; + } + +- return offset + byteLength +-} +- +-Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { +- value = +value +- offset = offset | 0 +- if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) +- if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) +- if (value < 0) value = 0xff + value + 1 +- this[offset] = (value & 0xff) +- return offset + 1 +-} ++ return r; ++}; + +-Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { +- value = +value +- offset = offset | 0 +- if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) +- if (Buffer.TYPED_ARRAY_SUPPORT) { +- this[offset] = (value & 0xff) +- this[offset + 1] = (value >>> 8) ++Red.prototype.invm = function invm(a) { ++ var inv = a._invmp(this.m); ++ if (inv.sign) { ++ inv.sign = false; ++ return this.imod(inv).redNeg(); + } else { +- objectWriteUInt16(this, value, offset, true) ++ return this.imod(inv); + } +- return offset + 2 +-} ++}; + +-Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { +- value = +value +- offset = offset | 0 +- if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) +- if (Buffer.TYPED_ARRAY_SUPPORT) { +- this[offset] = (value >>> 8) +- this[offset + 1] = (value & 0xff) +- } else { +- objectWriteUInt16(this, value, offset, false) +- } +- return offset + 2 +-} ++Red.prototype.pow = function pow(a, num) { ++ var w = []; + +-Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { +- value = +value +- offset = offset | 0 +- if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) +- if (Buffer.TYPED_ARRAY_SUPPORT) { +- this[offset] = (value & 0xff) +- this[offset + 1] = (value >>> 8) +- this[offset + 2] = (value >>> 16) +- this[offset + 3] = (value >>> 24) +- } else { +- objectWriteUInt32(this, value, offset, true) +- } +- return offset + 4 +-} ++ if (num.cmpn(0) === 0) ++ return new BN(1); + +-Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { +- value = +value +- offset = offset | 0 +- if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) +- if (value < 0) value = 0xffffffff + value + 1 +- if (Buffer.TYPED_ARRAY_SUPPORT) { +- this[offset] = (value >>> 24) +- this[offset + 1] = (value >>> 16) +- this[offset + 2] = (value >>> 8) +- this[offset + 3] = (value & 0xff) +- } else { +- objectWriteUInt32(this, value, offset, false) ++ var q = num.clone(); ++ ++ while (q.cmpn(0) !== 0) { ++ w.push(q.andln(1)); ++ q.ishrn(1); + } +- return offset + 4 +-} + +-function checkIEEE754 (buf, value, offset, ext, max, min) { +- if (offset + ext > buf.length) throw new RangeError('index out of range') +- if (offset < 0) throw new RangeError('index out of range') +-} ++ // Skip leading zeroes ++ var res = a; ++ for (var i = 0; i < w.length; i++, res = this.sqr(res)) ++ if (w[i] !== 0) ++ break; + +-function writeFloat (buf, value, offset, littleEndian, noAssert) { +- if (!noAssert) { +- checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) ++ if (++i < w.length) { ++ for (var q = this.sqr(res); i < w.length; i++, q = this.sqr(q)) { ++ if (w[i] === 0) ++ continue; ++ res = this.mul(res, q); ++ } + } +- ieee754.write(buf, value, offset, littleEndian, 23, 4) +- return offset + 4 +-} + +-Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { +- return writeFloat(this, value, offset, true, noAssert) +-} ++ return res; ++}; + +-Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { +- return writeFloat(this, value, offset, false, noAssert) +-} ++Red.prototype.convertTo = function convertTo(num) { ++ var r = num.mod(this.m); ++ if (r === num) ++ return r.clone(); ++ else ++ return r; ++}; + +-function writeDouble (buf, value, offset, littleEndian, noAssert) { +- if (!noAssert) { +- checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) +- } +- ieee754.write(buf, value, offset, littleEndian, 52, 8) +- return offset + 8 +-} ++Red.prototype.convertFrom = function convertFrom(num) { ++ var res = num.clone(); ++ res.red = null; ++ return res; ++}; + +-Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { +- return writeDouble(this, value, offset, true, noAssert) +-} ++// ++// Montgomery method engine ++// + +-Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { +- return writeDouble(this, value, offset, false, noAssert) +-} ++BN.mont = function mont(num) { ++ return new Mont(num); ++}; + +-// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) +-Buffer.prototype.copy = function copy (target, targetStart, start, end) { +- if (!start) start = 0 +- if (!end && end !== 0) end = this.length +- if (targetStart >= target.length) targetStart = target.length +- if (!targetStart) targetStart = 0 +- if (end > 0 && end < start) end = start ++function Mont(m) { ++ Red.call(this, m); + +- // Copy 0 bytes; we're done +- if (end === start) return 0 +- if (target.length === 0 || this.length === 0) return 0 ++ this.shift = this.m.bitLength(); ++ if (this.shift % 26 !== 0) ++ this.shift += 26 - (this.shift % 26); ++ this.r = new BN(1).ishln(this.shift); ++ this.r2 = this.imod(this.r.sqr()); ++ this.rinv = this.r._invmp(this.m); + +- // Fatal error conditions +- if (targetStart < 0) { +- throw new RangeError('targetStart out of bounds') +- } +- if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds') +- if (end < 0) throw new RangeError('sourceEnd out of bounds') ++ this.minv = this.rinv.mul(this.r).isubn(1).div(this.m); ++ this.minv.sign = true; ++ this.minv = this.minv.mod(this.r); ++} ++inherits(Mont, Red); + +- // Are we oob? +- if (end > this.length) end = this.length +- if (target.length - targetStart < end - start) { +- end = target.length - targetStart + start +- } ++Mont.prototype.convertTo = function convertTo(num) { ++ return this.imod(num.shln(this.shift)); ++}; + +- var len = end - start +- var i ++Mont.prototype.convertFrom = function convertFrom(num) { ++ var r = this.imod(num.mul(this.rinv)); ++ r.red = null; ++ return r; ++}; + +- if (this === target && start < targetStart && targetStart < end) { +- // descending copy from end +- for (i = len - 1; i >= 0; i--) { +- target[i + targetStart] = this[i + start] +- } +- } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { +- // ascending copy from start +- for (i = 0; i < len; i++) { +- target[i + targetStart] = this[i + start] +- } +- } else { +- Uint8Array.prototype.set.call( +- target, +- this.subarray(start, start + len), +- targetStart +- ) ++Mont.prototype.imul = function imul(a, b) { ++ if (a.cmpn(0) === 0 || b.cmpn(0) === 0) { ++ a.words[0] = 0; ++ a.length = 1; ++ return a; + } + +- return len +-} ++ var t = a.imul(b); ++ var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); ++ var u = t.isub(c).ishrn(this.shift); ++ var res = u; ++ if (u.cmp(this.m) >= 0) ++ res = u.isub(this.m); ++ else if (u.cmpn(0) < 0) ++ res = u.iadd(this.m); + +-// fill(value, start=0, end=buffer.length) +-Buffer.prototype.fill = function fill (value, start, end) { +- if (!value) value = 0 +- if (!start) start = 0 +- if (!end) end = this.length ++ return res._forceRed(this); ++}; + +- if (end < start) throw new RangeError('end < start') ++Mont.prototype.mul = function mul(a, b) { ++ if (a.cmpn(0) === 0 || b.cmpn(0) === 0) ++ return new BN(0)._forceRed(this); + +- // Fill 0 bytes; we're done +- if (end === start) return +- if (this.length === 0) return ++ var t = a.mul(b); ++ var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); ++ var u = t.isub(c).ishrn(this.shift); ++ var res = u; ++ if (u.cmp(this.m) >= 0) ++ res = u.isub(this.m); ++ else if (u.cmpn(0) < 0) ++ res = u.iadd(this.m); + +- if (start < 0 || start >= this.length) throw new RangeError('start out of bounds') +- if (end < 0 || end > this.length) throw new RangeError('end out of bounds') ++ return res._forceRed(this); ++}; + +- var i +- if (typeof value === 'number') { +- for (i = start; i < end; i++) { +- this[i] = value +- } +- } else { +- var bytes = utf8ToBytes(value.toString()) +- var len = bytes.length +- for (i = start; i < end; i++) { +- this[i] = bytes[i % len] +- } +- } ++Mont.prototype.invm = function invm(a) { ++ // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R ++ var res = this.imod(a._invmp(this.m).mul(this.r2)); ++ return res._forceRed(this); ++}; + +- return this +-} ++})(typeof module === 'undefined' || module, this); + +-// HELPER FUNCTIONS +-// ================ ++},{}],37:[function(require,module,exports){ ++'use strict' + +-var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g ++module.exports = boundary + +-function base64clean (str) { +- // Node strips out invalid characters like \n and \t from the string, base64-js does not +- str = stringtrim(str).replace(INVALID_BASE64_RE, '') +- // Node converts strings with length < 2 to '' +- if (str.length < 2) return '' +- // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not +- while (str.length % 4 !== 0) { +- str = str + '=' ++function boundary (cells) { ++ var i, j, k ++ var n = cells.length ++ var sz = 0 ++ for (i = 0; i < n; ++i) { ++ sz += cells[i].length + } +- return str ++ var result = new Array(sz) ++ var ptr = 0 ++ for (i = 0; i < n; ++i) { ++ var c = cells[i] ++ var d = c.length ++ for (j = 0; j < d; ++j) { ++ var b = result[ptr++] = new Array(d - 1) ++ var p = 0 ++ for (k = 0; k < d; ++k) { ++ if (k === j) { ++ continue ++ } ++ b[p++] = c[k] ++ } ++ if (j & 1) { ++ var tmp = b[1] ++ b[1] = b[0] ++ b[0] = tmp ++ } ++ } ++ } ++ return result + } + +-function stringtrim (str) { +- if (str.trim) return str.trim() +- return str.replace(/^\s+|\s+$/g, '') ++},{}],38:[function(require,module,exports){ ++'use strict' ++ ++module.exports = boxIntersectWrapper ++ ++var pool = require('typedarray-pool') ++var sweep = require('./lib/sweep') ++var boxIntersectIter = require('./lib/intersect') ++ ++function boxEmpty(d, box) { ++ for(var j=0; j 0xD7FF && codePoint < 0xE000) { +- // last char was a lead +- if (!leadSurrogate) { +- // no lead yet +- if (codePoint > 0xDBFF) { +- // unexpected trail +- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) +- continue +- } else if (i + 1 === length) { +- // unpaired lead +- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) +- continue +- } ++ //Compute dimension, if it is 0 then we skip ++ var d = (red[0].length)>>>1 ++ if(d <= 0) { ++ return ++ } + +- // valid lead +- leadSurrogate = codePoint ++ var retval + +- continue +- } ++ //Convert red boxes ++ var redList = pool.mallocDouble(2*d*n) ++ var redIds = pool.mallocInt32(n) ++ n = convertBoxes(red, d, redList, redIds) + +- // 2 leads in a row +- if (codePoint < 0xDC00) { +- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) +- leadSurrogate = codePoint +- continue +- } ++ if(n > 0) { ++ if(d === 1 && full) { ++ //Special case: 1d complete ++ sweep.init(n) ++ retval = sweep.sweepComplete( ++ d, visit, ++ 0, n, redList, redIds, ++ 0, n, redList, redIds) ++ } else { + +- // valid surrogate pair +- codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 +- } else if (leadSurrogate) { +- // valid bmp char, but last char was a lead +- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) +- } ++ //Convert blue boxes ++ var blueList = pool.mallocDouble(2*d*m) ++ var blueIds = pool.mallocInt32(m) ++ m = convertBoxes(blue, d, blueList, blueIds) + +- leadSurrogate = null ++ if(m > 0) { ++ sweep.init(n+m) + +- // encode utf8 +- if (codePoint < 0x80) { +- if ((units -= 1) < 0) break +- bytes.push(codePoint) +- } else if (codePoint < 0x800) { +- if ((units -= 2) < 0) break +- bytes.push( +- codePoint >> 0x6 | 0xC0, +- codePoint & 0x3F | 0x80 +- ) +- } else if (codePoint < 0x10000) { +- if ((units -= 3) < 0) break +- bytes.push( +- codePoint >> 0xC | 0xE0, +- codePoint >> 0x6 & 0x3F | 0x80, +- codePoint & 0x3F | 0x80 +- ) +- } else if (codePoint < 0x110000) { +- if ((units -= 4) < 0) break +- bytes.push( +- codePoint >> 0x12 | 0xF0, +- codePoint >> 0xC & 0x3F | 0x80, +- codePoint >> 0x6 & 0x3F | 0x80, +- codePoint & 0x3F | 0x80 +- ) +- } else { +- throw new Error('Invalid code point') ++ if(d === 1) { ++ //Special case: 1d bipartite ++ retval = sweep.sweepBipartite( ++ d, visit, ++ 0, n, redList, redIds, ++ 0, m, blueList, blueIds) ++ } else { ++ //General case: d>1 ++ retval = boxIntersectIter( ++ d, visit, full, ++ n, redList, redIds, ++ m, blueList, blueIds) ++ } ++ ++ pool.free(blueList) ++ pool.free(blueIds) ++ } + } ++ ++ pool.free(redList) ++ pool.free(redIds) + } + +- return bytes ++ return retval + } + +-function asciiToBytes (str) { +- var byteArray = [] +- for (var i = 0; i < str.length; i++) { +- // Node's code seems to be doing this and not & 0x7F.. +- byteArray.push(str.charCodeAt(i) & 0xFF) +- } +- return byteArray +-} + +-function utf16leToBytes (str, units) { +- var c, hi, lo +- var byteArray = [] +- for (var i = 0; i < str.length; i++) { +- if ((units -= 2) < 0) break ++var RESULT + +- c = str.charCodeAt(i) +- hi = c >> 8 +- lo = c % 256 +- byteArray.push(lo) +- byteArray.push(hi) +- } ++function appendItem(i,j) { ++ RESULT.push([i,j]) ++} + +- return byteArray ++function intersectFullArray(x) { ++ RESULT = [] ++ boxIntersect(x, x, appendItem, true) ++ return RESULT + } + +-function base64ToBytes (str) { +- return base64.toByteArray(base64clean(str)) ++function intersectBipartiteArray(x, y) { ++ RESULT = [] ++ boxIntersect(x, y, appendItem, false) ++ return RESULT + } + +-function blitBuffer (src, dst, offset, length) { +- for (var i = 0; i < length; i++) { +- if ((i + offset >= dst.length) || (i >= src.length)) break +- dst[i + offset] = src[i] ++//User-friendly wrapper, handle full input and no-visitor cases ++function boxIntersectWrapper(arg0, arg1, arg2) { ++ var result ++ switch(arguments.length) { ++ case 1: ++ return intersectFullArray(arg0) ++ case 2: ++ if(typeof arg1 === 'function') { ++ return boxIntersect(arg0, arg0, arg1, true) ++ } else { ++ return intersectBipartiteArray(arg0, arg1) ++ } ++ case 3: ++ return boxIntersect(arg0, arg1, arg2, false) ++ default: ++ throw new Error('box-intersect: Invalid arguments') + } +- return i + } +- +-}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +-},{"base64-js":40,"ieee754":41,"isarray":42}],40:[function(require,module,exports){ ++},{"./lib/intersect":40,"./lib/sweep":44,"typedarray-pool":246}],39:[function(require,module,exports){ + 'use strict' + +-exports.toByteArray = toByteArray +-exports.fromByteArray = fromByteArray +- +-var lookup = [] +-var revLookup = [] +-var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array ++var DIMENSION = 'd' ++var AXIS = 'ax' ++var VISIT = 'vv' ++var FLIP = 'fp' + +-function init () { +- var i +- var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' +- var len = code.length ++var ELEM_SIZE = 'es' + +- for (i = 0; i < len; i++) { +- lookup[i] = code[i] +- } ++var RED_START = 'rs' ++var RED_END = 're' ++var RED_BOXES = 'rb' ++var RED_INDEX = 'ri' ++var RED_PTR = 'rp' + +- for (i = 0; i < len; ++i) { +- revLookup[code.charCodeAt(i)] = i +- } +- revLookup['-'.charCodeAt(0)] = 62 +- revLookup['_'.charCodeAt(0)] = 63 +-} ++var BLUE_START = 'bs' ++var BLUE_END = 'be' ++var BLUE_BOXES = 'bb' ++var BLUE_INDEX = 'bi' ++var BLUE_PTR = 'bp' + +-init() ++var RETVAL = 'rv' + +-function toByteArray (b64) { +- var i, j, l, tmp, placeHolders, arr +- var len = b64.length ++var INNER_LABEL = 'Q' + +- if (len % 4 > 0) { +- throw new Error('Invalid string. Length must be a multiple of 4') +- } ++var ARGS = [ ++ DIMENSION, ++ AXIS, ++ VISIT, ++ RED_START, ++ RED_END, ++ RED_BOXES, ++ RED_INDEX, ++ BLUE_START, ++ BLUE_END, ++ BLUE_BOXES, ++ BLUE_INDEX ++] + +- // the number of equal signs (place holders) +- // if there are two placeholders, than the two characters before it +- // represent one byte +- // if there is only one, then the three characters before it represent 2 bytes +- // this is just a cheap hack to not do indexOf twice +- placeHolders = b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0 ++function generateBruteForce(redMajor, flip, full) { ++ var funcName = 'bruteForce' + ++ (redMajor ? 'Red' : 'Blue') + ++ (flip ? 'Flip' : '') + ++ (full ? 'Full' : '') + +- // base64 is 4/3 + up to two characters of the original data +- arr = new Arr(len * 3 / 4 - placeHolders) ++ var code = ['function ', funcName, '(', ARGS.join(), '){', ++ 'var ', ELEM_SIZE, '=2*', DIMENSION, ';'] + +- // if there are placeholders, only get up to the last complete 4 chars +- l = placeHolders > 0 ? len - 4 : len ++ var redLoop = ++ 'for(var i=' + RED_START + ',' + RED_PTR + '=' + ELEM_SIZE + '*' + RED_START + ';' + ++ 'i<' + RED_END +';' + ++ '++i,' + RED_PTR + '+=' + ELEM_SIZE + '){' + ++ 'var x0=' + RED_BOXES + '[' + AXIS + '+' + RED_PTR + '],' + ++ 'x1=' + RED_BOXES + '[' + AXIS + '+' + RED_PTR + '+' + DIMENSION + '],' + ++ 'xi=' + RED_INDEX + '[i];' + +- var L = 0 ++ var blueLoop = ++ 'for(var j=' + BLUE_START + ',' + BLUE_PTR + '=' + ELEM_SIZE + '*' + BLUE_START + ';' + ++ 'j<' + BLUE_END + ';' + ++ '++j,' + BLUE_PTR + '+=' + ELEM_SIZE + '){' + ++ 'var y0=' + BLUE_BOXES + '[' + AXIS + '+' + BLUE_PTR + '],' + ++ (full ? 'y1=' + BLUE_BOXES + '[' + AXIS + '+' + BLUE_PTR + '+' + DIMENSION + '],' : '') + ++ 'yi=' + BLUE_INDEX + '[j];' + +- for (i = 0, j = 0; i < l; i += 4, j += 3) { +- tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)] +- arr[L++] = (tmp & 0xFF0000) >> 16 +- arr[L++] = (tmp & 0xFF00) >> 8 +- arr[L++] = tmp & 0xFF ++ if(redMajor) { ++ code.push(redLoop, INNER_LABEL, ':', blueLoop) ++ } else { ++ code.push(blueLoop, INNER_LABEL, ':', redLoop) + } + +- if (placeHolders === 2) { +- tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4) +- arr[L++] = tmp & 0xFF +- } else if (placeHolders === 1) { +- tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2) +- arr[L++] = (tmp >> 8) & 0xFF +- arr[L++] = tmp & 0xFF ++ if(full) { ++ code.push('if(y1> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F] +-} ++ code.push('for(var k='+AXIS+'+1;k<'+DIMENSION+';++k){'+ ++ 'var r0='+RED_BOXES+'[k+'+RED_PTR+'],'+ ++ 'r1='+RED_BOXES+'[k+'+DIMENSION+'+'+RED_PTR+'],'+ ++ 'b0='+BLUE_BOXES+'[k+'+BLUE_PTR+'],'+ ++ 'b1='+BLUE_BOXES+'[k+'+DIMENSION+'+'+BLUE_PTR+'];'+ ++ 'if(r1 len2 ? len2 : (i + maxChunkLength))) +- } ++ code.push(');if(' + RETVAL + '!==void 0)return ' + RETVAL + ';}}}') + +- // pad the end with zeros, but make sure to not forget the extra bytes +- if (extraBytes === 1) { +- tmp = uint8[len - 1] +- output += lookup[tmp >> 2] +- output += lookup[(tmp << 4) & 0x3F] +- output += '==' +- } else if (extraBytes === 2) { +- tmp = (uint8[len - 2] << 8) + (uint8[len - 1]) +- output += lookup[tmp >> 10] +- output += lookup[(tmp >> 4) & 0x3F] +- output += lookup[(tmp << 2) & 0x3F] +- output += '=' ++ return { ++ name: funcName, ++ code: code.join('') + } +- +- parts.push(output) +- +- return parts.join('') + } + +-},{}],41:[function(require,module,exports){ +-exports.read = function (buffer, offset, isLE, mLen, nBytes) { +- var e, m +- var eLen = nBytes * 8 - mLen - 1 +- var eMax = (1 << eLen) - 1 +- var eBias = eMax >> 1 +- var nBits = -7 +- var i = isLE ? (nBytes - 1) : 0 +- var d = isLE ? -1 : 1 +- var s = buffer[offset + i] ++function bruteForcePlanner(full) { ++ var funcName = 'bruteForce' + (full ? 'Full' : 'Partial') ++ var prefix = [] ++ var fargs = ARGS.slice() ++ if(!full) { ++ fargs.splice(3, 0, FLIP) ++ } + +- i += d ++ var code = ['function ' + funcName + '(' + fargs.join() + '){'] + +- e = s & ((1 << (-nBits)) - 1) +- s >>= (-nBits) +- nBits += eLen +- for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {} ++ function invoke(redMajor, flip) { ++ var res = generateBruteForce(redMajor, flip, full) ++ prefix.push(res.code) ++ code.push('return ' + res.name + '(' + ARGS.join() + ');') ++ } + +- m = e & ((1 << (-nBits)) - 1) +- e >>= (-nBits) +- nBits += mLen +- for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {} ++ code.push('if(' + RED_END + '-' + RED_START + '>' + ++ BLUE_END + '-' + BLUE_START + '){') + +- if (e === 0) { +- e = 1 - eBias +- } else if (e === eMax) { +- return m ? NaN : ((s ? -1 : 1) * Infinity) ++ if(full) { ++ invoke(true, false) ++ code.push('}else{') ++ invoke(false, false) + } else { +- m = m + Math.pow(2, mLen) +- e = e - eBias ++ code.push('if(' + FLIP + '){') ++ invoke(true, true) ++ code.push('}else{') ++ invoke(true, false) ++ code.push('}}else{if(' + FLIP + '){') ++ invoke(false, true) ++ code.push('}else{') ++ invoke(false, false) ++ code.push('}') + } +- return (s ? -1 : 1) * m * Math.pow(2, e - mLen) ++ code.push('}}return ' + funcName) ++ ++ var codeStr = prefix.join('') + code.join('') ++ var proc = new Function(codeStr) ++ return proc() + } + +-exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { +- var e, m, c +- var eLen = nBytes * 8 - mLen - 1 +- var eMax = (1 << eLen) - 1 +- var eBias = eMax >> 1 +- var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) +- var i = isLE ? 0 : (nBytes - 1) +- var d = isLE ? 1 : -1 +- var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 + +- value = Math.abs(value) ++exports.partial = bruteForcePlanner(false) ++exports.full = bruteForcePlanner(true) ++},{}],40:[function(require,module,exports){ ++'use strict' + +- if (isNaN(value) || value === Infinity) { +- m = isNaN(value) ? 1 : 0 +- e = eMax +- } else { +- e = Math.floor(Math.log(value) / Math.LN2) +- if (value * (c = Math.pow(2, -e)) < 1) { +- e-- +- c *= 2 +- } +- if (e + eBias >= 1) { +- value += rt / c +- } else { +- value += rt * Math.pow(2, 1 - eBias) +- } +- if (value * c >= 2) { +- e++ +- c /= 2 +- } ++module.exports = boxIntersectIter + +- if (e + eBias >= eMax) { +- m = 0 +- e = eMax +- } else if (e + eBias >= 1) { +- m = (value * c - 1) * Math.pow(2, mLen) +- e = e + eBias +- } else { +- m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) +- e = 0 +- } +- } ++var pool = require('typedarray-pool') ++var bits = require('bit-twiddle') ++var bruteForce = require('./brute') ++var bruteForcePartial = bruteForce.partial ++var bruteForceFull = bruteForce.full ++var sweep = require('./sweep') ++var findMedian = require('./median') ++var genPartition = require('./partition') + +- for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} ++//Twiddle parameters ++var BRUTE_FORCE_CUTOFF = 128 //Cut off for brute force search ++var SCAN_CUTOFF = (1<<22) //Cut off for two way scan ++var SCAN_COMPLETE_CUTOFF = (1<<22) + +- e = (e << mLen) | m +- eLen += mLen +- for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} ++//Partition functions ++var partitionInteriorContainsInterval = genPartition( ++ '!(lo>=p0)&&!(p1>=hi)', ++ ['p0', 'p1']) + +- buffer[offset + i - d] |= s * 128 +-} ++var partitionStartEqual = genPartition( ++ 'lo===p0', ++ ['p0']) + +-},{}],42:[function(require,module,exports){ +-var toString = {}.toString; ++var partitionStartLessThan = genPartition( ++ 'lo 0 && this._events[type].length > m) { +- this._events[type].warned = true; +- console.error('(node) warning: possible EventEmitter memory ' + +- 'leak detected. %d listeners added. ' + +- 'Use emitter.setMaxListeners() to increase limit.', +- this._events[type].length); +- if (typeof console.trace === 'function') { +- // not supported in IE 10 +- console.trace(); ++ var r0 = red[redPtr+axis] ++ var r1 = red[redPtr+axis+d] ++ if(blueX < r0 || r1 < blueX) { ++ continue ++ } ++ for(var j=axis+1; j 0) { ++ top -= 1 + +- if (!isFunction(listener)) +- throw TypeError('listener must be a function'); ++ var iptr = top * IFRAME_SIZE ++ var axis = BOX_ISTACK[iptr] ++ var redStart = BOX_ISTACK[iptr+1] ++ var redEnd = BOX_ISTACK[iptr+2] ++ var blueStart = BOX_ISTACK[iptr+3] ++ var blueEnd = BOX_ISTACK[iptr+4] ++ var state = BOX_ISTACK[iptr+5] + +- if (!this._events || !this._events[type]) +- return this; ++ var dptr = top * DFRAME_SIZE ++ var lo = BOX_DSTACK[dptr] ++ var hi = BOX_DSTACK[dptr+1] + +- list = this._events[type]; +- length = list.length; +- position = -1; ++ //Unpack state info ++ var flip = (state & 1) ++ var full = !!(state & 16) + +- if (list === listener || +- (isFunction(list.listener) && list.listener === listener)) { +- delete this._events[type]; +- if (this._events.removeListener) +- this.emit('removeListener', type, listener); ++ //Unpack indices ++ var red = xBoxes ++ var redIndex = xIndex ++ var blue = yBoxes ++ var blueIndex = yIndex ++ if(flip) { ++ red = yBoxes ++ redIndex = yIndex ++ blue = xBoxes ++ blueIndex = xIndex ++ } + +- } else if (isObject(list)) { +- for (i = length; i-- > 0;) { +- if (list[i] === listener || +- (list[i].listener && list[i].listener === listener)) { +- position = i; +- break; ++ if(state & 2) { ++ redEnd = partitionStartLessThan( ++ d, axis, ++ redStart, redEnd, red, redIndex, ++ hi) ++ if(redStart >= redEnd) { ++ continue + } + } ++ if(state & 4) { ++ redStart = partitionEndLessThanEqual( ++ d, axis, ++ redStart, redEnd, red, redIndex, ++ lo) ++ if(redStart >= redEnd) { ++ continue ++ } ++ } ++ ++ var redCount = redEnd - redStart ++ var blueCount = blueEnd - blueStart + +- if (position < 0) +- return this; +- +- if (list.length === 1) { +- list.length = 0; +- delete this._events[type]; ++ if(full) { ++ if(d * redCount * (redCount + blueCount) < SCAN_COMPLETE_CUTOFF) { ++ retval = sweep.scanComplete( ++ d, axis, visit, ++ redStart, redEnd, red, redIndex, ++ blueStart, blueEnd, blue, blueIndex) ++ if(retval !== void 0) { ++ return retval ++ } ++ continue ++ } + } else { +- list.splice(position, 1); ++ if(d * Math.min(redCount, blueCount) < BRUTE_FORCE_CUTOFF) { ++ //If input small, then use brute force ++ retval = bruteForcePartial( ++ d, axis, visit, flip, ++ redStart, redEnd, red, redIndex, ++ blueStart, blueEnd, blue, blueIndex) ++ if(retval !== void 0) { ++ return retval ++ } ++ continue ++ } else if(d * redCount * blueCount < SCAN_CUTOFF) { ++ //If input medium sized, then use sweep and prune ++ retval = sweep.scanBipartite( ++ d, axis, visit, flip, ++ redStart, redEnd, red, redIndex, ++ blueStart, blueEnd, blue, blueIndex) ++ if(retval !== void 0) { ++ return retval ++ } ++ continue ++ } + } ++ ++ //First, find all red intervals whose interior contains (lo,hi) ++ var red0 = partitionInteriorContainsInterval( ++ d, axis, ++ redStart, redEnd, red, redIndex, ++ lo, hi) + +- if (this._events.removeListener) +- this.emit('removeListener', type, listener); +- } +- +- return this; +-}; +- +-EventEmitter.prototype.removeAllListeners = function(type) { +- var key, listeners; +- +- if (!this._events) +- return this; +- +- // not listening for removeListener, no need to emit +- if (!this._events.removeListener) { +- if (arguments.length === 0) +- this._events = {}; +- else if (this._events[type]) +- delete this._events[type]; +- return this; +- } ++ //Lower dimensional case ++ if(redStart < red0) { + +- // emit removeListener for all listeners on all events +- if (arguments.length === 0) { +- for (key in this._events) { +- if (key === 'removeListener') continue; +- this.removeAllListeners(key); ++ if(d * (red0 - redStart) < BRUTE_FORCE_CUTOFF) { ++ //Special case for small inputs: use brute force ++ retval = bruteForceFull( ++ d, axis+1, visit, ++ redStart, red0, red, redIndex, ++ blueStart, blueEnd, blue, blueIndex) ++ if(retval !== void 0) { ++ return retval ++ } ++ } else if(axis === d-2) { ++ if(flip) { ++ retval = sweep.sweepBipartite( ++ d, visit, ++ blueStart, blueEnd, blue, blueIndex, ++ redStart, red0, red, redIndex) ++ } else { ++ retval = sweep.sweepBipartite( ++ d, visit, ++ redStart, red0, red, redIndex, ++ blueStart, blueEnd, blue, blueIndex) ++ } ++ if(retval !== void 0) { ++ return retval ++ } ++ } else { ++ iterPush(top++, ++ axis+1, ++ redStart, red0, ++ blueStart, blueEnd, ++ flip, ++ -Infinity, Infinity) ++ iterPush(top++, ++ axis+1, ++ blueStart, blueEnd, ++ redStart, red0, ++ flip^1, ++ -Infinity, Infinity) ++ } + } +- this.removeAllListeners('removeListener'); +- this._events = {}; +- return this; +- } +- +- listeners = this._events[type]; +- +- if (isFunction(listeners)) { +- this.removeListener(type, listeners); +- } else if (listeners) { +- // LIFO order +- while (listeners.length) +- this.removeListener(type, listeners[listeners.length - 1]); +- } +- delete this._events[type]; + +- return this; +-}; ++ //Divide and conquer phase ++ if(red0 < redEnd) { + +-EventEmitter.prototype.listeners = function(type) { +- var ret; +- if (!this._events || !this._events[type]) +- ret = []; +- else if (isFunction(this._events[type])) +- ret = [this._events[type]]; +- else +- ret = this._events[type].slice(); +- return ret; +-}; ++ //Cut blue into 3 parts: ++ // ++ // Points < mid point ++ // Points = mid point ++ // Points > mid point ++ // ++ var blue0 = findMedian( ++ d, axis, ++ blueStart, blueEnd, blue, blueIndex) ++ var mid = blue[elemSize * blue0 + axis] ++ var blue1 = partitionStartEqual( ++ d, axis, ++ blue0, blueEnd, blue, blueIndex, ++ mid) + +-EventEmitter.prototype.listenerCount = function(type) { +- if (this._events) { +- var evlistener = this._events[type]; ++ //Right case ++ if(blue1 < blueEnd) { ++ iterPush(top++, ++ axis, ++ red0, redEnd, ++ blue1, blueEnd, ++ (flip|4) + (full ? 16 : 0), ++ mid, hi) ++ } + +- if (isFunction(evlistener)) +- return 1; +- else if (evlistener) +- return evlistener.length; +- } +- return 0; +-}; +- +-EventEmitter.listenerCount = function(emitter, type) { +- return emitter.listenerCount(type); +-}; ++ //Left case ++ if(blueStart < blue0) { ++ iterPush(top++, ++ axis, ++ red0, redEnd, ++ blueStart, blue0, ++ (flip|2) + (full ? 16 : 0), ++ lo, mid) ++ } + +-function isFunction(arg) { +- return typeof arg === 'function'; +-} ++ //Center case (the hard part) ++ if(blue0 + 1 === blue1) { ++ //Optimization: Range with exactly 1 point, use a brute force scan ++ if(full) { ++ retval = onePointFull( ++ d, axis, visit, ++ red0, redEnd, red, redIndex, ++ blue0, blue, blueIndex[blue0]) ++ } else { ++ retval = onePointPartial( ++ d, axis, visit, flip, ++ red0, redEnd, red, redIndex, ++ blue0, blue, blueIndex[blue0]) ++ } ++ if(retval !== void 0) { ++ return retval ++ } ++ } else if(blue0 < blue1) { ++ var red1 ++ if(full) { ++ //If full intersection, need to handle special case ++ red1 = partitionContainsPoint( ++ d, axis, ++ red0, redEnd, red, redIndex, ++ mid) ++ if(red0 < red1) { ++ var redX = partitionStartEqual( ++ d, axis, ++ red0, red1, red, redIndex, ++ mid) ++ if(axis === d-2) { ++ //Degenerate sweep intersection: ++ // [red0, redX] with [blue0, blue1] ++ if(red0 < redX) { ++ retval = sweep.sweepComplete( ++ d, visit, ++ red0, redX, red, redIndex, ++ blue0, blue1, blue, blueIndex) ++ if(retval !== void 0) { ++ return retval ++ } ++ } + +-function isNumber(arg) { +- return typeof arg === 'number'; ++ //Normal sweep intersection: ++ // [redX, red1] with [blue0, blue1] ++ if(redX < red1) { ++ retval = sweep.sweepBipartite( ++ d, visit, ++ redX, red1, red, redIndex, ++ blue0, blue1, blue, blueIndex) ++ if(retval !== void 0) { ++ return retval ++ } ++ } ++ } else { ++ if(red0 < redX) { ++ iterPush(top++, ++ axis+1, ++ red0, redX, ++ blue0, blue1, ++ 16, ++ -Infinity, Infinity) ++ } ++ if(redX < red1) { ++ iterPush(top++, ++ axis+1, ++ redX, red1, ++ blue0, blue1, ++ 0, ++ -Infinity, Infinity) ++ iterPush(top++, ++ axis+1, ++ blue0, blue1, ++ redX, red1, ++ 1, ++ -Infinity, Infinity) ++ } ++ } ++ } ++ } else { ++ if(flip) { ++ red1 = partitionContainsPointProper( ++ d, axis, ++ red0, redEnd, red, redIndex, ++ mid) ++ } else { ++ red1 = partitionContainsPoint( ++ d, axis, ++ red0, redEnd, red, redIndex, ++ mid) ++ } ++ if(red0 < red1) { ++ if(axis === d-2) { ++ if(flip) { ++ retval = sweep.sweepBipartite( ++ d, visit, ++ blue0, blue1, blue, blueIndex, ++ red0, red1, red, redIndex) ++ } else { ++ retval = sweep.sweepBipartite( ++ d, visit, ++ red0, red1, red, redIndex, ++ blue0, blue1, blue, blueIndex) ++ } ++ } else { ++ iterPush(top++, ++ axis+1, ++ red0, red1, ++ blue0, blue1, ++ flip, ++ -Infinity, Infinity) ++ iterPush(top++, ++ axis+1, ++ blue0, blue1, ++ red0, red1, ++ flip^1, ++ -Infinity, Infinity) ++ } ++ } ++ } ++ } ++ } ++ } + } ++},{"./brute":39,"./median":41,"./partition":42,"./sweep":44,"bit-twiddle":35,"typedarray-pool":246}],41:[function(require,module,exports){ ++'use strict' + +-function isObject(arg) { +- return typeof arg === 'object' && arg !== null; +-} ++module.exports = findMedian + +-function isUndefined(arg) { +- return arg === void 0; +-} ++var genPartition = require('./partition') + +-},{}],44:[function(require,module,exports){ +-// shim for using process in browser ++var partitionStartLessThan = genPartition('lostart && boxes[ptr+axis] > x; ++ --j, ptr-=elemSize) { ++ //Swap ++ var aPtr = ptr ++ var bPtr = ptr+elemSize ++ for(var k=0; k 1) { +- for (var i = 1; i < arguments.length; i++) { +- args[i - 1] = arguments[i]; +- } ++ var lo = start ++ var hi = end ++ var mid = ((end + start) >>> 1) ++ var elemSize = 2*d ++ var pivot = mid ++ var value = boxes[elemSize*mid+axis] ++ ++ while(lo < hi) { ++ if(hi - lo < PARTITION_THRESHOLD) { ++ insertionSort(d, axis, lo, hi, boxes, ids) ++ value = boxes[elemSize*mid+axis] ++ break + } +- queue.push(new Item(fun, args)); +- if (queue.length === 1 && !draining) { +- setTimeout(drainQueue, 0); ++ ++ //Select pivot using median-of-3 ++ var count = hi - lo ++ var pivot0 = (Math.random()*count+lo)|0 ++ var value0 = boxes[elemSize*pivot0 + axis] ++ var pivot1 = (Math.random()*count+lo)|0 ++ var value1 = boxes[elemSize*pivot1 + axis] ++ var pivot2 = (Math.random()*count+lo)|0 ++ var value2 = boxes[elemSize*pivot2 + axis] ++ if(value0 <= value1) { ++ if(value2 >= value1) { ++ pivot = pivot1 ++ value = value1 ++ } else if(value0 >= value2) { ++ pivot = pivot0 ++ value = value0 ++ } else { ++ pivot = pivot2 ++ value = value2 ++ } ++ } else { ++ if(value1 >= value2) { ++ pivot = pivot1 ++ value = value1 ++ } else if(value2 >= value0) { ++ pivot = pivot0 ++ value = value0 ++ } else { ++ pivot = pivot2 ++ value = value2 ++ } + } +-}; +- +-// v8 likes predictible objects +-function Item(fun, array) { +- this.fun = fun; +- this.array = array; +-} +-Item.prototype.run = function () { +- this.fun.apply(null, this.array); +-}; +-process.title = 'browser'; +-process.browser = true; +-process.env = {}; +-process.argv = []; +-process.version = ''; // empty string to avoid regexp issues +-process.versions = {}; + +-function noop() {} ++ //Swap pivot to end of array ++ var aPtr = elemSize * (hi-1) ++ var bPtr = elemSize * pivot ++ for(var i=0; i= 0) { ++ reads.push('lo=e[k+n]') ++ } ++ if(predicate.indexOf('hi') >= 0) { ++ reads.push('hi=e[k+o]') ++ } ++ fargs.push( ++ code.replace('_', reads.join()) ++ .replace('$', predicate)) ++ return Function.apply(void 0, fargs) + } ++},{}],43:[function(require,module,exports){ ++'use strict'; + +-function canonicalizeEdges(edges) { +- return edges.map(canonicalizeEdge).sort(compareEdge) +-} ++//This code is extracted from ndarray-sort ++//It is inlined here as a temporary workaround + +-function getDefault(options, property, dflt) { +- if(property in options) { +- return options[property] +- } +- return dflt +-} ++module.exports = wrapper; + +-function cdt2d(points, edges, options) { ++var INSERT_SORT_CUTOFF = 32 + +- if(!Array.isArray(edges)) { +- options = edges || {} +- edges = [] ++function wrapper(data, n0) { ++ if (n0 <= 4*INSERT_SORT_CUTOFF) { ++ insertionSort(0, n0 - 1, data); + } else { +- options = options || {} +- edges = edges || [] ++ quickSort(0, n0 - 1, data); + } ++} + +- //Parse out options +- var delaunay = !!getDefault(options, 'delaunay', true) +- var interior = !!getDefault(options, 'interior', true) +- var exterior = !!getDefault(options, 'exterior', true) +- var infinity = !!getDefault(options, 'infinity', false) +- +- //Handle trivial case +- if((!interior && !exterior) || points.length === 0) { +- return [] ++function insertionSort(left, right, data) { ++ var ptr = 2*(left+1) ++ for(var i=left+1; i<=right; ++i) { ++ var a = data[ptr++] ++ var b = data[ptr++] ++ var j = i ++ var jptr = ptr-2 ++ while(j-- > left) { ++ var x = data[jptr-2] ++ var y = data[jptr-1] ++ if(x < a) { ++ break ++ } else if(x === a && y < b) { ++ break ++ } ++ data[jptr] = x ++ data[jptr+1] = y ++ jptr -= 2 ++ } ++ data[jptr] = a ++ data[jptr+1] = b + } ++} + +- //Construct initial triangulation +- var cells = monotoneTriangulate(points, edges) ++function swap(i, j, data) { ++ i *= 2 ++ j *= 2 ++ var x = data[i] ++ var y = data[i+1] ++ data[i] = data[j] ++ data[i+1] = data[j+1] ++ data[j] = x ++ data[j+1] = y ++} + +- //If delaunay refinement needed, then improve quality by edge flipping +- if(delaunay || interior !== exterior || infinity) { ++function move(i, j, data) { ++ i *= 2 ++ j *= 2 ++ data[i] = data[j] ++ data[i+1] = data[j+1] ++} + +- //Index all of the cells to support fast neighborhood queries +- var triangulation = makeIndex(points.length, canonicalizeEdges(edges)) +- for(var i=0; i data[j+1] + } ++ return true + } + +-},{"./lib/delaunay":46,"./lib/filter":47,"./lib/monotone":48,"./lib/triangulation":49}],46:[function(require,module,exports){ +-'use strict' +- +-var inCircle = require('robust-in-sphere')[4] +-var bsearch = require('binary-search-bounds') +- +-module.exports = delaunayRefine +- +-function testFlip(points, triangulation, stack, a, b, x) { +- var y = triangulation.opposite(a, b) +- +- //Test boundary edge +- if(y < 0) { +- return ++function comparePivot(i, y, b, data) { ++ i *= 2 ++ var x = data[i] ++ if(x < y) { ++ return true ++ } else if(x === y) { ++ return data[i+1] < b + } ++ return false ++} + +- //Swap edge if order flipped +- if(b < a) { +- var tmp = a +- a = b +- b = tmp +- tmp = x +- x = y +- y = tmp ++function quickSort(left, right, data) { ++ var sixth = (right - left + 1) / 6 | 0, ++ index1 = left + sixth, ++ index5 = right - sixth, ++ index3 = left + right >> 1, ++ index2 = index3 - sixth, ++ index4 = index3 + sixth, ++ el1 = index1, ++ el2 = index2, ++ el3 = index3, ++ el4 = index4, ++ el5 = index5, ++ less = left + 1, ++ great = right - 1, ++ tmp = 0 ++ if(compare(el1, el2, data)) { ++ tmp = el1 ++ el1 = el2 ++ el2 = tmp + } +- +- //Test if edge is constrained +- if(triangulation.isConstraint(a, b)) { +- return ++ if(compare(el4, el5, data)) { ++ tmp = el4 ++ el4 = el5 ++ el5 = tmp + } +- +- //Test if edge is delaunay +- if(inCircle(points[a], points[b], points[x], points[y]) < 0) { +- stack.push(a, b) ++ if(compare(el1, el3, data)) { ++ tmp = el1 ++ el1 = el3 ++ el3 = tmp ++ } ++ if(compare(el2, el3, data)) { ++ tmp = el2 ++ el2 = el3 ++ el3 = tmp ++ } ++ if(compare(el1, el4, data)) { ++ tmp = el1 ++ el1 = el4 ++ el4 = tmp ++ } ++ if(compare(el3, el4, data)) { ++ tmp = el3 ++ el3 = el4 ++ el4 = tmp ++ } ++ if(compare(el2, el5, data)) { ++ tmp = el2 ++ el2 = el5 ++ el5 = tmp ++ } ++ if(compare(el2, el3, data)) { ++ tmp = el2 ++ el2 = el3 ++ el3 = tmp ++ } ++ if(compare(el4, el5, data)) { ++ tmp = el4 ++ el4 = el5 ++ el5 = tmp + } +-} +- +-//Assume edges are sorted lexicographically +-function delaunayRefine(points, triangulation) { +- var stack = [] + +- var numPoints = points.length +- var stars = triangulation.stars +- for(var a=0; a 0) { +- var b = stack.pop() +- var a = stack.pop() +- +- //Find opposite pairs +- var x = -1, y = -1 +- var star = stars[a] +- for(var i=1; i= 0) { +- continue +- } +- +- //Flip the edge +- triangulation.flip(a, b) +- +- //Test flipping neighboring edges +- testFlip(points, triangulation, stack, x, a, y) +- testFlip(points, triangulation, stack, a, y, x) +- testFlip(points, triangulation, stack, y, b, x) +- testFlip(points, triangulation, stack, b, x, y) ++ shufflePivot(left, less-1, pivot1X, pivot1Y, data) ++ shufflePivot(right, great+1, pivot2X, pivot2Y, data) ++ if (less - 2 - left <= INSERT_SORT_CUTOFF) { ++ insertionSort(left, less - 2, data); ++ } else { ++ quickSort(left, less - 2, data); ++ } ++ if (right - (great + 2) <= INSERT_SORT_CUTOFF) { ++ insertionSort(great + 2, right, data); ++ } else { ++ quickSort(great + 2, right, data); ++ } ++ if (great - less <= INSERT_SORT_CUTOFF) { ++ insertionSort(less, great, data); ++ } else { ++ quickSort(less, great, data); + } + } +- +-},{"binary-search-bounds":50,"robust-in-sphere":51}],47:[function(require,module,exports){ ++},{}],44:[function(require,module,exports){ + 'use strict' + +-var bsearch = require('binary-search-bounds') +- +-module.exports = classifyFaces +- +-function FaceIndex(cells, neighbor, constraint, flags, active, next, boundary) { +- this.cells = cells +- this.neighbor = neighbor +- this.flags = flags +- this.constraint = constraint +- this.active = active +- this.next = next +- this.boundary = boundary ++module.exports = { ++ init: sqInit, ++ sweepBipartite: sweepBipartite, ++ sweepComplete: sweepComplete, ++ scanBipartite: scanBipartite, ++ scanComplete: scanComplete + } + +-var proto = FaceIndex.prototype ++var pool = require('typedarray-pool') ++var bits = require('bit-twiddle') ++var isort = require('./sort') + +-function compareCell(a, b) { +- return a[0] - b[0] || +- a[1] - b[1] || +- a[2] - b[2] +-} ++//Flag for blue ++var BLUE_FLAG = (1<<28) + +-proto.locate = (function() { +- var key = [0,0,0] +- return function(a, b, c) { +- var x = a, y = b, z = c +- if(b < c) { +- if(b < a) { +- x = b +- y = c +- z = a +- } +- } else if(c < a) { +- x = c +- y = a +- z = b +- } +- if(x < 0) { +- return -1 +- } +- key[0] = x +- key[1] = y +- key[2] = z +- return bsearch.eq(this.cells, key, compareCell) +- } +-})() ++//1D sweep event queue stuff (use pool to save space) ++var INIT_CAPACITY = 1024 ++var RED_SWEEP_QUEUE = pool.mallocInt32(INIT_CAPACITY) ++var RED_SWEEP_INDEX = pool.mallocInt32(INIT_CAPACITY) ++var BLUE_SWEEP_QUEUE = pool.mallocInt32(INIT_CAPACITY) ++var BLUE_SWEEP_INDEX = pool.mallocInt32(INIT_CAPACITY) ++var COMMON_SWEEP_QUEUE = pool.mallocInt32(INIT_CAPACITY) ++var COMMON_SWEEP_INDEX = pool.mallocInt32(INIT_CAPACITY) ++var SWEEP_EVENTS = pool.mallocDouble(INIT_CAPACITY * 8) + +-function indexCells(triangulation, infinity) { +- //First get cells and canonicalize +- var cells = triangulation.cells() +- var nc = cells.length +- for(var i=0; i 0 || next.length > 0) { +- while(active.length > 0) { +- var t = active.pop() +- if(flags[t] === -side) { +- continue ++ //process events from left->right ++ var n = ptr >>> 1 ++ isort(SWEEP_EVENTS, n) ++ ++ var redActive = 0 ++ var blueActive = 0 ++ for(var i=0; i= BLUE_FLAG) { ++ //blue destroy event ++ e = (e-BLUE_FLAG)|0 ++ sqPop(BLUE_SWEEP_QUEUE, BLUE_SWEEP_INDEX, blueActive--, e) ++ } else if(e >= 0) { ++ //red destroy event ++ sqPop(RED_SWEEP_QUEUE, RED_SWEEP_INDEX, redActive--, e) ++ } else if(e <= -BLUE_FLAG) { ++ //blue create event ++ e = (-e-BLUE_FLAG)|0 ++ for(var j=0; j= 0 && flags[f] === 0) { +- if(constraint[3*t+j]) { +- next.push(f) +- } else { +- active.push(f) +- flags[f] = side +- } ++ sqPush(BLUE_SWEEP_QUEUE, BLUE_SWEEP_INDEX, blueActive++, e) ++ } else { ++ //red create event ++ e = (-e-1)|0 ++ for(var j=0; jright ++ var n = ptr >>> 1 ++ isort(SWEEP_EVENTS, n) ++ ++ var redActive = 0 ++ var blueActive = 0 ++ var commonActive = 0 ++ for(var i=0; i>1) === (SWEEP_EVENTS[2*i+3]>>1)) { ++ color = 2 ++ i += 1 ++ } ++ ++ if(e < 0) { ++ //Create event ++ var id = -(e>>1) - 1 + +-function addPoint(cells, hulls, points, p, idx) { +- var lo = bsearch.lt(hulls, p, testPoint) +- var hi = bsearch.gt(hulls, p, testPoint) +- for(var i=lo; i 1 && orient( +- points[lowerIds[m-2]], +- points[lowerIds[m-1]], +- p) > 0) { +- cells.push( +- [lowerIds[m-1], +- lowerIds[m-2], +- idx]) +- m -= 1 +- } +- lowerIds.length = m +- lowerIds.push(idx) ++ if(color !== 0) { ++ //Intersect with red ++ for(var j=0; j 1 && orient( +- points[upperIds[m-2]], +- points[upperIds[m-1]], +- p) < 0) { +- cells.push( +- [upperIds[m-2], +- upperIds[m-1], +- idx]) +- m -= 1 ++ if(color !== 1) { ++ //Intersect with blue ++ for(var j=0; j>1) - 1 ++ if(color === 0) { ++ //Red ++ sqPop(RED_SWEEP_QUEUE, RED_SWEEP_INDEX, redActive--, id) ++ } else if(color === 1) { ++ //Blue ++ sqPop(BLUE_SWEEP_QUEUE, BLUE_SWEEP_INDEX, blueActive--, id) ++ } else if(color === 2) { ++ //Both ++ sqPop(COMMON_SWEEP_QUEUE, COMMON_SWEEP_INDEX, commonActive--, id) ++ } + } +- upperIds.length = m +- upperIds.push(idx) + } + } + +-function findSplit(hull, edge) { +- var d +- if(hull.a[0] < edge.a[0]) { +- d = orient(hull.a, hull.b, edge.a) ++//Sweep and prune/scanline algorithm: ++// Scan along axis, detect intersections ++// Brute force all boxes along axis ++function scanBipartite( ++ d, axis, visit, flip, ++ redStart, redEnd, red, redIndex, ++ blueStart, blueEnd, blue, blueIndex) { ++ ++ var ptr = 0 ++ var elemSize = 2*d ++ var istart = axis ++ var iend = axis+d ++ ++ var redShift = 1 ++ var blueShift = 1 ++ if(flip) { ++ blueShift = BLUE_FLAG + } else { +- d = orient(edge.b, edge.a, hull.a) ++ redShift = BLUE_FLAG + } +- if(d) { return d } +- if(edge.b[0] < hull.b[0]) { +- d = orient(hull.a, hull.b, edge.b) +- } else { +- d = orient(edge.b, edge.a, hull.b) ++ ++ for(var i=redStart; iright ++ var n = ptr >>> 1 ++ isort(SWEEP_EVENTS, n) ++ ++ var redActive = 0 ++ for(var i=0; i= BLUE_FLAG) { ++ isRed = !flip ++ idx -= BLUE_FLAG ++ } else { ++ isRed = !!flip ++ idx -= 1 ++ } ++ if(isRed) { ++ sqPush(RED_SWEEP_QUEUE, RED_SWEEP_INDEX, redActive++, idx) ++ } else { ++ var blueId = blueIndex[idx] ++ var bluePtr = elemSize * idx ++ ++ var b0 = blue[bluePtr+axis+1] ++ var b1 = blue[bluePtr+axis+1+d] + ++red_loop: ++ for(var j=0; j b[0]) { +- events.push( +- new Event(b, a, EVENT_START, i), +- new Event(a, b, EVENT_END, i)) +- } ++ for(var i=blueStart; iright ++ var n = ptr >>> 1 ++ isort(SWEEP_EVENTS, n) ++ ++ var redActive = 0 ++ for(var i=0; i= BLUE_FLAG) { ++ RED_SWEEP_QUEUE[redActive++] = idx - BLUE_FLAG ++ } else { ++ idx -= 1 ++ var blueId = blueIndex[idx] ++ var bluePtr = elemSize * idx + +- //Initialize hull +- var minX = events[0].a[0] - (1 + Math.abs(events[0].a[0])) * Math.pow(2, -52) +- var hull = [ new PartialHull([minX, 1], [minX, 0], -1, [], [], [], []) ] ++ var b0 = blue[bluePtr+axis+1] ++ var b1 = blue[bluePtr+axis+1+d] + +- //Process events in order +- var cells = [] +- for(var i=0, numEvents=events.length; i=0; --j) { ++ if(RED_SWEEP_QUEUE[j] === idx) { ++ for(var k=j+1; k ++ * @license MIT ++ */ ++/* eslint-disable no-proto */ + +-},{"binary-search-bounds":50,"robust-orientation":225}],49:[function(require,module,exports){ + 'use strict' + +-var bsearch = require('binary-search-bounds') ++var base64 = require('base64-js') ++var ieee754 = require('ieee754') ++var isArray = require('isarray') + +-module.exports = createTriangulation ++exports.Buffer = Buffer ++exports.SlowBuffer = SlowBuffer ++exports.INSPECT_MAX_BYTES = 50 + +-function Triangulation(stars, edges) { +- this.stars = stars +- this.edges = edges +-} ++/** ++ * If `Buffer.TYPED_ARRAY_SUPPORT`: ++ * === true Use Uint8Array implementation (fastest) ++ * === false Use Object implementation (most compatible, even IE6) ++ * ++ * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, ++ * Opera 11.6+, iOS 4.2+. ++ * ++ * Due to various browser bugs, sometimes the Object implementation will be used even ++ * when the browser supports typed arrays. ++ * ++ * Note: ++ * ++ * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances, ++ * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. ++ * ++ * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. ++ * ++ * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of ++ * incorrect length in some situations. + +-var proto = Triangulation.prototype ++ * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they ++ * get the Object implementation, which is slower but behaves correctly. ++ */ ++Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined ++ ? global.TYPED_ARRAY_SUPPORT ++ : typedArraySupport() + +-function removePair(list, j, k) { +- for(var i=1, n=list.length; i= 0 ++function typedArraySupport () { ++ try { ++ var arr = new Uint8Array(1) ++ arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }} ++ return arr.foo() === 42 && // typed array instances can be augmented ++ typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray` ++ arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` ++ } catch (e) { ++ return false + } +-})() +- +-proto.removeTriangle = function(i, j, k) { +- var stars = this.stars +- removePair(stars[i], j, k) +- removePair(stars[j], k, i) +- removePair(stars[k], i, j) + } + +-proto.addTriangle = function(i, j, k) { +- var stars = this.stars +- stars[i].push(j, k) +- stars[j].push(k, i) +- stars[k].push(i, j) ++function kMaxLength () { ++ return Buffer.TYPED_ARRAY_SUPPORT ++ ? 0x7fffffff ++ : 0x3fffffff + } + +-proto.opposite = function(j, i) { +- var list = this.stars[i] +- for(var k=1, n=list.length; k>>1,x=a[m]"] +- if(earlyOut) { +- if(predicate.indexOf("c") < 0) { +- code.push(";if(x===y){return m}else if(x<=y){") +- } else { +- code.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){") +- } +- } else { +- code.push(";if(", predicate, "){i=m;") ++function from (that, value, encodingOrOffset, length) { ++ if (typeof value === 'number') { ++ throw new TypeError('"value" argument must not be a number') + } +- if(reversed) { +- code.push("l=m+1}else{h=m-1}") +- } else { +- code.push("h=m-1}else{l=m+1}") ++ ++ if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) { ++ return fromArrayBuffer(that, value, encodingOrOffset, length) + } +- code.push("}") +- if(earlyOut) { +- code.push("return -1};") +- } else { +- code.push("return i};") ++ ++ if (typeof value === 'string') { ++ return fromString(that, value, encodingOrOffset) + } +- return code.join("") +-} + +-function compileBoundsSearch(predicate, reversed, suffix, earlyOut) { +- var result = new Function([ +- compileSearch("A", "x" + predicate + "y", reversed, ["y"], earlyOut), +- compileSearch("P", "c(x,y)" + predicate + "0", reversed, ["y", "c"], earlyOut), +-"function dispatchBsearch", suffix, "(a,y,c,l,h){\ +-if(typeof(c)==='function'){\ +-return P(a,(l===void 0)?0:l|0,(h===void 0)?a.length-1:h|0,y,c)\ +-}else{\ +-return A(a,(c===void 0)?0:c|0,(l===void 0)?a.length-1:l|0,y)\ +-}}\ +-return dispatchBsearch", suffix].join("")) +- return result() ++ return fromObject(that, value) + } + +-module.exports = { +- ge: compileBoundsSearch(">=", false, "GE"), +- gt: compileBoundsSearch(">", false, "GT"), +- lt: compileBoundsSearch("<", true, "LT"), +- le: compileBoundsSearch("<=", true, "LE"), +- eq: compileBoundsSearch("-", true, "EQ", true) ++/** ++ * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError ++ * if value is a number. ++ * Buffer.from(str[, encoding]) ++ * Buffer.from(array) ++ * Buffer.from(buffer) ++ * Buffer.from(arrayBuffer[, byteOffset[, length]]) ++ **/ ++Buffer.from = function (value, encodingOrOffset, length) { ++ return from(null, value, encodingOrOffset, length) + } + +-},{}],51:[function(require,module,exports){ +-"use strict" +- +-var twoProduct = require("two-product") +-var robustSum = require("robust-sum") +-var robustDiff = require("robust-subtract") +-var robustScale = require("robust-scale") +- +-var NUM_EXPAND = 6 +- +-function cofactor(m, c) { +- var result = new Array(m.length-1) +- for(var i=1; i>1 +- return ["sum(", generateSum(expr.slice(0, m)), ",", generateSum(expr.slice(m)), ")"].join("") ++function alloc (that, size, fill, encoding) { ++ assertSize(size) ++ if (size <= 0) { ++ return createBuffer(that, size) + } +-} +- +-function makeProduct(a, b) { +- if(a.charAt(0) === "m") { +- if(b.charAt(0) === "w") { +- var toks = a.split("[") +- return ["w", b.substr(1), "m", toks[0].substr(1)].join("") +- } else { +- return ["prod(", a, ",", b, ")"].join("") +- } +- } else { +- return makeProduct(b, a) ++ if (fill !== undefined) { ++ // Only pay attention to encoding if it's a string. This ++ // prevents accidentally sending in a number that would ++ // be interpretted as a start offset. ++ return typeof encoding === 'string' ++ ? createBuffer(that, size).fill(fill, encoding) ++ : createBuffer(that, size).fill(fill) + } ++ return createBuffer(that, size) + } + +-function sign(s) { +- if(s & 1 !== 0) { +- return "-" +- } +- return "" ++/** ++ * Creates a new filled Buffer instance. ++ * alloc(size[, fill[, encoding]]) ++ **/ ++Buffer.alloc = function (size, fill, encoding) { ++ return alloc(null, size, fill, encoding) + } + +-function determinant(m) { +- if(m.length === 2) { +- return [["diff(", makeProduct(m[0][0], m[1][1]), ",", makeProduct(m[1][0], m[0][1]), ")"].join("")] +- } else { +- var expr = [] +- for(var i=0; i 0) { +- return [nextafter(f, -Infinity), f] +- } else { +- return [f, f] ++ if (obj.type === 'Buffer' && isArray(obj.data)) { ++ return fromArrayLike(that, obj.data) ++ } + } +-} + +-//Convert a list of edges in a pslg to bounding boxes +-function boundEdges(points, edges) { +- var bounds = new Array(edges.length) +- for(var i=0; i= kMaxLength()) { ++ throw new RangeError('Attempt to allocate Buffer larger than maximum ' + ++ 'size: 0x' + kMaxLength().toString(16) + ' bytes') + } +- return bounds ++ return length | 0 + } + +-//Find all pairs of crossing edges in a pslg (given edge bounds) +-function getCrossings(points, edges, edgeBounds) { +- var result = [] +- boxIntersect(edgeBounds, function(i, j) { +- var e = edges[i] +- var f = edges[j] +- if(e[0] === f[0] || e[0] === f[1] || +- e[1] === f[0] || e[1] === f[1]) { +- return +- } +- var a = points[e[0]] +- var b = points[e[1]] +- var c = points[f[0]] +- var d = points[f[1]] +- if(segseg(a, b, c, d)) { +- result.push([i, j]) +- } +- }) +- return result ++function SlowBuffer (length) { ++ if (+length != length) { // eslint-disable-line eqeqeq ++ length = 0 ++ } ++ return Buffer.alloc(+length) + } + +-//Find all pairs of crossing vertices in a pslg (given edge/vert bounds) +-function getTJunctions(points, edges, edgeBounds, vertBounds) { +- var result = [] +- boxIntersect(edgeBounds, vertBounds, function(i, v) { +- var e = edges[i] +- if(e[0] === v || e[1] === v) { +- return +- } +- var p = points[v] +- var a = points[e[0]] +- var b = points[e[1]] +- if(segseg(a, b, p, p)) { +- result.push([i, v]) +- } +- }) +- return result ++Buffer.isBuffer = function isBuffer (b) { ++ return !!(b != null && b._isBuffer) + } + ++Buffer.compare = function compare (a, b) { ++ if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { ++ throw new TypeError('Arguments must be Buffers') ++ } + +-//Cut edges along crossings/tjunctions +-function cutEdges(floatPoints, edges, crossings, junctions, useColor) { ++ if (a === b) return 0 + +- //Convert crossings into tjunctions by constructing rational points +- var ratPoints = [] +- for(var i=0; i= floatPoints.length) { +- return ratPoints[idx-floatPoints.length] ++ for (var i = 0, len = Math.min(x, y); i < len; ++i) { ++ if (a[i] !== b[i]) { ++ x = a[i] ++ y = b[i] ++ break + } +- var p = floatPoints[idx] +- return [ rat(p[0]), rat(p[1]) ] + } +- junctions.sort(function(a, b) { +- if(a[0] !== b[0]) { +- return a[0] - b[0] +- } +- var u = getPoint(a[1]) +- var v = getPoint(b[1]) +- return ratCmp(u[0], v[0]) || ratCmp(u[1], v[1]) +- }) +- +- //Split edges along junctions +- for(var i=junctions.length-1; i>=0; --i) { +- var junction = junctions[i] +- var e = junction[0] + +- var edge = edges[e] +- var s = edge[0] +- var t = edge[1] ++ if (x < y) return -1 ++ if (y < x) return 1 ++ return 0 ++} + +- //Check if edge is not lexicographically sorted +- var a = floatPoints[s] +- var b = floatPoints[t] +- if(((a[0] - b[0]) || (a[1] - b[1])) < 0) { +- var tmp = s +- s = t +- t = tmp +- } ++Buffer.isEncoding = function isEncoding (encoding) { ++ switch (String(encoding).toLowerCase()) { ++ case 'hex': ++ case 'utf8': ++ case 'utf-8': ++ case 'ascii': ++ case 'latin1': ++ case 'binary': ++ case 'base64': ++ case 'ucs2': ++ case 'ucs-2': ++ case 'utf16le': ++ case 'utf-16le': ++ return true ++ default: ++ return false ++ } ++} + +- //Split leading edge +- edge[0] = s +- var last = edge[1] = junction[1] ++Buffer.concat = function concat (list, length) { ++ if (!isArray(list)) { ++ throw new TypeError('"list" argument must be an Array of Buffers') ++ } + +- //If we are grouping edges by color, remember to track data +- var color +- if(useColor) { +- color = edge[2] +- } ++ if (list.length === 0) { ++ return Buffer.alloc(0) ++ } + +- //Split other edges +- while(i > 0 && junctions[i-1][0] === e) { +- var junction = junctions[--i] +- var next = junction[1] +- if(useColor) { +- edges.push([last, next, color]) +- } else { +- edges.push([last, next]) +- } +- last = next ++ var i ++ if (length === undefined) { ++ length = 0 ++ for (i = 0; i < list.length; ++i) { ++ length += list[i].length + } ++ } + +- //Add final edge +- if(useColor) { +- edges.push([last, t, color]) +- } else { +- edges.push([last, t]) ++ var buffer = Buffer.allocUnsafe(length) ++ var pos = 0 ++ for (i = 0; i < list.length; ++i) { ++ var buf = list[i] ++ if (!Buffer.isBuffer(buf)) { ++ throw new TypeError('"list" argument must be an Array of Buffers') + } ++ buf.copy(buffer, pos) ++ pos += buf.length + } +- +- //Return constructed rational points +- return ratPoints ++ return buffer + } + +-//Merge overlapping points +-function dedupPoints(floatPoints, ratPoints, floatBounds) { +- var numPoints = floatPoints.length + ratPoints.length +- var uf = new UnionFind(numPoints) +- +- //Compute rational bounds +- var bounds = floatBounds +- for(var i=0; i>> 1 ++ case 'base64': ++ return base64ToBytes(string).length ++ default: ++ if (loweredCase) return utf8ToBytes(string).length // assume utf8 ++ encoding = ('' + encoding).toLowerCase() ++ loweredCase = true + } + } +- floatPoints.length = ptr +- +- //If no duplicates, return null to signal termination +- if(noDupes) { +- return null +- } ++} ++Buffer.byteLength = byteLength + +- //Do a second pass to fix up missing labels +- for(var i=0; i b[2]) { +- return 1 ++ // Return early if start > this.length. Done here to prevent potential uint32 ++ // coercion fail below. ++ if (start > this.length) { ++ return '' + } +- return 0 +-} + +-//Remove duplicate edge labels +-function dedupEdges(edges, labels, useColor) { +- if(edges.length === 0) { +- return +- } +- if(labels) { +- for(var i=0; i this.length) { ++ end = this.length + } +- edges.length = ptr +-} +- +-//Repeat until convergence +-function snapRound(points, edges, useColor) { + +- // 1. find edge crossings +- var edgeBounds = boundEdges(points, edges) +- var crossings = getCrossings(points, edges, edgeBounds) ++ if (end <= 0) { ++ return '' ++ } + +- // 2. find t-junctions +- var vertBounds = boundPoints(points) +- var tjunctions = getTJunctions(points, edges, edgeBounds, vertBounds) ++ // Force coersion to uint32. This will also coerce falsey/NaN values to 0. ++ end >>>= 0 ++ start >>>= 0 + +- // 3. cut edges, construct rational points +- var ratPoints = cutEdges(points, edges, crossings, tjunctions, useColor) ++ if (end <= start) { ++ return '' ++ } + +- // 4. dedupe verts +- var labels = dedupPoints(points, ratPoints, vertBounds) ++ if (!encoding) encoding = 'utf8' + +- // 6. dedupe edges +- dedupEdges(edges, labels, useColor) ++ while (true) { ++ switch (encoding) { ++ case 'hex': ++ return hexSlice(this, start, end) + +- // 5. check termination +- if(!labels) { +- return (crossings.length > 0 || tjunctions.length > 0) +- } ++ case 'utf8': ++ case 'utf-8': ++ return utf8Slice(this, start, end) + +- // More iterations necessary +- return true +-} ++ case 'ascii': ++ return asciiSlice(this, start, end) + +-//Main loop, runs PSLG clean up until completion +-function cleanPSLG(points, edges, colors) { +- var modified = false ++ case 'latin1': ++ case 'binary': ++ return latin1Slice(this, start, end) + +- //If using colors, augment edges with color data +- var prevEdges +- if(colors) { +- prevEdges = edges +- var augEdges = new Array(edges.length) +- for(var i=0; i 0) { ++ str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') ++ if (this.length > max) str += ' ... ' + } ++ return '' ++} + +- var ac = rvSub(a, c) +- var dcXac = ratPerp(dc, ac) ++Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { ++ if (!Buffer.isBuffer(target)) { ++ throw new TypeError('Argument must be a Buffer') ++ } + +- var t = ratDiv(dcXac, baXdc) ++ if (start === undefined) { ++ start = 0 ++ } ++ if (end === undefined) { ++ end = target ? target.length : 0 ++ } ++ if (thisStart === undefined) { ++ thisStart = 0 ++ } ++ if (thisEnd === undefined) { ++ thisEnd = this.length ++ } + +- return rvAdd(a, rvMuls(ba, t)) +-} ++ if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { ++ throw new RangeError('out of range index') ++ } + +-},{"big-rat/div":56,"big-rat/mul":66,"big-rat/sign":68,"big-rat/sub":69,"big-rat/to-float":70,"rat-vec/add":80,"rat-vec/muls":82,"rat-vec/sub":83}],54:[function(require,module,exports){ +-'use strict' ++ if (thisStart >= thisEnd && start >= end) { ++ return 0 ++ } ++ if (thisStart >= thisEnd) { ++ return -1 ++ } ++ if (start >= end) { ++ return 1 ++ } + +-var rationalize = require('./lib/rationalize') ++ start >>>= 0 ++ end >>>= 0 ++ thisStart >>>= 0 ++ thisEnd >>>= 0 + +-module.exports = add ++ if (this === target) return 0 + +-function add(a, b) { +- return rationalize( +- a[0].mul(b[1]).add(b[0].mul(a[1])), +- a[1].mul(b[1])) +-} ++ var x = thisEnd - thisStart ++ var y = end - start ++ var len = Math.min(x, y) + +-},{"./lib/rationalize":64}],55:[function(require,module,exports){ +-'use strict' ++ var thisCopy = this.slice(thisStart, thisEnd) ++ var targetCopy = target.slice(start, end) + +-module.exports = cmp ++ for (var i = 0; i < len; ++i) { ++ if (thisCopy[i] !== targetCopy[i]) { ++ x = thisCopy[i] ++ y = targetCopy[i] ++ break ++ } ++ } + +-function cmp(a, b) { +- return a[0].mul(b[1]).cmp(b[0].mul(a[1])) ++ if (x < y) return -1 ++ if (y < x) return 1 ++ return 0 + } + +-},{}],56:[function(require,module,exports){ +-'use strict' +- +-var rationalize = require('./lib/rationalize') ++// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, ++// OR the last index of `val` in `buffer` at offset <= `byteOffset`. ++// ++// Arguments: ++// - buffer - a Buffer to search ++// - val - a string, Buffer, or number ++// - byteOffset - an index into `buffer`; will be clamped to an int32 ++// - encoding - an optional encoding, relevant is val is a string ++// - dir - true for indexOf, false for lastIndexOf ++function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { ++ // Empty buffer means no match ++ if (buffer.length === 0) return -1 ++ ++ // Normalize byteOffset ++ if (typeof byteOffset === 'string') { ++ encoding = byteOffset ++ byteOffset = 0 ++ } else if (byteOffset > 0x7fffffff) { ++ byteOffset = 0x7fffffff ++ } else if (byteOffset < -0x80000000) { ++ byteOffset = -0x80000000 ++ } ++ byteOffset = +byteOffset // Coerce to Number. ++ if (isNaN(byteOffset)) { ++ // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer ++ byteOffset = dir ? 0 : (buffer.length - 1) ++ } ++ ++ // Normalize byteOffset: negative offsets start from the end of the buffer ++ if (byteOffset < 0) byteOffset = buffer.length + byteOffset ++ if (byteOffset >= buffer.length) { ++ if (dir) return -1 ++ else byteOffset = buffer.length - 1 ++ } else if (byteOffset < 0) { ++ if (dir) byteOffset = 0 ++ else return -1 ++ } ++ ++ // Normalize val ++ if (typeof val === 'string') { ++ val = Buffer.from(val, encoding) ++ } + +-module.exports = div ++ // Finally, search either indexOf (if dir is true) or lastIndexOf ++ if (Buffer.isBuffer(val)) { ++ // Special case: looking for empty string/buffer always fails ++ if (val.length === 0) { ++ return -1 ++ } ++ return arrayIndexOf(buffer, val, byteOffset, encoding, dir) ++ } else if (typeof val === 'number') { ++ val = val & 0xFF // Search for a byte value [0-255] ++ if (Buffer.TYPED_ARRAY_SUPPORT && ++ typeof Uint8Array.prototype.indexOf === 'function') { ++ if (dir) { ++ return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) ++ } else { ++ return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) ++ } ++ } ++ return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) ++ } + +-function div(a, b) { +- return rationalize(a[0].mul(b[1]), a[1].mul(b[0])) ++ throw new TypeError('val must be string, number or Buffer') + } + +-},{"./lib/rationalize":64}],57:[function(require,module,exports){ +-'use strict' +- +-var isRat = require('./is-rat') +-var isBN = require('./lib/is-bn') +-var num2bn = require('./lib/num-to-bn') +-var str2bn = require('./lib/str-to-bn') +-var rationalize = require('./lib/rationalize') +-var div = require('./div') +- +-module.exports = makeRational ++function arrayIndexOf (arr, val, byteOffset, encoding, dir) { ++ var indexSize = 1 ++ var arrLength = arr.length ++ var valLength = val.length + +-function makeRational(numer, denom) { +- if(isRat(numer)) { +- if(denom) { +- return div(numer, makeRational(denom)) ++ if (encoding !== undefined) { ++ encoding = String(encoding).toLowerCase() ++ if (encoding === 'ucs2' || encoding === 'ucs-2' || ++ encoding === 'utf16le' || encoding === 'utf-16le') { ++ if (arr.length < 2 || val.length < 2) { ++ return -1 ++ } ++ indexSize = 2 ++ arrLength /= 2 ++ valLength /= 2 ++ byteOffset /= 2 + } +- return [numer[0].clone(), numer[1].clone()] + } +- var shift = 0 +- var a, b +- if(isBN(numer)) { +- a = numer.clone() +- } else if(typeof numer === 'string') { +- a = str2bn(numer) +- } else if(numer === 0) { +- return [num2bn(0), num2bn(1)] +- } else if(numer === Math.floor(numer)) { +- a = num2bn(numer) +- } else { +- while(numer !== Math.floor(numer)) { +- numer = numer * Math.pow(2, 256) +- shift -= 256 ++ ++ function read (buf, i) { ++ if (indexSize === 1) { ++ return buf[i] ++ } else { ++ return buf.readUInt16BE(i * indexSize) + } +- a = num2bn(numer) + } +- if(isRat(denom)) { +- a.mul(denom[1]) +- b = denom[0].clone() +- } else if(isBN(denom)) { +- b = denom.clone() +- } else if(typeof denom === 'string') { +- b = str2bn(denom) +- } else if(!denom) { +- b = num2bn(1) +- } else if(denom === Math.floor(denom)) { +- b = num2bn(denom) ++ ++ var i ++ if (dir) { ++ var foundIndex = -1 ++ for (i = byteOffset; i < arrLength; i++) { ++ if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { ++ if (foundIndex === -1) foundIndex = i ++ if (i - foundIndex + 1 === valLength) return foundIndex * indexSize ++ } else { ++ if (foundIndex !== -1) i -= i - foundIndex ++ foundIndex = -1 ++ } ++ } + } else { +- while(denom !== Math.floor(denom)) { +- denom = denom * Math.pow(2, 256) +- shift += 256 ++ if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength ++ for (i = byteOffset; i >= 0; i--) { ++ var found = true ++ for (var j = 0; j < valLength; j++) { ++ if (read(arr, i + j) !== read(val, j)) { ++ found = false ++ break ++ } ++ } ++ if (found) return i + } +- b = num2bn(denom) +- } +- if(shift > 0) { +- a = a.shln(shift) +- } else if(shift < 0) { +- b = b.shln(-shift) + } +- return rationalize(a, b) +-} +- +-},{"./div":56,"./is-rat":58,"./lib/is-bn":62,"./lib/num-to-bn":63,"./lib/rationalize":64,"./lib/str-to-bn":65}],58:[function(require,module,exports){ +-'use strict' +- +-var isBN = require('./lib/is-bn') +- +-module.exports = isRat + +-function isRat(x) { +- return Array.isArray(x) && x.length === 2 && isBN(x[0]) && isBN(x[1]) ++ return -1 + } + +-},{"./lib/is-bn":62}],59:[function(require,module,exports){ +-'use strict' +- +-var bn = require('bn.js') +- +-module.exports = sign +- +-function sign(x) { +- return x.cmp(new bn(0)) ++Buffer.prototype.includes = function includes (val, byteOffset, encoding) { ++ return this.indexOf(val, byteOffset, encoding) !== -1 + } + +-},{"bn.js":67}],60:[function(require,module,exports){ +-'use strict' ++Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { ++ return bidirectionalIndexOf(this, val, byteOffset, encoding, true) ++} + +-module.exports = bn2num ++Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { ++ return bidirectionalIndexOf(this, val, byteOffset, encoding, false) ++} + +-//TODO: Make this better +-function bn2num(b) { +- var l = b.length +- var words = b.words +- var out = 0 +- if (l === 1) { +- out = words[0] +- } else if (l === 2) { +- out = words[0] + (words[1] * 0x4000000) ++function hexWrite (buf, string, offset, length) { ++ offset = Number(offset) || 0 ++ var remaining = buf.length - offset ++ if (!length) { ++ length = remaining + } else { +- var out = 0 +- for (var i = 0; i < l; i++) { +- var w = words[i] +- out += w * Math.pow(0x4000000, i) ++ length = Number(length) ++ if (length > remaining) { ++ length = remaining + } + } +- return b.sign ? -out : out +-} +- +-},{}],61:[function(require,module,exports){ +-'use strict' +- +-var db = require('double-bits') +-var ctz = require('bit-twiddle').countTrailingZeros + +-module.exports = ctzNumber ++ // must be an even number of digits ++ var strLen = string.length ++ if (strLen % 2 !== 0) throw new TypeError('Invalid hex string') + +-//Counts the number of trailing zeros +-function ctzNumber(x) { +- var l = ctz(db.lo(x)) +- if(l < 32) { +- return l ++ if (length > strLen / 2) { ++ length = strLen / 2 + } +- var h = ctz(db.hi(x)) +- if(h > 20) { +- return 52 ++ for (var i = 0; i < length; ++i) { ++ var parsed = parseInt(string.substr(i * 2, 2), 16) ++ if (isNaN(parsed)) return i ++ buf[offset + i] = parsed + } +- return h + 32 ++ return i + } + +-},{"bit-twiddle":38,"double-bits":78}],62:[function(require,module,exports){ +-'use strict' ++function utf8Write (buf, string, offset, length) { ++ return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) ++} + +-var BN = require('bn.js') ++function asciiWrite (buf, string, offset, length) { ++ return blitBuffer(asciiToBytes(string), buf, offset, length) ++} + +-module.exports = isBN ++function latin1Write (buf, string, offset, length) { ++ return asciiWrite(buf, string, offset, length) ++} + +-//Test if x is a bignumber +-//FIXME: obviously this is the wrong way to do it +-function isBN(x) { +- return x && typeof x === 'object' && Boolean(x.words) ++function base64Write (buf, string, offset, length) { ++ return blitBuffer(base64ToBytes(string), buf, offset, length) + } + +-},{"bn.js":67}],63:[function(require,module,exports){ +-'use strict' ++function ucs2Write (buf, string, offset, length) { ++ return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) ++} + +-var BN = require('bn.js') +-var db = require('double-bits') ++Buffer.prototype.write = function write (string, offset, length, encoding) { ++ // Buffer#write(string) ++ if (offset === undefined) { ++ encoding = 'utf8' ++ length = this.length ++ offset = 0 ++ // Buffer#write(string, encoding) ++ } else if (length === undefined && typeof offset === 'string') { ++ encoding = offset ++ length = this.length ++ offset = 0 ++ // Buffer#write(string, offset[, length][, encoding]) ++ } else if (isFinite(offset)) { ++ offset = offset | 0 ++ if (isFinite(length)) { ++ length = length | 0 ++ if (encoding === undefined) encoding = 'utf8' ++ } else { ++ encoding = length ++ length = undefined ++ } ++ // legacy write(string, encoding, offset, length) - remove in v0.13 ++ } else { ++ throw new Error( ++ 'Buffer.write(string, encoding, offset[, length]) is no longer supported' ++ ) ++ } + +-module.exports = num2bn ++ var remaining = this.length - offset ++ if (length === undefined || length > remaining) length = remaining + +-function num2bn(x) { +- var e = db.exponent(x) +- if(e < 52) { +- return new BN(x) +- } else { +- return (new BN(x * Math.pow(2, 52-e))).shln(e-52) ++ if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { ++ throw new RangeError('Attempt to write outside buffer bounds') + } +-} + +-},{"bn.js":67,"double-bits":78}],64:[function(require,module,exports){ +-'use strict' ++ if (!encoding) encoding = 'utf8' + +-var num2bn = require('./num-to-bn') +-var sign = require('./bn-sign') ++ var loweredCase = false ++ for (;;) { ++ switch (encoding) { ++ case 'hex': ++ return hexWrite(this, string, offset, length) + +-module.exports = rationalize ++ case 'utf8': ++ case 'utf-8': ++ return utf8Write(this, string, offset, length) + +-function rationalize(numer, denom) { +- var snumer = sign(numer) +- var sdenom = sign(denom) +- if(snumer === 0) { +- return [num2bn(0), num2bn(1)] +- } +- if(sdenom === 0) { +- return [num2bn(0), num2bn(0)] +- } +- if(sdenom < 0) { +- numer = numer.neg() +- denom = denom.neg() +- } +- var d = numer.gcd(denom) +- if(d.cmpn(1)) { +- return [ numer.div(d), denom.div(d) ] +- } +- return [ numer, denom ] +-} ++ case 'ascii': ++ return asciiWrite(this, string, offset, length) + +-},{"./bn-sign":59,"./num-to-bn":63}],65:[function(require,module,exports){ +-'use strict' ++ case 'latin1': ++ case 'binary': ++ return latin1Write(this, string, offset, length) + +-var BN = require('bn.js') ++ case 'base64': ++ // Warning: maxLength not taken into account in base64Write ++ return base64Write(this, string, offset, length) + +-module.exports = str2BN ++ case 'ucs2': ++ case 'ucs-2': ++ case 'utf16le': ++ case 'utf-16le': ++ return ucs2Write(this, string, offset, length) + +-function str2BN(x) { +- return new BN(x) ++ default: ++ if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) ++ encoding = ('' + encoding).toLowerCase() ++ loweredCase = true ++ } ++ } + } + +-},{"bn.js":67}],66:[function(require,module,exports){ +-'use strict' +- +-var rationalize = require('./lib/rationalize') +- +-module.exports = mul +- +-function mul(a, b) { +- return rationalize(a[0].mul(b[0]), a[1].mul(b[1])) ++Buffer.prototype.toJSON = function toJSON () { ++ return { ++ type: 'Buffer', ++ data: Array.prototype.slice.call(this._arr || this, 0) ++ } + } + +-},{"./lib/rationalize":64}],67:[function(require,module,exports){ +-(function (module, exports) { ++function base64Slice (buf, start, end) { ++ if (start === 0 && end === buf.length) { ++ return base64.fromByteArray(buf) ++ } else { ++ return base64.fromByteArray(buf.slice(start, end)) ++ } ++} + +-'use strict'; ++function utf8Slice (buf, start, end) { ++ end = Math.min(buf.length, end) ++ var res = [] + +-// Utils ++ var i = start ++ while (i < end) { ++ var firstByte = buf[i] ++ var codePoint = null ++ var bytesPerSequence = (firstByte > 0xEF) ? 4 ++ : (firstByte > 0xDF) ? 3 ++ : (firstByte > 0xBF) ? 2 ++ : 1 + +-function assert(val, msg) { +- if (!val) +- throw new Error(msg || 'Assertion failed'); +-} ++ if (i + bytesPerSequence <= end) { ++ var secondByte, thirdByte, fourthByte, tempCodePoint + +-// Could use `inherits` module, but don't want to move from single file +-// architecture yet. +-function inherits(ctor, superCtor) { +- ctor.super_ = superCtor; +- var TempCtor = function () {}; +- TempCtor.prototype = superCtor.prototype; +- ctor.prototype = new TempCtor(); +- ctor.prototype.constructor = ctor; +-} ++ switch (bytesPerSequence) { ++ case 1: ++ if (firstByte < 0x80) { ++ codePoint = firstByte ++ } ++ break ++ case 2: ++ secondByte = buf[i + 1] ++ if ((secondByte & 0xC0) === 0x80) { ++ tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) ++ if (tempCodePoint > 0x7F) { ++ codePoint = tempCodePoint ++ } ++ } ++ break ++ case 3: ++ secondByte = buf[i + 1] ++ thirdByte = buf[i + 2] ++ if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { ++ tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) ++ if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { ++ codePoint = tempCodePoint ++ } ++ } ++ break ++ case 4: ++ secondByte = buf[i + 1] ++ thirdByte = buf[i + 2] ++ fourthByte = buf[i + 3] ++ if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { ++ tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) ++ if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { ++ codePoint = tempCodePoint ++ } ++ } ++ } ++ } + +-// BN ++ if (codePoint === null) { ++ // we did not generate a valid codePoint so insert a ++ // replacement char (U+FFFD) and advance only 1 byte ++ codePoint = 0xFFFD ++ bytesPerSequence = 1 ++ } else if (codePoint > 0xFFFF) { ++ // encode to utf16 (surrogate pair dance) ++ codePoint -= 0x10000 ++ res.push(codePoint >>> 10 & 0x3FF | 0xD800) ++ codePoint = 0xDC00 | codePoint & 0x3FF ++ } + +-function BN(number, base, endian) { +- // May be `new BN(bn)` ? +- if (number !== null && +- typeof number === 'object' && +- Array.isArray(number.words)) { +- return number; ++ res.push(codePoint) ++ i += bytesPerSequence + } + +- this.sign = false; +- this.words = null; +- this.length = 0; ++ return decodeCodePointsArray(res) ++} + +- // Reduction context +- this.red = null; ++// Based on http://stackoverflow.com/a/22747272/680742, the browser with ++// the lowest limit is Chrome, with 0x10000 args. ++// We go 1 magnitude less, for safety ++var MAX_ARGUMENTS_LENGTH = 0x1000 + +- if (base === 'le' || base === 'be') { +- endian = base; +- base = 10; ++function decodeCodePointsArray (codePoints) { ++ var len = codePoints.length ++ if (len <= MAX_ARGUMENTS_LENGTH) { ++ return String.fromCharCode.apply(String, codePoints) // avoid extra slice() + } + +- if (number !== null) +- this._init(number || 0, base || 10, endian || 'be'); ++ // Decode in chunks to avoid "call stack size exceeded". ++ var res = '' ++ var i = 0 ++ while (i < len) { ++ res += String.fromCharCode.apply( ++ String, ++ codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) ++ ) ++ } ++ return res + } +-if (typeof module === 'object') +- module.exports = BN; +-else +- exports.BN = BN; + +-BN.BN = BN; +-BN.wordSize = 26; ++function asciiSlice (buf, start, end) { ++ var ret = '' ++ end = Math.min(buf.length, end) + +-BN.prototype._init = function init(number, base, endian) { +- if (typeof number === 'number') { +- return this._initNumber(number, base, endian); +- } else if (typeof number === 'object') { +- return this._initArray(number, base, endian); ++ for (var i = start; i < end; ++i) { ++ ret += String.fromCharCode(buf[i] & 0x7F) + } +- if (base === 'hex') +- base = 16; +- assert(base === (base | 0) && base >= 2 && base <= 36); +- +- number = number.toString().replace(/\s+/g, ''); +- var start = 0; +- if (number[0] === '-') +- start++; +- +- if (base === 16) +- this._parseHex(number, start); +- else +- this._parseBase(number, base, start); ++ return ret ++} + +- if (number[0] === '-') +- this.sign = true; ++function latin1Slice (buf, start, end) { ++ var ret = '' ++ end = Math.min(buf.length, end) + +- this.strip(); ++ for (var i = start; i < end; ++i) { ++ ret += String.fromCharCode(buf[i]) ++ } ++ return ret ++} + +- if (endian !== 'le') +- return; ++function hexSlice (buf, start, end) { ++ var len = buf.length + +- this._initArray(this.toArray(), base, endian); +-}; ++ if (!start || start < 0) start = 0 ++ if (!end || end < 0 || end > len) end = len + +-BN.prototype._initNumber = function _initNumber(number, base, endian) { +- if (number < 0) { +- this.sign = true; +- number = -number; ++ var out = '' ++ for (var i = start; i < end; ++i) { ++ out += toHex(buf[i]) + } +- if (number < 0x4000000) { +- this.words = [ number & 0x3ffffff ]; +- this.length = 1; +- } else if (number < 0x10000000000000) { +- this.words = [ +- number & 0x3ffffff, +- (number / 0x4000000) & 0x3ffffff +- ]; +- this.length = 2; +- } else { +- assert(number < 0x20000000000000); // 2 ^ 53 (unsafe) +- this.words = [ +- number & 0x3ffffff, +- (number / 0x4000000) & 0x3ffffff, +- 1 +- ]; +- this.length = 3; ++ return out ++} ++ ++function utf16leSlice (buf, start, end) { ++ var bytes = buf.slice(start, end) ++ var res = '' ++ for (var i = 0; i < bytes.length; i += 2) { ++ res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256) + } ++ return res ++} + +- if (endian !== 'le') +- return; ++Buffer.prototype.slice = function slice (start, end) { ++ var len = this.length ++ start = ~~start ++ end = end === undefined ? len : ~~end + +- // Reverse the bytes +- this._initArray(this.toArray(), base, endian); +-}; ++ if (start < 0) { ++ start += len ++ if (start < 0) start = 0 ++ } else if (start > len) { ++ start = len ++ } + +-BN.prototype._initArray = function _initArray(number, base, endian) { +- // Perhaps a Uint8Array +- assert(typeof number.length === 'number'); +- if (number.length <= 0) { +- this.words = [ 0 ]; +- this.length = 1; +- return this; ++ if (end < 0) { ++ end += len ++ if (end < 0) end = 0 ++ } else if (end > len) { ++ end = len + } + +- this.length = Math.ceil(number.length / 3); +- this.words = new Array(this.length); +- for (var i = 0; i < this.length; i++) +- this.words[i] = 0; ++ if (end < start) end = start + +- var off = 0; +- if (endian === 'be') { +- for (var i = number.length - 1, j = 0; i >= 0; i -= 3) { +- var w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16); +- this.words[j] |= (w << off) & 0x3ffffff; +- this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; +- off += 24; +- if (off >= 26) { +- off -= 26; +- j++; +- } +- } +- } else if (endian === 'le') { +- for (var i = 0, j = 0; i < number.length; i += 3) { +- var w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16); +- this.words[j] |= (w << off) & 0x3ffffff; +- this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; +- off += 24; +- if (off >= 26) { +- off -= 26; +- j++; +- } ++ var newBuf ++ if (Buffer.TYPED_ARRAY_SUPPORT) { ++ newBuf = this.subarray(start, end) ++ newBuf.__proto__ = Buffer.prototype ++ } else { ++ var sliceLen = end - start ++ newBuf = new Buffer(sliceLen, undefined) ++ for (var i = 0; i < sliceLen; ++i) { ++ newBuf[i] = this[i + start] + } + } +- return this.strip(); +-}; +- +-function parseHex(str, start, end) { +- var r = 0; +- var len = Math.min(str.length, end); +- for (var i = start; i < len; i++) { +- var c = str.charCodeAt(i) - 48; + +- r <<= 4; ++ return newBuf ++} + +- // 'a' - 'f' +- if (c >= 49 && c <= 54) +- r |= c - 49 + 0xa; ++/* ++ * Need to make sure that buffer isn't trying to write out of bounds. ++ */ ++function checkOffset (offset, ext, length) { ++ if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') ++ if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') ++} + +- // 'A' - 'F' +- else if (c >= 17 && c <= 22) +- r |= c - 17 + 0xa; ++Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { ++ offset = offset | 0 ++ byteLength = byteLength | 0 ++ if (!noAssert) checkOffset(offset, byteLength, this.length) + +- // '0' - '9' +- else +- r |= c & 0xf; ++ var val = this[offset] ++ var mul = 1 ++ var i = 0 ++ while (++i < byteLength && (mul *= 0x100)) { ++ val += this[offset + i] * mul + } +- return r; +-} + +-BN.prototype._parseHex = function _parseHex(number, start) { +- // Create possibly bigger array to ensure that it fits the number +- this.length = Math.ceil((number.length - start) / 6); +- this.words = new Array(this.length); +- for (var i = 0; i < this.length; i++) +- this.words[i] = 0; ++ return val ++} + +- // Scan 24-bit chunks and add them to the number +- var off = 0; +- for (var i = number.length - 6, j = 0; i >= start; i -= 6) { +- var w = parseHex(number, i, i + 6); +- this.words[j] |= (w << off) & 0x3ffffff; +- this.words[j + 1] |= w >>> (26 - off) & 0x3fffff; +- off += 24; +- if (off >= 26) { +- off -= 26; +- j++; +- } +- } +- if (i + 6 !== start) { +- var w = parseHex(number, start, i + 6); +- this.words[j] |= (w << off) & 0x3ffffff; +- this.words[j + 1] |= w >>> (26 - off) & 0x3fffff; ++Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { ++ offset = offset | 0 ++ byteLength = byteLength | 0 ++ if (!noAssert) { ++ checkOffset(offset, byteLength, this.length) + } +- this.strip(); +-}; + +-function parseBase(str, start, end, mul) { +- var r = 0; +- var len = Math.min(str.length, end); +- for (var i = start; i < len; i++) { +- var c = str.charCodeAt(i) - 48; ++ var val = this[offset + --byteLength] ++ var mul = 1 ++ while (byteLength > 0 && (mul *= 0x100)) { ++ val += this[offset + --byteLength] * mul ++ } + +- r *= mul; ++ return val ++} + +- // 'a' +- if (c >= 49) +- r += c - 49 + 0xa; ++Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { ++ if (!noAssert) checkOffset(offset, 1, this.length) ++ return this[offset] ++} + +- // 'A' +- else if (c >= 17) +- r += c - 17 + 0xa; ++Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { ++ if (!noAssert) checkOffset(offset, 2, this.length) ++ return this[offset] | (this[offset + 1] << 8) ++} + +- // '0' - '9' +- else +- r += c; +- } +- return r; ++Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { ++ if (!noAssert) checkOffset(offset, 2, this.length) ++ return (this[offset] << 8) | this[offset + 1] + } + +-BN.prototype._parseBase = function _parseBase(number, base, start) { +- // Initialize as zero +- this.words = [ 0 ]; +- this.length = 1; ++Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { ++ if (!noAssert) checkOffset(offset, 4, this.length) + +- // Find length of limb in base +- for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) +- limbLen++; +- limbLen--; +- limbPow = (limbPow / base) | 0; ++ return ((this[offset]) | ++ (this[offset + 1] << 8) | ++ (this[offset + 2] << 16)) + ++ (this[offset + 3] * 0x1000000) ++} + +- var total = number.length - start; +- var mod = total % limbLen; +- var end = Math.min(total, total - mod) + start; ++Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { ++ if (!noAssert) checkOffset(offset, 4, this.length) + +- var word = 0; +- for (var i = start; i < end; i += limbLen) { +- word = parseBase(number, i, i + limbLen, base); ++ return (this[offset] * 0x1000000) + ++ ((this[offset + 1] << 16) | ++ (this[offset + 2] << 8) | ++ this[offset + 3]) ++} + +- this.imuln(limbPow); +- if (this.words[0] + word < 0x4000000) +- this.words[0] += word; +- else +- this._iaddn(word); ++Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { ++ offset = offset | 0 ++ byteLength = byteLength | 0 ++ if (!noAssert) checkOffset(offset, byteLength, this.length) ++ ++ var val = this[offset] ++ var mul = 1 ++ var i = 0 ++ while (++i < byteLength && (mul *= 0x100)) { ++ val += this[offset + i] * mul + } ++ mul *= 0x80 + +- if (mod !== 0) { +- var pow = 1; +- var word = parseBase(number, i, number.length, base); ++ if (val >= mul) val -= Math.pow(2, 8 * byteLength) + +- for (var i = 0; i < mod; i++) +- pow *= base; +- this.imuln(pow); +- if (this.words[0] + word < 0x4000000) +- this.words[0] += word; +- else +- this._iaddn(word); +- } +-}; ++ return val ++} + +-BN.prototype.copy = function copy(dest) { +- dest.words = new Array(this.length); +- for (var i = 0; i < this.length; i++) +- dest.words[i] = this.words[i]; +- dest.length = this.length; +- dest.sign = this.sign; +- dest.red = this.red; +-}; ++Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { ++ offset = offset | 0 ++ byteLength = byteLength | 0 ++ if (!noAssert) checkOffset(offset, byteLength, this.length) + +-BN.prototype.clone = function clone() { +- var r = new BN(null); +- this.copy(r); +- return r; +-}; ++ var i = byteLength ++ var mul = 1 ++ var val = this[offset + --i] ++ while (i > 0 && (mul *= 0x100)) { ++ val += this[offset + --i] * mul ++ } ++ mul *= 0x80 + +-// Remove leading `0` from `this` +-BN.prototype.strip = function strip() { +- while (this.length > 1 && this.words[this.length - 1] === 0) +- this.length--; +- return this._normSign(); +-}; ++ if (val >= mul) val -= Math.pow(2, 8 * byteLength) + +-BN.prototype._normSign = function _normSign() { +- // -0 = 0 +- if (this.length === 1 && this.words[0] === 0) +- this.sign = false; +- return this; +-}; ++ return val ++} + +-BN.prototype.inspect = function inspect() { +- return (this.red ? ''; +-}; +- +-/* ++Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { ++ if (!noAssert) checkOffset(offset, 1, this.length) ++ if (!(this[offset] & 0x80)) return (this[offset]) ++ return ((0xff - this[offset] + 1) * -1) ++} + +-var zeros = []; +-var groupSizes = []; +-var groupBases = []; ++Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { ++ if (!noAssert) checkOffset(offset, 2, this.length) ++ var val = this[offset] | (this[offset + 1] << 8) ++ return (val & 0x8000) ? val | 0xFFFF0000 : val ++} + +-var s = ''; +-var i = -1; +-while (++i < BN.wordSize) { +- zeros[i] = s; +- s += '0'; ++Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { ++ if (!noAssert) checkOffset(offset, 2, this.length) ++ var val = this[offset + 1] | (this[offset] << 8) ++ return (val & 0x8000) ? val | 0xFFFF0000 : val + } +-groupSizes[0] = 0; +-groupSizes[1] = 0; +-groupBases[0] = 0; +-groupBases[1] = 0; +-var base = 2 - 1; +-while (++base < 36 + 1) { +- var groupSize = 0; +- var groupBase = 1; +- while (groupBase < (1 << BN.wordSize) / base) { +- groupBase *= base; +- groupSize += 1; +- } +- groupSizes[base] = groupSize; +- groupBases[base] = groupBase; ++ ++Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { ++ if (!noAssert) checkOffset(offset, 4, this.length) ++ ++ return (this[offset]) | ++ (this[offset + 1] << 8) | ++ (this[offset + 2] << 16) | ++ (this[offset + 3] << 24) + } + +-*/ ++Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { ++ if (!noAssert) checkOffset(offset, 4, this.length) + +-var zeros = [ +- '', +- '0', +- '00', +- '000', +- '0000', +- '00000', +- '000000', +- '0000000', +- '00000000', +- '000000000', +- '0000000000', +- '00000000000', +- '000000000000', +- '0000000000000', +- '00000000000000', +- '000000000000000', +- '0000000000000000', +- '00000000000000000', +- '000000000000000000', +- '0000000000000000000', +- '00000000000000000000', +- '000000000000000000000', +- '0000000000000000000000', +- '00000000000000000000000', +- '000000000000000000000000', +- '0000000000000000000000000' +-]; ++ return (this[offset] << 24) | ++ (this[offset + 1] << 16) | ++ (this[offset + 2] << 8) | ++ (this[offset + 3]) ++} + +-var groupSizes = [ +- 0, 0, +- 25, 16, 12, 11, 10, 9, 8, +- 8, 7, 7, 7, 7, 6, 6, +- 6, 6, 6, 6, 6, 5, 5, +- 5, 5, 5, 5, 5, 5, 5, +- 5, 5, 5, 5, 5, 5, 5 +-]; ++Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { ++ if (!noAssert) checkOffset(offset, 4, this.length) ++ return ieee754.read(this, offset, true, 23, 4) ++} + +-var groupBases = [ +- 0, 0, +- 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, +- 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625, +- 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632, +- 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, +- 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176 +-]; ++Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { ++ if (!noAssert) checkOffset(offset, 4, this.length) ++ return ieee754.read(this, offset, false, 23, 4) ++} + +-BN.prototype.toString = function toString(base, padding) { +- base = base || 10; +- if (base === 16 || base === 'hex') { +- var out = ''; +- var off = 0; +- var padding = padding | 0 || 1; +- var carry = 0; +- for (var i = 0; i < this.length; i++) { +- var w = this.words[i]; +- var word = (((w << off) | carry) & 0xffffff).toString(16); +- carry = (w >>> (24 - off)) & 0xffffff; +- if (carry !== 0 || i !== this.length - 1) +- out = zeros[6 - word.length] + word + out; +- else +- out = word + out; +- off += 2; +- if (off >= 26) { +- off -= 26; +- i--; +- } +- } +- if (carry !== 0) +- out = carry.toString(16) + out; +- while (out.length % padding !== 0) +- out = '0' + out; +- if (this.sign) +- out = '-' + out; +- return out; +- } else if (base === (base | 0) && base >= 2 && base <= 36) { +- // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base)); +- var groupSize = groupSizes[base]; +- // var groupBase = Math.pow(base, groupSize); +- var groupBase = groupBases[base]; +- var out = ''; +- var c = this.clone(); +- c.sign = false; +- while (c.cmpn(0) !== 0) { +- var r = c.modn(groupBase).toString(base); +- c = c.idivn(groupBase); ++Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { ++ if (!noAssert) checkOffset(offset, 8, this.length) ++ return ieee754.read(this, offset, true, 52, 8) ++} + +- if (c.cmpn(0) !== 0) +- out = zeros[groupSize - r.length] + r + out; +- else +- out = r + out; +- } +- if (this.cmpn(0) === 0) +- out = '0' + out; +- if (this.sign) +- out = '-' + out; +- return out; +- } else { +- assert(false, 'Base should be between 2 and 36'); +- } +-}; ++Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { ++ if (!noAssert) checkOffset(offset, 8, this.length) ++ return ieee754.read(this, offset, false, 52, 8) ++} + +-BN.prototype.toJSON = function toJSON() { +- return this.toString(16); +-}; ++function checkInt (buf, value, offset, ext, max, min) { ++ if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') ++ if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') ++ if (offset + ext > buf.length) throw new RangeError('Index out of range') ++} + +-BN.prototype.toArray = function toArray(endian) { +- this.strip(); +- var res = new Array(this.byteLength()); +- res[0] = 0; ++Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { ++ value = +value ++ offset = offset | 0 ++ byteLength = byteLength | 0 ++ if (!noAssert) { ++ var maxBytes = Math.pow(2, 8 * byteLength) - 1 ++ checkInt(this, value, offset, byteLength, maxBytes, 0) ++ } + +- var q = this.clone(); +- if (endian !== 'le') { +- // Assume big-endian +- for (var i = 0; q.cmpn(0) !== 0; i++) { +- var b = q.andln(0xff); +- q.ishrn(8); ++ var mul = 1 ++ var i = 0 ++ this[offset] = value & 0xFF ++ while (++i < byteLength && (mul *= 0x100)) { ++ this[offset + i] = (value / mul) & 0xFF ++ } + +- res[res.length - i - 1] = b; +- } +- } else { +- // Assume little-endian +- for (var i = 0; q.cmpn(0) !== 0; i++) { +- var b = q.andln(0xff); +- q.ishrn(8); ++ return offset + byteLength ++} + +- res[i] = b; +- } ++Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { ++ value = +value ++ offset = offset | 0 ++ byteLength = byteLength | 0 ++ if (!noAssert) { ++ var maxBytes = Math.pow(2, 8 * byteLength) - 1 ++ checkInt(this, value, offset, byteLength, maxBytes, 0) + } + +- return res; +-}; ++ var i = byteLength - 1 ++ var mul = 1 ++ this[offset + i] = value & 0xFF ++ while (--i >= 0 && (mul *= 0x100)) { ++ this[offset + i] = (value / mul) & 0xFF ++ } + +-if (Math.clz32) { +- BN.prototype._countBits = function _countBits(w) { +- return 32 - Math.clz32(w); +- }; +-} else { +- BN.prototype._countBits = function _countBits(w) { +- var t = w; +- var r = 0; +- if (t >= 0x1000) { +- r += 13; +- t >>>= 13; +- } +- if (t >= 0x40) { +- r += 7; +- t >>>= 7; +- } +- if (t >= 0x8) { +- r += 4; +- t >>>= 4; +- } +- if (t >= 0x02) { +- r += 2; +- t >>>= 2; +- } +- return r + t; +- }; ++ return offset + byteLength + } + +-BN.prototype._zeroBits = function _zeroBits(w) { +- // Short-cut +- if (w === 0) +- return 26; ++Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { ++ value = +value ++ offset = offset | 0 ++ if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) ++ if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) ++ this[offset] = (value & 0xff) ++ return offset + 1 ++} + +- var t = w; +- var r = 0; +- if ((t & 0x1fff) === 0) { +- r += 13; +- t >>>= 13; +- } +- if ((t & 0x7f) === 0) { +- r += 7; +- t >>>= 7; ++function objectWriteUInt16 (buf, value, offset, littleEndian) { ++ if (value < 0) value = 0xffff + value + 1 ++ for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) { ++ buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> ++ (littleEndian ? i : 1 - i) * 8 + } +- if ((t & 0xf) === 0) { +- r += 4; +- t >>>= 4; ++} ++ ++Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { ++ value = +value ++ offset = offset | 0 ++ if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) ++ if (Buffer.TYPED_ARRAY_SUPPORT) { ++ this[offset] = (value & 0xff) ++ this[offset + 1] = (value >>> 8) ++ } else { ++ objectWriteUInt16(this, value, offset, true) + } +- if ((t & 0x3) === 0) { +- r += 2; +- t >>>= 2; ++ return offset + 2 ++} ++ ++Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { ++ value = +value ++ offset = offset | 0 ++ if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) ++ if (Buffer.TYPED_ARRAY_SUPPORT) { ++ this[offset] = (value >>> 8) ++ this[offset + 1] = (value & 0xff) ++ } else { ++ objectWriteUInt16(this, value, offset, false) + } +- if ((t & 0x1) === 0) +- r++; +- return r; +-}; ++ return offset + 2 ++} + +-// Return number of used bits in a BN +-BN.prototype.bitLength = function bitLength() { +- var hi = 0; +- var w = this.words[this.length - 1]; +- var hi = this._countBits(w); +- return (this.length - 1) * 26 + hi; +-}; ++function objectWriteUInt32 (buf, value, offset, littleEndian) { ++ if (value < 0) value = 0xffffffff + value + 1 ++ for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) { ++ buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff ++ } ++} + +-// Number of trailing zero bits +-BN.prototype.zeroBits = function zeroBits() { +- if (this.cmpn(0) === 0) +- return 0; ++Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { ++ value = +value ++ offset = offset | 0 ++ if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) ++ if (Buffer.TYPED_ARRAY_SUPPORT) { ++ this[offset + 3] = (value >>> 24) ++ this[offset + 2] = (value >>> 16) ++ this[offset + 1] = (value >>> 8) ++ this[offset] = (value & 0xff) ++ } else { ++ objectWriteUInt32(this, value, offset, true) ++ } ++ return offset + 4 ++} + +- var r = 0; +- for (var i = 0; i < this.length; i++) { +- var b = this._zeroBits(this.words[i]); +- r += b; +- if (b !== 26) +- break; ++Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { ++ value = +value ++ offset = offset | 0 ++ if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) ++ if (Buffer.TYPED_ARRAY_SUPPORT) { ++ this[offset] = (value >>> 24) ++ this[offset + 1] = (value >>> 16) ++ this[offset + 2] = (value >>> 8) ++ this[offset + 3] = (value & 0xff) ++ } else { ++ objectWriteUInt32(this, value, offset, false) + } +- return r; +-}; ++ return offset + 4 ++} + +-BN.prototype.byteLength = function byteLength() { +- return Math.ceil(this.bitLength() / 8); +-}; ++Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { ++ value = +value ++ offset = offset | 0 ++ if (!noAssert) { ++ var limit = Math.pow(2, 8 * byteLength - 1) + +-// Return negative clone of `this` +-BN.prototype.neg = function neg() { +- if (this.cmpn(0) === 0) +- return this.clone(); ++ checkInt(this, value, offset, byteLength, limit - 1, -limit) ++ } + +- var r = this.clone(); +- r.sign = !this.sign; +- return r; +-}; ++ var i = 0 ++ var mul = 1 ++ var sub = 0 ++ this[offset] = value & 0xFF ++ while (++i < byteLength && (mul *= 0x100)) { ++ if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { ++ sub = 1 ++ } ++ this[offset + i] = ((value / mul) >> 0) - sub & 0xFF ++ } + ++ return offset + byteLength ++} + +-// Or `num` with `this` in-place +-BN.prototype.ior = function ior(num) { +- this.sign = this.sign || num.sign; ++Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { ++ value = +value ++ offset = offset | 0 ++ if (!noAssert) { ++ var limit = Math.pow(2, 8 * byteLength - 1) + +- while (this.length < num.length) +- this.words[this.length++] = 0; ++ checkInt(this, value, offset, byteLength, limit - 1, -limit) ++ } + +- for (var i = 0; i < num.length; i++) +- this.words[i] = this.words[i] | num.words[i]; ++ var i = byteLength - 1 ++ var mul = 1 ++ var sub = 0 ++ this[offset + i] = value & 0xFF ++ while (--i >= 0 && (mul *= 0x100)) { ++ if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { ++ sub = 1 ++ } ++ this[offset + i] = ((value / mul) >> 0) - sub & 0xFF ++ } + +- return this.strip(); +-}; ++ return offset + byteLength ++} + ++Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { ++ value = +value ++ offset = offset | 0 ++ if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) ++ if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) ++ if (value < 0) value = 0xff + value + 1 ++ this[offset] = (value & 0xff) ++ return offset + 1 ++} + +-// Or `num` with `this` +-BN.prototype.or = function or(num) { +- if (this.length > num.length) +- return this.clone().ior(num); +- else +- return num.clone().ior(this); +-}; ++Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { ++ value = +value ++ offset = offset | 0 ++ if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) ++ if (Buffer.TYPED_ARRAY_SUPPORT) { ++ this[offset] = (value & 0xff) ++ this[offset + 1] = (value >>> 8) ++ } else { ++ objectWriteUInt16(this, value, offset, true) ++ } ++ return offset + 2 ++} + ++Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { ++ value = +value ++ offset = offset | 0 ++ if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) ++ if (Buffer.TYPED_ARRAY_SUPPORT) { ++ this[offset] = (value >>> 8) ++ this[offset + 1] = (value & 0xff) ++ } else { ++ objectWriteUInt16(this, value, offset, false) ++ } ++ return offset + 2 ++} + +-// And `num` with `this` in-place +-BN.prototype.iand = function iand(num) { +- this.sign = this.sign && num.sign; ++Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { ++ value = +value ++ offset = offset | 0 ++ if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) ++ if (Buffer.TYPED_ARRAY_SUPPORT) { ++ this[offset] = (value & 0xff) ++ this[offset + 1] = (value >>> 8) ++ this[offset + 2] = (value >>> 16) ++ this[offset + 3] = (value >>> 24) ++ } else { ++ objectWriteUInt32(this, value, offset, true) ++ } ++ return offset + 4 ++} + +- // b = min-length(num, this) +- var b; +- if (this.length > num.length) +- b = num; +- else +- b = this; ++Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { ++ value = +value ++ offset = offset | 0 ++ if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) ++ if (value < 0) value = 0xffffffff + value + 1 ++ if (Buffer.TYPED_ARRAY_SUPPORT) { ++ this[offset] = (value >>> 24) ++ this[offset + 1] = (value >>> 16) ++ this[offset + 2] = (value >>> 8) ++ this[offset + 3] = (value & 0xff) ++ } else { ++ objectWriteUInt32(this, value, offset, false) ++ } ++ return offset + 4 ++} + +- for (var i = 0; i < b.length; i++) +- this.words[i] = this.words[i] & num.words[i]; ++function checkIEEE754 (buf, value, offset, ext, max, min) { ++ if (offset + ext > buf.length) throw new RangeError('Index out of range') ++ if (offset < 0) throw new RangeError('Index out of range') ++} + +- this.length = b.length; ++function writeFloat (buf, value, offset, littleEndian, noAssert) { ++ if (!noAssert) { ++ checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) ++ } ++ ieee754.write(buf, value, offset, littleEndian, 23, 4) ++ return offset + 4 ++} + +- return this.strip(); +-}; ++Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { ++ return writeFloat(this, value, offset, true, noAssert) ++} + ++Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { ++ return writeFloat(this, value, offset, false, noAssert) ++} + +-// And `num` with `this` +-BN.prototype.and = function and(num) { +- if (this.length > num.length) +- return this.clone().iand(num); +- else +- return num.clone().iand(this); +-}; +- +- +-// Xor `num` with `this` in-place +-BN.prototype.ixor = function ixor(num) { +- this.sign = this.sign || num.sign; +- +- // a.length > b.length +- var a; +- var b; +- if (this.length > num.length) { +- a = this; +- b = num; +- } else { +- a = num; +- b = this; ++function writeDouble (buf, value, offset, littleEndian, noAssert) { ++ if (!noAssert) { ++ checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) + } ++ ieee754.write(buf, value, offset, littleEndian, 52, 8) ++ return offset + 8 ++} + +- for (var i = 0; i < b.length; i++) +- this.words[i] = a.words[i] ^ b.words[i]; +- +- if (this !== a) +- for (; i < a.length; i++) +- this.words[i] = a.words[i]; +- +- this.length = a.length; +- +- return this.strip(); +-}; +- +- +-// Xor `num` with `this` +-BN.prototype.xor = function xor(num) { +- if (this.length > num.length) +- return this.clone().ixor(num); +- else +- return num.clone().ixor(this); +-}; ++Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { ++ return writeDouble(this, value, offset, true, noAssert) ++} + ++Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { ++ return writeDouble(this, value, offset, false, noAssert) ++} + +-// Set `bit` of `this` +-BN.prototype.setn = function setn(bit, val) { +- assert(typeof bit === 'number' && bit >= 0); ++// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) ++Buffer.prototype.copy = function copy (target, targetStart, start, end) { ++ if (!start) start = 0 ++ if (!end && end !== 0) end = this.length ++ if (targetStart >= target.length) targetStart = target.length ++ if (!targetStart) targetStart = 0 ++ if (end > 0 && end < start) end = start + +- var off = (bit / 26) | 0; +- var wbit = bit % 26; ++ // Copy 0 bytes; we're done ++ if (end === start) return 0 ++ if (target.length === 0 || this.length === 0) return 0 + +- while (this.length <= off) +- this.words[this.length++] = 0; ++ // Fatal error conditions ++ if (targetStart < 0) { ++ throw new RangeError('targetStart out of bounds') ++ } ++ if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds') ++ if (end < 0) throw new RangeError('sourceEnd out of bounds') + +- if (val) +- this.words[off] = this.words[off] | (1 << wbit); +- else +- this.words[off] = this.words[off] & ~(1 << wbit); ++ // Are we oob? ++ if (end > this.length) end = this.length ++ if (target.length - targetStart < end - start) { ++ end = target.length - targetStart + start ++ } + +- return this.strip(); +-}; ++ var len = end - start ++ var i + ++ if (this === target && start < targetStart && targetStart < end) { ++ // descending copy from end ++ for (i = len - 1; i >= 0; --i) { ++ target[i + targetStart] = this[i + start] ++ } ++ } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { ++ // ascending copy from start ++ for (i = 0; i < len; ++i) { ++ target[i + targetStart] = this[i + start] ++ } ++ } else { ++ Uint8Array.prototype.set.call( ++ target, ++ this.subarray(start, start + len), ++ targetStart ++ ) ++ } + +-// Add `num` to `this` in-place +-BN.prototype.iadd = function iadd(num) { +- // negative + positive +- if (this.sign && !num.sign) { +- this.sign = false; +- var r = this.isub(num); +- this.sign = !this.sign; +- return this._normSign(); ++ return len ++} + +- // positive + negative +- } else if (!this.sign && num.sign) { +- num.sign = false; +- var r = this.isub(num); +- num.sign = true; +- return r._normSign(); ++// Usage: ++// buffer.fill(number[, offset[, end]]) ++// buffer.fill(buffer[, offset[, end]]) ++// buffer.fill(string[, offset[, end]][, encoding]) ++Buffer.prototype.fill = function fill (val, start, end, encoding) { ++ // Handle string cases: ++ if (typeof val === 'string') { ++ if (typeof start === 'string') { ++ encoding = start ++ start = 0 ++ end = this.length ++ } else if (typeof end === 'string') { ++ encoding = end ++ end = this.length ++ } ++ if (val.length === 1) { ++ var code = val.charCodeAt(0) ++ if (code < 256) { ++ val = code ++ } ++ } ++ if (encoding !== undefined && typeof encoding !== 'string') { ++ throw new TypeError('encoding must be a string') ++ } ++ if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { ++ throw new TypeError('Unknown encoding: ' + encoding) ++ } ++ } else if (typeof val === 'number') { ++ val = val & 255 + } + +- // a.length > b.length +- var a; +- var b; +- if (this.length > num.length) { +- a = this; +- b = num; +- } else { +- a = num; +- b = this; ++ // Invalid ranges are not set to a default, so can range check early. ++ if (start < 0 || this.length < start || this.length < end) { ++ throw new RangeError('Out of range index') + } + +- var carry = 0; +- for (var i = 0; i < b.length; i++) { +- var r = a.words[i] + b.words[i] + carry; +- this.words[i] = r & 0x3ffffff; +- carry = r >>> 26; +- } +- for (; carry !== 0 && i < a.length; i++) { +- var r = a.words[i] + carry; +- this.words[i] = r & 0x3ffffff; +- carry = r >>> 26; ++ if (end <= start) { ++ return this + } + +- this.length = a.length; +- if (carry !== 0) { +- this.words[this.length] = carry; +- this.length++; +- // Copy the rest of the words +- } else if (a !== this) { +- for (; i < a.length; i++) +- this.words[i] = a.words[i]; +- } ++ start = start >>> 0 ++ end = end === undefined ? this.length : end >>> 0 + +- return this; +-}; ++ if (!val) val = 0 + +-// Add `num` to `this` +-BN.prototype.add = function add(num) { +- if (num.sign && !this.sign) { +- num.sign = false; +- var res = this.sub(num); +- num.sign = true; +- return res; +- } else if (!num.sign && this.sign) { +- this.sign = false; +- var res = num.sub(this); +- this.sign = true; +- return res; ++ var i ++ if (typeof val === 'number') { ++ for (i = start; i < end; ++i) { ++ this[i] = val ++ } ++ } else { ++ var bytes = Buffer.isBuffer(val) ++ ? val ++ : utf8ToBytes(new Buffer(val, encoding).toString()) ++ var len = bytes.length ++ for (i = 0; i < end - start; ++i) { ++ this[i + start] = bytes[i % len] ++ } + } + +- if (this.length > num.length) +- return this.clone().iadd(num); +- else +- return num.clone().iadd(this); +-}; ++ return this ++} + +-// Subtract `num` from `this` in-place +-BN.prototype.isub = function isub(num) { +- // this - (-num) = this + num +- if (num.sign) { +- num.sign = false; +- var r = this.iadd(num); +- num.sign = true; +- return r._normSign(); ++// HELPER FUNCTIONS ++// ================ + +- // -this - num = -(this + num) +- } else if (this.sign) { +- this.sign = false; +- this.iadd(num); +- this.sign = true; +- return this._normSign(); ++var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g ++ ++function base64clean (str) { ++ // Node strips out invalid characters like \n and \t from the string, base64-js does not ++ str = stringtrim(str).replace(INVALID_BASE64_RE, '') ++ // Node converts strings with length < 2 to '' ++ if (str.length < 2) return '' ++ // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not ++ while (str.length % 4 !== 0) { ++ str = str + '=' + } ++ return str ++} + +- // At this point both numbers are positive +- var cmp = this.cmp(num); ++function stringtrim (str) { ++ if (str.trim) return str.trim() ++ return str.replace(/^\s+|\s+$/g, '') ++} + +- // Optimization - zeroify +- if (cmp === 0) { +- this.sign = false; +- this.length = 1; +- this.words[0] = 0; +- return this; +- } ++function toHex (n) { ++ if (n < 16) return '0' + n.toString(16) ++ return n.toString(16) ++} + +- // a > b +- var a; +- var b; +- if (cmp > 0) { +- a = this; +- b = num; +- } else { +- a = num; +- b = this; +- } ++function utf8ToBytes (string, units) { ++ units = units || Infinity ++ var codePoint ++ var length = string.length ++ var leadSurrogate = null ++ var bytes = [] + +- var carry = 0; +- for (var i = 0; i < b.length; i++) { +- var r = a.words[i] - b.words[i] + carry; +- carry = r >> 26; +- this.words[i] = r & 0x3ffffff; +- } +- for (; carry !== 0 && i < a.length; i++) { +- var r = a.words[i] + carry; +- carry = r >> 26; +- this.words[i] = r & 0x3ffffff; +- } ++ for (var i = 0; i < length; ++i) { ++ codePoint = string.charCodeAt(i) + +- // Copy rest of the words +- if (carry === 0 && i < a.length && a !== this) +- for (; i < a.length; i++) +- this.words[i] = a.words[i]; +- this.length = Math.max(this.length, i); ++ // is surrogate component ++ if (codePoint > 0xD7FF && codePoint < 0xE000) { ++ // last char was a lead ++ if (!leadSurrogate) { ++ // no lead yet ++ if (codePoint > 0xDBFF) { ++ // unexpected trail ++ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) ++ continue ++ } else if (i + 1 === length) { ++ // unpaired lead ++ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) ++ continue ++ } + +- if (a !== this) +- this.sign = true; ++ // valid lead ++ leadSurrogate = codePoint + +- return this.strip(); +-}; ++ continue ++ } + +-// Subtract `num` from `this` +-BN.prototype.sub = function sub(num) { +- return this.clone().isub(num); +-}; ++ // 2 leads in a row ++ if (codePoint < 0xDC00) { ++ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) ++ leadSurrogate = codePoint ++ continue ++ } + +-/* +-// NOTE: This could be potentionally used to generate loop-less multiplications +-function _genCombMulTo(alen, blen) { +- var len = alen + blen - 1; +- var src = [ +- 'var a = this.words, b = num.words, o = out.words, c = 0, w, ' + +- 'mask = 0x3ffffff, shift = 0x4000000;', +- 'out.length = ' + len + ';' +- ]; +- for (var k = 0; k < len; k++) { +- var minJ = Math.max(0, k - alen + 1); +- var maxJ = Math.min(k, blen - 1); ++ // valid surrogate pair ++ codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 ++ } else if (leadSurrogate) { ++ // valid bmp char, but last char was a lead ++ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) ++ } + +- for (var j = minJ; j <= maxJ; j++) { +- var i = k - j; +- var mul = 'a[' + i + '] * b[' + j + ']'; ++ leadSurrogate = null + +- if (j === minJ) { +- src.push('w = ' + mul + ' + c;'); +- src.push('c = (w / shift) | 0;'); +- } else { +- src.push('w += ' + mul + ';'); +- src.push('c += (w / shift) | 0;'); +- } +- src.push('w &= mask;'); ++ // encode utf8 ++ if (codePoint < 0x80) { ++ if ((units -= 1) < 0) break ++ bytes.push(codePoint) ++ } else if (codePoint < 0x800) { ++ if ((units -= 2) < 0) break ++ bytes.push( ++ codePoint >> 0x6 | 0xC0, ++ codePoint & 0x3F | 0x80 ++ ) ++ } else if (codePoint < 0x10000) { ++ if ((units -= 3) < 0) break ++ bytes.push( ++ codePoint >> 0xC | 0xE0, ++ codePoint >> 0x6 & 0x3F | 0x80, ++ codePoint & 0x3F | 0x80 ++ ) ++ } else if (codePoint < 0x110000) { ++ if ((units -= 4) < 0) break ++ bytes.push( ++ codePoint >> 0x12 | 0xF0, ++ codePoint >> 0xC & 0x3F | 0x80, ++ codePoint >> 0x6 & 0x3F | 0x80, ++ codePoint & 0x3F | 0x80 ++ ) ++ } else { ++ throw new Error('Invalid code point') + } +- src.push('o[' + k + '] = w;'); + } +- src.push('if (c !== 0) {', +- ' o[' + k + '] = c;', +- ' out.length++;', +- '}', +- 'return out;'); + +- return src.join('\n'); ++ return bytes + } +-*/ + +-BN.prototype._smallMulTo = function _smallMulTo(num, out) { +- out.sign = num.sign !== this.sign; +- out.length = this.length + num.length; ++function asciiToBytes (str) { ++ var byteArray = [] ++ for (var i = 0; i < str.length; ++i) { ++ // Node's code seems to be doing this and not & 0x7F.. ++ byteArray.push(str.charCodeAt(i) & 0xFF) ++ } ++ return byteArray ++} + +- var carry = 0; +- for (var k = 0; k < out.length - 1; k++) { +- // Sum all words with the same `i + j = k` and accumulate `ncarry`, +- // note that ncarry could be >= 0x3ffffff +- var ncarry = carry >>> 26; +- var rword = carry & 0x3ffffff; +- var maxJ = Math.min(k, num.length - 1); +- for (var j = Math.max(0, k - this.length + 1); j <= maxJ; j++) { +- var i = k - j; +- var a = this.words[i] | 0; +- var b = num.words[j] | 0; +- var r = a * b; ++function utf16leToBytes (str, units) { ++ var c, hi, lo ++ var byteArray = [] ++ for (var i = 0; i < str.length; ++i) { ++ if ((units -= 2) < 0) break + +- var lo = r & 0x3ffffff; +- ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0; +- lo = (lo + rword) | 0; +- rword = lo & 0x3ffffff; +- ncarry = (ncarry + (lo >>> 26)) | 0; +- } +- out.words[k] = rword; +- carry = ncarry; ++ c = str.charCodeAt(i) ++ hi = c >> 8 ++ lo = c % 256 ++ byteArray.push(lo) ++ byteArray.push(hi) + } +- if (carry !== 0) { +- out.words[k] = carry; +- } else { +- out.length--; ++ ++ return byteArray ++} ++ ++function base64ToBytes (str) { ++ return base64.toByteArray(base64clean(str)) ++} ++ ++function blitBuffer (src, dst, offset, length) { ++ for (var i = 0; i < length; ++i) { ++ if ((i + offset >= dst.length) || (i >= src.length)) break ++ dst[i + offset] = src[i] + } ++ return i ++} + +- return out.strip(); +-}; ++function isnan (val) { ++ return val !== val // eslint-disable-line no-self-compare ++} + +-BN.prototype._bigMulTo = function _bigMulTo(num, out) { +- out.sign = num.sign !== this.sign; +- out.length = this.length + num.length; ++}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) ++},{"base64-js":46,"ieee754":164,"isarray":47}],46:[function(require,module,exports){ ++'use strict' + +- var carry = 0; +- var hncarry = 0; +- for (var k = 0; k < out.length - 1; k++) { +- // Sum all words with the same `i + j = k` and accumulate `ncarry`, +- // note that ncarry could be >= 0x3ffffff +- var ncarry = hncarry; +- hncarry = 0; +- var rword = carry & 0x3ffffff; +- var maxJ = Math.min(k, num.length - 1); +- for (var j = Math.max(0, k - this.length + 1); j <= maxJ; j++) { +- var i = k - j; +- var a = this.words[i] | 0; +- var b = num.words[j] | 0; +- var r = a * b; ++exports.toByteArray = toByteArray ++exports.fromByteArray = fromByteArray + +- var lo = r & 0x3ffffff; +- ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0; +- lo = (lo + rword) | 0; +- rword = lo & 0x3ffffff; +- ncarry = (ncarry + (lo >>> 26)) | 0; ++var lookup = [] ++var revLookup = [] ++var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array + +- hncarry += ncarry >>> 26; +- ncarry &= 0x3ffffff; +- } +- out.words[k] = rword; +- carry = ncarry; +- ncarry = hncarry; +- } +- if (carry !== 0) { +- out.words[k] = carry; +- } else { +- out.length--; ++function init () { ++ var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' ++ for (var i = 0, len = code.length; i < len; ++i) { ++ lookup[i] = code[i] ++ revLookup[code.charCodeAt(i)] = i + } + +- return out.strip(); +-}; ++ revLookup['-'.charCodeAt(0)] = 62 ++ revLookup['_'.charCodeAt(0)] = 63 ++} + +-BN.prototype.mulTo = function mulTo(num, out) { +- var res; +- if (this.length + num.length < 63) +- res = this._smallMulTo(num, out); +- else +- res = this._bigMulTo(num, out); +- return res; +-}; ++init() + +-// Multiply `this` by `num` +-BN.prototype.mul = function mul(num) { +- var out = new BN(null); +- out.words = new Array(this.length + num.length); +- return this.mulTo(num, out); +-}; ++function toByteArray (b64) { ++ var i, j, l, tmp, placeHolders, arr ++ var len = b64.length + +-// In-place Multiplication +-BN.prototype.imul = function imul(num) { +- if (this.cmpn(0) === 0 || num.cmpn(0) === 0) { +- this.words[0] = 0; +- this.length = 1; +- return this; ++ if (len % 4 > 0) { ++ throw new Error('Invalid string. Length must be a multiple of 4') + } + +- var tlen = this.length; +- var nlen = num.length; ++ // the number of equal signs (place holders) ++ // if there are two placeholders, than the two characters before it ++ // represent one byte ++ // if there is only one, then the three characters before it represent 2 bytes ++ // this is just a cheap hack to not do indexOf twice ++ placeHolders = b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0 + +- this.sign = num.sign !== this.sign; +- this.length = this.length + num.length; +- this.words[this.length - 1] = 0; ++ // base64 is 4/3 + up to two characters of the original data ++ arr = new Arr(len * 3 / 4 - placeHolders) + +- for (var k = this.length - 2; k >= 0; k--) { +- // Sum all words with the same `i + j = k` and accumulate `carry`, +- // note that carry could be >= 0x3ffffff +- var carry = 0; +- var rword = 0; +- var maxJ = Math.min(k, nlen - 1); +- for (var j = Math.max(0, k - tlen + 1); j <= maxJ; j++) { +- var i = k - j; +- var a = this.words[i]; +- var b = num.words[j]; +- var r = a * b; ++ // if there are placeholders, only get up to the last complete 4 chars ++ l = placeHolders > 0 ? len - 4 : len + +- var lo = r & 0x3ffffff; +- carry += (r / 0x4000000) | 0; +- lo += rword; +- rword = lo & 0x3ffffff; +- carry += lo >>> 26; +- } +- this.words[k] = rword; +- this.words[k + 1] += carry; +- carry = 0; ++ var L = 0 ++ ++ for (i = 0, j = 0; i < l; i += 4, j += 3) { ++ tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)] ++ arr[L++] = (tmp >> 16) & 0xFF ++ arr[L++] = (tmp >> 8) & 0xFF ++ arr[L++] = tmp & 0xFF + } + +- // Propagate overflows +- var carry = 0; +- for (var i = 1; i < this.length; i++) { +- var w = this.words[i] + carry; +- this.words[i] = w & 0x3ffffff; +- carry = w >>> 26; ++ if (placeHolders === 2) { ++ tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4) ++ arr[L++] = tmp & 0xFF ++ } else if (placeHolders === 1) { ++ tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2) ++ arr[L++] = (tmp >> 8) & 0xFF ++ arr[L++] = tmp & 0xFF + } + +- return this.strip(); +-}; ++ return arr ++} + +-BN.prototype.imuln = function imuln(num) { +- assert(typeof num === 'number'); ++function tripletToBase64 (num) { ++ return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F] ++} + +- // Carry +- var carry = 0; +- for (var i = 0; i < this.length; i++) { +- var w = this.words[i] * num; +- var lo = (w & 0x3ffffff) + (carry & 0x3ffffff); +- carry >>= 26; +- carry += (w / 0x4000000) | 0; +- // NOTE: lo is 27bit maximum +- carry += lo >>> 26; +- this.words[i] = lo & 0x3ffffff; ++function encodeChunk (uint8, start, end) { ++ var tmp ++ var output = [] ++ for (var i = start; i < end; i += 3) { ++ tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]) ++ output.push(tripletToBase64(tmp)) + } ++ return output.join('') ++} + +- if (carry !== 0) { +- this.words[i] = carry; +- this.length++; ++function fromByteArray (uint8) { ++ var tmp ++ var len = uint8.length ++ var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes ++ var output = '' ++ var parts = [] ++ var maxChunkLength = 16383 // must be multiple of 3 ++ ++ // go through the array every three bytes, we'll deal with trailing stuff later ++ for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { ++ parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))) + } + +- return this; +-}; ++ // pad the end with zeros, but make sure to not forget the extra bytes ++ if (extraBytes === 1) { ++ tmp = uint8[len - 1] ++ output += lookup[tmp >> 2] ++ output += lookup[(tmp << 4) & 0x3F] ++ output += '==' ++ } else if (extraBytes === 2) { ++ tmp = (uint8[len - 2] << 8) + (uint8[len - 1]) ++ output += lookup[tmp >> 10] ++ output += lookup[(tmp >> 4) & 0x3F] ++ output += lookup[(tmp << 2) & 0x3F] ++ output += '=' ++ } + +-BN.prototype.muln = function muln(num) { +- return this.clone().imuln(num); +-}; ++ parts.push(output) + +-// `this` * `this` +-BN.prototype.sqr = function sqr() { +- return this.mul(this); +-}; ++ return parts.join('') ++} + +-// `this` * `this` in-place +-BN.prototype.isqr = function isqr() { +- return this.mul(this); +-}; ++},{}],47:[function(require,module,exports){ ++var toString = {}.toString; + +-// Shift-left in-place +-BN.prototype.ishln = function ishln(bits) { +- assert(typeof bits === 'number' && bits >= 0); +- var r = bits % 26; +- var s = (bits - r) / 26; +- var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r); ++module.exports = Array.isArray || function (arr) { ++ return toString.call(arr) == '[object Array]'; ++}; + +- if (r !== 0) { +- var carry = 0; +- for (var i = 0; i < this.length; i++) { +- var newCarry = this.words[i] & carryMask; +- var c = (this.words[i] - newCarry) << r; +- this.words[i] = c | carry; +- carry = newCarry >>> (26 - r); +- } +- if (carry) { +- this.words[i] = carry; +- this.length++; +- } +- } ++},{}],48:[function(require,module,exports){ ++'use strict' + +- if (s !== 0) { +- for (var i = this.length - 1; i >= 0; i--) +- this.words[i + s] = this.words[i]; +- for (var i = 0; i < s; i++) +- this.words[i] = 0; +- this.length += s; +- } ++var monotoneTriangulate = require('./lib/monotone') ++var makeIndex = require('./lib/triangulation') ++var delaunayFlip = require('./lib/delaunay') ++var filterTriangulation = require('./lib/filter') + +- return this.strip(); +-}; ++module.exports = cdt2d + +-// Shift-right in-place +-// NOTE: `hint` is a lowest bit before trailing zeroes +-// NOTE: if `extended` is present - it will be filled with destroyed bits +-BN.prototype.ishrn = function ishrn(bits, hint, extended) { +- assert(typeof bits === 'number' && bits >= 0); +- var h; +- if (hint) +- h = (hint - (hint % 26)) / 26; +- else +- h = 0; ++function canonicalizeEdge(e) { ++ return [Math.min(e[0], e[1]), Math.max(e[0], e[1])] ++} + +- var r = bits % 26; +- var s = Math.min((bits - r) / 26, this.length); +- var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); +- var maskedWords = extended; ++function compareEdge(a, b) { ++ return a[0]-b[0] || a[1]-b[1] ++} + +- h -= s; +- h = Math.max(0, h); ++function canonicalizeEdges(edges) { ++ return edges.map(canonicalizeEdge).sort(compareEdge) ++} + +- // Extended mode, copy masked part +- if (maskedWords) { +- for (var i = 0; i < s; i++) +- maskedWords.words[i] = this.words[i]; +- maskedWords.length = s; ++function getDefault(options, property, dflt) { ++ if(property in options) { ++ return options[property] + } ++ return dflt ++} + +- if (s === 0) { +- // No-op, we should not move anything at all +- } else if (this.length > s) { +- this.length -= s; +- for (var i = 0; i < this.length; i++) +- this.words[i] = this.words[i + s]; +- } else { +- this.words[0] = 0; +- this.length = 1; +- } ++function cdt2d(points, edges, options) { + +- var carry = 0; +- for (var i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) { +- var word = this.words[i]; +- this.words[i] = (carry << (26 - r)) | (word >>> r); +- carry = word & mask; ++ if(!Array.isArray(edges)) { ++ options = edges || {} ++ edges = [] ++ } else { ++ options = options || {} ++ edges = edges || [] + } + +- // Push carried bits as a mask +- if (maskedWords && carry !== 0) +- maskedWords.words[maskedWords.length++] = carry; ++ //Parse out options ++ var delaunay = !!getDefault(options, 'delaunay', true) ++ var interior = !!getDefault(options, 'interior', true) ++ var exterior = !!getDefault(options, 'exterior', true) ++ var infinity = !!getDefault(options, 'infinity', false) + +- if (this.length === 0) { +- this.words[0] = 0; +- this.length = 1; ++ //Handle trivial case ++ if((!interior && !exterior) || points.length === 0) { ++ return [] + } + +- this.strip(); +- +- return this; +-}; ++ //Construct initial triangulation ++ var cells = monotoneTriangulate(points, edges) + +-// Shift-left +-BN.prototype.shln = function shln(bits) { +- return this.clone().ishln(bits); +-}; ++ //If delaunay refinement needed, then improve quality by edge flipping ++ if(delaunay || interior !== exterior || infinity) { + +-// Shift-right +-BN.prototype.shrn = function shrn(bits) { +- return this.clone().ishrn(bits); +-}; ++ //Index all of the cells to support fast neighborhood queries ++ var triangulation = makeIndex(points.length, canonicalizeEdges(edges)) ++ for(var i=0; i= 0); +- var r = bit % 26; +- var s = (bit - r) / 26; +- var q = 1 << r; ++ //Run edge flipping ++ if(delaunay) { ++ delaunayFlip(points, triangulation) ++ } + +- // Fast case: bit is much higher than all existing words +- if (this.length <= s) { +- return false; ++ //Filter points ++ if(!exterior) { ++ return filterTriangulation(triangulation, -1) ++ } else if(!interior) { ++ return filterTriangulation(triangulation, 1, infinity) ++ } else if(infinity) { ++ return filterTriangulation(triangulation, 0, infinity) ++ } else { ++ return triangulation.cells() ++ } ++ ++ } else { ++ return cells + } ++} + +- // Check bit and return +- var w = this.words[s]; +- +- return !!(w & q); +-}; ++},{"./lib/delaunay":49,"./lib/filter":50,"./lib/monotone":51,"./lib/triangulation":52}],49:[function(require,module,exports){ ++'use strict' + +-// Return only lowers bits of number (in-place) +-BN.prototype.imaskn = function imaskn(bits) { +- assert(typeof bits === 'number' && bits >= 0); +- var r = bits % 26; +- var s = (bits - r) / 26; ++var inCircle = require('robust-in-sphere')[4] ++var bsearch = require('binary-search-bounds') + +- assert(!this.sign, 'imaskn works only with positive numbers'); ++module.exports = delaunayRefine + +- if (r !== 0) +- s++; +- this.length = Math.min(s, this.length); ++function testFlip(points, triangulation, stack, a, b, x) { ++ var y = triangulation.opposite(a, b) + +- if (r !== 0) { +- var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); +- this.words[this.length - 1] &= mask; ++ //Test boundary edge ++ if(y < 0) { ++ return + } + +- return this.strip(); +-}; +- +-// Return only lowers bits of number +-BN.prototype.maskn = function maskn(bits) { +- return this.clone().imaskn(bits); +-}; +- +-// Add plain number `num` to `this` +-BN.prototype.iaddn = function iaddn(num) { +- assert(typeof num === 'number'); +- if (num < 0) +- return this.isubn(-num); +- +- // Possible sign change +- if (this.sign) { +- if (this.length === 1 && this.words[0] < num) { +- this.words[0] = num - this.words[0]; +- this.sign = false; +- return this; +- } +- +- this.sign = false; +- this.isubn(num); +- this.sign = true; +- return this; ++ //Swap edge if order flipped ++ if(b < a) { ++ var tmp = a ++ a = b ++ b = tmp ++ tmp = x ++ x = y ++ y = tmp + } + +- // Add without checks +- return this._iaddn(num); +-}; +- +-BN.prototype._iaddn = function _iaddn(num) { +- this.words[0] += num; +- +- // Carry +- for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) { +- this.words[i] -= 0x4000000; +- if (i === this.length - 1) +- this.words[i + 1] = 1; +- else +- this.words[i + 1]++; ++ //Test if edge is constrained ++ if(triangulation.isConstraint(a, b)) { ++ return + } +- this.length = Math.max(this.length, i + 1); +- +- return this; +-}; +- +-// Subtract plain number `num` from `this` +-BN.prototype.isubn = function isubn(num) { +- assert(typeof num === 'number'); +- if (num < 0) +- return this.iaddn(-num); + +- if (this.sign) { +- this.sign = false; +- this.iaddn(num); +- this.sign = true; +- return this; ++ //Test if edge is delaunay ++ if(inCircle(points[a], points[b], points[x], points[y]) < 0) { ++ stack.push(a, b) + } ++} + +- this.words[0] -= num; ++//Assume edges are sorted lexicographically ++function delaunayRefine(points, triangulation) { ++ var stack = [] + +- // Carry +- for (var i = 0; i < this.length && this.words[i] < 0; i++) { +- this.words[i] += 0x4000000; +- this.words[i + 1] -= 1; +- } ++ var numPoints = points.length ++ var stars = triangulation.stars ++ for(var a=0; a 0) { ++ var b = stack.pop() ++ var a = stack.pop() + +-BN.prototype._ishlnsubmul = function _ishlnsubmul(num, mul, shift) { +- // Bigger storage is needed +- var len = num.length + shift; +- var i; +- if (this.words.length < len) { +- var t = new Array(len); +- for (var i = 0; i < this.length; i++) +- t[i] = this.words[i]; +- this.words = t; +- } else { +- i = this.length; +- } ++ //Find opposite pairs ++ var x = -1, y = -1 ++ var star = stars[a] ++ for(var i=1; i> 26) - ((right / 0x4000000) | 0); +- this.words[i + shift] = w & 0x3ffffff; +- } +- for (; i < this.length - shift; i++) { +- var w = this.words[i + shift] + carry; +- carry = w >> 26; +- this.words[i + shift] = w & 0x3ffffff; +- } ++ //If edge is now delaunay, then don't flip it ++ if(inCircle(points[a], points[b], points[x], points[y]) >= 0) { ++ continue ++ } + +- if (carry === 0) +- return this.strip(); ++ //Flip the edge ++ triangulation.flip(a, b) + +- // Subtraction overflow +- assert(carry === -1); +- carry = 0; +- for (var i = 0; i < this.length; i++) { +- var w = -this.words[i] + carry; +- carry = w >> 26; +- this.words[i] = w & 0x3ffffff; ++ //Test flipping neighboring edges ++ testFlip(points, triangulation, stack, x, a, y) ++ testFlip(points, triangulation, stack, a, y, x) ++ testFlip(points, triangulation, stack, y, b, x) ++ testFlip(points, triangulation, stack, b, x, y) + } +- this.sign = true; ++} + +- return this.strip(); +-}; ++},{"binary-search-bounds":53,"robust-in-sphere":217}],50:[function(require,module,exports){ ++'use strict' + +-BN.prototype._wordDiv = function _wordDiv(num, mode) { +- var shift = this.length - num.length; ++var bsearch = require('binary-search-bounds') + +- var a = this.clone(); +- var b = num; ++module.exports = classifyFaces + +- // Normalize +- var bhi = b.words[b.length - 1]; +- var bhiBits = this._countBits(bhi); +- shift = 26 - bhiBits; +- if (shift !== 0) { +- b = b.shln(shift); +- a.ishln(shift); +- bhi = b.words[b.length - 1]; +- } ++function FaceIndex(cells, neighbor, constraint, flags, active, next, boundary) { ++ this.cells = cells ++ this.neighbor = neighbor ++ this.flags = flags ++ this.constraint = constraint ++ this.active = active ++ this.next = next ++ this.boundary = boundary ++} + +- // Initialize quotient +- var m = a.length - b.length; +- var q; ++var proto = FaceIndex.prototype + +- if (mode !== 'mod') { +- q = new BN(null); +- q.length = m + 1; +- q.words = new Array(q.length); +- for (var i = 0; i < q.length; i++) +- q.words[i] = 0; +- } ++function compareCell(a, b) { ++ return a[0] - b[0] || ++ a[1] - b[1] || ++ a[2] - b[2] ++} + +- var diff = a.clone()._ishlnsubmul(b, 1, m); +- if (!diff.sign) { +- a = diff; +- if (q) +- q.words[m] = 1; ++proto.locate = (function() { ++ var key = [0,0,0] ++ return function(a, b, c) { ++ var x = a, y = b, z = c ++ if(b < c) { ++ if(b < a) { ++ x = b ++ y = c ++ z = a ++ } ++ } else if(c < a) { ++ x = c ++ y = a ++ z = b ++ } ++ if(x < 0) { ++ return -1 ++ } ++ key[0] = x ++ key[1] = y ++ key[2] = z ++ return bsearch.eq(this.cells, key, compareCell) + } ++})() + +- for (var j = m - 1; j >= 0; j--) { +- var qj = a.words[b.length + j] * 0x4000000 + a.words[b.length + j - 1]; ++function indexCells(triangulation, infinity) { ++ //First get cells and canonicalize ++ var cells = triangulation.cells() ++ var nc = cells.length ++ for(var i=0; i this.length || this.cmp(num) < 0) +- return { div: new BN(0), mod: this }; ++ while(active.length > 0 || next.length > 0) { ++ while(active.length > 0) { ++ var t = active.pop() ++ if(flags[t] === -side) { ++ continue ++ } ++ flags[t] = side ++ var c = cells[t] ++ for(var j=0; j<3; ++j) { ++ var f = neighbor[3*t+j] ++ if(f >= 0 && flags[f] === 0) { ++ if(constraint[3*t+j]) { ++ next.push(f) ++ } else { ++ active.push(f) ++ flags[f] = side ++ } ++ } ++ } ++ } + +- // Very short reduction +- if (num.length === 1) { +- if (mode === 'div') +- return { div: this.divn(num.words[0]), mod: null }; +- else if (mode === 'mod') +- return { div: null, mod: new BN(this.modn(num.words[0])) }; +- return { +- div: this.divn(num.words[0]), +- mod: new BN(this.modn(num.words[0])) +- }; ++ //Swap arrays and loop ++ var tmp = next ++ next = active ++ active = tmp ++ next.length = 0 ++ side = -side + } + +- return this._wordDiv(num, mode); +-}; +- +-// Find `this` / `num` +-BN.prototype.div = function div(num) { +- return this.divmod(num, 'div').div; +-}; +- +-// Find `this` % `num` +-BN.prototype.mod = function mod(num) { +- return this.divmod(num, 'mod').mod; +-}; ++ var result = filterCells(cells, flags, target) ++ if(infinity) { ++ return result.concat(index.boundary) ++ } ++ return result ++} + +-// Find Round(`this` / `num`) +-BN.prototype.divRound = function divRound(num) { +- var dm = this.divmod(num); ++},{"binary-search-bounds":53}],51:[function(require,module,exports){ ++'use strict' + +- // Fast case - exact division +- if (dm.mod.cmpn(0) === 0) +- return dm.div; ++var bsearch = require('binary-search-bounds') ++var orient = require('robust-orientation')[3] + +- var mod = dm.div.sign ? dm.mod.isub(num) : dm.mod; ++var EVENT_POINT = 0 ++var EVENT_END = 1 ++var EVENT_START = 2 + +- var half = num.shrn(1); +- var r2 = num.andln(1); +- var cmp = mod.cmp(half); ++module.exports = monotoneTriangulate + +- // Round down +- if (cmp < 0 || r2 === 1 && cmp === 0) +- return dm.div; ++//A partial convex hull fragment, made of two unimonotone polygons ++function PartialHull(a, b, idx, lowerIds, upperIds) { ++ this.a = a ++ this.b = b ++ this.idx = idx ++ this.lowerIds = lowerIds ++ this.upperIds = upperIds ++} + +- // Round up +- return dm.div.sign ? dm.div.isubn(1) : dm.div.iaddn(1); +-}; ++//An event in the sweep line procedure ++function Event(a, b, type, idx) { ++ this.a = a ++ this.b = b ++ this.type = type ++ this.idx = idx ++} + +-BN.prototype.modn = function modn(num) { +- assert(num <= 0x3ffffff); +- var p = (1 << 26) % num; ++//This is used to compare events for the sweep line procedure ++// Points are: ++// 1. sorted lexicographically ++// 2. sorted by type (point < end < start) ++// 3. segments sorted by winding order ++// 4. sorted by index ++function compareEvent(a, b) { ++ var d = ++ (a.a[0] - b.a[0]) || ++ (a.a[1] - b.a[1]) || ++ (a.type - b.type) ++ if(d) { return d } ++ if(a.type !== EVENT_POINT) { ++ d = orient(a.a, a.b, b.b) ++ if(d) { return d } ++ } ++ return a.idx - b.idx ++} + +- var acc = 0; +- for (var i = this.length - 1; i >= 0; i--) +- acc = (p * acc + this.words[i]) % num; ++function testPoint(hull, p) { ++ return orient(hull.a, hull.b, p) ++} + +- return acc; +-}; ++function addPoint(cells, hulls, points, p, idx) { ++ var lo = bsearch.lt(hulls, p, testPoint) ++ var hi = bsearch.gt(hulls, p, testPoint) ++ for(var i=lo; i 1 && orient( ++ points[lowerIds[m-2]], ++ points[lowerIds[m-1]], ++ p) > 0) { ++ cells.push( ++ [lowerIds[m-1], ++ lowerIds[m-2], ++ idx]) ++ m -= 1 ++ } ++ lowerIds.length = m ++ lowerIds.push(idx) + +- var carry = 0; +- for (var i = this.length - 1; i >= 0; i--) { +- var w = this.words[i] + carry * 0x4000000; +- this.words[i] = (w / num) | 0; +- carry = w % num; ++ //Insert p into upper hull ++ var upperIds = hull.upperIds ++ var m = upperIds.length ++ while(m > 1 && orient( ++ points[upperIds[m-2]], ++ points[upperIds[m-1]], ++ p) < 0) { ++ cells.push( ++ [upperIds[m-2], ++ upperIds[m-1], ++ idx]) ++ m -= 1 ++ } ++ upperIds.length = m ++ upperIds.push(idx) + } ++} + +- return this.strip(); +-}; ++function findSplit(hull, edge) { ++ var d ++ if(hull.a[0] < edge.a[0]) { ++ d = orient(hull.a, hull.b, edge.a) ++ } else { ++ d = orient(edge.b, edge.a, hull.a) ++ } ++ if(d) { return d } ++ if(edge.b[0] < hull.b[0]) { ++ d = orient(hull.a, hull.b, edge.b) ++ } else { ++ d = orient(edge.b, edge.a, hull.b) ++ } ++ return d || hull.idx - edge.idx ++} + +-BN.prototype.divn = function divn(num) { +- return this.clone().idivn(num); +-}; ++function splitHulls(hulls, points, event) { ++ var splitIdx = bsearch.le(hulls, event, findSplit) ++ var hull = hulls[splitIdx] ++ var upperIds = hull.upperIds ++ var x = upperIds[upperIds.length-1] ++ hull.upperIds = [x] ++ hulls.splice(splitIdx+1, 0, ++ new PartialHull(event.a, event.b, event.idx, [x], upperIds)) ++} + +-BN.prototype.egcd = function egcd(p) { +- assert(!p.sign); +- assert(p.cmpn(0) !== 0); + +- var x = this; +- var y = p.clone(); ++function mergeHulls(hulls, points, event) { ++ //Swap pointers for merge search ++ var tmp = event.a ++ event.a = event.b ++ event.b = tmp ++ var mergeIdx = bsearch.eq(hulls, event, findSplit) ++ var upper = hulls[mergeIdx] ++ var lower = hulls[mergeIdx-1] ++ lower.upperIds = upper.upperIds ++ hulls.splice(mergeIdx, 1) ++} + +- if (x.sign) +- x = x.mod(p); +- else +- x = x.clone(); + +- // A * x + B * y = x +- var A = new BN(1); +- var B = new BN(0); ++function monotoneTriangulate(points, edges) { + +- // C * x + D * y = y +- var C = new BN(0); +- var D = new BN(1); ++ var numPoints = points.length ++ var numEdges = edges.length + +- var g = 0; ++ var events = [] + +- while (x.isEven() && y.isEven()) { +- x.ishrn(1); +- y.ishrn(1); +- ++g; ++ //Create point events ++ for(var i=0; i b[0]) { ++ events.push( ++ new Event(b, a, EVENT_START, i), ++ new Event(a, b, EVENT_END, i)) + } ++ } + +- while (y.isEven()) { +- y.ishrn(1); +- if (C.isEven() && D.isEven()) { +- C.ishrn(1); +- D.ishrn(1); +- } else { +- C.iadd(yp).ishrn(1); +- D.isub(xp).ishrn(1); +- } +- } ++ //Sort events ++ events.sort(compareEvent) + +- if (x.cmp(y) >= 0) { +- x.isub(y); +- A.isub(C); +- B.isub(D); ++ //Initialize hull ++ var minX = events[0].a[0] - (1 + Math.abs(events[0].a[0])) * Math.pow(2, -52) ++ var hull = [ new PartialHull([minX, 1], [minX, 0], -1, [], [], [], []) ] ++ ++ //Process events in order ++ var cells = [] ++ for(var i=0, numEvents=events.length; i 0 && b.cmpn(1) > 0) { +- while (a.isEven()) { +- a.ishrn(1); +- if (x1.isEven()) +- x1.ishrn(1); +- else +- x1.iadd(delta).ishrn(1); +- } +- while (b.isEven()) { +- b.ishrn(1); +- if (x2.isEven()) +- x2.ishrn(1); +- else +- x2.iadd(delta).ishrn(1); +- } +- if (a.cmp(b) >= 0) { +- a.isub(b); +- x1.isub(x2); +- } else { +- b.isub(a); +- x2.isub(x1); ++function removePair(list, j, k) { ++ for(var i=1, n=list.length; i= 0 ++ } ++})() + +- var a = this.clone(); +- var b = num.clone(); +- a.sign = false; +- b.sign = false; ++proto.removeTriangle = function(i, j, k) { ++ var stars = this.stars ++ removePair(stars[i], j, k) ++ removePair(stars[j], k, i) ++ removePair(stars[k], i, j) ++} + +- // Remove common factor of two +- for (var shift = 0; a.isEven() && b.isEven(); shift++) { +- a.ishrn(1); +- b.ishrn(1); ++proto.addTriangle = function(i, j, k) { ++ var stars = this.stars ++ stars[i].push(j, k) ++ stars[j].push(k, i) ++ stars[k].push(i, j) ++} ++ ++proto.opposite = function(j, i) { ++ var list = this.stars[i] ++ for(var k=1, n=list.length; k>>1,x=a[m]"] ++ if(earlyOut) { ++ if(predicate.indexOf("c") < 0) { ++ code.push(";if(x===y){return m}else if(x<=y){") ++ } else { ++ code.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){") ++ } ++ } else { ++ code.push(";if(", predicate, "){i=m;") ++ } ++ if(reversed) { ++ code.push("l=m+1}else{h=m-1}") ++ } else { ++ code.push("h=m-1}else{l=m+1}") ++ } ++ code.push("}") ++ if(earlyOut) { ++ code.push("return -1};") ++ } else { ++ code.push("return i};") ++ } ++ return code.join("") ++} + +-BN.prototype.isOdd = function isOdd() { +- return (this.words[0] & 1) === 1; +-}; ++function compileBoundsSearch(predicate, reversed, suffix, earlyOut) { ++ var result = new Function([ ++ compileSearch("A", "x" + predicate + "y", reversed, ["y"], earlyOut), ++ compileSearch("P", "c(x,y)" + predicate + "0", reversed, ["y", "c"], earlyOut), ++"function dispatchBsearch", suffix, "(a,y,c,l,h){\ ++if(typeof(c)==='function'){\ ++return P(a,(l===void 0)?0:l|0,(h===void 0)?a.length-1:h|0,y,c)\ ++}else{\ ++return A(a,(c===void 0)?0:c|0,(l===void 0)?a.length-1:l|0,y)\ ++}}\ ++return dispatchBsearch", suffix].join("")) ++ return result() ++} + +-// And first word and num +-BN.prototype.andln = function andln(num) { +- return this.words[0] & num; +-}; ++module.exports = { ++ ge: compileBoundsSearch(">=", false, "GE"), ++ gt: compileBoundsSearch(">", false, "GT"), ++ lt: compileBoundsSearch("<", true, "LT"), ++ le: compileBoundsSearch("<=", true, "LE"), ++ eq: compileBoundsSearch("-", true, "EQ", true) ++} + +-// Increment at the bit position in-line +-BN.prototype.bincn = function bincn(bit) { +- assert(typeof bit === 'number'); +- var r = bit % 26; +- var s = (bit - r) / 26; +- var q = 1 << r; ++},{}],54:[function(require,module,exports){ ++'use strict' + +- // Fast case: bit is much higher than all existing words +- if (this.length <= s) { +- for (var i = this.length; i < s + 1; i++) +- this.words[i] = 0; +- this.words[s] |= q; +- this.length = s + 1; +- return this; +- } ++module.exports = orientation + +- // Add bit and propagate, if needed +- var carry = q; +- for (var i = s; carry !== 0 && i < this.length; i++) { +- var w = this.words[i]; +- w += carry; +- carry = w >>> 26; +- w &= 0x3ffffff; +- this.words[i] = w; +- } +- if (carry !== 0) { +- this.words[i] = carry; +- this.length++; ++function orientation(s) { ++ var p = 1 ++ for(var i=1; i 1) { +- res = 1; +- } else { +- var w = this.words[0]; +- res = w === num ? 0 : w < num ? -1 : 1; ++function dot(a, b) { ++ var s = 0.0 ++ var d = a.length ++ for(var i=0; i `num` +-// 0 - if `this` == `num` +-// -1 - if `this` < `num` +-BN.prototype.cmp = function cmp(num) { +- if (this.sign && !num.sign) +- return -1; +- else if (!this.sign && num.sign) +- return 1; ++function barycentricCircumcenter(points) { ++ var N = points.length ++ if(N === 0) { ++ return [] ++ } ++ ++ var D = points[0].length ++ var A = dup([points.length+1, points.length+1], 1.0) ++ var b = dup([points.length+1], 1.0) ++ A[N][N] = 0.0 ++ for(var i=0; i num.length) +- return 1; +- else if (this.length < num.length) +- return -1; ++ var y = new Array(N) ++ for(var i=0; i= 0; i--) { +- var a = this.words[i]; +- var b = num.words[i]; ++ return y ++} + +- if (a === b) +- continue; +- if (a < b) +- res = -1; +- else if (a > b) +- res = 1; +- break; ++function circumcenter(points) { ++ if(points.length === 0) { ++ return [] + } +- return res; +-}; +- +-// +-// A reduce context, could be using montgomery or something better, depending +-// on the `m` itself. +-// +-BN.red = function red(num) { +- return new Red(num); +-}; ++ var D = points[0].length ++ var result = dup([D]) ++ var weights = barycentricCircumcenter(points) ++ for(var i=0; i 0) { ++ return [nextafter(f, -Infinity), f] ++ } else { ++ return [f, f] ++ } ++} + +-BN.prototype.redISub = function redISub(num) { +- assert(this.red, 'redISub works only with red numbers'); +- return this.red.isub(this, num); +-}; ++//Convert a list of edges in a pslg to bounding boxes ++function boundEdges(points, edges) { ++ var bounds = new Array(edges.length) ++ for(var i=0; i= floatPoints.length) { ++ return ratPoints[idx-floatPoints.length] ++ } ++ var p = floatPoints[idx] ++ return [ rat(p[0]), rat(p[1]) ] ++ } ++ junctions.sort(function(a, b) { ++ if(a[0] !== b[0]) { ++ return a[0] - b[0] ++ } ++ var u = getPoint(a[1]) ++ var v = getPoint(b[1]) ++ return ratCmp(u[0], v[0]) || ratCmp(u[1], v[1]) ++ }) + +-// Prime numbers with efficient reduction +-var primes = { +- k256: null, +- p224: null, +- p192: null, +- p25519: null +-}; ++ //Split edges along junctions ++ for(var i=junctions.length-1; i>=0; --i) { ++ var junction = junctions[i] ++ var e = junction[0] + +-// Pseudo-Mersenne prime +-function MPrime(name, p) { +- // P = 2 ^ N - K +- this.name = name; +- this.p = new BN(p, 16); +- this.n = this.p.bitLength(); +- this.k = new BN(1).ishln(this.n).isub(this.p); ++ var edge = edges[e] ++ var s = edge[0] ++ var t = edge[1] + +- this.tmp = this._tmp(); +-} ++ //Check if edge is not lexicographically sorted ++ var a = floatPoints[s] ++ var b = floatPoints[t] ++ if(((a[0] - b[0]) || (a[1] - b[1])) < 0) { ++ var tmp = s ++ s = t ++ t = tmp ++ } + +-MPrime.prototype._tmp = function _tmp() { +- var tmp = new BN(null); +- tmp.words = new Array(Math.ceil(this.n / 13)); +- return tmp; +-}; ++ //Split leading edge ++ edge[0] = s ++ var last = edge[1] = junction[1] + +-MPrime.prototype.ireduce = function ireduce(num) { +- // Assumes that `num` is less than `P^2` +- // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P) +- var r = num; +- var rlen; ++ //If we are grouping edges by color, remember to track data ++ var color ++ if(useColor) { ++ color = edge[2] ++ } + +- do { +- this.split(r, this.tmp); +- r = this.imulK(r); +- r = r.iadd(this.tmp); +- rlen = r.bitLength(); +- } while (rlen > this.n); ++ //Split other edges ++ while(i > 0 && junctions[i-1][0] === e) { ++ var junction = junctions[--i] ++ var next = junction[1] ++ if(useColor) { ++ edges.push([last, next, color]) ++ } else { ++ edges.push([last, next]) ++ } ++ last = next ++ } + +- var cmp = rlen < this.n ? -1 : r.ucmp(this.p); +- if (cmp === 0) { +- r.words[0] = 0; +- r.length = 1; +- } else if (cmp > 0) { +- r.isub(this.p); +- } else { +- r.strip(); ++ //Add final edge ++ if(useColor) { ++ edges.push([last, t, color]) ++ } else { ++ edges.push([last, t]) ++ } + } + +- return r; +-}; +- +-MPrime.prototype.split = function split(input, out) { +- input.ishrn(this.n, 0, out); +-}; +- +-MPrime.prototype.imulK = function imulK(num) { +- return num.imul(this.k); +-}; +- +-function K256() { +- MPrime.call( +- this, +- 'k256', +- 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f'); ++ //Return constructed rational points ++ return ratPoints + } +-inherits(K256, MPrime); +- +-K256.prototype.split = function split(input, output) { +- // 256 = 9 * 26 + 22 +- var mask = 0x3fffff; + +- var outLen = Math.min(input.length, 9); +- for (var i = 0; i < outLen; i++) +- output.words[i] = input.words[i]; +- output.length = outLen; ++//Merge overlapping points ++function dedupPoints(floatPoints, ratPoints, floatBounds) { ++ var numPoints = floatPoints.length + ratPoints.length ++ var uf = new UnionFind(numPoints) + +- if (input.length <= 9) { +- input.words[0] = 0; +- input.length = 1; +- return; ++ //Compute rational bounds ++ var bounds = floatBounds ++ for(var i=0; i>> 22); +- prev = next; ++ //Call find on each point to get a relabeling ++ var ptr = 0 ++ var noDupes = true ++ var labels = new Array(numPoints) ++ for(var i=0; i>> 22; +- input.length -= 9; +-}; +- +-K256.prototype.imulK = function imulK(num) { +- // K = 0x1000003d1 = [ 0x40, 0x3d1 ] +- num.words[num.length] = 0; +- num.words[num.length + 1] = 0; +- num.length += 2; +- +- // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390 +- var hi; +- var lo = 0; +- for (var i = 0; i < num.length; i++) { +- var w = num.words[i]; +- hi = w * 0x40; +- lo += w * 0x3d1; +- hi += (lo / 0x4000000) | 0; +- lo &= 0x3ffffff; +- +- num.words[i] = lo; ++ floatPoints.length = ptr + +- lo = hi; ++ //If no duplicates, return null to signal termination ++ if(noDupes) { ++ return null + } + +- // Fast length reduction +- if (num.words[num.length - 1] === 0) { +- num.length--; +- if (num.words[num.length - 1] === 0) +- num.length--; ++ //Do a second pass to fix up missing labels ++ for(var i=0; i b[2]) { ++ return 1 ++ } ++ return 0 + } +-inherits(P192, MPrime); + +-function P25519() { +- // 2 ^ 255 - 19 +- MPrime.call( +- this, +- '25519', +- '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed'); ++//Remove duplicate edge labels ++function dedupEdges(edges, labels, useColor) { ++ if(edges.length === 0) { ++ return ++ } ++ if(labels) { ++ for(var i=0; i>>= 26; ++//Repeat until convergence ++function snapRound(points, edges, useColor) { + +- num.words[i] = lo; +- carry = hi; +- } +- if (carry !== 0) +- num.words[num.length++] = carry; +- return num; +-}; ++ // 1. find edge crossings ++ var edgeBounds = boundEdges(points, edges) ++ var crossings = getCrossings(points, edges, edgeBounds) + +-// Exported mostly for testing purposes, use plain name instead +-BN._prime = function prime(name) { +- // Cached version of prime +- if (primes[name]) +- return primes[name]; ++ // 2. find t-junctions ++ var vertBounds = boundPoints(points) ++ var tjunctions = getTJunctions(points, edges, edgeBounds, vertBounds) + +- var prime; +- if (name === 'k256') +- prime = new K256(); +- else if (name === 'p224') +- prime = new P224(); +- else if (name === 'p192') +- prime = new P192(); +- else if (name === 'p25519') +- prime = new P25519(); +- else +- throw new Error('Unknown prime ' + name); +- primes[name] = prime; ++ // 3. cut edges, construct rational points ++ var ratPoints = cutEdges(points, edges, crossings, tjunctions, useColor) + +- return prime; +-}; ++ // 4. dedupe verts ++ var labels = dedupPoints(points, ratPoints, vertBounds) + +-// +-// Base reduction engine +-// +-function Red(m) { +- if (typeof m === 'string') { +- var prime = BN._prime(m); +- this.m = prime.p; +- this.prime = prime; +- } else { +- this.m = m; +- this.prime = null; ++ // 6. dedupe edges ++ dedupEdges(edges, labels, useColor) ++ ++ // 5. check termination ++ if(!labels) { ++ return (crossings.length > 0 || tjunctions.length > 0) + } ++ ++ // More iterations necessary ++ return true + } + +-Red.prototype._verify1 = function _verify1(a) { +- assert(!a.sign, 'red works only with positives'); +- assert(a.red, 'red works only with red numbers'); +-}; ++//Main loop, runs PSLG clean up until completion ++function cleanPSLG(points, edges, colors) { ++ var modified = false + +-Red.prototype._verify2 = function _verify2(a, b) { +- assert(!a.sign && !b.sign, 'red works only with positives'); +- assert(a.red && a.red === b.red, +- 'red works only with red numbers'); +-}; ++ //If using colors, augment edges with color data ++ var prevEdges ++ if(colors) { ++ prevEdges = edges ++ var augEdges = new Array(edges.length) ++ for(var i=0; i= 0) +- res.isub(this.m); +- return res._forceRed(this); +-}; ++},{"./lib/rat-seg-intersect":58,"big-rat":21,"big-rat/cmp":19,"big-rat/to-float":33,"box-intersect":38,"compare-cell":63,"nextafter":192,"rat-vec":208,"robust-segment-intersect":222,"union-find":247}],58:[function(require,module,exports){ ++'use strict' + +-Red.prototype.iadd = function iadd(a, b) { +- this._verify2(a, b); ++//TODO: Move this to a separate module + +- var res = a.iadd(b); +- if (res.cmp(this.m) >= 0) +- res.isub(this.m); +- return res; +-}; ++module.exports = solveIntersection + +-Red.prototype.sub = function sub(a, b) { +- this._verify2(a, b); ++var ratMul = require('big-rat/mul') ++var ratDiv = require('big-rat/div') ++var ratSub = require('big-rat/sub') ++var ratSign = require('big-rat/sign') ++var rvSub = require('rat-vec/sub') ++var rvAdd = require('rat-vec/add') ++var rvMuls = require('rat-vec/muls') + +- var res = a.sub(b); +- if (res.cmpn(0) < 0) +- res.iadd(this.m); +- return res._forceRed(this); +-}; ++var toFloat = require('big-rat/to-float') + +-Red.prototype.isub = function isub(a, b) { +- this._verify2(a, b); ++function ratPerp(a, b) { ++ return ratSub(ratMul(a[0], b[1]), ratMul(a[1], b[0])) ++} + +- var res = a.isub(b); +- if (res.cmpn(0) < 0) +- res.iadd(this.m); +- return res; +-}; ++//Solve for intersection ++// x = a + t (b-a) ++// (x - c) ^ (d-c) = 0 ++// (t * (b-a) + (a-c) ) ^ (d-c) = 0 ++// t * (b-a)^(d-c) = (d-c)^(a-c) ++// t = (d-c)^(a-c) / (b-a)^(d-c) + +-Red.prototype.shl = function shl(a, num) { +- this._verify1(a); +- return this.imod(a.shln(num)); +-}; ++function solveIntersection(a, b, c, d) { ++ var ba = rvSub(b, a) ++ var dc = rvSub(d, c) + +-Red.prototype.imul = function imul(a, b) { +- this._verify2(a, b); +- return this.imod(a.imul(b)); +-}; ++ var baXdc = ratPerp(ba, dc) + +-Red.prototype.mul = function mul(a, b) { +- this._verify2(a, b); +- return this.imod(a.mul(b)); +-}; ++ if(ratSign(baXdc) === 0) { ++ return null ++ } + +-Red.prototype.isqr = function isqr(a) { +- return this.imul(a, a); +-}; ++ var ac = rvSub(a, c) ++ var dcXac = ratPerp(dc, ac) + +-Red.prototype.sqr = function sqr(a) { +- return this.mul(a, a); +-}; ++ var t = ratDiv(dcXac, baXdc) + +-Red.prototype.sqrt = function sqrt(a) { +- if (a.cmpn(0) === 0) +- return a.clone(); ++ return rvAdd(a, rvMuls(ba, t)) ++} + +- var mod3 = this.m.andln(3); +- assert(mod3 % 2 === 1); +- +- // Fast case +- if (mod3 === 3) { +- var pow = this.m.add(new BN(1)).ishrn(2); +- var r = this.pow(a, pow); +- return r; +- } ++},{"big-rat/div":20,"big-rat/mul":30,"big-rat/sign":31,"big-rat/sub":32,"big-rat/to-float":33,"rat-vec/add":207,"rat-vec/muls":209,"rat-vec/sub":210}],59:[function(require,module,exports){ ++(function (Buffer){ ++var clone = (function() { ++'use strict'; + +- // Tonelli-Shanks algorithm (Totally unoptimized and slow) +- // +- // Find Q and S, that Q * 2 ^ S = (P - 1) +- var q = this.m.subn(1); +- var s = 0; +- while (q.cmpn(0) !== 0 && q.andln(1) === 0) { +- s++; +- q.ishrn(1); ++/** ++ * Clones (copies) an Object using deep copying. ++ * ++ * This function supports circular references by default, but if you are certain ++ * there are no circular references in your object, you can save some CPU time ++ * by calling clone(obj, false). ++ * ++ * Caution: if `circular` is false and `parent` contains circular references, ++ * your program may enter an infinite loop and crash. ++ * ++ * @param `parent` - the object to be cloned ++ * @param `circular` - set to true if the object to be cloned may contain ++ * circular references. (optional - true by default) ++ * @param `depth` - set to a number if the object is only to be cloned to ++ * a particular depth. (optional - defaults to Infinity) ++ * @param `prototype` - sets the prototype to be used when cloning an object. ++ * (optional - defaults to parent prototype). ++*/ ++function clone(parent, circular, depth, prototype) { ++ var filter; ++ if (typeof circular === 'object') { ++ depth = circular.depth; ++ prototype = circular.prototype; ++ filter = circular.filter; ++ circular = circular.circular + } +- assert(q.cmpn(0) !== 0); +- +- var one = new BN(1).toRed(this); +- var nOne = one.redNeg(); ++ // maintain two arrays for circular references, where corresponding parents ++ // and children have the same index ++ var allParents = []; ++ var allChildren = []; + +- // Find quadratic non-residue +- // NOTE: Max is such because of generalized Riemann hypothesis. +- var lpow = this.m.subn(1).ishrn(1); +- var z = this.m.bitLength(); +- z = new BN(2 * z * z).toRed(this); +- while (this.pow(z, lpow).cmp(nOne) !== 0) +- z.redIAdd(nOne); ++ var useBuffer = typeof Buffer != 'undefined'; + +- var c = this.pow(z, q); +- var r = this.pow(a, q.addn(1).ishrn(1)); +- var t = this.pow(a, q); +- var m = s; +- while (t.cmp(one) !== 0) { +- var tmp = t; +- for (var i = 0; tmp.cmp(one) !== 0; i++) +- tmp = tmp.redSqr(); +- assert(i < m); +- var b = this.pow(c, new BN(1).ishln(m - i - 1)); ++ if (typeof circular == 'undefined') ++ circular = true; + +- r = r.redMul(b); +- c = b.redSqr(); +- t = t.redMul(c); +- m = i; +- } ++ if (typeof depth == 'undefined') ++ depth = Infinity; + +- return r; +-}; ++ // recurse this function so we don't reset allParents and allChildren ++ function _clone(parent, depth) { ++ // cloning null always returns null ++ if (parent === null) ++ return null; + +-Red.prototype.invm = function invm(a) { +- var inv = a._invmp(this.m); +- if (inv.sign) { +- inv.sign = false; +- return this.imod(inv).redNeg(); +- } else { +- return this.imod(inv); +- } +-}; ++ if (depth == 0) ++ return parent; + +-Red.prototype.pow = function pow(a, num) { +- var w = []; ++ var child; ++ var proto; ++ if (typeof parent != 'object') { ++ return parent; ++ } + +- if (num.cmpn(0) === 0) +- return new BN(1); ++ if (clone.__isArray(parent)) { ++ child = []; ++ } else if (clone.__isRegExp(parent)) { ++ child = new RegExp(parent.source, __getRegExpFlags(parent)); ++ if (parent.lastIndex) child.lastIndex = parent.lastIndex; ++ } else if (clone.__isDate(parent)) { ++ child = new Date(parent.getTime()); ++ } else if (useBuffer && Buffer.isBuffer(parent)) { ++ child = new Buffer(parent.length); ++ parent.copy(child); ++ return child; ++ } else { ++ if (typeof prototype == 'undefined') { ++ proto = Object.getPrototypeOf(parent); ++ child = Object.create(proto); ++ } ++ else { ++ child = Object.create(prototype); ++ proto = prototype; ++ } ++ } + +- var q = num.clone(); ++ if (circular) { ++ var index = allParents.indexOf(parent); + +- while (q.cmpn(0) !== 0) { +- w.push(q.andln(1)); +- q.ishrn(1); +- } ++ if (index != -1) { ++ return allChildren[index]; ++ } ++ allParents.push(parent); ++ allChildren.push(child); ++ } + +- // Skip leading zeroes +- var res = a; +- for (var i = 0; i < w.length; i++, res = this.sqr(res)) +- if (w[i] !== 0) +- break; ++ for (var i in parent) { ++ var attrs; ++ if (proto) { ++ attrs = Object.getOwnPropertyDescriptor(proto, i); ++ } + +- if (++i < w.length) { +- for (var q = this.sqr(res); i < w.length; i++, q = this.sqr(q)) { +- if (w[i] === 0) ++ if (attrs && attrs.set == null) { + continue; +- res = this.mul(res, q); ++ } ++ child[i] = _clone(parent[i], depth - 1); + } ++ ++ return child; + } + +- return res; ++ return _clone(parent, depth); ++} ++ ++/** ++ * Simple flat clone using prototype, accepts only objects, usefull for property ++ * override on FLAT configuration object (no nested props). ++ * ++ * USE WITH CAUTION! This may not behave as you wish if you do not know how this ++ * works. ++ */ ++clone.clonePrototype = function clonePrototype(parent) { ++ if (parent === null) ++ return null; ++ ++ var c = function () {}; ++ c.prototype = parent; ++ return new c(); + }; + +-Red.prototype.convertTo = function convertTo(num) { +- var r = num.mod(this.m); +- if (r === num) +- return r.clone(); +- else +- return r; ++// private utility functions ++ ++function __objToStr(o) { ++ return Object.prototype.toString.call(o); + }; ++clone.__objToStr = __objToStr; + +-Red.prototype.convertFrom = function convertFrom(num) { +- var res = num.clone(); +- res.red = null; +- return res; ++function __isDate(o) { ++ return typeof o === 'object' && __objToStr(o) === '[object Date]'; + }; ++clone.__isDate = __isDate; + +-// +-// Montgomery method engine +-// ++function __isArray(o) { ++ return typeof o === 'object' && __objToStr(o) === '[object Array]'; ++}; ++clone.__isArray = __isArray; + +-BN.mont = function mont(num) { +- return new Mont(num); ++function __isRegExp(o) { ++ return typeof o === 'object' && __objToStr(o) === '[object RegExp]'; + }; ++clone.__isRegExp = __isRegExp; + +-function Mont(m) { +- Red.call(this, m); ++function __getRegExpFlags(re) { ++ var flags = ''; ++ if (re.global) flags += 'g'; ++ if (re.ignoreCase) flags += 'i'; ++ if (re.multiline) flags += 'm'; ++ return flags; ++}; ++clone.__getRegExpFlags = __getRegExpFlags; + +- this.shift = this.m.bitLength(); +- if (this.shift % 26 !== 0) +- this.shift += 26 - (this.shift % 26); +- this.r = new BN(1).ishln(this.shift); +- this.r2 = this.imod(this.r.sqr()); +- this.rinv = this.r._invmp(this.m); ++return clone; ++})(); + +- this.minv = this.rinv.mul(this.r).isubn(1).div(this.m); +- this.minv.sign = true; +- this.minv = this.minv.mod(this.r); ++if (typeof module === 'object' && module.exports) { ++ module.exports = clone; + } +-inherits(Mont, Red); + +-Mont.prototype.convertTo = function convertTo(num) { +- return this.imod(num.shln(this.shift)); +-}; ++}).call(this,require("buffer").Buffer) ++},{"buffer":45}],60:[function(require,module,exports){ ++module.exports={ ++ "jet":[{"index":0,"rgb":[0,0,131]},{"index":0.125,"rgb":[0,60,170]},{"index":0.375,"rgb":[5,255,255]},{"index":0.625,"rgb":[255,255,0]},{"index":0.875,"rgb":[250,0,0]},{"index":1,"rgb":[128,0,0]}], + +-Mont.prototype.convertFrom = function convertFrom(num) { +- var r = this.imod(num.mul(this.rinv)); +- r.red = null; +- return r; +-}; ++ "hsv":[{"index":0,"rgb":[255,0,0]},{"index":0.169,"rgb":[253,255,2]},{"index":0.173,"rgb":[247,255,2]},{"index":0.337,"rgb":[0,252,4]},{"index":0.341,"rgb":[0,252,10]},{"index":0.506,"rgb":[1,249,255]},{"index":0.671,"rgb":[2,0,253]},{"index":0.675,"rgb":[8,0,253]},{"index":0.839,"rgb":[255,0,251]},{"index":0.843,"rgb":[255,0,245]},{"index":1,"rgb":[255,0,6]}], + +-Mont.prototype.imul = function imul(a, b) { +- if (a.cmpn(0) === 0 || b.cmpn(0) === 0) { +- a.words[0] = 0; +- a.length = 1; +- return a; +- } ++ "hot":[{"index":0,"rgb":[0,0,0]},{"index":0.3,"rgb":[230,0,0]},{"index":0.6,"rgb":[255,210,0]},{"index":1,"rgb":[255,255,255]}], + +- var t = a.imul(b); +- var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); +- var u = t.isub(c).ishrn(this.shift); +- var res = u; +- if (u.cmp(this.m) >= 0) +- res = u.isub(this.m); +- else if (u.cmpn(0) < 0) +- res = u.iadd(this.m); ++ "cool":[{"index":0,"rgb":[0,255,255]},{"index":1,"rgb":[255,0,255]}], + +- return res._forceRed(this); +-}; ++ "spring":[{"index":0,"rgb":[255,0,255]},{"index":1,"rgb":[255,255,0]}], + +-Mont.prototype.mul = function mul(a, b) { +- if (a.cmpn(0) === 0 || b.cmpn(0) === 0) +- return new BN(0)._forceRed(this); ++ "summer":[{"index":0,"rgb":[0,128,102]},{"index":1,"rgb":[255,255,102]}], + +- var t = a.mul(b); +- var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); +- var u = t.isub(c).ishrn(this.shift); +- var res = u; +- if (u.cmp(this.m) >= 0) +- res = u.isub(this.m); +- else if (u.cmpn(0) < 0) +- res = u.iadd(this.m); ++ "autumn":[{"index":0,"rgb":[255,0,0]},{"index":1,"rgb":[255,255,0]}], + +- return res._forceRed(this); +-}; ++ "winter":[{"index":0,"rgb":[0,0,255]},{"index":1,"rgb":[0,255,128]}], + +-Mont.prototype.invm = function invm(a) { +- // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R +- var res = this.imod(a._invmp(this.m).mul(this.r2)); +- return res._forceRed(this); +-}; ++ "bone":[{"index":0,"rgb":[0,0,0]},{"index":0.376,"rgb":[84,84,116]},{"index":0.753,"rgb":[169,200,200]},{"index":1,"rgb":[255,255,255]}], + +-})(typeof module === 'undefined' || module, this); ++ "copper":[{"index":0,"rgb":[0,0,0]},{"index":0.804,"rgb":[255,160,102]},{"index":1,"rgb":[255,199,127]}], + +-},{}],68:[function(require,module,exports){ +-'use strict' ++ "greys":[{"index":0,"rgb":[0,0,0]},{"index":1,"rgb":[255,255,255]}], + +-var bnsign = require('./lib/bn-sign') ++ "yignbu":[{"index":0,"rgb":[8,29,88]},{"index":0.125,"rgb":[37,52,148]},{"index":0.25,"rgb":[34,94,168]},{"index":0.375,"rgb":[29,145,192]},{"index":0.5,"rgb":[65,182,196]},{"index":0.625,"rgb":[127,205,187]},{"index":0.75,"rgb":[199,233,180]},{"index":0.875,"rgb":[237,248,217]},{"index":1,"rgb":[255,255,217]}], + +-module.exports = sign ++ "greens":[{"index":0,"rgb":[0,68,27]},{"index":0.125,"rgb":[0,109,44]},{"index":0.25,"rgb":[35,139,69]},{"index":0.375,"rgb":[65,171,93]},{"index":0.5,"rgb":[116,196,118]},{"index":0.625,"rgb":[161,217,155]},{"index":0.75,"rgb":[199,233,192]},{"index":0.875,"rgb":[229,245,224]},{"index":1,"rgb":[247,252,245]}], + +-function sign(x) { +- return bnsign(x[0]) * bnsign(x[1]) +-} ++ "yiorrd":[{"index":0,"rgb":[128,0,38]},{"index":0.125,"rgb":[189,0,38]},{"index":0.25,"rgb":[227,26,28]},{"index":0.375,"rgb":[252,78,42]},{"index":0.5,"rgb":[253,141,60]},{"index":0.625,"rgb":[254,178,76]},{"index":0.75,"rgb":[254,217,118]},{"index":0.875,"rgb":[255,237,160]},{"index":1,"rgb":[255,255,204]}], + +-},{"./lib/bn-sign":59}],69:[function(require,module,exports){ +-'use strict' ++ "bluered":[{"index":0,"rgb":[0,0,255]},{"index":1,"rgb":[255,0,0]}], + +-var rationalize = require('./lib/rationalize') ++ "rdbu":[{"index":0,"rgb":[5,10,172]},{"index":0.35,"rgb":[106,137,247]},{"index":0.5,"rgb":[190,190,190]},{"index":0.6,"rgb":[220,170,132]},{"index":0.7,"rgb":[230,145,90]},{"index":1,"rgb":[178,10,28]}], + +-module.exports = sub ++ "picnic":[{"index":0,"rgb":[0,0,255]},{"index":0.1,"rgb":[51,153,255]},{"index":0.2,"rgb":[102,204,255]},{"index":0.3,"rgb":[153,204,255]},{"index":0.4,"rgb":[204,204,255]},{"index":0.5,"rgb":[255,255,255]},{"index":0.6,"rgb":[255,204,255]},{"index":0.7,"rgb":[255,153,255]},{"index":0.8,"rgb":[255,102,204]},{"index":0.9,"rgb":[255,102,102]},{"index":1,"rgb":[255,0,0]}], + +-function sub(a, b) { +- return rationalize(a[0].mul(b[1]).sub(a[1].mul(b[0])), a[1].mul(b[1])) +-} ++ "rainbow":[{"index":0,"rgb":[150,0,90]},{"index":0.125,"rgb":[0,0,200]},{"index":0.25,"rgb":[0,25,255]},{"index":0.375,"rgb":[0,152,255]},{"index":0.5,"rgb":[44,255,150]},{"index":0.625,"rgb":[151,255,0]},{"index":0.75,"rgb":[255,234,0]},{"index":0.875,"rgb":[255,111,0]},{"index":1,"rgb":[255,0,0]}], + +-},{"./lib/rationalize":64}],70:[function(require,module,exports){ +-'use strict' ++ "portland":[{"index":0,"rgb":[12,51,131]},{"index":0.25,"rgb":[10,136,186]},{"index":0.5,"rgb":[242,211,56]},{"index":0.75,"rgb":[242,143,56]},{"index":1,"rgb":[217,30,30]}], + +-var bn2num = require('./lib/bn-to-num') +-var ctz = require('./lib/ctz') ++ "blackbody":[{"index":0,"rgb":[0,0,0]},{"index":0.2,"rgb":[230,0,0]},{"index":0.4,"rgb":[230,210,0]},{"index":0.7,"rgb":[255,255,255]},{"index":1,"rgb":[160,200,255]}], + +-module.exports = roundRat ++ "earth":[{"index":0,"rgb":[0,0,130]},{"index":0.1,"rgb":[0,180,180]},{"index":0.2,"rgb":[40,210,40]},{"index":0.4,"rgb":[230,230,50]},{"index":0.6,"rgb":[120,70,20]},{"index":1,"rgb":[255,255,255]}], + +-//Round a rational to the closest float +-function roundRat(f) { +- var a = f[0] +- var b = f[1] +- if(a.cmpn(0) === 0) { +- return 0 +- } +- var h = a.divmod(b) +- var iv = h.div +- var x = bn2num(iv) +- var ir = h.mod +- if(ir.cmpn(0) === 0) { +- return x +- } +- if(x) { +- var s = ctz(x) + 4 +- var y = bn2num(ir.shln(s).divRound(b)) ++ "electric":[{"index":0,"rgb":[0,0,0]},{"index":0.15,"rgb":[30,0,100]},{"index":0.4,"rgb":[120,0,100]},{"index":0.6,"rgb":[160,90,0]},{"index":0.8,"rgb":[230,200,0]},{"index":1,"rgb":[255,250,220]}], + +- // flip the sign of y if x is negative +- if (x<0) { +- y = -y; +- } ++ "alpha": [{"index":0, "rgb": [255,255,255,0]},{"index":0, "rgb": [255,255,255,1]}], + +- return x + y * Math.pow(2, -s) +- } else { +- var ybits = b.bitLength() - ir.bitLength() + 53 +- var y = bn2num(ir.shln(ybits).divRound(b)) +- if(ybits < 1023) { +- return y * Math.pow(2, -ybits) +- } +- y *= Math.pow(2, -1023) +- return y * Math.pow(2, 1023-ybits) +- } +-} ++ "viridis": [{"index":0,"rgb":[68,1,84]},{"index":0.13,"rgb":[71,44,122]},{"index":0.25,"rgb":[59,81,139]},{"index":0.38,"rgb":[44,113,142]},{"index":0.5,"rgb":[33,144,141]},{"index":0.63,"rgb":[39,173,129]},{"index":0.75,"rgb":[92,200,99]},{"index":0.88,"rgb":[170,220,50]},{"index":1,"rgb":[253,231,37]}], + +-},{"./lib/bn-to-num":60,"./lib/ctz":61}],71:[function(require,module,exports){ +-'use strict' ++ "inferno": [{"index":0,"rgb":[0,0,4]},{"index":0.13,"rgb":[31,12,72]},{"index":0.25,"rgb":[85,15,109]},{"index":0.38,"rgb":[136,34,106]},{"index":0.5,"rgb":[186,54,85]},{"index":0.63,"rgb":[227,89,51]},{"index":0.75,"rgb":[249,140,10]},{"index":0.88,"rgb":[249,201,50]},{"index":1,"rgb":[252,255,164]}], + +-module.exports = boxIntersectWrapper ++ "magma": [{"index":0,"rgb":[0,0,4]},{"index":0.13,"rgb":[28,16,68]},{"index":0.25,"rgb":[79,18,123]},{"index":0.38,"rgb":[129,37,129]},{"index":0.5,"rgb":[181,54,122]},{"index":0.63,"rgb":[229,80,100]},{"index":0.75,"rgb":[251,135,97]},{"index":0.88,"rgb":[254,194,135]},{"index":1,"rgb":[252,253,191]}], + +-var pool = require('typedarray-pool') +-var sweep = require('./lib/sweep') +-var boxIntersectIter = require('./lib/intersect') ++ "plasma": [{"index":0,"rgb":[13,8,135]},{"index":0.13,"rgb":[75,3,161]},{"index":0.25,"rgb":[125,3,168]},{"index":0.38,"rgb":[168,34,150]},{"index":0.5,"rgb":[203,70,121]},{"index":0.63,"rgb":[229,107,93]},{"index":0.75,"rgb":[248,148,65]},{"index":0.88,"rgb":[253,195,40]},{"index":1,"rgb":[240,249,33]}], + +-function boxEmpty(d, box) { +- for(var j=0; j>>1 +- if(d <= 0) { +- return +- } ++ "cdom": [{"index":0,"rgb":[47,15,62]},{"index":0.13,"rgb":[87,23,86]},{"index":0.25,"rgb":[130,28,99]},{"index":0.38,"rgb":[171,41,96]},{"index":0.5,"rgb":[206,67,86]},{"index":0.63,"rgb":[230,106,84]},{"index":0.75,"rgb":[242,149,103]},{"index":0.88,"rgb":[249,193,135]},{"index":1,"rgb":[254,237,176]}], + +- var retval ++ "chlorophyll": [{"index":0,"rgb":[18,36,20]},{"index":0.13,"rgb":[25,63,41]},{"index":0.25,"rgb":[24,91,59]},{"index":0.38,"rgb":[13,119,72]},{"index":0.5,"rgb":[18,148,80]},{"index":0.63,"rgb":[80,173,89]},{"index":0.75,"rgb":[132,196,122]},{"index":0.88,"rgb":[175,221,162]},{"index":1,"rgb":[215,249,208]}], + +- //Convert red boxes +- var redList = pool.mallocDouble(2*d*n) +- var redIds = pool.mallocInt32(n) +- n = convertBoxes(red, d, redList, redIds) ++ "density": [{"index":0,"rgb":[54,14,36]},{"index":0.13,"rgb":[89,23,80]},{"index":0.25,"rgb":[110,45,132]},{"index":0.38,"rgb":[120,77,178]},{"index":0.5,"rgb":[120,113,213]},{"index":0.63,"rgb":[115,151,228]},{"index":0.75,"rgb":[134,185,227]},{"index":0.88,"rgb":[177,214,227]},{"index":1,"rgb":[230,241,241]}], + +- if(n > 0) { +- if(d === 1 && full) { +- //Special case: 1d complete +- sweep.init(n) +- retval = sweep.sweepComplete( +- d, visit, +- 0, n, redList, redIds, +- 0, n, redList, redIds) +- } else { ++ "freesurface-blue": [{"index":0,"rgb":[30,4,110]},{"index":0.13,"rgb":[47,14,176]},{"index":0.25,"rgb":[41,45,236]},{"index":0.38,"rgb":[25,99,212]},{"index":0.5,"rgb":[68,131,200]},{"index":0.63,"rgb":[114,156,197]},{"index":0.75,"rgb":[157,181,203]},{"index":0.88,"rgb":[200,208,216]},{"index":1,"rgb":[241,237,236]}], + +- //Convert blue boxes +- var blueList = pool.mallocDouble(2*d*m) +- var blueIds = pool.mallocInt32(m) +- m = convertBoxes(blue, d, blueList, blueIds) ++ "freesurface-red": [{"index":0,"rgb":[60,9,18]},{"index":0.13,"rgb":[100,17,27]},{"index":0.25,"rgb":[142,20,29]},{"index":0.38,"rgb":[177,43,27]},{"index":0.5,"rgb":[192,87,63]},{"index":0.63,"rgb":[205,125,105]},{"index":0.75,"rgb":[216,162,148]},{"index":0.88,"rgb":[227,199,193]},{"index":1,"rgb":[241,237,236]}], + +- if(m > 0) { +- sweep.init(n+m) ++ "oxygen": [{"index":0,"rgb":[64,5,5]},{"index":0.13,"rgb":[106,6,15]},{"index":0.25,"rgb":[144,26,7]},{"index":0.38,"rgb":[168,64,3]},{"index":0.5,"rgb":[188,100,4]},{"index":0.63,"rgb":[206,136,11]},{"index":0.75,"rgb":[220,174,25]},{"index":0.88,"rgb":[231,215,44]},{"index":1,"rgb":[248,254,105]}], + +- if(d === 1) { +- //Special case: 1d bipartite +- retval = sweep.sweepBipartite( +- d, visit, +- 0, n, redList, redIds, +- 0, m, blueList, blueIds) +- } else { +- //General case: d>1 +- retval = boxIntersectIter( +- d, visit, full, +- n, redList, redIds, +- m, blueList, blueIds) +- } ++ "par": [{"index":0,"rgb":[51,20,24]},{"index":0.13,"rgb":[90,32,35]},{"index":0.25,"rgb":[129,44,34]},{"index":0.38,"rgb":[159,68,25]},{"index":0.5,"rgb":[182,99,19]},{"index":0.63,"rgb":[199,134,22]},{"index":0.75,"rgb":[212,171,35]},{"index":0.88,"rgb":[221,210,54]},{"index":1,"rgb":[225,253,75]}], + +- pool.free(blueList) +- pool.free(blueIds) +- } +- } ++ "phase": [{"index":0,"rgb":[145,105,18]},{"index":0.13,"rgb":[184,71,38]},{"index":0.25,"rgb":[186,58,115]},{"index":0.38,"rgb":[160,71,185]},{"index":0.5,"rgb":[110,97,218]},{"index":0.63,"rgb":[50,123,164]},{"index":0.75,"rgb":[31,131,110]},{"index":0.88,"rgb":[77,129,34]},{"index":1,"rgb":[145,105,18]}], + +- pool.free(redList) +- pool.free(redIds) +- } ++ "salinity": [{"index":0,"rgb":[42,24,108]},{"index":0.13,"rgb":[33,50,162]},{"index":0.25,"rgb":[15,90,145]},{"index":0.38,"rgb":[40,118,137]},{"index":0.5,"rgb":[59,146,135]},{"index":0.63,"rgb":[79,175,126]},{"index":0.75,"rgb":[120,203,104]},{"index":0.88,"rgb":[193,221,100]},{"index":1,"rgb":[253,239,154]}], + +- return retval +-} ++ "temperature": [{"index":0,"rgb":[4,35,51]},{"index":0.13,"rgb":[23,51,122]},{"index":0.25,"rgb":[85,59,157]},{"index":0.38,"rgb":[129,79,143]},{"index":0.5,"rgb":[175,95,130]},{"index":0.63,"rgb":[222,112,101]},{"index":0.75,"rgb":[249,146,66]},{"index":0.88,"rgb":[249,196,65]},{"index":1,"rgb":[232,250,91]}], + ++ "turbidity": [{"index":0,"rgb":[34,31,27]},{"index":0.13,"rgb":[65,50,41]},{"index":0.25,"rgb":[98,69,52]},{"index":0.38,"rgb":[131,89,57]},{"index":0.5,"rgb":[161,112,59]},{"index":0.63,"rgb":[185,140,66]},{"index":0.75,"rgb":[202,174,88]},{"index":0.88,"rgb":[216,209,126]},{"index":1,"rgb":[233,246,171]}], + +-var RESULT ++ "velocity-blue": [{"index":0,"rgb":[17,32,64]},{"index":0.13,"rgb":[35,52,116]},{"index":0.25,"rgb":[29,81,156]},{"index":0.38,"rgb":[31,113,162]},{"index":0.5,"rgb":[50,144,169]},{"index":0.63,"rgb":[87,173,176]},{"index":0.75,"rgb":[149,196,189]},{"index":0.88,"rgb":[203,221,211]},{"index":1,"rgb":[254,251,230]}], + +-function appendItem(i,j) { +- RESULT.push([i,j]) +-} ++ "velocity-green": [{"index":0,"rgb":[23,35,19]},{"index":0.13,"rgb":[24,64,38]},{"index":0.25,"rgb":[11,95,45]},{"index":0.38,"rgb":[39,123,35]},{"index":0.5,"rgb":[95,146,12]},{"index":0.63,"rgb":[152,165,18]},{"index":0.75,"rgb":[201,186,69]},{"index":0.88,"rgb":[233,216,137]},{"index":1,"rgb":[255,253,205]}], + +-function intersectFullArray(x) { +- RESULT = [] +- boxIntersect(x, x, appendItem, true) +- return RESULT +-} ++ "cubehelix": [{"index":0,"rgb":[0,0,0]},{"index":0.07,"rgb":[22,5,59]},{"index":0.13,"rgb":[60,4,105]},{"index":0.2,"rgb":[109,1,135]},{"index":0.27,"rgb":[161,0,147]},{"index":0.33,"rgb":[210,2,142]},{"index":0.4,"rgb":[251,11,123]},{"index":0.47,"rgb":[255,29,97]},{"index":0.53,"rgb":[255,54,69]},{"index":0.6,"rgb":[255,85,46]},{"index":0.67,"rgb":[255,120,34]},{"index":0.73,"rgb":[255,157,37]},{"index":0.8,"rgb":[241,191,57]},{"index":0.87,"rgb":[224,220,93]},{"index":0.93,"rgb":[218,241,142]},{"index":1,"rgb":[227,253,198]}] ++}; + +-function intersectBipartiteArray(x, y) { +- RESULT = [] +- boxIntersect(x, y, appendItem, false) +- return RESULT +-} ++},{}],61:[function(require,module,exports){ ++/* ++ * Ben Postlethwaite ++ * January 2013 ++ * License MIT ++ */ ++'use strict'; + +-//User-friendly wrapper, handle full input and no-visitor cases +-function boxIntersectWrapper(arg0, arg1, arg2) { +- var result +- switch(arguments.length) { +- case 1: +- return intersectFullArray(arg0) +- case 2: +- if(typeof arg1 === 'function') { +- return boxIntersect(arg0, arg0, arg1, true) +- } else { +- return intersectBipartiteArray(arg0, arg1) +- } +- case 3: +- return boxIntersect(arg0, arg1, arg2, false) +- default: +- throw new Error('box-intersect: Invalid arguments') +- } +-} +-},{"./lib/intersect":73,"./lib/sweep":77,"typedarray-pool":242}],72:[function(require,module,exports){ +-'use strict' ++var at = require('arraytools'); ++var clone = require('clone'); ++var colorScale = require('./colorScales'); + +-var DIMENSION = 'd' +-var AXIS = 'ax' +-var VISIT = 'vv' +-var FLIP = 'fp' ++module.exports = createColormap; + +-var ELEM_SIZE = 'es' ++function createColormap (spec) { ++ /* ++ * Default Options ++ */ ++ var indicies, rgba, fromrgba, torgba, ++ nsteps, cmap, colormap, format, ++ nshades, colors, alpha, index, i, ++ r = [], ++ g = [], ++ b = [], ++ a = []; + +-var RED_START = 'rs' +-var RED_END = 're' +-var RED_BOXES = 'rb' +-var RED_INDEX = 'ri' +-var RED_PTR = 'rp' ++ if ( !at.isPlainObject(spec) ) spec = {}; + +-var BLUE_START = 'bs' +-var BLUE_END = 'be' +-var BLUE_BOXES = 'bb' +-var BLUE_INDEX = 'bi' +-var BLUE_PTR = 'bp' ++ nshades = spec.nshades || 72; ++ format = spec.format || 'hex'; + +-var RETVAL = 'rv' ++ colormap = spec.colormap; ++ if (!colormap) colormap = 'jet'; + +-var INNER_LABEL = 'Q' ++ if (typeof colormap === 'string') { ++ colormap = colormap.toLowerCase(); + +-var ARGS = [ +- DIMENSION, +- AXIS, +- VISIT, +- RED_START, +- RED_END, +- RED_BOXES, +- RED_INDEX, +- BLUE_START, +- BLUE_END, +- BLUE_BOXES, +- BLUE_INDEX +-] ++ if (!colorScale[colormap]) { ++ throw Error(colormap + ' not a supported colorscale'); ++ } + +-function generateBruteForce(redMajor, flip, full) { +- var funcName = 'bruteForce' + +- (redMajor ? 'Red' : 'Blue') + +- (flip ? 'Flip' : '') + +- (full ? 'Full' : '') ++ cmap = clone(colorScale[colormap]); + +- var code = ['function ', funcName, '(', ARGS.join(), '){', +- 'var ', ELEM_SIZE, '=2*', DIMENSION, ';'] ++ } else if (Array.isArray(colormap)) { ++ cmap = clone(colormap); + +- var redLoop = +- 'for(var i=' + RED_START + ',' + RED_PTR + '=' + ELEM_SIZE + '*' + RED_START + ';' + +- 'i<' + RED_END +';' + +- '++i,' + RED_PTR + '+=' + ELEM_SIZE + '){' + +- 'var x0=' + RED_BOXES + '[' + AXIS + '+' + RED_PTR + '],' + +- 'x1=' + RED_BOXES + '[' + AXIS + '+' + RED_PTR + '+' + DIMENSION + '],' + +- 'xi=' + RED_INDEX + '[i];' ++ } else { ++ throw Error('unsupported colormap option', colormap); ++ } + +- var blueLoop = +- 'for(var j=' + BLUE_START + ',' + BLUE_PTR + '=' + ELEM_SIZE + '*' + BLUE_START + ';' + +- 'j<' + BLUE_END + ';' + +- '++j,' + BLUE_PTR + '+=' + ELEM_SIZE + '){' + +- 'var y0=' + BLUE_BOXES + '[' + AXIS + '+' + BLUE_PTR + '],' + +- (full ? 'y1=' + BLUE_BOXES + '[' + AXIS + '+' + BLUE_PTR + '+' + DIMENSION + '],' : '') + +- 'yi=' + BLUE_INDEX + '[j];' ++ if (cmap.length > nshades) { ++ throw new Error( ++ colormap+' map requires nshades to be at least size '+cmap.length ++ ); ++ } + +- if(redMajor) { +- code.push(redLoop, INNER_LABEL, ':', blueLoop) +- } else { +- code.push(blueLoop, INNER_LABEL, ':', redLoop) +- } ++ if (!Array.isArray(spec.alpha)) { + +- if(full) { +- code.push('if(y11 to 0 -> n-1 ++ */ ++ indicies = cmap.map(function(c) { ++ return Math.round(c.index * nshades); ++ }); + +-function bruteForcePlanner(full) { +- var funcName = 'bruteForce' + (full ? 'Full' : 'Partial') +- var prefix = [] +- var fargs = ARGS.slice() +- if(!full) { +- fargs.splice(3, 0, FLIP) +- } ++ /* ++ * Add alpha channel to the map ++ */ ++ if (alpha[0] < 0) alpha[0] = 0; ++ if (alpha[1] < 0) alpha[0] = 0; ++ if (alpha[0] > 1) alpha[0] = 1; ++ if (alpha[1] > 1) alpha[0] = 1; + +- var code = ['function ' + funcName + '(' + fargs.join() + '){'] ++ for (i = 0; i < indicies.length; ++i) { ++ index = cmap[i].index; ++ rgba = cmap[i].rgb; + +- function invoke(redMajor, flip) { +- var res = generateBruteForce(redMajor, flip, full) +- prefix.push(res.code) +- code.push('return ' + res.name + '(' + ARGS.join() + ');') +- } ++ // if user supplies their own map use it ++ if (rgba.length === 4 && rgba[3] >= 0 && rgba[3] <= 1) continue; ++ rgba[3] = alpha[0] + (alpha[1] - alpha[0])*index; ++ } + +- code.push('if(' + RED_END + '-' + RED_START + '>' + +- BLUE_END + '-' + BLUE_START + '){') ++ /* ++ * map increasing linear values between indicies to ++ * linear steps in colorvalues ++ */ ++ for (i = 0; i < indicies.length-1; ++i) { ++ nsteps = indicies[i+1] - indicies[i]; ++ fromrgba = cmap[i].rgb; ++ torgba = cmap[i+1].rgb; ++ r = r.concat(at.linspace(fromrgba[0], torgba[0], nsteps ) ); ++ g = g.concat(at.linspace(fromrgba[1], torgba[1], nsteps ) ); ++ b = b.concat(at.linspace(fromrgba[2], torgba[2], nsteps ) ); ++ a = a.concat(at.linspace(fromrgba[3], torgba[3], nsteps ) ); ++ } + +- if(full) { +- invoke(true, false) +- code.push('}else{') +- invoke(false, false) +- } else { +- code.push('if(' + FLIP + '){') +- invoke(true, true) +- code.push('}else{') +- invoke(true, false) +- code.push('}}else{if(' + FLIP + '){') +- invoke(false, true) +- code.push('}else{') +- invoke(false, false) +- code.push('}') +- } +- code.push('}}return ' + funcName) ++ r = r.map( Math.round ); ++ g = g.map( Math.round ); ++ b = b.map( Math.round ); + +- var codeStr = prefix.join('') + code.join('') +- var proc = new Function(codeStr) +- return proc() +-} ++ colors = at.zip(r, g, b, a); + ++ if (format === 'hex') colors = colors.map( rgb2hex ); ++ if (format === 'rgbaString') colors = colors.map( rgbaStr ); + +-exports.partial = bruteForcePlanner(false) +-exports.full = bruteForcePlanner(true) +-},{}],73:[function(require,module,exports){ +-'use strict' ++ return colors; ++}; + +-module.exports = boxIntersectIter + +-var pool = require('typedarray-pool') +-var bits = require('bit-twiddle') +-var bruteForce = require('./brute') +-var bruteForcePartial = bruteForce.partial +-var bruteForceFull = bruteForce.full +-var sweep = require('./sweep') +-var findMedian = require('./median') +-var genPartition = require('./partition') ++function rgb2hex (rgba) { ++ var dig, hex = '#'; ++ for (var i = 0; i < 3; ++i) { ++ dig = rgba[i]; ++ dig = dig.toString(16); ++ hex += ('00' + dig).substr( dig.length ); ++ } ++ return hex; ++} + +-//Twiddle parameters +-var BRUTE_FORCE_CUTOFF = 128 //Cut off for brute force search +-var SCAN_CUTOFF = (1<<22) //Cut off for two way scan +-var SCAN_COMPLETE_CUTOFF = (1<<22) ++function rgbaStr (rgba) { ++ return 'rgba(' + rgba.join(',') + ')'; ++} + +-//Partition functions +-var partitionInteriorContainsInterval = genPartition( +- '!(lo>=p0)&&!(p1>=hi)', +- ['p0', 'p1']) ++},{"./colorScales":60,"arraytools":15,"clone":59}],62:[function(require,module,exports){ ++"use strict" + +-var partitionStartEqual = genPartition( +- 'lo===p0', +- ['p0']) ++module.exports = compareAngle + +-var partitionStartLessThan = genPartition( +- 'lo= 0 ++} + +-//Frame size for iterative loop +-var IFRAME_SIZE = 6 +-var DFRAME_SIZE = 2 ++function compareAngle(a, b, c, d) { ++ var bcd = orient(b, c, d) ++ if(bcd === 0) { ++ //Handle degenerate cases ++ var sabc = sgn(orient(a, b, c)) ++ var sabd = sgn(orient(a, b, d)) ++ if(sabc === sabd) { ++ if(sabc === 0) { ++ var ic = testInterior(a, b, c) ++ var id = testInterior(a, b, d) ++ if(ic === id) { ++ return 0 ++ } else if(ic) { ++ return 1 ++ } else { ++ return -1 ++ } ++ } ++ return 0 ++ } else if(sabd === 0) { ++ if(sabc > 0) { ++ return -1 ++ } else if(testInterior(a, b, d)) { ++ return -1 ++ } else { ++ return 1 ++ } ++ } else if(sabc === 0) { ++ if(sabd > 0) { ++ return 1 ++ } else if(testInterior(a, b, c)) { ++ return 1 ++ } else { ++ return -1 ++ } ++ } ++ return sgn(sabd - sabc) ++ } ++ var abc = orient(a, b, c) ++ if(abc > 0) { ++ if(bcd > 0 && orient(a, b, d) > 0) { ++ return 1 ++ } ++ return -1 ++ } else if(abc < 0) { ++ if(bcd > 0 || orient(a, b, d) > 0) { ++ return 1 ++ } ++ return -1 ++ } else { ++ var abd = orient(a, b, d) ++ if(abd > 0) { ++ return 1 ++ } else { ++ if(testInterior(a, b, c)) { ++ return 1 ++ } else { ++ return -1 ++ } ++ } ++ } ++} ++},{"robust-orientation":219,"robust-product":220,"robust-sum":224,"signum":225,"two-sum":245}],63:[function(require,module,exports){ ++module.exports = compareCells + +-//Data for box statck +-var INIT_CAPACITY = 1024 +-var BOX_ISTACK = pool.mallocInt32(INIT_CAPACITY) +-var BOX_DSTACK = pool.mallocDouble(INIT_CAPACITY) ++var min = Math.min + +-//Initialize iterative loop queue +-function iterInit(d, count) { +- var levels = (8 * bits.log2(count+1) * (d+1))|0 +- var maxInts = bits.nextPow2(IFRAME_SIZE*levels) +- if(BOX_ISTACK.length < maxInts) { +- pool.free(BOX_ISTACK) +- BOX_ISTACK = pool.mallocInt32(maxInts) ++function compareInt(a, b) { ++ return a - b ++} ++ ++function compareCells(a, b) { ++ var n = a.length ++ , t = a.length - b.length ++ if(t) { ++ return t + } +- var maxDoubles = bits.nextPow2(DFRAME_SIZE*levels) +- if(BOX_DSTACK < maxDoubles) { +- pool.free(BOX_DSTACK) +- BOX_DSTACK = pool.mallocDouble(maxDoubles) ++ switch(n) { ++ case 0: ++ return 0 ++ case 1: ++ return a[0] - b[0] ++ case 2: ++ return (a[0]+a[1]-b[0]-b[1]) || ++ min(a[0],a[1]) - min(b[0],b[1]) ++ case 3: ++ var l1 = a[0]+a[1] ++ , m1 = b[0]+b[1] ++ t = l1+a[2] - (m1+b[2]) ++ if(t) { ++ return t ++ } ++ var l0 = min(a[0], a[1]) ++ , m0 = min(b[0], b[1]) ++ return min(l0, a[2]) - min(m0, b[2]) || ++ min(l0+a[2], l1) - min(m0+b[2], m1) ++ case 4: ++ var aw=a[0], ax=a[1], ay=a[2], az=a[3] ++ , bw=b[0], bx=b[1], by=b[2], bz=b[3] ++ return (aw+ax+ay+az)-(bw+bx+by+bz) || ++ min(aw,ax,ay,az)-min(bw,bx,by,bz,bw) || ++ min(aw+ax,aw+ay,aw+az,ax+ay,ax+az,ay+az) - ++ min(bw+bx,bw+by,bw+bz,bx+by,bx+bz,by+bz) || ++ min(aw+ax+ay,aw+ax+az,aw+ay+az,ax+ay+az) - ++ min(bw+bx+by,bw+bx+bz,bw+by+bz,bx+by+bz) ++ default: ++ var as = a.slice().sort(compareInt) ++ var bs = b.slice().sort(compareInt) ++ for(var i=0; i points[hi][0]) { ++ hi = i + } + } ++ if(lo < hi) { ++ return [[lo], [hi]] ++ } else if(lo > hi) { ++ return [[hi], [lo]] ++ } else { ++ return [[lo]] ++ } + } ++},{}],67:[function(require,module,exports){ ++'use strict' + +-//The main box intersection routine +-function boxIntersectIter( +- d, visit, initFull, +- xSize, xBoxes, xIndex, +- ySize, yBoxes, yIndex) { +- +- //Reserve memory for stack +- iterInit(d, xSize + ySize) ++module.exports = convexHull2D + +- var top = 0 +- var elemSize = 2 * d +- var retval ++var monotoneHull = require('monotone-convex-hull-2d') + +- iterPush(top++, +- 0, +- 0, xSize, +- 0, ySize, +- initFull ? 16 : 0, +- -Infinity, Infinity) +- if(!initFull) { +- iterPush(top++, +- 0, +- 0, ySize, +- 0, xSize, +- 1, +- -Infinity, Infinity) ++function convexHull2D(points) { ++ var hull = monotoneHull(points) ++ var h = hull.length ++ if(h <= 2) { ++ return [] ++ } ++ var edges = new Array(h) ++ var a = hull[h-1] ++ for(var i=0; i 0) { +- top -= 1 ++},{"monotone-convex-hull-2d":176}],68:[function(require,module,exports){ ++'use strict' + +- var iptr = top * IFRAME_SIZE +- var axis = BOX_ISTACK[iptr] +- var redStart = BOX_ISTACK[iptr+1] +- var redEnd = BOX_ISTACK[iptr+2] +- var blueStart = BOX_ISTACK[iptr+3] +- var blueEnd = BOX_ISTACK[iptr+4] +- var state = BOX_ISTACK[iptr+5] +- +- var dptr = top * DFRAME_SIZE +- var lo = BOX_DSTACK[dptr] +- var hi = BOX_DSTACK[dptr+1] +- +- //Unpack state info +- var flip = (state & 1) +- var full = !!(state & 16) +- +- //Unpack indices +- var red = xBoxes +- var redIndex = xIndex +- var blue = yBoxes +- var blueIndex = yIndex +- if(flip) { +- red = yBoxes +- redIndex = yIndex +- blue = xBoxes +- blueIndex = xIndex +- } ++module.exports = convexHullnD + +- if(state & 2) { +- redEnd = partitionStartLessThan( +- d, axis, +- redStart, redEnd, red, redIndex, +- hi) +- if(redStart >= redEnd) { +- continue +- } +- } +- if(state & 4) { +- redStart = partitionEndLessThanEqual( +- d, axis, +- redStart, redEnd, red, redIndex, +- lo) +- if(redStart >= redEnd) { +- continue +- } +- } +- +- var redCount = redEnd - redStart +- var blueCount = blueEnd - blueStart ++var ich = require('incremental-convex-hull') ++var aff = require('affine-hull') + +- if(full) { +- if(d * redCount * (redCount + blueCount) < SCAN_COMPLETE_CUTOFF) { +- retval = sweep.scanComplete( +- d, axis, visit, +- redStart, redEnd, red, redIndex, +- blueStart, blueEnd, blue, blueIndex) +- if(retval !== void 0) { +- return retval +- } +- continue +- } +- } else { +- if(d * Math.min(redCount, blueCount) < BRUTE_FORCE_CUTOFF) { +- //If input small, then use brute force +- retval = bruteForcePartial( +- d, axis, visit, flip, +- redStart, redEnd, red, redIndex, +- blueStart, blueEnd, blue, blueIndex) +- if(retval !== void 0) { +- return retval +- } +- continue +- } else if(d * redCount * blueCount < SCAN_CUTOFF) { +- //If input medium sized, then use sweep and prune +- retval = sweep.scanBipartite( +- d, axis, visit, flip, +- redStart, redEnd, red, redIndex, +- blueStart, blueEnd, blue, blueIndex) +- if(retval !== void 0) { +- return retval +- } +- continue +- } ++function permute(points, front) { ++ var n = points.length ++ var npoints = new Array(n) ++ for(var i=0; i mid point +- // +- var blue0 = findMedian( +- d, axis, +- blueStart, blueEnd, blue, blueIndex) +- var mid = blue[elemSize * blue0 + axis] +- var blue1 = partitionStartEqual( +- d, axis, +- blue0, blueEnd, blue, blueIndex, +- mid) +- +- //Right case +- if(blue1 < blueEnd) { +- iterPush(top++, +- axis, +- red0, redEnd, +- blue1, blueEnd, +- (flip|4) + (full ? 16 : 0), +- mid, hi) +- } +- +- //Left case +- if(blueStart < blue0) { +- iterPush(top++, +- axis, +- red0, redEnd, +- blueStart, blue0, +- (flip|2) + (full ? 16 : 0), +- lo, mid) +- } +- +- //Center case (the hard part) +- if(blue0 + 1 === blue1) { +- //Optimization: Range with exactly 1 point, use a brute force scan +- if(full) { +- retval = onePointFull( +- d, axis, visit, +- red0, redEnd, red, redIndex, +- blue0, blue, blueIndex[blue0]) +- } else { +- retval = onePointPartial( +- d, axis, visit, flip, +- red0, redEnd, red, redIndex, +- blue0, blue, blueIndex[blue0]) +- } +- if(retval !== void 0) { +- return retval +- } +- } else if(blue0 < blue1) { +- var red1 +- if(full) { +- //If full intersection, need to handle special case +- red1 = partitionContainsPoint( +- d, axis, +- red0, redEnd, red, redIndex, +- mid) +- if(red0 < red1) { +- var redX = partitionStartEqual( +- d, axis, +- red0, red1, red, redIndex, +- mid) +- if(axis === d-2) { +- //Degenerate sweep intersection: +- // [red0, redX] with [blue0, blue1] +- if(red0 < redX) { +- retval = sweep.sweepComplete( +- d, visit, +- red0, redX, red, redIndex, +- blue0, blue1, blue, blueIndex) +- if(retval !== void 0) { +- return retval +- } +- } +- +- //Normal sweep intersection: +- // [redX, red1] with [blue0, blue1] +- if(redX < red1) { +- retval = sweep.sweepBipartite( +- d, visit, +- redX, red1, red, redIndex, +- blue0, blue1, blue, blueIndex) +- if(retval !== void 0) { +- return retval +- } +- } +- } else { +- if(red0 < redX) { +- iterPush(top++, +- axis+1, +- red0, redX, +- blue0, blue1, +- 16, +- -Infinity, Infinity) +- } +- if(redX < red1) { +- iterPush(top++, +- axis+1, +- redX, red1, +- blue0, blue1, +- 0, +- -Infinity, Infinity) +- iterPush(top++, +- axis+1, +- blue0, blue1, +- redX, red1, +- 1, +- -Infinity, Infinity) +- } +- } +- } +- } else { +- if(flip) { +- red1 = partitionContainsPointProper( +- d, axis, +- red0, redEnd, red, redIndex, +- mid) +- } else { +- red1 = partitionContainsPoint( +- d, axis, +- red0, redEnd, red, redIndex, +- mid) +- } +- if(red0 < red1) { +- if(axis === d-2) { +- if(flip) { +- retval = sweep.sweepBipartite( +- d, visit, +- blue0, blue1, blue, blueIndex, +- red0, red1, red, redIndex) +- } else { +- retval = sweep.sweepBipartite( +- d, visit, +- red0, red1, red, redIndex, +- blue0, blue1, blue, blueIndex) +- } +- } else { +- iterPush(top++, +- axis+1, +- red0, red1, +- blue0, blue1, +- flip, +- -Infinity, Infinity) +- iterPush(top++, +- axis+1, +- blue0, blue1, +- red0, red1, +- flip^1, +- -Infinity, Infinity) +- } ++ x = x - nf ++ for(var k=0; k= front[k]) { ++ x += 1 + } + } ++ c[j] = x + } + } + } ++ return cells + } +-},{"./brute":72,"./median":74,"./partition":75,"./sweep":77,"bit-twiddle":38,"typedarray-pool":242}],74:[function(require,module,exports){ +-'use strict' +- +-module.exports = findMedian +- +-var genPartition = require('./partition') +- +-var partitionStartLessThan = genPartition('lostart && boxes[ptr+axis] > x; +- --j, ptr-=elemSize) { +- //Swap +- var aPtr = ptr +- var bPtr = ptr+elemSize +- for(var k=0; k>> 1) +- var elemSize = 2*d +- var pivot = mid +- var value = boxes[elemSize*mid+axis] +- +- while(lo < hi) { +- if(hi - lo < PARTITION_THRESHOLD) { +- insertionSort(d, axis, lo, hi, boxes, ids) +- value = boxes[elemSize*mid+axis] +- break +- } +- +- //Select pivot using median-of-3 +- var count = hi - lo +- var pivot0 = (Math.random()*count+lo)|0 +- var value0 = boxes[elemSize*pivot0 + axis] +- var pivot1 = (Math.random()*count+lo)|0 +- var value1 = boxes[elemSize*pivot1 + axis] +- var pivot2 = (Math.random()*count+lo)|0 +- var value2 = boxes[elemSize*pivot2 + axis] +- if(value0 <= value1) { +- if(value2 >= value1) { +- pivot = pivot1 +- value = value1 +- } else if(value0 >= value2) { +- pivot = pivot0 +- value = value0 +- } else { +- pivot = pivot2 +- value = value2 +- } +- } else { +- if(value1 >= value2) { +- pivot = pivot1 +- value = value1 +- } else if(value2 >= value0) { +- pivot = pivot0 +- value = value0 +- } else { +- pivot = pivot2 +- value = value2 +- } +- } +- +- //Swap pivot to end of array +- var aPtr = elemSize * (hi-1) +- var bPtr = elemSize * pivot +- for(var i=0; i=0; --i) { ++ f[i] = dh00*p0[i] + dh10*v0[i] + dh01*p1[i] + dh11*v1[i] + } ++ return f + } +- +- //Make sure pivot is at start +- return partitionStartLessThan( +- d, axis, +- start, mid, boxes, ids, +- boxes[elemSize*mid+axis]) ++ return dh00*p0 + dh10*v0 + dh01*p1[i] + dh11*v1 + } +-},{"./partition":75}],75:[function(require,module,exports){ +-'use strict' +- +-module.exports = genPartition +- +-var code = 'for(var j=2*a,k=j*c,l=k,m=c,n=b,o=a+b,p=c;d>p;++p,k+=j){var _;if($)if(m===p)m+=1,l+=j;else{for(var s=0;j>s;++s){var t=e[k+s];e[k+s]=e[l],e[l++]=t}var u=f[p];f[p]=f[m],f[m++]=u}}return m' + +-function genPartition(predicate, args) { +- var fargs ='abcdef'.split('').concat(args) +- var reads = [] +- if(predicate.indexOf('lo') >= 0) { +- reads.push('lo=e[k+n]') +- } +- if(predicate.indexOf('hi') >= 0) { +- reads.push('hi=e[k+o]') ++function cubicHermite(p0, v0, p1, v1, t, f) { ++ var ti = (t-1), t2 = t*t, ti2 = ti*ti, ++ h00 = (1+2*t)*ti2, ++ h10 = t*ti2, ++ h01 = t2*(3-2*t), ++ h11 = t2*ti ++ if(p0.length) { ++ if(!f) { ++ f = new Array(p0.length) ++ } ++ for(var i=p0.length-1; i>=0; --i) { ++ f[i] = h00*p0[i] + h10*v0[i] + h01*p1[i] + h11*v1[i] ++ } ++ return f + } +- fargs.push( +- code.replace('_', reads.join()) +- .replace('$', predicate)) +- return Function.apply(void 0, fargs) ++ return h00*p0 + h10*v0 + h01*p1 + h11*v1 + } +-},{}],76:[function(require,module,exports){ +-'use strict'; +- +-//This code is extracted from ndarray-sort +-//It is inlined here as a temporary workaround + +-module.exports = wrapper; +- +-var INSERT_SORT_CUTOFF = 32 +- +-function wrapper(data, n0) { +- if (n0 <= 4*INSERT_SORT_CUTOFF) { +- insertionSort(0, n0 - 1, data); +- } else { +- quickSort(0, n0 - 1, data); +- } +-} +- +-function insertionSort(left, right, data) { +- var ptr = 2*(left+1) +- for(var i=left+1; i<=right; ++i) { +- var a = data[ptr++] +- var b = data[ptr++] +- var j = i +- var jptr = ptr-2 +- while(j-- > left) { +- var x = data[jptr-2] +- var y = data[jptr-1] +- if(x < a) { +- break +- } else if(x === a && y < b) { +- break +- } +- data[jptr] = x +- data[jptr+1] = y +- jptr -= 2 +- } +- data[jptr] = a +- data[jptr+1] = b +- } +-} +- +-function swap(i, j, data) { +- i *= 2 +- j *= 2 +- var x = data[i] +- var y = data[i+1] +- data[i] = data[j] +- data[i+1] = data[j+1] +- data[j] = x +- data[j+1] = y +-} +- +-function move(i, j, data) { +- i *= 2 +- j *= 2 +- data[i] = data[j] +- data[i+1] = data[j+1] +-} +- +-function rotate(i, j, k, data) { +- i *= 2 +- j *= 2 +- k *= 2 +- var x = data[i] +- var y = data[i+1] +- data[i] = data[j] +- data[i+1] = data[j+1] +- data[j] = data[k] +- data[j+1] = data[k+1] +- data[k] = x +- data[k+1] = y +-} +- +-function shufflePivot(i, j, px, py, data) { +- i *= 2 +- j *= 2 +- data[i] = data[j] +- data[j] = px +- data[i+1] = data[j+1] +- data[j+1] = py +-} +- +-function compare(i, j, data) { +- i *= 2 +- j *= 2 +- var x = data[i], +- y = data[j] +- if(x < y) { +- return false +- } else if(x === y) { +- return data[i+1] > data[j+1] +- } +- return true +-} +- +-function comparePivot(i, y, b, data) { +- i *= 2 +- var x = data[i] +- if(x < y) { +- return true +- } else if(x === y) { +- return data[i+1] < b +- } +- return false +-} +- +-function quickSort(left, right, data) { +- var sixth = (right - left + 1) / 6 | 0, +- index1 = left + sixth, +- index5 = right - sixth, +- index3 = left + right >> 1, +- index2 = index3 - sixth, +- index4 = index3 + sixth, +- el1 = index1, +- el2 = index2, +- el3 = index3, +- el4 = index4, +- el5 = index5, +- less = left + 1, +- great = right - 1, +- tmp = 0 +- if(compare(el1, el2, data)) { +- tmp = el1 +- el1 = el2 +- el2 = tmp +- } +- if(compare(el4, el5, data)) { +- tmp = el4 +- el4 = el5 +- el5 = tmp +- } +- if(compare(el1, el3, data)) { +- tmp = el1 +- el1 = el3 +- el3 = tmp +- } +- if(compare(el2, el3, data)) { +- tmp = el2 +- el2 = el3 +- el3 = tmp +- } +- if(compare(el1, el4, data)) { +- tmp = el1 +- el1 = el4 +- el4 = tmp +- } +- if(compare(el3, el4, data)) { +- tmp = el3 +- el3 = el4 +- el4 = tmp +- } +- if(compare(el2, el5, data)) { +- tmp = el2 +- el2 = el5 +- el5 = tmp +- } +- if(compare(el2, el3, data)) { +- tmp = el2 +- el2 = el3 +- el3 = tmp +- } +- if(compare(el4, el5, data)) { +- tmp = el4 +- el4 = el5 +- el5 = tmp +- } +- +- var pivot1X = data[2*el2] +- var pivot1Y = data[2*el2+1] +- var pivot2X = data[2*el4] +- var pivot2Y = data[2*el4+1] +- +- var ptr0 = 2 * el1; +- var ptr2 = 2 * el3; +- var ptr4 = 2 * el5; +- var ptr5 = 2 * index1; +- var ptr6 = 2 * index3; +- var ptr7 = 2 * index5; +- for (var i1 = 0; i1 < 2; ++i1) { +- var x = data[ptr0+i1]; +- var y = data[ptr2+i1]; +- var z = data[ptr4+i1]; +- data[ptr5+i1] = x; +- data[ptr6+i1] = y; +- data[ptr7+i1] = z; +- } +- +- move(index2, left, data) +- move(index4, right, data) +- for (var k = less; k <= great; ++k) { +- if (comparePivot(k, pivot1X, pivot1Y, data)) { +- if (k !== less) { +- swap(k, less, data) +- } +- ++less; +- } else { +- if (!comparePivot(k, pivot2X, pivot2Y, data)) { +- while (true) { +- if (!comparePivot(great, pivot2X, pivot2Y, data)) { +- if (--great < k) { +- break; +- } +- continue; +- } else { +- if (comparePivot(great, pivot1X, pivot1Y, data)) { +- rotate(k, less, great, data) +- ++less; +- --great; +- } else { +- swap(k, great, data) +- --great; +- } +- break; +- } +- } +- } +- } +- } +- shufflePivot(left, less-1, pivot1X, pivot1Y, data) +- shufflePivot(right, great+1, pivot2X, pivot2Y, data) +- if (less - 2 - left <= INSERT_SORT_CUTOFF) { +- insertionSort(left, less - 2, data); +- } else { +- quickSort(left, less - 2, data); +- } +- if (right - (great + 2) <= INSERT_SORT_CUTOFF) { +- insertionSort(great + 2, right, data); +- } else { +- quickSort(great + 2, right, data); +- } +- if (great - less <= INSERT_SORT_CUTOFF) { +- insertionSort(less, great, data); +- } else { +- quickSort(less, great, data); +- } +-} +-},{}],77:[function(require,module,exports){ +-'use strict' +- +-module.exports = { +- init: sqInit, +- sweepBipartite: sweepBipartite, +- sweepComplete: sweepComplete, +- scanBipartite: scanBipartite, +- scanComplete: scanComplete +-} +- +-var pool = require('typedarray-pool') +-var bits = require('bit-twiddle') +-var isort = require('./sort') +- +-//Flag for blue +-var BLUE_FLAG = (1<<28) +- +-//1D sweep event queue stuff (use pool to save space) +-var INIT_CAPACITY = 1024 +-var RED_SWEEP_QUEUE = pool.mallocInt32(INIT_CAPACITY) +-var RED_SWEEP_INDEX = pool.mallocInt32(INIT_CAPACITY) +-var BLUE_SWEEP_QUEUE = pool.mallocInt32(INIT_CAPACITY) +-var BLUE_SWEEP_INDEX = pool.mallocInt32(INIT_CAPACITY) +-var COMMON_SWEEP_QUEUE = pool.mallocInt32(INIT_CAPACITY) +-var COMMON_SWEEP_INDEX = pool.mallocInt32(INIT_CAPACITY) +-var SWEEP_EVENTS = pool.mallocDouble(INIT_CAPACITY * 8) +- +-//Reserves memory for the 1D sweep data structures +-function sqInit(count) { +- var rcount = bits.nextPow2(count) +- if(RED_SWEEP_QUEUE.length < rcount) { +- pool.free(RED_SWEEP_QUEUE) +- RED_SWEEP_QUEUE = pool.mallocInt32(rcount) +- } +- if(RED_SWEEP_INDEX.length < rcount) { +- pool.free(RED_SWEEP_INDEX) +- RED_SWEEP_INDEX = pool.mallocInt32(rcount) +- } +- if(BLUE_SWEEP_QUEUE.length < rcount) { +- pool.free(BLUE_SWEEP_QUEUE) +- BLUE_SWEEP_QUEUE = pool.mallocInt32(rcount) +- } +- if(BLUE_SWEEP_INDEX.length < rcount) { +- pool.free(BLUE_SWEEP_INDEX) +- BLUE_SWEEP_INDEX = pool.mallocInt32(rcount) +- } +- if(COMMON_SWEEP_QUEUE.length < rcount) { +- pool.free(COMMON_SWEEP_QUEUE) +- COMMON_SWEEP_QUEUE = pool.mallocInt32(rcount) +- } +- if(COMMON_SWEEP_INDEX.length < rcount) { +- pool.free(COMMON_SWEEP_INDEX) +- COMMON_SWEEP_INDEX = pool.mallocInt32(rcount) +- } +- var eventLength = 8 * rcount +- if(SWEEP_EVENTS.length < eventLength) { +- pool.free(SWEEP_EVENTS) +- SWEEP_EVENTS = pool.mallocDouble(eventLength) +- } +-} +- +-//Remove an item from the active queue in O(1) +-function sqPop(queue, index, count, item) { +- var idx = index[item] +- var top = queue[count-1] +- queue[idx] = top +- index[top] = idx +-} +- +-//Insert an item into the active queue in O(1) +-function sqPush(queue, index, count, item) { +- queue[count] = item +- index[item] = count +-} +- +-//Recursion base case: use 1D sweep algorithm +-function sweepBipartite( +- d, visit, +- redStart, redEnd, red, redIndex, +- blueStart, blueEnd, blue, blueIndex) { +- +- //store events as pairs [coordinate, idx] +- // +- // red create: -(idx+1) +- // red destroy: idx +- // blue create: -(idx+BLUE_FLAG) +- // blue destroy: idx+BLUE_FLAG +- // +- var ptr = 0 +- var elemSize = 2*d +- var istart = d-1 +- var iend = elemSize-1 +- +- for(var i=redStart; iright +- var n = ptr >>> 1 +- isort(SWEEP_EVENTS, n) +- +- var redActive = 0 +- var blueActive = 0 +- for(var i=0; i= BLUE_FLAG) { +- //blue destroy event +- e = (e-BLUE_FLAG)|0 +- sqPop(BLUE_SWEEP_QUEUE, BLUE_SWEEP_INDEX, blueActive--, e) +- } else if(e >= 0) { +- //red destroy event +- sqPop(RED_SWEEP_QUEUE, RED_SWEEP_INDEX, redActive--, e) +- } else if(e <= -BLUE_FLAG) { +- //blue create event +- e = (-e-BLUE_FLAG)|0 +- for(var j=0; jright +- var n = ptr >>> 1 +- isort(SWEEP_EVENTS, n) +- +- var redActive = 0 +- var blueActive = 0 +- var commonActive = 0 +- for(var i=0; i>1) === (SWEEP_EVENTS[2*i+3]>>1)) { +- color = 2 +- i += 1 +- } +- +- if(e < 0) { +- //Create event +- var id = -(e>>1) - 1 +- +- //Intersect with common +- for(var j=0; j>1) - 1 +- if(color === 0) { +- //Red +- sqPop(RED_SWEEP_QUEUE, RED_SWEEP_INDEX, redActive--, id) +- } else if(color === 1) { +- //Blue +- sqPop(BLUE_SWEEP_QUEUE, BLUE_SWEEP_INDEX, blueActive--, id) +- } else if(color === 2) { +- //Both +- sqPop(COMMON_SWEEP_QUEUE, COMMON_SWEEP_INDEX, commonActive--, id) +- } +- } +- } +-} +- +-//Sweep and prune/scanline algorithm: +-// Scan along axis, detect intersections +-// Brute force all boxes along axis +-function scanBipartite( +- d, axis, visit, flip, +- redStart, redEnd, red, redIndex, +- blueStart, blueEnd, blue, blueIndex) { +- +- var ptr = 0 +- var elemSize = 2*d +- var istart = axis +- var iend = axis+d +- +- var redShift = 1 +- var blueShift = 1 +- if(flip) { +- blueShift = BLUE_FLAG +- } else { +- redShift = BLUE_FLAG +- } +- +- for(var i=redStart; iright +- var n = ptr >>> 1 +- isort(SWEEP_EVENTS, n) +- +- var redActive = 0 +- for(var i=0; i= BLUE_FLAG) { +- isRed = !flip +- idx -= BLUE_FLAG +- } else { +- isRed = !!flip +- idx -= 1 +- } +- if(isRed) { +- sqPush(RED_SWEEP_QUEUE, RED_SWEEP_INDEX, redActive++, idx) +- } else { +- var blueId = blueIndex[idx] +- var bluePtr = elemSize * idx +- +- var b0 = blue[bluePtr+axis+1] +- var b1 = blue[bluePtr+axis+1+d] +- +-red_loop: +- for(var j=0; jright +- var n = ptr >>> 1 +- isort(SWEEP_EVENTS, n) +- +- var redActive = 0 +- for(var i=0; i= BLUE_FLAG) { +- RED_SWEEP_QUEUE[redActive++] = idx - BLUE_FLAG +- } else { +- idx -= 1 +- var blueId = blueIndex[idx] +- var bluePtr = elemSize * idx +- +- var b0 = blue[bluePtr+axis+1] +- var b1 = blue[bluePtr+axis+1+d] +- +-red_loop: +- for(var j=0; j=0; --j) { +- if(RED_SWEEP_QUEUE[j] === idx) { +- for(var k=j+1; k>> 31 +-} +- +-module.exports.exponent = function(n) { +- var b = module.exports.hi(n) +- return ((b<<1) >>> 21) - 1023 +-} +- +-module.exports.fraction = function(n) { +- var lo = module.exports.lo(n) +- var hi = module.exports.hi(n) +- var b = hi & ((1<<20) - 1) +- if(hi & 0x7ff00000) { +- b += (1<<20) +- } +- return [lo, b] +-} +- +-module.exports.denormalized = function(n) { +- var hi = module.exports.hi(n) +- return !(hi & 0x7ff00000) +-} +-}).call(this,require("buffer").Buffer) +-},{"buffer":39}],79:[function(require,module,exports){ +-"use strict" +- +-var doubleBits = require("double-bits") +- +-var SMALLEST_DENORM = Math.pow(2, -1074) +-var UINT_MAX = (-1)>>>0 +- +-module.exports = nextafter +- +-function nextafter(x, y) { +- if(isNaN(x) || isNaN(y)) { +- return NaN +- } +- if(x === y) { +- return x +- } +- if(x === 0) { +- if(y < 0) { +- return -SMALLEST_DENORM +- } else { +- return SMALLEST_DENORM +- } +- } +- var hi = doubleBits.hi(x) +- var lo = doubleBits.lo(x) +- if((y > x) === (x > 0)) { +- if(lo === UINT_MAX) { +- hi += 1 +- lo = 0 +- } else { +- lo += 1 +- } +- } else { +- if(lo === 0) { +- lo = UINT_MAX +- hi -= 1 +- } else { +- lo -= 1 +- } +- } +- return doubleBits.pack(lo, hi) +-} +-},{"double-bits":78}],80:[function(require,module,exports){ +-'use strict' +- +-var bnadd = require('big-rat/add') +- +-module.exports = add +- +-function add(a, b) { +- var n = a.length +- var r = new Array(n) +- for(var i=0; i 0 && y0 > 0) || (x0 < 0 && y0 < 0)) { +- return false +- } +- +- var x1 = orient(b0, a0, a1) +- var y1 = orient(b1, a0, a1) +- if((x1 > 0 && y1 > 0) || (x1 < 0 && y1 < 0)) { +- return false +- } +- +- //Check for degenerate collinear case +- if(x0 === 0 && y0 === 0 && x1 === 0 && y1 === 0) { +- return checkCollinear(a0, a1, b0, b1) +- } +- +- return true +-} +-},{"robust-orientation":225}],85:[function(require,module,exports){ +-"use strict"; "use restrict"; +- +-module.exports = UnionFind; +- +-function UnionFind(count) { +- this.roots = new Array(count); +- this.ranks = new Array(count); +- +- for(var i=0; i nshades) { +- throw new Error( +- colormap+' map requires nshades to be at least size '+cmap.length +- ); +- } +- +- if (!Array.isArray(spec.alpha)) { +- +- if (typeof spec.alpha === 'number') { +- alpha = [spec.alpha, spec.alpha]; +- +- } else { +- alpha = [1, 1]; +- } +- +- } else if (spec.alpha.length !== 2) { +- alpha = [1, 1]; +- +- } else { +- alpha = clone(spec.alpha); +- } +- +- /* +- * map index points from 0->1 to 0 -> n-1 +- */ +- indicies = cmap.map(function(c) { +- return Math.round(c.index * nshades); +- }); +- +- /* +- * Add alpha channel to the map +- */ +- if (alpha[0] < 0) alpha[0] = 0; +- if (alpha[1] < 0) alpha[0] = 0; +- if (alpha[0] > 1) alpha[0] = 1; +- if (alpha[1] > 1) alpha[0] = 1; +- +- for (i = 0; i < indicies.length; ++i) { +- index = cmap[i].index; +- rgba = cmap[i].rgb; +- +- // if user supplies their own map use it +- if (rgba.length === 4 && rgba[3] >= 0 && rgba[3] <= 1) continue; +- rgba[3] = alpha[0] + (alpha[1] - alpha[0])*index; +- } +- +- /* +- * map increasing linear values between indicies to +- * linear steps in colorvalues +- */ +- for (i = 0; i < indicies.length-1; ++i) { +- nsteps = indicies[i+1] - indicies[i]; +- fromrgba = cmap[i].rgb; +- torgba = cmap[i+1].rgb; +- r = r.concat(at.linspace(fromrgba[0], torgba[0], nsteps ) ); +- g = g.concat(at.linspace(fromrgba[1], torgba[1], nsteps ) ); +- b = b.concat(at.linspace(fromrgba[2], torgba[2], nsteps ) ); +- a = a.concat(at.linspace(fromrgba[3], torgba[3], nsteps ) ); +- } +- +- r = r.map( Math.round ); +- g = g.map( Math.round ); +- b = b.map( Math.round ); +- +- colors = at.zip(r, g, b, a); +- +- if (format === 'hex') colors = colors.map( rgb2hex ); +- if (format === 'rgbaString') colors = colors.map( rgbaStr ); +- +- return colors; +-}; +- +- +-function rgb2hex (rgba) { +- var dig, hex = '#'; +- for (var i = 0; i < 3; ++i) { +- dig = rgba[i]; +- dig = dig.toString(16); +- hex += ('00' + dig).substr( dig.length ); +- } +- return hex; +-} +- +-function rgbaStr (rgba) { +- return 'rgba(' + rgba.join(',') + ')'; +-} +- +-},{"./colorScales":87,"arraytools":37,"clone":86}],89:[function(require,module,exports){ +-module.exports = compareCells +- +-var min = Math.min +- +-function compareInt(a, b) { +- return a - b +-} +- +-function compareCells(a, b) { +- var n = a.length +- , t = a.length - b.length +- if(t) { +- return t +- } +- switch(n) { +- case 0: +- return 0 +- case 1: +- return a[0] - b[0] +- case 2: +- return (a[0]+a[1]-b[0]-b[1]) || +- min(a[0],a[1]) - min(b[0],b[1]) +- case 3: +- var l1 = a[0]+a[1] +- , m1 = b[0]+b[1] +- t = l1+a[2] - (m1+b[2]) +- if(t) { +- return t +- } +- var l0 = min(a[0], a[1]) +- , m0 = min(b[0], b[1]) +- return min(l0, a[2]) - min(m0, b[2]) || +- min(l0+a[2], l1) - min(m0+b[2], m1) +- case 4: +- var aw=a[0], ax=a[1], ay=a[2], az=a[3] +- , bw=b[0], bx=b[1], by=b[2], bz=b[3] +- return (aw+ax+ay+az)-(bw+bx+by+bz) || +- min(aw,ax,ay,az)-min(bw,bx,by,bz,bw) || +- min(aw+ax,aw+ay,aw+az,ax+ay,ax+az,ay+az) - +- min(bw+bx,bw+by,bw+bz,bx+by,bx+bz,by+bz) || +- min(aw+ax+ay,aw+ax+az,aw+ay+az,ax+ay+az) - +- min(bw+bx+by,bw+bx+bz,bw+by+bz,bx+by+bz) +- default: +- var as = a.slice().sort(compareInt) +- var bs = b.slice().sort(compareInt) +- for(var i=0; i points[hi][0]) { +- hi = i +- } +- } +- if(lo < hi) { +- return [[lo], [hi]] +- } else if(lo > hi) { +- return [[hi], [lo]] +- } else { +- return [[lo]] +- } +-} +-},{}],92:[function(require,module,exports){ +-'use strict' +- +-module.exports = convexHull2D +- +-var monotoneHull = require('monotone-convex-hull-2d') +- +-function convexHull2D(points) { +- var hull = monotoneHull(points) +- var h = hull.length +- if(h <= 2) { +- return [] +- } +- var edges = new Array(h) +- var a = hull[h-1] +- for(var i=0; i= front[k]) { +- x += 1 +- } +- } +- c[j] = x +- } +- } +- } +- return cells +-} +- +-function convexHullnD(points, d) { +- try { +- return ich(points, true) +- } catch(e) { +- //If point set is degenerate, try to find a basis and rerun it +- var ah = aff(points) +- if(ah.length <= d) { +- //No basis, no try +- return [] +- } +- var npoints = permute(points, ah) +- var nhull = ich(npoints, true) +- return invPermute(nhull, ah) +- } +-} +-},{"affine-hull":94,"incremental-convex-hull":201}],94:[function(require,module,exports){ +-'use strict' +- +-module.exports = affineHull +- +-var orient = require('robust-orientation') +- +-function linearlyIndependent(points, d) { +- var nhull = new Array(d+1) +- for(var i=0; i 1 && orient( +- points[lower[m-2]], +- points[lower[m-1]], +- p) <= 0) { +- m -= 1 +- lower.pop() +- } +- lower.push(idx) +- +- //Insert into upper list +- m = upper.length +- while(m > 1 && orient( +- points[upper[m-2]], +- points[upper[m-1]], +- p) >= 0) { +- m -= 1 +- upper.pop() +- } +- upper.push(idx) +- } +- +- //Merge lists together +- var result = new Array(upper.length + lower.length - 2) +- var ptr = 0 +- for(var i=0, nl=lower.length; i0; --j) { +- result[ptr++] = upper[j] +- } +- +- //Return result +- return result +-} +-},{"robust-orientation":225}],96:[function(require,module,exports){ ++module.exports = cubicHermite ++module.exports.derivative = dcubicHermite ++},{}],70:[function(require,module,exports){ + "use strict" + + var createThunk = require("./lib/thunk.js") +@@ -11721,7 +9487,7 @@ function compileCwise(user_args) { + + module.exports = compileCwise + +-},{"./lib/thunk.js":98}],97:[function(require,module,exports){ ++},{"./lib/thunk.js":72}],71:[function(require,module,exports){ + "use strict" + + var uniq = require("uniq") +@@ -12077,7 +9843,7 @@ function generateCWiseOp(proc, typesig) { + } + module.exports = generateCWiseOp + +-},{"uniq":243}],98:[function(require,module,exports){ ++},{"uniq":248}],72:[function(require,module,exports){ + "use strict" + + // The function below is called when constructing a cwise function object, and does the following: +@@ -12165,12 +9931,12 @@ function createThunk(proc) { + + module.exports = createThunk + +-},{"./compile.js":97}],99:[function(require,module,exports){ ++},{"./compile.js":71}],73:[function(require,module,exports){ + module.exports = require("cwise-compiler") +-},{"cwise-compiler":96}],100:[function(require,module,exports){ ++},{"cwise-compiler":70}],74:[function(require,module,exports){ + !function() { + var d3 = { +- version: "3.5.16" ++ version: "3.5.17" + }; + var d3_arraySlice = [].slice, d3_array = function(list) { + return d3_arraySlice.call(list); +@@ -12537,229 +10303,655 @@ module.exports = require("cwise-compiler") + for (var key in this._) return false; + return true; + } +- d3.nest = function() { +- var nest = {}, keys = [], sortKeys = [], sortValues, rollup; +- function map(mapType, array, depth) { +- if (depth >= keys.length) return rollup ? rollup.call(nest, array) : sortValues ? array.sort(sortValues) : array; +- var i = -1, n = array.length, key = keys[depth++], keyValue, object, setter, valuesByKey = new d3_Map(), values; ++ d3.nest = function() { ++ var nest = {}, keys = [], sortKeys = [], sortValues, rollup; ++ function map(mapType, array, depth) { ++ if (depth >= keys.length) return rollup ? rollup.call(nest, array) : sortValues ? array.sort(sortValues) : array; ++ var i = -1, n = array.length, key = keys[depth++], keyValue, object, setter, valuesByKey = new d3_Map(), values; ++ while (++i < n) { ++ if (values = valuesByKey.get(keyValue = key(object = array[i]))) { ++ values.push(object); ++ } else { ++ valuesByKey.set(keyValue, [ object ]); ++ } ++ } ++ if (mapType) { ++ object = mapType(); ++ setter = function(keyValue, values) { ++ object.set(keyValue, map(mapType, values, depth)); ++ }; ++ } else { ++ object = {}; ++ setter = function(keyValue, values) { ++ object[keyValue] = map(mapType, values, depth); ++ }; ++ } ++ valuesByKey.forEach(setter); ++ return object; ++ } ++ function entries(map, depth) { ++ if (depth >= keys.length) return map; ++ var array = [], sortKey = sortKeys[depth++]; ++ map.forEach(function(key, keyMap) { ++ array.push({ ++ key: key, ++ values: entries(keyMap, depth) ++ }); ++ }); ++ return sortKey ? array.sort(function(a, b) { ++ return sortKey(a.key, b.key); ++ }) : array; ++ } ++ nest.map = function(array, mapType) { ++ return map(mapType, array, 0); ++ }; ++ nest.entries = function(array) { ++ return entries(map(d3.map, array, 0), 0); ++ }; ++ nest.key = function(d) { ++ keys.push(d); ++ return nest; ++ }; ++ nest.sortKeys = function(order) { ++ sortKeys[keys.length - 1] = order; ++ return nest; ++ }; ++ nest.sortValues = function(order) { ++ sortValues = order; ++ return nest; ++ }; ++ nest.rollup = function(f) { ++ rollup = f; ++ return nest; ++ }; ++ return nest; ++ }; ++ d3.set = function(array) { ++ var set = new d3_Set(); ++ if (array) for (var i = 0, n = array.length; i < n; ++i) set.add(array[i]); ++ return set; ++ }; ++ function d3_Set() { ++ this._ = Object.create(null); ++ } ++ d3_class(d3_Set, { ++ has: d3_map_has, ++ add: function(key) { ++ this._[d3_map_escape(key += "")] = true; ++ return key; ++ }, ++ remove: d3_map_remove, ++ values: d3_map_keys, ++ size: d3_map_size, ++ empty: d3_map_empty, ++ forEach: function(f) { ++ for (var key in this._) f.call(this, d3_map_unescape(key)); ++ } ++ }); ++ d3.behavior = {}; ++ function d3_identity(d) { ++ return d; ++ } ++ d3.rebind = function(target, source) { ++ var i = 1, n = arguments.length, method; ++ while (++i < n) target[method = arguments[i]] = d3_rebind(target, source, source[method]); ++ return target; ++ }; ++ function d3_rebind(target, source, method) { ++ return function() { ++ var value = method.apply(source, arguments); ++ return value === source ? target : value; ++ }; ++ } ++ function d3_vendorSymbol(object, name) { ++ if (name in object) return name; ++ name = name.charAt(0).toUpperCase() + name.slice(1); ++ for (var i = 0, n = d3_vendorPrefixes.length; i < n; ++i) { ++ var prefixName = d3_vendorPrefixes[i] + name; ++ if (prefixName in object) return prefixName; ++ } ++ } ++ var d3_vendorPrefixes = [ "webkit", "ms", "moz", "Moz", "o", "O" ]; ++ function d3_noop() {} ++ d3.dispatch = function() { ++ var dispatch = new d3_dispatch(), i = -1, n = arguments.length; ++ while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch); ++ return dispatch; ++ }; ++ function d3_dispatch() {} ++ d3_dispatch.prototype.on = function(type, listener) { ++ var i = type.indexOf("."), name = ""; ++ if (i >= 0) { ++ name = type.slice(i + 1); ++ type = type.slice(0, i); ++ } ++ if (type) return arguments.length < 2 ? this[type].on(name) : this[type].on(name, listener); ++ if (arguments.length === 2) { ++ if (listener == null) for (type in this) { ++ if (this.hasOwnProperty(type)) this[type].on(name, null); ++ } ++ return this; ++ } ++ }; ++ function d3_dispatch_event(dispatch) { ++ var listeners = [], listenerByName = new d3_Map(); ++ function event() { ++ var z = listeners, i = -1, n = z.length, l; ++ while (++i < n) if (l = z[i].on) l.apply(this, arguments); ++ return dispatch; ++ } ++ event.on = function(name, listener) { ++ var l = listenerByName.get(name), i; ++ if (arguments.length < 2) return l && l.on; ++ if (l) { ++ l.on = null; ++ listeners = listeners.slice(0, i = listeners.indexOf(l)).concat(listeners.slice(i + 1)); ++ listenerByName.remove(name); ++ } ++ if (listener) listeners.push(listenerByName.set(name, { ++ on: listener ++ })); ++ return dispatch; ++ }; ++ return event; ++ } ++ d3.event = null; ++ function d3_eventPreventDefault() { ++ d3.event.preventDefault(); ++ } ++ function d3_eventSource() { ++ var e = d3.event, s; ++ while (s = e.sourceEvent) e = s; ++ return e; ++ } ++ function d3_eventDispatch(target) { ++ var dispatch = new d3_dispatch(), i = 0, n = arguments.length; ++ while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch); ++ dispatch.of = function(thiz, argumentz) { ++ return function(e1) { ++ try { ++ var e0 = e1.sourceEvent = d3.event; ++ e1.target = target; ++ d3.event = e1; ++ dispatch[e1.type].apply(thiz, argumentz); ++ } finally { ++ d3.event = e0; ++ } ++ }; ++ }; ++ return dispatch; ++ } ++ d3.requote = function(s) { ++ return s.replace(d3_requote_re, "\\$&"); ++ }; ++ var d3_requote_re = /[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g; ++ var d3_subclass = {}.__proto__ ? function(object, prototype) { ++ object.__proto__ = prototype; ++ } : function(object, prototype) { ++ for (var property in prototype) object[property] = prototype[property]; ++ }; ++ function d3_selection(groups) { ++ d3_subclass(groups, d3_selectionPrototype); ++ return groups; ++ } ++ var d3_select = function(s, n) { ++ return n.querySelector(s); ++ }, d3_selectAll = function(s, n) { ++ return n.querySelectorAll(s); ++ }, d3_selectMatches = function(n, s) { ++ var d3_selectMatcher = n.matches || n[d3_vendorSymbol(n, "matchesSelector")]; ++ d3_selectMatches = function(n, s) { ++ return d3_selectMatcher.call(n, s); ++ }; ++ return d3_selectMatches(n, s); ++ }; ++ if (typeof Sizzle === "function") { ++ d3_select = function(s, n) { ++ return Sizzle(s, n)[0] || null; ++ }; ++ d3_selectAll = Sizzle; ++ d3_selectMatches = Sizzle.matchesSelector; ++ } ++ d3.selection = function() { ++ return d3.select(d3_document.documentElement); ++ }; ++ var d3_selectionPrototype = d3.selection.prototype = []; ++ d3_selectionPrototype.select = function(selector) { ++ var subgroups = [], subgroup, subnode, group, node; ++ selector = d3_selection_selector(selector); ++ for (var j = -1, m = this.length; ++j < m; ) { ++ subgroups.push(subgroup = []); ++ subgroup.parentNode = (group = this[j]).parentNode; ++ for (var i = -1, n = group.length; ++i < n; ) { ++ if (node = group[i]) { ++ subgroup.push(subnode = selector.call(node, node.__data__, i, j)); ++ if (subnode && "__data__" in node) subnode.__data__ = node.__data__; ++ } else { ++ subgroup.push(null); ++ } ++ } ++ } ++ return d3_selection(subgroups); ++ }; ++ function d3_selection_selector(selector) { ++ return typeof selector === "function" ? selector : function() { ++ return d3_select(selector, this); ++ }; ++ } ++ d3_selectionPrototype.selectAll = function(selector) { ++ var subgroups = [], subgroup, node; ++ selector = d3_selection_selectorAll(selector); ++ for (var j = -1, m = this.length; ++j < m; ) { ++ for (var group = this[j], i = -1, n = group.length; ++i < n; ) { ++ if (node = group[i]) { ++ subgroups.push(subgroup = d3_array(selector.call(node, node.__data__, i, j))); ++ subgroup.parentNode = node; ++ } ++ } ++ } ++ return d3_selection(subgroups); ++ }; ++ function d3_selection_selectorAll(selector) { ++ return typeof selector === "function" ? selector : function() { ++ return d3_selectAll(selector, this); ++ }; ++ } ++ var d3_nsXhtml = "http://www.w3.org/1999/xhtml"; ++ var d3_nsPrefix = { ++ svg: "http://www.w3.org/2000/svg", ++ xhtml: d3_nsXhtml, ++ xlink: "http://www.w3.org/1999/xlink", ++ xml: "http://www.w3.org/XML/1998/namespace", ++ xmlns: "http://www.w3.org/2000/xmlns/" ++ }; ++ d3.ns = { ++ prefix: d3_nsPrefix, ++ qualify: function(name) { ++ var i = name.indexOf(":"), prefix = name; ++ if (i >= 0 && (prefix = name.slice(0, i)) !== "xmlns") name = name.slice(i + 1); ++ return d3_nsPrefix.hasOwnProperty(prefix) ? { ++ space: d3_nsPrefix[prefix], ++ local: name ++ } : name; ++ } ++ }; ++ d3_selectionPrototype.attr = function(name, value) { ++ if (arguments.length < 2) { ++ if (typeof name === "string") { ++ var node = this.node(); ++ name = d3.ns.qualify(name); ++ return name.local ? node.getAttributeNS(name.space, name.local) : node.getAttribute(name); ++ } ++ for (value in name) this.each(d3_selection_attr(value, name[value])); ++ return this; ++ } ++ return this.each(d3_selection_attr(name, value)); ++ }; ++ function d3_selection_attr(name, value) { ++ name = d3.ns.qualify(name); ++ function attrNull() { ++ this.removeAttribute(name); ++ } ++ function attrNullNS() { ++ this.removeAttributeNS(name.space, name.local); ++ } ++ function attrConstant() { ++ this.setAttribute(name, value); ++ } ++ function attrConstantNS() { ++ this.setAttributeNS(name.space, name.local, value); ++ } ++ function attrFunction() { ++ var x = value.apply(this, arguments); ++ if (x == null) this.removeAttribute(name); else this.setAttribute(name, x); ++ } ++ function attrFunctionNS() { ++ var x = value.apply(this, arguments); ++ if (x == null) this.removeAttributeNS(name.space, name.local); else this.setAttributeNS(name.space, name.local, x); ++ } ++ return value == null ? name.local ? attrNullNS : attrNull : typeof value === "function" ? name.local ? attrFunctionNS : attrFunction : name.local ? attrConstantNS : attrConstant; ++ } ++ function d3_collapse(s) { ++ return s.trim().replace(/\s+/g, " "); ++ } ++ d3_selectionPrototype.classed = function(name, value) { ++ if (arguments.length < 2) { ++ if (typeof name === "string") { ++ var node = this.node(), n = (name = d3_selection_classes(name)).length, i = -1; ++ if (value = node.classList) { ++ while (++i < n) if (!value.contains(name[i])) return false; ++ } else { ++ value = node.getAttribute("class"); ++ while (++i < n) if (!d3_selection_classedRe(name[i]).test(value)) return false; ++ } ++ return true; ++ } ++ for (value in name) this.each(d3_selection_classed(value, name[value])); ++ return this; ++ } ++ return this.each(d3_selection_classed(name, value)); ++ }; ++ function d3_selection_classedRe(name) { ++ return new RegExp("(?:^|\\s+)" + d3.requote(name) + "(?:\\s+|$)", "g"); ++ } ++ function d3_selection_classes(name) { ++ return (name + "").trim().split(/^|\s+/); ++ } ++ function d3_selection_classed(name, value) { ++ name = d3_selection_classes(name).map(d3_selection_classedName); ++ var n = name.length; ++ function classedConstant() { ++ var i = -1; ++ while (++i < n) name[i](this, value); ++ } ++ function classedFunction() { ++ var i = -1, x = value.apply(this, arguments); ++ while (++i < n) name[i](this, x); ++ } ++ return typeof value === "function" ? classedFunction : classedConstant; ++ } ++ function d3_selection_classedName(name) { ++ var re = d3_selection_classedRe(name); ++ return function(node, value) { ++ if (c = node.classList) return value ? c.add(name) : c.remove(name); ++ var c = node.getAttribute("class") || ""; ++ if (value) { ++ re.lastIndex = 0; ++ if (!re.test(c)) node.setAttribute("class", d3_collapse(c + " " + name)); ++ } else { ++ node.setAttribute("class", d3_collapse(c.replace(re, " "))); ++ } ++ }; ++ } ++ d3_selectionPrototype.style = function(name, value, priority) { ++ var n = arguments.length; ++ if (n < 3) { ++ if (typeof name !== "string") { ++ if (n < 2) value = ""; ++ for (priority in name) this.each(d3_selection_style(priority, name[priority], value)); ++ return this; ++ } ++ if (n < 2) { ++ var node = this.node(); ++ return d3_window(node).getComputedStyle(node, null).getPropertyValue(name); ++ } ++ priority = ""; ++ } ++ return this.each(d3_selection_style(name, value, priority)); ++ }; ++ function d3_selection_style(name, value, priority) { ++ function styleNull() { ++ this.style.removeProperty(name); ++ } ++ function styleConstant() { ++ this.style.setProperty(name, value, priority); ++ } ++ function styleFunction() { ++ var x = value.apply(this, arguments); ++ if (x == null) this.style.removeProperty(name); else this.style.setProperty(name, x, priority); ++ } ++ return value == null ? styleNull : typeof value === "function" ? styleFunction : styleConstant; ++ } ++ d3_selectionPrototype.property = function(name, value) { ++ if (arguments.length < 2) { ++ if (typeof name === "string") return this.node()[name]; ++ for (value in name) this.each(d3_selection_property(value, name[value])); ++ return this; ++ } ++ return this.each(d3_selection_property(name, value)); ++ }; ++ function d3_selection_property(name, value) { ++ function propertyNull() { ++ delete this[name]; ++ } ++ function propertyConstant() { ++ this[name] = value; ++ } ++ function propertyFunction() { ++ var x = value.apply(this, arguments); ++ if (x == null) delete this[name]; else this[name] = x; ++ } ++ return value == null ? propertyNull : typeof value === "function" ? propertyFunction : propertyConstant; ++ } ++ d3_selectionPrototype.text = function(value) { ++ return arguments.length ? this.each(typeof value === "function" ? function() { ++ var v = value.apply(this, arguments); ++ this.textContent = v == null ? "" : v; ++ } : value == null ? function() { ++ this.textContent = ""; ++ } : function() { ++ this.textContent = value; ++ }) : this.node().textContent; ++ }; ++ d3_selectionPrototype.html = function(value) { ++ return arguments.length ? this.each(typeof value === "function" ? function() { ++ var v = value.apply(this, arguments); ++ this.innerHTML = v == null ? "" : v; ++ } : value == null ? function() { ++ this.innerHTML = ""; ++ } : function() { ++ this.innerHTML = value; ++ }) : this.node().innerHTML; ++ }; ++ d3_selectionPrototype.append = function(name) { ++ name = d3_selection_creator(name); ++ return this.select(function() { ++ return this.appendChild(name.apply(this, arguments)); ++ }); ++ }; ++ function d3_selection_creator(name) { ++ function create() { ++ var document = this.ownerDocument, namespace = this.namespaceURI; ++ return namespace === d3_nsXhtml && document.documentElement.namespaceURI === d3_nsXhtml ? document.createElement(name) : document.createElementNS(namespace, name); ++ } ++ function createNS() { ++ return this.ownerDocument.createElementNS(name.space, name.local); ++ } ++ return typeof name === "function" ? name : (name = d3.ns.qualify(name)).local ? createNS : create; ++ } ++ d3_selectionPrototype.insert = function(name, before) { ++ name = d3_selection_creator(name); ++ before = d3_selection_selector(before); ++ return this.select(function() { ++ return this.insertBefore(name.apply(this, arguments), before.apply(this, arguments) || null); ++ }); ++ }; ++ d3_selectionPrototype.remove = function() { ++ return this.each(d3_selectionRemove); ++ }; ++ function d3_selectionRemove() { ++ var parent = this.parentNode; ++ if (parent) parent.removeChild(this); ++ } ++ d3_selectionPrototype.data = function(value, key) { ++ var i = -1, n = this.length, group, node; ++ if (!arguments.length) { ++ value = new Array(n = (group = this[0]).length); + while (++i < n) { +- if (values = valuesByKey.get(keyValue = key(object = array[i]))) { +- values.push(object); +- } else { +- valuesByKey.set(keyValue, [ object ]); ++ if (node = group[i]) { ++ value[i] = node.__data__; + } + } +- if (mapType) { +- object = mapType(); +- setter = function(keyValue, values) { +- object.set(keyValue, map(mapType, values, depth)); +- }; ++ return value; ++ } ++ function bind(group, groupData) { ++ var i, n = group.length, m = groupData.length, n0 = Math.min(n, m), updateNodes = new Array(m), enterNodes = new Array(m), exitNodes = new Array(n), node, nodeData; ++ if (key) { ++ var nodeByKeyValue = new d3_Map(), keyValues = new Array(n), keyValue; ++ for (i = -1; ++i < n; ) { ++ if (node = group[i]) { ++ if (nodeByKeyValue.has(keyValue = key.call(node, node.__data__, i))) { ++ exitNodes[i] = node; ++ } else { ++ nodeByKeyValue.set(keyValue, node); ++ } ++ keyValues[i] = keyValue; ++ } ++ } ++ for (i = -1; ++i < m; ) { ++ if (!(node = nodeByKeyValue.get(keyValue = key.call(groupData, nodeData = groupData[i], i)))) { ++ enterNodes[i] = d3_selection_dataNode(nodeData); ++ } else if (node !== true) { ++ updateNodes[i] = node; ++ node.__data__ = nodeData; ++ } ++ nodeByKeyValue.set(keyValue, true); ++ } ++ for (i = -1; ++i < n; ) { ++ if (i in keyValues && nodeByKeyValue.get(keyValues[i]) !== true) { ++ exitNodes[i] = group[i]; ++ } ++ } + } else { +- object = {}; +- setter = function(keyValue, values) { +- object[keyValue] = map(mapType, values, depth); +- }; ++ for (i = -1; ++i < n0; ) { ++ node = group[i]; ++ nodeData = groupData[i]; ++ if (node) { ++ node.__data__ = nodeData; ++ updateNodes[i] = node; ++ } else { ++ enterNodes[i] = d3_selection_dataNode(nodeData); ++ } ++ } ++ for (;i < m; ++i) { ++ enterNodes[i] = d3_selection_dataNode(groupData[i]); ++ } ++ for (;i < n; ++i) { ++ exitNodes[i] = group[i]; ++ } + } +- valuesByKey.forEach(setter); +- return object; ++ enterNodes.update = updateNodes; ++ enterNodes.parentNode = updateNodes.parentNode = exitNodes.parentNode = group.parentNode; ++ enter.push(enterNodes); ++ update.push(updateNodes); ++ exit.push(exitNodes); + } +- function entries(map, depth) { +- if (depth >= keys.length) return map; +- var array = [], sortKey = sortKeys[depth++]; +- map.forEach(function(key, keyMap) { +- array.push({ +- key: key, +- values: entries(keyMap, depth) +- }); +- }); +- return sortKey ? array.sort(function(a, b) { +- return sortKey(a.key, b.key); +- }) : array; ++ var enter = d3_selection_enter([]), update = d3_selection([]), exit = d3_selection([]); ++ if (typeof value === "function") { ++ while (++i < n) { ++ bind(group = this[i], value.call(group, group.parentNode.__data__, i)); ++ } ++ } else { ++ while (++i < n) { ++ bind(group = this[i], value); ++ } + } +- nest.map = function(array, mapType) { +- return map(mapType, array, 0); +- }; +- nest.entries = function(array) { +- return entries(map(d3.map, array, 0), 0); +- }; +- nest.key = function(d) { +- keys.push(d); +- return nest; +- }; +- nest.sortKeys = function(order) { +- sortKeys[keys.length - 1] = order; +- return nest; +- }; +- nest.sortValues = function(order) { +- sortValues = order; +- return nest; ++ update.enter = function() { ++ return enter; + }; +- nest.rollup = function(f) { +- rollup = f; +- return nest; ++ update.exit = function() { ++ return exit; + }; +- return nest; +- }; +- d3.set = function(array) { +- var set = new d3_Set(); +- if (array) for (var i = 0, n = array.length; i < n; ++i) set.add(array[i]); +- return set; +- }; +- function d3_Set() { +- this._ = Object.create(null); +- } +- d3_class(d3_Set, { +- has: d3_map_has, +- add: function(key) { +- this._[d3_map_escape(key += "")] = true; +- return key; +- }, +- remove: d3_map_remove, +- values: d3_map_keys, +- size: d3_map_size, +- empty: d3_map_empty, +- forEach: function(f) { +- for (var key in this._) f.call(this, d3_map_unescape(key)); +- } +- }); +- d3.behavior = {}; +- function d3_identity(d) { +- return d; +- } +- d3.rebind = function(target, source) { +- var i = 1, n = arguments.length, method; +- while (++i < n) target[method = arguments[i]] = d3_rebind(target, source, source[method]); +- return target; ++ return update; + }; +- function d3_rebind(target, source, method) { +- return function() { +- var value = method.apply(source, arguments); +- return value === source ? target : value; ++ function d3_selection_dataNode(data) { ++ return { ++ __data__: data + }; + } +- function d3_vendorSymbol(object, name) { +- if (name in object) return name; +- name = name.charAt(0).toUpperCase() + name.slice(1); +- for (var i = 0, n = d3_vendorPrefixes.length; i < n; ++i) { +- var prefixName = d3_vendorPrefixes[i] + name; +- if (prefixName in object) return prefixName; +- } +- } +- var d3_vendorPrefixes = [ "webkit", "ms", "moz", "Moz", "o", "O" ]; +- function d3_noop() {} +- d3.dispatch = function() { +- var dispatch = new d3_dispatch(), i = -1, n = arguments.length; +- while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch); +- return dispatch; ++ d3_selectionPrototype.datum = function(value) { ++ return arguments.length ? this.property("__data__", value) : this.property("__data__"); + }; +- function d3_dispatch() {} +- d3_dispatch.prototype.on = function(type, listener) { +- var i = type.indexOf("."), name = ""; +- if (i >= 0) { +- name = type.slice(i + 1); +- type = type.slice(0, i); +- } +- if (type) return arguments.length < 2 ? this[type].on(name) : this[type].on(name, listener); +- if (arguments.length === 2) { +- if (listener == null) for (type in this) { +- if (this.hasOwnProperty(type)) this[type].on(name, null); ++ d3_selectionPrototype.filter = function(filter) { ++ var subgroups = [], subgroup, group, node; ++ if (typeof filter !== "function") filter = d3_selection_filter(filter); ++ for (var j = 0, m = this.length; j < m; j++) { ++ subgroups.push(subgroup = []); ++ subgroup.parentNode = (group = this[j]).parentNode; ++ for (var i = 0, n = group.length; i < n; i++) { ++ if ((node = group[i]) && filter.call(node, node.__data__, i, j)) { ++ subgroup.push(node); ++ } + } +- return this; + } ++ return d3_selection(subgroups); + }; +- function d3_dispatch_event(dispatch) { +- var listeners = [], listenerByName = new d3_Map(); +- function event() { +- var z = listeners, i = -1, n = z.length, l; +- while (++i < n) if (l = z[i].on) l.apply(this, arguments); +- return dispatch; +- } +- event.on = function(name, listener) { +- var l = listenerByName.get(name), i; +- if (arguments.length < 2) return l && l.on; +- if (l) { +- l.on = null; +- listeners = listeners.slice(0, i = listeners.indexOf(l)).concat(listeners.slice(i + 1)); +- listenerByName.remove(name); +- } +- if (listener) listeners.push(listenerByName.set(name, { +- on: listener +- })); +- return dispatch; ++ function d3_selection_filter(selector) { ++ return function() { ++ return d3_selectMatches(this, selector); + }; +- return event; +- } +- d3.event = null; +- function d3_eventPreventDefault() { +- d3.event.preventDefault(); +- } +- function d3_eventSource() { +- var e = d3.event, s; +- while (s = e.sourceEvent) e = s; +- return e; + } +- function d3_eventDispatch(target) { +- var dispatch = new d3_dispatch(), i = 0, n = arguments.length; +- while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch); +- dispatch.of = function(thiz, argumentz) { +- return function(e1) { +- try { +- var e0 = e1.sourceEvent = d3.event; +- e1.target = target; +- d3.event = e1; +- dispatch[e1.type].apply(thiz, argumentz); +- } finally { +- d3.event = e0; ++ d3_selectionPrototype.order = function() { ++ for (var j = -1, m = this.length; ++j < m; ) { ++ for (var group = this[j], i = group.length - 1, next = group[i], node; --i >= 0; ) { ++ if (node = group[i]) { ++ if (next && next !== node.nextSibling) next.parentNode.insertBefore(node, next); ++ next = node; + } +- }; ++ } ++ } ++ return this; ++ }; ++ d3_selectionPrototype.sort = function(comparator) { ++ comparator = d3_selection_sortComparator.apply(this, arguments); ++ for (var j = -1, m = this.length; ++j < m; ) this[j].sort(comparator); ++ return this.order(); ++ }; ++ function d3_selection_sortComparator(comparator) { ++ if (!arguments.length) comparator = d3_ascending; ++ return function(a, b) { ++ return a && b ? comparator(a.__data__, b.__data__) : !a - !b; + }; +- return dispatch; + } +- d3.requote = function(s) { +- return s.replace(d3_requote_re, "\\$&"); +- }; +- var d3_requote_re = /[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g; +- var d3_subclass = {}.__proto__ ? function(object, prototype) { +- object.__proto__ = prototype; +- } : function(object, prototype) { +- for (var property in prototype) object[property] = prototype[property]; ++ d3_selectionPrototype.each = function(callback) { ++ return d3_selection_each(this, function(node, i, j) { ++ callback.call(node, node.__data__, i, j); ++ }); + }; +- function d3_selection(groups) { +- d3_subclass(groups, d3_selectionPrototype); ++ function d3_selection_each(groups, callback) { ++ for (var j = 0, m = groups.length; j < m; j++) { ++ for (var group = groups[j], i = 0, n = group.length, node; i < n; i++) { ++ if (node = group[i]) callback(node, i, j); ++ } ++ } + return groups; + } +- var d3_select = function(s, n) { +- return n.querySelector(s); +- }, d3_selectAll = function(s, n) { +- return n.querySelectorAll(s); +- }, d3_selectMatches = function(n, s) { +- var d3_selectMatcher = n.matches || n[d3_vendorSymbol(n, "matchesSelector")]; +- d3_selectMatches = function(n, s) { +- return d3_selectMatcher.call(n, s); +- }; +- return d3_selectMatches(n, s); ++ d3_selectionPrototype.call = function(callback) { ++ var args = d3_array(arguments); ++ callback.apply(args[0] = this, args); ++ return this; + }; +- if (typeof Sizzle === "function") { +- d3_select = function(s, n) { +- return Sizzle(s, n)[0] || null; +- }; +- d3_selectAll = Sizzle; +- d3_selectMatches = Sizzle.matchesSelector; +- } +- d3.selection = function() { +- return d3.select(d3_document.documentElement); ++ d3_selectionPrototype.empty = function() { ++ return !this.node(); + }; +- var d3_selectionPrototype = d3.selection.prototype = []; +- d3_selectionPrototype.select = function(selector) { +- var subgroups = [], subgroup, subnode, group, node; +- selector = d3_selection_selector(selector); ++ d3_selectionPrototype.node = function() { ++ for (var j = 0, m = this.length; j < m; j++) { ++ for (var group = this[j], i = 0, n = group.length; i < n; i++) { ++ var node = group[i]; ++ if (node) return node; ++ } ++ } ++ return null; ++ }; ++ d3_selectionPrototype.size = function() { ++ var n = 0; ++ d3_selection_each(this, function() { ++ ++n; ++ }); ++ return n; ++ }; ++ function d3_selection_enter(selection) { ++ d3_subclass(selection, d3_selection_enterPrototype); ++ return selection; ++ } ++ var d3_selection_enterPrototype = []; ++ d3.selection.enter = d3_selection_enter; ++ d3.selection.enter.prototype = d3_selection_enterPrototype; ++ d3_selection_enterPrototype.append = d3_selectionPrototype.append; ++ d3_selection_enterPrototype.empty = d3_selectionPrototype.empty; ++ d3_selection_enterPrototype.node = d3_selectionPrototype.node; ++ d3_selection_enterPrototype.call = d3_selectionPrototype.call; ++ d3_selection_enterPrototype.size = d3_selectionPrototype.size; ++ d3_selection_enterPrototype.select = function(selector) { ++ var subgroups = [], subgroup, subnode, upgroup, group, node; + for (var j = -1, m = this.length; ++j < m; ) { ++ upgroup = (group = this[j]).update; + subgroups.push(subgroup = []); +- subgroup.parentNode = (group = this[j]).parentNode; ++ subgroup.parentNode = group.parentNode; + for (var i = -1, n = group.length; ++i < n; ) { + if (node = group[i]) { +- subgroup.push(subnode = selector.call(node, node.__data__, i, j)); +- if (subnode && "__data__" in node) subnode.__data__ = node.__data__; ++ subgroup.push(upgroup[i] = subnode = selector.call(group.parentNode, node.__data__, i, j)); ++ subnode.__data__ = node.__data__; + } else { + subgroup.push(null); + } +@@ -12767,33077 +10959,35659 @@ module.exports = require("cwise-compiler") + } + return d3_selection(subgroups); + }; +- function d3_selection_selector(selector) { +- return typeof selector === "function" ? selector : function() { +- return d3_select(selector, this); ++ d3_selection_enterPrototype.insert = function(name, before) { ++ if (arguments.length < 2) before = d3_selection_enterInsertBefore(this); ++ return d3_selectionPrototype.insert.call(this, name, before); ++ }; ++ function d3_selection_enterInsertBefore(enter) { ++ var i0, j0; ++ return function(d, i, j) { ++ var group = enter[j].update, n = group.length, node; ++ if (j != j0) j0 = j, i0 = 0; ++ if (i >= i0) i0 = i + 1; ++ while (!(node = group[i0]) && ++i0 < n) ; ++ return node; + }; + } +- d3_selectionPrototype.selectAll = function(selector) { +- var subgroups = [], subgroup, node; +- selector = d3_selection_selectorAll(selector); +- for (var j = -1, m = this.length; ++j < m; ) { +- for (var group = this[j], i = -1, n = group.length; ++i < n; ) { +- if (node = group[i]) { +- subgroups.push(subgroup = d3_array(selector.call(node, node.__data__, i, j))); +- subgroup.parentNode = node; ++ d3.select = function(node) { ++ var group; ++ if (typeof node === "string") { ++ group = [ d3_select(node, d3_document) ]; ++ group.parentNode = d3_document.documentElement; ++ } else { ++ group = [ node ]; ++ group.parentNode = d3_documentElement(node); ++ } ++ return d3_selection([ group ]); ++ }; ++ d3.selectAll = function(nodes) { ++ var group; ++ if (typeof nodes === "string") { ++ group = d3_array(d3_selectAll(nodes, d3_document)); ++ group.parentNode = d3_document.documentElement; ++ } else { ++ group = d3_array(nodes); ++ group.parentNode = null; ++ } ++ return d3_selection([ group ]); ++ }; ++ d3_selectionPrototype.on = function(type, listener, capture) { ++ var n = arguments.length; ++ if (n < 3) { ++ if (typeof type !== "string") { ++ if (n < 2) listener = false; ++ for (capture in type) this.each(d3_selection_on(capture, type[capture], listener)); ++ return this; ++ } ++ if (n < 2) return (n = this.node()["__on" + type]) && n._; ++ capture = false; ++ } ++ return this.each(d3_selection_on(type, listener, capture)); ++ }; ++ function d3_selection_on(type, listener, capture) { ++ var name = "__on" + type, i = type.indexOf("."), wrap = d3_selection_onListener; ++ if (i > 0) type = type.slice(0, i); ++ var filter = d3_selection_onFilters.get(type); ++ if (filter) type = filter, wrap = d3_selection_onFilter; ++ function onRemove() { ++ var l = this[name]; ++ if (l) { ++ this.removeEventListener(type, l, l.$); ++ delete this[name]; ++ } ++ } ++ function onAdd() { ++ var l = wrap(listener, d3_array(arguments)); ++ onRemove.call(this); ++ this.addEventListener(type, this[name] = l, l.$ = capture); ++ l._ = listener; ++ } ++ function removeAll() { ++ var re = new RegExp("^__on([^.]+)" + d3.requote(type) + "$"), match; ++ for (var name in this) { ++ if (match = name.match(re)) { ++ var l = this[name]; ++ this.removeEventListener(match[1], l, l.$); ++ delete this[name]; ++ } ++ } ++ } ++ return i ? listener ? onAdd : onRemove : listener ? d3_noop : removeAll; ++ } ++ var d3_selection_onFilters = d3.map({ ++ mouseenter: "mouseover", ++ mouseleave: "mouseout" ++ }); ++ if (d3_document) { ++ d3_selection_onFilters.forEach(function(k) { ++ if ("on" + k in d3_document) d3_selection_onFilters.remove(k); ++ }); ++ } ++ function d3_selection_onListener(listener, argumentz) { ++ return function(e) { ++ var o = d3.event; ++ d3.event = e; ++ argumentz[0] = this.__data__; ++ try { ++ listener.apply(this, argumentz); ++ } finally { ++ d3.event = o; ++ } ++ }; ++ } ++ function d3_selection_onFilter(listener, argumentz) { ++ var l = d3_selection_onListener(listener, argumentz); ++ return function(e) { ++ var target = this, related = e.relatedTarget; ++ if (!related || related !== target && !(related.compareDocumentPosition(target) & 8)) { ++ l.call(target, e); ++ } ++ }; ++ } ++ var d3_event_dragSelect, d3_event_dragId = 0; ++ function d3_event_dragSuppress(node) { ++ var name = ".dragsuppress-" + ++d3_event_dragId, click = "click" + name, w = d3.select(d3_window(node)).on("touchmove" + name, d3_eventPreventDefault).on("dragstart" + name, d3_eventPreventDefault).on("selectstart" + name, d3_eventPreventDefault); ++ if (d3_event_dragSelect == null) { ++ d3_event_dragSelect = "onselectstart" in node ? false : d3_vendorSymbol(node.style, "userSelect"); ++ } ++ if (d3_event_dragSelect) { ++ var style = d3_documentElement(node).style, select = style[d3_event_dragSelect]; ++ style[d3_event_dragSelect] = "none"; ++ } ++ return function(suppressClick) { ++ w.on(name, null); ++ if (d3_event_dragSelect) style[d3_event_dragSelect] = select; ++ if (suppressClick) { ++ var off = function() { ++ w.on(click, null); ++ }; ++ w.on(click, function() { ++ d3_eventPreventDefault(); ++ off(); ++ }, true); ++ setTimeout(off, 0); ++ } ++ }; ++ } ++ d3.mouse = function(container) { ++ return d3_mousePoint(container, d3_eventSource()); ++ }; ++ var d3_mouse_bug44083 = this.navigator && /WebKit/.test(this.navigator.userAgent) ? -1 : 0; ++ function d3_mousePoint(container, e) { ++ if (e.changedTouches) e = e.changedTouches[0]; ++ var svg = container.ownerSVGElement || container; ++ if (svg.createSVGPoint) { ++ var point = svg.createSVGPoint(); ++ if (d3_mouse_bug44083 < 0) { ++ var window = d3_window(container); ++ if (window.scrollX || window.scrollY) { ++ svg = d3.select("body").append("svg").style({ ++ position: "absolute", ++ top: 0, ++ left: 0, ++ margin: 0, ++ padding: 0, ++ border: "none" ++ }, "important"); ++ var ctm = svg[0][0].getScreenCTM(); ++ d3_mouse_bug44083 = !(ctm.f || ctm.e); ++ svg.remove(); + } + } ++ if (d3_mouse_bug44083) point.x = e.pageX, point.y = e.pageY; else point.x = e.clientX, ++ point.y = e.clientY; ++ point = point.matrixTransform(container.getScreenCTM().inverse()); ++ return [ point.x, point.y ]; + } +- return d3_selection(subgroups); +- }; +- function d3_selection_selectorAll(selector) { +- return typeof selector === "function" ? selector : function() { +- return d3_selectAll(selector, this); +- }; ++ var rect = container.getBoundingClientRect(); ++ return [ e.clientX - rect.left - container.clientLeft, e.clientY - rect.top - container.clientTop ]; + } +- var d3_nsXhtml = "http://www.w3.org/1999/xhtml"; +- var d3_nsPrefix = { +- svg: "http://www.w3.org/2000/svg", +- xhtml: d3_nsXhtml, +- xlink: "http://www.w3.org/1999/xlink", +- xml: "http://www.w3.org/XML/1998/namespace", +- xmlns: "http://www.w3.org/2000/xmlns/" +- }; +- d3.ns = { +- prefix: d3_nsPrefix, +- qualify: function(name) { +- var i = name.indexOf(":"), prefix = name; +- if (i >= 0 && (prefix = name.slice(0, i)) !== "xmlns") name = name.slice(i + 1); +- return d3_nsPrefix.hasOwnProperty(prefix) ? { +- space: d3_nsPrefix[prefix], +- local: name +- } : name; +- } +- }; +- d3_selectionPrototype.attr = function(name, value) { +- if (arguments.length < 2) { +- if (typeof name === "string") { +- var node = this.node(); +- name = d3.ns.qualify(name); +- return name.local ? node.getAttributeNS(name.space, name.local) : node.getAttribute(name); ++ d3.touch = function(container, touches, identifier) { ++ if (arguments.length < 3) identifier = touches, touches = d3_eventSource().changedTouches; ++ if (touches) for (var i = 0, n = touches.length, touch; i < n; ++i) { ++ if ((touch = touches[i]).identifier === identifier) { ++ return d3_mousePoint(container, touch); + } +- for (value in name) this.each(d3_selection_attr(value, name[value])); +- return this; + } +- return this.each(d3_selection_attr(name, value)); + }; +- function d3_selection_attr(name, value) { +- name = d3.ns.qualify(name); +- function attrNull() { +- this.removeAttribute(name); +- } +- function attrNullNS() { +- this.removeAttributeNS(name.space, name.local); +- } +- function attrConstant() { +- this.setAttribute(name, value); +- } +- function attrConstantNS() { +- this.setAttributeNS(name.space, name.local, value); +- } +- function attrFunction() { +- var x = value.apply(this, arguments); +- if (x == null) this.removeAttribute(name); else this.setAttribute(name, x); +- } +- function attrFunctionNS() { +- var x = value.apply(this, arguments); +- if (x == null) this.removeAttributeNS(name.space, name.local); else this.setAttributeNS(name.space, name.local, x); ++ d3.behavior.drag = function() { ++ var event = d3_eventDispatch(drag, "drag", "dragstart", "dragend"), origin = null, mousedown = dragstart(d3_noop, d3.mouse, d3_window, "mousemove", "mouseup"), touchstart = dragstart(d3_behavior_dragTouchId, d3.touch, d3_identity, "touchmove", "touchend"); ++ function drag() { ++ this.on("mousedown.drag", mousedown).on("touchstart.drag", touchstart); + } +- return value == null ? name.local ? attrNullNS : attrNull : typeof value === "function" ? name.local ? attrFunctionNS : attrFunction : name.local ? attrConstantNS : attrConstant; +- } +- function d3_collapse(s) { +- return s.trim().replace(/\s+/g, " "); +- } +- d3_selectionPrototype.classed = function(name, value) { +- if (arguments.length < 2) { +- if (typeof name === "string") { +- var node = this.node(), n = (name = d3_selection_classes(name)).length, i = -1; +- if (value = node.classList) { +- while (++i < n) if (!value.contains(name[i])) return false; ++ function dragstart(id, position, subject, move, end) { ++ return function() { ++ var that = this, target = d3.event.target.correspondingElement || d3.event.target, parent = that.parentNode, dispatch = event.of(that, arguments), dragged = 0, dragId = id(), dragName = ".drag" + (dragId == null ? "" : "-" + dragId), dragOffset, dragSubject = d3.select(subject(target)).on(move + dragName, moved).on(end + dragName, ended), dragRestore = d3_event_dragSuppress(target), position0 = position(parent, dragId); ++ if (origin) { ++ dragOffset = origin.apply(that, arguments); ++ dragOffset = [ dragOffset.x - position0[0], dragOffset.y - position0[1] ]; + } else { +- value = node.getAttribute("class"); +- while (++i < n) if (!d3_selection_classedRe(name[i]).test(value)) return false; ++ dragOffset = [ 0, 0 ]; + } +- return true; +- } +- for (value in name) this.each(d3_selection_classed(value, name[value])); +- return this; ++ dispatch({ ++ type: "dragstart" ++ }); ++ function moved() { ++ var position1 = position(parent, dragId), dx, dy; ++ if (!position1) return; ++ dx = position1[0] - position0[0]; ++ dy = position1[1] - position0[1]; ++ dragged |= dx | dy; ++ position0 = position1; ++ dispatch({ ++ type: "drag", ++ x: position1[0] + dragOffset[0], ++ y: position1[1] + dragOffset[1], ++ dx: dx, ++ dy: dy ++ }); ++ } ++ function ended() { ++ if (!position(parent, dragId)) return; ++ dragSubject.on(move + dragName, null).on(end + dragName, null); ++ dragRestore(dragged); ++ dispatch({ ++ type: "dragend" ++ }); ++ } ++ }; + } +- return this.each(d3_selection_classed(name, value)); ++ drag.origin = function(x) { ++ if (!arguments.length) return origin; ++ origin = x; ++ return drag; ++ }; ++ return d3.rebind(drag, event, "on"); + }; +- function d3_selection_classedRe(name) { +- return new RegExp("(?:^|\\s+)" + d3.requote(name) + "(?:\\s+|$)", "g"); ++ function d3_behavior_dragTouchId() { ++ return d3.event.changedTouches[0].identifier; + } +- function d3_selection_classes(name) { +- return (name + "").trim().split(/^|\s+/); ++ d3.touches = function(container, touches) { ++ if (arguments.length < 2) touches = d3_eventSource().touches; ++ return touches ? d3_array(touches).map(function(touch) { ++ var point = d3_mousePoint(container, touch); ++ point.identifier = touch.identifier; ++ return point; ++ }) : []; ++ }; ++ var ε = 1e-6, ε2 = ε * ε, π = Math.PI, τ = 2 * π, τε = τ - ε, halfπ = π / 2, d3_radians = π / 180, d3_degrees = 180 / π; ++ function d3_sgn(x) { ++ return x > 0 ? 1 : x < 0 ? -1 : 0; + } +- function d3_selection_classed(name, value) { +- name = d3_selection_classes(name).map(d3_selection_classedName); +- var n = name.length; +- function classedConstant() { +- var i = -1; +- while (++i < n) name[i](this, value); +- } +- function classedFunction() { +- var i = -1, x = value.apply(this, arguments); +- while (++i < n) name[i](this, x); +- } +- return typeof value === "function" ? classedFunction : classedConstant; ++ function d3_cross2d(a, b, c) { ++ return (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]); + } +- function d3_selection_classedName(name) { +- var re = d3_selection_classedRe(name); +- return function(node, value) { +- if (c = node.classList) return value ? c.add(name) : c.remove(name); +- var c = node.getAttribute("class") || ""; +- if (value) { +- re.lastIndex = 0; +- if (!re.test(c)) node.setAttribute("class", d3_collapse(c + " " + name)); +- } else { +- node.setAttribute("class", d3_collapse(c.replace(re, " "))); +- } +- }; ++ function d3_acos(x) { ++ return x > 1 ? 0 : x < -1 ? π : Math.acos(x); + } +- d3_selectionPrototype.style = function(name, value, priority) { +- var n = arguments.length; +- if (n < 3) { +- if (typeof name !== "string") { +- if (n < 2) value = ""; +- for (priority in name) this.each(d3_selection_style(priority, name[priority], value)); +- return this; +- } +- if (n < 2) { +- var node = this.node(); +- return d3_window(node).getComputedStyle(node, null).getPropertyValue(name); +- } +- priority = ""; ++ function d3_asin(x) { ++ return x > 1 ? halfπ : x < -1 ? -halfπ : Math.asin(x); ++ } ++ function d3_sinh(x) { ++ return ((x = Math.exp(x)) - 1 / x) / 2; ++ } ++ function d3_cosh(x) { ++ return ((x = Math.exp(x)) + 1 / x) / 2; ++ } ++ function d3_tanh(x) { ++ return ((x = Math.exp(2 * x)) - 1) / (x + 1); ++ } ++ function d3_haversin(x) { ++ return (x = Math.sin(x / 2)) * x; ++ } ++ var ρ = Math.SQRT2, ρ2 = 2, ρ4 = 4; ++ d3.interpolateZoom = function(p0, p1) { ++ var ux0 = p0[0], uy0 = p0[1], w0 = p0[2], ux1 = p1[0], uy1 = p1[1], w1 = p1[2], dx = ux1 - ux0, dy = uy1 - uy0, d2 = dx * dx + dy * dy, i, S; ++ if (d2 < ε2) { ++ S = Math.log(w1 / w0) / ρ; ++ i = function(t) { ++ return [ ux0 + t * dx, uy0 + t * dy, w0 * Math.exp(ρ * t * S) ]; ++ }; ++ } else { ++ var d1 = Math.sqrt(d2), b0 = (w1 * w1 - w0 * w0 + ρ4 * d2) / (2 * w0 * ρ2 * d1), b1 = (w1 * w1 - w0 * w0 - ρ4 * d2) / (2 * w1 * ρ2 * d1), r0 = Math.log(Math.sqrt(b0 * b0 + 1) - b0), r1 = Math.log(Math.sqrt(b1 * b1 + 1) - b1); ++ S = (r1 - r0) / ρ; ++ i = function(t) { ++ var s = t * S, coshr0 = d3_cosh(r0), u = w0 / (ρ2 * d1) * (coshr0 * d3_tanh(ρ * s + r0) - d3_sinh(r0)); ++ return [ ux0 + u * dx, uy0 + u * dy, w0 * coshr0 / d3_cosh(ρ * s + r0) ]; ++ }; + } +- return this.each(d3_selection_style(name, value, priority)); ++ i.duration = S * 1e3; ++ return i; + }; +- function d3_selection_style(name, value, priority) { +- function styleNull() { +- this.style.removeProperty(name); ++ d3.behavior.zoom = function() { ++ var view = { ++ x: 0, ++ y: 0, ++ k: 1 ++ }, translate0, center0, center, size = [ 960, 500 ], scaleExtent = d3_behavior_zoomInfinity, duration = 250, zooming = 0, mousedown = "mousedown.zoom", mousemove = "mousemove.zoom", mouseup = "mouseup.zoom", mousewheelTimer, touchstart = "touchstart.zoom", touchtime, event = d3_eventDispatch(zoom, "zoomstart", "zoom", "zoomend"), x0, x1, y0, y1; ++ if (!d3_behavior_zoomWheel) { ++ d3_behavior_zoomWheel = "onwheel" in d3_document ? (d3_behavior_zoomDelta = function() { ++ return -d3.event.deltaY * (d3.event.deltaMode ? 120 : 1); ++ }, "wheel") : "onmousewheel" in d3_document ? (d3_behavior_zoomDelta = function() { ++ return d3.event.wheelDelta; ++ }, "mousewheel") : (d3_behavior_zoomDelta = function() { ++ return -d3.event.detail; ++ }, "MozMousePixelScroll"); + } +- function styleConstant() { +- this.style.setProperty(name, value, priority); ++ function zoom(g) { ++ g.on(mousedown, mousedowned).on(d3_behavior_zoomWheel + ".zoom", mousewheeled).on("dblclick.zoom", dblclicked).on(touchstart, touchstarted); + } +- function styleFunction() { +- var x = value.apply(this, arguments); +- if (x == null) this.style.removeProperty(name); else this.style.setProperty(name, x, priority); ++ zoom.event = function(g) { ++ g.each(function() { ++ var dispatch = event.of(this, arguments), view1 = view; ++ if (d3_transitionInheritId) { ++ d3.select(this).transition().each("start.zoom", function() { ++ view = this.__chart__ || { ++ x: 0, ++ y: 0, ++ k: 1 ++ }; ++ zoomstarted(dispatch); ++ }).tween("zoom:zoom", function() { ++ var dx = size[0], dy = size[1], cx = center0 ? center0[0] : dx / 2, cy = center0 ? center0[1] : dy / 2, i = d3.interpolateZoom([ (cx - view.x) / view.k, (cy - view.y) / view.k, dx / view.k ], [ (cx - view1.x) / view1.k, (cy - view1.y) / view1.k, dx / view1.k ]); ++ return function(t) { ++ var l = i(t), k = dx / l[2]; ++ this.__chart__ = view = { ++ x: cx - l[0] * k, ++ y: cy - l[1] * k, ++ k: k ++ }; ++ zoomed(dispatch); ++ }; ++ }).each("interrupt.zoom", function() { ++ zoomended(dispatch); ++ }).each("end.zoom", function() { ++ zoomended(dispatch); ++ }); ++ } else { ++ this.__chart__ = view; ++ zoomstarted(dispatch); ++ zoomed(dispatch); ++ zoomended(dispatch); ++ } ++ }); ++ }; ++ zoom.translate = function(_) { ++ if (!arguments.length) return [ view.x, view.y ]; ++ view = { ++ x: +_[0], ++ y: +_[1], ++ k: view.k ++ }; ++ rescale(); ++ return zoom; ++ }; ++ zoom.scale = function(_) { ++ if (!arguments.length) return view.k; ++ view = { ++ x: view.x, ++ y: view.y, ++ k: null ++ }; ++ scaleTo(+_); ++ rescale(); ++ return zoom; ++ }; ++ zoom.scaleExtent = function(_) { ++ if (!arguments.length) return scaleExtent; ++ scaleExtent = _ == null ? d3_behavior_zoomInfinity : [ +_[0], +_[1] ]; ++ return zoom; ++ }; ++ zoom.center = function(_) { ++ if (!arguments.length) return center; ++ center = _ && [ +_[0], +_[1] ]; ++ return zoom; ++ }; ++ zoom.size = function(_) { ++ if (!arguments.length) return size; ++ size = _ && [ +_[0], +_[1] ]; ++ return zoom; ++ }; ++ zoom.duration = function(_) { ++ if (!arguments.length) return duration; ++ duration = +_; ++ return zoom; ++ }; ++ zoom.x = function(z) { ++ if (!arguments.length) return x1; ++ x1 = z; ++ x0 = z.copy(); ++ view = { ++ x: 0, ++ y: 0, ++ k: 1 ++ }; ++ return zoom; ++ }; ++ zoom.y = function(z) { ++ if (!arguments.length) return y1; ++ y1 = z; ++ y0 = z.copy(); ++ view = { ++ x: 0, ++ y: 0, ++ k: 1 ++ }; ++ return zoom; ++ }; ++ function location(p) { ++ return [ (p[0] - view.x) / view.k, (p[1] - view.y) / view.k ]; + } +- return value == null ? styleNull : typeof value === "function" ? styleFunction : styleConstant; +- } +- d3_selectionPrototype.property = function(name, value) { +- if (arguments.length < 2) { +- if (typeof name === "string") return this.node()[name]; +- for (value in name) this.each(d3_selection_property(value, name[value])); +- return this; ++ function point(l) { ++ return [ l[0] * view.k + view.x, l[1] * view.k + view.y ]; + } +- return this.each(d3_selection_property(name, value)); +- }; +- function d3_selection_property(name, value) { +- function propertyNull() { +- delete this[name]; ++ function scaleTo(s) { ++ view.k = Math.max(scaleExtent[0], Math.min(scaleExtent[1], s)); + } +- function propertyConstant() { +- this[name] = value; ++ function translateTo(p, l) { ++ l = point(l); ++ view.x += p[0] - l[0]; ++ view.y += p[1] - l[1]; + } +- function propertyFunction() { +- var x = value.apply(this, arguments); +- if (x == null) delete this[name]; else this[name] = x; ++ function zoomTo(that, p, l, k) { ++ that.__chart__ = { ++ x: view.x, ++ y: view.y, ++ k: view.k ++ }; ++ scaleTo(Math.pow(2, k)); ++ translateTo(center0 = p, l); ++ that = d3.select(that); ++ if (duration > 0) that = that.transition().duration(duration); ++ that.call(zoom.event); + } +- return value == null ? propertyNull : typeof value === "function" ? propertyFunction : propertyConstant; +- } +- d3_selectionPrototype.text = function(value) { +- return arguments.length ? this.each(typeof value === "function" ? function() { +- var v = value.apply(this, arguments); +- this.textContent = v == null ? "" : v; +- } : value == null ? function() { +- this.textContent = ""; +- } : function() { +- this.textContent = value; +- }) : this.node().textContent; +- }; +- d3_selectionPrototype.html = function(value) { +- return arguments.length ? this.each(typeof value === "function" ? function() { +- var v = value.apply(this, arguments); +- this.innerHTML = v == null ? "" : v; +- } : value == null ? function() { +- this.innerHTML = ""; +- } : function() { +- this.innerHTML = value; +- }) : this.node().innerHTML; +- }; +- d3_selectionPrototype.append = function(name) { +- name = d3_selection_creator(name); +- return this.select(function() { +- return this.appendChild(name.apply(this, arguments)); +- }); +- }; +- function d3_selection_creator(name) { +- function create() { +- var document = this.ownerDocument, namespace = this.namespaceURI; +- return namespace === d3_nsXhtml && document.documentElement.namespaceURI === d3_nsXhtml ? document.createElement(name) : document.createElementNS(namespace, name); ++ function rescale() { ++ if (x1) x1.domain(x0.range().map(function(x) { ++ return (x - view.x) / view.k; ++ }).map(x0.invert)); ++ if (y1) y1.domain(y0.range().map(function(y) { ++ return (y - view.y) / view.k; ++ }).map(y0.invert)); + } +- function createNS() { +- return this.ownerDocument.createElementNS(name.space, name.local); ++ function zoomstarted(dispatch) { ++ if (!zooming++) dispatch({ ++ type: "zoomstart" ++ }); + } +- return typeof name === "function" ? name : (name = d3.ns.qualify(name)).local ? createNS : create; +- } +- d3_selectionPrototype.insert = function(name, before) { +- name = d3_selection_creator(name); +- before = d3_selection_selector(before); +- return this.select(function() { +- return this.insertBefore(name.apply(this, arguments), before.apply(this, arguments) || null); +- }); +- }; +- d3_selectionPrototype.remove = function() { +- return this.each(d3_selectionRemove); +- }; +- function d3_selectionRemove() { +- var parent = this.parentNode; +- if (parent) parent.removeChild(this); +- } +- d3_selectionPrototype.data = function(value, key) { +- var i = -1, n = this.length, group, node; +- if (!arguments.length) { +- value = new Array(n = (group = this[0]).length); +- while (++i < n) { +- if (node = group[i]) { +- value[i] = node.__data__; ++ function zoomed(dispatch) { ++ rescale(); ++ dispatch({ ++ type: "zoom", ++ scale: view.k, ++ translate: [ view.x, view.y ] ++ }); ++ } ++ function zoomended(dispatch) { ++ if (!--zooming) dispatch({ ++ type: "zoomend" ++ }), center0 = null; ++ } ++ function mousedowned() { ++ var that = this, dispatch = event.of(that, arguments), dragged = 0, subject = d3.select(d3_window(that)).on(mousemove, moved).on(mouseup, ended), location0 = location(d3.mouse(that)), dragRestore = d3_event_dragSuppress(that); ++ d3_selection_interrupt.call(that); ++ zoomstarted(dispatch); ++ function moved() { ++ dragged = 1; ++ translateTo(d3.mouse(that), location0); ++ zoomed(dispatch); ++ } ++ function ended() { ++ subject.on(mousemove, null).on(mouseup, null); ++ dragRestore(dragged); ++ zoomended(dispatch); ++ } ++ } ++ function touchstarted() { ++ var that = this, dispatch = event.of(that, arguments), locations0 = {}, distance0 = 0, scale0, zoomName = ".zoom-" + d3.event.changedTouches[0].identifier, touchmove = "touchmove" + zoomName, touchend = "touchend" + zoomName, targets = [], subject = d3.select(that), dragRestore = d3_event_dragSuppress(that); ++ started(); ++ zoomstarted(dispatch); ++ subject.on(mousedown, null).on(touchstart, started); ++ function relocate() { ++ var touches = d3.touches(that); ++ scale0 = view.k; ++ touches.forEach(function(t) { ++ if (t.identifier in locations0) locations0[t.identifier] = location(t); ++ }); ++ return touches; ++ } ++ function started() { ++ var target = d3.event.target; ++ d3.select(target).on(touchmove, moved).on(touchend, ended); ++ targets.push(target); ++ var changed = d3.event.changedTouches; ++ for (var i = 0, n = changed.length; i < n; ++i) { ++ locations0[changed[i].identifier] = null; ++ } ++ var touches = relocate(), now = Date.now(); ++ if (touches.length === 1) { ++ if (now - touchtime < 500) { ++ var p = touches[0]; ++ zoomTo(that, p, locations0[p.identifier], Math.floor(Math.log(view.k) / Math.LN2) + 1); ++ d3_eventPreventDefault(); ++ } ++ touchtime = now; ++ } else if (touches.length > 1) { ++ var p = touches[0], q = touches[1], dx = p[0] - q[0], dy = p[1] - q[1]; ++ distance0 = dx * dx + dy * dy; + } + } +- return value; +- } +- function bind(group, groupData) { +- var i, n = group.length, m = groupData.length, n0 = Math.min(n, m), updateNodes = new Array(m), enterNodes = new Array(m), exitNodes = new Array(n), node, nodeData; +- if (key) { +- var nodeByKeyValue = new d3_Map(), keyValues = new Array(n), keyValue; +- for (i = -1; ++i < n; ) { +- if (node = group[i]) { +- if (nodeByKeyValue.has(keyValue = key.call(node, node.__data__, i))) { +- exitNodes[i] = node; +- } else { +- nodeByKeyValue.set(keyValue, node); +- } +- keyValues[i] = keyValue; ++ function moved() { ++ var touches = d3.touches(that), p0, l0, p1, l1; ++ d3_selection_interrupt.call(that); ++ for (var i = 0, n = touches.length; i < n; ++i, l1 = null) { ++ p1 = touches[i]; ++ if (l1 = locations0[p1.identifier]) { ++ if (l0) break; ++ p0 = p1, l0 = l1; + } + } +- for (i = -1; ++i < m; ) { +- if (!(node = nodeByKeyValue.get(keyValue = key.call(groupData, nodeData = groupData[i], i)))) { +- enterNodes[i] = d3_selection_dataNode(nodeData); +- } else if (node !== true) { +- updateNodes[i] = node; +- node.__data__ = nodeData; +- } +- nodeByKeyValue.set(keyValue, true); ++ if (l1) { ++ var distance1 = (distance1 = p1[0] - p0[0]) * distance1 + (distance1 = p1[1] - p0[1]) * distance1, scale1 = distance0 && Math.sqrt(distance1 / distance0); ++ p0 = [ (p0[0] + p1[0]) / 2, (p0[1] + p1[1]) / 2 ]; ++ l0 = [ (l0[0] + l1[0]) / 2, (l0[1] + l1[1]) / 2 ]; ++ scaleTo(scale1 * scale0); + } +- for (i = -1; ++i < n; ) { +- if (i in keyValues && nodeByKeyValue.get(keyValues[i]) !== true) { +- exitNodes[i] = group[i]; ++ touchtime = null; ++ translateTo(p0, l0); ++ zoomed(dispatch); ++ } ++ function ended() { ++ if (d3.event.touches.length) { ++ var changed = d3.event.changedTouches; ++ for (var i = 0, n = changed.length; i < n; ++i) { ++ delete locations0[changed[i].identifier]; + } +- } +- } else { +- for (i = -1; ++i < n0; ) { +- node = group[i]; +- nodeData = groupData[i]; +- if (node) { +- node.__data__ = nodeData; +- updateNodes[i] = node; +- } else { +- enterNodes[i] = d3_selection_dataNode(nodeData); ++ for (var identifier in locations0) { ++ return void relocate(); + } + } +- for (;i < m; ++i) { +- enterNodes[i] = d3_selection_dataNode(groupData[i]); +- } +- for (;i < n; ++i) { +- exitNodes[i] = group[i]; +- } ++ d3.selectAll(targets).on(zoomName, null); ++ subject.on(mousedown, mousedowned).on(touchstart, touchstarted); ++ dragRestore(); ++ zoomended(dispatch); + } +- enterNodes.update = updateNodes; +- enterNodes.parentNode = updateNodes.parentNode = exitNodes.parentNode = group.parentNode; +- enter.push(enterNodes); +- update.push(updateNodes); +- exit.push(exitNodes); + } +- var enter = d3_selection_enter([]), update = d3_selection([]), exit = d3_selection([]); +- if (typeof value === "function") { +- while (++i < n) { +- bind(group = this[i], value.call(group, group.parentNode.__data__, i)); +- } +- } else { +- while (++i < n) { +- bind(group = this[i], value); +- } ++ function mousewheeled() { ++ var dispatch = event.of(this, arguments); ++ if (mousewheelTimer) clearTimeout(mousewheelTimer); else d3_selection_interrupt.call(this), ++ translate0 = location(center0 = center || d3.mouse(this)), zoomstarted(dispatch); ++ mousewheelTimer = setTimeout(function() { ++ mousewheelTimer = null; ++ zoomended(dispatch); ++ }, 50); ++ d3_eventPreventDefault(); ++ scaleTo(Math.pow(2, d3_behavior_zoomDelta() * .002) * view.k); ++ translateTo(center0, translate0); ++ zoomed(dispatch); + } +- update.enter = function() { +- return enter; +- }; +- update.exit = function() { +- return exit; +- }; +- return update; ++ function dblclicked() { ++ var p = d3.mouse(this), k = Math.log(view.k) / Math.LN2; ++ zoomTo(this, p, location(p), d3.event.shiftKey ? Math.ceil(k) - 1 : Math.floor(k) + 1); ++ } ++ return d3.rebind(zoom, event, "on"); + }; +- function d3_selection_dataNode(data) { +- return { +- __data__: data +- }; ++ var d3_behavior_zoomInfinity = [ 0, Infinity ], d3_behavior_zoomDelta, d3_behavior_zoomWheel; ++ d3.color = d3_color; ++ function d3_color() {} ++ d3_color.prototype.toString = function() { ++ return this.rgb() + ""; ++ }; ++ d3.hsl = d3_hsl; ++ function d3_hsl(h, s, l) { ++ return this instanceof d3_hsl ? void (this.h = +h, this.s = +s, this.l = +l) : arguments.length < 2 ? h instanceof d3_hsl ? new d3_hsl(h.h, h.s, h.l) : d3_rgb_parse("" + h, d3_rgb_hsl, d3_hsl) : new d3_hsl(h, s, l); + } +- d3_selectionPrototype.datum = function(value) { +- return arguments.length ? this.property("__data__", value) : this.property("__data__"); ++ var d3_hslPrototype = d3_hsl.prototype = new d3_color(); ++ d3_hslPrototype.brighter = function(k) { ++ k = Math.pow(.7, arguments.length ? k : 1); ++ return new d3_hsl(this.h, this.s, this.l / k); + }; +- d3_selectionPrototype.filter = function(filter) { +- var subgroups = [], subgroup, group, node; +- if (typeof filter !== "function") filter = d3_selection_filter(filter); +- for (var j = 0, m = this.length; j < m; j++) { +- subgroups.push(subgroup = []); +- subgroup.parentNode = (group = this[j]).parentNode; +- for (var i = 0, n = group.length; i < n; i++) { +- if ((node = group[i]) && filter.call(node, node.__data__, i, j)) { +- subgroup.push(node); +- } +- } +- } +- return d3_selection(subgroups); ++ d3_hslPrototype.darker = function(k) { ++ k = Math.pow(.7, arguments.length ? k : 1); ++ return new d3_hsl(this.h, this.s, k * this.l); + }; +- function d3_selection_filter(selector) { +- return function() { +- return d3_selectMatches(this, selector); +- }; +- } +- d3_selectionPrototype.order = function() { +- for (var j = -1, m = this.length; ++j < m; ) { +- for (var group = this[j], i = group.length - 1, next = group[i], node; --i >= 0; ) { +- if (node = group[i]) { +- if (next && next !== node.nextSibling) next.parentNode.insertBefore(node, next); +- next = node; +- } +- } ++ d3_hslPrototype.rgb = function() { ++ return d3_hsl_rgb(this.h, this.s, this.l); ++ }; ++ function d3_hsl_rgb(h, s, l) { ++ var m1, m2; ++ h = isNaN(h) ? 0 : (h %= 360) < 0 ? h + 360 : h; ++ s = isNaN(s) ? 0 : s < 0 ? 0 : s > 1 ? 1 : s; ++ l = l < 0 ? 0 : l > 1 ? 1 : l; ++ m2 = l <= .5 ? l * (1 + s) : l + s - l * s; ++ m1 = 2 * l - m2; ++ function v(h) { ++ if (h > 360) h -= 360; else if (h < 0) h += 360; ++ if (h < 60) return m1 + (m2 - m1) * h / 60; ++ if (h < 180) return m2; ++ if (h < 240) return m1 + (m2 - m1) * (240 - h) / 60; ++ return m1; + } +- return this; ++ function vv(h) { ++ return Math.round(v(h) * 255); ++ } ++ return new d3_rgb(vv(h + 120), vv(h), vv(h - 120)); ++ } ++ d3.hcl = d3_hcl; ++ function d3_hcl(h, c, l) { ++ return this instanceof d3_hcl ? void (this.h = +h, this.c = +c, this.l = +l) : arguments.length < 2 ? h instanceof d3_hcl ? new d3_hcl(h.h, h.c, h.l) : h instanceof d3_lab ? d3_lab_hcl(h.l, h.a, h.b) : d3_lab_hcl((h = d3_rgb_lab((h = d3.rgb(h)).r, h.g, h.b)).l, h.a, h.b) : new d3_hcl(h, c, l); ++ } ++ var d3_hclPrototype = d3_hcl.prototype = new d3_color(); ++ d3_hclPrototype.brighter = function(k) { ++ return new d3_hcl(this.h, this.c, Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1))); + }; +- d3_selectionPrototype.sort = function(comparator) { +- comparator = d3_selection_sortComparator.apply(this, arguments); +- for (var j = -1, m = this.length; ++j < m; ) this[j].sort(comparator); +- return this.order(); ++ d3_hclPrototype.darker = function(k) { ++ return new d3_hcl(this.h, this.c, Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1))); + }; +- function d3_selection_sortComparator(comparator) { +- if (!arguments.length) comparator = d3_ascending; +- return function(a, b) { +- return a && b ? comparator(a.__data__, b.__data__) : !a - !b; +- }; ++ d3_hclPrototype.rgb = function() { ++ return d3_hcl_lab(this.h, this.c, this.l).rgb(); ++ }; ++ function d3_hcl_lab(h, c, l) { ++ if (isNaN(h)) h = 0; ++ if (isNaN(c)) c = 0; ++ return new d3_lab(l, Math.cos(h *= d3_radians) * c, Math.sin(h) * c); + } +- d3_selectionPrototype.each = function(callback) { +- return d3_selection_each(this, function(node, i, j) { +- callback.call(node, node.__data__, i, j); +- }); ++ d3.lab = d3_lab; ++ function d3_lab(l, a, b) { ++ return this instanceof d3_lab ? void (this.l = +l, this.a = +a, this.b = +b) : arguments.length < 2 ? l instanceof d3_lab ? new d3_lab(l.l, l.a, l.b) : l instanceof d3_hcl ? d3_hcl_lab(l.h, l.c, l.l) : d3_rgb_lab((l = d3_rgb(l)).r, l.g, l.b) : new d3_lab(l, a, b); ++ } ++ var d3_lab_K = 18; ++ var d3_lab_X = .95047, d3_lab_Y = 1, d3_lab_Z = 1.08883; ++ var d3_labPrototype = d3_lab.prototype = new d3_color(); ++ d3_labPrototype.brighter = function(k) { ++ return new d3_lab(Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1)), this.a, this.b); + }; +- function d3_selection_each(groups, callback) { +- for (var j = 0, m = groups.length; j < m; j++) { +- for (var group = groups[j], i = 0, n = group.length, node; i < n; i++) { +- if (node = group[i]) callback(node, i, j); +- } +- } +- return groups; ++ d3_labPrototype.darker = function(k) { ++ return new d3_lab(Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1)), this.a, this.b); ++ }; ++ d3_labPrototype.rgb = function() { ++ return d3_lab_rgb(this.l, this.a, this.b); ++ }; ++ function d3_lab_rgb(l, a, b) { ++ var y = (l + 16) / 116, x = y + a / 500, z = y - b / 200; ++ x = d3_lab_xyz(x) * d3_lab_X; ++ y = d3_lab_xyz(y) * d3_lab_Y; ++ z = d3_lab_xyz(z) * d3_lab_Z; ++ return new d3_rgb(d3_xyz_rgb(3.2404542 * x - 1.5371385 * y - .4985314 * z), d3_xyz_rgb(-.969266 * x + 1.8760108 * y + .041556 * z), d3_xyz_rgb(.0556434 * x - .2040259 * y + 1.0572252 * z)); + } +- d3_selectionPrototype.call = function(callback) { +- var args = d3_array(arguments); +- callback.apply(args[0] = this, args); +- return this; ++ function d3_lab_hcl(l, a, b) { ++ return l > 0 ? new d3_hcl(Math.atan2(b, a) * d3_degrees, Math.sqrt(a * a + b * b), l) : new d3_hcl(NaN, NaN, l); ++ } ++ function d3_lab_xyz(x) { ++ return x > .206893034 ? x * x * x : (x - 4 / 29) / 7.787037; ++ } ++ function d3_xyz_lab(x) { ++ return x > .008856 ? Math.pow(x, 1 / 3) : 7.787037 * x + 4 / 29; ++ } ++ function d3_xyz_rgb(r) { ++ return Math.round(255 * (r <= .00304 ? 12.92 * r : 1.055 * Math.pow(r, 1 / 2.4) - .055)); ++ } ++ d3.rgb = d3_rgb; ++ function d3_rgb(r, g, b) { ++ return this instanceof d3_rgb ? void (this.r = ~~r, this.g = ~~g, this.b = ~~b) : arguments.length < 2 ? r instanceof d3_rgb ? new d3_rgb(r.r, r.g, r.b) : d3_rgb_parse("" + r, d3_rgb, d3_hsl_rgb) : new d3_rgb(r, g, b); ++ } ++ function d3_rgbNumber(value) { ++ return new d3_rgb(value >> 16, value >> 8 & 255, value & 255); ++ } ++ function d3_rgbString(value) { ++ return d3_rgbNumber(value) + ""; ++ } ++ var d3_rgbPrototype = d3_rgb.prototype = new d3_color(); ++ d3_rgbPrototype.brighter = function(k) { ++ k = Math.pow(.7, arguments.length ? k : 1); ++ var r = this.r, g = this.g, b = this.b, i = 30; ++ if (!r && !g && !b) return new d3_rgb(i, i, i); ++ if (r && r < i) r = i; ++ if (g && g < i) g = i; ++ if (b && b < i) b = i; ++ return new d3_rgb(Math.min(255, r / k), Math.min(255, g / k), Math.min(255, b / k)); + }; +- d3_selectionPrototype.empty = function() { +- return !this.node(); ++ d3_rgbPrototype.darker = function(k) { ++ k = Math.pow(.7, arguments.length ? k : 1); ++ return new d3_rgb(k * this.r, k * this.g, k * this.b); + }; +- d3_selectionPrototype.node = function() { +- for (var j = 0, m = this.length; j < m; j++) { +- for (var group = this[j], i = 0, n = group.length; i < n; i++) { +- var node = group[i]; +- if (node) return node; +- } +- } +- return null; ++ d3_rgbPrototype.hsl = function() { ++ return d3_rgb_hsl(this.r, this.g, this.b); + }; +- d3_selectionPrototype.size = function() { +- var n = 0; +- d3_selection_each(this, function() { +- ++n; +- }); +- return n; ++ d3_rgbPrototype.toString = function() { ++ return "#" + d3_rgb_hex(this.r) + d3_rgb_hex(this.g) + d3_rgb_hex(this.b); + }; +- function d3_selection_enter(selection) { +- d3_subclass(selection, d3_selection_enterPrototype); +- return selection; ++ function d3_rgb_hex(v) { ++ return v < 16 ? "0" + Math.max(0, v).toString(16) : Math.min(255, v).toString(16); ++ } ++ function d3_rgb_parse(format, rgb, hsl) { ++ var r = 0, g = 0, b = 0, m1, m2, color; ++ m1 = /([a-z]+)\((.*)\)/.exec(format = format.toLowerCase()); ++ if (m1) { ++ m2 = m1[2].split(","); ++ switch (m1[1]) { ++ case "hsl": ++ { ++ return hsl(parseFloat(m2[0]), parseFloat(m2[1]) / 100, parseFloat(m2[2]) / 100); ++ } ++ ++ case "rgb": ++ { ++ return rgb(d3_rgb_parseNumber(m2[0]), d3_rgb_parseNumber(m2[1]), d3_rgb_parseNumber(m2[2])); ++ } ++ } ++ } ++ if (color = d3_rgb_names.get(format)) { ++ return rgb(color.r, color.g, color.b); ++ } ++ if (format != null && format.charAt(0) === "#" && !isNaN(color = parseInt(format.slice(1), 16))) { ++ if (format.length === 4) { ++ r = (color & 3840) >> 4; ++ r = r >> 4 | r; ++ g = color & 240; ++ g = g >> 4 | g; ++ b = color & 15; ++ b = b << 4 | b; ++ } else if (format.length === 7) { ++ r = (color & 16711680) >> 16; ++ g = (color & 65280) >> 8; ++ b = color & 255; ++ } ++ } ++ return rgb(r, g, b); ++ } ++ function d3_rgb_hsl(r, g, b) { ++ var min = Math.min(r /= 255, g /= 255, b /= 255), max = Math.max(r, g, b), d = max - min, h, s, l = (max + min) / 2; ++ if (d) { ++ s = l < .5 ? d / (max + min) : d / (2 - max - min); ++ if (r == max) h = (g - b) / d + (g < b ? 6 : 0); else if (g == max) h = (b - r) / d + 2; else h = (r - g) / d + 4; ++ h *= 60; ++ } else { ++ h = NaN; ++ s = l > 0 && l < 1 ? 0 : h; ++ } ++ return new d3_hsl(h, s, l); ++ } ++ function d3_rgb_lab(r, g, b) { ++ r = d3_rgb_xyz(r); ++ g = d3_rgb_xyz(g); ++ b = d3_rgb_xyz(b); ++ var x = d3_xyz_lab((.4124564 * r + .3575761 * g + .1804375 * b) / d3_lab_X), y = d3_xyz_lab((.2126729 * r + .7151522 * g + .072175 * b) / d3_lab_Y), z = d3_xyz_lab((.0193339 * r + .119192 * g + .9503041 * b) / d3_lab_Z); ++ return d3_lab(116 * y - 16, 500 * (x - y), 200 * (y - z)); ++ } ++ function d3_rgb_xyz(r) { ++ return (r /= 255) <= .04045 ? r / 12.92 : Math.pow((r + .055) / 1.055, 2.4); ++ } ++ function d3_rgb_parseNumber(c) { ++ var f = parseFloat(c); ++ return c.charAt(c.length - 1) === "%" ? Math.round(f * 2.55) : f; ++ } ++ var d3_rgb_names = d3.map({ ++ aliceblue: 15792383, ++ antiquewhite: 16444375, ++ aqua: 65535, ++ aquamarine: 8388564, ++ azure: 15794175, ++ beige: 16119260, ++ bisque: 16770244, ++ black: 0, ++ blanchedalmond: 16772045, ++ blue: 255, ++ blueviolet: 9055202, ++ brown: 10824234, ++ burlywood: 14596231, ++ cadetblue: 6266528, ++ chartreuse: 8388352, ++ chocolate: 13789470, ++ coral: 16744272, ++ cornflowerblue: 6591981, ++ cornsilk: 16775388, ++ crimson: 14423100, ++ cyan: 65535, ++ darkblue: 139, ++ darkcyan: 35723, ++ darkgoldenrod: 12092939, ++ darkgray: 11119017, ++ darkgreen: 25600, ++ darkgrey: 11119017, ++ darkkhaki: 12433259, ++ darkmagenta: 9109643, ++ darkolivegreen: 5597999, ++ darkorange: 16747520, ++ darkorchid: 10040012, ++ darkred: 9109504, ++ darksalmon: 15308410, ++ darkseagreen: 9419919, ++ darkslateblue: 4734347, ++ darkslategray: 3100495, ++ darkslategrey: 3100495, ++ darkturquoise: 52945, ++ darkviolet: 9699539, ++ deeppink: 16716947, ++ deepskyblue: 49151, ++ dimgray: 6908265, ++ dimgrey: 6908265, ++ dodgerblue: 2003199, ++ firebrick: 11674146, ++ floralwhite: 16775920, ++ forestgreen: 2263842, ++ fuchsia: 16711935, ++ gainsboro: 14474460, ++ ghostwhite: 16316671, ++ gold: 16766720, ++ goldenrod: 14329120, ++ gray: 8421504, ++ green: 32768, ++ greenyellow: 11403055, ++ grey: 8421504, ++ honeydew: 15794160, ++ hotpink: 16738740, ++ indianred: 13458524, ++ indigo: 4915330, ++ ivory: 16777200, ++ khaki: 15787660, ++ lavender: 15132410, ++ lavenderblush: 16773365, ++ lawngreen: 8190976, ++ lemonchiffon: 16775885, ++ lightblue: 11393254, ++ lightcoral: 15761536, ++ lightcyan: 14745599, ++ lightgoldenrodyellow: 16448210, ++ lightgray: 13882323, ++ lightgreen: 9498256, ++ lightgrey: 13882323, ++ lightpink: 16758465, ++ lightsalmon: 16752762, ++ lightseagreen: 2142890, ++ lightskyblue: 8900346, ++ lightslategray: 7833753, ++ lightslategrey: 7833753, ++ lightsteelblue: 11584734, ++ lightyellow: 16777184, ++ lime: 65280, ++ limegreen: 3329330, ++ linen: 16445670, ++ magenta: 16711935, ++ maroon: 8388608, ++ mediumaquamarine: 6737322, ++ mediumblue: 205, ++ mediumorchid: 12211667, ++ mediumpurple: 9662683, ++ mediumseagreen: 3978097, ++ mediumslateblue: 8087790, ++ mediumspringgreen: 64154, ++ mediumturquoise: 4772300, ++ mediumvioletred: 13047173, ++ midnightblue: 1644912, ++ mintcream: 16121850, ++ mistyrose: 16770273, ++ moccasin: 16770229, ++ navajowhite: 16768685, ++ navy: 128, ++ oldlace: 16643558, ++ olive: 8421376, ++ olivedrab: 7048739, ++ orange: 16753920, ++ orangered: 16729344, ++ orchid: 14315734, ++ palegoldenrod: 15657130, ++ palegreen: 10025880, ++ paleturquoise: 11529966, ++ palevioletred: 14381203, ++ papayawhip: 16773077, ++ peachpuff: 16767673, ++ peru: 13468991, ++ pink: 16761035, ++ plum: 14524637, ++ powderblue: 11591910, ++ purple: 8388736, ++ rebeccapurple: 6697881, ++ red: 16711680, ++ rosybrown: 12357519, ++ royalblue: 4286945, ++ saddlebrown: 9127187, ++ salmon: 16416882, ++ sandybrown: 16032864, ++ seagreen: 3050327, ++ seashell: 16774638, ++ sienna: 10506797, ++ silver: 12632256, ++ skyblue: 8900331, ++ slateblue: 6970061, ++ slategray: 7372944, ++ slategrey: 7372944, ++ snow: 16775930, ++ springgreen: 65407, ++ steelblue: 4620980, ++ tan: 13808780, ++ teal: 32896, ++ thistle: 14204888, ++ tomato: 16737095, ++ turquoise: 4251856, ++ violet: 15631086, ++ wheat: 16113331, ++ white: 16777215, ++ whitesmoke: 16119285, ++ yellow: 16776960, ++ yellowgreen: 10145074 ++ }); ++ d3_rgb_names.forEach(function(key, value) { ++ d3_rgb_names.set(key, d3_rgbNumber(value)); ++ }); ++ function d3_functor(v) { ++ return typeof v === "function" ? v : function() { ++ return v; ++ }; + } +- var d3_selection_enterPrototype = []; +- d3.selection.enter = d3_selection_enter; +- d3.selection.enter.prototype = d3_selection_enterPrototype; +- d3_selection_enterPrototype.append = d3_selectionPrototype.append; +- d3_selection_enterPrototype.empty = d3_selectionPrototype.empty; +- d3_selection_enterPrototype.node = d3_selectionPrototype.node; +- d3_selection_enterPrototype.call = d3_selectionPrototype.call; +- d3_selection_enterPrototype.size = d3_selectionPrototype.size; +- d3_selection_enterPrototype.select = function(selector) { +- var subgroups = [], subgroup, subnode, upgroup, group, node; +- for (var j = -1, m = this.length; ++j < m; ) { +- upgroup = (group = this[j]).update; +- subgroups.push(subgroup = []); +- subgroup.parentNode = group.parentNode; +- for (var i = -1, n = group.length; ++i < n; ) { +- if (node = group[i]) { +- subgroup.push(upgroup[i] = subnode = selector.call(group.parentNode, node.__data__, i, j)); +- subnode.__data__ = node.__data__; +- } else { +- subgroup.push(null); +- } +- } +- } +- return d3_selection(subgroups); +- }; +- d3_selection_enterPrototype.insert = function(name, before) { +- if (arguments.length < 2) before = d3_selection_enterInsertBefore(this); +- return d3_selectionPrototype.insert.call(this, name, before); +- }; +- function d3_selection_enterInsertBefore(enter) { +- var i0, j0; +- return function(d, i, j) { +- var group = enter[j].update, n = group.length, node; +- if (j != j0) j0 = j, i0 = 0; +- if (i >= i0) i0 = i + 1; +- while (!(node = group[i0]) && ++i0 < n) ; +- return node; ++ d3.functor = d3_functor; ++ d3.xhr = d3_xhrType(d3_identity); ++ function d3_xhrType(response) { ++ return function(url, mimeType, callback) { ++ if (arguments.length === 2 && typeof mimeType === "function") callback = mimeType, ++ mimeType = null; ++ return d3_xhr(url, mimeType, response, callback); + }; + } +- d3.select = function(node) { +- var group; +- if (typeof node === "string") { +- group = [ d3_select(node, d3_document) ]; +- group.parentNode = d3_document.documentElement; +- } else { +- group = [ node ]; +- group.parentNode = d3_documentElement(node); +- } +- return d3_selection([ group ]); +- }; +- d3.selectAll = function(nodes) { +- var group; +- if (typeof nodes === "string") { +- group = d3_array(d3_selectAll(nodes, d3_document)); +- group.parentNode = d3_document.documentElement; +- } else { +- group = d3_array(nodes); +- group.parentNode = null; +- } +- return d3_selection([ group ]); +- }; +- d3_selectionPrototype.on = function(type, listener, capture) { +- var n = arguments.length; +- if (n < 3) { +- if (typeof type !== "string") { +- if (n < 2) listener = false; +- for (capture in type) this.each(d3_selection_on(capture, type[capture], listener)); +- return this; +- } +- if (n < 2) return (n = this.node()["__on" + type]) && n._; +- capture = false; +- } +- return this.each(d3_selection_on(type, listener, capture)); +- }; +- function d3_selection_on(type, listener, capture) { +- var name = "__on" + type, i = type.indexOf("."), wrap = d3_selection_onListener; +- if (i > 0) type = type.slice(0, i); +- var filter = d3_selection_onFilters.get(type); +- if (filter) type = filter, wrap = d3_selection_onFilter; +- function onRemove() { +- var l = this[name]; +- if (l) { +- this.removeEventListener(type, l, l.$); +- delete this[name]; +- } +- } +- function onAdd() { +- var l = wrap(listener, d3_array(arguments)); +- onRemove.call(this); +- this.addEventListener(type, this[name] = l, l.$ = capture); +- l._ = listener; +- } +- function removeAll() { +- var re = new RegExp("^__on([^.]+)" + d3.requote(type) + "$"), match; +- for (var name in this) { +- if (match = name.match(re)) { +- var l = this[name]; +- this.removeEventListener(match[1], l, l.$); +- delete this[name]; ++ function d3_xhr(url, mimeType, response, callback) { ++ var xhr = {}, dispatch = d3.dispatch("beforesend", "progress", "load", "error"), headers = {}, request = new XMLHttpRequest(), responseType = null; ++ if (this.XDomainRequest && !("withCredentials" in request) && /^(http(s)?:)?\/\//.test(url)) request = new XDomainRequest(); ++ "onload" in request ? request.onload = request.onerror = respond : request.onreadystatechange = function() { ++ request.readyState > 3 && respond(); ++ }; ++ function respond() { ++ var status = request.status, result; ++ if (!status && d3_xhrHasResponse(request) || status >= 200 && status < 300 || status === 304) { ++ try { ++ result = response.call(xhr, request); ++ } catch (e) { ++ dispatch.error.call(xhr, e); ++ return; + } ++ dispatch.load.call(xhr, result); ++ } else { ++ dispatch.error.call(xhr, request); + } + } +- return i ? listener ? onAdd : onRemove : listener ? d3_noop : removeAll; +- } +- var d3_selection_onFilters = d3.map({ +- mouseenter: "mouseover", +- mouseleave: "mouseout" +- }); +- if (d3_document) { +- d3_selection_onFilters.forEach(function(k) { +- if ("on" + k in d3_document) d3_selection_onFilters.remove(k); +- }); +- } +- function d3_selection_onListener(listener, argumentz) { +- return function(e) { ++ request.onprogress = function(event) { + var o = d3.event; +- d3.event = e; +- argumentz[0] = this.__data__; ++ d3.event = event; + try { +- listener.apply(this, argumentz); ++ dispatch.progress.call(xhr, request); + } finally { + d3.event = o; + } + }; +- } +- function d3_selection_onFilter(listener, argumentz) { +- var l = d3_selection_onListener(listener, argumentz); +- return function(e) { +- var target = this, related = e.relatedTarget; +- if (!related || related !== target && !(related.compareDocumentPosition(target) & 8)) { +- l.call(target, e); +- } ++ xhr.header = function(name, value) { ++ name = (name + "").toLowerCase(); ++ if (arguments.length < 2) return headers[name]; ++ if (value == null) delete headers[name]; else headers[name] = value + ""; ++ return xhr; + }; +- } +- var d3_event_dragSelect, d3_event_dragId = 0; +- function d3_event_dragSuppress(node) { +- var name = ".dragsuppress-" + ++d3_event_dragId, click = "click" + name, w = d3.select(d3_window(node)).on("touchmove" + name, d3_eventPreventDefault).on("dragstart" + name, d3_eventPreventDefault).on("selectstart" + name, d3_eventPreventDefault); +- if (d3_event_dragSelect == null) { +- d3_event_dragSelect = "onselectstart" in node ? false : d3_vendorSymbol(node.style, "userSelect"); +- } +- if (d3_event_dragSelect) { +- var style = d3_documentElement(node).style, select = style[d3_event_dragSelect]; +- style[d3_event_dragSelect] = "none"; +- } +- return function(suppressClick) { +- w.on(name, null); +- if (d3_event_dragSelect) style[d3_event_dragSelect] = select; +- if (suppressClick) { +- var off = function() { +- w.on(click, null); +- }; +- w.on(click, function() { +- d3_eventPreventDefault(); +- off(); +- }, true); +- setTimeout(off, 0); +- } ++ xhr.mimeType = function(value) { ++ if (!arguments.length) return mimeType; ++ mimeType = value == null ? null : value + ""; ++ return xhr; + }; +- } +- d3.mouse = function(container) { +- return d3_mousePoint(container, d3_eventSource()); +- }; +- var d3_mouse_bug44083 = this.navigator && /WebKit/.test(this.navigator.userAgent) ? -1 : 0; +- function d3_mousePoint(container, e) { +- if (e.changedTouches) e = e.changedTouches[0]; +- var svg = container.ownerSVGElement || container; +- if (svg.createSVGPoint) { +- var point = svg.createSVGPoint(); +- if (d3_mouse_bug44083 < 0) { +- var window = d3_window(container); +- if (window.scrollX || window.scrollY) { +- svg = d3.select("body").append("svg").style({ +- position: "absolute", +- top: 0, +- left: 0, +- margin: 0, +- padding: 0, +- border: "none" +- }, "important"); +- var ctm = svg[0][0].getScreenCTM(); +- d3_mouse_bug44083 = !(ctm.f || ctm.e); +- svg.remove(); +- } +- } +- if (d3_mouse_bug44083) point.x = e.pageX, point.y = e.pageY; else point.x = e.clientX, +- point.y = e.clientY; +- point = point.matrixTransform(container.getScreenCTM().inverse()); +- return [ point.x, point.y ]; +- } +- var rect = container.getBoundingClientRect(); +- return [ e.clientX - rect.left - container.clientLeft, e.clientY - rect.top - container.clientTop ]; +- } +- d3.touch = function(container, touches, identifier) { +- if (arguments.length < 3) identifier = touches, touches = d3_eventSource().changedTouches; +- if (touches) for (var i = 0, n = touches.length, touch; i < n; ++i) { +- if ((touch = touches[i]).identifier === identifier) { +- return d3_mousePoint(container, touch); +- } +- } +- }; +- d3.behavior.drag = function() { +- var event = d3_eventDispatch(drag, "drag", "dragstart", "dragend"), origin = null, mousedown = dragstart(d3_noop, d3.mouse, d3_window, "mousemove", "mouseup"), touchstart = dragstart(d3_behavior_dragTouchId, d3.touch, d3_identity, "touchmove", "touchend"); +- function drag() { +- this.on("mousedown.drag", mousedown).on("touchstart.drag", touchstart); +- } +- function dragstart(id, position, subject, move, end) { +- return function() { +- var that = this, target = d3.event.target.correspondingElement || d3.event.target, parent = that.parentNode, dispatch = event.of(that, arguments), dragged = 0, dragId = id(), dragName = ".drag" + (dragId == null ? "" : "-" + dragId), dragOffset, dragSubject = d3.select(subject(target)).on(move + dragName, moved).on(end + dragName, ended), dragRestore = d3_event_dragSuppress(target), position0 = position(parent, dragId); +- if (origin) { +- dragOffset = origin.apply(that, arguments); +- dragOffset = [ dragOffset.x - position0[0], dragOffset.y - position0[1] ]; +- } else { +- dragOffset = [ 0, 0 ]; +- } +- dispatch({ +- type: "dragstart" +- }); +- function moved() { +- var position1 = position(parent, dragId), dx, dy; +- if (!position1) return; +- dx = position1[0] - position0[0]; +- dy = position1[1] - position0[1]; +- dragged |= dx | dy; +- position0 = position1; +- dispatch({ +- type: "drag", +- x: position1[0] + dragOffset[0], +- y: position1[1] + dragOffset[1], +- dx: dx, +- dy: dy +- }); +- } +- function ended() { +- if (!position(parent, dragId)) return; +- dragSubject.on(move + dragName, null).on(end + dragName, null); +- dragRestore(dragged); +- dispatch({ +- type: "dragend" +- }); +- } ++ xhr.responseType = function(value) { ++ if (!arguments.length) return responseType; ++ responseType = value; ++ return xhr; ++ }; ++ xhr.response = function(value) { ++ response = value; ++ return xhr; ++ }; ++ [ "get", "post" ].forEach(function(method) { ++ xhr[method] = function() { ++ return xhr.send.apply(xhr, [ method ].concat(d3_array(arguments))); + }; +- } +- drag.origin = function(x) { +- if (!arguments.length) return origin; +- origin = x; +- return drag; ++ }); ++ xhr.send = function(method, data, callback) { ++ if (arguments.length === 2 && typeof data === "function") callback = data, data = null; ++ request.open(method, url, true); ++ if (mimeType != null && !("accept" in headers)) headers["accept"] = mimeType + ",*/*"; ++ if (request.setRequestHeader) for (var name in headers) request.setRequestHeader(name, headers[name]); ++ if (mimeType != null && request.overrideMimeType) request.overrideMimeType(mimeType); ++ if (responseType != null) request.responseType = responseType; ++ if (callback != null) xhr.on("error", callback).on("load", function(request) { ++ callback(null, request); ++ }); ++ dispatch.beforesend.call(xhr, request); ++ request.send(data == null ? null : data); ++ return xhr; + }; +- return d3.rebind(drag, event, "on"); +- }; +- function d3_behavior_dragTouchId() { +- return d3.event.changedTouches[0].identifier; +- } +- d3.touches = function(container, touches) { +- if (arguments.length < 2) touches = d3_eventSource().touches; +- return touches ? d3_array(touches).map(function(touch) { +- var point = d3_mousePoint(container, touch); +- point.identifier = touch.identifier; +- return point; +- }) : []; +- }; +- var ε = 1e-6, ε2 = ε * ε, π = Math.PI, τ = 2 * π, τε = τ - ε, halfπ = π / 2, d3_radians = π / 180, d3_degrees = 180 / π; +- function d3_sgn(x) { +- return x > 0 ? 1 : x < 0 ? -1 : 0; +- } +- function d3_cross2d(a, b, c) { +- return (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]); +- } +- function d3_acos(x) { +- return x > 1 ? 0 : x < -1 ? π : Math.acos(x); +- } +- function d3_asin(x) { +- return x > 1 ? halfπ : x < -1 ? -halfπ : Math.asin(x); +- } +- function d3_sinh(x) { +- return ((x = Math.exp(x)) - 1 / x) / 2; +- } +- function d3_cosh(x) { +- return ((x = Math.exp(x)) + 1 / x) / 2; ++ xhr.abort = function() { ++ request.abort(); ++ return xhr; ++ }; ++ d3.rebind(xhr, dispatch, "on"); ++ return callback == null ? xhr : xhr.get(d3_xhr_fixCallback(callback)); + } +- function d3_tanh(x) { +- return ((x = Math.exp(2 * x)) - 1) / (x + 1); ++ function d3_xhr_fixCallback(callback) { ++ return callback.length === 1 ? function(error, request) { ++ callback(error == null ? request : null); ++ } : callback; + } +- function d3_haversin(x) { +- return (x = Math.sin(x / 2)) * x; ++ function d3_xhrHasResponse(request) { ++ var type = request.responseType; ++ return type && type !== "text" ? request.response : request.responseText; + } +- var ρ = Math.SQRT2, ρ2 = 2, ρ4 = 4; +- d3.interpolateZoom = function(p0, p1) { +- var ux0 = p0[0], uy0 = p0[1], w0 = p0[2], ux1 = p1[0], uy1 = p1[1], w1 = p1[2], dx = ux1 - ux0, dy = uy1 - uy0, d2 = dx * dx + dy * dy, i, S; +- if (d2 < ε2) { +- S = Math.log(w1 / w0) / ρ; +- i = function(t) { +- return [ ux0 + t * dx, uy0 + t * dy, w0 * Math.exp(ρ * t * S) ]; +- }; +- } else { +- var d1 = Math.sqrt(d2), b0 = (w1 * w1 - w0 * w0 + ρ4 * d2) / (2 * w0 * ρ2 * d1), b1 = (w1 * w1 - w0 * w0 - ρ4 * d2) / (2 * w1 * ρ2 * d1), r0 = Math.log(Math.sqrt(b0 * b0 + 1) - b0), r1 = Math.log(Math.sqrt(b1 * b1 + 1) - b1); +- S = (r1 - r0) / ρ; +- i = function(t) { +- var s = t * S, coshr0 = d3_cosh(r0), u = w0 / (ρ2 * d1) * (coshr0 * d3_tanh(ρ * s + r0) - d3_sinh(r0)); +- return [ ux0 + u * dx, uy0 + u * dy, w0 * coshr0 / d3_cosh(ρ * s + r0) ]; ++ d3.dsv = function(delimiter, mimeType) { ++ var reFormat = new RegExp('["' + delimiter + "\n]"), delimiterCode = delimiter.charCodeAt(0); ++ function dsv(url, row, callback) { ++ if (arguments.length < 3) callback = row, row = null; ++ var xhr = d3_xhr(url, mimeType, row == null ? response : typedResponse(row), callback); ++ xhr.row = function(_) { ++ return arguments.length ? xhr.response((row = _) == null ? response : typedResponse(_)) : row; + }; ++ return xhr; + } +- i.duration = S * 1e3; +- return i; +- }; +- d3.behavior.zoom = function() { +- var view = { +- x: 0, +- y: 0, +- k: 1 +- }, translate0, center0, center, size = [ 960, 500 ], scaleExtent = d3_behavior_zoomInfinity, duration = 250, zooming = 0, mousedown = "mousedown.zoom", mousemove = "mousemove.zoom", mouseup = "mouseup.zoom", mousewheelTimer, touchstart = "touchstart.zoom", touchtime, event = d3_eventDispatch(zoom, "zoomstart", "zoom", "zoomend"), x0, x1, y0, y1; +- if (!d3_behavior_zoomWheel) { +- d3_behavior_zoomWheel = "onwheel" in d3_document ? (d3_behavior_zoomDelta = function() { +- return -d3.event.deltaY * (d3.event.deltaMode ? 120 : 1); +- }, "wheel") : "onmousewheel" in d3_document ? (d3_behavior_zoomDelta = function() { +- return d3.event.wheelDelta; +- }, "mousewheel") : (d3_behavior_zoomDelta = function() { +- return -d3.event.detail; +- }, "MozMousePixelScroll"); ++ function response(request) { ++ return dsv.parse(request.responseText); + } +- function zoom(g) { +- g.on(mousedown, mousedowned).on(d3_behavior_zoomWheel + ".zoom", mousewheeled).on("dblclick.zoom", dblclicked).on(touchstart, touchstarted); ++ function typedResponse(f) { ++ return function(request) { ++ return dsv.parse(request.responseText, f); ++ }; + } +- zoom.event = function(g) { +- g.each(function() { +- var dispatch = event.of(this, arguments), view1 = view; +- if (d3_transitionInheritId) { +- d3.select(this).transition().each("start.zoom", function() { +- view = this.__chart__ || { +- x: 0, +- y: 0, +- k: 1 +- }; +- zoomstarted(dispatch); +- }).tween("zoom:zoom", function() { +- var dx = size[0], dy = size[1], cx = center0 ? center0[0] : dx / 2, cy = center0 ? center0[1] : dy / 2, i = d3.interpolateZoom([ (cx - view.x) / view.k, (cy - view.y) / view.k, dx / view.k ], [ (cx - view1.x) / view1.k, (cy - view1.y) / view1.k, dx / view1.k ]); +- return function(t) { +- var l = i(t), k = dx / l[2]; +- this.__chart__ = view = { +- x: cx - l[0] * k, +- y: cy - l[1] * k, +- k: k +- }; +- zoomed(dispatch); +- }; +- }).each("interrupt.zoom", function() { +- zoomended(dispatch); +- }).each("end.zoom", function() { +- zoomended(dispatch); +- }); +- } else { +- this.__chart__ = view; +- zoomstarted(dispatch); +- zoomed(dispatch); +- zoomended(dispatch); +- } ++ dsv.parse = function(text, f) { ++ var o; ++ return dsv.parseRows(text, function(row, i) { ++ if (o) return o(row, i - 1); ++ var a = new Function("d", "return {" + row.map(function(name, i) { ++ return JSON.stringify(name) + ": d[" + i + "]"; ++ }).join(",") + "}"); ++ o = f ? function(row, i) { ++ return f(a(row), i); ++ } : a; + }); + }; +- zoom.translate = function(_) { +- if (!arguments.length) return [ view.x, view.y ]; +- view = { +- x: +_[0], +- y: +_[1], +- k: view.k +- }; +- rescale(); +- return zoom; +- }; +- zoom.scale = function(_) { +- if (!arguments.length) return view.k; +- view = { +- x: view.x, +- y: view.y, +- k: null +- }; +- scaleTo(+_); +- rescale(); +- return zoom; +- }; +- zoom.scaleExtent = function(_) { +- if (!arguments.length) return scaleExtent; +- scaleExtent = _ == null ? d3_behavior_zoomInfinity : [ +_[0], +_[1] ]; +- return zoom; +- }; +- zoom.center = function(_) { +- if (!arguments.length) return center; +- center = _ && [ +_[0], +_[1] ]; +- return zoom; +- }; +- zoom.size = function(_) { +- if (!arguments.length) return size; +- size = _ && [ +_[0], +_[1] ]; +- return zoom; ++ dsv.parseRows = function(text, f) { ++ var EOL = {}, EOF = {}, rows = [], N = text.length, I = 0, n = 0, t, eol; ++ function token() { ++ if (I >= N) return EOF; ++ if (eol) return eol = false, EOL; ++ var j = I; ++ if (text.charCodeAt(j) === 34) { ++ var i = j; ++ while (i++ < N) { ++ if (text.charCodeAt(i) === 34) { ++ if (text.charCodeAt(i + 1) !== 34) break; ++ ++i; ++ } ++ } ++ I = i + 2; ++ var c = text.charCodeAt(i + 1); ++ if (c === 13) { ++ eol = true; ++ if (text.charCodeAt(i + 2) === 10) ++I; ++ } else if (c === 10) { ++ eol = true; ++ } ++ return text.slice(j + 1, i).replace(/""/g, '"'); ++ } ++ while (I < N) { ++ var c = text.charCodeAt(I++), k = 1; ++ if (c === 10) eol = true; else if (c === 13) { ++ eol = true; ++ if (text.charCodeAt(I) === 10) ++I, ++k; ++ } else if (c !== delimiterCode) continue; ++ return text.slice(j, I - k); ++ } ++ return text.slice(j); ++ } ++ while ((t = token()) !== EOF) { ++ var a = []; ++ while (t !== EOL && t !== EOF) { ++ a.push(t); ++ t = token(); ++ } ++ if (f && (a = f(a, n++)) == null) continue; ++ rows.push(a); ++ } ++ return rows; + }; +- zoom.duration = function(_) { +- if (!arguments.length) return duration; +- duration = +_; +- return zoom; ++ dsv.format = function(rows) { ++ if (Array.isArray(rows[0])) return dsv.formatRows(rows); ++ var fieldSet = new d3_Set(), fields = []; ++ rows.forEach(function(row) { ++ for (var field in row) { ++ if (!fieldSet.has(field)) { ++ fields.push(fieldSet.add(field)); ++ } ++ } ++ }); ++ return [ fields.map(formatValue).join(delimiter) ].concat(rows.map(function(row) { ++ return fields.map(function(field) { ++ return formatValue(row[field]); ++ }).join(delimiter); ++ })).join("\n"); + }; +- zoom.x = function(z) { +- if (!arguments.length) return x1; +- x1 = z; +- x0 = z.copy(); +- view = { +- x: 0, +- y: 0, +- k: 1 +- }; +- return zoom; ++ dsv.formatRows = function(rows) { ++ return rows.map(formatRow).join("\n"); + }; +- zoom.y = function(z) { +- if (!arguments.length) return y1; +- y1 = z; +- y0 = z.copy(); +- view = { +- x: 0, +- y: 0, +- k: 1 +- }; +- return zoom; ++ function formatRow(row) { ++ return row.map(formatValue).join(delimiter); ++ } ++ function formatValue(text) { ++ return reFormat.test(text) ? '"' + text.replace(/\"/g, '""') + '"' : text; ++ } ++ return dsv; ++ }; ++ d3.csv = d3.dsv(",", "text/csv"); ++ d3.tsv = d3.dsv(" ", "text/tab-separated-values"); ++ var d3_timer_queueHead, d3_timer_queueTail, d3_timer_interval, d3_timer_timeout, d3_timer_frame = this[d3_vendorSymbol(this, "requestAnimationFrame")] || function(callback) { ++ setTimeout(callback, 17); ++ }; ++ d3.timer = function() { ++ d3_timer.apply(this, arguments); ++ }; ++ function d3_timer(callback, delay, then) { ++ var n = arguments.length; ++ if (n < 2) delay = 0; ++ if (n < 3) then = Date.now(); ++ var time = then + delay, timer = { ++ c: callback, ++ t: time, ++ n: null + }; +- function location(p) { +- return [ (p[0] - view.x) / view.k, (p[1] - view.y) / view.k ]; ++ if (d3_timer_queueTail) d3_timer_queueTail.n = timer; else d3_timer_queueHead = timer; ++ d3_timer_queueTail = timer; ++ if (!d3_timer_interval) { ++ d3_timer_timeout = clearTimeout(d3_timer_timeout); ++ d3_timer_interval = 1; ++ d3_timer_frame(d3_timer_step); + } +- function point(l) { +- return [ l[0] * view.k + view.x, l[1] * view.k + view.y ]; ++ return timer; ++ } ++ function d3_timer_step() { ++ var now = d3_timer_mark(), delay = d3_timer_sweep() - now; ++ if (delay > 24) { ++ if (isFinite(delay)) { ++ clearTimeout(d3_timer_timeout); ++ d3_timer_timeout = setTimeout(d3_timer_step, delay); ++ } ++ d3_timer_interval = 0; ++ } else { ++ d3_timer_interval = 1; ++ d3_timer_frame(d3_timer_step); + } +- function scaleTo(s) { +- view.k = Math.max(scaleExtent[0], Math.min(scaleExtent[1], s)); ++ } ++ d3.timer.flush = function() { ++ d3_timer_mark(); ++ d3_timer_sweep(); ++ }; ++ function d3_timer_mark() { ++ var now = Date.now(), timer = d3_timer_queueHead; ++ while (timer) { ++ if (now >= timer.t && timer.c(now - timer.t)) timer.c = null; ++ timer = timer.n; + } +- function translateTo(p, l) { +- l = point(l); +- view.x += p[0] - l[0]; +- view.y += p[1] - l[1]; ++ return now; ++ } ++ function d3_timer_sweep() { ++ var t0, t1 = d3_timer_queueHead, time = Infinity; ++ while (t1) { ++ if (t1.c) { ++ if (t1.t < time) time = t1.t; ++ t1 = (t0 = t1).n; ++ } else { ++ t1 = t0 ? t0.n = t1.n : d3_timer_queueHead = t1.n; ++ } + } +- function zoomTo(that, p, l, k) { +- that.__chart__ = { +- x: view.x, +- y: view.y, +- k: view.k ++ d3_timer_queueTail = t0; ++ return time; ++ } ++ function d3_format_precision(x, p) { ++ return p - (x ? Math.ceil(Math.log(x) / Math.LN10) : 1); ++ } ++ d3.round = function(x, n) { ++ return n ? Math.round(x * (n = Math.pow(10, n))) / n : Math.round(x); ++ }; ++ var d3_formatPrefixes = [ "y", "z", "a", "f", "p", "n", "µ", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y" ].map(d3_formatPrefix); ++ d3.formatPrefix = function(value, precision) { ++ var i = 0; ++ if (value = +value) { ++ if (value < 0) value *= -1; ++ if (precision) value = d3.round(value, d3_format_precision(value, precision)); ++ i = 1 + Math.floor(1e-12 + Math.log(value) / Math.LN10); ++ i = Math.max(-24, Math.min(24, Math.floor((i - 1) / 3) * 3)); ++ } ++ return d3_formatPrefixes[8 + i / 3]; ++ }; ++ function d3_formatPrefix(d, i) { ++ var k = Math.pow(10, abs(8 - i) * 3); ++ return { ++ scale: i > 8 ? function(d) { ++ return d / k; ++ } : function(d) { ++ return d * k; ++ }, ++ symbol: d ++ }; ++ } ++ function d3_locale_numberFormat(locale) { ++ var locale_decimal = locale.decimal, locale_thousands = locale.thousands, locale_grouping = locale.grouping, locale_currency = locale.currency, formatGroup = locale_grouping && locale_thousands ? function(value, width) { ++ var i = value.length, t = [], j = 0, g = locale_grouping[0], length = 0; ++ while (i > 0 && g > 0) { ++ if (length + g + 1 > width) g = Math.max(1, width - length); ++ t.push(value.substring(i -= g, i + g)); ++ if ((length += g + 1) > width) break; ++ g = locale_grouping[j = (j + 1) % locale_grouping.length]; ++ } ++ return t.reverse().join(locale_thousands); ++ } : d3_identity; ++ return function(specifier) { ++ var match = d3_format_re.exec(specifier), fill = match[1] || " ", align = match[2] || ">", sign = match[3] || "-", symbol = match[4] || "", zfill = match[5], width = +match[6], comma = match[7], precision = match[8], type = match[9], scale = 1, prefix = "", suffix = "", integer = false, exponent = true; ++ if (precision) precision = +precision.substring(1); ++ if (zfill || fill === "0" && align === "=") { ++ zfill = fill = "0"; ++ align = "="; ++ } ++ switch (type) { ++ case "n": ++ comma = true; ++ type = "g"; ++ break; ++ ++ case "%": ++ scale = 100; ++ suffix = "%"; ++ type = "f"; ++ break; ++ ++ case "p": ++ scale = 100; ++ suffix = "%"; ++ type = "r"; ++ break; ++ ++ case "b": ++ case "o": ++ case "x": ++ case "X": ++ if (symbol === "#") prefix = "0" + type.toLowerCase(); ++ ++ case "c": ++ exponent = false; ++ ++ case "d": ++ integer = true; ++ precision = 0; ++ break; ++ ++ case "s": ++ scale = -1; ++ type = "r"; ++ break; ++ } ++ if (symbol === "$") prefix = locale_currency[0], suffix = locale_currency[1]; ++ if (type == "r" && !precision) type = "g"; ++ if (precision != null) { ++ if (type == "g") precision = Math.max(1, Math.min(21, precision)); else if (type == "e" || type == "f") precision = Math.max(0, Math.min(20, precision)); ++ } ++ type = d3_format_types.get(type) || d3_format_typeDefault; ++ var zcomma = zfill && comma; ++ return function(value) { ++ var fullSuffix = suffix; ++ if (integer && value % 1) return ""; ++ var negative = value < 0 || value === 0 && 1 / value < 0 ? (value = -value, "-") : sign === "-" ? "" : sign; ++ if (scale < 0) { ++ var unit = d3.formatPrefix(value, precision); ++ value = unit.scale(value); ++ fullSuffix = unit.symbol + suffix; ++ } else { ++ value *= scale; ++ } ++ value = type(value, precision); ++ var i = value.lastIndexOf("."), before, after; ++ if (i < 0) { ++ var j = exponent ? value.lastIndexOf("e") : -1; ++ if (j < 0) before = value, after = ""; else before = value.substring(0, j), after = value.substring(j); ++ } else { ++ before = value.substring(0, i); ++ after = locale_decimal + value.substring(i + 1); ++ } ++ if (!zfill && comma) before = formatGroup(before, Infinity); ++ var length = prefix.length + before.length + after.length + (zcomma ? 0 : negative.length), padding = length < width ? new Array(length = width - length + 1).join(fill) : ""; ++ if (zcomma) before = formatGroup(padding + before, padding.length ? width - after.length : Infinity); ++ negative += prefix; ++ value = before + after; ++ return (align === "<" ? negative + value + padding : align === ">" ? padding + negative + value : align === "^" ? padding.substring(0, length >>= 1) + negative + value + padding.substring(length) : negative + (zcomma ? value : padding + value)) + fullSuffix; + }; +- scaleTo(Math.pow(2, k)); +- translateTo(center0 = p, l); +- that = d3.select(that); +- if (duration > 0) that = that.transition().duration(duration); +- that.call(zoom.event); ++ }; ++ } ++ var d3_format_re = /(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i; ++ var d3_format_types = d3.map({ ++ b: function(x) { ++ return x.toString(2); ++ }, ++ c: function(x) { ++ return String.fromCharCode(x); ++ }, ++ o: function(x) { ++ return x.toString(8); ++ }, ++ x: function(x) { ++ return x.toString(16); ++ }, ++ X: function(x) { ++ return x.toString(16).toUpperCase(); ++ }, ++ g: function(x, p) { ++ return x.toPrecision(p); ++ }, ++ e: function(x, p) { ++ return x.toExponential(p); ++ }, ++ f: function(x, p) { ++ return x.toFixed(p); ++ }, ++ r: function(x, p) { ++ return (x = d3.round(x, d3_format_precision(x, p))).toFixed(Math.max(0, Math.min(20, d3_format_precision(x * (1 + 1e-15), p)))); + } +- function rescale() { +- if (x1) x1.domain(x0.range().map(function(x) { +- return (x - view.x) / view.k; +- }).map(x0.invert)); +- if (y1) y1.domain(y0.range().map(function(y) { +- return (y - view.y) / view.k; +- }).map(y0.invert)); ++ }); ++ function d3_format_typeDefault(x) { ++ return x + ""; ++ } ++ var d3_time = d3.time = {}, d3_date = Date; ++ function d3_date_utc() { ++ this._ = new Date(arguments.length > 1 ? Date.UTC.apply(this, arguments) : arguments[0]); ++ } ++ d3_date_utc.prototype = { ++ getDate: function() { ++ return this._.getUTCDate(); ++ }, ++ getDay: function() { ++ return this._.getUTCDay(); ++ }, ++ getFullYear: function() { ++ return this._.getUTCFullYear(); ++ }, ++ getHours: function() { ++ return this._.getUTCHours(); ++ }, ++ getMilliseconds: function() { ++ return this._.getUTCMilliseconds(); ++ }, ++ getMinutes: function() { ++ return this._.getUTCMinutes(); ++ }, ++ getMonth: function() { ++ return this._.getUTCMonth(); ++ }, ++ getSeconds: function() { ++ return this._.getUTCSeconds(); ++ }, ++ getTime: function() { ++ return this._.getTime(); ++ }, ++ getTimezoneOffset: function() { ++ return 0; ++ }, ++ valueOf: function() { ++ return this._.valueOf(); ++ }, ++ setDate: function() { ++ d3_time_prototype.setUTCDate.apply(this._, arguments); ++ }, ++ setDay: function() { ++ d3_time_prototype.setUTCDay.apply(this._, arguments); ++ }, ++ setFullYear: function() { ++ d3_time_prototype.setUTCFullYear.apply(this._, arguments); ++ }, ++ setHours: function() { ++ d3_time_prototype.setUTCHours.apply(this._, arguments); ++ }, ++ setMilliseconds: function() { ++ d3_time_prototype.setUTCMilliseconds.apply(this._, arguments); ++ }, ++ setMinutes: function() { ++ d3_time_prototype.setUTCMinutes.apply(this._, arguments); ++ }, ++ setMonth: function() { ++ d3_time_prototype.setUTCMonth.apply(this._, arguments); ++ }, ++ setSeconds: function() { ++ d3_time_prototype.setUTCSeconds.apply(this._, arguments); ++ }, ++ setTime: function() { ++ d3_time_prototype.setTime.apply(this._, arguments); + } +- function zoomstarted(dispatch) { +- if (!zooming++) dispatch({ +- type: "zoomstart" +- }); ++ }; ++ var d3_time_prototype = Date.prototype; ++ function d3_time_interval(local, step, number) { ++ function round(date) { ++ var d0 = local(date), d1 = offset(d0, 1); ++ return date - d0 < d1 - date ? d0 : d1; + } +- function zoomed(dispatch) { +- rescale(); +- dispatch({ +- type: "zoom", +- scale: view.k, +- translate: [ view.x, view.y ] +- }); ++ function ceil(date) { ++ step(date = local(new d3_date(date - 1)), 1); ++ return date; + } +- function zoomended(dispatch) { +- if (!--zooming) dispatch({ +- type: "zoomend" +- }), center0 = null; ++ function offset(date, k) { ++ step(date = new d3_date(+date), k); ++ return date; + } +- function mousedowned() { +- var that = this, dispatch = event.of(that, arguments), dragged = 0, subject = d3.select(d3_window(that)).on(mousemove, moved).on(mouseup, ended), location0 = location(d3.mouse(that)), dragRestore = d3_event_dragSuppress(that); +- d3_selection_interrupt.call(that); +- zoomstarted(dispatch); +- function moved() { +- dragged = 1; +- translateTo(d3.mouse(that), location0); +- zoomed(dispatch); ++ function range(t0, t1, dt) { ++ var time = ceil(t0), times = []; ++ if (dt > 1) { ++ while (time < t1) { ++ if (!(number(time) % dt)) times.push(new Date(+time)); ++ step(time, 1); ++ } ++ } else { ++ while (time < t1) times.push(new Date(+time)), step(time, 1); + } +- function ended() { +- subject.on(mousemove, null).on(mouseup, null); +- dragRestore(dragged); +- zoomended(dispatch); ++ return times; ++ } ++ function range_utc(t0, t1, dt) { ++ try { ++ d3_date = d3_date_utc; ++ var utc = new d3_date_utc(); ++ utc._ = t0; ++ return range(utc, t1, dt); ++ } finally { ++ d3_date = Date; + } + } +- function touchstarted() { +- var that = this, dispatch = event.of(that, arguments), locations0 = {}, distance0 = 0, scale0, zoomName = ".zoom-" + d3.event.changedTouches[0].identifier, touchmove = "touchmove" + zoomName, touchend = "touchend" + zoomName, targets = [], subject = d3.select(that), dragRestore = d3_event_dragSuppress(that); +- started(); +- zoomstarted(dispatch); +- subject.on(mousedown, null).on(touchstart, started); +- function relocate() { +- var touches = d3.touches(that); +- scale0 = view.k; +- touches.forEach(function(t) { +- if (t.identifier in locations0) locations0[t.identifier] = location(t); +- }); +- return touches; ++ local.floor = local; ++ local.round = round; ++ local.ceil = ceil; ++ local.offset = offset; ++ local.range = range; ++ var utc = local.utc = d3_time_interval_utc(local); ++ utc.floor = utc; ++ utc.round = d3_time_interval_utc(round); ++ utc.ceil = d3_time_interval_utc(ceil); ++ utc.offset = d3_time_interval_utc(offset); ++ utc.range = range_utc; ++ return local; ++ } ++ function d3_time_interval_utc(method) { ++ return function(date, k) { ++ try { ++ d3_date = d3_date_utc; ++ var utc = new d3_date_utc(); ++ utc._ = date; ++ return method(utc, k)._; ++ } finally { ++ d3_date = Date; + } +- function started() { +- var target = d3.event.target; +- d3.select(target).on(touchmove, moved).on(touchend, ended); +- targets.push(target); +- var changed = d3.event.changedTouches; +- for (var i = 0, n = changed.length; i < n; ++i) { +- locations0[changed[i].identifier] = null; +- } +- var touches = relocate(), now = Date.now(); +- if (touches.length === 1) { +- if (now - touchtime < 500) { +- var p = touches[0]; +- zoomTo(that, p, locations0[p.identifier], Math.floor(Math.log(view.k) / Math.LN2) + 1); +- d3_eventPreventDefault(); ++ }; ++ } ++ d3_time.year = d3_time_interval(function(date) { ++ date = d3_time.day(date); ++ date.setMonth(0, 1); ++ return date; ++ }, function(date, offset) { ++ date.setFullYear(date.getFullYear() + offset); ++ }, function(date) { ++ return date.getFullYear(); ++ }); ++ d3_time.years = d3_time.year.range; ++ d3_time.years.utc = d3_time.year.utc.range; ++ d3_time.day = d3_time_interval(function(date) { ++ var day = new d3_date(2e3, 0); ++ day.setFullYear(date.getFullYear(), date.getMonth(), date.getDate()); ++ return day; ++ }, function(date, offset) { ++ date.setDate(date.getDate() + offset); ++ }, function(date) { ++ return date.getDate() - 1; ++ }); ++ d3_time.days = d3_time.day.range; ++ d3_time.days.utc = d3_time.day.utc.range; ++ d3_time.dayOfYear = function(date) { ++ var year = d3_time.year(date); ++ return Math.floor((date - year - (date.getTimezoneOffset() - year.getTimezoneOffset()) * 6e4) / 864e5); ++ }; ++ [ "sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday" ].forEach(function(day, i) { ++ i = 7 - i; ++ var interval = d3_time[day] = d3_time_interval(function(date) { ++ (date = d3_time.day(date)).setDate(date.getDate() - (date.getDay() + i) % 7); ++ return date; ++ }, function(date, offset) { ++ date.setDate(date.getDate() + Math.floor(offset) * 7); ++ }, function(date) { ++ var day = d3_time.year(date).getDay(); ++ return Math.floor((d3_time.dayOfYear(date) + (day + i) % 7) / 7) - (day !== i); ++ }); ++ d3_time[day + "s"] = interval.range; ++ d3_time[day + "s"].utc = interval.utc.range; ++ d3_time[day + "OfYear"] = function(date) { ++ var day = d3_time.year(date).getDay(); ++ return Math.floor((d3_time.dayOfYear(date) + (day + i) % 7) / 7); ++ }; ++ }); ++ d3_time.week = d3_time.sunday; ++ d3_time.weeks = d3_time.sunday.range; ++ d3_time.weeks.utc = d3_time.sunday.utc.range; ++ d3_time.weekOfYear = d3_time.sundayOfYear; ++ function d3_locale_timeFormat(locale) { ++ var locale_dateTime = locale.dateTime, locale_date = locale.date, locale_time = locale.time, locale_periods = locale.periods, locale_days = locale.days, locale_shortDays = locale.shortDays, locale_months = locale.months, locale_shortMonths = locale.shortMonths; ++ function d3_time_format(template) { ++ var n = template.length; ++ function format(date) { ++ var string = [], i = -1, j = 0, c, p, f; ++ while (++i < n) { ++ if (template.charCodeAt(i) === 37) { ++ string.push(template.slice(j, i)); ++ if ((p = d3_time_formatPads[c = template.charAt(++i)]) != null) c = template.charAt(++i); ++ if (f = d3_time_formats[c]) c = f(date, p == null ? c === "e" ? " " : "0" : p); ++ string.push(c); ++ j = i + 1; + } +- touchtime = now; +- } else if (touches.length > 1) { +- var p = touches[0], q = touches[1], dx = p[0] - q[0], dy = p[1] - q[1]; +- distance0 = dx * dx + dy * dy; + } ++ string.push(template.slice(j, i)); ++ return string.join(""); + } +- function moved() { +- var touches = d3.touches(that), p0, l0, p1, l1; +- d3_selection_interrupt.call(that); +- for (var i = 0, n = touches.length; i < n; ++i, l1 = null) { +- p1 = touches[i]; +- if (l1 = locations0[p1.identifier]) { +- if (l0) break; +- p0 = p1, l0 = l1; +- } ++ format.parse = function(string) { ++ var d = { ++ y: 1900, ++ m: 0, ++ d: 1, ++ H: 0, ++ M: 0, ++ S: 0, ++ L: 0, ++ Z: null ++ }, i = d3_time_parse(d, template, string, 0); ++ if (i != string.length) return null; ++ if ("p" in d) d.H = d.H % 12 + d.p * 12; ++ var localZ = d.Z != null && d3_date !== d3_date_utc, date = new (localZ ? d3_date_utc : d3_date)(); ++ if ("j" in d) date.setFullYear(d.y, 0, d.j); else if ("W" in d || "U" in d) { ++ if (!("w" in d)) d.w = "W" in d ? 1 : 0; ++ date.setFullYear(d.y, 0, 1); ++ date.setFullYear(d.y, 0, "W" in d ? (d.w + 6) % 7 + d.W * 7 - (date.getDay() + 5) % 7 : d.w + d.U * 7 - (date.getDay() + 6) % 7); ++ } else date.setFullYear(d.y, d.m, d.d); ++ date.setHours(d.H + (d.Z / 100 | 0), d.M + d.Z % 100, d.S, d.L); ++ return localZ ? date._ : date; ++ }; ++ format.toString = function() { ++ return template; ++ }; ++ return format; ++ } ++ function d3_time_parse(date, template, string, j) { ++ var c, p, t, i = 0, n = template.length, m = string.length; ++ while (i < n) { ++ if (j >= m) return -1; ++ c = template.charCodeAt(i++); ++ if (c === 37) { ++ t = template.charAt(i++); ++ p = d3_time_parsers[t in d3_time_formatPads ? template.charAt(i++) : t]; ++ if (!p || (j = p(date, string, j)) < 0) return -1; ++ } else if (c != string.charCodeAt(j++)) { ++ return -1; + } +- if (l1) { +- var distance1 = (distance1 = p1[0] - p0[0]) * distance1 + (distance1 = p1[1] - p0[1]) * distance1, scale1 = distance0 && Math.sqrt(distance1 / distance0); +- p0 = [ (p0[0] + p1[0]) / 2, (p0[1] + p1[1]) / 2 ]; +- l0 = [ (l0[0] + l1[0]) / 2, (l0[1] + l1[1]) / 2 ]; +- scaleTo(scale1 * scale0); ++ } ++ return j; ++ } ++ d3_time_format.utc = function(template) { ++ var local = d3_time_format(template); ++ function format(date) { ++ try { ++ d3_date = d3_date_utc; ++ var utc = new d3_date(); ++ utc._ = date; ++ return local(utc); ++ } finally { ++ d3_date = Date; + } +- touchtime = null; +- translateTo(p0, l0); +- zoomed(dispatch); + } +- function ended() { +- if (d3.event.touches.length) { +- var changed = d3.event.changedTouches; +- for (var i = 0, n = changed.length; i < n; ++i) { +- delete locations0[changed[i].identifier]; +- } +- for (var identifier in locations0) { +- return void relocate(); +- } ++ format.parse = function(string) { ++ try { ++ d3_date = d3_date_utc; ++ var date = local.parse(string); ++ return date && date._; ++ } finally { ++ d3_date = Date; + } +- d3.selectAll(targets).on(zoomName, null); +- subject.on(mousedown, mousedowned).on(touchstart, touchstarted); +- dragRestore(); +- zoomended(dispatch); ++ }; ++ format.toString = local.toString; ++ return format; ++ }; ++ d3_time_format.multi = d3_time_format.utc.multi = d3_time_formatMulti; ++ var d3_time_periodLookup = d3.map(), d3_time_dayRe = d3_time_formatRe(locale_days), d3_time_dayLookup = d3_time_formatLookup(locale_days), d3_time_dayAbbrevRe = d3_time_formatRe(locale_shortDays), d3_time_dayAbbrevLookup = d3_time_formatLookup(locale_shortDays), d3_time_monthRe = d3_time_formatRe(locale_months), d3_time_monthLookup = d3_time_formatLookup(locale_months), d3_time_monthAbbrevRe = d3_time_formatRe(locale_shortMonths), d3_time_monthAbbrevLookup = d3_time_formatLookup(locale_shortMonths); ++ locale_periods.forEach(function(p, i) { ++ d3_time_periodLookup.set(p.toLowerCase(), i); ++ }); ++ var d3_time_formats = { ++ a: function(d) { ++ return locale_shortDays[d.getDay()]; ++ }, ++ A: function(d) { ++ return locale_days[d.getDay()]; ++ }, ++ b: function(d) { ++ return locale_shortMonths[d.getMonth()]; ++ }, ++ B: function(d) { ++ return locale_months[d.getMonth()]; ++ }, ++ c: d3_time_format(locale_dateTime), ++ d: function(d, p) { ++ return d3_time_formatPad(d.getDate(), p, 2); ++ }, ++ e: function(d, p) { ++ return d3_time_formatPad(d.getDate(), p, 2); ++ }, ++ H: function(d, p) { ++ return d3_time_formatPad(d.getHours(), p, 2); ++ }, ++ I: function(d, p) { ++ return d3_time_formatPad(d.getHours() % 12 || 12, p, 2); ++ }, ++ j: function(d, p) { ++ return d3_time_formatPad(1 + d3_time.dayOfYear(d), p, 3); ++ }, ++ L: function(d, p) { ++ return d3_time_formatPad(d.getMilliseconds(), p, 3); ++ }, ++ m: function(d, p) { ++ return d3_time_formatPad(d.getMonth() + 1, p, 2); ++ }, ++ M: function(d, p) { ++ return d3_time_formatPad(d.getMinutes(), p, 2); ++ }, ++ p: function(d) { ++ return locale_periods[+(d.getHours() >= 12)]; ++ }, ++ S: function(d, p) { ++ return d3_time_formatPad(d.getSeconds(), p, 2); ++ }, ++ U: function(d, p) { ++ return d3_time_formatPad(d3_time.sundayOfYear(d), p, 2); ++ }, ++ w: function(d) { ++ return d.getDay(); ++ }, ++ W: function(d, p) { ++ return d3_time_formatPad(d3_time.mondayOfYear(d), p, 2); ++ }, ++ x: d3_time_format(locale_date), ++ X: d3_time_format(locale_time), ++ y: function(d, p) { ++ return d3_time_formatPad(d.getFullYear() % 100, p, 2); ++ }, ++ Y: function(d, p) { ++ return d3_time_formatPad(d.getFullYear() % 1e4, p, 4); ++ }, ++ Z: d3_time_zone, ++ "%": function() { ++ return "%"; + } ++ }; ++ var d3_time_parsers = { ++ a: d3_time_parseWeekdayAbbrev, ++ A: d3_time_parseWeekday, ++ b: d3_time_parseMonthAbbrev, ++ B: d3_time_parseMonth, ++ c: d3_time_parseLocaleFull, ++ d: d3_time_parseDay, ++ e: d3_time_parseDay, ++ H: d3_time_parseHour24, ++ I: d3_time_parseHour24, ++ j: d3_time_parseDayOfYear, ++ L: d3_time_parseMilliseconds, ++ m: d3_time_parseMonthNumber, ++ M: d3_time_parseMinutes, ++ p: d3_time_parseAmPm, ++ S: d3_time_parseSeconds, ++ U: d3_time_parseWeekNumberSunday, ++ w: d3_time_parseWeekdayNumber, ++ W: d3_time_parseWeekNumberMonday, ++ x: d3_time_parseLocaleDate, ++ X: d3_time_parseLocaleTime, ++ y: d3_time_parseYear, ++ Y: d3_time_parseFullYear, ++ Z: d3_time_parseZone, ++ "%": d3_time_parseLiteralPercent ++ }; ++ function d3_time_parseWeekdayAbbrev(date, string, i) { ++ d3_time_dayAbbrevRe.lastIndex = 0; ++ var n = d3_time_dayAbbrevRe.exec(string.slice(i)); ++ return n ? (date.w = d3_time_dayAbbrevLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; + } +- function mousewheeled() { +- var dispatch = event.of(this, arguments); +- if (mousewheelTimer) clearTimeout(mousewheelTimer); else d3_selection_interrupt.call(this), +- translate0 = location(center0 = center || d3.mouse(this)), zoomstarted(dispatch); +- mousewheelTimer = setTimeout(function() { +- mousewheelTimer = null; +- zoomended(dispatch); +- }, 50); +- d3_eventPreventDefault(); +- scaleTo(Math.pow(2, d3_behavior_zoomDelta() * .002) * view.k); +- translateTo(center0, translate0); +- zoomed(dispatch); ++ function d3_time_parseWeekday(date, string, i) { ++ d3_time_dayRe.lastIndex = 0; ++ var n = d3_time_dayRe.exec(string.slice(i)); ++ return n ? (date.w = d3_time_dayLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; + } +- function dblclicked() { +- var p = d3.mouse(this), k = Math.log(view.k) / Math.LN2; +- zoomTo(this, p, location(p), d3.event.shiftKey ? Math.ceil(k) - 1 : Math.floor(k) + 1); ++ function d3_time_parseMonthAbbrev(date, string, i) { ++ d3_time_monthAbbrevRe.lastIndex = 0; ++ var n = d3_time_monthAbbrevRe.exec(string.slice(i)); ++ return n ? (date.m = d3_time_monthAbbrevLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; + } +- return d3.rebind(zoom, event, "on"); +- }; +- var d3_behavior_zoomInfinity = [ 0, Infinity ], d3_behavior_zoomDelta, d3_behavior_zoomWheel; +- d3.color = d3_color; +- function d3_color() {} +- d3_color.prototype.toString = function() { +- return this.rgb() + ""; +- }; +- d3.hsl = d3_hsl; +- function d3_hsl(h, s, l) { +- return this instanceof d3_hsl ? void (this.h = +h, this.s = +s, this.l = +l) : arguments.length < 2 ? h instanceof d3_hsl ? new d3_hsl(h.h, h.s, h.l) : d3_rgb_parse("" + h, d3_rgb_hsl, d3_hsl) : new d3_hsl(h, s, l); +- } +- var d3_hslPrototype = d3_hsl.prototype = new d3_color(); +- d3_hslPrototype.brighter = function(k) { +- k = Math.pow(.7, arguments.length ? k : 1); +- return new d3_hsl(this.h, this.s, this.l / k); +- }; +- d3_hslPrototype.darker = function(k) { +- k = Math.pow(.7, arguments.length ? k : 1); +- return new d3_hsl(this.h, this.s, k * this.l); +- }; +- d3_hslPrototype.rgb = function() { +- return d3_hsl_rgb(this.h, this.s, this.l); +- }; +- function d3_hsl_rgb(h, s, l) { +- var m1, m2; +- h = isNaN(h) ? 0 : (h %= 360) < 0 ? h + 360 : h; +- s = isNaN(s) ? 0 : s < 0 ? 0 : s > 1 ? 1 : s; +- l = l < 0 ? 0 : l > 1 ? 1 : l; +- m2 = l <= .5 ? l * (1 + s) : l + s - l * s; +- m1 = 2 * l - m2; +- function v(h) { +- if (h > 360) h -= 360; else if (h < 0) h += 360; +- if (h < 60) return m1 + (m2 - m1) * h / 60; +- if (h < 180) return m2; +- if (h < 240) return m1 + (m2 - m1) * (240 - h) / 60; +- return m1; ++ function d3_time_parseMonth(date, string, i) { ++ d3_time_monthRe.lastIndex = 0; ++ var n = d3_time_monthRe.exec(string.slice(i)); ++ return n ? (date.m = d3_time_monthLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; + } +- function vv(h) { +- return Math.round(v(h) * 255); ++ function d3_time_parseLocaleFull(date, string, i) { ++ return d3_time_parse(date, d3_time_formats.c.toString(), string, i); + } +- return new d3_rgb(vv(h + 120), vv(h), vv(h - 120)); ++ function d3_time_parseLocaleDate(date, string, i) { ++ return d3_time_parse(date, d3_time_formats.x.toString(), string, i); ++ } ++ function d3_time_parseLocaleTime(date, string, i) { ++ return d3_time_parse(date, d3_time_formats.X.toString(), string, i); ++ } ++ function d3_time_parseAmPm(date, string, i) { ++ var n = d3_time_periodLookup.get(string.slice(i, i += 2).toLowerCase()); ++ return n == null ? -1 : (date.p = n, i); ++ } ++ return d3_time_format; + } +- d3.hcl = d3_hcl; +- function d3_hcl(h, c, l) { +- return this instanceof d3_hcl ? void (this.h = +h, this.c = +c, this.l = +l) : arguments.length < 2 ? h instanceof d3_hcl ? new d3_hcl(h.h, h.c, h.l) : h instanceof d3_lab ? d3_lab_hcl(h.l, h.a, h.b) : d3_lab_hcl((h = d3_rgb_lab((h = d3.rgb(h)).r, h.g, h.b)).l, h.a, h.b) : new d3_hcl(h, c, l); ++ var d3_time_formatPads = { ++ "-": "", ++ _: " ", ++ "0": "0" ++ }, d3_time_numberRe = /^\s*\d+/, d3_time_percentRe = /^%/; ++ function d3_time_formatPad(value, fill, width) { ++ var sign = value < 0 ? "-" : "", string = (sign ? -value : value) + "", length = string.length; ++ return sign + (length < width ? new Array(width - length + 1).join(fill) + string : string); + } +- var d3_hclPrototype = d3_hcl.prototype = new d3_color(); +- d3_hclPrototype.brighter = function(k) { +- return new d3_hcl(this.h, this.c, Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1))); +- }; +- d3_hclPrototype.darker = function(k) { +- return new d3_hcl(this.h, this.c, Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1))); ++ function d3_time_formatRe(names) { ++ return new RegExp("^(?:" + names.map(d3.requote).join("|") + ")", "i"); ++ } ++ function d3_time_formatLookup(names) { ++ var map = new d3_Map(), i = -1, n = names.length; ++ while (++i < n) map.set(names[i].toLowerCase(), i); ++ return map; ++ } ++ function d3_time_parseWeekdayNumber(date, string, i) { ++ d3_time_numberRe.lastIndex = 0; ++ var n = d3_time_numberRe.exec(string.slice(i, i + 1)); ++ return n ? (date.w = +n[0], i + n[0].length) : -1; ++ } ++ function d3_time_parseWeekNumberSunday(date, string, i) { ++ d3_time_numberRe.lastIndex = 0; ++ var n = d3_time_numberRe.exec(string.slice(i)); ++ return n ? (date.U = +n[0], i + n[0].length) : -1; ++ } ++ function d3_time_parseWeekNumberMonday(date, string, i) { ++ d3_time_numberRe.lastIndex = 0; ++ var n = d3_time_numberRe.exec(string.slice(i)); ++ return n ? (date.W = +n[0], i + n[0].length) : -1; ++ } ++ function d3_time_parseFullYear(date, string, i) { ++ d3_time_numberRe.lastIndex = 0; ++ var n = d3_time_numberRe.exec(string.slice(i, i + 4)); ++ return n ? (date.y = +n[0], i + n[0].length) : -1; ++ } ++ function d3_time_parseYear(date, string, i) { ++ d3_time_numberRe.lastIndex = 0; ++ var n = d3_time_numberRe.exec(string.slice(i, i + 2)); ++ return n ? (date.y = d3_time_expandYear(+n[0]), i + n[0].length) : -1; ++ } ++ function d3_time_parseZone(date, string, i) { ++ return /^[+-]\d{4}$/.test(string = string.slice(i, i + 5)) ? (date.Z = -string, ++ i + 5) : -1; ++ } ++ function d3_time_expandYear(d) { ++ return d + (d > 68 ? 1900 : 2e3); ++ } ++ function d3_time_parseMonthNumber(date, string, i) { ++ d3_time_numberRe.lastIndex = 0; ++ var n = d3_time_numberRe.exec(string.slice(i, i + 2)); ++ return n ? (date.m = n[0] - 1, i + n[0].length) : -1; ++ } ++ function d3_time_parseDay(date, string, i) { ++ d3_time_numberRe.lastIndex = 0; ++ var n = d3_time_numberRe.exec(string.slice(i, i + 2)); ++ return n ? (date.d = +n[0], i + n[0].length) : -1; ++ } ++ function d3_time_parseDayOfYear(date, string, i) { ++ d3_time_numberRe.lastIndex = 0; ++ var n = d3_time_numberRe.exec(string.slice(i, i + 3)); ++ return n ? (date.j = +n[0], i + n[0].length) : -1; ++ } ++ function d3_time_parseHour24(date, string, i) { ++ d3_time_numberRe.lastIndex = 0; ++ var n = d3_time_numberRe.exec(string.slice(i, i + 2)); ++ return n ? (date.H = +n[0], i + n[0].length) : -1; ++ } ++ function d3_time_parseMinutes(date, string, i) { ++ d3_time_numberRe.lastIndex = 0; ++ var n = d3_time_numberRe.exec(string.slice(i, i + 2)); ++ return n ? (date.M = +n[0], i + n[0].length) : -1; ++ } ++ function d3_time_parseSeconds(date, string, i) { ++ d3_time_numberRe.lastIndex = 0; ++ var n = d3_time_numberRe.exec(string.slice(i, i + 2)); ++ return n ? (date.S = +n[0], i + n[0].length) : -1; ++ } ++ function d3_time_parseMilliseconds(date, string, i) { ++ d3_time_numberRe.lastIndex = 0; ++ var n = d3_time_numberRe.exec(string.slice(i, i + 3)); ++ return n ? (date.L = +n[0], i + n[0].length) : -1; ++ } ++ function d3_time_zone(d) { ++ var z = d.getTimezoneOffset(), zs = z > 0 ? "-" : "+", zh = abs(z) / 60 | 0, zm = abs(z) % 60; ++ return zs + d3_time_formatPad(zh, "0", 2) + d3_time_formatPad(zm, "0", 2); ++ } ++ function d3_time_parseLiteralPercent(date, string, i) { ++ d3_time_percentRe.lastIndex = 0; ++ var n = d3_time_percentRe.exec(string.slice(i, i + 1)); ++ return n ? i + n[0].length : -1; ++ } ++ function d3_time_formatMulti(formats) { ++ var n = formats.length, i = -1; ++ while (++i < n) formats[i][0] = this(formats[i][0]); ++ return function(date) { ++ var i = 0, f = formats[i]; ++ while (!f[1](date)) f = formats[++i]; ++ return f[0](date); ++ }; ++ } ++ d3.locale = function(locale) { ++ return { ++ numberFormat: d3_locale_numberFormat(locale), ++ timeFormat: d3_locale_timeFormat(locale) ++ }; + }; +- d3_hclPrototype.rgb = function() { +- return d3_hcl_lab(this.h, this.c, this.l).rgb(); ++ var d3_locale_enUS = d3.locale({ ++ decimal: ".", ++ thousands: ",", ++ grouping: [ 3 ], ++ currency: [ "$", "" ], ++ dateTime: "%a %b %e %X %Y", ++ date: "%m/%d/%Y", ++ time: "%H:%M:%S", ++ periods: [ "AM", "PM" ], ++ days: [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ], ++ shortDays: [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ], ++ months: [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ], ++ shortMonths: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ] ++ }); ++ d3.format = d3_locale_enUS.numberFormat; ++ d3.geo = {}; ++ function d3_adder() {} ++ d3_adder.prototype = { ++ s: 0, ++ t: 0, ++ add: function(y) { ++ d3_adderSum(y, this.t, d3_adderTemp); ++ d3_adderSum(d3_adderTemp.s, this.s, this); ++ if (this.s) this.t += d3_adderTemp.t; else this.s = d3_adderTemp.t; ++ }, ++ reset: function() { ++ this.s = this.t = 0; ++ }, ++ valueOf: function() { ++ return this.s; ++ } + }; +- function d3_hcl_lab(h, c, l) { +- if (isNaN(h)) h = 0; +- if (isNaN(c)) c = 0; +- return new d3_lab(l, Math.cos(h *= d3_radians) * c, Math.sin(h) * c); ++ var d3_adderTemp = new d3_adder(); ++ function d3_adderSum(a, b, o) { ++ var x = o.s = a + b, bv = x - a, av = x - bv; ++ o.t = a - av + (b - bv); + } +- d3.lab = d3_lab; +- function d3_lab(l, a, b) { +- return this instanceof d3_lab ? void (this.l = +l, this.a = +a, this.b = +b) : arguments.length < 2 ? l instanceof d3_lab ? new d3_lab(l.l, l.a, l.b) : l instanceof d3_hcl ? d3_hcl_lab(l.h, l.c, l.l) : d3_rgb_lab((l = d3_rgb(l)).r, l.g, l.b) : new d3_lab(l, a, b); ++ d3.geo.stream = function(object, listener) { ++ if (object && d3_geo_streamObjectType.hasOwnProperty(object.type)) { ++ d3_geo_streamObjectType[object.type](object, listener); ++ } else { ++ d3_geo_streamGeometry(object, listener); ++ } ++ }; ++ function d3_geo_streamGeometry(geometry, listener) { ++ if (geometry && d3_geo_streamGeometryType.hasOwnProperty(geometry.type)) { ++ d3_geo_streamGeometryType[geometry.type](geometry, listener); ++ } + } +- var d3_lab_K = 18; +- var d3_lab_X = .95047, d3_lab_Y = 1, d3_lab_Z = 1.08883; +- var d3_labPrototype = d3_lab.prototype = new d3_color(); +- d3_labPrototype.brighter = function(k) { +- return new d3_lab(Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1)), this.a, this.b); ++ var d3_geo_streamObjectType = { ++ Feature: function(feature, listener) { ++ d3_geo_streamGeometry(feature.geometry, listener); ++ }, ++ FeatureCollection: function(object, listener) { ++ var features = object.features, i = -1, n = features.length; ++ while (++i < n) d3_geo_streamGeometry(features[i].geometry, listener); ++ } ++ }; ++ var d3_geo_streamGeometryType = { ++ Sphere: function(object, listener) { ++ listener.sphere(); ++ }, ++ Point: function(object, listener) { ++ object = object.coordinates; ++ listener.point(object[0], object[1], object[2]); ++ }, ++ MultiPoint: function(object, listener) { ++ var coordinates = object.coordinates, i = -1, n = coordinates.length; ++ while (++i < n) object = coordinates[i], listener.point(object[0], object[1], object[2]); ++ }, ++ LineString: function(object, listener) { ++ d3_geo_streamLine(object.coordinates, listener, 0); ++ }, ++ MultiLineString: function(object, listener) { ++ var coordinates = object.coordinates, i = -1, n = coordinates.length; ++ while (++i < n) d3_geo_streamLine(coordinates[i], listener, 0); ++ }, ++ Polygon: function(object, listener) { ++ d3_geo_streamPolygon(object.coordinates, listener); ++ }, ++ MultiPolygon: function(object, listener) { ++ var coordinates = object.coordinates, i = -1, n = coordinates.length; ++ while (++i < n) d3_geo_streamPolygon(coordinates[i], listener); ++ }, ++ GeometryCollection: function(object, listener) { ++ var geometries = object.geometries, i = -1, n = geometries.length; ++ while (++i < n) d3_geo_streamGeometry(geometries[i], listener); ++ } + }; +- d3_labPrototype.darker = function(k) { +- return new d3_lab(Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1)), this.a, this.b); ++ function d3_geo_streamLine(coordinates, listener, closed) { ++ var i = -1, n = coordinates.length - closed, coordinate; ++ listener.lineStart(); ++ while (++i < n) coordinate = coordinates[i], listener.point(coordinate[0], coordinate[1], coordinate[2]); ++ listener.lineEnd(); ++ } ++ function d3_geo_streamPolygon(coordinates, listener) { ++ var i = -1, n = coordinates.length; ++ listener.polygonStart(); ++ while (++i < n) d3_geo_streamLine(coordinates[i], listener, 1); ++ listener.polygonEnd(); ++ } ++ d3.geo.area = function(object) { ++ d3_geo_areaSum = 0; ++ d3.geo.stream(object, d3_geo_area); ++ return d3_geo_areaSum; + }; +- d3_labPrototype.rgb = function() { +- return d3_lab_rgb(this.l, this.a, this.b); ++ var d3_geo_areaSum, d3_geo_areaRingSum = new d3_adder(); ++ var d3_geo_area = { ++ sphere: function() { ++ d3_geo_areaSum += 4 * π; ++ }, ++ point: d3_noop, ++ lineStart: d3_noop, ++ lineEnd: d3_noop, ++ polygonStart: function() { ++ d3_geo_areaRingSum.reset(); ++ d3_geo_area.lineStart = d3_geo_areaRingStart; ++ }, ++ polygonEnd: function() { ++ var area = 2 * d3_geo_areaRingSum; ++ d3_geo_areaSum += area < 0 ? 4 * π + area : area; ++ d3_geo_area.lineStart = d3_geo_area.lineEnd = d3_geo_area.point = d3_noop; ++ } + }; +- function d3_lab_rgb(l, a, b) { +- var y = (l + 16) / 116, x = y + a / 500, z = y - b / 200; +- x = d3_lab_xyz(x) * d3_lab_X; +- y = d3_lab_xyz(y) * d3_lab_Y; +- z = d3_lab_xyz(z) * d3_lab_Z; +- return new d3_rgb(d3_xyz_rgb(3.2404542 * x - 1.5371385 * y - .4985314 * z), d3_xyz_rgb(-.969266 * x + 1.8760108 * y + .041556 * z), d3_xyz_rgb(.0556434 * x - .2040259 * y + 1.0572252 * z)); ++ function d3_geo_areaRingStart() { ++ var λ00, φ00, λ0, cosφ0, sinφ0; ++ d3_geo_area.point = function(λ, φ) { ++ d3_geo_area.point = nextPoint; ++ λ0 = (λ00 = λ) * d3_radians, cosφ0 = Math.cos(φ = (φ00 = φ) * d3_radians / 2 + π / 4), ++ sinφ0 = Math.sin(φ); ++ }; ++ function nextPoint(λ, φ) { ++ λ *= d3_radians; ++ φ = φ * d3_radians / 2 + π / 4; ++ var dλ = λ - λ0, sdλ = dλ >= 0 ? 1 : -1, adλ = sdλ * dλ, cosφ = Math.cos(φ), sinφ = Math.sin(φ), k = sinφ0 * sinφ, u = cosφ0 * cosφ + k * Math.cos(adλ), v = k * sdλ * Math.sin(adλ); ++ d3_geo_areaRingSum.add(Math.atan2(v, u)); ++ λ0 = λ, cosφ0 = cosφ, sinφ0 = sinφ; ++ } ++ d3_geo_area.lineEnd = function() { ++ nextPoint(λ00, φ00); ++ }; + } +- function d3_lab_hcl(l, a, b) { +- return l > 0 ? new d3_hcl(Math.atan2(b, a) * d3_degrees, Math.sqrt(a * a + b * b), l) : new d3_hcl(NaN, NaN, l); ++ function d3_geo_cartesian(spherical) { ++ var λ = spherical[0], φ = spherical[1], cosφ = Math.cos(φ); ++ return [ cosφ * Math.cos(λ), cosφ * Math.sin(λ), Math.sin(φ) ]; + } +- function d3_lab_xyz(x) { +- return x > .206893034 ? x * x * x : (x - 4 / 29) / 7.787037; ++ function d3_geo_cartesianDot(a, b) { ++ return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; + } +- function d3_xyz_lab(x) { +- return x > .008856 ? Math.pow(x, 1 / 3) : 7.787037 * x + 4 / 29; ++ function d3_geo_cartesianCross(a, b) { ++ return [ a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0] ]; + } +- function d3_xyz_rgb(r) { +- return Math.round(255 * (r <= .00304 ? 12.92 * r : 1.055 * Math.pow(r, 1 / 2.4) - .055)); ++ function d3_geo_cartesianAdd(a, b) { ++ a[0] += b[0]; ++ a[1] += b[1]; ++ a[2] += b[2]; + } +- d3.rgb = d3_rgb; +- function d3_rgb(r, g, b) { +- return this instanceof d3_rgb ? void (this.r = ~~r, this.g = ~~g, this.b = ~~b) : arguments.length < 2 ? r instanceof d3_rgb ? new d3_rgb(r.r, r.g, r.b) : d3_rgb_parse("" + r, d3_rgb, d3_hsl_rgb) : new d3_rgb(r, g, b); ++ function d3_geo_cartesianScale(vector, k) { ++ return [ vector[0] * k, vector[1] * k, vector[2] * k ]; + } +- function d3_rgbNumber(value) { +- return new d3_rgb(value >> 16, value >> 8 & 255, value & 255); ++ function d3_geo_cartesianNormalize(d) { ++ var l = Math.sqrt(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]); ++ d[0] /= l; ++ d[1] /= l; ++ d[2] /= l; + } +- function d3_rgbString(value) { +- return d3_rgbNumber(value) + ""; ++ function d3_geo_spherical(cartesian) { ++ return [ Math.atan2(cartesian[1], cartesian[0]), d3_asin(cartesian[2]) ]; + } +- var d3_rgbPrototype = d3_rgb.prototype = new d3_color(); +- d3_rgbPrototype.brighter = function(k) { +- k = Math.pow(.7, arguments.length ? k : 1); +- var r = this.r, g = this.g, b = this.b, i = 30; +- if (!r && !g && !b) return new d3_rgb(i, i, i); +- if (r && r < i) r = i; +- if (g && g < i) g = i; +- if (b && b < i) b = i; +- return new d3_rgb(Math.min(255, r / k), Math.min(255, g / k), Math.min(255, b / k)); +- }; +- d3_rgbPrototype.darker = function(k) { +- k = Math.pow(.7, arguments.length ? k : 1); +- return new d3_rgb(k * this.r, k * this.g, k * this.b); +- }; +- d3_rgbPrototype.hsl = function() { +- return d3_rgb_hsl(this.r, this.g, this.b); +- }; +- d3_rgbPrototype.toString = function() { +- return "#" + d3_rgb_hex(this.r) + d3_rgb_hex(this.g) + d3_rgb_hex(this.b); +- }; +- function d3_rgb_hex(v) { +- return v < 16 ? "0" + Math.max(0, v).toString(16) : Math.min(255, v).toString(16); ++ function d3_geo_sphericalEqual(a, b) { ++ return abs(a[0] - b[0]) < ε && abs(a[1] - b[1]) < ε; + } +- function d3_rgb_parse(format, rgb, hsl) { +- var r = 0, g = 0, b = 0, m1, m2, color; +- m1 = /([a-z]+)\((.*)\)/.exec(format = format.toLowerCase()); +- if (m1) { +- m2 = m1[2].split(","); +- switch (m1[1]) { +- case "hsl": +- { +- return hsl(parseFloat(m2[0]), parseFloat(m2[1]) / 100, parseFloat(m2[2]) / 100); ++ d3.geo.bounds = function() { ++ var λ0, φ0, λ1, φ1, λ_, λ__, φ__, p0, dλSum, ranges, range; ++ var bound = { ++ point: point, ++ lineStart: lineStart, ++ lineEnd: lineEnd, ++ polygonStart: function() { ++ bound.point = ringPoint; ++ bound.lineStart = ringStart; ++ bound.lineEnd = ringEnd; ++ dλSum = 0; ++ d3_geo_area.polygonStart(); ++ }, ++ polygonEnd: function() { ++ d3_geo_area.polygonEnd(); ++ bound.point = point; ++ bound.lineStart = lineStart; ++ bound.lineEnd = lineEnd; ++ if (d3_geo_areaRingSum < 0) λ0 = -(λ1 = 180), φ0 = -(φ1 = 90); else if (dλSum > ε) φ1 = 90; else if (dλSum < -ε) φ0 = -90; ++ range[0] = λ0, range[1] = λ1; ++ } ++ }; ++ function point(λ, φ) { ++ ranges.push(range = [ λ0 = λ, λ1 = λ ]); ++ if (φ < φ0) φ0 = φ; ++ if (φ > φ1) φ1 = φ; ++ } ++ function linePoint(λ, φ) { ++ var p = d3_geo_cartesian([ λ * d3_radians, φ * d3_radians ]); ++ if (p0) { ++ var normal = d3_geo_cartesianCross(p0, p), equatorial = [ normal[1], -normal[0], 0 ], inflection = d3_geo_cartesianCross(equatorial, normal); ++ d3_geo_cartesianNormalize(inflection); ++ inflection = d3_geo_spherical(inflection); ++ var dλ = λ - λ_, s = dλ > 0 ? 1 : -1, λi = inflection[0] * d3_degrees * s, antimeridian = abs(dλ) > 180; ++ if (antimeridian ^ (s * λ_ < λi && λi < s * λ)) { ++ var φi = inflection[1] * d3_degrees; ++ if (φi > φ1) φ1 = φi; ++ } else if (λi = (λi + 360) % 360 - 180, antimeridian ^ (s * λ_ < λi && λi < s * λ)) { ++ var φi = -inflection[1] * d3_degrees; ++ if (φi < φ0) φ0 = φi; ++ } else { ++ if (φ < φ0) φ0 = φ; ++ if (φ > φ1) φ1 = φ; + } +- +- case "rgb": +- { +- return rgb(d3_rgb_parseNumber(m2[0]), d3_rgb_parseNumber(m2[1]), d3_rgb_parseNumber(m2[2])); ++ if (antimeridian) { ++ if (λ < λ_) { ++ if (angle(λ0, λ) > angle(λ0, λ1)) λ1 = λ; ++ } else { ++ if (angle(λ, λ1) > angle(λ0, λ1)) λ0 = λ; ++ } ++ } else { ++ if (λ1 >= λ0) { ++ if (λ < λ0) λ0 = λ; ++ if (λ > λ1) λ1 = λ; ++ } else { ++ if (λ > λ_) { ++ if (angle(λ0, λ) > angle(λ0, λ1)) λ1 = λ; ++ } else { ++ if (angle(λ, λ1) > angle(λ0, λ1)) λ0 = λ; ++ } ++ } + } ++ } else { ++ point(λ, φ); + } ++ p0 = p, λ_ = λ; + } +- if (color = d3_rgb_names.get(format)) { +- return rgb(color.r, color.g, color.b); ++ function lineStart() { ++ bound.point = linePoint; + } +- if (format != null && format.charAt(0) === "#" && !isNaN(color = parseInt(format.slice(1), 16))) { +- if (format.length === 4) { +- r = (color & 3840) >> 4; +- r = r >> 4 | r; +- g = color & 240; +- g = g >> 4 | g; +- b = color & 15; +- b = b << 4 | b; +- } else if (format.length === 7) { +- r = (color & 16711680) >> 16; +- g = (color & 65280) >> 8; +- b = color & 255; ++ function lineEnd() { ++ range[0] = λ0, range[1] = λ1; ++ bound.point = point; ++ p0 = null; ++ } ++ function ringPoint(λ, φ) { ++ if (p0) { ++ var dλ = λ - λ_; ++ dλSum += abs(dλ) > 180 ? dλ + (dλ > 0 ? 360 : -360) : dλ; ++ } else λ__ = λ, φ__ = φ; ++ d3_geo_area.point(λ, φ); ++ linePoint(λ, φ); ++ } ++ function ringStart() { ++ d3_geo_area.lineStart(); ++ } ++ function ringEnd() { ++ ringPoint(λ__, φ__); ++ d3_geo_area.lineEnd(); ++ if (abs(dλSum) > ε) λ0 = -(λ1 = 180); ++ range[0] = λ0, range[1] = λ1; ++ p0 = null; ++ } ++ function angle(λ0, λ1) { ++ return (λ1 -= λ0) < 0 ? λ1 + 360 : λ1; ++ } ++ function compareRanges(a, b) { ++ return a[0] - b[0]; ++ } ++ function withinRange(x, range) { ++ return range[0] <= range[1] ? range[0] <= x && x <= range[1] : x < range[0] || range[1] < x; ++ } ++ return function(feature) { ++ φ1 = λ1 = -(λ0 = φ0 = Infinity); ++ ranges = []; ++ d3.geo.stream(feature, bound); ++ var n = ranges.length; ++ if (n) { ++ ranges.sort(compareRanges); ++ for (var i = 1, a = ranges[0], b, merged = [ a ]; i < n; ++i) { ++ b = ranges[i]; ++ if (withinRange(b[0], a) || withinRange(b[1], a)) { ++ if (angle(a[0], b[1]) > angle(a[0], a[1])) a[1] = b[1]; ++ if (angle(b[0], a[1]) > angle(a[0], a[1])) a[0] = b[0]; ++ } else { ++ merged.push(a = b); ++ } ++ } ++ var best = -Infinity, dλ; ++ for (var n = merged.length - 1, i = 0, a = merged[n], b; i <= n; a = b, ++i) { ++ b = merged[i]; ++ if ((dλ = angle(a[1], b[0])) > best) best = dλ, λ0 = b[0], λ1 = a[1]; ++ } + } ++ ranges = range = null; ++ return λ0 === Infinity || φ0 === Infinity ? [ [ NaN, NaN ], [ NaN, NaN ] ] : [ [ λ0, φ0 ], [ λ1, φ1 ] ]; ++ }; ++ }(); ++ d3.geo.centroid = function(object) { ++ d3_geo_centroidW0 = d3_geo_centroidW1 = d3_geo_centroidX0 = d3_geo_centroidY0 = d3_geo_centroidZ0 = d3_geo_centroidX1 = d3_geo_centroidY1 = d3_geo_centroidZ1 = d3_geo_centroidX2 = d3_geo_centroidY2 = d3_geo_centroidZ2 = 0; ++ d3.geo.stream(object, d3_geo_centroid); ++ var x = d3_geo_centroidX2, y = d3_geo_centroidY2, z = d3_geo_centroidZ2, m = x * x + y * y + z * z; ++ if (m < ε2) { ++ x = d3_geo_centroidX1, y = d3_geo_centroidY1, z = d3_geo_centroidZ1; ++ if (d3_geo_centroidW1 < ε) x = d3_geo_centroidX0, y = d3_geo_centroidY0, z = d3_geo_centroidZ0; ++ m = x * x + y * y + z * z; ++ if (m < ε2) return [ NaN, NaN ]; + } +- return rgb(r, g, b); +- } +- function d3_rgb_hsl(r, g, b) { +- var min = Math.min(r /= 255, g /= 255, b /= 255), max = Math.max(r, g, b), d = max - min, h, s, l = (max + min) / 2; +- if (d) { +- s = l < .5 ? d / (max + min) : d / (2 - max - min); +- if (r == max) h = (g - b) / d + (g < b ? 6 : 0); else if (g == max) h = (b - r) / d + 2; else h = (r - g) / d + 4; +- h *= 60; +- } else { +- h = NaN; +- s = l > 0 && l < 1 ? 0 : h; ++ return [ Math.atan2(y, x) * d3_degrees, d3_asin(z / Math.sqrt(m)) * d3_degrees ]; ++ }; ++ var d3_geo_centroidW0, d3_geo_centroidW1, d3_geo_centroidX0, d3_geo_centroidY0, d3_geo_centroidZ0, d3_geo_centroidX1, d3_geo_centroidY1, d3_geo_centroidZ1, d3_geo_centroidX2, d3_geo_centroidY2, d3_geo_centroidZ2; ++ var d3_geo_centroid = { ++ sphere: d3_noop, ++ point: d3_geo_centroidPoint, ++ lineStart: d3_geo_centroidLineStart, ++ lineEnd: d3_geo_centroidLineEnd, ++ polygonStart: function() { ++ d3_geo_centroid.lineStart = d3_geo_centroidRingStart; ++ }, ++ polygonEnd: function() { ++ d3_geo_centroid.lineStart = d3_geo_centroidLineStart; + } +- return new d3_hsl(h, s, l); ++ }; ++ function d3_geo_centroidPoint(λ, φ) { ++ λ *= d3_radians; ++ var cosφ = Math.cos(φ *= d3_radians); ++ d3_geo_centroidPointXYZ(cosφ * Math.cos(λ), cosφ * Math.sin(λ), Math.sin(φ)); + } +- function d3_rgb_lab(r, g, b) { +- r = d3_rgb_xyz(r); +- g = d3_rgb_xyz(g); +- b = d3_rgb_xyz(b); +- var x = d3_xyz_lab((.4124564 * r + .3575761 * g + .1804375 * b) / d3_lab_X), y = d3_xyz_lab((.2126729 * r + .7151522 * g + .072175 * b) / d3_lab_Y), z = d3_xyz_lab((.0193339 * r + .119192 * g + .9503041 * b) / d3_lab_Z); +- return d3_lab(116 * y - 16, 500 * (x - y), 200 * (y - z)); ++ function d3_geo_centroidPointXYZ(x, y, z) { ++ ++d3_geo_centroidW0; ++ d3_geo_centroidX0 += (x - d3_geo_centroidX0) / d3_geo_centroidW0; ++ d3_geo_centroidY0 += (y - d3_geo_centroidY0) / d3_geo_centroidW0; ++ d3_geo_centroidZ0 += (z - d3_geo_centroidZ0) / d3_geo_centroidW0; + } +- function d3_rgb_xyz(r) { +- return (r /= 255) <= .04045 ? r / 12.92 : Math.pow((r + .055) / 1.055, 2.4); ++ function d3_geo_centroidLineStart() { ++ var x0, y0, z0; ++ d3_geo_centroid.point = function(λ, φ) { ++ λ *= d3_radians; ++ var cosφ = Math.cos(φ *= d3_radians); ++ x0 = cosφ * Math.cos(λ); ++ y0 = cosφ * Math.sin(λ); ++ z0 = Math.sin(φ); ++ d3_geo_centroid.point = nextPoint; ++ d3_geo_centroidPointXYZ(x0, y0, z0); ++ }; ++ function nextPoint(λ, φ) { ++ λ *= d3_radians; ++ var cosφ = Math.cos(φ *= d3_radians), x = cosφ * Math.cos(λ), y = cosφ * Math.sin(λ), z = Math.sin(φ), w = Math.atan2(Math.sqrt((w = y0 * z - z0 * y) * w + (w = z0 * x - x0 * z) * w + (w = x0 * y - y0 * x) * w), x0 * x + y0 * y + z0 * z); ++ d3_geo_centroidW1 += w; ++ d3_geo_centroidX1 += w * (x0 + (x0 = x)); ++ d3_geo_centroidY1 += w * (y0 + (y0 = y)); ++ d3_geo_centroidZ1 += w * (z0 + (z0 = z)); ++ d3_geo_centroidPointXYZ(x0, y0, z0); ++ } + } +- function d3_rgb_parseNumber(c) { +- var f = parseFloat(c); +- return c.charAt(c.length - 1) === "%" ? Math.round(f * 2.55) : f; ++ function d3_geo_centroidLineEnd() { ++ d3_geo_centroid.point = d3_geo_centroidPoint; + } +- var d3_rgb_names = d3.map({ +- aliceblue: 15792383, +- antiquewhite: 16444375, +- aqua: 65535, +- aquamarine: 8388564, +- azure: 15794175, +- beige: 16119260, +- bisque: 16770244, +- black: 0, +- blanchedalmond: 16772045, +- blue: 255, +- blueviolet: 9055202, +- brown: 10824234, +- burlywood: 14596231, +- cadetblue: 6266528, +- chartreuse: 8388352, +- chocolate: 13789470, +- coral: 16744272, +- cornflowerblue: 6591981, +- cornsilk: 16775388, +- crimson: 14423100, +- cyan: 65535, +- darkblue: 139, +- darkcyan: 35723, +- darkgoldenrod: 12092939, +- darkgray: 11119017, +- darkgreen: 25600, +- darkgrey: 11119017, +- darkkhaki: 12433259, +- darkmagenta: 9109643, +- darkolivegreen: 5597999, +- darkorange: 16747520, +- darkorchid: 10040012, +- darkred: 9109504, +- darksalmon: 15308410, +- darkseagreen: 9419919, +- darkslateblue: 4734347, +- darkslategray: 3100495, +- darkslategrey: 3100495, +- darkturquoise: 52945, +- darkviolet: 9699539, +- deeppink: 16716947, +- deepskyblue: 49151, +- dimgray: 6908265, +- dimgrey: 6908265, +- dodgerblue: 2003199, +- firebrick: 11674146, +- floralwhite: 16775920, +- forestgreen: 2263842, +- fuchsia: 16711935, +- gainsboro: 14474460, +- ghostwhite: 16316671, +- gold: 16766720, +- goldenrod: 14329120, +- gray: 8421504, +- green: 32768, +- greenyellow: 11403055, +- grey: 8421504, +- honeydew: 15794160, +- hotpink: 16738740, +- indianred: 13458524, +- indigo: 4915330, +- ivory: 16777200, +- khaki: 15787660, +- lavender: 15132410, +- lavenderblush: 16773365, +- lawngreen: 8190976, +- lemonchiffon: 16775885, +- lightblue: 11393254, +- lightcoral: 15761536, +- lightcyan: 14745599, +- lightgoldenrodyellow: 16448210, +- lightgray: 13882323, +- lightgreen: 9498256, +- lightgrey: 13882323, +- lightpink: 16758465, +- lightsalmon: 16752762, +- lightseagreen: 2142890, +- lightskyblue: 8900346, +- lightslategray: 7833753, +- lightslategrey: 7833753, +- lightsteelblue: 11584734, +- lightyellow: 16777184, +- lime: 65280, +- limegreen: 3329330, +- linen: 16445670, +- magenta: 16711935, +- maroon: 8388608, +- mediumaquamarine: 6737322, +- mediumblue: 205, +- mediumorchid: 12211667, +- mediumpurple: 9662683, +- mediumseagreen: 3978097, +- mediumslateblue: 8087790, +- mediumspringgreen: 64154, +- mediumturquoise: 4772300, +- mediumvioletred: 13047173, +- midnightblue: 1644912, +- mintcream: 16121850, +- mistyrose: 16770273, +- moccasin: 16770229, +- navajowhite: 16768685, +- navy: 128, +- oldlace: 16643558, +- olive: 8421376, +- olivedrab: 7048739, +- orange: 16753920, +- orangered: 16729344, +- orchid: 14315734, +- palegoldenrod: 15657130, +- palegreen: 10025880, +- paleturquoise: 11529966, +- palevioletred: 14381203, +- papayawhip: 16773077, +- peachpuff: 16767673, +- peru: 13468991, +- pink: 16761035, +- plum: 14524637, +- powderblue: 11591910, +- purple: 8388736, +- rebeccapurple: 6697881, +- red: 16711680, +- rosybrown: 12357519, +- royalblue: 4286945, +- saddlebrown: 9127187, +- salmon: 16416882, +- sandybrown: 16032864, +- seagreen: 3050327, +- seashell: 16774638, +- sienna: 10506797, +- silver: 12632256, +- skyblue: 8900331, +- slateblue: 6970061, +- slategray: 7372944, +- slategrey: 7372944, +- snow: 16775930, +- springgreen: 65407, +- steelblue: 4620980, +- tan: 13808780, +- teal: 32896, +- thistle: 14204888, +- tomato: 16737095, +- turquoise: 4251856, +- violet: 15631086, +- wheat: 16113331, +- white: 16777215, +- whitesmoke: 16119285, +- yellow: 16776960, +- yellowgreen: 10145074 +- }); +- d3_rgb_names.forEach(function(key, value) { +- d3_rgb_names.set(key, d3_rgbNumber(value)); +- }); +- function d3_functor(v) { +- return typeof v === "function" ? v : function() { +- return v; ++ function d3_geo_centroidRingStart() { ++ var λ00, φ00, x0, y0, z0; ++ d3_geo_centroid.point = function(λ, φ) { ++ λ00 = λ, φ00 = φ; ++ d3_geo_centroid.point = nextPoint; ++ λ *= d3_radians; ++ var cosφ = Math.cos(φ *= d3_radians); ++ x0 = cosφ * Math.cos(λ); ++ y0 = cosφ * Math.sin(λ); ++ z0 = Math.sin(φ); ++ d3_geo_centroidPointXYZ(x0, y0, z0); + }; +- } +- d3.functor = d3_functor; +- d3.xhr = d3_xhrType(d3_identity); +- function d3_xhrType(response) { +- return function(url, mimeType, callback) { +- if (arguments.length === 2 && typeof mimeType === "function") callback = mimeType, +- mimeType = null; +- return d3_xhr(url, mimeType, response, callback); ++ d3_geo_centroid.lineEnd = function() { ++ nextPoint(λ00, φ00); ++ d3_geo_centroid.lineEnd = d3_geo_centroidLineEnd; ++ d3_geo_centroid.point = d3_geo_centroidPoint; + }; ++ function nextPoint(λ, φ) { ++ λ *= d3_radians; ++ var cosφ = Math.cos(φ *= d3_radians), x = cosφ * Math.cos(λ), y = cosφ * Math.sin(λ), z = Math.sin(φ), cx = y0 * z - z0 * y, cy = z0 * x - x0 * z, cz = x0 * y - y0 * x, m = Math.sqrt(cx * cx + cy * cy + cz * cz), u = x0 * x + y0 * y + z0 * z, v = m && -d3_acos(u) / m, w = Math.atan2(m, u); ++ d3_geo_centroidX2 += v * cx; ++ d3_geo_centroidY2 += v * cy; ++ d3_geo_centroidZ2 += v * cz; ++ d3_geo_centroidW1 += w; ++ d3_geo_centroidX1 += w * (x0 + (x0 = x)); ++ d3_geo_centroidY1 += w * (y0 + (y0 = y)); ++ d3_geo_centroidZ1 += w * (z0 + (z0 = z)); ++ d3_geo_centroidPointXYZ(x0, y0, z0); ++ } + } +- function d3_xhr(url, mimeType, response, callback) { +- var xhr = {}, dispatch = d3.dispatch("beforesend", "progress", "load", "error"), headers = {}, request = new XMLHttpRequest(), responseType = null; +- if (this.XDomainRequest && !("withCredentials" in request) && /^(http(s)?:)?\/\//.test(url)) request = new XDomainRequest(); +- "onload" in request ? request.onload = request.onerror = respond : request.onreadystatechange = function() { +- request.readyState > 3 && respond(); +- }; +- function respond() { +- var status = request.status, result; +- if (!status && d3_xhrHasResponse(request) || status >= 200 && status < 300 || status === 304) { +- try { +- result = response.call(xhr, request); +- } catch (e) { +- dispatch.error.call(xhr, e); +- return; +- } +- dispatch.load.call(xhr, result); +- } else { +- dispatch.error.call(xhr, request); +- } ++ function d3_geo_compose(a, b) { ++ function compose(x, y) { ++ return x = a(x, y), b(x[0], x[1]); + } +- request.onprogress = function(event) { +- var o = d3.event; +- d3.event = event; +- try { +- dispatch.progress.call(xhr, request); +- } finally { +- d3.event = o; +- } +- }; +- xhr.header = function(name, value) { +- name = (name + "").toLowerCase(); +- if (arguments.length < 2) return headers[name]; +- if (value == null) delete headers[name]; else headers[name] = value + ""; +- return xhr; +- }; +- xhr.mimeType = function(value) { +- if (!arguments.length) return mimeType; +- mimeType = value == null ? null : value + ""; +- return xhr; +- }; +- xhr.responseType = function(value) { +- if (!arguments.length) return responseType; +- responseType = value; +- return xhr; +- }; +- xhr.response = function(value) { +- response = value; +- return xhr; +- }; +- [ "get", "post" ].forEach(function(method) { +- xhr[method] = function() { +- return xhr.send.apply(xhr, [ method ].concat(d3_array(arguments))); +- }; +- }); +- xhr.send = function(method, data, callback) { +- if (arguments.length === 2 && typeof data === "function") callback = data, data = null; +- request.open(method, url, true); +- if (mimeType != null && !("accept" in headers)) headers["accept"] = mimeType + ",*/*"; +- if (request.setRequestHeader) for (var name in headers) request.setRequestHeader(name, headers[name]); +- if (mimeType != null && request.overrideMimeType) request.overrideMimeType(mimeType); +- if (responseType != null) request.responseType = responseType; +- if (callback != null) xhr.on("error", callback).on("load", function(request) { +- callback(null, request); +- }); +- dispatch.beforesend.call(xhr, request); +- request.send(data == null ? null : data); +- return xhr; +- }; +- xhr.abort = function() { +- request.abort(); +- return xhr; ++ if (a.invert && b.invert) compose.invert = function(x, y) { ++ return x = b.invert(x, y), x && a.invert(x[0], x[1]); + }; +- d3.rebind(xhr, dispatch, "on"); +- return callback == null ? xhr : xhr.get(d3_xhr_fixCallback(callback)); +- } +- function d3_xhr_fixCallback(callback) { +- return callback.length === 1 ? function(error, request) { +- callback(error == null ? request : null); +- } : callback; ++ return compose; + } +- function d3_xhrHasResponse(request) { +- var type = request.responseType; +- return type && type !== "text" ? request.response : request.responseText; ++ function d3_true() { ++ return true; + } +- d3.dsv = function(delimiter, mimeType) { +- var reFormat = new RegExp('["' + delimiter + "\n]"), delimiterCode = delimiter.charCodeAt(0); +- function dsv(url, row, callback) { +- if (arguments.length < 3) callback = row, row = null; +- var xhr = d3_xhr(url, mimeType, row == null ? response : typedResponse(row), callback); +- xhr.row = function(_) { +- return arguments.length ? xhr.response((row = _) == null ? response : typedResponse(_)) : row; +- }; +- return xhr; ++ function d3_geo_clipPolygon(segments, compare, clipStartInside, interpolate, listener) { ++ var subject = [], clip = []; ++ segments.forEach(function(segment) { ++ if ((n = segment.length - 1) <= 0) return; ++ var n, p0 = segment[0], p1 = segment[n]; ++ if (d3_geo_sphericalEqual(p0, p1)) { ++ listener.lineStart(); ++ for (var i = 0; i < n; ++i) listener.point((p0 = segment[i])[0], p0[1]); ++ listener.lineEnd(); ++ return; ++ } ++ var a = new d3_geo_clipPolygonIntersection(p0, segment, null, true), b = new d3_geo_clipPolygonIntersection(p0, null, a, false); ++ a.o = b; ++ subject.push(a); ++ clip.push(b); ++ a = new d3_geo_clipPolygonIntersection(p1, segment, null, false); ++ b = new d3_geo_clipPolygonIntersection(p1, null, a, true); ++ a.o = b; ++ subject.push(a); ++ clip.push(b); ++ }); ++ clip.sort(compare); ++ d3_geo_clipPolygonLinkCircular(subject); ++ d3_geo_clipPolygonLinkCircular(clip); ++ if (!subject.length) return; ++ for (var i = 0, entry = clipStartInside, n = clip.length; i < n; ++i) { ++ clip[i].e = entry = !entry; + } +- function response(request) { +- return dsv.parse(request.responseText); ++ var start = subject[0], points, point; ++ while (1) { ++ var current = start, isSubject = true; ++ while (current.v) if ((current = current.n) === start) return; ++ points = current.z; ++ listener.lineStart(); ++ do { ++ current.v = current.o.v = true; ++ if (current.e) { ++ if (isSubject) { ++ for (var i = 0, n = points.length; i < n; ++i) listener.point((point = points[i])[0], point[1]); ++ } else { ++ interpolate(current.x, current.n.x, 1, listener); ++ } ++ current = current.n; ++ } else { ++ if (isSubject) { ++ points = current.p.z; ++ for (var i = points.length - 1; i >= 0; --i) listener.point((point = points[i])[0], point[1]); ++ } else { ++ interpolate(current.x, current.p.x, -1, listener); ++ } ++ current = current.p; ++ } ++ current = current.o; ++ points = current.z; ++ isSubject = !isSubject; ++ } while (!current.v); ++ listener.lineEnd(); + } +- function typedResponse(f) { +- return function(request) { +- return dsv.parse(request.responseText, f); +- }; ++ } ++ function d3_geo_clipPolygonLinkCircular(array) { ++ if (!(n = array.length)) return; ++ var n, i = 0, a = array[0], b; ++ while (++i < n) { ++ a.n = b = array[i]; ++ b.p = a; ++ a = b; + } +- dsv.parse = function(text, f) { +- var o; +- return dsv.parseRows(text, function(row, i) { +- if (o) return o(row, i - 1); +- var a = new Function("d", "return {" + row.map(function(name, i) { +- return JSON.stringify(name) + ": d[" + i + "]"; +- }).join(",") + "}"); +- o = f ? function(row, i) { +- return f(a(row), i); +- } : a; +- }); +- }; +- dsv.parseRows = function(text, f) { +- var EOL = {}, EOF = {}, rows = [], N = text.length, I = 0, n = 0, t, eol; +- function token() { +- if (I >= N) return EOF; +- if (eol) return eol = false, EOL; +- var j = I; +- if (text.charCodeAt(j) === 34) { +- var i = j; +- while (i++ < N) { +- if (text.charCodeAt(i) === 34) { +- if (text.charCodeAt(i + 1) !== 34) break; +- ++i; +- } +- } +- I = i + 2; +- var c = text.charCodeAt(i + 1); +- if (c === 13) { +- eol = true; +- if (text.charCodeAt(i + 2) === 10) ++I; +- } else if (c === 10) { +- eol = true; ++ a.n = b = array[0]; ++ b.p = a; ++ } ++ function d3_geo_clipPolygonIntersection(point, points, other, entry) { ++ this.x = point; ++ this.z = points; ++ this.o = other; ++ this.e = entry; ++ this.v = false; ++ this.n = this.p = null; ++ } ++ function d3_geo_clip(pointVisible, clipLine, interpolate, clipStart) { ++ return function(rotate, listener) { ++ var line = clipLine(listener), rotatedClipStart = rotate.invert(clipStart[0], clipStart[1]); ++ var clip = { ++ point: point, ++ lineStart: lineStart, ++ lineEnd: lineEnd, ++ polygonStart: function() { ++ clip.point = pointRing; ++ clip.lineStart = ringStart; ++ clip.lineEnd = ringEnd; ++ segments = []; ++ polygon = []; ++ }, ++ polygonEnd: function() { ++ clip.point = point; ++ clip.lineStart = lineStart; ++ clip.lineEnd = lineEnd; ++ segments = d3.merge(segments); ++ var clipStartInside = d3_geo_pointInPolygon(rotatedClipStart, polygon); ++ if (segments.length) { ++ if (!polygonStarted) listener.polygonStart(), polygonStarted = true; ++ d3_geo_clipPolygon(segments, d3_geo_clipSort, clipStartInside, interpolate, listener); ++ } else if (clipStartInside) { ++ if (!polygonStarted) listener.polygonStart(), polygonStarted = true; ++ listener.lineStart(); ++ interpolate(null, null, 1, listener); ++ listener.lineEnd(); + } +- return text.slice(j + 1, i).replace(/""/g, '"'); ++ if (polygonStarted) listener.polygonEnd(), polygonStarted = false; ++ segments = polygon = null; ++ }, ++ sphere: function() { ++ listener.polygonStart(); ++ listener.lineStart(); ++ interpolate(null, null, 1, listener); ++ listener.lineEnd(); ++ listener.polygonEnd(); + } +- while (I < N) { +- var c = text.charCodeAt(I++), k = 1; +- if (c === 10) eol = true; else if (c === 13) { +- eol = true; +- if (text.charCodeAt(I) === 10) ++I, ++k; +- } else if (c !== delimiterCode) continue; +- return text.slice(j, I - k); ++ }; ++ function point(λ, φ) { ++ var point = rotate(λ, φ); ++ if (pointVisible(λ = point[0], φ = point[1])) listener.point(λ, φ); ++ } ++ function pointLine(λ, φ) { ++ var point = rotate(λ, φ); ++ line.point(point[0], point[1]); ++ } ++ function lineStart() { ++ clip.point = pointLine; ++ line.lineStart(); ++ } ++ function lineEnd() { ++ clip.point = point; ++ line.lineEnd(); ++ } ++ var segments; ++ var buffer = d3_geo_clipBufferListener(), ringListener = clipLine(buffer), polygonStarted = false, polygon, ring; ++ function pointRing(λ, φ) { ++ ring.push([ λ, φ ]); ++ var point = rotate(λ, φ); ++ ringListener.point(point[0], point[1]); ++ } ++ function ringStart() { ++ ringListener.lineStart(); ++ ring = []; ++ } ++ function ringEnd() { ++ pointRing(ring[0][0], ring[0][1]); ++ ringListener.lineEnd(); ++ var clean = ringListener.clean(), ringSegments = buffer.buffer(), segment, n = ringSegments.length; ++ ring.pop(); ++ polygon.push(ring); ++ ring = null; ++ if (!n) return; ++ if (clean & 1) { ++ segment = ringSegments[0]; ++ var n = segment.length - 1, i = -1, point; ++ if (n > 0) { ++ if (!polygonStarted) listener.polygonStart(), polygonStarted = true; ++ listener.lineStart(); ++ while (++i < n) listener.point((point = segment[i])[0], point[1]); ++ listener.lineEnd(); ++ } ++ return; + } +- return text.slice(j); ++ if (n > 1 && clean & 2) ringSegments.push(ringSegments.pop().concat(ringSegments.shift())); ++ segments.push(ringSegments.filter(d3_geo_clipSegmentLength1)); + } +- while ((t = token()) !== EOF) { +- var a = []; +- while (t !== EOL && t !== EOF) { +- a.push(t); +- t = token(); ++ return clip; ++ }; ++ } ++ function d3_geo_clipSegmentLength1(segment) { ++ return segment.length > 1; ++ } ++ function d3_geo_clipBufferListener() { ++ var lines = [], line; ++ return { ++ lineStart: function() { ++ lines.push(line = []); ++ }, ++ point: function(λ, φ) { ++ line.push([ λ, φ ]); ++ }, ++ lineEnd: d3_noop, ++ buffer: function() { ++ var buffer = lines; ++ lines = []; ++ line = null; ++ return buffer; ++ }, ++ rejoin: function() { ++ if (lines.length > 1) lines.push(lines.pop().concat(lines.shift())); ++ } ++ }; ++ } ++ function d3_geo_clipSort(a, b) { ++ return ((a = a.x)[0] < 0 ? a[1] - halfπ - ε : halfπ - a[1]) - ((b = b.x)[0] < 0 ? b[1] - halfπ - ε : halfπ - b[1]); ++ } ++ var d3_geo_clipAntimeridian = d3_geo_clip(d3_true, d3_geo_clipAntimeridianLine, d3_geo_clipAntimeridianInterpolate, [ -π, -π / 2 ]); ++ function d3_geo_clipAntimeridianLine(listener) { ++ var λ0 = NaN, φ0 = NaN, sλ0 = NaN, clean; ++ return { ++ lineStart: function() { ++ listener.lineStart(); ++ clean = 1; ++ }, ++ point: function(λ1, φ1) { ++ var sλ1 = λ1 > 0 ? π : -π, dλ = abs(λ1 - λ0); ++ if (abs(dλ - π) < ε) { ++ listener.point(λ0, φ0 = (φ0 + φ1) / 2 > 0 ? halfπ : -halfπ); ++ listener.point(sλ0, φ0); ++ listener.lineEnd(); ++ listener.lineStart(); ++ listener.point(sλ1, φ0); ++ listener.point(λ1, φ0); ++ clean = 0; ++ } else if (sλ0 !== sλ1 && dλ >= π) { ++ if (abs(λ0 - sλ0) < ε) λ0 -= sλ0 * ε; ++ if (abs(λ1 - sλ1) < ε) λ1 -= sλ1 * ε; ++ φ0 = d3_geo_clipAntimeridianIntersect(λ0, φ0, λ1, φ1); ++ listener.point(sλ0, φ0); ++ listener.lineEnd(); ++ listener.lineStart(); ++ listener.point(sλ1, φ0); ++ clean = 0; + } +- if (f && (a = f(a, n++)) == null) continue; +- rows.push(a); ++ listener.point(λ0 = λ1, φ0 = φ1); ++ sλ0 = sλ1; ++ }, ++ lineEnd: function() { ++ listener.lineEnd(); ++ λ0 = φ0 = NaN; ++ }, ++ clean: function() { ++ return 2 - clean; + } +- return rows; + }; +- dsv.format = function(rows) { +- if (Array.isArray(rows[0])) return dsv.formatRows(rows); +- var fieldSet = new d3_Set(), fields = []; +- rows.forEach(function(row) { +- for (var field in row) { +- if (!fieldSet.has(field)) { +- fields.push(fieldSet.add(field)); ++ } ++ function d3_geo_clipAntimeridianIntersect(λ0, φ0, λ1, φ1) { ++ var cosφ0, cosφ1, sinλ0_λ1 = Math.sin(λ0 - λ1); ++ return abs(sinλ0_λ1) > ε ? Math.atan((Math.sin(φ0) * (cosφ1 = Math.cos(φ1)) * Math.sin(λ1) - Math.sin(φ1) * (cosφ0 = Math.cos(φ0)) * Math.sin(λ0)) / (cosφ0 * cosφ1 * sinλ0_λ1)) : (φ0 + φ1) / 2; ++ } ++ function d3_geo_clipAntimeridianInterpolate(from, to, direction, listener) { ++ var φ; ++ if (from == null) { ++ φ = direction * halfπ; ++ listener.point(-π, φ); ++ listener.point(0, φ); ++ listener.point(π, φ); ++ listener.point(π, 0); ++ listener.point(π, -φ); ++ listener.point(0, -φ); ++ listener.point(-π, -φ); ++ listener.point(-π, 0); ++ listener.point(-π, φ); ++ } else if (abs(from[0] - to[0]) > ε) { ++ var s = from[0] < to[0] ? π : -π; ++ φ = direction * s / 2; ++ listener.point(-s, φ); ++ listener.point(0, φ); ++ listener.point(s, φ); ++ } else { ++ listener.point(to[0], to[1]); ++ } ++ } ++ function d3_geo_pointInPolygon(point, polygon) { ++ var meridian = point[0], parallel = point[1], meridianNormal = [ Math.sin(meridian), -Math.cos(meridian), 0 ], polarAngle = 0, winding = 0; ++ d3_geo_areaRingSum.reset(); ++ for (var i = 0, n = polygon.length; i < n; ++i) { ++ var ring = polygon[i], m = ring.length; ++ if (!m) continue; ++ var point0 = ring[0], λ0 = point0[0], φ0 = point0[1] / 2 + π / 4, sinφ0 = Math.sin(φ0), cosφ0 = Math.cos(φ0), j = 1; ++ while (true) { ++ if (j === m) j = 0; ++ point = ring[j]; ++ var λ = point[0], φ = point[1] / 2 + π / 4, sinφ = Math.sin(φ), cosφ = Math.cos(φ), dλ = λ - λ0, sdλ = dλ >= 0 ? 1 : -1, adλ = sdλ * dλ, antimeridian = adλ > π, k = sinφ0 * sinφ; ++ d3_geo_areaRingSum.add(Math.atan2(k * sdλ * Math.sin(adλ), cosφ0 * cosφ + k * Math.cos(adλ))); ++ polarAngle += antimeridian ? dλ + sdλ * τ : dλ; ++ if (antimeridian ^ λ0 >= meridian ^ λ >= meridian) { ++ var arc = d3_geo_cartesianCross(d3_geo_cartesian(point0), d3_geo_cartesian(point)); ++ d3_geo_cartesianNormalize(arc); ++ var intersection = d3_geo_cartesianCross(meridianNormal, arc); ++ d3_geo_cartesianNormalize(intersection); ++ var φarc = (antimeridian ^ dλ >= 0 ? -1 : 1) * d3_asin(intersection[2]); ++ if (parallel > φarc || parallel === φarc && (arc[0] || arc[1])) { ++ winding += antimeridian ^ dλ >= 0 ? 1 : -1; ++ } ++ } ++ if (!j++) break; ++ λ0 = λ, sinφ0 = sinφ, cosφ0 = cosφ, point0 = point; ++ } ++ } ++ return (polarAngle < -ε || polarAngle < ε && d3_geo_areaRingSum < -ε) ^ winding & 1; ++ } ++ function d3_geo_clipCircle(radius) { ++ var cr = Math.cos(radius), smallRadius = cr > 0, notHemisphere = abs(cr) > ε, interpolate = d3_geo_circleInterpolate(radius, 6 * d3_radians); ++ return d3_geo_clip(visible, clipLine, interpolate, smallRadius ? [ 0, -radius ] : [ -π, radius - π ]); ++ function visible(λ, φ) { ++ return Math.cos(λ) * Math.cos(φ) > cr; ++ } ++ function clipLine(listener) { ++ var point0, c0, v0, v00, clean; ++ return { ++ lineStart: function() { ++ v00 = v0 = false; ++ clean = 1; ++ }, ++ point: function(λ, φ) { ++ var point1 = [ λ, φ ], point2, v = visible(λ, φ), c = smallRadius ? v ? 0 : code(λ, φ) : v ? code(λ + (λ < 0 ? π : -π), φ) : 0; ++ if (!point0 && (v00 = v0 = v)) listener.lineStart(); ++ if (v !== v0) { ++ point2 = intersect(point0, point1); ++ if (d3_geo_sphericalEqual(point0, point2) || d3_geo_sphericalEqual(point1, point2)) { ++ point1[0] += ε; ++ point1[1] += ε; ++ v = visible(point1[0], point1[1]); ++ } ++ } ++ if (v !== v0) { ++ clean = 0; ++ if (v) { ++ listener.lineStart(); ++ point2 = intersect(point1, point0); ++ listener.point(point2[0], point2[1]); ++ } else { ++ point2 = intersect(point0, point1); ++ listener.point(point2[0], point2[1]); ++ listener.lineEnd(); ++ } ++ point0 = point2; ++ } else if (notHemisphere && point0 && smallRadius ^ v) { ++ var t; ++ if (!(c & c0) && (t = intersect(point1, point0, true))) { ++ clean = 0; ++ if (smallRadius) { ++ listener.lineStart(); ++ listener.point(t[0][0], t[0][1]); ++ listener.point(t[1][0], t[1][1]); ++ listener.lineEnd(); ++ } else { ++ listener.point(t[1][0], t[1][1]); ++ listener.lineEnd(); ++ listener.lineStart(); ++ listener.point(t[0][0], t[0][1]); ++ } ++ } ++ } ++ if (v && (!point0 || !d3_geo_sphericalEqual(point0, point1))) { ++ listener.point(point1[0], point1[1]); + } ++ point0 = point1, v0 = v, c0 = c; ++ }, ++ lineEnd: function() { ++ if (v0) listener.lineEnd(); ++ point0 = null; ++ }, ++ clean: function() { ++ return clean | (v00 && v0) << 1; + } +- }); +- return [ fields.map(formatValue).join(delimiter) ].concat(rows.map(function(row) { +- return fields.map(function(field) { +- return formatValue(row[field]); +- }).join(delimiter); +- })).join("\n"); +- }; +- dsv.formatRows = function(rows) { +- return rows.map(formatRow).join("\n"); +- }; +- function formatRow(row) { +- return row.map(formatValue).join(delimiter); +- } +- function formatValue(text) { +- return reFormat.test(text) ? '"' + text.replace(/\"/g, '""') + '"' : text; +- } +- return dsv; +- }; +- d3.csv = d3.dsv(",", "text/csv"); +- d3.tsv = d3.dsv(" ", "text/tab-separated-values"); +- var d3_timer_queueHead, d3_timer_queueTail, d3_timer_interval, d3_timer_timeout, d3_timer_frame = this[d3_vendorSymbol(this, "requestAnimationFrame")] || function(callback) { +- setTimeout(callback, 17); +- }; +- d3.timer = function() { +- d3_timer.apply(this, arguments); +- }; +- function d3_timer(callback, delay, then) { +- var n = arguments.length; +- if (n < 2) delay = 0; +- if (n < 3) then = Date.now(); +- var time = then + delay, timer = { +- c: callback, +- t: time, +- n: null +- }; +- if (d3_timer_queueTail) d3_timer_queueTail.n = timer; else d3_timer_queueHead = timer; +- d3_timer_queueTail = timer; +- if (!d3_timer_interval) { +- d3_timer_timeout = clearTimeout(d3_timer_timeout); +- d3_timer_interval = 1; +- d3_timer_frame(d3_timer_step); ++ }; + } +- return timer; +- } +- function d3_timer_step() { +- var now = d3_timer_mark(), delay = d3_timer_sweep() - now; +- if (delay > 24) { +- if (isFinite(delay)) { +- clearTimeout(d3_timer_timeout); +- d3_timer_timeout = setTimeout(d3_timer_step, delay); ++ function intersect(a, b, two) { ++ var pa = d3_geo_cartesian(a), pb = d3_geo_cartesian(b); ++ var n1 = [ 1, 0, 0 ], n2 = d3_geo_cartesianCross(pa, pb), n2n2 = d3_geo_cartesianDot(n2, n2), n1n2 = n2[0], determinant = n2n2 - n1n2 * n1n2; ++ if (!determinant) return !two && a; ++ var c1 = cr * n2n2 / determinant, c2 = -cr * n1n2 / determinant, n1xn2 = d3_geo_cartesianCross(n1, n2), A = d3_geo_cartesianScale(n1, c1), B = d3_geo_cartesianScale(n2, c2); ++ d3_geo_cartesianAdd(A, B); ++ var u = n1xn2, w = d3_geo_cartesianDot(A, u), uu = d3_geo_cartesianDot(u, u), t2 = w * w - uu * (d3_geo_cartesianDot(A, A) - 1); ++ if (t2 < 0) return; ++ var t = Math.sqrt(t2), q = d3_geo_cartesianScale(u, (-w - t) / uu); ++ d3_geo_cartesianAdd(q, A); ++ q = d3_geo_spherical(q); ++ if (!two) return q; ++ var λ0 = a[0], λ1 = b[0], φ0 = a[1], φ1 = b[1], z; ++ if (λ1 < λ0) z = λ0, λ0 = λ1, λ1 = z; ++ var δλ = λ1 - λ0, polar = abs(δλ - π) < ε, meridian = polar || δλ < ε; ++ if (!polar && φ1 < φ0) z = φ0, φ0 = φ1, φ1 = z; ++ if (meridian ? polar ? φ0 + φ1 > 0 ^ q[1] < (abs(q[0] - λ0) < ε ? φ0 : φ1) : φ0 <= q[1] && q[1] <= φ1 : δλ > π ^ (λ0 <= q[0] && q[0] <= λ1)) { ++ var q1 = d3_geo_cartesianScale(u, (-w + t) / uu); ++ d3_geo_cartesianAdd(q1, A); ++ return [ q, d3_geo_spherical(q1) ]; + } +- d3_timer_interval = 0; +- } else { +- d3_timer_interval = 1; +- d3_timer_frame(d3_timer_step); + } +- } +- d3.timer.flush = function() { +- d3_timer_mark(); +- d3_timer_sweep(); +- }; +- function d3_timer_mark() { +- var now = Date.now(), timer = d3_timer_queueHead; +- while (timer) { +- if (now >= timer.t && timer.c(now - timer.t)) timer.c = null; +- timer = timer.n; ++ function code(λ, φ) { ++ var r = smallRadius ? radius : π - radius, code = 0; ++ if (λ < -r) code |= 1; else if (λ > r) code |= 2; ++ if (φ < -r) code |= 4; else if (φ > r) code |= 8; ++ return code; + } +- return now; + } +- function d3_timer_sweep() { +- var t0, t1 = d3_timer_queueHead, time = Infinity; +- while (t1) { +- if (t1.c) { +- if (t1.t < time) time = t1.t; +- t1 = (t0 = t1).n; +- } else { +- t1 = t0 ? t0.n = t1.n : d3_timer_queueHead = t1.n; ++ function d3_geom_clipLine(x0, y0, x1, y1) { ++ return function(line) { ++ var a = line.a, b = line.b, ax = a.x, ay = a.y, bx = b.x, by = b.y, t0 = 0, t1 = 1, dx = bx - ax, dy = by - ay, r; ++ r = x0 - ax; ++ if (!dx && r > 0) return; ++ r /= dx; ++ if (dx < 0) { ++ if (r < t0) return; ++ if (r < t1) t1 = r; ++ } else if (dx > 0) { ++ if (r > t1) return; ++ if (r > t0) t0 = r; + } +- } +- d3_timer_queueTail = t0; +- return time; +- } +- function d3_format_precision(x, p) { +- return p - (x ? Math.ceil(Math.log(x) / Math.LN10) : 1); ++ r = x1 - ax; ++ if (!dx && r < 0) return; ++ r /= dx; ++ if (dx < 0) { ++ if (r > t1) return; ++ if (r > t0) t0 = r; ++ } else if (dx > 0) { ++ if (r < t0) return; ++ if (r < t1) t1 = r; ++ } ++ r = y0 - ay; ++ if (!dy && r > 0) return; ++ r /= dy; ++ if (dy < 0) { ++ if (r < t0) return; ++ if (r < t1) t1 = r; ++ } else if (dy > 0) { ++ if (r > t1) return; ++ if (r > t0) t0 = r; ++ } ++ r = y1 - ay; ++ if (!dy && r < 0) return; ++ r /= dy; ++ if (dy < 0) { ++ if (r > t1) return; ++ if (r > t0) t0 = r; ++ } else if (dy > 0) { ++ if (r < t0) return; ++ if (r < t1) t1 = r; ++ } ++ if (t0 > 0) line.a = { ++ x: ax + t0 * dx, ++ y: ay + t0 * dy ++ }; ++ if (t1 < 1) line.b = { ++ x: ax + t1 * dx, ++ y: ay + t1 * dy ++ }; ++ return line; ++ }; + } +- d3.round = function(x, n) { +- return n ? Math.round(x * (n = Math.pow(10, n))) / n : Math.round(x); +- }; +- var d3_formatPrefixes = [ "y", "z", "a", "f", "p", "n", "µ", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y" ].map(d3_formatPrefix); +- d3.formatPrefix = function(value, precision) { +- var i = 0; +- if (value = +value) { +- if (value < 0) value *= -1; +- if (precision) value = d3.round(value, d3_format_precision(value, precision)); +- i = 1 + Math.floor(1e-12 + Math.log(value) / Math.LN10); +- i = Math.max(-24, Math.min(24, Math.floor((i - 1) / 3) * 3)); +- } +- return d3_formatPrefixes[8 + i / 3]; +- }; +- function d3_formatPrefix(d, i) { +- var k = Math.pow(10, abs(8 - i) * 3); +- return { +- scale: i > 8 ? function(d) { +- return d / k; +- } : function(d) { +- return d * k; ++ var d3_geo_clipExtentMAX = 1e9; ++ d3.geo.clipExtent = function() { ++ var x0, y0, x1, y1, stream, clip, clipExtent = { ++ stream: function(output) { ++ if (stream) stream.valid = false; ++ stream = clip(output); ++ stream.valid = true; ++ return stream; + }, +- symbol: d ++ extent: function(_) { ++ if (!arguments.length) return [ [ x0, y0 ], [ x1, y1 ] ]; ++ clip = d3_geo_clipExtent(x0 = +_[0][0], y0 = +_[0][1], x1 = +_[1][0], y1 = +_[1][1]); ++ if (stream) stream.valid = false, stream = null; ++ return clipExtent; ++ } + }; +- } +- function d3_locale_numberFormat(locale) { +- var locale_decimal = locale.decimal, locale_thousands = locale.thousands, locale_grouping = locale.grouping, locale_currency = locale.currency, formatGroup = locale_grouping && locale_thousands ? function(value, width) { +- var i = value.length, t = [], j = 0, g = locale_grouping[0], length = 0; +- while (i > 0 && g > 0) { +- if (length + g + 1 > width) g = Math.max(1, width - length); +- t.push(value.substring(i -= g, i + g)); +- if ((length += g + 1) > width) break; +- g = locale_grouping[j = (j + 1) % locale_grouping.length]; ++ return clipExtent.extent([ [ 0, 0 ], [ 960, 500 ] ]); ++ }; ++ function d3_geo_clipExtent(x0, y0, x1, y1) { ++ return function(listener) { ++ var listener_ = listener, bufferListener = d3_geo_clipBufferListener(), clipLine = d3_geom_clipLine(x0, y0, x1, y1), segments, polygon, ring; ++ var clip = { ++ point: point, ++ lineStart: lineStart, ++ lineEnd: lineEnd, ++ polygonStart: function() { ++ listener = bufferListener; ++ segments = []; ++ polygon = []; ++ clean = true; ++ }, ++ polygonEnd: function() { ++ listener = listener_; ++ segments = d3.merge(segments); ++ var clipStartInside = insidePolygon([ x0, y1 ]), inside = clean && clipStartInside, visible = segments.length; ++ if (inside || visible) { ++ listener.polygonStart(); ++ if (inside) { ++ listener.lineStart(); ++ interpolate(null, null, 1, listener); ++ listener.lineEnd(); ++ } ++ if (visible) { ++ d3_geo_clipPolygon(segments, compare, clipStartInside, interpolate, listener); ++ } ++ listener.polygonEnd(); ++ } ++ segments = polygon = ring = null; ++ } ++ }; ++ function insidePolygon(p) { ++ var wn = 0, n = polygon.length, y = p[1]; ++ for (var i = 0; i < n; ++i) { ++ for (var j = 1, v = polygon[i], m = v.length, a = v[0], b; j < m; ++j) { ++ b = v[j]; ++ if (a[1] <= y) { ++ if (b[1] > y && d3_cross2d(a, b, p) > 0) ++wn; ++ } else { ++ if (b[1] <= y && d3_cross2d(a, b, p) < 0) --wn; ++ } ++ a = b; ++ } ++ } ++ return wn !== 0; + } +- return t.reverse().join(locale_thousands); +- } : d3_identity; +- return function(specifier) { +- var match = d3_format_re.exec(specifier), fill = match[1] || " ", align = match[2] || ">", sign = match[3] || "-", symbol = match[4] || "", zfill = match[5], width = +match[6], comma = match[7], precision = match[8], type = match[9], scale = 1, prefix = "", suffix = "", integer = false, exponent = true; +- if (precision) precision = +precision.substring(1); +- if (zfill || fill === "0" && align === "=") { +- zfill = fill = "0"; +- align = "="; ++ function interpolate(from, to, direction, listener) { ++ var a = 0, a1 = 0; ++ if (from == null || (a = corner(from, direction)) !== (a1 = corner(to, direction)) || comparePoints(from, to) < 0 ^ direction > 0) { ++ do { ++ listener.point(a === 0 || a === 3 ? x0 : x1, a > 1 ? y1 : y0); ++ } while ((a = (a + direction + 4) % 4) !== a1); ++ } else { ++ listener.point(to[0], to[1]); ++ } + } +- switch (type) { +- case "n": +- comma = true; +- type = "g"; +- break; +- +- case "%": +- scale = 100; +- suffix = "%"; +- type = "f"; +- break; +- +- case "p": +- scale = 100; +- suffix = "%"; +- type = "r"; +- break; +- +- case "b": +- case "o": +- case "x": +- case "X": +- if (symbol === "#") prefix = "0" + type.toLowerCase(); +- +- case "c": +- exponent = false; +- +- case "d": +- integer = true; +- precision = 0; +- break; +- +- case "s": +- scale = -1; +- type = "r"; +- break; ++ function pointVisible(x, y) { ++ return x0 <= x && x <= x1 && y0 <= y && y <= y1; + } +- if (symbol === "$") prefix = locale_currency[0], suffix = locale_currency[1]; +- if (type == "r" && !precision) type = "g"; +- if (precision != null) { +- if (type == "g") precision = Math.max(1, Math.min(21, precision)); else if (type == "e" || type == "f") precision = Math.max(0, Math.min(20, precision)); ++ function point(x, y) { ++ if (pointVisible(x, y)) listener.point(x, y); + } +- type = d3_format_types.get(type) || d3_format_typeDefault; +- var zcomma = zfill && comma; +- return function(value) { +- var fullSuffix = suffix; +- if (integer && value % 1) return ""; +- var negative = value < 0 || value === 0 && 1 / value < 0 ? (value = -value, "-") : sign === "-" ? "" : sign; +- if (scale < 0) { +- var unit = d3.formatPrefix(value, precision); +- value = unit.scale(value); +- fullSuffix = unit.symbol + suffix; +- } else { +- value *= scale; ++ var x__, y__, v__, x_, y_, v_, first, clean; ++ function lineStart() { ++ clip.point = linePoint; ++ if (polygon) polygon.push(ring = []); ++ first = true; ++ v_ = false; ++ x_ = y_ = NaN; ++ } ++ function lineEnd() { ++ if (segments) { ++ linePoint(x__, y__); ++ if (v__ && v_) bufferListener.rejoin(); ++ segments.push(bufferListener.buffer()); + } +- value = type(value, precision); +- var i = value.lastIndexOf("."), before, after; +- if (i < 0) { +- var j = exponent ? value.lastIndexOf("e") : -1; +- if (j < 0) before = value, after = ""; else before = value.substring(0, j), after = value.substring(j); ++ clip.point = point; ++ if (v_) listener.lineEnd(); ++ } ++ function linePoint(x, y) { ++ x = Math.max(-d3_geo_clipExtentMAX, Math.min(d3_geo_clipExtentMAX, x)); ++ y = Math.max(-d3_geo_clipExtentMAX, Math.min(d3_geo_clipExtentMAX, y)); ++ var v = pointVisible(x, y); ++ if (polygon) ring.push([ x, y ]); ++ if (first) { ++ x__ = x, y__ = y, v__ = v; ++ first = false; ++ if (v) { ++ listener.lineStart(); ++ listener.point(x, y); ++ } + } else { +- before = value.substring(0, i); +- after = locale_decimal + value.substring(i + 1); +- } +- if (!zfill && comma) before = formatGroup(before, Infinity); +- var length = prefix.length + before.length + after.length + (zcomma ? 0 : negative.length), padding = length < width ? new Array(length = width - length + 1).join(fill) : ""; +- if (zcomma) before = formatGroup(padding + before, padding.length ? width - after.length : Infinity); +- negative += prefix; +- value = before + after; +- return (align === "<" ? negative + value + padding : align === ">" ? padding + negative + value : align === "^" ? padding.substring(0, length >>= 1) + negative + value + padding.substring(length) : negative + (zcomma ? value : padding + value)) + fullSuffix; +- }; +- }; +- } +- var d3_format_re = /(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i; +- var d3_format_types = d3.map({ +- b: function(x) { +- return x.toString(2); +- }, +- c: function(x) { +- return String.fromCharCode(x); +- }, +- o: function(x) { +- return x.toString(8); +- }, +- x: function(x) { +- return x.toString(16); +- }, +- X: function(x) { +- return x.toString(16).toUpperCase(); +- }, +- g: function(x, p) { +- return x.toPrecision(p); +- }, +- e: function(x, p) { +- return x.toExponential(p); +- }, +- f: function(x, p) { +- return x.toFixed(p); +- }, +- r: function(x, p) { +- return (x = d3.round(x, d3_format_precision(x, p))).toFixed(Math.max(0, Math.min(20, d3_format_precision(x * (1 + 1e-15), p)))); +- } +- }); +- function d3_format_typeDefault(x) { +- return x + ""; +- } +- var d3_time = d3.time = {}, d3_date = Date; +- function d3_date_utc() { +- this._ = new Date(arguments.length > 1 ? Date.UTC.apply(this, arguments) : arguments[0]); +- } +- d3_date_utc.prototype = { +- getDate: function() { +- return this._.getUTCDate(); +- }, +- getDay: function() { +- return this._.getUTCDay(); +- }, +- getFullYear: function() { +- return this._.getUTCFullYear(); +- }, +- getHours: function() { +- return this._.getUTCHours(); +- }, +- getMilliseconds: function() { +- return this._.getUTCMilliseconds(); +- }, +- getMinutes: function() { +- return this._.getUTCMinutes(); +- }, +- getMonth: function() { +- return this._.getUTCMonth(); +- }, +- getSeconds: function() { +- return this._.getUTCSeconds(); +- }, +- getTime: function() { +- return this._.getTime(); +- }, +- getTimezoneOffset: function() { +- return 0; +- }, +- valueOf: function() { +- return this._.valueOf(); +- }, +- setDate: function() { +- d3_time_prototype.setUTCDate.apply(this._, arguments); +- }, +- setDay: function() { +- d3_time_prototype.setUTCDay.apply(this._, arguments); +- }, +- setFullYear: function() { +- d3_time_prototype.setUTCFullYear.apply(this._, arguments); +- }, +- setHours: function() { +- d3_time_prototype.setUTCHours.apply(this._, arguments); +- }, +- setMilliseconds: function() { +- d3_time_prototype.setUTCMilliseconds.apply(this._, arguments); +- }, +- setMinutes: function() { +- d3_time_prototype.setUTCMinutes.apply(this._, arguments); +- }, +- setMonth: function() { +- d3_time_prototype.setUTCMonth.apply(this._, arguments); +- }, +- setSeconds: function() { +- d3_time_prototype.setUTCSeconds.apply(this._, arguments); +- }, +- setTime: function() { +- d3_time_prototype.setTime.apply(this._, arguments); +- } +- }; +- var d3_time_prototype = Date.prototype; +- function d3_time_interval(local, step, number) { +- function round(date) { +- var d0 = local(date), d1 = offset(d0, 1); +- return date - d0 < d1 - date ? d0 : d1; +- } +- function ceil(date) { +- step(date = local(new d3_date(date - 1)), 1); +- return date; +- } +- function offset(date, k) { +- step(date = new d3_date(+date), k); +- return date; +- } +- function range(t0, t1, dt) { +- var time = ceil(t0), times = []; +- if (dt > 1) { +- while (time < t1) { +- if (!(number(time) % dt)) times.push(new Date(+time)); +- step(time, 1); ++ if (v && v_) listener.point(x, y); else { ++ var l = { ++ a: { ++ x: x_, ++ y: y_ ++ }, ++ b: { ++ x: x, ++ y: y ++ } ++ }; ++ if (clipLine(l)) { ++ if (!v_) { ++ listener.lineStart(); ++ listener.point(l.a.x, l.a.y); ++ } ++ listener.point(l.b.x, l.b.y); ++ if (!v) listener.lineEnd(); ++ clean = false; ++ } else if (v) { ++ listener.lineStart(); ++ listener.point(x, y); ++ clean = false; ++ } ++ } + } +- } else { +- while (time < t1) times.push(new Date(+time)), step(time, 1); ++ x_ = x, y_ = y, v_ = v; + } +- return times; ++ return clip; ++ }; ++ function corner(p, direction) { ++ return abs(p[0] - x0) < ε ? direction > 0 ? 0 : 3 : abs(p[0] - x1) < ε ? direction > 0 ? 2 : 1 : abs(p[1] - y0) < ε ? direction > 0 ? 1 : 0 : direction > 0 ? 3 : 2; + } +- function range_utc(t0, t1, dt) { +- try { +- d3_date = d3_date_utc; +- var utc = new d3_date_utc(); +- utc._ = t0; +- return range(utc, t1, dt); +- } finally { +- d3_date = Date; +- } ++ function compare(a, b) { ++ return comparePoints(a.x, b.x); ++ } ++ function comparePoints(a, b) { ++ var ca = corner(a, 1), cb = corner(b, 1); ++ return ca !== cb ? ca - cb : ca === 0 ? b[1] - a[1] : ca === 1 ? a[0] - b[0] : ca === 2 ? a[1] - b[1] : b[0] - a[0]; + } +- local.floor = local; +- local.round = round; +- local.ceil = ceil; +- local.offset = offset; +- local.range = range; +- var utc = local.utc = d3_time_interval_utc(local); +- utc.floor = utc; +- utc.round = d3_time_interval_utc(round); +- utc.ceil = d3_time_interval_utc(ceil); +- utc.offset = d3_time_interval_utc(offset); +- utc.range = range_utc; +- return local; + } +- function d3_time_interval_utc(method) { +- return function(date, k) { +- try { +- d3_date = d3_date_utc; +- var utc = new d3_date_utc(); +- utc._ = date; +- return method(utc, k)._; +- } finally { +- d3_date = Date; +- } ++ function d3_geo_conic(projectAt) { ++ var φ0 = 0, φ1 = π / 3, m = d3_geo_projectionMutator(projectAt), p = m(φ0, φ1); ++ p.parallels = function(_) { ++ if (!arguments.length) return [ φ0 / π * 180, φ1 / π * 180 ]; ++ return m(φ0 = _[0] * π / 180, φ1 = _[1] * π / 180); + }; ++ return p; + } +- d3_time.year = d3_time_interval(function(date) { +- date = d3_time.day(date); +- date.setMonth(0, 1); +- return date; +- }, function(date, offset) { +- date.setFullYear(date.getFullYear() + offset); +- }, function(date) { +- return date.getFullYear(); +- }); +- d3_time.years = d3_time.year.range; +- d3_time.years.utc = d3_time.year.utc.range; +- d3_time.day = d3_time_interval(function(date) { +- var day = new d3_date(2e3, 0); +- day.setFullYear(date.getFullYear(), date.getMonth(), date.getDate()); +- return day; +- }, function(date, offset) { +- date.setDate(date.getDate() + offset); +- }, function(date) { +- return date.getDate() - 1; +- }); +- d3_time.days = d3_time.day.range; +- d3_time.days.utc = d3_time.day.utc.range; +- d3_time.dayOfYear = function(date) { +- var year = d3_time.year(date); +- return Math.floor((date - year - (date.getTimezoneOffset() - year.getTimezoneOffset()) * 6e4) / 864e5); ++ function d3_geo_conicEqualArea(φ0, φ1) { ++ var sinφ0 = Math.sin(φ0), n = (sinφ0 + Math.sin(φ1)) / 2, C = 1 + sinφ0 * (2 * n - sinφ0), ρ0 = Math.sqrt(C) / n; ++ function forward(λ, φ) { ++ var ρ = Math.sqrt(C - 2 * n * Math.sin(φ)) / n; ++ return [ ρ * Math.sin(λ *= n), ρ0 - ρ * Math.cos(λ) ]; ++ } ++ forward.invert = function(x, y) { ++ var ρ0_y = ρ0 - y; ++ return [ Math.atan2(x, ρ0_y) / n, d3_asin((C - (x * x + ρ0_y * ρ0_y) * n * n) / (2 * n)) ]; ++ }; ++ return forward; ++ } ++ (d3.geo.conicEqualArea = function() { ++ return d3_geo_conic(d3_geo_conicEqualArea); ++ }).raw = d3_geo_conicEqualArea; ++ d3.geo.albers = function() { ++ return d3.geo.conicEqualArea().rotate([ 96, 0 ]).center([ -.6, 38.7 ]).parallels([ 29.5, 45.5 ]).scale(1070); + }; +- [ "sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday" ].forEach(function(day, i) { +- i = 7 - i; +- var interval = d3_time[day] = d3_time_interval(function(date) { +- (date = d3_time.day(date)).setDate(date.getDate() - (date.getDay() + i) % 7); +- return date; +- }, function(date, offset) { +- date.setDate(date.getDate() + Math.floor(offset) * 7); +- }, function(date) { +- var day = d3_time.year(date).getDay(); +- return Math.floor((d3_time.dayOfYear(date) + (day + i) % 7) / 7) - (day !== i); +- }); +- d3_time[day + "s"] = interval.range; +- d3_time[day + "s"].utc = interval.utc.range; +- d3_time[day + "OfYear"] = function(date) { +- var day = d3_time.year(date).getDay(); +- return Math.floor((d3_time.dayOfYear(date) + (day + i) % 7) / 7); ++ d3.geo.albersUsa = function() { ++ var lower48 = d3.geo.albers(); ++ var alaska = d3.geo.conicEqualArea().rotate([ 154, 0 ]).center([ -2, 58.5 ]).parallels([ 55, 65 ]); ++ var hawaii = d3.geo.conicEqualArea().rotate([ 157, 0 ]).center([ -3, 19.9 ]).parallels([ 8, 18 ]); ++ var point, pointStream = { ++ point: function(x, y) { ++ point = [ x, y ]; ++ } ++ }, lower48Point, alaskaPoint, hawaiiPoint; ++ function albersUsa(coordinates) { ++ var x = coordinates[0], y = coordinates[1]; ++ point = null; ++ (lower48Point(x, y), point) || (alaskaPoint(x, y), point) || hawaiiPoint(x, y); ++ return point; ++ } ++ albersUsa.invert = function(coordinates) { ++ var k = lower48.scale(), t = lower48.translate(), x = (coordinates[0] - t[0]) / k, y = (coordinates[1] - t[1]) / k; ++ return (y >= .12 && y < .234 && x >= -.425 && x < -.214 ? alaska : y >= .166 && y < .234 && x >= -.214 && x < -.115 ? hawaii : lower48).invert(coordinates); + }; +- }); +- d3_time.week = d3_time.sunday; +- d3_time.weeks = d3_time.sunday.range; +- d3_time.weeks.utc = d3_time.sunday.utc.range; +- d3_time.weekOfYear = d3_time.sundayOfYear; +- function d3_locale_timeFormat(locale) { +- var locale_dateTime = locale.dateTime, locale_date = locale.date, locale_time = locale.time, locale_periods = locale.periods, locale_days = locale.days, locale_shortDays = locale.shortDays, locale_months = locale.months, locale_shortMonths = locale.shortMonths; +- function d3_time_format(template) { +- var n = template.length; +- function format(date) { +- var string = [], i = -1, j = 0, c, p, f; +- while (++i < n) { +- if (template.charCodeAt(i) === 37) { +- string.push(template.slice(j, i)); +- if ((p = d3_time_formatPads[c = template.charAt(++i)]) != null) c = template.charAt(++i); +- if (f = d3_time_formats[c]) c = f(date, p == null ? c === "e" ? " " : "0" : p); +- string.push(c); +- j = i + 1; +- } ++ albersUsa.stream = function(stream) { ++ var lower48Stream = lower48.stream(stream), alaskaStream = alaska.stream(stream), hawaiiStream = hawaii.stream(stream); ++ return { ++ point: function(x, y) { ++ lower48Stream.point(x, y); ++ alaskaStream.point(x, y); ++ hawaiiStream.point(x, y); ++ }, ++ sphere: function() { ++ lower48Stream.sphere(); ++ alaskaStream.sphere(); ++ hawaiiStream.sphere(); ++ }, ++ lineStart: function() { ++ lower48Stream.lineStart(); ++ alaskaStream.lineStart(); ++ hawaiiStream.lineStart(); ++ }, ++ lineEnd: function() { ++ lower48Stream.lineEnd(); ++ alaskaStream.lineEnd(); ++ hawaiiStream.lineEnd(); ++ }, ++ polygonStart: function() { ++ lower48Stream.polygonStart(); ++ alaskaStream.polygonStart(); ++ hawaiiStream.polygonStart(); ++ }, ++ polygonEnd: function() { ++ lower48Stream.polygonEnd(); ++ alaskaStream.polygonEnd(); ++ hawaiiStream.polygonEnd(); + } +- string.push(template.slice(j, i)); +- return string.join(""); +- } +- format.parse = function(string) { +- var d = { +- y: 1900, +- m: 0, +- d: 1, +- H: 0, +- M: 0, +- S: 0, +- L: 0, +- Z: null +- }, i = d3_time_parse(d, template, string, 0); +- if (i != string.length) return null; +- if ("p" in d) d.H = d.H % 12 + d.p * 12; +- var localZ = d.Z != null && d3_date !== d3_date_utc, date = new (localZ ? d3_date_utc : d3_date)(); +- if ("j" in d) date.setFullYear(d.y, 0, d.j); else if ("W" in d || "U" in d) { +- if (!("w" in d)) d.w = "W" in d ? 1 : 0; +- date.setFullYear(d.y, 0, 1); +- date.setFullYear(d.y, 0, "W" in d ? (d.w + 6) % 7 + d.W * 7 - (date.getDay() + 5) % 7 : d.w + d.U * 7 - (date.getDay() + 6) % 7); +- } else date.setFullYear(d.y, d.m, d.d); +- date.setHours(d.H + (d.Z / 100 | 0), d.M + d.Z % 100, d.S, d.L); +- return localZ ? date._ : date; +- }; +- format.toString = function() { +- return template; + }; +- return format; ++ }; ++ albersUsa.precision = function(_) { ++ if (!arguments.length) return lower48.precision(); ++ lower48.precision(_); ++ alaska.precision(_); ++ hawaii.precision(_); ++ return albersUsa; ++ }; ++ albersUsa.scale = function(_) { ++ if (!arguments.length) return lower48.scale(); ++ lower48.scale(_); ++ alaska.scale(_ * .35); ++ hawaii.scale(_); ++ return albersUsa.translate(lower48.translate()); ++ }; ++ albersUsa.translate = function(_) { ++ if (!arguments.length) return lower48.translate(); ++ var k = lower48.scale(), x = +_[0], y = +_[1]; ++ lower48Point = lower48.translate(_).clipExtent([ [ x - .455 * k, y - .238 * k ], [ x + .455 * k, y + .238 * k ] ]).stream(pointStream).point; ++ alaskaPoint = alaska.translate([ x - .307 * k, y + .201 * k ]).clipExtent([ [ x - .425 * k + ε, y + .12 * k + ε ], [ x - .214 * k - ε, y + .234 * k - ε ] ]).stream(pointStream).point; ++ hawaiiPoint = hawaii.translate([ x - .205 * k, y + .212 * k ]).clipExtent([ [ x - .214 * k + ε, y + .166 * k + ε ], [ x - .115 * k - ε, y + .234 * k - ε ] ]).stream(pointStream).point; ++ return albersUsa; ++ }; ++ return albersUsa.scale(1070); ++ }; ++ var d3_geo_pathAreaSum, d3_geo_pathAreaPolygon, d3_geo_pathArea = { ++ point: d3_noop, ++ lineStart: d3_noop, ++ lineEnd: d3_noop, ++ polygonStart: function() { ++ d3_geo_pathAreaPolygon = 0; ++ d3_geo_pathArea.lineStart = d3_geo_pathAreaRingStart; ++ }, ++ polygonEnd: function() { ++ d3_geo_pathArea.lineStart = d3_geo_pathArea.lineEnd = d3_geo_pathArea.point = d3_noop; ++ d3_geo_pathAreaSum += abs(d3_geo_pathAreaPolygon / 2); + } +- function d3_time_parse(date, template, string, j) { +- var c, p, t, i = 0, n = template.length, m = string.length; +- while (i < n) { +- if (j >= m) return -1; +- c = template.charCodeAt(i++); +- if (c === 37) { +- t = template.charAt(i++); +- p = d3_time_parsers[t in d3_time_formatPads ? template.charAt(i++) : t]; +- if (!p || (j = p(date, string, j)) < 0) return -1; +- } else if (c != string.charCodeAt(j++)) { +- return -1; +- } +- } +- return j; ++ }; ++ function d3_geo_pathAreaRingStart() { ++ var x00, y00, x0, y0; ++ d3_geo_pathArea.point = function(x, y) { ++ d3_geo_pathArea.point = nextPoint; ++ x00 = x0 = x, y00 = y0 = y; ++ }; ++ function nextPoint(x, y) { ++ d3_geo_pathAreaPolygon += y0 * x - x0 * y; ++ x0 = x, y0 = y; + } +- d3_time_format.utc = function(template) { +- var local = d3_time_format(template); +- function format(date) { +- try { +- d3_date = d3_date_utc; +- var utc = new d3_date(); +- utc._ = date; +- return local(utc); +- } finally { +- d3_date = Date; +- } +- } +- format.parse = function(string) { +- try { +- d3_date = d3_date_utc; +- var date = local.parse(string); +- return date && date._; +- } finally { +- d3_date = Date; +- } +- }; +- format.toString = local.toString; +- return format; ++ d3_geo_pathArea.lineEnd = function() { ++ nextPoint(x00, y00); + }; +- d3_time_format.multi = d3_time_format.utc.multi = d3_time_formatMulti; +- var d3_time_periodLookup = d3.map(), d3_time_dayRe = d3_time_formatRe(locale_days), d3_time_dayLookup = d3_time_formatLookup(locale_days), d3_time_dayAbbrevRe = d3_time_formatRe(locale_shortDays), d3_time_dayAbbrevLookup = d3_time_formatLookup(locale_shortDays), d3_time_monthRe = d3_time_formatRe(locale_months), d3_time_monthLookup = d3_time_formatLookup(locale_months), d3_time_monthAbbrevRe = d3_time_formatRe(locale_shortMonths), d3_time_monthAbbrevLookup = d3_time_formatLookup(locale_shortMonths); +- locale_periods.forEach(function(p, i) { +- d3_time_periodLookup.set(p.toLowerCase(), i); +- }); +- var d3_time_formats = { +- a: function(d) { +- return locale_shortDays[d.getDay()]; +- }, +- A: function(d) { +- return locale_days[d.getDay()]; +- }, +- b: function(d) { +- return locale_shortMonths[d.getMonth()]; +- }, +- B: function(d) { +- return locale_months[d.getMonth()]; +- }, +- c: d3_time_format(locale_dateTime), +- d: function(d, p) { +- return d3_time_formatPad(d.getDate(), p, 2); +- }, +- e: function(d, p) { +- return d3_time_formatPad(d.getDate(), p, 2); +- }, +- H: function(d, p) { +- return d3_time_formatPad(d.getHours(), p, 2); +- }, +- I: function(d, p) { +- return d3_time_formatPad(d.getHours() % 12 || 12, p, 2); +- }, +- j: function(d, p) { +- return d3_time_formatPad(1 + d3_time.dayOfYear(d), p, 3); +- }, +- L: function(d, p) { +- return d3_time_formatPad(d.getMilliseconds(), p, 3); +- }, +- m: function(d, p) { +- return d3_time_formatPad(d.getMonth() + 1, p, 2); +- }, +- M: function(d, p) { +- return d3_time_formatPad(d.getMinutes(), p, 2); +- }, +- p: function(d) { +- return locale_periods[+(d.getHours() >= 12)]; +- }, +- S: function(d, p) { +- return d3_time_formatPad(d.getSeconds(), p, 2); +- }, +- U: function(d, p) { +- return d3_time_formatPad(d3_time.sundayOfYear(d), p, 2); +- }, +- w: function(d) { +- return d.getDay(); ++ } ++ var d3_geo_pathBoundsX0, d3_geo_pathBoundsY0, d3_geo_pathBoundsX1, d3_geo_pathBoundsY1; ++ var d3_geo_pathBounds = { ++ point: d3_geo_pathBoundsPoint, ++ lineStart: d3_noop, ++ lineEnd: d3_noop, ++ polygonStart: d3_noop, ++ polygonEnd: d3_noop ++ }; ++ function d3_geo_pathBoundsPoint(x, y) { ++ if (x < d3_geo_pathBoundsX0) d3_geo_pathBoundsX0 = x; ++ if (x > d3_geo_pathBoundsX1) d3_geo_pathBoundsX1 = x; ++ if (y < d3_geo_pathBoundsY0) d3_geo_pathBoundsY0 = y; ++ if (y > d3_geo_pathBoundsY1) d3_geo_pathBoundsY1 = y; ++ } ++ function d3_geo_pathBuffer() { ++ var pointCircle = d3_geo_pathBufferCircle(4.5), buffer = []; ++ var stream = { ++ point: point, ++ lineStart: function() { ++ stream.point = pointLineStart; + }, +- W: function(d, p) { +- return d3_time_formatPad(d3_time.mondayOfYear(d), p, 2); ++ lineEnd: lineEnd, ++ polygonStart: function() { ++ stream.lineEnd = lineEndPolygon; + }, +- x: d3_time_format(locale_date), +- X: d3_time_format(locale_time), +- y: function(d, p) { +- return d3_time_formatPad(d.getFullYear() % 100, p, 2); ++ polygonEnd: function() { ++ stream.lineEnd = lineEnd; ++ stream.point = point; + }, +- Y: function(d, p) { +- return d3_time_formatPad(d.getFullYear() % 1e4, p, 4); ++ pointRadius: function(_) { ++ pointCircle = d3_geo_pathBufferCircle(_); ++ return stream; + }, +- Z: d3_time_zone, +- "%": function() { +- return "%"; ++ result: function() { ++ if (buffer.length) { ++ var result = buffer.join(""); ++ buffer = []; ++ return result; ++ } + } + }; +- var d3_time_parsers = { +- a: d3_time_parseWeekdayAbbrev, +- A: d3_time_parseWeekday, +- b: d3_time_parseMonthAbbrev, +- B: d3_time_parseMonth, +- c: d3_time_parseLocaleFull, +- d: d3_time_parseDay, +- e: d3_time_parseDay, +- H: d3_time_parseHour24, +- I: d3_time_parseHour24, +- j: d3_time_parseDayOfYear, +- L: d3_time_parseMilliseconds, +- m: d3_time_parseMonthNumber, +- M: d3_time_parseMinutes, +- p: d3_time_parseAmPm, +- S: d3_time_parseSeconds, +- U: d3_time_parseWeekNumberSunday, +- w: d3_time_parseWeekdayNumber, +- W: d3_time_parseWeekNumberMonday, +- x: d3_time_parseLocaleDate, +- X: d3_time_parseLocaleTime, +- y: d3_time_parseYear, +- Y: d3_time_parseFullYear, +- Z: d3_time_parseZone, +- "%": d3_time_parseLiteralPercent ++ function point(x, y) { ++ buffer.push("M", x, ",", y, pointCircle); ++ } ++ function pointLineStart(x, y) { ++ buffer.push("M", x, ",", y); ++ stream.point = pointLine; ++ } ++ function pointLine(x, y) { ++ buffer.push("L", x, ",", y); ++ } ++ function lineEnd() { ++ stream.point = point; ++ } ++ function lineEndPolygon() { ++ buffer.push("Z"); ++ } ++ return stream; ++ } ++ function d3_geo_pathBufferCircle(radius) { ++ return "m0," + radius + "a" + radius + "," + radius + " 0 1,1 0," + -2 * radius + "a" + radius + "," + radius + " 0 1,1 0," + 2 * radius + "z"; ++ } ++ var d3_geo_pathCentroid = { ++ point: d3_geo_pathCentroidPoint, ++ lineStart: d3_geo_pathCentroidLineStart, ++ lineEnd: d3_geo_pathCentroidLineEnd, ++ polygonStart: function() { ++ d3_geo_pathCentroid.lineStart = d3_geo_pathCentroidRingStart; ++ }, ++ polygonEnd: function() { ++ d3_geo_pathCentroid.point = d3_geo_pathCentroidPoint; ++ d3_geo_pathCentroid.lineStart = d3_geo_pathCentroidLineStart; ++ d3_geo_pathCentroid.lineEnd = d3_geo_pathCentroidLineEnd; ++ } ++ }; ++ function d3_geo_pathCentroidPoint(x, y) { ++ d3_geo_centroidX0 += x; ++ d3_geo_centroidY0 += y; ++ ++d3_geo_centroidZ0; ++ } ++ function d3_geo_pathCentroidLineStart() { ++ var x0, y0; ++ d3_geo_pathCentroid.point = function(x, y) { ++ d3_geo_pathCentroid.point = nextPoint; ++ d3_geo_pathCentroidPoint(x0 = x, y0 = y); ++ }; ++ function nextPoint(x, y) { ++ var dx = x - x0, dy = y - y0, z = Math.sqrt(dx * dx + dy * dy); ++ d3_geo_centroidX1 += z * (x0 + x) / 2; ++ d3_geo_centroidY1 += z * (y0 + y) / 2; ++ d3_geo_centroidZ1 += z; ++ d3_geo_pathCentroidPoint(x0 = x, y0 = y); ++ } ++ } ++ function d3_geo_pathCentroidLineEnd() { ++ d3_geo_pathCentroid.point = d3_geo_pathCentroidPoint; ++ } ++ function d3_geo_pathCentroidRingStart() { ++ var x00, y00, x0, y0; ++ d3_geo_pathCentroid.point = function(x, y) { ++ d3_geo_pathCentroid.point = nextPoint; ++ d3_geo_pathCentroidPoint(x00 = x0 = x, y00 = y0 = y); ++ }; ++ function nextPoint(x, y) { ++ var dx = x - x0, dy = y - y0, z = Math.sqrt(dx * dx + dy * dy); ++ d3_geo_centroidX1 += z * (x0 + x) / 2; ++ d3_geo_centroidY1 += z * (y0 + y) / 2; ++ d3_geo_centroidZ1 += z; ++ z = y0 * x - x0 * y; ++ d3_geo_centroidX2 += z * (x0 + x); ++ d3_geo_centroidY2 += z * (y0 + y); ++ d3_geo_centroidZ2 += z * 3; ++ d3_geo_pathCentroidPoint(x0 = x, y0 = y); ++ } ++ d3_geo_pathCentroid.lineEnd = function() { ++ nextPoint(x00, y00); ++ }; ++ } ++ function d3_geo_pathContext(context) { ++ var pointRadius = 4.5; ++ var stream = { ++ point: point, ++ lineStart: function() { ++ stream.point = pointLineStart; ++ }, ++ lineEnd: lineEnd, ++ polygonStart: function() { ++ stream.lineEnd = lineEndPolygon; ++ }, ++ polygonEnd: function() { ++ stream.lineEnd = lineEnd; ++ stream.point = point; ++ }, ++ pointRadius: function(_) { ++ pointRadius = _; ++ return stream; ++ }, ++ result: d3_noop + }; +- function d3_time_parseWeekdayAbbrev(date, string, i) { +- d3_time_dayAbbrevRe.lastIndex = 0; +- var n = d3_time_dayAbbrevRe.exec(string.slice(i)); +- return n ? (date.w = d3_time_dayAbbrevLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; ++ function point(x, y) { ++ context.moveTo(x + pointRadius, y); ++ context.arc(x, y, pointRadius, 0, τ); + } +- function d3_time_parseWeekday(date, string, i) { +- d3_time_dayRe.lastIndex = 0; +- var n = d3_time_dayRe.exec(string.slice(i)); +- return n ? (date.w = d3_time_dayLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; ++ function pointLineStart(x, y) { ++ context.moveTo(x, y); ++ stream.point = pointLine; + } +- function d3_time_parseMonthAbbrev(date, string, i) { +- d3_time_monthAbbrevRe.lastIndex = 0; +- var n = d3_time_monthAbbrevRe.exec(string.slice(i)); +- return n ? (date.m = d3_time_monthAbbrevLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; ++ function pointLine(x, y) { ++ context.lineTo(x, y); + } +- function d3_time_parseMonth(date, string, i) { +- d3_time_monthRe.lastIndex = 0; +- var n = d3_time_monthRe.exec(string.slice(i)); +- return n ? (date.m = d3_time_monthLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; ++ function lineEnd() { ++ stream.point = point; + } +- function d3_time_parseLocaleFull(date, string, i) { +- return d3_time_parse(date, d3_time_formats.c.toString(), string, i); ++ function lineEndPolygon() { ++ context.closePath(); + } +- function d3_time_parseLocaleDate(date, string, i) { +- return d3_time_parse(date, d3_time_formats.x.toString(), string, i); ++ return stream; ++ } ++ function d3_geo_resample(project) { ++ var δ2 = .5, cosMinDistance = Math.cos(30 * d3_radians), maxDepth = 16; ++ function resample(stream) { ++ return (maxDepth ? resampleRecursive : resampleNone)(stream); + } +- function d3_time_parseLocaleTime(date, string, i) { +- return d3_time_parse(date, d3_time_formats.X.toString(), string, i); ++ function resampleNone(stream) { ++ return d3_geo_transformPoint(stream, function(x, y) { ++ x = project(x, y); ++ stream.point(x[0], x[1]); ++ }); + } +- function d3_time_parseAmPm(date, string, i) { +- var n = d3_time_periodLookup.get(string.slice(i, i += 2).toLowerCase()); +- return n == null ? -1 : (date.p = n, i); ++ function resampleRecursive(stream) { ++ var λ00, φ00, x00, y00, a00, b00, c00, λ0, x0, y0, a0, b0, c0; ++ var resample = { ++ point: point, ++ lineStart: lineStart, ++ lineEnd: lineEnd, ++ polygonStart: function() { ++ stream.polygonStart(); ++ resample.lineStart = ringStart; ++ }, ++ polygonEnd: function() { ++ stream.polygonEnd(); ++ resample.lineStart = lineStart; ++ } ++ }; ++ function point(x, y) { ++ x = project(x, y); ++ stream.point(x[0], x[1]); ++ } ++ function lineStart() { ++ x0 = NaN; ++ resample.point = linePoint; ++ stream.lineStart(); ++ } ++ function linePoint(λ, φ) { ++ var c = d3_geo_cartesian([ λ, φ ]), p = project(λ, φ); ++ resampleLineTo(x0, y0, λ0, a0, b0, c0, x0 = p[0], y0 = p[1], λ0 = λ, a0 = c[0], b0 = c[1], c0 = c[2], maxDepth, stream); ++ stream.point(x0, y0); ++ } ++ function lineEnd() { ++ resample.point = point; ++ stream.lineEnd(); ++ } ++ function ringStart() { ++ lineStart(); ++ resample.point = ringPoint; ++ resample.lineEnd = ringEnd; ++ } ++ function ringPoint(λ, φ) { ++ linePoint(λ00 = λ, φ00 = φ), x00 = x0, y00 = y0, a00 = a0, b00 = b0, c00 = c0; ++ resample.point = linePoint; ++ } ++ function ringEnd() { ++ resampleLineTo(x0, y0, λ0, a0, b0, c0, x00, y00, λ00, a00, b00, c00, maxDepth, stream); ++ resample.lineEnd = lineEnd; ++ lineEnd(); ++ } ++ return resample; + } +- return d3_time_format; +- } +- var d3_time_formatPads = { +- "-": "", +- _: " ", +- "0": "0" +- }, d3_time_numberRe = /^\s*\d+/, d3_time_percentRe = /^%/; +- function d3_time_formatPad(value, fill, width) { +- var sign = value < 0 ? "-" : "", string = (sign ? -value : value) + "", length = string.length; +- return sign + (length < width ? new Array(width - length + 1).join(fill) + string : string); +- } +- function d3_time_formatRe(names) { +- return new RegExp("^(?:" + names.map(d3.requote).join("|") + ")", "i"); +- } +- function d3_time_formatLookup(names) { +- var map = new d3_Map(), i = -1, n = names.length; +- while (++i < n) map.set(names[i].toLowerCase(), i); +- return map; +- } +- function d3_time_parseWeekdayNumber(date, string, i) { +- d3_time_numberRe.lastIndex = 0; +- var n = d3_time_numberRe.exec(string.slice(i, i + 1)); +- return n ? (date.w = +n[0], i + n[0].length) : -1; +- } +- function d3_time_parseWeekNumberSunday(date, string, i) { +- d3_time_numberRe.lastIndex = 0; +- var n = d3_time_numberRe.exec(string.slice(i)); +- return n ? (date.U = +n[0], i + n[0].length) : -1; +- } +- function d3_time_parseWeekNumberMonday(date, string, i) { +- d3_time_numberRe.lastIndex = 0; +- var n = d3_time_numberRe.exec(string.slice(i)); +- return n ? (date.W = +n[0], i + n[0].length) : -1; +- } +- function d3_time_parseFullYear(date, string, i) { +- d3_time_numberRe.lastIndex = 0; +- var n = d3_time_numberRe.exec(string.slice(i, i + 4)); +- return n ? (date.y = +n[0], i + n[0].length) : -1; +- } +- function d3_time_parseYear(date, string, i) { +- d3_time_numberRe.lastIndex = 0; +- var n = d3_time_numberRe.exec(string.slice(i, i + 2)); +- return n ? (date.y = d3_time_expandYear(+n[0]), i + n[0].length) : -1; ++ function resampleLineTo(x0, y0, λ0, a0, b0, c0, x1, y1, λ1, a1, b1, c1, depth, stream) { ++ var dx = x1 - x0, dy = y1 - y0, d2 = dx * dx + dy * dy; ++ if (d2 > 4 * δ2 && depth--) { ++ var a = a0 + a1, b = b0 + b1, c = c0 + c1, m = Math.sqrt(a * a + b * b + c * c), φ2 = Math.asin(c /= m), λ2 = abs(abs(c) - 1) < ε || abs(λ0 - λ1) < ε ? (λ0 + λ1) / 2 : Math.atan2(b, a), p = project(λ2, φ2), x2 = p[0], y2 = p[1], dx2 = x2 - x0, dy2 = y2 - y0, dz = dy * dx2 - dx * dy2; ++ if (dz * dz / d2 > δ2 || abs((dx * dx2 + dy * dy2) / d2 - .5) > .3 || a0 * a1 + b0 * b1 + c0 * c1 < cosMinDistance) { ++ resampleLineTo(x0, y0, λ0, a0, b0, c0, x2, y2, λ2, a /= m, b /= m, c, depth, stream); ++ stream.point(x2, y2); ++ resampleLineTo(x2, y2, λ2, a, b, c, x1, y1, λ1, a1, b1, c1, depth, stream); ++ } ++ } ++ } ++ resample.precision = function(_) { ++ if (!arguments.length) return Math.sqrt(δ2); ++ maxDepth = (δ2 = _ * _) > 0 && 16; ++ return resample; ++ }; ++ return resample; + } +- function d3_time_parseZone(date, string, i) { +- return /^[+-]\d{4}$/.test(string = string.slice(i, i + 5)) ? (date.Z = -string, +- i + 5) : -1; ++ d3.geo.path = function() { ++ var pointRadius = 4.5, projection, context, projectStream, contextStream, cacheStream; ++ function path(object) { ++ if (object) { ++ if (typeof pointRadius === "function") contextStream.pointRadius(+pointRadius.apply(this, arguments)); ++ if (!cacheStream || !cacheStream.valid) cacheStream = projectStream(contextStream); ++ d3.geo.stream(object, cacheStream); ++ } ++ return contextStream.result(); ++ } ++ path.area = function(object) { ++ d3_geo_pathAreaSum = 0; ++ d3.geo.stream(object, projectStream(d3_geo_pathArea)); ++ return d3_geo_pathAreaSum; ++ }; ++ path.centroid = function(object) { ++ d3_geo_centroidX0 = d3_geo_centroidY0 = d3_geo_centroidZ0 = d3_geo_centroidX1 = d3_geo_centroidY1 = d3_geo_centroidZ1 = d3_geo_centroidX2 = d3_geo_centroidY2 = d3_geo_centroidZ2 = 0; ++ d3.geo.stream(object, projectStream(d3_geo_pathCentroid)); ++ return d3_geo_centroidZ2 ? [ d3_geo_centroidX2 / d3_geo_centroidZ2, d3_geo_centroidY2 / d3_geo_centroidZ2 ] : d3_geo_centroidZ1 ? [ d3_geo_centroidX1 / d3_geo_centroidZ1, d3_geo_centroidY1 / d3_geo_centroidZ1 ] : d3_geo_centroidZ0 ? [ d3_geo_centroidX0 / d3_geo_centroidZ0, d3_geo_centroidY0 / d3_geo_centroidZ0 ] : [ NaN, NaN ]; ++ }; ++ path.bounds = function(object) { ++ d3_geo_pathBoundsX1 = d3_geo_pathBoundsY1 = -(d3_geo_pathBoundsX0 = d3_geo_pathBoundsY0 = Infinity); ++ d3.geo.stream(object, projectStream(d3_geo_pathBounds)); ++ return [ [ d3_geo_pathBoundsX0, d3_geo_pathBoundsY0 ], [ d3_geo_pathBoundsX1, d3_geo_pathBoundsY1 ] ]; ++ }; ++ path.projection = function(_) { ++ if (!arguments.length) return projection; ++ projectStream = (projection = _) ? _.stream || d3_geo_pathProjectStream(_) : d3_identity; ++ return reset(); ++ }; ++ path.context = function(_) { ++ if (!arguments.length) return context; ++ contextStream = (context = _) == null ? new d3_geo_pathBuffer() : new d3_geo_pathContext(_); ++ if (typeof pointRadius !== "function") contextStream.pointRadius(pointRadius); ++ return reset(); ++ }; ++ path.pointRadius = function(_) { ++ if (!arguments.length) return pointRadius; ++ pointRadius = typeof _ === "function" ? _ : (contextStream.pointRadius(+_), +_); ++ return path; ++ }; ++ function reset() { ++ cacheStream = null; ++ return path; ++ } ++ return path.projection(d3.geo.albersUsa()).context(null); ++ }; ++ function d3_geo_pathProjectStream(project) { ++ var resample = d3_geo_resample(function(x, y) { ++ return project([ x * d3_degrees, y * d3_degrees ]); ++ }); ++ return function(stream) { ++ return d3_geo_projectionRadians(resample(stream)); ++ }; + } +- function d3_time_expandYear(d) { +- return d + (d > 68 ? 1900 : 2e3); ++ d3.geo.transform = function(methods) { ++ return { ++ stream: function(stream) { ++ var transform = new d3_geo_transform(stream); ++ for (var k in methods) transform[k] = methods[k]; ++ return transform; ++ } ++ }; ++ }; ++ function d3_geo_transform(stream) { ++ this.stream = stream; + } +- function d3_time_parseMonthNumber(date, string, i) { +- d3_time_numberRe.lastIndex = 0; +- var n = d3_time_numberRe.exec(string.slice(i, i + 2)); +- return n ? (date.m = n[0] - 1, i + n[0].length) : -1; ++ d3_geo_transform.prototype = { ++ point: function(x, y) { ++ this.stream.point(x, y); ++ }, ++ sphere: function() { ++ this.stream.sphere(); ++ }, ++ lineStart: function() { ++ this.stream.lineStart(); ++ }, ++ lineEnd: function() { ++ this.stream.lineEnd(); ++ }, ++ polygonStart: function() { ++ this.stream.polygonStart(); ++ }, ++ polygonEnd: function() { ++ this.stream.polygonEnd(); ++ } ++ }; ++ function d3_geo_transformPoint(stream, point) { ++ return { ++ point: point, ++ sphere: function() { ++ stream.sphere(); ++ }, ++ lineStart: function() { ++ stream.lineStart(); ++ }, ++ lineEnd: function() { ++ stream.lineEnd(); ++ }, ++ polygonStart: function() { ++ stream.polygonStart(); ++ }, ++ polygonEnd: function() { ++ stream.polygonEnd(); ++ } ++ }; + } +- function d3_time_parseDay(date, string, i) { +- d3_time_numberRe.lastIndex = 0; +- var n = d3_time_numberRe.exec(string.slice(i, i + 2)); +- return n ? (date.d = +n[0], i + n[0].length) : -1; ++ d3.geo.projection = d3_geo_projection; ++ d3.geo.projectionMutator = d3_geo_projectionMutator; ++ function d3_geo_projection(project) { ++ return d3_geo_projectionMutator(function() { ++ return project; ++ })(); + } +- function d3_time_parseDayOfYear(date, string, i) { +- d3_time_numberRe.lastIndex = 0; +- var n = d3_time_numberRe.exec(string.slice(i, i + 3)); +- return n ? (date.j = +n[0], i + n[0].length) : -1; ++ function d3_geo_projectionMutator(projectAt) { ++ var project, rotate, projectRotate, projectResample = d3_geo_resample(function(x, y) { ++ x = project(x, y); ++ return [ x[0] * k + δx, δy - x[1] * k ]; ++ }), k = 150, x = 480, y = 250, λ = 0, φ = 0, δλ = 0, δφ = 0, δγ = 0, δx, δy, preclip = d3_geo_clipAntimeridian, postclip = d3_identity, clipAngle = null, clipExtent = null, stream; ++ function projection(point) { ++ point = projectRotate(point[0] * d3_radians, point[1] * d3_radians); ++ return [ point[0] * k + δx, δy - point[1] * k ]; ++ } ++ function invert(point) { ++ point = projectRotate.invert((point[0] - δx) / k, (δy - point[1]) / k); ++ return point && [ point[0] * d3_degrees, point[1] * d3_degrees ]; ++ } ++ projection.stream = function(output) { ++ if (stream) stream.valid = false; ++ stream = d3_geo_projectionRadians(preclip(rotate, projectResample(postclip(output)))); ++ stream.valid = true; ++ return stream; ++ }; ++ projection.clipAngle = function(_) { ++ if (!arguments.length) return clipAngle; ++ preclip = _ == null ? (clipAngle = _, d3_geo_clipAntimeridian) : d3_geo_clipCircle((clipAngle = +_) * d3_radians); ++ return invalidate(); ++ }; ++ projection.clipExtent = function(_) { ++ if (!arguments.length) return clipExtent; ++ clipExtent = _; ++ postclip = _ ? d3_geo_clipExtent(_[0][0], _[0][1], _[1][0], _[1][1]) : d3_identity; ++ return invalidate(); ++ }; ++ projection.scale = function(_) { ++ if (!arguments.length) return k; ++ k = +_; ++ return reset(); ++ }; ++ projection.translate = function(_) { ++ if (!arguments.length) return [ x, y ]; ++ x = +_[0]; ++ y = +_[1]; ++ return reset(); ++ }; ++ projection.center = function(_) { ++ if (!arguments.length) return [ λ * d3_degrees, φ * d3_degrees ]; ++ λ = _[0] % 360 * d3_radians; ++ φ = _[1] % 360 * d3_radians; ++ return reset(); ++ }; ++ projection.rotate = function(_) { ++ if (!arguments.length) return [ δλ * d3_degrees, δφ * d3_degrees, δγ * d3_degrees ]; ++ δλ = _[0] % 360 * d3_radians; ++ δφ = _[1] % 360 * d3_radians; ++ δγ = _.length > 2 ? _[2] % 360 * d3_radians : 0; ++ return reset(); ++ }; ++ d3.rebind(projection, projectResample, "precision"); ++ function reset() { ++ projectRotate = d3_geo_compose(rotate = d3_geo_rotation(δλ, δφ, δγ), project); ++ var center = project(λ, φ); ++ δx = x - center[0] * k; ++ δy = y + center[1] * k; ++ return invalidate(); ++ } ++ function invalidate() { ++ if (stream) stream.valid = false, stream = null; ++ return projection; ++ } ++ return function() { ++ project = projectAt.apply(this, arguments); ++ projection.invert = project.invert && invert; ++ return reset(); ++ }; + } +- function d3_time_parseHour24(date, string, i) { +- d3_time_numberRe.lastIndex = 0; +- var n = d3_time_numberRe.exec(string.slice(i, i + 2)); +- return n ? (date.H = +n[0], i + n[0].length) : -1; ++ function d3_geo_projectionRadians(stream) { ++ return d3_geo_transformPoint(stream, function(x, y) { ++ stream.point(x * d3_radians, y * d3_radians); ++ }); + } +- function d3_time_parseMinutes(date, string, i) { +- d3_time_numberRe.lastIndex = 0; +- var n = d3_time_numberRe.exec(string.slice(i, i + 2)); +- return n ? (date.M = +n[0], i + n[0].length) : -1; ++ function d3_geo_equirectangular(λ, φ) { ++ return [ λ, φ ]; + } +- function d3_time_parseSeconds(date, string, i) { +- d3_time_numberRe.lastIndex = 0; +- var n = d3_time_numberRe.exec(string.slice(i, i + 2)); +- return n ? (date.S = +n[0], i + n[0].length) : -1; ++ (d3.geo.equirectangular = function() { ++ return d3_geo_projection(d3_geo_equirectangular); ++ }).raw = d3_geo_equirectangular.invert = d3_geo_equirectangular; ++ d3.geo.rotation = function(rotate) { ++ rotate = d3_geo_rotation(rotate[0] % 360 * d3_radians, rotate[1] * d3_radians, rotate.length > 2 ? rotate[2] * d3_radians : 0); ++ function forward(coordinates) { ++ coordinates = rotate(coordinates[0] * d3_radians, coordinates[1] * d3_radians); ++ return coordinates[0] *= d3_degrees, coordinates[1] *= d3_degrees, coordinates; ++ } ++ forward.invert = function(coordinates) { ++ coordinates = rotate.invert(coordinates[0] * d3_radians, coordinates[1] * d3_radians); ++ return coordinates[0] *= d3_degrees, coordinates[1] *= d3_degrees, coordinates; ++ }; ++ return forward; ++ }; ++ function d3_geo_identityRotation(λ, φ) { ++ return [ λ > π ? λ - τ : λ < -π ? λ + τ : λ, φ ]; + } +- function d3_time_parseMilliseconds(date, string, i) { +- d3_time_numberRe.lastIndex = 0; +- var n = d3_time_numberRe.exec(string.slice(i, i + 3)); +- return n ? (date.L = +n[0], i + n[0].length) : -1; ++ d3_geo_identityRotation.invert = d3_geo_equirectangular; ++ function d3_geo_rotation(δλ, δφ, δγ) { ++ return δλ ? δφ || δγ ? d3_geo_compose(d3_geo_rotationλ(δλ), d3_geo_rotationφγ(δφ, δγ)) : d3_geo_rotationλ(δλ) : δφ || δγ ? d3_geo_rotationφγ(δφ, δγ) : d3_geo_identityRotation; + } +- function d3_time_zone(d) { +- var z = d.getTimezoneOffset(), zs = z > 0 ? "-" : "+", zh = abs(z) / 60 | 0, zm = abs(z) % 60; +- return zs + d3_time_formatPad(zh, "0", 2) + d3_time_formatPad(zm, "0", 2); ++ function d3_geo_forwardRotationλ(δλ) { ++ return function(λ, φ) { ++ return λ += δλ, [ λ > π ? λ - τ : λ < -π ? λ + τ : λ, φ ]; ++ }; + } +- function d3_time_parseLiteralPercent(date, string, i) { +- d3_time_percentRe.lastIndex = 0; +- var n = d3_time_percentRe.exec(string.slice(i, i + 1)); +- return n ? i + n[0].length : -1; ++ function d3_geo_rotationλ(δλ) { ++ var rotation = d3_geo_forwardRotationλ(δλ); ++ rotation.invert = d3_geo_forwardRotationλ(-δλ); ++ return rotation; + } +- function d3_time_formatMulti(formats) { +- var n = formats.length, i = -1; +- while (++i < n) formats[i][0] = this(formats[i][0]); +- return function(date) { +- var i = 0, f = formats[i]; +- while (!f[1](date)) f = formats[++i]; +- return f[0](date); ++ function d3_geo_rotationφγ(δφ, δγ) { ++ var cosδφ = Math.cos(δφ), sinδφ = Math.sin(δφ), cosδγ = Math.cos(δγ), sinδγ = Math.sin(δγ); ++ function rotation(λ, φ) { ++ var cosφ = Math.cos(φ), x = Math.cos(λ) * cosφ, y = Math.sin(λ) * cosφ, z = Math.sin(φ), k = z * cosδφ + x * sinδφ; ++ return [ Math.atan2(y * cosδγ - k * sinδγ, x * cosδφ - z * sinδφ), d3_asin(k * cosδγ + y * sinδγ) ]; ++ } ++ rotation.invert = function(λ, φ) { ++ var cosφ = Math.cos(φ), x = Math.cos(λ) * cosφ, y = Math.sin(λ) * cosφ, z = Math.sin(φ), k = z * cosδγ - y * sinδγ; ++ return [ Math.atan2(y * cosδγ + z * sinδγ, x * cosδφ + k * sinδφ), d3_asin(k * cosδφ - x * sinδφ) ]; + }; ++ return rotation; + } +- d3.locale = function(locale) { +- return { +- numberFormat: d3_locale_numberFormat(locale), +- timeFormat: d3_locale_timeFormat(locale) +- }; +- }; +- var d3_locale_enUS = d3.locale({ +- decimal: ".", +- thousands: ",", +- grouping: [ 3 ], +- currency: [ "$", "" ], +- dateTime: "%a %b %e %X %Y", +- date: "%m/%d/%Y", +- time: "%H:%M:%S", +- periods: [ "AM", "PM" ], +- days: [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ], +- shortDays: [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ], +- months: [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ], +- shortMonths: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ] +- }); +- d3.format = d3_locale_enUS.numberFormat; +- d3.geo = {}; +- function d3_adder() {} +- d3_adder.prototype = { +- s: 0, +- t: 0, +- add: function(y) { +- d3_adderSum(y, this.t, d3_adderTemp); +- d3_adderSum(d3_adderTemp.s, this.s, this); +- if (this.s) this.t += d3_adderTemp.t; else this.s = d3_adderTemp.t; +- }, +- reset: function() { +- this.s = this.t = 0; +- }, +- valueOf: function() { +- return this.s; ++ d3.geo.circle = function() { ++ var origin = [ 0, 0 ], angle, precision = 6, interpolate; ++ function circle() { ++ var center = typeof origin === "function" ? origin.apply(this, arguments) : origin, rotate = d3_geo_rotation(-center[0] * d3_radians, -center[1] * d3_radians, 0).invert, ring = []; ++ interpolate(null, null, 1, { ++ point: function(x, y) { ++ ring.push(x = rotate(x, y)); ++ x[0] *= d3_degrees, x[1] *= d3_degrees; ++ } ++ }); ++ return { ++ type: "Polygon", ++ coordinates: [ ring ] ++ }; + } ++ circle.origin = function(x) { ++ if (!arguments.length) return origin; ++ origin = x; ++ return circle; ++ }; ++ circle.angle = function(x) { ++ if (!arguments.length) return angle; ++ interpolate = d3_geo_circleInterpolate((angle = +x) * d3_radians, precision * d3_radians); ++ return circle; ++ }; ++ circle.precision = function(_) { ++ if (!arguments.length) return precision; ++ interpolate = d3_geo_circleInterpolate(angle * d3_radians, (precision = +_) * d3_radians); ++ return circle; ++ }; ++ return circle.angle(90); + }; +- var d3_adderTemp = new d3_adder(); +- function d3_adderSum(a, b, o) { +- var x = o.s = a + b, bv = x - a, av = x - bv; +- o.t = a - av + (b - bv); ++ function d3_geo_circleInterpolate(radius, precision) { ++ var cr = Math.cos(radius), sr = Math.sin(radius); ++ return function(from, to, direction, listener) { ++ var step = direction * precision; ++ if (from != null) { ++ from = d3_geo_circleAngle(cr, from); ++ to = d3_geo_circleAngle(cr, to); ++ if (direction > 0 ? from < to : from > to) from += direction * τ; ++ } else { ++ from = radius + direction * τ; ++ to = radius - .5 * step; ++ } ++ for (var point, t = from; direction > 0 ? t > to : t < to; t -= step) { ++ listener.point((point = d3_geo_spherical([ cr, -sr * Math.cos(t), -sr * Math.sin(t) ]))[0], point[1]); ++ } ++ }; + } +- d3.geo.stream = function(object, listener) { +- if (object && d3_geo_streamObjectType.hasOwnProperty(object.type)) { +- d3_geo_streamObjectType[object.type](object, listener); +- } else { +- d3_geo_streamGeometry(object, listener); +- } ++ function d3_geo_circleAngle(cr, point) { ++ var a = d3_geo_cartesian(point); ++ a[0] -= cr; ++ d3_geo_cartesianNormalize(a); ++ var angle = d3_acos(-a[1]); ++ return ((-a[2] < 0 ? -angle : angle) + 2 * Math.PI - ε) % (2 * Math.PI); ++ } ++ d3.geo.distance = function(a, b) { ++ var Δλ = (b[0] - a[0]) * d3_radians, φ0 = a[1] * d3_radians, φ1 = b[1] * d3_radians, sinΔλ = Math.sin(Δλ), cosΔλ = Math.cos(Δλ), sinφ0 = Math.sin(φ0), cosφ0 = Math.cos(φ0), sinφ1 = Math.sin(φ1), cosφ1 = Math.cos(φ1), t; ++ return Math.atan2(Math.sqrt((t = cosφ1 * sinΔλ) * t + (t = cosφ0 * sinφ1 - sinφ0 * cosφ1 * cosΔλ) * t), sinφ0 * sinφ1 + cosφ0 * cosφ1 * cosΔλ); + }; +- function d3_geo_streamGeometry(geometry, listener) { +- if (geometry && d3_geo_streamGeometryType.hasOwnProperty(geometry.type)) { +- d3_geo_streamGeometryType[geometry.type](geometry, listener); ++ d3.geo.graticule = function() { ++ var x1, x0, X1, X0, y1, y0, Y1, Y0, dx = 10, dy = dx, DX = 90, DY = 360, x, y, X, Y, precision = 2.5; ++ function graticule() { ++ return { ++ type: "MultiLineString", ++ coordinates: lines() ++ }; + } +- } +- var d3_geo_streamObjectType = { +- Feature: function(feature, listener) { +- d3_geo_streamGeometry(feature.geometry, listener); +- }, +- FeatureCollection: function(object, listener) { +- var features = object.features, i = -1, n = features.length; +- while (++i < n) d3_geo_streamGeometry(features[i].geometry, listener); ++ function lines() { ++ return d3.range(Math.ceil(X0 / DX) * DX, X1, DX).map(X).concat(d3.range(Math.ceil(Y0 / DY) * DY, Y1, DY).map(Y)).concat(d3.range(Math.ceil(x0 / dx) * dx, x1, dx).filter(function(x) { ++ return abs(x % DX) > ε; ++ }).map(x)).concat(d3.range(Math.ceil(y0 / dy) * dy, y1, dy).filter(function(y) { ++ return abs(y % DY) > ε; ++ }).map(y)); + } ++ graticule.lines = function() { ++ return lines().map(function(coordinates) { ++ return { ++ type: "LineString", ++ coordinates: coordinates ++ }; ++ }); ++ }; ++ graticule.outline = function() { ++ return { ++ type: "Polygon", ++ coordinates: [ X(X0).concat(Y(Y1).slice(1), X(X1).reverse().slice(1), Y(Y0).reverse().slice(1)) ] ++ }; ++ }; ++ graticule.extent = function(_) { ++ if (!arguments.length) return graticule.minorExtent(); ++ return graticule.majorExtent(_).minorExtent(_); ++ }; ++ graticule.majorExtent = function(_) { ++ if (!arguments.length) return [ [ X0, Y0 ], [ X1, Y1 ] ]; ++ X0 = +_[0][0], X1 = +_[1][0]; ++ Y0 = +_[0][1], Y1 = +_[1][1]; ++ if (X0 > X1) _ = X0, X0 = X1, X1 = _; ++ if (Y0 > Y1) _ = Y0, Y0 = Y1, Y1 = _; ++ return graticule.precision(precision); ++ }; ++ graticule.minorExtent = function(_) { ++ if (!arguments.length) return [ [ x0, y0 ], [ x1, y1 ] ]; ++ x0 = +_[0][0], x1 = +_[1][0]; ++ y0 = +_[0][1], y1 = +_[1][1]; ++ if (x0 > x1) _ = x0, x0 = x1, x1 = _; ++ if (y0 > y1) _ = y0, y0 = y1, y1 = _; ++ return graticule.precision(precision); ++ }; ++ graticule.step = function(_) { ++ if (!arguments.length) return graticule.minorStep(); ++ return graticule.majorStep(_).minorStep(_); ++ }; ++ graticule.majorStep = function(_) { ++ if (!arguments.length) return [ DX, DY ]; ++ DX = +_[0], DY = +_[1]; ++ return graticule; ++ }; ++ graticule.minorStep = function(_) { ++ if (!arguments.length) return [ dx, dy ]; ++ dx = +_[0], dy = +_[1]; ++ return graticule; ++ }; ++ graticule.precision = function(_) { ++ if (!arguments.length) return precision; ++ precision = +_; ++ x = d3_geo_graticuleX(y0, y1, 90); ++ y = d3_geo_graticuleY(x0, x1, precision); ++ X = d3_geo_graticuleX(Y0, Y1, 90); ++ Y = d3_geo_graticuleY(X0, X1, precision); ++ return graticule; ++ }; ++ return graticule.majorExtent([ [ -180, -90 + ε ], [ 180, 90 - ε ] ]).minorExtent([ [ -180, -80 - ε ], [ 180, 80 + ε ] ]); + }; +- var d3_geo_streamGeometryType = { +- Sphere: function(object, listener) { +- listener.sphere(); +- }, +- Point: function(object, listener) { +- object = object.coordinates; +- listener.point(object[0], object[1], object[2]); +- }, +- MultiPoint: function(object, listener) { +- var coordinates = object.coordinates, i = -1, n = coordinates.length; +- while (++i < n) object = coordinates[i], listener.point(object[0], object[1], object[2]); +- }, +- LineString: function(object, listener) { +- d3_geo_streamLine(object.coordinates, listener, 0); +- }, +- MultiLineString: function(object, listener) { +- var coordinates = object.coordinates, i = -1, n = coordinates.length; +- while (++i < n) d3_geo_streamLine(coordinates[i], listener, 0); +- }, +- Polygon: function(object, listener) { +- d3_geo_streamPolygon(object.coordinates, listener); +- }, +- MultiPolygon: function(object, listener) { +- var coordinates = object.coordinates, i = -1, n = coordinates.length; +- while (++i < n) d3_geo_streamPolygon(coordinates[i], listener); +- }, +- GeometryCollection: function(object, listener) { +- var geometries = object.geometries, i = -1, n = geometries.length; +- while (++i < n) d3_geo_streamGeometry(geometries[i], listener); ++ function d3_geo_graticuleX(y0, y1, dy) { ++ var y = d3.range(y0, y1 - ε, dy).concat(y1); ++ return function(x) { ++ return y.map(function(y) { ++ return [ x, y ]; ++ }); ++ }; ++ } ++ function d3_geo_graticuleY(x0, x1, dx) { ++ var x = d3.range(x0, x1 - ε, dx).concat(x1); ++ return function(y) { ++ return x.map(function(x) { ++ return [ x, y ]; ++ }); ++ }; ++ } ++ function d3_source(d) { ++ return d.source; ++ } ++ function d3_target(d) { ++ return d.target; ++ } ++ d3.geo.greatArc = function() { ++ var source = d3_source, source_, target = d3_target, target_; ++ function greatArc() { ++ return { ++ type: "LineString", ++ coordinates: [ source_ || source.apply(this, arguments), target_ || target.apply(this, arguments) ] ++ }; + } ++ greatArc.distance = function() { ++ return d3.geo.distance(source_ || source.apply(this, arguments), target_ || target.apply(this, arguments)); ++ }; ++ greatArc.source = function(_) { ++ if (!arguments.length) return source; ++ source = _, source_ = typeof _ === "function" ? null : _; ++ return greatArc; ++ }; ++ greatArc.target = function(_) { ++ if (!arguments.length) return target; ++ target = _, target_ = typeof _ === "function" ? null : _; ++ return greatArc; ++ }; ++ greatArc.precision = function() { ++ return arguments.length ? greatArc : 0; ++ }; ++ return greatArc; + }; +- function d3_geo_streamLine(coordinates, listener, closed) { +- var i = -1, n = coordinates.length - closed, coordinate; +- listener.lineStart(); +- while (++i < n) coordinate = coordinates[i], listener.point(coordinate[0], coordinate[1], coordinate[2]); +- listener.lineEnd(); +- } +- function d3_geo_streamPolygon(coordinates, listener) { +- var i = -1, n = coordinates.length; +- listener.polygonStart(); +- while (++i < n) d3_geo_streamLine(coordinates[i], listener, 1); +- listener.polygonEnd(); ++ d3.geo.interpolate = function(source, target) { ++ return d3_geo_interpolate(source[0] * d3_radians, source[1] * d3_radians, target[0] * d3_radians, target[1] * d3_radians); ++ }; ++ function d3_geo_interpolate(x0, y0, x1, y1) { ++ var cy0 = Math.cos(y0), sy0 = Math.sin(y0), cy1 = Math.cos(y1), sy1 = Math.sin(y1), kx0 = cy0 * Math.cos(x0), ky0 = cy0 * Math.sin(x0), kx1 = cy1 * Math.cos(x1), ky1 = cy1 * Math.sin(x1), d = 2 * Math.asin(Math.sqrt(d3_haversin(y1 - y0) + cy0 * cy1 * d3_haversin(x1 - x0))), k = 1 / Math.sin(d); ++ var interpolate = d ? function(t) { ++ var B = Math.sin(t *= d) * k, A = Math.sin(d - t) * k, x = A * kx0 + B * kx1, y = A * ky0 + B * ky1, z = A * sy0 + B * sy1; ++ return [ Math.atan2(y, x) * d3_degrees, Math.atan2(z, Math.sqrt(x * x + y * y)) * d3_degrees ]; ++ } : function() { ++ return [ x0 * d3_degrees, y0 * d3_degrees ]; ++ }; ++ interpolate.distance = d; ++ return interpolate; + } +- d3.geo.area = function(object) { +- d3_geo_areaSum = 0; +- d3.geo.stream(object, d3_geo_area); +- return d3_geo_areaSum; ++ d3.geo.length = function(object) { ++ d3_geo_lengthSum = 0; ++ d3.geo.stream(object, d3_geo_length); ++ return d3_geo_lengthSum; + }; +- var d3_geo_areaSum, d3_geo_areaRingSum = new d3_adder(); +- var d3_geo_area = { +- sphere: function() { +- d3_geo_areaSum += 4 * π; +- }, ++ var d3_geo_lengthSum; ++ var d3_geo_length = { ++ sphere: d3_noop, + point: d3_noop, +- lineStart: d3_noop, ++ lineStart: d3_geo_lengthLineStart, + lineEnd: d3_noop, +- polygonStart: function() { +- d3_geo_areaRingSum.reset(); +- d3_geo_area.lineStart = d3_geo_areaRingStart; +- }, +- polygonEnd: function() { +- var area = 2 * d3_geo_areaRingSum; +- d3_geo_areaSum += area < 0 ? 4 * π + area : area; +- d3_geo_area.lineStart = d3_geo_area.lineEnd = d3_geo_area.point = d3_noop; +- } ++ polygonStart: d3_noop, ++ polygonEnd: d3_noop + }; +- function d3_geo_areaRingStart() { +- var λ00, φ00, λ0, cosφ0, sinφ0; +- d3_geo_area.point = function(λ, φ) { +- d3_geo_area.point = nextPoint; +- λ0 = (λ00 = λ) * d3_radians, cosφ0 = Math.cos(φ = (φ00 = φ) * d3_radians / 2 + π / 4), +- sinφ0 = Math.sin(φ); ++ function d3_geo_lengthLineStart() { ++ var λ0, sinφ0, cosφ0; ++ d3_geo_length.point = function(λ, φ) { ++ λ0 = λ * d3_radians, sinφ0 = Math.sin(φ *= d3_radians), cosφ0 = Math.cos(φ); ++ d3_geo_length.point = nextPoint; ++ }; ++ d3_geo_length.lineEnd = function() { ++ d3_geo_length.point = d3_geo_length.lineEnd = d3_noop; + }; + function nextPoint(λ, φ) { +- λ *= d3_radians; +- φ = φ * d3_radians / 2 + π / 4; +- var dλ = λ - λ0, sdλ = dλ >= 0 ? 1 : -1, adλ = sdλ * dλ, cosφ = Math.cos(φ), sinφ = Math.sin(φ), k = sinφ0 * sinφ, u = cosφ0 * cosφ + k * Math.cos(adλ), v = k * sdλ * Math.sin(adλ); +- d3_geo_areaRingSum.add(Math.atan2(v, u)); +- λ0 = λ, cosφ0 = cosφ, sinφ0 = sinφ; ++ var sinφ = Math.sin(φ *= d3_radians), cosφ = Math.cos(φ), t = abs((λ *= d3_radians) - λ0), cosΔλ = Math.cos(t); ++ d3_geo_lengthSum += Math.atan2(Math.sqrt((t = cosφ * Math.sin(t)) * t + (t = cosφ0 * sinφ - sinφ0 * cosφ * cosΔλ) * t), sinφ0 * sinφ + cosφ0 * cosφ * cosΔλ); ++ λ0 = λ, sinφ0 = sinφ, cosφ0 = cosφ; + } +- d3_geo_area.lineEnd = function() { +- nextPoint(λ00, φ00); +- }; +- } +- function d3_geo_cartesian(spherical) { +- var λ = spherical[0], φ = spherical[1], cosφ = Math.cos(φ); +- return [ cosφ * Math.cos(λ), cosφ * Math.sin(λ), Math.sin(φ) ]; +- } +- function d3_geo_cartesianDot(a, b) { +- return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; +- } +- function d3_geo_cartesianCross(a, b) { +- return [ a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0] ]; +- } +- function d3_geo_cartesianAdd(a, b) { +- a[0] += b[0]; +- a[1] += b[1]; +- a[2] += b[2]; + } +- function d3_geo_cartesianScale(vector, k) { +- return [ vector[0] * k, vector[1] * k, vector[2] * k ]; ++ function d3_geo_azimuthal(scale, angle) { ++ function azimuthal(λ, φ) { ++ var cosλ = Math.cos(λ), cosφ = Math.cos(φ), k = scale(cosλ * cosφ); ++ return [ k * cosφ * Math.sin(λ), k * Math.sin(φ) ]; ++ } ++ azimuthal.invert = function(x, y) { ++ var ρ = Math.sqrt(x * x + y * y), c = angle(ρ), sinc = Math.sin(c), cosc = Math.cos(c); ++ return [ Math.atan2(x * sinc, ρ * cosc), Math.asin(ρ && y * sinc / ρ) ]; ++ }; ++ return azimuthal; + } +- function d3_geo_cartesianNormalize(d) { +- var l = Math.sqrt(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]); +- d[0] /= l; +- d[1] /= l; +- d[2] /= l; ++ var d3_geo_azimuthalEqualArea = d3_geo_azimuthal(function(cosλcosφ) { ++ return Math.sqrt(2 / (1 + cosλcosφ)); ++ }, function(ρ) { ++ return 2 * Math.asin(ρ / 2); ++ }); ++ (d3.geo.azimuthalEqualArea = function() { ++ return d3_geo_projection(d3_geo_azimuthalEqualArea); ++ }).raw = d3_geo_azimuthalEqualArea; ++ var d3_geo_azimuthalEquidistant = d3_geo_azimuthal(function(cosλcosφ) { ++ var c = Math.acos(cosλcosφ); ++ return c && c / Math.sin(c); ++ }, d3_identity); ++ (d3.geo.azimuthalEquidistant = function() { ++ return d3_geo_projection(d3_geo_azimuthalEquidistant); ++ }).raw = d3_geo_azimuthalEquidistant; ++ function d3_geo_conicConformal(φ0, φ1) { ++ var cosφ0 = Math.cos(φ0), t = function(φ) { ++ return Math.tan(π / 4 + φ / 2); ++ }, n = φ0 === φ1 ? Math.sin(φ0) : Math.log(cosφ0 / Math.cos(φ1)) / Math.log(t(φ1) / t(φ0)), F = cosφ0 * Math.pow(t(φ0), n) / n; ++ if (!n) return d3_geo_mercator; ++ function forward(λ, φ) { ++ if (F > 0) { ++ if (φ < -halfπ + ε) φ = -halfπ + ε; ++ } else { ++ if (φ > halfπ - ε) φ = halfπ - ε; ++ } ++ var ρ = F / Math.pow(t(φ), n); ++ return [ ρ * Math.sin(n * λ), F - ρ * Math.cos(n * λ) ]; ++ } ++ forward.invert = function(x, y) { ++ var ρ0_y = F - y, ρ = d3_sgn(n) * Math.sqrt(x * x + ρ0_y * ρ0_y); ++ return [ Math.atan2(x, ρ0_y) / n, 2 * Math.atan(Math.pow(F / ρ, 1 / n)) - halfπ ]; ++ }; ++ return forward; + } +- function d3_geo_spherical(cartesian) { +- return [ Math.atan2(cartesian[1], cartesian[0]), d3_asin(cartesian[2]) ]; ++ (d3.geo.conicConformal = function() { ++ return d3_geo_conic(d3_geo_conicConformal); ++ }).raw = d3_geo_conicConformal; ++ function d3_geo_conicEquidistant(φ0, φ1) { ++ var cosφ0 = Math.cos(φ0), n = φ0 === φ1 ? Math.sin(φ0) : (cosφ0 - Math.cos(φ1)) / (φ1 - φ0), G = cosφ0 / n + φ0; ++ if (abs(n) < ε) return d3_geo_equirectangular; ++ function forward(λ, φ) { ++ var ρ = G - φ; ++ return [ ρ * Math.sin(n * λ), G - ρ * Math.cos(n * λ) ]; ++ } ++ forward.invert = function(x, y) { ++ var ρ0_y = G - y; ++ return [ Math.atan2(x, ρ0_y) / n, G - d3_sgn(n) * Math.sqrt(x * x + ρ0_y * ρ0_y) ]; ++ }; ++ return forward; + } +- function d3_geo_sphericalEqual(a, b) { +- return abs(a[0] - b[0]) < ε && abs(a[1] - b[1]) < ε; ++ (d3.geo.conicEquidistant = function() { ++ return d3_geo_conic(d3_geo_conicEquidistant); ++ }).raw = d3_geo_conicEquidistant; ++ var d3_geo_gnomonic = d3_geo_azimuthal(function(cosλcosφ) { ++ return 1 / cosλcosφ; ++ }, Math.atan); ++ (d3.geo.gnomonic = function() { ++ return d3_geo_projection(d3_geo_gnomonic); ++ }).raw = d3_geo_gnomonic; ++ function d3_geo_mercator(λ, φ) { ++ return [ λ, Math.log(Math.tan(π / 4 + φ / 2)) ]; + } +- d3.geo.bounds = function() { +- var λ0, φ0, λ1, φ1, λ_, λ__, φ__, p0, dλSum, ranges, range; +- var bound = { +- point: point, +- lineStart: lineStart, +- lineEnd: lineEnd, +- polygonStart: function() { +- bound.point = ringPoint; +- bound.lineStart = ringStart; +- bound.lineEnd = ringEnd; +- dλSum = 0; +- d3_geo_area.polygonStart(); +- }, +- polygonEnd: function() { +- d3_geo_area.polygonEnd(); +- bound.point = point; +- bound.lineStart = lineStart; +- bound.lineEnd = lineEnd; +- if (d3_geo_areaRingSum < 0) λ0 = -(λ1 = 180), φ0 = -(φ1 = 90); else if (dλSum > ε) φ1 = 90; else if (dλSum < -ε) φ0 = -90; +- range[0] = λ0, range[1] = λ1; +- } ++ d3_geo_mercator.invert = function(x, y) { ++ return [ x, 2 * Math.atan(Math.exp(y)) - halfπ ]; ++ }; ++ function d3_geo_mercatorProjection(project) { ++ var m = d3_geo_projection(project), scale = m.scale, translate = m.translate, clipExtent = m.clipExtent, clipAuto; ++ m.scale = function() { ++ var v = scale.apply(m, arguments); ++ return v === m ? clipAuto ? m.clipExtent(null) : m : v; + }; +- function point(λ, φ) { +- ranges.push(range = [ λ0 = λ, λ1 = λ ]); +- if (φ < φ0) φ0 = φ; +- if (φ > φ1) φ1 = φ; +- } +- function linePoint(λ, φ) { +- var p = d3_geo_cartesian([ λ * d3_radians, φ * d3_radians ]); +- if (p0) { +- var normal = d3_geo_cartesianCross(p0, p), equatorial = [ normal[1], -normal[0], 0 ], inflection = d3_geo_cartesianCross(equatorial, normal); +- d3_geo_cartesianNormalize(inflection); +- inflection = d3_geo_spherical(inflection); +- var dλ = λ - λ_, s = dλ > 0 ? 1 : -1, λi = inflection[0] * d3_degrees * s, antimeridian = abs(dλ) > 180; +- if (antimeridian ^ (s * λ_ < λi && λi < s * λ)) { +- var φi = inflection[1] * d3_degrees; +- if (φi > φ1) φ1 = φi; +- } else if (λi = (λi + 360) % 360 - 180, antimeridian ^ (s * λ_ < λi && λi < s * λ)) { +- var φi = -inflection[1] * d3_degrees; +- if (φi < φ0) φ0 = φi; +- } else { +- if (φ < φ0) φ0 = φ; +- if (φ > φ1) φ1 = φ; +- } +- if (antimeridian) { +- if (λ < λ_) { +- if (angle(λ0, λ) > angle(λ0, λ1)) λ1 = λ; +- } else { +- if (angle(λ, λ1) > angle(λ0, λ1)) λ0 = λ; +- } +- } else { +- if (λ1 >= λ0) { +- if (λ < λ0) λ0 = λ; +- if (λ > λ1) λ1 = λ; +- } else { +- if (λ > λ_) { +- if (angle(λ0, λ) > angle(λ0, λ1)) λ1 = λ; +- } else { +- if (angle(λ, λ1) > angle(λ0, λ1)) λ0 = λ; +- } +- } ++ m.translate = function() { ++ var v = translate.apply(m, arguments); ++ return v === m ? clipAuto ? m.clipExtent(null) : m : v; ++ }; ++ m.clipExtent = function(_) { ++ var v = clipExtent.apply(m, arguments); ++ if (v === m) { ++ if (clipAuto = _ == null) { ++ var k = π * scale(), t = translate(); ++ clipExtent([ [ t[0] - k, t[1] - k ], [ t[0] + k, t[1] + k ] ]); + } +- } else { +- point(λ, φ); ++ } else if (clipAuto) { ++ v = null; + } +- p0 = p, λ_ = λ; +- } +- function lineStart() { +- bound.point = linePoint; +- } +- function lineEnd() { +- range[0] = λ0, range[1] = λ1; +- bound.point = point; +- p0 = null; +- } +- function ringPoint(λ, φ) { +- if (p0) { +- var dλ = λ - λ_; +- dλSum += abs(dλ) > 180 ? dλ + (dλ > 0 ? 360 : -360) : dλ; +- } else λ__ = λ, φ__ = φ; +- d3_geo_area.point(λ, φ); +- linePoint(λ, φ); +- } +- function ringStart() { +- d3_geo_area.lineStart(); +- } +- function ringEnd() { +- ringPoint(λ__, φ__); +- d3_geo_area.lineEnd(); +- if (abs(dλSum) > ε) λ0 = -(λ1 = 180); +- range[0] = λ0, range[1] = λ1; +- p0 = null; ++ return v; ++ }; ++ return m.clipExtent(null); ++ } ++ (d3.geo.mercator = function() { ++ return d3_geo_mercatorProjection(d3_geo_mercator); ++ }).raw = d3_geo_mercator; ++ var d3_geo_orthographic = d3_geo_azimuthal(function() { ++ return 1; ++ }, Math.asin); ++ (d3.geo.orthographic = function() { ++ return d3_geo_projection(d3_geo_orthographic); ++ }).raw = d3_geo_orthographic; ++ var d3_geo_stereographic = d3_geo_azimuthal(function(cosλcosφ) { ++ return 1 / (1 + cosλcosφ); ++ }, function(ρ) { ++ return 2 * Math.atan(ρ); ++ }); ++ (d3.geo.stereographic = function() { ++ return d3_geo_projection(d3_geo_stereographic); ++ }).raw = d3_geo_stereographic; ++ function d3_geo_transverseMercator(λ, φ) { ++ return [ Math.log(Math.tan(π / 4 + φ / 2)), -λ ]; ++ } ++ d3_geo_transverseMercator.invert = function(x, y) { ++ return [ -y, 2 * Math.atan(Math.exp(x)) - halfπ ]; ++ }; ++ (d3.geo.transverseMercator = function() { ++ var projection = d3_geo_mercatorProjection(d3_geo_transverseMercator), center = projection.center, rotate = projection.rotate; ++ projection.center = function(_) { ++ return _ ? center([ -_[1], _[0] ]) : (_ = center(), [ _[1], -_[0] ]); ++ }; ++ projection.rotate = function(_) { ++ return _ ? rotate([ _[0], _[1], _.length > 2 ? _[2] + 90 : 90 ]) : (_ = rotate(), ++ [ _[0], _[1], _[2] - 90 ]); ++ }; ++ return rotate([ 0, 0, 90 ]); ++ }).raw = d3_geo_transverseMercator; ++ d3.geom = {}; ++ function d3_geom_pointX(d) { ++ return d[0]; ++ } ++ function d3_geom_pointY(d) { ++ return d[1]; ++ } ++ d3.geom.hull = function(vertices) { ++ var x = d3_geom_pointX, y = d3_geom_pointY; ++ if (arguments.length) return hull(vertices); ++ function hull(data) { ++ if (data.length < 3) return []; ++ var fx = d3_functor(x), fy = d3_functor(y), i, n = data.length, points = [], flippedPoints = []; ++ for (i = 0; i < n; i++) { ++ points.push([ +fx.call(this, data[i], i), +fy.call(this, data[i], i), i ]); ++ } ++ points.sort(d3_geom_hullOrder); ++ for (i = 0; i < n; i++) flippedPoints.push([ points[i][0], -points[i][1] ]); ++ var upper = d3_geom_hullUpper(points), lower = d3_geom_hullUpper(flippedPoints); ++ var skipLeft = lower[0] === upper[0], skipRight = lower[lower.length - 1] === upper[upper.length - 1], polygon = []; ++ for (i = upper.length - 1; i >= 0; --i) polygon.push(data[points[upper[i]][2]]); ++ for (i = +skipLeft; i < lower.length - skipRight; ++i) polygon.push(data[points[lower[i]][2]]); ++ return polygon; + } +- function angle(λ0, λ1) { +- return (λ1 -= λ0) < 0 ? λ1 + 360 : λ1; ++ hull.x = function(_) { ++ return arguments.length ? (x = _, hull) : x; ++ }; ++ hull.y = function(_) { ++ return arguments.length ? (y = _, hull) : y; ++ }; ++ return hull; ++ }; ++ function d3_geom_hullUpper(points) { ++ var n = points.length, hull = [ 0, 1 ], hs = 2; ++ for (var i = 2; i < n; i++) { ++ while (hs > 1 && d3_cross2d(points[hull[hs - 2]], points[hull[hs - 1]], points[i]) <= 0) --hs; ++ hull[hs++] = i; + } +- function compareRanges(a, b) { +- return a[0] - b[0]; ++ return hull.slice(0, hs); ++ } ++ function d3_geom_hullOrder(a, b) { ++ return a[0] - b[0] || a[1] - b[1]; ++ } ++ d3.geom.polygon = function(coordinates) { ++ d3_subclass(coordinates, d3_geom_polygonPrototype); ++ return coordinates; ++ }; ++ var d3_geom_polygonPrototype = d3.geom.polygon.prototype = []; ++ d3_geom_polygonPrototype.area = function() { ++ var i = -1, n = this.length, a, b = this[n - 1], area = 0; ++ while (++i < n) { ++ a = b; ++ b = this[i]; ++ area += a[1] * b[0] - a[0] * b[1]; + } +- function withinRange(x, range) { +- return range[0] <= range[1] ? range[0] <= x && x <= range[1] : x < range[0] || range[1] < x; ++ return area * .5; ++ }; ++ d3_geom_polygonPrototype.centroid = function(k) { ++ var i = -1, n = this.length, x = 0, y = 0, a, b = this[n - 1], c; ++ if (!arguments.length) k = -1 / (6 * this.area()); ++ while (++i < n) { ++ a = b; ++ b = this[i]; ++ c = a[0] * b[1] - b[0] * a[1]; ++ x += (a[0] + b[0]) * c; ++ y += (a[1] + b[1]) * c; + } +- return function(feature) { +- φ1 = λ1 = -(λ0 = φ0 = Infinity); +- ranges = []; +- d3.geo.stream(feature, bound); +- var n = ranges.length; +- if (n) { +- ranges.sort(compareRanges); +- for (var i = 1, a = ranges[0], b, merged = [ a ]; i < n; ++i) { +- b = ranges[i]; +- if (withinRange(b[0], a) || withinRange(b[1], a)) { +- if (angle(a[0], b[1]) > angle(a[0], a[1])) a[1] = b[1]; +- if (angle(b[0], a[1]) > angle(a[0], a[1])) a[0] = b[0]; +- } else { +- merged.push(a = b); ++ return [ x * k, y * k ]; ++ }; ++ d3_geom_polygonPrototype.clip = function(subject) { ++ var input, closed = d3_geom_polygonClosed(subject), i = -1, n = this.length - d3_geom_polygonClosed(this), j, m, a = this[n - 1], b, c, d; ++ while (++i < n) { ++ input = subject.slice(); ++ subject.length = 0; ++ b = this[i]; ++ c = input[(m = input.length - closed) - 1]; ++ j = -1; ++ while (++j < m) { ++ d = input[j]; ++ if (d3_geom_polygonInside(d, a, b)) { ++ if (!d3_geom_polygonInside(c, a, b)) { ++ subject.push(d3_geom_polygonIntersect(c, d, a, b)); + } ++ subject.push(d); ++ } else if (d3_geom_polygonInside(c, a, b)) { ++ subject.push(d3_geom_polygonIntersect(c, d, a, b)); + } +- var best = -Infinity, dλ; +- for (var n = merged.length - 1, i = 0, a = merged[n], b; i <= n; a = b, ++i) { +- b = merged[i]; +- if ((dλ = angle(a[1], b[0])) > best) best = dλ, λ0 = b[0], λ1 = a[1]; +- } ++ c = d; + } +- ranges = range = null; +- return λ0 === Infinity || φ0 === Infinity ? [ [ NaN, NaN ], [ NaN, NaN ] ] : [ [ λ0, φ0 ], [ λ1, φ1 ] ]; +- }; +- }(); +- d3.geo.centroid = function(object) { +- d3_geo_centroidW0 = d3_geo_centroidW1 = d3_geo_centroidX0 = d3_geo_centroidY0 = d3_geo_centroidZ0 = d3_geo_centroidX1 = d3_geo_centroidY1 = d3_geo_centroidZ1 = d3_geo_centroidX2 = d3_geo_centroidY2 = d3_geo_centroidZ2 = 0; +- d3.geo.stream(object, d3_geo_centroid); +- var x = d3_geo_centroidX2, y = d3_geo_centroidY2, z = d3_geo_centroidZ2, m = x * x + y * y + z * z; +- if (m < ε2) { +- x = d3_geo_centroidX1, y = d3_geo_centroidY1, z = d3_geo_centroidZ1; +- if (d3_geo_centroidW1 < ε) x = d3_geo_centroidX0, y = d3_geo_centroidY0, z = d3_geo_centroidZ0; +- m = x * x + y * y + z * z; +- if (m < ε2) return [ NaN, NaN ]; +- } +- return [ Math.atan2(y, x) * d3_degrees, d3_asin(z / Math.sqrt(m)) * d3_degrees ]; +- }; +- var d3_geo_centroidW0, d3_geo_centroidW1, d3_geo_centroidX0, d3_geo_centroidY0, d3_geo_centroidZ0, d3_geo_centroidX1, d3_geo_centroidY1, d3_geo_centroidZ1, d3_geo_centroidX2, d3_geo_centroidY2, d3_geo_centroidZ2; +- var d3_geo_centroid = { +- sphere: d3_noop, +- point: d3_geo_centroidPoint, +- lineStart: d3_geo_centroidLineStart, +- lineEnd: d3_geo_centroidLineEnd, +- polygonStart: function() { +- d3_geo_centroid.lineStart = d3_geo_centroidRingStart; +- }, +- polygonEnd: function() { +- d3_geo_centroid.lineStart = d3_geo_centroidLineStart; ++ if (closed) subject.push(subject[0]); ++ a = b; + } ++ return subject; + }; +- function d3_geo_centroidPoint(λ, φ) { +- λ *= d3_radians; +- var cosφ = Math.cos(φ *= d3_radians); +- d3_geo_centroidPointXYZ(cosφ * Math.cos(λ), cosφ * Math.sin(λ), Math.sin(φ)); +- } +- function d3_geo_centroidPointXYZ(x, y, z) { +- ++d3_geo_centroidW0; +- d3_geo_centroidX0 += (x - d3_geo_centroidX0) / d3_geo_centroidW0; +- d3_geo_centroidY0 += (y - d3_geo_centroidY0) / d3_geo_centroidW0; +- d3_geo_centroidZ0 += (z - d3_geo_centroidZ0) / d3_geo_centroidW0; ++ function d3_geom_polygonInside(p, a, b) { ++ return (b[0] - a[0]) * (p[1] - a[1]) < (b[1] - a[1]) * (p[0] - a[0]); + } +- function d3_geo_centroidLineStart() { +- var x0, y0, z0; +- d3_geo_centroid.point = function(λ, φ) { +- λ *= d3_radians; +- var cosφ = Math.cos(φ *= d3_radians); +- x0 = cosφ * Math.cos(λ); +- y0 = cosφ * Math.sin(λ); +- z0 = Math.sin(φ); +- d3_geo_centroid.point = nextPoint; +- d3_geo_centroidPointXYZ(x0, y0, z0); +- }; +- function nextPoint(λ, φ) { +- λ *= d3_radians; +- var cosφ = Math.cos(φ *= d3_radians), x = cosφ * Math.cos(λ), y = cosφ * Math.sin(λ), z = Math.sin(φ), w = Math.atan2(Math.sqrt((w = y0 * z - z0 * y) * w + (w = z0 * x - x0 * z) * w + (w = x0 * y - y0 * x) * w), x0 * x + y0 * y + z0 * z); +- d3_geo_centroidW1 += w; +- d3_geo_centroidX1 += w * (x0 + (x0 = x)); +- d3_geo_centroidY1 += w * (y0 + (y0 = y)); +- d3_geo_centroidZ1 += w * (z0 + (z0 = z)); +- d3_geo_centroidPointXYZ(x0, y0, z0); +- } ++ function d3_geom_polygonIntersect(c, d, a, b) { ++ var x1 = c[0], x3 = a[0], x21 = d[0] - x1, x43 = b[0] - x3, y1 = c[1], y3 = a[1], y21 = d[1] - y1, y43 = b[1] - y3, ua = (x43 * (y1 - y3) - y43 * (x1 - x3)) / (y43 * x21 - x43 * y21); ++ return [ x1 + ua * x21, y1 + ua * y21 ]; + } +- function d3_geo_centroidLineEnd() { +- d3_geo_centroid.point = d3_geo_centroidPoint; ++ function d3_geom_polygonClosed(coordinates) { ++ var a = coordinates[0], b = coordinates[coordinates.length - 1]; ++ return !(a[0] - b[0] || a[1] - b[1]); + } +- function d3_geo_centroidRingStart() { +- var λ00, φ00, x0, y0, z0; +- d3_geo_centroid.point = function(λ, φ) { +- λ00 = λ, φ00 = φ; +- d3_geo_centroid.point = nextPoint; +- λ *= d3_radians; +- var cosφ = Math.cos(φ *= d3_radians); +- x0 = cosφ * Math.cos(λ); +- y0 = cosφ * Math.sin(λ); +- z0 = Math.sin(φ); +- d3_geo_centroidPointXYZ(x0, y0, z0); +- }; +- d3_geo_centroid.lineEnd = function() { +- nextPoint(λ00, φ00); +- d3_geo_centroid.lineEnd = d3_geo_centroidLineEnd; +- d3_geo_centroid.point = d3_geo_centroidPoint; +- }; +- function nextPoint(λ, φ) { +- λ *= d3_radians; +- var cosφ = Math.cos(φ *= d3_radians), x = cosφ * Math.cos(λ), y = cosφ * Math.sin(λ), z = Math.sin(φ), cx = y0 * z - z0 * y, cy = z0 * x - x0 * z, cz = x0 * y - y0 * x, m = Math.sqrt(cx * cx + cy * cy + cz * cz), u = x0 * x + y0 * y + z0 * z, v = m && -d3_acos(u) / m, w = Math.atan2(m, u); +- d3_geo_centroidX2 += v * cx; +- d3_geo_centroidY2 += v * cy; +- d3_geo_centroidZ2 += v * cz; +- d3_geo_centroidW1 += w; +- d3_geo_centroidX1 += w * (x0 + (x0 = x)); +- d3_geo_centroidY1 += w * (y0 + (y0 = y)); +- d3_geo_centroidZ1 += w * (z0 + (z0 = z)); +- d3_geo_centroidPointXYZ(x0, y0, z0); +- } ++ var d3_geom_voronoiEdges, d3_geom_voronoiCells, d3_geom_voronoiBeaches, d3_geom_voronoiBeachPool = [], d3_geom_voronoiFirstCircle, d3_geom_voronoiCircles, d3_geom_voronoiCirclePool = []; ++ function d3_geom_voronoiBeach() { ++ d3_geom_voronoiRedBlackNode(this); ++ this.edge = this.site = this.circle = null; + } +- function d3_geo_compose(a, b) { +- function compose(x, y) { +- return x = a(x, y), b(x[0], x[1]); +- } +- if (a.invert && b.invert) compose.invert = function(x, y) { +- return x = b.invert(x, y), x && a.invert(x[0], x[1]); +- }; +- return compose; ++ function d3_geom_voronoiCreateBeach(site) { ++ var beach = d3_geom_voronoiBeachPool.pop() || new d3_geom_voronoiBeach(); ++ beach.site = site; ++ return beach; + } +- function d3_true() { +- return true; ++ function d3_geom_voronoiDetachBeach(beach) { ++ d3_geom_voronoiDetachCircle(beach); ++ d3_geom_voronoiBeaches.remove(beach); ++ d3_geom_voronoiBeachPool.push(beach); ++ d3_geom_voronoiRedBlackNode(beach); + } +- function d3_geo_clipPolygon(segments, compare, clipStartInside, interpolate, listener) { +- var subject = [], clip = []; +- segments.forEach(function(segment) { +- if ((n = segment.length - 1) <= 0) return; +- var n, p0 = segment[0], p1 = segment[n]; +- if (d3_geo_sphericalEqual(p0, p1)) { +- listener.lineStart(); +- for (var i = 0; i < n; ++i) listener.point((p0 = segment[i])[0], p0[1]); +- listener.lineEnd(); +- return; +- } +- var a = new d3_geo_clipPolygonIntersection(p0, segment, null, true), b = new d3_geo_clipPolygonIntersection(p0, null, a, false); +- a.o = b; +- subject.push(a); +- clip.push(b); +- a = new d3_geo_clipPolygonIntersection(p1, segment, null, false); +- b = new d3_geo_clipPolygonIntersection(p1, null, a, true); +- a.o = b; +- subject.push(a); +- clip.push(b); +- }); +- clip.sort(compare); +- d3_geo_clipPolygonLinkCircular(subject); +- d3_geo_clipPolygonLinkCircular(clip); +- if (!subject.length) return; +- for (var i = 0, entry = clipStartInside, n = clip.length; i < n; ++i) { +- clip[i].e = entry = !entry; ++ function d3_geom_voronoiRemoveBeach(beach) { ++ var circle = beach.circle, x = circle.x, y = circle.cy, vertex = { ++ x: x, ++ y: y ++ }, previous = beach.P, next = beach.N, disappearing = [ beach ]; ++ d3_geom_voronoiDetachBeach(beach); ++ var lArc = previous; ++ while (lArc.circle && abs(x - lArc.circle.x) < ε && abs(y - lArc.circle.cy) < ε) { ++ previous = lArc.P; ++ disappearing.unshift(lArc); ++ d3_geom_voronoiDetachBeach(lArc); ++ lArc = previous; + } +- var start = subject[0], points, point; +- while (1) { +- var current = start, isSubject = true; +- while (current.v) if ((current = current.n) === start) return; +- points = current.z; +- listener.lineStart(); +- do { +- current.v = current.o.v = true; +- if (current.e) { +- if (isSubject) { +- for (var i = 0, n = points.length; i < n; ++i) listener.point((point = points[i])[0], point[1]); +- } else { +- interpolate(current.x, current.n.x, 1, listener); ++ disappearing.unshift(lArc); ++ d3_geom_voronoiDetachCircle(lArc); ++ var rArc = next; ++ while (rArc.circle && abs(x - rArc.circle.x) < ε && abs(y - rArc.circle.cy) < ε) { ++ next = rArc.N; ++ disappearing.push(rArc); ++ d3_geom_voronoiDetachBeach(rArc); ++ rArc = next; ++ } ++ disappearing.push(rArc); ++ d3_geom_voronoiDetachCircle(rArc); ++ var nArcs = disappearing.length, iArc; ++ for (iArc = 1; iArc < nArcs; ++iArc) { ++ rArc = disappearing[iArc]; ++ lArc = disappearing[iArc - 1]; ++ d3_geom_voronoiSetEdgeEnd(rArc.edge, lArc.site, rArc.site, vertex); ++ } ++ lArc = disappearing[0]; ++ rArc = disappearing[nArcs - 1]; ++ rArc.edge = d3_geom_voronoiCreateEdge(lArc.site, rArc.site, null, vertex); ++ d3_geom_voronoiAttachCircle(lArc); ++ d3_geom_voronoiAttachCircle(rArc); ++ } ++ function d3_geom_voronoiAddBeach(site) { ++ var x = site.x, directrix = site.y, lArc, rArc, dxl, dxr, node = d3_geom_voronoiBeaches._; ++ while (node) { ++ dxl = d3_geom_voronoiLeftBreakPoint(node, directrix) - x; ++ if (dxl > ε) node = node.L; else { ++ dxr = x - d3_geom_voronoiRightBreakPoint(node, directrix); ++ if (dxr > ε) { ++ if (!node.R) { ++ lArc = node; ++ break; + } +- current = current.n; ++ node = node.R; + } else { +- if (isSubject) { +- points = current.p.z; +- for (var i = points.length - 1; i >= 0; --i) listener.point((point = points[i])[0], point[1]); ++ if (dxl > -ε) { ++ lArc = node.P; ++ rArc = node; ++ } else if (dxr > -ε) { ++ lArc = node; ++ rArc = node.N; + } else { +- interpolate(current.x, current.p.x, -1, listener); ++ lArc = rArc = node; + } +- current = current.p; ++ break; + } +- current = current.o; +- points = current.z; +- isSubject = !isSubject; +- } while (!current.v); +- listener.lineEnd(); ++ } + } +- } +- function d3_geo_clipPolygonLinkCircular(array) { +- if (!(n = array.length)) return; +- var n, i = 0, a = array[0], b; +- while (++i < n) { +- a.n = b = array[i]; +- b.p = a; +- a = b; ++ var newArc = d3_geom_voronoiCreateBeach(site); ++ d3_geom_voronoiBeaches.insert(lArc, newArc); ++ if (!lArc && !rArc) return; ++ if (lArc === rArc) { ++ d3_geom_voronoiDetachCircle(lArc); ++ rArc = d3_geom_voronoiCreateBeach(lArc.site); ++ d3_geom_voronoiBeaches.insert(newArc, rArc); ++ newArc.edge = rArc.edge = d3_geom_voronoiCreateEdge(lArc.site, newArc.site); ++ d3_geom_voronoiAttachCircle(lArc); ++ d3_geom_voronoiAttachCircle(rArc); ++ return; + } +- a.n = b = array[0]; +- b.p = a; ++ if (!rArc) { ++ newArc.edge = d3_geom_voronoiCreateEdge(lArc.site, newArc.site); ++ return; ++ } ++ d3_geom_voronoiDetachCircle(lArc); ++ d3_geom_voronoiDetachCircle(rArc); ++ var lSite = lArc.site, ax = lSite.x, ay = lSite.y, bx = site.x - ax, by = site.y - ay, rSite = rArc.site, cx = rSite.x - ax, cy = rSite.y - ay, d = 2 * (bx * cy - by * cx), hb = bx * bx + by * by, hc = cx * cx + cy * cy, vertex = { ++ x: (cy * hb - by * hc) / d + ax, ++ y: (bx * hc - cx * hb) / d + ay ++ }; ++ d3_geom_voronoiSetEdgeEnd(rArc.edge, lSite, rSite, vertex); ++ newArc.edge = d3_geom_voronoiCreateEdge(lSite, site, null, vertex); ++ rArc.edge = d3_geom_voronoiCreateEdge(site, rSite, null, vertex); ++ d3_geom_voronoiAttachCircle(lArc); ++ d3_geom_voronoiAttachCircle(rArc); + } +- function d3_geo_clipPolygonIntersection(point, points, other, entry) { +- this.x = point; +- this.z = points; +- this.o = other; +- this.e = entry; +- this.v = false; +- this.n = this.p = null; ++ function d3_geom_voronoiLeftBreakPoint(arc, directrix) { ++ var site = arc.site, rfocx = site.x, rfocy = site.y, pby2 = rfocy - directrix; ++ if (!pby2) return rfocx; ++ var lArc = arc.P; ++ if (!lArc) return -Infinity; ++ site = lArc.site; ++ var lfocx = site.x, lfocy = site.y, plby2 = lfocy - directrix; ++ if (!plby2) return lfocx; ++ var hl = lfocx - rfocx, aby2 = 1 / pby2 - 1 / plby2, b = hl / plby2; ++ if (aby2) return (-b + Math.sqrt(b * b - 2 * aby2 * (hl * hl / (-2 * plby2) - lfocy + plby2 / 2 + rfocy - pby2 / 2))) / aby2 + rfocx; ++ return (rfocx + lfocx) / 2; + } +- function d3_geo_clip(pointVisible, clipLine, interpolate, clipStart) { +- return function(rotate, listener) { +- var line = clipLine(listener), rotatedClipStart = rotate.invert(clipStart[0], clipStart[1]); +- var clip = { +- point: point, +- lineStart: lineStart, +- lineEnd: lineEnd, +- polygonStart: function() { +- clip.point = pointRing; +- clip.lineStart = ringStart; +- clip.lineEnd = ringEnd; +- segments = []; +- polygon = []; +- }, +- polygonEnd: function() { +- clip.point = point; +- clip.lineStart = lineStart; +- clip.lineEnd = lineEnd; +- segments = d3.merge(segments); +- var clipStartInside = d3_geo_pointInPolygon(rotatedClipStart, polygon); +- if (segments.length) { +- if (!polygonStarted) listener.polygonStart(), polygonStarted = true; +- d3_geo_clipPolygon(segments, d3_geo_clipSort, clipStartInside, interpolate, listener); +- } else if (clipStartInside) { +- if (!polygonStarted) listener.polygonStart(), polygonStarted = true; +- listener.lineStart(); +- interpolate(null, null, 1, listener); +- listener.lineEnd(); +- } +- if (polygonStarted) listener.polygonEnd(), polygonStarted = false; +- segments = polygon = null; +- }, +- sphere: function() { +- listener.polygonStart(); +- listener.lineStart(); +- interpolate(null, null, 1, listener); +- listener.lineEnd(); +- listener.polygonEnd(); +- } +- }; +- function point(λ, φ) { +- var point = rotate(λ, φ); +- if (pointVisible(λ = point[0], φ = point[1])) listener.point(λ, φ); +- } +- function pointLine(λ, φ) { +- var point = rotate(λ, φ); +- line.point(point[0], point[1]); +- } +- function lineStart() { +- clip.point = pointLine; +- line.lineStart(); +- } +- function lineEnd() { +- clip.point = point; +- line.lineEnd(); +- } +- var segments; +- var buffer = d3_geo_clipBufferListener(), ringListener = clipLine(buffer), polygonStarted = false, polygon, ring; +- function pointRing(λ, φ) { +- ring.push([ λ, φ ]); +- var point = rotate(λ, φ); +- ringListener.point(point[0], point[1]); +- } +- function ringStart() { +- ringListener.lineStart(); +- ring = []; +- } +- function ringEnd() { +- pointRing(ring[0][0], ring[0][1]); +- ringListener.lineEnd(); +- var clean = ringListener.clean(), ringSegments = buffer.buffer(), segment, n = ringSegments.length; +- ring.pop(); +- polygon.push(ring); +- ring = null; +- if (!n) return; +- if (clean & 1) { +- segment = ringSegments[0]; +- var n = segment.length - 1, i = -1, point; +- if (n > 0) { +- if (!polygonStarted) listener.polygonStart(), polygonStarted = true; +- listener.lineStart(); +- while (++i < n) listener.point((point = segment[i])[0], point[1]); +- listener.lineEnd(); +- } +- return; ++ function d3_geom_voronoiRightBreakPoint(arc, directrix) { ++ var rArc = arc.N; ++ if (rArc) return d3_geom_voronoiLeftBreakPoint(rArc, directrix); ++ var site = arc.site; ++ return site.y === directrix ? site.x : Infinity; ++ } ++ function d3_geom_voronoiCell(site) { ++ this.site = site; ++ this.edges = []; ++ } ++ d3_geom_voronoiCell.prototype.prepare = function() { ++ var halfEdges = this.edges, iHalfEdge = halfEdges.length, edge; ++ while (iHalfEdge--) { ++ edge = halfEdges[iHalfEdge].edge; ++ if (!edge.b || !edge.a) halfEdges.splice(iHalfEdge, 1); ++ } ++ halfEdges.sort(d3_geom_voronoiHalfEdgeOrder); ++ return halfEdges.length; ++ }; ++ function d3_geom_voronoiCloseCells(extent) { ++ var x0 = extent[0][0], x1 = extent[1][0], y0 = extent[0][1], y1 = extent[1][1], x2, y2, x3, y3, cells = d3_geom_voronoiCells, iCell = cells.length, cell, iHalfEdge, halfEdges, nHalfEdges, start, end; ++ while (iCell--) { ++ cell = cells[iCell]; ++ if (!cell || !cell.prepare()) continue; ++ halfEdges = cell.edges; ++ nHalfEdges = halfEdges.length; ++ iHalfEdge = 0; ++ while (iHalfEdge < nHalfEdges) { ++ end = halfEdges[iHalfEdge].end(), x3 = end.x, y3 = end.y; ++ start = halfEdges[++iHalfEdge % nHalfEdges].start(), x2 = start.x, y2 = start.y; ++ if (abs(x3 - x2) > ε || abs(y3 - y2) > ε) { ++ halfEdges.splice(iHalfEdge, 0, new d3_geom_voronoiHalfEdge(d3_geom_voronoiCreateBorderEdge(cell.site, end, abs(x3 - x0) < ε && y1 - y3 > ε ? { ++ x: x0, ++ y: abs(x2 - x0) < ε ? y2 : y1 ++ } : abs(y3 - y1) < ε && x1 - x3 > ε ? { ++ x: abs(y2 - y1) < ε ? x2 : x1, ++ y: y1 ++ } : abs(x3 - x1) < ε && y3 - y0 > ε ? { ++ x: x1, ++ y: abs(x2 - x1) < ε ? y2 : y0 ++ } : abs(y3 - y0) < ε && x3 - x0 > ε ? { ++ x: abs(y2 - y0) < ε ? x2 : x0, ++ y: y0 ++ } : null), cell.site, null)); ++ ++nHalfEdges; + } +- if (n > 1 && clean & 2) ringSegments.push(ringSegments.pop().concat(ringSegments.shift())); +- segments.push(ringSegments.filter(d3_geo_clipSegmentLength1)); + } +- return clip; +- }; +- } +- function d3_geo_clipSegmentLength1(segment) { +- return segment.length > 1; ++ } + } +- function d3_geo_clipBufferListener() { +- var lines = [], line; +- return { +- lineStart: function() { +- lines.push(line = []); +- }, +- point: function(λ, φ) { +- line.push([ λ, φ ]); +- }, +- lineEnd: d3_noop, +- buffer: function() { +- var buffer = lines; +- lines = []; +- line = null; +- return buffer; +- }, +- rejoin: function() { +- if (lines.length > 1) lines.push(lines.pop().concat(lines.shift())); +- } +- }; ++ function d3_geom_voronoiHalfEdgeOrder(a, b) { ++ return b.angle - a.angle; + } +- function d3_geo_clipSort(a, b) { +- return ((a = a.x)[0] < 0 ? a[1] - halfπ - ε : halfπ - a[1]) - ((b = b.x)[0] < 0 ? b[1] - halfπ - ε : halfπ - b[1]); ++ function d3_geom_voronoiCircle() { ++ d3_geom_voronoiRedBlackNode(this); ++ this.x = this.y = this.arc = this.site = this.cy = null; + } +- var d3_geo_clipAntimeridian = d3_geo_clip(d3_true, d3_geo_clipAntimeridianLine, d3_geo_clipAntimeridianInterpolate, [ -π, -π / 2 ]); +- function d3_geo_clipAntimeridianLine(listener) { +- var λ0 = NaN, φ0 = NaN, sλ0 = NaN, clean; +- return { +- lineStart: function() { +- listener.lineStart(); +- clean = 1; +- }, +- point: function(λ1, φ1) { +- var sλ1 = λ1 > 0 ? π : -π, dλ = abs(λ1 - λ0); +- if (abs(dλ - π) < ε) { +- listener.point(λ0, φ0 = (φ0 + φ1) / 2 > 0 ? halfπ : -halfπ); +- listener.point(sλ0, φ0); +- listener.lineEnd(); +- listener.lineStart(); +- listener.point(sλ1, φ0); +- listener.point(λ1, φ0); +- clean = 0; +- } else if (sλ0 !== sλ1 && dλ >= π) { +- if (abs(λ0 - sλ0) < ε) λ0 -= sλ0 * ε; +- if (abs(λ1 - sλ1) < ε) λ1 -= sλ1 * ε; +- φ0 = d3_geo_clipAntimeridianIntersect(λ0, φ0, λ1, φ1); +- listener.point(sλ0, φ0); +- listener.lineEnd(); +- listener.lineStart(); +- listener.point(sλ1, φ0); +- clean = 0; ++ function d3_geom_voronoiAttachCircle(arc) { ++ var lArc = arc.P, rArc = arc.N; ++ if (!lArc || !rArc) return; ++ var lSite = lArc.site, cSite = arc.site, rSite = rArc.site; ++ if (lSite === rSite) return; ++ var bx = cSite.x, by = cSite.y, ax = lSite.x - bx, ay = lSite.y - by, cx = rSite.x - bx, cy = rSite.y - by; ++ var d = 2 * (ax * cy - ay * cx); ++ if (d >= -ε2) return; ++ var ha = ax * ax + ay * ay, hc = cx * cx + cy * cy, x = (cy * ha - ay * hc) / d, y = (ax * hc - cx * ha) / d, cy = y + by; ++ var circle = d3_geom_voronoiCirclePool.pop() || new d3_geom_voronoiCircle(); ++ circle.arc = arc; ++ circle.site = cSite; ++ circle.x = x + bx; ++ circle.y = cy + Math.sqrt(x * x + y * y); ++ circle.cy = cy; ++ arc.circle = circle; ++ var before = null, node = d3_geom_voronoiCircles._; ++ while (node) { ++ if (circle.y < node.y || circle.y === node.y && circle.x <= node.x) { ++ if (node.L) node = node.L; else { ++ before = node.P; ++ break; ++ } ++ } else { ++ if (node.R) node = node.R; else { ++ before = node; ++ break; + } +- listener.point(λ0 = λ1, φ0 = φ1); +- sλ0 = sλ1; +- }, +- lineEnd: function() { +- listener.lineEnd(); +- λ0 = φ0 = NaN; +- }, +- clean: function() { +- return 2 - clean; + } +- }; +- } +- function d3_geo_clipAntimeridianIntersect(λ0, φ0, λ1, φ1) { +- var cosφ0, cosφ1, sinλ0_λ1 = Math.sin(λ0 - λ1); +- return abs(sinλ0_λ1) > ε ? Math.atan((Math.sin(φ0) * (cosφ1 = Math.cos(φ1)) * Math.sin(λ1) - Math.sin(φ1) * (cosφ0 = Math.cos(φ0)) * Math.sin(λ0)) / (cosφ0 * cosφ1 * sinλ0_λ1)) : (φ0 + φ1) / 2; ++ } ++ d3_geom_voronoiCircles.insert(before, circle); ++ if (!before) d3_geom_voronoiFirstCircle = circle; + } +- function d3_geo_clipAntimeridianInterpolate(from, to, direction, listener) { +- var φ; +- if (from == null) { +- φ = direction * halfπ; +- listener.point(-π, φ); +- listener.point(0, φ); +- listener.point(π, φ); +- listener.point(π, 0); +- listener.point(π, -φ); +- listener.point(0, -φ); +- listener.point(-π, -φ); +- listener.point(-π, 0); +- listener.point(-π, φ); +- } else if (abs(from[0] - to[0]) > ε) { +- var s = from[0] < to[0] ? π : -π; +- φ = direction * s / 2; +- listener.point(-s, φ); +- listener.point(0, φ); +- listener.point(s, φ); +- } else { +- listener.point(to[0], to[1]); ++ function d3_geom_voronoiDetachCircle(arc) { ++ var circle = arc.circle; ++ if (circle) { ++ if (!circle.P) d3_geom_voronoiFirstCircle = circle.N; ++ d3_geom_voronoiCircles.remove(circle); ++ d3_geom_voronoiCirclePool.push(circle); ++ d3_geom_voronoiRedBlackNode(circle); ++ arc.circle = null; + } + } +- function d3_geo_pointInPolygon(point, polygon) { +- var meridian = point[0], parallel = point[1], meridianNormal = [ Math.sin(meridian), -Math.cos(meridian), 0 ], polarAngle = 0, winding = 0; +- d3_geo_areaRingSum.reset(); +- for (var i = 0, n = polygon.length; i < n; ++i) { +- var ring = polygon[i], m = ring.length; +- if (!m) continue; +- var point0 = ring[0], λ0 = point0[0], φ0 = point0[1] / 2 + π / 4, sinφ0 = Math.sin(φ0), cosφ0 = Math.cos(φ0), j = 1; +- while (true) { +- if (j === m) j = 0; +- point = ring[j]; +- var λ = point[0], φ = point[1] / 2 + π / 4, sinφ = Math.sin(φ), cosφ = Math.cos(φ), dλ = λ - λ0, sdλ = dλ >= 0 ? 1 : -1, adλ = sdλ * dλ, antimeridian = adλ > π, k = sinφ0 * sinφ; +- d3_geo_areaRingSum.add(Math.atan2(k * sdλ * Math.sin(adλ), cosφ0 * cosφ + k * Math.cos(adλ))); +- polarAngle += antimeridian ? dλ + sdλ * τ : dλ; +- if (antimeridian ^ λ0 >= meridian ^ λ >= meridian) { +- var arc = d3_geo_cartesianCross(d3_geo_cartesian(point0), d3_geo_cartesian(point)); +- d3_geo_cartesianNormalize(arc); +- var intersection = d3_geo_cartesianCross(meridianNormal, arc); +- d3_geo_cartesianNormalize(intersection); +- var φarc = (antimeridian ^ dλ >= 0 ? -1 : 1) * d3_asin(intersection[2]); +- if (parallel > φarc || parallel === φarc && (arc[0] || arc[1])) { +- winding += antimeridian ^ dλ >= 0 ? 1 : -1; +- } +- } +- if (!j++) break; +- λ0 = λ, sinφ0 = sinφ, cosφ0 = cosφ, point0 = point; ++ function d3_geom_voronoiClipEdges(extent) { ++ var edges = d3_geom_voronoiEdges, clip = d3_geom_clipLine(extent[0][0], extent[0][1], extent[1][0], extent[1][1]), i = edges.length, e; ++ while (i--) { ++ e = edges[i]; ++ if (!d3_geom_voronoiConnectEdge(e, extent) || !clip(e) || abs(e.a.x - e.b.x) < ε && abs(e.a.y - e.b.y) < ε) { ++ e.a = e.b = null; ++ edges.splice(i, 1); + } + } +- return (polarAngle < -ε || polarAngle < ε && d3_geo_areaRingSum < 0) ^ winding & 1; + } +- function d3_geo_clipCircle(radius) { +- var cr = Math.cos(radius), smallRadius = cr > 0, notHemisphere = abs(cr) > ε, interpolate = d3_geo_circleInterpolate(radius, 6 * d3_radians); +- return d3_geo_clip(visible, clipLine, interpolate, smallRadius ? [ 0, -radius ] : [ -π, radius - π ]); +- function visible(λ, φ) { +- return Math.cos(λ) * Math.cos(φ) > cr; +- } +- function clipLine(listener) { +- var point0, c0, v0, v00, clean; +- return { +- lineStart: function() { +- v00 = v0 = false; +- clean = 1; +- }, +- point: function(λ, φ) { +- var point1 = [ λ, φ ], point2, v = visible(λ, φ), c = smallRadius ? v ? 0 : code(λ, φ) : v ? code(λ + (λ < 0 ? π : -π), φ) : 0; +- if (!point0 && (v00 = v0 = v)) listener.lineStart(); +- if (v !== v0) { +- point2 = intersect(point0, point1); +- if (d3_geo_sphericalEqual(point0, point2) || d3_geo_sphericalEqual(point1, point2)) { +- point1[0] += ε; +- point1[1] += ε; +- v = visible(point1[0], point1[1]); +- } +- } +- if (v !== v0) { +- clean = 0; +- if (v) { +- listener.lineStart(); +- point2 = intersect(point1, point0); +- listener.point(point2[0], point2[1]); +- } else { +- point2 = intersect(point0, point1); +- listener.point(point2[0], point2[1]); +- listener.lineEnd(); +- } +- point0 = point2; +- } else if (notHemisphere && point0 && smallRadius ^ v) { +- var t; +- if (!(c & c0) && (t = intersect(point1, point0, true))) { +- clean = 0; +- if (smallRadius) { +- listener.lineStart(); +- listener.point(t[0][0], t[0][1]); +- listener.point(t[1][0], t[1][1]); +- listener.lineEnd(); +- } else { +- listener.point(t[1][0], t[1][1]); +- listener.lineEnd(); +- listener.lineStart(); +- listener.point(t[0][0], t[0][1]); +- } +- } +- } +- if (v && (!point0 || !d3_geo_sphericalEqual(point0, point1))) { +- listener.point(point1[0], point1[1]); +- } +- point0 = point1, v0 = v, c0 = c; +- }, +- lineEnd: function() { +- if (v0) listener.lineEnd(); +- point0 = null; +- }, +- clean: function() { +- return clean | (v00 && v0) << 1; ++ function d3_geom_voronoiConnectEdge(edge, extent) { ++ var vb = edge.b; ++ if (vb) return true; ++ var va = edge.a, x0 = extent[0][0], x1 = extent[1][0], y0 = extent[0][1], y1 = extent[1][1], lSite = edge.l, rSite = edge.r, lx = lSite.x, ly = lSite.y, rx = rSite.x, ry = rSite.y, fx = (lx + rx) / 2, fy = (ly + ry) / 2, fm, fb; ++ if (ry === ly) { ++ if (fx < x0 || fx >= x1) return; ++ if (lx > rx) { ++ if (!va) va = { ++ x: fx, ++ y: y0 ++ }; else if (va.y >= y1) return; ++ vb = { ++ x: fx, ++ y: y1 ++ }; ++ } else { ++ if (!va) va = { ++ x: fx, ++ y: y1 ++ }; else if (va.y < y0) return; ++ vb = { ++ x: fx, ++ y: y0 ++ }; ++ } ++ } else { ++ fm = (lx - rx) / (ry - ly); ++ fb = fy - fm * fx; ++ if (fm < -1 || fm > 1) { ++ if (lx > rx) { ++ if (!va) va = { ++ x: (y0 - fb) / fm, ++ y: y0 ++ }; else if (va.y >= y1) return; ++ vb = { ++ x: (y1 - fb) / fm, ++ y: y1 ++ }; ++ } else { ++ if (!va) va = { ++ x: (y1 - fb) / fm, ++ y: y1 ++ }; else if (va.y < y0) return; ++ vb = { ++ x: (y0 - fb) / fm, ++ y: y0 ++ }; ++ } ++ } else { ++ if (ly < ry) { ++ if (!va) va = { ++ x: x0, ++ y: fm * x0 + fb ++ }; else if (va.x >= x1) return; ++ vb = { ++ x: x1, ++ y: fm * x1 + fb ++ }; ++ } else { ++ if (!va) va = { ++ x: x1, ++ y: fm * x1 + fb ++ }; else if (va.x < x0) return; ++ vb = { ++ x: x0, ++ y: fm * x0 + fb ++ }; + } +- }; +- } +- function intersect(a, b, two) { +- var pa = d3_geo_cartesian(a), pb = d3_geo_cartesian(b); +- var n1 = [ 1, 0, 0 ], n2 = d3_geo_cartesianCross(pa, pb), n2n2 = d3_geo_cartesianDot(n2, n2), n1n2 = n2[0], determinant = n2n2 - n1n2 * n1n2; +- if (!determinant) return !two && a; +- var c1 = cr * n2n2 / determinant, c2 = -cr * n1n2 / determinant, n1xn2 = d3_geo_cartesianCross(n1, n2), A = d3_geo_cartesianScale(n1, c1), B = d3_geo_cartesianScale(n2, c2); +- d3_geo_cartesianAdd(A, B); +- var u = n1xn2, w = d3_geo_cartesianDot(A, u), uu = d3_geo_cartesianDot(u, u), t2 = w * w - uu * (d3_geo_cartesianDot(A, A) - 1); +- if (t2 < 0) return; +- var t = Math.sqrt(t2), q = d3_geo_cartesianScale(u, (-w - t) / uu); +- d3_geo_cartesianAdd(q, A); +- q = d3_geo_spherical(q); +- if (!two) return q; +- var λ0 = a[0], λ1 = b[0], φ0 = a[1], φ1 = b[1], z; +- if (λ1 < λ0) z = λ0, λ0 = λ1, λ1 = z; +- var δλ = λ1 - λ0, polar = abs(δλ - π) < ε, meridian = polar || δλ < ε; +- if (!polar && φ1 < φ0) z = φ0, φ0 = φ1, φ1 = z; +- if (meridian ? polar ? φ0 + φ1 > 0 ^ q[1] < (abs(q[0] - λ0) < ε ? φ0 : φ1) : φ0 <= q[1] && q[1] <= φ1 : δλ > π ^ (λ0 <= q[0] && q[0] <= λ1)) { +- var q1 = d3_geo_cartesianScale(u, (-w + t) / uu); +- d3_geo_cartesianAdd(q1, A); +- return [ q, d3_geo_spherical(q1) ]; + } + } +- function code(λ, φ) { +- var r = smallRadius ? radius : π - radius, code = 0; +- if (λ < -r) code |= 1; else if (λ > r) code |= 2; +- if (φ < -r) code |= 4; else if (φ > r) code |= 8; +- return code; ++ edge.a = va; ++ edge.b = vb; ++ return true; ++ } ++ function d3_geom_voronoiEdge(lSite, rSite) { ++ this.l = lSite; ++ this.r = rSite; ++ this.a = this.b = null; ++ } ++ function d3_geom_voronoiCreateEdge(lSite, rSite, va, vb) { ++ var edge = new d3_geom_voronoiEdge(lSite, rSite); ++ d3_geom_voronoiEdges.push(edge); ++ if (va) d3_geom_voronoiSetEdgeEnd(edge, lSite, rSite, va); ++ if (vb) d3_geom_voronoiSetEdgeEnd(edge, rSite, lSite, vb); ++ d3_geom_voronoiCells[lSite.i].edges.push(new d3_geom_voronoiHalfEdge(edge, lSite, rSite)); ++ d3_geom_voronoiCells[rSite.i].edges.push(new d3_geom_voronoiHalfEdge(edge, rSite, lSite)); ++ return edge; ++ } ++ function d3_geom_voronoiCreateBorderEdge(lSite, va, vb) { ++ var edge = new d3_geom_voronoiEdge(lSite, null); ++ edge.a = va; ++ edge.b = vb; ++ d3_geom_voronoiEdges.push(edge); ++ return edge; ++ } ++ function d3_geom_voronoiSetEdgeEnd(edge, lSite, rSite, vertex) { ++ if (!edge.a && !edge.b) { ++ edge.a = vertex; ++ edge.l = lSite; ++ edge.r = rSite; ++ } else if (edge.l === rSite) { ++ edge.b = vertex; ++ } else { ++ edge.a = vertex; + } + } +- function d3_geom_clipLine(x0, y0, x1, y1) { +- return function(line) { +- var a = line.a, b = line.b, ax = a.x, ay = a.y, bx = b.x, by = b.y, t0 = 0, t1 = 1, dx = bx - ax, dy = by - ay, r; +- r = x0 - ax; +- if (!dx && r > 0) return; +- r /= dx; +- if (dx < 0) { +- if (r < t0) return; +- if (r < t1) t1 = r; +- } else if (dx > 0) { +- if (r > t1) return; +- if (r > t0) t0 = r; +- } +- r = x1 - ax; +- if (!dx && r < 0) return; +- r /= dx; +- if (dx < 0) { +- if (r > t1) return; +- if (r > t0) t0 = r; +- } else if (dx > 0) { +- if (r < t0) return; +- if (r < t1) t1 = r; +- } +- r = y0 - ay; +- if (!dy && r > 0) return; +- r /= dy; +- if (dy < 0) { +- if (r < t0) return; +- if (r < t1) t1 = r; +- } else if (dy > 0) { +- if (r > t1) return; +- if (r > t0) t0 = r; +- } +- r = y1 - ay; +- if (!dy && r < 0) return; +- r /= dy; +- if (dy < 0) { +- if (r > t1) return; +- if (r > t0) t0 = r; +- } else if (dy > 0) { +- if (r < t0) return; +- if (r < t1) t1 = r; +- } +- if (t0 > 0) line.a = { +- x: ax + t0 * dx, +- y: ay + t0 * dy +- }; +- if (t1 < 1) line.b = { +- x: ax + t1 * dx, +- y: ay + t1 * dy +- }; +- return line; +- }; ++ function d3_geom_voronoiHalfEdge(edge, lSite, rSite) { ++ var va = edge.a, vb = edge.b; ++ this.edge = edge; ++ this.site = lSite; ++ this.angle = rSite ? Math.atan2(rSite.y - lSite.y, rSite.x - lSite.x) : edge.l === lSite ? Math.atan2(vb.x - va.x, va.y - vb.y) : Math.atan2(va.x - vb.x, vb.y - va.y); + } +- var d3_geo_clipExtentMAX = 1e9; +- d3.geo.clipExtent = function() { +- var x0, y0, x1, y1, stream, clip, clipExtent = { +- stream: function(output) { +- if (stream) stream.valid = false; +- stream = clip(output); +- stream.valid = true; +- return stream; +- }, +- extent: function(_) { +- if (!arguments.length) return [ [ x0, y0 ], [ x1, y1 ] ]; +- clip = d3_geo_clipExtent(x0 = +_[0][0], y0 = +_[0][1], x1 = +_[1][0], y1 = +_[1][1]); +- if (stream) stream.valid = false, stream = null; +- return clipExtent; +- } +- }; +- return clipExtent.extent([ [ 0, 0 ], [ 960, 500 ] ]); ++ d3_geom_voronoiHalfEdge.prototype = { ++ start: function() { ++ return this.edge.l === this.site ? this.edge.a : this.edge.b; ++ }, ++ end: function() { ++ return this.edge.l === this.site ? this.edge.b : this.edge.a; ++ } + }; +- function d3_geo_clipExtent(x0, y0, x1, y1) { +- return function(listener) { +- var listener_ = listener, bufferListener = d3_geo_clipBufferListener(), clipLine = d3_geom_clipLine(x0, y0, x1, y1), segments, polygon, ring; +- var clip = { +- point: point, +- lineStart: lineStart, +- lineEnd: lineEnd, +- polygonStart: function() { +- listener = bufferListener; +- segments = []; +- polygon = []; +- clean = true; +- }, +- polygonEnd: function() { +- listener = listener_; +- segments = d3.merge(segments); +- var clipStartInside = insidePolygon([ x0, y1 ]), inside = clean && clipStartInside, visible = segments.length; +- if (inside || visible) { +- listener.polygonStart(); +- if (inside) { +- listener.lineStart(); +- interpolate(null, null, 1, listener); +- listener.lineEnd(); +- } +- if (visible) { +- d3_geo_clipPolygon(segments, compare, clipStartInside, interpolate, listener); ++ function d3_geom_voronoiRedBlackTree() { ++ this._ = null; ++ } ++ function d3_geom_voronoiRedBlackNode(node) { ++ node.U = node.C = node.L = node.R = node.P = node.N = null; ++ } ++ d3_geom_voronoiRedBlackTree.prototype = { ++ insert: function(after, node) { ++ var parent, grandpa, uncle; ++ if (after) { ++ node.P = after; ++ node.N = after.N; ++ if (after.N) after.N.P = node; ++ after.N = node; ++ if (after.R) { ++ after = after.R; ++ while (after.L) after = after.L; ++ after.L = node; ++ } else { ++ after.R = node; ++ } ++ parent = after; ++ } else if (this._) { ++ after = d3_geom_voronoiRedBlackFirst(this._); ++ node.P = null; ++ node.N = after; ++ after.P = after.L = node; ++ parent = after; ++ } else { ++ node.P = node.N = null; ++ this._ = node; ++ parent = null; ++ } ++ node.L = node.R = null; ++ node.U = parent; ++ node.C = true; ++ after = node; ++ while (parent && parent.C) { ++ grandpa = parent.U; ++ if (parent === grandpa.L) { ++ uncle = grandpa.R; ++ if (uncle && uncle.C) { ++ parent.C = uncle.C = false; ++ grandpa.C = true; ++ after = grandpa; ++ } else { ++ if (after === parent.R) { ++ d3_geom_voronoiRedBlackRotateLeft(this, parent); ++ after = parent; ++ parent = after.U; + } +- listener.polygonEnd(); ++ parent.C = false; ++ grandpa.C = true; ++ d3_geom_voronoiRedBlackRotateRight(this, grandpa); + } +- segments = polygon = ring = null; +- } +- }; +- function insidePolygon(p) { +- var wn = 0, n = polygon.length, y = p[1]; +- for (var i = 0; i < n; ++i) { +- for (var j = 1, v = polygon[i], m = v.length, a = v[0], b; j < m; ++j) { +- b = v[j]; +- if (a[1] <= y) { +- if (b[1] > y && d3_cross2d(a, b, p) > 0) ++wn; +- } else { +- if (b[1] <= y && d3_cross2d(a, b, p) < 0) --wn; ++ } else { ++ uncle = grandpa.L; ++ if (uncle && uncle.C) { ++ parent.C = uncle.C = false; ++ grandpa.C = true; ++ after = grandpa; ++ } else { ++ if (after === parent.L) { ++ d3_geom_voronoiRedBlackRotateRight(this, parent); ++ after = parent; ++ parent = after.U; + } +- a = b; ++ parent.C = false; ++ grandpa.C = true; ++ d3_geom_voronoiRedBlackRotateLeft(this, grandpa); + } + } +- return wn !== 0; ++ parent = after.U; + } +- function interpolate(from, to, direction, listener) { +- var a = 0, a1 = 0; +- if (from == null || (a = corner(from, direction)) !== (a1 = corner(to, direction)) || comparePoints(from, to) < 0 ^ direction > 0) { +- do { +- listener.point(a === 0 || a === 3 ? x0 : x1, a > 1 ? y1 : y0); +- } while ((a = (a + direction + 4) % 4) !== a1); ++ this._.C = false; ++ }, ++ remove: function(node) { ++ if (node.N) node.N.P = node.P; ++ if (node.P) node.P.N = node.N; ++ node.N = node.P = null; ++ var parent = node.U, sibling, left = node.L, right = node.R, next, red; ++ if (!left) next = right; else if (!right) next = left; else next = d3_geom_voronoiRedBlackFirst(right); ++ if (parent) { ++ if (parent.L === node) parent.L = next; else parent.R = next; ++ } else { ++ this._ = next; ++ } ++ if (left && right) { ++ red = next.C; ++ next.C = node.C; ++ next.L = left; ++ left.U = next; ++ if (next !== right) { ++ parent = next.U; ++ next.U = node.U; ++ node = next.R; ++ parent.L = node; ++ next.R = right; ++ right.U = next; + } else { +- listener.point(to[0], to[1]); ++ next.U = parent; ++ parent = next; ++ node = next.R; + } ++ } else { ++ red = node.C; ++ node = next; + } +- function pointVisible(x, y) { +- return x0 <= x && x <= x1 && y0 <= y && y <= y1; +- } +- function point(x, y) { +- if (pointVisible(x, y)) listener.point(x, y); +- } +- var x__, y__, v__, x_, y_, v_, first, clean; +- function lineStart() { +- clip.point = linePoint; +- if (polygon) polygon.push(ring = []); +- first = true; +- v_ = false; +- x_ = y_ = NaN; +- } +- function lineEnd() { +- if (segments) { +- linePoint(x__, y__); +- if (v__ && v_) bufferListener.rejoin(); +- segments.push(bufferListener.buffer()); +- } +- clip.point = point; +- if (v_) listener.lineEnd(); ++ if (node) node.U = parent; ++ if (red) return; ++ if (node && node.C) { ++ node.C = false; ++ return; + } +- function linePoint(x, y) { +- x = Math.max(-d3_geo_clipExtentMAX, Math.min(d3_geo_clipExtentMAX, x)); +- y = Math.max(-d3_geo_clipExtentMAX, Math.min(d3_geo_clipExtentMAX, y)); +- var v = pointVisible(x, y); +- if (polygon) ring.push([ x, y ]); +- if (first) { +- x__ = x, y__ = y, v__ = v; +- first = false; +- if (v) { +- listener.lineStart(); +- listener.point(x, y); ++ do { ++ if (node === this._) break; ++ if (node === parent.L) { ++ sibling = parent.R; ++ if (sibling.C) { ++ sibling.C = false; ++ parent.C = true; ++ d3_geom_voronoiRedBlackRotateLeft(this, parent); ++ sibling = parent.R; ++ } ++ if (sibling.L && sibling.L.C || sibling.R && sibling.R.C) { ++ if (!sibling.R || !sibling.R.C) { ++ sibling.L.C = false; ++ sibling.C = true; ++ d3_geom_voronoiRedBlackRotateRight(this, sibling); ++ sibling = parent.R; ++ } ++ sibling.C = parent.C; ++ parent.C = sibling.R.C = false; ++ d3_geom_voronoiRedBlackRotateLeft(this, parent); ++ node = this._; ++ break; + } + } else { +- if (v && v_) listener.point(x, y); else { +- var l = { +- a: { +- x: x_, +- y: y_ +- }, +- b: { +- x: x, +- y: y +- } +- }; +- if (clipLine(l)) { +- if (!v_) { +- listener.lineStart(); +- listener.point(l.a.x, l.a.y); +- } +- listener.point(l.b.x, l.b.y); +- if (!v) listener.lineEnd(); +- clean = false; +- } else if (v) { +- listener.lineStart(); +- listener.point(x, y); +- clean = false; ++ sibling = parent.L; ++ if (sibling.C) { ++ sibling.C = false; ++ parent.C = true; ++ d3_geom_voronoiRedBlackRotateRight(this, parent); ++ sibling = parent.L; ++ } ++ if (sibling.L && sibling.L.C || sibling.R && sibling.R.C) { ++ if (!sibling.L || !sibling.L.C) { ++ sibling.R.C = false; ++ sibling.C = true; ++ d3_geom_voronoiRedBlackRotateLeft(this, sibling); ++ sibling = parent.L; + } ++ sibling.C = parent.C; ++ parent.C = sibling.L.C = false; ++ d3_geom_voronoiRedBlackRotateRight(this, parent); ++ node = this._; ++ break; + } + } +- x_ = x, y_ = y, v_ = v; +- } +- return clip; +- }; +- function corner(p, direction) { +- return abs(p[0] - x0) < ε ? direction > 0 ? 0 : 3 : abs(p[0] - x1) < ε ? direction > 0 ? 2 : 1 : abs(p[1] - y0) < ε ? direction > 0 ? 1 : 0 : direction > 0 ? 3 : 2; ++ sibling.C = true; ++ node = parent; ++ parent = parent.U; ++ } while (!node.C); ++ if (node) node.C = false; + } +- function compare(a, b) { +- return comparePoints(a.x, b.x); ++ }; ++ function d3_geom_voronoiRedBlackRotateLeft(tree, node) { ++ var p = node, q = node.R, parent = p.U; ++ if (parent) { ++ if (parent.L === p) parent.L = q; else parent.R = q; ++ } else { ++ tree._ = q; + } +- function comparePoints(a, b) { +- var ca = corner(a, 1), cb = corner(b, 1); +- return ca !== cb ? ca - cb : ca === 0 ? b[1] - a[1] : ca === 1 ? a[0] - b[0] : ca === 2 ? a[1] - b[1] : b[0] - a[0]; ++ q.U = parent; ++ p.U = q; ++ p.R = q.L; ++ if (p.R) p.R.U = p; ++ q.L = p; ++ } ++ function d3_geom_voronoiRedBlackRotateRight(tree, node) { ++ var p = node, q = node.L, parent = p.U; ++ if (parent) { ++ if (parent.L === p) parent.L = q; else parent.R = q; ++ } else { ++ tree._ = q; + } ++ q.U = parent; ++ p.U = q; ++ p.L = q.R; ++ if (p.L) p.L.U = p; ++ q.R = p; + } +- function d3_geo_conic(projectAt) { +- var φ0 = 0, φ1 = π / 3, m = d3_geo_projectionMutator(projectAt), p = m(φ0, φ1); +- p.parallels = function(_) { +- if (!arguments.length) return [ φ0 / π * 180, φ1 / π * 180 ]; +- return m(φ0 = _[0] * π / 180, φ1 = _[1] * π / 180); +- }; +- return p; ++ function d3_geom_voronoiRedBlackFirst(node) { ++ while (node.L) node = node.L; ++ return node; + } +- function d3_geo_conicEqualArea(φ0, φ1) { +- var sinφ0 = Math.sin(φ0), n = (sinφ0 + Math.sin(φ1)) / 2, C = 1 + sinφ0 * (2 * n - sinφ0), ρ0 = Math.sqrt(C) / n; +- function forward(λ, φ) { +- var ρ = Math.sqrt(C - 2 * n * Math.sin(φ)) / n; +- return [ ρ * Math.sin(λ *= n), ρ0 - ρ * Math.cos(λ) ]; ++ function d3_geom_voronoi(sites, bbox) { ++ var site = sites.sort(d3_geom_voronoiVertexOrder).pop(), x0, y0, circle; ++ d3_geom_voronoiEdges = []; ++ d3_geom_voronoiCells = new Array(sites.length); ++ d3_geom_voronoiBeaches = new d3_geom_voronoiRedBlackTree(); ++ d3_geom_voronoiCircles = new d3_geom_voronoiRedBlackTree(); ++ while (true) { ++ circle = d3_geom_voronoiFirstCircle; ++ if (site && (!circle || site.y < circle.y || site.y === circle.y && site.x < circle.x)) { ++ if (site.x !== x0 || site.y !== y0) { ++ d3_geom_voronoiCells[site.i] = new d3_geom_voronoiCell(site); ++ d3_geom_voronoiAddBeach(site); ++ x0 = site.x, y0 = site.y; ++ } ++ site = sites.pop(); ++ } else if (circle) { ++ d3_geom_voronoiRemoveBeach(circle.arc); ++ } else { ++ break; ++ } + } +- forward.invert = function(x, y) { +- var ρ0_y = ρ0 - y; +- return [ Math.atan2(x, ρ0_y) / n, d3_asin((C - (x * x + ρ0_y * ρ0_y) * n * n) / (2 * n)) ]; ++ if (bbox) d3_geom_voronoiClipEdges(bbox), d3_geom_voronoiCloseCells(bbox); ++ var diagram = { ++ cells: d3_geom_voronoiCells, ++ edges: d3_geom_voronoiEdges + }; +- return forward; ++ d3_geom_voronoiBeaches = d3_geom_voronoiCircles = d3_geom_voronoiEdges = d3_geom_voronoiCells = null; ++ return diagram; + } +- (d3.geo.conicEqualArea = function() { +- return d3_geo_conic(d3_geo_conicEqualArea); +- }).raw = d3_geo_conicEqualArea; +- d3.geo.albers = function() { +- return d3.geo.conicEqualArea().rotate([ 96, 0 ]).center([ -.6, 38.7 ]).parallels([ 29.5, 45.5 ]).scale(1070); +- }; +- d3.geo.albersUsa = function() { +- var lower48 = d3.geo.albers(); +- var alaska = d3.geo.conicEqualArea().rotate([ 154, 0 ]).center([ -2, 58.5 ]).parallels([ 55, 65 ]); +- var hawaii = d3.geo.conicEqualArea().rotate([ 157, 0 ]).center([ -3, 19.9 ]).parallels([ 8, 18 ]); +- var point, pointStream = { +- point: function(x, y) { +- point = [ x, y ]; +- } +- }, lower48Point, alaskaPoint, hawaiiPoint; +- function albersUsa(coordinates) { +- var x = coordinates[0], y = coordinates[1]; +- point = null; +- (lower48Point(x, y), point) || (alaskaPoint(x, y), point) || hawaiiPoint(x, y); +- return point; ++ function d3_geom_voronoiVertexOrder(a, b) { ++ return b.y - a.y || b.x - a.x; ++ } ++ d3.geom.voronoi = function(points) { ++ var x = d3_geom_pointX, y = d3_geom_pointY, fx = x, fy = y, clipExtent = d3_geom_voronoiClipExtent; ++ if (points) return voronoi(points); ++ function voronoi(data) { ++ var polygons = new Array(data.length), x0 = clipExtent[0][0], y0 = clipExtent[0][1], x1 = clipExtent[1][0], y1 = clipExtent[1][1]; ++ d3_geom_voronoi(sites(data), clipExtent).cells.forEach(function(cell, i) { ++ var edges = cell.edges, site = cell.site, polygon = polygons[i] = edges.length ? edges.map(function(e) { ++ var s = e.start(); ++ return [ s.x, s.y ]; ++ }) : site.x >= x0 && site.x <= x1 && site.y >= y0 && site.y <= y1 ? [ [ x0, y1 ], [ x1, y1 ], [ x1, y0 ], [ x0, y0 ] ] : []; ++ polygon.point = data[i]; ++ }); ++ return polygons; + } +- albersUsa.invert = function(coordinates) { +- var k = lower48.scale(), t = lower48.translate(), x = (coordinates[0] - t[0]) / k, y = (coordinates[1] - t[1]) / k; +- return (y >= .12 && y < .234 && x >= -.425 && x < -.214 ? alaska : y >= .166 && y < .234 && x >= -.214 && x < -.115 ? hawaii : lower48).invert(coordinates); ++ function sites(data) { ++ return data.map(function(d, i) { ++ return { ++ x: Math.round(fx(d, i) / ε) * ε, ++ y: Math.round(fy(d, i) / ε) * ε, ++ i: i ++ }; ++ }); ++ } ++ voronoi.links = function(data) { ++ return d3_geom_voronoi(sites(data)).edges.filter(function(edge) { ++ return edge.l && edge.r; ++ }).map(function(edge) { ++ return { ++ source: data[edge.l.i], ++ target: data[edge.r.i] ++ }; ++ }); + }; +- albersUsa.stream = function(stream) { +- var lower48Stream = lower48.stream(stream), alaskaStream = alaska.stream(stream), hawaiiStream = hawaii.stream(stream); +- return { +- point: function(x, y) { +- lower48Stream.point(x, y); +- alaskaStream.point(x, y); +- hawaiiStream.point(x, y); +- }, +- sphere: function() { +- lower48Stream.sphere(); +- alaskaStream.sphere(); +- hawaiiStream.sphere(); +- }, +- lineStart: function() { +- lower48Stream.lineStart(); +- alaskaStream.lineStart(); +- hawaiiStream.lineStart(); +- }, +- lineEnd: function() { +- lower48Stream.lineEnd(); +- alaskaStream.lineEnd(); +- hawaiiStream.lineEnd(); +- }, +- polygonStart: function() { +- lower48Stream.polygonStart(); +- alaskaStream.polygonStart(); +- hawaiiStream.polygonStart(); +- }, +- polygonEnd: function() { +- lower48Stream.polygonEnd(); +- alaskaStream.polygonEnd(); +- hawaiiStream.polygonEnd(); ++ voronoi.triangles = function(data) { ++ var triangles = []; ++ d3_geom_voronoi(sites(data)).cells.forEach(function(cell, i) { ++ var site = cell.site, edges = cell.edges.sort(d3_geom_voronoiHalfEdgeOrder), j = -1, m = edges.length, e0, s0, e1 = edges[m - 1].edge, s1 = e1.l === site ? e1.r : e1.l; ++ while (++j < m) { ++ e0 = e1; ++ s0 = s1; ++ e1 = edges[j].edge; ++ s1 = e1.l === site ? e1.r : e1.l; ++ if (i < s0.i && i < s1.i && d3_geom_voronoiTriangleArea(site, s0, s1) < 0) { ++ triangles.push([ data[i], data[s0.i], data[s1.i] ]); ++ } + } +- }; +- }; +- albersUsa.precision = function(_) { +- if (!arguments.length) return lower48.precision(); +- lower48.precision(_); +- alaska.precision(_); +- hawaii.precision(_); +- return albersUsa; ++ }); ++ return triangles; + }; +- albersUsa.scale = function(_) { +- if (!arguments.length) return lower48.scale(); +- lower48.scale(_); +- alaska.scale(_ * .35); +- hawaii.scale(_); +- return albersUsa.translate(lower48.translate()); ++ voronoi.x = function(_) { ++ return arguments.length ? (fx = d3_functor(x = _), voronoi) : x; + }; +- albersUsa.translate = function(_) { +- if (!arguments.length) return lower48.translate(); +- var k = lower48.scale(), x = +_[0], y = +_[1]; +- lower48Point = lower48.translate(_).clipExtent([ [ x - .455 * k, y - .238 * k ], [ x + .455 * k, y + .238 * k ] ]).stream(pointStream).point; +- alaskaPoint = alaska.translate([ x - .307 * k, y + .201 * k ]).clipExtent([ [ x - .425 * k + ε, y + .12 * k + ε ], [ x - .214 * k - ε, y + .234 * k - ε ] ]).stream(pointStream).point; +- hawaiiPoint = hawaii.translate([ x - .205 * k, y + .212 * k ]).clipExtent([ [ x - .214 * k + ε, y + .166 * k + ε ], [ x - .115 * k - ε, y + .234 * k - ε ] ]).stream(pointStream).point; +- return albersUsa; ++ voronoi.y = function(_) { ++ return arguments.length ? (fy = d3_functor(y = _), voronoi) : y; + }; +- return albersUsa.scale(1070); +- }; +- var d3_geo_pathAreaSum, d3_geo_pathAreaPolygon, d3_geo_pathArea = { +- point: d3_noop, +- lineStart: d3_noop, +- lineEnd: d3_noop, +- polygonStart: function() { +- d3_geo_pathAreaPolygon = 0; +- d3_geo_pathArea.lineStart = d3_geo_pathAreaRingStart; +- }, +- polygonEnd: function() { +- d3_geo_pathArea.lineStart = d3_geo_pathArea.lineEnd = d3_geo_pathArea.point = d3_noop; +- d3_geo_pathAreaSum += abs(d3_geo_pathAreaPolygon / 2); +- } +- }; +- function d3_geo_pathAreaRingStart() { +- var x00, y00, x0, y0; +- d3_geo_pathArea.point = function(x, y) { +- d3_geo_pathArea.point = nextPoint; +- x00 = x0 = x, y00 = y0 = y; ++ voronoi.clipExtent = function(_) { ++ if (!arguments.length) return clipExtent === d3_geom_voronoiClipExtent ? null : clipExtent; ++ clipExtent = _ == null ? d3_geom_voronoiClipExtent : _; ++ return voronoi; + }; +- function nextPoint(x, y) { +- d3_geo_pathAreaPolygon += y0 * x - x0 * y; +- x0 = x, y0 = y; +- } +- d3_geo_pathArea.lineEnd = function() { +- nextPoint(x00, y00); ++ voronoi.size = function(_) { ++ if (!arguments.length) return clipExtent === d3_geom_voronoiClipExtent ? null : clipExtent && clipExtent[1]; ++ return voronoi.clipExtent(_ && [ [ 0, 0 ], _ ]); + }; +- } +- var d3_geo_pathBoundsX0, d3_geo_pathBoundsY0, d3_geo_pathBoundsX1, d3_geo_pathBoundsY1; +- var d3_geo_pathBounds = { +- point: d3_geo_pathBoundsPoint, +- lineStart: d3_noop, +- lineEnd: d3_noop, +- polygonStart: d3_noop, +- polygonEnd: d3_noop ++ return voronoi; + }; +- function d3_geo_pathBoundsPoint(x, y) { +- if (x < d3_geo_pathBoundsX0) d3_geo_pathBoundsX0 = x; +- if (x > d3_geo_pathBoundsX1) d3_geo_pathBoundsX1 = x; +- if (y < d3_geo_pathBoundsY0) d3_geo_pathBoundsY0 = y; +- if (y > d3_geo_pathBoundsY1) d3_geo_pathBoundsY1 = y; ++ var d3_geom_voronoiClipExtent = [ [ -1e6, -1e6 ], [ 1e6, 1e6 ] ]; ++ function d3_geom_voronoiTriangleArea(a, b, c) { ++ return (a.x - c.x) * (b.y - a.y) - (a.x - b.x) * (c.y - a.y); + } +- function d3_geo_pathBuffer() { +- var pointCircle = d3_geo_pathBufferCircle(4.5), buffer = []; +- var stream = { +- point: point, +- lineStart: function() { +- stream.point = pointLineStart; +- }, +- lineEnd: lineEnd, +- polygonStart: function() { +- stream.lineEnd = lineEndPolygon; +- }, +- polygonEnd: function() { +- stream.lineEnd = lineEnd; +- stream.point = point; +- }, +- pointRadius: function(_) { +- pointCircle = d3_geo_pathBufferCircle(_); +- return stream; +- }, +- result: function() { +- if (buffer.length) { +- var result = buffer.join(""); +- buffer = []; +- return result; ++ d3.geom.delaunay = function(vertices) { ++ return d3.geom.voronoi().triangles(vertices); ++ }; ++ d3.geom.quadtree = function(points, x1, y1, x2, y2) { ++ var x = d3_geom_pointX, y = d3_geom_pointY, compat; ++ if (compat = arguments.length) { ++ x = d3_geom_quadtreeCompatX; ++ y = d3_geom_quadtreeCompatY; ++ if (compat === 3) { ++ y2 = y1; ++ x2 = x1; ++ y1 = x1 = 0; ++ } ++ return quadtree(points); ++ } ++ function quadtree(data) { ++ var d, fx = d3_functor(x), fy = d3_functor(y), xs, ys, i, n, x1_, y1_, x2_, y2_; ++ if (x1 != null) { ++ x1_ = x1, y1_ = y1, x2_ = x2, y2_ = y2; ++ } else { ++ x2_ = y2_ = -(x1_ = y1_ = Infinity); ++ xs = [], ys = []; ++ n = data.length; ++ if (compat) for (i = 0; i < n; ++i) { ++ d = data[i]; ++ if (d.x < x1_) x1_ = d.x; ++ if (d.y < y1_) y1_ = d.y; ++ if (d.x > x2_) x2_ = d.x; ++ if (d.y > y2_) y2_ = d.y; ++ xs.push(d.x); ++ ys.push(d.y); ++ } else for (i = 0; i < n; ++i) { ++ var x_ = +fx(d = data[i], i), y_ = +fy(d, i); ++ if (x_ < x1_) x1_ = x_; ++ if (y_ < y1_) y1_ = y_; ++ if (x_ > x2_) x2_ = x_; ++ if (y_ > y2_) y2_ = y_; ++ xs.push(x_); ++ ys.push(y_); + } + } +- }; +- function point(x, y) { +- buffer.push("M", x, ",", y, pointCircle); +- } +- function pointLineStart(x, y) { +- buffer.push("M", x, ",", y); +- stream.point = pointLine; +- } +- function pointLine(x, y) { +- buffer.push("L", x, ",", y); +- } +- function lineEnd() { +- stream.point = point; +- } +- function lineEndPolygon() { +- buffer.push("Z"); +- } +- return stream; +- } +- function d3_geo_pathBufferCircle(radius) { +- return "m0," + radius + "a" + radius + "," + radius + " 0 1,1 0," + -2 * radius + "a" + radius + "," + radius + " 0 1,1 0," + 2 * radius + "z"; +- } +- var d3_geo_pathCentroid = { +- point: d3_geo_pathCentroidPoint, +- lineStart: d3_geo_pathCentroidLineStart, +- lineEnd: d3_geo_pathCentroidLineEnd, +- polygonStart: function() { +- d3_geo_pathCentroid.lineStart = d3_geo_pathCentroidRingStart; +- }, +- polygonEnd: function() { +- d3_geo_pathCentroid.point = d3_geo_pathCentroidPoint; +- d3_geo_pathCentroid.lineStart = d3_geo_pathCentroidLineStart; +- d3_geo_pathCentroid.lineEnd = d3_geo_pathCentroidLineEnd; ++ var dx = x2_ - x1_, dy = y2_ - y1_; ++ if (dx > dy) y2_ = y1_ + dx; else x2_ = x1_ + dy; ++ function insert(n, d, x, y, x1, y1, x2, y2) { ++ if (isNaN(x) || isNaN(y)) return; ++ if (n.leaf) { ++ var nx = n.x, ny = n.y; ++ if (nx != null) { ++ if (abs(nx - x) + abs(ny - y) < .01) { ++ insertChild(n, d, x, y, x1, y1, x2, y2); ++ } else { ++ var nPoint = n.point; ++ n.x = n.y = n.point = null; ++ insertChild(n, nPoint, nx, ny, x1, y1, x2, y2); ++ insertChild(n, d, x, y, x1, y1, x2, y2); ++ } ++ } else { ++ n.x = x, n.y = y, n.point = d; ++ } ++ } else { ++ insertChild(n, d, x, y, x1, y1, x2, y2); ++ } ++ } ++ function insertChild(n, d, x, y, x1, y1, x2, y2) { ++ var xm = (x1 + x2) * .5, ym = (y1 + y2) * .5, right = x >= xm, below = y >= ym, i = below << 1 | right; ++ n.leaf = false; ++ n = n.nodes[i] || (n.nodes[i] = d3_geom_quadtreeNode()); ++ if (right) x1 = xm; else x2 = xm; ++ if (below) y1 = ym; else y2 = ym; ++ insert(n, d, x, y, x1, y1, x2, y2); ++ } ++ var root = d3_geom_quadtreeNode(); ++ root.add = function(d) { ++ insert(root, d, +fx(d, ++i), +fy(d, i), x1_, y1_, x2_, y2_); ++ }; ++ root.visit = function(f) { ++ d3_geom_quadtreeVisit(f, root, x1_, y1_, x2_, y2_); ++ }; ++ root.find = function(point) { ++ return d3_geom_quadtreeFind(root, point[0], point[1], x1_, y1_, x2_, y2_); ++ }; ++ i = -1; ++ if (x1 == null) { ++ while (++i < n) { ++ insert(root, data[i], xs[i], ys[i], x1_, y1_, x2_, y2_); ++ } ++ --i; ++ } else data.forEach(root.add); ++ xs = ys = data = d = null; ++ return root; + } +- }; +- function d3_geo_pathCentroidPoint(x, y) { +- d3_geo_centroidX0 += x; +- d3_geo_centroidY0 += y; +- ++d3_geo_centroidZ0; +- } +- function d3_geo_pathCentroidLineStart() { +- var x0, y0; +- d3_geo_pathCentroid.point = function(x, y) { +- d3_geo_pathCentroid.point = nextPoint; +- d3_geo_pathCentroidPoint(x0 = x, y0 = y); ++ quadtree.x = function(_) { ++ return arguments.length ? (x = _, quadtree) : x; + }; +- function nextPoint(x, y) { +- var dx = x - x0, dy = y - y0, z = Math.sqrt(dx * dx + dy * dy); +- d3_geo_centroidX1 += z * (x0 + x) / 2; +- d3_geo_centroidY1 += z * (y0 + y) / 2; +- d3_geo_centroidZ1 += z; +- d3_geo_pathCentroidPoint(x0 = x, y0 = y); +- } +- } +- function d3_geo_pathCentroidLineEnd() { +- d3_geo_pathCentroid.point = d3_geo_pathCentroidPoint; +- } +- function d3_geo_pathCentroidRingStart() { +- var x00, y00, x0, y0; +- d3_geo_pathCentroid.point = function(x, y) { +- d3_geo_pathCentroid.point = nextPoint; +- d3_geo_pathCentroidPoint(x00 = x0 = x, y00 = y0 = y); ++ quadtree.y = function(_) { ++ return arguments.length ? (y = _, quadtree) : y; + }; +- function nextPoint(x, y) { +- var dx = x - x0, dy = y - y0, z = Math.sqrt(dx * dx + dy * dy); +- d3_geo_centroidX1 += z * (x0 + x) / 2; +- d3_geo_centroidY1 += z * (y0 + y) / 2; +- d3_geo_centroidZ1 += z; +- z = y0 * x - x0 * y; +- d3_geo_centroidX2 += z * (x0 + x); +- d3_geo_centroidY2 += z * (y0 + y); +- d3_geo_centroidZ2 += z * 3; +- d3_geo_pathCentroidPoint(x0 = x, y0 = y); +- } +- d3_geo_pathCentroid.lineEnd = function() { +- nextPoint(x00, y00); ++ quadtree.extent = function(_) { ++ if (!arguments.length) return x1 == null ? null : [ [ x1, y1 ], [ x2, y2 ] ]; ++ if (_ == null) x1 = y1 = x2 = y2 = null; else x1 = +_[0][0], y1 = +_[0][1], x2 = +_[1][0], ++ y2 = +_[1][1]; ++ return quadtree; ++ }; ++ quadtree.size = function(_) { ++ if (!arguments.length) return x1 == null ? null : [ x2 - x1, y2 - y1 ]; ++ if (_ == null) x1 = y1 = x2 = y2 = null; else x1 = y1 = 0, x2 = +_[0], y2 = +_[1]; ++ return quadtree; + }; ++ return quadtree; ++ }; ++ function d3_geom_quadtreeCompatX(d) { ++ return d.x; + } +- function d3_geo_pathContext(context) { +- var pointRadius = 4.5; +- var stream = { +- point: point, +- lineStart: function() { +- stream.point = pointLineStart; +- }, +- lineEnd: lineEnd, +- polygonStart: function() { +- stream.lineEnd = lineEndPolygon; +- }, +- polygonEnd: function() { +- stream.lineEnd = lineEnd; +- stream.point = point; +- }, +- pointRadius: function(_) { +- pointRadius = _; +- return stream; +- }, +- result: d3_noop ++ function d3_geom_quadtreeCompatY(d) { ++ return d.y; ++ } ++ function d3_geom_quadtreeNode() { ++ return { ++ leaf: true, ++ nodes: [], ++ point: null, ++ x: null, ++ y: null + }; +- function point(x, y) { +- context.moveTo(x + pointRadius, y); +- context.arc(x, y, pointRadius, 0, τ); +- } +- function pointLineStart(x, y) { +- context.moveTo(x, y); +- stream.point = pointLine; +- } +- function pointLine(x, y) { +- context.lineTo(x, y); +- } +- function lineEnd() { +- stream.point = point; +- } +- function lineEndPolygon() { +- context.closePath(); +- } +- return stream; + } +- function d3_geo_resample(project) { +- var δ2 = .5, cosMinDistance = Math.cos(30 * d3_radians), maxDepth = 16; +- function resample(stream) { +- return (maxDepth ? resampleRecursive : resampleNone)(stream); +- } +- function resampleNone(stream) { +- return d3_geo_transformPoint(stream, function(x, y) { +- x = project(x, y); +- stream.point(x[0], x[1]); +- }); ++ function d3_geom_quadtreeVisit(f, node, x1, y1, x2, y2) { ++ if (!f(node, x1, y1, x2, y2)) { ++ var sx = (x1 + x2) * .5, sy = (y1 + y2) * .5, children = node.nodes; ++ if (children[0]) d3_geom_quadtreeVisit(f, children[0], x1, y1, sx, sy); ++ if (children[1]) d3_geom_quadtreeVisit(f, children[1], sx, y1, x2, sy); ++ if (children[2]) d3_geom_quadtreeVisit(f, children[2], x1, sy, sx, y2); ++ if (children[3]) d3_geom_quadtreeVisit(f, children[3], sx, sy, x2, y2); + } +- function resampleRecursive(stream) { +- var λ00, φ00, x00, y00, a00, b00, c00, λ0, x0, y0, a0, b0, c0; +- var resample = { +- point: point, +- lineStart: lineStart, +- lineEnd: lineEnd, +- polygonStart: function() { +- stream.polygonStart(); +- resample.lineStart = ringStart; +- }, +- polygonEnd: function() { +- stream.polygonEnd(); +- resample.lineStart = lineStart; ++ } ++ function d3_geom_quadtreeFind(root, x, y, x0, y0, x3, y3) { ++ var minDistance2 = Infinity, closestPoint; ++ (function find(node, x1, y1, x2, y2) { ++ if (x1 > x3 || y1 > y3 || x2 < x0 || y2 < y0) return; ++ if (point = node.point) { ++ var point, dx = x - node.x, dy = y - node.y, distance2 = dx * dx + dy * dy; ++ if (distance2 < minDistance2) { ++ var distance = Math.sqrt(minDistance2 = distance2); ++ x0 = x - distance, y0 = y - distance; ++ x3 = x + distance, y3 = y + distance; ++ closestPoint = point; + } +- }; +- function point(x, y) { +- x = project(x, y); +- stream.point(x[0], x[1]); +- } +- function lineStart() { +- x0 = NaN; +- resample.point = linePoint; +- stream.lineStart(); +- } +- function linePoint(λ, φ) { +- var c = d3_geo_cartesian([ λ, φ ]), p = project(λ, φ); +- resampleLineTo(x0, y0, λ0, a0, b0, c0, x0 = p[0], y0 = p[1], λ0 = λ, a0 = c[0], b0 = c[1], c0 = c[2], maxDepth, stream); +- stream.point(x0, y0); +- } +- function lineEnd() { +- resample.point = point; +- stream.lineEnd(); + } +- function ringStart() { +- lineStart(); +- resample.point = ringPoint; +- resample.lineEnd = ringEnd; +- } +- function ringPoint(λ, φ) { +- linePoint(λ00 = λ, φ00 = φ), x00 = x0, y00 = y0, a00 = a0, b00 = b0, c00 = c0; +- resample.point = linePoint; ++ var children = node.nodes, xm = (x1 + x2) * .5, ym = (y1 + y2) * .5, right = x >= xm, below = y >= ym; ++ for (var i = below << 1 | right, j = i + 4; i < j; ++i) { ++ if (node = children[i & 3]) switch (i & 3) { ++ case 0: ++ find(node, x1, y1, xm, ym); ++ break; ++ ++ case 1: ++ find(node, xm, y1, x2, ym); ++ break; ++ ++ case 2: ++ find(node, x1, ym, xm, y2); ++ break; ++ ++ case 3: ++ find(node, xm, ym, x2, y2); ++ break; ++ } + } +- function ringEnd() { +- resampleLineTo(x0, y0, λ0, a0, b0, c0, x00, y00, λ00, a00, b00, c00, maxDepth, stream); +- resample.lineEnd = lineEnd; +- lineEnd(); ++ })(root, x0, y0, x3, y3); ++ return closestPoint; ++ } ++ d3.interpolateRgb = d3_interpolateRgb; ++ function d3_interpolateRgb(a, b) { ++ a = d3.rgb(a); ++ b = d3.rgb(b); ++ var ar = a.r, ag = a.g, ab = a.b, br = b.r - ar, bg = b.g - ag, bb = b.b - ab; ++ return function(t) { ++ return "#" + d3_rgb_hex(Math.round(ar + br * t)) + d3_rgb_hex(Math.round(ag + bg * t)) + d3_rgb_hex(Math.round(ab + bb * t)); ++ }; ++ } ++ d3.interpolateObject = d3_interpolateObject; ++ function d3_interpolateObject(a, b) { ++ var i = {}, c = {}, k; ++ for (k in a) { ++ if (k in b) { ++ i[k] = d3_interpolate(a[k], b[k]); ++ } else { ++ c[k] = a[k]; + } +- return resample; + } +- function resampleLineTo(x0, y0, λ0, a0, b0, c0, x1, y1, λ1, a1, b1, c1, depth, stream) { +- var dx = x1 - x0, dy = y1 - y0, d2 = dx * dx + dy * dy; +- if (d2 > 4 * δ2 && depth--) { +- var a = a0 + a1, b = b0 + b1, c = c0 + c1, m = Math.sqrt(a * a + b * b + c * c), φ2 = Math.asin(c /= m), λ2 = abs(abs(c) - 1) < ε || abs(λ0 - λ1) < ε ? (λ0 + λ1) / 2 : Math.atan2(b, a), p = project(λ2, φ2), x2 = p[0], y2 = p[1], dx2 = x2 - x0, dy2 = y2 - y0, dz = dy * dx2 - dx * dy2; +- if (dz * dz / d2 > δ2 || abs((dx * dx2 + dy * dy2) / d2 - .5) > .3 || a0 * a1 + b0 * b1 + c0 * c1 < cosMinDistance) { +- resampleLineTo(x0, y0, λ0, a0, b0, c0, x2, y2, λ2, a /= m, b /= m, c, depth, stream); +- stream.point(x2, y2); +- resampleLineTo(x2, y2, λ2, a, b, c, x1, y1, λ1, a1, b1, c1, depth, stream); +- } ++ for (k in b) { ++ if (!(k in a)) { ++ c[k] = b[k]; + } + } +- resample.precision = function(_) { +- if (!arguments.length) return Math.sqrt(δ2); +- maxDepth = (δ2 = _ * _) > 0 && 16; +- return resample; ++ return function(t) { ++ for (k in i) c[k] = i[k](t); ++ return c; + }; +- return resample; + } +- d3.geo.path = function() { +- var pointRadius = 4.5, projection, context, projectStream, contextStream, cacheStream; +- function path(object) { +- if (object) { +- if (typeof pointRadius === "function") contextStream.pointRadius(+pointRadius.apply(this, arguments)); +- if (!cacheStream || !cacheStream.valid) cacheStream = projectStream(contextStream); +- d3.geo.stream(object, cacheStream); ++ d3.interpolateNumber = d3_interpolateNumber; ++ function d3_interpolateNumber(a, b) { ++ a = +a, b = +b; ++ return function(t) { ++ return a * (1 - t) + b * t; ++ }; ++ } ++ d3.interpolateString = d3_interpolateString; ++ function d3_interpolateString(a, b) { ++ var bi = d3_interpolate_numberA.lastIndex = d3_interpolate_numberB.lastIndex = 0, am, bm, bs, i = -1, s = [], q = []; ++ a = a + "", b = b + ""; ++ while ((am = d3_interpolate_numberA.exec(a)) && (bm = d3_interpolate_numberB.exec(b))) { ++ if ((bs = bm.index) > bi) { ++ bs = b.slice(bi, bs); ++ if (s[i]) s[i] += bs; else s[++i] = bs; + } +- return contextStream.result(); ++ if ((am = am[0]) === (bm = bm[0])) { ++ if (s[i]) s[i] += bm; else s[++i] = bm; ++ } else { ++ s[++i] = null; ++ q.push({ ++ i: i, ++ x: d3_interpolateNumber(am, bm) ++ }); ++ } ++ bi = d3_interpolate_numberB.lastIndex; + } +- path.area = function(object) { +- d3_geo_pathAreaSum = 0; +- d3.geo.stream(object, projectStream(d3_geo_pathArea)); +- return d3_geo_pathAreaSum; +- }; +- path.centroid = function(object) { +- d3_geo_centroidX0 = d3_geo_centroidY0 = d3_geo_centroidZ0 = d3_geo_centroidX1 = d3_geo_centroidY1 = d3_geo_centroidZ1 = d3_geo_centroidX2 = d3_geo_centroidY2 = d3_geo_centroidZ2 = 0; +- d3.geo.stream(object, projectStream(d3_geo_pathCentroid)); +- return d3_geo_centroidZ2 ? [ d3_geo_centroidX2 / d3_geo_centroidZ2, d3_geo_centroidY2 / d3_geo_centroidZ2 ] : d3_geo_centroidZ1 ? [ d3_geo_centroidX1 / d3_geo_centroidZ1, d3_geo_centroidY1 / d3_geo_centroidZ1 ] : d3_geo_centroidZ0 ? [ d3_geo_centroidX0 / d3_geo_centroidZ0, d3_geo_centroidY0 / d3_geo_centroidZ0 ] : [ NaN, NaN ]; +- }; +- path.bounds = function(object) { +- d3_geo_pathBoundsX1 = d3_geo_pathBoundsY1 = -(d3_geo_pathBoundsX0 = d3_geo_pathBoundsY0 = Infinity); +- d3.geo.stream(object, projectStream(d3_geo_pathBounds)); +- return [ [ d3_geo_pathBoundsX0, d3_geo_pathBoundsY0 ], [ d3_geo_pathBoundsX1, d3_geo_pathBoundsY1 ] ]; +- }; +- path.projection = function(_) { +- if (!arguments.length) return projection; +- projectStream = (projection = _) ? _.stream || d3_geo_pathProjectStream(_) : d3_identity; +- return reset(); +- }; +- path.context = function(_) { +- if (!arguments.length) return context; +- contextStream = (context = _) == null ? new d3_geo_pathBuffer() : new d3_geo_pathContext(_); +- if (typeof pointRadius !== "function") contextStream.pointRadius(pointRadius); +- return reset(); +- }; +- path.pointRadius = function(_) { +- if (!arguments.length) return pointRadius; +- pointRadius = typeof _ === "function" ? _ : (contextStream.pointRadius(+_), +_); +- return path; +- }; +- function reset() { +- cacheStream = null; +- return path; ++ if (bi < b.length) { ++ bs = b.slice(bi); ++ if (s[i]) s[i] += bs; else s[++i] = bs; + } +- return path.projection(d3.geo.albersUsa()).context(null); +- }; +- function d3_geo_pathProjectStream(project) { +- var resample = d3_geo_resample(function(x, y) { +- return project([ x * d3_degrees, y * d3_degrees ]); ++ return s.length < 2 ? q[0] ? (b = q[0].x, function(t) { ++ return b(t) + ""; ++ }) : function() { ++ return b; ++ } : (b = q.length, function(t) { ++ for (var i = 0, o; i < b; ++i) s[(o = q[i]).i] = o.x(t); ++ return s.join(""); + }); +- return function(stream) { +- return d3_geo_projectionRadians(resample(stream)); +- }; + } +- d3.geo.transform = function(methods) { +- return { +- stream: function(stream) { +- var transform = new d3_geo_transform(stream); +- for (var k in methods) transform[k] = methods[k]; +- return transform; +- } ++ var d3_interpolate_numberA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, d3_interpolate_numberB = new RegExp(d3_interpolate_numberA.source, "g"); ++ d3.interpolate = d3_interpolate; ++ function d3_interpolate(a, b) { ++ var i = d3.interpolators.length, f; ++ while (--i >= 0 && !(f = d3.interpolators[i](a, b))) ; ++ return f; ++ } ++ d3.interpolators = [ function(a, b) { ++ var t = typeof b; ++ return (t === "string" ? d3_rgb_names.has(b.toLowerCase()) || /^(#|rgb\(|hsl\()/i.test(b) ? d3_interpolateRgb : d3_interpolateString : b instanceof d3_color ? d3_interpolateRgb : Array.isArray(b) ? d3_interpolateArray : t === "object" && isNaN(b) ? d3_interpolateObject : d3_interpolateNumber)(a, b); ++ } ]; ++ d3.interpolateArray = d3_interpolateArray; ++ function d3_interpolateArray(a, b) { ++ var x = [], c = [], na = a.length, nb = b.length, n0 = Math.min(a.length, b.length), i; ++ for (i = 0; i < n0; ++i) x.push(d3_interpolate(a[i], b[i])); ++ for (;i < na; ++i) c[i] = a[i]; ++ for (;i < nb; ++i) c[i] = b[i]; ++ return function(t) { ++ for (i = 0; i < n0; ++i) c[i] = x[i](t); ++ return c; + }; +- }; +- function d3_geo_transform(stream) { +- this.stream = stream; + } +- d3_geo_transform.prototype = { +- point: function(x, y) { +- this.stream.point(x, y); ++ var d3_ease_default = function() { ++ return d3_identity; ++ }; ++ var d3_ease = d3.map({ ++ linear: d3_ease_default, ++ poly: d3_ease_poly, ++ quad: function() { ++ return d3_ease_quad; + }, +- sphere: function() { +- this.stream.sphere(); ++ cubic: function() { ++ return d3_ease_cubic; + }, +- lineStart: function() { +- this.stream.lineStart(); ++ sin: function() { ++ return d3_ease_sin; + }, +- lineEnd: function() { +- this.stream.lineEnd(); ++ exp: function() { ++ return d3_ease_exp; + }, +- polygonStart: function() { +- this.stream.polygonStart(); ++ circle: function() { ++ return d3_ease_circle; + }, +- polygonEnd: function() { +- this.stream.polygonEnd(); +- } +- }; +- function d3_geo_transformPoint(stream, point) { +- return { +- point: point, +- sphere: function() { +- stream.sphere(); +- }, +- lineStart: function() { +- stream.lineStart(); +- }, +- lineEnd: function() { +- stream.lineEnd(); +- }, +- polygonStart: function() { +- stream.polygonStart(); +- }, +- polygonEnd: function() { +- stream.polygonEnd(); +- } +- }; +- } +- d3.geo.projection = d3_geo_projection; +- d3.geo.projectionMutator = d3_geo_projectionMutator; +- function d3_geo_projection(project) { +- return d3_geo_projectionMutator(function() { +- return project; +- })(); +- } +- function d3_geo_projectionMutator(projectAt) { +- var project, rotate, projectRotate, projectResample = d3_geo_resample(function(x, y) { +- x = project(x, y); +- return [ x[0] * k + δx, δy - x[1] * k ]; +- }), k = 150, x = 480, y = 250, λ = 0, φ = 0, δλ = 0, δφ = 0, δγ = 0, δx, δy, preclip = d3_geo_clipAntimeridian, postclip = d3_identity, clipAngle = null, clipExtent = null, stream; +- function projection(point) { +- point = projectRotate(point[0] * d3_radians, point[1] * d3_radians); +- return [ point[0] * k + δx, δy - point[1] * k ]; ++ elastic: d3_ease_elastic, ++ back: d3_ease_back, ++ bounce: function() { ++ return d3_ease_bounce; + } +- function invert(point) { +- point = projectRotate.invert((point[0] - δx) / k, (δy - point[1]) / k); +- return point && [ point[0] * d3_degrees, point[1] * d3_degrees ]; ++ }); ++ var d3_ease_mode = d3.map({ ++ "in": d3_identity, ++ out: d3_ease_reverse, ++ "in-out": d3_ease_reflect, ++ "out-in": function(f) { ++ return d3_ease_reflect(d3_ease_reverse(f)); + } +- projection.stream = function(output) { +- if (stream) stream.valid = false; +- stream = d3_geo_projectionRadians(preclip(rotate, projectResample(postclip(output)))); +- stream.valid = true; +- return stream; ++ }); ++ d3.ease = function(name) { ++ var i = name.indexOf("-"), t = i >= 0 ? name.slice(0, i) : name, m = i >= 0 ? name.slice(i + 1) : "in"; ++ t = d3_ease.get(t) || d3_ease_default; ++ m = d3_ease_mode.get(m) || d3_identity; ++ return d3_ease_clamp(m(t.apply(null, d3_arraySlice.call(arguments, 1)))); ++ }; ++ function d3_ease_clamp(f) { ++ return function(t) { ++ return t <= 0 ? 0 : t >= 1 ? 1 : f(t); + }; +- projection.clipAngle = function(_) { +- if (!arguments.length) return clipAngle; +- preclip = _ == null ? (clipAngle = _, d3_geo_clipAntimeridian) : d3_geo_clipCircle((clipAngle = +_) * d3_radians); +- return invalidate(); ++ } ++ function d3_ease_reverse(f) { ++ return function(t) { ++ return 1 - f(1 - t); + }; +- projection.clipExtent = function(_) { +- if (!arguments.length) return clipExtent; +- clipExtent = _; +- postclip = _ ? d3_geo_clipExtent(_[0][0], _[0][1], _[1][0], _[1][1]) : d3_identity; +- return invalidate(); ++ } ++ function d3_ease_reflect(f) { ++ return function(t) { ++ return .5 * (t < .5 ? f(2 * t) : 2 - f(2 - 2 * t)); + }; +- projection.scale = function(_) { +- if (!arguments.length) return k; +- k = +_; +- return reset(); ++ } ++ function d3_ease_quad(t) { ++ return t * t; ++ } ++ function d3_ease_cubic(t) { ++ return t * t * t; ++ } ++ function d3_ease_cubicInOut(t) { ++ if (t <= 0) return 0; ++ if (t >= 1) return 1; ++ var t2 = t * t, t3 = t2 * t; ++ return 4 * (t < .5 ? t3 : 3 * (t - t2) + t3 - .75); ++ } ++ function d3_ease_poly(e) { ++ return function(t) { ++ return Math.pow(t, e); + }; +- projection.translate = function(_) { +- if (!arguments.length) return [ x, y ]; +- x = +_[0]; +- y = +_[1]; +- return reset(); ++ } ++ function d3_ease_sin(t) { ++ return 1 - Math.cos(t * halfπ); ++ } ++ function d3_ease_exp(t) { ++ return Math.pow(2, 10 * (t - 1)); ++ } ++ function d3_ease_circle(t) { ++ return 1 - Math.sqrt(1 - t * t); ++ } ++ function d3_ease_elastic(a, p) { ++ var s; ++ if (arguments.length < 2) p = .45; ++ if (arguments.length) s = p / τ * Math.asin(1 / a); else a = 1, s = p / 4; ++ return function(t) { ++ return 1 + a * Math.pow(2, -10 * t) * Math.sin((t - s) * τ / p); + }; +- projection.center = function(_) { +- if (!arguments.length) return [ λ * d3_degrees, φ * d3_degrees ]; +- λ = _[0] % 360 * d3_radians; +- φ = _[1] % 360 * d3_radians; +- return reset(); ++ } ++ function d3_ease_back(s) { ++ if (!s) s = 1.70158; ++ return function(t) { ++ return t * t * ((s + 1) * t - s); + }; +- projection.rotate = function(_) { +- if (!arguments.length) return [ δλ * d3_degrees, δφ * d3_degrees, δγ * d3_degrees ]; +- δλ = _[0] % 360 * d3_radians; +- δφ = _[1] % 360 * d3_radians; +- δγ = _.length > 2 ? _[2] % 360 * d3_radians : 0; +- return reset(); ++ } ++ function d3_ease_bounce(t) { ++ return t < 1 / 2.75 ? 7.5625 * t * t : t < 2 / 2.75 ? 7.5625 * (t -= 1.5 / 2.75) * t + .75 : t < 2.5 / 2.75 ? 7.5625 * (t -= 2.25 / 2.75) * t + .9375 : 7.5625 * (t -= 2.625 / 2.75) * t + .984375; ++ } ++ d3.interpolateHcl = d3_interpolateHcl; ++ function d3_interpolateHcl(a, b) { ++ a = d3.hcl(a); ++ b = d3.hcl(b); ++ var ah = a.h, ac = a.c, al = a.l, bh = b.h - ah, bc = b.c - ac, bl = b.l - al; ++ if (isNaN(bc)) bc = 0, ac = isNaN(ac) ? b.c : ac; ++ if (isNaN(bh)) bh = 0, ah = isNaN(ah) ? b.h : ah; else if (bh > 180) bh -= 360; else if (bh < -180) bh += 360; ++ return function(t) { ++ return d3_hcl_lab(ah + bh * t, ac + bc * t, al + bl * t) + ""; + }; +- d3.rebind(projection, projectResample, "precision"); +- function reset() { +- projectRotate = d3_geo_compose(rotate = d3_geo_rotation(δλ, δφ, δγ), project); +- var center = project(λ, φ); +- δx = x - center[0] * k; +- δy = y + center[1] * k; +- return invalidate(); +- } +- function invalidate() { +- if (stream) stream.valid = false, stream = null; +- return projection; +- } +- return function() { +- project = projectAt.apply(this, arguments); +- projection.invert = project.invert && invert; +- return reset(); ++ } ++ d3.interpolateHsl = d3_interpolateHsl; ++ function d3_interpolateHsl(a, b) { ++ a = d3.hsl(a); ++ b = d3.hsl(b); ++ var ah = a.h, as = a.s, al = a.l, bh = b.h - ah, bs = b.s - as, bl = b.l - al; ++ if (isNaN(bs)) bs = 0, as = isNaN(as) ? b.s : as; ++ if (isNaN(bh)) bh = 0, ah = isNaN(ah) ? b.h : ah; else if (bh > 180) bh -= 360; else if (bh < -180) bh += 360; ++ return function(t) { ++ return d3_hsl_rgb(ah + bh * t, as + bs * t, al + bl * t) + ""; + }; + } +- function d3_geo_projectionRadians(stream) { +- return d3_geo_transformPoint(stream, function(x, y) { +- stream.point(x * d3_radians, y * d3_radians); +- }); ++ d3.interpolateLab = d3_interpolateLab; ++ function d3_interpolateLab(a, b) { ++ a = d3.lab(a); ++ b = d3.lab(b); ++ var al = a.l, aa = a.a, ab = a.b, bl = b.l - al, ba = b.a - aa, bb = b.b - ab; ++ return function(t) { ++ return d3_lab_rgb(al + bl * t, aa + ba * t, ab + bb * t) + ""; ++ }; + } +- function d3_geo_equirectangular(λ, φ) { +- return [ λ, φ ]; ++ d3.interpolateRound = d3_interpolateRound; ++ function d3_interpolateRound(a, b) { ++ b -= a; ++ return function(t) { ++ return Math.round(a + b * t); ++ }; + } +- (d3.geo.equirectangular = function() { +- return d3_geo_projection(d3_geo_equirectangular); +- }).raw = d3_geo_equirectangular.invert = d3_geo_equirectangular; +- d3.geo.rotation = function(rotate) { +- rotate = d3_geo_rotation(rotate[0] % 360 * d3_radians, rotate[1] * d3_radians, rotate.length > 2 ? rotate[2] * d3_radians : 0); +- function forward(coordinates) { +- coordinates = rotate(coordinates[0] * d3_radians, coordinates[1] * d3_radians); +- return coordinates[0] *= d3_degrees, coordinates[1] *= d3_degrees, coordinates; ++ d3.transform = function(string) { ++ var g = d3_document.createElementNS(d3.ns.prefix.svg, "g"); ++ return (d3.transform = function(string) { ++ if (string != null) { ++ g.setAttribute("transform", string); ++ var t = g.transform.baseVal.consolidate(); ++ } ++ return new d3_transform(t ? t.matrix : d3_transformIdentity); ++ })(string); ++ }; ++ function d3_transform(m) { ++ var r0 = [ m.a, m.b ], r1 = [ m.c, m.d ], kx = d3_transformNormalize(r0), kz = d3_transformDot(r0, r1), ky = d3_transformNormalize(d3_transformCombine(r1, r0, -kz)) || 0; ++ if (r0[0] * r1[1] < r1[0] * r0[1]) { ++ r0[0] *= -1; ++ r0[1] *= -1; ++ kx *= -1; ++ kz *= -1; + } +- forward.invert = function(coordinates) { +- coordinates = rotate.invert(coordinates[0] * d3_radians, coordinates[1] * d3_radians); +- return coordinates[0] *= d3_degrees, coordinates[1] *= d3_degrees, coordinates; +- }; +- return forward; ++ this.rotate = (kx ? Math.atan2(r0[1], r0[0]) : Math.atan2(-r1[0], r1[1])) * d3_degrees; ++ this.translate = [ m.e, m.f ]; ++ this.scale = [ kx, ky ]; ++ this.skew = ky ? Math.atan2(kz, ky) * d3_degrees : 0; ++ } ++ d3_transform.prototype.toString = function() { ++ return "translate(" + this.translate + ")rotate(" + this.rotate + ")skewX(" + this.skew + ")scale(" + this.scale + ")"; + }; +- function d3_geo_identityRotation(λ, φ) { +- return [ λ > π ? λ - τ : λ < -π ? λ + τ : λ, φ ]; ++ function d3_transformDot(a, b) { ++ return a[0] * b[0] + a[1] * b[1]; + } +- d3_geo_identityRotation.invert = d3_geo_equirectangular; +- function d3_geo_rotation(δλ, δφ, δγ) { +- return δλ ? δφ || δγ ? d3_geo_compose(d3_geo_rotationλ(δλ), d3_geo_rotationφγ(δφ, δγ)) : d3_geo_rotationλ(δλ) : δφ || δγ ? d3_geo_rotationφγ(δφ, δγ) : d3_geo_identityRotation; ++ function d3_transformNormalize(a) { ++ var k = Math.sqrt(d3_transformDot(a, a)); ++ if (k) { ++ a[0] /= k; ++ a[1] /= k; ++ } ++ return k; + } +- function d3_geo_forwardRotationλ(δλ) { +- return function(λ, φ) { +- return λ += δλ, [ λ > π ? λ - τ : λ < -π ? λ + τ : λ, φ ]; +- }; ++ function d3_transformCombine(a, b, k) { ++ a[0] += k * b[0]; ++ a[1] += k * b[1]; ++ return a; + } +- function d3_geo_rotationλ(δλ) { +- var rotation = d3_geo_forwardRotationλ(δλ); +- rotation.invert = d3_geo_forwardRotationλ(-δλ); +- return rotation; ++ var d3_transformIdentity = { ++ a: 1, ++ b: 0, ++ c: 0, ++ d: 1, ++ e: 0, ++ f: 0 ++ }; ++ d3.interpolateTransform = d3_interpolateTransform; ++ function d3_interpolateTransformPop(s) { ++ return s.length ? s.pop() + "," : ""; + } +- function d3_geo_rotationφγ(δφ, δγ) { +- var cosδφ = Math.cos(δφ), sinδφ = Math.sin(δφ), cosδγ = Math.cos(δγ), sinδγ = Math.sin(δγ); +- function rotation(λ, φ) { +- var cosφ = Math.cos(φ), x = Math.cos(λ) * cosφ, y = Math.sin(λ) * cosφ, z = Math.sin(φ), k = z * cosδφ + x * sinδφ; +- return [ Math.atan2(y * cosδγ - k * sinδγ, x * cosδφ - z * sinδφ), d3_asin(k * cosδγ + y * sinδγ) ]; ++ function d3_interpolateTranslate(ta, tb, s, q) { ++ if (ta[0] !== tb[0] || ta[1] !== tb[1]) { ++ var i = s.push("translate(", null, ",", null, ")"); ++ q.push({ ++ i: i - 4, ++ x: d3_interpolateNumber(ta[0], tb[0]) ++ }, { ++ i: i - 2, ++ x: d3_interpolateNumber(ta[1], tb[1]) ++ }); ++ } else if (tb[0] || tb[1]) { ++ s.push("translate(" + tb + ")"); + } +- rotation.invert = function(λ, φ) { +- var cosφ = Math.cos(φ), x = Math.cos(λ) * cosφ, y = Math.sin(λ) * cosφ, z = Math.sin(φ), k = z * cosδγ - y * sinδγ; +- return [ Math.atan2(y * cosδγ + z * sinδγ, x * cosδφ + k * sinδφ), d3_asin(k * cosδφ - x * sinδφ) ]; +- }; +- return rotation; + } +- d3.geo.circle = function() { +- var origin = [ 0, 0 ], angle, precision = 6, interpolate; +- function circle() { +- var center = typeof origin === "function" ? origin.apply(this, arguments) : origin, rotate = d3_geo_rotation(-center[0] * d3_radians, -center[1] * d3_radians, 0).invert, ring = []; +- interpolate(null, null, 1, { +- point: function(x, y) { +- ring.push(x = rotate(x, y)); +- x[0] *= d3_degrees, x[1] *= d3_degrees; +- } ++ function d3_interpolateRotate(ra, rb, s, q) { ++ if (ra !== rb) { ++ if (ra - rb > 180) rb += 360; else if (rb - ra > 180) ra += 360; ++ q.push({ ++ i: s.push(d3_interpolateTransformPop(s) + "rotate(", null, ")") - 2, ++ x: d3_interpolateNumber(ra, rb) + }); +- return { +- type: "Polygon", +- coordinates: [ ring ] +- }; ++ } else if (rb) { ++ s.push(d3_interpolateTransformPop(s) + "rotate(" + rb + ")"); + } +- circle.origin = function(x) { +- if (!arguments.length) return origin; +- origin = x; +- return circle; +- }; +- circle.angle = function(x) { +- if (!arguments.length) return angle; +- interpolate = d3_geo_circleInterpolate((angle = +x) * d3_radians, precision * d3_radians); +- return circle; +- }; +- circle.precision = function(_) { +- if (!arguments.length) return precision; +- interpolate = d3_geo_circleInterpolate(angle * d3_radians, (precision = +_) * d3_radians); +- return circle; ++ } ++ function d3_interpolateSkew(wa, wb, s, q) { ++ if (wa !== wb) { ++ q.push({ ++ i: s.push(d3_interpolateTransformPop(s) + "skewX(", null, ")") - 2, ++ x: d3_interpolateNumber(wa, wb) ++ }); ++ } else if (wb) { ++ s.push(d3_interpolateTransformPop(s) + "skewX(" + wb + ")"); ++ } ++ } ++ function d3_interpolateScale(ka, kb, s, q) { ++ if (ka[0] !== kb[0] || ka[1] !== kb[1]) { ++ var i = s.push(d3_interpolateTransformPop(s) + "scale(", null, ",", null, ")"); ++ q.push({ ++ i: i - 4, ++ x: d3_interpolateNumber(ka[0], kb[0]) ++ }, { ++ i: i - 2, ++ x: d3_interpolateNumber(ka[1], kb[1]) ++ }); ++ } else if (kb[0] !== 1 || kb[1] !== 1) { ++ s.push(d3_interpolateTransformPop(s) + "scale(" + kb + ")"); ++ } ++ } ++ function d3_interpolateTransform(a, b) { ++ var s = [], q = []; ++ a = d3.transform(a), b = d3.transform(b); ++ d3_interpolateTranslate(a.translate, b.translate, s, q); ++ d3_interpolateRotate(a.rotate, b.rotate, s, q); ++ d3_interpolateSkew(a.skew, b.skew, s, q); ++ d3_interpolateScale(a.scale, b.scale, s, q); ++ a = b = null; ++ return function(t) { ++ var i = -1, n = q.length, o; ++ while (++i < n) s[(o = q[i]).i] = o.x(t); ++ return s.join(""); + }; +- return circle.angle(90); +- }; +- function d3_geo_circleInterpolate(radius, precision) { +- var cr = Math.cos(radius), sr = Math.sin(radius); +- return function(from, to, direction, listener) { +- var step = direction * precision; +- if (from != null) { +- from = d3_geo_circleAngle(cr, from); +- to = d3_geo_circleAngle(cr, to); +- if (direction > 0 ? from < to : from > to) from += direction * τ; +- } else { +- from = radius + direction * τ; +- to = radius - .5 * step; +- } +- for (var point, t = from; direction > 0 ? t > to : t < to; t -= step) { +- listener.point((point = d3_geo_spherical([ cr, -sr * Math.cos(t), -sr * Math.sin(t) ]))[0], point[1]); +- } ++ } ++ function d3_uninterpolateNumber(a, b) { ++ b = (b -= a = +a) || 1 / b; ++ return function(x) { ++ return (x - a) / b; + }; + } +- function d3_geo_circleAngle(cr, point) { +- var a = d3_geo_cartesian(point); +- a[0] -= cr; +- d3_geo_cartesianNormalize(a); +- var angle = d3_acos(-a[1]); +- return ((-a[2] < 0 ? -angle : angle) + 2 * Math.PI - ε) % (2 * Math.PI); ++ function d3_uninterpolateClamp(a, b) { ++ b = (b -= a = +a) || 1 / b; ++ return function(x) { ++ return Math.max(0, Math.min(1, (x - a) / b)); ++ }; + } +- d3.geo.distance = function(a, b) { +- var Δλ = (b[0] - a[0]) * d3_radians, φ0 = a[1] * d3_radians, φ1 = b[1] * d3_radians, sinΔλ = Math.sin(Δλ), cosΔλ = Math.cos(Δλ), sinφ0 = Math.sin(φ0), cosφ0 = Math.cos(φ0), sinφ1 = Math.sin(φ1), cosφ1 = Math.cos(φ1), t; +- return Math.atan2(Math.sqrt((t = cosφ1 * sinΔλ) * t + (t = cosφ0 * sinφ1 - sinφ0 * cosφ1 * cosΔλ) * t), sinφ0 * sinφ1 + cosφ0 * cosφ1 * cosΔλ); ++ d3.layout = {}; ++ d3.layout.bundle = function() { ++ return function(links) { ++ var paths = [], i = -1, n = links.length; ++ while (++i < n) paths.push(d3_layout_bundlePath(links[i])); ++ return paths; ++ }; + }; +- d3.geo.graticule = function() { +- var x1, x0, X1, X0, y1, y0, Y1, Y0, dx = 10, dy = dx, DX = 90, DY = 360, x, y, X, Y, precision = 2.5; +- function graticule() { +- return { +- type: "MultiLineString", +- coordinates: lines() +- }; ++ function d3_layout_bundlePath(link) { ++ var start = link.source, end = link.target, lca = d3_layout_bundleLeastCommonAncestor(start, end), points = [ start ]; ++ while (start !== lca) { ++ start = start.parent; ++ points.push(start); + } +- function lines() { +- return d3.range(Math.ceil(X0 / DX) * DX, X1, DX).map(X).concat(d3.range(Math.ceil(Y0 / DY) * DY, Y1, DY).map(Y)).concat(d3.range(Math.ceil(x0 / dx) * dx, x1, dx).filter(function(x) { +- return abs(x % DX) > ε; +- }).map(x)).concat(d3.range(Math.ceil(y0 / dy) * dy, y1, dy).filter(function(y) { +- return abs(y % DY) > ε; +- }).map(y)); ++ var k = points.length; ++ while (end !== lca) { ++ points.splice(k, 0, end); ++ end = end.parent; + } +- graticule.lines = function() { +- return lines().map(function(coordinates) { +- return { +- type: "LineString", +- coordinates: coordinates ++ return points; ++ } ++ function d3_layout_bundleAncestors(node) { ++ var ancestors = [], parent = node.parent; ++ while (parent != null) { ++ ancestors.push(node); ++ node = parent; ++ parent = parent.parent; ++ } ++ ancestors.push(node); ++ return ancestors; ++ } ++ function d3_layout_bundleLeastCommonAncestor(a, b) { ++ if (a === b) return a; ++ var aNodes = d3_layout_bundleAncestors(a), bNodes = d3_layout_bundleAncestors(b), aNode = aNodes.pop(), bNode = bNodes.pop(), sharedNode = null; ++ while (aNode === bNode) { ++ sharedNode = aNode; ++ aNode = aNodes.pop(); ++ bNode = bNodes.pop(); ++ } ++ return sharedNode; ++ } ++ d3.layout.chord = function() { ++ var chord = {}, chords, groups, matrix, n, padding = 0, sortGroups, sortSubgroups, sortChords; ++ function relayout() { ++ var subgroups = {}, groupSums = [], groupIndex = d3.range(n), subgroupIndex = [], k, x, x0, i, j; ++ chords = []; ++ groups = []; ++ k = 0, i = -1; ++ while (++i < n) { ++ x = 0, j = -1; ++ while (++j < n) { ++ x += matrix[i][j]; ++ } ++ groupSums.push(x); ++ subgroupIndex.push(d3.range(n)); ++ k += x; ++ } ++ if (sortGroups) { ++ groupIndex.sort(function(a, b) { ++ return sortGroups(groupSums[a], groupSums[b]); ++ }); ++ } ++ if (sortSubgroups) { ++ subgroupIndex.forEach(function(d, i) { ++ d.sort(function(a, b) { ++ return sortSubgroups(matrix[i][a], matrix[i][b]); ++ }); ++ }); ++ } ++ k = (τ - padding * n) / k; ++ x = 0, i = -1; ++ while (++i < n) { ++ x0 = x, j = -1; ++ while (++j < n) { ++ var di = groupIndex[i], dj = subgroupIndex[di][j], v = matrix[di][dj], a0 = x, a1 = x += v * k; ++ subgroups[di + "-" + dj] = { ++ index: di, ++ subindex: dj, ++ startAngle: a0, ++ endAngle: a1, ++ value: v ++ }; ++ } ++ groups[di] = { ++ index: di, ++ startAngle: x0, ++ endAngle: x, ++ value: groupSums[di] + }; ++ x += padding; ++ } ++ i = -1; ++ while (++i < n) { ++ j = i - 1; ++ while (++j < n) { ++ var source = subgroups[i + "-" + j], target = subgroups[j + "-" + i]; ++ if (source.value || target.value) { ++ chords.push(source.value < target.value ? { ++ source: target, ++ target: source ++ } : { ++ source: source, ++ target: target ++ }); ++ } ++ } ++ } ++ if (sortChords) resort(); ++ } ++ function resort() { ++ chords.sort(function(a, b) { ++ return sortChords((a.source.value + a.target.value) / 2, (b.source.value + b.target.value) / 2); + }); ++ } ++ chord.matrix = function(x) { ++ if (!arguments.length) return matrix; ++ n = (matrix = x) && matrix.length; ++ chords = groups = null; ++ return chord; + }; +- graticule.outline = function() { +- return { +- type: "Polygon", +- coordinates: [ X(X0).concat(Y(Y1).slice(1), X(X1).reverse().slice(1), Y(Y0).reverse().slice(1)) ] +- }; +- }; +- graticule.extent = function(_) { +- if (!arguments.length) return graticule.minorExtent(); +- return graticule.majorExtent(_).minorExtent(_); +- }; +- graticule.majorExtent = function(_) { +- if (!arguments.length) return [ [ X0, Y0 ], [ X1, Y1 ] ]; +- X0 = +_[0][0], X1 = +_[1][0]; +- Y0 = +_[0][1], Y1 = +_[1][1]; +- if (X0 > X1) _ = X0, X0 = X1, X1 = _; +- if (Y0 > Y1) _ = Y0, Y0 = Y1, Y1 = _; +- return graticule.precision(precision); +- }; +- graticule.minorExtent = function(_) { +- if (!arguments.length) return [ [ x0, y0 ], [ x1, y1 ] ]; +- x0 = +_[0][0], x1 = +_[1][0]; +- y0 = +_[0][1], y1 = +_[1][1]; +- if (x0 > x1) _ = x0, x0 = x1, x1 = _; +- if (y0 > y1) _ = y0, y0 = y1, y1 = _; +- return graticule.precision(precision); +- }; +- graticule.step = function(_) { +- if (!arguments.length) return graticule.minorStep(); +- return graticule.majorStep(_).minorStep(_); ++ chord.padding = function(x) { ++ if (!arguments.length) return padding; ++ padding = x; ++ chords = groups = null; ++ return chord; + }; +- graticule.majorStep = function(_) { +- if (!arguments.length) return [ DX, DY ]; +- DX = +_[0], DY = +_[1]; +- return graticule; ++ chord.sortGroups = function(x) { ++ if (!arguments.length) return sortGroups; ++ sortGroups = x; ++ chords = groups = null; ++ return chord; + }; +- graticule.minorStep = function(_) { +- if (!arguments.length) return [ dx, dy ]; +- dx = +_[0], dy = +_[1]; +- return graticule; ++ chord.sortSubgroups = function(x) { ++ if (!arguments.length) return sortSubgroups; ++ sortSubgroups = x; ++ chords = null; ++ return chord; + }; +- graticule.precision = function(_) { +- if (!arguments.length) return precision; +- precision = +_; +- x = d3_geo_graticuleX(y0, y1, 90); +- y = d3_geo_graticuleY(x0, x1, precision); +- X = d3_geo_graticuleX(Y0, Y1, 90); +- Y = d3_geo_graticuleY(X0, X1, precision); +- return graticule; ++ chord.sortChords = function(x) { ++ if (!arguments.length) return sortChords; ++ sortChords = x; ++ if (chords) resort(); ++ return chord; + }; +- return graticule.majorExtent([ [ -180, -90 + ε ], [ 180, 90 - ε ] ]).minorExtent([ [ -180, -80 - ε ], [ 180, 80 + ε ] ]); +- }; +- function d3_geo_graticuleX(y0, y1, dy) { +- var y = d3.range(y0, y1 - ε, dy).concat(y1); +- return function(x) { +- return y.map(function(y) { +- return [ x, y ]; +- }); ++ chord.chords = function() { ++ if (!chords) relayout(); ++ return chords; + }; +- } +- function d3_geo_graticuleY(x0, x1, dx) { +- var x = d3.range(x0, x1 - ε, dx).concat(x1); +- return function(y) { +- return x.map(function(x) { +- return [ x, y ]; +- }); ++ chord.groups = function() { ++ if (!groups) relayout(); ++ return groups; + }; +- } +- function d3_source(d) { +- return d.source; +- } +- function d3_target(d) { +- return d.target; +- } +- d3.geo.greatArc = function() { +- var source = d3_source, source_, target = d3_target, target_; +- function greatArc() { +- return { +- type: "LineString", +- coordinates: [ source_ || source.apply(this, arguments), target_ || target.apply(this, arguments) ] ++ return chord; ++ }; ++ d3.layout.force = function() { ++ var force = {}, event = d3.dispatch("start", "tick", "end"), timer, size = [ 1, 1 ], drag, alpha, friction = .9, linkDistance = d3_layout_forceLinkDistance, linkStrength = d3_layout_forceLinkStrength, charge = -30, chargeDistance2 = d3_layout_forceChargeDistance2, gravity = .1, theta2 = .64, nodes = [], links = [], distances, strengths, charges; ++ function repulse(node) { ++ return function(quad, x1, _, x2) { ++ if (quad.point !== node) { ++ var dx = quad.cx - node.x, dy = quad.cy - node.y, dw = x2 - x1, dn = dx * dx + dy * dy; ++ if (dw * dw / theta2 < dn) { ++ if (dn < chargeDistance2) { ++ var k = quad.charge / dn; ++ node.px -= dx * k; ++ node.py -= dy * k; ++ } ++ return true; ++ } ++ if (quad.point && dn && dn < chargeDistance2) { ++ var k = quad.pointCharge / dn; ++ node.px -= dx * k; ++ node.py -= dy * k; ++ } ++ } ++ return !quad.charge; + }; + } +- greatArc.distance = function() { +- return d3.geo.distance(source_ || source.apply(this, arguments), target_ || target.apply(this, arguments)); +- }; +- greatArc.source = function(_) { +- if (!arguments.length) return source; +- source = _, source_ = typeof _ === "function" ? null : _; +- return greatArc; ++ force.tick = function() { ++ if ((alpha *= .99) < .005) { ++ timer = null; ++ event.end({ ++ type: "end", ++ alpha: alpha = 0 ++ }); ++ return true; ++ } ++ var n = nodes.length, m = links.length, q, i, o, s, t, l, k, x, y; ++ for (i = 0; i < m; ++i) { ++ o = links[i]; ++ s = o.source; ++ t = o.target; ++ x = t.x - s.x; ++ y = t.y - s.y; ++ if (l = x * x + y * y) { ++ l = alpha * strengths[i] * ((l = Math.sqrt(l)) - distances[i]) / l; ++ x *= l; ++ y *= l; ++ t.x -= x * (k = s.weight + t.weight ? s.weight / (s.weight + t.weight) : .5); ++ t.y -= y * k; ++ s.x += x * (k = 1 - k); ++ s.y += y * k; ++ } ++ } ++ if (k = alpha * gravity) { ++ x = size[0] / 2; ++ y = size[1] / 2; ++ i = -1; ++ if (k) while (++i < n) { ++ o = nodes[i]; ++ o.x += (x - o.x) * k; ++ o.y += (y - o.y) * k; ++ } ++ } ++ if (charge) { ++ d3_layout_forceAccumulate(q = d3.geom.quadtree(nodes), alpha, charges); ++ i = -1; ++ while (++i < n) { ++ if (!(o = nodes[i]).fixed) { ++ q.visit(repulse(o)); ++ } ++ } ++ } ++ i = -1; ++ while (++i < n) { ++ o = nodes[i]; ++ if (o.fixed) { ++ o.x = o.px; ++ o.y = o.py; ++ } else { ++ o.x -= (o.px - (o.px = o.x)) * friction; ++ o.y -= (o.py - (o.py = o.y)) * friction; ++ } ++ } ++ event.tick({ ++ type: "tick", ++ alpha: alpha ++ }); + }; +- greatArc.target = function(_) { +- if (!arguments.length) return target; +- target = _, target_ = typeof _ === "function" ? null : _; +- return greatArc; ++ force.nodes = function(x) { ++ if (!arguments.length) return nodes; ++ nodes = x; ++ return force; + }; +- greatArc.precision = function() { +- return arguments.length ? greatArc : 0; ++ force.links = function(x) { ++ if (!arguments.length) return links; ++ links = x; ++ return force; + }; +- return greatArc; +- }; +- d3.geo.interpolate = function(source, target) { +- return d3_geo_interpolate(source[0] * d3_radians, source[1] * d3_radians, target[0] * d3_radians, target[1] * d3_radians); +- }; +- function d3_geo_interpolate(x0, y0, x1, y1) { +- var cy0 = Math.cos(y0), sy0 = Math.sin(y0), cy1 = Math.cos(y1), sy1 = Math.sin(y1), kx0 = cy0 * Math.cos(x0), ky0 = cy0 * Math.sin(x0), kx1 = cy1 * Math.cos(x1), ky1 = cy1 * Math.sin(x1), d = 2 * Math.asin(Math.sqrt(d3_haversin(y1 - y0) + cy0 * cy1 * d3_haversin(x1 - x0))), k = 1 / Math.sin(d); +- var interpolate = d ? function(t) { +- var B = Math.sin(t *= d) * k, A = Math.sin(d - t) * k, x = A * kx0 + B * kx1, y = A * ky0 + B * ky1, z = A * sy0 + B * sy1; +- return [ Math.atan2(y, x) * d3_degrees, Math.atan2(z, Math.sqrt(x * x + y * y)) * d3_degrees ]; +- } : function() { +- return [ x0 * d3_degrees, y0 * d3_degrees ]; ++ force.size = function(x) { ++ if (!arguments.length) return size; ++ size = x; ++ return force; + }; +- interpolate.distance = d; +- return interpolate; +- } +- d3.geo.length = function(object) { +- d3_geo_lengthSum = 0; +- d3.geo.stream(object, d3_geo_length); +- return d3_geo_lengthSum; +- }; +- var d3_geo_lengthSum; +- var d3_geo_length = { +- sphere: d3_noop, +- point: d3_noop, +- lineStart: d3_geo_lengthLineStart, +- lineEnd: d3_noop, +- polygonStart: d3_noop, +- polygonEnd: d3_noop +- }; +- function d3_geo_lengthLineStart() { +- var λ0, sinφ0, cosφ0; +- d3_geo_length.point = function(λ, φ) { +- λ0 = λ * d3_radians, sinφ0 = Math.sin(φ *= d3_radians), cosφ0 = Math.cos(φ); +- d3_geo_length.point = nextPoint; ++ force.linkDistance = function(x) { ++ if (!arguments.length) return linkDistance; ++ linkDistance = typeof x === "function" ? x : +x; ++ return force; + }; +- d3_geo_length.lineEnd = function() { +- d3_geo_length.point = d3_geo_length.lineEnd = d3_noop; ++ force.distance = force.linkDistance; ++ force.linkStrength = function(x) { ++ if (!arguments.length) return linkStrength; ++ linkStrength = typeof x === "function" ? x : +x; ++ return force; + }; +- function nextPoint(λ, φ) { +- var sinφ = Math.sin(φ *= d3_radians), cosφ = Math.cos(φ), t = abs((λ *= d3_radians) - λ0), cosΔλ = Math.cos(t); +- d3_geo_lengthSum += Math.atan2(Math.sqrt((t = cosφ * Math.sin(t)) * t + (t = cosφ0 * sinφ - sinφ0 * cosφ * cosΔλ) * t), sinφ0 * sinφ + cosφ0 * cosφ * cosΔλ); +- λ0 = λ, sinφ0 = sinφ, cosφ0 = cosφ; +- } +- } +- function d3_geo_azimuthal(scale, angle) { +- function azimuthal(λ, φ) { +- var cosλ = Math.cos(λ), cosφ = Math.cos(φ), k = scale(cosλ * cosφ); +- return [ k * cosφ * Math.sin(λ), k * Math.sin(φ) ]; +- } +- azimuthal.invert = function(x, y) { +- var ρ = Math.sqrt(x * x + y * y), c = angle(ρ), sinc = Math.sin(c), cosc = Math.cos(c); +- return [ Math.atan2(x * sinc, ρ * cosc), Math.asin(ρ && y * sinc / ρ) ]; ++ force.friction = function(x) { ++ if (!arguments.length) return friction; ++ friction = +x; ++ return force; + }; +- return azimuthal; +- } +- var d3_geo_azimuthalEqualArea = d3_geo_azimuthal(function(cosλcosφ) { +- return Math.sqrt(2 / (1 + cosλcosφ)); +- }, function(ρ) { +- return 2 * Math.asin(ρ / 2); +- }); +- (d3.geo.azimuthalEqualArea = function() { +- return d3_geo_projection(d3_geo_azimuthalEqualArea); +- }).raw = d3_geo_azimuthalEqualArea; +- var d3_geo_azimuthalEquidistant = d3_geo_azimuthal(function(cosλcosφ) { +- var c = Math.acos(cosλcosφ); +- return c && c / Math.sin(c); +- }, d3_identity); +- (d3.geo.azimuthalEquidistant = function() { +- return d3_geo_projection(d3_geo_azimuthalEquidistant); +- }).raw = d3_geo_azimuthalEquidistant; +- function d3_geo_conicConformal(φ0, φ1) { +- var cosφ0 = Math.cos(φ0), t = function(φ) { +- return Math.tan(π / 4 + φ / 2); +- }, n = φ0 === φ1 ? Math.sin(φ0) : Math.log(cosφ0 / Math.cos(φ1)) / Math.log(t(φ1) / t(φ0)), F = cosφ0 * Math.pow(t(φ0), n) / n; +- if (!n) return d3_geo_mercator; +- function forward(λ, φ) { +- if (F > 0) { +- if (φ < -halfπ + ε) φ = -halfπ + ε; +- } else { +- if (φ > halfπ - ε) φ = halfπ - ε; +- } +- var ρ = F / Math.pow(t(φ), n); +- return [ ρ * Math.sin(n * λ), F - ρ * Math.cos(n * λ) ]; +- } +- forward.invert = function(x, y) { +- var ρ0_y = F - y, ρ = d3_sgn(n) * Math.sqrt(x * x + ρ0_y * ρ0_y); +- return [ Math.atan2(x, ρ0_y) / n, 2 * Math.atan(Math.pow(F / ρ, 1 / n)) - halfπ ]; ++ force.charge = function(x) { ++ if (!arguments.length) return charge; ++ charge = typeof x === "function" ? x : +x; ++ return force; + }; +- return forward; +- } +- (d3.geo.conicConformal = function() { +- return d3_geo_conic(d3_geo_conicConformal); +- }).raw = d3_geo_conicConformal; +- function d3_geo_conicEquidistant(φ0, φ1) { +- var cosφ0 = Math.cos(φ0), n = φ0 === φ1 ? Math.sin(φ0) : (cosφ0 - Math.cos(φ1)) / (φ1 - φ0), G = cosφ0 / n + φ0; +- if (abs(n) < ε) return d3_geo_equirectangular; +- function forward(λ, φ) { +- var ρ = G - φ; +- return [ ρ * Math.sin(n * λ), G - ρ * Math.cos(n * λ) ]; +- } +- forward.invert = function(x, y) { +- var ρ0_y = G - y; +- return [ Math.atan2(x, ρ0_y) / n, G - d3_sgn(n) * Math.sqrt(x * x + ρ0_y * ρ0_y) ]; ++ force.chargeDistance = function(x) { ++ if (!arguments.length) return Math.sqrt(chargeDistance2); ++ chargeDistance2 = x * x; ++ return force; + }; +- return forward; +- } +- (d3.geo.conicEquidistant = function() { +- return d3_geo_conic(d3_geo_conicEquidistant); +- }).raw = d3_geo_conicEquidistant; +- var d3_geo_gnomonic = d3_geo_azimuthal(function(cosλcosφ) { +- return 1 / cosλcosφ; +- }, Math.atan); +- (d3.geo.gnomonic = function() { +- return d3_geo_projection(d3_geo_gnomonic); +- }).raw = d3_geo_gnomonic; +- function d3_geo_mercator(λ, φ) { +- return [ λ, Math.log(Math.tan(π / 4 + φ / 2)) ]; +- } +- d3_geo_mercator.invert = function(x, y) { +- return [ x, 2 * Math.atan(Math.exp(y)) - halfπ ]; +- }; +- function d3_geo_mercatorProjection(project) { +- var m = d3_geo_projection(project), scale = m.scale, translate = m.translate, clipExtent = m.clipExtent, clipAuto; +- m.scale = function() { +- var v = scale.apply(m, arguments); +- return v === m ? clipAuto ? m.clipExtent(null) : m : v; ++ force.gravity = function(x) { ++ if (!arguments.length) return gravity; ++ gravity = +x; ++ return force; + }; +- m.translate = function() { +- var v = translate.apply(m, arguments); +- return v === m ? clipAuto ? m.clipExtent(null) : m : v; ++ force.theta = function(x) { ++ if (!arguments.length) return Math.sqrt(theta2); ++ theta2 = x * x; ++ return force; + }; +- m.clipExtent = function(_) { +- var v = clipExtent.apply(m, arguments); +- if (v === m) { +- if (clipAuto = _ == null) { +- var k = π * scale(), t = translate(); +- clipExtent([ [ t[0] - k, t[1] - k ], [ t[0] + k, t[1] + k ] ]); ++ force.alpha = function(x) { ++ if (!arguments.length) return alpha; ++ x = +x; ++ if (alpha) { ++ if (x > 0) { ++ alpha = x; ++ } else { ++ timer.c = null, timer.t = NaN, timer = null; ++ event.end({ ++ type: "end", ++ alpha: alpha = 0 ++ }); + } +- } else if (clipAuto) { +- v = null; ++ } else if (x > 0) { ++ event.start({ ++ type: "start", ++ alpha: alpha = x ++ }); ++ timer = d3_timer(force.tick); + } +- return v; +- }; +- return m.clipExtent(null); +- } +- (d3.geo.mercator = function() { +- return d3_geo_mercatorProjection(d3_geo_mercator); +- }).raw = d3_geo_mercator; +- var d3_geo_orthographic = d3_geo_azimuthal(function() { +- return 1; +- }, Math.asin); +- (d3.geo.orthographic = function() { +- return d3_geo_projection(d3_geo_orthographic); +- }).raw = d3_geo_orthographic; +- var d3_geo_stereographic = d3_geo_azimuthal(function(cosλcosφ) { +- return 1 / (1 + cosλcosφ); +- }, function(ρ) { +- return 2 * Math.atan(ρ); +- }); +- (d3.geo.stereographic = function() { +- return d3_geo_projection(d3_geo_stereographic); +- }).raw = d3_geo_stereographic; +- function d3_geo_transverseMercator(λ, φ) { +- return [ Math.log(Math.tan(π / 4 + φ / 2)), -λ ]; +- } +- d3_geo_transverseMercator.invert = function(x, y) { +- return [ -y, 2 * Math.atan(Math.exp(x)) - halfπ ]; +- }; +- (d3.geo.transverseMercator = function() { +- var projection = d3_geo_mercatorProjection(d3_geo_transverseMercator), center = projection.center, rotate = projection.rotate; +- projection.center = function(_) { +- return _ ? center([ -_[1], _[0] ]) : (_ = center(), [ _[1], -_[0] ]); +- }; +- projection.rotate = function(_) { +- return _ ? rotate([ _[0], _[1], _.length > 2 ? _[2] + 90 : 90 ]) : (_ = rotate(), +- [ _[0], _[1], _[2] - 90 ]); ++ return force; + }; +- return rotate([ 0, 0, 90 ]); +- }).raw = d3_geo_transverseMercator; +- d3.geom = {}; +- function d3_geom_pointX(d) { +- return d[0]; +- } +- function d3_geom_pointY(d) { +- return d[1]; +- } +- d3.geom.hull = function(vertices) { +- var x = d3_geom_pointX, y = d3_geom_pointY; +- if (arguments.length) return hull(vertices); +- function hull(data) { +- if (data.length < 3) return []; +- var fx = d3_functor(x), fy = d3_functor(y), i, n = data.length, points = [], flippedPoints = []; +- for (i = 0; i < n; i++) { +- points.push([ +fx.call(this, data[i], i), +fy.call(this, data[i], i), i ]); ++ force.start = function() { ++ var i, n = nodes.length, m = links.length, w = size[0], h = size[1], neighbors, o; ++ for (i = 0; i < n; ++i) { ++ (o = nodes[i]).index = i; ++ o.weight = 0; + } +- points.sort(d3_geom_hullOrder); +- for (i = 0; i < n; i++) flippedPoints.push([ points[i][0], -points[i][1] ]); +- var upper = d3_geom_hullUpper(points), lower = d3_geom_hullUpper(flippedPoints); +- var skipLeft = lower[0] === upper[0], skipRight = lower[lower.length - 1] === upper[upper.length - 1], polygon = []; +- for (i = upper.length - 1; i >= 0; --i) polygon.push(data[points[upper[i]][2]]); +- for (i = +skipLeft; i < lower.length - skipRight; ++i) polygon.push(data[points[lower[i]][2]]); +- return polygon; +- } +- hull.x = function(_) { +- return arguments.length ? (x = _, hull) : x; +- }; +- hull.y = function(_) { +- return arguments.length ? (y = _, hull) : y; +- }; +- return hull; +- }; +- function d3_geom_hullUpper(points) { +- var n = points.length, hull = [ 0, 1 ], hs = 2; +- for (var i = 2; i < n; i++) { +- while (hs > 1 && d3_cross2d(points[hull[hs - 2]], points[hull[hs - 1]], points[i]) <= 0) --hs; +- hull[hs++] = i; +- } +- return hull.slice(0, hs); +- } +- function d3_geom_hullOrder(a, b) { +- return a[0] - b[0] || a[1] - b[1]; +- } +- d3.geom.polygon = function(coordinates) { +- d3_subclass(coordinates, d3_geom_polygonPrototype); +- return coordinates; +- }; +- var d3_geom_polygonPrototype = d3.geom.polygon.prototype = []; +- d3_geom_polygonPrototype.area = function() { +- var i = -1, n = this.length, a, b = this[n - 1], area = 0; +- while (++i < n) { +- a = b; +- b = this[i]; +- area += a[1] * b[0] - a[0] * b[1]; +- } +- return area * .5; +- }; +- d3_geom_polygonPrototype.centroid = function(k) { +- var i = -1, n = this.length, x = 0, y = 0, a, b = this[n - 1], c; +- if (!arguments.length) k = -1 / (6 * this.area()); +- while (++i < n) { +- a = b; +- b = this[i]; +- c = a[0] * b[1] - b[0] * a[1]; +- x += (a[0] + b[0]) * c; +- y += (a[1] + b[1]) * c; +- } +- return [ x * k, y * k ]; +- }; +- d3_geom_polygonPrototype.clip = function(subject) { +- var input, closed = d3_geom_polygonClosed(subject), i = -1, n = this.length - d3_geom_polygonClosed(this), j, m, a = this[n - 1], b, c, d; +- while (++i < n) { +- input = subject.slice(); +- subject.length = 0; +- b = this[i]; +- c = input[(m = input.length - closed) - 1]; +- j = -1; +- while (++j < m) { +- d = input[j]; +- if (d3_geom_polygonInside(d, a, b)) { +- if (!d3_geom_polygonInside(c, a, b)) { +- subject.push(d3_geom_polygonIntersect(c, d, a, b)); ++ for (i = 0; i < m; ++i) { ++ o = links[i]; ++ if (typeof o.source == "number") o.source = nodes[o.source]; ++ if (typeof o.target == "number") o.target = nodes[o.target]; ++ ++o.source.weight; ++ ++o.target.weight; ++ } ++ for (i = 0; i < n; ++i) { ++ o = nodes[i]; ++ if (isNaN(o.x)) o.x = position("x", w); ++ if (isNaN(o.y)) o.y = position("y", h); ++ if (isNaN(o.px)) o.px = o.x; ++ if (isNaN(o.py)) o.py = o.y; ++ } ++ distances = []; ++ if (typeof linkDistance === "function") for (i = 0; i < m; ++i) distances[i] = +linkDistance.call(this, links[i], i); else for (i = 0; i < m; ++i) distances[i] = linkDistance; ++ strengths = []; ++ if (typeof linkStrength === "function") for (i = 0; i < m; ++i) strengths[i] = +linkStrength.call(this, links[i], i); else for (i = 0; i < m; ++i) strengths[i] = linkStrength; ++ charges = []; ++ if (typeof charge === "function") for (i = 0; i < n; ++i) charges[i] = +charge.call(this, nodes[i], i); else for (i = 0; i < n; ++i) charges[i] = charge; ++ function position(dimension, size) { ++ if (!neighbors) { ++ neighbors = new Array(n); ++ for (j = 0; j < n; ++j) { ++ neighbors[j] = []; ++ } ++ for (j = 0; j < m; ++j) { ++ var o = links[j]; ++ neighbors[o.source.index].push(o.target); ++ neighbors[o.target.index].push(o.source); + } +- subject.push(d); +- } else if (d3_geom_polygonInside(c, a, b)) { +- subject.push(d3_geom_polygonIntersect(c, d, a, b)); + } +- c = d; ++ var candidates = neighbors[i], j = -1, l = candidates.length, x; ++ while (++j < l) if (!isNaN(x = candidates[j][dimension])) return x; ++ return Math.random() * size; + } +- if (closed) subject.push(subject[0]); +- a = b; ++ return force.resume(); ++ }; ++ force.resume = function() { ++ return force.alpha(.1); ++ }; ++ force.stop = function() { ++ return force.alpha(0); ++ }; ++ force.drag = function() { ++ if (!drag) drag = d3.behavior.drag().origin(d3_identity).on("dragstart.force", d3_layout_forceDragstart).on("drag.force", dragmove).on("dragend.force", d3_layout_forceDragend); ++ if (!arguments.length) return drag; ++ this.on("mouseover.force", d3_layout_forceMouseover).on("mouseout.force", d3_layout_forceMouseout).call(drag); ++ }; ++ function dragmove(d) { ++ d.px = d3.event.x, d.py = d3.event.y; ++ force.resume(); + } +- return subject; ++ return d3.rebind(force, event, "on"); + }; +- function d3_geom_polygonInside(p, a, b) { +- return (b[0] - a[0]) * (p[1] - a[1]) < (b[1] - a[1]) * (p[0] - a[0]); +- } +- function d3_geom_polygonIntersect(c, d, a, b) { +- var x1 = c[0], x3 = a[0], x21 = d[0] - x1, x43 = b[0] - x3, y1 = c[1], y3 = a[1], y21 = d[1] - y1, y43 = b[1] - y3, ua = (x43 * (y1 - y3) - y43 * (x1 - x3)) / (y43 * x21 - x43 * y21); +- return [ x1 + ua * x21, y1 + ua * y21 ]; +- } +- function d3_geom_polygonClosed(coordinates) { +- var a = coordinates[0], b = coordinates[coordinates.length - 1]; +- return !(a[0] - b[0] || a[1] - b[1]); ++ function d3_layout_forceDragstart(d) { ++ d.fixed |= 2; + } +- var d3_geom_voronoiEdges, d3_geom_voronoiCells, d3_geom_voronoiBeaches, d3_geom_voronoiBeachPool = [], d3_geom_voronoiFirstCircle, d3_geom_voronoiCircles, d3_geom_voronoiCirclePool = []; +- function d3_geom_voronoiBeach() { +- d3_geom_voronoiRedBlackNode(this); +- this.edge = this.site = this.circle = null; ++ function d3_layout_forceDragend(d) { ++ d.fixed &= ~6; + } +- function d3_geom_voronoiCreateBeach(site) { +- var beach = d3_geom_voronoiBeachPool.pop() || new d3_geom_voronoiBeach(); +- beach.site = site; +- return beach; ++ function d3_layout_forceMouseover(d) { ++ d.fixed |= 4; ++ d.px = d.x, d.py = d.y; + } +- function d3_geom_voronoiDetachBeach(beach) { +- d3_geom_voronoiDetachCircle(beach); +- d3_geom_voronoiBeaches.remove(beach); +- d3_geom_voronoiBeachPool.push(beach); +- d3_geom_voronoiRedBlackNode(beach); ++ function d3_layout_forceMouseout(d) { ++ d.fixed &= ~4; + } +- function d3_geom_voronoiRemoveBeach(beach) { +- var circle = beach.circle, x = circle.x, y = circle.cy, vertex = { +- x: x, +- y: y +- }, previous = beach.P, next = beach.N, disappearing = [ beach ]; +- d3_geom_voronoiDetachBeach(beach); +- var lArc = previous; +- while (lArc.circle && abs(x - lArc.circle.x) < ε && abs(y - lArc.circle.cy) < ε) { +- previous = lArc.P; +- disappearing.unshift(lArc); +- d3_geom_voronoiDetachBeach(lArc); +- lArc = previous; +- } +- disappearing.unshift(lArc); +- d3_geom_voronoiDetachCircle(lArc); +- var rArc = next; +- while (rArc.circle && abs(x - rArc.circle.x) < ε && abs(y - rArc.circle.cy) < ε) { +- next = rArc.N; +- disappearing.push(rArc); +- d3_geom_voronoiDetachBeach(rArc); +- rArc = next; ++ function d3_layout_forceAccumulate(quad, alpha, charges) { ++ var cx = 0, cy = 0; ++ quad.charge = 0; ++ if (!quad.leaf) { ++ var nodes = quad.nodes, n = nodes.length, i = -1, c; ++ while (++i < n) { ++ c = nodes[i]; ++ if (c == null) continue; ++ d3_layout_forceAccumulate(c, alpha, charges); ++ quad.charge += c.charge; ++ cx += c.charge * c.cx; ++ cy += c.charge * c.cy; ++ } + } +- disappearing.push(rArc); +- d3_geom_voronoiDetachCircle(rArc); +- var nArcs = disappearing.length, iArc; +- for (iArc = 1; iArc < nArcs; ++iArc) { +- rArc = disappearing[iArc]; +- lArc = disappearing[iArc - 1]; +- d3_geom_voronoiSetEdgeEnd(rArc.edge, lArc.site, rArc.site, vertex); ++ if (quad.point) { ++ if (!quad.leaf) { ++ quad.point.x += Math.random() - .5; ++ quad.point.y += Math.random() - .5; ++ } ++ var k = alpha * charges[quad.point.index]; ++ quad.charge += quad.pointCharge = k; ++ cx += k * quad.point.x; ++ cy += k * quad.point.y; + } +- lArc = disappearing[0]; +- rArc = disappearing[nArcs - 1]; +- rArc.edge = d3_geom_voronoiCreateEdge(lArc.site, rArc.site, null, vertex); +- d3_geom_voronoiAttachCircle(lArc); +- d3_geom_voronoiAttachCircle(rArc); ++ quad.cx = cx / quad.charge; ++ quad.cy = cy / quad.charge; + } +- function d3_geom_voronoiAddBeach(site) { +- var x = site.x, directrix = site.y, lArc, rArc, dxl, dxr, node = d3_geom_voronoiBeaches._; +- while (node) { +- dxl = d3_geom_voronoiLeftBreakPoint(node, directrix) - x; +- if (dxl > ε) node = node.L; else { +- dxr = x - d3_geom_voronoiRightBreakPoint(node, directrix); +- if (dxr > ε) { +- if (!node.R) { +- lArc = node; +- break; ++ var d3_layout_forceLinkDistance = 20, d3_layout_forceLinkStrength = 1, d3_layout_forceChargeDistance2 = Infinity; ++ d3.layout.hierarchy = function() { ++ var sort = d3_layout_hierarchySort, children = d3_layout_hierarchyChildren, value = d3_layout_hierarchyValue; ++ function hierarchy(root) { ++ var stack = [ root ], nodes = [], node; ++ root.depth = 0; ++ while ((node = stack.pop()) != null) { ++ nodes.push(node); ++ if ((childs = children.call(hierarchy, node, node.depth)) && (n = childs.length)) { ++ var n, childs, child; ++ while (--n >= 0) { ++ stack.push(child = childs[n]); ++ child.parent = node; ++ child.depth = node.depth + 1; + } +- node = node.R; ++ if (value) node.value = 0; ++ node.children = childs; + } else { +- if (dxl > -ε) { +- lArc = node.P; +- rArc = node; +- } else if (dxr > -ε) { +- lArc = node; +- rArc = node.N; +- } else { +- lArc = rArc = node; +- } +- break; ++ if (value) node.value = +value.call(hierarchy, node, node.depth) || 0; ++ delete node.children; + } + } ++ d3_layout_hierarchyVisitAfter(root, function(node) { ++ var childs, parent; ++ if (sort && (childs = node.children)) childs.sort(sort); ++ if (value && (parent = node.parent)) parent.value += node.value; ++ }); ++ return nodes; + } +- var newArc = d3_geom_voronoiCreateBeach(site); +- d3_geom_voronoiBeaches.insert(lArc, newArc); +- if (!lArc && !rArc) return; +- if (lArc === rArc) { +- d3_geom_voronoiDetachCircle(lArc); +- rArc = d3_geom_voronoiCreateBeach(lArc.site); +- d3_geom_voronoiBeaches.insert(newArc, rArc); +- newArc.edge = rArc.edge = d3_geom_voronoiCreateEdge(lArc.site, newArc.site); +- d3_geom_voronoiAttachCircle(lArc); +- d3_geom_voronoiAttachCircle(rArc); +- return; ++ hierarchy.sort = function(x) { ++ if (!arguments.length) return sort; ++ sort = x; ++ return hierarchy; ++ }; ++ hierarchy.children = function(x) { ++ if (!arguments.length) return children; ++ children = x; ++ return hierarchy; ++ }; ++ hierarchy.value = function(x) { ++ if (!arguments.length) return value; ++ value = x; ++ return hierarchy; ++ }; ++ hierarchy.revalue = function(root) { ++ if (value) { ++ d3_layout_hierarchyVisitBefore(root, function(node) { ++ if (node.children) node.value = 0; ++ }); ++ d3_layout_hierarchyVisitAfter(root, function(node) { ++ var parent; ++ if (!node.children) node.value = +value.call(hierarchy, node, node.depth) || 0; ++ if (parent = node.parent) parent.value += node.value; ++ }); ++ } ++ return root; ++ }; ++ return hierarchy; ++ }; ++ function d3_layout_hierarchyRebind(object, hierarchy) { ++ d3.rebind(object, hierarchy, "sort", "children", "value"); ++ object.nodes = object; ++ object.links = d3_layout_hierarchyLinks; ++ return object; ++ } ++ function d3_layout_hierarchyVisitBefore(node, callback) { ++ var nodes = [ node ]; ++ while ((node = nodes.pop()) != null) { ++ callback(node); ++ if ((children = node.children) && (n = children.length)) { ++ var n, children; ++ while (--n >= 0) nodes.push(children[n]); ++ } + } +- if (!rArc) { +- newArc.edge = d3_geom_voronoiCreateEdge(lArc.site, newArc.site); +- return; ++ } ++ function d3_layout_hierarchyVisitAfter(node, callback) { ++ var nodes = [ node ], nodes2 = []; ++ while ((node = nodes.pop()) != null) { ++ nodes2.push(node); ++ if ((children = node.children) && (n = children.length)) { ++ var i = -1, n, children; ++ while (++i < n) nodes.push(children[i]); ++ } ++ } ++ while ((node = nodes2.pop()) != null) { ++ callback(node); + } +- d3_geom_voronoiDetachCircle(lArc); +- d3_geom_voronoiDetachCircle(rArc); +- var lSite = lArc.site, ax = lSite.x, ay = lSite.y, bx = site.x - ax, by = site.y - ay, rSite = rArc.site, cx = rSite.x - ax, cy = rSite.y - ay, d = 2 * (bx * cy - by * cx), hb = bx * bx + by * by, hc = cx * cx + cy * cy, vertex = { +- x: (cy * hb - by * hc) / d + ax, +- y: (bx * hc - cx * hb) / d + ay +- }; +- d3_geom_voronoiSetEdgeEnd(rArc.edge, lSite, rSite, vertex); +- newArc.edge = d3_geom_voronoiCreateEdge(lSite, site, null, vertex); +- rArc.edge = d3_geom_voronoiCreateEdge(site, rSite, null, vertex); +- d3_geom_voronoiAttachCircle(lArc); +- d3_geom_voronoiAttachCircle(rArc); + } +- function d3_geom_voronoiLeftBreakPoint(arc, directrix) { +- var site = arc.site, rfocx = site.x, rfocy = site.y, pby2 = rfocy - directrix; +- if (!pby2) return rfocx; +- var lArc = arc.P; +- if (!lArc) return -Infinity; +- site = lArc.site; +- var lfocx = site.x, lfocy = site.y, plby2 = lfocy - directrix; +- if (!plby2) return lfocx; +- var hl = lfocx - rfocx, aby2 = 1 / pby2 - 1 / plby2, b = hl / plby2; +- if (aby2) return (-b + Math.sqrt(b * b - 2 * aby2 * (hl * hl / (-2 * plby2) - lfocy + plby2 / 2 + rfocy - pby2 / 2))) / aby2 + rfocx; +- return (rfocx + lfocx) / 2; ++ function d3_layout_hierarchyChildren(d) { ++ return d.children; + } +- function d3_geom_voronoiRightBreakPoint(arc, directrix) { +- var rArc = arc.N; +- if (rArc) return d3_geom_voronoiLeftBreakPoint(rArc, directrix); +- var site = arc.site; +- return site.y === directrix ? site.x : Infinity; ++ function d3_layout_hierarchyValue(d) { ++ return d.value; + } +- function d3_geom_voronoiCell(site) { +- this.site = site; +- this.edges = []; ++ function d3_layout_hierarchySort(a, b) { ++ return b.value - a.value; + } +- d3_geom_voronoiCell.prototype.prepare = function() { +- var halfEdges = this.edges, iHalfEdge = halfEdges.length, edge; +- while (iHalfEdge--) { +- edge = halfEdges[iHalfEdge].edge; +- if (!edge.b || !edge.a) halfEdges.splice(iHalfEdge, 1); ++ function d3_layout_hierarchyLinks(nodes) { ++ return d3.merge(nodes.map(function(parent) { ++ return (parent.children || []).map(function(child) { ++ return { ++ source: parent, ++ target: child ++ }; ++ }); ++ })); ++ } ++ d3.layout.partition = function() { ++ var hierarchy = d3.layout.hierarchy(), size = [ 1, 1 ]; ++ function position(node, x, dx, dy) { ++ var children = node.children; ++ node.x = x; ++ node.y = node.depth * dy; ++ node.dx = dx; ++ node.dy = dy; ++ if (children && (n = children.length)) { ++ var i = -1, n, c, d; ++ dx = node.value ? dx / node.value : 0; ++ while (++i < n) { ++ position(c = children[i], x, d = c.value * dx, dy); ++ x += d; ++ } ++ } + } +- halfEdges.sort(d3_geom_voronoiHalfEdgeOrder); +- return halfEdges.length; ++ function depth(node) { ++ var children = node.children, d = 0; ++ if (children && (n = children.length)) { ++ var i = -1, n; ++ while (++i < n) d = Math.max(d, depth(children[i])); ++ } ++ return 1 + d; ++ } ++ function partition(d, i) { ++ var nodes = hierarchy.call(this, d, i); ++ position(nodes[0], 0, size[0], size[1] / depth(nodes[0])); ++ return nodes; ++ } ++ partition.size = function(x) { ++ if (!arguments.length) return size; ++ size = x; ++ return partition; ++ }; ++ return d3_layout_hierarchyRebind(partition, hierarchy); + }; +- function d3_geom_voronoiCloseCells(extent) { +- var x0 = extent[0][0], x1 = extent[1][0], y0 = extent[0][1], y1 = extent[1][1], x2, y2, x3, y3, cells = d3_geom_voronoiCells, iCell = cells.length, cell, iHalfEdge, halfEdges, nHalfEdges, start, end; +- while (iCell--) { +- cell = cells[iCell]; +- if (!cell || !cell.prepare()) continue; +- halfEdges = cell.edges; +- nHalfEdges = halfEdges.length; +- iHalfEdge = 0; +- while (iHalfEdge < nHalfEdges) { +- end = halfEdges[iHalfEdge].end(), x3 = end.x, y3 = end.y; +- start = halfEdges[++iHalfEdge % nHalfEdges].start(), x2 = start.x, y2 = start.y; +- if (abs(x3 - x2) > ε || abs(y3 - y2) > ε) { +- halfEdges.splice(iHalfEdge, 0, new d3_geom_voronoiHalfEdge(d3_geom_voronoiCreateBorderEdge(cell.site, end, abs(x3 - x0) < ε && y1 - y3 > ε ? { +- x: x0, +- y: abs(x2 - x0) < ε ? y2 : y1 +- } : abs(y3 - y1) < ε && x1 - x3 > ε ? { +- x: abs(y2 - y1) < ε ? x2 : x1, +- y: y1 +- } : abs(x3 - x1) < ε && y3 - y0 > ε ? { +- x: x1, +- y: abs(x2 - x1) < ε ? y2 : y0 +- } : abs(y3 - y0) < ε && x3 - x0 > ε ? { +- x: abs(y2 - y0) < ε ? x2 : x0, +- y: y0 +- } : null), cell.site, null)); +- ++nHalfEdges; ++ d3.layout.pie = function() { ++ var value = Number, sort = d3_layout_pieSortByValue, startAngle = 0, endAngle = τ, padAngle = 0; ++ function pie(data) { ++ var n = data.length, values = data.map(function(d, i) { ++ return +value.call(pie, d, i); ++ }), a = +(typeof startAngle === "function" ? startAngle.apply(this, arguments) : startAngle), da = (typeof endAngle === "function" ? endAngle.apply(this, arguments) : endAngle) - a, p = Math.min(Math.abs(da) / n, +(typeof padAngle === "function" ? padAngle.apply(this, arguments) : padAngle)), pa = p * (da < 0 ? -1 : 1), sum = d3.sum(values), k = sum ? (da - n * pa) / sum : 0, index = d3.range(n), arcs = [], v; ++ if (sort != null) index.sort(sort === d3_layout_pieSortByValue ? function(i, j) { ++ return values[j] - values[i]; ++ } : function(i, j) { ++ return sort(data[i], data[j]); ++ }); ++ index.forEach(function(i) { ++ arcs[i] = { ++ data: data[i], ++ value: v = values[i], ++ startAngle: a, ++ endAngle: a += v * k + pa, ++ padAngle: p ++ }; ++ }); ++ return arcs; ++ } ++ pie.value = function(_) { ++ if (!arguments.length) return value; ++ value = _; ++ return pie; ++ }; ++ pie.sort = function(_) { ++ if (!arguments.length) return sort; ++ sort = _; ++ return pie; ++ }; ++ pie.startAngle = function(_) { ++ if (!arguments.length) return startAngle; ++ startAngle = _; ++ return pie; ++ }; ++ pie.endAngle = function(_) { ++ if (!arguments.length) return endAngle; ++ endAngle = _; ++ return pie; ++ }; ++ pie.padAngle = function(_) { ++ if (!arguments.length) return padAngle; ++ padAngle = _; ++ return pie; ++ }; ++ return pie; ++ }; ++ var d3_layout_pieSortByValue = {}; ++ d3.layout.stack = function() { ++ var values = d3_identity, order = d3_layout_stackOrderDefault, offset = d3_layout_stackOffsetZero, out = d3_layout_stackOut, x = d3_layout_stackX, y = d3_layout_stackY; ++ function stack(data, index) { ++ if (!(n = data.length)) return data; ++ var series = data.map(function(d, i) { ++ return values.call(stack, d, i); ++ }); ++ var points = series.map(function(d) { ++ return d.map(function(v, i) { ++ return [ x.call(stack, v, i), y.call(stack, v, i) ]; ++ }); ++ }); ++ var orders = order.call(stack, points, index); ++ series = d3.permute(series, orders); ++ points = d3.permute(points, orders); ++ var offsets = offset.call(stack, points, index); ++ var m = series[0].length, n, i, j, o; ++ for (j = 0; j < m; ++j) { ++ out.call(stack, series[0][j], o = offsets[j], points[0][j][1]); ++ for (i = 1; i < n; ++i) { ++ out.call(stack, series[i][j], o += points[i - 1][j][1], points[i][j][1]); ++ } ++ } ++ return data; ++ } ++ stack.values = function(x) { ++ if (!arguments.length) return values; ++ values = x; ++ return stack; ++ }; ++ stack.order = function(x) { ++ if (!arguments.length) return order; ++ order = typeof x === "function" ? x : d3_layout_stackOrders.get(x) || d3_layout_stackOrderDefault; ++ return stack; ++ }; ++ stack.offset = function(x) { ++ if (!arguments.length) return offset; ++ offset = typeof x === "function" ? x : d3_layout_stackOffsets.get(x) || d3_layout_stackOffsetZero; ++ return stack; ++ }; ++ stack.x = function(z) { ++ if (!arguments.length) return x; ++ x = z; ++ return stack; ++ }; ++ stack.y = function(z) { ++ if (!arguments.length) return y; ++ y = z; ++ return stack; ++ }; ++ stack.out = function(z) { ++ if (!arguments.length) return out; ++ out = z; ++ return stack; ++ }; ++ return stack; ++ }; ++ function d3_layout_stackX(d) { ++ return d.x; ++ } ++ function d3_layout_stackY(d) { ++ return d.y; ++ } ++ function d3_layout_stackOut(d, y0, y) { ++ d.y0 = y0; ++ d.y = y; ++ } ++ var d3_layout_stackOrders = d3.map({ ++ "inside-out": function(data) { ++ var n = data.length, i, j, max = data.map(d3_layout_stackMaxIndex), sums = data.map(d3_layout_stackReduceSum), index = d3.range(n).sort(function(a, b) { ++ return max[a] - max[b]; ++ }), top = 0, bottom = 0, tops = [], bottoms = []; ++ for (i = 0; i < n; ++i) { ++ j = index[i]; ++ if (top < bottom) { ++ top += sums[j]; ++ tops.push(j); ++ } else { ++ bottom += sums[j]; ++ bottoms.push(j); ++ } ++ } ++ return bottoms.reverse().concat(tops); ++ }, ++ reverse: function(data) { ++ return d3.range(data.length).reverse(); ++ }, ++ "default": d3_layout_stackOrderDefault ++ }); ++ var d3_layout_stackOffsets = d3.map({ ++ silhouette: function(data) { ++ var n = data.length, m = data[0].length, sums = [], max = 0, i, j, o, y0 = []; ++ for (j = 0; j < m; ++j) { ++ for (i = 0, o = 0; i < n; i++) o += data[i][j][1]; ++ if (o > max) max = o; ++ sums.push(o); ++ } ++ for (j = 0; j < m; ++j) { ++ y0[j] = (max - sums[j]) / 2; ++ } ++ return y0; ++ }, ++ wiggle: function(data) { ++ var n = data.length, x = data[0], m = x.length, i, j, k, s1, s2, s3, dx, o, o0, y0 = []; ++ y0[0] = o = o0 = 0; ++ for (j = 1; j < m; ++j) { ++ for (i = 0, s1 = 0; i < n; ++i) s1 += data[i][j][1]; ++ for (i = 0, s2 = 0, dx = x[j][0] - x[j - 1][0]; i < n; ++i) { ++ for (k = 0, s3 = (data[i][j][1] - data[i][j - 1][1]) / (2 * dx); k < i; ++k) { ++ s3 += (data[k][j][1] - data[k][j - 1][1]) / dx; ++ } ++ s2 += s3 * data[i][j][1]; + } ++ y0[j] = o -= s1 ? s2 / s1 * dx : 0; ++ if (o < o0) o0 = o; + } +- } +- } +- function d3_geom_voronoiHalfEdgeOrder(a, b) { +- return b.angle - a.angle; ++ for (j = 0; j < m; ++j) y0[j] -= o0; ++ return y0; ++ }, ++ expand: function(data) { ++ var n = data.length, m = data[0].length, k = 1 / n, i, j, o, y0 = []; ++ for (j = 0; j < m; ++j) { ++ for (i = 0, o = 0; i < n; i++) o += data[i][j][1]; ++ if (o) for (i = 0; i < n; i++) data[i][j][1] /= o; else for (i = 0; i < n; i++) data[i][j][1] = k; ++ } ++ for (j = 0; j < m; ++j) y0[j] = 0; ++ return y0; ++ }, ++ zero: d3_layout_stackOffsetZero ++ }); ++ function d3_layout_stackOrderDefault(data) { ++ return d3.range(data.length); + } +- function d3_geom_voronoiCircle() { +- d3_geom_voronoiRedBlackNode(this); +- this.x = this.y = this.arc = this.site = this.cy = null; ++ function d3_layout_stackOffsetZero(data) { ++ var j = -1, m = data[0].length, y0 = []; ++ while (++j < m) y0[j] = 0; ++ return y0; + } +- function d3_geom_voronoiAttachCircle(arc) { +- var lArc = arc.P, rArc = arc.N; +- if (!lArc || !rArc) return; +- var lSite = lArc.site, cSite = arc.site, rSite = rArc.site; +- if (lSite === rSite) return; +- var bx = cSite.x, by = cSite.y, ax = lSite.x - bx, ay = lSite.y - by, cx = rSite.x - bx, cy = rSite.y - by; +- var d = 2 * (ax * cy - ay * cx); +- if (d >= -ε2) return; +- var ha = ax * ax + ay * ay, hc = cx * cx + cy * cy, x = (cy * ha - ay * hc) / d, y = (ax * hc - cx * ha) / d, cy = y + by; +- var circle = d3_geom_voronoiCirclePool.pop() || new d3_geom_voronoiCircle(); +- circle.arc = arc; +- circle.site = cSite; +- circle.x = x + bx; +- circle.y = cy + Math.sqrt(x * x + y * y); +- circle.cy = cy; +- arc.circle = circle; +- var before = null, node = d3_geom_voronoiCircles._; +- while (node) { +- if (circle.y < node.y || circle.y === node.y && circle.x <= node.x) { +- if (node.L) node = node.L; else { +- before = node.P; +- break; +- } +- } else { +- if (node.R) node = node.R; else { +- before = node; +- break; +- } ++ function d3_layout_stackMaxIndex(array) { ++ var i = 1, j = 0, v = array[0][1], k, n = array.length; ++ for (;i < n; ++i) { ++ if ((k = array[i][1]) > v) { ++ j = i; ++ v = k; + } + } +- d3_geom_voronoiCircles.insert(before, circle); +- if (!before) d3_geom_voronoiFirstCircle = circle; ++ return j; + } +- function d3_geom_voronoiDetachCircle(arc) { +- var circle = arc.circle; +- if (circle) { +- if (!circle.P) d3_geom_voronoiFirstCircle = circle.N; +- d3_geom_voronoiCircles.remove(circle); +- d3_geom_voronoiCirclePool.push(circle); +- d3_geom_voronoiRedBlackNode(circle); +- arc.circle = null; +- } ++ function d3_layout_stackReduceSum(d) { ++ return d.reduce(d3_layout_stackSum, 0); + } +- function d3_geom_voronoiClipEdges(extent) { +- var edges = d3_geom_voronoiEdges, clip = d3_geom_clipLine(extent[0][0], extent[0][1], extent[1][0], extent[1][1]), i = edges.length, e; +- while (i--) { +- e = edges[i]; +- if (!d3_geom_voronoiConnectEdge(e, extent) || !clip(e) || abs(e.a.x - e.b.x) < ε && abs(e.a.y - e.b.y) < ε) { +- e.a = e.b = null; +- edges.splice(i, 1); +- } +- } ++ function d3_layout_stackSum(p, d) { ++ return p + d[1]; + } +- function d3_geom_voronoiConnectEdge(edge, extent) { +- var vb = edge.b; +- if (vb) return true; +- var va = edge.a, x0 = extent[0][0], x1 = extent[1][0], y0 = extent[0][1], y1 = extent[1][1], lSite = edge.l, rSite = edge.r, lx = lSite.x, ly = lSite.y, rx = rSite.x, ry = rSite.y, fx = (lx + rx) / 2, fy = (ly + ry) / 2, fm, fb; +- if (ry === ly) { +- if (fx < x0 || fx >= x1) return; +- if (lx > rx) { +- if (!va) va = { +- x: fx, +- y: y0 +- }; else if (va.y >= y1) return; +- vb = { +- x: fx, +- y: y1 +- }; +- } else { +- if (!va) va = { +- x: fx, +- y: y1 +- }; else if (va.y < y0) return; +- vb = { +- x: fx, +- y: y0 +- }; ++ d3.layout.histogram = function() { ++ var frequency = true, valuer = Number, ranger = d3_layout_histogramRange, binner = d3_layout_histogramBinSturges; ++ function histogram(data, i) { ++ var bins = [], values = data.map(valuer, this), range = ranger.call(this, values, i), thresholds = binner.call(this, range, values, i), bin, i = -1, n = values.length, m = thresholds.length - 1, k = frequency ? 1 : 1 / n, x; ++ while (++i < m) { ++ bin = bins[i] = []; ++ bin.dx = thresholds[i + 1] - (bin.x = thresholds[i]); ++ bin.y = 0; + } +- } else { +- fm = (lx - rx) / (ry - ly); +- fb = fy - fm * fx; +- if (fm < -1 || fm > 1) { +- if (lx > rx) { +- if (!va) va = { +- x: (y0 - fb) / fm, +- y: y0 +- }; else if (va.y >= y1) return; +- vb = { +- x: (y1 - fb) / fm, +- y: y1 +- }; +- } else { +- if (!va) va = { +- x: (y1 - fb) / fm, +- y: y1 +- }; else if (va.y < y0) return; +- vb = { +- x: (y0 - fb) / fm, +- y: y0 +- }; +- } +- } else { +- if (ly < ry) { +- if (!va) va = { +- x: x0, +- y: fm * x0 + fb +- }; else if (va.x >= x1) return; +- vb = { +- x: x1, +- y: fm * x1 + fb +- }; +- } else { +- if (!va) va = { +- x: x1, +- y: fm * x1 + fb +- }; else if (va.x < x0) return; +- vb = { +- x: x0, +- y: fm * x0 + fb +- }; ++ if (m > 0) { ++ i = -1; ++ while (++i < n) { ++ x = values[i]; ++ if (x >= range[0] && x <= range[1]) { ++ bin = bins[d3.bisect(thresholds, x, 1, m) - 1]; ++ bin.y += k; ++ bin.push(data[i]); ++ } + } + } ++ return bins; + } +- edge.a = va; +- edge.b = vb; +- return true; +- } +- function d3_geom_voronoiEdge(lSite, rSite) { +- this.l = lSite; +- this.r = rSite; +- this.a = this.b = null; ++ histogram.value = function(x) { ++ if (!arguments.length) return valuer; ++ valuer = x; ++ return histogram; ++ }; ++ histogram.range = function(x) { ++ if (!arguments.length) return ranger; ++ ranger = d3_functor(x); ++ return histogram; ++ }; ++ histogram.bins = function(x) { ++ if (!arguments.length) return binner; ++ binner = typeof x === "number" ? function(range) { ++ return d3_layout_histogramBinFixed(range, x); ++ } : d3_functor(x); ++ return histogram; ++ }; ++ histogram.frequency = function(x) { ++ if (!arguments.length) return frequency; ++ frequency = !!x; ++ return histogram; ++ }; ++ return histogram; ++ }; ++ function d3_layout_histogramBinSturges(range, values) { ++ return d3_layout_histogramBinFixed(range, Math.ceil(Math.log(values.length) / Math.LN2 + 1)); + } +- function d3_geom_voronoiCreateEdge(lSite, rSite, va, vb) { +- var edge = new d3_geom_voronoiEdge(lSite, rSite); +- d3_geom_voronoiEdges.push(edge); +- if (va) d3_geom_voronoiSetEdgeEnd(edge, lSite, rSite, va); +- if (vb) d3_geom_voronoiSetEdgeEnd(edge, rSite, lSite, vb); +- d3_geom_voronoiCells[lSite.i].edges.push(new d3_geom_voronoiHalfEdge(edge, lSite, rSite)); +- d3_geom_voronoiCells[rSite.i].edges.push(new d3_geom_voronoiHalfEdge(edge, rSite, lSite)); +- return edge; ++ function d3_layout_histogramBinFixed(range, n) { ++ var x = -1, b = +range[0], m = (range[1] - b) / n, f = []; ++ while (++x <= n) f[x] = m * x + b; ++ return f; + } +- function d3_geom_voronoiCreateBorderEdge(lSite, va, vb) { +- var edge = new d3_geom_voronoiEdge(lSite, null); +- edge.a = va; +- edge.b = vb; +- d3_geom_voronoiEdges.push(edge); +- return edge; ++ function d3_layout_histogramRange(values) { ++ return [ d3.min(values), d3.max(values) ]; + } +- function d3_geom_voronoiSetEdgeEnd(edge, lSite, rSite, vertex) { +- if (!edge.a && !edge.b) { +- edge.a = vertex; +- edge.l = lSite; +- edge.r = rSite; +- } else if (edge.l === rSite) { +- edge.b = vertex; +- } else { +- edge.a = vertex; ++ d3.layout.pack = function() { ++ var hierarchy = d3.layout.hierarchy().sort(d3_layout_packSort), padding = 0, size = [ 1, 1 ], radius; ++ function pack(d, i) { ++ var nodes = hierarchy.call(this, d, i), root = nodes[0], w = size[0], h = size[1], r = radius == null ? Math.sqrt : typeof radius === "function" ? radius : function() { ++ return radius; ++ }; ++ root.x = root.y = 0; ++ d3_layout_hierarchyVisitAfter(root, function(d) { ++ d.r = +r(d.value); ++ }); ++ d3_layout_hierarchyVisitAfter(root, d3_layout_packSiblings); ++ if (padding) { ++ var dr = padding * (radius ? 1 : Math.max(2 * root.r / w, 2 * root.r / h)) / 2; ++ d3_layout_hierarchyVisitAfter(root, function(d) { ++ d.r += dr; ++ }); ++ d3_layout_hierarchyVisitAfter(root, d3_layout_packSiblings); ++ d3_layout_hierarchyVisitAfter(root, function(d) { ++ d.r -= dr; ++ }); ++ } ++ d3_layout_packTransform(root, w / 2, h / 2, radius ? 1 : 1 / Math.max(2 * root.r / w, 2 * root.r / h)); ++ return nodes; + } ++ pack.size = function(_) { ++ if (!arguments.length) return size; ++ size = _; ++ return pack; ++ }; ++ pack.radius = function(_) { ++ if (!arguments.length) return radius; ++ radius = _ == null || typeof _ === "function" ? _ : +_; ++ return pack; ++ }; ++ pack.padding = function(_) { ++ if (!arguments.length) return padding; ++ padding = +_; ++ return pack; ++ }; ++ return d3_layout_hierarchyRebind(pack, hierarchy); ++ }; ++ function d3_layout_packSort(a, b) { ++ return a.value - b.value; + } +- function d3_geom_voronoiHalfEdge(edge, lSite, rSite) { +- var va = edge.a, vb = edge.b; +- this.edge = edge; +- this.site = lSite; +- this.angle = rSite ? Math.atan2(rSite.y - lSite.y, rSite.x - lSite.x) : edge.l === lSite ? Math.atan2(vb.x - va.x, va.y - vb.y) : Math.atan2(va.x - vb.x, vb.y - va.y); ++ function d3_layout_packInsert(a, b) { ++ var c = a._pack_next; ++ a._pack_next = b; ++ b._pack_prev = a; ++ b._pack_next = c; ++ c._pack_prev = b; + } +- d3_geom_voronoiHalfEdge.prototype = { +- start: function() { +- return this.edge.l === this.site ? this.edge.a : this.edge.b; +- }, +- end: function() { +- return this.edge.l === this.site ? this.edge.b : this.edge.a; +- } +- }; +- function d3_geom_voronoiRedBlackTree() { +- this._ = null; ++ function d3_layout_packSplice(a, b) { ++ a._pack_next = b; ++ b._pack_prev = a; + } +- function d3_geom_voronoiRedBlackNode(node) { +- node.U = node.C = node.L = node.R = node.P = node.N = null; ++ function d3_layout_packIntersects(a, b) { ++ var dx = b.x - a.x, dy = b.y - a.y, dr = a.r + b.r; ++ return .999 * dr * dr > dx * dx + dy * dy; + } +- d3_geom_voronoiRedBlackTree.prototype = { +- insert: function(after, node) { +- var parent, grandpa, uncle; +- if (after) { +- node.P = after; +- node.N = after.N; +- if (after.N) after.N.P = node; +- after.N = node; +- if (after.R) { +- after = after.R; +- while (after.L) after = after.L; +- after.L = node; +- } else { +- after.R = node; +- } +- parent = after; +- } else if (this._) { +- after = d3_geom_voronoiRedBlackFirst(this._); +- node.P = null; +- node.N = after; +- after.P = after.L = node; +- parent = after; +- } else { +- node.P = node.N = null; +- this._ = node; +- parent = null; +- } +- node.L = node.R = null; +- node.U = parent; +- node.C = true; +- after = node; +- while (parent && parent.C) { +- grandpa = parent.U; +- if (parent === grandpa.L) { +- uncle = grandpa.R; +- if (uncle && uncle.C) { +- parent.C = uncle.C = false; +- grandpa.C = true; +- after = grandpa; +- } else { +- if (after === parent.R) { +- d3_geom_voronoiRedBlackRotateLeft(this, parent); +- after = parent; +- parent = after.U; ++ function d3_layout_packSiblings(node) { ++ if (!(nodes = node.children) || !(n = nodes.length)) return; ++ var nodes, xMin = Infinity, xMax = -Infinity, yMin = Infinity, yMax = -Infinity, a, b, c, i, j, k, n; ++ function bound(node) { ++ xMin = Math.min(node.x - node.r, xMin); ++ xMax = Math.max(node.x + node.r, xMax); ++ yMin = Math.min(node.y - node.r, yMin); ++ yMax = Math.max(node.y + node.r, yMax); ++ } ++ nodes.forEach(d3_layout_packLink); ++ a = nodes[0]; ++ a.x = -a.r; ++ a.y = 0; ++ bound(a); ++ if (n > 1) { ++ b = nodes[1]; ++ b.x = b.r; ++ b.y = 0; ++ bound(b); ++ if (n > 2) { ++ c = nodes[2]; ++ d3_layout_packPlace(a, b, c); ++ bound(c); ++ d3_layout_packInsert(a, c); ++ a._pack_prev = c; ++ d3_layout_packInsert(c, b); ++ b = a._pack_next; ++ for (i = 3; i < n; i++) { ++ d3_layout_packPlace(a, b, c = nodes[i]); ++ var isect = 0, s1 = 1, s2 = 1; ++ for (j = b._pack_next; j !== b; j = j._pack_next, s1++) { ++ if (d3_layout_packIntersects(j, c)) { ++ isect = 1; ++ break; + } +- parent.C = false; +- grandpa.C = true; +- d3_geom_voronoiRedBlackRotateRight(this, grandpa); + } +- } else { +- uncle = grandpa.L; +- if (uncle && uncle.C) { +- parent.C = uncle.C = false; +- grandpa.C = true; +- after = grandpa; +- } else { +- if (after === parent.L) { +- d3_geom_voronoiRedBlackRotateRight(this, parent); +- after = parent; +- parent = after.U; ++ if (isect == 1) { ++ for (k = a._pack_prev; k !== j._pack_prev; k = k._pack_prev, s2++) { ++ if (d3_layout_packIntersects(k, c)) { ++ break; ++ } + } +- parent.C = false; +- grandpa.C = true; +- d3_geom_voronoiRedBlackRotateLeft(this, grandpa); ++ } ++ if (isect) { ++ if (s1 < s2 || s1 == s2 && b.r < a.r) d3_layout_packSplice(a, b = j); else d3_layout_packSplice(a = k, b); ++ i--; ++ } else { ++ d3_layout_packInsert(a, c); ++ b = c; ++ bound(c); + } + } +- parent = after.U; + } +- this._.C = false; +- }, +- remove: function(node) { +- if (node.N) node.N.P = node.P; +- if (node.P) node.P.N = node.N; +- node.N = node.P = null; +- var parent = node.U, sibling, left = node.L, right = node.R, next, red; +- if (!left) next = right; else if (!right) next = left; else next = d3_geom_voronoiRedBlackFirst(right); +- if (parent) { +- if (parent.L === node) parent.L = next; else parent.R = next; +- } else { +- this._ = next; ++ } ++ var cx = (xMin + xMax) / 2, cy = (yMin + yMax) / 2, cr = 0; ++ for (i = 0; i < n; i++) { ++ c = nodes[i]; ++ c.x -= cx; ++ c.y -= cy; ++ cr = Math.max(cr, c.r + Math.sqrt(c.x * c.x + c.y * c.y)); ++ } ++ node.r = cr; ++ nodes.forEach(d3_layout_packUnlink); ++ } ++ function d3_layout_packLink(node) { ++ node._pack_next = node._pack_prev = node; ++ } ++ function d3_layout_packUnlink(node) { ++ delete node._pack_next; ++ delete node._pack_prev; ++ } ++ function d3_layout_packTransform(node, x, y, k) { ++ var children = node.children; ++ node.x = x += k * node.x; ++ node.y = y += k * node.y; ++ node.r *= k; ++ if (children) { ++ var i = -1, n = children.length; ++ while (++i < n) d3_layout_packTransform(children[i], x, y, k); ++ } ++ } ++ function d3_layout_packPlace(a, b, c) { ++ var db = a.r + c.r, dx = b.x - a.x, dy = b.y - a.y; ++ if (db && (dx || dy)) { ++ var da = b.r + c.r, dc = dx * dx + dy * dy; ++ da *= da; ++ db *= db; ++ var x = .5 + (db - da) / (2 * dc), y = Math.sqrt(Math.max(0, 2 * da * (db + dc) - (db -= dc) * db - da * da)) / (2 * dc); ++ c.x = a.x + x * dx + y * dy; ++ c.y = a.y + x * dy - y * dx; ++ } else { ++ c.x = a.x + db; ++ c.y = a.y; ++ } ++ } ++ d3.layout.tree = function() { ++ var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ], nodeSize = null; ++ function tree(d, i) { ++ var nodes = hierarchy.call(this, d, i), root0 = nodes[0], root1 = wrapTree(root0); ++ d3_layout_hierarchyVisitAfter(root1, firstWalk), root1.parent.m = -root1.z; ++ d3_layout_hierarchyVisitBefore(root1, secondWalk); ++ if (nodeSize) d3_layout_hierarchyVisitBefore(root0, sizeNode); else { ++ var left = root0, right = root0, bottom = root0; ++ d3_layout_hierarchyVisitBefore(root0, function(node) { ++ if (node.x < left.x) left = node; ++ if (node.x > right.x) right = node; ++ if (node.depth > bottom.depth) bottom = node; ++ }); ++ var tx = separation(left, right) / 2 - left.x, kx = size[0] / (right.x + separation(right, left) / 2 + tx), ky = size[1] / (bottom.depth || 1); ++ d3_layout_hierarchyVisitBefore(root0, function(node) { ++ node.x = (node.x + tx) * kx; ++ node.y = node.depth * ky; ++ }); + } +- if (left && right) { +- red = next.C; +- next.C = node.C; +- next.L = left; +- left.U = next; +- if (next !== right) { +- parent = next.U; +- next.U = node.U; +- node = next.R; +- parent.L = node; +- next.R = right; +- right.U = next; +- } else { +- next.U = parent; +- parent = next; +- node = next.R; ++ return nodes; ++ } ++ function wrapTree(root0) { ++ var root1 = { ++ A: null, ++ children: [ root0 ] ++ }, queue = [ root1 ], node1; ++ while ((node1 = queue.pop()) != null) { ++ for (var children = node1.children, child, i = 0, n = children.length; i < n; ++i) { ++ queue.push((children[i] = child = { ++ _: children[i], ++ parent: node1, ++ children: (child = children[i].children) && child.slice() || [], ++ A: null, ++ a: null, ++ z: 0, ++ m: 0, ++ c: 0, ++ s: 0, ++ t: null, ++ i: i ++ }).a = child); + } +- } else { +- red = node.C; +- node = next; +- } +- if (node) node.U = parent; +- if (red) return; +- if (node && node.C) { +- node.C = false; +- return; + } +- do { +- if (node === this._) break; +- if (node === parent.L) { +- sibling = parent.R; +- if (sibling.C) { +- sibling.C = false; +- parent.C = true; +- d3_geom_voronoiRedBlackRotateLeft(this, parent); +- sibling = parent.R; +- } +- if (sibling.L && sibling.L.C || sibling.R && sibling.R.C) { +- if (!sibling.R || !sibling.R.C) { +- sibling.L.C = false; +- sibling.C = true; +- d3_geom_voronoiRedBlackRotateRight(this, sibling); +- sibling = parent.R; +- } +- sibling.C = parent.C; +- parent.C = sibling.R.C = false; +- d3_geom_voronoiRedBlackRotateLeft(this, parent); +- node = this._; +- break; +- } ++ return root1.children[0]; ++ } ++ function firstWalk(v) { ++ var children = v.children, siblings = v.parent.children, w = v.i ? siblings[v.i - 1] : null; ++ if (children.length) { ++ d3_layout_treeShift(v); ++ var midpoint = (children[0].z + children[children.length - 1].z) / 2; ++ if (w) { ++ v.z = w.z + separation(v._, w._); ++ v.m = v.z - midpoint; + } else { +- sibling = parent.L; +- if (sibling.C) { +- sibling.C = false; +- parent.C = true; +- d3_geom_voronoiRedBlackRotateRight(this, parent); +- sibling = parent.L; +- } +- if (sibling.L && sibling.L.C || sibling.R && sibling.R.C) { +- if (!sibling.L || !sibling.L.C) { +- sibling.R.C = false; +- sibling.C = true; +- d3_geom_voronoiRedBlackRotateLeft(this, sibling); +- sibling = parent.L; +- } +- sibling.C = parent.C; +- parent.C = sibling.L.C = false; +- d3_geom_voronoiRedBlackRotateRight(this, parent); +- node = this._; +- break; ++ v.z = midpoint; ++ } ++ } else if (w) { ++ v.z = w.z + separation(v._, w._); ++ } ++ v.parent.A = apportion(v, w, v.parent.A || siblings[0]); ++ } ++ function secondWalk(v) { ++ v._.x = v.z + v.parent.m; ++ v.m += v.parent.m; ++ } ++ function apportion(v, w, ancestor) { ++ if (w) { ++ var vip = v, vop = v, vim = w, vom = vip.parent.children[0], sip = vip.m, sop = vop.m, sim = vim.m, som = vom.m, shift; ++ while (vim = d3_layout_treeRight(vim), vip = d3_layout_treeLeft(vip), vim && vip) { ++ vom = d3_layout_treeLeft(vom); ++ vop = d3_layout_treeRight(vop); ++ vop.a = v; ++ shift = vim.z + sim - vip.z - sip + separation(vim._, vip._); ++ if (shift > 0) { ++ d3_layout_treeMove(d3_layout_treeAncestor(vim, v, ancestor), v, shift); ++ sip += shift; ++ sop += shift; + } ++ sim += vim.m; ++ sip += vip.m; ++ som += vom.m; ++ sop += vop.m; + } +- sibling.C = true; +- node = parent; +- parent = parent.U; +- } while (!node.C); +- if (node) node.C = false; ++ if (vim && !d3_layout_treeRight(vop)) { ++ vop.t = vim; ++ vop.m += sim - sop; ++ } ++ if (vip && !d3_layout_treeLeft(vom)) { ++ vom.t = vip; ++ vom.m += sip - som; ++ ancestor = v; ++ } ++ } ++ return ancestor; + } +- }; +- function d3_geom_voronoiRedBlackRotateLeft(tree, node) { +- var p = node, q = node.R, parent = p.U; +- if (parent) { +- if (parent.L === p) parent.L = q; else parent.R = q; +- } else { +- tree._ = q; ++ function sizeNode(node) { ++ node.x *= size[0]; ++ node.y = node.depth * size[1]; + } +- q.U = parent; +- p.U = q; +- p.R = q.L; +- if (p.R) p.R.U = p; +- q.L = p; ++ tree.separation = function(x) { ++ if (!arguments.length) return separation; ++ separation = x; ++ return tree; ++ }; ++ tree.size = function(x) { ++ if (!arguments.length) return nodeSize ? null : size; ++ nodeSize = (size = x) == null ? sizeNode : null; ++ return tree; ++ }; ++ tree.nodeSize = function(x) { ++ if (!arguments.length) return nodeSize ? size : null; ++ nodeSize = (size = x) == null ? null : sizeNode; ++ return tree; ++ }; ++ return d3_layout_hierarchyRebind(tree, hierarchy); ++ }; ++ function d3_layout_treeSeparation(a, b) { ++ return a.parent == b.parent ? 1 : 2; + } +- function d3_geom_voronoiRedBlackRotateRight(tree, node) { +- var p = node, q = node.L, parent = p.U; +- if (parent) { +- if (parent.L === p) parent.L = q; else parent.R = q; +- } else { +- tree._ = q; +- } +- q.U = parent; +- p.U = q; +- p.L = q.R; +- if (p.L) p.L.U = p; +- q.R = p; ++ function d3_layout_treeLeft(v) { ++ var children = v.children; ++ return children.length ? children[0] : v.t; + } +- function d3_geom_voronoiRedBlackFirst(node) { +- while (node.L) node = node.L; +- return node; ++ function d3_layout_treeRight(v) { ++ var children = v.children, n; ++ return (n = children.length) ? children[n - 1] : v.t; + } +- function d3_geom_voronoi(sites, bbox) { +- var site = sites.sort(d3_geom_voronoiVertexOrder).pop(), x0, y0, circle; +- d3_geom_voronoiEdges = []; +- d3_geom_voronoiCells = new Array(sites.length); +- d3_geom_voronoiBeaches = new d3_geom_voronoiRedBlackTree(); +- d3_geom_voronoiCircles = new d3_geom_voronoiRedBlackTree(); +- while (true) { +- circle = d3_geom_voronoiFirstCircle; +- if (site && (!circle || site.y < circle.y || site.y === circle.y && site.x < circle.x)) { +- if (site.x !== x0 || site.y !== y0) { +- d3_geom_voronoiCells[site.i] = new d3_geom_voronoiCell(site); +- d3_geom_voronoiAddBeach(site); +- x0 = site.x, y0 = site.y; +- } +- site = sites.pop(); +- } else if (circle) { +- d3_geom_voronoiRemoveBeach(circle.arc); +- } else { +- break; +- } ++ function d3_layout_treeMove(wm, wp, shift) { ++ var change = shift / (wp.i - wm.i); ++ wp.c -= change; ++ wp.s += shift; ++ wm.c += change; ++ wp.z += shift; ++ wp.m += shift; ++ } ++ function d3_layout_treeShift(v) { ++ var shift = 0, change = 0, children = v.children, i = children.length, w; ++ while (--i >= 0) { ++ w = children[i]; ++ w.z += shift; ++ w.m += shift; ++ shift += w.s + (change += w.c); + } +- if (bbox) d3_geom_voronoiClipEdges(bbox), d3_geom_voronoiCloseCells(bbox); +- var diagram = { +- cells: d3_geom_voronoiCells, +- edges: d3_geom_voronoiEdges +- }; +- d3_geom_voronoiBeaches = d3_geom_voronoiCircles = d3_geom_voronoiEdges = d3_geom_voronoiCells = null; +- return diagram; + } +- function d3_geom_voronoiVertexOrder(a, b) { +- return b.y - a.y || b.x - a.x; ++ function d3_layout_treeAncestor(vim, v, ancestor) { ++ return vim.a.parent === v.parent ? vim.a : ancestor; + } +- d3.geom.voronoi = function(points) { +- var x = d3_geom_pointX, y = d3_geom_pointY, fx = x, fy = y, clipExtent = d3_geom_voronoiClipExtent; +- if (points) return voronoi(points); +- function voronoi(data) { +- var polygons = new Array(data.length), x0 = clipExtent[0][0], y0 = clipExtent[0][1], x1 = clipExtent[1][0], y1 = clipExtent[1][1]; +- d3_geom_voronoi(sites(data), clipExtent).cells.forEach(function(cell, i) { +- var edges = cell.edges, site = cell.site, polygon = polygons[i] = edges.length ? edges.map(function(e) { +- var s = e.start(); +- return [ s.x, s.y ]; +- }) : site.x >= x0 && site.x <= x1 && site.y >= y0 && site.y <= y1 ? [ [ x0, y1 ], [ x1, y1 ], [ x1, y0 ], [ x0, y0 ] ] : []; +- polygon.point = data[i]; ++ d3.layout.cluster = function() { ++ var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ], nodeSize = false; ++ function cluster(d, i) { ++ var nodes = hierarchy.call(this, d, i), root = nodes[0], previousNode, x = 0; ++ d3_layout_hierarchyVisitAfter(root, function(node) { ++ var children = node.children; ++ if (children && children.length) { ++ node.x = d3_layout_clusterX(children); ++ node.y = d3_layout_clusterY(children); ++ } else { ++ node.x = previousNode ? x += separation(node, previousNode) : 0; ++ node.y = 0; ++ previousNode = node; ++ } + }); +- return polygons; +- } +- function sites(data) { +- return data.map(function(d, i) { +- return { +- x: Math.round(fx(d, i) / ε) * ε, +- y: Math.round(fy(d, i) / ε) * ε, +- i: i +- }; ++ var left = d3_layout_clusterLeft(root), right = d3_layout_clusterRight(root), x0 = left.x - separation(left, right) / 2, x1 = right.x + separation(right, left) / 2; ++ d3_layout_hierarchyVisitAfter(root, nodeSize ? function(node) { ++ node.x = (node.x - root.x) * size[0]; ++ node.y = (root.y - node.y) * size[1]; ++ } : function(node) { ++ node.x = (node.x - x0) / (x1 - x0) * size[0]; ++ node.y = (1 - (root.y ? node.y / root.y : 1)) * size[1]; + }); ++ return nodes; + } +- voronoi.links = function(data) { +- return d3_geom_voronoi(sites(data)).edges.filter(function(edge) { +- return edge.l && edge.r; +- }).map(function(edge) { +- return { +- source: data[edge.l.i], +- target: data[edge.r.i] +- }; +- }); +- }; +- voronoi.triangles = function(data) { +- var triangles = []; +- d3_geom_voronoi(sites(data)).cells.forEach(function(cell, i) { +- var site = cell.site, edges = cell.edges.sort(d3_geom_voronoiHalfEdgeOrder), j = -1, m = edges.length, e0, s0, e1 = edges[m - 1].edge, s1 = e1.l === site ? e1.r : e1.l; +- while (++j < m) { +- e0 = e1; +- s0 = s1; +- e1 = edges[j].edge; +- s1 = e1.l === site ? e1.r : e1.l; +- if (i < s0.i && i < s1.i && d3_geom_voronoiTriangleArea(site, s0, s1) < 0) { +- triangles.push([ data[i], data[s0.i], data[s1.i] ]); +- } +- } +- }); +- return triangles; +- }; +- voronoi.x = function(_) { +- return arguments.length ? (fx = d3_functor(x = _), voronoi) : x; +- }; +- voronoi.y = function(_) { +- return arguments.length ? (fy = d3_functor(y = _), voronoi) : y; ++ cluster.separation = function(x) { ++ if (!arguments.length) return separation; ++ separation = x; ++ return cluster; + }; +- voronoi.clipExtent = function(_) { +- if (!arguments.length) return clipExtent === d3_geom_voronoiClipExtent ? null : clipExtent; +- clipExtent = _ == null ? d3_geom_voronoiClipExtent : _; +- return voronoi; ++ cluster.size = function(x) { ++ if (!arguments.length) return nodeSize ? null : size; ++ nodeSize = (size = x) == null; ++ return cluster; + }; +- voronoi.size = function(_) { +- if (!arguments.length) return clipExtent === d3_geom_voronoiClipExtent ? null : clipExtent && clipExtent[1]; +- return voronoi.clipExtent(_ && [ [ 0, 0 ], _ ]); ++ cluster.nodeSize = function(x) { ++ if (!arguments.length) return nodeSize ? size : null; ++ nodeSize = (size = x) != null; ++ return cluster; + }; +- return voronoi; ++ return d3_layout_hierarchyRebind(cluster, hierarchy); + }; +- var d3_geom_voronoiClipExtent = [ [ -1e6, -1e6 ], [ 1e6, 1e6 ] ]; +- function d3_geom_voronoiTriangleArea(a, b, c) { +- return (a.x - c.x) * (b.y - a.y) - (a.x - b.x) * (c.y - a.y); ++ function d3_layout_clusterY(children) { ++ return 1 + d3.max(children, function(child) { ++ return child.y; ++ }); + } +- d3.geom.delaunay = function(vertices) { +- return d3.geom.voronoi().triangles(vertices); +- }; +- d3.geom.quadtree = function(points, x1, y1, x2, y2) { +- var x = d3_geom_pointX, y = d3_geom_pointY, compat; +- if (compat = arguments.length) { +- x = d3_geom_quadtreeCompatX; +- y = d3_geom_quadtreeCompatY; +- if (compat === 3) { +- y2 = y1; +- x2 = x1; +- y1 = x1 = 0; ++ function d3_layout_clusterX(children) { ++ return children.reduce(function(x, child) { ++ return x + child.x; ++ }, 0) / children.length; ++ } ++ function d3_layout_clusterLeft(node) { ++ var children = node.children; ++ return children && children.length ? d3_layout_clusterLeft(children[0]) : node; ++ } ++ function d3_layout_clusterRight(node) { ++ var children = node.children, n; ++ return children && (n = children.length) ? d3_layout_clusterRight(children[n - 1]) : node; ++ } ++ d3.layout.treemap = function() { ++ var hierarchy = d3.layout.hierarchy(), round = Math.round, size = [ 1, 1 ], padding = null, pad = d3_layout_treemapPadNull, sticky = false, stickies, mode = "squarify", ratio = .5 * (1 + Math.sqrt(5)); ++ function scale(children, k) { ++ var i = -1, n = children.length, child, area; ++ while (++i < n) { ++ area = (child = children[i]).value * (k < 0 ? 0 : k); ++ child.area = isNaN(area) || area <= 0 ? 0 : area; + } +- return quadtree(points); + } +- function quadtree(data) { +- var d, fx = d3_functor(x), fy = d3_functor(y), xs, ys, i, n, x1_, y1_, x2_, y2_; +- if (x1 != null) { +- x1_ = x1, y1_ = y1, x2_ = x2, y2_ = y2; +- } else { +- x2_ = y2_ = -(x1_ = y1_ = Infinity); +- xs = [], ys = []; +- n = data.length; +- if (compat) for (i = 0; i < n; ++i) { +- d = data[i]; +- if (d.x < x1_) x1_ = d.x; +- if (d.y < y1_) y1_ = d.y; +- if (d.x > x2_) x2_ = d.x; +- if (d.y > y2_) y2_ = d.y; +- xs.push(d.x); +- ys.push(d.y); +- } else for (i = 0; i < n; ++i) { +- var x_ = +fx(d = data[i], i), y_ = +fy(d, i); +- if (x_ < x1_) x1_ = x_; +- if (y_ < y1_) y1_ = y_; +- if (x_ > x2_) x2_ = x_; +- if (y_ > y2_) y2_ = y_; +- xs.push(x_); +- ys.push(y_); ++ function squarify(node) { ++ var children = node.children; ++ if (children && children.length) { ++ var rect = pad(node), row = [], remaining = children.slice(), child, best = Infinity, score, u = mode === "slice" ? rect.dx : mode === "dice" ? rect.dy : mode === "slice-dice" ? node.depth & 1 ? rect.dy : rect.dx : Math.min(rect.dx, rect.dy), n; ++ scale(remaining, rect.dx * rect.dy / node.value); ++ row.area = 0; ++ while ((n = remaining.length) > 0) { ++ row.push(child = remaining[n - 1]); ++ row.area += child.area; ++ if (mode !== "squarify" || (score = worst(row, u)) <= best) { ++ remaining.pop(); ++ best = score; ++ } else { ++ row.area -= row.pop().area; ++ position(row, u, rect, false); ++ u = Math.min(rect.dx, rect.dy); ++ row.length = row.area = 0; ++ best = Infinity; ++ } ++ } ++ if (row.length) { ++ position(row, u, rect, true); ++ row.length = row.area = 0; + } ++ children.forEach(squarify); + } +- var dx = x2_ - x1_, dy = y2_ - y1_; +- if (dx > dy) y2_ = y1_ + dx; else x2_ = x1_ + dy; +- function insert(n, d, x, y, x1, y1, x2, y2) { +- if (isNaN(x) || isNaN(y)) return; +- if (n.leaf) { +- var nx = n.x, ny = n.y; +- if (nx != null) { +- if (abs(nx - x) + abs(ny - y) < .01) { +- insertChild(n, d, x, y, x1, y1, x2, y2); +- } else { +- var nPoint = n.point; +- n.x = n.y = n.point = null; +- insertChild(n, nPoint, nx, ny, x1, y1, x2, y2); +- insertChild(n, d, x, y, x1, y1, x2, y2); +- } +- } else { +- n.x = x, n.y = y, n.point = d; ++ } ++ function stickify(node) { ++ var children = node.children; ++ if (children && children.length) { ++ var rect = pad(node), remaining = children.slice(), child, row = []; ++ scale(remaining, rect.dx * rect.dy / node.value); ++ row.area = 0; ++ while (child = remaining.pop()) { ++ row.push(child); ++ row.area += child.area; ++ if (child.z != null) { ++ position(row, child.z ? rect.dx : rect.dy, rect, !remaining.length); ++ row.length = row.area = 0; + } +- } else { +- insertChild(n, d, x, y, x1, y1, x2, y2); + } ++ children.forEach(stickify); + } +- function insertChild(n, d, x, y, x1, y1, x2, y2) { +- var xm = (x1 + x2) * .5, ym = (y1 + y2) * .5, right = x >= xm, below = y >= ym, i = below << 1 | right; +- n.leaf = false; +- n = n.nodes[i] || (n.nodes[i] = d3_geom_quadtreeNode()); +- if (right) x1 = xm; else x2 = xm; +- if (below) y1 = ym; else y2 = ym; +- insert(n, d, x, y, x1, y1, x2, y2); ++ } ++ function worst(row, u) { ++ var s = row.area, r, rmax = 0, rmin = Infinity, i = -1, n = row.length; ++ while (++i < n) { ++ if (!(r = row[i].area)) continue; ++ if (r < rmin) rmin = r; ++ if (r > rmax) rmax = r; + } +- var root = d3_geom_quadtreeNode(); +- root.add = function(d) { +- insert(root, d, +fx(d, ++i), +fy(d, i), x1_, y1_, x2_, y2_); +- }; +- root.visit = function(f) { +- d3_geom_quadtreeVisit(f, root, x1_, y1_, x2_, y2_); +- }; +- root.find = function(point) { +- return d3_geom_quadtreeFind(root, point[0], point[1], x1_, y1_, x2_, y2_); +- }; +- i = -1; +- if (x1 == null) { ++ s *= s; ++ u *= u; ++ return s ? Math.max(u * rmax * ratio / s, s / (u * rmin * ratio)) : Infinity; ++ } ++ function position(row, u, rect, flush) { ++ var i = -1, n = row.length, x = rect.x, y = rect.y, v = u ? round(row.area / u) : 0, o; ++ if (u == rect.dx) { ++ if (flush || v > rect.dy) v = rect.dy; + while (++i < n) { +- insert(root, data[i], xs[i], ys[i], x1_, y1_, x2_, y2_); ++ o = row[i]; ++ o.x = x; ++ o.y = y; ++ o.dy = v; ++ x += o.dx = Math.min(rect.x + rect.dx - x, v ? round(o.area / v) : 0); + } +- --i; +- } else data.forEach(root.add); +- xs = ys = data = d = null; +- return root; ++ o.z = true; ++ o.dx += rect.x + rect.dx - x; ++ rect.y += v; ++ rect.dy -= v; ++ } else { ++ if (flush || v > rect.dx) v = rect.dx; ++ while (++i < n) { ++ o = row[i]; ++ o.x = x; ++ o.y = y; ++ o.dx = v; ++ y += o.dy = Math.min(rect.y + rect.dy - y, v ? round(o.area / v) : 0); ++ } ++ o.z = false; ++ o.dy += rect.y + rect.dy - y; ++ rect.x += v; ++ rect.dx -= v; ++ } + } +- quadtree.x = function(_) { +- return arguments.length ? (x = _, quadtree) : x; ++ function treemap(d) { ++ var nodes = stickies || hierarchy(d), root = nodes[0]; ++ root.x = root.y = 0; ++ if (root.value) root.dx = size[0], root.dy = size[1]; else root.dx = root.dy = 0; ++ if (stickies) hierarchy.revalue(root); ++ scale([ root ], root.dx * root.dy / root.value); ++ (stickies ? stickify : squarify)(root); ++ if (sticky) stickies = nodes; ++ return nodes; ++ } ++ treemap.size = function(x) { ++ if (!arguments.length) return size; ++ size = x; ++ return treemap; ++ }; ++ treemap.padding = function(x) { ++ if (!arguments.length) return padding; ++ function padFunction(node) { ++ var p = x.call(treemap, node, node.depth); ++ return p == null ? d3_layout_treemapPadNull(node) : d3_layout_treemapPad(node, typeof p === "number" ? [ p, p, p, p ] : p); ++ } ++ function padConstant(node) { ++ return d3_layout_treemapPad(node, x); ++ } ++ var type; ++ pad = (padding = x) == null ? d3_layout_treemapPadNull : (type = typeof x) === "function" ? padFunction : type === "number" ? (x = [ x, x, x, x ], ++ padConstant) : padConstant; ++ return treemap; + }; +- quadtree.y = function(_) { +- return arguments.length ? (y = _, quadtree) : y; ++ treemap.round = function(x) { ++ if (!arguments.length) return round != Number; ++ round = x ? Math.round : Number; ++ return treemap; + }; +- quadtree.extent = function(_) { +- if (!arguments.length) return x1 == null ? null : [ [ x1, y1 ], [ x2, y2 ] ]; +- if (_ == null) x1 = y1 = x2 = y2 = null; else x1 = +_[0][0], y1 = +_[0][1], x2 = +_[1][0], +- y2 = +_[1][1]; +- return quadtree; ++ treemap.sticky = function(x) { ++ if (!arguments.length) return sticky; ++ sticky = x; ++ stickies = null; ++ return treemap; + }; +- quadtree.size = function(_) { +- if (!arguments.length) return x1 == null ? null : [ x2 - x1, y2 - y1 ]; +- if (_ == null) x1 = y1 = x2 = y2 = null; else x1 = y1 = 0, x2 = +_[0], y2 = +_[1]; +- return quadtree; ++ treemap.ratio = function(x) { ++ if (!arguments.length) return ratio; ++ ratio = x; ++ return treemap; + }; +- return quadtree; ++ treemap.mode = function(x) { ++ if (!arguments.length) return mode; ++ mode = x + ""; ++ return treemap; ++ }; ++ return d3_layout_hierarchyRebind(treemap, hierarchy); + }; +- function d3_geom_quadtreeCompatX(d) { +- return d.x; +- } +- function d3_geom_quadtreeCompatY(d) { +- return d.y; ++ function d3_layout_treemapPadNull(node) { ++ return { ++ x: node.x, ++ y: node.y, ++ dx: node.dx, ++ dy: node.dy ++ }; + } +- function d3_geom_quadtreeNode() { ++ function d3_layout_treemapPad(node, padding) { ++ var x = node.x + padding[3], y = node.y + padding[0], dx = node.dx - padding[1] - padding[3], dy = node.dy - padding[0] - padding[2]; ++ if (dx < 0) { ++ x += dx / 2; ++ dx = 0; ++ } ++ if (dy < 0) { ++ y += dy / 2; ++ dy = 0; ++ } + return { +- leaf: true, +- nodes: [], +- point: null, +- x: null, +- y: null ++ x: x, ++ y: y, ++ dx: dx, ++ dy: dy + }; + } +- function d3_geom_quadtreeVisit(f, node, x1, y1, x2, y2) { +- if (!f(node, x1, y1, x2, y2)) { +- var sx = (x1 + x2) * .5, sy = (y1 + y2) * .5, children = node.nodes; +- if (children[0]) d3_geom_quadtreeVisit(f, children[0], x1, y1, sx, sy); +- if (children[1]) d3_geom_quadtreeVisit(f, children[1], sx, y1, x2, sy); +- if (children[2]) d3_geom_quadtreeVisit(f, children[2], x1, sy, sx, y2); +- if (children[3]) d3_geom_quadtreeVisit(f, children[3], sx, sy, x2, y2); ++ d3.random = { ++ normal: function(µ, σ) { ++ var n = arguments.length; ++ if (n < 2) σ = 1; ++ if (n < 1) µ = 0; ++ return function() { ++ var x, y, r; ++ do { ++ x = Math.random() * 2 - 1; ++ y = Math.random() * 2 - 1; ++ r = x * x + y * y; ++ } while (!r || r > 1); ++ return µ + σ * x * Math.sqrt(-2 * Math.log(r) / r); ++ }; ++ }, ++ logNormal: function() { ++ var random = d3.random.normal.apply(d3, arguments); ++ return function() { ++ return Math.exp(random()); ++ }; ++ }, ++ bates: function(m) { ++ var random = d3.random.irwinHall(m); ++ return function() { ++ return random() / m; ++ }; ++ }, ++ irwinHall: function(m) { ++ return function() { ++ for (var s = 0, j = 0; j < m; j++) s += Math.random(); ++ return s; ++ }; + } ++ }; ++ d3.scale = {}; ++ function d3_scaleExtent(domain) { ++ var start = domain[0], stop = domain[domain.length - 1]; ++ return start < stop ? [ start, stop ] : [ stop, start ]; + } +- function d3_geom_quadtreeFind(root, x, y, x0, y0, x3, y3) { +- var minDistance2 = Infinity, closestPoint; +- (function find(node, x1, y1, x2, y2) { +- if (x1 > x3 || y1 > y3 || x2 < x0 || y2 < y0) return; +- if (point = node.point) { +- var point, dx = x - node.x, dy = y - node.y, distance2 = dx * dx + dy * dy; +- if (distance2 < minDistance2) { +- var distance = Math.sqrt(minDistance2 = distance2); +- x0 = x - distance, y0 = y - distance; +- x3 = x + distance, y3 = y + distance; +- closestPoint = point; +- } +- } +- var children = node.nodes, xm = (x1 + x2) * .5, ym = (y1 + y2) * .5, right = x >= xm, below = y >= ym; +- for (var i = below << 1 | right, j = i + 4; i < j; ++i) { +- if (node = children[i & 3]) switch (i & 3) { +- case 0: +- find(node, x1, y1, xm, ym); +- break; +- +- case 1: +- find(node, xm, y1, x2, ym); +- break; +- +- case 2: +- find(node, x1, ym, xm, y2); +- break; +- +- case 3: +- find(node, xm, ym, x2, y2); +- break; +- } +- } +- })(root, x0, y0, x3, y3); +- return closestPoint; ++ function d3_scaleRange(scale) { ++ return scale.rangeExtent ? scale.rangeExtent() : d3_scaleExtent(scale.range()); + } +- d3.interpolateRgb = d3_interpolateRgb; +- function d3_interpolateRgb(a, b) { +- a = d3.rgb(a); +- b = d3.rgb(b); +- var ar = a.r, ag = a.g, ab = a.b, br = b.r - ar, bg = b.g - ag, bb = b.b - ab; +- return function(t) { +- return "#" + d3_rgb_hex(Math.round(ar + br * t)) + d3_rgb_hex(Math.round(ag + bg * t)) + d3_rgb_hex(Math.round(ab + bb * t)); ++ function d3_scale_bilinear(domain, range, uninterpolate, interpolate) { ++ var u = uninterpolate(domain[0], domain[1]), i = interpolate(range[0], range[1]); ++ return function(x) { ++ return i(u(x)); + }; + } +- d3.interpolateObject = d3_interpolateObject; +- function d3_interpolateObject(a, b) { +- var i = {}, c = {}, k; +- for (k in a) { +- if (k in b) { +- i[k] = d3_interpolate(a[k], b[k]); +- } else { +- c[k] = a[k]; +- } +- } +- for (k in b) { +- if (!(k in a)) { +- c[k] = b[k]; +- } ++ function d3_scale_nice(domain, nice) { ++ var i0 = 0, i1 = domain.length - 1, x0 = domain[i0], x1 = domain[i1], dx; ++ if (x1 < x0) { ++ dx = i0, i0 = i1, i1 = dx; ++ dx = x0, x0 = x1, x1 = dx; + } +- return function(t) { +- for (k in i) c[k] = i[k](t); +- return c; +- }; +- } +- d3.interpolateNumber = d3_interpolateNumber; +- function d3_interpolateNumber(a, b) { +- a = +a, b = +b; +- return function(t) { +- return a * (1 - t) + b * t; +- }; ++ domain[i0] = nice.floor(x0); ++ domain[i1] = nice.ceil(x1); ++ return domain; + } +- d3.interpolateString = d3_interpolateString; +- function d3_interpolateString(a, b) { +- var bi = d3_interpolate_numberA.lastIndex = d3_interpolate_numberB.lastIndex = 0, am, bm, bs, i = -1, s = [], q = []; +- a = a + "", b = b + ""; +- while ((am = d3_interpolate_numberA.exec(a)) && (bm = d3_interpolate_numberB.exec(b))) { +- if ((bs = bm.index) > bi) { +- bs = b.slice(bi, bs); +- if (s[i]) s[i] += bs; else s[++i] = bs; +- } +- if ((am = am[0]) === (bm = bm[0])) { +- if (s[i]) s[i] += bm; else s[++i] = bm; +- } else { +- s[++i] = null; +- q.push({ +- i: i, +- x: d3_interpolateNumber(am, bm) +- }); ++ function d3_scale_niceStep(step) { ++ return step ? { ++ floor: function(x) { ++ return Math.floor(x / step) * step; ++ }, ++ ceil: function(x) { ++ return Math.ceil(x / step) * step; + } +- bi = d3_interpolate_numberB.lastIndex; ++ } : d3_scale_niceIdentity; ++ } ++ var d3_scale_niceIdentity = { ++ floor: d3_identity, ++ ceil: d3_identity ++ }; ++ function d3_scale_polylinear(domain, range, uninterpolate, interpolate) { ++ var u = [], i = [], j = 0, k = Math.min(domain.length, range.length) - 1; ++ if (domain[k] < domain[0]) { ++ domain = domain.slice().reverse(); ++ range = range.slice().reverse(); + } +- if (bi < b.length) { +- bs = b.slice(bi); +- if (s[i]) s[i] += bs; else s[++i] = bs; ++ while (++j <= k) { ++ u.push(uninterpolate(domain[j - 1], domain[j])); ++ i.push(interpolate(range[j - 1], range[j])); + } +- return s.length < 2 ? q[0] ? (b = q[0].x, function(t) { +- return b(t) + ""; +- }) : function() { +- return b; +- } : (b = q.length, function(t) { +- for (var i = 0, o; i < b; ++i) s[(o = q[i]).i] = o.x(t); +- return s.join(""); +- }); +- } +- var d3_interpolate_numberA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, d3_interpolate_numberB = new RegExp(d3_interpolate_numberA.source, "g"); +- d3.interpolate = d3_interpolate; +- function d3_interpolate(a, b) { +- var i = d3.interpolators.length, f; +- while (--i >= 0 && !(f = d3.interpolators[i](a, b))) ; +- return f; +- } +- d3.interpolators = [ function(a, b) { +- var t = typeof b; +- return (t === "string" ? d3_rgb_names.has(b.toLowerCase()) || /^(#|rgb\(|hsl\()/i.test(b) ? d3_interpolateRgb : d3_interpolateString : b instanceof d3_color ? d3_interpolateRgb : Array.isArray(b) ? d3_interpolateArray : t === "object" && isNaN(b) ? d3_interpolateObject : d3_interpolateNumber)(a, b); +- } ]; +- d3.interpolateArray = d3_interpolateArray; +- function d3_interpolateArray(a, b) { +- var x = [], c = [], na = a.length, nb = b.length, n0 = Math.min(a.length, b.length), i; +- for (i = 0; i < n0; ++i) x.push(d3_interpolate(a[i], b[i])); +- for (;i < na; ++i) c[i] = a[i]; +- for (;i < nb; ++i) c[i] = b[i]; +- return function(t) { +- for (i = 0; i < n0; ++i) c[i] = x[i](t); +- return c; ++ return function(x) { ++ var j = d3.bisect(domain, x, 1, k) - 1; ++ return i[j](u[j](x)); + }; + } +- var d3_ease_default = function() { +- return d3_identity; ++ d3.scale.linear = function() { ++ return d3_scale_linear([ 0, 1 ], [ 0, 1 ], d3_interpolate, false); + }; +- var d3_ease = d3.map({ +- linear: d3_ease_default, +- poly: d3_ease_poly, +- quad: function() { +- return d3_ease_quad; +- }, +- cubic: function() { +- return d3_ease_cubic; +- }, +- sin: function() { +- return d3_ease_sin; +- }, +- exp: function() { +- return d3_ease_exp; +- }, +- circle: function() { +- return d3_ease_circle; +- }, +- elastic: d3_ease_elastic, +- back: d3_ease_back, +- bounce: function() { +- return d3_ease_bounce; ++ function d3_scale_linear(domain, range, interpolate, clamp) { ++ var output, input; ++ function rescale() { ++ var linear = Math.min(domain.length, range.length) > 2 ? d3_scale_polylinear : d3_scale_bilinear, uninterpolate = clamp ? d3_uninterpolateClamp : d3_uninterpolateNumber; ++ output = linear(domain, range, uninterpolate, interpolate); ++ input = linear(range, domain, uninterpolate, d3_interpolate); ++ return scale; + } +- }); +- var d3_ease_mode = d3.map({ +- "in": d3_identity, +- out: d3_ease_reverse, +- "in-out": d3_ease_reflect, +- "out-in": function(f) { +- return d3_ease_reflect(d3_ease_reverse(f)); ++ function scale(x) { ++ return output(x); + } +- }); +- d3.ease = function(name) { +- var i = name.indexOf("-"), t = i >= 0 ? name.slice(0, i) : name, m = i >= 0 ? name.slice(i + 1) : "in"; +- t = d3_ease.get(t) || d3_ease_default; +- m = d3_ease_mode.get(m) || d3_identity; +- return d3_ease_clamp(m(t.apply(null, d3_arraySlice.call(arguments, 1)))); +- }; +- function d3_ease_clamp(f) { +- return function(t) { +- return t <= 0 ? 0 : t >= 1 ? 1 : f(t); ++ scale.invert = function(y) { ++ return input(y); + }; +- } +- function d3_ease_reverse(f) { +- return function(t) { +- return 1 - f(1 - t); ++ scale.domain = function(x) { ++ if (!arguments.length) return domain; ++ domain = x.map(Number); ++ return rescale(); + }; +- } +- function d3_ease_reflect(f) { +- return function(t) { +- return .5 * (t < .5 ? f(2 * t) : 2 - f(2 - 2 * t)); ++ scale.range = function(x) { ++ if (!arguments.length) return range; ++ range = x; ++ return rescale(); + }; +- } +- function d3_ease_quad(t) { +- return t * t; +- } +- function d3_ease_cubic(t) { +- return t * t * t; +- } +- function d3_ease_cubicInOut(t) { +- if (t <= 0) return 0; +- if (t >= 1) return 1; +- var t2 = t * t, t3 = t2 * t; +- return 4 * (t < .5 ? t3 : 3 * (t - t2) + t3 - .75); +- } +- function d3_ease_poly(e) { +- return function(t) { +- return Math.pow(t, e); ++ scale.rangeRound = function(x) { ++ return scale.range(x).interpolate(d3_interpolateRound); + }; +- } +- function d3_ease_sin(t) { +- return 1 - Math.cos(t * halfπ); +- } +- function d3_ease_exp(t) { +- return Math.pow(2, 10 * (t - 1)); +- } +- function d3_ease_circle(t) { +- return 1 - Math.sqrt(1 - t * t); +- } +- function d3_ease_elastic(a, p) { +- var s; +- if (arguments.length < 2) p = .45; +- if (arguments.length) s = p / τ * Math.asin(1 / a); else a = 1, s = p / 4; +- return function(t) { +- return 1 + a * Math.pow(2, -10 * t) * Math.sin((t - s) * τ / p); ++ scale.clamp = function(x) { ++ if (!arguments.length) return clamp; ++ clamp = x; ++ return rescale(); + }; +- } +- function d3_ease_back(s) { +- if (!s) s = 1.70158; +- return function(t) { +- return t * t * ((s + 1) * t - s); ++ scale.interpolate = function(x) { ++ if (!arguments.length) return interpolate; ++ interpolate = x; ++ return rescale(); + }; +- } +- function d3_ease_bounce(t) { +- return t < 1 / 2.75 ? 7.5625 * t * t : t < 2 / 2.75 ? 7.5625 * (t -= 1.5 / 2.75) * t + .75 : t < 2.5 / 2.75 ? 7.5625 * (t -= 2.25 / 2.75) * t + .9375 : 7.5625 * (t -= 2.625 / 2.75) * t + .984375; +- } +- d3.interpolateHcl = d3_interpolateHcl; +- function d3_interpolateHcl(a, b) { +- a = d3.hcl(a); +- b = d3.hcl(b); +- var ah = a.h, ac = a.c, al = a.l, bh = b.h - ah, bc = b.c - ac, bl = b.l - al; +- if (isNaN(bc)) bc = 0, ac = isNaN(ac) ? b.c : ac; +- if (isNaN(bh)) bh = 0, ah = isNaN(ah) ? b.h : ah; else if (bh > 180) bh -= 360; else if (bh < -180) bh += 360; +- return function(t) { +- return d3_hcl_lab(ah + bh * t, ac + bc * t, al + bl * t) + ""; ++ scale.ticks = function(m) { ++ return d3_scale_linearTicks(domain, m); + }; +- } +- d3.interpolateHsl = d3_interpolateHsl; +- function d3_interpolateHsl(a, b) { +- a = d3.hsl(a); +- b = d3.hsl(b); +- var ah = a.h, as = a.s, al = a.l, bh = b.h - ah, bs = b.s - as, bl = b.l - al; +- if (isNaN(bs)) bs = 0, as = isNaN(as) ? b.s : as; +- if (isNaN(bh)) bh = 0, ah = isNaN(ah) ? b.h : ah; else if (bh > 180) bh -= 360; else if (bh < -180) bh += 360; +- return function(t) { +- return d3_hsl_rgb(ah + bh * t, as + bs * t, al + bl * t) + ""; ++ scale.tickFormat = function(m, format) { ++ return d3_scale_linearTickFormat(domain, m, format); + }; +- } +- d3.interpolateLab = d3_interpolateLab; +- function d3_interpolateLab(a, b) { +- a = d3.lab(a); +- b = d3.lab(b); +- var al = a.l, aa = a.a, ab = a.b, bl = b.l - al, ba = b.a - aa, bb = b.b - ab; +- return function(t) { +- return d3_lab_rgb(al + bl * t, aa + ba * t, ab + bb * t) + ""; ++ scale.nice = function(m) { ++ d3_scale_linearNice(domain, m); ++ return rescale(); + }; +- } +- d3.interpolateRound = d3_interpolateRound; +- function d3_interpolateRound(a, b) { +- b -= a; +- return function(t) { +- return Math.round(a + b * t); ++ scale.copy = function() { ++ return d3_scale_linear(domain, range, interpolate, clamp); + }; ++ return rescale(); + } +- d3.transform = function(string) { +- var g = d3_document.createElementNS(d3.ns.prefix.svg, "g"); +- return (d3.transform = function(string) { +- if (string != null) { +- g.setAttribute("transform", string); +- var t = g.transform.baseVal.consolidate(); +- } +- return new d3_transform(t ? t.matrix : d3_transformIdentity); +- })(string); +- }; +- function d3_transform(m) { +- var r0 = [ m.a, m.b ], r1 = [ m.c, m.d ], kx = d3_transformNormalize(r0), kz = d3_transformDot(r0, r1), ky = d3_transformNormalize(d3_transformCombine(r1, r0, -kz)) || 0; +- if (r0[0] * r1[1] < r1[0] * r0[1]) { +- r0[0] *= -1; +- r0[1] *= -1; +- kx *= -1; +- kz *= -1; +- } +- this.rotate = (kx ? Math.atan2(r0[1], r0[0]) : Math.atan2(-r1[0], r1[1])) * d3_degrees; +- this.translate = [ m.e, m.f ]; +- this.scale = [ kx, ky ]; +- this.skew = ky ? Math.atan2(kz, ky) * d3_degrees : 0; ++ function d3_scale_linearRebind(scale, linear) { ++ return d3.rebind(scale, linear, "range", "rangeRound", "interpolate", "clamp"); + } +- d3_transform.prototype.toString = function() { +- return "translate(" + this.translate + ")rotate(" + this.rotate + ")skewX(" + this.skew + ")scale(" + this.scale + ")"; +- }; +- function d3_transformDot(a, b) { +- return a[0] * b[0] + a[1] * b[1]; ++ function d3_scale_linearNice(domain, m) { ++ d3_scale_nice(domain, d3_scale_niceStep(d3_scale_linearTickRange(domain, m)[2])); ++ d3_scale_nice(domain, d3_scale_niceStep(d3_scale_linearTickRange(domain, m)[2])); ++ return domain; + } +- function d3_transformNormalize(a) { +- var k = Math.sqrt(d3_transformDot(a, a)); +- if (k) { +- a[0] /= k; +- a[1] /= k; +- } +- return k; ++ function d3_scale_linearTickRange(domain, m) { ++ if (m == null) m = 10; ++ var extent = d3_scaleExtent(domain), span = extent[1] - extent[0], step = Math.pow(10, Math.floor(Math.log(span / m) / Math.LN10)), err = m / span * step; ++ if (err <= .15) step *= 10; else if (err <= .35) step *= 5; else if (err <= .75) step *= 2; ++ extent[0] = Math.ceil(extent[0] / step) * step; ++ extent[1] = Math.floor(extent[1] / step) * step + step * .5; ++ extent[2] = step; ++ return extent; + } +- function d3_transformCombine(a, b, k) { +- a[0] += k * b[0]; +- a[1] += k * b[1]; +- return a; ++ function d3_scale_linearTicks(domain, m) { ++ return d3.range.apply(d3, d3_scale_linearTickRange(domain, m)); ++ } ++ function d3_scale_linearTickFormat(domain, m, format) { ++ var range = d3_scale_linearTickRange(domain, m); ++ if (format) { ++ var match = d3_format_re.exec(format); ++ match.shift(); ++ if (match[8] === "s") { ++ var prefix = d3.formatPrefix(Math.max(abs(range[0]), abs(range[1]))); ++ if (!match[7]) match[7] = "." + d3_scale_linearPrecision(prefix.scale(range[2])); ++ match[8] = "f"; ++ format = d3.format(match.join("")); ++ return function(d) { ++ return format(prefix.scale(d)) + prefix.symbol; ++ }; ++ } ++ if (!match[7]) match[7] = "." + d3_scale_linearFormatPrecision(match[8], range); ++ format = match.join(""); ++ } else { ++ format = ",." + d3_scale_linearPrecision(range[2]) + "f"; ++ } ++ return d3.format(format); + } +- var d3_transformIdentity = { +- a: 1, +- b: 0, +- c: 0, +- d: 1, +- e: 0, +- f: 0 ++ var d3_scale_linearFormatSignificant = { ++ s: 1, ++ g: 1, ++ p: 1, ++ r: 1, ++ e: 1 + }; +- d3.interpolateTransform = d3_interpolateTransform; +- function d3_interpolateTransformPop(s) { +- return s.length ? s.pop() + "," : ""; ++ function d3_scale_linearPrecision(value) { ++ return -Math.floor(Math.log(value) / Math.LN10 + .01); + } +- function d3_interpolateTranslate(ta, tb, s, q) { +- if (ta[0] !== tb[0] || ta[1] !== tb[1]) { +- var i = s.push("translate(", null, ",", null, ")"); +- q.push({ +- i: i - 4, +- x: d3_interpolateNumber(ta[0], tb[0]) +- }, { +- i: i - 2, +- x: d3_interpolateNumber(ta[1], tb[1]) +- }); +- } else if (tb[0] || tb[1]) { +- s.push("translate(" + tb + ")"); +- } ++ function d3_scale_linearFormatPrecision(type, range) { ++ var p = d3_scale_linearPrecision(range[2]); ++ return type in d3_scale_linearFormatSignificant ? Math.abs(p - d3_scale_linearPrecision(Math.max(abs(range[0]), abs(range[1])))) + +(type !== "e") : p - (type === "%") * 2; + } +- function d3_interpolateRotate(ra, rb, s, q) { +- if (ra !== rb) { +- if (ra - rb > 180) rb += 360; else if (rb - ra > 180) ra += 360; +- q.push({ +- i: s.push(d3_interpolateTransformPop(s) + "rotate(", null, ")") - 2, +- x: d3_interpolateNumber(ra, rb) +- }); +- } else if (rb) { +- s.push(d3_interpolateTransformPop(s) + "rotate(" + rb + ")"); ++ d3.scale.log = function() { ++ return d3_scale_log(d3.scale.linear().domain([ 0, 1 ]), 10, true, [ 1, 10 ]); ++ }; ++ function d3_scale_log(linear, base, positive, domain) { ++ function log(x) { ++ return (positive ? Math.log(x < 0 ? 0 : x) : -Math.log(x > 0 ? 0 : -x)) / Math.log(base); + } +- } +- function d3_interpolateSkew(wa, wb, s, q) { +- if (wa !== wb) { +- q.push({ +- i: s.push(d3_interpolateTransformPop(s) + "skewX(", null, ")") - 2, +- x: d3_interpolateNumber(wa, wb) +- }); +- } else if (wb) { +- s.push(d3_interpolateTransformPop(s) + "skewX(" + wb + ")"); ++ function pow(x) { ++ return positive ? Math.pow(base, x) : -Math.pow(base, -x); + } +- } +- function d3_interpolateScale(ka, kb, s, q) { +- if (ka[0] !== kb[0] || ka[1] !== kb[1]) { +- var i = s.push(d3_interpolateTransformPop(s) + "scale(", null, ",", null, ")"); +- q.push({ +- i: i - 4, +- x: d3_interpolateNumber(ka[0], kb[0]) +- }, { +- i: i - 2, +- x: d3_interpolateNumber(ka[1], kb[1]) +- }); +- } else if (kb[0] !== 1 || kb[1] !== 1) { +- s.push(d3_interpolateTransformPop(s) + "scale(" + kb + ")"); ++ function scale(x) { ++ return linear(log(x)); + } +- } +- function d3_interpolateTransform(a, b) { +- var s = [], q = []; +- a = d3.transform(a), b = d3.transform(b); +- d3_interpolateTranslate(a.translate, b.translate, s, q); +- d3_interpolateRotate(a.rotate, b.rotate, s, q); +- d3_interpolateSkew(a.skew, b.skew, s, q); +- d3_interpolateScale(a.scale, b.scale, s, q); +- a = b = null; +- return function(t) { +- var i = -1, n = q.length, o; +- while (++i < n) s[(o = q[i]).i] = o.x(t); +- return s.join(""); ++ scale.invert = function(x) { ++ return pow(linear.invert(x)); + }; +- } +- function d3_uninterpolateNumber(a, b) { +- b = (b -= a = +a) || 1 / b; +- return function(x) { +- return (x - a) / b; ++ scale.domain = function(x) { ++ if (!arguments.length) return domain; ++ positive = x[0] >= 0; ++ linear.domain((domain = x.map(Number)).map(log)); ++ return scale; + }; +- } +- function d3_uninterpolateClamp(a, b) { +- b = (b -= a = +a) || 1 / b; +- return function(x) { +- return Math.max(0, Math.min(1, (x - a) / b)); ++ scale.base = function(_) { ++ if (!arguments.length) return base; ++ base = +_; ++ linear.domain(domain.map(log)); ++ return scale; + }; +- } +- d3.layout = {}; +- d3.layout.bundle = function() { +- return function(links) { +- var paths = [], i = -1, n = links.length; +- while (++i < n) paths.push(d3_layout_bundlePath(links[i])); +- return paths; ++ scale.nice = function() { ++ var niced = d3_scale_nice(domain.map(log), positive ? Math : d3_scale_logNiceNegative); ++ linear.domain(niced); ++ domain = niced.map(pow); ++ return scale; + }; +- }; +- function d3_layout_bundlePath(link) { +- var start = link.source, end = link.target, lca = d3_layout_bundleLeastCommonAncestor(start, end), points = [ start ]; +- while (start !== lca) { +- start = start.parent; +- points.push(start); +- } +- var k = points.length; +- while (end !== lca) { +- points.splice(k, 0, end); +- end = end.parent; +- } +- return points; +- } +- function d3_layout_bundleAncestors(node) { +- var ancestors = [], parent = node.parent; +- while (parent != null) { +- ancestors.push(node); +- node = parent; +- parent = parent.parent; +- } +- ancestors.push(node); +- return ancestors; +- } +- function d3_layout_bundleLeastCommonAncestor(a, b) { +- if (a === b) return a; +- var aNodes = d3_layout_bundleAncestors(a), bNodes = d3_layout_bundleAncestors(b), aNode = aNodes.pop(), bNode = bNodes.pop(), sharedNode = null; +- while (aNode === bNode) { +- sharedNode = aNode; +- aNode = aNodes.pop(); +- bNode = bNodes.pop(); +- } +- return sharedNode; +- } +- d3.layout.chord = function() { +- var chord = {}, chords, groups, matrix, n, padding = 0, sortGroups, sortSubgroups, sortChords; +- function relayout() { +- var subgroups = {}, groupSums = [], groupIndex = d3.range(n), subgroupIndex = [], k, x, x0, i, j; +- chords = []; +- groups = []; +- k = 0, i = -1; +- while (++i < n) { +- x = 0, j = -1; +- while (++j < n) { +- x += matrix[i][j]; +- } +- groupSums.push(x); +- subgroupIndex.push(d3.range(n)); +- k += x; +- } +- if (sortGroups) { +- groupIndex.sort(function(a, b) { +- return sortGroups(groupSums[a], groupSums[b]); +- }); +- } +- if (sortSubgroups) { +- subgroupIndex.forEach(function(d, i) { +- d.sort(function(a, b) { +- return sortSubgroups(matrix[i][a], matrix[i][b]); +- }); +- }); +- } +- k = (τ - padding * n) / k; +- x = 0, i = -1; +- while (++i < n) { +- x0 = x, j = -1; +- while (++j < n) { +- var di = groupIndex[i], dj = subgroupIndex[di][j], v = matrix[di][dj], a0 = x, a1 = x += v * k; +- subgroups[di + "-" + dj] = { +- index: di, +- subindex: dj, +- startAngle: a0, +- endAngle: a1, +- value: v +- }; +- } +- groups[di] = { +- index: di, +- startAngle: x0, +- endAngle: x, +- value: groupSums[di] +- }; +- x += padding; +- } +- i = -1; +- while (++i < n) { +- j = i - 1; +- while (++j < n) { +- var source = subgroups[i + "-" + j], target = subgroups[j + "-" + i]; +- if (source.value || target.value) { +- chords.push(source.value < target.value ? { +- source: target, +- target: source +- } : { +- source: source, +- target: target +- }); +- } ++ scale.ticks = function() { ++ var extent = d3_scaleExtent(domain), ticks = [], u = extent[0], v = extent[1], i = Math.floor(log(u)), j = Math.ceil(log(v)), n = base % 1 ? 2 : base; ++ if (isFinite(j - i)) { ++ if (positive) { ++ for (;i < j; i++) for (var k = 1; k < n; k++) ticks.push(pow(i) * k); ++ ticks.push(pow(i)); ++ } else { ++ ticks.push(pow(i)); ++ for (;i++ < j; ) for (var k = n - 1; k > 0; k--) ticks.push(pow(i) * k); + } ++ for (i = 0; ticks[i] < u; i++) {} ++ for (j = ticks.length; ticks[j - 1] > v; j--) {} ++ ticks = ticks.slice(i, j); + } +- if (sortChords) resort(); ++ return ticks; ++ }; ++ scale.tickFormat = function(n, format) { ++ if (!arguments.length) return d3_scale_logFormat; ++ if (arguments.length < 2) format = d3_scale_logFormat; else if (typeof format !== "function") format = d3.format(format); ++ var k = Math.max(1, base * n / scale.ticks().length); ++ return function(d) { ++ var i = d / pow(Math.round(log(d))); ++ if (i * base < base - .5) i *= base; ++ return i <= k ? format(d) : ""; ++ }; ++ }; ++ scale.copy = function() { ++ return d3_scale_log(linear.copy(), base, positive, domain); ++ }; ++ return d3_scale_linearRebind(scale, linear); ++ } ++ var d3_scale_logFormat = d3.format(".0e"), d3_scale_logNiceNegative = { ++ floor: function(x) { ++ return -Math.ceil(-x); ++ }, ++ ceil: function(x) { ++ return -Math.floor(-x); + } +- function resort() { +- chords.sort(function(a, b) { +- return sortChords((a.source.value + a.target.value) / 2, (b.source.value + b.target.value) / 2); +- }); ++ }; ++ d3.scale.pow = function() { ++ return d3_scale_pow(d3.scale.linear(), 1, [ 0, 1 ]); ++ }; ++ function d3_scale_pow(linear, exponent, domain) { ++ var powp = d3_scale_powPow(exponent), powb = d3_scale_powPow(1 / exponent); ++ function scale(x) { ++ return linear(powp(x)); + } +- chord.matrix = function(x) { +- if (!arguments.length) return matrix; +- n = (matrix = x) && matrix.length; +- chords = groups = null; +- return chord; ++ scale.invert = function(x) { ++ return powb(linear.invert(x)); + }; +- chord.padding = function(x) { +- if (!arguments.length) return padding; +- padding = x; +- chords = groups = null; +- return chord; ++ scale.domain = function(x) { ++ if (!arguments.length) return domain; ++ linear.domain((domain = x.map(Number)).map(powp)); ++ return scale; + }; +- chord.sortGroups = function(x) { +- if (!arguments.length) return sortGroups; +- sortGroups = x; +- chords = groups = null; +- return chord; ++ scale.ticks = function(m) { ++ return d3_scale_linearTicks(domain, m); + }; +- chord.sortSubgroups = function(x) { +- if (!arguments.length) return sortSubgroups; +- sortSubgroups = x; +- chords = null; +- return chord; ++ scale.tickFormat = function(m, format) { ++ return d3_scale_linearTickFormat(domain, m, format); + }; +- chord.sortChords = function(x) { +- if (!arguments.length) return sortChords; +- sortChords = x; +- if (chords) resort(); +- return chord; ++ scale.nice = function(m) { ++ return scale.domain(d3_scale_linearNice(domain, m)); + }; +- chord.chords = function() { +- if (!chords) relayout(); +- return chords; ++ scale.exponent = function(x) { ++ if (!arguments.length) return exponent; ++ powp = d3_scale_powPow(exponent = x); ++ powb = d3_scale_powPow(1 / exponent); ++ linear.domain(domain.map(powp)); ++ return scale; + }; +- chord.groups = function() { +- if (!groups) relayout(); +- return groups; ++ scale.copy = function() { ++ return d3_scale_pow(linear.copy(), exponent, domain); + }; +- return chord; ++ return d3_scale_linearRebind(scale, linear); ++ } ++ function d3_scale_powPow(e) { ++ return function(x) { ++ return x < 0 ? -Math.pow(-x, e) : Math.pow(x, e); ++ }; ++ } ++ d3.scale.sqrt = function() { ++ return d3.scale.pow().exponent(.5); + }; +- d3.layout.force = function() { +- var force = {}, event = d3.dispatch("start", "tick", "end"), timer, size = [ 1, 1 ], drag, alpha, friction = .9, linkDistance = d3_layout_forceLinkDistance, linkStrength = d3_layout_forceLinkStrength, charge = -30, chargeDistance2 = d3_layout_forceChargeDistance2, gravity = .1, theta2 = .64, nodes = [], links = [], distances, strengths, charges; +- function repulse(node) { +- return function(quad, x1, _, x2) { +- if (quad.point !== node) { +- var dx = quad.cx - node.x, dy = quad.cy - node.y, dw = x2 - x1, dn = dx * dx + dy * dy; +- if (dw * dw / theta2 < dn) { +- if (dn < chargeDistance2) { +- var k = quad.charge / dn; +- node.px -= dx * k; +- node.py -= dy * k; +- } +- return true; +- } +- if (quad.point && dn && dn < chargeDistance2) { +- var k = quad.pointCharge / dn; +- node.px -= dx * k; +- node.py -= dy * k; +- } +- } +- return !quad.charge; +- }; ++ d3.scale.ordinal = function() { ++ return d3_scale_ordinal([], { ++ t: "range", ++ a: [ [] ] ++ }); ++ }; ++ function d3_scale_ordinal(domain, ranger) { ++ var index, range, rangeBand; ++ function scale(x) { ++ return range[((index.get(x) || (ranger.t === "range" ? index.set(x, domain.push(x)) : NaN)) - 1) % range.length]; + } +- force.tick = function() { +- if ((alpha *= .99) < .005) { +- timer = null; +- event.end({ +- type: "end", +- alpha: alpha = 0 +- }); +- return true; +- } +- var n = nodes.length, m = links.length, q, i, o, s, t, l, k, x, y; +- for (i = 0; i < m; ++i) { +- o = links[i]; +- s = o.source; +- t = o.target; +- x = t.x - s.x; +- y = t.y - s.y; +- if (l = x * x + y * y) { +- l = alpha * strengths[i] * ((l = Math.sqrt(l)) - distances[i]) / l; +- x *= l; +- y *= l; +- t.x -= x * (k = s.weight + t.weight ? s.weight / (s.weight + t.weight) : .5); +- t.y -= y * k; +- s.x += x * (k = 1 - k); +- s.y += y * k; +- } +- } +- if (k = alpha * gravity) { +- x = size[0] / 2; +- y = size[1] / 2; +- i = -1; +- if (k) while (++i < n) { +- o = nodes[i]; +- o.x += (x - o.x) * k; +- o.y += (y - o.y) * k; +- } +- } +- if (charge) { +- d3_layout_forceAccumulate(q = d3.geom.quadtree(nodes), alpha, charges); +- i = -1; +- while (++i < n) { +- if (!(o = nodes[i]).fixed) { +- q.visit(repulse(o)); +- } +- } +- } +- i = -1; +- while (++i < n) { +- o = nodes[i]; +- if (o.fixed) { +- o.x = o.px; +- o.y = o.py; +- } else { +- o.x -= (o.px - (o.px = o.x)) * friction; +- o.y -= (o.py - (o.py = o.y)) * friction; +- } +- } +- event.tick({ +- type: "tick", +- alpha: alpha ++ function steps(start, step) { ++ return d3.range(domain.length).map(function(i) { ++ return start + step * i; + }); ++ } ++ scale.domain = function(x) { ++ if (!arguments.length) return domain; ++ domain = []; ++ index = new d3_Map(); ++ var i = -1, n = x.length, xi; ++ while (++i < n) if (!index.has(xi = x[i])) index.set(xi, domain.push(xi)); ++ return scale[ranger.t].apply(scale, ranger.a); + }; +- force.nodes = function(x) { +- if (!arguments.length) return nodes; +- nodes = x; +- return force; +- }; +- force.links = function(x) { +- if (!arguments.length) return links; +- links = x; +- return force; +- }; +- force.size = function(x) { +- if (!arguments.length) return size; +- size = x; +- return force; ++ scale.range = function(x) { ++ if (!arguments.length) return range; ++ range = x; ++ rangeBand = 0; ++ ranger = { ++ t: "range", ++ a: arguments ++ }; ++ return scale; + }; +- force.linkDistance = function(x) { +- if (!arguments.length) return linkDistance; +- linkDistance = typeof x === "function" ? x : +x; +- return force; ++ scale.rangePoints = function(x, padding) { ++ if (arguments.length < 2) padding = 0; ++ var start = x[0], stop = x[1], step = domain.length < 2 ? (start = (start + stop) / 2, ++ 0) : (stop - start) / (domain.length - 1 + padding); ++ range = steps(start + step * padding / 2, step); ++ rangeBand = 0; ++ ranger = { ++ t: "rangePoints", ++ a: arguments ++ }; ++ return scale; + }; +- force.distance = force.linkDistance; +- force.linkStrength = function(x) { +- if (!arguments.length) return linkStrength; +- linkStrength = typeof x === "function" ? x : +x; +- return force; ++ scale.rangeRoundPoints = function(x, padding) { ++ if (arguments.length < 2) padding = 0; ++ var start = x[0], stop = x[1], step = domain.length < 2 ? (start = stop = Math.round((start + stop) / 2), ++ 0) : (stop - start) / (domain.length - 1 + padding) | 0; ++ range = steps(start + Math.round(step * padding / 2 + (stop - start - (domain.length - 1 + padding) * step) / 2), step); ++ rangeBand = 0; ++ ranger = { ++ t: "rangeRoundPoints", ++ a: arguments ++ }; ++ return scale; + }; +- force.friction = function(x) { +- if (!arguments.length) return friction; +- friction = +x; +- return force; ++ scale.rangeBands = function(x, padding, outerPadding) { ++ if (arguments.length < 2) padding = 0; ++ if (arguments.length < 3) outerPadding = padding; ++ var reverse = x[1] < x[0], start = x[reverse - 0], stop = x[1 - reverse], step = (stop - start) / (domain.length - padding + 2 * outerPadding); ++ range = steps(start + step * outerPadding, step); ++ if (reverse) range.reverse(); ++ rangeBand = step * (1 - padding); ++ ranger = { ++ t: "rangeBands", ++ a: arguments ++ }; ++ return scale; + }; +- force.charge = function(x) { +- if (!arguments.length) return charge; +- charge = typeof x === "function" ? x : +x; +- return force; ++ scale.rangeRoundBands = function(x, padding, outerPadding) { ++ if (arguments.length < 2) padding = 0; ++ if (arguments.length < 3) outerPadding = padding; ++ var reverse = x[1] < x[0], start = x[reverse - 0], stop = x[1 - reverse], step = Math.floor((stop - start) / (domain.length - padding + 2 * outerPadding)); ++ range = steps(start + Math.round((stop - start - (domain.length - padding) * step) / 2), step); ++ if (reverse) range.reverse(); ++ rangeBand = Math.round(step * (1 - padding)); ++ ranger = { ++ t: "rangeRoundBands", ++ a: arguments ++ }; ++ return scale; + }; +- force.chargeDistance = function(x) { +- if (!arguments.length) return Math.sqrt(chargeDistance2); +- chargeDistance2 = x * x; +- return force; ++ scale.rangeBand = function() { ++ return rangeBand; + }; +- force.gravity = function(x) { +- if (!arguments.length) return gravity; +- gravity = +x; +- return force; ++ scale.rangeExtent = function() { ++ return d3_scaleExtent(ranger.a[0]); + }; +- force.theta = function(x) { +- if (!arguments.length) return Math.sqrt(theta2); +- theta2 = x * x; +- return force; ++ scale.copy = function() { ++ return d3_scale_ordinal(domain, ranger); + }; +- force.alpha = function(x) { +- if (!arguments.length) return alpha; +- x = +x; +- if (alpha) { +- if (x > 0) { +- alpha = x; +- } else { +- timer.c = null, timer.t = NaN, timer = null; +- event.end({ +- type: "end", +- alpha: alpha = 0 +- }); +- } +- } else if (x > 0) { +- event.start({ +- type: "start", +- alpha: alpha = x +- }); +- timer = d3_timer(force.tick); +- } +- return force; ++ return scale.domain(domain); ++ } ++ d3.scale.category10 = function() { ++ return d3.scale.ordinal().range(d3_category10); ++ }; ++ d3.scale.category20 = function() { ++ return d3.scale.ordinal().range(d3_category20); ++ }; ++ d3.scale.category20b = function() { ++ return d3.scale.ordinal().range(d3_category20b); ++ }; ++ d3.scale.category20c = function() { ++ return d3.scale.ordinal().range(d3_category20c); ++ }; ++ var d3_category10 = [ 2062260, 16744206, 2924588, 14034728, 9725885, 9197131, 14907330, 8355711, 12369186, 1556175 ].map(d3_rgbString); ++ var d3_category20 = [ 2062260, 11454440, 16744206, 16759672, 2924588, 10018698, 14034728, 16750742, 9725885, 12955861, 9197131, 12885140, 14907330, 16234194, 8355711, 13092807, 12369186, 14408589, 1556175, 10410725 ].map(d3_rgbString); ++ var d3_category20b = [ 3750777, 5395619, 7040719, 10264286, 6519097, 9216594, 11915115, 13556636, 9202993, 12426809, 15186514, 15190932, 8666169, 11356490, 14049643, 15177372, 8077683, 10834324, 13528509, 14589654 ].map(d3_rgbString); ++ var d3_category20c = [ 3244733, 7057110, 10406625, 13032431, 15095053, 16616764, 16625259, 16634018, 3253076, 7652470, 10607003, 13101504, 7695281, 10394312, 12369372, 14342891, 6513507, 9868950, 12434877, 14277081 ].map(d3_rgbString); ++ d3.scale.quantile = function() { ++ return d3_scale_quantile([], []); ++ }; ++ function d3_scale_quantile(domain, range) { ++ var thresholds; ++ function rescale() { ++ var k = 0, q = range.length; ++ thresholds = []; ++ while (++k < q) thresholds[k - 1] = d3.quantile(domain, k / q); ++ return scale; ++ } ++ function scale(x) { ++ if (!isNaN(x = +x)) return range[d3.bisect(thresholds, x)]; ++ } ++ scale.domain = function(x) { ++ if (!arguments.length) return domain; ++ domain = x.map(d3_number).filter(d3_numeric).sort(d3_ascending); ++ return rescale(); + }; +- force.start = function() { +- var i, n = nodes.length, m = links.length, w = size[0], h = size[1], neighbors, o; +- for (i = 0; i < n; ++i) { +- (o = nodes[i]).index = i; +- o.weight = 0; +- } +- for (i = 0; i < m; ++i) { +- o = links[i]; +- if (typeof o.source == "number") o.source = nodes[o.source]; +- if (typeof o.target == "number") o.target = nodes[o.target]; +- ++o.source.weight; +- ++o.target.weight; +- } +- for (i = 0; i < n; ++i) { +- o = nodes[i]; +- if (isNaN(o.x)) o.x = position("x", w); +- if (isNaN(o.y)) o.y = position("y", h); +- if (isNaN(o.px)) o.px = o.x; +- if (isNaN(o.py)) o.py = o.y; +- } +- distances = []; +- if (typeof linkDistance === "function") for (i = 0; i < m; ++i) distances[i] = +linkDistance.call(this, links[i], i); else for (i = 0; i < m; ++i) distances[i] = linkDistance; +- strengths = []; +- if (typeof linkStrength === "function") for (i = 0; i < m; ++i) strengths[i] = +linkStrength.call(this, links[i], i); else for (i = 0; i < m; ++i) strengths[i] = linkStrength; +- charges = []; +- if (typeof charge === "function") for (i = 0; i < n; ++i) charges[i] = +charge.call(this, nodes[i], i); else for (i = 0; i < n; ++i) charges[i] = charge; +- function position(dimension, size) { +- if (!neighbors) { +- neighbors = new Array(n); +- for (j = 0; j < n; ++j) { +- neighbors[j] = []; +- } +- for (j = 0; j < m; ++j) { +- var o = links[j]; +- neighbors[o.source.index].push(o.target); +- neighbors[o.target.index].push(o.source); +- } +- } +- var candidates = neighbors[i], j = -1, l = candidates.length, x; +- while (++j < l) if (!isNaN(x = candidates[j][dimension])) return x; +- return Math.random() * size; +- } +- return force.resume(); ++ scale.range = function(x) { ++ if (!arguments.length) return range; ++ range = x; ++ return rescale(); + }; +- force.resume = function() { +- return force.alpha(.1); ++ scale.quantiles = function() { ++ return thresholds; + }; +- force.stop = function() { +- return force.alpha(0); ++ scale.invertExtent = function(y) { ++ y = range.indexOf(y); ++ return y < 0 ? [ NaN, NaN ] : [ y > 0 ? thresholds[y - 1] : domain[0], y < thresholds.length ? thresholds[y] : domain[domain.length - 1] ]; + }; +- force.drag = function() { +- if (!drag) drag = d3.behavior.drag().origin(d3_identity).on("dragstart.force", d3_layout_forceDragstart).on("drag.force", dragmove).on("dragend.force", d3_layout_forceDragend); +- if (!arguments.length) return drag; +- this.on("mouseover.force", d3_layout_forceMouseover).on("mouseout.force", d3_layout_forceMouseout).call(drag); ++ scale.copy = function() { ++ return d3_scale_quantile(domain, range); + }; +- function dragmove(d) { +- d.px = d3.event.x, d.py = d3.event.y; +- force.resume(); +- } +- return d3.rebind(force, event, "on"); +- }; +- function d3_layout_forceDragstart(d) { +- d.fixed |= 2; +- } +- function d3_layout_forceDragend(d) { +- d.fixed &= ~6; +- } +- function d3_layout_forceMouseover(d) { +- d.fixed |= 4; +- d.px = d.x, d.py = d.y; +- } +- function d3_layout_forceMouseout(d) { +- d.fixed &= ~4; ++ return rescale(); + } +- function d3_layout_forceAccumulate(quad, alpha, charges) { +- var cx = 0, cy = 0; +- quad.charge = 0; +- if (!quad.leaf) { +- var nodes = quad.nodes, n = nodes.length, i = -1, c; +- while (++i < n) { +- c = nodes[i]; +- if (c == null) continue; +- d3_layout_forceAccumulate(c, alpha, charges); +- quad.charge += c.charge; +- cx += c.charge * c.cx; +- cy += c.charge * c.cy; +- } +- } +- if (quad.point) { +- if (!quad.leaf) { +- quad.point.x += Math.random() - .5; +- quad.point.y += Math.random() - .5; +- } +- var k = alpha * charges[quad.point.index]; +- quad.charge += quad.pointCharge = k; +- cx += k * quad.point.x; +- cy += k * quad.point.y; ++ d3.scale.quantize = function() { ++ return d3_scale_quantize(0, 1, [ 0, 1 ]); ++ }; ++ function d3_scale_quantize(x0, x1, range) { ++ var kx, i; ++ function scale(x) { ++ return range[Math.max(0, Math.min(i, Math.floor(kx * (x - x0))))]; + } +- quad.cx = cx / quad.charge; +- quad.cy = cy / quad.charge; +- } +- var d3_layout_forceLinkDistance = 20, d3_layout_forceLinkStrength = 1, d3_layout_forceChargeDistance2 = Infinity; +- d3.layout.hierarchy = function() { +- var sort = d3_layout_hierarchySort, children = d3_layout_hierarchyChildren, value = d3_layout_hierarchyValue; +- function hierarchy(root) { +- var stack = [ root ], nodes = [], node; +- root.depth = 0; +- while ((node = stack.pop()) != null) { +- nodes.push(node); +- if ((childs = children.call(hierarchy, node, node.depth)) && (n = childs.length)) { +- var n, childs, child; +- while (--n >= 0) { +- stack.push(child = childs[n]); +- child.parent = node; +- child.depth = node.depth + 1; +- } +- if (value) node.value = 0; +- node.children = childs; +- } else { +- if (value) node.value = +value.call(hierarchy, node, node.depth) || 0; +- delete node.children; +- } +- } +- d3_layout_hierarchyVisitAfter(root, function(node) { +- var childs, parent; +- if (sort && (childs = node.children)) childs.sort(sort); +- if (value && (parent = node.parent)) parent.value += node.value; +- }); +- return nodes; ++ function rescale() { ++ kx = range.length / (x1 - x0); ++ i = range.length - 1; ++ return scale; + } +- hierarchy.sort = function(x) { +- if (!arguments.length) return sort; +- sort = x; +- return hierarchy; ++ scale.domain = function(x) { ++ if (!arguments.length) return [ x0, x1 ]; ++ x0 = +x[0]; ++ x1 = +x[x.length - 1]; ++ return rescale(); + }; +- hierarchy.children = function(x) { +- if (!arguments.length) return children; +- children = x; +- return hierarchy; ++ scale.range = function(x) { ++ if (!arguments.length) return range; ++ range = x; ++ return rescale(); + }; +- hierarchy.value = function(x) { +- if (!arguments.length) return value; +- value = x; +- return hierarchy; ++ scale.invertExtent = function(y) { ++ y = range.indexOf(y); ++ y = y < 0 ? NaN : y / kx + x0; ++ return [ y, y + 1 / kx ]; + }; +- hierarchy.revalue = function(root) { +- if (value) { +- d3_layout_hierarchyVisitBefore(root, function(node) { +- if (node.children) node.value = 0; +- }); +- d3_layout_hierarchyVisitAfter(root, function(node) { +- var parent; +- if (!node.children) node.value = +value.call(hierarchy, node, node.depth) || 0; +- if (parent = node.parent) parent.value += node.value; +- }); +- } +- return root; ++ scale.copy = function() { ++ return d3_scale_quantize(x0, x1, range); + }; +- return hierarchy; +- }; +- function d3_layout_hierarchyRebind(object, hierarchy) { +- d3.rebind(object, hierarchy, "sort", "children", "value"); +- object.nodes = object; +- object.links = d3_layout_hierarchyLinks; +- return object; +- } +- function d3_layout_hierarchyVisitBefore(node, callback) { +- var nodes = [ node ]; +- while ((node = nodes.pop()) != null) { +- callback(node); +- if ((children = node.children) && (n = children.length)) { +- var n, children; +- while (--n >= 0) nodes.push(children[n]); +- } +- } +- } +- function d3_layout_hierarchyVisitAfter(node, callback) { +- var nodes = [ node ], nodes2 = []; +- while ((node = nodes.pop()) != null) { +- nodes2.push(node); +- if ((children = node.children) && (n = children.length)) { +- var i = -1, n, children; +- while (++i < n) nodes.push(children[i]); +- } +- } +- while ((node = nodes2.pop()) != null) { +- callback(node); +- } +- } +- function d3_layout_hierarchyChildren(d) { +- return d.children; +- } +- function d3_layout_hierarchyValue(d) { +- return d.value; +- } +- function d3_layout_hierarchySort(a, b) { +- return b.value - a.value; +- } +- function d3_layout_hierarchyLinks(nodes) { +- return d3.merge(nodes.map(function(parent) { +- return (parent.children || []).map(function(child) { +- return { +- source: parent, +- target: child +- }; +- }); +- })); ++ return rescale(); + } +- d3.layout.partition = function() { +- var hierarchy = d3.layout.hierarchy(), size = [ 1, 1 ]; +- function position(node, x, dx, dy) { +- var children = node.children; +- node.x = x; +- node.y = node.depth * dy; +- node.dx = dx; +- node.dy = dy; +- if (children && (n = children.length)) { +- var i = -1, n, c, d; +- dx = node.value ? dx / node.value : 0; +- while (++i < n) { +- position(c = children[i], x, d = c.value * dx, dy); +- x += d; +- } +- } +- } +- function depth(node) { +- var children = node.children, d = 0; +- if (children && (n = children.length)) { +- var i = -1, n; +- while (++i < n) d = Math.max(d, depth(children[i])); +- } +- return 1 + d; +- } +- function partition(d, i) { +- var nodes = hierarchy.call(this, d, i); +- position(nodes[0], 0, size[0], size[1] / depth(nodes[0])); +- return nodes; ++ d3.scale.threshold = function() { ++ return d3_scale_threshold([ .5 ], [ 0, 1 ]); ++ }; ++ function d3_scale_threshold(domain, range) { ++ function scale(x) { ++ if (x <= x) return range[d3.bisect(domain, x)]; + } +- partition.size = function(x) { +- if (!arguments.length) return size; +- size = x; +- return partition; ++ scale.domain = function(_) { ++ if (!arguments.length) return domain; ++ domain = _; ++ return scale; + }; +- return d3_layout_hierarchyRebind(partition, hierarchy); ++ scale.range = function(_) { ++ if (!arguments.length) return range; ++ range = _; ++ return scale; ++ }; ++ scale.invertExtent = function(y) { ++ y = range.indexOf(y); ++ return [ domain[y - 1], domain[y] ]; ++ }; ++ scale.copy = function() { ++ return d3_scale_threshold(domain, range); ++ }; ++ return scale; ++ } ++ d3.scale.identity = function() { ++ return d3_scale_identity([ 0, 1 ]); + }; +- d3.layout.pie = function() { +- var value = Number, sort = d3_layout_pieSortByValue, startAngle = 0, endAngle = τ, padAngle = 0; +- function pie(data) { +- var n = data.length, values = data.map(function(d, i) { +- return +value.call(pie, d, i); +- }), a = +(typeof startAngle === "function" ? startAngle.apply(this, arguments) : startAngle), da = (typeof endAngle === "function" ? endAngle.apply(this, arguments) : endAngle) - a, p = Math.min(Math.abs(da) / n, +(typeof padAngle === "function" ? padAngle.apply(this, arguments) : padAngle)), pa = p * (da < 0 ? -1 : 1), sum = d3.sum(values), k = sum ? (da - n * pa) / sum : 0, index = d3.range(n), arcs = [], v; +- if (sort != null) index.sort(sort === d3_layout_pieSortByValue ? function(i, j) { +- return values[j] - values[i]; +- } : function(i, j) { +- return sort(data[i], data[j]); +- }); +- index.forEach(function(i) { +- arcs[i] = { +- data: data[i], +- value: v = values[i], +- startAngle: a, +- endAngle: a += v * k + pa, +- padAngle: p +- }; +- }); +- return arcs; ++ function d3_scale_identity(domain) { ++ function identity(x) { ++ return +x; + } +- pie.value = function(_) { +- if (!arguments.length) return value; +- value = _; +- return pie; +- }; +- pie.sort = function(_) { +- if (!arguments.length) return sort; +- sort = _; +- return pie; ++ identity.invert = identity; ++ identity.domain = identity.range = function(x) { ++ if (!arguments.length) return domain; ++ domain = x.map(identity); ++ return identity; + }; +- pie.startAngle = function(_) { +- if (!arguments.length) return startAngle; +- startAngle = _; +- return pie; ++ identity.ticks = function(m) { ++ return d3_scale_linearTicks(domain, m); + }; +- pie.endAngle = function(_) { +- if (!arguments.length) return endAngle; +- endAngle = _; +- return pie; ++ identity.tickFormat = function(m, format) { ++ return d3_scale_linearTickFormat(domain, m, format); + }; +- pie.padAngle = function(_) { +- if (!arguments.length) return padAngle; +- padAngle = _; +- return pie; ++ identity.copy = function() { ++ return d3_scale_identity(domain); + }; +- return pie; +- }; +- var d3_layout_pieSortByValue = {}; +- d3.layout.stack = function() { +- var values = d3_identity, order = d3_layout_stackOrderDefault, offset = d3_layout_stackOffsetZero, out = d3_layout_stackOut, x = d3_layout_stackX, y = d3_layout_stackY; +- function stack(data, index) { +- if (!(n = data.length)) return data; +- var series = data.map(function(d, i) { +- return values.call(stack, d, i); +- }); +- var points = series.map(function(d) { +- return d.map(function(v, i) { +- return [ x.call(stack, v, i), y.call(stack, v, i) ]; +- }); +- }); +- var orders = order.call(stack, points, index); +- series = d3.permute(series, orders); +- points = d3.permute(points, orders); +- var offsets = offset.call(stack, points, index); +- var m = series[0].length, n, i, j, o; +- for (j = 0; j < m; ++j) { +- out.call(stack, series[0][j], o = offsets[j], points[0][j][1]); +- for (i = 1; i < n; ++i) { +- out.call(stack, series[i][j], o += points[i - 1][j][1], points[i][j][1]); ++ return identity; ++ } ++ d3.svg = {}; ++ function d3_zero() { ++ return 0; ++ } ++ d3.svg.arc = function() { ++ var innerRadius = d3_svg_arcInnerRadius, outerRadius = d3_svg_arcOuterRadius, cornerRadius = d3_zero, padRadius = d3_svg_arcAuto, startAngle = d3_svg_arcStartAngle, endAngle = d3_svg_arcEndAngle, padAngle = d3_svg_arcPadAngle; ++ function arc() { ++ var r0 = Math.max(0, +innerRadius.apply(this, arguments)), r1 = Math.max(0, +outerRadius.apply(this, arguments)), a0 = startAngle.apply(this, arguments) - halfπ, a1 = endAngle.apply(this, arguments) - halfπ, da = Math.abs(a1 - a0), cw = a0 > a1 ? 0 : 1; ++ if (r1 < r0) rc = r1, r1 = r0, r0 = rc; ++ if (da >= τε) return circleSegment(r1, cw) + (r0 ? circleSegment(r0, 1 - cw) : "") + "Z"; ++ var rc, cr, rp, ap, p0 = 0, p1 = 0, x0, y0, x1, y1, x2, y2, x3, y3, path = []; ++ if (ap = (+padAngle.apply(this, arguments) || 0) / 2) { ++ rp = padRadius === d3_svg_arcAuto ? Math.sqrt(r0 * r0 + r1 * r1) : +padRadius.apply(this, arguments); ++ if (!cw) p1 *= -1; ++ if (r1) p1 = d3_asin(rp / r1 * Math.sin(ap)); ++ if (r0) p0 = d3_asin(rp / r0 * Math.sin(ap)); ++ } ++ if (r1) { ++ x0 = r1 * Math.cos(a0 + p1); ++ y0 = r1 * Math.sin(a0 + p1); ++ x1 = r1 * Math.cos(a1 - p1); ++ y1 = r1 * Math.sin(a1 - p1); ++ var l1 = Math.abs(a1 - a0 - 2 * p1) <= π ? 0 : 1; ++ if (p1 && d3_svg_arcSweep(x0, y0, x1, y1) === cw ^ l1) { ++ var h1 = (a0 + a1) / 2; ++ x0 = r1 * Math.cos(h1); ++ y0 = r1 * Math.sin(h1); ++ x1 = y1 = null; ++ } ++ } else { ++ x0 = y0 = 0; ++ } ++ if (r0) { ++ x2 = r0 * Math.cos(a1 - p0); ++ y2 = r0 * Math.sin(a1 - p0); ++ x3 = r0 * Math.cos(a0 + p0); ++ y3 = r0 * Math.sin(a0 + p0); ++ var l0 = Math.abs(a0 - a1 + 2 * p0) <= π ? 0 : 1; ++ if (p0 && d3_svg_arcSweep(x2, y2, x3, y3) === 1 - cw ^ l0) { ++ var h0 = (a0 + a1) / 2; ++ x2 = r0 * Math.cos(h0); ++ y2 = r0 * Math.sin(h0); ++ x3 = y3 = null; ++ } ++ } else { ++ x2 = y2 = 0; ++ } ++ if (da > ε && (rc = Math.min(Math.abs(r1 - r0) / 2, +cornerRadius.apply(this, arguments))) > .001) { ++ cr = r0 < r1 ^ cw ? 0 : 1; ++ var rc1 = rc, rc0 = rc; ++ if (da < π) { ++ var oc = x3 == null ? [ x2, y2 ] : x1 == null ? [ x0, y0 ] : d3_geom_polygonIntersect([ x0, y0 ], [ x3, y3 ], [ x1, y1 ], [ x2, y2 ]), ax = x0 - oc[0], ay = y0 - oc[1], bx = x1 - oc[0], by = y1 - oc[1], kc = 1 / Math.sin(Math.acos((ax * bx + ay * by) / (Math.sqrt(ax * ax + ay * ay) * Math.sqrt(bx * bx + by * by))) / 2), lc = Math.sqrt(oc[0] * oc[0] + oc[1] * oc[1]); ++ rc0 = Math.min(rc, (r0 - lc) / (kc - 1)); ++ rc1 = Math.min(rc, (r1 - lc) / (kc + 1)); ++ } ++ if (x1 != null) { ++ var t30 = d3_svg_arcCornerTangents(x3 == null ? [ x2, y2 ] : [ x3, y3 ], [ x0, y0 ], r1, rc1, cw), t12 = d3_svg_arcCornerTangents([ x1, y1 ], [ x2, y2 ], r1, rc1, cw); ++ if (rc === rc1) { ++ path.push("M", t30[0], "A", rc1, ",", rc1, " 0 0,", cr, " ", t30[1], "A", r1, ",", r1, " 0 ", 1 - cw ^ d3_svg_arcSweep(t30[1][0], t30[1][1], t12[1][0], t12[1][1]), ",", cw, " ", t12[1], "A", rc1, ",", rc1, " 0 0,", cr, " ", t12[0]); ++ } else { ++ path.push("M", t30[0], "A", rc1, ",", rc1, " 0 1,", cr, " ", t12[0]); ++ } ++ } else { ++ path.push("M", x0, ",", y0); ++ } ++ if (x3 != null) { ++ var t03 = d3_svg_arcCornerTangents([ x0, y0 ], [ x3, y3 ], r0, -rc0, cw), t21 = d3_svg_arcCornerTangents([ x2, y2 ], x1 == null ? [ x0, y0 ] : [ x1, y1 ], r0, -rc0, cw); ++ if (rc === rc0) { ++ path.push("L", t21[0], "A", rc0, ",", rc0, " 0 0,", cr, " ", t21[1], "A", r0, ",", r0, " 0 ", cw ^ d3_svg_arcSweep(t21[1][0], t21[1][1], t03[1][0], t03[1][1]), ",", 1 - cw, " ", t03[1], "A", rc0, ",", rc0, " 0 0,", cr, " ", t03[0]); ++ } else { ++ path.push("L", t21[0], "A", rc0, ",", rc0, " 0 0,", cr, " ", t03[0]); ++ } ++ } else { ++ path.push("L", x2, ",", y2); + } ++ } else { ++ path.push("M", x0, ",", y0); ++ if (x1 != null) path.push("A", r1, ",", r1, " 0 ", l1, ",", cw, " ", x1, ",", y1); ++ path.push("L", x2, ",", y2); ++ if (x3 != null) path.push("A", r0, ",", r0, " 0 ", l0, ",", 1 - cw, " ", x3, ",", y3); + } +- return data; ++ path.push("Z"); ++ return path.join(""); + } +- stack.values = function(x) { +- if (!arguments.length) return values; +- values = x; +- return stack; ++ function circleSegment(r1, cw) { ++ return "M0," + r1 + "A" + r1 + "," + r1 + " 0 1," + cw + " 0," + -r1 + "A" + r1 + "," + r1 + " 0 1," + cw + " 0," + r1; ++ } ++ arc.innerRadius = function(v) { ++ if (!arguments.length) return innerRadius; ++ innerRadius = d3_functor(v); ++ return arc; + }; +- stack.order = function(x) { +- if (!arguments.length) return order; +- order = typeof x === "function" ? x : d3_layout_stackOrders.get(x) || d3_layout_stackOrderDefault; +- return stack; ++ arc.outerRadius = function(v) { ++ if (!arguments.length) return outerRadius; ++ outerRadius = d3_functor(v); ++ return arc; + }; +- stack.offset = function(x) { +- if (!arguments.length) return offset; +- offset = typeof x === "function" ? x : d3_layout_stackOffsets.get(x) || d3_layout_stackOffsetZero; +- return stack; ++ arc.cornerRadius = function(v) { ++ if (!arguments.length) return cornerRadius; ++ cornerRadius = d3_functor(v); ++ return arc; + }; +- stack.x = function(z) { +- if (!arguments.length) return x; +- x = z; +- return stack; ++ arc.padRadius = function(v) { ++ if (!arguments.length) return padRadius; ++ padRadius = v == d3_svg_arcAuto ? d3_svg_arcAuto : d3_functor(v); ++ return arc; + }; +- stack.y = function(z) { +- if (!arguments.length) return y; +- y = z; +- return stack; ++ arc.startAngle = function(v) { ++ if (!arguments.length) return startAngle; ++ startAngle = d3_functor(v); ++ return arc; + }; +- stack.out = function(z) { +- if (!arguments.length) return out; +- out = z; +- return stack; ++ arc.endAngle = function(v) { ++ if (!arguments.length) return endAngle; ++ endAngle = d3_functor(v); ++ return arc; + }; +- return stack; ++ arc.padAngle = function(v) { ++ if (!arguments.length) return padAngle; ++ padAngle = d3_functor(v); ++ return arc; ++ }; ++ arc.centroid = function() { ++ var r = (+innerRadius.apply(this, arguments) + +outerRadius.apply(this, arguments)) / 2, a = (+startAngle.apply(this, arguments) + +endAngle.apply(this, arguments)) / 2 - halfπ; ++ return [ Math.cos(a) * r, Math.sin(a) * r ]; ++ }; ++ return arc; + }; +- function d3_layout_stackX(d) { +- return d.x; +- } +- function d3_layout_stackY(d) { +- return d.y; ++ var d3_svg_arcAuto = "auto"; ++ function d3_svg_arcInnerRadius(d) { ++ return d.innerRadius; + } +- function d3_layout_stackOut(d, y0, y) { +- d.y0 = y0; +- d.y = y; ++ function d3_svg_arcOuterRadius(d) { ++ return d.outerRadius; + } +- var d3_layout_stackOrders = d3.map({ +- "inside-out": function(data) { +- var n = data.length, i, j, max = data.map(d3_layout_stackMaxIndex), sums = data.map(d3_layout_stackReduceSum), index = d3.range(n).sort(function(a, b) { +- return max[a] - max[b]; +- }), top = 0, bottom = 0, tops = [], bottoms = []; +- for (i = 0; i < n; ++i) { +- j = index[i]; +- if (top < bottom) { +- top += sums[j]; +- tops.push(j); +- } else { +- bottom += sums[j]; +- bottoms.push(j); +- } +- } +- return bottoms.reverse().concat(tops); +- }, +- reverse: function(data) { +- return d3.range(data.length).reverse(); +- }, +- "default": d3_layout_stackOrderDefault +- }); +- var d3_layout_stackOffsets = d3.map({ +- silhouette: function(data) { +- var n = data.length, m = data[0].length, sums = [], max = 0, i, j, o, y0 = []; +- for (j = 0; j < m; ++j) { +- for (i = 0, o = 0; i < n; i++) o += data[i][j][1]; +- if (o > max) max = o; +- sums.push(o); +- } +- for (j = 0; j < m; ++j) { +- y0[j] = (max - sums[j]) / 2; +- } +- return y0; +- }, +- wiggle: function(data) { +- var n = data.length, x = data[0], m = x.length, i, j, k, s1, s2, s3, dx, o, o0, y0 = []; +- y0[0] = o = o0 = 0; +- for (j = 1; j < m; ++j) { +- for (i = 0, s1 = 0; i < n; ++i) s1 += data[i][j][1]; +- for (i = 0, s2 = 0, dx = x[j][0] - x[j - 1][0]; i < n; ++i) { +- for (k = 0, s3 = (data[i][j][1] - data[i][j - 1][1]) / (2 * dx); k < i; ++k) { +- s3 += (data[k][j][1] - data[k][j - 1][1]) / dx; +- } +- s2 += s3 * data[i][j][1]; +- } +- y0[j] = o -= s1 ? s2 / s1 * dx : 0; +- if (o < o0) o0 = o; +- } +- for (j = 0; j < m; ++j) y0[j] -= o0; +- return y0; +- }, +- expand: function(data) { +- var n = data.length, m = data[0].length, k = 1 / n, i, j, o, y0 = []; +- for (j = 0; j < m; ++j) { +- for (i = 0, o = 0; i < n; i++) o += data[i][j][1]; +- if (o) for (i = 0; i < n; i++) data[i][j][1] /= o; else for (i = 0; i < n; i++) data[i][j][1] = k; +- } +- for (j = 0; j < m; ++j) y0[j] = 0; +- return y0; +- }, +- zero: d3_layout_stackOffsetZero +- }); +- function d3_layout_stackOrderDefault(data) { +- return d3.range(data.length); ++ function d3_svg_arcStartAngle(d) { ++ return d.startAngle; + } +- function d3_layout_stackOffsetZero(data) { +- var j = -1, m = data[0].length, y0 = []; +- while (++j < m) y0[j] = 0; +- return y0; ++ function d3_svg_arcEndAngle(d) { ++ return d.endAngle; + } +- function d3_layout_stackMaxIndex(array) { +- var i = 1, j = 0, v = array[0][1], k, n = array.length; +- for (;i < n; ++i) { +- if ((k = array[i][1]) > v) { +- j = i; +- v = k; +- } +- } +- return j; ++ function d3_svg_arcPadAngle(d) { ++ return d && d.padAngle; + } +- function d3_layout_stackReduceSum(d) { +- return d.reduce(d3_layout_stackSum, 0); ++ function d3_svg_arcSweep(x0, y0, x1, y1) { ++ return (x0 - x1) * y0 - (y0 - y1) * x0 > 0 ? 0 : 1; + } +- function d3_layout_stackSum(p, d) { +- return p + d[1]; ++ function d3_svg_arcCornerTangents(p0, p1, r1, rc, cw) { ++ var x01 = p0[0] - p1[0], y01 = p0[1] - p1[1], lo = (cw ? rc : -rc) / Math.sqrt(x01 * x01 + y01 * y01), ox = lo * y01, oy = -lo * x01, x1 = p0[0] + ox, y1 = p0[1] + oy, x2 = p1[0] + ox, y2 = p1[1] + oy, x3 = (x1 + x2) / 2, y3 = (y1 + y2) / 2, dx = x2 - x1, dy = y2 - y1, d2 = dx * dx + dy * dy, r = r1 - rc, D = x1 * y2 - x2 * y1, d = (dy < 0 ? -1 : 1) * Math.sqrt(Math.max(0, r * r * d2 - D * D)), cx0 = (D * dy - dx * d) / d2, cy0 = (-D * dx - dy * d) / d2, cx1 = (D * dy + dx * d) / d2, cy1 = (-D * dx + dy * d) / d2, dx0 = cx0 - x3, dy0 = cy0 - y3, dx1 = cx1 - x3, dy1 = cy1 - y3; ++ if (dx0 * dx0 + dy0 * dy0 > dx1 * dx1 + dy1 * dy1) cx0 = cx1, cy0 = cy1; ++ return [ [ cx0 - ox, cy0 - oy ], [ cx0 * r1 / r, cy0 * r1 / r ] ]; + } +- d3.layout.histogram = function() { +- var frequency = true, valuer = Number, ranger = d3_layout_histogramRange, binner = d3_layout_histogramBinSturges; +- function histogram(data, i) { +- var bins = [], values = data.map(valuer, this), range = ranger.call(this, values, i), thresholds = binner.call(this, range, values, i), bin, i = -1, n = values.length, m = thresholds.length - 1, k = frequency ? 1 : 1 / n, x; +- while (++i < m) { +- bin = bins[i] = []; +- bin.dx = thresholds[i + 1] - (bin.x = thresholds[i]); +- bin.y = 0; ++ function d3_svg_line(projection) { ++ var x = d3_geom_pointX, y = d3_geom_pointY, defined = d3_true, interpolate = d3_svg_lineLinear, interpolateKey = interpolate.key, tension = .7; ++ function line(data) { ++ var segments = [], points = [], i = -1, n = data.length, d, fx = d3_functor(x), fy = d3_functor(y); ++ function segment() { ++ segments.push("M", interpolate(projection(points), tension)); + } +- if (m > 0) { +- i = -1; +- while (++i < n) { +- x = values[i]; +- if (x >= range[0] && x <= range[1]) { +- bin = bins[d3.bisect(thresholds, x, 1, m) - 1]; +- bin.y += k; +- bin.push(data[i]); +- } ++ while (++i < n) { ++ if (defined.call(this, d = data[i], i)) { ++ points.push([ +fx.call(this, d, i), +fy.call(this, d, i) ]); ++ } else if (points.length) { ++ segment(); ++ points = []; + } + } +- return bins; ++ if (points.length) segment(); ++ return segments.length ? segments.join("") : null; + } +- histogram.value = function(x) { +- if (!arguments.length) return valuer; +- valuer = x; +- return histogram; ++ line.x = function(_) { ++ if (!arguments.length) return x; ++ x = _; ++ return line; + }; +- histogram.range = function(x) { +- if (!arguments.length) return ranger; +- ranger = d3_functor(x); +- return histogram; ++ line.y = function(_) { ++ if (!arguments.length) return y; ++ y = _; ++ return line; + }; +- histogram.bins = function(x) { +- if (!arguments.length) return binner; +- binner = typeof x === "number" ? function(range) { +- return d3_layout_histogramBinFixed(range, x); +- } : d3_functor(x); +- return histogram; ++ line.defined = function(_) { ++ if (!arguments.length) return defined; ++ defined = _; ++ return line; + }; +- histogram.frequency = function(x) { +- if (!arguments.length) return frequency; +- frequency = !!x; +- return histogram; ++ line.interpolate = function(_) { ++ if (!arguments.length) return interpolateKey; ++ if (typeof _ === "function") interpolateKey = interpolate = _; else interpolateKey = (interpolate = d3_svg_lineInterpolators.get(_) || d3_svg_lineLinear).key; ++ return line; + }; +- return histogram; ++ line.tension = function(_) { ++ if (!arguments.length) return tension; ++ tension = _; ++ return line; ++ }; ++ return line; ++ } ++ d3.svg.line = function() { ++ return d3_svg_line(d3_identity); + }; +- function d3_layout_histogramBinSturges(range, values) { +- return d3_layout_histogramBinFixed(range, Math.ceil(Math.log(values.length) / Math.LN2 + 1)); ++ var d3_svg_lineInterpolators = d3.map({ ++ linear: d3_svg_lineLinear, ++ "linear-closed": d3_svg_lineLinearClosed, ++ step: d3_svg_lineStep, ++ "step-before": d3_svg_lineStepBefore, ++ "step-after": d3_svg_lineStepAfter, ++ basis: d3_svg_lineBasis, ++ "basis-open": d3_svg_lineBasisOpen, ++ "basis-closed": d3_svg_lineBasisClosed, ++ bundle: d3_svg_lineBundle, ++ cardinal: d3_svg_lineCardinal, ++ "cardinal-open": d3_svg_lineCardinalOpen, ++ "cardinal-closed": d3_svg_lineCardinalClosed, ++ monotone: d3_svg_lineMonotone ++ }); ++ d3_svg_lineInterpolators.forEach(function(key, value) { ++ value.key = key; ++ value.closed = /-closed$/.test(key); ++ }); ++ function d3_svg_lineLinear(points) { ++ return points.length > 1 ? points.join("L") : points + "Z"; + } +- function d3_layout_histogramBinFixed(range, n) { +- var x = -1, b = +range[0], m = (range[1] - b) / n, f = []; +- while (++x <= n) f[x] = m * x + b; +- return f; ++ function d3_svg_lineLinearClosed(points) { ++ return points.join("L") + "Z"; + } +- function d3_layout_histogramRange(values) { +- return [ d3.min(values), d3.max(values) ]; ++ function d3_svg_lineStep(points) { ++ var i = 0, n = points.length, p = points[0], path = [ p[0], ",", p[1] ]; ++ while (++i < n) path.push("H", (p[0] + (p = points[i])[0]) / 2, "V", p[1]); ++ if (n > 1) path.push("H", p[0]); ++ return path.join(""); + } +- d3.layout.pack = function() { +- var hierarchy = d3.layout.hierarchy().sort(d3_layout_packSort), padding = 0, size = [ 1, 1 ], radius; +- function pack(d, i) { +- var nodes = hierarchy.call(this, d, i), root = nodes[0], w = size[0], h = size[1], r = radius == null ? Math.sqrt : typeof radius === "function" ? radius : function() { +- return radius; +- }; +- root.x = root.y = 0; +- d3_layout_hierarchyVisitAfter(root, function(d) { +- d.r = +r(d.value); +- }); +- d3_layout_hierarchyVisitAfter(root, d3_layout_packSiblings); +- if (padding) { +- var dr = padding * (radius ? 1 : Math.max(2 * root.r / w, 2 * root.r / h)) / 2; +- d3_layout_hierarchyVisitAfter(root, function(d) { +- d.r += dr; +- }); +- d3_layout_hierarchyVisitAfter(root, d3_layout_packSiblings); +- d3_layout_hierarchyVisitAfter(root, function(d) { +- d.r -= dr; +- }); ++ function d3_svg_lineStepBefore(points) { ++ var i = 0, n = points.length, p = points[0], path = [ p[0], ",", p[1] ]; ++ while (++i < n) path.push("V", (p = points[i])[1], "H", p[0]); ++ return path.join(""); ++ } ++ function d3_svg_lineStepAfter(points) { ++ var i = 0, n = points.length, p = points[0], path = [ p[0], ",", p[1] ]; ++ while (++i < n) path.push("H", (p = points[i])[0], "V", p[1]); ++ return path.join(""); ++ } ++ function d3_svg_lineCardinalOpen(points, tension) { ++ return points.length < 4 ? d3_svg_lineLinear(points) : points[1] + d3_svg_lineHermite(points.slice(1, -1), d3_svg_lineCardinalTangents(points, tension)); ++ } ++ function d3_svg_lineCardinalClosed(points, tension) { ++ return points.length < 3 ? d3_svg_lineLinearClosed(points) : points[0] + d3_svg_lineHermite((points.push(points[0]), ++ points), d3_svg_lineCardinalTangents([ points[points.length - 2] ].concat(points, [ points[1] ]), tension)); ++ } ++ function d3_svg_lineCardinal(points, tension) { ++ return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite(points, d3_svg_lineCardinalTangents(points, tension)); ++ } ++ function d3_svg_lineHermite(points, tangents) { ++ if (tangents.length < 1 || points.length != tangents.length && points.length != tangents.length + 2) { ++ return d3_svg_lineLinear(points); ++ } ++ var quad = points.length != tangents.length, path = "", p0 = points[0], p = points[1], t0 = tangents[0], t = t0, pi = 1; ++ if (quad) { ++ path += "Q" + (p[0] - t0[0] * 2 / 3) + "," + (p[1] - t0[1] * 2 / 3) + "," + p[0] + "," + p[1]; ++ p0 = points[1]; ++ pi = 2; ++ } ++ if (tangents.length > 1) { ++ t = tangents[1]; ++ p = points[pi]; ++ pi++; ++ path += "C" + (p0[0] + t0[0]) + "," + (p0[1] + t0[1]) + "," + (p[0] - t[0]) + "," + (p[1] - t[1]) + "," + p[0] + "," + p[1]; ++ for (var i = 2; i < tangents.length; i++, pi++) { ++ p = points[pi]; ++ t = tangents[i]; ++ path += "S" + (p[0] - t[0]) + "," + (p[1] - t[1]) + "," + p[0] + "," + p[1]; + } +- d3_layout_packTransform(root, w / 2, h / 2, radius ? 1 : 1 / Math.max(2 * root.r / w, 2 * root.r / h)); +- return nodes; + } +- pack.size = function(_) { +- if (!arguments.length) return size; +- size = _; +- return pack; +- }; +- pack.radius = function(_) { +- if (!arguments.length) return radius; +- radius = _ == null || typeof _ === "function" ? _ : +_; +- return pack; +- }; +- pack.padding = function(_) { +- if (!arguments.length) return padding; +- padding = +_; +- return pack; +- }; +- return d3_layout_hierarchyRebind(pack, hierarchy); +- }; +- function d3_layout_packSort(a, b) { +- return a.value - b.value; ++ if (quad) { ++ var lp = points[pi]; ++ path += "Q" + (p[0] + t[0] * 2 / 3) + "," + (p[1] + t[1] * 2 / 3) + "," + lp[0] + "," + lp[1]; ++ } ++ return path; + } +- function d3_layout_packInsert(a, b) { +- var c = a._pack_next; +- a._pack_next = b; +- b._pack_prev = a; +- b._pack_next = c; +- c._pack_prev = b; ++ function d3_svg_lineCardinalTangents(points, tension) { ++ var tangents = [], a = (1 - tension) / 2, p0, p1 = points[0], p2 = points[1], i = 1, n = points.length; ++ while (++i < n) { ++ p0 = p1; ++ p1 = p2; ++ p2 = points[i]; ++ tangents.push([ a * (p2[0] - p0[0]), a * (p2[1] - p0[1]) ]); ++ } ++ return tangents; + } +- function d3_layout_packSplice(a, b) { +- a._pack_next = b; +- b._pack_prev = a; ++ function d3_svg_lineBasis(points) { ++ if (points.length < 3) return d3_svg_lineLinear(points); ++ var i = 1, n = points.length, pi = points[0], x0 = pi[0], y0 = pi[1], px = [ x0, x0, x0, (pi = points[1])[0] ], py = [ y0, y0, y0, pi[1] ], path = [ x0, ",", y0, "L", d3_svg_lineDot4(d3_svg_lineBasisBezier3, px), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier3, py) ]; ++ points.push(points[n - 1]); ++ while (++i <= n) { ++ pi = points[i]; ++ px.shift(); ++ px.push(pi[0]); ++ py.shift(); ++ py.push(pi[1]); ++ d3_svg_lineBasisBezier(path, px, py); ++ } ++ points.pop(); ++ path.push("L", pi); ++ return path.join(""); + } +- function d3_layout_packIntersects(a, b) { +- var dx = b.x - a.x, dy = b.y - a.y, dr = a.r + b.r; +- return .999 * dr * dr > dx * dx + dy * dy; ++ function d3_svg_lineBasisOpen(points) { ++ if (points.length < 4) return d3_svg_lineLinear(points); ++ var path = [], i = -1, n = points.length, pi, px = [ 0 ], py = [ 0 ]; ++ while (++i < 3) { ++ pi = points[i]; ++ px.push(pi[0]); ++ py.push(pi[1]); ++ } ++ path.push(d3_svg_lineDot4(d3_svg_lineBasisBezier3, px) + "," + d3_svg_lineDot4(d3_svg_lineBasisBezier3, py)); ++ --i; ++ while (++i < n) { ++ pi = points[i]; ++ px.shift(); ++ px.push(pi[0]); ++ py.shift(); ++ py.push(pi[1]); ++ d3_svg_lineBasisBezier(path, px, py); ++ } ++ return path.join(""); + } +- function d3_layout_packSiblings(node) { +- if (!(nodes = node.children) || !(n = nodes.length)) return; +- var nodes, xMin = Infinity, xMax = -Infinity, yMin = Infinity, yMax = -Infinity, a, b, c, i, j, k, n; +- function bound(node) { +- xMin = Math.min(node.x - node.r, xMin); +- xMax = Math.max(node.x + node.r, xMax); +- yMin = Math.min(node.y - node.r, yMin); +- yMax = Math.max(node.y + node.r, yMax); ++ function d3_svg_lineBasisClosed(points) { ++ var path, i = -1, n = points.length, m = n + 4, pi, px = [], py = []; ++ while (++i < 4) { ++ pi = points[i % n]; ++ px.push(pi[0]); ++ py.push(pi[1]); + } +- nodes.forEach(d3_layout_packLink); +- a = nodes[0]; +- a.x = -a.r; +- a.y = 0; +- bound(a); +- if (n > 1) { +- b = nodes[1]; +- b.x = b.r; +- b.y = 0; +- bound(b); +- if (n > 2) { +- c = nodes[2]; +- d3_layout_packPlace(a, b, c); +- bound(c); +- d3_layout_packInsert(a, c); +- a._pack_prev = c; +- d3_layout_packInsert(c, b); +- b = a._pack_next; +- for (i = 3; i < n; i++) { +- d3_layout_packPlace(a, b, c = nodes[i]); +- var isect = 0, s1 = 1, s2 = 1; +- for (j = b._pack_next; j !== b; j = j._pack_next, s1++) { +- if (d3_layout_packIntersects(j, c)) { +- isect = 1; +- break; +- } +- } +- if (isect == 1) { +- for (k = a._pack_prev; k !== j._pack_prev; k = k._pack_prev, s2++) { +- if (d3_layout_packIntersects(k, c)) { +- break; +- } +- } +- } +- if (isect) { +- if (s1 < s2 || s1 == s2 && b.r < a.r) d3_layout_packSplice(a, b = j); else d3_layout_packSplice(a = k, b); +- i--; +- } else { +- d3_layout_packInsert(a, c); +- b = c; +- bound(c); +- } +- } +- } ++ path = [ d3_svg_lineDot4(d3_svg_lineBasisBezier3, px), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier3, py) ]; ++ --i; ++ while (++i < m) { ++ pi = points[i % n]; ++ px.shift(); ++ px.push(pi[0]); ++ py.shift(); ++ py.push(pi[1]); ++ d3_svg_lineBasisBezier(path, px, py); + } +- var cx = (xMin + xMax) / 2, cy = (yMin + yMax) / 2, cr = 0; +- for (i = 0; i < n; i++) { +- c = nodes[i]; +- c.x -= cx; +- c.y -= cy; +- cr = Math.max(cr, c.r + Math.sqrt(c.x * c.x + c.y * c.y)); ++ return path.join(""); ++ } ++ function d3_svg_lineBundle(points, tension) { ++ var n = points.length - 1; ++ if (n) { ++ var x0 = points[0][0], y0 = points[0][1], dx = points[n][0] - x0, dy = points[n][1] - y0, i = -1, p, t; ++ while (++i <= n) { ++ p = points[i]; ++ t = i / n; ++ p[0] = tension * p[0] + (1 - tension) * (x0 + t * dx); ++ p[1] = tension * p[1] + (1 - tension) * (y0 + t * dy); ++ } + } +- node.r = cr; +- nodes.forEach(d3_layout_packUnlink); ++ return d3_svg_lineBasis(points); + } +- function d3_layout_packLink(node) { +- node._pack_next = node._pack_prev = node; ++ function d3_svg_lineDot4(a, b) { ++ return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3]; + } +- function d3_layout_packUnlink(node) { +- delete node._pack_next; +- delete node._pack_prev; ++ var d3_svg_lineBasisBezier1 = [ 0, 2 / 3, 1 / 3, 0 ], d3_svg_lineBasisBezier2 = [ 0, 1 / 3, 2 / 3, 0 ], d3_svg_lineBasisBezier3 = [ 0, 1 / 6, 2 / 3, 1 / 6 ]; ++ function d3_svg_lineBasisBezier(path, x, y) { ++ path.push("C", d3_svg_lineDot4(d3_svg_lineBasisBezier1, x), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier1, y), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier2, x), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier2, y), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier3, x), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier3, y)); + } +- function d3_layout_packTransform(node, x, y, k) { +- var children = node.children; +- node.x = x += k * node.x; +- node.y = y += k * node.y; +- node.r *= k; +- if (children) { +- var i = -1, n = children.length; +- while (++i < n) d3_layout_packTransform(children[i], x, y, k); +- } ++ function d3_svg_lineSlope(p0, p1) { ++ return (p1[1] - p0[1]) / (p1[0] - p0[0]); + } +- function d3_layout_packPlace(a, b, c) { +- var db = a.r + c.r, dx = b.x - a.x, dy = b.y - a.y; +- if (db && (dx || dy)) { +- var da = b.r + c.r, dc = dx * dx + dy * dy; +- da *= da; +- db *= db; +- var x = .5 + (db - da) / (2 * dc), y = Math.sqrt(Math.max(0, 2 * da * (db + dc) - (db -= dc) * db - da * da)) / (2 * dc); +- c.x = a.x + x * dx + y * dy; +- c.y = a.y + x * dy - y * dx; +- } else { +- c.x = a.x + db; +- c.y = a.y; ++ function d3_svg_lineFiniteDifferences(points) { ++ var i = 0, j = points.length - 1, m = [], p0 = points[0], p1 = points[1], d = m[0] = d3_svg_lineSlope(p0, p1); ++ while (++i < j) { ++ m[i] = (d + (d = d3_svg_lineSlope(p0 = p1, p1 = points[i + 1]))) / 2; + } ++ m[i] = d; ++ return m; + } +- d3.layout.tree = function() { +- var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ], nodeSize = null; +- function tree(d, i) { +- var nodes = hierarchy.call(this, d, i), root0 = nodes[0], root1 = wrapTree(root0); +- d3_layout_hierarchyVisitAfter(root1, firstWalk), root1.parent.m = -root1.z; +- d3_layout_hierarchyVisitBefore(root1, secondWalk); +- if (nodeSize) d3_layout_hierarchyVisitBefore(root0, sizeNode); else { +- var left = root0, right = root0, bottom = root0; +- d3_layout_hierarchyVisitBefore(root0, function(node) { +- if (node.x < left.x) left = node; +- if (node.x > right.x) right = node; +- if (node.depth > bottom.depth) bottom = node; +- }); +- var tx = separation(left, right) / 2 - left.x, kx = size[0] / (right.x + separation(right, left) / 2 + tx), ky = size[1] / (bottom.depth || 1); +- d3_layout_hierarchyVisitBefore(root0, function(node) { +- node.x = (node.x + tx) * kx; +- node.y = node.depth * ky; +- }); +- } +- return nodes; +- } +- function wrapTree(root0) { +- var root1 = { +- A: null, +- children: [ root0 ] +- }, queue = [ root1 ], node1; +- while ((node1 = queue.pop()) != null) { +- for (var children = node1.children, child, i = 0, n = children.length; i < n; ++i) { +- queue.push((children[i] = child = { +- _: children[i], +- parent: node1, +- children: (child = children[i].children) && child.slice() || [], +- A: null, +- a: null, +- z: 0, +- m: 0, +- c: 0, +- s: 0, +- t: null, +- i: i +- }).a = child); ++ function d3_svg_lineMonotoneTangents(points) { ++ var tangents = [], d, a, b, s, m = d3_svg_lineFiniteDifferences(points), i = -1, j = points.length - 1; ++ while (++i < j) { ++ d = d3_svg_lineSlope(points[i], points[i + 1]); ++ if (abs(d) < ε) { ++ m[i] = m[i + 1] = 0; ++ } else { ++ a = m[i] / d; ++ b = m[i + 1] / d; ++ s = a * a + b * b; ++ if (s > 9) { ++ s = d * 3 / Math.sqrt(s); ++ m[i] = s * a; ++ m[i + 1] = s * b; + } + } +- return root1.children[0]; + } +- function firstWalk(v) { +- var children = v.children, siblings = v.parent.children, w = v.i ? siblings[v.i - 1] : null; +- if (children.length) { +- d3_layout_treeShift(v); +- var midpoint = (children[0].z + children[children.length - 1].z) / 2; +- if (w) { +- v.z = w.z + separation(v._, w._); +- v.m = v.z - midpoint; +- } else { +- v.z = midpoint; +- } +- } else if (w) { +- v.z = w.z + separation(v._, w._); +- } +- v.parent.A = apportion(v, w, v.parent.A || siblings[0]); ++ i = -1; ++ while (++i <= j) { ++ s = (points[Math.min(j, i + 1)][0] - points[Math.max(0, i - 1)][0]) / (6 * (1 + m[i] * m[i])); ++ tangents.push([ s || 0, m[i] * s || 0 ]); + } +- function secondWalk(v) { +- v._.x = v.z + v.parent.m; +- v.m += v.parent.m; ++ return tangents; ++ } ++ function d3_svg_lineMonotone(points) { ++ return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite(points, d3_svg_lineMonotoneTangents(points)); ++ } ++ d3.svg.line.radial = function() { ++ var line = d3_svg_line(d3_svg_lineRadial); ++ line.radius = line.x, delete line.x; ++ line.angle = line.y, delete line.y; ++ return line; ++ }; ++ function d3_svg_lineRadial(points) { ++ var point, i = -1, n = points.length, r, a; ++ while (++i < n) { ++ point = points[i]; ++ r = point[0]; ++ a = point[1] - halfπ; ++ point[0] = r * Math.cos(a); ++ point[1] = r * Math.sin(a); + } +- function apportion(v, w, ancestor) { +- if (w) { +- var vip = v, vop = v, vim = w, vom = vip.parent.children[0], sip = vip.m, sop = vop.m, sim = vim.m, som = vom.m, shift; +- while (vim = d3_layout_treeRight(vim), vip = d3_layout_treeLeft(vip), vim && vip) { +- vom = d3_layout_treeLeft(vom); +- vop = d3_layout_treeRight(vop); +- vop.a = v; +- shift = vim.z + sim - vip.z - sip + separation(vim._, vip._); +- if (shift > 0) { +- d3_layout_treeMove(d3_layout_treeAncestor(vim, v, ancestor), v, shift); +- sip += shift; +- sop += shift; +- } +- sim += vim.m; +- sip += vip.m; +- som += vom.m; +- sop += vop.m; +- } +- if (vim && !d3_layout_treeRight(vop)) { +- vop.t = vim; +- vop.m += sim - sop; +- } +- if (vip && !d3_layout_treeLeft(vom)) { +- vom.t = vip; +- vom.m += sip - som; +- ancestor = v; ++ return points; ++ } ++ function d3_svg_area(projection) { ++ var x0 = d3_geom_pointX, x1 = d3_geom_pointX, y0 = 0, y1 = d3_geom_pointY, defined = d3_true, interpolate = d3_svg_lineLinear, interpolateKey = interpolate.key, interpolateReverse = interpolate, L = "L", tension = .7; ++ function area(data) { ++ var segments = [], points0 = [], points1 = [], i = -1, n = data.length, d, fx0 = d3_functor(x0), fy0 = d3_functor(y0), fx1 = x0 === x1 ? function() { ++ return x; ++ } : d3_functor(x1), fy1 = y0 === y1 ? function() { ++ return y; ++ } : d3_functor(y1), x, y; ++ function segment() { ++ segments.push("M", interpolate(projection(points1), tension), L, interpolateReverse(projection(points0.reverse()), tension), "Z"); ++ } ++ while (++i < n) { ++ if (defined.call(this, d = data[i], i)) { ++ points0.push([ x = +fx0.call(this, d, i), y = +fy0.call(this, d, i) ]); ++ points1.push([ +fx1.call(this, d, i), +fy1.call(this, d, i) ]); ++ } else if (points0.length) { ++ segment(); ++ points0 = []; ++ points1 = []; + } + } +- return ancestor; ++ if (points0.length) segment(); ++ return segments.length ? segments.join("") : null; + } +- function sizeNode(node) { +- node.x *= size[0]; +- node.y = node.depth * size[1]; ++ area.x = function(_) { ++ if (!arguments.length) return x1; ++ x0 = x1 = _; ++ return area; ++ }; ++ area.x0 = function(_) { ++ if (!arguments.length) return x0; ++ x0 = _; ++ return area; ++ }; ++ area.x1 = function(_) { ++ if (!arguments.length) return x1; ++ x1 = _; ++ return area; ++ }; ++ area.y = function(_) { ++ if (!arguments.length) return y1; ++ y0 = y1 = _; ++ return area; ++ }; ++ area.y0 = function(_) { ++ if (!arguments.length) return y0; ++ y0 = _; ++ return area; ++ }; ++ area.y1 = function(_) { ++ if (!arguments.length) return y1; ++ y1 = _; ++ return area; ++ }; ++ area.defined = function(_) { ++ if (!arguments.length) return defined; ++ defined = _; ++ return area; ++ }; ++ area.interpolate = function(_) { ++ if (!arguments.length) return interpolateKey; ++ if (typeof _ === "function") interpolateKey = interpolate = _; else interpolateKey = (interpolate = d3_svg_lineInterpolators.get(_) || d3_svg_lineLinear).key; ++ interpolateReverse = interpolate.reverse || interpolate; ++ L = interpolate.closed ? "M" : "L"; ++ return area; ++ }; ++ area.tension = function(_) { ++ if (!arguments.length) return tension; ++ tension = _; ++ return area; ++ }; ++ return area; ++ } ++ d3_svg_lineStepBefore.reverse = d3_svg_lineStepAfter; ++ d3_svg_lineStepAfter.reverse = d3_svg_lineStepBefore; ++ d3.svg.area = function() { ++ return d3_svg_area(d3_identity); ++ }; ++ d3.svg.area.radial = function() { ++ var area = d3_svg_area(d3_svg_lineRadial); ++ area.radius = area.x, delete area.x; ++ area.innerRadius = area.x0, delete area.x0; ++ area.outerRadius = area.x1, delete area.x1; ++ area.angle = area.y, delete area.y; ++ area.startAngle = area.y0, delete area.y0; ++ area.endAngle = area.y1, delete area.y1; ++ return area; ++ }; ++ d3.svg.chord = function() { ++ var source = d3_source, target = d3_target, radius = d3_svg_chordRadius, startAngle = d3_svg_arcStartAngle, endAngle = d3_svg_arcEndAngle; ++ function chord(d, i) { ++ var s = subgroup(this, source, d, i), t = subgroup(this, target, d, i); ++ return "M" + s.p0 + arc(s.r, s.p1, s.a1 - s.a0) + (equals(s, t) ? curve(s.r, s.p1, s.r, s.p0) : curve(s.r, s.p1, t.r, t.p0) + arc(t.r, t.p1, t.a1 - t.a0) + curve(t.r, t.p1, s.r, s.p0)) + "Z"; + } +- tree.separation = function(x) { +- if (!arguments.length) return separation; +- separation = x; +- return tree; ++ function subgroup(self, f, d, i) { ++ var subgroup = f.call(self, d, i), r = radius.call(self, subgroup, i), a0 = startAngle.call(self, subgroup, i) - halfπ, a1 = endAngle.call(self, subgroup, i) - halfπ; ++ return { ++ r: r, ++ a0: a0, ++ a1: a1, ++ p0: [ r * Math.cos(a0), r * Math.sin(a0) ], ++ p1: [ r * Math.cos(a1), r * Math.sin(a1) ] ++ }; ++ } ++ function equals(a, b) { ++ return a.a0 == b.a0 && a.a1 == b.a1; ++ } ++ function arc(r, p, a) { ++ return "A" + r + "," + r + " 0 " + +(a > π) + ",1 " + p; ++ } ++ function curve(r0, p0, r1, p1) { ++ return "Q 0,0 " + p1; ++ } ++ chord.radius = function(v) { ++ if (!arguments.length) return radius; ++ radius = d3_functor(v); ++ return chord; + }; +- tree.size = function(x) { +- if (!arguments.length) return nodeSize ? null : size; +- nodeSize = (size = x) == null ? sizeNode : null; +- return tree; ++ chord.source = function(v) { ++ if (!arguments.length) return source; ++ source = d3_functor(v); ++ return chord; + }; +- tree.nodeSize = function(x) { +- if (!arguments.length) return nodeSize ? size : null; +- nodeSize = (size = x) == null ? null : sizeNode; +- return tree; ++ chord.target = function(v) { ++ if (!arguments.length) return target; ++ target = d3_functor(v); ++ return chord; + }; +- return d3_layout_hierarchyRebind(tree, hierarchy); ++ chord.startAngle = function(v) { ++ if (!arguments.length) return startAngle; ++ startAngle = d3_functor(v); ++ return chord; ++ }; ++ chord.endAngle = function(v) { ++ if (!arguments.length) return endAngle; ++ endAngle = d3_functor(v); ++ return chord; ++ }; ++ return chord; + }; +- function d3_layout_treeSeparation(a, b) { +- return a.parent == b.parent ? 1 : 2; +- } +- function d3_layout_treeLeft(v) { +- var children = v.children; +- return children.length ? children[0] : v.t; +- } +- function d3_layout_treeRight(v) { +- var children = v.children, n; +- return (n = children.length) ? children[n - 1] : v.t; +- } +- function d3_layout_treeMove(wm, wp, shift) { +- var change = shift / (wp.i - wm.i); +- wp.c -= change; +- wp.s += shift; +- wm.c += change; +- wp.z += shift; +- wp.m += shift; ++ function d3_svg_chordRadius(d) { ++ return d.radius; + } +- function d3_layout_treeShift(v) { +- var shift = 0, change = 0, children = v.children, i = children.length, w; +- while (--i >= 0) { +- w = children[i]; +- w.z += shift; +- w.m += shift; +- shift += w.s + (change += w.c); ++ d3.svg.diagonal = function() { ++ var source = d3_source, target = d3_target, projection = d3_svg_diagonalProjection; ++ function diagonal(d, i) { ++ var p0 = source.call(this, d, i), p3 = target.call(this, d, i), m = (p0.y + p3.y) / 2, p = [ p0, { ++ x: p0.x, ++ y: m ++ }, { ++ x: p3.x, ++ y: m ++ }, p3 ]; ++ p = p.map(projection); ++ return "M" + p[0] + "C" + p[1] + " " + p[2] + " " + p[3]; + } ++ diagonal.source = function(x) { ++ if (!arguments.length) return source; ++ source = d3_functor(x); ++ return diagonal; ++ }; ++ diagonal.target = function(x) { ++ if (!arguments.length) return target; ++ target = d3_functor(x); ++ return diagonal; ++ }; ++ diagonal.projection = function(x) { ++ if (!arguments.length) return projection; ++ projection = x; ++ return diagonal; ++ }; ++ return diagonal; ++ }; ++ function d3_svg_diagonalProjection(d) { ++ return [ d.x, d.y ]; + } +- function d3_layout_treeAncestor(vim, v, ancestor) { +- return vim.a.parent === v.parent ? vim.a : ancestor; ++ d3.svg.diagonal.radial = function() { ++ var diagonal = d3.svg.diagonal(), projection = d3_svg_diagonalProjection, projection_ = diagonal.projection; ++ diagonal.projection = function(x) { ++ return arguments.length ? projection_(d3_svg_diagonalRadialProjection(projection = x)) : projection; ++ }; ++ return diagonal; ++ }; ++ function d3_svg_diagonalRadialProjection(projection) { ++ return function() { ++ var d = projection.apply(this, arguments), r = d[0], a = d[1] - halfπ; ++ return [ r * Math.cos(a), r * Math.sin(a) ]; ++ }; + } +- d3.layout.cluster = function() { +- var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ], nodeSize = false; +- function cluster(d, i) { +- var nodes = hierarchy.call(this, d, i), root = nodes[0], previousNode, x = 0; +- d3_layout_hierarchyVisitAfter(root, function(node) { +- var children = node.children; +- if (children && children.length) { +- node.x = d3_layout_clusterX(children); +- node.y = d3_layout_clusterY(children); +- } else { +- node.x = previousNode ? x += separation(node, previousNode) : 0; +- node.y = 0; +- previousNode = node; +- } +- }); +- var left = d3_layout_clusterLeft(root), right = d3_layout_clusterRight(root), x0 = left.x - separation(left, right) / 2, x1 = right.x + separation(right, left) / 2; +- d3_layout_hierarchyVisitAfter(root, nodeSize ? function(node) { +- node.x = (node.x - root.x) * size[0]; +- node.y = (root.y - node.y) * size[1]; +- } : function(node) { +- node.x = (node.x - x0) / (x1 - x0) * size[0]; +- node.y = (1 - (root.y ? node.y / root.y : 1)) * size[1]; +- }); +- return nodes; ++ d3.svg.symbol = function() { ++ var type = d3_svg_symbolType, size = d3_svg_symbolSize; ++ function symbol(d, i) { ++ return (d3_svg_symbols.get(type.call(this, d, i)) || d3_svg_symbolCircle)(size.call(this, d, i)); + } +- cluster.separation = function(x) { +- if (!arguments.length) return separation; +- separation = x; +- return cluster; ++ symbol.type = function(x) { ++ if (!arguments.length) return type; ++ type = d3_functor(x); ++ return symbol; + }; +- cluster.size = function(x) { +- if (!arguments.length) return nodeSize ? null : size; +- nodeSize = (size = x) == null; +- return cluster; ++ symbol.size = function(x) { ++ if (!arguments.length) return size; ++ size = d3_functor(x); ++ return symbol; + }; +- cluster.nodeSize = function(x) { +- if (!arguments.length) return nodeSize ? size : null; +- nodeSize = (size = x) != null; +- return cluster; ++ return symbol; ++ }; ++ function d3_svg_symbolSize() { ++ return 64; ++ } ++ function d3_svg_symbolType() { ++ return "circle"; ++ } ++ function d3_svg_symbolCircle(size) { ++ var r = Math.sqrt(size / π); ++ return "M0," + r + "A" + r + "," + r + " 0 1,1 0," + -r + "A" + r + "," + r + " 0 1,1 0," + r + "Z"; ++ } ++ var d3_svg_symbols = d3.map({ ++ circle: d3_svg_symbolCircle, ++ cross: function(size) { ++ var r = Math.sqrt(size / 5) / 2; ++ return "M" + -3 * r + "," + -r + "H" + -r + "V" + -3 * r + "H" + r + "V" + -r + "H" + 3 * r + "V" + r + "H" + r + "V" + 3 * r + "H" + -r + "V" + r + "H" + -3 * r + "Z"; ++ }, ++ diamond: function(size) { ++ var ry = Math.sqrt(size / (2 * d3_svg_symbolTan30)), rx = ry * d3_svg_symbolTan30; ++ return "M0," + -ry + "L" + rx + ",0" + " 0," + ry + " " + -rx + ",0" + "Z"; ++ }, ++ square: function(size) { ++ var r = Math.sqrt(size) / 2; ++ return "M" + -r + "," + -r + "L" + r + "," + -r + " " + r + "," + r + " " + -r + "," + r + "Z"; ++ }, ++ "triangle-down": function(size) { ++ var rx = Math.sqrt(size / d3_svg_symbolSqrt3), ry = rx * d3_svg_symbolSqrt3 / 2; ++ return "M0," + ry + "L" + rx + "," + -ry + " " + -rx + "," + -ry + "Z"; ++ }, ++ "triangle-up": function(size) { ++ var rx = Math.sqrt(size / d3_svg_symbolSqrt3), ry = rx * d3_svg_symbolSqrt3 / 2; ++ return "M0," + -ry + "L" + rx + "," + ry + " " + -rx + "," + ry + "Z"; ++ } ++ }); ++ d3.svg.symbolTypes = d3_svg_symbols.keys(); ++ var d3_svg_symbolSqrt3 = Math.sqrt(3), d3_svg_symbolTan30 = Math.tan(30 * d3_radians); ++ d3_selectionPrototype.transition = function(name) { ++ var id = d3_transitionInheritId || ++d3_transitionId, ns = d3_transitionNamespace(name), subgroups = [], subgroup, node, transition = d3_transitionInherit || { ++ time: Date.now(), ++ ease: d3_ease_cubicInOut, ++ delay: 0, ++ duration: 250 + }; +- return d3_layout_hierarchyRebind(cluster, hierarchy); ++ for (var j = -1, m = this.length; ++j < m; ) { ++ subgroups.push(subgroup = []); ++ for (var group = this[j], i = -1, n = group.length; ++i < n; ) { ++ if (node = group[i]) d3_transitionNode(node, i, ns, id, transition); ++ subgroup.push(node); ++ } ++ } ++ return d3_transition(subgroups, ns, id); ++ }; ++ d3_selectionPrototype.interrupt = function(name) { ++ return this.each(name == null ? d3_selection_interrupt : d3_selection_interruptNS(d3_transitionNamespace(name))); + }; +- function d3_layout_clusterY(children) { +- return 1 + d3.max(children, function(child) { +- return child.y; +- }); +- } +- function d3_layout_clusterX(children) { +- return children.reduce(function(x, child) { +- return x + child.x; +- }, 0) / children.length; +- } +- function d3_layout_clusterLeft(node) { +- var children = node.children; +- return children && children.length ? d3_layout_clusterLeft(children[0]) : node; ++ var d3_selection_interrupt = d3_selection_interruptNS(d3_transitionNamespace()); ++ function d3_selection_interruptNS(ns) { ++ return function() { ++ var lock, activeId, active; ++ if ((lock = this[ns]) && (active = lock[activeId = lock.active])) { ++ active.timer.c = null; ++ active.timer.t = NaN; ++ if (--lock.count) delete lock[activeId]; else delete this[ns]; ++ lock.active += .5; ++ active.event && active.event.interrupt.call(this, this.__data__, active.index); ++ } ++ }; + } +- function d3_layout_clusterRight(node) { +- var children = node.children, n; +- return children && (n = children.length) ? d3_layout_clusterRight(children[n - 1]) : node; ++ function d3_transition(groups, ns, id) { ++ d3_subclass(groups, d3_transitionPrototype); ++ groups.namespace = ns; ++ groups.id = id; ++ return groups; + } +- d3.layout.treemap = function() { +- var hierarchy = d3.layout.hierarchy(), round = Math.round, size = [ 1, 1 ], padding = null, pad = d3_layout_treemapPadNull, sticky = false, stickies, mode = "squarify", ratio = .5 * (1 + Math.sqrt(5)); +- function scale(children, k) { +- var i = -1, n = children.length, child, area; +- while (++i < n) { +- area = (child = children[i]).value * (k < 0 ? 0 : k); +- child.area = isNaN(area) || area <= 0 ? 0 : area; +- } +- } +- function squarify(node) { +- var children = node.children; +- if (children && children.length) { +- var rect = pad(node), row = [], remaining = children.slice(), child, best = Infinity, score, u = mode === "slice" ? rect.dx : mode === "dice" ? rect.dy : mode === "slice-dice" ? node.depth & 1 ? rect.dy : rect.dx : Math.min(rect.dx, rect.dy), n; +- scale(remaining, rect.dx * rect.dy / node.value); +- row.area = 0; +- while ((n = remaining.length) > 0) { +- row.push(child = remaining[n - 1]); +- row.area += child.area; +- if (mode !== "squarify" || (score = worst(row, u)) <= best) { +- remaining.pop(); +- best = score; +- } else { +- row.area -= row.pop().area; +- position(row, u, rect, false); +- u = Math.min(rect.dx, rect.dy); +- row.length = row.area = 0; +- best = Infinity; +- } +- } +- if (row.length) { +- position(row, u, rect, true); +- row.length = row.area = 0; ++ var d3_transitionPrototype = [], d3_transitionId = 0, d3_transitionInheritId, d3_transitionInherit; ++ d3_transitionPrototype.call = d3_selectionPrototype.call; ++ d3_transitionPrototype.empty = d3_selectionPrototype.empty; ++ d3_transitionPrototype.node = d3_selectionPrototype.node; ++ d3_transitionPrototype.size = d3_selectionPrototype.size; ++ d3.transition = function(selection, name) { ++ return selection && selection.transition ? d3_transitionInheritId ? selection.transition(name) : selection : d3.selection().transition(selection); ++ }; ++ d3.transition.prototype = d3_transitionPrototype; ++ d3_transitionPrototype.select = function(selector) { ++ var id = this.id, ns = this.namespace, subgroups = [], subgroup, subnode, node; ++ selector = d3_selection_selector(selector); ++ for (var j = -1, m = this.length; ++j < m; ) { ++ subgroups.push(subgroup = []); ++ for (var group = this[j], i = -1, n = group.length; ++i < n; ) { ++ if ((node = group[i]) && (subnode = selector.call(node, node.__data__, i, j))) { ++ if ("__data__" in node) subnode.__data__ = node.__data__; ++ d3_transitionNode(subnode, i, ns, id, node[ns][id]); ++ subgroup.push(subnode); ++ } else { ++ subgroup.push(null); + } +- children.forEach(squarify); + } + } +- function stickify(node) { +- var children = node.children; +- if (children && children.length) { +- var rect = pad(node), remaining = children.slice(), child, row = []; +- scale(remaining, rect.dx * rect.dy / node.value); +- row.area = 0; +- while (child = remaining.pop()) { +- row.push(child); +- row.area += child.area; +- if (child.z != null) { +- position(row, child.z ? rect.dx : rect.dy, rect, !remaining.length); +- row.length = row.area = 0; ++ return d3_transition(subgroups, ns, id); ++ }; ++ d3_transitionPrototype.selectAll = function(selector) { ++ var id = this.id, ns = this.namespace, subgroups = [], subgroup, subnodes, node, subnode, transition; ++ selector = d3_selection_selectorAll(selector); ++ for (var j = -1, m = this.length; ++j < m; ) { ++ for (var group = this[j], i = -1, n = group.length; ++i < n; ) { ++ if (node = group[i]) { ++ transition = node[ns][id]; ++ subnodes = selector.call(node, node.__data__, i, j); ++ subgroups.push(subgroup = []); ++ for (var k = -1, o = subnodes.length; ++k < o; ) { ++ if (subnode = subnodes[k]) d3_transitionNode(subnode, k, ns, id, transition); ++ subgroup.push(subnode); + } + } +- children.forEach(stickify); +- } +- } +- function worst(row, u) { +- var s = row.area, r, rmax = 0, rmin = Infinity, i = -1, n = row.length; +- while (++i < n) { +- if (!(r = row[i].area)) continue; +- if (r < rmin) rmin = r; +- if (r > rmax) rmax = r; + } +- s *= s; +- u *= u; +- return s ? Math.max(u * rmax * ratio / s, s / (u * rmin * ratio)) : Infinity; + } +- function position(row, u, rect, flush) { +- var i = -1, n = row.length, x = rect.x, y = rect.y, v = u ? round(row.area / u) : 0, o; +- if (u == rect.dx) { +- if (flush || v > rect.dy) v = rect.dy; +- while (++i < n) { +- o = row[i]; +- o.x = x; +- o.y = y; +- o.dy = v; +- x += o.dx = Math.min(rect.x + rect.dx - x, v ? round(o.area / v) : 0); +- } +- o.z = true; +- o.dx += rect.x + rect.dx - x; +- rect.y += v; +- rect.dy -= v; +- } else { +- if (flush || v > rect.dx) v = rect.dx; +- while (++i < n) { +- o = row[i]; +- o.x = x; +- o.y = y; +- o.dx = v; +- y += o.dy = Math.min(rect.y + rect.dy - y, v ? round(o.area / v) : 0); ++ return d3_transition(subgroups, ns, id); ++ }; ++ d3_transitionPrototype.filter = function(filter) { ++ var subgroups = [], subgroup, group, node; ++ if (typeof filter !== "function") filter = d3_selection_filter(filter); ++ for (var j = 0, m = this.length; j < m; j++) { ++ subgroups.push(subgroup = []); ++ for (var group = this[j], i = 0, n = group.length; i < n; i++) { ++ if ((node = group[i]) && filter.call(node, node.__data__, i, j)) { ++ subgroup.push(node); + } +- o.z = false; +- o.dy += rect.y + rect.dy - y; +- rect.x += v; +- rect.dx -= v; + } + } +- function treemap(d) { +- var nodes = stickies || hierarchy(d), root = nodes[0]; +- root.x = root.y = 0; +- if (root.value) root.dx = size[0], root.dy = size[1]; else root.dx = root.dy = 0; +- if (stickies) hierarchy.revalue(root); +- scale([ root ], root.dx * root.dy / root.value); +- (stickies ? stickify : squarify)(root); +- if (sticky) stickies = nodes; +- return nodes; +- } +- treemap.size = function(x) { +- if (!arguments.length) return size; +- size = x; +- return treemap; +- }; +- treemap.padding = function(x) { +- if (!arguments.length) return padding; +- function padFunction(node) { +- var p = x.call(treemap, node, node.depth); +- return p == null ? d3_layout_treemapPadNull(node) : d3_layout_treemapPad(node, typeof p === "number" ? [ p, p, p, p ] : p); +- } +- function padConstant(node) { +- return d3_layout_treemapPad(node, x); +- } +- var type; +- pad = (padding = x) == null ? d3_layout_treemapPadNull : (type = typeof x) === "function" ? padFunction : type === "number" ? (x = [ x, x, x, x ], +- padConstant) : padConstant; +- return treemap; +- }; +- treemap.round = function(x) { +- if (!arguments.length) return round != Number; +- round = x ? Math.round : Number; +- return treemap; +- }; +- treemap.sticky = function(x) { +- if (!arguments.length) return sticky; +- sticky = x; +- stickies = null; +- return treemap; +- }; +- treemap.ratio = function(x) { +- if (!arguments.length) return ratio; +- ratio = x; +- return treemap; +- }; +- treemap.mode = function(x) { +- if (!arguments.length) return mode; +- mode = x + ""; +- return treemap; +- }; +- return d3_layout_hierarchyRebind(treemap, hierarchy); ++ return d3_transition(subgroups, this.namespace, this.id); + }; +- function d3_layout_treemapPadNull(node) { +- return { +- x: node.x, +- y: node.y, +- dx: node.dx, +- dy: node.dy +- }; ++ d3_transitionPrototype.tween = function(name, tween) { ++ var id = this.id, ns = this.namespace; ++ if (arguments.length < 2) return this.node()[ns][id].tween.get(name); ++ return d3_selection_each(this, tween == null ? function(node) { ++ node[ns][id].tween.remove(name); ++ } : function(node) { ++ node[ns][id].tween.set(name, tween); ++ }); ++ }; ++ function d3_transition_tween(groups, name, value, tween) { ++ var id = groups.id, ns = groups.namespace; ++ return d3_selection_each(groups, typeof value === "function" ? function(node, i, j) { ++ node[ns][id].tween.set(name, tween(value.call(node, node.__data__, i, j))); ++ } : (value = tween(value), function(node) { ++ node[ns][id].tween.set(name, value); ++ })); + } +- function d3_layout_treemapPad(node, padding) { +- var x = node.x + padding[3], y = node.y + padding[0], dx = node.dx - padding[1] - padding[3], dy = node.dy - padding[0] - padding[2]; +- if (dx < 0) { +- x += dx / 2; +- dx = 0; ++ d3_transitionPrototype.attr = function(nameNS, value) { ++ if (arguments.length < 2) { ++ for (value in nameNS) this.attr(value, nameNS[value]); ++ return this; + } +- if (dy < 0) { +- y += dy / 2; +- dy = 0; ++ var interpolate = nameNS == "transform" ? d3_interpolateTransform : d3_interpolate, name = d3.ns.qualify(nameNS); ++ function attrNull() { ++ this.removeAttribute(name); + } +- return { +- x: x, +- y: y, +- dx: dx, +- dy: dy +- }; +- } +- d3.random = { +- normal: function(µ, σ) { +- var n = arguments.length; +- if (n < 2) σ = 1; +- if (n < 1) µ = 0; +- return function() { +- var x, y, r; +- do { +- x = Math.random() * 2 - 1; +- y = Math.random() * 2 - 1; +- r = x * x + y * y; +- } while (!r || r > 1); +- return µ + σ * x * Math.sqrt(-2 * Math.log(r) / r); +- }; +- }, +- logNormal: function() { +- var random = d3.random.normal.apply(d3, arguments); +- return function() { +- return Math.exp(random()); ++ function attrNullNS() { ++ this.removeAttributeNS(name.space, name.local); ++ } ++ function attrTween(b) { ++ return b == null ? attrNull : (b += "", function() { ++ var a = this.getAttribute(name), i; ++ return a !== b && (i = interpolate(a, b), function(t) { ++ this.setAttribute(name, i(t)); ++ }); ++ }); ++ } ++ function attrTweenNS(b) { ++ return b == null ? attrNullNS : (b += "", function() { ++ var a = this.getAttributeNS(name.space, name.local), i; ++ return a !== b && (i = interpolate(a, b), function(t) { ++ this.setAttributeNS(name.space, name.local, i(t)); ++ }); ++ }); ++ } ++ return d3_transition_tween(this, "attr." + nameNS, value, name.local ? attrTweenNS : attrTween); ++ }; ++ d3_transitionPrototype.attrTween = function(nameNS, tween) { ++ var name = d3.ns.qualify(nameNS); ++ function attrTween(d, i) { ++ var f = tween.call(this, d, i, this.getAttribute(name)); ++ return f && function(t) { ++ this.setAttribute(name, f(t)); + }; +- }, +- bates: function(m) { +- var random = d3.random.irwinHall(m); +- return function() { +- return random() / m; ++ } ++ function attrTweenNS(d, i) { ++ var f = tween.call(this, d, i, this.getAttributeNS(name.space, name.local)); ++ return f && function(t) { ++ this.setAttributeNS(name.space, name.local, f(t)); + }; +- }, +- irwinHall: function(m) { +- return function() { +- for (var s = 0, j = 0; j < m; j++) s += Math.random(); +- return s; ++ } ++ return this.tween("attr." + nameNS, name.local ? attrTweenNS : attrTween); ++ }; ++ d3_transitionPrototype.style = function(name, value, priority) { ++ var n = arguments.length; ++ if (n < 3) { ++ if (typeof name !== "string") { ++ if (n < 2) value = ""; ++ for (priority in name) this.style(priority, name[priority], value); ++ return this; ++ } ++ priority = ""; ++ } ++ function styleNull() { ++ this.style.removeProperty(name); ++ } ++ function styleString(b) { ++ return b == null ? styleNull : (b += "", function() { ++ var a = d3_window(this).getComputedStyle(this, null).getPropertyValue(name), i; ++ return a !== b && (i = d3_interpolate(a, b), function(t) { ++ this.style.setProperty(name, i(t), priority); ++ }); ++ }); ++ } ++ return d3_transition_tween(this, "style." + name, value, styleString); ++ }; ++ d3_transitionPrototype.styleTween = function(name, tween, priority) { ++ if (arguments.length < 3) priority = ""; ++ function styleTween(d, i) { ++ var f = tween.call(this, d, i, d3_window(this).getComputedStyle(this, null).getPropertyValue(name)); ++ return f && function(t) { ++ this.style.setProperty(name, f(t), priority); + }; + } ++ return this.tween("style." + name, styleTween); + }; +- d3.scale = {}; +- function d3_scaleExtent(domain) { +- var start = domain[0], stop = domain[domain.length - 1]; +- return start < stop ? [ start, stop ] : [ stop, start ]; +- } +- function d3_scaleRange(scale) { +- return scale.rangeExtent ? scale.rangeExtent() : d3_scaleExtent(scale.range()); +- } +- function d3_scale_bilinear(domain, range, uninterpolate, interpolate) { +- var u = uninterpolate(domain[0], domain[1]), i = interpolate(range[0], range[1]); +- return function(x) { +- return i(u(x)); ++ d3_transitionPrototype.text = function(value) { ++ return d3_transition_tween(this, "text", value, d3_transition_text); ++ }; ++ function d3_transition_text(b) { ++ if (b == null) b = ""; ++ return function() { ++ this.textContent = b; + }; + } +- function d3_scale_nice(domain, nice) { +- var i0 = 0, i1 = domain.length - 1, x0 = domain[i0], x1 = domain[i1], dx; +- if (x1 < x0) { +- dx = i0, i0 = i1, i1 = dx; +- dx = x0, x0 = x1, x1 = dx; ++ d3_transitionPrototype.remove = function() { ++ var ns = this.namespace; ++ return this.each("end.transition", function() { ++ var p; ++ if (this[ns].count < 2 && (p = this.parentNode)) p.removeChild(this); ++ }); ++ }; ++ d3_transitionPrototype.ease = function(value) { ++ var id = this.id, ns = this.namespace; ++ if (arguments.length < 1) return this.node()[ns][id].ease; ++ if (typeof value !== "function") value = d3.ease.apply(d3, arguments); ++ return d3_selection_each(this, function(node) { ++ node[ns][id].ease = value; ++ }); ++ }; ++ d3_transitionPrototype.delay = function(value) { ++ var id = this.id, ns = this.namespace; ++ if (arguments.length < 1) return this.node()[ns][id].delay; ++ return d3_selection_each(this, typeof value === "function" ? function(node, i, j) { ++ node[ns][id].delay = +value.call(node, node.__data__, i, j); ++ } : (value = +value, function(node) { ++ node[ns][id].delay = value; ++ })); ++ }; ++ d3_transitionPrototype.duration = function(value) { ++ var id = this.id, ns = this.namespace; ++ if (arguments.length < 1) return this.node()[ns][id].duration; ++ return d3_selection_each(this, typeof value === "function" ? function(node, i, j) { ++ node[ns][id].duration = Math.max(1, value.call(node, node.__data__, i, j)); ++ } : (value = Math.max(1, value), function(node) { ++ node[ns][id].duration = value; ++ })); ++ }; ++ d3_transitionPrototype.each = function(type, listener) { ++ var id = this.id, ns = this.namespace; ++ if (arguments.length < 2) { ++ var inherit = d3_transitionInherit, inheritId = d3_transitionInheritId; ++ try { ++ d3_transitionInheritId = id; ++ d3_selection_each(this, function(node, i, j) { ++ d3_transitionInherit = node[ns][id]; ++ type.call(node, node.__data__, i, j); ++ }); ++ } finally { ++ d3_transitionInherit = inherit; ++ d3_transitionInheritId = inheritId; ++ } ++ } else { ++ d3_selection_each(this, function(node) { ++ var transition = node[ns][id]; ++ (transition.event || (transition.event = d3.dispatch("start", "end", "interrupt"))).on(type, listener); ++ }); + } +- domain[i0] = nice.floor(x0); +- domain[i1] = nice.ceil(x1); +- return domain; ++ return this; ++ }; ++ d3_transitionPrototype.transition = function() { ++ var id0 = this.id, id1 = ++d3_transitionId, ns = this.namespace, subgroups = [], subgroup, group, node, transition; ++ for (var j = 0, m = this.length; j < m; j++) { ++ subgroups.push(subgroup = []); ++ for (var group = this[j], i = 0, n = group.length; i < n; i++) { ++ if (node = group[i]) { ++ transition = node[ns][id0]; ++ d3_transitionNode(node, i, ns, id1, { ++ time: transition.time, ++ ease: transition.ease, ++ delay: transition.delay + transition.duration, ++ duration: transition.duration ++ }); ++ } ++ subgroup.push(node); ++ } ++ } ++ return d3_transition(subgroups, ns, id1); ++ }; ++ function d3_transitionNamespace(name) { ++ return name == null ? "__transition__" : "__transition_" + name + "__"; + } +- function d3_scale_niceStep(step) { +- return step ? { +- floor: function(x) { +- return Math.floor(x / step) * step; +- }, +- ceil: function(x) { +- return Math.ceil(x / step) * step; ++ function d3_transitionNode(node, i, ns, id, inherit) { ++ var lock = node[ns] || (node[ns] = { ++ active: 0, ++ count: 0 ++ }), transition = lock[id], time, timer, duration, ease, tweens; ++ function schedule(elapsed) { ++ var delay = transition.delay; ++ timer.t = delay + time; ++ if (delay <= elapsed) return start(elapsed - delay); ++ timer.c = start; ++ } ++ function start(elapsed) { ++ var activeId = lock.active, active = lock[activeId]; ++ if (active) { ++ active.timer.c = null; ++ active.timer.t = NaN; ++ --lock.count; ++ delete lock[activeId]; ++ active.event && active.event.interrupt.call(node, node.__data__, active.index); ++ } ++ for (var cancelId in lock) { ++ if (+cancelId < id) { ++ var cancel = lock[cancelId]; ++ cancel.timer.c = null; ++ cancel.timer.t = NaN; ++ --lock.count; ++ delete lock[cancelId]; ++ } ++ } ++ timer.c = tick; ++ d3_timer(function() { ++ if (timer.c && tick(elapsed || 1)) { ++ timer.c = null; ++ timer.t = NaN; ++ } ++ return 1; ++ }, 0, time); ++ lock.active = id; ++ transition.event && transition.event.start.call(node, node.__data__, i); ++ tweens = []; ++ transition.tween.forEach(function(key, value) { ++ if (value = value.call(node, node.__data__, i)) { ++ tweens.push(value); ++ } ++ }); ++ ease = transition.ease; ++ duration = transition.duration; ++ } ++ function tick(elapsed) { ++ var t = elapsed / duration, e = ease(t), n = tweens.length; ++ while (n > 0) { ++ tweens[--n].call(node, e); ++ } ++ if (t >= 1) { ++ transition.event && transition.event.end.call(node, node.__data__, i); ++ if (--lock.count) delete lock[id]; else delete node[ns]; ++ return 1; + } +- } : d3_scale_niceIdentity; +- } +- var d3_scale_niceIdentity = { +- floor: d3_identity, +- ceil: d3_identity +- }; +- function d3_scale_polylinear(domain, range, uninterpolate, interpolate) { +- var u = [], i = [], j = 0, k = Math.min(domain.length, range.length) - 1; +- if (domain[k] < domain[0]) { +- domain = domain.slice().reverse(); +- range = range.slice().reverse(); + } +- while (++j <= k) { +- u.push(uninterpolate(domain[j - 1], domain[j])); +- i.push(interpolate(range[j - 1], range[j])); ++ if (!transition) { ++ time = inherit.time; ++ timer = d3_timer(schedule, 0, time); ++ transition = lock[id] = { ++ tween: new d3_Map(), ++ time: time, ++ timer: timer, ++ delay: inherit.delay, ++ duration: inherit.duration, ++ ease: inherit.ease, ++ index: i ++ }; ++ inherit = null; ++ ++lock.count; + } +- return function(x) { +- var j = d3.bisect(domain, x, 1, k) - 1; +- return i[j](u[j](x)); +- }; + } +- d3.scale.linear = function() { +- return d3_scale_linear([ 0, 1 ], [ 0, 1 ], d3_interpolate, false); +- }; +- function d3_scale_linear(domain, range, interpolate, clamp) { +- var output, input; +- function rescale() { +- var linear = Math.min(domain.length, range.length) > 2 ? d3_scale_polylinear : d3_scale_bilinear, uninterpolate = clamp ? d3_uninterpolateClamp : d3_uninterpolateNumber; +- output = linear(domain, range, uninterpolate, interpolate); +- input = linear(range, domain, uninterpolate, d3_interpolate); +- return scale; +- } +- function scale(x) { +- return output(x); ++ d3.svg.axis = function() { ++ var scale = d3.scale.linear(), orient = d3_svg_axisDefaultOrient, innerTickSize = 6, outerTickSize = 6, tickPadding = 3, tickArguments_ = [ 10 ], tickValues = null, tickFormat_; ++ function axis(g) { ++ g.each(function() { ++ var g = d3.select(this); ++ var scale0 = this.__chart__ || scale, scale1 = this.__chart__ = scale.copy(); ++ var ticks = tickValues == null ? scale1.ticks ? scale1.ticks.apply(scale1, tickArguments_) : scale1.domain() : tickValues, tickFormat = tickFormat_ == null ? scale1.tickFormat ? scale1.tickFormat.apply(scale1, tickArguments_) : d3_identity : tickFormat_, tick = g.selectAll(".tick").data(ticks, scale1), tickEnter = tick.enter().insert("g", ".domain").attr("class", "tick").style("opacity", ε), tickExit = d3.transition(tick.exit()).style("opacity", ε).remove(), tickUpdate = d3.transition(tick.order()).style("opacity", 1), tickSpacing = Math.max(innerTickSize, 0) + tickPadding, tickTransform; ++ var range = d3_scaleRange(scale1), path = g.selectAll(".domain").data([ 0 ]), pathUpdate = (path.enter().append("path").attr("class", "domain"), ++ d3.transition(path)); ++ tickEnter.append("line"); ++ tickEnter.append("text"); ++ var lineEnter = tickEnter.select("line"), lineUpdate = tickUpdate.select("line"), text = tick.select("text").text(tickFormat), textEnter = tickEnter.select("text"), textUpdate = tickUpdate.select("text"), sign = orient === "top" || orient === "left" ? -1 : 1, x1, x2, y1, y2; ++ if (orient === "bottom" || orient === "top") { ++ tickTransform = d3_svg_axisX, x1 = "x", y1 = "y", x2 = "x2", y2 = "y2"; ++ text.attr("dy", sign < 0 ? "0em" : ".71em").style("text-anchor", "middle"); ++ pathUpdate.attr("d", "M" + range[0] + "," + sign * outerTickSize + "V0H" + range[1] + "V" + sign * outerTickSize); ++ } else { ++ tickTransform = d3_svg_axisY, x1 = "y", y1 = "x", x2 = "y2", y2 = "x2"; ++ text.attr("dy", ".32em").style("text-anchor", sign < 0 ? "end" : "start"); ++ pathUpdate.attr("d", "M" + sign * outerTickSize + "," + range[0] + "H0V" + range[1] + "H" + sign * outerTickSize); ++ } ++ lineEnter.attr(y2, sign * innerTickSize); ++ textEnter.attr(y1, sign * tickSpacing); ++ lineUpdate.attr(x2, 0).attr(y2, sign * innerTickSize); ++ textUpdate.attr(x1, 0).attr(y1, sign * tickSpacing); ++ if (scale1.rangeBand) { ++ var x = scale1, dx = x.rangeBand() / 2; ++ scale0 = scale1 = function(d) { ++ return x(d) + dx; ++ }; ++ } else if (scale0.rangeBand) { ++ scale0 = scale1; ++ } else { ++ tickExit.call(tickTransform, scale1, scale0); ++ } ++ tickEnter.call(tickTransform, scale0, scale1); ++ tickUpdate.call(tickTransform, scale1, scale1); ++ }); + } +- scale.invert = function(y) { +- return input(y); ++ axis.scale = function(x) { ++ if (!arguments.length) return scale; ++ scale = x; ++ return axis; + }; +- scale.domain = function(x) { +- if (!arguments.length) return domain; +- domain = x.map(Number); +- return rescale(); ++ axis.orient = function(x) { ++ if (!arguments.length) return orient; ++ orient = x in d3_svg_axisOrients ? x + "" : d3_svg_axisDefaultOrient; ++ return axis; + }; +- scale.range = function(x) { +- if (!arguments.length) return range; +- range = x; +- return rescale(); ++ axis.ticks = function() { ++ if (!arguments.length) return tickArguments_; ++ tickArguments_ = d3_array(arguments); ++ return axis; + }; +- scale.rangeRound = function(x) { +- return scale.range(x).interpolate(d3_interpolateRound); ++ axis.tickValues = function(x) { ++ if (!arguments.length) return tickValues; ++ tickValues = x; ++ return axis; + }; +- scale.clamp = function(x) { +- if (!arguments.length) return clamp; +- clamp = x; +- return rescale(); ++ axis.tickFormat = function(x) { ++ if (!arguments.length) return tickFormat_; ++ tickFormat_ = x; ++ return axis; + }; +- scale.interpolate = function(x) { +- if (!arguments.length) return interpolate; +- interpolate = x; +- return rescale(); ++ axis.tickSize = function(x) { ++ var n = arguments.length; ++ if (!n) return innerTickSize; ++ innerTickSize = +x; ++ outerTickSize = +arguments[n - 1]; ++ return axis; + }; +- scale.ticks = function(m) { +- return d3_scale_linearTicks(domain, m); ++ axis.innerTickSize = function(x) { ++ if (!arguments.length) return innerTickSize; ++ innerTickSize = +x; ++ return axis; + }; +- scale.tickFormat = function(m, format) { +- return d3_scale_linearTickFormat(domain, m, format); ++ axis.outerTickSize = function(x) { ++ if (!arguments.length) return outerTickSize; ++ outerTickSize = +x; ++ return axis; + }; +- scale.nice = function(m) { +- d3_scale_linearNice(domain, m); +- return rescale(); ++ axis.tickPadding = function(x) { ++ if (!arguments.length) return tickPadding; ++ tickPadding = +x; ++ return axis; + }; +- scale.copy = function() { +- return d3_scale_linear(domain, range, interpolate, clamp); ++ axis.tickSubdivide = function() { ++ return arguments.length && axis; + }; +- return rescale(); +- } +- function d3_scale_linearRebind(scale, linear) { +- return d3.rebind(scale, linear, "range", "rangeRound", "interpolate", "clamp"); +- } +- function d3_scale_linearNice(domain, m) { +- d3_scale_nice(domain, d3_scale_niceStep(d3_scale_linearTickRange(domain, m)[2])); +- d3_scale_nice(domain, d3_scale_niceStep(d3_scale_linearTickRange(domain, m)[2])); +- return domain; +- } +- function d3_scale_linearTickRange(domain, m) { +- if (m == null) m = 10; +- var extent = d3_scaleExtent(domain), span = extent[1] - extent[0], step = Math.pow(10, Math.floor(Math.log(span / m) / Math.LN10)), err = m / span * step; +- if (err <= .15) step *= 10; else if (err <= .35) step *= 5; else if (err <= .75) step *= 2; +- extent[0] = Math.ceil(extent[0] / step) * step; +- extent[1] = Math.floor(extent[1] / step) * step + step * .5; +- extent[2] = step; +- return extent; +- } +- function d3_scale_linearTicks(domain, m) { +- return d3.range.apply(d3, d3_scale_linearTickRange(domain, m)); +- } +- function d3_scale_linearTickFormat(domain, m, format) { +- var range = d3_scale_linearTickRange(domain, m); +- if (format) { +- var match = d3_format_re.exec(format); +- match.shift(); +- if (match[8] === "s") { +- var prefix = d3.formatPrefix(Math.max(abs(range[0]), abs(range[1]))); +- if (!match[7]) match[7] = "." + d3_scale_linearPrecision(prefix.scale(range[2])); +- match[8] = "f"; +- format = d3.format(match.join("")); +- return function(d) { +- return format(prefix.scale(d)) + prefix.symbol; +- }; +- } +- if (!match[7]) match[7] = "." + d3_scale_linearFormatPrecision(match[8], range); +- format = match.join(""); +- } else { +- format = ",." + d3_scale_linearPrecision(range[2]) + "f"; +- } +- return d3.format(format); +- } +- var d3_scale_linearFormatSignificant = { +- s: 1, +- g: 1, +- p: 1, +- r: 1, +- e: 1 ++ return axis; + }; +- function d3_scale_linearPrecision(value) { +- return -Math.floor(Math.log(value) / Math.LN10 + .01); ++ var d3_svg_axisDefaultOrient = "bottom", d3_svg_axisOrients = { ++ top: 1, ++ right: 1, ++ bottom: 1, ++ left: 1 ++ }; ++ function d3_svg_axisX(selection, x0, x1) { ++ selection.attr("transform", function(d) { ++ var v0 = x0(d); ++ return "translate(" + (isFinite(v0) ? v0 : x1(d)) + ",0)"; ++ }); + } +- function d3_scale_linearFormatPrecision(type, range) { +- var p = d3_scale_linearPrecision(range[2]); +- return type in d3_scale_linearFormatSignificant ? Math.abs(p - d3_scale_linearPrecision(Math.max(abs(range[0]), abs(range[1])))) + +(type !== "e") : p - (type === "%") * 2; ++ function d3_svg_axisY(selection, y0, y1) { ++ selection.attr("transform", function(d) { ++ var v0 = y0(d); ++ return "translate(0," + (isFinite(v0) ? v0 : y1(d)) + ")"; ++ }); + } +- d3.scale.log = function() { +- return d3_scale_log(d3.scale.linear().domain([ 0, 1 ]), 10, true, [ 1, 10 ]); +- }; +- function d3_scale_log(linear, base, positive, domain) { +- function log(x) { +- return (positive ? Math.log(x < 0 ? 0 : x) : -Math.log(x > 0 ? 0 : -x)) / Math.log(base); ++ d3.svg.brush = function() { ++ var event = d3_eventDispatch(brush, "brushstart", "brush", "brushend"), x = null, y = null, xExtent = [ 0, 0 ], yExtent = [ 0, 0 ], xExtentDomain, yExtentDomain, xClamp = true, yClamp = true, resizes = d3_svg_brushResizes[0]; ++ function brush(g) { ++ g.each(function() { ++ var g = d3.select(this).style("pointer-events", "all").style("-webkit-tap-highlight-color", "rgba(0,0,0,0)").on("mousedown.brush", brushstart).on("touchstart.brush", brushstart); ++ var background = g.selectAll(".background").data([ 0 ]); ++ background.enter().append("rect").attr("class", "background").style("visibility", "hidden").style("cursor", "crosshair"); ++ g.selectAll(".extent").data([ 0 ]).enter().append("rect").attr("class", "extent").style("cursor", "move"); ++ var resize = g.selectAll(".resize").data(resizes, d3_identity); ++ resize.exit().remove(); ++ resize.enter().append("g").attr("class", function(d) { ++ return "resize " + d; ++ }).style("cursor", function(d) { ++ return d3_svg_brushCursor[d]; ++ }).append("rect").attr("x", function(d) { ++ return /[ew]$/.test(d) ? -3 : null; ++ }).attr("y", function(d) { ++ return /^[ns]/.test(d) ? -3 : null; ++ }).attr("width", 6).attr("height", 6).style("visibility", "hidden"); ++ resize.style("display", brush.empty() ? "none" : null); ++ var gUpdate = d3.transition(g), backgroundUpdate = d3.transition(background), range; ++ if (x) { ++ range = d3_scaleRange(x); ++ backgroundUpdate.attr("x", range[0]).attr("width", range[1] - range[0]); ++ redrawX(gUpdate); ++ } ++ if (y) { ++ range = d3_scaleRange(y); ++ backgroundUpdate.attr("y", range[0]).attr("height", range[1] - range[0]); ++ redrawY(gUpdate); ++ } ++ redraw(gUpdate); ++ }); + } +- function pow(x) { +- return positive ? Math.pow(base, x) : -Math.pow(base, -x); ++ brush.event = function(g) { ++ g.each(function() { ++ var event_ = event.of(this, arguments), extent1 = { ++ x: xExtent, ++ y: yExtent, ++ i: xExtentDomain, ++ j: yExtentDomain ++ }, extent0 = this.__chart__ || extent1; ++ this.__chart__ = extent1; ++ if (d3_transitionInheritId) { ++ d3.select(this).transition().each("start.brush", function() { ++ xExtentDomain = extent0.i; ++ yExtentDomain = extent0.j; ++ xExtent = extent0.x; ++ yExtent = extent0.y; ++ event_({ ++ type: "brushstart" ++ }); ++ }).tween("brush:brush", function() { ++ var xi = d3_interpolateArray(xExtent, extent1.x), yi = d3_interpolateArray(yExtent, extent1.y); ++ xExtentDomain = yExtentDomain = null; ++ return function(t) { ++ xExtent = extent1.x = xi(t); ++ yExtent = extent1.y = yi(t); ++ event_({ ++ type: "brush", ++ mode: "resize" ++ }); ++ }; ++ }).each("end.brush", function() { ++ xExtentDomain = extent1.i; ++ yExtentDomain = extent1.j; ++ event_({ ++ type: "brush", ++ mode: "resize" ++ }); ++ event_({ ++ type: "brushend" ++ }); ++ }); ++ } else { ++ event_({ ++ type: "brushstart" ++ }); ++ event_({ ++ type: "brush", ++ mode: "resize" ++ }); ++ event_({ ++ type: "brushend" ++ }); ++ } ++ }); ++ }; ++ function redraw(g) { ++ g.selectAll(".resize").attr("transform", function(d) { ++ return "translate(" + xExtent[+/e$/.test(d)] + "," + yExtent[+/^s/.test(d)] + ")"; ++ }); + } +- function scale(x) { +- return linear(log(x)); ++ function redrawX(g) { ++ g.select(".extent").attr("x", xExtent[0]); ++ g.selectAll(".extent,.n>rect,.s>rect").attr("width", xExtent[1] - xExtent[0]); + } +- scale.invert = function(x) { +- return pow(linear.invert(x)); +- }; +- scale.domain = function(x) { +- if (!arguments.length) return domain; +- positive = x[0] >= 0; +- linear.domain((domain = x.map(Number)).map(log)); +- return scale; ++ function redrawY(g) { ++ g.select(".extent").attr("y", yExtent[0]); ++ g.selectAll(".extent,.e>rect,.w>rect").attr("height", yExtent[1] - yExtent[0]); ++ } ++ function brushstart() { ++ var target = this, eventTarget = d3.select(d3.event.target), event_ = event.of(target, arguments), g = d3.select(target), resizing = eventTarget.datum(), resizingX = !/^(n|s)$/.test(resizing) && x, resizingY = !/^(e|w)$/.test(resizing) && y, dragging = eventTarget.classed("extent"), dragRestore = d3_event_dragSuppress(target), center, origin = d3.mouse(target), offset; ++ var w = d3.select(d3_window(target)).on("keydown.brush", keydown).on("keyup.brush", keyup); ++ if (d3.event.changedTouches) { ++ w.on("touchmove.brush", brushmove).on("touchend.brush", brushend); ++ } else { ++ w.on("mousemove.brush", brushmove).on("mouseup.brush", brushend); ++ } ++ g.interrupt().selectAll("*").interrupt(); ++ if (dragging) { ++ origin[0] = xExtent[0] - origin[0]; ++ origin[1] = yExtent[0] - origin[1]; ++ } else if (resizing) { ++ var ex = +/w$/.test(resizing), ey = +/^n/.test(resizing); ++ offset = [ xExtent[1 - ex] - origin[0], yExtent[1 - ey] - origin[1] ]; ++ origin[0] = xExtent[ex]; ++ origin[1] = yExtent[ey]; ++ } else if (d3.event.altKey) center = origin.slice(); ++ g.style("pointer-events", "none").selectAll(".resize").style("display", null); ++ d3.select("body").style("cursor", eventTarget.style("cursor")); ++ event_({ ++ type: "brushstart" ++ }); ++ brushmove(); ++ function keydown() { ++ if (d3.event.keyCode == 32) { ++ if (!dragging) { ++ center = null; ++ origin[0] -= xExtent[1]; ++ origin[1] -= yExtent[1]; ++ dragging = 2; ++ } ++ d3_eventPreventDefault(); ++ } ++ } ++ function keyup() { ++ if (d3.event.keyCode == 32 && dragging == 2) { ++ origin[0] += xExtent[1]; ++ origin[1] += yExtent[1]; ++ dragging = 0; ++ d3_eventPreventDefault(); ++ } ++ } ++ function brushmove() { ++ var point = d3.mouse(target), moved = false; ++ if (offset) { ++ point[0] += offset[0]; ++ point[1] += offset[1]; ++ } ++ if (!dragging) { ++ if (d3.event.altKey) { ++ if (!center) center = [ (xExtent[0] + xExtent[1]) / 2, (yExtent[0] + yExtent[1]) / 2 ]; ++ origin[0] = xExtent[+(point[0] < center[0])]; ++ origin[1] = yExtent[+(point[1] < center[1])]; ++ } else center = null; ++ } ++ if (resizingX && move1(point, x, 0)) { ++ redrawX(g); ++ moved = true; ++ } ++ if (resizingY && move1(point, y, 1)) { ++ redrawY(g); ++ moved = true; ++ } ++ if (moved) { ++ redraw(g); ++ event_({ ++ type: "brush", ++ mode: dragging ? "move" : "resize" ++ }); ++ } ++ } ++ function move1(point, scale, i) { ++ var range = d3_scaleRange(scale), r0 = range[0], r1 = range[1], position = origin[i], extent = i ? yExtent : xExtent, size = extent[1] - extent[0], min, max; ++ if (dragging) { ++ r0 -= position; ++ r1 -= size + position; ++ } ++ min = (i ? yClamp : xClamp) ? Math.max(r0, Math.min(r1, point[i])) : point[i]; ++ if (dragging) { ++ max = (min += position) + size; ++ } else { ++ if (center) position = Math.max(r0, Math.min(r1, 2 * center[i] - min)); ++ if (position < min) { ++ max = min; ++ min = position; ++ } else { ++ max = position; ++ } ++ } ++ if (extent[0] != min || extent[1] != max) { ++ if (i) yExtentDomain = null; else xExtentDomain = null; ++ extent[0] = min; ++ extent[1] = max; ++ return true; ++ } ++ } ++ function brushend() { ++ brushmove(); ++ g.style("pointer-events", "all").selectAll(".resize").style("display", brush.empty() ? "none" : null); ++ d3.select("body").style("cursor", null); ++ w.on("mousemove.brush", null).on("mouseup.brush", null).on("touchmove.brush", null).on("touchend.brush", null).on("keydown.brush", null).on("keyup.brush", null); ++ dragRestore(); ++ event_({ ++ type: "brushend" ++ }); ++ } ++ } ++ brush.x = function(z) { ++ if (!arguments.length) return x; ++ x = z; ++ resizes = d3_svg_brushResizes[!x << 1 | !y]; ++ return brush; + }; +- scale.base = function(_) { +- if (!arguments.length) return base; +- base = +_; +- linear.domain(domain.map(log)); +- return scale; ++ brush.y = function(z) { ++ if (!arguments.length) return y; ++ y = z; ++ resizes = d3_svg_brushResizes[!x << 1 | !y]; ++ return brush; + }; +- scale.nice = function() { +- var niced = d3_scale_nice(domain.map(log), positive ? Math : d3_scale_logNiceNegative); +- linear.domain(niced); +- domain = niced.map(pow); +- return scale; ++ brush.clamp = function(z) { ++ if (!arguments.length) return x && y ? [ xClamp, yClamp ] : x ? xClamp : y ? yClamp : null; ++ if (x && y) xClamp = !!z[0], yClamp = !!z[1]; else if (x) xClamp = !!z; else if (y) yClamp = !!z; ++ return brush; + }; +- scale.ticks = function() { +- var extent = d3_scaleExtent(domain), ticks = [], u = extent[0], v = extent[1], i = Math.floor(log(u)), j = Math.ceil(log(v)), n = base % 1 ? 2 : base; +- if (isFinite(j - i)) { +- if (positive) { +- for (;i < j; i++) for (var k = 1; k < n; k++) ticks.push(pow(i) * k); +- ticks.push(pow(i)); +- } else { +- ticks.push(pow(i)); +- for (;i++ < j; ) for (var k = n - 1; k > 0; k--) ticks.push(pow(i) * k); ++ brush.extent = function(z) { ++ var x0, x1, y0, y1, t; ++ if (!arguments.length) { ++ if (x) { ++ if (xExtentDomain) { ++ x0 = xExtentDomain[0], x1 = xExtentDomain[1]; ++ } else { ++ x0 = xExtent[0], x1 = xExtent[1]; ++ if (x.invert) x0 = x.invert(x0), x1 = x.invert(x1); ++ if (x1 < x0) t = x0, x0 = x1, x1 = t; ++ } + } +- for (i = 0; ticks[i] < u; i++) {} +- for (j = ticks.length; ticks[j - 1] > v; j--) {} +- ticks = ticks.slice(i, j); ++ if (y) { ++ if (yExtentDomain) { ++ y0 = yExtentDomain[0], y1 = yExtentDomain[1]; ++ } else { ++ y0 = yExtent[0], y1 = yExtent[1]; ++ if (y.invert) y0 = y.invert(y0), y1 = y.invert(y1); ++ if (y1 < y0) t = y0, y0 = y1, y1 = t; ++ } ++ } ++ return x && y ? [ [ x0, y0 ], [ x1, y1 ] ] : x ? [ x0, x1 ] : y && [ y0, y1 ]; ++ } ++ if (x) { ++ x0 = z[0], x1 = z[1]; ++ if (y) x0 = x0[0], x1 = x1[0]; ++ xExtentDomain = [ x0, x1 ]; ++ if (x.invert) x0 = x(x0), x1 = x(x1); ++ if (x1 < x0) t = x0, x0 = x1, x1 = t; ++ if (x0 != xExtent[0] || x1 != xExtent[1]) xExtent = [ x0, x1 ]; + } +- return ticks; ++ if (y) { ++ y0 = z[0], y1 = z[1]; ++ if (x) y0 = y0[1], y1 = y1[1]; ++ yExtentDomain = [ y0, y1 ]; ++ if (y.invert) y0 = y(y0), y1 = y(y1); ++ if (y1 < y0) t = y0, y0 = y1, y1 = t; ++ if (y0 != yExtent[0] || y1 != yExtent[1]) yExtent = [ y0, y1 ]; ++ } ++ return brush; + }; +- scale.tickFormat = function(n, format) { +- if (!arguments.length) return d3_scale_logFormat; +- if (arguments.length < 2) format = d3_scale_logFormat; else if (typeof format !== "function") format = d3.format(format); +- var k = Math.max(1, base * n / scale.ticks().length); +- return function(d) { +- var i = d / pow(Math.round(log(d))); +- if (i * base < base - .5) i *= base; +- return i <= k ? format(d) : ""; +- }; ++ brush.clear = function() { ++ if (!brush.empty()) { ++ xExtent = [ 0, 0 ], yExtent = [ 0, 0 ]; ++ xExtentDomain = yExtentDomain = null; ++ } ++ return brush; + }; +- scale.copy = function() { +- return d3_scale_log(linear.copy(), base, positive, domain); ++ brush.empty = function() { ++ return !!x && xExtent[0] == xExtent[1] || !!y && yExtent[0] == yExtent[1]; + }; +- return d3_scale_linearRebind(scale, linear); +- } +- var d3_scale_logFormat = d3.format(".0e"), d3_scale_logNiceNegative = { +- floor: function(x) { +- return -Math.ceil(-x); +- }, +- ceil: function(x) { +- return -Math.floor(-x); +- } ++ return d3.rebind(brush, event, "on"); + }; +- d3.scale.pow = function() { +- return d3_scale_pow(d3.scale.linear(), 1, [ 0, 1 ]); ++ var d3_svg_brushCursor = { ++ n: "ns-resize", ++ e: "ew-resize", ++ s: "ns-resize", ++ w: "ew-resize", ++ nw: "nwse-resize", ++ ne: "nesw-resize", ++ se: "nwse-resize", ++ sw: "nesw-resize" + }; +- function d3_scale_pow(linear, exponent, domain) { +- var powp = d3_scale_powPow(exponent), powb = d3_scale_powPow(1 / exponent); ++ var d3_svg_brushResizes = [ [ "n", "e", "s", "w", "nw", "ne", "se", "sw" ], [ "e", "w" ], [ "n", "s" ], [] ]; ++ var d3_time_format = d3_time.format = d3_locale_enUS.timeFormat; ++ var d3_time_formatUtc = d3_time_format.utc; ++ var d3_time_formatIso = d3_time_formatUtc("%Y-%m-%dT%H:%M:%S.%LZ"); ++ d3_time_format.iso = Date.prototype.toISOString && +new Date("2000-01-01T00:00:00.000Z") ? d3_time_formatIsoNative : d3_time_formatIso; ++ function d3_time_formatIsoNative(date) { ++ return date.toISOString(); ++ } ++ d3_time_formatIsoNative.parse = function(string) { ++ var date = new Date(string); ++ return isNaN(date) ? null : date; ++ }; ++ d3_time_formatIsoNative.toString = d3_time_formatIso.toString; ++ d3_time.second = d3_time_interval(function(date) { ++ return new d3_date(Math.floor(date / 1e3) * 1e3); ++ }, function(date, offset) { ++ date.setTime(date.getTime() + Math.floor(offset) * 1e3); ++ }, function(date) { ++ return date.getSeconds(); ++ }); ++ d3_time.seconds = d3_time.second.range; ++ d3_time.seconds.utc = d3_time.second.utc.range; ++ d3_time.minute = d3_time_interval(function(date) { ++ return new d3_date(Math.floor(date / 6e4) * 6e4); ++ }, function(date, offset) { ++ date.setTime(date.getTime() + Math.floor(offset) * 6e4); ++ }, function(date) { ++ return date.getMinutes(); ++ }); ++ d3_time.minutes = d3_time.minute.range; ++ d3_time.minutes.utc = d3_time.minute.utc.range; ++ d3_time.hour = d3_time_interval(function(date) { ++ var timezone = date.getTimezoneOffset() / 60; ++ return new d3_date((Math.floor(date / 36e5 - timezone) + timezone) * 36e5); ++ }, function(date, offset) { ++ date.setTime(date.getTime() + Math.floor(offset) * 36e5); ++ }, function(date) { ++ return date.getHours(); ++ }); ++ d3_time.hours = d3_time.hour.range; ++ d3_time.hours.utc = d3_time.hour.utc.range; ++ d3_time.month = d3_time_interval(function(date) { ++ date = d3_time.day(date); ++ date.setDate(1); ++ return date; ++ }, function(date, offset) { ++ date.setMonth(date.getMonth() + offset); ++ }, function(date) { ++ return date.getMonth(); ++ }); ++ d3_time.months = d3_time.month.range; ++ d3_time.months.utc = d3_time.month.utc.range; ++ function d3_time_scale(linear, methods, format) { + function scale(x) { +- return linear(powp(x)); ++ return linear(x); + } + scale.invert = function(x) { +- return powb(linear.invert(x)); ++ return d3_time_scaleDate(linear.invert(x)); + }; + scale.domain = function(x) { +- if (!arguments.length) return domain; +- linear.domain((domain = x.map(Number)).map(powp)); ++ if (!arguments.length) return linear.domain().map(d3_time_scaleDate); ++ linear.domain(x); + return scale; + }; +- scale.ticks = function(m) { +- return d3_scale_linearTicks(domain, m); +- }; +- scale.tickFormat = function(m, format) { +- return d3_scale_linearTickFormat(domain, m, format); ++ function tickMethod(extent, count) { ++ var span = extent[1] - extent[0], target = span / count, i = d3.bisect(d3_time_scaleSteps, target); ++ return i == d3_time_scaleSteps.length ? [ methods.year, d3_scale_linearTickRange(extent.map(function(d) { ++ return d / 31536e6; ++ }), count)[2] ] : !i ? [ d3_time_scaleMilliseconds, d3_scale_linearTickRange(extent, count)[2] ] : methods[target / d3_time_scaleSteps[i - 1] < d3_time_scaleSteps[i] / target ? i - 1 : i]; ++ } ++ scale.nice = function(interval, skip) { ++ var domain = scale.domain(), extent = d3_scaleExtent(domain), method = interval == null ? tickMethod(extent, 10) : typeof interval === "number" && tickMethod(extent, interval); ++ if (method) interval = method[0], skip = method[1]; ++ function skipped(date) { ++ return !isNaN(date) && !interval.range(date, d3_time_scaleDate(+date + 1), skip).length; ++ } ++ return scale.domain(d3_scale_nice(domain, skip > 1 ? { ++ floor: function(date) { ++ while (skipped(date = interval.floor(date))) date = d3_time_scaleDate(date - 1); ++ return date; ++ }, ++ ceil: function(date) { ++ while (skipped(date = interval.ceil(date))) date = d3_time_scaleDate(+date + 1); ++ return date; ++ } ++ } : interval)); + }; +- scale.nice = function(m) { +- return scale.domain(d3_scale_linearNice(domain, m)); ++ scale.ticks = function(interval, skip) { ++ var extent = d3_scaleExtent(scale.domain()), method = interval == null ? tickMethod(extent, 10) : typeof interval === "number" ? tickMethod(extent, interval) : !interval.range && [ { ++ range: interval ++ }, skip ]; ++ if (method) interval = method[0], skip = method[1]; ++ return interval.range(extent[0], d3_time_scaleDate(+extent[1] + 1), skip < 1 ? 1 : skip); + }; +- scale.exponent = function(x) { +- if (!arguments.length) return exponent; +- powp = d3_scale_powPow(exponent = x); +- powb = d3_scale_powPow(1 / exponent); +- linear.domain(domain.map(powp)); +- return scale; ++ scale.tickFormat = function() { ++ return format; + }; + scale.copy = function() { +- return d3_scale_pow(linear.copy(), exponent, domain); ++ return d3_time_scale(linear.copy(), methods, format); + }; + return d3_scale_linearRebind(scale, linear); + } +- function d3_scale_powPow(e) { +- return function(x) { +- return x < 0 ? -Math.pow(-x, e) : Math.pow(x, e); +- }; +- } +- d3.scale.sqrt = function() { +- return d3.scale.pow().exponent(.5); +- }; +- d3.scale.ordinal = function() { +- return d3_scale_ordinal([], { +- t: "range", +- a: [ [] ] +- }); +- }; +- function d3_scale_ordinal(domain, ranger) { +- var index, range, rangeBand; +- function scale(x) { +- return range[((index.get(x) || (ranger.t === "range" ? index.set(x, domain.push(x)) : NaN)) - 1) % range.length]; +- } +- function steps(start, step) { +- return d3.range(domain.length).map(function(i) { +- return start + step * i; +- }); +- } +- scale.domain = function(x) { +- if (!arguments.length) return domain; +- domain = []; +- index = new d3_Map(); +- var i = -1, n = x.length, xi; +- while (++i < n) if (!index.has(xi = x[i])) index.set(xi, domain.push(xi)); +- return scale[ranger.t].apply(scale, ranger.a); +- }; +- scale.range = function(x) { +- if (!arguments.length) return range; +- range = x; +- rangeBand = 0; +- ranger = { +- t: "range", +- a: arguments +- }; +- return scale; +- }; +- scale.rangePoints = function(x, padding) { +- if (arguments.length < 2) padding = 0; +- var start = x[0], stop = x[1], step = domain.length < 2 ? (start = (start + stop) / 2, +- 0) : (stop - start) / (domain.length - 1 + padding); +- range = steps(start + step * padding / 2, step); +- rangeBand = 0; +- ranger = { +- t: "rangePoints", +- a: arguments +- }; +- return scale; +- }; +- scale.rangeRoundPoints = function(x, padding) { +- if (arguments.length < 2) padding = 0; +- var start = x[0], stop = x[1], step = domain.length < 2 ? (start = stop = Math.round((start + stop) / 2), +- 0) : (stop - start) / (domain.length - 1 + padding) | 0; +- range = steps(start + Math.round(step * padding / 2 + (stop - start - (domain.length - 1 + padding) * step) / 2), step); +- rangeBand = 0; +- ranger = { +- t: "rangeRoundPoints", +- a: arguments +- }; +- return scale; +- }; +- scale.rangeBands = function(x, padding, outerPadding) { +- if (arguments.length < 2) padding = 0; +- if (arguments.length < 3) outerPadding = padding; +- var reverse = x[1] < x[0], start = x[reverse - 0], stop = x[1 - reverse], step = (stop - start) / (domain.length - padding + 2 * outerPadding); +- range = steps(start + step * outerPadding, step); +- if (reverse) range.reverse(); +- rangeBand = step * (1 - padding); +- ranger = { +- t: "rangeBands", +- a: arguments +- }; +- return scale; +- }; +- scale.rangeRoundBands = function(x, padding, outerPadding) { +- if (arguments.length < 2) padding = 0; +- if (arguments.length < 3) outerPadding = padding; +- var reverse = x[1] < x[0], start = x[reverse - 0], stop = x[1 - reverse], step = Math.floor((stop - start) / (domain.length - padding + 2 * outerPadding)); +- range = steps(start + Math.round((stop - start - (domain.length - padding) * step) / 2), step); +- if (reverse) range.reverse(); +- rangeBand = Math.round(step * (1 - padding)); +- ranger = { +- t: "rangeRoundBands", +- a: arguments +- }; +- return scale; +- }; +- scale.rangeBand = function() { +- return rangeBand; +- }; +- scale.rangeExtent = function() { +- return d3_scaleExtent(ranger.a[0]); +- }; +- scale.copy = function() { +- return d3_scale_ordinal(domain, ranger); +- }; +- return scale.domain(domain); ++ function d3_time_scaleDate(t) { ++ return new Date(t); + } +- d3.scale.category10 = function() { +- return d3.scale.ordinal().range(d3_category10); +- }; +- d3.scale.category20 = function() { +- return d3.scale.ordinal().range(d3_category20); ++ var d3_time_scaleSteps = [ 1e3, 5e3, 15e3, 3e4, 6e4, 3e5, 9e5, 18e5, 36e5, 108e5, 216e5, 432e5, 864e5, 1728e5, 6048e5, 2592e6, 7776e6, 31536e6 ]; ++ var d3_time_scaleLocalMethods = [ [ d3_time.second, 1 ], [ d3_time.second, 5 ], [ d3_time.second, 15 ], [ d3_time.second, 30 ], [ d3_time.minute, 1 ], [ d3_time.minute, 5 ], [ d3_time.minute, 15 ], [ d3_time.minute, 30 ], [ d3_time.hour, 1 ], [ d3_time.hour, 3 ], [ d3_time.hour, 6 ], [ d3_time.hour, 12 ], [ d3_time.day, 1 ], [ d3_time.day, 2 ], [ d3_time.week, 1 ], [ d3_time.month, 1 ], [ d3_time.month, 3 ], [ d3_time.year, 1 ] ]; ++ var d3_time_scaleLocalFormat = d3_time_format.multi([ [ ".%L", function(d) { ++ return d.getMilliseconds(); ++ } ], [ ":%S", function(d) { ++ return d.getSeconds(); ++ } ], [ "%I:%M", function(d) { ++ return d.getMinutes(); ++ } ], [ "%I %p", function(d) { ++ return d.getHours(); ++ } ], [ "%a %d", function(d) { ++ return d.getDay() && d.getDate() != 1; ++ } ], [ "%b %d", function(d) { ++ return d.getDate() != 1; ++ } ], [ "%B", function(d) { ++ return d.getMonth(); ++ } ], [ "%Y", d3_true ] ]); ++ var d3_time_scaleMilliseconds = { ++ range: function(start, stop, step) { ++ return d3.range(Math.ceil(start / step) * step, +stop, step).map(d3_time_scaleDate); ++ }, ++ floor: d3_identity, ++ ceil: d3_identity + }; +- d3.scale.category20b = function() { +- return d3.scale.ordinal().range(d3_category20b); ++ d3_time_scaleLocalMethods.year = d3_time.year; ++ d3_time.scale = function() { ++ return d3_time_scale(d3.scale.linear(), d3_time_scaleLocalMethods, d3_time_scaleLocalFormat); + }; +- d3.scale.category20c = function() { +- return d3.scale.ordinal().range(d3_category20c); ++ var d3_time_scaleUtcMethods = d3_time_scaleLocalMethods.map(function(m) { ++ return [ m[0].utc, m[1] ]; ++ }); ++ var d3_time_scaleUtcFormat = d3_time_formatUtc.multi([ [ ".%L", function(d) { ++ return d.getUTCMilliseconds(); ++ } ], [ ":%S", function(d) { ++ return d.getUTCSeconds(); ++ } ], [ "%I:%M", function(d) { ++ return d.getUTCMinutes(); ++ } ], [ "%I %p", function(d) { ++ return d.getUTCHours(); ++ } ], [ "%a %d", function(d) { ++ return d.getUTCDay() && d.getUTCDate() != 1; ++ } ], [ "%b %d", function(d) { ++ return d.getUTCDate() != 1; ++ } ], [ "%B", function(d) { ++ return d.getUTCMonth(); ++ } ], [ "%Y", d3_true ] ]); ++ d3_time_scaleUtcMethods.year = d3_time.year.utc; ++ d3_time.scale.utc = function() { ++ return d3_time_scale(d3.scale.linear(), d3_time_scaleUtcMethods, d3_time_scaleUtcFormat); + }; +- var d3_category10 = [ 2062260, 16744206, 2924588, 14034728, 9725885, 9197131, 14907330, 8355711, 12369186, 1556175 ].map(d3_rgbString); +- var d3_category20 = [ 2062260, 11454440, 16744206, 16759672, 2924588, 10018698, 14034728, 16750742, 9725885, 12955861, 9197131, 12885140, 14907330, 16234194, 8355711, 13092807, 12369186, 14408589, 1556175, 10410725 ].map(d3_rgbString); +- var d3_category20b = [ 3750777, 5395619, 7040719, 10264286, 6519097, 9216594, 11915115, 13556636, 9202993, 12426809, 15186514, 15190932, 8666169, 11356490, 14049643, 15177372, 8077683, 10834324, 13528509, 14589654 ].map(d3_rgbString); +- var d3_category20c = [ 3244733, 7057110, 10406625, 13032431, 15095053, 16616764, 16625259, 16634018, 3253076, 7652470, 10607003, 13101504, 7695281, 10394312, 12369372, 14342891, 6513507, 9868950, 12434877, 14277081 ].map(d3_rgbString); +- d3.scale.quantile = function() { +- return d3_scale_quantile([], []); ++ d3.text = d3_xhrType(function(request) { ++ return request.responseText; ++ }); ++ d3.json = function(url, callback) { ++ return d3_xhr(url, "application/json", d3_json, callback); + }; +- function d3_scale_quantile(domain, range) { +- var thresholds; +- function rescale() { +- var k = 0, q = range.length; +- thresholds = []; +- while (++k < q) thresholds[k - 1] = d3.quantile(domain, k / q); +- return scale; +- } +- function scale(x) { +- if (!isNaN(x = +x)) return range[d3.bisect(thresholds, x)]; +- } +- scale.domain = function(x) { +- if (!arguments.length) return domain; +- domain = x.map(d3_number).filter(d3_numeric).sort(d3_ascending); +- return rescale(); +- }; +- scale.range = function(x) { +- if (!arguments.length) return range; +- range = x; +- return rescale(); +- }; +- scale.quantiles = function() { +- return thresholds; +- }; +- scale.invertExtent = function(y) { +- y = range.indexOf(y); +- return y < 0 ? [ NaN, NaN ] : [ y > 0 ? thresholds[y - 1] : domain[0], y < thresholds.length ? thresholds[y] : domain[domain.length - 1] ]; +- }; +- scale.copy = function() { +- return d3_scale_quantile(domain, range); +- }; +- return rescale(); ++ function d3_json(request) { ++ return JSON.parse(request.responseText); + } +- d3.scale.quantize = function() { +- return d3_scale_quantize(0, 1, [ 0, 1 ]); ++ d3.html = function(url, callback) { ++ return d3_xhr(url, "text/html", d3_html, callback); + }; +- function d3_scale_quantize(x0, x1, range) { +- var kx, i; +- function scale(x) { +- return range[Math.max(0, Math.min(i, Math.floor(kx * (x - x0))))]; +- } +- function rescale() { +- kx = range.length / (x1 - x0); +- i = range.length - 1; +- return scale; ++ function d3_html(request) { ++ var range = d3_document.createRange(); ++ range.selectNode(d3_document.body); ++ return range.createContextualFragment(request.responseText); ++ } ++ d3.xml = d3_xhrType(function(request) { ++ return request.responseXML; ++ }); ++ if (typeof define === "function" && define.amd) this.d3 = d3, define(d3); else if (typeof module === "object" && module.exports) module.exports = d3; else this.d3 = d3; ++}(); ++},{}],75:[function(require,module,exports){ ++"use strict" ++ ++var ch = require("incremental-convex-hull") ++var uniq = require("uniq") ++ ++module.exports = triangulate ++ ++function LiftedPoint(p, i) { ++ this.point = p ++ this.index = i ++} ++ ++function compareLifted(a, b) { ++ var ap = a.point ++ var bp = b.point ++ var d = ap.length ++ for(var i=0; i a1 ? 0 : 1; +- if (r1 < r0) rc = r1, r1 = r0, r0 = rc; +- if (da >= τε) return circleSegment(r1, cw) + (r0 ? circleSegment(r0, 1 - cw) : "") + "Z"; +- var rc, cr, rp, ap, p0 = 0, p1 = 0, x0, y0, x1, y1, x2, y2, x3, y3, path = []; +- if (ap = (+padAngle.apply(this, arguments) || 0) / 2) { +- rp = padRadius === d3_svg_arcAuto ? Math.sqrt(r0 * r0 + r1 * r1) : +padRadius.apply(this, arguments); +- if (!cw) p1 *= -1; +- if (r1) p1 = d3_asin(rp / r1 * Math.sin(ap)); +- if (r0) p0 = d3_asin(rp / r0 * Math.sin(ap)); +- } +- if (r1) { +- x0 = r1 * Math.cos(a0 + p1); +- y0 = r1 * Math.sin(a0 + p1); +- x1 = r1 * Math.cos(a1 - p1); +- y1 = r1 * Math.sin(a1 - p1); +- var l1 = Math.abs(a1 - a0 - 2 * p1) <= π ? 0 : 1; +- if (p1 && d3_svg_arcSweep(x0, y0, x1, y1) === cw ^ l1) { +- var h1 = (a0 + a1) / 2; +- x0 = r1 * Math.cos(h1); +- y0 = r1 * Math.sin(h1); +- x1 = y1 = null; +- } +- } else { +- x0 = y0 = 0; +- } +- if (r0) { +- x2 = r0 * Math.cos(a1 - p0); +- y2 = r0 * Math.sin(a1 - p0); +- x3 = r0 * Math.cos(a0 + p0); +- y3 = r0 * Math.sin(a0 + p0); +- var l0 = Math.abs(a0 - a1 + 2 * p0) <= π ? 0 : 1; +- if (p0 && d3_svg_arcSweep(x2, y2, x3, y3) === 1 - cw ^ l0) { +- var h0 = (a0 + a1) / 2; +- x2 = r0 * Math.cos(h0); +- y2 = r0 * Math.sin(h0); +- x3 = y3 = null; +- } +- } else { +- x2 = y2 = 0; +- } +- if (da > ε && (rc = Math.min(Math.abs(r1 - r0) / 2, +cornerRadius.apply(this, arguments))) > .001) { +- cr = r0 < r1 ^ cw ? 0 : 1; +- var rc1 = rc, rc0 = rc; +- if (da < π) { +- var oc = x3 == null ? [ x2, y2 ] : x1 == null ? [ x0, y0 ] : d3_geom_polygonIntersect([ x0, y0 ], [ x3, y3 ], [ x1, y1 ], [ x2, y2 ]), ax = x0 - oc[0], ay = y0 - oc[1], bx = x1 - oc[0], by = y1 - oc[1], kc = 1 / Math.sin(Math.acos((ax * bx + ay * by) / (Math.sqrt(ax * ax + ay * ay) * Math.sqrt(bx * bx + by * by))) / 2), lc = Math.sqrt(oc[0] * oc[0] + oc[1] * oc[1]); +- rc0 = Math.min(rc, (r0 - lc) / (kc - 1)); +- rc1 = Math.min(rc, (r1 - lc) / (kc + 1)); +- } +- if (x1 != null) { +- var t30 = d3_svg_arcCornerTangents(x3 == null ? [ x2, y2 ] : [ x3, y3 ], [ x0, y0 ], r1, rc1, cw), t12 = d3_svg_arcCornerTangents([ x1, y1 ], [ x2, y2 ], r1, rc1, cw); +- if (rc === rc1) { +- path.push("M", t30[0], "A", rc1, ",", rc1, " 0 0,", cr, " ", t30[1], "A", r1, ",", r1, " 0 ", 1 - cw ^ d3_svg_arcSweep(t30[1][0], t30[1][1], t12[1][0], t12[1][1]), ",", cw, " ", t12[1], "A", rc1, ",", rc1, " 0 0,", cr, " ", t12[0]); +- } else { +- path.push("M", t30[0], "A", rc1, ",", rc1, " 0 1,", cr, " ", t12[0]); ++ y[d] = u ++ ++ dpoints[0] = y.slice() ++ dindex[0] = -1 ++ ++ for(var i=0; i<=d; ++i) { ++ var x = y.slice() ++ x[i] = 1 ++ dpoints[i+1] = x ++ dindex[i+1] = -1 ++ } ++ ++ //Copy rest of the points over ++ for(var i=0; i= 2) { ++ return false + } +- } else { +- path.push("M", x0, ",", y0); + } +- if (x3 != null) { +- var t03 = d3_svg_arcCornerTangents([ x0, y0 ], [ x3, y3 ], r0, -rc0, cw), t21 = d3_svg_arcCornerTangents([ x2, y2 ], x1 == null ? [ x0, y0 ] : [ x1, y1 ], r0, -rc0, cw); +- if (rc === rc0) { +- path.push("L", t21[0], "A", rc0, ",", rc0, " 0 0,", cr, " ", t21[1], "A", r0, ",", r0, " 0 ", cw ^ d3_svg_arcSweep(t21[1][0], t21[1][1], t03[1][0], t03[1][1]), ",", 1 - cw, " ", t03[1], "A", rc0, ",", rc0, " 0 0,", cr, " ", t03[0]); +- } else { +- path.push("L", t21[0], "A", rc0, ",", rc0, " 0 0,", cr, " ", t03[0]); +- } +- } else { +- path.push("L", x2, ",", y2); ++ cell[j] = v ++ } ++ return true ++ }) ++ } else { ++ hull = hull.filter(function(cell) { ++ for(var i=0; i<=d; ++i) { ++ var v = dindex[cell[i]] ++ if(v < 0) { ++ return false + } +- } else { +- path.push("M", x0, ",", y0); +- if (x1 != null) path.push("A", r1, ",", r1, " 0 ", l1, ",", cw, " ", x1, ",", y1); +- path.push("L", x2, ",", y2); +- if (x3 != null) path.push("A", r0, ",", r0, " 0 ", l0, ",", 1 - cw, " ", x3, ",", y3); ++ cell[i] = v + } +- path.push("Z"); +- return path.join(""); ++ return true ++ }) ++ } ++ ++ if(d & 1) { ++ for(var i=0; i 0 ? 0 : 1; ++ module.exports.hi = highUint ++} ++ ++module.exports.sign = function(n) { ++ return module.exports.hi(n) >>> 31 ++} ++ ++module.exports.exponent = function(n) { ++ var b = module.exports.hi(n) ++ return ((b<<1) >>> 21) - 1023 ++} ++ ++module.exports.fraction = function(n) { ++ var lo = module.exports.lo(n) ++ var hi = module.exports.hi(n) ++ var b = hi & ((1<<20) - 1) ++ if(hi & 0x7ff00000) { ++ b += (1<<20) + } +- function d3_svg_arcCornerTangents(p0, p1, r1, rc, cw) { +- var x01 = p0[0] - p1[0], y01 = p0[1] - p1[1], lo = (cw ? rc : -rc) / Math.sqrt(x01 * x01 + y01 * y01), ox = lo * y01, oy = -lo * x01, x1 = p0[0] + ox, y1 = p0[1] + oy, x2 = p1[0] + ox, y2 = p1[1] + oy, x3 = (x1 + x2) / 2, y3 = (y1 + y2) / 2, dx = x2 - x1, dy = y2 - y1, d2 = dx * dx + dy * dy, r = r1 - rc, D = x1 * y2 - x2 * y1, d = (dy < 0 ? -1 : 1) * Math.sqrt(Math.max(0, r * r * d2 - D * D)), cx0 = (D * dy - dx * d) / d2, cy0 = (-D * dx - dy * d) / d2, cx1 = (D * dy + dx * d) / d2, cy1 = (-D * dx + dy * d) / d2, dx0 = cx0 - x3, dy0 = cy0 - y3, dx1 = cx1 - x3, dy1 = cy1 - y3; +- if (dx0 * dx0 + dy0 * dy0 > dx1 * dx1 + dy1 * dy1) cx0 = cx1, cy0 = cy1; +- return [ [ cx0 - ox, cy0 - oy ], [ cx0 * r1 / r, cy0 * r1 / r ] ]; ++ return [lo, b] ++} ++ ++module.exports.denormalized = function(n) { ++ var hi = module.exports.hi(n) ++ return !(hi & 0x7ff00000) ++} ++}).call(this,require("buffer").Buffer) ++},{"buffer":45}],77:[function(require,module,exports){ ++"use strict" ++ ++function dupe_array(count, value, i) { ++ var c = count[i]|0 ++ if(c <= 0) { ++ return [] + } +- function d3_svg_line(projection) { +- var x = d3_geom_pointX, y = d3_geom_pointY, defined = d3_true, interpolate = d3_svg_lineLinear, interpolateKey = interpolate.key, tension = .7; +- function line(data) { +- var segments = [], points = [], i = -1, n = data.length, d, fx = d3_functor(x), fy = d3_functor(y); +- function segment() { +- segments.push("M", interpolate(projection(points), tension)); ++ var result = new Array(c), j ++ if(i === count.length-1) { ++ for(j=0; j 0) { ++ return dupe_number(count|0, value) + } +- while (++i < n) { +- if (defined.call(this, d = data[i], i)) { +- points.push([ +fx.call(this, d, i), +fy.call(this, d, i) ]); +- } else if (points.length) { +- segment(); +- points = []; +- } ++ break ++ case "object": ++ if(typeof (count.length) === "number") { ++ return dupe_array(count, value, 0) + } +- if (points.length) segment(); +- return segments.length ? segments.join("") : null; ++ break ++ } ++ return [] ++} ++ ++module.exports = dupe ++},{}],78:[function(require,module,exports){ ++"use strict" ++ ++module.exports = edgeToAdjacency ++ ++var uniq = require("uniq") ++ ++function edgeToAdjacency(edges, numVertices) { ++ var numEdges = edges.length ++ if(typeof numVertices !== "number") { ++ numVertices = 0 ++ for(var i=0; i 1 ? points.join("L") : points + "Z"; ++} else { ++ _isArray = Array.isArray; ++} ++ ++var isArray = _isArray; ++ ++var len = 0; ++var vertxNext = undefined; ++var customSchedulerFn = undefined; ++ ++var asap = function asap(callback, arg) { ++ queue[len] = callback; ++ queue[len + 1] = arg; ++ len += 2; ++ if (len === 2) { ++ // If len is 2, that means that we need to schedule an async flush. ++ // If additional callbacks are queued before the queue is flushed, they ++ // will be processed by this flush that we are scheduling. ++ if (customSchedulerFn) { ++ customSchedulerFn(flush); ++ } else { ++ scheduleFlush(); ++ } + } +- function d3_svg_lineLinearClosed(points) { +- return points.join("L") + "Z"; ++}; ++ ++function setScheduler(scheduleFn) { ++ customSchedulerFn = scheduleFn; ++} ++ ++function setAsap(asapFn) { ++ asap = asapFn; ++} ++ ++var browserWindow = typeof window !== 'undefined' ? window : undefined; ++var browserGlobal = browserWindow || {}; ++var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver; ++var isNode = typeof self === 'undefined' && typeof process !== 'undefined' && ({}).toString.call(process) === '[object process]'; ++ ++// test for web worker but not in IE10 ++var isWorker = typeof Uint8ClampedArray !== 'undefined' && typeof importScripts !== 'undefined' && typeof MessageChannel !== 'undefined'; ++ ++// node ++function useNextTick() { ++ // node version 0.10.x displays a deprecation warning when nextTick is used recursively ++ // see https://github.com/cujojs/when/issues/410 for details ++ return function () { ++ return process.nextTick(flush); ++ }; ++} ++ ++// vertx ++function useVertxTimer() { ++ return function () { ++ vertxNext(flush); ++ }; ++} ++ ++function useMutationObserver() { ++ var iterations = 0; ++ var observer = new BrowserMutationObserver(flush); ++ var node = document.createTextNode(''); ++ observer.observe(node, { characterData: true }); ++ ++ return function () { ++ node.data = iterations = ++iterations % 2; ++ }; ++} ++ ++// web worker ++function useMessageChannel() { ++ var channel = new MessageChannel(); ++ channel.port1.onmessage = flush; ++ return function () { ++ return channel.port2.postMessage(0); ++ }; ++} ++ ++function useSetTimeout() { ++ // Store setTimeout reference so es6-promise will be unaffected by ++ // other code modifying setTimeout (like sinon.useFakeTimers()) ++ var globalSetTimeout = setTimeout; ++ return function () { ++ return globalSetTimeout(flush, 1); ++ }; ++} ++ ++var queue = new Array(1000); ++function flush() { ++ for (var i = 0; i < len; i += 2) { ++ var callback = queue[i]; ++ var arg = queue[i + 1]; ++ ++ callback(arg); ++ ++ queue[i] = undefined; ++ queue[i + 1] = undefined; + } +- function d3_svg_lineStep(points) { +- var i = 0, n = points.length, p = points[0], path = [ p[0], ",", p[1] ]; +- while (++i < n) path.push("H", (p[0] + (p = points[i])[0]) / 2, "V", p[1]); +- if (n > 1) path.push("H", p[0]); +- return path.join(""); ++ ++ len = 0; ++} ++ ++function attemptVertx() { ++ try { ++ var r = require; ++ var vertx = r('vertx'); ++ vertxNext = vertx.runOnLoop || vertx.runOnContext; ++ return useVertxTimer(); ++ } catch (e) { ++ return useSetTimeout(); + } +- function d3_svg_lineStepBefore(points) { +- var i = 0, n = points.length, p = points[0], path = [ p[0], ",", p[1] ]; +- while (++i < n) path.push("V", (p = points[i])[1], "H", p[0]); +- return path.join(""); ++} ++ ++var scheduleFlush = undefined; ++// Decide what async method to use to triggering processing of queued callbacks: ++if (isNode) { ++ scheduleFlush = useNextTick(); ++} else if (BrowserMutationObserver) { ++ scheduleFlush = useMutationObserver(); ++} else if (isWorker) { ++ scheduleFlush = useMessageChannel(); ++} else if (browserWindow === undefined && typeof require === 'function') { ++ scheduleFlush = attemptVertx(); ++} else { ++ scheduleFlush = useSetTimeout(); ++} ++ ++function then(onFulfillment, onRejection) { ++ var _arguments = arguments; ++ ++ var parent = this; ++ ++ var child = new this.constructor(noop); ++ ++ if (child[PROMISE_ID] === undefined) { ++ makePromise(child); + } +- function d3_svg_lineStepAfter(points) { +- var i = 0, n = points.length, p = points[0], path = [ p[0], ",", p[1] ]; +- while (++i < n) path.push("H", (p = points[i])[0], "V", p[1]); +- return path.join(""); ++ ++ var _state = parent._state; ++ ++ if (_state) { ++ (function () { ++ var callback = _arguments[_state - 1]; ++ asap(function () { ++ return invokeCallback(_state, child, callback, parent._result); ++ }); ++ })(); ++ } else { ++ subscribe(parent, child, onFulfillment, onRejection); + } +- function d3_svg_lineCardinalOpen(points, tension) { +- return points.length < 4 ? d3_svg_lineLinear(points) : points[1] + d3_svg_lineHermite(points.slice(1, -1), d3_svg_lineCardinalTangents(points, tension)); ++ ++ return child; ++} ++ ++/** ++ `Promise.resolve` returns a promise that will become resolved with the ++ passed `value`. It is shorthand for the following: ++ ++ ```javascript ++ let promise = new Promise(function(resolve, reject){ ++ resolve(1); ++ }); ++ ++ promise.then(function(value){ ++ // value === 1 ++ }); ++ ``` ++ ++ Instead of writing the above, your code now simply becomes the following: ++ ++ ```javascript ++ let promise = Promise.resolve(1); ++ ++ promise.then(function(value){ ++ // value === 1 ++ }); ++ ``` ++ ++ @method resolve ++ @static ++ @param {Any} value value that the returned promise will be resolved with ++ Useful for tooling. ++ @return {Promise} a promise that will become fulfilled with the given ++ `value` ++*/ ++function resolve(object) { ++ /*jshint validthis:true */ ++ var Constructor = this; ++ ++ if (object && typeof object === 'object' && object.constructor === Constructor) { ++ return object; + } +- function d3_svg_lineCardinalClosed(points, tension) { +- return points.length < 3 ? d3_svg_lineLinearClosed(points) : points[0] + d3_svg_lineHermite((points.push(points[0]), +- points), d3_svg_lineCardinalTangents([ points[points.length - 2] ].concat(points, [ points[1] ]), tension)); ++ ++ var promise = new Constructor(noop); ++ _resolve(promise, object); ++ return promise; ++} ++ ++var PROMISE_ID = Math.random().toString(36).substring(16); ++ ++function noop() {} ++ ++var PENDING = void 0; ++var FULFILLED = 1; ++var REJECTED = 2; ++ ++var GET_THEN_ERROR = new ErrorObject(); ++ ++function selfFulfillment() { ++ return new TypeError("You cannot resolve a promise with itself"); ++} ++ ++function cannotReturnOwn() { ++ return new TypeError('A promises callback cannot return that same promise.'); ++} ++ ++function getThen(promise) { ++ try { ++ return promise.then; ++ } catch (error) { ++ GET_THEN_ERROR.error = error; ++ return GET_THEN_ERROR; + } +- function d3_svg_lineCardinal(points, tension) { +- return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite(points, d3_svg_lineCardinalTangents(points, tension)); ++} ++ ++function tryThen(then, value, fulfillmentHandler, rejectionHandler) { ++ try { ++ then.call(value, fulfillmentHandler, rejectionHandler); ++ } catch (e) { ++ return e; + } +- function d3_svg_lineHermite(points, tangents) { +- if (tangents.length < 1 || points.length != tangents.length && points.length != tangents.length + 2) { +- return d3_svg_lineLinear(points); +- } +- var quad = points.length != tangents.length, path = "", p0 = points[0], p = points[1], t0 = tangents[0], t = t0, pi = 1; +- if (quad) { +- path += "Q" + (p[0] - t0[0] * 2 / 3) + "," + (p[1] - t0[1] * 2 / 3) + "," + p[0] + "," + p[1]; +- p0 = points[1]; +- pi = 2; +- } +- if (tangents.length > 1) { +- t = tangents[1]; +- p = points[pi]; +- pi++; +- path += "C" + (p0[0] + t0[0]) + "," + (p0[1] + t0[1]) + "," + (p[0] - t[0]) + "," + (p[1] - t[1]) + "," + p[0] + "," + p[1]; +- for (var i = 2; i < tangents.length; i++, pi++) { +- p = points[pi]; +- t = tangents[i]; +- path += "S" + (p[0] - t[0]) + "," + (p[1] - t[1]) + "," + p[0] + "," + p[1]; ++} ++ ++function handleForeignThenable(promise, thenable, then) { ++ asap(function (promise) { ++ var sealed = false; ++ var error = tryThen(then, thenable, function (value) { ++ if (sealed) { ++ return; + } ++ sealed = true; ++ if (thenable !== value) { ++ _resolve(promise, value); ++ } else { ++ fulfill(promise, value); ++ } ++ }, function (reason) { ++ if (sealed) { ++ return; ++ } ++ sealed = true; ++ ++ _reject(promise, reason); ++ }, 'Settle: ' + (promise._label || ' unknown promise')); ++ ++ if (!sealed && error) { ++ sealed = true; ++ _reject(promise, error); + } +- if (quad) { +- var lp = points[pi]; +- path += "Q" + (p[0] + t[0] * 2 / 3) + "," + (p[1] + t[1] * 2 / 3) + "," + lp[0] + "," + lp[1]; +- } +- return path; +- } +- function d3_svg_lineCardinalTangents(points, tension) { +- var tangents = [], a = (1 - tension) / 2, p0, p1 = points[0], p2 = points[1], i = 1, n = points.length; +- while (++i < n) { +- p0 = p1; +- p1 = p2; +- p2 = points[i]; +- tangents.push([ a * (p2[0] - p0[0]), a * (p2[1] - p0[1]) ]); +- } +- return tangents; +- } +- function d3_svg_lineBasis(points) { +- if (points.length < 3) return d3_svg_lineLinear(points); +- var i = 1, n = points.length, pi = points[0], x0 = pi[0], y0 = pi[1], px = [ x0, x0, x0, (pi = points[1])[0] ], py = [ y0, y0, y0, pi[1] ], path = [ x0, ",", y0, "L", d3_svg_lineDot4(d3_svg_lineBasisBezier3, px), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier3, py) ]; +- points.push(points[n - 1]); +- while (++i <= n) { +- pi = points[i]; +- px.shift(); +- px.push(pi[0]); +- py.shift(); +- py.push(pi[1]); +- d3_svg_lineBasisBezier(path, px, py); +- } +- points.pop(); +- path.push("L", pi); +- return path.join(""); +- } +- function d3_svg_lineBasisOpen(points) { +- if (points.length < 4) return d3_svg_lineLinear(points); +- var path = [], i = -1, n = points.length, pi, px = [ 0 ], py = [ 0 ]; +- while (++i < 3) { +- pi = points[i]; +- px.push(pi[0]); +- py.push(pi[1]); +- } +- path.push(d3_svg_lineDot4(d3_svg_lineBasisBezier3, px) + "," + d3_svg_lineDot4(d3_svg_lineBasisBezier3, py)); +- --i; +- while (++i < n) { +- pi = points[i]; +- px.shift(); +- px.push(pi[0]); +- py.shift(); +- py.push(pi[1]); +- d3_svg_lineBasisBezier(path, px, py); +- } +- return path.join(""); ++ }, promise); ++} ++ ++function handleOwnThenable(promise, thenable) { ++ if (thenable._state === FULFILLED) { ++ fulfill(promise, thenable._result); ++ } else if (thenable._state === REJECTED) { ++ _reject(promise, thenable._result); ++ } else { ++ subscribe(thenable, undefined, function (value) { ++ return _resolve(promise, value); ++ }, function (reason) { ++ return _reject(promise, reason); ++ }); + } +- function d3_svg_lineBasisClosed(points) { +- var path, i = -1, n = points.length, m = n + 4, pi, px = [], py = []; +- while (++i < 4) { +- pi = points[i % n]; +- px.push(pi[0]); +- py.push(pi[1]); +- } +- path = [ d3_svg_lineDot4(d3_svg_lineBasisBezier3, px), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier3, py) ]; +- --i; +- while (++i < m) { +- pi = points[i % n]; +- px.shift(); +- px.push(pi[0]); +- py.shift(); +- py.push(pi[1]); +- d3_svg_lineBasisBezier(path, px, py); ++} ++ ++function handleMaybeThenable(promise, maybeThenable, then$$) { ++ if (maybeThenable.constructor === promise.constructor && then$$ === then && maybeThenable.constructor.resolve === resolve) { ++ handleOwnThenable(promise, maybeThenable); ++ } else { ++ if (then$$ === GET_THEN_ERROR) { ++ _reject(promise, GET_THEN_ERROR.error); ++ } else if (then$$ === undefined) { ++ fulfill(promise, maybeThenable); ++ } else if (isFunction(then$$)) { ++ handleForeignThenable(promise, maybeThenable, then$$); ++ } else { ++ fulfill(promise, maybeThenable); + } +- return path.join(""); + } +- function d3_svg_lineBundle(points, tension) { +- var n = points.length - 1; +- if (n) { +- var x0 = points[0][0], y0 = points[0][1], dx = points[n][0] - x0, dy = points[n][1] - y0, i = -1, p, t; +- while (++i <= n) { +- p = points[i]; +- t = i / n; +- p[0] = tension * p[0] + (1 - tension) * (x0 + t * dx); +- p[1] = tension * p[1] + (1 - tension) * (y0 + t * dy); +- } +- } +- return d3_svg_lineBasis(points); ++} ++ ++function _resolve(promise, value) { ++ if (promise === value) { ++ _reject(promise, selfFulfillment()); ++ } else if (objectOrFunction(value)) { ++ handleMaybeThenable(promise, value, getThen(value)); ++ } else { ++ fulfill(promise, value); + } +- function d3_svg_lineDot4(a, b) { +- return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3]; ++} ++ ++function publishRejection(promise) { ++ if (promise._onerror) { ++ promise._onerror(promise._result); + } +- var d3_svg_lineBasisBezier1 = [ 0, 2 / 3, 1 / 3, 0 ], d3_svg_lineBasisBezier2 = [ 0, 1 / 3, 2 / 3, 0 ], d3_svg_lineBasisBezier3 = [ 0, 1 / 6, 2 / 3, 1 / 6 ]; +- function d3_svg_lineBasisBezier(path, x, y) { +- path.push("C", d3_svg_lineDot4(d3_svg_lineBasisBezier1, x), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier1, y), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier2, x), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier2, y), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier3, x), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier3, y)); ++ ++ publish(promise); ++} ++ ++function fulfill(promise, value) { ++ if (promise._state !== PENDING) { ++ return; + } +- function d3_svg_lineSlope(p0, p1) { +- return (p1[1] - p0[1]) / (p1[0] - p0[0]); ++ ++ promise._result = value; ++ promise._state = FULFILLED; ++ ++ if (promise._subscribers.length !== 0) { ++ asap(publish, promise); + } +- function d3_svg_lineFiniteDifferences(points) { +- var i = 0, j = points.length - 1, m = [], p0 = points[0], p1 = points[1], d = m[0] = d3_svg_lineSlope(p0, p1); +- while (++i < j) { +- m[i] = (d + (d = d3_svg_lineSlope(p0 = p1, p1 = points[i + 1]))) / 2; +- } +- m[i] = d; +- return m; ++} ++ ++function _reject(promise, reason) { ++ if (promise._state !== PENDING) { ++ return; + } +- function d3_svg_lineMonotoneTangents(points) { +- var tangents = [], d, a, b, s, m = d3_svg_lineFiniteDifferences(points), i = -1, j = points.length - 1; +- while (++i < j) { +- d = d3_svg_lineSlope(points[i], points[i + 1]); +- if (abs(d) < ε) { +- m[i] = m[i + 1] = 0; +- } else { +- a = m[i] / d; +- b = m[i + 1] / d; +- s = a * a + b * b; +- if (s > 9) { +- s = d * 3 / Math.sqrt(s); +- m[i] = s * a; +- m[i + 1] = s * b; +- } +- } +- } +- i = -1; +- while (++i <= j) { +- s = (points[Math.min(j, i + 1)][0] - points[Math.max(0, i - 1)][0]) / (6 * (1 + m[i] * m[i])); +- tangents.push([ s || 0, m[i] * s || 0 ]); +- } +- return tangents; ++ promise._state = REJECTED; ++ promise._result = reason; ++ ++ asap(publishRejection, promise); ++} ++ ++function subscribe(parent, child, onFulfillment, onRejection) { ++ var _subscribers = parent._subscribers; ++ var length = _subscribers.length; ++ ++ parent._onerror = null; ++ ++ _subscribers[length] = child; ++ _subscribers[length + FULFILLED] = onFulfillment; ++ _subscribers[length + REJECTED] = onRejection; ++ ++ if (length === 0 && parent._state) { ++ asap(publish, parent); + } +- function d3_svg_lineMonotone(points) { +- return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite(points, d3_svg_lineMonotoneTangents(points)); ++} ++ ++function publish(promise) { ++ var subscribers = promise._subscribers; ++ var settled = promise._state; ++ ++ if (subscribers.length === 0) { ++ return; + } +- d3.svg.line.radial = function() { +- var line = d3_svg_line(d3_svg_lineRadial); +- line.radius = line.x, delete line.x; +- line.angle = line.y, delete line.y; +- return line; +- }; +- function d3_svg_lineRadial(points) { +- var point, i = -1, n = points.length, r, a; +- while (++i < n) { +- point = points[i]; +- r = point[0]; +- a = point[1] - halfπ; +- point[0] = r * Math.cos(a); +- point[1] = r * Math.sin(a); ++ ++ var child = undefined, ++ callback = undefined, ++ detail = promise._result; ++ ++ for (var i = 0; i < subscribers.length; i += 3) { ++ child = subscribers[i]; ++ callback = subscribers[i + settled]; ++ ++ if (child) { ++ invokeCallback(settled, child, callback, detail); ++ } else { ++ callback(detail); + } +- return points; + } +- function d3_svg_area(projection) { +- var x0 = d3_geom_pointX, x1 = d3_geom_pointX, y0 = 0, y1 = d3_geom_pointY, defined = d3_true, interpolate = d3_svg_lineLinear, interpolateKey = interpolate.key, interpolateReverse = interpolate, L = "L", tension = .7; +- function area(data) { +- var segments = [], points0 = [], points1 = [], i = -1, n = data.length, d, fx0 = d3_functor(x0), fy0 = d3_functor(y0), fx1 = x0 === x1 ? function() { +- return x; +- } : d3_functor(x1), fy1 = y0 === y1 ? function() { +- return y; +- } : d3_functor(y1), x, y; +- function segment() { +- segments.push("M", interpolate(projection(points1), tension), L, interpolateReverse(projection(points0.reverse()), tension), "Z"); +- } +- while (++i < n) { +- if (defined.call(this, d = data[i], i)) { +- points0.push([ x = +fx0.call(this, d, i), y = +fy0.call(this, d, i) ]); +- points1.push([ +fx1.call(this, d, i), +fy1.call(this, d, i) ]); +- } else if (points0.length) { +- segment(); +- points0 = []; +- points1 = []; +- } +- } +- if (points0.length) segment(); +- return segments.length ? segments.join("") : null; +- } +- area.x = function(_) { +- if (!arguments.length) return x1; +- x0 = x1 = _; +- return area; +- }; +- area.x0 = function(_) { +- if (!arguments.length) return x0; +- x0 = _; +- return area; +- }; +- area.x1 = function(_) { +- if (!arguments.length) return x1; +- x1 = _; +- return area; +- }; +- area.y = function(_) { +- if (!arguments.length) return y1; +- y0 = y1 = _; +- return area; +- }; +- area.y0 = function(_) { +- if (!arguments.length) return y0; +- y0 = _; +- return area; +- }; +- area.y1 = function(_) { +- if (!arguments.length) return y1; +- y1 = _; +- return area; +- }; +- area.defined = function(_) { +- if (!arguments.length) return defined; +- defined = _; +- return area; +- }; +- area.interpolate = function(_) { +- if (!arguments.length) return interpolateKey; +- if (typeof _ === "function") interpolateKey = interpolate = _; else interpolateKey = (interpolate = d3_svg_lineInterpolators.get(_) || d3_svg_lineLinear).key; +- interpolateReverse = interpolate.reverse || interpolate; +- L = interpolate.closed ? "M" : "L"; +- return area; +- }; +- area.tension = function(_) { +- if (!arguments.length) return tension; +- tension = _; +- return area; +- }; +- return area; ++ ++ promise._subscribers.length = 0; ++} ++ ++function ErrorObject() { ++ this.error = null; ++} ++ ++var TRY_CATCH_ERROR = new ErrorObject(); ++ ++function tryCatch(callback, detail) { ++ try { ++ return callback(detail); ++ } catch (e) { ++ TRY_CATCH_ERROR.error = e; ++ return TRY_CATCH_ERROR; + } +- d3_svg_lineStepBefore.reverse = d3_svg_lineStepAfter; +- d3_svg_lineStepAfter.reverse = d3_svg_lineStepBefore; +- d3.svg.area = function() { +- return d3_svg_area(d3_identity); +- }; +- d3.svg.area.radial = function() { +- var area = d3_svg_area(d3_svg_lineRadial); +- area.radius = area.x, delete area.x; +- area.innerRadius = area.x0, delete area.x0; +- area.outerRadius = area.x1, delete area.x1; +- area.angle = area.y, delete area.y; +- area.startAngle = area.y0, delete area.y0; +- area.endAngle = area.y1, delete area.y1; +- return area; +- }; +- d3.svg.chord = function() { +- var source = d3_source, target = d3_target, radius = d3_svg_chordRadius, startAngle = d3_svg_arcStartAngle, endAngle = d3_svg_arcEndAngle; +- function chord(d, i) { +- var s = subgroup(this, source, d, i), t = subgroup(this, target, d, i); +- return "M" + s.p0 + arc(s.r, s.p1, s.a1 - s.a0) + (equals(s, t) ? curve(s.r, s.p1, s.r, s.p0) : curve(s.r, s.p1, t.r, t.p0) + arc(t.r, t.p1, t.a1 - t.a0) + curve(t.r, t.p1, s.r, s.p0)) + "Z"; +- } +- function subgroup(self, f, d, i) { +- var subgroup = f.call(self, d, i), r = radius.call(self, subgroup, i), a0 = startAngle.call(self, subgroup, i) - halfπ, a1 = endAngle.call(self, subgroup, i) - halfπ; +- return { +- r: r, +- a0: a0, +- a1: a1, +- p0: [ r * Math.cos(a0), r * Math.sin(a0) ], +- p1: [ r * Math.cos(a1), r * Math.sin(a1) ] +- }; +- } +- function equals(a, b) { +- return a.a0 == b.a0 && a.a1 == b.a1; +- } +- function arc(r, p, a) { +- return "A" + r + "," + r + " 0 " + +(a > π) + ",1 " + p; ++} ++ ++function invokeCallback(settled, promise, callback, detail) { ++ var hasCallback = isFunction(callback), ++ value = undefined, ++ error = undefined, ++ succeeded = undefined, ++ failed = undefined; ++ ++ if (hasCallback) { ++ value = tryCatch(callback, detail); ++ ++ if (value === TRY_CATCH_ERROR) { ++ failed = true; ++ error = value.error; ++ value = null; ++ } else { ++ succeeded = true; + } +- function curve(r0, p0, r1, p1) { +- return "Q 0,0 " + p1; ++ ++ if (promise === value) { ++ _reject(promise, cannotReturnOwn()); ++ return; + } +- chord.radius = function(v) { +- if (!arguments.length) return radius; +- radius = d3_functor(v); +- return chord; +- }; +- chord.source = function(v) { +- if (!arguments.length) return source; +- source = d3_functor(v); +- return chord; +- }; +- chord.target = function(v) { +- if (!arguments.length) return target; +- target = d3_functor(v); +- return chord; +- }; +- chord.startAngle = function(v) { +- if (!arguments.length) return startAngle; +- startAngle = d3_functor(v); +- return chord; +- }; +- chord.endAngle = function(v) { +- if (!arguments.length) return endAngle; +- endAngle = d3_functor(v); +- return chord; +- }; +- return chord; +- }; +- function d3_svg_chordRadius(d) { +- return d.radius; ++ } else { ++ value = detail; ++ succeeded = true; + } +- d3.svg.diagonal = function() { +- var source = d3_source, target = d3_target, projection = d3_svg_diagonalProjection; +- function diagonal(d, i) { +- var p0 = source.call(this, d, i), p3 = target.call(this, d, i), m = (p0.y + p3.y) / 2, p = [ p0, { +- x: p0.x, +- y: m +- }, { +- x: p3.x, +- y: m +- }, p3 ]; +- p = p.map(projection); +- return "M" + p[0] + "C" + p[1] + " " + p[2] + " " + p[3]; ++ ++ if (promise._state !== PENDING) { ++ // noop ++ } else if (hasCallback && succeeded) { ++ _resolve(promise, value); ++ } else if (failed) { ++ _reject(promise, error); ++ } else if (settled === FULFILLED) { ++ fulfill(promise, value); ++ } else if (settled === REJECTED) { ++ _reject(promise, value); + } +- diagonal.source = function(x) { +- if (!arguments.length) return source; +- source = d3_functor(x); +- return diagonal; +- }; +- diagonal.target = function(x) { +- if (!arguments.length) return target; +- target = d3_functor(x); +- return diagonal; +- }; +- diagonal.projection = function(x) { +- if (!arguments.length) return projection; +- projection = x; +- return diagonal; +- }; +- return diagonal; +- }; +- function d3_svg_diagonalProjection(d) { +- return [ d.x, d.y ]; ++} ++ ++function initializePromise(promise, resolver) { ++ try { ++ resolver(function resolvePromise(value) { ++ _resolve(promise, value); ++ }, function rejectPromise(reason) { ++ _reject(promise, reason); ++ }); ++ } catch (e) { ++ _reject(promise, e); + } +- d3.svg.diagonal.radial = function() { +- var diagonal = d3.svg.diagonal(), projection = d3_svg_diagonalProjection, projection_ = diagonal.projection; +- diagonal.projection = function(x) { +- return arguments.length ? projection_(d3_svg_diagonalRadialProjection(projection = x)) : projection; +- }; +- return diagonal; +- }; +- function d3_svg_diagonalRadialProjection(projection) { +- return function() { +- var d = projection.apply(this, arguments), r = d[0], a = d[1] - halfπ; +- return [ r * Math.cos(a), r * Math.sin(a) ]; +- }; ++} ++ ++var id = 0; ++function nextId() { ++ return id++; ++} ++ ++function makePromise(promise) { ++ promise[PROMISE_ID] = id++; ++ promise._state = undefined; ++ promise._result = undefined; ++ promise._subscribers = []; ++} ++ ++function Enumerator(Constructor, input) { ++ this._instanceConstructor = Constructor; ++ this.promise = new Constructor(noop); ++ ++ if (!this.promise[PROMISE_ID]) { ++ makePromise(this.promise); + } +- d3.svg.symbol = function() { +- var type = d3_svg_symbolType, size = d3_svg_symbolSize; +- function symbol(d, i) { +- return (d3_svg_symbols.get(type.call(this, d, i)) || d3_svg_symbolCircle)(size.call(this, d, i)); ++ ++ if (isArray(input)) { ++ this._input = input; ++ this.length = input.length; ++ this._remaining = input.length; ++ ++ this._result = new Array(this.length); ++ ++ if (this.length === 0) { ++ fulfill(this.promise, this._result); ++ } else { ++ this.length = this.length || 0; ++ this._enumerate(); ++ if (this._remaining === 0) { ++ fulfill(this.promise, this._result); ++ } + } +- symbol.type = function(x) { +- if (!arguments.length) return type; +- type = d3_functor(x); +- return symbol; +- }; +- symbol.size = function(x) { +- if (!arguments.length) return size; +- size = d3_functor(x); +- return symbol; +- }; +- return symbol; +- }; +- function d3_svg_symbolSize() { +- return 64; +- } +- function d3_svg_symbolType() { +- return "circle"; ++ } else { ++ _reject(this.promise, validationError()); + } +- function d3_svg_symbolCircle(size) { +- var r = Math.sqrt(size / π); +- return "M0," + r + "A" + r + "," + r + " 0 1,1 0," + -r + "A" + r + "," + r + " 0 1,1 0," + r + "Z"; ++} ++ ++function validationError() { ++ return new Error('Array Methods must be provided an Array'); ++}; ++ ++Enumerator.prototype._enumerate = function () { ++ var length = this.length; ++ var _input = this._input; ++ ++ for (var i = 0; this._state === PENDING && i < length; i++) { ++ this._eachEntry(_input[i], i); + } +- var d3_svg_symbols = d3.map({ +- circle: d3_svg_symbolCircle, +- cross: function(size) { +- var r = Math.sqrt(size / 5) / 2; +- return "M" + -3 * r + "," + -r + "H" + -r + "V" + -3 * r + "H" + r + "V" + -r + "H" + 3 * r + "V" + r + "H" + r + "V" + 3 * r + "H" + -r + "V" + r + "H" + -3 * r + "Z"; +- }, +- diamond: function(size) { +- var ry = Math.sqrt(size / (2 * d3_svg_symbolTan30)), rx = ry * d3_svg_symbolTan30; +- return "M0," + -ry + "L" + rx + ",0" + " 0," + ry + " " + -rx + ",0" + "Z"; +- }, +- square: function(size) { +- var r = Math.sqrt(size) / 2; +- return "M" + -r + "," + -r + "L" + r + "," + -r + " " + r + "," + r + " " + -r + "," + r + "Z"; +- }, +- "triangle-down": function(size) { +- var rx = Math.sqrt(size / d3_svg_symbolSqrt3), ry = rx * d3_svg_symbolSqrt3 / 2; +- return "M0," + ry + "L" + rx + "," + -ry + " " + -rx + "," + -ry + "Z"; +- }, +- "triangle-up": function(size) { +- var rx = Math.sqrt(size / d3_svg_symbolSqrt3), ry = rx * d3_svg_symbolSqrt3 / 2; +- return "M0," + -ry + "L" + rx + "," + ry + " " + -rx + "," + ry + "Z"; ++}; ++ ++Enumerator.prototype._eachEntry = function (entry, i) { ++ var c = this._instanceConstructor; ++ var resolve$$ = c.resolve; ++ ++ if (resolve$$ === resolve) { ++ var _then = getThen(entry); ++ ++ if (_then === then && entry._state !== PENDING) { ++ this._settledAt(entry._state, i, entry._result); ++ } else if (typeof _then !== 'function') { ++ this._remaining--; ++ this._result[i] = entry; ++ } else if (c === Promise) { ++ var promise = new c(noop); ++ handleMaybeThenable(promise, entry, _then); ++ this._willSettleAt(promise, i); ++ } else { ++ this._willSettleAt(new c(function (resolve$$) { ++ return resolve$$(entry); ++ }), i); + } +- }); +- d3.svg.symbolTypes = d3_svg_symbols.keys(); +- var d3_svg_symbolSqrt3 = Math.sqrt(3), d3_svg_symbolTan30 = Math.tan(30 * d3_radians); +- d3_selectionPrototype.transition = function(name) { +- var id = d3_transitionInheritId || ++d3_transitionId, ns = d3_transitionNamespace(name), subgroups = [], subgroup, node, transition = d3_transitionInherit || { +- time: Date.now(), +- ease: d3_ease_cubicInOut, +- delay: 0, +- duration: 250 +- }; +- for (var j = -1, m = this.length; ++j < m; ) { +- subgroups.push(subgroup = []); +- for (var group = this[j], i = -1, n = group.length; ++i < n; ) { +- if (node = group[i]) d3_transitionNode(node, i, ns, id, transition); +- subgroup.push(node); +- } ++ } else { ++ this._willSettleAt(resolve$$(entry), i); ++ } ++}; ++ ++Enumerator.prototype._settledAt = function (state, i, value) { ++ var promise = this.promise; ++ ++ if (promise._state === PENDING) { ++ this._remaining--; ++ ++ if (state === REJECTED) { ++ _reject(promise, value); ++ } else { ++ this._result[i] = value; + } +- return d3_transition(subgroups, ns, id); +- }; +- d3_selectionPrototype.interrupt = function(name) { +- return this.each(name == null ? d3_selection_interrupt : d3_selection_interruptNS(d3_transitionNamespace(name))); +- }; +- var d3_selection_interrupt = d3_selection_interruptNS(d3_transitionNamespace()); +- function d3_selection_interruptNS(ns) { +- return function() { +- var lock, activeId, active; +- if ((lock = this[ns]) && (active = lock[activeId = lock.active])) { +- active.timer.c = null; +- active.timer.t = NaN; +- if (--lock.count) delete lock[activeId]; else delete this[ns]; +- lock.active += .5; +- active.event && active.event.interrupt.call(this, this.__data__, active.index); +- } +- }; + } +- function d3_transition(groups, ns, id) { +- d3_subclass(groups, d3_transitionPrototype); +- groups.namespace = ns; +- groups.id = id; +- return groups; ++ ++ if (this._remaining === 0) { ++ fulfill(promise, this._result); + } +- var d3_transitionPrototype = [], d3_transitionId = 0, d3_transitionInheritId, d3_transitionInherit; +- d3_transitionPrototype.call = d3_selectionPrototype.call; +- d3_transitionPrototype.empty = d3_selectionPrototype.empty; +- d3_transitionPrototype.node = d3_selectionPrototype.node; +- d3_transitionPrototype.size = d3_selectionPrototype.size; +- d3.transition = function(selection, name) { +- return selection && selection.transition ? d3_transitionInheritId ? selection.transition(name) : selection : d3.selection().transition(selection); +- }; +- d3.transition.prototype = d3_transitionPrototype; +- d3_transitionPrototype.select = function(selector) { +- var id = this.id, ns = this.namespace, subgroups = [], subgroup, subnode, node; +- selector = d3_selection_selector(selector); +- for (var j = -1, m = this.length; ++j < m; ) { +- subgroups.push(subgroup = []); +- for (var group = this[j], i = -1, n = group.length; ++i < n; ) { +- if ((node = group[i]) && (subnode = selector.call(node, node.__data__, i, j))) { +- if ("__data__" in node) subnode.__data__ = node.__data__; +- d3_transitionNode(subnode, i, ns, id, node[ns][id]); +- subgroup.push(subnode); +- } else { +- subgroup.push(null); +- } ++}; ++ ++Enumerator.prototype._willSettleAt = function (promise, i) { ++ var enumerator = this; ++ ++ subscribe(promise, undefined, function (value) { ++ return enumerator._settledAt(FULFILLED, i, value); ++ }, function (reason) { ++ return enumerator._settledAt(REJECTED, i, reason); ++ }); ++}; ++ ++/** ++ `Promise.all` accepts an array of promises, and returns a new promise which ++ is fulfilled with an array of fulfillment values for the passed promises, or ++ rejected with the reason of the first passed promise to be rejected. It casts all ++ elements of the passed iterable to promises as it runs this algorithm. ++ ++ Example: ++ ++ ```javascript ++ let promise1 = resolve(1); ++ let promise2 = resolve(2); ++ let promise3 = resolve(3); ++ let promises = [ promise1, promise2, promise3 ]; ++ ++ Promise.all(promises).then(function(array){ ++ // The array here would be [ 1, 2, 3 ]; ++ }); ++ ``` ++ ++ If any of the `promises` given to `all` are rejected, the first promise ++ that is rejected will be given as an argument to the returned promises's ++ rejection handler. For example: ++ ++ Example: ++ ++ ```javascript ++ let promise1 = resolve(1); ++ let promise2 = reject(new Error("2")); ++ let promise3 = reject(new Error("3")); ++ let promises = [ promise1, promise2, promise3 ]; ++ ++ Promise.all(promises).then(function(array){ ++ // Code here never runs because there are rejected promises! ++ }, function(error) { ++ // error.message === "2" ++ }); ++ ``` ++ ++ @method all ++ @static ++ @param {Array} entries array of promises ++ @param {String} label optional string for labeling the promise. ++ Useful for tooling. ++ @return {Promise} promise that is fulfilled when all `promises` have been ++ fulfilled, or rejected if any of them become rejected. ++ @static ++*/ ++function all(entries) { ++ return new Enumerator(this, entries).promise; ++} ++ ++/** ++ `Promise.race` returns a new promise which is settled in the same way as the ++ first passed promise to settle. ++ ++ Example: ++ ++ ```javascript ++ let promise1 = new Promise(function(resolve, reject){ ++ setTimeout(function(){ ++ resolve('promise 1'); ++ }, 200); ++ }); ++ ++ let promise2 = new Promise(function(resolve, reject){ ++ setTimeout(function(){ ++ resolve('promise 2'); ++ }, 100); ++ }); ++ ++ Promise.race([promise1, promise2]).then(function(result){ ++ // result === 'promise 2' because it was resolved before promise1 ++ // was resolved. ++ }); ++ ``` ++ ++ `Promise.race` is deterministic in that only the state of the first ++ settled promise matters. For example, even if other promises given to the ++ `promises` array argument are resolved, but the first settled promise has ++ become rejected before the other promises became fulfilled, the returned ++ promise will become rejected: ++ ++ ```javascript ++ let promise1 = new Promise(function(resolve, reject){ ++ setTimeout(function(){ ++ resolve('promise 1'); ++ }, 200); ++ }); ++ ++ let promise2 = new Promise(function(resolve, reject){ ++ setTimeout(function(){ ++ reject(new Error('promise 2')); ++ }, 100); ++ }); ++ ++ Promise.race([promise1, promise2]).then(function(result){ ++ // Code here never runs ++ }, function(reason){ ++ // reason.message === 'promise 2' because promise 2 became rejected before ++ // promise 1 became fulfilled ++ }); ++ ``` ++ ++ An example real-world use case is implementing timeouts: ++ ++ ```javascript ++ Promise.race([ajax('foo.json'), timeout(5000)]) ++ ``` ++ ++ @method race ++ @static ++ @param {Array} promises array of promises to observe ++ Useful for tooling. ++ @return {Promise} a promise which settles in the same way as the first passed ++ promise to settle. ++*/ ++function race(entries) { ++ /*jshint validthis:true */ ++ var Constructor = this; ++ ++ if (!isArray(entries)) { ++ return new Constructor(function (_, reject) { ++ return reject(new TypeError('You must pass an array to race.')); ++ }); ++ } else { ++ return new Constructor(function (resolve, reject) { ++ var length = entries.length; ++ for (var i = 0; i < length; i++) { ++ Constructor.resolve(entries[i]).then(resolve, reject); + } +- } +- return d3_transition(subgroups, ns, id); +- }; +- d3_transitionPrototype.selectAll = function(selector) { +- var id = this.id, ns = this.namespace, subgroups = [], subgroup, subnodes, node, subnode, transition; +- selector = d3_selection_selectorAll(selector); +- for (var j = -1, m = this.length; ++j < m; ) { +- for (var group = this[j], i = -1, n = group.length; ++i < n; ) { +- if (node = group[i]) { +- transition = node[ns][id]; +- subnodes = selector.call(node, node.__data__, i, j); +- subgroups.push(subgroup = []); +- for (var k = -1, o = subnodes.length; ++k < o; ) { +- if (subnode = subnodes[k]) d3_transitionNode(subnode, k, ns, id, transition); +- subgroup.push(subnode); ++ }); ++ } ++} ++ ++/** ++ `Promise.reject` returns a promise rejected with the passed `reason`. ++ It is shorthand for the following: ++ ++ ```javascript ++ let promise = new Promise(function(resolve, reject){ ++ reject(new Error('WHOOPS')); ++ }); ++ ++ promise.then(function(value){ ++ // Code here doesn't run because the promise is rejected! ++ }, function(reason){ ++ // reason.message === 'WHOOPS' ++ }); ++ ``` ++ ++ Instead of writing the above, your code now simply becomes the following: ++ ++ ```javascript ++ let promise = Promise.reject(new Error('WHOOPS')); ++ ++ promise.then(function(value){ ++ // Code here doesn't run because the promise is rejected! ++ }, function(reason){ ++ // reason.message === 'WHOOPS' ++ }); ++ ``` ++ ++ @method reject ++ @static ++ @param {Any} reason value that the returned promise will be rejected with. ++ Useful for tooling. ++ @return {Promise} a promise rejected with the given `reason`. ++*/ ++function reject(reason) { ++ /*jshint validthis:true */ ++ var Constructor = this; ++ var promise = new Constructor(noop); ++ _reject(promise, reason); ++ return promise; ++} ++ ++function needsResolver() { ++ throw new TypeError('You must pass a resolver function as the first argument to the promise constructor'); ++} ++ ++function needsNew() { ++ throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function."); ++} ++ ++/** ++ Promise objects represent the eventual result of an asynchronous operation. The ++ primary way of interacting with a promise is through its `then` method, which ++ registers callbacks to receive either a promise's eventual value or the reason ++ why the promise cannot be fulfilled. ++ ++ Terminology ++ ----------- ++ ++ - `promise` is an object or function with a `then` method whose behavior conforms to this specification. ++ - `thenable` is an object or function that defines a `then` method. ++ - `value` is any legal JavaScript value (including undefined, a thenable, or a promise). ++ - `exception` is a value that is thrown using the throw statement. ++ - `reason` is a value that indicates why a promise was rejected. ++ - `settled` the final resting state of a promise, fulfilled or rejected. ++ ++ A promise can be in one of three states: pending, fulfilled, or rejected. ++ ++ Promises that are fulfilled have a fulfillment value and are in the fulfilled ++ state. Promises that are rejected have a rejection reason and are in the ++ rejected state. A fulfillment value is never a thenable. ++ ++ Promises can also be said to *resolve* a value. If this value is also a ++ promise, then the original promise's settled state will match the value's ++ settled state. So a promise that *resolves* a promise that rejects will ++ itself reject, and a promise that *resolves* a promise that fulfills will ++ itself fulfill. ++ ++ ++ Basic Usage: ++ ------------ ++ ++ ```js ++ let promise = new Promise(function(resolve, reject) { ++ // on success ++ resolve(value); ++ ++ // on failure ++ reject(reason); ++ }); ++ ++ promise.then(function(value) { ++ // on fulfillment ++ }, function(reason) { ++ // on rejection ++ }); ++ ``` ++ ++ Advanced Usage: ++ --------------- ++ ++ Promises shine when abstracting away asynchronous interactions such as ++ `XMLHttpRequest`s. ++ ++ ```js ++ function getJSON(url) { ++ return new Promise(function(resolve, reject){ ++ let xhr = new XMLHttpRequest(); ++ ++ xhr.open('GET', url); ++ xhr.onreadystatechange = handler; ++ xhr.responseType = 'json'; ++ xhr.setRequestHeader('Accept', 'application/json'); ++ xhr.send(); ++ ++ function handler() { ++ if (this.readyState === this.DONE) { ++ if (this.status === 200) { ++ resolve(this.response); ++ } else { ++ reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']')); + } + } +- } +- } +- return d3_transition(subgroups, ns, id); +- }; +- d3_transitionPrototype.filter = function(filter) { +- var subgroups = [], subgroup, group, node; +- if (typeof filter !== "function") filter = d3_selection_filter(filter); +- for (var j = 0, m = this.length; j < m; j++) { +- subgroups.push(subgroup = []); +- for (var group = this[j], i = 0, n = group.length; i < n; i++) { +- if ((node = group[i]) && filter.call(node, node.__data__, i, j)) { +- subgroup.push(node); +- } +- } +- } +- return d3_transition(subgroups, this.namespace, this.id); +- }; +- d3_transitionPrototype.tween = function(name, tween) { +- var id = this.id, ns = this.namespace; +- if (arguments.length < 2) return this.node()[ns][id].tween.get(name); +- return d3_selection_each(this, tween == null ? function(node) { +- node[ns][id].tween.remove(name); +- } : function(node) { +- node[ns][id].tween.set(name, tween); ++ }; + }); +- }; +- function d3_transition_tween(groups, name, value, tween) { +- var id = groups.id, ns = groups.namespace; +- return d3_selection_each(groups, typeof value === "function" ? function(node, i, j) { +- node[ns][id].tween.set(name, tween(value.call(node, node.__data__, i, j))); +- } : (value = tween(value), function(node) { +- node[ns][id].tween.set(name, value); +- })); + } +- d3_transitionPrototype.attr = function(nameNS, value) { +- if (arguments.length < 2) { +- for (value in nameNS) this.attr(value, nameNS[value]); +- return this; +- } +- var interpolate = nameNS == "transform" ? d3_interpolateTransform : d3_interpolate, name = d3.ns.qualify(nameNS); +- function attrNull() { +- this.removeAttribute(name); +- } +- function attrNullNS() { +- this.removeAttributeNS(name.space, name.local); +- } +- function attrTween(b) { +- return b == null ? attrNull : (b += "", function() { +- var a = this.getAttribute(name), i; +- return a !== b && (i = interpolate(a, b), function(t) { +- this.setAttribute(name, i(t)); +- }); +- }); ++ ++ getJSON('/posts.json').then(function(json) { ++ // on fulfillment ++ }, function(reason) { ++ // on rejection ++ }); ++ ``` ++ ++ Unlike callbacks, promises are great composable primitives. ++ ++ ```js ++ Promise.all([ ++ getJSON('/posts'), ++ getJSON('/comments') ++ ]).then(function(values){ ++ values[0] // => postsJSON ++ values[1] // => commentsJSON ++ ++ return values; ++ }); ++ ``` ++ ++ @class Promise ++ @param {function} resolver ++ Useful for tooling. ++ @constructor ++*/ ++function Promise(resolver) { ++ this[PROMISE_ID] = nextId(); ++ this._result = this._state = undefined; ++ this._subscribers = []; ++ ++ if (noop !== resolver) { ++ typeof resolver !== 'function' && needsResolver(); ++ this instanceof Promise ? initializePromise(this, resolver) : needsNew(); ++ } ++} ++ ++Promise.all = all; ++Promise.race = race; ++Promise.resolve = resolve; ++Promise.reject = reject; ++Promise._setScheduler = setScheduler; ++Promise._setAsap = setAsap; ++Promise._asap = asap; ++ ++Promise.prototype = { ++ constructor: Promise, ++ ++ /** ++ The primary way of interacting with a promise is through its `then` method, ++ which registers callbacks to receive either a promise's eventual value or the ++ reason why the promise cannot be fulfilled. ++ ++ ```js ++ findUser().then(function(user){ ++ // user is available ++ }, function(reason){ ++ // user is unavailable, and you are given the reason why ++ }); ++ ``` ++ ++ Chaining ++ -------- ++ ++ The return value of `then` is itself a promise. This second, 'downstream' ++ promise is resolved with the return value of the first promise's fulfillment ++ or rejection handler, or rejected if the handler throws an exception. ++ ++ ```js ++ findUser().then(function (user) { ++ return user.name; ++ }, function (reason) { ++ return 'default name'; ++ }).then(function (userName) { ++ // If `findUser` fulfilled, `userName` will be the user's name, otherwise it ++ // will be `'default name'` ++ }); ++ ++ findUser().then(function (user) { ++ throw new Error('Found user, but still unhappy'); ++ }, function (reason) { ++ throw new Error('`findUser` rejected and we're unhappy'); ++ }).then(function (value) { ++ // never reached ++ }, function (reason) { ++ // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'. ++ // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'. ++ }); ++ ``` ++ If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream. ++ ++ ```js ++ findUser().then(function (user) { ++ throw new PedagogicalException('Upstream error'); ++ }).then(function (value) { ++ // never reached ++ }).then(function (value) { ++ // never reached ++ }, function (reason) { ++ // The `PedgagocialException` is propagated all the way down to here ++ }); ++ ``` ++ ++ Assimilation ++ ------------ ++ ++ Sometimes the value you want to propagate to a downstream promise can only be ++ retrieved asynchronously. This can be achieved by returning a promise in the ++ fulfillment or rejection handler. The downstream promise will then be pending ++ until the returned promise is settled. This is called *assimilation*. ++ ++ ```js ++ findUser().then(function (user) { ++ return findCommentsByAuthor(user); ++ }).then(function (comments) { ++ // The user's comments are now available ++ }); ++ ``` ++ ++ If the assimliated promise rejects, then the downstream promise will also reject. ++ ++ ```js ++ findUser().then(function (user) { ++ return findCommentsByAuthor(user); ++ }).then(function (comments) { ++ // If `findCommentsByAuthor` fulfills, we'll have the value here ++ }, function (reason) { ++ // If `findCommentsByAuthor` rejects, we'll have the reason here ++ }); ++ ``` ++ ++ Simple Example ++ -------------- ++ ++ Synchronous Example ++ ++ ```javascript ++ let result; ++ ++ try { ++ result = findResult(); ++ // success ++ } catch(reason) { ++ // failure + } +- function attrTweenNS(b) { +- return b == null ? attrNullNS : (b += "", function() { +- var a = this.getAttributeNS(name.space, name.local), i; +- return a !== b && (i = interpolate(a, b), function(t) { +- this.setAttributeNS(name.space, name.local, i(t)); +- }); +- }); ++ ``` ++ ++ Errback Example ++ ++ ```js ++ findResult(function(result, err){ ++ if (err) { ++ // failure ++ } else { ++ // success ++ } ++ }); ++ ``` ++ ++ Promise Example; ++ ++ ```javascript ++ findResult().then(function(result){ ++ // success ++ }, function(reason){ ++ // failure ++ }); ++ ``` ++ ++ Advanced Example ++ -------------- ++ ++ Synchronous Example ++ ++ ```javascript ++ let author, books; ++ ++ try { ++ author = findAuthor(); ++ books = findBooksByAuthor(author); ++ // success ++ } catch(reason) { ++ // failure + } +- return d3_transition_tween(this, "attr." + nameNS, value, name.local ? attrTweenNS : attrTween); +- }; +- d3_transitionPrototype.attrTween = function(nameNS, tween) { +- var name = d3.ns.qualify(nameNS); +- function attrTween(d, i) { +- var f = tween.call(this, d, i, this.getAttribute(name)); +- return f && function(t) { +- this.setAttribute(name, f(t)); +- }; ++ ``` ++ ++ Errback Example ++ ++ ```js ++ ++ function foundBooks(books) { ++ + } +- function attrTweenNS(d, i) { +- var f = tween.call(this, d, i, this.getAttributeNS(name.space, name.local)); +- return f && function(t) { +- this.setAttributeNS(name.space, name.local, f(t)); +- }; ++ ++ function failure(reason) { ++ + } +- return this.tween("attr." + nameNS, name.local ? attrTweenNS : attrTween); +- }; +- d3_transitionPrototype.style = function(name, value, priority) { +- var n = arguments.length; +- if (n < 3) { +- if (typeof name !== "string") { +- if (n < 2) value = ""; +- for (priority in name) this.style(priority, name[priority], value); +- return this; ++ ++ findAuthor(function(author, err){ ++ if (err) { ++ failure(err); ++ // failure ++ } else { ++ try { ++ findBoooksByAuthor(author, function(books, err) { ++ if (err) { ++ failure(err); ++ } else { ++ try { ++ foundBooks(books); ++ } catch(reason) { ++ failure(reason); ++ } ++ } ++ }); ++ } catch(error) { ++ failure(err); ++ } ++ // success + } +- priority = ""; ++ }); ++ ``` ++ ++ Promise Example; ++ ++ ```javascript ++ findAuthor(). ++ then(findBooksByAuthor). ++ then(function(books){ ++ // found books ++ }).catch(function(reason){ ++ // something went wrong ++ }); ++ ``` ++ ++ @method then ++ @param {Function} onFulfilled ++ @param {Function} onRejected ++ Useful for tooling. ++ @return {Promise} ++ */ ++ then: then, ++ ++ /** ++ `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same ++ as the catch block of a try/catch statement. ++ ++ ```js ++ function findAuthor(){ ++ throw new Error('couldn't find that author'); + } +- function styleNull() { +- this.style.removeProperty(name); ++ ++ // synchronous ++ try { ++ findAuthor(); ++ } catch(reason) { ++ // something went wrong + } +- function styleString(b) { +- return b == null ? styleNull : (b += "", function() { +- var a = d3_window(this).getComputedStyle(this, null).getPropertyValue(name), i; +- return a !== b && (i = d3_interpolate(a, b), function(t) { +- this.style.setProperty(name, i(t), priority); +- }); +- }); ++ ++ // async with promises ++ findAuthor().catch(function(reason){ ++ // something went wrong ++ }); ++ ``` ++ ++ @method catch ++ @param {Function} onRejection ++ Useful for tooling. ++ @return {Promise} ++ */ ++ 'catch': function _catch(onRejection) { ++ return this.then(null, onRejection); ++ } ++}; ++ ++function polyfill() { ++ var local = undefined; ++ ++ if (typeof global !== 'undefined') { ++ local = global; ++ } else if (typeof self !== 'undefined') { ++ local = self; ++ } else { ++ try { ++ local = Function('return this')(); ++ } catch (e) { ++ throw new Error('polyfill failed because global object is unavailable in this environment'); ++ } + } +- return d3_transition_tween(this, "style." + name, value, styleString); +- }; +- d3_transitionPrototype.styleTween = function(name, tween, priority) { +- if (arguments.length < 3) priority = ""; +- function styleTween(d, i) { +- var f = tween.call(this, d, i, d3_window(this).getComputedStyle(this, null).getPropertyValue(name)); +- return f && function(t) { +- this.style.setProperty(name, f(t), priority); +- }; ++ ++ var P = local.Promise; ++ ++ if (P) { ++ var promiseToString = null; ++ try { ++ promiseToString = Object.prototype.toString.call(P.resolve()); ++ } catch (e) { ++ // silently ignored ++ } ++ ++ if (promiseToString === '[object Promise]' && !P.cast) { ++ return; ++ } + } +- return this.tween("style." + name, styleTween); +- }; +- d3_transitionPrototype.text = function(value) { +- return d3_transition_tween(this, "text", value, d3_transition_text); +- }; +- function d3_transition_text(b) { +- if (b == null) b = ""; +- return function() { +- this.textContent = b; +- }; +- } +- d3_transitionPrototype.remove = function() { +- var ns = this.namespace; +- return this.each("end.transition", function() { +- var p; +- if (this[ns].count < 2 && (p = this.parentNode)) p.removeChild(this); +- }); +- }; +- d3_transitionPrototype.ease = function(value) { +- var id = this.id, ns = this.namespace; +- if (arguments.length < 1) return this.node()[ns][id].ease; +- if (typeof value !== "function") value = d3.ease.apply(d3, arguments); +- return d3_selection_each(this, function(node) { +- node[ns][id].ease = value; +- }); +- }; +- d3_transitionPrototype.delay = function(value) { +- var id = this.id, ns = this.namespace; +- if (arguments.length < 1) return this.node()[ns][id].delay; +- return d3_selection_each(this, typeof value === "function" ? function(node, i, j) { +- node[ns][id].delay = +value.call(node, node.__data__, i, j); +- } : (value = +value, function(node) { +- node[ns][id].delay = value; +- })); +- }; +- d3_transitionPrototype.duration = function(value) { +- var id = this.id, ns = this.namespace; +- if (arguments.length < 1) return this.node()[ns][id].duration; +- return d3_selection_each(this, typeof value === "function" ? function(node, i, j) { +- node[ns][id].duration = Math.max(1, value.call(node, node.__data__, i, j)); +- } : (value = Math.max(1, value), function(node) { +- node[ns][id].duration = value; +- })); +- }; +- d3_transitionPrototype.each = function(type, listener) { +- var id = this.id, ns = this.namespace; +- if (arguments.length < 2) { +- var inherit = d3_transitionInherit, inheritId = d3_transitionInheritId; +- try { +- d3_transitionInheritId = id; +- d3_selection_each(this, function(node, i, j) { +- d3_transitionInherit = node[ns][id]; +- type.call(node, node.__data__, i, j); +- }); +- } finally { +- d3_transitionInherit = inherit; +- d3_transitionInheritId = inheritId; ++ ++ local.Promise = Promise; ++} ++ ++polyfill(); ++// Strange compat.. ++Promise.polyfill = polyfill; ++Promise.Promise = Promise; ++ ++return Promise; ++ ++}))); ++ ++}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) ++},{"_process":205}],80:[function(require,module,exports){ ++// Copyright Joyent, Inc. and other Node contributors. ++// ++// Permission is hereby granted, free of charge, to any person obtaining a ++// copy of this software and associated documentation files (the ++// "Software"), to deal in the Software without restriction, including ++// without limitation the rights to use, copy, modify, merge, publish, ++// distribute, sublicense, and/or sell copies of the Software, and to permit ++// persons to whom the Software is furnished to do so, subject to the ++// following conditions: ++// ++// The above copyright notice and this permission notice shall be included ++// in all copies or substantial portions of the Software. ++// ++// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ++// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ++// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN ++// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, ++// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR ++// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE ++// USE OR OTHER DEALINGS IN THE SOFTWARE. ++ ++function EventEmitter() { ++ this._events = this._events || {}; ++ this._maxListeners = this._maxListeners || undefined; ++} ++module.exports = EventEmitter; ++ ++// Backwards-compat with node 0.10.x ++EventEmitter.EventEmitter = EventEmitter; ++ ++EventEmitter.prototype._events = undefined; ++EventEmitter.prototype._maxListeners = undefined; ++ ++// By default EventEmitters will print a warning if more than 10 listeners are ++// added to it. This is a useful default which helps finding memory leaks. ++EventEmitter.defaultMaxListeners = 10; ++ ++// Obviously not all Emitters should be limited to 10. This function allows ++// that to be increased. Set to zero for unlimited. ++EventEmitter.prototype.setMaxListeners = function(n) { ++ if (!isNumber(n) || n < 0 || isNaN(n)) ++ throw TypeError('n must be a positive number'); ++ this._maxListeners = n; ++ return this; ++}; ++ ++EventEmitter.prototype.emit = function(type) { ++ var er, handler, len, args, i, listeners; ++ ++ if (!this._events) ++ this._events = {}; ++ ++ // If there is no 'error' event listener then throw. ++ if (type === 'error') { ++ if (!this._events.error || ++ (isObject(this._events.error) && !this._events.error.length)) { ++ er = arguments[1]; ++ if (er instanceof Error) { ++ throw er; // Unhandled 'error' event ++ } else { ++ // At least give some kind of context to the user ++ var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); ++ err.context = er; ++ throw err; + } +- } else { +- d3_selection_each(this, function(node) { +- var transition = node[ns][id]; +- (transition.event || (transition.event = d3.dispatch("start", "end", "interrupt"))).on(type, listener); +- }); + } +- return this; +- }; +- d3_transitionPrototype.transition = function() { +- var id0 = this.id, id1 = ++d3_transitionId, ns = this.namespace, subgroups = [], subgroup, group, node, transition; +- for (var j = 0, m = this.length; j < m; j++) { +- subgroups.push(subgroup = []); +- for (var group = this[j], i = 0, n = group.length; i < n; i++) { +- if (node = group[i]) { +- transition = node[ns][id0]; +- d3_transitionNode(node, i, ns, id1, { +- time: transition.time, +- ease: transition.ease, +- delay: transition.delay + transition.duration, +- duration: transition.duration +- }); +- } +- subgroup.push(node); +- } ++ } ++ ++ handler = this._events[type]; ++ ++ if (isUndefined(handler)) ++ return false; ++ ++ if (isFunction(handler)) { ++ switch (arguments.length) { ++ // fast cases ++ case 1: ++ handler.call(this); ++ break; ++ case 2: ++ handler.call(this, arguments[1]); ++ break; ++ case 3: ++ handler.call(this, arguments[1], arguments[2]); ++ break; ++ // slower ++ default: ++ args = Array.prototype.slice.call(arguments, 1); ++ handler.apply(this, args); + } +- return d3_transition(subgroups, ns, id1); +- }; +- function d3_transitionNamespace(name) { +- return name == null ? "__transition__" : "__transition_" + name + "__"; ++ } else if (isObject(handler)) { ++ args = Array.prototype.slice.call(arguments, 1); ++ listeners = handler.slice(); ++ len = listeners.length; ++ for (i = 0; i < len; i++) ++ listeners[i].apply(this, args); + } +- function d3_transitionNode(node, i, ns, id, inherit) { +- var lock = node[ns] || (node[ns] = { +- active: 0, +- count: 0 +- }), transition = lock[id], time, timer, duration, ease, tweens; +- function schedule(elapsed) { +- var delay = transition.delay; +- timer.t = delay + time; +- if (delay <= elapsed) return start(elapsed - delay); +- timer.c = start; ++ ++ return true; ++}; ++ ++EventEmitter.prototype.addListener = function(type, listener) { ++ var m; ++ ++ if (!isFunction(listener)) ++ throw TypeError('listener must be a function'); ++ ++ if (!this._events) ++ this._events = {}; ++ ++ // To avoid recursion in the case that type === "newListener"! Before ++ // adding it to the listeners, first emit "newListener". ++ if (this._events.newListener) ++ this.emit('newListener', type, ++ isFunction(listener.listener) ? ++ listener.listener : listener); ++ ++ if (!this._events[type]) ++ // Optimize the case of one listener. Don't need the extra array object. ++ this._events[type] = listener; ++ else if (isObject(this._events[type])) ++ // If we've already got an array, just append. ++ this._events[type].push(listener); ++ else ++ // Adding the second element, need to change to array. ++ this._events[type] = [this._events[type], listener]; ++ ++ // Check for listener leak ++ if (isObject(this._events[type]) && !this._events[type].warned) { ++ if (!isUndefined(this._maxListeners)) { ++ m = this._maxListeners; ++ } else { ++ m = EventEmitter.defaultMaxListeners; + } +- function start(elapsed) { +- var activeId = lock.active, active = lock[activeId]; +- if (active) { +- active.timer.c = null; +- active.timer.t = NaN; +- --lock.count; +- delete lock[activeId]; +- active.event && active.event.interrupt.call(node, node.__data__, active.index); +- } +- for (var cancelId in lock) { +- if (+cancelId < id) { +- var cancel = lock[cancelId]; +- cancel.timer.c = null; +- cancel.timer.t = NaN; +- --lock.count; +- delete lock[cancelId]; +- } ++ ++ if (m && m > 0 && this._events[type].length > m) { ++ this._events[type].warned = true; ++ console.error('(node) warning: possible EventEmitter memory ' + ++ 'leak detected. %d listeners added. ' + ++ 'Use emitter.setMaxListeners() to increase limit.', ++ this._events[type].length); ++ if (typeof console.trace === 'function') { ++ // not supported in IE 10 ++ console.trace(); + } +- timer.c = tick; +- d3_timer(function() { +- if (timer.c && tick(elapsed || 1)) { +- timer.c = null; +- timer.t = NaN; +- } +- return 1; +- }, 0, time); +- lock.active = id; +- transition.event && transition.event.start.call(node, node.__data__, i); +- tweens = []; +- transition.tween.forEach(function(key, value) { +- if (value = value.call(node, node.__data__, i)) { +- tweens.push(value); +- } +- }); +- ease = transition.ease; +- duration = transition.duration; + } +- function tick(elapsed) { +- var t = elapsed / duration, e = ease(t), n = tweens.length; +- while (n > 0) { +- tweens[--n].call(node, e); +- } +- if (t >= 1) { +- transition.event && transition.event.end.call(node, node.__data__, i); +- if (--lock.count) delete lock[id]; else delete node[ns]; +- return 1; ++ } ++ ++ return this; ++}; ++ ++EventEmitter.prototype.on = EventEmitter.prototype.addListener; ++ ++EventEmitter.prototype.once = function(type, listener) { ++ if (!isFunction(listener)) ++ throw TypeError('listener must be a function'); ++ ++ var fired = false; ++ ++ function g() { ++ this.removeListener(type, g); ++ ++ if (!fired) { ++ fired = true; ++ listener.apply(this, arguments); ++ } ++ } ++ ++ g.listener = listener; ++ this.on(type, g); ++ ++ return this; ++}; ++ ++// emits a 'removeListener' event iff the listener was removed ++EventEmitter.prototype.removeListener = function(type, listener) { ++ var list, position, length, i; ++ ++ if (!isFunction(listener)) ++ throw TypeError('listener must be a function'); ++ ++ if (!this._events || !this._events[type]) ++ return this; ++ ++ list = this._events[type]; ++ length = list.length; ++ position = -1; ++ ++ if (list === listener || ++ (isFunction(list.listener) && list.listener === listener)) { ++ delete this._events[type]; ++ if (this._events.removeListener) ++ this.emit('removeListener', type, listener); ++ ++ } else if (isObject(list)) { ++ for (i = length; i-- > 0;) { ++ if (list[i] === listener || ++ (list[i].listener && list[i].listener === listener)) { ++ position = i; ++ break; + } + } +- if (!transition) { +- time = inherit.time; +- timer = d3_timer(schedule, 0, time); +- transition = lock[id] = { +- tween: new d3_Map(), +- time: time, +- timer: timer, +- delay: inherit.delay, +- duration: inherit.duration, +- ease: inherit.ease, +- index: i +- }; +- inherit = null; +- ++lock.count; ++ ++ if (position < 0) ++ return this; ++ ++ if (list.length === 1) { ++ list.length = 0; ++ delete this._events[type]; ++ } else { ++ list.splice(position, 1); + } ++ ++ if (this._events.removeListener) ++ this.emit('removeListener', type, listener); + } +- d3.svg.axis = function() { +- var scale = d3.scale.linear(), orient = d3_svg_axisDefaultOrient, innerTickSize = 6, outerTickSize = 6, tickPadding = 3, tickArguments_ = [ 10 ], tickValues = null, tickFormat_; +- function axis(g) { +- g.each(function() { +- var g = d3.select(this); +- var scale0 = this.__chart__ || scale, scale1 = this.__chart__ = scale.copy(); +- var ticks = tickValues == null ? scale1.ticks ? scale1.ticks.apply(scale1, tickArguments_) : scale1.domain() : tickValues, tickFormat = tickFormat_ == null ? scale1.tickFormat ? scale1.tickFormat.apply(scale1, tickArguments_) : d3_identity : tickFormat_, tick = g.selectAll(".tick").data(ticks, scale1), tickEnter = tick.enter().insert("g", ".domain").attr("class", "tick").style("opacity", ε), tickExit = d3.transition(tick.exit()).style("opacity", ε).remove(), tickUpdate = d3.transition(tick.order()).style("opacity", 1), tickSpacing = Math.max(innerTickSize, 0) + tickPadding, tickTransform; +- var range = d3_scaleRange(scale1), path = g.selectAll(".domain").data([ 0 ]), pathUpdate = (path.enter().append("path").attr("class", "domain"), +- d3.transition(path)); +- tickEnter.append("line"); +- tickEnter.append("text"); +- var lineEnter = tickEnter.select("line"), lineUpdate = tickUpdate.select("line"), text = tick.select("text").text(tickFormat), textEnter = tickEnter.select("text"), textUpdate = tickUpdate.select("text"), sign = orient === "top" || orient === "left" ? -1 : 1, x1, x2, y1, y2; +- if (orient === "bottom" || orient === "top") { +- tickTransform = d3_svg_axisX, x1 = "x", y1 = "y", x2 = "x2", y2 = "y2"; +- text.attr("dy", sign < 0 ? "0em" : ".71em").style("text-anchor", "middle"); +- pathUpdate.attr("d", "M" + range[0] + "," + sign * outerTickSize + "V0H" + range[1] + "V" + sign * outerTickSize); +- } else { +- tickTransform = d3_svg_axisY, x1 = "y", y1 = "x", x2 = "y2", y2 = "x2"; +- text.attr("dy", ".32em").style("text-anchor", sign < 0 ? "end" : "start"); +- pathUpdate.attr("d", "M" + sign * outerTickSize + "," + range[0] + "H0V" + range[1] + "H" + sign * outerTickSize); +- } +- lineEnter.attr(y2, sign * innerTickSize); +- textEnter.attr(y1, sign * tickSpacing); +- lineUpdate.attr(x2, 0).attr(y2, sign * innerTickSize); +- textUpdate.attr(x1, 0).attr(y1, sign * tickSpacing); +- if (scale1.rangeBand) { +- var x = scale1, dx = x.rangeBand() / 2; +- scale0 = scale1 = function(d) { +- return x(d) + dx; +- }; +- } else if (scale0.rangeBand) { +- scale0 = scale1; +- } else { +- tickExit.call(tickTransform, scale1, scale0); +- } +- tickEnter.call(tickTransform, scale0, scale1); +- tickUpdate.call(tickTransform, scale1, scale1); +- }); ++ ++ return this; ++}; ++ ++EventEmitter.prototype.removeAllListeners = function(type) { ++ var key, listeners; ++ ++ if (!this._events) ++ return this; ++ ++ // not listening for removeListener, no need to emit ++ if (!this._events.removeListener) { ++ if (arguments.length === 0) ++ this._events = {}; ++ else if (this._events[type]) ++ delete this._events[type]; ++ return this; ++ } ++ ++ // emit removeListener for all listeners on all events ++ if (arguments.length === 0) { ++ for (key in this._events) { ++ if (key === 'removeListener') continue; ++ this.removeAllListeners(key); + } +- axis.scale = function(x) { +- if (!arguments.length) return scale; +- scale = x; +- return axis; +- }; +- axis.orient = function(x) { +- if (!arguments.length) return orient; +- orient = x in d3_svg_axisOrients ? x + "" : d3_svg_axisDefaultOrient; +- return axis; +- }; +- axis.ticks = function() { +- if (!arguments.length) return tickArguments_; +- tickArguments_ = d3_array(arguments); +- return axis; +- }; +- axis.tickValues = function(x) { +- if (!arguments.length) return tickValues; +- tickValues = x; +- return axis; +- }; +- axis.tickFormat = function(x) { +- if (!arguments.length) return tickFormat_; +- tickFormat_ = x; +- return axis; +- }; +- axis.tickSize = function(x) { +- var n = arguments.length; +- if (!n) return innerTickSize; +- innerTickSize = +x; +- outerTickSize = +arguments[n - 1]; +- return axis; +- }; +- axis.innerTickSize = function(x) { +- if (!arguments.length) return innerTickSize; +- innerTickSize = +x; +- return axis; +- }; +- axis.outerTickSize = function(x) { +- if (!arguments.length) return outerTickSize; +- outerTickSize = +x; +- return axis; +- }; +- axis.tickPadding = function(x) { +- if (!arguments.length) return tickPadding; +- tickPadding = +x; +- return axis; +- }; +- axis.tickSubdivide = function() { +- return arguments.length && axis; +- }; +- return axis; +- }; +- var d3_svg_axisDefaultOrient = "bottom", d3_svg_axisOrients = { +- top: 1, +- right: 1, +- bottom: 1, +- left: 1 +- }; +- function d3_svg_axisX(selection, x0, x1) { +- selection.attr("transform", function(d) { +- var v0 = x0(d); +- return "translate(" + (isFinite(v0) ? v0 : x1(d)) + ",0)"; +- }); ++ this.removeAllListeners('removeListener'); ++ this._events = {}; ++ return this; + } +- function d3_svg_axisY(selection, y0, y1) { +- selection.attr("transform", function(d) { +- var v0 = y0(d); +- return "translate(0," + (isFinite(v0) ? v0 : y1(d)) + ")"; +- }); ++ ++ listeners = this._events[type]; ++ ++ if (isFunction(listeners)) { ++ this.removeListener(type, listeners); ++ } else if (listeners) { ++ // LIFO order ++ while (listeners.length) ++ this.removeListener(type, listeners[listeners.length - 1]); + } +- d3.svg.brush = function() { +- var event = d3_eventDispatch(brush, "brushstart", "brush", "brushend"), x = null, y = null, xExtent = [ 0, 0 ], yExtent = [ 0, 0 ], xExtentDomain, yExtentDomain, xClamp = true, yClamp = true, resizes = d3_svg_brushResizes[0]; +- function brush(g) { +- g.each(function() { +- var g = d3.select(this).style("pointer-events", "all").style("-webkit-tap-highlight-color", "rgba(0,0,0,0)").on("mousedown.brush", brushstart).on("touchstart.brush", brushstart); +- var background = g.selectAll(".background").data([ 0 ]); +- background.enter().append("rect").attr("class", "background").style("visibility", "hidden").style("cursor", "crosshair"); +- g.selectAll(".extent").data([ 0 ]).enter().append("rect").attr("class", "extent").style("cursor", "move"); +- var resize = g.selectAll(".resize").data(resizes, d3_identity); +- resize.exit().remove(); +- resize.enter().append("g").attr("class", function(d) { +- return "resize " + d; +- }).style("cursor", function(d) { +- return d3_svg_brushCursor[d]; +- }).append("rect").attr("x", function(d) { +- return /[ew]$/.test(d) ? -3 : null; +- }).attr("y", function(d) { +- return /^[ns]/.test(d) ? -3 : null; +- }).attr("width", 6).attr("height", 6).style("visibility", "hidden"); +- resize.style("display", brush.empty() ? "none" : null); +- var gUpdate = d3.transition(g), backgroundUpdate = d3.transition(background), range; +- if (x) { +- range = d3_scaleRange(x); +- backgroundUpdate.attr("x", range[0]).attr("width", range[1] - range[0]); +- redrawX(gUpdate); +- } +- if (y) { +- range = d3_scaleRange(y); +- backgroundUpdate.attr("y", range[0]).attr("height", range[1] - range[0]); +- redrawY(gUpdate); ++ delete this._events[type]; ++ ++ return this; ++}; ++ ++EventEmitter.prototype.listeners = function(type) { ++ var ret; ++ if (!this._events || !this._events[type]) ++ ret = []; ++ else if (isFunction(this._events[type])) ++ ret = [this._events[type]]; ++ else ++ ret = this._events[type].slice(); ++ return ret; ++}; ++ ++EventEmitter.prototype.listenerCount = function(type) { ++ if (this._events) { ++ var evlistener = this._events[type]; ++ ++ if (isFunction(evlistener)) ++ return 1; ++ else if (evlistener) ++ return evlistener.length; ++ } ++ return 0; ++}; ++ ++EventEmitter.listenerCount = function(emitter, type) { ++ return emitter.listenerCount(type); ++}; ++ ++function isFunction(arg) { ++ return typeof arg === 'function'; ++} ++ ++function isNumber(arg) { ++ return typeof arg === 'number'; ++} ++ ++function isObject(arg) { ++ return typeof arg === 'object' && arg !== null; ++} ++ ++function isUndefined(arg) { ++ return arg === void 0; ++} ++ ++},{}],81:[function(require,module,exports){ ++"use strict" ++ ++module.exports = extractPlanes ++ ++function extractPlanes(M, zNear, zFar) { ++ var z = zNear || 0.0 ++ var zf = zFar || 1.0 ++ return [ ++ [ M[12] + M[0], M[13] + M[1], M[14] + M[2], M[15] + M[3] ], ++ [ M[12] - M[0], M[13] - M[1], M[14] - M[2], M[15] - M[3] ], ++ [ M[12] + M[4], M[13] + M[5], M[14] + M[6], M[15] + M[7] ], ++ [ M[12] - M[4], M[13] - M[5], M[14] - M[6], M[15] - M[7] ], ++ [ z*M[12] + M[8], z*M[13] + M[9], z*M[14] + M[10], z*M[15] + M[11] ], ++ [ zf*M[12] - M[8], zf*M[13] - M[9], zf*M[14] - M[10], zf*M[15] - M[11] ] ++ ] ++} ++},{}],82:[function(require,module,exports){ ++/** ++ * inspired by is-number ++ * but significantly simplified and sped up by ignoring number and string constructors ++ * ie these return false: ++ * new Number(1) ++ * new String('1') ++ */ ++ ++'use strict'; ++ ++/** ++ * Is this string all whitespace? ++ * This solution kind of makes my brain hurt, but it's significantly faster ++ * than !str.trim() or any other solution I could find. ++ * ++ * whitespace codes from: http://en.wikipedia.org/wiki/Whitespace_character ++ * and verified with: ++ * ++ * for(var i = 0; i < 65536; i++) { ++ * var s = String.fromCharCode(i); ++ * if(+s===0 && !s.trim()) console.log(i, s); ++ * } ++ * ++ * which counts a couple of these as *not* whitespace, but finds nothing else ++ * that *is* whitespace. Note that charCodeAt stops at 16 bits, but it appears ++ * that there are no whitespace characters above this, and code points above ++ * this do not map onto white space characters. ++ */ ++function allBlankCharCodes(str){ ++ var l = str.length, ++ a; ++ for(var i = 0; i < l; i++) { ++ a = str.charCodeAt(i); ++ if((a < 9 || a > 13) && (a !== 32) && (a !== 133) && (a !== 160) && ++ (a !== 5760) && (a !== 6158) && (a < 8192 || a > 8205) && ++ (a !== 8232) && (a !== 8233) && (a !== 8239) && (a !== 8287) && ++ (a !== 8288) && (a !== 12288) && (a !== 65279)) { ++ return false; + } +- redraw(gUpdate); +- }); + } +- brush.event = function(g) { +- g.each(function() { +- var event_ = event.of(this, arguments), extent1 = { +- x: xExtent, +- y: yExtent, +- i: xExtentDomain, +- j: yExtentDomain +- }, extent0 = this.__chart__ || extent1; +- this.__chart__ = extent1; +- if (d3_transitionInheritId) { +- d3.select(this).transition().each("start.brush", function() { +- xExtentDomain = extent0.i; +- yExtentDomain = extent0.j; +- xExtent = extent0.x; +- yExtent = extent0.y; +- event_({ +- type: "brushstart" +- }); +- }).tween("brush:brush", function() { +- var xi = d3_interpolateArray(xExtent, extent1.x), yi = d3_interpolateArray(yExtent, extent1.y); +- xExtentDomain = yExtentDomain = null; +- return function(t) { +- xExtent = extent1.x = xi(t); +- yExtent = extent1.y = yi(t); +- event_({ +- type: "brush", +- mode: "resize" +- }); +- }; +- }).each("end.brush", function() { +- xExtentDomain = extent1.i; +- yExtentDomain = extent1.j; +- event_({ +- type: "brush", +- mode: "resize" +- }); +- event_({ +- type: "brushend" +- }); +- }); +- } else { +- event_({ +- type: "brushstart" +- }); +- event_({ +- type: "brush", +- mode: "resize" +- }); +- event_({ +- type: "brushend" +- }); +- } +- }); +- }; +- function redraw(g) { +- g.selectAll(".resize").attr("transform", function(d) { +- return "translate(" + xExtent[+/e$/.test(d)] + "," + yExtent[+/^s/.test(d)] + ")"; +- }); ++ return true; ++} ++ ++module.exports = function(n) { ++ var type = typeof n; ++ if(type === 'string') { ++ var original = n; ++ n = +n; ++ // whitespace strings cast to zero - filter them out ++ if(n===0 && allBlankCharCodes(original)) return false; + } +- function redrawX(g) { +- g.select(".extent").attr("x", xExtent[0]); +- g.selectAll(".extent,.n>rect,.s>rect").attr("width", xExtent[1] - xExtent[0]); ++ else if(type !== 'number') return false; ++ ++ return n - n < 1; ++}; ++ ++},{}],83:[function(require,module,exports){ ++'use strict' ++ ++module.exports = createFilteredVector ++ ++var cubicHermite = require('cubic-hermite') ++var bsearch = require('binary-search-bounds') ++ ++function clamp(lo, hi, x) { ++ return Math.min(hi, Math.max(lo, x)) ++} ++ ++function FilteredVector(state0, velocity0, t0) { ++ this.dimension = state0.length ++ this.bounds = [ new Array(this.dimension), new Array(this.dimension) ] ++ for(var i=0; irect,.w>rect").attr("height", yExtent[1] - yExtent[0]); ++ } else if(idx >= n-1) { ++ var ptr = state.length-1 ++ var tf = t - time[n-1] ++ for(var i=0; i 1 ? { +- floor: function(date) { +- while (skipped(date = interval.floor(date))) date = d3_time_scaleDate(date - 1); +- return date; +- }, +- ceil: function(date) { +- while (skipped(date = interval.ceil(date))) date = d3_time_scaleDate(+date + 1); +- return date; +- } +- } : interval)); +- }; +- scale.ticks = function(interval, skip) { +- var extent = d3_scaleExtent(scale.domain()), method = interval == null ? tickMethod(extent, 10) : typeof interval === "number" ? tickMethod(extent, interval) : !interval.range && [ { +- range: interval +- }, skip ]; +- if (method) interval = method[0], skip = method[1]; +- return interval.range(extent[0], d3_time_scaleDate(+extent[1] + 1), skip < 1 ? 1 : skip); +- }; +- scale.tickFormat = function() { +- return format; +- }; +- scale.copy = function() { +- return d3_time_scale(linear.copy(), methods, format); +- }; +- return d3_scale_linearRebind(scale, linear); +- } +- function d3_time_scaleDate(t) { +- return new Date(t); +- } +- var d3_time_scaleSteps = [ 1e3, 5e3, 15e3, 3e4, 6e4, 3e5, 9e5, 18e5, 36e5, 108e5, 216e5, 432e5, 864e5, 1728e5, 6048e5, 2592e6, 7776e6, 31536e6 ]; +- var d3_time_scaleLocalMethods = [ [ d3_time.second, 1 ], [ d3_time.second, 5 ], [ d3_time.second, 15 ], [ d3_time.second, 30 ], [ d3_time.minute, 1 ], [ d3_time.minute, 5 ], [ d3_time.minute, 15 ], [ d3_time.minute, 30 ], [ d3_time.hour, 1 ], [ d3_time.hour, 3 ], [ d3_time.hour, 6 ], [ d3_time.hour, 12 ], [ d3_time.day, 1 ], [ d3_time.day, 2 ], [ d3_time.week, 1 ], [ d3_time.month, 1 ], [ d3_time.month, 3 ], [ d3_time.year, 1 ] ]; +- var d3_time_scaleLocalFormat = d3_time_format.multi([ [ ".%L", function(d) { +- return d.getMilliseconds(); +- } ], [ ":%S", function(d) { +- return d.getSeconds(); +- } ], [ "%I:%M", function(d) { +- return d.getMinutes(); +- } ], [ "%I %p", function(d) { +- return d.getHours(); +- } ], [ "%a %d", function(d) { +- return d.getDay() && d.getDate() != 1; +- } ], [ "%b %d", function(d) { +- return d.getDate() != 1; +- } ], [ "%B", function(d) { +- return d.getMonth(); +- } ], [ "%Y", d3_true ] ]); +- var d3_time_scaleMilliseconds = { +- range: function(start, stop, step) { +- return d3.range(Math.ceil(start / step) * step, +stop, step).map(d3_time_scaleDate); +- }, +- floor: d3_identity, +- ceil: d3_identity +- }; +- d3_time_scaleLocalMethods.year = d3_time.year; +- d3_time.scale = function() { +- return d3_time_scale(d3.scale.linear(), d3_time_scaleLocalMethods, d3_time_scaleLocalFormat); +- }; +- var d3_time_scaleUtcMethods = d3_time_scaleLocalMethods.map(function(m) { +- return [ m[0].utc, m[1] ]; +- }); +- var d3_time_scaleUtcFormat = d3_time_formatUtc.multi([ [ ".%L", function(d) { +- return d.getUTCMilliseconds(); +- } ], [ ":%S", function(d) { +- return d.getUTCSeconds(); +- } ], [ "%I:%M", function(d) { +- return d.getUTCMinutes(); +- } ], [ "%I %p", function(d) { +- return d.getUTCHours(); +- } ], [ "%a %d", function(d) { +- return d.getUTCDay() && d.getUTCDate() != 1; +- } ], [ "%b %d", function(d) { +- return d.getUTCDate() != 1; +- } ], [ "%B", function(d) { +- return d.getUTCMonth(); +- } ], [ "%Y", d3_true ] ]); +- d3_time_scaleUtcMethods.year = d3_time.year.utc; +- d3_time.scale.utc = function() { +- return d3_time_scale(d3.scale.linear(), d3_time_scaleUtcMethods, d3_time_scaleUtcFormat); +- }; +- d3.text = d3_xhrType(function(request) { +- return request.responseText; +- }); +- d3.json = function(url, callback) { +- return d3_xhr(url, "application/json", d3_json, callback); +- }; +- function d3_json(request) { +- return JSON.parse(request.responseText); + } +- d3.html = function(url, callback) { +- return d3_xhr(url, "text/html", d3_html, callback); +- }; +- function d3_html(request) { +- var range = d3_document.createRange(); +- range.selectNode(d3_document.body); +- return range.createContextualFragment(request.responseText); ++ var lo = bounds[0] ++ var hi = bounds[1] ++ for(var i=0; i= n-1) { ++ var ptr = state.length-1 ++ var tf = t - time[n-1] ++ for(var i=0; i=0; --i) { ++ if(velocity[--ptr]) { ++ return false + } + } +- return 0 ++ return true + } + +-function triangulate1D(n, points, includePointAtInfinity) { +- if(n === 1) { +- if(includePointAtInfinity) { +- return [ [-1, 0] ] +- } else { +- return [] ++proto.jump = function(t) { ++ var t0 = this.lastT() ++ var d = this.dimension ++ if(t < t0 || arguments.length !== d+1) { ++ return ++ } ++ var state = this._state ++ var velocity = this._velocity ++ var ptr = state.length-this.dimension ++ var bounds = this.bounds ++ var lo = bounds[0] ++ var hi = bounds[1] ++ this._time.push(t0, t) ++ for(var j=0; j<2; ++j) { ++ for(var i=0; i0; --i) { ++ state.push(clamp(lo[i-1], hi[i-1], arguments[i])) ++ velocity.push(0) + } +- if(includePointAtInfinity) { +- cells.push( +- [ -1, cells[0][1], ], +- [ cells[n-1][1], -1 ]) ++} ++ ++proto.push = function(t) { ++ var t0 = this.lastT() ++ var d = this.dimension ++ if(t < t0 || arguments.length !== d+1) { ++ return ++ } ++ var state = this._state ++ var velocity = this._velocity ++ var ptr = state.length-this.dimension ++ var dt = t - t0 ++ var bounds = this.bounds ++ var lo = bounds[0] ++ var hi = bounds[1] ++ var sf = (dt > 1e-6) ? 1/dt : 0 ++ this._time.push(t) ++ for(var i=d; i>0; --i) { ++ var xc = clamp(lo[i-1], hi[i-1], arguments[i]) ++ state.push(xc) ++ velocity.push((xc - state[ptr++]) * sf) + } +- return cells + } + +-function triangulate(points, includePointAtInfinity) { +- var n = points.length +- if(n === 0) { +- return [] ++proto.set = function(t) { ++ var d = this.dimension ++ if(t < this.lastT() || arguments.length !== d+1) { ++ return + } +- +- var d = points[0].length +- if(d < 1) { +- return [] ++ var state = this._state ++ var velocity = this._velocity ++ var bounds = this.bounds ++ var lo = bounds[0] ++ var hi = bounds[1] ++ this._time.push(t) ++ for(var i=d; i>0; --i) { ++ state.push(clamp(lo[i-1], hi[i-1], arguments[i])) ++ velocity.push(0) + } ++} + +- //Special case: For 1D we can just sort the points +- if(d === 1) { +- return triangulate1D(n, points, includePointAtInfinity) ++proto.move = function(t) { ++ var t0 = this.lastT() ++ var d = this.dimension ++ if(t <= t0 || arguments.length !== d+1) { ++ return + } +- +- //Lift points, sort +- var lifted = new Array(n) +- var upper = 1.0 +- for(var i=0; i 1e-6) ? 1/dt : 0.0 ++ this._time.push(t) ++ for(var i=d; i>0; --i) { ++ var dx = arguments[i] ++ state.push(clamp(lo[i-1], hi[i-1], state[statePtr++] + dx)) ++ velocity.push(dx * sf) + } +- uniq(lifted, compareLifted) +- +- //Double points +- n = lifted.length ++} + +- //Create new list of points +- var dpoints = new Array(n + d + 1) +- var dindex = new Array(n + d + 1) ++proto.idle = function(t) { ++ var t0 = this.lastT() ++ if(t < t0) { ++ return ++ } ++ var d = this.dimension ++ var state = this._state ++ var velocity = this._velocity ++ var statePtr = state.length-d ++ var bounds = this.bounds ++ var lo = bounds[0] ++ var hi = bounds[1] ++ var dt = t - t0 ++ this._time.push(t) ++ for(var i=d-1; i>=0; --i) { ++ state.push(clamp(lo[i], hi[i], state[statePtr] + dt * velocity[statePtr])) ++ velocity.push(0) ++ statePtr += 1 ++ } ++} + +- //Add steiner points at top +- var u = (d+1) * (d+1) * upper +- var y = new Array(d+1) +- for(var i=0; i<=d; ++i) { +- y[i] = 0.0 ++function getZero(d) { ++ var result = new Array(d) ++ for(var i=0; i= 2) { +- return false ++//Returns the number of nodes in the tree ++Object.defineProperty(proto, "length", { ++ get: function() { ++ if(this.root) { ++ return this.root._count ++ } ++ return 0 ++ } ++}) ++ ++//Insert a new item into the tree ++proto.insert = function(key, value) { ++ var cmp = this._compare ++ //Find point to insert new node at ++ var n = this.root ++ var n_stack = [] ++ var d_stack = [] ++ while(n) { ++ var d = cmp(key, n.key) ++ n_stack.push(n) ++ d_stack.push(d) ++ if(d <= 0) { ++ n = n.left ++ } else { ++ n = n.right ++ } ++ } ++ //Rebuild path to leaf node ++ n_stack.push(new RBNode(RED, key, value, null, null, 1)) ++ for(var s=n_stack.length-2; s>=0; --s) { ++ var n = n_stack[s] ++ if(d_stack[s] <= 0) { ++ n_stack[s] = new RBNode(n._color, n.key, n.value, n_stack[s+1], n.right, n._count+1) ++ } else { ++ n_stack[s] = new RBNode(n._color, n.key, n.value, n.left, n_stack[s+1], n._count+1) ++ } ++ } ++ //Rebalance tree using rotations ++ //console.log("start insert", key, d_stack) ++ for(var s=n_stack.length-1; s>1; --s) { ++ var p = n_stack[s-1] ++ var n = n_stack[s] ++ if(p._color === BLACK || n._color === BLACK) { ++ break ++ } ++ var pp = n_stack[s-2] ++ if(pp.left === p) { ++ if(p.left === n) { ++ var y = pp.right ++ if(y && y._color === RED) { ++ //console.log("LLr") ++ p._color = BLACK ++ pp.right = repaint(BLACK, y) ++ pp._color = RED ++ s -= 1 ++ } else { ++ //console.log("LLb") ++ pp._color = RED ++ pp.left = p.right ++ p._color = BLACK ++ p.right = pp ++ n_stack[s-2] = p ++ n_stack[s-1] = n ++ recount(pp) ++ recount(p) ++ if(s >= 3) { ++ var ppp = n_stack[s-3] ++ if(ppp.left === pp) { ++ ppp.left = p ++ } else { ++ ppp.right = p ++ } + } ++ break ++ } ++ } else { ++ var y = pp.right ++ if(y && y._color === RED) { ++ //console.log("LRr") ++ p._color = BLACK ++ pp.right = repaint(BLACK, y) ++ pp._color = RED ++ s -= 1 ++ } else { ++ //console.log("LRb") ++ p.right = n.left ++ pp._color = RED ++ pp.left = n.right ++ n._color = BLACK ++ n.left = p ++ n.right = pp ++ n_stack[s-2] = n ++ n_stack[s-1] = p ++ recount(pp) ++ recount(p) ++ recount(n) ++ if(s >= 3) { ++ var ppp = n_stack[s-3] ++ if(ppp.left === pp) { ++ ppp.left = n ++ } else { ++ ppp.right = n ++ } ++ } ++ break + } +- cell[j] = v + } +- return true +- }) +- } else { +- hull = hull.filter(function(cell) { +- for(var i=0; i<=d; ++i) { +- var v = dindex[cell[i]] +- if(v < 0) { +- return false ++ } else { ++ if(p.right === n) { ++ var y = pp.left ++ if(y && y._color === RED) { ++ //console.log("RRr", y.key) ++ p._color = BLACK ++ pp.left = repaint(BLACK, y) ++ pp._color = RED ++ s -= 1 ++ } else { ++ //console.log("RRb") ++ pp._color = RED ++ pp.right = p.left ++ p._color = BLACK ++ p.left = pp ++ n_stack[s-2] = p ++ n_stack[s-1] = n ++ recount(pp) ++ recount(p) ++ if(s >= 3) { ++ var ppp = n_stack[s-3] ++ if(ppp.right === pp) { ++ ppp.right = p ++ } else { ++ ppp.left = p ++ } ++ } ++ break ++ } ++ } else { ++ var y = pp.left ++ if(y && y._color === RED) { ++ //console.log("RLr") ++ p._color = BLACK ++ pp.left = repaint(BLACK, y) ++ pp._color = RED ++ s -= 1 ++ } else { ++ //console.log("RLb") ++ p.left = n.right ++ pp._color = RED ++ pp.right = n.left ++ n._color = BLACK ++ n.right = p ++ n.left = pp ++ n_stack[s-2] = n ++ n_stack[s-1] = p ++ recount(pp) ++ recount(p) ++ recount(n) ++ if(s >= 3) { ++ var ppp = n_stack[s-3] ++ if(ppp.right === pp) { ++ ppp.right = n ++ } else { ++ ppp.left = n ++ } ++ } ++ break + } +- cell[i] = v + } +- return true +- }) +- } +- +- if(d & 1) { +- for(var i=0; i 0) { ++ v = visit(node.key, node.value) ++ if(v) { return v } ++ } ++ } ++ if(h > 0 && node.right) { ++ return doVisit(lo, hi, compare, visit, node.right) + } +- return result + } + +-function dupe(count, value) { +- if(typeof value === "undefined") { +- value = 0 ++ ++proto.forEach = function rbTreeForEach(visit, lo, hi) { ++ if(!this.root) { ++ return + } +- switch(typeof count) { +- case "number": +- if(count > 0) { +- return dupe_number(count|0, value) +- } ++ switch(arguments.length) { ++ case 1: ++ return doVisitFull(visit, this.root) + break +- case "object": +- if(typeof (count.length) === "number") { +- return dupe_array(count, value, 0) ++ ++ case 2: ++ return doVisitHalf(lo, this._compare, visit, this.root) ++ break ++ ++ case 3: ++ if(this._compare(lo, hi) >= 0) { ++ return + } ++ return doVisit(lo, hi, this._compare, visit, this.root) + break + } +- return [] + } + +-module.exports = dupe +-},{}],103:[function(require,module,exports){ +-(function (process,global){ +-/*! +- * @overview es6-promise - a tiny implementation of Promises/A+. +- * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald) +- * @license Licensed under MIT license +- * See https://raw.githubusercontent.com/jakearchibald/es6-promise/master/LICENSE +- * @version 3.1.2 +- */ +- +-(function() { +- "use strict"; +- function lib$es6$promise$utils$$objectOrFunction(x) { +- return typeof x === 'function' || (typeof x === 'object' && x !== null); ++//First item in list ++Object.defineProperty(proto, "begin", { ++ get: function() { ++ var stack = [] ++ var n = this.root ++ while(n) { ++ stack.push(n) ++ n = n.left + } ++ return new RedBlackTreeIterator(this, stack) ++ } ++}) + +- function lib$es6$promise$utils$$isFunction(x) { +- return typeof x === 'function'; ++//Last item in list ++Object.defineProperty(proto, "end", { ++ get: function() { ++ var stack = [] ++ var n = this.root ++ while(n) { ++ stack.push(n) ++ n = n.right + } ++ return new RedBlackTreeIterator(this, stack) ++ } ++}) + +- function lib$es6$promise$utils$$isMaybeThenable(x) { +- return typeof x === 'object' && x !== null; ++//Find the ith item in the tree ++proto.at = function(idx) { ++ if(idx < 0) { ++ return new RedBlackTreeIterator(this, []) ++ } ++ var n = this.root ++ var stack = [] ++ while(true) { ++ stack.push(n) ++ if(n.left) { ++ if(idx < n.left._count) { ++ n = n.left ++ continue ++ } ++ idx -= n.left._count + } +- +- var lib$es6$promise$utils$$_isArray; +- if (!Array.isArray) { +- lib$es6$promise$utils$$_isArray = function (x) { +- return Object.prototype.toString.call(x) === '[object Array]'; +- }; +- } else { +- lib$es6$promise$utils$$_isArray = Array.isArray; +- } +- +- var lib$es6$promise$utils$$isArray = lib$es6$promise$utils$$_isArray; +- var lib$es6$promise$asap$$len = 0; +- var lib$es6$promise$asap$$vertxNext; +- var lib$es6$promise$asap$$customSchedulerFn; +- +- var lib$es6$promise$asap$$asap = function asap(callback, arg) { +- lib$es6$promise$asap$$queue[lib$es6$promise$asap$$len] = callback; +- lib$es6$promise$asap$$queue[lib$es6$promise$asap$$len + 1] = arg; +- lib$es6$promise$asap$$len += 2; +- if (lib$es6$promise$asap$$len === 2) { +- // If len is 2, that means that we need to schedule an async flush. +- // If additional callbacks are queued before the queue is flushed, they +- // will be processed by this flush that we are scheduling. +- if (lib$es6$promise$asap$$customSchedulerFn) { +- lib$es6$promise$asap$$customSchedulerFn(lib$es6$promise$asap$$flush); +- } else { +- lib$es6$promise$asap$$scheduleFlush(); +- } ++ if(!idx) { ++ return new RedBlackTreeIterator(this, stack) ++ } ++ idx -= 1 ++ if(n.right) { ++ if(idx >= n.right._count) { ++ break + } ++ n = n.right ++ } else { ++ break + } ++ } ++ return new RedBlackTreeIterator(this, []) ++} + +- function lib$es6$promise$asap$$setScheduler(scheduleFn) { +- lib$es6$promise$asap$$customSchedulerFn = scheduleFn; ++proto.ge = function(key) { ++ var cmp = this._compare ++ var n = this.root ++ var stack = [] ++ var last_ptr = 0 ++ while(n) { ++ var d = cmp(key, n.key) ++ stack.push(n) ++ if(d <= 0) { ++ last_ptr = stack.length + } +- +- function lib$es6$promise$asap$$setAsap(asapFn) { +- lib$es6$promise$asap$$asap = asapFn; ++ if(d <= 0) { ++ n = n.left ++ } else { ++ n = n.right + } ++ } ++ stack.length = last_ptr ++ return new RedBlackTreeIterator(this, stack) ++} + +- var lib$es6$promise$asap$$browserWindow = (typeof window !== 'undefined') ? window : undefined; +- var lib$es6$promise$asap$$browserGlobal = lib$es6$promise$asap$$browserWindow || {}; +- var lib$es6$promise$asap$$BrowserMutationObserver = lib$es6$promise$asap$$browserGlobal.MutationObserver || lib$es6$promise$asap$$browserGlobal.WebKitMutationObserver; +- var lib$es6$promise$asap$$isNode = typeof process !== 'undefined' && {}.toString.call(process) === '[object process]'; +- +- // test for web worker but not in IE10 +- var lib$es6$promise$asap$$isWorker = typeof Uint8ClampedArray !== 'undefined' && +- typeof importScripts !== 'undefined' && +- typeof MessageChannel !== 'undefined'; +- +- // node +- function lib$es6$promise$asap$$useNextTick() { +- // node version 0.10.x displays a deprecation warning when nextTick is used recursively +- // see https://github.com/cujojs/when/issues/410 for details +- return function() { +- process.nextTick(lib$es6$promise$asap$$flush); +- }; ++proto.gt = function(key) { ++ var cmp = this._compare ++ var n = this.root ++ var stack = [] ++ var last_ptr = 0 ++ while(n) { ++ var d = cmp(key, n.key) ++ stack.push(n) ++ if(d < 0) { ++ last_ptr = stack.length + } +- +- // vertx +- function lib$es6$promise$asap$$useVertxTimer() { +- return function() { +- lib$es6$promise$asap$$vertxNext(lib$es6$promise$asap$$flush); +- }; ++ if(d < 0) { ++ n = n.left ++ } else { ++ n = n.right + } ++ } ++ stack.length = last_ptr ++ return new RedBlackTreeIterator(this, stack) ++} + +- function lib$es6$promise$asap$$useMutationObserver() { +- var iterations = 0; +- var observer = new lib$es6$promise$asap$$BrowserMutationObserver(lib$es6$promise$asap$$flush); +- var node = document.createTextNode(''); +- observer.observe(node, { characterData: true }); +- +- return function() { +- node.data = (iterations = ++iterations % 2); +- }; ++proto.lt = function(key) { ++ var cmp = this._compare ++ var n = this.root ++ var stack = [] ++ var last_ptr = 0 ++ while(n) { ++ var d = cmp(key, n.key) ++ stack.push(n) ++ if(d > 0) { ++ last_ptr = stack.length + } +- +- // web worker +- function lib$es6$promise$asap$$useMessageChannel() { +- var channel = new MessageChannel(); +- channel.port1.onmessage = lib$es6$promise$asap$$flush; +- return function () { +- channel.port2.postMessage(0); +- }; ++ if(d <= 0) { ++ n = n.left ++ } else { ++ n = n.right + } ++ } ++ stack.length = last_ptr ++ return new RedBlackTreeIterator(this, stack) ++} + +- function lib$es6$promise$asap$$useSetTimeout() { +- return function() { +- setTimeout(lib$es6$promise$asap$$flush, 1); +- }; ++proto.le = function(key) { ++ var cmp = this._compare ++ var n = this.root ++ var stack = [] ++ var last_ptr = 0 ++ while(n) { ++ var d = cmp(key, n.key) ++ stack.push(n) ++ if(d >= 0) { ++ last_ptr = stack.length + } +- +- var lib$es6$promise$asap$$queue = new Array(1000); +- function lib$es6$promise$asap$$flush() { +- for (var i = 0; i < lib$es6$promise$asap$$len; i+=2) { +- var callback = lib$es6$promise$asap$$queue[i]; +- var arg = lib$es6$promise$asap$$queue[i+1]; +- +- callback(arg); +- +- lib$es6$promise$asap$$queue[i] = undefined; +- lib$es6$promise$asap$$queue[i+1] = undefined; +- } +- +- lib$es6$promise$asap$$len = 0; ++ if(d < 0) { ++ n = n.left ++ } else { ++ n = n.right + } ++ } ++ stack.length = last_ptr ++ return new RedBlackTreeIterator(this, stack) ++} + +- function lib$es6$promise$asap$$attemptVertx() { +- try { +- var r = require; +- var vertx = r('vertx'); +- lib$es6$promise$asap$$vertxNext = vertx.runOnLoop || vertx.runOnContext; +- return lib$es6$promise$asap$$useVertxTimer(); +- } catch(e) { +- return lib$es6$promise$asap$$useSetTimeout(); +- } +- } +- +- var lib$es6$promise$asap$$scheduleFlush; +- // Decide what async method to use to triggering processing of queued callbacks: +- if (lib$es6$promise$asap$$isNode) { +- lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useNextTick(); +- } else if (lib$es6$promise$asap$$BrowserMutationObserver) { +- lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useMutationObserver(); +- } else if (lib$es6$promise$asap$$isWorker) { +- lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useMessageChannel(); +- } else if (lib$es6$promise$asap$$browserWindow === undefined && typeof require === 'function') { +- lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$attemptVertx(); ++//Finds the item with key if it exists ++proto.find = function(key) { ++ var cmp = this._compare ++ var n = this.root ++ var stack = [] ++ while(n) { ++ var d = cmp(key, n.key) ++ stack.push(n) ++ if(d === 0) { ++ return new RedBlackTreeIterator(this, stack) ++ } ++ if(d <= 0) { ++ n = n.left + } else { +- lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useSetTimeout(); ++ n = n.right + } +- function lib$es6$promise$then$$then(onFulfillment, onRejection) { +- var parent = this; +- var state = parent._state; +- +- if (state === lib$es6$promise$$internal$$FULFILLED && !onFulfillment || state === lib$es6$promise$$internal$$REJECTED && !onRejection) { +- return this; +- } +- +- var child = new this.constructor(lib$es6$promise$$internal$$noop); +- var result = parent._result; ++ } ++ return new RedBlackTreeIterator(this, []) ++} + +- if (state) { +- var callback = arguments[state - 1]; +- lib$es6$promise$asap$$asap(function(){ +- lib$es6$promise$$internal$$invokeCallback(state, child, callback, result); +- }); +- } else { +- lib$es6$promise$$internal$$subscribe(parent, child, onFulfillment, onRejection); +- } ++//Removes item with key from tree ++proto.remove = function(key) { ++ var iter = this.find(key) ++ if(iter) { ++ return iter.remove() ++ } ++ return this ++} + +- return child; ++//Returns the item at `key` ++proto.get = function(key) { ++ var cmp = this._compare ++ var n = this.root ++ while(n) { ++ var d = cmp(key, n.key) ++ if(d === 0) { ++ return n.value + } +- var lib$es6$promise$then$$default = lib$es6$promise$then$$then; +- function lib$es6$promise$promise$resolve$$resolve(object) { +- /*jshint validthis:true */ +- var Constructor = this; +- +- if (object && typeof object === 'object' && object.constructor === Constructor) { +- return object; +- } +- +- var promise = new Constructor(lib$es6$promise$$internal$$noop); +- lib$es6$promise$$internal$$resolve(promise, object); +- return promise; ++ if(d <= 0) { ++ n = n.left ++ } else { ++ n = n.right + } +- var lib$es6$promise$promise$resolve$$default = lib$es6$promise$promise$resolve$$resolve; ++ } ++ return ++} + +- function lib$es6$promise$$internal$$noop() {} ++//Iterator for red black tree ++function RedBlackTreeIterator(tree, stack) { ++ this.tree = tree ++ this._stack = stack ++} + +- var lib$es6$promise$$internal$$PENDING = void 0; +- var lib$es6$promise$$internal$$FULFILLED = 1; +- var lib$es6$promise$$internal$$REJECTED = 2; ++var iproto = RedBlackTreeIterator.prototype + +- var lib$es6$promise$$internal$$GET_THEN_ERROR = new lib$es6$promise$$internal$$ErrorObject(); ++//Test if iterator is valid ++Object.defineProperty(iproto, "valid", { ++ get: function() { ++ return this._stack.length > 0 ++ } ++}) + +- function lib$es6$promise$$internal$$selfFulfillment() { +- return new TypeError("You cannot resolve a promise with itself"); ++//Node of the iterator ++Object.defineProperty(iproto, "node", { ++ get: function() { ++ if(this._stack.length > 0) { ++ return this._stack[this._stack.length-1] + } ++ return null ++ }, ++ enumerable: true ++}) + +- function lib$es6$promise$$internal$$cannotReturnOwn() { +- return new TypeError('A promises callback cannot return that same promise.'); +- } ++//Makes a copy of an iterator ++iproto.clone = function() { ++ return new RedBlackTreeIterator(this.tree, this._stack.slice()) ++} + +- function lib$es6$promise$$internal$$getThen(promise) { +- try { +- return promise.then; +- } catch(error) { +- lib$es6$promise$$internal$$GET_THEN_ERROR.error = error; +- return lib$es6$promise$$internal$$GET_THEN_ERROR; +- } +- } ++//Swaps two nodes ++function swapNode(n, v) { ++ n.key = v.key ++ n.value = v.value ++ n.left = v.left ++ n.right = v.right ++ n._color = v._color ++ n._count = v._count ++} + +- function lib$es6$promise$$internal$$tryThen(then, value, fulfillmentHandler, rejectionHandler) { +- try { +- then.call(value, fulfillmentHandler, rejectionHandler); +- } catch(e) { +- return e; +- } ++//Fix up a double black node in a tree ++function fixDoubleBlack(stack) { ++ var n, p, s, z ++ for(var i=stack.length-1; i>=0; --i) { ++ n = stack[i] ++ if(i === 0) { ++ n._color = BLACK ++ return + } +- +- function lib$es6$promise$$internal$$handleForeignThenable(promise, thenable, then) { +- lib$es6$promise$asap$$asap(function(promise) { +- var sealed = false; +- var error = lib$es6$promise$$internal$$tryThen(then, thenable, function(value) { +- if (sealed) { return; } +- sealed = true; +- if (thenable !== value) { +- lib$es6$promise$$internal$$resolve(promise, value); ++ //console.log("visit node:", n.key, i, stack[i].key, stack[i-1].key) ++ p = stack[i-1] ++ if(p.left === n) { ++ //console.log("left child") ++ s = p.right ++ if(s.right && s.right._color === RED) { ++ //console.log("case 1: right sibling child red") ++ s = p.right = cloneNode(s) ++ z = s.right = cloneNode(s.right) ++ p.right = s.left ++ s.left = p ++ s.right = z ++ s._color = p._color ++ n._color = BLACK ++ p._color = BLACK ++ z._color = BLACK ++ recount(p) ++ recount(s) ++ if(i > 1) { ++ var pp = stack[i-2] ++ if(pp.left === p) { ++ pp.left = s + } else { +- lib$es6$promise$$internal$$fulfill(promise, value); ++ pp.right = s + } +- }, function(reason) { +- if (sealed) { return; } +- sealed = true; +- +- lib$es6$promise$$internal$$reject(promise, reason); +- }, 'Settle: ' + (promise._label || ' unknown promise')); +- +- if (!sealed && error) { +- sealed = true; +- lib$es6$promise$$internal$$reject(promise, error); + } +- }, promise); +- } +- +- function lib$es6$promise$$internal$$handleOwnThenable(promise, thenable) { +- if (thenable._state === lib$es6$promise$$internal$$FULFILLED) { +- lib$es6$promise$$internal$$fulfill(promise, thenable._result); +- } else if (thenable._state === lib$es6$promise$$internal$$REJECTED) { +- lib$es6$promise$$internal$$reject(promise, thenable._result); ++ stack[i-1] = s ++ return ++ } else if(s.left && s.left._color === RED) { ++ //console.log("case 1: left sibling child red") ++ s = p.right = cloneNode(s) ++ z = s.left = cloneNode(s.left) ++ p.right = z.left ++ s.left = z.right ++ z.left = p ++ z.right = s ++ z._color = p._color ++ p._color = BLACK ++ s._color = BLACK ++ n._color = BLACK ++ recount(p) ++ recount(s) ++ recount(z) ++ if(i > 1) { ++ var pp = stack[i-2] ++ if(pp.left === p) { ++ pp.left = z ++ } else { ++ pp.right = z ++ } ++ } ++ stack[i-1] = z ++ return ++ } ++ if(s._color === BLACK) { ++ if(p._color === RED) { ++ //console.log("case 2: black sibling, red parent", p.right.value) ++ p._color = BLACK ++ p.right = repaint(RED, s) ++ return ++ } else { ++ //console.log("case 2: black sibling, black parent", p.right.value) ++ p.right = repaint(RED, s) ++ continue ++ } + } else { +- lib$es6$promise$$internal$$subscribe(thenable, undefined, function(value) { +- lib$es6$promise$$internal$$resolve(promise, value); +- }, function(reason) { +- lib$es6$promise$$internal$$reject(promise, reason); +- }); ++ //console.log("case 3: red sibling") ++ s = cloneNode(s) ++ p.right = s.left ++ s.left = p ++ s._color = p._color ++ p._color = RED ++ recount(p) ++ recount(s) ++ if(i > 1) { ++ var pp = stack[i-2] ++ if(pp.left === p) { ++ pp.left = s ++ } else { ++ pp.right = s ++ } ++ } ++ stack[i-1] = s ++ stack[i] = p ++ if(i+1 < stack.length) { ++ stack[i+1] = n ++ } else { ++ stack.push(n) ++ } ++ i = i+2 ++ } ++ } else { ++ //console.log("right child") ++ s = p.left ++ if(s.left && s.left._color === RED) { ++ //console.log("case 1: left sibling child red", p.value, p._color) ++ s = p.left = cloneNode(s) ++ z = s.left = cloneNode(s.left) ++ p.left = s.right ++ s.right = p ++ s.left = z ++ s._color = p._color ++ n._color = BLACK ++ p._color = BLACK ++ z._color = BLACK ++ recount(p) ++ recount(s) ++ if(i > 1) { ++ var pp = stack[i-2] ++ if(pp.right === p) { ++ pp.right = s ++ } else { ++ pp.left = s ++ } ++ } ++ stack[i-1] = s ++ return ++ } else if(s.right && s.right._color === RED) { ++ //console.log("case 1: right sibling child red") ++ s = p.left = cloneNode(s) ++ z = s.right = cloneNode(s.right) ++ p.left = z.right ++ s.right = z.left ++ z.right = p ++ z.left = s ++ z._color = p._color ++ p._color = BLACK ++ s._color = BLACK ++ n._color = BLACK ++ recount(p) ++ recount(s) ++ recount(z) ++ if(i > 1) { ++ var pp = stack[i-2] ++ if(pp.right === p) { ++ pp.right = z ++ } else { ++ pp.left = z ++ } ++ } ++ stack[i-1] = z ++ return + } +- } +- +- function lib$es6$promise$$internal$$handleMaybeThenable(promise, maybeThenable, then) { +- if (maybeThenable.constructor === promise.constructor && +- then === lib$es6$promise$then$$default && +- constructor.resolve === lib$es6$promise$promise$resolve$$default) { +- lib$es6$promise$$internal$$handleOwnThenable(promise, maybeThenable); +- } else { +- if (then === lib$es6$promise$$internal$$GET_THEN_ERROR) { +- lib$es6$promise$$internal$$reject(promise, lib$es6$promise$$internal$$GET_THEN_ERROR.error); +- } else if (then === undefined) { +- lib$es6$promise$$internal$$fulfill(promise, maybeThenable); +- } else if (lib$es6$promise$utils$$isFunction(then)) { +- lib$es6$promise$$internal$$handleForeignThenable(promise, maybeThenable, then); ++ if(s._color === BLACK) { ++ if(p._color === RED) { ++ //console.log("case 2: black sibling, red parent") ++ p._color = BLACK ++ p.left = repaint(RED, s) ++ return + } else { +- lib$es6$promise$$internal$$fulfill(promise, maybeThenable); ++ //console.log("case 2: black sibling, black parent") ++ p.left = repaint(RED, s) ++ continue + } +- } +- } +- +- function lib$es6$promise$$internal$$resolve(promise, value) { +- if (promise === value) { +- lib$es6$promise$$internal$$reject(promise, lib$es6$promise$$internal$$selfFulfillment()); +- } else if (lib$es6$promise$utils$$objectOrFunction(value)) { +- lib$es6$promise$$internal$$handleMaybeThenable(promise, value, lib$es6$promise$$internal$$getThen(value)); + } else { +- lib$es6$promise$$internal$$fulfill(promise, value); +- } +- } +- +- function lib$es6$promise$$internal$$publishRejection(promise) { +- if (promise._onerror) { +- promise._onerror(promise._result); +- } +- +- lib$es6$promise$$internal$$publish(promise); +- } +- +- function lib$es6$promise$$internal$$fulfill(promise, value) { +- if (promise._state !== lib$es6$promise$$internal$$PENDING) { return; } +- +- promise._result = value; +- promise._state = lib$es6$promise$$internal$$FULFILLED; +- +- if (promise._subscribers.length !== 0) { +- lib$es6$promise$asap$$asap(lib$es6$promise$$internal$$publish, promise); +- } +- } +- +- function lib$es6$promise$$internal$$reject(promise, reason) { +- if (promise._state !== lib$es6$promise$$internal$$PENDING) { return; } +- promise._state = lib$es6$promise$$internal$$REJECTED; +- promise._result = reason; +- +- lib$es6$promise$asap$$asap(lib$es6$promise$$internal$$publishRejection, promise); +- } +- +- function lib$es6$promise$$internal$$subscribe(parent, child, onFulfillment, onRejection) { +- var subscribers = parent._subscribers; +- var length = subscribers.length; +- +- parent._onerror = null; +- +- subscribers[length] = child; +- subscribers[length + lib$es6$promise$$internal$$FULFILLED] = onFulfillment; +- subscribers[length + lib$es6$promise$$internal$$REJECTED] = onRejection; +- +- if (length === 0 && parent._state) { +- lib$es6$promise$asap$$asap(lib$es6$promise$$internal$$publish, parent); +- } +- } +- +- function lib$es6$promise$$internal$$publish(promise) { +- var subscribers = promise._subscribers; +- var settled = promise._state; +- +- if (subscribers.length === 0) { return; } +- +- var child, callback, detail = promise._result; +- +- for (var i = 0; i < subscribers.length; i += 3) { +- child = subscribers[i]; +- callback = subscribers[i + settled]; +- +- if (child) { +- lib$es6$promise$$internal$$invokeCallback(settled, child, callback, detail); +- } else { +- callback(detail); ++ //console.log("case 3: red sibling") ++ s = cloneNode(s) ++ p.left = s.right ++ s.right = p ++ s._color = p._color ++ p._color = RED ++ recount(p) ++ recount(s) ++ if(i > 1) { ++ var pp = stack[i-2] ++ if(pp.right === p) { ++ pp.right = s ++ } else { ++ pp.left = s ++ } + } +- } +- +- promise._subscribers.length = 0; +- } +- +- function lib$es6$promise$$internal$$ErrorObject() { +- this.error = null; +- } +- +- var lib$es6$promise$$internal$$TRY_CATCH_ERROR = new lib$es6$promise$$internal$$ErrorObject(); +- +- function lib$es6$promise$$internal$$tryCatch(callback, detail) { +- try { +- return callback(detail); +- } catch(e) { +- lib$es6$promise$$internal$$TRY_CATCH_ERROR.error = e; +- return lib$es6$promise$$internal$$TRY_CATCH_ERROR; +- } +- } +- +- function lib$es6$promise$$internal$$invokeCallback(settled, promise, callback, detail) { +- var hasCallback = lib$es6$promise$utils$$isFunction(callback), +- value, error, succeeded, failed; +- +- if (hasCallback) { +- value = lib$es6$promise$$internal$$tryCatch(callback, detail); +- +- if (value === lib$es6$promise$$internal$$TRY_CATCH_ERROR) { +- failed = true; +- error = value.error; +- value = null; ++ stack[i-1] = s ++ stack[i] = p ++ if(i+1 < stack.length) { ++ stack[i+1] = n + } else { +- succeeded = true; +- } +- +- if (promise === value) { +- lib$es6$promise$$internal$$reject(promise, lib$es6$promise$$internal$$cannotReturnOwn()); +- return; ++ stack.push(n) + } +- +- } else { +- value = detail; +- succeeded = true; +- } +- +- if (promise._state !== lib$es6$promise$$internal$$PENDING) { +- // noop +- } else if (hasCallback && succeeded) { +- lib$es6$promise$$internal$$resolve(promise, value); +- } else if (failed) { +- lib$es6$promise$$internal$$reject(promise, error); +- } else if (settled === lib$es6$promise$$internal$$FULFILLED) { +- lib$es6$promise$$internal$$fulfill(promise, value); +- } else if (settled === lib$es6$promise$$internal$$REJECTED) { +- lib$es6$promise$$internal$$reject(promise, value); +- } +- } +- +- function lib$es6$promise$$internal$$initializePromise(promise, resolver) { +- try { +- resolver(function resolvePromise(value){ +- lib$es6$promise$$internal$$resolve(promise, value); +- }, function rejectPromise(reason) { +- lib$es6$promise$$internal$$reject(promise, reason); +- }); +- } catch(e) { +- lib$es6$promise$$internal$$reject(promise, e); ++ i = i+2 + } + } ++ } ++} + +- function lib$es6$promise$promise$all$$all(entries) { +- return new lib$es6$promise$enumerator$$default(this, entries).promise; ++//Removes item at iterator from tree ++iproto.remove = function() { ++ var stack = this._stack ++ if(stack.length === 0) { ++ return this.tree ++ } ++ //First copy path to node ++ var cstack = new Array(stack.length) ++ var n = stack[stack.length-1] ++ cstack[cstack.length-1] = new RBNode(n._color, n.key, n.value, n.left, n.right, n._count) ++ for(var i=stack.length-2; i>=0; --i) { ++ var n = stack[i] ++ if(n.left === stack[i+1]) { ++ cstack[i] = new RBNode(n._color, n.key, n.value, cstack[i+1], n.right, n._count) ++ } else { ++ cstack[i] = new RBNode(n._color, n.key, n.value, n.left, cstack[i+1], n._count) + } +- var lib$es6$promise$promise$all$$default = lib$es6$promise$promise$all$$all; +- function lib$es6$promise$promise$race$$race(entries) { +- /*jshint validthis:true */ +- var Constructor = this; +- +- var promise = new Constructor(lib$es6$promise$$internal$$noop); +- +- if (!lib$es6$promise$utils$$isArray(entries)) { +- lib$es6$promise$$internal$$reject(promise, new TypeError('You must pass an array to race.')); +- return promise; +- } +- +- var length = entries.length; +- +- function onFulfillment(value) { +- lib$es6$promise$$internal$$resolve(promise, value); +- } ++ } + +- function onRejection(reason) { +- lib$es6$promise$$internal$$reject(promise, reason); +- } ++ //Get node ++ n = cstack[cstack.length-1] ++ //console.log("start remove: ", n.value) + +- for (var i = 0; promise._state === lib$es6$promise$$internal$$PENDING && i < length; i++) { +- lib$es6$promise$$internal$$subscribe(Constructor.resolve(entries[i]), undefined, onFulfillment, onRejection); +- } ++ //If not leaf, then swap with previous node ++ if(n.left && n.right) { ++ //console.log("moving to leaf") + +- return promise; +- } +- var lib$es6$promise$promise$race$$default = lib$es6$promise$promise$race$$race; +- function lib$es6$promise$promise$reject$$reject(reason) { +- /*jshint validthis:true */ +- var Constructor = this; +- var promise = new Constructor(lib$es6$promise$$internal$$noop); +- lib$es6$promise$$internal$$reject(promise, reason); +- return promise; ++ //First walk to previous leaf ++ var split = cstack.length ++ n = n.left ++ while(n.right) { ++ cstack.push(n) ++ n = n.right + } +- var lib$es6$promise$promise$reject$$default = lib$es6$promise$promise$reject$$reject; +- +- var lib$es6$promise$promise$$counter = 0; ++ //Copy path to leaf ++ var v = cstack[split-1] ++ cstack.push(new RBNode(n._color, v.key, v.value, n.left, n.right, n._count)) ++ cstack[split-1].key = n.key ++ cstack[split-1].value = n.value + +- function lib$es6$promise$promise$$needsResolver() { +- throw new TypeError('You must pass a resolver function as the first argument to the promise constructor'); ++ //Fix up stack ++ for(var i=cstack.length-2; i>=split; --i) { ++ n = cstack[i] ++ cstack[i] = new RBNode(n._color, n.key, n.value, n.left, cstack[i+1], n._count) + } ++ cstack[split-1].left = cstack[split] ++ } ++ //console.log("stack=", cstack.map(function(v) { return v.value })) + +- function lib$es6$promise$promise$$needsNew() { +- throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function."); ++ //Remove leaf node ++ n = cstack[cstack.length-1] ++ if(n._color === RED) { ++ //Easy case: removing red leaf ++ //console.log("RED leaf") ++ var p = cstack[cstack.length-2] ++ if(p.left === n) { ++ p.left = null ++ } else if(p.right === n) { ++ p.right = null + } +- +- var lib$es6$promise$promise$$default = lib$es6$promise$promise$$Promise; +- /** +- Promise objects represent the eventual result of an asynchronous operation. The +- primary way of interacting with a promise is through its `then` method, which +- registers callbacks to receive either a promise's eventual value or the reason +- why the promise cannot be fulfilled. +- +- Terminology +- ----------- +- +- - `promise` is an object or function with a `then` method whose behavior conforms to this specification. +- - `thenable` is an object or function that defines a `then` method. +- - `value` is any legal JavaScript value (including undefined, a thenable, or a promise). +- - `exception` is a value that is thrown using the throw statement. +- - `reason` is a value that indicates why a promise was rejected. +- - `settled` the final resting state of a promise, fulfilled or rejected. +- +- A promise can be in one of three states: pending, fulfilled, or rejected. +- +- Promises that are fulfilled have a fulfillment value and are in the fulfilled +- state. Promises that are rejected have a rejection reason and are in the +- rejected state. A fulfillment value is never a thenable. +- +- Promises can also be said to *resolve* a value. If this value is also a +- promise, then the original promise's settled state will match the value's +- settled state. So a promise that *resolves* a promise that rejects will +- itself reject, and a promise that *resolves* a promise that fulfills will +- itself fulfill. +- +- +- Basic Usage: +- ------------ +- +- ```js +- var promise = new Promise(function(resolve, reject) { +- // on success +- resolve(value); +- +- // on failure +- reject(reason); +- }); +- +- promise.then(function(value) { +- // on fulfillment +- }, function(reason) { +- // on rejection +- }); +- ``` +- +- Advanced Usage: +- --------------- +- +- Promises shine when abstracting away asynchronous interactions such as +- `XMLHttpRequest`s. +- +- ```js +- function getJSON(url) { +- return new Promise(function(resolve, reject){ +- var xhr = new XMLHttpRequest(); +- +- xhr.open('GET', url); +- xhr.onreadystatechange = handler; +- xhr.responseType = 'json'; +- xhr.setRequestHeader('Accept', 'application/json'); +- xhr.send(); +- +- function handler() { +- if (this.readyState === this.DONE) { +- if (this.status === 200) { +- resolve(this.response); +- } else { +- reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']')); +- } +- } +- }; +- }); +- } +- +- getJSON('/posts.json').then(function(json) { +- // on fulfillment +- }, function(reason) { +- // on rejection +- }); +- ``` +- +- Unlike callbacks, promises are great composable primitives. +- +- ```js +- Promise.all([ +- getJSON('/posts'), +- getJSON('/comments') +- ]).then(function(values){ +- values[0] // => postsJSON +- values[1] // => commentsJSON +- +- return values; +- }); +- ``` +- +- @class Promise +- @param {function} resolver +- Useful for tooling. +- @constructor +- */ +- function lib$es6$promise$promise$$Promise(resolver) { +- this._id = lib$es6$promise$promise$$counter++; +- this._state = undefined; +- this._result = undefined; +- this._subscribers = []; +- +- if (lib$es6$promise$$internal$$noop !== resolver) { +- typeof resolver !== 'function' && lib$es6$promise$promise$$needsResolver(); +- this instanceof lib$es6$promise$promise$$Promise ? lib$es6$promise$$internal$$initializePromise(this, resolver) : lib$es6$promise$promise$$needsNew(); +- } ++ cstack.pop() ++ for(var i=0; i 0) { ++ return this._stack[this._stack.length-1].key ++ } ++ return ++ }, ++ enumerable: true ++}) + +- lib$es6$promise$enumerator$$Enumerator.prototype._enumerate = function() { +- var length = this.length; +- var input = this._input; ++//Returns value ++Object.defineProperty(iproto, "value", { ++ get: function() { ++ if(this._stack.length > 0) { ++ return this._stack[this._stack.length-1].value ++ } ++ return ++ }, ++ enumerable: true ++}) + +- for (var i = 0; this._state === lib$es6$promise$$internal$$PENDING && i < length; i++) { +- this._eachEntry(input[i], i); +- } +- }; + +- lib$es6$promise$enumerator$$Enumerator.prototype._eachEntry = function(entry, i) { +- var c = this._instanceConstructor; +- var resolve = c.resolve; +- +- if (resolve === lib$es6$promise$promise$resolve$$default) { +- var then = lib$es6$promise$$internal$$getThen(entry); +- +- if (then === lib$es6$promise$then$$default && +- entry._state !== lib$es6$promise$$internal$$PENDING) { +- this._settledAt(entry._state, i, entry._result); +- } else if (typeof then !== 'function') { +- this._remaining--; +- this._result[i] = entry; +- } else if (c === lib$es6$promise$promise$$default) { +- var promise = new c(lib$es6$promise$$internal$$noop); +- lib$es6$promise$$internal$$handleMaybeThenable(promise, entry, then); +- this._willSettleAt(promise, i); +- } else { +- this._willSettleAt(new c(function(resolve) { resolve(entry); }), i); +- } +- } else { +- this._willSettleAt(resolve(entry), i); ++//Returns the position of this iterator in the sorted list ++Object.defineProperty(iproto, "index", { ++ get: function() { ++ var idx = 0 ++ var stack = this._stack ++ if(stack.length === 0) { ++ var r = this.tree.root ++ if(r) { ++ return r._count + } +- }; +- +- lib$es6$promise$enumerator$$Enumerator.prototype._settledAt = function(state, i, value) { +- var promise = this.promise; +- +- if (promise._state === lib$es6$promise$$internal$$PENDING) { +- this._remaining--; +- +- if (state === lib$es6$promise$$internal$$REJECTED) { +- lib$es6$promise$$internal$$reject(promise, value); +- } else { +- this._result[i] = value; ++ return 0 ++ } else if(stack[stack.length-1].left) { ++ idx = stack[stack.length-1].left._count ++ } ++ for(var s=stack.length-2; s>=0; --s) { ++ if(stack[s+1] === stack[s].right) { ++ ++idx ++ if(stack[s].left) { ++ idx += stack[s].left._count + } + } +- +- if (this._remaining === 0) { +- lib$es6$promise$$internal$$fulfill(promise, this._result); +- } +- }; +- +- lib$es6$promise$enumerator$$Enumerator.prototype._willSettleAt = function(promise, i) { +- var enumerator = this; +- +- lib$es6$promise$$internal$$subscribe(promise, undefined, function(value) { +- enumerator._settledAt(lib$es6$promise$$internal$$FULFILLED, i, value); +- }, function(reason) { +- enumerator._settledAt(lib$es6$promise$$internal$$REJECTED, i, reason); +- }); +- }; +- function lib$es6$promise$polyfill$$polyfill() { +- var local; +- +- if (typeof global !== 'undefined') { +- local = global; +- } else if (typeof self !== 'undefined') { +- local = self; +- } else { +- try { +- local = Function('return this')(); +- } catch (e) { +- throw new Error('polyfill failed because global object is unavailable in this environment'); +- } +- } +- +- var P = local.Promise; +- +- if (P && Object.prototype.toString.call(P.resolve()) === '[object Promise]' && !P.cast) { +- return; +- } +- +- local.Promise = lib$es6$promise$promise$$default; + } +- var lib$es6$promise$polyfill$$default = lib$es6$promise$polyfill$$polyfill; +- +- var lib$es6$promise$umd$$ES6Promise = { +- 'Promise': lib$es6$promise$promise$$default, +- 'polyfill': lib$es6$promise$polyfill$$default +- }; ++ return idx ++ }, ++ enumerable: true ++}) + +- /* global define:true module:true window: true */ +- if (typeof define === 'function' && define['amd']) { +- define(function() { return lib$es6$promise$umd$$ES6Promise; }); +- } else if (typeof module !== 'undefined' && module['exports']) { +- module['exports'] = lib$es6$promise$umd$$ES6Promise; +- } else if (typeof this !== 'undefined') { +- this['ES6Promise'] = lib$es6$promise$umd$$ES6Promise; ++//Advances iterator to next element in list ++iproto.next = function() { ++ var stack = this._stack ++ if(stack.length === 0) { ++ return ++ } ++ var n = stack[stack.length-1] ++ if(n.right) { ++ n = n.right ++ while(n) { ++ stack.push(n) ++ n = n.left + } +- +- lib$es6$promise$polyfill$$default(); +-}).call(this); +- +- +-}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +-},{"_process":44}],104:[function(require,module,exports){ +-/** +- * inspired by is-number +- * but significantly simplified and sped up by ignoring number and string constructors +- * ie these return false: +- * new Number(1) +- * new String('1') +- */ +- +-'use strict'; +- +-/** +- * Is this string all whitespace? +- * This solution kind of makes my brain hurt, but it's significantly faster +- * than !str.trim() or any other solution I could find. +- * +- * whitespace codes from: http://en.wikipedia.org/wiki/Whitespace_character +- * and verified with: +- * +- * for(var i = 0; i < 65536; i++) { +- * var s = String.fromCharCode(i); +- * if(+s===0 && !s.trim()) console.log(i, s); +- * } +- * +- * which counts a couple of these as *not* whitespace, but finds nothing else +- * that *is* whitespace. Note that charCodeAt stops at 16 bits, but it appears +- * that there are no whitespace characters above this, and code points above +- * this do not map onto white space characters. +- */ +-function allBlankCharCodes(str){ +- var l = str.length, +- a; +- for(var i = 0; i < l; i++) { +- a = str.charCodeAt(i); +- if((a < 9 || a > 13) && (a !== 32) && (a !== 133) && (a !== 160) && +- (a !== 5760) && (a !== 6158) && (a < 8192 || a > 8205) && +- (a !== 8232) && (a !== 8233) && (a !== 8239) && (a !== 8287) && +- (a !== 8288) && (a !== 12288) && (a !== 65279)) { +- return false; +- } ++ } else { ++ stack.pop() ++ while(stack.length > 0 && stack[stack.length-1].right === n) { ++ n = stack[stack.length-1] ++ stack.pop() + } +- return true; ++ } + } + +-module.exports = function(n) { +- var type = typeof n; +- if(type === 'string') { +- var original = n; +- n = +n; +- // whitespace strings cast to zero - filter them out +- if(n===0 && allBlankCharCodes(original)) return false; ++//Checks if iterator is at end of tree ++Object.defineProperty(iproto, "hasNext", { ++ get: function() { ++ var stack = this._stack ++ if(stack.length === 0) { ++ return false + } +- else if(type !== 'number') return false; +- +- return n - n < 1; +-}; +- +-},{}],105:[function(require,module,exports){ +-"use strict" +- +-var pool = require("typedarray-pool") +-var ops = require("ndarray-ops") +-var ndarray = require("ndarray") +- +-var SUPPORTED_TYPES = [ +- "uint8", +- "uint8_clamped", +- "uint16", +- "uint32", +- "int8", +- "int16", +- "int32", +- "float32" ] +- +-function GLBuffer(gl, type, handle, length, usage) { +- this.gl = gl +- this.type = type +- this.handle = handle +- this.length = length +- this.usage = usage +-} +- +-var proto = GLBuffer.prototype +- +-proto.bind = function() { +- this.gl.bindBuffer(this.type, this.handle) +-} +- +-proto.unbind = function() { +- this.gl.bindBuffer(this.type, null) +-} +- +-proto.dispose = function() { +- this.gl.deleteBuffer(this.handle) +-} +- +-function updateTypeArray(gl, type, len, usage, data, offset) { +- var dataLen = data.length * data.BYTES_PER_ELEMENT +- if(offset < 0) { +- gl.bufferData(type, data, usage) +- return dataLen +- } +- if(dataLen + offset > len) { +- throw new Error("gl-buffer: If resizing buffer, must not specify offset") ++ if(stack[stack.length-1].right) { ++ return true ++ } ++ for(var s=stack.length-1; s>0; --s) { ++ if(stack[s-1].left === stack[s]) { ++ return true ++ } ++ } ++ return false + } +- gl.bufferSubData(type, offset, data) +- return len +-} ++}) + +-function makeScratchTypeArray(array, dtype) { +- var res = pool.malloc(array.length, dtype) +- var n = array.length +- for(var i=0; i=0; --i) { +- if(stride[i] !== n) { +- return false ++ var cstack = new Array(stack.length) ++ var n = stack[stack.length-1] ++ cstack[cstack.length-1] = new RBNode(n._color, n.key, value, n.left, n.right, n._count) ++ for(var i=stack.length-2; i>=0; --i) { ++ n = stack[i] ++ if(n.left === stack[i+1]) { ++ cstack[i] = new RBNode(n._color, n.key, n.value, cstack[i+1], n.right, n._count) ++ } else { ++ cstack[i] = new RBNode(n._color, n.key, n.value, n.left, cstack[i+1], n._count) + } +- n *= shape[i] + } +- return true ++ return new RedBlackTree(this.tree._compare, cstack[0]) + } + +-proto.update = function(array, offset) { +- if(typeof offset !== "number") { +- offset = -1 ++//Moves iterator backward one element ++iproto.prev = function() { ++ var stack = this._stack ++ if(stack.length === 0) { ++ return + } +- this.bind() +- if(typeof array === "object" && typeof array.shape !== "undefined") { //ndarray +- var dtype = array.dtype +- if(SUPPORTED_TYPES.indexOf(dtype) < 0) { +- dtype = "float32" +- } +- if(this.type === this.gl.ELEMENT_ARRAY_BUFFER) { +- var ext = gl.getExtension('OES_element_index_uint') +- if(ext && dtype !== "uint16") { +- dtype = "uint32" +- } else { +- dtype = "uint16" +- } +- } +- if(dtype === array.dtype && isPacked(array.shape, array.stride)) { +- if(array.offset === 0 && array.data.length === array.shape[0]) { +- this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, array.data, offset) +- } else { +- this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, array.data.subarray(array.offset, array.shape[0]), offset) +- } +- } else { +- var tmp = pool.malloc(array.size, dtype) +- var ndt = ndarray(tmp, array.shape) +- ops.assign(ndt, array) +- if(offset < 0) { +- this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, tmp, offset) +- } else { +- this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, tmp.subarray(0, array.size), offset) +- } +- pool.free(tmp) ++ var n = stack[stack.length-1] ++ if(n.left) { ++ n = n.left ++ while(n) { ++ stack.push(n) ++ n = n.right + } +- } else if(Array.isArray(array)) { //Vanilla array +- var t +- if(this.type === this.gl.ELEMENT_ARRAY_BUFFER) { +- t = makeScratchTypeArray(array, "uint16") +- } else { +- t = makeScratchTypeArray(array, "float32") ++ } else { ++ stack.pop() ++ while(stack.length > 0 && stack[stack.length-1].left === n) { ++ n = stack[stack.length-1] ++ stack.pop() + } +- if(offset < 0) { +- this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, t, offset) +- } else { +- this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, t.subarray(0, array.length), offset) ++ } ++} ++ ++//Checks if iterator is at start of tree ++Object.defineProperty(iproto, "hasPrev", { ++ get: function() { ++ var stack = this._stack ++ if(stack.length === 0) { ++ return false + } +- pool.free(t) +- } else if(typeof array === "object" && typeof array.length === "number") { //Typed array +- this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, array, offset) +- } else if(typeof array === "number" || array === undefined) { //Number/default +- if(offset >= 0) { +- throw new Error("gl-buffer: Cannot specify offset when resizing buffer") ++ if(stack[stack.length-1].left) { ++ return true + } +- array = array | 0 +- if(array <= 0) { +- array = 1 ++ for(var s=stack.length-1; s>0; --s) { ++ if(stack[s-1].right === stack[s]) { ++ return true ++ } + } +- this.gl.bufferData(this.type, array|0, this.usage) +- this.length = array +- } else { //Error, case should not happen +- throw new Error("gl-buffer: Invalid data type") ++ return false + } +-} ++}) + +-function createBuffer(gl, data, type, usage) { +- type = type || gl.ARRAY_BUFFER +- usage = usage || gl.DYNAMIC_DRAW +- if(type !== gl.ARRAY_BUFFER && type !== gl.ELEMENT_ARRAY_BUFFER) { +- throw new Error("gl-buffer: Invalid type for webgl buffer, must be either gl.ARRAY_BUFFER or gl.ELEMENT_ARRAY_BUFFER") ++//Default comparison function ++function defaultCompare(a, b) { ++ if(a < b) { ++ return -1 + } +- if(usage !== gl.DYNAMIC_DRAW && usage !== gl.STATIC_DRAW && usage !== gl.STREAM_DRAW) { +- throw new Error("gl-buffer: Invalid usage for buffer, must be either gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW") ++ if(a > b) { ++ return 1 + } +- var handle = gl.createBuffer() +- var result = new GLBuffer(gl, type, handle, 0, usage) +- result.update(data) +- return result ++ return 0 + } + +-module.exports = createBuffer +- +-},{"ndarray":219,"ndarray-ops":218,"typedarray-pool":242}],106:[function(require,module,exports){ +-'use strict' ++//Build a tree ++function createRBTree(compare) { ++ return new RedBlackTree(compare || defaultCompare, null) ++} ++},{}],85:[function(require,module,exports){ ++// transliterated from the python snippet here: ++// http://en.wikipedia.org/wiki/Lanczos_approximation + +-module.exports = createErrorBars ++var g = 7; ++var p = [ ++ 0.99999999999980993, ++ 676.5203681218851, ++ -1259.1392167224028, ++ 771.32342877765313, ++ -176.61502916214059, ++ 12.507343278686905, ++ -0.13857109526572012, ++ 9.9843695780195716e-6, ++ 1.5056327351493116e-7 ++]; + +-var createBuffer = require('gl-buffer') +-var createVAO = require('gl-vao') +-var createShader = require('./shaders/index') ++var g_ln = 607/128; ++var p_ln = [ ++ 0.99999999999999709182, ++ 57.156235665862923517, ++ -59.597960355475491248, ++ 14.136097974741747174, ++ -0.49191381609762019978, ++ 0.33994649984811888699e-4, ++ 0.46523628927048575665e-4, ++ -0.98374475304879564677e-4, ++ 0.15808870322491248884e-3, ++ -0.21026444172410488319e-3, ++ 0.21743961811521264320e-3, ++ -0.16431810653676389022e-3, ++ 0.84418223983852743293e-4, ++ -0.26190838401581408670e-4, ++ 0.36899182659531622704e-5 ++]; + +-var IDENTITY = [1,0,0,0, +- 0,1,0,0, +- 0,0,1,0, +- 0,0,0,1] ++// Spouge approximation (suitable for large arguments) ++function lngamma(z) { + +-function ErrorBars(gl, buffer, vao, shader) { +- this.gl = gl +- this.shader = shader +- this.buffer = buffer +- this.vao = vao +- this.pixelRatio = 1 +- this.bounds = [[ Infinity, Infinity, Infinity], [-Infinity,-Infinity,-Infinity]] +- this.clipBounds = [[-Infinity,-Infinity,-Infinity], [ Infinity, Infinity, Infinity]] +- this.lineWidth = [1,1,1] +- this.capSize = [10,10,10] +- this.lineCount = [0,0,0] +- this.lineOffset = [0,0,0] +- this.opacity = 1 ++ if(z < 0) return Number('0/0'); ++ var x = p_ln[0]; ++ for(var i = p_ln.length - 1; i > 0; --i) x += p_ln[i] / (z + i); ++ var t = z + g_ln + 0.5; ++ return .5*Math.log(2*Math.PI)+(z+.5)*Math.log(t)-t+Math.log(x)-Math.log(z); + } + +-var proto = ErrorBars.prototype +- +-proto.isOpaque = function() { +- return this.opacity >= 1 +-} ++module.exports = function gamma (z) { ++ if (z < 0.5) { ++ return Math.PI / (Math.sin(Math.PI * z) * gamma(1 - z)); ++ } ++ else if(z > 100) return Math.exp(lngamma(z)); ++ else { ++ z -= 1; ++ var x = p[0]; ++ for (var i = 1; i < g + 2; i++) { ++ x += p[i] / (z + i); ++ } ++ var t = z + g + 0.5; + +-proto.isTransparent = function() { +- return this.opacity < 1 +-} ++ return Math.sqrt(2 * Math.PI) ++ * Math.pow(t, z + 0.5) ++ * Math.exp(-t) ++ * x ++ ; ++ } ++}; + +-proto.drawTransparent = proto.draw = function(cameraParams) { +- var gl = this.gl +- var uniforms = this.shader.uniforms ++module.exports.log = lngamma; + +- this.shader.bind() +- var view = uniforms.view = cameraParams.view || IDENTITY +- var projection = uniforms.projection = cameraParams.projection || IDENTITY +- uniforms.model = cameraParams.model || IDENTITY +- uniforms.clipBounds = this.clipBounds +- uniforms.opacity = this.opacity ++},{}],86:[function(require,module,exports){ ++'use strict' + ++module.exports = createAxes + +- var cx = view[12] +- var cy = view[13] +- var cz = view[14] +- var cw = view[15] +- var pixelScaleF = this.pixelRatio * (projection[3]*cx + projection[7]*cy + projection[11]*cz + projection[15]*cw) / gl.drawingBufferHeight ++var createText = require('./lib/text.js') ++var createLines = require('./lib/lines.js') ++var createBackground = require('./lib/background.js') ++var getCubeProperties = require('./lib/cube.js') ++var Ticks = require('./lib/ticks.js') + ++var identity = new Float32Array([ ++ 1, 0, 0, 0, ++ 0, 1, 0, 0, ++ 0, 0, 1, 0, ++ 0, 0, 0, 1]) + +- this.vao.bind() +- for(var i=0; i<3; ++i) { +- gl.lineWidth(this.lineWidth[i]) +- uniforms.capSize = this.capSize[i] * pixelScaleF +- gl.drawArrays(gl.LINES, this.lineOffset[i], this.lineCount[i]) +- } +- this.vao.unbind() ++function copyVec3(a, b) { ++ a[0] = b[0] ++ a[1] = b[1] ++ a[2] = b[2] ++ return a + } + +-function updateBounds(bounds, point) { +- for(var i=0; i<3; ++i) { +- bounds[0][i] = Math.min(bounds[0][i], point[i]) +- bounds[1][i] = Math.max(bounds[1][i], point[i]) +- } +-} ++function Axes(gl) { ++ this.gl = gl + +-var FACE_TABLE = (function(){ +- var table = new Array(3) +- for(var d=0; d<3; ++d) { +- var row = [] +- for(var j=1; j<=2; ++j) { +- for(var s=-1; s<=1; s+=2) { +- var u = (j+d) % 3 +- var y = [0,0,0] +- y[u] = s +- row.push(y) +- } +- } +- table[d] = row +- } +- return table +-})() ++ this.pixelRatio = 1 ++ ++ this.bounds = [ [-10, -10, -10], ++ [ 10, 10, 10] ] ++ this.ticks = [ [], [], [] ] ++ this.autoTicks = true ++ this.tickSpacing = [ 1, 1, 1 ] + ++ this.tickEnable = [ true, true, true ] ++ this.tickFont = [ 'sans-serif', 'sans-serif', 'sans-serif' ] ++ this.tickSize = [ 12, 12, 12 ] ++ this.tickAngle = [ 0, 0, 0 ] ++ this.tickColor = [ [0,0,0,1], [0,0,0,1], [0,0,0,1] ] ++ this.tickPad = [ 10, 10, 10 ] + +-function emitFace(verts, x, c, d) { +- var offsets = FACE_TABLE[d] +- for(var i=0; i 0) { +- var x = p.slice() +- x[j] += e[1][j] +- verts.push(p[0], p[1], p[2], +- c[0], c[1], c[2], c[3], +- 0, 0, 0, +- x[0], x[1], x[2], +- c[0], c[1], c[2], c[3], +- 0, 0, 0) +- updateBounds(this.bounds, x) +- vertexCount += 2 + emitFace(verts, x, c, j) ++proto.update = function(options) { ++ options = options || {} ++ ++ //Option parsing helper functions ++ function parseOption(nest, cons, name) { ++ if(name in options) { ++ var opt = options[name] ++ var prev = this[name] ++ var next ++ if(nest ? (Array.isArray(opt) && Array.isArray(opt[0])) : ++ Array.isArray(opt) ) { ++ this[name] = next = [ cons(opt[0]), cons(opt[1]), cons(opt[2]) ] ++ } else { ++ this[name] = next = [ cons(opt), cons(opt), cons(opt) ] ++ } ++ for(var i=0; i<3; ++i) { ++ if(next[i] !== prev[i]) { ++ return true + } + } +- this.lineCount[j] = vertexCount - this.lineOffset[j] + } +- this.buffer.update(verts) ++ return false + } +-} + +-proto.dispose = function() { +- this.shader.dispose() +- this.buffer.dispose() +- this.vao.dispose() +-} ++ var NUMBER = parseOption.bind(this, false, Number) ++ var BOOLEAN = parseOption.bind(this, false, Boolean) ++ var STRING = parseOption.bind(this, false, String) ++ var COLOR = parseOption.bind(this, true, function(v) { ++ if(Array.isArray(v)) { ++ if(v.length === 3) { ++ return [ +v[0], +v[1], +v[2], 1.0 ] ++ } else if(v.length === 4) { ++ return [ +v[0], +v[1], +v[2], +v[3] ] ++ } ++ } ++ return [ 0, 0, 0, 1 ] ++ }) + +-function createErrorBars(options) { +- var gl = options.gl +- var buffer = createBuffer(gl) +- var vao = createVAO(gl, [ +- { +- buffer: buffer, +- type: gl.FLOAT, +- size: 3, +- offset: 0, +- stride: 40 +- }, +- { +- buffer: buffer, +- type: gl.FLOAT, +- size: 4, +- offset: 12, +- stride: 40 +- }, +- { +- buffer: buffer, +- type: gl.FLOAT, +- size: 3, +- offset: 28, +- stride: 40 ++ //Tick marks and bounds ++ var nextTicks ++ var ticksUpdate = false ++ var boundsChanged = false ++ if('bounds' in options) { ++ var bounds = options.bounds ++i_loop: ++ for(var i=0; i<2; ++i) { ++ for(var j=0; j<3; ++j) { ++ if(bounds[i][j] !== this.bounds[i][j]) { ++ boundsChanged = true ++ } ++ this.bounds[i][j] = bounds[i][j] + } +- ]) ++ } ++ } ++ if('ticks' in options) { ++ nextTicks = options.ticks ++ ticksUpdate = true ++ this.autoTicks = false ++ for(var i=0; i<3; ++i) { ++ this.tickSpacing[i] = 0.0 ++ } ++ } else if(NUMBER('tickSpacing')) { ++ this.autoTicks = true ++ boundsChanged = true ++ } + +- var shader = createShader(gl) +- shader.attributes.position.location = 0 +- shader.attributes.color.location = 1 +- shader.attributes.offset.location = 2 ++ if(this._firstInit) { ++ if(!('ticks' in options || 'tickSpacing' in options)) { ++ this.autoTicks = true ++ } + +- var result = new ErrorBars(gl, buffer, vao, shader) +- result.update(options) +- return result +-} ++ //Force tick recomputation on first update ++ boundsChanged = true ++ ticksUpdate = true ++ this._firstInit = false ++ } + +-},{"./shaders/index":107,"gl-buffer":105,"gl-vao":192}],107:[function(require,module,exports){ +-'use strict' ++ if(boundsChanged && this.autoTicks) { ++ nextTicks = Ticks.create(this.bounds, this.tickSpacing) ++ ticksUpdate = true ++ } + ++ //Compare next ticks to previous ticks, only update if needed ++ if(ticksUpdate) { ++ for(var i=0; i<3; ++i) { ++ nextTicks[i].sort(function(a,b) { ++ return a.x-b.x ++ }) ++ } ++ if(Ticks.equal(nextTicks, this.ticks)) { ++ ticksUpdate = false ++ } else { ++ this.ticks = nextTicks ++ } ++ } + +-var createShader = require('gl-shader') ++ //Parse tick properties ++ BOOLEAN('tickEnable') ++ if(STRING('tickFont')) { ++ ticksUpdate = true //If font changes, must rebuild vbo ++ } ++ NUMBER('tickSize') ++ NUMBER('tickAngle') ++ NUMBER('tickPad') ++ COLOR('tickColor') + +-var vertSrc = "precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position, offset;\nattribute vec4 color;\nuniform mat4 model, view, projection;\nuniform float capSize;\nvarying vec4 fragColor;\nvarying vec3 fragPosition;\n\nvoid main() {\n vec4 worldPosition = model * vec4(position, 1.0);\n worldPosition = (worldPosition / worldPosition.w) + vec4(capSize * offset, 0.0);\n gl_Position = projection * view * worldPosition;\n fragColor = color;\n fragPosition = position;\n}" +-var fragSrc = "precision mediump float;\n#define GLSLIFY 1\nuniform vec3 clipBounds[2];\nuniform float opacity;\nvarying vec3 fragPosition;\nvarying vec4 fragColor;\n\nvoid main() {\n if(any(lessThan(fragPosition, clipBounds[0])) || any(greaterThan(fragPosition, clipBounds[1]))) {\n discard;\n }\n gl_FragColor = opacity * fragColor;\n}" ++ //Axis labels ++ var labelUpdate = STRING('labels') ++ if(STRING('labelFont')) { ++ labelUpdate = true ++ } ++ BOOLEAN('labelEnable') ++ NUMBER('labelSize') ++ NUMBER('labelPad') ++ COLOR('labelColor') + +-module.exports = function(gl) { +- return createShader(gl, vertSrc, fragSrc, null, [ +- {name: 'position', type: 'vec3'}, +- {name: 'offset', type: 'vec3'}, +- {name: 'color', type: 'vec4'} +- ]) +-} ++ //Axis lines ++ BOOLEAN('lineEnable') ++ BOOLEAN('lineMirror') ++ NUMBER('lineWidth') ++ COLOR('lineColor') + +-},{"gl-shader":164}],108:[function(require,module,exports){ +-'use strict' ++ //Axis line ticks ++ BOOLEAN('lineTickEnable') ++ BOOLEAN('lineTickMirror') ++ NUMBER('lineTickLength') ++ NUMBER('lineTickWidth') ++ COLOR('lineTickColor') + +-var createTexture = require('gl-texture2d') ++ //Grid lines ++ BOOLEAN('gridEnable') ++ NUMBER('gridWidth') ++ COLOR('gridColor') + +-module.exports = createFBO ++ //Zero line ++ BOOLEAN('zeroEnable') ++ COLOR('zeroLineColor') ++ NUMBER('zeroLineWidth') + +-var colorAttachmentArrays = null +-var FRAMEBUFFER_UNSUPPORTED +-var FRAMEBUFFER_INCOMPLETE_ATTACHMENT +-var FRAMEBUFFER_INCOMPLETE_DIMENSIONS +-var FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT ++ //Background ++ BOOLEAN('backgroundEnable') ++ COLOR('backgroundColor') + +-function saveFBOState(gl) { +- var fbo = gl.getParameter(gl.FRAMEBUFFER_BINDING) +- var rbo = gl.getParameter(gl.RENDERBUFFER_BINDING) +- var tex = gl.getParameter(gl.TEXTURE_BINDING_2D) +- return [fbo, rbo, tex] ++ //Update text if necessary ++ if(!this._text) { ++ this._text = createText( ++ this.gl, ++ this.bounds, ++ this.labels, ++ this.labelFont, ++ this.ticks, ++ this.tickFont) ++ } else if(this._text && (labelUpdate || ticksUpdate)) { ++ this._text.update( ++ this.bounds, ++ this.labels, ++ this.labelFont, ++ this.ticks, ++ this.tickFont) ++ } ++ ++ //Update lines if necessary ++ if(this._lines && ticksUpdate) { ++ this._lines.dispose() ++ this._lines = null ++ } ++ if(!this._lines) { ++ this._lines = createLines(this.gl, this.bounds, this.ticks) ++ } + } + +-function restoreFBOState(gl, data) { +- gl.bindFramebuffer(gl.FRAMEBUFFER, data[0]) +- gl.bindRenderbuffer(gl.RENDERBUFFER, data[1]) +- gl.bindTexture(gl.TEXTURE_2D, data[2]) ++function OffsetInfo() { ++ this.primalOffset = [0,0,0] ++ this.primalMinor = [0,0,0] ++ this.mirrorOffset = [0,0,0] ++ this.mirrorMinor = [0,0,0] + } + +-function lazyInitColorAttachments(gl, ext) { +- var maxColorAttachments = gl.getParameter(ext.MAX_COLOR_ATTACHMENTS_WEBGL) +- colorAttachmentArrays = new Array(maxColorAttachments + 1) +- for(var i=0; i<=maxColorAttachments; ++i) { +- var x = new Array(maxColorAttachments) +- for(var j=0; j 0) { ++ c[j] = -1 ++ d[j] = 0 ++ } else { ++ c[j] = 0 ++ d[j] = +1 + } +- colorAttachmentArrays[i] = x + } + } + +-//Throw an appropriate error +-function throwFBOError(status) { +- switch(status){ +- case FRAMEBUFFER_UNSUPPORTED: +- throw new Error('gl-fbo: Framebuffer unsupported') +- case FRAMEBUFFER_INCOMPLETE_ATTACHMENT: +- throw new Error('gl-fbo: Framebuffer incomplete attachment') +- case FRAMEBUFFER_INCOMPLETE_DIMENSIONS: +- throw new Error('gl-fbo: Framebuffer incomplete dimensions') +- case FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: +- throw new Error('gl-fbo: Framebuffer incomplete missing attachment') +- default: +- throw new Error('gl-fbo: Framebuffer failed for unspecified reason') +- } ++var CUBE_ENABLE = [0,0,0] ++var DEFAULT_PARAMS = { ++ model: identity, ++ view: identity, ++ projection: identity + } + +-//Initialize a texture object +-function initTexture(gl, width, height, type, format, attachment) { +- if(!type) { +- return null +- } +- var result = createTexture(gl, width, height, format, type) +- result.magFilter = gl.NEAREST +- result.minFilter = gl.NEAREST +- result.mipSamples = 1 +- result.bind() +- gl.framebufferTexture2D(gl.FRAMEBUFFER, attachment, gl.TEXTURE_2D, result.handle, 0) +- return result ++proto.isOpaque = function() { ++ return true + } + +-//Initialize a render buffer object +-function initRenderBuffer(gl, width, height, component, attachment) { +- var result = gl.createRenderbuffer() +- gl.bindRenderbuffer(gl.RENDERBUFFER, result) +- gl.renderbufferStorage(gl.RENDERBUFFER, component, width, height) +- gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, result) +- return result ++proto.isTransparent = function() { ++ return false + } + +-//Rebuild the frame buffer +-function rebuildFBO(fbo) { ++proto.drawTransparent = function(params) {} + +- //Save FBO state +- var state = saveFBOState(fbo.gl) + +- var gl = fbo.gl +- var handle = fbo.handle = gl.createFramebuffer() +- var width = fbo._shape[0] +- var height = fbo._shape[1] +- var numColors = fbo.color.length +- var ext = fbo._ext +- var useStencil = fbo._useStencil +- var useDepth = fbo._useDepth +- var colorType = fbo._colorType ++var PRIMAL_MINOR = [0,0,0] ++var MIRROR_MINOR = [0,0,0] ++var PRIMAL_OFFSET = [0,0,0] + +- //Bind the fbo +- gl.bindFramebuffer(gl.FRAMEBUFFER, handle) ++proto.draw = function(params) { ++ params = params || DEFAULT_PARAMS + +- //Allocate color buffers +- for(var i=0; i 1) { +- ext.drawBuffersWEBGL(colorAttachmentArrays[numColors]) ++ ++ //Compute axis info ++ var lineOffset = LINE_OFFSET ++ for(var i=0; i<3; ++i) { ++ computeLineOffset( ++ LINE_OFFSET[i], ++ i, ++ this.bounds, ++ cubeEdges, ++ cubeAxis) + } + +- //Allocate depth/stencil buffers +- var WEBGL_depth_texture = gl.getExtension('WEBGL_depth_texture') +- if(WEBGL_depth_texture) { +- if(useStencil) { +- fbo.depth = initTexture(gl, width, height, +- WEBGL_depth_texture.UNSIGNED_INT_24_8_WEBGL, +- gl.DEPTH_STENCIL, +- gl.DEPTH_STENCIL_ATTACHMENT) +- } else if(useDepth) { +- fbo.depth = initTexture(gl, width, height, +- gl.UNSIGNED_SHORT, +- gl.DEPTH_COMPONENT, +- gl.DEPTH_ATTACHMENT) +- } +- } else { +- if(useDepth && useStencil) { +- fbo._depth_rb = initRenderBuffer(gl, width, height, gl.DEPTH_STENCIL, gl.DEPTH_STENCIL_ATTACHMENT) +- } else if(useDepth) { +- fbo._depth_rb = initRenderBuffer(gl, width, height, gl.DEPTH_COMPONENT16, gl.DEPTH_ATTACHMENT) +- } else if(useStencil) { +- fbo._depth_rb = initRenderBuffer(gl, width, height, gl.STENCIL_INDEX, gl.STENCIL_ATTACHMENT) ++ //Set up state parameters ++ var gl = this.gl ++ ++ //Draw background first ++ var cubeEnable = CUBE_ENABLE ++ for(var i=0; i<3; ++i) { ++ if(this.backgroundEnable[i]) { ++ cubeEnable[i] = cubeAxis[i] ++ } else { ++ cubeEnable[i] = 0 + } + } + +- //Check frame buffer state +- var status = gl.checkFramebufferStatus(gl.FRAMEBUFFER) +- if(status !== gl.FRAMEBUFFER_COMPLETE) { ++ this._background.draw( ++ model, ++ view, ++ projection, ++ bounds, ++ cubeEnable, ++ this.backgroundColor) + +- //Release all partially allocated resources +- fbo._destroyed = true ++ //Draw lines ++ this._lines.bind( ++ model, ++ view, ++ projection, ++ this) + +- //Release all resources +- gl.bindFramebuffer(gl.FRAMEBUFFER, null) +- gl.deleteFramebuffer(fbo.handle) +- fbo.handle = null +- if(fbo.depth) { +- fbo.depth.dispose() +- fbo.depth = null ++ //First draw grid lines and zero lines ++ for(var i=0; i<3; ++i) { ++ var x = [0,0,0] ++ if(cubeAxis[i] > 0) { ++ x[i] = bounds[1][i] ++ } else { ++ x[i] = bounds[0][i] + } +- if(fbo._depth_rb) { +- gl.deleteRenderbuffer(fbo._depth_rb) +- fbo._depth_rb = null ++ ++ //Draw grid lines ++ for(var j=0; j<2; ++j) { ++ var u = (i + 1 + j) % 3 ++ var v = (i + 1 + (j^1)) % 3 ++ if(this.gridEnable[u]) { ++ this._lines.drawGrid(u, v, this.bounds, x, this.gridColor[u], this.gridWidth[u]*this.pixelRatio) ++ } + } +- for(var i=0; i= 0) { ++ this._lines.drawZero(u, v, this.bounds, x, this.zeroLineColor[v], this.zeroLineWidth[v]*this.pixelRatio) ++ } ++ } + } +- if(fbo._color_rb) { +- gl.deleteRenderbuffer(fbo._color_rb) +- fbo._color_rb = null ++ } ++ ++ //Then draw axis lines and tick marks ++ for(var i=0; i<3; ++i) { ++ ++ //Draw axis lines ++ if(this.lineEnable[i]) { ++ this._lines.drawAxisLine(i, this.bounds, lineOffset[i].primalOffset, this.lineColor[i], this.lineWidth[i]*this.pixelRatio) ++ } ++ if(this.lineMirror[i]) { ++ this._lines.drawAxisLine(i, this.bounds, lineOffset[i].mirrorOffset, this.lineColor[i], this.lineWidth[i]*this.pixelRatio) + } + +- restoreFBOState(gl, state) ++ //Compute minor axes ++ var primalMinor = copyVec3(PRIMAL_MINOR, lineOffset[i].primalMinor) ++ var mirrorMinor = copyVec3(MIRROR_MINOR, lineOffset[i].mirrorMinor) ++ var tickLength = this.lineTickLength ++ var op = 0 ++ for(var j=0; j<3; ++j) { ++ var scaleFactor = pixelScaleF / model[5*j] ++ primalMinor[j] *= tickLength[j] * scaleFactor ++ mirrorMinor[j] *= tickLength[j] * scaleFactor ++ } + +- //Throw the frame buffer error +- throwFBOError(status) ++ //Draw axis line ticks ++ if(this.lineTickEnable[i]) { ++ this._lines.drawAxisTicks(i, lineOffset[i].primalOffset, primalMinor, this.lineTickColor[i], this.lineTickWidth[i]*this.pixelRatio) ++ } ++ if(this.lineTickMirror[i]) { ++ this._lines.drawAxisTicks(i, lineOffset[i].mirrorOffset, mirrorMinor, this.lineTickColor[i], this.lineTickWidth[i]*this.pixelRatio) ++ } + } + +- //Everything ok, let's get on with life +- restoreFBOState(gl, state) +-} ++ //Draw text sprites ++ this._text.bind( ++ model, ++ view, ++ projection, ++ this.pixelRatio) + +-function Framebuffer(gl, width, height, colorType, numColors, useDepth, useStencil, ext) { ++ for(var i=0; i<3; ++i) { + +- //Handle and set properties +- this.gl = gl +- this._shape = [width|0, height|0] +- this._destroyed = false +- this._ext = ext ++ var minor = lineOffset[i].primalMinor ++ var offset = copyVec3(PRIMAL_OFFSET, lineOffset[i].primalOffset) + +- //Allocate buffers +- this.color = new Array(numColors) +- for(var i=0; i maxFBOSize || +- h < 0 || h > maxFBOSize) { +- throw new Error('gl-fbo: Can\'t resize FBO, invalid dimensions') ++ gl.enable(gl.POLYGON_OFFSET_FILL) ++ gl.polygonOffset(1, 2) ++ ++ this.shader.bind() ++ this.shader.uniforms = { ++ model: model, ++ view: view, ++ projection: projection, ++ bounds: bounds, ++ enable: enable, ++ colors: colors + } ++ this.vao.bind() ++ this.vao.draw(this.gl.TRIANGLES, 36) + +- //Update shape +- fbo._shape[0] = w +- fbo._shape[1] = h ++ gl.disable(gl.POLYGON_OFFSET_FILL) ++} + +- //Save framebuffer state +- var state = saveFBOState(gl) ++proto.dispose = function() { ++ this.vao.dispose() ++ this.buffer.dispose() ++ this.shader.dispose() ++} + +- //Resize framebuffer attachments +- for(var i=0; i maxFBOSize || height < 0 || height > maxFBOSize) { +- throw new Error('gl-fbo: Parameters are too large for FBO') ++ if(closest < 0) { ++ closest = 0 ++ for(var d=0; d<3; ++d) { ++ var u = (d+2) % 3 ++ var v = (d+1) % 3 ++ var o0 = -1 ++ var o1 = -1 ++ for(var s=0; s<2; ++s) { ++ var f0 = (s< o0) { ++ closest |= 1< o0) { ++ closest |= 1< 1) { +- //Check if multiple render targets supported +- if(!WEBGL_draw_buffers) { +- throw new Error('gl-fbo: Multiple draw buffer extension not supported') +- } else if(numColors > gl.getParameter(WEBGL_draw_buffers.MAX_COLOR_ATTACHMENTS_WEBGL)) { +- throw new Error('gl-fbo: Context does not support ' + numColors + ' draw buffers') +- } ++ if(bottom < 0) { ++ bottom = i ++ } else if(cubeVerts[bottom][1] > cubeVerts[i][1]) { ++ bottom = i + } + } + +- //Determine whether to use floating point textures +- var colorType = gl.UNSIGNED_BYTE +- var OES_texture_float = gl.getExtension('OES_texture_float') +- if(options.float && numColors > 0) { +- if(!OES_texture_float) { +- throw new Error('gl-fbo: Context does not support floating point textures') ++ //Find left/right neighbors of bottom vertex ++ var left = -1 ++ for(var i=0; i<3; ++i) { ++ var idx = bottom ^ (1< 0) { +- if(OES_texture_float) { +- colorType = gl.FLOAT ++ if(left < 0) { ++ left = idx ++ } ++ var v = cubeVerts[idx] ++ if(v[0] < cubeVerts[left][0]) { ++ left = idx + } + } +- +- //Check if we should use depth buffer +- var useDepth = true +- if('depth' in options) { +- useDepth = !!options.depth ++ var right = -1 ++ for(var i=0; i<3; ++i) { ++ var idx = bottom ^ (1< cubeVerts[right][0]) { ++ right = idx ++ } + } + +- //Check if we should use a stencil buffer +- var useStencil = false +- if('stencil' in options) { +- useStencil = !!options.stencil ++ //Determine edge axis coordinates ++ var cubeEdges = CUBE_EDGES ++ cubeEdges[0] = cubeEdges[1] = cubeEdges[2] = 0 ++ cubeEdges[bits.log2(left^bottom)] = bottom&left ++ cubeEdges[bits.log2(bottom^right)] = bottom&right ++ var top = right ^ 7 ++ if(top === closest || top === farthest) { ++ top = left ^ 7 ++ cubeEdges[bits.log2(right^top)] = top&right ++ } else { ++ cubeEdges[bits.log2(left^top)] = top&left + } + +- return new Framebuffer( +- gl, +- width, +- height, +- colorType, +- numColors, +- useDepth, +- useStencil, +- WEBGL_draw_buffers) +-} +- +-},{"gl-texture2d":188}],109:[function(require,module,exports){ +- +-var createShader = require('gl-shader') +- +-var vertSrc = "precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position, nextPosition;\nattribute float arcLength, lineWidth;\nattribute vec4 color;\n\nuniform vec2 screenShape;\nuniform float pixelRatio;\nuniform mat4 model, view, projection;\n\nvarying vec4 fragColor;\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\n\nvoid main() {\n vec4 projected = projection * view * model * vec4(position, 1.0);\n vec4 tangentClip = projection * view * model * vec4(nextPosition - position, 0.0);\n vec2 tangent = normalize(screenShape * tangentClip.xy);\n vec2 offset = 0.5 * pixelRatio * lineWidth * vec2(tangent.y, -tangent.x) / screenShape;\n\n gl_Position = vec4(projected.xy + projected.w * offset, projected.zw);\n\n worldPosition = position;\n pixelArcLength = arcLength;\n fragColor = color;\n}\n" +-var forwardFrag = "precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 clipBounds[2];\nuniform sampler2D dashTexture;\nuniform float dashScale;\nuniform float opacity;\n\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\nvarying vec4 fragColor;\n\nvoid main() {\n if(any(lessThan(worldPosition, clipBounds[0])) || any(greaterThan(worldPosition, clipBounds[1]))) {\n discard;\n }\n float dashWeight = texture2D(dashTexture, vec2(dashScale * pixelArcLength, 0)).r;\n if(dashWeight < 0.5) {\n discard;\n }\n gl_FragColor = fragColor * opacity;\n}\n" +-var pickFrag = "precision mediump float;\n#define GLSLIFY 1\n\n#define FLOAT_MAX 1.70141184e38\n#define FLOAT_MIN 1.17549435e-38\n\nlowp vec4 encode_float_1_0(highp float v) {\n highp float av = abs(v);\n\n //Handle special cases\n if(av < FLOAT_MIN) {\n return vec4(0.0, 0.0, 0.0, 0.0);\n } else if(v > FLOAT_MAX) {\n return vec4(127.0, 128.0, 0.0, 0.0) / 255.0;\n } else if(v < -FLOAT_MAX) {\n return vec4(255.0, 128.0, 0.0, 0.0) / 255.0;\n }\n\n highp vec4 c = vec4(0,0,0,0);\n\n //Compute exponent and mantissa\n highp float e = floor(log2(av));\n highp float m = av * pow(2.0, -e) - 1.0;\n \n //Unpack mantissa\n c[1] = floor(128.0 * m);\n m -= c[1] / 128.0;\n c[2] = floor(32768.0 * m);\n m -= c[2] / 32768.0;\n c[3] = floor(8388608.0 * m);\n \n //Unpack exponent\n highp float ebias = e + 127.0;\n c[0] = floor(ebias / 2.0);\n ebias -= c[0] * 2.0;\n c[1] += floor(ebias) * 128.0; \n\n //Unpack sign bit\n c[0] += 128.0 * step(0.0, -v);\n\n //Scale back to range\n return c / 255.0;\n}\n\n\n\nuniform float pickId;\nuniform vec3 clipBounds[2];\n\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\nvarying vec4 fragColor;\n\nvoid main() {\n if(any(lessThan(worldPosition, clipBounds[0])) || any(greaterThan(worldPosition, clipBounds[1]))) {\n discard;\n }\n gl_FragColor = vec4(pickId/255.0, encode_float_1_0(pixelArcLength).xyz);\n}" +- +-var ATTRIBUTES = [ +- {name: 'position', type: 'vec3'}, +- {name: 'nextPosition', type: 'vec3'}, +- {name: 'arcLength', type: 'float'}, +- {name: 'lineWidth', type: 'float'}, +- {name: 'color', type: 'vec4'} +-] +- +-exports.createShader = function(gl) { +- return createShader(gl, vertSrc, forwardFrag, null, ATTRIBUTES) +-} ++ //Determine visible faces ++ var axis = CUBE_AXIS ++ var cutCorner = closest ++ for(var d=0; d<3; ++d) { ++ if(cutCorner & (1<= 1 ++ this.shader.uniforms.screenShape = SHAPE ++ this.vao.bind() + } + +-proto.pickSlots = 1 +- +-proto.setPickBase = function (id) { +- this.pickId = id +-} ++proto.drawAxisLine = function(j, bounds, offset, color, lineWidth) { ++ var minorAxis = zeroVec(MINOR_AXIS) ++ this.shader.uniforms.majorAxis = MINOR_AXIS + +-proto.drawTransparent = proto.draw = function (camera) { +- var gl = this.gl +- var shader = this.shader +- var vao = this.vao +- shader.bind() +- shader.uniforms = { +- model: camera.model || identity, +- view: camera.view || identity, +- projection: camera.projection || identity, +- clipBounds: filterClipBounds(this.clipBounds), +- dashTexture: this.texture.bind(), +- dashScale: this.dashScale / this.arcLength[this.arcLength.length - 1], +- opacity: this.opacity, +- screenShape: [gl.drawingBufferWidth, gl.drawingBufferHeight], +- pixelRatio: this.pixelRatio +- } +- vao.bind() +- vao.draw(gl.TRIANGLE_STRIP, this.vertexCount) +-} ++ minorAxis[j] = bounds[1][j] - bounds[0][j] ++ this.shader.uniforms.minorAxis = minorAxis + +-proto.drawPick = function (camera) { +- var gl = this.gl +- var shader = this.pickShader +- var vao = this.vao +- shader.bind() +- shader.uniforms = { +- model: camera.model || identity, +- view: camera.view || identity, +- projection: camera.projection || identity, +- pickId: this.pickId, +- clipBounds: filterClipBounds(this.clipBounds), +- screenShape: [gl.drawingBufferWidth, gl.drawingBufferHeight], +- pixelRatio: this.pixelRatio +- } +- vao.bind() +- vao.draw(gl.TRIANGLE_STRIP, this.vertexCount) +-} ++ var noffset = copyVec(OFFSET_VEC, offset) ++ noffset[j] += bounds[0][j] ++ this.shader.uniforms.offset = noffset + +-proto.update = function (options) { +- var i, j ++ this.shader.uniforms.lineWidth = lineWidth + +- this.dirty = true ++ this.shader.uniforms.color = color + +- var connectGaps = !!options.connectGaps ++ var screenAxis = zeroVec(SCREEN_AXIS) ++ screenAxis[(j+2)%3] = 1 ++ this.shader.uniforms.screenAxis = screenAxis ++ this.vao.draw(this.gl.TRIANGLES, 6) + +- if ('dashScale' in options) { +- this.dashScale = options.dashScale +- } +- if ('opacity' in options) { +- this.opacity = +options.opacity +- } ++ var screenAxis = zeroVec(SCREEN_AXIS) ++ screenAxis[(j+1)%3] = 1 ++ this.shader.uniforms.screenAxis = screenAxis ++ this.vao.draw(this.gl.TRIANGLES, 6) ++} + +- var positions = options.position || options.positions +- if (!positions) { ++proto.drawAxisTicks = function(j, offset, minorAxis, color, lineWidth) { ++ if(!this.tickCount[j]) { + return + } + +- // Default color +- var colors = options.color || options.colors || [0, 0, 0, 1] +- +- var lineWidth = options.lineWidth || 1 ++ var majorAxis = zeroVec(MAJOR_AXIS) ++ majorAxis[j] = 1 ++ this.shader.uniforms.majorAxis = majorAxis ++ this.shader.uniforms.offset = offset ++ this.shader.uniforms.minorAxis = minorAxis ++ this.shader.uniforms.color = color ++ this.shader.uniforms.lineWidth = lineWidth + +- // Recalculate buffer data +- var buffer = [] +- var arcLengthArray = [] +- var pointArray = [] +- var arcLength = 0.0 +- var vertexCount = 0 +- var bounds = [ +- [ Infinity, Infinity, Infinity ], +- [ -Infinity, -Infinity, -Infinity ]] +- var hadGap = false ++ var screenAxis = zeroVec(SCREEN_AXIS) ++ screenAxis[j] = 1 ++ this.shader.uniforms.screenAxis = screenAxis ++ this.vao.draw(this.gl.TRIANGLES, this.tickCount[j], this.tickOffset[j]) ++} + +- fill_loop: +- for (i = 1; i < positions.length; ++i) { +- var a = positions[i - 1] +- var b = positions[i] + +- arcLengthArray.push(arcLength) +- pointArray.push(a.slice()) ++proto.drawGrid = function(i, j, bounds, offset, color, lineWidth) { ++ if(!this.gridCount[i]) { ++ return ++ } + +- for (j = 0; j < 3; ++j) { +- if (isNaN(a[j]) || isNaN(b[j]) || +- !isFinite(a[j]) || !isFinite(b[j])) { ++ var minorAxis = zeroVec(MINOR_AXIS) ++ minorAxis[j] = bounds[1][j] - bounds[0][j] ++ this.shader.uniforms.minorAxis = minorAxis + +- if (!connectGaps && buffer.length > 0) { +- for (var k = 0; k < 24; ++k) { +- buffer.push(buffer[buffer.length - 12]) +- } +- vertexCount += 2 +- hadGap = true +- } ++ var noffset = copyVec(OFFSET_VEC, offset) ++ noffset[j] += bounds[0][j] ++ this.shader.uniforms.offset = noffset + +- continue fill_loop +- } +- bounds[0][j] = Math.min(bounds[0][j], a[j], b[j]) +- bounds[1][j] = Math.max(bounds[1][j], a[j], b[j]) +- } ++ var majorAxis = zeroVec(MAJOR_AXIS) ++ majorAxis[i] = 1 ++ this.shader.uniforms.majorAxis = majorAxis + +- var acolor, bcolor +- if (Array.isArray(colors[0])) { +- acolor = colors[i - 1] +- bcolor = colors[i] +- } else { +- acolor = bcolor = colors +- } +- if (acolor.length === 3) { +- acolor = [acolor[0], acolor[1], acolor[2], 1] +- } +- if (bcolor.length === 3) { +- bcolor = [bcolor[0], bcolor[1], bcolor[2], 1] +- } ++ var screenAxis = zeroVec(SCREEN_AXIS) ++ screenAxis[i] = 1 ++ this.shader.uniforms.screenAxis = screenAxis ++ this.shader.uniforms.lineWidth = lineWidth + +- var w0 +- if (Array.isArray(lineWidth)) { +- w0 = lineWidth[i - 1] +- } else { +- w0 = lineWidth +- } ++ this.shader.uniforms.color = color ++ this.vao.draw(this.gl.TRIANGLES, this.gridCount[i], this.gridOffset[i]) ++} + +- var t0 = arcLength +- arcLength += distance(a, b) ++proto.drawZero = function(j, i, bounds, offset, color, lineWidth) { ++ var minorAxis = zeroVec(MINOR_AXIS) ++ this.shader.uniforms.majorAxis = minorAxis + +- if (hadGap) { +- for (j = 0; j < 2; ++j) { +- buffer.push( +- a[0], a[1], a[2], b[0], b[1], b[2], t0, w0, acolor[0], acolor[1], acolor[2], acolor[3]) +- } +- vertexCount += 2 +- hadGap = false +- } ++ minorAxis[j] = bounds[1][j] - bounds[0][j] ++ this.shader.uniforms.minorAxis = minorAxis + +- buffer.push( +- a[0], a[1], a[2], b[0], b[1], b[2], t0, w0, acolor[0], acolor[1], acolor[2], acolor[3], +- a[0], a[1], a[2], b[0], b[1], b[2], t0, -w0, acolor[0], acolor[1], acolor[2], acolor[3], +- b[0], b[1], b[2], a[0], a[1], a[2], arcLength, -w0, bcolor[0], bcolor[1], bcolor[2], bcolor[3], +- b[0], b[1], b[2], a[0], a[1], a[2], arcLength, w0, bcolor[0], bcolor[1], bcolor[2], bcolor[3]) ++ var noffset = copyVec(OFFSET_VEC, offset) ++ noffset[j] += bounds[0][j] ++ this.shader.uniforms.offset = noffset + +- vertexCount += 4 +- } +- this.buffer.update(buffer) ++ var screenAxis = zeroVec(SCREEN_AXIS) ++ screenAxis[i] = 1 ++ this.shader.uniforms.screenAxis = screenAxis ++ this.shader.uniforms.lineWidth = lineWidth + +- arcLengthArray.push(arcLength) +- pointArray.push(positions[positions.length - 1].slice()) ++ this.shader.uniforms.color = color ++ this.vao.draw(this.gl.TRIANGLES, 6) ++} + +- this.bounds = bounds ++proto.dispose = function() { ++ this.vao.dispose() ++ this.vertBuffer.dispose() ++ this.shader.dispose() ++} + +- this.vertexCount = vertexCount ++function createLines(gl, bounds, ticks) { ++ var vertices = [] ++ var tickOffset = [0,0,0] ++ var tickCount = [0,0,0] + +- this.points = pointArray +- this.arcLength = arcLengthArray ++ //Create grid lines for each axis/direction ++ var gridOffset = [0,0,0] ++ var gridCount = [0,0,0] + +- if ('dashes' in options) { +- var dashArray = options.dashes ++ //Add zero line ++ vertices.push( ++ 0,0,1, 0,1,1, 0,0,-1, ++ 0,0,-1, 0,1,1, 0,1,-1) + +- // Calculate prefix sum +- var prefixSum = dashArray.slice() +- prefixSum.unshift(0) +- for (i = 1; i < prefixSum.length; ++i) { +- prefixSum[i] = prefixSum[i - 1] + prefixSum[i] ++ for(var i=0; i<3; ++i) { ++ //Axis tick marks ++ var start = ((vertices.length / 3)|0) ++ for(var j=0; j=0; --j) { ++ var p = positions[c[j]] ++ data.push(scale*p[0], -scale*p[1], t) ++ } ++ } ++ } + +-/** +- * Creates a new identity mat4 +- * +- * @returns {mat4} a new 4x4 matrix +- */ +-function create() { +- var out = new Float32Array(16); +- out[0] = 1; +- out[1] = 0; +- out[2] = 0; +- out[3] = 0; +- out[4] = 0; +- out[5] = 1; +- out[6] = 0; +- out[7] = 0; +- out[8] = 0; +- out[9] = 0; +- out[10] = 1; +- out[11] = 0; +- out[12] = 0; +- out[13] = 0; +- out[14] = 0; +- out[15] = 1; +- return out; +-}; +-},{}],116:[function(require,module,exports){ +-module.exports = determinant; ++ //Generate sprites for all 3 axes, store data in texture atlases ++ var tickOffset = [0,0,0] ++ var tickCount = [0,0,0] ++ var labelOffset = [0,0,0] ++ var labelCount = [0,0,0] ++ for(var d=0; d<3; ++d) { + +-/** +- * Calculates the determinant of a mat4 +- * +- * @param {mat4} a the source matrix +- * @returns {Number} determinant of a +- */ +-function determinant(a) { +- var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3], +- a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7], +- a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11], +- a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15], ++ //Generate label ++ labelOffset[d] = (data.length/VERTEX_SIZE)|0 ++ addItem(0.5*(bounds[0][d]+bounds[1][d]), labels[d], labelFont) ++ labelCount[d] = ((data.length/VERTEX_SIZE)|0) - labelOffset[d] + +- b00 = a00 * a11 - a01 * a10, +- b01 = a00 * a12 - a02 * a10, +- b02 = a00 * a13 - a03 * a10, +- b03 = a01 * a12 - a02 * a11, +- b04 = a01 * a13 - a03 * a11, +- b05 = a02 * a13 - a03 * a12, +- b06 = a20 * a31 - a21 * a30, +- b07 = a20 * a32 - a22 * a30, +- b08 = a20 * a33 - a23 * a30, +- b09 = a21 * a32 - a22 * a31, +- b10 = a21 * a33 - a23 * a31, +- b11 = a22 * a33 - a23 * a32; ++ //Generate sprites for tick marks ++ tickOffset[d] = (data.length/VERTEX_SIZE)|0 ++ for(var i=0; i= 0) { ++ sigFigs = stepStr.length - u - 1 ++ } ++ var shift = Math.pow(10, sigFigs) ++ var x = Math.round(spacing * i * shift) ++ var xstr = x + "" ++ if(xstr.indexOf("e") >= 0) { ++ return xstr ++ } ++ var xi = x / shift, xf = x % shift ++ if(x < 0) { ++ xi = -Math.ceil(xi)|0 ++ xf = (-xf)|0 ++ } else { ++ xi = Math.floor(xi)|0 ++ xf = xf|0 ++ } ++ var xis = "" + xi ++ if(x < 0) { ++ xis = "-" + xis ++ } ++ if(sigFigs) { ++ var xs = "" + xf ++ while(xs.length < sigFigs) { ++ xs = "0" + xs ++ } ++ return xis + "." + xs ++ } else { ++ return xis ++ } ++} + +- if (!det) { +- return null; ++function defaultTicks(bounds, tickSpacing) { ++ var array = [] ++ for(var d=0; d<3; ++d) { ++ var ticks = [] ++ var m = 0.5*(bounds[0][d]+bounds[1][d]) ++ for(var t=0; t*tickSpacing[d]<=bounds[1][d]; ++t) { ++ ticks.push({x: t*tickSpacing[d], text: prettyPrint(tickSpacing[d], t)}) + } +- det = 1.0 / det; ++ for(var t=-1; t*tickSpacing[d]>=bounds[0][d]; --t) { ++ ticks.push({x: t*tickSpacing[d], text: prettyPrint(tickSpacing[d], t)}) ++ } ++ array.push(ticks) ++ } ++ return array ++} + +- out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; +- out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det; +- out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det; +- out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det; +- out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det; +- out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det; +- out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det; +- out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det; +- out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det; +- out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det; +- out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det; +- out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det; +- out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det; +- out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det; +- out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det; +- out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det; ++function ticksEqual(ticksA, ticksB) { ++ for(var i=0; i<3; ++i) { ++ if(ticksA[i].length !== ticksB[i].length) { ++ return false ++ } ++ for(var j=0; j len) { ++ throw new Error("gl-buffer: If resizing buffer, must not specify offset") ++ } ++ gl.bufferSubData(type, offset, data) ++ return len ++} + +- if (a !== out) { // If the source and destination differ, copy the unchanged last row +- out[8] = a[8]; +- out[9] = a[9]; +- out[10] = a[10]; +- out[11] = a[11]; +- out[12] = a[12]; +- out[13] = a[13]; +- out[14] = a[14]; +- out[15] = a[15]; ++function makeScratchTypeArray(array, dtype) { ++ var res = pool.malloc(array.length, dtype) ++ var n = array.length ++ for(var i=0; i=0; --i) { ++ if(stride[i] !== n) { ++ return false ++ } ++ n *= shape[i] ++ } ++ return true ++} ++ ++proto.update = function(array, offset) { ++ if(typeof offset !== "number") { ++ offset = -1 ++ } ++ this.bind() ++ if(typeof array === "object" && typeof array.shape !== "undefined") { //ndarray ++ var dtype = array.dtype ++ if(SUPPORTED_TYPES.indexOf(dtype) < 0) { ++ dtype = "float32" ++ } ++ if(this.type === this.gl.ELEMENT_ARRAY_BUFFER) { ++ var ext = gl.getExtension('OES_element_index_uint') ++ if(ext && dtype !== "uint16") { ++ dtype = "uint32" ++ } else { ++ dtype = "uint16" ++ } ++ } ++ if(dtype === array.dtype && isPacked(array.shape, array.stride)) { ++ if(array.offset === 0 && array.data.length === array.shape[0]) { ++ this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, array.data, offset) ++ } else { ++ this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, array.data.subarray(array.offset, array.shape[0]), offset) ++ } ++ } else { ++ var tmp = pool.malloc(array.size, dtype) ++ var ndt = ndarray(tmp, array.shape) ++ ops.assign(ndt, array) ++ if(offset < 0) { ++ this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, tmp, offset) ++ } else { ++ this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, tmp.subarray(0, array.size), offset) ++ } ++ pool.free(tmp) ++ } ++ } else if(Array.isArray(array)) { //Vanilla array ++ var t ++ if(this.type === this.gl.ELEMENT_ARRAY_BUFFER) { ++ t = makeScratchTypeArray(array, "uint16") ++ } else { ++ t = makeScratchTypeArray(array, "float32") ++ } ++ if(offset < 0) { ++ this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, t, offset) ++ } else { ++ this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, t.subarray(0, array.length), offset) ++ } ++ pool.free(t) ++ } else if(typeof array === "object" && typeof array.length === "number") { //Typed array ++ this.length = updateTypeArray(this.gl, this.type, this.length, this.usage, array, offset) ++ } else if(typeof array === "number" || array === undefined) { //Number/default ++ if(offset >= 0) { ++ throw new Error("gl-buffer: Cannot specify offset when resizing buffer") + } ++ array = array | 0 ++ if(array <= 0) { ++ array = 1 ++ } ++ this.gl.bufferData(this.type, array|0, this.usage) ++ this.length = array ++ } else { //Error, case should not happen ++ throw new Error("gl-buffer: Invalid data type") ++ } ++} + +- // Perform axis-specific matrix multiplication +- out[0] = a00 * c + a10 * s; +- out[1] = a01 * c + a11 * s; +- out[2] = a02 * c + a12 * s; +- out[3] = a03 * c + a13 * s; +- out[4] = a10 * c - a00 * s; +- out[5] = a11 * c - a01 * s; +- out[6] = a12 * c - a02 * s; +- out[7] = a13 * c - a03 * s; +- return out; +-}; +-},{}],128:[function(require,module,exports){ +-module.exports = scale; ++function createBuffer(gl, data, type, usage) { ++ type = type || gl.ARRAY_BUFFER ++ usage = usage || gl.DYNAMIC_DRAW ++ if(type !== gl.ARRAY_BUFFER && type !== gl.ELEMENT_ARRAY_BUFFER) { ++ throw new Error("gl-buffer: Invalid type for webgl buffer, must be either gl.ARRAY_BUFFER or gl.ELEMENT_ARRAY_BUFFER") ++ } ++ if(usage !== gl.DYNAMIC_DRAW && usage !== gl.STATIC_DRAW && usage !== gl.STREAM_DRAW) { ++ throw new Error("gl-buffer: Invalid usage for buffer, must be either gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW") ++ } ++ var handle = gl.createBuffer() ++ var result = new GLBuffer(gl, type, handle, 0, usage) ++ result.update(data) ++ return result ++} + +-/** +- * Scales the mat4 by the dimensions in the given vec3 +- * +- * @param {mat4} out the receiving matrix +- * @param {mat4} a the matrix to scale +- * @param {vec3} v the vec3 to scale the matrix by +- * @returns {mat4} out +- **/ +-function scale(out, a, v) { +- var x = v[0], y = v[1], z = v[2]; ++module.exports = createBuffer + +- out[0] = a[0] * x; +- out[1] = a[1] * x; +- out[2] = a[2] * x; +- out[3] = a[3] * x; +- out[4] = a[4] * y; +- out[5] = a[5] * y; +- out[6] = a[6] * y; +- out[7] = a[7] * y; +- out[8] = a[8] * z; +- out[9] = a[9] * z; +- out[10] = a[10] * z; +- out[11] = a[11] * z; +- out[12] = a[12]; +- out[13] = a[13]; +- out[14] = a[14]; +- out[15] = a[15]; +- return out; +-}; +-},{}],129:[function(require,module,exports){ +-module.exports = translate; ++},{"ndarray":191,"ndarray-ops":185,"typedarray-pool":246}],95:[function(require,module,exports){ ++module.exports = { ++ 0: 'NONE', ++ 1: 'ONE', ++ 2: 'LINE_LOOP', ++ 3: 'LINE_STRIP', ++ 4: 'TRIANGLES', ++ 5: 'TRIANGLE_STRIP', ++ 6: 'TRIANGLE_FAN', ++ 256: 'DEPTH_BUFFER_BIT', ++ 512: 'NEVER', ++ 513: 'LESS', ++ 514: 'EQUAL', ++ 515: 'LEQUAL', ++ 516: 'GREATER', ++ 517: 'NOTEQUAL', ++ 518: 'GEQUAL', ++ 519: 'ALWAYS', ++ 768: 'SRC_COLOR', ++ 769: 'ONE_MINUS_SRC_COLOR', ++ 770: 'SRC_ALPHA', ++ 771: 'ONE_MINUS_SRC_ALPHA', ++ 772: 'DST_ALPHA', ++ 773: 'ONE_MINUS_DST_ALPHA', ++ 774: 'DST_COLOR', ++ 775: 'ONE_MINUS_DST_COLOR', ++ 776: 'SRC_ALPHA_SATURATE', ++ 1024: 'STENCIL_BUFFER_BIT', ++ 1028: 'FRONT', ++ 1029: 'BACK', ++ 1032: 'FRONT_AND_BACK', ++ 1280: 'INVALID_ENUM', ++ 1281: 'INVALID_VALUE', ++ 1282: 'INVALID_OPERATION', ++ 1285: 'OUT_OF_MEMORY', ++ 1286: 'INVALID_FRAMEBUFFER_OPERATION', ++ 2304: 'CW', ++ 2305: 'CCW', ++ 2849: 'LINE_WIDTH', ++ 2884: 'CULL_FACE', ++ 2885: 'CULL_FACE_MODE', ++ 2886: 'FRONT_FACE', ++ 2928: 'DEPTH_RANGE', ++ 2929: 'DEPTH_TEST', ++ 2930: 'DEPTH_WRITEMASK', ++ 2931: 'DEPTH_CLEAR_VALUE', ++ 2932: 'DEPTH_FUNC', ++ 2960: 'STENCIL_TEST', ++ 2961: 'STENCIL_CLEAR_VALUE', ++ 2962: 'STENCIL_FUNC', ++ 2963: 'STENCIL_VALUE_MASK', ++ 2964: 'STENCIL_FAIL', ++ 2965: 'STENCIL_PASS_DEPTH_FAIL', ++ 2966: 'STENCIL_PASS_DEPTH_PASS', ++ 2967: 'STENCIL_REF', ++ 2968: 'STENCIL_WRITEMASK', ++ 2978: 'VIEWPORT', ++ 3024: 'DITHER', ++ 3042: 'BLEND', ++ 3088: 'SCISSOR_BOX', ++ 3089: 'SCISSOR_TEST', ++ 3106: 'COLOR_CLEAR_VALUE', ++ 3107: 'COLOR_WRITEMASK', ++ 3317: 'UNPACK_ALIGNMENT', ++ 3333: 'PACK_ALIGNMENT', ++ 3379: 'MAX_TEXTURE_SIZE', ++ 3386: 'MAX_VIEWPORT_DIMS', ++ 3408: 'SUBPIXEL_BITS', ++ 3410: 'RED_BITS', ++ 3411: 'GREEN_BITS', ++ 3412: 'BLUE_BITS', ++ 3413: 'ALPHA_BITS', ++ 3414: 'DEPTH_BITS', ++ 3415: 'STENCIL_BITS', ++ 3553: 'TEXTURE_2D', ++ 4352: 'DONT_CARE', ++ 4353: 'FASTEST', ++ 4354: 'NICEST', ++ 5120: 'BYTE', ++ 5121: 'UNSIGNED_BYTE', ++ 5122: 'SHORT', ++ 5123: 'UNSIGNED_SHORT', ++ 5124: 'INT', ++ 5125: 'UNSIGNED_INT', ++ 5126: 'FLOAT', ++ 5386: 'INVERT', ++ 5890: 'TEXTURE', ++ 6401: 'STENCIL_INDEX', ++ 6402: 'DEPTH_COMPONENT', ++ 6406: 'ALPHA', ++ 6407: 'RGB', ++ 6408: 'RGBA', ++ 6409: 'LUMINANCE', ++ 6410: 'LUMINANCE_ALPHA', ++ 7680: 'KEEP', ++ 7681: 'REPLACE', ++ 7682: 'INCR', ++ 7683: 'DECR', ++ 7936: 'VENDOR', ++ 7937: 'RENDERER', ++ 7938: 'VERSION', ++ 9728: 'NEAREST', ++ 9729: 'LINEAR', ++ 9984: 'NEAREST_MIPMAP_NEAREST', ++ 9985: 'LINEAR_MIPMAP_NEAREST', ++ 9986: 'NEAREST_MIPMAP_LINEAR', ++ 9987: 'LINEAR_MIPMAP_LINEAR', ++ 10240: 'TEXTURE_MAG_FILTER', ++ 10241: 'TEXTURE_MIN_FILTER', ++ 10242: 'TEXTURE_WRAP_S', ++ 10243: 'TEXTURE_WRAP_T', ++ 10497: 'REPEAT', ++ 10752: 'POLYGON_OFFSET_UNITS', ++ 16384: 'COLOR_BUFFER_BIT', ++ 32769: 'CONSTANT_COLOR', ++ 32770: 'ONE_MINUS_CONSTANT_COLOR', ++ 32771: 'CONSTANT_ALPHA', ++ 32772: 'ONE_MINUS_CONSTANT_ALPHA', ++ 32773: 'BLEND_COLOR', ++ 32774: 'FUNC_ADD', ++ 32777: 'BLEND_EQUATION_RGB', ++ 32778: 'FUNC_SUBTRACT', ++ 32779: 'FUNC_REVERSE_SUBTRACT', ++ 32819: 'UNSIGNED_SHORT_4_4_4_4', ++ 32820: 'UNSIGNED_SHORT_5_5_5_1', ++ 32823: 'POLYGON_OFFSET_FILL', ++ 32824: 'POLYGON_OFFSET_FACTOR', ++ 32854: 'RGBA4', ++ 32855: 'RGB5_A1', ++ 32873: 'TEXTURE_BINDING_2D', ++ 32926: 'SAMPLE_ALPHA_TO_COVERAGE', ++ 32928: 'SAMPLE_COVERAGE', ++ 32936: 'SAMPLE_BUFFERS', ++ 32937: 'SAMPLES', ++ 32938: 'SAMPLE_COVERAGE_VALUE', ++ 32939: 'SAMPLE_COVERAGE_INVERT', ++ 32968: 'BLEND_DST_RGB', ++ 32969: 'BLEND_SRC_RGB', ++ 32970: 'BLEND_DST_ALPHA', ++ 32971: 'BLEND_SRC_ALPHA', ++ 33071: 'CLAMP_TO_EDGE', ++ 33170: 'GENERATE_MIPMAP_HINT', ++ 33189: 'DEPTH_COMPONENT16', ++ 33306: 'DEPTH_STENCIL_ATTACHMENT', ++ 33635: 'UNSIGNED_SHORT_5_6_5', ++ 33648: 'MIRRORED_REPEAT', ++ 33901: 'ALIASED_POINT_SIZE_RANGE', ++ 33902: 'ALIASED_LINE_WIDTH_RANGE', ++ 33984: 'TEXTURE0', ++ 33985: 'TEXTURE1', ++ 33986: 'TEXTURE2', ++ 33987: 'TEXTURE3', ++ 33988: 'TEXTURE4', ++ 33989: 'TEXTURE5', ++ 33990: 'TEXTURE6', ++ 33991: 'TEXTURE7', ++ 33992: 'TEXTURE8', ++ 33993: 'TEXTURE9', ++ 33994: 'TEXTURE10', ++ 33995: 'TEXTURE11', ++ 33996: 'TEXTURE12', ++ 33997: 'TEXTURE13', ++ 33998: 'TEXTURE14', ++ 33999: 'TEXTURE15', ++ 34000: 'TEXTURE16', ++ 34001: 'TEXTURE17', ++ 34002: 'TEXTURE18', ++ 34003: 'TEXTURE19', ++ 34004: 'TEXTURE20', ++ 34005: 'TEXTURE21', ++ 34006: 'TEXTURE22', ++ 34007: 'TEXTURE23', ++ 34008: 'TEXTURE24', ++ 34009: 'TEXTURE25', ++ 34010: 'TEXTURE26', ++ 34011: 'TEXTURE27', ++ 34012: 'TEXTURE28', ++ 34013: 'TEXTURE29', ++ 34014: 'TEXTURE30', ++ 34015: 'TEXTURE31', ++ 34016: 'ACTIVE_TEXTURE', ++ 34024: 'MAX_RENDERBUFFER_SIZE', ++ 34041: 'DEPTH_STENCIL', ++ 34055: 'INCR_WRAP', ++ 34056: 'DECR_WRAP', ++ 34067: 'TEXTURE_CUBE_MAP', ++ 34068: 'TEXTURE_BINDING_CUBE_MAP', ++ 34069: 'TEXTURE_CUBE_MAP_POSITIVE_X', ++ 34070: 'TEXTURE_CUBE_MAP_NEGATIVE_X', ++ 34071: 'TEXTURE_CUBE_MAP_POSITIVE_Y', ++ 34072: 'TEXTURE_CUBE_MAP_NEGATIVE_Y', ++ 34073: 'TEXTURE_CUBE_MAP_POSITIVE_Z', ++ 34074: 'TEXTURE_CUBE_MAP_NEGATIVE_Z', ++ 34076: 'MAX_CUBE_MAP_TEXTURE_SIZE', ++ 34338: 'VERTEX_ATTRIB_ARRAY_ENABLED', ++ 34339: 'VERTEX_ATTRIB_ARRAY_SIZE', ++ 34340: 'VERTEX_ATTRIB_ARRAY_STRIDE', ++ 34341: 'VERTEX_ATTRIB_ARRAY_TYPE', ++ 34342: 'CURRENT_VERTEX_ATTRIB', ++ 34373: 'VERTEX_ATTRIB_ARRAY_POINTER', ++ 34466: 'NUM_COMPRESSED_TEXTURE_FORMATS', ++ 34467: 'COMPRESSED_TEXTURE_FORMATS', ++ 34660: 'BUFFER_SIZE', ++ 34661: 'BUFFER_USAGE', ++ 34816: 'STENCIL_BACK_FUNC', ++ 34817: 'STENCIL_BACK_FAIL', ++ 34818: 'STENCIL_BACK_PASS_DEPTH_FAIL', ++ 34819: 'STENCIL_BACK_PASS_DEPTH_PASS', ++ 34877: 'BLEND_EQUATION_ALPHA', ++ 34921: 'MAX_VERTEX_ATTRIBS', ++ 34922: 'VERTEX_ATTRIB_ARRAY_NORMALIZED', ++ 34930: 'MAX_TEXTURE_IMAGE_UNITS', ++ 34962: 'ARRAY_BUFFER', ++ 34963: 'ELEMENT_ARRAY_BUFFER', ++ 34964: 'ARRAY_BUFFER_BINDING', ++ 34965: 'ELEMENT_ARRAY_BUFFER_BINDING', ++ 34975: 'VERTEX_ATTRIB_ARRAY_BUFFER_BINDING', ++ 35040: 'STREAM_DRAW', ++ 35044: 'STATIC_DRAW', ++ 35048: 'DYNAMIC_DRAW', ++ 35632: 'FRAGMENT_SHADER', ++ 35633: 'VERTEX_SHADER', ++ 35660: 'MAX_VERTEX_TEXTURE_IMAGE_UNITS', ++ 35661: 'MAX_COMBINED_TEXTURE_IMAGE_UNITS', ++ 35663: 'SHADER_TYPE', ++ 35664: 'FLOAT_VEC2', ++ 35665: 'FLOAT_VEC3', ++ 35666: 'FLOAT_VEC4', ++ 35667: 'INT_VEC2', ++ 35668: 'INT_VEC3', ++ 35669: 'INT_VEC4', ++ 35670: 'BOOL', ++ 35671: 'BOOL_VEC2', ++ 35672: 'BOOL_VEC3', ++ 35673: 'BOOL_VEC4', ++ 35674: 'FLOAT_MAT2', ++ 35675: 'FLOAT_MAT3', ++ 35676: 'FLOAT_MAT4', ++ 35678: 'SAMPLER_2D', ++ 35680: 'SAMPLER_CUBE', ++ 35712: 'DELETE_STATUS', ++ 35713: 'COMPILE_STATUS', ++ 35714: 'LINK_STATUS', ++ 35715: 'VALIDATE_STATUS', ++ 35716: 'INFO_LOG_LENGTH', ++ 35717: 'ATTACHED_SHADERS', ++ 35718: 'ACTIVE_UNIFORMS', ++ 35719: 'ACTIVE_UNIFORM_MAX_LENGTH', ++ 35720: 'SHADER_SOURCE_LENGTH', ++ 35721: 'ACTIVE_ATTRIBUTES', ++ 35722: 'ACTIVE_ATTRIBUTE_MAX_LENGTH', ++ 35724: 'SHADING_LANGUAGE_VERSION', ++ 35725: 'CURRENT_PROGRAM', ++ 36003: 'STENCIL_BACK_REF', ++ 36004: 'STENCIL_BACK_VALUE_MASK', ++ 36005: 'STENCIL_BACK_WRITEMASK', ++ 36006: 'FRAMEBUFFER_BINDING', ++ 36007: 'RENDERBUFFER_BINDING', ++ 36048: 'FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE', ++ 36049: 'FRAMEBUFFER_ATTACHMENT_OBJECT_NAME', ++ 36050: 'FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL', ++ 36051: 'FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE', ++ 36053: 'FRAMEBUFFER_COMPLETE', ++ 36054: 'FRAMEBUFFER_INCOMPLETE_ATTACHMENT', ++ 36055: 'FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT', ++ 36057: 'FRAMEBUFFER_INCOMPLETE_DIMENSIONS', ++ 36061: 'FRAMEBUFFER_UNSUPPORTED', ++ 36064: 'COLOR_ATTACHMENT0', ++ 36096: 'DEPTH_ATTACHMENT', ++ 36128: 'STENCIL_ATTACHMENT', ++ 36160: 'FRAMEBUFFER', ++ 36161: 'RENDERBUFFER', ++ 36162: 'RENDERBUFFER_WIDTH', ++ 36163: 'RENDERBUFFER_HEIGHT', ++ 36164: 'RENDERBUFFER_INTERNAL_FORMAT', ++ 36168: 'STENCIL_INDEX8', ++ 36176: 'RENDERBUFFER_RED_SIZE', ++ 36177: 'RENDERBUFFER_GREEN_SIZE', ++ 36178: 'RENDERBUFFER_BLUE_SIZE', ++ 36179: 'RENDERBUFFER_ALPHA_SIZE', ++ 36180: 'RENDERBUFFER_DEPTH_SIZE', ++ 36181: 'RENDERBUFFER_STENCIL_SIZE', ++ 36194: 'RGB565', ++ 36336: 'LOW_FLOAT', ++ 36337: 'MEDIUM_FLOAT', ++ 36338: 'HIGH_FLOAT', ++ 36339: 'LOW_INT', ++ 36340: 'MEDIUM_INT', ++ 36341: 'HIGH_INT', ++ 36346: 'SHADER_COMPILER', ++ 36347: 'MAX_VERTEX_UNIFORM_VECTORS', ++ 36348: 'MAX_VARYING_VECTORS', ++ 36349: 'MAX_FRAGMENT_UNIFORM_VECTORS', ++ 37440: 'UNPACK_FLIP_Y_WEBGL', ++ 37441: 'UNPACK_PREMULTIPLY_ALPHA_WEBGL', ++ 37442: 'CONTEXT_LOST_WEBGL', ++ 37443: 'UNPACK_COLORSPACE_CONVERSION_WEBGL', ++ 37444: 'BROWSER_DEFAULT_WEBGL' ++} + +-/** +- * Translate a mat4 by the given vector +- * +- * @param {mat4} out the receiving matrix +- * @param {mat4} a the matrix to translate +- * @param {vec3} v vector to translate by +- * @returns {mat4} out +- */ +-function translate(out, a, v) { +- var x = v[0], y = v[1], z = v[2], +- a00, a01, a02, a03, +- a10, a11, a12, a13, +- a20, a21, a22, a23; ++},{}],96:[function(require,module,exports){ ++var gl10 = require('./1.0/numbers') + +- if (a === out) { +- out[12] = a[0] * x + a[4] * y + a[8] * z + a[12]; +- out[13] = a[1] * x + a[5] * y + a[9] * z + a[13]; +- out[14] = a[2] * x + a[6] * y + a[10] * z + a[14]; +- out[15] = a[3] * x + a[7] * y + a[11] * z + a[15]; +- } else { +- a00 = a[0]; a01 = a[1]; a02 = a[2]; a03 = a[3]; +- a10 = a[4]; a11 = a[5]; a12 = a[6]; a13 = a[7]; +- a20 = a[8]; a21 = a[9]; a22 = a[10]; a23 = a[11]; ++module.exports = function lookupConstant (number) { ++ return gl10[number] ++} + +- out[0] = a00; out[1] = a01; out[2] = a02; out[3] = a03; +- out[4] = a10; out[5] = a11; out[6] = a12; out[7] = a13; +- out[8] = a20; out[9] = a21; out[10] = a22; out[11] = a23; ++},{"./1.0/numbers":95}],97:[function(require,module,exports){ ++'use strict' + +- out[12] = a00 * x + a10 * y + a20 * z + a[12]; +- out[13] = a01 * x + a11 * y + a21 * z + a[13]; +- out[14] = a02 * x + a12 * y + a22 * z + a[14]; +- out[15] = a03 * x + a13 * y + a23 * z + a[15]; +- } ++module.exports = createErrorBars + +- return out; +-}; +-},{}],130:[function(require,module,exports){ +-module.exports = transpose; ++var createBuffer = require('gl-buffer') ++var createVAO = require('gl-vao') ++var createShader = require('./shaders/index') + +-/** +- * Transpose the values of a mat4 +- * +- * @param {mat4} out the receiving matrix +- * @param {mat4} a the source matrix +- * @returns {mat4} out +- */ +-function transpose(out, a) { +- // If we are transposing ourselves we can skip a few steps but have to cache some values +- if (out === a) { +- var a01 = a[1], a02 = a[2], a03 = a[3], +- a12 = a[6], a13 = a[7], +- a23 = a[11]; ++var IDENTITY = [1,0,0,0, ++ 0,1,0,0, ++ 0,0,1,0, ++ 0,0,0,1] + +- out[1] = a[4]; +- out[2] = a[8]; +- out[3] = a[12]; +- out[4] = a01; +- out[6] = a[9]; +- out[7] = a[13]; +- out[8] = a02; +- out[9] = a12; +- out[11] = a[14]; +- out[12] = a03; +- out[13] = a13; +- out[14] = a23; +- } else { +- out[0] = a[0]; +- out[1] = a[4]; +- out[2] = a[8]; +- out[3] = a[12]; +- out[4] = a[1]; +- out[5] = a[5]; +- out[6] = a[9]; +- out[7] = a[13]; +- out[8] = a[2]; +- out[9] = a[6]; +- out[10] = a[10]; +- out[11] = a[14]; +- out[12] = a[3]; +- out[13] = a[7]; +- out[14] = a[11]; +- out[15] = a[15]; +- } +- +- return out; +-}; +-},{}],131:[function(require,module,exports){ +-'use strict' ++function ErrorBars(gl, buffer, vao, shader) { ++ this.gl = gl ++ this.shader = shader ++ this.buffer = buffer ++ this.vao = vao ++ this.pixelRatio = 1 ++ this.bounds = [[ Infinity, Infinity, Infinity], [-Infinity,-Infinity,-Infinity]] ++ this.clipBounds = [[-Infinity,-Infinity,-Infinity], [ Infinity, Infinity, Infinity]] ++ this.lineWidth = [1,1,1] ++ this.capSize = [10,10,10] ++ this.lineCount = [0,0,0] ++ this.lineOffset = [0,0,0] ++ this.opacity = 1 ++} + +-var barycentric = require('barycentric') +-var closestPointToTriangle = require('polytope-closest-point/lib/closest_point_2d.js') ++var proto = ErrorBars.prototype + +-module.exports = closestPointToPickLocation ++proto.isOpaque = function() { ++ return this.opacity >= 1 ++} + +-function xformMatrix(m, v) { +- var out = [0,0,0,0] +- for(var i=0; i<4; ++i) { +- for(var j=0; j<4; ++j) { +- out[j] += m[4*i + j] * v[i] +- } +- } +- return out ++proto.isTransparent = function() { ++ return this.opacity < 1 + } + +-function projectVertex(v, model, view, projection, resolution) { +- var p = xformMatrix(projection, +- xformMatrix(view, +- xformMatrix(model, [v[0], v[1], v[2], 1]))) ++proto.drawTransparent = proto.draw = function(cameraParams) { ++ var gl = this.gl ++ var uniforms = this.shader.uniforms ++ ++ this.shader.bind() ++ var view = uniforms.view = cameraParams.view || IDENTITY ++ var projection = uniforms.projection = cameraParams.projection || IDENTITY ++ uniforms.model = cameraParams.model || IDENTITY ++ uniforms.clipBounds = this.clipBounds ++ uniforms.opacity = this.opacity ++ ++ ++ var cx = view[12] ++ var cy = view[13] ++ var cz = view[14] ++ var cw = view[15] ++ var pixelScaleF = this.pixelRatio * (projection[3]*cx + projection[7]*cy + projection[11]*cz + projection[15]*cw) / gl.drawingBufferHeight ++ ++ ++ this.vao.bind() + for(var i=0; i<3; ++i) { +- p[i] /= p[3] ++ gl.lineWidth(this.lineWidth[i]) ++ uniforms.capSize = this.capSize[i] * pixelScaleF ++ gl.drawArrays(gl.LINES, this.lineOffset[i], this.lineCount[i]) + } +- return [ 0.5 * resolution[0] * (1.0+p[0]), 0.5 * resolution[1] * (1.0-p[1]) ] ++ this.vao.unbind() + } + +-function barycentricCoord(simplex, point) { +- if(simplex.length === 2) { +- var d0 = 0.0 +- var d1 = 0.0 +- for(var i=0; i<2; ++i) { +- d0 += Math.pow(point[i] - simplex[0][i], 2) +- d1 += Math.pow(point[i] - simplex[1][i], 2) +- } +- d0 = Math.sqrt(d0) +- d1 = Math.sqrt(d1) +- if(d0+d1 < 1e-6) { +- return [1,0] +- } +- return [d1/(d0+d1),d0/(d1+d0)] +- } else if(simplex.length === 3) { +- var closestPoint = [0,0] +- closestPointToTriangle(simplex[0], simplex[1], simplex[2], point, closestPoint) +- return barycentric(simplex, closestPoint) ++function updateBounds(bounds, point) { ++ for(var i=0; i<3; ++i) { ++ bounds[0][i] = Math.min(bounds[0][i], point[i]) ++ bounds[1][i] = Math.max(bounds[1][i], point[i]) + } +- return [] + } + +-function interpolate(simplex, weights) { +- var result = [0,0,0] +- for(var i=0; i 1.0001) { +- return null ++ if('capSize' in options) { ++ this.capSize = options.capSize ++ if(!Array.isArray(this.capSize)) { ++ this.capSize = [this.capSize, this.capSize, this.capSize] + } +- s += weights[i] + } +- if(Math.abs(s - 1.0) > 0.001) { +- return null ++ if('opacity' in options) { ++ this.opacity = options.opacity + } +- return [closestIndex, interpolate(simplex, weights), weights] +-} +-},{"barycentric":134,"polytope-closest-point/lib/closest_point_2d.js":136}],132:[function(require,module,exports){ + ++ var color = options.color || [[0,0,0],[0,0,0],[0,0,0]] ++ var position = options.position ++ var error = options.error ++ if(!Array.isArray(color[0])) { ++ color = [color,color,color] ++ } + +-var triVertSrc = "precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position, normal;\nattribute vec4 color;\nattribute vec2 uv;\n\nuniform mat4 model\n , view\n , projection;\nuniform vec3 eyePosition\n , lightPosition;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n vec4 m_position = model * vec4(position, 1.0);\n vec4 t_position = view * m_position;\n gl_Position = projection * t_position;\n f_color = color;\n f_normal = normal;\n f_data = position;\n f_eyeDirection = eyePosition - position;\n f_lightDirection = lightPosition - position;\n f_uv = uv;\n}" +-var triFragSrc = "precision mediump float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution_2_0(float x, float roughness) {\n float NdotH = max(x, 0.0001);\n float cos2Alpha = NdotH * NdotH;\n float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha;\n float roughness2 = roughness * roughness;\n float denom = 3.141592653589793 * roughness2 * cos2Alpha * cos2Alpha;\n return exp(tan2Alpha / roughness2) / denom;\n}\n\n\n\nfloat cookTorranceSpecular_1_1(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness,\n float fresnel) {\n\n float VdotN = max(dot(viewDirection, surfaceNormal), 0.0);\n float LdotN = max(dot(lightDirection, surfaceNormal), 0.0);\n\n //Half angle vector\n vec3 H = normalize(lightDirection + viewDirection);\n\n //Geometric term\n float NdotH = max(dot(surfaceNormal, H), 0.0);\n float VdotH = max(dot(viewDirection, H), 0.000001);\n float LdotH = max(dot(lightDirection, H), 0.000001);\n float G1 = (2.0 * NdotH * VdotN) / VdotH;\n float G2 = (2.0 * NdotH * LdotN) / LdotH;\n float G = min(1.0, min(G1, G2));\n \n //Distribution term\n float D = beckmannDistribution_2_0(NdotH, roughness);\n\n //Fresnel term\n float F = pow(1.0 - VdotN, fresnel);\n\n //Multiply terms and done\n return G * F * D / max(3.14159265 * VdotN, 0.000001);\n}\n\n\n\nuniform vec3 clipBounds[2];\nuniform float roughness\n , fresnel\n , kambient\n , kdiffuse\n , kspecular\n , opacity;\nuniform sampler2D texture;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n if(any(lessThan(f_data, clipBounds[0])) || \n any(greaterThan(f_data, clipBounds[1]))) {\n discard;\n }\n\n vec3 N = normalize(f_normal);\n vec3 L = normalize(f_lightDirection);\n vec3 V = normalize(f_eyeDirection);\n \n if(!gl_FrontFacing) {\n N = -N;\n }\n\n float specular = cookTorranceSpecular_1_1(L, V, N, roughness, fresnel);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = f_color * texture2D(texture, f_uv);\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = litColor * opacity;\n}" +-var edgeVertSrc = "precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 uv;\n\nuniform mat4 model, view, projection;\n\nvarying vec4 f_color;\nvarying vec3 f_data;\nvarying vec2 f_uv;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n f_color = color;\n f_data = position;\n f_uv = uv;\n}" +-var edgeFragSrc = "precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 clipBounds[2];\nuniform sampler2D texture;\nuniform float opacity;\n\nvarying vec4 f_color;\nvarying vec3 f_data;\nvarying vec2 f_uv;\n\nvoid main() {\n if(any(lessThan(f_data, clipBounds[0])) || \n any(greaterThan(f_data, clipBounds[1]))) {\n discard;\n }\n\n gl_FragColor = f_color * texture2D(texture, f_uv) * opacity;\n}" +-var pointVertSrc = "precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 uv;\nattribute float pointSize;\n\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n if(any(lessThan(position, clipBounds[0])) || \n any(greaterThan(position, clipBounds[1]))) {\n gl_Position = vec4(0,0,0,0);\n } else {\n gl_Position = projection * view * model * vec4(position, 1.0);\n }\n gl_PointSize = pointSize;\n f_color = color;\n f_uv = uv;\n}" +-var pointFragSrc = "precision mediump float;\n#define GLSLIFY 1\n\nuniform sampler2D texture;\nuniform float opacity;\n\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n vec2 pointR = gl_PointCoord.xy - vec2(0.5,0.5);\n if(dot(pointR, pointR) > 0.25) {\n discard;\n }\n gl_FragColor = f_color * texture2D(texture, f_uv) * opacity;\n}" +-var pickVertSrc = "precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n f_id = id;\n f_position = position;\n}" +-var pickFragSrc = "precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if(any(lessThan(f_position, clipBounds[0])) || \n any(greaterThan(f_position, clipBounds[1]))) {\n discard;\n }\n gl_FragColor = vec4(pickId, f_id.xyz);\n}" +-var pickPointVertSrc = "precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute float pointSize;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if(any(lessThan(position, clipBounds[0])) || \n any(greaterThan(position, clipBounds[1]))) {\n gl_Position = vec4(0,0,0,0);\n } else {\n gl_Position = projection * view * model * vec4(position, 1.0);\n gl_PointSize = pointSize;\n }\n f_id = id;\n f_position = position;\n}" +-var contourVertSrc = "precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\n\nuniform mat4 model, view, projection;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n}" +-var contourFragSrc = "precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 contourColor;\n\nvoid main() {\n gl_FragColor = vec4(contourColor,1);\n}\n" ++ if(position && error) { + +-exports.meshShader = { +- vertex: triVertSrc, +- fragment: triFragSrc, +- attributes: [ +- {name: 'position', type: 'vec3'}, +- {name: 'normal', type: 'vec3'}, +- {name: 'color', type: 'vec4'}, +- {name: 'uv', type: 'vec2'} +- ] +-} +-exports.wireShader = { +- vertex: edgeVertSrc, +- fragment: edgeFragSrc, +- attributes: [ +- {name: 'position', type: 'vec3'}, +- {name: 'color', type: 'vec4'}, +- {name: 'uv', type: 'vec2'} +- ] ++ var verts = [] ++ var n = position.length ++ var vertexCount = 0 ++ this.bounds = [[ Infinity, Infinity, Infinity], ++ [-Infinity,-Infinity,-Infinity]] ++ this.lineCount = [0,0,0] ++ ++ //Build geometry for lines ++ for(var j=0; j<3; ++j) { ++ this.lineOffset[j] = vertexCount ++ ++i_loop: ++ for(var i=0; i 0) { ++ var x = p.slice() ++ x[j] += e[1][j] ++ verts.push(p[0], p[1], p[2], ++ c[0], c[1], c[2], c[3], ++ 0, 0, 0, ++ x[0], x[1], x[2], ++ c[0], c[1], c[2], c[3], ++ 0, 0, 0) ++ updateBounds(this.bounds, x) ++ vertexCount += 2 + emitFace(verts, x, c, j) ++ } ++ } ++ this.lineCount[j] = vertexCount - this.lineOffset[j] ++ } ++ this.buffer.update(verts) ++ } + } +-exports.pointShader = { +- vertex: pointVertSrc, +- fragment: pointFragSrc, +- attributes: [ +- {name: 'position', type: 'vec3'}, +- {name: 'color', type: 'vec4'}, +- {name: 'uv', type: 'vec2'}, +- {name: 'pointSize', type: 'float'} +- ] ++ ++proto.dispose = function() { ++ this.shader.dispose() ++ this.buffer.dispose() ++ this.vao.dispose() + } +-exports.pickShader = { +- vertex: pickVertSrc, +- fragment: pickFragSrc, +- attributes: [ +- {name: 'position', type: 'vec3'}, +- {name: 'id', type: 'vec4'} +- ] ++ ++function createErrorBars(options) { ++ var gl = options.gl ++ var buffer = createBuffer(gl) ++ var vao = createVAO(gl, [ ++ { ++ buffer: buffer, ++ type: gl.FLOAT, ++ size: 3, ++ offset: 0, ++ stride: 40 ++ }, ++ { ++ buffer: buffer, ++ type: gl.FLOAT, ++ size: 4, ++ offset: 12, ++ stride: 40 ++ }, ++ { ++ buffer: buffer, ++ type: gl.FLOAT, ++ size: 3, ++ offset: 28, ++ stride: 40 ++ } ++ ]) ++ ++ var shader = createShader(gl) ++ shader.attributes.position.location = 0 ++ shader.attributes.color.location = 1 ++ shader.attributes.offset.location = 2 ++ ++ var result = new ErrorBars(gl, buffer, vao, shader) ++ result.update(options) ++ return result + } +-exports.pointPickShader = { +- vertex: pickPointVertSrc, +- fragment: pickFragSrc, +- attributes: [ ++ ++},{"./shaders/index":98,"gl-buffer":94,"gl-vao":148}],98:[function(require,module,exports){ ++'use strict' ++ ++ ++var createShader = require('gl-shader') ++ ++var vertSrc = "precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position, offset;\nattribute vec4 color;\nuniform mat4 model, view, projection;\nuniform float capSize;\nvarying vec4 fragColor;\nvarying vec3 fragPosition;\n\nvoid main() {\n vec4 worldPosition = model * vec4(position, 1.0);\n worldPosition = (worldPosition / worldPosition.w) + vec4(capSize * offset, 0.0);\n gl_Position = projection * view * worldPosition;\n fragColor = color;\n fragPosition = position;\n}" ++var fragSrc = "precision mediump float;\n#define GLSLIFY 1\nuniform vec3 clipBounds[2];\nuniform float opacity;\nvarying vec3 fragPosition;\nvarying vec4 fragColor;\n\nvoid main() {\n if(any(lessThan(fragPosition, clipBounds[0])) || any(greaterThan(fragPosition, clipBounds[1]))) {\n discard;\n }\n gl_FragColor = opacity * fragColor;\n}" ++ ++module.exports = function(gl) { ++ return createShader(gl, vertSrc, fragSrc, null, [ + {name: 'position', type: 'vec3'}, +- {name: 'pointSize', type: 'float'}, +- {name: 'id', type: 'vec4'} +- ] +-} +-exports.contourShader = { +- vertex: contourVertSrc, +- fragment: contourFragSrc, +- attributes: [ +- {name: 'position', type: 'vec3'} +- ] ++ {name: 'offset', type: 'vec3'}, ++ {name: 'color', type: 'vec4'} ++ ]) + } + +-},{}],133:[function(require,module,exports){ ++},{"gl-shader":133}],99:[function(require,module,exports){ + 'use strict' + +-var DEFAULT_VERTEX_NORMALS_EPSILON = 1e-6; // may be too large if triangles are very small +-var DEFAULT_FACE_NORMALS_EPSILON = 1e-6; +- +-var createShader = require('gl-shader') +-var createBuffer = require('gl-buffer') +-var createVAO = require('gl-vao') + var createTexture = require('gl-texture2d') +-var normals = require('normals') +-var multiply = require('gl-mat4/multiply') +-var invert = require('gl-mat4/invert') +-var ndarray = require('ndarray') +-var colormap = require('colormap') +-var getContour = require('simplicial-complex-contour') +-var pool = require('typedarray-pool') +-var shaders = require('./lib/shaders') +-var closestPoint = require('./lib/closest-point') + +-var meshShader = shaders.meshShader +-var wireShader = shaders.wireShader +-var pointShader = shaders.pointShader +-var pickShader = shaders.pickShader +-var pointPickShader = shaders.pointPickShader +-var contourShader = shaders.contourShader ++module.exports = createFBO + +-var identityMatrix = [ +- 1,0,0,0, +- 0,1,0,0, +- 0,0,1,0, +- 0,0,0,1] ++var colorAttachmentArrays = null ++var FRAMEBUFFER_UNSUPPORTED ++var FRAMEBUFFER_INCOMPLETE_ATTACHMENT ++var FRAMEBUFFER_INCOMPLETE_DIMENSIONS ++var FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT + +-function SimplicialMesh(gl +- , texture +- , triShader +- , lineShader +- , pointShader +- , pickShader +- , pointPickShader +- , contourShader +- , trianglePositions +- , triangleIds +- , triangleColors +- , triangleUVs +- , triangleNormals +- , triangleVAO +- , edgePositions +- , edgeIds +- , edgeColors +- , edgeUVs +- , edgeVAO +- , pointPositions +- , pointIds +- , pointColors +- , pointUVs +- , pointSizes +- , pointVAO +- , contourPositions +- , contourVAO) { ++function saveFBOState(gl) { ++ var fbo = gl.getParameter(gl.FRAMEBUFFER_BINDING) ++ var rbo = gl.getParameter(gl.RENDERBUFFER_BINDING) ++ var tex = gl.getParameter(gl.TEXTURE_BINDING_2D) ++ return [fbo, rbo, tex] ++} + +- this.gl = gl +- this.cells = [] +- this.positions = [] +- this.intensity = [] +- this.texture = texture +- this.dirty = true ++function restoreFBOState(gl, data) { ++ gl.bindFramebuffer(gl.FRAMEBUFFER, data[0]) ++ gl.bindRenderbuffer(gl.RENDERBUFFER, data[1]) ++ gl.bindTexture(gl.TEXTURE_2D, data[2]) ++} + +- this.triShader = triShader +- this.lineShader = lineShader +- this.pointShader = pointShader +- this.pickShader = pickShader +- this.pointPickShader = pointPickShader +- this.contourShader = contourShader ++function lazyInitColorAttachments(gl, ext) { ++ var maxColorAttachments = gl.getParameter(ext.MAX_COLOR_ATTACHMENTS_WEBGL) ++ colorAttachmentArrays = new Array(maxColorAttachments + 1) ++ for(var i=0; i<=maxColorAttachments; ++i) { ++ var x = new Array(maxColorAttachments) ++ for(var j=0; j 1) { ++ ext.drawBuffersWEBGL(colorAttachmentArrays[numColors]) ++ } + +- this.contourLineWidth = 1 +- this.contourPositions = contourPositions +- this.contourVAO = contourVAO +- this.contourCount = 0 +- this.contourColor = [0,0,0] +- this.contourEnable = true ++ //Allocate depth/stencil buffers ++ var WEBGL_depth_texture = gl.getExtension('WEBGL_depth_texture') ++ if(WEBGL_depth_texture) { ++ if(useStencil) { ++ fbo.depth = initTexture(gl, width, height, ++ WEBGL_depth_texture.UNSIGNED_INT_24_8_WEBGL, ++ gl.DEPTH_STENCIL, ++ gl.DEPTH_STENCIL_ATTACHMENT) ++ } else if(useDepth) { ++ fbo.depth = initTexture(gl, width, height, ++ gl.UNSIGNED_SHORT, ++ gl.DEPTH_COMPONENT, ++ gl.DEPTH_ATTACHMENT) ++ } ++ } else { ++ if(useDepth && useStencil) { ++ fbo._depth_rb = initRenderBuffer(gl, width, height, gl.DEPTH_STENCIL, gl.DEPTH_STENCIL_ATTACHMENT) ++ } else if(useDepth) { ++ fbo._depth_rb = initRenderBuffer(gl, width, height, gl.DEPTH_COMPONENT16, gl.DEPTH_ATTACHMENT) ++ } else if(useStencil) { ++ fbo._depth_rb = initRenderBuffer(gl, width, height, gl.STENCIL_INDEX, gl.STENCIL_ATTACHMENT) ++ } ++ } + +- this.pickId = 1 +- this.bounds = [ +- [ Infinity, Infinity, Infinity], +- [-Infinity,-Infinity,-Infinity] ] +- this.clipBounds = [ +- [-Infinity,-Infinity,-Infinity], +- [ Infinity, Infinity, Infinity] ] ++ //Check frame buffer state ++ var status = gl.checkFramebufferStatus(gl.FRAMEBUFFER) ++ if(status !== gl.FRAMEBUFFER_COMPLETE) { + +- this.lightPosition = [1e5, 1e5, 0] +- this.ambientLight = 0.8 +- this.diffuseLight = 0.8 +- this.specularLight = 2.0 +- this.roughness = 0.5 +- this.fresnel = 1.5 ++ //Release all partially allocated resources ++ fbo._destroyed = true + +- this.opacity = 1.0 ++ //Release all resources ++ gl.bindFramebuffer(gl.FRAMEBUFFER, null) ++ gl.deleteFramebuffer(fbo.handle) ++ fbo.handle = null ++ if(fbo.depth) { ++ fbo.depth.dispose() ++ fbo.depth = null ++ } ++ if(fbo._depth_rb) { ++ gl.deleteRenderbuffer(fbo._depth_rb) ++ fbo._depth_rb = null ++ } ++ for(var i=0; i= 1 ++ //Everything ok, let's get on with life ++ restoreFBOState(gl, state) + } + +-proto.isTransparent = function() { +- return this.opacity < 1 +-} ++function Framebuffer(gl, width, height, colorType, numColors, useDepth, useStencil, ext) { + +-proto.pickSlots = 1 ++ //Handle and set properties ++ this.gl = gl ++ this._shape = [width|0, height|0] ++ this._destroyed = false ++ this._ext = ext + +-proto.setPickBase = function(id) { +- this.pickId = id +-} ++ //Allocate buffers ++ this.color = new Array(numColors) ++ for(var i=0; i maxFBOSize || ++ h < 0 || h > maxFBOSize) { ++ throw new Error('gl-fbo: Can\'t resize FBO, invalid dimensions') + } +- this.contourCount = (ptr / 3)|0 +- this.contourPositions.update(result.subarray(0, ptr)) +- pool.free(result) +-} + +-proto.update = function(params) { +- params = params || {} +- var gl = this.gl ++ //Update shape ++ fbo._shape[0] = w ++ fbo._shape[1] = h + +- this.dirty = true ++ //Save framebuffer state ++ var state = saveFBOState(gl) + +- if('contourEnable' in params) { +- this.contourEnable = params.contourEnable ++ //Resize framebuffer attachments ++ for(var i=0; i maxFBOSize || height < 0 || height > maxFBOSize) { ++ throw new Error('gl-fbo: Parameters are too large for FBO') + } + +- //Point size +- var pointSizes = params.pointSizes +- var meshPointSize = params.pointSize || 1.0 ++ //Handle each option type ++ options = options || {} + +- //Update bounds +- this.bounds = [[Infinity,Infinity,Infinity], [-Infinity,-Infinity,-Infinity]] +- for(var i=0; i 1) { ++ //Check if multiple render targets supported ++ if(!WEBGL_draw_buffers) { ++ throw new Error('gl-fbo: Multiple draw buffer extension not supported') ++ } else if(numColors > gl.getParameter(WEBGL_draw_buffers.MAX_COLOR_ATTACHMENTS_WEBGL)) { ++ throw new Error('gl-fbo: Context does not support ' + numColors + ' draw buffers') + } +- this.bounds[0][j] = Math.min(this.bounds[0][j], p[j]) +- this.bounds[1][j] = Math.max(this.bounds[1][j], p[j]) + } + } + +- //Pack cells into buffers +- var triangleCount = 0 +- var edgeCount = 0 +- var pointCount = 0 ++ //Determine whether to use floating point textures ++ var colorType = gl.UNSIGNED_BYTE ++ var OES_texture_float = gl.getExtension('OES_texture_float') ++ if(options.float && numColors > 0) { ++ if(!OES_texture_float) { ++ throw new Error('gl-fbo: Context does not support floating point textures') ++ } ++ colorType = gl.FLOAT ++ } else if(options.preferFloat && numColors > 0) { ++ if(OES_texture_float) { ++ colorType = gl.FLOAT ++ } ++ } + +-fill_loop: +- for(var i=0; i= 1 ++} + +- eyePosition: [0,0,0], +- lightPosition: [0,0,0], ++proto.pickSlots = 1 + +- opacity: this.opacity, ++proto.setPickBase = function (id) { ++ this.pickId = id ++} + +- contourColor: this.contourColor, ++proto.drawTransparent = proto.draw = function (camera) { ++ var gl = this.gl ++ var shader = this.shader ++ var vao = this.vao ++ shader.bind() ++ shader.uniforms = { ++ model: camera.model || identity, ++ view: camera.view || identity, ++ projection: camera.projection || identity, ++ clipBounds: filterClipBounds(this.clipBounds), ++ dashTexture: this.texture.bind(), ++ dashScale: this.dashScale / this.arcLength[this.arcLength.length - 1], ++ opacity: this.opacity, ++ screenShape: [gl.drawingBufferWidth, gl.drawingBufferHeight], ++ pixelRatio: this.pixelRatio ++ } ++ vao.bind() ++ vao.draw(gl.TRIANGLE_STRIP, this.vertexCount) ++} + +- texture: 0 ++proto.drawPick = function (camera) { ++ var gl = this.gl ++ var shader = this.pickShader ++ var vao = this.vao ++ shader.bind() ++ shader.uniforms = { ++ model: camera.model || identity, ++ view: camera.view || identity, ++ projection: camera.projection || identity, ++ pickId: this.pickId, ++ clipBounds: filterClipBounds(this.clipBounds), ++ screenShape: [gl.drawingBufferWidth, gl.drawingBufferHeight], ++ pixelRatio: this.pixelRatio + } ++ vao.bind() ++ vao.draw(gl.TRIANGLE_STRIP, this.vertexCount) ++} + +- this.texture.bind(0) ++proto.update = function (options) { ++ var i, j + +- var invCameraMatrix = new Array(16) +- multiply(invCameraMatrix, uniforms.view, uniforms.model) +- multiply(invCameraMatrix, uniforms.projection, invCameraMatrix) +- invert(invCameraMatrix, invCameraMatrix) ++ this.dirty = true + +- for(var i=0; i<3; ++i) { +- uniforms.eyePosition[i] = invCameraMatrix[12+i] / invCameraMatrix[15] +- } ++ var connectGaps = !!options.connectGaps + +- var w = invCameraMatrix[15] +- for(var i=0; i<3; ++i) { +- w += this.lightPosition[i] * invCameraMatrix[4*i+3] ++ if ('dashScale' in options) { ++ this.dashScale = options.dashScale + } +- for(var i=0; i<3; ++i) { +- var s = invCameraMatrix[12+i] +- for(var j=0; j<3; ++j) { +- s += invCameraMatrix[4*j+i] * this.lightPosition[j] +- } +- uniforms.lightPosition[i] = s / w ++ if ('opacity' in options) { ++ this.opacity = +options.opacity + } + +- if(this.triangleCount > 0) { +- var shader = this.triShader +- shader.bind() +- shader.uniforms = uniforms +- +- this.triangleVAO.bind() +- gl.drawArrays(gl.TRIANGLES, 0, this.triangleCount*3) +- this.triangleVAO.unbind() ++ var positions = options.position || options.positions ++ if (!positions) { ++ return + } + +- if(this.edgeCount > 0 && this.lineWidth > 0) { +- var shader = this.lineShader +- shader.bind() +- shader.uniforms = uniforms ++ // Default color ++ var colors = options.color || options.colors || [0, 0, 0, 1] + +- this.edgeVAO.bind() +- gl.lineWidth(this.lineWidth) +- gl.drawArrays(gl.LINES, 0, this.edgeCount*2) +- this.edgeVAO.unbind() +- } ++ var lineWidth = options.lineWidth || 1 + +- if(this.pointCount > 0) { +- var shader = this.pointShader +- shader.bind() +- shader.uniforms = uniforms ++ // Recalculate buffer data ++ var buffer = [] ++ var arcLengthArray = [] ++ var pointArray = [] ++ var arcLength = 0.0 ++ var vertexCount = 0 ++ var bounds = [ ++ [ Infinity, Infinity, Infinity ], ++ [ -Infinity, -Infinity, -Infinity ]] ++ var hadGap = false + +- this.pointVAO.bind() +- gl.drawArrays(gl.POINTS, 0, this.pointCount) +- this.pointVAO.unbind() +- } ++ fill_loop: ++ for (i = 1; i < positions.length; ++i) { ++ var a = positions[i - 1] ++ var b = positions[i] + +- if(this.contourEnable && this.contourCount > 0 && this.contourLineWidth > 0) { +- var shader = this.contourShader +- shader.bind() +- shader.uniforms = uniforms ++ arcLengthArray.push(arcLength) ++ pointArray.push(a.slice()) + +- this.contourVAO.bind() +- gl.drawArrays(gl.LINES, 0, this.contourCount) +- this.contourVAO.unbind() +- } +-} ++ for (j = 0; j < 3; ++j) { ++ if (isNaN(a[j]) || isNaN(b[j]) || ++ !isFinite(a[j]) || !isFinite(b[j])) { + +-proto.drawPick = function(params) { +- params = params || {} ++ if (!connectGaps && buffer.length > 0) { ++ for (var k = 0; k < 24; ++k) { ++ buffer.push(buffer[buffer.length - 12]) ++ } ++ vertexCount += 2 ++ hadGap = true ++ } + +- var gl = this.gl ++ continue fill_loop ++ } ++ bounds[0][j] = Math.min(bounds[0][j], a[j], b[j]) ++ bounds[1][j] = Math.max(bounds[1][j], a[j], b[j]) ++ } ++ ++ var acolor, bcolor ++ if (Array.isArray(colors[0])) { ++ acolor = colors[i - 1] ++ bcolor = colors[i] ++ } else { ++ acolor = bcolor = colors ++ } ++ if (acolor.length === 3) { ++ acolor = [acolor[0], acolor[1], acolor[2], 1] ++ } ++ if (bcolor.length === 3) { ++ bcolor = [bcolor[0], bcolor[1], bcolor[2], 1] ++ } ++ ++ var w0 ++ if (Array.isArray(lineWidth)) { ++ w0 = lineWidth[i - 1] ++ } else { ++ w0 = lineWidth ++ } ++ ++ var t0 = arcLength ++ arcLength += distance(a, b) ++ ++ if (hadGap) { ++ for (j = 0; j < 2; ++j) { ++ buffer.push( ++ a[0], a[1], a[2], b[0], b[1], b[2], t0, w0, acolor[0], acolor[1], acolor[2], acolor[3]) ++ } ++ vertexCount += 2 ++ hadGap = false ++ } + +- var model = params.model || identityMatrix +- var view = params.view || identityMatrix +- var projection = params.projection || identityMatrix ++ buffer.push( ++ a[0], a[1], a[2], b[0], b[1], b[2], t0, w0, acolor[0], acolor[1], acolor[2], acolor[3], ++ a[0], a[1], a[2], b[0], b[1], b[2], t0, -w0, acolor[0], acolor[1], acolor[2], acolor[3], ++ b[0], b[1], b[2], a[0], a[1], a[2], arcLength, -w0, bcolor[0], bcolor[1], bcolor[2], bcolor[3], ++ b[0], b[1], b[2], a[0], a[1], a[2], arcLength, w0, bcolor[0], bcolor[1], bcolor[2], bcolor[3]) + +- var clipBounds = [[-1e6,-1e6,-1e6],[1e6,1e6,1e6]] +- for(var i=0; i<3; ++i) { +- clipBounds[0][i] = Math.max(clipBounds[0][i], this.clipBounds[0][i]) +- clipBounds[1][i] = Math.min(clipBounds[1][i], this.clipBounds[1][i]) ++ vertexCount += 4 + } ++ this.buffer.update(buffer) + +- //Save camera parameters +- this._model = [].slice.call(model) +- this._view = [].slice.call(view) +- this._projection = [].slice.call(projection) +- this._resolution = [gl.drawingBufferWidth, gl.drawingBufferHeight] ++ arcLengthArray.push(arcLength) ++ pointArray.push(positions[positions.length - 1].slice()) + +- var uniforms = { +- model: model, +- view: view, +- projection: projection, +- clipBounds: clipBounds, +- pickId: this.pickId / 255.0, +- } ++ this.bounds = bounds + +- var shader = this.pickShader +- shader.bind() +- shader.uniforms = uniforms ++ this.vertexCount = vertexCount + +- if(this.triangleCount > 0) { +- this.triangleVAO.bind() +- gl.drawArrays(gl.TRIANGLES, 0, this.triangleCount*3) +- this.triangleVAO.unbind() +- } ++ this.points = pointArray ++ this.arcLength = arcLengthArray + +- if(this.edgeCount > 0) { +- this.edgeVAO.bind() +- gl.lineWidth(this.lineWidth) +- gl.drawArrays(gl.LINES, 0, this.edgeCount*2) +- this.edgeVAO.unbind() +- } ++ if ('dashes' in options) { ++ var dashArray = options.dashes + +- if(this.pointCount > 0) { +- var shader = this.pointPickShader +- shader.bind() +- shader.uniforms = uniforms ++ // Calculate prefix sum ++ var prefixSum = dashArray.slice() ++ prefixSum.unshift(0) ++ for (i = 1; i < prefixSum.length; ++i) { ++ prefixSum[i] = prefixSum[i - 1] + prefixSum[i] ++ } + +- this.pointVAO.bind() +- gl.drawArrays(gl.POINTS, 0, this.pointCount) +- this.pointVAO.unbind() ++ var dashTexture = ndarray(new Array(256 * 4), [256, 1, 4]) ++ for (i = 0; i < 256; ++i) { ++ for (j = 0; j < 4; ++j) { ++ dashTexture.set(i, 0, j, 0) ++ } ++ if (bsearch.le(prefixSum, prefixSum[prefixSum.length - 1] * i / 255.0) & 1) { ++ dashTexture.set(i, 0, 0, 0) ++ } else { ++ dashTexture.set(i, 0, 0, 255) ++ } ++ } ++ ++ this.texture.setPixels(dashTexture) + } + } + ++proto.dispose = function () { ++ this.shader.dispose() ++ this.vao.dispose() ++ this.buffer.dispose() ++} + +-proto.pick = function(pickData) { +- if(!pickData) { ++proto.pick = function (selection) { ++ if (!selection) { + return null + } +- if(pickData.id !== this.pickId) { ++ if (selection.id !== this.pickId) { + return null + } +- +- var cellId = pickData.value[0] + 256*pickData.value[1] + 65536*pickData.value[2] +- var cell = this.cells[cellId] +- var positions = this.positions +- +- var simplex = new Array(cell.length) +- for(var i=0; i epsilon) { +- var norm = normals[c]; +- var w = 1.0 / Math.sqrt(m01 * m21); +- for(var k=0; k<3; ++k) { +- var u = (k+1)%3; +- var v = (k+2)%3; +- norm[k] += w * (d21[u] * d01[v] - d21[v] * d01[u]); +- } +- } +- } +- } ++ out[0] = 1 - yy - zz; ++ out[1] = yx + wz; ++ out[2] = zx - wy; ++ out[3] = 0; + +- //Scale all normals to unit length +- for(var i=0; i epsilon) { +- var w = 1.0 / Math.sqrt(m); +- for(var k=0; k<3; ++k) { +- norm[k] *= w; +- } +- } else { +- for(var k=0; k<3; ++k) { +- norm[k] = 0.0; +- } +- } +- } ++ out[4] = yx - wz; ++ out[5] = 1 - xx - zz; ++ out[6] = zy + wx; ++ out[7] = 0; + +- //Return the resulting set of patches +- return normals; +-} ++ out[8] = zx + wy; ++ out[9] = zy - wx; ++ out[10] = 1 - xx - yy; ++ out[11] = 0; + +-//Compute face normals of a mesh +-exports.faceNormals = function(faces, positions, specifiedEpsilon) { ++ out[12] = 0; ++ out[13] = 0; ++ out[14] = 0; ++ out[15] = 1; + +- var N = faces.length; +- var normals = new Array(N); +- var epsilon = specifiedEpsilon === void(0) ? DEFAULT_FACE_EPSILON : specifiedEpsilon; ++ return out; ++}; ++},{}],109:[function(require,module,exports){ ++module.exports = fromRotationTranslation; + +- for(var i=0; i epsilon) { +- l = 1.0 / Math.sqrt(l); +- } else { +- l = 0.0; +- } +- for(var j=0; j<3; ++j) { +- n[j] *= l; +- } +- normals[i] = n; +- } +- return normals; +-} ++ out[0] = 1 - (yy + zz); ++ out[1] = xy + wz; ++ out[2] = xz - wy; ++ out[3] = 0; ++ out[4] = xy - wz; ++ out[5] = 1 - (xx + zz); ++ out[6] = yz + wx; ++ out[7] = 0; ++ out[8] = xz + wy; ++ out[9] = yz - wx; ++ out[10] = 1 - (xx + yy); ++ out[11] = 0; ++ out[12] = v[0]; ++ out[13] = v[1]; ++ out[14] = v[2]; ++ out[15] = 1; ++ ++ return out; ++}; ++},{}],110:[function(require,module,exports){ ++module.exports = identity; + ++/** ++ * Set a mat4 to the identity matrix ++ * ++ * @param {mat4} out the receiving matrix ++ * @returns {mat4} out ++ */ ++function identity(out) { ++ out[0] = 1; ++ out[1] = 0; ++ out[2] = 0; ++ out[3] = 0; ++ out[4] = 0; ++ out[5] = 1; ++ out[6] = 0; ++ out[7] = 0; ++ out[8] = 0; ++ out[9] = 0; ++ out[10] = 1; ++ out[11] = 0; ++ out[12] = 0; ++ out[13] = 0; ++ out[14] = 0; ++ out[15] = 1; ++ return out; ++}; ++},{}],111:[function(require,module,exports){ ++module.exports = invert; + ++/** ++ * Inverts a mat4 ++ * ++ * @param {mat4} out the receiving matrix ++ * @param {mat4} a the source matrix ++ * @returns {mat4} out ++ */ ++function invert(out, a) { ++ var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3], ++ a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7], ++ a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11], ++ a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15], + +-},{}],136:[function(require,module,exports){ +-//Optimized version for triangle closest point +-// Based on Eberly's WildMagick codes +-// http://www.geometrictools.com/LibMathematics/Distance/Distance.html +-"use strict"; ++ b00 = a00 * a11 - a01 * a10, ++ b01 = a00 * a12 - a02 * a10, ++ b02 = a00 * a13 - a03 * a10, ++ b03 = a01 * a12 - a02 * a11, ++ b04 = a01 * a13 - a03 * a11, ++ b05 = a02 * a13 - a03 * a12, ++ b06 = a20 * a31 - a21 * a30, ++ b07 = a20 * a32 - a22 * a30, ++ b08 = a20 * a33 - a23 * a30, ++ b09 = a21 * a32 - a22 * a31, ++ b10 = a21 * a33 - a23 * a31, ++ b11 = a22 * a33 - a23 * a32, + +-var diff = new Float64Array(4); +-var edge0 = new Float64Array(4); +-var edge1 = new Float64Array(4); ++ // Calculate the determinant ++ det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; + +-function closestPoint2d(V0, V1, V2, point, result) { +- //Reallocate buffers if necessary +- if(diff.length < point.length) { +- diff = new Float64Array(point.length); +- edge0 = new Float64Array(point.length); +- edge1 = new Float64Array(point.length); +- } +- //Compute edges +- for(var i=0; i= a00) { +- s = 1.0; +- sqrDistance = a00 + 2.0*b0 + c; +- } else { +- s = -b0/a00; +- sqrDistance = b0*s + c; +- } +- } else { +- s = 0; +- if (b1 >= 0) { +- t = 0; +- sqrDistance = c; +- } else if (-b1 >= a11) { +- t = 1; +- sqrDistance = a11 + 2.0*b1 + c; +- } else { +- t = -b1/a11; +- sqrDistance = b1*t + c; +- } +- } +- } else { // region 3 +- s = 0; +- if (b1 >= 0) { +- t = 0; +- sqrDistance = c; +- } else if (-b1 >= a11) { +- t = 1; +- sqrDistance = a11 + 2.0*b1 + c; +- } else { +- t = -b1/a11; +- sqrDistance = b1*t + c; +- } +- } +- } else if (t < 0) { // region 5 +- t = 0; +- if (b0 >= 0) { +- s = 0; +- sqrDistance = c; +- } else if (-b0 >= a00) { +- s = 1; +- sqrDistance = a00 + 2.0*b0 + c; +- } else { +- s = -b0/a00; +- sqrDistance = b0*s + c; +- } +- } else { // region 0 +- // minimum at interior point +- var invDet = 1.0 / det; +- s *= invDet; +- t *= invDet; +- sqrDistance = s*(a00*s + a01*t + 2.0*b0) + t*(a01*s + a11*t + 2.0*b1) + c; +- } +- } else { +- var tmp0, tmp1, numer, denom; +- +- if (s < 0) { // region 2 +- tmp0 = a01 + b0; +- tmp1 = a11 + b1; +- if (tmp1 > tmp0) { +- numer = tmp1 - tmp0; +- denom = a00 - 2.0*a01 + a11; +- if (numer >= denom) { +- s = 1; +- t = 0; +- sqrDistance = a00 + 2.0*b0 + c; +- } else { +- s = numer/denom; +- t = 1 - s; +- sqrDistance = s*(a00*s + a01*t + 2.0*b0) + +- t*(a01*s + a11*t + 2.0*b1) + c; +- } +- } else { +- s = 0; +- if (tmp1 <= 0) { +- t = 1; +- sqrDistance = a11 + 2.0*b1 + c; +- } else if (b1 >= 0) { +- t = 0; +- sqrDistance = c; +- } else { +- t = -b1/a11; +- sqrDistance = b1*t + c; +- } +- } +- } else if (t < 0) { // region 6 +- tmp0 = a01 + b1; +- tmp1 = a00 + b0; +- if (tmp1 > tmp0) { +- numer = tmp1 - tmp0; +- denom = a00 - 2.0*a01 + a11; +- if (numer >= denom) { +- t = 1; +- s = 0; +- sqrDistance = a11 + 2.0*b1 + c; +- } else { +- t = numer/denom; +- s = 1 - t; +- sqrDistance = s*(a00*s + a01*t + 2.0*b0) + +- t*(a01*s + a11*t + 2.0*b1) + c; +- } +- } else { +- t = 0; +- if (tmp1 <= 0) { +- s = 1; +- sqrDistance = a00 + 2.0*b0 + c; +- } else if (b0 >= 0) { +- s = 0; +- sqrDistance = c; +- } else { +- s = -b0/a00; +- sqrDistance = b0*s + c; +- } +- } +- } else { // region 1 +- numer = a11 + b1 - a01 - b0; +- if (numer <= 0) { +- s = 0; +- t = 1; +- sqrDistance = a11 + 2.0*b1 + c; +- } else { +- denom = a00 - 2.0*a01 + a11; +- if (numer >= denom) { +- s = 1; +- t = 0; +- sqrDistance = a00 + 2.0*b0 + c; +- } else { +- s = numer/denom; +- t = 1 - s; +- sqrDistance = s*(a00*s + a01*t + 2.0*b0) + +- t*(a01*s + a11*t + 2.0*b1) + c; +- } +- } ++ if (!det) { ++ return null; + } +- } +- var u = 1.0 - s - t; +- for(var i=0; i>1,v=E[2*m+1];', +- 'if(v===b){return m}', +- 'if(b 0) { +- code.push(',') +- } +- code.push('[') +- for(var j=0; j 0) { +- code.push(',') +- } +- code.push('B(C,E,c[', f[0], '],c[', f[1], '])') +- } +- code.push(']') ++ if (a !== out) { // If the source and destination differ, copy the unchanged rows ++ out[0] = a[0]; ++ out[1] = a[1]; ++ out[2] = a[2]; ++ out[3] = a[3]; ++ out[12] = a[12]; ++ out[13] = a[13]; ++ out[14] = a[14]; ++ out[15] = a[15]; + } +- code.push(');') +- } + +- for(var i=d+1; i>1; --i) { +- if(i < d+1) { +- code.push('else ') ++ // Perform axis-specific matrix multiplication ++ out[4] = a10 * c + a20 * s; ++ out[5] = a11 * c + a21 * s; ++ out[6] = a12 * c + a22 * s; ++ out[7] = a13 * c + a23 * s; ++ out[8] = a20 * c - a10 * s; ++ out[9] = a21 * c - a11 * s; ++ out[10] = a22 * c - a12 * s; ++ out[11] = a23 * c - a13 * s; ++ return out; ++}; ++},{}],117:[function(require,module,exports){ ++module.exports = rotateY; ++ ++/** ++ * Rotates a matrix by the given angle around the Y axis ++ * ++ * @param {mat4} out the receiving matrix ++ * @param {mat4} a the matrix to rotate ++ * @param {Number} rad the angle to rotate the matrix by ++ * @returns {mat4} out ++ */ ++function rotateY(out, a, rad) { ++ var s = Math.sin(rad), ++ c = Math.cos(rad), ++ a00 = a[0], ++ a01 = a[1], ++ a02 = a[2], ++ a03 = a[3], ++ a20 = a[8], ++ a21 = a[9], ++ a22 = a[10], ++ a23 = a[11]; ++ ++ if (a !== out) { // If the source and destination differ, copy the unchanged rows ++ out[4] = a[4]; ++ out[5] = a[5]; ++ out[6] = a[6]; ++ out[7] = a[7]; ++ out[12] = a[12]; ++ out[13] = a[13]; ++ out[14] = a[14]; ++ out[15] = a[15]; + } +- code.push('if(l===', i, '){') + +- //Generate mask +- var maskStr = [] +- for(var j=0; j 1) { +- var scratch_shape = [] +- for(var i=1; i 1) { +- +- //Copy data into scratch +- code.push("dptr=0;sptr=ptr") +- for(var i=order.length-1; i>=0; --i) { +- var j = order[i] +- if(j === 0) { +- continue +- } +- code.push(["for(i",j,"=0;i",j,"left){", +- "dptr=0", +- "sptr=cptr-s0") +- for(var i=1; ib){break __l}"].join("")) +- for(var i=order.length-1; i>=1; --i) { +- code.push( +- "sptr+=e"+i, +- "dptr+=f"+i, +- "}") +- } +- +- //Copy data back +- code.push("dptr=cptr;sptr=cptr-s0") +- for(var i=order.length-1; i>=0; --i) { +- var j = order[i] +- if(j === 0) { +- continue +- } +- code.push(["for(i",j,"=0;i",j,"=0; --i) { +- var j = order[i] +- if(j === 0) { +- continue +- } +- code.push(["for(i",j,"=0;i",j,"left)&&("+dataRead("cptr-s0")+">scratch)){", +- dataWrite("cptr", dataRead("cptr-s0")), +- "cptr-=s0", +- "}", +- dataWrite("cptr", "scratch")) +- } +- +- //Close outer loop body +- code.push("}") +- if(order.length > 1 && allocator) { +- code.push("free(scratch)") +- } +- code.push("} return " + funcName) +- +- //Compile and link function +- if(allocator) { +- var result = new Function("malloc", "free", code.join("\n")) +- return result(allocator[0], allocator[1]) +- } else { +- var result = new Function(code.join("\n")) +- return result() +- } +-} ++module.exports = invert + +-function createQuickSort(order, dtype, insertionSort) { +- var code = [ "'use strict'" ] +- var funcName = ["ndarrayQuickSort", order.join("d"), dtype].join("") +- var funcArgs = ["left", "right", "data", "offset" ].concat(shapeArgs(order.length)) +- var allocator = getMallocFree(dtype) +- var labelCounter=0 +- +- code.push(["function ", funcName, "(", funcArgs.join(","), "){"].join("")) +- +- var vars = [ +- "sixth=((right-left+1)/6)|0", +- "index1=left+sixth", +- "index5=right-sixth", +- "index3=(left+right)>>1", +- "index2=index3-sixth", +- "index4=index3+sixth", +- "el1=index1", +- "el2=index2", +- "el3=index3", +- "el4=index4", +- "el5=index5", +- "less=left+1", +- "great=right-1", +- "pivots_are_equal=true", +- "tmp", +- "tmp0", +- "x", +- "y", +- "z", +- "k", +- "ptr0", +- "ptr1", +- "ptr2", +- "comp_pivot1=0", +- "comp_pivot2=0", +- "comp=0" +- ] +- +- if(order.length > 1) { +- var ele_size = [] +- for(var i=1; i=0; --i) { +- var j = order[i] +- if(j === 0) { +- continue +- } +- code.push(["for(i",j,"=0;i",j," 1) { +- for(var i=0; i1) { +- code.push("ptr_shift+=d"+j) +- } else { +- code.push("ptr0+=d"+j) +- } +- code.push("}") +- } ++ return out ++} ++ ++function projectVertex(v, model, view, projection, resolution) { ++ var p = xformMatrix(projection, ++ xformMatrix(view, ++ xformMatrix(model, [v[0], v[1], v[2], 1]))) ++ for(var i=0; i<3; ++i) { ++ p[i] /= p[3] + } +- +- function lexicoLoop(label, ptrs, usePivot, body) { +- if(ptrs.length === 1) { +- code.push("ptr0="+toPointer(ptrs[0])) +- } else { +- for(var i=0; i 1) { +- for(var i=0; i=1; --i) { +- if(usePivot) { +- code.push("pivot_ptr+=f"+i) +- } +- if(ptrs.length > 1) { +- code.push("ptr_shift+=e"+i) +- } else { +- code.push("ptr0+=e"+i) +- } +- code.push("}") ++ d0 = Math.sqrt(d0) ++ d1 = Math.sqrt(d1) ++ if(d0+d1 < 1e-6) { ++ return [1,0] + } ++ return [d1/(d0+d1),d0/(d1+d0)] ++ } else if(simplex.length === 3) { ++ var closestPoint = [0,0] ++ closestPointToTriangle(simplex[0], simplex[1], simplex[2], point, closestPoint) ++ return barycentric(simplex, closestPoint) + } +- +- function cleanUp() { +- if(order.length > 1 && allocator) { +- code.push("free(pivot1)", "free(pivot2)") ++ return [] ++} ++ ++function interpolate(simplex, weights) { ++ var result = [0,0,0] ++ for(var i=0; i 1) { +- var lbl = "__l" + (++labelCounter) +- lexicoLoop(lbl, [a, b], false, [ +- "comp=",dataRead("ptr0"),"-",dataRead("ptr1"),"\n", +- "if(comp>0){tmp0=", a, ";",a,"=",b,";", b,"=tmp0;break ", lbl,"}\n", +- "if(comp<0){break ", lbl, "}" +- ].join("")) +- } else { +- code.push(["if(", dataRead(toPointer(a)), ">", dataRead(toPointer(b)), "){tmp0=", a, ";",a,"=",b,";", b,"=tmp0}"].join("")) +- } ++ return result ++} ++ ++function closestPointToPickLocation(simplex, pixelCoord, model, view, projection, resolution) { ++ if(simplex.length === 1) { ++ return [0, simplex[0].slice()] + } +- +- compareSwap(1, 2) +- compareSwap(4, 5) +- compareSwap(1, 3) +- compareSwap(2, 3) +- compareSwap(1, 4) +- compareSwap(3, 4) +- compareSwap(2, 5) +- compareSwap(2, 3) +- compareSwap(4, 5) +- +- if(order.length > 1) { +- cacheLoop(["el1", "el2", "el3", "el4", "el5", "index1", "index3", "index5"], true, [ +- "pivot1[pivot_ptr]=",dataRead("ptr1"),"\n", +- "pivot2[pivot_ptr]=",dataRead("ptr3"),"\n", +- "pivots_are_equal=pivots_are_equal&&(pivot1[pivot_ptr]===pivot2[pivot_ptr])\n", +- "x=",dataRead("ptr0"),"\n", +- "y=",dataRead("ptr2"),"\n", +- "z=",dataRead("ptr4"),"\n", +- dataWrite("ptr5", "x"),"\n", +- dataWrite("ptr6", "y"),"\n", +- dataWrite("ptr7", "z") +- ].join("")) +- } else { +- code.push([ +- "pivot1=", dataRead(toPointer("el2")), "\n", +- "pivot2=", dataRead(toPointer("el4")), "\n", +- "pivots_are_equal=pivot1===pivot2\n", +- "x=", dataRead(toPointer("el1")), "\n", +- "y=", dataRead(toPointer("el3")), "\n", +- "z=", dataRead(toPointer("el5")), "\n", +- dataWrite(toPointer("index1"), "x"), "\n", +- dataWrite(toPointer("index3"), "y"), "\n", +- dataWrite(toPointer("index5"), "z") +- ].join("")) ++ var simplex2D = new Array(simplex.length) ++ for(var i=0; i 1) { +- cacheLoop([dst, src], false, +- dataWrite("ptr0", dataRead("ptr1")) +- ) +- } else { +- code.push(dataWrite(toPointer(dst), dataRead(toPointer(src)))) +- } +- } +- +- moveElement("index2", "left") +- moveElement("index4", "right") +- +- function comparePivot(result, ptr, n) { +- if(order.length > 1) { +- var lbl = "__l" + (++labelCounter) +- lexicoLoop(lbl, [ptr], true, [ +- result,"=",dataRead("ptr0"),"-pivot",n,"[pivot_ptr]\n", +- "if(",result,"!==0){break ", lbl, "}" +- ].join("")) +- } else { +- code.push([result,"=", dataRead(toPointer(ptr)), "-pivot", n].join("")) ++ var closestIndex = 0 ++ var closestDist = Infinity ++ for(var i=0; i 1) { +- cacheLoop([a,b],false,[ +- "tmp=",dataRead("ptr0"),"\n", +- dataWrite("ptr0", dataRead("ptr1")),"\n", +- dataWrite("ptr1", "tmp") +- ].join("")) +- } else { +- code.push([ +- "ptr0=",toPointer(a),"\n", +- "ptr1=",toPointer(b),"\n", +- "tmp=",dataRead("ptr0"),"\n", +- dataWrite("ptr0", dataRead("ptr1")),"\n", +- dataWrite("ptr1", "tmp") +- ].join("")) ++ if(d2 < closestDist) { ++ closestDist = d2 ++ closestIndex = i + } + } +- +- function tripleSwap(k, less, great) { +- if(order.length > 1) { +- cacheLoop([k,less,great], false, [ +- "tmp=",dataRead("ptr0"),"\n", +- dataWrite("ptr0", dataRead("ptr1")),"\n", +- dataWrite("ptr1", dataRead("ptr2")),"\n", +- dataWrite("ptr2", "tmp") +- ].join("")) +- code.push("++"+less, "--"+great) +- } else { +- code.push([ +- "ptr0=",toPointer(k),"\n", +- "ptr1=",toPointer(less),"\n", +- "ptr2=",toPointer(great),"\n", +- "++",less,"\n", +- "--",great,"\n", +- "tmp=", dataRead("ptr0"), "\n", +- dataWrite("ptr0", dataRead("ptr1")), "\n", +- dataWrite("ptr1", dataRead("ptr2")), "\n", +- dataWrite("ptr2", "tmp") +- ].join("")) ++ ++ var weights = barycentricCoord(simplex2D, pixelCoord) ++ var s = 0.0 ++ for(var i=0; i<3; ++i) { ++ if(weights[i] < -0.001 || ++ weights[i] > 1.0001) { ++ return null + } ++ s += weights[i] + } +- +- function swapAndDecrement(k, great) { +- swapElements(k, great) +- code.push("--"+great) ++ if(Math.abs(s - 1.0) > 0.001) { ++ return null + } +- +- code.push("if(pivots_are_equal){") +- //Pivots are equal case +- code.push("for(k=less;k<=great;++k){") +- comparePivot("comp", "k", 1) +- code.push("if(comp===0){continue}") +- code.push("if(comp<0){") +- code.push("if(k!==less){") +- swapElements("k", "less") +- code.push("}") +- code.push("++less") +- code.push("}else{") +- code.push("while(true){") +- comparePivot("comp", "great", 1) +- code.push("if(comp>0){") +- code.push("great--") +- code.push("}else if(comp<0){") +- tripleSwap("k", "less", "great") +- code.push("break") +- code.push("}else{") +- swapAndDecrement("k", "great") +- code.push("break") +- code.push("}") +- code.push("}") +- code.push("}") +- code.push("}") +- code.push("}else{") +- //Pivots not equal case +- code.push("for(k=less;k<=great;++k){") +- comparePivot("comp_pivot1", "k", 1) +- code.push("if(comp_pivot1<0){") +- code.push("if(k!==less){") +- swapElements("k", "less") +- code.push("}") +- code.push("++less") +- code.push("}else{") +- comparePivot("comp_pivot2", "k", 2) +- code.push("if(comp_pivot2>0){") +- code.push("while(true){") +- comparePivot("comp", "great", 2) +- code.push("if(comp>0){") +- code.push("if(--great1) { +- cacheLoop([mem_dest, pivot_dest], true, [ +- dataWrite("ptr0", dataRead("ptr1")), "\n", +- dataWrite("ptr1", ["pivot",pivot,"[pivot_ptr]"].join("")) +- ].join("")) +- } else { +- code.push( +- dataWrite(toPointer(mem_dest), dataRead(toPointer(pivot_dest))), +- dataWrite(toPointer(pivot_dest), "pivot"+pivot)) ++ return [closestIndex, interpolate(simplex, weights), weights] ++} ++},{"barycentric":17,"polytope-closest-point/lib/closest_point_2d.js":204}],124:[function(require,module,exports){ ++ ++ ++var triVertSrc = "precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position, normal;\nattribute vec4 color;\nattribute vec2 uv;\n\nuniform mat4 model\n , view\n , projection;\nuniform vec3 eyePosition\n , lightPosition;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n vec4 m_position = model * vec4(position, 1.0);\n vec4 t_position = view * m_position;\n gl_Position = projection * t_position;\n f_color = color;\n f_normal = normal;\n f_data = position;\n f_eyeDirection = eyePosition - position;\n f_lightDirection = lightPosition - position;\n f_uv = uv;\n}" ++var triFragSrc = "precision mediump float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution_2_0(float x, float roughness) {\n float NdotH = max(x, 0.0001);\n float cos2Alpha = NdotH * NdotH;\n float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha;\n float roughness2 = roughness * roughness;\n float denom = 3.141592653589793 * roughness2 * cos2Alpha * cos2Alpha;\n return exp(tan2Alpha / roughness2) / denom;\n}\n\n\n\nfloat cookTorranceSpecular_1_1(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness,\n float fresnel) {\n\n float VdotN = max(dot(viewDirection, surfaceNormal), 0.0);\n float LdotN = max(dot(lightDirection, surfaceNormal), 0.0);\n\n //Half angle vector\n vec3 H = normalize(lightDirection + viewDirection);\n\n //Geometric term\n float NdotH = max(dot(surfaceNormal, H), 0.0);\n float VdotH = max(dot(viewDirection, H), 0.000001);\n float LdotH = max(dot(lightDirection, H), 0.000001);\n float G1 = (2.0 * NdotH * VdotN) / VdotH;\n float G2 = (2.0 * NdotH * LdotN) / LdotH;\n float G = min(1.0, min(G1, G2));\n \n //Distribution term\n float D = beckmannDistribution_2_0(NdotH, roughness);\n\n //Fresnel term\n float F = pow(1.0 - VdotN, fresnel);\n\n //Multiply terms and done\n return G * F * D / max(3.14159265 * VdotN, 0.000001);\n}\n\n\n\nuniform vec3 clipBounds[2];\nuniform float roughness\n , fresnel\n , kambient\n , kdiffuse\n , kspecular\n , opacity;\nuniform sampler2D texture;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n if(any(lessThan(f_data, clipBounds[0])) || \n any(greaterThan(f_data, clipBounds[1]))) {\n discard;\n }\n\n vec3 N = normalize(f_normal);\n vec3 L = normalize(f_lightDirection);\n vec3 V = normalize(f_eyeDirection);\n \n if(!gl_FrontFacing) {\n N = -N;\n }\n\n float specular = cookTorranceSpecular_1_1(L, V, N, roughness, fresnel);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = f_color * texture2D(texture, f_uv);\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = litColor * opacity;\n}" ++var edgeVertSrc = "precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 uv;\n\nuniform mat4 model, view, projection;\n\nvarying vec4 f_color;\nvarying vec3 f_data;\nvarying vec2 f_uv;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n f_color = color;\n f_data = position;\n f_uv = uv;\n}" ++var edgeFragSrc = "precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 clipBounds[2];\nuniform sampler2D texture;\nuniform float opacity;\n\nvarying vec4 f_color;\nvarying vec3 f_data;\nvarying vec2 f_uv;\n\nvoid main() {\n if(any(lessThan(f_data, clipBounds[0])) || \n any(greaterThan(f_data, clipBounds[1]))) {\n discard;\n }\n\n gl_FragColor = f_color * texture2D(texture, f_uv) * opacity;\n}" ++var pointVertSrc = "precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 uv;\nattribute float pointSize;\n\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n if(any(lessThan(position, clipBounds[0])) || \n any(greaterThan(position, clipBounds[1]))) {\n gl_Position = vec4(0,0,0,0);\n } else {\n gl_Position = projection * view * model * vec4(position, 1.0);\n }\n gl_PointSize = pointSize;\n f_color = color;\n f_uv = uv;\n}" ++var pointFragSrc = "precision mediump float;\n#define GLSLIFY 1\n\nuniform sampler2D texture;\nuniform float opacity;\n\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n vec2 pointR = gl_PointCoord.xy - vec2(0.5,0.5);\n if(dot(pointR, pointR) > 0.25) {\n discard;\n }\n gl_FragColor = f_color * texture2D(texture, f_uv) * opacity;\n}" ++var pickVertSrc = "precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n f_id = id;\n f_position = position;\n}" ++var pickFragSrc = "precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if(any(lessThan(f_position, clipBounds[0])) || \n any(greaterThan(f_position, clipBounds[1]))) {\n discard;\n }\n gl_FragColor = vec4(pickId, f_id.xyz);\n}" ++var pickPointVertSrc = "precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute float pointSize;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if(any(lessThan(position, clipBounds[0])) || \n any(greaterThan(position, clipBounds[1]))) {\n gl_Position = vec4(0,0,0,0);\n } else {\n gl_Position = projection * view * model * vec4(position, 1.0);\n gl_PointSize = pointSize;\n }\n f_id = id;\n f_position = position;\n}" ++var contourVertSrc = "precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\n\nuniform mat4 model, view, projection;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n}" ++var contourFragSrc = "precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 contourColor;\n\nvoid main() {\n gl_FragColor = vec4(contourColor,1);\n}\n" ++ ++exports.meshShader = { ++ vertex: triVertSrc, ++ fragment: triFragSrc, ++ attributes: [ ++ {name: 'position', type: 'vec3'}, ++ {name: 'normal', type: 'vec3'}, ++ {name: 'color', type: 'vec4'}, ++ {name: 'uv', type: 'vec2'} ++ ] ++} ++exports.wireShader = { ++ vertex: edgeVertSrc, ++ fragment: edgeFragSrc, ++ attributes: [ ++ {name: 'position', type: 'vec3'}, ++ {name: 'color', type: 'vec4'}, ++ {name: 'uv', type: 'vec2'} ++ ] ++} ++exports.pointShader = { ++ vertex: pointVertSrc, ++ fragment: pointFragSrc, ++ attributes: [ ++ {name: 'position', type: 'vec3'}, ++ {name: 'color', type: 'vec4'}, ++ {name: 'uv', type: 'vec2'}, ++ {name: 'pointSize', type: 'float'} ++ ] ++} ++exports.pickShader = { ++ vertex: pickVertSrc, ++ fragment: pickFragSrc, ++ attributes: [ ++ {name: 'position', type: 'vec3'}, ++ {name: 'id', type: 'vec4'} ++ ] ++} ++exports.pointPickShader = { ++ vertex: pickPointVertSrc, ++ fragment: pickFragSrc, ++ attributes: [ ++ {name: 'position', type: 'vec3'}, ++ {name: 'pointSize', type: 'float'}, ++ {name: 'id', type: 'vec4'} ++ ] ++} ++exports.contourShader = { ++ vertex: contourVertSrc, ++ fragment: contourFragSrc, ++ attributes: [ ++ {name: 'position', type: 'vec3'} ++ ] ++} ++ ++},{}],125:[function(require,module,exports){ ++'use strict' ++ ++var DEFAULT_VERTEX_NORMALS_EPSILON = 1e-6; // may be too large if triangles are very small ++var DEFAULT_FACE_NORMALS_EPSILON = 1e-6; ++ ++var createShader = require('gl-shader') ++var createBuffer = require('gl-buffer') ++var createVAO = require('gl-vao') ++var createTexture = require('gl-texture2d') ++var normals = require('normals') ++var multiply = require('gl-mat4/multiply') ++var invert = require('gl-mat4/invert') ++var ndarray = require('ndarray') ++var colormap = require('colormap') ++var getContour = require('simplicial-complex-contour') ++var pool = require('typedarray-pool') ++var shaders = require('./lib/shaders') ++var closestPoint = require('./lib/closest-point') ++ ++var meshShader = shaders.meshShader ++var wireShader = shaders.wireShader ++var pointShader = shaders.pointShader ++var pickShader = shaders.pickShader ++var pointPickShader = shaders.pointPickShader ++var contourShader = shaders.contourShader ++ ++var identityMatrix = [ ++ 1,0,0,0, ++ 0,1,0,0, ++ 0,0,1,0, ++ 0,0,0,1] ++ ++function SimplicialMesh(gl ++ , texture ++ , triShader ++ , lineShader ++ , pointShader ++ , pickShader ++ , pointPickShader ++ , contourShader ++ , trianglePositions ++ , triangleIds ++ , triangleColors ++ , triangleUVs ++ , triangleNormals ++ , triangleVAO ++ , edgePositions ++ , edgeIds ++ , edgeColors ++ , edgeUVs ++ , edgeVAO ++ , pointPositions ++ , pointIds ++ , pointColors ++ , pointUVs ++ , pointSizes ++ , pointVAO ++ , contourPositions ++ , contourVAO) { ++ ++ this.gl = gl ++ this.cells = [] ++ this.positions = [] ++ this.intensity = [] ++ this.texture = texture ++ this.dirty = true ++ ++ this.triShader = triShader ++ this.lineShader = lineShader ++ this.pointShader = pointShader ++ this.pickShader = pickShader ++ this.pointPickShader = pointPickShader ++ this.contourShader = contourShader ++ ++ this.trianglePositions = trianglePositions ++ this.triangleColors = triangleColors ++ this.triangleNormals = triangleNormals ++ this.triangleUVs = triangleUVs ++ this.triangleIds = triangleIds ++ this.triangleVAO = triangleVAO ++ this.triangleCount = 0 ++ ++ this.lineWidth = 1 ++ this.edgePositions = edgePositions ++ this.edgeColors = edgeColors ++ this.edgeUVs = edgeUVs ++ this.edgeIds = edgeIds ++ this.edgeVAO = edgeVAO ++ this.edgeCount = 0 ++ ++ this.pointPositions = pointPositions ++ this.pointColors = pointColors ++ this.pointUVs = pointUVs ++ this.pointSizes = pointSizes ++ this.pointIds = pointIds ++ this.pointVAO = pointVAO ++ this.pointCount = 0 ++ ++ this.contourLineWidth = 1 ++ this.contourPositions = contourPositions ++ this.contourVAO = contourVAO ++ this.contourCount = 0 ++ this.contourColor = [0,0,0] ++ this.contourEnable = true ++ ++ this.pickId = 1 ++ this.bounds = [ ++ [ Infinity, Infinity, Infinity], ++ [-Infinity,-Infinity,-Infinity] ] ++ this.clipBounds = [ ++ [-Infinity,-Infinity,-Infinity], ++ [ Infinity, Infinity, Infinity] ] ++ ++ this.lightPosition = [1e5, 1e5, 0] ++ this.ambientLight = 0.8 ++ this.diffuseLight = 0.8 ++ this.specularLight = 2.0 ++ this.roughness = 0.5 ++ this.fresnel = 1.5 ++ ++ this.opacity = 1.0 ++ ++ this._model = identityMatrix ++ this._view = identityMatrix ++ this._projection = identityMatrix ++ this._resolution = [1,1] ++} ++ ++var proto = SimplicialMesh.prototype ++ ++proto.isOpaque = function() { ++ return this.opacity >= 1 ++} ++ ++proto.isTransparent = function() { ++ return this.opacity < 1 ++} ++ ++proto.pickSlots = 1 ++ ++proto.setPickBase = function(id) { ++ this.pickId = id ++} ++ ++function genColormap(param) { ++ var colors = colormap({ ++ colormap: param ++ , nshades: 256 ++ , format: 'rgba' ++ }) ++ ++ var result = new Uint8Array(256*4) ++ for(var i=0; i<256; ++i) { ++ var c = colors[i] ++ for(var j=0; j<3; ++j) { ++ result[4*i+j] = c[j] + } ++ result[4*i+3] = c[3]*255 + } +- +- storePivot("left", "(less-1)", 1) +- storePivot("right", "(great+1)", 2) + +- //Recursive sort call +- function doSort(left, right) { +- code.push([ +- "if((",right,"-",left,")<=",INSERTION_SORT_THRESHOLD,"){\n", +- "insertionSort(", left, ",", right, ",data,offset,", shapeArgs(order.length).join(","), ")\n", +- "}else{\n", +- funcName, "(", left, ",", right, ",data,offset,", shapeArgs(order.length).join(","), ")\n", +- "}" +- ].join("")) ++ return ndarray(result, [256,256,4], [4,0,1]) ++} ++ ++function unpackIntensity(cells, numVerts, cellIntensity) { ++ var result = new Array(numVerts) ++ for(var i=0; i 1) { +- code.push(["__l",++labelCounter,":while(true){"].join("")) +- cacheLoop([ptr], true, [ +- "if(", dataRead("ptr0"), "!==pivot", pivot, "[pivot_ptr]){break __l", labelCounter, "}" +- ].join("")) +- code.push(body, "}") +- } else { +- code.push(["while(", dataRead(toPointer(ptr)), "===pivot", pivot, "){", body, "}"].join("")) ++ var numCells = cells.length ++ for(var i=0; iindex5){") +- +- walkPointer("less", 1, "++less") +- walkPointer("great", 2, "--great") +- +- code.push("for(k=less;k<=great;++k){") +- comparePivot("comp_pivot1", "k", 1) +- code.push("if(comp_pivot1===0){") +- code.push("if(k!==less){") +- swapElements("k", "less") +- code.push("}") +- code.push("++less") +- code.push("}else{") +- comparePivot("comp_pivot2", "k", 2) +- code.push("if(comp_pivot2===0){") +- code.push("while(true){") +- comparePivot("comp", "great", 2) +- code.push("if(comp===0){") +- code.push("if(--great 1 && allocator) { +- var compiled = new Function("insertionSort", "malloc", "free", code.join("\n")) +- return compiled(insertionSort, allocator[0], allocator[1]) +- } +- var compiled = new Function("insertionSort", code.join("\n")) +- return compiled(insertionSort) ++ return result + } + +-function compileSort(order, dtype) { +- var code = ["'use strict'"] +- var funcName = ["ndarraySortWrapper", order.join("d"), dtype].join("") +- var funcArgs = [ "array" ] +- +- code.push(["function ", funcName, "(", funcArgs.join(","), "){"].join("")) +- +- //Unpack local variables from array +- var vars = ["data=array.data,offset=array.offset|0,shape=array.shape,stride=array.stride"] +- for(var i=0; i 0) { +- vars.push(["d",j,"=s",j,"-d",p,"*n",p].join("")) +- } else { +- vars.push(["d",j,"=s",j].join("")) ++ var level = getContour(this.cells, this.intensity, selection.intensity) ++ var cells = level.cells ++ var vertexIds = level.vertexIds ++ var vertexWeights = level.vertexWeights ++ var numCells = cells.length ++ var result = pool.mallocFloat32(2 * 3 * numCells) ++ var ptr = 0 ++ for(var i=0; i 0) { +- vars.push(["e",k,"=s",k,"-e",q,"*n",q, +- ",f",k,"=",scratch_stride[k],"-f",q,"*n",q].join("")) +- } else { +- vars.push(["e",k,"=s",k,",f",k,"=",scratch_stride[k]].join("")) ++ var a = vertexIds[v][0] ++ var b = vertexIds[v][1] ++ var w = vertexWeights[v] ++ var wi = 1.0 - w ++ var pa = this.positions[a] ++ var pb = this.positions[b] ++ for(var k=0; k<3; ++k) { ++ result[ptr++] = w * pa[k] + wi * pb[k] + } +- q = k + } + } +- +- //Declare local variables +- code.push("var " + vars.join(",")) +- +- //Create arguments for subroutine +- var sortArgs = ["0", "n0-1", "data", "offset"].concat(shapeArgs(order.length)) +- +- //Call main sorting routine +- code.push([ +- "if(n0<=",INSERTION_SORT_THRESHOLD,"){", +- "insertionSort(", sortArgs.join(","), ")}else{", +- "quickSort(", sortArgs.join(","), +- ")}" +- ].join("")) +- +- //Return +- code.push("}return " + funcName) +- +- //Link everything together +- var result = new Function("insertionSort", "quickSort", code.join("\n")) +- var insertionSort = createInsertionSort(order, dtype) +- var quickSort = createQuickSort(order, dtype, insertionSort) +- return result(insertionSort, quickSort) ++ this.contourCount = (ptr / 3)|0 ++ this.contourPositions.update(result.subarray(0, ptr)) ++ pool.free(result) + } + +-module.exports = compileSort +-},{"typedarray-pool":242}],141:[function(require,module,exports){ +-"use strict" ++proto.update = function(params) { ++ params = params || {} ++ var gl = this.gl + +-var compile = require("./lib/compile_sort.js") +-var CACHE = {} ++ this.dirty = true + +-function sort(array) { +- var order = array.order +- var dtype = array.dtype +- var typeSig = [order, dtype ] +- var typeName = typeSig.join(":") +- var compiled = CACHE[typeName] +- if(!compiled) { +- CACHE[typeName] = compiled = compile(order, dtype) ++ if('contourEnable' in params) { ++ this.contourEnable = params.contourEnable + } +- compiled(array) +- return array +-} +- +-module.exports = sort +-},{"./lib/compile_sort.js":140}],142:[function(require,module,exports){ +- +-var createShader = require('gl-shader') +- +-var vertSrc = "precision mediump float;\n#define GLSLIFY 1\nattribute vec2 position;\nvarying vec2 uv;\nvoid main() {\n uv = position;\n gl_Position = vec4(position, 0, 1);\n}" +-var fragSrc = "precision mediump float;\n#define GLSLIFY 1\n\nuniform sampler2D accumBuffer;\nvarying vec2 uv;\n\nvoid main() {\n vec4 accum = texture2D(accumBuffer, 0.5 * (uv + 1.0));\n gl_FragColor = min(vec4(1,1,1,1), accum);\n}" +- +-module.exports = function(gl) { +- return createShader(gl, vertSrc, fragSrc, null, [ { name: 'position', type: 'vec2'}]) +-} +- +-},{"gl-shader":164}],143:[function(require,module,exports){ +-'use strict' +- +-module.exports = createCamera +- +-var now = require('right-now') +-var createView = require('3d-view') +-var mouseChange = require('mouse-change') +-var mouseWheel = require('mouse-wheel') +- +-function createCamera(element, options) { +- element = element || document.body +- options = options || {} +- +- var limits = [ 0.01, Infinity ] +- if('distanceLimits' in options) { +- limits[0] = options.distanceLimits[0] +- limits[1] = options.distanceLimits[1] ++ if('contourColor' in params) { ++ this.contourColor = params.contourColor + } +- if('zoomMin' in options) { +- limits[0] = options.zoomMin ++ if('lineWidth' in params) { ++ this.lineWidth = params.lineWidth + } +- if('zoomMax' in options) { +- limits[1] = options.zoomMax ++ if('lightPosition' in params) { ++ this.lightPosition = params.lightPosition ++ } ++ if('opacity' in params) { ++ this.opacity = params.opacity ++ } ++ if('ambient' in params) { ++ this.ambientLight = params.ambient ++ } ++ if('diffuse' in params) { ++ this.diffuseLight = params.diffuse ++ } ++ if('specular' in params) { ++ this.specularLight = params.specular ++ } ++ if('roughness' in params) { ++ this.roughness = params.roughness ++ } ++ if('fresnel' in params) { ++ this.fresnel = params.fresnel + } + +- var view = createView({ +- center: options.center || [0,0,0], +- up: options.up || [0,1,0], +- eye: options.eye || [0,0,10], +- mode: options.mode || 'orbit', +- distanceLimits: limits +- }) ++ if(params.texture) { ++ this.texture.dispose() ++ this.texture = createTexture(gl, params.texture) ++ } else if (params.colormap) { ++ this.texture.shape = [256,256] ++ this.texture.minFilter = gl.LINEAR_MIPMAP_LINEAR ++ this.texture.magFilter = gl.LINEAR ++ this.texture.setPixels(genColormap(params.colormap)) ++ this.texture.generateMipmap() ++ } + +- var pmatrix = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] +- var distance = 0.0 +- var width = element.clientWidth +- var height = element.clientHeight ++ var cells = params.cells ++ var positions = params.positions + +- var camera = { +- view: view, +- element: element, +- delay: options.delay || 16, +- rotateSpeed: options.rotateSpeed || 1, +- zoomSpeed: options.zoomSpeed || 1, +- translateSpeed: options.translateSpeed || 1, +- flipX: !!options.flipX, +- flipY: !!options.flipY, +- modes: view.modes, +- tick: function() { +- var t = now() +- var delay = this.delay +- view.idle(t-delay) +- view.flush(t-(100+delay*2)) +- var ctime = t - 2 * delay +- view.recalcMatrix(ctime) +- var allEqual = true +- var matrix = view.computedMatrix +- for(var i=0; i<16; ++i) { +- allEqual = allEqual && (pmatrix[i] === matrix[i]) +- pmatrix[i] = matrix[i] +- } +- var sizeChanged = +- element.clientWidth === width && +- element.clientHeight === height +- width = element.clientWidth +- height = element.clientHeight +- if(allEqual) { +- return !sizeChanged +- } +- distance = Math.exp(view.computedRadius[0]) +- return true +- }, +- lookAt: function(center, eye, up) { +- view.lookAt(view.lastT(), center, eye, up) +- }, +- rotate: function(pitch, yaw, roll) { +- view.rotate(view.lastT(), pitch, yaw, roll) +- }, +- pan: function(dx, dy, dz) { +- view.pan(view.lastT(), dx, dy, dz) +- }, +- translate: function(dx, dy, dz) { +- view.translate(view.lastT(), dx, dy, dz) +- } ++ if(!positions || !cells) { ++ return + } + +- Object.defineProperties(camera, { +- matrix: { +- get: function() { +- return view.computedMatrix +- }, +- set: function(mat) { +- view.setMatrix(view.lastT(), mat) +- return view.computedMatrix +- }, +- enumerable: true +- }, +- mode: { +- get: function() { +- return view.getMode() +- }, +- set: function(mode) { +- view.setMode(mode) +- return view.getMode() +- }, +- enumerable: true +- }, +- center: { +- get: function() { +- return view.computedCenter +- }, +- set: function(ncenter) { +- view.lookAt(view.lastT(), ncenter) +- return view.computedCenter +- }, +- enumerable: true +- }, +- eye: { +- get: function() { +- return view.computedEye +- }, +- set: function(neye) { +- view.lookAt(view.lastT(), null, neye) +- return view.computedEye +- }, +- enumerable: true +- }, +- up: { +- get: function() { +- return view.computedUp +- }, +- set: function(nup) { +- view.lookAt(view.lastT(), null, null, nup) +- return view.computedUp +- }, +- enumerable: true +- }, +- distance: { +- get: function() { +- return distance +- }, +- set: function(d) { +- view.setDistance(view.lastT(), d) +- return d +- }, +- enumerable: true +- }, +- distanceLimits: { +- get: function() { +- return view.getDistanceLimits(limits) +- }, +- set: function(v) { +- view.setDistanceLimits(v) +- return v +- }, +- enumerable: true +- } +- }) +- +- element.addEventListener('contextmenu', function(ev) { +- ev.preventDefault() +- return false +- }) ++ var tPos = [] ++ var tCol = [] ++ var tNor = [] ++ var tUVs = [] ++ var tIds = [] + +- var lastX = 0, lastY = 0 +- mouseChange(element, function(buttons, x, y, mods) { +- var scale = 1.0 / element.clientHeight +- var dx = scale * (x - lastX) +- var dy = scale * (y - lastY) ++ var ePos = [] ++ var eCol = [] ++ var eUVs = [] ++ var eIds = [] ++ ++ var pPos = [] ++ var pCol = [] ++ var pUVs = [] ++ var pSiz = [] ++ var pIds = [] ++ ++ //Save geometry data for picking calculations ++ this.cells = cells ++ this.positions = positions + +- var flipX = camera.flipX ? 1 : -1 +- var flipY = camera.flipY ? 1 : -1 ++ //Compute normals ++ var vertexNormals = params.vertexNormals ++ var cellNormals = params.cellNormals ++ var vertexNormalsEpsilon = params.vertexNormalsEpsilon === void(0) ? DEFAULT_VERTEX_NORMALS_EPSILON : params.vertexNormalsEpsilon ++ var faceNormalsEpsilon = params.faceNormalsEpsilon === void(0) ? DEFAULT_FACE_NORMALS_EPSILON : params.faceNormalsEpsilon ++ if(params.useFacetNormals && !cellNormals) { ++ cellNormals = normals.faceNormals(cells, positions, faceNormalsEpsilon) ++ } ++ if(!cellNormals && !vertexNormals) { ++ vertexNormals = normals.vertexNormals(cells, positions, vertexNormalsEpsilon) ++ } + +- var drot = Math.PI * camera.rotateSpeed ++ //Compute colors ++ var vertexColors = params.vertexColors ++ var cellColors = params.cellColors ++ var meshColor = params.meshColor || [1,1,1,1] + +- var t = now() ++ //UVs ++ var vertexUVs = params.vertexUVs ++ var vertexIntensity = params.vertexIntensity ++ var cellUVs = params.cellUVs ++ var cellIntensity = params.cellIntensity + +- if(buttons & 1) { +- if(mods.shift) { +- view.rotate(t, 0, 0, -dx * drot) +- } else { +- view.rotate(t, flipX * drot * dx, -flipY * drot * dy, 0) ++ var intensityLo = Infinity ++ var intensityHi = -Infinity ++ if(!vertexUVs && !cellUVs) { ++ if(vertexIntensity) { ++ for(var i=0; i Math.abs(dy)) { +- view.rotate(t, 0, 0, -dx * flipX * Math.PI * camera.rotateSpeed / window.innerWidth) +- } else { +- var kzoom = camera.zoomSpeed * flipY * dy / window.innerHeight * (t - view.lastT()) / 100.0 +- view.pan(t, 0, 0, distance * (Math.exp(kzoom) - 1)) ++ //Point size ++ var pointSizes = params.pointSizes ++ var meshPointSize = params.pointSize || 1.0 ++ ++ //Update bounds ++ this.bounds = [[Infinity,Infinity,Infinity], [-Infinity,-Infinity,-Infinity]] ++ for(var i=0; iAssumes that an ES5 platform where, if {@code WeakMap} is +- * already present, then it conforms to the anticipated ES6 +- * specification. To run this file on an ES5 or almost ES5 +- * implementation where the {@code WeakMap} specification does not +- * quite conform, run repairES5.js first. +- * +- *

Even though WeakMapModule is not global, the linter thinks it +- * is, which is why it is in the overrides list below. +- * +- *

NOTE: Before using this WeakMap emulation in a non-SES +- * environment, see the note below about hiddenRecord. +- * +- * @author Mark S. Miller +- * @requires crypto, ArrayBuffer, Uint8Array, navigator, console +- * @overrides WeakMap, ses, Proxy +- * @overrides WeakMapModule +- */ ++fill_loop: ++ for(var i=0; iAs with true WeakMaps, in this emulation, a key does not +- * retain maps indexed by that key and (crucially) a map does not +- * retain the keys it indexes. A map by itself also does not retain +- * the values associated with that map. +- * +- *

However, the values associated with a key in some map are +- * retained so long as that key is retained and those associations are +- * not overridden. For example, when used to support membranes, all +- * values exported from a given membrane will live for the lifetime +- * they would have had in the absence of an interposed membrane. Even +- * when the membrane is revoked, all objects that would have been +- * reachable in the absence of revocation will still be reachable, as +- * far as the GC can tell, even though they will no longer be relevant +- * to ongoing computation. +- * +- *

The API implemented here is approximately the API as implemented +- * in FF6.0a1 and agreed to by MarkM, Andreas Gal, and Dave Herman, +- * rather than the offially approved proposal page. TODO(erights): +- * upgrade the ecmascript WeakMap proposal page to explain this API +- * change and present to EcmaScript committee for their approval. +- * +- *

The first difference between the emulation here and that in +- * FF6.0a1 is the presence of non enumerable {@code get___, has___, +- * set___, and delete___} methods on WeakMap instances to represent +- * what would be the hidden internal properties of a primitive +- * implementation. Whereas the FF6.0a1 WeakMap.prototype methods +- * require their {@code this} to be a genuine WeakMap instance (i.e., +- * an object of {@code [[Class]]} "WeakMap}), since there is nothing +- * unforgeable about the pseudo-internal method names used here, +- * nothing prevents these emulated prototype methods from being +- * applied to non-WeakMaps with pseudo-internal methods of the same +- * names. +- * +- *

Another difference is that our emulated {@code +- * WeakMap.prototype} is not itself a WeakMap. A problem with the +- * current FF6.0a1 API is that WeakMap.prototype is itself a WeakMap +- * providing ambient mutability and an ambient communications +- * channel. Thus, if a WeakMap is already present and has this +- * problem, repairES5.js wraps it in a safe wrappper in order to +- * prevent access to this channel. (See +- * PATCH_MUTABLE_FROZEN_WEAKMAP_PROTO in repairES5.js). +- */ ++ var v = cell[0] ++ var p = positions[v] + +-/** +- * If this is a full secureable ES5 platform and the ES-Harmony {@code WeakMap} is +- * absent, install an approximate emulation. +- * +- *

If WeakMap is present but cannot store some objects, use our approximate +- * emulation as a wrapper. +- * +- *

If this is almost a secureable ES5 platform, then WeakMap.js +- * should be run after repairES5.js. +- * +- *

See {@code WeakMap} for documentation of the garbage collection +- * properties of this WeakMap emulation. +- */ +-(function WeakMapModule() { +- "use strict"; ++ //Check NaNs ++ for(var j=0; j<3; ++j) { ++ if(isNaN(p[j]) || !isFinite(p[j])) { ++ continue fill_loop ++ } ++ } + +- if (typeof ses !== 'undefined' && ses.ok && !ses.ok()) { +- // already too broken, so give up +- return; +- } ++ pPos.push(p[0], p[1], p[2]) + +- /** +- * In some cases (current Firefox), we must make a choice betweeen a +- * WeakMap which is capable of using all varieties of host objects as +- * keys and one which is capable of safely using proxies as keys. See +- * comments below about HostWeakMap and DoubleWeakMap for details. +- * +- * This function (which is a global, not exposed to guests) marks a +- * WeakMap as permitted to do what is necessary to index all host +- * objects, at the cost of making it unsafe for proxies. +- * +- * Do not apply this function to anything which is not a genuine +- * fresh WeakMap. +- */ +- function weakMapPermitHostObjects(map) { +- // identity of function used as a secret -- good enough and cheap +- if (map.permitHostObjects___) { +- map.permitHostObjects___(weakMapPermitHostObjects); +- } +- } +- if (typeof ses !== 'undefined') { +- ses.weakMapPermitHostObjects = weakMapPermitHostObjects; +- } ++ var c ++ if(vertexColors) { ++ c = vertexColors[v] ++ } else if(cellColors) { ++ c = cellColors[i] ++ } else { ++ c = meshColor ++ } ++ if(c.length === 3) { ++ pCol.push(c[0], c[1], c[2], 1) ++ } else { ++ pCol.push(c[0], c[1], c[2], c[3]) ++ } + +- // IE 11 has no Proxy but has a broken WeakMap such that we need to patch +- // it using DoubleWeakMap; this flag tells DoubleWeakMap so. +- var doubleWeakMapCheckSilentFailure = false; ++ var uv ++ if(vertexUVs) { ++ uv = vertexUVs[v] ++ } else if(vertexIntensity) { ++ uv = [ ++ (vertexIntensity[v] - intensityLo) / ++ (intensityHi - intensityLo), 0] ++ } else if(cellUVs) { ++ uv = cellUVs[i] ++ } else if(cellIntensity) { ++ uv = [ ++ (cellIntensity[i] - intensityLo) / ++ (intensityHi - intensityLo), 0] ++ } else { ++ uv = [ ++ (p[2] - intensityLo) / ++ (intensityHi - intensityLo), 0] ++ } ++ pUVs.push(uv[0], uv[1]) + +- // Check if there is already a good-enough WeakMap implementation, and if so +- // exit without replacing it. +- if (typeof WeakMap === 'function') { +- var HostWeakMap = WeakMap; +- // There is a WeakMap -- is it good enough? +- if (typeof navigator !== 'undefined' && +- /Firefox/.test(navigator.userAgent)) { +- // We're now *assuming not*, because as of this writing (2013-05-06) +- // Firefox's WeakMaps have a miscellany of objects they won't accept, and +- // we don't want to make an exhaustive list, and testing for just one +- // will be a problem if that one is fixed alone (as they did for Event). ++ if(pointSizes) { ++ pSiz.push(pointSizes[v]) ++ } else { ++ pSiz.push(meshPointSize) ++ } + +- // If there is a platform that we *can* reliably test on, here's how to +- // do it: +- // var problematic = ... ; +- // var testHostMap = new HostWeakMap(); +- // try { +- // testHostMap.set(problematic, 1); // Firefox 20 will throw here +- // if (testHostMap.get(problematic) === 1) { +- // return; +- // } +- // } catch (e) {} ++ pIds.push(i) + +- } else { +- // IE 11 bug: WeakMaps silently fail to store frozen objects. +- var testMap = new HostWeakMap(); +- var testObject = Object.freeze({}); +- testMap.set(testObject, 1); +- if (testMap.get(testObject) !== 1) { +- doubleWeakMapCheckSilentFailure = true; +- // Fall through to installing our WeakMap. +- } else { +- module.exports = WeakMap; +- return; +- } +- } +- } ++ pointCount += 1 ++ break + +- var hop = Object.prototype.hasOwnProperty; +- var gopn = Object.getOwnPropertyNames; +- var defProp = Object.defineProperty; +- var isExtensible = Object.isExtensible; ++ case 2: + +- /** +- * Security depends on HIDDEN_NAME being both unguessable and +- * undiscoverable by untrusted code. +- * +- *

Given the known weaknesses of Math.random() on existing +- * browsers, it does not generate unguessability we can be confident +- * of. +- * +- *

It is the monkey patching logic in this file that is intended +- * to ensure undiscoverability. The basic idea is that there are +- * three fundamental means of discovering properties of an object: +- * The for/in loop, Object.keys(), and Object.getOwnPropertyNames(), +- * as well as some proposed ES6 extensions that appear on our +- * whitelist. The first two only discover enumerable properties, and +- * we only use HIDDEN_NAME to name a non-enumerable property, so the +- * only remaining threat should be getOwnPropertyNames and some +- * proposed ES6 extensions that appear on our whitelist. We monkey +- * patch them to remove HIDDEN_NAME from the list of properties they +- * returns. +- * +- *

TODO(erights): On a platform with built-in Proxies, proxies +- * could be used to trap and thereby discover the HIDDEN_NAME, so we +- * need to monkey patch Proxy.create, Proxy.createFunction, etc, in +- * order to wrap the provided handler with the real handler which +- * filters out all traps using HIDDEN_NAME. +- * +- *

TODO(erights): Revisit Mike Stay's suggestion that we use an +- * encapsulated function at a not-necessarily-secret name, which +- * uses the Stiegler shared-state rights amplification pattern to +- * reveal the associated value only to the WeakMap in which this key +- * is associated with that value. Since only the key retains the +- * function, the function can also remember the key without causing +- * leakage of the key, so this doesn't violate our general gc +- * goals. In addition, because the name need not be a guarded +- * secret, we could efficiently handle cross-frame frozen keys. +- */ +- var HIDDEN_NAME_PREFIX = 'weakmap:'; +- var HIDDEN_NAME = HIDDEN_NAME_PREFIX + 'ident:' + Math.random() + '___'; ++ //Check NaNs ++ for(var j=0; j<2; ++j) { ++ var v = cell[j] ++ var p = positions[v] ++ for(var k=0; k<3; ++k) { ++ if(isNaN(p[k]) || !isFinite(p[k])) { ++ continue fill_loop ++ } ++ } ++ } + +- if (typeof crypto !== 'undefined' && +- typeof crypto.getRandomValues === 'function' && +- typeof ArrayBuffer === 'function' && +- typeof Uint8Array === 'function') { +- var ab = new ArrayBuffer(25); +- var u8s = new Uint8Array(ab); +- crypto.getRandomValues(u8s); +- HIDDEN_NAME = HIDDEN_NAME_PREFIX + 'rand:' + +- Array.prototype.map.call(u8s, function(u8) { +- return (u8 % 36).toString(36); +- }).join('') + '___'; +- } ++ for(var j=0; j<2; ++j) { ++ var v = cell[j] ++ var p = positions[v] + +- function isNotHiddenName(name) { +- return !( +- name.substr(0, HIDDEN_NAME_PREFIX.length) == HIDDEN_NAME_PREFIX && +- name.substr(name.length - 3) === '___'); +- } ++ ePos.push(p[0], p[1], p[2]) + +- /** +- * Monkey patch getOwnPropertyNames to avoid revealing the +- * HIDDEN_NAME. +- * +- *

The ES5.1 spec requires each name to appear only once, but as +- * of this writing, this requirement is controversial for ES6, so we +- * made this code robust against this case. If the resulting extra +- * search turns out to be expensive, we can probably relax this once +- * ES6 is adequately supported on all major browsers, iff no browser +- * versions we support at that time have relaxed this constraint +- * without providing built-in ES6 WeakMaps. +- */ +- defProp(Object, 'getOwnPropertyNames', { +- value: function fakeGetOwnPropertyNames(obj) { +- return gopn(obj).filter(isNotHiddenName); +- } +- }); ++ var c ++ if(vertexColors) { ++ c = vertexColors[v] ++ } else if(cellColors) { ++ c = cellColors[i] ++ } else { ++ c = meshColor ++ } ++ if(c.length === 3) { ++ eCol.push(c[0], c[1], c[2], 1) ++ } else { ++ eCol.push(c[0], c[1], c[2], c[3]) ++ } + +- /** +- * getPropertyNames is not in ES5 but it is proposed for ES6 and +- * does appear in our whitelist, so we need to clean it too. +- */ +- if ('getPropertyNames' in Object) { +- var originalGetPropertyNames = Object.getPropertyNames; +- defProp(Object, 'getPropertyNames', { +- value: function fakeGetPropertyNames(obj) { +- return originalGetPropertyNames(obj).filter(isNotHiddenName); +- } +- }); +- } ++ var uv ++ if(vertexUVs) { ++ uv = vertexUVs[v] ++ } else if(vertexIntensity) { ++ uv = [ ++ (vertexIntensity[v] - intensityLo) / ++ (intensityHi - intensityLo), 0] ++ } else if(cellUVs) { ++ uv = cellUVs[i] ++ } else if(cellIntensity) { ++ uv = [ ++ (cellIntensity[i] - intensityLo) / ++ (intensityHi - intensityLo), 0] ++ } else { ++ uv = [ ++ (p[2] - intensityLo) / ++ (intensityHi - intensityLo), 0] ++ } ++ eUVs.push(uv[0], uv[1]) + +- /** +- *

To treat objects as identity-keys with reasonable efficiency +- * on ES5 by itself (i.e., without any object-keyed collections), we +- * need to add a hidden property to such key objects when we +- * can. This raises several issues: +- *

    +- *
  • Arranging to add this property to objects before we lose the +- * chance, and +- *
  • Hiding the existence of this new property from most +- * JavaScript code. +- *
  • Preventing certification theft, where one object is +- * created falsely claiming to be the key of an association +- * actually keyed by another object. +- *
  • Preventing value theft, where untrusted code with +- * access to a key object but not a weak map nevertheless +- * obtains access to the value associated with that key in that +- * weak map. +- *
+- * We do so by +- *
    +- *
  • Making the name of the hidden property unguessable, so "[]" +- * indexing, which we cannot intercept, cannot be used to access +- * a property without knowing the name. +- *
  • Making the hidden property non-enumerable, so we need not +- * worry about for-in loops or {@code Object.keys}, +- *
  • monkey patching those reflective methods that would +- * prevent extensions, to add this hidden property first, +- *
  • monkey patching those methods that would reveal this +- * hidden property. +- *
+- * Unfortunately, because of same-origin iframes, we cannot reliably +- * add this hidden property before an object becomes +- * non-extensible. Instead, if we encounter a non-extensible object +- * without a hidden record that we can detect (whether or not it has +- * a hidden record stored under a name secret to us), then we just +- * use the key object itself to represent its identity in a brute +- * force leaky map stored in the weak map, losing all the advantages +- * of weakness for these. +- */ +- function getHiddenRecord(key) { +- if (key !== Object(key)) { +- throw new TypeError('Not an object: ' + key); +- } +- var hiddenRecord = key[HIDDEN_NAME]; +- if (hiddenRecord && hiddenRecord.key === key) { return hiddenRecord; } +- if (!isExtensible(key)) { +- // Weak map must brute force, as explained in doc-comment above. +- return void 0; +- } ++ eIds.push(i) ++ } ++ edgeCount += 1 ++ break ++ ++ case 3: ++ //Check NaNs ++ for(var j=0; j<3; ++j) { ++ var v = cell[j] ++ var p = positions[v] ++ for(var k=0; k<3; ++k) { ++ if(isNaN(p[k]) || !isFinite(p[k])) { ++ continue fill_loop ++ } ++ } ++ } + +- // The hiddenRecord and the key point directly at each other, via +- // the "key" and HIDDEN_NAME properties respectively. The key +- // field is for quickly verifying that this hidden record is an +- // own property, not a hidden record from up the prototype chain. +- // +- // NOTE: Because this WeakMap emulation is meant only for systems like +- // SES where Object.prototype is frozen without any numeric +- // properties, it is ok to use an object literal for the hiddenRecord. +- // This has two advantages: +- // * It is much faster in a performance critical place +- // * It avoids relying on Object.create(null), which had been +- // problematic on Chrome 28.0.1480.0. See +- // https://code.google.com/p/google-caja/issues/detail?id=1687 +- hiddenRecord = { key: key }; ++ for(var j=0; j<3; ++j) { ++ var v = cell[j] + +- // When using this WeakMap emulation on platforms where +- // Object.prototype might not be frozen and Object.create(null) is +- // reliable, use the following two commented out lines instead. +- // hiddenRecord = Object.create(null); +- // hiddenRecord.key = key; ++ var p = positions[v] ++ tPos.push(p[0], p[1], p[2]) + +- // Please contact us if you need this to work on platforms where +- // Object.prototype might not be frozen and +- // Object.create(null) might not be reliable. ++ var c ++ if(vertexColors) { ++ c = vertexColors[v] ++ } else if(cellColors) { ++ c = cellColors[i] ++ } else { ++ c = meshColor ++ } ++ if(c.length === 3) { ++ tCol.push(c[0], c[1], c[2], 1) ++ } else { ++ tCol.push(c[0], c[1], c[2], c[3]) ++ } + +- try { +- defProp(key, HIDDEN_NAME, { +- value: hiddenRecord, +- writable: false, +- enumerable: false, +- configurable: false +- }); +- return hiddenRecord; +- } catch (error) { +- // Under some circumstances, isExtensible seems to misreport whether +- // the HIDDEN_NAME can be defined. +- // The circumstances have not been isolated, but at least affect +- // Node.js v0.10.26 on TravisCI / Linux, but not the same version of +- // Node.js on OS X. +- return void 0; +- } +- } ++ var uv ++ if(vertexUVs) { ++ uv = vertexUVs[v] ++ } else if(vertexIntensity) { ++ uv = [ ++ (vertexIntensity[v] - intensityLo) / ++ (intensityHi - intensityLo), 0] ++ } else if(cellUVs) { ++ uv = cellUVs[i] ++ } else if(cellIntensity) { ++ uv = [ ++ (cellIntensity[i] - intensityLo) / ++ (intensityHi - intensityLo), 0] ++ } else { ++ uv = [ ++ (p[2] - intensityLo) / ++ (intensityHi - intensityLo), 0] ++ } ++ tUVs.push(uv[0], uv[1]) + +- /** +- * Monkey patch operations that would make their argument +- * non-extensible. +- * +- *

The monkey patched versions throw a TypeError if their +- * argument is not an object, so it should only be done to functions +- * that should throw a TypeError anyway if their argument is not an +- * object. +- */ +- (function(){ +- var oldFreeze = Object.freeze; +- defProp(Object, 'freeze', { +- value: function identifyingFreeze(obj) { +- getHiddenRecord(obj); +- return oldFreeze(obj); +- } +- }); +- var oldSeal = Object.seal; +- defProp(Object, 'seal', { +- value: function identifyingSeal(obj) { +- getHiddenRecord(obj); +- return oldSeal(obj); +- } +- }); +- var oldPreventExtensions = Object.preventExtensions; +- defProp(Object, 'preventExtensions', { +- value: function identifyingPreventExtensions(obj) { +- getHiddenRecord(obj); +- return oldPreventExtensions(obj); +- } +- }); +- })(); ++ var q ++ if(vertexNormals) { ++ q = vertexNormals[v] ++ } else { ++ q = cellNormals[i] ++ } ++ tNor.push(q[0], q[1], q[2]) + +- function constFunc(func) { +- func.prototype = null; +- return Object.freeze(func); +- } ++ tIds.push(i) ++ } ++ triangleCount += 1 ++ break + +- var calledAsFunctionWarningDone = false; +- function calledAsFunctionWarning() { +- // Future ES6 WeakMap is currently (2013-09-10) expected to reject WeakMap() +- // but we used to permit it and do it ourselves, so warn only. +- if (!calledAsFunctionWarningDone && typeof console !== 'undefined') { +- calledAsFunctionWarningDone = true; +- console.warn('WeakMap should be invoked as new WeakMap(), not ' + +- 'WeakMap(). This will be an error in the future.'); ++ default: ++ break + } + } + +- var nextId = 0; ++ this.pointCount = pointCount ++ this.edgeCount = edgeCount ++ this.triangleCount = triangleCount + +- var OurWeakMap = function() { +- if (!(this instanceof OurWeakMap)) { // approximate test for new ...() +- calledAsFunctionWarning(); +- } ++ this.pointPositions.update(pPos) ++ this.pointColors.update(pCol) ++ this.pointUVs.update(pUVs) ++ this.pointSizes.update(pSiz) ++ this.pointIds.update(new Uint32Array(pIds)) + +- // We are currently (12/25/2012) never encountering any prematurely +- // non-extensible keys. +- var keys = []; // brute force for prematurely non-extensible keys. +- var values = []; // brute force for corresponding values. +- var id = nextId++; ++ this.edgePositions.update(ePos) ++ this.edgeColors.update(eCol) ++ this.edgeUVs.update(eUVs) ++ this.edgeIds.update(new Uint32Array(eIds)) + +- function get___(key, opt_default) { +- var index; +- var hiddenRecord = getHiddenRecord(key); +- if (hiddenRecord) { +- return id in hiddenRecord ? hiddenRecord[id] : opt_default; +- } else { +- index = keys.indexOf(key); +- return index >= 0 ? values[index] : opt_default; +- } +- } ++ this.trianglePositions.update(tPos) ++ this.triangleColors.update(tCol) ++ this.triangleUVs.update(tUVs) ++ this.triangleNormals.update(tNor) ++ this.triangleIds.update(new Uint32Array(tIds)) ++} + +- function has___(key) { +- var hiddenRecord = getHiddenRecord(key); +- if (hiddenRecord) { +- return id in hiddenRecord; +- } else { +- return keys.indexOf(key) >= 0; +- } +- } ++proto.drawTransparent = proto.draw = function(params) { ++ params = params || {} ++ var gl = this.gl ++ var model = params.model || identityMatrix ++ var view = params.view || identityMatrix ++ var projection = params.projection || identityMatrix + +- function set___(key, value) { +- var index; +- var hiddenRecord = getHiddenRecord(key); +- if (hiddenRecord) { +- hiddenRecord[id] = value; +- } else { +- index = keys.indexOf(key); +- if (index >= 0) { +- values[index] = value; +- } else { +- // Since some browsers preemptively terminate slow turns but +- // then continue computing with presumably corrupted heap +- // state, we here defensively get keys.length first and then +- // use it to update both the values and keys arrays, keeping +- // them in sync. +- index = keys.length; +- values[index] = value; +- // If we crash here, values will be one longer than keys. +- keys[index] = key; +- } +- } +- return this; +- } ++ var clipBounds = [[-1e6,-1e6,-1e6],[1e6,1e6,1e6]] ++ for(var i=0; i<3; ++i) { ++ clipBounds[0][i] = Math.max(clipBounds[0][i], this.clipBounds[0][i]) ++ clipBounds[1][i] = Math.min(clipBounds[1][i], this.clipBounds[1][i]) ++ } + +- function delete___(key) { +- var hiddenRecord = getHiddenRecord(key); +- var index, lastIndex; +- if (hiddenRecord) { +- return id in hiddenRecord && delete hiddenRecord[id]; +- } else { +- index = keys.indexOf(key); +- if (index < 0) { +- return false; +- } +- // Since some browsers preemptively terminate slow turns but +- // then continue computing with potentially corrupted heap +- // state, we here defensively get keys.length first and then use +- // it to update both the keys and the values array, keeping +- // them in sync. We update the two with an order of assignments, +- // such that any prefix of these assignments will preserve the +- // key/value correspondence, either before or after the delete. +- // Note that this needs to work correctly when index === lastIndex. +- lastIndex = keys.length - 1; +- keys[index] = void 0; +- // If we crash here, there's a void 0 in the keys array, but +- // no operation will cause a "keys.indexOf(void 0)", since +- // getHiddenRecord(void 0) will always throw an error first. +- values[index] = values[lastIndex]; +- // If we crash here, values[index] cannot be found here, +- // because keys[index] is void 0. +- keys[index] = keys[lastIndex]; +- // If index === lastIndex and we crash here, then keys[index] +- // is still void 0, since the aliasing killed the previous key. +- keys.length = lastIndex; +- // If we crash here, keys will be one shorter than values. +- values.length = lastIndex; +- return true; +- } +- } ++ var uniforms = { ++ model: model, ++ view: view, ++ projection: projection, + +- return Object.create(OurWeakMap.prototype, { +- get___: { value: constFunc(get___) }, +- has___: { value: constFunc(has___) }, +- set___: { value: constFunc(set___) }, +- delete___: { value: constFunc(delete___) } +- }); +- }; ++ clipBounds: clipBounds, + +- OurWeakMap.prototype = Object.create(Object.prototype, { +- get: { +- /** +- * Return the value most recently associated with key, or +- * opt_default if none. +- */ +- value: function get(key, opt_default) { +- return this.get___(key, opt_default); +- }, +- writable: true, +- configurable: true +- }, ++ kambient: this.ambientLight, ++ kdiffuse: this.diffuseLight, ++ kspecular: this.specularLight, ++ roughness: this.roughness, ++ fresnel: this.fresnel, + +- has: { +- /** +- * Is there a value associated with key in this WeakMap? +- */ +- value: function has(key) { +- return this.has___(key); +- }, +- writable: true, +- configurable: true +- }, ++ eyePosition: [0,0,0], ++ lightPosition: [0,0,0], + +- set: { +- /** +- * Associate value with key in this WeakMap, overwriting any +- * previous association if present. +- */ +- value: function set(key, value) { +- return this.set___(key, value); +- }, +- writable: true, +- configurable: true +- }, ++ opacity: this.opacity, + +- 'delete': { +- /** +- * Remove any association for key in this WeakMap, returning +- * whether there was one. +- * +- *

Note that the boolean return here does not work like the +- * {@code delete} operator. The {@code delete} operator returns +- * whether the deletion succeeds at bringing about a state in +- * which the deleted property is absent. The {@code delete} +- * operator therefore returns true if the property was already +- * absent, whereas this {@code delete} method returns false if +- * the association was already absent. +- */ +- value: function remove(key) { +- return this.delete___(key); +- }, +- writable: true, +- configurable: true ++ contourColor: this.contourColor, ++ ++ texture: 0 ++ } ++ ++ this.texture.bind(0) ++ ++ var invCameraMatrix = new Array(16) ++ multiply(invCameraMatrix, uniforms.view, uniforms.model) ++ multiply(invCameraMatrix, uniforms.projection, invCameraMatrix) ++ invert(invCameraMatrix, invCameraMatrix) ++ ++ for(var i=0; i<3; ++i) { ++ uniforms.eyePosition[i] = invCameraMatrix[12+i] / invCameraMatrix[15] ++ } ++ ++ var w = invCameraMatrix[15] ++ for(var i=0; i<3; ++i) { ++ w += this.lightPosition[i] * invCameraMatrix[4*i+3] ++ } ++ for(var i=0; i<3; ++i) { ++ var s = invCameraMatrix[12+i] ++ for(var j=0; j<3; ++j) { ++ s += invCameraMatrix[4*j+i] * this.lightPosition[j] + } +- }); ++ uniforms.lightPosition[i] = s / w ++ } + +- if (typeof HostWeakMap === 'function') { +- (function() { +- // If we got here, then the platform has a WeakMap but we are concerned +- // that it may refuse to store some key types. Therefore, make a map +- // implementation which makes use of both as possible. ++ if(this.triangleCount > 0) { ++ var shader = this.triShader ++ shader.bind() ++ shader.uniforms = uniforms + +- // In this mode we are always using double maps, so we are not proxy-safe. +- // This combination does not occur in any known browser, but we had best +- // be safe. +- if (doubleWeakMapCheckSilentFailure && typeof Proxy !== 'undefined') { +- Proxy = undefined; +- } ++ this.triangleVAO.bind() ++ gl.drawArrays(gl.TRIANGLES, 0, this.triangleCount*3) ++ this.triangleVAO.unbind() ++ } + +- function DoubleWeakMap() { +- if (!(this instanceof OurWeakMap)) { // approximate test for new ...() +- calledAsFunctionWarning(); +- } ++ if(this.edgeCount > 0 && this.lineWidth > 0) { ++ var shader = this.lineShader ++ shader.bind() ++ shader.uniforms = uniforms + +- // Preferable, truly weak map. +- var hmap = new HostWeakMap(); ++ this.edgeVAO.bind() ++ gl.lineWidth(this.lineWidth) ++ gl.drawArrays(gl.LINES, 0, this.edgeCount*2) ++ this.edgeVAO.unbind() ++ } + +- // Our hidden-property-based pseudo-weak-map. Lazily initialized in the +- // 'set' implementation; thus we can avoid performing extra lookups if +- // we know all entries actually stored are entered in 'hmap'. +- var omap = undefined; ++ if(this.pointCount > 0) { ++ var shader = this.pointShader ++ shader.bind() ++ shader.uniforms = uniforms + +- // Hidden-property maps are not compatible with proxies because proxies +- // can observe the hidden name and either accidentally expose it or fail +- // to allow the hidden property to be set. Therefore, we do not allow +- // arbitrary WeakMaps to switch to using hidden properties, but only +- // those which need the ability, and unprivileged code is not allowed +- // to set the flag. +- // +- // (Except in doubleWeakMapCheckSilentFailure mode in which case we +- // disable proxies.) +- var enableSwitching = false; ++ this.pointVAO.bind() ++ gl.drawArrays(gl.POINTS, 0, this.pointCount) ++ this.pointVAO.unbind() ++ } + +- function dget(key, opt_default) { +- if (omap) { +- return hmap.has(key) ? hmap.get(key) +- : omap.get___(key, opt_default); +- } else { +- return hmap.get(key, opt_default); +- } +- } ++ if(this.contourEnable && this.contourCount > 0 && this.contourLineWidth > 0) { ++ var shader = this.contourShader ++ shader.bind() ++ shader.uniforms = uniforms + +- function dhas(key) { +- return hmap.has(key) || (omap ? omap.has___(key) : false); +- } ++ this.contourVAO.bind() ++ gl.drawArrays(gl.LINES, 0, this.contourCount) ++ this.contourVAO.unbind() ++ } ++} + +- var dset; +- if (doubleWeakMapCheckSilentFailure) { +- dset = function(key, value) { +- hmap.set(key, value); +- if (!hmap.has(key)) { +- if (!omap) { omap = new OurWeakMap(); } +- omap.set(key, value); +- } +- return this; +- }; +- } else { +- dset = function(key, value) { +- if (enableSwitching) { +- try { +- hmap.set(key, value); +- } catch (e) { +- if (!omap) { omap = new OurWeakMap(); } +- omap.set___(key, value); +- } +- } else { +- hmap.set(key, value); +- } +- return this; +- }; +- } ++proto.drawPick = function(params) { ++ params = params || {} + +- function ddelete(key) { +- var result = !!hmap['delete'](key); +- if (omap) { return omap.delete___(key) || result; } +- return result; +- } ++ var gl = this.gl + +- return Object.create(OurWeakMap.prototype, { +- get___: { value: constFunc(dget) }, +- has___: { value: constFunc(dhas) }, +- set___: { value: constFunc(dset) }, +- delete___: { value: constFunc(ddelete) }, +- permitHostObjects___: { value: constFunc(function(token) { +- if (token === weakMapPermitHostObjects) { +- enableSwitching = true; +- } else { +- throw new Error('bogus call to permitHostObjects___'); +- } +- })} +- }); +- } +- DoubleWeakMap.prototype = OurWeakMap.prototype; +- module.exports = DoubleWeakMap; ++ var model = params.model || identityMatrix ++ var view = params.view || identityMatrix ++ var projection = params.projection || identityMatrix + +- // define .constructor to hide OurWeakMap ctor +- Object.defineProperty(WeakMap.prototype, 'constructor', { +- value: WeakMap, +- enumerable: false, // as default .constructor is +- configurable: true, +- writable: true +- }); +- })(); +- } else { +- // There is no host WeakMap, so we must use the emulation. ++ var clipBounds = [[-1e6,-1e6,-1e6],[1e6,1e6,1e6]] ++ for(var i=0; i<3; ++i) { ++ clipBounds[0][i] = Math.max(clipBounds[0][i], this.clipBounds[0][i]) ++ clipBounds[1][i] = Math.min(clipBounds[1][i], this.clipBounds[1][i]) ++ } + +- // Emulated WeakMaps are incompatible with native proxies (because proxies +- // can observe the hidden name), so we must disable Proxy usage (in +- // ArrayLike and Domado, currently). +- if (typeof Proxy !== 'undefined') { +- Proxy = undefined; +- } ++ //Save camera parameters ++ this._model = [].slice.call(model) ++ this._view = [].slice.call(view) ++ this._projection = [].slice.call(projection) ++ this._resolution = [gl.drawingBufferWidth, gl.drawingBufferHeight] ++ ++ var uniforms = { ++ model: model, ++ view: view, ++ projection: projection, ++ clipBounds: clipBounds, ++ pickId: this.pickId / 255.0, ++ } ++ ++ var shader = this.pickShader ++ shader.bind() ++ shader.uniforms = uniforms + +- module.exports = OurWeakMap; ++ if(this.triangleCount > 0) { ++ this.triangleVAO.bind() ++ gl.drawArrays(gl.TRIANGLES, 0, this.triangleCount*3) ++ this.triangleVAO.unbind() + } +-})(); + +-},{}],145:[function(require,module,exports){ +-'use strict' ++ if(this.edgeCount > 0) { ++ this.edgeVAO.bind() ++ gl.lineWidth(this.lineWidth) ++ gl.drawArrays(gl.LINES, 0, this.edgeCount*2) ++ this.edgeVAO.unbind() ++ } + +-var weakMap = typeof WeakMap === 'undefined' ? require('weak-map') : WeakMap +-var createBuffer = require('gl-buffer') +-var createVAO = require('gl-vao') ++ if(this.pointCount > 0) { ++ var shader = this.pointPickShader ++ shader.bind() ++ shader.uniforms = uniforms + +-var TriangleCache = new weakMap() ++ this.pointVAO.bind() ++ gl.drawArrays(gl.POINTS, 0, this.pointCount) ++ this.pointVAO.unbind() ++ } ++} + +-function createABigTriangle(gl) { + +- var triangleVAO = TriangleCache.get(gl) +- if(!triangleVAO || !gl.isBuffer(triangleVAO._triangleBuffer.buffer)) { +- var buf = createBuffer(gl, new Float32Array([-1, -1, -1, 4, 4, -1])) +- triangleVAO = createVAO(gl, [ +- { buffer: buf, +- type: gl.FLOAT, +- size: 2 +- } +- ]) +- triangleVAO._triangleBuffer = buf +- TriangleCache.set(gl, triangleVAO) ++proto.pick = function(pickData) { ++ if(!pickData) { ++ return null ++ } ++ if(pickData.id !== this.pickId) { ++ return null + } +- triangleVAO.bind() +- gl.drawArrays(gl.TRIANGLES, 0, 3) +- triangleVAO.unbind() +-} + +-module.exports = createABigTriangle ++ var cellId = pickData.value[0] + 256*pickData.value[1] + 65536*pickData.value[2] ++ var cell = this.cells[cellId] ++ var positions = this.positions + +-},{"gl-buffer":105,"gl-vao":192,"weak-map":144}],146:[function(require,module,exports){ +-'use strict' ++ var simplex = new Array(cell.length) ++ for(var i=0; i 0) { ++ var base = Math.round(Math.pow(10, y)) ++ return Math.ceil(x/base) * base + } ++ return Math.ceil(x) + } + +-function OffsetInfo() { +- this.primalOffset = [0,0,0] +- this.primalMinor = [0,0,0] +- this.mirrorOffset = [0,0,0] +- this.mirrorMinor = [0,0,0] ++function defaultBool(x) { ++ if(typeof x === 'boolean') { ++ return x ++ } ++ return true + } + +-var LINE_OFFSET = [ new OffsetInfo(), new OffsetInfo(), new OffsetInfo() ] ++function createScene(options) { ++ options = options || {} + +-function computeLineOffset(result, i, bounds, cubeEdges, cubeAxis) { +- var primalOffset = result.primalOffset +- var primalMinor = result.primalMinor +- var dualOffset = result.mirrorOffset +- var dualMinor = result.mirrorMinor +- var e = cubeEdges[i] ++ var stopped = false + +- //Calculate offsets +- for(var j=0; j<3; ++j) { +- if(i === j) { +- continue +- } +- var a = primalOffset, +- b = dualOffset, +- c = primalMinor, +- d = dualMinor +- if(e & (1< 0) { +- c[j] = -1 +- d[j] = 0 ++ var pixelRatio = options.pixelRatio || parseFloat(window.devicePixelRatio) ++ ++ var canvas = options.canvas ++ if(!canvas) { ++ canvas = document.createElement('canvas') ++ if(options.container) { ++ var container = options.container ++ container.appendChild(canvas) + } else { +- c[j] = 0 +- d[j] = +1 ++ document.body.appendChild(canvas) + } + } +-} +- +-var CUBE_ENABLE = [0,0,0] +-var DEFAULT_PARAMS = { +- model: identity, +- view: identity, +- projection: identity +-} + +-proto.isOpaque = function() { +- return true +-} ++ var gl = options.gl ++ if(!gl) { ++ gl = getContext(canvas, ++ options.glOptions || { ++ premultipliedAlpha: true, ++ antialias: true ++ }) ++ } ++ if(!gl) { ++ throw new Error('webgl not supported') ++ } + +-proto.isTransparent = function() { +- return false +-} ++ //Initial bounds ++ var bounds = options.bounds || [[-10,-10,-10], [10,10,10]] + +-proto.drawTransparent = function(params) {} ++ //Create selection ++ var selection = new MouseSelect() + ++ //Accumulation buffer ++ var accumBuffer = createFBO(gl, ++ [gl.drawingBufferWidth, gl.drawingBufferHeight], { ++ preferFloat: true ++ }) + +-var PRIMAL_MINOR = [0,0,0] +-var MIRROR_MINOR = [0,0,0] +-var PRIMAL_OFFSET = [0,0,0] ++ var accumShader = createShader(gl) + +-proto.draw = function(params) { +- params = params || DEFAULT_PARAMS ++ //Create a camera ++ var cameraOptions = options.camera || { ++ eye: [2,0,0], ++ center: [0,0,0], ++ up: [0,1,0], ++ zoomMin: 0.1, ++ zoomMax: 100, ++ mode: 'turntable' ++ } + +- var gl = this.gl ++ //Create axes ++ var axesOptions = options.axes || {} ++ var axes = createAxes(gl, axesOptions) ++ axes.enable = !axesOptions.disable + +- //Geometry for camera and axes +- var model = params.model || identity +- var view = params.view || identity +- var projection = params.projection || identity +- var bounds = this.bounds ++ //Create spikes ++ var spikeOptions = options.spikes || {} ++ var spikes = createSpikes(gl, spikeOptions) + +- //Unpack axis info +- var cubeParams = getCubeProperties(model, view, projection, bounds) +- var cubeEdges = cubeParams.cubeEdges +- var cubeAxis = cubeParams.axis ++ //Object list is empty initially ++ var objects = [] ++ var pickBufferIds = [] ++ var pickBufferCount = [] ++ var pickBuffers = [] + +- var cx = view[12] +- var cy = view[13] +- var cz = view[14] +- var cw = view[15] ++ //Dirty flag, skip redraw if scene static ++ var dirty = true ++ var pickDirty = true + +- var pixelScaleF = this.pixelRatio * (projection[3]*cx + projection[7]*cy + projection[11]*cz + projection[15]*cw) / gl.drawingBufferHeight ++ var projection = new Array(16) ++ var model = new Array(16) + +- for(var i=0; i<3; ++i) { +- this.lastCubeProps.cubeEdges[i] = cubeEdges[i] +- this.lastCubeProps.axis[i] = cubeAxis[i] ++ var cameraParams = { ++ view: null, ++ projection: projection, ++ model: model + } + +- //Compute axis info +- var lineOffset = LINE_OFFSET +- for(var i=0; i<3; ++i) { +- computeLineOffset( +- LINE_OFFSET[i], +- i, +- this.bounds, +- cubeEdges, +- cubeAxis) +- } ++ var pickDirty = true + +- //Set up state parameters +- var gl = this.gl ++ var viewShape = [ gl.drawingBufferWidth, gl.drawingBufferHeight ] + +- //Draw background first +- var cubeEnable = CUBE_ENABLE +- for(var i=0; i<3; ++i) { +- if(this.backgroundEnable[i]) { +- cubeEnable[i] = cubeAxis[i] +- } else { +- cubeEnable[i] = 0 +- } ++ //Create scene object ++ var scene = { ++ gl: gl, ++ contextLost: false, ++ pixelRatio: options.pixelRatio || parseFloat(window.devicePixelRatio), ++ canvas: canvas, ++ selection: selection, ++ camera: createCamera(canvas, cameraOptions), ++ axes: axes, ++ axesPixels: null, ++ spikes: spikes, ++ bounds: bounds, ++ objects: objects, ++ shape: viewShape, ++ aspect: options.aspectRatio || [1,1,1], ++ pickRadius: options.pickRadius || 10, ++ zNear: options.zNear || 0.01, ++ zFar: options.zFar || 1000, ++ fovy: options.fovy || Math.PI/4, ++ clearColor: options.clearColor || [0,0,0,0], ++ autoResize: defaultBool(options.autoResize), ++ autoBounds: defaultBool(options.autoBounds), ++ autoScale: !!options.autoScale, ++ autoCenter: defaultBool(options.autoCenter), ++ clipToBounds: defaultBool(options.clipToBounds), ++ snapToData: !!options.snapToData, ++ onselect: options.onselect || null, ++ onrender: options.onrender || null, ++ onclick: options.onclick || null, ++ cameraParams: cameraParams, ++ oncontextloss: null, ++ mouseListener: null + } + +- this._background.draw( +- model, +- view, +- projection, +- bounds, +- cubeEnable, +- this.backgroundColor) +- +- //Draw lines +- this._lines.bind( +- model, +- view, +- projection, +- this) ++ var pickShape = [ (gl.drawingBufferWidth/scene.pixelRatio)|0, (gl.drawingBufferHeight/scene.pixelRatio)|0 ] + +- //First draw grid lines and zero lines +- for(var i=0; i<3; ++i) { +- var x = [0,0,0] +- if(cubeAxis[i] > 0) { +- x[i] = bounds[1][i] ++ function resizeListener() { ++ if(stopped) { ++ return ++ } ++ if(!scene.autoResize) { ++ return ++ } ++ var parent = canvas.parentNode ++ var width = 1 ++ var height = 1 ++ if(parent && parent !== document.body) { ++ width = parent.clientWidth ++ height = parent.clientHeight + } else { +- x[i] = bounds[0][i] ++ width = window.innerWidth ++ height = window.innerHeight + } +- +- //Draw grid lines +- for(var j=0; j<2; ++j) { +- var u = (i + 1 + j) % 3 +- var v = (i + 1 + (j^1)) % 3 +- if(this.gridEnable[u]) { +- this._lines.drawGrid(u, v, this.bounds, x, this.gridColor[u], this.gridWidth[u]*this.pixelRatio) +- } ++ var nextWidth = Math.ceil(width * scene.pixelRatio)|0 ++ var nextHeight = Math.ceil(height * scene.pixelRatio)|0 ++ if(nextWidth !== canvas.width || nextHeight !== canvas.height) { ++ canvas.width = nextWidth ++ canvas.height = nextHeight ++ var style = canvas.style ++ style.position = style.position || 'absolute' ++ style.left = '0px' ++ style.top = '0px' ++ style.width = width + 'px' ++ style.height = height + 'px' ++ dirty = true + } ++ } ++ if(scene.autoResize) { ++ resizeListener() ++ } ++ window.addEventListener('resize', resizeListener) + +- //Draw zero lines (need to do this AFTER all grid lines are drawn) +- for(var j=0; j<2; ++j) { +- var u = (i + 1 + j) % 3 +- var v = (i + 1 + (j^1)) % 3 +- if(this.zeroEnable[v]) { +- //Check if zero line in bounds +- if(bounds[0][v] <= 0 && bounds[1][v] >= 0) { +- this._lines.drawZero(u, v, this.bounds, x, this.zeroLineColor[v], this.zeroLineWidth[v]*this.pixelRatio) ++ function reallocPickIds() { ++ var numObjs = objects.length ++ var numPick = pickBuffers.length ++ for(var i=0; i 0 && pickBufferCount[numPick-1] === 0) { ++ pickBufferCount.pop() ++ pickBuffers.pop().dispose() + } + } + +- //Then draw axis lines and tick marks +- for(var i=0; i<3; ++i) { ++ scene.update = function(options) { ++ if(stopped) { ++ return ++ } ++ options = options || {} ++ dirty = true ++ pickDirty = true ++ } + +- //Draw axis lines +- if(this.lineEnable[i]) { +- this._lines.drawAxisLine(i, this.bounds, lineOffset[i].primalOffset, this.lineColor[i], this.lineWidth[i]*this.pixelRatio) ++ scene.add = function(obj) { ++ if(stopped) { ++ return + } +- if(this.lineMirror[i]) { +- this._lines.drawAxisLine(i, this.bounds, lineOffset[i].mirrorOffset, this.lineColor[i], this.lineWidth[i]*this.pixelRatio) ++ obj.axes = axes ++ objects.push(obj) ++ pickBufferIds.push(-1) ++ dirty = true ++ pickDirty = true ++ reallocPickIds() ++ } ++ ++ scene.remove = function(obj) { ++ if(stopped) { ++ return ++ } ++ var idx = objects.indexOf(obj) ++ if(idx < 0) { ++ return + } ++ objects.splice(idx, 1) ++ pickBufferIds.pop() ++ dirty = true ++ pickDirty = true ++ reallocPickIds() ++ } + +- //Compute minor axes +- var primalMinor = copyVec3(PRIMAL_MINOR, lineOffset[i].primalMinor) +- var mirrorMinor = copyVec3(MIRROR_MINOR, lineOffset[i].mirrorMinor) +- var tickLength = this.lineTickLength +- var op = 0 +- for(var j=0; j<3; ++j) { +- var scaleFactor = pixelScaleF / model[5*j] +- primalMinor[j] *= tickLength[j] * scaleFactor +- mirrorMinor[j] *= tickLength[j] * scaleFactor ++ scene.dispose = function() { ++ if(stopped) { ++ return + } + +- //Draw axis line ticks +- if(this.lineTickEnable[i]) { +- this._lines.drawAxisTicks(i, lineOffset[i].primalOffset, primalMinor, this.lineTickColor[i], this.lineTickWidth[i]*this.pixelRatio) ++ stopped = true ++ ++ window.removeEventListener('resize', resizeListener) ++ canvas.removeEventListener('webglcontextlost', checkContextLoss) ++ scene.mouseListener.enabled = false ++ ++ if(scene.contextLost) { ++ return + } +- if(this.lineTickMirror[i]) { +- this._lines.drawAxisTicks(i, lineOffset[i].mirrorOffset, mirrorMinor, this.lineTickColor[i], this.lineTickWidth[i]*this.pixelRatio) ++ ++ //Destroy objects ++ axes.dispose() ++ spikes.dispose() ++ for(var i=0; i selection.distance) { ++ continue ++ } ++ for(var j=0; j o0) { +- closest |= 1< o0) { +- closest |= 1< cubeVerts[i][1]) { +- bottom = i ++ ++ //Clear dirty flags ++ dirty = false ++ for(var i=0; i cubeVerts[right][0]) { +- right = idx ++ render() ++ ++ //Force redraw of whole scene ++ scene.redraw = function() { ++ if(stopped) { ++ return + } ++ dirty = true ++ redraw() + } + +- //Determine edge axis coordinates +- var cubeEdges = CUBE_EDGES +- cubeEdges[0] = cubeEdges[1] = cubeEdges[2] = 0 +- cubeEdges[bits.log2(left^bottom)] = bottom&left +- cubeEdges[bits.log2(bottom^right)] = bottom&right +- var top = right ^ 7 +- if(top === closest || top === farthest) { +- top = left ^ 7 +- cubeEdges[bits.log2(right^top)] = top&right +- } else { +- cubeEdges[bits.log2(left^top)] = top&left +- } ++ return scene ++} + +- //Determine visible faces +- var axis = CUBE_AXIS +- var cutCorner = closest +- for(var d=0; d<3; ++d) { +- if(cutCorner & (1< 0.000001) { ++ // standard case (slerp) ++ omega = Math.acos(cosom) ++ sinom = Math.sin(omega) ++ scale0 = Math.sin((1.0 - t) * omega) / sinom ++ scale1 = Math.sin(t * omega) / sinom ++ } else { ++ // "from" and "to" quaternions are very close ++ // ... so we can do a linear interpolation ++ scale0 = 1.0 - t ++ scale1 = t + } ++ // calculate final values ++ out[0] = scale0 * ax + scale1 * bx ++ out[1] = scale0 * ay + scale1 * by ++ out[2] = scale0 * az + scale1 * bz ++ out[3] = scale0 * aw + scale1 * bw + +- //Return result +- return CUBE_RESULT ++ return out + } +-},{"bit-twiddle":38,"gl-mat4/invert":120,"gl-mat4/multiply":122,"robust-orientation":225,"split-polygon":154}],149:[function(require,module,exports){ +-'use strict' + +-module.exports = createLines ++},{}],129:[function(require,module,exports){ ++"use strict" + +-var createBuffer = require('gl-buffer') +-var createVAO = require('gl-vao') +-var createShader = require('./shaders').line ++var vectorizeText = require("vectorize-text") + +-var MAJOR_AXIS = [0,0,0] +-var MINOR_AXIS = [0,0,0] +-var SCREEN_AXIS = [0,0,0] +-var OFFSET_VEC = [0,0,0] +-var SHAPE = [1,1] ++module.exports = getGlyph + +-function zeroVec(a) { +- a[0] = a[1] = a[2] = 0 +- return a +-} ++var GLYPH_CACHE = {} + +-function copyVec(a,b) { +- a[0] = b[0] +- a[1] = b[1] +- a[2] = b[2] +- return a +-} ++function getGlyph(symbol, font) { ++ var fontCache = GLYPH_CACHE[font] ++ if(!fontCache) { ++ fontCache = GLYPH_CACHE[font] = {} ++ } ++ if(symbol in fontCache) { ++ return fontCache[symbol] ++ } + +-function Lines(gl, vertBuffer, vao, shader, tickCount, tickOffset, gridCount, gridOffset) { +- this.gl = gl +- this.vertBuffer = vertBuffer +- this.vao = vao +- this.shader = shader +- this.tickCount = tickCount +- this.tickOffset = tickOffset +- this.gridCount = gridCount +- this.gridOffset = gridOffset ++ //Get line and triangle meshes for glyph ++ var lineSymbol = vectorizeText(symbol, { ++ textAlign: "center", ++ textBaseline: "middle", ++ lineHeight: 1.0, ++ font: font ++ }) ++ var triSymbol = vectorizeText(symbol, { ++ triangles: true, ++ textAlign: "center", ++ textBaseline: "middle", ++ lineHeight: 1.0, ++ font: font ++ }) ++ ++ //Calculate bounding box ++ var bounds = [[Infinity,Infinity], [-Infinity,-Infinity]] ++ for(var i=0; i= 1) { ++ return true ++ } ++ for(var i=0; i<3; ++i) { ++ if(this.axesProject[i] && this.projectOpacity[i] >= 1) { ++ return true + } +- ]) +- var shader = createShader(gl) +- shader.attributes.position.location = 0 +- return new Lines(gl, vertBuf, vao, shader, tickCount, tickOffset, gridCount, gridOffset) ++ } ++ return false + } + +-},{"./shaders":150,"gl-buffer":105,"gl-vao":192}],150:[function(require,module,exports){ +-'use strict' +- +- +-var createShader = require('gl-shader') ++var VIEW_SHAPE = [0,0] ++var U_VEC = [0,0,0] ++var V_VEC = [0,0,0] ++var MU_VEC = [0,0,0,1] ++var MV_VEC = [0,0,0,1] ++var SCRATCH_MATRIX = IDENTITY.slice() ++var SCRATCH_VEC = [0,0,0] ++var CLIP_BOUNDS = [[0,0,0], [0,0,0]] + +-var lineVert = "#define GLSLIFY 1\nattribute vec3 position;\n\nuniform mat4 model, view, projection;\nuniform vec3 offset, majorAxis, minorAxis, screenAxis;\nuniform float lineWidth;\nuniform vec2 screenShape;\n\nvec3 project(vec3 p) {\n vec4 pp = projection * view * model * vec4(p, 1.0);\n return pp.xyz / max(pp.w, 0.0001);\n}\n\nvoid main() {\n vec3 major = position.x * majorAxis;\n vec3 minor = position.y * minorAxis;\n\n vec3 vPosition = major + minor + offset;\n vec3 pPosition = project(vPosition);\n vec3 offset = project(vPosition + screenAxis * position.z);\n\n vec2 screen = normalize((offset - pPosition).xy * screenShape) / screenShape;\n\n gl_Position = vec4(pPosition + vec3(0.5 * screen * lineWidth, 0), 1.0);\n}\n" +-var lineFrag = "precision mediump float;\n#define GLSLIFY 1\nuniform vec4 color;\nvoid main() {\n gl_FragColor = color;\n}" +-exports.line = function(gl) { +- return createShader(gl, lineVert, lineFrag, null, [ +- {name: 'position', type: 'vec3'} +- ]) ++function zeroVec(a) { ++ a[0] = a[1] = a[2] = 0 ++ return a + } + +-var textVert = "#define GLSLIFY 1\nattribute vec3 position;\n\nuniform mat4 model, view, projection;\nuniform vec3 offset, axis;\nuniform float scale, angle, pixelScale;\nuniform vec2 resolution;\n\nvoid main() { \n //Compute plane offset\n vec2 planeCoord = position.xy * pixelScale;\n mat2 planeXform = scale * mat2(cos(angle), sin(angle),\n -sin(angle), cos(angle));\n vec2 viewOffset = 2.0 * planeXform * planeCoord / resolution;\n\n //Compute world offset\n float axisDistance = position.z;\n vec3 dataPosition = axisDistance * axis + offset;\n vec4 worldPosition = model * vec4(dataPosition, 1);\n \n //Compute clip position\n vec4 viewPosition = view * worldPosition;\n vec4 clipPosition = projection * viewPosition;\n clipPosition /= clipPosition.w;\n\n //Apply text offset in clip coordinates\n clipPosition += vec4(viewOffset, 0, 0);\n\n //Done\n gl_Position = clipPosition;\n}" +-var textFrag = "precision mediump float;\n#define GLSLIFY 1\nuniform vec4 color;\nvoid main() {\n gl_FragColor = color;\n}" +-exports.text = function(gl) { +- return createShader(gl, textVert, textFrag, null, [ +- {name: 'position', type: 'vec3'} +- ]) ++function augment(hg, af) { ++ hg[0] = af[0] ++ hg[1] = af[1] ++ hg[2] = af[2] ++ hg[3] = 1 ++ return hg + } + +-var bgVert = "#define GLSLIFY 1\nattribute vec3 position;\nattribute vec3 normal;\n\nuniform mat4 model, view, projection;\nuniform vec3 enable;\nuniform vec3 bounds[2];\n\nvarying vec3 colorChannel;\n\nvoid main() {\n if(dot(normal, enable) > 0.0) {\n vec3 nPosition = mix(bounds[0], bounds[1], 0.5 * (position + 1.0));\n gl_Position = projection * view * model * vec4(nPosition, 1.0);\n } else {\n gl_Position = vec4(0,0,0,0);\n }\n colorChannel = abs(normal);\n}" +-var bgFrag = "precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 colors[3];\n\nvarying vec3 colorChannel;\n\nvoid main() {\n gl_FragColor = colorChannel.x * colors[0] + \n colorChannel.y * colors[1] +\n colorChannel.z * colors[2];\n}" +-exports.bg = function(gl) { +- return createShader(gl, bgVert, bgFrag, null, [ +- {name: 'position', type: 'vec3'}, +- {name: 'normal', type: 'vec3'} +- ]) ++function setComponent(out, v, i, x) { ++ out[0] = v[0] ++ out[1] = v[1] ++ out[2] = v[2] ++ out[i] = x ++ return out + } + +-},{"gl-shader":164}],151:[function(require,module,exports){ +-(function (process){ +-"use strict" ++function getClipBounds(bounds) { ++ var result = CLIP_BOUNDS ++ for(var i=0; i<2; ++i) { ++ for(var j=0; j<3; ++j) { ++ result[i][j] = Math.max(Math.min(bounds[i][j], 1e8), -1e8) ++ } ++ } ++ return result ++} + +-module.exports = createTextSprites ++function drawProject(shader, points, camera, transparent, forceDraw) { ++ var axesProject = points.axesProject + +-var createBuffer = require('gl-buffer') +-var createVAO = require('gl-vao') +-var vectorizeText = require('vectorize-text') +-var createShader = require('./shaders').text ++ var gl = points.gl ++ var uniforms = shader.uniforms ++ var model = camera.model || IDENTITY ++ var view = camera.view || IDENTITY ++ var projection = camera.projection || IDENTITY ++ var bounds = points.axesBounds ++ var clipBounds = getClipBounds(points.clipBounds) + +-var globals = window || process.global || {} +-var __TEXT_CACHE = globals.__TEXT_CACHE || {} +-globals.__TEXT_CACHE = {} ++ var cubeAxis ++ if(points.axes) { ++ cubeAxis = points.axes.lastCubeProps.axis ++ } else { ++ cubeAxis = [1,1,1] ++ } + +-//Vertex buffer format for text is: +-// +-/// [x,y,z] = Spatial coordinate +-// ++ VIEW_SHAPE[0] = 2.0/gl.drawingBufferWidth ++ VIEW_SHAPE[1] = 2.0/gl.drawingBufferHeight + +-var VERTEX_SIZE = 3 +-var VERTEX_STRIDE = VERTEX_SIZE * 4 ++ shader.bind() ++ uniforms.view = view ++ uniforms.projection = projection ++ uniforms.screenSize = VIEW_SHAPE ++ uniforms.highlightId = points.highlightId ++ uniforms.highlightScale = points.highlightScale ++ uniforms.clipBounds = clipBounds ++ uniforms.pickGroup = points.pickId / 255.0 ++ uniforms.pixelRatio = points.pixelRatio + +-function TextSprites( +- gl, +- shader, +- buffer, +- vao) { +- this.gl = gl +- this.shader = shader +- this.buffer = buffer +- this.vao = vao +- this.tickOffset = +- this.tickCount = +- this.labelOffset = +- this.labelCount = null +-} ++ for(var i=0; i<3; ++i) { ++ if(!axesProject[i]) { ++ continue ++ } ++ if((points.projectOpacity[i] < 1) !== transparent) { ++ continue ++ } + +-var proto = TextSprites.prototype ++ uniforms.scale = points.projectScale[i] ++ uniforms.opacity = points.projectOpacity[i] + +-//Bind textures for rendering +-var SHAPE = [0,0] +-proto.bind = function(model, view, projection, pixelScale) { +- this.vao.bind() +- this.shader.bind() +- var uniforms = this.shader.uniforms +- uniforms.model = model +- uniforms.view = view +- uniforms.projection = projection +- uniforms.pixelScale = pixelScale +- SHAPE[0] = this.gl.drawingBufferWidth +- SHAPE[1] = this.gl.drawingBufferHeight +- this.shader.uniforms.resolution = SHAPE +-} ++ //Project model matrix ++ var pmodel = SCRATCH_MATRIX ++ for(var j=0; j<16; ++j) { ++ pmodel[j] = 0 ++ } ++ for(var j=0; j<4; ++j) { ++ pmodel[5*j] = 1 ++ } ++ pmodel[5*i] = 0 ++ if(cubeAxis[i] < 0) { ++ pmodel[12+i] = bounds[0][i] ++ } else { ++ pmodel[12+i] = bounds[1][i] ++ } ++ mat4mult(pmodel, model, pmodel) ++ uniforms.model = pmodel + +-proto.update = function(bounds, labels, labelFont, ticks, tickFont) { +- var gl = this.gl +- var data = [] ++ //Compute initial axes ++ var u = (i+1)%3 ++ var v = (i+2)%3 ++ var du = zeroVec(U_VEC) ++ var dv = zeroVec(V_VEC) ++ du[u] = 1 ++ dv[v] = 1 + +- function addItem(t, text, font, size) { +- var fontcache = __TEXT_CACHE[font] +- if(!fontcache) { +- fontcache = __TEXT_CACHE[font] = {} ++ //Align orientation relative to viewer ++ var mdu = project(projection, view, model, augment(MU_VEC, du)) ++ var mdv = project(projection, view, model, augment(MV_VEC, dv)) ++ if(Math.abs(mdu[1]) > Math.abs(mdv[1])) { ++ var tmp = mdu ++ mdu = mdv ++ mdv = tmp ++ tmp = du ++ du = dv ++ dv = tmp ++ var t = u ++ u = v ++ v = t + } +- var mesh = fontcache[text] +- if(!mesh) { +- mesh = fontcache[text] = tryVectorizeText(text, { +- triangles: true, +- font: font, +- textAlign: 'center', +- textBaseline: 'middle' +- }) ++ if(mdu[0] < 0) { ++ du[u] = -1 + } +- var scale = (size || 12) / 12 +- var positions = mesh.positions +- var cells = mesh.cells +- var lo = [ Infinity, Infinity] +- var hi = [-Infinity,-Infinity] +- for(var i=0, nc=cells.length; i=0; --j) { +- var p = positions[c[j]] +- data.push(scale*p[0], -scale*p[1], t) +- } ++ if(mdv[1] > 0) { ++ dv[v] = -1 + } +- } ++ var su = 0.0 ++ var sv = 0.0 ++ for(var j=0; j<4; ++j) { ++ su += Math.pow(model[4*u+j], 2) ++ sv += Math.pow(model[4*v+j], 2) ++ } ++ du[u] /= Math.sqrt(su) ++ dv[v] /= Math.sqrt(sv) ++ uniforms.axes[0] = du ++ uniforms.axes[1] = dv + +- //Generate sprites for all 3 axes, store data in texture atlases +- var tickOffset = [0,0,0] +- var tickCount = [0,0,0] +- var labelOffset = [0,0,0] +- var labelCount = [0,0,0] +- for(var d=0; d<3; ++d) { ++ //Update fragment clip bounds ++ uniforms.fragClipBounds[0] = setComponent(SCRATCH_VEC, clipBounds[0], i, -1e8) ++ uniforms.fragClipBounds[1] = setComponent(SCRATCH_VEC, clipBounds[1], i, 1e8) + +- //Generate label +- labelOffset[d] = (data.length/VERTEX_SIZE)|0 +- addItem(0.5*(bounds[0][d]+bounds[1][d]), labels[d], labelFont) +- labelCount[d] = ((data.length/VERTEX_SIZE)|0) - labelOffset[d] ++ //Draw interior ++ points.vao.draw(gl.TRIANGLES, points.vertexCount) + +- //Generate sprites for tick marks +- tickOffset[d] = (data.length/VERTEX_SIZE)|0 +- for(var i=0; i 0) { ++ gl.lineWidth(points.lineWidth) ++ points.vao.draw(gl.LINES, points.lineVertexCount, points.vertexCount) + } +- tickCount[d] = ((data.length/VERTEX_SIZE)|0) - tickOffset[d] + } +- +- this.buffer.update(data) +- this.tickOffset = tickOffset +- this.tickCount = tickCount +- this.labelOffset = labelOffset +- this.labelCount = labelCount + } + +-//Draws the tick marks for an axis +-var AXIS = [0,0,0] +-proto.drawTicks = function(d, scale, angle, offset, color) { +- if(!this.tickCount[d]) { +- return +- } +- +- var v = AXIS +- v[0] = v[1] = v[2] = 0 +- v[d] = 1 +- this.shader.uniforms.axis = v +- this.shader.uniforms.color = color +- this.shader.uniforms.angle = angle +- this.shader.uniforms.scale = scale +- this.shader.uniforms.offset = offset +- this.vao.draw(this.gl.TRIANGLES, this.tickCount[d], this.tickOffset[d]) +-} + +-//Draws the text label for an axis +-var ZERO = [0,0,0] +-proto.drawLabel = function(d, scale, angle, offset, color) { +- if(!this.labelCount[d]) { +- return +- } +- this.shader.uniforms.axis = ZERO +- this.shader.uniforms.color = color +- this.shader.uniforms.angle = angle +- this.shader.uniforms.scale = scale +- this.shader.uniforms.offset = offset +- this.vao.draw(this.gl.TRIANGLES, this.labelCount[d], this.labelOffset[d]) +-} ++var NEG_INFINITY3 = [-1e8, -1e8, -1e8] ++var POS_INFINITY3 = [1e8, 1e8, 1e8] ++var CLIP_GROUP = [NEG_INFINITY3, POS_INFINITY3] + +-//Releases all resources attached to this object +-proto.dispose = function() { +- this.shader.dispose() +- this.vao.dispose() +- this.buffer.dispose() +-} ++function drawFull(shader, pshader, points, camera, transparent, forceDraw) { ++ var gl = points.gl + +-function tryVectorizeText(text, options) { +- try { +- return vectorizeText(text, options) +- } catch(e) { +- console.warn('error vectorizing text:', e) +- return { +- cells: [], +- positions: [] +- } +- } +-} ++ points.vao.bind() + +-function createTextSprites( +- gl, +- bounds, +- labels, +- labelFont, +- ticks, +- tickFont) { ++ if(transparent === (points.opacity < 1) || forceDraw) { ++ shader.bind() ++ var uniforms = shader.uniforms + +- var buffer = createBuffer(gl) +- var vao = createVAO(gl, [ +- { "buffer": buffer, +- "size": 3 +- } +- ]) ++ uniforms.model = camera.model || IDENTITY ++ uniforms.view = camera.view || IDENTITY ++ uniforms.projection = camera.projection || IDENTITY + +- var shader = createShader(gl) +- shader.attributes.position.location = 0 ++ VIEW_SHAPE[0] = 2.0/gl.drawingBufferWidth ++ VIEW_SHAPE[1] = 2.0/gl.drawingBufferHeight ++ uniforms.screenSize = VIEW_SHAPE + +- var result = new TextSprites( +- gl, +- shader, +- buffer, +- vao) ++ uniforms.highlightId = points.highlightId ++ uniforms.highlightScale = points.highlightScale + +- result.update(bounds, labels, labelFont, ticks, tickFont) ++ uniforms.fragClipBounds = CLIP_GROUP ++ uniforms.clipBounds = points.axes.bounds + +- return result +-} ++ uniforms.opacity = points.opacity ++ uniforms.pickGroup = points.pickId / 255.0 + +-}).call(this,require('_process')) +-},{"./shaders":150,"_process":44,"gl-buffer":105,"gl-vao":192,"vectorize-text":244}],152:[function(require,module,exports){ +-'use strict' ++ uniforms.pixelRatio = points.pixelRatio + +-exports.create = defaultTicks +-exports.equal = ticksEqual ++ //Draw interior ++ points.vao.draw(gl.TRIANGLES, points.vertexCount) + +-function prettyPrint(spacing, i) { +- var stepStr = spacing + "" +- var u = stepStr.indexOf(".") +- var sigFigs = 0 +- if(u >= 0) { +- sigFigs = stepStr.length - u - 1 +- } +- var shift = Math.pow(10, sigFigs) +- var x = Math.round(spacing * i * shift) +- var xstr = x + "" +- if(xstr.indexOf("e") >= 0) { +- return xstr +- } +- var xi = x / shift, xf = x % shift +- if(x < 0) { +- xi = -Math.ceil(xi)|0 +- xf = (-xf)|0 +- } else { +- xi = Math.floor(xi)|0 +- xf = xf|0 +- } +- var xis = "" + xi +- if(x < 0) { +- xis = "-" + xis +- } +- if(sigFigs) { +- var xs = "" + xf +- while(xs.length < sigFigs) { +- xs = "0" + xs ++ //Draw edges ++ if(points.lineWidth > 0) { ++ gl.lineWidth(points.lineWidth) ++ points.vao.draw(gl.LINES, points.lineVertexCount, points.vertexCount) + } +- return xis + "." + xs +- } else { +- return xis + } +-} + +-function defaultTicks(bounds, tickSpacing) { +- var array = [] +- for(var d=0; d<3; ++d) { +- var ticks = [] +- var m = 0.5*(bounds[0][d]+bounds[1][d]) +- for(var t=0; t*tickSpacing[d]<=bounds[1][d]; ++t) { +- ticks.push({x: t*tickSpacing[d], text: prettyPrint(tickSpacing[d], t)}) +- } +- for(var t=-1; t*tickSpacing[d]>=bounds[0][d]; --t) { +- ticks.push({x: t*tickSpacing[d], text: prettyPrint(tickSpacing[d], t)}) +- } +- array.push(ticks) +- } +- return array +-} ++ drawProject(pshader, points, camera, transparent, forceDraw) + +-function ticksEqual(ticksA, ticksB) { +- for(var i=0; i<3; ++i) { +- if(ticksA[i].length !== ticksB[i].length) { +- return false +- } +- for(var j=0; j= this.pointCount || x < 0) { ++ return null ++ } + +-//Can't do this exactly and emit a floating point result +-function lerpW(a, wa, b, wb) { +- var d = wb - wa +- var t = -wa / d +- if(t < 0.0) { +- t = 0.0 +- } else if(t > 1.0) { +- t = 1.0 ++ //Unpack result ++ var coord = this.points[x] ++ var result = this._selectResult ++ result.index = x ++ for(var i=0; i<3; ++i) { ++ result.position[i] = result.dataCoordinate[i] = coord[i] + } +- var ti = 1.0 - t +- var n = a.length +- var r = new Array(n) +- for(var i=0; i>8) &0xff ++ var a2 = (pointId>>16)&0xff ++ this.highlightId = [a0/255.0, a1/255.0, a2/255.0, 0] + } +- return r + } + +-function splitPolygon(points, plane) { +- var pos = [] +- var neg = [] +- var a = planeT(points[points.length-1], plane) +- for(var s=points[points.length-1], t=points[0], i=0; i 0) || (a > 0 && b < 0)) { +- var p = lerpW(s, b, t, a) +- pos.push(p) +- neg.push(p.slice()) +- } +- if(b < 0) { +- neg.push(t.slice()) +- } else if(b > 0) { +- pos.push(t.slice()) ++proto.update = function(options) { ++ ++ options = options || {} ++ ++ if('perspective' in options) { ++ this.useOrtho = !options.perspective ++ } ++ if('orthographic' in options) { ++ this.useOrtho = !!options.orthographic ++ } ++ if('lineWidth' in options) { ++ this.lineWidth = options.lineWidth ++ } ++ if('project' in options) { ++ if(Array.isArray(options.project)) { ++ this.axesProject = options.project + } else { +- pos.push(t.slice()) +- neg.push(t.slice()) ++ var v = !!options.project ++ this.axesProject = [v,v,v] + } +- a = b + } +- return { positive: pos, negative: neg } +-} +- +-function positive(points, plane) { +- var pos = [] +- var a = planeT(points[points.length-1], plane) +- for(var s=points[points.length-1], t=points[0], i=0; i 0) || (a > 0 && b < 0)) { +- pos.push(lerpW(s, b, t, a)) +- } +- if(b >= 0) { +- pos.push(t.slice()) ++ if('projectScale' in options) { ++ if(Array.isArray(options.projectScale)) { ++ this.projectScale = options.projectScale.slice() ++ } else { ++ var s = +options.projectScale ++ this.projectScale = [s,s,s] + } +- a = b + } +- return pos +-} +- +-function negative(points, plane) { +- var neg = [] +- var a = planeT(points[points.length-1], plane) +- for(var s=points[points.length-1], t=points[0], i=0; i 0) || (a > 0 && b < 0)) { +- neg.push(lerpW(s, b, t, a)) +- } +- if(b <= 0) { +- neg.push(t.slice()) ++ if('projectOpacity' in options) { ++ if(Array.isArray(options.projectOpacity)) { ++ this.projectOpacity = options.projectOpacity.slice() ++ } else { ++ var s = +options.projectOpacity ++ this.projectOpacity = [s,s,s] + } +- a = b + } +- return neg +-} +-},{"robust-dot-product":155,"robust-sum":228}],155:[function(require,module,exports){ +-"use strict" +- +-var twoProduct = require("two-product") +-var robustSum = require("robust-sum") ++ if('opacity' in options) { ++ this.opacity = options.opacity ++ } + +-module.exports = robustDotProduct ++ //Set dirty flag ++ this.dirty = true + +-function robustDotProduct(a, b) { +- var r = twoProduct(a[0], b[0]) +- for(var i=1; i 0) { ++ textOffset[0] = -alignment[0] * (1+glyphBounds[0][0]) ++ } ++ ++ //Write out inner marker ++ var cells = glyphMesh.cells ++ var verts = glyphMesh.positions ++ ++ for(var j=0; j this.buffer.length) { ++ pool.free(this.buffer) ++ var buffer = this.buffer = pool.mallocUint8(nextPow2(r*c*4)) ++ for(var i=0; i 0) { +- var base = Math.round(Math.pow(10, y)) +- return Math.ceil(x/base) * base ++proto.bind = function() { ++ if(!this.program) { ++ this._relink() + } +- return Math.ceil(x) +-} + +-function defaultBool(x) { +- if(typeof x === 'boolean') { +- return x ++ // ensuring that we have the right number of enabled vertex attributes ++ var i ++ var newAttribCount = this.gl.getProgramParameter(this.program, this.gl.ACTIVE_ATTRIBUTES) // more robust approach ++ //var newAttribCount = Object.keys(this.attributes).length // avoids the probably immaterial introspection slowdown ++ var oldAttribCount = this.gl.lastAttribCount ++ if(newAttribCount > oldAttribCount) { ++ for(i = oldAttribCount; i < newAttribCount; i++) { ++ this.gl.enableVertexAttribArray(i) ++ } ++ } else if(oldAttribCount > newAttribCount) { ++ for(i = newAttribCount; i < oldAttribCount; i++) { ++ this.gl.disableVertexAttribArray(i) ++ } + } +- return true +-} + +-function createScene(options) { +- options = options || {} ++ this.gl.lastAttribCount = newAttribCount + +- var stopped = false ++ this.gl.useProgram(this.program) ++} + +- var pixelRatio = options.pixelRatio || parseFloat(window.devicePixelRatio) ++proto.dispose = function() { + +- var canvas = options.canvas +- if(!canvas) { +- canvas = document.createElement('canvas') +- if(options.container) { +- var container = options.container +- container.appendChild(canvas) +- } else { +- document.body.appendChild(canvas) +- } ++ // disabling vertex attributes so new shader starts with zero ++ // and it's also useful if all shaders are disposed but the ++ // gl context is reused for subsequent replotting ++ var oldAttribCount = this.gl.lastAttribCount ++ for (var i = 0; i < oldAttribCount; i++) { ++ this.gl.disableVertexAttribArray(i) + } ++ this.gl.lastAttribCount = 0 + +- var gl = options.gl +- if(!gl) { +- gl = getContext(canvas, +- options.glOptions || { +- premultipliedAlpha: true, +- antialias: true +- }) ++ if(this._fref) { ++ this._fref.dispose() + } +- if(!gl) { +- throw new Error('webgl not supported') ++ if(this._vref) { ++ this._vref.dispose() + } ++ this.attributes = ++ this.types = ++ this.vertShader = ++ this.fragShader = ++ this.program = ++ this._relink = ++ this._fref = ++ this._vref = null ++} + +- //Initial bounds +- var bounds = options.bounds || [[-10,-10,-10], [10,10,10]] +- +- //Create selection +- var selection = new MouseSelect() +- +- //Accumulation buffer +- var accumBuffer = createFBO(gl, +- [gl.drawingBufferWidth, gl.drawingBufferHeight], { +- preferFloat: true +- }) +- +- var accumShader = createShader(gl) +- +- //Create a camera +- var cameraOptions = options.camera || { +- eye: [2,0,0], +- center: [0,0,0], +- up: [0,1,0], +- zoomMin: 0.1, +- zoomMax: 100, +- mode: 'turntable' ++function compareAttributes(a, b) { ++ if(a.name < b.name) { ++ return -1 + } ++ return 1 ++} + +- //Create axes +- var axesOptions = options.axes || {} +- var axes = createAxes(gl, axesOptions) +- axes.enable = !axesOptions.disable +- +- //Create spikes +- var spikeOptions = options.spikes || {} +- var spikes = createSpikes(gl, spikeOptions) +- +- //Object list is empty initially +- var objects = [] +- var pickBufferIds = [] +- var pickBufferCount = [] +- var pickBuffers = [] +- +- //Dirty flag, skip redraw if scene static +- var dirty = true +- var pickDirty = true +- +- var projection = new Array(16) +- var model = new Array(16) ++//Update export hook for glslify-live ++proto.update = function( ++ vertSource ++ , fragSource ++ , uniforms ++ , attributes) { + +- var cameraParams = { +- view: null, +- projection: projection, +- model: model ++ //If only one object passed, assume glslify style output ++ if(!fragSource || arguments.length === 1) { ++ var obj = vertSource ++ vertSource = obj.vertex ++ fragSource = obj.fragment ++ uniforms = obj.uniforms ++ attributes = obj.attributes + } + +- var pickDirty = true +- +- var viewShape = [ gl.drawingBufferWidth, gl.drawingBufferHeight ] ++ var wrapper = this ++ var gl = wrapper.gl + +- //Create scene object +- var scene = { +- gl: gl, +- contextLost: false, +- pixelRatio: options.pixelRatio || parseFloat(window.devicePixelRatio), +- canvas: canvas, +- selection: selection, +- camera: createCamera(canvas, cameraOptions), +- axes: axes, +- axesPixels: null, +- spikes: spikes, +- bounds: bounds, +- objects: objects, +- shape: viewShape, +- aspect: options.aspectRatio || [1,1,1], +- pickRadius: options.pickRadius || 10, +- zNear: options.zNear || 0.01, +- zFar: options.zFar || 1000, +- fovy: options.fovy || Math.PI/4, +- clearColor: options.clearColor || [0,0,0,0], +- autoResize: defaultBool(options.autoResize), +- autoBounds: defaultBool(options.autoBounds), +- autoScale: !!options.autoScale, +- autoCenter: defaultBool(options.autoCenter), +- clipToBounds: defaultBool(options.clipToBounds), +- snapToData: !!options.snapToData, +- onselect: options.onselect || null, +- onrender: options.onrender || null, +- onclick: options.onclick || null, +- cameraParams: cameraParams, +- oncontextloss: null, +- mouseListener: null ++ //Compile vertex and fragment shaders ++ var pvref = wrapper._vref ++ wrapper._vref = shaderCache.shader(gl, gl.VERTEX_SHADER, vertSource) ++ if(pvref) { ++ pvref.dispose() ++ } ++ wrapper.vertShader = wrapper._vref.shader ++ var pfref = this._fref ++ wrapper._fref = shaderCache.shader(gl, gl.FRAGMENT_SHADER, fragSource) ++ if(pfref) { ++ pfref.dispose() + } ++ wrapper.fragShader = wrapper._fref.shader + +- var pickShape = [ (gl.drawingBufferWidth/scene.pixelRatio)|0, (gl.drawingBufferHeight/scene.pixelRatio)|0 ] ++ //If uniforms/attributes is not specified, use RT reflection ++ if(!uniforms || !attributes) { + +- function resizeListener() { +- if(stopped) { +- return +- } +- if(!scene.autoResize) { +- return +- } +- var parent = canvas.parentNode +- var width = 1 +- var height = 1 +- if(parent && parent !== document.body) { +- width = parent.clientWidth +- height = parent.clientHeight +- } else { +- width = window.innerWidth +- height = window.innerHeight +- } +- var nextWidth = Math.ceil(width * scene.pixelRatio)|0 +- var nextHeight = Math.ceil(height * scene.pixelRatio)|0 +- if(nextWidth !== canvas.width || nextHeight !== canvas.height) { +- canvas.width = nextWidth +- canvas.height = nextHeight +- var style = canvas.style +- style.position = style.position || 'absolute' +- style.left = '0px' +- style.top = '0px' +- style.width = width + 'px' +- style.height = height + 'px' +- dirty = true ++ //Create initial test program ++ var testProgram = gl.createProgram() ++ gl.attachShader(testProgram, wrapper.fragShader) ++ gl.attachShader(testProgram, wrapper.vertShader) ++ gl.linkProgram(testProgram) ++ if(!gl.getProgramParameter(testProgram, gl.LINK_STATUS)) { ++ var errLog = gl.getProgramInfoLog(testProgram) ++ throw new GLError(errLog, 'Error linking program:' + errLog) + } +- } +- if(scene.autoResize) { +- resizeListener() +- } +- window.addEventListener('resize', resizeListener) + +- function reallocPickIds() { +- var numObjs = objects.length +- var numPick = pickBuffers.length +- for(var i=0; i= 0) { ++ var size = attr.type.charAt(attr.type.length-1)|0 ++ var locVector = new Array(size) ++ for(var j=0; j 0 && pickBufferCount[numPick-1] === 0) { +- pickBufferCount.pop() +- pickBuffers.pop().dispose() ++ attributeUnpacked.push({ ++ name: attr.name, ++ type: attr.type, ++ locations: locVector ++ }) ++ } else { ++ attributeUnpacked.push({ ++ name: attr.name, ++ type: attr.type, ++ locations: [ attributeLocations.length ] ++ }) ++ attributeNames.push(attr.name) ++ if(typeof attr.location === 'number') { ++ attributeLocations.push(attr.location|0) ++ } else { ++ attributeLocations.push(-1) ++ } + } + } + +- scene.update = function(options) { +- if(stopped) { +- return ++ //For all unspecified attributes, assign them lexicographically min attribute ++ var curLocation = 0 ++ for(i=0; i= 0) { ++ curLocation += 1 ++ } ++ attributeLocations[i] = curLocation + } +- options = options || {} +- dirty = true +- pickDirty = true + } + +- scene.add = function(obj) { +- if(stopped) { +- return ++ //Rebuild program and recompute all uniform locations ++ var uniformLocations = new Array(uniforms.length) ++ function relink() { ++ wrapper.program = shaderCache.program( ++ gl ++ , wrapper._vref ++ , wrapper._fref ++ , attributeNames ++ , attributeLocations) ++ ++ for(var i=0; i selection.distance) { +- continue +- } +- for(var j=0; j= 0) { ++ var d = type.charCodeAt(type.length-1) - 48 ++ if(d < 2 || d > 4) { ++ throw new GLError('', 'Invalid data type for attribute ' + name + ': ' + type) ++ } ++ addVectorAttribute( ++ gl ++ , wrapper ++ , locs[0] ++ , locations ++ , d ++ , obj ++ , name) ++ } else if(type.indexOf('mat') >= 0) { ++ var d = type.charCodeAt(type.length-1) - 48 ++ if(d < 2 || d > 4) { ++ throw new GLError('', 'Invalid data type for attribute ' + name + ': ' + type) ++ } ++ addMatrixAttribute( ++ gl ++ , wrapper ++ , locs ++ , locations ++ , d ++ , obj ++ , name) ++ } else { ++ throw new GLError('', 'Unknown data type for attribute ' + name + ': ' + type) + } +- } +- buf.end() ++ break + } + } ++ return obj ++} + +- var nBounds = [ +- [ Infinity, Infinity, Infinity], +- [-Infinity,-Infinity,-Infinity]] +- +- var prevBounds = [nBounds[0].slice(), nBounds[1].slice()] +- +- function redraw() { +- if(checkContextLoss()) { +- return +- } ++},{"./GLError":134}],136:[function(require,module,exports){ ++'use strict' + +- resizeListener() ++var coallesceUniforms = require('./reflect') ++var GLError = require("./GLError") + +- //Tick camera +- var cameraMoved = scene.camera.tick() +- cameraParams.view = scene.camera.matrix +- dirty = dirty || cameraMoved +- pickDirty = pickDirty || cameraMoved ++module.exports = createUniformWrapper + +- //Set pixel ratio +- axes.pixelRatio = scene.pixelRatio +- spikes.pixelRatio = scene.pixelRatio ++//Binds a function and returns a value ++function identity(x) { ++ var c = new Function('y', 'return function(){return y}') ++ return c(x) ++} + +- //Check if any objects changed, recalculate bounds +- var numObjs = objects.length +- var lo = nBounds[0] +- var hi = nBounds[1] +- lo[0] = lo[1] = lo[2] = Infinity +- hi[0] = hi[1] = hi[2] = -Infinity +- for(var i=0; i 4) { ++ throw new GLError('', 'Invalid data type') + } +- var padding = 0.05 * (hi[j] - lo[j]) +- lo[j] = lo[j] - padding +- hi[j] = hi[j] + padding ++ switch(type.charAt(0)) { ++ case 'b': ++ case 'i': ++ return 'gl.uniform' + d + 'iv(locations[' + index + '],obj' + path + ')' ++ case 'v': ++ return 'gl.uniform' + d + 'fv(locations[' + index + '],obj' + path + ')' ++ default: ++ throw new GLError('', 'Unrecognized data type for vector ' + name + ': ' + type) ++ } ++ } else if(type.indexOf('mat') === 0 && type.length === 4) { ++ var d = type.charCodeAt(type.length-1) - 48 ++ if(d < 2 || d > 4) { ++ throw new GLError('', 'Invalid uniform dimension type for matrix ' + name + ': ' + type) ++ } ++ return 'gl.uniformMatrix' + d + 'fv(locations[' + index + '],false,obj' + path + ')' ++ } else { ++ throw new GLError('', 'Unknown uniform data type for ' + name + ': ' + type) + } +- bounds[0][j] = lo[j] +- bounds[1][j] = hi[j] +- } ++ break + } ++ } + +- var boundsChanged = false +- for(var j=0; j<3; ++j) { +- boundsChanged = boundsChanged || +- (prevBounds[0][j] !== bounds[0][j]) || +- (prevBounds[1][j] !== bounds[1][j]) +- prevBounds[0][j] = bounds[0][j] +- prevBounds[1][j] = bounds[1][j] ++ function enumerateIndices(prefix, type) { ++ if(typeof type !== 'object') { ++ return [ [prefix, type] ] + } +- +- if(boundsChanged) { +- var tickSpacing = [0,0,0] +- for(var i=0; i<3; ++i) { +- tickSpacing[i] = roundUpPow10((bounds[1][i]-bounds[0][i]) / 10.0) ++ var indices = [] ++ for(var id in type) { ++ var prop = type[id] ++ var tprefix = prefix ++ if(parseInt(id) + '' === id) { ++ tprefix += '[' + id + ']' ++ } else { ++ tprefix += '.' + id + } +- if(axes.autoTicks) { +- axes.update({ +- bounds: bounds, +- tickSpacing: tickSpacing +- }) ++ if(typeof prop === 'object') { ++ indices.push.apply(indices, enumerateIndices(tprefix, prop)) + } else { +- axes.update({ +- bounds: bounds +- }) ++ indices.push([tprefix, prop]) + } + } ++ return indices ++ } + +- //Recalculate bounds +- pickDirty = pickDirty || boundsChanged +- dirty = dirty || boundsChanged +- +- //Get scene +- var width = gl.drawingBufferWidth +- var height = gl.drawingBufferHeight +- viewShape[0] = width +- viewShape[1] = height +- pickShape[0] = Math.max(width/scene.pixelRatio, 1)|0 +- pickShape[1] = Math.max(height/scene.pixelRatio, 1)|0 +- +- //Compute camera parameters +- perspective(projection, +- scene.fovy, +- width/height, +- scene.zNear, +- scene.zFar) +- +- //Compute model matrix +- for(var i=0; i<16; ++i) { +- model[i] = 0 ++ function makeSetter(type) { ++ var code = [ 'return function updateProperty(obj){' ] ++ var indices = enumerateIndices('', type) ++ for(var i=0; i 4) { ++ throw new GLError('', 'Invalid data type') ++ } ++ if(type.charAt(0) === 'b') { ++ return makeVector(d, false) ++ } ++ return makeVector(d, 0) ++ } else if(type.indexOf('mat') === 0 && type.length === 4) { ++ var d = type.charCodeAt(type.length-1) - 48 ++ if(d < 2 || d > 4) { ++ throw new GLError('', 'Invalid uniform dimension type for matrix ' + name + ': ' + type) ++ } ++ return makeVector(d*d, 0) ++ } else { ++ throw new GLError('', 'Unknown uniform data type for ' + name + ': ' + type) ++ } ++ break + } ++ } + +- for(var i=0; i<3; ++i) { +- if(scene.autoScale) { +- model[5*i] = scene.aspect[i] / (bounds[1][i] - bounds[0][i]) ++ function storeProperty(obj, prop, type) { ++ if(typeof type === 'object') { ++ var child = processObject(type) ++ Object.defineProperty(obj, prop, { ++ get: identity(child), ++ set: makeSetter(type), ++ enumerable: true, ++ configurable: false ++ }) ++ } else { ++ if(locations[type]) { ++ Object.defineProperty(obj, prop, { ++ get: makeGetter(type), ++ set: makeSetter(type), ++ enumerable: true, ++ configurable: false ++ }) + } else { +- model[5*i] = 1 / maxS +- } +- if(scene.autoCenter) { +- model[12+i] = -model[5*i] * 0.5 * (bounds[0][i] + bounds[1][i]) ++ obj[prop] = defaultValue(uniforms[type].type) + } + } ++ } + +- //Apply axes/clip bounds +- for(var i=0; i 1) { ++ if(!(x[0] in o)) { ++ o[x[0]] = [] ++ } ++ o = o[x[0]] ++ for(var k=1; k 1) { ++ for(var j=0; j= 1) { +- return true +- } +- for(var i=0; i<3; ++i) { +- if(this.axesProject[i] && this.projectOpacity[i] >= 1) { +- return true +- } +- } +- return false +-} ++},{"./shaders/index":140,"gl-buffer":94,"gl-vao":148}],142:[function(require,module,exports){ ++var createShader = require('gl-shader') + +-var VIEW_SHAPE = [0,0] +-var U_VEC = [0,0,0] +-var V_VEC = [0,0,0] +-var MU_VEC = [0,0,0,1] +-var MV_VEC = [0,0,0,1] +-var SCRATCH_MATRIX = IDENTITY.slice() +-var SCRATCH_VEC = [0,0,0] +-var CLIP_BOUNDS = [[0,0,0], [0,0,0]] + +-function zeroVec(a) { +- a[0] = a[1] = a[2] = 0 +- return a +-} ++var vertSrc = "precision mediump float;\n#define GLSLIFY 1\n\nattribute vec4 uv;\nattribute vec3 f;\nattribute vec3 normal;\n\nuniform mat4 model, view, projection, inverseModel;\nuniform vec3 lightPosition, eyePosition;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\n\nvoid main() {\n worldCoordinate = vec3(uv.zw, f.x);\n vec4 worldPosition = model * vec4(worldCoordinate, 1.0);\n vec4 clipPosition = projection * view * worldPosition;\n gl_Position = clipPosition;\n kill = f.y;\n value = f.z;\n planeCoordinate = uv.xy;\n\n //Lighting geometry parameters\n vec4 cameraCoordinate = view * worldPosition;\n cameraCoordinate.xyz /= cameraCoordinate.w;\n lightDirection = lightPosition - cameraCoordinate.xyz;\n eyeDirection = eyePosition - cameraCoordinate.xyz;\n surfaceNormal = normalize((vec4(normal,0) * inverseModel).xyz);\n}\n" ++var fragSrc = "precision mediump float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution_2_0(float x, float roughness) {\n float NdotH = max(x, 0.0001);\n float cos2Alpha = NdotH * NdotH;\n float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha;\n float roughness2 = roughness * roughness;\n float denom = 3.141592653589793 * roughness2 * cos2Alpha * cos2Alpha;\n return exp(tan2Alpha / roughness2) / denom;\n}\n\n\n\nfloat beckmannSpecular_1_1(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness) {\n return beckmannDistribution_2_0(dot(surfaceNormal, normalize(lightDirection + viewDirection)), roughness);\n}\n\n\n\nuniform vec3 lowerBound, upperBound;\nuniform float contourTint;\nuniform vec4 contourColor;\nuniform sampler2D colormap;\nuniform vec3 clipBounds[2];\nuniform float roughness, fresnel, kambient, kdiffuse, kspecular, opacity;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\n\nvoid main() {\n if(kill > 0.0 ||\n any(lessThan(worldCoordinate, clipBounds[0])) || any(greaterThan(worldCoordinate, clipBounds[1]))) {\n discard;\n }\n\n vec3 N = normalize(surfaceNormal);\n vec3 V = normalize(eyeDirection);\n vec3 L = normalize(lightDirection);\n\n if(gl_FrontFacing) {\n N = -N;\n }\n\n float specular = beckmannSpecular_1_1(L, V, N, roughness);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = texture2D(colormap, vec2(value, value));\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = mix(litColor, contourColor, contourTint) * opacity;\n}\n" ++var contourVertSrc = "precision mediump float;\n#define GLSLIFY 1\n\nattribute vec4 uv;\nattribute float f;\n\nuniform mat3 permutation;\nuniform mat4 model, view, projection;\nuniform float height, zOffset;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\n\nvoid main() {\n vec3 dataCoordinate = permutation * vec3(uv.xy, height);\n vec4 worldPosition = model * vec4(dataCoordinate, 1.0);\n\n vec4 clipPosition = projection * view * worldPosition;\n clipPosition.z = clipPosition.z + zOffset;\n\n gl_Position = clipPosition;\n value = f;\n kill = -1.0;\n worldCoordinate = dataCoordinate;\n planeCoordinate = uv.zw;\n\n //Don't do lighting for contours\n surfaceNormal = vec3(1,0,0);\n eyeDirection = vec3(0,1,0);\n lightDirection = vec3(0,0,1);\n}\n" ++var pickSrc = "precision mediump float;\n#define GLSLIFY 1\n\nuniform vec2 shape;\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 surfaceNormal;\n\nvec2 splitFloat(float v) {\n float vh = 255.0 * v;\n float upper = floor(vh);\n float lower = fract(vh);\n return vec2(upper / 255.0, floor(lower * 16.0) / 16.0);\n}\n\nvoid main() {\n if(kill > 0.0 ||\n any(lessThan(worldCoordinate, clipBounds[0])) || any(greaterThan(worldCoordinate, clipBounds[1]))) {\n discard;\n }\n vec2 ux = splitFloat(planeCoordinate.x / shape.x);\n vec2 uy = splitFloat(planeCoordinate.y / shape.y);\n gl_FragColor = vec4(pickId, ux.x, uy.x, ux.y + (uy.y/16.0));\n}\n" + +-function augment(hg, af) { +- hg[0] = af[0] +- hg[1] = af[1] +- hg[2] = af[2] +- hg[3] = 1 +- return hg ++exports.createShader = function (gl) { ++ var shader = createShader(gl, vertSrc, fragSrc, null, [ ++ {name: 'uv', type: 'vec4'}, ++ {name: 'f', type: 'vec3'}, ++ {name: 'normal', type: 'vec3'} ++ ]) ++ shader.attributes.uv.location = 0 ++ shader.attributes.f.location = 1 ++ shader.attributes.normal.location = 2 ++ return shader + } +- +-function setComponent(out, v, i, x) { +- out[0] = v[0] +- out[1] = v[1] +- out[2] = v[2] +- out[i] = x +- return out ++exports.createPickShader = function (gl) { ++ var shader = createShader(gl, vertSrc, pickSrc, null, [ ++ {name: 'uv', type: 'vec4'}, ++ {name: 'f', type: 'vec3'}, ++ {name: 'normal', type: 'vec3'} ++ ]) ++ shader.attributes.uv.location = 0 ++ shader.attributes.f.location = 1 ++ shader.attributes.normal.location = 2 ++ return shader + } +- +-function getClipBounds(bounds) { +- var result = CLIP_BOUNDS +- for(var i=0; i<2; ++i) { +- for(var j=0; j<3; ++j) { +- result[i][j] = Math.max(Math.min(bounds[i][j], 1e8), -1e8) +- } +- } +- return result ++exports.createContourShader = function (gl) { ++ var shader = createShader(gl, contourVertSrc, fragSrc, null, [ ++ {name: 'uv', type: 'vec4'}, ++ {name: 'f', type: 'float'} ++ ]) ++ shader.attributes.uv.location = 0 ++ shader.attributes.f.location = 1 ++ return shader ++} ++exports.createPickContourShader = function (gl) { ++ var shader = createShader(gl, contourVertSrc, pickSrc, null, [ ++ {name: 'uv', type: 'vec4'}, ++ {name: 'f', type: 'float'} ++ ]) ++ shader.attributes.uv.location = 0 ++ shader.attributes.f.location = 1 ++ return shader + } + +-function drawProject(shader, points, camera, transparent, forceDraw) { +- var axesProject = points.axesProject +- +- var gl = points.gl +- var uniforms = shader.uniforms +- var model = camera.model || IDENTITY +- var view = camera.view || IDENTITY +- var projection = camera.projection || IDENTITY +- var bounds = points.axesBounds +- var clipBounds = getClipBounds(points.clipBounds) ++},{"gl-shader":133}],143:[function(require,module,exports){ ++'use strict' + +- var cubeAxis +- if(points.axes) { +- cubeAxis = points.axes.lastCubeProps.axis +- } else { +- cubeAxis = [1,1,1] +- } ++module.exports = createSurfacePlot + +- VIEW_SHAPE[0] = 2.0/gl.drawingBufferWidth +- VIEW_SHAPE[1] = 2.0/gl.drawingBufferHeight ++var bits = require('bit-twiddle') ++var createBuffer = require('gl-buffer') ++var createVAO = require('gl-vao') ++var createTexture = require('gl-texture2d') ++var pool = require('typedarray-pool') ++var colormap = require('colormap') ++var ops = require('ndarray-ops') ++var pack = require('ndarray-pack') ++var ndarray = require('ndarray') ++var surfaceNets = require('surface-nets') ++var multiply = require('gl-mat4/multiply') ++var invert = require('gl-mat4/invert') ++var bsearch = require('binary-search-bounds') ++var gradient = require('ndarray-gradient') ++var shaders = require('./lib/shaders') + +- shader.bind() +- uniforms.view = view +- uniforms.projection = projection +- uniforms.screenSize = VIEW_SHAPE +- uniforms.highlightId = points.highlightId +- uniforms.highlightScale = points.highlightScale +- uniforms.clipBounds = clipBounds +- uniforms.pickGroup = points.pickId / 255.0 +- uniforms.pixelRatio = points.pixelRatio ++var createShader = shaders.createShader ++var createContourShader = shaders.createContourShader ++var createPickShader = shaders.createPickShader ++var createPickContourShader = shaders.createPickContourShader + +- for(var i=0; i<3; ++i) { +- if(!axesProject[i]) { +- continue +- } +- if((points.projectOpacity[i] < 1) !== transparent) { +- continue +- } ++var SURFACE_VERTEX_SIZE = 4 * (4 + 3 + 3) + +- uniforms.scale = points.projectScale[i] +- uniforms.opacity = points.projectOpacity[i] ++var IDENTITY = [ ++ 1, 0, 0, 0, ++ 0, 1, 0, 0, ++ 0, 0, 1, 0, ++ 0, 0, 0, 1 ] + +- //Project model matrix +- var pmodel = SCRATCH_MATRIX +- for(var j=0; j<16; ++j) { +- pmodel[j] = 0 +- } +- for(var j=0; j<4; ++j) { +- pmodel[5*j] = 1 +- } +- pmodel[5*i] = 0 +- if(cubeAxis[i] < 0) { +- pmodel[12+i] = bounds[0][i] +- } else { +- pmodel[12+i] = bounds[1][i] +- } +- mat4mult(pmodel, model, pmodel) +- uniforms.model = pmodel ++var QUAD = [ ++ [0, 0], ++ [0, 1], ++ [1, 0], ++ [1, 1], ++ [1, 0], ++ [0, 1] ++] + +- //Compute initial axes +- var u = (i+1)%3 +- var v = (i+2)%3 +- var du = zeroVec(U_VEC) +- var dv = zeroVec(V_VEC) +- du[u] = 1 +- dv[v] = 1 ++var PERMUTATIONS = [ ++ [0, 0, 0, 0, 0, 0, 0, 0, 0], ++ [0, 0, 0, 0, 0, 0, 0, 0, 0], ++ [0, 0, 0, 0, 0, 0, 0, 0, 0] ++] + +- //Align orientation relative to viewer +- var mdu = project(projection, view, model, augment(MU_VEC, du)) +- var mdv = project(projection, view, model, augment(MV_VEC, dv)) +- if(Math.abs(mdu[1]) > Math.abs(mdv[1])) { +- var tmp = mdu +- mdu = mdv +- mdv = tmp +- tmp = du +- du = dv +- dv = tmp +- var t = u +- u = v +- v = t +- } +- if(mdu[0] < 0) { +- du[u] = -1 +- } +- if(mdv[1] > 0) { +- dv[v] = -1 +- } +- var su = 0.0 +- var sv = 0.0 +- for(var j=0; j<4; ++j) { +- su += Math.pow(model[4*u+j], 2) +- sv += Math.pow(model[4*v+j], 2) +- } +- du[u] /= Math.sqrt(su) +- dv[v] /= Math.sqrt(sv) +- uniforms.axes[0] = du +- uniforms.axes[1] = dv ++;(function () { ++ for (var i = 0; i < 3; ++i) { ++ var p = PERMUTATIONS[i] ++ var u = (i + 1) % 3 ++ var v = (i + 2) % 3 ++ p[u + 0] = 1 ++ p[v + 3] = 1 ++ p[i + 6] = 1 ++ } ++})() + +- //Update fragment clip bounds +- uniforms.fragClipBounds[0] = setComponent(SCRATCH_VEC, clipBounds[0], i, -1e8) +- uniforms.fragClipBounds[1] = setComponent(SCRATCH_VEC, clipBounds[1], i, 1e8) ++function SurfacePickResult (position, index, uv, level, dataCoordinate) { ++ this.position = position ++ this.index = index ++ this.uv = uv ++ this.level = level ++ this.dataCoordinate = dataCoordinate ++} + +- //Draw interior +- points.vao.draw(gl.TRIANGLES, points.vertexCount) ++var N_COLORS = 265 + +- //Draw edges +- if(points.lineWidth > 0) { +- gl.lineWidth(points.lineWidth) +- points.vao.draw(gl.LINES, points.lineVertexCount, points.vertexCount) +- } +- } ++function genColormap (name) { ++ var x = pack([colormap({ ++ colormap: name, ++ nshades: N_COLORS, ++ format: 'rgba' ++ }).map(function (c) { ++ return [c[0], c[1], c[2], 255 * c[3]] ++ })]) ++ ops.divseq(x, 255.0) ++ return x + } + ++function SurfacePlot ( ++ gl, ++ shape, ++ bounds, ++ shader, ++ pickShader, ++ coordinates, ++ vao, ++ colorMap, ++ contourShader, ++ contourPickShader, ++ contourBuffer, ++ contourVAO, ++ dynamicBuffer, ++ dynamicVAO) { ++ this.gl = gl ++ this.shape = shape ++ this.bounds = bounds ++ this.intensityBounds = []; + +-var NEG_INFINITY3 = [-1e8, -1e8, -1e8] +-var POS_INFINITY3 = [1e8, 1e8, 1e8] +-var CLIP_GROUP = [NEG_INFINITY3, POS_INFINITY3] ++ this._shader = shader ++ this._pickShader = pickShader ++ this._coordinateBuffer = coordinates ++ this._vao = vao ++ this._colorMap = colorMap + +-function drawFull(shader, pshader, points, camera, transparent, forceDraw) { +- var gl = points.gl ++ this._contourShader = contourShader ++ this._contourPickShader = contourPickShader ++ this._contourBuffer = contourBuffer ++ this._contourVAO = contourVAO ++ this._contourOffsets = [[], [], []] ++ this._contourCounts = [[], [], []] ++ this._vertexCount = 0 + +- points.vao.bind() ++ this._pickResult = new SurfacePickResult([0, 0, 0], [0, 0], [0, 0], [0, 0, 0], [0, 0, 0]) + +- if(transparent === (points.opacity < 1) || forceDraw) { +- shader.bind() +- var uniforms = shader.uniforms ++ this._dynamicBuffer = dynamicBuffer ++ this._dynamicVAO = dynamicVAO ++ this._dynamicOffsets = [0, 0, 0] ++ this._dynamicCounts = [0, 0, 0] + +- uniforms.model = camera.model || IDENTITY +- uniforms.view = camera.view || IDENTITY +- uniforms.projection = camera.projection || IDENTITY ++ this.contourWidth = [ 1, 1, 1 ] ++ this.contourLevels = [[1], [1], [1]] ++ this.contourTint = [0, 0, 0] ++ this.contourColor = [[0.5, 0.5, 0.5, 1], [0.5, 0.5, 0.5, 1], [0.5, 0.5, 0.5, 1]] + +- VIEW_SHAPE[0] = 2.0/gl.drawingBufferWidth +- VIEW_SHAPE[1] = 2.0/gl.drawingBufferHeight +- uniforms.screenSize = VIEW_SHAPE ++ this.showContour = true ++ this.showSurface = true + +- uniforms.highlightId = points.highlightId +- uniforms.highlightScale = points.highlightScale ++ this.enableHighlight = [true, true, true] ++ this.highlightColor = [[0, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 1]] ++ this.highlightTint = [ 1, 1, 1 ] ++ this.highlightLevel = [-1, -1, -1] + +- uniforms.fragClipBounds = CLIP_GROUP +- uniforms.clipBounds = points.axes.bounds ++ // Dynamic contour options ++ this.enableDynamic = [ true, true, true ] ++ this.dynamicLevel = [ NaN, NaN, NaN ] ++ this.dynamicColor = [ [0, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 1] ] ++ this.dynamicTint = [ 1, 1, 1 ] ++ this.dynamicWidth = [ 1, 1, 1 ] + +- uniforms.opacity = points.opacity +- uniforms.pickGroup = points.pickId / 255.0 ++ this.axesBounds = [[Infinity, Infinity, Infinity], [-Infinity, -Infinity, -Infinity]] ++ this.surfaceProject = [ false, false, false ] ++ this.contourProject = [[ false, false, false ], ++ [ false, false, false ], ++ [ false, false, false ]] + +- uniforms.pixelRatio = points.pixelRatio ++ this.colorBounds = [ false, false ] + +- //Draw interior +- points.vao.draw(gl.TRIANGLES, points.vertexCount) ++ // Store xyz fields, need this for picking ++ this._field = [ ++ ndarray(pool.mallocFloat(1024), [0, 0]), ++ ndarray(pool.mallocFloat(1024), [0, 0]), ++ ndarray(pool.mallocFloat(1024), [0, 0]) ] + +- //Draw edges +- if(points.lineWidth > 0) { +- gl.lineWidth(points.lineWidth) +- points.vao.draw(gl.LINES, points.lineVertexCount, points.vertexCount) +- } +- } ++ this.pickId = 1 ++ this.clipBounds = [[-Infinity, -Infinity, -Infinity], [Infinity, Infinity, Infinity]] + +- drawProject(pshader, points, camera, transparent, forceDraw) ++ this.snapToData = false + +- points.vao.unbind() +-} ++ this.opacity = 1.0 + +-proto.draw = function(camera) { +- var shader = this.useOrtho ? this.orthoShader : this.shader +- drawFull(shader, this.projectShader, this, camera, false, false) +-} ++ this.lightPosition = [10, 10000, 0] ++ this.ambientLight = 0.8 ++ this.diffuseLight = 0.8 ++ this.specularLight = 2.0 ++ this.roughness = 0.5 ++ this.fresnel = 1.5 + +-proto.drawTransparent = function(camera) { +- var shader = this.useOrtho ? this.orthoShader : this.shader +- drawFull(shader, this.projectShader, this, camera, true, false) ++ this.dirty = true + } + +-proto.drawPick = function(camera) { +- var shader = this.useOrtho ? this.pickOrthoShader : this.pickPerspectiveShader +- drawFull(shader, this.pickProjectShader, this, camera, false, true) ++var proto = SurfacePlot.prototype ++ ++proto.isTransparent = function () { ++ return this.opacity < 1 + } + +-proto.pick = function(selected) { +- if(!selected) { +- return null +- } +- if(selected.id !== this.pickId) { +- return null ++proto.isOpaque = function () { ++ if (this.opacity >= 1) { ++ return true + } +- var x = selected.value[2] + (selected.value[1]<<8) + (selected.value[0]<<16) +- if(x >= this.pointCount || x < 0) { +- return null ++ for (var i = 0; i < 3; ++i) { ++ if (this._contourCounts[i].length > 0 || this._dynamicCounts[i] > 0) { ++ return true ++ } + } ++ return false ++} + +- //Unpack result +- var coord = this.points[x] +- var result = this._selectResult +- result.index = x +- for(var i=0; i<3; ++i) { +- result.position[i] = result.dataCoordinate[i] = coord[i] +- } +- return result ++proto.pickSlots = 1 ++ ++proto.setPickBase = function (id) { ++ this.pickId = id + } + +-proto.highlight = function(selection) { +- if(!selection) { +- this.highlightId = [1,1,1,1] +- } else { +- var pointId = selection.index +- var a0 = pointId &0xff +- var a1 = (pointId>>8) &0xff +- var a2 = (pointId>>16)&0xff +- this.highlightId = [a0/255.0, a1/255.0, a2/255.0, 0] +- } ++var ZERO_VEC = [0, 0, 0] ++ ++var PROJECT_DATA = { ++ showSurface: false, ++ showContour: false, ++ projections: [IDENTITY.slice(), IDENTITY.slice(), IDENTITY.slice()], ++ clipBounds: [ ++ [[0, 0, 0], [0, 0, 0]], ++ [[0, 0, 0], [0, 0, 0]], ++ [[0, 0, 0], [0, 0, 0]]] + } + +-proto.update = function(options) { ++function computeProjectionData (camera, obj) { ++ var i, j, k + +- options = options || {} ++ // Compute cube properties ++ var cubeAxis = (obj.axes && obj.axes.lastCubeProps.axis) || ZERO_VEC + +- if('perspective' in options) { +- this.useOrtho = !options.perspective +- } +- if('orthographic' in options) { +- this.useOrtho = !!options.orthographic +- } +- if('lineWidth' in options) { +- this.lineWidth = options.lineWidth +- } +- if('project' in options) { +- if(Array.isArray(options.project)) { +- this.axesProject = options.project +- } else { +- var v = !!options.project +- this.axesProject = [v,v,v] ++ var showSurface = obj.showSurface ++ var showContour = obj.showContour ++ ++ for (i = 0; i < 3; ++i) { ++ showSurface = showSurface || obj.surfaceProject[i] ++ for (j = 0; j < 3; ++j) { ++ showContour = showContour || obj.contourProject[i][j] + } + } +- if('projectScale' in options) { +- if(Array.isArray(options.projectScale)) { +- this.projectScale = options.projectScale.slice() +- } else { +- var s = +options.projectScale +- this.projectScale = [s,s,s] ++ ++ for (i = 0; i < 3; ++i) { ++ // Construct projection onto axis ++ var axisSquish = PROJECT_DATA.projections[i] ++ for (j = 0; j < 16; ++j) { ++ axisSquish[j] = 0 + } +- } +- if('projectOpacity' in options) { +- if(Array.isArray(options.projectOpacity)) { +- this.projectOpacity = options.projectOpacity.slice() +- } else { +- var s = +options.projectOpacity +- this.projectOpacity = [s,s,s] ++ for (j = 0; j < 4; ++j) { ++ axisSquish[5 * j] = 1 + } +- } +- if('opacity' in options) { +- this.opacity = options.opacity ++ axisSquish[5 * i] = 0 ++ axisSquish[12 + i] = obj.axesBounds[+(cubeAxis[i] > 0)][i] ++ multiply(axisSquish, camera.model, axisSquish) ++ ++ var nclipBounds = PROJECT_DATA.clipBounds[i] ++ for (k = 0; k < 2; ++k) { ++ for (j = 0; j < 3; ++j) { ++ nclipBounds[k][j] = camera.clipBounds[k][j] ++ } ++ } ++ nclipBounds[0][i] = -1e8 ++ nclipBounds[1][i] = 1e8 + } + +- //Set dirty flag +- this.dirty = true ++ PROJECT_DATA.showSurface = showSurface ++ PROJECT_DATA.showContour = showContour + +- //Create new buffers +- var points = options.position +- if(!points) { +- return +- } ++ return PROJECT_DATA ++} + +- //Text font +- var font = options.font || 'normal' +- var alignment = options.alignment || [0,0] ++var UNIFORMS = { ++ model: IDENTITY, ++ view: IDENTITY, ++ projection: IDENTITY, ++ inverseModel: IDENTITY.slice(), ++ lowerBound: [0, 0, 0], ++ upperBound: [0, 0, 0], ++ colorMap: 0, ++ clipBounds: [[0, 0, 0], [0, 0, 0]], ++ height: 0.0, ++ contourTint: 0, ++ contourColor: [0, 0, 0, 1], ++ permutation: [1, 0, 0, 0, 1, 0, 0, 0, 1], ++ zOffset: -1e-4, ++ kambient: 1, ++ kdiffuse: 1, ++ kspecular: 1, ++ lightPosition: [1000, 1000, 1000], ++ eyePosition: [0, 0, 0], ++ roughness: 1, ++ fresnel: 1, ++ opacity: 1 ++} + +- //Bounds +- var lowerBound = [ Infinity, Infinity, Infinity] +- var upperBound = [-Infinity,-Infinity,-Infinity] ++var MATRIX_INVERSE = IDENTITY.slice() ++var DEFAULT_PERM = [1, 0, 0, 0, 1, 0, 0, 0, 1] + +- //Unpack options +- var glyphs = options.glyph +- var colors = options.color +- var sizes = options.size +- var angles = options.angle +- var lineColors = options.lineColor ++function drawCore (params, transparent) { ++ params = params || {} ++ var gl = this.gl + +- //Picking geometry +- var pickCounter = 0 ++ gl.disable(gl.CULL_FACE) + +- //First do pass to compute buffer sizes +- var triVertexCount = 0 +- var lineVertexCount = 0 ++ this._colorMap.bind(0) + +- //Count number of points and buffer size +- var numPoints = points.length ++ var uniforms = UNIFORMS ++ uniforms.model = params.model || IDENTITY ++ uniforms.view = params.view || IDENTITY ++ uniforms.projection = params.projection || IDENTITY ++ uniforms.lowerBound = [this.bounds[0][0], this.bounds[0][1], this.colorBounds[0] || this.bounds[0][2]] ++ uniforms.upperBound = [this.bounds[1][0], this.bounds[1][1], this.colorBounds[1] || this.bounds[1][2]] ++ uniforms.contourColor = this.contourColor[0] + +-count_loop: +- for(var i=0; i 0) { +- textOffset[0] = -alignment[0] * (1+glyphBounds[0][0]) +- } ++ // Draw contour lines ++ var vao = this._contourVAO ++ vao.bind() + +- //Write out inner marker +- var cells = glyphMesh.cells +- var verts = glyphMesh.positions ++ // Draw contour levels ++ for (i = 0; i < 3; ++i) { ++ shader.uniforms.permutation = PERMUTATIONS[i] ++ gl.lineWidth(this.contourWidth[i]) + +- for(var j=0; j_inline_55_arg0_||255>_inline_55_arg1_||255>_inline_55_arg2_||255>_inline_55_arg3_){var _inline_55_l=_inline_55_arg4_-_inline_55_arg6_[0],_inline_55_a=_inline_55_arg5_-_inline_55_arg6_[1],_inline_55_f=_inline_55_l*_inline_55_l+_inline_55_a*_inline_55_a;_inline_55_f this.buffer.length) { +- pool.free(this.buffer) +- var buffer = this.buffer = pool.mallocUint8(nextPow2(r*c*4)) +- for(var i=0; i> 4) / 16.0) / 255.0 ++ var ix = Math.floor(x) ++ var fx = x - ix + +- if(x1 <= x0 || y1 <= y0) { +- return null +- } ++ var y = shape[1] * (selection.value[1] + (selection.value[2] & 15) / 16.0) / 255.0 ++ var iy = Math.floor(y) ++ var fy = y - iy + +- var dims = [x1-x0,y1-y0] +- var region = ndarray( +- this.buffer, +- [dims[0], dims[1], 4], +- [4, shape[0]*4, 1], +- 4*(x0 + shape[0]*y0)); ++ ix += 1 ++ iy += 1 + +- var closest = selectRange(region.hi(dims[0],dims[1],1), radius, radius) +- var dx = closest[0] +- var dy = closest[1] +- if(dx < 0 || Math.pow(this.radius, 2) < closest[2]) { +- return null +- } ++ // Compute xyz coordinate ++ var pos = result.position ++ pos[0] = pos[1] = pos[2] = 0 ++ for (var dx = 0; dx < 2; ++dx) { ++ var s = dx ? fx : 1.0 - fx ++ for (var dy = 0; dy < 2; ++dy) { ++ var t = dy ? fy : 1.0 - fy + +- var c0 = region.get(dx, dy, 0) +- var c1 = region.get(dx, dy, 1) +- var c2 = region.get(dx, dy, 2) +- var c3 = region.get(dx, dy, 3) ++ var r = ix + dx ++ var c = iy + dy ++ var w = s * t + +- return new SelectResult( +- (dx + x0)|0, +- (dy + y0)|0, +- c0, +- [c1, c2, c3], +- Math.sqrt(closest[2])) +-} ++ for (var i = 0; i < 3; ++i) { ++ pos[i] += this._field[i].get(r, c) * w ++ } ++ } ++ } + +-proto.dispose = function() { +- if(!this.gl) { +- return ++ // Find closest level ++ var levelIndex = this._pickResult.level ++ for (var j = 0; j < 3; ++j) { ++ levelIndex[j] = bsearch.le(this.contourLevels[j], pos[j]) ++ if (levelIndex[j] < 0) { ++ if (this.contourLevels[j].length > 0) { ++ levelIndex[j] = 0 ++ } ++ } else if (levelIndex[j] < this.contourLevels[j].length - 1) { ++ var a = this.contourLevels[j][levelIndex[j]] ++ var b = this.contourLevels[j][levelIndex[j] + 1] ++ if (Math.abs(a - pos[j]) > Math.abs(b - pos[j])) { ++ levelIndex[j] += 1 ++ } ++ } + } +- this.fbo.dispose() +- pool.free(this.buffer) +- this.gl = null +- if(this._readTimeout) { +- clearTimeout(this._readTimeout) ++ ++ result.index[0] = fx < 0.5 ? ix : (ix + 1) ++ result.index[1] = fy < 0.5 ? iy : (iy + 1) ++ ++ result.uv[0] = x / shape[0] ++ result.uv[1] = y / shape[1] ++ ++ for (i = 0; i < 3; ++i) { ++ result.dataCoordinate[i] = this._field[i].get(result.index[0], result.index[1]) + } +-} + +-function createSelectBuffer(gl, shape) { +- var fbo = createFBO(gl, shape) +- var buffer = pool.mallocUint8(shape[0]*shape[1]*4) +- return new SelectBuffer(gl, fbo, buffer) ++ return result + } + +-},{"bit-twiddle":38,"cwise/lib/wrapper":99,"gl-fbo":108,"ndarray":219,"typedarray-pool":242}],164:[function(require,module,exports){ +-'use strict' +- +-var createUniformWrapper = require('./lib/create-uniforms') +-var createAttributeWrapper = require('./lib/create-attributes') +-var makeReflect = require('./lib/reflect') +-var shaderCache = require('./lib/shader-cache') +-var runtime = require('./lib/runtime-reflect') +-var GLError = require("./lib/GLError") ++function padField (nfield, field) { ++ var shape = field.shape.slice() ++ var nshape = nfield.shape.slice() + +-//Shader object +-function Shader(gl) { +- this.gl = gl ++ // Center ++ ops.assign(nfield.lo(1, 1).hi(shape[0], shape[1]), field) + +- //Default initialize these to null +- this._vref = +- this._fref = +- this._relink = +- this.vertShader = +- this.fragShader = +- this.program = +- this.attributes = +- this.uniforms = +- this.types = null ++ // Edges ++ ops.assign(nfield.lo(1).hi(shape[0], 1), ++ field.hi(shape[0], 1)) ++ ops.assign(nfield.lo(1, nshape[1] - 1).hi(shape[0], 1), ++ field.lo(0, shape[1] - 1).hi(shape[0], 1)) ++ ops.assign(nfield.lo(0, 1).hi(1, shape[1]), ++ field.hi(1)) ++ ops.assign(nfield.lo(nshape[0] - 1, 1).hi(1, shape[1]), ++ field.lo(shape[0] - 1)) ++ // Corners ++ nfield.set(0, 0, field.get(0, 0)) ++ nfield.set(0, nshape[1] - 1, field.get(0, shape[1] - 1)) ++ nfield.set(nshape[0] - 1, 0, field.get(shape[0] - 1, 0)) ++ nfield.set(nshape[0] - 1, nshape[1] - 1, field.get(shape[0] - 1, shape[1] - 1)) + } + +-var proto = Shader.prototype +- +-proto.bind = function() { +- if(!this.program) { +- this._relink() ++function handleArray (param, ctor) { ++ if (Array.isArray(param)) { ++ return [ ctor(param[0]), ctor(param[1]), ctor(param[2]) ] + } +- this.gl.useProgram(this.program) ++ return [ ctor(param), ctor(param), ctor(param) ] + } + +-proto.dispose = function() { +- if(this._fref) { +- this._fref.dispose() +- } +- if(this._vref) { +- this._vref.dispose() ++function toColor (x) { ++ if (Array.isArray(x)) { ++ if (x.length === 3) { ++ return [x[0], x[1], x[2], 1] ++ } ++ return [x[0], x[1], x[2], x[3]] + } +- this.attributes = +- this.types = +- this.vertShader = +- this.fragShader = +- this.program = +- this._relink = +- this._fref = +- this._vref = null ++ return [0, 0, 0, 1] + } + +-function compareAttributes(a, b) { +- if(a.name < b.name) { +- return -1 ++function handleColor (param) { ++ if (Array.isArray(param)) { ++ if (Array.isArray(param)) { ++ return [ ++ toColor(param[0]), ++ toColor(param[1]), ++ toColor(param[2]) ] ++ } else { ++ var c = toColor(param) ++ return [ ++ c.slice(), ++ c.slice(), ++ c.slice() ] ++ } + } +- return 1 + } + +-//Update export hook for glslify-live +-proto.update = function( +- vertSource +- , fragSource +- , uniforms +- , attributes) { ++proto.update = function (params) { ++ params = params || {} + +- //If only one object passed, assume glslify style output +- if(!fragSource || arguments.length === 1) { +- var obj = vertSource +- vertSource = obj.vertex +- fragSource = obj.fragment +- uniforms = obj.uniforms +- attributes = obj.attributes ++ this.dirty = true ++ ++ if ('contourWidth' in params) { ++ this.contourWidth = handleArray(params.contourWidth, Number) ++ } ++ if ('showContour' in params) { ++ this.showContour = handleArray(params.showContour, Boolean) ++ } ++ if ('showSurface' in params) { ++ this.showSurface = !!params.showSurface ++ } ++ if ('contourTint' in params) { ++ this.contourTint = handleArray(params.contourTint, Boolean) ++ } ++ if ('contourColor' in params) { ++ this.contourColor = handleColor(params.contourColor) ++ } ++ if ('contourProject' in params) { ++ this.contourProject = handleArray(params.contourProject, function (x) { ++ return handleArray(x, Boolean) ++ }) ++ } ++ if ('surfaceProject' in params) { ++ this.surfaceProject = params.surfaceProject ++ } ++ if ('dynamicColor' in params) { ++ this.dynamicColor = handleColor(params.dynamicColor) ++ } ++ if ('dynamicTint' in params) { ++ this.dynamicTint = handleArray(params.dynamicTint, Number) ++ } ++ if ('dynamicWidth' in params) { ++ this.dynamicWidth = handleArray(params.dynamicWidth, Number) ++ } ++ if ('opacity' in params) { ++ this.opacity = params.opacity ++ } ++ if ('colorBounds' in params) { ++ this.colorBounds = params.colorBounds + } + +- var wrapper = this +- var gl = wrapper.gl ++ var field = params.field || (params.coords && params.coords[2]) || null ++ var levelsChanged = false + +- //Compile vertex and fragment shaders +- var pvref = wrapper._vref +- wrapper._vref = shaderCache.shader(gl, gl.VERTEX_SHADER, vertSource) +- if(pvref) { +- pvref.dispose() +- } +- wrapper.vertShader = wrapper._vref.shader +- var pfref = this._fref +- wrapper._fref = shaderCache.shader(gl, gl.FRAGMENT_SHADER, fragSource) +- if(pfref) { +- pfref.dispose() ++ if (!field) { ++ if (this._field[2].shape[0] || this._field[2].shape[2]) { ++ field = this._field[2].lo(1, 1).hi(this._field[2].shape[0] - 2, this._field[2].shape[1] - 2) ++ } else { ++ field = this._field[2].hi(0, 0) ++ } + } +- wrapper.fragShader = wrapper._fref.shader + +- //If uniforms/attributes is not specified, use RT reflection +- if(!uniforms || !attributes) { ++ // Update field ++ if ('field' in params || 'coords' in params) { ++ var fsize = (field.shape[0] + 2) * (field.shape[1] + 2) + +- //Create initial test program +- var testProgram = gl.createProgram() +- gl.attachShader(testProgram, wrapper.fragShader) +- gl.attachShader(testProgram, wrapper.vertShader) +- gl.linkProgram(testProgram) +- if(!gl.getProgramParameter(testProgram, gl.LINK_STATUS)) { +- var errLog = gl.getProgramInfoLog(testProgram) +- throw new GLError(errLog, 'Error linking program:' + errLog) ++ // Resize if necessary ++ if (fsize > this._field[2].data.length) { ++ pool.freeFloat(this._field[2].data) ++ this._field[2].data = pool.mallocFloat(bits.nextPow2(fsize)) + } + +- //Load data from runtime +- uniforms = uniforms || runtime.uniforms(gl, testProgram) +- attributes = attributes || runtime.attributes(gl, testProgram) ++ // Pad field ++ this._field[2] = ndarray(this._field[2].data, [field.shape[0] + 2, field.shape[1] + 2]) ++ padField(this._field[2], field) ++ ++ // Save shape of field ++ this.shape = field.shape.slice() ++ var shape = this.shape ++ ++ // Resize coordinate fields if necessary ++ for (var i = 0; i < 2; ++i) { ++ if (this._field[2].size > this._field[i].data.length) { ++ pool.freeFloat(this._field[i].data) ++ this._field[i].data = pool.mallocFloat(this._field[2].size) ++ } ++ this._field[i] = ndarray(this._field[i].data, [shape[0] + 2, shape[1] + 2]) ++ } ++ ++ // Generate x/y coordinates ++ if (params.coords) { ++ var coords = params.coords ++ if (!Array.isArray(coords) || coords.length !== 3) { ++ throw new Error('gl-surface: invalid coordinates for x/y') ++ } ++ for (i = 0; i < 2; ++i) { ++ var coord = coords[i] ++ for (j = 0; j < 2; ++j) { ++ if (coord.shape[j] !== shape[j]) { ++ throw new Error('gl-surface: coords have incorrect shape') ++ } ++ } ++ padField(this._field[i], coord) ++ } ++ } else if (params.ticks) { ++ var ticks = params.ticks ++ if (!Array.isArray(ticks) || ticks.length !== 2) { ++ throw new Error('gl-surface: invalid ticks') ++ } ++ for (i = 0; i < 2; ++i) { ++ var tick = ticks[i] ++ if (Array.isArray(tick) || tick.length) { ++ tick = ndarray(tick) ++ } ++ if (tick.shape[0] !== shape[i]) { ++ throw new Error('gl-surface: invalid tick length') ++ } ++ // Make a copy view of the tick array ++ var tick2 = ndarray(tick.data, shape) ++ tick2.stride[i] = tick.stride[0] ++ tick2.stride[i ^ 1] = 0 ++ ++ // Fill in field array ++ padField(this._field[i], tick2) ++ } ++ } else { ++ for (i = 0; i < 2; ++i) { ++ var offset = [0, 0] ++ offset[i] = 1 ++ this._field[i] = ndarray(this._field[i].data, [shape[0] + 2, shape[1] + 2], offset, 0) ++ } ++ this._field[0].set(0, 0, 0) ++ for (var j = 0; j < shape[0]; ++j) { ++ this._field[0].set(j + 1, 0, j) ++ } ++ this._field[0].set(shape[0] + 1, 0, shape[0] - 1) ++ this._field[1].set(0, 0, 0) ++ for (j = 0; j < shape[1]; ++j) { ++ this._field[1].set(0, j + 1, j) ++ } ++ this._field[1].set(0, shape[1] + 1, shape[1] - 1) ++ } ++ ++ // Save shape ++ var fields = this._field ++ ++ // Compute surface normals ++ var dfields = ndarray(pool.mallocFloat(fields[2].size * 3 * 2), [3, shape[0] + 2, shape[1] + 2, 2]) ++ for (i = 0; i < 3; ++i) { ++ gradient(dfields.pick(i), fields[i], 'mirror') ++ } ++ var normals = ndarray(pool.mallocFloat(fields[2].size * 3), [shape[0] + 2, shape[1] + 2, 3]) ++ for (i = 0; i < shape[0] + 2; ++i) { ++ for (j = 0; j < shape[1] + 2; ++j) { ++ var dxdu = dfields.get(0, i, j, 0) ++ var dxdv = dfields.get(0, i, j, 1) ++ var dydu = dfields.get(1, i, j, 0) ++ var dydv = dfields.get(1, i, j, 1) ++ var dzdu = dfields.get(2, i, j, 0) ++ var dzdv = dfields.get(2, i, j, 1) ++ ++ var nx = dydu * dzdv - dydv * dzdu ++ var ny = dzdu * dxdv - dzdv * dxdu ++ var nz = dxdu * dydv - dxdv * dydu ++ ++ var nl = Math.sqrt(nx * nx + ny * ny + nz * nz) ++ if (nl < 1e-8) { ++ nl = Math.max(Math.abs(nx), Math.abs(ny), Math.abs(nz)) ++ if (nl < 1e-8) { ++ nz = 1.0 ++ ny = nx = 0.0 ++ nl = 1.0 ++ } else { ++ nl = 1.0 / nl ++ } ++ } else { ++ nl = 1.0 / Math.sqrt(nl) ++ } ++ ++ normals.set(i, j, 0, nx * nl) ++ normals.set(i, j, 1, ny * nl) ++ normals.set(i, j, 2, nz * nl) ++ } ++ } ++ pool.free(dfields.data) ++ ++ // Initialize surface ++ var lo = [ Infinity, Infinity, Infinity ] ++ var hi = [ -Infinity, -Infinity, -Infinity ] ++ var lo_intensity = Infinity ++ var hi_intensity = -Infinity ++ var count = (shape[0] - 1) * (shape[1] - 1) * 6 ++ var tverts = pool.mallocFloat(bits.nextPow2(10 * count)) ++ var tptr = 0 ++ var vertexCount = 0 ++ for (i = 0; i < shape[0] - 1; ++i) { ++ j_loop: ++ for (j = 0; j < shape[1] - 1; ++j) { ++ // Test for NaNs ++ for (var dx = 0; dx < 2; ++dx) { ++ for (var dy = 0; dy < 2; ++dy) { ++ for (var k = 0; k < 3; ++k) { ++ var f = this._field[k].get(1 + i + dx, 1 + j + dy) ++ if (isNaN(f) || !isFinite(f)) { ++ continue j_loop ++ } ++ } ++ } ++ } ++ for (k = 0; k < 6; ++k) { ++ var r = i + QUAD[k][0] ++ var c = j + QUAD[k][1] ++ ++ var tx = this._field[0].get(r + 1, c + 1) ++ var ty = this._field[1].get(r + 1, c + 1) ++ f = this._field[2].get(r + 1, c + 1) ++ var vf = f ++ nx = normals.get(r + 1, c + 1, 0) ++ ny = normals.get(r + 1, c + 1, 1) ++ nz = normals.get(r + 1, c + 1, 2) ++ ++ if (params.intensity) { ++ vf = params.intensity.get(r, c) ++ } + +- //Release test program +- gl.deleteProgram(testProgram) +- } ++ tverts[tptr++] = r ++ tverts[tptr++] = c ++ tverts[tptr++] = tx ++ tverts[tptr++] = ty ++ tverts[tptr++] = f ++ tverts[tptr++] = 0 ++ tverts[tptr++] = vf ++ tverts[tptr++] = nx ++ tverts[tptr++] = ny ++ tverts[tptr++] = nz + +- //Sort attributes lexicographically +- // overrides undefined WebGL behavior for attribute locations +- attributes = attributes.slice() +- attributes.sort(compareAttributes) ++ lo[0] = Math.min(lo[0], tx) ++ lo[1] = Math.min(lo[1], ty) ++ lo[2] = Math.min(lo[2], f) ++ lo_intensity = Math.min(lo_intensity, vf) + +- //Convert attribute types, read out locations +- var attributeUnpacked = [] +- var attributeNames = [] +- var attributeLocations = [] +- for(var i=0; i= 0) { +- var size = attr.type.charAt(attr.type.length-1)|0 +- var locVector = new Array(size) +- for(var j=0; j= 0) { +- curLocation += 1 +- } +- attributeLocations[i] = curLocation ++ if (params.intensityBounds) { ++ lo_intensity = +params.intensityBounds[0] ++ hi_intensity = +params.intensityBounds[1] + } +- } +- +- //Rebuild program and recompute all uniform locations +- var uniformLocations = new Array(uniforms.length) +- function relink() { +- wrapper.program = shaderCache.program( +- gl +- , wrapper._vref +- , wrapper._fref +- , attributeNames +- , attributeLocations) + +- for(var i=0; i 0) { ++ // If we already added first edge, pop off verts ++ for (var l = 0; l < 5; ++l) { ++ contourVerts.pop() ++ } ++ vertexCount -= 1 ++ } ++ continue edge_loop ++ } ++ } ++ } ++ levelCounts.push(vertexCount) ++ } + +-proto.pointer = function setAttribPointer( +- type +- , normalized +- , stride +- , offset) { ++ // Store results ++ this._contourOffsets[dim] = levelOffsets ++ this._contourCounts[dim] = levelCounts ++ } + +- var self = this +- var gl = self._gl +- var location = self._locations[self._index] ++ var floatBuffer = pool.mallocFloat(contourVerts.length) ++ for (i = 0; i < contourVerts.length; ++i) { ++ floatBuffer[i] = contourVerts[i] ++ } ++ this._contourBuffer.update(floatBuffer) ++ pool.freeFloat(floatBuffer) ++ } + +- gl.vertexAttribPointer( +- location +- , self._dimension +- , type || gl.FLOAT +- , !!normalized +- , stride || 0 +- , offset || 0) +- gl.enableVertexAttribArray(location) ++ if (params.colormap) { ++ this._colorMap.setPixels(genColormap(params.colormap)) ++ } + } + +-proto.set = function(x0, x1, x2, x3) { +- return this._constFunc(this._locations[this._index], x0, x1, x2, x3) ++proto.dispose = function () { ++ this._shader.dispose() ++ this._vao.dispose() ++ this._coordinateBuffer.dispose() ++ this._colorMap.dispose() ++ this._contourBuffer.dispose() ++ this._contourVAO.dispose() ++ this._contourShader.dispose() ++ this._contourPickShader.dispose() ++ this._dynamicBuffer.dispose() ++ this._dynamicVAO.dispose() ++ for (var i = 0; i < 3; ++i) { ++ pool.freeFloat(this._field[i].data) ++ } + } + +-Object.defineProperty(proto, 'location', { +- get: function() { +- return this._locations[this._index] ++proto.highlight = function (selection) { ++ if (!selection) { ++ this._dynamicCounts = [0, 0, 0] ++ this.dyanamicLevel = [NaN, NaN, NaN] ++ this.highlightLevel = [-1, -1, -1] ++ return + } +- , set: function(v) { +- if(v !== this._locations[this._index]) { +- this._locations[this._index] = v|0 +- this._wrapper.program = null ++ ++ for (var i = 0; i < 3; ++i) { ++ if (this.enableHighlight[i]) { ++ this.highlightLevel[i] = selection.level[i] ++ } else { ++ this.highlightLevel[i] = -1 + } +- return v|0 + } +-}) +- +-//Adds a vector attribute to obj +-function addVectorAttribute( +- gl +- , wrapper +- , index +- , locations +- , dimension +- , obj +- , name) { + +- //Construct constant function +- var constFuncArgs = [ 'gl', 'v' ] +- var varNames = [] +- for(var i=0; i= 0) { +- var d = type.charCodeAt(type.length-1) - 48 +- if(d < 2 || d > 4) { +- throw new GLError('', 'Invalid data type for attribute ' + name + ': ' + type) +- } +- addVectorAttribute( +- gl +- , wrapper +- , locs[0] +- , locations +- , d +- , obj +- , name) +- } else if(type.indexOf('mat') >= 0) { +- var d = type.charCodeAt(type.length-1) - 48 +- if(d < 2 || d > 4) { +- throw new GLError('', 'Invalid data type for attribute ' + name + ': ' + type) +- } +- addMatrixAttribute( +- gl +- , wrapper +- , locs +- , locations +- , d +- , obj +- , name) +- } else { +- throw new GLError('', 'Unknown data type for attribute ' + name + ': ' + type) +- } +- break ++ var contourBuffer = createBuffer(gl) ++ var contourVAO = createVAO(gl, [ ++ { ++ buffer: contourBuffer, ++ size: 4, ++ stride: 20, ++ offset: 0 ++ }, ++ { ++ buffer: contourBuffer, ++ size: 1, ++ stride: 20, ++ offset: 16 + } ++ ]) ++ ++ var dynamicBuffer = createBuffer(gl) ++ var dynamicVAO = createVAO(gl, [ ++ { ++ buffer: dynamicBuffer, ++ size: 2, ++ type: gl.FLOAT ++ }]) ++ ++ var cmap = createTexture(gl, 1, N_COLORS, gl.RGBA, gl.UNSIGNED_BYTE) ++ cmap.minFilter = gl.LINEAR ++ cmap.magFilter = gl.LINEAR ++ ++ var surface = new SurfacePlot( ++ gl, ++ [0, 0], ++ [[0, 0, 0], [0, 0, 0]], ++ shader, ++ pickShader, ++ coordinateBuffer, ++ vao, ++ cmap, ++ contourShader, ++ contourPickShader, ++ contourBuffer, ++ contourVAO, ++ dynamicBuffer, ++ dynamicVAO) ++ ++ var nparams = { ++ levels: [[], [], []] + } +- return obj ++ for (var id in params) { ++ nparams[id] = params[id] ++ } ++ nparams.colormap = nparams.colormap || 'jet' ++ ++ surface.update(nparams) ++ ++ return surface + } + +-},{"./GLError":165}],167:[function(require,module,exports){ ++},{"./lib/shaders":142,"binary-search-bounds":34,"bit-twiddle":35,"colormap":61,"gl-buffer":94,"gl-mat4/invert":111,"gl-mat4/multiply":113,"gl-texture2d":144,"gl-vao":148,"ndarray":191,"ndarray-gradient":182,"ndarray-ops":185,"ndarray-pack":186,"surface-nets":239,"typedarray-pool":246}],144:[function(require,module,exports){ + 'use strict' + +-var coallesceUniforms = require('./reflect') +-var GLError = require("./GLError") ++var ndarray = require('ndarray') ++var ops = require('ndarray-ops') ++var pool = require('typedarray-pool') + +-module.exports = createUniformWrapper ++module.exports = createTexture2D + +-//Binds a function and returns a value +-function identity(x) { +- var c = new Function('y', 'return function(){return y}') +- return c(x) ++var linearTypes = null ++var filterTypes = null ++var wrapTypes = null ++ ++function lazyInitLinearTypes(gl) { ++ linearTypes = [ ++ gl.LINEAR, ++ gl.NEAREST_MIPMAP_LINEAR, ++ gl.LINEAR_MIPMAP_NEAREST, ++ gl.LINEAR_MIPMAP_NEAREST ++ ] ++ filterTypes = [ ++ gl.NEAREST, ++ gl.LINEAR, ++ gl.NEAREST_MIPMAP_NEAREST, ++ gl.NEAREST_MIPMAP_LINEAR, ++ gl.LINEAR_MIPMAP_NEAREST, ++ gl.LINEAR_MIPMAP_LINEAR ++ ] ++ wrapTypes = [ ++ gl.REPEAT, ++ gl.CLAMP_TO_EDGE, ++ gl.MIRRORED_REPEAT ++ ] + } + +-function makeVector(length, fill) { +- var result = new Array(length) +- for(var i=0; i maxSize || h < 0 || h > maxSize) { ++ throw new Error('gl-texture2d: Invalid texture size') + } +- return result ++ tex._shape = [w, h] ++ tex.bind() ++ gl.texImage2D(gl.TEXTURE_2D, 0, tex.format, w, h, 0, tex.format, tex.type, null) ++ tex._mipLevels = [0] ++ return tex + } + +-//Create shims for uniforms +-function createUniformWrapper(gl, wrapper, uniforms, locations) { ++function Texture2D(gl, handle, width, height, format, type) { ++ this.gl = gl ++ this.handle = handle ++ this.format = format ++ this.type = type ++ this._shape = [width, height] ++ this._mipLevels = [0] ++ this._magFilter = gl.NEAREST ++ this._minFilter = gl.NEAREST ++ this._wrapS = gl.CLAMP_TO_EDGE ++ this._wrapT = gl.CLAMP_TO_EDGE ++ this._anisoSamples = 1 + +- function makeGetter(index) { +- var proc = new Function( +- 'gl' +- , 'wrapper' +- , 'locations' +- , 'return function(){return gl.getUniform(wrapper.program,locations[' + index + '])}') +- return proc(gl, wrapper, locations) +- } ++ var parent = this ++ var wrapVector = [this._wrapS, this._wrapT] ++ Object.defineProperties(wrapVector, [ ++ { ++ get: function() { ++ return parent._wrapS ++ }, ++ set: function(v) { ++ return parent.wrapS = v ++ } ++ }, ++ { ++ get: function() { ++ return parent._wrapT ++ }, ++ set: function(v) { ++ return parent.wrapT = v ++ } ++ } ++ ]) ++ this._wrapVector = wrapVector + +- function makePropSetter(path, index, type) { +- switch(type) { +- case 'bool': +- case 'int': +- case 'sampler2D': +- case 'samplerCube': +- return 'gl.uniform1i(locations[' + index + '],obj' + path + ')' +- case 'float': +- return 'gl.uniform1f(locations[' + index + '],obj' + path + ')' +- default: +- var vidx = type.indexOf('vec') +- if(0 <= vidx && vidx <= 1 && type.length === 4 + vidx) { +- var d = type.charCodeAt(type.length-1) - 48 +- if(d < 2 || d > 4) { +- throw new GLError('', 'Invalid data type') +- } +- switch(type.charAt(0)) { +- case 'b': +- case 'i': +- return 'gl.uniform' + d + 'iv(locations[' + index + '],obj' + path + ')' +- case 'v': +- return 'gl.uniform' + d + 'fv(locations[' + index + '],obj' + path + ')' +- default: +- throw new GLError('', 'Unrecognized data type for vector ' + name + ': ' + type) +- } +- } else if(type.indexOf('mat') === 0 && type.length === 4) { +- var d = type.charCodeAt(type.length-1) - 48 +- if(d < 2 || d > 4) { +- throw new GLError('', 'Invalid uniform dimension type for matrix ' + name + ': ' + type) +- } +- return 'gl.uniformMatrix' + d + 'fv(locations[' + index + '],false,obj' + path + ')' +- } else { +- throw new GLError('', 'Unknown uniform data type for ' + name + ': ' + type) +- } +- break ++ var shapeVector = [this._shape[0], this._shape[1]] ++ Object.defineProperties(shapeVector, [ ++ { ++ get: function() { ++ return parent._shape[0] ++ }, ++ set: function(v) { ++ return parent.width = v ++ } ++ }, ++ { ++ get: function() { ++ return parent._shape[1] ++ }, ++ set: function(v) { ++ return parent.height = v ++ } + } +- } ++ ]) ++ this._shapeVector = shapeVector ++} + +- function enumerateIndices(prefix, type) { +- if(typeof type !== 'object') { +- return [ [prefix, type] ] ++var proto = Texture2D.prototype ++ ++Object.defineProperties(proto, { ++ minFilter: { ++ get: function() { ++ return this._minFilter ++ }, ++ set: function(v) { ++ this.bind() ++ var gl = this.gl ++ if(this.type === gl.FLOAT && linearTypes.indexOf(v) >= 0) { ++ if(!gl.getExtension('OES_texture_float_linear')) { ++ v = gl.NEAREST ++ } ++ } ++ if(filterTypes.indexOf(v) < 0) { ++ throw new Error('gl-texture2d: Unknown filter mode ' + v) ++ } ++ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, v) ++ return this._minFilter = v + } +- var indices = [] +- for(var id in type) { +- var prop = type[id] +- var tprefix = prefix +- if(parseInt(id) + '' === id) { +- tprefix += '[' + id + ']' +- } else { +- tprefix += '.' + id ++ }, ++ magFilter: { ++ get: function() { ++ return this._magFilter ++ }, ++ set: function(v) { ++ this.bind() ++ var gl = this.gl ++ if(this.type === gl.FLOAT && linearTypes.indexOf(v) >= 0) { ++ if(!gl.getExtension('OES_texture_float_linear')) { ++ v = gl.NEAREST ++ } + } +- if(typeof prop === 'object') { +- indices.push.apply(indices, enumerateIndices(tprefix, prop)) +- } else { +- indices.push([tprefix, prop]) ++ if(filterTypes.indexOf(v) < 0) { ++ throw new Error('gl-texture2d: Unknown filter mode ' + v) + } ++ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, v) ++ return this._magFilter = v + } +- return indices +- } +- +- function makeSetter(type) { +- var code = [ 'return function updateProperty(obj){' ] +- var indices = enumerateIndices('', type) +- for(var i=0; i 4) { +- throw new GLError('', 'Invalid data type') +- } +- if(type.charAt(0) === 'b') { +- return makeVector(d, false) +- } +- return makeVector(d, 0) +- } else if(type.indexOf('mat') === 0 && type.length === 4) { +- var d = type.charCodeAt(type.length-1) - 48 +- if(d < 2 || d > 4) { +- throw new GLError('', 'Invalid uniform dimension type for matrix ' + name + ': ' + type) +- } +- return makeVector(d*d, 0) +- } else { +- throw new GLError('', 'Unknown uniform data type for ' + name + ': ' + type) ++ var gl = this.gl ++ this.bind() ++ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, this._wrapS) ++ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, this._wrapT) ++ ++ return v ++ } ++ }, ++ shape: { ++ get: function() { ++ return this._shapeVector ++ }, ++ set: function(x) { ++ if(!Array.isArray(x)) { ++ x = [x|0,x|0] ++ } else { ++ if(x.length !== 2) { ++ throw new Error('gl-texture2d: Invalid texture shape') + } +- break ++ } ++ reshapeTexture(this, x[0]|0, x[1]|0) ++ return [x[0]|0, x[1]|0] ++ } ++ }, ++ width: { ++ get: function() { ++ return this._shape[0] ++ }, ++ set: function(w) { ++ w = w|0 ++ reshapeTexture(this, w, this._shape[1]) ++ return w ++ } ++ }, ++ height: { ++ get: function() { ++ return this._shape[1] ++ }, ++ set: function(h) { ++ h = h|0 ++ reshapeTexture(this, this._shape[0], h) ++ return h + } + } ++}) + +- function storeProperty(obj, prop, type) { +- if(typeof type === 'object') { +- var child = processObject(type) +- Object.defineProperty(obj, prop, { +- get: identity(child), +- set: makeSetter(type), +- enumerable: true, +- configurable: false +- }) +- } else { +- if(locations[type]) { +- Object.defineProperty(obj, prop, { +- get: makeGetter(type), +- set: makeSetter(type), +- enumerable: true, +- configurable: false +- }) +- } else { +- obj[prop] = defaultValue(uniforms[type].type) +- } +- } ++proto.bind = function(unit) { ++ var gl = this.gl ++ if(unit !== undefined) { ++ gl.activeTexture(gl.TEXTURE0 + (unit|0)) ++ } ++ gl.bindTexture(gl.TEXTURE_2D, this.handle) ++ if(unit !== undefined) { ++ return (unit|0) + } ++ return gl.getParameter(gl.ACTIVE_TEXTURE) - gl.TEXTURE0 ++} + +- function processObject(obj) { +- var result +- if(Array.isArray(obj)) { +- result = new Array(obj.length) +- for(var i=0; i0; ++i, l>>>=1) { ++ if(this._mipLevels.indexOf(i) < 0) { ++ this._mipLevels.push(i) + } +- return result + } ++} + +- //Return data +- var coallesced = coallesceUniforms(uniforms, true) +- return { +- get: identity(processObject(coallesced)), +- set: makeSetter(coallesced), +- enumerable: true, +- configurable: true ++proto.setPixels = function(data, x_off, y_off, mip_level) { ++ var gl = this.gl ++ this.bind() ++ if(Array.isArray(x_off)) { ++ mip_level = y_off ++ y_off = x_off[1]|0 ++ x_off = x_off[0]|0 ++ } else { ++ x_off = x_off || 0 ++ y_off = y_off || 0 ++ } ++ mip_level = mip_level || 0 ++ if(data instanceof HTMLCanvasElement || ++ data instanceof ImageData || ++ data instanceof HTMLImageElement || ++ data instanceof HTMLVideoElement) { ++ var needsMip = this._mipLevels.indexOf(mip_level) < 0 ++ if(needsMip) { ++ gl.texImage2D(gl.TEXTURE_2D, 0, this.format, this.format, this.type, data) ++ this._mipLevels.push(mip_level) ++ } else { ++ gl.texSubImage2D(gl.TEXTURE_2D, mip_level, x_off, y_off, this.format, this.type, data) ++ } ++ } else if(data.shape && data.stride && data.data) { ++ if(data.shape.length < 2 || ++ x_off + data.shape[1] > this._shape[1]>>>mip_level || ++ y_off + data.shape[0] > this._shape[0]>>>mip_level || ++ x_off < 0 || ++ y_off < 0) { ++ throw new Error('gl-texture2d: Texture dimensions are out of bounds') ++ } ++ texSubImageArray(gl, x_off, y_off, mip_level, this.format, this.type, this._mipLevels, data) ++ } else { ++ throw new Error('gl-texture2d: Unsupported data type') + } + } + +-},{"./GLError":165,"./reflect":168}],168:[function(require,module,exports){ +-'use strict' + +-module.exports = makeReflectTypes ++function isPacked(shape, stride) { ++ if(shape.length === 3) { ++ return (stride[2] === 1) && ++ (stride[1] === shape[0]*shape[2]) && ++ (stride[0] === shape[2]) ++ } ++ return (stride[0] === 1) && ++ (stride[1] === shape[0]) ++} + +-//Construct type info for reflection. +-// +-// This iterates over the flattened list of uniform type values and smashes them into a JSON object. +-// +-// The leaves of the resulting object are either indices or type strings representing primitive glslify types +-function makeReflectTypes(uniforms, useIndex) { +- var obj = {} +- for(var i=0; i 1) { +- if(!(x[0] in o)) { +- o[x[0]] = [] +- } +- o = o[x[0]] +- for(var k=1; k 3) { ++ throw new Error('gl-texture2d: Invalid ndarray, must be 2d or 3d') ++ } ++ var type = 0, format = 0 ++ var packed = isPacked(shape, array.stride.slice()) ++ if(dtype === 'float32') { ++ type = gl.FLOAT ++ } else if(dtype === 'float64') { ++ type = gl.FLOAT ++ packed = false ++ dtype = 'float32' ++ } else if(dtype === 'uint8') { ++ type = gl.UNSIGNED_BYTE ++ } else { ++ type = gl.UNSIGNED_BYTE ++ packed = false ++ dtype = 'uint8' ++ } ++ var channels = 1 ++ if(shape.length === 2) { ++ format = gl.LUMINANCE ++ shape = [shape[0], shape[1], 1] ++ array = ndarray(array.data, shape, [array.stride[0], array.stride[1], 1], array.offset) ++ } else if(shape.length === 3) { ++ if(shape[2] === 1) { ++ format = gl.ALPHA ++ } else if(shape[2] === 2) { ++ format = gl.LUMINANCE_ALPHA ++ } else if(shape[2] === 3) { ++ format = gl.RGB ++ } else if(shape[2] === 4) { ++ format = gl.RGBA ++ } else { ++ throw new Error('gl-texture2d: Invalid shape for pixel coords') ++ } ++ channels = shape[2] ++ } else { ++ throw new Error('gl-texture2d: Invalid shape for texture') ++ } ++ //For 1-channel textures allow conversion between formats ++ if((format === gl.LUMINANCE || format === gl.ALPHA) && ++ (cformat === gl.LUMINANCE || cformat === gl.ALPHA)) { ++ format = cformat ++ } ++ if(format !== cformat) { ++ throw new Error('gl-texture2d: Incompatible texture format for setPixels') ++ } ++ var size = array.size ++ var needsMip = mipLevels.indexOf(mip_level) < 0 ++ if(needsMip) { ++ mipLevels.push(mip_level) ++ } ++ if(type === ctype && packed) { ++ //Array data types are compatible, can directly copy into texture ++ if(array.offset === 0 && array.data.length === size) { ++ if(needsMip) { ++ gl.texImage2D(gl.TEXTURE_2D, mip_level, cformat, shape[0], shape[1], 0, cformat, ctype, array.data) + } else { +- if(useIndex) { +- o[x[0]] = i +- } else { +- o[x[0]] = uniforms[i].type +- } ++ gl.texSubImage2D(gl.TEXTURE_2D, mip_level, x_off, y_off, shape[0], shape[1], cformat, ctype, array.data) ++ } ++ } else { ++ if(needsMip) { ++ gl.texImage2D(gl.TEXTURE_2D, mip_level, cformat, shape[0], shape[1], 0, cformat, ctype, array.data.subarray(array.offset, array.offset+size)) ++ } else { ++ gl.texSubImage2D(gl.TEXTURE_2D, mip_level, x_off, y_off, shape[0], shape[1], cformat, ctype, array.data.subarray(array.offset, array.offset+size)) + } + } ++ } else { ++ //Need to do type conversion to pack data into buffer ++ var pack_buffer ++ if(ctype === gl.FLOAT) { ++ pack_buffer = pool.mallocFloat32(size) ++ } else { ++ pack_buffer = pool.mallocUint8(size) ++ } ++ var pack_view = ndarray(pack_buffer, shape, [shape[2], shape[2]*shape[0], 1]) ++ if(type === gl.FLOAT && ctype === gl.UNSIGNED_BYTE) { ++ convertFloatToUint8(pack_view, array) ++ } else { ++ ops.assign(pack_view, array) ++ } ++ if(needsMip) { ++ gl.texImage2D(gl.TEXTURE_2D, mip_level, cformat, shape[0], shape[1], 0, cformat, ctype, pack_buffer.subarray(0, size)) ++ } else { ++ gl.texSubImage2D(gl.TEXTURE_2D, mip_level, x_off, y_off, shape[0], shape[1], cformat, ctype, pack_buffer.subarray(0, size)) ++ } ++ if(ctype === gl.FLOAT) { ++ pool.freeFloat32(pack_buffer) ++ } else { ++ pool.freeUint8(pack_buffer) ++ } + } +- return obj + } +-},{}],169:[function(require,module,exports){ +-'use strict' + +-exports.uniforms = runtimeUniforms +-exports.attributes = runtimeAttributes ++function initTexture(gl) { ++ var tex = gl.createTexture() ++ gl.bindTexture(gl.TEXTURE_2D, tex) ++ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST) ++ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST) ++ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE) ++ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE) ++ return tex ++} + +-var GL_TO_GLSL_TYPES = { +- 'FLOAT': 'float', +- 'FLOAT_VEC2': 'vec2', +- 'FLOAT_VEC3': 'vec3', +- 'FLOAT_VEC4': 'vec4', +- 'INT': 'int', +- 'INT_VEC2': 'ivec2', +- 'INT_VEC3': 'ivec3', +- 'INT_VEC4': 'ivec4', +- 'BOOL': 'bool', +- 'BOOL_VEC2': 'bvec2', +- 'BOOL_VEC3': 'bvec3', +- 'BOOL_VEC4': 'bvec4', +- 'FLOAT_MAT2': 'mat2', +- 'FLOAT_MAT3': 'mat3', +- 'FLOAT_MAT4': 'mat4', +- 'SAMPLER_2D': 'sampler2D', +- 'SAMPLER_CUBE':'samplerCube' ++function createTextureShape(gl, width, height, format, type) { ++ var maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE) ++ if(width < 0 || width > maxTextureSize || height < 0 || height > maxTextureSize) { ++ throw new Error('gl-texture2d: Invalid texture shape') ++ } ++ if(type === gl.FLOAT && !gl.getExtension('OES_texture_float')) { ++ throw new Error('gl-texture2d: Floating point textures not supported on this platform') ++ } ++ var tex = initTexture(gl) ++ gl.texImage2D(gl.TEXTURE_2D, 0, format, width, height, 0, format, type, null) ++ return new Texture2D(gl, tex, width, height, format, type) + } + +-var GL_TABLE = null ++function createTextureDOM(gl, element, format, type) { ++ var tex = initTexture(gl) ++ gl.texImage2D(gl.TEXTURE_2D, 0, format, format, type, element) ++ return new Texture2D(gl, tex, element.width|0, element.height|0, format, type) ++} + +-function getType(gl, type) { +- if(!GL_TABLE) { +- var typeNames = Object.keys(GL_TO_GLSL_TYPES) +- GL_TABLE = {} +- for(var i=0; i maxSize || shape[1] < 0 || shape[1] > maxSize) { ++ throw new Error('gl-texture2d: Invalid texture size') ++ } ++ var packed = isPacked(shape, array.stride.slice()) ++ var type = 0 ++ if(dtype === 'float32') { ++ type = gl.FLOAT ++ } else if(dtype === 'float64') { ++ type = gl.FLOAT ++ packed = false ++ dtype = 'float32' ++ } else if(dtype === 'uint8') { ++ type = gl.UNSIGNED_BYTE ++ } else { ++ type = gl.UNSIGNED_BYTE ++ packed = false ++ dtype = 'uint8' ++ } ++ var format = 0 ++ if(shape.length === 2) { ++ format = gl.LUMINANCE ++ shape = [shape[0], shape[1], 1] ++ array = ndarray(array.data, shape, [array.stride[0], array.stride[1], 1], array.offset) ++ } else if(shape.length === 3) { ++ if(shape[2] === 1) { ++ format = gl.ALPHA ++ } else if(shape[2] === 2) { ++ format = gl.LUMINANCE_ALPHA ++ } else if(shape[2] === 3) { ++ format = gl.RGB ++ } else if(shape[2] === 4) { ++ format = gl.RGBA ++ } else { ++ throw new Error('gl-texture2d: Invalid shape for pixel coords') + } ++ } else { ++ throw new Error('gl-texture2d: Invalid shape for texture') + } +- return GL_TABLE[type] +-} +- +-function runtimeUniforms(gl, program) { +- var numUniforms = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS) +- var result = [] +- for(var i=0; i 1) { +- for(var j=0; j nattribs) { ++ throw new Error("gl-vao: Too many vertex attributes") ++ } ++ for(var i=0; i +- * +- * Copyright (c) 2014-2015, Jon Schlinkert. +- * Licensed under the MIT license. +- */ +- +-'use strict'; +- +-var repeat = require('repeat-string'); +- +-module.exports = function padLeft(str, num, ch) { +- ch = typeof ch !== 'undefined' ? (ch + '') : ' '; +- return repeat(ch, num) + str; +-}; +-},{"repeat-string":220}],174:[function(require,module,exports){ +-module.exports = { +- 0: 'NONE', +- 1: 'ONE', +- 2: 'LINE_LOOP', +- 3: 'LINE_STRIP', +- 4: 'TRIANGLES', +- 5: 'TRIANGLE_STRIP', +- 6: 'TRIANGLE_FAN', +- 256: 'DEPTH_BUFFER_BIT', +- 512: 'NEVER', +- 513: 'LESS', +- 514: 'EQUAL', +- 515: 'LEQUAL', +- 516: 'GREATER', +- 517: 'NOTEQUAL', +- 518: 'GEQUAL', +- 519: 'ALWAYS', +- 768: 'SRC_COLOR', +- 769: 'ONE_MINUS_SRC_COLOR', +- 770: 'SRC_ALPHA', +- 771: 'ONE_MINUS_SRC_ALPHA', +- 772: 'DST_ALPHA', +- 773: 'ONE_MINUS_DST_ALPHA', +- 774: 'DST_COLOR', +- 775: 'ONE_MINUS_DST_COLOR', +- 776: 'SRC_ALPHA_SATURATE', +- 1024: 'STENCIL_BUFFER_BIT', +- 1028: 'FRONT', +- 1029: 'BACK', +- 1032: 'FRONT_AND_BACK', +- 1280: 'INVALID_ENUM', +- 1281: 'INVALID_VALUE', +- 1282: 'INVALID_OPERATION', +- 1285: 'OUT_OF_MEMORY', +- 1286: 'INVALID_FRAMEBUFFER_OPERATION', +- 2304: 'CW', +- 2305: 'CCW', +- 2849: 'LINE_WIDTH', +- 2884: 'CULL_FACE', +- 2885: 'CULL_FACE_MODE', +- 2886: 'FRONT_FACE', +- 2928: 'DEPTH_RANGE', +- 2929: 'DEPTH_TEST', +- 2930: 'DEPTH_WRITEMASK', +- 2931: 'DEPTH_CLEAR_VALUE', +- 2932: 'DEPTH_FUNC', +- 2960: 'STENCIL_TEST', +- 2961: 'STENCIL_CLEAR_VALUE', +- 2962: 'STENCIL_FUNC', +- 2963: 'STENCIL_VALUE_MASK', +- 2964: 'STENCIL_FAIL', +- 2965: 'STENCIL_PASS_DEPTH_FAIL', +- 2966: 'STENCIL_PASS_DEPTH_PASS', +- 2967: 'STENCIL_REF', +- 2968: 'STENCIL_WRITEMASK', +- 2978: 'VIEWPORT', +- 3024: 'DITHER', +- 3042: 'BLEND', +- 3088: 'SCISSOR_BOX', +- 3089: 'SCISSOR_TEST', +- 3106: 'COLOR_CLEAR_VALUE', +- 3107: 'COLOR_WRITEMASK', +- 3317: 'UNPACK_ALIGNMENT', +- 3333: 'PACK_ALIGNMENT', +- 3379: 'MAX_TEXTURE_SIZE', +- 3386: 'MAX_VIEWPORT_DIMS', +- 3408: 'SUBPIXEL_BITS', +- 3410: 'RED_BITS', +- 3411: 'GREEN_BITS', +- 3412: 'BLUE_BITS', +- 3413: 'ALPHA_BITS', +- 3414: 'DEPTH_BITS', +- 3415: 'STENCIL_BITS', +- 3553: 'TEXTURE_2D', +- 4352: 'DONT_CARE', +- 4353: 'FASTEST', +- 4354: 'NICEST', +- 5120: 'BYTE', +- 5121: 'UNSIGNED_BYTE', +- 5122: 'SHORT', +- 5123: 'UNSIGNED_SHORT', +- 5124: 'INT', +- 5125: 'UNSIGNED_INT', +- 5126: 'FLOAT', +- 5386: 'INVERT', +- 5890: 'TEXTURE', +- 6401: 'STENCIL_INDEX', +- 6402: 'DEPTH_COMPONENT', +- 6406: 'ALPHA', +- 6407: 'RGB', +- 6408: 'RGBA', +- 6409: 'LUMINANCE', +- 6410: 'LUMINANCE_ALPHA', +- 7680: 'KEEP', +- 7681: 'REPLACE', +- 7682: 'INCR', +- 7683: 'DECR', +- 7936: 'VENDOR', +- 7937: 'RENDERER', +- 7938: 'VERSION', +- 9728: 'NEAREST', +- 9729: 'LINEAR', +- 9984: 'NEAREST_MIPMAP_NEAREST', +- 9985: 'LINEAR_MIPMAP_NEAREST', +- 9986: 'NEAREST_MIPMAP_LINEAR', +- 9987: 'LINEAR_MIPMAP_LINEAR', +- 10240: 'TEXTURE_MAG_FILTER', +- 10241: 'TEXTURE_MIN_FILTER', +- 10242: 'TEXTURE_WRAP_S', +- 10243: 'TEXTURE_WRAP_T', +- 10497: 'REPEAT', +- 10752: 'POLYGON_OFFSET_UNITS', +- 16384: 'COLOR_BUFFER_BIT', +- 32769: 'CONSTANT_COLOR', +- 32770: 'ONE_MINUS_CONSTANT_COLOR', +- 32771: 'CONSTANT_ALPHA', +- 32772: 'ONE_MINUS_CONSTANT_ALPHA', +- 32773: 'BLEND_COLOR', +- 32774: 'FUNC_ADD', +- 32777: 'BLEND_EQUATION_RGB', +- 32778: 'FUNC_SUBTRACT', +- 32779: 'FUNC_REVERSE_SUBTRACT', +- 32819: 'UNSIGNED_SHORT_4_4_4_4', +- 32820: 'UNSIGNED_SHORT_5_5_5_1', +- 32823: 'POLYGON_OFFSET_FILL', +- 32824: 'POLYGON_OFFSET_FACTOR', +- 32854: 'RGBA4', +- 32855: 'RGB5_A1', +- 32873: 'TEXTURE_BINDING_2D', +- 32926: 'SAMPLE_ALPHA_TO_COVERAGE', +- 32928: 'SAMPLE_COVERAGE', +- 32936: 'SAMPLE_BUFFERS', +- 32937: 'SAMPLES', +- 32938: 'SAMPLE_COVERAGE_VALUE', +- 32939: 'SAMPLE_COVERAGE_INVERT', +- 32968: 'BLEND_DST_RGB', +- 32969: 'BLEND_SRC_RGB', +- 32970: 'BLEND_DST_ALPHA', +- 32971: 'BLEND_SRC_ALPHA', +- 33071: 'CLAMP_TO_EDGE', +- 33170: 'GENERATE_MIPMAP_HINT', +- 33189: 'DEPTH_COMPONENT16', +- 33306: 'DEPTH_STENCIL_ATTACHMENT', +- 33635: 'UNSIGNED_SHORT_5_6_5', +- 33648: 'MIRRORED_REPEAT', +- 33901: 'ALIASED_POINT_SIZE_RANGE', +- 33902: 'ALIASED_LINE_WIDTH_RANGE', +- 33984: 'TEXTURE0', +- 33985: 'TEXTURE1', +- 33986: 'TEXTURE2', +- 33987: 'TEXTURE3', +- 33988: 'TEXTURE4', +- 33989: 'TEXTURE5', +- 33990: 'TEXTURE6', +- 33991: 'TEXTURE7', +- 33992: 'TEXTURE8', +- 33993: 'TEXTURE9', +- 33994: 'TEXTURE10', +- 33995: 'TEXTURE11', +- 33996: 'TEXTURE12', +- 33997: 'TEXTURE13', +- 33998: 'TEXTURE14', +- 33999: 'TEXTURE15', +- 34000: 'TEXTURE16', +- 34001: 'TEXTURE17', +- 34002: 'TEXTURE18', +- 34003: 'TEXTURE19', +- 34004: 'TEXTURE20', +- 34005: 'TEXTURE21', +- 34006: 'TEXTURE22', +- 34007: 'TEXTURE23', +- 34008: 'TEXTURE24', +- 34009: 'TEXTURE25', +- 34010: 'TEXTURE26', +- 34011: 'TEXTURE27', +- 34012: 'TEXTURE28', +- 34013: 'TEXTURE29', +- 34014: 'TEXTURE30', +- 34015: 'TEXTURE31', +- 34016: 'ACTIVE_TEXTURE', +- 34024: 'MAX_RENDERBUFFER_SIZE', +- 34041: 'DEPTH_STENCIL', +- 34055: 'INCR_WRAP', +- 34056: 'DECR_WRAP', +- 34067: 'TEXTURE_CUBE_MAP', +- 34068: 'TEXTURE_BINDING_CUBE_MAP', +- 34069: 'TEXTURE_CUBE_MAP_POSITIVE_X', +- 34070: 'TEXTURE_CUBE_MAP_NEGATIVE_X', +- 34071: 'TEXTURE_CUBE_MAP_POSITIVE_Y', +- 34072: 'TEXTURE_CUBE_MAP_NEGATIVE_Y', +- 34073: 'TEXTURE_CUBE_MAP_POSITIVE_Z', +- 34074: 'TEXTURE_CUBE_MAP_NEGATIVE_Z', +- 34076: 'MAX_CUBE_MAP_TEXTURE_SIZE', +- 34338: 'VERTEX_ATTRIB_ARRAY_ENABLED', +- 34339: 'VERTEX_ATTRIB_ARRAY_SIZE', +- 34340: 'VERTEX_ATTRIB_ARRAY_STRIDE', +- 34341: 'VERTEX_ATTRIB_ARRAY_TYPE', +- 34342: 'CURRENT_VERTEX_ATTRIB', +- 34373: 'VERTEX_ATTRIB_ARRAY_POINTER', +- 34466: 'NUM_COMPRESSED_TEXTURE_FORMATS', +- 34467: 'COMPRESSED_TEXTURE_FORMATS', +- 34660: 'BUFFER_SIZE', +- 34661: 'BUFFER_USAGE', +- 34816: 'STENCIL_BACK_FUNC', +- 34817: 'STENCIL_BACK_FAIL', +- 34818: 'STENCIL_BACK_PASS_DEPTH_FAIL', +- 34819: 'STENCIL_BACK_PASS_DEPTH_PASS', +- 34877: 'BLEND_EQUATION_ALPHA', +- 34921: 'MAX_VERTEX_ATTRIBS', +- 34922: 'VERTEX_ATTRIB_ARRAY_NORMALIZED', +- 34930: 'MAX_TEXTURE_IMAGE_UNITS', +- 34962: 'ARRAY_BUFFER', +- 34963: 'ELEMENT_ARRAY_BUFFER', +- 34964: 'ARRAY_BUFFER_BINDING', +- 34965: 'ELEMENT_ARRAY_BUFFER_BINDING', +- 34975: 'VERTEX_ATTRIB_ARRAY_BUFFER_BINDING', +- 35040: 'STREAM_DRAW', +- 35044: 'STATIC_DRAW', +- 35048: 'DYNAMIC_DRAW', +- 35632: 'FRAGMENT_SHADER', +- 35633: 'VERTEX_SHADER', +- 35660: 'MAX_VERTEX_TEXTURE_IMAGE_UNITS', +- 35661: 'MAX_COMBINED_TEXTURE_IMAGE_UNITS', +- 35663: 'SHADER_TYPE', +- 35664: 'FLOAT_VEC2', +- 35665: 'FLOAT_VEC3', +- 35666: 'FLOAT_VEC4', +- 35667: 'INT_VEC2', +- 35668: 'INT_VEC3', +- 35669: 'INT_VEC4', +- 35670: 'BOOL', +- 35671: 'BOOL_VEC2', +- 35672: 'BOOL_VEC3', +- 35673: 'BOOL_VEC4', +- 35674: 'FLOAT_MAT2', +- 35675: 'FLOAT_MAT3', +- 35676: 'FLOAT_MAT4', +- 35678: 'SAMPLER_2D', +- 35680: 'SAMPLER_CUBE', +- 35712: 'DELETE_STATUS', +- 35713: 'COMPILE_STATUS', +- 35714: 'LINK_STATUS', +- 35715: 'VALIDATE_STATUS', +- 35716: 'INFO_LOG_LENGTH', +- 35717: 'ATTACHED_SHADERS', +- 35718: 'ACTIVE_UNIFORMS', +- 35719: 'ACTIVE_UNIFORM_MAX_LENGTH', +- 35720: 'SHADER_SOURCE_LENGTH', +- 35721: 'ACTIVE_ATTRIBUTES', +- 35722: 'ACTIVE_ATTRIBUTE_MAX_LENGTH', +- 35724: 'SHADING_LANGUAGE_VERSION', +- 35725: 'CURRENT_PROGRAM', +- 36003: 'STENCIL_BACK_REF', +- 36004: 'STENCIL_BACK_VALUE_MASK', +- 36005: 'STENCIL_BACK_WRITEMASK', +- 36006: 'FRAMEBUFFER_BINDING', +- 36007: 'RENDERBUFFER_BINDING', +- 36048: 'FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE', +- 36049: 'FRAMEBUFFER_ATTACHMENT_OBJECT_NAME', +- 36050: 'FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL', +- 36051: 'FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE', +- 36053: 'FRAMEBUFFER_COMPLETE', +- 36054: 'FRAMEBUFFER_INCOMPLETE_ATTACHMENT', +- 36055: 'FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT', +- 36057: 'FRAMEBUFFER_INCOMPLETE_DIMENSIONS', +- 36061: 'FRAMEBUFFER_UNSUPPORTED', +- 36064: 'COLOR_ATTACHMENT0', +- 36096: 'DEPTH_ATTACHMENT', +- 36128: 'STENCIL_ATTACHMENT', +- 36160: 'FRAMEBUFFER', +- 36161: 'RENDERBUFFER', +- 36162: 'RENDERBUFFER_WIDTH', +- 36163: 'RENDERBUFFER_HEIGHT', +- 36164: 'RENDERBUFFER_INTERNAL_FORMAT', +- 36168: 'STENCIL_INDEX8', +- 36176: 'RENDERBUFFER_RED_SIZE', +- 36177: 'RENDERBUFFER_GREEN_SIZE', +- 36178: 'RENDERBUFFER_BLUE_SIZE', +- 36179: 'RENDERBUFFER_ALPHA_SIZE', +- 36180: 'RENDERBUFFER_DEPTH_SIZE', +- 36181: 'RENDERBUFFER_STENCIL_SIZE', +- 36194: 'RGB565', +- 36336: 'LOW_FLOAT', +- 36337: 'MEDIUM_FLOAT', +- 36338: 'HIGH_FLOAT', +- 36339: 'LOW_INT', +- 36340: 'MEDIUM_INT', +- 36341: 'HIGH_INT', +- 36346: 'SHADER_COMPILER', +- 36347: 'MAX_VERTEX_UNIFORM_VECTORS', +- 36348: 'MAX_VARYING_VECTORS', +- 36349: 'MAX_FRAGMENT_UNIFORM_VECTORS', +- 37440: 'UNPACK_FLIP_Y_WEBGL', +- 37441: 'UNPACK_PREMULTIPLY_ALPHA_WEBGL', +- 37442: 'CONTEXT_LOST_WEBGL', +- 37443: 'UNPACK_COLORSPACE_CONVERSION_WEBGL', +- 37444: 'BROWSER_DEFAULT_WEBGL' ++function VAONative(gl, ext, handle) { ++ this.gl = gl ++ this._ext = ext ++ this.handle = handle ++ this._attribs = [] ++ this._useElements = false ++ this._elementsType = gl.UNSIGNED_SHORT + } + +-},{}],175:[function(require,module,exports){ +-var gl10 = require('./1.0/numbers') ++VAONative.prototype.bind = function() { ++ this._ext.bindVertexArrayOES(this.handle) ++ for(var i=0; i= 0 +- } ++ out[0] = ay * bz - az * by ++ out[1] = az * bx - ax * bz ++ out[2] = ax * by - ay * bx ++ return out ++} ++},{}],150:[function(require,module,exports){ ++module.exports = dot; + +- switch (match[8]) { +- case "b": +- arg = arg.toString(2) +- break +- case "c": +- arg = String.fromCharCode(arg) +- break +- case "d": +- case "i": +- arg = parseInt(arg, 10) +- break +- case "j": +- arg = JSON.stringify(arg, null, match[6] ? parseInt(match[6]) : 0) +- break +- case "e": +- arg = match[7] ? arg.toExponential(match[7]) : arg.toExponential() +- break +- case "f": +- arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg) +- break +- case "g": +- arg = match[7] ? parseFloat(arg).toPrecision(match[7]) : parseFloat(arg) +- break +- case "o": +- arg = arg.toString(8) +- break +- case "s": +- arg = ((arg = String(arg)) && match[7] ? arg.substring(0, match[7]) : arg) +- break +- case "u": +- arg = arg >>> 0 +- break +- case "x": +- arg = arg.toString(16) +- break +- case "X": +- arg = arg.toString(16).toUpperCase() +- break +- } +- if (re.json.test(match[8])) { +- output[output.length] = arg +- } +- else { +- if (re.number.test(match[8]) && (!is_positive || match[3])) { +- sign = is_positive ? "+" : "-" +- arg = arg.toString().replace(re.sign, "") +- } +- else { +- sign = "" +- } +- pad_character = match[4] ? match[4] === "0" ? "0" : match[4].charAt(1) : " " +- pad_length = match[6] - (sign + arg).length +- pad = match[6] ? (pad_length > 0 ? str_repeat(pad_character, pad_length) : "") : "" +- output[output.length] = match[5] ? sign + arg + pad : (pad_character === "0" ? sign + pad + arg : pad + sign + arg) +- } +- } +- } +- return output.join("") +- } ++/** ++ * Calculates the dot product of two vec3's ++ * ++ * @param {vec3} a the first operand ++ * @param {vec3} b the second operand ++ * @returns {Number} dot product of a and b ++ */ ++function dot(a, b) { ++ return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] ++} ++},{}],151:[function(require,module,exports){ ++module.exports = length; + +- sprintf.cache = {} ++/** ++ * Calculates the length of a vec3 ++ * ++ * @param {vec3} a vector to calculate length of ++ * @returns {Number} length of a ++ */ ++function length(a) { ++ var x = a[0], ++ y = a[1], ++ z = a[2] ++ return Math.sqrt(x*x + y*y + z*z) ++} ++},{}],152:[function(require,module,exports){ ++module.exports = lerp; + +- sprintf.parse = function(fmt) { +- var _fmt = fmt, match = [], parse_tree = [], arg_names = 0 +- while (_fmt) { +- if ((match = re.text.exec(_fmt)) !== null) { +- parse_tree[parse_tree.length] = match[0] +- } +- else if ((match = re.modulo.exec(_fmt)) !== null) { +- parse_tree[parse_tree.length] = "%" +- } +- else if ((match = re.placeholder.exec(_fmt)) !== null) { +- if (match[2]) { +- arg_names |= 1 +- var field_list = [], replacement_field = match[2], field_match = [] +- if ((field_match = re.key.exec(replacement_field)) !== null) { +- field_list[field_list.length] = field_match[1] +- while ((replacement_field = replacement_field.substring(field_match[0].length)) !== "") { +- if ((field_match = re.key_access.exec(replacement_field)) !== null) { +- field_list[field_list.length] = field_match[1] +- } +- else if ((field_match = re.index_access.exec(replacement_field)) !== null) { +- field_list[field_list.length] = field_match[1] +- } +- else { +- throw new SyntaxError("[sprintf] failed to parse named argument key") +- } +- } +- } +- else { +- throw new SyntaxError("[sprintf] failed to parse named argument key") +- } +- match[2] = field_list +- } +- else { +- arg_names |= 2 +- } +- if (arg_names === 3) { +- throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported") +- } +- parse_tree[parse_tree.length] = match +- } +- else { +- throw new SyntaxError("[sprintf] unexpected placeholder") +- } +- _fmt = _fmt.substring(match[0].length) +- } +- return parse_tree +- } ++/** ++ * Performs a linear interpolation between two vec3's ++ * ++ * @param {vec3} out the receiving vector ++ * @param {vec3} a the first operand ++ * @param {vec3} b the second operand ++ * @param {Number} t interpolation amount between the two inputs ++ * @returns {vec3} out ++ */ ++function lerp(out, a, b, t) { ++ var ax = a[0], ++ ay = a[1], ++ az = a[2] ++ out[0] = ax + t * (b[0] - ax) ++ out[1] = ay + t * (b[1] - ay) ++ out[2] = az + t * (b[2] - az) ++ return out ++} ++},{}],153:[function(require,module,exports){ ++module.exports = normalize; + +- var vsprintf = function(fmt, argv, _argv) { +- _argv = (argv || []).slice(0) +- _argv.splice(0, 0, fmt) +- return sprintf.apply(null, _argv) ++/** ++ * Normalize a vec3 ++ * ++ * @param {vec3} out the receiving vector ++ * @param {vec3} a vector to normalize ++ * @returns {vec3} out ++ */ ++function normalize(out, a) { ++ var x = a[0], ++ y = a[1], ++ z = a[2] ++ var len = x*x + y*y + z*z ++ if (len > 0) { ++ //TODO: evaluate use of glm_invsqrt here? ++ len = 1 / Math.sqrt(len) ++ out[0] = a[0] * len ++ out[1] = a[1] * len ++ out[2] = a[2] * len + } ++ return out ++} ++},{}],154:[function(require,module,exports){ ++module.exports = transformMat4 + +- /** +- * helpers +- */ +- function get_type(variable) { +- return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase() +- } ++/** ++ * Transforms the vec4 with a mat4. ++ * ++ * @param {vec4} out the receiving vector ++ * @param {vec4} a the vector to transform ++ * @param {mat4} m matrix to transform with ++ * @returns {vec4} out ++ */ ++function transformMat4 (out, a, m) { ++ var x = a[0], y = a[1], z = a[2], w = a[3] ++ out[0] = m[0] * x + m[4] * y + m[8] * z + m[12] * w ++ out[1] = m[1] * x + m[5] * y + m[9] * z + m[13] * w ++ out[2] = m[2] * x + m[6] * y + m[10] * z + m[14] * w ++ out[3] = m[3] * x + m[7] * y + m[11] * z + m[15] * w ++ return out ++} + +- function str_repeat(input, multiplier) { +- return Array(multiplier + 1).join(input) +- } ++},{}],155:[function(require,module,exports){ ++module.exports = decodeFloat + +- /** +- * export to either browser or node.js +- */ +- if (typeof exports !== "undefined") { +- exports.sprintf = sprintf +- exports.vsprintf = vsprintf +- } +- else { +- window.sprintf = sprintf +- window.vsprintf = vsprintf ++var UINT8_VIEW = new Uint8Array(4) ++var FLOAT_VIEW = new Float32Array(UINT8_VIEW.buffer) + +- if (typeof define === "function" && define.amd) { +- define(function() { +- return { +- sprintf: sprintf, +- vsprintf: vsprintf +- } +- }) +- } +- } +-})(typeof window === "undefined" ? this : window); ++function decodeFloat(x, y, z, w) { ++ UINT8_VIEW[0] = w ++ UINT8_VIEW[1] = z ++ UINT8_VIEW[2] = y ++ UINT8_VIEW[3] = x ++ return FLOAT_VIEW[0] ++} + +-},{}],179:[function(require,module,exports){ +-var hiddenStore = require('./hidden-store.js'); ++},{}],156:[function(require,module,exports){ ++var tokenize = require('glsl-tokenizer') ++var atob = require('atob-lite') + +-module.exports = createStore; ++module.exports = getName + +-function createStore() { +- var key = {}; ++function getName(src) { ++ var tokens = Array.isArray(src) ++ ? src ++ : tokenize(src) + +- return function (obj) { +- if ((typeof obj !== 'object' || obj === null) && +- typeof obj !== 'function' +- ) { +- throw new Error('Weakmap-shim: Key must be object') +- } ++ for (var i = 0; i < tokens.length; i++) { ++ var token = tokens[i] ++ if (token.type !== 'preprocessor') continue ++ var match = token.data.match(/\#define\s+SHADER_NAME(_B64)?\s+(.+)$/) ++ if (!match) continue ++ if (!match[2]) continue + +- var store = obj.valueOf(key); +- return store && store.identity === key ? +- store : hiddenStore(obj, key); +- }; ++ var b64 = match[1] ++ var name = match[2] ++ ++ return (b64 ? atob(name) : name).trim() ++ } + } + +-},{"./hidden-store.js":180}],180:[function(require,module,exports){ +-module.exports = hiddenStore; ++},{"atob-lite":16,"glsl-tokenizer":163}],157:[function(require,module,exports){ ++module.exports = tokenize + +-function hiddenStore(obj, key) { +- var store = { identity: key }; +- var valueOf = obj.valueOf; ++var literals100 = require('./lib/literals') ++ , operators = require('./lib/operators') ++ , builtins100 = require('./lib/builtins') ++ , literals300es = require('./lib/literals-300es') ++ , builtins300es = require('./lib/builtins-300es') + +- Object.defineProperty(obj, "valueOf", { +- value: function (value) { +- return value !== key ? +- valueOf.apply(this, arguments) : store; +- }, +- writable: true +- }); ++var NORMAL = 999 // <-- never emitted ++ , TOKEN = 9999 // <-- never emitted ++ , BLOCK_COMMENT = 0 ++ , LINE_COMMENT = 1 ++ , PREPROCESSOR = 2 ++ , OPERATOR = 3 ++ , INTEGER = 4 ++ , FLOAT = 5 ++ , IDENT = 6 ++ , BUILTIN = 7 ++ , KEYWORD = 8 ++ , WHITESPACE = 9 ++ , EOF = 10 ++ , HEX = 11 + +- return store; +-} ++var map = [ ++ 'block-comment' ++ , 'line-comment' ++ , 'preprocessor' ++ , 'operator' ++ , 'integer' ++ , 'float' ++ , 'ident' ++ , 'builtin' ++ , 'keyword' ++ , 'whitespace' ++ , 'eof' ++ , 'integer' ++] + +-},{}],181:[function(require,module,exports){ +-// Original - @Gozola. +-// https://gist.github.com/Gozala/1269991 +-// This is a reimplemented version (with a few bug fixes). ++function tokenize(opt) { ++ var i = 0 ++ , total = 0 ++ , mode = NORMAL ++ , c ++ , last ++ , content = [] ++ , tokens = [] ++ , token_idx = 0 ++ , token_offs = 0 ++ , line = 1 ++ , col = 0 ++ , start = 0 ++ , isnum = false ++ , isoperator = false ++ , input = '' ++ , len ++ ++ opt = opt || {} ++ var allBuiltins = builtins100 ++ var allLiterals = literals100 ++ if (opt.version === '300 es') { ++ allBuiltins = builtins300es ++ allLiterals = literals300es ++ } ++ ++ return function(data) { ++ tokens = [] ++ if (data !== null) return write(data.replace ? data.replace(/\r\n/g, '\n') : data) ++ return end() ++ } ++ ++ function token(data) { ++ if (data.length) { ++ tokens.push({ ++ type: map[mode] ++ , data: data ++ , position: start ++ , line: line ++ , column: col ++ }) ++ } ++ } ++ ++ function write(chunk) { ++ i = 0 ++ input += chunk ++ len = input.length + +-var createStore = require('./create-store.js'); ++ var last + +-module.exports = weakMap; ++ while(c = input[i], i < len) { ++ last = i + +-function weakMap() { +- var privates = createStore(); ++ switch(mode) { ++ case BLOCK_COMMENT: i = block_comment(); break ++ case LINE_COMMENT: i = line_comment(); break ++ case PREPROCESSOR: i = preprocessor(); break ++ case OPERATOR: i = operator(); break ++ case INTEGER: i = integer(); break ++ case HEX: i = hex(); break ++ case FLOAT: i = decimal(); break ++ case TOKEN: i = readtoken(); break ++ case WHITESPACE: i = whitespace(); break ++ case NORMAL: i = normal(); break ++ } + +- return { +- 'get': function (key, fallback) { +- var store = privates(key) +- return store.hasOwnProperty('value') ? +- store.value : fallback +- }, +- 'set': function (key, value) { +- privates(key).value = value; +- }, +- 'has': function(key) { +- return 'value' in privates(key); +- }, +- 'delete': function (key) { +- return delete privates(key).value; ++ if(last !== i) { ++ switch(input[last]) { ++ case '\n': col = 0; ++line; break ++ default: ++col; break + } ++ } + } +-} +- +-},{"./create-store.js":179}],182:[function(require,module,exports){ +-var createShader = require('gl-shader') + ++ total += i ++ input = input.slice(i) ++ return tokens ++ } + +-var vertSrc = "precision mediump float;\n#define GLSLIFY 1\n\nattribute vec4 uv;\nattribute vec3 f;\nattribute vec3 normal;\n\nuniform mat4 model, view, projection, inverseModel;\nuniform vec3 lightPosition, eyePosition;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\n\nvoid main() {\n worldCoordinate = vec3(uv.zw, f.x);\n vec4 worldPosition = model * vec4(worldCoordinate, 1.0);\n vec4 clipPosition = projection * view * worldPosition;\n gl_Position = clipPosition;\n kill = f.y;\n value = f.z;\n planeCoordinate = uv.xy;\n\n //Lighting geometry parameters\n vec4 cameraCoordinate = view * worldPosition;\n cameraCoordinate.xyz /= cameraCoordinate.w;\n lightDirection = lightPosition - cameraCoordinate.xyz;\n eyeDirection = eyePosition - cameraCoordinate.xyz;\n surfaceNormal = normalize((vec4(normal,0) * inverseModel).xyz);\n}\n" +-var fragSrc = "precision mediump float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution_2_0(float x, float roughness) {\n float NdotH = max(x, 0.0001);\n float cos2Alpha = NdotH * NdotH;\n float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha;\n float roughness2 = roughness * roughness;\n float denom = 3.141592653589793 * roughness2 * cos2Alpha * cos2Alpha;\n return exp(tan2Alpha / roughness2) / denom;\n}\n\n\n\nfloat beckmannSpecular_1_1(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness) {\n return beckmannDistribution_2_0(dot(surfaceNormal, normalize(lightDirection + viewDirection)), roughness);\n}\n\n\n\nuniform vec3 lowerBound, upperBound;\nuniform float contourTint;\nuniform vec4 contourColor;\nuniform sampler2D colormap;\nuniform vec3 clipBounds[2];\nuniform float roughness, fresnel, kambient, kdiffuse, kspecular, opacity;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\n\nvoid main() {\n if(kill > 0.0 ||\n any(lessThan(worldCoordinate, clipBounds[0])) || any(greaterThan(worldCoordinate, clipBounds[1]))) {\n discard;\n }\n\n vec3 N = normalize(surfaceNormal);\n vec3 V = normalize(eyeDirection);\n vec3 L = normalize(lightDirection);\n\n if(gl_FrontFacing) {\n N = -N;\n }\n\n float specular = beckmannSpecular_1_1(L, V, N, roughness);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = texture2D(colormap, vec2(value, value));\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = mix(litColor, contourColor, contourTint) * opacity;\n}\n" +-var contourVertSrc = "precision mediump float;\n#define GLSLIFY 1\n\nattribute vec4 uv;\nattribute float f;\n\nuniform mat3 permutation;\nuniform mat4 model, view, projection;\nuniform float height, zOffset;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\n\nvoid main() {\n vec3 dataCoordinate = permutation * vec3(uv.xy, height);\n vec4 worldPosition = model * vec4(dataCoordinate, 1.0);\n\n vec4 clipPosition = projection * view * worldPosition;\n clipPosition.z = clipPosition.z + zOffset;\n\n gl_Position = clipPosition;\n value = f;\n kill = -1.0;\n worldCoordinate = dataCoordinate;\n planeCoordinate = uv.zw;\n\n //Don't do lighting for contours\n surfaceNormal = vec3(1,0,0);\n eyeDirection = vec3(0,1,0);\n lightDirection = vec3(0,0,1);\n}\n" +-var pickSrc = "precision mediump float;\n#define GLSLIFY 1\n\nuniform vec2 shape;\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 surfaceNormal;\n\nvec2 splitFloat(float v) {\n float vh = 255.0 * v;\n float upper = floor(vh);\n float lower = fract(vh);\n return vec2(upper / 255.0, floor(lower * 16.0) / 16.0);\n}\n\nvoid main() {\n if(kill > 0.0 ||\n any(lessThan(worldCoordinate, clipBounds[0])) || any(greaterThan(worldCoordinate, clipBounds[1]))) {\n discard;\n }\n vec2 ux = splitFloat(planeCoordinate.x / shape.x);\n vec2 uy = splitFloat(planeCoordinate.y / shape.y);\n gl_FragColor = vec4(pickId, ux.x, uy.x, ux.y + (uy.y/16.0));\n}\n" ++ function end(chunk) { ++ if(content.length) { ++ token(content.join('')) ++ } + +-exports.createShader = function (gl) { +- var shader = createShader(gl, vertSrc, fragSrc, null, [ +- {name: 'uv', type: 'vec4'}, +- {name: 'f', type: 'vec3'}, +- {name: 'normal', type: 'vec3'} +- ]) +- shader.attributes.uv.location = 0 +- shader.attributes.f.location = 1 +- shader.attributes.normal.location = 2 +- return shader +-} +-exports.createPickShader = function (gl) { +- var shader = createShader(gl, vertSrc, pickSrc, null, [ +- {name: 'uv', type: 'vec4'}, +- {name: 'f', type: 'vec3'}, +- {name: 'normal', type: 'vec3'} +- ]) +- shader.attributes.uv.location = 0 +- shader.attributes.f.location = 1 +- shader.attributes.normal.location = 2 +- return shader +-} +-exports.createContourShader = function (gl) { +- var shader = createShader(gl, contourVertSrc, fragSrc, null, [ +- {name: 'uv', type: 'vec4'}, +- {name: 'f', type: 'float'} +- ]) +- shader.attributes.uv.location = 0 +- shader.attributes.f.location = 1 +- return shader +-} +-exports.createPickContourShader = function (gl) { +- var shader = createShader(gl, contourVertSrc, pickSrc, null, [ +- {name: 'uv', type: 'vec4'}, +- {name: 'f', type: 'float'} +- ]) +- shader.attributes.uv.location = 0 +- shader.attributes.f.location = 1 +- return shader +-} ++ mode = EOF ++ token('(eof)') ++ return tokens ++ } + +-},{"gl-shader":164}],183:[function(require,module,exports){ +-arguments[4][9][0].apply(exports,arguments) +-},{"dup":9}],184:[function(require,module,exports){ +-'use strict' ++ function normal() { ++ content = content.length ? [] : content + +-module.exports = gradient ++ if(last === '/' && c === '*') { ++ start = total + i - 1 ++ mode = BLOCK_COMMENT ++ last = c ++ return i + 1 ++ } + +-var dup = require('dup') +-var cwiseCompiler = require('cwise-compiler') ++ if(last === '/' && c === '/') { ++ start = total + i - 1 ++ mode = LINE_COMMENT ++ last = c ++ return i + 1 ++ } + +-var TEMPLATE_CACHE = {} +-var GRADIENT_CACHE = {} ++ if(c === '#') { ++ mode = PREPROCESSOR ++ start = total + i ++ return i ++ } + +-var EmptyProc = { +- body: "", +- args: [], +- thisVars: [], +- localVars: [] +-} ++ if(/\s/.test(c)) { ++ mode = WHITESPACE ++ start = total + i ++ return i ++ } + +-var centralDiff = cwiseCompiler({ +- args: [ 'array', 'array', 'array' ], +- pre: EmptyProc, +- post: EmptyProc, +- body: { +- args: [ { +- name: 'out', +- lvalue: true, +- rvalue: false, +- count: 1 +- }, { +- name: 'left', +- lvalue: false, +- rvalue: true, +- count: 1 +- }, { +- name: 'right', +- lvalue: false, +- rvalue: true, +- count: 1 +- }], +- body: "out=0.5*(left-right)", +- thisVars: [], +- localVars: [] +- }, +- funcName: 'cdiff' +-}) ++ isnum = /\d/.test(c) ++ isoperator = /[^\w_]/.test(c) + +-var zeroOut = cwiseCompiler({ +- args: [ 'array' ], +- pre: EmptyProc, +- post: EmptyProc, +- body: { +- args: [ { +- name: 'out', +- lvalue: true, +- rvalue: false, +- count: 1 +- }], +- body: "out=0", +- thisVars: [], +- localVars: [] +- }, +- funcName: 'zero' +-}) ++ start = total + i ++ mode = isnum ? INTEGER : isoperator ? OPERATOR : TOKEN ++ return i ++ } + +-function generateTemplate(d) { +- if(d in TEMPLATE_CACHE) { +- return TEMPLATE_CACHE[d] ++ function whitespace() { ++ if(/[^\s]/g.test(c)) { ++ token(content.join('')) ++ mode = NORMAL ++ return i ++ } ++ content.push(c) ++ last = c ++ return i + 1 + } +- var code = [] +- for(var i=0; i= 0) { +- pickStr.push('0') +- } else if(facet.indexOf(-(i+1)) >= 0) { +- pickStr.push('s['+i+']-1') +- } else { +- pickStr.push('-1') +- loStr.push('1') +- hiStr.push('s['+i+']-2') +- } ++ if(last === '/' && c === '*') { ++ mode = BLOCK_COMMENT ++ return i + } +- var boundStr = '.lo(' + loStr.join() + ').hi(' + hiStr.join() + ')' +- if(loStr.length === 0) { +- boundStr = '' ++ ++ if(last === '/' && c === '/') { ++ mode = LINE_COMMENT ++ return i + } +- +- if(cod > 0) { +- code.push('if(1') +- for(var i=0; i= 0 || facet.indexOf(-(i+1)) >= 0) { +- continue +- } +- code.push('&&s[', i, ']>2') +- } +- code.push('){grad', cod, '(src.pick(', pickStr.join(), ')', boundStr) +- for(var i=0; i= 0 || facet.indexOf(-(i+1)) >= 0) { +- continue +- } +- code.push(',dst.pick(', pickStr.join(), ',', i, ')', boundStr) +- } +- code.push(');') ++ ++ if(c === '.' && content.length) { ++ while(determine_operator(content)); ++ ++ mode = FLOAT ++ return i + } + +- for(var i=0; i1){dst.set(', +- pickStr.join(), ',', bnd, ',0.5*(src.get(', +- cPickStr.join(), ')-src.get(', +- dPickStr.join(), ')))}else{dst.set(', +- pickStr.join(), ',', bnd, ',0)};') +- } else { +- code.push('if(s[', bnd, ']>1){diff(', outStr, +- ',src.pick(', cPickStr.join(), ')', boundStr, +- ',src.pick(', dPickStr.join(), ')', boundStr, +- ');}else{zero(', outStr, ');};') +- } +- break ++ var is_composite_operator = content.length === 2 && c !== '=' ++ if(/[\w_\d\s]/.test(c) || is_composite_operator) { ++ while(determine_operator(content)); ++ mode = NORMAL ++ return i ++ } + +- case 'mirror': +- if(cod === 0) { +- code.push('dst.set(', pickStr.join(), ',', bnd, ',0);') +- } else { +- code.push('zero(', outStr, ');') +- } +- break ++ content.push(c) ++ last = c ++ return i + 1 ++ } + +- case 'wrap': +- var aPickStr = pickStr.slice() +- var bPickStr = pickStr.slice() +- if(facet[i] < 0) { +- aPickStr[bnd] = 's[' + bnd + ']-2' +- bPickStr[bnd] = '0' +- +- } else { +- aPickStr[bnd] = 's[' + bnd + ']-1' +- bPickStr[bnd] = '1' +- } +- if(cod === 0) { +- code.push('if(s[', bnd, ']>2){dst.set(', +- pickStr.join(), ',', bnd, ',0.5*(src.get(', +- aPickStr.join(), ')-src.get(', +- bPickStr.join(), ')))}else{dst.set(', +- pickStr.join(), ',', bnd, ',0)};') +- } else { +- code.push('if(s[', bnd, ']>2){diff(', outStr, +- ',src.pick(', aPickStr.join(), ')', boundStr, +- ',src.pick(', bPickStr.join(), ')', boundStr, +- ');}else{zero(', outStr, ');};') +- } +- break ++ function determine_operator(buf) { ++ var j = 0 ++ , idx ++ , res + +- default: +- throw new Error('ndarray-gradient: Invalid boundary condition') ++ do { ++ idx = operators.indexOf(buf.slice(0, buf.length + j).join('')) ++ res = operators[idx] ++ ++ if(idx === -1) { ++ if(j-- + buf.length > 0) continue ++ res = buf.slice(0, 1).join('') + } +- } + +- if(cod > 0) { +- code.push('};') ++ token(res) ++ ++ start += res.length ++ content = content.slice(res.length) ++ return content.length ++ } while(1) ++ } ++ ++ function hex() { ++ if(/[^a-fA-F0-9]/.test(c)) { ++ token(content.join('')) ++ mode = NORMAL ++ return i + } ++ ++ content.push(c) ++ last = c ++ return i + 1 + } + +- //Enumerate ridges, facets, etc. of hypercube +- for(var i=0; i<(1< -1) { ++ mode = KEYWORD ++ } else if(allBuiltins.indexOf(contentstr) > -1) { ++ mode = BUILTIN ++ } else { ++ mode = IDENT ++ } ++ token(content.join('')) ++ mode = NORMAL ++ return i ++ } ++ content.push(c) ++ last = c ++ return i + 1 + } +- do_convert(result, arr) +- return result + } + +-},{"./doConvert.js":186,"ndarray":219}],186:[function(require,module,exports){ +-module.exports=require('cwise-compiler')({"args":["array","scalar","index"],"pre":{"body":"{}","args":[],"thisVars":[],"localVars":[]},"body":{"body":"{\nvar _inline_1_v=_inline_1_arg1_,_inline_1_i\nfor(_inline_1_i=0;_inline_1_i<_inline_1_arg2_.length-1;++_inline_1_i) {\n_inline_1_v=_inline_1_v[_inline_1_arg2_[_inline_1_i]]\n}\n_inline_1_arg0_=_inline_1_v[_inline_1_arg2_[_inline_1_arg2_.length-1]]\n}","args":[{"name":"_inline_1_arg0_","lvalue":true,"rvalue":false,"count":1},{"name":"_inline_1_arg1_","lvalue":false,"rvalue":true,"count":1},{"name":"_inline_1_arg2_","lvalue":false,"rvalue":true,"count":4}],"thisVars":[],"localVars":["_inline_1_i","_inline_1_v"]},"post":{"body":"{}","args":[],"thisVars":[],"localVars":[]},"funcName":"convert","blockSize":64}) ++},{"./lib/builtins":159,"./lib/builtins-300es":158,"./lib/literals":161,"./lib/literals-300es":160,"./lib/operators":162}],158:[function(require,module,exports){ ++// 300es builtins/reserved words that were previously valid in v100 ++var v100 = require('./builtins') + +-},{"cwise-compiler":96}],187:[function(require,module,exports){ +-'use strict' ++// The texture2D|Cube functions have been removed ++// And the gl_ features are updated ++v100 = v100.slice().filter(function (b) { ++ return !/^(gl\_|texture)/.test(b) ++}) + +-module.exports = createSurfacePlot ++module.exports = v100.concat([ ++ // the updated gl_ constants ++ 'gl_VertexID' ++ , 'gl_InstanceID' ++ , 'gl_Position' ++ , 'gl_PointSize' ++ , 'gl_FragCoord' ++ , 'gl_FrontFacing' ++ , 'gl_FragDepth' ++ , 'gl_PointCoord' ++ , 'gl_MaxVertexAttribs' ++ , 'gl_MaxVertexUniformVectors' ++ , 'gl_MaxVertexOutputVectors' ++ , 'gl_MaxFragmentInputVectors' ++ , 'gl_MaxVertexTextureImageUnits' ++ , 'gl_MaxCombinedTextureImageUnits' ++ , 'gl_MaxTextureImageUnits' ++ , 'gl_MaxFragmentUniformVectors' ++ , 'gl_MaxDrawBuffers' ++ , 'gl_MinProgramTexelOffset' ++ , 'gl_MaxProgramTexelOffset' ++ , 'gl_DepthRangeParameters' ++ , 'gl_DepthRange' + +-var bits = require('bit-twiddle') +-var createBuffer = require('gl-buffer') +-var createVAO = require('gl-vao') +-var createTexture = require('gl-texture2d') +-var pool = require('typedarray-pool') +-var colormap = require('colormap') +-var ops = require('ndarray-ops') +-var pack = require('ndarray-pack') +-var ndarray = require('ndarray') +-var surfaceNets = require('surface-nets') +-var multiply = require('gl-mat4/multiply') +-var invert = require('gl-mat4/invert') +-var bsearch = require('binary-search-bounds') +-var gradient = require('ndarray-gradient') +-var shaders = require('./lib/shaders') ++ // other builtins ++ , 'trunc' ++ , 'round' ++ , 'roundEven' ++ , 'isnan' ++ , 'isinf' ++ , 'floatBitsToInt' ++ , 'floatBitsToUint' ++ , 'intBitsToFloat' ++ , 'uintBitsToFloat' ++ , 'packSnorm2x16' ++ , 'unpackSnorm2x16' ++ , 'packUnorm2x16' ++ , 'unpackUnorm2x16' ++ , 'packHalf2x16' ++ , 'unpackHalf2x16' ++ , 'outerProduct' ++ , 'transpose' ++ , 'determinant' ++ , 'inverse' ++ , 'texture' ++ , 'textureSize' ++ , 'textureProj' ++ , 'textureLod' ++ , 'textureOffset' ++ , 'texelFetch' ++ , 'texelFetchOffset' ++ , 'textureProjOffset' ++ , 'textureLodOffset' ++ , 'textureProjLod' ++ , 'textureProjLodOffset' ++ , 'textureGrad' ++ , 'textureGradOffset' ++ , 'textureProjGrad' ++ , 'textureProjGradOffset' ++]) + +-var createShader = shaders.createShader +-var createContourShader = shaders.createContourShader +-var createPickShader = shaders.createPickShader +-var createPickContourShader = shaders.createPickContourShader ++},{"./builtins":159}],159:[function(require,module,exports){ ++module.exports = [ ++ // Keep this list sorted ++ 'abs' ++ , 'acos' ++ , 'all' ++ , 'any' ++ , 'asin' ++ , 'atan' ++ , 'ceil' ++ , 'clamp' ++ , 'cos' ++ , 'cross' ++ , 'dFdx' ++ , 'dFdy' ++ , 'degrees' ++ , 'distance' ++ , 'dot' ++ , 'equal' ++ , 'exp' ++ , 'exp2' ++ , 'faceforward' ++ , 'floor' ++ , 'fract' ++ , 'gl_BackColor' ++ , 'gl_BackLightModelProduct' ++ , 'gl_BackLightProduct' ++ , 'gl_BackMaterial' ++ , 'gl_BackSecondaryColor' ++ , 'gl_ClipPlane' ++ , 'gl_ClipVertex' ++ , 'gl_Color' ++ , 'gl_DepthRange' ++ , 'gl_DepthRangeParameters' ++ , 'gl_EyePlaneQ' ++ , 'gl_EyePlaneR' ++ , 'gl_EyePlaneS' ++ , 'gl_EyePlaneT' ++ , 'gl_Fog' ++ , 'gl_FogCoord' ++ , 'gl_FogFragCoord' ++ , 'gl_FogParameters' ++ , 'gl_FragColor' ++ , 'gl_FragCoord' ++ , 'gl_FragData' ++ , 'gl_FragDepth' ++ , 'gl_FragDepthEXT' ++ , 'gl_FrontColor' ++ , 'gl_FrontFacing' ++ , 'gl_FrontLightModelProduct' ++ , 'gl_FrontLightProduct' ++ , 'gl_FrontMaterial' ++ , 'gl_FrontSecondaryColor' ++ , 'gl_LightModel' ++ , 'gl_LightModelParameters' ++ , 'gl_LightModelProducts' ++ , 'gl_LightProducts' ++ , 'gl_LightSource' ++ , 'gl_LightSourceParameters' ++ , 'gl_MaterialParameters' ++ , 'gl_MaxClipPlanes' ++ , 'gl_MaxCombinedTextureImageUnits' ++ , 'gl_MaxDrawBuffers' ++ , 'gl_MaxFragmentUniformComponents' ++ , 'gl_MaxLights' ++ , 'gl_MaxTextureCoords' ++ , 'gl_MaxTextureImageUnits' ++ , 'gl_MaxTextureUnits' ++ , 'gl_MaxVaryingFloats' ++ , 'gl_MaxVertexAttribs' ++ , 'gl_MaxVertexTextureImageUnits' ++ , 'gl_MaxVertexUniformComponents' ++ , 'gl_ModelViewMatrix' ++ , 'gl_ModelViewMatrixInverse' ++ , 'gl_ModelViewMatrixInverseTranspose' ++ , 'gl_ModelViewMatrixTranspose' ++ , 'gl_ModelViewProjectionMatrix' ++ , 'gl_ModelViewProjectionMatrixInverse' ++ , 'gl_ModelViewProjectionMatrixInverseTranspose' ++ , 'gl_ModelViewProjectionMatrixTranspose' ++ , 'gl_MultiTexCoord0' ++ , 'gl_MultiTexCoord1' ++ , 'gl_MultiTexCoord2' ++ , 'gl_MultiTexCoord3' ++ , 'gl_MultiTexCoord4' ++ , 'gl_MultiTexCoord5' ++ , 'gl_MultiTexCoord6' ++ , 'gl_MultiTexCoord7' ++ , 'gl_Normal' ++ , 'gl_NormalMatrix' ++ , 'gl_NormalScale' ++ , 'gl_ObjectPlaneQ' ++ , 'gl_ObjectPlaneR' ++ , 'gl_ObjectPlaneS' ++ , 'gl_ObjectPlaneT' ++ , 'gl_Point' ++ , 'gl_PointCoord' ++ , 'gl_PointParameters' ++ , 'gl_PointSize' ++ , 'gl_Position' ++ , 'gl_ProjectionMatrix' ++ , 'gl_ProjectionMatrixInverse' ++ , 'gl_ProjectionMatrixInverseTranspose' ++ , 'gl_ProjectionMatrixTranspose' ++ , 'gl_SecondaryColor' ++ , 'gl_TexCoord' ++ , 'gl_TextureEnvColor' ++ , 'gl_TextureMatrix' ++ , 'gl_TextureMatrixInverse' ++ , 'gl_TextureMatrixInverseTranspose' ++ , 'gl_TextureMatrixTranspose' ++ , 'gl_Vertex' ++ , 'greaterThan' ++ , 'greaterThanEqual' ++ , 'inversesqrt' ++ , 'length' ++ , 'lessThan' ++ , 'lessThanEqual' ++ , 'log' ++ , 'log2' ++ , 'matrixCompMult' ++ , 'max' ++ , 'min' ++ , 'mix' ++ , 'mod' ++ , 'normalize' ++ , 'not' ++ , 'notEqual' ++ , 'pow' ++ , 'radians' ++ , 'reflect' ++ , 'refract' ++ , 'sign' ++ , 'sin' ++ , 'smoothstep' ++ , 'sqrt' ++ , 'step' ++ , 'tan' ++ , 'texture2D' ++ , 'texture2DLod' ++ , 'texture2DProj' ++ , 'texture2DProjLod' ++ , 'textureCube' ++ , 'textureCubeLod' ++ , 'texture2DLodEXT' ++ , 'texture2DProjLodEXT' ++ , 'textureCubeLodEXT' ++ , 'texture2DGradEXT' ++ , 'texture2DProjGradEXT' ++ , 'textureCubeGradEXT' ++] + +-var SURFACE_VERTEX_SIZE = 4 * (4 + 3 + 3) ++},{}],160:[function(require,module,exports){ ++var v100 = require('./literals') ++ ++module.exports = v100.slice().concat([ ++ 'layout' ++ , 'centroid' ++ , 'smooth' ++ , 'case' ++ , 'mat2x2' ++ , 'mat2x3' ++ , 'mat2x4' ++ , 'mat3x2' ++ , 'mat3x3' ++ , 'mat3x4' ++ , 'mat4x2' ++ , 'mat4x3' ++ , 'mat4x4' ++ , 'uint' ++ , 'uvec2' ++ , 'uvec3' ++ , 'uvec4' ++ , 'samplerCubeShadow' ++ , 'sampler2DArray' ++ , 'sampler2DArrayShadow' ++ , 'isampler2D' ++ , 'isampler3D' ++ , 'isamplerCube' ++ , 'isampler2DArray' ++ , 'usampler2D' ++ , 'usampler3D' ++ , 'usamplerCube' ++ , 'usampler2DArray' ++ , 'coherent' ++ , 'restrict' ++ , 'readonly' ++ , 'writeonly' ++ , 'resource' ++ , 'atomic_uint' ++ , 'noperspective' ++ , 'patch' ++ , 'sample' ++ , 'subroutine' ++ , 'common' ++ , 'partition' ++ , 'active' ++ , 'filter' ++ , 'image1D' ++ , 'image2D' ++ , 'image3D' ++ , 'imageCube' ++ , 'iimage1D' ++ , 'iimage2D' ++ , 'iimage3D' ++ , 'iimageCube' ++ , 'uimage1D' ++ , 'uimage2D' ++ , 'uimage3D' ++ , 'uimageCube' ++ , 'image1DArray' ++ , 'image2DArray' ++ , 'iimage1DArray' ++ , 'iimage2DArray' ++ , 'uimage1DArray' ++ , 'uimage2DArray' ++ , 'image1DShadow' ++ , 'image2DShadow' ++ , 'image1DArrayShadow' ++ , 'image2DArrayShadow' ++ , 'imageBuffer' ++ , 'iimageBuffer' ++ , 'uimageBuffer' ++ , 'sampler1DArray' ++ , 'sampler1DArrayShadow' ++ , 'isampler1D' ++ , 'isampler1DArray' ++ , 'usampler1D' ++ , 'usampler1DArray' ++ , 'isampler2DRect' ++ , 'usampler2DRect' ++ , 'samplerBuffer' ++ , 'isamplerBuffer' ++ , 'usamplerBuffer' ++ , 'sampler2DMS' ++ , 'isampler2DMS' ++ , 'usampler2DMS' ++ , 'sampler2DMSArray' ++ , 'isampler2DMSArray' ++ , 'usampler2DMSArray' ++]) ++ ++},{"./literals":161}],161:[function(require,module,exports){ ++module.exports = [ ++ // current ++ 'precision' ++ , 'highp' ++ , 'mediump' ++ , 'lowp' ++ , 'attribute' ++ , 'const' ++ , 'uniform' ++ , 'varying' ++ , 'break' ++ , 'continue' ++ , 'do' ++ , 'for' ++ , 'while' ++ , 'if' ++ , 'else' ++ , 'in' ++ , 'out' ++ , 'inout' ++ , 'float' ++ , 'int' ++ , 'void' ++ , 'bool' ++ , 'true' ++ , 'false' ++ , 'discard' ++ , 'return' ++ , 'mat2' ++ , 'mat3' ++ , 'mat4' ++ , 'vec2' ++ , 'vec3' ++ , 'vec4' ++ , 'ivec2' ++ , 'ivec3' ++ , 'ivec4' ++ , 'bvec2' ++ , 'bvec3' ++ , 'bvec4' ++ , 'sampler1D' ++ , 'sampler2D' ++ , 'sampler3D' ++ , 'samplerCube' ++ , 'sampler1DShadow' ++ , 'sampler2DShadow' ++ , 'struct' ++ ++ // future ++ , 'asm' ++ , 'class' ++ , 'union' ++ , 'enum' ++ , 'typedef' ++ , 'template' ++ , 'this' ++ , 'packed' ++ , 'goto' ++ , 'switch' ++ , 'default' ++ , 'inline' ++ , 'noinline' ++ , 'volatile' ++ , 'public' ++ , 'static' ++ , 'extern' ++ , 'external' ++ , 'interface' ++ , 'long' ++ , 'short' ++ , 'double' ++ , 'half' ++ , 'fixed' ++ , 'unsigned' ++ , 'input' ++ , 'output' ++ , 'hvec2' ++ , 'hvec3' ++ , 'hvec4' ++ , 'dvec2' ++ , 'dvec3' ++ , 'dvec4' ++ , 'fvec2' ++ , 'fvec3' ++ , 'fvec4' ++ , 'sampler2DRect' ++ , 'sampler3DRect' ++ , 'sampler2DRectShadow' ++ , 'sizeof' ++ , 'cast' ++ , 'namespace' ++ , 'using' ++] ++ ++},{}],162:[function(require,module,exports){ ++module.exports = [ ++ '<<=' ++ , '>>=' ++ , '++' ++ , '--' ++ , '<<' ++ , '>>' ++ , '<=' ++ , '>=' ++ , '==' ++ , '!=' ++ , '&&' ++ , '||' ++ , '+=' ++ , '-=' ++ , '*=' ++ , '/=' ++ , '%=' ++ , '&=' ++ , '^^' ++ , '^=' ++ , '|=' ++ , '(' ++ , ')' ++ , '[' ++ , ']' ++ , '.' ++ , '!' ++ , '~' ++ , '*' ++ , '/' ++ , '%' ++ , '+' ++ , '-' ++ , '<' ++ , '>' ++ , '&' ++ , '^' ++ , '|' ++ , '?' ++ , ':' ++ , '=' ++ , ',' ++ , ';' ++ , '{' ++ , '}' ++] + +-var IDENTITY = [ +- 1, 0, 0, 0, +- 0, 1, 0, 0, +- 0, 0, 1, 0, +- 0, 0, 0, 1 ] ++},{}],163:[function(require,module,exports){ ++var tokenize = require('./index') + +-var QUAD = [ +- [0, 0], +- [0, 1], +- [1, 0], +- [1, 1], +- [1, 0], +- [0, 1] +-] ++module.exports = tokenizeString + +-var PERMUTATIONS = [ +- [0, 0, 0, 0, 0, 0, 0, 0, 0], +- [0, 0, 0, 0, 0, 0, 0, 0, 0], +- [0, 0, 0, 0, 0, 0, 0, 0, 0] +-] ++function tokenizeString(str, opt) { ++ var generator = tokenize(opt) ++ var tokens = [] + +-;(function () { +- for (var i = 0; i < 3; ++i) { +- var p = PERMUTATIONS[i] +- var u = (i + 1) % 3 +- var v = (i + 2) % 3 +- p[u + 0] = 1 +- p[v + 3] = 1 +- p[i + 6] = 1 +- } +-})() ++ tokens = tokens.concat(generator(str)) ++ tokens = tokens.concat(generator(null)) + +-function SurfacePickResult (position, index, uv, level, dataCoordinate) { +- this.position = position +- this.index = index +- this.uv = uv +- this.level = level +- this.dataCoordinate = dataCoordinate ++ return tokens + } + +-var N_COLORS = 265 ++},{"./index":157}],164:[function(require,module,exports){ ++exports.read = function (buffer, offset, isLE, mLen, nBytes) { ++ var e, m ++ var eLen = nBytes * 8 - mLen - 1 ++ var eMax = (1 << eLen) - 1 ++ var eBias = eMax >> 1 ++ var nBits = -7 ++ var i = isLE ? (nBytes - 1) : 0 ++ var d = isLE ? -1 : 1 ++ var s = buffer[offset + i] + +-function genColormap (name) { +- var x = pack([colormap({ +- colormap: name, +- nshades: N_COLORS, +- format: 'rgba' +- }).map(function (c) { +- return [c[0], c[1], c[2], 255 * c[3]] +- })]) +- ops.divseq(x, 255.0) +- return x +-} ++ i += d + +-function SurfacePlot ( +- gl, +- shape, +- bounds, +- shader, +- pickShader, +- coordinates, +- vao, +- colorMap, +- contourShader, +- contourPickShader, +- contourBuffer, +- contourVAO, +- dynamicBuffer, +- dynamicVAO) { +- this.gl = gl +- this.shape = shape +- this.bounds = bounds +- this.intensityBounds = []; ++ e = s & ((1 << (-nBits)) - 1) ++ s >>= (-nBits) ++ nBits += eLen ++ for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {} + +- this._shader = shader +- this._pickShader = pickShader +- this._coordinateBuffer = coordinates +- this._vao = vao +- this._colorMap = colorMap ++ m = e & ((1 << (-nBits)) - 1) ++ e >>= (-nBits) ++ nBits += mLen ++ for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {} + +- this._contourShader = contourShader +- this._contourPickShader = contourPickShader +- this._contourBuffer = contourBuffer +- this._contourVAO = contourVAO +- this._contourOffsets = [[], [], []] +- this._contourCounts = [[], [], []] +- this._vertexCount = 0 ++ if (e === 0) { ++ e = 1 - eBias ++ } else if (e === eMax) { ++ return m ? NaN : ((s ? -1 : 1) * Infinity) ++ } else { ++ m = m + Math.pow(2, mLen) ++ e = e - eBias ++ } ++ return (s ? -1 : 1) * m * Math.pow(2, e - mLen) ++} + +- this._pickResult = new SurfacePickResult([0, 0, 0], [0, 0], [0, 0], [0, 0, 0], [0, 0, 0]) ++exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { ++ var e, m, c ++ var eLen = nBytes * 8 - mLen - 1 ++ var eMax = (1 << eLen) - 1 ++ var eBias = eMax >> 1 ++ var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) ++ var i = isLE ? 0 : (nBytes - 1) ++ var d = isLE ? 1 : -1 ++ var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 + +- this._dynamicBuffer = dynamicBuffer +- this._dynamicVAO = dynamicVAO +- this._dynamicOffsets = [0, 0, 0] +- this._dynamicCounts = [0, 0, 0] ++ value = Math.abs(value) + +- this.contourWidth = [ 1, 1, 1 ] +- this.contourLevels = [[1], [1], [1]] +- this.contourTint = [0, 0, 0] +- this.contourColor = [[0.5, 0.5, 0.5, 1], [0.5, 0.5, 0.5, 1], [0.5, 0.5, 0.5, 1]] ++ if (isNaN(value) || value === Infinity) { ++ m = isNaN(value) ? 1 : 0 ++ e = eMax ++ } else { ++ e = Math.floor(Math.log(value) / Math.LN2) ++ if (value * (c = Math.pow(2, -e)) < 1) { ++ e-- ++ c *= 2 ++ } ++ if (e + eBias >= 1) { ++ value += rt / c ++ } else { ++ value += rt * Math.pow(2, 1 - eBias) ++ } ++ if (value * c >= 2) { ++ e++ ++ c /= 2 ++ } + +- this.showContour = true +- this.showSurface = true ++ if (e + eBias >= eMax) { ++ m = 0 ++ e = eMax ++ } else if (e + eBias >= 1) { ++ m = (value * c - 1) * Math.pow(2, mLen) ++ e = e + eBias ++ } else { ++ m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) ++ e = 0 ++ } ++ } + +- this.enableHighlight = [true, true, true] +- this.highlightColor = [[0, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 1]] +- this.highlightTint = [ 1, 1, 1 ] +- this.highlightLevel = [-1, -1, -1] ++ for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} + +- // Dynamic contour options +- this.enableDynamic = [ true, true, true ] +- this.dynamicLevel = [ NaN, NaN, NaN ] +- this.dynamicColor = [ [0, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 1] ] +- this.dynamicTint = [ 1, 1, 1 ] +- this.dynamicWidth = [ 1, 1, 1 ] ++ e = (e << mLen) | m ++ eLen += mLen ++ for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} + +- this.axesBounds = [[Infinity, Infinity, Infinity], [-Infinity, -Infinity, -Infinity]] +- this.surfaceProject = [ false, false, false ] +- this.contourProject = [[ false, false, false ], +- [ false, false, false ], +- [ false, false, false ]] ++ buffer[offset + i - d] |= s * 128 ++} + +- this.colorBounds = [ false, false ] ++},{}],165:[function(require,module,exports){ ++"use strict" + +- // Store xyz fields, need this for picking +- this._field = [ +- ndarray(pool.mallocFloat(1024), [0, 0]), +- ndarray(pool.mallocFloat(1024), [0, 0]), +- ndarray(pool.mallocFloat(1024), [0, 0]) ] ++//High level idea: ++// 1. Use Clarkson's incremental construction to find convex hull ++// 2. Point location in triangulation by jump and walk + +- this.pickId = 1 +- this.clipBounds = [[-Infinity, -Infinity, -Infinity], [Infinity, Infinity, Infinity]] ++module.exports = incrementalConvexHull + +- this.snapToData = false ++var orient = require("robust-orientation") ++var compareCell = require("simplicial-complex").compareCells + +- this.opacity = 1.0 ++function compareInt(a, b) { ++ return a - b ++} + +- this.lightPosition = [10, 10000, 0] +- this.ambientLight = 0.8 +- this.diffuseLight = 0.8 +- this.specularLight = 2.0 +- this.roughness = 0.5 +- this.fresnel = 1.5 ++function Simplex(vertices, adjacent, boundary) { ++ this.vertices = vertices ++ this.adjacent = adjacent ++ this.boundary = boundary ++ this.lastVisited = -1 ++} + +- this.dirty = true ++Simplex.prototype.flip = function() { ++ var t = this.vertices[0] ++ this.vertices[0] = this.vertices[1] ++ this.vertices[1] = t ++ var u = this.adjacent[0] ++ this.adjacent[0] = this.adjacent[1] ++ this.adjacent[1] = u + } + +-var proto = SurfacePlot.prototype ++function GlueFacet(vertices, cell, index) { ++ this.vertices = vertices ++ this.cell = cell ++ this.index = index ++} + +-proto.isTransparent = function () { +- return this.opacity < 1 ++function compareGlue(a, b) { ++ return compareCell(a.vertices, b.vertices) + } + +-proto.isOpaque = function () { +- if (this.opacity >= 1) { +- return true +- } +- for (var i = 0; i < 3; ++i) { +- if (this._contourCounts[i].length > 0 || this._dynamicCounts[i] > 0) { +- return true ++function bakeOrient(d) { ++ var code = ["function orient(){var tuple=this.tuple;return test("] ++ for(var i=0; i<=d; ++i) { ++ if(i > 0) { ++ code.push(",") + } ++ code.push("tuple[", i, "]") + } +- return false ++ code.push(")}return orient") ++ var proc = new Function("test", code.join("")) ++ var test = orient[d+1] ++ if(!test) { ++ test = orient ++ } ++ return proc(test) + } + +-proto.pickSlots = 1 ++var BAKED = [] + +-proto.setPickBase = function (id) { +- this.pickId = id +-} ++function Triangulation(dimension, vertices, simplices) { ++ this.dimension = dimension ++ this.vertices = vertices ++ this.simplices = simplices ++ this.interior = simplices.filter(function(c) { ++ return !c.boundary ++ }) + +-var ZERO_VEC = [0, 0, 0] ++ this.tuple = new Array(dimension+1) ++ for(var i=0; i<=dimension; ++i) { ++ this.tuple[i] = this.vertices[i] ++ } + +-var PROJECT_DATA = { +- showSurface: false, +- showContour: false, +- projections: [IDENTITY.slice(), IDENTITY.slice(), IDENTITY.slice()], +- clipBounds: [ +- [[0, 0, 0], [0, 0, 0]], +- [[0, 0, 0], [0, 0, 0]], +- [[0, 0, 0], [0, 0, 0]]] ++ var o = BAKED[dimension] ++ if(!o) { ++ o = BAKED[dimension] = bakeOrient(dimension) ++ } ++ this.orient = o + } + +-function computeProjectionData (camera, obj) { +- var i, j, k +- +- // Compute cube properties +- var cubeAxis = (obj.axes && obj.axes.lastCubeProps.axis) || ZERO_VEC ++var proto = Triangulation.prototype + +- var showSurface = obj.showSurface +- var showContour = obj.showContour ++//Degenerate situation where we are on boundary, but coplanar to face ++proto.handleBoundaryDegeneracy = function(cell, point) { ++ var d = this.dimension ++ var n = this.vertices.length - 1 ++ var tuple = this.tuple ++ var verts = this.vertices + +- for (i = 0; i < 3; ++i) { +- showSurface = showSurface || obj.surfaceProject[i] +- for (j = 0; j < 3; ++j) { +- showContour = showContour || obj.contourProject[i][j] ++ //Dumb solution: Just do dfs from boundary cell until we find any peak, or terminate ++ var toVisit = [ cell ] ++ cell.lastVisited = -n ++ while(toVisit.length > 0) { ++ cell = toVisit.pop() ++ var cellVerts = cell.vertices ++ var cellAdj = cell.adjacent ++ for(var i=0; i<=d; ++i) { ++ var neighbor = cellAdj[i] ++ if(!neighbor.boundary || neighbor.lastVisited <= -n) { ++ continue ++ } ++ var nv = neighbor.vertices ++ for(var j=0; j<=d; ++j) { ++ var vv = nv[j] ++ if(vv < 0) { ++ tuple[j] = point ++ } else { ++ tuple[j] = verts[vv] ++ } ++ } ++ var o = this.orient() ++ if(o > 0) { ++ return neighbor ++ } ++ neighbor.lastVisited = -n ++ if(o === 0) { ++ toVisit.push(neighbor) ++ } + } + } ++ return null ++} + +- for (i = 0; i < 3; ++i) { +- // Construct projection onto axis +- var axisSquish = PROJECT_DATA.projections[i] +- for (j = 0; j < 16; ++j) { +- axisSquish[j] = 0 +- } +- for (j = 0; j < 4; ++j) { +- axisSquish[5 * j] = 1 ++proto.walk = function(point, random) { ++ //Alias local properties ++ var n = this.vertices.length - 1 ++ var d = this.dimension ++ var verts = this.vertices ++ var tuple = this.tuple ++ ++ //Compute initial jump cell ++ var initIndex = random ? (this.interior.length * Math.random())|0 : (this.interior.length-1) ++ var cell = this.interior[ initIndex ] ++ ++ //Start walking ++outerLoop: ++ while(!cell.boundary) { ++ var cellVerts = cell.vertices ++ var cellAdj = cell.adjacent ++ ++ for(var i=0; i<=d; ++i) { ++ tuple[i] = verts[cellVerts[i]] + } +- axisSquish[5 * i] = 0 +- axisSquish[12 + i] = obj.axesBounds[+(cubeAxis[i] > 0)][i] +- multiply(axisSquish, camera.model, axisSquish) ++ cell.lastVisited = n + +- var nclipBounds = PROJECT_DATA.clipBounds[i] +- for (k = 0; k < 2; ++k) { +- for (j = 0; j < 3; ++j) { +- nclipBounds[k][j] = camera.clipBounds[k][j] ++ //Find farthest adjacent cell ++ for(var i=0; i<=d; ++i) { ++ var neighbor = cellAdj[i] ++ if(neighbor.lastVisited >= n) { ++ continue ++ } ++ var prev = tuple[i] ++ tuple[i] = point ++ var o = this.orient() ++ tuple[i] = prev ++ if(o < 0) { ++ cell = neighbor ++ continue outerLoop ++ } else { ++ if(!neighbor.boundary) { ++ neighbor.lastVisited = n ++ } else { ++ neighbor.lastVisited = -n ++ } + } + } +- nclipBounds[0][i] = -1e8 +- nclipBounds[1][i] = 1e8 ++ return + } + +- PROJECT_DATA.showSurface = showSurface +- PROJECT_DATA.showContour = showContour +- +- return PROJECT_DATA ++ return cell + } + +-var UNIFORMS = { +- model: IDENTITY, +- view: IDENTITY, +- projection: IDENTITY, +- inverseModel: IDENTITY.slice(), +- lowerBound: [0, 0, 0], +- upperBound: [0, 0, 0], +- colorMap: 0, +- clipBounds: [[0, 0, 0], [0, 0, 0]], +- height: 0.0, +- contourTint: 0, +- contourColor: [0, 0, 0, 1], +- permutation: [1, 0, 0, 0, 1, 0, 0, 0, 1], +- zOffset: -1e-4, +- kambient: 1, +- kdiffuse: 1, +- kspecular: 1, +- lightPosition: [1000, 1000, 1000], +- eyePosition: [0, 0, 0], +- roughness: 1, +- fresnel: 1, +- opacity: 1 +-} ++proto.addPeaks = function(point, cell) { ++ var n = this.vertices.length - 1 ++ var d = this.dimension ++ var verts = this.vertices ++ var tuple = this.tuple ++ var interior = this.interior ++ var simplices = this.simplices + +-var MATRIX_INVERSE = IDENTITY.slice() +-var DEFAULT_PERM = [1, 0, 0, 0, 1, 0, 0, 0, 1] ++ //Walking finished at boundary, time to add peaks ++ var tovisit = [ cell ] + +-function drawCore (params, transparent) { +- params = params || {} +- var gl = this.gl ++ //Stretch initial boundary cell into a peak ++ cell.lastVisited = n ++ cell.vertices[cell.vertices.indexOf(-1)] = n ++ cell.boundary = false ++ interior.push(cell) + +- gl.disable(gl.CULL_FACE) ++ //Record a list of all new boundaries created by added peaks so we can glue them together when we are all done ++ var glueFacets = [] ++ ++ //Do a traversal of the boundary walking outward from starting peak ++ while(tovisit.length > 0) { ++ //Pop off peak and walk over adjacent cells ++ var cell = tovisit.pop() ++ var cellVerts = cell.vertices ++ var cellAdj = cell.adjacent ++ var indexOfN = cellVerts.indexOf(n) ++ if(indexOfN < 0) { ++ continue ++ } ++ ++ for(var i=0; i<=d; ++i) { ++ if(i === indexOfN) { ++ continue ++ } ++ ++ //For each boundary neighbor of the cell ++ var neighbor = cellAdj[i] ++ if(!neighbor.boundary || neighbor.lastVisited >= n) { ++ continue ++ } ++ ++ var nv = neighbor.vertices ++ ++ //Test if neighbor is a peak ++ if(neighbor.lastVisited !== -n) { ++ //Compute orientation of p relative to each boundary peak ++ var indexOfNeg1 = 0 ++ for(var j=0; j<=d; ++j) { ++ if(nv[j] < 0) { ++ indexOfNeg1 = j ++ tuple[j] = point ++ } else { ++ tuple[j] = verts[nv[j]] ++ } ++ } ++ var o = this.orient() ++ ++ //Test if neighbor cell is also a peak ++ if(o > 0) { ++ nv[indexOfNeg1] = n ++ neighbor.boundary = false ++ interior.push(neighbor) ++ tovisit.push(neighbor) ++ neighbor.lastVisited = n ++ continue ++ } else { ++ neighbor.lastVisited = -n ++ } ++ } ++ ++ var na = neighbor.adjacent ++ ++ //Otherwise, replace neighbor with new face ++ var vverts = cellVerts.slice() ++ var vadj = cellAdj.slice() ++ var ncell = new Simplex(vverts, vadj, true) ++ simplices.push(ncell) + +- this._colorMap.bind(0) ++ //Connect to neighbor ++ var opposite = na.indexOf(cell) ++ if(opposite < 0) { ++ continue ++ } ++ na[opposite] = ncell ++ vadj[indexOfN] = neighbor + +- var uniforms = UNIFORMS +- uniforms.model = params.model || IDENTITY +- uniforms.view = params.view || IDENTITY +- uniforms.projection = params.projection || IDENTITY +- uniforms.lowerBound = [this.bounds[0][0], this.bounds[0][1], this.colorBounds[0] || this.bounds[0][2]] +- uniforms.upperBound = [this.bounds[1][0], this.bounds[1][1], this.colorBounds[1] || this.bounds[1][2]] +- uniforms.contourColor = this.contourColor[0] ++ //Connect to cell ++ vverts[i] = -1 ++ vadj[i] = cell ++ cellAdj[i] = ncell + +- uniforms.inverseModel = invert(uniforms.inverseModel, uniforms.model) ++ //Flip facet ++ ncell.flip() + +- for (var i = 0; i < 2; ++i) { +- var clipClamped = uniforms.clipBounds[i] +- for (var j = 0; j < 3; ++j) { +- clipClamped[j] = Math.min(Math.max(this.clipBounds[i][j], -1e8), 1e8) ++ //Add to glue list ++ for(var j=0; j<=d; ++j) { ++ var uu = vverts[j] ++ if(uu < 0 || uu === n) { ++ continue ++ } ++ var nface = new Array(d-1) ++ var nptr = 0 ++ for(var k=0; k<=d; ++k) { ++ var vv = vverts[k] ++ if(vv < 0 || k === j) { ++ continue ++ } ++ nface[nptr++] = vv ++ } ++ glueFacets.push(new GlueFacet(nface, ncell, j)) ++ } + } + } + +- uniforms.kambient = this.ambientLight +- uniforms.kdiffuse = this.diffuseLight +- uniforms.kspecular = this.specularLight +- +- uniforms.roughness = this.roughness +- uniforms.fresnel = this.fresnel +- uniforms.opacity = this.opacity ++ //Glue boundary facets together ++ glueFacets.sort(compareGlue) + +- uniforms.height = 0.0 +- uniforms.permutation = DEFAULT_PERM ++ for(var i=0; i+1= 0) { ++ bcell[ptr++] = cv[j] ++ } else { ++ parity = j&1 ++ } + } +- this._shader.uniforms.model = projectData.projections[i] +- this._shader.uniforms.clipBounds = projectData.clipBounds[i] +- this._vao.draw(gl.TRIANGLES, this._vertexCount) ++ if(parity === (d&1)) { ++ var t = bcell[0] ++ bcell[0] = bcell[1] ++ bcell[1] = t ++ } ++ boundary.push(bcell) + } +- +- this._vao.unbind() + } ++ return boundary ++} + +- if (projectData.showContour && !transparent) { +- var shader = this._contourShader +- +- // Don't apply lighting to contours +- uniforms.kambient = 1.0 +- uniforms.kdiffuse = 0.0 +- uniforms.kspecular = 0.0 +- uniforms.opacity = 1.0 +- +- shader.bind() +- shader.uniforms = uniforms ++function incrementalConvexHull(points, randomSearch) { ++ var n = points.length ++ if(n === 0) { ++ throw new Error("Must have at least d+1 points") ++ } ++ var d = points[0].length ++ if(n <= d) { ++ throw new Error("Must input at least d+1 points") ++ } + +- // Draw contour lines +- var vao = this._contourVAO +- vao.bind() ++ //FIXME: This could be degenerate, but need to select d+1 non-coplanar points to bootstrap process ++ var initialSimplex = points.slice(0, d+1) + +- // Draw contour levels +- for (i = 0; i < 3; ++i) { +- shader.uniforms.permutation = PERMUTATIONS[i] +- gl.lineWidth(this.contourWidth[i]) ++ //Make sure initial simplex is positively oriented ++ var o = orient.apply(void 0, initialSimplex) ++ if(o === 0) { ++ throw new Error("Input not in general position") ++ } ++ var initialCoords = new Array(d+1) ++ for(var i=0; i<=d; ++i) { ++ initialCoords[i] = i ++ } ++ if(o < 0) { ++ initialCoords[0] = 1 ++ initialCoords[1] = 0 ++ } + +- for (j = 0; j < this.contourLevels[i].length; ++j) { +- if (!this._contourCounts[i][j]) { +- continue +- } +- if (j === this.highlightLevel[i]) { +- shader.uniforms.contourColor = this.highlightColor[i] +- shader.uniforms.contourTint = this.highlightTint[i] +- } else if (j === 0 || (j - 1) === this.highlightLevel[i]) { +- shader.uniforms.contourColor = this.contourColor[i] +- shader.uniforms.contourTint = this.contourTint[i] +- } +- shader.uniforms.height = this.contourLevels[i][j] +- vao.draw(gl.LINES, this._contourCounts[i][j], this._contourOffsets[i][j]) ++ //Create initial topological index, glue pointers together (kind of messy) ++ var initialCell = new Simplex(initialCoords, new Array(d+1), false) ++ var boundary = initialCell.adjacent ++ var list = new Array(d+2) ++ for(var i=0; i<=d; ++i) { ++ var verts = initialCoords.slice() ++ for(var j=0; j<=d; ++j) { ++ if(j === i) { ++ verts[j] = -1 + } + } +- +- // Draw projections of surface +- for (i = 0; i < 3; ++i) { +- shader.uniforms.model = projectData.projections[i] +- shader.uniforms.clipBounds = projectData.clipBounds[i] +- for (j = 0; j < 3; ++j) { +- if (!this.contourProject[i][j]) { +- continue +- } +- shader.uniforms.permutation = PERMUTATIONS[j] +- gl.lineWidth(this.contourWidth[j]) +- for (var k = 0; k < this.contourLevels[j].length; ++k) { +- if (k === this.highlightLevel[j]) { +- shader.uniforms.contourColor = this.highlightColor[j] +- shader.uniforms.contourTint = this.highlightTint[j] +- } else if (k === 0 || (k - 1) === this.highlightLevel[j]) { +- shader.uniforms.contourColor = this.contourColor[j] +- shader.uniforms.contourTint = this.contourTint[j] +- } +- shader.uniforms.height = this.contourLevels[j][k] +- vao.draw(gl.LINES, this._contourCounts[j][k], this._contourOffsets[j][k]) ++ var t = verts[0] ++ verts[0] = verts[1] ++ verts[1] = t ++ var cell = new Simplex(verts, new Array(d+1), true) ++ boundary[i] = cell ++ list[i] = cell ++ } ++ list[d+1] = initialCell ++ for(var i=0; i<=d; ++i) { ++ var verts = boundary[i].vertices ++ var adj = boundary[i].adjacent ++ for(var j=0; j<=d; ++j) { ++ var v = verts[j] ++ if(v < 0) { ++ adj[j] = initialCell ++ continue ++ } ++ for(var k=0; k<=d; ++k) { ++ if(boundary[k].vertices.indexOf(v) < 0) { ++ adj[j] = boundary[k] + } + } + } ++ } + +- // Draw dynamic contours +- vao = this._dynamicVAO +- vao.bind() +- +- // Draw contour levels +- for (i = 0; i < 3; ++i) { +- if (this._dynamicCounts[i] === 0) { +- continue +- } ++ //Initialize triangles ++ var triangles = new Triangulation(d, initialSimplex, list) + +- shader.uniforms.model = uniforms.model +- shader.uniforms.clipBounds = uniforms.clipBounds +- shader.uniforms.permutation = PERMUTATIONS[i] +- gl.lineWidth(this.dynamicWidth[i]) ++ //Insert remaining points ++ var useRandom = !!randomSearch ++ for(var i=d+1; i 3*(weight+1)) { ++ rebuildWithInterval(this, interval) ++ } else { ++ this.left.insert(interval) + } +- this._pickShader.uniforms.model = projectData.projections[i] +- this._pickShader.uniforms.clipBounds = projectData.clipBounds[i] +- this._vao.draw(gl.TRIANGLES, this._vertexCount) ++ } else { ++ this.left = createIntervalTree([interval]) + } +- +- this._vao.unbind() ++ } else if(interval[0] > this.mid) { ++ if(this.right) { ++ if(4*(this.right.count+1) > 3*(weight+1)) { ++ rebuildWithInterval(this, interval) ++ } else { ++ this.right.insert(interval) ++ } ++ } else { ++ this.right = createIntervalTree([interval]) ++ } ++ } else { ++ var l = bounds.ge(this.leftPoints, interval, compareBegin) ++ var r = bounds.ge(this.rightPoints, interval, compareEnd) ++ this.leftPoints.splice(l, 0, interval) ++ this.rightPoints.splice(r, 0, interval) + } ++} + +- if (projectData.showContour) { +- var shader = this._contourPickShader +- +- shader.bind() +- shader.uniforms = uniforms +- +- var vao = this._contourVAO +- vao.bind() +- +- for (j = 0; j < 3; ++j) { +- gl.lineWidth(this.contourWidth[j]) +- shader.uniforms.permutation = PERMUTATIONS[j] +- for (i = 0; i < this.contourLevels[j].length; ++i) { +- if (this._contourCounts[j][i]) { +- shader.uniforms.height = this.contourLevels[j][i] +- vao.draw(gl.LINES, this._contourCounts[j][i], this._contourOffsets[j][i]) ++proto.remove = function(interval) { ++ var weight = this.count - this.leftPoints ++ if(interval[1] < this.mid) { ++ if(!this.left) { ++ return NOT_FOUND ++ } ++ var rw = this.right ? this.right.count : 0 ++ if(4 * rw > 3 * (weight-1)) { ++ return rebuildWithoutInterval(this, interval) ++ } ++ var r = this.left.remove(interval) ++ if(r === EMPTY) { ++ this.left = null ++ this.count -= 1 ++ return SUCCESS ++ } else if(r === SUCCESS) { ++ this.count -= 1 ++ } ++ return r ++ } else if(interval[0] > this.mid) { ++ if(!this.right) { ++ return NOT_FOUND ++ } ++ var lw = this.left ? this.left.count : 0 ++ if(4 * lw > 3 * (weight-1)) { ++ return rebuildWithoutInterval(this, interval) ++ } ++ var r = this.right.remove(interval) ++ if(r === EMPTY) { ++ this.right = null ++ this.count -= 1 ++ return SUCCESS ++ } else if(r === SUCCESS) { ++ this.count -= 1 ++ } ++ return r ++ } else { ++ if(this.count === 1) { ++ if(this.leftPoints[0] === interval) { ++ return EMPTY ++ } else { ++ return NOT_FOUND ++ } ++ } ++ if(this.leftPoints.length === 1 && this.leftPoints[0] === interval) { ++ if(this.left && this.right) { ++ var p = this ++ var n = this.left ++ while(n.right) { ++ p = n ++ n = n.right ++ } ++ if(p === this) { ++ n.right = this.right ++ } else { ++ var l = this.left ++ var r = this.right ++ p.count -= n.count ++ p.right = n.left ++ n.left = l ++ n.right = r + } ++ copy(this, n) ++ this.count = (this.left?this.left.count:0) + (this.right?this.right.count:0) + this.leftPoints.length ++ } else if(this.left) { ++ copy(this, this.left) ++ } else { ++ copy(this, this.right) + } ++ return SUCCESS + } +- +- // Draw projections of surface +- for (i = 0; i < 3; ++i) { +- shader.uniforms.model = projectData.projections[i] +- shader.uniforms.clipBounds = projectData.clipBounds[i] +- +- for (j = 0; j < 3; ++j) { +- if (!this.contourProject[i][j]) { +- continue +- } +- +- shader.uniforms.permutation = PERMUTATIONS[j] +- gl.lineWidth(this.contourWidth[j]) +- for (var k = 0; k < this.contourLevels[j].length; ++k) { +- if (this._contourCounts[j][k]) { +- shader.uniforms.height = this.contourLevels[j][k] +- vao.draw(gl.LINES, this._contourCounts[j][k], this._contourOffsets[j][k]) ++ for(var l = bounds.ge(this.leftPoints, interval, compareBegin); l=0 && arr[i][1] >= lo; --i) { ++ var r = cb(arr[i]) ++ if(r) { return r } + } ++} + +- if (selection.id !== this.pickId) { +- return null ++function reportRange(arr, cb) { ++ for(var i=0; i this.mid) { ++ if(this.right) { ++ var r = this.right.queryPoint(x, cb) ++ if(r) { return r } ++ } ++ return reportRightRange(this.rightPoints, x, cb) ++ } else { ++ return reportRange(this.leftPoints, cb) ++ } ++} + +- var result = this._pickResult ++proto.queryInterval = function(lo, hi, cb) { ++ if(lo < this.mid && this.left) { ++ var r = this.left.queryInterval(lo, hi, cb) ++ if(r) { return r } ++ } ++ if(hi > this.mid && this.right) { ++ var r = this.right.queryInterval(lo, hi, cb) ++ if(r) { return r } ++ } ++ if(hi < this.mid) { ++ return reportLeftRange(this.leftPoints, hi, cb) ++ } else if(lo > this.mid) { ++ return reportRightRange(this.rightPoints, lo, cb) ++ } else { ++ return reportRange(this.leftPoints, cb) ++ } ++} + +- // Compute uv coordinate +- var x = shape[0] * (selection.value[0] + (selection.value[2] >> 4) / 16.0) / 255.0 +- var ix = Math.floor(x) +- var fx = x - ix ++function compareNumbers(a, b) { ++ return a - b ++} + +- var y = shape[1] * (selection.value[1] + (selection.value[2] & 15) / 16.0) / 255.0 +- var iy = Math.floor(y) +- var fy = y - iy ++function compareBegin(a, b) { ++ var d = a[0] - b[0] ++ if(d) { return d } ++ return a[1] - b[1] ++} + +- ix += 1 +- iy += 1 ++function compareEnd(a, b) { ++ var d = a[1] - b[1] ++ if(d) { return d } ++ return a[0] - b[0] ++} + +- // Compute xyz coordinate +- var pos = result.position +- pos[0] = pos[1] = pos[2] = 0 +- for (var dx = 0; dx < 2; ++dx) { +- var s = dx ? fx : 1.0 - fx +- for (var dy = 0; dy < 2; ++dy) { +- var t = dy ? fy : 1.0 - fy ++function createIntervalTree(intervals) { ++ if(intervals.length === 0) { ++ return null ++ } ++ var pts = [] ++ for(var i=0; i>1] + +- for (var i = 0; i < 3; ++i) { +- pos[i] += this._field[i].get(r, c) * w +- } ++ var leftIntervals = [] ++ var rightIntervals = [] ++ var centerIntervals = [] ++ for(var i=0; i 0) { +- levelIndex[j] = 0 +- } +- } else if (levelIndex[j] < this.contourLevels[j].length - 1) { +- var a = this.contourLevels[j][levelIndex[j]] +- var b = this.contourLevels[j][levelIndex[j] + 1] +- if (Math.abs(a - pos[j]) > Math.abs(b - pos[j])) { +- levelIndex[j] += 1 +- } +- } +- } ++ //Split center intervals ++ var leftPoints = centerIntervals ++ var rightPoints = centerIntervals.slice() ++ leftPoints.sort(compareBegin) ++ rightPoints.sort(compareEnd) + +- result.index[0] = fx < 0.5 ? ix : (ix + 1) +- result.index[1] = fy < 0.5 ? iy : (iy + 1) ++ return new IntervalTreeNode(mid, ++ createIntervalTree(leftIntervals), ++ createIntervalTree(rightIntervals), ++ leftPoints, ++ rightPoints) ++} + +- result.uv[0] = x / shape[0] +- result.uv[1] = y / shape[1] ++//User friendly wrapper that makes it possible to support empty trees ++function IntervalTree(root) { ++ this.root = root ++} + +- for (i = 0; i < 3; ++i) { +- result.dataCoordinate[i] = this._field[i].get(result.index[0], result.index[1]) +- } ++var tproto = IntervalTree.prototype + +- return result ++tproto.insert = function(interval) { ++ if(this.root) { ++ this.root.insert(interval) ++ } else { ++ this.root = new IntervalTreeNode(interval[0], null, null, [interval], [interval]) ++ } + } + +-function padField (nfield, field) { +- var shape = field.shape.slice() +- var nshape = nfield.shape.slice() +- +- // Center +- ops.assign(nfield.lo(1, 1).hi(shape[0], shape[1]), field) ++tproto.remove = function(interval) { ++ if(this.root) { ++ var r = this.root.remove(interval) ++ if(r === EMPTY) { ++ this.root = null ++ } ++ return r !== NOT_FOUND ++ } ++ return false ++} + +- // Edges +- ops.assign(nfield.lo(1).hi(shape[0], 1), +- field.hi(shape[0], 1)) +- ops.assign(nfield.lo(1, nshape[1] - 1).hi(shape[0], 1), +- field.lo(0, shape[1] - 1).hi(shape[0], 1)) +- ops.assign(nfield.lo(0, 1).hi(1, shape[1]), +- field.hi(1)) +- ops.assign(nfield.lo(nshape[0] - 1, 1).hi(1, shape[1]), +- field.lo(shape[0] - 1)) +- // Corners +- nfield.set(0, 0, field.get(0, 0)) +- nfield.set(0, nshape[1] - 1, field.get(0, shape[1] - 1)) +- nfield.set(nshape[0] - 1, 0, field.get(shape[0] - 1, 0)) +- nfield.set(nshape[0] - 1, nshape[1] - 1, field.get(shape[0] - 1, shape[1] - 1)) ++tproto.queryPoint = function(p, cb) { ++ if(this.root) { ++ return this.root.queryPoint(p, cb) ++ } + } + +-function handleArray (param, ctor) { +- if (Array.isArray(param)) { +- return [ ctor(param[0]), ctor(param[1]), ctor(param[2]) ] ++tproto.queryInterval = function(lo, hi, cb) { ++ if(lo <= hi && this.root) { ++ return this.root.queryInterval(lo, hi, cb) + } +- return [ ctor(param), ctor(param), ctor(param) ] + } + +-function toColor (x) { +- if (Array.isArray(x)) { +- if (x.length === 3) { +- return [x[0], x[1], x[2], 1] ++Object.defineProperty(tproto, "count", { ++ get: function() { ++ if(this.root) { ++ return this.root.count + } +- return [x[0], x[1], x[2], x[3]] ++ return 0 + } +- return [0, 0, 0, 1] +-} ++}) + +-function handleColor (param) { +- if (Array.isArray(param)) { +- if (Array.isArray(param)) { +- return [ +- toColor(param[0]), +- toColor(param[1]), +- toColor(param[2]) ] +- } else { +- var c = toColor(param) +- return [ +- c.slice(), +- c.slice(), +- c.slice() ] ++Object.defineProperty(tproto, "intervals", { ++ get: function() { ++ if(this.root) { ++ return this.root.intervals([]) + } ++ return [] + } +-} ++}) + +-proto.update = function (params) { +- params = params || {} ++function createWrapper(intervals) { ++ if(!intervals || intervals.length === 0) { ++ return new IntervalTree(null) ++ } ++ return new IntervalTree(createIntervalTree(intervals)) ++} + +- this.dirty = true ++},{"binary-search-bounds":34}],167:[function(require,module,exports){ ++"use strict" + +- if ('contourWidth' in params) { +- this.contourWidth = handleArray(params.contourWidth, Number) +- } +- if ('showContour' in params) { +- this.showContour = handleArray(params.showContour, Boolean) +- } +- if ('showSurface' in params) { +- this.showSurface = !!params.showSurface +- } +- if ('contourTint' in params) { +- this.contourTint = handleArray(params.contourTint, Boolean) +- } +- if ('contourColor' in params) { +- this.contourColor = handleColor(params.contourColor) +- } +- if ('contourProject' in params) { +- this.contourProject = handleArray(params.contourProject, function (x) { +- return handleArray(x, Boolean) +- }) +- } +- if ('surfaceProject' in params) { +- this.surfaceProject = params.surfaceProject +- } +- if ('dynamicColor' in params) { +- this.dynamicColor = handleColor(params.dynamicColor) +- } +- if ('dynamicTint' in params) { +- this.dynamicTint = handleArray(params.dynamicTint, Number) +- } +- if ('dynamicWidth' in params) { +- this.dynamicWidth = handleArray(params.dynamicWidth, Number) +- } +- if ('opacity' in params) { +- this.opacity = params.opacity +- } +- if ('colorBounds' in params) { +- this.colorBounds = params.colorBounds ++function invertPermutation(pi, result) { ++ result = result || new Array(pi.length) ++ for(var i=0; i this._field[2].data.length) { +- pool.freeFloat(this._field[2].data) +- this._field[2].data = pool.mallocFloat(bits.nextPow2(fsize)) +- } ++module.exports = iota ++},{}],169:[function(require,module,exports){ ++/*! ++ * Determine if an object is a Buffer ++ * ++ * @author Feross Aboukhadijeh ++ * @license MIT ++ */ + +- // Pad field +- this._field[2] = ndarray(this._field[2].data, [field.shape[0] + 2, field.shape[1] + 2]) +- padField(this._field[2], field) ++// The _isBuffer check is for Safari 5-7 support, because it's missing ++// Object.prototype.constructor. Remove this eventually ++module.exports = function (obj) { ++ return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer) ++} + +- // Save shape of field +- this.shape = field.shape.slice() +- var shape = this.shape ++function isBuffer (obj) { ++ return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj) ++} + +- // Resize coordinate fields if necessary +- for (var i = 0; i < 2; ++i) { +- if (this._field[2].size > this._field[i].data.length) { +- pool.freeFloat(this._field[i].data) +- this._field[i].data = pool.mallocFloat(this._field[2].size) +- } +- this._field[i] = ndarray(this._field[i].data, [shape[0] + 2, shape[1] + 2]) +- } ++// For Node v0.10 support. Remove this eventually. ++function isSlowBuffer (obj) { ++ return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0)) ++} + +- // Generate x/y coordinates +- if (params.coords) { +- var coords = params.coords +- if (!Array.isArray(coords) || coords.length !== 3) { +- throw new Error('gl-surface: invalid coordinates for x/y') +- } +- for (i = 0; i < 2; ++i) { +- var coord = coords[i] +- for (j = 0; j < 2; ++j) { +- if (coord.shape[j] !== shape[j]) { +- throw new Error('gl-surface: coords have incorrect shape') +- } +- } +- padField(this._field[i], coord) +- } +- } else if (params.ticks) { +- var ticks = params.ticks +- if (!Array.isArray(ticks) || ticks.length !== 2) { +- throw new Error('gl-surface: invalid ticks') +- } +- for (i = 0; i < 2; ++i) { +- var tick = ticks[i] +- if (Array.isArray(tick) || tick.length) { +- tick = ndarray(tick) +- } +- if (tick.shape[0] !== shape[i]) { +- throw new Error('gl-surface: invalid tick length') +- } +- // Make a copy view of the tick array +- var tick2 = ndarray(tick.data, shape) +- tick2.stride[i] = tick.stride[0] +- tick2.stride[i ^ 1] = 0 ++},{}],170:[function(require,module,exports){ ++'use strict' + +- // Fill in field array +- padField(this._field[i], tick2) +- } +- } else { +- for (i = 0; i < 2; ++i) { +- var offset = [0, 0] +- offset[i] = 1 +- this._field[i] = ndarray(this._field[i].data, [shape[0] + 2, shape[1] + 2], offset, 0) +- } +- this._field[0].set(0, 0, 0) +- for (var j = 0; j < shape[0]; ++j) { +- this._field[0].set(j + 1, 0, j) +- } +- this._field[0].set(shape[0] + 1, 0, shape[0] - 1) +- this._field[1].set(0, 0, 0) +- for (j = 0; j < shape[1]; ++j) { +- this._field[1].set(0, j + 1, j) +- } +- this._field[1].set(0, shape[1] + 1, shape[1] - 1) +- } ++module.exports = createTable + +- // Save shape +- var fields = this._field ++var chull = require('convex-hull') + +- // Compute surface normals +- var dfields = ndarray(pool.mallocFloat(fields[2].size * 3 * 2), [3, shape[0] + 2, shape[1] + 2, 2]) +- for (i = 0; i < 3; ++i) { +- gradient(dfields.pick(i), fields[i], 'mirror') ++function constructVertex(d, a, b) { ++ var x = new Array(d) ++ for(var i=0; i 0) { +- // If we already added first edge, pop off verts +- for (var l = 0; l < 5; ++l) { +- contourVerts.pop() +- } +- vertexCount -= 1 +- } +- continue edge_loop +- } +- } +- } +- levelCounts.push(vertexCount) +- } ++ if (row[2][1] > row[1][2]) ++ quaternion[0] = -quaternion[0] ++ if (row[0][2] > row[2][0]) ++ quaternion[1] = -quaternion[1] ++ if (row[1][0] > row[0][1]) ++ quaternion[2] = -quaternion[2] ++ return true ++} + +- // Store results +- this._contourOffsets[dim] = levelOffsets +- this._contourCounts[dim] = levelCounts +- } ++//will be replaced by gl-vec4 eventually ++function vec4multMat4(out, a, m) { ++ var x = a[0], y = a[1], z = a[2], w = a[3]; ++ out[0] = m[0] * x + m[4] * y + m[8] * z + m[12] * w; ++ out[1] = m[1] * x + m[5] * y + m[9] * z + m[13] * w; ++ out[2] = m[2] * x + m[6] * y + m[10] * z + m[14] * w; ++ out[3] = m[3] * x + m[7] * y + m[11] * z + m[15] * w; ++ return out; ++} + +- var floatBuffer = pool.mallocFloat(contourVerts.length) +- for (i = 0; i < contourVerts.length; ++i) { +- floatBuffer[i] = contourVerts[i] +- } +- this._contourBuffer.update(floatBuffer) +- pool.freeFloat(floatBuffer) +- } ++//gets upper-left of a 4x4 matrix into a 3x3 of vectors ++function mat3from4(out, mat4x4) { ++ out[0][0] = mat4x4[0] ++ out[0][1] = mat4x4[1] ++ out[0][2] = mat4x4[2] ++ ++ out[1][0] = mat4x4[4] ++ out[1][1] = mat4x4[5] ++ out[1][2] = mat4x4[6] + +- if (params.colormap) { +- this._colorMap.setPixels(genColormap(params.colormap)) +- } ++ out[2][0] = mat4x4[8] ++ out[2][1] = mat4x4[9] ++ out[2][2] = mat4x4[10] + } + +-proto.dispose = function () { +- this._shader.dispose() +- this._vao.dispose() +- this._coordinateBuffer.dispose() +- this._colorMap.dispose() +- this._contourBuffer.dispose() +- this._contourVAO.dispose() +- this._contourShader.dispose() +- this._contourPickShader.dispose() +- this._dynamicBuffer.dispose() +- this._dynamicVAO.dispose() +- for (var i = 0; i < 3; ++i) { +- pool.freeFloat(this._field[i].data) +- } ++function combine(out, a, b, scale1, scale2) { ++ out[0] = a[0] * scale1 + b[0] * scale2 ++ out[1] = a[1] * scale1 + b[1] * scale2 ++ out[2] = a[2] * scale1 + b[2] * scale2 + } ++},{"./normalize":172,"gl-mat4/clone":105,"gl-mat4/create":106,"gl-mat4/determinant":107,"gl-mat4/invert":111,"gl-mat4/transpose":121,"gl-vec3/cross":149,"gl-vec3/dot":150,"gl-vec3/length":151,"gl-vec3/normalize":153}],172:[function(require,module,exports){ ++module.exports = function normalize(out, mat) { ++ var m44 = mat[15] ++ // Cannot normalize. ++ if (m44 === 0) ++ return false ++ var scale = 1 / m44 ++ for (var i=0; i<16; i++) ++ out[i] = mat[i] * scale ++ return true ++} ++},{}],173:[function(require,module,exports){ ++var lerp = require('gl-vec3/lerp') + +-proto.highlight = function (selection) { +- if (!selection) { +- this._dynamicCounts = [0, 0, 0] +- this.dyanamicLevel = [NaN, NaN, NaN] +- this.highlightLevel = [-1, -1, -1] +- return +- } ++var recompose = require('mat4-recompose') ++var decompose = require('mat4-decompose') ++var determinant = require('gl-mat4/determinant') ++var slerp = require('quat-slerp') + +- for (var i = 0; i < 3; ++i) { +- if (this.enableHighlight[i]) { +- this.highlightLevel[i] = selection.level[i] +- } else { +- this.highlightLevel[i] = -1 +- } +- } ++var state0 = state() ++var state1 = state() ++var tmp = state() + +- var levels +- if (this.snapToData) { +- levels = selection.dataCoordinate +- } else { +- levels = selection.position +- } +- if ((!this.enableDynamic[0] || levels[0] === this.dynamicLevel[0]) && +- (!this.enableDynamic[1] || levels[1] === this.dynamicLevel[1]) && +- (!this.enableDynamic[2] || levels[2] === this.dynamicLevel[2])) { +- return +- } ++module.exports = interpolate ++function interpolate(out, start, end, alpha) { ++ if (determinant(start) === 0 || determinant(end) === 0) ++ return false + +- var vertexCount = 0 +- var shape = this.shape +- var scratchBuffer = pool.mallocFloat(12 * shape[0] * shape[1]) ++ //decompose the start and end matrices into individual components ++ var r0 = decompose(start, state0.translate, state0.scale, state0.skew, state0.perspective, state0.quaternion) ++ var r1 = decompose(end, state1.translate, state1.scale, state1.skew, state1.perspective, state1.quaternion) ++ if (!r0 || !r1) ++ return false + +- for (var d = 0; d < 3; ++d) { +- if (!this.enableDynamic[d]) { +- this.dynamicLevel[d] = NaN +- this._dynamicCounts[d] = 0 +- continue ++ ++ //now lerp/slerp the start and end components into a temporary lerp(tmptranslate, state0.translate, state1.translate, alpha) ++ lerp(tmp.translate, state0.translate, state1.translate, alpha) ++ lerp(tmp.skew, state0.skew, state1.skew, alpha) ++ lerp(tmp.scale, state0.scale, state1.scale, alpha) ++ lerp(tmp.perspective, state0.perspective, state1.perspective, alpha) ++ slerp(tmp.quaternion, state0.quaternion, state1.quaternion, alpha) ++ ++ //and recompose into our 'out' matrix ++ recompose(out, tmp.translate, tmp.scale, tmp.skew, tmp.perspective, tmp.quaternion) ++ return true ++} ++ ++function state() { ++ return { ++ translate: vec3(), ++ scale: vec3(1), ++ skew: vec3(), ++ perspective: vec4(), ++ quaternion: vec4() + } ++} + +- this.dynamicLevel[d] = levels[d] ++function vec3(n) { ++ return [n||0,n||0,n||0] ++} + +- var u = (d + 1) % 3 +- var v = (d + 2) % 3 ++function vec4() { ++ return [0,0,0,1] ++} ++},{"gl-mat4/determinant":107,"gl-vec3/lerp":152,"mat4-decompose":171,"mat4-recompose":174,"quat-slerp":206}],174:[function(require,module,exports){ ++/* ++Input: translation ; a 3 component vector ++ scale ; a 3 component vector ++ skew ; skew factors XY,XZ,YZ represented as a 3 component vector ++ perspective ; a 4 component vector ++ quaternion ; a 4 component vector ++Output: matrix ; a 4x4 matrix + +- var f = this._field[d] +- var g = this._field[u] +- var h = this._field[v] +- var intensity = this.intensity ++From: http://www.w3.org/TR/css3-transforms/#recomposing-to-a-3d-matrix ++*/ + +- var graph = surfaceNets(f, levels[d]) +- var edges = graph.cells +- var positions = graph.positions ++var mat4 = { ++ identity: require('gl-mat4/identity'), ++ translate: require('gl-mat4/translate'), ++ multiply: require('gl-mat4/multiply'), ++ create: require('gl-mat4/create'), ++ scale: require('gl-mat4/scale'), ++ fromRotationTranslation: require('gl-mat4/fromRotationTranslation') ++} + +- this._dynamicOffsets[d] = vertexCount ++var rotationMatrix = mat4.create() ++var temp = mat4.create() + +- for (i = 0; i < edges.length; ++i) { +- var e = edges[i] +- for (var j = 0; j < 2; ++j) { +- var p = positions[e[j]] ++module.exports = function recomposeMat4(matrix, translation, scale, skew, perspective, quaternion) { ++ mat4.identity(matrix) + +- var x = +p[0] +- var ix = x | 0 +- var jx = Math.min(ix + 1, shape[0]) | 0 +- var fx = x - ix +- var hx = 1.0 - fx ++ //apply translation & rotation ++ mat4.fromRotationTranslation(matrix, quaternion, translation) + +- var y = +p[1] +- var iy = y | 0 +- var jy = Math.min(iy + 1, shape[1]) | 0 +- var fy = y - iy +- var hy = 1.0 - fy ++ //apply perspective ++ matrix[3] = perspective[0] ++ matrix[7] = perspective[1] ++ matrix[11] = perspective[2] ++ matrix[15] = perspective[3] ++ ++ // apply skew ++ // temp is a identity 4x4 matrix initially ++ mat4.identity(temp) + +- var w00 = hx * hy +- var w01 = hx * fy +- var w10 = fx * hy +- var w11 = fx * fy ++ if (skew[2] !== 0) { ++ temp[9] = skew[2] ++ mat4.multiply(matrix, matrix, temp) ++ } + +- var cu = w00 * g.get(ix, iy) + +- w01 * g.get(ix, jy) + +- w10 * g.get(jx, iy) + +- w11 * g.get(jx, jy) ++ if (skew[1] !== 0) { ++ temp[9] = 0 ++ temp[8] = skew[1] ++ mat4.multiply(matrix, matrix, temp) ++ } + +- var cv = w00 * h.get(ix, iy) + +- w01 * h.get(ix, jy) + +- w10 * h.get(jx, iy) + +- w11 * h.get(jx, jy) ++ if (skew[0] !== 0) { ++ temp[8] = 0 ++ temp[4] = skew[0] ++ mat4.multiply(matrix, matrix, temp) ++ } + +- if (isNaN(cu) || isNaN(cv)) { +- if (j) { +- vertexCount -= 1 +- } +- break +- } ++ //apply scale ++ mat4.scale(matrix, matrix, scale) ++ return matrix ++} ++},{"gl-mat4/create":106,"gl-mat4/fromRotationTranslation":109,"gl-mat4/identity":110,"gl-mat4/multiply":113,"gl-mat4/scale":119,"gl-mat4/translate":120}],175:[function(require,module,exports){ ++'use strict' + +- scratchBuffer[2 * vertexCount + 0] = cu +- scratchBuffer[2 * vertexCount + 1] = cv ++var bsearch = require('binary-search-bounds') ++var m4interp = require('mat4-interpolate') ++var invert44 = require('gl-mat4/invert') ++var rotateX = require('gl-mat4/rotateX') ++var rotateY = require('gl-mat4/rotateY') ++var rotateZ = require('gl-mat4/rotateZ') ++var lookAt = require('gl-mat4/lookAt') ++var translate = require('gl-mat4/translate') ++var scale = require('gl-mat4/scale') ++var normalize = require('gl-vec3/normalize') + +- vertexCount += 1 +- } +- } ++var DEFAULT_CENTER = [0,0,0] + +- this._dynamicCounts[d] = vertexCount - this._dynamicOffsets[d] +- } ++module.exports = createMatrixCameraController + +- this._dynamicBuffer.update(scratchBuffer.subarray(0, 2 * vertexCount)) +- pool.freeFloat(scratchBuffer) ++function MatrixCameraController(initialMatrix) { ++ this._components = initialMatrix.slice() ++ this._time = [0] ++ this.prevMatrix = initialMatrix.slice() ++ this.nextMatrix = initialMatrix.slice() ++ this.computedMatrix = initialMatrix.slice() ++ this.computedInverse = initialMatrix.slice() ++ this.computedEye = [0,0,0] ++ this.computedUp = [0,0,0] ++ this.computedCenter = [0,0,0] ++ this.computedRadius = [0] ++ this._limits = [-Infinity, Infinity] + } + +-function createSurfacePlot (params) { +- var gl = params.gl +- var shader = createShader(gl) +- var pickShader = createPickShader(gl) +- var contourShader = createContourShader(gl) +- var contourPickShader = createPickContourShader(gl) ++var proto = MatrixCameraController.prototype + +- var coordinateBuffer = createBuffer(gl) +- var vao = createVAO(gl, [ +- { buffer: coordinateBuffer, +- size: 4, +- stride: SURFACE_VERTEX_SIZE, +- offset: 0 +- }, +- { buffer: coordinateBuffer, +- size: 3, +- stride: SURFACE_VERTEX_SIZE, +- offset: 16 +- }, +- { +- buffer: coordinateBuffer, +- size: 3, +- stride: SURFACE_VERTEX_SIZE, +- offset: 28 ++proto.recalcMatrix = function(t) { ++ var time = this._time ++ var tidx = bsearch.le(time, t) ++ var mat = this.computedMatrix ++ if(tidx < 0) { ++ return ++ } ++ var comps = this._components ++ if(tidx === time.length-1) { ++ var ptr = 16*tidx ++ for(var i=0; i<16; ++i) { ++ mat[i] = comps[ptr++] + } +- ]) +- +- var contourBuffer = createBuffer(gl) +- var contourVAO = createVAO(gl, [ +- { +- buffer: contourBuffer, +- size: 4, +- stride: 20, +- offset: 0 +- }, +- { +- buffer: contourBuffer, +- size: 1, +- stride: 20, +- offset: 16 ++ } else { ++ var dt = (time[tidx+1] - time[tidx]) ++ var ptr = 16*tidx ++ var prev = this.prevMatrix ++ var allEqual = true ++ for(var i=0; i<16; ++i) { ++ prev[i] = comps[ptr++] + } +- ]) ++ var next = this.nextMatrix ++ for(var i=0; i<16; ++i) { ++ next[i] = comps[ptr++] ++ allEqual = allEqual && (prev[i] === next[i]) ++ } ++ if(dt < 1e-6 || allEqual) { ++ for(var i=0; i<16; ++i) { ++ mat[i] = prev[i] ++ } ++ } else { ++ m4interp(mat, prev, next, (t - time[tidx])/dt) ++ } ++ } + +- var dynamicBuffer = createBuffer(gl) +- var dynamicVAO = createVAO(gl, [ +- { +- buffer: dynamicBuffer, +- size: 2, +- type: gl.FLOAT +- }]) ++ var up = this.computedUp ++ up[0] = mat[1] ++ up[1] = mat[5] ++ up[2] = mat[6] ++ normalize(up, up) + +- var cmap = createTexture(gl, 1, N_COLORS, gl.RGBA, gl.UNSIGNED_BYTE) +- cmap.minFilter = gl.LINEAR +- cmap.magFilter = gl.LINEAR ++ var imat = this.computedInverse ++ invert44(imat, mat) ++ var eye = this.computedEye ++ var w = imat[15] ++ eye[0] = imat[12]/w ++ eye[1] = imat[13]/w ++ eye[2] = imat[14]/w + +- var surface = new SurfacePlot( +- gl, +- [0, 0], +- [[0, 0, 0], [0, 0, 0]], +- shader, +- pickShader, +- coordinateBuffer, +- vao, +- cmap, +- contourShader, +- contourPickShader, +- contourBuffer, +- contourVAO, +- dynamicBuffer, +- dynamicVAO) ++ var center = this.computedCenter ++ var radius = Math.exp(this.computedRadius[0]) ++ for(var i=0; i<3; ++i) { ++ center[i] = eye[i] - mat[2+4*i] * radius ++ } ++} + +- var nparams = { +- levels: [[], [], []] ++proto.idle = function(t) { ++ if(t < this.lastT()) { ++ return + } +- for (var id in params) { +- nparams[id] = params[id] ++ var mc = this._components ++ var ptr = mc.length-16 ++ for(var i=0; i<16; ++i) { ++ mc.push(mc[ptr++]) + } +- nparams.colormap = nparams.colormap || 'jet' +- +- surface.update(nparams) ++ this._time.push(t) ++} + +- return surface ++proto.flush = function(t) { ++ var idx = bsearch.gt(this._time, t) - 2 ++ if(idx < 0) { ++ return ++ } ++ this._time.slice(0, idx) ++ this._components.slice(0, 16*idx) + } + +-},{"./lib/shaders":182,"binary-search-bounds":183,"bit-twiddle":38,"colormap":88,"gl-buffer":105,"gl-mat4/invert":120,"gl-mat4/multiply":122,"gl-texture2d":188,"gl-vao":192,"ndarray":219,"ndarray-gradient":184,"ndarray-ops":218,"ndarray-pack":185,"surface-nets":238,"typedarray-pool":242}],188:[function(require,module,exports){ +-'use strict' ++proto.lastT = function() { ++ return this._time[this._time.length-1] ++} + +-var ndarray = require('ndarray') +-var ops = require('ndarray-ops') +-var pool = require('typedarray-pool') ++proto.lookAt = function(t, eye, center, up) { ++ this.recalcMatrix(t) ++ eye = eye || this.computedEye ++ center = center || DEFAULT_CENTER ++ up = up || this.computedUp ++ this.setMatrix(t, lookAt(this.computedMatrix, eye, center, up)) ++ var d2 = 0.0 ++ for(var i=0; i<3; ++i) { ++ d2 += Math.pow(center[i] - eye[i], 2) ++ } ++ d2 = Math.log(Math.sqrt(d2)) ++ this.computedRadius[0] = d2 ++} + +-module.exports = createTexture2D ++proto.rotate = function(t, yaw, pitch, roll) { ++ this.recalcMatrix(t) ++ var mat = this.computedInverse ++ if(yaw) rotateY(mat, mat, yaw) ++ if(pitch) rotateX(mat, mat, pitch) ++ if(roll) rotateZ(mat, mat, roll) ++ this.setMatrix(t, invert44(this.computedMatrix, mat)) ++} + +-var linearTypes = null +-var filterTypes = null +-var wrapTypes = null ++var tvec = [0,0,0] + +-function lazyInitLinearTypes(gl) { +- linearTypes = [ +- gl.LINEAR, +- gl.NEAREST_MIPMAP_LINEAR, +- gl.LINEAR_MIPMAP_NEAREST, +- gl.LINEAR_MIPMAP_NEAREST +- ] +- filterTypes = [ +- gl.NEAREST, +- gl.LINEAR, +- gl.NEAREST_MIPMAP_NEAREST, +- gl.NEAREST_MIPMAP_LINEAR, +- gl.LINEAR_MIPMAP_NEAREST, +- gl.LINEAR_MIPMAP_LINEAR +- ] +- wrapTypes = [ +- gl.REPEAT, +- gl.CLAMP_TO_EDGE, +- gl.MIRRORED_REPEAT +- ] ++proto.pan = function(t, dx, dy, dz) { ++ tvec[0] = -(dx || 0.0) ++ tvec[1] = -(dy || 0.0) ++ tvec[2] = -(dz || 0.0) ++ this.recalcMatrix(t) ++ var mat = this.computedInverse ++ translate(mat, mat, tvec) ++ this.setMatrix(t, invert44(mat, mat)) + } + +-var convertFloatToUint8 = function(out, inp) { +- ops.muls(out, inp, 255.0) ++proto.translate = function(t, dx, dy, dz) { ++ tvec[0] = dx || 0.0 ++ tvec[1] = dy || 0.0 ++ tvec[2] = dz || 0.0 ++ this.recalcMatrix(t) ++ var mat = this.computedMatrix ++ translate(mat, mat, tvec) ++ this.setMatrix(t, mat) + } + +-function reshapeTexture(tex, w, h) { +- var gl = tex.gl +- var maxSize = gl.getParameter(gl.MAX_TEXTURE_SIZE) +- if(w < 0 || w > maxSize || h < 0 || h > maxSize) { +- throw new Error('gl-texture2d: Invalid texture size') ++proto.setMatrix = function(t, mat) { ++ if(t < this.lastT()) { ++ return ++ } ++ this._time.push(t) ++ for(var i=0; i<16; ++i) { ++ this._components.push(mat[i]) + } +- tex._shape = [w, h] +- tex.bind() +- gl.texImage2D(gl.TEXTURE_2D, 0, tex.format, w, h, 0, tex.format, tex.type, null) +- tex._mipLevels = [0] +- return tex + } + +-function Texture2D(gl, handle, width, height, format, type) { +- this.gl = gl +- this.handle = handle +- this.format = format +- this.type = type +- this._shape = [width, height] +- this._mipLevels = [0] +- this._magFilter = gl.NEAREST +- this._minFilter = gl.NEAREST +- this._wrapS = gl.CLAMP_TO_EDGE +- this._wrapT = gl.CLAMP_TO_EDGE +- this._anisoSamples = 1 ++proto.setDistance = function(t, d) { ++ this.computedRadius[0] = d ++} + +- var parent = this +- var wrapVector = [this._wrapS, this._wrapT] +- Object.defineProperties(wrapVector, [ +- { +- get: function() { +- return parent._wrapS +- }, +- set: function(v) { +- return parent.wrapS = v +- } +- }, +- { +- get: function() { +- return parent._wrapT +- }, +- set: function(v) { +- return parent.wrapT = v +- } +- } +- ]) +- this._wrapVector = wrapVector ++proto.setDistanceLimits = function(a,b) { ++ var lim = this._limits ++ lim[0] = a ++ lim[1] = b ++} + +- var shapeVector = [this._shape[0], this._shape[1]] +- Object.defineProperties(shapeVector, [ +- { +- get: function() { +- return parent._shape[0] +- }, +- set: function(v) { +- return parent.width = v +- } +- }, +- { +- get: function() { +- return parent._shape[1] +- }, +- set: function(v) { +- return parent.height = v +- } +- } +- ]) +- this._shapeVector = shapeVector ++proto.getDistanceLimits = function(out) { ++ var lim = this._limits ++ if(out) { ++ out[0] = lim[0] ++ out[1] = lim[1] ++ return out ++ } ++ return lim + } + +-var proto = Texture2D.prototype ++function createMatrixCameraController(options) { ++ options = options || {} ++ var matrix = options.matrix || ++ [1,0,0,0, ++ 0,1,0,0, ++ 0,0,1,0, ++ 0,0,0,1] ++ return new MatrixCameraController(matrix) ++} ++},{"binary-search-bounds":34,"gl-mat4/invert":111,"gl-mat4/lookAt":112,"gl-mat4/rotateX":116,"gl-mat4/rotateY":117,"gl-mat4/rotateZ":118,"gl-mat4/scale":119,"gl-mat4/translate":120,"gl-vec3/normalize":153,"mat4-interpolate":173}],176:[function(require,module,exports){ ++'use strict' + +-Object.defineProperties(proto, { +- minFilter: { +- get: function() { +- return this._minFilter +- }, +- set: function(v) { +- this.bind() +- var gl = this.gl +- if(this.type === gl.FLOAT && linearTypes.indexOf(v) >= 0) { +- if(!gl.getExtension('OES_texture_float_linear')) { +- v = gl.NEAREST +- } +- } +- if(filterTypes.indexOf(v) < 0) { +- throw new Error('gl-texture2d: Unknown filter mode ' + v) +- } +- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, v) +- return this._minFilter = v +- } +- }, +- magFilter: { +- get: function() { +- return this._magFilter +- }, +- set: function(v) { +- this.bind() +- var gl = this.gl +- if(this.type === gl.FLOAT && linearTypes.indexOf(v) >= 0) { +- if(!gl.getExtension('OES_texture_float_linear')) { +- v = gl.NEAREST +- } +- } +- if(filterTypes.indexOf(v) < 0) { +- throw new Error('gl-texture2d: Unknown filter mode ' + v) +- } +- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, v) +- return this._magFilter = v +- } +- }, +- mipSamples: { +- get: function() { +- return this._anisoSamples +- }, +- set: function(i) { +- var psamples = this._anisoSamples +- this._anisoSamples = Math.max(i, 1)|0 +- if(psamples !== this._anisoSamples) { +- var ext = gl.getExtension('EXT_texture_filter_anisotropic') +- if(ext) { +- this.gl.texParameterf(this.gl.TEXTURE_2D, ext.TEXTURE_MAX_ANISOTROPY_EXT, this._anisoSamples) +- } +- } +- return this._anisoSamples +- } +- }, +- wrapS: { +- get: function() { +- return this._wrapS +- }, +- set: function(v) { +- this.bind() +- if(wrapTypes.indexOf(v) < 0) { +- throw new Error('gl-texture2d: Unknown wrap mode ' + v) +- } +- this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_S, v) +- return this._wrapS = v ++module.exports = monotoneConvexHull2D ++ ++var orient = require('robust-orientation')[3] ++ ++function monotoneConvexHull2D(points) { ++ var n = points.length ++ ++ if(n < 3) { ++ var result = new Array(n) ++ for(var i=0; i 1 && orient( ++ points[lower[m-2]], ++ points[lower[m-1]], ++ p) <= 0) { ++ m -= 1 ++ lower.pop() + } +- }, +- height: { +- get: function() { +- return this._shape[1] +- }, +- set: function(h) { +- h = h|0 +- reshapeTexture(this, this._shape[0], h) +- return h ++ lower.push(idx) ++ ++ //Insert into upper list ++ m = upper.length ++ while(m > 1 && orient( ++ points[upper[m-2]], ++ points[upper[m-1]], ++ p) >= 0) { ++ m -= 1 ++ upper.pop() + } ++ upper.push(idx) + } +-}) + +-proto.bind = function(unit) { +- var gl = this.gl +- if(unit !== undefined) { +- gl.activeTexture(gl.TEXTURE0 + (unit|0)) ++ //Merge lists together ++ var result = new Array(upper.length + lower.length - 2) ++ var ptr = 0 ++ for(var i=0, nl=lower.length; i0; --j) { ++ result[ptr++] = upper[j] + } +- return gl.getParameter(gl.ACTIVE_TEXTURE) - gl.TEXTURE0 +-} + +-proto.dispose = function() { +- this.gl.deleteTexture(this.handle) ++ //Return result ++ return result + } ++},{"robust-orientation":219}],177:[function(require,module,exports){ ++'use strict' + +-proto.generateMipmap = function() { +- this.bind() +- this.gl.generateMipmap(this.gl.TEXTURE_2D) ++module.exports = mouseListen + +- //Update mip levels +- var l = Math.min(this._shape[0], this._shape[1]) +- for(var i=0; l>0; ++i, l>>>=1) { +- if(this._mipLevels.indexOf(i) < 0) { +- this._mipLevels.push(i) +- } ++var mouse = require('mouse-event') ++ ++function mouseListen(element, callback) { ++ if(!callback) { ++ callback = element ++ element = window + } +-} + +-proto.setPixels = function(data, x_off, y_off, mip_level) { +- var gl = this.gl +- this.bind() +- if(Array.isArray(x_off)) { +- mip_level = y_off +- y_off = x_off[1]|0 +- x_off = x_off[0]|0 +- } else { +- x_off = x_off || 0 +- y_off = y_off || 0 ++ var buttonState = 0 ++ var x = 0 ++ var y = 0 ++ var mods = { ++ shift: false, ++ alt: false, ++ control: false, ++ meta: false + } +- mip_level = mip_level || 0 +- if(data instanceof HTMLCanvasElement || +- data instanceof ImageData || +- data instanceof HTMLImageElement || +- data instanceof HTMLVideoElement) { +- var needsMip = this._mipLevels.indexOf(mip_level) < 0 +- if(needsMip) { +- gl.texImage2D(gl.TEXTURE_2D, 0, this.format, this.format, this.type, data) +- this._mipLevels.push(mip_level) +- } else { +- gl.texSubImage2D(gl.TEXTURE_2D, mip_level, x_off, y_off, this.format, this.type, data) ++ var attached = false ++ ++ function updateMods(ev) { ++ var changed = false ++ if('altKey' in ev) { ++ changed = changed || ev.altKey !== mods.alt ++ mods.alt = !!ev.altKey + } +- } else if(data.shape && data.stride && data.data) { +- if(data.shape.length < 2 || +- x_off + data.shape[1] > this._shape[1]>>>mip_level || +- y_off + data.shape[0] > this._shape[0]>>>mip_level || +- x_off < 0 || +- y_off < 0) { +- throw new Error('gl-texture2d: Texture dimensions are out of bounds') ++ if('shiftKey' in ev) { ++ changed = changed || ev.shiftKey !== mods.shift ++ mods.shift = !!ev.shiftKey + } +- texSubImageArray(gl, x_off, y_off, mip_level, this.format, this.type, this._mipLevels, data) +- } else { +- throw new Error('gl-texture2d: Unsupported data type') ++ if('ctrlKey' in ev) { ++ changed = changed || ev.ctrlKey !== mods.control ++ mods.control = !!ev.ctrlKey ++ } ++ if('metaKey' in ev) { ++ changed = changed || ev.metaKey !== mods.meta ++ mods.meta = !!ev.metaKey ++ } ++ return changed + } +-} + ++ function handleEvent(nextButtons, ev) { ++ var nextX = mouse.x(ev) ++ var nextY = mouse.y(ev) ++ if('buttons' in ev) { ++ nextButtons = ev.buttons|0 ++ } ++ if(nextButtons !== buttonState || ++ nextX !== x || ++ nextY !== y || ++ updateMods(ev)) { ++ buttonState = nextButtons|0 ++ x = nextX||0 ++ y = nextY||0 ++ callback && callback(buttonState, x, y, mods) ++ } ++ } + +-function isPacked(shape, stride) { +- if(shape.length === 3) { +- return (stride[2] === 1) && +- (stride[1] === shape[0]*shape[2]) && +- (stride[0] === shape[2]) ++ function clearState(ev) { ++ handleEvent(0, ev) + } +- return (stride[0] === 1) && +- (stride[1] === shape[0]) +-} + +-function texSubImageArray(gl, x_off, y_off, mip_level, cformat, ctype, mipLevels, array) { +- var dtype = array.dtype +- var shape = array.shape.slice() +- if(shape.length < 2 || shape.length > 3) { +- throw new Error('gl-texture2d: Invalid ndarray, must be 2d or 3d') ++ function handleBlur() { ++ if(buttonState || ++ x || ++ y || ++ mods.shift || ++ mods.alt || ++ mods.meta || ++ mods.control) { ++ ++ x = y = 0 ++ buttonState = 0 ++ mods.shift = mods.alt = mods.control = mods.meta = false ++ callback && callback(0, 0, 0, mods) ++ } + } +- var type = 0, format = 0 +- var packed = isPacked(shape, array.stride.slice()) +- if(dtype === 'float32') { +- type = gl.FLOAT +- } else if(dtype === 'float64') { +- type = gl.FLOAT +- packed = false +- dtype = 'float32' +- } else if(dtype === 'uint8') { +- type = gl.UNSIGNED_BYTE +- } else { +- type = gl.UNSIGNED_BYTE +- packed = false +- dtype = 'uint8' ++ ++ function handleMods(ev) { ++ if(updateMods(ev)) { ++ callback && callback(buttonState, x, y, mods) ++ } + } +- var channels = 1 +- if(shape.length === 2) { +- format = gl.LUMINANCE +- shape = [shape[0], shape[1], 1] +- array = ndarray(array.data, shape, [array.stride[0], array.stride[1], 1], array.offset) +- } else if(shape.length === 3) { +- if(shape[2] === 1) { +- format = gl.ALPHA +- } else if(shape[2] === 2) { +- format = gl.LUMINANCE_ALPHA +- } else if(shape[2] === 3) { +- format = gl.RGB +- } else if(shape[2] === 4) { +- format = gl.RGBA ++ ++ function handleMouseMove(ev) { ++ if(mouse.buttons(ev) === 0) { ++ handleEvent(0, ev) + } else { +- throw new Error('gl-texture2d: Invalid shape for pixel coords') ++ handleEvent(buttonState, ev) + } +- channels = shape[2] +- } else { +- throw new Error('gl-texture2d: Invalid shape for texture') +- } +- //For 1-channel textures allow conversion between formats +- if((format === gl.LUMINANCE || format === gl.ALPHA) && +- (cformat === gl.LUMINANCE || cformat === gl.ALPHA)) { +- format = cformat + } +- if(format !== cformat) { +- throw new Error('gl-texture2d: Incompatible texture format for setPixels') ++ ++ function handleMouseDown(ev) { ++ handleEvent(buttonState | mouse.buttons(ev), ev) + } +- var size = array.size +- var needsMip = mipLevels.indexOf(mip_level) < 0 +- if(needsMip) { +- mipLevels.push(mip_level) ++ ++ function handleMouseUp(ev) { ++ handleEvent(buttonState & ~mouse.buttons(ev), ev) + } +- if(type === ctype && packed) { +- //Array data types are compatible, can directly copy into texture +- if(array.offset === 0 && array.data.length === size) { +- if(needsMip) { +- gl.texImage2D(gl.TEXTURE_2D, mip_level, cformat, shape[0], shape[1], 0, cformat, ctype, array.data) +- } else { +- gl.texSubImage2D(gl.TEXTURE_2D, mip_level, x_off, y_off, shape[0], shape[1], cformat, ctype, array.data) +- } +- } else { +- if(needsMip) { +- gl.texImage2D(gl.TEXTURE_2D, mip_level, cformat, shape[0], shape[1], 0, cformat, ctype, array.data.subarray(array.offset, array.offset+size)) +- } else { +- gl.texSubImage2D(gl.TEXTURE_2D, mip_level, x_off, y_off, shape[0], shape[1], cformat, ctype, array.data.subarray(array.offset, array.offset+size)) +- } +- } +- } else { +- //Need to do type conversion to pack data into buffer +- var pack_buffer +- if(ctype === gl.FLOAT) { +- pack_buffer = pool.mallocFloat32(size) +- } else { +- pack_buffer = pool.mallocUint8(size) ++ ++ function attachListeners() { ++ if(attached) { ++ return + } +- var pack_view = ndarray(pack_buffer, shape, [shape[2], shape[2]*shape[0], 1]) +- if(type === gl.FLOAT && ctype === gl.UNSIGNED_BYTE) { +- convertFloatToUint8(pack_view, array) +- } else { +- ops.assign(pack_view, array) ++ attached = true ++ ++ element.addEventListener('mousemove', handleMouseMove) ++ ++ element.addEventListener('mousedown', handleMouseDown) ++ ++ element.addEventListener('mouseup', handleMouseUp) ++ ++ element.addEventListener('mouseleave', clearState) ++ element.addEventListener('mouseenter', clearState) ++ element.addEventListener('mouseout', clearState) ++ element.addEventListener('mouseover', clearState) ++ ++ element.addEventListener('blur', handleBlur) ++ ++ element.addEventListener('keyup', handleMods) ++ element.addEventListener('keydown', handleMods) ++ element.addEventListener('keypress', handleMods) ++ ++ if(element !== window) { ++ window.addEventListener('blur', handleBlur) ++ ++ window.addEventListener('keyup', handleMods) ++ window.addEventListener('keydown', handleMods) ++ window.addEventListener('keypress', handleMods) + } +- if(needsMip) { +- gl.texImage2D(gl.TEXTURE_2D, mip_level, cformat, shape[0], shape[1], 0, cformat, ctype, pack_buffer.subarray(0, size)) +- } else { +- gl.texSubImage2D(gl.TEXTURE_2D, mip_level, x_off, y_off, shape[0], shape[1], cformat, ctype, pack_buffer.subarray(0, size)) ++ } ++ ++ function detachListeners() { ++ if(!attached) { ++ return + } +- if(ctype === gl.FLOAT) { +- pool.freeFloat32(pack_buffer) +- } else { +- pool.freeUint8(pack_buffer) ++ attached = false ++ ++ element.removeEventListener('mousemove', handleMouseMove) ++ ++ element.removeEventListener('mousedown', handleMouseDown) ++ ++ element.removeEventListener('mouseup', handleMouseUp) ++ ++ element.removeEventListener('mouseleave', clearState) ++ element.removeEventListener('mouseenter', clearState) ++ element.removeEventListener('mouseout', clearState) ++ element.removeEventListener('mouseover', clearState) ++ ++ element.removeEventListener('blur', handleBlur) ++ ++ element.removeEventListener('keyup', handleMods) ++ element.removeEventListener('keydown', handleMods) ++ element.removeEventListener('keypress', handleMods) ++ ++ if(element !== window) { ++ window.removeEventListener('blur', handleBlur) ++ ++ window.removeEventListener('keyup', handleMods) ++ window.removeEventListener('keydown', handleMods) ++ window.removeEventListener('keypress', handleMods) + } + } +-} + +-function initTexture(gl) { +- var tex = gl.createTexture() +- gl.bindTexture(gl.TEXTURE_2D, tex) +- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST) +- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST) +- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE) +- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE) +- return tex +-} ++ //Attach listeners ++ attachListeners() + +-function createTextureShape(gl, width, height, format, type) { +- var maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE) +- if(width < 0 || width > maxTextureSize || height < 0 || height > maxTextureSize) { +- throw new Error('gl-texture2d: Invalid texture shape') +- } +- if(type === gl.FLOAT && !gl.getExtension('OES_texture_float')) { +- throw new Error('gl-texture2d: Floating point textures not supported on this platform') ++ var result = { ++ element: element + } +- var tex = initTexture(gl) +- gl.texImage2D(gl.TEXTURE_2D, 0, format, width, height, 0, format, type, null) +- return new Texture2D(gl, tex, width, height, format, type) +-} + +-function createTextureDOM(gl, element, format, type) { +- var tex = initTexture(gl) +- gl.texImage2D(gl.TEXTURE_2D, 0, format, format, type, element) +- return new Texture2D(gl, tex, element.width|0, element.height|0, format, type) ++ Object.defineProperties(result, { ++ enabled: { ++ get: function() { return attached }, ++ set: function(f) { ++ if(f) { ++ attachListeners() ++ } else { ++ detachListeners ++ } ++ }, ++ enumerable: true ++ }, ++ buttons: { ++ get: function() { return buttonState }, ++ enumerable: true ++ }, ++ x: { ++ get: function() { return x }, ++ enumerable: true ++ }, ++ y: { ++ get: function() { return y }, ++ enumerable: true ++ }, ++ mods: { ++ get: function() { return mods }, ++ enumerable: true ++ } ++ }) ++ ++ return result + } + +-//Creates a texture from an ndarray +-function createTextureArray(gl, array) { +- var dtype = array.dtype +- var shape = array.shape.slice() +- var maxSize = gl.getParameter(gl.MAX_TEXTURE_SIZE) +- if(shape[0] < 0 || shape[0] > maxSize || shape[1] < 0 || shape[1] > maxSize) { +- throw new Error('gl-texture2d: Invalid texture size') +- } +- var packed = isPacked(shape, array.stride.slice()) +- var type = 0 +- if(dtype === 'float32') { +- type = gl.FLOAT +- } else if(dtype === 'float64') { +- type = gl.FLOAT +- packed = false +- dtype = 'float32' +- } else if(dtype === 'uint8') { +- type = gl.UNSIGNED_BYTE +- } else { +- type = gl.UNSIGNED_BYTE +- packed = false +- dtype = 'uint8' +- } +- var format = 0 +- if(shape.length === 2) { +- format = gl.LUMINANCE +- shape = [shape[0], shape[1], 1] +- array = ndarray(array.data, shape, [array.stride[0], array.stride[1], 1], array.offset) +- } else if(shape.length === 3) { +- if(shape[2] === 1) { +- format = gl.ALPHA +- } else if(shape[2] === 2) { +- format = gl.LUMINANCE_ALPHA +- } else if(shape[2] === 3) { +- format = gl.RGB +- } else if(shape[2] === 4) { +- format = gl.RGBA +- } else { +- throw new Error('gl-texture2d: Invalid shape for pixel coords') +- } +- } else { +- throw new Error('gl-texture2d: Invalid shape for texture') +- } +- if(type === gl.FLOAT && !gl.getExtension('OES_texture_float')) { +- type = gl.UNSIGNED_BYTE +- packed = false +- } +- var buffer, buf_store +- var size = array.size +- if(!packed) { +- var stride = [shape[2], shape[2]*shape[0], 1] +- buf_store = pool.malloc(size, dtype) +- var buf_array = ndarray(buf_store, shape, stride, 0) +- if((dtype === 'float32' || dtype === 'float64') && type === gl.UNSIGNED_BYTE) { +- convertFloatToUint8(buf_array, array) +- } else { +- ops.assign(buf_array, array) ++},{"mouse-event":178}],178:[function(require,module,exports){ ++'use strict' ++ ++function mouseButtons(ev) { ++ if(typeof ev === 'object') { ++ if('buttons' in ev) { ++ return ev.buttons ++ } else if('which' in ev) { ++ var b = ev.which ++ if(b === 2) { ++ return 4 ++ } else if(b === 3) { ++ return 2 ++ } else if(b > 0) { ++ return 1<<(b-1) ++ } ++ } else if('button' in ev) { ++ var b = ev.button ++ if(b === 1) { ++ return 4 ++ } else if(b === 2) { ++ return 2 ++ } else if(b >= 0) { ++ return 1< nattribs) { +- throw new Error("gl-vao: Too many vertex attributes") +- } +- for(var i=0; i 0) { ++ stepVal.push(stride(i, order[j-1]) + "*" + shape(order[j-1]) ) ++ } ++ vars.push(step(i,order[j]) + "=(" + stepVal.join("-") + ")|0") + } +- +- mode = EOF +- token('(eof)') +- return tokens + } +- +- function normal() { +- content = content.length ? [] : content +- +- if(last === '/' && c === '*') { +- start = total + i - 1 +- mode = BLOCK_COMMENT +- last = c +- return i + 1 +- } +- +- if(last === '/' && c === '/') { +- start = total + i - 1 +- mode = LINE_COMMENT +- last = c +- return i + 1 +- } +- +- if(c === '#') { +- mode = PREPROCESSOR +- start = total + i +- return i ++ //Create index variables ++ for(var i=0; i=0; --i) { ++ sizeVariable.push(shape(order[i])) ++ } ++ //Previous phases and vertex_ids ++ vars.push(POOL_SIZE + "=(" + sizeVariable.join("*") + ")|0", ++ PHASES + "=mallocUint32(" + POOL_SIZE + ")", ++ VERTEX_IDS + "=mallocUint32(" + POOL_SIZE + ")", ++ POINTER + "=0") ++ //Create cube variables for phases ++ vars.push(pcube(0) + "=0") ++ for(var j=1; j<(1<=0; --i) { ++ forLoopBegin(i, 0) ++ } ++ var phaseFuncArgs = [] ++ for(var i=0; i 0) continue +- res = buf.slice(0, 1).join('') ++ for(var i=0; i0; k=(k-1)&subset) { ++ faceArgs.push(VERTEX_IDS + "[" + POINTER + "+" + pdelta(k) + "]") ++ } ++ faceArgs.push(vert(0)) ++ for(var k=0; k0){", ++ index(order[i]), "=1;") ++ createLoop(i-1, mask|(1< -1) { +- mode = KEYWORD +- } else if(allBuiltins.indexOf(contentstr) > -1) { +- mode = BUILTIN +- } else { +- mode = IDENT +- } +- token(content.join('')) +- mode = NORMAL +- return i ++ if(typeof args !== "object") { ++ error("Must specify arguments") ++ } ++ var order = args.order ++ if(!Array.isArray(order)) { ++ error("Must specify order") ++ } ++ var arrays = args.arrayArguments||1 ++ if(arrays < 1) { ++ error("Must have at least one array argument") ++ } ++ var scalars = args.scalarArguments||0 ++ if(scalars < 0) { ++ error("Scalar arg count must be > 0") ++ } ++ if(typeof args.vertex !== "function") { ++ error("Must specify vertex creation function") ++ } ++ if(typeof args.cell !== "function") { ++ error("Must specify cell creation function") ++ } ++ if(typeof args.phase !== "function") { ++ error("Must specify phase function") ++ } ++ var getters = args.getters || [] ++ var typesig = new Array(arrays) ++ for(var i=0; i= 0) { ++ typesig[i] = true ++ } else { ++ typesig[i] = false + } +- content.push(c) +- last = c +- return i + 1 + } ++ return compileSurfaceProcedure( ++ args.vertex, ++ args.cell, ++ args.phase, ++ scalars, ++ order, ++ typesig) + } ++},{"typedarray-pool":246}],181:[function(require,module,exports){ ++"use strict" + +-},{"./lib/builtins":196,"./lib/builtins-300es":195,"./lib/literals":198,"./lib/literals-300es":197,"./lib/operators":199}],195:[function(require,module,exports){ +-// 300es builtins/reserved words that were previously valid in v100 +-var v100 = require('./builtins') + +-// The texture2D|Cube functions have been removed +-// And the gl_ features are updated +-v100 = v100.slice().filter(function (b) { +- return !/^(gl\_|texture)/.test(b) +-}) + +-module.exports = v100.concat([ +- // the updated gl_ constants +- 'gl_VertexID' +- , 'gl_InstanceID' +- , 'gl_Position' +- , 'gl_PointSize' +- , 'gl_FragCoord' +- , 'gl_FrontFacing' +- , 'gl_FragDepth' +- , 'gl_PointCoord' +- , 'gl_MaxVertexAttribs' +- , 'gl_MaxVertexUniformVectors' +- , 'gl_MaxVertexOutputVectors' +- , 'gl_MaxFragmentInputVectors' +- , 'gl_MaxVertexTextureImageUnits' +- , 'gl_MaxCombinedTextureImageUnits' +- , 'gl_MaxTextureImageUnits' +- , 'gl_MaxFragmentUniformVectors' +- , 'gl_MaxDrawBuffers' +- , 'gl_MinProgramTexelOffset' +- , 'gl_MaxProgramTexelOffset' +- , 'gl_DepthRangeParameters' +- , 'gl_DepthRange' ++var fill = require('cwise/lib/wrapper')({"args":["index","array","scalar"],"pre":{"body":"{}","args":[],"thisVars":[],"localVars":[]},"body":{"body":"{_inline_7_arg1_=_inline_7_arg2_.apply(void 0,_inline_7_arg0_)}","args":[{"name":"_inline_7_arg0_","lvalue":false,"rvalue":true,"count":1},{"name":"_inline_7_arg1_","lvalue":true,"rvalue":false,"count":1},{"name":"_inline_7_arg2_","lvalue":false,"rvalue":true,"count":1}],"thisVars":[],"localVars":[]},"post":{"body":"{}","args":[],"thisVars":[],"localVars":[]},"debug":false,"funcName":"cwise","blockSize":64}) + +- // other builtins +- , 'trunc' +- , 'round' +- , 'roundEven' +- , 'isnan' +- , 'isinf' +- , 'floatBitsToInt' +- , 'floatBitsToUint' +- , 'intBitsToFloat' +- , 'uintBitsToFloat' +- , 'packSnorm2x16' +- , 'unpackSnorm2x16' +- , 'packUnorm2x16' +- , 'unpackUnorm2x16' +- , 'packHalf2x16' +- , 'unpackHalf2x16' +- , 'outerProduct' +- , 'transpose' +- , 'determinant' +- , 'inverse' +- , 'texture' +- , 'textureSize' +- , 'textureProj' +- , 'textureLod' +- , 'textureOffset' +- , 'texelFetch' +- , 'texelFetchOffset' +- , 'textureProjOffset' +- , 'textureLodOffset' +- , 'textureProjLod' +- , 'textureProjLodOffset' +- , 'textureGrad' +- , 'textureGradOffset' +- , 'textureProjGrad' +- , 'textureProjGradOffset' +-]) ++module.exports = function(array, f) { ++ fill(array, f) ++ return array ++} ++ ++},{"cwise/lib/wrapper":73}],182:[function(require,module,exports){ ++'use strict' ++ ++module.exports = gradient ++ ++var dup = require('dup') ++var cwiseCompiler = require('cwise-compiler') ++ ++var TEMPLATE_CACHE = {} ++var GRADIENT_CACHE = {} ++ ++var EmptyProc = { ++ body: "", ++ args: [], ++ thisVars: [], ++ localVars: [] ++} ++ ++var centralDiff = cwiseCompiler({ ++ args: [ 'array', 'array', 'array' ], ++ pre: EmptyProc, ++ post: EmptyProc, ++ body: { ++ args: [ { ++ name: 'out', ++ lvalue: true, ++ rvalue: false, ++ count: 1 ++ }, { ++ name: 'left', ++ lvalue: false, ++ rvalue: true, ++ count: 1 ++ }, { ++ name: 'right', ++ lvalue: false, ++ rvalue: true, ++ count: 1 ++ }], ++ body: "out=0.5*(left-right)", ++ thisVars: [], ++ localVars: [] ++ }, ++ funcName: 'cdiff' ++}) ++ ++var zeroOut = cwiseCompiler({ ++ args: [ 'array' ], ++ pre: EmptyProc, ++ post: EmptyProc, ++ body: { ++ args: [ { ++ name: 'out', ++ lvalue: true, ++ rvalue: false, ++ count: 1 ++ }], ++ body: "out=0", ++ thisVars: [], ++ localVars: [] ++ }, ++ funcName: 'zero' ++}) + +-},{"./builtins":196}],196:[function(require,module,exports){ +-module.exports = [ +- // Keep this list sorted +- 'abs' +- , 'acos' +- , 'all' +- , 'any' +- , 'asin' +- , 'atan' +- , 'ceil' +- , 'clamp' +- , 'cos' +- , 'cross' +- , 'dFdx' +- , 'dFdy' +- , 'degrees' +- , 'distance' +- , 'dot' +- , 'equal' +- , 'exp' +- , 'exp2' +- , 'faceforward' +- , 'floor' +- , 'fract' +- , 'gl_BackColor' +- , 'gl_BackLightModelProduct' +- , 'gl_BackLightProduct' +- , 'gl_BackMaterial' +- , 'gl_BackSecondaryColor' +- , 'gl_ClipPlane' +- , 'gl_ClipVertex' +- , 'gl_Color' +- , 'gl_DepthRange' +- , 'gl_DepthRangeParameters' +- , 'gl_EyePlaneQ' +- , 'gl_EyePlaneR' +- , 'gl_EyePlaneS' +- , 'gl_EyePlaneT' +- , 'gl_Fog' +- , 'gl_FogCoord' +- , 'gl_FogFragCoord' +- , 'gl_FogParameters' +- , 'gl_FragColor' +- , 'gl_FragCoord' +- , 'gl_FragData' +- , 'gl_FragDepth' +- , 'gl_FragDepthEXT' +- , 'gl_FrontColor' +- , 'gl_FrontFacing' +- , 'gl_FrontLightModelProduct' +- , 'gl_FrontLightProduct' +- , 'gl_FrontMaterial' +- , 'gl_FrontSecondaryColor' +- , 'gl_LightModel' +- , 'gl_LightModelParameters' +- , 'gl_LightModelProducts' +- , 'gl_LightProducts' +- , 'gl_LightSource' +- , 'gl_LightSourceParameters' +- , 'gl_MaterialParameters' +- , 'gl_MaxClipPlanes' +- , 'gl_MaxCombinedTextureImageUnits' +- , 'gl_MaxDrawBuffers' +- , 'gl_MaxFragmentUniformComponents' +- , 'gl_MaxLights' +- , 'gl_MaxTextureCoords' +- , 'gl_MaxTextureImageUnits' +- , 'gl_MaxTextureUnits' +- , 'gl_MaxVaryingFloats' +- , 'gl_MaxVertexAttribs' +- , 'gl_MaxVertexTextureImageUnits' +- , 'gl_MaxVertexUniformComponents' +- , 'gl_ModelViewMatrix' +- , 'gl_ModelViewMatrixInverse' +- , 'gl_ModelViewMatrixInverseTranspose' +- , 'gl_ModelViewMatrixTranspose' +- , 'gl_ModelViewProjectionMatrix' +- , 'gl_ModelViewProjectionMatrixInverse' +- , 'gl_ModelViewProjectionMatrixInverseTranspose' +- , 'gl_ModelViewProjectionMatrixTranspose' +- , 'gl_MultiTexCoord0' +- , 'gl_MultiTexCoord1' +- , 'gl_MultiTexCoord2' +- , 'gl_MultiTexCoord3' +- , 'gl_MultiTexCoord4' +- , 'gl_MultiTexCoord5' +- , 'gl_MultiTexCoord6' +- , 'gl_MultiTexCoord7' +- , 'gl_Normal' +- , 'gl_NormalMatrix' +- , 'gl_NormalScale' +- , 'gl_ObjectPlaneQ' +- , 'gl_ObjectPlaneR' +- , 'gl_ObjectPlaneS' +- , 'gl_ObjectPlaneT' +- , 'gl_Point' +- , 'gl_PointCoord' +- , 'gl_PointParameters' +- , 'gl_PointSize' +- , 'gl_Position' +- , 'gl_ProjectionMatrix' +- , 'gl_ProjectionMatrixInverse' +- , 'gl_ProjectionMatrixInverseTranspose' +- , 'gl_ProjectionMatrixTranspose' +- , 'gl_SecondaryColor' +- , 'gl_TexCoord' +- , 'gl_TextureEnvColor' +- , 'gl_TextureMatrix' +- , 'gl_TextureMatrixInverse' +- , 'gl_TextureMatrixInverseTranspose' +- , 'gl_TextureMatrixTranspose' +- , 'gl_Vertex' +- , 'greaterThan' +- , 'greaterThanEqual' +- , 'inversesqrt' +- , 'length' +- , 'lessThan' +- , 'lessThanEqual' +- , 'log' +- , 'log2' +- , 'matrixCompMult' +- , 'max' +- , 'min' +- , 'mix' +- , 'mod' +- , 'normalize' +- , 'not' +- , 'notEqual' +- , 'pow' +- , 'radians' +- , 'reflect' +- , 'refract' +- , 'sign' +- , 'sin' +- , 'smoothstep' +- , 'sqrt' +- , 'step' +- , 'tan' +- , 'texture2D' +- , 'texture2DLod' +- , 'texture2DProj' +- , 'texture2DProjLod' +- , 'textureCube' +- , 'textureCubeLod' +- , 'texture2DLodEXT' +- , 'texture2DProjLodEXT' +- , 'textureCubeLodEXT' +- , 'texture2DGradEXT' +- , 'texture2DProjGradEXT' +- , 'textureCubeGradEXT' +-] ++function generateTemplate(d) { ++ if(d in TEMPLATE_CACHE) { ++ return TEMPLATE_CACHE[d] ++ } ++ var code = [] ++ for(var i=0; i= 0) { ++ pickStr.push('0') ++ } else if(facet.indexOf(-(i+1)) >= 0) { ++ pickStr.push('s['+i+']-1') ++ } else { ++ pickStr.push('-1') ++ loStr.push('1') ++ hiStr.push('s['+i+']-2') ++ } ++ } ++ var boundStr = '.lo(' + loStr.join() + ').hi(' + hiStr.join() + ')' ++ if(loStr.length === 0) { ++ boundStr = '' ++ } ++ ++ if(cod > 0) { ++ code.push('if(1') ++ for(var i=0; i= 0 || facet.indexOf(-(i+1)) >= 0) { ++ continue ++ } ++ code.push('&&s[', i, ']>2') ++ } ++ code.push('){grad', cod, '(src.pick(', pickStr.join(), ')', boundStr) ++ for(var i=0; i= 0 || facet.indexOf(-(i+1)) >= 0) { ++ continue ++ } ++ code.push(',dst.pick(', pickStr.join(), ',', i, ')', boundStr) ++ } ++ code.push(');') ++ } + +- // future +- , 'asm' +- , 'class' +- , 'union' +- , 'enum' +- , 'typedef' +- , 'template' +- , 'this' +- , 'packed' +- , 'goto' +- , 'switch' +- , 'default' +- , 'inline' +- , 'noinline' +- , 'volatile' +- , 'public' +- , 'static' +- , 'extern' +- , 'external' +- , 'interface' +- , 'long' +- , 'short' +- , 'double' +- , 'half' +- , 'fixed' +- , 'unsigned' +- , 'input' +- , 'output' +- , 'hvec2' +- , 'hvec3' +- , 'hvec4' +- , 'dvec2' +- , 'dvec3' +- , 'dvec4' +- , 'fvec2' +- , 'fvec3' +- , 'fvec4' +- , 'sampler2DRect' +- , 'sampler3DRect' +- , 'sampler2DRectShadow' +- , 'sizeof' +- , 'cast' +- , 'namespace' +- , 'using' +-] ++ for(var i=0; i>=' +- , '++' +- , '--' +- , '<<' +- , '>>' +- , '<=' +- , '>=' +- , '==' +- , '!=' +- , '&&' +- , '||' +- , '+=' +- , '-=' +- , '*=' +- , '/=' +- , '%=' +- , '&=' +- , '^^' +- , '^=' +- , '|=' +- , '(' +- , ')' +- , '[' +- , ']' +- , '.' +- , '!' +- , '~' +- , '*' +- , '/' +- , '%' +- , '+' +- , '-' +- , '<' +- , '>' +- , '&' +- , '^' +- , '|' +- , '?' +- , ':' +- , '=' +- , ',' +- , ';' +- , '{' +- , '}' +-] ++ case 'clamp': ++ var cPickStr = pickStr.slice() ++ var dPickStr = pickStr.slice() ++ if(facet[i] < 0) { ++ cPickStr[bnd] = 's[' + bnd + ']-2' ++ } else { ++ dPickStr[bnd] = '1' ++ } ++ if(cod === 0) { ++ code.push('if(s[', bnd, ']>1){dst.set(', ++ pickStr.join(), ',', bnd, ',0.5*(src.get(', ++ cPickStr.join(), ')-src.get(', ++ dPickStr.join(), ')))}else{dst.set(', ++ pickStr.join(), ',', bnd, ',0)};') ++ } else { ++ code.push('if(s[', bnd, ']>1){diff(', outStr, ++ ',src.pick(', cPickStr.join(), ')', boundStr, ++ ',src.pick(', dPickStr.join(), ')', boundStr, ++ ');}else{zero(', outStr, ');};') ++ } ++ break ++ ++ case 'mirror': ++ if(cod === 0) { ++ code.push('dst.set(', pickStr.join(), ',', bnd, ',0);') ++ } else { ++ code.push('zero(', outStr, ');') ++ } ++ break + +-},{}],200:[function(require,module,exports){ +-var tokenize = require('./index') ++ case 'wrap': ++ var aPickStr = pickStr.slice() ++ var bPickStr = pickStr.slice() ++ if(facet[i] < 0) { ++ aPickStr[bnd] = 's[' + bnd + ']-2' ++ bPickStr[bnd] = '0' ++ ++ } else { ++ aPickStr[bnd] = 's[' + bnd + ']-1' ++ bPickStr[bnd] = '1' ++ } ++ if(cod === 0) { ++ code.push('if(s[', bnd, ']>2){dst.set(', ++ pickStr.join(), ',', bnd, ',0.5*(src.get(', ++ aPickStr.join(), ')-src.get(', ++ bPickStr.join(), ')))}else{dst.set(', ++ pickStr.join(), ',', bnd, ',0)};') ++ } else { ++ code.push('if(s[', bnd, ']>2){diff(', outStr, ++ ',src.pick(', aPickStr.join(), ')', boundStr, ++ ',src.pick(', bPickStr.join(), ')', boundStr, ++ ');}else{zero(', outStr, ');};') ++ } ++ break + +-module.exports = tokenizeString ++ default: ++ throw new Error('ndarray-gradient: Invalid boundary condition') ++ } ++ } + +-function tokenizeString(str, opt) { +- var generator = tokenize(opt) +- var tokens = [] ++ if(cod > 0) { ++ code.push('};') ++ } ++ } + +- tokens = tokens.concat(generator(str)) +- tokens = tokens.concat(generator(null)) ++ //Enumerate ridges, facets, etc. of hypercube ++ for(var i=0; i<(1< 0) { +- code.push(",") ++function fixup(x) { ++ if(!x) { ++ return EmptyProc ++ } ++ for(var i=0; i>", ++ rrshift: ">>>" ++} ++;(function(){ ++ for(var id in assign_ops) { ++ var op = assign_ops[id] ++ exports[id] = makeOp({ ++ args: ["array","array","array"], ++ body: {args:["a","b","c"], ++ body: "a=b"+op+"c"}, ++ funcName: id ++ }) ++ exports[id+"eq"] = makeOp({ ++ args: ["array","array"], ++ body: {args:["a","b"], ++ body:"a"+op+"=b"}, ++ rvalue: true, ++ funcName: id+"eq" ++ }) ++ exports[id+"s"] = makeOp({ ++ args: ["array", "array", "scalar"], ++ body: {args:["a","b","s"], ++ body:"a=b"+op+"s"}, ++ funcName: id+"s" ++ }) ++ exports[id+"seq"] = makeOp({ ++ args: ["array","scalar"], ++ body: {args:["a","s"], ++ body:"a"+op+"=s"}, ++ rvalue: true, ++ funcName: id+"seq" ++ }) + } +- this.orient = o ++})(); ++ ++var unary_ops = { ++ not: "!", ++ bnot: "~", ++ neg: "-", ++ recip: "1.0/" + } ++;(function(){ ++ for(var id in unary_ops) { ++ var op = unary_ops[id] ++ exports[id] = makeOp({ ++ args: ["array", "array"], ++ body: {args:["a","b"], ++ body:"a="+op+"b"}, ++ funcName: id ++ }) ++ exports[id+"eq"] = makeOp({ ++ args: ["array"], ++ body: {args:["a"], ++ body:"a="+op+"a"}, ++ rvalue: true, ++ count: 2, ++ funcName: id+"eq" ++ }) ++ } ++})(); + +-var proto = Triangulation.prototype ++var binary_ops = { ++ and: "&&", ++ or: "||", ++ eq: "===", ++ neq: "!==", ++ lt: "<", ++ gt: ">", ++ leq: "<=", ++ geq: ">=" ++} ++;(function() { ++ for(var id in binary_ops) { ++ var op = binary_ops[id] ++ exports[id] = makeOp({ ++ args: ["array","array","array"], ++ body: {args:["a", "b", "c"], ++ body:"a=b"+op+"c"}, ++ funcName: id ++ }) ++ exports[id+"s"] = makeOp({ ++ args: ["array","array","scalar"], ++ body: {args:["a", "b", "s"], ++ body:"a=b"+op+"s"}, ++ funcName: id+"s" ++ }) ++ exports[id+"eq"] = makeOp({ ++ args: ["array", "array"], ++ body: {args:["a", "b"], ++ body:"a=a"+op+"b"}, ++ rvalue:true, ++ count:2, ++ funcName: id+"eq" ++ }) ++ exports[id+"seq"] = makeOp({ ++ args: ["array", "scalar"], ++ body: {args:["a","s"], ++ body:"a=a"+op+"s"}, ++ rvalue:true, ++ count:2, ++ funcName: id+"seq" ++ }) ++ } ++})(); + +-//Degenerate situation where we are on boundary, but coplanar to face +-proto.handleBoundaryDegeneracy = function(cell, point) { +- var d = this.dimension +- var n = this.vertices.length - 1 +- var tuple = this.tuple +- var verts = this.vertices ++var math_unary = [ ++ "abs", ++ "acos", ++ "asin", ++ "atan", ++ "ceil", ++ "cos", ++ "exp", ++ "floor", ++ "log", ++ "round", ++ "sin", ++ "sqrt", ++ "tan" ++] ++;(function() { ++ for(var i=0; i 0) { +- cell = toVisit.pop() +- var cellVerts = cell.vertices +- var cellAdj = cell.adjacent +- for(var i=0; i<=d; ++i) { +- var neighbor = cellAdj[i] +- if(!neighbor.boundary || neighbor.lastVisited <= -n) { +- continue +- } +- var nv = neighbor.vertices +- for(var j=0; j<=d; ++j) { +- var vv = nv[j] +- if(vv < 0) { +- tuple[j] = point +- } else { +- tuple[j] = verts[vv] +- } +- } +- var o = this.orient() +- if(o > 0) { +- return neighbor +- } +- neighbor.lastVisited = -n +- if(o === 0) { +- toVisit.push(neighbor) +- } +- } ++var math_comm = [ ++ "max", ++ "min", ++ "atan2", ++ "pow" ++] ++;(function(){ ++ for(var i=0; i= n) { +- continue +- } +- var prev = tuple[i] +- tuple[i] = point +- var o = this.orient() +- tuple[i] = prev +- if(o < 0) { +- cell = neighbor +- continue outerLoop +- } else { +- if(!neighbor.boundary) { +- neighbor.lastVisited = n +- } else { +- neighbor.lastVisited = -n +- } +- } +- } +- return +- } ++exports.prod = compile({ ++ args:["array"], ++ pre: {args:[], localVars:[], thisVars:["this_s"], body:"this_s=1"}, ++ body: {args:[{name:"a", lvalue:false, rvalue:true, count:1}], body: "this_s*=a", localVars: [], thisVars: ["this_s"]}, ++ post: {args:[], localVars:[], thisVars:["this_s"], body:"return this_s"}, ++ funcName: "prod" ++}) + +- return cell +-} ++exports.norm2squared = compile({ ++ args:["array"], ++ pre: {args:[], localVars:[], thisVars:["this_s"], body:"this_s=0"}, ++ body: {args:[{name:"a", lvalue:false, rvalue:true, count:2}], body: "this_s+=a*a", localVars: [], thisVars: ["this_s"]}, ++ post: {args:[], localVars:[], thisVars:["this_s"], body:"return this_s"}, ++ funcName: "norm2squared" ++}) ++ ++exports.norm2 = compile({ ++ args:["array"], ++ pre: {args:[], localVars:[], thisVars:["this_s"], body:"this_s=0"}, ++ body: {args:[{name:"a", lvalue:false, rvalue:true, count:2}], body: "this_s+=a*a", localVars: [], thisVars: ["this_s"]}, ++ post: {args:[], localVars:[], thisVars:["this_s"], body:"return Math.sqrt(this_s)"}, ++ funcName: "norm2" ++}) ++ + +-proto.addPeaks = function(point, cell) { +- var n = this.vertices.length - 1 +- var d = this.dimension +- var verts = this.vertices +- var tuple = this.tuple +- var interior = this.interior +- var simplices = this.simplices ++exports.norminf = compile({ ++ args:["array"], ++ pre: {args:[], localVars:[], thisVars:["this_s"], body:"this_s=0"}, ++ body: {args:[{name:"a", lvalue:false, rvalue:true, count:4}], body:"if(-a>this_s){this_s=-a}else if(a>this_s){this_s=a}", localVars: [], thisVars: ["this_s"]}, ++ post: {args:[], localVars:[], thisVars:["this_s"], body:"return this_s"}, ++ funcName: "norminf" ++}) + +- //Walking finished at boundary, time to add peaks +- var tovisit = [ cell ] ++exports.norm1 = compile({ ++ args:["array"], ++ pre: {args:[], localVars:[], thisVars:["this_s"], body:"this_s=0"}, ++ body: {args:[{name:"a", lvalue:false, rvalue:true, count:3}], body: "this_s+=a<0?-a:a", localVars: [], thisVars: ["this_s"]}, ++ post: {args:[], localVars:[], thisVars:["this_s"], body:"return this_s"}, ++ funcName: "norm1" ++}) + +- //Stretch initial boundary cell into a peak +- cell.lastVisited = n +- cell.vertices[cell.vertices.indexOf(-1)] = n +- cell.boundary = false +- interior.push(cell) ++exports.sup = compile({ ++ args: [ "array" ], ++ pre: ++ { body: "this_h=-Infinity", ++ args: [], ++ thisVars: [ "this_h" ], ++ localVars: [] }, ++ body: ++ { body: "if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_", ++ args: [{"name":"_inline_1_arg0_","lvalue":false,"rvalue":true,"count":2} ], ++ thisVars: [ "this_h" ], ++ localVars: [] }, ++ post: ++ { body: "return this_h", ++ args: [], ++ thisVars: [ "this_h" ], ++ localVars: [] } ++ }) + +- //Record a list of all new boundaries created by added peaks so we can glue them together when we are all done +- var glueFacets = [] ++exports.inf = compile({ ++ args: [ "array" ], ++ pre: ++ { body: "this_h=Infinity", ++ args: [], ++ thisVars: [ "this_h" ], ++ localVars: [] }, ++ body: ++ { body: "if(_inline_1_arg0_ 0) { +- //Pop off peak and walk over adjacent cells +- var cell = tovisit.pop() +- var cellVerts = cell.vertices +- var cellAdj = cell.adjacent +- var indexOfN = cellVerts.indexOf(n) +- if(indexOfN < 0) { +- continue +- } ++exports.argmin = compile({ ++ args:["index","array","shape"], ++ pre:{ ++ body:"{this_v=Infinity;this_i=_inline_0_arg2_.slice(0)}", ++ args:[ ++ {name:"_inline_0_arg0_",lvalue:false,rvalue:false,count:0}, ++ {name:"_inline_0_arg1_",lvalue:false,rvalue:false,count:0}, ++ {name:"_inline_0_arg2_",lvalue:false,rvalue:true,count:1} ++ ], ++ thisVars:["this_i","this_v"], ++ localVars:[]}, ++ body:{ ++ body:"{if(_inline_1_arg1_this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}", ++ args:[ ++ {name:"_inline_1_arg0_",lvalue:false,rvalue:true,count:2}, ++ {name:"_inline_1_arg1_",lvalue:false,rvalue:true,count:2}], ++ thisVars:["this_i","this_v"], ++ localVars:["_inline_1_k"]}, ++ post:{ ++ body:"{return this_i}", ++ args:[], ++ thisVars:["this_i"], ++ localVars:[]} ++}) + +- //For each boundary neighbor of the cell +- var neighbor = cellAdj[i] +- if(!neighbor.boundary || neighbor.lastVisited >= n) { +- continue +- } ++exports.random = makeOp({ ++ args: ["array"], ++ pre: {args:[], body:"this_f=Math.random", thisVars:["this_f"]}, ++ body: {args: ["a"], body:"a=this_f()", thisVars:["this_f"]}, ++ funcName: "random" ++}) + +- var nv = neighbor.vertices ++exports.assign = makeOp({ ++ args:["array", "array"], ++ body: {args:["a", "b"], body:"a=b"}, ++ funcName: "assign" }) + +- //Test if neighbor is a peak +- if(neighbor.lastVisited !== -n) { +- //Compute orientation of p relative to each boundary peak +- var indexOfNeg1 = 0 +- for(var j=0; j<=d; ++j) { +- if(nv[j] < 0) { +- indexOfNeg1 = j +- tuple[j] = point +- } else { +- tuple[j] = verts[nv[j]] +- } +- } +- var o = this.orient() ++exports.assigns = makeOp({ ++ args:["array", "scalar"], ++ body: {args:["a", "b"], body:"a=b"}, ++ funcName: "assigns" }) + +- //Test if neighbor cell is also a peak +- if(o > 0) { +- nv[indexOfNeg1] = n +- neighbor.boundary = false +- interior.push(neighbor) +- tovisit.push(neighbor) +- neighbor.lastVisited = n +- continue +- } else { +- neighbor.lastVisited = -n +- } +- } + +- var na = neighbor.adjacent ++exports.equals = compile({ ++ args:["array", "array"], ++ pre: EmptyProc, ++ body: {args:[{name:"x", lvalue:false, rvalue:true, count:1}, ++ {name:"y", lvalue:false, rvalue:true, count:1}], ++ body: "if(x!==y){return false}", ++ localVars: [], ++ thisVars: []}, ++ post: {args:[], localVars:[], thisVars:[], body:"return true"}, ++ funcName: "equals" ++}) + +- //Otherwise, replace neighbor with new face +- var vverts = cellVerts.slice() +- var vadj = cellAdj.slice() +- var ncell = new Simplex(vverts, vadj, true) +- simplices.push(ncell) + +- //Connect to neighbor +- var opposite = na.indexOf(cell) +- if(opposite < 0) { +- continue +- } +- na[opposite] = ncell +- vadj[indexOfN] = neighbor + +- //Connect to cell +- vverts[i] = -1 +- vadj[i] = cell +- cellAdj[i] = ncell ++},{"cwise-compiler":70}],186:[function(require,module,exports){ ++"use strict" + +- //Flip facet +- ncell.flip() ++var ndarray = require("ndarray") ++var do_convert = require("./doConvert.js") + +- //Add to glue list +- for(var j=0; j<=d; ++j) { +- var uu = vverts[j] +- if(uu < 0 || uu === n) { +- continue +- } +- var nface = new Array(d-1) +- var nptr = 0 +- for(var k=0; k<=d; ++k) { +- var vv = vverts[k] +- if(vv < 0 || k === j) { +- continue +- } +- nface[nptr++] = vv +- } +- glueFacets.push(new GlueFacet(nface, ncell, j)) +- } +- } ++module.exports = function convert(arr, result) { ++ var shape = [], c = arr, sz = 1 ++ while(Array.isArray(c)) { ++ shape.push(c.length) ++ sz *= c.length ++ c = c[0] + } +- +- //Glue boundary facets together +- glueFacets.sort(compareGlue) +- +- for(var i=0; i+1= 0) { +- bcell[ptr++] = cv[j] +- } else { +- parity = j&1 +- } +- } +- if(parity === (d&1)) { +- var t = bcell[0] +- bcell[0] = bcell[1] +- bcell[1] = t +- } +- boundary.push(bcell) +- } ++function getMallocFree(dtype) { ++ switch(dtype) { ++ case "uint8": ++ return [pool.mallocUint8, pool.freeUint8] ++ case "uint16": ++ return [pool.mallocUint16, pool.freeUint16] ++ case "uint32": ++ return [pool.mallocUint32, pool.freeUint32] ++ case "int8": ++ return [pool.mallocInt8, pool.freeInt8] ++ case "int16": ++ return [pool.mallocInt16, pool.freeInt16] ++ case "int32": ++ return [pool.mallocInt32, pool.freeInt32] ++ case "float32": ++ return [pool.mallocFloat, pool.freeFloat] ++ case "float64": ++ return [pool.mallocDouble, pool.freeDouble] ++ default: ++ return null + } +- return boundary + } + +-function incrementalConvexHull(points, randomSearch) { +- var n = points.length +- if(n === 0) { +- throw new Error("Must have at least d+1 points") ++function shapeArgs(dimension) { ++ var args = [] ++ for(var i=0; i 1) { ++ var scratch_shape = [] ++ for(var i=1; i 1) { ++ ++ //Copy data into scratch ++ code.push("dptr=0;sptr=ptr") ++ for(var i=order.length-1; i>=0; --i) { ++ var j = order[i] ++ if(j === 0) { ++ continue ++ } ++ code.push(["for(i",j,"=0;i",j,"left){", ++ "dptr=0", ++ "sptr=cptr-s0") ++ for(var i=1; ib){break __l}"].join("")) ++ for(var i=order.length-1; i>=1; --i) { ++ code.push( ++ "sptr+=e"+i, ++ "dptr+=f"+i, ++ "}") ++ } ++ ++ //Copy data back ++ code.push("dptr=cptr;sptr=cptr-s0") ++ for(var i=order.length-1; i>=0; --i) { ++ var j = order[i] ++ if(j === 0) { + continue + } +- for(var k=0; k<=d; ++k) { +- if(boundary[k].vertices.indexOf(v) < 0) { +- adj[j] = boundary[k] +- } ++ code.push(["for(i",j,"=0;i",j,"=0; --i) { ++ var j = order[i] ++ if(j === 0) { ++ continue ++ } ++ code.push(["for(i",j,"=0;i",j,"left)&&("+dataRead("cptr-s0")+">scratch)){", ++ dataWrite("cptr", dataRead("cptr-s0")), ++ "cptr-=s0", ++ "}", ++ dataWrite("cptr", "scratch")) + } + +- //Extract boundary cells +- return triangles.boundary() +-} +-},{"robust-orientation":225,"simplicial-complex":204}],202:[function(require,module,exports){ +-arguments[4][38][0].apply(exports,arguments) +-},{"dup":38}],203:[function(require,module,exports){ +-arguments[4][85][0].apply(exports,arguments) +-},{"dup":85}],204:[function(require,module,exports){ +-"use strict"; "use restrict"; +- +-var bits = require("bit-twiddle") +- , UnionFind = require("union-find") +- +-//Returns the dimension of a cell complex +-function dimension(cells) { +- var d = 0 +- , max = Math.max +- for(var i=0, il=cells.length; i 1 && allocator) { ++ code.push("free(scratch)") ++ } ++ code.push("} return " + funcName) ++ ++ //Compile and link function ++ if(allocator) { ++ var result = new Function("malloc", "free", code.join("\n")) ++ return result(allocator[0], allocator[1]) ++ } else { ++ var result = new Function(code.join("\n")) ++ return result() + } +- return d-1 + } +-exports.dimension = dimension + +-//Counts the number of vertices in faces +-function countVertices(cells) { +- var vc = -1 +- , max = Math.max +- for(var i=0, il=cells.length; i>1", ++ "index2=index3-sixth", ++ "index4=index3+sixth", ++ "el1=index1", ++ "el2=index2", ++ "el3=index3", ++ "el4=index4", ++ "el5=index5", ++ "less=left+1", ++ "great=right-1", ++ "pivots_are_equal=true", ++ "tmp", ++ "tmp0", ++ "x", ++ "y", ++ "z", ++ "k", ++ "ptr0", ++ "ptr1", ++ "ptr2", ++ "comp_pivot1=0", ++ "comp_pivot2=0", ++ "comp=0" ++ ] ++ ++ if(order.length > 1) { ++ var ele_size = [] ++ for(var i=1; i=0; --i) { ++ var j = order[i] ++ if(j === 0) { ++ continue + } +- var l0 = min(a[0], a[1]) +- , m0 = min(b[0], b[1]) +- , d = min(l0, a[2]) - min(m0, b[2]) +- if(d) { +- return d ++ code.push(["for(i",j,"=0;i",j," 1) { ++ for(var i=0; i1) { ++ code.push("ptr_shift+=d"+j) ++ } else { ++ code.push("ptr0+=d"+j) ++ } ++ code.push("}") ++ } + } +-} +-exports.compareCells = compareCells +- +-function compareZipped(a, b) { +- return compareCells(a[0], b[0]) +-} +- +-//Puts a cell complex into normal order for the purposes of findCell queries +-function normalize(cells, attr) { +- if(attr) { +- var len = cells.length +- var zipped = new Array(len) +- for(var i=0; i 1) { ++ for(var i=0; i=1; --i) { ++ if(usePivot) { ++ code.push("pivot_ptr+=f"+i) ++ } ++ if(ptrs.length > 1) { ++ code.push("ptr_shift+=e"+i) ++ } else { ++ code.push("ptr0+=e"+i) ++ } ++ code.push("}") + } +- return cells +- } else { +- cells.sort(compareCells) +- return cells + } +-} +-exports.normalize = normalize +- +-//Removes all duplicate cells in the complex +-function unique(cells) { +- if(cells.length === 0) { +- return [] ++ ++ function cleanUp() { ++ if(order.length > 1 && allocator) { ++ code.push("free(pivot1)", "free(pivot2)") ++ } + } +- var ptr = 1 +- , len = cells.length +- for(var i=1; i 1) { ++ var lbl = "__l" + (++labelCounter) ++ lexicoLoop(lbl, [a, b], false, [ ++ "comp=",dataRead("ptr0"),"-",dataRead("ptr1"),"\n", ++ "if(comp>0){tmp0=", a, ";",a,"=",b,";", b,"=tmp0;break ", lbl,"}\n", ++ "if(comp<0){break ", lbl, "}" ++ ].join("")) ++ } else { ++ code.push(["if(", dataRead(toPointer(a)), ">", dataRead(toPointer(b)), "){tmp0=", a, ";",a,"=",b,";", b,"=tmp0}"].join("")) + } + } +- cells.length = ptr +- return cells +-} +-exports.unique = unique; ++ ++ compareSwap(1, 2) ++ compareSwap(4, 5) ++ compareSwap(1, 3) ++ compareSwap(2, 3) ++ compareSwap(1, 4) ++ compareSwap(3, 4) ++ compareSwap(2, 5) ++ compareSwap(2, 3) ++ compareSwap(4, 5) ++ ++ if(order.length > 1) { ++ cacheLoop(["el1", "el2", "el3", "el4", "el5", "index1", "index3", "index5"], true, [ ++ "pivot1[pivot_ptr]=",dataRead("ptr1"),"\n", ++ "pivot2[pivot_ptr]=",dataRead("ptr3"),"\n", ++ "pivots_are_equal=pivots_are_equal&&(pivot1[pivot_ptr]===pivot2[pivot_ptr])\n", ++ "x=",dataRead("ptr0"),"\n", ++ "y=",dataRead("ptr2"),"\n", ++ "z=",dataRead("ptr4"),"\n", ++ dataWrite("ptr5", "x"),"\n", ++ dataWrite("ptr6", "y"),"\n", ++ dataWrite("ptr7", "z") ++ ].join("")) ++ } else { ++ code.push([ ++ "pivot1=", dataRead(toPointer("el2")), "\n", ++ "pivot2=", dataRead(toPointer("el4")), "\n", ++ "pivots_are_equal=pivot1===pivot2\n", ++ "x=", dataRead(toPointer("el1")), "\n", ++ "y=", dataRead(toPointer("el3")), "\n", ++ "z=", dataRead(toPointer("el5")), "\n", ++ dataWrite(toPointer("index1"), "x"), "\n", ++ dataWrite(toPointer("index3"), "y"), "\n", ++ dataWrite(toPointer("index5"), "z") ++ ].join("")) ++ } ++ + +-//Finds a cell in a normalized cell complex +-function findCell(cells, c) { +- var lo = 0 +- , hi = cells.length-1 +- , r = -1 +- while (lo <= hi) { +- var mid = (lo + hi) >> 1 +- , s = compareCells(cells[mid], c) +- if(s <= 0) { +- if(s === 0) { +- r = mid +- } +- lo = mid + 1 +- } else if(s > 0) { +- hi = mid - 1 ++ function moveElement(dst, src) { ++ if(order.length > 1) { ++ cacheLoop([dst, src], false, ++ dataWrite("ptr0", dataRead("ptr1")) ++ ) ++ } else { ++ code.push(dataWrite(toPointer(dst), dataRead(toPointer(src)))) + } + } +- return r +-} +-exports.findCell = findCell; +- +-//Builds an index for an n-cell. This is more general than dual, but less efficient +-function incidence(from_cells, to_cells) { +- var index = new Array(from_cells.length) +- for(var i=0, il=index.length; i= from_cells.length || compareCells(from_cells[idx], b) !== 0) { +- break +- } +- } ++ ++ moveElement("index2", "left") ++ moveElement("index4", "right") ++ ++ function comparePivot(result, ptr, n) { ++ if(order.length > 1) { ++ var lbl = "__l" + (++labelCounter) ++ lexicoLoop(lbl, [ptr], true, [ ++ result,"=",dataRead("ptr0"),"-pivot",n,"[pivot_ptr]\n", ++ "if(",result,"!==0){break ", lbl, "}" ++ ].join("")) ++ } else { ++ code.push([result,"=", dataRead(toPointer(ptr)), "-pivot", n].join("")) + } + } +- return index +-} +-exports.incidence = incidence +- +-//Computes the dual of the mesh. This is basically an optimized version of buildIndex for the situation where from_cells is just the list of vertices +-function dual(cells, vertex_count) { +- if(!vertex_count) { +- return incidence(unique(skeleton(cells, 0)), cells, 0) +- } +- var res = new Array(vertex_count) +- for(var i=0; i 1) { ++ cacheLoop([a,b],false,[ ++ "tmp=",dataRead("ptr0"),"\n", ++ dataWrite("ptr0", dataRead("ptr1")),"\n", ++ dataWrite("ptr1", "tmp") ++ ].join("")) ++ } else { ++ code.push([ ++ "ptr0=",toPointer(a),"\n", ++ "ptr1=",toPointer(b),"\n", ++ "tmp=",dataRead("ptr0"),"\n", ++ dataWrite("ptr0", dataRead("ptr1")),"\n", ++ dataWrite("ptr1", "tmp") ++ ].join("")) + } + } +- return res +-} +-exports.dual = dual +- +-//Enumerates all cells in the complex +-function explode(cells) { +- var result = [] +- for(var i=0, il=cells.length; i>> k) & 1) { +- b.push(c[k]) +- } +- } +- result.push(b) ++ ++ function tripleSwap(k, less, great) { ++ if(order.length > 1) { ++ cacheLoop([k,less,great], false, [ ++ "tmp=",dataRead("ptr0"),"\n", ++ dataWrite("ptr0", dataRead("ptr1")),"\n", ++ dataWrite("ptr1", dataRead("ptr2")),"\n", ++ dataWrite("ptr2", "tmp") ++ ].join("")) ++ code.push("++"+less, "--"+great) ++ } else { ++ code.push([ ++ "ptr0=",toPointer(k),"\n", ++ "ptr1=",toPointer(less),"\n", ++ "ptr2=",toPointer(great),"\n", ++ "++",less,"\n", ++ "--",great,"\n", ++ "tmp=", dataRead("ptr0"), "\n", ++ dataWrite("ptr0", dataRead("ptr1")), "\n", ++ dataWrite("ptr1", dataRead("ptr2")), "\n", ++ dataWrite("ptr2", "tmp") ++ ].join("")) + } + } +- return normalize(result) +-} +-exports.explode = explode +- +-//Enumerates all of the n-cells of a cell complex +-function skeleton(cells, n) { +- if(n < 0) { +- return [] ++ ++ function swapAndDecrement(k, great) { ++ swapElements(k, great) ++ code.push("--"+great) + } +- var result = [] +- , k0 = (1<<(n+1))-1 +- for(var i=0; i0){") ++ code.push("great--") ++ code.push("}else if(comp<0){") ++ tripleSwap("k", "less", "great") ++ code.push("break") ++ code.push("}else{") ++ swapAndDecrement("k", "great") ++ code.push("break") ++ code.push("}") ++ code.push("}") ++ code.push("}") ++ code.push("}") ++ code.push("}else{") ++ //Pivots not equal case ++ code.push("for(k=less;k<=great;++k){") ++ comparePivot("comp_pivot1", "k", 1) ++ code.push("if(comp_pivot1<0){") ++ code.push("if(k!==less){") ++ swapElements("k", "less") ++ code.push("}") ++ code.push("++less") ++ code.push("}else{") ++ comparePivot("comp_pivot2", "k", 2) ++ code.push("if(comp_pivot2>0){") ++ code.push("while(true){") ++ comparePivot("comp", "great", 2) ++ code.push("if(comp>0){") ++ code.push("if(--great1) { ++ cacheLoop([mem_dest, pivot_dest], true, [ ++ dataWrite("ptr0", dataRead("ptr1")), "\n", ++ dataWrite("ptr1", ["pivot",pivot,"[pivot_ptr]"].join("")) ++ ].join("")) ++ } else { ++ code.push( ++ dataWrite(toPointer(mem_dest), dataRead(toPointer(pivot_dest))), ++ dataWrite(toPointer(pivot_dest), "pivot"+pivot)) + } + } +- return normalize(result) +-} +-exports.skeleton = skeleton; ++ ++ storePivot("left", "(less-1)", 1) ++ storePivot("right", "(great+1)", 2) + +-//Computes the boundary of all cells, does not remove duplicates +-function boundary(cells) { +- var res = [] +- for(var i=0,il=cells.length; i 1) { ++ code.push(["__l",++labelCounter,":while(true){"].join("")) ++ cacheLoop([ptr], true, [ ++ "if(", dataRead("ptr0"), "!==pivot", pivot, "[pivot_ptr]){break __l", labelCounter, "}" ++ ].join("")) ++ code.push(body, "}") ++ } else { ++ code.push(["while(", dataRead(toPointer(ptr)), "===pivot", pivot, "){", body, "}"].join("")) + } + } +- return normalize(res) ++ ++ //Check bounds ++ code.push("if(lessindex5){") ++ ++ walkPointer("less", 1, "++less") ++ walkPointer("great", 2, "--great") ++ ++ code.push("for(k=less;k<=great;++k){") ++ comparePivot("comp_pivot1", "k", 1) ++ code.push("if(comp_pivot1===0){") ++ code.push("if(k!==less){") ++ swapElements("k", "less") ++ code.push("}") ++ code.push("++less") ++ code.push("}else{") ++ comparePivot("comp_pivot2", "k", 2) ++ code.push("if(comp_pivot2===0){") ++ code.push("while(true){") ++ comparePivot("comp", "great", 2) ++ code.push("if(comp===0){") ++ code.push("if(--great 1 && allocator) { ++ var compiled = new Function("insertionSort", "malloc", "free", code.join("\n")) ++ return compiled(insertionSort, allocator[0], allocator[1]) ++ } ++ var compiled = new Function("insertionSort", code.join("\n")) ++ return compiled(insertionSort) + } +-exports.boundary = boundary; + +-//Computes connected components for a dense cell complex +-function connectedComponents_dense(cells, vertex_count) { +- var labels = new UnionFind(vertex_count) +- for(var i=0; i 0) { ++ vars.push(["d",j,"=s",j,"-d",p,"*n",p].join("")) ++ } else { ++ vars.push(["d",j,"=s",j].join("")) + } ++ p = j + } +- } +- var components = [] +- , component_labels = labels.ranks +- for(var i=0; i 0) { ++ vars.push(["e",k,"=s",k,"-e",q,"*n",q, ++ ",f",k,"=",scratch_stride[k],"-f",q,"*n",q].join("")) ++ } else { ++ vars.push(["e",k,"=s",k,",f",k,"=",scratch_stride[k]].join("")) ++ } ++ q = k + } + } +- return components +-} +- +-//Computes connected components for a cell complex +-function connectedComponents(cells, vertex_count) { +- if(vertex_count) { +- return connectedComponents_dense(cells, vertex_count) +- } +- return connectedComponents_sparse(cells) ++ ++ //Declare local variables ++ code.push("var " + vars.join(",")) ++ ++ //Create arguments for subroutine ++ var sortArgs = ["0", "n0-1", "data", "offset"].concat(shapeArgs(order.length)) ++ ++ //Call main sorting routine ++ code.push([ ++ "if(n0<=",INSERTION_SORT_THRESHOLD,"){", ++ "insertionSort(", sortArgs.join(","), ")}else{", ++ "quickSort(", sortArgs.join(","), ++ ")}" ++ ].join("")) ++ ++ //Return ++ code.push("}return " + funcName) ++ ++ //Link everything together ++ var result = new Function("insertionSort", "quickSort", code.join("\n")) ++ var insertionSort = createInsertionSort(order, dtype) ++ var quickSort = createQuickSort(order, dtype, insertionSort) ++ return result(insertionSort, quickSort) + } +-exports.connectedComponents = connectedComponents + +-},{"bit-twiddle":202,"union-find":203}],205:[function(require,module,exports){ ++module.exports = compileSort ++},{"typedarray-pool":246}],189:[function(require,module,exports){ + "use strict" + +-function iota(n) { +- var result = new Array(n) +- for(var i=0; i +- * License: MIT +- * +- * `npm install is-buffer` +- */ ++module.exports = sort ++},{"./lib/compile_sort.js":188}],190:[function(require,module,exports){ ++'use strict' + +-module.exports = function (obj) { +- return !!(obj != null && +- (obj._isBuffer || // For Safari 5-7 (missing Object.prototype.constructor) +- (obj.constructor && +- typeof obj.constructor.isBuffer === 'function' && +- obj.constructor.isBuffer(obj)) +- )) ++var interp = require('ndarray-linear-interpolate') ++ ++ ++var do_warp = require('cwise/lib/wrapper')({"args":["index","array","scalar","scalar","scalar"],"pre":{"body":"{this_warped=new Array(_inline_33_arg4_)}","args":[{"name":"_inline_33_arg0_","lvalue":false,"rvalue":false,"count":0},{"name":"_inline_33_arg1_","lvalue":false,"rvalue":false,"count":0},{"name":"_inline_33_arg2_","lvalue":false,"rvalue":false,"count":0},{"name":"_inline_33_arg3_","lvalue":false,"rvalue":false,"count":0},{"name":"_inline_33_arg4_","lvalue":false,"rvalue":true,"count":1}],"thisVars":["this_warped"],"localVars":[]},"body":{"body":"{_inline_34_arg2_(this_warped,_inline_34_arg0_),_inline_34_arg1_=_inline_34_arg3_.apply(void 0,this_warped)}","args":[{"name":"_inline_34_arg0_","lvalue":false,"rvalue":true,"count":1},{"name":"_inline_34_arg1_","lvalue":true,"rvalue":false,"count":1},{"name":"_inline_34_arg2_","lvalue":false,"rvalue":true,"count":1},{"name":"_inline_34_arg3_","lvalue":false,"rvalue":true,"count":1},{"name":"_inline_34_arg4_","lvalue":false,"rvalue":false,"count":0}],"thisVars":["this_warped"],"localVars":[]},"post":{"body":"{}","args":[],"thisVars":[],"localVars":[]},"debug":false,"funcName":"warpND","blockSize":64}) ++ ++var do_warp_1 = require('cwise/lib/wrapper')({"args":["index","array","scalar","scalar","scalar"],"pre":{"body":"{this_warped=[0]}","args":[],"thisVars":["this_warped"],"localVars":[]},"body":{"body":"{_inline_37_arg2_(this_warped,_inline_37_arg0_),_inline_37_arg1_=_inline_37_arg3_(_inline_37_arg4_,this_warped[0])}","args":[{"name":"_inline_37_arg0_","lvalue":false,"rvalue":true,"count":1},{"name":"_inline_37_arg1_","lvalue":true,"rvalue":false,"count":1},{"name":"_inline_37_arg2_","lvalue":false,"rvalue":true,"count":1},{"name":"_inline_37_arg3_","lvalue":false,"rvalue":true,"count":1},{"name":"_inline_37_arg4_","lvalue":false,"rvalue":true,"count":1}],"thisVars":["this_warped"],"localVars":[]},"post":{"body":"{}","args":[],"thisVars":[],"localVars":[]},"debug":false,"funcName":"warp1D","blockSize":64}) ++ ++var do_warp_2 = require('cwise/lib/wrapper')({"args":["index","array","scalar","scalar","scalar"],"pre":{"body":"{this_warped=[0,0]}","args":[],"thisVars":["this_warped"],"localVars":[]},"body":{"body":"{_inline_40_arg2_(this_warped,_inline_40_arg0_),_inline_40_arg1_=_inline_40_arg3_(_inline_40_arg4_,this_warped[0],this_warped[1])}","args":[{"name":"_inline_40_arg0_","lvalue":false,"rvalue":true,"count":1},{"name":"_inline_40_arg1_","lvalue":true,"rvalue":false,"count":1},{"name":"_inline_40_arg2_","lvalue":false,"rvalue":true,"count":1},{"name":"_inline_40_arg3_","lvalue":false,"rvalue":true,"count":1},{"name":"_inline_40_arg4_","lvalue":false,"rvalue":true,"count":1}],"thisVars":["this_warped"],"localVars":[]},"post":{"body":"{}","args":[],"thisVars":[],"localVars":[]},"debug":false,"funcName":"warp2D","blockSize":64}) ++ ++var do_warp_3 = require('cwise/lib/wrapper')({"args":["index","array","scalar","scalar","scalar"],"pre":{"body":"{this_warped=[0,0,0]}","args":[],"thisVars":["this_warped"],"localVars":[]},"body":{"body":"{_inline_43_arg2_(this_warped,_inline_43_arg0_),_inline_43_arg1_=_inline_43_arg3_(_inline_43_arg4_,this_warped[0],this_warped[1],this_warped[2])}","args":[{"name":"_inline_43_arg0_","lvalue":false,"rvalue":true,"count":1},{"name":"_inline_43_arg1_","lvalue":true,"rvalue":false,"count":1},{"name":"_inline_43_arg2_","lvalue":false,"rvalue":true,"count":1},{"name":"_inline_43_arg3_","lvalue":false,"rvalue":true,"count":1},{"name":"_inline_43_arg4_","lvalue":false,"rvalue":true,"count":1}],"thisVars":["this_warped"],"localVars":[]},"post":{"body":"{}","args":[],"thisVars":[],"localVars":[]},"debug":false,"funcName":"warp3D","blockSize":64}) ++ ++module.exports = function warp(dest, src, func) { ++ switch(src.shape.length) { ++ case 1: ++ do_warp_1(dest, func, interp.d1, src) ++ break ++ case 2: ++ do_warp_2(dest, func, interp.d2, src) ++ break ++ case 3: ++ do_warp_3(dest, func, interp.d3, src) ++ break ++ default: ++ do_warp(dest, func, interp.bind(undefined, src), src.shape.length) ++ break ++ } ++ return dest + } + +-},{}],207:[function(require,module,exports){ +-'use strict' +- +-module.exports = mouseListen +- +-var mouse = require('mouse-event') ++},{"cwise/lib/wrapper":73,"ndarray-linear-interpolate":184}],191:[function(require,module,exports){ ++var iota = require("iota-array") ++var isBuffer = require("is-buffer") + +-function mouseListen(element, callback) { ++var hasTypedArrays = ((typeof Float64Array) !== "undefined") + +- if(!callback) { +- callback = element +- element = window +- } ++function compare1st(a, b) { ++ return a[0] - b[0] ++} + +- var buttonState = 0 +- var x = 0 +- var y = 0 +- var mods = { +- shift: false, +- alt: false, +- control: false, +- meta: false ++function order() { ++ var stride = this.stride ++ var terms = new Array(stride.length) ++ var i ++ for(i=0; iMath.abs(this.stride[1]))?[1,0]:[0,1]}})") ++ } else if(dimension === 3) { ++ code.push( ++"var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);\ ++if(s0>s1){\ ++if(s1>s2){\ ++return [2,1,0];\ ++}else if(s0>s2){\ ++return [1,2,0];\ ++}else{\ ++return [1,0,2];\ ++}\ ++}else if(s0>s2){\ ++return [2,0,1];\ ++}else if(s2>s1){\ ++return [0,1,2];\ ++}else{\ ++return [0,2,1];\ ++}}})") ++ } + } else { +- handleEvent(buttonState, ev) ++ code.push("ORDER})") + } + } + +- function handleMouseDown(ev) { +- handleEvent(buttonState | mouse.buttons(ev), ev) ++ //view.set(i0, ..., v): ++ code.push( ++"proto.set=function "+className+"_set("+args.join(",")+",v){") ++ if(useGetters) { ++ code.push("return this.data.set("+index_str+",v)}") ++ } else { ++ code.push("return this.data["+index_str+"]=v}") + } + +- function handleMouseUp(ev) { +- handleEvent(buttonState & ~mouse.buttons(ev), ev) ++ //view.get(i0, ...): ++ code.push("proto.get=function "+className+"_get("+args.join(",")+"){") ++ if(useGetters) { ++ code.push("return this.data.get("+index_str+")}") ++ } else { ++ code.push("return this.data["+index_str+"]}") + } + +- function attachListeners() { +- if(attached) { +- return +- } +- attached = true ++ //view.index: ++ code.push( ++ "proto.index=function "+className+"_index(", args.join(), "){return "+index_str+"}") + +- element.addEventListener('mousemove', handleMouseMove) ++ //view.hi(): ++ code.push("proto.hi=function "+className+"_hi("+args.join(",")+"){return new "+className+"(this.data,"+ ++ indices.map(function(i) { ++ return ["(typeof i",i,"!=='number'||i",i,"<0)?this.shape[", i, "]:i", i,"|0"].join("") ++ }).join(",")+","+ ++ indices.map(function(i) { ++ return "this.stride["+i + "]" ++ }).join(",")+",this.offset)}") + +- element.addEventListener('mousedown', handleMouseDown) ++ //view.lo(): ++ var a_vars = indices.map(function(i) { return "a"+i+"=this.shape["+i+"]" }) ++ var c_vars = indices.map(function(i) { return "c"+i+"=this.stride["+i+"]" }) ++ code.push("proto.lo=function "+className+"_lo("+args.join(",")+"){var b=this.offset,d=0,"+a_vars.join(",")+","+c_vars.join(",")) ++ for(var i=0; i=0){\ ++d=i"+i+"|0;\ ++b+=c"+i+"*d;\ ++a"+i+"-=d}") ++ } ++ code.push("return new "+className+"(this.data,"+ ++ indices.map(function(i) { ++ return "a"+i ++ }).join(",")+","+ ++ indices.map(function(i) { ++ return "c"+i ++ }).join(",")+",b)}") + +- element.addEventListener('mouseup', handleMouseUp) ++ //view.step(): ++ code.push("proto.step=function "+className+"_step("+args.join(",")+"){var "+ ++ indices.map(function(i) { ++ return "a"+i+"=this.shape["+i+"]" ++ }).join(",")+","+ ++ indices.map(function(i) { ++ return "b"+i+"=this.stride["+i+"]" ++ }).join(",")+",c=this.offset,d=0,ceil=Math.ceil") ++ for(var i=0; i=0){c=(c+this.stride["+i+"]*i"+i+")|0}else{a.push(this.shape["+i+"]);b.push(this.stride["+i+"])}") ++ } ++ code.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}") + +- element.addEventListener('keyup', handleMods) +- element.addEventListener('keydown', handleMods) +- element.addEventListener('keypress', handleMods) ++ //Add return statement ++ code.push("return function construct_"+className+"(data,shape,stride,offset){return new "+className+"(data,"+ ++ indices.map(function(i) { ++ return "shape["+i+"]" ++ }).join(",")+","+ ++ indices.map(function(i) { ++ return "stride["+i+"]" ++ }).join(",")+",offset)}") + +- if(element !== window) { +- window.addEventListener('blur', handleBlur) ++ //Compile procedure ++ var procedure = new Function("CTOR_LIST", "ORDER", code.join("\n")) ++ return procedure(CACHED_CONSTRUCTORS[dtype], order) ++} + +- window.addEventListener('keyup', handleMods) +- window.addEventListener('keydown', handleMods) +- window.addEventListener('keypress', handleMods) +- } ++function arrayDType(data) { ++ if(isBuffer(data)) { ++ return "buffer" + } +- +- function detachListeners() { +- if(!attached) { +- return ++ if(hasTypedArrays) { ++ switch(Object.prototype.toString.call(data)) { ++ case "[object Float64Array]": ++ return "float64" ++ case "[object Float32Array]": ++ return "float32" ++ case "[object Int8Array]": ++ return "int8" ++ case "[object Int16Array]": ++ return "int16" ++ case "[object Int32Array]": ++ return "int32" ++ case "[object Uint8Array]": ++ return "uint8" ++ case "[object Uint16Array]": ++ return "uint16" ++ case "[object Uint32Array]": ++ return "uint32" ++ case "[object Uint8ClampedArray]": ++ return "uint8_clamped" + } +- attached = false +- +- element.removeEventListener('mousemove', handleMouseMove) +- +- element.removeEventListener('mousedown', handleMouseDown) +- +- element.removeEventListener('mouseup', handleMouseUp) +- +- element.removeEventListener('mouseleave', clearState) +- element.removeEventListener('mouseenter', clearState) +- element.removeEventListener('mouseout', clearState) +- element.removeEventListener('mouseover', clearState) +- +- element.removeEventListener('blur', handleBlur) ++ } ++ if(Array.isArray(data)) { ++ return "array" ++ } ++ return "generic" ++} + +- element.removeEventListener('keyup', handleMods) +- element.removeEventListener('keydown', handleMods) +- element.removeEventListener('keypress', handleMods) ++var CACHED_CONSTRUCTORS = { ++ "float32":[], ++ "float64":[], ++ "int8":[], ++ "int16":[], ++ "int32":[], ++ "uint8":[], ++ "uint16":[], ++ "uint32":[], ++ "array":[], ++ "uint8_clamped":[], ++ "buffer":[], ++ "generic":[] ++} + +- if(element !== window) { +- window.removeEventListener('blur', handleBlur) ++;(function() { ++ for(var id in CACHED_CONSTRUCTORS) { ++ CACHED_CONSTRUCTORS[id].push(compileConstructor(id, -1)) ++ } ++}); + +- window.removeEventListener('keyup', handleMods) +- window.removeEventListener('keydown', handleMods) +- window.removeEventListener('keypress', handleMods) ++function wrappedNDArrayCtor(data, shape, stride, offset) { ++ if(data === undefined) { ++ var ctor = CACHED_CONSTRUCTORS.array[0] ++ return ctor([]) ++ } else if(typeof data === "number") { ++ data = [data] ++ } ++ if(shape === undefined) { ++ shape = [ data.length ] ++ } ++ var d = shape.length ++ if(stride === undefined) { ++ stride = new Array(d) ++ for(var i=d-1, sz=1; i>=0; --i) { ++ stride[i] = sz ++ sz *= shape[i] ++ } ++ } ++ if(offset === undefined) { ++ offset = 0 ++ for(var i=0; i>>0 + +-},{"mouse-event":208}],208:[function(require,module,exports){ +-'use strict' ++module.exports = nextafter + +-function mouseButtons(ev) { +- if(typeof ev === 'object') { +- if('buttons' in ev) { +- return ev.buttons +- } else if('which' in ev) { +- var b = ev.which +- if(b === 2) { +- return 4 +- } else if(b === 3) { +- return 2 +- } else if(b > 0) { +- return 1<<(b-1) +- } +- } else if('button' in ev) { +- var b = ev.button +- if(b === 1) { +- return 4 +- } else if(b === 2) { +- return 2 +- } else if(b >= 0) { +- return 1< x) === (x > 0)) { ++ if(lo === UINT_MAX) { ++ hi += 1 ++ lo = 0 ++ } else { ++ lo += 1 + } +- var target = mouseElement(ev) +- var bounds = target.getBoundingClientRect() +- return ev.clientX - bounds.left +- } +- return 0 +-} +-exports.x = mouseRelativeX +- +-function mouseRelativeY(ev) { +- if(typeof ev === 'object') { +- if('offsetY' in ev) { +- return ev.offsetY ++ } else { ++ if(lo === 0) { ++ lo = UINT_MAX ++ hi -= 1 ++ } else { ++ lo -= 1 + } +- var target = mouseElement(ev) +- var bounds = target.getBoundingClientRect() +- return ev.clientY - bounds.top + } +- return 0 ++ return doubleBits.pack(lo, hi) + } +-exports.y = mouseRelativeY ++},{"double-bits":76}],193:[function(require,module,exports){ ++var DEFAULT_NORMALS_EPSILON = 1e-6; ++var DEFAULT_FACE_EPSILON = 1e-6; + +-},{}],209:[function(require,module,exports){ +-module.exports = function parseUnit(str, out) { +- if (!out) +- out = [ 0, '' ] ++//Estimate the vertex normals of a mesh ++exports.vertexNormals = function(faces, positions, specifiedEpsilon) { + +- str = String(str) +- var num = parseFloat(str, 10) +- out[0] = num +- out[1] = str.match(/[\d.\-\+]*\s*(.*)/)[1] || '' +- return out +-} +-},{}],210:[function(require,module,exports){ +-'use strict' ++ var N = positions.length; ++ var normals = new Array(N); ++ var epsilon = specifiedEpsilon === void(0) ? DEFAULT_NORMALS_EPSILON : specifiedEpsilon; + +-var parseUnit = require('parse-unit') ++ //Initialize normal array ++ for(var i=0; i epsilon) { ++ var norm = normals[c]; ++ var w = 1.0 / Math.sqrt(m01 * m21); ++ for(var k=0; k<3; ++k) { ++ var u = (k+1)%3; ++ var v = (k+2)%3; ++ norm[k] += w * (d21[u] * d01[v] - d21[v] * d01[u]); ++ } ++ } ++ } + } +- switch(str) { +- case '%': //Ambiguous, not sure if we should use width or height +- return element.clientHeight / 100.0 +- case 'ch': +- case 'ex': +- return getSizeBrutal(str, element) +- case 'em': +- return getPropertyInPX(element, 'font-size') +- case 'rem': +- return getPropertyInPX(document.body, 'font-size') +- case 'vw': +- return window.innerWidth/100 +- case 'vh': +- return window.innerHeight/100 +- case 'vmin': +- return Math.min(window.innerWidth, window.innerHeight) / 100 +- case 'vmax': +- return Math.max(window.innerWidth, window.innerHeight) / 100 +- case 'in': +- return PIXELS_PER_INCH +- case 'cm': +- return PIXELS_PER_INCH / 2.54 +- case 'mm': +- return PIXELS_PER_INCH / 25.4 +- case 'pt': +- return PIXELS_PER_INCH / 72 +- case 'pc': +- return PIXELS_PER_INCH / 6 ++ ++ //Scale all normals to unit length ++ for(var i=0; i epsilon) { ++ var w = 1.0 / Math.sqrt(m); ++ for(var k=0; k<3; ++k) { ++ norm[k] *= w; ++ } ++ } else { ++ for(var k=0; k<3; ++k) { ++ norm[k] = 0.0; ++ } ++ } + } +- return 1 ++ ++ //Return the resulting set of patches ++ return normals; + } +-},{"parse-unit":209}],211:[function(require,module,exports){ +-'use strict' + +-var toPX = require('to-px') ++//Compute face normals of a mesh ++exports.faceNormals = function(faces, positions, specifiedEpsilon) { + +-module.exports = mouseWheelListen ++ var N = faces.length; ++ var normals = new Array(N); ++ var epsilon = specifiedEpsilon === void(0) ? DEFAULT_FACE_EPSILON : specifiedEpsilon; + +-function mouseWheelListen(element, callback, noScroll) { +- if(typeof element === 'function') { +- noScroll = !!callback +- callback = element +- element = window +- } +- var lineHeight = toPX('ex', element) +- var listener = function(ev) { +- if(noScroll) { +- ev.preventDefault() ++ for(var i=0; i epsilon) { ++ l = 1.0 / Math.sqrt(l); ++ } else { ++ l = 0.0; ++ } ++ for(var j=0; j<3; ++j) { ++ n[j] *= l; + } ++ normals[i] = n; + } +- element.addEventListener('wheel', listener) +- return listener ++ return normals; + } + +-},{"to-px":210}],212:[function(require,module,exports){ +-"use strict" + + ++},{}],194:[function(require,module,exports){ ++'use strict' + +-var fill = require('cwise/lib/wrapper')({"args":["index","array","scalar"],"pre":{"body":"{}","args":[],"thisVars":[],"localVars":[]},"body":{"body":"{_inline_7_arg1_=_inline_7_arg2_.apply(void 0,_inline_7_arg0_)}","args":[{"name":"_inline_7_arg0_","lvalue":false,"rvalue":true,"count":1},{"name":"_inline_7_arg1_","lvalue":true,"rvalue":false,"count":1},{"name":"_inline_7_arg2_","lvalue":false,"rvalue":true,"count":1}],"thisVars":[],"localVars":[]},"post":{"body":"{}","args":[],"thisVars":[],"localVars":[]},"debug":false,"funcName":"cwise","blockSize":64}) ++module.exports = quatFromFrame + +-module.exports = function(array, f) { +- fill(array, f) +- return array ++function quatFromFrame( ++ out, ++ rx, ry, rz, ++ ux, uy, uz, ++ fx, fy, fz) { ++ var tr = rx + uy + fz ++ if(l > 0) { ++ var l = Math.sqrt(tr + 1.0) ++ out[0] = 0.5 * (uz - fy) / l ++ out[1] = 0.5 * (fx - rz) / l ++ out[2] = 0.5 * (ry - uy) / l ++ out[3] = 0.5 * l ++ } else { ++ var tf = Math.max(rx, uy, fz) ++ var l = Math.sqrt(2 * tf - tr + 1.0) ++ if(rx >= tf) { ++ //x y z order ++ out[0] = 0.5 * l ++ out[1] = 0.5 * (ux + ry) / l ++ out[2] = 0.5 * (fx + rz) / l ++ out[3] = 0.5 * (uz - fy) / l ++ } else if(uy >= tf) { ++ //y z x order ++ out[0] = 0.5 * (ry + ux) / l ++ out[1] = 0.5 * l ++ out[2] = 0.5 * (fy + uz) / l ++ out[3] = 0.5 * (fx - rz) / l ++ } else { ++ //z x y order ++ out[0] = 0.5 * (rz + fx) / l ++ out[1] = 0.5 * (uz + fy) / l ++ out[2] = 0.5 * l ++ out[3] = 0.5 * (ry - ux) / l ++ } ++ } ++ return out + } +- +-},{"cwise/lib/wrapper":99}],213:[function(require,module,exports){ ++},{}],195:[function(require,module,exports){ + 'use strict' + +-module.exports = invert ++module.exports = createOrbitController + +-var invert2 = require('gl-mat2/invert') +-var invert3 = require('gl-mat3/invert') +-var invert4 = require('gl-mat4/invert') ++var filterVector = require('filtered-vector') ++var lookAt = require('gl-mat4/lookAt') ++var mat4FromQuat = require('gl-mat4/fromQuat') ++var invert44 = require('gl-mat4/invert') ++var quatFromFrame = require('./lib/quatFromFrame') + +-function invert(out, M) { +- switch(M.length) { +- case 0: +- break +- case 1: +- out[0] = 1.0 / M[0] +- break +- case 4: +- invert2(out, M) +- break +- case 9: +- invert3(out, M) +- break +- case 16: +- invert4(out, M) +- break +- default: +- throw new Error('currently supports matrices up to 4x4') +- break +- } +- return out ++function len3(x,y,z) { ++ return Math.sqrt(Math.pow(x,2) + Math.pow(y,2) + Math.pow(z,2)) + } +-},{"gl-mat2/invert":214,"gl-mat3/invert":113,"gl-mat4/invert":120}],214:[function(require,module,exports){ +-module.exports = invert + +-/** +- * Inverts a mat2 +- * +- * @alias mat2.invert +- * @param {mat2} out the receiving matrix +- * @param {mat2} a the source matrix +- * @returns {mat2} out +- */ +-function invert(out, a) { +- var a0 = a[0] +- var a1 = a[1] +- var a2 = a[2] +- var a3 = a[3] +- var det = a0 * a3 - a2 * a1 ++function len4(w,x,y,z) { ++ return Math.sqrt(Math.pow(w,2) + Math.pow(x,2) + Math.pow(y,2) + Math.pow(z,2)) ++} + +- if (!det) return null +- det = 1.0 / det ++function normalize4(out, a) { ++ var ax = a[0] ++ var ay = a[1] ++ var az = a[2] ++ var aw = a[3] ++ var al = len4(ax, ay, az, aw) ++ if(al > 1e-6) { ++ out[0] = ax/al ++ out[1] = ay/al ++ out[2] = az/al ++ out[3] = aw/al ++ } else { ++ out[0] = out[1] = out[2] = 0.0 ++ out[3] = 1.0 ++ } ++} + +- out[0] = a3 * det +- out[1] = -a1 * det +- out[2] = -a2 * det +- out[3] = a0 * det ++function OrbitCameraController(initQuat, initCenter, initRadius) { ++ this.radius = filterVector([initRadius]) ++ this.center = filterVector(initCenter) ++ this.rotation = filterVector(initQuat) + +- return out ++ this.computedRadius = this.radius.curve(0) ++ this.computedCenter = this.center.curve(0) ++ this.computedRotation = this.rotation.curve(0) ++ this.computedUp = [0.1,0,0] ++ this.computedEye = [0.1,0,0] ++ this.computedMatrix = [0.1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] ++ ++ this.recalcMatrix(0) + } + +-},{}],215:[function(require,module,exports){ +-"use strict" ++var proto = OrbitCameraController.prototype + +-function interp1d(arr, x) { +- var ix = Math.floor(x) +- , fx = x - ix +- , s0 = 0 <= ix && ix < arr.shape[0] +- , s1 = 0 <= ix+1 && ix+1 < arr.shape[0] +- , w0 = s0 ? +arr.get(ix) : 0.0 +- , w1 = s1 ? +arr.get(ix+1) : 0.0 +- return (1.0-fx)*w0 + fx*w1 ++proto.lastT = function() { ++ return Math.max( ++ this.radius.lastT(), ++ this.center.lastT(), ++ this.rotation.lastT()) + } + +-function interp2d(arr, x, y) { +- var ix = Math.floor(x) +- , fx = x - ix +- , s0 = 0 <= ix && ix < arr.shape[0] +- , s1 = 0 <= ix+1 && ix+1 < arr.shape[0] +- , iy = Math.floor(y) +- , fy = y - iy +- , t0 = 0 <= iy && iy < arr.shape[1] +- , t1 = 0 <= iy+1 && iy+1 < arr.shape[1] +- , w00 = s0&&t0 ? arr.get(ix ,iy ) : 0.0 +- , w01 = s0&&t1 ? arr.get(ix ,iy+1) : 0.0 +- , w10 = s1&&t0 ? arr.get(ix+1,iy ) : 0.0 +- , w11 = s1&&t1 ? arr.get(ix+1,iy+1) : 0.0 +- return (1.0-fy) * ((1.0-fx)*w00 + fx*w10) + fy * ((1.0-fx)*w01 + fx*w11) +-} ++proto.recalcMatrix = function(t) { ++ this.radius.curve(t) ++ this.center.curve(t) ++ this.rotation.curve(t) + +-function interp3d(arr, x, y, z) { +- var ix = Math.floor(x) +- , fx = x - ix +- , s0 = 0 <= ix && ix < arr.shape[0] +- , s1 = 0 <= ix+1 && ix+1 < arr.shape[0] +- , iy = Math.floor(y) +- , fy = y - iy +- , t0 = 0 <= iy && iy < arr.shape[1] +- , t1 = 0 <= iy+1 && iy+1 < arr.shape[1] +- , iz = Math.floor(z) +- , fz = z - iz +- , u0 = 0 <= iz && iz < arr.shape[2] +- , u1 = 0 <= iz+1 && iz+1 < arr.shape[2] +- , w000 = s0&&t0&&u0 ? arr.get(ix,iy,iz) : 0.0 +- , w010 = s0&&t1&&u0 ? arr.get(ix,iy+1,iz) : 0.0 +- , w100 = s1&&t0&&u0 ? arr.get(ix+1,iy,iz) : 0.0 +- , w110 = s1&&t1&&u0 ? arr.get(ix+1,iy+1,iz) : 0.0 +- , w001 = s0&&t0&&u1 ? arr.get(ix,iy,iz+1) : 0.0 +- , w011 = s0&&t1&&u1 ? arr.get(ix,iy+1,iz+1) : 0.0 +- , w101 = s1&&t0&&u1 ? arr.get(ix+1,iy,iz+1) : 0.0 +- , w111 = s1&&t1&&u1 ? arr.get(ix+1,iy+1,iz+1) : 0.0 +- return (1.0-fz) * ((1.0-fy) * ((1.0-fx)*w000 + fx*w100) + fy * ((1.0-fx)*w010 + fx*w110)) + fz * ((1.0-fy) * ((1.0-fx)*w001 + fx*w101) + fy * ((1.0-fx)*w011 + fx*w111)) +-} ++ var quat = this.computedRotation ++ normalize4(quat, quat) + +-function interpNd(arr) { +- var d = arr.shape.length|0 +- , ix = new Array(d) +- , fx = new Array(d) +- , s0 = new Array(d) +- , s1 = new Array(d) +- , i, t +- for(i=0; i 1e-6) { ++ bx /= bl ++ by /= bl ++ bz /= bl ++ bw /= bl ++ } else { ++ bx = by = bz = 0.0 ++ bw = 1.0 + } +- if(!x.thisVars) { +- x.thisVars = [] ++ ++ var rotation = this.computedRotation ++ var ax = rotation[0] ++ var ay = rotation[1] ++ var az = rotation[2] ++ var aw = rotation[3] ++ ++ var cx = ax*bw + aw*bx + ay*bz - az*by ++ var cy = ay*bw + aw*by + az*bx - ax*bz ++ var cz = az*bw + aw*bz + ax*by - ay*bx ++ var cw = aw*bw - ax*bx - ay*by - az*bz ++ ++ //Apply roll ++ if(dz) { ++ bx = fx ++ by = fy ++ bz = fz ++ var s = Math.sin(dz) / len3(bx, by, bz) ++ bx *= s ++ by *= s ++ bz *= s ++ bw = Math.cos(dx) ++ cx = cx*bw + cw*bx + cy*bz - cz*by ++ cy = cy*bw + cw*by + cz*bx - cx*bz ++ cz = cz*bw + cw*bz + cx*by - cy*bx ++ cw = cw*bw - cx*bx - cy*by - cz*bz + } +- if(!x.localVars) { +- x.localVars = [] ++ ++ var cl = len4(cx, cy, cz, cw) ++ if(cl > 1e-6) { ++ cx /= cl ++ cy /= cl ++ cz /= cl ++ cw /= cl ++ } else { ++ cx = cy = cz = 0.0 ++ cw = 1.0 + } +- return x +-} + +-function pcompile(user_args) { +- return compile({ +- args: user_args.args, +- pre: fixup(user_args.pre), +- body: fixup(user_args.body), +- post: fixup(user_args.proc), +- funcName: user_args.funcName +- }) ++ this.rotation.set(t, cx, cy, cz, cw) + } + +-function makeOp(user_args) { +- var args = [] +- for(var i=0; i>", +- rrshift: ">>>" ++ this.center.set(t, center[0], center[1], center[2]) + } +-;(function(){ +- for(var id in assign_ops) { +- var op = assign_ops[id] +- exports[id] = makeOp({ +- args: ["array","array","array"], +- body: {args:["a","b","c"], +- body: "a=b"+op+"c"}, +- funcName: id +- }) +- exports[id+"eq"] = makeOp({ +- args: ["array","array"], +- body: {args:["a","b"], +- body:"a"+op+"=b"}, +- rvalue: true, +- funcName: id+"eq" +- }) +- exports[id+"s"] = makeOp({ +- args: ["array", "array", "scalar"], +- body: {args:["a","b","s"], +- body:"a=b"+op+"s"}, +- funcName: id+"s" +- }) +- exports[id+"seq"] = makeOp({ +- args: ["array","scalar"], +- body: {args:["a","s"], +- body:"a"+op+"=s"}, +- rvalue: true, +- funcName: id+"seq" +- }) +- } +-})(); + +-var unary_ops = { +- not: "!", +- bnot: "~", +- neg: "-", +- recip: "1.0/" ++proto.translate = function(t, dx, dy, dz) { ++ this.center.move(t, ++ dx||0.0, ++ dy||0.0, ++ dz||0.0) + } +-;(function(){ +- for(var id in unary_ops) { +- var op = unary_ops[id] +- exports[id] = makeOp({ +- args: ["array", "array"], +- body: {args:["a","b"], +- body:"a="+op+"b"}, +- funcName: id +- }) +- exports[id+"eq"] = makeOp({ +- args: ["array"], +- body: {args:["a"], +- body:"a="+op+"a"}, +- rvalue: true, +- count: 2, +- funcName: id+"eq" +- }) +- } +-})(); + +-var binary_ops = { +- and: "&&", +- or: "||", +- eq: "===", +- neq: "!==", +- lt: "<", +- gt: ">", +- leq: "<=", +- geq: ">=" ++proto.setMatrix = function(t, matrix) { ++ ++ var rotation = this.computedRotation ++ quatFromFrame(rotation, ++ matrix[0], matrix[1], matrix[2], ++ matrix[4], matrix[5], matrix[6], ++ matrix[8], matrix[9], matrix[10]) ++ normalize4(rotation, rotation) ++ this.rotation.set(t, rotation[0], rotation[1], rotation[2], rotation[3]) ++ ++ var mat = this.computedMatrix ++ invert44(mat, matrix) ++ var w = mat[15] ++ if(Math.abs(w) > 1e-6) { ++ var cx = mat[12]/w ++ var cy = mat[13]/w ++ var cz = mat[14]/w ++ ++ this.recalcMatrix(t) ++ var r = Math.exp(this.computedRadius[0]) ++ this.center.set(t, cx-mat[2]*r, cy-mat[6]*r, cz-mat[10]*r) ++ this.radius.idle(t) ++ } else { ++ this.center.idle(t) ++ this.radius.idle(t) ++ } + } +-;(function() { +- for(var id in binary_ops) { +- var op = binary_ops[id] +- exports[id] = makeOp({ +- args: ["array","array","array"], +- body: {args:["a", "b", "c"], +- body:"a=b"+op+"c"}, +- funcName: id +- }) +- exports[id+"s"] = makeOp({ +- args: ["array","array","scalar"], +- body: {args:["a", "b", "s"], +- body:"a=b"+op+"s"}, +- funcName: id+"s" +- }) +- exports[id+"eq"] = makeOp({ +- args: ["array", "array"], +- body: {args:["a", "b"], +- body:"a=a"+op+"b"}, +- rvalue:true, +- count:2, +- funcName: id+"eq" +- }) +- exports[id+"seq"] = makeOp({ +- args: ["array", "scalar"], +- body: {args:["a","s"], +- body:"a=a"+op+"s"}, +- rvalue:true, +- count:2, +- funcName: id+"seq" +- }) ++ ++proto.setDistance = function(t, d) { ++ if(d > 0) { ++ this.radius.set(t, Math.log(d)) + } +-})(); ++} + +-var math_unary = [ +- "abs", +- "acos", +- "asin", +- "atan", +- "ceil", +- "cos", +- "exp", +- "floor", +- "log", +- "round", +- "sin", +- "sqrt", +- "tan" +-] +-;(function() { +- for(var i=0; i 0) { ++ lo = Math.log(lo) ++ } else { ++ lo = -Infinity + } +-})(); ++ if(hi > 0) { ++ hi = Math.log(hi) ++ } else { ++ hi = Infinity ++ } ++ hi = Math.max(hi, lo) ++ this.radius.bounds[0][0] = lo ++ this.radius.bounds[1][0] = hi ++} + +-var math_comm = [ +- "max", +- "min", +- "atan2", +- "pow" +-] +-;(function(){ +- for(var i=0; i 0) { ++ this.radius.set(t, Math.log(d)) ++ } ++ this.setDistanceLimits(options.zoomMin, options.zoomMax) ++} + +-exports.all = compile({ +- args:["array"], +- pre: EmptyProc, +- body: {args:[{name:"x", lvalue:false, rvalue:true, count:1}], body: "if(!x){return false}", localVars: [], thisVars: []}, +- post: {args:[], localVars:[], thisVars:[], body:"return true"}, +- funcName: "all" +-}) ++function createOrbitController(options) { ++ options = options || {} ++ var center = options.center || [0,0,0] ++ var rotation = options.rotation || [0,0,0,1] ++ var radius = options.radius || 1.0 + +-exports.sum = compile({ +- args:["array"], +- pre: {args:[], localVars:[], thisVars:["this_s"], body:"this_s=0"}, +- body: {args:[{name:"a", lvalue:false, rvalue:true, count:1}], body: "this_s+=a", localVars: [], thisVars: ["this_s"]}, +- post: {args:[], localVars:[], thisVars:["this_s"], body:"return this_s"}, +- funcName: "sum" +-}) ++ center = [].slice.call(center, 0, 3) ++ rotation = [].slice.call(rotation, 0, 4) ++ normalize4(rotation, rotation) + +-exports.prod = compile({ +- args:["array"], +- pre: {args:[], localVars:[], thisVars:["this_s"], body:"this_s=1"}, +- body: {args:[{name:"a", lvalue:false, rvalue:true, count:1}], body: "this_s*=a", localVars: [], thisVars: ["this_s"]}, +- post: {args:[], localVars:[], thisVars:["this_s"], body:"return this_s"}, +- funcName: "prod" +-}) ++ var result = new OrbitCameraController( ++ rotation, ++ center, ++ Math.log(radius)) + +-exports.norm2squared = compile({ +- args:["array"], +- pre: {args:[], localVars:[], thisVars:["this_s"], body:"this_s=0"}, +- body: {args:[{name:"a", lvalue:false, rvalue:true, count:2}], body: "this_s+=a*a", localVars: [], thisVars: ["this_s"]}, +- post: {args:[], localVars:[], thisVars:["this_s"], body:"return this_s"}, +- funcName: "norm2squared" +-}) +- +-exports.norm2 = compile({ +- args:["array"], +- pre: {args:[], localVars:[], thisVars:["this_s"], body:"this_s=0"}, +- body: {args:[{name:"a", lvalue:false, rvalue:true, count:2}], body: "this_s+=a*a", localVars: [], thisVars: ["this_s"]}, +- post: {args:[], localVars:[], thisVars:["this_s"], body:"return Math.sqrt(this_s)"}, +- funcName: "norm2" +-}) +- ++ result.setDistanceLimits(options.zoomMin, options.zoomMax) + +-exports.norminf = compile({ +- args:["array"], +- pre: {args:[], localVars:[], thisVars:["this_s"], body:"this_s=0"}, +- body: {args:[{name:"a", lvalue:false, rvalue:true, count:4}], body:"if(-a>this_s){this_s=-a}else if(a>this_s){this_s=a}", localVars: [], thisVars: ["this_s"]}, +- post: {args:[], localVars:[], thisVars:["this_s"], body:"return this_s"}, +- funcName: "norminf" +-}) ++ if('eye' in options || 'up' in options) { ++ result.lookAt(0, options.eye, options.center, options.up) ++ } + +-exports.norm1 = compile({ +- args:["array"], +- pre: {args:[], localVars:[], thisVars:["this_s"], body:"this_s=0"}, +- body: {args:[{name:"a", lvalue:false, rvalue:true, count:3}], body: "this_s+=a<0?-a:a", localVars: [], thisVars: ["this_s"]}, +- post: {args:[], localVars:[], thisVars:["this_s"], body:"return this_s"}, +- funcName: "norm1" +-}) ++ return result ++} ++},{"./lib/quatFromFrame":194,"filtered-vector":83,"gl-mat4/fromQuat":108,"gl-mat4/invert":111,"gl-mat4/lookAt":112}],196:[function(require,module,exports){ ++/*! ++ * pad-left ++ * ++ * Copyright (c) 2014-2015, Jon Schlinkert. ++ * Licensed under the MIT license. ++ */ + +-exports.sup = compile({ +- args: [ "array" ], +- pre: +- { body: "this_h=-Infinity", +- args: [], +- thisVars: [ "this_h" ], +- localVars: [] }, +- body: +- { body: "if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_", +- args: [{"name":"_inline_1_arg0_","lvalue":false,"rvalue":true,"count":2} ], +- thisVars: [ "this_h" ], +- localVars: [] }, +- post: +- { body: "return this_h", +- args: [], +- thisVars: [ "this_h" ], +- localVars: [] } +- }) ++'use strict'; + +-exports.inf = compile({ +- args: [ "array" ], +- pre: +- { body: "this_h=Infinity", +- args: [], +- thisVars: [ "this_h" ], +- localVars: [] }, +- body: +- { body: "if(_inline_1_arg0_this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}", +- args:[ +- {name:"_inline_1_arg0_",lvalue:false,rvalue:true,count:2}, +- {name:"_inline_1_arg1_",lvalue:false,rvalue:true,count:2}], +- thisVars:["this_i","this_v"], +- localVars:["_inline_1_k"]}, +- post:{ +- body:"{return this_i}", +- args:[], +- thisVars:["this_i"], +- localVars:[]} +-}) ++ str = String(str) ++ var num = parseFloat(str, 10) ++ out[0] = num ++ out[1] = str.match(/[\d.\-\+]*\s*(.*)/)[1] || '' ++ return out ++} ++},{}],198:[function(require,module,exports){ ++"use strict" + +-exports.random = makeOp({ +- args: ["array"], +- pre: {args:[], body:"this_f=Math.random", thisVars:["this_f"]}, +- body: {args: ["a"], body:"a=this_f()", thisVars:["this_f"]}, +- funcName: "random" +-}) ++module.exports = permutationSign + +-exports.assign = makeOp({ +- args:["array", "array"], +- body: {args:["a", "b"], body:"a=b"}, +- funcName: "assign" }) ++var BRUTE_FORCE_CUTOFF = 32 + +-exports.assigns = makeOp({ +- args:["array", "scalar"], +- body: {args:["a", "b"], body:"a=b"}, +- funcName: "assigns" }) ++var pool = require("typedarray-pool") ++ ++function permutationSign(p) { ++ var n = p.length ++ if(n < BRUTE_FORCE_CUTOFF) { ++ //Use quadratic algorithm for small n ++ var sgn = 1 ++ for(var i=0; i0; --i) { ++ t = pinv[i] ++ s = p[i] ++ p[i] = p[t] ++ p[t] = s ++ pinv[i] = pinv[s] ++ pinv[s] = t ++ r = (r + s) * i ++ } ++ pool.freeUint32(pinv) ++ pool.freeUint32(p) ++ return r ++} ++ ++function unrank(n, r, p) { ++ switch(n) { ++ case 0: ++ if(p) { return p } ++ return [] ++ case 1: ++ if(p) { ++ p[0] = 0 ++ return p ++ } else { ++ return [0] ++ } ++ case 2: ++ if(p) { ++ if(r) { ++ p[0] = 0 ++ p[1] = 1 ++ } else { ++ p[0] = 1 ++ p[1] = 0 ++ } ++ return p ++ } else { ++ return r ? [0,1] : [1,0] ++ } ++ default: ++ break ++ } ++ p = p || new Array(n) ++ var s, t, i, nf=1 ++ p[0] = 0 ++ for(i=1; i0; --i) { ++ s = (r / nf)|0 ++ r = (r - s * nf)|0 ++ nf = (nf / i)|0 ++ t = p[i]|0 ++ p[i] = p[s]|0 ++ p[s] = t|0 ++ } ++ return p ++} + ++exports.rank = rank ++exports.unrank = unrank + ++},{"invert-permutation":167,"typedarray-pool":246}],200:[function(require,module,exports){ ++"use strict" + +-},{"cwise-compiler":96}],219:[function(require,module,exports){ +-var iota = require("iota-array") +-var isBuffer = require("is-buffer") ++module.exports = planarDual + +-var hasTypedArrays = ((typeof Float64Array) !== "undefined") ++var compareAngle = require("compare-angle") + +-function compare1st(a, b) { +- return a[0] - b[0] +-} ++function planarDual(cells, positions) { + +-function order() { +- var stride = this.stride +- var terms = new Array(stride.length) +- var i +- for(i=0; i 0) { ++ nextCell = e ++ nextVertex = p ++ nextDir = dir ++ } ++ } ++ } ++ if(noCut) { ++ return nextVertex ++ } ++ if(nextCell) { ++ cut(nextCell, nextDir) ++ } ++ return nextVertex ++ } + +- //view.order: +- if(dimension === 1) { +- code.push("proto.order=[0]") +- } else { +- code.push("Object.defineProperty(proto,'order',{get:") +- if(dimension < 4) { +- code.push("function "+className+"_order(){") +- if(dimension === 2) { +- code.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})") +- } else if(dimension === 3) { +- code.push( +-"var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);\ +-if(s0>s1){\ +-if(s1>s2){\ +-return [2,1,0];\ +-}else if(s0>s2){\ +-return [1,2,0];\ +-}else{\ +-return [1,0,2];\ +-}\ +-}else if(s0>s2){\ +-return [2,0,1];\ +-}else if(s2>s1){\ +-return [0,1,2];\ +-}else{\ +-return [0,2,1];\ +-}}})") ++ function extractCycle(v, dir) { ++ var e0 = adj[dir][v][0] ++ var cycle = [v] ++ cut(e0, dir) ++ var u = e0[dir^1] ++ var d0 = dir ++ while(true) { ++ while(u !== v) { ++ cycle.push(u) ++ u = next(cycle[cycle.length-2], u, false) + } +- } else { +- code.push("ORDER})") ++ if(adj[0][v].length + adj[1][v].length === 0) { ++ break ++ } ++ var a = cycle[cycle.length-1] ++ var b = v ++ var c = cycle[1] ++ var d = next(a, b, true) ++ if(compareAngle(positions[a], positions[b], positions[c], positions[d]) < 0) { ++ break ++ } ++ cycle.push(v) ++ u = next(a, b) + } ++ return cycle + } + +- //view.set(i0, ..., v): +- code.push( +-"proto.set=function "+className+"_set("+args.join(",")+",v){") +- if(useGetters) { +- code.push("return this.data.set("+index_str+",v)}") +- } else { +- code.push("return this.data["+index_str+"]=v}") ++ function shouldGlue(pcycle, ncycle) { ++ return (ncycle[1] === ncycle[ncycle.length-1]) + } + +- //view.get(i0, ...): +- code.push("proto.get=function "+className+"_get("+args.join(",")+"){") +- if(useGetters) { +- code.push("return this.data.get("+index_str+")}") +- } else { +- code.push("return this.data["+index_str+"]}") ++ for(var i=0; i 0) { ++ var ni = adj[0][i].length ++ var ncycle = extractCycle(i,j) ++ if(shouldGlue(pcycle, ncycle)) { ++ //Glue together trivial cycles ++ pcycle.push.apply(pcycle, ncycle) ++ } else { ++ if(pcycle.length > 0) { ++ cycles.push(pcycle) ++ } ++ pcycle = ncycle ++ } ++ } ++ if(pcycle.length > 0) { ++ cycles.push(pcycle) ++ } ++ } + } + +- //view.index: +- code.push( +- "proto.index=function "+className+"_index(", args.join(), "){return "+index_str+"}") ++ //Combine paths and loops together ++ return cycles ++} ++},{"compare-angle":62}],201:[function(require,module,exports){ ++'use strict' + +- //view.hi(): +- code.push("proto.hi=function "+className+"_hi("+args.join(",")+"){return new "+className+"(this.data,"+ +- indices.map(function(i) { +- return ["(typeof i",i,"!=='number'||i",i,"<0)?this.shape[", i, "]:i", i,"|0"].join("") +- }).join(",")+","+ +- indices.map(function(i) { +- return "this.stride["+i + "]" +- }).join(",")+",this.offset)}") ++module.exports = trimLeaves + +- //view.lo(): +- var a_vars = indices.map(function(i) { return "a"+i+"=this.shape["+i+"]" }) +- var c_vars = indices.map(function(i) { return "c"+i+"=this.stride["+i+"]" }) +- code.push("proto.lo=function "+className+"_lo("+args.join(",")+"){var b=this.offset,d=0,"+a_vars.join(",")+","+c_vars.join(",")) +- for(var i=0; i=0){\ +-d=i"+i+"|0;\ +-b+=c"+i+"*d;\ +-a"+i+"-=d}") ++var e2a = require('edges-to-adjacency-list') ++ ++function trimLeaves(edges, positions) { ++ var adj = e2a(edges, positions.length) ++ var live = new Array(positions.length) ++ var nbhd = new Array(positions.length) ++ ++ var dead = [] ++ for(var i=0; i 0) { ++ var v = dead.pop() ++ live[v] = false ++ var n = adj[v] ++ for(var i=0; i=0){c=(c+this.stride["+i+"]*i"+i+")|0}else{a.push(this.shape["+i+"]);b.push(this.stride["+i+"])}") ++ var nedges = [] ++ for(var i=0; i=0; --i) { +- stride[i] = sz +- sz *= shape[i] ++ ++ //Get faces ++ var faces = planarDual(edges, positions) ++ ++ //Check orientation of a polygon using exact arithmetic ++ function ccw(c) { ++ var n = c.length ++ var area = [0] ++ for(var j=0; j 0 + } +- if(offset === undefined) { +- offset = 0 +- for(var i=0; i +- * +- * Copyright (c) 2014-2015, Jon Schlinkert. +- * Licensed under the MIT License. +- */ +- +-'use strict'; +- +-/** +- * Results cache +- */ + +-var res = ''; +-var cache; ++ //Initialize face adjacency list ++ var fadj = makeArrayOfArrays(numFaces) ++ for(var i=0; i AAAAA +- * ``` +- * +- * @param {String} `string` The string to repeat +- * @param {Number} `number` The number of times to repeat the string +- * @return {String} Repeated string +- * @api public +- */ ++ var toVisit = [] ++ var parity = makeArray(numFaces, -1) ++ for(var i=0; i 0) { ++ var top = toVisit.pop() ++ var nbhd = fadj[top] ++ uniq(nbhd, function(a,b) { ++ return a-b ++ }) ++ var nnbhr = nbhd.length ++ var p = parity[top] ++ var polyline ++ if(p === 0) { ++ var c = faces[top] ++ polyline = [c] ++ } ++ for(var i=0; i= 0) { ++ continue ++ } ++ parity[f] = p^1 ++ toVisit.push(f) ++ if(p === 0) { ++ var c = faces[f] ++ if(!sharedBoundary(c)) { ++ c.reverse() ++ polyline.push(c) ++ } ++ } ++ } ++ if(p === 0) { ++ result.push(polyline) ++ } + } + +- // cover common, quick use cases +- if (num === 1) return str; +- if (num === 2) return str + str; ++ return result ++} ++},{"./lib/trim-leaves":201,"edges-to-adjacency-list":78,"planar-dual":200,"point-in-big-polygon":203,"robust-sum":224,"two-product":244,"uniq":248}],203:[function(require,module,exports){ ++module.exports = preprocessPolygon + +- var max = str.length * num; +- if (cache !== str || typeof cache === 'undefined') { +- cache = str; +- res = ''; +- } ++var orient = require('robust-orientation')[3] ++var makeSlabs = require('slab-decomposition') ++var makeIntervalTree = require('interval-tree-1d') ++var bsearch = require('binary-search-bounds') + +- while (max > res.length && num > 0) { +- if (num & 1) { +- res += str; +- } ++function visitInterval() { ++ return true ++} + +- num >>= 1; +- if (!num) break; +- str += str; ++function intervalSearch(table) { ++ return function(x, y) { ++ var tree = table[x] ++ if(tree) { ++ return !!tree.queryPoint(y, visitInterval) ++ } ++ return false + } +- +- return res.substr(0, max); + } + +- +-},{}],221:[function(require,module,exports){ +-(function (global){ +-module.exports = +- global.performance && +- global.performance.now ? function now() { +- return performance.now() +- } : Date.now || function now() { +- return +new Date ++function buildVerticalIndex(segments) { ++ var table = {} ++ for(var i=0; i 0) { +- code.push(",") ++function buildSlabSearch(slabs, coordinates) { ++ return function(p) { ++ var bucket = bsearch.le(coordinates, p[0]) ++ if(bucket < 0) { ++ return 1 ++ } ++ var root = slabs[bucket] ++ if(!root) { ++ if(bucket > 0 && coordinates[bucket] === p[0]) { ++ root = slabs[bucket-1] ++ } else { ++ return 1 + } +- code.push("[") +- for(var k=0; k 0) { +- code.push(",") ++ } ++ var lastOrientation = 1 ++ while(root) { ++ var s = root.key ++ var o = orient(p, s[0], s[1]) ++ if(s[0][0] < s[1][0]) { ++ if(o < 0) { ++ root = root.left ++ } else if(o > 0) { ++ lastOrientation = -1 ++ root = root.right ++ } else { ++ return 0 + } +- if(k === i) { +- code.push("+b[", j, "]") ++ } else { ++ if(o > 0) { ++ root = root.left ++ } else if(o < 0) { ++ lastOrientation = 1 ++ root = root.right + } else { +- code.push("+A[", j, "][", k, "]") ++ return 0 + } + } +- code.push("]") + } +- code.push("]),") +- } +- code.push("det(A)]}return ", funcName) +- var proc = new Function("det", code.join("")) +- if(n < 6) { +- return proc(determinant[n]) ++ return lastOrientation + } +- return proc(determinant) +-} +- +-function robustLinearSolve0d() { +- return [ 0 ] + } + +-function robustLinearSolve1d(A, b) { +- return [ [ b[0] ], [ A[0][0] ] ] ++function classifyEmpty(p) { ++ return 1 + } + +-var CACHE = [ +- robustLinearSolve0d, +- robustLinearSolve1d +-] +- +-function generateDispatch() { +- while(CACHE.length < NUM_EXPAND) { +- CACHE.push(generateSolver(CACHE.length)) +- } +- var procArgs = [] +- var code = ["function dispatchLinearSolve(A,b){switch(A.length){"] +- for(var i=0; i=0; --i) { +- var a = Q +- var b = e[i] +- Q = a + b +- var bv = Q - a +- var q = b - bv +- if(q) { +- e[--bottom] = Q +- Q = q +- } +- } +- var top = 0 +- for(var i=bottom; i>1 +- return ["sum(", generateSum(expr.slice(0, m)), ",", generateSum(expr.slice(m)), ")"].join("") +- } +-} ++ //Build slab decomposition ++ var slabs = makeSlabs(segments) ++ var testSlab = buildSlabSearch(slabs.slabs, slabs.coordinates) + +-function determinant(m) { +- if(m.length === 2) { +- return ["sum(prod(", m[0][0], ",", m[1][1], "),prod(-", m[0][1], ",", m[1][0], "))"].join("") ++ if(vsegments.length === 0) { ++ return testSlab + } else { +- var expr = [] +- for(var i=0; i= a00) { ++ s = 1.0; ++ sqrDistance = a00 + 2.0*b0 + c; ++ } else { ++ s = -b0/a00; ++ sqrDistance = b0*s + c; ++ } ++ } else { ++ s = 0; ++ if (b1 >= 0) { ++ t = 0; ++ sqrDistance = c; ++ } else if (-b1 >= a11) { ++ t = 1; ++ sqrDistance = a11 + 2.0*b1 + c; ++ } else { ++ t = -b1/a11; ++ sqrDistance = b1*t + c; ++ } ++ } ++ } else { // region 3 ++ s = 0; ++ if (b1 >= 0) { ++ t = 0; ++ sqrDistance = c; ++ } else if (-b1 >= a11) { ++ t = 1; ++ sqrDistance = a11 + 2.0*b1 + c; ++ } else { ++ t = -b1/a11; ++ sqrDistance = b1*t + c; ++ } ++ } ++ } else if (t < 0) { // region 5 ++ t = 0; ++ if (b0 >= 0) { ++ s = 0; ++ sqrDistance = c; ++ } else if (-b0 >= a00) { ++ s = 1; ++ sqrDistance = a00 + 2.0*b0 + c; ++ } else { ++ s = -b0/a00; ++ sqrDistance = b0*s + c; ++ } ++ } else { // region 0 ++ // minimum at interior point ++ var invDet = 1.0 / det; ++ s *= invDet; ++ t *= invDet; ++ sqrDistance = s*(a00*s + a01*t + 2.0*b0) + t*(a01*s + a11*t + 2.0*b1) + c; ++ } ++ } else { ++ var tmp0, tmp1, numer, denom; ++ ++ if (s < 0) { // region 2 ++ tmp0 = a01 + b0; ++ tmp1 = a11 + b1; ++ if (tmp1 > tmp0) { ++ numer = tmp1 - tmp0; ++ denom = a00 - 2.0*a01 + a11; ++ if (numer >= denom) { ++ s = 1; ++ t = 0; ++ sqrDistance = a00 + 2.0*b0 + c; ++ } else { ++ s = numer/denom; ++ t = 1 - s; ++ sqrDistance = s*(a00*s + a01*t + 2.0*b0) + ++ t*(a01*s + a11*t + 2.0*b1) + c; ++ } ++ } else { ++ s = 0; ++ if (tmp1 <= 0) { ++ t = 1; ++ sqrDistance = a11 + 2.0*b1 + c; ++ } else if (b1 >= 0) { ++ t = 0; ++ sqrDistance = c; ++ } else { ++ t = -b1/a11; ++ sqrDistance = b1*t + c; ++ } ++ } ++ } else if (t < 0) { // region 6 ++ tmp0 = a01 + b1; ++ tmp1 = a00 + b0; ++ if (tmp1 > tmp0) { ++ numer = tmp1 - tmp0; ++ denom = a00 - 2.0*a01 + a11; ++ if (numer >= denom) { ++ t = 1; ++ s = 0; ++ sqrDistance = a11 + 2.0*b1 + c; ++ } else { ++ t = numer/denom; ++ s = 1 - t; ++ sqrDistance = s*(a00*s + a01*t + 2.0*b0) + ++ t*(a01*s + a11*t + 2.0*b1) + c; ++ } ++ } else { ++ t = 0; ++ if (tmp1 <= 0) { ++ s = 1; ++ sqrDistance = a00 + 2.0*b0 + c; ++ } else if (b0 >= 0) { ++ s = 0; ++ sqrDistance = c; ++ } else { ++ s = -b0/a00; ++ sqrDistance = b0*s + c; ++ } ++ } ++ } else { // region 1 ++ numer = a11 + b1 - a01 - b0; ++ if (numer <= 0) { ++ s = 0; ++ t = 1; ++ sqrDistance = a11 + 2.0*b1 + c; ++ } else { ++ denom = a00 - 2.0*a01 + a11; ++ if (numer >= denom) { ++ s = 1; ++ t = 0; ++ sqrDistance = a00 + 2.0*b0 + c; ++ } else { ++ s = numer/denom; ++ t = 1 - s; ++ sqrDistance = s*(a00*s + a01*t + 2.0*b0) + ++ t*(a01*s + a11*t + 2.0*b1) + c; ++ } + } +- r[k++] = m[i][j] + } + } +- return result +-} +- +-function matrix(n) { +- var result = new Array(n) +- for(var i=0; i>1 +- return ["sum(", generateSum(expr.slice(0, m)), ",", generateSum(expr.slice(m)), ")"].join("") +- } ++module.exports = closestPoint2d; ++ ++},{}],205:[function(require,module,exports){ ++// shim for using process in browser ++var process = module.exports = {}; ++ ++// cached from whatever global is present so that test runners that stub it ++// don't break things. But we need to wrap it in a try catch in case it is ++// wrapped in strict mode code which doesn't define any globals. It's inside a ++// function because try/catches deoptimize in certain engines. ++ ++var cachedSetTimeout; ++var cachedClearTimeout; ++ ++function defaultSetTimout() { ++ throw new Error('setTimeout has not been defined'); ++} ++function defaultClearTimeout () { ++ throw new Error('clearTimeout has not been defined'); + } ++(function () { ++ try { ++ if (typeof setTimeout === 'function') { ++ cachedSetTimeout = setTimeout; ++ } else { ++ cachedSetTimeout = defaultSetTimout; ++ } ++ } catch (e) { ++ cachedSetTimeout = defaultSetTimout; ++ } ++ try { ++ if (typeof clearTimeout === 'function') { ++ cachedClearTimeout = clearTimeout; ++ } else { ++ cachedClearTimeout = defaultClearTimeout; ++ } ++ } catch (e) { ++ cachedClearTimeout = defaultClearTimeout; ++ } ++} ()) ++function runTimeout(fun) { ++ if (cachedSetTimeout === setTimeout) { ++ //normal enviroments in sane situations ++ return setTimeout(fun, 0); ++ } ++ // if setTimeout wasn't available but was latter defined ++ if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { ++ cachedSetTimeout = setTimeout; ++ return setTimeout(fun, 0); ++ } ++ try { ++ // when when somebody has screwed with setTimeout but no I.E. maddness ++ return cachedSetTimeout(fun, 0); ++ } catch(e){ ++ try { ++ // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally ++ return cachedSetTimeout.call(null, fun, 0); ++ } catch(e){ ++ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error ++ return cachedSetTimeout.call(this, fun, 0); ++ } ++ } + +-function determinant(m) { +- if(m.length === 2) { +- return [["sum(prod(", m[0][0], ",", m[1][1], "),prod(-", m[0][1], ",", m[1][0], "))"].join("")] +- } else { +- var expr = [] +- for(var i=0; i 0) { +- if(r <= 0) { +- return det +- } else { +- s = l + r +- } +- } else if(l < 0) { +- if(r >= 0) { +- return det +- } else { +- s = -(l + r) +- } +- } else { +- return det ++ var len = queue.length; ++ while(len) { ++ currentQueue = queue; ++ queue = []; ++ while (++queueIndex < len) { ++ if (currentQueue) { ++ currentQueue[queueIndex].run(); ++ } ++ } ++ queueIndex = -1; ++ len = queue.length; + } +- var tol = ERRBOUND3 * s +- if(det >= tol || det <= -tol) { +- return det ++ currentQueue = null; ++ draining = false; ++ runClearTimeout(timeout); ++} ++ ++process.nextTick = function (fun) { ++ var args = new Array(arguments.length - 1); ++ if (arguments.length > 1) { ++ for (var i = 1; i < arguments.length; i++) { ++ args[i - 1] = arguments[i]; ++ } + } +- return orientation3Exact(a, b, c) +- }, +- function orientation4(a,b,c,d) { +- var adx = a[0] - d[0] +- var bdx = b[0] - d[0] +- var cdx = c[0] - d[0] +- var ady = a[1] - d[1] +- var bdy = b[1] - d[1] +- var cdy = c[1] - d[1] +- var adz = a[2] - d[2] +- var bdz = b[2] - d[2] +- var cdz = c[2] - d[2] +- var bdxcdy = bdx * cdy +- var cdxbdy = cdx * bdy +- var cdxady = cdx * ady +- var adxcdy = adx * cdy +- var adxbdy = adx * bdy +- var bdxady = bdx * ady +- var det = adz * (bdxcdy - cdxbdy) +- + bdz * (cdxady - adxcdy) +- + cdz * (adxbdy - bdxady) +- var permanent = (Math.abs(bdxcdy) + Math.abs(cdxbdy)) * Math.abs(adz) +- + (Math.abs(cdxady) + Math.abs(adxcdy)) * Math.abs(bdz) +- + (Math.abs(adxbdy) + Math.abs(bdxady)) * Math.abs(cdz) +- var tol = ERRBOUND4 * permanent +- if ((det > tol) || (-det > tol)) { +- return det ++ queue.push(new Item(fun, args)); ++ if (queue.length === 1 && !draining) { ++ runTimeout(drainQueue); + } +- return orientation4Exact(a,b,c,d) +- } +-] ++}; + +-function slowOrient(args) { +- var proc = CACHED[args.length] +- if(!proc) { +- proc = CACHED[args.length] = orientation(args.length) +- } +- return proc.apply(undefined, args) ++// v8 likes predictible objects ++function Item(fun, array) { ++ this.fun = fun; ++ this.array = array; + } ++Item.prototype.run = function () { ++ this.fun.apply(null, this.array); ++}; ++process.title = 'browser'; ++process.browser = true; ++process.env = {}; ++process.argv = []; ++process.version = ''; // empty string to avoid regexp issues ++process.versions = {}; + +-function generateOrientationProc() { +- while(CACHED.length <= NUM_EXPAND) { +- CACHED.push(orientation(CACHED.length)) +- } +- var args = [] +- var procArgs = ["slow"] +- for(var i=0; i<=NUM_EXPAND; ++i) { +- args.push("a" + i) +- procArgs.push("o" + i) +- } +- var code = [ +- "function getOrientation(", args.join(), "){switch(arguments.length){case 0:case 1:return 0;" +- ] +- for(var i=2; i<=NUM_EXPAND; ++i) { +- code.push("case ", i, ":return o", i, "(", args.slice(0, i).join(), ");") +- } +- code.push("}var s=new Array(arguments.length);for(var i=0;i= nf)) { +- a = ei +- eptr += 1 +- if(eptr < ne) { +- ei = e[eptr] +- ea = abs(ei) +- } +- } else { +- a = fi +- fptr += 1 +- if(fptr < nf) { +- fi = -f[fptr] +- fa = abs(fi) +- } +- } +- var x = a + b +- var bv = x - a +- var y = b - bv +- var q0 = y +- var q1 = x +- var _x, _bv, _av, _br, _ar +- while(eptr < ne && fptr < nf) { +- if(ea < fa) { +- a = ei +- eptr += 1 +- if(eptr < ne) { +- ei = e[eptr] +- ea = abs(ei) +- } +- } else { +- a = fi +- fptr += 1 +- if(fptr < nf) { +- fi = -f[fptr] +- fa = abs(fi) +- } +- } +- b = q0 +- x = a + b +- bv = x - a +- y = b - bv +- if(y) { +- g[count++] = y +- } +- _x = q1 + x +- _bv = _x - q1 +- _av = _x - _bv +- _br = x - _bv +- _ar = q1 - _av +- q0 = _ar + _br +- q1 = _x ++},{"big-rat":21,"big-rat/mul":30}],210:[function(require,module,exports){ ++'use strict' ++ ++var bnsub = require('big-rat/sub') ++ ++module.exports = sub ++ ++function sub(a, b) { ++ var n = a.length ++ var r = new Array(n) ++ for(var i=0; i 0) { ++ var f = cells[ptr-1] ++ if(compareCell(c, f) === 0 && ++ orientation(f) !== o) { ++ ptr -= 1 ++ continue ++ } + } ++ cells[ptr++] = c + } +- if(q0) { +- g[count++] = q0 +- } +- if(q1) { +- g[count++] = q1 ++ cells.length = ptr ++ return cells ++} ++ ++},{"cell-orientation":54,"compare-cell":63,"compare-oriented-cell":64}],212:[function(require,module,exports){ ++/*! ++ * repeat-string ++ * ++ * Copyright (c) 2014-2015, Jon Schlinkert. ++ * Licensed under the MIT License. ++ */ ++ ++'use strict'; ++ ++/** ++ * Results cache ++ */ ++ ++var res = ''; ++var cache; ++ ++/** ++ * Expose `repeat` ++ */ ++ ++module.exports = repeat; ++ ++/** ++ * Repeat the given `string` the specified `number` ++ * of times. ++ * ++ * **Example:** ++ * ++ * ```js ++ * var repeat = require('repeat-string'); ++ * repeat('A', 5); ++ * //=> AAAAA ++ * ``` ++ * ++ * @param {String} `string` The string to repeat ++ * @param {Number} `number` The number of times to repeat the string ++ * @return {String} Repeated string ++ * @api public ++ */ ++ ++function repeat(str, num) { ++ if (typeof str !== 'string') { ++ throw new TypeError('repeat-string expects a string.'); + } +- if(!count) { +- g[count++] = 0.0 ++ ++ // cover common, quick use cases ++ if (num === 1) return str; ++ if (num === 2) return str + str; ++ ++ var max = str.length * num; ++ if (cache !== str || typeof cache === 'undefined') { ++ cache = str; ++ res = ''; + } +- g.length = count +- return g +-} +-},{}],228:[function(require,module,exports){ +-"use strict" + +-module.exports = linearExpansionSum ++ while (max > res.length && num > 0) { ++ if (num & 1) { ++ res += str; ++ } + +-//Easy case: Add two scalars +-function scalarScalar(a, b) { +- var x = a + b +- var bv = x - a +- var av = x - bv +- var br = b - bv +- var ar = a - av +- var y = ar + br +- if(y) { +- return [y, x] ++ num >>= 1; ++ if (!num) break; ++ str += str; + } +- return [x] ++ ++ return res.substr(0, max); + } + +-function linearExpansionSum(e, f) { +- var ne = e.length|0 +- var nf = f.length|0 +- if(ne === 1 && nf === 1) { +- return scalarScalar(e[0], f[0]) ++ ++},{}],213:[function(require,module,exports){ ++(function (global){ ++module.exports = ++ global.performance && ++ global.performance.now ? function now() { ++ return performance.now() ++ } : Date.now || function now() { ++ return +new Date + } +- var n = ne + nf +- var g = new Array(n) +- var count = 0 +- var eptr = 0 +- var fptr = 0 +- var abs = Math.abs +- var ei = e[eptr] +- var ea = abs(ei) +- var fi = f[fptr] +- var fa = abs(fi) +- var a, b +- if(ea < fa) { +- b = ei +- eptr += 1 +- if(eptr < ne) { +- ei = e[eptr] +- ea = abs(ei) +- } +- } else { +- b = fi +- fptr += 1 +- if(fptr < nf) { +- fi = f[fptr] +- fa = abs(fi) ++ ++}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) ++},{}],214:[function(require,module,exports){ ++"use strict" ++ ++module.exports = compressExpansion ++ ++function compressExpansion(e) { ++ var m = e.length ++ var Q = e[e.length-1] ++ var bottom = m ++ for(var i=m-2; i>=0; --i) { ++ var a = Q ++ var b = e[i] ++ Q = a + b ++ var bv = Q - a ++ var q = b - bv ++ if(q) { ++ e[--bottom] = Q ++ Q = q + } + } +- if((eptr < ne && ea < fa) || (fptr >= nf)) { +- a = ei +- eptr += 1 +- if(eptr < ne) { +- ei = e[eptr] +- ea = abs(ei) +- } +- } else { +- a = fi +- fptr += 1 +- if(fptr < nf) { +- fi = f[fptr] +- fa = abs(fi) ++ var top = 0 ++ for(var i=bottom; i>1 ++ return ["sum(", generateSum(expr.slice(0, m)), ",", generateSum(expr.slice(m)), ")"].join("") + } +- g.length = count +- return g + } +-},{}],229:[function(require,module,exports){ +-'use strict' + +-module.exports = toSuperScript ++function determinant(m) { ++ if(m.length === 2) { ++ return ["sum(prod(", m[0][0], ",", m[1][1], "),prod(-", m[0][1], ",", m[1][0], "))"].join("") ++ } else { ++ var expr = [] ++ for(var i=0; i>1 ++ return ["sum(", generateSum(expr.slice(0, m)), ",", generateSum(expr.slice(m)), ")"].join("") ++ } + } +-function pcube(bitmask) { +- return "b" + bitmask ++ ++function makeProduct(a, b) { ++ if(a.charAt(0) === "m") { ++ if(b.charAt(0) === "w") { ++ var toks = a.split("[") ++ return ["w", b.substr(1), "m", toks[0].substr(1)].join("") ++ } else { ++ return ["prod(", a, ",", b, ")"].join("") ++ } ++ } else { ++ return makeProduct(b, a) ++ } + } +-function qcube(bitmask) { +- return "y" + bitmask ++ ++function sign(s) { ++ if(s & 1 !== 0) { ++ return "-" ++ } ++ return "" + } +-function pdelta(bitmask) { +- return "e" + bitmask ++ ++function determinant(m) { ++ if(m.length === 2) { ++ return [["diff(", makeProduct(m[0][0], m[1][1]), ",", makeProduct(m[1][0], m[0][1]), ")"].join("")] ++ } else { ++ var expr = [] ++ for(var i=0; i 0) { ++ code.push(",") ++ } ++ code.push("[") ++ for(var k=0; k 0) { ++ code.push(",") ++ } ++ if(k === i) { ++ code.push("+b[", j, "]") ++ } else { ++ code.push("+A[", j, "][", k, "]") + } + } +- vars.push(delta(i,j) + "=(" + ptrStr.join("") + ")|0") +- vars.push(cube(i,j) + "=0") ++ code.push("]") + } ++ code.push("]),") + } +- //Create step variables +- for(var i=0; i 0) { +- stepVal.push(stride(i, order[j-1]) + "*" + shape(order[j-1]) ) +- } +- vars.push(step(i,order[j]) + "=(" + stepVal.join("-") + ")|0") +- } ++ code.push("det(A)]}return ", funcName) ++ var proc = new Function("det", code.join("")) ++ if(n < 6) { ++ return proc(determinant[n]) + } +- //Create index variables +- for(var i=0; i=0; --i) { +- sizeVariable.push(shape(order[i])) ++ var procArgs = [] ++ var code = ["function dispatchLinearSolve(A,b){switch(A.length){"] ++ for(var i=0; i=0; --i) { +- forLoopBegin(i, 0) +- } +- var phaseFuncArgs = [] +- for(var i=0; i>1 ++ return ["sum(", generateSum(expr.slice(0, m)), ",", generateSum(expr.slice(m)), ")"].join("") + } ++} + +- function processGridCell(mask) { +- //Read in local data +- for(var i=0; i 0) { ++ if(r <= 0) { ++ return det ++ } else { ++ s = l + r ++ } ++ } else if(l < 0) { ++ if(r >= 0) { ++ return det ++ } else { ++ s = -(l + r) + } ++ } else { ++ return det + } +- for(var i=0; i<(1<= tol || det <= -tol) { ++ return det + } +- for(var i=0; i tol) || (-det > tol)) { ++ return det + } ++ return orientation4Exact(a,b,c,d) ++ } ++] + +- //Generate vertex +- code.push("vertex(", vertexArgs.join(), ");", +- vert(0), "=", VERTEX_IDS, "[", POINTER, "]=", VERTEX_COUNT, "++;") +- +- //Check for face crossings +- var base = (1<0; k=(k-1)&subset) { +- faceArgs.push(VERTEX_IDS + "[" + POINTER + "+" + pdelta(k) + "]") +- } +- faceArgs.push(vert(0)) +- for(var k=0; k0){", +- index(order[i]), "=1;") +- createLoop(i-1, mask|(1< 0") ++ return r ++} ++},{"robust-scale":221,"robust-sum":224}],221:[function(require,module,exports){ ++"use strict" ++ ++var twoProduct = require("two-product") ++var twoSum = require("two-sum") ++ ++module.exports = scaleLinearExpansion ++ ++function scaleLinearExpansion(e, scale) { ++ var n = e.length ++ if(n === 1) { ++ var ts = twoProduct(e[0], scale) ++ if(ts[0]) { ++ return ts ++ } ++ return [ ts[1] ] + } +- if(typeof args.vertex !== "function") { +- error("Must specify vertex creation function") ++ var g = new Array(2 * n) ++ var q = [0.1, 0.1] ++ var t = [0.1, 0.1] ++ var count = 0 ++ twoProduct(e[0], scale, q) ++ if(q[0]) { ++ g[count++] = q[0] + } +- if(typeof args.cell !== "function") { +- error("Must specify cell creation function") ++ for(var i=1; i= 0) { +- typesig[i] = true +- } else { +- typesig[i] = false +- } ++ if(count === 0) { ++ g[count++] = 0.0 + } +- return compileSurfaceProcedure( +- args.vertex, +- args.cell, +- args.phase, +- scalars, +- order, +- typesig) ++ g.length = count ++ return g + } +-},{"typedarray-pool":242}],231:[function(require,module,exports){ +-// transliterated from the python snippet here: +-// http://en.wikipedia.org/wiki/Lanczos_approximation ++},{"two-product":244,"two-sum":245}],222:[function(require,module,exports){ ++"use strict" + +-var g = 7; +-var p = [ +- 0.99999999999980993, +- 676.5203681218851, +- -1259.1392167224028, +- 771.32342877765313, +- -176.61502916214059, +- 12.507343278686905, +- -0.13857109526572012, +- 9.9843695780195716e-6, +- 1.5056327351493116e-7 +-]; ++module.exports = segmentsIntersect + +-var g_ln = 607/128; +-var p_ln = [ +- 0.99999999999999709182, +- 57.156235665862923517, +- -59.597960355475491248, +- 14.136097974741747174, +- -0.49191381609762019978, +- 0.33994649984811888699e-4, +- 0.46523628927048575665e-4, +- -0.98374475304879564677e-4, +- 0.15808870322491248884e-3, +- -0.21026444172410488319e-3, +- 0.21743961811521264320e-3, +- -0.16431810653676389022e-3, +- 0.84418223983852743293e-4, +- -0.26190838401581408670e-4, +- 0.36899182659531622704e-5 +-]; ++var orient = require("robust-orientation")[3] + +-// Spouge approximation (suitable for large arguments) +-function lngamma(z) { ++function checkCollinear(a0, a1, b0, b1) { + +- if(z < 0) return Number('0/0'); +- var x = p_ln[0]; +- for(var i = p_ln.length - 1; i > 0; --i) x += p_ln[i] / (z + i); +- var t = z + g_ln + 0.5; +- return .5*Math.log(2*Math.PI)+(z+.5)*Math.log(t)-t+Math.log(x)-Math.log(z); +-} ++ for(var d=0; d<2; ++d) { ++ var x0 = a0[d] ++ var y0 = a1[d] ++ var l0 = Math.min(x0, y0) ++ var h0 = Math.max(x0, y0) + +-module.exports = function gamma (z) { +- if (z < 0.5) { +- return Math.PI / (Math.sin(Math.PI * z) * gamma(1 - z)); +- } +- else if(z > 100) return Math.exp(lngamma(z)); +- else { +- z -= 1; +- var x = p[0]; +- for (var i = 1; i < g + 2; i++) { +- x += p[i] / (z + i); +- } +- var t = z + g + 0.5; ++ var x1 = b0[d] ++ var y1 = b1[d] ++ var l1 = Math.min(x1, y1) ++ var h1 = Math.max(x1, y1) + +- return Math.sqrt(2 * Math.PI) +- * Math.pow(t, z + 0.5) +- * Math.exp(-t) +- * x +- ; ++ if(h1 < l0 || h0 < l1) { ++ return false + } +-}; +- +-module.exports.log = lngamma; +- +-},{}],232:[function(require,module,exports){ +-"use strict" ++ } + +-module.exports = permutationSign ++ return true ++} + +-var BRUTE_FORCE_CUTOFF = 32 ++function segmentsIntersect(a0, a1, b0, b1) { ++ var x0 = orient(a0, b0, b1) ++ var y0 = orient(a1, b0, b1) ++ if((x0 > 0 && y0 > 0) || (x0 < 0 && y0 < 0)) { ++ return false ++ } + +-var pool = require("typedarray-pool") ++ var x1 = orient(b0, a0, a1) ++ var y1 = orient(b1, a0, a1) ++ if((x1 > 0 && y1 > 0) || (x1 < 0 && y1 < 0)) { ++ return false ++ } + +-function permutationSign(p) { +- var n = p.length +- if(n < BRUTE_FORCE_CUTOFF) { +- //Use quadratic algorithm for small n +- var sgn = 1 +- for(var i=0; i0; --i) { +- t = pinv[i] +- s = p[i] +- p[i] = p[t] +- p[t] = s +- pinv[i] = pinv[s] +- pinv[s] = t +- r = (r + s) * i ++//Easy case: Add two scalars ++function scalarScalar(a, b) { ++ var x = a + b ++ var bv = x - a ++ var av = x - bv ++ var br = b - bv ++ var ar = a - av ++ var y = ar + br ++ if(y) { ++ return [y, x] + } +- pool.freeUint32(pinv) +- pool.freeUint32(p) +- return r ++ return [x] + } + +-function unrank(n, r, p) { +- switch(n) { +- case 0: +- if(p) { return p } +- return [] +- case 1: +- if(p) { +- p[0] = 0 +- return p +- } else { +- return [0] ++function robustSubtract(e, f) { ++ var ne = e.length|0 ++ var nf = f.length|0 ++ if(ne === 1 && nf === 1) { ++ return scalarScalar(e[0], -f[0]) ++ } ++ var n = ne + nf ++ var g = new Array(n) ++ var count = 0 ++ var eptr = 0 ++ var fptr = 0 ++ var abs = Math.abs ++ var ei = e[eptr] ++ var ea = abs(ei) ++ var fi = -f[fptr] ++ var fa = abs(fi) ++ var a, b ++ if(ea < fa) { ++ b = ei ++ eptr += 1 ++ if(eptr < ne) { ++ ei = e[eptr] ++ ea = abs(ei) ++ } ++ } else { ++ b = fi ++ fptr += 1 ++ if(fptr < nf) { ++ fi = -f[fptr] ++ fa = abs(fi) ++ } ++ } ++ if((eptr < ne && ea < fa) || (fptr >= nf)) { ++ a = ei ++ eptr += 1 ++ if(eptr < ne) { ++ ei = e[eptr] ++ ea = abs(ei) ++ } ++ } else { ++ a = fi ++ fptr += 1 ++ if(fptr < nf) { ++ fi = -f[fptr] ++ fa = abs(fi) ++ } ++ } ++ var x = a + b ++ var bv = x - a ++ var y = b - bv ++ var q0 = y ++ var q1 = x ++ var _x, _bv, _av, _br, _ar ++ while(eptr < ne && fptr < nf) { ++ if(ea < fa) { ++ a = ei ++ eptr += 1 ++ if(eptr < ne) { ++ ei = e[eptr] ++ ea = abs(ei) + } +- case 2: +- if(p) { +- if(r) { +- p[0] = 0 +- p[1] = 1 +- } else { +- p[0] = 1 +- p[1] = 0 +- } +- return p +- } else { +- return r ? [0,1] : [1,0] ++ } else { ++ a = fi ++ fptr += 1 ++ if(fptr < nf) { ++ fi = -f[fptr] ++ fa = abs(fi) + } +- default: +- break ++ } ++ b = q0 ++ x = a + b ++ bv = x - a ++ y = b - bv ++ if(y) { ++ g[count++] = y ++ } ++ _x = q1 + x ++ _bv = _x - q1 ++ _av = _x - _bv ++ _br = x - _bv ++ _ar = q1 - _av ++ q0 = _ar + _br ++ q1 = _x + } +- p = p || new Array(n) +- var s, t, i, nf=1 +- p[0] = 0 +- for(i=1; i0; --i) { +- s = (r / nf)|0 +- r = (r - s * nf)|0 +- nf = (nf / i)|0 +- t = p[i]|0 +- p[i] = p[s]|0 +- p[s] = t|0 ++ while(fptr < nf) { ++ a = fi ++ b = q0 ++ x = a + b ++ bv = x - a ++ y = b - bv ++ if(y) { ++ g[count++] = y ++ } ++ _x = q1 + x ++ _bv = _x - q1 ++ _av = _x - _bv ++ _br = x - _bv ++ _ar = q1 - _av ++ q0 = _ar + _br ++ q1 = _x ++ fptr += 1 ++ if(fptr < nf) { ++ fi = -f[fptr] ++ } ++ } ++ if(q0) { ++ g[count++] = q0 ++ } ++ if(q1) { ++ g[count++] = q1 ++ } ++ if(!count) { ++ g[count++] = 0.0 + } +- return p ++ g.length = count ++ return g + } +- +-exports.rank = rank +-exports.unrank = unrank +- +-},{"invert-permutation":234,"typedarray-pool":242}],234:[function(require,module,exports){ ++},{}],224:[function(require,module,exports){ + "use strict" + +-function invertPermutation(pi, result) { +- result = result || new Array(pi.length) +- for(var i=0; i= nf)) { ++ a = ei ++ eptr += 1 ++ if(eptr < ne) { ++ ei = e[eptr] ++ ea = abs(ei) + } +- if(sgn(p) < 1) { +- cell[0] = v +- cell[dimension] = 0 ++ } else { ++ a = fi ++ fptr += 1 ++ if(fptr < nf) { ++ fi = f[fptr] ++ fa = abs(fi) + } +- result.push(cell) + } +- return result ++ var x = a + b ++ var bv = x - a ++ var y = b - bv ++ var q0 = y ++ var q1 = x ++ var _x, _bv, _av, _br, _ar ++ while(eptr < ne && fptr < nf) { ++ if(ea < fa) { ++ a = ei ++ eptr += 1 ++ if(eptr < ne) { ++ ei = e[eptr] ++ ea = abs(ei) ++ } ++ } else { ++ a = fi ++ fptr += 1 ++ if(fptr < nf) { ++ fi = f[fptr] ++ fa = abs(fi) ++ } ++ } ++ b = q0 ++ x = a + b ++ bv = x - a ++ y = b - bv ++ if(y) { ++ g[count++] = y ++ } ++ _x = q1 + x ++ _bv = _x - q1 ++ _av = _x - _bv ++ _br = x - _bv ++ _ar = q1 - _av ++ q0 = _ar + _br ++ q1 = _x ++ } ++ while(eptr < ne) { ++ a = ei ++ b = q0 ++ x = a + b ++ bv = x - a ++ y = b - bv ++ if(y) { ++ g[count++] = y ++ } ++ _x = q1 + x ++ _bv = _x - q1 ++ _av = _x - _bv ++ _br = x - _bv ++ _ar = q1 - _av ++ q0 = _ar + _br ++ q1 = _x ++ eptr += 1 ++ if(eptr < ne) { ++ ei = e[eptr] ++ } ++ } ++ while(fptr < nf) { ++ a = fi ++ b = q0 ++ x = a + b ++ bv = x - a ++ y = b - bv ++ if(y) { ++ g[count++] = y ++ } ++ _x = q1 + x ++ _bv = _x - q1 ++ _av = _x - _bv ++ _br = x - _bv ++ _ar = q1 - _av ++ q0 = _ar + _br ++ q1 = _x ++ fptr += 1 ++ if(fptr < nf) { ++ fi = f[fptr] ++ } ++ } ++ if(q0) { ++ g[count++] = q0 ++ } ++ if(q1) { ++ g[count++] = q1 ++ } ++ if(!count) { ++ g[count++] = 0.0 ++ } ++ g.length = count ++ return g + } +-},{"gamma":231,"permutation-parity":232,"permutation-rank":233}],236:[function(require,module,exports){ +-module.exports = require('cwise-compiler')({ +- args: ['array', { +- offset: [1], +- array: 0 +- }, 'scalar', 'scalar', 'index'], +- pre: { +- "body": "{}", +- "args": [], +- "thisVars": [], +- "localVars": [] +- }, +- post: { +- "body": "{}", +- "args": [], +- "thisVars": [], +- "localVars": [] +- }, +- body: { +- "body": "{\n var _inline_1_da = _inline_1_arg0_ - _inline_1_arg3_\n var _inline_1_db = _inline_1_arg1_ - _inline_1_arg3_\n if((_inline_1_da >= 0) !== (_inline_1_db >= 0)) {\n _inline_1_arg2_.push(_inline_1_arg4_[0] + 0.5 + 0.5 * (_inline_1_da + _inline_1_db) / (_inline_1_da - _inline_1_db))\n }\n }", +- "args": [{ +- "name": "_inline_1_arg0_", +- "lvalue": false, +- "rvalue": true, +- "count": 1 +- }, { +- "name": "_inline_1_arg1_", +- "lvalue": false, +- "rvalue": true, +- "count": 1 +- }, { +- "name": "_inline_1_arg2_", +- "lvalue": false, +- "rvalue": true, +- "count": 1 +- }, { +- "name": "_inline_1_arg3_", +- "lvalue": false, +- "rvalue": true, +- "count": 2 +- }, { +- "name": "_inline_1_arg4_", +- "lvalue": false, +- "rvalue": true, +- "count": 1 +- }], +- "thisVars": [], +- "localVars": ["_inline_1_da", "_inline_1_db"] +- }, +- funcName: 'zeroCrossings' +-}) +- +-},{"cwise-compiler":96}],237:[function(require,module,exports){ ++},{}],225:[function(require,module,exports){ + "use strict" + +-module.exports = findZeroCrossings ++module.exports = function signum(x) { ++ if(x < 0) { return -1 } ++ if(x > 0) { return 1 } ++ return 0.0 ++} ++},{}],226:[function(require,module,exports){ ++'use strict' + +-var core = require("./lib/zc-core") ++module.exports = boundary + +-function findZeroCrossings(array, level) { +- var cross = [] +- level = +level || 0.0 +- core(array.hi(array.shape[0]-1), cross, level) +- return cross ++var bnd = require('boundary-cells') ++var reduce = require('reduce-simplicial-complex') ++ ++function boundary(cells) { ++ return reduce(bnd(cells)) + } +-},{"./lib/zc-core":236}],238:[function(require,module,exports){ +-"use strict" + +-module.exports = surfaceNets ++},{"boundary-cells":37,"reduce-simplicial-complex":211}],227:[function(require,module,exports){ ++'use strict' + +-var generateContourExtractor = require("ndarray-extract-contour") +-var triangulateCube = require("triangulate-hypercube") +-var zeroCrossings = require("zero-crossings") ++module.exports = extractContour + +-function buildSurfaceNets(order, dtype) { +- var dimension = order.length +- var code = ["'use strict';"] +- var funcName = "surfaceNets" + order.join("_") + "d" + dtype ++var ndarray = require('ndarray') ++var pool = require('typedarray-pool') ++var ndsort = require('ndarray-sort') + +- //Contour extraction function +- code.push( +- "var contour=genContour({", +- "order:[", order.join(), "],", +- "scalarArguments: 3,", +- "phase:function phaseFunc(p,a,b,c) { return (p > c)|0 },") +- if(dtype === "generic") { +- code.push("getters:[0],") +- } ++var contourAlgorithm = require('./lib/codegen') + +- //Generate vertex function +- var cubeArgs = [] +- var extraArgs = [] +- for(var i=0; i>>7){") ++ return d-1 ++} ++ ++function getSigns(values, level) { ++ var numVerts = values.length ++ var vertexSigns = pool.mallocUint8(numVerts) ++ for(var i=0; i 128) { +- if((i%128)===0) { +- if(extraFuncs.length > 0) { +- currentFunc.push("}}") +- } +- var efName = "vExtra" + extraFuncs.length +- code.push("case ", (i>>>7), ":", efName, "(m&0x7f,", extraArgs.join(), ");break;") +- currentFunc = [ +- "function ", efName, "(m,", extraArgs.join(), "){switch(m){" +- ] +- extraFuncs.push(currentFunc) +- } ++ return vertexSigns ++} ++ ++function getEdges(cells, d) { ++ var numCells = cells.length ++ var maxEdges = ((d * (d+1)/2) * numCells)|0 ++ var edges = pool.mallocUint32(maxEdges*2) ++ var ePtr = 0 ++ for(var i=0; i j) { +- continue +- } +- if(!(i&(1< 0) { +- cStr = "+" + crossingCount[k] + "*c" +- } +- var weight = 0.5 * (crossings[k].length / totalCrossings) +- var shift = 0.5 + 0.5 * (bias[k] / totalCrossings) +- vertexStr.push("d" + k + "-" + shift + "-" + weight + "*(" + crossings[k].join("+") + cStr + ")/(" + denoms[k].join("+") + ")") +- ++ var va = values[a] ++ var vb = values[b] ++ edata[2*ptr] = a ++ edata[2*ptr+1] = b ++ weights[ptr++] = (vb - level) / (vb - va) ++ } ++ edges.shape[0] = ptr ++ return ndarray(weights, [ptr]) ++} ++ ++function getCascade(edges, numVerts) { ++ var result = pool.mallocInt32(numVerts*2) ++ var numEdges = edges.shape[0] ++ var edata = edges.data ++ result[0] = 0 ++ var lastV = 0 ++ for(var i=0; i 0) { +- currentFunc.push("}}") ++ result[2*lastV+1] = numEdges ++ while(++lastV < numVerts) { ++ result[2*lastV] = result[2*lastV+1] = numEdges + } ++ return result ++} + +- //Create face function +- var faceArgs = [] +- for(var i=0; i<(1<<(dimension-1)); ++i) { +- faceArgs.push("v" + i) ++function unpackEdges(edges) { ++ var ne = edges.shape[0]|0 ++ var edata = edges.data ++ var result = new Array(ne) ++ for(var i=0; i>1,v=E[2*m+1];', ++ 'if(v===b){return m}', ++ 'if(b 0) { ++ code.push(',') ++ } ++ code.push('[') ++ for(var j=0; j 0) { ++ code.push(',') ++ } ++ code.push('B(C,E,c[', f[0], '],c[', f[1], '])') ++ } ++ code.push(']') ++ } ++ code.push(');') ++ } + +- color = (color) ? color : ''; +- opts = opts || { }; ++ for(var i=d+1; i>1; --i) { ++ if(i < d+1) { ++ code.push('else ') ++ } ++ code.push('if(l===', i, '){') + +- // If input is already a tinycolor, return itself +- if (color instanceof tinycolor) { +- return color; ++ //Generate mask ++ var maskStr = [] ++ for(var j=0; j= 0; +- var needsAlphaFormat = !formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "name"); ++//Finds a cell in a normalized cell complex ++function findCell(cells, c) { ++ var lo = 0 ++ , hi = cells.length-1 ++ , r = -1 ++ while (lo <= hi) { ++ var mid = (lo + hi) >> 1 ++ , s = compareCells(cells[mid], c) ++ if(s <= 0) { ++ if(s === 0) { ++ r = mid ++ } ++ lo = mid + 1 ++ } else if(s > 0) { ++ hi = mid - 1 ++ } ++ } ++ return r ++} ++exports.findCell = findCell; + +- if (needsAlphaFormat) { +- // Special case for "transparent", all other non-alpha formats +- // will return rgba when there is transparency. +- if (format === "name" && this._a === 0) { +- return this.toName(); +- } +- return this.toRgbString(); +- } +- if (format === "rgb") { +- formattedString = this.toRgbString(); +- } +- if (format === "prgb") { +- formattedString = this.toPercentageRgbString(); +- } +- if (format === "hex" || format === "hex6") { +- formattedString = this.toHexString(); +- } +- if (format === "hex3") { +- formattedString = this.toHexString(true); +- } +- if (format === "hex8") { +- formattedString = this.toHex8String(); +- } +- if (format === "name") { +- formattedString = this.toName(); ++//Builds an index for an n-cell. This is more general than dual, but less efficient ++function incidence(from_cells, to_cells) { ++ var index = new Array(from_cells.length) ++ for(var i=0, il=index.length; i= from_cells.length || compareCells(from_cells[idx], b) !== 0) { ++ break + } +- if (format === "hsv") { +- formattedString = this.toHsvString(); ++ } ++ } ++ } ++ return index ++} ++exports.incidence = incidence ++ ++//Computes the dual of the mesh. This is basically an optimized version of buildIndex for the situation where from_cells is just the list of vertices ++function dual(cells, vertex_count) { ++ if(!vertex_count) { ++ return incidence(unique(skeleton(cells, 0)), cells, 0) ++ } ++ var res = new Array(vertex_count) ++ for(var i=0; i>> k) & 1) { ++ b.push(c[k]) + } ++ } ++ result.push(b) ++ } ++ } ++ return normalize(result) ++} ++exports.explode = explode + +- return formattedString || this.toHexString(); +- }, +- clone: function() { +- return tinycolor(this.toString()); +- }, ++//Enumerates all of the n-cells of a cell complex ++function skeleton(cells, n) { ++ if(n < 0) { ++ return [] ++ } ++ var result = [] ++ , k0 = (1<<(n+1))-1 ++ for(var i=0; i ++module.exports = simplifyPolygon + +-// `rgbToRgb` +-// Handle bounds / percentage checking to conform to CSS color spec +-// +-// *Assumes:* r, g, b in [0, 255] or [0, 1] +-// *Returns:* { r, g, b } in [0, 255] +-function rgbToRgb(r, g, b){ +- return { +- r: bound01(r, 255) * 255, +- g: bound01(g, 255) * 255, +- b: bound01(b, 255) * 255 +- }; ++var orient = require("robust-orientation") ++var sc = require("simplicial-complex") ++ ++function errorWeight(base, a, b) { ++ var area = Math.abs(orient(base, a, b)) ++ var perim = Math.sqrt(Math.pow(a[0] - b[0], 2) + Math.pow(a[1]-b[1], 2)) ++ return area / perim + } + +-// `rgbToHsl` +-// Converts an RGB color value to HSL. +-// *Assumes:* r, g, and b are contained in [0, 255] or [0, 1] +-// *Returns:* { h, s, l } in [0,1] +-function rgbToHsl(r, g, b) { ++function simplifyPolygon(cells, positions, minArea) { + +- r = bound01(r, 255); +- g = bound01(g, 255); +- b = bound01(b, 255); ++ var n = positions.length ++ var nc = cells.length ++ var inv = new Array(n) ++ var outv = new Array(n) ++ var weights = new Array(n) ++ var dead = new Array(n) ++ ++ //Initialize tables ++ for(var i=0; i 0.5 ? d / (2 - max - min) : d / (max + min); +- switch(max) { +- case r: h = (g - b) / d + (g < b ? 6 : 0); break; +- case g: h = (b - r) / d + 2; break; +- case b: h = (r - g) / d + 4; break; ++ //TODO: Check that the line segment doesn't cross once simplified ++ var s = inv[i] ++ var t = outv[i] ++ if((s<0) || (t<0)) { ++ return Infinity ++ } else { ++ return errorWeight(positions[i], positions[s], positions[t]) ++ } ++ } ++ ++ //Swaps two nodes on the heap (i,j) are the index of the nodes ++ function heapSwap(i,j) { ++ var a = heap[i] ++ var b = heap[j] ++ heap[i] = b ++ heap[j] = a ++ index[a] = j ++ index[b] = i ++ } ++ ++ //Returns the weight of node i on the heap ++ function heapWeight(i) { ++ return weights[heap[i]] ++ } ++ ++ function heapParent(i) { ++ if(i & 1) { ++ return (i - 1) >> 1 ++ } ++ return (i >> 1) - 1 ++ } ++ ++ //Bubble element i down the heap ++ function heapDown(i) { ++ var w = heapWeight(i) ++ while(true) { ++ var tw = w ++ var left = 2*i + 1 ++ var right = 2*(i + 1) ++ var next = i ++ if(left < heapCount) { ++ var lw = heapWeight(left) ++ if(lw < tw) { ++ next = left ++ tw = lw ++ } ++ } ++ if(right < heapCount) { ++ var rw = heapWeight(right) ++ if(rw < tw) { ++ next = right + } ++ } ++ if(next === i) { ++ return i ++ } ++ heapSwap(i, next) ++ i = next ++ } ++ } + +- h /= 6; ++ //Bubbles element i up the heap ++ function heapUp(i) { ++ var w = heapWeight(i) ++ while(i > 0) { ++ var parent = heapParent(i) ++ if(parent >= 0) { ++ var pw = heapWeight(parent) ++ if(w < pw) { ++ heapSwap(i, parent) ++ i = parent ++ continue ++ } ++ } ++ return i + } ++ } + +- return { h: h, s: s, l: l }; +-} ++ //Pop minimum element ++ function heapPop() { ++ if(heapCount > 0) { ++ var head = heap[0] ++ heapSwap(0, heapCount-1) ++ heapCount -= 1 ++ heapDown(0) ++ return head ++ } ++ return -1 ++ } + +-// `hslToRgb` +-// Converts an HSL color value to RGB. +-// *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100] +-// *Returns:* { r, g, b } in the set [0, 255] +-function hslToRgb(h, s, l) { +- var r, g, b; ++ //Update heap item i ++ function heapUpdate(i, w) { ++ var a = heap[i] ++ if(weights[a] === w) { ++ return i ++ } ++ weights[a] = -Infinity ++ heapUp(i) ++ heapPop() ++ weights[a] = w ++ heapCount += 1 ++ return heapUp(heapCount-1) ++ } + +- h = bound01(h, 360); +- s = bound01(s, 100); +- l = bound01(l, 100); ++ //Kills a vertex (assume vertex already removed from heap) ++ function kill(i) { ++ if(dead[i]) { ++ return ++ } ++ //Kill vertex ++ dead[i] = true ++ //Fixup topology ++ var s = inv[i] ++ var t = outv[i] ++ if(inv[t] >= 0) { ++ inv[t] = s ++ } ++ if(outv[s] >= 0) { ++ outv[s] = t ++ } + +- function hue2rgb(p, q, t) { +- if(t < 0) t += 1; +- if(t > 1) t -= 1; +- if(t < 1/6) return p + (q - p) * 6 * t; +- if(t < 1/2) return q; +- if(t < 2/3) return p + (q - p) * (2/3 - t) * 6; +- return p; ++ //Update weights on s and t ++ if(index[s] >= 0) { ++ heapUpdate(index[s], computeWeight(s)) ++ } ++ if(index[t] >= 0) { ++ heapUpdate(index[t], computeWeight(t)) + } ++ } + +- if(s === 0) { +- r = g = b = l; // achromatic ++ //Initialize weights and heap ++ var heap = [] ++ var index = new Array(n) ++ for(var i=0; i>1; i>=0; --i) { ++ heapDown(i) ++ } ++ ++ //Kill vertices ++ while(true) { ++ var hmin = heapPop() ++ if((hmin < 0) || (weights[hmin] > minArea)) { ++ break + } ++ kill(hmin) ++ } + +- return { r: r * 255, g: g * 255, b: b * 255 }; +-} +- +-// `rgbToHsv` +-// Converts an RGB color value to HSV +-// *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1] +-// *Returns:* { h, s, v } in [0,1] +-function rgbToHsv(r, g, b) { +- +- r = bound01(r, 255); +- g = bound01(g, 255); +- b = bound01(b, 255); +- +- var max = mathMax(r, g, b), min = mathMin(r, g, b); +- var h, s, v = max; +- +- var d = max - min; +- s = max === 0 ? 0 : d / max; +- +- if(max == min) { +- h = 0; // achromatic ++ //Build collapsed vertex table ++ var npositions = [] ++ for(var i=0; i= 0 && tout >= 0 && tin !== tout) { ++ var cin = index[tin] ++ var cout = index[tout] ++ if(cin !== cout) { ++ ncells.push([ cin, cout ]) ++ } ++ } ++ }) + +- var i = math.floor(h), +- f = h - i, +- p = v * (1 - s), +- q = v * (1 - f * s), +- t = v * (1 - (1 - f) * s), +- mod = i % 6, +- r = [v, q, p, p, t, v][mod], +- g = [t, v, v, q, p, p][mod], +- b = [p, p, t, v, v, q][mod]; ++ //Normalize result ++ sc.unique(sc.normalize(ncells)) + +- return { r: r * 255, g: g * 255, b: b * 255 }; ++ //Return final list of cells ++ return { ++ positions: npositions, ++ edges: ncells ++ } + } ++},{"robust-orientation":219,"simplicial-complex":231}],234:[function(require,module,exports){ ++"use strict" + +-// `rgbToHex` +-// Converts an RGB color to hex +-// Assumes r, g, and b are contained in the set [0, 255] +-// Returns a 3 or 6 character hex +-function rgbToHex(r, g, b, allow3Char) { ++module.exports = orderSegments + +- var hex = [ +- pad2(mathRound(r).toString(16)), +- pad2(mathRound(g).toString(16)), +- pad2(mathRound(b).toString(16)) +- ]; ++var orient = require("robust-orientation") + +- // Return a 3 character hex if possible +- if (allow3Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1)) { +- return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0); ++function horizontalOrder(a, b) { ++ var bl, br ++ if(b[0][0] < b[1][0]) { ++ bl = b[0] ++ br = b[1] ++ } else if(b[0][0] > b[1][0]) { ++ bl = b[1] ++ br = b[0] ++ } else { ++ var alo = Math.min(a[0][1], a[1][1]) ++ var ahi = Math.max(a[0][1], a[1][1]) ++ var blo = Math.min(b[0][1], b[1][1]) ++ var bhi = Math.max(b[0][1], b[1][1]) ++ if(ahi < blo) { ++ return ahi - blo + } +- +- return hex.join(""); ++ if(alo > bhi) { ++ return alo - bhi ++ } ++ return ahi - bhi ++ } ++ var al, ar ++ if(a[0][1] < a[1][1]) { ++ al = a[0] ++ ar = a[1] ++ } else { ++ al = a[1] ++ ar = a[0] ++ } ++ var d = orient(br, bl, al) ++ if(d) { ++ return d ++ } ++ d = orient(br, bl, ar) ++ if(d) { ++ return d ++ } ++ return ar - br + } + +-// `rgbaToHex` +-// Converts an RGBA color plus alpha transparency to hex +-// Assumes r, g, b and a are contained in the set [0, 255] +-// Returns an 8 character hex +-function rgbaToHex(r, g, b, a) { +- +- var hex = [ +- pad2(convertDecimalToHex(a)), +- pad2(mathRound(r).toString(16)), +- pad2(mathRound(g).toString(16)), +- pad2(mathRound(b).toString(16)) +- ]; +- +- return hex.join(""); ++function orderSegments(b, a) { ++ var al, ar ++ if(a[0][0] < a[1][0]) { ++ al = a[0] ++ ar = a[1] ++ } else if(a[0][0] > a[1][0]) { ++ al = a[1] ++ ar = a[0] ++ } else { ++ return horizontalOrder(a, b) ++ } ++ var bl, br ++ if(b[0][0] < b[1][0]) { ++ bl = b[0] ++ br = b[1] ++ } else if(b[0][0] > b[1][0]) { ++ bl = b[1] ++ br = b[0] ++ } else { ++ return -horizontalOrder(b, a) ++ } ++ var d1 = orient(al, ar, br) ++ var d2 = orient(al, ar, bl) ++ if(d1 < 0) { ++ if(d2 <= 0) { ++ return d1 ++ } ++ } else if(d1 > 0) { ++ if(d2 >= 0) { ++ return d1 ++ } ++ } else if(d2) { ++ return d2 ++ } ++ d1 = orient(br, bl, ar) ++ d2 = orient(br, bl, al) ++ if(d1 < 0) { ++ if(d2 <= 0) { ++ return d1 ++ } ++ } else if(d1 > 0) { ++ if(d2 >= 0) { ++ return d1 ++ } ++ } else if(d2) { ++ return d2 ++ } ++ return ar[0] - br[0] + } ++},{"robust-orientation":219}],235:[function(require,module,exports){ ++"use strict" + +-// `equals` +-// Can be called with any tinycolor input +-tinycolor.equals = function (color1, color2) { +- if (!color1 || !color2) { return false; } +- return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString(); +-}; ++module.exports = createSlabDecomposition + +-tinycolor.random = function() { +- return tinycolor.fromRatio({ +- r: mathRandom(), +- g: mathRandom(), +- b: mathRandom() +- }); +-}; ++var bounds = require("binary-search-bounds") ++var createRBTree = require("functional-red-black-tree") ++var orient = require("robust-orientation") ++var orderSegments = require("./lib/order-segments") + ++function SlabDecomposition(slabs, coordinates, horizontal) { ++ this.slabs = slabs ++ this.coordinates = coordinates ++ this.horizontal = horizontal ++} + +-// Modification Functions +-// ---------------------- +-// Thanks to less.js for some of the basics here +-// ++var proto = SlabDecomposition.prototype + +-function desaturate(color, amount) { +- amount = (amount === 0) ? 0 : (amount || 10); +- var hsl = tinycolor(color).toHsl(); +- hsl.s -= amount / 100; +- hsl.s = clamp01(hsl.s); +- return tinycolor(hsl); ++function compareHorizontal(e, y) { ++ return e.y - y + } + +-function saturate(color, amount) { +- amount = (amount === 0) ? 0 : (amount || 10); +- var hsl = tinycolor(color).toHsl(); +- hsl.s += amount / 100; +- hsl.s = clamp01(hsl.s); +- return tinycolor(hsl); ++function searchBucket(root, p) { ++ var lastNode = null ++ while(root) { ++ var seg = root.key ++ var l, r ++ if(seg[0][0] < seg[1][0]) { ++ l = seg[0] ++ r = seg[1] ++ } else { ++ l = seg[1] ++ r = seg[0] ++ } ++ var o = orient(l, r, p) ++ if(o < 0) { ++ root = root.left ++ } else if(o > 0) { ++ if(p[0] !== seg[1][0]) { ++ lastNode = root ++ root = root.right ++ } else { ++ var val = searchBucket(root.right, p) ++ if(val) { ++ return val ++ } ++ root = root.left ++ } ++ } else { ++ if(p[0] !== seg[1][0]) { ++ return root ++ } else { ++ var val = searchBucket(root.right, p) ++ if(val) { ++ return val ++ } ++ root = root.left ++ } ++ } ++ } ++ return lastNode + } + +-function greyscale(color) { +- return tinycolor(color).desaturate(100); ++proto.castUp = function(p) { ++ var bucket = bounds.le(this.coordinates, p[0]) ++ if(bucket < 0) { ++ return -1 ++ } ++ var root = this.slabs[bucket] ++ var hitNode = searchBucket(this.slabs[bucket], p) ++ var lastHit = -1 ++ if(hitNode) { ++ lastHit = hitNode.value ++ } ++ //Edge case: need to handle horizontal segments (sucks) ++ if(this.coordinates[bucket] === p[0]) { ++ var lastSegment = null ++ if(hitNode) { ++ lastSegment = hitNode.key ++ } ++ if(bucket > 0) { ++ var otherHitNode = searchBucket(this.slabs[bucket-1], p) ++ if(otherHitNode) { ++ if(lastSegment) { ++ if(orderSegments(otherHitNode.key, lastSegment) > 0) { ++ lastSegment = otherHitNode.key ++ lastHit = otherHitNode.value ++ } ++ } else { ++ lastHit = otherHitNode.value ++ lastSegment = otherHitNode.key ++ } ++ } ++ } ++ var horiz = this.horizontal[bucket] ++ if(horiz.length > 0) { ++ var hbucket = bounds.ge(horiz, p[1], compareHorizontal) ++ if(hbucket < horiz.length) { ++ var e = horiz[hbucket] ++ if(p[1] === e.y) { ++ if(e.closed) { ++ return e.index ++ } else { ++ while(hbucket < horiz.length-1 && horiz[hbucket+1].y === p[1]) { ++ hbucket = hbucket+1 ++ e = horiz[hbucket] ++ if(e.closed) { ++ return e.index ++ } ++ } ++ if(e.y === p[1] && !e.start) { ++ hbucket = hbucket+1 ++ if(hbucket >= horiz.length) { ++ return lastHit ++ } ++ e = horiz[hbucket] ++ } ++ } ++ } ++ //Check if e is above/below last segment ++ if(e.start) { ++ if(lastSegment) { ++ var o = orient(lastSegment[0], lastSegment[1], [p[0], e.y]) ++ if(lastSegment[0][0] > lastSegment[1][0]) { ++ o = -o ++ } ++ if(o > 0) { ++ lastHit = e.index ++ } ++ } else { ++ lastHit = e.index ++ } ++ } else if(e.y !== p[1]) { ++ lastHit = e.index ++ } ++ } ++ } ++ } ++ return lastHit + } + +-function lighten (color, amount) { +- amount = (amount === 0) ? 0 : (amount || 10); +- var hsl = tinycolor(color).toHsl(); +- hsl.l += amount / 100; +- hsl.l = clamp01(hsl.l); +- return tinycolor(hsl); ++function IntervalSegment(y, index, start, closed) { ++ this.y = y ++ this.index = index ++ this.start = start ++ this.closed = closed + } + +-function brighten(color, amount) { +- amount = (amount === 0) ? 0 : (amount || 10); +- var rgb = tinycolor(color).toRgb(); +- rgb.r = mathMax(0, mathMin(255, rgb.r - mathRound(255 * - (amount / 100)))); +- rgb.g = mathMax(0, mathMin(255, rgb.g - mathRound(255 * - (amount / 100)))); +- rgb.b = mathMax(0, mathMin(255, rgb.b - mathRound(255 * - (amount / 100)))); +- return tinycolor(rgb); ++function Event(x, segment, create, index) { ++ this.x = x ++ this.segment = segment ++ this.create = create ++ this.index = index + } + +-function darken (color, amount) { +- amount = (amount === 0) ? 0 : (amount || 10); +- var hsl = tinycolor(color).toHsl(); +- hsl.l -= amount / 100; +- hsl.l = clamp01(hsl.l); +- return tinycolor(hsl); +-} + +-// Spin takes a positive or negative amount within [-360, 360] indicating the change of hue. +-// Values outside of this range will be wrapped into this range. +-function spin(color, amount) { +- var hsl = tinycolor(color).toHsl(); +- var hue = (mathRound(hsl.h) + amount) % 360; +- hsl.h = hue < 0 ? 360 + hue : hue; +- return tinycolor(hsl); ++function createSlabDecomposition(segments) { ++ var numSegments = segments.length ++ var numEvents = 2 * numSegments ++ var events = new Array(numEvents) ++ for(var i=0; i ++var robustDot = require("robust-dot-product") ++var robustSum = require("robust-sum") + +-function complement(color) { +- var hsl = tinycolor(color).toHsl(); +- hsl.h = (hsl.h + 180) % 360; +- return tinycolor(hsl); +-} ++module.exports = splitPolygon ++module.exports.positive = positive ++module.exports.negative = negative + +-function triad(color) { +- var hsl = tinycolor(color).toHsl(); +- var h = hsl.h; +- return [ +- tinycolor(color), +- tinycolor({ h: (h + 120) % 360, s: hsl.s, l: hsl.l }), +- tinycolor({ h: (h + 240) % 360, s: hsl.s, l: hsl.l }) +- ]; ++function planeT(p, plane) { ++ var r = robustSum(robustDot(p, plane), [plane[plane.length-1]]) ++ return r[r.length-1] + } + +-function tetrad(color) { +- var hsl = tinycolor(color).toHsl(); +- var h = hsl.h; +- return [ +- tinycolor(color), +- tinycolor({ h: (h + 90) % 360, s: hsl.s, l: hsl.l }), +- tinycolor({ h: (h + 180) % 360, s: hsl.s, l: hsl.l }), +- tinycolor({ h: (h + 270) % 360, s: hsl.s, l: hsl.l }) +- ]; +-} + +-function splitcomplement(color) { +- var hsl = tinycolor(color).toHsl(); +- var h = hsl.h; +- return [ +- tinycolor(color), +- tinycolor({ h: (h + 72) % 360, s: hsl.s, l: hsl.l}), +- tinycolor({ h: (h + 216) % 360, s: hsl.s, l: hsl.l}) +- ]; ++//Can't do this exactly and emit a floating point result ++function lerpW(a, wa, b, wb) { ++ var d = wb - wa ++ var t = -wa / d ++ if(t < 0.0) { ++ t = 0.0 ++ } else if(t > 1.0) { ++ t = 1.0 ++ } ++ var ti = 1.0 - t ++ var n = a.length ++ var r = new Array(n) ++ for(var i=0; i> 1)) + 720) % 360; --results; ) { +- hsl.h = (hsl.h + part) % 360; +- ret.push(tinycolor(hsl)); ++function splitPolygon(points, plane) { ++ var pos = [] ++ var neg = [] ++ var a = planeT(points[points.length-1], plane) ++ for(var s=points[points.length-1], t=points[0], i=0; i 0) || (a > 0 && b < 0)) { ++ var p = lerpW(s, b, t, a) ++ pos.push(p) ++ neg.push(p.slice()) + } +- return ret; +-} +- +-function monochromatic(color, results) { +- results = results || 6; +- var hsv = tinycolor(color).toHsv(); +- var h = hsv.h, s = hsv.s, v = hsv.v; +- var ret = []; +- var modification = 1 / results; +- +- while (results--) { +- ret.push(tinycolor({ h: h, s: s, v: v})); +- v = (v + modification) % 1; ++ if(b < 0) { ++ neg.push(t.slice()) ++ } else if(b > 0) { ++ pos.push(t.slice()) ++ } else { ++ pos.push(t.slice()) ++ neg.push(t.slice()) + } +- +- return ret; ++ a = b ++ } ++ return { positive: pos, negative: neg } + } + +-// Utility Functions +-// --------------------- +- +-tinycolor.mix = function(color1, color2, amount) { +- amount = (amount === 0) ? 0 : (amount || 50); +- +- var rgb1 = tinycolor(color1).toRgb(); +- var rgb2 = tinycolor(color2).toRgb(); +- +- var p = amount / 100; +- var w = p * 2 - 1; +- var a = rgb2.a - rgb1.a; +- +- var w1; +- +- if (w * a == -1) { +- w1 = w; +- } else { +- w1 = (w + a) / (1 + w * a); ++function positive(points, plane) { ++ var pos = [] ++ var a = planeT(points[points.length-1], plane) ++ for(var s=points[points.length-1], t=points[0], i=0; i 0) || (a > 0 && b < 0)) { ++ pos.push(lerpW(s, b, t, a)) + } +- +- w1 = (w1 + 1) / 2; +- +- var w2 = 1 - w1; +- +- var rgba = { +- r: rgb2.r * w1 + rgb1.r * w2, +- g: rgb2.g * w1 + rgb1.g * w2, +- b: rgb2.b * w1 + rgb1.b * w2, +- a: rgb2.a * p + rgb1.a * (1 - p) +- }; +- +- return tinycolor(rgba); +-}; +- +- +-// Readability Functions +-// --------------------- +-// false +-// tinycolor.isReadable("#000", "#111",{level:"AA",size:"large"}) => false +-tinycolor.isReadable = function(color1, color2, wcag2) { +- var readability = tinycolor.readability(color1, color2); +- var wcag2Parms, out; +- +- out = false; +- +- wcag2Parms = validateWCAG2Parms(wcag2); +- switch (wcag2Parms.level + wcag2Parms.size) { +- case "AAsmall": +- case "AAAlarge": +- out = readability >= 4.5; +- break; +- case "AAlarge": +- out = readability >= 3; +- break; +- case "AAAsmall": +- out = readability >= 7; +- break; ++ if(b >= 0) { ++ pos.push(t.slice()) + } +- return out; +- +-}; +- +-// `mostReadable` +-// Given a base color and a list of possible foreground or background +-// colors for that base, returns the most readable color. +-// Optionally returns Black or White if the most readable color is unreadable. +-// *Example* +-// tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:false}).toHexString(); // "#112255" +-// tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:true}).toHexString(); // "#ffffff" +-// tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"large"}).toHexString(); // "#faf3f3" +-// tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"small"}).toHexString(); // "#ffffff" +-tinycolor.mostReadable = function(baseColor, colorList, args) { +- var bestColor = null; +- var bestScore = 0; +- var readability; +- var includeFallbackColors, level, size ; +- args = args || {}; +- includeFallbackColors = args.includeFallbackColors ; +- level = args.level; +- size = args.size; ++ a = b ++ } ++ return pos ++} + +- for (var i= 0; i < colorList.length ; i++) { +- readability = tinycolor.readability(baseColor, colorList[i]); +- if (readability > bestScore) { +- bestScore = readability; +- bestColor = tinycolor(colorList[i]); +- } ++function negative(points, plane) { ++ var neg = [] ++ var a = planeT(points[points.length-1], plane) ++ for(var s=points[points.length-1], t=points[0], i=0; i 0) || (a > 0 && b < 0)) { ++ neg.push(lerpW(s, b, t, a)) + } +- +- if (tinycolor.isReadable(baseColor, bestColor, {"level":level,"size":size}) || !includeFallbackColors) { +- return bestColor; ++ if(b <= 0) { ++ neg.push(t.slice()) + } +- else { +- args.includeFallbackColors=false; +- return tinycolor.mostReadable(baseColor,["#fff", "#000"],args); ++ a = b ++ } ++ return neg ++} ++},{"robust-dot-product":216,"robust-sum":224}],237:[function(require,module,exports){ ++(function(window) { ++ var re = { ++ not_string: /[^s]/, ++ number: /[diefg]/, ++ json: /[j]/, ++ not_json: /[^j]/, ++ text: /^[^\x25]+/, ++ modulo: /^\x25{2}/, ++ placeholder: /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijosuxX])/, ++ key: /^([a-z_][a-z_\d]*)/i, ++ key_access: /^\.([a-z_][a-z_\d]*)/i, ++ index_access: /^\[(\d+)\]/, ++ sign: /^[\+\-]/ + } +-}; + ++ function sprintf() { ++ var key = arguments[0], cache = sprintf.cache ++ if (!(cache[key] && cache.hasOwnProperty(key))) { ++ cache[key] = sprintf.parse(key) ++ } ++ return sprintf.format.call(null, cache[key], arguments) ++ } + +-// Big List of Colors +-// ------------------ +-// +-var names = tinycolor.names = { +- aliceblue: "f0f8ff", +- antiquewhite: "faebd7", +- aqua: "0ff", +- aquamarine: "7fffd4", +- azure: "f0ffff", +- beige: "f5f5dc", +- bisque: "ffe4c4", +- black: "000", +- blanchedalmond: "ffebcd", +- blue: "00f", +- blueviolet: "8a2be2", +- brown: "a52a2a", +- burlywood: "deb887", +- burntsienna: "ea7e5d", +- cadetblue: "5f9ea0", +- chartreuse: "7fff00", +- chocolate: "d2691e", +- coral: "ff7f50", +- cornflowerblue: "6495ed", +- cornsilk: "fff8dc", +- crimson: "dc143c", +- cyan: "0ff", +- darkblue: "00008b", +- darkcyan: "008b8b", +- darkgoldenrod: "b8860b", +- darkgray: "a9a9a9", +- darkgreen: "006400", +- darkgrey: "a9a9a9", +- darkkhaki: "bdb76b", +- darkmagenta: "8b008b", +- darkolivegreen: "556b2f", +- darkorange: "ff8c00", +- darkorchid: "9932cc", +- darkred: "8b0000", +- darksalmon: "e9967a", +- darkseagreen: "8fbc8f", +- darkslateblue: "483d8b", +- darkslategray: "2f4f4f", +- darkslategrey: "2f4f4f", +- darkturquoise: "00ced1", +- darkviolet: "9400d3", +- deeppink: "ff1493", +- deepskyblue: "00bfff", +- dimgray: "696969", +- dimgrey: "696969", +- dodgerblue: "1e90ff", +- firebrick: "b22222", +- floralwhite: "fffaf0", +- forestgreen: "228b22", +- fuchsia: "f0f", +- gainsboro: "dcdcdc", +- ghostwhite: "f8f8ff", +- gold: "ffd700", +- goldenrod: "daa520", +- gray: "808080", +- green: "008000", +- greenyellow: "adff2f", +- grey: "808080", +- honeydew: "f0fff0", +- hotpink: "ff69b4", +- indianred: "cd5c5c", +- indigo: "4b0082", +- ivory: "fffff0", +- khaki: "f0e68c", +- lavender: "e6e6fa", +- lavenderblush: "fff0f5", +- lawngreen: "7cfc00", +- lemonchiffon: "fffacd", +- lightblue: "add8e6", +- lightcoral: "f08080", +- lightcyan: "e0ffff", +- lightgoldenrodyellow: "fafad2", +- lightgray: "d3d3d3", +- lightgreen: "90ee90", +- lightgrey: "d3d3d3", +- lightpink: "ffb6c1", +- lightsalmon: "ffa07a", +- lightseagreen: "20b2aa", +- lightskyblue: "87cefa", +- lightslategray: "789", +- lightslategrey: "789", +- lightsteelblue: "b0c4de", +- lightyellow: "ffffe0", +- lime: "0f0", +- limegreen: "32cd32", +- linen: "faf0e6", +- magenta: "f0f", +- maroon: "800000", +- mediumaquamarine: "66cdaa", +- mediumblue: "0000cd", +- mediumorchid: "ba55d3", +- mediumpurple: "9370db", +- mediumseagreen: "3cb371", +- mediumslateblue: "7b68ee", +- mediumspringgreen: "00fa9a", +- mediumturquoise: "48d1cc", +- mediumvioletred: "c71585", +- midnightblue: "191970", +- mintcream: "f5fffa", +- mistyrose: "ffe4e1", +- moccasin: "ffe4b5", +- navajowhite: "ffdead", +- navy: "000080", +- oldlace: "fdf5e6", +- olive: "808000", +- olivedrab: "6b8e23", +- orange: "ffa500", +- orangered: "ff4500", +- orchid: "da70d6", +- palegoldenrod: "eee8aa", +- palegreen: "98fb98", +- paleturquoise: "afeeee", +- palevioletred: "db7093", +- papayawhip: "ffefd5", +- peachpuff: "ffdab9", +- peru: "cd853f", +- pink: "ffc0cb", +- plum: "dda0dd", +- powderblue: "b0e0e6", +- purple: "800080", +- rebeccapurple: "663399", +- red: "f00", +- rosybrown: "bc8f8f", +- royalblue: "4169e1", +- saddlebrown: "8b4513", +- salmon: "fa8072", +- sandybrown: "f4a460", +- seagreen: "2e8b57", +- seashell: "fff5ee", +- sienna: "a0522d", +- silver: "c0c0c0", +- skyblue: "87ceeb", +- slateblue: "6a5acd", +- slategray: "708090", +- slategrey: "708090", +- snow: "fffafa", +- springgreen: "00ff7f", +- steelblue: "4682b4", +- tan: "d2b48c", +- teal: "008080", +- thistle: "d8bfd8", +- tomato: "ff6347", +- turquoise: "40e0d0", +- violet: "ee82ee", +- wheat: "f5deb3", +- white: "fff", +- whitesmoke: "f5f5f5", +- yellow: "ff0", +- yellowgreen: "9acd32" +-}; ++ sprintf.format = function(parse_tree, argv) { ++ var cursor = 1, tree_length = parse_tree.length, node_type = "", arg, output = [], i, k, match, pad, pad_character, pad_length, is_positive = true, sign = "" ++ for (i = 0; i < tree_length; i++) { ++ node_type = get_type(parse_tree[i]) ++ if (node_type === "string") { ++ output[output.length] = parse_tree[i] ++ } ++ else if (node_type === "array") { ++ match = parse_tree[i] // convenience purposes only ++ if (match[2]) { // keyword argument ++ arg = argv[cursor] ++ for (k = 0; k < match[2].length; k++) { ++ if (!arg.hasOwnProperty(match[2][k])) { ++ throw new Error(sprintf("[sprintf] property '%s' does not exist", match[2][k])) ++ } ++ arg = arg[match[2][k]] ++ } ++ } ++ else if (match[1]) { // positional argument (explicit) ++ arg = argv[match[1]] ++ } ++ else { // positional argument (implicit) ++ arg = argv[cursor++] ++ } + +-// Make it easy to access colors via `hexNames[hex]` +-var hexNames = tinycolor.hexNames = flip(names); ++ if (get_type(arg) == "function") { ++ arg = arg() ++ } + ++ if (re.not_string.test(match[8]) && re.not_json.test(match[8]) && (get_type(arg) != "number" && isNaN(arg))) { ++ throw new TypeError(sprintf("[sprintf] expecting number but found %s", get_type(arg))) ++ } + +-// Utilities +-// --------- ++ if (re.number.test(match[8])) { ++ is_positive = arg >= 0 ++ } + +-// `{ 'name1': 'val1' }` becomes `{ 'val1': 'name1' }` +-function flip(o) { +- var flipped = { }; +- for (var i in o) { +- if (o.hasOwnProperty(i)) { +- flipped[o[i]] = i; ++ switch (match[8]) { ++ case "b": ++ arg = arg.toString(2) ++ break ++ case "c": ++ arg = String.fromCharCode(arg) ++ break ++ case "d": ++ case "i": ++ arg = parseInt(arg, 10) ++ break ++ case "j": ++ arg = JSON.stringify(arg, null, match[6] ? parseInt(match[6]) : 0) ++ break ++ case "e": ++ arg = match[7] ? arg.toExponential(match[7]) : arg.toExponential() ++ break ++ case "f": ++ arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg) ++ break ++ case "g": ++ arg = match[7] ? parseFloat(arg).toPrecision(match[7]) : parseFloat(arg) ++ break ++ case "o": ++ arg = arg.toString(8) ++ break ++ case "s": ++ arg = ((arg = String(arg)) && match[7] ? arg.substring(0, match[7]) : arg) ++ break ++ case "u": ++ arg = arg >>> 0 ++ break ++ case "x": ++ arg = arg.toString(16) ++ break ++ case "X": ++ arg = arg.toString(16).toUpperCase() ++ break ++ } ++ if (re.json.test(match[8])) { ++ output[output.length] = arg ++ } ++ else { ++ if (re.number.test(match[8]) && (!is_positive || match[3])) { ++ sign = is_positive ? "+" : "-" ++ arg = arg.toString().replace(re.sign, "") ++ } ++ else { ++ sign = "" ++ } ++ pad_character = match[4] ? match[4] === "0" ? "0" : match[4].charAt(1) : " " ++ pad_length = match[6] - (sign + arg).length ++ pad = match[6] ? (pad_length > 0 ? str_repeat(pad_character, pad_length) : "") : "" ++ output[output.length] = match[5] ? sign + arg + pad : (pad_character === "0" ? sign + pad + arg : pad + sign + arg) ++ } ++ } + } ++ return output.join("") + } +- return flipped; +-} + +-// Return a valid alpha value [0,1] with all invalid values being set to 1 +-function boundAlpha(a) { +- a = parseFloat(a); ++ sprintf.cache = {} + +- if (isNaN(a) || a < 0 || a > 1) { +- a = 1; ++ sprintf.parse = function(fmt) { ++ var _fmt = fmt, match = [], parse_tree = [], arg_names = 0 ++ while (_fmt) { ++ if ((match = re.text.exec(_fmt)) !== null) { ++ parse_tree[parse_tree.length] = match[0] ++ } ++ else if ((match = re.modulo.exec(_fmt)) !== null) { ++ parse_tree[parse_tree.length] = "%" ++ } ++ else if ((match = re.placeholder.exec(_fmt)) !== null) { ++ if (match[2]) { ++ arg_names |= 1 ++ var field_list = [], replacement_field = match[2], field_match = [] ++ if ((field_match = re.key.exec(replacement_field)) !== null) { ++ field_list[field_list.length] = field_match[1] ++ while ((replacement_field = replacement_field.substring(field_match[0].length)) !== "") { ++ if ((field_match = re.key_access.exec(replacement_field)) !== null) { ++ field_list[field_list.length] = field_match[1] ++ } ++ else if ((field_match = re.index_access.exec(replacement_field)) !== null) { ++ field_list[field_list.length] = field_match[1] ++ } ++ else { ++ throw new SyntaxError("[sprintf] failed to parse named argument key") ++ } ++ } ++ } ++ else { ++ throw new SyntaxError("[sprintf] failed to parse named argument key") ++ } ++ match[2] = field_list ++ } ++ else { ++ arg_names |= 2 ++ } ++ if (arg_names === 3) { ++ throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported") ++ } ++ parse_tree[parse_tree.length] = match ++ } ++ else { ++ throw new SyntaxError("[sprintf] unexpected placeholder") ++ } ++ _fmt = _fmt.substring(match[0].length) ++ } ++ return parse_tree + } + +- return a; +-} +- +-// Take input from [0, n] and return it as [0, 1] +-function bound01(n, max) { +- if (isOnePointZero(n)) { n = "100%"; } +- +- var processPercent = isPercentage(n); +- n = mathMin(max, mathMax(0, parseFloat(n))); +- +- // Automatically convert percentage into number +- if (processPercent) { +- n = parseInt(n * max, 10) / 100; ++ var vsprintf = function(fmt, argv, _argv) { ++ _argv = (argv || []).slice(0) ++ _argv.splice(0, 0, fmt) ++ return sprintf.apply(null, _argv) + } + +- // Handle floating point rounding errors +- if ((math.abs(n - max) < 0.000001)) { +- return 1; ++ /** ++ * helpers ++ */ ++ function get_type(variable) { ++ return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase() + } + +- // Convert into [0, 1] range if it isn't already +- return (n % max) / parseFloat(max); +-} ++ function str_repeat(input, multiplier) { ++ return Array(multiplier + 1).join(input) ++ } + +-// Force a number between 0 and 1 +-function clamp01(val) { +- return mathMin(1, mathMax(0, val)); +-} ++ /** ++ * export to either browser or node.js ++ */ ++ if (typeof exports !== "undefined") { ++ exports.sprintf = sprintf ++ exports.vsprintf = vsprintf ++ } ++ else { ++ window.sprintf = sprintf ++ window.vsprintf = vsprintf + +-// Parse a base-16 hex value into a base-10 integer +-function parseIntFromHex(val) { +- return parseInt(val, 16); +-} ++ if (typeof define === "function" && define.amd) { ++ define(function() { ++ return { ++ sprintf: sprintf, ++ vsprintf: vsprintf ++ } ++ }) ++ } ++ } ++})(typeof window === "undefined" ? this : window); + +-// Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1 +-// +-function isOnePointZero(n) { +- return typeof n == "string" && n.indexOf('.') != -1 && parseFloat(n) === 1; +-} ++},{}],238:[function(require,module,exports){ ++'use strict' + +-// Check to see if string passed in is a percentage +-function isPercentage(n) { +- return typeof n === "string" && n.indexOf('%') != -1; +-} ++module.exports = toSuperScript + +-// Force a hex value to have 2 characters +-function pad2(c) { +- return c.length == 1 ? '0' + c : '' + c; ++var SUPERSCRIPTS = { ++ ' ': ' ', ++ '0': '⁰', ++ '1': '¹', ++ '2': '²', ++ '3': '³', ++ '4': '⁴', ++ '5': '⁵', ++ '6': '⁶', ++ '7': '⁷', ++ '8': '⁸', ++ '9': '⁹', ++ '+': '⁺', ++ '-': '⁻', ++ 'a': 'ᵃ', ++ 'b': 'ᵇ', ++ 'c': 'ᶜ', ++ 'd': 'ᵈ', ++ 'e': 'ᵉ', ++ 'f': 'ᶠ', ++ 'g': 'ᵍ', ++ 'h': 'ʰ', ++ 'i': 'ⁱ', ++ 'j': 'ʲ', ++ 'k': 'ᵏ', ++ 'l': 'ˡ', ++ 'm': 'ᵐ', ++ 'n': 'ⁿ', ++ 'o': 'ᵒ', ++ 'p': 'ᵖ', ++ 'r': 'ʳ', ++ 's': 'ˢ', ++ 't': 'ᵗ', ++ 'u': 'ᵘ', ++ 'v': 'ᵛ', ++ 'w': 'ʷ', ++ 'x': 'ˣ', ++ 'y': 'ʸ', ++ 'z': 'ᶻ' + } + +-// Replace a decimal with it's percentage value +-function convertToPercentage(n) { +- if (n <= 1) { +- n = (n * 100) + "%"; ++function toSuperScript(x) { ++ return x.split('').map(function(c) { ++ if(c in SUPERSCRIPTS) { ++ return SUPERSCRIPTS[c] + } +- +- return n; +-} +- +-// Converts a decimal to a hex value +-function convertDecimalToHex(d) { +- return Math.round(parseFloat(d) * 255).toString(16); +-} +-// Converts a hex value to a decimal +-function convertHexToDecimal(h) { +- return (parseIntFromHex(h) / 255); ++ return '' ++ }).join('') + } + +-var matchers = (function() { +- +- // +- var CSS_INTEGER = "[-\\+]?\\d+%?"; +- +- // +- var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?"; +- +- // Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome. +- var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")"; ++},{}],239:[function(require,module,exports){ ++"use strict" + +- // Actual matching. +- // Parentheses and commas are optional, but not required. +- // Whitespace can take the place of commas or opening paren +- var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?"; +- var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?"; ++module.exports = surfaceNets + +- return { +- rgb: new RegExp("rgb" + PERMISSIVE_MATCH3), +- rgba: new RegExp("rgba" + PERMISSIVE_MATCH4), +- hsl: new RegExp("hsl" + PERMISSIVE_MATCH3), +- hsla: new RegExp("hsla" + PERMISSIVE_MATCH4), +- hsv: new RegExp("hsv" + PERMISSIVE_MATCH3), +- hsva: new RegExp("hsva" + PERMISSIVE_MATCH4), +- hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/, +- hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/, +- hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/ +- }; +-})(); ++var generateContourExtractor = require("ndarray-extract-contour") ++var triangulateCube = require("triangulate-hypercube") ++var zeroCrossings = require("zero-crossings") + +-// `stringInputToObject` +-// Permissive string parsing. Take in a number of formats, and output an object +-// based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}` +-function stringInputToObject(color) { ++function buildSurfaceNets(order, dtype) { ++ var dimension = order.length ++ var code = ["'use strict';"] ++ var funcName = "surfaceNets" + order.join("_") + "d" + dtype + +- color = color.replace(trimLeft,'').replace(trimRight, '').toLowerCase(); +- var named = false; +- if (names[color]) { +- color = names[color]; +- named = true; +- } +- else if (color == 'transparent') { +- return { r: 0, g: 0, b: 0, a: 0, format: "name" }; +- } ++ //Contour extraction function ++ code.push( ++ "var contour=genContour({", ++ "order:[", order.join(), "],", ++ "scalarArguments: 3,", ++ "phase:function phaseFunc(p,a,b,c) { return (p > c)|0 },") ++ if(dtype === "generic") { ++ code.push("getters:[0],") ++ } + +- // Try to match string input using regular expressions. +- // Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360] +- // Just return an object and let the conversion functions handle that. +- // This way the result will be the same whether the tinycolor is initialized with string or object. +- var match; +- if ((match = matchers.rgb.exec(color))) { +- return { r: match[1], g: match[2], b: match[3] }; +- } +- if ((match = matchers.rgba.exec(color))) { +- return { r: match[1], g: match[2], b: match[3], a: match[4] }; +- } +- if ((match = matchers.hsl.exec(color))) { +- return { h: match[1], s: match[2], l: match[3] }; +- } +- if ((match = matchers.hsla.exec(color))) { +- return { h: match[1], s: match[2], l: match[3], a: match[4] }; +- } +- if ((match = matchers.hsv.exec(color))) { +- return { h: match[1], s: match[2], v: match[3] }; +- } +- if ((match = matchers.hsva.exec(color))) { +- return { h: match[1], s: match[2], v: match[3], a: match[4] }; +- } +- if ((match = matchers.hex8.exec(color))) { +- return { +- a: convertHexToDecimal(match[1]), +- r: parseIntFromHex(match[2]), +- g: parseIntFromHex(match[3]), +- b: parseIntFromHex(match[4]), +- format: named ? "name" : "hex8" +- }; +- } +- if ((match = matchers.hex6.exec(color))) { +- return { +- r: parseIntFromHex(match[1]), +- g: parseIntFromHex(match[2]), +- b: parseIntFromHex(match[3]), +- format: named ? "name" : "hex" +- }; ++ //Generate vertex function ++ var cubeArgs = [] ++ var extraArgs = [] ++ for(var i=0; i>>7){") ++ } ++ for(var i=0; i<1<<(1< 128) { ++ if((i%128)===0) { ++ if(extraFuncs.length > 0) { ++ currentFunc.push("}}") ++ } ++ var efName = "vExtra" + extraFuncs.length ++ code.push("case ", (i>>>7), ":", efName, "(m&0x7f,", extraArgs.join(), ");break;") ++ currentFunc = [ ++ "function ", efName, "(m,", extraArgs.join(), "){switch(m){" ++ ] ++ extraFuncs.push(currentFunc) ++ } + } +- if ((match = matchers.hex3.exec(color))) { +- return { +- r: parseIntFromHex(match[1] + '' + match[1]), +- g: parseIntFromHex(match[2] + '' + match[2]), +- b: parseIntFromHex(match[3] + '' + match[3]), +- format: named ? "name" : "hex" +- }; ++ currentFunc.push("case ", (i&0x7f), ":") ++ var crossings = new Array(dimension) ++ var denoms = new Array(dimension) ++ var crossingCount = new Array(dimension) ++ var bias = new Array(dimension) ++ var totalCrossings = 0 ++ for(var j=0; j j) { ++ continue ++ } ++ if(!(i&(1< 0) { ++ cStr = "+" + crossingCount[k] + "*c" ++ } ++ var weight = 0.5 * (crossings[k].length / totalCrossings) ++ var shift = 0.5 + 0.5 * (bias[k] / totalCrossings) ++ vertexStr.push("d" + k + "-" + shift + "-" + weight + "*(" + crossings[k].join("+") + cStr + ")/(" + denoms[k].join("+") + ")") ++ ++ } + } +- return {"level":level, "size":size}; +-} +- +-// Node: Export function +-if (typeof module !== "undefined" && module.exports) { +- module.exports = tinycolor; +-} +-// AMD/requirejs: Define the module +-else if (typeof define === 'function' && define.amd) { +- define(function () {return tinycolor;}); +-} +-// Browser: Expose to window +-else { +- window.tinycolor = tinycolor; +-} +- +-})(); +- +-},{}],240:[function(require,module,exports){ +-"use strict" +- +-module.exports = twoProduct +- +-var SPLITTER = +(Math.pow(2, 27) + 1.0) +- +-function twoProduct(a, b, result) { +- var x = a * b +- +- var c = SPLITTER * a +- var abig = c - a +- var ahi = c - abig +- var alo = a - ahi +- +- var d = SPLITTER * b +- var bbig = d - b +- var bhi = d - bbig +- var blo = b - bhi ++ currentFunc.push("a.push([", vertexStr.join(), "]);", ++ "break;") ++ } ++ code.push("}},") ++ if(extraFuncs.length > 0) { ++ currentFunc.push("}}") ++ } + +- var err1 = x - (ahi * bhi) +- var err2 = err1 - (alo * bhi) +- var err3 = err2 - (ahi * blo) ++ //Create face function ++ var faceArgs = [] ++ for(var i=0; i<(1<<(dimension-1)); ++i) { ++ faceArgs.push("v" + i) ++ } ++ faceArgs.push("c0", "c1", "p0", "p1", "a", "b", "c") ++ code.push("cell:function cellFunc(", faceArgs.join(), "){") + +- var y = alo * blo - err3 ++ var facets = triangulateCube(dimension-1) ++ code.push("if(p0){b.push(", ++ facets.map(function(f) { ++ return "[" + f.map(function(v) { ++ return "v" + v ++ }) + "]" ++ }).join(), ")}else{b.push(", ++ facets.map(function(f) { ++ var e = f.slice() ++ e.reverse() ++ return "[" + e.map(function(v) { ++ return "v" + v ++ }) + "]" ++ }).join(), ++ ")}}});function ", funcName, "(array,level){var verts=[],cells=[];contour(array,verts,cells,level);return {positions:verts,cells:cells};} return ", funcName, ";") + +- if(result) { +- result[0] = y +- result[1] = x +- return result ++ for(var i=0; i= 0; ++ var needsAlphaFormat = !formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "hex4" || format === "hex8" || format === "name"); ++ ++ if (needsAlphaFormat) { ++ // Special case for "transparent", all other non-alpha formats ++ // will return rgba when there is transparency. ++ if (format === "name" && this._a === 0) { ++ return this.toName(); ++ } ++ return this.toRgbString(); ++ } ++ if (format === "rgb") { ++ formattedString = this.toRgbString(); ++ } ++ if (format === "prgb") { ++ formattedString = this.toPercentageRgbString(); ++ } ++ if (format === "hex" || format === "hex6") { ++ formattedString = this.toHexString(); ++ } ++ if (format === "hex3") { ++ formattedString = this.toHexString(true); ++ } ++ if (format === "hex4") { ++ formattedString = this.toHex8String(true); ++ } ++ if (format === "hex8") { ++ formattedString = this.toHex8String(); ++ } ++ if (format === "name") { ++ formattedString = this.toName(); ++ } ++ if (format === "hsl") { ++ formattedString = this.toHslString(); ++ } ++ if (format === "hsv") { ++ formattedString = this.toHsvString(); ++ } ++ ++ return formattedString || this.toHexString(); ++ }, ++ clone: function() { ++ return tinycolor(this.toString()); ++ }, ++ ++ _applyModification: function(fn, args) { ++ var color = fn.apply(null, [this].concat([].slice.call(args))); ++ this._r = color._r; ++ this._g = color._g; ++ this._b = color._b; ++ this.setAlpha(color._a); ++ return this; ++ }, ++ lighten: function() { ++ return this._applyModification(lighten, arguments); ++ }, ++ brighten: function() { ++ return this._applyModification(brighten, arguments); ++ }, ++ darken: function() { ++ return this._applyModification(darken, arguments); ++ }, ++ desaturate: function() { ++ return this._applyModification(desaturate, arguments); ++ }, ++ saturate: function() { ++ return this._applyModification(saturate, arguments); ++ }, ++ greyscale: function() { ++ return this._applyModification(greyscale, arguments); ++ }, ++ spin: function() { ++ return this._applyModification(spin, arguments); ++ }, ++ ++ _applyCombination: function(fn, args) { ++ return fn.apply(null, [this].concat([].slice.call(args))); ++ }, ++ analogous: function() { ++ return this._applyCombination(analogous, arguments); ++ }, ++ complement: function() { ++ return this._applyCombination(complement, arguments); ++ }, ++ monochromatic: function() { ++ return this._applyCombination(monochromatic, arguments); ++ }, ++ splitcomplement: function() { ++ return this._applyCombination(splitcomplement, arguments); ++ }, ++ triad: function() { ++ return this._applyCombination(triad, arguments); ++ }, ++ tetrad: function() { ++ return this._applyCombination(tetrad, arguments); + } +- } +- return null +-} ++}; + +-function mallocArrayBuffer(n) { +- var n = bits.nextPow2(n) +- var log_n = bits.log2(n) +- var d = DATA[log_n] +- if(d.length > 0) { +- return d.pop() +- } +- return new ArrayBuffer(n) +-} +-exports.mallocArrayBuffer = mallocArrayBuffer ++// If input is an object, force 1 into "1.0" to handle ratios properly ++// String input requires "1.0" as input, so 1 will be treated as 1 ++tinycolor.fromRatio = function(color, opts) { ++ if (typeof color == "object") { ++ var newColor = {}; ++ for (var i in color) { ++ if (color.hasOwnProperty(i)) { ++ if (i === "a") { ++ newColor[i] = color[i]; ++ } ++ else { ++ newColor[i] = convertToPercentage(color[i]); ++ } ++ } ++ } ++ color = newColor; ++ } + +-function mallocUint8(n) { +- return new Uint8Array(mallocArrayBuffer(n), 0, n) +-} +-exports.mallocUint8 = mallocUint8 ++ return tinycolor(color, opts); ++}; + +-function mallocUint16(n) { +- return new Uint16Array(mallocArrayBuffer(2*n), 0, n) +-} +-exports.mallocUint16 = mallocUint16 ++// Given a string or object, convert that input to RGB ++// Possible string inputs: ++// ++// "red" ++// "#f00" or "f00" ++// "#ff0000" or "ff0000" ++// "#ff000000" or "ff000000" ++// "rgb 255 0 0" or "rgb (255, 0, 0)" ++// "rgb 1.0 0 0" or "rgb (1, 0, 0)" ++// "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1" ++// "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1" ++// "hsl(0, 100%, 50%)" or "hsl 0 100% 50%" ++// "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1" ++// "hsv(0, 100%, 100%)" or "hsv 0 100% 100%" ++// ++function inputToRGB(color) { + +-function mallocUint32(n) { +- return new Uint32Array(mallocArrayBuffer(4*n), 0, n) +-} +-exports.mallocUint32 = mallocUint32 ++ var rgb = { r: 0, g: 0, b: 0 }; ++ var a = 1; ++ var s = null; ++ var v = null; ++ var l = null; ++ var ok = false; ++ var format = false; + +-function mallocInt8(n) { +- return new Int8Array(mallocArrayBuffer(n), 0, n) +-} +-exports.mallocInt8 = mallocInt8 ++ if (typeof color == "string") { ++ color = stringInputToObject(color); ++ } + +-function mallocInt16(n) { +- return new Int16Array(mallocArrayBuffer(2*n), 0, n) +-} +-exports.mallocInt16 = mallocInt16 ++ if (typeof color == "object") { ++ if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) { ++ rgb = rgbToRgb(color.r, color.g, color.b); ++ ok = true; ++ format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb"; ++ } ++ else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) { ++ s = convertToPercentage(color.s); ++ v = convertToPercentage(color.v); ++ rgb = hsvToRgb(color.h, s, v); ++ ok = true; ++ format = "hsv"; ++ } ++ else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) { ++ s = convertToPercentage(color.s); ++ l = convertToPercentage(color.l); ++ rgb = hslToRgb(color.h, s, l); ++ ok = true; ++ format = "hsl"; ++ } + +-function mallocInt32(n) { +- return new Int32Array(mallocArrayBuffer(4*n), 0, n) +-} +-exports.mallocInt32 = mallocInt32 ++ if (color.hasOwnProperty("a")) { ++ a = color.a; ++ } ++ } + +-function mallocFloat(n) { +- return new Float32Array(mallocArrayBuffer(4*n), 0, n) +-} +-exports.mallocFloat32 = exports.mallocFloat = mallocFloat ++ a = boundAlpha(a); + +-function mallocDouble(n) { +- return new Float64Array(mallocArrayBuffer(8*n), 0, n) ++ return { ++ ok: ok, ++ format: color.format || format, ++ r: mathMin(255, mathMax(rgb.r, 0)), ++ g: mathMin(255, mathMax(rgb.g, 0)), ++ b: mathMin(255, mathMax(rgb.b, 0)), ++ a: a ++ }; + } +-exports.mallocFloat64 = exports.mallocDouble = mallocDouble + +-function mallocUint8Clamped(n) { +- if(hasUint8C) { +- return new Uint8ClampedArray(mallocArrayBuffer(n), 0, n) +- } else { +- return mallocUint8(n) +- } +-} +-exports.mallocUint8Clamped = mallocUint8Clamped + +-function mallocDataView(n) { +- return new DataView(mallocArrayBuffer(n), 0, n) +-} +-exports.mallocDataView = mallocDataView ++// Conversion Functions ++// -------------------- + +-function mallocBuffer(n) { +- n = bits.nextPow2(n) +- var log_n = bits.log2(n) +- var cache = BUFFER[log_n] +- if(cache.length > 0) { +- return cache.pop() +- } +- return new Buffer(n) +-} +-exports.mallocBuffer = mallocBuffer ++// `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from: ++// + +-exports.clearCache = function clearCache() { +- for(var i=0; i<32; ++i) { +- POOL.UINT8[i].length = 0 +- POOL.UINT16[i].length = 0 +- POOL.UINT32[i].length = 0 +- POOL.INT8[i].length = 0 +- POOL.INT16[i].length = 0 +- POOL.INT32[i].length = 0 +- POOL.FLOAT[i].length = 0 +- POOL.DOUBLE[i].length = 0 +- POOL.UINT8C[i].length = 0 +- DATA[i].length = 0 +- BUFFER[i].length = 0 +- } ++// `rgbToRgb` ++// Handle bounds / percentage checking to conform to CSS color spec ++// ++// *Assumes:* r, g, b in [0, 255] or [0, 1] ++// *Returns:* { r, g, b } in [0, 255] ++function rgbToRgb(r, g, b){ ++ return { ++ r: bound01(r, 255) * 255, ++ g: bound01(g, 255) * 255, ++ b: bound01(b, 255) * 255 ++ }; + } +-}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer) +-},{"bit-twiddle":38,"buffer":39,"dup":102}],243:[function(require,module,exports){ +-"use strict" + +-function unique_pred(list, compare) { +- var ptr = 1 +- , len = list.length +- , a=list[0], b=list[0] +- for(var i=1; i 0.5 ? d / (2 - max - min) : d / (max + min); ++ switch(max) { ++ case r: h = (g - b) / d + (g < b ? 6 : 0); break; ++ case g: h = (b - r) / d + 2; break; ++ case b: h = (r - g) / d + 4; break; ++ } + +-function unique(list, compare, sorted) { +- if(list.length === 0) { +- return list +- } +- if(compare) { +- if(!sorted) { +- list.sort(compare) ++ h /= 6; + } +- return unique_pred(list, compare) +- } +- if(!sorted) { +- list.sort() +- } +- return unique_eq(list) +-} + +-module.exports = unique ++ return { h: h, s: s, l: l }; ++} + +-},{}],244:[function(require,module,exports){ +-"use strict" ++// `hslToRgb` ++// Converts an HSL color value to RGB. ++// *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100] ++// *Returns:* { r, g, b } in the set [0, 255] ++function hslToRgb(h, s, l) { ++ var r, g, b; + +-module.exports = createText ++ h = bound01(h, 360); ++ s = bound01(s, 100); ++ l = bound01(l, 100); + +-var vectorizeText = require("./lib/vtext") +-var defaultCanvas = null +-var defaultContext = null ++ function hue2rgb(p, q, t) { ++ if(t < 0) t += 1; ++ if(t > 1) t -= 1; ++ if(t < 1/6) return p + (q - p) * 6 * t; ++ if(t < 1/2) return q; ++ if(t < 2/3) return p + (q - p) * (2/3 - t) * 6; ++ return p; ++ } + +-if(typeof document !== 'undefined') { +- defaultCanvas = document.createElement('canvas') +- defaultCanvas.width = 8192 +- defaultCanvas.height = 1024 +- defaultContext = defaultCanvas.getContext("2d") +-} ++ if(s === 0) { ++ r = g = b = l; // achromatic ++ } ++ else { ++ var q = l < 0.5 ? l * (1 + s) : l + s - l * s; ++ var p = 2 * l - q; ++ r = hue2rgb(p, q, h + 1/3); ++ g = hue2rgb(p, q, h); ++ b = hue2rgb(p, q, h - 1/3); ++ } + +-function createText(str, options) { +- if((typeof options !== "object") || (options === null)) { +- options = {} +- } +- return vectorizeText( +- str, +- options.canvas || defaultCanvas, +- options.context || defaultContext, +- options) ++ return { r: r * 255, g: g * 255, b: b * 255 }; + } + +-},{"./lib/vtext":245}],245:[function(require,module,exports){ +-"use strict" ++// `rgbToHsv` ++// Converts an RGB color value to HSV ++// *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1] ++// *Returns:* { h, s, v } in [0,1] ++function rgbToHsv(r, g, b) { + +-module.exports = vectorizeText +-module.exports.processPixels = processPixels ++ r = bound01(r, 255); ++ g = bound01(g, 255); ++ b = bound01(b, 255); + +-var surfaceNets = require('surface-nets') +-var ndarray = require('ndarray') +-var simplify = require('simplify-planar-graph') +-var cleanPSLG = require('clean-pslg') +-var cdt2d = require('cdt2d') +-var toPolygonCrappy = require('planar-graph-to-polyline') ++ var max = mathMax(r, g, b), min = mathMin(r, g, b); ++ var h, s, v = max; + +-function transformPositions(positions, options, size) { +- var align = options.textAlign || "start" +- var baseline = options.textBaseline || "alphabetic" ++ var d = max - min; ++ s = max === 0 ? 0 : d / max; + +- var lo = [1<<30, 1<<30] +- var hi = [0,0] +- var n = positions.length +- for(var i=0; i 8192) { +- throw new Error("vectorize-text: String too long (sorry, this will get fixed later)") +- } +- var height = 3 * size +- if(canvas.height < height) { +- canvas.height = height +- } ++ // Return a 4 character hex if possible ++ if (allow4Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1) && hex[3].charAt(0) == hex[3].charAt(1)) { ++ return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0); ++ } + +- context.fillStyle = "#000" +- context.fillRect(0, 0, canvas.width, canvas.height) ++ return hex.join(""); ++} + +- context.fillStyle = "#fff" +- context.fillText(str, size, 2*size) ++// `rgbaToArgbHex` ++// Converts an RGBA color to an ARGB Hex8 string ++// Rarely used, but required for "toFilter()" ++function rgbaToArgbHex(r, g, b, a) { + +- //Cut pixels from image +- var pixelData = context.getImageData(0, 0, width, height) +- var pixels = ndarray(pixelData.data, [height, width, 4]) ++ var hex = [ ++ pad2(convertDecimalToHex(a)), ++ pad2(mathRound(r).toString(16)), ++ pad2(mathRound(g).toString(16)), ++ pad2(mathRound(b).toString(16)) ++ ]; + +- return pixels.pick(-1,-1,0).transpose(1,0) ++ return hex.join(""); + } + +-function getContour(pixels, doSimplify) { +- var contour = surfaceNets(pixels, 128) +- if(doSimplify) { +- return simplify(contour.cells, contour.positions, 0.25) +- } +- return { +- edges: contour.cells, +- positions: contour.positions +- } +-} ++// `equals` ++// Can be called with any tinycolor input ++tinycolor.equals = function (color1, color2) { ++ if (!color1 || !color2) { return false; } ++ return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString(); ++}; + +-function processPixelsImpl(pixels, options, size, simplify) { +- //Extract contour +- var contour = getContour(pixels, simplify) ++tinycolor.random = function() { ++ return tinycolor.fromRatio({ ++ r: mathRandom(), ++ g: mathRandom(), ++ b: mathRandom() ++ }); ++}; + +- //Apply warp to positions +- var positions = transformPositions(contour.positions, options, size) +- var edges = contour.edges +- var flip = "ccw" === options.orientation + +- //Clean up the PSLG, resolve self intersections, etc. +- cleanPSLG(positions, edges) ++// Modification Functions ++// ---------------------- ++// Thanks to less.js for some of the basics here ++// + +- //If triangulate flag passed, triangulate the result +- if(options.polygons || options.polygon || options.polyline) { +- var result = toPolygonCrappy(edges, positions) +- var nresult = new Array(result.length) +- for(var i=0; i + +-var e2a = require('edges-to-adjacency-list') ++function complement(color) { ++ var hsl = tinycolor(color).toHsl(); ++ hsl.h = (hsl.h + 180) % 360; ++ return tinycolor(hsl); ++} + +-function trimLeaves(edges, positions) { +- var adj = e2a(edges, positions.length) +- var live = new Array(positions.length) +- var nbhd = new Array(positions.length) ++function triad(color) { ++ var hsl = tinycolor(color).toHsl(); ++ var h = hsl.h; ++ return [ ++ tinycolor(color), ++ tinycolor({ h: (h + 120) % 360, s: hsl.s, l: hsl.l }), ++ tinycolor({ h: (h + 240) % 360, s: hsl.s, l: hsl.l }) ++ ]; ++} + +- var dead = [] +- for(var i=0; i 0) { +- var v = dead.pop() +- live[v] = false +- var n = adj[v] +- for(var i=0; i> 1)) + 720) % 360; --results; ) { ++ hsl.h = (hsl.h + part) % 360; ++ ret.push(tinycolor(hsl)); + } +- } +- +- return [ nedges, npositions ] ++ return ret; + } +-},{"edges-to-adjacency-list":247}],247:[function(require,module,exports){ +-"use strict" +- +-module.exports = edgeToAdjacency + +-var uniq = require("uniq") ++function monochromatic(color, results) { ++ results = results || 6; ++ var hsv = tinycolor(color).toHsv(); ++ var h = hsv.h, s = hsv.s, v = hsv.v; ++ var ret = []; ++ var modification = 1 / results; + +-function edgeToAdjacency(edges, numVertices) { +- var numEdges = edges.length +- if(typeof numVertices !== "number") { +- numVertices = 0 +- for(var i=0; i 0) { +- nextCell = adj[i][b][0] +- nextDir = i +- break +- } +- } +- nextVertex = nextCell[nextDir^1] ++// Readability Functions ++// --------------------- ++// 0) { +- nextCell = e +- nextVertex = p +- nextDir = dir +- } +- } +- } +- if(noCut) { +- return nextVertex +- } +- if(nextCell) { +- cut(nextCell, nextDir) +- } +- return nextVertex +- } ++// `contrast` ++// Analyze the 2 colors and returns the color contrast defined by (WCAG Version 2) ++tinycolor.readability = function(color1, color2) { ++ var c1 = tinycolor(color1); ++ var c2 = tinycolor(color2); ++ return (Math.max(c1.getLuminance(),c2.getLuminance())+0.05) / (Math.min(c1.getLuminance(),c2.getLuminance())+0.05); ++}; + +- function extractCycle(v, dir) { +- var e0 = adj[dir][v][0] +- var cycle = [v] +- cut(e0, dir) +- var u = e0[dir^1] +- var d0 = dir +- while(true) { +- while(u !== v) { +- cycle.push(u) +- u = next(cycle[cycle.length-2], u, false) +- } +- if(adj[0][v].length + adj[1][v].length === 0) { +- break +- } +- var a = cycle[cycle.length-1] +- var b = v +- var c = cycle[1] +- var d = next(a, b, true) +- if(compareAngle(positions[a], positions[b], positions[c], positions[d]) < 0) { +- break +- } +- cycle.push(v) +- u = next(a, b) ++// `isReadable` ++// Ensure that foreground and background color combinations meet WCAG2 guidelines. ++// The third argument is an optional Object. ++// the 'level' property states 'AA' or 'AAA' - if missing or invalid, it defaults to 'AA'; ++// the 'size' property states 'large' or 'small' - if missing or invalid, it defaults to 'small'. ++// If the entire object is absent, isReadable defaults to {level:"AA",size:"small"}. ++ ++// *Example* ++// tinycolor.isReadable("#000", "#111") => false ++// tinycolor.isReadable("#000", "#111",{level:"AA",size:"large"}) => false ++tinycolor.isReadable = function(color1, color2, wcag2) { ++ var readability = tinycolor.readability(color1, color2); ++ var wcag2Parms, out; ++ ++ out = false; ++ ++ wcag2Parms = validateWCAG2Parms(wcag2); ++ switch (wcag2Parms.level + wcag2Parms.size) { ++ case "AAsmall": ++ case "AAAlarge": ++ out = readability >= 4.5; ++ break; ++ case "AAlarge": ++ out = readability >= 3; ++ break; ++ case "AAAsmall": ++ out = readability >= 7; ++ break; + } +- return cycle +- } ++ return out; + +- function shouldGlue(pcycle, ncycle) { +- return (ncycle[1] === ncycle[ncycle.length-1]) +- } ++}; + +- for(var i=0; i 0) { +- var ni = adj[0][i].length +- var ncycle = extractCycle(i,j) +- if(shouldGlue(pcycle, ncycle)) { +- //Glue together trivial cycles +- pcycle.push.apply(pcycle, ncycle) +- } else { +- if(pcycle.length > 0) { +- cycles.push(pcycle) +- } +- pcycle = ncycle ++// `mostReadable` ++// Given a base color and a list of possible foreground or background ++// colors for that base, returns the most readable color. ++// Optionally returns Black or White if the most readable color is unreadable. ++// *Example* ++// tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:false}).toHexString(); // "#112255" ++// tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:true}).toHexString(); // "#ffffff" ++// tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"large"}).toHexString(); // "#faf3f3" ++// tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"small"}).toHexString(); // "#ffffff" ++tinycolor.mostReadable = function(baseColor, colorList, args) { ++ var bestColor = null; ++ var bestScore = 0; ++ var readability; ++ var includeFallbackColors, level, size ; ++ args = args || {}; ++ includeFallbackColors = args.includeFallbackColors ; ++ level = args.level; ++ size = args.size; ++ ++ for (var i= 0; i < colorList.length ; i++) { ++ readability = tinycolor.readability(baseColor, colorList[i]); ++ if (readability > bestScore) { ++ bestScore = readability; ++ bestColor = tinycolor(colorList[i]); + } +- } +- if(pcycle.length > 0) { +- cycles.push(pcycle) +- } + } +- } + +- //Combine paths and loops together +- return cycles +-} +-},{"compare-angle":249}],249:[function(require,module,exports){ +-"use strict" ++ if (tinycolor.isReadable(baseColor, bestColor, {"level":level,"size":size}) || !includeFallbackColors) { ++ return bestColor; ++ } ++ else { ++ args.includeFallbackColors=false; ++ return tinycolor.mostReadable(baseColor,["#fff", "#000"],args); ++ } ++}; + +-module.exports = compareAngle + +-var orient = require("robust-orientation") +-var sgn = require("signum") +-var twoSum = require("two-sum") +-var robustProduct = require("robust-product") +-var robustSum = require("robust-sum") ++// Big List of Colors ++// ------------------ ++// ++var names = tinycolor.names = { ++ aliceblue: "f0f8ff", ++ antiquewhite: "faebd7", ++ aqua: "0ff", ++ aquamarine: "7fffd4", ++ azure: "f0ffff", ++ beige: "f5f5dc", ++ bisque: "ffe4c4", ++ black: "000", ++ blanchedalmond: "ffebcd", ++ blue: "00f", ++ blueviolet: "8a2be2", ++ brown: "a52a2a", ++ burlywood: "deb887", ++ burntsienna: "ea7e5d", ++ cadetblue: "5f9ea0", ++ chartreuse: "7fff00", ++ chocolate: "d2691e", ++ coral: "ff7f50", ++ cornflowerblue: "6495ed", ++ cornsilk: "fff8dc", ++ crimson: "dc143c", ++ cyan: "0ff", ++ darkblue: "00008b", ++ darkcyan: "008b8b", ++ darkgoldenrod: "b8860b", ++ darkgray: "a9a9a9", ++ darkgreen: "006400", ++ darkgrey: "a9a9a9", ++ darkkhaki: "bdb76b", ++ darkmagenta: "8b008b", ++ darkolivegreen: "556b2f", ++ darkorange: "ff8c00", ++ darkorchid: "9932cc", ++ darkred: "8b0000", ++ darksalmon: "e9967a", ++ darkseagreen: "8fbc8f", ++ darkslateblue: "483d8b", ++ darkslategray: "2f4f4f", ++ darkslategrey: "2f4f4f", ++ darkturquoise: "00ced1", ++ darkviolet: "9400d3", ++ deeppink: "ff1493", ++ deepskyblue: "00bfff", ++ dimgray: "696969", ++ dimgrey: "696969", ++ dodgerblue: "1e90ff", ++ firebrick: "b22222", ++ floralwhite: "fffaf0", ++ forestgreen: "228b22", ++ fuchsia: "f0f", ++ gainsboro: "dcdcdc", ++ ghostwhite: "f8f8ff", ++ gold: "ffd700", ++ goldenrod: "daa520", ++ gray: "808080", ++ green: "008000", ++ greenyellow: "adff2f", ++ grey: "808080", ++ honeydew: "f0fff0", ++ hotpink: "ff69b4", ++ indianred: "cd5c5c", ++ indigo: "4b0082", ++ ivory: "fffff0", ++ khaki: "f0e68c", ++ lavender: "e6e6fa", ++ lavenderblush: "fff0f5", ++ lawngreen: "7cfc00", ++ lemonchiffon: "fffacd", ++ lightblue: "add8e6", ++ lightcoral: "f08080", ++ lightcyan: "e0ffff", ++ lightgoldenrodyellow: "fafad2", ++ lightgray: "d3d3d3", ++ lightgreen: "90ee90", ++ lightgrey: "d3d3d3", ++ lightpink: "ffb6c1", ++ lightsalmon: "ffa07a", ++ lightseagreen: "20b2aa", ++ lightskyblue: "87cefa", ++ lightslategray: "789", ++ lightslategrey: "789", ++ lightsteelblue: "b0c4de", ++ lightyellow: "ffffe0", ++ lime: "0f0", ++ limegreen: "32cd32", ++ linen: "faf0e6", ++ magenta: "f0f", ++ maroon: "800000", ++ mediumaquamarine: "66cdaa", ++ mediumblue: "0000cd", ++ mediumorchid: "ba55d3", ++ mediumpurple: "9370db", ++ mediumseagreen: "3cb371", ++ mediumslateblue: "7b68ee", ++ mediumspringgreen: "00fa9a", ++ mediumturquoise: "48d1cc", ++ mediumvioletred: "c71585", ++ midnightblue: "191970", ++ mintcream: "f5fffa", ++ mistyrose: "ffe4e1", ++ moccasin: "ffe4b5", ++ navajowhite: "ffdead", ++ navy: "000080", ++ oldlace: "fdf5e6", ++ olive: "808000", ++ olivedrab: "6b8e23", ++ orange: "ffa500", ++ orangered: "ff4500", ++ orchid: "da70d6", ++ palegoldenrod: "eee8aa", ++ palegreen: "98fb98", ++ paleturquoise: "afeeee", ++ palevioletred: "db7093", ++ papayawhip: "ffefd5", ++ peachpuff: "ffdab9", ++ peru: "cd853f", ++ pink: "ffc0cb", ++ plum: "dda0dd", ++ powderblue: "b0e0e6", ++ purple: "800080", ++ rebeccapurple: "663399", ++ red: "f00", ++ rosybrown: "bc8f8f", ++ royalblue: "4169e1", ++ saddlebrown: "8b4513", ++ salmon: "fa8072", ++ sandybrown: "f4a460", ++ seagreen: "2e8b57", ++ seashell: "fff5ee", ++ sienna: "a0522d", ++ silver: "c0c0c0", ++ skyblue: "87ceeb", ++ slateblue: "6a5acd", ++ slategray: "708090", ++ slategrey: "708090", ++ snow: "fffafa", ++ springgreen: "00ff7f", ++ steelblue: "4682b4", ++ tan: "d2b48c", ++ teal: "008080", ++ thistle: "d8bfd8", ++ tomato: "ff6347", ++ turquoise: "40e0d0", ++ violet: "ee82ee", ++ wheat: "f5deb3", ++ white: "fff", ++ whitesmoke: "f5f5f5", ++ yellow: "ff0", ++ yellowgreen: "9acd32" ++}; + +-function testInterior(a, b, c) { +- var x0 = twoSum(a[0], -b[0]) +- var y0 = twoSum(a[1], -b[1]) +- var x1 = twoSum(c[0], -b[0]) +- var y1 = twoSum(c[1], -b[1]) ++// Make it easy to access colors via `hexNames[hex]` ++var hexNames = tinycolor.hexNames = flip(names); + +- var d = robustSum( +- robustProduct(x0, x1), +- robustProduct(y0, y1)) + +- return d[d.length-1] >= 0 +-} ++// Utilities ++// --------- + +-function compareAngle(a, b, c, d) { +- var bcd = orient(b, c, d) +- if(bcd === 0) { +- //Handle degenerate cases +- var sabc = sgn(orient(a, b, c)) +- var sabd = sgn(orient(a, b, d)) +- if(sabc === sabd) { +- if(sabc === 0) { +- var ic = testInterior(a, b, c) +- var id = testInterior(a, b, d) +- if(ic === id) { +- return 0 +- } else if(ic) { +- return 1 +- } else { +- return -1 ++// `{ 'name1': 'val1' }` becomes `{ 'val1': 'name1' }` ++function flip(o) { ++ var flipped = { }; ++ for (var i in o) { ++ if (o.hasOwnProperty(i)) { ++ flipped[o[i]] = i; + } +- } +- return 0 +- } else if(sabd === 0) { +- if(sabc > 0) { +- return -1 +- } else if(testInterior(a, b, d)) { +- return -1 +- } else { +- return 1 +- } +- } else if(sabc === 0) { +- if(sabd > 0) { +- return 1 +- } else if(testInterior(a, b, c)) { +- return 1 +- } else { +- return -1 +- } +- } +- return sgn(sabd - sabc) +- } +- var abc = orient(a, b, c) +- if(abc > 0) { +- if(bcd > 0 && orient(a, b, d) > 0) { +- return 1 +- } +- return -1 +- } else if(abc < 0) { +- if(bcd > 0 || orient(a, b, d) > 0) { +- return 1 + } +- return -1 +- } else { +- var abd = orient(a, b, d) +- if(abd > 0) { +- return 1 +- } else { +- if(testInterior(a, b, c)) { +- return 1 +- } else { +- return -1 +- } ++ return flipped; ++} ++ ++// Return a valid alpha value [0,1] with all invalid values being set to 1 ++function boundAlpha(a) { ++ a = parseFloat(a); ++ ++ if (isNaN(a) || a < 0 || a > 1) { ++ a = 1; + } +- } ++ ++ return a; + } +-},{"robust-orientation":225,"robust-product":250,"robust-sum":228,"signum":251,"two-sum":241}],250:[function(require,module,exports){ +-"use strict" + +-var robustSum = require("robust-sum") +-var robustScale = require("robust-scale") ++// Take input from [0, n] and return it as [0, 1] ++function bound01(n, max) { ++ if (isOnePointZero(n)) { n = "100%"; } ++ ++ var processPercent = isPercentage(n); ++ n = mathMin(max, mathMax(0, parseFloat(n))); + +-module.exports = robustProduct ++ // Automatically convert percentage into number ++ if (processPercent) { ++ n = parseInt(n * max, 10) / 100; ++ } + +-function robustProduct(a, b) { +- if(a.length === 1) { +- return robustScale(b, a[0]) +- } +- if(b.length === 1) { +- return robustScale(a, b[0]) +- } +- if(a.length === 0 || b.length === 0) { +- return [0] +- } +- var r = [0] +- if(a.length < b.length) { +- for(var i=0; i 0) { return 1 } +- return 0.0 ++// Force a number between 0 and 1 ++function clamp01(val) { ++ return mathMin(1, mathMax(0, val)); + } +-},{}],252:[function(require,module,exports){ +-arguments[4][9][0].apply(exports,arguments) +-},{"dup":9}],253:[function(require,module,exports){ +-"use strict" + +-var bounds = require("binary-search-bounds") ++// Parse a base-16 hex value into a base-10 integer ++function parseIntFromHex(val) { ++ return parseInt(val, 16); ++} + +-var NOT_FOUND = 0 +-var SUCCESS = 1 +-var EMPTY = 2 ++// Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1 ++// ++function isOnePointZero(n) { ++ return typeof n == "string" && n.indexOf('.') != -1 && parseFloat(n) === 1; ++} + +-module.exports = createWrapper ++// Check to see if string passed in is a percentage ++function isPercentage(n) { ++ return typeof n === "string" && n.indexOf('%') != -1; ++} + +-function IntervalTreeNode(mid, left, right, leftPoints, rightPoints) { +- this.mid = mid +- this.left = left +- this.right = right +- this.leftPoints = leftPoints +- this.rightPoints = rightPoints +- this.count = (left ? left.count : 0) + (right ? right.count : 0) + leftPoints.length ++// Force a hex value to have 2 characters ++function pad2(c) { ++ return c.length == 1 ? '0' + c : '' + c; + } + +-var proto = IntervalTreeNode.prototype ++// Replace a decimal with it's percentage value ++function convertToPercentage(n) { ++ if (n <= 1) { ++ n = (n * 100) + "%"; ++ } + +-function copy(a, b) { +- a.mid = b.mid +- a.left = b.left +- a.right = b.right +- a.leftPoints = b.leftPoints +- a.rightPoints = b.rightPoints +- a.count = b.count ++ return n; + } + +-function rebuild(node, intervals) { +- var ntree = createIntervalTree(intervals) +- node.mid = ntree.mid +- node.left = ntree.left +- node.right = ntree.right +- node.leftPoints = ntree.leftPoints +- node.rightPoints = ntree.rightPoints +- node.count = ntree.count ++// Converts a decimal to a hex value ++function convertDecimalToHex(d) { ++ return Math.round(parseFloat(d) * 255).toString(16); + } +- +-function rebuildWithInterval(node, interval) { +- var intervals = node.intervals([]) +- intervals.push(interval) +- rebuild(node, intervals) ++// Converts a hex value to a decimal ++function convertHexToDecimal(h) { ++ return (parseIntFromHex(h) / 255); + } + +-function rebuildWithoutInterval(node, interval) { +- var intervals = node.intervals([]) +- var idx = intervals.indexOf(interval) +- if(idx < 0) { +- return NOT_FOUND +- } +- intervals.splice(idx, 1) +- rebuild(node, intervals) +- return SUCCESS +-} ++var matchers = (function() { + +-proto.intervals = function(result) { +- result.push.apply(result, this.leftPoints) +- if(this.left) { +- this.left.intervals(result) +- } +- if(this.right) { +- this.right.intervals(result) +- } +- return result ++ // ++ var CSS_INTEGER = "[-\\+]?\\d+%?"; ++ ++ // ++ var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?"; ++ ++ // Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome. ++ var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")"; ++ ++ // Actual matching. ++ // Parentheses and commas are optional, but not required. ++ // Whitespace can take the place of commas or opening paren ++ var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?"; ++ var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?"; ++ ++ return { ++ CSS_UNIT: new RegExp(CSS_UNIT), ++ rgb: new RegExp("rgb" + PERMISSIVE_MATCH3), ++ rgba: new RegExp("rgba" + PERMISSIVE_MATCH4), ++ hsl: new RegExp("hsl" + PERMISSIVE_MATCH3), ++ hsla: new RegExp("hsla" + PERMISSIVE_MATCH4), ++ hsv: new RegExp("hsv" + PERMISSIVE_MATCH3), ++ hsva: new RegExp("hsva" + PERMISSIVE_MATCH4), ++ hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/, ++ hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/, ++ hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/, ++ hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/ ++ }; ++})(); ++ ++// `isValidCSSUnit` ++// Take in a single string / number and check to see if it looks like a CSS unit ++// (see `matchers` above for definition). ++function isValidCSSUnit(color) { ++ return !!matchers.CSS_UNIT.exec(color); + } + +-proto.insert = function(interval) { +- var weight = this.count - this.leftPoints.length +- this.count += 1 +- if(interval[1] < this.mid) { +- if(this.left) { +- if(4*(this.left.count+1) > 3*(weight+1)) { +- rebuildWithInterval(this, interval) +- } else { +- this.left.insert(interval) +- } +- } else { +- this.left = createIntervalTree([interval]) ++// `stringInputToObject` ++// Permissive string parsing. Take in a number of formats, and output an object ++// based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}` ++function stringInputToObject(color) { ++ ++ color = color.replace(trimLeft,'').replace(trimRight, '').toLowerCase(); ++ var named = false; ++ if (names[color]) { ++ color = names[color]; ++ named = true; + } +- } else if(interval[0] > this.mid) { +- if(this.right) { +- if(4*(this.right.count+1) > 3*(weight+1)) { +- rebuildWithInterval(this, interval) +- } else { +- this.right.insert(interval) +- } +- } else { +- this.right = createIntervalTree([interval]) ++ else if (color == 'transparent') { ++ return { r: 0, g: 0, b: 0, a: 0, format: "name" }; + } +- } else { +- var l = bounds.ge(this.leftPoints, interval, compareBegin) +- var r = bounds.ge(this.rightPoints, interval, compareEnd) +- this.leftPoints.splice(l, 0, interval) +- this.rightPoints.splice(r, 0, interval) +- } +-} + +-proto.remove = function(interval) { +- var weight = this.count - this.leftPoints +- if(interval[1] < this.mid) { +- if(!this.left) { +- return NOT_FOUND ++ // Try to match string input using regular expressions. ++ // Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360] ++ // Just return an object and let the conversion functions handle that. ++ // This way the result will be the same whether the tinycolor is initialized with string or object. ++ var match; ++ if ((match = matchers.rgb.exec(color))) { ++ return { r: match[1], g: match[2], b: match[3] }; + } +- var rw = this.right ? this.right.count : 0 +- if(4 * rw > 3 * (weight-1)) { +- return rebuildWithoutInterval(this, interval) ++ if ((match = matchers.rgba.exec(color))) { ++ return { r: match[1], g: match[2], b: match[3], a: match[4] }; + } +- var r = this.left.remove(interval) +- if(r === EMPTY) { +- this.left = null +- this.count -= 1 +- return SUCCESS +- } else if(r === SUCCESS) { +- this.count -= 1 ++ if ((match = matchers.hsl.exec(color))) { ++ return { h: match[1], s: match[2], l: match[3] }; + } +- return r +- } else if(interval[0] > this.mid) { +- if(!this.right) { +- return NOT_FOUND ++ if ((match = matchers.hsla.exec(color))) { ++ return { h: match[1], s: match[2], l: match[3], a: match[4] }; + } +- var lw = this.left ? this.left.count : 0 +- if(4 * lw > 3 * (weight-1)) { +- return rebuildWithoutInterval(this, interval) ++ if ((match = matchers.hsv.exec(color))) { ++ return { h: match[1], s: match[2], v: match[3] }; + } +- var r = this.right.remove(interval) +- if(r === EMPTY) { +- this.right = null +- this.count -= 1 +- return SUCCESS +- } else if(r === SUCCESS) { +- this.count -= 1 ++ if ((match = matchers.hsva.exec(color))) { ++ return { h: match[1], s: match[2], v: match[3], a: match[4] }; + } +- return r +- } else { +- if(this.count === 1) { +- if(this.leftPoints[0] === interval) { +- return EMPTY +- } else { +- return NOT_FOUND +- } ++ if ((match = matchers.hex8.exec(color))) { ++ return { ++ r: parseIntFromHex(match[1]), ++ g: parseIntFromHex(match[2]), ++ b: parseIntFromHex(match[3]), ++ a: convertHexToDecimal(match[4]), ++ format: named ? "name" : "hex8" ++ }; + } +- if(this.leftPoints.length === 1 && this.leftPoints[0] === interval) { +- if(this.left && this.right) { +- var p = this +- var n = this.left +- while(n.right) { +- p = n +- n = n.right +- } +- if(p === this) { +- n.right = this.right +- } else { +- var l = this.left +- var r = this.right +- p.count -= n.count +- p.right = n.left +- n.left = l +- n.right = r +- } +- copy(this, n) +- this.count = (this.left?this.left.count:0) + (this.right?this.right.count:0) + this.leftPoints.length +- } else if(this.left) { +- copy(this, this.left) +- } else { +- copy(this, this.right) +- } +- return SUCCESS ++ if ((match = matchers.hex6.exec(color))) { ++ return { ++ r: parseIntFromHex(match[1]), ++ g: parseIntFromHex(match[2]), ++ b: parseIntFromHex(match[3]), ++ format: named ? "name" : "hex" ++ }; + } +- for(var l = bounds.ge(this.leftPoints, interval, compareBegin); l=0 && arr[i][1] >= lo; --i) { +- var r = cb(arr[i]) +- if(r) { return r } +- } +-} + +-function reportRange(arr, cb) { +- for(var i=0; i this.mid) { +- if(this.right) { +- var r = this.right.queryPoint(x, cb) +- if(r) { return r } ++ if (size !== "small" && size !== "large") { ++ size = "small"; + } +- return reportRightRange(this.rightPoints, x, cb) +- } else { +- return reportRange(this.leftPoints, cb) +- } ++ return {"level":level, "size":size}; + } + +-proto.queryInterval = function(lo, hi, cb) { +- if(lo < this.mid && this.left) { +- var r = this.left.queryInterval(lo, hi, cb) +- if(r) { return r } +- } +- if(hi > this.mid && this.right) { +- var r = this.right.queryInterval(lo, hi, cb) +- if(r) { return r } +- } +- if(hi < this.mid) { +- return reportLeftRange(this.leftPoints, hi, cb) +- } else if(lo > this.mid) { +- return reportRightRange(this.rightPoints, lo, cb) +- } else { +- return reportRange(this.leftPoints, cb) +- } ++// Node: Export function ++if (typeof module !== "undefined" && module.exports) { ++ module.exports = tinycolor; + } +- +-function compareNumbers(a, b) { +- return a - b ++// AMD/requirejs: Define the module ++else if (typeof define === 'function' && define.amd) { ++ define(function () {return tinycolor;}); ++} ++// Browser: Expose to window ++else { ++ window.tinycolor = tinycolor; + } + +-function compareBegin(a, b) { +- var d = a[0] - b[0] +- if(d) { return d } +- return a[1] - b[1] ++})(Math); ++ ++},{}],241:[function(require,module,exports){ ++'use strict' ++ ++var parseUnit = require('parse-unit') ++ ++module.exports = toPX ++ ++var PIXELS_PER_INCH = 96 ++ ++function getPropertyInPX(element, prop) { ++ var parts = parseUnit(getComputedStyle(element).getPropertyValue(prop)) ++ return parts[0] * toPX(parts[1], element) + } + +-function compareEnd(a, b) { +- var d = a[1] - b[1] +- if(d) { return d } +- return a[0] - b[0] ++//This brutal hack is needed ++function getSizeBrutal(unit, element) { ++ var testDIV = document.createElement('div') ++ testDIV.style['font-size'] = '128' + unit ++ element.appendChild(testDIV) ++ var size = getPropertyInPX(testDIV, 'font-size') / 128 ++ element.removeChild(testDIV) ++ return size + } + +-function createIntervalTree(intervals) { +- if(intervals.length === 0) { +- return null ++function toPX(str, element) { ++ element = element || document.body ++ str = (str || 'px').trim().toLowerCase() ++ if(element === window || element === document) { ++ element = document.body + } +- var pts = [] +- for(var i=0; i>1] ++ return 1 ++} ++},{"parse-unit":197}],242:[function(require,module,exports){ ++"use strict" + +- var leftIntervals = [] +- var rightIntervals = [] +- var centerIntervals = [] +- for(var i=0; i Math.max(vy, vz)) { ++ u[2] = 1 ++ } else if(vy > Math.max(vx, vz)) { ++ u[0] = 1 ++ } else { ++ u[1] = 1 + } +-} + +-tproto.queryInterval = function(lo, hi, cb) { +- if(lo <= hi && this.root) { +- return this.root.queryInterval(lo, hi, cb) ++ var vv = 0 ++ var uv = 0 ++ for(var i=0; i<3; ++i ) { ++ vv += v[i] * v[i] ++ uv += u[i] * v[i] ++ } ++ for(var i=0; i<3; ++i) { ++ u[i] -= (uv / vv) * v[i] + } ++ normalize3(u, u) ++ return u + } + +-Object.defineProperty(tproto, "count", { +- get: function() { +- if(this.root) { +- return this.root.count +- } +- return 0 +- } +-}) ++function TurntableController(zoomMin, zoomMax, center, up, right, radius, theta, phi) { ++ this.center = filterVector(center) ++ this.up = filterVector(up) ++ this.right = filterVector(right) ++ this.radius = filterVector([radius]) ++ this.angle = filterVector([theta, phi]) ++ this.angle.bounds = [[-Infinity,-Math.PI/2], [Infinity,Math.PI/2]] ++ this.setDistanceLimits(zoomMin, zoomMax) + +-Object.defineProperty(tproto, "intervals", { +- get: function() { +- if(this.root) { +- return this.root.intervals([]) +- } +- return [] ++ this.computedCenter = this.center.curve(0) ++ this.computedUp = this.up.curve(0) ++ this.computedRight = this.right.curve(0) ++ this.computedRadius = this.radius.curve(0) ++ this.computedAngle = this.angle.curve(0) ++ this.computedToward = [0,0,0] ++ this.computedEye = [0,0,0] ++ this.computedMatrix = new Array(16) ++ for(var i=0; i<16; ++i) { ++ this.computedMatrix[i] = 0.5 + } +-}) + +-function createWrapper(intervals) { +- if(!intervals || intervals.length === 0) { +- return new IntervalTree(null) +- } +- return new IntervalTree(createIntervalTree(intervals)) ++ this.recalcMatrix(0) + } + +-},{"binary-search-bounds":252}],254:[function(require,module,exports){ +-"use strict" +- +-module.exports = orderSegments +- +-var orient = require("robust-orientation") ++var proto = TurntableController.prototype + +-function horizontalOrder(a, b) { +- var bl, br +- if(b[0][0] < b[1][0]) { +- bl = b[0] +- br = b[1] +- } else if(b[0][0] > b[1][0]) { +- bl = b[1] +- br = b[0] ++proto.setDistanceLimits = function(minDist, maxDist) { ++ if(minDist > 0) { ++ minDist = Math.log(minDist) + } else { +- var alo = Math.min(a[0][1], a[1][1]) +- var ahi = Math.max(a[0][1], a[1][1]) +- var blo = Math.min(b[0][1], b[1][1]) +- var bhi = Math.max(b[0][1], b[1][1]) +- if(ahi < blo) { +- return ahi - blo +- } +- if(alo > bhi) { +- return alo - bhi +- } +- return ahi - bhi ++ minDist = -Infinity + } +- var al, ar +- if(a[0][1] < a[1][1]) { +- al = a[0] +- ar = a[1] ++ if(maxDist > 0) { ++ maxDist = Math.log(maxDist) + } else { +- al = a[1] +- ar = a[0] +- } +- var d = orient(br, bl, al) +- if(d) { +- return d +- } +- d = orient(br, bl, ar) +- if(d) { +- return d ++ maxDist = Infinity + } +- return ar - br ++ maxDist = Math.max(maxDist, minDist) ++ this.radius.bounds[0][0] = minDist ++ this.radius.bounds[1][0] = maxDist + } + +-function orderSegments(b, a) { +- var al, ar +- if(a[0][0] < a[1][0]) { +- al = a[0] +- ar = a[1] +- } else if(a[0][0] > a[1][0]) { +- al = a[1] +- ar = a[0] +- } else { +- return horizontalOrder(a, b) +- } +- var bl, br +- if(b[0][0] < b[1][0]) { +- bl = b[0] +- br = b[1] +- } else if(b[0][0] > b[1][0]) { +- bl = b[1] +- br = b[0] +- } else { +- return -horizontalOrder(b, a) +- } +- var d1 = orient(al, ar, br) +- var d2 = orient(al, ar, bl) +- if(d1 < 0) { +- if(d2 <= 0) { +- return d1 +- } +- } else if(d1 > 0) { +- if(d2 >= 0) { +- return d1 +- } +- } else if(d2) { +- return d2 +- } +- d1 = orient(br, bl, ar) +- d2 = orient(br, bl, al) +- if(d1 < 0) { +- if(d2 <= 0) { +- return d1 +- } +- } else if(d1 > 0) { +- if(d2 >= 0) { +- return d1 +- } +- } else if(d2) { +- return d2 ++proto.getDistanceLimits = function(out) { ++ var bounds = this.radius.bounds[0] ++ if(out) { ++ out[0] = Math.exp(bounds[0][0]) ++ out[1] = Math.exp(bounds[1][0]) ++ return out + } +- return ar[0] - br[0] ++ return [ Math.exp(bounds[0][0]), Math.exp(bounds[1][0]) ] + } +-},{"robust-orientation":225}],255:[function(require,module,exports){ +-"use strict" + +-module.exports = createRBTree ++proto.recalcMatrix = function(t) { ++ //Recompute curves ++ this.center.curve(t) ++ this.up.curve(t) ++ this.right.curve(t) ++ this.radius.curve(t) ++ this.angle.curve(t) + +-var RED = 0 +-var BLACK = 1 ++ //Compute frame for camera matrix ++ var up = this.computedUp ++ var right = this.computedRight ++ var uu = 0.0 ++ var ur = 0.0 ++ for(var i=0; i<3; ++i) { ++ ur += up[i] * right[i] ++ uu += up[i] * up[i] ++ } ++ var ul = Math.sqrt(uu) ++ var rr = 0.0 ++ for(var i=0; i<3; ++i) { ++ right[i] -= up[i] * ur / uu ++ rr += right[i] * right[i] ++ up[i] /= ul ++ } ++ var rl = Math.sqrt(rr) ++ for(var i=0; i<3; ++i) { ++ right[i] /= rl ++ } + +-function RBNode(color, key, value, left, right, count) { +- this._color = color +- this.key = key +- this.value = value +- this.left = left +- this.right = right +- this._count = count +-} ++ //Compute toward vector ++ var toward = this.computedToward ++ cross(toward, up, right) ++ normalize3(toward, toward) + +-function cloneNode(node) { +- return new RBNode(node._color, node.key, node.value, node.left, node.right, node._count) +-} ++ //Compute angular parameters ++ var radius = Math.exp(this.computedRadius[0]) ++ var theta = this.computedAngle[0] ++ var phi = this.computedAngle[1] + +-function repaint(color, node) { +- return new RBNode(color, node.key, node.value, node.left, node.right, node._count) +-} ++ var ctheta = Math.cos(theta) ++ var stheta = Math.sin(theta) ++ var cphi = Math.cos(phi) ++ var sphi = Math.sin(phi) + +-function recount(node) { +- node._count = 1 + (node.left ? node.left._count : 0) + (node.right ? node.right._count : 0) +-} ++ var center = this.computedCenter + +-function RedBlackTree(compare, root) { +- this._compare = compare +- this.root = root +-} ++ var wx = ctheta * cphi ++ var wy = stheta * cphi ++ var wz = sphi + +-var proto = RedBlackTree.prototype ++ var sx = -ctheta * sphi ++ var sy = -stheta * sphi ++ var sz = cphi + +-Object.defineProperty(proto, "keys", { +- get: function() { +- var result = [] +- this.forEach(function(k,v) { +- result.push(k) +- }) +- return result ++ var eye = this.computedEye ++ var mat = this.computedMatrix ++ for(var i=0; i<3; ++i) { ++ var x = wx * right[i] + wy * toward[i] + wz * up[i] ++ mat[4*i+1] = sx * right[i] + sy * toward[i] + sz * up[i] ++ mat[4*i+2] = x ++ mat[4*i+3] = 0.0 + } +-}) + +-Object.defineProperty(proto, "values", { +- get: function() { +- var result = [] +- this.forEach(function(k,v) { +- result.push(v) +- }) +- return result +- } +-}) ++ var ax = mat[1] ++ var ay = mat[5] ++ var az = mat[9] ++ var bx = mat[2] ++ var by = mat[6] ++ var bz = mat[10] ++ var cx = ay * bz - az * by ++ var cy = az * bx - ax * bz ++ var cz = ax * by - ay * bx ++ var cl = len3(cx, cy, cz) ++ cx /= cl ++ cy /= cl ++ cz /= cl ++ mat[0] = cx ++ mat[4] = cy ++ mat[8] = cz + +-//Returns the number of nodes in the tree +-Object.defineProperty(proto, "length", { +- get: function() { +- if(this.root) { +- return this.root._count +- } +- return 0 ++ for(var i=0; i<3; ++i) { ++ eye[i] = center[i] + mat[2+4*i]*radius + } +-}) + +-//Insert a new item into the tree +-proto.insert = function(key, value) { +- var cmp = this._compare +- //Find point to insert new node at +- var n = this.root +- var n_stack = [] +- var d_stack = [] +- while(n) { +- var d = cmp(key, n.key) +- n_stack.push(n) +- d_stack.push(d) +- if(d <= 0) { +- n = n.left +- } else { +- n = n.right ++ for(var i=0; i<3; ++i) { ++ var rr = 0.0 ++ for(var j=0; j<3; ++j) { ++ rr += mat[i+4*j] * eye[j] + } ++ mat[12+i] = -rr + } +- //Rebuild path to leaf node +- n_stack.push(new RBNode(RED, key, value, null, null, 1)) +- for(var s=n_stack.length-2; s>=0; --s) { +- var n = n_stack[s] +- if(d_stack[s] <= 0) { +- n_stack[s] = new RBNode(n._color, n.key, n.value, n_stack[s+1], n.right, n._count+1) +- } else { +- n_stack[s] = new RBNode(n._color, n.key, n.value, n.left, n_stack[s+1], n._count+1) ++ mat[15] = 1.0 ++} ++ ++proto.getMatrix = function(t, result) { ++ this.recalcMatrix(t) ++ var mat = this.computedMatrix ++ if(result) { ++ for(var i=0; i<16; ++i) { ++ result[i] = mat[i] + } ++ return result + } +- //Rebalance tree using rotations +- //console.log("start insert", key, d_stack) +- for(var s=n_stack.length-1; s>1; --s) { +- var p = n_stack[s-1] +- var n = n_stack[s] +- if(p._color === BLACK || n._color === BLACK) { +- break +- } +- var pp = n_stack[s-2] +- if(pp.left === p) { +- if(p.left === n) { +- var y = pp.right +- if(y && y._color === RED) { +- //console.log("LLr") +- p._color = BLACK +- pp.right = repaint(BLACK, y) +- pp._color = RED +- s -= 1 +- } else { +- //console.log("LLb") +- pp._color = RED +- pp.left = p.right +- p._color = BLACK +- p.right = pp +- n_stack[s-2] = p +- n_stack[s-1] = n +- recount(pp) +- recount(p) +- if(s >= 3) { +- var ppp = n_stack[s-3] +- if(ppp.left === pp) { +- ppp.left = p +- } else { +- ppp.right = p +- } +- } +- break +- } +- } else { +- var y = pp.right +- if(y && y._color === RED) { +- //console.log("LRr") +- p._color = BLACK +- pp.right = repaint(BLACK, y) +- pp._color = RED +- s -= 1 +- } else { +- //console.log("LRb") +- p.right = n.left +- pp._color = RED +- pp.left = n.right +- n._color = BLACK +- n.left = p +- n.right = pp +- n_stack[s-2] = n +- n_stack[s-1] = p +- recount(pp) +- recount(p) +- recount(n) +- if(s >= 3) { +- var ppp = n_stack[s-3] +- if(ppp.left === pp) { +- ppp.left = n +- } else { +- ppp.right = n +- } +- } +- break +- } +- } +- } else { +- if(p.right === n) { +- var y = pp.left +- if(y && y._color === RED) { +- //console.log("RRr", y.key) +- p._color = BLACK +- pp.left = repaint(BLACK, y) +- pp._color = RED +- s -= 1 +- } else { +- //console.log("RRb") +- pp._color = RED +- pp.right = p.left +- p._color = BLACK +- p.left = pp +- n_stack[s-2] = p +- n_stack[s-1] = n +- recount(pp) +- recount(p) +- if(s >= 3) { +- var ppp = n_stack[s-3] +- if(ppp.right === pp) { +- ppp.right = p +- } else { +- ppp.left = p +- } +- } +- break +- } +- } else { +- var y = pp.left +- if(y && y._color === RED) { +- //console.log("RLr") +- p._color = BLACK +- pp.left = repaint(BLACK, y) +- pp._color = RED +- s -= 1 +- } else { +- //console.log("RLb") +- p.left = n.right +- pp._color = RED +- pp.right = n.left +- n._color = BLACK +- n.right = p +- n.left = pp +- n_stack[s-2] = n +- n_stack[s-1] = p +- recount(pp) +- recount(p) +- recount(n) +- if(s >= 3) { +- var ppp = n_stack[s-3] +- if(ppp.right === pp) { +- ppp.right = n +- } else { +- ppp.left = n +- } +- } +- break +- } +- } ++ return mat ++} ++ ++var zAxis = [0,0,0] ++proto.rotate = function(t, dtheta, dphi, droll) { ++ this.angle.move(t, dtheta, dphi) ++ if(droll) { ++ this.recalcMatrix(t) ++ ++ var mat = this.computedMatrix ++ zAxis[0] = mat[2] ++ zAxis[1] = mat[6] ++ zAxis[2] = mat[10] ++ ++ var up = this.computedUp ++ var right = this.computedRight ++ var toward = this.computedToward ++ ++ for(var i=0; i<3; ++i) { ++ mat[4*i] = up[i] ++ mat[4*i+1] = right[i] ++ mat[4*i+2] = toward[i] ++ } ++ rotateM(mat, mat, droll, zAxis) ++ for(var i=0; i<3; ++i) { ++ up[i] = mat[4*i] ++ right[i] = mat[4*i+1] + } ++ ++ this.up.set(t, up[0], up[1], up[2]) ++ this.right.set(t, right[0], right[1], right[2]) + } +- //Return new tree +- n_stack[0]._color = BLACK +- return new RedBlackTree(cmp, n_stack[0]) + } + ++proto.pan = function(t, dx, dy, dz) { ++ dx = dx || 0.0 ++ dy = dy || 0.0 ++ dz = dz || 0.0 + +-//Visit all nodes inorder +-function doVisitFull(visit, node) { +- if(node.left) { +- var v = doVisitFull(visit, node.left) +- if(v) { return v } +- } +- var v = visit(node.key, node.value) +- if(v) { return v } +- if(node.right) { +- return doVisitFull(visit, node.right) +- } ++ this.recalcMatrix(t) ++ var mat = this.computedMatrix ++ ++ var dist = Math.exp(this.computedRadius[0]) ++ ++ var ux = mat[1] ++ var uy = mat[5] ++ var uz = mat[9] ++ var ul = len3(ux, uy, uz) ++ ux /= ul ++ uy /= ul ++ uz /= ul ++ ++ var rx = mat[0] ++ var ry = mat[4] ++ var rz = mat[8] ++ var ru = rx * ux + ry * uy + rz * uz ++ rx -= ux * ru ++ ry -= uy * ru ++ rz -= uz * ru ++ var rl = len3(rx, ry, rz) ++ rx /= rl ++ ry /= rl ++ rz /= rl ++ ++ var vx = rx * dx + ux * dy ++ var vy = ry * dx + uy * dy ++ var vz = rz * dx + uz * dy ++ this.center.move(t, vx, vy, vz) ++ ++ //Update z-component of radius ++ var radius = Math.exp(this.computedRadius[0]) ++ radius = Math.max(1e-4, radius + dz) ++ this.radius.set(t, Math.log(radius)) + } + +-//Visit half nodes in order +-function doVisitHalf(lo, compare, visit, node) { +- var l = compare(lo, node.key) +- if(l <= 0) { +- if(node.left) { +- var v = doVisitHalf(lo, compare, visit, node.left) +- if(v) { return v } +- } +- var v = visit(node.key, node.value) +- if(v) { return v } ++proto.translate = function(t, dx, dy, dz) { ++ this.center.move(t, ++ dx||0.0, ++ dy||0.0, ++ dz||0.0) ++} ++ ++//Recenters the coordinate axes ++proto.setMatrix = function(t, mat, axes, noSnap) { ++ ++ //Get the axes for tare ++ var ushift = 1 ++ if(typeof axes === 'number') { ++ ushift = (axes)|0 ++ } ++ if(ushift < 0 || ushift > 3) { ++ ushift = 1 + } +- if(node.right) { +- return doVisitHalf(lo, compare, visit, node.right) ++ var vshift = (ushift + 2) % 3 ++ var fshift = (ushift + 1) % 3 ++ ++ //Recompute state for new t value ++ if(!mat) { ++ this.recalcMatrix(t) ++ mat = this.computedMatrix + } +-} + +-//Visit all nodes within a range +-function doVisit(lo, hi, compare, visit, node) { +- var l = compare(lo, node.key) +- var h = compare(hi, node.key) +- var v +- if(l <= 0) { +- if(node.left) { +- v = doVisit(lo, hi, compare, visit, node.left) +- if(v) { return v } +- } +- if(h > 0) { +- v = visit(node.key, node.value) +- if(v) { return v } ++ //Get right and up vectors ++ var ux = mat[ushift] ++ var uy = mat[ushift+4] ++ var uz = mat[ushift+8] ++ if(!noSnap) { ++ var ul = len3(ux, uy, uz) ++ ux /= ul ++ uy /= ul ++ uz /= ul ++ } else { ++ var ax = Math.abs(ux) ++ var ay = Math.abs(uy) ++ var az = Math.abs(uz) ++ var am = Math.max(ax,ay,az) ++ if(ax === am) { ++ ux = (ux < 0) ? -1 : 1 ++ uy = uz = 0 ++ } else if(az === am) { ++ uz = (uz < 0) ? -1 : 1 ++ ux = uy = 0 ++ } else { ++ uy = (uy < 0) ? -1 : 1 ++ ux = uz = 0 + } + } +- if(h > 0 && node.right) { +- return doVisit(lo, hi, compare, visit, node.right) ++ ++ var rx = mat[vshift] ++ var ry = mat[vshift+4] ++ var rz = mat[vshift+8] ++ var ru = rx * ux + ry * uy + rz * uz ++ rx -= ux * ru ++ ry -= uy * ru ++ rz -= uz * ru ++ var rl = len3(rx, ry, rz) ++ rx /= rl ++ ry /= rl ++ rz /= rl ++ ++ var fx = uy * rz - uz * ry ++ var fy = uz * rx - ux * rz ++ var fz = ux * ry - uy * rx ++ var fl = len3(fx, fy, fz) ++ fx /= fl ++ fy /= fl ++ fz /= fl ++ ++ this.center.jump(t, ex, ey, ez) ++ this.radius.idle(t) ++ this.up.jump(t, ux, uy, uz) ++ this.right.jump(t, rx, ry, rz) ++ ++ var phi, theta ++ if(ushift === 2) { ++ var cx = mat[1] ++ var cy = mat[5] ++ var cz = mat[9] ++ var cr = cx * rx + cy * ry + cz * rz ++ var cf = cx * fx + cy * fy + cz * fz ++ if(tu < 0) { ++ phi = -Math.PI/2 ++ } else { ++ phi = Math.PI/2 ++ } ++ theta = Math.atan2(cf, cr) ++ } else { ++ var tx = mat[2] ++ var ty = mat[6] ++ var tz = mat[10] ++ var tu = tx * ux + ty * uy + tz * uz ++ var tr = tx * rx + ty * ry + tz * rz ++ var tf = tx * fx + ty * fy + tz * fz ++ ++ phi = Math.asin(clamp1(tu)) ++ theta = Math.atan2(tf, tr) + } ++ ++ this.angle.jump(t, theta, phi) ++ ++ this.recalcMatrix(t) ++ var dx = mat[2] ++ var dy = mat[6] ++ var dz = mat[10] ++ ++ var imat = this.computedMatrix ++ invert44(imat, mat) ++ var w = imat[15] ++ var ex = imat[12] / w ++ var ey = imat[13] / w ++ var ez = imat[14] / w ++ ++ var gs = Math.exp(this.computedRadius[0]) ++ this.center.jump(t, ex-dx*gs, ey-dy*gs, ez-dz*gs) + } + ++proto.lastT = function() { ++ return Math.max( ++ this.center.lastT(), ++ this.up.lastT(), ++ this.right.lastT(), ++ this.radius.lastT(), ++ this.angle.lastT()) ++} + +-proto.forEach = function rbTreeForEach(visit, lo, hi) { +- if(!this.root) { +- return +- } +- switch(arguments.length) { +- case 1: +- return doVisitFull(visit, this.root) +- break ++proto.idle = function(t) { ++ this.center.idle(t) ++ this.up.idle(t) ++ this.right.idle(t) ++ this.radius.idle(t) ++ this.angle.idle(t) ++} + +- case 2: +- return doVisitHalf(lo, this._compare, visit, this.root) +- break ++proto.flush = function(t) { ++ this.center.flush(t) ++ this.up.flush(t) ++ this.right.flush(t) ++ this.radius.flush(t) ++ this.angle.flush(t) ++} + +- case 3: +- if(this._compare(lo, hi) >= 0) { +- return +- } +- return doVisit(lo, hi, this._compare, visit, this.root) +- break ++proto.setDistance = function(t, d) { ++ if(d > 0) { ++ this.radius.set(t, Math.log(d)) + } + } + +-//First item in list +-Object.defineProperty(proto, "begin", { +- get: function() { +- var stack = [] +- var n = this.root +- while(n) { +- stack.push(n) +- n = n.left +- } +- return new RedBlackTreeIterator(this, stack) +- } +-}) ++proto.lookAt = function(t, eye, center, up) { ++ this.recalcMatrix(t) + +-//Last item in list +-Object.defineProperty(proto, "end", { +- get: function() { +- var stack = [] +- var n = this.root +- while(n) { +- stack.push(n) +- n = n.right +- } +- return new RedBlackTreeIterator(this, stack) ++ eye = eye || this.computedEye ++ center = center || this.computedCenter ++ up = up || this.computedUp ++ ++ var ux = up[0] ++ var uy = up[1] ++ var uz = up[2] ++ var ul = len3(ux, uy, uz) ++ if(ul < 1e-6) { ++ return + } +-}) ++ ux /= ul ++ uy /= ul ++ uz /= ul + +-//Find the ith item in the tree +-proto.at = function(idx) { +- if(idx < 0) { +- return new RedBlackTreeIterator(this, []) ++ var tx = eye[0] - center[0] ++ var ty = eye[1] - center[1] ++ var tz = eye[2] - center[2] ++ var tl = len3(tx, ty, tz) ++ if(tl < 1e-6) { ++ return + } +- var n = this.root +- var stack = [] +- while(true) { +- stack.push(n) +- if(n.left) { +- if(idx < n.left._count) { +- n = n.left +- continue +- } +- idx -= n.left._count +- } +- if(!idx) { +- return new RedBlackTreeIterator(this, stack) +- } +- idx -= 1 +- if(n.right) { +- if(idx >= n.right._count) { +- break +- } +- n = n.right +- } else { +- break ++ tx /= tl ++ ty /= tl ++ tz /= tl ++ ++ var right = this.computedRight ++ var rx = right[0] ++ var ry = right[1] ++ var rz = right[2] ++ var ru = ux*rx + uy*ry + uz*rz ++ rx -= ru * ux ++ ry -= ru * uy ++ rz -= ru * uz ++ var rl = len3(rx, ry, rz) ++ ++ if(rl < 0.01) { ++ rx = uy * tz - uz * ty ++ ry = uz * tx - ux * tz ++ rz = ux * ty - uy * tx ++ rl = len3(rx, ry, rz) ++ if(rl < 1e-6) { ++ return + } + } +- return new RedBlackTreeIterator(this, []) +-} ++ rx /= rl ++ ry /= rl ++ rz /= rl + +-proto.ge = function(key) { +- var cmp = this._compare +- var n = this.root +- var stack = [] +- var last_ptr = 0 +- while(n) { +- var d = cmp(key, n.key) +- stack.push(n) +- if(d <= 0) { +- last_ptr = stack.length +- } +- if(d <= 0) { +- n = n.left +- } else { +- n = n.right +- } ++ this.up.set(t, ux, uy, uz) ++ this.right.set(t, rx, ry, rz) ++ this.center.set(t, center[0], center[1], center[2]) ++ this.radius.set(t, Math.log(tl)) ++ ++ var fx = uy * rz - uz * ry ++ var fy = uz * rx - ux * rz ++ var fz = ux * ry - uy * rx ++ var fl = len3(fx, fy, fz) ++ fx /= fl ++ fy /= fl ++ fz /= fl ++ ++ var tu = ux*tx + uy*ty + uz*tz ++ var tr = rx*tx + ry*ty + rz*tz ++ var tf = fx*tx + fy*ty + fz*tz ++ ++ var phi = Math.asin(clamp1(tu)) ++ var theta = Math.atan2(tf, tr) ++ ++ var angleState = this.angle._state ++ var lastTheta = angleState[angleState.length-1] ++ var lastPhi = angleState[angleState.length-2] ++ lastTheta = lastTheta % (2.0 * Math.PI) ++ var dp = Math.abs(lastTheta + 2.0 * Math.PI - theta) ++ var d0 = Math.abs(lastTheta - theta) ++ var dn = Math.abs(lastTheta - 2.0 * Math.PI - theta) ++ if(dp < d0) { ++ lastTheta += 2.0 * Math.PI + } +- stack.length = last_ptr +- return new RedBlackTreeIterator(this, stack) ++ if(dn < d0) { ++ lastTheta -= 2.0 * Math.PI ++ } ++ ++ this.angle.jump(this.angle.lastT(), lastTheta, lastPhi) ++ this.angle.set(t, theta, phi) + } + +-proto.gt = function(key) { +- var cmp = this._compare +- var n = this.root +- var stack = [] +- var last_ptr = 0 +- while(n) { +- var d = cmp(key, n.key) +- stack.push(n) +- if(d < 0) { +- last_ptr = stack.length +- } +- if(d < 0) { +- n = n.left ++function createTurntableController(options) { ++ options = options || {} ++ ++ var center = options.center || [0,0,0] ++ var up = options.up || [0,1,0] ++ var right = options.right || findOrthoPair(up) ++ var radius = options.radius || 1.0 ++ var theta = options.theta || 0.0 ++ var phi = options.phi || 0.0 ++ ++ center = [].slice.call(center, 0, 3) ++ ++ up = [].slice.call(up, 0, 3) ++ normalize3(up, up) ++ ++ right = [].slice.call(right, 0, 3) ++ normalize3(right, right) ++ ++ if('eye' in options) { ++ var eye = options.eye ++ var toward = [ ++ eye[0]-center[0], ++ eye[1]-center[1], ++ eye[2]-center[2] ++ ] ++ cross(right, toward, up) ++ if(len3(right[0], right[1], right[2]) < 1e-6) { ++ right = findOrthoPair(up) + } else { +- n = n.right ++ normalize3(right, right) + } ++ ++ radius = len3(toward[0], toward[1], toward[2]) ++ ++ var ut = dot3(up, toward) / radius ++ var rt = dot3(right, toward) / radius ++ phi = Math.acos(ut) ++ theta = Math.acos(rt) + } +- stack.length = last_ptr +- return new RedBlackTreeIterator(this, stack) ++ ++ //Use logarithmic coordinates for radius ++ radius = Math.log(radius) ++ ++ //Return the controller ++ return new TurntableController( ++ options.zoomMin, ++ options.zoomMax, ++ center, ++ up, ++ right, ++ radius, ++ theta, ++ phi) + } ++},{"filtered-vector":83,"gl-mat4/invert":111,"gl-mat4/rotate":115,"gl-vec3/cross":149,"gl-vec3/dot":150,"gl-vec3/normalize":153}],244:[function(require,module,exports){ ++"use strict" + +-proto.lt = function(key) { +- var cmp = this._compare +- var n = this.root +- var stack = [] +- var last_ptr = 0 +- while(n) { +- var d = cmp(key, n.key) +- stack.push(n) +- if(d > 0) { +- last_ptr = stack.length +- } +- if(d <= 0) { +- n = n.left +- } else { +- n = n.right +- } ++module.exports = twoProduct ++ ++var SPLITTER = +(Math.pow(2, 27) + 1.0) ++ ++function twoProduct(a, b, result) { ++ var x = a * b ++ ++ var c = SPLITTER * a ++ var abig = c - a ++ var ahi = c - abig ++ var alo = a - ahi ++ ++ var d = SPLITTER * b ++ var bbig = d - b ++ var bhi = d - bbig ++ var blo = b - bhi ++ ++ var err1 = x - (ahi * bhi) ++ var err2 = err1 - (alo * bhi) ++ var err3 = err2 - (ahi * blo) ++ ++ var y = alo * blo - err3 ++ ++ if(result) { ++ result[0] = y ++ result[1] = x ++ return result + } +- stack.length = last_ptr +- return new RedBlackTreeIterator(this, stack) ++ ++ return [ y, x ] + } ++},{}],245:[function(require,module,exports){ ++"use strict" + +-proto.le = function(key) { +- var cmp = this._compare +- var n = this.root +- var stack = [] +- var last_ptr = 0 +- while(n) { +- var d = cmp(key, n.key) +- stack.push(n) +- if(d >= 0) { +- last_ptr = stack.length +- } +- if(d < 0) { +- n = n.left +- } else { +- n = n.right +- } +- } +- stack.length = last_ptr +- return new RedBlackTreeIterator(this, stack) ++module.exports = fastTwoSum ++ ++function fastTwoSum(a, b, result) { ++ var x = a + b ++ var bv = x - a ++ var av = x - bv ++ var br = b - bv ++ var ar = a - av ++ if(result) { ++ result[0] = ar + br ++ result[1] = x ++ return result ++ } ++ return [ar+br, x] + } ++},{}],246:[function(require,module,exports){ ++(function (global,Buffer){ ++'use strict' + +-//Finds the item with key if it exists +-proto.find = function(key) { +- var cmp = this._compare +- var n = this.root +- var stack = [] +- while(n) { +- var d = cmp(key, n.key) +- stack.push(n) +- if(d === 0) { +- return new RedBlackTreeIterator(this, stack) +- } +- if(d <= 0) { +- n = n.left +- } else { +- n = n.right +- } ++var bits = require('bit-twiddle') ++var dup = require('dup') ++ ++//Legacy pool support ++if(!global.__TYPEDARRAY_POOL) { ++ global.__TYPEDARRAY_POOL = { ++ UINT8 : dup([32, 0]) ++ , UINT16 : dup([32, 0]) ++ , UINT32 : dup([32, 0]) ++ , INT8 : dup([32, 0]) ++ , INT16 : dup([32, 0]) ++ , INT32 : dup([32, 0]) ++ , FLOAT : dup([32, 0]) ++ , DOUBLE : dup([32, 0]) ++ , DATA : dup([32, 0]) ++ , UINT8C : dup([32, 0]) ++ , BUFFER : dup([32, 0]) + } +- return new RedBlackTreeIterator(this, []) + } + +-//Removes item with key from tree +-proto.remove = function(key) { +- var iter = this.find(key) +- if(iter) { +- return iter.remove() +- } +- return this ++var hasUint8C = (typeof Uint8ClampedArray) !== 'undefined' ++var POOL = global.__TYPEDARRAY_POOL ++ ++//Upgrade pool ++if(!POOL.UINT8C) { ++ POOL.UINT8C = dup([32, 0]) ++} ++if(!POOL.BUFFER) { ++ POOL.BUFFER = dup([32, 0]) + } + +-//Returns the item at `key` +-proto.get = function(key) { +- var cmp = this._compare +- var n = this.root +- while(n) { +- var d = cmp(key, n.key) +- if(d === 0) { +- return n.value ++//New technique: Only allocate from ArrayBufferView and Buffer ++var DATA = POOL.DATA ++ , BUFFER = POOL.BUFFER ++ ++exports.free = function free(array) { ++ if(Buffer.isBuffer(array)) { ++ BUFFER[bits.log2(array.length)].push(array) ++ } else { ++ if(Object.prototype.toString.call(array) !== '[object ArrayBuffer]') { ++ array = array.buffer + } +- if(d <= 0) { +- n = n.left +- } else { +- n = n.right ++ if(!array) { ++ return + } ++ var n = array.length || array.byteLength ++ var log_n = bits.log2(n)|0 ++ DATA[log_n].push(array) + } +- return + } + +-//Iterator for red black tree +-function RedBlackTreeIterator(tree, stack) { +- this.tree = tree +- this._stack = stack ++function freeArrayBuffer(buffer) { ++ if(!buffer) { ++ return ++ } ++ var n = buffer.length || buffer.byteLength ++ var log_n = bits.log2(n) ++ DATA[log_n].push(buffer) + } + +-var iproto = RedBlackTreeIterator.prototype ++function freeTypedArray(array) { ++ freeArrayBuffer(array.buffer) ++} + +-//Test if iterator is valid +-Object.defineProperty(iproto, "valid", { +- get: function() { +- return this._stack.length > 0 +- } +-}) ++exports.freeUint8 = ++exports.freeUint16 = ++exports.freeUint32 = ++exports.freeInt8 = ++exports.freeInt16 = ++exports.freeInt32 = ++exports.freeFloat32 = ++exports.freeFloat = ++exports.freeFloat64 = ++exports.freeDouble = ++exports.freeUint8Clamped = ++exports.freeDataView = freeTypedArray + +-//Node of the iterator +-Object.defineProperty(iproto, "node", { +- get: function() { +- if(this._stack.length > 0) { +- return this._stack[this._stack.length-1] +- } +- return null +- }, +- enumerable: true +-}) ++exports.freeArrayBuffer = freeArrayBuffer + +-//Makes a copy of an iterator +-iproto.clone = function() { +- return new RedBlackTreeIterator(this.tree, this._stack.slice()) ++exports.freeBuffer = function freeBuffer(array) { ++ BUFFER[bits.log2(array.length)].push(array) + } + +-//Swaps two nodes +-function swapNode(n, v) { +- n.key = v.key +- n.value = v.value +- n.left = v.left +- n.right = v.right +- n._color = v._color +- n._count = v._count +-} ++exports.malloc = function malloc(n, dtype) { ++ if(dtype === undefined || dtype === 'arraybuffer') { ++ return mallocArrayBuffer(n) ++ } else { ++ switch(dtype) { ++ case 'uint8': ++ return mallocUint8(n) ++ case 'uint16': ++ return mallocUint16(n) ++ case 'uint32': ++ return mallocUint32(n) ++ case 'int8': ++ return mallocInt8(n) ++ case 'int16': ++ return mallocInt16(n) ++ case 'int32': ++ return mallocInt32(n) ++ case 'float': ++ case 'float32': ++ return mallocFloat(n) ++ case 'double': ++ case 'float64': ++ return mallocDouble(n) ++ case 'uint8_clamped': ++ return mallocUint8Clamped(n) ++ case 'buffer': ++ return mallocBuffer(n) ++ case 'data': ++ case 'dataview': ++ return mallocDataView(n) + +-//Fix up a double black node in a tree +-function fixDoubleBlack(stack) { +- var n, p, s, z +- for(var i=stack.length-1; i>=0; --i) { +- n = stack[i] +- if(i === 0) { +- n._color = BLACK +- return +- } +- //console.log("visit node:", n.key, i, stack[i].key, stack[i-1].key) +- p = stack[i-1] +- if(p.left === n) { +- //console.log("left child") +- s = p.right +- if(s.right && s.right._color === RED) { +- //console.log("case 1: right sibling child red") +- s = p.right = cloneNode(s) +- z = s.right = cloneNode(s.right) +- p.right = s.left +- s.left = p +- s.right = z +- s._color = p._color +- n._color = BLACK +- p._color = BLACK +- z._color = BLACK +- recount(p) +- recount(s) +- if(i > 1) { +- var pp = stack[i-2] +- if(pp.left === p) { +- pp.left = s +- } else { +- pp.right = s +- } +- } +- stack[i-1] = s +- return +- } else if(s.left && s.left._color === RED) { +- //console.log("case 1: left sibling child red") +- s = p.right = cloneNode(s) +- z = s.left = cloneNode(s.left) +- p.right = z.left +- s.left = z.right +- z.left = p +- z.right = s +- z._color = p._color +- p._color = BLACK +- s._color = BLACK +- n._color = BLACK +- recount(p) +- recount(s) +- recount(z) +- if(i > 1) { +- var pp = stack[i-2] +- if(pp.left === p) { +- pp.left = z +- } else { +- pp.right = z +- } +- } +- stack[i-1] = z +- return +- } +- if(s._color === BLACK) { +- if(p._color === RED) { +- //console.log("case 2: black sibling, red parent", p.right.value) +- p._color = BLACK +- p.right = repaint(RED, s) +- return +- } else { +- //console.log("case 2: black sibling, black parent", p.right.value) +- p.right = repaint(RED, s) +- continue +- } +- } else { +- //console.log("case 3: red sibling") +- s = cloneNode(s) +- p.right = s.left +- s.left = p +- s._color = p._color +- p._color = RED +- recount(p) +- recount(s) +- if(i > 1) { +- var pp = stack[i-2] +- if(pp.left === p) { +- pp.left = s +- } else { +- pp.right = s +- } +- } +- stack[i-1] = s +- stack[i] = p +- if(i+1 < stack.length) { +- stack[i+1] = n +- } else { +- stack.push(n) +- } +- i = i+2 +- } +- } else { +- //console.log("right child") +- s = p.left +- if(s.left && s.left._color === RED) { +- //console.log("case 1: left sibling child red", p.value, p._color) +- s = p.left = cloneNode(s) +- z = s.left = cloneNode(s.left) +- p.left = s.right +- s.right = p +- s.left = z +- s._color = p._color +- n._color = BLACK +- p._color = BLACK +- z._color = BLACK +- recount(p) +- recount(s) +- if(i > 1) { +- var pp = stack[i-2] +- if(pp.right === p) { +- pp.right = s +- } else { +- pp.left = s +- } +- } +- stack[i-1] = s +- return +- } else if(s.right && s.right._color === RED) { +- //console.log("case 1: right sibling child red") +- s = p.left = cloneNode(s) +- z = s.right = cloneNode(s.right) +- p.left = z.right +- s.right = z.left +- z.right = p +- z.left = s +- z._color = p._color +- p._color = BLACK +- s._color = BLACK +- n._color = BLACK +- recount(p) +- recount(s) +- recount(z) +- if(i > 1) { +- var pp = stack[i-2] +- if(pp.right === p) { +- pp.right = z +- } else { +- pp.left = z +- } +- } +- stack[i-1] = z +- return +- } +- if(s._color === BLACK) { +- if(p._color === RED) { +- //console.log("case 2: black sibling, red parent") +- p._color = BLACK +- p.left = repaint(RED, s) +- return +- } else { +- //console.log("case 2: black sibling, black parent") +- p.left = repaint(RED, s) +- continue +- } +- } else { +- //console.log("case 3: red sibling") +- s = cloneNode(s) +- p.left = s.right +- s.right = p +- s._color = p._color +- p._color = RED +- recount(p) +- recount(s) +- if(i > 1) { +- var pp = stack[i-2] +- if(pp.right === p) { +- pp.right = s +- } else { +- pp.left = s +- } +- } +- stack[i-1] = s +- stack[i] = p +- if(i+1 < stack.length) { +- stack[i+1] = n +- } else { +- stack.push(n) +- } +- i = i+2 +- } ++ default: ++ return null + } + } ++ return null + } + +-//Removes item at iterator from tree +-iproto.remove = function() { +- var stack = this._stack +- if(stack.length === 0) { +- return this.tree +- } +- //First copy path to node +- var cstack = new Array(stack.length) +- var n = stack[stack.length-1] +- cstack[cstack.length-1] = new RBNode(n._color, n.key, n.value, n.left, n.right, n._count) +- for(var i=stack.length-2; i>=0; --i) { +- var n = stack[i] +- if(n.left === stack[i+1]) { +- cstack[i] = new RBNode(n._color, n.key, n.value, cstack[i+1], n.right, n._count) +- } else { +- cstack[i] = new RBNode(n._color, n.key, n.value, n.left, cstack[i+1], n._count) +- } ++function mallocArrayBuffer(n) { ++ var n = bits.nextPow2(n) ++ var log_n = bits.log2(n) ++ var d = DATA[log_n] ++ if(d.length > 0) { ++ return d.pop() + } ++ return new ArrayBuffer(n) ++} ++exports.mallocArrayBuffer = mallocArrayBuffer + +- //Get node +- n = cstack[cstack.length-1] +- //console.log("start remove: ", n.value) +- +- //If not leaf, then swap with previous node +- if(n.left && n.right) { +- //console.log("moving to leaf") +- +- //First walk to previous leaf +- var split = cstack.length +- n = n.left +- while(n.right) { +- cstack.push(n) +- n = n.right +- } +- //Copy path to leaf +- var v = cstack[split-1] +- cstack.push(new RBNode(n._color, v.key, v.value, n.left, n.right, n._count)) +- cstack[split-1].key = n.key +- cstack[split-1].value = n.value ++function mallocUint8(n) { ++ return new Uint8Array(mallocArrayBuffer(n), 0, n) ++} ++exports.mallocUint8 = mallocUint8 + +- //Fix up stack +- for(var i=cstack.length-2; i>=split; --i) { +- n = cstack[i] +- cstack[i] = new RBNode(n._color, n.key, n.value, n.left, cstack[i+1], n._count) +- } +- cstack[split-1].left = cstack[split] +- } +- //console.log("stack=", cstack.map(function(v) { return v.value })) ++function mallocUint16(n) { ++ return new Uint16Array(mallocArrayBuffer(2*n), 0, n) ++} ++exports.mallocUint16 = mallocUint16 + +- //Remove leaf node +- n = cstack[cstack.length-1] +- if(n._color === RED) { +- //Easy case: removing red leaf +- //console.log("RED leaf") +- var p = cstack[cstack.length-2] +- if(p.left === n) { +- p.left = null +- } else if(p.right === n) { +- p.right = null +- } +- cstack.pop() +- for(var i=0; i 0) { +- return this._stack[this._stack.length-1].key +- } +- return +- }, +- enumerable: true +-}) ++function mallocInt8(n) { ++ return new Int8Array(mallocArrayBuffer(n), 0, n) ++} ++exports.mallocInt8 = mallocInt8 + +-//Returns value +-Object.defineProperty(iproto, "value", { +- get: function() { +- if(this._stack.length > 0) { +- return this._stack[this._stack.length-1].value +- } +- return +- }, +- enumerable: true +-}) ++function mallocInt16(n) { ++ return new Int16Array(mallocArrayBuffer(2*n), 0, n) ++} ++exports.mallocInt16 = mallocInt16 + ++function mallocInt32(n) { ++ return new Int32Array(mallocArrayBuffer(4*n), 0, n) ++} ++exports.mallocInt32 = mallocInt32 + +-//Returns the position of this iterator in the sorted list +-Object.defineProperty(iproto, "index", { +- get: function() { +- var idx = 0 +- var stack = this._stack +- if(stack.length === 0) { +- var r = this.tree.root +- if(r) { +- return r._count +- } +- return 0 +- } else if(stack[stack.length-1].left) { +- idx = stack[stack.length-1].left._count +- } +- for(var s=stack.length-2; s>=0; --s) { +- if(stack[s+1] === stack[s].right) { +- ++idx +- if(stack[s].left) { +- idx += stack[s].left._count +- } +- } +- } +- return idx +- }, +- enumerable: true +-}) ++function mallocFloat(n) { ++ return new Float32Array(mallocArrayBuffer(4*n), 0, n) ++} ++exports.mallocFloat32 = exports.mallocFloat = mallocFloat + +-//Advances iterator to next element in list +-iproto.next = function() { +- var stack = this._stack +- if(stack.length === 0) { +- return +- } +- var n = stack[stack.length-1] +- if(n.right) { +- n = n.right +- while(n) { +- stack.push(n) +- n = n.left +- } ++function mallocDouble(n) { ++ return new Float64Array(mallocArrayBuffer(8*n), 0, n) ++} ++exports.mallocFloat64 = exports.mallocDouble = mallocDouble ++ ++function mallocUint8Clamped(n) { ++ if(hasUint8C) { ++ return new Uint8ClampedArray(mallocArrayBuffer(n), 0, n) + } else { +- stack.pop() +- while(stack.length > 0 && stack[stack.length-1].right === n) { +- n = stack[stack.length-1] +- stack.pop() +- } ++ return mallocUint8(n) + } + } ++exports.mallocUint8Clamped = mallocUint8Clamped + +-//Checks if iterator is at end of tree +-Object.defineProperty(iproto, "hasNext", { +- get: function() { +- var stack = this._stack +- if(stack.length === 0) { +- return false +- } +- if(stack[stack.length-1].right) { +- return true +- } +- for(var s=stack.length-1; s>0; --s) { +- if(stack[s-1].left === stack[s]) { +- return true +- } +- } +- return false ++function mallocDataView(n) { ++ return new DataView(mallocArrayBuffer(n), 0, n) ++} ++exports.mallocDataView = mallocDataView ++ ++function mallocBuffer(n) { ++ n = bits.nextPow2(n) ++ var log_n = bits.log2(n) ++ var cache = BUFFER[log_n] ++ if(cache.length > 0) { ++ return cache.pop() ++ } ++ return new Buffer(n) ++} ++exports.mallocBuffer = mallocBuffer ++ ++exports.clearCache = function clearCache() { ++ for(var i=0; i<32; ++i) { ++ POOL.UINT8[i].length = 0 ++ POOL.UINT16[i].length = 0 ++ POOL.UINT32[i].length = 0 ++ POOL.INT8[i].length = 0 ++ POOL.INT16[i].length = 0 ++ POOL.INT32[i].length = 0 ++ POOL.FLOAT[i].length = 0 ++ POOL.DOUBLE[i].length = 0 ++ POOL.UINT8C[i].length = 0 ++ DATA[i].length = 0 ++ BUFFER[i].length = 0 ++ } ++} ++}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer) ++},{"bit-twiddle":35,"buffer":45,"dup":77}],247:[function(require,module,exports){ ++"use strict"; "use restrict"; ++ ++module.exports = UnionFind; ++ ++function UnionFind(count) { ++ this.roots = new Array(count); ++ this.ranks = new Array(count); ++ ++ for(var i=0; i=0; --i) { +- n = stack[i] +- if(n.left === stack[i+1]) { +- cstack[i] = new RBNode(n._color, n.key, n.value, cstack[i+1], n.right, n._count) +- } else { +- cstack[i] = new RBNode(n._color, n.key, n.value, n.left, cstack[i+1], n._count) +- } ++ while(roots[x0] !== x) { ++ var y = roots[x0] ++ roots[x0] = x ++ x0 = y + } +- return new RedBlackTree(this.tree._compare, cstack[0]) ++ return x; + } + +-//Moves iterator backward one element +-iproto.prev = function() { +- var stack = this._stack +- if(stack.length === 0) { +- return ++proto.link = function(x, y) { ++ var xr = this.find(x) ++ , yr = this.find(y); ++ if(xr === yr) { ++ return; + } +- var n = stack[stack.length-1] +- if(n.left) { +- n = n.left +- while(n) { +- stack.push(n) +- n = n.right +- } ++ var ranks = this.ranks ++ , roots = this.roots ++ , xd = ranks[xr] ++ , yd = ranks[yr]; ++ if(xd < yd) { ++ roots[xr] = yr; ++ } else if(yd < xd) { ++ roots[yr] = xr; + } else { +- stack.pop() +- while(stack.length > 0 && stack[stack.length-1].left === n) { +- n = stack[stack.length-1] +- stack.pop() +- } ++ roots[yr] = xr; ++ ++ranks[xr]; + } + } ++},{}],248:[function(require,module,exports){ ++"use strict" + +-//Checks if iterator is at start of tree +-Object.defineProperty(iproto, "hasPrev", { +- get: function() { +- var stack = this._stack +- if(stack.length === 0) { +- return false +- } +- if(stack[stack.length-1].left) { +- return true ++function unique_pred(list, compare) { ++ var ptr = 1 ++ , len = list.length ++ , a=list[0], b=list[0] ++ for(var i=1; i0; --s) { +- if(stack[s-1].right === stack[s]) { +- return true ++ } ++ list.length = ptr ++ return list ++} ++ ++function unique_eq(list) { ++ var ptr = 1 ++ , len = list.length ++ , a=list[0], b = list[0] ++ for(var i=1; i b) { +- return 1 ++ if(compare) { ++ if(!sorted) { ++ list.sort(compare) ++ } ++ return unique_pred(list, compare) + } +- return 0 ++ if(!sorted) { ++ list.sort() ++ } ++ return unique_eq(list) + } + +-//Build a tree +-function createRBTree(compare) { +- return new RedBlackTree(compare || defaultCompare, null) +-} +-},{}],256:[function(require,module,exports){ ++module.exports = unique ++ ++},{}],249:[function(require,module,exports){ + "use strict" + +-module.exports = createSlabDecomposition ++module.exports = createText + +-var bounds = require("binary-search-bounds") +-var createRBTree = require("functional-red-black-tree") +-var orient = require("robust-orientation") +-var orderSegments = require("./lib/order-segments") ++var vectorizeText = require("./lib/vtext") ++var defaultCanvas = null ++var defaultContext = null + +-function SlabDecomposition(slabs, coordinates, horizontal) { +- this.slabs = slabs +- this.coordinates = coordinates +- this.horizontal = horizontal ++if(typeof document !== 'undefined') { ++ defaultCanvas = document.createElement('canvas') ++ defaultCanvas.width = 8192 ++ defaultCanvas.height = 1024 ++ defaultContext = defaultCanvas.getContext("2d") + } + +-var proto = SlabDecomposition.prototype +- +-function compareHorizontal(e, y) { +- return e.y - y ++function createText(str, options) { ++ if((typeof options !== "object") || (options === null)) { ++ options = {} ++ } ++ return vectorizeText( ++ str, ++ options.canvas || defaultCanvas, ++ options.context || defaultContext, ++ options) + } + +-function searchBucket(root, p) { +- var lastNode = null +- while(root) { +- var seg = root.key +- var l, r +- if(seg[0][0] < seg[1][0]) { +- l = seg[0] +- r = seg[1] +- } else { +- l = seg[1] +- r = seg[0] +- } +- var o = orient(l, r, p) +- if(o < 0) { +- root = root.left +- } else if(o > 0) { +- if(p[0] !== seg[1][0]) { +- lastNode = root +- root = root.right +- } else { +- var val = searchBucket(root.right, p) +- if(val) { +- return val +- } +- root = root.left +- } +- } else { +- if(p[0] !== seg[1][0]) { +- return root +- } else { +- var val = searchBucket(root.right, p) +- if(val) { +- return val +- } +- root = root.left +- } ++},{"./lib/vtext":250}],250:[function(require,module,exports){ ++"use strict" ++ ++module.exports = vectorizeText ++module.exports.processPixels = processPixels ++ ++var surfaceNets = require('surface-nets') ++var ndarray = require('ndarray') ++var simplify = require('simplify-planar-graph') ++var cleanPSLG = require('clean-pslg') ++var cdt2d = require('cdt2d') ++var toPolygonCrappy = require('planar-graph-to-polyline') ++ ++function transformPositions(positions, options, size) { ++ var align = options.textAlign || "start" ++ var baseline = options.textBaseline || "alphabetic" ++ ++ var lo = [1<<30, 1<<30] ++ var hi = [0,0] ++ var n = positions.length ++ for(var i=0; i 0) { +- var otherHitNode = searchBucket(this.slabs[bucket-1], p) +- if(otherHitNode) { +- if(lastSegment) { +- if(orderSegments(otherHitNode.key, lastSegment) > 0) { +- lastSegment = otherHitNode.key +- lastHit = otherHitNode.value +- } +- } else { +- lastHit = otherHitNode.value +- lastSegment = otherHitNode.key +- } +- } +- } +- var horiz = this.horizontal[bucket] +- if(horiz.length > 0) { +- var hbucket = bounds.ge(horiz, p[1], compareHorizontal) +- if(hbucket < horiz.length) { +- var e = horiz[hbucket] +- if(p[1] === e.y) { +- if(e.closed) { +- return e.index +- } else { +- while(hbucket < horiz.length-1 && horiz[hbucket+1].y === p[1]) { +- hbucket = hbucket+1 +- e = horiz[hbucket] +- if(e.closed) { +- return e.index +- } +- } +- if(e.y === p[1] && !e.start) { +- hbucket = hbucket+1 +- if(hbucket >= horiz.length) { +- return lastHit +- } +- e = horiz[hbucket] +- } +- } +- } +- //Check if e is above/below last segment +- if(e.start) { +- if(lastSegment) { +- var o = orient(lastSegment[0], lastSegment[1], [p[0], e.y]) +- if(lastSegment[0][0] > lastSegment[1][0]) { +- o = -o +- } +- if(o > 0) { +- lastHit = e.index +- } +- } else { +- lastHit = e.index +- } +- } else if(e.y !== p[1]) { +- lastHit = e.index +- } +- } +- } ++ ++ var scale = 1.0 / size ++ if("lineHeight" in options) { ++ scale *= +options.lineHeight ++ } else if("width" in options) { ++ scale = options.width / (hi[0] - lo[0]) ++ } else if("height" in options) { ++ scale = options.height / (hi[1] - lo[1]) + } +- return lastHit +-} +- +-function IntervalSegment(y, index, start, closed) { +- this.y = y +- this.index = index +- this.start = start +- this.closed = closed +-} + +-function Event(x, segment, create, index) { +- this.x = x +- this.segment = segment +- this.create = create +- this.index = index ++ return positions.map(function(p) { ++ return [ scale * (p[0] + xShift), scale * (p[1] + yShift) ] ++ }) + } + +- +-function createSlabDecomposition(segments) { +- var numSegments = segments.length +- var numEvents = 2 * numSegments +- var events = new Array(numEvents) +- for(var i=0; i 8192) { ++ throw new Error("vectorize-text: String too long (sorry, this will get fixed later)") + } +- events.sort(function(a,b) { +- var d = a.x - b.x +- if(d) { +- return d +- } +- d = a.create - b.create +- if(d) { +- return d +- } +- return Math.min(a.segment[0][1], a.segment[1][1]) - Math.min(b.segment[0][1], b.segment[1][1]) +- }) +- var tree = createRBTree(orderSegments) +- var slabs = [] +- var lines = [] +- var horizontal = [] +- var lastX = -Infinity +- for(var i=0; i 0 && coordinates[bucket] === p[0]) { +- root = slabs[bucket-1] +- } else { +- return 1 +- } +- } +- var lastOrientation = 1 +- while(root) { +- var s = root.key +- var o = orient(p, s[0], s[1]) +- if(s[0][0] < s[1][0]) { +- if(o < 0) { +- root = root.left +- } else if(o > 0) { +- lastOrientation = -1 +- root = root.right +- } else { +- return 0 ++function processPixelsImpl(pixels, options, size, simplify) { ++ //Extract contour ++ var contour = getContour(pixels, simplify) ++ ++ //Apply warp to positions ++ var positions = transformPositions(contour.positions, options, size) ++ var edges = contour.edges ++ var flip = "ccw" === options.orientation ++ ++ //Clean up the PSLG, resolve self intersections, etc. ++ cleanPSLG(positions, edges) ++ ++ //If triangulate flag passed, triangulate the result ++ if(options.polygons || options.polygon || options.polyline) { ++ var result = toPolygonCrappy(edges, positions) ++ var nresult = new Array(result.length) ++ for(var i=0; i 0) { +- root = root.left +- } else if(o < 0) { +- lastOrientation = 1 +- root = root.right +- } else { +- return 0 ++ if(flip) { ++ nloop.reverse() + } ++ nloops[j] = nloop + } ++ nresult[i] = nloops ++ } ++ return nresult ++ } else if(options.triangles || options.triangulate || options.triangle) { ++ return { ++ cells: cdt2d(positions, edges, { ++ delaunay: false, ++ exterior: false, ++ interior: true ++ }), ++ positions: positions ++ } ++ } else { ++ return { ++ edges: edges, ++ positions: positions + } +- return lastOrientation + } + } + +-function classifyEmpty(p) { +- return 1 +-} +- +-function createClassifyVertical(testVertical) { +- return function classify(p) { +- if(testVertical(p[0], p[1])) { +- return 0 ++function processPixels(pixels, options, size) { ++ try { ++ return processPixelsImpl(pixels, options, size, true) ++ } catch(e) {} ++ try { ++ return processPixelsImpl(pixels, options, size, false) ++ } catch(e) {} ++ if(options.polygons || options.polyline || options.polygon) { ++ return [] ++ } ++ if(options.triangles || options.triangulate || options.triangle) { ++ return { ++ cells: [], ++ positions: [] + } +- return 1 ++ } ++ return { ++ edges: [], ++ positions: [] + } + } + +-function createClassifyPointDegen(testVertical, testNormal) { +- return function classify(p) { +- if(testVertical(p[0], p[1])) { +- return 0 +- } +- return testNormal(p) +- } ++function vectorizeText(str, canvas, context, options) { ++ var size = options.size || 64 ++ var family = options.font || "normal" ++ ++ context.font = size + "px " + family ++ context.textAlign = "start" ++ context.textBaseline = "alphabetic" ++ context.direction = "ltr" ++ ++ var pixels = getPixels(canvas, context, str, size) ++ ++ return processPixels(pixels, options, size) + } + +-function preprocessPolygon(loops) { +- //Compute number of loops +- var numLoops = loops.length ++},{"cdt2d":48,"clean-pslg":57,"ndarray":191,"planar-graph-to-polyline":202,"simplify-planar-graph":233,"surface-nets":239}],251:[function(require,module,exports){ ++// Copyright (C) 2011 Google Inc. ++// ++// Licensed under the Apache License, Version 2.0 (the "License"); ++// you may not use this file except in compliance with the License. ++// You may obtain a copy of the License at ++// ++// http://www.apache.org/licenses/LICENSE-2.0 ++// ++// Unless required by applicable law or agreed to in writing, software ++// distributed under the License is distributed on an "AS IS" BASIS, ++// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++// See the License for the specific language governing permissions and ++// limitations under the License. + +- //Unpack segments +- var segments = [] +- var vsegments = [] +- var ptr = 0 +- for(var i=0; iAssumes that an ES5 platform where, if {@code WeakMap} is ++ * already present, then it conforms to the anticipated ES6 ++ * specification. To run this file on an ES5 or almost ES5 ++ * implementation where the {@code WeakMap} specification does not ++ * quite conform, run repairES5.js first. ++ * ++ *

Even though WeakMapModule is not global, the linter thinks it ++ * is, which is why it is in the overrides list below. ++ * ++ *

NOTE: Before using this WeakMap emulation in a non-SES ++ * environment, see the note below about hiddenRecord. ++ * ++ * @author Mark S. Miller ++ * @requires crypto, ArrayBuffer, Uint8Array, navigator, console ++ * @overrides WeakMap, ses, Proxy ++ * @overrides WeakMapModule ++ */ ++ ++/** ++ * This {@code WeakMap} emulation is observably equivalent to the ++ * ES-Harmony WeakMap, but with leakier garbage collection properties. ++ * ++ *

As with true WeakMaps, in this emulation, a key does not ++ * retain maps indexed by that key and (crucially) a map does not ++ * retain the keys it indexes. A map by itself also does not retain ++ * the values associated with that map. ++ * ++ *

However, the values associated with a key in some map are ++ * retained so long as that key is retained and those associations are ++ * not overridden. For example, when used to support membranes, all ++ * values exported from a given membrane will live for the lifetime ++ * they would have had in the absence of an interposed membrane. Even ++ * when the membrane is revoked, all objects that would have been ++ * reachable in the absence of revocation will still be reachable, as ++ * far as the GC can tell, even though they will no longer be relevant ++ * to ongoing computation. ++ * ++ *

The API implemented here is approximately the API as implemented ++ * in FF6.0a1 and agreed to by MarkM, Andreas Gal, and Dave Herman, ++ * rather than the offially approved proposal page. TODO(erights): ++ * upgrade the ecmascript WeakMap proposal page to explain this API ++ * change and present to EcmaScript committee for their approval. ++ * ++ *

The first difference between the emulation here and that in ++ * FF6.0a1 is the presence of non enumerable {@code get___, has___, ++ * set___, and delete___} methods on WeakMap instances to represent ++ * what would be the hidden internal properties of a primitive ++ * implementation. Whereas the FF6.0a1 WeakMap.prototype methods ++ * require their {@code this} to be a genuine WeakMap instance (i.e., ++ * an object of {@code [[Class]]} "WeakMap}), since there is nothing ++ * unforgeable about the pseudo-internal method names used here, ++ * nothing prevents these emulated prototype methods from being ++ * applied to non-WeakMaps with pseudo-internal methods of the same ++ * names. ++ * ++ *

Another difference is that our emulated {@code ++ * WeakMap.prototype} is not itself a WeakMap. A problem with the ++ * current FF6.0a1 API is that WeakMap.prototype is itself a WeakMap ++ * providing ambient mutability and an ambient communications ++ * channel. Thus, if a WeakMap is already present and has this ++ * problem, repairES5.js wraps it in a safe wrappper in order to ++ * prevent access to this channel. (See ++ * PATCH_MUTABLE_FROZEN_WEAKMAP_PROTO in repairES5.js). ++ */ ++ ++/** ++ * If this is a full secureable ES5 platform and the ES-Harmony {@code WeakMap} is ++ * absent, install an approximate emulation. ++ * ++ *

If WeakMap is present but cannot store some objects, use our approximate ++ * emulation as a wrapper. ++ * ++ *

If this is almost a secureable ES5 platform, then WeakMap.js ++ * should be run after repairES5.js. ++ * ++ *

See {@code WeakMap} for documentation of the garbage collection ++ * properties of this WeakMap emulation. ++ */ ++(function WeakMapModule() { ++ "use strict"; ++ ++ if (typeof ses !== 'undefined' && ses.ok && !ses.ok()) { ++ // already too broken, so give up ++ return; + } + +- //Degenerate case: All loops are empty +- if(segments.length === 0) { +- if(vsegments.length === 0) { +- return classifyEmpty +- } else { +- return createClassifyVertical(buildVerticalIndex(vsegments)) ++ /** ++ * In some cases (current Firefox), we must make a choice betweeen a ++ * WeakMap which is capable of using all varieties of host objects as ++ * keys and one which is capable of safely using proxies as keys. See ++ * comments below about HostWeakMap and DoubleWeakMap for details. ++ * ++ * This function (which is a global, not exposed to guests) marks a ++ * WeakMap as permitted to do what is necessary to index all host ++ * objects, at the cost of making it unsafe for proxies. ++ * ++ * Do not apply this function to anything which is not a genuine ++ * fresh WeakMap. ++ */ ++ function weakMapPermitHostObjects(map) { ++ // identity of function used as a secret -- good enough and cheap ++ if (map.permitHostObjects___) { ++ map.permitHostObjects___(weakMapPermitHostObjects); + } + } ++ if (typeof ses !== 'undefined') { ++ ses.weakMapPermitHostObjects = weakMapPermitHostObjects; ++ } + +- //Build slab decomposition +- var slabs = makeSlabs(segments) +- var testSlab = buildSlabSearch(slabs.slabs, slabs.coordinates) ++ // IE 11 has no Proxy but has a broken WeakMap such that we need to patch ++ // it using DoubleWeakMap; this flag tells DoubleWeakMap so. ++ var doubleWeakMapCheckSilentFailure = false; + +- if(vsegments.length === 0) { +- return testSlab +- } else { +- return createClassifyPointDegen( +- buildVerticalIndex(vsegments), +- testSlab) ++ // Check if there is already a good-enough WeakMap implementation, and if so ++ // exit without replacing it. ++ if (typeof WeakMap === 'function') { ++ var HostWeakMap = WeakMap; ++ // There is a WeakMap -- is it good enough? ++ if (typeof navigator !== 'undefined' && ++ /Firefox/.test(navigator.userAgent)) { ++ // We're now *assuming not*, because as of this writing (2013-05-06) ++ // Firefox's WeakMaps have a miscellany of objects they won't accept, and ++ // we don't want to make an exhaustive list, and testing for just one ++ // will be a problem if that one is fixed alone (as they did for Event). ++ ++ // If there is a platform that we *can* reliably test on, here's how to ++ // do it: ++ // var problematic = ... ; ++ // var testHostMap = new HostWeakMap(); ++ // try { ++ // testHostMap.set(problematic, 1); // Firefox 20 will throw here ++ // if (testHostMap.get(problematic) === 1) { ++ // return; ++ // } ++ // } catch (e) {} ++ ++ } else { ++ // IE 11 bug: WeakMaps silently fail to store frozen objects. ++ var testMap = new HostWeakMap(); ++ var testObject = Object.freeze({}); ++ testMap.set(testObject, 1); ++ if (testMap.get(testObject) !== 1) { ++ doubleWeakMapCheckSilentFailure = true; ++ // Fall through to installing our WeakMap. ++ } else { ++ module.exports = WeakMap; ++ return; ++ } ++ } + } +-} +-},{"binary-search-bounds":252,"interval-tree-1d":253,"robust-orientation":225,"slab-decomposition":256}],258:[function(require,module,exports){ +-'use strict' + +-module.exports = planarGraphToPolyline ++ var hop = Object.prototype.hasOwnProperty; ++ var gopn = Object.getOwnPropertyNames; ++ var defProp = Object.defineProperty; ++ var isExtensible = Object.isExtensible; + +-var e2a = require('edges-to-adjacency-list') +-var planarDual = require('planar-dual') +-var preprocessPolygon = require('point-in-big-polygon') +-var twoProduct = require('two-product') +-var robustSum = require('robust-sum') +-var uniq = require('uniq') +-var trimLeaves = require('./lib/trim-leaves') ++ /** ++ * Security depends on HIDDEN_NAME being both unguessable and ++ * undiscoverable by untrusted code. ++ * ++ *

Given the known weaknesses of Math.random() on existing ++ * browsers, it does not generate unguessability we can be confident ++ * of. ++ * ++ *

It is the monkey patching logic in this file that is intended ++ * to ensure undiscoverability. The basic idea is that there are ++ * three fundamental means of discovering properties of an object: ++ * The for/in loop, Object.keys(), and Object.getOwnPropertyNames(), ++ * as well as some proposed ES6 extensions that appear on our ++ * whitelist. The first two only discover enumerable properties, and ++ * we only use HIDDEN_NAME to name a non-enumerable property, so the ++ * only remaining threat should be getOwnPropertyNames and some ++ * proposed ES6 extensions that appear on our whitelist. We monkey ++ * patch them to remove HIDDEN_NAME from the list of properties they ++ * returns. ++ * ++ *

TODO(erights): On a platform with built-in Proxies, proxies ++ * could be used to trap and thereby discover the HIDDEN_NAME, so we ++ * need to monkey patch Proxy.create, Proxy.createFunction, etc, in ++ * order to wrap the provided handler with the real handler which ++ * filters out all traps using HIDDEN_NAME. ++ * ++ *

TODO(erights): Revisit Mike Stay's suggestion that we use an ++ * encapsulated function at a not-necessarily-secret name, which ++ * uses the Stiegler shared-state rights amplification pattern to ++ * reveal the associated value only to the WeakMap in which this key ++ * is associated with that value. Since only the key retains the ++ * function, the function can also remember the key without causing ++ * leakage of the key, so this doesn't violate our general gc ++ * goals. In addition, because the name need not be a guarded ++ * secret, we could efficiently handle cross-frame frozen keys. ++ */ ++ var HIDDEN_NAME_PREFIX = 'weakmap:'; ++ var HIDDEN_NAME = HIDDEN_NAME_PREFIX + 'ident:' + Math.random() + '___'; + +-function makeArray(length, fill) { +- var result = new Array(length) +- for(var i=0; iThe ES5.1 spec requires each name to appear only once, but as ++ * of this writing, this requirement is controversial for ES6, so we ++ * made this code robust against this case. If the resulting extra ++ * search turns out to be expensive, we can probably relax this once ++ * ES6 is adequately supported on all major browsers, iff no browser ++ * versions we support at that time have relaxed this constraint ++ * without providing built-in ES6 WeakMaps. ++ */ ++ defProp(Object, 'getOwnPropertyNames', { ++ value: function fakeGetOwnPropertyNames(obj) { ++ return gopn(obj).filter(isNotHiddenName); ++ } ++ }); + +-function planarGraphToPolyline(edges, positions) { ++ /** ++ * getPropertyNames is not in ES5 but it is proposed for ES6 and ++ * does appear in our whitelist, so we need to clean it too. ++ */ ++ if ('getPropertyNames' in Object) { ++ var originalGetPropertyNames = Object.getPropertyNames; ++ defProp(Object, 'getPropertyNames', { ++ value: function fakeGetPropertyNames(obj) { ++ return originalGetPropertyNames(obj).filter(isNotHiddenName); ++ } ++ }); ++ } + +- //Trim leaves +- var result = trimLeaves(edges, positions) +- edges = result[0] +- positions = result[1] ++ /** ++ *

To treat objects as identity-keys with reasonable efficiency ++ * on ES5 by itself (i.e., without any object-keyed collections), we ++ * need to add a hidden property to such key objects when we ++ * can. This raises several issues: ++ *

    ++ *
  • Arranging to add this property to objects before we lose the ++ * chance, and ++ *
  • Hiding the existence of this new property from most ++ * JavaScript code. ++ *
  • Preventing certification theft, where one object is ++ * created falsely claiming to be the key of an association ++ * actually keyed by another object. ++ *
  • Preventing value theft, where untrusted code with ++ * access to a key object but not a weak map nevertheless ++ * obtains access to the value associated with that key in that ++ * weak map. ++ *
++ * We do so by ++ *
    ++ *
  • Making the name of the hidden property unguessable, so "[]" ++ * indexing, which we cannot intercept, cannot be used to access ++ * a property without knowing the name. ++ *
  • Making the hidden property non-enumerable, so we need not ++ * worry about for-in loops or {@code Object.keys}, ++ *
  • monkey patching those reflective methods that would ++ * prevent extensions, to add this hidden property first, ++ *
  • monkey patching those methods that would reveal this ++ * hidden property. ++ *
++ * Unfortunately, because of same-origin iframes, we cannot reliably ++ * add this hidden property before an object becomes ++ * non-extensible. Instead, if we encounter a non-extensible object ++ * without a hidden record that we can detect (whether or not it has ++ * a hidden record stored under a name secret to us), then we just ++ * use the key object itself to represent its identity in a brute ++ * force leaky map stored in the weak map, losing all the advantages ++ * of weakness for these. ++ */ ++ function getHiddenRecord(key) { ++ if (key !== Object(key)) { ++ throw new TypeError('Not an object: ' + key); ++ } ++ var hiddenRecord = key[HIDDEN_NAME]; ++ if (hiddenRecord && hiddenRecord.key === key) { return hiddenRecord; } ++ if (!isExtensible(key)) { ++ // Weak map must brute force, as explained in doc-comment above. ++ return void 0; ++ } + +- var numVertices = positions.length +- var numEdges = edges.length ++ // The hiddenRecord and the key point directly at each other, via ++ // the "key" and HIDDEN_NAME properties respectively. The key ++ // field is for quickly verifying that this hidden record is an ++ // own property, not a hidden record from up the prototype chain. ++ // ++ // NOTE: Because this WeakMap emulation is meant only for systems like ++ // SES where Object.prototype is frozen without any numeric ++ // properties, it is ok to use an object literal for the hiddenRecord. ++ // This has two advantages: ++ // * It is much faster in a performance critical place ++ // * It avoids relying on Object.create(null), which had been ++ // problematic on Chrome 28.0.1480.0. See ++ // https://code.google.com/p/google-caja/issues/detail?id=1687 ++ hiddenRecord = { key: key }; + +- //Calculate adjacency list, check manifold +- var adj = e2a(edges, positions.length) +- for(var i=0; i 0 + } + +- //Extract all clockwise faces +- faces = faces.filter(ccw) +- +- //Detect which loops are contained in one another to handle parent-of relation +- var numFaces = faces.length +- var parent = new Array(numFaces) +- var containment = new Array(numFaces) +- for(var i=0; iThe monkey patched versions throw a TypeError if their ++ * argument is not an object, so it should only be done to functions ++ * that should throw a TypeError anyway if their argument is not an ++ * object. ++ */ ++ (function(){ ++ var oldFreeze = Object.freeze; ++ defProp(Object, 'freeze', { ++ value: function identifyingFreeze(obj) { ++ getHiddenRecord(obj); ++ return oldFreeze(obj); + } +- var c = faces[j] +- var n = c.length +- for(var k=0; k= 0 ? values[index] : opt_default; + } + } +- } + +- function sharedBoundary(c) { +- var n = c.length +- for(var i=0; i= 0; + } + } +- return true +- } + +- var toVisit = [] +- var parity = makeArray(numFaces, -1) +- for(var i=0; i= 0) { ++ values[index] = value; ++ } else { ++ // Since some browsers preemptively terminate slow turns but ++ // then continue computing with presumably corrupted heap ++ // state, we here defensively get keys.length first and then ++ // use it to update both the values and keys arrays, keeping ++ // them in sync. ++ index = keys.length; ++ values[index] = value; ++ // If we crash here, values will be one longer than keys. ++ keys[index] = key; ++ } ++ } ++ return this; + } +- } + +- //Using face adjacency, classify faces as in/out +- var result = [] +- while(toVisit.length > 0) { +- var top = toVisit.pop() +- var nbhd = fadj[top] +- uniq(nbhd, function(a,b) { +- return a-b +- }) +- var nnbhr = nbhd.length +- var p = parity[top] +- var polyline +- if(p === 0) { +- var c = faces[top] +- polyline = [c] +- } +- for(var i=0; i= 0) { +- continue +- } +- parity[f] = p^1 +- toVisit.push(f) +- if(p === 0) { +- var c = faces[f] +- if(!sharedBoundary(c)) { +- c.reverse() +- polyline.push(c) ++ function delete___(key) { ++ var hiddenRecord = getHiddenRecord(key); ++ var index, lastIndex; ++ if (hiddenRecord) { ++ return id in hiddenRecord && delete hiddenRecord[id]; ++ } else { ++ index = keys.indexOf(key); ++ if (index < 0) { ++ return false; + } ++ // Since some browsers preemptively terminate slow turns but ++ // then continue computing with potentially corrupted heap ++ // state, we here defensively get keys.length first and then use ++ // it to update both the keys and the values array, keeping ++ // them in sync. We update the two with an order of assignments, ++ // such that any prefix of these assignments will preserve the ++ // key/value correspondence, either before or after the delete. ++ // Note that this needs to work correctly when index === lastIndex. ++ lastIndex = keys.length - 1; ++ keys[index] = void 0; ++ // If we crash here, there's a void 0 in the keys array, but ++ // no operation will cause a "keys.indexOf(void 0)", since ++ // getHiddenRecord(void 0) will always throw an error first. ++ values[index] = values[lastIndex]; ++ // If we crash here, values[index] cannot be found here, ++ // because keys[index] is void 0. ++ keys[index] = keys[lastIndex]; ++ // If index === lastIndex and we crash here, then keys[index] ++ // is still void 0, since the aliasing killed the previous key. ++ keys.length = lastIndex; ++ // If we crash here, keys will be one shorter than values. ++ values.length = lastIndex; ++ return true; + } + } +- if(p === 0) { +- result.push(polyline) +- } +- } + +- return result +-} +-},{"./lib/trim-leaves":246,"edges-to-adjacency-list":247,"planar-dual":248,"point-in-big-polygon":257,"robust-sum":228,"two-product":240,"uniq":243}],259:[function(require,module,exports){ +-arguments[4][38][0].apply(exports,arguments) +-},{"dup":38}],260:[function(require,module,exports){ +-"use strict"; "use restrict"; ++ return Object.create(OurWeakMap.prototype, { ++ get___: { value: constFunc(get___) }, ++ has___: { value: constFunc(has___) }, ++ set___: { value: constFunc(set___) }, ++ delete___: { value: constFunc(delete___) } ++ }); ++ }; + +-module.exports = UnionFind; ++ OurWeakMap.prototype = Object.create(Object.prototype, { ++ get: { ++ /** ++ * Return the value most recently associated with key, or ++ * opt_default if none. ++ */ ++ value: function get(key, opt_default) { ++ return this.get___(key, opt_default); ++ }, ++ writable: true, ++ configurable: true ++ }, + +-function UnionFind(count) { +- this.roots = new Array(count); +- this.ranks = new Array(count); +- +- for(var i=0; iNote that the boolean return here does not work like the ++ * {@code delete} operator. The {@code delete} operator returns ++ * whether the deletion succeeds at bringing about a state in ++ * which the deleted property is absent. The {@code delete} ++ * operator therefore returns true if the property was already ++ * absent, whereas this {@code delete} method returns false if ++ * the association was already absent. ++ */ ++ value: function remove(key) { ++ return this.delete___(key); ++ }, ++ writable: true, ++ configurable: true ++ } ++ }); ++ ++ if (typeof HostWeakMap === 'function') { ++ (function() { ++ // If we got here, then the platform has a WeakMap but we are concerned ++ // that it may refuse to store some key types. Therefore, make a map ++ // implementation which makes use of both as possible. ++ ++ // In this mode we are always using double maps, so we are not proxy-safe. ++ // This combination does not occur in any known browser, but we had best ++ // be safe. ++ if (doubleWeakMapCheckSilentFailure && typeof Proxy !== 'undefined') { ++ Proxy = undefined; ++ } + +-UnionFind.prototype.find = function(x) { +- var roots = this.roots; +- while(roots[x] !== x) { +- var y = roots[x]; +- roots[x] = roots[y]; +- x = y; +- } +- return x; +-} ++ function DoubleWeakMap() { ++ if (!(this instanceof OurWeakMap)) { // approximate test for new ...() ++ calledAsFunctionWarning(); ++ } + +-UnionFind.prototype.link = function(x, y) { +- var xr = this.find(x) +- , yr = this.find(y); +- if(xr === yr) { +- return; +- } +- var ranks = this.ranks +- , roots = this.roots +- , xd = ranks[xr] +- , yd = ranks[yr]; +- if(xd < yd) { +- roots[xr] = yr; +- } else if(yd < xd) { +- roots[yr] = xr; +- } else { +- roots[yr] = xr; +- ++ranks[xr]; +- } +-} ++ // Preferable, truly weak map. ++ var hmap = new HostWeakMap(); + ++ // Our hidden-property-based pseudo-weak-map. Lazily initialized in the ++ // 'set' implementation; thus we can avoid performing extra lookups if ++ // we know all entries actually stored are entered in 'hmap'. ++ var omap = undefined; + +-},{}],261:[function(require,module,exports){ +-arguments[4][204][0].apply(exports,arguments) +-},{"bit-twiddle":259,"dup":204,"union-find":260}],262:[function(require,module,exports){ +-"use strict" ++ // Hidden-property maps are not compatible with proxies because proxies ++ // can observe the hidden name and either accidentally expose it or fail ++ // to allow the hidden property to be set. Therefore, we do not allow ++ // arbitrary WeakMaps to switch to using hidden properties, but only ++ // those which need the ability, and unprivileged code is not allowed ++ // to set the flag. ++ // ++ // (Except in doubleWeakMapCheckSilentFailure mode in which case we ++ // disable proxies.) ++ var enableSwitching = false; + +-module.exports = simplifyPolygon ++ function dget(key, opt_default) { ++ if (omap) { ++ return hmap.has(key) ? hmap.get(key) ++ : omap.get___(key, opt_default); ++ } else { ++ return hmap.get(key, opt_default); ++ } ++ } + +-var orient = require("robust-orientation") +-var sc = require("simplicial-complex") ++ function dhas(key) { ++ return hmap.has(key) || (omap ? omap.has___(key) : false); ++ } + +-function errorWeight(base, a, b) { +- var area = Math.abs(orient(base, a, b)) +- var perim = Math.sqrt(Math.pow(a[0] - b[0], 2) + Math.pow(a[1]-b[1], 2)) +- return area / perim +-} ++ var dset; ++ if (doubleWeakMapCheckSilentFailure) { ++ dset = function(key, value) { ++ hmap.set(key, value); ++ if (!hmap.has(key)) { ++ if (!omap) { omap = new OurWeakMap(); } ++ omap.set(key, value); ++ } ++ return this; ++ }; ++ } else { ++ dset = function(key, value) { ++ if (enableSwitching) { ++ try { ++ hmap.set(key, value); ++ } catch (e) { ++ if (!omap) { omap = new OurWeakMap(); } ++ omap.set___(key, value); ++ } ++ } else { ++ hmap.set(key, value); ++ } ++ return this; ++ }; ++ } + +-function simplifyPolygon(cells, positions, minArea) { ++ function ddelete(key) { ++ var result = !!hmap['delete'](key); ++ if (omap) { return omap.delete___(key) || result; } ++ return result; ++ } + +- var n = positions.length +- var nc = cells.length +- var inv = new Array(n) +- var outv = new Array(n) +- var weights = new Array(n) +- var dead = new Array(n) +- +- //Initialize tables +- for(var i=0; i