From 19a7db0e0190ab002b3c3017a7aa88a584b21d18 Mon Sep 17 00:00:00 2001 From: "arichika.taniguchi" Date: Tue, 13 Dec 2022 10:39:57 +0900 Subject: [PATCH] Published build --- dist/extension.js | 13802 +----- dist/extension.js.map | 2 +- dist/mermaid/mermaid.js | 54382 +----------------------- dist/mermaid/mermaid.min.js | 1282 +- dist/mscgenjs-inpage/mscgen-inpage.js | 3 +- 5 files changed, 7 insertions(+), 69464 deletions(-) diff --git a/dist/extension.js b/dist/extension.js index e23f0a4..c1217bc 100644 --- a/dist/extension.js +++ b/dist/extension.js @@ -1,13801 +1 @@ -/******/ (() => { // webpackBootstrap -/******/ var __webpack_modules__ = ([ -/* 0 */, -/* 1 */ -/***/ ((module) => { - -"use strict"; -module.exports = require("vscode"); - -/***/ }), -/* 2 */ -/***/ ((module) => { - -"use strict"; -module.exports = require("path"); - -/***/ }), -/* 3 */ -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - -var Rx = __webpack_require__(4); -__webpack_require__(5); -__webpack_require__(6); -__webpack_require__(8); -__webpack_require__(7); -__webpack_require__(9); -__webpack_require__(10); -__webpack_require__(11); -__webpack_require__(12); -__webpack_require__(13); -__webpack_require__(14); -__webpack_require__(15); - -module.exports = Rx; - - -/***/ }), -/* 4 */ -/***/ (function(module, exports, __webpack_require__) { - -/* module decorator */ module = __webpack_require__.nmd(module); -var __WEBPACK_AMD_DEFINE_RESULT__;// Copyright (c) Microsoft, All rights reserved. See License.txt in the project root for license information. - -;(function (undefined) { - - var objectTypes = { - 'function': true, - 'object': true - }; - - function checkGlobal(value) { - return (value && value.Object === Object) ? value : null; - } - - var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType) ? exports : null; - var freeModule = (objectTypes["object"] && module && !module.nodeType) ? module : null; - var freeGlobal = checkGlobal(freeExports && freeModule && typeof global === 'object' && global); - var freeSelf = checkGlobal(objectTypes[typeof self] && self); - var freeWindow = checkGlobal(objectTypes[typeof window] && window); - var moduleExports = (freeModule && freeModule.exports === freeExports) ? freeExports : null; - var thisGlobal = checkGlobal(objectTypes[typeof this] && this); - var root = freeGlobal || ((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) || freeSelf || thisGlobal || Function('return this')(); - - var Rx = { - internals: {}, - config: { - Promise: root.Promise - }, - helpers: { } - }; - - // Defaults - var noop = Rx.helpers.noop = function () { }, - identity = Rx.helpers.identity = function (x) { return x; }, - defaultNow = Rx.helpers.defaultNow = Date.now, - defaultComparer = Rx.helpers.defaultComparer = function (x, y) { return isEqual(x, y); }, - defaultSubComparer = Rx.helpers.defaultSubComparer = function (x, y) { return x > y ? 1 : (x < y ? -1 : 0); }, - defaultKeySerializer = Rx.helpers.defaultKeySerializer = function (x) { return x.toString(); }, - defaultError = Rx.helpers.defaultError = function (err) { throw err; }, - isPromise = Rx.helpers.isPromise = function (p) { return !!p && typeof p.subscribe !== 'function' && typeof p.then === 'function'; }, - isFunction = Rx.helpers.isFunction = (function () { - - var isFn = function (value) { - return typeof value == 'function' || false; - }; - - // fallback for older versions of Chrome and Safari - if (isFn(/x/)) { - isFn = function(value) { - return typeof value == 'function' && toString.call(value) == '[object Function]'; - }; - } - - return isFn; - }()); - - function cloneArray(arr) { for(var a = [], i = 0, len = arr.length; i < len; i++) { a.push(arr[i]); } return a;} - - var errorObj = {e: {}}; - - function tryCatcherGen(tryCatchTarget) { - return function tryCatcher() { - try { - return tryCatchTarget.apply(this, arguments); - } catch (e) { - errorObj.e = e; - return errorObj; - } - }; - } - - var tryCatch = Rx.internals.tryCatch = function tryCatch(fn) { - if (!isFunction(fn)) { throw new TypeError('fn must be a function'); } - return tryCatcherGen(fn); - }; - - function thrower(e) { - throw e; - } - - Rx.config.longStackSupport = false; - var hasStacks = false, stacks = tryCatch(function () { throw new Error(); })(); - hasStacks = !!stacks.e && !!stacks.e.stack; - - // All code after this point will be filtered from stack traces reported by RxJS - var rStartingLine = captureLine(), rFileName; - - var STACK_JUMP_SEPARATOR = 'From previous event:'; - - function makeStackTraceLong(error, observable) { - // If possible, transform the error stack trace by removing Node and RxJS - // cruft, then concatenating with the stack trace of `observable`. - if (hasStacks && - observable.stack && - typeof error === 'object' && - error !== null && - error.stack && - error.stack.indexOf(STACK_JUMP_SEPARATOR) === -1 - ) { - var stacks = []; - for (var o = observable; !!o; o = o.source) { - if (o.stack) { - stacks.unshift(o.stack); - } - } - stacks.unshift(error.stack); - - var concatedStacks = stacks.join('\n' + STACK_JUMP_SEPARATOR + '\n'); - error.stack = filterStackString(concatedStacks); - } - } - - function filterStackString(stackString) { - var lines = stackString.split('\n'), desiredLines = []; - for (var i = 0, len = lines.length; i < len; i++) { - var line = lines[i]; - - if (!isInternalFrame(line) && !isNodeFrame(line) && line) { - desiredLines.push(line); - } - } - return desiredLines.join('\n'); - } - - function isInternalFrame(stackLine) { - var fileNameAndLineNumber = getFileNameAndLineNumber(stackLine); - if (!fileNameAndLineNumber) { - return false; - } - var fileName = fileNameAndLineNumber[0], lineNumber = fileNameAndLineNumber[1]; - - return fileName === rFileName && - lineNumber >= rStartingLine && - lineNumber <= rEndingLine; - } - - function isNodeFrame(stackLine) { - return stackLine.indexOf('(module.js:') !== -1 || - stackLine.indexOf('(node.js:') !== -1; - } - - function captureLine() { - if (!hasStacks) { return; } - - try { - throw new Error(); - } catch (e) { - var lines = e.stack.split('\n'); - var firstLine = lines[0].indexOf('@') > 0 ? lines[1] : lines[2]; - var fileNameAndLineNumber = getFileNameAndLineNumber(firstLine); - if (!fileNameAndLineNumber) { return; } - - rFileName = fileNameAndLineNumber[0]; - return fileNameAndLineNumber[1]; - } - } - - function getFileNameAndLineNumber(stackLine) { - // Named functions: 'at functionName (filename:lineNumber:columnNumber)' - var attempt1 = /at .+ \((.+):(\d+):(?:\d+)\)$/.exec(stackLine); - if (attempt1) { return [attempt1[1], Number(attempt1[2])]; } - - // Anonymous functions: 'at filename:lineNumber:columnNumber' - var attempt2 = /at ([^ ]+):(\d+):(?:\d+)$/.exec(stackLine); - if (attempt2) { return [attempt2[1], Number(attempt2[2])]; } - - // Firefox style: 'function@filename:lineNumber or @filename:lineNumber' - var attempt3 = /.*@(.+):(\d+)$/.exec(stackLine); - if (attempt3) { return [attempt3[1], Number(attempt3[2])]; } - } - - var EmptyError = Rx.EmptyError = function() { - this.message = 'Sequence contains no elements.'; - Error.call(this); - }; - EmptyError.prototype = Object.create(Error.prototype); - EmptyError.prototype.name = 'EmptyError'; - - var ObjectDisposedError = Rx.ObjectDisposedError = function() { - this.message = 'Object has been disposed'; - Error.call(this); - }; - ObjectDisposedError.prototype = Object.create(Error.prototype); - ObjectDisposedError.prototype.name = 'ObjectDisposedError'; - - var ArgumentOutOfRangeError = Rx.ArgumentOutOfRangeError = function () { - this.message = 'Argument out of range'; - Error.call(this); - }; - ArgumentOutOfRangeError.prototype = Object.create(Error.prototype); - ArgumentOutOfRangeError.prototype.name = 'ArgumentOutOfRangeError'; - - var NotSupportedError = Rx.NotSupportedError = function (message) { - this.message = message || 'This operation is not supported'; - Error.call(this); - }; - NotSupportedError.prototype = Object.create(Error.prototype); - NotSupportedError.prototype.name = 'NotSupportedError'; - - var NotImplementedError = Rx.NotImplementedError = function (message) { - this.message = message || 'This operation is not implemented'; - Error.call(this); - }; - NotImplementedError.prototype = Object.create(Error.prototype); - NotImplementedError.prototype.name = 'NotImplementedError'; - - var notImplemented = Rx.helpers.notImplemented = function () { - throw new NotImplementedError(); - }; - - var notSupported = Rx.helpers.notSupported = function () { - throw new NotSupportedError(); - }; - - // Shim in iterator support - var $iterator$ = (typeof Symbol === 'function' && Symbol.iterator) || - '_es6shim_iterator_'; - // Bug for mozilla version - if (root.Set && typeof new root.Set()['@@iterator'] === 'function') { - $iterator$ = '@@iterator'; - } - - var doneEnumerator = Rx.doneEnumerator = { done: true, value: undefined }; - - var isIterable = Rx.helpers.isIterable = function (o) { - return o && o[$iterator$] !== undefined; - }; - - var isArrayLike = Rx.helpers.isArrayLike = function (o) { - return o && o.length !== undefined; - }; - - Rx.helpers.iterator = $iterator$; - - var bindCallback = Rx.internals.bindCallback = function (func, thisArg, argCount) { - if (typeof thisArg === 'undefined') { return func; } - switch(argCount) { - case 0: - return function() { - return func.call(thisArg) - }; - case 1: - return function(arg) { - return func.call(thisArg, arg); - }; - case 2: - return function(value, index) { - return func.call(thisArg, value, index); - }; - case 3: - return function(value, index, collection) { - return func.call(thisArg, value, index, collection); - }; - } - - return function() { - return func.apply(thisArg, arguments); - }; - }; - - /** Used to determine if values are of the language type Object */ - var dontEnums = ['toString', - 'toLocaleString', - 'valueOf', - 'hasOwnProperty', - 'isPrototypeOf', - 'propertyIsEnumerable', - 'constructor'], - dontEnumsLength = dontEnums.length; - -var argsTag = '[object Arguments]', - arrayTag = '[object Array]', - boolTag = '[object Boolean]', - dateTag = '[object Date]', - errorTag = '[object Error]', - funcTag = '[object Function]', - mapTag = '[object Map]', - numberTag = '[object Number]', - objectTag = '[object Object]', - regexpTag = '[object RegExp]', - setTag = '[object Set]', - stringTag = '[object String]', - weakMapTag = '[object WeakMap]'; - -var arrayBufferTag = '[object ArrayBuffer]', - float32Tag = '[object Float32Array]', - float64Tag = '[object Float64Array]', - int8Tag = '[object Int8Array]', - int16Tag = '[object Int16Array]', - int32Tag = '[object Int32Array]', - uint8Tag = '[object Uint8Array]', - uint8ClampedTag = '[object Uint8ClampedArray]', - uint16Tag = '[object Uint16Array]', - uint32Tag = '[object Uint32Array]'; - -var typedArrayTags = {}; -typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = -typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = -typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = -typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = -typedArrayTags[uint32Tag] = true; -typedArrayTags[argsTag] = typedArrayTags[arrayTag] = -typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = -typedArrayTags[dateTag] = typedArrayTags[errorTag] = -typedArrayTags[funcTag] = typedArrayTags[mapTag] = -typedArrayTags[numberTag] = typedArrayTags[objectTag] = -typedArrayTags[regexpTag] = typedArrayTags[setTag] = -typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false; - -var objectProto = Object.prototype, - hasOwnProperty = objectProto.hasOwnProperty, - objToString = objectProto.toString, - MAX_SAFE_INTEGER = Math.pow(2, 53) - 1; - -var keys = Object.keys || (function() { - var hasOwnProperty = Object.prototype.hasOwnProperty, - hasDontEnumBug = !({ toString: null }).propertyIsEnumerable('toString'), - dontEnums = [ - 'toString', - 'toLocaleString', - 'valueOf', - 'hasOwnProperty', - 'isPrototypeOf', - 'propertyIsEnumerable', - 'constructor' - ], - dontEnumsLength = dontEnums.length; - - return function(obj) { - if (typeof obj !== 'object' && (typeof obj !== 'function' || obj === null)) { - throw new TypeError('Object.keys called on non-object'); - } - - var result = [], prop, i; - - for (prop in obj) { - if (hasOwnProperty.call(obj, prop)) { - result.push(prop); - } - } - - if (hasDontEnumBug) { - for (i = 0; i < dontEnumsLength; i++) { - if (hasOwnProperty.call(obj, dontEnums[i])) { - result.push(dontEnums[i]); - } - } - } - return result; - }; - }()); - -function equalObjects(object, other, equalFunc, isLoose, stackA, stackB) { - var objProps = keys(object), - objLength = objProps.length, - othProps = keys(other), - othLength = othProps.length; - - if (objLength !== othLength && !isLoose) { - return false; - } - var index = objLength, key; - while (index--) { - key = objProps[index]; - if (!(isLoose ? key in other : hasOwnProperty.call(other, key))) { - return false; - } - } - var skipCtor = isLoose; - while (++index < objLength) { - key = objProps[index]; - var objValue = object[key], - othValue = other[key], - result; - - if (!(result === undefined ? equalFunc(objValue, othValue, isLoose, stackA, stackB) : result)) { - return false; - } - skipCtor || (skipCtor = key === 'constructor'); - } - if (!skipCtor) { - var objCtor = object.constructor, - othCtor = other.constructor; - - if (objCtor !== othCtor && - ('constructor' in object && 'constructor' in other) && - !(typeof objCtor === 'function' && objCtor instanceof objCtor && - typeof othCtor === 'function' && othCtor instanceof othCtor)) { - return false; - } - } - return true; -} - -function equalByTag(object, other, tag) { - switch (tag) { - case boolTag: - case dateTag: - return +object === +other; - - case errorTag: - return object.name === other.name && object.message === other.message; - - case numberTag: - return (object !== +object) ? - other !== +other : - object === +other; - - case regexpTag: - case stringTag: - return object === (other + ''); - } - return false; -} - -var isObject = Rx.internals.isObject = function(value) { - var type = typeof value; - return !!value && (type === 'object' || type === 'function'); -}; - -function isObjectLike(value) { - return !!value && typeof value === 'object'; -} - -function isLength(value) { - return typeof value === 'number' && value > -1 && value % 1 === 0 && value <= MAX_SAFE_INTEGER; -} - -var isHostObject = (function() { - try { - Object({ 'toString': 0 } + ''); - } catch(e) { - return function() { return false; }; - } - return function(value) { - return typeof value.toString !== 'function' && typeof (value + '') === 'string'; - }; -}()); - -function isTypedArray(value) { - return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objToString.call(value)]; -} - -var isArray = Array.isArray || function(value) { - return isObjectLike(value) && isLength(value.length) && objToString.call(value) === arrayTag; -}; - -function arraySome (array, predicate) { - var index = -1, - length = array.length; - - while (++index < length) { - if (predicate(array[index], index, array)) { - return true; - } - } - return false; -} - -function equalArrays(array, other, equalFunc, isLoose, stackA, stackB) { - var index = -1, - arrLength = array.length, - othLength = other.length; - - if (arrLength !== othLength && !(isLoose && othLength > arrLength)) { - return false; - } - // Ignore non-index properties. - while (++index < arrLength) { - var arrValue = array[index], - othValue = other[index], - result; - - if (result !== undefined) { - if (result) { - continue; - } - return false; - } - // Recursively compare arrays (susceptible to call stack limits). - if (isLoose) { - if (!arraySome(other, function(othValue) { - return arrValue === othValue || equalFunc(arrValue, othValue, isLoose, stackA, stackB); - })) { - return false; - } - } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, isLoose, stackA, stackB))) { - return false; - } - } - return true; -} - -function baseIsEqualDeep(object, other, equalFunc, isLoose, stackA, stackB) { - var objIsArr = isArray(object), - othIsArr = isArray(other), - objTag = arrayTag, - othTag = arrayTag; - - if (!objIsArr) { - objTag = objToString.call(object); - if (objTag === argsTag) { - objTag = objectTag; - } else if (objTag !== objectTag) { - objIsArr = isTypedArray(object); - } - } - if (!othIsArr) { - othTag = objToString.call(other); - if (othTag === argsTag) { - othTag = objectTag; - } - } - var objIsObj = objTag === objectTag && !isHostObject(object), - othIsObj = othTag === objectTag && !isHostObject(other), - isSameTag = objTag === othTag; - - if (isSameTag && !(objIsArr || objIsObj)) { - return equalByTag(object, other, objTag); - } - if (!isLoose) { - var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), - othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); - - if (objIsWrapped || othIsWrapped) { - return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, isLoose, stackA, stackB); - } - } - if (!isSameTag) { - return false; - } - // Assume cyclic values are equal. - // For more information on detecting circular references see https://es5.github.io/#JO. - stackA || (stackA = []); - stackB || (stackB = []); - - var length = stackA.length; - while (length--) { - if (stackA[length] === object) { - return stackB[length] === other; - } - } - // Add `object` and `other` to the stack of traversed objects. - stackA.push(object); - stackB.push(other); - - var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, isLoose, stackA, stackB); - - stackA.pop(); - stackB.pop(); - - return result; -} - -function baseIsEqual(value, other, isLoose, stackA, stackB) { - if (value === other) { - return true; - } - if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) { - return value !== value && other !== other; - } - return baseIsEqualDeep(value, other, baseIsEqual, isLoose, stackA, stackB); -} - -var isEqual = Rx.internals.isEqual = function (value, other) { - return baseIsEqual(value, other); -}; - - var hasProp = {}.hasOwnProperty, - slice = Array.prototype.slice; - - var inherits = Rx.internals.inherits = function (child, parent) { - function __() { this.constructor = child; } - __.prototype = parent.prototype; - child.prototype = new __(); - }; - - var addProperties = Rx.internals.addProperties = function (obj) { - for(var sources = [], i = 1, len = arguments.length; i < len; i++) { sources.push(arguments[i]); } - for (var idx = 0, ln = sources.length; idx < ln; idx++) { - var source = sources[idx]; - for (var prop in source) { - obj[prop] = source[prop]; - } - } - }; - - // Rx Utils - var addRef = Rx.internals.addRef = function (xs, r) { - return new AnonymousObservable(function (observer) { - return new BinaryDisposable(r.getDisposable(), xs.subscribe(observer)); - }); - }; - - function arrayInitialize(count, factory) { - var a = new Array(count); - for (var i = 0; i < count; i++) { - a[i] = factory(); - } - return a; - } - - /** - * Represents a group of disposable resources that are disposed together. - * @constructor - */ - var CompositeDisposable = Rx.CompositeDisposable = function () { - var args = [], i, len; - if (Array.isArray(arguments[0])) { - args = arguments[0]; - } else { - len = arguments.length; - args = new Array(len); - for(i = 0; i < len; i++) { args[i] = arguments[i]; } - } - this.disposables = args; - this.isDisposed = false; - this.length = args.length; - }; - - var CompositeDisposablePrototype = CompositeDisposable.prototype; - - /** - * Adds a disposable to the CompositeDisposable or disposes the disposable if the CompositeDisposable is disposed. - * @param {Mixed} item Disposable to add. - */ - CompositeDisposablePrototype.add = function (item) { - if (this.isDisposed) { - item.dispose(); - } else { - this.disposables.push(item); - this.length++; - } - }; - - /** - * Removes and disposes the first occurrence of a disposable from the CompositeDisposable. - * @param {Mixed} item Disposable to remove. - * @returns {Boolean} true if found; false otherwise. - */ - CompositeDisposablePrototype.remove = function (item) { - var shouldDispose = false; - if (!this.isDisposed) { - var idx = this.disposables.indexOf(item); - if (idx !== -1) { - shouldDispose = true; - this.disposables.splice(idx, 1); - this.length--; - item.dispose(); - } - } - return shouldDispose; - }; - - /** - * Disposes all disposables in the group and removes them from the group. - */ - CompositeDisposablePrototype.dispose = function () { - if (!this.isDisposed) { - this.isDisposed = true; - var len = this.disposables.length, currentDisposables = new Array(len); - for(var i = 0; i < len; i++) { currentDisposables[i] = this.disposables[i]; } - this.disposables = []; - this.length = 0; - - for (i = 0; i < len; i++) { - currentDisposables[i].dispose(); - } - } - }; - - /** - * Provides a set of static methods for creating Disposables. - * @param {Function} dispose Action to run during the first call to dispose. The action is guaranteed to be run at most once. - */ - var Disposable = Rx.Disposable = function (action) { - this.isDisposed = false; - this.action = action || noop; - }; - - /** Performs the task of cleaning up resources. */ - Disposable.prototype.dispose = function () { - if (!this.isDisposed) { - this.action(); - this.isDisposed = true; - } - }; - - /** - * Creates a disposable object that invokes the specified action when disposed. - * @param {Function} dispose Action to run during the first call to dispose. The action is guaranteed to be run at most once. - * @return {Disposable} The disposable object that runs the given action upon disposal. - */ - var disposableCreate = Disposable.create = function (action) { return new Disposable(action); }; - - /** - * Gets the disposable that does nothing when disposed. - */ - var disposableEmpty = Disposable.empty = { dispose: noop }; - - /** - * Validates whether the given object is a disposable - * @param {Object} Object to test whether it has a dispose method - * @returns {Boolean} true if a disposable object, else false. - */ - var isDisposable = Disposable.isDisposable = function (d) { - return d && isFunction(d.dispose); - }; - - var checkDisposed = Disposable.checkDisposed = function (disposable) { - if (disposable.isDisposed) { throw new ObjectDisposedError(); } - }; - - var disposableFixup = Disposable._fixup = function (result) { - return isDisposable(result) ? result : disposableEmpty; - }; - - // Single assignment - var SingleAssignmentDisposable = Rx.SingleAssignmentDisposable = function () { - this.isDisposed = false; - this.current = null; - }; - SingleAssignmentDisposable.prototype.getDisposable = function () { - return this.current; - }; - SingleAssignmentDisposable.prototype.setDisposable = function (value) { - if (this.current) { throw new Error('Disposable has already been assigned'); } - var shouldDispose = this.isDisposed; - !shouldDispose && (this.current = value); - shouldDispose && value && value.dispose(); - }; - SingleAssignmentDisposable.prototype.dispose = function () { - if (!this.isDisposed) { - this.isDisposed = true; - var old = this.current; - this.current = null; - old && old.dispose(); - } - }; - - // Multiple assignment disposable - var SerialDisposable = Rx.SerialDisposable = function () { - this.isDisposed = false; - this.current = null; - }; - SerialDisposable.prototype.getDisposable = function () { - return this.current; - }; - SerialDisposable.prototype.setDisposable = function (value) { - var shouldDispose = this.isDisposed; - if (!shouldDispose) { - var old = this.current; - this.current = value; - } - old && old.dispose(); - shouldDispose && value && value.dispose(); - }; - SerialDisposable.prototype.dispose = function () { - if (!this.isDisposed) { - this.isDisposed = true; - var old = this.current; - this.current = null; - } - old && old.dispose(); - }; - - var BinaryDisposable = Rx.BinaryDisposable = function (first, second) { - this._first = first; - this._second = second; - this.isDisposed = false; - }; - - BinaryDisposable.prototype.dispose = function () { - if (!this.isDisposed) { - this.isDisposed = true; - var old1 = this._first; - this._first = null; - old1 && old1.dispose(); - var old2 = this._second; - this._second = null; - old2 && old2.dispose(); - } - }; - - var NAryDisposable = Rx.NAryDisposable = function (disposables) { - this._disposables = disposables; - this.isDisposed = false; - }; - - NAryDisposable.prototype.dispose = function () { - if (!this.isDisposed) { - this.isDisposed = true; - for (var i = 0, len = this._disposables.length; i < len; i++) { - this._disposables[i].dispose(); - } - this._disposables.length = 0; - } - }; - - /** - * Represents a disposable resource that only disposes its underlying disposable resource when all dependent disposable objects have been disposed. - */ - var RefCountDisposable = Rx.RefCountDisposable = (function () { - - function InnerDisposable(disposable) { - this.disposable = disposable; - this.disposable.count++; - this.isInnerDisposed = false; - } - - InnerDisposable.prototype.dispose = function () { - if (!this.disposable.isDisposed && !this.isInnerDisposed) { - this.isInnerDisposed = true; - this.disposable.count--; - if (this.disposable.count === 0 && this.disposable.isPrimaryDisposed) { - this.disposable.isDisposed = true; - this.disposable.underlyingDisposable.dispose(); - } - } - }; - - /** - * Initializes a new instance of the RefCountDisposable with the specified disposable. - * @constructor - * @param {Disposable} disposable Underlying disposable. - */ - function RefCountDisposable(disposable) { - this.underlyingDisposable = disposable; - this.isDisposed = false; - this.isPrimaryDisposed = false; - this.count = 0; - } - - /** - * Disposes the underlying disposable only when all dependent disposables have been disposed - */ - RefCountDisposable.prototype.dispose = function () { - if (!this.isDisposed && !this.isPrimaryDisposed) { - this.isPrimaryDisposed = true; - if (this.count === 0) { - this.isDisposed = true; - this.underlyingDisposable.dispose(); - } - } - }; - - /** - * Returns a dependent disposable that when disposed decreases the refcount on the underlying disposable. - * @returns {Disposable} A dependent disposable contributing to the reference count that manages the underlying disposable's lifetime. - */ - RefCountDisposable.prototype.getDisposable = function () { - return this.isDisposed ? disposableEmpty : new InnerDisposable(this); - }; - - return RefCountDisposable; - })(); - - function ScheduledDisposable(scheduler, disposable) { - this.scheduler = scheduler; - this.disposable = disposable; - this.isDisposed = false; - } - - function scheduleItem(s, self) { - if (!self.isDisposed) { - self.isDisposed = true; - self.disposable.dispose(); - } - } - - ScheduledDisposable.prototype.dispose = function () { - this.scheduler.schedule(this, scheduleItem); - }; - - var ScheduledItem = Rx.internals.ScheduledItem = function (scheduler, state, action, dueTime, comparer) { - this.scheduler = scheduler; - this.state = state; - this.action = action; - this.dueTime = dueTime; - this.comparer = comparer || defaultSubComparer; - this.disposable = new SingleAssignmentDisposable(); - }; - - ScheduledItem.prototype.invoke = function () { - this.disposable.setDisposable(this.invokeCore()); - }; - - ScheduledItem.prototype.compareTo = function (other) { - return this.comparer(this.dueTime, other.dueTime); - }; - - ScheduledItem.prototype.isCancelled = function () { - return this.disposable.isDisposed; - }; - - ScheduledItem.prototype.invokeCore = function () { - return disposableFixup(this.action(this.scheduler, this.state)); - }; - - /** Provides a set of static properties to access commonly used schedulers. */ - var Scheduler = Rx.Scheduler = (function () { - - function Scheduler() { } - - /** Determines whether the given object is a scheduler */ - Scheduler.isScheduler = function (s) { - return s instanceof Scheduler; - }; - - var schedulerProto = Scheduler.prototype; - - /** - * Schedules an action to be executed. - * @param state State passed to the action to be executed. - * @param {Function} action Action to be executed. - * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). - */ - schedulerProto.schedule = function (state, action) { - throw new NotImplementedError(); - }; - - /** - * Schedules an action to be executed after dueTime. - * @param state State passed to the action to be executed. - * @param {Function} action Action to be executed. - * @param {Number} dueTime Relative time after which to execute the action. - * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). - */ - schedulerProto.scheduleFuture = function (state, dueTime, action) { - var dt = dueTime; - dt instanceof Date && (dt = dt - this.now()); - dt = Scheduler.normalize(dt); - - if (dt === 0) { return this.schedule(state, action); } - - return this._scheduleFuture(state, dt, action); - }; - - schedulerProto._scheduleFuture = function (state, dueTime, action) { - throw new NotImplementedError(); - }; - - /** Gets the current time according to the local machine's system clock. */ - Scheduler.now = defaultNow; - - /** Gets the current time according to the local machine's system clock. */ - Scheduler.prototype.now = defaultNow; - - /** - * Normalizes the specified TimeSpan value to a positive value. - * @param {Number} timeSpan The time span value to normalize. - * @returns {Number} The specified TimeSpan value if it is zero or positive; otherwise, 0 - */ - Scheduler.normalize = function (timeSpan) { - timeSpan < 0 && (timeSpan = 0); - return timeSpan; - }; - - return Scheduler; - }()); - - var normalizeTime = Scheduler.normalize, isScheduler = Scheduler.isScheduler; - - (function (schedulerProto) { - - function invokeRecImmediate(scheduler, pair) { - var state = pair[0], action = pair[1], group = new CompositeDisposable(); - action(state, innerAction); - return group; - - function innerAction(state2) { - var isAdded = false, isDone = false; - - var d = scheduler.schedule(state2, scheduleWork); - if (!isDone) { - group.add(d); - isAdded = true; - } - - function scheduleWork(_, state3) { - if (isAdded) { - group.remove(d); - } else { - isDone = true; - } - action(state3, innerAction); - return disposableEmpty; - } - } - } - - function invokeRecDate(scheduler, pair) { - var state = pair[0], action = pair[1], group = new CompositeDisposable(); - action(state, innerAction); - return group; - - function innerAction(state2, dueTime1) { - var isAdded = false, isDone = false; - - var d = scheduler.scheduleFuture(state2, dueTime1, scheduleWork); - if (!isDone) { - group.add(d); - isAdded = true; - } - - function scheduleWork(_, state3) { - if (isAdded) { - group.remove(d); - } else { - isDone = true; - } - action(state3, innerAction); - return disposableEmpty; - } - } - } - - /** - * Schedules an action to be executed recursively. - * @param {Mixed} state State passed to the action to be executed. - * @param {Function} action Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in recursive invocation state. - * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). - */ - schedulerProto.scheduleRecursive = function (state, action) { - return this.schedule([state, action], invokeRecImmediate); - }; - - /** - * Schedules an action to be executed recursively after a specified relative or absolute due time. - * @param {Mixed} state State passed to the action to be executed. - * @param {Function} action Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in the recursive due time and invocation state. - * @param {Number | Date} dueTime Relative or absolute time after which to execute the action for the first time. - * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). - */ - schedulerProto.scheduleRecursiveFuture = function (state, dueTime, action) { - return this.scheduleFuture([state, action], dueTime, invokeRecDate); - }; - - }(Scheduler.prototype)); - - (function (schedulerProto) { - - /** - * Schedules a periodic piece of work by dynamically discovering the scheduler's capabilities. The periodic task will be scheduled using window.setInterval for the base implementation. - * @param {Mixed} state Initial state passed to the action upon the first iteration. - * @param {Number} period Period for running the work periodically. - * @param {Function} action Action to be executed, potentially updating the state. - * @returns {Disposable} The disposable object used to cancel the scheduled recurring action (best effort). - */ - schedulerProto.schedulePeriodic = function(state, period, action) { - if (typeof root.setInterval === 'undefined') { throw new NotSupportedError(); } - period = normalizeTime(period); - var s = state, id = root.setInterval(function () { s = action(s); }, period); - return disposableCreate(function () { root.clearInterval(id); }); - }; - - }(Scheduler.prototype)); - - (function (schedulerProto) { - /** - * Returns a scheduler that wraps the original scheduler, adding exception handling for scheduled actions. - * @param {Function} handler Handler that's run if an exception is caught. The exception will be rethrown if the handler returns false. - * @returns {Scheduler} Wrapper around the original scheduler, enforcing exception handling. - */ - schedulerProto.catchError = schedulerProto['catch'] = function (handler) { - return new CatchScheduler(this, handler); - }; - }(Scheduler.prototype)); - - var SchedulePeriodicRecursive = Rx.internals.SchedulePeriodicRecursive = (function () { - function createTick(self) { - return function tick(command, recurse) { - recurse(0, self._period); - var state = tryCatch(self._action)(self._state); - if (state === errorObj) { - self._cancel.dispose(); - thrower(state.e); - } - self._state = state; - }; - } - - function SchedulePeriodicRecursive(scheduler, state, period, action) { - this._scheduler = scheduler; - this._state = state; - this._period = period; - this._action = action; - } - - SchedulePeriodicRecursive.prototype.start = function () { - var d = new SingleAssignmentDisposable(); - this._cancel = d; - d.setDisposable(this._scheduler.scheduleRecursiveFuture(0, this._period, createTick(this))); - - return d; - }; - - return SchedulePeriodicRecursive; - }()); - - /** Gets a scheduler that schedules work immediately on the current thread. */ - var ImmediateScheduler = (function (__super__) { - inherits(ImmediateScheduler, __super__); - function ImmediateScheduler() { - __super__.call(this); - } - - ImmediateScheduler.prototype.schedule = function (state, action) { - return disposableFixup(action(this, state)); - }; - - return ImmediateScheduler; - }(Scheduler)); - - var immediateScheduler = Scheduler.immediate = new ImmediateScheduler(); - - /** - * Gets a scheduler that schedules work as soon as possible on the current thread. - */ - var CurrentThreadScheduler = (function (__super__) { - var queue; - - function runTrampoline () { - while (queue.length > 0) { - var item = queue.dequeue(); - !item.isCancelled() && item.invoke(); - } - } - - inherits(CurrentThreadScheduler, __super__); - function CurrentThreadScheduler() { - __super__.call(this); - } - - CurrentThreadScheduler.prototype.schedule = function (state, action) { - var si = new ScheduledItem(this, state, action, this.now()); - - if (!queue) { - queue = new PriorityQueue(4); - queue.enqueue(si); - - var result = tryCatch(runTrampoline)(); - queue = null; - if (result === errorObj) { thrower(result.e); } - } else { - queue.enqueue(si); - } - return si.disposable; - }; - - CurrentThreadScheduler.prototype.scheduleRequired = function () { return !queue; }; - - return CurrentThreadScheduler; - }(Scheduler)); - - var currentThreadScheduler = Scheduler.currentThread = new CurrentThreadScheduler(); - - var scheduleMethod, clearMethod; - - var localTimer = (function () { - var localSetTimeout, localClearTimeout = noop; - if (!!root.setTimeout) { - localSetTimeout = root.setTimeout; - localClearTimeout = root.clearTimeout; - } else if (!!root.WScript) { - localSetTimeout = function (fn, time) { - root.WScript.Sleep(time); - fn(); - }; - } else { - throw new NotSupportedError(); - } - - return { - setTimeout: localSetTimeout, - clearTimeout: localClearTimeout - }; - }()); - var localSetTimeout = localTimer.setTimeout, - localClearTimeout = localTimer.clearTimeout; - - (function () { - - var nextHandle = 1, tasksByHandle = {}, currentlyRunning = false; - - clearMethod = function (handle) { - delete tasksByHandle[handle]; - }; - - function runTask(handle) { - if (currentlyRunning) { - localSetTimeout(function () { runTask(handle); }, 0); - } else { - var task = tasksByHandle[handle]; - if (task) { - currentlyRunning = true; - var result = tryCatch(task)(); - clearMethod(handle); - currentlyRunning = false; - if (result === errorObj) { thrower(result.e); } - } - } - } - - var reNative = new RegExp('^' + - String(toString) - .replace(/[.*+?^${}()|[\]\\]/g, '\\$&') - .replace(/toString| for [^\]]+/g, '.*?') + '$' - ); - - var setImmediate = typeof (setImmediate = freeGlobal && moduleExports && freeGlobal.setImmediate) == 'function' && - !reNative.test(setImmediate) && setImmediate; - - function postMessageSupported () { - // Ensure not in a worker - if (!root.postMessage || root.importScripts) { return false; } - var isAsync = false, oldHandler = root.onmessage; - // Test for async - root.onmessage = function () { isAsync = true; }; - root.postMessage('', '*'); - root.onmessage = oldHandler; - - return isAsync; - } - - // Use in order, setImmediate, nextTick, postMessage, MessageChannel, script readystatechanged, setTimeout - if (isFunction(setImmediate)) { - scheduleMethod = function (action) { - var id = nextHandle++; - tasksByHandle[id] = action; - setImmediate(function () { runTask(id); }); - - return id; - }; - } else if (typeof process !== 'undefined' && {}.toString.call(process) === '[object process]') { - scheduleMethod = function (action) { - var id = nextHandle++; - tasksByHandle[id] = action; - process.nextTick(function () { runTask(id); }); - - return id; - }; - } else if (postMessageSupported()) { - var MSG_PREFIX = 'ms.rx.schedule' + Math.random(); - - var onGlobalPostMessage = function (event) { - // Only if we're a match to avoid any other global events - if (typeof event.data === 'string' && event.data.substring(0, MSG_PREFIX.length) === MSG_PREFIX) { - runTask(event.data.substring(MSG_PREFIX.length)); - } - }; - - root.addEventListener('message', onGlobalPostMessage, false); - - scheduleMethod = function (action) { - var id = nextHandle++; - tasksByHandle[id] = action; - root.postMessage(MSG_PREFIX + id, '*'); - return id; - }; - } else if (!!root.MessageChannel) { - var channel = new root.MessageChannel(); - - channel.port1.onmessage = function (e) { runTask(e.data); }; - - scheduleMethod = function (action) { - var id = nextHandle++; - tasksByHandle[id] = action; - channel.port2.postMessage(id); - return id; - }; - } else if ('document' in root && 'onreadystatechange' in root.document.createElement('script')) { - - scheduleMethod = function (action) { - var scriptElement = root.document.createElement('script'); - var id = nextHandle++; - tasksByHandle[id] = action; - - scriptElement.onreadystatechange = function () { - runTask(id); - scriptElement.onreadystatechange = null; - scriptElement.parentNode.removeChild(scriptElement); - scriptElement = null; - }; - root.document.documentElement.appendChild(scriptElement); - return id; - }; - - } else { - scheduleMethod = function (action) { - var id = nextHandle++; - tasksByHandle[id] = action; - localSetTimeout(function () { - runTask(id); - }, 0); - - return id; - }; - } - }()); - - /** - * Gets a scheduler that schedules work via a timed callback based upon platform. - */ - var DefaultScheduler = (function (__super__) { - inherits(DefaultScheduler, __super__); - function DefaultScheduler() { - __super__.call(this); - } - - function scheduleAction(disposable, action, scheduler, state) { - return function schedule() { - disposable.setDisposable(Disposable._fixup(action(scheduler, state))); - }; - } - - function ClearDisposable(id) { - this._id = id; - this.isDisposed = false; - } - - ClearDisposable.prototype.dispose = function () { - if (!this.isDisposed) { - this.isDisposed = true; - clearMethod(this._id); - } - }; - - function LocalClearDisposable(id) { - this._id = id; - this.isDisposed = false; - } - - LocalClearDisposable.prototype.dispose = function () { - if (!this.isDisposed) { - this.isDisposed = true; - localClearTimeout(this._id); - } - }; - - DefaultScheduler.prototype.schedule = function (state, action) { - var disposable = new SingleAssignmentDisposable(), - id = scheduleMethod(scheduleAction(disposable, action, this, state)); - return new BinaryDisposable(disposable, new ClearDisposable(id)); - }; - - DefaultScheduler.prototype._scheduleFuture = function (state, dueTime, action) { - if (dueTime === 0) { return this.schedule(state, action); } - var disposable = new SingleAssignmentDisposable(), - id = localSetTimeout(scheduleAction(disposable, action, this, state), dueTime); - return new BinaryDisposable(disposable, new LocalClearDisposable(id)); - }; - - function scheduleLongRunning(state, action, disposable) { - return function () { action(state, disposable); }; - } - - DefaultScheduler.prototype.scheduleLongRunning = function (state, action) { - var disposable = disposableCreate(noop); - scheduleMethod(scheduleLongRunning(state, action, disposable)); - return disposable; - }; - - return DefaultScheduler; - }(Scheduler)); - - var defaultScheduler = Scheduler['default'] = Scheduler.async = new DefaultScheduler(); - - var CatchScheduler = (function (__super__) { - inherits(CatchScheduler, __super__); - - function CatchScheduler(scheduler, handler) { - this._scheduler = scheduler; - this._handler = handler; - this._recursiveOriginal = null; - this._recursiveWrapper = null; - __super__.call(this); - } - - CatchScheduler.prototype.schedule = function (state, action) { - return this._scheduler.schedule(state, this._wrap(action)); - }; - - CatchScheduler.prototype._scheduleFuture = function (state, dueTime, action) { - return this._scheduler.schedule(state, dueTime, this._wrap(action)); - }; - - CatchScheduler.prototype.now = function () { return this._scheduler.now(); }; - - CatchScheduler.prototype._clone = function (scheduler) { - return new CatchScheduler(scheduler, this._handler); - }; - - CatchScheduler.prototype._wrap = function (action) { - var parent = this; - return function (self, state) { - var res = tryCatch(action)(parent._getRecursiveWrapper(self), state); - if (res === errorObj) { - if (!parent._handler(res.e)) { thrower(res.e); } - return disposableEmpty; - } - return disposableFixup(res); - }; - }; - - CatchScheduler.prototype._getRecursiveWrapper = function (scheduler) { - if (this._recursiveOriginal !== scheduler) { - this._recursiveOriginal = scheduler; - var wrapper = this._clone(scheduler); - wrapper._recursiveOriginal = scheduler; - wrapper._recursiveWrapper = wrapper; - this._recursiveWrapper = wrapper; - } - return this._recursiveWrapper; - }; - - CatchScheduler.prototype.schedulePeriodic = function (state, period, action) { - var self = this, failed = false, d = new SingleAssignmentDisposable(); - - d.setDisposable(this._scheduler.schedulePeriodic(state, period, function (state1) { - if (failed) { return null; } - var res = tryCatch(action)(state1); - if (res === errorObj) { - failed = true; - if (!self._handler(res.e)) { thrower(res.e); } - d.dispose(); - return null; - } - return res; - })); - - return d; - }; - - return CatchScheduler; - }(Scheduler)); - - function IndexedItem(id, value) { - this.id = id; - this.value = value; - } - - IndexedItem.prototype.compareTo = function (other) { - var c = this.value.compareTo(other.value); - c === 0 && (c = this.id - other.id); - return c; - }; - - var PriorityQueue = Rx.internals.PriorityQueue = function (capacity) { - this.items = new Array(capacity); - this.length = 0; - }; - - var priorityProto = PriorityQueue.prototype; - priorityProto.isHigherPriority = function (left, right) { - return this.items[left].compareTo(this.items[right]) < 0; - }; - - priorityProto.percolate = function (index) { - if (index >= this.length || index < 0) { return; } - var parent = index - 1 >> 1; - if (parent < 0 || parent === index) { return; } - if (this.isHigherPriority(index, parent)) { - var temp = this.items[index]; - this.items[index] = this.items[parent]; - this.items[parent] = temp; - this.percolate(parent); - } - }; - - priorityProto.heapify = function (index) { - +index || (index = 0); - if (index >= this.length || index < 0) { return; } - var left = 2 * index + 1, - right = 2 * index + 2, - first = index; - if (left < this.length && this.isHigherPriority(left, first)) { - first = left; - } - if (right < this.length && this.isHigherPriority(right, first)) { - first = right; - } - if (first !== index) { - var temp = this.items[index]; - this.items[index] = this.items[first]; - this.items[first] = temp; - this.heapify(first); - } - }; - - priorityProto.peek = function () { return this.items[0].value; }; - - priorityProto.removeAt = function (index) { - this.items[index] = this.items[--this.length]; - this.items[this.length] = undefined; - this.heapify(); - }; - - priorityProto.dequeue = function () { - var result = this.peek(); - this.removeAt(0); - return result; - }; - - priorityProto.enqueue = function (item) { - var index = this.length++; - this.items[index] = new IndexedItem(PriorityQueue.count++, item); - this.percolate(index); - }; - - priorityProto.remove = function (item) { - for (var i = 0; i < this.length; i++) { - if (this.items[i].value === item) { - this.removeAt(i); - return true; - } - } - return false; - }; - PriorityQueue.count = 0; - - /** - * Represents a notification to an observer. - */ - var Notification = Rx.Notification = (function () { - function Notification() { - - } - - Notification.prototype._accept = function (onNext, onError, onCompleted) { - throw new NotImplementedError(); - }; - - Notification.prototype._acceptObserver = function (onNext, onError, onCompleted) { - throw new NotImplementedError(); - }; - - /** - * Invokes the delegate corresponding to the notification or the observer's method corresponding to the notification and returns the produced result. - * @param {Function | Observer} observerOrOnNext Function to invoke for an OnNext notification or Observer to invoke the notification on.. - * @param {Function} onError Function to invoke for an OnError notification. - * @param {Function} onCompleted Function to invoke for an OnCompleted notification. - * @returns {Any} Result produced by the observation. - */ - Notification.prototype.accept = function (observerOrOnNext, onError, onCompleted) { - return observerOrOnNext && typeof observerOrOnNext === 'object' ? - this._acceptObserver(observerOrOnNext) : - this._accept(observerOrOnNext, onError, onCompleted); - }; - - /** - * Returns an observable sequence with a single notification. - * - * @memberOf Notifications - * @param {Scheduler} [scheduler] Scheduler to send out the notification calls on. - * @returns {Observable} The observable sequence that surfaces the behavior of the notification upon subscription. - */ - Notification.prototype.toObservable = function (scheduler) { - var self = this; - isScheduler(scheduler) || (scheduler = immediateScheduler); - return new AnonymousObservable(function (o) { - return scheduler.schedule(self, function (_, notification) { - notification._acceptObserver(o); - notification.kind === 'N' && o.onCompleted(); - }); - }); - }; - - return Notification; - })(); - - var OnNextNotification = (function (__super__) { - inherits(OnNextNotification, __super__); - function OnNextNotification(value) { - this.value = value; - this.kind = 'N'; - } - - OnNextNotification.prototype._accept = function (onNext) { - return onNext(this.value); - }; - - OnNextNotification.prototype._acceptObserver = function (o) { - return o.onNext(this.value); - }; - - OnNextNotification.prototype.toString = function () { - return 'OnNext(' + this.value + ')'; - }; - - return OnNextNotification; - }(Notification)); - - var OnErrorNotification = (function (__super__) { - inherits(OnErrorNotification, __super__); - function OnErrorNotification(error) { - this.error = error; - this.kind = 'E'; - } - - OnErrorNotification.prototype._accept = function (onNext, onError) { - return onError(this.error); - }; - - OnErrorNotification.prototype._acceptObserver = function (o) { - return o.onError(this.error); - }; - - OnErrorNotification.prototype.toString = function () { - return 'OnError(' + this.error + ')'; - }; - - return OnErrorNotification; - }(Notification)); - - var OnCompletedNotification = (function (__super__) { - inherits(OnCompletedNotification, __super__); - function OnCompletedNotification() { - this.kind = 'C'; - } - - OnCompletedNotification.prototype._accept = function (onNext, onError, onCompleted) { - return onCompleted(); - }; - - OnCompletedNotification.prototype._acceptObserver = function (o) { - return o.onCompleted(); - }; - - OnCompletedNotification.prototype.toString = function () { - return 'OnCompleted()'; - }; - - return OnCompletedNotification; - }(Notification)); - - /** - * Creates an object that represents an OnNext notification to an observer. - * @param {Any} value The value contained in the notification. - * @returns {Notification} The OnNext notification containing the value. - */ - var notificationCreateOnNext = Notification.createOnNext = function (value) { - return new OnNextNotification(value); - }; - - /** - * Creates an object that represents an OnError notification to an observer. - * @param {Any} error The exception contained in the notification. - * @returns {Notification} The OnError notification containing the exception. - */ - var notificationCreateOnError = Notification.createOnError = function (error) { - return new OnErrorNotification(error); - }; - - /** - * Creates an object that represents an OnCompleted notification to an observer. - * @returns {Notification} The OnCompleted notification. - */ - var notificationCreateOnCompleted = Notification.createOnCompleted = function () { - return new OnCompletedNotification(); - }; - - /** - * Supports push-style iteration over an observable sequence. - */ - var Observer = Rx.Observer = function () { }; - - /** - * Creates a notification callback from an observer. - * @returns The action that forwards its input notification to the underlying observer. - */ - Observer.prototype.toNotifier = function () { - var observer = this; - return function (n) { return n.accept(observer); }; - }; - - /** - * Hides the identity of an observer. - * @returns An observer that hides the identity of the specified observer. - */ - Observer.prototype.asObserver = function () { - var self = this; - return new AnonymousObserver( - function (x) { self.onNext(x); }, - function (err) { self.onError(err); }, - function () { self.onCompleted(); }); - }; - - /** - * Checks access to the observer for grammar violations. This includes checking for multiple OnError or OnCompleted calls, as well as reentrancy in any of the observer methods. - * If a violation is detected, an Error is thrown from the offending observer method call. - * @returns An observer that checks callbacks invocations against the observer grammar and, if the checks pass, forwards those to the specified observer. - */ - Observer.prototype.checked = function () { return new CheckedObserver(this); }; - - /** - * Creates an observer from the specified OnNext, along with optional OnError, and OnCompleted actions. - * @param {Function} [onNext] Observer's OnNext action implementation. - * @param {Function} [onError] Observer's OnError action implementation. - * @param {Function} [onCompleted] Observer's OnCompleted action implementation. - * @returns {Observer} The observer object implemented using the given actions. - */ - var observerCreate = Observer.create = function (onNext, onError, onCompleted) { - onNext || (onNext = noop); - onError || (onError = defaultError); - onCompleted || (onCompleted = noop); - return new AnonymousObserver(onNext, onError, onCompleted); - }; - - /** - * Creates an observer from a notification callback. - * @param {Function} handler Action that handles a notification. - * @returns The observer object that invokes the specified handler using a notification corresponding to each message it receives. - */ - Observer.fromNotifier = function (handler, thisArg) { - var cb = bindCallback(handler, thisArg, 1); - return new AnonymousObserver(function (x) { - return cb(notificationCreateOnNext(x)); - }, function (e) { - return cb(notificationCreateOnError(e)); - }, function () { - return cb(notificationCreateOnCompleted()); - }); - }; - - /** - * Schedules the invocation of observer methods on the given scheduler. - * @param {Scheduler} scheduler Scheduler to schedule observer messages on. - * @returns {Observer} Observer whose messages are scheduled on the given scheduler. - */ - Observer.prototype.notifyOn = function (scheduler) { - return new ObserveOnObserver(scheduler, this); - }; - - Observer.prototype.makeSafe = function(disposable) { - return new AnonymousSafeObserver(this._onNext, this._onError, this._onCompleted, disposable); - }; - - /** - * Abstract base class for implementations of the Observer class. - * This base class enforces the grammar of observers where OnError and OnCompleted are terminal messages. - */ - var AbstractObserver = Rx.internals.AbstractObserver = (function (__super__) { - inherits(AbstractObserver, __super__); - - /** - * Creates a new observer in a non-stopped state. - */ - function AbstractObserver() { - this.isStopped = false; - } - - // Must be implemented by other observers - AbstractObserver.prototype.next = notImplemented; - AbstractObserver.prototype.error = notImplemented; - AbstractObserver.prototype.completed = notImplemented; - - /** - * Notifies the observer of a new element in the sequence. - * @param {Any} value Next element in the sequence. - */ - AbstractObserver.prototype.onNext = function (value) { - !this.isStopped && this.next(value); - }; - - /** - * Notifies the observer that an exception has occurred. - * @param {Any} error The error that has occurred. - */ - AbstractObserver.prototype.onError = function (error) { - if (!this.isStopped) { - this.isStopped = true; - this.error(error); - } - }; - - /** - * Notifies the observer of the end of the sequence. - */ - AbstractObserver.prototype.onCompleted = function () { - if (!this.isStopped) { - this.isStopped = true; - this.completed(); - } - }; - - /** - * Disposes the observer, causing it to transition to the stopped state. - */ - AbstractObserver.prototype.dispose = function () { this.isStopped = true; }; - - AbstractObserver.prototype.fail = function (e) { - if (!this.isStopped) { - this.isStopped = true; - this.error(e); - return true; - } - - return false; - }; - - return AbstractObserver; - }(Observer)); - - /** - * Class to create an Observer instance from delegate-based implementations of the on* methods. - */ - var AnonymousObserver = Rx.AnonymousObserver = (function (__super__) { - inherits(AnonymousObserver, __super__); - - /** - * Creates an observer from the specified OnNext, OnError, and OnCompleted actions. - * @param {Any} onNext Observer's OnNext action implementation. - * @param {Any} onError Observer's OnError action implementation. - * @param {Any} onCompleted Observer's OnCompleted action implementation. - */ - function AnonymousObserver(onNext, onError, onCompleted) { - __super__.call(this); - this._onNext = onNext; - this._onError = onError; - this._onCompleted = onCompleted; - } - - /** - * Calls the onNext action. - * @param {Any} value Next element in the sequence. - */ - AnonymousObserver.prototype.next = function (value) { - this._onNext(value); - }; - - /** - * Calls the onError action. - * @param {Any} error The error that has occurred. - */ - AnonymousObserver.prototype.error = function (error) { - this._onError(error); - }; - - /** - * Calls the onCompleted action. - */ - AnonymousObserver.prototype.completed = function () { - this._onCompleted(); - }; - - return AnonymousObserver; - }(AbstractObserver)); - - var CheckedObserver = (function (__super__) { - inherits(CheckedObserver, __super__); - - function CheckedObserver(observer) { - __super__.call(this); - this._observer = observer; - this._state = 0; // 0 - idle, 1 - busy, 2 - done - } - - var CheckedObserverPrototype = CheckedObserver.prototype; - - CheckedObserverPrototype.onNext = function (value) { - this.checkAccess(); - var res = tryCatch(this._observer.onNext).call(this._observer, value); - this._state = 0; - res === errorObj && thrower(res.e); - }; - - CheckedObserverPrototype.onError = function (err) { - this.checkAccess(); - var res = tryCatch(this._observer.onError).call(this._observer, err); - this._state = 2; - res === errorObj && thrower(res.e); - }; - - CheckedObserverPrototype.onCompleted = function () { - this.checkAccess(); - var res = tryCatch(this._observer.onCompleted).call(this._observer); - this._state = 2; - res === errorObj && thrower(res.e); - }; - - CheckedObserverPrototype.checkAccess = function () { - if (this._state === 1) { throw new Error('Re-entrancy detected'); } - if (this._state === 2) { throw new Error('Observer completed'); } - if (this._state === 0) { this._state = 1; } - }; - - return CheckedObserver; - }(Observer)); - - var ScheduledObserver = Rx.internals.ScheduledObserver = (function (__super__) { - inherits(ScheduledObserver, __super__); - - function ScheduledObserver(scheduler, observer) { - __super__.call(this); - this.scheduler = scheduler; - this.observer = observer; - this.isAcquired = false; - this.hasFaulted = false; - this.queue = []; - this.disposable = new SerialDisposable(); - } - - function enqueueNext(observer, x) { return function () { observer.onNext(x); }; } - function enqueueError(observer, e) { return function () { observer.onError(e); }; } - function enqueueCompleted(observer) { return function () { observer.onCompleted(); }; } - - ScheduledObserver.prototype.next = function (x) { - this.queue.push(enqueueNext(this.observer, x)); - }; - - ScheduledObserver.prototype.error = function (e) { - this.queue.push(enqueueError(this.observer, e)); - }; - - ScheduledObserver.prototype.completed = function () { - this.queue.push(enqueueCompleted(this.observer)); - }; - - - function scheduleMethod(state, recurse) { - var work; - if (state.queue.length > 0) { - work = state.queue.shift(); - } else { - state.isAcquired = false; - return; - } - var res = tryCatch(work)(); - if (res === errorObj) { - state.queue = []; - state.hasFaulted = true; - return thrower(res.e); - } - recurse(state); - } - - ScheduledObserver.prototype.ensureActive = function () { - var isOwner = false; - if (!this.hasFaulted && this.queue.length > 0) { - isOwner = !this.isAcquired; - this.isAcquired = true; - } - isOwner && - this.disposable.setDisposable(this.scheduler.scheduleRecursive(this, scheduleMethod)); - }; - - ScheduledObserver.prototype.dispose = function () { - __super__.prototype.dispose.call(this); - this.disposable.dispose(); - }; - - return ScheduledObserver; - }(AbstractObserver)); - - var ObserveOnObserver = (function (__super__) { - inherits(ObserveOnObserver, __super__); - - function ObserveOnObserver(scheduler, observer, cancel) { - __super__.call(this, scheduler, observer); - this._cancel = cancel; - } - - ObserveOnObserver.prototype.next = function (value) { - __super__.prototype.next.call(this, value); - this.ensureActive(); - }; - - ObserveOnObserver.prototype.error = function (e) { - __super__.prototype.error.call(this, e); - this.ensureActive(); - }; - - ObserveOnObserver.prototype.completed = function () { - __super__.prototype.completed.call(this); - this.ensureActive(); - }; - - ObserveOnObserver.prototype.dispose = function () { - __super__.prototype.dispose.call(this); - this._cancel && this._cancel.dispose(); - this._cancel = null; - }; - - return ObserveOnObserver; - })(ScheduledObserver); - - var observableProto; - - /** - * Represents a push-style collection. - */ - var Observable = Rx.Observable = (function () { - - function makeSubscribe(self, subscribe) { - return function (o) { - var oldOnError = o.onError; - o.onError = function (e) { - makeStackTraceLong(e, self); - oldOnError.call(o, e); - }; - - return subscribe.call(self, o); - }; - } - - function Observable() { - if (Rx.config.longStackSupport && hasStacks) { - var oldSubscribe = this._subscribe; - var e = tryCatch(thrower)(new Error()).e; - this.stack = e.stack.substring(e.stack.indexOf('\n') + 1); - this._subscribe = makeSubscribe(this, oldSubscribe); - } - } - - observableProto = Observable.prototype; - - /** - * Determines whether the given object is an Observable - * @param {Any} An object to determine whether it is an Observable - * @returns {Boolean} true if an Observable, else false. - */ - Observable.isObservable = function (o) { - return o && isFunction(o.subscribe); - }; - - /** - * Subscribes an o to the observable sequence. - * @param {Mixed} [oOrOnNext] The object that is to receive notifications or an action to invoke for each element in the observable sequence. - * @param {Function} [onError] Action to invoke upon exceptional termination of the observable sequence. - * @param {Function} [onCompleted] Action to invoke upon graceful termination of the observable sequence. - * @returns {Diposable} A disposable handling the subscriptions and unsubscriptions. - */ - observableProto.subscribe = observableProto.forEach = function (oOrOnNext, onError, onCompleted) { - return this._subscribe(typeof oOrOnNext === 'object' ? - oOrOnNext : - observerCreate(oOrOnNext, onError, onCompleted)); - }; - - /** - * Subscribes to the next value in the sequence with an optional "this" argument. - * @param {Function} onNext The function to invoke on each element in the observable sequence. - * @param {Any} [thisArg] Object to use as this when executing callback. - * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions. - */ - observableProto.subscribeOnNext = function (onNext, thisArg) { - return this._subscribe(observerCreate(typeof thisArg !== 'undefined' ? function(x) { onNext.call(thisArg, x); } : onNext)); - }; - - /** - * Subscribes to an exceptional condition in the sequence with an optional "this" argument. - * @param {Function} onError The function to invoke upon exceptional termination of the observable sequence. - * @param {Any} [thisArg] Object to use as this when executing callback. - * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions. - */ - observableProto.subscribeOnError = function (onError, thisArg) { - return this._subscribe(observerCreate(null, typeof thisArg !== 'undefined' ? function(e) { onError.call(thisArg, e); } : onError)); - }; - - /** - * Subscribes to the next value in the sequence with an optional "this" argument. - * @param {Function} onCompleted The function to invoke upon graceful termination of the observable sequence. - * @param {Any} [thisArg] Object to use as this when executing callback. - * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions. - */ - observableProto.subscribeOnCompleted = function (onCompleted, thisArg) { - return this._subscribe(observerCreate(null, null, typeof thisArg !== 'undefined' ? function() { onCompleted.call(thisArg); } : onCompleted)); - }; - - return Observable; - })(); - - var ObservableBase = Rx.ObservableBase = (function (__super__) { - inherits(ObservableBase, __super__); - - function fixSubscriber(subscriber) { - return subscriber && isFunction(subscriber.dispose) ? subscriber : - isFunction(subscriber) ? disposableCreate(subscriber) : disposableEmpty; - } - - function setDisposable(s, state) { - var ado = state[0], self = state[1]; - var sub = tryCatch(self.subscribeCore).call(self, ado); - if (sub === errorObj && !ado.fail(errorObj.e)) { thrower(errorObj.e); } - ado.setDisposable(fixSubscriber(sub)); - } - - function ObservableBase() { - __super__.call(this); - } - - ObservableBase.prototype._subscribe = function (o) { - var ado = new AutoDetachObserver(o), state = [ado, this]; - - if (currentThreadScheduler.scheduleRequired()) { - currentThreadScheduler.schedule(state, setDisposable); - } else { - setDisposable(null, state); - } - return ado; - }; - - ObservableBase.prototype.subscribeCore = notImplemented; - - return ObservableBase; - }(Observable)); - -var FlatMapObservable = Rx.FlatMapObservable = (function(__super__) { - - inherits(FlatMapObservable, __super__); - - function FlatMapObservable(source, selector, resultSelector, thisArg) { - this.resultSelector = isFunction(resultSelector) ? resultSelector : null; - this.selector = bindCallback(isFunction(selector) ? selector : function() { return selector; }, thisArg, 3); - this.source = source; - __super__.call(this); - } - - FlatMapObservable.prototype.subscribeCore = function(o) { - return this.source.subscribe(new InnerObserver(o, this.selector, this.resultSelector, this)); - }; - - inherits(InnerObserver, AbstractObserver); - function InnerObserver(observer, selector, resultSelector, source) { - this.i = 0; - this.selector = selector; - this.resultSelector = resultSelector; - this.source = source; - this.o = observer; - AbstractObserver.call(this); - } - - InnerObserver.prototype._wrapResult = function(result, x, i) { - return this.resultSelector ? - result.map(function(y, i2) { return this.resultSelector(x, y, i, i2); }, this) : - result; - }; - - InnerObserver.prototype.next = function(x) { - var i = this.i++; - var result = tryCatch(this.selector)(x, i, this.source); - if (result === errorObj) { return this.o.onError(result.e); } - - isPromise(result) && (result = observableFromPromise(result)); - (isArrayLike(result) || isIterable(result)) && (result = Observable.from(result)); - this.o.onNext(this._wrapResult(result, x, i)); - }; - - InnerObserver.prototype.error = function(e) { this.o.onError(e); }; - - InnerObserver.prototype.completed = function() { this.o.onCompleted(); }; - - return FlatMapObservable; - -}(ObservableBase)); - - var Enumerable = Rx.internals.Enumerable = function () { }; - - function IsDisposedDisposable(state) { - this._s = state; - this.isDisposed = false; - } - - IsDisposedDisposable.prototype.dispose = function () { - if (!this.isDisposed) { - this.isDisposed = true; - this._s.isDisposed = true; - } - }; - - var ConcatEnumerableObservable = (function(__super__) { - inherits(ConcatEnumerableObservable, __super__); - function ConcatEnumerableObservable(sources) { - this.sources = sources; - __super__.call(this); - } - - function scheduleMethod(state, recurse) { - if (state.isDisposed) { return; } - var currentItem = tryCatch(state.e.next).call(state.e); - if (currentItem === errorObj) { return state.o.onError(currentItem.e); } - if (currentItem.done) { return state.o.onCompleted(); } - - // Check if promise - var currentValue = currentItem.value; - isPromise(currentValue) && (currentValue = observableFromPromise(currentValue)); - - var d = new SingleAssignmentDisposable(); - state.subscription.setDisposable(d); - d.setDisposable(currentValue.subscribe(new InnerObserver(state, recurse))); - } - - ConcatEnumerableObservable.prototype.subscribeCore = function (o) { - var subscription = new SerialDisposable(); - var state = { - isDisposed: false, - o: o, - subscription: subscription, - e: this.sources[$iterator$]() - }; - - var cancelable = currentThreadScheduler.scheduleRecursive(state, scheduleMethod); - return new NAryDisposable([subscription, cancelable, new IsDisposedDisposable(state)]); - }; - - function InnerObserver(state, recurse) { - this._state = state; - this._recurse = recurse; - AbstractObserver.call(this); - } - - inherits(InnerObserver, AbstractObserver); - - InnerObserver.prototype.next = function (x) { this._state.o.onNext(x); }; - InnerObserver.prototype.error = function (e) { this._state.o.onError(e); }; - InnerObserver.prototype.completed = function () { this._recurse(this._state); }; - - return ConcatEnumerableObservable; - }(ObservableBase)); - - Enumerable.prototype.concat = function () { - return new ConcatEnumerableObservable(this); - }; - - var CatchErrorObservable = (function(__super__) { - function CatchErrorObservable(sources) { - this.sources = sources; - __super__.call(this); - } - - inherits(CatchErrorObservable, __super__); - - function scheduleMethod(state, recurse) { - if (state.isDisposed) { return; } - var currentItem = tryCatch(state.e.next).call(state.e); - if (currentItem === errorObj) { return state.o.onError(currentItem.e); } - if (currentItem.done) { return state.lastError !== null ? state.o.onError(state.lastError) : state.o.onCompleted(); } - - var currentValue = currentItem.value; - isPromise(currentValue) && (currentValue = observableFromPromise(currentValue)); - - var d = new SingleAssignmentDisposable(); - state.subscription.setDisposable(d); - d.setDisposable(currentValue.subscribe(new InnerObserver(state, recurse))); - } - - CatchErrorObservable.prototype.subscribeCore = function (o) { - var subscription = new SerialDisposable(); - var state = { - isDisposed: false, - e: this.sources[$iterator$](), - subscription: subscription, - lastError: null, - o: o - }; - - var cancelable = currentThreadScheduler.scheduleRecursive(state, scheduleMethod); - return new NAryDisposable([subscription, cancelable, new IsDisposedDisposable(state)]); - }; - - function InnerObserver(state, recurse) { - this._state = state; - this._recurse = recurse; - AbstractObserver.call(this); - } - - inherits(InnerObserver, AbstractObserver); - - InnerObserver.prototype.next = function (x) { this._state.o.onNext(x); }; - InnerObserver.prototype.error = function (e) { this._state.lastError = e; this._recurse(this._state); }; - InnerObserver.prototype.completed = function () { this._state.o.onCompleted(); }; - - return CatchErrorObservable; - }(ObservableBase)); - - Enumerable.prototype.catchError = function () { - return new CatchErrorObservable(this); - }; - - var RepeatEnumerable = (function (__super__) { - inherits(RepeatEnumerable, __super__); - function RepeatEnumerable(v, c) { - this.v = v; - this.c = c == null ? -1 : c; - } - - RepeatEnumerable.prototype[$iterator$] = function () { - return new RepeatEnumerator(this); - }; - - function RepeatEnumerator(p) { - this.v = p.v; - this.l = p.c; - } - - RepeatEnumerator.prototype.next = function () { - if (this.l === 0) { return doneEnumerator; } - if (this.l > 0) { this.l--; } - return { done: false, value: this.v }; - }; - - return RepeatEnumerable; - }(Enumerable)); - - var enumerableRepeat = Enumerable.repeat = function (value, repeatCount) { - return new RepeatEnumerable(value, repeatCount); - }; - - var OfEnumerable = (function(__super__) { - inherits(OfEnumerable, __super__); - function OfEnumerable(s, fn, thisArg) { - this.s = s; - this.fn = fn ? bindCallback(fn, thisArg, 3) : null; - } - OfEnumerable.prototype[$iterator$] = function () { - return new OfEnumerator(this); - }; - - function OfEnumerator(p) { - this.i = -1; - this.s = p.s; - this.l = this.s.length; - this.fn = p.fn; - } - - OfEnumerator.prototype.next = function () { - return ++this.i < this.l ? - { done: false, value: !this.fn ? this.s[this.i] : this.fn(this.s[this.i], this.i, this.s) } : - doneEnumerator; - }; - - return OfEnumerable; - }(Enumerable)); - - var enumerableOf = Enumerable.of = function (source, selector, thisArg) { - return new OfEnumerable(source, selector, thisArg); - }; - -var ObserveOnObservable = (function (__super__) { - inherits(ObserveOnObservable, __super__); - function ObserveOnObservable(source, s) { - this.source = source; - this._s = s; - __super__.call(this); - } - - ObserveOnObservable.prototype.subscribeCore = function (o) { - return this.source.subscribe(new ObserveOnObserver(this._s, o)); - }; - - return ObserveOnObservable; -}(ObservableBase)); - - /** - * Wraps the source sequence in order to run its observer callbacks on the specified scheduler. - * - * This only invokes observer callbacks on a scheduler. In case the subscription and/or unsubscription actions have side-effects - * that require to be run on a scheduler, use subscribeOn. - * - * @param {Scheduler} scheduler Scheduler to notify observers on. - * @returns {Observable} The source sequence whose observations happen on the specified scheduler. - */ - observableProto.observeOn = function (scheduler) { - return new ObserveOnObservable(this, scheduler); - }; - - var SubscribeOnObservable = (function (__super__) { - inherits(SubscribeOnObservable, __super__); - function SubscribeOnObservable(source, s) { - this.source = source; - this._s = s; - __super__.call(this); - } - - function scheduleMethod(scheduler, state) { - var source = state[0], d = state[1], o = state[2]; - d.setDisposable(new ScheduledDisposable(scheduler, source.subscribe(o))); - } - - SubscribeOnObservable.prototype.subscribeCore = function (o) { - var m = new SingleAssignmentDisposable(), d = new SerialDisposable(); - d.setDisposable(m); - m.setDisposable(this._s.schedule([this.source, d, o], scheduleMethod)); - return d; - }; - - return SubscribeOnObservable; - }(ObservableBase)); - - /** - * Wraps the source sequence in order to run its subscription and unsubscription logic on the specified scheduler. This operation is not commonly used; - * see the remarks section for more information on the distinction between subscribeOn and observeOn. - - * This only performs the side-effects of subscription and unsubscription on the specified scheduler. In order to invoke observer - * callbacks on a scheduler, use observeOn. - - * @param {Scheduler} scheduler Scheduler to perform subscription and unsubscription actions on. - * @returns {Observable} The source sequence whose subscriptions and unsubscriptions happen on the specified scheduler. - */ - observableProto.subscribeOn = function (scheduler) { - return new SubscribeOnObservable(this, scheduler); - }; - - var FromPromiseObservable = (function(__super__) { - inherits(FromPromiseObservable, __super__); - function FromPromiseObservable(p, s) { - this._p = p; - this._s = s; - __super__.call(this); - } - - function scheduleNext(s, state) { - var o = state[0], data = state[1]; - o.onNext(data); - o.onCompleted(); - } - - function scheduleError(s, state) { - var o = state[0], err = state[1]; - o.onError(err); - } - - FromPromiseObservable.prototype.subscribeCore = function(o) { - var sad = new SingleAssignmentDisposable(), self = this, p = this._p; - - if (isFunction(p)) { - p = tryCatch(p)(); - if (p === errorObj) { - o.onError(p.e); - return sad; - } - } - - p - .then(function (data) { - sad.setDisposable(self._s.schedule([o, data], scheduleNext)); - }, function (err) { - sad.setDisposable(self._s.schedule([o, err], scheduleError)); - }); - - return sad; - }; - - return FromPromiseObservable; - }(ObservableBase)); - - /** - * Converts a Promise to an Observable sequence - * @param {Promise} An ES6 Compliant promise. - * @returns {Observable} An Observable sequence which wraps the existing promise success and failure. - */ - var observableFromPromise = Observable.fromPromise = function (promise, scheduler) { - scheduler || (scheduler = defaultScheduler); - return new FromPromiseObservable(promise, scheduler); - }; - - /* - * Converts an existing observable sequence to an ES6 Compatible Promise - * @example - * var promise = Rx.Observable.return(42).toPromise(RSVP.Promise); - * - * // With config - * Rx.config.Promise = RSVP.Promise; - * var promise = Rx.Observable.return(42).toPromise(); - * @param {Function} [promiseCtor] The constructor of the promise. If not provided, it looks for it in Rx.config.Promise. - * @returns {Promise} An ES6 compatible promise with the last value from the observable sequence. - */ - observableProto.toPromise = function (promiseCtor) { - promiseCtor || (promiseCtor = Rx.config.Promise); - if (!promiseCtor) { throw new NotSupportedError('Promise type not provided nor in Rx.config.Promise'); } - var source = this; - return new promiseCtor(function (resolve, reject) { - // No cancellation can be done - var value; - source.subscribe(function (v) { - value = v; - }, reject, function () { - resolve(value); - }); - }); - }; - - var ToArrayObservable = (function(__super__) { - inherits(ToArrayObservable, __super__); - function ToArrayObservable(source) { - this.source = source; - __super__.call(this); - } - - ToArrayObservable.prototype.subscribeCore = function(o) { - return this.source.subscribe(new InnerObserver(o)); - }; - - inherits(InnerObserver, AbstractObserver); - function InnerObserver(o) { - this.o = o; - this.a = []; - AbstractObserver.call(this); - } - - InnerObserver.prototype.next = function (x) { this.a.push(x); }; - InnerObserver.prototype.error = function (e) { this.o.onError(e); }; - InnerObserver.prototype.completed = function () { this.o.onNext(this.a); this.o.onCompleted(); }; - - return ToArrayObservable; - }(ObservableBase)); - - /** - * Creates an array from an observable sequence. - * @returns {Observable} An observable sequence containing a single element with a list containing all the elements of the source sequence. - */ - observableProto.toArray = function () { - return new ToArrayObservable(this); - }; - - /** - * Creates an observable sequence from a specified subscribe method implementation. - * @example - * var res = Rx.Observable.create(function (observer) { return function () { } ); - * var res = Rx.Observable.create(function (observer) { return Rx.Disposable.empty; } ); - * var res = Rx.Observable.create(function (observer) { } ); - * @param {Function} subscribe Implementation of the resulting observable sequence's subscribe method, returning a function that will be wrapped in a Disposable. - * @returns {Observable} The observable sequence with the specified implementation for the Subscribe method. - */ - Observable.create = function (subscribe, parent) { - return new AnonymousObservable(subscribe, parent); - }; - - var Defer = (function(__super__) { - inherits(Defer, __super__); - function Defer(factory) { - this._f = factory; - __super__.call(this); - } - - Defer.prototype.subscribeCore = function (o) { - var result = tryCatch(this._f)(); - if (result === errorObj) { return observableThrow(result.e).subscribe(o);} - isPromise(result) && (result = observableFromPromise(result)); - return result.subscribe(o); - }; - - return Defer; - }(ObservableBase)); - - /** - * Returns an observable sequence that invokes the specified factory function whenever a new observer subscribes. - * - * @example - * var res = Rx.Observable.defer(function () { return Rx.Observable.fromArray([1,2,3]); }); - * @param {Function} observableFactory Observable factory function to invoke for each observer that subscribes to the resulting sequence or Promise. - * @returns {Observable} An observable sequence whose observers trigger an invocation of the given observable factory function. - */ - var observableDefer = Observable.defer = function (observableFactory) { - return new Defer(observableFactory); - }; - - var EmptyObservable = (function(__super__) { - inherits(EmptyObservable, __super__); - function EmptyObservable(scheduler) { - this.scheduler = scheduler; - __super__.call(this); - } - - EmptyObservable.prototype.subscribeCore = function (observer) { - var sink = new EmptySink(observer, this.scheduler); - return sink.run(); - }; - - function EmptySink(observer, scheduler) { - this.observer = observer; - this.scheduler = scheduler; - } - - function scheduleItem(s, state) { - state.onCompleted(); - return disposableEmpty; - } - - EmptySink.prototype.run = function () { - var state = this.observer; - return this.scheduler === immediateScheduler ? - scheduleItem(null, state) : - this.scheduler.schedule(state, scheduleItem); - }; - - return EmptyObservable; - }(ObservableBase)); - - var EMPTY_OBSERVABLE = new EmptyObservable(immediateScheduler); - - /** - * Returns an empty observable sequence, using the specified scheduler to send out the single OnCompleted message. - * - * @example - * var res = Rx.Observable.empty(); - * var res = Rx.Observable.empty(Rx.Scheduler.timeout); - * @param {Scheduler} [scheduler] Scheduler to send the termination call on. - * @returns {Observable} An observable sequence with no elements. - */ - var observableEmpty = Observable.empty = function (scheduler) { - isScheduler(scheduler) || (scheduler = immediateScheduler); - return scheduler === immediateScheduler ? EMPTY_OBSERVABLE : new EmptyObservable(scheduler); - }; - - var FromObservable = (function(__super__) { - inherits(FromObservable, __super__); - function FromObservable(iterable, fn, scheduler) { - this._iterable = iterable; - this._fn = fn; - this._scheduler = scheduler; - __super__.call(this); - } - - function createScheduleMethod(o, it, fn) { - return function loopRecursive(i, recurse) { - var next = tryCatch(it.next).call(it); - if (next === errorObj) { return o.onError(next.e); } - if (next.done) { return o.onCompleted(); } - - var result = next.value; - - if (isFunction(fn)) { - result = tryCatch(fn)(result, i); - if (result === errorObj) { return o.onError(result.e); } - } - - o.onNext(result); - recurse(i + 1); - }; - } - - FromObservable.prototype.subscribeCore = function (o) { - var list = Object(this._iterable), - it = getIterable(list); - - return this._scheduler.scheduleRecursive(0, createScheduleMethod(o, it, this._fn)); - }; - - return FromObservable; - }(ObservableBase)); - - var maxSafeInteger = Math.pow(2, 53) - 1; - - function StringIterable(s) { - this._s = s; - } - - StringIterable.prototype[$iterator$] = function () { - return new StringIterator(this._s); - }; - - function StringIterator(s) { - this._s = s; - this._l = s.length; - this._i = 0; - } - - StringIterator.prototype[$iterator$] = function () { - return this; - }; - - StringIterator.prototype.next = function () { - return this._i < this._l ? { done: false, value: this._s.charAt(this._i++) } : doneEnumerator; - }; - - function ArrayIterable(a) { - this._a = a; - } - - ArrayIterable.prototype[$iterator$] = function () { - return new ArrayIterator(this._a); - }; - - function ArrayIterator(a) { - this._a = a; - this._l = toLength(a); - this._i = 0; - } - - ArrayIterator.prototype[$iterator$] = function () { - return this; - }; - - ArrayIterator.prototype.next = function () { - return this._i < this._l ? { done: false, value: this._a[this._i++] } : doneEnumerator; - }; - - function numberIsFinite(value) { - return typeof value === 'number' && root.isFinite(value); - } - - function isNan(n) { - return n !== n; - } - - function getIterable(o) { - var i = o[$iterator$], it; - if (!i && typeof o === 'string') { - it = new StringIterable(o); - return it[$iterator$](); - } - if (!i && o.length !== undefined) { - it = new ArrayIterable(o); - return it[$iterator$](); - } - if (!i) { throw new TypeError('Object is not iterable'); } - return o[$iterator$](); - } - - function sign(value) { - var number = +value; - if (number === 0) { return number; } - if (isNaN(number)) { return number; } - return number < 0 ? -1 : 1; - } - - function toLength(o) { - var len = +o.length; - if (isNaN(len)) { return 0; } - if (len === 0 || !numberIsFinite(len)) { return len; } - len = sign(len) * Math.floor(Math.abs(len)); - if (len <= 0) { return 0; } - if (len > maxSafeInteger) { return maxSafeInteger; } - return len; - } - - /** - * This method creates a new Observable sequence from an array-like or iterable object. - * @param {Any} arrayLike An array-like or iterable object to convert to an Observable sequence. - * @param {Function} [mapFn] Map function to call on every element of the array. - * @param {Any} [thisArg] The context to use calling the mapFn if provided. - * @param {Scheduler} [scheduler] Optional scheduler to use for scheduling. If not provided, defaults to Scheduler.currentThread. - */ - var observableFrom = Observable.from = function (iterable, mapFn, thisArg, scheduler) { - if (iterable == null) { - throw new Error('iterable cannot be null.') - } - if (mapFn && !isFunction(mapFn)) { - throw new Error('mapFn when provided must be a function'); - } - if (mapFn) { - var mapper = bindCallback(mapFn, thisArg, 2); - } - isScheduler(scheduler) || (scheduler = currentThreadScheduler); - return new FromObservable(iterable, mapper, scheduler); - } - - var FromArrayObservable = (function(__super__) { - inherits(FromArrayObservable, __super__); - function FromArrayObservable(args, scheduler) { - this._args = args; - this._scheduler = scheduler; - __super__.call(this); - } - - function scheduleMethod(o, args) { - var len = args.length; - return function loopRecursive (i, recurse) { - if (i < len) { - o.onNext(args[i]); - recurse(i + 1); - } else { - o.onCompleted(); - } - }; - } - - FromArrayObservable.prototype.subscribeCore = function (o) { - return this._scheduler.scheduleRecursive(0, scheduleMethod(o, this._args)); - }; - - return FromArrayObservable; - }(ObservableBase)); - - /** - * Converts an array to an observable sequence, using an optional scheduler to enumerate the array. - * @deprecated use Observable.from or Observable.of - * @param {Scheduler} [scheduler] Scheduler to run the enumeration of the input sequence on. - * @returns {Observable} The observable sequence whose elements are pulled from the given enumerable sequence. - */ - var observableFromArray = Observable.fromArray = function (array, scheduler) { - isScheduler(scheduler) || (scheduler = currentThreadScheduler); - return new FromArrayObservable(array, scheduler) - }; - - var GenerateObservable = (function (__super__) { - inherits(GenerateObservable, __super__); - function GenerateObservable(state, cndFn, itrFn, resFn, s) { - this._initialState = state; - this._cndFn = cndFn; - this._itrFn = itrFn; - this._resFn = resFn; - this._s = s; - __super__.call(this); - } - - function scheduleRecursive(state, recurse) { - if (state.first) { - state.first = false; - } else { - state.newState = tryCatch(state.self._itrFn)(state.newState); - if (state.newState === errorObj) { return state.o.onError(state.newState.e); } - } - var hasResult = tryCatch(state.self._cndFn)(state.newState); - if (hasResult === errorObj) { return state.o.onError(hasResult.e); } - if (hasResult) { - var result = tryCatch(state.self._resFn)(state.newState); - if (result === errorObj) { return state.o.onError(result.e); } - state.o.onNext(result); - recurse(state); - } else { - state.o.onCompleted(); - } - } - - GenerateObservable.prototype.subscribeCore = function (o) { - var state = { - o: o, - self: this, - first: true, - newState: this._initialState - }; - return this._s.scheduleRecursive(state, scheduleRecursive); - }; - - return GenerateObservable; - }(ObservableBase)); - - /** - * Generates an observable sequence by running a state-driven loop producing the sequence's elements, using the specified scheduler to send out observer messages. - * - * @example - * var res = Rx.Observable.generate(0, function (x) { return x < 10; }, function (x) { return x + 1; }, function (x) { return x; }); - * var res = Rx.Observable.generate(0, function (x) { return x < 10; }, function (x) { return x + 1; }, function (x) { return x; }, Rx.Scheduler.timeout); - * @param {Mixed} initialState Initial state. - * @param {Function} condition Condition to terminate generation (upon returning false). - * @param {Function} iterate Iteration step function. - * @param {Function} resultSelector Selector function for results produced in the sequence. - * @param {Scheduler} [scheduler] Scheduler on which to run the generator loop. If not provided, defaults to Scheduler.currentThread. - * @returns {Observable} The generated sequence. - */ - Observable.generate = function (initialState, condition, iterate, resultSelector, scheduler) { - isScheduler(scheduler) || (scheduler = currentThreadScheduler); - return new GenerateObservable(initialState, condition, iterate, resultSelector, scheduler); - }; - - var NeverObservable = (function(__super__) { - inherits(NeverObservable, __super__); - function NeverObservable() { - __super__.call(this); - } - - NeverObservable.prototype.subscribeCore = function (observer) { - return disposableEmpty; - }; - - return NeverObservable; - }(ObservableBase)); - - var NEVER_OBSERVABLE = new NeverObservable(); - - /** - * Returns a non-terminating observable sequence, which can be used to denote an infinite duration (e.g. when using reactive joins). - * @returns {Observable} An observable sequence whose observers will never get called. - */ - var observableNever = Observable.never = function () { - return NEVER_OBSERVABLE; - }; - - function observableOf (scheduler, array) { - isScheduler(scheduler) || (scheduler = currentThreadScheduler); - return new FromArrayObservable(array, scheduler); - } - - /** - * This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments. - * @returns {Observable} The observable sequence whose elements are pulled from the given arguments. - */ - Observable.of = function () { - var len = arguments.length, args = new Array(len); - for(var i = 0; i < len; i++) { args[i] = arguments[i]; } - return new FromArrayObservable(args, currentThreadScheduler); - }; - - /** - * This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments. - * @param {Scheduler} scheduler A scheduler to use for scheduling the arguments. - * @returns {Observable} The observable sequence whose elements are pulled from the given arguments. - */ - Observable.ofWithScheduler = function (scheduler) { - var len = arguments.length, args = new Array(len - 1); - for(var i = 1; i < len; i++) { args[i - 1] = arguments[i]; } - return new FromArrayObservable(args, scheduler); - }; - - var PairsObservable = (function(__super__) { - inherits(PairsObservable, __super__); - function PairsObservable(o, scheduler) { - this._o = o; - this._keys = Object.keys(o); - this._scheduler = scheduler; - __super__.call(this); - } - - function scheduleMethod(o, obj, keys) { - return function loopRecursive(i, recurse) { - if (i < keys.length) { - var key = keys[i]; - o.onNext([key, obj[key]]); - recurse(i + 1); - } else { - o.onCompleted(); - } - }; - } - - PairsObservable.prototype.subscribeCore = function (o) { - return this._scheduler.scheduleRecursive(0, scheduleMethod(o, this._o, this._keys)); - }; - - return PairsObservable; - }(ObservableBase)); - - /** - * Convert an object into an observable sequence of [key, value] pairs. - * @param {Object} obj The object to inspect. - * @param {Scheduler} [scheduler] Scheduler to run the enumeration of the input sequence on. - * @returns {Observable} An observable sequence of [key, value] pairs from the object. - */ - Observable.pairs = function (obj, scheduler) { - scheduler || (scheduler = currentThreadScheduler); - return new PairsObservable(obj, scheduler); - }; - - var RangeObservable = (function(__super__) { - inherits(RangeObservable, __super__); - function RangeObservable(start, count, scheduler) { - this.start = start; - this.rangeCount = count; - this.scheduler = scheduler; - __super__.call(this); - } - - function loopRecursive(start, count, o) { - return function loop (i, recurse) { - if (i < count) { - o.onNext(start + i); - recurse(i + 1); - } else { - o.onCompleted(); - } - }; - } - - RangeObservable.prototype.subscribeCore = function (o) { - return this.scheduler.scheduleRecursive( - 0, - loopRecursive(this.start, this.rangeCount, o) - ); - }; - - return RangeObservable; - }(ObservableBase)); - - /** - * Generates an observable sequence of integral numbers within a specified range, using the specified scheduler to send out observer messages. - * @param {Number} start The value of the first integer in the sequence. - * @param {Number} count The number of sequential integers to generate. - * @param {Scheduler} [scheduler] Scheduler to run the generator loop on. If not specified, defaults to Scheduler.currentThread. - * @returns {Observable} An observable sequence that contains a range of sequential integral numbers. - */ - Observable.range = function (start, count, scheduler) { - isScheduler(scheduler) || (scheduler = currentThreadScheduler); - return new RangeObservable(start, count, scheduler); - }; - - var RepeatObservable = (function(__super__) { - inherits(RepeatObservable, __super__); - function RepeatObservable(value, repeatCount, scheduler) { - this.value = value; - this.repeatCount = repeatCount == null ? -1 : repeatCount; - this.scheduler = scheduler; - __super__.call(this); - } - - RepeatObservable.prototype.subscribeCore = function (observer) { - var sink = new RepeatSink(observer, this); - return sink.run(); - }; - - return RepeatObservable; - }(ObservableBase)); - - function RepeatSink(observer, parent) { - this.observer = observer; - this.parent = parent; - } - - RepeatSink.prototype.run = function () { - var observer = this.observer, value = this.parent.value; - function loopRecursive(i, recurse) { - if (i === -1 || i > 0) { - observer.onNext(value); - i > 0 && i--; - } - if (i === 0) { return observer.onCompleted(); } - recurse(i); - } - - return this.parent.scheduler.scheduleRecursive(this.parent.repeatCount, loopRecursive); - }; - - /** - * Generates an observable sequence that repeats the given element the specified number of times, using the specified scheduler to send out observer messages. - * @param {Mixed} value Element to repeat. - * @param {Number} repeatCount [Optiona] Number of times to repeat the element. If not specified, repeats indefinitely. - * @param {Scheduler} scheduler Scheduler to run the producer loop on. If not specified, defaults to Scheduler.immediate. - * @returns {Observable} An observable sequence that repeats the given element the specified number of times. - */ - Observable.repeat = function (value, repeatCount, scheduler) { - isScheduler(scheduler) || (scheduler = currentThreadScheduler); - return new RepeatObservable(value, repeatCount, scheduler); - }; - - var JustObservable = (function(__super__) { - inherits(JustObservable, __super__); - function JustObservable(value, scheduler) { - this._value = value; - this._scheduler = scheduler; - __super__.call(this); - } - - JustObservable.prototype.subscribeCore = function (o) { - var state = [this._value, o]; - return this._scheduler === immediateScheduler ? - scheduleItem(null, state) : - this._scheduler.schedule(state, scheduleItem); - }; - - function scheduleItem(s, state) { - var value = state[0], observer = state[1]; - observer.onNext(value); - observer.onCompleted(); - return disposableEmpty; - } - - return JustObservable; - }(ObservableBase)); - - /** - * Returns an observable sequence that contains a single element, using the specified scheduler to send out observer messages. - * There is an alias called 'just' or browsers 0) { - this.parent.handleSubscribe(this.parent.q.shift()); - } else { - this.parent.activeCount--; - this.parent.done && this.parent.activeCount === 0 && this.parent.o.onCompleted(); - } - }; - - return MergeObserver; - }(AbstractObserver)); - - /** - * Merges an observable sequence of observable sequences into an observable sequence, limiting the number of concurrent subscriptions to inner sequences. - * Or merges two observable sequences into a single observable sequence. - * @param {Mixed} [maxConcurrentOrOther] Maximum number of inner observable sequences being subscribed to concurrently or the second observable sequence. - * @returns {Observable} The observable sequence that merges the elements of the inner sequences. - */ - observableProto.merge = function (maxConcurrentOrOther) { - return typeof maxConcurrentOrOther !== 'number' ? - observableMerge(this, maxConcurrentOrOther) : - new MergeObservable(this, maxConcurrentOrOther); - }; - - /** - * Merges all the observable sequences into a single observable sequence. - * The scheduler is optional and if not specified, the immediate scheduler is used. - * @returns {Observable} The observable sequence that merges the elements of the observable sequences. - */ - var observableMerge = Observable.merge = function () { - var scheduler, sources = [], i, len = arguments.length; - if (!arguments[0]) { - scheduler = immediateScheduler; - for(i = 1; i < len; i++) { sources.push(arguments[i]); } - } else if (isScheduler(arguments[0])) { - scheduler = arguments[0]; - for(i = 1; i < len; i++) { sources.push(arguments[i]); } - } else { - scheduler = immediateScheduler; - for(i = 0; i < len; i++) { sources.push(arguments[i]); } - } - if (Array.isArray(sources[0])) { - sources = sources[0]; - } - return observableOf(scheduler, sources).mergeAll(); - }; - - var CompositeError = Rx.CompositeError = function(errors) { - this.innerErrors = errors; - this.message = 'This contains multiple errors. Check the innerErrors'; - Error.call(this); - }; - CompositeError.prototype = Object.create(Error.prototype); - CompositeError.prototype.name = 'CompositeError'; - - var MergeDelayErrorObservable = (function(__super__) { - inherits(MergeDelayErrorObservable, __super__); - function MergeDelayErrorObservable(source) { - this.source = source; - __super__.call(this); - } - - MergeDelayErrorObservable.prototype.subscribeCore = function (o) { - var group = new CompositeDisposable(), - m = new SingleAssignmentDisposable(), - state = { isStopped: false, errors: [], o: o }; - - group.add(m); - m.setDisposable(this.source.subscribe(new MergeDelayErrorObserver(group, state))); - - return group; - }; - - return MergeDelayErrorObservable; - }(ObservableBase)); - - var MergeDelayErrorObserver = (function(__super__) { - inherits(MergeDelayErrorObserver, __super__); - function MergeDelayErrorObserver(group, state) { - this._group = group; - this._state = state; - __super__.call(this); - } - - function setCompletion(o, errors) { - if (errors.length === 0) { - o.onCompleted(); - } else if (errors.length === 1) { - o.onError(errors[0]); - } else { - o.onError(new CompositeError(errors)); - } - } - - MergeDelayErrorObserver.prototype.next = function (x) { - var inner = new SingleAssignmentDisposable(); - this._group.add(inner); - - // Check for promises support - isPromise(x) && (x = observableFromPromise(x)); - inner.setDisposable(x.subscribe(new InnerObserver(inner, this._group, this._state))); - }; - - MergeDelayErrorObserver.prototype.error = function (e) { - this._state.errors.push(e); - this._state.isStopped = true; - this._group.length === 1 && setCompletion(this._state.o, this._state.errors); - }; - - MergeDelayErrorObserver.prototype.completed = function () { - this._state.isStopped = true; - this._group.length === 1 && setCompletion(this._state.o, this._state.errors); - }; - - inherits(InnerObserver, __super__); - function InnerObserver(inner, group, state) { - this._inner = inner; - this._group = group; - this._state = state; - __super__.call(this); - } - - InnerObserver.prototype.next = function (x) { this._state.o.onNext(x); }; - InnerObserver.prototype.error = function (e) { - this._state.errors.push(e); - this._group.remove(this._inner); - this._state.isStopped && this._group.length === 1 && setCompletion(this._state.o, this._state.errors); - }; - InnerObserver.prototype.completed = function () { - this._group.remove(this._inner); - this._state.isStopped && this._group.length === 1 && setCompletion(this._state.o, this._state.errors); - }; - - return MergeDelayErrorObserver; - }(AbstractObserver)); - - /** - * Flattens an Observable that emits Observables into one Observable, in a way that allows an Observer to - * receive all successfully emitted items from all of the source Observables without being interrupted by - * an error notification from one of them. - * - * This behaves like Observable.prototype.mergeAll except that if any of the merged Observables notify of an - * error via the Observer's onError, mergeDelayError will refrain from propagating that - * error notification until all of the merged Observables have finished emitting items. - * @param {Array | Arguments} args Arguments or an array to merge. - * @returns {Observable} an Observable that emits all of the items emitted by the Observables emitted by the Observable - */ - Observable.mergeDelayError = function() { - var args; - if (Array.isArray(arguments[0])) { - args = arguments[0]; - } else { - var len = arguments.length; - args = new Array(len); - for(var i = 0; i < len; i++) { args[i] = arguments[i]; } - } - var source = observableOf(null, args); - return new MergeDelayErrorObservable(source); - }; - - var MergeAllObservable = (function (__super__) { - inherits(MergeAllObservable, __super__); - - function MergeAllObservable(source) { - this.source = source; - __super__.call(this); - } - - MergeAllObservable.prototype.subscribeCore = function (o) { - var g = new CompositeDisposable(), m = new SingleAssignmentDisposable(); - g.add(m); - m.setDisposable(this.source.subscribe(new MergeAllObserver(o, g))); - return g; - }; - - return MergeAllObservable; - }(ObservableBase)); - - var MergeAllObserver = (function (__super__) { - function MergeAllObserver(o, g) { - this.o = o; - this.g = g; - this.done = false; - __super__.call(this); - } - - inherits(MergeAllObserver, __super__); - - MergeAllObserver.prototype.next = function(innerSource) { - var sad = new SingleAssignmentDisposable(); - this.g.add(sad); - isPromise(innerSource) && (innerSource = observableFromPromise(innerSource)); - sad.setDisposable(innerSource.subscribe(new InnerObserver(this, sad))); - }; - - MergeAllObserver.prototype.error = function (e) { - this.o.onError(e); - }; - - MergeAllObserver.prototype.completed = function () { - this.done = true; - this.g.length === 1 && this.o.onCompleted(); - }; - - function InnerObserver(parent, sad) { - this.parent = parent; - this.sad = sad; - __super__.call(this); - } - - inherits(InnerObserver, __super__); - - InnerObserver.prototype.next = function (x) { - this.parent.o.onNext(x); - }; - InnerObserver.prototype.error = function (e) { - this.parent.o.onError(e); - }; - InnerObserver.prototype.completed = function () { - this.parent.g.remove(this.sad); - this.parent.done && this.parent.g.length === 1 && this.parent.o.onCompleted(); - }; - - return MergeAllObserver; - }(AbstractObserver)); - - /** - * Merges an observable sequence of observable sequences into an observable sequence. - * @returns {Observable} The observable sequence that merges the elements of the inner sequences. - */ - observableProto.mergeAll = function () { - return new MergeAllObservable(this); - }; - - /** - * Continues an observable sequence that is terminated normally or by an exception with the next observable sequence. - * @param {Observable} second Second observable sequence used to produce results after the first sequence terminates. - * @returns {Observable} An observable sequence that concatenates the first and second sequence, even if the first sequence terminates exceptionally. - */ - observableProto.onErrorResumeNext = function (second) { - if (!second) { throw new Error('Second observable is required'); } - return onErrorResumeNext([this, second]); - }; - - var OnErrorResumeNextObservable = (function(__super__) { - inherits(OnErrorResumeNextObservable, __super__); - function OnErrorResumeNextObservable(sources) { - this.sources = sources; - __super__.call(this); - } - - function scheduleMethod(state, recurse) { - if (state.pos < state.sources.length) { - var current = state.sources[state.pos++]; - isPromise(current) && (current = observableFromPromise(current)); - var d = new SingleAssignmentDisposable(); - state.subscription.setDisposable(d); - d.setDisposable(current.subscribe(new OnErrorResumeNextObserver(state, recurse))); - } else { - state.o.onCompleted(); - } - } - - OnErrorResumeNextObservable.prototype.subscribeCore = function (o) { - var subscription = new SerialDisposable(), - state = {pos: 0, subscription: subscription, o: o, sources: this.sources }, - cancellable = immediateScheduler.scheduleRecursive(state, scheduleMethod); - - return new BinaryDisposable(subscription, cancellable); - }; - - return OnErrorResumeNextObservable; - }(ObservableBase)); - - var OnErrorResumeNextObserver = (function(__super__) { - inherits(OnErrorResumeNextObserver, __super__); - function OnErrorResumeNextObserver(state, recurse) { - this._state = state; - this._recurse = recurse; - __super__.call(this); - } - - OnErrorResumeNextObserver.prototype.next = function (x) { this._state.o.onNext(x); }; - OnErrorResumeNextObserver.prototype.error = function () { this._recurse(this._state); }; - OnErrorResumeNextObserver.prototype.completed = function () { this._recurse(this._state); }; - - return OnErrorResumeNextObserver; - }(AbstractObserver)); - - /** - * Continues an observable sequence that is terminated normally or by an exception with the next observable sequence. - * @returns {Observable} An observable sequence that concatenates the source sequences, even if a sequence terminates exceptionally. - */ - var onErrorResumeNext = Observable.onErrorResumeNext = function () { - var sources = []; - if (Array.isArray(arguments[0])) { - sources = arguments[0]; - } else { - var len = arguments.length; - sources = new Array(len); - for(var i = 0; i < len; i++) { sources[i] = arguments[i]; } - } - return new OnErrorResumeNextObservable(sources); - }; - - var SkipUntilObservable = (function(__super__) { - inherits(SkipUntilObservable, __super__); - - function SkipUntilObservable(source, other) { - this._s = source; - this._o = isPromise(other) ? observableFromPromise(other) : other; - this._open = false; - __super__.call(this); - } - - SkipUntilObservable.prototype.subscribeCore = function(o) { - var leftSubscription = new SingleAssignmentDisposable(); - leftSubscription.setDisposable(this._s.subscribe(new SkipUntilSourceObserver(o, this))); - - isPromise(this._o) && (this._o = observableFromPromise(this._o)); - - var rightSubscription = new SingleAssignmentDisposable(); - rightSubscription.setDisposable(this._o.subscribe(new SkipUntilOtherObserver(o, this, rightSubscription))); - - return new BinaryDisposable(leftSubscription, rightSubscription); - }; - - return SkipUntilObservable; - }(ObservableBase)); - - var SkipUntilSourceObserver = (function(__super__) { - inherits(SkipUntilSourceObserver, __super__); - function SkipUntilSourceObserver(o, p) { - this._o = o; - this._p = p; - __super__.call(this); - } - - SkipUntilSourceObserver.prototype.next = function (x) { - this._p._open && this._o.onNext(x); - }; - - SkipUntilSourceObserver.prototype.error = function (err) { - this._o.onError(err); - }; - - SkipUntilSourceObserver.prototype.onCompleted = function () { - this._p._open && this._o.onCompleted(); - }; - - return SkipUntilSourceObserver; - }(AbstractObserver)); - - var SkipUntilOtherObserver = (function(__super__) { - inherits(SkipUntilOtherObserver, __super__); - function SkipUntilOtherObserver(o, p, r) { - this._o = o; - this._p = p; - this._r = r; - __super__.call(this); - } - - SkipUntilOtherObserver.prototype.next = function () { - this._p._open = true; - this._r.dispose(); - }; - - SkipUntilOtherObserver.prototype.error = function (err) { - this._o.onError(err); - }; - - SkipUntilOtherObserver.prototype.onCompleted = function () { - this._r.dispose(); - }; - - return SkipUntilOtherObserver; - }(AbstractObserver)); - - /** - * Returns the values from the source observable sequence only after the other observable sequence produces a value. - * @param {Observable | Promise} other The observable sequence or Promise that triggers propagation of elements of the source sequence. - * @returns {Observable} An observable sequence containing the elements of the source sequence starting from the point the other sequence triggered propagation. - */ - observableProto.skipUntil = function (other) { - return new SkipUntilObservable(this, other); - }; - - var SwitchObservable = (function(__super__) { - inherits(SwitchObservable, __super__); - function SwitchObservable(source) { - this.source = source; - __super__.call(this); - } - - SwitchObservable.prototype.subscribeCore = function (o) { - var inner = new SerialDisposable(), s = this.source.subscribe(new SwitchObserver(o, inner)); - return new BinaryDisposable(s, inner); - }; - - inherits(SwitchObserver, AbstractObserver); - function SwitchObserver(o, inner) { - this.o = o; - this.inner = inner; - this.stopped = false; - this.latest = 0; - this.hasLatest = false; - AbstractObserver.call(this); - } - - SwitchObserver.prototype.next = function (innerSource) { - var d = new SingleAssignmentDisposable(), id = ++this.latest; - this.hasLatest = true; - this.inner.setDisposable(d); - isPromise(innerSource) && (innerSource = observableFromPromise(innerSource)); - d.setDisposable(innerSource.subscribe(new InnerObserver(this, id))); - }; - - SwitchObserver.prototype.error = function (e) { - this.o.onError(e); - }; - - SwitchObserver.prototype.completed = function () { - this.stopped = true; - !this.hasLatest && this.o.onCompleted(); - }; - - inherits(InnerObserver, AbstractObserver); - function InnerObserver(parent, id) { - this.parent = parent; - this.id = id; - AbstractObserver.call(this); - } - InnerObserver.prototype.next = function (x) { - this.parent.latest === this.id && this.parent.o.onNext(x); - }; - - InnerObserver.prototype.error = function (e) { - this.parent.latest === this.id && this.parent.o.onError(e); - }; - - InnerObserver.prototype.completed = function () { - if (this.parent.latest === this.id) { - this.parent.hasLatest = false; - this.parent.stopped && this.parent.o.onCompleted(); - } - }; - - return SwitchObservable; - }(ObservableBase)); - - /** - * Transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence. - * @returns {Observable} The observable sequence that at any point in time produces the elements of the most recent inner observable sequence that has been received. - */ - observableProto['switch'] = observableProto.switchLatest = function () { - return new SwitchObservable(this); - }; - - var TakeUntilObservable = (function(__super__) { - inherits(TakeUntilObservable, __super__); - - function TakeUntilObservable(source, other) { - this.source = source; - this.other = isPromise(other) ? observableFromPromise(other) : other; - __super__.call(this); - } - - TakeUntilObservable.prototype.subscribeCore = function(o) { - return new BinaryDisposable( - this.source.subscribe(o), - this.other.subscribe(new TakeUntilObserver(o)) - ); - }; - - return TakeUntilObservable; - }(ObservableBase)); - - var TakeUntilObserver = (function(__super__) { - inherits(TakeUntilObserver, __super__); - function TakeUntilObserver(o) { - this._o = o; - __super__.call(this); - } - - TakeUntilObserver.prototype.next = function () { - this._o.onCompleted(); - }; - - TakeUntilObserver.prototype.error = function (err) { - this._o.onError(err); - }; - - TakeUntilObserver.prototype.onCompleted = noop; - - return TakeUntilObserver; - }(AbstractObserver)); - - /** - * Returns the values from the source observable sequence until the other observable sequence produces a value. - * @param {Observable | Promise} other Observable sequence or Promise that terminates propagation of elements of the source sequence. - * @returns {Observable} An observable sequence containing the elements of the source sequence up to the point the other sequence interrupted further propagation. - */ - observableProto.takeUntil = function (other) { - return new TakeUntilObservable(this, other); - }; - - function falseFactory() { return false; } - function argumentsToArray() { - var len = arguments.length, args = new Array(len); - for(var i = 0; i < len; i++) { args[i] = arguments[i]; } - return args; - } - - var WithLatestFromObservable = (function(__super__) { - inherits(WithLatestFromObservable, __super__); - function WithLatestFromObservable(source, sources, resultSelector) { - this._s = source; - this._ss = sources; - this._cb = resultSelector; - __super__.call(this); - } - - WithLatestFromObservable.prototype.subscribeCore = function (o) { - var len = this._ss.length; - var state = { - hasValue: arrayInitialize(len, falseFactory), - hasValueAll: false, - values: new Array(len) - }; - - var n = this._ss.length, subscriptions = new Array(n + 1); - for (var i = 0; i < n; i++) { - var other = this._ss[i], sad = new SingleAssignmentDisposable(); - isPromise(other) && (other = observableFromPromise(other)); - sad.setDisposable(other.subscribe(new WithLatestFromOtherObserver(o, i, state))); - subscriptions[i] = sad; - } - - var outerSad = new SingleAssignmentDisposable(); - outerSad.setDisposable(this._s.subscribe(new WithLatestFromSourceObserver(o, this._cb, state))); - subscriptions[n] = outerSad; - - return new NAryDisposable(subscriptions); - }; - - return WithLatestFromObservable; - }(ObservableBase)); - - var WithLatestFromOtherObserver = (function (__super__) { - inherits(WithLatestFromOtherObserver, __super__); - function WithLatestFromOtherObserver(o, i, state) { - this._o = o; - this._i = i; - this._state = state; - __super__.call(this); - } - - WithLatestFromOtherObserver.prototype.next = function (x) { - this._state.values[this._i] = x; - this._state.hasValue[this._i] = true; - this._state.hasValueAll = this._state.hasValue.every(identity); - }; - - WithLatestFromOtherObserver.prototype.error = function (e) { - this._o.onError(e); - }; - - WithLatestFromOtherObserver.prototype.completed = noop; - - return WithLatestFromOtherObserver; - }(AbstractObserver)); - - var WithLatestFromSourceObserver = (function (__super__) { - inherits(WithLatestFromSourceObserver, __super__); - function WithLatestFromSourceObserver(o, cb, state) { - this._o = o; - this._cb = cb; - this._state = state; - __super__.call(this); - } - - WithLatestFromSourceObserver.prototype.next = function (x) { - var allValues = [x].concat(this._state.values); - if (!this._state.hasValueAll) { return; } - var res = tryCatch(this._cb).apply(null, allValues); - if (res === errorObj) { return this._o.onError(res.e); } - this._o.onNext(res); - }; - - WithLatestFromSourceObserver.prototype.error = function (e) { - this._o.onError(e); - }; - - WithLatestFromSourceObserver.prototype.completed = function () { - this._o.onCompleted(); - }; - - return WithLatestFromSourceObserver; - }(AbstractObserver)); - - /** - * Merges the specified observable sequences into one observable sequence by using the selector function only when the (first) source observable sequence produces an element. - * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function. - */ - observableProto.withLatestFrom = function () { - if (arguments.length === 0) { throw new Error('invalid arguments'); } - - var len = arguments.length, args = new Array(len); - for(var i = 0; i < len; i++) { args[i] = arguments[i]; } - var resultSelector = isFunction(args[len - 1]) ? args.pop() : argumentsToArray; - Array.isArray(args[0]) && (args = args[0]); - - return new WithLatestFromObservable(this, args, resultSelector); - }; - - function falseFactory() { return false; } - function emptyArrayFactory() { return []; } - - var ZipObservable = (function(__super__) { - inherits(ZipObservable, __super__); - function ZipObservable(sources, resultSelector) { - this._s = sources; - this._cb = resultSelector; - __super__.call(this); - } - - ZipObservable.prototype.subscribeCore = function(observer) { - var n = this._s.length, - subscriptions = new Array(n), - done = arrayInitialize(n, falseFactory), - q = arrayInitialize(n, emptyArrayFactory); - - for (var i = 0; i < n; i++) { - var source = this._s[i], sad = new SingleAssignmentDisposable(); - subscriptions[i] = sad; - isPromise(source) && (source = observableFromPromise(source)); - sad.setDisposable(source.subscribe(new ZipObserver(observer, i, this, q, done))); - } - - return new NAryDisposable(subscriptions); - }; - - return ZipObservable; - }(ObservableBase)); - - var ZipObserver = (function (__super__) { - inherits(ZipObserver, __super__); - function ZipObserver(o, i, p, q, d) { - this._o = o; - this._i = i; - this._p = p; - this._q = q; - this._d = d; - __super__.call(this); - } - - function notEmpty(x) { return x.length > 0; } - function shiftEach(x) { return x.shift(); } - function notTheSame(i) { - return function (x, j) { - return j !== i; - }; - } - - ZipObserver.prototype.next = function (x) { - this._q[this._i].push(x); - if (this._q.every(notEmpty)) { - var queuedValues = this._q.map(shiftEach); - var res = tryCatch(this._p._cb).apply(null, queuedValues); - if (res === errorObj) { return this._o.onError(res.e); } - this._o.onNext(res); - } else if (this._d.filter(notTheSame(this._i)).every(identity)) { - this._o.onCompleted(); - } - }; - - ZipObserver.prototype.error = function (e) { - this._o.onError(e); - }; - - ZipObserver.prototype.completed = function () { - this._d[this._i] = true; - this._d.every(identity) && this._o.onCompleted(); - }; - - return ZipObserver; - }(AbstractObserver)); - - /** - * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences or an array have produced an element at a corresponding index. - * The last element in the arguments must be a function to invoke for each series of elements at corresponding indexes in the args. - * @returns {Observable} An observable sequence containing the result of combining elements of the args using the specified result selector function. - */ - observableProto.zip = function () { - if (arguments.length === 0) { throw new Error('invalid arguments'); } - - var len = arguments.length, args = new Array(len); - for(var i = 0; i < len; i++) { args[i] = arguments[i]; } - var resultSelector = isFunction(args[len - 1]) ? args.pop() : argumentsToArray; - Array.isArray(args[0]) && (args = args[0]); - - var parent = this; - args.unshift(parent); - - return new ZipObservable(args, resultSelector); - }; - - /** - * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index. - * @param arguments Observable sources. - * @param {Function} resultSelector Function to invoke for each series of elements at corresponding indexes in the sources. - * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function. - */ - Observable.zip = function () { - var len = arguments.length, args = new Array(len); - for(var i = 0; i < len; i++) { args[i] = arguments[i]; } - if (Array.isArray(args[0])) { - args = isFunction(args[1]) ? args[0].concat(args[1]) : args[0]; - } - var first = args.shift(); - return first.zip.apply(first, args); - }; - -function falseFactory() { return false; } -function emptyArrayFactory() { return []; } -function argumentsToArray() { - var len = arguments.length, args = new Array(len); - for(var i = 0; i < len; i++) { args[i] = arguments[i]; } - return args; -} - -var ZipIterableObservable = (function(__super__) { - inherits(ZipIterableObservable, __super__); - function ZipIterableObservable(sources, cb) { - this.sources = sources; - this._cb = cb; - __super__.call(this); - } - - ZipIterableObservable.prototype.subscribeCore = function (o) { - var sources = this.sources, len = sources.length, subscriptions = new Array(len); - - var state = { - q: arrayInitialize(len, emptyArrayFactory), - done: arrayInitialize(len, falseFactory), - cb: this._cb, - o: o - }; - - for (var i = 0; i < len; i++) { - (function (i) { - var source = sources[i], sad = new SingleAssignmentDisposable(); - (isArrayLike(source) || isIterable(source)) && (source = observableFrom(source)); - - subscriptions[i] = sad; - sad.setDisposable(source.subscribe(new ZipIterableObserver(state, i))); - }(i)); - } - - return new NAryDisposable(subscriptions); - }; - - return ZipIterableObservable; -}(ObservableBase)); - -var ZipIterableObserver = (function (__super__) { - inherits(ZipIterableObserver, __super__); - function ZipIterableObserver(s, i) { - this._s = s; - this._i = i; - __super__.call(this); - } - - function notEmpty(x) { return x.length > 0; } - function shiftEach(x) { return x.shift(); } - function notTheSame(i) { - return function (x, j) { - return j !== i; - }; - } - - ZipIterableObserver.prototype.next = function (x) { - this._s.q[this._i].push(x); - if (this._s.q.every(notEmpty)) { - var queuedValues = this._s.q.map(shiftEach), - res = tryCatch(this._s.cb).apply(null, queuedValues); - if (res === errorObj) { return this._s.o.onError(res.e); } - this._s.o.onNext(res); - } else if (this._s.done.filter(notTheSame(this._i)).every(identity)) { - this._s.o.onCompleted(); - } - }; - - ZipIterableObserver.prototype.error = function (e) { this._s.o.onError(e); }; - - ZipIterableObserver.prototype.completed = function () { - this._s.done[this._i] = true; - this._s.done.every(identity) && this._s.o.onCompleted(); - }; - - return ZipIterableObserver; -}(AbstractObserver)); - -/** - * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences or an array have produced an element at a corresponding index. - * The last element in the arguments must be a function to invoke for each series of elements at corresponding indexes in the args. - * @returns {Observable} An observable sequence containing the result of combining elements of the args using the specified result selector function. - */ -observableProto.zipIterable = function () { - if (arguments.length === 0) { throw new Error('invalid arguments'); } - - var len = arguments.length, args = new Array(len); - for(var i = 0; i < len; i++) { args[i] = arguments[i]; } - var resultSelector = isFunction(args[len - 1]) ? args.pop() : argumentsToArray; - - var parent = this; - args.unshift(parent); - return new ZipIterableObservable(args, resultSelector); -}; - - function asObservable(source) { - return function subscribe(o) { return source.subscribe(o); }; - } - - /** - * Hides the identity of an observable sequence. - * @returns {Observable} An observable sequence that hides the identity of the source sequence. - */ - observableProto.asObservable = function () { - return new AnonymousObservable(asObservable(this), this); - }; - - function toArray(x) { return x.toArray(); } - function notEmpty(x) { return x.length > 0; } - - /** - * Projects each element of an observable sequence into zero or more buffers which are produced based on element count information. - * @param {Number} count Length of each buffer. - * @param {Number} [skip] Number of elements to skip between creation of consecutive buffers. If not provided, defaults to the count. - * @returns {Observable} An observable sequence of buffers. - */ - observableProto.bufferWithCount = observableProto.bufferCount = function (count, skip) { - typeof skip !== 'number' && (skip = count); - return this.windowWithCount(count, skip) - .flatMap(toArray) - .filter(notEmpty); - }; - - var DematerializeObservable = (function (__super__) { - inherits(DematerializeObservable, __super__); - function DematerializeObservable(source) { - this.source = source; - __super__.call(this); - } - - DematerializeObservable.prototype.subscribeCore = function (o) { - return this.source.subscribe(new DematerializeObserver(o)); - }; - - return DematerializeObservable; - }(ObservableBase)); - - var DematerializeObserver = (function (__super__) { - inherits(DematerializeObserver, __super__); - - function DematerializeObserver(o) { - this._o = o; - __super__.call(this); - } - - DematerializeObserver.prototype.next = function (x) { x.accept(this._o); }; - DematerializeObserver.prototype.error = function (e) { this._o.onError(e); }; - DematerializeObserver.prototype.completed = function () { this._o.onCompleted(); }; - - return DematerializeObserver; - }(AbstractObserver)); - - /** - * Dematerializes the explicit notification values of an observable sequence as implicit notifications. - * @returns {Observable} An observable sequence exhibiting the behavior corresponding to the source sequence's notification values. - */ - observableProto.dematerialize = function () { - return new DematerializeObservable(this); - }; - - var DistinctUntilChangedObservable = (function(__super__) { - inherits(DistinctUntilChangedObservable, __super__); - function DistinctUntilChangedObservable(source, keyFn, comparer) { - this.source = source; - this.keyFn = keyFn; - this.comparer = comparer; - __super__.call(this); - } - - DistinctUntilChangedObservable.prototype.subscribeCore = function (o) { - return this.source.subscribe(new DistinctUntilChangedObserver(o, this.keyFn, this.comparer)); - }; - - return DistinctUntilChangedObservable; - }(ObservableBase)); - - var DistinctUntilChangedObserver = (function(__super__) { - inherits(DistinctUntilChangedObserver, __super__); - function DistinctUntilChangedObserver(o, keyFn, comparer) { - this.o = o; - this.keyFn = keyFn; - this.comparer = comparer; - this.hasCurrentKey = false; - this.currentKey = null; - __super__.call(this); - } - - DistinctUntilChangedObserver.prototype.next = function (x) { - var key = x, comparerEquals; - if (isFunction(this.keyFn)) { - key = tryCatch(this.keyFn)(x); - if (key === errorObj) { return this.o.onError(key.e); } - } - if (this.hasCurrentKey) { - comparerEquals = tryCatch(this.comparer)(this.currentKey, key); - if (comparerEquals === errorObj) { return this.o.onError(comparerEquals.e); } - } - if (!this.hasCurrentKey || !comparerEquals) { - this.hasCurrentKey = true; - this.currentKey = key; - this.o.onNext(x); - } - }; - DistinctUntilChangedObserver.prototype.error = function(e) { - this.o.onError(e); - }; - DistinctUntilChangedObserver.prototype.completed = function () { - this.o.onCompleted(); - }; - - return DistinctUntilChangedObserver; - }(AbstractObserver)); - - /** - * Returns an observable sequence that contains only distinct contiguous elements according to the keyFn and the comparer. - * @param {Function} [keyFn] A function to compute the comparison key for each element. If not provided, it projects the value. - * @param {Function} [comparer] Equality comparer for computed key values. If not provided, defaults to an equality comparer function. - * @returns {Observable} An observable sequence only containing the distinct contiguous elements, based on a computed key value, from the source sequence. - */ - observableProto.distinctUntilChanged = function (keyFn, comparer) { - comparer || (comparer = defaultComparer); - return new DistinctUntilChangedObservable(this, keyFn, comparer); - }; - - var TapObservable = (function(__super__) { - inherits(TapObservable,__super__); - function TapObservable(source, observerOrOnNext, onError, onCompleted) { - this.source = source; - this._oN = observerOrOnNext; - this._oE = onError; - this._oC = onCompleted; - __super__.call(this); - } - - TapObservable.prototype.subscribeCore = function(o) { - return this.source.subscribe(new InnerObserver(o, this)); - }; - - inherits(InnerObserver, AbstractObserver); - function InnerObserver(o, p) { - this.o = o; - this.t = !p._oN || isFunction(p._oN) ? - observerCreate(p._oN || noop, p._oE || noop, p._oC || noop) : - p._oN; - this.isStopped = false; - AbstractObserver.call(this); - } - InnerObserver.prototype.next = function(x) { - var res = tryCatch(this.t.onNext).call(this.t, x); - if (res === errorObj) { this.o.onError(res.e); } - this.o.onNext(x); - }; - InnerObserver.prototype.error = function(err) { - var res = tryCatch(this.t.onError).call(this.t, err); - if (res === errorObj) { return this.o.onError(res.e); } - this.o.onError(err); - }; - InnerObserver.prototype.completed = function() { - var res = tryCatch(this.t.onCompleted).call(this.t); - if (res === errorObj) { return this.o.onError(res.e); } - this.o.onCompleted(); - }; - - return TapObservable; - }(ObservableBase)); - - /** - * Invokes an action for each element in the observable sequence and invokes an action upon graceful or exceptional termination of the observable sequence. - * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline. - * @param {Function | Observer} observerOrOnNext Action to invoke for each element in the observable sequence or an o. - * @param {Function} [onError] Action to invoke upon exceptional termination of the observable sequence. Used if only the observerOrOnNext parameter is also a function. - * @param {Function} [onCompleted] Action to invoke upon graceful termination of the observable sequence. Used if only the observerOrOnNext parameter is also a function. - * @returns {Observable} The source sequence with the side-effecting behavior applied. - */ - observableProto['do'] = observableProto.tap = observableProto.doAction = function (observerOrOnNext, onError, onCompleted) { - return new TapObservable(this, observerOrOnNext, onError, onCompleted); - }; - - /** - * Invokes an action for each element in the observable sequence. - * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline. - * @param {Function} onNext Action to invoke for each element in the observable sequence. - * @param {Any} [thisArg] Object to use as this when executing callback. - * @returns {Observable} The source sequence with the side-effecting behavior applied. - */ - observableProto.doOnNext = observableProto.tapOnNext = function (onNext, thisArg) { - return this.tap(typeof thisArg !== 'undefined' ? function (x) { onNext.call(thisArg, x); } : onNext); - }; - - /** - * Invokes an action upon exceptional termination of the observable sequence. - * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline. - * @param {Function} onError Action to invoke upon exceptional termination of the observable sequence. - * @param {Any} [thisArg] Object to use as this when executing callback. - * @returns {Observable} The source sequence with the side-effecting behavior applied. - */ - observableProto.doOnError = observableProto.tapOnError = function (onError, thisArg) { - return this.tap(noop, typeof thisArg !== 'undefined' ? function (e) { onError.call(thisArg, e); } : onError); - }; - - /** - * Invokes an action upon graceful termination of the observable sequence. - * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline. - * @param {Function} onCompleted Action to invoke upon graceful termination of the observable sequence. - * @param {Any} [thisArg] Object to use as this when executing callback. - * @returns {Observable} The source sequence with the side-effecting behavior applied. - */ - observableProto.doOnCompleted = observableProto.tapOnCompleted = function (onCompleted, thisArg) { - return this.tap(noop, null, typeof thisArg !== 'undefined' ? function () { onCompleted.call(thisArg); } : onCompleted); - }; - - var FinallyObservable = (function (__super__) { - inherits(FinallyObservable, __super__); - function FinallyObservable(source, fn, thisArg) { - this.source = source; - this._fn = bindCallback(fn, thisArg, 0); - __super__.call(this); - } - - FinallyObservable.prototype.subscribeCore = function (o) { - var d = tryCatch(this.source.subscribe).call(this.source, o); - if (d === errorObj) { - this._fn(); - thrower(d.e); - } - - return new FinallyDisposable(d, this._fn); - }; - - function FinallyDisposable(s, fn) { - this.isDisposed = false; - this._s = s; - this._fn = fn; - } - FinallyDisposable.prototype.dispose = function () { - if (!this.isDisposed) { - var res = tryCatch(this._s.dispose).call(this._s); - this._fn(); - res === errorObj && thrower(res.e); - } - }; - - return FinallyObservable; - - }(ObservableBase)); - - /** - * Invokes a specified action after the source observable sequence terminates gracefully or exceptionally. - * @param {Function} finallyAction Action to invoke after the source observable sequence terminates. - * @returns {Observable} Source sequence with the action-invoking termination behavior applied. - */ - observableProto['finally'] = function (action, thisArg) { - return new FinallyObservable(this, action, thisArg); - }; - - var IgnoreElementsObservable = (function(__super__) { - inherits(IgnoreElementsObservable, __super__); - - function IgnoreElementsObservable(source) { - this.source = source; - __super__.call(this); - } - - IgnoreElementsObservable.prototype.subscribeCore = function (o) { - return this.source.subscribe(new InnerObserver(o)); - }; - - function InnerObserver(o) { - this.o = o; - this.isStopped = false; - } - InnerObserver.prototype.onNext = noop; - InnerObserver.prototype.onError = function (err) { - if(!this.isStopped) { - this.isStopped = true; - this.o.onError(err); - } - }; - InnerObserver.prototype.onCompleted = function () { - if(!this.isStopped) { - this.isStopped = true; - this.o.onCompleted(); - } - }; - InnerObserver.prototype.dispose = function() { this.isStopped = true; }; - InnerObserver.prototype.fail = function (e) { - if (!this.isStopped) { - this.isStopped = true; - this.observer.onError(e); - return true; - } - - return false; - }; - - return IgnoreElementsObservable; - }(ObservableBase)); - - /** - * Ignores all elements in an observable sequence leaving only the termination messages. - * @returns {Observable} An empty observable sequence that signals termination, successful or exceptional, of the source sequence. - */ - observableProto.ignoreElements = function () { - return new IgnoreElementsObservable(this); - }; - - var MaterializeObservable = (function (__super__) { - inherits(MaterializeObservable, __super__); - function MaterializeObservable(source, fn) { - this.source = source; - __super__.call(this); - } - - MaterializeObservable.prototype.subscribeCore = function (o) { - return this.source.subscribe(new MaterializeObserver(o)); - }; - - return MaterializeObservable; - }(ObservableBase)); - - var MaterializeObserver = (function (__super__) { - inherits(MaterializeObserver, __super__); - - function MaterializeObserver(o) { - this._o = o; - __super__.call(this); - } - - MaterializeObserver.prototype.next = function (x) { this._o.onNext(notificationCreateOnNext(x)) }; - MaterializeObserver.prototype.error = function (e) { this._o.onNext(notificationCreateOnError(e)); this._o.onCompleted(); }; - MaterializeObserver.prototype.completed = function () { this._o.onNext(notificationCreateOnCompleted()); this._o.onCompleted(); }; - - return MaterializeObserver; - }(AbstractObserver)); - - /** - * Materializes the implicit notifications of an observable sequence as explicit notification values. - * @returns {Observable} An observable sequence containing the materialized notification values from the source sequence. - */ - observableProto.materialize = function () { - return new MaterializeObservable(this); - }; - - /** - * Repeats the observable sequence a specified number of times. If the repeat count is not specified, the sequence repeats indefinitely. - * @param {Number} [repeatCount] Number of times to repeat the sequence. If not provided, repeats the sequence indefinitely. - * @returns {Observable} The observable sequence producing the elements of the given sequence repeatedly. - */ - observableProto.repeat = function (repeatCount) { - return enumerableRepeat(this, repeatCount).concat(); - }; - - /** - * Repeats the source observable sequence the specified number of times or until it successfully terminates. If the retry count is not specified, it retries indefinitely. - * Note if you encounter an error and want it to retry once, then you must use .retry(2); - * - * @example - * var res = retried = retry.repeat(); - * var res = retried = retry.repeat(2); - * @param {Number} [retryCount] Number of times to retry the sequence. If not provided, retry the sequence indefinitely. - * @returns {Observable} An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully. - */ - observableProto.retry = function (retryCount) { - return enumerableRepeat(this, retryCount).catchError(); - }; - - function repeat(value) { - return { - '@@iterator': function () { - return { - next: function () { - return { done: false, value: value }; - } - }; - } - }; - } - - var RetryWhenObservable = (function(__super__) { - function createDisposable(state) { - return { - isDisposed: false, - dispose: function () { - if (!this.isDisposed) { - this.isDisposed = true; - state.isDisposed = true; - } - } - }; - } - - function RetryWhenObservable(source, notifier) { - this.source = source; - this._notifier = notifier; - __super__.call(this); - } - - inherits(RetryWhenObservable, __super__); - - RetryWhenObservable.prototype.subscribeCore = function (o) { - var exceptions = new Subject(), - notifier = new Subject(), - handled = this._notifier(exceptions), - notificationDisposable = handled.subscribe(notifier); - - var e = this.source['@@iterator'](); - - var state = { isDisposed: false }, - lastError, - subscription = new SerialDisposable(); - var cancelable = currentThreadScheduler.scheduleRecursive(null, function (_, recurse) { - if (state.isDisposed) { return; } - var currentItem = e.next(); - - if (currentItem.done) { - if (lastError) { - o.onError(lastError); - } else { - o.onCompleted(); - } - return; - } - - // Check if promise - var currentValue = currentItem.value; - isPromise(currentValue) && (currentValue = observableFromPromise(currentValue)); - - var outer = new SingleAssignmentDisposable(); - var inner = new SingleAssignmentDisposable(); - subscription.setDisposable(new BinaryDisposable(inner, outer)); - outer.setDisposable(currentValue.subscribe( - function(x) { o.onNext(x); }, - function (exn) { - inner.setDisposable(notifier.subscribe(recurse, function(ex) { - o.onError(ex); - }, function() { - o.onCompleted(); - })); - - exceptions.onNext(exn); - outer.dispose(); - }, - function() { o.onCompleted(); })); - }); - - return new NAryDisposable([notificationDisposable, subscription, cancelable, createDisposable(state)]); - }; - - return RetryWhenObservable; - }(ObservableBase)); - - observableProto.retryWhen = function (notifier) { - return new RetryWhenObservable(repeat(this), notifier); - }; - - function repeat(value) { - return { - '@@iterator': function () { - return { - next: function () { - return { done: false, value: value }; - } - }; - } - }; - } - - var RepeatWhenObservable = (function(__super__) { - function createDisposable(state) { - return { - isDisposed: false, - dispose: function () { - if (!this.isDisposed) { - this.isDisposed = true; - state.isDisposed = true; - } - } - }; - } - - function RepeatWhenObservable(source, notifier) { - this.source = source; - this._notifier = notifier; - __super__.call(this); - } - - inherits(RepeatWhenObservable, __super__); - - RepeatWhenObservable.prototype.subscribeCore = function (o) { - var completions = new Subject(), - notifier = new Subject(), - handled = this._notifier(completions), - notificationDisposable = handled.subscribe(notifier); - - var e = this.source['@@iterator'](); - - var state = { isDisposed: false }, - lastError, - subscription = new SerialDisposable(); - var cancelable = currentThreadScheduler.scheduleRecursive(null, function (_, recurse) { - if (state.isDisposed) { return; } - var currentItem = e.next(); - - if (currentItem.done) { - if (lastError) { - o.onError(lastError); - } else { - o.onCompleted(); - } - return; - } - - // Check if promise - var currentValue = currentItem.value; - isPromise(currentValue) && (currentValue = observableFromPromise(currentValue)); - - var outer = new SingleAssignmentDisposable(); - var inner = new SingleAssignmentDisposable(); - subscription.setDisposable(new BinaryDisposable(inner, outer)); - outer.setDisposable(currentValue.subscribe( - function(x) { o.onNext(x); }, - function (exn) { o.onError(exn); }, - function() { - inner.setDisposable(notifier.subscribe(recurse, function(ex) { - o.onError(ex); - }, function() { - o.onCompleted(); - })); - - completions.onNext(null); - outer.dispose(); - })); - }); - - return new NAryDisposable([notificationDisposable, subscription, cancelable, createDisposable(state)]); - }; - - return RepeatWhenObservable; - }(ObservableBase)); - - observableProto.repeatWhen = function (notifier) { - return new RepeatWhenObservable(repeat(this), notifier); - }; - - var ScanObservable = (function(__super__) { - inherits(ScanObservable, __super__); - function ScanObservable(source, accumulator, hasSeed, seed) { - this.source = source; - this.accumulator = accumulator; - this.hasSeed = hasSeed; - this.seed = seed; - __super__.call(this); - } - - ScanObservable.prototype.subscribeCore = function(o) { - return this.source.subscribe(new ScanObserver(o,this)); - }; - - return ScanObservable; - }(ObservableBase)); - - var ScanObserver = (function (__super__) { - inherits(ScanObserver, __super__); - function ScanObserver(o, parent) { - this._o = o; - this._p = parent; - this._fn = parent.accumulator; - this._hs = parent.hasSeed; - this._s = parent.seed; - this._ha = false; - this._a = null; - this._hv = false; - this._i = 0; - __super__.call(this); - } - - ScanObserver.prototype.next = function (x) { - !this._hv && (this._hv = true); - if (this._ha) { - this._a = tryCatch(this._fn)(this._a, x, this._i, this._p); - } else { - this._a = this._hs ? tryCatch(this._fn)(this._s, x, this._i, this._p) : x; - this._ha = true; - } - if (this._a === errorObj) { return this._o.onError(this._a.e); } - this._o.onNext(this._a); - this._i++; - }; - - ScanObserver.prototype.error = function (e) { - this._o.onError(e); - }; - - ScanObserver.prototype.completed = function () { - !this._hv && this._hs && this._o.onNext(this._s); - this._o.onCompleted(); - }; - - return ScanObserver; - }(AbstractObserver)); - - /** - * Applies an accumulator function over an observable sequence and returns each intermediate result. The optional seed value is used as the initial accumulator value. - * For aggregation behavior with no intermediate results, see Observable.aggregate. - * @param {Mixed} [seed] The initial accumulator value. - * @param {Function} accumulator An accumulator function to be invoked on each element. - * @returns {Observable} An observable sequence containing the accumulated values. - */ - observableProto.scan = function () { - var hasSeed = false, seed, accumulator = arguments[0]; - if (arguments.length === 2) { - hasSeed = true; - seed = arguments[1]; - } - return new ScanObservable(this, accumulator, hasSeed, seed); - }; - - var SkipLastObservable = (function (__super__) { - inherits(SkipLastObservable, __super__); - function SkipLastObservable(source, c) { - this.source = source; - this._c = c; - __super__.call(this); - } - - SkipLastObservable.prototype.subscribeCore = function (o) { - return this.source.subscribe(new SkipLastObserver(o, this._c)); - }; - - return SkipLastObservable; - }(ObservableBase)); - - var SkipLastObserver = (function (__super__) { - inherits(SkipLastObserver, __super__); - function SkipLastObserver(o, c) { - this._o = o; - this._c = c; - this._q = []; - __super__.call(this); - } - - SkipLastObserver.prototype.next = function (x) { - this._q.push(x); - this._q.length > this._c && this._o.onNext(this._q.shift()); - }; - - SkipLastObserver.prototype.error = function (e) { - this._o.onError(e); - }; - - SkipLastObserver.prototype.completed = function () { - this._o.onCompleted(); - }; - - return SkipLastObserver; - }(AbstractObserver)); - - /** - * Bypasses a specified number of elements at the end of an observable sequence. - * @description - * This operator accumulates a queue with a length enough to store the first `count` elements. As more elements are - * received, elements are taken from the front of the queue and produced on the result sequence. This causes elements to be delayed. - * @param count Number of elements to bypass at the end of the source sequence. - * @returns {Observable} An observable sequence containing the source sequence elements except for the bypassed ones at the end. - */ - observableProto.skipLast = function (count) { - if (count < 0) { throw new ArgumentOutOfRangeError(); } - return new SkipLastObservable(this, count); - }; - - /** - * Prepends a sequence of values to an observable sequence with an optional scheduler and an argument list of values to prepend. - * @example - * var res = source.startWith(1, 2, 3); - * var res = source.startWith(Rx.Scheduler.timeout, 1, 2, 3); - * @param {Arguments} args The specified values to prepend to the observable sequence - * @returns {Observable} The source sequence prepended with the specified values. - */ - observableProto.startWith = function () { - var values, scheduler, start = 0; - if (!!arguments.length && isScheduler(arguments[0])) { - scheduler = arguments[0]; - start = 1; - } else { - scheduler = immediateScheduler; - } - for(var args = [], i = start, len = arguments.length; i < len; i++) { args.push(arguments[i]); } - return observableConcat.apply(null, [observableFromArray(args, scheduler), this]); - }; - - var TakeLastObserver = (function (__super__) { - inherits(TakeLastObserver, __super__); - function TakeLastObserver(o, c) { - this._o = o; - this._c = c; - this._q = []; - __super__.call(this); - } - - TakeLastObserver.prototype.next = function (x) { - this._q.push(x); - this._q.length > this._c && this._q.shift(); - }; - - TakeLastObserver.prototype.error = function (e) { - this._o.onError(e); - }; - - TakeLastObserver.prototype.completed = function () { - while (this._q.length > 0) { this._o.onNext(this._q.shift()); } - this._o.onCompleted(); - }; - - return TakeLastObserver; - }(AbstractObserver)); - - /** - * Returns a specified number of contiguous elements from the end of an observable sequence. - * @description - * This operator accumulates a buffer with a length enough to store elements count elements. Upon completion of - * the source sequence, this buffer is drained on the result sequence. This causes the elements to be delayed. - * @param {Number} count Number of elements to take from the end of the source sequence. - * @returns {Observable} An observable sequence containing the specified number of elements from the end of the source sequence. - */ - observableProto.takeLast = function (count) { - if (count < 0) { throw new ArgumentOutOfRangeError(); } - var source = this; - return new AnonymousObservable(function (o) { - return source.subscribe(new TakeLastObserver(o, count)); - }, source); - }; - - var TakeLastBufferObserver = (function (__super__) { - inherits(TakeLastBufferObserver, __super__); - function TakeLastBufferObserver(o, c) { - this._o = o; - this._c = c; - this._q = []; - __super__.call(this); - } - - TakeLastBufferObserver.prototype.next = function (x) { - this._q.push(x); - this._q.length > this._c && this._q.shift(); - }; - - TakeLastBufferObserver.prototype.error = function (e) { - this._o.onError(e); - }; - - TakeLastBufferObserver.prototype.completed = function () { - this._o.onNext(this._q); - this._o.onCompleted(); - }; - - return TakeLastBufferObserver; - }(AbstractObserver)); - - /** - * Returns an array with the specified number of contiguous elements from the end of an observable sequence. - * - * @description - * This operator accumulates a buffer with a length enough to store count elements. Upon completion of the - * source sequence, this buffer is produced on the result sequence. - * @param {Number} count Number of elements to take from the end of the source sequence. - * @returns {Observable} An observable sequence containing a single array with the specified number of elements from the end of the source sequence. - */ - observableProto.takeLastBuffer = function (count) { - if (count < 0) { throw new ArgumentOutOfRangeError(); } - var source = this; - return new AnonymousObservable(function (o) { - return source.subscribe(new TakeLastBufferObserver(o, count)); - }, source); - }; - - /** - * Projects each element of an observable sequence into zero or more windows which are produced based on element count information. - * @param {Number} count Length of each window. - * @param {Number} [skip] Number of elements to skip between creation of consecutive windows. If not specified, defaults to the count. - * @returns {Observable} An observable sequence of windows. - */ - observableProto.windowWithCount = observableProto.windowCount = function (count, skip) { - var source = this; - +count || (count = 0); - Math.abs(count) === Infinity && (count = 0); - if (count <= 0) { throw new ArgumentOutOfRangeError(); } - skip == null && (skip = count); - +skip || (skip = 0); - Math.abs(skip) === Infinity && (skip = 0); - - if (skip <= 0) { throw new ArgumentOutOfRangeError(); } - return new AnonymousObservable(function (observer) { - var m = new SingleAssignmentDisposable(), - refCountDisposable = new RefCountDisposable(m), - n = 0, - q = []; - - function createWindow () { - var s = new Subject(); - q.push(s); - observer.onNext(addRef(s, refCountDisposable)); - } - - createWindow(); - - m.setDisposable(source.subscribe( - function (x) { - for (var i = 0, len = q.length; i < len; i++) { q[i].onNext(x); } - var c = n - count + 1; - c >= 0 && c % skip === 0 && q.shift().onCompleted(); - ++n % skip === 0 && createWindow(); - }, - function (e) { - while (q.length > 0) { q.shift().onError(e); } - observer.onError(e); - }, - function () { - while (q.length > 0) { q.shift().onCompleted(); } - observer.onCompleted(); - } - )); - return refCountDisposable; - }, source); - }; - -observableProto.flatMapConcat = observableProto.concatMap = function(selector, resultSelector, thisArg) { - return new FlatMapObservable(this, selector, resultSelector, thisArg).merge(1); -}; - /** - * Projects each notification of an observable sequence to an observable sequence and concats the resulting observable sequences into one observable sequence. - * @param {Function} onNext A transform function to apply to each element; the second parameter of the function represents the index of the source element. - * @param {Function} onError A transform function to apply when an error occurs in the source sequence. - * @param {Function} onCompleted A transform function to apply when the end of the source sequence is reached. - * @param {Any} [thisArg] An optional "this" to use to invoke each transform. - * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence. - */ - observableProto.concatMapObserver = observableProto.selectConcatObserver = function(onNext, onError, onCompleted, thisArg) { - var source = this, - onNextFunc = bindCallback(onNext, thisArg, 2), - onErrorFunc = bindCallback(onError, thisArg, 1), - onCompletedFunc = bindCallback(onCompleted, thisArg, 0); - return new AnonymousObservable(function (observer) { - var index = 0; - return source.subscribe( - function (x) { - var result; - try { - result = onNextFunc(x, index++); - } catch (e) { - observer.onError(e); - return; - } - isPromise(result) && (result = observableFromPromise(result)); - observer.onNext(result); - }, - function (err) { - var result; - try { - result = onErrorFunc(err); - } catch (e) { - observer.onError(e); - return; - } - isPromise(result) && (result = observableFromPromise(result)); - observer.onNext(result); - observer.onCompleted(); - }, - function () { - var result; - try { - result = onCompletedFunc(); - } catch (e) { - observer.onError(e); - return; - } - isPromise(result) && (result = observableFromPromise(result)); - observer.onNext(result); - observer.onCompleted(); - }); - }, this).concatAll(); - }; - - var DefaultIfEmptyObserver = (function (__super__) { - inherits(DefaultIfEmptyObserver, __super__); - function DefaultIfEmptyObserver(o, d) { - this._o = o; - this._d = d; - this._f = false; - __super__.call(this); - } - - DefaultIfEmptyObserver.prototype.next = function (x) { - this._f = true; - this._o.onNext(x); - }; - - DefaultIfEmptyObserver.prototype.error = function (e) { - this._o.onError(e); - }; - - DefaultIfEmptyObserver.prototype.completed = function () { - !this._f && this._o.onNext(this._d); - this._o.onCompleted(); - }; - - return DefaultIfEmptyObserver; - }(AbstractObserver)); - - /** - * Returns the elements of the specified sequence or the specified value in a singleton sequence if the sequence is empty. - * - * var res = obs = xs.defaultIfEmpty(); - * 2 - obs = xs.defaultIfEmpty(false); - * - * @memberOf Observable# - * @param defaultValue The value to return if the sequence is empty. If not provided, this defaults to null. - * @returns {Observable} An observable sequence that contains the specified default value if the source is empty; otherwise, the elements of the source itself. - */ - observableProto.defaultIfEmpty = function (defaultValue) { - var source = this; - defaultValue === undefined && (defaultValue = null); - return new AnonymousObservable(function (o) { - return source.subscribe(new DefaultIfEmptyObserver(o, defaultValue)); - }, source); - }; - - // Swap out for Array.findIndex - function arrayIndexOfComparer(array, item, comparer) { - for (var i = 0, len = array.length; i < len; i++) { - if (comparer(array[i], item)) { return i; } - } - return -1; - } - - function HashSet(comparer) { - this.comparer = comparer; - this.set = []; - } - HashSet.prototype.push = function(value) { - var retValue = arrayIndexOfComparer(this.set, value, this.comparer) === -1; - retValue && this.set.push(value); - return retValue; - }; - - var DistinctObservable = (function (__super__) { - inherits(DistinctObservable, __super__); - function DistinctObservable(source, keyFn, cmpFn) { - this.source = source; - this._keyFn = keyFn; - this._cmpFn = cmpFn; - __super__.call(this); - } - - DistinctObservable.prototype.subscribeCore = function (o) { - return this.source.subscribe(new DistinctObserver(o, this._keyFn, this._cmpFn)); - }; - - return DistinctObservable; - }(ObservableBase)); - - var DistinctObserver = (function (__super__) { - inherits(DistinctObserver, __super__); - function DistinctObserver(o, keyFn, cmpFn) { - this._o = o; - this._keyFn = keyFn; - this._h = new HashSet(cmpFn); - __super__.call(this); - } - - DistinctObserver.prototype.next = function (x) { - var key = x; - if (isFunction(this._keyFn)) { - key = tryCatch(this._keyFn)(x); - if (key === errorObj) { return this._o.onError(key.e); } - } - this._h.push(key) && this._o.onNext(x); - }; - - DistinctObserver.prototype.error = function (e) { this._o.onError(e); }; - DistinctObserver.prototype.completed = function () { this._o.onCompleted(); }; - - return DistinctObserver; - }(AbstractObserver)); - - /** - * Returns an observable sequence that contains only distinct elements according to the keySelector and the comparer. - * Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large. - * - * @example - * var res = obs = xs.distinct(); - * 2 - obs = xs.distinct(function (x) { return x.id; }); - * 2 - obs = xs.distinct(function (x) { return x.id; }, function (a,b) { return a === b; }); - * @param {Function} [keySelector] A function to compute the comparison key for each element. - * @param {Function} [comparer] Used to compare items in the collection. - * @returns {Observable} An observable sequence only containing the distinct elements, based on a computed key value, from the source sequence. - */ - observableProto.distinct = function (keySelector, comparer) { - comparer || (comparer = defaultComparer); - return new DistinctObservable(this, keySelector, comparer); - }; - - var MapObservable = (function (__super__) { - inherits(MapObservable, __super__); - - function MapObservable(source, selector, thisArg) { - this.source = source; - this.selector = bindCallback(selector, thisArg, 3); - __super__.call(this); - } - - function innerMap(selector, self) { - return function (x, i, o) { return selector.call(this, self.selector(x, i, o), i, o); }; - } - - MapObservable.prototype.internalMap = function (selector, thisArg) { - return new MapObservable(this.source, innerMap(selector, this), thisArg); - }; - - MapObservable.prototype.subscribeCore = function (o) { - return this.source.subscribe(new InnerObserver(o, this.selector, this)); - }; - - inherits(InnerObserver, AbstractObserver); - function InnerObserver(o, selector, source) { - this.o = o; - this.selector = selector; - this.source = source; - this.i = 0; - AbstractObserver.call(this); - } - - InnerObserver.prototype.next = function(x) { - var result = tryCatch(this.selector)(x, this.i++, this.source); - if (result === errorObj) { return this.o.onError(result.e); } - this.o.onNext(result); - }; - - InnerObserver.prototype.error = function (e) { - this.o.onError(e); - }; - - InnerObserver.prototype.completed = function () { - this.o.onCompleted(); - }; - - return MapObservable; - - }(ObservableBase)); - - /** - * Projects each element of an observable sequence into a new form by incorporating the element's index. - * @param {Function} selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element. - * @param {Any} [thisArg] Object to use as this when executing callback. - * @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source. - */ - observableProto.map = observableProto.select = function (selector, thisArg) { - var selectorFn = typeof selector === 'function' ? selector : function () { return selector; }; - return this instanceof MapObservable ? - this.internalMap(selectorFn, thisArg) : - new MapObservable(this, selectorFn, thisArg); - }; - - function plucker(args, len) { - return function mapper(x) { - var currentProp = x; - for (var i = 0; i < len; i++) { - var p = currentProp[args[i]]; - if (typeof p !== 'undefined') { - currentProp = p; - } else { - return undefined; - } - } - return currentProp; - }; - } - - /** - * Retrieves the value of a specified nested property from all elements in - * the Observable sequence. - * @param {Arguments} arguments The nested properties to pluck. - * @returns {Observable} Returns a new Observable sequence of property values. - */ - observableProto.pluck = function () { - var len = arguments.length, args = new Array(len); - if (len === 0) { throw new Error('List of properties cannot be empty.'); } - for(var i = 0; i < len; i++) { args[i] = arguments[i]; } - return this.map(plucker(args, len)); - }; - - /** - * Projects each notification of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence. - * @param {Function} onNext A transform function to apply to each element; the second parameter of the function represents the index of the source element. - * @param {Function} onError A transform function to apply when an error occurs in the source sequence. - * @param {Function} onCompleted A transform function to apply when the end of the source sequence is reached. - * @param {Any} [thisArg] An optional "this" to use to invoke each transform. - * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence. - */ - observableProto.flatMapObserver = observableProto.selectManyObserver = function (onNext, onError, onCompleted, thisArg) { - var source = this; - return new AnonymousObservable(function (observer) { - var index = 0; - - return source.subscribe( - function (x) { - var result; - try { - result = onNext.call(thisArg, x, index++); - } catch (e) { - observer.onError(e); - return; - } - isPromise(result) && (result = observableFromPromise(result)); - observer.onNext(result); - }, - function (err) { - var result; - try { - result = onError.call(thisArg, err); - } catch (e) { - observer.onError(e); - return; - } - isPromise(result) && (result = observableFromPromise(result)); - observer.onNext(result); - observer.onCompleted(); - }, - function () { - var result; - try { - result = onCompleted.call(thisArg); - } catch (e) { - observer.onError(e); - return; - } - isPromise(result) && (result = observableFromPromise(result)); - observer.onNext(result); - observer.onCompleted(); - }); - }, source).mergeAll(); - }; - -observableProto.flatMap = observableProto.selectMany = observableProto.mergeMap = function(selector, resultSelector, thisArg) { - return new FlatMapObservable(this, selector, resultSelector, thisArg).mergeAll(); -}; - -observableProto.flatMapLatest = observableProto.switchMap = function(selector, resultSelector, thisArg) { - return new FlatMapObservable(this, selector, resultSelector, thisArg).switchLatest(); -}; - - var SkipObservable = (function(__super__) { - inherits(SkipObservable, __super__); - function SkipObservable(source, count) { - this.source = source; - this._count = count; - __super__.call(this); - } - - SkipObservable.prototype.subscribeCore = function (o) { - return this.source.subscribe(new SkipObserver(o, this._count)); - }; - - function SkipObserver(o, c) { - this._o = o; - this._r = c; - AbstractObserver.call(this); - } - - inherits(SkipObserver, AbstractObserver); - - SkipObserver.prototype.next = function (x) { - if (this._r <= 0) { - this._o.onNext(x); - } else { - this._r--; - } - }; - SkipObserver.prototype.error = function(e) { this._o.onError(e); }; - SkipObserver.prototype.completed = function() { this._o.onCompleted(); }; - - return SkipObservable; - }(ObservableBase)); - - /** - * Bypasses a specified number of elements in an observable sequence and then returns the remaining elements. - * @param {Number} count The number of elements to skip before returning the remaining elements. - * @returns {Observable} An observable sequence that contains the elements that occur after the specified index in the input sequence. - */ - observableProto.skip = function (count) { - if (count < 0) { throw new ArgumentOutOfRangeError(); } - return new SkipObservable(this, count); - }; - - var SkipWhileObservable = (function (__super__) { - inherits(SkipWhileObservable, __super__); - function SkipWhileObservable(source, fn) { - this.source = source; - this._fn = fn; - __super__.call(this); - } - - SkipWhileObservable.prototype.subscribeCore = function (o) { - return this.source.subscribe(new SkipWhileObserver(o, this)); - }; - - return SkipWhileObservable; - }(ObservableBase)); - - var SkipWhileObserver = (function (__super__) { - inherits(SkipWhileObserver, __super__); - - function SkipWhileObserver(o, p) { - this._o = o; - this._p = p; - this._i = 0; - this._r = false; - __super__.call(this); - } - - SkipWhileObserver.prototype.next = function (x) { - if (!this._r) { - var res = tryCatch(this._p._fn)(x, this._i++, this._p); - if (res === errorObj) { return this._o.onError(res.e); } - this._r = !res; - } - this._r && this._o.onNext(x); - }; - SkipWhileObserver.prototype.error = function (e) { this._o.onError(e); }; - SkipWhileObserver.prototype.completed = function () { this._o.onCompleted(); }; - - return SkipWhileObserver; - }(AbstractObserver)); - - /** - * Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements. - * The element's index is used in the logic of the predicate function. - * - * var res = source.skipWhile(function (value) { return value < 10; }); - * var res = source.skipWhile(function (value, index) { return value < 10 || index < 10; }); - * @param {Function} predicate A function to test each element for a condition; the second parameter of the function represents the index of the source element. - * @param {Any} [thisArg] Object to use as this when executing callback. - * @returns {Observable} An observable sequence that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by predicate. - */ - observableProto.skipWhile = function (predicate, thisArg) { - var fn = bindCallback(predicate, thisArg, 3); - return new SkipWhileObservable(this, fn); - }; - - var TakeObservable = (function(__super__) { - inherits(TakeObservable, __super__); - function TakeObservable(source, count) { - this.source = source; - this._count = count; - __super__.call(this); - } - - TakeObservable.prototype.subscribeCore = function (o) { - return this.source.subscribe(new TakeObserver(o, this._count)); - }; - - function TakeObserver(o, c) { - this._o = o; - this._c = c; - this._r = c; - AbstractObserver.call(this); - } - - inherits(TakeObserver, AbstractObserver); - - TakeObserver.prototype.next = function (x) { - if (this._r-- > 0) { - this._o.onNext(x); - this._r <= 0 && this._o.onCompleted(); - } - }; - - TakeObserver.prototype.error = function (e) { this._o.onError(e); }; - TakeObserver.prototype.completed = function () { this._o.onCompleted(); }; - - return TakeObservable; - }(ObservableBase)); - - /** - * Returns a specified number of contiguous elements from the start of an observable sequence, using the specified scheduler for the edge case of take(0). - * @param {Number} count The number of elements to return. - * @param {Scheduler} [scheduler] Scheduler used to produce an OnCompleted message in case 0) { - this._v = key; - this._l = []; - } - if (comparison >= 0) { this._l.push(x); } - }; - - ExtremaByObserver.prototype.error = function (e) { - this._o.onError(e); - }; - - ExtremaByObserver.prototype.completed = function () { - this._o.onNext(this._l); - this._o.onCompleted(); - }; - - return ExtremaByObserver; - }(AbstractObserver)); - - function firstOnly(x) { - if (x.length === 0) { throw new EmptyError(); } - return x[0]; - } - - var ReduceObservable = (function(__super__) { - inherits(ReduceObservable, __super__); - function ReduceObservable(source, accumulator, hasSeed, seed) { - this.source = source; - this.accumulator = accumulator; - this.hasSeed = hasSeed; - this.seed = seed; - __super__.call(this); - } - - ReduceObservable.prototype.subscribeCore = function(observer) { - return this.source.subscribe(new ReduceObserver(observer,this)); - }; - - return ReduceObservable; - }(ObservableBase)); - - var ReduceObserver = (function (__super__) { - inherits(ReduceObserver, __super__); - function ReduceObserver(o, parent) { - this._o = o; - this._p = parent; - this._fn = parent.accumulator; - this._hs = parent.hasSeed; - this._s = parent.seed; - this._ha = false; - this._a = null; - this._hv = false; - this._i = 0; - __super__.call(this); - } - - ReduceObserver.prototype.next = function (x) { - !this._hv && (this._hv = true); - if (this._ha) { - this._a = tryCatch(this._fn)(this._a, x, this._i, this._p); - } else { - this._a = this._hs ? tryCatch(this._fn)(this._s, x, this._i, this._p) : x; - this._ha = true; - } - if (this._a === errorObj) { return this._o.onError(this._a.e); } - this._i++; - }; - - ReduceObserver.prototype.error = function (e) { - this._o.onError(e); - }; - - ReduceObserver.prototype.completed = function () { - this._hv && this._o.onNext(this._a); - !this._hv && this._hs && this._o.onNext(this._s); - !this._hv && !this._hs && this._o.onError(new EmptyError()); - this._o.onCompleted(); - }; - - return ReduceObserver; - }(AbstractObserver)); - - /** - * Applies an accumulator function over an observable sequence, returning the result of the aggregation as a single element in the result sequence. The specified seed value is used as the initial accumulator value. - * For aggregation behavior with incremental intermediate results, see Observable.scan. - * @param {Function} accumulator An accumulator function to be invoked on each element. - * @param {Any} [seed] The initial accumulator value. - * @returns {Observable} An observable sequence containing a single element with the final accumulator value. - */ - observableProto.reduce = function () { - var hasSeed = false, seed, accumulator = arguments[0]; - if (arguments.length === 2) { - hasSeed = true; - seed = arguments[1]; - } - return new ReduceObservable(this, accumulator, hasSeed, seed); - }; - - var SomeObservable = (function (__super__) { - inherits(SomeObservable, __super__); - function SomeObservable(source, fn) { - this.source = source; - this._fn = fn; - __super__.call(this); - } - - SomeObservable.prototype.subscribeCore = function (o) { - return this.source.subscribe(new SomeObserver(o, this._fn, this.source)); - }; - - return SomeObservable; - }(ObservableBase)); - - var SomeObserver = (function (__super__) { - inherits(SomeObserver, __super__); - - function SomeObserver(o, fn, s) { - this._o = o; - this._fn = fn; - this._s = s; - this._i = 0; - __super__.call(this); - } - - SomeObserver.prototype.next = function (x) { - var result = tryCatch(this._fn)(x, this._i++, this._s); - if (result === errorObj) { return this._o.onError(result.e); } - if (Boolean(result)) { - this._o.onNext(true); - this._o.onCompleted(); - } - }; - SomeObserver.prototype.error = function (e) { this._o.onError(e); }; - SomeObserver.prototype.completed = function () { - this._o.onNext(false); - this._o.onCompleted(); - }; - - return SomeObserver; - }(AbstractObserver)); - - /** - * Determines whether any element of an observable sequence satisfies a condition if present, else if any items are in the sequence. - * @param {Function} [predicate] A function to test each element for a condition. - * @returns {Observable} An observable sequence containing a single element determining whether any elements in the source sequence pass the test in the specified predicate if given, else if any items are in the sequence. - */ - observableProto.some = function (predicate, thisArg) { - var fn = bindCallback(predicate, thisArg, 3); - return new SomeObservable(this, fn); - }; - - var IsEmptyObservable = (function (__super__) { - inherits(IsEmptyObservable, __super__); - function IsEmptyObservable(source) { - this.source = source; - __super__.call(this); - } - - IsEmptyObservable.prototype.subscribeCore = function (o) { - return this.source.subscribe(new IsEmptyObserver(o)); - }; - - return IsEmptyObservable; - }(ObservableBase)); - - var IsEmptyObserver = (function(__super__) { - inherits(IsEmptyObserver, __super__); - function IsEmptyObserver(o) { - this._o = o; - __super__.call(this); - } - - IsEmptyObserver.prototype.next = function () { - this._o.onNext(false); - this._o.onCompleted(); - }; - IsEmptyObserver.prototype.error = function (e) { this._o.onError(e); }; - IsEmptyObserver.prototype.completed = function () { - this._o.onNext(true); - this._o.onCompleted(); - }; - - return IsEmptyObserver; - }(AbstractObserver)); - - /** - * Determines whether an observable sequence is empty. - * @returns {Observable} An observable sequence containing a single element determining whether the source sequence is empty. - */ - observableProto.isEmpty = function () { - return new IsEmptyObservable(this); - }; - - var EveryObservable = (function (__super__) { - inherits(EveryObservable, __super__); - function EveryObservable(source, fn) { - this.source = source; - this._fn = fn; - __super__.call(this); - } - - EveryObservable.prototype.subscribeCore = function (o) { - return this.source.subscribe(new EveryObserver(o, this._fn, this.source)); - }; - - return EveryObservable; - }(ObservableBase)); - - var EveryObserver = (function (__super__) { - inherits(EveryObserver, __super__); - - function EveryObserver(o, fn, s) { - this._o = o; - this._fn = fn; - this._s = s; - this._i = 0; - __super__.call(this); - } - - EveryObserver.prototype.next = function (x) { - var result = tryCatch(this._fn)(x, this._i++, this._s); - if (result === errorObj) { return this._o.onError(result.e); } - if (!Boolean(result)) { - this._o.onNext(false); - this._o.onCompleted(); - } - }; - EveryObserver.prototype.error = function (e) { this._o.onError(e); }; - EveryObserver.prototype.completed = function () { - this._o.onNext(true); - this._o.onCompleted(); - }; - - return EveryObserver; - }(AbstractObserver)); - - /** - * Determines whether all elements of an observable sequence satisfy a condition. - * @param {Function} [predicate] A function to test each element for a condition. - * @param {Any} [thisArg] Object to use as this when executing callback. - * @returns {Observable} An observable sequence containing a single element determining whether all elements in the source sequence pass the test in the specified predicate. - */ - observableProto.every = function (predicate, thisArg) { - var fn = bindCallback(predicate, thisArg, 3); - return new EveryObservable(this, fn); - }; - - var IncludesObservable = (function (__super__) { - inherits(IncludesObservable, __super__); - function IncludesObservable(source, elem, idx) { - var n = +idx || 0; - Math.abs(n) === Infinity && (n = 0); - - this.source = source; - this._elem = elem; - this._n = n; - __super__.call(this); - } - - IncludesObservable.prototype.subscribeCore = function (o) { - if (this._n < 0) { - o.onNext(false); - o.onCompleted(); - return disposableEmpty; - } - - return this.source.subscribe(new IncludesObserver(o, this._elem, this._n)); - }; - - return IncludesObservable; - }(ObservableBase)); - - var IncludesObserver = (function (__super__) { - inherits(IncludesObserver, __super__); - function IncludesObserver(o, elem, n) { - this._o = o; - this._elem = elem; - this._n = n; - this._i = 0; - __super__.call(this); - } - - function comparer(a, b) { - return (a === 0 && b === 0) || (a === b || (isNaN(a) && isNaN(b))); - } - - IncludesObserver.prototype.next = function (x) { - if (this._i++ >= this._n && comparer(x, this._elem)) { - this._o.onNext(true); - this._o.onCompleted(); - } - }; - IncludesObserver.prototype.error = function (e) { this._o.onError(e); }; - IncludesObserver.prototype.completed = function () { this._o.onNext(false); this._o.onCompleted(); }; - - return IncludesObserver; - }(AbstractObserver)); - - /** - * Determines whether an observable sequence includes a specified element with an optional equality comparer. - * @param searchElement The value to locate in the source sequence. - * @param {Number} [fromIndex] An equality comparer to compare elements. - * @returns {Observable} An observable sequence containing a single element determining whether the source sequence includes an element that has the specified value from the given index. - */ - observableProto.includes = function (searchElement, fromIndex) { - return new IncludesObservable(this, searchElement, fromIndex); - }; - - var CountObservable = (function (__super__) { - inherits(CountObservable, __super__); - function CountObservable(source, fn) { - this.source = source; - this._fn = fn; - __super__.call(this); - } - - CountObservable.prototype.subscribeCore = function (o) { - return this.source.subscribe(new CountObserver(o, this._fn, this.source)); - }; - - return CountObservable; - }(ObservableBase)); - - var CountObserver = (function (__super__) { - inherits(CountObserver, __super__); - - function CountObserver(o, fn, s) { - this._o = o; - this._fn = fn; - this._s = s; - this._i = 0; - this._c = 0; - __super__.call(this); - } - - CountObserver.prototype.next = function (x) { - if (this._fn) { - var result = tryCatch(this._fn)(x, this._i++, this._s); - if (result === errorObj) { return this._o.onError(result.e); } - Boolean(result) && (this._c++); - } else { - this._c++; - } - }; - CountObserver.prototype.error = function (e) { this._o.onError(e); }; - CountObserver.prototype.completed = function () { - this._o.onNext(this._c); - this._o.onCompleted(); - }; - - return CountObserver; - }(AbstractObserver)); - - /** - * Returns an observable sequence containing a value that represents how many elements in the specified observable sequence satisfy a condition if provided, else the count of items. - * @example - * res = source.count(); - * res = source.count(function (x) { return x > 3; }); - * @param {Function} [predicate]A function to test each element for a condition. - * @param {Any} [thisArg] Object to use as this when executing callback. - * @returns {Observable} An observable sequence containing a single element with a number that represents how many elements in the input sequence satisfy the condition in the predicate function if provided, else the count of items in the sequence. - */ - observableProto.count = function (predicate, thisArg) { - var fn = bindCallback(predicate, thisArg, 3); - return new CountObservable(this, fn); - }; - - var IndexOfObservable = (function (__super__) { - inherits(IndexOfObservable, __super__); - function IndexOfObservable(source, e, n) { - this.source = source; - this._e = e; - this._n = n; - __super__.call(this); - } - - IndexOfObservable.prototype.subscribeCore = function (o) { - if (this._n < 0) { - o.onNext(-1); - o.onCompleted(); - return disposableEmpty; - } - - return this.source.subscribe(new IndexOfObserver(o, this._e, this._n)); - }; - - return IndexOfObservable; - }(ObservableBase)); - - var IndexOfObserver = (function (__super__) { - inherits(IndexOfObserver, __super__); - function IndexOfObserver(o, e, n) { - this._o = o; - this._e = e; - this._n = n; - this._i = 0; - __super__.call(this); - } - - IndexOfObserver.prototype.next = function (x) { - if (this._i >= this._n && x === this._e) { - this._o.onNext(this._i); - this._o.onCompleted(); - } - this._i++; - }; - IndexOfObserver.prototype.error = function (e) { this._o.onError(e); }; - IndexOfObserver.prototype.completed = function () { this._o.onNext(-1); this._o.onCompleted(); }; - - return IndexOfObserver; - }(AbstractObserver)); - - /** - * Returns the first index at which a given element can be found in the observable sequence, or -1 if it is not present. - * @param {Any} searchElement Element to locate in the array. - * @param {Number} [fromIndex] The index to start the search. If not specified, defaults to 0. - * @returns {Observable} And observable sequence containing the first index at which a given element can be found in the observable sequence, or -1 if it is not present. - */ - observableProto.indexOf = function(searchElement, fromIndex) { - var n = +fromIndex || 0; - Math.abs(n) === Infinity && (n = 0); - return new IndexOfObservable(this, searchElement, n); - }; - - var SumObservable = (function (__super__) { - inherits(SumObservable, __super__); - function SumObservable(source, fn) { - this.source = source; - this._fn = fn; - __super__.call(this); - } - - SumObservable.prototype.subscribeCore = function (o) { - return this.source.subscribe(new SumObserver(o, this._fn, this.source)); - }; - - return SumObservable; - }(ObservableBase)); - - var SumObserver = (function (__super__) { - inherits(SumObserver, __super__); - - function SumObserver(o, fn, s) { - this._o = o; - this._fn = fn; - this._s = s; - this._i = 0; - this._c = 0; - __super__.call(this); - } - - SumObserver.prototype.next = function (x) { - if (this._fn) { - var result = tryCatch(this._fn)(x, this._i++, this._s); - if (result === errorObj) { return this._o.onError(result.e); } - this._c += result; - } else { - this._c += x; - } - }; - SumObserver.prototype.error = function (e) { this._o.onError(e); }; - SumObserver.prototype.completed = function () { - this._o.onNext(this._c); - this._o.onCompleted(); - }; - - return SumObserver; - }(AbstractObserver)); - - /** - * Computes the sum of a sequence of values that are obtained by invoking an optional transform function on each element of the input sequence, else if not specified computes the sum on each item in the sequence. - * @param {Function} [selector] A transform function to apply to each element. - * @param {Any} [thisArg] Object to use as this when executing callback. - * @returns {Observable} An observable sequence containing a single element with the sum of the values in the source sequence. - */ - observableProto.sum = function (keySelector, thisArg) { - var fn = bindCallback(keySelector, thisArg, 3); - return new SumObservable(this, fn); - }; - - /** - * Returns the elements in an observable sequence with the minimum key value according to the specified comparer. - * @example - * var res = source.minBy(function (x) { return x.value; }); - * var res = source.minBy(function (x) { return x.value; }, function (x, y) { return x - y; }); - * @param {Function} keySelector Key selector function. - * @param {Function} [comparer] Comparer used to compare key values. - * @returns {Observable} An observable sequence containing a list of zero or more elements that have a minimum key value. - */ - observableProto.minBy = function (keySelector, comparer) { - comparer || (comparer = defaultSubComparer); - return new ExtremaByObservable(this, keySelector, function (x, y) { return comparer(x, y) * -1; }); - }; - - /** - * Returns the minimum element in an observable sequence according to the optional comparer else a default greater than less than check. - * @example - * var res = source.min(); - * var res = source.min(function (x, y) { return x.value - y.value; }); - * @param {Function} [comparer] Comparer used to compare elements. - * @returns {Observable} An observable sequence containing a single element with the minimum element in the source sequence. - */ - observableProto.min = function (comparer) { - return this.minBy(identity, comparer).map(firstOnly); - }; - - /** - * Returns the elements in an observable sequence with the maximum key value according to the specified comparer. - * @example - * var res = source.maxBy(function (x) { return x.value; }); - * var res = source.maxBy(function (x) { return x.value; }, function (x, y) { return x - y;; }); - * @param {Function} keySelector Key selector function. - * @param {Function} [comparer] Comparer used to compare key values. - * @returns {Observable} An observable sequence containing a list of zero or more elements that have a maximum key value. - */ - observableProto.maxBy = function (keySelector, comparer) { - comparer || (comparer = defaultSubComparer); - return new ExtremaByObservable(this, keySelector, comparer); - }; - - /** - * Returns the maximum value in an observable sequence according to the specified comparer. - * @example - * var res = source.max(); - * var res = source.max(function (x, y) { return x.value - y.value; }); - * @param {Function} [comparer] Comparer used to compare elements. - * @returns {Observable} An observable sequence containing a single element with the maximum element in the source sequence. - */ - observableProto.max = function (comparer) { - return this.maxBy(identity, comparer).map(firstOnly); - }; - - var AverageObservable = (function (__super__) { - inherits(AverageObservable, __super__); - function AverageObservable(source, fn) { - this.source = source; - this._fn = fn; - __super__.call(this); - } - - AverageObservable.prototype.subscribeCore = function (o) { - return this.source.subscribe(new AverageObserver(o, this._fn, this.source)); - }; - - return AverageObservable; - }(ObservableBase)); - - var AverageObserver = (function(__super__) { - inherits(AverageObserver, __super__); - function AverageObserver(o, fn, s) { - this._o = o; - this._fn = fn; - this._s = s; - this._c = 0; - this._t = 0; - __super__.call(this); - } - - AverageObserver.prototype.next = function (x) { - if(this._fn) { - var r = tryCatch(this._fn)(x, this._c++, this._s); - if (r === errorObj) { return this._o.onError(r.e); } - this._t += r; - } else { - this._c++; - this._t += x; - } - }; - AverageObserver.prototype.error = function (e) { this._o.onError(e); }; - AverageObserver.prototype.completed = function () { - if (this._c === 0) { return this._o.onError(new EmptyError()); } - this._o.onNext(this._t / this._c); - this._o.onCompleted(); - }; - - return AverageObserver; - }(AbstractObserver)); - - /** - * Computes the average of an observable sequence of values that are in the sequence or obtained by invoking a transform function on each element of the input sequence if present. - * @param {Function} [selector] A transform function to apply to each element. - * @param {Any} [thisArg] Object to use as this when executing callback. - * @returns {Observable} An observable sequence containing a single element with the average of the sequence of values. - */ - observableProto.average = function (keySelector, thisArg) { - var source = this, fn; - if (isFunction(keySelector)) { - fn = bindCallback(keySelector, thisArg, 3); - } - return new AverageObservable(source, fn); - }; - - /** - * Determines whether two sequences are equal by comparing the elements pairwise using a specified equality comparer. - * - * @example - * var res = res = source.sequenceEqual([1,2,3]); - * var res = res = source.sequenceEqual([{ value: 42 }], function (x, y) { return x.value === y.value; }); - * 3 - res = source.sequenceEqual(Rx.Observable.returnValue(42)); - * 4 - res = source.sequenceEqual(Rx.Observable.returnValue({ value: 42 }), function (x, y) { return x.value === y.value; }); - * @param {Observable} second Second observable sequence or array to compare. - * @param {Function} [comparer] Comparer used to compare elements of both sequences. - * @returns {Observable} An observable sequence that contains a single element which indicates whether both sequences are of equal length and their corresponding elements are equal according to the specified equality comparer. - */ - observableProto.sequenceEqual = function (second, comparer) { - var first = this; - comparer || (comparer = defaultComparer); - return new AnonymousObservable(function (o) { - var donel = false, doner = false, ql = [], qr = []; - var subscription1 = first.subscribe(function (x) { - if (qr.length > 0) { - var v = qr.shift(); - var equal = tryCatch(comparer)(v, x); - if (equal === errorObj) { return o.onError(equal.e); } - if (!equal) { - o.onNext(false); - o.onCompleted(); - } - } else if (doner) { - o.onNext(false); - o.onCompleted(); - } else { - ql.push(x); - } - }, function(e) { o.onError(e); }, function () { - donel = true; - if (ql.length === 0) { - if (qr.length > 0) { - o.onNext(false); - o.onCompleted(); - } else if (doner) { - o.onNext(true); - o.onCompleted(); - } - } - }); - - (isArrayLike(second) || isIterable(second)) && (second = observableFrom(second)); - isPromise(second) && (second = observableFromPromise(second)); - var subscription2 = second.subscribe(function (x) { - if (ql.length > 0) { - var v = ql.shift(); - var equal = tryCatch(comparer)(v, x); - if (equal === errorObj) { return o.onError(equal.e); } - if (!equal) { - o.onNext(false); - o.onCompleted(); - } - } else if (donel) { - o.onNext(false); - o.onCompleted(); - } else { - qr.push(x); - } - }, function(e) { o.onError(e); }, function () { - doner = true; - if (qr.length === 0) { - if (ql.length > 0) { - o.onNext(false); - o.onCompleted(); - } else if (donel) { - o.onNext(true); - o.onCompleted(); - } - } - }); - return new BinaryDisposable(subscription1, subscription2); - }, first); - }; - - var ElementAtObservable = (function (__super__) { - inherits(ElementAtObservable, __super__); - function ElementAtObservable(source, i, d) { - this.source = source; - this._i = i; - this._d = d; - __super__.call(this); - } - - ElementAtObservable.prototype.subscribeCore = function (o) { - return this.source.subscribe(new ElementAtObserver(o, this._i, this._d)); - }; - - return ElementAtObservable; - }(ObservableBase)); - - var ElementAtObserver = (function (__super__) { - inherits(ElementAtObserver, __super__); - - function ElementAtObserver(o, i, d) { - this._o = o; - this._i = i; - this._d = d; - __super__.call(this); - } - - ElementAtObserver.prototype.next = function (x) { - if (this._i-- === 0) { - this._o.onNext(x); - this._o.onCompleted(); - } - }; - ElementAtObserver.prototype.error = function (e) { this._o.onError(e); }; - ElementAtObserver.prototype.completed = function () { - if (this._d === undefined) { - this._o.onError(new ArgumentOutOfRangeError()); - } else { - this._o.onNext(this._d); - this._o.onCompleted(); - } - }; - - return ElementAtObserver; - }(AbstractObserver)); - - /** - * Returns the element at a specified index in a sequence or default value if not found. - * @param {Number} index The zero-based index of the element to retrieve. - * @param {Any} [defaultValue] The default value to use if elementAt does not find a value. - * @returns {Observable} An observable sequence that produces the element at the specified position in the source sequence. - */ - observableProto.elementAt = function (index, defaultValue) { - if (index < 0) { throw new ArgumentOutOfRangeError(); } - return new ElementAtObservable(this, index, defaultValue); - }; - - var SingleObserver = (function(__super__) { - inherits(SingleObserver, __super__); - function SingleObserver(o, obj, s) { - this._o = o; - this._obj = obj; - this._s = s; - this._i = 0; - this._hv = false; - this._v = null; - __super__.call(this); - } - - SingleObserver.prototype.next = function (x) { - var shouldYield = false; - if (this._obj.predicate) { - var res = tryCatch(this._obj.predicate)(x, this._i++, this._s); - if (res === errorObj) { return this._o.onError(res.e); } - Boolean(res) && (shouldYield = true); - } else if (!this._obj.predicate) { - shouldYield = true; - } - if (shouldYield) { - if (this._hv) { - return this._o.onError(new Error('Sequence contains more than one matching element')); - } - this._hv = true; - this._v = x; - } - }; - SingleObserver.prototype.error = function (e) { this._o.onError(e); }; - SingleObserver.prototype.completed = function () { - if (this._hv) { - this._o.onNext(this._v); - this._o.onCompleted(); - } - else if (this._obj.defaultValue === undefined) { - this._o.onError(new EmptyError()); - } else { - this._o.onNext(this._obj.defaultValue); - this._o.onCompleted(); - } - }; - - return SingleObserver; - }(AbstractObserver)); - - - /** - * Returns the only element of an observable sequence that satisfies the condition in the optional predicate, and reports an exception if there is not exactly one element in the observable sequence. - * @returns {Observable} Sequence containing the single element in the observable sequence that satisfies the condition in the predicate. - */ - observableProto.single = function (predicate, thisArg) { - var obj = {}, source = this; - if (typeof arguments[0] === 'object') { - obj = arguments[0]; - } else { - obj = { - predicate: arguments[0], - thisArg: arguments[1], - defaultValue: arguments[2] - }; - } - if (isFunction (obj.predicate)) { - var fn = obj.predicate; - obj.predicate = bindCallback(fn, obj.thisArg, 3); - } - return new AnonymousObservable(function (o) { - return source.subscribe(new SingleObserver(o, obj, source)); - }, source); - }; - - var FirstObservable = (function (__super__) { - inherits(FirstObservable, __super__); - function FirstObservable(source, obj) { - this.source = source; - this._obj = obj; - __super__.call(this); - } - - FirstObservable.prototype.subscribeCore = function (o) { - return this.source.subscribe(new FirstObserver(o, this._obj, this.source)); - }; - - return FirstObservable; - }(ObservableBase)); - - var FirstObserver = (function(__super__) { - inherits(FirstObserver, __super__); - function FirstObserver(o, obj, s) { - this._o = o; - this._obj = obj; - this._s = s; - this._i = 0; - __super__.call(this); - } - - FirstObserver.prototype.next = function (x) { - if (this._obj.predicate) { - var res = tryCatch(this._obj.predicate)(x, this._i++, this._s); - if (res === errorObj) { return this._o.onError(res.e); } - if (Boolean(res)) { - this._o.onNext(x); - this._o.onCompleted(); - } - } else if (!this._obj.predicate) { - this._o.onNext(x); - this._o.onCompleted(); - } - }; - FirstObserver.prototype.error = function (e) { this._o.onError(e); }; - FirstObserver.prototype.completed = function () { - if (this._obj.defaultValue === undefined) { - this._o.onError(new EmptyError()); - } else { - this._o.onNext(this._obj.defaultValue); - this._o.onCompleted(); - } - }; - - return FirstObserver; - }(AbstractObserver)); - - /** - * Returns the first element of an observable sequence that satisfies the condition in the predicate if present else the first item in the sequence. - * @returns {Observable} Sequence containing the first element in the observable sequence that satisfies the condition in the predicate if provided, else the first item in the sequence. - */ - observableProto.first = function () { - var obj = {}, source = this; - if (typeof arguments[0] === 'object') { - obj = arguments[0]; - } else { - obj = { - predicate: arguments[0], - thisArg: arguments[1], - defaultValue: arguments[2] - }; - } - if (isFunction (obj.predicate)) { - var fn = obj.predicate; - obj.predicate = bindCallback(fn, obj.thisArg, 3); - } - return new FirstObservable(this, obj); - }; - - var LastObservable = (function (__super__) { - inherits(LastObservable, __super__); - function LastObservable(source, obj) { - this.source = source; - this._obj = obj; - __super__.call(this); - } - - LastObservable.prototype.subscribeCore = function (o) { - return this.source.subscribe(new LastObserver(o, this._obj, this.source)); - }; - - return LastObservable; - }(ObservableBase)); - - var LastObserver = (function(__super__) { - inherits(LastObserver, __super__); - function LastObserver(o, obj, s) { - this._o = o; - this._obj = obj; - this._s = s; - this._i = 0; - this._hv = false; - this._v = null; - __super__.call(this); - } - - LastObserver.prototype.next = function (x) { - var shouldYield = false; - if (this._obj.predicate) { - var res = tryCatch(this._obj.predicate)(x, this._i++, this._s); - if (res === errorObj) { return this._o.onError(res.e); } - Boolean(res) && (shouldYield = true); - } else if (!this._obj.predicate) { - shouldYield = true; - } - if (shouldYield) { - this._hv = true; - this._v = x; - } - }; - LastObserver.prototype.error = function (e) { this._o.onError(e); }; - LastObserver.prototype.completed = function () { - if (this._hv) { - this._o.onNext(this._v); - this._o.onCompleted(); - } - else if (this._obj.defaultValue === undefined) { - this._o.onError(new EmptyError()); - } else { - this._o.onNext(this._obj.defaultValue); - this._o.onCompleted(); - } - }; - - return LastObserver; - }(AbstractObserver)); - - /** - * Returns the last element of an observable sequence that satisfies the condition in the predicate if specified, else the last element. - * @returns {Observable} Sequence containing the last element in the observable sequence that satisfies the condition in the predicate. - */ - observableProto.last = function () { - var obj = {}, source = this; - if (typeof arguments[0] === 'object') { - obj = arguments[0]; - } else { - obj = { - predicate: arguments[0], - thisArg: arguments[1], - defaultValue: arguments[2] - }; - } - if (isFunction (obj.predicate)) { - var fn = obj.predicate; - obj.predicate = bindCallback(fn, obj.thisArg, 3); - } - return new LastObservable(this, obj); - }; - - var FindValueObserver = (function(__super__) { - inherits(FindValueObserver, __super__); - function FindValueObserver(observer, source, callback, yieldIndex) { - this._o = observer; - this._s = source; - this._cb = callback; - this._y = yieldIndex; - this._i = 0; - __super__.call(this); - } - - FindValueObserver.prototype.next = function (x) { - var shouldRun = tryCatch(this._cb)(x, this._i, this._s); - if (shouldRun === errorObj) { return this._o.onError(shouldRun.e); } - if (shouldRun) { - this._o.onNext(this._y ? this._i : x); - this._o.onCompleted(); - } else { - this._i++; - } - }; - - FindValueObserver.prototype.error = function (e) { - this._o.onError(e); - }; - - FindValueObserver.prototype.completed = function () { - this._y && this._o.onNext(-1); - this._o.onCompleted(); - }; - - return FindValueObserver; - }(AbstractObserver)); - - function findValue (source, predicate, thisArg, yieldIndex) { - var callback = bindCallback(predicate, thisArg, 3); - return new AnonymousObservable(function (o) { - return source.subscribe(new FindValueObserver(o, source, callback, yieldIndex)); - }, source); - } - - /** - * Searches for an element that matches the conditions defined by the specified predicate, and returns the first occurrence within the entire Observable sequence. - * @param {Function} predicate The predicate that defines the conditions of the element to search for. - * @param {Any} [thisArg] Object to use as `this` when executing the predicate. - * @returns {Observable} An Observable sequence with the first element that matches the conditions defined by the specified predicate, if found; otherwise, undefined. - */ - observableProto.find = function (predicate, thisArg) { - return findValue(this, predicate, thisArg, false); - }; - - /** - * Searches for an element that matches the conditions defined by the specified predicate, and returns - * an Observable sequence with the zero-based index of the first occurrence within the entire Observable sequence. - * @param {Function} predicate The predicate that defines the conditions of the element to search for. - * @param {Any} [thisArg] Object to use as `this` when executing the predicate. - * @returns {Observable} An Observable sequence with the zero-based index of the first occurrence of an element that matches the conditions defined by match, if found; otherwise, –1. - */ - observableProto.findIndex = function (predicate, thisArg) { - return findValue(this, predicate, thisArg, true); - }; - - var ToSetObservable = (function (__super__) { - inherits(ToSetObservable, __super__); - function ToSetObservable(source) { - this.source = source; - __super__.call(this); - } - - ToSetObservable.prototype.subscribeCore = function (o) { - return this.source.subscribe(new ToSetObserver(o)); - }; - - return ToSetObservable; - }(ObservableBase)); - - var ToSetObserver = (function (__super__) { - inherits(ToSetObserver, __super__); - function ToSetObserver(o) { - this._o = o; - this._s = new root.Set(); - __super__.call(this); - } - - ToSetObserver.prototype.next = function (x) { - this._s.add(x); - }; - - ToSetObserver.prototype.error = function (e) { - this._o.onError(e); - }; - - ToSetObserver.prototype.completed = function () { - this._o.onNext(this._s); - this._o.onCompleted(); - }; - - return ToSetObserver; - }(AbstractObserver)); - - /** - * Converts the observable sequence to a Set if it exists. - * @returns {Observable} An observable sequence with a single value of a Set containing the values from the observable sequence. - */ - observableProto.toSet = function () { - if (typeof root.Set === 'undefined') { throw new TypeError(); } - return new ToSetObservable(this); - }; - - var ToMapObservable = (function (__super__) { - inherits(ToMapObservable, __super__); - function ToMapObservable(source, k, e) { - this.source = source; - this._k = k; - this._e = e; - __super__.call(this); - } - - ToMapObservable.prototype.subscribeCore = function (o) { - return this.source.subscribe(new ToMapObserver(o, this._k, this._e)); - }; - - return ToMapObservable; - }(ObservableBase)); - - var ToMapObserver = (function (__super__) { - inherits(ToMapObserver, __super__); - function ToMapObserver(o, k, e) { - this._o = o; - this._k = k; - this._e = e; - this._m = new root.Map(); - __super__.call(this); - } - - ToMapObserver.prototype.next = function (x) { - var key = tryCatch(this._k)(x); - if (key === errorObj) { return this._o.onError(key.e); } - var elem = x; - if (this._e) { - elem = tryCatch(this._e)(x); - if (elem === errorObj) { return this._o.onError(elem.e); } - } - - this._m.set(key, elem); - }; - - ToMapObserver.prototype.error = function (e) { - this._o.onError(e); - }; - - ToMapObserver.prototype.completed = function () { - this._o.onNext(this._m); - this._o.onCompleted(); - }; - - return ToMapObserver; - }(AbstractObserver)); - - /** - * Converts the observable sequence to a Map if it exists. - * @param {Function} keySelector A function which produces the key for the Map. - * @param {Function} [elementSelector] An optional function which produces the element for the Map. If not present, defaults to the value from the observable sequence. - * @returns {Observable} An observable sequence with a single value of a Map containing the values from the observable sequence. - */ - observableProto.toMap = function (keySelector, elementSelector) { - if (typeof root.Map === 'undefined') { throw new TypeError(); } - return new ToMapObservable(this, keySelector, elementSelector); - }; - - var SliceObservable = (function (__super__) { - inherits(SliceObservable, __super__); - function SliceObservable(source, b, e) { - this.source = source; - this._b = b; - this._e = e; - __super__.call(this); - } - - SliceObservable.prototype.subscribeCore = function (o) { - return this.source.subscribe(new SliceObserver(o, this._b, this._e)); - }; - - return SliceObservable; - }(ObservableBase)); - - var SliceObserver = (function (__super__) { - inherits(SliceObserver, __super__); - - function SliceObserver(o, b, e) { - this._o = o; - this._b = b; - this._e = e; - this._i = 0; - __super__.call(this); - } - - SliceObserver.prototype.next = function (x) { - if (this._i >= this._b) { - if (this._e === this._i) { - this._o.onCompleted(); - } else { - this._o.onNext(x); - } - } - this._i++; - }; - SliceObserver.prototype.error = function (e) { this._o.onError(e); }; - SliceObserver.prototype.completed = function () { this._o.onCompleted(); }; - - return SliceObserver; - }(AbstractObserver)); - - /* - * The slice() method returns a shallow copy of a portion of an Observable into a new Observable object. - * Unlike the array version, this does not support negative numbers for being or end. - * @param {Number} [begin] Zero-based index at which to begin extraction. If omitted, this will default to zero. - * @param {Number} [end] Zero-based index at which to end extraction. slice extracts up to but not including end. - * If omitted, this will emit the rest of the Observable object. - * @returns {Observable} A shallow copy of a portion of an Observable into a new Observable object. - */ - observableProto.slice = function (begin, end) { - var start = begin || 0; - if (start < 0) { throw new Rx.ArgumentOutOfRangeError(); } - if (typeof end === 'number' && end < start) { - throw new Rx.ArgumentOutOfRangeError(); - } - return new SliceObservable(this, start, end); - }; - - var LastIndexOfObservable = (function (__super__) { - inherits(LastIndexOfObservable, __super__); - function LastIndexOfObservable(source, e, n) { - this.source = source; - this._e = e; - this._n = n; - __super__.call(this); - } - - LastIndexOfObservable.prototype.subscribeCore = function (o) { - if (this._n < 0) { - o.onNext(-1); - o.onCompleted(); - return disposableEmpty; - } - - return this.source.subscribe(new LastIndexOfObserver(o, this._e, this._n)); - }; - - return LastIndexOfObservable; - }(ObservableBase)); - - var LastIndexOfObserver = (function (__super__) { - inherits(LastIndexOfObserver, __super__); - function LastIndexOfObserver(o, e, n) { - this._o = o; - this._e = e; - this._n = n; - this._v = 0; - this._hv = false; - this._i = 0; - __super__.call(this); - } - - LastIndexOfObserver.prototype.next = function (x) { - if (this._i >= this._n && x === this._e) { - this._hv = true; - this._v = this._i; - } - this._i++; - }; - LastIndexOfObserver.prototype.error = function (e) { this._o.onError(e); }; - LastIndexOfObserver.prototype.completed = function () { - if (this._hv) { - this._o.onNext(this._v); - } else { - this._o.onNext(-1); - } - this._o.onCompleted(); - }; - - return LastIndexOfObserver; - }(AbstractObserver)); - - /** - * Returns the last index at which a given element can be found in the observable sequence, or -1 if it is not present. - * @param {Any} searchElement Element to locate in the array. - * @param {Number} [fromIndex] The index to start the search. If not specified, defaults to 0. - * @returns {Observable} And observable sequence containing the last index at which a given element can be found in the observable sequence, or -1 if it is not present. - */ - observableProto.lastIndexOf = function(searchElement, fromIndex) { - var n = +fromIndex || 0; - Math.abs(n) === Infinity && (n = 0); - return new LastIndexOfObservable(this, searchElement, n); - }; - - return Rx; -})); - - -/***/ }), -/* 6 */ -/***/ (function(module, exports, __webpack_require__) { - -/* module decorator */ module = __webpack_require__.nmd(module); -var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Copyright (c) Microsoft, All rights reserved. See License.txt in the project root for license information. - -;(function (factory) { - var objectTypes = { - 'function': true, - 'object': true - }; - - function checkGlobal(value) { - return (value && value.Object === Object) ? value : null; - } - - var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType) ? exports : null; - var freeModule = (objectTypes["object"] && module && !module.nodeType) ? module : null; - var freeGlobal = checkGlobal(freeExports && freeModule && typeof global === 'object' && global); - var freeSelf = checkGlobal(objectTypes[typeof self] && self); - var freeWindow = checkGlobal(objectTypes[typeof window] && window); - var moduleExports = (freeModule && freeModule.exports === freeExports) ? freeExports : null; - var thisGlobal = checkGlobal(objectTypes[typeof this] && this); - var root = freeGlobal || ((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) || freeSelf || thisGlobal || Function('return this')(); - - // Because of build optimizers - if (true) { - !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(7), exports], __WEBPACK_AMD_DEFINE_RESULT__ = (function (Rx, exports) { - root.Rx = factory(root, exports, Rx); - return root.Rx; - }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), - __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); - } else {} -}.call(this, function (root, exp, Rx, undefined) { - - // Aliases - var Observable = Rx.Observable, - observableFromPromise = Observable.fromPromise, - observableThrow = Observable.throwError, - AnonymousObservable = Rx.AnonymousObservable, - ObservableBase = Rx.ObservableBase, - AsyncSubject = Rx.AsyncSubject, - disposableCreate = Rx.Disposable.create, - CompositeDisposable = Rx.CompositeDisposable, - immediateScheduler = Rx.Scheduler.immediate, - defaultScheduler = Rx.Scheduler['default'], - inherits = Rx.internals.inherits, - isScheduler = Rx.Scheduler.isScheduler, - isPromise = Rx.helpers.isPromise, - isFunction = Rx.helpers.isFunction, - isIterable = Rx.helpers.isIterable, - isArrayLike = Rx.helpers.isArrayLike; - - var errorObj = {e: {}}; - - function tryCatcherGen(tryCatchTarget) { - return function tryCatcher() { - try { - return tryCatchTarget.apply(this, arguments); - } catch (e) { - errorObj.e = e; - return errorObj; - } - }; - } - - var tryCatch = Rx.internals.tryCatch = function tryCatch(fn) { - if (!isFunction(fn)) { throw new TypeError('fn must be a function'); } - return tryCatcherGen(fn); - }; - - function thrower(e) { - throw e; - } - - Observable.wrap = function (fn) { - function createObservable() { - return Observable.spawn.call(this, fn.apply(this, arguments)); - } - - createObservable.__generatorFunction__ = fn; - return createObservable; - }; - - var spawn = Observable.spawn = function () { - var gen = arguments[0], self = this, args = []; - for (var i = 1, len = arguments.length; i < len; i++) { args.push(arguments[i]); } - - return new AnonymousObservable(function (o) { - var g = new CompositeDisposable(); - - if (isFunction(gen)) { gen = gen.apply(self, args); } - if (!gen || !isFunction(gen.next)) { - o.onNext(gen); - return o.onCompleted(); - } - - function processGenerator(res) { - var ret = tryCatch(gen.next).call(gen, res); - if (ret === errorObj) { return o.onError(ret.e); } - next(ret); - } - - processGenerator(); - - function onError(err) { - var ret = tryCatch(gen.next).call(gen, err); - if (ret === errorObj) { return o.onError(ret.e); } - next(ret); - } - - function next(ret) { - if (ret.done) { - o.onNext(ret.value); - o.onCompleted(); - return; - } - var obs = toObservable.call(self, ret.value); - var value = null; - var hasValue = false; - if (Observable.isObservable(obs)) { - g.add(obs.subscribe(function(val) { - hasValue = true; - value = val; - }, onError, function() { - hasValue && processGenerator(value); - })); - } else { - onError(new TypeError('type not supported')); - } - } - - return g; - }); - }; - - function toObservable(obj) { - if (!obj) { return obj; } - if (Observable.isObservable(obj)) { return obj; } - if (isPromise(obj)) { return Observable.fromPromise(obj); } - if (isGeneratorFunction(obj) || isGenerator(obj)) { return spawn.call(this, obj); } - if (isFunction(obj)) { return thunkToObservable.call(this, obj); } - if (isArrayLike(obj) || isIterable(obj)) { return arrayToObservable.call(this, obj); } - if (isObject(obj)) {return objectToObservable.call(this, obj);} - return obj; - } - - function arrayToObservable (obj) { - return Observable.from(obj).concatMap(function(o) { - if(Observable.isObservable(o) || isObject(o)) { - return toObservable.call(null, o); - } else { - return Rx.Observable.just(o); - } - }).toArray(); - } - - function objectToObservable (obj) { - var results = new obj.constructor(), keys = Object.keys(obj), observables = []; - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i]; - var observable = toObservable.call(this, obj[key]); - - if(observable && Observable.isObservable(observable)) { - defer(observable, key); - } else { - results[key] = obj[key]; - } - } - - return Observable.forkJoin.apply(Observable, observables).map(function() { - return results; - }); - - - function defer (observable, key) { - results[key] = undefined; - observables.push(observable.map(function (next) { - results[key] = next; - })); - } - } - - function thunkToObservable(fn) { - var self = this; - return new AnonymousObservable(function (o) { - fn.call(self, function () { - var err = arguments[0], res = arguments[1]; - if (err) { return o.onError(err); } - if (arguments.length > 2) { - var args = []; - for (var i = 1, len = arguments.length; i < len; i++) { args.push(arguments[i]); } - res = args; - } - o.onNext(res); - o.onCompleted(); - }); - }); - } - - function isGenerator(obj) { - return isFunction (obj.next) && isFunction (obj['throw']); - } - - function isGeneratorFunction(obj) { - var ctor = obj.constructor; - if (!ctor) { return false; } - if (ctor.name === 'GeneratorFunction' || ctor.displayName === 'GeneratorFunction') { return true; } - return isGenerator(ctor.prototype); - } - - function isObject(val) { - return Object == val.constructor; - } - - /** - * Invokes the specified function asynchronously on the specified scheduler, surfacing the result through an observable sequence. - * - * @example - * var res = Rx.Observable.start(function () { console.log('hello'); }); - * var res = Rx.Observable.start(function () { console.log('hello'); }, Rx.Scheduler.timeout); - * var res = Rx.Observable.start(function () { this.log('hello'); }, Rx.Scheduler.timeout, console); - * - * @param {Function} func Function to run asynchronously. - * @param {Scheduler} [scheduler] Scheduler to run the function on. If not specified, defaults to Scheduler.timeout. - * @param [context] The context for the func parameter to be executed. If not specified, defaults to undefined. - * @returns {Observable} An observable sequence exposing the function's result value, or an exception. - * - * Remarks - * * The function is called immediately, not during the subscription of the resulting sequence. - * * Multiple subscriptions to the resulting sequence can observe the function's result. - */ - Observable.start = function (func, context, scheduler) { - return observableToAsync(func, context, scheduler)(); - }; - - /** - * Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler. - * @param {Function} function Function to convert to an asynchronous function. - * @param {Scheduler} [scheduler] Scheduler to run the function on. If not specified, defaults to Scheduler.timeout. - * @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined. - * @returns {Function} Asynchronous function. - */ - var observableToAsync = Observable.toAsync = function (func, context, scheduler) { - isScheduler(scheduler) || (scheduler = defaultScheduler); - return function () { - var args = arguments, - subject = new AsyncSubject(); - - scheduler.schedule(null, function () { - var result; - try { - result = func.apply(context, args); - } catch (e) { - subject.onError(e); - return; - } - subject.onNext(result); - subject.onCompleted(); - }); - return subject.asObservable(); - }; - }; - -function createCbObservable(fn, ctx, selector, args) { - var o = new AsyncSubject(); - - args.push(createCbHandler(o, ctx, selector)); - fn.apply(ctx, args); - - return o.asObservable(); -} - -function createCbHandler(o, ctx, selector) { - return function handler () { - var len = arguments.length, results = new Array(len); - for(var i = 0; i < len; i++) { results[i] = arguments[i]; } - - if (isFunction(selector)) { - results = tryCatch(selector).apply(ctx, results); - if (results === errorObj) { return o.onError(results.e); } - o.onNext(results); - } else { - if (results.length <= 1) { - o.onNext(results[0]); - } else { - o.onNext(results); - } - } - - o.onCompleted(); - }; -} - -/** - * Converts a callback function to an observable sequence. - * - * @param {Function} fn Function with a callback as the last parameter to convert to an Observable sequence. - * @param {Mixed} [ctx] The context for the func parameter to be executed. If not specified, defaults to undefined. - * @param {Function} [selector] A selector which takes the arguments from the callback to produce a single item to yield on next. - * @returns {Function} A function, when executed with the required parameters minus the callback, produces an Observable sequence with a single value of the arguments to the callback as an array. - */ -Observable.fromCallback = function (fn, ctx, selector) { - return function () { - typeof ctx === 'undefined' && (ctx = this); - - var len = arguments.length, args = new Array(len) - for(var i = 0; i < len; i++) { args[i] = arguments[i]; } - return createCbObservable(fn, ctx, selector, args); - }; -}; - -function createNodeObservable(fn, ctx, selector, args) { - var o = new AsyncSubject(); - - args.push(createNodeHandler(o, ctx, selector)); - fn.apply(ctx, args); - - return o.asObservable(); -} - -function createNodeHandler(o, ctx, selector) { - return function handler () { - var err = arguments[0]; - if (err) { return o.onError(err); } - - var len = arguments.length, results = []; - for(var i = 1; i < len; i++) { results[i - 1] = arguments[i]; } - - if (isFunction(selector)) { - var results = tryCatch(selector).apply(ctx, results); - if (results === errorObj) { return o.onError(results.e); } - o.onNext(results); - } else { - if (results.length <= 1) { - o.onNext(results[0]); - } else { - o.onNext(results); - } - } - - o.onCompleted(); - }; -} - -/** - * Converts a Node.js callback style function to an observable sequence. This must be in function (err, ...) format. - * @param {Function} fn The function to call - * @param {Mixed} [ctx] The context for the func parameter to be executed. If not specified, defaults to undefined. - * @param {Function} [selector] A selector which takes the arguments from the callback minus the error to produce a single item to yield on next. - * @returns {Function} An async function which when applied, returns an observable sequence with the callback arguments as an array. - */ -Observable.fromNodeCallback = function (fn, ctx, selector) { - return function () { - typeof ctx === 'undefined' && (ctx = this); - var len = arguments.length, args = new Array(len); - for(var i = 0; i < len; i++) { args[i] = arguments[i]; } - return createNodeObservable(fn, ctx, selector, args); - }; -}; - - function isNodeList(el) { - if (root.StaticNodeList) { - // IE8 Specific - // instanceof is slower than Object#toString, but Object#toString will not work as intended in IE8 - return el instanceof root.StaticNodeList || el instanceof root.NodeList; - } else { - return Object.prototype.toString.call(el) === '[object NodeList]'; - } - } - - function ListenDisposable(e, n, fn) { - this._e = e; - this._n = n; - this._fn = fn; - this._e.addEventListener(this._n, this._fn, false); - this.isDisposed = false; - } - ListenDisposable.prototype.dispose = function () { - if (!this.isDisposed) { - this._e.removeEventListener(this._n, this._fn, false); - this.isDisposed = true; - } - }; - - function createEventListener (el, eventName, handler) { - var disposables = new CompositeDisposable(); - - // Asume NodeList or HTMLCollection - var elemToString = Object.prototype.toString.call(el); - if (isNodeList(el) || elemToString === '[object HTMLCollection]') { - for (var i = 0, len = el.length; i < len; i++) { - disposables.add(createEventListener(el.item(i), eventName, handler)); - } - } else if (el) { - disposables.add(new ListenDisposable(el, eventName, handler)); - } - - return disposables; - } - - /** - * Configuration option to determine whether to use native events only - */ - Rx.config.useNativeEvents = false; - - var EventObservable = (function(__super__) { - inherits(EventObservable, __super__); - function EventObservable(el, name, fn) { - this._el = el; - this._n = name; - this._fn = fn; - __super__.call(this); - } - - function createHandler(o, fn) { - return function handler () { - var results = arguments[0]; - if (isFunction(fn)) { - results = tryCatch(fn).apply(null, arguments); - if (results === errorObj) { return o.onError(results.e); } - } - o.onNext(results); - }; - } - - EventObservable.prototype.subscribeCore = function (o) { - return createEventListener( - this._el, - this._n, - createHandler(o, this._fn)); - }; - - return EventObservable; - }(ObservableBase)); - - /** - * Creates an observable sequence by adding an event listener to the matching DOMElement or each item in the NodeList. - * @param {Object} element The DOMElement or NodeList to attach a listener. - * @param {String} eventName The event name to attach the observable sequence. - * @param {Function} [selector] A selector which takes the arguments from the event handler to produce a single item to yield on next. - * @returns {Observable} An observable sequence of events from the specified element and the specified event. - */ - Observable.fromEvent = function (element, eventName, selector) { - // Node.js specific - if (element.addListener) { - return fromEventPattern( - function (h) { element.addListener(eventName, h); }, - function (h) { element.removeListener(eventName, h); }, - selector); - } - - // Use only if non-native events are allowed - if (!Rx.config.useNativeEvents) { - // Handles jq, Angular.js, Zepto, Marionette, Ember.js - if (typeof element.on === 'function' && typeof element.off === 'function') { - return fromEventPattern( - function (h) { element.on(eventName, h); }, - function (h) { element.off(eventName, h); }, - selector); - } - } - - return new EventObservable(element, eventName, selector).publish().refCount(); - }; - - var EventPatternObservable = (function(__super__) { - inherits(EventPatternObservable, __super__); - function EventPatternObservable(add, del, fn) { - this._add = add; - this._del = del; - this._fn = fn; - __super__.call(this); - } - - function createHandler(o, fn) { - return function handler () { - var results = arguments[0]; - if (isFunction(fn)) { - results = tryCatch(fn).apply(null, arguments); - if (results === errorObj) { return o.onError(results.e); } - } - o.onNext(results); - }; - } - - EventPatternObservable.prototype.subscribeCore = function (o) { - var fn = createHandler(o, this._fn); - var returnValue = this._add(fn); - return new EventPatternDisposable(this._del, fn, returnValue); - }; - - function EventPatternDisposable(del, fn, ret) { - this._del = del; - this._fn = fn; - this._ret = ret; - this.isDisposed = false; - } - - EventPatternDisposable.prototype.dispose = function () { - if(!this.isDisposed) { - isFunction(this._del) && this._del(this._fn, this._ret); - this.isDisposed = true; - } - }; - - return EventPatternObservable; - }(ObservableBase)); - - /** - * Creates an observable sequence from an event emitter via an addHandler/removeHandler pair. - * @param {Function} addHandler The function to add a handler to the emitter. - * @param {Function} [removeHandler] The optional function to remove a handler from an emitter. - * @param {Function} [selector] A selector which takes the arguments from the event handler to produce a single item to yield on next. - * @returns {Observable} An observable sequence which wraps an event from an event emitter - */ - var fromEventPattern = Observable.fromEventPattern = function (addHandler, removeHandler, selector) { - return new EventPatternObservable(addHandler, removeHandler, selector).publish().refCount(); - }; - - /** - * Invokes the asynchronous function, surfacing the result through an observable sequence. - * @param {Function} functionAsync Asynchronous function which returns a Promise to run. - * @returns {Observable} An observable sequence exposing the function's result value, or an exception. - */ - Observable.startAsync = function (functionAsync) { - var promise = tryCatch(functionAsync)(); - if (promise === errorObj) { return observableThrow(promise.e); } - return observableFromPromise(promise); - }; - - return Rx; -})); - - -/***/ }), -/* 7 */ -/***/ (function(module, exports, __webpack_require__) { - -/* module decorator */ module = __webpack_require__.nmd(module); -var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Copyright (c) Microsoft, All rights reserved. See License.txt in the project root for license information. - -;(function (factory) { - var objectTypes = { - 'function': true, - 'object': true - }; - - function checkGlobal(value) { - return (value && value.Object === Object) ? value : null; - } - - var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType) ? exports : null; - var freeModule = (objectTypes["object"] && module && !module.nodeType) ? module : null; - var freeGlobal = checkGlobal(freeExports && freeModule && typeof global === 'object' && global); - var freeSelf = checkGlobal(objectTypes[typeof self] && self); - var freeWindow = checkGlobal(objectTypes[typeof window] && window); - var moduleExports = (freeModule && freeModule.exports === freeExports) ? freeExports : null; - var thisGlobal = checkGlobal(objectTypes[typeof this] && this); - var root = freeGlobal || ((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) || freeSelf || thisGlobal || Function('return this')(); - - // Because of build optimizers - if (true) { - !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(4)], __WEBPACK_AMD_DEFINE_RESULT__ = (function (Rx, exports) { - return factory(root, exports, Rx); - }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), - __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); - } else {} -}.call(this, function (root, exp, Rx, undefined) { - - var Observable = Rx.Observable, - observableProto = Observable.prototype, - AnonymousObservable = Rx.AnonymousObservable, - ObservableBase = Rx.ObservableBase, - Subject = Rx.Subject, - AsyncSubject = Rx.AsyncSubject, - Observer = Rx.Observer, - ScheduledObserver = Rx.internals.ScheduledObserver, - disposableCreate = Rx.Disposable.create, - disposableEmpty = Rx.Disposable.empty, - BinaryDisposable = Rx.BinaryDisposable, - currentThreadScheduler = Rx.Scheduler.currentThread, - isFunction = Rx.helpers.isFunction, - inherits = Rx.internals.inherits, - addProperties = Rx.internals.addProperties, - checkDisposed = Rx.Disposable.checkDisposed; - - // Utilities - function cloneArray(arr) { - var len = arr.length, a = new Array(len); - for(var i = 0; i < len; i++) { a[i] = arr[i]; } - return a; - } - - var MulticastObservable = (function (__super__) { - inherits(MulticastObservable, __super__); - function MulticastObservable(source, fn1, fn2) { - this.source = source; - this._fn1 = fn1; - this._fn2 = fn2; - __super__.call(this); - } - - MulticastObservable.prototype.subscribeCore = function (o) { - var connectable = this.source.multicast(this._fn1()); - return new BinaryDisposable(this._fn2(connectable).subscribe(o), connectable.connect()); - }; - - return MulticastObservable; - }(ObservableBase)); - - /** - * Multicasts the source sequence notifications through an instantiated subject into all uses of the sequence within a selector function. Each - * subscription to the resulting sequence causes a separate multicast invocation, exposing the sequence resulting from the selector function's - * invocation. For specializations with fixed subject types, see Publish, PublishLast, and Replay. - * - * @example - * 1 - res = source.multicast(observable); - * 2 - res = source.multicast(function () { return new Subject(); }, function (x) { return x; }); - * - * @param {Function|Subject} subjectOrSubjectSelector - * Factory function to create an intermediate subject through which the source sequence's elements will be multicast to the selector function. - * Or: - * Subject to push source elements into. - * - * @param {Function} [selector] Optional selector function which can use the multicasted source sequence subject to the policies enforced by the created subject. Specified only if 0; }, - /** - * Notifies all subscribed observers about the end of the sequence. - */ - onCompleted: function () { - checkDisposed(this); - if (this.isStopped) { return; } - this.isStopped = true; - for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { - os[i].onCompleted(); - } - - this.observers.length = 0; - }, - /** - * Notifies all subscribed observers about the exception. - * @param {Mixed} error The exception to send to all observers. - */ - onError: function (error) { - checkDisposed(this); - if (this.isStopped) { return; } - this.isStopped = true; - this.hasError = true; - this.error = error; - - for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { - os[i].onError(error); - } - - this.observers.length = 0; - }, - /** - * Notifies all subscribed observers about the arrival of the specified element in the sequence. - * @param {Mixed} value The value to send to all observers. - */ - onNext: function (value) { - checkDisposed(this); - if (this.isStopped) { return; } - this.value = value; - for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { - os[i].onNext(value); - } - }, - /** - * Unsubscribe all observers and release resources. - */ - dispose: function () { - this.isDisposed = true; - this.observers = null; - this.value = null; - this.error = null; - } - }); - - return BehaviorSubject; - }(Observable)); - - /** - * Represents an object that is both an observable sequence as well as an observer. - * Each notification is broadcasted to all subscribed and future observers, subject to buffer trimming policies. - */ - var ReplaySubject = Rx.ReplaySubject = (function (__super__) { - - var maxSafeInteger = Math.pow(2, 53) - 1; - - function createRemovableDisposable(subject, observer) { - return disposableCreate(function () { - observer.dispose(); - !subject.isDisposed && subject.observers.splice(subject.observers.indexOf(observer), 1); - }); - } - - inherits(ReplaySubject, __super__); - - /** - * Initializes a new instance of the ReplaySubject class with the specified buffer size, window size and scheduler. - * @param {Number} [bufferSize] Maximum element count of the replay buffer. - * @param {Number} [windowSize] Maximum time length of the replay buffer. - * @param {Scheduler} [scheduler] Scheduler the observers are invoked on. - */ - function ReplaySubject(bufferSize, windowSize, scheduler) { - this.bufferSize = bufferSize == null ? maxSafeInteger : bufferSize; - this.windowSize = windowSize == null ? maxSafeInteger : windowSize; - this.scheduler = scheduler || currentThreadScheduler; - this.q = []; - this.observers = []; - this.isStopped = false; - this.isDisposed = false; - this.hasError = false; - this.error = null; - __super__.call(this); - } - - addProperties(ReplaySubject.prototype, Observer.prototype, { - _subscribe: function (o) { - checkDisposed(this); - var so = new ScheduledObserver(this.scheduler, o), subscription = createRemovableDisposable(this, so); - - this._trim(this.scheduler.now()); - this.observers.push(so); - - for (var i = 0, len = this.q.length; i < len; i++) { - so.onNext(this.q[i].value); - } - - if (this.hasError) { - so.onError(this.error); - } else if (this.isStopped) { - so.onCompleted(); - } - - so.ensureActive(); - return subscription; - }, - /** - * Indicates whether the subject has observers subscribed to it. - * @returns {Boolean} Indicates whether the subject has observers subscribed to it. - */ - hasObservers: function () { checkDisposed(this); return this.observers.length > 0; }, - _trim: function (now) { - while (this.q.length > this.bufferSize) { - this.q.shift(); - } - while (this.q.length > 0 && (now - this.q[0].interval) > this.windowSize) { - this.q.shift(); - } - }, - /** - * Notifies all subscribed observers about the arrival of the specified element in the sequence. - * @param {Mixed} value The value to send to all observers. - */ - onNext: function (value) { - checkDisposed(this); - if (this.isStopped) { return; } - var now = this.scheduler.now(); - this.q.push({ interval: now, value: value }); - this._trim(now); - - for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { - var observer = os[i]; - observer.onNext(value); - observer.ensureActive(); - } - }, - /** - * Notifies all subscribed observers about the exception. - * @param {Mixed} error The exception to send to all observers. - */ - onError: function (error) { - checkDisposed(this); - if (this.isStopped) { return; } - this.isStopped = true; - this.error = error; - this.hasError = true; - var now = this.scheduler.now(); - this._trim(now); - for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { - var observer = os[i]; - observer.onError(error); - observer.ensureActive(); - } - this.observers.length = 0; - }, - /** - * Notifies all subscribed observers about the end of the sequence. - */ - onCompleted: function () { - checkDisposed(this); - if (this.isStopped) { return; } - this.isStopped = true; - var now = this.scheduler.now(); - this._trim(now); - for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) { - var observer = os[i]; - observer.onCompleted(); - observer.ensureActive(); - } - this.observers.length = 0; - }, - /** - * Unsubscribe all observers and release resources. - */ - dispose: function () { - this.isDisposed = true; - this.observers = null; - } - }); - - return ReplaySubject; - }(Observable)); - - var RefCountObservable = (function (__super__) { - inherits(RefCountObservable, __super__); - function RefCountObservable(source) { - this.source = source; - this._count = 0; - this._connectableSubscription = null; - __super__.call(this); - } - - RefCountObservable.prototype.subscribeCore = function (o) { - var subscription = this.source.subscribe(o); - ++this._count === 1 && (this._connectableSubscription = this.source.connect()); - return new RefCountDisposable(this, subscription); - }; - - function RefCountDisposable(p, s) { - this._p = p; - this._s = s; - this.isDisposed = false; - } - - RefCountDisposable.prototype.dispose = function () { - if (!this.isDisposed) { - this.isDisposed = true; - this._s.dispose(); - --this._p._count === 0 && this._p._connectableSubscription.dispose(); - } - }; - - return RefCountObservable; - }(ObservableBase)); - - var ConnectableObservable = Rx.ConnectableObservable = (function (__super__) { - inherits(ConnectableObservable, __super__); - function ConnectableObservable(source, subject) { - this.source = source; - this._connection = null; - this._source = source.asObservable(); - this._subject = subject; - __super__.call(this); - } - - function ConnectDisposable(parent, subscription) { - this._p = parent; - this._s = subscription; - } - - ConnectDisposable.prototype.dispose = function () { - if (this._s) { - this._s.dispose(); - this._s = null; - this._p._connection = null; - } - }; - - ConnectableObservable.prototype.connect = function () { - if (!this._connection) { - if (this._subject.isStopped) { - return disposableEmpty; - } - var subscription = this._source.subscribe(this._subject); - this._connection = new ConnectDisposable(this, subscription); - } - return this._connection; - }; - - ConnectableObservable.prototype._subscribe = function (o) { - return this._subject.subscribe(o); - }; - - ConnectableObservable.prototype.refCount = function () { - return new RefCountObservable(this); - }; - - return ConnectableObservable; - }(Observable)); - - /** - * Returns an observable sequence that shares a single subscription to the underlying sequence. This observable sequence - * can be resubscribed to, even if all prior subscriptions have ended. (unlike `.publish().refCount()`) - * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source. - */ - observableProto.singleInstance = function() { - var source = this, hasObservable = false, observable; - - function getObservable() { - if (!hasObservable) { - hasObservable = true; - observable = source['finally'](function() { hasObservable = false; }).publish().refCount(); - } - return observable; - } - - return new AnonymousObservable(function(o) { - return getObservable().subscribe(o); - }); - }; - - return Rx; -})); - - -/***/ }), -/* 8 */ -/***/ (function(module, exports, __webpack_require__) { - -/* module decorator */ module = __webpack_require__.nmd(module); -var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Copyright (c) Microsoft, All rights reserved. See License.txt in the project root for license information. - -;(function (factory) { - var objectTypes = { - 'function': true, - 'object': true - }; - - function checkGlobal(value) { - return (value && value.Object === Object) ? value : null; - } - - var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType) ? exports : null; - var freeModule = (objectTypes["object"] && module && !module.nodeType) ? module : null; - var freeGlobal = checkGlobal(freeExports && freeModule && typeof global === 'object' && global); - var freeSelf = checkGlobal(objectTypes[typeof self] && self); - var freeWindow = checkGlobal(objectTypes[typeof window] && window); - var moduleExports = (freeModule && freeModule.exports === freeExports) ? freeExports : null; - var thisGlobal = checkGlobal(objectTypes[typeof this] && this); - var root = freeGlobal || ((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) || freeSelf || thisGlobal || Function('return this')(); - - // Because of build optimizers - if (true) { - !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(4)], __WEBPACK_AMD_DEFINE_RESULT__ = (function (Rx, exports) { - return factory(root, exports, Rx); - }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), - __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); - } else {} -}.call(this, function (root, exp, Rx, undefined) { - - // References - var Observable = Rx.Observable, - observableProto = Observable.prototype, - AnonymousObservable = Rx.AnonymousObservable, - AbstractObserver = Rx.internals.AbstractObserver, - CompositeDisposable = Rx.CompositeDisposable, - BinaryDisposable = Rx.BinaryDisposable, - NAryDisposable = Rx.NAryDisposable, - Notification = Rx.Notification, - Subject = Rx.Subject, - Observer = Rx.Observer, - disposableEmpty = Rx.Disposable.empty, - disposableCreate = Rx.Disposable.create, - inherits = Rx.internals.inherits, - addProperties = Rx.internals.addProperties, - defaultScheduler = Rx.Scheduler['default'], - currentThreadScheduler = Rx.Scheduler.currentThread, - identity = Rx.helpers.identity, - isScheduler = Rx.Scheduler.isScheduler, - isFunction = Rx.helpers.isFunction, - checkDisposed = Rx.Disposable.checkDisposed; - - var errorObj = {e: {}}; - - function tryCatcherGen(tryCatchTarget) { - return function tryCatcher() { - try { - return tryCatchTarget.apply(this, arguments); - } catch (e) { - errorObj.e = e; - return errorObj; - } - }; - } - - var tryCatch = Rx.internals.tryCatch = function tryCatch(fn) { - if (!isFunction(fn)) { throw new TypeError('fn must be a function'); } - return tryCatcherGen(fn); - }; - - function thrower(e) { - throw e; - } - - /** - * Used to pause and resume streams. - */ - Rx.Pauser = (function (__super__) { - inherits(Pauser, __super__); - function Pauser() { - __super__.call(this); - } - - /** - * Pauses the underlying sequence. - */ - Pauser.prototype.pause = function () { this.onNext(false); }; - - /** - * Resumes the underlying sequence. - */ - Pauser.prototype.resume = function () { this.onNext(true); }; - - return Pauser; - }(Subject)); - - var PausableObservable = (function (__super__) { - inherits(PausableObservable, __super__); - function PausableObservable(source, pauser) { - this.source = source; - this.controller = new Subject(); - this.paused = true; - - if (pauser && pauser.subscribe) { - this.pauser = this.controller.merge(pauser); - } else { - this.pauser = this.controller; - } - - __super__.call(this); - } - - PausableObservable.prototype._subscribe = function (o) { - var conn = this.source.publish(), - subscription = conn.subscribe(o), - connection = disposableEmpty; - - var pausable = this.pauser.startWith(!this.paused).distinctUntilChanged().subscribe(function (b) { - if (b) { - connection = conn.connect(); - } else { - connection.dispose(); - connection = disposableEmpty; - } - }); - - return new NAryDisposable([subscription, connection, pausable]); - }; - - PausableObservable.prototype.pause = function () { - this.paused = true; - this.controller.onNext(false); - }; - - PausableObservable.prototype.resume = function () { - this.paused = false; - this.controller.onNext(true); - }; - - return PausableObservable; - - }(Observable)); - - /** - * Pauses the underlying observable sequence based upon the observable sequence which yields true/false. - * @example - * var pauser = new Rx.Subject(); - * var source = Rx.Observable.interval(100).pausable(pauser); - * @param {Observable} pauser The observable sequence used to pause the underlying sequence. - * @returns {Observable} The observable sequence which is paused based upon the pauser. - */ - observableProto.pausable = function (pauser) { - return new PausableObservable(this, pauser); - }; - - function combineLatestSource(source, subject, resultSelector) { - return new AnonymousObservable(function (o) { - var hasValue = [false, false], - hasValueAll = false, - isDone = false, - values = new Array(2), - err; - - function next(x, i) { - values[i] = x; - hasValue[i] = true; - if (hasValueAll || (hasValueAll = hasValue.every(identity))) { - if (err) { return o.onError(err); } - var res = tryCatch(resultSelector).apply(null, values); - if (res === errorObj) { return o.onError(res.e); } - o.onNext(res); - } - isDone && values[1] && o.onCompleted(); - } - - return new BinaryDisposable( - source.subscribe( - function (x) { - next(x, 0); - }, - function (e) { - if (values[1]) { - o.onError(e); - } else { - err = e; - } - }, - function () { - isDone = true; - values[1] && o.onCompleted(); - }), - subject.subscribe( - function (x) { - next(x, 1); - }, - function (e) { o.onError(e); }, - function () { - isDone = true; - next(true, 1); - }) - ); - }, source); - } - - var PausableBufferedObservable = (function (__super__) { - inherits(PausableBufferedObservable, __super__); - function PausableBufferedObservable(source, pauser) { - this.source = source; - this.controller = new Subject(); - this.paused = true; - - if (pauser && pauser.subscribe) { - this.pauser = this.controller.merge(pauser); - } else { - this.pauser = this.controller; - } - - __super__.call(this); - } - - PausableBufferedObservable.prototype._subscribe = function (o) { - var q = [], previousShouldFire; - - function drainQueue() { while (q.length > 0) { o.onNext(q.shift()); } } - - var subscription = - combineLatestSource( - this.source, - this.pauser.startWith(!this.paused).distinctUntilChanged(), - function (data, shouldFire) { - return { data: data, shouldFire: shouldFire }; - }) - .subscribe( - function (results) { - if (previousShouldFire !== undefined && results.shouldFire !== previousShouldFire) { - previousShouldFire = results.shouldFire; - // change in shouldFire - if (results.shouldFire) { drainQueue(); } - } else { - previousShouldFire = results.shouldFire; - // new data - if (results.shouldFire) { - o.onNext(results.data); - } else { - q.push(results.data); - } - } - }, - function (err) { - drainQueue(); - o.onError(err); - }, - function () { - drainQueue(); - o.onCompleted(); - } - ); - return subscription; - }; - - PausableBufferedObservable.prototype.pause = function () { - this.paused = true; - this.controller.onNext(false); - }; - - PausableBufferedObservable.prototype.resume = function () { - this.paused = false; - this.controller.onNext(true); - }; - - return PausableBufferedObservable; - - }(Observable)); - - /** - * Pauses the underlying observable sequence based upon the observable sequence which yields true/false, - * and yields the values that were buffered while paused. - * @example - * var pauser = new Rx.Subject(); - * var source = Rx.Observable.interval(100).pausableBuffered(pauser); - * @param {Observable} pauser The observable sequence used to pause the underlying sequence. - * @returns {Observable} The observable sequence which is paused based upon the pauser. - */ - observableProto.pausableBuffered = function (pauser) { - return new PausableBufferedObservable(this, pauser); - }; - - var ControlledObservable = (function (__super__) { - inherits(ControlledObservable, __super__); - function ControlledObservable (source, enableQueue, scheduler) { - __super__.call(this); - this.subject = new ControlledSubject(enableQueue, scheduler); - this.source = source.multicast(this.subject).refCount(); - } - - ControlledObservable.prototype._subscribe = function (o) { - return this.source.subscribe(o); - }; - - ControlledObservable.prototype.request = function (numberOfItems) { - return this.subject.request(numberOfItems == null ? -1 : numberOfItems); - }; - - return ControlledObservable; - - }(Observable)); - - var ControlledSubject = (function (__super__) { - inherits(ControlledSubject, __super__); - function ControlledSubject(enableQueue, scheduler) { - enableQueue == null && (enableQueue = true); - - __super__.call(this); - this.subject = new Subject(); - this.enableQueue = enableQueue; - this.queue = enableQueue ? [] : null; - this.requestedCount = 0; - this.requestedDisposable = null; - this.error = null; - this.hasFailed = false; - this.hasCompleted = false; - this.scheduler = scheduler || currentThreadScheduler; - } - - addProperties(ControlledSubject.prototype, Observer, { - _subscribe: function (o) { - return this.subject.subscribe(o); - }, - onCompleted: function () { - this.hasCompleted = true; - if (!this.enableQueue || this.queue.length === 0) { - this.subject.onCompleted(); - this.disposeCurrentRequest(); - } else { - this.queue.push(Notification.createOnCompleted()); - } - }, - onError: function (error) { - this.hasFailed = true; - this.error = error; - if (!this.enableQueue || this.queue.length === 0) { - this.subject.onError(error); - this.disposeCurrentRequest(); - } else { - this.queue.push(Notification.createOnError(error)); - } - }, - onNext: function (value) { - if (this.requestedCount <= 0) { - this.enableQueue && this.queue.push(Notification.createOnNext(value)); - } else { - (this.requestedCount-- === 0) && this.disposeCurrentRequest(); - this.subject.onNext(value); - } - }, - _processRequest: function (numberOfItems) { - if (this.enableQueue) { - while (this.queue.length > 0 && (numberOfItems > 0 || this.queue[0].kind !== 'N')) { - var first = this.queue.shift(); - first.accept(this.subject); - if (first.kind === 'N') { - numberOfItems--; - } else { - this.disposeCurrentRequest(); - this.queue = []; - } - } - } - - return numberOfItems; - }, - request: function (number) { - this.disposeCurrentRequest(); - var self = this; - - this.requestedDisposable = this.scheduler.schedule(number, - function(s, i) { - var remaining = self._processRequest(i); - var stopped = self.hasCompleted || self.hasFailed; - if (!stopped && remaining > 0) { - self.requestedCount = remaining; - - return disposableCreate(function () { - self.requestedCount = 0; - }); - // Scheduled item is still in progress. Return a new - // disposable to allow the request to be interrupted - // via dispose. - } - }); - - return this.requestedDisposable; - }, - disposeCurrentRequest: function () { - if (this.requestedDisposable) { - this.requestedDisposable.dispose(); - this.requestedDisposable = null; - } - } - }); - - return ControlledSubject; - }(Observable)); - - /** - * Attaches a controller to the observable sequence with the ability to queue. - * @example - * var source = Rx.Observable.interval(100).controlled(); - * source.request(3); // Reads 3 values - * @param {bool} enableQueue truthy value to determine if values should be queued pending the next request - * @param {Scheduler} scheduler determines how the requests will be scheduled - * @returns {Observable} The observable sequence which only propagates values on request. - */ - observableProto.controlled = function (enableQueue, scheduler) { - - if (enableQueue && isScheduler(enableQueue)) { - scheduler = enableQueue; - enableQueue = true; - } - - if (enableQueue == null) { enableQueue = true; } - return new ControlledObservable(this, enableQueue, scheduler); - }; - - var StopAndWaitObservable = (function (__super__) { - inherits(StopAndWaitObservable, __super__); - function StopAndWaitObservable (source) { - __super__.call(this); - this.source = source; - } - - function scheduleMethod(s, self) { - return self.source.request(1); - } - - StopAndWaitObservable.prototype._subscribe = function (o) { - this.subscription = this.source.subscribe(new StopAndWaitObserver(o, this, this.subscription)); - return new BinaryDisposable( - this.subscription, - defaultScheduler.schedule(this, scheduleMethod) - ); - }; - - var StopAndWaitObserver = (function (__sub__) { - inherits(StopAndWaitObserver, __sub__); - function StopAndWaitObserver (observer, observable, cancel) { - __sub__.call(this); - this.observer = observer; - this.observable = observable; - this.cancel = cancel; - this.scheduleDisposable = null; - } - - StopAndWaitObserver.prototype.completed = function () { - this.observer.onCompleted(); - this.dispose(); - }; - - StopAndWaitObserver.prototype.error = function (error) { - this.observer.onError(error); - this.dispose(); - }; - - function innerScheduleMethod(s, self) { - return self.observable.source.request(1); - } - - StopAndWaitObserver.prototype.next = function (value) { - this.observer.onNext(value); - this.scheduleDisposable = defaultScheduler.schedule(this, innerScheduleMethod); - }; - - StopAndWaitObserver.dispose = function () { - this.observer = null; - if (this.cancel) { - this.cancel.dispose(); - this.cancel = null; - } - if (this.scheduleDisposable) { - this.scheduleDisposable.dispose(); - this.scheduleDisposable = null; - } - __sub__.prototype.dispose.call(this); - }; - - return StopAndWaitObserver; - }(AbstractObserver)); - - return StopAndWaitObservable; - }(Observable)); - - - /** - * Attaches a stop and wait observable to the current observable. - * @returns {Observable} A stop and wait observable. - */ - ControlledObservable.prototype.stopAndWait = function () { - return new StopAndWaitObservable(this); - }; - - var WindowedObservable = (function (__super__) { - inherits(WindowedObservable, __super__); - function WindowedObservable(source, windowSize) { - __super__.call(this); - this.source = source; - this.windowSize = windowSize; - } - - function scheduleMethod(s, self) { - return self.source.request(self.windowSize); - } - - WindowedObservable.prototype._subscribe = function (o) { - this.subscription = this.source.subscribe(new WindowedObserver(o, this, this.subscription)); - return new BinaryDisposable( - this.subscription, - defaultScheduler.schedule(this, scheduleMethod) - ); - }; - - var WindowedObserver = (function (__sub__) { - inherits(WindowedObserver, __sub__); - function WindowedObserver(observer, observable, cancel) { - this.observer = observer; - this.observable = observable; - this.cancel = cancel; - this.received = 0; - this.scheduleDisposable = null; - __sub__.call(this); - } - - WindowedObserver.prototype.completed = function () { - this.observer.onCompleted(); - this.dispose(); - }; - - WindowedObserver.prototype.error = function (error) { - this.observer.onError(error); - this.dispose(); - }; - - function innerScheduleMethod(s, self) { - return self.observable.source.request(self.observable.windowSize); - } - - WindowedObserver.prototype.next = function (value) { - this.observer.onNext(value); - this.received = ++this.received % this.observable.windowSize; - this.received === 0 && (this.scheduleDisposable = defaultScheduler.schedule(this, innerScheduleMethod)); - }; - - WindowedObserver.prototype.dispose = function () { - this.observer = null; - if (this.cancel) { - this.cancel.dispose(); - this.cancel = null; - } - if (this.scheduleDisposable) { - this.scheduleDisposable.dispose(); - this.scheduleDisposable = null; - } - __sub__.prototype.dispose.call(this); - }; - - return WindowedObserver; - }(AbstractObserver)); - - return WindowedObservable; - }(Observable)); - - /** - * Creates a sliding windowed observable based upon the window size. - * @param {Number} windowSize The number of items in the window - * @returns {Observable} A windowed observable based upon the window size. - */ - ControlledObservable.prototype.windowed = function (windowSize) { - return new WindowedObservable(this, windowSize); - }; - - /** - * Pipes the existing Observable sequence into a Node.js Stream. - * @param {Stream} dest The destination Node.js stream. - * @returns {Stream} The destination stream. - */ - observableProto.pipe = function (dest) { - var source = this.pausableBuffered(); - - function onDrain() { - source.resume(); - } - - dest.addListener('drain', onDrain); - - source.subscribe( - function (x) { - !dest.write(x) && source.pause(); - }, - function (err) { - dest.emit('error', err); - }, - function () { - // Hack check because STDIO is not closable - !dest._isStdio && dest.end(); - dest.removeListener('drain', onDrain); - }); - - source.resume(); - - return dest; - }; - - return Rx; -})); - - -/***/ }), -/* 9 */ -/***/ (function(module, exports, __webpack_require__) { - -/* module decorator */ module = __webpack_require__.nmd(module); -var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Copyright (c) Microsoft, All rights reserved. See License.txt in the project root for license information. - -;(function (factory) { - var objectTypes = { - 'function': true, - 'object': true - }; - - function checkGlobal(value) { - return (value && value.Object === Object) ? value : null; - } - - var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType) ? exports : null; - var freeModule = (objectTypes["object"] && module && !module.nodeType) ? module : null; - var freeGlobal = checkGlobal(freeExports && freeModule && typeof global === 'object' && global); - var freeSelf = checkGlobal(objectTypes[typeof self] && self); - var freeWindow = checkGlobal(objectTypes[typeof window] && window); - var moduleExports = (freeModule && freeModule.exports === freeExports) ? freeExports : null; - var thisGlobal = checkGlobal(objectTypes[typeof this] && this); - var root = freeGlobal || ((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) || freeSelf || thisGlobal || Function('return this')(); - - // Because of build optimizers - if (true) { - !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(4)], __WEBPACK_AMD_DEFINE_RESULT__ = (function (Rx, exports) { - return factory(root, exports, Rx); - }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), - __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); - } else {} -}.call(this, function (root, exp, Rx, undefined) { - - var Observable = Rx.Observable, - ObservableBase = Rx.ObservableBase, - AbstractObserver = Rx.internals.AbstractObserver, - CompositeDisposable = Rx.CompositeDisposable, - BinaryDisposable = Rx.BinaryDisposable, - RefCountDisposable = Rx.RefCountDisposable, - SingleAssignmentDisposable = Rx.SingleAssignmentDisposable, - SerialDisposable = Rx.SerialDisposable, - Subject = Rx.Subject, - observableProto = Observable.prototype, - observableEmpty = Observable.empty, - observableNever = Observable.never, - AnonymousObservable = Rx.AnonymousObservable, - addRef = Rx.internals.addRef, - inherits = Rx.internals.inherits, - bindCallback = Rx.internals.bindCallback, - noop = Rx.helpers.noop, - isPromise = Rx.helpers.isPromise, - isFunction = Rx.helpers.isFunction, - observableFromPromise = Observable.fromPromise; - - var errorObj = {e: {}}; - - function tryCatcherGen(tryCatchTarget) { - return function tryCatcher() { - try { - return tryCatchTarget.apply(this, arguments); - } catch (e) { - errorObj.e = e; - return errorObj; - } - }; - } - - var tryCatch = Rx.internals.tryCatch = function tryCatch(fn) { - if (!isFunction(fn)) { throw new TypeError('fn must be a function'); } - return tryCatcherGen(fn); - }; - - function thrower(e) { - throw e; - } - - var Map = root.Map || (function () { - function Map() { - this.size = 0; - this._values = []; - this._keys = []; - } - - Map.prototype['delete'] = function (key) { - var i = this._keys.indexOf(key); - if (i === -1) { return false; } - this._values.splice(i, 1); - this._keys.splice(i, 1); - this.size--; - return true; - }; - - Map.prototype.get = function (key) { - var i = this._keys.indexOf(key); - return i === -1 ? undefined : this._values[i]; - }; - - Map.prototype.set = function (key, value) { - var i = this._keys.indexOf(key); - if (i === -1) { - this._keys.push(key); - this._values.push(value); - this.size++; - } else { - this._values[i] = value; - } - return this; - }; - - Map.prototype.forEach = function (cb, thisArg) { - for (var i = 0; i < this.size; i++) { - cb.call(thisArg, this._values[i], this._keys[i]); - } - }; - - return Map; - }()); - - /** - * Correlates the elements of two sequences based on overlapping durations. - * - * @param {Observable} right The right observable sequence to join elements for. - * @param {Function} leftDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the left observable sequence, used to determine overlap. - * @param {Function} rightDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the right observable sequence, used to determine overlap. - * @param {Function} resultSelector A function invoked to compute a result element for any two overlapping elements of the left and right observable sequences. The parameters passed to the function correspond with the elements from the left and right source sequences for which overlap occurs. - * @returns {Observable} An observable sequence that contains result elements computed from source elements that have an overlapping duration. - */ - observableProto.join = function (right, leftDurationSelector, rightDurationSelector, resultSelector) { - var left = this; - return new AnonymousObservable(function (o) { - var group = new CompositeDisposable(); - var leftDone = false, rightDone = false; - var leftId = 0, rightId = 0; - var leftMap = new Map(), rightMap = new Map(); - var handleError = function (e) { o.onError(e); }; - - group.add(left.subscribe( - function (value) { - var id = leftId++, md = new SingleAssignmentDisposable(); - - leftMap.set(id, value); - group.add(md); - - var duration = tryCatch(leftDurationSelector)(value); - if (duration === errorObj) { return o.onError(duration.e); } - - md.setDisposable(duration.take(1).subscribe( - noop, - handleError, - function () { - leftMap['delete'](id) && leftMap.size === 0 && leftDone && o.onCompleted(); - group.remove(md); - })); - - rightMap.forEach(function (v) { - var result = tryCatch(resultSelector)(value, v); - if (result === errorObj) { return o.onError(result.e); } - o.onNext(result); - }); - }, - handleError, - function () { - leftDone = true; - (rightDone || leftMap.size === 0) && o.onCompleted(); - }) - ); - - group.add(right.subscribe( - function (value) { - var id = rightId++, md = new SingleAssignmentDisposable(); - - rightMap.set(id, value); - group.add(md); - - var duration = tryCatch(rightDurationSelector)(value); - if (duration === errorObj) { return o.onError(duration.e); } - - md.setDisposable(duration.take(1).subscribe( - noop, - handleError, - function () { - rightMap['delete'](id) && rightMap.size === 0 && rightDone && o.onCompleted(); - group.remove(md); - })); - - leftMap.forEach(function (v) { - var result = tryCatch(resultSelector)(v, value); - if (result === errorObj) { return o.onError(result.e); } - o.onNext(result); - }); - }, - handleError, - function () { - rightDone = true; - (leftDone || rightMap.size === 0) && o.onCompleted(); - }) - ); - return group; - }, left); - }; - - /** - * Correlates the elements of two sequences based on overlapping durations, and groups the results. - * - * @param {Observable} right The right observable sequence to join elements for. - * @param {Function} leftDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the left observable sequence, used to determine overlap. - * @param {Function} rightDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the right observable sequence, used to determine overlap. - * @param {Function} resultSelector A function invoked to compute a result element for any element of the left sequence with overlapping elements from the right observable sequence. The first parameter passed to the function is an element of the left sequence. The second parameter passed to the function is an observable sequence with elements from the right sequence that overlap with the left sequence's element. - * @returns {Observable} An observable sequence that contains result elements computed from source elements that have an overlapping duration. - */ - observableProto.groupJoin = function (right, leftDurationSelector, rightDurationSelector, resultSelector) { - var left = this; - return new AnonymousObservable(function (o) { - var group = new CompositeDisposable(); - var r = new RefCountDisposable(group); - var leftMap = new Map(), rightMap = new Map(); - var leftId = 0, rightId = 0; - var handleError = function (e) { return function (v) { v.onError(e); }; }; - - function handleError(e) { }; - - group.add(left.subscribe( - function (value) { - var s = new Subject(); - var id = leftId++; - leftMap.set(id, s); - - var result = tryCatch(resultSelector)(value, addRef(s, r)); - if (result === errorObj) { - leftMap.forEach(handleError(result.e)); - return o.onError(result.e); - } - o.onNext(result); - - rightMap.forEach(function (v) { s.onNext(v); }); - - var md = new SingleAssignmentDisposable(); - group.add(md); - - var duration = tryCatch(leftDurationSelector)(value); - if (duration === errorObj) { - leftMap.forEach(handleError(duration.e)); - return o.onError(duration.e); - } - - md.setDisposable(duration.take(1).subscribe( - noop, - function (e) { - leftMap.forEach(handleError(e)); - o.onError(e); - }, - function () { - leftMap['delete'](id) && s.onCompleted(); - group.remove(md); - })); - }, - function (e) { - leftMap.forEach(handleError(e)); - o.onError(e); - }, - function () { o.onCompleted(); }) - ); - - group.add(right.subscribe( - function (value) { - var id = rightId++; - rightMap.set(id, value); - - var md = new SingleAssignmentDisposable(); - group.add(md); - - var duration = tryCatch(rightDurationSelector)(value); - if (duration === errorObj) { - leftMap.forEach(handleError(duration.e)); - return o.onError(duration.e); - } - - md.setDisposable(duration.take(1).subscribe( - noop, - function (e) { - leftMap.forEach(handleError(e)); - o.onError(e); - }, - function () { - rightMap['delete'](id); - group.remove(md); - })); - - leftMap.forEach(function (v) { v.onNext(value); }); - }, - function (e) { - leftMap.forEach(handleError(e)); - o.onError(e); - }) - ); - - return r; - }, left); - }; - - function toArray(x) { return x.toArray(); } - - /** - * Projects each element of an observable sequence into zero or more buffers. - * @param {Mixed} bufferOpeningsOrClosingSelector Observable sequence whose elements denote the creation of new windows, or, a function invoked to define the boundaries of the produced windows (a new window is started when the previous one is closed, resulting in non-overlapping windows). - * @param {Function} [bufferClosingSelector] A function invoked to define the closing of each produced window. If a closing selector function is specified for the first parameter, this parameter is ignored. - * @returns {Observable} An observable sequence of windows. - */ - observableProto.buffer = function () { - return this.window.apply(this, arguments) - .flatMap(toArray); - }; - - /** - * Projects each element of an observable sequence into zero or more windows. - * - * @param {Mixed} windowOpeningsOrClosingSelector Observable sequence whose elements denote the creation of new windows, or, a function invoked to define the boundaries of the produced windows (a new window is started when the previous one is closed, resulting in non-overlapping windows). - * @param {Function} [windowClosingSelector] A function invoked to define the closing of each produced window. If a closing selector function is specified for the first parameter, this parameter is ignored. - * @returns {Observable} An observable sequence of windows. - */ - observableProto.window = function (windowOpeningsOrClosingSelector, windowClosingSelector) { - if (arguments.length === 1 && typeof arguments[0] !== 'function') { - return observableWindowWithBoundaries.call(this, windowOpeningsOrClosingSelector); - } - return typeof windowOpeningsOrClosingSelector === 'function' ? - observableWindowWithClosingSelector.call(this, windowOpeningsOrClosingSelector) : - observableWindowWithOpenings.call(this, windowOpeningsOrClosingSelector, windowClosingSelector); - }; - - function observableWindowWithOpenings(windowOpenings, windowClosingSelector) { - return windowOpenings.groupJoin(this, windowClosingSelector, observableEmpty, function (_, win) { - return win; - }); - } - - function observableWindowWithBoundaries(windowBoundaries) { - var source = this; - return new AnonymousObservable(function (observer) { - var win = new Subject(), - d = new CompositeDisposable(), - r = new RefCountDisposable(d); - - observer.onNext(addRef(win, r)); - - d.add(source.subscribe(function (x) { - win.onNext(x); - }, function (err) { - win.onError(err); - observer.onError(err); - }, function () { - win.onCompleted(); - observer.onCompleted(); - })); - - isPromise(windowBoundaries) && (windowBoundaries = observableFromPromise(windowBoundaries)); - - d.add(windowBoundaries.subscribe(function (w) { - win.onCompleted(); - win = new Subject(); - observer.onNext(addRef(win, r)); - }, function (err) { - win.onError(err); - observer.onError(err); - }, function () { - win.onCompleted(); - observer.onCompleted(); - })); - - return r; - }, source); - } - - function observableWindowWithClosingSelector(windowClosingSelector) { - var source = this; - return new AnonymousObservable(function (observer) { - var m = new SerialDisposable(), - d = new CompositeDisposable(m), - r = new RefCountDisposable(d), - win = new Subject(); - observer.onNext(addRef(win, r)); - d.add(source.subscribe(function (x) { - win.onNext(x); - }, function (err) { - win.onError(err); - observer.onError(err); - }, function () { - win.onCompleted(); - observer.onCompleted(); - })); - - function createWindowClose () { - var windowClose; - try { - windowClose = windowClosingSelector(); - } catch (e) { - observer.onError(e); - return; - } - - isPromise(windowClose) && (windowClose = observableFromPromise(windowClose)); - - var m1 = new SingleAssignmentDisposable(); - m.setDisposable(m1); - m1.setDisposable(windowClose.take(1).subscribe(noop, function (err) { - win.onError(err); - observer.onError(err); - }, function () { - win.onCompleted(); - win = new Subject(); - observer.onNext(addRef(win, r)); - createWindowClose(); - })); - } - - createWindowClose(); - return r; - }, source); - } - - var PairwiseObservable = (function (__super__) { - inherits(PairwiseObservable, __super__); - function PairwiseObservable(source) { - this.source = source; - __super__.call(this); - } - - PairwiseObservable.prototype.subscribeCore = function (o) { - return this.source.subscribe(new PairwiseObserver(o)); - }; - - return PairwiseObservable; - }(ObservableBase)); - - var PairwiseObserver = (function(__super__) { - inherits(PairwiseObserver, __super__); - function PairwiseObserver(o) { - this._o = o; - this._p = null; - this._hp = false; - __super__.call(this); - } - - PairwiseObserver.prototype.next = function (x) { - if (this._hp) { - this._o.onNext([this._p, x]); - } else { - this._hp = true; - } - this._p = x; - }; - PairwiseObserver.prototype.error = function (err) { this._o.onError(err); }; - PairwiseObserver.prototype.completed = function () { this._o.onCompleted(); }; - - return PairwiseObserver; - }(AbstractObserver)); - - /** - * Returns a new observable that triggers on the second and subsequent triggerings of the input observable. - * The Nth triggering of the input observable passes the arguments from the N-1th and Nth triggering as a pair. - * The argument passed to the N-1th triggering is held in hidden internal state until the Nth triggering occurs. - * @returns {Observable} An observable that triggers on successive pairs of observations from the input observable as an array. - */ - observableProto.pairwise = function () { - return new PairwiseObservable(this); - }; - - /** - * Returns two observables which partition the observations of the source by the given function. - * The first will trigger observations for those values for which the predicate returns true. - * The second will trigger observations for those values where the predicate returns false. - * The predicate is executed once for each subscribed observer. - * Both also propagate all error observations arising from the source and each completes - * when the source completes. - * @param {Function} predicate - * The function to determine which output Observable will trigger a particular observation. - * @returns {Array} - * An array of observables. The first triggers when the predicate returns true, - * and the second triggers when the predicate returns false. - */ - observableProto.partition = function(predicate, thisArg) { - var fn = bindCallback(predicate, thisArg, 3); - return [ - this.filter(predicate, thisArg), - this.filter(function (x, i, o) { return !fn(x, i, o); }) - ]; - }; - - /** - * Groups the elements of an observable sequence according to a specified key selector function and comparer and selects the resulting elements by using a specified function. - * - * @example - * var res = observable.groupBy(function (x) { return x.id; }); - * 2 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }); - * 3 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }, function (x) { return x.toString(); }); - * @param {Function} keySelector A function to extract the key for each element. - * @param {Function} [elementSelector] A function to map each source element to an element in an observable group. - * @returns {Observable} A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value. - */ - observableProto.groupBy = function (keySelector, elementSelector) { - return this.groupByUntil(keySelector, elementSelector, observableNever); - }; - - /** - * Groups the elements of an observable sequence according to a specified key selector function. - * A duration selector function is used to control the lifetime of groups. When a group expires, it receives an OnCompleted notification. When a new element with the same - * key value as a reclaimed group occurs, the group will be reborn with a new lifetime request. - * - * @example - * var res = observable.groupByUntil(function (x) { return x.id; }, null, function () { return Rx.Observable.never(); }); - * 2 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }, function () { return Rx.Observable.never(); }); - * 3 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }, function () { return Rx.Observable.never(); }, function (x) { return x.toString(); }); - * @param {Function} keySelector A function to extract the key for each element. - * @param {Function} durationSelector A function to signal the expiration of a group. - * @returns {Observable} - * A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value. - * If a group's lifetime expires, a new group with the same key value can be created once an element with such a key value is encoutered. - * - */ - observableProto.groupByUntil = function (keySelector, elementSelector, durationSelector) { - var source = this; - return new AnonymousObservable(function (o) { - var map = new Map(), - groupDisposable = new CompositeDisposable(), - refCountDisposable = new RefCountDisposable(groupDisposable), - handleError = function (e) { return function (item) { item.onError(e); }; }; - - groupDisposable.add( - source.subscribe(function (x) { - var key = tryCatch(keySelector)(x); - if (key === errorObj) { - map.forEach(handleError(key.e)); - return o.onError(key.e); - } - - var fireNewMapEntry = false, writer = map.get(key); - if (writer === undefined) { - writer = new Subject(); - map.set(key, writer); - fireNewMapEntry = true; - } - - if (fireNewMapEntry) { - var group = new GroupedObservable(key, writer, refCountDisposable), - durationGroup = new GroupedObservable(key, writer); - var duration = tryCatch(durationSelector)(durationGroup); - if (duration === errorObj) { - map.forEach(handleError(duration.e)); - return o.onError(duration.e); - } - - o.onNext(group); - - var md = new SingleAssignmentDisposable(); - groupDisposable.add(md); - - md.setDisposable(duration.take(1).subscribe( - noop, - function (e) { - map.forEach(handleError(e)); - o.onError(e); - }, - function () { - if (map['delete'](key)) { writer.onCompleted(); } - groupDisposable.remove(md); - })); - } - - var element = x; - if (isFunction(elementSelector)) { - element = tryCatch(elementSelector)(x); - if (element === errorObj) { - map.forEach(handleError(element.e)); - return o.onError(element.e); - } - } - - writer.onNext(element); - }, function (e) { - map.forEach(handleError(e)); - o.onError(e); - }, function () { - map.forEach(function (item) { item.onCompleted(); }); - o.onCompleted(); - })); - - return refCountDisposable; - }, source); - }; - - var UnderlyingObservable = (function (__super__) { - inherits(UnderlyingObservable, __super__); - function UnderlyingObservable(m, u) { - this._m = m; - this._u = u; - __super__.call(this); - } - - UnderlyingObservable.prototype.subscribeCore = function (o) { - return new BinaryDisposable(this._m.getDisposable(), this._u.subscribe(o)); - }; - - return UnderlyingObservable; - }(ObservableBase)); - - var GroupedObservable = (function (__super__) { - inherits(GroupedObservable, __super__); - function GroupedObservable(key, underlyingObservable, mergedDisposable) { - __super__.call(this); - this.key = key; - this.underlyingObservable = !mergedDisposable ? - underlyingObservable : - new UnderlyingObservable(mergedDisposable, underlyingObservable); - } - - GroupedObservable.prototype._subscribe = function (o) { - return this.underlyingObservable.subscribe(o); - }; - - return GroupedObservable; - }(Observable)); - - return Rx; -})); - - -/***/ }), -/* 10 */ -/***/ (function(module, exports, __webpack_require__) { - -/* module decorator */ module = __webpack_require__.nmd(module); -var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Copyright (c) Microsoft, All rights reserved. See License.txt in the project root for license information. - -;(function (factory) { - var objectTypes = { - 'function': true, - 'object': true - }; - - function checkGlobal(value) { - return (value && value.Object === Object) ? value : null; - } - - var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType) ? exports : null; - var freeModule = (objectTypes["object"] && module && !module.nodeType) ? module : null; - var freeGlobal = checkGlobal(freeExports && freeModule && typeof global === 'object' && global); - var freeSelf = checkGlobal(objectTypes[typeof self] && self); - var freeWindow = checkGlobal(objectTypes[typeof window] && window); - var moduleExports = (freeModule && freeModule.exports === freeExports) ? freeExports : null; - var thisGlobal = checkGlobal(objectTypes[typeof this] && this); - var root = freeGlobal || ((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) || freeSelf || thisGlobal || Function('return this')(); - - // Because of build optimizers - if (true) { - !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(4)], __WEBPACK_AMD_DEFINE_RESULT__ = (function (Rx, exports) { - return factory(root, exports, Rx); - }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), - __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); - } else {} -}.call(this, function (root, exp, Rx, undefined) { - - // Aliases - var Observable = Rx.Observable, - observableProto = Observable.prototype, - ObservableBase = Rx.ObservableBase, - AbstractObserver = Rx.internals.AbstractObserver, - FlatMapObservable = Rx.FlatMapObservable, - observableConcat = Observable.concat, - observableDefer = Observable.defer, - observableEmpty = Observable.empty, - disposableEmpty = Rx.Disposable.empty, - CompositeDisposable = Rx.CompositeDisposable, - SerialDisposable = Rx.SerialDisposable, - SingleAssignmentDisposable = Rx.SingleAssignmentDisposable, - Enumerable = Rx.internals.Enumerable, - enumerableOf = Enumerable.of, - currentThreadScheduler = Rx.Scheduler.currentThread, - AsyncSubject = Rx.AsyncSubject, - Observer = Rx.Observer, - inherits = Rx.internals.inherits, - addProperties = Rx.internals.addProperties, - helpers = Rx.helpers, - noop = helpers.noop, - isPromise = helpers.isPromise, - isFunction = helpers.isFunction, - isIterable = Rx.helpers.isIterable, - isArrayLike = Rx.helpers.isArrayLike, - isScheduler = Rx.Scheduler.isScheduler, - observableFromPromise = Observable.fromPromise; - - var errorObj = {e: {}}; - - function tryCatcherGen(tryCatchTarget) { - return function tryCatcher() { - try { - return tryCatchTarget.apply(this, arguments); - } catch (e) { - errorObj.e = e; - return errorObj; - } - }; - } - - var tryCatch = Rx.internals.tryCatch = function tryCatch(fn) { - if (!isFunction(fn)) { throw new TypeError('fn must be a function'); } - return tryCatcherGen(fn); - }; - - function thrower(e) { - throw e; - } - - // Shim in iterator support - var $iterator$ = (typeof Symbol === 'function' && Symbol.iterator) || - '_es6shim_iterator_'; - // Bug for mozilla version - if (root.Set && typeof new root.Set()['@@iterator'] === 'function') { - $iterator$ = '@@iterator'; - } - - var doneEnumerator = Rx.doneEnumerator = { done: true, value: undefined }; - - var isIterable = Rx.helpers.isIterable = function (o) { - return o && o[$iterator$] !== undefined; - }; - - var isArrayLike = Rx.helpers.isArrayLike = function (o) { - return o && o.length !== undefined; - }; - - Rx.helpers.iterator = $iterator$; - - var WhileEnumerable = (function(__super__) { - inherits(WhileEnumerable, __super__); - function WhileEnumerable(c, s) { - this.c = c; - this.s = s; - } - WhileEnumerable.prototype[$iterator$] = function () { - var self = this; - return { - next: function () { - return self.c() ? - { done: false, value: self.s } : - { done: true, value: void 0 }; - } - }; - }; - return WhileEnumerable; - }(Enumerable)); - - function enumerableWhile(condition, source) { - return new WhileEnumerable(condition, source); - } - - /** - * Returns an observable sequence that is the result of invoking the selector on the source sequence, without sharing subscriptions. - * This operator allows for a fluent style of writing queries that use the same sequence multiple times. - * - * @param {Function} selector Selector function which can use the source sequence as many times as needed, without sharing subscriptions to the source sequence. - * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function. - */ - observableProto.letBind = observableProto['let'] = function (func) { - return func(this); - }; - - /** - * Determines whether an observable collection contains values. - * - * @example - * 1 - res = Rx.Observable.if(condition, obs1); - * 2 - res = Rx.Observable.if(condition, obs1, obs2); - * 3 - res = Rx.Observable.if(condition, obs1, scheduler); - * @param {Function} condition The condition which determines if the thenSource or elseSource will be run. - * @param {Observable} thenSource The observable sequence or Promise that will be run if the condition function returns true. - * @param {Observable} [elseSource] The observable sequence or Promise that will be run if the condition function returns false. If this is not provided, it defaults to Rx.Observabe.Empty with the specified scheduler. - * @returns {Observable} An observable sequence which is either the thenSource or elseSource. - */ - Observable['if'] = function (condition, thenSource, elseSourceOrScheduler) { - return observableDefer(function () { - elseSourceOrScheduler || (elseSourceOrScheduler = observableEmpty()); - - isPromise(thenSource) && (thenSource = observableFromPromise(thenSource)); - isPromise(elseSourceOrScheduler) && (elseSourceOrScheduler = observableFromPromise(elseSourceOrScheduler)); - - // Assume a scheduler for empty only - typeof elseSourceOrScheduler.now === 'function' && (elseSourceOrScheduler = observableEmpty(elseSourceOrScheduler)); - return condition() ? thenSource : elseSourceOrScheduler; - }); - }; - - /** - * Concatenates the observable sequences obtained by running the specified result selector for each element in source. - * There is an alias for this method called 'forIn' for browsers 0) { - work = state.q.shift(); - } else { - state.isAcquired = false; - return; - } - var m1 = new SingleAssignmentDisposable(); - state.d.add(m1); - m1.setDisposable(work.subscribe(new ExpandObserver(state, self, m1))); - recurse([state, self]); - } - - ExpandObservable.prototype._ensureActive = function (state) { - var isOwner = false; - if (state.q.length > 0) { - isOwner = !state.isAcquired; - state.isAcquired = true; - } - isOwner && state.m.setDisposable(this._scheduler.scheduleRecursive([state, this], scheduleRecursive)); - }; - - ExpandObservable.prototype.subscribeCore = function (o) { - var m = new SerialDisposable(), - d = new CompositeDisposable(m), - state = { - q: [], - m: m, - d: d, - activeCount: 0, - isAcquired: false, - o: o - }; - - state.q.push(this.source); - state.activeCount++; - this._ensureActive(state); - return d; - }; - - return ExpandObservable; - }(ObservableBase)); - - var ExpandObserver = (function(__super__) { - inherits(ExpandObserver, __super__); - function ExpandObserver(state, parent, m1) { - this._s = state; - this._p = parent; - this._m1 = m1; - __super__.call(this); - } - - ExpandObserver.prototype.next = function (x) { - this._s.o.onNext(x); - var result = tryCatch(this._p._fn)(x); - if (result === errorObj) { return this._s.o.onError(result.e); } - this._s.q.push(result); - this._s.activeCount++; - this._p._ensureActive(this._s); - }; - - ExpandObserver.prototype.error = function (e) { - this._s.o.onError(e); - }; - - ExpandObserver.prototype.completed = function () { - this._s.d.remove(this._m1); - this._s.activeCount--; - this._s.activeCount === 0 && this._s.o.onCompleted(); - }; - - return ExpandObserver; - }(AbstractObserver)); - - /** - * Expands an observable sequence by recursively invoking selector. - * - * @param {Function} selector Selector function to invoke for each produced element, resulting in another sequence to which the selector will be invoked recursively again. - * @param {Scheduler} [scheduler] Scheduler on which to perform the expansion. If not provided, this defaults to the current thread scheduler. - * @returns {Observable} An observable sequence containing all the elements produced by the recursive expansion. - */ - observableProto.expand = function (selector, scheduler) { - isScheduler(scheduler) || (scheduler = currentThreadScheduler); - return new ExpandObservable(this, selector, scheduler); - }; - - function argumentsToArray() { - var len = arguments.length, args = new Array(len); - for(var i = 0; i < len; i++) { args[i] = arguments[i]; } - return args; - } - - var ForkJoinObservable = (function (__super__) { - inherits(ForkJoinObservable, __super__); - function ForkJoinObservable(sources, cb) { - this._sources = sources; - this._cb = cb; - __super__.call(this); - } - - ForkJoinObservable.prototype.subscribeCore = function (o) { - if (this._sources.length === 0) { - o.onCompleted(); - return disposableEmpty; - } - - var count = this._sources.length; - var state = { - finished: false, - hasResults: new Array(count), - hasCompleted: new Array(count), - results: new Array(count) - }; - - var subscriptions = new CompositeDisposable(); - for (var i = 0, len = this._sources.length; i < len; i++) { - var source = this._sources[i]; - isPromise(source) && (source = observableFromPromise(source)); - subscriptions.add(source.subscribe(new ForkJoinObserver(o, state, i, this._cb, subscriptions))); - } - - return subscriptions; - }; - - return ForkJoinObservable; - }(ObservableBase)); - - var ForkJoinObserver = (function(__super__) { - inherits(ForkJoinObserver, __super__); - function ForkJoinObserver(o, s, i, cb, subs) { - this._o = o; - this._s = s; - this._i = i; - this._cb = cb; - this._subs = subs; - __super__.call(this); - } - - ForkJoinObserver.prototype.next = function (x) { - if (!this._s.finished) { - this._s.hasResults[this._i] = true; - this._s.results[this._i] = x; - } - }; - - ForkJoinObserver.prototype.error = function (e) { - this._s.finished = true; - this._o.onError(e); - this._subs.dispose(); - }; - - ForkJoinObserver.prototype.completed = function () { - if (!this._s.finished) { - if (!this._s.hasResults[this._i]) { - return this._o.onCompleted(); - } - this._s.hasCompleted[this._i] = true; - for (var i = 0; i < this._s.results.length; i++) { - if (!this._s.hasCompleted[i]) { return; } - } - this._s.finished = true; - - var res = tryCatch(this._cb).apply(null, this._s.results); - if (res === errorObj) { return this._o.onError(res.e); } - - this._o.onNext(res); - this._o.onCompleted(); - } - }; - - return ForkJoinObserver; - }(AbstractObserver)); - - /** - * Runs all observable sequences in parallel and collect their last elements. - * - * @example - * 1 - res = Rx.Observable.forkJoin([obs1, obs2]); - * 1 - res = Rx.Observable.forkJoin(obs1, obs2, ...); - * @returns {Observable} An observable sequence with an array collecting the last elements of all the input sequences. - */ - Observable.forkJoin = function () { - var len = arguments.length, args = new Array(len); - for(var i = 0; i < len; i++) { args[i] = arguments[i]; } - var resultSelector = isFunction(args[len - 1]) ? args.pop() : argumentsToArray; - Array.isArray(args[0]) && (args = args[0]); - return new ForkJoinObservable(args, resultSelector); - }; - - /** - * Runs two observable sequences in parallel and combines their last elemenets. - * @param {Observable} second Second observable sequence. - * @param {Function} resultSelector Result selector function to invoke with the last elements of both sequences. - * @returns {Observable} An observable sequence with the result of calling the selector function with the last elements of both input sequences. - */ - observableProto.forkJoin = function () { - var len = arguments.length, args = new Array(len); - for(var i = 0; i < len; i++) { args[i] = arguments[i]; } - if (Array.isArray(args[0])) { - args[0].unshift(this); - } else { - args.unshift(this); - } - return Observable.forkJoin.apply(null, args); - }; - - /** - * Comonadic bind operator. - * @param {Function} selector A transform function to apply to each element. - * @param {Object} scheduler Scheduler used to execute the operation. If not specified, defaults to the ImmediateScheduler. - * @returns {Observable} An observable sequence which results from the comonadic bind operation. - */ - observableProto.manySelect = observableProto.extend = function (selector, scheduler) { - isScheduler(scheduler) || (scheduler = Rx.Scheduler.immediate); - var source = this; - return observableDefer(function () { - var chain; - - return source - .map(function (x) { - var curr = new ChainObservable(x); - - chain && chain.onNext(x); - chain = curr; - - return curr; - }) - .tap( - noop, - function (e) { chain && chain.onError(e); }, - function () { chain && chain.onCompleted(); } - ) - .observeOn(scheduler) - .map(selector); - }, source); - }; - - var ChainObservable = (function (__super__) { - inherits(ChainObservable, __super__); - function ChainObservable(head) { - __super__.call(this); - this.head = head; - this.tail = new AsyncSubject(); - } - - addProperties(ChainObservable.prototype, Observer, { - _subscribe: function (o) { - var g = new CompositeDisposable(); - g.add(currentThreadScheduler.schedule(this, function (_, self) { - o.onNext(self.head); - g.add(self.tail.mergeAll().subscribe(o)); - })); - - return g; - }, - onCompleted: function () { - this.onNext(Observable.empty()); - }, - onError: function (e) { - this.onNext(Observable['throw'](e)); - }, - onNext: function (v) { - this.tail.onNext(v); - this.tail.onCompleted(); - } - }); - - return ChainObservable; - - }(Observable)); - - var SwitchFirstObservable = (function (__super__) { - inherits(SwitchFirstObservable, __super__); - function SwitchFirstObservable(source) { - this.source = source; - __super__.call(this); - } - - SwitchFirstObservable.prototype.subscribeCore = function (o) { - var m = new SingleAssignmentDisposable(), - g = new CompositeDisposable(), - state = { - hasCurrent: false, - isStopped: false, - o: o, - g: g - }; - - g.add(m); - m.setDisposable(this.source.subscribe(new SwitchFirstObserver(state))); - return g; - }; - - return SwitchFirstObservable; - }(ObservableBase)); - - var SwitchFirstObserver = (function(__super__) { - inherits(SwitchFirstObserver, __super__); - function SwitchFirstObserver(state) { - this._s = state; - __super__.call(this); - } - - SwitchFirstObserver.prototype.next = function (x) { - if (!this._s.hasCurrent) { - this._s.hasCurrent = true; - isPromise(x) && (x = observableFromPromise(x)); - var inner = new SingleAssignmentDisposable(); - this._s.g.add(inner); - inner.setDisposable(x.subscribe(new InnerObserver(this._s, inner))); - } - }; - - SwitchFirstObserver.prototype.error = function (e) { - this._s.o.onError(e); - }; - - SwitchFirstObserver.prototype.completed = function () { - this._s.isStopped = true; - !this._s.hasCurrent && this._s.g.length === 1 && this._s.o.onCompleted(); - }; - - inherits(InnerObserver, __super__); - function InnerObserver(state, inner) { - this._s = state; - this._i = inner; - __super__.call(this); - } - - InnerObserver.prototype.next = function (x) { this._s.o.onNext(x); }; - InnerObserver.prototype.error = function (e) { this._s.o.onError(e); }; - InnerObserver.prototype.completed = function () { - this._s.g.remove(this._i); - this._s.hasCurrent = false; - this._s.isStopped && this._s.g.length === 1 && this._s.o.onCompleted(); - }; - - return SwitchFirstObserver; - }(AbstractObserver)); - - /** - * Performs a exclusive waiting for the first to finish before subscribing to another observable. - * Observables that come in between subscriptions will be dropped on the floor. - * @returns {Observable} A exclusive observable with only the results that happen when subscribed. - */ - observableProto.switchFirst = function () { - return new SwitchFirstObservable(this); - }; - -observableProto.flatMapFirst = observableProto.exhaustMap = function(selector, resultSelector, thisArg) { - return new FlatMapObservable(this, selector, resultSelector, thisArg).switchFirst(); -}; - -observableProto.flatMapWithMaxConcurrent = observableProto.flatMapMaxConcurrent = function(limit, selector, resultSelector, thisArg) { - return new FlatMapObservable(this, selector, resultSelector, thisArg).merge(limit); -}; - - return Rx; -})); - - -/***/ }), -/* 11 */ -/***/ (function(module, exports, __webpack_require__) { - -/* module decorator */ module = __webpack_require__.nmd(module); -var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Copyright (c) Microsoft, All rights reserved. See License.txt in the project root for license information. - -;(function (factory) { - var objectTypes = { - 'function': true, - 'object': true - }; - - function checkGlobal(value) { - return (value && value.Object === Object) ? value : null; - } - - var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType) ? exports : null; - var freeModule = (objectTypes["object"] && module && !module.nodeType) ? module : null; - var freeGlobal = checkGlobal(freeExports && freeModule && typeof global === 'object' && global); - var freeSelf = checkGlobal(objectTypes[typeof self] && self); - var freeWindow = checkGlobal(objectTypes[typeof window] && window); - var moduleExports = (freeModule && freeModule.exports === freeExports) ? freeExports : null; - var thisGlobal = checkGlobal(objectTypes[typeof this] && this); - var root = freeGlobal || ((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) || freeSelf || thisGlobal || Function('return this')(); - - // Because of build optimizers - if (true) { - !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(4)], __WEBPACK_AMD_DEFINE_RESULT__ = (function (Rx, exports) { - return factory(root, exports, Rx); - }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), - __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); - } else {} -}.call(this, function (root, exp, Rx, undefined) { - - // Aliases - var Observable = Rx.Observable, - observableProto = Observable.prototype, - AnonymousObservable = Rx.AnonymousObservable, - observableThrow = Observable.throwError, - observerCreate = Rx.Observer.create, - SingleAssignmentDisposable = Rx.SingleAssignmentDisposable, - CompositeDisposable = Rx.CompositeDisposable, - AbstractObserver = Rx.internals.AbstractObserver, - noop = Rx.helpers.noop, - inherits = Rx.internals.inherits, - isFunction = Rx.helpers.isFunction; - - var errorObj = {e: {}}; - - function tryCatcherGen(tryCatchTarget) { - return function tryCatcher() { - try { - return tryCatchTarget.apply(this, arguments); - } catch (e) { - errorObj.e = e; - return errorObj; - } - }; - } - - var tryCatch = Rx.internals.tryCatch = function tryCatch(fn) { - if (!isFunction(fn)) { throw new TypeError('fn must be a function'); } - return tryCatcherGen(fn); - }; - - function thrower(e) { - throw e; - } - - var Map = root.Map || (function () { - function Map() { - this.size = 0; - this._values = []; - this._keys = []; - } - - Map.prototype['delete'] = function (key) { - var i = this._keys.indexOf(key); - if (i === -1) { return false; } - this._values.splice(i, 1); - this._keys.splice(i, 1); - this.size--; - return true; - }; - - Map.prototype.get = function (key) { - var i = this._keys.indexOf(key); - return i === -1 ? undefined : this._values[i]; - }; - - Map.prototype.set = function (key, value) { - var i = this._keys.indexOf(key); - if (i === -1) { - this._keys.push(key); - this._values.push(value); - this.size++; - } else { - this._values[i] = value; - } - return this; - }; - - Map.prototype.forEach = function (cb, thisArg) { - for (var i = 0; i < this.size; i++) { - cb.call(thisArg, this._values[i], this._keys[i]); - } - }; - - return Map; - }()); - - /** - * @constructor - * Represents a join pattern over observable sequences. - */ - function Pattern(patterns) { - this.patterns = patterns; - } - - /** - * Creates a pattern that matches the current plan matches and when the specified observable sequences has an available value. - * @param other Observable sequence to match in addition to the current pattern. - * @return {Pattern} Pattern object that matches when all observable sequences in the pattern have an available value. - */ - Pattern.prototype.and = function (other) { - return new Pattern(this.patterns.concat(other)); - }; - - /** - * Matches when all observable sequences in the pattern (specified using a chain of and operators) have an available value and projects the values. - * @param {Function} selector Selector that will be invoked with available values from the source sequences, in the same order of the sequences in the pattern. - * @return {Plan} Plan that produces the projected values, to be fed (with other plans) to the when operator. - */ - Pattern.prototype.thenDo = function (selector) { - return new Plan(this, selector); - }; - - function Plan(expression, selector) { - this.expression = expression; - this.selector = selector; - } - - function handleOnError(o) { return function (e) { o.onError(e); }; } - function handleOnNext(self, observer) { - return function onNext () { - var result = tryCatch(self.selector).apply(self, arguments); - if (result === errorObj) { return observer.onError(result.e); } - observer.onNext(result); - }; - } - - Plan.prototype.activate = function (externalSubscriptions, observer, deactivate) { - var joinObservers = [], errHandler = handleOnError(observer); - for (var i = 0, len = this.expression.patterns.length; i < len; i++) { - joinObservers.push(planCreateObserver(externalSubscriptions, this.expression.patterns[i], errHandler)); - } - var activePlan = new ActivePlan(joinObservers, handleOnNext(this, observer), function () { - for (var j = 0, jlen = joinObservers.length; j < jlen; j++) { - joinObservers[j].removeActivePlan(activePlan); - } - deactivate(activePlan); - }); - for (i = 0, len = joinObservers.length; i < len; i++) { - joinObservers[i].addActivePlan(activePlan); - } - return activePlan; - }; - - function planCreateObserver(externalSubscriptions, observable, onError) { - var entry = externalSubscriptions.get(observable); - if (!entry) { - var observer = new JoinObserver(observable, onError); - externalSubscriptions.set(observable, observer); - return observer; - } - return entry; - } - - function ActivePlan(joinObserverArray, onNext, onCompleted) { - this.joinObserverArray = joinObserverArray; - this.onNext = onNext; - this.onCompleted = onCompleted; - this.joinObservers = new Map(); - for (var i = 0, len = this.joinObserverArray.length; i < len; i++) { - var joinObserver = this.joinObserverArray[i]; - this.joinObservers.set(joinObserver, joinObserver); - } - } - - ActivePlan.prototype.dequeue = function () { - this.joinObservers.forEach(function (v) { v.queue.shift(); }); - }; - - ActivePlan.prototype.match = function () { - var i, len, hasValues = true; - for (i = 0, len = this.joinObserverArray.length; i < len; i++) { - if (this.joinObserverArray[i].queue.length === 0) { - hasValues = false; - break; - } - } - if (hasValues) { - var firstValues = [], - isCompleted = false; - for (i = 0, len = this.joinObserverArray.length; i < len; i++) { - firstValues.push(this.joinObserverArray[i].queue[0]); - this.joinObserverArray[i].queue[0].kind === 'C' && (isCompleted = true); - } - if (isCompleted) { - this.onCompleted(); - } else { - this.dequeue(); - var values = []; - for (i = 0, len = firstValues.length; i < firstValues.length; i++) { - values.push(firstValues[i].value); - } - this.onNext.apply(this, values); - } - } - }; - - var JoinObserver = (function (__super__) { - inherits(JoinObserver, __super__); - - function JoinObserver(source, onError) { - __super__.call(this); - this.source = source; - this.onError = onError; - this.queue = []; - this.activePlans = []; - this.subscription = new SingleAssignmentDisposable(); - this.isDisposed = false; - } - - var JoinObserverPrototype = JoinObserver.prototype; - - JoinObserverPrototype.next = function (notification) { - if (!this.isDisposed) { - if (notification.kind === 'E') { - return this.onError(notification.error); - } - this.queue.push(notification); - var activePlans = this.activePlans.slice(0); - for (var i = 0, len = activePlans.length; i < len; i++) { - activePlans[i].match(); - } - } - }; - - JoinObserverPrototype.error = noop; - JoinObserverPrototype.completed = noop; - - JoinObserverPrototype.addActivePlan = function (activePlan) { - this.activePlans.push(activePlan); - }; - - JoinObserverPrototype.subscribe = function () { - this.subscription.setDisposable(this.source.materialize().subscribe(this)); - }; - - JoinObserverPrototype.removeActivePlan = function (activePlan) { - this.activePlans.splice(this.activePlans.indexOf(activePlan), 1); - this.activePlans.length === 0 && this.dispose(); - }; - - JoinObserverPrototype.dispose = function () { - __super__.prototype.dispose.call(this); - if (!this.isDisposed) { - this.isDisposed = true; - this.subscription.dispose(); - } - }; - - return JoinObserver; - } (AbstractObserver)); - - /** - * Creates a pattern that matches when both observable sequences have an available value. - * - * @param right Observable sequence to match with the current sequence. - * @return {Pattern} Pattern object that matches when both observable sequences have an available value. - */ - observableProto.and = function (right) { - return new Pattern([this, right]); - }; - - /** - * Matches when the observable sequence has an available value and projects the value. - * - * @param {Function} selector Selector that will be invoked for values in the source sequence. - * @returns {Plan} Plan that produces the projected values, to be fed (with other plans) to the when operator. - */ - observableProto.thenDo = function (selector) { - return new Pattern([this]).thenDo(selector); - }; - - /** - * Joins together the results from several patterns. - * - * @param plans A series of plans (specified as an Array of as a series of arguments) created by use of the Then operator on patterns. - * @returns {Observable} Observable sequence with the results form matching several patterns. - */ - Observable.when = function () { - var len = arguments.length, plans; - if (Array.isArray(arguments[0])) { - plans = arguments[0]; - } else { - plans = new Array(len); - for(var i = 0; i < len; i++) { plans[i] = arguments[i]; } - } - return new AnonymousObservable(function (o) { - var activePlans = [], - externalSubscriptions = new Map(); - var outObserver = observerCreate( - function (x) { o.onNext(x); }, - function (err) { - externalSubscriptions.forEach(function (v) { v.onError(err); }); - o.onError(err); - }, - function (x) { o.onCompleted(); } - ); - try { - for (var i = 0, len = plans.length; i < len; i++) { - activePlans.push(plans[i].activate(externalSubscriptions, outObserver, function (activePlan) { - var idx = activePlans.indexOf(activePlan); - activePlans.splice(idx, 1); - activePlans.length === 0 && o.onCompleted(); - })); - } - } catch (e) { - return observableThrow(e).subscribe(o); - } - var group = new CompositeDisposable(); - externalSubscriptions.forEach(function (joinObserver) { - joinObserver.subscribe(); - group.add(joinObserver); - }); - - return group; - }); - }; - - return Rx; -})); - - -/***/ }), -/* 12 */ -/***/ (function(module, exports, __webpack_require__) { - -/* module decorator */ module = __webpack_require__.nmd(module); -var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Copyright (c) Microsoft, All rights reserved. See License.txt in the project root for license information. - -;(function (factory) { - var objectTypes = { - 'function': true, - 'object': true - }; - - function checkGlobal(value) { - return (value && value.Object === Object) ? value : null; - } - - var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType) ? exports : null; - var freeModule = (objectTypes["object"] && module && !module.nodeType) ? module : null; - var freeGlobal = checkGlobal(freeExports && freeModule && typeof global === 'object' && global); - var freeSelf = checkGlobal(objectTypes[typeof self] && self); - var freeWindow = checkGlobal(objectTypes[typeof window] && window); - var moduleExports = (freeModule && freeModule.exports === freeExports) ? freeExports : null; - var thisGlobal = checkGlobal(objectTypes[typeof this] && this); - var root = freeGlobal || ((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) || freeSelf || thisGlobal || Function('return this')(); - - // Because of build optimizers - if (true) { - !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(4)], __WEBPACK_AMD_DEFINE_RESULT__ = (function (Rx, exports) { - return factory(root, exports, Rx); - }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), - __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); - } else {} -}.call(this, function (root, exp, Rx, undefined) { - - var Observable = Rx.Observable, - observableProto = Observable.prototype, - AnonymousObservable = Rx.AnonymousObservable, - observableNever = Observable.never, - isEqual = Rx.internals.isEqual, - defaultSubComparer = Rx.helpers.defaultSubComparer; - - /** - * jortSort checks if your inputs are sorted. Note that this is only for a sequence with an end. - * See http://jort.technology/ for full details. - * @returns {Observable} An observable which has a single value of true if sorted, else false. - */ - observableProto.jortSort = function () { - return this.jortSortUntil(observableNever()); - }; - - /** - * jortSort checks if your inputs are sorted until another Observable sequence fires. - * See http://jort.technology/ for full details. - * @returns {Observable} An observable which has a single value of true if sorted, else false. - */ - observableProto.jortSortUntil = function (other) { - var source = this; - return new AnonymousObservable(function (observer) { - var arr = []; - return source.takeUntil(other).subscribe( - arr.push.bind(arr), - observer.onError.bind(observer), - function () { - var sorted = arr.slice(0).sort(defaultSubComparer); - observer.onNext(isEqual(arr, sorted)); - observer.onCompleted(); - }); - }, source); - }; - - return Rx; -})); - - -/***/ }), -/* 13 */ -/***/ (function(module, exports, __webpack_require__) { - -/* module decorator */ module = __webpack_require__.nmd(module); -var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Copyright (c) Microsoft, All rights reserved. See License.txt in the project root for license information. - -;(function (factory) { - var objectTypes = { - 'function': true, - 'object': true - }; - - function checkGlobal(value) { - return (value && value.Object === Object) ? value : null; - } - - var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType) ? exports : null; - var freeModule = (objectTypes["object"] && module && !module.nodeType) ? module : null; - var freeGlobal = checkGlobal(freeExports && freeModule && typeof global === 'object' && global); - var freeSelf = checkGlobal(objectTypes[typeof self] && self); - var freeWindow = checkGlobal(objectTypes[typeof window] && window); - var moduleExports = (freeModule && freeModule.exports === freeExports) ? freeExports : null; - var thisGlobal = checkGlobal(objectTypes[typeof this] && this); - var root = freeGlobal || ((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) || freeSelf || thisGlobal || Function('return this')(); - - // Because of build optimizers - if (true) { - !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(4)], __WEBPACK_AMD_DEFINE_RESULT__ = (function (Rx, exports) { - return factory(root, exports, Rx); - }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), - __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); - } else {} -}.call(this, function (root, exp, Rx, undefined) { - - // Aliases - var Scheduler = Rx.Scheduler, - ScheduledItem = Rx.internals.ScheduledItem, - SchedulePeriodicRecursive = Rx.internals.SchedulePeriodicRecursive, - PriorityQueue = Rx.internals.PriorityQueue, - inherits = Rx.internals.inherits, - defaultSubComparer = Rx.helpers.defaultSubComparer, - notImplemented = Rx.helpers.notImplemented; - - /** Provides a set of extension methods for virtual time scheduling. */ - var VirtualTimeScheduler = Rx.VirtualTimeScheduler = (function (__super__) { - inherits(VirtualTimeScheduler, __super__); - - /** - * Creates a new virtual time scheduler with the specified initial clock value and absolute time comparer. - * - * @constructor - * @param {Number} initialClock Initial value for the clock. - * @param {Function} comparer Comparer to determine causality of events based on absolute time. - */ - function VirtualTimeScheduler(initialClock, comparer) { - this.clock = initialClock; - this.comparer = comparer; - this.isEnabled = false; - this.queue = new PriorityQueue(1024); - __super__.call(this); - } - - var VirtualTimeSchedulerPrototype = VirtualTimeScheduler.prototype; - - VirtualTimeSchedulerPrototype.now = function () { - return this.toAbsoluteTime(this.clock); - }; - - VirtualTimeSchedulerPrototype.schedule = function (state, action) { - return this.scheduleAbsolute(state, this.clock, action); - }; - - VirtualTimeSchedulerPrototype.scheduleFuture = function (state, dueTime, action) { - var dt = dueTime instanceof Date ? - this.toRelativeTime(dueTime - this.now()) : - this.toRelativeTime(dueTime); - - return this.scheduleRelative(state, dt, action); - }; - - /** - * Adds a relative time value to an absolute time value. - * @param {Number} absolute Absolute virtual time value. - * @param {Number} relative Relative virtual time value to add. - * @return {Number} Resulting absolute virtual time sum value. - */ - VirtualTimeSchedulerPrototype.add = notImplemented; - - /** - * Converts an absolute time to a number - * @param {Any} The absolute time. - * @returns {Number} The absolute time in ms - */ - VirtualTimeSchedulerPrototype.toAbsoluteTime = notImplemented; - - /** - * Converts the TimeSpan value to a relative virtual time value. - * @param {Number} timeSpan TimeSpan value to convert. - * @return {Number} Corresponding relative virtual time value. - */ - VirtualTimeSchedulerPrototype.toRelativeTime = notImplemented; - - /** - * Schedules a periodic piece of work by dynamically discovering the scheduler's capabilities. The periodic task will be emulated using recursive scheduling. - * @param {Mixed} state Initial state passed to the action upon the first iteration. - * @param {Number} period Period for running the work periodically. - * @param {Function} action Action to be executed, potentially updating the state. - * @returns {Disposable} The disposable object used to cancel the scheduled recurring action (best effort). - */ - VirtualTimeSchedulerPrototype.schedulePeriodic = function (state, period, action) { - var s = new SchedulePeriodicRecursive(this, state, period, action); - return s.start(); - }; - - /** - * Schedules an action to be executed after dueTime. - * @param {Mixed} state State passed to the action to be executed. - * @param {Number} dueTime Relative time after which to execute the action. - * @param {Function} action Action to be executed. - * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). - */ - VirtualTimeSchedulerPrototype.scheduleRelative = function (state, dueTime, action) { - var runAt = this.add(this.clock, dueTime); - return this.scheduleAbsolute(state, runAt, action); - }; - - /** - * Starts the virtual time scheduler. - */ - VirtualTimeSchedulerPrototype.start = function () { - if (!this.isEnabled) { - this.isEnabled = true; - do { - var next = this.getNext(); - if (next !== null) { - this.comparer(next.dueTime, this.clock) > 0 && (this.clock = next.dueTime); - next.invoke(); - } else { - this.isEnabled = false; - } - } while (this.isEnabled); - } - }; - - /** - * Stops the virtual time scheduler. - */ - VirtualTimeSchedulerPrototype.stop = function () { - this.isEnabled = false; - }; - - /** - * Advances the scheduler's clock to the specified time, running all work till that point. - * @param {Number} time Absolute time to advance the scheduler's clock to. - */ - VirtualTimeSchedulerPrototype.advanceTo = function (time) { - var dueToClock = this.comparer(this.clock, time); - if (this.comparer(this.clock, time) > 0) { throw new ArgumentOutOfRangeError(); } - if (dueToClock === 0) { return; } - if (!this.isEnabled) { - this.isEnabled = true; - do { - var next = this.getNext(); - if (next !== null && this.comparer(next.dueTime, time) <= 0) { - this.comparer(next.dueTime, this.clock) > 0 && (this.clock = next.dueTime); - next.invoke(); - } else { - this.isEnabled = false; - } - } while (this.isEnabled); - this.clock = time; - } - }; - - /** - * Advances the scheduler's clock by the specified relative time, running all work scheduled for that timespan. - * @param {Number} time Relative time to advance the scheduler's clock by. - */ - VirtualTimeSchedulerPrototype.advanceBy = function (time) { - var dt = this.add(this.clock, time), - dueToClock = this.comparer(this.clock, dt); - if (dueToClock > 0) { throw new ArgumentOutOfRangeError(); } - if (dueToClock === 0) { return; } - - this.advanceTo(dt); - }; - - /** - * Advances the scheduler's clock by the specified relative time. - * @param {Number} time Relative time to advance the scheduler's clock by. - */ - VirtualTimeSchedulerPrototype.sleep = function (time) { - var dt = this.add(this.clock, time); - if (this.comparer(this.clock, dt) >= 0) { throw new ArgumentOutOfRangeError(); } - - this.clock = dt; - }; - - /** - * Gets the next scheduled item to be executed. - * @returns {ScheduledItem} The next scheduled item. - */ - VirtualTimeSchedulerPrototype.getNext = function () { - while (this.queue.length > 0) { - var next = this.queue.peek(); - if (next.isCancelled()) { - this.queue.dequeue(); - } else { - return next; - } - } - return null; - }; - - /** - * Schedules an action to be executed at dueTime. - * @param {Mixed} state State passed to the action to be executed. - * @param {Number} dueTime Absolute time at which to execute the action. - * @param {Function} action Action to be executed. - * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort). - */ - VirtualTimeSchedulerPrototype.scheduleAbsolute = function (state, dueTime, action) { - var self = this; - - function run(scheduler, state1) { - self.queue.remove(si); - return action(scheduler, state1); - } - - var si = new ScheduledItem(this, state, run, dueTime, this.comparer); - this.queue.enqueue(si); - - return si.disposable; - }; - - return VirtualTimeScheduler; - }(Scheduler)); - - /** Provides a virtual time scheduler that uses Date for absolute time and number for relative time. */ - Rx.HistoricalScheduler = (function (__super__) { - inherits(HistoricalScheduler, __super__); - - /** - * Creates a new historical scheduler with the specified initial clock value. - * @constructor - * @param {Number} initialClock Initial value for the clock. - * @param {Function} comparer Comparer to determine causality of events based on absolute time. - */ - function HistoricalScheduler(initialClock, comparer) { - var clock = initialClock == null ? 0 : initialClock; - var cmp = comparer || defaultSubComparer; - __super__.call(this, clock, cmp); - } - - var HistoricalSchedulerProto = HistoricalScheduler.prototype; - - /** - * Adds a relative time value to an absolute time value. - * @param {Number} absolute Absolute virtual time value. - * @param {Number} relative Relative virtual time value to add. - * @return {Number} Resulting absolute virtual time sum value. - */ - HistoricalSchedulerProto.add = function (absolute, relative) { - return absolute + relative; - }; - - HistoricalSchedulerProto.toAbsoluteTime = function (absolute) { - return new Date(absolute).getTime(); - }; - - /** - * Converts the TimeSpan value to a relative virtual time value. - * @memberOf HistoricalScheduler - * @param {Number} timeSpan TimeSpan value to convert. - * @return {Number} Corresponding relative virtual time value. - */ - HistoricalSchedulerProto.toRelativeTime = function (timeSpan) { - return timeSpan; - }; - - return HistoricalScheduler; - }(Rx.VirtualTimeScheduler)); - - return Rx; -})); - - -/***/ }), -/* 14 */ -/***/ (function(module, exports, __webpack_require__) { - -/* module decorator */ module = __webpack_require__.nmd(module); -var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Copyright (c) Microsoft, All rights reserved. See License.txt in the project root for license information. - -;(function (factory) { - var objectTypes = { - 'function': true, - 'object': true - }; - - function checkGlobal(value) { - return (value && value.Object === Object) ? value : null; - } - - var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType) ? exports : null; - var freeModule = (objectTypes["object"] && module && !module.nodeType) ? module : null; - var freeGlobal = checkGlobal(freeExports && freeModule && typeof global === 'object' && global); - var freeSelf = checkGlobal(objectTypes[typeof self] && self); - var freeWindow = checkGlobal(objectTypes[typeof window] && window); - var moduleExports = (freeModule && freeModule.exports === freeExports) ? freeExports : null; - var thisGlobal = checkGlobal(objectTypes[typeof this] && this); - var root = freeGlobal || ((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) || freeSelf || thisGlobal || Function('return this')(); - - // Because of build optimizers - if (true) { - !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(13), exports], __WEBPACK_AMD_DEFINE_RESULT__ = (function (Rx, exports) { - root.Rx = factory(root, exports, Rx); - return root.Rx; - }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), - __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); - } else {} -}.call(this, function (root, exp, Rx, undefined) { - - // Defaults - var Observer = Rx.Observer, - Observable = Rx.Observable, - Notification = Rx.Notification, - VirtualTimeScheduler = Rx.VirtualTimeScheduler, - Disposable = Rx.Disposable, - disposableEmpty = Disposable.empty, - disposableCreate = Disposable.create, - CompositeDisposable = Rx.CompositeDisposable, - inherits = Rx.internals.inherits, - defaultComparer = Rx.internals.isEqual; - -function OnNextPredicate(predicate) { - this.predicate = predicate; -} - -OnNextPredicate.prototype.equals = function (other) { - if (other === this) { return true; } - if (other == null) { return false; } - if (other.kind !== 'N') { return false; } - return this.predicate(other.value); -}; - -function OnErrorPredicate(predicate) { - this.predicate = predicate; -} - -OnErrorPredicate.prototype.equals = function (other) { - if (other === this) { return true; } - if (other == null) { return false; } - if (other.kind !== 'E') { return false; } - return this.predicate(other.error); -}; - -var ReactiveTest = Rx.ReactiveTest = { - /** Default virtual time used for creation of observable sequences in unit tests. */ - created: 100, - /** Default virtual time used to subscribe to observable sequences in unit tests. */ - subscribed: 200, - /** Default virtual time used to dispose subscriptions in unit tests. */ - disposed: 1000, - - /** - * Factory method for an OnNext notification record at a given time with a given value or a predicate function. - * - * 1 - ReactiveTest.onNext(200, 42); - * 2 - ReactiveTest.onNext(200, function (x) { return x.length == 2; }); - * - * @param ticks Recorded virtual time the OnNext notification occurs. - * @param value Recorded value stored in the OnNext notification or a predicate. - * @return Recorded OnNext notification. - */ - onNext: function (ticks, value) { - return typeof value === 'function' ? - new Recorded(ticks, new OnNextPredicate(value)) : - new Recorded(ticks, Notification.createOnNext(value)); - }, - /** - * Factory method for an OnError notification record at a given time with a given error. - * - * 1 - ReactiveTest.onNext(200, new Error('error')); - * 2 - ReactiveTest.onNext(200, function (e) { return e.message === 'error'; }); - * - * @param ticks Recorded virtual time the OnError notification occurs. - * @param exception Recorded exception stored in the OnError notification. - * @return Recorded OnError notification. - */ - onError: function (ticks, error) { - return typeof error === 'function' ? - new Recorded(ticks, new OnErrorPredicate(error)) : - new Recorded(ticks, Notification.createOnError(error)); - }, - /** - * Factory method for an OnCompleted notification record at a given time. - * - * @param ticks Recorded virtual time the OnCompleted notification occurs. - * @return Recorded OnCompleted notification. - */ - onCompleted: function (ticks) { - return new Recorded(ticks, Notification.createOnCompleted()); - }, - /** - * Factory method for a subscription record based on a given subscription and disposal time. - * - * @param start Virtual time indicating when the subscription was created. - * @param end Virtual time indicating when the subscription was disposed. - * @return Subscription object. - */ - subscribe: function (start, end) { - return new Subscription(start, end); - } -}; - - /** - * Creates a new object recording the production of the specified value at the given virtual time. - * - * @constructor - * @param {Number} time Virtual time the value was produced on. - * @param {Mixed} value Value that was produced. - * @param {Function} comparer An optional comparer. - */ - var Recorded = Rx.Recorded = function (time, value, comparer) { - this.time = time; - this.value = value; - this.comparer = comparer || defaultComparer; - }; - - /** - * Checks whether the given recorded object is equal to the current instance. - * - * @param {Recorded} other Recorded object to check for equality. - * @returns {Boolean} true if both objects are equal; false otherwise. - */ - Recorded.prototype.equals = function (other) { - return this.time === other.time && this.comparer(this.value, other.value); - }; - - /** - * Returns a string representation of the current Recorded value. - * - * @returns {String} String representation of the current Recorded value. - */ - Recorded.prototype.toString = function () { - return this.value.toString() + '@' + this.time; - }; - - /** - * Creates a new subscription object with the given virtual subscription and unsubscription time. - * - * @constructor - * @param {Number} subscribe Virtual time at which the subscription occurred. - * @param {Number} unsubscribe Virtual time at which the unsubscription occurred. - */ - var Subscription = Rx.Subscription = function (start, end) { - this.subscribe = start; - this.unsubscribe = end || Number.MAX_VALUE; - }; - - /** - * Checks whether the given subscription is equal to the current instance. - * @param other Subscription object to check for equality. - * @returns {Boolean} true if both objects are equal; false otherwise. - */ - Subscription.prototype.equals = function (other) { - return this.subscribe === other.subscribe && this.unsubscribe === other.unsubscribe; - }; - - /** - * Returns a string representation of the current Subscription value. - * @returns {String} String representation of the current Subscription value. - */ - Subscription.prototype.toString = function () { - return '(' + this.subscribe + ', ' + (this.unsubscribe === Number.MAX_VALUE ? 'Infinite' : this.unsubscribe) + ')'; - }; - - var MockDisposable = Rx.MockDisposable = function (scheduler) { - this.scheduler = scheduler; - this.disposes = []; - this.disposes.push(this.scheduler.clock); - }; - - MockDisposable.prototype.dispose = function () { - this.disposes.push(this.scheduler.clock); - }; - - var MockObserver = (function (__super__) { - inherits(MockObserver, __super__); - - function MockObserver(scheduler) { - __super__.call(this); - this.scheduler = scheduler; - this.messages = []; - } - - var MockObserverPrototype = MockObserver.prototype; - - MockObserverPrototype.onNext = function (value) { - this.messages.push(new Recorded(this.scheduler.clock, Notification.createOnNext(value))); - }; - - MockObserverPrototype.onError = function (e) { - this.messages.push(new Recorded(this.scheduler.clock, Notification.createOnError(e))); - }; - - MockObserverPrototype.onCompleted = function () { - this.messages.push(new Recorded(this.scheduler.clock, Notification.createOnCompleted())); - }; - - return MockObserver; - })(Observer); - - function MockPromise(scheduler, messages) { - var self = this; - this.scheduler = scheduler; - this.messages = messages; - this.subscriptions = []; - this.observers = []; - for (var i = 0, len = this.messages.length; i < len; i++) { - var message = this.messages[i], - notification = message.value; - (function (innerNotification) { - scheduler.scheduleAbsolute(null, message.time, function () { - var obs = self.observers.slice(0); - - for (var j = 0, jLen = obs.length; j < jLen; j++) { - innerNotification.accept(obs[j]); - } - return disposableEmpty; - }); - })(notification); - } - } - - MockPromise.prototype.then = function (onResolved, onRejected) { - var self = this; - - this.subscriptions.push(new Subscription(this.scheduler.clock)); - var index = this.subscriptions.length - 1; - - var newPromise; - - var observer = Rx.Observer.create( - function (x) { - var retValue = onResolved(x); - if (retValue && typeof retValue.then === 'function') { - newPromise = retValue; - } else { - var ticks = self.scheduler.clock; - newPromise = new MockPromise(self.scheduler, [Rx.ReactiveTest.onNext(ticks, undefined), Rx.ReactiveTest.onCompleted(ticks)]); - } - var idx = self.observers.indexOf(observer); - self.observers.splice(idx, 1); - self.subscriptions[index] = new Subscription(self.subscriptions[index].subscribe, self.scheduler.clock); - }, - function (err) { - onRejected(err); - var idx = self.observers.indexOf(observer); - self.observers.splice(idx, 1); - self.subscriptions[index] = new Subscription(self.subscriptions[index].subscribe, self.scheduler.clock); - } - ); - this.observers.push(observer); - - return newPromise || new MockPromise(this.scheduler, this.messages); - }; - - var HotObservable = (function (__super__) { - inherits(HotObservable, __super__); - - function HotObservable(scheduler, messages) { - __super__.call(this); - var message, notification, observable = this; - this.scheduler = scheduler; - this.messages = messages; - this.subscriptions = []; - this.observers = []; - for (var i = 0, len = this.messages.length; i < len; i++) { - message = this.messages[i]; - notification = message.value; - (function (innerNotification) { - scheduler.scheduleAbsolute(null, message.time, function () { - var obs = observable.observers.slice(0); - - for (var j = 0, jLen = obs.length; j < jLen; j++) { - innerNotification.accept(obs[j]); - } - return disposableEmpty; - }); - })(notification); - } - } - - HotObservable.prototype._subscribe = function (o) { - var observable = this; - this.observers.push(o); - this.subscriptions.push(new Subscription(this.scheduler.clock)); - var index = this.subscriptions.length - 1; - return disposableCreate(function () { - var idx = observable.observers.indexOf(o); - observable.observers.splice(idx, 1); - observable.subscriptions[index] = new Subscription(observable.subscriptions[index].subscribe, observable.scheduler.clock); - }); - }; - - return HotObservable; - })(Observable); - - var ColdObservable = (function (__super__) { - inherits(ColdObservable, __super__); - - function ColdObservable(scheduler, messages) { - __super__.call(this); - this.scheduler = scheduler; - this.messages = messages; - this.subscriptions = []; - } - - ColdObservable.prototype._subscribe = function (o) { - var message, notification, observable = this; - this.subscriptions.push(new Subscription(this.scheduler.clock)); - var index = this.subscriptions.length - 1; - var d = new CompositeDisposable(); - for (var i = 0, len = this.messages.length; i < len; i++) { - message = this.messages[i]; - notification = message.value; - (function (innerNotification) { - d.add(observable.scheduler.scheduleRelative(null, message.time, function () { - innerNotification.accept(o); - return disposableEmpty; - })); - })(notification); - } - return disposableCreate(function () { - observable.subscriptions[index] = new Subscription(observable.subscriptions[index].subscribe, observable.scheduler.clock); - d.dispose(); - }); - }; - - return ColdObservable; - })(Observable); - - /** Virtual time scheduler used for testing applications and libraries built using Reactive Extensions. */ - Rx.TestScheduler = (function (__super__) { - inherits(TestScheduler, __super__); - - function baseComparer(x, y) { - return x > y ? 1 : (x < y ? -1 : 0); - } - - function TestScheduler() { - __super__.call(this, 0, baseComparer); - } - - /** - * Schedules an action to be executed at the specified virtual time. - * - * @param state State passed to the action to be executed. - * @param dueTime Absolute virtual time at which to execute the action. - * @param action Action to be executed. - * @return Disposable object used to cancel the scheduled action (best effort). - */ - TestScheduler.prototype.scheduleAbsolute = function (state, dueTime, action) { - dueTime <= this.clock && (dueTime = this.clock + 1); - return __super__.prototype.scheduleAbsolute.call(this, state, dueTime, action); - }; - /** - * Adds a relative virtual time to an absolute virtual time value. - * - * @param absolute Absolute virtual time value. - * @param relative Relative virtual time value to add. - * @return Resulting absolute virtual time sum value. - */ - TestScheduler.prototype.add = function (absolute, relative) { - return absolute + relative; - }; - /** - * Converts the absolute virtual time value to a DateTimeOffset value. - * - * @param absolute Absolute virtual time value to convert. - * @return Corresponding DateTimeOffset value. - */ - TestScheduler.prototype.toAbsoluteTime = function (absolute) { - return new Date(absolute).getTime(); - }; - /** - * Converts the TimeSpan value to a relative virtual time value. - * - * @param timeSpan TimeSpan value to convert. - * @return Corresponding relative virtual time value. - */ - TestScheduler.prototype.toRelativeTime = function (timeSpan) { - return timeSpan; - }; - /** - * Starts the test scheduler and uses the specified virtual times to invoke the factory function, subscribe to the resulting sequence, and dispose the subscription. - * - * @param create Factory method to create an observable sequence. - * @param created Virtual time at which to invoke the factory to create an observable sequence. - * @param subscribed Virtual time at which to subscribe to the created observable sequence. - * @param disposed Virtual time at which to dispose the subscription. - * @return Observer with timestamped recordings of notification messages that were received during the virtual time window when the subscription to the source sequence was active. - */ - TestScheduler.prototype.startScheduler = function (createFn, settings) { - settings || (settings = {}); - settings.created == null && (settings.created = ReactiveTest.created); - settings.subscribed == null && (settings.subscribed = ReactiveTest.subscribed); - settings.disposed == null && (settings.disposed = ReactiveTest.disposed); - - var observer = this.createObserver(), source, subscription; - - this.scheduleAbsolute(null, settings.created, function () { - source = createFn(); - return disposableEmpty; - }); - - this.scheduleAbsolute(null, settings.subscribed, function () { - subscription = source.subscribe(observer); - return disposableEmpty; - }); - - this.scheduleAbsolute(null, settings.disposed, function () { - subscription.dispose(); - return disposableEmpty; - }); - - this.start(); - - return observer; - }; - - /** - * Creates a hot observable using the specified timestamped notification messages either as an array or arguments. - * @param messages Notifications to surface through the created sequence at their specified absolute virtual times. - * @return Hot observable sequence that can be used to assert the timing of subscriptions and notifications. - */ - TestScheduler.prototype.createHotObservable = function () { - var len = arguments.length, args; - if (Array.isArray(arguments[0])) { - args = arguments[0]; - } else { - args = new Array(len); - for (var i = 0; i < len; i++) { args[i] = arguments[i]; } - } - return new HotObservable(this, args); - }; - - /** - * Creates a cold observable using the specified timestamped notification messages either as an array or arguments. - * @param messages Notifications to surface through the created sequence at their specified virtual time offsets from the sequence subscription time. - * @return Cold observable sequence that can be used to assert the timing of subscriptions and notifications. - */ - TestScheduler.prototype.createColdObservable = function () { - var len = arguments.length, args; - if (Array.isArray(arguments[0])) { - args = arguments[0]; - } else { - args = new Array(len); - for (var i = 0; i < len; i++) { args[i] = arguments[i]; } - } - return new ColdObservable(this, args); - }; - - /** - * Creates a resolved promise with the given value and ticks - * @param {Number} ticks The absolute time of the resolution. - * @param {Any} value The value to yield at the given tick. - * @returns {MockPromise} A mock Promise which fulfills with the given value. - */ - TestScheduler.prototype.createResolvedPromise = function (ticks, value) { - return new MockPromise(this, [Rx.ReactiveTest.onNext(ticks, value), Rx.ReactiveTest.onCompleted(ticks)]); - }; - - /** - * Creates a rejected promise with the given reason and ticks - * @param {Number} ticks The absolute time of the resolution. - * @param {Any} reason The reason for rejection to yield at the given tick. - * @returns {MockPromise} A mock Promise which rejects with the given reason. - */ - TestScheduler.prototype.createRejectedPromise = function (ticks, reason) { - return new MockPromise(this, [Rx.ReactiveTest.onError(ticks, reason)]); - }; - - /** - * Creates an observer that records received notification messages and timestamps those. - * @return Observer that can be used to assert the timing of received notifications. - */ - TestScheduler.prototype.createObserver = function () { - return new MockObserver(this); - }; - - return TestScheduler; - })(VirtualTimeScheduler); - - return Rx; -})); - - -/***/ }), -/* 15 */ -/***/ (function(module, exports, __webpack_require__) { - -/* module decorator */ module = __webpack_require__.nmd(module); -var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Copyright (c) Microsoft, All rights reserved. See License.txt in the project root for license information. - -;(function (factory) { - var objectTypes = { - 'function': true, - 'object': true - }; - - function checkGlobal(value) { - return (value && value.Object === Object) ? value : null; - } - - var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType) ? exports : null; - var freeModule = (objectTypes["object"] && module && !module.nodeType) ? module : null; - var freeGlobal = checkGlobal(freeExports && freeModule && typeof global === 'object' && global); - var freeSelf = checkGlobal(objectTypes[typeof self] && self); - var freeWindow = checkGlobal(objectTypes[typeof window] && window); - var moduleExports = (freeModule && freeModule.exports === freeExports) ? freeExports : null; - var thisGlobal = checkGlobal(objectTypes[typeof this] && this); - var root = freeGlobal || ((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) || freeSelf || thisGlobal || Function('return this')(); - - // Because of build optimizers - if (true) { - !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(4)], __WEBPACK_AMD_DEFINE_RESULT__ = (function (Rx, exports) { - return factory(root, exports, Rx); - }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), - __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); - } else {} -}.call(this, function (root, exp, Rx, undefined) { - - // Refernces - var inherits = Rx.internals.inherits, - AbstractObserver = Rx.internals.AbstractObserver, - Observable = Rx.Observable, - observableProto = Observable.prototype, - AnonymousObservable = Rx.AnonymousObservable, - ObservableBase = Rx.ObservableBase, - observableDefer = Observable.defer, - observableEmpty = Observable.empty, - observableNever = Observable.never, - observableThrow = Observable['throw'], - observableFromArray = Observable.fromArray, - defaultScheduler = Rx.Scheduler['default'], - SingleAssignmentDisposable = Rx.SingleAssignmentDisposable, - SerialDisposable = Rx.SerialDisposable, - CompositeDisposable = Rx.CompositeDisposable, - BinaryDisposable = Rx.BinaryDisposable, - RefCountDisposable = Rx.RefCountDisposable, - Subject = Rx.Subject, - addRef = Rx.internals.addRef, - normalizeTime = Rx.Scheduler.normalize, - helpers = Rx.helpers, - isPromise = helpers.isPromise, - isFunction = helpers.isFunction, - isScheduler = Rx.Scheduler.isScheduler, - observableFromPromise = Observable.fromPromise; - - var errorObj = {e: {}}; - - function tryCatcherGen(tryCatchTarget) { - return function tryCatcher() { - try { - return tryCatchTarget.apply(this, arguments); - } catch (e) { - errorObj.e = e; - return errorObj; - } - }; - } - - var tryCatch = Rx.internals.tryCatch = function tryCatch(fn) { - if (!isFunction(fn)) { throw new TypeError('fn must be a function'); } - return tryCatcherGen(fn); - }; - - function thrower(e) { - throw e; - } - - var TimerObservable = (function(__super__) { - inherits(TimerObservable, __super__); - function TimerObservable(dt, s) { - this._dt = dt; - this._s = s; - __super__.call(this); - } - - TimerObservable.prototype.subscribeCore = function (o) { - return this._s.scheduleFuture(o, this._dt, scheduleMethod); - }; - - function scheduleMethod(s, o) { - o.onNext(0); - o.onCompleted(); - } - - return TimerObservable; - }(ObservableBase)); - - function _observableTimer(dueTime, scheduler) { - return new TimerObservable(dueTime, scheduler); - } - - function observableTimerDateAndPeriod(dueTime, period, scheduler) { - return new AnonymousObservable(function (observer) { - var d = dueTime, p = normalizeTime(period); - return scheduler.scheduleRecursiveFuture(0, d, function (count, self) { - if (p > 0) { - var now = scheduler.now(); - d = new Date(d.getTime() + p); - d.getTime() <= now && (d = new Date(now + p)); - } - observer.onNext(count); - self(count + 1, new Date(d)); - }); - }); - } - - function observableTimerTimeSpanAndPeriod(dueTime, period, scheduler) { - return dueTime === period ? - new AnonymousObservable(function (observer) { - return scheduler.schedulePeriodic(0, period, function (count) { - observer.onNext(count); - return count + 1; - }); - }) : - observableDefer(function () { - return observableTimerDateAndPeriod(new Date(scheduler.now() + dueTime), period, scheduler); - }); - } - - /** - * Returns an observable sequence that produces a value after each period. - * - * @example - * 1 - res = Rx.Observable.interval(1000); - * 2 - res = Rx.Observable.interval(1000, Rx.Scheduler.timeout); - * - * @param {Number} period Period for producing the values in the resulting sequence (specified as an integer denoting milliseconds). - * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, Rx.Scheduler.timeout is used. - * @returns {Observable} An observable sequence that produces a value after each period. - */ - var observableinterval = Observable.interval = function (period, scheduler) { - return observableTimerTimeSpanAndPeriod(period, period, isScheduler(scheduler) ? scheduler : defaultScheduler); - }; - - /** - * Returns an observable sequence that produces a value after dueTime has elapsed and then after each period. - * @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) at which to produce the first value. - * @param {Mixed} [periodOrScheduler] Period to produce subsequent values (specified as an integer denoting milliseconds), or the scheduler to run the timer on. If not specified, the resulting timer is not recurring. - * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, the timeout scheduler is used. - * @returns {Observable} An observable sequence that produces a value after due time has elapsed and then each period. - */ - var observableTimer = Observable.timer = function (dueTime, periodOrScheduler, scheduler) { - var period; - isScheduler(scheduler) || (scheduler = defaultScheduler); - if (periodOrScheduler != null && typeof periodOrScheduler === 'number') { - period = periodOrScheduler; - } else if (isScheduler(periodOrScheduler)) { - scheduler = periodOrScheduler; - } - if ((dueTime instanceof Date || typeof dueTime === 'number') && period === undefined) { - return _observableTimer(dueTime, scheduler); - } - if (dueTime instanceof Date && period !== undefined) { - return observableTimerDateAndPeriod(dueTime, periodOrScheduler, scheduler); - } - return observableTimerTimeSpanAndPeriod(dueTime, period, scheduler); - }; - - function observableDelayRelative(source, dueTime, scheduler) { - return new AnonymousObservable(function (o) { - var active = false, - cancelable = new SerialDisposable(), - exception = null, - q = [], - running = false, - subscription; - subscription = source.materialize().timestamp(scheduler).subscribe(function (notification) { - var d, shouldRun; - if (notification.value.kind === 'E') { - q = []; - q.push(notification); - exception = notification.value.error; - shouldRun = !running; - } else { - q.push({ value: notification.value, timestamp: notification.timestamp + dueTime }); - shouldRun = !active; - active = true; - } - if (shouldRun) { - if (exception !== null) { - o.onError(exception); - } else { - d = new SingleAssignmentDisposable(); - cancelable.setDisposable(d); - d.setDisposable(scheduler.scheduleRecursiveFuture(null, dueTime, function (_, self) { - var e, recurseDueTime, result, shouldRecurse; - if (exception !== null) { - return; - } - running = true; - do { - result = null; - if (q.length > 0 && q[0].timestamp - scheduler.now() <= 0) { - result = q.shift().value; - } - if (result !== null) { - result.accept(o); - } - } while (result !== null); - shouldRecurse = false; - recurseDueTime = 0; - if (q.length > 0) { - shouldRecurse = true; - recurseDueTime = Math.max(0, q[0].timestamp - scheduler.now()); - } else { - active = false; - } - e = exception; - running = false; - if (e !== null) { - o.onError(e); - } else if (shouldRecurse) { - self(null, recurseDueTime); - } - })); - } - } - }); - return new BinaryDisposable(subscription, cancelable); - }, source); - } - - function observableDelayAbsolute(source, dueTime, scheduler) { - return observableDefer(function () { - return observableDelayRelative(source, dueTime - scheduler.now(), scheduler); - }); - } - - function delayWithSelector(source, subscriptionDelay, delayDurationSelector) { - var subDelay, selector; - if (isFunction(subscriptionDelay)) { - selector = subscriptionDelay; - } else { - subDelay = subscriptionDelay; - selector = delayDurationSelector; - } - return new AnonymousObservable(function (o) { - var delays = new CompositeDisposable(), atEnd = false, subscription = new SerialDisposable(); - - function start() { - subscription.setDisposable(source.subscribe( - function (x) { - var delay = tryCatch(selector)(x); - if (delay === errorObj) { return o.onError(delay.e); } - var d = new SingleAssignmentDisposable(); - delays.add(d); - d.setDisposable(delay.subscribe( - function () { - o.onNext(x); - delays.remove(d); - done(); - }, - function (e) { o.onError(e); }, - function () { - o.onNext(x); - delays.remove(d); - done(); - } - )); - }, - function (e) { o.onError(e); }, - function () { - atEnd = true; - subscription.dispose(); - done(); - } - )); - } - - function done () { - atEnd && delays.length === 0 && o.onCompleted(); - } - - if (!subDelay) { - start(); - } else { - subscription.setDisposable(subDelay.subscribe(start, function (e) { o.onError(e); }, start)); - } - - return new BinaryDisposable(subscription, delays); - }, source); - } - - /** - * Time shifts the observable sequence by dueTime. - * The relative time intervals between the values are preserved. - * - * @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) by which to shift the observable sequence. - * @param {Scheduler} [scheduler] Scheduler to run the delay timers on. If not specified, the timeout scheduler is used. - * @returns {Observable} Time-shifted sequence. - */ - observableProto.delay = function () { - var firstArg = arguments[0]; - if (typeof firstArg === 'number' || firstArg instanceof Date) { - var dueTime = firstArg, scheduler = arguments[1]; - isScheduler(scheduler) || (scheduler = defaultScheduler); - return dueTime instanceof Date ? - observableDelayAbsolute(this, dueTime, scheduler) : - observableDelayRelative(this, dueTime, scheduler); - } else if (Observable.isObservable(firstArg) || isFunction(firstArg)) { - return delayWithSelector(this, firstArg, arguments[1]); - } else { - throw new Error('Invalid arguments'); - } - }; - - var DebounceObservable = (function (__super__) { - inherits(DebounceObservable, __super__); - function DebounceObservable(source, dt, s) { - isScheduler(s) || (s = defaultScheduler); - this.source = source; - this._dt = dt; - this._s = s; - __super__.call(this); - } - - DebounceObservable.prototype.subscribeCore = function (o) { - var cancelable = new SerialDisposable(); - return new BinaryDisposable( - this.source.subscribe(new DebounceObserver(o, this._dt, this._s, cancelable)), - cancelable); - }; - - return DebounceObservable; - }(ObservableBase)); - - var DebounceObserver = (function (__super__) { - inherits(DebounceObserver, __super__); - function DebounceObserver(observer, dueTime, scheduler, cancelable) { - this._o = observer; - this._d = dueTime; - this._scheduler = scheduler; - this._c = cancelable; - this._v = null; - this._hv = false; - this._id = 0; - __super__.call(this); - } - - function scheduleFuture(s, state) { - state.self._hv && state.self._id === state.currentId && state.self._o.onNext(state.x); - state.self._hv = false; - } - - DebounceObserver.prototype.next = function (x) { - this._hv = true; - this._v = x; - var currentId = ++this._id, d = new SingleAssignmentDisposable(); - this._c.setDisposable(d); - d.setDisposable(this._scheduler.scheduleFuture(this, this._d, function (_, self) { - self._hv && self._id === currentId && self._o.onNext(x); - self._hv = false; - })); - }; - - DebounceObserver.prototype.error = function (e) { - this._c.dispose(); - this._o.onError(e); - this._hv = false; - this._id++; - }; - - DebounceObserver.prototype.completed = function () { - this._c.dispose(); - this._hv && this._o.onNext(this._v); - this._o.onCompleted(); - this._hv = false; - this._id++; - }; - - return DebounceObserver; - }(AbstractObserver)); - - function debounceWithSelector(source, durationSelector) { - return new AnonymousObservable(function (o) { - var value, hasValue = false, cancelable = new SerialDisposable(), id = 0; - var subscription = source.subscribe( - function (x) { - var throttle = tryCatch(durationSelector)(x); - if (throttle === errorObj) { return o.onError(throttle.e); } - - isPromise(throttle) && (throttle = observableFromPromise(throttle)); - - hasValue = true; - value = x; - id++; - var currentid = id, d = new SingleAssignmentDisposable(); - cancelable.setDisposable(d); - d.setDisposable(throttle.subscribe( - function () { - hasValue && id === currentid && o.onNext(value); - hasValue = false; - d.dispose(); - }, - function (e) { o.onError(e); }, - function () { - hasValue && id === currentid && o.onNext(value); - hasValue = false; - d.dispose(); - } - )); - }, - function (e) { - cancelable.dispose(); - o.onError(e); - hasValue = false; - id++; - }, - function () { - cancelable.dispose(); - hasValue && o.onNext(value); - o.onCompleted(); - hasValue = false; - id++; - } - ); - return new BinaryDisposable(subscription, cancelable); - }, source); - } - - observableProto.debounce = function () { - if (isFunction (arguments[0])) { - return debounceWithSelector(this, arguments[0]); - } else if (typeof arguments[0] === 'number') { - return new DebounceObservable(this, arguments[0], arguments[1]); - } else { - throw new Error('Invalid arguments'); - } - }; - - /** - * Projects each element of an observable sequence into zero or more windows which are produced based on timing information. - * @param {Number} timeSpan Length of each window (specified as an integer denoting milliseconds). - * @param {Mixed} [timeShiftOrScheduler] Interval between creation of consecutive windows (specified as an integer denoting milliseconds), or an optional scheduler parameter. If not specified, the time shift corresponds to the timeSpan parameter, resulting in non-overlapping adjacent windows. - * @param {Scheduler} [scheduler] Scheduler to run windowing timers on. If not specified, the timeout scheduler is used. - * @returns {Observable} An observable sequence of windows. - */ - observableProto.windowWithTime = observableProto.windowTime = function (timeSpan, timeShiftOrScheduler, scheduler) { - var source = this, timeShift; - timeShiftOrScheduler == null && (timeShift = timeSpan); - isScheduler(scheduler) || (scheduler = defaultScheduler); - if (typeof timeShiftOrScheduler === 'number') { - timeShift = timeShiftOrScheduler; - } else if (isScheduler(timeShiftOrScheduler)) { - timeShift = timeSpan; - scheduler = timeShiftOrScheduler; - } - return new AnonymousObservable(function (observer) { - var groupDisposable, - nextShift = timeShift, - nextSpan = timeSpan, - q = [], - refCountDisposable, - timerD = new SerialDisposable(), - totalTime = 0; - groupDisposable = new CompositeDisposable(timerD), - refCountDisposable = new RefCountDisposable(groupDisposable); - - function createTimer () { - var m = new SingleAssignmentDisposable(), - isSpan = false, - isShift = false; - timerD.setDisposable(m); - if (nextSpan === nextShift) { - isSpan = true; - isShift = true; - } else if (nextSpan < nextShift) { - isSpan = true; - } else { - isShift = true; - } - var newTotalTime = isSpan ? nextSpan : nextShift, - ts = newTotalTime - totalTime; - totalTime = newTotalTime; - if (isSpan) { - nextSpan += timeShift; - } - if (isShift) { - nextShift += timeShift; - } - m.setDisposable(scheduler.scheduleFuture(null, ts, function () { - if (isShift) { - var s = new Subject(); - q.push(s); - observer.onNext(addRef(s, refCountDisposable)); - } - isSpan && q.shift().onCompleted(); - createTimer(); - })); - }; - q.push(new Subject()); - observer.onNext(addRef(q[0], refCountDisposable)); - createTimer(); - groupDisposable.add(source.subscribe( - function (x) { - for (var i = 0, len = q.length; i < len; i++) { q[i].onNext(x); } - }, - function (e) { - for (var i = 0, len = q.length; i < len; i++) { q[i].onError(e); } - observer.onError(e); - }, - function () { - for (var i = 0, len = q.length; i < len; i++) { q[i].onCompleted(); } - observer.onCompleted(); - } - )); - return refCountDisposable; - }, source); - }; - - /** - * Projects each element of an observable sequence into a window that is completed when either it's full or a given amount of time has elapsed. - * @param {Number} timeSpan Maximum time length of a window. - * @param {Number} count Maximum element count of a window. - * @param {Scheduler} [scheduler] Scheduler to run windowing timers on. If not specified, the timeout scheduler is used. - * @returns {Observable} An observable sequence of windows. - */ - observableProto.windowWithTimeOrCount = observableProto.windowTimeOrCount = function (timeSpan, count, scheduler) { - var source = this; - isScheduler(scheduler) || (scheduler = defaultScheduler); - return new AnonymousObservable(function (observer) { - var timerD = new SerialDisposable(), - groupDisposable = new CompositeDisposable(timerD), - refCountDisposable = new RefCountDisposable(groupDisposable), - n = 0, - windowId = 0, - s = new Subject(); - - function createTimer(id) { - var m = new SingleAssignmentDisposable(); - timerD.setDisposable(m); - m.setDisposable(scheduler.scheduleFuture(null, timeSpan, function () { - if (id !== windowId) { return; } - n = 0; - var newId = ++windowId; - s.onCompleted(); - s = new Subject(); - observer.onNext(addRef(s, refCountDisposable)); - createTimer(newId); - })); - } - - observer.onNext(addRef(s, refCountDisposable)); - createTimer(0); - - groupDisposable.add(source.subscribe( - function (x) { - var newId = 0, newWindow = false; - s.onNext(x); - if (++n === count) { - newWindow = true; - n = 0; - newId = ++windowId; - s.onCompleted(); - s = new Subject(); - observer.onNext(addRef(s, refCountDisposable)); - } - newWindow && createTimer(newId); - }, - function (e) { - s.onError(e); - observer.onError(e); - }, function () { - s.onCompleted(); - observer.onCompleted(); - } - )); - return refCountDisposable; - }, source); - }; - - function toArray(x) { return x.toArray(); } - - /** - * Projects each element of an observable sequence into zero or more buffers which are produced based on timing information. - * @param {Number} timeSpan Length of each buffer (specified as an integer denoting milliseconds). - * @param {Mixed} [timeShiftOrScheduler] Interval between creation of consecutive buffers (specified as an integer denoting milliseconds), or an optional scheduler parameter. If not specified, the time shift corresponds to the timeSpan parameter, resulting in non-overlapping adjacent buffers. - * @param {Scheduler} [scheduler] Scheduler to run buffer timers on. If not specified, the timeout scheduler is used. - * @returns {Observable} An observable sequence of buffers. - */ - observableProto.bufferWithTime = observableProto.bufferTime = function (timeSpan, timeShiftOrScheduler, scheduler) { - return this.windowWithTime(timeSpan, timeShiftOrScheduler, scheduler).flatMap(toArray); - }; - - function toArray(x) { return x.toArray(); } - - /** - * Projects each element of an observable sequence into a buffer that is completed when either it's full or a given amount of time has elapsed. - * @param {Number} timeSpan Maximum time length of a buffer. - * @param {Number} count Maximum element count of a buffer. - * @param {Scheduler} [scheduler] Scheduler to run bufferin timers on. If not specified, the timeout scheduler is used. - * @returns {Observable} An observable sequence of buffers. - */ - observableProto.bufferWithTimeOrCount = observableProto.bufferTimeOrCount = function (timeSpan, count, scheduler) { - return this.windowWithTimeOrCount(timeSpan, count, scheduler).flatMap(toArray); - }; - - var TimeIntervalObservable = (function (__super__) { - inherits(TimeIntervalObservable, __super__); - function TimeIntervalObservable(source, s) { - this.source = source; - this._s = s; - __super__.call(this); - } - - TimeIntervalObservable.prototype.subscribeCore = function (o) { - return this.source.subscribe(new TimeIntervalObserver(o, this._s)); - }; - - return TimeIntervalObservable; - }(ObservableBase)); - - var TimeIntervalObserver = (function (__super__) { - inherits(TimeIntervalObserver, __super__); - - function TimeIntervalObserver(o, s) { - this._o = o; - this._s = s; - this._l = s.now(); - __super__.call(this); - } - - TimeIntervalObserver.prototype.next = function (x) { - var now = this._s.now(), span = now - this._l; - this._l = now; - this._o.onNext({ value: x, interval: span }); - }; - TimeIntervalObserver.prototype.error = function (e) { this._o.onError(e); }; - TimeIntervalObserver.prototype.completed = function () { this._o.onCompleted(); }; - - return TimeIntervalObserver; - }(AbstractObserver)); - - /** - * Records the time interval between consecutive values in an observable sequence. - * - * @example - * 1 - res = source.timeInterval(); - * 2 - res = source.timeInterval(Rx.Scheduler.timeout); - * - * @param [scheduler] Scheduler used to compute time intervals. If not specified, the timeout scheduler is used. - * @returns {Observable} An observable sequence with time interval information on values. - */ - observableProto.timeInterval = function (scheduler) { - isScheduler(scheduler) || (scheduler = defaultScheduler); - return new TimeIntervalObservable(this, scheduler); - }; - - var TimestampObservable = (function (__super__) { - inherits(TimestampObservable, __super__); - function TimestampObservable(source, s) { - this.source = source; - this._s = s; - __super__.call(this); - } - - TimestampObservable.prototype.subscribeCore = function (o) { - return this.source.subscribe(new TimestampObserver(o, this._s)); - }; - - return TimestampObservable; - }(ObservableBase)); - - var TimestampObserver = (function (__super__) { - inherits(TimestampObserver, __super__); - function TimestampObserver(o, s) { - this._o = o; - this._s = s; - __super__.call(this); - } - - TimestampObserver.prototype.next = function (x) { - this._o.onNext({ value: x, timestamp: this._s.now() }); - }; - - TimestampObserver.prototype.error = function (e) { - this._o.onError(e); - }; - - TimestampObserver.prototype.completed = function () { - this._o.onCompleted(); - }; - - return TimestampObserver; - }(AbstractObserver)); - - /** - * Records the timestamp for each value in an observable sequence. - * - * @example - * 1 - res = source.timestamp(); // produces { value: x, timestamp: ts } - * 2 - res = source.timestamp(Rx.Scheduler.default); - * - * @param {Scheduler} [scheduler] Scheduler used to compute timestamps. If not specified, the default scheduler is used. - * @returns {Observable} An observable sequence with timestamp information on values. - */ - observableProto.timestamp = function (scheduler) { - isScheduler(scheduler) || (scheduler = defaultScheduler); - return new TimestampObservable(this, scheduler); - }; - - var SampleObservable = (function(__super__) { - inherits(SampleObservable, __super__); - function SampleObservable(source, sampler) { - this.source = source; - this._sampler = sampler; - __super__.call(this); - } - - SampleObservable.prototype.subscribeCore = function (o) { - var state = { - o: o, - atEnd: false, - value: null, - hasValue: false, - sourceSubscription: new SingleAssignmentDisposable() - }; - - state.sourceSubscription.setDisposable(this.source.subscribe(new SampleSourceObserver(state))); - return new BinaryDisposable( - state.sourceSubscription, - this._sampler.subscribe(new SamplerObserver(state)) - ); - }; - - return SampleObservable; - }(ObservableBase)); - - var SamplerObserver = (function(__super__) { - inherits(SamplerObserver, __super__); - function SamplerObserver(s) { - this._s = s; - __super__.call(this); - } - - SamplerObserver.prototype._handleMessage = function () { - if (this._s.hasValue) { - this._s.hasValue = false; - this._s.o.onNext(this._s.value); - } - this._s.atEnd && this._s.o.onCompleted(); - }; - - SamplerObserver.prototype.next = function () { this._handleMessage(); }; - SamplerObserver.prototype.error = function (e) { this._s.onError(e); }; - SamplerObserver.prototype.completed = function () { this._handleMessage(); }; - - return SamplerObserver; - }(AbstractObserver)); - - var SampleSourceObserver = (function(__super__) { - inherits(SampleSourceObserver, __super__); - function SampleSourceObserver(s) { - this._s = s; - __super__.call(this); - } - - SampleSourceObserver.prototype.next = function (x) { - this._s.hasValue = true; - this._s.value = x; - }; - SampleSourceObserver.prototype.error = function (e) { this._s.o.onError(e); }; - SampleSourceObserver.prototype.completed = function () { - this._s.atEnd = true; - this._s.sourceSubscription.dispose(); - }; - - return SampleSourceObserver; - }(AbstractObserver)); - - /** - * Samples the observable sequence at each interval. - * - * @example - * 1 - res = source.sample(sampleObservable); // Sampler tick sequence - * 2 - res = source.sample(5000); // 5 seconds - * 2 - res = source.sample(5000, Rx.Scheduler.timeout); // 5 seconds - * - * @param {Mixed} intervalOrSampler Interval at which to sample (specified as an integer denoting milliseconds) or Sampler Observable. - * @param {Scheduler} [scheduler] Scheduler to run the sampling timer on. If not specified, the timeout scheduler is used. - * @returns {Observable} Sampled observable sequence. - */ - observableProto.sample = function (intervalOrSampler, scheduler) { - isScheduler(scheduler) || (scheduler = defaultScheduler); - return typeof intervalOrSampler === 'number' ? - new SampleObservable(this, observableinterval(intervalOrSampler, scheduler)) : - new SampleObservable(this, intervalOrSampler); - }; - - var TimeoutError = Rx.TimeoutError = function(message) { - this.message = message || 'Timeout has occurred'; - this.name = 'TimeoutError'; - Error.call(this); - }; - TimeoutError.prototype = Object.create(Error.prototype); - - function timeoutWithSelector(source, firstTimeout, timeoutDurationSelector, other) { - if (isFunction(firstTimeout)) { - other = timeoutDurationSelector; - timeoutDurationSelector = firstTimeout; - firstTimeout = observableNever(); - } - Observable.isObservable(other) || (other = observableThrow(new TimeoutError())); - return new AnonymousObservable(function (o) { - var subscription = new SerialDisposable(), - timer = new SerialDisposable(), - original = new SingleAssignmentDisposable(); - - subscription.setDisposable(original); - - var id = 0, switched = false; - - function setTimer(timeout) { - var myId = id, d = new SingleAssignmentDisposable(); - - function timerWins() { - switched = (myId === id); - return switched; - } - - timer.setDisposable(d); - d.setDisposable(timeout.subscribe(function () { - timerWins() && subscription.setDisposable(other.subscribe(o)); - d.dispose(); - }, function (e) { - timerWins() && o.onError(e); - }, function () { - timerWins() && subscription.setDisposable(other.subscribe(o)); - })); - }; - - setTimer(firstTimeout); - - function oWins() { - var res = !switched; - if (res) { id++; } - return res; - } - - original.setDisposable(source.subscribe(function (x) { - if (oWins()) { - o.onNext(x); - var timeout = tryCatch(timeoutDurationSelector)(x); - if (timeout === errorObj) { return o.onError(timeout.e); } - setTimer(isPromise(timeout) ? observableFromPromise(timeout) : timeout); - } - }, function (e) { - oWins() && o.onError(e); - }, function () { - oWins() && o.onCompleted(); - })); - return new BinaryDisposable(subscription, timer); - }, source); - } - - function timeout(source, dueTime, other, scheduler) { - if (isScheduler(other)) { - scheduler = other; - other = observableThrow(new TimeoutError()); - } - if (other instanceof Error) { other = observableThrow(other); } - isScheduler(scheduler) || (scheduler = defaultScheduler); - Observable.isObservable(other) || (other = observableThrow(new TimeoutError())); - return new AnonymousObservable(function (o) { - var id = 0, - original = new SingleAssignmentDisposable(), - subscription = new SerialDisposable(), - switched = false, - timer = new SerialDisposable(); - - subscription.setDisposable(original); - - function createTimer() { - var myId = id; - timer.setDisposable(scheduler.scheduleFuture(null, dueTime, function () { - switched = id === myId; - if (switched) { - isPromise(other) && (other = observableFromPromise(other)); - subscription.setDisposable(other.subscribe(o)); - } - })); - } - - createTimer(); - - original.setDisposable(source.subscribe(function (x) { - if (!switched) { - id++; - o.onNext(x); - createTimer(); - } - }, function (e) { - if (!switched) { - id++; - o.onError(e); - } - }, function () { - if (!switched) { - id++; - o.onCompleted(); - } - })); - return new BinaryDisposable(subscription, timer); - }, source); - } - - observableProto.timeout = function () { - var firstArg = arguments[0]; - if (firstArg instanceof Date || typeof firstArg === 'number') { - return timeout(this, firstArg, arguments[1], arguments[2]); - } else if (Observable.isObservable(firstArg) || isFunction(firstArg)) { - return timeoutWithSelector(this, firstArg, arguments[1], arguments[2]); - } else { - throw new Error('Invalid arguments'); - } - }; - - var GenerateAbsoluteObservable = (function (__super__) { - inherits(GenerateAbsoluteObservable, __super__); - function GenerateAbsoluteObservable(state, cndFn, itrFn, resFn, timeFn, s) { - this._state = state; - this._cndFn = cndFn; - this._itrFn = itrFn; - this._resFn = resFn; - this._timeFn = timeFn; - this._s = s; - __super__.call(this); - } - - function scheduleRecursive(state, recurse) { - state.hasResult && state.o.onNext(state.result); - - if (state.first) { - state.first = false; - } else { - state.newState = tryCatch(state.self._itrFn)(state.newState); - if (state.newState === errorObj) { return state.o.onError(state.newState.e); } - } - state.hasResult = tryCatch(state.self._cndFn)(state.newState); - if (state.hasResult === errorObj) { return state.o.onError(state.hasResult.e); } - if (state.hasResult) { - state.result = tryCatch(state.self._resFn)(state.newState); - if (state.result === errorObj) { return state.o.onError(state.result.e); } - var time = tryCatch(state.self._timeFn)(state.newState); - if (time === errorObj) { return state.o.onError(time.e); } - recurse(state, time); - } else { - state.o.onCompleted(); - } - } - - GenerateAbsoluteObservable.prototype.subscribeCore = function (o) { - var state = { - o: o, - self: this, - newState: this._state, - first: true, - hasResult: false - }; - return this._s.scheduleRecursiveFuture(state, new Date(this._s.now()), scheduleRecursive); - }; - - return GenerateAbsoluteObservable; - }(ObservableBase)); - - /** - * GenerateAbsolutes an observable sequence by iterating a state from an initial state until the condition fails. - * - * @example - * res = source.generateWithAbsoluteTime(0, - * function (x) { return return true; }, - * function (x) { return x + 1; }, - * function (x) { return x; }, - * function (x) { return new Date(); } - * }); - * - * @param {Mixed} initialState Initial state. - * @param {Function} condition Condition to terminate generation (upon returning false). - * @param {Function} iterate Iteration step function. - * @param {Function} resultSelector Selector function for results produced in the sequence. - * @param {Function} timeSelector Time selector function to control the speed of values being produced each iteration, returning Date values. - * @param {Scheduler} [scheduler] Scheduler on which to run the generator loop. If not specified, the timeout scheduler is used. - * @returns {Observable} The generated sequence. - */ - Observable.generateWithAbsoluteTime = function (initialState, condition, iterate, resultSelector, timeSelector, scheduler) { - isScheduler(scheduler) || (scheduler = defaultScheduler); - return new GenerateAbsoluteObservable(initialState, condition, iterate, resultSelector, timeSelector, scheduler); - }; - - var GenerateRelativeObservable = (function (__super__) { - inherits(GenerateRelativeObservable, __super__); - function GenerateRelativeObservable(state, cndFn, itrFn, resFn, timeFn, s) { - this._state = state; - this._cndFn = cndFn; - this._itrFn = itrFn; - this._resFn = resFn; - this._timeFn = timeFn; - this._s = s; - __super__.call(this); - } - - function scheduleRecursive(state, recurse) { - state.hasResult && state.o.onNext(state.result); - - if (state.first) { - state.first = false; - } else { - state.newState = tryCatch(state.self._itrFn)(state.newState); - if (state.newState === errorObj) { return state.o.onError(state.newState.e); } - } - - state.hasResult = tryCatch(state.self._cndFn)(state.newState); - if (state.hasResult === errorObj) { return state.o.onError(state.hasResult.e); } - if (state.hasResult) { - state.result = tryCatch(state.self._resFn)(state.newState); - if (state.result === errorObj) { return state.o.onError(state.result.e); } - var time = tryCatch(state.self._timeFn)(state.newState); - if (time === errorObj) { return state.o.onError(time.e); } - recurse(state, time); - } else { - state.o.onCompleted(); - } - } - - GenerateRelativeObservable.prototype.subscribeCore = function (o) { - var state = { - o: o, - self: this, - newState: this._state, - first: true, - hasResult: false - }; - return this._s.scheduleRecursiveFuture(state, 0, scheduleRecursive); - }; - - return GenerateRelativeObservable; - }(ObservableBase)); - - /** - * Generates an observable sequence by iterating a state from an initial state until the condition fails. - * - * @example - * res = source.generateWithRelativeTime(0, - * function (x) { return return true; }, - * function (x) { return x + 1; }, - * function (x) { return x; }, - * function (x) { return 500; } - * ); - * - * @param {Mixed} initialState Initial state. - * @param {Function} condition Condition to terminate generation (upon returning false). - * @param {Function} iterate Iteration step function. - * @param {Function} resultSelector Selector function for results produced in the sequence. - * @param {Function} timeSelector Time selector function to control the speed of values being produced each iteration, returning integer values denoting milliseconds. - * @param {Scheduler} [scheduler] Scheduler on which to run the generator loop. If not specified, the timeout scheduler is used. - * @returns {Observable} The generated sequence. - */ - Observable.generateWithRelativeTime = function (initialState, condition, iterate, resultSelector, timeSelector, scheduler) { - isScheduler(scheduler) || (scheduler = defaultScheduler); - return new GenerateRelativeObservable(initialState, condition, iterate, resultSelector, timeSelector, scheduler); - }; - - var DelaySubscription = (function(__super__) { - inherits(DelaySubscription, __super__); - function DelaySubscription(source, dt, s) { - this.source = source; - this._dt = dt; - this._s = s; - __super__.call(this); - } - - DelaySubscription.prototype.subscribeCore = function (o) { - var d = new SerialDisposable(); - - d.setDisposable(this._s.scheduleFuture([this.source, o, d], this._dt, scheduleMethod)); - - return d; - }; - - function scheduleMethod(s, state) { - var source = state[0], o = state[1], d = state[2]; - d.setDisposable(source.subscribe(o)); - } - - return DelaySubscription; - }(ObservableBase)); - - /** - * Time shifts the observable sequence by delaying the subscription with the specified relative time duration, using the specified scheduler to run timers. - * - * @example - * 1 - res = source.delaySubscription(5000); // 5s - * 2 - res = source.delaySubscription(5000, Rx.Scheduler.default); // 5 seconds - * - * @param {Number} dueTime Relative or absolute time shift of the subscription. - * @param {Scheduler} [scheduler] Scheduler to run the subscription delay timer on. If not specified, the timeout scheduler is used. - * @returns {Observable} Time-shifted sequence. - */ - observableProto.delaySubscription = function (dueTime, scheduler) { - isScheduler(scheduler) || (scheduler = defaultScheduler); - return new DelaySubscription(this, dueTime, scheduler); - }; - - var SkipLastWithTimeObservable = (function (__super__) { - inherits(SkipLastWithTimeObservable, __super__); - function SkipLastWithTimeObservable(source, d, s) { - this.source = source; - this._d = d; - this._s = s; - __super__.call(this); - } - - SkipLastWithTimeObservable.prototype.subscribeCore = function (o) { - return this.source.subscribe(new SkipLastWithTimeObserver(o, this)); - }; - - return SkipLastWithTimeObservable; - }(ObservableBase)); - - var SkipLastWithTimeObserver = (function (__super__) { - inherits(SkipLastWithTimeObserver, __super__); - - function SkipLastWithTimeObserver(o, p) { - this._o = o; - this._s = p._s; - this._d = p._d; - this._q = []; - __super__.call(this); - } - - SkipLastWithTimeObserver.prototype.next = function (x) { - var now = this._s.now(); - this._q.push({ interval: now, value: x }); - while (this._q.length > 0 && now - this._q[0].interval >= this._d) { - this._o.onNext(this._q.shift().value); - } - }; - SkipLastWithTimeObserver.prototype.error = function (e) { this._o.onError(e); }; - SkipLastWithTimeObserver.prototype.completed = function () { - var now = this._s.now(); - while (this._q.length > 0 && now - this._q[0].interval >= this._d) { - this._o.onNext(this._q.shift().value); - } - this._o.onCompleted(); - }; - - return SkipLastWithTimeObserver; - }(AbstractObserver)); - - /** - * Skips elements for the specified duration from the end of the observable source sequence, using the specified scheduler to run timers. - * @description - * This operator accumulates a queue with a length enough to store elements received during the initial duration window. - * As more elements are received, elements older than the specified duration are taken from the queue and produced on the - * result sequence. This causes elements to be delayed with duration. - * @param {Number} duration Duration for skipping elements from the end of the sequence. - * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout - * @returns {Observable} An observable sequence with the elements skipped during the specified duration from the end of the source sequence. - */ - observableProto.skipLastWithTime = function (duration, scheduler) { - isScheduler(scheduler) || (scheduler = defaultScheduler); - return new SkipLastWithTimeObservable(this, duration, scheduler); - }; - - var TakeLastWithTimeObservable = (function (__super__) { - inherits(TakeLastWithTimeObservable, __super__); - function TakeLastWithTimeObservable(source, d, s) { - this.source = source; - this._d = d; - this._s = s; - __super__.call(this); - } - - TakeLastWithTimeObservable.prototype.subscribeCore = function (o) { - return this.source.subscribe(new TakeLastWithTimeObserver(o, this._d, this._s)); - }; - - return TakeLastWithTimeObservable; - }(ObservableBase)); - - var TakeLastWithTimeObserver = (function (__super__) { - inherits(TakeLastWithTimeObserver, __super__); - - function TakeLastWithTimeObserver(o, d, s) { - this._o = o; - this._d = d; - this._s = s; - this._q = []; - __super__.call(this); - } - - TakeLastWithTimeObserver.prototype.next = function (x) { - var now = this._s.now(); - this._q.push({ interval: now, value: x }); - while (this._q.length > 0 && now - this._q[0].interval >= this._d) { - this._q.shift(); - } - }; - TakeLastWithTimeObserver.prototype.error = function (e) { this._o.onError(e); }; - TakeLastWithTimeObserver.prototype.completed = function () { - var now = this._s.now(); - while (this._q.length > 0) { - var next = this._q.shift(); - if (now - next.interval <= this._d) { this._o.onNext(next.value); } - } - this._o.onCompleted(); - }; - - return TakeLastWithTimeObserver; - }(AbstractObserver)); - - /** - * Returns elements within the specified duration from the end of the observable source sequence, using the specified schedulers to run timers and to drain the collected elements. - * @description - * This operator accumulates a queue with a length enough to store elements received during the initial duration window. - * As more elements are received, elements older than the specified duration are taken from the queue and produced on the - * result sequence. This causes elements to be delayed with duration. - * @param {Number} duration Duration for taking elements from the end of the sequence. - * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout. - * @returns {Observable} An observable sequence with the elements taken during the specified duration from the end of the source sequence. - */ - observableProto.takeLastWithTime = function (duration, scheduler) { - isScheduler(scheduler) || (scheduler = defaultScheduler); - return new TakeLastWithTimeObservable(this, duration, scheduler); - }; - - /** - * Returns an array with the elements within the specified duration from the end of the observable source sequence, using the specified scheduler to run timers. - * @description - * This operator accumulates a queue with a length enough to store elements received during the initial duration window. - * As more elements are received, elements older than the specified duration are taken from the queue and produced on the - * result sequence. This causes elements to be delayed with duration. - * @param {Number} duration Duration for taking elements from the end of the sequence. - * @param {Scheduler} scheduler Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout. - * @returns {Observable} An observable sequence containing a single array with the elements taken during the specified duration from the end of the source sequence. - */ - observableProto.takeLastBufferWithTime = function (duration, scheduler) { - var source = this; - isScheduler(scheduler) || (scheduler = defaultScheduler); - return new AnonymousObservable(function (o) { - var q = []; - return source.subscribe(function (x) { - var now = scheduler.now(); - q.push({ interval: now, value: x }); - while (q.length > 0 && now - q[0].interval >= duration) { - q.shift(); - } - }, function (e) { o.onError(e); }, function () { - var now = scheduler.now(), res = []; - while (q.length > 0) { - var next = q.shift(); - now - next.interval <= duration && res.push(next.value); - } - o.onNext(res); - o.onCompleted(); - }); - }, source); - }; - - var TakeWithTimeObservable = (function (__super__) { - inherits(TakeWithTimeObservable, __super__); - function TakeWithTimeObservable(source, d, s) { - this.source = source; - this._d = d; - this._s = s; - __super__.call(this); - } - - function scheduleMethod(s, o) { - o.onCompleted(); - } - - TakeWithTimeObservable.prototype.subscribeCore = function (o) { - return new BinaryDisposable( - this._s.scheduleFuture(o, this._d, scheduleMethod), - this.source.subscribe(o) - ); - }; - - return TakeWithTimeObservable; - }(ObservableBase)); - - /** - * Takes elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers. - * - * @example - * 1 - res = source.takeWithTime(5000, [optional scheduler]); - * @description - * This operator accumulates a queue with a length enough to store elements received during the initial duration window. - * As more elements are received, elements older than the specified duration are taken from the queue and produced on the - * result sequence. This causes elements to be delayed with duration. - * @param {Number} duration Duration for taking elements from the start of the sequence. - * @param {Scheduler} scheduler Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout. - * @returns {Observable} An observable sequence with the elements taken during the specified duration from the start of the source sequence. - */ - observableProto.takeWithTime = function (duration, scheduler) { - isScheduler(scheduler) || (scheduler = defaultScheduler); - return new TakeWithTimeObservable(this, duration, scheduler); - }; - - var SkipWithTimeObservable = (function (__super__) { - inherits(SkipWithTimeObservable, __super__); - function SkipWithTimeObservable(source, d, s) { - this.source = source; - this._d = d; - this._s = s; - this._open = false; - __super__.call(this); - } - - function scheduleMethod(s, self) { - self._open = true; - } - - SkipWithTimeObservable.prototype.subscribeCore = function (o) { - return new BinaryDisposable( - this._s.scheduleFuture(this, this._d, scheduleMethod), - this.source.subscribe(new SkipWithTimeObserver(o, this)) - ); - }; - - return SkipWithTimeObservable; - }(ObservableBase)); - - var SkipWithTimeObserver = (function (__super__) { - inherits(SkipWithTimeObserver, __super__); - - function SkipWithTimeObserver(o, p) { - this._o = o; - this._p = p; - __super__.call(this); - } - - SkipWithTimeObserver.prototype.next = function (x) { this._p._open && this._o.onNext(x); }; - SkipWithTimeObserver.prototype.error = function (e) { this._o.onError(e); }; - SkipWithTimeObserver.prototype.completed = function () { this._o.onCompleted(); }; - - return SkipWithTimeObserver; - }(AbstractObserver)); - - /** - * Skips elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers. - * @description - * Specifying a zero value for duration doesn't guarantee no elements will be dropped from the start of the source sequence. - * This is a side-effect of the asynchrony introduced by the scheduler, where the action that causes callbacks from the source sequence to be forwarded - * may not execute immediately, despite the zero due time. - * - * Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the duration. - * @param {Number} duration Duration for skipping elements from the start of the sequence. - * @param {Scheduler} scheduler Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout. - * @returns {Observable} An observable sequence with the elements skipped during the specified duration from the start of the source sequence. - */ - observableProto.skipWithTime = function (duration, scheduler) { - isScheduler(scheduler) || (scheduler = defaultScheduler); - return new SkipWithTimeObservable(this, duration, scheduler); - }; - - var SkipUntilWithTimeObservable = (function (__super__) { - inherits(SkipUntilWithTimeObservable, __super__); - function SkipUntilWithTimeObservable(source, startTime, scheduler) { - this.source = source; - this._st = startTime; - this._s = scheduler; - __super__.call(this); - } - - function scheduleMethod(s, state) { - state._open = true; - } - - SkipUntilWithTimeObservable.prototype.subscribeCore = function (o) { - this._open = false; - return new BinaryDisposable( - this._s.scheduleFuture(this, this._st, scheduleMethod), - this.source.subscribe(new SkipUntilWithTimeObserver(o, this)) - ); - }; - - return SkipUntilWithTimeObservable; - }(ObservableBase)); - - var SkipUntilWithTimeObserver = (function (__super__) { - inherits(SkipUntilWithTimeObserver, __super__); - - function SkipUntilWithTimeObserver(o, p) { - this._o = o; - this._p = p; - __super__.call(this); - } - - SkipUntilWithTimeObserver.prototype.next = function (x) { this._p._open && this._o.onNext(x); }; - SkipUntilWithTimeObserver.prototype.error = function (e) { this._o.onError(e); }; - SkipUntilWithTimeObserver.prototype.completed = function () { this._o.onCompleted(); }; - - return SkipUntilWithTimeObserver; - }(AbstractObserver)); - - - /** - * Skips elements from the observable source sequence until the specified start time, using the specified scheduler to run timers. - * Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the start time. - * - * @examples - * 1 - res = source.skipUntilWithTime(new Date(), [scheduler]); - * 2 - res = source.skipUntilWithTime(5000, [scheduler]); - * @param {Date|Number} startTime Time to start taking elements from the source sequence. If this value is less than or equal to Date(), no elements will be skipped. - * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout. - * @returns {Observable} An observable sequence with the elements skipped until the specified start time. - */ - observableProto.skipUntilWithTime = function (startTime, scheduler) { - isScheduler(scheduler) || (scheduler = defaultScheduler); - return new SkipUntilWithTimeObservable(this, startTime, scheduler); - }; - - /** - * Takes elements for the specified duration until the specified end time, using the specified scheduler to run timers. - * @param {Number | Date} endTime Time to stop taking elements from the source sequence. If this value is less than or equal to new Date(), the result stream will complete immediately. - * @param {Scheduler} [scheduler] Scheduler to run the timer on. - * @returns {Observable} An observable sequence with the elements taken until the specified end time. - */ - observableProto.takeUntilWithTime = function (endTime, scheduler) { - isScheduler(scheduler) || (scheduler = defaultScheduler); - var source = this; - return new AnonymousObservable(function (o) { - return new BinaryDisposable( - scheduler.scheduleFuture(o, endTime, function (_, o) { o.onCompleted(); }), - source.subscribe(o)); - }, source); - }; - - /** - * Returns an Observable that emits only the first item emitted by the source Observable during sequential time windows of a specified duration. - * @param {Number} windowDuration time to wait before emitting another item after emitting the last item - * @param {Scheduler} [scheduler] the Scheduler to use internally to manage the timers that handle timeout for each item. If not provided, defaults to Scheduler.timeout. - * @returns {Observable} An Observable that performs the throttle operation. - */ - observableProto.throttle = function (windowDuration, scheduler) { - isScheduler(scheduler) || (scheduler = defaultScheduler); - var duration = +windowDuration || 0; - if (duration <= 0) { throw new RangeError('windowDuration cannot be less or equal zero.'); } - var source = this; - return new AnonymousObservable(function (o) { - var lastOnNext = 0; - return source.subscribe( - function (x) { - var now = scheduler.now(); - if (lastOnNext === 0 || now - lastOnNext >= duration) { - lastOnNext = now; - o.onNext(x); - } - },function (e) { o.onError(e); }, function () { o.onCompleted(); } - ); - }, source); - }; - - return Rx; -})); - - -/***/ }), -/* 16 */ -/***/ ((module) => { - -"use strict"; -module.exports = require("events"); - -/***/ }), -/* 17 */ -/***/ ((__unused_webpack_module, exports, __webpack_require__) => { - -"use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.Misc = void 0; -const vscode = __webpack_require__(1); -class Misc { - static getFormattedHtml(head, body, webview) { - var _a; - var fileName = ((_a = vscode.window.activeTextEditor) === null || _a === void 0 ? void 0 : _a.document.fileName) || "PreviewSeqDiagImage"; - fileName = fileName.substring(fileName.lastIndexOf("\\") + 1).substring(fileName.lastIndexOf("/") + 1); - return `` - + `` - + head - + `` - + `` - + `
- PNG - PNG* - JPEG - SVG - Clipboard -
` - + `` - + body - + ``; - } -} -exports.Misc = Misc; -Misc.previewUri = vscode.Uri.parse('previewSeqDiag://authority/previewSeqDiag'); - - -/***/ }), -/* 18 */ -/***/ ((__unused_webpack_module, exports, __webpack_require__) => { - -"use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.PreviewSeqDiagDocumentContentProvider = void 0; -const vscode = __webpack_require__(1); -const defaultCodeSnippet_1 = __webpack_require__(19); -const mscgenCodeSnippet_1 = __webpack_require__(20); -const mermaidCodeSnippet_1 = __webpack_require__(21); -const suppotablelanguageId = ["mermaid", "mmd", "mscgen", "msgenny", "xu"]; -class PreviewSeqDiagDocumentContentProvider { - constructor() { - this.latestSnippetResultBuffer = ""; - this.webViewPanel = null; - this.extentionPath = ""; - this._currentSnippet = defaultCodeSnippet_1.DefaultCodeSnippet.instance; - } - // private _onDidChange: vscode.EventEmitter = new vscode.EventEmitter(); - // readonly onDidChange: vscode.Event = this._onDidChange.event; - setCurrentWebViewPanel(panel) { - this.webViewPanel = panel; - } - getExtensionPath(path) { - this.extentionPath = path; - } - update(uri) { - if (vscode.window.activeTextEditor) { - if (suppotablelanguageId.indexOf(vscode.window.activeTextEditor.document.languageId) > -1) { - // this._onDidChange.fire(uri); - this.refresh(); - } - } - } - provideTextDocumentContent(uri, token) { - return this.latestSnippetResultBuffer; - } - refresh() { - let editor = vscode.window.activeTextEditor; - if (!editor) { - return this.latestSnippetResultBuffer; - } - switch (editor.document.languageId) { - case "mermaid": - case "mmd": - this._currentSnippet = mermaidCodeSnippet_1.MermaidCodeSnippet.instance; - break; - case "mscgen": - case "msgenny": - case "xu": - this._currentSnippet = mscgenCodeSnippet_1.MscgenCodeSnippet.instance; - break; - default: - this._currentSnippet = defaultCodeSnippet_1.DefaultCodeSnippet.instance; - break; - } - if (this.webViewPanel && this.webViewPanel.webview) { - this._currentSnippet - .createCodeSnippet(editor.document.languageId, this.extentionPath, this.webViewPanel.webview) - .then(result => { - this.latestSnippetResultBuffer = result; - if (this.webViewPanel && this.webViewPanel.webview) { - this.webViewPanel.webview.html = result; - } - }) - .catch(); - } - } -} -exports.PreviewSeqDiagDocumentContentProvider = PreviewSeqDiagDocumentContentProvider; - - -/***/ }), -/* 19 */ -/***/ (function(__unused_webpack_module, exports, __webpack_require__) { - -"use strict"; - -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.DefaultCodeSnippet = void 0; -const vscode = __webpack_require__(1); -const misc_1 = __webpack_require__(17); -class DefaultCodeSnippet { - constructor() { } - static get instance() { - if (!this._instance) { - this._instance = new DefaultCodeSnippet(); - } - return this._instance; - } - createCodeSnippet(languageId, extentiponPath, webview) { - return __awaiter(this, void 0, void 0, function* () { - return this.extractSnippet(languageId, extentiponPath, webview); - }); - } - extractSnippet(languageId, extentiponPath, webview) { - return __awaiter(this, void 0, void 0, function* () { - let editor = vscode.window.activeTextEditor; - let text = editor === null || editor === void 0 ? void 0 : editor.document.getText(); - return this.previewSnippet(languageId, extentiponPath, text || "", webview); - }); - } - errorSnippet(error, webview) { - return __awaiter(this, void 0, void 0, function* () { - return misc_1.Misc.getFormattedHtml("", error, webview); - }); - } - previewSnippet(languageId, extentiponPath, payLoad, webview) { - return __awaiter(this, void 0, void 0, function* () { - return misc_1.Misc.getFormattedHtml(``, `${payLoad}`, webview); - }); - } -} -exports.DefaultCodeSnippet = DefaultCodeSnippet; - - -/***/ }), -/* 20 */ -/***/ (function(__unused_webpack_module, exports, __webpack_require__) { - -"use strict"; - -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.MscgenCodeSnippet = void 0; -const vscode = __webpack_require__(1); -const misc_1 = __webpack_require__(17); -const Path = __webpack_require__(2); -var StyleName; -(function (StyleName) { - StyleName.classic = "classic"; - StyleName.cygne = "cygne"; - StyleName.fountainpen = "fountainpen"; - StyleName.lazy = "lazy"; - StyleName.pegasse = "pegasse"; -})(StyleName || (StyleName = {})); -var Alignment; -(function (Alignment) { - Alignment.fixed = "fixed"; - Alignment.stretch = "stretch"; -})(Alignment || (Alignment = {})); -class ConfigMscgen { - constructor() { - this.fixedNamedStyle = StyleName.classic; - this.horizontalAlignment = Alignment.stretch; - } -} -class MscgenCodeSnippet { - constructor() { - this._configMscgen = new ConfigMscgen(); - // defaults - this._configMscgen.fixedNamedStyle = StyleName.cygne; - this._configMscgen.horizontalAlignment = Alignment.stretch; - var config = vscode.workspace.getConfiguration('previewSeqDiag'); - if (!!config && !!config.mscgen) { - // fixedNamedStyle - switch (config.mscgen.fixedNamedStyle) { - case StyleName.classic: - case StyleName.cygne: - case StyleName.fountainpen: - case StyleName.lazy: - case StyleName.pegasse: - this._configMscgen.fixedNamedStyle = config.mscgen.fixedNamedStyle; - break; - default: - break; - } - // horizontalAlignment - switch (config.mscgen.horizontalAlignment) { - case Alignment.fixed: - this._configMscgen.horizontalAlignment = Alignment.fixed; - break; - default: - break; - } - } - } - static get instance() { - if (!this._instance) { - this._instance = new MscgenCodeSnippet(); - } - return this._instance; - } - createCodeSnippet(languageId, extentiponPath, webview) { - return __awaiter(this, void 0, void 0, function* () { - return this.extractSnippet(languageId, extentiponPath, webview); - }); - } - extractSnippet(languageId, extentiponPath, webview) { - return __awaiter(this, void 0, void 0, function* () { - let editor = vscode.window.activeTextEditor; - let text = (editor === null || editor === void 0 ? void 0 : editor.document.getText()) || ""; - return this.previewSnippet(languageId, extentiponPath, text, webview); - }); - } - errorSnippet(error, webview) { - return __awaiter(this, void 0, void 0, function* () { - return misc_1.Misc.getFormattedHtml("", error, webview); - }); - } - previewSnippet(languageId, extentiponPath, payLoad, webview) { - return __awaiter(this, void 0, void 0, function* () { - var jsPath = vscode.Uri.file(Path.join(extentiponPath, 'dist', 'mscgenjs-inpage', 'mscgen-inpage.js')); - const jsSrc = webview.asWebviewUri(jsPath); - return misc_1.Misc.getFormattedHtml(` - ` - + ((this._configMscgen.horizontalAlignment === Alignment.stretch) ? `` : ``), `
- -
- `, webview); - }); - } -} -exports.MscgenCodeSnippet = MscgenCodeSnippet; - - -/***/ }), -/* 21 */ -/***/ (function(__unused_webpack_module, exports, __webpack_require__) { - -"use strict"; - -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.MermaidCodeSnippet = void 0; -const vscode = __webpack_require__(1); -const fs = __webpack_require__(22); -const Path = __webpack_require__(2); -const misc_1 = __webpack_require__(17); -var StyleName; -(function (StyleName) { - StyleName.dark = "dark"; - StyleName.forest = "forest"; - StyleName.neutral = "neutral"; -})(StyleName || (StyleName = {})); -const backgroundColorDefault = "#fafaf6"; -class ConfigMermaid { - constructor() { - this.fixedStyle = StyleName.forest; - this.fixedBackgroundColor = backgroundColorDefault; - } -} -class MermaidCodeSnippet { - constructor() { - this._configMermaid = new ConfigMermaid(); - // defaults - this._configMermaid.fixedStyle = StyleName.forest; - this._configMermaid.fixedBackgroundColor = backgroundColorDefault; - var config = vscode.workspace.getConfiguration('previewSeqDiag'); - if (!!config && !!config.mermaid) { - // fixedStyle - switch (config.mermaid.fixedStyle) { - case StyleName.dark: - case StyleName.forest: - case StyleName.neutral: - this._configMermaid.fixedStyle = config.mscgen.fixedNamedStyle; - break; - default: - break; - } - // fixedBackgroundColor - if (config.mermaid.fixedBackgroundColor !== null) { - this._configMermaid.fixedBackgroundColor = config.mermaid.fixedBackgroundColor; - } - } - } - static get instance() { - if (!this._instance) { - this._instance = new MermaidCodeSnippet(); - } - return this._instance; - } - createCodeSnippet(languageId, extentiponPath, webview) { - return __awaiter(this, void 0, void 0, function* () { - return this.extractSnippet(languageId, extentiponPath, webview); - }); - } - extractSnippet(languageId, extentiponPath, webview) { - return __awaiter(this, void 0, void 0, function* () { - let editor = vscode.window.activeTextEditor; - let text = (editor === null || editor === void 0 ? void 0 : editor.document.getText()) || ""; - try { - text = text.replace(/%%[ \t]+import[ \t]?:[ \t]?(.+)/g, (match, subsequenceFile) => { - if (!editor) { - return ""; - } - let dirname = editor.document.uri.fsPath - .toString() - .split(Path.sep); - dirname.pop(); - const fileName = dirname.join(Path.sep) + Path.sep + subsequenceFile.trim(); - const importSequence = fs - .readFileSync(fileName, 'utf8') - .replace(/sequenceDiagram/g, ''); - return importSequence; - }); - } - catch (err) { - console.error(err); - } - return this.previewSnippet(languageId, extentiponPath, text, webview); - }); - } - errorSnippet(error, webview) { - return __awaiter(this, void 0, void 0, function* () { - return misc_1.Misc.getFormattedHtml("", error, webview); - }); - } - previewSnippet(languageId, extentiponPath, payLoad, webview) { - return __awaiter(this, void 0, void 0, function* () { - var jsPath = vscode.Uri.file(Path.join(extentiponPath, 'dist', 'mermaid', 'mermaid.min.js')); - const jsSrc = webview.asWebviewUri(jsPath); - return misc_1.Misc.getFormattedHtml(` - `, `
-
${payLoad}
- -
`, webview); - }); - } -} -exports.MermaidCodeSnippet = MermaidCodeSnippet; - - -/***/ }), -/* 22 */ -/***/ ((module) => { - -"use strict"; -module.exports = require("fs"); - -/***/ }) -/******/ ]); -/************************************************************************/ -/******/ // The module cache -/******/ var __webpack_module_cache__ = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ // Check if module is in cache -/******/ var cachedModule = __webpack_module_cache__[moduleId]; -/******/ if (cachedModule !== undefined) { -/******/ return cachedModule.exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = __webpack_module_cache__[moduleId] = { -/******/ id: moduleId, -/******/ loaded: false, -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__); -/******/ -/******/ // Flag the module as loaded -/******/ module.loaded = true; -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/************************************************************************/ -/******/ /* webpack/runtime/node module decorator */ -/******/ (() => { -/******/ __webpack_require__.nmd = (module) => { -/******/ module.paths = []; -/******/ if (!module.children) module.children = []; -/******/ return module; -/******/ }; -/******/ })(); -/******/ -/************************************************************************/ -var __webpack_exports__ = {}; -// This entry need to be wrapped in an IIFE because it need to be in strict mode. -(() => { -"use strict"; -var exports = __webpack_exports__; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.deactivate = exports.activate = void 0; -const vscode = __webpack_require__(1); -const vscode_1 = __webpack_require__(1); -const path = __webpack_require__(2); -const Rx = __webpack_require__(3); -const events_1 = __webpack_require__(16); -const misc_1 = __webpack_require__(17); -const previewSeqDiagDocumentContentProvider_1 = __webpack_require__(18); -function activate(context) { - const provider = new previewSeqDiagDocumentContentProvider_1.PreviewSeqDiagDocumentContentProvider(); - let showPreview = vscode.commands.registerCommand('previewSeqDiag.showPreview', () => { - const panel = vscode.window.createWebviewPanel('previewSeqDiag', 'Preview Sequence Diagrams', vscode.ViewColumn.Two, { - enableScripts: true, - localResourceRoots: [ - vscode.Uri.file(path.join(context.extensionPath, 'dist/mermaid')), - vscode.Uri.file(path.join(context.extensionPath, 'dist/mscgenjs-inpage')), - ] - }); - provider.getExtensionPath(context.extensionPath); - provider.setCurrentWebViewPanel(panel); - provider.update(misc_1.Misc.previewUri); - }); - context.subscriptions.push(showPreview); - const emitter = new events_1.EventEmitter(); - const _ = Rx.Observable - .fromEvent(emitter, 'update') - .debounce(500 /* ms */) - .subscribe((_) => { - provider.update(misc_1.Misc.previewUri); - }); - vscode_1.window.onDidChangeActiveTextEditor((e) => { - if (!!e && !!e.document && (e === vscode_1.window.activeTextEditor)) { - provider.update(misc_1.Misc.previewUri); - } - }); - vscode_1.workspace.onDidChangeTextDocument((e) => { - var _a; - if (e.document === ((_a = vscode.window.activeTextEditor) === null || _a === void 0 ? void 0 : _a.document)) { - emitter.emit('update', e); - } - }); - context.subscriptions.push(vscode.workspace.registerTextDocumentContentProvider(misc_1.Misc.previewUri.scheme, provider)); -} -exports.activate = activate; -// this method is called when your extension is deactivated -function deactivate() { } -exports.deactivate = deactivate; - -})(); - -module.exports = __webpack_exports__; -/******/ })() -; -//# sourceMappingURL=extension.js.map \ No newline at end of file +(()=>{var t={230:function(t,e,n){var r,i;t=n.nmd(t),function(o){var s={function:!0,object:!0};function u(t){return t&&t.Object===Object?t:null}var c=s[typeof e]&&e&&!e.nodeType?e:null,h=s.object&&t&&!t.nodeType?t:null,a=u(c&&h&&"object"==typeof global&&global),l=u(s[typeof self]&&self),p=u(s[typeof window]&&window),f=(h&&h.exports,u(s[typeof this]&&this)),d=a||p!==(f&&f.window)&&p||l||f||Function("return this")();r=[n(374)],i=function(t,e){return o(d,e,t)}.apply(e,r),void 0===i||(t.exports=i)}.call(this,(function(t,e,n,r){var i=n.Observable,o=i.prototype,s=n.BinaryDisposable,u=n.AnonymousObservable,c=n.internals.AbstractObserver,h=n.Disposable.empty,a=n.helpers,l=a.defaultComparer,p=a.identity,f=a.defaultSubComparer,d=a.isFunction,b=a.isPromise,v=a.isArrayLike,_=a.isIterable,y=n.internals.inherits,w=i.fromPromise,m=i.from,g=n.internals.bindCallback,x=n.EmptyError,C=n.ObservableBase,E=n.ArgumentOutOfRangeError,S={e:{}},D=n.internals.tryCatch=function(t){if(!d(t))throw new TypeError("fn must be a function");return e=t,function(){try{return e.apply(this,arguments)}catch(t){return S.e=t,S}};var e},N=function(t){function e(e,n,r){this.source=e,this._k=n,this._c=r,t.call(this)}return y(e,t),e.prototype.subscribeCore=function(t){return this.source.subscribe(new A(t,this._k,this._c))},e}(C),A=function(t){function e(e,n,r){this._o=e,this._k=n,this._c=r,this._v=null,this._hv=!1,this._l=[],t.call(this)}return y(e,t),e.prototype.next=function(t){var e=D(this._k)(t);if(e===S)return this._o.onError(e.e);var n=0;if(this._hv){if((n=D(this._c)(e,this._v))===S)return this._o.onError(n.e)}else this._hv=!0,this._v=e;n>0&&(this._v=e,this._l=[]),n>=0&&this._l.push(t)},e.prototype.error=function(t){this._o.onError(t)},e.prototype.completed=function(){this._o.onNext(this._l),this._o.onCompleted()},e}(c);function O(t){if(0===t.length)throw new x;return t[0]}var j=function(t){function e(e,n,r,i){this.source=e,this.accumulator=n,this.hasSeed=r,this.seed=i,t.call(this)}return y(e,t),e.prototype.subscribeCore=function(t){return this.source.subscribe(new k(t,this))},e}(C),k=function(t){function e(e,n){this._o=e,this._p=n,this._fn=n.accumulator,this._hs=n.hasSeed,this._s=n.seed,this._ha=!1,this._a=null,this._hv=!1,this._i=0,t.call(this)}return y(e,t),e.prototype.next=function(t){if(!this._hv&&(this._hv=!0),this._ha?this._a=D(this._fn)(this._a,t,this._i,this._p):(this._a=this._hs?D(this._fn)(this._s,t,this._i,this._p):t,this._ha=!0),this._a===S)return this._o.onError(this._a.e);this._i++},e.prototype.error=function(t){this._o.onError(t)},e.prototype.completed=function(){this._hv&&this._o.onNext(this._a),!this._hv&&this._hs&&this._o.onNext(this._s),!this._hv&&!this._hs&&this._o.onError(new x),this._o.onCompleted()},e}(c);o.reduce=function(){var t,e=!1,n=arguments[0];return 2===arguments.length&&(e=!0,t=arguments[1]),new j(this,n,e,t)};var q=function(t){function e(e,n){this.source=e,this._fn=n,t.call(this)}return y(e,t),e.prototype.subscribeCore=function(t){return this.source.subscribe(new T(t,this._fn,this.source))},e}(C),T=function(t){function e(e,n,r){this._o=e,this._fn=n,this._s=r,this._i=0,t.call(this)}return y(e,t),e.prototype.next=function(t){var e=D(this._fn)(t,this._i++,this._s);if(e===S)return this._o.onError(e.e);Boolean(e)&&(this._o.onNext(!0),this._o.onCompleted())},e.prototype.error=function(t){this._o.onError(t)},e.prototype.completed=function(){this._o.onNext(!1),this._o.onCompleted()},e}(c);o.some=function(t,e){var n=g(t,e,3);return new q(this,n)};var F=function(t){function e(e){this.source=e,t.call(this)}return y(e,t),e.prototype.subscribeCore=function(t){return this.source.subscribe(new R(t))},e}(C),R=function(t){function e(e){this._o=e,t.call(this)}return y(e,t),e.prototype.next=function(){this._o.onNext(!1),this._o.onCompleted()},e.prototype.error=function(t){this._o.onError(t)},e.prototype.completed=function(){this._o.onNext(!0),this._o.onCompleted()},e}(c);o.isEmpty=function(){return new F(this)};var P=function(t){function e(e,n){this.source=e,this._fn=n,t.call(this)}return y(e,t),e.prototype.subscribeCore=function(t){return this.source.subscribe(new M(t,this._fn,this.source))},e}(C),M=function(t){function e(e,n,r){this._o=e,this._fn=n,this._s=r,this._i=0,t.call(this)}return y(e,t),e.prototype.next=function(t){var e=D(this._fn)(t,this._i++,this._s);if(e===S)return this._o.onError(e.e);Boolean(e)||(this._o.onNext(!1),this._o.onCompleted())},e.prototype.error=function(t){this._o.onError(t)},e.prototype.completed=function(){this._o.onNext(!0),this._o.onCompleted()},e}(c);o.every=function(t,e){var n=g(t,e,3);return new P(this,n)};var I=function(t){function e(e,n,r){var i=+r||0;Math.abs(i)===1/0&&(i=0),this.source=e,this._elem=n,this._n=i,t.call(this)}return y(e,t),e.prototype.subscribeCore=function(t){return this._n<0?(t.onNext(!1),t.onCompleted(),h):this.source.subscribe(new V(t,this._elem,this._n))},e}(C),V=function(t){function e(e,n,r){this._o=e,this._elem=n,this._n=r,this._i=0,t.call(this)}return y(e,t),e.prototype.next=function(t){var e,n;this._i++>=this._n&&(e=t,n=this._elem,0===e&&0===n||e===n||isNaN(e)&&isNaN(n))&&(this._o.onNext(!0),this._o.onCompleted())},e.prototype.error=function(t){this._o.onError(t)},e.prototype.completed=function(){this._o.onNext(!1),this._o.onCompleted()},e}(c);o.includes=function(t,e){return new I(this,t,e)};var B=function(t){function e(e,n){this.source=e,this._fn=n,t.call(this)}return y(e,t),e.prototype.subscribeCore=function(t){return this.source.subscribe(new z(t,this._fn,this.source))},e}(C),z=function(t){function e(e,n,r){this._o=e,this._fn=n,this._s=r,this._i=0,this._c=0,t.call(this)}return y(e,t),e.prototype.next=function(t){if(this._fn){var e=D(this._fn)(t,this._i++,this._s);if(e===S)return this._o.onError(e.e);Boolean(e)&&this._c++}else this._c++},e.prototype.error=function(t){this._o.onError(t)},e.prototype.completed=function(){this._o.onNext(this._c),this._o.onCompleted()},e}(c);o.count=function(t,e){var n=g(t,e,3);return new B(this,n)};var L=function(t){function e(e,n,r){this.source=e,this._e=n,this._n=r,t.call(this)}return y(e,t),e.prototype.subscribeCore=function(t){return this._n<0?(t.onNext(-1),t.onCompleted(),h):this.source.subscribe(new W(t,this._e,this._n))},e}(C),W=function(t){function e(e,n,r){this._o=e,this._e=n,this._n=r,this._i=0,t.call(this)}return y(e,t),e.prototype.next=function(t){this._i>=this._n&&t===this._e&&(this._o.onNext(this._i),this._o.onCompleted()),this._i++},e.prototype.error=function(t){this._o.onError(t)},e.prototype.completed=function(){this._o.onNext(-1),this._o.onCompleted()},e}(c);o.indexOf=function(t,e){var n=+e||0;return Math.abs(n)===1/0&&(n=0),new L(this,t,n)};var U=function(t){function e(e,n){this.source=e,this._fn=n,t.call(this)}return y(e,t),e.prototype.subscribeCore=function(t){return this.source.subscribe(new $(t,this._fn,this.source))},e}(C),$=function(t){function e(e,n,r){this._o=e,this._fn=n,this._s=r,this._i=0,this._c=0,t.call(this)}return y(e,t),e.prototype.next=function(t){if(this._fn){var e=D(this._fn)(t,this._i++,this._s);if(e===S)return this._o.onError(e.e);this._c+=e}else this._c+=t},e.prototype.error=function(t){this._o.onError(t)},e.prototype.completed=function(){this._o.onNext(this._c),this._o.onCompleted()},e}(c);o.sum=function(t,e){var n=g(t,e,3);return new U(this,n)},o.minBy=function(t,e){return e||(e=f),new N(this,t,(function(t,n){return-1*e(t,n)}))},o.min=function(t){return this.minBy(p,t).map(O)},o.maxBy=function(t,e){return e||(e=f),new N(this,t,e)},o.max=function(t){return this.maxBy(p,t).map(O)};var H=function(t){function e(e,n){this.source=e,this._fn=n,t.call(this)}return y(e,t),e.prototype.subscribeCore=function(t){return this.source.subscribe(new G(t,this._fn,this.source))},e}(C),G=function(t){function e(e,n,r){this._o=e,this._fn=n,this._s=r,this._c=0,this._t=0,t.call(this)}return y(e,t),e.prototype.next=function(t){if(this._fn){var e=D(this._fn)(t,this._c++,this._s);if(e===S)return this._o.onError(e.e);this._t+=e}else this._c++,this._t+=t},e.prototype.error=function(t){this._o.onError(t)},e.prototype.completed=function(){if(0===this._c)return this._o.onError(new x);this._o.onNext(this._t/this._c),this._o.onCompleted()},e}(c);o.average=function(t,e){var n;return d(t)&&(n=g(t,e,3)),new H(this,n)},o.sequenceEqual=function(t,e){var n=this;return e||(e=l),new u((function(r){var i=!1,o=!1,u=[],c=[],h=n.subscribe((function(t){if(c.length>0){var n=c.shift(),i=D(e)(n,t);if(i===S)return r.onError(i.e);i||(r.onNext(!1),r.onCompleted())}else o?(r.onNext(!1),r.onCompleted()):u.push(t)}),(function(t){r.onError(t)}),(function(){i=!0,0===u.length&&(c.length>0?(r.onNext(!1),r.onCompleted()):o&&(r.onNext(!0),r.onCompleted()))}));(v(t)||_(t))&&(t=m(t)),b(t)&&(t=w(t));var a=t.subscribe((function(t){if(u.length>0){var n=u.shift(),o=D(e)(n,t);if(o===S)return r.onError(o.e);o||(r.onNext(!1),r.onCompleted())}else i?(r.onNext(!1),r.onCompleted()):c.push(t)}),(function(t){r.onError(t)}),(function(){o=!0,0===c.length&&(u.length>0?(r.onNext(!1),r.onCompleted()):i&&(r.onNext(!0),r.onCompleted()))}));return new s(h,a)}),n)};var J=function(t){function e(e,n,r){this.source=e,this._i=n,this._d=r,t.call(this)}return y(e,t),e.prototype.subscribeCore=function(t){return this.source.subscribe(new K(t,this._i,this._d))},e}(C),K=function(t){function e(e,n,r){this._o=e,this._i=n,this._d=r,t.call(this)}return y(e,t),e.prototype.next=function(t){0==this._i--&&(this._o.onNext(t),this._o.onCompleted())},e.prototype.error=function(t){this._o.onError(t)},e.prototype.completed=function(){this._d===r?this._o.onError(new E):(this._o.onNext(this._d),this._o.onCompleted())},e}(c);o.elementAt=function(t,e){if(t<0)throw new E;return new J(this,t,e)};var Q=function(t){function e(e,n,r){this._o=e,this._obj=n,this._s=r,this._i=0,this._hv=!1,this._v=null,t.call(this)}return y(e,t),e.prototype.next=function(t){var e=!1;if(this._obj.predicate){var n=D(this._obj.predicate)(t,this._i++,this._s);if(n===S)return this._o.onError(n.e);Boolean(n)&&(e=!0)}else this._obj.predicate||(e=!0);if(e){if(this._hv)return this._o.onError(new Error("Sequence contains more than one matching element"));this._hv=!0,this._v=t}},e.prototype.error=function(t){this._o.onError(t)},e.prototype.completed=function(){this._hv?(this._o.onNext(this._v),this._o.onCompleted()):this._obj.defaultValue===r?this._o.onError(new x):(this._o.onNext(this._obj.defaultValue),this._o.onCompleted())},e}(c);o.single=function(t,e){var n={},r=this;if(d((n="object"==typeof arguments[0]?arguments[0]:{predicate:arguments[0],thisArg:arguments[1],defaultValue:arguments[2]}).predicate)){var i=n.predicate;n.predicate=g(i,n.thisArg,3)}return new u((function(t){return r.subscribe(new Q(t,n,r))}),r)};var X=function(t){function e(e,n){this.source=e,this._obj=n,t.call(this)}return y(e,t),e.prototype.subscribeCore=function(t){return this.source.subscribe(new Y(t,this._obj,this.source))},e}(C),Y=function(t){function e(e,n,r){this._o=e,this._obj=n,this._s=r,this._i=0,t.call(this)}return y(e,t),e.prototype.next=function(t){if(this._obj.predicate){var e=D(this._obj.predicate)(t,this._i++,this._s);if(e===S)return this._o.onError(e.e);Boolean(e)&&(this._o.onNext(t),this._o.onCompleted())}else this._obj.predicate||(this._o.onNext(t),this._o.onCompleted())},e.prototype.error=function(t){this._o.onError(t)},e.prototype.completed=function(){this._obj.defaultValue===r?this._o.onError(new x):(this._o.onNext(this._obj.defaultValue),this._o.onCompleted())},e}(c);o.first=function(){var t={};if(d((t="object"==typeof arguments[0]?arguments[0]:{predicate:arguments[0],thisArg:arguments[1],defaultValue:arguments[2]}).predicate)){var e=t.predicate;t.predicate=g(e,t.thisArg,3)}return new X(this,t)};var Z=function(t){function e(e,n){this.source=e,this._obj=n,t.call(this)}return y(e,t),e.prototype.subscribeCore=function(t){return this.source.subscribe(new tt(t,this._obj,this.source))},e}(C),tt=function(t){function e(e,n,r){this._o=e,this._obj=n,this._s=r,this._i=0,this._hv=!1,this._v=null,t.call(this)}return y(e,t),e.prototype.next=function(t){var e=!1;if(this._obj.predicate){var n=D(this._obj.predicate)(t,this._i++,this._s);if(n===S)return this._o.onError(n.e);Boolean(n)&&(e=!0)}else this._obj.predicate||(e=!0);e&&(this._hv=!0,this._v=t)},e.prototype.error=function(t){this._o.onError(t)},e.prototype.completed=function(){this._hv?(this._o.onNext(this._v),this._o.onCompleted()):this._obj.defaultValue===r?this._o.onError(new x):(this._o.onNext(this._obj.defaultValue),this._o.onCompleted())},e}(c);o.last=function(){var t={};if(d((t="object"==typeof arguments[0]?arguments[0]:{predicate:arguments[0],thisArg:arguments[1],defaultValue:arguments[2]}).predicate)){var e=t.predicate;t.predicate=g(e,t.thisArg,3)}return new Z(this,t)};var et=function(t){function e(e,n,r,i){this._o=e,this._s=n,this._cb=r,this._y=i,this._i=0,t.call(this)}return y(e,t),e.prototype.next=function(t){var e=D(this._cb)(t,this._i,this._s);if(e===S)return this._o.onError(e.e);e?(this._o.onNext(this._y?this._i:t),this._o.onCompleted()):this._i++},e.prototype.error=function(t){this._o.onError(t)},e.prototype.completed=function(){this._y&&this._o.onNext(-1),this._o.onCompleted()},e}(c);function nt(t,e,n,r){var i=g(e,n,3);return new u((function(e){return t.subscribe(new et(e,t,i,r))}),t)}o.find=function(t,e){return nt(this,t,e,!1)},o.findIndex=function(t,e){return nt(this,t,e,!0)};var rt=function(t){function e(e){this.source=e,t.call(this)}return y(e,t),e.prototype.subscribeCore=function(t){return this.source.subscribe(new it(t))},e}(C),it=function(e){function n(n){this._o=n,this._s=new t.Set,e.call(this)}return y(n,e),n.prototype.next=function(t){this._s.add(t)},n.prototype.error=function(t){this._o.onError(t)},n.prototype.completed=function(){this._o.onNext(this._s),this._o.onCompleted()},n}(c);o.toSet=function(){if(void 0===t.Set)throw new TypeError;return new rt(this)};var ot=function(t){function e(e,n,r){this.source=e,this._k=n,this._e=r,t.call(this)}return y(e,t),e.prototype.subscribeCore=function(t){return this.source.subscribe(new st(t,this._k,this._e))},e}(C),st=function(e){function n(n,r,i){this._o=n,this._k=r,this._e=i,this._m=new t.Map,e.call(this)}return y(n,e),n.prototype.next=function(t){var e=D(this._k)(t);if(e===S)return this._o.onError(e.e);var n=t;if(this._e&&(n=D(this._e)(t))===S)return this._o.onError(n.e);this._m.set(e,n)},n.prototype.error=function(t){this._o.onError(t)},n.prototype.completed=function(){this._o.onNext(this._m),this._o.onCompleted()},n}(c);o.toMap=function(e,n){if(void 0===t.Map)throw new TypeError;return new ot(this,e,n)};var ut=function(t){function e(e,n,r){this.source=e,this._b=n,this._e=r,t.call(this)}return y(e,t),e.prototype.subscribeCore=function(t){return this.source.subscribe(new ct(t,this._b,this._e))},e}(C),ct=function(t){function e(e,n,r){this._o=e,this._b=n,this._e=r,this._i=0,t.call(this)}return y(e,t),e.prototype.next=function(t){this._i>=this._b&&(this._e===this._i?this._o.onCompleted():this._o.onNext(t)),this._i++},e.prototype.error=function(t){this._o.onError(t)},e.prototype.completed=function(){this._o.onCompleted()},e}(c);o.slice=function(t,e){var r=t||0;if(r<0)throw new n.ArgumentOutOfRangeError;if("number"==typeof e&&e=this._n&&t===this._e&&(this._hv=!0,this._v=this._i),this._i++},e.prototype.error=function(t){this._o.onError(t)},e.prototype.completed=function(){this._hv?this._o.onNext(this._v):this._o.onNext(-1),this._o.onCompleted()},e}(c);return o.lastIndexOf=function(t,e){var n=+e||0;return Math.abs(n)===1/0&&(n=0),new ht(this,t,n)},n}))},139:function(t,e,n){var r,i;t=n.nmd(t),function(o){var s={function:!0,object:!0};function u(t){return t&&t.Object===Object?t:null}var c=s[typeof e]&&e&&!e.nodeType?e:null,h=s.object&&t&&!t.nodeType?t:null,a=u(c&&h&&"object"==typeof global&&global),l=u(s[typeof self]&&self),p=u(s[typeof window]&&window),f=(h&&h.exports,u(s[typeof this]&&this)),d=a||p!==(f&&f.window)&&p||l||f||Function("return this")();r=[n(506),e],i=function(t,e){return d.Rx=o(d,e,t),d.Rx}.apply(e,r),void 0===i||(t.exports=i)}.call(this,(function(t,e,n,r){var i=n.Observable,o=i.fromPromise,s=i.throwError,u=n.AnonymousObservable,c=n.ObservableBase,h=n.AsyncSubject,a=(n.Disposable.create,n.CompositeDisposable),l=(n.Scheduler.immediate,n.Scheduler.default),p=n.internals.inherits,f=n.Scheduler.isScheduler,d=n.helpers.isPromise,b=n.helpers.isFunction,v=n.helpers.isIterable,_=n.helpers.isArrayLike,y={e:{}},w=n.internals.tryCatch=function(t){if(!b(t))throw new TypeError("fn must be a function");return e=t,function(){try{return e.apply(this,arguments)}catch(t){return y.e=t,y}};var e};i.wrap=function(t){function e(){return i.spawn.call(this,t.apply(this,arguments))}return e.__generatorFunction__=t,e};var m=i.spawn=function(){for(var t=arguments[0],e=this,n=[],r=1,o=arguments.length;r2){for(var r=[],i=1,o=arguments.length;i0;)t.onNext(u.shift())}return(n=this.source,i=this.pauser.startWith(!this.paused).distinctUntilChanged(),o=function(t,e){return{data:t,shouldFire:e}},new s((function(t){var e,r=[!1,!1],s=!1,u=!1,h=new Array(2);function a(n,i){if(h[i]=n,r[i]=!0,s||(s=r.every(w))){if(e)return t.onError(e);var c=C(o).apply(null,h);if(c===x)return t.onError(c.e);t.onNext(c)}u&&h[1]&&t.onCompleted()}return new c(n.subscribe((function(t){a(t,0)}),(function(n){h[1]?t.onError(n):e=n}),(function(){u=!0,h[1]&&t.onCompleted()})),i.subscribe((function(t){a(t,1)}),(function(e){t.onError(e)}),(function(){u=!0,a(!0,1)})))}),n)).subscribe((function(n){e!==r&&n.shouldFire!==e?(e=n.shouldFire,n.shouldFire&&h()):(e=n.shouldFire,n.shouldFire?t.onNext(n.data):u.push(n.data))}),(function(e){h(),t.onError(e)}),(function(){h(),t.onCompleted()}))},e.prototype.pause=function(){this.paused=!0,this.controller.onNext(!1)},e.prototype.resume=function(){this.paused=!1,this.controller.onNext(!0)},e}(i);o.pausableBuffered=function(t){return new S(this,t)};var D=function(t){function e(e,n,r){t.call(this),this.subject=new N(n,r),this.source=e.multicast(this.subject).refCount()}return b(e,t),e.prototype._subscribe=function(t){return this.source.subscribe(t)},e.prototype.request=function(t){return this.subject.request(null==t?-1:t)},e}(i),N=function(t){function e(e,n){null==e&&(e=!0),t.call(this),this.subject=new l,this.enableQueue=e,this.queue=e?[]:null,this.requestedCount=0,this.requestedDisposable=null,this.error=null,this.hasFailed=!1,this.hasCompleted=!1,this.scheduler=n||y}return b(e,t),v(e.prototype,p,{_subscribe:function(t){return this.subject.subscribe(t)},onCompleted:function(){this.hasCompleted=!0,this.enableQueue&&0!==this.queue.length?this.queue.push(a.createOnCompleted()):(this.subject.onCompleted(),this.disposeCurrentRequest())},onError:function(t){this.hasFailed=!0,this.error=t,this.enableQueue&&0!==this.queue.length?this.queue.push(a.createOnError(t)):(this.subject.onError(t),this.disposeCurrentRequest())},onNext:function(t){this.requestedCount<=0?this.enableQueue&&this.queue.push(a.createOnNext(t)):(0==this.requestedCount--&&this.disposeCurrentRequest(),this.subject.onNext(t))},_processRequest:function(t){if(this.enableQueue)for(;this.queue.length>0&&(t>0||"N"!==this.queue[0].kind);){var e=this.queue.shift();e.accept(this.subject),"N"===e.kind?t--:(this.disposeCurrentRequest(),this.queue=[])}return t},request:function(t){this.disposeCurrentRequest();var e=this;return this.requestedDisposable=this.scheduler.schedule(t,(function(t,n){var r=e._processRequest(n);if(!e.hasCompleted&&!e.hasFailed&&r>0)return e.requestedCount=r,d((function(){e.requestedCount=0}))})),this.requestedDisposable},disposeCurrentRequest:function(){this.requestedDisposable&&(this.requestedDisposable.dispose(),this.requestedDisposable=null)}}),e}(i);o.controlled=function(t,e){return t&&m(t)&&(e=t,t=!0),null==t&&(t=!0),new D(this,t,e)};var A=function(t){function e(e){t.call(this),this.source=e}function n(t,e){return e.source.request(1)}b(e,t),e.prototype._subscribe=function(t){return this.subscription=this.source.subscribe(new r(t,this,this.subscription)),new c(this.subscription,_.schedule(this,n))};var r=function(t){function e(e,n,r){t.call(this),this.observer=e,this.observable=n,this.cancel=r,this.scheduleDisposable=null}function n(t,e){return e.observable.source.request(1)}return b(e,t),e.prototype.completed=function(){this.observer.onCompleted(),this.dispose()},e.prototype.error=function(t){this.observer.onError(t),this.dispose()},e.prototype.next=function(t){this.observer.onNext(t),this.scheduleDisposable=_.schedule(this,n)},e.dispose=function(){this.observer=null,this.cancel&&(this.cancel.dispose(),this.cancel=null),this.scheduleDisposable&&(this.scheduleDisposable.dispose(),this.scheduleDisposable=null),t.prototype.dispose.call(this)},e}(u);return e}(i);D.prototype.stopAndWait=function(){return new A(this)};var O=function(t){function e(e,n){t.call(this),this.source=e,this.windowSize=n}function n(t,e){return e.source.request(e.windowSize)}b(e,t),e.prototype._subscribe=function(t){return this.subscription=this.source.subscribe(new r(t,this,this.subscription)),new c(this.subscription,_.schedule(this,n))};var r=function(t){function e(e,n,r){this.observer=e,this.observable=n,this.cancel=r,this.received=0,this.scheduleDisposable=null,t.call(this)}function n(t,e){return e.observable.source.request(e.observable.windowSize)}return b(e,t),e.prototype.completed=function(){this.observer.onCompleted(),this.dispose()},e.prototype.error=function(t){this.observer.onError(t),this.dispose()},e.prototype.next=function(t){this.observer.onNext(t),this.received=++this.received%this.observable.windowSize,0===this.received&&(this.scheduleDisposable=_.schedule(this,n))},e.prototype.dispose=function(){this.observer=null,this.cancel&&(this.cancel.dispose(),this.cancel=null),this.scheduleDisposable&&(this.scheduleDisposable.dispose(),this.scheduleDisposable=null),t.prototype.dispose.call(this)},e}(u);return e}(i);return D.prototype.windowed=function(t){return new O(this,t)},o.pipe=function(t){var e=this.pausableBuffered();function n(){e.resume()}return t.addListener("drain",n),e.subscribe((function(n){!t.write(n)&&e.pause()}),(function(e){t.emit("error",e)}),(function(){!t._isStdio&&t.end(),t.removeListener("drain",n)})),e.resume(),t},n}))},506:function(t,e,n){var r,i;t=n.nmd(t),function(o){var s={function:!0,object:!0};function u(t){return t&&t.Object===Object?t:null}var c=s[typeof e]&&e&&!e.nodeType?e:null,h=s.object&&t&&!t.nodeType?t:null,a=u(c&&h&&"object"==typeof global&&global),l=u(s[typeof self]&&self),p=u(s[typeof window]&&window),f=(h&&h.exports,u(s[typeof this]&&this)),d=a||p!==(f&&f.window)&&p||l||f||Function("return this")();r=[n(374)],i=function(t,e){return o(d,e,t)}.apply(e,r),void 0===i||(t.exports=i)}.call(this,(function(t,e,n,r){var i=n.Observable,o=i.prototype,s=n.AnonymousObservable,u=n.ObservableBase,c=n.Subject,h=n.AsyncSubject,a=n.Observer,l=n.internals.ScheduledObserver,p=n.Disposable.create,f=n.Disposable.empty,d=n.BinaryDisposable,b=n.Scheduler.currentThread,v=n.helpers.isFunction,_=n.internals.inherits,y=n.internals.addProperties,w=n.Disposable.checkDisposed;function m(t){for(var e=t.length,n=new Array(e),r=0;r0},onCompleted:function(){if(w(this),!this.isStopped){this.isStopped=!0;for(var t=0,e=m(this.observers),n=e.length;t0},_trim:function(t){for(;this.q.length>this.bufferSize;)this.q.shift();for(;this.q.length>0&&t-this.q[0].interval>this.windowSize;)this.q.shift()},onNext:function(t){if(w(this),!this.isStopped){var e=this.scheduler.now();this.q.push({interval:e,value:t}),this._trim(e);for(var n=0,r=m(this.observers),i=r.length;n0){n=r.q.shift();var o=new b;r.d.add(o),o.setDisposable(n.subscribe(new R(r,i,o))),e([r,i])}else r.isAcquired=!1}return g(e,t),e.prototype._ensureActive=function(t){var e=!1;t.q.length>0&&(e=!t.isAcquired,t.isAcquired=!0),e&&t.m.setDisposable(this._scheduler.scheduleRecursive([t,this],n))},e.prototype.subscribeCore=function(t){var e=new d,n=new f(e),r={q:[],m:e,d:n,activeCount:0,isAcquired:!1,o:t};return r.q.push(this.source),r.activeCount++,this._ensureActive(r),n},e}(s),R=function(t){function e(e,n,r){this._s=e,this._p=n,this._m1=r,t.call(this)}return g(e,t),e.prototype.next=function(t){this._s.o.onNext(t);var e=j(this._p._fn)(t);if(e===O)return this._s.o.onError(e.e);this._s.q.push(e),this._s.activeCount++,this._p._ensureActive(this._s)},e.prototype.error=function(t){this._s.o.onError(t)},e.prototype.completed=function(){this._s.d.remove(this._m1),this._s.activeCount--,0===this._s.activeCount&&this._s.o.onCompleted()},e}(u);function P(){for(var t=arguments.length,e=new Array(t),n=0;ne?1:t=q&&r<=Or}function F(){if(O)try{throw new Error}catch(n){var t=n.stack.split("\n"),e=R(t[0].indexOf("@")>0?t[1]:t[2]);if(!e)return;return k=e[0],e[1]}}function R(t){var e=/at .+ \((.+):(\d+):(?:\d+)\)$/.exec(t);if(e)return[e[1],Number(e[2])];var n=/at ([^ ]+):(\d+):(?:\d+)$/.exec(t);if(n)return[n[1],Number(n[2])];var r=/.*@(.+):(\d+)$/.exec(t);return r?[r[1],Number(r[2])]:void 0}var P=v.EmptyError=function(){this.message="Sequence contains no elements.",Error.call(this)};P.prototype=Object.create(Error.prototype),P.prototype.name="EmptyError";var M=v.ObjectDisposedError=function(){this.message="Object has been disposed",Error.call(this)};M.prototype=Object.create(Error.prototype),M.prototype.name="ObjectDisposedError";var I=v.ArgumentOutOfRangeError=function(){this.message="Argument out of range",Error.call(this)};I.prototype=Object.create(Error.prototype),I.prototype.name="ArgumentOutOfRangeError";var V=v.NotSupportedError=function(t){this.message=t||"This operation is not supported",Error.call(this)};V.prototype=Object.create(Error.prototype),V.prototype.name="NotSupportedError";var B=v.NotImplementedError=function(t){this.message=t||"This operation is not implemented",Error.call(this)};B.prototype=Object.create(Error.prototype),B.prototype.name="NotImplementedError";var z=v.helpers.notImplemented=function(){throw new B},L=(v.helpers.notSupported=function(){throw new V},"function"==typeof Symbol&&Symbol.iterator||"_es6shim_iterator_");b.Set&&"function"==typeof(new b.Set)["@@iterator"]&&(L="@@iterator");var W=v.doneEnumerator={done:!0,value:i},U=v.helpers.isIterable=function(t){return t&&t[L]!==i},$=v.helpers.isArrayLike=function(t){return t&&t.length!==i};v.helpers.iterator=L;var H=v.internals.bindCallback=function(t,e,n){if(void 0===e)return t;switch(n){case 0:return function(){return t.call(e)};case 1:return function(n){return t.call(e,n)};case 2:return function(n,r){return t.call(e,n,r)};case 3:return function(n,r,i){return t.call(e,n,r,i)}}return function(){return t.apply(e,arguments)}},G="[object Arguments]",J="[object Array]",K="[object Boolean]",Q="[object Date]",X="[object Error]",Y="[object Number]",Z="[object Object]",tt="[object RegExp]",et="[object String]",nt={};nt["[object Float32Array]"]=nt["[object Float64Array]"]=nt["[object Int8Array]"]=nt["[object Int16Array]"]=nt["[object Int32Array]"]=nt["[object Uint8Array]"]=nt["[object Uint8ClampedArray]"]=nt["[object Uint16Array]"]=nt["[object Uint32Array]"]=!0,nt[G]=nt[J]=nt["[object ArrayBuffer]"]=nt[K]=nt[Q]=nt[X]=nt["[object Function]"]=nt["[object Map]"]=nt[Y]=nt[Z]=nt[tt]=nt["[object Set]"]=nt[et]=nt["[object WeakMap]"]=!1;var rt=Object.prototype,it=rt.hasOwnProperty,ot=rt.toString,st=Math.pow(2,53)-1,ut=Object.keys||function(){var t=Object.prototype.hasOwnProperty,e=!{toString:null}.propertyIsEnumerable("toString"),n=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],r=n.length;return function(i){if("object"!=typeof i&&("function"!=typeof i||null===i))throw new TypeError("Object.keys called on non-object");var o,s,u=[];for(o in i)t.call(i,o)&&u.push(o);if(e)for(s=0;s-1&&t%1==0&&t<=st}var pt=function(){try{Object({toString:0}+"")}catch(t){return function(){return!1}}return function(t){return"function"!=typeof t.toString&&"string"==typeof(t+"")}}(),ft=Array.isArray||function(t){return at(t)&<(t.length)&&ot.call(t)===J};function dt(t,e){for(var n=-1,r=t.length;++nc))return!1;for(;++u0;){var t=e.dequeue();!t.isCancelled()&&t.invoke()}}function r(){t.call(this)}return wt(r,t),r.prototype.schedule=function(t,r){var i=new It(this,t,r,this.now());if(e)e.enqueue(i);else{(e=new ne(4)).enqueue(i);var o=N(n)();e=null,o===D&&A(o.e)}return i.disposable},r.prototype.scheduleRequired=function(){return!e},r}(Bt),Jt=Bt.currentThread=new Gt,Kt=function(){var t,e=_;if(b.setTimeout)t=b.setTimeout,e=b.clearTimeout;else{if(!b.WScript)throw new V;t=function(t,e){b.WScript.Sleep(e),t()}}return{setTimeout:t,clearTimeout:e}}(),Qt=Kt.setTimeout,Xt=Kt.clearTimeout;!function(){var t=1,e={},n=!1;function r(t){if(n)Qt((function(){r(t)}),0);else{var i=e[t];if(i){n=!0;var o=N(i)();Ut(t),n=!1,o===D&&A(o.e)}}}Ut=function(t){delete e[t]};var i=new RegExp("^"+String(toString).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$"),o="function"==typeof(o=a&&f&&a.setImmediate)&&!i.test(o)&&o;if(E(o))Wt=function(n){var i=t++;return e[i]=n,o((function(){r(i)})),i};else if("undefined"!=typeof process&&"[object process]"==={}.toString.call(process))Wt=function(n){var i=t++;return e[i]=n,process.nextTick((function(){r(i)})),i};else if(function(){if(!b.postMessage||b.importScripts)return!1;var t=!1,e=b.onmessage;return b.onmessage=function(){t=!0},b.postMessage("","*"),b.onmessage=e,t}()){var s="ms.rx.schedule"+Math.random();b.addEventListener("message",(function(t){"string"==typeof t.data&&t.data.substring(0,s.length)===s&&r(t.data.substring(s.length))}),!1),Wt=function(n){var r=t++;return e[r]=n,b.postMessage(s+r,"*"),r}}else if(b.MessageChannel){var u=new b.MessageChannel;u.port1.onmessage=function(t){r(t.data)},Wt=function(n){var r=t++;return e[r]=n,u.port2.postMessage(r),r}}else Wt="document"in b&&"onreadystatechange"in b.document.createElement("script")?function(n){var i=b.document.createElement("script"),o=t++;return e[o]=n,i.onreadystatechange=function(){r(o),i.onreadystatechange=null,i.parentNode.removeChild(i),i=null},b.document.documentElement.appendChild(i),o}:function(n){var i=t++;return e[i]=n,Qt((function(){r(i)}),0),i}}();var Yt=function(t){function e(){t.call(this)}function n(t,e,n,r){return function(){t.setDisposable(St._fixup(e(n,r)))}}function r(t){this._id=t,this.isDisposed=!1}function i(t){this._id=t,this.isDisposed=!1}return wt(e,t),r.prototype.dispose=function(){this.isDisposed||(this.isDisposed=!0,Ut(this._id))},i.prototype.dispose=function(){this.isDisposed||(this.isDisposed=!0,Xt(this._id))},e.prototype.schedule=function(t,e){var i=new kt,o=Wt(n(i,e,this,t));return new Tt(i,new r(o))},e.prototype._scheduleFuture=function(t,e,r){if(0===e)return this.schedule(t,r);var o=new kt,s=Qt(n(o,r,this,t),e);return new Tt(o,new i(s))},e.prototype.scheduleLongRunning=function(t,e){var n=Dt(_);return Wt(function(t,e,n){return function(){e(t,n)}}(t,e,n)),n},e}(Bt),Zt=Bt.default=Bt.async=new Yt,te=function(t){function e(e,n){this._scheduler=e,this._handler=n,this._recursiveOriginal=null,this._recursiveWrapper=null,t.call(this)}return wt(e,t),e.prototype.schedule=function(t,e){return this._scheduler.schedule(t,this._wrap(e))},e.prototype._scheduleFuture=function(t,e,n){return this._scheduler.schedule(t,e,this._wrap(n))},e.prototype.now=function(){return this._scheduler.now()},e.prototype._clone=function(t){return new e(t,this._handler)},e.prototype._wrap=function(t){var e=this;return function(n,r){var i=N(t)(e._getRecursiveWrapper(n),r);return i===D?(e._handler(i.e)||A(i.e),Nt):jt(i)}},e.prototype._getRecursiveWrapper=function(t){if(this._recursiveOriginal!==t){this._recursiveOriginal=t;var e=this._clone(t);e._recursiveOriginal=t,e._recursiveWrapper=e,this._recursiveWrapper=e}return this._recursiveWrapper},e.prototype.schedulePeriodic=function(t,e,n){var r=this,i=!1,o=new kt;return o.setDisposable(this._scheduler.schedulePeriodic(t,e,(function(t){if(i)return null;var e=N(n)(t);return e===D?(i=!0,r._handler(e.e)||A(e.e),o.dispose(),null):e}))),o},e}(Bt);function ee(t,e){this.id=t,this.value=e}ee.prototype.compareTo=function(t){var e=this.value.compareTo(t.value);return 0===e&&(e=this.id-t.id),e};var ne=v.internals.PriorityQueue=function(t){this.items=new Array(t),this.length=0},re=ne.prototype;re.isHigherPriority=function(t,e){return this.items[t].compareTo(this.items[e])<0},re.percolate=function(t){if(!(t>=this.length||t<0)){var e=t-1>>1;if(!(e<0||e===t)&&this.isHigherPriority(t,e)){var n=this.items[t];this.items[t]=this.items[e],this.items[e]=n,this.percolate(e)}}},re.heapify=function(t){if(+t||(t=0),!(t>=this.length||t<0)){var e=2*t+1,n=2*t+2,r=t;if(e0){n=t.queue.shift();var r=N(n)();if(r===D)return t.queue=[],t.hasFaulted=!0,A(r.e);e(t)}else t.isAcquired=!1}return wt(e,t),e.prototype.next=function(t){this.queue.push(function(t,e){return function(){t.onNext(e)}}(this.observer,t))},e.prototype.error=function(t){this.queue.push(function(t,e){return function(){t.onError(e)}}(this.observer,t))},e.prototype.completed=function(){var t;this.queue.push((t=this.observer,function(){t.onCompleted()}))},e.prototype.ensureActive=function(){var t=!1;!this.hasFaulted&&this.queue.length>0&&(t=!this.isAcquired,this.isAcquired=!0),t&&this.disposable.setDisposable(this.scheduler.scheduleRecursive(this,n))},e.prototype.dispose=function(){t.prototype.dispose.call(this),this.disposable.dispose()},e}(de),ye=function(t){function e(e,n,r){t.call(this,e,n),this._cancel=r}return wt(e,t),e.prototype.next=function(e){t.prototype.next.call(this,e),this.ensureActive()},e.prototype.error=function(e){t.prototype.error.call(this,e),this.ensureActive()},e.prototype.completed=function(){t.prototype.completed.call(this),this.ensureActive()},e.prototype.dispose=function(){t.prototype.dispose.call(this),this._cancel&&this._cancel.dispose(),this._cancel=null},e}(_e),we=v.Observable=function(){function t(){if(v.config.longStackSupport&&O){var t=this._subscribe,e=N(A)(new Error).e;this.stack=e.stack.substring(e.stack.indexOf("\n")+1),this._subscribe=function(t,e){return function(n){var r=n.onError;return n.onError=function(e){(function(t,e){if(O&&e.stack&&"object"==typeof t&&null!==t&&t.stack&&-1===t.stack.indexOf("From previous event:")){for(var n=[],r=e;r;r=r.source)r.stack&&n.unshift(r.stack);n.unshift(t.stack);var i=n.join("\nFrom previous event:\n");t.stack=function(t){for(var e=t.split("\n"),n=[],r=0,i=e.length;r0&&this.l--,{done:!1,value:this.v})},e}(xe),Ne=xe.repeat=function(t,e){return new De(t,e)},Ae=function(t){function e(t,e,n){this.s=t,this.fn=e?H(e,n,3):null}function n(t){this.i=-1,this.s=t.s,this.l=this.s.length,this.fn=t.fn}return wt(e,t),e.prototype[L]=function(){return new n(this)},n.prototype.next=function(){return++this.iBe?Be:n:n),this._i=0}ze.prototype[L]=function(){return new Le(this._s)},Le.prototype[L]=function(){return this},Le.prototype.next=function(){return this._i0)&&(t.onNext(e),n>0&&n--),0===n)return t.onCompleted();r(n)}))},we.repeat=function(t,e,n){return Lt(n)||(n=Jt),new tn(t,e,n)};var nn=function(t){function e(e,n){this._value=e,this._scheduler=n,t.call(this)}function n(t,e){var n=e[0],r=e[1];return r.onNext(n),r.onCompleted(),Nt}return wt(e,t),e.prototype.subscribeCore=function(t){var e=[this._value,t];return this._scheduler===Ht?n(0,e):this._scheduler.schedule(e,n)},e}(me),rn=(we.return=we.just=function(t,e){return Lt(e)||(e=Ht),new nn(t,e)},function(t){function e(e,n){this._error=e,this._scheduler=n,t.call(this)}function n(t,e){var n=e[0];return e[1].onError(n),Nt}return wt(e,t),e.prototype.subscribeCore=function(t){var e=[this._error,t];return this._scheduler===Ht?n(0,e):this._scheduler.schedule(e,n)},e}(me)),on=we.throw=function(t,e){return Lt(e)||(e=Ht),new rn(t,e)},sn=function(t){function e(e,n){this._resFn=e,this._obsFn=n,t.call(this)}return wt(e,t),e.prototype.subscribeCore=function(t){var e=Nt,n=N(this._resFn)();if(n===D)return new Tt(on(n.e).subscribe(t),e);n&&(e=n);var r=N(this._obsFn)(n);return new Tt(r===D?on(r.e).subscribe(t):r.subscribe(t),e)},e}(me);function un(t,e){return t.amb(e)}we.using=function(t,e){return new sn(t,e)},fe.amb=function(t){var e=this;return new Er((function(n){var r,i="L",o="R",s=new kt,u=new kt;function c(){r||(r=i,u.dispose())}function h(){r||(r=o,s.dispose())}C(t)&&(t=Te(t));var a=pe((function(t){c(),r===i&&n.onNext(t)}),(function(t){c(),r===i&&n.onError(t)}),(function(){c(),r===i&&n.onCompleted()})),l=pe((function(t){h(),r===o&&n.onNext(t)}),(function(t){h(),r===o&&n.onError(t)}),(function(){h(),r===o&&n.onCompleted()}));return s.setDisposable(e.subscribe(a)),u.setDisposable(t.subscribe(l)),new Tt(s,u)}))},we.amb=function(){var t,e=Qe();if(Array.isArray(arguments[0]))t=arguments[0];else{var n=arguments.length;t=new Array(t);for(var r=0;r0?this.parent.handleSubscribe(this.parent.q.shift()):(this.parent.activeCount--,this.parent.done&&0===this.parent.activeCount&&this.parent.o.onCompleted())},e}(de);fe.merge=function(t){return"number"!=typeof t?gn(this,t):new wn(this,t)};var gn=we.merge=function(){var t,e,n=[],r=arguments.length;if(arguments[0])if(Lt(arguments[0]))for(t=arguments[0],e=1;e0}function r(t){return t.shift()}return wt(e,t),e.prototype.next=function(t){if(this._q[this._i].push(t),this._q.every(n)){var e=this._q.map(r),i=N(this._p._cb).apply(null,e);if(i===D)return this._o.onError(i.e);this._o.onNext(i)}else this._d.filter((o=this._i,function(t,e){return e!==o})).every(y)&&this._o.onCompleted();var o},e.prototype.error=function(t){this._o.onError(t)},e.prototype.completed=function(){this._d[this._i]=!0,this._d.every(y)&&this._o.onCompleted()},e}(de);function ln(){return!1}function Vn(){return[]}function pn(){for(var t=arguments.length,e=new Array(t),n=0;n0}function r(t){return t.shift()}return wt(e,t),e.prototype.next=function(t){if(this._s.q[this._i].push(t),this._s.q.every(n)){var e=this._s.q.map(r),i=N(this._s.cb).apply(null,e);if(i===D)return this._s.o.onError(i.e);this._s.o.onNext(i)}else this._s.done.filter((o=this._i,function(t,e){return e!==o})).every(y)&&this._s.o.onCompleted();var o},e.prototype.error=function(t){this._s.o.onError(t)},e.prototype.completed=function(){this._s.done[this._i]=!0,this._s.done.every(y)&&this._s.o.onCompleted()},e}(de);function Un(t){return t.toArray()}function $n(t){return t.length>0}fe.zipIterable=function(){if(0===arguments.length)throw new Error("invalid arguments");for(var t=arguments.length,e=new Array(t),n=0;nthis._c&&this._o.onNext(this._q.shift())},e.prototype.error=function(t){this._o.onError(t)},e.prototype.completed=function(){this._o.onCompleted()},e}(de);fe.skipLast=function(t){if(t<0)throw new I;return new sr(this,t)},fe.startWith=function(){var t,e=0;arguments.length&&Lt(arguments[0])?(t=arguments[0],e=1):t=Ht;for(var n=[],r=e,i=arguments.length;rthis._c&&this._q.shift()},e.prototype.error=function(t){this._o.onError(t)},e.prototype.completed=function(){for(;this._q.length>0;)this._o.onNext(this._q.shift());this._o.onCompleted()},e}(de);fe.takeLast=function(t){if(t<0)throw new I;var e=this;return new Er((function(n){return e.subscribe(new cr(n,t))}),e)};var hr=function(t){function e(e,n){this._o=e,this._c=n,this._q=[],t.call(this)}return wt(e,t),e.prototype.next=function(t){this._q.push(t),this._q.length>this._c&&this._q.shift()},e.prototype.error=function(t){this._o.onError(t)},e.prototype.completed=function(){this._o.onNext(this._q),this._o.onCompleted()},e}(de);fe.takeLastBuffer=function(t){if(t<0)throw new I;var e=this;return new Er((function(n){return e.subscribe(new hr(n,t))}),e)},fe.windowWithCount=fe.windowCount=function(t,e){var n=this;if(+t||(t=0),Math.abs(t)===1/0&&(t=0),t<=0)throw new I;if(null==e&&(e=t),+e||(e=0),Math.abs(e)===1/0&&(e=0),e<=0)throw new I;return new Er((function(r){var i=new kt,o=new Rt(i),s=0,u=[];function c(){var t=new Nr;u.push(t),r.onNext(gt(t,o))}return c(),i.setDisposable(n.subscribe((function(n){for(var r=0,i=u.length;r=0&&o%e==0&&u.shift().onCompleted(),++s%e==0&&c()}),(function(t){for(;u.length>0;)u.shift().onError(t);r.onError(t)}),(function(){for(;u.length>0;)u.shift().onCompleted();r.onCompleted()}))),o}),n)},fe.flatMapConcat=fe.concatMap=function(t,e,n){return new ge(this,t,e,n).merge(1)},fe.concatMapObserver=fe.selectConcatObserver=function(t,e,n,r){var i=this,o=H(t,r,2),s=H(e,r,1),u=H(n,r,0);return new Er((function(t){var e=0;return i.subscribe((function(n){var r;try{r=o(n,e++)}catch(e){return void t.onError(e)}C(r)&&(r=Te(r)),t.onNext(r)}),(function(e){var n;try{n=s(e)}catch(e){return void t.onError(e)}C(n)&&(n=Te(n)),t.onNext(n),t.onCompleted()}),(function(){var e;try{e=u()}catch(e){return void t.onError(e)}C(e)&&(e=Te(e)),t.onNext(e),t.onCompleted()}))}),this).concatAll()};var ar=function(t){function e(e,n){this._o=e,this._d=n,this._f=!1,t.call(this)}return wt(e,t),e.prototype.next=function(t){this._f=!0,this._o.onNext(t)},e.prototype.error=function(t){this._o.onError(t)},e.prototype.completed=function(){!this._f&&this._o.onNext(this._d),this._o.onCompleted()},e}(de);function lr(t){this.comparer=t,this.set=[]}fe.defaultIfEmpty=function(t){var e=this;return t===i&&(t=null),new Er((function(n){return e.subscribe(new ar(n,t))}),e)},lr.prototype.push=function(t){var e=-1===function(t,e,n){for(var r=0,i=t.length;r0&&(this._o.onNext(t),this._r<=0&&this._o.onCompleted())},n.prototype.error=function(t){this._o.onError(t)},n.prototype.completed=function(){this._o.onCompleted()},e}(me);fe.take=function(t,e){if(t<0)throw new I;return 0===t?Ie(e):new wr(this,t)};var mr=function(t){function e(e,n){this.source=e,this._fn=n,t.call(this)}return wt(e,t),e.prototype.subscribeCore=function(t){return this.source.subscribe(new gr(t,this))},e}(me),gr=function(t){function e(e,n){this._o=e,this._p=n,this._i=0,this._r=!0,t.call(this)}return wt(e,t),e.prototype.next=function(t){if(this._r&&(this._r=N(this._p._fn)(t,this._i++,this._p),this._r===D))return this._o.onError(this._r.e);this._r?this._o.onNext(t):this._o.onCompleted()},e.prototype.error=function(t){this._o.onError(t)},e.prototype.completed=function(){this._o.onCompleted()},e}(de);fe.takeWhile=function(t,e){var n=H(t,e,3);return new mr(this,n)};var xr=function(t){function e(e,n,r){this.source=e,this.predicate=H(n,r,3),t.call(this)}function n(t,e,n){this.o=t,this.predicate=e,this.source=n,this.i=0,de.call(this)}return wt(e,t),e.prototype.subscribeCore=function(t){return this.source.subscribe(new n(t,this.predicate,this))},e.prototype.internalFilter=function(t,n){return new e(this.source,function(t,e){return function(n,r,i){return e.predicate(n,r,i)&&t.call(this,n,r,i)}}(t,this),n)},wt(n,de),n.prototype.next=function(t){var e=N(this.predicate)(t,this.i++,this.source);if(e===D)return this.o.onError(e.e);e&&this.o.onNext(t)},n.prototype.error=function(t){this.o.onError(t)},n.prototype.completed=function(){this.o.onCompleted()},e}(me);fe.filter=fe.where=function(t,e){return this instanceof xr?this.internalFilter(t,e):new xr(this,t,e)};var Cr=function(t){function e(e,n){this._o=e,this._xform=n,t.call(this)}return wt(e,t),e.prototype.next=function(t){var e=N(this._xform["@@transducer/step"]).call(this._xform,this._o,t);e===D&&this._o.onError(e.e)},e.prototype.error=function(t){this._o.onError(t)},e.prototype.completed=function(){this._xform["@@transducer/result"](this._o)},e}(de);fe.transduce=function(t){var e=this;return new Er((function(n){var r=t(function(t){return{"@@transducer/init":function(){return t},"@@transducer/step":function(t,e){return t.onNext(e)},"@@transducer/result":function(t){return t.onCompleted()}}}(n));return e.subscribe(new Cr(n,r))}),e)};var Er=v.AnonymousObservable=function(t){function e(t,e){var n,r=e[0],i=e[1],o=N(i.__subscribe).call(i,r);o!==D||r.fail(D.e)||A(D.e),r.setDisposable((n=o)&&E(n.dispose)?n:E(n)?Dt(n):Nt)}function n(e,n){this.source=n,this.__subscribe=e,t.call(this)}return wt(n,t),n.prototype._subscribe=function(t){var n=new Sr(t),r=[n,this];return Jt.scheduleRequired()?Jt.schedule(r,e):e(0,r),n},n}(we),Sr=function(t){function e(e){t.call(this),this.observer=e,this.m=new kt}wt(e,t);var n=e.prototype;return n.next=function(t){var e=N(this.observer.onNext).call(this.observer,t);e===D&&(this.dispose(),A(e.e))},n.error=function(t){var e=N(this.observer.onError).call(this.observer,t);this.dispose(),e===D&&A(e.e)},n.completed=function(){var t=N(this.observer.onCompleted).call(this.observer);this.dispose(),t===D&&A(t.e)},n.setDisposable=function(t){this.m.setDisposable(t)},n.getDisposable=function(){return this.m.getDisposable()},n.dispose=function(){t.prototype.dispose.call(this),this.m.dispose()},e}(de),Dr=function(t,e){this._s=t,this._o=e};Dr.prototype.dispose=function(){if(!this._s.isDisposed&&null!==this._o){var t=this._s.observers.indexOf(this._o);this._s.observers.splice(t,1),this._o=null}};var Nr=v.Subject=function(t){function e(){t.call(this),this.isDisposed=!1,this.isStopped=!1,this.observers=[],this.hasError=!1}return wt(e,t),mt(e.prototype,le.prototype,{_subscribe:function(t){return Ot(this),this.isStopped?this.hasError?(t.onError(this.error),Nt):(t.onCompleted(),Nt):(this.observers.push(t),new Dr(this,t))},hasObservers:function(){return Ot(this),this.observers.length>0},onCompleted:function(){if(Ot(this),!this.isStopped){this.isStopped=!0;for(var t=0,e=S(this.observers),n=e.length;t0},onCompleted:function(){var t;if(Ot(this),!this.isStopped){this.isStopped=!0;var e=S(this.observers),n=e.length;if(this.hasValue)for(t=0;te?1:t0){var s=n.now();(i=new Date(i.getTime()+o)).getTime()<=s&&(i=new Date(s+o))}r.onNext(t),e(t+1,new Date(i))}))}))}function k(t,e,n){return t===e?new c((function(t){return n.schedulePeriodic(0,e,(function(e){return t.onNext(e),e+1}))})):a((function(){return j(new Date(n.now()+t),e,n)}))}var q=s.interval=function(t,e){return k(t,t,S(e)?e:f)};function T(t,e,n){return new c((function(r){var i,o=!1,s=new b,u=null,c=[],h=!1;return i=t.materialize().timestamp(n).subscribe((function(t){var i,a;"E"===t.value.kind?((c=[]).push(t),u=t.value.error,a=!h):(c.push({value:t.value,timestamp:t.timestamp+e}),a=!o,o=!0),a&&(null!==u?r.onError(u):(i=new d,s.setDisposable(i),i.setDisposable(n.scheduleRecursiveFuture(null,e,(function(t,e){var i,s,a,l;if(null===u){h=!0;do{a=null,c.length>0&&c[0].timestamp-n.now()<=0&&(a=c.shift().value),null!==a&&a.accept(r)}while(null!==a);l=!1,s=0,c.length>0?(l=!0,s=Math.max(0,c[0].timestamp-n.now())):o=!1,h=!1,null!==(i=u)?r.onError(i):l&&e(null,s)}})))))})),new _(i,s)}),t)}function F(t,e,n){return a((function(){return T(t,e-n.now(),n)}))}function R(t,e,n){var r,i;return E(e)?i=e:(r=e,i=n),new c((function(e){var n=new v,o=!1,s=new b;function u(){s.setDisposable(t.subscribe((function(t){var r=A(i)(t);if(r===N)return e.onError(r.e);var o=new d;n.add(o),o.setDisposable(r.subscribe((function(){e.onNext(t),n.remove(o),c()}),(function(t){e.onError(t)}),(function(){e.onNext(t),n.remove(o),c()})))}),(function(t){e.onError(t)}),(function(){o=!0,s.dispose(),c()})))}function c(){o&&0===n.length&&e.onCompleted()}return r?s.setDisposable(r.subscribe(u,(function(t){e.onError(t)}),u)):u(),new _(s,n)}),t)}s.timer=function(t,e,n){var i;return S(n)||(n=f),null!=e&&"number"==typeof e?i=e:S(e)&&(n=e),(t instanceof Date||"number"==typeof t)&&i===r?function(t,e){return new O(t,e)}(t,n):t instanceof Date&&i!==r?j(t,e,n):k(t,i,n)},u.delay=function(){var t=arguments[0];if("number"==typeof t||t instanceof Date){var e=t,n=arguments[1];return S(n)||(n=f),e instanceof Date?F(this,e,n):T(this,e,n)}if(s.isObservable(t)||E(t))return R(this,t,arguments[1]);throw new Error("Invalid arguments")};var P=function(t){function e(e,n,r){S(r)||(r=f),this.source=e,this._dt=n,this._s=r,t.call(this)}return i(e,t),e.prototype.subscribeCore=function(t){var e=new b;return new _(this.source.subscribe(new M(t,this._dt,this._s,e)),e)},e}(h),M=function(t){function e(e,n,r,i){this._o=e,this._d=n,this._scheduler=r,this._c=i,this._v=null,this._hv=!1,this._id=0,t.call(this)}return i(e,t),e.prototype.next=function(t){this._hv=!0,this._v=t;var e=++this._id,n=new d;this._c.setDisposable(n),n.setDisposable(this._scheduler.scheduleFuture(this,this._d,(function(n,r){r._hv&&r._id===e&&r._o.onNext(t),r._hv=!1})))},e.prototype.error=function(t){this._c.dispose(),this._o.onError(t),this._hv=!1,this._id++},e.prototype.completed=function(){this._c.dispose(),this._hv&&this._o.onNext(this._v),this._o.onCompleted(),this._hv=!1,this._id++},e}(o);function I(t,e){return new c((function(n){var r,i=!1,o=new b,s=0,u=t.subscribe((function(t){var u=A(e)(t);if(u===N)return n.onError(u.e);C(u)&&(u=D(u)),i=!0,r=t;var c=++s,h=new d;o.setDisposable(h),h.setDisposable(u.subscribe((function(){i&&s===c&&n.onNext(r),i=!1,h.dispose()}),(function(t){n.onError(t)}),(function(){i&&s===c&&n.onNext(r),i=!1,h.dispose()})))}),(function(t){o.dispose(),n.onError(t),i=!1,s++}),(function(){o.dispose(),i&&n.onNext(r),n.onCompleted(),i=!1,s++}));return new _(u,o)}),t)}function V(t){return t.toArray()}function V(t){return t.toArray()}u.debounce=function(){if(E(arguments[0]))return I(this,arguments[0]);if("number"==typeof arguments[0])return new P(this,arguments[0],arguments[1]);throw new Error("Invalid arguments")},u.windowWithTime=u.windowTime=function(t,e,n){var r,i=this;return null==e&&(r=t),S(n)||(n=f),"number"==typeof e?r=e:S(e)&&(r=t,n=e),new c((function(e){var o,s,u=r,c=t,h=[],a=new b,l=0;return o=new v(a),s=new y(o),h.push(new w),e.onNext(m(h[0],s)),function t(){var i=new d,o=!1,p=!1;a.setDisposable(i),c===u?(o=!0,p=!0):c0&&e-this._q[0].interval>=this._d;)this._o.onNext(this._q.shift().value)},e.prototype.error=function(t){this._o.onError(t)},e.prototype.completed=function(){for(var t=this._s.now();this._q.length>0&&t-this._q[0].interval>=this._d;)this._o.onNext(this._q.shift().value);this._o.onCompleted()},e}(o);u.skipLastWithTime=function(t,e){return S(e)||(e=f),new Z(this,t,e)};var et=function(t){function e(e,n,r){this.source=e,this._d=n,this._s=r,t.call(this)}return i(e,t),e.prototype.subscribeCore=function(t){return this.source.subscribe(new nt(t,this._d,this._s))},e}(h),nt=function(t){function e(e,n,r){this._o=e,this._d=n,this._s=r,this._q=[],t.call(this)}return i(e,t),e.prototype.next=function(t){var e=this._s.now();for(this._q.push({interval:e,value:t});this._q.length>0&&e-this._q[0].interval>=this._d;)this._q.shift()},e.prototype.error=function(t){this._o.onError(t)},e.prototype.completed=function(){for(var t=this._s.now();this._q.length>0;){var e=this._q.shift();t-e.interval<=this._d&&this._o.onNext(e.value)}this._o.onCompleted()},e}(o);u.takeLastWithTime=function(t,e){return S(e)||(e=f),new et(this,t,e)},u.takeLastBufferWithTime=function(t,e){var n=this;return S(e)||(e=f),new c((function(r){var i=[];return n.subscribe((function(n){var r=e.now();for(i.push({interval:r,value:n});i.length>0&&r-i[0].interval>=t;)i.shift()}),(function(t){r.onError(t)}),(function(){for(var n=e.now(),o=[];i.length>0;){var s=i.shift();n-s.interval<=t&&o.push(s.value)}r.onNext(o),r.onCompleted()}))}),n)};var rt=function(t){function e(e,n,r){this.source=e,this._d=n,this._s=r,t.call(this)}function n(t,e){e.onCompleted()}return i(e,t),e.prototype.subscribeCore=function(t){return new _(this._s.scheduleFuture(t,this._d,n),this.source.subscribe(t))},e}(h);u.takeWithTime=function(t,e){return S(e)||(e=f),new rt(this,t,e)};var it=function(t){function e(e,n,r){this.source=e,this._d=n,this._s=r,this._open=!1,t.call(this)}function n(t,e){e._open=!0}return i(e,t),e.prototype.subscribeCore=function(t){return new _(this._s.scheduleFuture(this,this._d,n),this.source.subscribe(new ot(t,this)))},e}(h),ot=function(t){function e(e,n){this._o=e,this._p=n,t.call(this)}return i(e,t),e.prototype.next=function(t){this._p._open&&this._o.onNext(t)},e.prototype.error=function(t){this._o.onError(t)},e.prototype.completed=function(){this._o.onCompleted()},e}(o);u.skipWithTime=function(t,e){return S(e)||(e=f),new it(this,t,e)};var st=function(t){function e(e,n,r){this.source=e,this._st=n,this._s=r,t.call(this)}function n(t,e){e._open=!0}return i(e,t),e.prototype.subscribeCore=function(t){return this._open=!1,new _(this._s.scheduleFuture(this,this._st,n),this.source.subscribe(new ut(t,this)))},e}(h),ut=function(t){function e(e,n){this._o=e,this._p=n,t.call(this)}return i(e,t),e.prototype.next=function(t){this._p._open&&this._o.onNext(t)},e.prototype.error=function(t){this._o.onError(t)},e.prototype.completed=function(){this._o.onCompleted()},e}(o);return u.skipUntilWithTime=function(t,e){return S(e)||(e=f),new st(this,t,e)},u.takeUntilWithTime=function(t,e){S(e)||(e=f);var n=this;return new c((function(r){return new _(e.scheduleFuture(r,t,(function(t,e){e.onCompleted()})),n.subscribe(r))}),n)},u.throttle=function(t,e){S(e)||(e=f);var n=+t||0;if(n<=0)throw new RangeError("windowDuration cannot be less or equal zero.");var r=this;return new c((function(t){var i=0;return r.subscribe((function(r){var o=e.now();(0===i||o-i>=n)&&(i=o,t.onNext(r))}),(function(e){t.onError(e)}),(function(){t.onCompleted()}))}),r)},n}))},887:function(t,e,n){var r,i;t=n.nmd(t),function(o){var s={function:!0,object:!0};function u(t){return t&&t.Object===Object?t:null}var c=s[typeof e]&&e&&!e.nodeType?e:null,h=s.object&&t&&!t.nodeType?t:null,a=u(c&&h&&"object"==typeof global&&global),l=u(s[typeof self]&&self),p=u(s[typeof window]&&window),f=(h&&h.exports,u(s[typeof this]&&this)),d=a||p!==(f&&f.window)&&p||l||f||Function("return this")();r=[n(374)],i=function(t,e){return o(d,e,t)}.apply(e,r),void 0===i||(t.exports=i)}.call(this,(function(t,e,n,r){var i=n.Scheduler,o=n.internals.ScheduledItem,s=n.internals.SchedulePeriodicRecursive,u=n.internals.PriorityQueue,c=n.internals.inherits,h=n.helpers.defaultSubComparer,a=n.helpers.notImplemented;return n.VirtualTimeScheduler=function(t){function e(e,n){this.clock=e,this.comparer=n,this.isEnabled=!1,this.queue=new u(1024),t.call(this)}c(e,t);var n=e.prototype;return n.now=function(){return this.toAbsoluteTime(this.clock)},n.schedule=function(t,e){return this.scheduleAbsolute(t,this.clock,e)},n.scheduleFuture=function(t,e,n){var r=e instanceof Date?this.toRelativeTime(e-this.now()):this.toRelativeTime(e);return this.scheduleRelative(t,r,n)},n.add=a,n.toAbsoluteTime=a,n.toRelativeTime=a,n.schedulePeriodic=function(t,e,n){return new s(this,t,e,n).start()},n.scheduleRelative=function(t,e,n){var r=this.add(this.clock,e);return this.scheduleAbsolute(t,r,n)},n.start=function(){if(!this.isEnabled){this.isEnabled=!0;do{var t=this.getNext();null!==t?(this.comparer(t.dueTime,this.clock)>0&&(this.clock=t.dueTime),t.invoke()):this.isEnabled=!1}while(this.isEnabled)}},n.stop=function(){this.isEnabled=!1},n.advanceTo=function(t){var e=this.comparer(this.clock,t);if(this.comparer(this.clock,t)>0)throw new ArgumentOutOfRangeError;if(0!==e&&!this.isEnabled){this.isEnabled=!0;do{var n=this.getNext();null!==n&&this.comparer(n.dueTime,t)<=0?(this.comparer(n.dueTime,this.clock)>0&&(this.clock=n.dueTime),n.invoke()):this.isEnabled=!1}while(this.isEnabled);this.clock=t}},n.advanceBy=function(t){var e=this.add(this.clock,t),n=this.comparer(this.clock,e);if(n>0)throw new ArgumentOutOfRangeError;0!==n&&this.advanceTo(e)},n.sleep=function(t){var e=this.add(this.clock,t);if(this.comparer(this.clock,e)>=0)throw new ArgumentOutOfRangeError;this.clock=e},n.getNext=function(){for(;this.queue.length>0;){var t=this.queue.peek();if(!t.isCancelled())return t;this.queue.dequeue()}return null},n.scheduleAbsolute=function(t,e,n){var r=this,i=new o(this,t,(function(t,e){return r.queue.remove(i),n(t,e)}),e,this.comparer);return this.queue.enqueue(i),i.disposable},e}(i),n.HistoricalScheduler=function(t){function e(e,n){var r=null==e?0:e,i=n||h;t.call(this,r,i)}c(e,t);var n=e.prototype;return n.add=function(t,e){return t+e},n.toAbsoluteTime=function(t){return new Date(t).getTime()},n.toRelativeTime=function(t){return t},e}(n.VirtualTimeScheduler),n}))},680:(t,e,n)=>{var r=n(374);n(230),n(139),n(910),n(506),n(847),n(576),n(909),n(402),n(887),n(534),n(215),t.exports=r},182:function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,o){function s(t){try{c(r.next(t))}catch(t){o(t)}}function u(t){try{c(r.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,u)}c((r=r.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.DefaultCodeSnippet=void 0;const i=n(496),o=n(548);class s{constructor(){}static get instance(){return this._instance||(this._instance=new s),this._instance}createCodeSnippet(t,e,n){return r(this,void 0,void 0,(function*(){return this.extractSnippet(t,e,n)}))}extractSnippet(t,e,n){return r(this,void 0,void 0,(function*(){let r=i.window.activeTextEditor,o=null==r?void 0:r.document.getText();return this.previewSnippet(t,e,o||"",n)}))}errorSnippet(t,e){return r(this,void 0,void 0,(function*(){return o.Misc.getFormattedHtml("",t,e)}))}previewSnippet(t,e,n,i){return r(this,void 0,void 0,(function*(){return o.Misc.getFormattedHtml("",`${n}`,i)}))}}e.DefaultCodeSnippet=s},85:function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,o){function s(t){try{c(r.next(t))}catch(t){o(t)}}function u(t){try{c(r.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,u)}c((r=r.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.MermaidCodeSnippet=void 0;const i=n(496),o=n(147),s=n(17),u=n(548);var c;!function(t){t.dark="dark",t.forest="forest",t.neutral="neutral"}(c||(c={}));const h="#fafaf6";class a{constructor(){this.fixedStyle=c.forest,this.fixedBackgroundColor=h}}class l{constructor(){this._configMermaid=new a,this._configMermaid.fixedStyle=c.forest,this._configMermaid.fixedBackgroundColor=h;var t=i.workspace.getConfiguration("previewSeqDiag");if(t&&t.mermaid){switch(t.mermaid.fixedStyle){case c.dark:case c.forest:case c.neutral:this._configMermaid.fixedStyle=t.mscgen.fixedNamedStyle}null!==t.mermaid.fixedBackgroundColor&&(this._configMermaid.fixedBackgroundColor=t.mermaid.fixedBackgroundColor)}}static get instance(){return this._instance||(this._instance=new l),this._instance}createCodeSnippet(t,e,n){return r(this,void 0,void 0,(function*(){return this.extractSnippet(t,e,n)}))}extractSnippet(t,e,n){return r(this,void 0,void 0,(function*(){let r=i.window.activeTextEditor,u=(null==r?void 0:r.document.getText())||"";try{u=u.replace(/%%[ \t]+import[ \t]?:[ \t]?(.+)/g,((t,e)=>{if(!r)return"";let n=r.document.uri.fsPath.toString().split(s.sep);n.pop();const i=n.join(s.sep)+s.sep+e.trim();return o.readFileSync(i,"utf8").replace(/sequenceDiagram/g,"")}))}catch(t){console.error(t)}return this.previewSnippet(t,e,u,n)}))}errorSnippet(t,e){return r(this,void 0,void 0,(function*(){return u.Misc.getFormattedHtml("",t,e)}))}previewSnippet(t,e,n,o){return r(this,void 0,void 0,(function*(){var t=i.Uri.file(s.join(e,"dist","mermaid","mermaid.min.js"));const r=o.asWebviewUri(t);return u.Misc.getFormattedHtml(`\n `,\n `
\n
${payLoad}
\n \n
`,\n webview);\n }\n}\n","'use strict';\n\nimport * as vscode from 'vscode';\nimport * as Path from 'path';\n\nexport class Misc\n{\n public static previewUri = vscode.Uri.parse('previewSeqDiag://authority/previewSeqDiag');\n\n public static getFormattedHtml(head: string, body: string, webview: vscode.Webview): string\n {\n var fileName = vscode.window.activeTextEditor?.document.fileName || \"PreviewSeqDiagImage\";\n fileName = fileName.substring(fileName.lastIndexOf(\"\\\\\")+1).substring(fileName.lastIndexOf(\"/\")+1);\n\n return ``\n + ``\n + head\n + ``\n + ``\n + `
\n PNG\n PNG*\n JPEG\n SVG\n Clipboard\n
`\n + ``\n + body\n + ``;\n }\n}\n","'use strict';\n\nimport * as vscode from 'vscode';\nimport { workspace, window, commands, ExtensionContext } from 'vscode';\nimport { CodeSnippetInterface } from './codeSnippetInterface';\nimport { Misc } from './misc';\nimport * as Path from 'path';\n\n\ntype StyleName = \"classic\" | \"cygne\" | \"fountainpen\" | \"lazy\" | \"pegasse\";\nnamespace StyleName{\n export const classic = \"classic\";\n export const cygne = \"cygne\";\n export const fountainpen = \"fountainpen\";\n export const lazy = \"lazy\";\n export const pegasse = \"pegasse\";\n}\n\ntype Alignment = \"fixed\" | \"stretch\";\nnamespace Alignment{\n export const fixed = \"fixed\";\n export const stretch = \"stretch\";\n}\n\nclass ConfigMscgen\n{\n public fixedNamedStyle: StyleName = StyleName.classic;\n public horizontalAlignment: Alignment = Alignment.stretch;\n}\n\n\nexport class MscgenCodeSnippet implements CodeSnippetInterface\n{\n private static _instance:MscgenCodeSnippet;\n\n private _configMscgen: ConfigMscgen;\n\n private constructor()\n {\n this._configMscgen = new ConfigMscgen();\n\n // defaults\n this._configMscgen.fixedNamedStyle = StyleName.cygne;\n this._configMscgen.horizontalAlignment = Alignment.stretch;\n\n var config = vscode.workspace.getConfiguration('previewSeqDiag');\n if(!!config && !!config.mscgen)\n {\n // fixedNamedStyle\n switch(config.mscgen.fixedNamedStyle)\n {\n case StyleName.classic:\n case StyleName.cygne:\n case StyleName.fountainpen:\n case StyleName.lazy:\n case StyleName.pegasse:\n this._configMscgen.fixedNamedStyle = config.mscgen.fixedNamedStyle;\n break;\n\n default:\n break;\n }\n\n // horizontalAlignment\n switch(config.mscgen.horizontalAlignment)\n {\n case Alignment.fixed:\n this._configMscgen.horizontalAlignment = Alignment.fixed;\n break;\n\n default:\n break;\n }\n }\n }\n\n public static get instance():MscgenCodeSnippet\n {\n if (!this._instance){\n this._instance = new MscgenCodeSnippet();\n }\n \n return this._instance;\n }\n \n public async createCodeSnippet(languageId: string, extentiponPath:string, webview: vscode.Webview): Promise\n {\n return this.extractSnippet(languageId, extentiponPath, webview);\n }\n\n private async extractSnippet(languageId: string, extentiponPath:string, webview: vscode.Webview): Promise\n {\n let editor = vscode.window.activeTextEditor;\n let text = editor?.document.getText() || \"\";\n return this.previewSnippet(languageId,extentiponPath, text, webview);\n }\n\n private async errorSnippet(error: string, webview: vscode.Webview): Promise\n {\n return Misc.getFormattedHtml(\"\",error, webview);\n }\n\n private async previewSnippet(languageId: string, extentiponPath:string, payLoad: string, webview: vscode.Webview): Promise\n {\n var jsPath = vscode.Uri.file(Path.join(extentiponPath, 'dist','mscgenjs-inpage', 'mscgen-inpage.js'));\n const jsSrc = webview.asWebviewUri(jsPath);\n return Misc.getFormattedHtml(\n `\n `\n + ((this._configMscgen.horizontalAlignment === Alignment.stretch) ? `` : ``)\n ,\n `
\n ${payLoad}\n \n \n
\n `,\n webview);\n }\n}\n","'use strict';\n\nimport * as vscode from 'vscode';\nimport { Misc } from './misc';\nimport { CodeSnippetInterface } from './codeSnippetInterface';\nimport { DefaultCodeSnippet } from './defaultCodeSnippet';\nimport { MscgenCodeSnippet } from './mscgenCodeSnippet';\nimport { MermaidCodeSnippet } from './mermaidCodeSnippet';\n\nconst suppotablelanguageId: string[] = [\"mermaid\",\"mmd\",\"mscgen\",\"msgenny\",\"xu\"];\n\nexport class PreviewSeqDiagDocumentContentProvider implements vscode.TextDocumentContentProvider\n{\n latestSnippetResultBuffer: string = \"\";\n webViewPanel: vscode.WebviewPanel | null = null;\n extentionPath: string = \"\";\n \n private _currentSnippet : CodeSnippetInterface = DefaultCodeSnippet.instance;\n\n // private _onDidChange: vscode.EventEmitter = new vscode.EventEmitter();\n\t// readonly onDidChange: vscode.Event = this._onDidChange.event;\n\n public setCurrentWebViewPanel(panel: vscode.WebviewPanel) {\n this.webViewPanel = panel;\n }\n\n public getExtensionPath(path: string) {\n this.extentionPath = path;\n }\n\n public update(uri: vscode.Uri) {\n if(vscode.window.activeTextEditor) {\n if(suppotablelanguageId.indexOf(vscode.window.activeTextEditor.document.languageId) > -1) {\n // this._onDidChange.fire(uri);\n this.refresh();\n }\n }\n }\n\n public provideTextDocumentContent(uri: vscode.Uri, token: vscode.CancellationToken): vscode.ProviderResult {\n return this.latestSnippetResultBuffer;\n }\n\n private refresh() {\n let editor = vscode.window.activeTextEditor;\n\n if(!editor){\n return this.latestSnippetResultBuffer;\n }\n\n switch (editor.document.languageId) {\n case \"mermaid\":\n case \"mmd\":\n this._currentSnippet = MermaidCodeSnippet.instance;\n break;\n\n case \"mscgen\":\n case \"msgenny\":\n case \"xu\":\n this._currentSnippet = MscgenCodeSnippet.instance;\n break;\n\n default:\n this._currentSnippet = DefaultCodeSnippet.instance;\n break;\n }\n\n if(this.webViewPanel && this.webViewPanel.webview){\n this._currentSnippet\n .createCodeSnippet(editor.document.languageId, this.extentionPath, this.webViewPanel.webview)\n .then(result=>{\n this.latestSnippetResultBuffer = result;\n if(this.webViewPanel && this.webViewPanel.webview){\n this.webViewPanel.webview.html = result;\n }\n })\n .catch();\n }\n }\n}\n","module.exports = require(\"vscode\");","module.exports = require(\"events\");","module.exports = require(\"fs\");","module.exports = require(\"path\");","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\tid: moduleId,\n\t\tloaded: false,\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Flag the module as loaded\n\tmodule.loaded = true;\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","__webpack_require__.nmd = (module) => {\n\tmodule.paths = [];\n\tif (!module.children) module.children = [];\n\treturn module;\n};","'use strict';\n\nimport * as vscode from 'vscode';\nimport { workspace, window, commands, ExtensionContext } from 'vscode';\nimport * as path from 'path';\nimport * as Rx from 'rx';\nimport { EventEmitter } from 'events';\nimport { Misc } from './misc';\nimport { PreviewSeqDiagDocumentContentProvider } from './previewSeqDiagDocumentContentProvider';\n\nexport function activate(context: vscode.ExtensionContext) {\n\n\tconst provider = new PreviewSeqDiagDocumentContentProvider();\n\n\tlet showPreview = vscode.commands.registerCommand('previewSeqDiag.showPreview', () => {\n\t\tconst panel = vscode.window.createWebviewPanel(\n\t\t\t'previewSeqDiag',\n\t\t\t'Preview Sequence Diagrams',\n\t\t\tvscode.ViewColumn.Two,\n\t\t\t{\n\t\t\t\tenableScripts: true,\n\t\t\t\tlocalResourceRoots: [\n\t\t\t\t\tvscode.Uri.file(path.join(context.extensionPath, 'dist/mermaid')),\n\t\t\t\t\tvscode.Uri.file(path.join(context.extensionPath, 'dist/mscgenjs-inpage')),\n\t\t\t\t]\n\t\t\t}\n\t\t);\n\t\tprovider.getExtensionPath(context.extensionPath);\n\t\tprovider.setCurrentWebViewPanel(panel);\n\t\tprovider.update(Misc.previewUri);\n\t});\n\n\tcontext.subscriptions.push(showPreview);\n\n\tconst emitter = new EventEmitter();\n\tconst _ = Rx.Observable\n\t\t.fromEvent(emitter, 'update')\n\t\t.debounce(500 /* ms */)\n\t\t.subscribe(\n\t\t\t(_) => {\n\t\t\t\tprovider.update(Misc.previewUri);\n\t\t\t}\n\t\t);\n\t\n\twindow.onDidChangeActiveTextEditor(\n\t\t(e) => {\n\t\t\tif (!!e && !!e.document && (e === window.activeTextEditor)) {\n\t\t\t\tprovider.update(Misc.previewUri);\n\t\t\t}\n\t\t}\n\t);\n\n\tworkspace.onDidChangeTextDocument(\n\t\t(e) => {\n\t\t\tif (e.document === vscode.window.activeTextEditor?.document) {\n\t\t\t\temitter.emit('update', e);\n\t\t\t}\n\t\t}\n\t);\n\n\tcontext.subscriptions.push(\n\t\tvscode.workspace.registerTextDocumentContentProvider(Misc.previewUri.scheme, provider)\n\t);\n}\n\n// this method is called when your extension is deactivated\nexport function deactivate() {}\n"],"names":["factory","objectTypes","checkGlobal","value","Object","freeExports","exports","nodeType","freeModule","module","freeGlobal","global","freeSelf","self","freeWindow","window","thisGlobal","this","root","Function","Rx","call","exp","undefined","Observable","observableProto","prototype","BinaryDisposable","AnonymousObservable","AbstractObserver","internals","disposableEmpty","Disposable","empty","helpers","defaultComparer","identity","defaultSubComparer","isFunction","isPromise","isArrayLike","isIterable","inherits","observableFromPromise","fromPromise","observableFrom","from","bindCallback","EmptyError","ObservableBase","ArgumentOutOfRangeError","errorObj","e","tryCatch","fn","TypeError","tryCatchTarget","apply","arguments","ExtremaByObservable","__super__","source","k","c","_k","_c","subscribeCore","o","subscribe","ExtremaByObserver","_o","_v","_hv","_l","next","x","key","onError","comparison","push","error","completed","onNext","onCompleted","firstOnly","length","ReduceObservable","accumulator","hasSeed","seed","observer","ReduceObserver","parent","_p","_fn","_hs","_s","_ha","_a","_i","reduce","SomeObservable","SomeObserver","s","result","Boolean","some","predicate","thisArg","IsEmptyObservable","IsEmptyObserver","isEmpty","EveryObservable","EveryObserver","every","IncludesObservable","elem","idx","n","Math","abs","Infinity","_elem","_n","IncludesObserver","a","b","isNaN","includes","searchElement","fromIndex","CountObservable","CountObserver","count","IndexOfObservable","_e","IndexOfObserver","indexOf","SumObservable","SumObserver","sum","keySelector","minBy","comparer","y","min","map","maxBy","max","AverageObservable","AverageObserver","_t","r","average","sequenceEqual","second","first","donel","doner","ql","qr","subscription1","v","shift","equal","subscription2","ElementAtObservable","i","d","_d","ElementAtObserver","elementAt","index","defaultValue","SingleObserver","obj","_obj","shouldYield","res","Error","single","FirstObservable","FirstObserver","LastObservable","LastObserver","last","FindValueObserver","callback","yieldIndex","_cb","_y","shouldRun","findValue","find","findIndex","ToSetObservable","ToSetObserver","Set","add","toSet","ToMapObservable","ToMapObserver","_m","Map","set","toMap","elementSelector","SliceObservable","_b","SliceObserver","slice","begin","end","start","LastIndexOfObservable","LastIndexOfObserver","lastIndexOf","observableThrow","throwError","AsyncSubject","CompositeDisposable","create","defaultScheduler","Scheduler","immediate","isScheduler","wrap","createObservable","spawn","__generatorFunction__","gen","args","len","g","processGenerator","ret","err","done","obs","toObservable","hasValue","isObservable","val","ctor","constructor","name","displayName","isGenerator","isGeneratorFunction","thunkToObservable","arrayToObservable","isObject","objectToObservable","concatMap","just","toArray","results","keys","observables","observable","defer","forkJoin","func","context","scheduler","observableToAsync","toAsync","subject","schedule","asObservable","createCbObservable","ctx","selector","Array","createCbHandler","createNodeObservable","createNodeHandler","ListenDisposable","addEventListener","isDisposed","createEventListener","el","eventName","handler","disposables","elemToString","toString","StaticNodeList","NodeList","isNodeList","item","fromCallback","fromNodeCallback","dispose","removeEventListener","config","useNativeEvents","EventObservable","_el","createHandler","fromEvent","element","addListener","fromEventPattern","h","removeListener","on","off","publish","refCount","EventPatternObservable","del","_add","_del","EventPatternDisposable","_ret","returnValue","addHandler","removeHandler","startAsync","functionAsync","promise","NAryDisposable","Notification","Subject","Observer","disposableCreate","addProperties","currentThreadScheduler","currentThread","checkDisposed","Pauser","pause","resume","PausableObservable","pauser","controller","paused","merge","_subscribe","conn","subscription","connection","pausable","startWith","distinctUntilChanged","connect","PausableBufferedObservable","previousShouldFire","resultSelector","q","drainQueue","data","shouldFire","hasValueAll","isDone","values","pausableBuffered","ControlledObservable","enableQueue","ControlledSubject","multicast","request","numberOfItems","queue","requestedCount","requestedDisposable","hasFailed","hasCompleted","createOnCompleted","disposeCurrentRequest","createOnError","createOnNext","_processRequest","kind","accept","number","remaining","controlled","StopAndWaitObservable","scheduleMethod","StopAndWaitObserver","__sub__","cancel","scheduleDisposable","innerScheduleMethod","stopAndWait","WindowedObservable","windowSize","WindowedObserver","received","windowed","pipe","dest","onDrain","write","emit","_isStdio","ScheduledObserver","cloneArray","arr","MulticastObservable","fn1","fn2","_fn1","_fn2","connectable","subjectOrSubjectSelector","ConnectableObservable","share","publishLast","publishValue","initialValueOrSelector","initialValue","BehaviorSubject","shareValue","replay","bufferSize","ReplaySubject","shareReplay","InnerSubscription","observers","splice","isStopped","hasError","getValue","thrower","hasObservers","os","maxSafeInteger","pow","so","_trim","now","ensureActive","interval","RefCountObservable","_count","_connectableSubscription","RefCountDisposable","p","_connection","_source","_subject","ConnectDisposable","singleInstance","hasObservable","SingleAssignmentDisposable","SerialDisposable","observableEmpty","observableNever","never","addRef","noop","size","_values","_keys","get","forEach","cb","observableWindowWithOpenings","windowOpenings","windowClosingSelector","groupJoin","_","win","observableWindowWithBoundaries","windowBoundaries","w","observableWindowWithClosingSelector","m","createWindowClose","windowClose","m1","setDisposable","take","join","right","leftDurationSelector","rightDurationSelector","left","group","leftDone","rightDone","leftId","rightId","leftMap","rightMap","handleError","id","md","duration","remove","buffer","flatMap","windowOpeningsOrClosingSelector","PairwiseObservable","PairwiseObserver","_hp","pairwise","partition","filter","groupBy","groupByUntil","durationSelector","groupDisposable","refCountDisposable","fireNewMapEntry","writer","GroupedObservable","durationGroup","UnderlyingObservable","u","_u","getDisposable","underlyingObservable","mergedDisposable","FlatMapObservable","observableConcat","concat","observableDefer","Enumerable","enumerableOf","of","$iterator$","Symbol","iterator","doneEnumerator","WhileEnumerable","letBind","condition","thenSource","elseSourceOrScheduler","forIn","sources","observableWhileDo","whileDo","enumerableWhile","doWhile","defaultSourceOrScheduler","ExpandObservable","_scheduler","scheduleRecursive","recurse","work","state","ExpandObserver","isAcquired","_ensureActive","isOwner","activeCount","_m1","argumentsToArray","expand","ForkJoinObservable","_sources","finished","hasResults","subscriptions","ForkJoinObserver","subs","_subs","pop","isArray","unshift","manySelect","extend","chain","curr","ChainObservable","tap","observeOn","head","tail","mergeAll","SwitchFirstObservable","hasCurrent","SwitchFirstObserver","InnerObserver","inner","switchFirst","flatMapFirst","exhaustMap","flatMapWithMaxConcurrent","flatMapMaxConcurrent","limit","observerCreate","Pattern","patterns","Plan","expression","planCreateObserver","externalSubscriptions","entry","JoinObserver","ActivePlan","joinObserverArray","joinObservers","joinObserver","and","other","thenDo","activate","deactivate","errHandler","activePlan","handleOnNext","j","jlen","removeActivePlan","addActivePlan","dequeue","match","hasValues","firstValues","isCompleted","activePlans","JoinObserverPrototype","notification","materialize","when","plans","outObserver","isFn","moduleExports","Promise","defaultNow","Date","isEqual","defaultError","defaultKeySerializer","then","longStackSupport","hasStacks","stacks","stack","rFileName","rStartingLine","captureLine","isInternalFrame","stackLine","fileNameAndLineNumber","getFileNameAndLineNumber","fileName","lineNumber","rEndingLine","lines","split","attempt1","exec","Number","attempt2","attempt3","message","ObjectDisposedError","NotSupportedError","NotImplementedError","notImplemented","notSupported","argCount","arg","collection","argsTag","arrayTag","boolTag","dateTag","errorTag","numberTag","objectTag","regexpTag","stringTag","typedArrayTags","objectProto","hasOwnProperty","objToString","MAX_SAFE_INTEGER","hasDontEnumBug","propertyIsEnumerable","dontEnums","dontEnumsLength","prop","equalObjects","object","equalFunc","isLoose","stackA","stackB","objProps","objLength","skipCtor","objValue","othValue","objCtor","othCtor","type","isObjectLike","isLength","isHostObject","arraySome","array","equalArrays","arrLength","othLength","arrValue","baseIsEqualDeep","objIsArr","othIsArr","objTag","othTag","objIsObj","othIsObj","isSameTag","tag","equalByTag","objIsWrapped","othIsWrapped","baseIsEqual","child","__","ln","xs","arrayInitialize","CompositeDisposablePrototype","shouldDispose","currentDisposables","action","isDisposable","disposable","disposableFixup","_fixup","current","old","_first","_second","old1","old2","_disposables","InnerDisposable","isInnerDisposed","underlyingDisposable","isPrimaryDisposed","ScheduledDisposable","scheduleItem","ScheduledItem","dueTime","invoke","invokeCore","compareTo","isCancelled","schedulerProto","scheduleFuture","dt","normalize","_scheduleFuture","timeSpan","normalizeTime","invokeRecImmediate","pair","innerAction","state2","isAdded","state3","invokeRecDate","dueTime1","scheduleRecursiveFuture","schedulePeriodic","period","setInterval","clearInterval","catchError","CatchScheduler","SchedulePeriodicRecursive","_state","_period","_action","_cancel","command","createTick","clearMethod","ImmediateScheduler","immediateScheduler","CurrentThreadScheduler","runTrampoline","si","enqueue","PriorityQueue","scheduleRequired","localTimer","localSetTimeout","localClearTimeout","setTimeout","clearTimeout","WScript","time","Sleep","nextHandle","tasksByHandle","currentlyRunning","runTask","handle","task","reNative","RegExp","String","replace","setImmediate","test","process","nextTick","postMessage","importScripts","isAsync","oldHandler","onmessage","postMessageSupported","MSG_PREFIX","random","event","substring","MessageChannel","channel","port1","port2","document","createElement","scriptElement","onreadystatechange","parentNode","removeChild","documentElement","appendChild","DefaultScheduler","scheduleAction","ClearDisposable","_id","LocalClearDisposable","scheduleLongRunning","async","_handler","_recursiveOriginal","_recursiveWrapper","_wrap","_clone","_getRecursiveWrapper","wrapper","failed","state1","IndexedItem","capacity","items","priorityProto","isHigherPriority","percolate","temp","heapify","peek","removeAt","_accept","_acceptObserver","observerOrOnNext","OnNextNotification","OnErrorNotification","OnCompletedNotification","notificationCreateOnNext","notificationCreateOnError","notificationCreateOnCompleted","toNotifier","asObserver","AnonymousObserver","checked","CheckedObserver","fromNotifier","notifyOn","ObserveOnObserver","makeSafe","AnonymousSafeObserver","_onNext","_onError","_onCompleted","fail","_observer","CheckedObserverPrototype","checkAccess","hasFaulted","enqueueNext","enqueueError","oldSubscribe","oldOnError","concatedStacks","stackString","desiredLines","line","filterStackString","makeStackTraceLong","makeSubscribe","oOrOnNext","subscribeOnNext","subscribeOnError","subscribeOnCompleted","subscriber","ado","sub","AutoDetachObserver","_wrapResult","i2","IsDisposedDisposable","ConcatEnumerableObservable","currentItem","currentValue","_recurse","cancelable","CatchErrorObservable","lastError","RepeatEnumerable","RepeatEnumerator","l","enumerableRepeat","repeat","repeatCount","OfEnumerable","OfEnumerator","ObserveOnObservable","SubscribeOnObservable","subscribeOn","FromPromiseObservable","scheduleNext","scheduleError","sad","toPromise","promiseCtor","resolve","reject","ToArrayObservable","Defer","_f","EmptyObservable","observableFactory","EmptySink","run","EMPTY_OBSERVABLE","FromObservable","iterable","_iterable","it","StringIterable","ArrayIterable","getIterable","createScheduleMethod","StringIterator","ArrayIterator","isFinite","sign","floor","charAt","mapFn","mapper","FromArrayObservable","_args","observableFromArray","fromArray","GenerateObservable","cndFn","itrFn","resFn","_initialState","_cndFn","_itrFn","_resFn","newState","hasResult","generate","initialState","iterate","NEVER_OBSERVABLE","NeverObservable","observableOf","ofWithScheduler","PairsObservable","pairs","RangeObservable","rangeCount","loopRecursive","range","RepeatObservable","RepeatSink","JustObservable","_value","ThrowObservable","_error","UsingObservable","obsFn","_obsFn","resource","amb","using","resourceFactory","rightSource","leftSource","choice","leftChoice","rightChoice","leftSubscription","rightSubscription","choiceL","choiceR","leftSubscribe","rightSubscribe","acc","CatchObservable","d1","CatchObserver","handlerOrSecond","observableCatch","falseFactory","combineLatest","CombineLatestObservable","params","_params","CombineLatestObserver","ConcatObserver","ConcatObservable","concatAll","MergeObservable","maxConcurrent","MergeObserver","handleSubscribe","innerSource","maxConcurrentOrOther","observableMerge","CompositeError","errors","innerErrors","MergeDelayErrorObservable","MergeDelayErrorObserver","_group","setCompletion","_inner","mergeDelayError","MergeAllObservable","MergeAllObserver","onErrorResumeNext","OnErrorResumeNextObservable","pos","OnErrorResumeNextObserver","cancellable","SkipUntilObservable","_open","SkipUntilSourceObserver","SkipUntilOtherObserver","_r","skipUntil","SwitchObservable","SwitchObserver","stopped","latest","hasLatest","switchLatest","TakeUntilObservable","TakeUntilObserver","takeUntil","WithLatestFromObservable","_ss","WithLatestFromOtherObserver","outerSad","WithLatestFromSourceObserver","allValues","emptyArrayFactory","withLatestFrom","ZipObservable","ZipObserver","_q","notEmpty","shiftEach","queuedValues","zip","ZipIterableObservable","ZipIterableObserver","zipIterable","bufferWithCount","bufferCount","skip","windowWithCount","DematerializeObservable","DematerializeObserver","dematerialize","DistinctUntilChangedObservable","keyFn","DistinctUntilChangedObserver","hasCurrentKey","currentKey","comparerEquals","TapObservable","_oN","_oE","_oC","t","doAction","doOnNext","tapOnNext","doOnError","tapOnError","doOnCompleted","tapOnCompleted","FinallyObservable","FinallyDisposable","IgnoreElementsObservable","ignoreElements","MaterializeObservable","MaterializeObserver","retry","retryCount","RetryWhenObservable","createDisposable","notifier","_notifier","exceptions","notificationDisposable","outer","exn","ex","retryWhen","RepeatWhenObservable","completions","repeatWhen","ScanObservable","ScanObserver","scan","SkipLastObservable","SkipLastObserver","skipLast","TakeLastObserver","takeLast","TakeLastBufferObserver","takeLastBuffer","windowCount","createWindow","flatMapConcat","concatMapObserver","selectConcatObserver","onNextFunc","onErrorFunc","onCompletedFunc","DefaultIfEmptyObserver","HashSet","defaultIfEmpty","retValue","arrayIndexOfComparer","DistinctObservable","cmpFn","_keyFn","_cmpFn","DistinctObserver","_h","distinct","MapObservable","internalMap","innerMap","plucker","currentProp","select","selectorFn","pluck","flatMapObserver","selectManyObserver","selectMany","mergeMap","flatMapLatest","switchMap","SkipObservable","SkipObserver","SkipWhileObservable","SkipWhileObserver","skipWhile","TakeObservable","TakeObserver","TakeWhileObservable","TakeWhileObserver","takeWhile","FilterObservable","internalFilter","innerPredicate","where","TransduceObserver","xform","_xform","transduce","transducer","input","transformForObserver","__subscribe","AutoDetachObserverPrototype","AnonymousSubject","jortSort","jortSortUntil","bind","sorted","sort","VirtualTimeScheduler","OnNextPredicate","OnErrorPredicate","equals","ReactiveTest","created","subscribed","disposed","ticks","Recorded","Subscription","unsubscribe","MAX_VALUE","MockDisposable","disposes","clock","MockObserver","messages","MockObserverPrototype","MockPromise","innerNotification","scheduleAbsolute","jLen","onResolved","onRejected","newPromise","HotObservable","ColdObservable","scheduleRelative","TestScheduler","baseComparer","absolute","relative","toAbsoluteTime","getTime","toRelativeTime","startScheduler","createFn","settings","createObserver","createHotObservable","createColdObservable","createResolvedPromise","createRejectedPromise","reason","TimerObservable","_dt","observableTimerDateAndPeriod","observableTimerTimeSpanAndPeriod","observableinterval","observableDelayRelative","active","exception","running","timestamp","recurseDueTime","shouldRecurse","observableDelayAbsolute","delayWithSelector","subscriptionDelay","delayDurationSelector","subDelay","delays","atEnd","delay","timer","periodOrScheduler","_observableTimer","firstArg","DebounceObservable","DebounceObserver","currentId","debounceWithSelector","throttle","currentid","debounce","windowWithTime","windowTime","timeShiftOrScheduler","timeShift","nextShift","nextSpan","timerD","totalTime","createTimer","isSpan","isShift","newTotalTime","ts","windowWithTimeOrCount","windowTimeOrCount","windowId","newId","newWindow","bufferWithTime","bufferTime","bufferWithTimeOrCount","bufferTimeOrCount","TimeIntervalObservable","TimeIntervalObserver","span","timeInterval","TimestampObservable","TimestampObserver","SampleObservable","sampler","_sampler","sourceSubscription","SampleSourceObserver","SamplerObserver","_handleMessage","sample","intervalOrSampler","TimeoutError","timeoutWithSelector","firstTimeout","timeoutDurationSelector","original","switched","setTimer","timeout","myId","timerWins","oWins","GenerateAbsoluteObservable","timeFn","_timeFn","generateWithAbsoluteTime","timeSelector","GenerateRelativeObservable","generateWithRelativeTime","DelaySubscription","delaySubscription","SkipLastWithTimeObservable","SkipLastWithTimeObserver","skipLastWithTime","TakeLastWithTimeObservable","TakeLastWithTimeObserver","takeLastWithTime","takeLastBufferWithTime","TakeWithTimeObservable","takeWithTime","SkipWithTimeObservable","SkipWithTimeObserver","skipWithTime","SkipUntilWithTimeObservable","startTime","_st","SkipUntilWithTimeObserver","skipUntilWithTime","takeUntilWithTime","endTime","windowDuration","RangeError","lastOnNext","initialClock","isEnabled","VirtualTimeSchedulerPrototype","runAt","getNext","stop","advanceTo","dueToClock","advanceBy","sleep","HistoricalScheduler","cmp","HistoricalSchedulerProto","DefaultCodeSnippet","instance","_instance","createCodeSnippet","languageId","extentiponPath","webview","extractSnippet","editor","vscode","activeTextEditor","text","getText","previewSnippet","errorSnippet","Misc","getFormattedHtml","payLoad","StyleName","dark","forest","neutral","backgroundColorDefault","ConfigMermaid","fixedStyle","fixedBackgroundColor","MermaidCodeSnippet","_configMermaid","workspace","getConfiguration","mermaid","mscgen","fixedNamedStyle","subsequenceFile","dirname","uri","fsPath","Path","sep","trim","fs","readFileSync","console","jsPath","Uri","file","jsSrc","asWebviewUri","static","body","cspSource","previewUri","parse","Alignment","classic","cygne","fountainpen","lazy","pegasse","fixed","stretch","ConfigMscgen","horizontalAlignment","MscgenCodeSnippet","_configMscgen","suppotablelanguageId","latestSnippetResultBuffer","webViewPanel","extentionPath","_currentSnippet","setCurrentWebViewPanel","panel","getExtensionPath","path","update","refresh","provideTextDocumentContent","token","html","catch","require","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","loaded","__webpack_modules__","nmd","paths","children","provider","PreviewSeqDiagDocumentContentProvider","showPreview","commands","registerCommand","createWebviewPanel","ViewColumn","Two","enableScripts","localResourceRoots","extensionPath","emitter","EventEmitter","onDidChangeActiveTextEditor","onDidChangeTextDocument","registerTextDocumentContentProvider","scheme"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/mermaid/mermaid.js b/dist/mermaid/mermaid.js index b32033b..26b2bbd 100644 --- a/dist/mermaid/mermaid.js +++ b/dist/mermaid/mermaid.js @@ -1,54380 +1,2 @@ -var __defProp = Object.defineProperty; -var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; -var __publicField = (obj, key, value) => { - __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); - return value; -}; -(function(global2, factory) { - typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() : typeof define === "function" && define.amd ? define(factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, global2.mermaid = factory()); -})(this, function() { - "use strict"; - var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {}; - function getAugmentedNamespace(n) { - var f = n.default; - if (typeof f == "function") { - var a2 = function() { - return f.apply(this, arguments); - }; - a2.prototype = f.prototype; - } else - a2 = {}; - Object.defineProperty(a2, "__esModule", { value: true }); - Object.keys(n).forEach(function(k2) { - var d = Object.getOwnPropertyDescriptor(n, k2); - Object.defineProperty(a2, k2, d.get ? d : { - enumerable: true, - get: function() { - return n[k2]; - } - }); - }); - return a2; - } - function commonjsRequire(path2) { - throw new Error('Could not dynamically require "' + path2 + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); - } - var moment_min = { exports: {} }; - (function(module3, exports2) { - !function(e, t) { - module3.exports = t(); - }(commonjsGlobal, function() { - var H; - function f() { - return H.apply(null, arguments); - } - function a2(e3) { - return e3 instanceof Array || "[object Array]" === Object.prototype.toString.call(e3); - } - function F(e3) { - return null != e3 && "[object Object]" === Object.prototype.toString.call(e3); - } - function c2(e3, t4) { - return Object.prototype.hasOwnProperty.call(e3, t4); - } - function L(e3) { - if (Object.getOwnPropertyNames) - return 0 === Object.getOwnPropertyNames(e3).length; - for (var t4 in e3) - if (c2(e3, t4)) - return; - return 1; - } - function o(e3) { - return void 0 === e3; - } - function u2(e3) { - return "number" == typeof e3 || "[object Number]" === Object.prototype.toString.call(e3); - } - function V(e3) { - return e3 instanceof Date || "[object Date]" === Object.prototype.toString.call(e3); - } - function G(e3, t4) { - for (var n2 = [], s3 = e3.length, i2 = 0; i2 < s3; ++i2) - n2.push(t4(e3[i2], i2)); - return n2; - } - function E2(e3, t4) { - for (var n2 in t4) - c2(t4, n2) && (e3[n2] = t4[n2]); - return c2(t4, "toString") && (e3.toString = t4.toString), c2(t4, "valueOf") && (e3.valueOf = t4.valueOf), e3; - } - function l(e3, t4, n2, s3) { - return Pt(e3, t4, n2, s3, true).utc(); - } - function m2(e3) { - return null == e3._pf && (e3._pf = { empty: false, unusedTokens: [], unusedInput: [], overflow: -2, charsLeftOver: 0, nullInput: false, invalidEra: null, invalidMonth: null, invalidFormat: false, userInvalidated: false, iso: false, parsedDateParts: [], era: null, meridiem: null, rfc2822: false, weekdayMismatch: false }), e3._pf; - } - function A5(e3) { - if (null == e3._isValid) { - var t4 = m2(e3), n2 = j.call(t4.parsedDateParts, function(e4) { - return null != e4; - }), n2 = !isNaN(e3._d.getTime()) && t4.overflow < 0 && !t4.empty && !t4.invalidEra && !t4.invalidMonth && !t4.invalidWeekday && !t4.weekdayMismatch && !t4.nullInput && !t4.invalidFormat && !t4.userInvalidated && (!t4.meridiem || t4.meridiem && n2); - if (e3._strict && (n2 = n2 && 0 === t4.charsLeftOver && 0 === t4.unusedTokens.length && void 0 === t4.bigHour), null != Object.isFrozen && Object.isFrozen(e3)) - return n2; - e3._isValid = n2; - } - return e3._isValid; - } - function I(e3) { - var t4 = l(NaN); - return null != e3 ? E2(m2(t4), e3) : m2(t4).userInvalidated = true, t4; - } - var j = Array.prototype.some || function(e3) { - for (var t4 = Object(this), n2 = t4.length >>> 0, s3 = 0; s3 < n2; s3++) - if (s3 in t4 && e3.call(this, t4[s3], s3, t4)) - return true; - return false; - }, Z = f.momentProperties = [], z = false; - function $(e3, t4) { - var n2, s3, i2, r2 = Z.length; - if (o(t4._isAMomentObject) || (e3._isAMomentObject = t4._isAMomentObject), o(t4._i) || (e3._i = t4._i), o(t4._f) || (e3._f = t4._f), o(t4._l) || (e3._l = t4._l), o(t4._strict) || (e3._strict = t4._strict), o(t4._tzm) || (e3._tzm = t4._tzm), o(t4._isUTC) || (e3._isUTC = t4._isUTC), o(t4._offset) || (e3._offset = t4._offset), o(t4._pf) || (e3._pf = m2(t4)), o(t4._locale) || (e3._locale = t4._locale), 0 < r2) - for (n2 = 0; n2 < r2; n2++) - o(i2 = t4[s3 = Z[n2]]) || (e3[s3] = i2); - return e3; - } - function q(e3) { - $(this, e3), this._d = new Date(null != e3._d ? e3._d.getTime() : NaN), this.isValid() || (this._d = new Date(NaN)), false === z && (z = true, f.updateOffset(this), z = false); - } - function h(e3) { - return e3 instanceof q || null != e3 && null != e3._isAMomentObject; - } - function B2(e3) { - false === f.suppressDeprecationWarnings && "undefined" != typeof console && console.warn && console.warn("Deprecation warning: " + e3); - } - function e(r2, a3) { - var o2 = true; - return E2(function() { - if (null != f.deprecationHandler && f.deprecationHandler(null, r2), o2) { - for (var e3, t4, n2 = [], s3 = arguments.length, i2 = 0; i2 < s3; i2++) { - if (e3 = "", "object" == typeof arguments[i2]) { - for (t4 in e3 += "\n[" + i2 + "] ", arguments[0]) - c2(arguments[0], t4) && (e3 += t4 + ": " + arguments[0][t4] + ", "); - e3 = e3.slice(0, -2); - } else - e3 = arguments[i2]; - n2.push(e3); - } - B2(r2 + "\nArguments: " + Array.prototype.slice.call(n2).join("") + "\n" + new Error().stack), o2 = false; - } - return a3.apply(this, arguments); - }, a3); - } - var J = {}; - function Q(e3, t4) { - null != f.deprecationHandler && f.deprecationHandler(e3, t4), J[e3] || (B2(t4), J[e3] = true); - } - function d(e3) { - return "undefined" != typeof Function && e3 instanceof Function || "[object Function]" === Object.prototype.toString.call(e3); - } - function X3(e3, t4) { - var n2, s3 = E2({}, e3); - for (n2 in t4) - c2(t4, n2) && (F(e3[n2]) && F(t4[n2]) ? (s3[n2] = {}, E2(s3[n2], e3[n2]), E2(s3[n2], t4[n2])) : null != t4[n2] ? s3[n2] = t4[n2] : delete s3[n2]); - for (n2 in e3) - c2(e3, n2) && !c2(t4, n2) && F(e3[n2]) && (s3[n2] = E2({}, s3[n2])); - return s3; - } - function K2(e3) { - null != e3 && this.set(e3); - } - f.suppressDeprecationWarnings = false, f.deprecationHandler = null; - var ee = Object.keys || function(e3) { - var t4, n2 = []; - for (t4 in e3) - c2(e3, t4) && n2.push(t4); - return n2; - }; - function r(e3, t4, n2) { - var s3 = "" + Math.abs(e3); - return (0 <= e3 ? n2 ? "+" : "" : "-") + Math.pow(10, Math.max(0, t4 - s3.length)).toString().substr(1) + s3; - } - var te = /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|N{1,5}|YYYYYY|YYYYY|YYYY|YY|y{2,4}|yo?|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g, ne = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g, se = {}, ie = {}; - function s2(e3, t4, n2, s3) { - var i2 = "string" == typeof s3 ? function() { - return this[s3](); - } : s3; - e3 && (ie[e3] = i2), t4 && (ie[t4[0]] = function() { - return r(i2.apply(this, arguments), t4[1], t4[2]); - }), n2 && (ie[n2] = function() { - return this.localeData().ordinal(i2.apply(this, arguments), e3); - }); - } - function re2(e3, t4) { - return e3.isValid() ? (t4 = ae(t4, e3.localeData()), se[t4] = se[t4] || function(s3) { - for (var e4, i2 = s3.match(te), t5 = 0, r2 = i2.length; t5 < r2; t5++) - ie[i2[t5]] ? i2[t5] = ie[i2[t5]] : i2[t5] = (e4 = i2[t5]).match(/\[[\s\S]/) ? e4.replace(/^\[|\]$/g, "") : e4.replace(/\\/g, ""); - return function(e6) { - for (var t6 = "", n2 = 0; n2 < r2; n2++) - t6 += d(i2[n2]) ? i2[n2].call(e6, s3) : i2[n2]; - return t6; - }; - }(t4), se[t4](e3)) : e3.localeData().invalidDate(); - } - function ae(e3, t4) { - var n2 = 5; - function s3(e4) { - return t4.longDateFormat(e4) || e4; - } - for (ne.lastIndex = 0; 0 <= n2 && ne.test(e3); ) - e3 = e3.replace(ne, s3), ne.lastIndex = 0, --n2; - return e3; - } - var oe = {}; - function t(e3, t4) { - var n2 = e3.toLowerCase(); - oe[n2] = oe[n2 + "s"] = oe[t4] = e3; - } - function _2(e3) { - return "string" == typeof e3 ? oe[e3] || oe[e3.toLowerCase()] : void 0; - } - function ue(e3) { - var t4, n2, s3 = {}; - for (n2 in e3) - c2(e3, n2) && (t4 = _2(n2)) && (s3[t4] = e3[n2]); - return s3; - } - var le = {}; - function n(e3, t4) { - le[e3] = t4; - } - function he(e3) { - return e3 % 4 == 0 && e3 % 100 != 0 || e3 % 400 == 0; - } - function y2(e3) { - return e3 < 0 ? Math.ceil(e3) || 0 : Math.floor(e3); - } - function g(e3) { - var e3 = +e3, t4 = 0; - return t4 = 0 != e3 && isFinite(e3) ? y2(e3) : t4; - } - function de(t4, n2) { - return function(e3) { - return null != e3 ? (fe(this, t4, e3), f.updateOffset(this, n2), this) : ce(this, t4); - }; - } - function ce(e3, t4) { - return e3.isValid() ? e3._d["get" + (e3._isUTC ? "UTC" : "") + t4]() : NaN; - } - function fe(e3, t4, n2) { - e3.isValid() && !isNaN(n2) && ("FullYear" === t4 && he(e3.year()) && 1 === e3.month() && 29 === e3.date() ? (n2 = g(n2), e3._d["set" + (e3._isUTC ? "UTC" : "") + t4](n2, e3.month(), We(n2, e3.month()))) : e3._d["set" + (e3._isUTC ? "UTC" : "") + t4](n2)); - } - var i = /\d/, w2 = /\d\d/, me = /\d{3}/, _e = /\d{4}/, ye = /[+-]?\d{6}/, p = /\d\d?/, ge = /\d\d\d\d?/, we = /\d\d\d\d\d\d?/, pe = /\d{1,3}/, ke = /\d{1,4}/, ve = /[+-]?\d{1,6}/, Me = /\d+/, De = /[+-]?\d+/, Se = /Z|[+-]\d\d:?\d\d/gi, Ye = /Z|[+-]\d\d(?::?\d\d)?/gi, k2 = /[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i; - function v(e3, n2, s3) { - be[e3] = d(n2) ? n2 : function(e4, t4) { - return e4 && s3 ? s3 : n2; - }; - } - function Oe(e3, t4) { - return c2(be, e3) ? be[e3](t4._strict, t4._locale) : new RegExp(M2(e3.replace("\\", "").replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function(e4, t5, n2, s3, i2) { - return t5 || n2 || s3 || i2; - }))); - } - function M2(e3) { - return e3.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&"); - } - var be = {}, xe = {}; - function D2(e3, n2) { - var t4, s3, i2 = n2; - for ("string" == typeof e3 && (e3 = [e3]), u2(n2) && (i2 = function(e4, t5) { - t5[n2] = g(e4); - }), s3 = e3.length, t4 = 0; t4 < s3; t4++) - xe[e3[t4]] = i2; - } - function Te(e3, i2) { - D2(e3, function(e4, t4, n2, s3) { - n2._w = n2._w || {}, i2(e4, n2._w, n2, s3); - }); - } - var S, Y3 = 0, O = 1, b = 2, x2 = 3, T = 4, N = 5, Ne = 6, Pe = 7, Re = 8; - function We(e3, t4) { - if (isNaN(e3) || isNaN(t4)) - return NaN; - var n2 = (t4 % (n2 = 12) + n2) % n2; - return e3 += (t4 - n2) / 12, 1 == n2 ? he(e3) ? 29 : 28 : 31 - n2 % 7 % 2; - } - S = Array.prototype.indexOf || function(e3) { - for (var t4 = 0; t4 < this.length; ++t4) - if (this[t4] === e3) - return t4; - return -1; - }, s2("M", ["MM", 2], "Mo", function() { - return this.month() + 1; - }), s2("MMM", 0, 0, function(e3) { - return this.localeData().monthsShort(this, e3); - }), s2("MMMM", 0, 0, function(e3) { - return this.localeData().months(this, e3); - }), t("month", "M"), n("month", 8), v("M", p), v("MM", p, w2), v("MMM", function(e3, t4) { - return t4.monthsShortRegex(e3); - }), v("MMMM", function(e3, t4) { - return t4.monthsRegex(e3); - }), D2(["M", "MM"], function(e3, t4) { - t4[O] = g(e3) - 1; - }), D2(["MMM", "MMMM"], function(e3, t4, n2, s3) { - s3 = n2._locale.monthsParse(e3, s3, n2._strict); - null != s3 ? t4[O] = s3 : m2(n2).invalidMonth = e3; - }); - var Ce = "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), Ue = "Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"), He = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/, Fe = k2, Le = k2; - function Ve(e3, t4) { - var n2; - if (e3.isValid()) { - if ("string" == typeof t4) { - if (/^\d+$/.test(t4)) - t4 = g(t4); - else if (!u2(t4 = e3.localeData().monthsParse(t4))) - return; - } - n2 = Math.min(e3.date(), We(e3.year(), t4)), e3._d["set" + (e3._isUTC ? "UTC" : "") + "Month"](t4, n2); - } - } - function Ge(e3) { - return null != e3 ? (Ve(this, e3), f.updateOffset(this, true), this) : ce(this, "Month"); - } - function Ee() { - function e3(e4, t5) { - return t5.length - e4.length; - } - for (var t4, n2 = [], s3 = [], i2 = [], r2 = 0; r2 < 12; r2++) - t4 = l([2e3, r2]), n2.push(this.monthsShort(t4, "")), s3.push(this.months(t4, "")), i2.push(this.months(t4, "")), i2.push(this.monthsShort(t4, "")); - for (n2.sort(e3), s3.sort(e3), i2.sort(e3), r2 = 0; r2 < 12; r2++) - n2[r2] = M2(n2[r2]), s3[r2] = M2(s3[r2]); - for (r2 = 0; r2 < 24; r2++) - i2[r2] = M2(i2[r2]); - this._monthsRegex = new RegExp("^(" + i2.join("|") + ")", "i"), this._monthsShortRegex = this._monthsRegex, this._monthsStrictRegex = new RegExp("^(" + s3.join("|") + ")", "i"), this._monthsShortStrictRegex = new RegExp("^(" + n2.join("|") + ")", "i"); - } - function Ae(e3) { - return he(e3) ? 366 : 365; - } - s2("Y", 0, 0, function() { - var e3 = this.year(); - return e3 <= 9999 ? r(e3, 4) : "+" + e3; - }), s2(0, ["YY", 2], 0, function() { - return this.year() % 100; - }), s2(0, ["YYYY", 4], 0, "year"), s2(0, ["YYYYY", 5], 0, "year"), s2(0, ["YYYYYY", 6, true], 0, "year"), t("year", "y"), n("year", 1), v("Y", De), v("YY", p, w2), v("YYYY", ke, _e), v("YYYYY", ve, ye), v("YYYYYY", ve, ye), D2(["YYYYY", "YYYYYY"], Y3), D2("YYYY", function(e3, t4) { - t4[Y3] = 2 === e3.length ? f.parseTwoDigitYear(e3) : g(e3); - }), D2("YY", function(e3, t4) { - t4[Y3] = f.parseTwoDigitYear(e3); - }), D2("Y", function(e3, t4) { - t4[Y3] = parseInt(e3, 10); - }), f.parseTwoDigitYear = function(e3) { - return g(e3) + (68 < g(e3) ? 1900 : 2e3); - }; - var Ie = de("FullYear", true); - function je(e3, t4, n2, s3, i2, r2, a3) { - var o2; - return e3 < 100 && 0 <= e3 ? (o2 = new Date(e3 + 400, t4, n2, s3, i2, r2, a3), isFinite(o2.getFullYear()) && o2.setFullYear(e3)) : o2 = new Date(e3, t4, n2, s3, i2, r2, a3), o2; - } - function Ze(e3) { - var t4; - return e3 < 100 && 0 <= e3 ? ((t4 = Array.prototype.slice.call(arguments))[0] = e3 + 400, t4 = new Date(Date.UTC.apply(null, t4)), isFinite(t4.getUTCFullYear()) && t4.setUTCFullYear(e3)) : t4 = new Date(Date.UTC.apply(null, arguments)), t4; - } - function ze(e3, t4, n2) { - n2 = 7 + t4 - n2; - return n2 - (7 + Ze(e3, 0, n2).getUTCDay() - t4) % 7 - 1; - } - function $e(e3, t4, n2, s3, i2) { - var r2, t4 = 1 + 7 * (t4 - 1) + (7 + n2 - s3) % 7 + ze(e3, s3, i2), n2 = t4 <= 0 ? Ae(r2 = e3 - 1) + t4 : t4 > Ae(e3) ? (r2 = e3 + 1, t4 - Ae(e3)) : (r2 = e3, t4); - return { year: r2, dayOfYear: n2 }; - } - function qe(e3, t4, n2) { - var s3, i2, r2 = ze(e3.year(), t4, n2), r2 = Math.floor((e3.dayOfYear() - r2 - 1) / 7) + 1; - return r2 < 1 ? s3 = r2 + P(i2 = e3.year() - 1, t4, n2) : r2 > P(e3.year(), t4, n2) ? (s3 = r2 - P(e3.year(), t4, n2), i2 = e3.year() + 1) : (i2 = e3.year(), s3 = r2), { week: s3, year: i2 }; - } - function P(e3, t4, n2) { - var s3 = ze(e3, t4, n2), t4 = ze(e3 + 1, t4, n2); - return (Ae(e3) - s3 + t4) / 7; - } - s2("w", ["ww", 2], "wo", "week"), s2("W", ["WW", 2], "Wo", "isoWeek"), t("week", "w"), t("isoWeek", "W"), n("week", 5), n("isoWeek", 5), v("w", p), v("ww", p, w2), v("W", p), v("WW", p, w2), Te(["w", "ww", "W", "WW"], function(e3, t4, n2, s3) { - t4[s3.substr(0, 1)] = g(e3); - }); - function Be(e3, t4) { - return e3.slice(t4, 7).concat(e3.slice(0, t4)); - } - s2("d", 0, "do", "day"), s2("dd", 0, 0, function(e3) { - return this.localeData().weekdaysMin(this, e3); - }), s2("ddd", 0, 0, function(e3) { - return this.localeData().weekdaysShort(this, e3); - }), s2("dddd", 0, 0, function(e3) { - return this.localeData().weekdays(this, e3); - }), s2("e", 0, 0, "weekday"), s2("E", 0, 0, "isoWeekday"), t("day", "d"), t("weekday", "e"), t("isoWeekday", "E"), n("day", 11), n("weekday", 11), n("isoWeekday", 11), v("d", p), v("e", p), v("E", p), v("dd", function(e3, t4) { - return t4.weekdaysMinRegex(e3); - }), v("ddd", function(e3, t4) { - return t4.weekdaysShortRegex(e3); - }), v("dddd", function(e3, t4) { - return t4.weekdaysRegex(e3); - }), Te(["dd", "ddd", "dddd"], function(e3, t4, n2, s3) { - s3 = n2._locale.weekdaysParse(e3, s3, n2._strict); - null != s3 ? t4.d = s3 : m2(n2).invalidWeekday = e3; - }), Te(["d", "e", "E"], function(e3, t4, n2, s3) { - t4[s3] = g(e3); - }); - var Je = "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), Qe = "Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"), Xe = "Su_Mo_Tu_We_Th_Fr_Sa".split("_"), Ke = k2, et = k2, tt = k2; - function nt() { - function e3(e4, t5) { - return t5.length - e4.length; - } - for (var t4, n2, s3, i2 = [], r2 = [], a3 = [], o2 = [], u3 = 0; u3 < 7; u3++) - s3 = l([2e3, 1]).day(u3), t4 = M2(this.weekdaysMin(s3, "")), n2 = M2(this.weekdaysShort(s3, "")), s3 = M2(this.weekdays(s3, "")), i2.push(t4), r2.push(n2), a3.push(s3), o2.push(t4), o2.push(n2), o2.push(s3); - i2.sort(e3), r2.sort(e3), a3.sort(e3), o2.sort(e3), this._weekdaysRegex = new RegExp("^(" + o2.join("|") + ")", "i"), this._weekdaysShortRegex = this._weekdaysRegex, this._weekdaysMinRegex = this._weekdaysRegex, this._weekdaysStrictRegex = new RegExp("^(" + a3.join("|") + ")", "i"), this._weekdaysShortStrictRegex = new RegExp("^(" + r2.join("|") + ")", "i"), this._weekdaysMinStrictRegex = new RegExp("^(" + i2.join("|") + ")", "i"); - } - function st() { - return this.hours() % 12 || 12; - } - function it(e3, t4) { - s2(e3, 0, 0, function() { - return this.localeData().meridiem(this.hours(), this.minutes(), t4); - }); - } - function rt(e3, t4) { - return t4._meridiemParse; - } - s2("H", ["HH", 2], 0, "hour"), s2("h", ["hh", 2], 0, st), s2("k", ["kk", 2], 0, function() { - return this.hours() || 24; - }), s2("hmm", 0, 0, function() { - return "" + st.apply(this) + r(this.minutes(), 2); - }), s2("hmmss", 0, 0, function() { - return "" + st.apply(this) + r(this.minutes(), 2) + r(this.seconds(), 2); - }), s2("Hmm", 0, 0, function() { - return "" + this.hours() + r(this.minutes(), 2); - }), s2("Hmmss", 0, 0, function() { - return "" + this.hours() + r(this.minutes(), 2) + r(this.seconds(), 2); - }), it("a", true), it("A", false), t("hour", "h"), n("hour", 13), v("a", rt), v("A", rt), v("H", p), v("h", p), v("k", p), v("HH", p, w2), v("hh", p, w2), v("kk", p, w2), v("hmm", ge), v("hmmss", we), v("Hmm", ge), v("Hmmss", we), D2(["H", "HH"], x2), D2(["k", "kk"], function(e3, t4, n2) { - e3 = g(e3); - t4[x2] = 24 === e3 ? 0 : e3; - }), D2(["a", "A"], function(e3, t4, n2) { - n2._isPm = n2._locale.isPM(e3), n2._meridiem = e3; - }), D2(["h", "hh"], function(e3, t4, n2) { - t4[x2] = g(e3), m2(n2).bigHour = true; - }), D2("hmm", function(e3, t4, n2) { - var s3 = e3.length - 2; - t4[x2] = g(e3.substr(0, s3)), t4[T] = g(e3.substr(s3)), m2(n2).bigHour = true; - }), D2("hmmss", function(e3, t4, n2) { - var s3 = e3.length - 4, i2 = e3.length - 2; - t4[x2] = g(e3.substr(0, s3)), t4[T] = g(e3.substr(s3, 2)), t4[N] = g(e3.substr(i2)), m2(n2).bigHour = true; - }), D2("Hmm", function(e3, t4, n2) { - var s3 = e3.length - 2; - t4[x2] = g(e3.substr(0, s3)), t4[T] = g(e3.substr(s3)); - }), D2("Hmmss", function(e3, t4, n2) { - var s3 = e3.length - 4, i2 = e3.length - 2; - t4[x2] = g(e3.substr(0, s3)), t4[T] = g(e3.substr(s3, 2)), t4[N] = g(e3.substr(i2)); - }); - k2 = de("Hours", true); - var at, ot = { calendar: { sameDay: "[Today at] LT", nextDay: "[Tomorrow at] LT", nextWeek: "dddd [at] LT", lastDay: "[Yesterday at] LT", lastWeek: "[Last] dddd [at] LT", sameElse: "L" }, longDateFormat: { LTS: "h:mm:ss A", LT: "h:mm A", L: "MM/DD/YYYY", LL: "MMMM D, YYYY", LLL: "MMMM D, YYYY h:mm A", LLLL: "dddd, MMMM D, YYYY h:mm A" }, invalidDate: "Invalid date", ordinal: "%d", dayOfMonthOrdinalParse: /\d{1,2}/, relativeTime: { future: "in %s", past: "%s ago", s: "a few seconds", ss: "%d seconds", m: "a minute", mm: "%d minutes", h: "an hour", hh: "%d hours", d: "a day", dd: "%d days", w: "a week", ww: "%d weeks", M: "a month", MM: "%d months", y: "a year", yy: "%d years" }, months: Ce, monthsShort: Ue, week: { dow: 0, doy: 6 }, weekdays: Je, weekdaysMin: Xe, weekdaysShort: Qe, meridiemParse: /[ap]\.?m?\.?/i }, R = {}, ut = {}; - function lt(e3) { - return e3 && e3.toLowerCase().replace("_", "-"); - } - function ht(e3) { - for (var t4, n2, s3, i2, r2 = 0; r2 < e3.length; ) { - for (t4 = (i2 = lt(e3[r2]).split("-")).length, n2 = (n2 = lt(e3[r2 + 1])) ? n2.split("-") : null; 0 < t4; ) { - if (s3 = dt(i2.slice(0, t4).join("-"))) - return s3; - if (n2 && n2.length >= t4 && function(e4, t5) { - for (var n3 = Math.min(e4.length, t5.length), s4 = 0; s4 < n3; s4 += 1) - if (e4[s4] !== t5[s4]) - return s4; - return n3; - }(i2, n2) >= t4 - 1) - break; - t4--; - } - r2++; - } - return at; - } - function dt(t4) { - var e3; - if (void 0 === R[t4] && true && module3 && module3.exports && null != t4.match("^[^/\\\\]*$")) - try { - e3 = at._abbr, commonjsRequire("./locale/" + t4), ct(e3); - } catch (e4) { - R[t4] = null; - } - return R[t4]; - } - function ct(e3, t4) { - return e3 && ((t4 = o(t4) ? mt(e3) : ft(e3, t4)) ? at = t4 : "undefined" != typeof console && console.warn && console.warn("Locale " + e3 + " not found. Did you forget to load it?")), at._abbr; - } - function ft(e3, t4) { - if (null === t4) - return delete R[e3], null; - var n2, s3 = ot; - if (t4.abbr = e3, null != R[e3]) - Q("defineLocaleOverride", "use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info."), s3 = R[e3]._config; - else if (null != t4.parentLocale) - if (null != R[t4.parentLocale]) - s3 = R[t4.parentLocale]._config; - else { - if (null == (n2 = dt(t4.parentLocale))) - return ut[t4.parentLocale] || (ut[t4.parentLocale] = []), ut[t4.parentLocale].push({ name: e3, config: t4 }), null; - s3 = n2._config; - } - return R[e3] = new K2(X3(s3, t4)), ut[e3] && ut[e3].forEach(function(e4) { - ft(e4.name, e4.config); - }), ct(e3), R[e3]; - } - function mt(e3) { - var t4; - if (!(e3 = e3 && e3._locale && e3._locale._abbr ? e3._locale._abbr : e3)) - return at; - if (!a2(e3)) { - if (t4 = dt(e3)) - return t4; - e3 = [e3]; - } - return ht(e3); - } - function _t(e3) { - var t4 = e3._a; - return t4 && -2 === m2(e3).overflow && (t4 = t4[O] < 0 || 11 < t4[O] ? O : t4[b] < 1 || t4[b] > We(t4[Y3], t4[O]) ? b : t4[x2] < 0 || 24 < t4[x2] || 24 === t4[x2] && (0 !== t4[T] || 0 !== t4[N] || 0 !== t4[Ne]) ? x2 : t4[T] < 0 || 59 < t4[T] ? T : t4[N] < 0 || 59 < t4[N] ? N : t4[Ne] < 0 || 999 < t4[Ne] ? Ne : -1, m2(e3)._overflowDayOfYear && (t4 < Y3 || b < t4) && (t4 = b), m2(e3)._overflowWeeks && -1 === t4 && (t4 = Pe), m2(e3)._overflowWeekday && -1 === t4 && (t4 = Re), m2(e3).overflow = t4), e3; - } - var yt = /^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/, gt = /^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d|))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/, wt = /Z|[+-]\d\d(?::?\d\d)?/, pt = [["YYYYYY-MM-DD", /[+-]\d{6}-\d\d-\d\d/], ["YYYY-MM-DD", /\d{4}-\d\d-\d\d/], ["GGGG-[W]WW-E", /\d{4}-W\d\d-\d/], ["GGGG-[W]WW", /\d{4}-W\d\d/, false], ["YYYY-DDD", /\d{4}-\d{3}/], ["YYYY-MM", /\d{4}-\d\d/, false], ["YYYYYYMMDD", /[+-]\d{10}/], ["YYYYMMDD", /\d{8}/], ["GGGG[W]WWE", /\d{4}W\d{3}/], ["GGGG[W]WW", /\d{4}W\d{2}/, false], ["YYYYDDD", /\d{7}/], ["YYYYMM", /\d{6}/, false], ["YYYY", /\d{4}/, false]], kt = [["HH:mm:ss.SSSS", /\d\d:\d\d:\d\d\.\d+/], ["HH:mm:ss,SSSS", /\d\d:\d\d:\d\d,\d+/], ["HH:mm:ss", /\d\d:\d\d:\d\d/], ["HH:mm", /\d\d:\d\d/], ["HHmmss.SSSS", /\d\d\d\d\d\d\.\d+/], ["HHmmss,SSSS", /\d\d\d\d\d\d,\d+/], ["HHmmss", /\d\d\d\d\d\d/], ["HHmm", /\d\d\d\d/], ["HH", /\d\d/]], vt = /^\/?Date\((-?\d+)/i, Mt = /^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/, Dt = { UT: 0, GMT: 0, EDT: -240, EST: -300, CDT: -300, CST: -360, MDT: -360, MST: -420, PDT: -420, PST: -480 }; - function St(e3) { - var t4, n2, s3, i2, r2, a3, o2 = e3._i, u3 = yt.exec(o2) || gt.exec(o2), o2 = pt.length, l2 = kt.length; - if (u3) { - for (m2(e3).iso = true, t4 = 0, n2 = o2; t4 < n2; t4++) - if (pt[t4][1].exec(u3[1])) { - i2 = pt[t4][0], s3 = false !== pt[t4][2]; - break; - } - if (null == i2) - e3._isValid = false; - else { - if (u3[3]) { - for (t4 = 0, n2 = l2; t4 < n2; t4++) - if (kt[t4][1].exec(u3[3])) { - r2 = (u3[2] || " ") + kt[t4][0]; - break; - } - if (null == r2) - return void (e3._isValid = false); - } - if (s3 || null == r2) { - if (u3[4]) { - if (!wt.exec(u3[4])) - return void (e3._isValid = false); - a3 = "Z"; - } - e3._f = i2 + (r2 || "") + (a3 || ""), Tt(e3); - } else - e3._isValid = false; - } - } else - e3._isValid = false; - } - function Yt(e3, t4, n2, s3, i2, r2) { - e3 = [function(e4) { - e4 = parseInt(e4, 10); - { - if (e4 <= 49) - return 2e3 + e4; - if (e4 <= 999) - return 1900 + e4; - } - return e4; - }(e3), Ue.indexOf(t4), parseInt(n2, 10), parseInt(s3, 10), parseInt(i2, 10)]; - return r2 && e3.push(parseInt(r2, 10)), e3; - } - function Ot(e3) { - var t4, n2, s3, i2, r2 = Mt.exec(e3._i.replace(/\([^()]*\)|[\n\t]/g, " ").replace(/(\s\s+)/g, " ").replace(/^\s\s*/, "").replace(/\s\s*$/, "")); - r2 ? (t4 = Yt(r2[4], r2[3], r2[2], r2[5], r2[6], r2[7]), n2 = r2[1], s3 = t4, i2 = e3, n2 && Qe.indexOf(n2) !== new Date(s3[0], s3[1], s3[2]).getDay() ? (m2(i2).weekdayMismatch = true, i2._isValid = false) : (e3._a = t4, e3._tzm = (n2 = r2[8], s3 = r2[9], i2 = r2[10], n2 ? Dt[n2] : s3 ? 0 : 60 * (((n2 = parseInt(i2, 10)) - (s3 = n2 % 100)) / 100) + s3), e3._d = Ze.apply(null, e3._a), e3._d.setUTCMinutes(e3._d.getUTCMinutes() - e3._tzm), m2(e3).rfc2822 = true)) : e3._isValid = false; - } - function bt(e3, t4, n2) { - return null != e3 ? e3 : null != t4 ? t4 : n2; - } - function xt(e3) { - var t4, n2, s3, i2, r2, a3, o2, u3, l2, h2, d2, c3 = []; - if (!e3._d) { - for (s3 = e3, i2 = new Date(f.now()), n2 = s3._useUTC ? [i2.getUTCFullYear(), i2.getUTCMonth(), i2.getUTCDate()] : [i2.getFullYear(), i2.getMonth(), i2.getDate()], e3._w && null == e3._a[b] && null == e3._a[O] && (null != (i2 = (s3 = e3)._w).GG || null != i2.W || null != i2.E ? (u3 = 1, l2 = 4, r2 = bt(i2.GG, s3._a[Y3], qe(W(), 1, 4).year), a3 = bt(i2.W, 1), ((o2 = bt(i2.E, 1)) < 1 || 7 < o2) && (h2 = true)) : (u3 = s3._locale._week.dow, l2 = s3._locale._week.doy, d2 = qe(W(), u3, l2), r2 = bt(i2.gg, s3._a[Y3], d2.year), a3 = bt(i2.w, d2.week), null != i2.d ? ((o2 = i2.d) < 0 || 6 < o2) && (h2 = true) : null != i2.e ? (o2 = i2.e + u3, (i2.e < 0 || 6 < i2.e) && (h2 = true)) : o2 = u3), a3 < 1 || a3 > P(r2, u3, l2) ? m2(s3)._overflowWeeks = true : null != h2 ? m2(s3)._overflowWeekday = true : (d2 = $e(r2, a3, o2, u3, l2), s3._a[Y3] = d2.year, s3._dayOfYear = d2.dayOfYear)), null != e3._dayOfYear && (i2 = bt(e3._a[Y3], n2[Y3]), (e3._dayOfYear > Ae(i2) || 0 === e3._dayOfYear) && (m2(e3)._overflowDayOfYear = true), h2 = Ze(i2, 0, e3._dayOfYear), e3._a[O] = h2.getUTCMonth(), e3._a[b] = h2.getUTCDate()), t4 = 0; t4 < 3 && null == e3._a[t4]; ++t4) - e3._a[t4] = c3[t4] = n2[t4]; - for (; t4 < 7; t4++) - e3._a[t4] = c3[t4] = null == e3._a[t4] ? 2 === t4 ? 1 : 0 : e3._a[t4]; - 24 === e3._a[x2] && 0 === e3._a[T] && 0 === e3._a[N] && 0 === e3._a[Ne] && (e3._nextDay = true, e3._a[x2] = 0), e3._d = (e3._useUTC ? Ze : je).apply(null, c3), r2 = e3._useUTC ? e3._d.getUTCDay() : e3._d.getDay(), null != e3._tzm && e3._d.setUTCMinutes(e3._d.getUTCMinutes() - e3._tzm), e3._nextDay && (e3._a[x2] = 24), e3._w && void 0 !== e3._w.d && e3._w.d !== r2 && (m2(e3).weekdayMismatch = true); - } - } - function Tt(e3) { - if (e3._f === f.ISO_8601) - St(e3); - else if (e3._f === f.RFC_2822) - Ot(e3); - else { - e3._a = [], m2(e3).empty = true; - for (var t4, n2, s3, i2, r2, a3 = "" + e3._i, o2 = a3.length, u3 = 0, l2 = ae(e3._f, e3._locale).match(te) || [], h2 = l2.length, d2 = 0; d2 < h2; d2++) - n2 = l2[d2], (t4 = (a3.match(Oe(n2, e3)) || [])[0]) && (0 < (s3 = a3.substr(0, a3.indexOf(t4))).length && m2(e3).unusedInput.push(s3), a3 = a3.slice(a3.indexOf(t4) + t4.length), u3 += t4.length), ie[n2] ? (t4 ? m2(e3).empty = false : m2(e3).unusedTokens.push(n2), s3 = n2, r2 = e3, null != (i2 = t4) && c2(xe, s3) && xe[s3](i2, r2._a, r2, s3)) : e3._strict && !t4 && m2(e3).unusedTokens.push(n2); - m2(e3).charsLeftOver = o2 - u3, 0 < a3.length && m2(e3).unusedInput.push(a3), e3._a[x2] <= 12 && true === m2(e3).bigHour && 0 < e3._a[x2] && (m2(e3).bigHour = void 0), m2(e3).parsedDateParts = e3._a.slice(0), m2(e3).meridiem = e3._meridiem, e3._a[x2] = function(e4, t5, n3) { - if (null == n3) - return t5; - return null != e4.meridiemHour ? e4.meridiemHour(t5, n3) : null != e4.isPM ? ((e4 = e4.isPM(n3)) && t5 < 12 && (t5 += 12), t5 = e4 || 12 !== t5 ? t5 : 0) : t5; - }(e3._locale, e3._a[x2], e3._meridiem), null !== (o2 = m2(e3).era) && (e3._a[Y3] = e3._locale.erasConvertYear(o2, e3._a[Y3])), xt(e3), _t(e3); - } - } - function Nt(e3) { - var t4, n2, s3, i2 = e3._i, r2 = e3._f; - if (e3._locale = e3._locale || mt(e3._l), null === i2 || void 0 === r2 && "" === i2) - return I({ nullInput: true }); - if ("string" == typeof i2 && (e3._i = i2 = e3._locale.preparse(i2)), h(i2)) - return new q(_t(i2)); - if (V(i2)) - e3._d = i2; - else if (a2(r2)) - !function(e4) { - var t5, n3, s4, i3, r3, a3, o2 = false, u3 = e4._f.length; - if (0 === u3) - return m2(e4).invalidFormat = true, e4._d = new Date(NaN); - for (i3 = 0; i3 < u3; i3++) - r3 = 0, a3 = false, t5 = $({}, e4), null != e4._useUTC && (t5._useUTC = e4._useUTC), t5._f = e4._f[i3], Tt(t5), A5(t5) && (a3 = true), r3 = (r3 += m2(t5).charsLeftOver) + 10 * m2(t5).unusedTokens.length, m2(t5).score = r3, o2 ? r3 < s4 && (s4 = r3, n3 = t5) : (null == s4 || r3 < s4 || a3) && (s4 = r3, n3 = t5, a3 && (o2 = true)); - E2(e4, n3 || t5); - }(e3); - else if (r2) - Tt(e3); - else if (o(r2 = (i2 = e3)._i)) - i2._d = new Date(f.now()); - else - V(r2) ? i2._d = new Date(r2.valueOf()) : "string" == typeof r2 ? (n2 = i2, null !== (t4 = vt.exec(n2._i)) ? n2._d = new Date(+t4[1]) : (St(n2), false === n2._isValid && (delete n2._isValid, Ot(n2), false === n2._isValid && (delete n2._isValid, n2._strict ? n2._isValid = false : f.createFromInputFallback(n2))))) : a2(r2) ? (i2._a = G(r2.slice(0), function(e4) { - return parseInt(e4, 10); - }), xt(i2)) : F(r2) ? (t4 = i2)._d || (s3 = void 0 === (n2 = ue(t4._i)).day ? n2.date : n2.day, t4._a = G([n2.year, n2.month, s3, n2.hour, n2.minute, n2.second, n2.millisecond], function(e4) { - return e4 && parseInt(e4, 10); - }), xt(t4)) : u2(r2) ? i2._d = new Date(r2) : f.createFromInputFallback(i2); - return A5(e3) || (e3._d = null), e3; - } - function Pt(e3, t4, n2, s3, i2) { - var r2 = {}; - return true !== t4 && false !== t4 || (s3 = t4, t4 = void 0), true !== n2 && false !== n2 || (s3 = n2, n2 = void 0), (F(e3) && L(e3) || a2(e3) && 0 === e3.length) && (e3 = void 0), r2._isAMomentObject = true, r2._useUTC = r2._isUTC = i2, r2._l = n2, r2._i = e3, r2._f = t4, r2._strict = s3, (i2 = new q(_t(Nt(i2 = r2))))._nextDay && (i2.add(1, "d"), i2._nextDay = void 0), i2; - } - function W(e3, t4, n2, s3) { - return Pt(e3, t4, n2, s3, false); - } - f.createFromInputFallback = e("value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.", function(e3) { - e3._d = new Date(e3._i + (e3._useUTC ? " UTC" : "")); - }), f.ISO_8601 = function() { - }, f.RFC_2822 = function() { - }; - ge = e("moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/", function() { - var e3 = W.apply(null, arguments); - return this.isValid() && e3.isValid() ? e3 < this ? this : e3 : I(); - }), we = e("moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/", function() { - var e3 = W.apply(null, arguments); - return this.isValid() && e3.isValid() ? this < e3 ? this : e3 : I(); - }); - function Rt(e3, t4) { - var n2, s3; - if (!(t4 = 1 === t4.length && a2(t4[0]) ? t4[0] : t4).length) - return W(); - for (n2 = t4[0], s3 = 1; s3 < t4.length; ++s3) - t4[s3].isValid() && !t4[s3][e3](n2) || (n2 = t4[s3]); - return n2; - } - var Wt = ["year", "quarter", "month", "week", "day", "hour", "minute", "second", "millisecond"]; - function Ct(e3) { - var e3 = ue(e3), t4 = e3.year || 0, n2 = e3.quarter || 0, s3 = e3.month || 0, i2 = e3.week || e3.isoWeek || 0, r2 = e3.day || 0, a3 = e3.hour || 0, o2 = e3.minute || 0, u3 = e3.second || 0, l2 = e3.millisecond || 0; - this._isValid = function(e4) { - var t5, n3, s4 = false, i3 = Wt.length; - for (t5 in e4) - if (c2(e4, t5) && (-1 === S.call(Wt, t5) || null != e4[t5] && isNaN(e4[t5]))) - return false; - for (n3 = 0; n3 < i3; ++n3) - if (e4[Wt[n3]]) { - if (s4) - return false; - parseFloat(e4[Wt[n3]]) !== g(e4[Wt[n3]]) && (s4 = true); - } - return true; - }(e3), this._milliseconds = +l2 + 1e3 * u3 + 6e4 * o2 + 1e3 * a3 * 60 * 60, this._days = +r2 + 7 * i2, this._months = +s3 + 3 * n2 + 12 * t4, this._data = {}, this._locale = mt(), this._bubble(); - } - function Ut(e3) { - return e3 instanceof Ct; - } - function Ht(e3) { - return e3 < 0 ? -1 * Math.round(-1 * e3) : Math.round(e3); - } - function Ft(e3, n2) { - s2(e3, 0, 0, function() { - var e4 = this.utcOffset(), t4 = "+"; - return e4 < 0 && (e4 = -e4, t4 = "-"), t4 + r(~~(e4 / 60), 2) + n2 + r(~~e4 % 60, 2); - }); - } - Ft("Z", ":"), Ft("ZZ", ""), v("Z", Ye), v("ZZ", Ye), D2(["Z", "ZZ"], function(e3, t4, n2) { - n2._useUTC = true, n2._tzm = Vt(Ye, e3); - }); - var Lt = /([\+\-]|\d\d)/gi; - function Vt(e3, t4) { - var t4 = (t4 || "").match(e3); - return null === t4 ? null : 0 === (t4 = 60 * (e3 = ((t4[t4.length - 1] || []) + "").match(Lt) || ["-", 0, 0])[1] + g(e3[2])) ? 0 : "+" === e3[0] ? t4 : -t4; - } - function Gt(e3, t4) { - var n2; - return t4._isUTC ? (t4 = t4.clone(), n2 = (h(e3) || V(e3) ? e3 : W(e3)).valueOf() - t4.valueOf(), t4._d.setTime(t4._d.valueOf() + n2), f.updateOffset(t4, false), t4) : W(e3).local(); - } - function Et(e3) { - return -Math.round(e3._d.getTimezoneOffset()); - } - function At() { - return !!this.isValid() && (this._isUTC && 0 === this._offset); - } - f.updateOffset = function() { - }; - var It = /^(-|\+)?(?:(\d*)[. ])?(\d+):(\d+)(?::(\d+)(\.\d*)?)?$/, jt = /^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/; - function C3(e3, t4) { - var n2, s3 = e3, i2 = null; - return Ut(e3) ? s3 = { ms: e3._milliseconds, d: e3._days, M: e3._months } : u2(e3) || !isNaN(+e3) ? (s3 = {}, t4 ? s3[t4] = +e3 : s3.milliseconds = +e3) : (i2 = It.exec(e3)) ? (n2 = "-" === i2[1] ? -1 : 1, s3 = { y: 0, d: g(i2[b]) * n2, h: g(i2[x2]) * n2, m: g(i2[T]) * n2, s: g(i2[N]) * n2, ms: g(Ht(1e3 * i2[Ne])) * n2 }) : (i2 = jt.exec(e3)) ? (n2 = "-" === i2[1] ? -1 : 1, s3 = { y: Zt(i2[2], n2), M: Zt(i2[3], n2), w: Zt(i2[4], n2), d: Zt(i2[5], n2), h: Zt(i2[6], n2), m: Zt(i2[7], n2), s: Zt(i2[8], n2) }) : null == s3 ? s3 = {} : "object" == typeof s3 && ("from" in s3 || "to" in s3) && (t4 = function(e4, t5) { - var n3; - if (!e4.isValid() || !t5.isValid()) - return { milliseconds: 0, months: 0 }; - t5 = Gt(t5, e4), e4.isBefore(t5) ? n3 = zt(e4, t5) : ((n3 = zt(t5, e4)).milliseconds = -n3.milliseconds, n3.months = -n3.months); - return n3; - }(W(s3.from), W(s3.to)), (s3 = {}).ms = t4.milliseconds, s3.M = t4.months), i2 = new Ct(s3), Ut(e3) && c2(e3, "_locale") && (i2._locale = e3._locale), Ut(e3) && c2(e3, "_isValid") && (i2._isValid = e3._isValid), i2; - } - function Zt(e3, t4) { - e3 = e3 && parseFloat(e3.replace(",", ".")); - return (isNaN(e3) ? 0 : e3) * t4; - } - function zt(e3, t4) { - var n2 = {}; - return n2.months = t4.month() - e3.month() + 12 * (t4.year() - e3.year()), e3.clone().add(n2.months, "M").isAfter(t4) && --n2.months, n2.milliseconds = +t4 - +e3.clone().add(n2.months, "M"), n2; - } - function $t(s3, i2) { - return function(e3, t4) { - var n2; - return null === t4 || isNaN(+t4) || (Q(i2, "moment()." + i2 + "(period, number) is deprecated. Please use moment()." + i2 + "(number, period). See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info."), n2 = e3, e3 = t4, t4 = n2), qt(this, C3(e3, t4), s3), this; - }; - } - function qt(e3, t4, n2, s3) { - var i2 = t4._milliseconds, r2 = Ht(t4._days), t4 = Ht(t4._months); - e3.isValid() && (s3 = null == s3 || s3, t4 && Ve(e3, ce(e3, "Month") + t4 * n2), r2 && fe(e3, "Date", ce(e3, "Date") + r2 * n2), i2 && e3._d.setTime(e3._d.valueOf() + i2 * n2), s3 && f.updateOffset(e3, r2 || t4)); - } - C3.fn = Ct.prototype, C3.invalid = function() { - return C3(NaN); - }; - Ce = $t(1, "add"), Je = $t(-1, "subtract"); - function Bt(e3) { - return "string" == typeof e3 || e3 instanceof String; - } - function Jt(e3) { - return h(e3) || V(e3) || Bt(e3) || u2(e3) || function(t4) { - var e4 = a2(t4), n2 = false; - e4 && (n2 = 0 === t4.filter(function(e6) { - return !u2(e6) && Bt(t4); - }).length); - return e4 && n2; - }(e3) || function(e4) { - var t4, n2, s3 = F(e4) && !L(e4), i2 = false, r2 = ["years", "year", "y", "months", "month", "M", "days", "day", "d", "dates", "date", "D", "hours", "hour", "h", "minutes", "minute", "m", "seconds", "second", "s", "milliseconds", "millisecond", "ms"], a3 = r2.length; - for (t4 = 0; t4 < a3; t4 += 1) - n2 = r2[t4], i2 = i2 || c2(e4, n2); - return s3 && i2; - }(e3) || null == e3; - } - function Qt(e3, t4) { - if (e3.date() < t4.date()) - return -Qt(t4, e3); - var n2 = 12 * (t4.year() - e3.year()) + (t4.month() - e3.month()), s3 = e3.clone().add(n2, "months"), t4 = t4 - s3 < 0 ? (t4 - s3) / (s3 - e3.clone().add(n2 - 1, "months")) : (t4 - s3) / (e3.clone().add(1 + n2, "months") - s3); - return -(n2 + t4) || 0; - } - function Xt(e3) { - return void 0 === e3 ? this._locale._abbr : (null != (e3 = mt(e3)) && (this._locale = e3), this); - } - f.defaultFormat = "YYYY-MM-DDTHH:mm:ssZ", f.defaultFormatUtc = "YYYY-MM-DDTHH:mm:ss[Z]"; - Xe = e("moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.", function(e3) { - return void 0 === e3 ? this.localeData() : this.locale(e3); - }); - function Kt() { - return this._locale; - } - var en = 126227808e5; - function tn(e3, t4) { - return (e3 % t4 + t4) % t4; - } - function nn(e3, t4, n2) { - return e3 < 100 && 0 <= e3 ? new Date(e3 + 400, t4, n2) - en : new Date(e3, t4, n2).valueOf(); - } - function sn(e3, t4, n2) { - return e3 < 100 && 0 <= e3 ? Date.UTC(e3 + 400, t4, n2) - en : Date.UTC(e3, t4, n2); - } - function rn(e3, t4) { - return t4.erasAbbrRegex(e3); - } - function an() { - for (var e3 = [], t4 = [], n2 = [], s3 = [], i2 = this.eras(), r2 = 0, a3 = i2.length; r2 < a3; ++r2) - t4.push(M2(i2[r2].name)), e3.push(M2(i2[r2].abbr)), n2.push(M2(i2[r2].narrow)), s3.push(M2(i2[r2].name)), s3.push(M2(i2[r2].abbr)), s3.push(M2(i2[r2].narrow)); - this._erasRegex = new RegExp("^(" + s3.join("|") + ")", "i"), this._erasNameRegex = new RegExp("^(" + t4.join("|") + ")", "i"), this._erasAbbrRegex = new RegExp("^(" + e3.join("|") + ")", "i"), this._erasNarrowRegex = new RegExp("^(" + n2.join("|") + ")", "i"); - } - function on(e3, t4) { - s2(0, [e3, e3.length], 0, t4); - } - function un(e3, t4, n2, s3, i2) { - var r2; - return null == e3 ? qe(this, s3, i2).year : (r2 = P(e3, s3, i2), function(e4, t5, n3, s4, i3) { - e4 = $e(e4, t5, n3, s4, i3), t5 = Ze(e4.year, 0, e4.dayOfYear); - return this.year(t5.getUTCFullYear()), this.month(t5.getUTCMonth()), this.date(t5.getUTCDate()), this; - }.call(this, e3, t4 = r2 < t4 ? r2 : t4, n2, s3, i2)); - } - s2("N", 0, 0, "eraAbbr"), s2("NN", 0, 0, "eraAbbr"), s2("NNN", 0, 0, "eraAbbr"), s2("NNNN", 0, 0, "eraName"), s2("NNNNN", 0, 0, "eraNarrow"), s2("y", ["y", 1], "yo", "eraYear"), s2("y", ["yy", 2], 0, "eraYear"), s2("y", ["yyy", 3], 0, "eraYear"), s2("y", ["yyyy", 4], 0, "eraYear"), v("N", rn), v("NN", rn), v("NNN", rn), v("NNNN", function(e3, t4) { - return t4.erasNameRegex(e3); - }), v("NNNNN", function(e3, t4) { - return t4.erasNarrowRegex(e3); - }), D2(["N", "NN", "NNN", "NNNN", "NNNNN"], function(e3, t4, n2, s3) { - s3 = n2._locale.erasParse(e3, s3, n2._strict); - s3 ? m2(n2).era = s3 : m2(n2).invalidEra = e3; - }), v("y", Me), v("yy", Me), v("yyy", Me), v("yyyy", Me), v("yo", function(e3, t4) { - return t4._eraYearOrdinalRegex || Me; - }), D2(["y", "yy", "yyy", "yyyy"], Y3), D2(["yo"], function(e3, t4, n2, s3) { - var i2; - n2._locale._eraYearOrdinalRegex && (i2 = e3.match(n2._locale._eraYearOrdinalRegex)), n2._locale.eraYearOrdinalParse ? t4[Y3] = n2._locale.eraYearOrdinalParse(e3, i2) : t4[Y3] = parseInt(e3, 10); - }), s2(0, ["gg", 2], 0, function() { - return this.weekYear() % 100; - }), s2(0, ["GG", 2], 0, function() { - return this.isoWeekYear() % 100; - }), on("gggg", "weekYear"), on("ggggg", "weekYear"), on("GGGG", "isoWeekYear"), on("GGGGG", "isoWeekYear"), t("weekYear", "gg"), t("isoWeekYear", "GG"), n("weekYear", 1), n("isoWeekYear", 1), v("G", De), v("g", De), v("GG", p, w2), v("gg", p, w2), v("GGGG", ke, _e), v("gggg", ke, _e), v("GGGGG", ve, ye), v("ggggg", ve, ye), Te(["gggg", "ggggg", "GGGG", "GGGGG"], function(e3, t4, n2, s3) { - t4[s3.substr(0, 2)] = g(e3); - }), Te(["gg", "GG"], function(e3, t4, n2, s3) { - t4[s3] = f.parseTwoDigitYear(e3); - }), s2("Q", 0, "Qo", "quarter"), t("quarter", "Q"), n("quarter", 7), v("Q", i), D2("Q", function(e3, t4) { - t4[O] = 3 * (g(e3) - 1); - }), s2("D", ["DD", 2], "Do", "date"), t("date", "D"), n("date", 9), v("D", p), v("DD", p, w2), v("Do", function(e3, t4) { - return e3 ? t4._dayOfMonthOrdinalParse || t4._ordinalParse : t4._dayOfMonthOrdinalParseLenient; - }), D2(["D", "DD"], b), D2("Do", function(e3, t4) { - t4[b] = g(e3.match(p)[0]); - }); - ke = de("Date", true); - s2("DDD", ["DDDD", 3], "DDDo", "dayOfYear"), t("dayOfYear", "DDD"), n("dayOfYear", 4), v("DDD", pe), v("DDDD", me), D2(["DDD", "DDDD"], function(e3, t4, n2) { - n2._dayOfYear = g(e3); - }), s2("m", ["mm", 2], 0, "minute"), t("minute", "m"), n("minute", 14), v("m", p), v("mm", p, w2), D2(["m", "mm"], T); - var ln, _e = de("Minutes", false), ve = (s2("s", ["ss", 2], 0, "second"), t("second", "s"), n("second", 15), v("s", p), v("ss", p, w2), D2(["s", "ss"], N), de("Seconds", false)); - for (s2("S", 0, 0, function() { - return ~~(this.millisecond() / 100); - }), s2(0, ["SS", 2], 0, function() { - return ~~(this.millisecond() / 10); - }), s2(0, ["SSS", 3], 0, "millisecond"), s2(0, ["SSSS", 4], 0, function() { - return 10 * this.millisecond(); - }), s2(0, ["SSSSS", 5], 0, function() { - return 100 * this.millisecond(); - }), s2(0, ["SSSSSS", 6], 0, function() { - return 1e3 * this.millisecond(); - }), s2(0, ["SSSSSSS", 7], 0, function() { - return 1e4 * this.millisecond(); - }), s2(0, ["SSSSSSSS", 8], 0, function() { - return 1e5 * this.millisecond(); - }), s2(0, ["SSSSSSSSS", 9], 0, function() { - return 1e6 * this.millisecond(); - }), t("millisecond", "ms"), n("millisecond", 16), v("S", pe, i), v("SS", pe, w2), v("SSS", pe, me), ln = "SSSS"; ln.length <= 9; ln += "S") - v(ln, Me); - function hn(e3, t4) { - t4[Ne] = g(1e3 * ("0." + e3)); - } - for (ln = "S"; ln.length <= 9; ln += "S") - D2(ln, hn); - ye = de("Milliseconds", false), s2("z", 0, 0, "zoneAbbr"), s2("zz", 0, 0, "zoneName"); - i = q.prototype; - function dn(e3) { - return e3; - } - i.add = Ce, i.calendar = function(e3, t4) { - 1 === arguments.length && (arguments[0] ? Jt(arguments[0]) ? (e3 = arguments[0], t4 = void 0) : function(e4) { - for (var t5 = F(e4) && !L(e4), n3 = false, s3 = ["sameDay", "nextDay", "lastDay", "nextWeek", "lastWeek", "sameElse"], i2 = 0; i2 < s3.length; i2 += 1) - n3 = n3 || c2(e4, s3[i2]); - return t5 && n3; - }(arguments[0]) && (t4 = arguments[0], e3 = void 0) : t4 = e3 = void 0); - var e3 = e3 || W(), n2 = Gt(e3, this).startOf("day"), n2 = f.calendarFormat(this, n2) || "sameElse", t4 = t4 && (d(t4[n2]) ? t4[n2].call(this, e3) : t4[n2]); - return this.format(t4 || this.localeData().calendar(n2, this, W(e3))); - }, i.clone = function() { - return new q(this); - }, i.diff = function(e3, t4, n2) { - var s3, i2, r2; - if (!this.isValid()) - return NaN; - if (!(s3 = Gt(e3, this)).isValid()) - return NaN; - switch (i2 = 6e4 * (s3.utcOffset() - this.utcOffset()), t4 = _2(t4)) { - case "year": - r2 = Qt(this, s3) / 12; - break; - case "month": - r2 = Qt(this, s3); - break; - case "quarter": - r2 = Qt(this, s3) / 3; - break; - case "second": - r2 = (this - s3) / 1e3; - break; - case "minute": - r2 = (this - s3) / 6e4; - break; - case "hour": - r2 = (this - s3) / 36e5; - break; - case "day": - r2 = (this - s3 - i2) / 864e5; - break; - case "week": - r2 = (this - s3 - i2) / 6048e5; - break; - default: - r2 = this - s3; - } - return n2 ? r2 : y2(r2); - }, i.endOf = function(e3) { - var t4, n2; - if (void 0 === (e3 = _2(e3)) || "millisecond" === e3 || !this.isValid()) - return this; - switch (n2 = this._isUTC ? sn : nn, e3) { - case "year": - t4 = n2(this.year() + 1, 0, 1) - 1; - break; - case "quarter": - t4 = n2(this.year(), this.month() - this.month() % 3 + 3, 1) - 1; - break; - case "month": - t4 = n2(this.year(), this.month() + 1, 1) - 1; - break; - case "week": - t4 = n2(this.year(), this.month(), this.date() - this.weekday() + 7) - 1; - break; - case "isoWeek": - t4 = n2(this.year(), this.month(), this.date() - (this.isoWeekday() - 1) + 7) - 1; - break; - case "day": - case "date": - t4 = n2(this.year(), this.month(), this.date() + 1) - 1; - break; - case "hour": - t4 = this._d.valueOf(), t4 += 36e5 - tn(t4 + (this._isUTC ? 0 : 6e4 * this.utcOffset()), 36e5) - 1; - break; - case "minute": - t4 = this._d.valueOf(), t4 += 6e4 - tn(t4, 6e4) - 1; - break; - case "second": - t4 = this._d.valueOf(), t4 += 1e3 - tn(t4, 1e3) - 1; - break; - } - return this._d.setTime(t4), f.updateOffset(this, true), this; - }, i.format = function(e3) { - return e3 = e3 || (this.isUtc() ? f.defaultFormatUtc : f.defaultFormat), e3 = re2(this, e3), this.localeData().postformat(e3); - }, i.from = function(e3, t4) { - return this.isValid() && (h(e3) && e3.isValid() || W(e3).isValid()) ? C3({ to: this, from: e3 }).locale(this.locale()).humanize(!t4) : this.localeData().invalidDate(); - }, i.fromNow = function(e3) { - return this.from(W(), e3); - }, i.to = function(e3, t4) { - return this.isValid() && (h(e3) && e3.isValid() || W(e3).isValid()) ? C3({ from: this, to: e3 }).locale(this.locale()).humanize(!t4) : this.localeData().invalidDate(); - }, i.toNow = function(e3) { - return this.to(W(), e3); - }, i.get = function(e3) { - return d(this[e3 = _2(e3)]) ? this[e3]() : this; - }, i.invalidAt = function() { - return m2(this).overflow; - }, i.isAfter = function(e3, t4) { - return e3 = h(e3) ? e3 : W(e3), !(!this.isValid() || !e3.isValid()) && ("millisecond" === (t4 = _2(t4) || "millisecond") ? this.valueOf() > e3.valueOf() : e3.valueOf() < this.clone().startOf(t4).valueOf()); - }, i.isBefore = function(e3, t4) { - return e3 = h(e3) ? e3 : W(e3), !(!this.isValid() || !e3.isValid()) && ("millisecond" === (t4 = _2(t4) || "millisecond") ? this.valueOf() < e3.valueOf() : this.clone().endOf(t4).valueOf() < e3.valueOf()); - }, i.isBetween = function(e3, t4, n2, s3) { - return e3 = h(e3) ? e3 : W(e3), t4 = h(t4) ? t4 : W(t4), !!(this.isValid() && e3.isValid() && t4.isValid()) && (("(" === (s3 = s3 || "()")[0] ? this.isAfter(e3, n2) : !this.isBefore(e3, n2)) && (")" === s3[1] ? this.isBefore(t4, n2) : !this.isAfter(t4, n2))); - }, i.isSame = function(e3, t4) { - var e3 = h(e3) ? e3 : W(e3); - return !(!this.isValid() || !e3.isValid()) && ("millisecond" === (t4 = _2(t4) || "millisecond") ? this.valueOf() === e3.valueOf() : (e3 = e3.valueOf(), this.clone().startOf(t4).valueOf() <= e3 && e3 <= this.clone().endOf(t4).valueOf())); - }, i.isSameOrAfter = function(e3, t4) { - return this.isSame(e3, t4) || this.isAfter(e3, t4); - }, i.isSameOrBefore = function(e3, t4) { - return this.isSame(e3, t4) || this.isBefore(e3, t4); - }, i.isValid = function() { - return A5(this); - }, i.lang = Xe, i.locale = Xt, i.localeData = Kt, i.max = we, i.min = ge, i.parsingFlags = function() { - return E2({}, m2(this)); - }, i.set = function(e3, t4) { - if ("object" == typeof e3) - for (var n2 = function(e4) { - var t5, n3 = []; - for (t5 in e4) - c2(e4, t5) && n3.push({ unit: t5, priority: le[t5] }); - return n3.sort(function(e6, t6) { - return e6.priority - t6.priority; - }), n3; - }(e3 = ue(e3)), s3 = n2.length, i2 = 0; i2 < s3; i2++) - this[n2[i2].unit](e3[n2[i2].unit]); - else if (d(this[e3 = _2(e3)])) - return this[e3](t4); - return this; - }, i.startOf = function(e3) { - var t4, n2; - if (void 0 === (e3 = _2(e3)) || "millisecond" === e3 || !this.isValid()) - return this; - switch (n2 = this._isUTC ? sn : nn, e3) { - case "year": - t4 = n2(this.year(), 0, 1); - break; - case "quarter": - t4 = n2(this.year(), this.month() - this.month() % 3, 1); - break; - case "month": - t4 = n2(this.year(), this.month(), 1); - break; - case "week": - t4 = n2(this.year(), this.month(), this.date() - this.weekday()); - break; - case "isoWeek": - t4 = n2(this.year(), this.month(), this.date() - (this.isoWeekday() - 1)); - break; - case "day": - case "date": - t4 = n2(this.year(), this.month(), this.date()); - break; - case "hour": - t4 = this._d.valueOf(), t4 -= tn(t4 + (this._isUTC ? 0 : 6e4 * this.utcOffset()), 36e5); - break; - case "minute": - t4 = this._d.valueOf(), t4 -= tn(t4, 6e4); - break; - case "second": - t4 = this._d.valueOf(), t4 -= tn(t4, 1e3); - break; - } - return this._d.setTime(t4), f.updateOffset(this, true), this; - }, i.subtract = Je, i.toArray = function() { - var e3 = this; - return [e3.year(), e3.month(), e3.date(), e3.hour(), e3.minute(), e3.second(), e3.millisecond()]; - }, i.toObject = function() { - var e3 = this; - return { years: e3.year(), months: e3.month(), date: e3.date(), hours: e3.hours(), minutes: e3.minutes(), seconds: e3.seconds(), milliseconds: e3.milliseconds() }; - }, i.toDate = function() { - return new Date(this.valueOf()); - }, i.toISOString = function(e3) { - if (!this.isValid()) - return null; - var t4 = (e3 = true !== e3) ? this.clone().utc() : this; - return t4.year() < 0 || 9999 < t4.year() ? re2(t4, e3 ? "YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]" : "YYYYYY-MM-DD[T]HH:mm:ss.SSSZ") : d(Date.prototype.toISOString) ? e3 ? this.toDate().toISOString() : new Date(this.valueOf() + 60 * this.utcOffset() * 1e3).toISOString().replace("Z", re2(t4, "Z")) : re2(t4, e3 ? "YYYY-MM-DD[T]HH:mm:ss.SSS[Z]" : "YYYY-MM-DD[T]HH:mm:ss.SSSZ"); - }, i.inspect = function() { - if (!this.isValid()) - return "moment.invalid(/* " + this._i + " */)"; - var e3, t4 = "moment", n2 = ""; - return this.isLocal() || (t4 = 0 === this.utcOffset() ? "moment.utc" : "moment.parseZone", n2 = "Z"), t4 = "[" + t4 + '("]', e3 = 0 <= this.year() && this.year() <= 9999 ? "YYYY" : "YYYYYY", this.format(t4 + e3 + "-MM-DD[T]HH:mm:ss.SSS" + (n2 + '[")]')); - }, "undefined" != typeof Symbol && null != Symbol.for && (i[Symbol.for("nodejs.util.inspect.custom")] = function() { - return "Moment<" + this.format() + ">"; - }), i.toJSON = function() { - return this.isValid() ? this.toISOString() : null; - }, i.toString = function() { - return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ"); - }, i.unix = function() { - return Math.floor(this.valueOf() / 1e3); - }, i.valueOf = function() { - return this._d.valueOf() - 6e4 * (this._offset || 0); - }, i.creationData = function() { - return { input: this._i, format: this._f, locale: this._locale, isUTC: this._isUTC, strict: this._strict }; - }, i.eraName = function() { - for (var e3, t4 = this.localeData().eras(), n2 = 0, s3 = t4.length; n2 < s3; ++n2) { - if (e3 = this.clone().startOf("day").valueOf(), t4[n2].since <= e3 && e3 <= t4[n2].until) - return t4[n2].name; - if (t4[n2].until <= e3 && e3 <= t4[n2].since) - return t4[n2].name; - } - return ""; - }, i.eraNarrow = function() { - for (var e3, t4 = this.localeData().eras(), n2 = 0, s3 = t4.length; n2 < s3; ++n2) { - if (e3 = this.clone().startOf("day").valueOf(), t4[n2].since <= e3 && e3 <= t4[n2].until) - return t4[n2].narrow; - if (t4[n2].until <= e3 && e3 <= t4[n2].since) - return t4[n2].narrow; - } - return ""; - }, i.eraAbbr = function() { - for (var e3, t4 = this.localeData().eras(), n2 = 0, s3 = t4.length; n2 < s3; ++n2) { - if (e3 = this.clone().startOf("day").valueOf(), t4[n2].since <= e3 && e3 <= t4[n2].until) - return t4[n2].abbr; - if (t4[n2].until <= e3 && e3 <= t4[n2].since) - return t4[n2].abbr; - } - return ""; - }, i.eraYear = function() { - for (var e3, t4, n2 = this.localeData().eras(), s3 = 0, i2 = n2.length; s3 < i2; ++s3) - if (e3 = n2[s3].since <= n2[s3].until ? 1 : -1, t4 = this.clone().startOf("day").valueOf(), n2[s3].since <= t4 && t4 <= n2[s3].until || n2[s3].until <= t4 && t4 <= n2[s3].since) - return (this.year() - f(n2[s3].since).year()) * e3 + n2[s3].offset; - return this.year(); - }, i.year = Ie, i.isLeapYear = function() { - return he(this.year()); - }, i.weekYear = function(e3) { - return un.call(this, e3, this.week(), this.weekday(), this.localeData()._week.dow, this.localeData()._week.doy); - }, i.isoWeekYear = function(e3) { - return un.call(this, e3, this.isoWeek(), this.isoWeekday(), 1, 4); - }, i.quarter = i.quarters = function(e3) { - return null == e3 ? Math.ceil((this.month() + 1) / 3) : this.month(3 * (e3 - 1) + this.month() % 3); - }, i.month = Ge, i.daysInMonth = function() { - return We(this.year(), this.month()); - }, i.week = i.weeks = function(e3) { - var t4 = this.localeData().week(this); - return null == e3 ? t4 : this.add(7 * (e3 - t4), "d"); - }, i.isoWeek = i.isoWeeks = function(e3) { - var t4 = qe(this, 1, 4).week; - return null == e3 ? t4 : this.add(7 * (e3 - t4), "d"); - }, i.weeksInYear = function() { - var e3 = this.localeData()._week; - return P(this.year(), e3.dow, e3.doy); - }, i.weeksInWeekYear = function() { - var e3 = this.localeData()._week; - return P(this.weekYear(), e3.dow, e3.doy); - }, i.isoWeeksInYear = function() { - return P(this.year(), 1, 4); - }, i.isoWeeksInISOWeekYear = function() { - return P(this.isoWeekYear(), 1, 4); - }, i.date = ke, i.day = i.days = function(e3) { - if (!this.isValid()) - return null != e3 ? this : NaN; - var t4, n2, s3 = this._isUTC ? this._d.getUTCDay() : this._d.getDay(); - return null != e3 ? (t4 = e3, n2 = this.localeData(), e3 = "string" != typeof t4 ? t4 : isNaN(t4) ? "number" == typeof (t4 = n2.weekdaysParse(t4)) ? t4 : null : parseInt(t4, 10), this.add(e3 - s3, "d")) : s3; - }, i.weekday = function(e3) { - if (!this.isValid()) - return null != e3 ? this : NaN; - var t4 = (this.day() + 7 - this.localeData()._week.dow) % 7; - return null == e3 ? t4 : this.add(e3 - t4, "d"); - }, i.isoWeekday = function(e3) { - return this.isValid() ? null != e3 ? (t4 = e3, n2 = this.localeData(), n2 = "string" == typeof t4 ? n2.weekdaysParse(t4) % 7 || 7 : isNaN(t4) ? null : t4, this.day(this.day() % 7 ? n2 : n2 - 7)) : this.day() || 7 : null != e3 ? this : NaN; - var t4, n2; - }, i.dayOfYear = function(e3) { - var t4 = Math.round((this.clone().startOf("day") - this.clone().startOf("year")) / 864e5) + 1; - return null == e3 ? t4 : this.add(e3 - t4, "d"); - }, i.hour = i.hours = k2, i.minute = i.minutes = _e, i.second = i.seconds = ve, i.millisecond = i.milliseconds = ye, i.utcOffset = function(e3, t4, n2) { - var s3, i2 = this._offset || 0; - if (!this.isValid()) - return null != e3 ? this : NaN; - if (null == e3) - return this._isUTC ? i2 : Et(this); - if ("string" == typeof e3) { - if (null === (e3 = Vt(Ye, e3))) - return this; - } else - Math.abs(e3) < 16 && !n2 && (e3 *= 60); - return !this._isUTC && t4 && (s3 = Et(this)), this._offset = e3, this._isUTC = true, null != s3 && this.add(s3, "m"), i2 !== e3 && (!t4 || this._changeInProgress ? qt(this, C3(e3 - i2, "m"), 1, false) : this._changeInProgress || (this._changeInProgress = true, f.updateOffset(this, true), this._changeInProgress = null)), this; - }, i.utc = function(e3) { - return this.utcOffset(0, e3); - }, i.local = function(e3) { - return this._isUTC && (this.utcOffset(0, e3), this._isUTC = false, e3 && this.subtract(Et(this), "m")), this; - }, i.parseZone = function() { - var e3; - return null != this._tzm ? this.utcOffset(this._tzm, false, true) : "string" == typeof this._i && (null != (e3 = Vt(Se, this._i)) ? this.utcOffset(e3) : this.utcOffset(0, true)), this; - }, i.hasAlignedHourOffset = function(e3) { - return !!this.isValid() && (e3 = e3 ? W(e3).utcOffset() : 0, (this.utcOffset() - e3) % 60 == 0); - }, i.isDST = function() { - return this.utcOffset() > this.clone().month(0).utcOffset() || this.utcOffset() > this.clone().month(5).utcOffset(); - }, i.isLocal = function() { - return !!this.isValid() && !this._isUTC; - }, i.isUtcOffset = function() { - return !!this.isValid() && this._isUTC; - }, i.isUtc = At, i.isUTC = At, i.zoneAbbr = function() { - return this._isUTC ? "UTC" : ""; - }, i.zoneName = function() { - return this._isUTC ? "Coordinated Universal Time" : ""; - }, i.dates = e("dates accessor is deprecated. Use date instead.", ke), i.months = e("months accessor is deprecated. Use month instead", Ge), i.years = e("years accessor is deprecated. Use year instead", Ie), i.zone = e("moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/", function(e3, t4) { - return null != e3 ? (this.utcOffset(e3 = "string" != typeof e3 ? -e3 : e3, t4), this) : -this.utcOffset(); - }), i.isDSTShifted = e("isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information", function() { - if (!o(this._isDSTShifted)) - return this._isDSTShifted; - var e3, t4 = {}; - return $(t4, this), (t4 = Nt(t4))._a ? (e3 = (t4._isUTC ? l : W)(t4._a), this._isDSTShifted = this.isValid() && 0 < function(e4, t5, n2) { - for (var s3 = Math.min(e4.length, t5.length), i2 = Math.abs(e4.length - t5.length), r2 = 0, a3 = 0; a3 < s3; a3++) - (n2 && e4[a3] !== t5[a3] || !n2 && g(e4[a3]) !== g(t5[a3])) && r2++; - return r2 + i2; - }(t4._a, e3.toArray())) : this._isDSTShifted = false, this._isDSTShifted; - }); - w2 = K2.prototype; - function cn(e3, t4, n2, s3) { - var i2 = mt(), s3 = l().set(s3, t4); - return i2[n2](s3, e3); - } - function fn(e3, t4, n2) { - if (u2(e3) && (t4 = e3, e3 = void 0), e3 = e3 || "", null != t4) - return cn(e3, t4, n2, "month"); - for (var s3 = [], i2 = 0; i2 < 12; i2++) - s3[i2] = cn(e3, i2, n2, "month"); - return s3; - } - function mn(e3, t4, n2, s3) { - t4 = ("boolean" == typeof e3 ? u2(t4) && (n2 = t4, t4 = void 0) : (t4 = e3, e3 = false, u2(n2 = t4) && (n2 = t4, t4 = void 0)), t4 || ""); - var i2, r2 = mt(), a3 = e3 ? r2._week.dow : 0, o2 = []; - if (null != n2) - return cn(t4, (n2 + a3) % 7, s3, "day"); - for (i2 = 0; i2 < 7; i2++) - o2[i2] = cn(t4, (i2 + a3) % 7, s3, "day"); - return o2; - } - w2.calendar = function(e3, t4, n2) { - return d(e3 = this._calendar[e3] || this._calendar.sameElse) ? e3.call(t4, n2) : e3; - }, w2.longDateFormat = function(e3) { - var t4 = this._longDateFormat[e3], n2 = this._longDateFormat[e3.toUpperCase()]; - return t4 || !n2 ? t4 : (this._longDateFormat[e3] = n2.match(te).map(function(e4) { - return "MMMM" === e4 || "MM" === e4 || "DD" === e4 || "dddd" === e4 ? e4.slice(1) : e4; - }).join(""), this._longDateFormat[e3]); - }, w2.invalidDate = function() { - return this._invalidDate; - }, w2.ordinal = function(e3) { - return this._ordinal.replace("%d", e3); - }, w2.preparse = dn, w2.postformat = dn, w2.relativeTime = function(e3, t4, n2, s3) { - var i2 = this._relativeTime[n2]; - return d(i2) ? i2(e3, t4, n2, s3) : i2.replace(/%d/i, e3); - }, w2.pastFuture = function(e3, t4) { - return d(e3 = this._relativeTime[0 < e3 ? "future" : "past"]) ? e3(t4) : e3.replace(/%s/i, t4); - }, w2.set = function(e3) { - var t4, n2; - for (n2 in e3) - c2(e3, n2) && (d(t4 = e3[n2]) ? this[n2] = t4 : this["_" + n2] = t4); - this._config = e3, this._dayOfMonthOrdinalParseLenient = new RegExp((this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) + "|" + /\d{1,2}/.source); - }, w2.eras = function(e3, t4) { - for (var n2, s3 = this._eras || mt("en")._eras, i2 = 0, r2 = s3.length; i2 < r2; ++i2) { - switch (typeof s3[i2].since) { - case "string": - n2 = f(s3[i2].since).startOf("day"), s3[i2].since = n2.valueOf(); - break; - } - switch (typeof s3[i2].until) { - case "undefined": - s3[i2].until = 1 / 0; - break; - case "string": - n2 = f(s3[i2].until).startOf("day").valueOf(), s3[i2].until = n2.valueOf(); - break; - } - } - return s3; - }, w2.erasParse = function(e3, t4, n2) { - var s3, i2, r2, a3, o2, u3 = this.eras(); - for (e3 = e3.toUpperCase(), s3 = 0, i2 = u3.length; s3 < i2; ++s3) - if (r2 = u3[s3].name.toUpperCase(), a3 = u3[s3].abbr.toUpperCase(), o2 = u3[s3].narrow.toUpperCase(), n2) - switch (t4) { - case "N": - case "NN": - case "NNN": - if (a3 === e3) - return u3[s3]; - break; - case "NNNN": - if (r2 === e3) - return u3[s3]; - break; - case "NNNNN": - if (o2 === e3) - return u3[s3]; - break; - } - else if (0 <= [r2, a3, o2].indexOf(e3)) - return u3[s3]; - }, w2.erasConvertYear = function(e3, t4) { - var n2 = e3.since <= e3.until ? 1 : -1; - return void 0 === t4 ? f(e3.since).year() : f(e3.since).year() + (t4 - e3.offset) * n2; - }, w2.erasAbbrRegex = function(e3) { - return c2(this, "_erasAbbrRegex") || an.call(this), e3 ? this._erasAbbrRegex : this._erasRegex; - }, w2.erasNameRegex = function(e3) { - return c2(this, "_erasNameRegex") || an.call(this), e3 ? this._erasNameRegex : this._erasRegex; - }, w2.erasNarrowRegex = function(e3) { - return c2(this, "_erasNarrowRegex") || an.call(this), e3 ? this._erasNarrowRegex : this._erasRegex; - }, w2.months = function(e3, t4) { - return e3 ? (a2(this._months) ? this._months : this._months[(this._months.isFormat || He).test(t4) ? "format" : "standalone"])[e3.month()] : a2(this._months) ? this._months : this._months.standalone; - }, w2.monthsShort = function(e3, t4) { - return e3 ? (a2(this._monthsShort) ? this._monthsShort : this._monthsShort[He.test(t4) ? "format" : "standalone"])[e3.month()] : a2(this._monthsShort) ? this._monthsShort : this._monthsShort.standalone; - }, w2.monthsParse = function(e3, t4, n2) { - var s3, i2; - if (this._monthsParseExact) - return function(e4, t5, n3) { - var s4, i3, r2, e4 = e4.toLocaleLowerCase(); - if (!this._monthsParse) - for (this._monthsParse = [], this._longMonthsParse = [], this._shortMonthsParse = [], s4 = 0; s4 < 12; ++s4) - r2 = l([2e3, s4]), this._shortMonthsParse[s4] = this.monthsShort(r2, "").toLocaleLowerCase(), this._longMonthsParse[s4] = this.months(r2, "").toLocaleLowerCase(); - return n3 ? "MMM" === t5 ? -1 !== (i3 = S.call(this._shortMonthsParse, e4)) ? i3 : null : -1 !== (i3 = S.call(this._longMonthsParse, e4)) ? i3 : null : "MMM" === t5 ? -1 !== (i3 = S.call(this._shortMonthsParse, e4)) || -1 !== (i3 = S.call(this._longMonthsParse, e4)) ? i3 : null : -1 !== (i3 = S.call(this._longMonthsParse, e4)) || -1 !== (i3 = S.call(this._shortMonthsParse, e4)) ? i3 : null; - }.call(this, e3, t4, n2); - for (this._monthsParse || (this._monthsParse = [], this._longMonthsParse = [], this._shortMonthsParse = []), s3 = 0; s3 < 12; s3++) { - if (i2 = l([2e3, s3]), n2 && !this._longMonthsParse[s3] && (this._longMonthsParse[s3] = new RegExp("^" + this.months(i2, "").replace(".", "") + "$", "i"), this._shortMonthsParse[s3] = new RegExp("^" + this.monthsShort(i2, "").replace(".", "") + "$", "i")), n2 || this._monthsParse[s3] || (i2 = "^" + this.months(i2, "") + "|^" + this.monthsShort(i2, ""), this._monthsParse[s3] = new RegExp(i2.replace(".", ""), "i")), n2 && "MMMM" === t4 && this._longMonthsParse[s3].test(e3)) - return s3; - if (n2 && "MMM" === t4 && this._shortMonthsParse[s3].test(e3)) - return s3; - if (!n2 && this._monthsParse[s3].test(e3)) - return s3; - } - }, w2.monthsRegex = function(e3) { - return this._monthsParseExact ? (c2(this, "_monthsRegex") || Ee.call(this), e3 ? this._monthsStrictRegex : this._monthsRegex) : (c2(this, "_monthsRegex") || (this._monthsRegex = Le), this._monthsStrictRegex && e3 ? this._monthsStrictRegex : this._monthsRegex); - }, w2.monthsShortRegex = function(e3) { - return this._monthsParseExact ? (c2(this, "_monthsRegex") || Ee.call(this), e3 ? this._monthsShortStrictRegex : this._monthsShortRegex) : (c2(this, "_monthsShortRegex") || (this._monthsShortRegex = Fe), this._monthsShortStrictRegex && e3 ? this._monthsShortStrictRegex : this._monthsShortRegex); - }, w2.week = function(e3) { - return qe(e3, this._week.dow, this._week.doy).week; - }, w2.firstDayOfYear = function() { - return this._week.doy; - }, w2.firstDayOfWeek = function() { - return this._week.dow; - }, w2.weekdays = function(e3, t4) { - return t4 = a2(this._weekdays) ? this._weekdays : this._weekdays[e3 && true !== e3 && this._weekdays.isFormat.test(t4) ? "format" : "standalone"], true === e3 ? Be(t4, this._week.dow) : e3 ? t4[e3.day()] : t4; - }, w2.weekdaysMin = function(e3) { - return true === e3 ? Be(this._weekdaysMin, this._week.dow) : e3 ? this._weekdaysMin[e3.day()] : this._weekdaysMin; - }, w2.weekdaysShort = function(e3) { - return true === e3 ? Be(this._weekdaysShort, this._week.dow) : e3 ? this._weekdaysShort[e3.day()] : this._weekdaysShort; - }, w2.weekdaysParse = function(e3, t4, n2) { - var s3, i2; - if (this._weekdaysParseExact) - return function(e4, t5, n3) { - var s4, i3, r2, e4 = e4.toLocaleLowerCase(); - if (!this._weekdaysParse) - for (this._weekdaysParse = [], this._shortWeekdaysParse = [], this._minWeekdaysParse = [], s4 = 0; s4 < 7; ++s4) - r2 = l([2e3, 1]).day(s4), this._minWeekdaysParse[s4] = this.weekdaysMin(r2, "").toLocaleLowerCase(), this._shortWeekdaysParse[s4] = this.weekdaysShort(r2, "").toLocaleLowerCase(), this._weekdaysParse[s4] = this.weekdays(r2, "").toLocaleLowerCase(); - return n3 ? "dddd" === t5 ? -1 !== (i3 = S.call(this._weekdaysParse, e4)) ? i3 : null : "ddd" === t5 ? -1 !== (i3 = S.call(this._shortWeekdaysParse, e4)) ? i3 : null : -1 !== (i3 = S.call(this._minWeekdaysParse, e4)) ? i3 : null : "dddd" === t5 ? -1 !== (i3 = S.call(this._weekdaysParse, e4)) || -1 !== (i3 = S.call(this._shortWeekdaysParse, e4)) || -1 !== (i3 = S.call(this._minWeekdaysParse, e4)) ? i3 : null : "ddd" === t5 ? -1 !== (i3 = S.call(this._shortWeekdaysParse, e4)) || -1 !== (i3 = S.call(this._weekdaysParse, e4)) || -1 !== (i3 = S.call(this._minWeekdaysParse, e4)) ? i3 : null : -1 !== (i3 = S.call(this._minWeekdaysParse, e4)) || -1 !== (i3 = S.call(this._weekdaysParse, e4)) || -1 !== (i3 = S.call(this._shortWeekdaysParse, e4)) ? i3 : null; - }.call(this, e3, t4, n2); - for (this._weekdaysParse || (this._weekdaysParse = [], this._minWeekdaysParse = [], this._shortWeekdaysParse = [], this._fullWeekdaysParse = []), s3 = 0; s3 < 7; s3++) { - if (i2 = l([2e3, 1]).day(s3), n2 && !this._fullWeekdaysParse[s3] && (this._fullWeekdaysParse[s3] = new RegExp("^" + this.weekdays(i2, "").replace(".", "\\.?") + "$", "i"), this._shortWeekdaysParse[s3] = new RegExp("^" + this.weekdaysShort(i2, "").replace(".", "\\.?") + "$", "i"), this._minWeekdaysParse[s3] = new RegExp("^" + this.weekdaysMin(i2, "").replace(".", "\\.?") + "$", "i")), this._weekdaysParse[s3] || (i2 = "^" + this.weekdays(i2, "") + "|^" + this.weekdaysShort(i2, "") + "|^" + this.weekdaysMin(i2, ""), this._weekdaysParse[s3] = new RegExp(i2.replace(".", ""), "i")), n2 && "dddd" === t4 && this._fullWeekdaysParse[s3].test(e3)) - return s3; - if (n2 && "ddd" === t4 && this._shortWeekdaysParse[s3].test(e3)) - return s3; - if (n2 && "dd" === t4 && this._minWeekdaysParse[s3].test(e3)) - return s3; - if (!n2 && this._weekdaysParse[s3].test(e3)) - return s3; - } - }, w2.weekdaysRegex = function(e3) { - return this._weekdaysParseExact ? (c2(this, "_weekdaysRegex") || nt.call(this), e3 ? this._weekdaysStrictRegex : this._weekdaysRegex) : (c2(this, "_weekdaysRegex") || (this._weekdaysRegex = Ke), this._weekdaysStrictRegex && e3 ? this._weekdaysStrictRegex : this._weekdaysRegex); - }, w2.weekdaysShortRegex = function(e3) { - return this._weekdaysParseExact ? (c2(this, "_weekdaysRegex") || nt.call(this), e3 ? this._weekdaysShortStrictRegex : this._weekdaysShortRegex) : (c2(this, "_weekdaysShortRegex") || (this._weekdaysShortRegex = et), this._weekdaysShortStrictRegex && e3 ? this._weekdaysShortStrictRegex : this._weekdaysShortRegex); - }, w2.weekdaysMinRegex = function(e3) { - return this._weekdaysParseExact ? (c2(this, "_weekdaysRegex") || nt.call(this), e3 ? this._weekdaysMinStrictRegex : this._weekdaysMinRegex) : (c2(this, "_weekdaysMinRegex") || (this._weekdaysMinRegex = tt), this._weekdaysMinStrictRegex && e3 ? this._weekdaysMinStrictRegex : this._weekdaysMinRegex); - }, w2.isPM = function(e3) { - return "p" === (e3 + "").toLowerCase().charAt(0); - }, w2.meridiem = function(e3, t4, n2) { - return 11 < e3 ? n2 ? "pm" : "PM" : n2 ? "am" : "AM"; - }, ct("en", { eras: [{ since: "0001-01-01", until: 1 / 0, offset: 1, name: "Anno Domini", narrow: "AD", abbr: "AD" }, { since: "0000-12-31", until: -1 / 0, offset: 1, name: "Before Christ", narrow: "BC", abbr: "BC" }], dayOfMonthOrdinalParse: /\d{1,2}(th|st|nd|rd)/, ordinal: function(e3) { - var t4 = e3 % 10; - return e3 + (1 === g(e3 % 100 / 10) ? "th" : 1 == t4 ? "st" : 2 == t4 ? "nd" : 3 == t4 ? "rd" : "th"); - } }), f.lang = e("moment.lang is deprecated. Use moment.locale instead.", ct), f.langData = e("moment.langData is deprecated. Use moment.localeData instead.", mt); - var _n = Math.abs; - function yn(e3, t4, n2, s3) { - t4 = C3(t4, n2); - return e3._milliseconds += s3 * t4._milliseconds, e3._days += s3 * t4._days, e3._months += s3 * t4._months, e3._bubble(); - } - function gn(e3) { - return e3 < 0 ? Math.floor(e3) : Math.ceil(e3); - } - function wn(e3) { - return 4800 * e3 / 146097; - } - function pn(e3) { - return 146097 * e3 / 4800; - } - function kn(e3) { - return function() { - return this.as(e3); - }; - } - pe = kn("ms"), me = kn("s"), Ce = kn("m"), we = kn("h"), ge = kn("d"), Je = kn("w"), k2 = kn("M"), _e = kn("Q"), ve = kn("y"); - function vn(e3) { - return function() { - return this.isValid() ? this._data[e3] : NaN; - }; - } - var ye = vn("milliseconds"), ke = vn("seconds"), Ie = vn("minutes"), w2 = vn("hours"), Mn = vn("days"), Dn = vn("months"), Sn = vn("years"); - var Yn2 = Math.round, On = { ss: 44, s: 45, m: 45, h: 22, d: 26, w: null, M: 11 }; - function bn(e3, t4, n2, s3) { - var i2 = C3(e3).abs(), r2 = Yn2(i2.as("s")), a3 = Yn2(i2.as("m")), o2 = Yn2(i2.as("h")), u3 = Yn2(i2.as("d")), l2 = Yn2(i2.as("M")), h2 = Yn2(i2.as("w")), i2 = Yn2(i2.as("y")), r2 = (r2 <= n2.ss ? ["s", r2] : r2 < n2.s && ["ss", r2]) || a3 <= 1 && ["m"] || a3 < n2.m && ["mm", a3] || o2 <= 1 && ["h"] || o2 < n2.h && ["hh", o2] || u3 <= 1 && ["d"] || u3 < n2.d && ["dd", u3]; - return (r2 = (r2 = null != n2.w ? r2 || h2 <= 1 && ["w"] || h2 < n2.w && ["ww", h2] : r2) || l2 <= 1 && ["M"] || l2 < n2.M && ["MM", l2] || i2 <= 1 && ["y"] || ["yy", i2])[2] = t4, r2[3] = 0 < +e3, r2[4] = s3, function(e4, t5, n3, s4, i3) { - return i3.relativeTime(t5 || 1, !!n3, e4, s4); - }.apply(null, r2); - } - var xn = Math.abs; - function Tn(e3) { - return (0 < e3) - (e3 < 0) || +e3; - } - function Nn() { - if (!this.isValid()) - return this.localeData().invalidDate(); - var e3, t4, n2, s3, i2, r2, a3, o2 = xn(this._milliseconds) / 1e3, u3 = xn(this._days), l2 = xn(this._months), h2 = this.asSeconds(); - return h2 ? (e3 = y2(o2 / 60), t4 = y2(e3 / 60), o2 %= 60, e3 %= 60, n2 = y2(l2 / 12), l2 %= 12, s3 = o2 ? o2.toFixed(3).replace(/\.?0+$/, "") : "", i2 = Tn(this._months) !== Tn(h2) ? "-" : "", r2 = Tn(this._days) !== Tn(h2) ? "-" : "", a3 = Tn(this._milliseconds) !== Tn(h2) ? "-" : "", (h2 < 0 ? "-" : "") + "P" + (n2 ? i2 + n2 + "Y" : "") + (l2 ? i2 + l2 + "M" : "") + (u3 ? r2 + u3 + "D" : "") + (t4 || e3 || o2 ? "T" : "") + (t4 ? a3 + t4 + "H" : "") + (e3 ? a3 + e3 + "M" : "") + (o2 ? a3 + s3 + "S" : "")) : "P0D"; - } - var U = Ct.prototype; - return U.isValid = function() { - return this._isValid; - }, U.abs = function() { - var e3 = this._data; - return this._milliseconds = _n(this._milliseconds), this._days = _n(this._days), this._months = _n(this._months), e3.milliseconds = _n(e3.milliseconds), e3.seconds = _n(e3.seconds), e3.minutes = _n(e3.minutes), e3.hours = _n(e3.hours), e3.months = _n(e3.months), e3.years = _n(e3.years), this; - }, U.add = function(e3, t4) { - return yn(this, e3, t4, 1); - }, U.subtract = function(e3, t4) { - return yn(this, e3, t4, -1); - }, U.as = function(e3) { - if (!this.isValid()) - return NaN; - var t4, n2, s3 = this._milliseconds; - if ("month" === (e3 = _2(e3)) || "quarter" === e3 || "year" === e3) - switch (t4 = this._days + s3 / 864e5, n2 = this._months + wn(t4), e3) { - case "month": - return n2; - case "quarter": - return n2 / 3; - case "year": - return n2 / 12; - } - else - switch (t4 = this._days + Math.round(pn(this._months)), e3) { - case "week": - return t4 / 7 + s3 / 6048e5; - case "day": - return t4 + s3 / 864e5; - case "hour": - return 24 * t4 + s3 / 36e5; - case "minute": - return 1440 * t4 + s3 / 6e4; - case "second": - return 86400 * t4 + s3 / 1e3; - case "millisecond": - return Math.floor(864e5 * t4) + s3; - default: - throw new Error("Unknown unit " + e3); - } - }, U.asMilliseconds = pe, U.asSeconds = me, U.asMinutes = Ce, U.asHours = we, U.asDays = ge, U.asWeeks = Je, U.asMonths = k2, U.asQuarters = _e, U.asYears = ve, U.valueOf = function() { - return this.isValid() ? this._milliseconds + 864e5 * this._days + this._months % 12 * 2592e6 + 31536e6 * g(this._months / 12) : NaN; - }, U._bubble = function() { - var e3 = this._milliseconds, t4 = this._days, n2 = this._months, s3 = this._data; - return 0 <= e3 && 0 <= t4 && 0 <= n2 || e3 <= 0 && t4 <= 0 && n2 <= 0 || (e3 += 864e5 * gn(pn(n2) + t4), n2 = t4 = 0), s3.milliseconds = e3 % 1e3, e3 = y2(e3 / 1e3), s3.seconds = e3 % 60, e3 = y2(e3 / 60), s3.minutes = e3 % 60, e3 = y2(e3 / 60), s3.hours = e3 % 24, t4 += y2(e3 / 24), n2 += e3 = y2(wn(t4)), t4 -= gn(pn(e3)), e3 = y2(n2 / 12), n2 %= 12, s3.days = t4, s3.months = n2, s3.years = e3, this; - }, U.clone = function() { - return C3(this); - }, U.get = function(e3) { - return e3 = _2(e3), this.isValid() ? this[e3 + "s"]() : NaN; - }, U.milliseconds = ye, U.seconds = ke, U.minutes = Ie, U.hours = w2, U.days = Mn, U.weeks = function() { - return y2(this.days() / 7); - }, U.months = Dn, U.years = Sn, U.humanize = function(e3, t4) { - if (!this.isValid()) - return this.localeData().invalidDate(); - var n2 = false, s3 = On; - return "object" == typeof e3 && (t4 = e3, e3 = false), "boolean" == typeof e3 && (n2 = e3), "object" == typeof t4 && (s3 = Object.assign({}, On, t4), null != t4.s && null == t4.ss && (s3.ss = t4.s - 1)), e3 = this.localeData(), t4 = bn(this, !n2, s3, e3), n2 && (t4 = e3.pastFuture(+this, t4)), e3.postformat(t4); - }, U.toISOString = Nn, U.toString = Nn, U.toJSON = Nn, U.locale = Xt, U.localeData = Kt, U.toIsoString = e("toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)", Nn), U.lang = Xe, s2("X", 0, 0, "unix"), s2("x", 0, 0, "valueOf"), v("x", De), v("X", /[+-]?\d+(\.\d{1,3})?/), D2("X", function(e3, t4, n2) { - n2._d = new Date(1e3 * parseFloat(e3)); - }), D2("x", function(e3, t4, n2) { - n2._d = new Date(g(e3)); - }), f.version = "2.29.4", H = W, f.fn = i, f.min = function() { - return Rt("isBefore", [].slice.call(arguments, 0)); - }, f.max = function() { - return Rt("isAfter", [].slice.call(arguments, 0)); - }, f.now = function() { - return Date.now ? Date.now() : +new Date(); - }, f.utc = l, f.unix = function(e3) { - return W(1e3 * e3); - }, f.months = function(e3, t4) { - return fn(e3, t4, "months"); - }, f.isDate = V, f.locale = ct, f.invalid = I, f.duration = C3, f.isMoment = h, f.weekdays = function(e3, t4, n2) { - return mn(e3, t4, n2, "weekdays"); - }, f.parseZone = function() { - return W.apply(null, arguments).parseZone(); - }, f.localeData = mt, f.isDuration = Ut, f.monthsShort = function(e3, t4) { - return fn(e3, t4, "monthsShort"); - }, f.weekdaysMin = function(e3, t4, n2) { - return mn(e3, t4, n2, "weekdaysMin"); - }, f.defineLocale = ft, f.updateLocale = function(e3, t4) { - var n2, s3; - return null != t4 ? (s3 = ot, null != R[e3] && null != R[e3].parentLocale ? R[e3].set(X3(R[e3]._config, t4)) : (t4 = X3(s3 = null != (n2 = dt(e3)) ? n2._config : s3, t4), null == n2 && (t4.abbr = e3), (s3 = new K2(t4)).parentLocale = R[e3], R[e3] = s3), ct(e3)) : null != R[e3] && (null != R[e3].parentLocale ? (R[e3] = R[e3].parentLocale, e3 === ct() && ct(e3)) : null != R[e3] && delete R[e3]), R[e3]; - }, f.locales = function() { - return ee(R); - }, f.weekdaysShort = function(e3, t4, n2) { - return mn(e3, t4, n2, "weekdaysShort"); - }, f.normalizeUnits = _2, f.relativeTimeRounding = function(e3) { - return void 0 === e3 ? Yn2 : "function" == typeof e3 && (Yn2 = e3, true); - }, f.relativeTimeThreshold = function(e3, t4) { - return void 0 !== On[e3] && (void 0 === t4 ? On[e3] : (On[e3] = t4, "s" === e3 && (On.ss = t4 - 1), true)); - }, f.calendarFormat = function(e3, t4) { - return (e3 = e3.diff(t4, "days", true)) < -6 ? "sameElse" : e3 < -1 ? "lastWeek" : e3 < 0 ? "lastDay" : e3 < 1 ? "sameDay" : e3 < 2 ? "nextDay" : e3 < 7 ? "nextWeek" : "sameElse"; - }, f.prototype = i, f.HTML5_FMT = { DATETIME_LOCAL: "YYYY-MM-DDTHH:mm", DATETIME_LOCAL_SECONDS: "YYYY-MM-DDTHH:mm:ss", DATETIME_LOCAL_MS: "YYYY-MM-DDTHH:mm:ss.SSS", DATE: "YYYY-MM-DD", TIME: "HH:mm", TIME_SECONDS: "HH:mm:ss", TIME_MS: "HH:mm:ss.SSS", WEEK: "GGGG-[W]WW", MONTH: "YYYY-MM" }, f; - }); - })(moment_min); - const moment = moment_min.exports; - const LEVELS = { - trace: 0, - debug: 1, - info: 2, - warn: 3, - error: 4, - fatal: 5 - }; - const log$3 = { - trace: (..._args) => { - }, - debug: (..._args) => { - }, - info: (..._args) => { - }, - warn: (..._args) => { - }, - error: (..._args) => { - }, - fatal: (..._args) => { - } - }; - const setLogLevel$1 = function(level = "fatal") { - let numericLevel = LEVELS.fatal; - if (typeof level === "string") { - level = level.toLowerCase(); - if (level in LEVELS) { - numericLevel = LEVELS[level]; - } - } else if (typeof level === "number") { - numericLevel = level; - } - log$3.trace = () => { - }; - log$3.debug = () => { - }; - log$3.info = () => { - }; - log$3.warn = () => { - }; - log$3.error = () => { - }; - log$3.fatal = () => { - }; - if (numericLevel <= LEVELS.fatal) { - log$3.fatal = console.error ? console.error.bind(console, format$1("FATAL"), "color: orange") : console.log.bind(console, "\x1B[35m", format$1("FATAL")); - } - if (numericLevel <= LEVELS.error) { - log$3.error = console.error ? console.error.bind(console, format$1("ERROR"), "color: orange") : console.log.bind(console, "\x1B[31m", format$1("ERROR")); - } - if (numericLevel <= LEVELS.warn) { - log$3.warn = console.warn ? console.warn.bind(console, format$1("WARN"), "color: orange") : console.log.bind(console, `\x1B[33m`, format$1("WARN")); - } - if (numericLevel <= LEVELS.info) { - log$3.info = console.info ? console.info.bind(console, format$1("INFO"), "color: lightblue") : console.log.bind(console, "\x1B[34m", format$1("INFO")); - } - if (numericLevel <= LEVELS.debug) { - log$3.debug = console.debug ? console.debug.bind(console, format$1("DEBUG"), "color: lightgreen") : console.log.bind(console, "\x1B[32m", format$1("DEBUG")); - } - if (numericLevel <= LEVELS.trace) { - log$3.trace = console.debug ? console.debug.bind(console, format$1("TRACE"), "color: lightgreen") : console.log.bind(console, "\x1B[32m", format$1("TRACE")); - } - }; - const format$1 = (level) => { - const time2 = moment().format("ss.SSS"); - return `%c${time2} : ${level} : `; - }; - var dist$1 = {}; - Object.defineProperty(dist$1, "__esModule", { value: true }); - var sanitizeUrl_1 = dist$1.sanitizeUrl = void 0; - var invalidProtocolRegex = /^([^\w]*)(javascript|data|vbscript)/im; - var htmlEntitiesRegex = /&#(\w+)(^\w|;)?/g; - var ctrlCharactersRegex = /[\u0000-\u001F\u007F-\u009F\u2000-\u200D\uFEFF]/gim; - var urlSchemeRegex = /^([^:]+):/gm; - var relativeFirstCharacters = [".", "/"]; - function isRelativeUrlWithoutProtocol(url) { - return relativeFirstCharacters.indexOf(url[0]) > -1; - } - function decodeHtmlCharacters(str) { - return str.replace(htmlEntitiesRegex, function(match, dec) { - return String.fromCharCode(dec); - }); - } - function sanitizeUrl(url) { - var sanitizedUrl = decodeHtmlCharacters(url || "").replace(ctrlCharactersRegex, "").trim(); - if (!sanitizedUrl) { - return "about:blank"; - } - if (isRelativeUrlWithoutProtocol(sanitizedUrl)) { - return sanitizedUrl; - } - var urlSchemeParseResults = sanitizedUrl.match(urlSchemeRegex); - if (!urlSchemeParseResults) { - return sanitizedUrl; - } - var urlScheme = urlSchemeParseResults[0]; - if (invalidProtocolRegex.test(urlScheme)) { - return "about:blank"; - } - return sanitizedUrl; - } - sanitizeUrl_1 = dist$1.sanitizeUrl = sanitizeUrl; - function ascending$3(a2, b) { - return a2 == null || b == null ? NaN : a2 < b ? -1 : a2 > b ? 1 : a2 >= b ? 0 : NaN; - } - function descending$2(a2, b) { - return a2 == null || b == null ? NaN : b < a2 ? -1 : b > a2 ? 1 : b >= a2 ? 0 : NaN; - } - function bisector(f) { - let compare1, compare2, delta; - if (f.length !== 2) { - compare1 = ascending$3; - compare2 = (d, x2) => ascending$3(f(d), x2); - delta = (d, x2) => f(d) - x2; - } else { - compare1 = f === ascending$3 || f === descending$2 ? f : zero$1; - compare2 = f; - delta = f; - } - function left2(a2, x2, lo = 0, hi = a2.length) { - if (lo < hi) { - if (compare1(x2, x2) !== 0) - return hi; - do { - const mid = lo + hi >>> 1; - if (compare2(a2[mid], x2) < 0) - lo = mid + 1; - else - hi = mid; - } while (lo < hi); - } - return lo; - } - function right2(a2, x2, lo = 0, hi = a2.length) { - if (lo < hi) { - if (compare1(x2, x2) !== 0) - return hi; - do { - const mid = lo + hi >>> 1; - if (compare2(a2[mid], x2) <= 0) - lo = mid + 1; - else - hi = mid; - } while (lo < hi); - } - return lo; - } - function center2(a2, x2, lo = 0, hi = a2.length) { - const i = left2(a2, x2, lo, hi - 1); - return i > lo && delta(a2[i - 1], x2) > -delta(a2[i], x2) ? i - 1 : i; - } - return { left: left2, center: center2, right: right2 }; - } - function zero$1() { - return 0; - } - function number$3(x2) { - return x2 === null ? NaN : +x2; - } - function* numbers(values, valueof) { - if (valueof === void 0) { - for (let value of values) { - if (value != null && (value = +value) >= value) { - yield value; - } - } - } else { - let index2 = -1; - for (let value of values) { - if ((value = valueof(value, ++index2, values)) != null && (value = +value) >= value) { - yield value; - } - } - } - } - const ascendingBisect = bisector(ascending$3); - const bisectRight = ascendingBisect.right; - const bisectLeft = ascendingBisect.left; - const bisectCenter = bisector(number$3).center; - const bisect = bisectRight; - function blur(values, r) { - if (!((r = +r) >= 0)) - throw new RangeError("invalid r"); - let length2 = values.length; - if (!((length2 = Math.floor(length2)) >= 0)) - throw new RangeError("invalid length"); - if (!length2 || !r) - return values; - const blur3 = blurf(r); - const temp = values.slice(); - blur3(values, temp, 0, length2, 1); - blur3(temp, values, 0, length2, 1); - blur3(values, temp, 0, length2, 1); - return values; - } - const blur2 = Blur2(blurf); - const blurImage = Blur2(blurfImage); - function Blur2(blur3) { - return function(data, rx, ry = rx) { - if (!((rx = +rx) >= 0)) - throw new RangeError("invalid rx"); - if (!((ry = +ry) >= 0)) - throw new RangeError("invalid ry"); - let { data: values, width: width2, height: height2 } = data; - if (!((width2 = Math.floor(width2)) >= 0)) - throw new RangeError("invalid width"); - if (!((height2 = Math.floor(height2 !== void 0 ? height2 : values.length / width2)) >= 0)) - throw new RangeError("invalid height"); - if (!width2 || !height2 || !rx && !ry) - return data; - const blurx = rx && blur3(rx); - const blury = ry && blur3(ry); - const temp = values.slice(); - if (blurx && blury) { - blurh(blurx, temp, values, width2, height2); - blurh(blurx, values, temp, width2, height2); - blurh(blurx, temp, values, width2, height2); - blurv(blury, values, temp, width2, height2); - blurv(blury, temp, values, width2, height2); - blurv(blury, values, temp, width2, height2); - } else if (blurx) { - blurh(blurx, values, temp, width2, height2); - blurh(blurx, temp, values, width2, height2); - blurh(blurx, values, temp, width2, height2); - } else if (blury) { - blurv(blury, values, temp, width2, height2); - blurv(blury, temp, values, width2, height2); - blurv(blury, values, temp, width2, height2); - } - return data; - }; - } - function blurh(blur3, T, S, w2, h) { - for (let y2 = 0, n = w2 * h; y2 < n; ) { - blur3(T, S, y2, y2 += w2, 1); - } - } - function blurv(blur3, T, S, w2, h) { - for (let x2 = 0, n = w2 * h; x2 < w2; ++x2) { - blur3(T, S, x2, x2 + n, w2); - } - } - function blurfImage(radius) { - const blur3 = blurf(radius); - return (T, S, start2, stop, step) => { - start2 <<= 2, stop <<= 2, step <<= 2; - blur3(T, S, start2 + 0, stop + 0, step); - blur3(T, S, start2 + 1, stop + 1, step); - blur3(T, S, start2 + 2, stop + 2, step); - blur3(T, S, start2 + 3, stop + 3, step); - }; - } - function blurf(radius) { - const radius0 = Math.floor(radius); - if (radius0 === radius) - return bluri(radius); - const t = radius - radius0; - const w2 = 2 * radius + 1; - return (T, S, start2, stop, step) => { - if (!((stop -= step) >= start2)) - return; - let sum2 = radius0 * S[start2]; - const s0 = step * radius0; - const s1 = s0 + step; - for (let i = start2, j = start2 + s0; i < j; i += step) { - sum2 += S[Math.min(stop, i)]; - } - for (let i = start2, j = stop; i <= j; i += step) { - sum2 += S[Math.min(stop, i + s0)]; - T[i] = (sum2 + t * (S[Math.max(start2, i - s1)] + S[Math.min(stop, i + s1)])) / w2; - sum2 -= S[Math.max(start2, i - s0)]; - } - }; - } - function bluri(radius) { - const w2 = 2 * radius + 1; - return (T, S, start2, stop, step) => { - if (!((stop -= step) >= start2)) - return; - let sum2 = radius * S[start2]; - const s2 = step * radius; - for (let i = start2, j = start2 + s2; i < j; i += step) { - sum2 += S[Math.min(stop, i)]; - } - for (let i = start2, j = stop; i <= j; i += step) { - sum2 += S[Math.min(stop, i + s2)]; - T[i] = sum2 / w2; - sum2 -= S[Math.max(start2, i - s2)]; - } - }; - } - function count$1(values, valueof) { - let count2 = 0; - if (valueof === void 0) { - for (let value of values) { - if (value != null && (value = +value) >= value) { - ++count2; - } - } - } else { - let index2 = -1; - for (let value of values) { - if ((value = valueof(value, ++index2, values)) != null && (value = +value) >= value) { - ++count2; - } - } - } - return count2; - } - function length$4(array2) { - return array2.length | 0; - } - function empty$2(length2) { - return !(length2 > 0); - } - function arrayify(values) { - return typeof values !== "object" || "length" in values ? values : Array.from(values); - } - function reducer(reduce2) { - return (values) => reduce2(...values); - } - function cross$3(...values) { - const reduce2 = typeof values[values.length - 1] === "function" && reducer(values.pop()); - values = values.map(arrayify); - const lengths = values.map(length$4); - const j = values.length - 1; - const index2 = new Array(j + 1).fill(0); - const product = []; - if (j < 0 || lengths.some(empty$2)) - return product; - while (true) { - product.push(index2.map((j2, i2) => values[i2][j2])); - let i = j; - while (++index2[i] === lengths[i]) { - if (i === 0) - return reduce2 ? product.map(reduce2) : product; - index2[i--] = 0; - } - } - } - function cumsum(values, valueof) { - var sum2 = 0, index2 = 0; - return Float64Array.from(values, valueof === void 0 ? (v) => sum2 += +v || 0 : (v) => sum2 += +valueof(v, index2++, values) || 0); - } - function variance(values, valueof) { - let count2 = 0; - let delta; - let mean2 = 0; - let sum2 = 0; - if (valueof === void 0) { - for (let value of values) { - if (value != null && (value = +value) >= value) { - delta = value - mean2; - mean2 += delta / ++count2; - sum2 += delta * (value - mean2); - } - } - } else { - let index2 = -1; - for (let value of values) { - if ((value = valueof(value, ++index2, values)) != null && (value = +value) >= value) { - delta = value - mean2; - mean2 += delta / ++count2; - sum2 += delta * (value - mean2); - } - } - } - if (count2 > 1) - return sum2 / (count2 - 1); - } - function deviation(values, valueof) { - const v = variance(values, valueof); - return v ? Math.sqrt(v) : v; - } - function extent$1(values, valueof) { - let min2; - let max2; - if (valueof === void 0) { - for (const value of values) { - if (value != null) { - if (min2 === void 0) { - if (value >= value) - min2 = max2 = value; - } else { - if (min2 > value) - min2 = value; - if (max2 < value) - max2 = value; - } - } - } - } else { - let index2 = -1; - for (let value of values) { - if ((value = valueof(value, ++index2, values)) != null) { - if (min2 === void 0) { - if (value >= value) - min2 = max2 = value; - } else { - if (min2 > value) - min2 = value; - if (max2 < value) - max2 = value; - } - } - } - } - return [min2, max2]; - } - class Adder { - constructor() { - this._partials = new Float64Array(32); - this._n = 0; - } - add(x2) { - const p = this._partials; - let i = 0; - for (let j = 0; j < this._n && j < 32; j++) { - const y2 = p[j], hi = x2 + y2, lo = Math.abs(x2) < Math.abs(y2) ? x2 - (hi - y2) : y2 - (hi - x2); - if (lo) - p[i++] = lo; - x2 = hi; - } - p[i] = x2; - this._n = i + 1; - return this; - } - valueOf() { - const p = this._partials; - let n = this._n, x2, y2, lo, hi = 0; - if (n > 0) { - hi = p[--n]; - while (n > 0) { - x2 = hi; - y2 = p[--n]; - hi = x2 + y2; - lo = y2 - (hi - x2); - if (lo) - break; - } - if (n > 0 && (lo < 0 && p[n - 1] < 0 || lo > 0 && p[n - 1] > 0)) { - y2 = lo * 2; - x2 = hi + y2; - if (y2 == x2 - hi) - hi = x2; - } - } - return hi; - } - } - function fsum(values, valueof) { - const adder = new Adder(); - if (valueof === void 0) { - for (let value of values) { - if (value = +value) { - adder.add(value); - } - } - } else { - let index2 = -1; - for (let value of values) { - if (value = +valueof(value, ++index2, values)) { - adder.add(value); - } - } - } - return +adder; - } - function fcumsum(values, valueof) { - const adder = new Adder(); - let index2 = -1; - return Float64Array.from( - values, - valueof === void 0 ? (v) => adder.add(+v || 0) : (v) => adder.add(+valueof(v, ++index2, values) || 0) - ); - } - class InternMap extends Map { - constructor(entries, key = keyof) { - super(); - Object.defineProperties(this, { _intern: { value: /* @__PURE__ */ new Map() }, _key: { value: key } }); - if (entries != null) - for (const [key2, value] of entries) - this.set(key2, value); - } - get(key) { - return super.get(intern_get(this, key)); - } - has(key) { - return super.has(intern_get(this, key)); - } - set(key, value) { - return super.set(intern_set(this, key), value); - } - delete(key) { - return super.delete(intern_delete(this, key)); - } - } - class InternSet extends Set { - constructor(values, key = keyof) { - super(); - Object.defineProperties(this, { _intern: { value: /* @__PURE__ */ new Map() }, _key: { value: key } }); - if (values != null) - for (const value of values) - this.add(value); - } - has(value) { - return super.has(intern_get(this, value)); - } - add(value) { - return super.add(intern_set(this, value)); - } - delete(value) { - return super.delete(intern_delete(this, value)); - } - } - function intern_get({ _intern, _key }, value) { - const key = _key(value); - return _intern.has(key) ? _intern.get(key) : value; - } - function intern_set({ _intern, _key }, value) { - const key = _key(value); - if (_intern.has(key)) - return _intern.get(key); - _intern.set(key, value); - return value; - } - function intern_delete({ _intern, _key }, value) { - const key = _key(value); - if (_intern.has(key)) { - value = _intern.get(key); - _intern.delete(key); - } - return value; - } - function keyof(value) { - return value !== null && typeof value === "object" ? value.valueOf() : value; - } - function identity$9(x2) { - return x2; - } - function group(values, ...keys) { - return nest(values, identity$9, identity$9, keys); - } - function groups(values, ...keys) { - return nest(values, Array.from, identity$9, keys); - } - function flatten$1(groups2, keys) { - for (let i = 1, n = keys.length; i < n; ++i) { - groups2 = groups2.flatMap((g) => g.pop().map(([key, value]) => [...g, key, value])); - } - return groups2; - } - function flatGroup(values, ...keys) { - return flatten$1(groups(values, ...keys), keys); - } - function flatRollup(values, reduce2, ...keys) { - return flatten$1(rollups(values, reduce2, ...keys), keys); - } - function rollup(values, reduce2, ...keys) { - return nest(values, identity$9, reduce2, keys); - } - function rollups(values, reduce2, ...keys) { - return nest(values, Array.from, reduce2, keys); - } - function index$4(values, ...keys) { - return nest(values, identity$9, unique, keys); - } - function indexes(values, ...keys) { - return nest(values, Array.from, unique, keys); - } - function unique(values) { - if (values.length !== 1) - throw new Error("duplicate key"); - return values[0]; - } - function nest(values, map2, reduce2, keys) { - return function regroup(values2, i) { - if (i >= keys.length) - return reduce2(values2); - const groups2 = new InternMap(); - const keyof2 = keys[i++]; - let index2 = -1; - for (const value of values2) { - const key = keyof2(value, ++index2, values2); - const group2 = groups2.get(key); - if (group2) - group2.push(value); - else - groups2.set(key, [value]); - } - for (const [key, values3] of groups2) { - groups2.set(key, regroup(values3, i)); - } - return map2(groups2); - }(values, 0); - } - function permute(source, keys) { - return Array.from(keys, (key) => source[key]); - } - function sort(values, ...F) { - if (typeof values[Symbol.iterator] !== "function") - throw new TypeError("values is not iterable"); - values = Array.from(values); - let [f] = F; - if (f && f.length !== 2 || F.length > 1) { - const index2 = Uint32Array.from(values, (d, i) => i); - if (F.length > 1) { - F = F.map((f2) => values.map(f2)); - index2.sort((i, j) => { - for (const f2 of F) { - const c2 = ascendingDefined(f2[i], f2[j]); - if (c2) - return c2; - } - }); - } else { - f = values.map(f); - index2.sort((i, j) => ascendingDefined(f[i], f[j])); - } - return permute(values, index2); - } - return values.sort(compareDefined(f)); - } - function compareDefined(compare = ascending$3) { - if (compare === ascending$3) - return ascendingDefined; - if (typeof compare !== "function") - throw new TypeError("compare is not a function"); - return (a2, b) => { - const x2 = compare(a2, b); - if (x2 || x2 === 0) - return x2; - return (compare(b, b) === 0) - (compare(a2, a2) === 0); - }; - } - function ascendingDefined(a2, b) { - return (a2 == null || !(a2 >= a2)) - (b == null || !(b >= b)) || (a2 < b ? -1 : a2 > b ? 1 : 0); - } - function groupSort(values, reduce2, key) { - return (reduce2.length !== 2 ? sort(rollup(values, reduce2, key), ([ak, av], [bk2, bv]) => ascending$3(av, bv) || ascending$3(ak, bk2)) : sort(group(values, key), ([ak, av], [bk2, bv]) => reduce2(av, bv) || ascending$3(ak, bk2))).map(([key2]) => key2); - } - var array$5 = Array.prototype; - var slice$4 = array$5.slice; - function constant$b(x2) { - return () => x2; - } - var e10 = Math.sqrt(50), e5 = Math.sqrt(10), e2 = Math.sqrt(2); - function ticks(start2, stop, count2) { - var reverse2, i = -1, n, ticks2, step; - stop = +stop, start2 = +start2, count2 = +count2; - if (start2 === stop && count2 > 0) - return [start2]; - if (reverse2 = stop < start2) - n = start2, start2 = stop, stop = n; - if ((step = tickIncrement(start2, stop, count2)) === 0 || !isFinite(step)) - return []; - if (step > 0) { - let r0 = Math.round(start2 / step), r1 = Math.round(stop / step); - if (r0 * step < start2) - ++r0; - if (r1 * step > stop) - --r1; - ticks2 = new Array(n = r1 - r0 + 1); - while (++i < n) - ticks2[i] = (r0 + i) * step; - } else { - step = -step; - let r0 = Math.round(start2 * step), r1 = Math.round(stop * step); - if (r0 / step < start2) - ++r0; - if (r1 / step > stop) - --r1; - ticks2 = new Array(n = r1 - r0 + 1); - while (++i < n) - ticks2[i] = (r0 + i) / step; - } - if (reverse2) - ticks2.reverse(); - return ticks2; - } - function tickIncrement(start2, stop, count2) { - var step = (stop - start2) / Math.max(0, count2), power = Math.floor(Math.log(step) / Math.LN10), error = step / Math.pow(10, power); - return power >= 0 ? (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1) * Math.pow(10, power) : -Math.pow(10, -power) / (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1); - } - function tickStep(start2, stop, count2) { - var step0 = Math.abs(stop - start2) / Math.max(0, count2), step1 = Math.pow(10, Math.floor(Math.log(step0) / Math.LN10)), error = step0 / step1; - if (error >= e10) - step1 *= 10; - else if (error >= e5) - step1 *= 5; - else if (error >= e2) - step1 *= 2; - return stop < start2 ? -step1 : step1; - } - function nice$1(start2, stop, count2) { - let prestep; - while (true) { - const step = tickIncrement(start2, stop, count2); - if (step === prestep || step === 0 || !isFinite(step)) { - return [start2, stop]; - } else if (step > 0) { - start2 = Math.floor(start2 / step) * step; - stop = Math.ceil(stop / step) * step; - } else if (step < 0) { - start2 = Math.ceil(start2 * step) / step; - stop = Math.floor(stop * step) / step; - } - prestep = step; - } - } - function thresholdSturges(values) { - return Math.ceil(Math.log(count$1(values)) / Math.LN2) + 1; - } - function bin() { - var value = identity$9, domain = extent$1, threshold2 = thresholdSturges; - function histogram(data) { - if (!Array.isArray(data)) - data = Array.from(data); - var i, n = data.length, x2, step, values = new Array(n); - for (i = 0; i < n; ++i) { - values[i] = value(data[i], i, data); - } - var xz = domain(values), x02 = xz[0], x12 = xz[1], tz = threshold2(values, x02, x12); - if (!Array.isArray(tz)) { - const max2 = x12, tn = +tz; - if (domain === extent$1) - [x02, x12] = nice$1(x02, x12, tn); - tz = ticks(x02, x12, tn); - if (tz[0] <= x02) - step = tickIncrement(x02, x12, tn); - if (tz[tz.length - 1] >= x12) { - if (max2 >= x12 && domain === extent$1) { - const step2 = tickIncrement(x02, x12, tn); - if (isFinite(step2)) { - if (step2 > 0) { - x12 = (Math.floor(x12 / step2) + 1) * step2; - } else if (step2 < 0) { - x12 = (Math.ceil(x12 * -step2) + 1) / -step2; - } - } - } else { - tz.pop(); - } - } - } - var m2 = tz.length; - while (tz[0] <= x02) - tz.shift(), --m2; - while (tz[m2 - 1] > x12) - tz.pop(), --m2; - var bins = new Array(m2 + 1), bin2; - for (i = 0; i <= m2; ++i) { - bin2 = bins[i] = []; - bin2.x0 = i > 0 ? tz[i - 1] : x02; - bin2.x1 = i < m2 ? tz[i] : x12; - } - if (isFinite(step)) { - if (step > 0) { - for (i = 0; i < n; ++i) { - if ((x2 = values[i]) != null && x02 <= x2 && x2 <= x12) { - bins[Math.min(m2, Math.floor((x2 - x02) / step))].push(data[i]); - } - } - } else if (step < 0) { - for (i = 0; i < n; ++i) { - if ((x2 = values[i]) != null && x02 <= x2 && x2 <= x12) { - const j = Math.floor((x02 - x2) * step); - bins[Math.min(m2, j + (tz[j] <= x2))].push(data[i]); - } - } - } - } else { - for (i = 0; i < n; ++i) { - if ((x2 = values[i]) != null && x02 <= x2 && x2 <= x12) { - bins[bisect(tz, x2, 0, m2)].push(data[i]); - } - } - } - return bins; - } - histogram.value = function(_2) { - return arguments.length ? (value = typeof _2 === "function" ? _2 : constant$b(_2), histogram) : value; - }; - histogram.domain = function(_2) { - return arguments.length ? (domain = typeof _2 === "function" ? _2 : constant$b([_2[0], _2[1]]), histogram) : domain; - }; - histogram.thresholds = function(_2) { - return arguments.length ? (threshold2 = typeof _2 === "function" ? _2 : Array.isArray(_2) ? constant$b(slice$4.call(_2)) : constant$b(_2), histogram) : threshold2; - }; - return histogram; - } - function max$3(values, valueof) { - let max2; - if (valueof === void 0) { - for (const value of values) { - if (value != null && (max2 < value || max2 === void 0 && value >= value)) { - max2 = value; - } - } - } else { - let index2 = -1; - for (let value of values) { - if ((value = valueof(value, ++index2, values)) != null && (max2 < value || max2 === void 0 && value >= value)) { - max2 = value; - } - } - } - return max2; - } - function maxIndex(values, valueof) { - let max2; - let maxIndex2 = -1; - let index2 = -1; - if (valueof === void 0) { - for (const value of values) { - ++index2; - if (value != null && (max2 < value || max2 === void 0 && value >= value)) { - max2 = value, maxIndex2 = index2; - } - } - } else { - for (let value of values) { - if ((value = valueof(value, ++index2, values)) != null && (max2 < value || max2 === void 0 && value >= value)) { - max2 = value, maxIndex2 = index2; - } - } - } - return maxIndex2; - } - function min$2(values, valueof) { - let min2; - if (valueof === void 0) { - for (const value of values) { - if (value != null && (min2 > value || min2 === void 0 && value >= value)) { - min2 = value; - } - } - } else { - let index2 = -1; - for (let value of values) { - if ((value = valueof(value, ++index2, values)) != null && (min2 > value || min2 === void 0 && value >= value)) { - min2 = value; - } - } - } - return min2; - } - function minIndex(values, valueof) { - let min2; - let minIndex2 = -1; - let index2 = -1; - if (valueof === void 0) { - for (const value of values) { - ++index2; - if (value != null && (min2 > value || min2 === void 0 && value >= value)) { - min2 = value, minIndex2 = index2; - } - } - } else { - for (let value of values) { - if ((value = valueof(value, ++index2, values)) != null && (min2 > value || min2 === void 0 && value >= value)) { - min2 = value, minIndex2 = index2; - } - } - } - return minIndex2; - } - function quickselect(array2, k2, left2 = 0, right2 = array2.length - 1, compare) { - compare = compare === void 0 ? ascendingDefined : compareDefined(compare); - while (right2 > left2) { - if (right2 - left2 > 600) { - const n = right2 - left2 + 1; - const m2 = k2 - left2 + 1; - const z = Math.log(n); - const s2 = 0.5 * Math.exp(2 * z / 3); - const sd = 0.5 * Math.sqrt(z * s2 * (n - s2) / n) * (m2 - n / 2 < 0 ? -1 : 1); - const newLeft = Math.max(left2, Math.floor(k2 - m2 * s2 / n + sd)); - const newRight = Math.min(right2, Math.floor(k2 + (n - m2) * s2 / n + sd)); - quickselect(array2, k2, newLeft, newRight, compare); - } - const t = array2[k2]; - let i = left2; - let j = right2; - swap$1(array2, left2, k2); - if (compare(array2[right2], t) > 0) - swap$1(array2, left2, right2); - while (i < j) { - swap$1(array2, i, j), ++i, --j; - while (compare(array2[i], t) < 0) - ++i; - while (compare(array2[j], t) > 0) - --j; - } - if (compare(array2[left2], t) === 0) - swap$1(array2, left2, j); - else - ++j, swap$1(array2, j, right2); - if (j <= k2) - left2 = j + 1; - if (k2 <= j) - right2 = j - 1; - } - return array2; - } - function swap$1(array2, i, j) { - const t = array2[i]; - array2[i] = array2[j]; - array2[j] = t; - } - function greatest(values, compare = ascending$3) { - let max2; - let defined = false; - if (compare.length === 1) { - let maxValue; - for (const element of values) { - const value = compare(element); - if (defined ? ascending$3(value, maxValue) > 0 : ascending$3(value, value) === 0) { - max2 = element; - maxValue = value; - defined = true; - } - } - } else { - for (const value of values) { - if (defined ? compare(value, max2) > 0 : compare(value, value) === 0) { - max2 = value; - defined = true; - } - } - } - return max2; - } - function quantile$1(values, p, valueof) { - values = Float64Array.from(numbers(values, valueof)); - if (!(n = values.length)) - return; - if ((p = +p) <= 0 || n < 2) - return min$2(values); - if (p >= 1) - return max$3(values); - var n, i = (n - 1) * p, i0 = Math.floor(i), value0 = max$3(quickselect(values, i0).subarray(0, i0 + 1)), value1 = min$2(values.subarray(i0 + 1)); - return value0 + (value1 - value0) * (i - i0); - } - function quantileSorted(values, p, valueof = number$3) { - if (!(n = values.length)) - return; - if ((p = +p) <= 0 || n < 2) - return +valueof(values[0], 0, values); - if (p >= 1) - return +valueof(values[n - 1], n - 1, values); - var n, i = (n - 1) * p, i0 = Math.floor(i), value0 = +valueof(values[i0], i0, values), value1 = +valueof(values[i0 + 1], i0 + 1, values); - return value0 + (value1 - value0) * (i - i0); - } - function quantileIndex(values, p, valueof) { - values = Float64Array.from(numbers(values, valueof)); - if (!(n = values.length)) - return; - if ((p = +p) <= 0 || n < 2) - return minIndex(values); - if (p >= 1) - return maxIndex(values); - var n, i = Math.floor((n - 1) * p), order = (i2, j) => ascendingDefined(values[i2], values[j]), index2 = quickselect(Uint32Array.from(values, (_2, i2) => i2), i, 0, n - 1, order); - return greatest(index2.subarray(0, i + 1), (i2) => values[i2]); - } - function thresholdFreedmanDiaconis(values, min2, max2) { - return Math.ceil((max2 - min2) / (2 * (quantile$1(values, 0.75) - quantile$1(values, 0.25)) * Math.pow(count$1(values), -1 / 3))); - } - function thresholdScott(values, min2, max2) { - return Math.ceil((max2 - min2) * Math.cbrt(count$1(values)) / (3.49 * deviation(values))); - } - function mean(values, valueof) { - let count2 = 0; - let sum2 = 0; - if (valueof === void 0) { - for (let value of values) { - if (value != null && (value = +value) >= value) { - ++count2, sum2 += value; - } - } - } else { - let index2 = -1; - for (let value of values) { - if ((value = valueof(value, ++index2, values)) != null && (value = +value) >= value) { - ++count2, sum2 += value; - } - } - } - if (count2) - return sum2 / count2; - } - function median(values, valueof) { - return quantile$1(values, 0.5, valueof); - } - function medianIndex(values, valueof) { - return quantileIndex(values, 0.5, valueof); - } - function* flatten(arrays) { - for (const array2 of arrays) { - yield* array2; - } - } - function merge$1(arrays) { - return Array.from(flatten(arrays)); - } - function mode(values, valueof) { - const counts = new InternMap(); - if (valueof === void 0) { - for (let value of values) { - if (value != null && value >= value) { - counts.set(value, (counts.get(value) || 0) + 1); - } - } - } else { - let index2 = -1; - for (let value of values) { - if ((value = valueof(value, ++index2, values)) != null && value >= value) { - counts.set(value, (counts.get(value) || 0) + 1); - } - } - } - let modeValue; - let modeCount = 0; - for (const [value, count2] of counts) { - if (count2 > modeCount) { - modeCount = count2; - modeValue = value; - } - } - return modeValue; - } - function pairs(values, pairof = pair) { - const pairs2 = []; - let previous; - let first = false; - for (const value of values) { - if (first) - pairs2.push(pairof(previous, value)); - previous = value; - first = true; - } - return pairs2; - } - function pair(a2, b) { - return [a2, b]; - } - function range$2(start2, stop, step) { - start2 = +start2, stop = +stop, step = (n = arguments.length) < 2 ? (stop = start2, start2 = 0, 1) : n < 3 ? 1 : +step; - var i = -1, n = Math.max(0, Math.ceil((stop - start2) / step)) | 0, range2 = new Array(n); - while (++i < n) { - range2[i] = start2 + i * step; - } - return range2; - } - function rank(values, valueof = ascending$3) { - if (typeof values[Symbol.iterator] !== "function") - throw new TypeError("values is not iterable"); - let V = Array.from(values); - const R = new Float64Array(V.length); - if (valueof.length !== 2) - V = V.map(valueof), valueof = ascending$3; - const compareIndex = (i, j) => valueof(V[i], V[j]); - let k2, r; - Uint32Array.from(V, (_2, i) => i).sort(valueof === ascending$3 ? (i, j) => ascendingDefined(V[i], V[j]) : compareDefined(compareIndex)).forEach((j, i) => { - const c2 = compareIndex(j, k2 === void 0 ? j : k2); - if (c2 >= 0) { - if (k2 === void 0 || c2 > 0) - k2 = j, r = i; - R[j] = r; - } else { - R[j] = NaN; - } - }); - return R; - } - function least(values, compare = ascending$3) { - let min2; - let defined = false; - if (compare.length === 1) { - let minValue; - for (const element of values) { - const value = compare(element); - if (defined ? ascending$3(value, minValue) < 0 : ascending$3(value, value) === 0) { - min2 = element; - minValue = value; - defined = true; - } - } - } else { - for (const value of values) { - if (defined ? compare(value, min2) < 0 : compare(value, value) === 0) { - min2 = value; - defined = true; - } - } - } - return min2; - } - function leastIndex(values, compare = ascending$3) { - if (compare.length === 1) - return minIndex(values, compare); - let minValue; - let min2 = -1; - let index2 = -1; - for (const value of values) { - ++index2; - if (min2 < 0 ? compare(value, value) === 0 : compare(value, minValue) < 0) { - minValue = value; - min2 = index2; - } - } - return min2; - } - function greatestIndex(values, compare = ascending$3) { - if (compare.length === 1) - return maxIndex(values, compare); - let maxValue; - let max2 = -1; - let index2 = -1; - for (const value of values) { - ++index2; - if (max2 < 0 ? compare(value, value) === 0 : compare(value, maxValue) > 0) { - maxValue = value; - max2 = index2; - } - } - return max2; - } - function scan(values, compare) { - const index2 = leastIndex(values, compare); - return index2 < 0 ? void 0 : index2; - } - const shuffle$1 = shuffler(Math.random); - function shuffler(random2) { - return function shuffle2(array2, i0 = 0, i1 = array2.length) { - let m2 = i1 - (i0 = +i0); - while (m2) { - const i = random2() * m2-- | 0, t = array2[m2 + i0]; - array2[m2 + i0] = array2[i + i0]; - array2[i + i0] = t; - } - return array2; - }; - } - function sum$2(values, valueof) { - let sum2 = 0; - if (valueof === void 0) { - for (let value of values) { - if (value = +value) { - sum2 += value; - } - } - } else { - let index2 = -1; - for (let value of values) { - if (value = +valueof(value, ++index2, values)) { - sum2 += value; - } - } - } - return sum2; - } - function transpose(matrix) { - if (!(n = matrix.length)) - return []; - for (var i = -1, m2 = min$2(matrix, length$3), transpose2 = new Array(m2); ++i < m2; ) { - for (var j = -1, n, row = transpose2[i] = new Array(n); ++j < n; ) { - row[j] = matrix[j][i]; - } - } - return transpose2; - } - function length$3(d) { - return d.length; - } - function zip() { - return transpose(arguments); - } - function every(values, test) { - if (typeof test !== "function") - throw new TypeError("test is not a function"); - let index2 = -1; - for (const value of values) { - if (!test(value, ++index2, values)) { - return false; - } - } - return true; - } - function some(values, test) { - if (typeof test !== "function") - throw new TypeError("test is not a function"); - let index2 = -1; - for (const value of values) { - if (test(value, ++index2, values)) { - return true; - } - } - return false; - } - function filter$1(values, test) { - if (typeof test !== "function") - throw new TypeError("test is not a function"); - const array2 = []; - let index2 = -1; - for (const value of values) { - if (test(value, ++index2, values)) { - array2.push(value); - } - } - return array2; - } - function map$1(values, mapper) { - if (typeof values[Symbol.iterator] !== "function") - throw new TypeError("values is not iterable"); - if (typeof mapper !== "function") - throw new TypeError("mapper is not a function"); - return Array.from(values, (value, index2) => mapper(value, index2, values)); - } - function reduce(values, reducer2, value) { - if (typeof reducer2 !== "function") - throw new TypeError("reducer is not a function"); - const iterator = values[Symbol.iterator](); - let done, next2, index2 = -1; - if (arguments.length < 3) { - ({ done, value } = iterator.next()); - if (done) - return; - ++index2; - } - while ({ done, value: next2 } = iterator.next(), !done) { - value = reducer2(value, next2, ++index2, values); - } - return value; - } - function reverse$1(values) { - if (typeof values[Symbol.iterator] !== "function") - throw new TypeError("values is not iterable"); - return Array.from(values).reverse(); - } - function difference(values, ...others) { - values = new InternSet(values); - for (const other of others) { - for (const value of other) { - values.delete(value); - } - } - return values; - } - function disjoint(values, other) { - const iterator = other[Symbol.iterator](), set2 = new InternSet(); - for (const v of values) { - if (set2.has(v)) - return false; - let value, done; - while ({ value, done } = iterator.next()) { - if (done) - break; - if (Object.is(v, value)) - return false; - set2.add(value); - } - } - return true; - } - function intersection$1(values, ...others) { - values = new InternSet(values); - others = others.map(set$2); - out: - for (const value of values) { - for (const other of others) { - if (!other.has(value)) { - values.delete(value); - continue out; - } - } - } - return values; - } - function set$2(values) { - return values instanceof InternSet ? values : new InternSet(values); - } - function superset(values, other) { - const iterator = values[Symbol.iterator](), set2 = /* @__PURE__ */ new Set(); - for (const o of other) { - const io = intern(o); - if (set2.has(io)) - continue; - let value, done; - while ({ value, done } = iterator.next()) { - if (done) - return false; - const ivalue = intern(value); - set2.add(ivalue); - if (Object.is(io, ivalue)) - break; - } - } - return true; - } - function intern(value) { - return value !== null && typeof value === "object" ? value.valueOf() : value; - } - function subset(values, other) { - return superset(other, values); - } - function union(...others) { - const set2 = new InternSet(); - for (const other of others) { - for (const o of other) { - set2.add(o); - } - } - return set2; - } - function identity$8(x2) { - return x2; - } - var top = 1, right = 2, bottom = 3, left = 4, epsilon$6 = 1e-6; - function translateX(x2) { - return "translate(" + x2 + ",0)"; - } - function translateY(y2) { - return "translate(0," + y2 + ")"; - } - function number$2(scale) { - return (d) => +scale(d); - } - function center$1(scale, offset) { - offset = Math.max(0, scale.bandwidth() - offset * 2) / 2; - if (scale.round()) - offset = Math.round(offset); - return (d) => +scale(d) + offset; - } - function entering() { - return !this.__axis; - } - function axis(orient, scale) { - var tickArguments = [], tickValues = null, tickFormat2 = null, tickSizeInner = 6, tickSizeOuter = 6, tickPadding = 3, offset = typeof window !== "undefined" && window.devicePixelRatio > 1 ? 0 : 0.5, k2 = orient === top || orient === left ? -1 : 1, x2 = orient === left || orient === right ? "x" : "y", transform2 = orient === top || orient === bottom ? translateX : translateY; - function axis2(context) { - var values = tickValues == null ? scale.ticks ? scale.ticks.apply(scale, tickArguments) : scale.domain() : tickValues, format2 = tickFormat2 == null ? scale.tickFormat ? scale.tickFormat.apply(scale, tickArguments) : identity$8 : tickFormat2, spacing = Math.max(tickSizeInner, 0) + tickPadding, range2 = scale.range(), range0 = +range2[0] + offset, range1 = +range2[range2.length - 1] + offset, position2 = (scale.bandwidth ? center$1 : number$2)(scale.copy(), offset), selection2 = context.selection ? context.selection() : context, path2 = selection2.selectAll(".domain").data([null]), tick = selection2.selectAll(".tick").data(values, scale).order(), tickExit = tick.exit(), tickEnter = tick.enter().append("g").attr("class", "tick"), line2 = tick.select("line"), text2 = tick.select("text"); - path2 = path2.merge(path2.enter().insert("path", ".tick").attr("class", "domain").attr("stroke", "currentColor")); - tick = tick.merge(tickEnter); - line2 = line2.merge(tickEnter.append("line").attr("stroke", "currentColor").attr(x2 + "2", k2 * tickSizeInner)); - text2 = text2.merge(tickEnter.append("text").attr("fill", "currentColor").attr(x2, k2 * spacing).attr("dy", orient === top ? "0em" : orient === bottom ? "0.71em" : "0.32em")); - if (context !== selection2) { - path2 = path2.transition(context); - tick = tick.transition(context); - line2 = line2.transition(context); - text2 = text2.transition(context); - tickExit = tickExit.transition(context).attr("opacity", epsilon$6).attr("transform", function(d) { - return isFinite(d = position2(d)) ? transform2(d + offset) : this.getAttribute("transform"); - }); - tickEnter.attr("opacity", epsilon$6).attr("transform", function(d) { - var p = this.parentNode.__axis; - return transform2((p && isFinite(p = p(d)) ? p : position2(d)) + offset); - }); - } - tickExit.remove(); - path2.attr("d", orient === left || orient === right ? tickSizeOuter ? "M" + k2 * tickSizeOuter + "," + range0 + "H" + offset + "V" + range1 + "H" + k2 * tickSizeOuter : "M" + offset + "," + range0 + "V" + range1 : tickSizeOuter ? "M" + range0 + "," + k2 * tickSizeOuter + "V" + offset + "H" + range1 + "V" + k2 * tickSizeOuter : "M" + range0 + "," + offset + "H" + range1); - tick.attr("opacity", 1).attr("transform", function(d) { - return transform2(position2(d) + offset); - }); - line2.attr(x2 + "2", k2 * tickSizeInner); - text2.attr(x2, k2 * spacing).text(format2); - selection2.filter(entering).attr("fill", "none").attr("font-size", 10).attr("font-family", "sans-serif").attr("text-anchor", orient === right ? "start" : orient === left ? "end" : "middle"); - selection2.each(function() { - this.__axis = position2; - }); - } - axis2.scale = function(_2) { - return arguments.length ? (scale = _2, axis2) : scale; - }; - axis2.ticks = function() { - return tickArguments = Array.from(arguments), axis2; - }; - axis2.tickArguments = function(_2) { - return arguments.length ? (tickArguments = _2 == null ? [] : Array.from(_2), axis2) : tickArguments.slice(); - }; - axis2.tickValues = function(_2) { - return arguments.length ? (tickValues = _2 == null ? null : Array.from(_2), axis2) : tickValues && tickValues.slice(); - }; - axis2.tickFormat = function(_2) { - return arguments.length ? (tickFormat2 = _2, axis2) : tickFormat2; - }; - axis2.tickSize = function(_2) { - return arguments.length ? (tickSizeInner = tickSizeOuter = +_2, axis2) : tickSizeInner; - }; - axis2.tickSizeInner = function(_2) { - return arguments.length ? (tickSizeInner = +_2, axis2) : tickSizeInner; - }; - axis2.tickSizeOuter = function(_2) { - return arguments.length ? (tickSizeOuter = +_2, axis2) : tickSizeOuter; - }; - axis2.tickPadding = function(_2) { - return arguments.length ? (tickPadding = +_2, axis2) : tickPadding; - }; - axis2.offset = function(_2) { - return arguments.length ? (offset = +_2, axis2) : offset; - }; - return axis2; - } - function axisTop(scale) { - return axis(top, scale); - } - function axisRight(scale) { - return axis(right, scale); - } - function axisBottom(scale) { - return axis(bottom, scale); - } - function axisLeft(scale) { - return axis(left, scale); - } - var noop$3 = { value: () => { - } }; - function dispatch() { - for (var i = 0, n = arguments.length, _2 = {}, t; i < n; ++i) { - if (!(t = arguments[i] + "") || t in _2 || /[\s.]/.test(t)) - throw new Error("illegal type: " + t); - _2[t] = []; - } - return new Dispatch(_2); - } - function Dispatch(_2) { - this._ = _2; - } - function parseTypenames$1(typenames, types2) { - return typenames.trim().split(/^|\s+/).map(function(t) { - var name2 = "", i = t.indexOf("."); - if (i >= 0) - name2 = t.slice(i + 1), t = t.slice(0, i); - if (t && !types2.hasOwnProperty(t)) - throw new Error("unknown type: " + t); - return { type: t, name: name2 }; - }); - } - Dispatch.prototype = dispatch.prototype = { - constructor: Dispatch, - on: function(typename, callback) { - var _2 = this._, T = parseTypenames$1(typename + "", _2), t, i = -1, n = T.length; - if (arguments.length < 2) { - while (++i < n) - if ((t = (typename = T[i]).type) && (t = get$1(_2[t], typename.name))) - return t; - return; - } - if (callback != null && typeof callback !== "function") - throw new Error("invalid callback: " + callback); - while (++i < n) { - if (t = (typename = T[i]).type) - _2[t] = set$1(_2[t], typename.name, callback); - else if (callback == null) - for (t in _2) - _2[t] = set$1(_2[t], typename.name, null); - } - return this; - }, - copy: function() { - var copy2 = {}, _2 = this._; - for (var t in _2) - copy2[t] = _2[t].slice(); - return new Dispatch(copy2); - }, - call: function(type2, that) { - if ((n = arguments.length - 2) > 0) - for (var args = new Array(n), i = 0, n, t; i < n; ++i) - args[i] = arguments[i + 2]; - if (!this._.hasOwnProperty(type2)) - throw new Error("unknown type: " + type2); - for (t = this._[type2], i = 0, n = t.length; i < n; ++i) - t[i].value.apply(that, args); - }, - apply: function(type2, that, args) { - if (!this._.hasOwnProperty(type2)) - throw new Error("unknown type: " + type2); - for (var t = this._[type2], i = 0, n = t.length; i < n; ++i) - t[i].value.apply(that, args); - } - }; - function get$1(type2, name2) { - for (var i = 0, n = type2.length, c2; i < n; ++i) { - if ((c2 = type2[i]).name === name2) { - return c2.value; - } - } - } - function set$1(type2, name2, callback) { - for (var i = 0, n = type2.length; i < n; ++i) { - if (type2[i].name === name2) { - type2[i] = noop$3, type2 = type2.slice(0, i).concat(type2.slice(i + 1)); - break; - } - } - if (callback != null) - type2.push({ name: name2, value: callback }); - return type2; - } - var xhtml = "http://www.w3.org/1999/xhtml"; - const namespaces = { - svg: "http://www.w3.org/2000/svg", - xhtml, - xlink: "http://www.w3.org/1999/xlink", - xml: "http://www.w3.org/XML/1998/namespace", - xmlns: "http://www.w3.org/2000/xmlns/" - }; - function namespace(name2) { - var prefix = name2 += "", i = prefix.indexOf(":"); - if (i >= 0 && (prefix = name2.slice(0, i)) !== "xmlns") - name2 = name2.slice(i + 1); - return namespaces.hasOwnProperty(prefix) ? { space: namespaces[prefix], local: name2 } : name2; - } - function creatorInherit(name2) { - return function() { - var document2 = this.ownerDocument, uri = this.namespaceURI; - return uri === xhtml && document2.documentElement.namespaceURI === xhtml ? document2.createElement(name2) : document2.createElementNS(uri, name2); - }; - } - function creatorFixed(fullname) { - return function() { - return this.ownerDocument.createElementNS(fullname.space, fullname.local); - }; - } - function creator(name2) { - var fullname = namespace(name2); - return (fullname.local ? creatorFixed : creatorInherit)(fullname); - } - function none$2() { - } - function selector(selector2) { - return selector2 == null ? none$2 : function() { - return this.querySelector(selector2); - }; - } - function selection_select(select2) { - if (typeof select2 !== "function") - select2 = selector(select2); - for (var groups2 = this._groups, m2 = groups2.length, subgroups = new Array(m2), j = 0; j < m2; ++j) { - for (var group2 = groups2[j], n = group2.length, subgroup = subgroups[j] = new Array(n), node2, subnode, i = 0; i < n; ++i) { - if ((node2 = group2[i]) && (subnode = select2.call(node2, node2.__data__, i, group2))) { - if ("__data__" in node2) - subnode.__data__ = node2.__data__; - subgroup[i] = subnode; - } - } - } - return new Selection$1(subgroups, this._parents); - } - function array$4(x2) { - return x2 == null ? [] : Array.isArray(x2) ? x2 : Array.from(x2); - } - function empty$1() { - return []; - } - function selectorAll(selector2) { - return selector2 == null ? empty$1 : function() { - return this.querySelectorAll(selector2); - }; - } - function arrayAll(select2) { - return function() { - return array$4(select2.apply(this, arguments)); - }; - } - function selection_selectAll(select2) { - if (typeof select2 === "function") - select2 = arrayAll(select2); - else - select2 = selectorAll(select2); - for (var groups2 = this._groups, m2 = groups2.length, subgroups = [], parents2 = [], j = 0; j < m2; ++j) { - for (var group2 = groups2[j], n = group2.length, node2, i = 0; i < n; ++i) { - if (node2 = group2[i]) { - subgroups.push(select2.call(node2, node2.__data__, i, group2)); - parents2.push(node2); - } - } - } - return new Selection$1(subgroups, parents2); - } - function matcher(selector2) { - return function() { - return this.matches(selector2); - }; - } - function childMatcher(selector2) { - return function(node2) { - return node2.matches(selector2); - }; - } - var find$1 = Array.prototype.find; - function childFind(match) { - return function() { - return find$1.call(this.children, match); - }; - } - function childFirst() { - return this.firstElementChild; - } - function selection_selectChild(match) { - return this.select(match == null ? childFirst : childFind(typeof match === "function" ? match : childMatcher(match))); - } - var filter = Array.prototype.filter; - function children() { - return Array.from(this.children); - } - function childrenFilter(match) { - return function() { - return filter.call(this.children, match); - }; - } - function selection_selectChildren(match) { - return this.selectAll(match == null ? children : childrenFilter(typeof match === "function" ? match : childMatcher(match))); - } - function selection_filter(match) { - if (typeof match !== "function") - match = matcher(match); - for (var groups2 = this._groups, m2 = groups2.length, subgroups = new Array(m2), j = 0; j < m2; ++j) { - for (var group2 = groups2[j], n = group2.length, subgroup = subgroups[j] = [], node2, i = 0; i < n; ++i) { - if ((node2 = group2[i]) && match.call(node2, node2.__data__, i, group2)) { - subgroup.push(node2); - } - } - } - return new Selection$1(subgroups, this._parents); - } - function sparse(update) { - return new Array(update.length); - } - function selection_enter() { - return new Selection$1(this._enter || this._groups.map(sparse), this._parents); - } - function EnterNode(parent, datum2) { - this.ownerDocument = parent.ownerDocument; - this.namespaceURI = parent.namespaceURI; - this._next = null; - this._parent = parent; - this.__data__ = datum2; - } - EnterNode.prototype = { - constructor: EnterNode, - appendChild: function(child) { - return this._parent.insertBefore(child, this._next); - }, - insertBefore: function(child, next2) { - return this._parent.insertBefore(child, next2); - }, - querySelector: function(selector2) { - return this._parent.querySelector(selector2); - }, - querySelectorAll: function(selector2) { - return this._parent.querySelectorAll(selector2); - } - }; - function constant$a(x2) { - return function() { - return x2; - }; - } - function bindIndex(parent, group2, enter, update, exit, data) { - var i = 0, node2, groupLength = group2.length, dataLength = data.length; - for (; i < dataLength; ++i) { - if (node2 = group2[i]) { - node2.__data__ = data[i]; - update[i] = node2; - } else { - enter[i] = new EnterNode(parent, data[i]); - } - } - for (; i < groupLength; ++i) { - if (node2 = group2[i]) { - exit[i] = node2; - } - } - } - function bindKey(parent, group2, enter, update, exit, data, key) { - var i, node2, nodeByKeyValue = /* @__PURE__ */ new Map(), groupLength = group2.length, dataLength = data.length, keyValues = new Array(groupLength), keyValue; - for (i = 0; i < groupLength; ++i) { - if (node2 = group2[i]) { - keyValues[i] = keyValue = key.call(node2, node2.__data__, i, group2) + ""; - if (nodeByKeyValue.has(keyValue)) { - exit[i] = node2; - } else { - nodeByKeyValue.set(keyValue, node2); - } - } - } - for (i = 0; i < dataLength; ++i) { - keyValue = key.call(parent, data[i], i, data) + ""; - if (node2 = nodeByKeyValue.get(keyValue)) { - update[i] = node2; - node2.__data__ = data[i]; - nodeByKeyValue.delete(keyValue); - } else { - enter[i] = new EnterNode(parent, data[i]); - } - } - for (i = 0; i < groupLength; ++i) { - if ((node2 = group2[i]) && nodeByKeyValue.get(keyValues[i]) === node2) { - exit[i] = node2; - } - } - } - function datum(node2) { - return node2.__data__; - } - function selection_data(value, key) { - if (!arguments.length) - return Array.from(this, datum); - var bind = key ? bindKey : bindIndex, parents2 = this._parents, groups2 = this._groups; - if (typeof value !== "function") - value = constant$a(value); - for (var m2 = groups2.length, update = new Array(m2), enter = new Array(m2), exit = new Array(m2), j = 0; j < m2; ++j) { - var parent = parents2[j], group2 = groups2[j], groupLength = group2.length, data = arraylike(value.call(parent, parent && parent.__data__, j, parents2)), dataLength = data.length, enterGroup = enter[j] = new Array(dataLength), updateGroup = update[j] = new Array(dataLength), exitGroup = exit[j] = new Array(groupLength); - bind(parent, group2, enterGroup, updateGroup, exitGroup, data, key); - for (var i0 = 0, i1 = 0, previous, next2; i0 < dataLength; ++i0) { - if (previous = enterGroup[i0]) { - if (i0 >= i1) - i1 = i0 + 1; - while (!(next2 = updateGroup[i1]) && ++i1 < dataLength) - ; - previous._next = next2 || null; - } - } - } - update = new Selection$1(update, parents2); - update._enter = enter; - update._exit = exit; - return update; - } - function arraylike(data) { - return typeof data === "object" && "length" in data ? data : Array.from(data); - } - function selection_exit() { - return new Selection$1(this._exit || this._groups.map(sparse), this._parents); - } - function selection_join(onenter, onupdate, onexit) { - var enter = this.enter(), update = this, exit = this.exit(); - if (typeof onenter === "function") { - enter = onenter(enter); - if (enter) - enter = enter.selection(); - } else { - enter = enter.append(onenter + ""); - } - if (onupdate != null) { - update = onupdate(update); - if (update) - update = update.selection(); - } - if (onexit == null) - exit.remove(); - else - onexit(exit); - return enter && update ? enter.merge(update).order() : update; - } - function selection_merge(context) { - var selection2 = context.selection ? context.selection() : context; - for (var groups0 = this._groups, groups1 = selection2._groups, m0 = groups0.length, m1 = groups1.length, m2 = Math.min(m0, m1), merges = new Array(m0), j = 0; j < m2; ++j) { - for (var group0 = groups0[j], group1 = groups1[j], n = group0.length, merge2 = merges[j] = new Array(n), node2, i = 0; i < n; ++i) { - if (node2 = group0[i] || group1[i]) { - merge2[i] = node2; - } - } - } - for (; j < m0; ++j) { - merges[j] = groups0[j]; - } - return new Selection$1(merges, this._parents); - } - function selection_order() { - for (var groups2 = this._groups, j = -1, m2 = groups2.length; ++j < m2; ) { - for (var group2 = groups2[j], i = group2.length - 1, next2 = group2[i], node2; --i >= 0; ) { - if (node2 = group2[i]) { - if (next2 && node2.compareDocumentPosition(next2) ^ 4) - next2.parentNode.insertBefore(node2, next2); - next2 = node2; - } - } - } - return this; - } - function selection_sort(compare) { - if (!compare) - compare = ascending$2; - function compareNode(a2, b) { - return a2 && b ? compare(a2.__data__, b.__data__) : !a2 - !b; - } - for (var groups2 = this._groups, m2 = groups2.length, sortgroups = new Array(m2), j = 0; j < m2; ++j) { - for (var group2 = groups2[j], n = group2.length, sortgroup = sortgroups[j] = new Array(n), node2, i = 0; i < n; ++i) { - if (node2 = group2[i]) { - sortgroup[i] = node2; - } - } - sortgroup.sort(compareNode); - } - return new Selection$1(sortgroups, this._parents).order(); - } - function ascending$2(a2, b) { - return a2 < b ? -1 : a2 > b ? 1 : a2 >= b ? 0 : NaN; - } - function selection_call() { - var callback = arguments[0]; - arguments[0] = this; - callback.apply(null, arguments); - return this; - } - function selection_nodes() { - return Array.from(this); - } - function selection_node() { - for (var groups2 = this._groups, j = 0, m2 = groups2.length; j < m2; ++j) { - for (var group2 = groups2[j], i = 0, n = group2.length; i < n; ++i) { - var node2 = group2[i]; - if (node2) - return node2; - } - } - return null; - } - function selection_size() { - let size = 0; - for (const node2 of this) - ++size; - return size; - } - function selection_empty() { - return !this.node(); - } - function selection_each(callback) { - for (var groups2 = this._groups, j = 0, m2 = groups2.length; j < m2; ++j) { - for (var group2 = groups2[j], i = 0, n = group2.length, node2; i < n; ++i) { - if (node2 = group2[i]) - callback.call(node2, node2.__data__, i, group2); - } - } - return this; - } - function attrRemove$1(name2) { - return function() { - this.removeAttribute(name2); - }; - } - function attrRemoveNS$1(fullname) { - return function() { - this.removeAttributeNS(fullname.space, fullname.local); - }; - } - function attrConstant$1(name2, value) { - return function() { - this.setAttribute(name2, value); - }; - } - function attrConstantNS$1(fullname, value) { - return function() { - this.setAttributeNS(fullname.space, fullname.local, value); - }; - } - function attrFunction$1(name2, value) { - return function() { - var v = value.apply(this, arguments); - if (v == null) - this.removeAttribute(name2); - else - this.setAttribute(name2, v); - }; - } - function attrFunctionNS$1(fullname, value) { - return function() { - var v = value.apply(this, arguments); - if (v == null) - this.removeAttributeNS(fullname.space, fullname.local); - else - this.setAttributeNS(fullname.space, fullname.local, v); - }; - } - function selection_attr(name2, value) { - var fullname = namespace(name2); - if (arguments.length < 2) { - var node2 = this.node(); - return fullname.local ? node2.getAttributeNS(fullname.space, fullname.local) : node2.getAttribute(fullname); - } - return this.each((value == null ? fullname.local ? attrRemoveNS$1 : attrRemove$1 : typeof value === "function" ? fullname.local ? attrFunctionNS$1 : attrFunction$1 : fullname.local ? attrConstantNS$1 : attrConstant$1)(fullname, value)); - } - function defaultView(node2) { - return node2.ownerDocument && node2.ownerDocument.defaultView || node2.document && node2 || node2.defaultView; - } - function styleRemove$1(name2) { - return function() { - this.style.removeProperty(name2); - }; - } - function styleConstant$1(name2, value, priority) { - return function() { - this.style.setProperty(name2, value, priority); - }; - } - function styleFunction$1(name2, value, priority) { - return function() { - var v = value.apply(this, arguments); - if (v == null) - this.style.removeProperty(name2); - else - this.style.setProperty(name2, v, priority); - }; - } - function selection_style(name2, value, priority) { - return arguments.length > 1 ? this.each((value == null ? styleRemove$1 : typeof value === "function" ? styleFunction$1 : styleConstant$1)(name2, value, priority == null ? "" : priority)) : styleValue(this.node(), name2); - } - function styleValue(node2, name2) { - return node2.style.getPropertyValue(name2) || defaultView(node2).getComputedStyle(node2, null).getPropertyValue(name2); - } - function propertyRemove(name2) { - return function() { - delete this[name2]; - }; - } - function propertyConstant(name2, value) { - return function() { - this[name2] = value; - }; - } - function propertyFunction(name2, value) { - return function() { - var v = value.apply(this, arguments); - if (v == null) - delete this[name2]; - else - this[name2] = v; - }; - } - function selection_property(name2, value) { - return arguments.length > 1 ? this.each((value == null ? propertyRemove : typeof value === "function" ? propertyFunction : propertyConstant)(name2, value)) : this.node()[name2]; - } - function classArray(string) { - return string.trim().split(/^|\s+/); - } - function classList(node2) { - return node2.classList || new ClassList(node2); - } - function ClassList(node2) { - this._node = node2; - this._names = classArray(node2.getAttribute("class") || ""); - } - ClassList.prototype = { - add: function(name2) { - var i = this._names.indexOf(name2); - if (i < 0) { - this._names.push(name2); - this._node.setAttribute("class", this._names.join(" ")); - } - }, - remove: function(name2) { - var i = this._names.indexOf(name2); - if (i >= 0) { - this._names.splice(i, 1); - this._node.setAttribute("class", this._names.join(" ")); - } - }, - contains: function(name2) { - return this._names.indexOf(name2) >= 0; - } - }; - function classedAdd(node2, names) { - var list2 = classList(node2), i = -1, n = names.length; - while (++i < n) - list2.add(names[i]); - } - function classedRemove(node2, names) { - var list2 = classList(node2), i = -1, n = names.length; - while (++i < n) - list2.remove(names[i]); - } - function classedTrue(names) { - return function() { - classedAdd(this, names); - }; - } - function classedFalse(names) { - return function() { - classedRemove(this, names); - }; - } - function classedFunction(names, value) { - return function() { - (value.apply(this, arguments) ? classedAdd : classedRemove)(this, names); - }; - } - function selection_classed(name2, value) { - var names = classArray(name2 + ""); - if (arguments.length < 2) { - var list2 = classList(this.node()), i = -1, n = names.length; - while (++i < n) - if (!list2.contains(names[i])) - return false; - return true; - } - return this.each((typeof value === "function" ? classedFunction : value ? classedTrue : classedFalse)(names, value)); - } - function textRemove() { - this.textContent = ""; - } - function textConstant$1(value) { - return function() { - this.textContent = value; - }; - } - function textFunction$1(value) { - return function() { - var v = value.apply(this, arguments); - this.textContent = v == null ? "" : v; - }; - } - function selection_text(value) { - return arguments.length ? this.each(value == null ? textRemove : (typeof value === "function" ? textFunction$1 : textConstant$1)(value)) : this.node().textContent; - } - function htmlRemove() { - this.innerHTML = ""; - } - function htmlConstant(value) { - return function() { - this.innerHTML = value; - }; - } - function htmlFunction(value) { - return function() { - var v = value.apply(this, arguments); - this.innerHTML = v == null ? "" : v; - }; - } - function selection_html(value) { - return arguments.length ? this.each(value == null ? htmlRemove : (typeof value === "function" ? htmlFunction : htmlConstant)(value)) : this.node().innerHTML; - } - function raise() { - if (this.nextSibling) - this.parentNode.appendChild(this); - } - function selection_raise() { - return this.each(raise); - } - function lower() { - if (this.previousSibling) - this.parentNode.insertBefore(this, this.parentNode.firstChild); - } - function selection_lower() { - return this.each(lower); - } - function selection_append(name2) { - var create2 = typeof name2 === "function" ? name2 : creator(name2); - return this.select(function() { - return this.appendChild(create2.apply(this, arguments)); - }); - } - function constantNull() { - return null; - } - function selection_insert(name2, before) { - var create2 = typeof name2 === "function" ? name2 : creator(name2), select2 = before == null ? constantNull : typeof before === "function" ? before : selector(before); - return this.select(function() { - return this.insertBefore(create2.apply(this, arguments), select2.apply(this, arguments) || null); - }); - } - function remove() { - var parent = this.parentNode; - if (parent) - parent.removeChild(this); - } - function selection_remove() { - return this.each(remove); - } - function selection_cloneShallow() { - var clone2 = this.cloneNode(false), parent = this.parentNode; - return parent ? parent.insertBefore(clone2, this.nextSibling) : clone2; - } - function selection_cloneDeep() { - var clone2 = this.cloneNode(true), parent = this.parentNode; - return parent ? parent.insertBefore(clone2, this.nextSibling) : clone2; - } - function selection_clone(deep) { - return this.select(deep ? selection_cloneDeep : selection_cloneShallow); - } - function selection_datum(value) { - return arguments.length ? this.property("__data__", value) : this.node().__data__; - } - function contextListener(listener) { - return function(event) { - listener.call(this, event, this.__data__); - }; - } - function parseTypenames(typenames) { - return typenames.trim().split(/^|\s+/).map(function(t) { - var name2 = "", i = t.indexOf("."); - if (i >= 0) - name2 = t.slice(i + 1), t = t.slice(0, i); - return { type: t, name: name2 }; - }); - } - function onRemove(typename) { - return function() { - var on = this.__on; - if (!on) - return; - for (var j = 0, i = -1, m2 = on.length, o; j < m2; ++j) { - if (o = on[j], (!typename.type || o.type === typename.type) && o.name === typename.name) { - this.removeEventListener(o.type, o.listener, o.options); - } else { - on[++i] = o; - } - } - if (++i) - on.length = i; - else - delete this.__on; - }; - } - function onAdd(typename, value, options2) { - return function() { - var on = this.__on, o, listener = contextListener(value); - if (on) - for (var j = 0, m2 = on.length; j < m2; ++j) { - if ((o = on[j]).type === typename.type && o.name === typename.name) { - this.removeEventListener(o.type, o.listener, o.options); - this.addEventListener(o.type, o.listener = listener, o.options = options2); - o.value = value; - return; - } - } - this.addEventListener(typename.type, listener, options2); - o = { type: typename.type, name: typename.name, value, listener, options: options2 }; - if (!on) - this.__on = [o]; - else - on.push(o); - }; - } - function selection_on(typename, value, options2) { - var typenames = parseTypenames(typename + ""), i, n = typenames.length, t; - if (arguments.length < 2) { - var on = this.node().__on; - if (on) - for (var j = 0, m2 = on.length, o; j < m2; ++j) { - for (i = 0, o = on[j]; i < n; ++i) { - if ((t = typenames[i]).type === o.type && t.name === o.name) { - return o.value; - } - } - } - return; - } - on = value ? onAdd : onRemove; - for (i = 0; i < n; ++i) - this.each(on(typenames[i], value, options2)); - return this; - } - function dispatchEvent(node2, type2, params) { - var window2 = defaultView(node2), event = window2.CustomEvent; - if (typeof event === "function") { - event = new event(type2, params); - } else { - event = window2.document.createEvent("Event"); - if (params) - event.initEvent(type2, params.bubbles, params.cancelable), event.detail = params.detail; - else - event.initEvent(type2, false, false); - } - node2.dispatchEvent(event); - } - function dispatchConstant(type2, params) { - return function() { - return dispatchEvent(this, type2, params); - }; - } - function dispatchFunction(type2, params) { - return function() { - return dispatchEvent(this, type2, params.apply(this, arguments)); - }; - } - function selection_dispatch(type2, params) { - return this.each((typeof params === "function" ? dispatchFunction : dispatchConstant)(type2, params)); - } - function* selection_iterator() { - for (var groups2 = this._groups, j = 0, m2 = groups2.length; j < m2; ++j) { - for (var group2 = groups2[j], i = 0, n = group2.length, node2; i < n; ++i) { - if (node2 = group2[i]) - yield node2; - } - } - } - var root$4 = [null]; - function Selection$1(groups2, parents2) { - this._groups = groups2; - this._parents = parents2; - } - function selection() { - return new Selection$1([[document.documentElement]], root$4); - } - function selection_selection() { - return this; - } - Selection$1.prototype = selection.prototype = { - constructor: Selection$1, - select: selection_select, - selectAll: selection_selectAll, - selectChild: selection_selectChild, - selectChildren: selection_selectChildren, - filter: selection_filter, - data: selection_data, - enter: selection_enter, - exit: selection_exit, - join: selection_join, - merge: selection_merge, - selection: selection_selection, - order: selection_order, - sort: selection_sort, - call: selection_call, - nodes: selection_nodes, - node: selection_node, - size: selection_size, - empty: selection_empty, - each: selection_each, - attr: selection_attr, - style: selection_style, - property: selection_property, - classed: selection_classed, - text: selection_text, - html: selection_html, - raise: selection_raise, - lower: selection_lower, - append: selection_append, - insert: selection_insert, - remove: selection_remove, - clone: selection_clone, - datum: selection_datum, - on: selection_on, - dispatch: selection_dispatch, - [Symbol.iterator]: selection_iterator - }; - function select(selector2) { - return typeof selector2 === "string" ? new Selection$1([[document.querySelector(selector2)]], [document.documentElement]) : new Selection$1([[selector2]], root$4); - } - function create$2(name2) { - return select(creator(name2).call(document.documentElement)); - } - var nextId = 0; - function local$1() { - return new Local(); - } - function Local() { - this._ = "@" + (++nextId).toString(36); - } - Local.prototype = local$1.prototype = { - constructor: Local, - get: function(node2) { - var id2 = this._; - while (!(id2 in node2)) - if (!(node2 = node2.parentNode)) - return; - return node2[id2]; - }, - set: function(node2, value) { - return node2[this._] = value; - }, - remove: function(node2) { - return this._ in node2 && delete node2[this._]; - }, - toString: function() { - return this._; - } - }; - function sourceEvent(event) { - let sourceEvent2; - while (sourceEvent2 = event.sourceEvent) - event = sourceEvent2; - return event; - } - function pointer(event, node2) { - event = sourceEvent(event); - if (node2 === void 0) - node2 = event.currentTarget; - if (node2) { - var svg2 = node2.ownerSVGElement || node2; - if (svg2.createSVGPoint) { - var point2 = svg2.createSVGPoint(); - point2.x = event.clientX, point2.y = event.clientY; - point2 = point2.matrixTransform(node2.getScreenCTM().inverse()); - return [point2.x, point2.y]; - } - if (node2.getBoundingClientRect) { - var rect2 = node2.getBoundingClientRect(); - return [event.clientX - rect2.left - node2.clientLeft, event.clientY - rect2.top - node2.clientTop]; - } - } - return [event.pageX, event.pageY]; - } - function pointers(events, node2) { - if (events.target) { - events = sourceEvent(events); - if (node2 === void 0) - node2 = events.currentTarget; - events = events.touches || [events]; - } - return Array.from(events, (event) => pointer(event, node2)); - } - function selectAll(selector2) { - return typeof selector2 === "string" ? new Selection$1([document.querySelectorAll(selector2)], [document.documentElement]) : new Selection$1([array$4(selector2)], root$4); - } - const nonpassive = { passive: false }; - const nonpassivecapture = { capture: true, passive: false }; - function nopropagation$2(event) { - event.stopImmediatePropagation(); - } - function noevent$2(event) { - event.preventDefault(); - event.stopImmediatePropagation(); - } - function dragDisable(view) { - var root2 = view.document.documentElement, selection2 = select(view).on("dragstart.drag", noevent$2, nonpassivecapture); - if ("onselectstart" in root2) { - selection2.on("selectstart.drag", noevent$2, nonpassivecapture); - } else { - root2.__noselect = root2.style.MozUserSelect; - root2.style.MozUserSelect = "none"; - } - } - function yesdrag(view, noclick) { - var root2 = view.document.documentElement, selection2 = select(view).on("dragstart.drag", null); - if (noclick) { - selection2.on("click.drag", noevent$2, nonpassivecapture); - setTimeout(function() { - selection2.on("click.drag", null); - }, 0); - } - if ("onselectstart" in root2) { - selection2.on("selectstart.drag", null); - } else { - root2.style.MozUserSelect = root2.__noselect; - delete root2.__noselect; - } - } - const constant$9 = (x2) => () => x2; - function DragEvent(type2, { - sourceEvent: sourceEvent2, - subject, - target, - identifier: identifier2, - active: active2, - x: x2, - y: y2, - dx, - dy, - dispatch: dispatch2 - }) { - Object.defineProperties(this, { - type: { value: type2, enumerable: true, configurable: true }, - sourceEvent: { value: sourceEvent2, enumerable: true, configurable: true }, - subject: { value: subject, enumerable: true, configurable: true }, - target: { value: target, enumerable: true, configurable: true }, - identifier: { value: identifier2, enumerable: true, configurable: true }, - active: { value: active2, enumerable: true, configurable: true }, - x: { value: x2, enumerable: true, configurable: true }, - y: { value: y2, enumerable: true, configurable: true }, - dx: { value: dx, enumerable: true, configurable: true }, - dy: { value: dy, enumerable: true, configurable: true }, - _: { value: dispatch2 } - }); - } - DragEvent.prototype.on = function() { - var value = this._.on.apply(this._, arguments); - return value === this._ ? this : value; - }; - function defaultFilter$2(event) { - return !event.ctrlKey && !event.button; - } - function defaultContainer() { - return this.parentNode; - } - function defaultSubject(event, d) { - return d == null ? { x: event.x, y: event.y } : d; - } - function defaultTouchable$2() { - return navigator.maxTouchPoints || "ontouchstart" in this; - } - function drag() { - var filter2 = defaultFilter$2, container = defaultContainer, subject = defaultSubject, touchable = defaultTouchable$2, gestures = {}, listeners = dispatch("start", "drag", "end"), active2 = 0, mousedownx, mousedowny, mousemoving, touchending, clickDistance2 = 0; - function drag2(selection2) { - selection2.on("mousedown.drag", mousedowned).filter(touchable).on("touchstart.drag", touchstarted).on("touchmove.drag", touchmoved, nonpassive).on("touchend.drag touchcancel.drag", touchended).style("touch-action", "none").style("-webkit-tap-highlight-color", "rgba(0,0,0,0)"); - } - function mousedowned(event, d) { - if (touchending || !filter2.call(this, event, d)) - return; - var gesture = beforestart(this, container.call(this, event, d), event, d, "mouse"); - if (!gesture) - return; - select(event.view).on("mousemove.drag", mousemoved, nonpassivecapture).on("mouseup.drag", mouseupped, nonpassivecapture); - dragDisable(event.view); - nopropagation$2(event); - mousemoving = false; - mousedownx = event.clientX; - mousedowny = event.clientY; - gesture("start", event); - } - function mousemoved(event) { - noevent$2(event); - if (!mousemoving) { - var dx = event.clientX - mousedownx, dy = event.clientY - mousedowny; - mousemoving = dx * dx + dy * dy > clickDistance2; - } - gestures.mouse("drag", event); - } - function mouseupped(event) { - select(event.view).on("mousemove.drag mouseup.drag", null); - yesdrag(event.view, mousemoving); - noevent$2(event); - gestures.mouse("end", event); - } - function touchstarted(event, d) { - if (!filter2.call(this, event, d)) - return; - var touches = event.changedTouches, c2 = container.call(this, event, d), n = touches.length, i, gesture; - for (i = 0; i < n; ++i) { - if (gesture = beforestart(this, c2, event, d, touches[i].identifier, touches[i])) { - nopropagation$2(event); - gesture("start", event, touches[i]); - } - } - } - function touchmoved(event) { - var touches = event.changedTouches, n = touches.length, i, gesture; - for (i = 0; i < n; ++i) { - if (gesture = gestures[touches[i].identifier]) { - noevent$2(event); - gesture("drag", event, touches[i]); - } - } - } - function touchended(event) { - var touches = event.changedTouches, n = touches.length, i, gesture; - if (touchending) - clearTimeout(touchending); - touchending = setTimeout(function() { - touchending = null; - }, 500); - for (i = 0; i < n; ++i) { - if (gesture = gestures[touches[i].identifier]) { - nopropagation$2(event); - gesture("end", event, touches[i]); - } - } - } - function beforestart(that, container2, event, d, identifier2, touch) { - var dispatch2 = listeners.copy(), p = pointer(touch || event, container2), dx, dy, s2; - if ((s2 = subject.call(that, new DragEvent("beforestart", { - sourceEvent: event, - target: drag2, - identifier: identifier2, - active: active2, - x: p[0], - y: p[1], - dx: 0, - dy: 0, - dispatch: dispatch2 - }), d)) == null) - return; - dx = s2.x - p[0] || 0; - dy = s2.y - p[1] || 0; - return function gesture(type2, event2, touch2) { - var p02 = p, n; - switch (type2) { - case "start": - gestures[identifier2] = gesture, n = active2++; - break; - case "end": - delete gestures[identifier2], --active2; - case "drag": - p = pointer(touch2 || event2, container2), n = active2; - break; - } - dispatch2.call( - type2, - that, - new DragEvent(type2, { - sourceEvent: event2, - subject: s2, - target: drag2, - identifier: identifier2, - active: n, - x: p[0] + dx, - y: p[1] + dy, - dx: p[0] - p02[0], - dy: p[1] - p02[1], - dispatch: dispatch2 - }), - d - ); - }; - } - drag2.filter = function(_2) { - return arguments.length ? (filter2 = typeof _2 === "function" ? _2 : constant$9(!!_2), drag2) : filter2; - }; - drag2.container = function(_2) { - return arguments.length ? (container = typeof _2 === "function" ? _2 : constant$9(_2), drag2) : container; - }; - drag2.subject = function(_2) { - return arguments.length ? (subject = typeof _2 === "function" ? _2 : constant$9(_2), drag2) : subject; - }; - drag2.touchable = function(_2) { - return arguments.length ? (touchable = typeof _2 === "function" ? _2 : constant$9(!!_2), drag2) : touchable; - }; - drag2.on = function() { - var value = listeners.on.apply(listeners, arguments); - return value === listeners ? drag2 : value; - }; - drag2.clickDistance = function(_2) { - return arguments.length ? (clickDistance2 = (_2 = +_2) * _2, drag2) : Math.sqrt(clickDistance2); - }; - return drag2; - } - function define2(constructor, factory, prototype) { - constructor.prototype = factory.prototype = prototype; - prototype.constructor = constructor; - } - function extend(parent, definition) { - var prototype = Object.create(parent.prototype); - for (var key in definition) - prototype[key] = definition[key]; - return prototype; - } - function Color$2() { - } - var darker = 0.7; - var brighter = 1 / darker; - var reI = "\\s*([+-]?\\d+)\\s*", reN = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*", reP = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*", reHex = /^#([0-9a-f]{3,8})$/, reRgbInteger = new RegExp(`^rgb\\(${reI},${reI},${reI}\\)$`), reRgbPercent = new RegExp(`^rgb\\(${reP},${reP},${reP}\\)$`), reRgbaInteger = new RegExp(`^rgba\\(${reI},${reI},${reI},${reN}\\)$`), reRgbaPercent = new RegExp(`^rgba\\(${reP},${reP},${reP},${reN}\\)$`), reHslPercent = new RegExp(`^hsl\\(${reN},${reP},${reP}\\)$`), reHslaPercent = new RegExp(`^hsla\\(${reN},${reP},${reP},${reN}\\)$`); - var named = { - 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 - }; - define2(Color$2, color, { - copy(channels2) { - return Object.assign(new this.constructor(), this, channels2); - }, - displayable() { - return this.rgb().displayable(); - }, - hex: color_formatHex, - formatHex: color_formatHex, - formatHex8: color_formatHex8, - formatHsl: color_formatHsl, - formatRgb: color_formatRgb, - toString: color_formatRgb - }); - function color_formatHex() { - return this.rgb().formatHex(); - } - function color_formatHex8() { - return this.rgb().formatHex8(); - } - function color_formatHsl() { - return hslConvert(this).formatHsl(); - } - function color_formatRgb() { - return this.rgb().formatRgb(); - } - function color(format2) { - var m2, l; - format2 = (format2 + "").trim().toLowerCase(); - return (m2 = reHex.exec(format2)) ? (l = m2[1].length, m2 = parseInt(m2[1], 16), l === 6 ? rgbn(m2) : l === 3 ? new Rgb(m2 >> 8 & 15 | m2 >> 4 & 240, m2 >> 4 & 15 | m2 & 240, (m2 & 15) << 4 | m2 & 15, 1) : l === 8 ? rgba$2(m2 >> 24 & 255, m2 >> 16 & 255, m2 >> 8 & 255, (m2 & 255) / 255) : l === 4 ? rgba$2(m2 >> 12 & 15 | m2 >> 8 & 240, m2 >> 8 & 15 | m2 >> 4 & 240, m2 >> 4 & 15 | m2 & 240, ((m2 & 15) << 4 | m2 & 15) / 255) : null) : (m2 = reRgbInteger.exec(format2)) ? new Rgb(m2[1], m2[2], m2[3], 1) : (m2 = reRgbPercent.exec(format2)) ? new Rgb(m2[1] * 255 / 100, m2[2] * 255 / 100, m2[3] * 255 / 100, 1) : (m2 = reRgbaInteger.exec(format2)) ? rgba$2(m2[1], m2[2], m2[3], m2[4]) : (m2 = reRgbaPercent.exec(format2)) ? rgba$2(m2[1] * 255 / 100, m2[2] * 255 / 100, m2[3] * 255 / 100, m2[4]) : (m2 = reHslPercent.exec(format2)) ? hsla(m2[1], m2[2] / 100, m2[3] / 100, 1) : (m2 = reHslaPercent.exec(format2)) ? hsla(m2[1], m2[2] / 100, m2[3] / 100, m2[4]) : named.hasOwnProperty(format2) ? rgbn(named[format2]) : format2 === "transparent" ? new Rgb(NaN, NaN, NaN, 0) : null; - } - function rgbn(n) { - return new Rgb(n >> 16 & 255, n >> 8 & 255, n & 255, 1); - } - function rgba$2(r, g, b, a2) { - if (a2 <= 0) - r = g = b = NaN; - return new Rgb(r, g, b, a2); - } - function rgbConvert(o) { - if (!(o instanceof Color$2)) - o = color(o); - if (!o) - return new Rgb(); - o = o.rgb(); - return new Rgb(o.r, o.g, o.b, o.opacity); - } - function rgb(r, g, b, opacity) { - return arguments.length === 1 ? rgbConvert(r) : new Rgb(r, g, b, opacity == null ? 1 : opacity); - } - function Rgb(r, g, b, opacity) { - this.r = +r; - this.g = +g; - this.b = +b; - this.opacity = +opacity; - } - define2(Rgb, rgb, extend(Color$2, { - brighter(k2) { - k2 = k2 == null ? brighter : Math.pow(brighter, k2); - return new Rgb(this.r * k2, this.g * k2, this.b * k2, this.opacity); - }, - darker(k2) { - k2 = k2 == null ? darker : Math.pow(darker, k2); - return new Rgb(this.r * k2, this.g * k2, this.b * k2, this.opacity); - }, - rgb() { - return this; - }, - clamp() { - return new Rgb(clampi(this.r), clampi(this.g), clampi(this.b), clampa(this.opacity)); - }, - displayable() { - return -0.5 <= this.r && this.r < 255.5 && (-0.5 <= this.g && this.g < 255.5) && (-0.5 <= this.b && this.b < 255.5) && (0 <= this.opacity && this.opacity <= 1); - }, - hex: rgb_formatHex, - formatHex: rgb_formatHex, - formatHex8: rgb_formatHex8, - formatRgb: rgb_formatRgb, - toString: rgb_formatRgb - })); - function rgb_formatHex() { - return `#${hex(this.r)}${hex(this.g)}${hex(this.b)}`; - } - function rgb_formatHex8() { - return `#${hex(this.r)}${hex(this.g)}${hex(this.b)}${hex((isNaN(this.opacity) ? 1 : this.opacity) * 255)}`; - } - function rgb_formatRgb() { - const a2 = clampa(this.opacity); - return `${a2 === 1 ? "rgb(" : "rgba("}${clampi(this.r)}, ${clampi(this.g)}, ${clampi(this.b)}${a2 === 1 ? ")" : `, ${a2})`}`; - } - function clampa(opacity) { - return isNaN(opacity) ? 1 : Math.max(0, Math.min(1, opacity)); - } - function clampi(value) { - return Math.max(0, Math.min(255, Math.round(value) || 0)); - } - function hex(value) { - value = clampi(value); - return (value < 16 ? "0" : "") + value.toString(16); - } - function hsla(h, s2, l, a2) { - if (a2 <= 0) - h = s2 = l = NaN; - else if (l <= 0 || l >= 1) - h = s2 = NaN; - else if (s2 <= 0) - h = NaN; - return new Hsl(h, s2, l, a2); - } - function hslConvert(o) { - if (o instanceof Hsl) - return new Hsl(o.h, o.s, o.l, o.opacity); - if (!(o instanceof Color$2)) - o = color(o); - if (!o) - return new Hsl(); - if (o instanceof Hsl) - return o; - o = o.rgb(); - var r = o.r / 255, g = o.g / 255, b = o.b / 255, min2 = Math.min(r, g, b), max2 = Math.max(r, g, b), h = NaN, s2 = max2 - min2, l = (max2 + min2) / 2; - if (s2) { - if (r === max2) - h = (g - b) / s2 + (g < b) * 6; - else if (g === max2) - h = (b - r) / s2 + 2; - else - h = (r - g) / s2 + 4; - s2 /= l < 0.5 ? max2 + min2 : 2 - max2 - min2; - h *= 60; - } else { - s2 = l > 0 && l < 1 ? 0 : h; - } - return new Hsl(h, s2, l, o.opacity); - } - function hsl$2(h, s2, l, opacity) { - return arguments.length === 1 ? hslConvert(h) : new Hsl(h, s2, l, opacity == null ? 1 : opacity); - } - function Hsl(h, s2, l, opacity) { - this.h = +h; - this.s = +s2; - this.l = +l; - this.opacity = +opacity; - } - define2(Hsl, hsl$2, extend(Color$2, { - brighter(k2) { - k2 = k2 == null ? brighter : Math.pow(brighter, k2); - return new Hsl(this.h, this.s, this.l * k2, this.opacity); - }, - darker(k2) { - k2 = k2 == null ? darker : Math.pow(darker, k2); - return new Hsl(this.h, this.s, this.l * k2, this.opacity); - }, - rgb() { - var h = this.h % 360 + (this.h < 0) * 360, s2 = isNaN(h) || isNaN(this.s) ? 0 : this.s, l = this.l, m2 = l + (l < 0.5 ? l : 1 - l) * s2, m1 = 2 * l - m2; - return new Rgb( - hsl2rgb(h >= 240 ? h - 240 : h + 120, m1, m2), - hsl2rgb(h, m1, m2), - hsl2rgb(h < 120 ? h + 240 : h - 120, m1, m2), - this.opacity - ); - }, - clamp() { - return new Hsl(clamph(this.h), clampt(this.s), clampt(this.l), clampa(this.opacity)); - }, - displayable() { - return (0 <= this.s && this.s <= 1 || isNaN(this.s)) && (0 <= this.l && this.l <= 1) && (0 <= this.opacity && this.opacity <= 1); - }, - formatHsl() { - const a2 = clampa(this.opacity); - return `${a2 === 1 ? "hsl(" : "hsla("}${clamph(this.h)}, ${clampt(this.s) * 100}%, ${clampt(this.l) * 100}%${a2 === 1 ? ")" : `, ${a2})`}`; - } - })); - function clamph(value) { - value = (value || 0) % 360; - return value < 0 ? value + 360 : value; - } - function clampt(value) { - return Math.max(0, Math.min(1, value || 0)); - } - function hsl2rgb(h, m1, m2) { - return (h < 60 ? m1 + (m2 - m1) * h / 60 : h < 180 ? m2 : h < 240 ? m1 + (m2 - m1) * (240 - h) / 60 : m1) * 255; - } - const radians$1 = Math.PI / 180; - const degrees$2 = 180 / Math.PI; - const K = 18, Xn = 0.96422, Yn = 1, Zn = 0.82521, t0$1 = 4 / 29, t1$1 = 6 / 29, t2 = 3 * t1$1 * t1$1, t3 = t1$1 * t1$1 * t1$1; - function labConvert(o) { - if (o instanceof Lab) - return new Lab(o.l, o.a, o.b, o.opacity); - if (o instanceof Hcl) - return hcl2lab(o); - if (!(o instanceof Rgb)) - o = rgbConvert(o); - var r = rgb2lrgb(o.r), g = rgb2lrgb(o.g), b = rgb2lrgb(o.b), y2 = xyz2lab((0.2225045 * r + 0.7168786 * g + 0.0606169 * b) / Yn), x2, z; - if (r === g && g === b) - x2 = z = y2; - else { - x2 = xyz2lab((0.4360747 * r + 0.3850649 * g + 0.1430804 * b) / Xn); - z = xyz2lab((0.0139322 * r + 0.0971045 * g + 0.7141733 * b) / Zn); - } - return new Lab(116 * y2 - 16, 500 * (x2 - y2), 200 * (y2 - z), o.opacity); - } - function gray(l, opacity) { - return new Lab(l, 0, 0, opacity == null ? 1 : opacity); - } - function lab$1(l, a2, b, opacity) { - return arguments.length === 1 ? labConvert(l) : new Lab(l, a2, b, opacity == null ? 1 : opacity); - } - function Lab(l, a2, b, opacity) { - this.l = +l; - this.a = +a2; - this.b = +b; - this.opacity = +opacity; - } - define2(Lab, lab$1, extend(Color$2, { - brighter(k2) { - return new Lab(this.l + K * (k2 == null ? 1 : k2), this.a, this.b, this.opacity); - }, - darker(k2) { - return new Lab(this.l - K * (k2 == null ? 1 : k2), this.a, this.b, this.opacity); - }, - rgb() { - var y2 = (this.l + 16) / 116, x2 = isNaN(this.a) ? y2 : y2 + this.a / 500, z = isNaN(this.b) ? y2 : y2 - this.b / 200; - x2 = Xn * lab2xyz(x2); - y2 = Yn * lab2xyz(y2); - z = Zn * lab2xyz(z); - return new Rgb( - lrgb2rgb(3.1338561 * x2 - 1.6168667 * y2 - 0.4906146 * z), - lrgb2rgb(-0.9787684 * x2 + 1.9161415 * y2 + 0.033454 * z), - lrgb2rgb(0.0719453 * x2 - 0.2289914 * y2 + 1.4052427 * z), - this.opacity - ); - } - })); - function xyz2lab(t) { - return t > t3 ? Math.pow(t, 1 / 3) : t / t2 + t0$1; - } - function lab2xyz(t) { - return t > t1$1 ? t * t * t : t2 * (t - t0$1); - } - function lrgb2rgb(x2) { - return 255 * (x2 <= 31308e-7 ? 12.92 * x2 : 1.055 * Math.pow(x2, 1 / 2.4) - 0.055); - } - function rgb2lrgb(x2) { - return (x2 /= 255) <= 0.04045 ? x2 / 12.92 : Math.pow((x2 + 0.055) / 1.055, 2.4); - } - function hclConvert(o) { - if (o instanceof Hcl) - return new Hcl(o.h, o.c, o.l, o.opacity); - if (!(o instanceof Lab)) - o = labConvert(o); - if (o.a === 0 && o.b === 0) - return new Hcl(NaN, 0 < o.l && o.l < 100 ? 0 : NaN, o.l, o.opacity); - var h = Math.atan2(o.b, o.a) * degrees$2; - return new Hcl(h < 0 ? h + 360 : h, Math.sqrt(o.a * o.a + o.b * o.b), o.l, o.opacity); - } - function lch(l, c2, h, opacity) { - return arguments.length === 1 ? hclConvert(l) : new Hcl(h, c2, l, opacity == null ? 1 : opacity); - } - function hcl$1(h, c2, l, opacity) { - return arguments.length === 1 ? hclConvert(h) : new Hcl(h, c2, l, opacity == null ? 1 : opacity); - } - function Hcl(h, c2, l, opacity) { - this.h = +h; - this.c = +c2; - this.l = +l; - this.opacity = +opacity; - } - function hcl2lab(o) { - if (isNaN(o.h)) - return new Lab(o.l, 0, 0, o.opacity); - var h = o.h * radians$1; - return new Lab(o.l, Math.cos(h) * o.c, Math.sin(h) * o.c, o.opacity); - } - define2(Hcl, hcl$1, extend(Color$2, { - brighter(k2) { - return new Hcl(this.h, this.c, this.l + K * (k2 == null ? 1 : k2), this.opacity); - }, - darker(k2) { - return new Hcl(this.h, this.c, this.l - K * (k2 == null ? 1 : k2), this.opacity); - }, - rgb() { - return hcl2lab(this).rgb(); - } - })); - var A = -0.14861, B$1 = 1.78277, C = -0.29227, D$1 = -0.90649, E = 1.97294, ED = E * D$1, EB = E * B$1, BC_DA = B$1 * C - D$1 * A; - function cubehelixConvert(o) { - if (o instanceof Cubehelix) - return new Cubehelix(o.h, o.s, o.l, o.opacity); - if (!(o instanceof Rgb)) - o = rgbConvert(o); - var r = o.r / 255, g = o.g / 255, b = o.b / 255, l = (BC_DA * b + ED * r - EB * g) / (BC_DA + ED - EB), bl = b - l, k2 = (E * (g - l) - C * bl) / D$1, s2 = Math.sqrt(k2 * k2 + bl * bl) / (E * l * (1 - l)), h = s2 ? Math.atan2(k2, bl) * degrees$2 - 120 : NaN; - return new Cubehelix(h < 0 ? h + 360 : h, s2, l, o.opacity); - } - function cubehelix$3(h, s2, l, opacity) { - return arguments.length === 1 ? cubehelixConvert(h) : new Cubehelix(h, s2, l, opacity == null ? 1 : opacity); - } - function Cubehelix(h, s2, l, opacity) { - this.h = +h; - this.s = +s2; - this.l = +l; - this.opacity = +opacity; - } - define2(Cubehelix, cubehelix$3, extend(Color$2, { - brighter(k2) { - k2 = k2 == null ? brighter : Math.pow(brighter, k2); - return new Cubehelix(this.h, this.s, this.l * k2, this.opacity); - }, - darker(k2) { - k2 = k2 == null ? darker : Math.pow(darker, k2); - return new Cubehelix(this.h, this.s, this.l * k2, this.opacity); - }, - rgb() { - var h = isNaN(this.h) ? 0 : (this.h + 120) * radians$1, l = +this.l, a2 = isNaN(this.s) ? 0 : this.s * l * (1 - l), cosh2 = Math.cos(h), sinh2 = Math.sin(h); - return new Rgb( - 255 * (l + a2 * (A * cosh2 + B$1 * sinh2)), - 255 * (l + a2 * (C * cosh2 + D$1 * sinh2)), - 255 * (l + a2 * (E * cosh2)), - this.opacity - ); - } - })); - function basis(t12, v0, v1, v2, v3) { - var t22 = t12 * t12, t32 = t22 * t12; - return ((1 - 3 * t12 + 3 * t22 - t32) * v0 + (4 - 6 * t22 + 3 * t32) * v1 + (1 + 3 * t12 + 3 * t22 - 3 * t32) * v2 + t32 * v3) / 6; - } - function basis$1(values) { - var n = values.length - 1; - return function(t) { - var i = t <= 0 ? t = 0 : t >= 1 ? (t = 1, n - 1) : Math.floor(t * n), v1 = values[i], v2 = values[i + 1], v0 = i > 0 ? values[i - 1] : 2 * v1 - v2, v3 = i < n - 1 ? values[i + 2] : 2 * v2 - v1; - return basis((t - i / n) * n, v0, v1, v2, v3); - }; - } - function basisClosed(values) { - var n = values.length; - return function(t) { - var i = Math.floor(((t %= 1) < 0 ? ++t : t) * n), v0 = values[(i + n - 1) % n], v1 = values[i % n], v2 = values[(i + 1) % n], v3 = values[(i + 2) % n]; - return basis((t - i / n) * n, v0, v1, v2, v3); - }; - } - const constant$8 = (x2) => () => x2; - function linear$2(a2, d) { - return function(t) { - return a2 + t * d; - }; - } - function exponential$1(a2, b, y2) { - return a2 = Math.pow(a2, y2), b = Math.pow(b, y2) - a2, y2 = 1 / y2, function(t) { - return Math.pow(a2 + t * b, y2); - }; - } - function hue$1(a2, b) { - var d = b - a2; - return d ? linear$2(a2, d > 180 || d < -180 ? d - 360 * Math.round(d / 360) : d) : constant$8(isNaN(a2) ? b : a2); - } - function gamma$1(y2) { - return (y2 = +y2) === 1 ? nogamma : function(a2, b) { - return b - a2 ? exponential$1(a2, b, y2) : constant$8(isNaN(a2) ? b : a2); - }; - } - function nogamma(a2, b) { - var d = b - a2; - return d ? linear$2(a2, d) : constant$8(isNaN(a2) ? b : a2); - } - const interpolateRgb = function rgbGamma(y2) { - var color2 = gamma$1(y2); - function rgb$1(start2, end2) { - var r = color2((start2 = rgb(start2)).r, (end2 = rgb(end2)).r), g = color2(start2.g, end2.g), b = color2(start2.b, end2.b), opacity = nogamma(start2.opacity, end2.opacity); - return function(t) { - start2.r = r(t); - start2.g = g(t); - start2.b = b(t); - start2.opacity = opacity(t); - return start2 + ""; - }; - } - rgb$1.gamma = rgbGamma; - return rgb$1; - }(1); - function rgbSpline(spline) { - return function(colors2) { - var n = colors2.length, r = new Array(n), g = new Array(n), b = new Array(n), i, color2; - for (i = 0; i < n; ++i) { - color2 = rgb(colors2[i]); - r[i] = color2.r || 0; - g[i] = color2.g || 0; - b[i] = color2.b || 0; - } - r = spline(r); - g = spline(g); - b = spline(b); - color2.opacity = 1; - return function(t) { - color2.r = r(t); - color2.g = g(t); - color2.b = b(t); - return color2 + ""; - }; - }; - } - var rgbBasis = rgbSpline(basis$1); - var rgbBasisClosed = rgbSpline(basisClosed); - function numberArray(a2, b) { - if (!b) - b = []; - var n = a2 ? Math.min(b.length, a2.length) : 0, c2 = b.slice(), i; - return function(t) { - for (i = 0; i < n; ++i) - c2[i] = a2[i] * (1 - t) + b[i] * t; - return c2; - }; - } - function isNumberArray(x2) { - return ArrayBuffer.isView(x2) && !(x2 instanceof DataView); - } - function array$3(a2, b) { - return (isNumberArray(b) ? numberArray : genericArray)(a2, b); - } - function genericArray(a2, b) { - var nb = b ? b.length : 0, na = a2 ? Math.min(nb, a2.length) : 0, x2 = new Array(na), c2 = new Array(nb), i; - for (i = 0; i < na; ++i) - x2[i] = interpolate$2(a2[i], b[i]); - for (; i < nb; ++i) - c2[i] = b[i]; - return function(t) { - for (i = 0; i < na; ++i) - c2[i] = x2[i](t); - return c2; - }; - } - function date$1(a2, b) { - var d = new Date(); - return a2 = +a2, b = +b, function(t) { - return d.setTime(a2 * (1 - t) + b * t), d; - }; - } - function interpolateNumber(a2, b) { - return a2 = +a2, b = +b, function(t) { - return a2 * (1 - t) + b * t; - }; - } - function object$1(a2, b) { - var i = {}, c2 = {}, k2; - if (a2 === null || typeof a2 !== "object") - a2 = {}; - if (b === null || typeof b !== "object") - b = {}; - for (k2 in b) { - if (k2 in a2) { - i[k2] = interpolate$2(a2[k2], b[k2]); - } else { - c2[k2] = b[k2]; - } - } - return function(t) { - for (k2 in i) - c2[k2] = i[k2](t); - return c2; - }; - } - var reA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, reB = new RegExp(reA.source, "g"); - function zero(b) { - return function() { - return b; - }; - } - function one(b) { - return function(t) { - return b(t) + ""; - }; - } - function interpolateString(a2, b) { - var bi = reA.lastIndex = reB.lastIndex = 0, am, bm, bs, i = -1, s2 = [], q = []; - a2 = a2 + "", b = b + ""; - while ((am = reA.exec(a2)) && (bm = reB.exec(b))) { - if ((bs = bm.index) > bi) { - bs = b.slice(bi, bs); - if (s2[i]) - s2[i] += bs; - else - s2[++i] = bs; - } - if ((am = am[0]) === (bm = bm[0])) { - if (s2[i]) - s2[i] += bm; - else - s2[++i] = bm; - } else { - s2[++i] = null; - q.push({ i, x: interpolateNumber(am, bm) }); - } - bi = reB.lastIndex; - } - if (bi < b.length) { - bs = b.slice(bi); - if (s2[i]) - s2[i] += bs; - else - s2[++i] = bs; - } - return s2.length < 2 ? q[0] ? one(q[0].x) : zero(b) : (b = q.length, function(t) { - for (var i2 = 0, o; i2 < b; ++i2) - s2[(o = q[i2]).i] = o.x(t); - return s2.join(""); - }); - } - function interpolate$2(a2, b) { - var t = typeof b, c2; - return b == null || t === "boolean" ? constant$8(b) : (t === "number" ? interpolateNumber : t === "string" ? (c2 = color(b)) ? (b = c2, interpolateRgb) : interpolateString : b instanceof color ? interpolateRgb : b instanceof Date ? date$1 : isNumberArray(b) ? numberArray : Array.isArray(b) ? genericArray : typeof b.valueOf !== "function" && typeof b.toString !== "function" || isNaN(b) ? object$1 : interpolateNumber)(a2, b); - } - function discrete(range2) { - var n = range2.length; - return function(t) { - return range2[Math.max(0, Math.min(n - 1, Math.floor(t * n)))]; - }; - } - function hue(a2, b) { - var i = hue$1(+a2, +b); - return function(t) { - var x2 = i(t); - return x2 - 360 * Math.floor(x2 / 360); - }; - } - function interpolateRound(a2, b) { - return a2 = +a2, b = +b, function(t) { - return Math.round(a2 * (1 - t) + b * t); - }; - } - var degrees$1 = 180 / Math.PI; - var identity$7 = { - translateX: 0, - translateY: 0, - rotate: 0, - skewX: 0, - scaleX: 1, - scaleY: 1 - }; - function decompose(a2, b, c2, d, e, f) { - var scaleX, scaleY, skewX; - if (scaleX = Math.sqrt(a2 * a2 + b * b)) - a2 /= scaleX, b /= scaleX; - if (skewX = a2 * c2 + b * d) - c2 -= a2 * skewX, d -= b * skewX; - if (scaleY = Math.sqrt(c2 * c2 + d * d)) - c2 /= scaleY, d /= scaleY, skewX /= scaleY; - if (a2 * d < b * c2) - a2 = -a2, b = -b, skewX = -skewX, scaleX = -scaleX; - return { - translateX: e, - translateY: f, - rotate: Math.atan2(b, a2) * degrees$1, - skewX: Math.atan(skewX) * degrees$1, - scaleX, - scaleY - }; - } - var svgNode; - function parseCss(value) { - const m2 = new (typeof DOMMatrix === "function" ? DOMMatrix : WebKitCSSMatrix)(value + ""); - return m2.isIdentity ? identity$7 : decompose(m2.a, m2.b, m2.c, m2.d, m2.e, m2.f); - } - function parseSvg(value) { - if (value == null) - return identity$7; - if (!svgNode) - svgNode = document.createElementNS("http://www.w3.org/2000/svg", "g"); - svgNode.setAttribute("transform", value); - if (!(value = svgNode.transform.baseVal.consolidate())) - return identity$7; - value = value.matrix; - return decompose(value.a, value.b, value.c, value.d, value.e, value.f); - } - function interpolateTransform(parse2, pxComma, pxParen, degParen) { - function pop(s2) { - return s2.length ? s2.pop() + " " : ""; - } - function translate(xa, ya, xb, yb, s2, q) { - if (xa !== xb || ya !== yb) { - var i = s2.push("translate(", null, pxComma, null, pxParen); - q.push({ i: i - 4, x: interpolateNumber(xa, xb) }, { i: i - 2, x: interpolateNumber(ya, yb) }); - } else if (xb || yb) { - s2.push("translate(" + xb + pxComma + yb + pxParen); - } - } - function rotate(a2, b, s2, q) { - if (a2 !== b) { - if (a2 - b > 180) - b += 360; - else if (b - a2 > 180) - a2 += 360; - q.push({ i: s2.push(pop(s2) + "rotate(", null, degParen) - 2, x: interpolateNumber(a2, b) }); - } else if (b) { - s2.push(pop(s2) + "rotate(" + b + degParen); - } - } - function skewX(a2, b, s2, q) { - if (a2 !== b) { - q.push({ i: s2.push(pop(s2) + "skewX(", null, degParen) - 2, x: interpolateNumber(a2, b) }); - } else if (b) { - s2.push(pop(s2) + "skewX(" + b + degParen); - } - } - function scale(xa, ya, xb, yb, s2, q) { - if (xa !== xb || ya !== yb) { - var i = s2.push(pop(s2) + "scale(", null, ",", null, ")"); - q.push({ i: i - 4, x: interpolateNumber(xa, xb) }, { i: i - 2, x: interpolateNumber(ya, yb) }); - } else if (xb !== 1 || yb !== 1) { - s2.push(pop(s2) + "scale(" + xb + "," + yb + ")"); - } - } - return function(a2, b) { - var s2 = [], q = []; - a2 = parse2(a2), b = parse2(b); - translate(a2.translateX, a2.translateY, b.translateX, b.translateY, s2, q); - rotate(a2.rotate, b.rotate, s2, q); - skewX(a2.skewX, b.skewX, s2, q); - scale(a2.scaleX, a2.scaleY, b.scaleX, b.scaleY, s2, q); - a2 = b = null; - return function(t) { - var i = -1, n = q.length, o; - while (++i < n) - s2[(o = q[i]).i] = o.x(t); - return s2.join(""); - }; - }; - } - var interpolateTransformCss = interpolateTransform(parseCss, "px, ", "px)", "deg)"); - var interpolateTransformSvg = interpolateTransform(parseSvg, ", ", ")", ")"); - var epsilon2$1 = 1e-12; - function cosh(x2) { - return ((x2 = Math.exp(x2)) + 1 / x2) / 2; - } - function sinh(x2) { - return ((x2 = Math.exp(x2)) - 1 / x2) / 2; - } - function tanh(x2) { - return ((x2 = Math.exp(2 * x2)) - 1) / (x2 + 1); - } - const interpolateZoom = function zoomRho(rho, rho2, rho4) { - function zoom2(p02, p1) { - var ux0 = p02[0], uy0 = p02[1], w0 = p02[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 < epsilon2$1) { - S = Math.log(w1 / w0) / rho; - i = function(t) { - return [ - ux0 + t * dx, - uy0 + t * dy, - w0 * Math.exp(rho * t * S) - ]; - }; - } else { - var d1 = Math.sqrt(d2), b02 = (w1 * w1 - w0 * w0 + rho4 * d2) / (2 * w0 * rho2 * d1), b12 = (w1 * w1 - w0 * w0 - rho4 * d2) / (2 * w1 * rho2 * d1), r0 = Math.log(Math.sqrt(b02 * b02 + 1) - b02), r1 = Math.log(Math.sqrt(b12 * b12 + 1) - b12); - S = (r1 - r0) / rho; - i = function(t) { - var s2 = t * S, coshr0 = cosh(r0), u2 = w0 / (rho2 * d1) * (coshr0 * tanh(rho * s2 + r0) - sinh(r0)); - return [ - ux0 + u2 * dx, - uy0 + u2 * dy, - w0 * coshr0 / cosh(rho * s2 + r0) - ]; - }; - } - i.duration = S * 1e3 * rho / Math.SQRT2; - return i; - } - zoom2.rho = function(_2) { - var _1 = Math.max(1e-3, +_2), _22 = _1 * _1, _4 = _22 * _22; - return zoomRho(_1, _22, _4); - }; - return zoom2; - }(Math.SQRT2, 2, 4); - function hsl(hue2) { - return function(start2, end2) { - var h = hue2((start2 = hsl$2(start2)).h, (end2 = hsl$2(end2)).h), s2 = nogamma(start2.s, end2.s), l = nogamma(start2.l, end2.l), opacity = nogamma(start2.opacity, end2.opacity); - return function(t) { - start2.h = h(t); - start2.s = s2(t); - start2.l = l(t); - start2.opacity = opacity(t); - return start2 + ""; - }; - }; - } - const hsl$1 = hsl(hue$1); - var hslLong = hsl(nogamma); - function lab(start2, end2) { - var l = nogamma((start2 = lab$1(start2)).l, (end2 = lab$1(end2)).l), a2 = nogamma(start2.a, end2.a), b = nogamma(start2.b, end2.b), opacity = nogamma(start2.opacity, end2.opacity); - return function(t) { - start2.l = l(t); - start2.a = a2(t); - start2.b = b(t); - start2.opacity = opacity(t); - return start2 + ""; - }; - } - function hcl(hue2) { - return function(start2, end2) { - var h = hue2((start2 = hcl$1(start2)).h, (end2 = hcl$1(end2)).h), c2 = nogamma(start2.c, end2.c), l = nogamma(start2.l, end2.l), opacity = nogamma(start2.opacity, end2.opacity); - return function(t) { - start2.h = h(t); - start2.c = c2(t); - start2.l = l(t); - start2.opacity = opacity(t); - return start2 + ""; - }; - }; - } - const interpolateHcl = hcl(hue$1); - var hclLong = hcl(nogamma); - function cubehelix$1(hue2) { - return function cubehelixGamma(y2) { - y2 = +y2; - function cubehelix2(start2, end2) { - var h = hue2((start2 = cubehelix$3(start2)).h, (end2 = cubehelix$3(end2)).h), s2 = nogamma(start2.s, end2.s), l = nogamma(start2.l, end2.l), opacity = nogamma(start2.opacity, end2.opacity); - return function(t) { - start2.h = h(t); - start2.s = s2(t); - start2.l = l(Math.pow(t, y2)); - start2.opacity = opacity(t); - return start2 + ""; - }; - } - cubehelix2.gamma = cubehelixGamma; - return cubehelix2; - }(1); - } - const cubehelix$2 = cubehelix$1(hue$1); - var cubehelixLong = cubehelix$1(nogamma); - function piecewise(interpolate2, values) { - if (values === void 0) - values = interpolate2, interpolate2 = interpolate$2; - var i = 0, n = values.length - 1, v = values[0], I = new Array(n < 0 ? 0 : n); - while (i < n) - I[i] = interpolate2(v, v = values[++i]); - return function(t) { - var i2 = Math.max(0, Math.min(n - 1, Math.floor(t *= n))); - return I[i2](t - i2); - }; - } - function quantize$1(interpolator, n) { - var samples = new Array(n); - for (var i = 0; i < n; ++i) - samples[i] = interpolator(i / (n - 1)); - return samples; - } - var frame = 0, timeout$1 = 0, interval$1 = 0, pokeDelay = 1e3, taskHead, taskTail, clockLast = 0, clockNow = 0, clockSkew = 0, clock = typeof performance === "object" && performance.now ? performance : Date, setFrame = typeof window === "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(f) { - setTimeout(f, 17); - }; - function now() { - return clockNow || (setFrame(clearNow), clockNow = clock.now() + clockSkew); - } - function clearNow() { - clockNow = 0; - } - function Timer() { - this._call = this._time = this._next = null; - } - Timer.prototype = timer.prototype = { - constructor: Timer, - restart: function(callback, delay, time2) { - if (typeof callback !== "function") - throw new TypeError("callback is not a function"); - time2 = (time2 == null ? now() : +time2) + (delay == null ? 0 : +delay); - if (!this._next && taskTail !== this) { - if (taskTail) - taskTail._next = this; - else - taskHead = this; - taskTail = this; - } - this._call = callback; - this._time = time2; - sleep(); - }, - stop: function() { - if (this._call) { - this._call = null; - this._time = Infinity; - sleep(); - } - } - }; - function timer(callback, delay, time2) { - var t = new Timer(); - t.restart(callback, delay, time2); - return t; - } - function timerFlush() { - now(); - ++frame; - var t = taskHead, e; - while (t) { - if ((e = clockNow - t._time) >= 0) - t._call.call(void 0, e); - t = t._next; - } - --frame; - } - function wake() { - clockNow = (clockLast = clock.now()) + clockSkew; - frame = timeout$1 = 0; - try { - timerFlush(); - } finally { - frame = 0; - nap(); - clockNow = 0; - } - } - function poke() { - var now2 = clock.now(), delay = now2 - clockLast; - if (delay > pokeDelay) - clockSkew -= delay, clockLast = now2; - } - function nap() { - var t02, t12 = taskHead, t22, time2 = Infinity; - while (t12) { - if (t12._call) { - if (time2 > t12._time) - time2 = t12._time; - t02 = t12, t12 = t12._next; - } else { - t22 = t12._next, t12._next = null; - t12 = t02 ? t02._next = t22 : taskHead = t22; - } - } - taskTail = t02; - sleep(time2); - } - function sleep(time2) { - if (frame) - return; - if (timeout$1) - timeout$1 = clearTimeout(timeout$1); - var delay = time2 - clockNow; - if (delay > 24) { - if (time2 < Infinity) - timeout$1 = setTimeout(wake, time2 - clock.now() - clockSkew); - if (interval$1) - interval$1 = clearInterval(interval$1); - } else { - if (!interval$1) - clockLast = clock.now(), interval$1 = setInterval(poke, pokeDelay); - frame = 1, setFrame(wake); - } - } - function timeout(callback, delay, time2) { - var t = new Timer(); - delay = delay == null ? 0 : +delay; - t.restart((elapsed) => { - t.stop(); - callback(elapsed + delay); - }, delay, time2); - return t; - } - function interval(callback, delay, time2) { - var t = new Timer(), total = delay; - if (delay == null) - return t.restart(callback, delay, time2), t; - t._restart = t.restart; - t.restart = function(callback2, delay2, time3) { - delay2 = +delay2, time3 = time3 == null ? now() : +time3; - t._restart(function tick(elapsed) { - elapsed += total; - t._restart(tick, total += delay2, time3); - callback2(elapsed); - }, delay2, time3); - }; - t.restart(callback, delay, time2); - return t; - } - var emptyOn = dispatch("start", "end", "cancel", "interrupt"); - var emptyTween = []; - var CREATED = 0; - var SCHEDULED = 1; - var STARTING = 2; - var STARTED = 3; - var RUNNING = 4; - var ENDING = 5; - var ENDED = 6; - function schedule(node2, name2, id2, index2, group2, timing) { - var schedules = node2.__transition; - if (!schedules) - node2.__transition = {}; - else if (id2 in schedules) - return; - create$1(node2, id2, { - name: name2, - index: index2, - group: group2, - on: emptyOn, - tween: emptyTween, - time: timing.time, - delay: timing.delay, - duration: timing.duration, - ease: timing.ease, - timer: null, - state: CREATED - }); - } - function init$1(node2, id2) { - var schedule2 = get(node2, id2); - if (schedule2.state > CREATED) - throw new Error("too late; already scheduled"); - return schedule2; - } - function set(node2, id2) { - var schedule2 = get(node2, id2); - if (schedule2.state > STARTED) - throw new Error("too late; already running"); - return schedule2; - } - function get(node2, id2) { - var schedule2 = node2.__transition; - if (!schedule2 || !(schedule2 = schedule2[id2])) - throw new Error("transition not found"); - return schedule2; - } - function create$1(node2, id2, self2) { - var schedules = node2.__transition, tween; - schedules[id2] = self2; - self2.timer = timer(schedule2, 0, self2.time); - function schedule2(elapsed) { - self2.state = SCHEDULED; - self2.timer.restart(start2, self2.delay, self2.time); - if (self2.delay <= elapsed) - start2(elapsed - self2.delay); - } - function start2(elapsed) { - var i, j, n, o; - if (self2.state !== SCHEDULED) - return stop(); - for (i in schedules) { - o = schedules[i]; - if (o.name !== self2.name) - continue; - if (o.state === STARTED) - return timeout(start2); - if (o.state === RUNNING) { - o.state = ENDED; - o.timer.stop(); - o.on.call("interrupt", node2, node2.__data__, o.index, o.group); - delete schedules[i]; - } else if (+i < id2) { - o.state = ENDED; - o.timer.stop(); - o.on.call("cancel", node2, node2.__data__, o.index, o.group); - delete schedules[i]; - } - } - timeout(function() { - if (self2.state === STARTED) { - self2.state = RUNNING; - self2.timer.restart(tick, self2.delay, self2.time); - tick(elapsed); - } - }); - self2.state = STARTING; - self2.on.call("start", node2, node2.__data__, self2.index, self2.group); - if (self2.state !== STARTING) - return; - self2.state = STARTED; - tween = new Array(n = self2.tween.length); - for (i = 0, j = -1; i < n; ++i) { - if (o = self2.tween[i].value.call(node2, node2.__data__, self2.index, self2.group)) { - tween[++j] = o; - } - } - tween.length = j + 1; - } - function tick(elapsed) { - var t = elapsed < self2.duration ? self2.ease.call(null, elapsed / self2.duration) : (self2.timer.restart(stop), self2.state = ENDING, 1), i = -1, n = tween.length; - while (++i < n) { - tween[i].call(node2, t); - } - if (self2.state === ENDING) { - self2.on.call("end", node2, node2.__data__, self2.index, self2.group); - stop(); - } - } - function stop() { - self2.state = ENDED; - self2.timer.stop(); - delete schedules[id2]; - for (var i in schedules) - return; - delete node2.__transition; - } - } - function interrupt(node2, name2) { - var schedules = node2.__transition, schedule2, active2, empty2 = true, i; - if (!schedules) - return; - name2 = name2 == null ? null : name2 + ""; - for (i in schedules) { - if ((schedule2 = schedules[i]).name !== name2) { - empty2 = false; - continue; - } - active2 = schedule2.state > STARTING && schedule2.state < ENDING; - schedule2.state = ENDED; - schedule2.timer.stop(); - schedule2.on.call(active2 ? "interrupt" : "cancel", node2, node2.__data__, schedule2.index, schedule2.group); - delete schedules[i]; - } - if (empty2) - delete node2.__transition; - } - function selection_interrupt(name2) { - return this.each(function() { - interrupt(this, name2); - }); - } - function tweenRemove(id2, name2) { - var tween0, tween1; - return function() { - var schedule2 = set(this, id2), tween = schedule2.tween; - if (tween !== tween0) { - tween1 = tween0 = tween; - for (var i = 0, n = tween1.length; i < n; ++i) { - if (tween1[i].name === name2) { - tween1 = tween1.slice(); - tween1.splice(i, 1); - break; - } - } - } - schedule2.tween = tween1; - }; - } - function tweenFunction(id2, name2, value) { - var tween0, tween1; - if (typeof value !== "function") - throw new Error(); - return function() { - var schedule2 = set(this, id2), tween = schedule2.tween; - if (tween !== tween0) { - tween1 = (tween0 = tween).slice(); - for (var t = { name: name2, value }, i = 0, n = tween1.length; i < n; ++i) { - if (tween1[i].name === name2) { - tween1[i] = t; - break; - } - } - if (i === n) - tween1.push(t); - } - schedule2.tween = tween1; - }; - } - function transition_tween(name2, value) { - var id2 = this._id; - name2 += ""; - if (arguments.length < 2) { - var tween = get(this.node(), id2).tween; - for (var i = 0, n = tween.length, t; i < n; ++i) { - if ((t = tween[i]).name === name2) { - return t.value; - } - } - return null; - } - return this.each((value == null ? tweenRemove : tweenFunction)(id2, name2, value)); - } - function tweenValue(transition2, name2, value) { - var id2 = transition2._id; - transition2.each(function() { - var schedule2 = set(this, id2); - (schedule2.value || (schedule2.value = {}))[name2] = value.apply(this, arguments); - }); - return function(node2) { - return get(node2, id2).value[name2]; - }; - } - function interpolate$1(a2, b) { - var c2; - return (typeof b === "number" ? interpolateNumber : b instanceof color ? interpolateRgb : (c2 = color(b)) ? (b = c2, interpolateRgb) : interpolateString)(a2, b); - } - function attrRemove(name2) { - return function() { - this.removeAttribute(name2); - }; - } - function attrRemoveNS(fullname) { - return function() { - this.removeAttributeNS(fullname.space, fullname.local); - }; - } - function attrConstant(name2, interpolate2, value1) { - var string00, string1 = value1 + "", interpolate0; - return function() { - var string0 = this.getAttribute(name2); - return string0 === string1 ? null : string0 === string00 ? interpolate0 : interpolate0 = interpolate2(string00 = string0, value1); - }; - } - function attrConstantNS(fullname, interpolate2, value1) { - var string00, string1 = value1 + "", interpolate0; - return function() { - var string0 = this.getAttributeNS(fullname.space, fullname.local); - return string0 === string1 ? null : string0 === string00 ? interpolate0 : interpolate0 = interpolate2(string00 = string0, value1); - }; - } - function attrFunction(name2, interpolate2, value) { - var string00, string10, interpolate0; - return function() { - var string0, value1 = value(this), string1; - if (value1 == null) - return void this.removeAttribute(name2); - string0 = this.getAttribute(name2); - string1 = value1 + ""; - return string0 === string1 ? null : string0 === string00 && string1 === string10 ? interpolate0 : (string10 = string1, interpolate0 = interpolate2(string00 = string0, value1)); - }; - } - function attrFunctionNS(fullname, interpolate2, value) { - var string00, string10, interpolate0; - return function() { - var string0, value1 = value(this), string1; - if (value1 == null) - return void this.removeAttributeNS(fullname.space, fullname.local); - string0 = this.getAttributeNS(fullname.space, fullname.local); - string1 = value1 + ""; - return string0 === string1 ? null : string0 === string00 && string1 === string10 ? interpolate0 : (string10 = string1, interpolate0 = interpolate2(string00 = string0, value1)); - }; - } - function transition_attr(name2, value) { - var fullname = namespace(name2), i = fullname === "transform" ? interpolateTransformSvg : interpolate$1; - return this.attrTween(name2, typeof value === "function" ? (fullname.local ? attrFunctionNS : attrFunction)(fullname, i, tweenValue(this, "attr." + name2, value)) : value == null ? (fullname.local ? attrRemoveNS : attrRemove)(fullname) : (fullname.local ? attrConstantNS : attrConstant)(fullname, i, value)); - } - function attrInterpolate(name2, i) { - return function(t) { - this.setAttribute(name2, i.call(this, t)); - }; - } - function attrInterpolateNS(fullname, i) { - return function(t) { - this.setAttributeNS(fullname.space, fullname.local, i.call(this, t)); - }; - } - function attrTweenNS(fullname, value) { - var t02, i0; - function tween() { - var i = value.apply(this, arguments); - if (i !== i0) - t02 = (i0 = i) && attrInterpolateNS(fullname, i); - return t02; - } - tween._value = value; - return tween; - } - function attrTween(name2, value) { - var t02, i0; - function tween() { - var i = value.apply(this, arguments); - if (i !== i0) - t02 = (i0 = i) && attrInterpolate(name2, i); - return t02; - } - tween._value = value; - return tween; - } - function transition_attrTween(name2, value) { - var key = "attr." + name2; - if (arguments.length < 2) - return (key = this.tween(key)) && key._value; - if (value == null) - return this.tween(key, null); - if (typeof value !== "function") - throw new Error(); - var fullname = namespace(name2); - return this.tween(key, (fullname.local ? attrTweenNS : attrTween)(fullname, value)); - } - function delayFunction(id2, value) { - return function() { - init$1(this, id2).delay = +value.apply(this, arguments); - }; - } - function delayConstant(id2, value) { - return value = +value, function() { - init$1(this, id2).delay = value; - }; - } - function transition_delay(value) { - var id2 = this._id; - return arguments.length ? this.each((typeof value === "function" ? delayFunction : delayConstant)(id2, value)) : get(this.node(), id2).delay; - } - function durationFunction(id2, value) { - return function() { - set(this, id2).duration = +value.apply(this, arguments); - }; - } - function durationConstant(id2, value) { - return value = +value, function() { - set(this, id2).duration = value; - }; - } - function transition_duration(value) { - var id2 = this._id; - return arguments.length ? this.each((typeof value === "function" ? durationFunction : durationConstant)(id2, value)) : get(this.node(), id2).duration; - } - function easeConstant(id2, value) { - if (typeof value !== "function") - throw new Error(); - return function() { - set(this, id2).ease = value; - }; - } - function transition_ease(value) { - var id2 = this._id; - return arguments.length ? this.each(easeConstant(id2, value)) : get(this.node(), id2).ease; - } - function easeVarying(id2, value) { - return function() { - var v = value.apply(this, arguments); - if (typeof v !== "function") - throw new Error(); - set(this, id2).ease = v; - }; - } - function transition_easeVarying(value) { - if (typeof value !== "function") - throw new Error(); - return this.each(easeVarying(this._id, value)); - } - function transition_filter(match) { - if (typeof match !== "function") - match = matcher(match); - for (var groups2 = this._groups, m2 = groups2.length, subgroups = new Array(m2), j = 0; j < m2; ++j) { - for (var group2 = groups2[j], n = group2.length, subgroup = subgroups[j] = [], node2, i = 0; i < n; ++i) { - if ((node2 = group2[i]) && match.call(node2, node2.__data__, i, group2)) { - subgroup.push(node2); - } - } - } - return new Transition(subgroups, this._parents, this._name, this._id); - } - function transition_merge(transition2) { - if (transition2._id !== this._id) - throw new Error(); - for (var groups0 = this._groups, groups1 = transition2._groups, m0 = groups0.length, m1 = groups1.length, m2 = Math.min(m0, m1), merges = new Array(m0), j = 0; j < m2; ++j) { - for (var group0 = groups0[j], group1 = groups1[j], n = group0.length, merge2 = merges[j] = new Array(n), node2, i = 0; i < n; ++i) { - if (node2 = group0[i] || group1[i]) { - merge2[i] = node2; - } - } - } - for (; j < m0; ++j) { - merges[j] = groups0[j]; - } - return new Transition(merges, this._parents, this._name, this._id); - } - function start$1(name2) { - return (name2 + "").trim().split(/^|\s+/).every(function(t) { - var i = t.indexOf("."); - if (i >= 0) - t = t.slice(0, i); - return !t || t === "start"; - }); - } - function onFunction(id2, name2, listener) { - var on0, on1, sit = start$1(name2) ? init$1 : set; - return function() { - var schedule2 = sit(this, id2), on = schedule2.on; - if (on !== on0) - (on1 = (on0 = on).copy()).on(name2, listener); - schedule2.on = on1; - }; - } - function transition_on(name2, listener) { - var id2 = this._id; - return arguments.length < 2 ? get(this.node(), id2).on.on(name2) : this.each(onFunction(id2, name2, listener)); - } - function removeFunction(id2) { - return function() { - var parent = this.parentNode; - for (var i in this.__transition) - if (+i !== id2) - return; - if (parent) - parent.removeChild(this); - }; - } - function transition_remove() { - return this.on("end.remove", removeFunction(this._id)); - } - function transition_select(select2) { - var name2 = this._name, id2 = this._id; - if (typeof select2 !== "function") - select2 = selector(select2); - for (var groups2 = this._groups, m2 = groups2.length, subgroups = new Array(m2), j = 0; j < m2; ++j) { - for (var group2 = groups2[j], n = group2.length, subgroup = subgroups[j] = new Array(n), node2, subnode, i = 0; i < n; ++i) { - if ((node2 = group2[i]) && (subnode = select2.call(node2, node2.__data__, i, group2))) { - if ("__data__" in node2) - subnode.__data__ = node2.__data__; - subgroup[i] = subnode; - schedule(subgroup[i], name2, id2, i, subgroup, get(node2, id2)); - } - } - } - return new Transition(subgroups, this._parents, name2, id2); - } - function transition_selectAll(select2) { - var name2 = this._name, id2 = this._id; - if (typeof select2 !== "function") - select2 = selectorAll(select2); - for (var groups2 = this._groups, m2 = groups2.length, subgroups = [], parents2 = [], j = 0; j < m2; ++j) { - for (var group2 = groups2[j], n = group2.length, node2, i = 0; i < n; ++i) { - if (node2 = group2[i]) { - for (var children2 = select2.call(node2, node2.__data__, i, group2), child, inherit2 = get(node2, id2), k2 = 0, l = children2.length; k2 < l; ++k2) { - if (child = children2[k2]) { - schedule(child, name2, id2, k2, children2, inherit2); - } - } - subgroups.push(children2); - parents2.push(node2); - } - } - } - return new Transition(subgroups, parents2, name2, id2); - } - var Selection = selection.prototype.constructor; - function transition_selection() { - return new Selection(this._groups, this._parents); - } - function styleNull(name2, interpolate2) { - var string00, string10, interpolate0; - return function() { - var string0 = styleValue(this, name2), string1 = (this.style.removeProperty(name2), styleValue(this, name2)); - return string0 === string1 ? null : string0 === string00 && string1 === string10 ? interpolate0 : interpolate0 = interpolate2(string00 = string0, string10 = string1); - }; - } - function styleRemove(name2) { - return function() { - this.style.removeProperty(name2); - }; - } - function styleConstant(name2, interpolate2, value1) { - var string00, string1 = value1 + "", interpolate0; - return function() { - var string0 = styleValue(this, name2); - return string0 === string1 ? null : string0 === string00 ? interpolate0 : interpolate0 = interpolate2(string00 = string0, value1); - }; - } - function styleFunction(name2, interpolate2, value) { - var string00, string10, interpolate0; - return function() { - var string0 = styleValue(this, name2), value1 = value(this), string1 = value1 + ""; - if (value1 == null) - string1 = value1 = (this.style.removeProperty(name2), styleValue(this, name2)); - return string0 === string1 ? null : string0 === string00 && string1 === string10 ? interpolate0 : (string10 = string1, interpolate0 = interpolate2(string00 = string0, value1)); - }; - } - function styleMaybeRemove(id2, name2) { - var on0, on1, listener0, key = "style." + name2, event = "end." + key, remove2; - return function() { - var schedule2 = set(this, id2), on = schedule2.on, listener = schedule2.value[key] == null ? remove2 || (remove2 = styleRemove(name2)) : void 0; - if (on !== on0 || listener0 !== listener) - (on1 = (on0 = on).copy()).on(event, listener0 = listener); - schedule2.on = on1; - }; - } - function transition_style(name2, value, priority) { - var i = (name2 += "") === "transform" ? interpolateTransformCss : interpolate$1; - return value == null ? this.styleTween(name2, styleNull(name2, i)).on("end.style." + name2, styleRemove(name2)) : typeof value === "function" ? this.styleTween(name2, styleFunction(name2, i, tweenValue(this, "style." + name2, value))).each(styleMaybeRemove(this._id, name2)) : this.styleTween(name2, styleConstant(name2, i, value), priority).on("end.style." + name2, null); - } - function styleInterpolate(name2, i, priority) { - return function(t) { - this.style.setProperty(name2, i.call(this, t), priority); - }; - } - function styleTween(name2, value, priority) { - var t, i0; - function tween() { - var i = value.apply(this, arguments); - if (i !== i0) - t = (i0 = i) && styleInterpolate(name2, i, priority); - return t; - } - tween._value = value; - return tween; - } - function transition_styleTween(name2, value, priority) { - var key = "style." + (name2 += ""); - if (arguments.length < 2) - return (key = this.tween(key)) && key._value; - if (value == null) - return this.tween(key, null); - if (typeof value !== "function") - throw new Error(); - return this.tween(key, styleTween(name2, value, priority == null ? "" : priority)); - } - function textConstant(value) { - return function() { - this.textContent = value; - }; - } - function textFunction(value) { - return function() { - var value1 = value(this); - this.textContent = value1 == null ? "" : value1; - }; - } - function transition_text(value) { - return this.tween("text", typeof value === "function" ? textFunction(tweenValue(this, "text", value)) : textConstant(value == null ? "" : value + "")); - } - function textInterpolate(i) { - return function(t) { - this.textContent = i.call(this, t); - }; - } - function textTween(value) { - var t02, i0; - function tween() { - var i = value.apply(this, arguments); - if (i !== i0) - t02 = (i0 = i) && textInterpolate(i); - return t02; - } - tween._value = value; - return tween; - } - function transition_textTween(value) { - var key = "text"; - if (arguments.length < 1) - return (key = this.tween(key)) && key._value; - if (value == null) - return this.tween(key, null); - if (typeof value !== "function") - throw new Error(); - return this.tween(key, textTween(value)); - } - function transition_transition() { - var name2 = this._name, id0 = this._id, id1 = newId(); - for (var groups2 = this._groups, m2 = groups2.length, j = 0; j < m2; ++j) { - for (var group2 = groups2[j], n = group2.length, node2, i = 0; i < n; ++i) { - if (node2 = group2[i]) { - var inherit2 = get(node2, id0); - schedule(node2, name2, id1, i, group2, { - time: inherit2.time + inherit2.delay + inherit2.duration, - delay: 0, - duration: inherit2.duration, - ease: inherit2.ease - }); - } - } - } - return new Transition(groups2, this._parents, name2, id1); - } - function transition_end() { - var on0, on1, that = this, id2 = that._id, size = that.size(); - return new Promise(function(resolve, reject) { - var cancel = { value: reject }, end2 = { value: function() { - if (--size === 0) - resolve(); - } }; - that.each(function() { - var schedule2 = set(this, id2), on = schedule2.on; - if (on !== on0) { - on1 = (on0 = on).copy(); - on1._.cancel.push(cancel); - on1._.interrupt.push(cancel); - on1._.end.push(end2); - } - schedule2.on = on1; - }); - if (size === 0) - resolve(); - }); - } - var id = 0; - function Transition(groups2, parents2, name2, id2) { - this._groups = groups2; - this._parents = parents2; - this._name = name2; - this._id = id2; - } - function transition(name2) { - return selection().transition(name2); - } - function newId() { - return ++id; - } - var selection_prototype = selection.prototype; - Transition.prototype = transition.prototype = { - constructor: Transition, - select: transition_select, - selectAll: transition_selectAll, - selectChild: selection_prototype.selectChild, - selectChildren: selection_prototype.selectChildren, - filter: transition_filter, - merge: transition_merge, - selection: transition_selection, - transition: transition_transition, - call: selection_prototype.call, - nodes: selection_prototype.nodes, - node: selection_prototype.node, - size: selection_prototype.size, - empty: selection_prototype.empty, - each: selection_prototype.each, - on: transition_on, - attr: transition_attr, - attrTween: transition_attrTween, - style: transition_style, - styleTween: transition_styleTween, - text: transition_text, - textTween: transition_textTween, - remove: transition_remove, - tween: transition_tween, - delay: transition_delay, - duration: transition_duration, - ease: transition_ease, - easeVarying: transition_easeVarying, - end: transition_end, - [Symbol.iterator]: selection_prototype[Symbol.iterator] - }; - const linear$1 = (t) => +t; - function quadIn(t) { - return t * t; - } - function quadOut(t) { - return t * (2 - t); - } - function quadInOut(t) { - return ((t *= 2) <= 1 ? t * t : --t * (2 - t) + 1) / 2; - } - function cubicIn(t) { - return t * t * t; - } - function cubicOut(t) { - return --t * t * t + 1; - } - function cubicInOut(t) { - return ((t *= 2) <= 1 ? t * t * t : (t -= 2) * t * t + 2) / 2; - } - var exponent$1 = 3; - var polyIn = function custom(e) { - e = +e; - function polyIn2(t) { - return Math.pow(t, e); - } - polyIn2.exponent = custom; - return polyIn2; - }(exponent$1); - var polyOut = function custom(e) { - e = +e; - function polyOut2(t) { - return 1 - Math.pow(1 - t, e); - } - polyOut2.exponent = custom; - return polyOut2; - }(exponent$1); - var polyInOut = function custom(e) { - e = +e; - function polyInOut2(t) { - return ((t *= 2) <= 1 ? Math.pow(t, e) : 2 - Math.pow(2 - t, e)) / 2; - } - polyInOut2.exponent = custom; - return polyInOut2; - }(exponent$1); - var pi$4 = Math.PI, halfPi$3 = pi$4 / 2; - function sinIn(t) { - return +t === 1 ? 1 : 1 - Math.cos(t * halfPi$3); - } - function sinOut(t) { - return Math.sin(t * halfPi$3); - } - function sinInOut(t) { - return (1 - Math.cos(pi$4 * t)) / 2; - } - function tpmt(x2) { - return (Math.pow(2, -10 * x2) - 9765625e-10) * 1.0009775171065494; - } - function expIn(t) { - return tpmt(1 - +t); - } - function expOut(t) { - return 1 - tpmt(t); - } - function expInOut(t) { - return ((t *= 2) <= 1 ? tpmt(1 - t) : 2 - tpmt(t - 1)) / 2; - } - function circleIn(t) { - return 1 - Math.sqrt(1 - t * t); - } - function circleOut(t) { - return Math.sqrt(1 - --t * t); - } - function circleInOut(t) { - return ((t *= 2) <= 1 ? 1 - Math.sqrt(1 - t * t) : Math.sqrt(1 - (t -= 2) * t) + 1) / 2; - } - var b1 = 4 / 11, b2 = 6 / 11, b3 = 8 / 11, b4 = 3 / 4, b5 = 9 / 11, b6 = 10 / 11, b7 = 15 / 16, b8 = 21 / 22, b9 = 63 / 64, b0 = 1 / b1 / b1; - function bounceIn(t) { - return 1 - bounceOut(1 - t); - } - function bounceOut(t) { - return (t = +t) < b1 ? b0 * t * t : t < b3 ? b0 * (t -= b2) * t + b4 : t < b6 ? b0 * (t -= b5) * t + b7 : b0 * (t -= b8) * t + b9; - } - function bounceInOut(t) { - return ((t *= 2) <= 1 ? 1 - bounceOut(1 - t) : bounceOut(t - 1) + 1) / 2; - } - var overshoot = 1.70158; - var backIn = function custom(s2) { - s2 = +s2; - function backIn2(t) { - return (t = +t) * t * (s2 * (t - 1) + t); - } - backIn2.overshoot = custom; - return backIn2; - }(overshoot); - var backOut = function custom(s2) { - s2 = +s2; - function backOut2(t) { - return --t * t * ((t + 1) * s2 + t) + 1; - } - backOut2.overshoot = custom; - return backOut2; - }(overshoot); - var backInOut = function custom(s2) { - s2 = +s2; - function backInOut2(t) { - return ((t *= 2) < 1 ? t * t * ((s2 + 1) * t - s2) : (t -= 2) * t * ((s2 + 1) * t + s2) + 2) / 2; - } - backInOut2.overshoot = custom; - return backInOut2; - }(overshoot); - var tau$5 = 2 * Math.PI, amplitude = 1, period = 0.3; - var elasticIn = function custom(a2, p) { - var s2 = Math.asin(1 / (a2 = Math.max(1, a2))) * (p /= tau$5); - function elasticIn2(t) { - return a2 * tpmt(- --t) * Math.sin((s2 - t) / p); - } - elasticIn2.amplitude = function(a3) { - return custom(a3, p * tau$5); - }; - elasticIn2.period = function(p2) { - return custom(a2, p2); - }; - return elasticIn2; - }(amplitude, period); - var elasticOut = function custom(a2, p) { - var s2 = Math.asin(1 / (a2 = Math.max(1, a2))) * (p /= tau$5); - function elasticOut2(t) { - return 1 - a2 * tpmt(t = +t) * Math.sin((t + s2) / p); - } - elasticOut2.amplitude = function(a3) { - return custom(a3, p * tau$5); - }; - elasticOut2.period = function(p2) { - return custom(a2, p2); - }; - return elasticOut2; - }(amplitude, period); - var elasticInOut = function custom(a2, p) { - var s2 = Math.asin(1 / (a2 = Math.max(1, a2))) * (p /= tau$5); - function elasticInOut2(t) { - return ((t = t * 2 - 1) < 0 ? a2 * tpmt(-t) * Math.sin((s2 - t) / p) : 2 - a2 * tpmt(t) * Math.sin((s2 + t) / p)) / 2; - } - elasticInOut2.amplitude = function(a3) { - return custom(a3, p * tau$5); - }; - elasticInOut2.period = function(p2) { - return custom(a2, p2); - }; - return elasticInOut2; - }(amplitude, period); - var defaultTiming = { - time: null, - delay: 0, - duration: 250, - ease: cubicInOut - }; - function inherit(node2, id2) { - var timing; - while (!(timing = node2.__transition) || !(timing = timing[id2])) { - if (!(node2 = node2.parentNode)) { - throw new Error(`transition ${id2} not found`); - } - } - return timing; - } - function selection_transition(name2) { - var id2, timing; - if (name2 instanceof Transition) { - id2 = name2._id, name2 = name2._name; - } else { - id2 = newId(), (timing = defaultTiming).time = now(), name2 = name2 == null ? null : name2 + ""; - } - for (var groups2 = this._groups, m2 = groups2.length, j = 0; j < m2; ++j) { - for (var group2 = groups2[j], n = group2.length, node2, i = 0; i < n; ++i) { - if (node2 = group2[i]) { - schedule(node2, name2, id2, i, group2, timing || inherit(node2, id2)); - } - } - } - return new Transition(groups2, this._parents, name2, id2); - } - selection.prototype.interrupt = selection_interrupt; - selection.prototype.transition = selection_transition; - var root$3 = [null]; - function active(node2, name2) { - var schedules = node2.__transition, schedule2, i; - if (schedules) { - name2 = name2 == null ? null : name2 + ""; - for (i in schedules) { - if ((schedule2 = schedules[i]).state > SCHEDULED && schedule2.name === name2) { - return new Transition([[node2]], root$3, name2, +i); - } - } - } - return null; - } - const constant$7 = (x2) => () => x2; - function BrushEvent(type2, { - sourceEvent: sourceEvent2, - target, - selection: selection2, - mode: mode2, - dispatch: dispatch2 - }) { - Object.defineProperties(this, { - type: { value: type2, enumerable: true, configurable: true }, - sourceEvent: { value: sourceEvent2, enumerable: true, configurable: true }, - target: { value: target, enumerable: true, configurable: true }, - selection: { value: selection2, enumerable: true, configurable: true }, - mode: { value: mode2, enumerable: true, configurable: true }, - _: { value: dispatch2 } - }); - } - function nopropagation$1(event) { - event.stopImmediatePropagation(); - } - function noevent$1(event) { - event.preventDefault(); - event.stopImmediatePropagation(); - } - var MODE_DRAG = { name: "drag" }, MODE_SPACE = { name: "space" }, MODE_HANDLE = { name: "handle" }, MODE_CENTER = { name: "center" }; - const { abs: abs$4, max: max$2, min: min$1 } = Math; - function number1(e) { - return [+e[0], +e[1]]; - } - function number2(e) { - return [number1(e[0]), number1(e[1])]; - } - var X = { - name: "x", - handles: ["w", "e"].map(type$1), - input: function(x2, e) { - return x2 == null ? null : [[+x2[0], e[0][1]], [+x2[1], e[1][1]]]; - }, - output: function(xy) { - return xy && [xy[0][0], xy[1][0]]; - } - }; - var Y = { - name: "y", - handles: ["n", "s"].map(type$1), - input: function(y2, e) { - return y2 == null ? null : [[e[0][0], +y2[0]], [e[1][0], +y2[1]]]; - }, - output: function(xy) { - return xy && [xy[0][1], xy[1][1]]; - } - }; - var XY = { - name: "xy", - handles: ["n", "w", "e", "s", "nw", "ne", "sw", "se"].map(type$1), - input: function(xy) { - return xy == null ? null : number2(xy); - }, - output: function(xy) { - return xy; - } - }; - var cursors = { - overlay: "crosshair", - selection: "move", - n: "ns-resize", - e: "ew-resize", - s: "ns-resize", - w: "ew-resize", - nw: "nwse-resize", - ne: "nesw-resize", - se: "nwse-resize", - sw: "nesw-resize" - }; - var flipX = { - e: "w", - w: "e", - nw: "ne", - ne: "nw", - se: "sw", - sw: "se" - }; - var flipY = { - n: "s", - s: "n", - nw: "sw", - ne: "se", - se: "ne", - sw: "nw" - }; - var signsX = { - overlay: 1, - selection: 1, - n: null, - e: 1, - s: null, - w: -1, - nw: -1, - ne: 1, - se: 1, - sw: -1 - }; - var signsY = { - overlay: 1, - selection: 1, - n: -1, - e: null, - s: 1, - w: null, - nw: -1, - ne: -1, - se: 1, - sw: 1 - }; - function type$1(t) { - return { type: t }; - } - function defaultFilter$1(event) { - return !event.ctrlKey && !event.button; - } - function defaultExtent$1() { - var svg2 = this.ownerSVGElement || this; - if (svg2.hasAttribute("viewBox")) { - svg2 = svg2.viewBox.baseVal; - return [[svg2.x, svg2.y], [svg2.x + svg2.width, svg2.y + svg2.height]]; - } - return [[0, 0], [svg2.width.baseVal.value, svg2.height.baseVal.value]]; - } - function defaultTouchable$1() { - return navigator.maxTouchPoints || "ontouchstart" in this; - } - function local(node2) { - while (!node2.__brush) - if (!(node2 = node2.parentNode)) - return; - return node2.__brush; - } - function empty(extent2) { - return extent2[0][0] === extent2[1][0] || extent2[0][1] === extent2[1][1]; - } - function brushSelection(node2) { - var state = node2.__brush; - return state ? state.dim.output(state.selection) : null; - } - function brushX() { - return brush$1(X); - } - function brushY() { - return brush$1(Y); - } - function brush() { - return brush$1(XY); - } - function brush$1(dim) { - var extent2 = defaultExtent$1, filter2 = defaultFilter$1, touchable = defaultTouchable$1, keys = true, listeners = dispatch("start", "brush", "end"), handleSize = 6, touchending; - function brush2(group2) { - var overlay = group2.property("__brush", initialize2).selectAll(".overlay").data([type$1("overlay")]); - overlay.enter().append("rect").attr("class", "overlay").attr("pointer-events", "all").attr("cursor", cursors.overlay).merge(overlay).each(function() { - var extent3 = local(this).extent; - select(this).attr("x", extent3[0][0]).attr("y", extent3[0][1]).attr("width", extent3[1][0] - extent3[0][0]).attr("height", extent3[1][1] - extent3[0][1]); - }); - group2.selectAll(".selection").data([type$1("selection")]).enter().append("rect").attr("class", "selection").attr("cursor", cursors.selection).attr("fill", "#777").attr("fill-opacity", 0.3).attr("stroke", "#fff").attr("shape-rendering", "crispEdges"); - var handle = group2.selectAll(".handle").data(dim.handles, function(d) { - return d.type; - }); - handle.exit().remove(); - handle.enter().append("rect").attr("class", function(d) { - return "handle handle--" + d.type; - }).attr("cursor", function(d) { - return cursors[d.type]; - }); - group2.each(redraw).attr("fill", "none").attr("pointer-events", "all").on("mousedown.brush", started).filter(touchable).on("touchstart.brush", started).on("touchmove.brush", touchmoved).on("touchend.brush touchcancel.brush", touchended).style("touch-action", "none").style("-webkit-tap-highlight-color", "rgba(0,0,0,0)"); - } - brush2.move = function(group2, selection2, event) { - if (group2.tween) { - group2.on("start.brush", function(event2) { - emitter(this, arguments).beforestart().start(event2); - }).on("interrupt.brush end.brush", function(event2) { - emitter(this, arguments).end(event2); - }).tween("brush", function() { - var that = this, state = that.__brush, emit = emitter(that, arguments), selection0 = state.selection, selection1 = dim.input(typeof selection2 === "function" ? selection2.apply(this, arguments) : selection2, state.extent), i = interpolate$2(selection0, selection1); - function tween(t) { - state.selection = t === 1 && selection1 === null ? null : i(t); - redraw.call(that); - emit.brush(); - } - return selection0 !== null && selection1 !== null ? tween : tween(1); - }); - } else { - group2.each(function() { - var that = this, args = arguments, state = that.__brush, selection1 = dim.input(typeof selection2 === "function" ? selection2.apply(that, args) : selection2, state.extent), emit = emitter(that, args).beforestart(); - interrupt(that); - state.selection = selection1 === null ? null : selection1; - redraw.call(that); - emit.start(event).brush(event).end(event); - }); - } - }; - brush2.clear = function(group2, event) { - brush2.move(group2, null, event); - }; - function redraw() { - var group2 = select(this), selection2 = local(this).selection; - if (selection2) { - group2.selectAll(".selection").style("display", null).attr("x", selection2[0][0]).attr("y", selection2[0][1]).attr("width", selection2[1][0] - selection2[0][0]).attr("height", selection2[1][1] - selection2[0][1]); - group2.selectAll(".handle").style("display", null).attr("x", function(d) { - return d.type[d.type.length - 1] === "e" ? selection2[1][0] - handleSize / 2 : selection2[0][0] - handleSize / 2; - }).attr("y", function(d) { - return d.type[0] === "s" ? selection2[1][1] - handleSize / 2 : selection2[0][1] - handleSize / 2; - }).attr("width", function(d) { - return d.type === "n" || d.type === "s" ? selection2[1][0] - selection2[0][0] + handleSize : handleSize; - }).attr("height", function(d) { - return d.type === "e" || d.type === "w" ? selection2[1][1] - selection2[0][1] + handleSize : handleSize; - }); - } else { - group2.selectAll(".selection,.handle").style("display", "none").attr("x", null).attr("y", null).attr("width", null).attr("height", null); - } - } - function emitter(that, args, clean) { - var emit = that.__brush.emitter; - return emit && (!clean || !emit.clean) ? emit : new Emitter(that, args, clean); - } - function Emitter(that, args, clean) { - this.that = that; - this.args = args; - this.state = that.__brush; - this.active = 0; - this.clean = clean; - } - Emitter.prototype = { - beforestart: function() { - if (++this.active === 1) - this.state.emitter = this, this.starting = true; - return this; - }, - start: function(event, mode2) { - if (this.starting) - this.starting = false, this.emit("start", event, mode2); - else - this.emit("brush", event); - return this; - }, - brush: function(event, mode2) { - this.emit("brush", event, mode2); - return this; - }, - end: function(event, mode2) { - if (--this.active === 0) - delete this.state.emitter, this.emit("end", event, mode2); - return this; - }, - emit: function(type2, event, mode2) { - var d = select(this.that).datum(); - listeners.call( - type2, - this.that, - new BrushEvent(type2, { - sourceEvent: event, - target: brush2, - selection: dim.output(this.state.selection), - mode: mode2, - dispatch: listeners - }), - d - ); - } - }; - function started(event) { - if (touchending && !event.touches) - return; - if (!filter2.apply(this, arguments)) - return; - var that = this, type2 = event.target.__data__.type, mode2 = (keys && event.metaKey ? type2 = "overlay" : type2) === "selection" ? MODE_DRAG : keys && event.altKey ? MODE_CENTER : MODE_HANDLE, signX = dim === Y ? null : signsX[type2], signY = dim === X ? null : signsY[type2], state = local(that), extent3 = state.extent, selection2 = state.selection, W = extent3[0][0], w0, w1, N = extent3[0][1], n0, n1, E2 = extent3[1][0], e0, e1, S = extent3[1][1], s0, s1, dx = 0, dy = 0, moving, shifting = signX && signY && keys && event.shiftKey, lockX, lockY, points = Array.from(event.touches || [event], (t) => { - const i = t.identifier; - t = pointer(t, that); - t.point0 = t.slice(); - t.identifier = i; - return t; - }); - interrupt(that); - var emit = emitter(that, arguments, true).beforestart(); - if (type2 === "overlay") { - if (selection2) - moving = true; - const pts = [points[0], points[1] || points[0]]; - state.selection = selection2 = [[ - w0 = dim === Y ? W : min$1(pts[0][0], pts[1][0]), - n0 = dim === X ? N : min$1(pts[0][1], pts[1][1]) - ], [ - e0 = dim === Y ? E2 : max$2(pts[0][0], pts[1][0]), - s0 = dim === X ? S : max$2(pts[0][1], pts[1][1]) - ]]; - if (points.length > 1) - move(event); - } else { - w0 = selection2[0][0]; - n0 = selection2[0][1]; - e0 = selection2[1][0]; - s0 = selection2[1][1]; - } - w1 = w0; - n1 = n0; - e1 = e0; - s1 = s0; - var group2 = select(that).attr("pointer-events", "none"); - var overlay = group2.selectAll(".overlay").attr("cursor", cursors[type2]); - if (event.touches) { - emit.moved = moved; - emit.ended = ended; - } else { - var view = select(event.view).on("mousemove.brush", moved, true).on("mouseup.brush", ended, true); - if (keys) - view.on("keydown.brush", keydowned, true).on("keyup.brush", keyupped, true); - dragDisable(event.view); - } - redraw.call(that); - emit.start(event, mode2.name); - function moved(event2) { - for (const p of event2.changedTouches || [event2]) { - for (const d of points) - if (d.identifier === p.identifier) - d.cur = pointer(p, that); - } - if (shifting && !lockX && !lockY && points.length === 1) { - const point2 = points[0]; - if (abs$4(point2.cur[0] - point2[0]) > abs$4(point2.cur[1] - point2[1])) - lockY = true; - else - lockX = true; - } - for (const point2 of points) - if (point2.cur) - point2[0] = point2.cur[0], point2[1] = point2.cur[1]; - moving = true; - noevent$1(event2); - move(event2); - } - function move(event2) { - const point2 = points[0], point0 = point2.point0; - var t; - dx = point2[0] - point0[0]; - dy = point2[1] - point0[1]; - switch (mode2) { - case MODE_SPACE: - case MODE_DRAG: { - if (signX) - dx = max$2(W - w0, min$1(E2 - e0, dx)), w1 = w0 + dx, e1 = e0 + dx; - if (signY) - dy = max$2(N - n0, min$1(S - s0, dy)), n1 = n0 + dy, s1 = s0 + dy; - break; - } - case MODE_HANDLE: { - if (points[1]) { - if (signX) - w1 = max$2(W, min$1(E2, points[0][0])), e1 = max$2(W, min$1(E2, points[1][0])), signX = 1; - if (signY) - n1 = max$2(N, min$1(S, points[0][1])), s1 = max$2(N, min$1(S, points[1][1])), signY = 1; - } else { - if (signX < 0) - dx = max$2(W - w0, min$1(E2 - w0, dx)), w1 = w0 + dx, e1 = e0; - else if (signX > 0) - dx = max$2(W - e0, min$1(E2 - e0, dx)), w1 = w0, e1 = e0 + dx; - if (signY < 0) - dy = max$2(N - n0, min$1(S - n0, dy)), n1 = n0 + dy, s1 = s0; - else if (signY > 0) - dy = max$2(N - s0, min$1(S - s0, dy)), n1 = n0, s1 = s0 + dy; - } - break; - } - case MODE_CENTER: { - if (signX) - w1 = max$2(W, min$1(E2, w0 - dx * signX)), e1 = max$2(W, min$1(E2, e0 + dx * signX)); - if (signY) - n1 = max$2(N, min$1(S, n0 - dy * signY)), s1 = max$2(N, min$1(S, s0 + dy * signY)); - break; - } - } - if (e1 < w1) { - signX *= -1; - t = w0, w0 = e0, e0 = t; - t = w1, w1 = e1, e1 = t; - if (type2 in flipX) - overlay.attr("cursor", cursors[type2 = flipX[type2]]); - } - if (s1 < n1) { - signY *= -1; - t = n0, n0 = s0, s0 = t; - t = n1, n1 = s1, s1 = t; - if (type2 in flipY) - overlay.attr("cursor", cursors[type2 = flipY[type2]]); - } - if (state.selection) - selection2 = state.selection; - if (lockX) - w1 = selection2[0][0], e1 = selection2[1][0]; - if (lockY) - n1 = selection2[0][1], s1 = selection2[1][1]; - if (selection2[0][0] !== w1 || selection2[0][1] !== n1 || selection2[1][0] !== e1 || selection2[1][1] !== s1) { - state.selection = [[w1, n1], [e1, s1]]; - redraw.call(that); - emit.brush(event2, mode2.name); - } - } - function ended(event2) { - nopropagation$1(event2); - if (event2.touches) { - if (event2.touches.length) - return; - if (touchending) - clearTimeout(touchending); - touchending = setTimeout(function() { - touchending = null; - }, 500); - } else { - yesdrag(event2.view, moving); - view.on("keydown.brush keyup.brush mousemove.brush mouseup.brush", null); - } - group2.attr("pointer-events", "all"); - overlay.attr("cursor", cursors.overlay); - if (state.selection) - selection2 = state.selection; - if (empty(selection2)) - state.selection = null, redraw.call(that); - emit.end(event2, mode2.name); - } - function keydowned(event2) { - switch (event2.keyCode) { - case 16: { - shifting = signX && signY; - break; - } - case 18: { - if (mode2 === MODE_HANDLE) { - if (signX) - e0 = e1 - dx * signX, w0 = w1 + dx * signX; - if (signY) - s0 = s1 - dy * signY, n0 = n1 + dy * signY; - mode2 = MODE_CENTER; - move(event2); - } - break; - } - case 32: { - if (mode2 === MODE_HANDLE || mode2 === MODE_CENTER) { - if (signX < 0) - e0 = e1 - dx; - else if (signX > 0) - w0 = w1 - dx; - if (signY < 0) - s0 = s1 - dy; - else if (signY > 0) - n0 = n1 - dy; - mode2 = MODE_SPACE; - overlay.attr("cursor", cursors.selection); - move(event2); - } - break; - } - default: - return; - } - noevent$1(event2); - } - function keyupped(event2) { - switch (event2.keyCode) { - case 16: { - if (shifting) { - lockX = lockY = shifting = false; - move(event2); - } - break; - } - case 18: { - if (mode2 === MODE_CENTER) { - if (signX < 0) - e0 = e1; - else if (signX > 0) - w0 = w1; - if (signY < 0) - s0 = s1; - else if (signY > 0) - n0 = n1; - mode2 = MODE_HANDLE; - move(event2); - } - break; - } - case 32: { - if (mode2 === MODE_SPACE) { - if (event2.altKey) { - if (signX) - e0 = e1 - dx * signX, w0 = w1 + dx * signX; - if (signY) - s0 = s1 - dy * signY, n0 = n1 + dy * signY; - mode2 = MODE_CENTER; - } else { - if (signX < 0) - e0 = e1; - else if (signX > 0) - w0 = w1; - if (signY < 0) - s0 = s1; - else if (signY > 0) - n0 = n1; - mode2 = MODE_HANDLE; - } - overlay.attr("cursor", cursors[type2]); - move(event2); - } - break; - } - default: - return; - } - noevent$1(event2); - } - } - function touchmoved(event) { - emitter(this, arguments).moved(event); - } - function touchended(event) { - emitter(this, arguments).ended(event); - } - function initialize2() { - var state = this.__brush || { selection: null }; - state.extent = number2(extent2.apply(this, arguments)); - state.dim = dim; - return state; - } - brush2.extent = function(_2) { - return arguments.length ? (extent2 = typeof _2 === "function" ? _2 : constant$7(number2(_2)), brush2) : extent2; - }; - brush2.filter = function(_2) { - return arguments.length ? (filter2 = typeof _2 === "function" ? _2 : constant$7(!!_2), brush2) : filter2; - }; - brush2.touchable = function(_2) { - return arguments.length ? (touchable = typeof _2 === "function" ? _2 : constant$7(!!_2), brush2) : touchable; - }; - brush2.handleSize = function(_2) { - return arguments.length ? (handleSize = +_2, brush2) : handleSize; - }; - brush2.keyModifiers = function(_2) { - return arguments.length ? (keys = !!_2, brush2) : keys; - }; - brush2.on = function() { - var value = listeners.on.apply(listeners, arguments); - return value === listeners ? brush2 : value; - }; - return brush2; - } - var abs$3 = Math.abs; - var cos$2 = Math.cos; - var sin$2 = Math.sin; - var pi$3 = Math.PI; - var halfPi$2 = pi$3 / 2; - var tau$4 = pi$3 * 2; - var max$1 = Math.max; - var epsilon$5 = 1e-12; - function range$1(i, j) { - return Array.from({ length: j - i }, (_2, k2) => i + k2); - } - function compareValue(compare) { - return function(a2, b) { - return compare( - a2.source.value + a2.target.value, - b.source.value + b.target.value - ); - }; - } - function chord() { - return chord$1(false, false); - } - function chordTranspose() { - return chord$1(false, true); - } - function chordDirected() { - return chord$1(true, false); - } - function chord$1(directed, transpose2) { - var padAngle = 0, sortGroups = null, sortSubgroups = null, sortChords = null; - function chord2(matrix) { - var n = matrix.length, groupSums = new Array(n), groupIndex = range$1(0, n), chords = new Array(n * n), groups2 = new Array(n), k2 = 0, dx; - matrix = Float64Array.from({ length: n * n }, transpose2 ? (_2, i) => matrix[i % n][i / n | 0] : (_2, i) => matrix[i / n | 0][i % n]); - for (let i = 0; i < n; ++i) { - let x2 = 0; - for (let j = 0; j < n; ++j) - x2 += matrix[i * n + j] + directed * matrix[j * n + i]; - k2 += groupSums[i] = x2; - } - k2 = max$1(0, tau$4 - padAngle * n) / k2; - dx = k2 ? padAngle : tau$4 / n; - { - let x2 = 0; - if (sortGroups) - groupIndex.sort((a2, b) => sortGroups(groupSums[a2], groupSums[b])); - for (const i of groupIndex) { - const x02 = x2; - if (directed) { - const subgroupIndex = range$1(~n + 1, n).filter((j) => j < 0 ? matrix[~j * n + i] : matrix[i * n + j]); - if (sortSubgroups) - subgroupIndex.sort((a2, b) => sortSubgroups(a2 < 0 ? -matrix[~a2 * n + i] : matrix[i * n + a2], b < 0 ? -matrix[~b * n + i] : matrix[i * n + b])); - for (const j of subgroupIndex) { - if (j < 0) { - const chord3 = chords[~j * n + i] || (chords[~j * n + i] = { source: null, target: null }); - chord3.target = { index: i, startAngle: x2, endAngle: x2 += matrix[~j * n + i] * k2, value: matrix[~j * n + i] }; - } else { - const chord3 = chords[i * n + j] || (chords[i * n + j] = { source: null, target: null }); - chord3.source = { index: i, startAngle: x2, endAngle: x2 += matrix[i * n + j] * k2, value: matrix[i * n + j] }; - } - } - groups2[i] = { index: i, startAngle: x02, endAngle: x2, value: groupSums[i] }; - } else { - const subgroupIndex = range$1(0, n).filter((j) => matrix[i * n + j] || matrix[j * n + i]); - if (sortSubgroups) - subgroupIndex.sort((a2, b) => sortSubgroups(matrix[i * n + a2], matrix[i * n + b])); - for (const j of subgroupIndex) { - let chord3; - if (i < j) { - chord3 = chords[i * n + j] || (chords[i * n + j] = { source: null, target: null }); - chord3.source = { index: i, startAngle: x2, endAngle: x2 += matrix[i * n + j] * k2, value: matrix[i * n + j] }; - } else { - chord3 = chords[j * n + i] || (chords[j * n + i] = { source: null, target: null }); - chord3.target = { index: i, startAngle: x2, endAngle: x2 += matrix[i * n + j] * k2, value: matrix[i * n + j] }; - if (i === j) - chord3.source = chord3.target; - } - if (chord3.source && chord3.target && chord3.source.value < chord3.target.value) { - const source = chord3.source; - chord3.source = chord3.target; - chord3.target = source; - } - } - groups2[i] = { index: i, startAngle: x02, endAngle: x2, value: groupSums[i] }; - } - x2 += dx; - } - } - chords = Object.values(chords); - chords.groups = groups2; - return sortChords ? chords.sort(sortChords) : chords; - } - chord2.padAngle = function(_2) { - return arguments.length ? (padAngle = max$1(0, _2), chord2) : padAngle; - }; - chord2.sortGroups = function(_2) { - return arguments.length ? (sortGroups = _2, chord2) : sortGroups; - }; - chord2.sortSubgroups = function(_2) { - return arguments.length ? (sortSubgroups = _2, chord2) : sortSubgroups; - }; - chord2.sortChords = function(_2) { - return arguments.length ? (_2 == null ? sortChords = null : (sortChords = compareValue(_2))._ = _2, chord2) : sortChords && sortChords._; - }; - return chord2; - } - const pi$2 = Math.PI, tau$3 = 2 * pi$2, epsilon$4 = 1e-6, tauEpsilon = tau$3 - epsilon$4; - function Path$1() { - this._x0 = this._y0 = this._x1 = this._y1 = null; - this._ = ""; - } - function path() { - return new Path$1(); - } - Path$1.prototype = path.prototype = { - constructor: Path$1, - moveTo: function(x2, y2) { - this._ += "M" + (this._x0 = this._x1 = +x2) + "," + (this._y0 = this._y1 = +y2); - }, - closePath: function() { - if (this._x1 !== null) { - this._x1 = this._x0, this._y1 = this._y0; - this._ += "Z"; - } - }, - lineTo: function(x2, y2) { - this._ += "L" + (this._x1 = +x2) + "," + (this._y1 = +y2); - }, - quadraticCurveTo: function(x12, y12, x2, y2) { - this._ += "Q" + +x12 + "," + +y12 + "," + (this._x1 = +x2) + "," + (this._y1 = +y2); - }, - bezierCurveTo: function(x12, y12, x2, y2, x3, y3) { - this._ += "C" + +x12 + "," + +y12 + "," + +x2 + "," + +y2 + "," + (this._x1 = +x3) + "," + (this._y1 = +y3); - }, - arcTo: function(x12, y12, x2, y2, r) { - x12 = +x12, y12 = +y12, x2 = +x2, y2 = +y2, r = +r; - var x02 = this._x1, y02 = this._y1, x21 = x2 - x12, y21 = y2 - y12, x01 = x02 - x12, y01 = y02 - y12, l01_2 = x01 * x01 + y01 * y01; - if (r < 0) - throw new Error("negative radius: " + r); - if (this._x1 === null) { - this._ += "M" + (this._x1 = x12) + "," + (this._y1 = y12); - } else if (!(l01_2 > epsilon$4)) - ; - else if (!(Math.abs(y01 * x21 - y21 * x01) > epsilon$4) || !r) { - this._ += "L" + (this._x1 = x12) + "," + (this._y1 = y12); - } else { - var x20 = x2 - x02, y20 = y2 - y02, l21_2 = x21 * x21 + y21 * y21, l20_2 = x20 * x20 + y20 * y20, l21 = Math.sqrt(l21_2), l01 = Math.sqrt(l01_2), l = r * Math.tan((pi$2 - Math.acos((l21_2 + l01_2 - l20_2) / (2 * l21 * l01))) / 2), t01 = l / l01, t21 = l / l21; - if (Math.abs(t01 - 1) > epsilon$4) { - this._ += "L" + (x12 + t01 * x01) + "," + (y12 + t01 * y01); - } - this._ += "A" + r + "," + r + ",0,0," + +(y01 * x20 > x01 * y20) + "," + (this._x1 = x12 + t21 * x21) + "," + (this._y1 = y12 + t21 * y21); - } - }, - arc: function(x2, y2, r, a0, a1, ccw) { - x2 = +x2, y2 = +y2, r = +r, ccw = !!ccw; - var dx = r * Math.cos(a0), dy = r * Math.sin(a0), x02 = x2 + dx, y02 = y2 + dy, cw = 1 ^ ccw, da = ccw ? a0 - a1 : a1 - a0; - if (r < 0) - throw new Error("negative radius: " + r); - if (this._x1 === null) { - this._ += "M" + x02 + "," + y02; - } else if (Math.abs(this._x1 - x02) > epsilon$4 || Math.abs(this._y1 - y02) > epsilon$4) { - this._ += "L" + x02 + "," + y02; - } - if (!r) - return; - if (da < 0) - da = da % tau$3 + tau$3; - if (da > tauEpsilon) { - this._ += "A" + r + "," + r + ",0,1," + cw + "," + (x2 - dx) + "," + (y2 - dy) + "A" + r + "," + r + ",0,1," + cw + "," + (this._x1 = x02) + "," + (this._y1 = y02); - } else if (da > epsilon$4) { - this._ += "A" + r + "," + r + ",0," + +(da >= pi$2) + "," + cw + "," + (this._x1 = x2 + r * Math.cos(a1)) + "," + (this._y1 = y2 + r * Math.sin(a1)); - } - }, - rect: function(x2, y2, w2, h) { - this._ += "M" + (this._x0 = this._x1 = +x2) + "," + (this._y0 = this._y1 = +y2) + "h" + +w2 + "v" + +h + "h" + -w2 + "Z"; - }, - toString: function() { - return this._; - } - }; - var slice$3 = Array.prototype.slice; - function constant$6(x2) { - return function() { - return x2; - }; - } - function defaultSource$1(d) { - return d.source; - } - function defaultTarget(d) { - return d.target; - } - function defaultRadius$1(d) { - return d.radius; - } - function defaultStartAngle(d) { - return d.startAngle; - } - function defaultEndAngle(d) { - return d.endAngle; - } - function defaultPadAngle() { - return 0; - } - function defaultArrowheadRadius() { - return 10; - } - function ribbon(headRadius) { - var source = defaultSource$1, target = defaultTarget, sourceRadius = defaultRadius$1, targetRadius = defaultRadius$1, startAngle = defaultStartAngle, endAngle = defaultEndAngle, padAngle = defaultPadAngle, context = null; - function ribbon2() { - var buffer2, s2 = source.apply(this, arguments), t = target.apply(this, arguments), ap = padAngle.apply(this, arguments) / 2, argv = slice$3.call(arguments), sr = +sourceRadius.apply(this, (argv[0] = s2, argv)), sa0 = startAngle.apply(this, argv) - halfPi$2, sa1 = endAngle.apply(this, argv) - halfPi$2, tr = +targetRadius.apply(this, (argv[0] = t, argv)), ta0 = startAngle.apply(this, argv) - halfPi$2, ta1 = endAngle.apply(this, argv) - halfPi$2; - if (!context) - context = buffer2 = path(); - if (ap > epsilon$5) { - if (abs$3(sa1 - sa0) > ap * 2 + epsilon$5) - sa1 > sa0 ? (sa0 += ap, sa1 -= ap) : (sa0 -= ap, sa1 += ap); - else - sa0 = sa1 = (sa0 + sa1) / 2; - if (abs$3(ta1 - ta0) > ap * 2 + epsilon$5) - ta1 > ta0 ? (ta0 += ap, ta1 -= ap) : (ta0 -= ap, ta1 += ap); - else - ta0 = ta1 = (ta0 + ta1) / 2; - } - context.moveTo(sr * cos$2(sa0), sr * sin$2(sa0)); - context.arc(0, 0, sr, sa0, sa1); - if (sa0 !== ta0 || sa1 !== ta1) { - if (headRadius) { - var hr = +headRadius.apply(this, arguments), tr2 = tr - hr, ta2 = (ta0 + ta1) / 2; - context.quadraticCurveTo(0, 0, tr2 * cos$2(ta0), tr2 * sin$2(ta0)); - context.lineTo(tr * cos$2(ta2), tr * sin$2(ta2)); - context.lineTo(tr2 * cos$2(ta1), tr2 * sin$2(ta1)); - } else { - context.quadraticCurveTo(0, 0, tr * cos$2(ta0), tr * sin$2(ta0)); - context.arc(0, 0, tr, ta0, ta1); - } - } - context.quadraticCurveTo(0, 0, sr * cos$2(sa0), sr * sin$2(sa0)); - context.closePath(); - if (buffer2) - return context = null, buffer2 + "" || null; - } - if (headRadius) - ribbon2.headRadius = function(_2) { - return arguments.length ? (headRadius = typeof _2 === "function" ? _2 : constant$6(+_2), ribbon2) : headRadius; - }; - ribbon2.radius = function(_2) { - return arguments.length ? (sourceRadius = targetRadius = typeof _2 === "function" ? _2 : constant$6(+_2), ribbon2) : sourceRadius; - }; - ribbon2.sourceRadius = function(_2) { - return arguments.length ? (sourceRadius = typeof _2 === "function" ? _2 : constant$6(+_2), ribbon2) : sourceRadius; - }; - ribbon2.targetRadius = function(_2) { - return arguments.length ? (targetRadius = typeof _2 === "function" ? _2 : constant$6(+_2), ribbon2) : targetRadius; - }; - ribbon2.startAngle = function(_2) { - return arguments.length ? (startAngle = typeof _2 === "function" ? _2 : constant$6(+_2), ribbon2) : startAngle; - }; - ribbon2.endAngle = function(_2) { - return arguments.length ? (endAngle = typeof _2 === "function" ? _2 : constant$6(+_2), ribbon2) : endAngle; - }; - ribbon2.padAngle = function(_2) { - return arguments.length ? (padAngle = typeof _2 === "function" ? _2 : constant$6(+_2), ribbon2) : padAngle; - }; - ribbon2.source = function(_2) { - return arguments.length ? (source = _2, ribbon2) : source; - }; - ribbon2.target = function(_2) { - return arguments.length ? (target = _2, ribbon2) : target; - }; - ribbon2.context = function(_2) { - return arguments.length ? (context = _2 == null ? null : _2, ribbon2) : context; - }; - return ribbon2; - } - function ribbon$1() { - return ribbon(); - } - function ribbonArrow() { - return ribbon(defaultArrowheadRadius); - } - var array$2 = Array.prototype; - var slice$2 = array$2.slice; - function ascending$1(a2, b) { - return a2 - b; - } - function area$3(ring) { - var i = 0, n = ring.length, area2 = ring[n - 1][1] * ring[0][0] - ring[n - 1][0] * ring[0][1]; - while (++i < n) - area2 += ring[i - 1][1] * ring[i][0] - ring[i - 1][0] * ring[i][1]; - return area2; - } - const constant$5 = (x2) => () => x2; - function contains$2(ring, hole) { - var i = -1, n = hole.length, c2; - while (++i < n) - if (c2 = ringContains(ring, hole[i])) - return c2; - return 0; - } - function ringContains(ring, point2) { - var x2 = point2[0], y2 = point2[1], contains2 = -1; - for (var i = 0, n = ring.length, j = n - 1; i < n; j = i++) { - var pi2 = ring[i], xi = pi2[0], yi = pi2[1], pj = ring[j], xj = pj[0], yj = pj[1]; - if (segmentContains(pi2, pj, point2)) - return 0; - if (yi > y2 !== yj > y2 && x2 < (xj - xi) * (y2 - yi) / (yj - yi) + xi) - contains2 = -contains2; - } - return contains2; - } - function segmentContains(a2, b, c2) { - var i; - return collinear$1(a2, b, c2) && within(a2[i = +(a2[0] === b[0])], c2[i], b[i]); - } - function collinear$1(a2, b, c2) { - return (b[0] - a2[0]) * (c2[1] - a2[1]) === (c2[0] - a2[0]) * (b[1] - a2[1]); - } - function within(p, q, r) { - return p <= q && q <= r || r <= q && q <= p; - } - function noop$2() { - } - var cases = [ - [], - [[[1, 1.5], [0.5, 1]]], - [[[1.5, 1], [1, 1.5]]], - [[[1.5, 1], [0.5, 1]]], - [[[1, 0.5], [1.5, 1]]], - [[[1, 1.5], [0.5, 1]], [[1, 0.5], [1.5, 1]]], - [[[1, 0.5], [1, 1.5]]], - [[[1, 0.5], [0.5, 1]]], - [[[0.5, 1], [1, 0.5]]], - [[[1, 1.5], [1, 0.5]]], - [[[0.5, 1], [1, 0.5]], [[1.5, 1], [1, 1.5]]], - [[[1.5, 1], [1, 0.5]]], - [[[0.5, 1], [1.5, 1]]], - [[[1, 1.5], [1.5, 1]]], - [[[0.5, 1], [1, 1.5]]], - [] - ]; - function Contours() { - var dx = 1, dy = 1, threshold2 = thresholdSturges, smooth = smoothLinear; - function contours(values) { - var tz = threshold2(values); - if (!Array.isArray(tz)) { - const e = extent$1(values), ts = tickStep(e[0], e[1], tz); - tz = ticks(Math.floor(e[0] / ts) * ts, Math.floor(e[1] / ts - 1) * ts, tz); - } else { - tz = tz.slice().sort(ascending$1); - } - return tz.map((value) => contour(values, value)); - } - function contour(values, value) { - var polygons = [], holes = []; - isorings(values, value, function(ring) { - smooth(ring, values, value); - if (area$3(ring) > 0) - polygons.push([ring]); - else - holes.push(ring); - }); - holes.forEach(function(hole) { - for (var i = 0, n = polygons.length, polygon; i < n; ++i) { - if (contains$2((polygon = polygons[i])[0], hole) !== -1) { - polygon.push(hole); - return; - } - } - }); - return { - type: "MultiPolygon", - value, - coordinates: polygons - }; - } - function isorings(values, value, callback) { - var fragmentByStart = new Array(), fragmentByEnd = new Array(), x2, y2, t02, t12, t22, t32; - x2 = y2 = -1; - t12 = values[0] >= value; - cases[t12 << 1].forEach(stitch); - while (++x2 < dx - 1) { - t02 = t12, t12 = values[x2 + 1] >= value; - cases[t02 | t12 << 1].forEach(stitch); - } - cases[t12 << 0].forEach(stitch); - while (++y2 < dy - 1) { - x2 = -1; - t12 = values[y2 * dx + dx] >= value; - t22 = values[y2 * dx] >= value; - cases[t12 << 1 | t22 << 2].forEach(stitch); - while (++x2 < dx - 1) { - t02 = t12, t12 = values[y2 * dx + dx + x2 + 1] >= value; - t32 = t22, t22 = values[y2 * dx + x2 + 1] >= value; - cases[t02 | t12 << 1 | t22 << 2 | t32 << 3].forEach(stitch); - } - cases[t12 | t22 << 3].forEach(stitch); - } - x2 = -1; - t22 = values[y2 * dx] >= value; - cases[t22 << 2].forEach(stitch); - while (++x2 < dx - 1) { - t32 = t22, t22 = values[y2 * dx + x2 + 1] >= value; - cases[t22 << 2 | t32 << 3].forEach(stitch); - } - cases[t22 << 3].forEach(stitch); - function stitch(line2) { - var start2 = [line2[0][0] + x2, line2[0][1] + y2], end2 = [line2[1][0] + x2, line2[1][1] + y2], startIndex = index2(start2), endIndex = index2(end2), f, g; - if (f = fragmentByEnd[startIndex]) { - if (g = fragmentByStart[endIndex]) { - delete fragmentByEnd[f.end]; - delete fragmentByStart[g.start]; - if (f === g) { - f.ring.push(end2); - callback(f.ring); - } else { - fragmentByStart[f.start] = fragmentByEnd[g.end] = { start: f.start, end: g.end, ring: f.ring.concat(g.ring) }; - } - } else { - delete fragmentByEnd[f.end]; - f.ring.push(end2); - fragmentByEnd[f.end = endIndex] = f; - } - } else if (f = fragmentByStart[endIndex]) { - if (g = fragmentByEnd[startIndex]) { - delete fragmentByStart[f.start]; - delete fragmentByEnd[g.end]; - if (f === g) { - f.ring.push(end2); - callback(f.ring); - } else { - fragmentByStart[g.start] = fragmentByEnd[f.end] = { start: g.start, end: f.end, ring: g.ring.concat(f.ring) }; - } - } else { - delete fragmentByStart[f.start]; - f.ring.unshift(start2); - fragmentByStart[f.start = startIndex] = f; - } - } else { - fragmentByStart[startIndex] = fragmentByEnd[endIndex] = { start: startIndex, end: endIndex, ring: [start2, end2] }; - } - } - } - function index2(point2) { - return point2[0] * 2 + point2[1] * (dx + 1) * 4; - } - function smoothLinear(ring, values, value) { - ring.forEach(function(point2) { - var x2 = point2[0], y2 = point2[1], xt = x2 | 0, yt = y2 | 0, v0, v1 = values[yt * dx + xt]; - if (x2 > 0 && x2 < dx && xt === x2) { - v0 = values[yt * dx + xt - 1]; - point2[0] = x2 + (value - v0) / (v1 - v0) - 0.5; - } - if (y2 > 0 && y2 < dy && yt === y2) { - v0 = values[(yt - 1) * dx + xt]; - point2[1] = y2 + (value - v0) / (v1 - v0) - 0.5; - } - }); - } - contours.contour = contour; - contours.size = function(_2) { - if (!arguments.length) - return [dx, dy]; - var _0 = Math.floor(_2[0]), _1 = Math.floor(_2[1]); - if (!(_0 >= 0 && _1 >= 0)) - throw new Error("invalid size"); - return dx = _0, dy = _1, contours; - }; - contours.thresholds = function(_2) { - return arguments.length ? (threshold2 = typeof _2 === "function" ? _2 : Array.isArray(_2) ? constant$5(slice$2.call(_2)) : constant$5(_2), contours) : threshold2; - }; - contours.smooth = function(_2) { - return arguments.length ? (smooth = _2 ? smoothLinear : noop$2, contours) : smooth === smoothLinear; - }; - return contours; - } - function defaultX$1(d) { - return d[0]; - } - function defaultY$1(d) { - return d[1]; - } - function defaultWeight() { - return 1; - } - function density() { - var x2 = defaultX$1, y2 = defaultY$1, weight = defaultWeight, dx = 960, dy = 500, r = 20, k2 = 2, o = r * 3, n = dx + o * 2 >> k2, m2 = dy + o * 2 >> k2, threshold2 = constant$5(20); - function grid(data) { - var values = new Float32Array(n * m2), pow2k = Math.pow(2, -k2), i = -1; - for (const d of data) { - var xi = (x2(d, ++i, data) + o) * pow2k, yi = (y2(d, i, data) + o) * pow2k, wi = +weight(d, i, data); - if (xi >= 0 && xi < n && yi >= 0 && yi < m2) { - var x02 = Math.floor(xi), y02 = Math.floor(yi), xt = xi - x02 - 0.5, yt = yi - y02 - 0.5; - values[x02 + y02 * n] += (1 - xt) * (1 - yt) * wi; - values[x02 + 1 + y02 * n] += xt * (1 - yt) * wi; - values[x02 + 1 + (y02 + 1) * n] += xt * yt * wi; - values[x02 + (y02 + 1) * n] += (1 - xt) * yt * wi; - } - } - blur2({ data: values, width: n, height: m2 }, r * pow2k); - return values; - } - function density2(data) { - var values = grid(data), tz = threshold2(values), pow4k = Math.pow(2, 2 * k2); - if (!Array.isArray(tz)) { - tz = ticks(Number.MIN_VALUE, max$3(values) / pow4k, tz); - } - return Contours().size([n, m2]).thresholds(tz.map((d) => d * pow4k))(values).map((c2, i) => (c2.value = +tz[i], transform2(c2))); - } - density2.contours = function(data) { - var values = grid(data), contours = Contours().size([n, m2]), pow4k = Math.pow(2, 2 * k2), contour = (value) => { - value = +value; - var c2 = transform2(contours.contour(values, value * pow4k)); - c2.value = value; - return c2; - }; - Object.defineProperty(contour, "max", { get: () => max$3(values) / pow4k }); - return contour; - }; - function transform2(geometry) { - geometry.coordinates.forEach(transformPolygon); - return geometry; - } - function transformPolygon(coordinates2) { - coordinates2.forEach(transformRing); - } - function transformRing(coordinates2) { - coordinates2.forEach(transformPoint); - } - function transformPoint(coordinates2) { - coordinates2[0] = coordinates2[0] * Math.pow(2, k2) - o; - coordinates2[1] = coordinates2[1] * Math.pow(2, k2) - o; - } - function resize() { - o = r * 3; - n = dx + o * 2 >> k2; - m2 = dy + o * 2 >> k2; - return density2; - } - density2.x = function(_2) { - return arguments.length ? (x2 = typeof _2 === "function" ? _2 : constant$5(+_2), density2) : x2; - }; - density2.y = function(_2) { - return arguments.length ? (y2 = typeof _2 === "function" ? _2 : constant$5(+_2), density2) : y2; - }; - density2.weight = function(_2) { - return arguments.length ? (weight = typeof _2 === "function" ? _2 : constant$5(+_2), density2) : weight; - }; - density2.size = function(_2) { - if (!arguments.length) - return [dx, dy]; - var _0 = +_2[0], _1 = +_2[1]; - if (!(_0 >= 0 && _1 >= 0)) - throw new Error("invalid size"); - return dx = _0, dy = _1, resize(); - }; - density2.cellSize = function(_2) { - if (!arguments.length) - return 1 << k2; - if (!((_2 = +_2) >= 1)) - throw new Error("invalid cell size"); - return k2 = Math.floor(Math.log(_2) / Math.LN2), resize(); - }; - density2.thresholds = function(_2) { - return arguments.length ? (threshold2 = typeof _2 === "function" ? _2 : Array.isArray(_2) ? constant$5(slice$2.call(_2)) : constant$5(_2), density2) : threshold2; - }; - density2.bandwidth = function(_2) { - if (!arguments.length) - return Math.sqrt(r * (r + 1)); - if (!((_2 = +_2) >= 0)) - throw new Error("invalid bandwidth"); - return r = (Math.sqrt(4 * _2 * _2 + 1) - 1) / 2, resize(); - }; - return density2; - } - const epsilon$3 = 11102230246251565e-32; - const splitter = 134217729; - const resulterrbound = (3 + 8 * epsilon$3) * epsilon$3; - function sum$1(elen, e, flen, f, h) { - let Q, Qnew, hh, bvirt; - let enow = e[0]; - let fnow = f[0]; - let eindex = 0; - let findex = 0; - if (fnow > enow === fnow > -enow) { - Q = enow; - enow = e[++eindex]; - } else { - Q = fnow; - fnow = f[++findex]; - } - let hindex = 0; - if (eindex < elen && findex < flen) { - if (fnow > enow === fnow > -enow) { - Qnew = enow + Q; - hh = Q - (Qnew - enow); - enow = e[++eindex]; - } else { - Qnew = fnow + Q; - hh = Q - (Qnew - fnow); - fnow = f[++findex]; - } - Q = Qnew; - if (hh !== 0) { - h[hindex++] = hh; - } - while (eindex < elen && findex < flen) { - if (fnow > enow === fnow > -enow) { - Qnew = Q + enow; - bvirt = Qnew - Q; - hh = Q - (Qnew - bvirt) + (enow - bvirt); - enow = e[++eindex]; - } else { - Qnew = Q + fnow; - bvirt = Qnew - Q; - hh = Q - (Qnew - bvirt) + (fnow - bvirt); - fnow = f[++findex]; - } - Q = Qnew; - if (hh !== 0) { - h[hindex++] = hh; - } - } - } - while (eindex < elen) { - Qnew = Q + enow; - bvirt = Qnew - Q; - hh = Q - (Qnew - bvirt) + (enow - bvirt); - enow = e[++eindex]; - Q = Qnew; - if (hh !== 0) { - h[hindex++] = hh; - } - } - while (findex < flen) { - Qnew = Q + fnow; - bvirt = Qnew - Q; - hh = Q - (Qnew - bvirt) + (fnow - bvirt); - fnow = f[++findex]; - Q = Qnew; - if (hh !== 0) { - h[hindex++] = hh; - } - } - if (Q !== 0 || hindex === 0) { - h[hindex++] = Q; - } - return hindex; - } - function estimate(elen, e) { - let Q = e[0]; - for (let i = 1; i < elen; i++) - Q += e[i]; - return Q; - } - function vec(n) { - return new Float64Array(n); - } - const ccwerrboundA = (3 + 16 * epsilon$3) * epsilon$3; - const ccwerrboundB = (2 + 12 * epsilon$3) * epsilon$3; - const ccwerrboundC = (9 + 64 * epsilon$3) * epsilon$3 * epsilon$3; - const B = vec(4); - const C1 = vec(8); - const C2 = vec(12); - const D = vec(16); - const u = vec(4); - function orient2dadapt(ax, ay, bx, by, cx, cy, detsum) { - let acxtail, acytail, bcxtail, bcytail; - let bvirt, c2, ahi, alo, bhi, blo, _i, _j, _0, s1, s0, t12, t02, u3; - const acx = ax - cx; - const bcx = bx - cx; - const acy = ay - cy; - const bcy = by - cy; - s1 = acx * bcy; - c2 = splitter * acx; - ahi = c2 - (c2 - acx); - alo = acx - ahi; - c2 = splitter * bcy; - bhi = c2 - (c2 - bcy); - blo = bcy - bhi; - s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo); - t12 = acy * bcx; - c2 = splitter * acy; - ahi = c2 - (c2 - acy); - alo = acy - ahi; - c2 = splitter * bcx; - bhi = c2 - (c2 - bcx); - blo = bcx - bhi; - t02 = alo * blo - (t12 - ahi * bhi - alo * bhi - ahi * blo); - _i = s0 - t02; - bvirt = s0 - _i; - B[0] = s0 - (_i + bvirt) + (bvirt - t02); - _j = s1 + _i; - bvirt = _j - s1; - _0 = s1 - (_j - bvirt) + (_i - bvirt); - _i = _0 - t12; - bvirt = _0 - _i; - B[1] = _0 - (_i + bvirt) + (bvirt - t12); - u3 = _j + _i; - bvirt = u3 - _j; - B[2] = _j - (u3 - bvirt) + (_i - bvirt); - B[3] = u3; - let det = estimate(4, B); - let errbound = ccwerrboundB * detsum; - if (det >= errbound || -det >= errbound) { - return det; - } - bvirt = ax - acx; - acxtail = ax - (acx + bvirt) + (bvirt - cx); - bvirt = bx - bcx; - bcxtail = bx - (bcx + bvirt) + (bvirt - cx); - bvirt = ay - acy; - acytail = ay - (acy + bvirt) + (bvirt - cy); - bvirt = by - bcy; - bcytail = by - (bcy + bvirt) + (bvirt - cy); - if (acxtail === 0 && acytail === 0 && bcxtail === 0 && bcytail === 0) { - return det; - } - errbound = ccwerrboundC * detsum + resulterrbound * Math.abs(det); - det += acx * bcytail + bcy * acxtail - (acy * bcxtail + bcx * acytail); - if (det >= errbound || -det >= errbound) - return det; - s1 = acxtail * bcy; - c2 = splitter * acxtail; - ahi = c2 - (c2 - acxtail); - alo = acxtail - ahi; - c2 = splitter * bcy; - bhi = c2 - (c2 - bcy); - blo = bcy - bhi; - s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo); - t12 = acytail * bcx; - c2 = splitter * acytail; - ahi = c2 - (c2 - acytail); - alo = acytail - ahi; - c2 = splitter * bcx; - bhi = c2 - (c2 - bcx); - blo = bcx - bhi; - t02 = alo * blo - (t12 - ahi * bhi - alo * bhi - ahi * blo); - _i = s0 - t02; - bvirt = s0 - _i; - u[0] = s0 - (_i + bvirt) + (bvirt - t02); - _j = s1 + _i; - bvirt = _j - s1; - _0 = s1 - (_j - bvirt) + (_i - bvirt); - _i = _0 - t12; - bvirt = _0 - _i; - u[1] = _0 - (_i + bvirt) + (bvirt - t12); - u3 = _j + _i; - bvirt = u3 - _j; - u[2] = _j - (u3 - bvirt) + (_i - bvirt); - u[3] = u3; - const C1len = sum$1(4, B, 4, u, C1); - s1 = acx * bcytail; - c2 = splitter * acx; - ahi = c2 - (c2 - acx); - alo = acx - ahi; - c2 = splitter * bcytail; - bhi = c2 - (c2 - bcytail); - blo = bcytail - bhi; - s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo); - t12 = acy * bcxtail; - c2 = splitter * acy; - ahi = c2 - (c2 - acy); - alo = acy - ahi; - c2 = splitter * bcxtail; - bhi = c2 - (c2 - bcxtail); - blo = bcxtail - bhi; - t02 = alo * blo - (t12 - ahi * bhi - alo * bhi - ahi * blo); - _i = s0 - t02; - bvirt = s0 - _i; - u[0] = s0 - (_i + bvirt) + (bvirt - t02); - _j = s1 + _i; - bvirt = _j - s1; - _0 = s1 - (_j - bvirt) + (_i - bvirt); - _i = _0 - t12; - bvirt = _0 - _i; - u[1] = _0 - (_i + bvirt) + (bvirt - t12); - u3 = _j + _i; - bvirt = u3 - _j; - u[2] = _j - (u3 - bvirt) + (_i - bvirt); - u[3] = u3; - const C2len = sum$1(C1len, C1, 4, u, C2); - s1 = acxtail * bcytail; - c2 = splitter * acxtail; - ahi = c2 - (c2 - acxtail); - alo = acxtail - ahi; - c2 = splitter * bcytail; - bhi = c2 - (c2 - bcytail); - blo = bcytail - bhi; - s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo); - t12 = acytail * bcxtail; - c2 = splitter * acytail; - ahi = c2 - (c2 - acytail); - alo = acytail - ahi; - c2 = splitter * bcxtail; - bhi = c2 - (c2 - bcxtail); - blo = bcxtail - bhi; - t02 = alo * blo - (t12 - ahi * bhi - alo * bhi - ahi * blo); - _i = s0 - t02; - bvirt = s0 - _i; - u[0] = s0 - (_i + bvirt) + (bvirt - t02); - _j = s1 + _i; - bvirt = _j - s1; - _0 = s1 - (_j - bvirt) + (_i - bvirt); - _i = _0 - t12; - bvirt = _0 - _i; - u[1] = _0 - (_i + bvirt) + (bvirt - t12); - u3 = _j + _i; - bvirt = u3 - _j; - u[2] = _j - (u3 - bvirt) + (_i - bvirt); - u[3] = u3; - const Dlen = sum$1(C2len, C2, 4, u, D); - return D[Dlen - 1]; - } - function orient2d(ax, ay, bx, by, cx, cy) { - const detleft = (ay - cy) * (bx - cx); - const detright = (ax - cx) * (by - cy); - const det = detleft - detright; - if (detleft === 0 || detright === 0 || detleft > 0 !== detright > 0) - return det; - const detsum = Math.abs(detleft + detright); - if (Math.abs(det) >= ccwerrboundA * detsum) - return det; - return -orient2dadapt(ax, ay, bx, by, cx, cy, detsum); - } - const EPSILON = Math.pow(2, -52); - const EDGE_STACK = new Uint32Array(512); - class Delaunator { - static from(points, getX = defaultGetX, getY = defaultGetY) { - const n = points.length; - const coords = new Float64Array(n * 2); - for (let i = 0; i < n; i++) { - const p = points[i]; - coords[2 * i] = getX(p); - coords[2 * i + 1] = getY(p); - } - return new Delaunator(coords); - } - constructor(coords) { - const n = coords.length >> 1; - if (n > 0 && typeof coords[0] !== "number") - throw new Error("Expected coords to contain numbers."); - this.coords = coords; - const maxTriangles = Math.max(2 * n - 5, 0); - this._triangles = new Uint32Array(maxTriangles * 3); - this._halfedges = new Int32Array(maxTriangles * 3); - this._hashSize = Math.ceil(Math.sqrt(n)); - this._hullPrev = new Uint32Array(n); - this._hullNext = new Uint32Array(n); - this._hullTri = new Uint32Array(n); - this._hullHash = new Int32Array(this._hashSize).fill(-1); - this._ids = new Uint32Array(n); - this._dists = new Float64Array(n); - this.update(); - } - update() { - const { coords, _hullPrev: hullPrev, _hullNext: hullNext, _hullTri: hullTri, _hullHash: hullHash } = this; - const n = coords.length >> 1; - let minX = Infinity; - let minY = Infinity; - let maxX = -Infinity; - let maxY2 = -Infinity; - for (let i = 0; i < n; i++) { - const x2 = coords[2 * i]; - const y2 = coords[2 * i + 1]; - if (x2 < minX) - minX = x2; - if (y2 < minY) - minY = y2; - if (x2 > maxX) - maxX = x2; - if (y2 > maxY2) - maxY2 = y2; - this._ids[i] = i; - } - const cx = (minX + maxX) / 2; - const cy = (minY + maxY2) / 2; - let minDist = Infinity; - let i0, i1, i2; - for (let i = 0; i < n; i++) { - const d = dist(cx, cy, coords[2 * i], coords[2 * i + 1]); - if (d < minDist) { - i0 = i; - minDist = d; - } - } - const i0x = coords[2 * i0]; - const i0y = coords[2 * i0 + 1]; - minDist = Infinity; - for (let i = 0; i < n; i++) { - if (i === i0) - continue; - const d = dist(i0x, i0y, coords[2 * i], coords[2 * i + 1]); - if (d < minDist && d > 0) { - i1 = i; - minDist = d; - } - } - let i1x = coords[2 * i1]; - let i1y = coords[2 * i1 + 1]; - let minRadius = Infinity; - for (let i = 0; i < n; i++) { - if (i === i0 || i === i1) - continue; - const r = circumradius(i0x, i0y, i1x, i1y, coords[2 * i], coords[2 * i + 1]); - if (r < minRadius) { - i2 = i; - minRadius = r; - } - } - let i2x = coords[2 * i2]; - let i2y = coords[2 * i2 + 1]; - if (minRadius === Infinity) { - for (let i = 0; i < n; i++) { - this._dists[i] = coords[2 * i] - coords[0] || coords[2 * i + 1] - coords[1]; - } - quicksort(this._ids, this._dists, 0, n - 1); - const hull2 = new Uint32Array(n); - let j = 0; - for (let i = 0, d0 = -Infinity; i < n; i++) { - const id2 = this._ids[i]; - if (this._dists[id2] > d0) { - hull2[j++] = id2; - d0 = this._dists[id2]; - } - } - this.hull = hull2.subarray(0, j); - this.triangles = new Uint32Array(0); - this.halfedges = new Uint32Array(0); - return; - } - if (orient2d(i0x, i0y, i1x, i1y, i2x, i2y) < 0) { - const i = i1; - const x2 = i1x; - const y2 = i1y; - i1 = i2; - i1x = i2x; - i1y = i2y; - i2 = i; - i2x = x2; - i2y = y2; - } - const center2 = circumcenter(i0x, i0y, i1x, i1y, i2x, i2y); - this._cx = center2.x; - this._cy = center2.y; - for (let i = 0; i < n; i++) { - this._dists[i] = dist(coords[2 * i], coords[2 * i + 1], center2.x, center2.y); - } - quicksort(this._ids, this._dists, 0, n - 1); - this._hullStart = i0; - let hullSize = 3; - hullNext[i0] = hullPrev[i2] = i1; - hullNext[i1] = hullPrev[i0] = i2; - hullNext[i2] = hullPrev[i1] = i0; - hullTri[i0] = 0; - hullTri[i1] = 1; - hullTri[i2] = 2; - hullHash.fill(-1); - hullHash[this._hashKey(i0x, i0y)] = i0; - hullHash[this._hashKey(i1x, i1y)] = i1; - hullHash[this._hashKey(i2x, i2y)] = i2; - this.trianglesLen = 0; - this._addTriangle(i0, i1, i2, -1, -1, -1); - for (let k2 = 0, xp, yp; k2 < this._ids.length; k2++) { - const i = this._ids[k2]; - const x2 = coords[2 * i]; - const y2 = coords[2 * i + 1]; - if (k2 > 0 && Math.abs(x2 - xp) <= EPSILON && Math.abs(y2 - yp) <= EPSILON) - continue; - xp = x2; - yp = y2; - if (i === i0 || i === i1 || i === i2) - continue; - let start2 = 0; - for (let j = 0, key = this._hashKey(x2, y2); j < this._hashSize; j++) { - start2 = hullHash[(key + j) % this._hashSize]; - if (start2 !== -1 && start2 !== hullNext[start2]) - break; - } - start2 = hullPrev[start2]; - let e = start2, q; - while (q = hullNext[e], orient2d(x2, y2, coords[2 * e], coords[2 * e + 1], coords[2 * q], coords[2 * q + 1]) >= 0) { - e = q; - if (e === start2) { - e = -1; - break; - } - } - if (e === -1) - continue; - let t = this._addTriangle(e, i, hullNext[e], -1, -1, hullTri[e]); - hullTri[i] = this._legalize(t + 2); - hullTri[e] = t; - hullSize++; - let n2 = hullNext[e]; - while (q = hullNext[n2], orient2d(x2, y2, coords[2 * n2], coords[2 * n2 + 1], coords[2 * q], coords[2 * q + 1]) < 0) { - t = this._addTriangle(n2, i, q, hullTri[i], -1, hullTri[n2]); - hullTri[i] = this._legalize(t + 2); - hullNext[n2] = n2; - hullSize--; - n2 = q; - } - if (e === start2) { - while (q = hullPrev[e], orient2d(x2, y2, coords[2 * q], coords[2 * q + 1], coords[2 * e], coords[2 * e + 1]) < 0) { - t = this._addTriangle(q, i, e, -1, hullTri[e], hullTri[q]); - this._legalize(t + 2); - hullTri[q] = t; - hullNext[e] = e; - hullSize--; - e = q; - } - } - this._hullStart = hullPrev[i] = e; - hullNext[e] = hullPrev[n2] = i; - hullNext[i] = n2; - hullHash[this._hashKey(x2, y2)] = i; - hullHash[this._hashKey(coords[2 * e], coords[2 * e + 1])] = e; - } - this.hull = new Uint32Array(hullSize); - for (let i = 0, e = this._hullStart; i < hullSize; i++) { - this.hull[i] = e; - e = hullNext[e]; - } - this.triangles = this._triangles.subarray(0, this.trianglesLen); - this.halfedges = this._halfedges.subarray(0, this.trianglesLen); - } - _hashKey(x2, y2) { - return Math.floor(pseudoAngle(x2 - this._cx, y2 - this._cy) * this._hashSize) % this._hashSize; - } - _legalize(a2) { - const { _triangles: triangles, _halfedges: halfedges, coords } = this; - let i = 0; - let ar = 0; - while (true) { - const b = halfedges[a2]; - const a0 = a2 - a2 % 3; - ar = a0 + (a2 + 2) % 3; - if (b === -1) { - if (i === 0) - break; - a2 = EDGE_STACK[--i]; - continue; - } - const b02 = b - b % 3; - const al = a0 + (a2 + 1) % 3; - const bl = b02 + (b + 2) % 3; - const p02 = triangles[ar]; - const pr = triangles[a2]; - const pl = triangles[al]; - const p1 = triangles[bl]; - const illegal = inCircle( - coords[2 * p02], - coords[2 * p02 + 1], - coords[2 * pr], - coords[2 * pr + 1], - coords[2 * pl], - coords[2 * pl + 1], - coords[2 * p1], - coords[2 * p1 + 1] - ); - if (illegal) { - triangles[a2] = p1; - triangles[b] = p02; - const hbl = halfedges[bl]; - if (hbl === -1) { - let e = this._hullStart; - do { - if (this._hullTri[e] === bl) { - this._hullTri[e] = a2; - break; - } - e = this._hullPrev[e]; - } while (e !== this._hullStart); - } - this._link(a2, hbl); - this._link(b, halfedges[ar]); - this._link(ar, bl); - const br = b02 + (b + 1) % 3; - if (i < EDGE_STACK.length) { - EDGE_STACK[i++] = br; - } - } else { - if (i === 0) - break; - a2 = EDGE_STACK[--i]; - } - } - return ar; - } - _link(a2, b) { - this._halfedges[a2] = b; - if (b !== -1) - this._halfedges[b] = a2; - } - _addTriangle(i0, i1, i2, a2, b, c2) { - const t = this.trianglesLen; - this._triangles[t] = i0; - this._triangles[t + 1] = i1; - this._triangles[t + 2] = i2; - this._link(t, a2); - this._link(t + 1, b); - this._link(t + 2, c2); - this.trianglesLen += 3; - return t; - } - } - function pseudoAngle(dx, dy) { - const p = dx / (Math.abs(dx) + Math.abs(dy)); - return (dy > 0 ? 3 - p : 1 + p) / 4; - } - function dist(ax, ay, bx, by) { - const dx = ax - bx; - const dy = ay - by; - return dx * dx + dy * dy; - } - function inCircle(ax, ay, bx, by, cx, cy, px, py) { - const dx = ax - px; - const dy = ay - py; - const ex = bx - px; - const ey = by - py; - const fx = cx - px; - const fy = cy - py; - const ap = dx * dx + dy * dy; - const bp = ex * ex + ey * ey; - const cp = fx * fx + fy * fy; - return dx * (ey * cp - bp * fy) - dy * (ex * cp - bp * fx) + ap * (ex * fy - ey * fx) < 0; - } - function circumradius(ax, ay, bx, by, cx, cy) { - const dx = bx - ax; - const dy = by - ay; - const ex = cx - ax; - const ey = cy - ay; - const bl = dx * dx + dy * dy; - const cl = ex * ex + ey * ey; - const d = 0.5 / (dx * ey - dy * ex); - const x2 = (ey * bl - dy * cl) * d; - const y2 = (dx * cl - ex * bl) * d; - return x2 * x2 + y2 * y2; - } - function circumcenter(ax, ay, bx, by, cx, cy) { - const dx = bx - ax; - const dy = by - ay; - const ex = cx - ax; - const ey = cy - ay; - const bl = dx * dx + dy * dy; - const cl = ex * ex + ey * ey; - const d = 0.5 / (dx * ey - dy * ex); - const x2 = ax + (ey * bl - dy * cl) * d; - const y2 = ay + (dx * cl - ex * bl) * d; - return { x: x2, y: y2 }; - } - function quicksort(ids, dists, left2, right2) { - if (right2 - left2 <= 20) { - for (let i = left2 + 1; i <= right2; i++) { - const temp = ids[i]; - const tempDist = dists[temp]; - let j = i - 1; - while (j >= left2 && dists[ids[j]] > tempDist) - ids[j + 1] = ids[j--]; - ids[j + 1] = temp; - } - } else { - const median2 = left2 + right2 >> 1; - let i = left2 + 1; - let j = right2; - swap(ids, median2, i); - if (dists[ids[left2]] > dists[ids[right2]]) - swap(ids, left2, right2); - if (dists[ids[i]] > dists[ids[right2]]) - swap(ids, i, right2); - if (dists[ids[left2]] > dists[ids[i]]) - swap(ids, left2, i); - const temp = ids[i]; - const tempDist = dists[temp]; - while (true) { - do - i++; - while (dists[ids[i]] < tempDist); - do - j--; - while (dists[ids[j]] > tempDist); - if (j < i) - break; - swap(ids, i, j); - } - ids[left2 + 1] = ids[j]; - ids[j] = temp; - if (right2 - i + 1 >= j - left2) { - quicksort(ids, dists, i, right2); - quicksort(ids, dists, left2, j - 1); - } else { - quicksort(ids, dists, left2, j - 1); - quicksort(ids, dists, i, right2); - } - } - } - function swap(arr, i, j) { - const tmp = arr[i]; - arr[i] = arr[j]; - arr[j] = tmp; - } - function defaultGetX(p) { - return p[0]; - } - function defaultGetY(p) { - return p[1]; - } - const epsilon$2 = 1e-6; - class Path { - constructor() { - this._x0 = this._y0 = this._x1 = this._y1 = null; - this._ = ""; - } - moveTo(x2, y2) { - this._ += `M${this._x0 = this._x1 = +x2},${this._y0 = this._y1 = +y2}`; - } - closePath() { - if (this._x1 !== null) { - this._x1 = this._x0, this._y1 = this._y0; - this._ += "Z"; - } - } - lineTo(x2, y2) { - this._ += `L${this._x1 = +x2},${this._y1 = +y2}`; - } - arc(x2, y2, r) { - x2 = +x2, y2 = +y2, r = +r; - const x02 = x2 + r; - const y02 = y2; - if (r < 0) - throw new Error("negative radius"); - if (this._x1 === null) - this._ += `M${x02},${y02}`; - else if (Math.abs(this._x1 - x02) > epsilon$2 || Math.abs(this._y1 - y02) > epsilon$2) - this._ += "L" + x02 + "," + y02; - if (!r) - return; - this._ += `A${r},${r},0,1,1,${x2 - r},${y2}A${r},${r},0,1,1,${this._x1 = x02},${this._y1 = y02}`; - } - rect(x2, y2, w2, h) { - this._ += `M${this._x0 = this._x1 = +x2},${this._y0 = this._y1 = +y2}h${+w2}v${+h}h${-w2}Z`; - } - value() { - return this._ || null; - } - } - class Polygon { - constructor() { - this._ = []; - } - moveTo(x2, y2) { - this._.push([x2, y2]); - } - closePath() { - this._.push(this._[0].slice()); - } - lineTo(x2, y2) { - this._.push([x2, y2]); - } - value() { - return this._.length ? this._ : null; - } - } - class Voronoi { - constructor(delaunay, [xmin, ymin, xmax, ymax] = [0, 0, 960, 500]) { - if (!((xmax = +xmax) >= (xmin = +xmin)) || !((ymax = +ymax) >= (ymin = +ymin))) - throw new Error("invalid bounds"); - this.delaunay = delaunay; - this._circumcenters = new Float64Array(delaunay.points.length * 2); - this.vectors = new Float64Array(delaunay.points.length * 2); - this.xmax = xmax, this.xmin = xmin; - this.ymax = ymax, this.ymin = ymin; - this._init(); - } - update() { - this.delaunay.update(); - this._init(); - return this; - } - _init() { - const { delaunay: { points, hull: hull2, triangles }, vectors } = this; - const circumcenters = this.circumcenters = this._circumcenters.subarray(0, triangles.length / 3 * 2); - for (let i = 0, j = 0, n = triangles.length, x2, y2; i < n; i += 3, j += 2) { - const t12 = triangles[i] * 2; - const t22 = triangles[i + 1] * 2; - const t32 = triangles[i + 2] * 2; - const x13 = points[t12]; - const y13 = points[t12 + 1]; - const x22 = points[t22]; - const y22 = points[t22 + 1]; - const x3 = points[t32]; - const y3 = points[t32 + 1]; - const dx = x22 - x13; - const dy = y22 - y13; - const ex = x3 - x13; - const ey = y3 - y13; - const ab = (dx * ey - dy * ex) * 2; - if (Math.abs(ab) < 1e-9) { - let a2 = 1e9; - const r = triangles[0] * 2; - a2 *= Math.sign((points[r] - x13) * ey - (points[r + 1] - y13) * ex); - x2 = (x13 + x3) / 2 - a2 * ey; - y2 = (y13 + y3) / 2 + a2 * ex; - } else { - const d = 1 / ab; - const bl = dx * dx + dy * dy; - const cl = ex * ex + ey * ey; - x2 = x13 + (ey * bl - dy * cl) * d; - y2 = y13 + (dx * cl - ex * bl) * d; - } - circumcenters[j] = x2; - circumcenters[j + 1] = y2; - } - let h = hull2[hull2.length - 1]; - let p02, p1 = h * 4; - let x02, x12 = points[2 * h]; - let y02, y12 = points[2 * h + 1]; - vectors.fill(0); - for (let i = 0; i < hull2.length; ++i) { - h = hull2[i]; - p02 = p1, x02 = x12, y02 = y12; - p1 = h * 4, x12 = points[2 * h], y12 = points[2 * h + 1]; - vectors[p02 + 2] = vectors[p1] = y02 - y12; - vectors[p02 + 3] = vectors[p1 + 1] = x12 - x02; - } - } - render(context) { - const buffer2 = context == null ? context = new Path() : void 0; - const { delaunay: { halfedges, inedges, hull: hull2 }, circumcenters, vectors } = this; - if (hull2.length <= 1) - return null; - for (let i = 0, n = halfedges.length; i < n; ++i) { - const j = halfedges[i]; - if (j < i) - continue; - const ti = Math.floor(i / 3) * 2; - const tj = Math.floor(j / 3) * 2; - const xi = circumcenters[ti]; - const yi = circumcenters[ti + 1]; - const xj = circumcenters[tj]; - const yj = circumcenters[tj + 1]; - this._renderSegment(xi, yi, xj, yj, context); - } - let h0, h1 = hull2[hull2.length - 1]; - for (let i = 0; i < hull2.length; ++i) { - h0 = h1, h1 = hull2[i]; - const t = Math.floor(inedges[h1] / 3) * 2; - const x2 = circumcenters[t]; - const y2 = circumcenters[t + 1]; - const v = h0 * 4; - const p = this._project(x2, y2, vectors[v + 2], vectors[v + 3]); - if (p) - this._renderSegment(x2, y2, p[0], p[1], context); - } - return buffer2 && buffer2.value(); - } - renderBounds(context) { - const buffer2 = context == null ? context = new Path() : void 0; - context.rect(this.xmin, this.ymin, this.xmax - this.xmin, this.ymax - this.ymin); - return buffer2 && buffer2.value(); - } - renderCell(i, context) { - const buffer2 = context == null ? context = new Path() : void 0; - const points = this._clip(i); - if (points === null || !points.length) - return; - context.moveTo(points[0], points[1]); - let n = points.length; - while (points[0] === points[n - 2] && points[1] === points[n - 1] && n > 1) - n -= 2; - for (let i2 = 2; i2 < n; i2 += 2) { - if (points[i2] !== points[i2 - 2] || points[i2 + 1] !== points[i2 - 1]) - context.lineTo(points[i2], points[i2 + 1]); - } - context.closePath(); - return buffer2 && buffer2.value(); - } - *cellPolygons() { - const { delaunay: { points } } = this; - for (let i = 0, n = points.length / 2; i < n; ++i) { - const cell = this.cellPolygon(i); - if (cell) - cell.index = i, yield cell; - } - } - cellPolygon(i) { - const polygon = new Polygon(); - this.renderCell(i, polygon); - return polygon.value(); - } - _renderSegment(x02, y02, x12, y12, context) { - let S; - const c0 = this._regioncode(x02, y02); - const c1 = this._regioncode(x12, y12); - if (c0 === 0 && c1 === 0) { - context.moveTo(x02, y02); - context.lineTo(x12, y12); - } else if (S = this._clipSegment(x02, y02, x12, y12, c0, c1)) { - context.moveTo(S[0], S[1]); - context.lineTo(S[2], S[3]); - } - } - contains(i, x2, y2) { - if ((x2 = +x2, x2 !== x2) || (y2 = +y2, y2 !== y2)) - return false; - return this.delaunay._step(i, x2, y2) === i; - } - *neighbors(i) { - const ci = this._clip(i); - if (ci) - for (const j of this.delaunay.neighbors(i)) { - const cj = this._clip(j); - if (cj) - loop: - for (let ai = 0, li = ci.length; ai < li; ai += 2) { - for (let aj = 0, lj = cj.length; aj < lj; aj += 2) { - if (ci[ai] == cj[aj] && ci[ai + 1] == cj[aj + 1] && ci[(ai + 2) % li] == cj[(aj + lj - 2) % lj] && ci[(ai + 3) % li] == cj[(aj + lj - 1) % lj]) { - yield j; - break loop; - } - } - } - } - } - _cell(i) { - const { circumcenters, delaunay: { inedges, halfedges, triangles } } = this; - const e0 = inedges[i]; - if (e0 === -1) - return null; - const points = []; - let e = e0; - do { - const t = Math.floor(e / 3); - points.push(circumcenters[t * 2], circumcenters[t * 2 + 1]); - e = e % 3 === 2 ? e - 2 : e + 1; - if (triangles[e] !== i) - break; - e = halfedges[e]; - } while (e !== e0 && e !== -1); - return points; - } - _clip(i) { - if (i === 0 && this.delaunay.hull.length === 1) { - return [this.xmax, this.ymin, this.xmax, this.ymax, this.xmin, this.ymax, this.xmin, this.ymin]; - } - const points = this._cell(i); - if (points === null) - return null; - const { vectors: V } = this; - const v = i * 4; - return V[v] || V[v + 1] ? this._clipInfinite(i, points, V[v], V[v + 1], V[v + 2], V[v + 3]) : this._clipFinite(i, points); - } - _clipFinite(i, points) { - const n = points.length; - let P = null; - let x02, y02, x12 = points[n - 2], y12 = points[n - 1]; - let c0, c1 = this._regioncode(x12, y12); - let e0, e1 = 0; - for (let j = 0; j < n; j += 2) { - x02 = x12, y02 = y12, x12 = points[j], y12 = points[j + 1]; - c0 = c1, c1 = this._regioncode(x12, y12); - if (c0 === 0 && c1 === 0) { - e0 = e1, e1 = 0; - if (P) - P.push(x12, y12); - else - P = [x12, y12]; - } else { - let S, sx0, sy0, sx1, sy1; - if (c0 === 0) { - if ((S = this._clipSegment(x02, y02, x12, y12, c0, c1)) === null) - continue; - [sx0, sy0, sx1, sy1] = S; - } else { - if ((S = this._clipSegment(x12, y12, x02, y02, c1, c0)) === null) - continue; - [sx1, sy1, sx0, sy0] = S; - e0 = e1, e1 = this._edgecode(sx0, sy0); - if (e0 && e1) - this._edge(i, e0, e1, P, P.length); - if (P) - P.push(sx0, sy0); - else - P = [sx0, sy0]; - } - e0 = e1, e1 = this._edgecode(sx1, sy1); - if (e0 && e1) - this._edge(i, e0, e1, P, P.length); - if (P) - P.push(sx1, sy1); - else - P = [sx1, sy1]; - } - } - if (P) { - e0 = e1, e1 = this._edgecode(P[0], P[1]); - if (e0 && e1) - this._edge(i, e0, e1, P, P.length); - } else if (this.contains(i, (this.xmin + this.xmax) / 2, (this.ymin + this.ymax) / 2)) { - return [this.xmax, this.ymin, this.xmax, this.ymax, this.xmin, this.ymax, this.xmin, this.ymin]; - } - return P; - } - _clipSegment(x02, y02, x12, y12, c0, c1) { - while (true) { - if (c0 === 0 && c1 === 0) - return [x02, y02, x12, y12]; - if (c0 & c1) - return null; - let x2, y2, c2 = c0 || c1; - if (c2 & 8) - x2 = x02 + (x12 - x02) * (this.ymax - y02) / (y12 - y02), y2 = this.ymax; - else if (c2 & 4) - x2 = x02 + (x12 - x02) * (this.ymin - y02) / (y12 - y02), y2 = this.ymin; - else if (c2 & 2) - y2 = y02 + (y12 - y02) * (this.xmax - x02) / (x12 - x02), x2 = this.xmax; - else - y2 = y02 + (y12 - y02) * (this.xmin - x02) / (x12 - x02), x2 = this.xmin; - if (c0) - x02 = x2, y02 = y2, c0 = this._regioncode(x02, y02); - else - x12 = x2, y12 = y2, c1 = this._regioncode(x12, y12); - } - } - _clipInfinite(i, points, vx0, vy0, vxn, vyn) { - let P = Array.from(points), p; - if (p = this._project(P[0], P[1], vx0, vy0)) - P.unshift(p[0], p[1]); - if (p = this._project(P[P.length - 2], P[P.length - 1], vxn, vyn)) - P.push(p[0], p[1]); - if (P = this._clipFinite(i, P)) { - for (let j = 0, n = P.length, c0, c1 = this._edgecode(P[n - 2], P[n - 1]); j < n; j += 2) { - c0 = c1, c1 = this._edgecode(P[j], P[j + 1]); - if (c0 && c1) - j = this._edge(i, c0, c1, P, j), n = P.length; - } - } else if (this.contains(i, (this.xmin + this.xmax) / 2, (this.ymin + this.ymax) / 2)) { - P = [this.xmin, this.ymin, this.xmax, this.ymin, this.xmax, this.ymax, this.xmin, this.ymax]; - } - return P; - } - _edge(i, e0, e1, P, j) { - while (e0 !== e1) { - let x2, y2; - switch (e0) { - case 5: - e0 = 4; - continue; - case 4: - e0 = 6, x2 = this.xmax, y2 = this.ymin; - break; - case 6: - e0 = 2; - continue; - case 2: - e0 = 10, x2 = this.xmax, y2 = this.ymax; - break; - case 10: - e0 = 8; - continue; - case 8: - e0 = 9, x2 = this.xmin, y2 = this.ymax; - break; - case 9: - e0 = 1; - continue; - case 1: - e0 = 5, x2 = this.xmin, y2 = this.ymin; - break; - } - if ((P[j] !== x2 || P[j + 1] !== y2) && this.contains(i, x2, y2)) { - P.splice(j, 0, x2, y2), j += 2; - } - } - if (P.length > 4) { - for (let i2 = 0; i2 < P.length; i2 += 2) { - const j2 = (i2 + 2) % P.length, k2 = (i2 + 4) % P.length; - if (P[i2] === P[j2] && P[j2] === P[k2] || P[i2 + 1] === P[j2 + 1] && P[j2 + 1] === P[k2 + 1]) - P.splice(j2, 2), i2 -= 2; - } - } - return j; - } - _project(x02, y02, vx, vy) { - let t = Infinity, c2, x2, y2; - if (vy < 0) { - if (y02 <= this.ymin) - return null; - if ((c2 = (this.ymin - y02) / vy) < t) - y2 = this.ymin, x2 = x02 + (t = c2) * vx; - } else if (vy > 0) { - if (y02 >= this.ymax) - return null; - if ((c2 = (this.ymax - y02) / vy) < t) - y2 = this.ymax, x2 = x02 + (t = c2) * vx; - } - if (vx > 0) { - if (x02 >= this.xmax) - return null; - if ((c2 = (this.xmax - x02) / vx) < t) - x2 = this.xmax, y2 = y02 + (t = c2) * vy; - } else if (vx < 0) { - if (x02 <= this.xmin) - return null; - if ((c2 = (this.xmin - x02) / vx) < t) - x2 = this.xmin, y2 = y02 + (t = c2) * vy; - } - return [x2, y2]; - } - _edgecode(x2, y2) { - return (x2 === this.xmin ? 1 : x2 === this.xmax ? 2 : 0) | (y2 === this.ymin ? 4 : y2 === this.ymax ? 8 : 0); - } - _regioncode(x2, y2) { - return (x2 < this.xmin ? 1 : x2 > this.xmax ? 2 : 0) | (y2 < this.ymin ? 4 : y2 > this.ymax ? 8 : 0); - } - } - const tau$2 = 2 * Math.PI, pow$2 = Math.pow; - function pointX(p) { - return p[0]; - } - function pointY(p) { - return p[1]; - } - function collinear(d) { - const { triangles, coords } = d; - for (let i = 0; i < triangles.length; i += 3) { - const a2 = 2 * triangles[i], b = 2 * triangles[i + 1], c2 = 2 * triangles[i + 2], cross2 = (coords[c2] - coords[a2]) * (coords[b + 1] - coords[a2 + 1]) - (coords[b] - coords[a2]) * (coords[c2 + 1] - coords[a2 + 1]); - if (cross2 > 1e-10) - return false; - } - return true; - } - function jitter(x2, y2, r) { - return [x2 + Math.sin(x2 + y2) * r, y2 + Math.cos(x2 - y2) * r]; - } - class Delaunay { - static from(points, fx = pointX, fy = pointY, that) { - return new Delaunay("length" in points ? flatArray(points, fx, fy, that) : Float64Array.from(flatIterable(points, fx, fy, that))); - } - constructor(points) { - this._delaunator = new Delaunator(points); - this.inedges = new Int32Array(points.length / 2); - this._hullIndex = new Int32Array(points.length / 2); - this.points = this._delaunator.coords; - this._init(); - } - update() { - this._delaunator.update(); - this._init(); - return this; - } - _init() { - const d = this._delaunator, points = this.points; - if (d.hull && d.hull.length > 2 && collinear(d)) { - this.collinear = Int32Array.from({ length: points.length / 2 }, (_2, i) => i).sort((i, j) => points[2 * i] - points[2 * j] || points[2 * i + 1] - points[2 * j + 1]); - const e = this.collinear[0], f = this.collinear[this.collinear.length - 1], bounds2 = [points[2 * e], points[2 * e + 1], points[2 * f], points[2 * f + 1]], r = 1e-8 * Math.hypot(bounds2[3] - bounds2[1], bounds2[2] - bounds2[0]); - for (let i = 0, n = points.length / 2; i < n; ++i) { - const p = jitter(points[2 * i], points[2 * i + 1], r); - points[2 * i] = p[0]; - points[2 * i + 1] = p[1]; - } - this._delaunator = new Delaunator(points); - } else { - delete this.collinear; - } - const halfedges = this.halfedges = this._delaunator.halfedges; - const hull2 = this.hull = this._delaunator.hull; - const triangles = this.triangles = this._delaunator.triangles; - const inedges = this.inedges.fill(-1); - const hullIndex = this._hullIndex.fill(-1); - for (let e = 0, n = halfedges.length; e < n; ++e) { - const p = triangles[e % 3 === 2 ? e - 2 : e + 1]; - if (halfedges[e] === -1 || inedges[p] === -1) - inedges[p] = e; - } - for (let i = 0, n = hull2.length; i < n; ++i) { - hullIndex[hull2[i]] = i; - } - if (hull2.length <= 2 && hull2.length > 0) { - this.triangles = new Int32Array(3).fill(-1); - this.halfedges = new Int32Array(3).fill(-1); - this.triangles[0] = hull2[0]; - inedges[hull2[0]] = 1; - if (hull2.length === 2) { - inedges[hull2[1]] = 0; - this.triangles[1] = hull2[1]; - this.triangles[2] = hull2[1]; - } - } - } - voronoi(bounds2) { - return new Voronoi(this, bounds2); - } - *neighbors(i) { - const { inedges, hull: hull2, _hullIndex, halfedges, triangles, collinear: collinear2 } = this; - if (collinear2) { - const l = collinear2.indexOf(i); - if (l > 0) - yield collinear2[l - 1]; - if (l < collinear2.length - 1) - yield collinear2[l + 1]; - return; - } - const e0 = inedges[i]; - if (e0 === -1) - return; - let e = e0, p02 = -1; - do { - yield p02 = triangles[e]; - e = e % 3 === 2 ? e - 2 : e + 1; - if (triangles[e] !== i) - return; - e = halfedges[e]; - if (e === -1) { - const p = hull2[(_hullIndex[i] + 1) % hull2.length]; - if (p !== p02) - yield p; - return; - } - } while (e !== e0); - } - find(x2, y2, i = 0) { - if ((x2 = +x2, x2 !== x2) || (y2 = +y2, y2 !== y2)) - return -1; - const i0 = i; - let c2; - while ((c2 = this._step(i, x2, y2)) >= 0 && c2 !== i && c2 !== i0) - i = c2; - return c2; - } - _step(i, x2, y2) { - const { inedges, hull: hull2, _hullIndex, halfedges, triangles, points } = this; - if (inedges[i] === -1 || !points.length) - return (i + 1) % (points.length >> 1); - let c2 = i; - let dc = pow$2(x2 - points[i * 2], 2) + pow$2(y2 - points[i * 2 + 1], 2); - const e0 = inedges[i]; - let e = e0; - do { - let t = triangles[e]; - const dt = pow$2(x2 - points[t * 2], 2) + pow$2(y2 - points[t * 2 + 1], 2); - if (dt < dc) - dc = dt, c2 = t; - e = e % 3 === 2 ? e - 2 : e + 1; - if (triangles[e] !== i) - break; - e = halfedges[e]; - if (e === -1) { - e = hull2[(_hullIndex[i] + 1) % hull2.length]; - if (e !== t) { - if (pow$2(x2 - points[e * 2], 2) + pow$2(y2 - points[e * 2 + 1], 2) < dc) - return e; - } - break; - } - } while (e !== e0); - return c2; - } - render(context) { - const buffer2 = context == null ? context = new Path() : void 0; - const { points, halfedges, triangles } = this; - for (let i = 0, n = halfedges.length; i < n; ++i) { - const j = halfedges[i]; - if (j < i) - continue; - const ti = triangles[i] * 2; - const tj = triangles[j] * 2; - context.moveTo(points[ti], points[ti + 1]); - context.lineTo(points[tj], points[tj + 1]); - } - this.renderHull(context); - return buffer2 && buffer2.value(); - } - renderPoints(context, r) { - if (r === void 0 && (!context || typeof context.moveTo !== "function")) - r = context, context = null; - r = r == void 0 ? 2 : +r; - const buffer2 = context == null ? context = new Path() : void 0; - const { points } = this; - for (let i = 0, n = points.length; i < n; i += 2) { - const x2 = points[i], y2 = points[i + 1]; - context.moveTo(x2 + r, y2); - context.arc(x2, y2, r, 0, tau$2); - } - return buffer2 && buffer2.value(); - } - renderHull(context) { - const buffer2 = context == null ? context = new Path() : void 0; - const { hull: hull2, points } = this; - const h = hull2[0] * 2, n = hull2.length; - context.moveTo(points[h], points[h + 1]); - for (let i = 1; i < n; ++i) { - const h2 = 2 * hull2[i]; - context.lineTo(points[h2], points[h2 + 1]); - } - context.closePath(); - return buffer2 && buffer2.value(); - } - hullPolygon() { - const polygon = new Polygon(); - this.renderHull(polygon); - return polygon.value(); - } - renderTriangle(i, context) { - const buffer2 = context == null ? context = new Path() : void 0; - const { points, triangles } = this; - const t02 = triangles[i *= 3] * 2; - const t12 = triangles[i + 1] * 2; - const t22 = triangles[i + 2] * 2; - context.moveTo(points[t02], points[t02 + 1]); - context.lineTo(points[t12], points[t12 + 1]); - context.lineTo(points[t22], points[t22 + 1]); - context.closePath(); - return buffer2 && buffer2.value(); - } - *trianglePolygons() { - const { triangles } = this; - for (let i = 0, n = triangles.length / 3; i < n; ++i) { - yield this.trianglePolygon(i); - } - } - trianglePolygon(i) { - const polygon = new Polygon(); - this.renderTriangle(i, polygon); - return polygon.value(); - } - } - function flatArray(points, fx, fy, that) { - const n = points.length; - const array2 = new Float64Array(n * 2); - for (let i = 0; i < n; ++i) { - const p = points[i]; - array2[i * 2] = fx.call(that, p, i, points); - array2[i * 2 + 1] = fy.call(that, p, i, points); - } - return array2; - } - function* flatIterable(points, fx, fy, that) { - let i = 0; - for (const p of points) { - yield fx.call(that, p, i, points); - yield fy.call(that, p, i, points); - ++i; - } - } - var EOL = {}, EOF = {}, QUOTE = 34, NEWLINE = 10, RETURN = 13; - function objectConverter(columns) { - return new Function("d", "return {" + columns.map(function(name2, i) { - return JSON.stringify(name2) + ": d[" + i + '] || ""'; - }).join(",") + "}"); - } - function customConverter(columns, f) { - var object2 = objectConverter(columns); - return function(row, i) { - return f(object2(row), i, columns); - }; - } - function inferColumns(rows) { - var columnSet = /* @__PURE__ */ Object.create(null), columns = []; - rows.forEach(function(row) { - for (var column2 in row) { - if (!(column2 in columnSet)) { - columns.push(columnSet[column2] = column2); - } - } - }); - return columns; - } - function pad$1(value, width2) { - var s2 = value + "", length2 = s2.length; - return length2 < width2 ? new Array(width2 - length2 + 1).join(0) + s2 : s2; - } - function formatYear$1(year2) { - return year2 < 0 ? "-" + pad$1(-year2, 6) : year2 > 9999 ? "+" + pad$1(year2, 6) : pad$1(year2, 4); - } - function formatDate(date2) { - var hours2 = date2.getUTCHours(), minutes2 = date2.getUTCMinutes(), seconds2 = date2.getUTCSeconds(), milliseconds2 = date2.getUTCMilliseconds(); - return isNaN(date2) ? "Invalid Date" : formatYear$1(date2.getUTCFullYear()) + "-" + pad$1(date2.getUTCMonth() + 1, 2) + "-" + pad$1(date2.getUTCDate(), 2) + (milliseconds2 ? "T" + pad$1(hours2, 2) + ":" + pad$1(minutes2, 2) + ":" + pad$1(seconds2, 2) + "." + pad$1(milliseconds2, 3) + "Z" : seconds2 ? "T" + pad$1(hours2, 2) + ":" + pad$1(minutes2, 2) + ":" + pad$1(seconds2, 2) + "Z" : minutes2 || hours2 ? "T" + pad$1(hours2, 2) + ":" + pad$1(minutes2, 2) + "Z" : ""); - } - function dsvFormat(delimiter2) { - var reFormat = new RegExp('["' + delimiter2 + "\n\r]"), DELIMITER = delimiter2.charCodeAt(0); - function parse2(text2, f) { - var convert, columns, rows = parseRows(text2, function(row, i) { - if (convert) - return convert(row, i - 1); - columns = row, convert = f ? customConverter(row, f) : objectConverter(row); - }); - rows.columns = columns || []; - return rows; - } - function parseRows(text2, f) { - var rows = [], N = text2.length, I = 0, n = 0, t, eof = N <= 0, eol = false; - if (text2.charCodeAt(N - 1) === NEWLINE) - --N; - if (text2.charCodeAt(N - 1) === RETURN) - --N; - function token2() { - if (eof) - return EOF; - if (eol) - return eol = false, EOL; - var i, j = I, c2; - if (text2.charCodeAt(j) === QUOTE) { - while (I++ < N && text2.charCodeAt(I) !== QUOTE || text2.charCodeAt(++I) === QUOTE) - ; - if ((i = I) >= N) - eof = true; - else if ((c2 = text2.charCodeAt(I++)) === NEWLINE) - eol = true; - else if (c2 === RETURN) { - eol = true; - if (text2.charCodeAt(I) === NEWLINE) - ++I; - } - return text2.slice(j + 1, i - 1).replace(/""/g, '"'); - } - while (I < N) { - if ((c2 = text2.charCodeAt(i = I++)) === NEWLINE) - eol = true; - else if (c2 === RETURN) { - eol = true; - if (text2.charCodeAt(I) === NEWLINE) - ++I; - } else if (c2 !== DELIMITER) - continue; - return text2.slice(j, i); - } - return eof = true, text2.slice(j, N); - } - while ((t = token2()) !== EOF) { - var row = []; - while (t !== EOL && t !== EOF) - row.push(t), t = token2(); - if (f && (row = f(row, n++)) == null) - continue; - rows.push(row); - } - return rows; - } - function preformatBody(rows, columns) { - return rows.map(function(row) { - return columns.map(function(column2) { - return formatValue(row[column2]); - }).join(delimiter2); - }); - } - function format2(rows, columns) { - if (columns == null) - columns = inferColumns(rows); - return [columns.map(formatValue).join(delimiter2)].concat(preformatBody(rows, columns)).join("\n"); - } - function formatBody(rows, columns) { - if (columns == null) - columns = inferColumns(rows); - return preformatBody(rows, columns).join("\n"); - } - function formatRows(rows) { - return rows.map(formatRow).join("\n"); - } - function formatRow(row) { - return row.map(formatValue).join(delimiter2); - } - function formatValue(value) { - return value == null ? "" : value instanceof Date ? formatDate(value) : reFormat.test(value += "") ? '"' + value.replace(/"/g, '""') + '"' : value; - } - return { - parse: parse2, - parseRows, - format: format2, - formatBody, - formatRows, - formatRow, - formatValue - }; - } - var csv$1 = dsvFormat(","); - var csvParse = csv$1.parse; - var csvParseRows = csv$1.parseRows; - var csvFormat = csv$1.format; - var csvFormatBody = csv$1.formatBody; - var csvFormatRows = csv$1.formatRows; - var csvFormatRow = csv$1.formatRow; - var csvFormatValue = csv$1.formatValue; - var tsv$1 = dsvFormat(" "); - var tsvParse = tsv$1.parse; - var tsvParseRows = tsv$1.parseRows; - var tsvFormat = tsv$1.format; - var tsvFormatBody = tsv$1.formatBody; - var tsvFormatRows = tsv$1.formatRows; - var tsvFormatRow = tsv$1.formatRow; - var tsvFormatValue = tsv$1.formatValue; - function autoType(object2) { - for (var key in object2) { - var value = object2[key].trim(), number3, m2; - if (!value) - value = null; - else if (value === "true") - value = true; - else if (value === "false") - value = false; - else if (value === "NaN") - value = NaN; - else if (!isNaN(number3 = +value)) - value = number3; - else if (m2 = value.match(/^([-+]\d{2})?\d{4}(-\d{2}(-\d{2})?)?(T\d{2}:\d{2}(:\d{2}(\.\d{3})?)?(Z|[-+]\d{2}:\d{2})?)?$/)) { - if (fixtz && !!m2[4] && !m2[7]) - value = value.replace(/-/g, "/").replace(/T/, " "); - value = new Date(value); - } else - continue; - object2[key] = value; - } - return object2; - } - const fixtz = new Date("2019-01-01T00:00").getHours() || new Date("2019-07-01T00:00").getHours(); - function responseBlob(response) { - if (!response.ok) - throw new Error(response.status + " " + response.statusText); - return response.blob(); - } - function blob(input, init2) { - return fetch(input, init2).then(responseBlob); - } - function responseArrayBuffer(response) { - if (!response.ok) - throw new Error(response.status + " " + response.statusText); - return response.arrayBuffer(); - } - function buffer(input, init2) { - return fetch(input, init2).then(responseArrayBuffer); - } - function responseText(response) { - if (!response.ok) - throw new Error(response.status + " " + response.statusText); - return response.text(); - } - function text$1(input, init2) { - return fetch(input, init2).then(responseText); - } - function dsvParse(parse2) { - return function(input, init2, row) { - if (arguments.length === 2 && typeof init2 === "function") - row = init2, init2 = void 0; - return text$1(input, init2).then(function(response) { - return parse2(response, row); - }); - }; - } - function dsv(delimiter2, input, init2, row) { - if (arguments.length === 3 && typeof init2 === "function") - row = init2, init2 = void 0; - var format2 = dsvFormat(delimiter2); - return text$1(input, init2).then(function(response) { - return format2.parse(response, row); - }); - } - var csv = dsvParse(csvParse); - var tsv = dsvParse(tsvParse); - function image(input, init2) { - return new Promise(function(resolve, reject) { - var image2 = new Image(); - for (var key in init2) - image2[key] = init2[key]; - image2.onerror = reject; - image2.onload = function() { - resolve(image2); - }; - image2.src = input; - }); - } - function responseJson(response) { - if (!response.ok) - throw new Error(response.status + " " + response.statusText); - if (response.status === 204 || response.status === 205) - return; - return response.json(); - } - function json$1(input, init2) { - return fetch(input, init2).then(responseJson); - } - function parser$c(type2) { - return (input, init2) => text$1(input, init2).then((text2) => new DOMParser().parseFromString(text2, type2)); - } - const xml$1 = parser$c("application/xml"); - var html$2 = parser$c("text/html"); - var svg$2 = parser$c("image/svg+xml"); - function center(x2, y2) { - var nodes, strength = 1; - if (x2 == null) - x2 = 0; - if (y2 == null) - y2 = 0; - function force() { - var i, n = nodes.length, node2, sx = 0, sy = 0; - for (i = 0; i < n; ++i) { - node2 = nodes[i], sx += node2.x, sy += node2.y; - } - for (sx = (sx / n - x2) * strength, sy = (sy / n - y2) * strength, i = 0; i < n; ++i) { - node2 = nodes[i], node2.x -= sx, node2.y -= sy; - } - } - force.initialize = function(_2) { - nodes = _2; - }; - force.x = function(_2) { - return arguments.length ? (x2 = +_2, force) : x2; - }; - force.y = function(_2) { - return arguments.length ? (y2 = +_2, force) : y2; - }; - force.strength = function(_2) { - return arguments.length ? (strength = +_2, force) : strength; - }; - return force; - } - function tree_add(d) { - const x2 = +this._x.call(null, d), y2 = +this._y.call(null, d); - return add(this.cover(x2, y2), x2, y2, d); - } - function add(tree2, x2, y2, d) { - if (isNaN(x2) || isNaN(y2)) - return tree2; - var parent, node2 = tree2._root, leaf = { data: d }, x02 = tree2._x0, y02 = tree2._y0, x12 = tree2._x1, y12 = tree2._y1, xm, ym, xp, yp, right2, bottom2, i, j; - if (!node2) - return tree2._root = leaf, tree2; - while (node2.length) { - if (right2 = x2 >= (xm = (x02 + x12) / 2)) - x02 = xm; - else - x12 = xm; - if (bottom2 = y2 >= (ym = (y02 + y12) / 2)) - y02 = ym; - else - y12 = ym; - if (parent = node2, !(node2 = node2[i = bottom2 << 1 | right2])) - return parent[i] = leaf, tree2; - } - xp = +tree2._x.call(null, node2.data); - yp = +tree2._y.call(null, node2.data); - if (x2 === xp && y2 === yp) - return leaf.next = node2, parent ? parent[i] = leaf : tree2._root = leaf, tree2; - do { - parent = parent ? parent[i] = new Array(4) : tree2._root = new Array(4); - if (right2 = x2 >= (xm = (x02 + x12) / 2)) - x02 = xm; - else - x12 = xm; - if (bottom2 = y2 >= (ym = (y02 + y12) / 2)) - y02 = ym; - else - y12 = ym; - } while ((i = bottom2 << 1 | right2) === (j = (yp >= ym) << 1 | xp >= xm)); - return parent[j] = node2, parent[i] = leaf, tree2; - } - function addAll(data) { - var d, i, n = data.length, x2, y2, xz = new Array(n), yz = new Array(n), x02 = Infinity, y02 = Infinity, x12 = -Infinity, y12 = -Infinity; - for (i = 0; i < n; ++i) { - if (isNaN(x2 = +this._x.call(null, d = data[i])) || isNaN(y2 = +this._y.call(null, d))) - continue; - xz[i] = x2; - yz[i] = y2; - if (x2 < x02) - x02 = x2; - if (x2 > x12) - x12 = x2; - if (y2 < y02) - y02 = y2; - if (y2 > y12) - y12 = y2; - } - if (x02 > x12 || y02 > y12) - return this; - this.cover(x02, y02).cover(x12, y12); - for (i = 0; i < n; ++i) { - add(this, xz[i], yz[i], data[i]); - } - return this; - } - function tree_cover(x2, y2) { - if (isNaN(x2 = +x2) || isNaN(y2 = +y2)) - return this; - var x02 = this._x0, y02 = this._y0, x12 = this._x1, y12 = this._y1; - if (isNaN(x02)) { - x12 = (x02 = Math.floor(x2)) + 1; - y12 = (y02 = Math.floor(y2)) + 1; - } else { - var z = x12 - x02 || 1, node2 = this._root, parent, i; - while (x02 > x2 || x2 >= x12 || y02 > y2 || y2 >= y12) { - i = (y2 < y02) << 1 | x2 < x02; - parent = new Array(4), parent[i] = node2, node2 = parent, z *= 2; - switch (i) { - case 0: - x12 = x02 + z, y12 = y02 + z; - break; - case 1: - x02 = x12 - z, y12 = y02 + z; - break; - case 2: - x12 = x02 + z, y02 = y12 - z; - break; - case 3: - x02 = x12 - z, y02 = y12 - z; - break; - } - } - if (this._root && this._root.length) - this._root = node2; - } - this._x0 = x02; - this._y0 = y02; - this._x1 = x12; - this._y1 = y12; - return this; - } - function tree_data() { - var data = []; - this.visit(function(node2) { - if (!node2.length) - do - data.push(node2.data); - while (node2 = node2.next); - }); - return data; - } - function tree_extent(_2) { - return arguments.length ? this.cover(+_2[0][0], +_2[0][1]).cover(+_2[1][0], +_2[1][1]) : isNaN(this._x0) ? void 0 : [[this._x0, this._y0], [this._x1, this._y1]]; - } - function Quad(node2, x02, y02, x12, y12) { - this.node = node2; - this.x0 = x02; - this.y0 = y02; - this.x1 = x12; - this.y1 = y12; - } - function tree_find(x2, y2, radius) { - var data, x02 = this._x0, y02 = this._y0, x12, y12, x22, y22, x3 = this._x1, y3 = this._y1, quads = [], node2 = this._root, q, i; - if (node2) - quads.push(new Quad(node2, x02, y02, x3, y3)); - if (radius == null) - radius = Infinity; - else { - x02 = x2 - radius, y02 = y2 - radius; - x3 = x2 + radius, y3 = y2 + radius; - radius *= radius; - } - while (q = quads.pop()) { - if (!(node2 = q.node) || (x12 = q.x0) > x3 || (y12 = q.y0) > y3 || (x22 = q.x1) < x02 || (y22 = q.y1) < y02) - continue; - if (node2.length) { - var xm = (x12 + x22) / 2, ym = (y12 + y22) / 2; - quads.push( - new Quad(node2[3], xm, ym, x22, y22), - new Quad(node2[2], x12, ym, xm, y22), - new Quad(node2[1], xm, y12, x22, ym), - new Quad(node2[0], x12, y12, xm, ym) - ); - if (i = (y2 >= ym) << 1 | x2 >= xm) { - q = quads[quads.length - 1]; - quads[quads.length - 1] = quads[quads.length - 1 - i]; - quads[quads.length - 1 - i] = q; - } - } else { - var dx = x2 - +this._x.call(null, node2.data), dy = y2 - +this._y.call(null, node2.data), d2 = dx * dx + dy * dy; - if (d2 < radius) { - var d = Math.sqrt(radius = d2); - x02 = x2 - d, y02 = y2 - d; - x3 = x2 + d, y3 = y2 + d; - data = node2.data; - } - } - } - return data; - } - function tree_remove(d) { - if (isNaN(x2 = +this._x.call(null, d)) || isNaN(y2 = +this._y.call(null, d))) - return this; - var parent, node2 = this._root, retainer, previous, next2, x02 = this._x0, y02 = this._y0, x12 = this._x1, y12 = this._y1, x2, y2, xm, ym, right2, bottom2, i, j; - if (!node2) - return this; - if (node2.length) - while (true) { - if (right2 = x2 >= (xm = (x02 + x12) / 2)) - x02 = xm; - else - x12 = xm; - if (bottom2 = y2 >= (ym = (y02 + y12) / 2)) - y02 = ym; - else - y12 = ym; - if (!(parent = node2, node2 = node2[i = bottom2 << 1 | right2])) - return this; - if (!node2.length) - break; - if (parent[i + 1 & 3] || parent[i + 2 & 3] || parent[i + 3 & 3]) - retainer = parent, j = i; - } - while (node2.data !== d) - if (!(previous = node2, node2 = node2.next)) - return this; - if (next2 = node2.next) - delete node2.next; - if (previous) - return next2 ? previous.next = next2 : delete previous.next, this; - if (!parent) - return this._root = next2, this; - next2 ? parent[i] = next2 : delete parent[i]; - if ((node2 = parent[0] || parent[1] || parent[2] || parent[3]) && node2 === (parent[3] || parent[2] || parent[1] || parent[0]) && !node2.length) { - if (retainer) - retainer[j] = node2; - else - this._root = node2; - } - return this; - } - function removeAll(data) { - for (var i = 0, n = data.length; i < n; ++i) - this.remove(data[i]); - return this; - } - function tree_root() { - return this._root; - } - function tree_size() { - var size = 0; - this.visit(function(node2) { - if (!node2.length) - do - ++size; - while (node2 = node2.next); - }); - return size; - } - function tree_visit(callback) { - var quads = [], q, node2 = this._root, child, x02, y02, x12, y12; - if (node2) - quads.push(new Quad(node2, this._x0, this._y0, this._x1, this._y1)); - while (q = quads.pop()) { - if (!callback(node2 = q.node, x02 = q.x0, y02 = q.y0, x12 = q.x1, y12 = q.y1) && node2.length) { - var xm = (x02 + x12) / 2, ym = (y02 + y12) / 2; - if (child = node2[3]) - quads.push(new Quad(child, xm, ym, x12, y12)); - if (child = node2[2]) - quads.push(new Quad(child, x02, ym, xm, y12)); - if (child = node2[1]) - quads.push(new Quad(child, xm, y02, x12, ym)); - if (child = node2[0]) - quads.push(new Quad(child, x02, y02, xm, ym)); - } - } - return this; - } - function tree_visitAfter(callback) { - var quads = [], next2 = [], q; - if (this._root) - quads.push(new Quad(this._root, this._x0, this._y0, this._x1, this._y1)); - while (q = quads.pop()) { - var node2 = q.node; - if (node2.length) { - var child, x02 = q.x0, y02 = q.y0, x12 = q.x1, y12 = q.y1, xm = (x02 + x12) / 2, ym = (y02 + y12) / 2; - if (child = node2[0]) - quads.push(new Quad(child, x02, y02, xm, ym)); - if (child = node2[1]) - quads.push(new Quad(child, xm, y02, x12, ym)); - if (child = node2[2]) - quads.push(new Quad(child, x02, ym, xm, y12)); - if (child = node2[3]) - quads.push(new Quad(child, xm, ym, x12, y12)); - } - next2.push(q); - } - while (q = next2.pop()) { - callback(q.node, q.x0, q.y0, q.x1, q.y1); - } - return this; - } - function defaultX(d) { - return d[0]; - } - function tree_x(_2) { - return arguments.length ? (this._x = _2, this) : this._x; - } - function defaultY(d) { - return d[1]; - } - function tree_y(_2) { - return arguments.length ? (this._y = _2, this) : this._y; - } - function quadtree(nodes, x2, y2) { - var tree2 = new Quadtree(x2 == null ? defaultX : x2, y2 == null ? defaultY : y2, NaN, NaN, NaN, NaN); - return nodes == null ? tree2 : tree2.addAll(nodes); - } - function Quadtree(x2, y2, x02, y02, x12, y12) { - this._x = x2; - this._y = y2; - this._x0 = x02; - this._y0 = y02; - this._x1 = x12; - this._y1 = y12; - this._root = void 0; - } - function leaf_copy(leaf) { - var copy2 = { data: leaf.data }, next2 = copy2; - while (leaf = leaf.next) - next2 = next2.next = { data: leaf.data }; - return copy2; - } - var treeProto = quadtree.prototype = Quadtree.prototype; - treeProto.copy = function() { - var copy2 = new Quadtree(this._x, this._y, this._x0, this._y0, this._x1, this._y1), node2 = this._root, nodes, child; - if (!node2) - return copy2; - if (!node2.length) - return copy2._root = leaf_copy(node2), copy2; - nodes = [{ source: node2, target: copy2._root = new Array(4) }]; - while (node2 = nodes.pop()) { - for (var i = 0; i < 4; ++i) { - if (child = node2.source[i]) { - if (child.length) - nodes.push({ source: child, target: node2.target[i] = new Array(4) }); - else - node2.target[i] = leaf_copy(child); - } - } - } - return copy2; - }; - treeProto.add = tree_add; - treeProto.addAll = addAll; - treeProto.cover = tree_cover; - treeProto.data = tree_data; - treeProto.extent = tree_extent; - treeProto.find = tree_find; - treeProto.remove = tree_remove; - treeProto.removeAll = removeAll; - treeProto.root = tree_root; - treeProto.size = tree_size; - treeProto.visit = tree_visit; - treeProto.visitAfter = tree_visitAfter; - treeProto.x = tree_x; - treeProto.y = tree_y; - function constant$4(x2) { - return function() { - return x2; - }; - } - function jiggle(random2) { - return (random2() - 0.5) * 1e-6; - } - function x$4(d) { - return d.x + d.vx; - } - function y$3(d) { - return d.y + d.vy; - } - function collide(radius) { - var nodes, radii, random2, strength = 1, iterations2 = 1; - if (typeof radius !== "function") - radius = constant$4(radius == null ? 1 : +radius); - function force() { - var i, n = nodes.length, tree2, node2, xi, yi, ri, ri2; - for (var k2 = 0; k2 < iterations2; ++k2) { - tree2 = quadtree(nodes, x$4, y$3).visitAfter(prepare); - for (i = 0; i < n; ++i) { - node2 = nodes[i]; - ri = radii[node2.index], ri2 = ri * ri; - xi = node2.x + node2.vx; - yi = node2.y + node2.vy; - tree2.visit(apply2); - } - } - function apply2(quad, x02, y02, x12, y12) { - var data = quad.data, rj = quad.r, r = ri + rj; - if (data) { - if (data.index > node2.index) { - var x2 = xi - data.x - data.vx, y2 = yi - data.y - data.vy, l = x2 * x2 + y2 * y2; - if (l < r * r) { - if (x2 === 0) - x2 = jiggle(random2), l += x2 * x2; - if (y2 === 0) - y2 = jiggle(random2), l += y2 * y2; - l = (r - (l = Math.sqrt(l))) / l * strength; - node2.vx += (x2 *= l) * (r = (rj *= rj) / (ri2 + rj)); - node2.vy += (y2 *= l) * r; - data.vx -= x2 * (r = 1 - r); - data.vy -= y2 * r; - } - } - return; - } - return x02 > xi + r || x12 < xi - r || y02 > yi + r || y12 < yi - r; - } - } - function prepare(quad) { - if (quad.data) - return quad.r = radii[quad.data.index]; - for (var i = quad.r = 0; i < 4; ++i) { - if (quad[i] && quad[i].r > quad.r) { - quad.r = quad[i].r; - } - } - } - function initialize2() { - if (!nodes) - return; - var i, n = nodes.length, node2; - radii = new Array(n); - for (i = 0; i < n; ++i) - node2 = nodes[i], radii[node2.index] = +radius(node2, i, nodes); - } - force.initialize = function(_nodes, _random) { - nodes = _nodes; - random2 = _random; - initialize2(); - }; - force.iterations = function(_2) { - return arguments.length ? (iterations2 = +_2, force) : iterations2; - }; - force.strength = function(_2) { - return arguments.length ? (strength = +_2, force) : strength; - }; - force.radius = function(_2) { - return arguments.length ? (radius = typeof _2 === "function" ? _2 : constant$4(+_2), initialize2(), force) : radius; - }; - return force; - } - function index$3(d) { - return d.index; - } - function find(nodeById, nodeId) { - var node2 = nodeById.get(nodeId); - if (!node2) - throw new Error("node not found: " + nodeId); - return node2; - } - function link$2(links2) { - var id2 = index$3, strength = defaultStrength, strengths, distance2 = constant$4(30), distances, nodes, count2, bias, random2, iterations2 = 1; - if (links2 == null) - links2 = []; - function defaultStrength(link2) { - return 1 / Math.min(count2[link2.source.index], count2[link2.target.index]); - } - function force(alpha) { - for (var k2 = 0, n = links2.length; k2 < iterations2; ++k2) { - for (var i = 0, link2, source, target, x2, y2, l, b; i < n; ++i) { - link2 = links2[i], source = link2.source, target = link2.target; - x2 = target.x + target.vx - source.x - source.vx || jiggle(random2); - y2 = target.y + target.vy - source.y - source.vy || jiggle(random2); - l = Math.sqrt(x2 * x2 + y2 * y2); - l = (l - distances[i]) / l * alpha * strengths[i]; - x2 *= l, y2 *= l; - target.vx -= x2 * (b = bias[i]); - target.vy -= y2 * b; - source.vx += x2 * (b = 1 - b); - source.vy += y2 * b; - } - } - } - function initialize2() { - if (!nodes) - return; - var i, n = nodes.length, m2 = links2.length, nodeById = new Map(nodes.map((d, i2) => [id2(d, i2, nodes), d])), link2; - for (i = 0, count2 = new Array(n); i < m2; ++i) { - link2 = links2[i], link2.index = i; - if (typeof link2.source !== "object") - link2.source = find(nodeById, link2.source); - if (typeof link2.target !== "object") - link2.target = find(nodeById, link2.target); - count2[link2.source.index] = (count2[link2.source.index] || 0) + 1; - count2[link2.target.index] = (count2[link2.target.index] || 0) + 1; - } - for (i = 0, bias = new Array(m2); i < m2; ++i) { - link2 = links2[i], bias[i] = count2[link2.source.index] / (count2[link2.source.index] + count2[link2.target.index]); - } - strengths = new Array(m2), initializeStrength(); - distances = new Array(m2), initializeDistance(); - } - function initializeStrength() { - if (!nodes) - return; - for (var i = 0, n = links2.length; i < n; ++i) { - strengths[i] = +strength(links2[i], i, links2); - } - } - function initializeDistance() { - if (!nodes) - return; - for (var i = 0, n = links2.length; i < n; ++i) { - distances[i] = +distance2(links2[i], i, links2); - } - } - force.initialize = function(_nodes, _random) { - nodes = _nodes; - random2 = _random; - initialize2(); - }; - force.links = function(_2) { - return arguments.length ? (links2 = _2, initialize2(), force) : links2; - }; - force.id = function(_2) { - return arguments.length ? (id2 = _2, force) : id2; - }; - force.iterations = function(_2) { - return arguments.length ? (iterations2 = +_2, force) : iterations2; - }; - force.strength = function(_2) { - return arguments.length ? (strength = typeof _2 === "function" ? _2 : constant$4(+_2), initializeStrength(), force) : strength; - }; - force.distance = function(_2) { - return arguments.length ? (distance2 = typeof _2 === "function" ? _2 : constant$4(+_2), initializeDistance(), force) : distance2; - }; - return force; - } - const a$2 = 1664525; - const c$5 = 1013904223; - const m$1 = 4294967296; - function lcg$2() { - let s2 = 1; - return () => (s2 = (a$2 * s2 + c$5) % m$1) / m$1; - } - function x$3(d) { - return d.x; - } - function y$2(d) { - return d.y; - } - var initialRadius = 10, initialAngle = Math.PI * (3 - Math.sqrt(5)); - function simulation(nodes) { - var simulation2, alpha = 1, alphaMin = 1e-3, alphaDecay = 1 - Math.pow(alphaMin, 1 / 300), alphaTarget = 0, velocityDecay = 0.6, forces = /* @__PURE__ */ new Map(), stepper = timer(step), event = dispatch("tick", "end"), random2 = lcg$2(); - if (nodes == null) - nodes = []; - function step() { - tick(); - event.call("tick", simulation2); - if (alpha < alphaMin) { - stepper.stop(); - event.call("end", simulation2); - } - } - function tick(iterations2) { - var i, n = nodes.length, node2; - if (iterations2 === void 0) - iterations2 = 1; - for (var k2 = 0; k2 < iterations2; ++k2) { - alpha += (alphaTarget - alpha) * alphaDecay; - forces.forEach(function(force) { - force(alpha); - }); - for (i = 0; i < n; ++i) { - node2 = nodes[i]; - if (node2.fx == null) - node2.x += node2.vx *= velocityDecay; - else - node2.x = node2.fx, node2.vx = 0; - if (node2.fy == null) - node2.y += node2.vy *= velocityDecay; - else - node2.y = node2.fy, node2.vy = 0; - } - } - return simulation2; - } - function initializeNodes() { - for (var i = 0, n = nodes.length, node2; i < n; ++i) { - node2 = nodes[i], node2.index = i; - if (node2.fx != null) - node2.x = node2.fx; - if (node2.fy != null) - node2.y = node2.fy; - if (isNaN(node2.x) || isNaN(node2.y)) { - var radius = initialRadius * Math.sqrt(0.5 + i), angle2 = i * initialAngle; - node2.x = radius * Math.cos(angle2); - node2.y = radius * Math.sin(angle2); - } - if (isNaN(node2.vx) || isNaN(node2.vy)) { - node2.vx = node2.vy = 0; - } - } - } - function initializeForce(force) { - if (force.initialize) - force.initialize(nodes, random2); - return force; - } - initializeNodes(); - return simulation2 = { - tick, - restart: function() { - return stepper.restart(step), simulation2; - }, - stop: function() { - return stepper.stop(), simulation2; - }, - nodes: function(_2) { - return arguments.length ? (nodes = _2, initializeNodes(), forces.forEach(initializeForce), simulation2) : nodes; - }, - alpha: function(_2) { - return arguments.length ? (alpha = +_2, simulation2) : alpha; - }, - alphaMin: function(_2) { - return arguments.length ? (alphaMin = +_2, simulation2) : alphaMin; - }, - alphaDecay: function(_2) { - return arguments.length ? (alphaDecay = +_2, simulation2) : +alphaDecay; - }, - alphaTarget: function(_2) { - return arguments.length ? (alphaTarget = +_2, simulation2) : alphaTarget; - }, - velocityDecay: function(_2) { - return arguments.length ? (velocityDecay = 1 - _2, simulation2) : 1 - velocityDecay; - }, - randomSource: function(_2) { - return arguments.length ? (random2 = _2, forces.forEach(initializeForce), simulation2) : random2; - }, - force: function(name2, _2) { - return arguments.length > 1 ? (_2 == null ? forces.delete(name2) : forces.set(name2, initializeForce(_2)), simulation2) : forces.get(name2); - }, - find: function(x2, y2, radius) { - var i = 0, n = nodes.length, dx, dy, d2, node2, closest; - if (radius == null) - radius = Infinity; - else - radius *= radius; - for (i = 0; i < n; ++i) { - node2 = nodes[i]; - dx = x2 - node2.x; - dy = y2 - node2.y; - d2 = dx * dx + dy * dy; - if (d2 < radius) - closest = node2, radius = d2; - } - return closest; - }, - on: function(name2, _2) { - return arguments.length > 1 ? (event.on(name2, _2), simulation2) : event.on(name2); - } - }; - } - function manyBody() { - var nodes, node2, random2, alpha, strength = constant$4(-30), strengths, distanceMin2 = 1, distanceMax2 = Infinity, theta2 = 0.81; - function force(_2) { - var i, n = nodes.length, tree2 = quadtree(nodes, x$3, y$2).visitAfter(accumulate); - for (alpha = _2, i = 0; i < n; ++i) - node2 = nodes[i], tree2.visit(apply2); - } - function initialize2() { - if (!nodes) - return; - var i, n = nodes.length, node3; - strengths = new Array(n); - for (i = 0; i < n; ++i) - node3 = nodes[i], strengths[node3.index] = +strength(node3, i, nodes); - } - function accumulate(quad) { - var strength2 = 0, q, c2, weight = 0, x2, y2, i; - if (quad.length) { - for (x2 = y2 = i = 0; i < 4; ++i) { - if ((q = quad[i]) && (c2 = Math.abs(q.value))) { - strength2 += q.value, weight += c2, x2 += c2 * q.x, y2 += c2 * q.y; - } - } - quad.x = x2 / weight; - quad.y = y2 / weight; - } else { - q = quad; - q.x = q.data.x; - q.y = q.data.y; - do - strength2 += strengths[q.data.index]; - while (q = q.next); - } - quad.value = strength2; - } - function apply2(quad, x12, _2, x2) { - if (!quad.value) - return true; - var x3 = quad.x - node2.x, y2 = quad.y - node2.y, w2 = x2 - x12, l = x3 * x3 + y2 * y2; - if (w2 * w2 / theta2 < l) { - if (l < distanceMax2) { - if (x3 === 0) - x3 = jiggle(random2), l += x3 * x3; - if (y2 === 0) - y2 = jiggle(random2), l += y2 * y2; - if (l < distanceMin2) - l = Math.sqrt(distanceMin2 * l); - node2.vx += x3 * quad.value * alpha / l; - node2.vy += y2 * quad.value * alpha / l; - } - return true; - } else if (quad.length || l >= distanceMax2) - return; - if (quad.data !== node2 || quad.next) { - if (x3 === 0) - x3 = jiggle(random2), l += x3 * x3; - if (y2 === 0) - y2 = jiggle(random2), l += y2 * y2; - if (l < distanceMin2) - l = Math.sqrt(distanceMin2 * l); - } - do - if (quad.data !== node2) { - w2 = strengths[quad.data.index] * alpha / l; - node2.vx += x3 * w2; - node2.vy += y2 * w2; - } - while (quad = quad.next); - } - force.initialize = function(_nodes, _random) { - nodes = _nodes; - random2 = _random; - initialize2(); - }; - force.strength = function(_2) { - return arguments.length ? (strength = typeof _2 === "function" ? _2 : constant$4(+_2), initialize2(), force) : strength; - }; - force.distanceMin = function(_2) { - return arguments.length ? (distanceMin2 = _2 * _2, force) : Math.sqrt(distanceMin2); - }; - force.distanceMax = function(_2) { - return arguments.length ? (distanceMax2 = _2 * _2, force) : Math.sqrt(distanceMax2); - }; - force.theta = function(_2) { - return arguments.length ? (theta2 = _2 * _2, force) : Math.sqrt(theta2); - }; - return force; - } - function radial$1(radius, x2, y2) { - var nodes, strength = constant$4(0.1), strengths, radiuses; - if (typeof radius !== "function") - radius = constant$4(+radius); - if (x2 == null) - x2 = 0; - if (y2 == null) - y2 = 0; - function force(alpha) { - for (var i = 0, n = nodes.length; i < n; ++i) { - var node2 = nodes[i], dx = node2.x - x2 || 1e-6, dy = node2.y - y2 || 1e-6, r = Math.sqrt(dx * dx + dy * dy), k2 = (radiuses[i] - r) * strengths[i] * alpha / r; - node2.vx += dx * k2; - node2.vy += dy * k2; - } - } - function initialize2() { - if (!nodes) - return; - var i, n = nodes.length; - strengths = new Array(n); - radiuses = new Array(n); - for (i = 0; i < n; ++i) { - radiuses[i] = +radius(nodes[i], i, nodes); - strengths[i] = isNaN(radiuses[i]) ? 0 : +strength(nodes[i], i, nodes); - } - } - force.initialize = function(_2) { - nodes = _2, initialize2(); - }; - force.strength = function(_2) { - return arguments.length ? (strength = typeof _2 === "function" ? _2 : constant$4(+_2), initialize2(), force) : strength; - }; - force.radius = function(_2) { - return arguments.length ? (radius = typeof _2 === "function" ? _2 : constant$4(+_2), initialize2(), force) : radius; - }; - force.x = function(_2) { - return arguments.length ? (x2 = +_2, force) : x2; - }; - force.y = function(_2) { - return arguments.length ? (y2 = +_2, force) : y2; - }; - return force; - } - function x$2(x2) { - var strength = constant$4(0.1), nodes, strengths, xz; - if (typeof x2 !== "function") - x2 = constant$4(x2 == null ? 0 : +x2); - function force(alpha) { - for (var i = 0, n = nodes.length, node2; i < n; ++i) { - node2 = nodes[i], node2.vx += (xz[i] - node2.x) * strengths[i] * alpha; - } - } - function initialize2() { - if (!nodes) - return; - var i, n = nodes.length; - strengths = new Array(n); - xz = new Array(n); - for (i = 0; i < n; ++i) { - strengths[i] = isNaN(xz[i] = +x2(nodes[i], i, nodes)) ? 0 : +strength(nodes[i], i, nodes); - } - } - force.initialize = function(_2) { - nodes = _2; - initialize2(); - }; - force.strength = function(_2) { - return arguments.length ? (strength = typeof _2 === "function" ? _2 : constant$4(+_2), initialize2(), force) : strength; - }; - force.x = function(_2) { - return arguments.length ? (x2 = typeof _2 === "function" ? _2 : constant$4(+_2), initialize2(), force) : x2; - }; - return force; - } - function y$1(y2) { - var strength = constant$4(0.1), nodes, strengths, yz; - if (typeof y2 !== "function") - y2 = constant$4(y2 == null ? 0 : +y2); - function force(alpha) { - for (var i = 0, n = nodes.length, node2; i < n; ++i) { - node2 = nodes[i], node2.vy += (yz[i] - node2.y) * strengths[i] * alpha; - } - } - function initialize2() { - if (!nodes) - return; - var i, n = nodes.length; - strengths = new Array(n); - yz = new Array(n); - for (i = 0; i < n; ++i) { - strengths[i] = isNaN(yz[i] = +y2(nodes[i], i, nodes)) ? 0 : +strength(nodes[i], i, nodes); - } - } - force.initialize = function(_2) { - nodes = _2; - initialize2(); - }; - force.strength = function(_2) { - return arguments.length ? (strength = typeof _2 === "function" ? _2 : constant$4(+_2), initialize2(), force) : strength; - }; - force.y = function(_2) { - return arguments.length ? (y2 = typeof _2 === "function" ? _2 : constant$4(+_2), initialize2(), force) : y2; - }; - return force; - } - function formatDecimal(x2) { - return Math.abs(x2 = Math.round(x2)) >= 1e21 ? x2.toLocaleString("en").replace(/,/g, "") : x2.toString(10); - } - function formatDecimalParts(x2, p) { - if ((i = (x2 = p ? x2.toExponential(p - 1) : x2.toExponential()).indexOf("e")) < 0) - return null; - var i, coefficient = x2.slice(0, i); - return [ - coefficient.length > 1 ? coefficient[0] + coefficient.slice(2) : coefficient, - +x2.slice(i + 1) - ]; - } - function exponent(x2) { - return x2 = formatDecimalParts(Math.abs(x2)), x2 ? x2[1] : NaN; - } - function formatGroup(grouping, thousands) { - return function(value, width2) { - var i = value.length, t = [], j = 0, g = grouping[0], length2 = 0; - while (i > 0 && g > 0) { - if (length2 + g + 1 > width2) - g = Math.max(1, width2 - length2); - t.push(value.substring(i -= g, i + g)); - if ((length2 += g + 1) > width2) - break; - g = grouping[j = (j + 1) % grouping.length]; - } - return t.reverse().join(thousands); - }; - } - function formatNumerals(numerals) { - return function(value) { - return value.replace(/[0-9]/g, function(i) { - return numerals[+i]; - }); - }; - } - var re = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i; - function formatSpecifier(specifier) { - if (!(match = re.exec(specifier))) - throw new Error("invalid format: " + specifier); - var match; - return new FormatSpecifier({ - fill: match[1], - align: match[2], - sign: match[3], - symbol: match[4], - zero: match[5], - width: match[6], - comma: match[7], - precision: match[8] && match[8].slice(1), - trim: match[9], - type: match[10] - }); - } - formatSpecifier.prototype = FormatSpecifier.prototype; - function FormatSpecifier(specifier) { - this.fill = specifier.fill === void 0 ? " " : specifier.fill + ""; - this.align = specifier.align === void 0 ? ">" : specifier.align + ""; - this.sign = specifier.sign === void 0 ? "-" : specifier.sign + ""; - this.symbol = specifier.symbol === void 0 ? "" : specifier.symbol + ""; - this.zero = !!specifier.zero; - this.width = specifier.width === void 0 ? void 0 : +specifier.width; - this.comma = !!specifier.comma; - this.precision = specifier.precision === void 0 ? void 0 : +specifier.precision; - this.trim = !!specifier.trim; - this.type = specifier.type === void 0 ? "" : specifier.type + ""; - } - FormatSpecifier.prototype.toString = function() { - return this.fill + this.align + this.sign + this.symbol + (this.zero ? "0" : "") + (this.width === void 0 ? "" : Math.max(1, this.width | 0)) + (this.comma ? "," : "") + (this.precision === void 0 ? "" : "." + Math.max(0, this.precision | 0)) + (this.trim ? "~" : "") + this.type; - }; - function formatTrim(s2) { - out: - for (var n = s2.length, i = 1, i0 = -1, i1; i < n; ++i) { - switch (s2[i]) { - case ".": - i0 = i1 = i; - break; - case "0": - if (i0 === 0) - i0 = i; - i1 = i; - break; - default: - if (!+s2[i]) - break out; - if (i0 > 0) - i0 = 0; - break; - } - } - return i0 > 0 ? s2.slice(0, i0) + s2.slice(i1 + 1) : s2; - } - var prefixExponent; - function formatPrefixAuto(x2, p) { - var d = formatDecimalParts(x2, p); - if (!d) - return x2 + ""; - var coefficient = d[0], exponent2 = d[1], i = exponent2 - (prefixExponent = Math.max(-8, Math.min(8, Math.floor(exponent2 / 3))) * 3) + 1, n = coefficient.length; - return i === n ? coefficient : i > n ? coefficient + new Array(i - n + 1).join("0") : i > 0 ? coefficient.slice(0, i) + "." + coefficient.slice(i) : "0." + new Array(1 - i).join("0") + formatDecimalParts(x2, Math.max(0, p + i - 1))[0]; - } - function formatRounded(x2, p) { - var d = formatDecimalParts(x2, p); - if (!d) - return x2 + ""; - var coefficient = d[0], exponent2 = d[1]; - return exponent2 < 0 ? "0." + new Array(-exponent2).join("0") + coefficient : coefficient.length > exponent2 + 1 ? coefficient.slice(0, exponent2 + 1) + "." + coefficient.slice(exponent2 + 1) : coefficient + new Array(exponent2 - coefficient.length + 2).join("0"); - } - const formatTypes = { - "%": (x2, p) => (x2 * 100).toFixed(p), - "b": (x2) => Math.round(x2).toString(2), - "c": (x2) => x2 + "", - "d": formatDecimal, - "e": (x2, p) => x2.toExponential(p), - "f": (x2, p) => x2.toFixed(p), - "g": (x2, p) => x2.toPrecision(p), - "o": (x2) => Math.round(x2).toString(8), - "p": (x2, p) => formatRounded(x2 * 100, p), - "r": formatRounded, - "s": formatPrefixAuto, - "X": (x2) => Math.round(x2).toString(16).toUpperCase(), - "x": (x2) => Math.round(x2).toString(16) - }; - function identity$6(x2) { - return x2; - } - var map = Array.prototype.map, prefixes = ["y", "z", "a", "f", "p", "n", "\xB5", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y"]; - function formatLocale$1(locale2) { - var group2 = locale2.grouping === void 0 || locale2.thousands === void 0 ? identity$6 : formatGroup(map.call(locale2.grouping, Number), locale2.thousands + ""), currencyPrefix = locale2.currency === void 0 ? "" : locale2.currency[0] + "", currencySuffix = locale2.currency === void 0 ? "" : locale2.currency[1] + "", decimal = locale2.decimal === void 0 ? "." : locale2.decimal + "", numerals = locale2.numerals === void 0 ? identity$6 : formatNumerals(map.call(locale2.numerals, String)), percent = locale2.percent === void 0 ? "%" : locale2.percent + "", minus = locale2.minus === void 0 ? "\u2212" : locale2.minus + "", nan = locale2.nan === void 0 ? "NaN" : locale2.nan + ""; - function newFormat(specifier) { - specifier = formatSpecifier(specifier); - var fill = specifier.fill, align = specifier.align, sign2 = specifier.sign, symbol = specifier.symbol, zero2 = specifier.zero, width2 = specifier.width, comma = specifier.comma, precision = specifier.precision, trim2 = specifier.trim, type2 = specifier.type; - if (type2 === "n") - comma = true, type2 = "g"; - else if (!formatTypes[type2]) - precision === void 0 && (precision = 12), trim2 = true, type2 = "g"; - if (zero2 || fill === "0" && align === "=") - zero2 = true, fill = "0", align = "="; - var prefix = symbol === "$" ? currencyPrefix : symbol === "#" && /[boxX]/.test(type2) ? "0" + type2.toLowerCase() : "", suffix = symbol === "$" ? currencySuffix : /[%p]/.test(type2) ? percent : ""; - var formatType = formatTypes[type2], maybeSuffix = /[defgprs%]/.test(type2); - precision = precision === void 0 ? 6 : /[gprs]/.test(type2) ? Math.max(1, Math.min(21, precision)) : Math.max(0, Math.min(20, precision)); - function format2(value) { - var valuePrefix = prefix, valueSuffix = suffix, i, n, c2; - if (type2 === "c") { - valueSuffix = formatType(value) + valueSuffix; - value = ""; - } else { - value = +value; - var valueNegative = value < 0 || 1 / value < 0; - value = isNaN(value) ? nan : formatType(Math.abs(value), precision); - if (trim2) - value = formatTrim(value); - if (valueNegative && +value === 0 && sign2 !== "+") - valueNegative = false; - valuePrefix = (valueNegative ? sign2 === "(" ? sign2 : minus : sign2 === "-" || sign2 === "(" ? "" : sign2) + valuePrefix; - valueSuffix = (type2 === "s" ? prefixes[8 + prefixExponent / 3] : "") + valueSuffix + (valueNegative && sign2 === "(" ? ")" : ""); - if (maybeSuffix) { - i = -1, n = value.length; - while (++i < n) { - if (c2 = value.charCodeAt(i), 48 > c2 || c2 > 57) { - valueSuffix = (c2 === 46 ? decimal + value.slice(i + 1) : value.slice(i)) + valueSuffix; - value = value.slice(0, i); - break; - } - } - } - } - if (comma && !zero2) - value = group2(value, Infinity); - var length2 = valuePrefix.length + value.length + valueSuffix.length, padding2 = length2 < width2 ? new Array(width2 - length2 + 1).join(fill) : ""; - if (comma && zero2) - value = group2(padding2 + value, padding2.length ? width2 - valueSuffix.length : Infinity), padding2 = ""; - switch (align) { - case "<": - value = valuePrefix + value + valueSuffix + padding2; - break; - case "=": - value = valuePrefix + padding2 + value + valueSuffix; - break; - case "^": - value = padding2.slice(0, length2 = padding2.length >> 1) + valuePrefix + value + valueSuffix + padding2.slice(length2); - break; - default: - value = padding2 + valuePrefix + value + valueSuffix; - break; - } - return numerals(value); - } - format2.toString = function() { - return specifier + ""; - }; - return format2; - } - function formatPrefix2(specifier, value) { - var f = newFormat((specifier = formatSpecifier(specifier), specifier.type = "f", specifier)), e = Math.max(-8, Math.min(8, Math.floor(exponent(value) / 3))) * 3, k2 = Math.pow(10, -e), prefix = prefixes[8 + e / 3]; - return function(value2) { - return f(k2 * value2) + prefix; - }; - } - return { - format: newFormat, - formatPrefix: formatPrefix2 - }; - } - var locale$1; - var format; - var formatPrefix; - defaultLocale$1({ - thousands: ",", - grouping: [3], - currency: ["$", ""] - }); - function defaultLocale$1(definition) { - locale$1 = formatLocale$1(definition); - format = locale$1.format; - formatPrefix = locale$1.formatPrefix; - return locale$1; - } - function precisionFixed(step) { - return Math.max(0, -exponent(Math.abs(step))); - } - function precisionPrefix(step, value) { - return Math.max(0, Math.max(-8, Math.min(8, Math.floor(exponent(value) / 3))) * 3 - exponent(Math.abs(step))); - } - function precisionRound(step, max2) { - step = Math.abs(step), max2 = Math.abs(max2) - step; - return Math.max(0, exponent(max2) - exponent(step)) + 1; - } - var epsilon$1 = 1e-6; - var epsilon2 = 1e-12; - var pi$1 = Math.PI; - var halfPi$1 = pi$1 / 2; - var quarterPi = pi$1 / 4; - var tau$1 = pi$1 * 2; - var degrees = 180 / pi$1; - var radians = pi$1 / 180; - var abs$2 = Math.abs; - var atan = Math.atan; - var atan2$1 = Math.atan2; - var cos$1 = Math.cos; - var ceil = Math.ceil; - var exp = Math.exp; - var hypot = Math.hypot; - var log$2 = Math.log; - var pow$1 = Math.pow; - var sin$1 = Math.sin; - var sign$1 = Math.sign || function(x2) { - return x2 > 0 ? 1 : x2 < 0 ? -1 : 0; - }; - var sqrt$2 = Math.sqrt; - var tan = Math.tan; - function acos$1(x2) { - return x2 > 1 ? 0 : x2 < -1 ? pi$1 : Math.acos(x2); - } - function asin$1(x2) { - return x2 > 1 ? halfPi$1 : x2 < -1 ? -halfPi$1 : Math.asin(x2); - } - function haversin(x2) { - return (x2 = sin$1(x2 / 2)) * x2; - } - function noop$1() { - } - function streamGeometry(geometry, stream) { - if (geometry && streamGeometryType.hasOwnProperty(geometry.type)) { - streamGeometryType[geometry.type](geometry, stream); - } - } - var streamObjectType = { - Feature: function(object2, stream) { - streamGeometry(object2.geometry, stream); - }, - FeatureCollection: function(object2, stream) { - var features = object2.features, i = -1, n = features.length; - while (++i < n) - streamGeometry(features[i].geometry, stream); - } - }; - var streamGeometryType = { - Sphere: function(object2, stream) { - stream.sphere(); - }, - Point: function(object2, stream) { - object2 = object2.coordinates; - stream.point(object2[0], object2[1], object2[2]); - }, - MultiPoint: function(object2, stream) { - var coordinates2 = object2.coordinates, i = -1, n = coordinates2.length; - while (++i < n) - object2 = coordinates2[i], stream.point(object2[0], object2[1], object2[2]); - }, - LineString: function(object2, stream) { - streamLine(object2.coordinates, stream, 0); - }, - MultiLineString: function(object2, stream) { - var coordinates2 = object2.coordinates, i = -1, n = coordinates2.length; - while (++i < n) - streamLine(coordinates2[i], stream, 0); - }, - Polygon: function(object2, stream) { - streamPolygon(object2.coordinates, stream); - }, - MultiPolygon: function(object2, stream) { - var coordinates2 = object2.coordinates, i = -1, n = coordinates2.length; - while (++i < n) - streamPolygon(coordinates2[i], stream); - }, - GeometryCollection: function(object2, stream) { - var geometries = object2.geometries, i = -1, n = geometries.length; - while (++i < n) - streamGeometry(geometries[i], stream); - } - }; - function streamLine(coordinates2, stream, closed) { - var i = -1, n = coordinates2.length - closed, coordinate; - stream.lineStart(); - while (++i < n) - coordinate = coordinates2[i], stream.point(coordinate[0], coordinate[1], coordinate[2]); - stream.lineEnd(); - } - function streamPolygon(coordinates2, stream) { - var i = -1, n = coordinates2.length; - stream.polygonStart(); - while (++i < n) - streamLine(coordinates2[i], stream, 1); - stream.polygonEnd(); - } - function geoStream(object2, stream) { - if (object2 && streamObjectType.hasOwnProperty(object2.type)) { - streamObjectType[object2.type](object2, stream); - } else { - streamGeometry(object2, stream); - } - } - var areaRingSum$1 = new Adder(); - var areaSum$1 = new Adder(), lambda00$2, phi00$2, lambda0$2, cosPhi0$1, sinPhi0$1; - var areaStream$1 = { - point: noop$1, - lineStart: noop$1, - lineEnd: noop$1, - polygonStart: function() { - areaRingSum$1 = new Adder(); - areaStream$1.lineStart = areaRingStart$1; - areaStream$1.lineEnd = areaRingEnd$1; - }, - polygonEnd: function() { - var areaRing = +areaRingSum$1; - areaSum$1.add(areaRing < 0 ? tau$1 + areaRing : areaRing); - this.lineStart = this.lineEnd = this.point = noop$1; - }, - sphere: function() { - areaSum$1.add(tau$1); - } - }; - function areaRingStart$1() { - areaStream$1.point = areaPointFirst$1; - } - function areaRingEnd$1() { - areaPoint$1(lambda00$2, phi00$2); - } - function areaPointFirst$1(lambda, phi2) { - areaStream$1.point = areaPoint$1; - lambda00$2 = lambda, phi00$2 = phi2; - lambda *= radians, phi2 *= radians; - lambda0$2 = lambda, cosPhi0$1 = cos$1(phi2 = phi2 / 2 + quarterPi), sinPhi0$1 = sin$1(phi2); - } - function areaPoint$1(lambda, phi2) { - lambda *= radians, phi2 *= radians; - phi2 = phi2 / 2 + quarterPi; - var dLambda = lambda - lambda0$2, sdLambda = dLambda >= 0 ? 1 : -1, adLambda = sdLambda * dLambda, cosPhi = cos$1(phi2), sinPhi = sin$1(phi2), k2 = sinPhi0$1 * sinPhi, u2 = cosPhi0$1 * cosPhi + k2 * cos$1(adLambda), v = k2 * sdLambda * sin$1(adLambda); - areaRingSum$1.add(atan2$1(v, u2)); - lambda0$2 = lambda, cosPhi0$1 = cosPhi, sinPhi0$1 = sinPhi; - } - function area$2(object2) { - areaSum$1 = new Adder(); - geoStream(object2, areaStream$1); - return areaSum$1 * 2; - } - function spherical(cartesian2) { - return [atan2$1(cartesian2[1], cartesian2[0]), asin$1(cartesian2[2])]; - } - function cartesian(spherical2) { - var lambda = spherical2[0], phi2 = spherical2[1], cosPhi = cos$1(phi2); - return [cosPhi * cos$1(lambda), cosPhi * sin$1(lambda), sin$1(phi2)]; - } - function cartesianDot(a2, b) { - return a2[0] * b[0] + a2[1] * b[1] + a2[2] * b[2]; - } - function cartesianCross(a2, b) { - return [a2[1] * b[2] - a2[2] * b[1], a2[2] * b[0] - a2[0] * b[2], a2[0] * b[1] - a2[1] * b[0]]; - } - function cartesianAddInPlace(a2, b) { - a2[0] += b[0], a2[1] += b[1], a2[2] += b[2]; - } - function cartesianScale(vector, k2) { - return [vector[0] * k2, vector[1] * k2, vector[2] * k2]; - } - function cartesianNormalizeInPlace(d) { - var l = sqrt$2(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]); - d[0] /= l, d[1] /= l, d[2] /= l; - } - var lambda0$1, phi0, lambda1, phi1, lambda2, lambda00$1, phi00$1, p0, deltaSum, ranges, range; - var boundsStream$2 = { - point: boundsPoint$1, - lineStart: boundsLineStart, - lineEnd: boundsLineEnd, - polygonStart: function() { - boundsStream$2.point = boundsRingPoint; - boundsStream$2.lineStart = boundsRingStart; - boundsStream$2.lineEnd = boundsRingEnd; - deltaSum = new Adder(); - areaStream$1.polygonStart(); - }, - polygonEnd: function() { - areaStream$1.polygonEnd(); - boundsStream$2.point = boundsPoint$1; - boundsStream$2.lineStart = boundsLineStart; - boundsStream$2.lineEnd = boundsLineEnd; - if (areaRingSum$1 < 0) - lambda0$1 = -(lambda1 = 180), phi0 = -(phi1 = 90); - else if (deltaSum > epsilon$1) - phi1 = 90; - else if (deltaSum < -epsilon$1) - phi0 = -90; - range[0] = lambda0$1, range[1] = lambda1; - }, - sphere: function() { - lambda0$1 = -(lambda1 = 180), phi0 = -(phi1 = 90); - } - }; - function boundsPoint$1(lambda, phi2) { - ranges.push(range = [lambda0$1 = lambda, lambda1 = lambda]); - if (phi2 < phi0) - phi0 = phi2; - if (phi2 > phi1) - phi1 = phi2; - } - function linePoint(lambda, phi2) { - var p = cartesian([lambda * radians, phi2 * radians]); - if (p0) { - var normal2 = cartesianCross(p0, p), equatorial = [normal2[1], -normal2[0], 0], inflection = cartesianCross(equatorial, normal2); - cartesianNormalizeInPlace(inflection); - inflection = spherical(inflection); - var delta = lambda - lambda2, sign2 = delta > 0 ? 1 : -1, lambdai = inflection[0] * degrees * sign2, phii, antimeridian = abs$2(delta) > 180; - if (antimeridian ^ (sign2 * lambda2 < lambdai && lambdai < sign2 * lambda)) { - phii = inflection[1] * degrees; - if (phii > phi1) - phi1 = phii; - } else if (lambdai = (lambdai + 360) % 360 - 180, antimeridian ^ (sign2 * lambda2 < lambdai && lambdai < sign2 * lambda)) { - phii = -inflection[1] * degrees; - if (phii < phi0) - phi0 = phii; - } else { - if (phi2 < phi0) - phi0 = phi2; - if (phi2 > phi1) - phi1 = phi2; - } - if (antimeridian) { - if (lambda < lambda2) { - if (angle(lambda0$1, lambda) > angle(lambda0$1, lambda1)) - lambda1 = lambda; - } else { - if (angle(lambda, lambda1) > angle(lambda0$1, lambda1)) - lambda0$1 = lambda; - } - } else { - if (lambda1 >= lambda0$1) { - if (lambda < lambda0$1) - lambda0$1 = lambda; - if (lambda > lambda1) - lambda1 = lambda; - } else { - if (lambda > lambda2) { - if (angle(lambda0$1, lambda) > angle(lambda0$1, lambda1)) - lambda1 = lambda; - } else { - if (angle(lambda, lambda1) > angle(lambda0$1, lambda1)) - lambda0$1 = lambda; - } - } - } - } else { - ranges.push(range = [lambda0$1 = lambda, lambda1 = lambda]); - } - if (phi2 < phi0) - phi0 = phi2; - if (phi2 > phi1) - phi1 = phi2; - p0 = p, lambda2 = lambda; - } - function boundsLineStart() { - boundsStream$2.point = linePoint; - } - function boundsLineEnd() { - range[0] = lambda0$1, range[1] = lambda1; - boundsStream$2.point = boundsPoint$1; - p0 = null; - } - function boundsRingPoint(lambda, phi2) { - if (p0) { - var delta = lambda - lambda2; - deltaSum.add(abs$2(delta) > 180 ? delta + (delta > 0 ? 360 : -360) : delta); - } else { - lambda00$1 = lambda, phi00$1 = phi2; - } - areaStream$1.point(lambda, phi2); - linePoint(lambda, phi2); - } - function boundsRingStart() { - areaStream$1.lineStart(); - } - function boundsRingEnd() { - boundsRingPoint(lambda00$1, phi00$1); - areaStream$1.lineEnd(); - if (abs$2(deltaSum) > epsilon$1) - lambda0$1 = -(lambda1 = 180); - range[0] = lambda0$1, range[1] = lambda1; - p0 = null; - } - function angle(lambda02, lambda12) { - return (lambda12 -= lambda02) < 0 ? lambda12 + 360 : lambda12; - } - function rangeCompare(a2, b) { - return a2[0] - b[0]; - } - function rangeContains(range2, x2) { - return range2[0] <= range2[1] ? range2[0] <= x2 && x2 <= range2[1] : x2 < range2[0] || range2[1] < x2; - } - function bounds$2(feature) { - var i, n, a2, b, merged, deltaMax, delta; - phi1 = lambda1 = -(lambda0$1 = phi0 = Infinity); - ranges = []; - geoStream(feature, boundsStream$2); - if (n = ranges.length) { - ranges.sort(rangeCompare); - for (i = 1, a2 = ranges[0], merged = [a2]; i < n; ++i) { - b = ranges[i]; - if (rangeContains(a2, b[0]) || rangeContains(a2, b[1])) { - if (angle(a2[0], b[1]) > angle(a2[0], a2[1])) - a2[1] = b[1]; - if (angle(b[0], a2[1]) > angle(a2[0], a2[1])) - a2[0] = b[0]; - } else { - merged.push(a2 = b); - } - } - for (deltaMax = -Infinity, n = merged.length - 1, i = 0, a2 = merged[n]; i <= n; a2 = b, ++i) { - b = merged[i]; - if ((delta = angle(a2[1], b[0])) > deltaMax) - deltaMax = delta, lambda0$1 = b[0], lambda1 = a2[1]; - } - } - ranges = range = null; - return lambda0$1 === Infinity || phi0 === Infinity ? [[NaN, NaN], [NaN, NaN]] : [[lambda0$1, phi0], [lambda1, phi1]]; - } - var W0, W1, X0$1, Y0$1, Z0$1, X1$1, Y1$1, Z1$1, X2$1, Y2$1, Z2$1, lambda00, phi00, x0$4, y0$4, z0; - var centroidStream$1 = { - sphere: noop$1, - point: centroidPoint$1, - lineStart: centroidLineStart$1, - lineEnd: centroidLineEnd$1, - polygonStart: function() { - centroidStream$1.lineStart = centroidRingStart$1; - centroidStream$1.lineEnd = centroidRingEnd$1; - }, - polygonEnd: function() { - centroidStream$1.lineStart = centroidLineStart$1; - centroidStream$1.lineEnd = centroidLineEnd$1; - } - }; - function centroidPoint$1(lambda, phi2) { - lambda *= radians, phi2 *= radians; - var cosPhi = cos$1(phi2); - centroidPointCartesian(cosPhi * cos$1(lambda), cosPhi * sin$1(lambda), sin$1(phi2)); - } - function centroidPointCartesian(x2, y2, z) { - ++W0; - X0$1 += (x2 - X0$1) / W0; - Y0$1 += (y2 - Y0$1) / W0; - Z0$1 += (z - Z0$1) / W0; - } - function centroidLineStart$1() { - centroidStream$1.point = centroidLinePointFirst; - } - function centroidLinePointFirst(lambda, phi2) { - lambda *= radians, phi2 *= radians; - var cosPhi = cos$1(phi2); - x0$4 = cosPhi * cos$1(lambda); - y0$4 = cosPhi * sin$1(lambda); - z0 = sin$1(phi2); - centroidStream$1.point = centroidLinePoint; - centroidPointCartesian(x0$4, y0$4, z0); - } - function centroidLinePoint(lambda, phi2) { - lambda *= radians, phi2 *= radians; - var cosPhi = cos$1(phi2), x2 = cosPhi * cos$1(lambda), y2 = cosPhi * sin$1(lambda), z = sin$1(phi2), w2 = atan2$1(sqrt$2((w2 = y0$4 * z - z0 * y2) * w2 + (w2 = z0 * x2 - x0$4 * z) * w2 + (w2 = x0$4 * y2 - y0$4 * x2) * w2), x0$4 * x2 + y0$4 * y2 + z0 * z); - W1 += w2; - X1$1 += w2 * (x0$4 + (x0$4 = x2)); - Y1$1 += w2 * (y0$4 + (y0$4 = y2)); - Z1$1 += w2 * (z0 + (z0 = z)); - centroidPointCartesian(x0$4, y0$4, z0); - } - function centroidLineEnd$1() { - centroidStream$1.point = centroidPoint$1; - } - function centroidRingStart$1() { - centroidStream$1.point = centroidRingPointFirst; - } - function centroidRingEnd$1() { - centroidRingPoint(lambda00, phi00); - centroidStream$1.point = centroidPoint$1; - } - function centroidRingPointFirst(lambda, phi2) { - lambda00 = lambda, phi00 = phi2; - lambda *= radians, phi2 *= radians; - centroidStream$1.point = centroidRingPoint; - var cosPhi = cos$1(phi2); - x0$4 = cosPhi * cos$1(lambda); - y0$4 = cosPhi * sin$1(lambda); - z0 = sin$1(phi2); - centroidPointCartesian(x0$4, y0$4, z0); - } - function centroidRingPoint(lambda, phi2) { - lambda *= radians, phi2 *= radians; - var cosPhi = cos$1(phi2), x2 = cosPhi * cos$1(lambda), y2 = cosPhi * sin$1(lambda), z = sin$1(phi2), cx = y0$4 * z - z0 * y2, cy = z0 * x2 - x0$4 * z, cz = x0$4 * y2 - y0$4 * x2, m2 = hypot(cx, cy, cz), w2 = asin$1(m2), v = m2 && -w2 / m2; - X2$1.add(v * cx); - Y2$1.add(v * cy); - Z2$1.add(v * cz); - W1 += w2; - X1$1 += w2 * (x0$4 + (x0$4 = x2)); - Y1$1 += w2 * (y0$4 + (y0$4 = y2)); - Z1$1 += w2 * (z0 + (z0 = z)); - centroidPointCartesian(x0$4, y0$4, z0); - } - function centroid$1(object2) { - W0 = W1 = X0$1 = Y0$1 = Z0$1 = X1$1 = Y1$1 = Z1$1 = 0; - X2$1 = new Adder(); - Y2$1 = new Adder(); - Z2$1 = new Adder(); - geoStream(object2, centroidStream$1); - var x2 = +X2$1, y2 = +Y2$1, z = +Z2$1, m2 = hypot(x2, y2, z); - if (m2 < epsilon2) { - x2 = X1$1, y2 = Y1$1, z = Z1$1; - if (W1 < epsilon$1) - x2 = X0$1, y2 = Y0$1, z = Z0$1; - m2 = hypot(x2, y2, z); - if (m2 < epsilon2) - return [NaN, NaN]; - } - return [atan2$1(y2, x2) * degrees, asin$1(z / m2) * degrees]; - } - function constant$3(x2) { - return function() { - return x2; - }; - } - function compose(a2, b) { - function compose2(x2, y2) { - return x2 = a2(x2, y2), b(x2[0], x2[1]); - } - if (a2.invert && b.invert) - compose2.invert = function(x2, y2) { - return x2 = b.invert(x2, y2), x2 && a2.invert(x2[0], x2[1]); - }; - return compose2; - } - function rotationIdentity(lambda, phi2) { - return [abs$2(lambda) > pi$1 ? lambda + Math.round(-lambda / tau$1) * tau$1 : lambda, phi2]; - } - rotationIdentity.invert = rotationIdentity; - function rotateRadians(deltaLambda, deltaPhi, deltaGamma) { - return (deltaLambda %= tau$1) ? deltaPhi || deltaGamma ? compose(rotationLambda(deltaLambda), rotationPhiGamma(deltaPhi, deltaGamma)) : rotationLambda(deltaLambda) : deltaPhi || deltaGamma ? rotationPhiGamma(deltaPhi, deltaGamma) : rotationIdentity; - } - function forwardRotationLambda(deltaLambda) { - return function(lambda, phi2) { - return lambda += deltaLambda, [lambda > pi$1 ? lambda - tau$1 : lambda < -pi$1 ? lambda + tau$1 : lambda, phi2]; - }; - } - function rotationLambda(deltaLambda) { - var rotation2 = forwardRotationLambda(deltaLambda); - rotation2.invert = forwardRotationLambda(-deltaLambda); - return rotation2; - } - function rotationPhiGamma(deltaPhi, deltaGamma) { - var cosDeltaPhi = cos$1(deltaPhi), sinDeltaPhi = sin$1(deltaPhi), cosDeltaGamma = cos$1(deltaGamma), sinDeltaGamma = sin$1(deltaGamma); - function rotation2(lambda, phi2) { - var cosPhi = cos$1(phi2), x2 = cos$1(lambda) * cosPhi, y2 = sin$1(lambda) * cosPhi, z = sin$1(phi2), k2 = z * cosDeltaPhi + x2 * sinDeltaPhi; - return [ - atan2$1(y2 * cosDeltaGamma - k2 * sinDeltaGamma, x2 * cosDeltaPhi - z * sinDeltaPhi), - asin$1(k2 * cosDeltaGamma + y2 * sinDeltaGamma) - ]; - } - rotation2.invert = function(lambda, phi2) { - var cosPhi = cos$1(phi2), x2 = cos$1(lambda) * cosPhi, y2 = sin$1(lambda) * cosPhi, z = sin$1(phi2), k2 = z * cosDeltaGamma - y2 * sinDeltaGamma; - return [ - atan2$1(y2 * cosDeltaGamma + z * sinDeltaGamma, x2 * cosDeltaPhi + k2 * sinDeltaPhi), - asin$1(k2 * cosDeltaPhi - x2 * sinDeltaPhi) - ]; - }; - return rotation2; - } - function rotation(rotate) { - rotate = rotateRadians(rotate[0] * radians, rotate[1] * radians, rotate.length > 2 ? rotate[2] * radians : 0); - function forward(coordinates2) { - coordinates2 = rotate(coordinates2[0] * radians, coordinates2[1] * radians); - return coordinates2[0] *= degrees, coordinates2[1] *= degrees, coordinates2; - } - forward.invert = function(coordinates2) { - coordinates2 = rotate.invert(coordinates2[0] * radians, coordinates2[1] * radians); - return coordinates2[0] *= degrees, coordinates2[1] *= degrees, coordinates2; - }; - return forward; - } - function circleStream(stream, radius, delta, direction2, t02, t12) { - if (!delta) - return; - var cosRadius = cos$1(radius), sinRadius = sin$1(radius), step = direction2 * delta; - if (t02 == null) { - t02 = radius + direction2 * tau$1; - t12 = radius - step / 2; - } else { - t02 = circleRadius(cosRadius, t02); - t12 = circleRadius(cosRadius, t12); - if (direction2 > 0 ? t02 < t12 : t02 > t12) - t02 += direction2 * tau$1; - } - for (var point2, t = t02; direction2 > 0 ? t > t12 : t < t12; t -= step) { - point2 = spherical([cosRadius, -sinRadius * cos$1(t), -sinRadius * sin$1(t)]); - stream.point(point2[0], point2[1]); - } - } - function circleRadius(cosRadius, point2) { - point2 = cartesian(point2), point2[0] -= cosRadius; - cartesianNormalizeInPlace(point2); - var radius = acos$1(-point2[1]); - return ((-point2[2] < 0 ? -radius : radius) + tau$1 - epsilon$1) % tau$1; - } - function circle$4() { - var center2 = constant$3([0, 0]), radius = constant$3(90), precision = constant$3(6), ring, rotate, stream = { point: point2 }; - function point2(x2, y2) { - ring.push(x2 = rotate(x2, y2)); - x2[0] *= degrees, x2[1] *= degrees; - } - function circle2() { - var c2 = center2.apply(this, arguments), r = radius.apply(this, arguments) * radians, p = precision.apply(this, arguments) * radians; - ring = []; - rotate = rotateRadians(-c2[0] * radians, -c2[1] * radians, 0).invert; - circleStream(stream, r, p, 1); - c2 = { type: "Polygon", coordinates: [ring] }; - ring = rotate = null; - return c2; - } - circle2.center = function(_2) { - return arguments.length ? (center2 = typeof _2 === "function" ? _2 : constant$3([+_2[0], +_2[1]]), circle2) : center2; - }; - circle2.radius = function(_2) { - return arguments.length ? (radius = typeof _2 === "function" ? _2 : constant$3(+_2), circle2) : radius; - }; - circle2.precision = function(_2) { - return arguments.length ? (precision = typeof _2 === "function" ? _2 : constant$3(+_2), circle2) : precision; - }; - return circle2; - } - function clipBuffer() { - var lines = [], line2; - return { - point: function(x2, y2, m2) { - line2.push([x2, y2, m2]); - }, - lineStart: function() { - lines.push(line2 = []); - }, - lineEnd: noop$1, - rejoin: function() { - if (lines.length > 1) - lines.push(lines.pop().concat(lines.shift())); - }, - result: function() { - var result = lines; - lines = []; - line2 = null; - return result; - } - }; - } - function pointEqual(a2, b) { - return abs$2(a2[0] - b[0]) < epsilon$1 && abs$2(a2[1] - b[1]) < epsilon$1; - } - function Intersection(point2, points, other, entry) { - this.x = point2; - this.z = points; - this.o = other; - this.e = entry; - this.v = false; - this.n = this.p = null; - } - function clipRejoin(segments, compareIntersection2, startInside, interpolate2, stream) { - var subject = [], clip2 = [], i, n; - segments.forEach(function(segment) { - if ((n2 = segment.length - 1) <= 0) - return; - var n2, p02 = segment[0], p1 = segment[n2], x2; - if (pointEqual(p02, p1)) { - if (!p02[2] && !p1[2]) { - stream.lineStart(); - for (i = 0; i < n2; ++i) - stream.point((p02 = segment[i])[0], p02[1]); - stream.lineEnd(); - return; - } - p1[0] += 2 * epsilon$1; - } - subject.push(x2 = new Intersection(p02, segment, null, true)); - clip2.push(x2.o = new Intersection(p02, null, x2, false)); - subject.push(x2 = new Intersection(p1, segment, null, false)); - clip2.push(x2.o = new Intersection(p1, null, x2, true)); - }); - if (!subject.length) - return; - clip2.sort(compareIntersection2); - link$1(subject); - link$1(clip2); - for (i = 0, n = clip2.length; i < n; ++i) { - clip2[i].e = startInside = !startInside; - } - var start2 = subject[0], points, point2; - while (1) { - var current = start2, isSubject = true; - while (current.v) - if ((current = current.n) === start2) - return; - points = current.z; - stream.lineStart(); - do { - current.v = current.o.v = true; - if (current.e) { - if (isSubject) { - for (i = 0, n = points.length; i < n; ++i) - stream.point((point2 = points[i])[0], point2[1]); - } else { - interpolate2(current.x, current.n.x, 1, stream); - } - current = current.n; - } else { - if (isSubject) { - points = current.p.z; - for (i = points.length - 1; i >= 0; --i) - stream.point((point2 = points[i])[0], point2[1]); - } else { - interpolate2(current.x, current.p.x, -1, stream); - } - current = current.p; - } - current = current.o; - points = current.z; - isSubject = !isSubject; - } while (!current.v); - stream.lineEnd(); - } - } - function link$1(array2) { - if (!(n = array2.length)) - return; - var n, i = 0, a2 = array2[0], b; - while (++i < n) { - a2.n = b = array2[i]; - b.p = a2; - a2 = b; - } - a2.n = b = array2[0]; - b.p = a2; - } - function longitude(point2) { - return abs$2(point2[0]) <= pi$1 ? point2[0] : sign$1(point2[0]) * ((abs$2(point2[0]) + pi$1) % tau$1 - pi$1); - } - function polygonContains(polygon, point2) { - var lambda = longitude(point2), phi2 = point2[1], sinPhi = sin$1(phi2), normal2 = [sin$1(lambda), -cos$1(lambda), 0], angle2 = 0, winding = 0; - var sum2 = new Adder(); - if (sinPhi === 1) - phi2 = halfPi$1 + epsilon$1; - else if (sinPhi === -1) - phi2 = -halfPi$1 - epsilon$1; - for (var i = 0, n = polygon.length; i < n; ++i) { - if (!(m2 = (ring = polygon[i]).length)) - continue; - var ring, m2, point0 = ring[m2 - 1], lambda02 = longitude(point0), phi02 = point0[1] / 2 + quarterPi, sinPhi02 = sin$1(phi02), cosPhi02 = cos$1(phi02); - for (var j = 0; j < m2; ++j, lambda02 = lambda12, sinPhi02 = sinPhi1, cosPhi02 = cosPhi1, point0 = point1) { - var point1 = ring[j], lambda12 = longitude(point1), phi12 = point1[1] / 2 + quarterPi, sinPhi1 = sin$1(phi12), cosPhi1 = cos$1(phi12), delta = lambda12 - lambda02, sign2 = delta >= 0 ? 1 : -1, absDelta = sign2 * delta, antimeridian = absDelta > pi$1, k2 = sinPhi02 * sinPhi1; - sum2.add(atan2$1(k2 * sign2 * sin$1(absDelta), cosPhi02 * cosPhi1 + k2 * cos$1(absDelta))); - angle2 += antimeridian ? delta + sign2 * tau$1 : delta; - if (antimeridian ^ lambda02 >= lambda ^ lambda12 >= lambda) { - var arc = cartesianCross(cartesian(point0), cartesian(point1)); - cartesianNormalizeInPlace(arc); - var intersection2 = cartesianCross(normal2, arc); - cartesianNormalizeInPlace(intersection2); - var phiArc = (antimeridian ^ delta >= 0 ? -1 : 1) * asin$1(intersection2[2]); - if (phi2 > phiArc || phi2 === phiArc && (arc[0] || arc[1])) { - winding += antimeridian ^ delta >= 0 ? 1 : -1; - } - } - } - } - return (angle2 < -epsilon$1 || angle2 < epsilon$1 && sum2 < -epsilon2) ^ winding & 1; - } - function clip(pointVisible, clipLine2, interpolate2, start2) { - return function(sink) { - var line2 = clipLine2(sink), ringBuffer = clipBuffer(), ringSink = clipLine2(ringBuffer), polygonStarted = false, polygon, segments, ring; - var clip2 = { - point: point2, - lineStart, - lineEnd, - polygonStart: function() { - clip2.point = pointRing; - clip2.lineStart = ringStart; - clip2.lineEnd = ringEnd; - segments = []; - polygon = []; - }, - polygonEnd: function() { - clip2.point = point2; - clip2.lineStart = lineStart; - clip2.lineEnd = lineEnd; - segments = merge$1(segments); - var startInside = polygonContains(polygon, start2); - if (segments.length) { - if (!polygonStarted) - sink.polygonStart(), polygonStarted = true; - clipRejoin(segments, compareIntersection, startInside, interpolate2, sink); - } else if (startInside) { - if (!polygonStarted) - sink.polygonStart(), polygonStarted = true; - sink.lineStart(); - interpolate2(null, null, 1, sink); - sink.lineEnd(); - } - if (polygonStarted) - sink.polygonEnd(), polygonStarted = false; - segments = polygon = null; - }, - sphere: function() { - sink.polygonStart(); - sink.lineStart(); - interpolate2(null, null, 1, sink); - sink.lineEnd(); - sink.polygonEnd(); - } - }; - function point2(lambda, phi2) { - if (pointVisible(lambda, phi2)) - sink.point(lambda, phi2); - } - function pointLine(lambda, phi2) { - line2.point(lambda, phi2); - } - function lineStart() { - clip2.point = pointLine; - line2.lineStart(); - } - function lineEnd() { - clip2.point = point2; - line2.lineEnd(); - } - function pointRing(lambda, phi2) { - ring.push([lambda, phi2]); - ringSink.point(lambda, phi2); - } - function ringStart() { - ringSink.lineStart(); - ring = []; - } - function ringEnd() { - pointRing(ring[0][0], ring[0][1]); - ringSink.lineEnd(); - var clean = ringSink.clean(), ringSegments = ringBuffer.result(), i, n = ringSegments.length, m2, segment, point3; - ring.pop(); - polygon.push(ring); - ring = null; - if (!n) - return; - if (clean & 1) { - segment = ringSegments[0]; - if ((m2 = segment.length - 1) > 0) { - if (!polygonStarted) - sink.polygonStart(), polygonStarted = true; - sink.lineStart(); - for (i = 0; i < m2; ++i) - sink.point((point3 = segment[i])[0], point3[1]); - sink.lineEnd(); - } - return; - } - if (n > 1 && clean & 2) - ringSegments.push(ringSegments.pop().concat(ringSegments.shift())); - segments.push(ringSegments.filter(validSegment)); - } - return clip2; - }; - } - function validSegment(segment) { - return segment.length > 1; - } - function compareIntersection(a2, b) { - return ((a2 = a2.x)[0] < 0 ? a2[1] - halfPi$1 - epsilon$1 : halfPi$1 - a2[1]) - ((b = b.x)[0] < 0 ? b[1] - halfPi$1 - epsilon$1 : halfPi$1 - b[1]); - } - const clipAntimeridian = clip( - function() { - return true; - }, - clipAntimeridianLine, - clipAntimeridianInterpolate, - [-pi$1, -halfPi$1] - ); - function clipAntimeridianLine(stream) { - var lambda02 = NaN, phi02 = NaN, sign0 = NaN, clean; - return { - lineStart: function() { - stream.lineStart(); - clean = 1; - }, - point: function(lambda12, phi12) { - var sign1 = lambda12 > 0 ? pi$1 : -pi$1, delta = abs$2(lambda12 - lambda02); - if (abs$2(delta - pi$1) < epsilon$1) { - stream.point(lambda02, phi02 = (phi02 + phi12) / 2 > 0 ? halfPi$1 : -halfPi$1); - stream.point(sign0, phi02); - stream.lineEnd(); - stream.lineStart(); - stream.point(sign1, phi02); - stream.point(lambda12, phi02); - clean = 0; - } else if (sign0 !== sign1 && delta >= pi$1) { - if (abs$2(lambda02 - sign0) < epsilon$1) - lambda02 -= sign0 * epsilon$1; - if (abs$2(lambda12 - sign1) < epsilon$1) - lambda12 -= sign1 * epsilon$1; - phi02 = clipAntimeridianIntersect(lambda02, phi02, lambda12, phi12); - stream.point(sign0, phi02); - stream.lineEnd(); - stream.lineStart(); - stream.point(sign1, phi02); - clean = 0; - } - stream.point(lambda02 = lambda12, phi02 = phi12); - sign0 = sign1; - }, - lineEnd: function() { - stream.lineEnd(); - lambda02 = phi02 = NaN; - }, - clean: function() { - return 2 - clean; - } - }; - } - function clipAntimeridianIntersect(lambda02, phi02, lambda12, phi12) { - var cosPhi02, cosPhi1, sinLambda0Lambda1 = sin$1(lambda02 - lambda12); - return abs$2(sinLambda0Lambda1) > epsilon$1 ? atan((sin$1(phi02) * (cosPhi1 = cos$1(phi12)) * sin$1(lambda12) - sin$1(phi12) * (cosPhi02 = cos$1(phi02)) * sin$1(lambda02)) / (cosPhi02 * cosPhi1 * sinLambda0Lambda1)) : (phi02 + phi12) / 2; - } - function clipAntimeridianInterpolate(from2, to, direction2, stream) { - var phi2; - if (from2 == null) { - phi2 = direction2 * halfPi$1; - stream.point(-pi$1, phi2); - stream.point(0, phi2); - stream.point(pi$1, phi2); - stream.point(pi$1, 0); - stream.point(pi$1, -phi2); - stream.point(0, -phi2); - stream.point(-pi$1, -phi2); - stream.point(-pi$1, 0); - stream.point(-pi$1, phi2); - } else if (abs$2(from2[0] - to[0]) > epsilon$1) { - var lambda = from2[0] < to[0] ? pi$1 : -pi$1; - phi2 = direction2 * lambda / 2; - stream.point(-lambda, phi2); - stream.point(0, phi2); - stream.point(lambda, phi2); - } else { - stream.point(to[0], to[1]); - } - } - function clipCircle(radius) { - var cr = cos$1(radius), delta = 6 * radians, smallRadius = cr > 0, notHemisphere = abs$2(cr) > epsilon$1; - function interpolate2(from2, to, direction2, stream) { - circleStream(stream, radius, delta, direction2, from2, to); - } - function visible(lambda, phi2) { - return cos$1(lambda) * cos$1(phi2) > cr; - } - function clipLine2(stream) { - var point0, c0, v0, v00, clean; - return { - lineStart: function() { - v00 = v0 = false; - clean = 1; - }, - point: function(lambda, phi2) { - var point1 = [lambda, phi2], point2, v = visible(lambda, phi2), c2 = smallRadius ? v ? 0 : code(lambda, phi2) : v ? code(lambda + (lambda < 0 ? pi$1 : -pi$1), phi2) : 0; - if (!point0 && (v00 = v0 = v)) - stream.lineStart(); - if (v !== v0) { - point2 = intersect2(point0, point1); - if (!point2 || pointEqual(point0, point2) || pointEqual(point1, point2)) - point1[2] = 1; - } - if (v !== v0) { - clean = 0; - if (v) { - stream.lineStart(); - point2 = intersect2(point1, point0); - stream.point(point2[0], point2[1]); - } else { - point2 = intersect2(point0, point1); - stream.point(point2[0], point2[1], 2); - stream.lineEnd(); - } - point0 = point2; - } else if (notHemisphere && point0 && smallRadius ^ v) { - var t; - if (!(c2 & c0) && (t = intersect2(point1, point0, true))) { - clean = 0; - if (smallRadius) { - stream.lineStart(); - stream.point(t[0][0], t[0][1]); - stream.point(t[1][0], t[1][1]); - stream.lineEnd(); - } else { - stream.point(t[1][0], t[1][1]); - stream.lineEnd(); - stream.lineStart(); - stream.point(t[0][0], t[0][1], 3); - } - } - } - if (v && (!point0 || !pointEqual(point0, point1))) { - stream.point(point1[0], point1[1]); - } - point0 = point1, v0 = v, c0 = c2; - }, - lineEnd: function() { - if (v0) - stream.lineEnd(); - point0 = null; - }, - clean: function() { - return clean | (v00 && v0) << 1; - } - }; - } - function intersect2(a2, b, two) { - var pa = cartesian(a2), pb = cartesian(b); - var n1 = [1, 0, 0], n2 = cartesianCross(pa, pb), n2n2 = cartesianDot(n2, n2), n1n2 = n2[0], determinant = n2n2 - n1n2 * n1n2; - if (!determinant) - return !two && a2; - var c1 = cr * n2n2 / determinant, c2 = -cr * n1n2 / determinant, n1xn2 = cartesianCross(n1, n2), A5 = cartesianScale(n1, c1), B2 = cartesianScale(n2, c2); - cartesianAddInPlace(A5, B2); - var u2 = n1xn2, w2 = cartesianDot(A5, u2), uu = cartesianDot(u2, u2), t22 = w2 * w2 - uu * (cartesianDot(A5, A5) - 1); - if (t22 < 0) - return; - var t = sqrt$2(t22), q = cartesianScale(u2, (-w2 - t) / uu); - cartesianAddInPlace(q, A5); - q = spherical(q); - if (!two) - return q; - var lambda02 = a2[0], lambda12 = b[0], phi02 = a2[1], phi12 = b[1], z; - if (lambda12 < lambda02) - z = lambda02, lambda02 = lambda12, lambda12 = z; - var delta2 = lambda12 - lambda02, polar = abs$2(delta2 - pi$1) < epsilon$1, meridian = polar || delta2 < epsilon$1; - if (!polar && phi12 < phi02) - z = phi02, phi02 = phi12, phi12 = z; - if (meridian ? polar ? phi02 + phi12 > 0 ^ q[1] < (abs$2(q[0] - lambda02) < epsilon$1 ? phi02 : phi12) : phi02 <= q[1] && q[1] <= phi12 : delta2 > pi$1 ^ (lambda02 <= q[0] && q[0] <= lambda12)) { - var q1 = cartesianScale(u2, (-w2 + t) / uu); - cartesianAddInPlace(q1, A5); - return [q, spherical(q1)]; - } - } - function code(lambda, phi2) { - var r = smallRadius ? radius : pi$1 - radius, code2 = 0; - if (lambda < -r) - code2 |= 1; - else if (lambda > r) - code2 |= 2; - if (phi2 < -r) - code2 |= 4; - else if (phi2 > r) - code2 |= 8; - return code2; - } - return clip(visible, clipLine2, interpolate2, smallRadius ? [0, -radius] : [-pi$1, radius - pi$1]); - } - function clipLine(a2, b, x02, y02, x12, y12) { - var ax = a2[0], ay = a2[1], bx = b[0], by = b[1], t02 = 0, t12 = 1, dx = bx - ax, dy = by - ay, r; - r = x02 - ax; - if (!dx && r > 0) - return; - r /= dx; - if (dx < 0) { - if (r < t02) - return; - if (r < t12) - t12 = r; - } else if (dx > 0) { - if (r > t12) - return; - if (r > t02) - t02 = r; - } - r = x12 - ax; - if (!dx && r < 0) - return; - r /= dx; - if (dx < 0) { - if (r > t12) - return; - if (r > t02) - t02 = r; - } else if (dx > 0) { - if (r < t02) - return; - if (r < t12) - t12 = r; - } - r = y02 - ay; - if (!dy && r > 0) - return; - r /= dy; - if (dy < 0) { - if (r < t02) - return; - if (r < t12) - t12 = r; - } else if (dy > 0) { - if (r > t12) - return; - if (r > t02) - t02 = r; - } - r = y12 - ay; - if (!dy && r < 0) - return; - r /= dy; - if (dy < 0) { - if (r > t12) - return; - if (r > t02) - t02 = r; - } else if (dy > 0) { - if (r < t02) - return; - if (r < t12) - t12 = r; - } - if (t02 > 0) - a2[0] = ax + t02 * dx, a2[1] = ay + t02 * dy; - if (t12 < 1) - b[0] = ax + t12 * dx, b[1] = ay + t12 * dy; - return true; - } - var clipMax = 1e9, clipMin = -clipMax; - function clipRectangle(x02, y02, x12, y12) { - function visible(x2, y2) { - return x02 <= x2 && x2 <= x12 && y02 <= y2 && y2 <= y12; - } - function interpolate2(from2, to, direction2, stream) { - var a2 = 0, a1 = 0; - if (from2 == null || (a2 = corner(from2, direction2)) !== (a1 = corner(to, direction2)) || comparePoint(from2, to) < 0 ^ direction2 > 0) { - do - stream.point(a2 === 0 || a2 === 3 ? x02 : x12, a2 > 1 ? y12 : y02); - while ((a2 = (a2 + direction2 + 4) % 4) !== a1); - } else { - stream.point(to[0], to[1]); - } - } - function corner(p, direction2) { - return abs$2(p[0] - x02) < epsilon$1 ? direction2 > 0 ? 0 : 3 : abs$2(p[0] - x12) < epsilon$1 ? direction2 > 0 ? 2 : 1 : abs$2(p[1] - y02) < epsilon$1 ? direction2 > 0 ? 1 : 0 : direction2 > 0 ? 3 : 2; - } - function compareIntersection2(a2, b) { - return comparePoint(a2.x, b.x); - } - function comparePoint(a2, b) { - var ca = corner(a2, 1), cb = corner(b, 1); - return ca !== cb ? ca - cb : ca === 0 ? b[1] - a2[1] : ca === 1 ? a2[0] - b[0] : ca === 2 ? a2[1] - b[1] : b[0] - a2[0]; - } - return function(stream) { - var activeStream = stream, bufferStream = clipBuffer(), segments, polygon, ring, x__, y__, v__, x_, y_, v_, first, clean; - var clipStream = { - point: point2, - lineStart, - lineEnd, - polygonStart, - polygonEnd - }; - function point2(x2, y2) { - if (visible(x2, y2)) - activeStream.point(x2, y2); - } - function polygonInside() { - var winding = 0; - for (var i = 0, n = polygon.length; i < n; ++i) { - for (var ring2 = polygon[i], j = 1, m2 = ring2.length, point3 = ring2[0], a0, a1, b02 = point3[0], b12 = point3[1]; j < m2; ++j) { - a0 = b02, a1 = b12, point3 = ring2[j], b02 = point3[0], b12 = point3[1]; - if (a1 <= y12) { - if (b12 > y12 && (b02 - a0) * (y12 - a1) > (b12 - a1) * (x02 - a0)) - ++winding; - } else { - if (b12 <= y12 && (b02 - a0) * (y12 - a1) < (b12 - a1) * (x02 - a0)) - --winding; - } - } - } - return winding; - } - function polygonStart() { - activeStream = bufferStream, segments = [], polygon = [], clean = true; - } - function polygonEnd() { - var startInside = polygonInside(), cleanInside = clean && startInside, visible2 = (segments = merge$1(segments)).length; - if (cleanInside || visible2) { - stream.polygonStart(); - if (cleanInside) { - stream.lineStart(); - interpolate2(null, null, 1, stream); - stream.lineEnd(); - } - if (visible2) { - clipRejoin(segments, compareIntersection2, startInside, interpolate2, stream); - } - stream.polygonEnd(); - } - activeStream = stream, segments = polygon = ring = null; - } - function lineStart() { - clipStream.point = linePoint2; - if (polygon) - polygon.push(ring = []); - first = true; - v_ = false; - x_ = y_ = NaN; - } - function lineEnd() { - if (segments) { - linePoint2(x__, y__); - if (v__ && v_) - bufferStream.rejoin(); - segments.push(bufferStream.result()); - } - clipStream.point = point2; - if (v_) - activeStream.lineEnd(); - } - function linePoint2(x2, y2) { - var v = visible(x2, y2); - if (polygon) - ring.push([x2, y2]); - if (first) { - x__ = x2, y__ = y2, v__ = v; - first = false; - if (v) { - activeStream.lineStart(); - activeStream.point(x2, y2); - } - } else { - if (v && v_) - activeStream.point(x2, y2); - else { - var a2 = [x_ = Math.max(clipMin, Math.min(clipMax, x_)), y_ = Math.max(clipMin, Math.min(clipMax, y_))], b = [x2 = Math.max(clipMin, Math.min(clipMax, x2)), y2 = Math.max(clipMin, Math.min(clipMax, y2))]; - if (clipLine(a2, b, x02, y02, x12, y12)) { - if (!v_) { - activeStream.lineStart(); - activeStream.point(a2[0], a2[1]); - } - activeStream.point(b[0], b[1]); - if (!v) - activeStream.lineEnd(); - clean = false; - } else if (v) { - activeStream.lineStart(); - activeStream.point(x2, y2); - clean = false; - } - } - } - x_ = x2, y_ = y2, v_ = v; - } - return clipStream; - }; - } - function extent() { - var x02 = 0, y02 = 0, x12 = 960, y12 = 500, cache, cacheStream, clip2; - return clip2 = { - stream: function(stream) { - return cache && cacheStream === stream ? cache : cache = clipRectangle(x02, y02, x12, y12)(cacheStream = stream); - }, - extent: function(_2) { - return arguments.length ? (x02 = +_2[0][0], y02 = +_2[0][1], x12 = +_2[1][0], y12 = +_2[1][1], cache = cacheStream = null, clip2) : [[x02, y02], [x12, y12]]; - } - }; - } - var lengthSum$1, lambda0, sinPhi0, cosPhi0; - var lengthStream$1 = { - sphere: noop$1, - point: noop$1, - lineStart: lengthLineStart, - lineEnd: noop$1, - polygonStart: noop$1, - polygonEnd: noop$1 - }; - function lengthLineStart() { - lengthStream$1.point = lengthPointFirst$1; - lengthStream$1.lineEnd = lengthLineEnd; - } - function lengthLineEnd() { - lengthStream$1.point = lengthStream$1.lineEnd = noop$1; - } - function lengthPointFirst$1(lambda, phi2) { - lambda *= radians, phi2 *= radians; - lambda0 = lambda, sinPhi0 = sin$1(phi2), cosPhi0 = cos$1(phi2); - lengthStream$1.point = lengthPoint$1; - } - function lengthPoint$1(lambda, phi2) { - lambda *= radians, phi2 *= radians; - var sinPhi = sin$1(phi2), cosPhi = cos$1(phi2), delta = abs$2(lambda - lambda0), cosDelta = cos$1(delta), sinDelta = sin$1(delta), x2 = cosPhi * sinDelta, y2 = cosPhi0 * sinPhi - sinPhi0 * cosPhi * cosDelta, z = sinPhi0 * sinPhi + cosPhi0 * cosPhi * cosDelta; - lengthSum$1.add(atan2$1(sqrt$2(x2 * x2 + y2 * y2), z)); - lambda0 = lambda, sinPhi0 = sinPhi, cosPhi0 = cosPhi; - } - function length$2(object2) { - lengthSum$1 = new Adder(); - geoStream(object2, lengthStream$1); - return +lengthSum$1; - } - var coordinates = [null, null], object = { type: "LineString", coordinates }; - function distance$1(a2, b) { - coordinates[0] = a2; - coordinates[1] = b; - return length$2(object); - } - var containsObjectType = { - Feature: function(object2, point2) { - return containsGeometry(object2.geometry, point2); - }, - FeatureCollection: function(object2, point2) { - var features = object2.features, i = -1, n = features.length; - while (++i < n) - if (containsGeometry(features[i].geometry, point2)) - return true; - return false; - } - }; - var containsGeometryType = { - Sphere: function() { - return true; - }, - Point: function(object2, point2) { - return containsPoint(object2.coordinates, point2); - }, - MultiPoint: function(object2, point2) { - var coordinates2 = object2.coordinates, i = -1, n = coordinates2.length; - while (++i < n) - if (containsPoint(coordinates2[i], point2)) - return true; - return false; - }, - LineString: function(object2, point2) { - return containsLine(object2.coordinates, point2); - }, - MultiLineString: function(object2, point2) { - var coordinates2 = object2.coordinates, i = -1, n = coordinates2.length; - while (++i < n) - if (containsLine(coordinates2[i], point2)) - return true; - return false; - }, - Polygon: function(object2, point2) { - return containsPolygon(object2.coordinates, point2); - }, - MultiPolygon: function(object2, point2) { - var coordinates2 = object2.coordinates, i = -1, n = coordinates2.length; - while (++i < n) - if (containsPolygon(coordinates2[i], point2)) - return true; - return false; - }, - GeometryCollection: function(object2, point2) { - var geometries = object2.geometries, i = -1, n = geometries.length; - while (++i < n) - if (containsGeometry(geometries[i], point2)) - return true; - return false; - } - }; - function containsGeometry(geometry, point2) { - return geometry && containsGeometryType.hasOwnProperty(geometry.type) ? containsGeometryType[geometry.type](geometry, point2) : false; - } - function containsPoint(coordinates2, point2) { - return distance$1(coordinates2, point2) === 0; - } - function containsLine(coordinates2, point2) { - var ao, bo, ab; - for (var i = 0, n = coordinates2.length; i < n; i++) { - bo = distance$1(coordinates2[i], point2); - if (bo === 0) - return true; - if (i > 0) { - ab = distance$1(coordinates2[i], coordinates2[i - 1]); - if (ab > 0 && ao <= ab && bo <= ab && (ao + bo - ab) * (1 - Math.pow((ao - bo) / ab, 2)) < epsilon2 * ab) - return true; - } - ao = bo; - } - return false; - } - function containsPolygon(coordinates2, point2) { - return !!polygonContains(coordinates2.map(ringRadians), pointRadians(point2)); - } - function ringRadians(ring) { - return ring = ring.map(pointRadians), ring.pop(), ring; - } - function pointRadians(point2) { - return [point2[0] * radians, point2[1] * radians]; - } - function contains$1(object2, point2) { - return (object2 && containsObjectType.hasOwnProperty(object2.type) ? containsObjectType[object2.type] : containsGeometry)(object2, point2); - } - function graticuleX(y02, y12, dy) { - var y2 = range$2(y02, y12 - epsilon$1, dy).concat(y12); - return function(x2) { - return y2.map(function(y3) { - return [x2, y3]; - }); - }; - } - function graticuleY(x02, x12, dx) { - var x2 = range$2(x02, x12 - epsilon$1, dx).concat(x12); - return function(y2) { - return x2.map(function(x3) { - return [x3, y2]; - }); - }; - } - function graticule() { - var x12, x02, X12, X02, y12, y02, Y12, Y02, dx = 10, dy = dx, DX = 90, DY = 360, x2, y2, X3, Y3, precision = 2.5; - function graticule2() { - return { type: "MultiLineString", coordinates: lines() }; - } - function lines() { - return range$2(ceil(X02 / DX) * DX, X12, DX).map(X3).concat(range$2(ceil(Y02 / DY) * DY, Y12, DY).map(Y3)).concat(range$2(ceil(x02 / dx) * dx, x12, dx).filter(function(x3) { - return abs$2(x3 % DX) > epsilon$1; - }).map(x2)).concat(range$2(ceil(y02 / dy) * dy, y12, dy).filter(function(y3) { - return abs$2(y3 % DY) > epsilon$1; - }).map(y2)); - } - graticule2.lines = function() { - return lines().map(function(coordinates2) { - return { type: "LineString", coordinates: coordinates2 }; - }); - }; - graticule2.outline = function() { - return { - type: "Polygon", - coordinates: [ - X3(X02).concat( - Y3(Y12).slice(1), - X3(X12).reverse().slice(1), - Y3(Y02).reverse().slice(1) - ) - ] - }; - }; - graticule2.extent = function(_2) { - if (!arguments.length) - return graticule2.extentMinor(); - return graticule2.extentMajor(_2).extentMinor(_2); - }; - graticule2.extentMajor = function(_2) { - if (!arguments.length) - return [[X02, Y02], [X12, Y12]]; - X02 = +_2[0][0], X12 = +_2[1][0]; - Y02 = +_2[0][1], Y12 = +_2[1][1]; - if (X02 > X12) - _2 = X02, X02 = X12, X12 = _2; - if (Y02 > Y12) - _2 = Y02, Y02 = Y12, Y12 = _2; - return graticule2.precision(precision); - }; - graticule2.extentMinor = function(_2) { - if (!arguments.length) - return [[x02, y02], [x12, y12]]; - x02 = +_2[0][0], x12 = +_2[1][0]; - y02 = +_2[0][1], y12 = +_2[1][1]; - if (x02 > x12) - _2 = x02, x02 = x12, x12 = _2; - if (y02 > y12) - _2 = y02, y02 = y12, y12 = _2; - return graticule2.precision(precision); - }; - graticule2.step = function(_2) { - if (!arguments.length) - return graticule2.stepMinor(); - return graticule2.stepMajor(_2).stepMinor(_2); - }; - graticule2.stepMajor = function(_2) { - if (!arguments.length) - return [DX, DY]; - DX = +_2[0], DY = +_2[1]; - return graticule2; - }; - graticule2.stepMinor = function(_2) { - if (!arguments.length) - return [dx, dy]; - dx = +_2[0], dy = +_2[1]; - return graticule2; - }; - graticule2.precision = function(_2) { - if (!arguments.length) - return precision; - precision = +_2; - x2 = graticuleX(y02, y12, 90); - y2 = graticuleY(x02, x12, precision); - X3 = graticuleX(Y02, Y12, 90); - Y3 = graticuleY(X02, X12, precision); - return graticule2; - }; - return graticule2.extentMajor([[-180, -90 + epsilon$1], [180, 90 - epsilon$1]]).extentMinor([[-180, -80 - epsilon$1], [180, 80 + epsilon$1]]); - } - function graticule10() { - return graticule()(); - } - function interpolate(a2, b) { - var x02 = a2[0] * radians, y02 = a2[1] * radians, x12 = b[0] * radians, y12 = b[1] * radians, cy0 = cos$1(y02), sy0 = sin$1(y02), cy1 = cos$1(y12), sy1 = sin$1(y12), kx0 = cy0 * cos$1(x02), ky0 = cy0 * sin$1(x02), kx1 = cy1 * cos$1(x12), ky1 = cy1 * sin$1(x12), d = 2 * asin$1(sqrt$2(haversin(y12 - y02) + cy0 * cy1 * haversin(x12 - x02))), k2 = sin$1(d); - var interpolate2 = d ? function(t) { - var B2 = sin$1(t *= d) / k2, A5 = sin$1(d - t) / k2, x2 = A5 * kx0 + B2 * kx1, y2 = A5 * ky0 + B2 * ky1, z = A5 * sy0 + B2 * sy1; - return [ - atan2$1(y2, x2) * degrees, - atan2$1(z, sqrt$2(x2 * x2 + y2 * y2)) * degrees - ]; - } : function() { - return [x02 * degrees, y02 * degrees]; - }; - interpolate2.distance = d; - return interpolate2; - } - const identity$5 = (x2) => x2; - var areaSum = new Adder(), areaRingSum = new Adder(), x00$2, y00$2, x0$3, y0$3; - var areaStream = { - point: noop$1, - lineStart: noop$1, - lineEnd: noop$1, - polygonStart: function() { - areaStream.lineStart = areaRingStart; - areaStream.lineEnd = areaRingEnd; - }, - polygonEnd: function() { - areaStream.lineStart = areaStream.lineEnd = areaStream.point = noop$1; - areaSum.add(abs$2(areaRingSum)); - areaRingSum = new Adder(); - }, - result: function() { - var area2 = areaSum / 2; - areaSum = new Adder(); - return area2; - } - }; - function areaRingStart() { - areaStream.point = areaPointFirst; - } - function areaPointFirst(x2, y2) { - areaStream.point = areaPoint; - x00$2 = x0$3 = x2, y00$2 = y0$3 = y2; - } - function areaPoint(x2, y2) { - areaRingSum.add(y0$3 * x2 - x0$3 * y2); - x0$3 = x2, y0$3 = y2; - } - function areaRingEnd() { - areaPoint(x00$2, y00$2); - } - const pathArea = areaStream; - var x0$2 = Infinity, y0$2 = x0$2, x1 = -x0$2, y1 = x1; - var boundsStream = { - point: boundsPoint, - lineStart: noop$1, - lineEnd: noop$1, - polygonStart: noop$1, - polygonEnd: noop$1, - result: function() { - var bounds2 = [[x0$2, y0$2], [x1, y1]]; - x1 = y1 = -(y0$2 = x0$2 = Infinity); - return bounds2; - } - }; - function boundsPoint(x2, y2) { - if (x2 < x0$2) - x0$2 = x2; - if (x2 > x1) - x1 = x2; - if (y2 < y0$2) - y0$2 = y2; - if (y2 > y1) - y1 = y2; - } - const boundsStream$1 = boundsStream; - var X0 = 0, Y0 = 0, Z0 = 0, X1 = 0, Y1 = 0, Z1 = 0, X2 = 0, Y2 = 0, Z2 = 0, x00$1, y00$1, x0$1, y0$1; - var centroidStream = { - point: centroidPoint, - lineStart: centroidLineStart, - lineEnd: centroidLineEnd, - polygonStart: function() { - centroidStream.lineStart = centroidRingStart; - centroidStream.lineEnd = centroidRingEnd; - }, - polygonEnd: function() { - centroidStream.point = centroidPoint; - centroidStream.lineStart = centroidLineStart; - centroidStream.lineEnd = centroidLineEnd; - }, - result: function() { - var centroid2 = Z2 ? [X2 / Z2, Y2 / Z2] : Z1 ? [X1 / Z1, Y1 / Z1] : Z0 ? [X0 / Z0, Y0 / Z0] : [NaN, NaN]; - X0 = Y0 = Z0 = X1 = Y1 = Z1 = X2 = Y2 = Z2 = 0; - return centroid2; - } - }; - function centroidPoint(x2, y2) { - X0 += x2; - Y0 += y2; - ++Z0; - } - function centroidLineStart() { - centroidStream.point = centroidPointFirstLine; - } - function centroidPointFirstLine(x2, y2) { - centroidStream.point = centroidPointLine; - centroidPoint(x0$1 = x2, y0$1 = y2); - } - function centroidPointLine(x2, y2) { - var dx = x2 - x0$1, dy = y2 - y0$1, z = sqrt$2(dx * dx + dy * dy); - X1 += z * (x0$1 + x2) / 2; - Y1 += z * (y0$1 + y2) / 2; - Z1 += z; - centroidPoint(x0$1 = x2, y0$1 = y2); - } - function centroidLineEnd() { - centroidStream.point = centroidPoint; - } - function centroidRingStart() { - centroidStream.point = centroidPointFirstRing; - } - function centroidRingEnd() { - centroidPointRing(x00$1, y00$1); - } - function centroidPointFirstRing(x2, y2) { - centroidStream.point = centroidPointRing; - centroidPoint(x00$1 = x0$1 = x2, y00$1 = y0$1 = y2); - } - function centroidPointRing(x2, y2) { - var dx = x2 - x0$1, dy = y2 - y0$1, z = sqrt$2(dx * dx + dy * dy); - X1 += z * (x0$1 + x2) / 2; - Y1 += z * (y0$1 + y2) / 2; - Z1 += z; - z = y0$1 * x2 - x0$1 * y2; - X2 += z * (x0$1 + x2); - Y2 += z * (y0$1 + y2); - Z2 += z * 3; - centroidPoint(x0$1 = x2, y0$1 = y2); - } - const pathCentroid = centroidStream; - function PathContext(context) { - this._context = context; - } - PathContext.prototype = { - _radius: 4.5, - pointRadius: function(_2) { - return this._radius = _2, this; - }, - polygonStart: function() { - this._line = 0; - }, - polygonEnd: function() { - this._line = NaN; - }, - lineStart: function() { - this._point = 0; - }, - lineEnd: function() { - if (this._line === 0) - this._context.closePath(); - this._point = NaN; - }, - point: function(x2, y2) { - switch (this._point) { - case 0: { - this._context.moveTo(x2, y2); - this._point = 1; - break; - } - case 1: { - this._context.lineTo(x2, y2); - break; - } - default: { - this._context.moveTo(x2 + this._radius, y2); - this._context.arc(x2, y2, this._radius, 0, tau$1); - break; - } - } - }, - result: noop$1 - }; - var lengthSum = new Adder(), lengthRing, x00, y00, x0, y0; - var lengthStream = { - point: noop$1, - lineStart: function() { - lengthStream.point = lengthPointFirst; - }, - lineEnd: function() { - if (lengthRing) - lengthPoint(x00, y00); - lengthStream.point = noop$1; - }, - polygonStart: function() { - lengthRing = true; - }, - polygonEnd: function() { - lengthRing = null; - }, - result: function() { - var length2 = +lengthSum; - lengthSum = new Adder(); - return length2; - } - }; - function lengthPointFirst(x2, y2) { - lengthStream.point = lengthPoint; - x00 = x0 = x2, y00 = y0 = y2; - } - function lengthPoint(x2, y2) { - x0 -= x2, y0 -= y2; - lengthSum.add(sqrt$2(x0 * x0 + y0 * y0)); - x0 = x2, y0 = y2; - } - const pathMeasure = lengthStream; - function PathString() { - this._string = []; - } - PathString.prototype = { - _radius: 4.5, - _circle: circle$3(4.5), - pointRadius: function(_2) { - if ((_2 = +_2) !== this._radius) - this._radius = _2, this._circle = null; - return this; - }, - polygonStart: function() { - this._line = 0; - }, - polygonEnd: function() { - this._line = NaN; - }, - lineStart: function() { - this._point = 0; - }, - lineEnd: function() { - if (this._line === 0) - this._string.push("Z"); - this._point = NaN; - }, - point: function(x2, y2) { - switch (this._point) { - case 0: { - this._string.push("M", x2, ",", y2); - this._point = 1; - break; - } - case 1: { - this._string.push("L", x2, ",", y2); - break; - } - default: { - if (this._circle == null) - this._circle = circle$3(this._radius); - this._string.push("M", x2, ",", y2, this._circle); - break; - } - } - }, - result: function() { - if (this._string.length) { - var result = this._string.join(""); - this._string = []; - return result; - } else { - return null; - } - } - }; - function circle$3(radius) { - return "m0," + radius + "a" + radius + "," + radius + " 0 1,1 0," + -2 * radius + "a" + radius + "," + radius + " 0 1,1 0," + 2 * radius + "z"; - } - function index$2(projection2, context) { - var pointRadius = 4.5, projectionStream, contextStream; - function path2(object2) { - if (object2) { - if (typeof pointRadius === "function") - contextStream.pointRadius(+pointRadius.apply(this, arguments)); - geoStream(object2, projectionStream(contextStream)); - } - return contextStream.result(); - } - path2.area = function(object2) { - geoStream(object2, projectionStream(pathArea)); - return pathArea.result(); - }; - path2.measure = function(object2) { - geoStream(object2, projectionStream(pathMeasure)); - return pathMeasure.result(); - }; - path2.bounds = function(object2) { - geoStream(object2, projectionStream(boundsStream$1)); - return boundsStream$1.result(); - }; - path2.centroid = function(object2) { - geoStream(object2, projectionStream(pathCentroid)); - return pathCentroid.result(); - }; - path2.projection = function(_2) { - return arguments.length ? (projectionStream = _2 == null ? (projection2 = null, identity$5) : (projection2 = _2).stream, path2) : projection2; - }; - path2.context = function(_2) { - if (!arguments.length) - return context; - contextStream = _2 == null ? (context = null, new PathString()) : new PathContext(context = _2); - if (typeof pointRadius !== "function") - contextStream.pointRadius(pointRadius); - return path2; - }; - path2.pointRadius = function(_2) { - if (!arguments.length) - return pointRadius; - pointRadius = typeof _2 === "function" ? _2 : (contextStream.pointRadius(+_2), +_2); - return path2; - }; - return path2.projection(projection2).context(context); - } - function transform$1(methods) { - return { - stream: transformer$3(methods) - }; - } - function transformer$3(methods) { - return function(stream) { - var s2 = new TransformStream(); - for (var key in methods) - s2[key] = methods[key]; - s2.stream = stream; - return s2; - }; - } - function TransformStream() { - } - TransformStream.prototype = { - constructor: TransformStream, - point: function(x2, y2) { - this.stream.point(x2, y2); - }, - 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 fit(projection2, fitBounds, object2) { - var clip2 = projection2.clipExtent && projection2.clipExtent(); - projection2.scale(150).translate([0, 0]); - if (clip2 != null) - projection2.clipExtent(null); - geoStream(object2, projection2.stream(boundsStream$1)); - fitBounds(boundsStream$1.result()); - if (clip2 != null) - projection2.clipExtent(clip2); - return projection2; - } - function fitExtent(projection2, extent2, object2) { - return fit(projection2, function(b) { - var w2 = extent2[1][0] - extent2[0][0], h = extent2[1][1] - extent2[0][1], k2 = Math.min(w2 / (b[1][0] - b[0][0]), h / (b[1][1] - b[0][1])), x2 = +extent2[0][0] + (w2 - k2 * (b[1][0] + b[0][0])) / 2, y2 = +extent2[0][1] + (h - k2 * (b[1][1] + b[0][1])) / 2; - projection2.scale(150 * k2).translate([x2, y2]); - }, object2); - } - function fitSize(projection2, size, object2) { - return fitExtent(projection2, [[0, 0], size], object2); - } - function fitWidth(projection2, width2, object2) { - return fit(projection2, function(b) { - var w2 = +width2, k2 = w2 / (b[1][0] - b[0][0]), x2 = (w2 - k2 * (b[1][0] + b[0][0])) / 2, y2 = -k2 * b[0][1]; - projection2.scale(150 * k2).translate([x2, y2]); - }, object2); - } - function fitHeight(projection2, height2, object2) { - return fit(projection2, function(b) { - var h = +height2, k2 = h / (b[1][1] - b[0][1]), x2 = -k2 * b[0][0], y2 = (h - k2 * (b[1][1] + b[0][1])) / 2; - projection2.scale(150 * k2).translate([x2, y2]); - }, object2); - } - var maxDepth = 16, cosMinDistance = cos$1(30 * radians); - function resample(project, delta2) { - return +delta2 ? resample$1(project, delta2) : resampleNone(project); - } - function resampleNone(project) { - return transformer$3({ - point: function(x2, y2) { - x2 = project(x2, y2); - this.stream.point(x2[0], x2[1]); - } - }); - } - function resample$1(project, delta2) { - function resampleLineTo(x02, y02, lambda02, a0, b02, c0, x12, y12, lambda12, a1, b12, c1, depth, stream) { - var dx = x12 - x02, dy = y12 - y02, d2 = dx * dx + dy * dy; - if (d2 > 4 * delta2 && depth--) { - var a2 = a0 + a1, b = b02 + b12, c2 = c0 + c1, m2 = sqrt$2(a2 * a2 + b * b + c2 * c2), phi2 = asin$1(c2 /= m2), lambda22 = abs$2(abs$2(c2) - 1) < epsilon$1 || abs$2(lambda02 - lambda12) < epsilon$1 ? (lambda02 + lambda12) / 2 : atan2$1(b, a2), p = project(lambda22, phi2), x2 = p[0], y2 = p[1], dx2 = x2 - x02, dy2 = y2 - y02, dz = dy * dx2 - dx * dy2; - if (dz * dz / d2 > delta2 || abs$2((dx * dx2 + dy * dy2) / d2 - 0.5) > 0.3 || a0 * a1 + b02 * b12 + c0 * c1 < cosMinDistance) { - resampleLineTo(x02, y02, lambda02, a0, b02, c0, x2, y2, lambda22, a2 /= m2, b /= m2, c2, depth, stream); - stream.point(x2, y2); - resampleLineTo(x2, y2, lambda22, a2, b, c2, x12, y12, lambda12, a1, b12, c1, depth, stream); - } - } - } - return function(stream) { - var lambda002, x002, y002, a00, b00, c00, lambda02, x02, y02, a0, b02, c0; - var resampleStream = { - point: point2, - lineStart, - lineEnd, - polygonStart: function() { - stream.polygonStart(); - resampleStream.lineStart = ringStart; - }, - polygonEnd: function() { - stream.polygonEnd(); - resampleStream.lineStart = lineStart; - } - }; - function point2(x2, y2) { - x2 = project(x2, y2); - stream.point(x2[0], x2[1]); - } - function lineStart() { - x02 = NaN; - resampleStream.point = linePoint2; - stream.lineStart(); - } - function linePoint2(lambda, phi2) { - var c2 = cartesian([lambda, phi2]), p = project(lambda, phi2); - resampleLineTo(x02, y02, lambda02, a0, b02, c0, x02 = p[0], y02 = p[1], lambda02 = lambda, a0 = c2[0], b02 = c2[1], c0 = c2[2], maxDepth, stream); - stream.point(x02, y02); - } - function lineEnd() { - resampleStream.point = point2; - stream.lineEnd(); - } - function ringStart() { - lineStart(); - resampleStream.point = ringPoint; - resampleStream.lineEnd = ringEnd; - } - function ringPoint(lambda, phi2) { - linePoint2(lambda002 = lambda, phi2), x002 = x02, y002 = y02, a00 = a0, b00 = b02, c00 = c0; - resampleStream.point = linePoint2; - } - function ringEnd() { - resampleLineTo(x02, y02, lambda02, a0, b02, c0, x002, y002, lambda002, a00, b00, c00, maxDepth, stream); - resampleStream.lineEnd = lineEnd; - lineEnd(); - } - return resampleStream; - }; - } - var transformRadians = transformer$3({ - point: function(x2, y2) { - this.stream.point(x2 * radians, y2 * radians); - } - }); - function transformRotate(rotate) { - return transformer$3({ - point: function(x2, y2) { - var r = rotate(x2, y2); - return this.stream.point(r[0], r[1]); - } - }); - } - function scaleTranslate(k2, dx, dy, sx, sy) { - function transform2(x2, y2) { - x2 *= sx; - y2 *= sy; - return [dx + k2 * x2, dy - k2 * y2]; - } - transform2.invert = function(x2, y2) { - return [(x2 - dx) / k2 * sx, (dy - y2) / k2 * sy]; - }; - return transform2; - } - function scaleTranslateRotate(k2, dx, dy, sx, sy, alpha) { - if (!alpha) - return scaleTranslate(k2, dx, dy, sx, sy); - var cosAlpha = cos$1(alpha), sinAlpha = sin$1(alpha), a2 = cosAlpha * k2, b = sinAlpha * k2, ai = cosAlpha / k2, bi = sinAlpha / k2, ci = (sinAlpha * dy - cosAlpha * dx) / k2, fi = (sinAlpha * dx + cosAlpha * dy) / k2; - function transform2(x2, y2) { - x2 *= sx; - y2 *= sy; - return [a2 * x2 - b * y2 + dx, dy - b * x2 - a2 * y2]; - } - transform2.invert = function(x2, y2) { - return [sx * (ai * x2 - bi * y2 + ci), sy * (fi - bi * x2 - ai * y2)]; - }; - return transform2; - } - function projection(project) { - return projectionMutator(function() { - return project; - })(); - } - function projectionMutator(projectAt) { - var project, k2 = 150, x2 = 480, y2 = 250, lambda = 0, phi2 = 0, deltaLambda = 0, deltaPhi = 0, deltaGamma = 0, rotate, alpha = 0, sx = 1, sy = 1, theta = null, preclip = clipAntimeridian, x02 = null, y02, x12, y12, postclip = identity$5, delta2 = 0.5, projectResample, projectTransform, projectRotateTransform, cache, cacheStream; - function projection2(point2) { - return projectRotateTransform(point2[0] * radians, point2[1] * radians); - } - function invert2(point2) { - point2 = projectRotateTransform.invert(point2[0], point2[1]); - return point2 && [point2[0] * degrees, point2[1] * degrees]; - } - projection2.stream = function(stream) { - return cache && cacheStream === stream ? cache : cache = transformRadians(transformRotate(rotate)(preclip(projectResample(postclip(cacheStream = stream))))); - }; - projection2.preclip = function(_2) { - return arguments.length ? (preclip = _2, theta = void 0, reset2()) : preclip; - }; - projection2.postclip = function(_2) { - return arguments.length ? (postclip = _2, x02 = y02 = x12 = y12 = null, reset2()) : postclip; - }; - projection2.clipAngle = function(_2) { - return arguments.length ? (preclip = +_2 ? clipCircle(theta = _2 * radians) : (theta = null, clipAntimeridian), reset2()) : theta * degrees; - }; - projection2.clipExtent = function(_2) { - return arguments.length ? (postclip = _2 == null ? (x02 = y02 = x12 = y12 = null, identity$5) : clipRectangle(x02 = +_2[0][0], y02 = +_2[0][1], x12 = +_2[1][0], y12 = +_2[1][1]), reset2()) : x02 == null ? null : [[x02, y02], [x12, y12]]; - }; - projection2.scale = function(_2) { - return arguments.length ? (k2 = +_2, recenter()) : k2; - }; - projection2.translate = function(_2) { - return arguments.length ? (x2 = +_2[0], y2 = +_2[1], recenter()) : [x2, y2]; - }; - projection2.center = function(_2) { - return arguments.length ? (lambda = _2[0] % 360 * radians, phi2 = _2[1] % 360 * radians, recenter()) : [lambda * degrees, phi2 * degrees]; - }; - projection2.rotate = function(_2) { - return arguments.length ? (deltaLambda = _2[0] % 360 * radians, deltaPhi = _2[1] % 360 * radians, deltaGamma = _2.length > 2 ? _2[2] % 360 * radians : 0, recenter()) : [deltaLambda * degrees, deltaPhi * degrees, deltaGamma * degrees]; - }; - projection2.angle = function(_2) { - return arguments.length ? (alpha = _2 % 360 * radians, recenter()) : alpha * degrees; - }; - projection2.reflectX = function(_2) { - return arguments.length ? (sx = _2 ? -1 : 1, recenter()) : sx < 0; - }; - projection2.reflectY = function(_2) { - return arguments.length ? (sy = _2 ? -1 : 1, recenter()) : sy < 0; - }; - projection2.precision = function(_2) { - return arguments.length ? (projectResample = resample(projectTransform, delta2 = _2 * _2), reset2()) : sqrt$2(delta2); - }; - projection2.fitExtent = function(extent2, object2) { - return fitExtent(projection2, extent2, object2); - }; - projection2.fitSize = function(size, object2) { - return fitSize(projection2, size, object2); - }; - projection2.fitWidth = function(width2, object2) { - return fitWidth(projection2, width2, object2); - }; - projection2.fitHeight = function(height2, object2) { - return fitHeight(projection2, height2, object2); - }; - function recenter() { - var center2 = scaleTranslateRotate(k2, 0, 0, sx, sy, alpha).apply(null, project(lambda, phi2)), transform2 = scaleTranslateRotate(k2, x2 - center2[0], y2 - center2[1], sx, sy, alpha); - rotate = rotateRadians(deltaLambda, deltaPhi, deltaGamma); - projectTransform = compose(project, transform2); - projectRotateTransform = compose(rotate, projectTransform); - projectResample = resample(projectTransform, delta2); - return reset2(); - } - function reset2() { - cache = cacheStream = null; - return projection2; - } - return function() { - project = projectAt.apply(this, arguments); - projection2.invert = project.invert && invert2; - return recenter(); - }; - } - function conicProjection(projectAt) { - var phi02 = 0, phi12 = pi$1 / 3, m2 = projectionMutator(projectAt), p = m2(phi02, phi12); - p.parallels = function(_2) { - return arguments.length ? m2(phi02 = _2[0] * radians, phi12 = _2[1] * radians) : [phi02 * degrees, phi12 * degrees]; - }; - return p; - } - function cylindricalEqualAreaRaw(phi02) { - var cosPhi02 = cos$1(phi02); - function forward(lambda, phi2) { - return [lambda * cosPhi02, sin$1(phi2) / cosPhi02]; - } - forward.invert = function(x2, y2) { - return [x2 / cosPhi02, asin$1(y2 * cosPhi02)]; - }; - return forward; - } - function conicEqualAreaRaw(y02, y12) { - var sy0 = sin$1(y02), n = (sy0 + sin$1(y12)) / 2; - if (abs$2(n) < epsilon$1) - return cylindricalEqualAreaRaw(y02); - var c2 = 1 + sy0 * (2 * n - sy0), r0 = sqrt$2(c2) / n; - function project(x2, y2) { - var r = sqrt$2(c2 - 2 * n * sin$1(y2)) / n; - return [r * sin$1(x2 *= n), r0 - r * cos$1(x2)]; - } - project.invert = function(x2, y2) { - var r0y = r0 - y2, l = atan2$1(x2, abs$2(r0y)) * sign$1(r0y); - if (r0y * n < 0) - l -= pi$1 * sign$1(x2) * sign$1(r0y); - return [l / n, asin$1((c2 - (x2 * x2 + r0y * r0y) * n * n) / (2 * n))]; - }; - return project; - } - function conicEqualArea() { - return conicProjection(conicEqualAreaRaw).scale(155.424).center([0, 33.6442]); - } - function albers() { - return conicEqualArea().parallels([29.5, 45.5]).scale(1070).translate([480, 250]).rotate([96, 0]).center([-0.6, 38.7]); - } - function multiplex(streams) { - var n = streams.length; - return { - point: function(x2, y2) { - var i = -1; - while (++i < n) - streams[i].point(x2, y2); - }, - sphere: function() { - var i = -1; - while (++i < n) - streams[i].sphere(); - }, - lineStart: function() { - var i = -1; - while (++i < n) - streams[i].lineStart(); - }, - lineEnd: function() { - var i = -1; - while (++i < n) - streams[i].lineEnd(); - }, - polygonStart: function() { - var i = -1; - while (++i < n) - streams[i].polygonStart(); - }, - polygonEnd: function() { - var i = -1; - while (++i < n) - streams[i].polygonEnd(); - } - }; - } - function albersUsa() { - var cache, cacheStream, lower48 = albers(), lower48Point, alaska = conicEqualArea().rotate([154, 0]).center([-2, 58.5]).parallels([55, 65]), alaskaPoint, hawaii = conicEqualArea().rotate([157, 0]).center([-3, 19.9]).parallels([8, 18]), hawaiiPoint, point2, pointStream = { point: function(x2, y2) { - point2 = [x2, y2]; - } }; - function albersUsa2(coordinates2) { - var x2 = coordinates2[0], y2 = coordinates2[1]; - return point2 = null, (lower48Point.point(x2, y2), point2) || (alaskaPoint.point(x2, y2), point2) || (hawaiiPoint.point(x2, y2), point2); - } - albersUsa2.invert = function(coordinates2) { - var k2 = lower48.scale(), t = lower48.translate(), x2 = (coordinates2[0] - t[0]) / k2, y2 = (coordinates2[1] - t[1]) / k2; - return (y2 >= 0.12 && y2 < 0.234 && x2 >= -0.425 && x2 < -0.214 ? alaska : y2 >= 0.166 && y2 < 0.234 && x2 >= -0.214 && x2 < -0.115 ? hawaii : lower48).invert(coordinates2); - }; - albersUsa2.stream = function(stream) { - return cache && cacheStream === stream ? cache : cache = multiplex([lower48.stream(cacheStream = stream), alaska.stream(stream), hawaii.stream(stream)]); - }; - albersUsa2.precision = function(_2) { - if (!arguments.length) - return lower48.precision(); - lower48.precision(_2), alaska.precision(_2), hawaii.precision(_2); - return reset2(); - }; - albersUsa2.scale = function(_2) { - if (!arguments.length) - return lower48.scale(); - lower48.scale(_2), alaska.scale(_2 * 0.35), hawaii.scale(_2); - return albersUsa2.translate(lower48.translate()); - }; - albersUsa2.translate = function(_2) { - if (!arguments.length) - return lower48.translate(); - var k2 = lower48.scale(), x2 = +_2[0], y2 = +_2[1]; - lower48Point = lower48.translate(_2).clipExtent([[x2 - 0.455 * k2, y2 - 0.238 * k2], [x2 + 0.455 * k2, y2 + 0.238 * k2]]).stream(pointStream); - alaskaPoint = alaska.translate([x2 - 0.307 * k2, y2 + 0.201 * k2]).clipExtent([[x2 - 0.425 * k2 + epsilon$1, y2 + 0.12 * k2 + epsilon$1], [x2 - 0.214 * k2 - epsilon$1, y2 + 0.234 * k2 - epsilon$1]]).stream(pointStream); - hawaiiPoint = hawaii.translate([x2 - 0.205 * k2, y2 + 0.212 * k2]).clipExtent([[x2 - 0.214 * k2 + epsilon$1, y2 + 0.166 * k2 + epsilon$1], [x2 - 0.115 * k2 - epsilon$1, y2 + 0.234 * k2 - epsilon$1]]).stream(pointStream); - return reset2(); - }; - albersUsa2.fitExtent = function(extent2, object2) { - return fitExtent(albersUsa2, extent2, object2); - }; - albersUsa2.fitSize = function(size, object2) { - return fitSize(albersUsa2, size, object2); - }; - albersUsa2.fitWidth = function(width2, object2) { - return fitWidth(albersUsa2, width2, object2); - }; - albersUsa2.fitHeight = function(height2, object2) { - return fitHeight(albersUsa2, height2, object2); - }; - function reset2() { - cache = cacheStream = null; - return albersUsa2; - } - return albersUsa2.scale(1070); - } - function azimuthalRaw(scale) { - return function(x2, y2) { - var cx = cos$1(x2), cy = cos$1(y2), k2 = scale(cx * cy); - if (k2 === Infinity) - return [2, 0]; - return [ - k2 * cy * sin$1(x2), - k2 * sin$1(y2) - ]; - }; - } - function azimuthalInvert(angle2) { - return function(x2, y2) { - var z = sqrt$2(x2 * x2 + y2 * y2), c2 = angle2(z), sc = sin$1(c2), cc = cos$1(c2); - return [ - atan2$1(x2 * sc, z * cc), - asin$1(z && y2 * sc / z) - ]; - }; - } - var azimuthalEqualAreaRaw = azimuthalRaw(function(cxcy) { - return sqrt$2(2 / (1 + cxcy)); - }); - azimuthalEqualAreaRaw.invert = azimuthalInvert(function(z) { - return 2 * asin$1(z / 2); - }); - function azimuthalEqualArea() { - return projection(azimuthalEqualAreaRaw).scale(124.75).clipAngle(180 - 1e-3); - } - var azimuthalEquidistantRaw = azimuthalRaw(function(c2) { - return (c2 = acos$1(c2)) && c2 / sin$1(c2); - }); - azimuthalEquidistantRaw.invert = azimuthalInvert(function(z) { - return z; - }); - function azimuthalEquidistant() { - return projection(azimuthalEquidistantRaw).scale(79.4188).clipAngle(180 - 1e-3); - } - function mercatorRaw(lambda, phi2) { - return [lambda, log$2(tan((halfPi$1 + phi2) / 2))]; - } - mercatorRaw.invert = function(x2, y2) { - return [x2, 2 * atan(exp(y2)) - halfPi$1]; - }; - function mercator() { - return mercatorProjection(mercatorRaw).scale(961 / tau$1); - } - function mercatorProjection(project) { - var m2 = projection(project), center2 = m2.center, scale = m2.scale, translate = m2.translate, clipExtent = m2.clipExtent, x02 = null, y02, x12, y12; - m2.scale = function(_2) { - return arguments.length ? (scale(_2), reclip()) : scale(); - }; - m2.translate = function(_2) { - return arguments.length ? (translate(_2), reclip()) : translate(); - }; - m2.center = function(_2) { - return arguments.length ? (center2(_2), reclip()) : center2(); - }; - m2.clipExtent = function(_2) { - return arguments.length ? (_2 == null ? x02 = y02 = x12 = y12 = null : (x02 = +_2[0][0], y02 = +_2[0][1], x12 = +_2[1][0], y12 = +_2[1][1]), reclip()) : x02 == null ? null : [[x02, y02], [x12, y12]]; - }; - function reclip() { - var k2 = pi$1 * scale(), t = m2(rotation(m2.rotate()).invert([0, 0])); - return clipExtent(x02 == null ? [[t[0] - k2, t[1] - k2], [t[0] + k2, t[1] + k2]] : project === mercatorRaw ? [[Math.max(t[0] - k2, x02), y02], [Math.min(t[0] + k2, x12), y12]] : [[x02, Math.max(t[1] - k2, y02)], [x12, Math.min(t[1] + k2, y12)]]); - } - return reclip(); - } - function tany(y2) { - return tan((halfPi$1 + y2) / 2); - } - function conicConformalRaw(y02, y12) { - var cy0 = cos$1(y02), n = y02 === y12 ? sin$1(y02) : log$2(cy0 / cos$1(y12)) / log$2(tany(y12) / tany(y02)), f = cy0 * pow$1(tany(y02), n) / n; - if (!n) - return mercatorRaw; - function project(x2, y2) { - if (f > 0) { - if (y2 < -halfPi$1 + epsilon$1) - y2 = -halfPi$1 + epsilon$1; - } else { - if (y2 > halfPi$1 - epsilon$1) - y2 = halfPi$1 - epsilon$1; - } - var r = f / pow$1(tany(y2), n); - return [r * sin$1(n * x2), f - r * cos$1(n * x2)]; - } - project.invert = function(x2, y2) { - var fy = f - y2, r = sign$1(n) * sqrt$2(x2 * x2 + fy * fy), l = atan2$1(x2, abs$2(fy)) * sign$1(fy); - if (fy * n < 0) - l -= pi$1 * sign$1(x2) * sign$1(fy); - return [l / n, 2 * atan(pow$1(f / r, 1 / n)) - halfPi$1]; - }; - return project; - } - function conicConformal() { - return conicProjection(conicConformalRaw).scale(109.5).parallels([30, 30]); - } - function equirectangularRaw(lambda, phi2) { - return [lambda, phi2]; - } - equirectangularRaw.invert = equirectangularRaw; - function equirectangular() { - return projection(equirectangularRaw).scale(152.63); - } - function conicEquidistantRaw(y02, y12) { - var cy0 = cos$1(y02), n = y02 === y12 ? sin$1(y02) : (cy0 - cos$1(y12)) / (y12 - y02), g = cy0 / n + y02; - if (abs$2(n) < epsilon$1) - return equirectangularRaw; - function project(x2, y2) { - var gy = g - y2, nx = n * x2; - return [gy * sin$1(nx), g - gy * cos$1(nx)]; - } - project.invert = function(x2, y2) { - var gy = g - y2, l = atan2$1(x2, abs$2(gy)) * sign$1(gy); - if (gy * n < 0) - l -= pi$1 * sign$1(x2) * sign$1(gy); - return [l / n, g - sign$1(n) * sqrt$2(x2 * x2 + gy * gy)]; - }; - return project; - } - function conicEquidistant() { - return conicProjection(conicEquidistantRaw).scale(131.154).center([0, 13.9389]); - } - var A1 = 1.340264, A2 = -0.081106, A3 = 893e-6, A4 = 3796e-6, M = sqrt$2(3) / 2, iterations = 12; - function equalEarthRaw(lambda, phi2) { - var l = asin$1(M * sin$1(phi2)), l2 = l * l, l6 = l2 * l2 * l2; - return [ - lambda * cos$1(l) / (M * (A1 + 3 * A2 * l2 + l6 * (7 * A3 + 9 * A4 * l2))), - l * (A1 + A2 * l2 + l6 * (A3 + A4 * l2)) - ]; - } - equalEarthRaw.invert = function(x2, y2) { - var l = y2, l2 = l * l, l6 = l2 * l2 * l2; - for (var i = 0, delta, fy, fpy; i < iterations; ++i) { - fy = l * (A1 + A2 * l2 + l6 * (A3 + A4 * l2)) - y2; - fpy = A1 + 3 * A2 * l2 + l6 * (7 * A3 + 9 * A4 * l2); - l -= delta = fy / fpy, l2 = l * l, l6 = l2 * l2 * l2; - if (abs$2(delta) < epsilon2) - break; - } - return [ - M * x2 * (A1 + 3 * A2 * l2 + l6 * (7 * A3 + 9 * A4 * l2)) / cos$1(l), - asin$1(sin$1(l) / M) - ]; - }; - function equalEarth() { - return projection(equalEarthRaw).scale(177.158); - } - function gnomonicRaw(x2, y2) { - var cy = cos$1(y2), k2 = cos$1(x2) * cy; - return [cy * sin$1(x2) / k2, sin$1(y2) / k2]; - } - gnomonicRaw.invert = azimuthalInvert(atan); - function gnomonic() { - return projection(gnomonicRaw).scale(144.049).clipAngle(60); - } - function identity$4() { - var k2 = 1, tx = 0, ty = 0, sx = 1, sy = 1, alpha = 0, ca, sa, x02 = null, y02, x12, y12, kx2 = 1, ky2 = 1, transform2 = transformer$3({ - point: function(x2, y2) { - var p = projection2([x2, y2]); - this.stream.point(p[0], p[1]); - } - }), postclip = identity$5, cache, cacheStream; - function reset2() { - kx2 = k2 * sx; - ky2 = k2 * sy; - cache = cacheStream = null; - return projection2; - } - function projection2(p) { - var x2 = p[0] * kx2, y2 = p[1] * ky2; - if (alpha) { - var t = y2 * ca - x2 * sa; - x2 = x2 * ca + y2 * sa; - y2 = t; - } - return [x2 + tx, y2 + ty]; - } - projection2.invert = function(p) { - var x2 = p[0] - tx, y2 = p[1] - ty; - if (alpha) { - var t = y2 * ca + x2 * sa; - x2 = x2 * ca - y2 * sa; - y2 = t; - } - return [x2 / kx2, y2 / ky2]; - }; - projection2.stream = function(stream) { - return cache && cacheStream === stream ? cache : cache = transform2(postclip(cacheStream = stream)); - }; - projection2.postclip = function(_2) { - return arguments.length ? (postclip = _2, x02 = y02 = x12 = y12 = null, reset2()) : postclip; - }; - projection2.clipExtent = function(_2) { - return arguments.length ? (postclip = _2 == null ? (x02 = y02 = x12 = y12 = null, identity$5) : clipRectangle(x02 = +_2[0][0], y02 = +_2[0][1], x12 = +_2[1][0], y12 = +_2[1][1]), reset2()) : x02 == null ? null : [[x02, y02], [x12, y12]]; - }; - projection2.scale = function(_2) { - return arguments.length ? (k2 = +_2, reset2()) : k2; - }; - projection2.translate = function(_2) { - return arguments.length ? (tx = +_2[0], ty = +_2[1], reset2()) : [tx, ty]; - }; - projection2.angle = function(_2) { - return arguments.length ? (alpha = _2 % 360 * radians, sa = sin$1(alpha), ca = cos$1(alpha), reset2()) : alpha * degrees; - }; - projection2.reflectX = function(_2) { - return arguments.length ? (sx = _2 ? -1 : 1, reset2()) : sx < 0; - }; - projection2.reflectY = function(_2) { - return arguments.length ? (sy = _2 ? -1 : 1, reset2()) : sy < 0; - }; - projection2.fitExtent = function(extent2, object2) { - return fitExtent(projection2, extent2, object2); - }; - projection2.fitSize = function(size, object2) { - return fitSize(projection2, size, object2); - }; - projection2.fitWidth = function(width2, object2) { - return fitWidth(projection2, width2, object2); - }; - projection2.fitHeight = function(height2, object2) { - return fitHeight(projection2, height2, object2); - }; - return projection2; - } - function naturalEarth1Raw(lambda, phi2) { - var phi22 = phi2 * phi2, phi4 = phi22 * phi22; - return [ - lambda * (0.8707 - 0.131979 * phi22 + phi4 * (-0.013791 + phi4 * (3971e-6 * phi22 - 1529e-6 * phi4))), - phi2 * (1.007226 + phi22 * (0.015085 + phi4 * (-0.044475 + 0.028874 * phi22 - 5916e-6 * phi4))) - ]; - } - naturalEarth1Raw.invert = function(x2, y2) { - var phi2 = y2, i = 25, delta; - do { - var phi22 = phi2 * phi2, phi4 = phi22 * phi22; - phi2 -= delta = (phi2 * (1.007226 + phi22 * (0.015085 + phi4 * (-0.044475 + 0.028874 * phi22 - 5916e-6 * phi4))) - y2) / (1.007226 + phi22 * (0.015085 * 3 + phi4 * (-0.044475 * 7 + 0.028874 * 9 * phi22 - 5916e-6 * 11 * phi4))); - } while (abs$2(delta) > epsilon$1 && --i > 0); - return [ - x2 / (0.8707 + (phi22 = phi2 * phi2) * (-0.131979 + phi22 * (-0.013791 + phi22 * phi22 * phi22 * (3971e-6 - 1529e-6 * phi22)))), - phi2 - ]; - }; - function naturalEarth1() { - return projection(naturalEarth1Raw).scale(175.295); - } - function orthographicRaw(x2, y2) { - return [cos$1(y2) * sin$1(x2), sin$1(y2)]; - } - orthographicRaw.invert = azimuthalInvert(asin$1); - function orthographic() { - return projection(orthographicRaw).scale(249.5).clipAngle(90 + epsilon$1); - } - function stereographicRaw(x2, y2) { - var cy = cos$1(y2), k2 = 1 + cos$1(x2) * cy; - return [cy * sin$1(x2) / k2, sin$1(y2) / k2]; - } - stereographicRaw.invert = azimuthalInvert(function(z) { - return 2 * atan(z); - }); - function stereographic() { - return projection(stereographicRaw).scale(250).clipAngle(142); - } - function transverseMercatorRaw(lambda, phi2) { - return [log$2(tan((halfPi$1 + phi2) / 2)), -lambda]; - } - transverseMercatorRaw.invert = function(x2, y2) { - return [-y2, 2 * atan(exp(x2)) - halfPi$1]; - }; - function transverseMercator() { - var m2 = mercatorProjection(transverseMercatorRaw), center2 = m2.center, rotate = m2.rotate; - m2.center = function(_2) { - return arguments.length ? center2([-_2[1], _2[0]]) : (_2 = center2(), [_2[1], -_2[0]]); - }; - m2.rotate = function(_2) { - return arguments.length ? rotate([_2[0], _2[1], _2.length > 2 ? _2[2] + 90 : 90]) : (_2 = rotate(), [_2[0], _2[1], _2[2] - 90]); - }; - return rotate([0, 0, 90]).scale(159.155); - } - function defaultSeparation$1(a2, b) { - return a2.parent === b.parent ? 1 : 2; - } - function meanX(children2) { - return children2.reduce(meanXReduce, 0) / children2.length; - } - function meanXReduce(x2, c2) { - return x2 + c2.x; - } - function maxY(children2) { - return 1 + children2.reduce(maxYReduce, 0); - } - function maxYReduce(y2, c2) { - return Math.max(y2, c2.y); - } - function leafLeft(node2) { - var children2; - while (children2 = node2.children) - node2 = children2[0]; - return node2; - } - function leafRight(node2) { - var children2; - while (children2 = node2.children) - node2 = children2[children2.length - 1]; - return node2; - } - function cluster() { - var separation = defaultSeparation$1, dx = 1, dy = 1, nodeSize = false; - function cluster2(root2) { - var previousNode, x2 = 0; - root2.eachAfter(function(node2) { - var children2 = node2.children; - if (children2) { - node2.x = meanX(children2); - node2.y = maxY(children2); - } else { - node2.x = previousNode ? x2 += separation(node2, previousNode) : 0; - node2.y = 0; - previousNode = node2; - } - }); - var left2 = leafLeft(root2), right2 = leafRight(root2), x02 = left2.x - separation(left2, right2) / 2, x12 = right2.x + separation(right2, left2) / 2; - return root2.eachAfter(nodeSize ? function(node2) { - node2.x = (node2.x - root2.x) * dx; - node2.y = (root2.y - node2.y) * dy; - } : function(node2) { - node2.x = (node2.x - x02) / (x12 - x02) * dx; - node2.y = (1 - (root2.y ? node2.y / root2.y : 1)) * dy; - }); - } - cluster2.separation = function(x2) { - return arguments.length ? (separation = x2, cluster2) : separation; - }; - cluster2.size = function(x2) { - return arguments.length ? (nodeSize = false, dx = +x2[0], dy = +x2[1], cluster2) : nodeSize ? null : [dx, dy]; - }; - cluster2.nodeSize = function(x2) { - return arguments.length ? (nodeSize = true, dx = +x2[0], dy = +x2[1], cluster2) : nodeSize ? [dx, dy] : null; - }; - return cluster2; - } - function count(node2) { - var sum2 = 0, children2 = node2.children, i = children2 && children2.length; - if (!i) - sum2 = 1; - else - while (--i >= 0) - sum2 += children2[i].value; - node2.value = sum2; - } - function node_count() { - return this.eachAfter(count); - } - function node_each(callback, that) { - let index2 = -1; - for (const node2 of this) { - callback.call(that, node2, ++index2, this); - } - return this; - } - function node_eachBefore(callback, that) { - var node2 = this, nodes = [node2], children2, i, index2 = -1; - while (node2 = nodes.pop()) { - callback.call(that, node2, ++index2, this); - if (children2 = node2.children) { - for (i = children2.length - 1; i >= 0; --i) { - nodes.push(children2[i]); - } - } - } - return this; - } - function node_eachAfter(callback, that) { - var node2 = this, nodes = [node2], next2 = [], children2, i, n, index2 = -1; - while (node2 = nodes.pop()) { - next2.push(node2); - if (children2 = node2.children) { - for (i = 0, n = children2.length; i < n; ++i) { - nodes.push(children2[i]); - } - } - } - while (node2 = next2.pop()) { - callback.call(that, node2, ++index2, this); - } - return this; - } - function node_find(callback, that) { - let index2 = -1; - for (const node2 of this) { - if (callback.call(that, node2, ++index2, this)) { - return node2; - } - } - } - function node_sum(value) { - return this.eachAfter(function(node2) { - var sum2 = +value(node2.data) || 0, children2 = node2.children, i = children2 && children2.length; - while (--i >= 0) - sum2 += children2[i].value; - node2.value = sum2; - }); - } - function node_sort(compare) { - return this.eachBefore(function(node2) { - if (node2.children) { - node2.children.sort(compare); - } - }); - } - function node_path(end2) { - var start2 = this, ancestor = leastCommonAncestor(start2, end2), nodes = [start2]; - while (start2 !== ancestor) { - start2 = start2.parent; - nodes.push(start2); - } - var k2 = nodes.length; - while (end2 !== ancestor) { - nodes.splice(k2, 0, end2); - end2 = end2.parent; - } - return nodes; - } - function leastCommonAncestor(a2, b) { - if (a2 === b) - return a2; - var aNodes = a2.ancestors(), bNodes = b.ancestors(), c2 = null; - a2 = aNodes.pop(); - b = bNodes.pop(); - while (a2 === b) { - c2 = a2; - a2 = aNodes.pop(); - b = bNodes.pop(); - } - return c2; - } - function node_ancestors() { - var node2 = this, nodes = [node2]; - while (node2 = node2.parent) { - nodes.push(node2); - } - return nodes; - } - function node_descendants() { - return Array.from(this); - } - function node_leaves() { - var leaves = []; - this.eachBefore(function(node2) { - if (!node2.children) { - leaves.push(node2); - } - }); - return leaves; - } - function node_links() { - var root2 = this, links2 = []; - root2.each(function(node2) { - if (node2 !== root2) { - links2.push({ source: node2.parent, target: node2 }); - } - }); - return links2; - } - function* node_iterator() { - var node2 = this, current, next2 = [node2], children2, i, n; - do { - current = next2.reverse(), next2 = []; - while (node2 = current.pop()) { - yield node2; - if (children2 = node2.children) { - for (i = 0, n = children2.length; i < n; ++i) { - next2.push(children2[i]); - } - } - } - } while (next2.length); - } - function hierarchy(data, children2) { - if (data instanceof Map) { - data = [void 0, data]; - if (children2 === void 0) - children2 = mapChildren; - } else if (children2 === void 0) { - children2 = objectChildren; - } - var root2 = new Node$1(data), node2, nodes = [root2], child, childs, i, n; - while (node2 = nodes.pop()) { - if ((childs = children2(node2.data)) && (n = (childs = Array.from(childs)).length)) { - node2.children = childs; - for (i = n - 1; i >= 0; --i) { - nodes.push(child = childs[i] = new Node$1(childs[i])); - child.parent = node2; - child.depth = node2.depth + 1; - } - } - } - return root2.eachBefore(computeHeight); - } - function node_copy() { - return hierarchy(this).eachBefore(copyData); - } - function objectChildren(d) { - return d.children; - } - function mapChildren(d) { - return Array.isArray(d) ? d[1] : null; - } - function copyData(node2) { - if (node2.data.value !== void 0) - node2.value = node2.data.value; - node2.data = node2.data.data; - } - function computeHeight(node2) { - var height2 = 0; - do - node2.height = height2; - while ((node2 = node2.parent) && node2.height < ++height2); - } - function Node$1(data) { - this.data = data; - this.depth = this.height = 0; - this.parent = null; - } - Node$1.prototype = hierarchy.prototype = { - constructor: Node$1, - count: node_count, - each: node_each, - eachAfter: node_eachAfter, - eachBefore: node_eachBefore, - find: node_find, - sum: node_sum, - sort: node_sort, - path: node_path, - ancestors: node_ancestors, - descendants: node_descendants, - leaves: node_leaves, - links: node_links, - copy: node_copy, - [Symbol.iterator]: node_iterator - }; - function optional(f) { - return f == null ? null : required(f); - } - function required(f) { - if (typeof f !== "function") - throw new Error(); - return f; - } - function constantZero() { - return 0; - } - function constant$2(x2) { - return function() { - return x2; - }; - } - const a$1 = 1664525; - const c$4 = 1013904223; - const m = 4294967296; - function lcg$1() { - let s2 = 1; - return () => (s2 = (a$1 * s2 + c$4) % m) / m; - } - function array$1(x2) { - return typeof x2 === "object" && "length" in x2 ? x2 : Array.from(x2); - } - function shuffle(array2, random2) { - let m2 = array2.length, t, i; - while (m2) { - i = random2() * m2-- | 0; - t = array2[m2]; - array2[m2] = array2[i]; - array2[i] = t; - } - return array2; - } - function enclose(circles) { - return packEncloseRandom(circles, lcg$1()); - } - function packEncloseRandom(circles, random2) { - var i = 0, n = (circles = shuffle(Array.from(circles), random2)).length, B2 = [], p, e; - while (i < n) { - p = circles[i]; - if (e && enclosesWeak(e, p)) - ++i; - else - e = encloseBasis(B2 = extendBasis(B2, p)), i = 0; - } - return e; - } - function extendBasis(B2, p) { - var i, j; - if (enclosesWeakAll(p, B2)) - return [p]; - for (i = 0; i < B2.length; ++i) { - if (enclosesNot(p, B2[i]) && enclosesWeakAll(encloseBasis2(B2[i], p), B2)) { - return [B2[i], p]; - } - } - for (i = 0; i < B2.length - 1; ++i) { - for (j = i + 1; j < B2.length; ++j) { - if (enclosesNot(encloseBasis2(B2[i], B2[j]), p) && enclosesNot(encloseBasis2(B2[i], p), B2[j]) && enclosesNot(encloseBasis2(B2[j], p), B2[i]) && enclosesWeakAll(encloseBasis3(B2[i], B2[j], p), B2)) { - return [B2[i], B2[j], p]; - } - } - } - throw new Error(); - } - function enclosesNot(a2, b) { - var dr = a2.r - b.r, dx = b.x - a2.x, dy = b.y - a2.y; - return dr < 0 || dr * dr < dx * dx + dy * dy; - } - function enclosesWeak(a2, b) { - var dr = a2.r - b.r + Math.max(a2.r, b.r, 1) * 1e-9, dx = b.x - a2.x, dy = b.y - a2.y; - return dr > 0 && dr * dr > dx * dx + dy * dy; - } - function enclosesWeakAll(a2, B2) { - for (var i = 0; i < B2.length; ++i) { - if (!enclosesWeak(a2, B2[i])) { - return false; - } - } - return true; - } - function encloseBasis(B2) { - switch (B2.length) { - case 1: - return encloseBasis1(B2[0]); - case 2: - return encloseBasis2(B2[0], B2[1]); - case 3: - return encloseBasis3(B2[0], B2[1], B2[2]); - } - } - function encloseBasis1(a2) { - return { - x: a2.x, - y: a2.y, - r: a2.r - }; - } - function encloseBasis2(a2, b) { - var x12 = a2.x, y12 = a2.y, r1 = a2.r, x2 = b.x, y2 = b.y, r2 = b.r, x21 = x2 - x12, y21 = y2 - y12, r21 = r2 - r1, l = Math.sqrt(x21 * x21 + y21 * y21); - return { - x: (x12 + x2 + x21 / l * r21) / 2, - y: (y12 + y2 + y21 / l * r21) / 2, - r: (l + r1 + r2) / 2 - }; - } - function encloseBasis3(a2, b, c2) { - var x12 = a2.x, y12 = a2.y, r1 = a2.r, x2 = b.x, y2 = b.y, r2 = b.r, x3 = c2.x, y3 = c2.y, r3 = c2.r, a22 = x12 - x2, a3 = x12 - x3, b22 = y12 - y2, b32 = y12 - y3, c22 = r2 - r1, c3 = r3 - r1, d1 = x12 * x12 + y12 * y12 - r1 * r1, d2 = d1 - x2 * x2 - y2 * y2 + r2 * r2, d32 = d1 - x3 * x3 - y3 * y3 + r3 * r3, ab = a3 * b22 - a22 * b32, xa = (b22 * d32 - b32 * d2) / (ab * 2) - x12, xb = (b32 * c22 - b22 * c3) / ab, ya = (a3 * d2 - a22 * d32) / (ab * 2) - y12, yb = (a22 * c3 - a3 * c22) / ab, A5 = xb * xb + yb * yb - 1, B2 = 2 * (r1 + xa * xb + ya * yb), C3 = xa * xa + ya * ya - r1 * r1, r = -(Math.abs(A5) > 1e-6 ? (B2 + Math.sqrt(B2 * B2 - 4 * A5 * C3)) / (2 * A5) : C3 / B2); - return { - x: x12 + xa + xb * r, - y: y12 + ya + yb * r, - r - }; - } - function place(b, a2, c2) { - var dx = b.x - a2.x, x2, a22, dy = b.y - a2.y, y2, b22, d2 = dx * dx + dy * dy; - if (d2) { - a22 = a2.r + c2.r, a22 *= a22; - b22 = b.r + c2.r, b22 *= b22; - if (a22 > b22) { - x2 = (d2 + b22 - a22) / (2 * d2); - y2 = Math.sqrt(Math.max(0, b22 / d2 - x2 * x2)); - c2.x = b.x - x2 * dx - y2 * dy; - c2.y = b.y - x2 * dy + y2 * dx; - } else { - x2 = (d2 + a22 - b22) / (2 * d2); - y2 = Math.sqrt(Math.max(0, a22 / d2 - x2 * x2)); - c2.x = a2.x + x2 * dx - y2 * dy; - c2.y = a2.y + x2 * dy + y2 * dx; - } - } else { - c2.x = a2.x + c2.r; - c2.y = a2.y; - } - } - function intersects(a2, b) { - var dr = a2.r + b.r - 1e-6, dx = b.x - a2.x, dy = b.y - a2.y; - return dr > 0 && dr * dr > dx * dx + dy * dy; - } - function score(node2) { - var a2 = node2._, b = node2.next._, ab = a2.r + b.r, dx = (a2.x * b.r + b.x * a2.r) / ab, dy = (a2.y * b.r + b.y * a2.r) / ab; - return dx * dx + dy * dy; - } - function Node(circle2) { - this._ = circle2; - this.next = null; - this.previous = null; - } - function packSiblingsRandom(circles, random2) { - if (!(n = (circles = array$1(circles)).length)) - return 0; - var a2, b, c2, n, aa, ca, i, j, k2, sj, sk; - a2 = circles[0], a2.x = 0, a2.y = 0; - if (!(n > 1)) - return a2.r; - b = circles[1], a2.x = -b.r, b.x = a2.r, b.y = 0; - if (!(n > 2)) - return a2.r + b.r; - place(b, a2, c2 = circles[2]); - a2 = new Node(a2), b = new Node(b), c2 = new Node(c2); - a2.next = c2.previous = b; - b.next = a2.previous = c2; - c2.next = b.previous = a2; - pack: - for (i = 3; i < n; ++i) { - place(a2._, b._, c2 = circles[i]), c2 = new Node(c2); - j = b.next, k2 = a2.previous, sj = b._.r, sk = a2._.r; - do { - if (sj <= sk) { - if (intersects(j._, c2._)) { - b = j, a2.next = b, b.previous = a2, --i; - continue pack; - } - sj += j._.r, j = j.next; - } else { - if (intersects(k2._, c2._)) { - a2 = k2, a2.next = b, b.previous = a2, --i; - continue pack; - } - sk += k2._.r, k2 = k2.previous; - } - } while (j !== k2.next); - c2.previous = a2, c2.next = b, a2.next = b.previous = b = c2; - aa = score(a2); - while ((c2 = c2.next) !== b) { - if ((ca = score(c2)) < aa) { - a2 = c2, aa = ca; - } - } - b = a2.next; - } - a2 = [b._], c2 = b; - while ((c2 = c2.next) !== b) - a2.push(c2._); - c2 = packEncloseRandom(a2, random2); - for (i = 0; i < n; ++i) - a2 = circles[i], a2.x -= c2.x, a2.y -= c2.y; - return c2.r; - } - function siblings(circles) { - packSiblingsRandom(circles, lcg$1()); - return circles; - } - function defaultRadius(d) { - return Math.sqrt(d.value); - } - function index$1() { - var radius = null, dx = 1, dy = 1, padding2 = constantZero; - function pack(root2) { - const random2 = lcg$1(); - root2.x = dx / 2, root2.y = dy / 2; - if (radius) { - root2.eachBefore(radiusLeaf(radius)).eachAfter(packChildrenRandom(padding2, 0.5, random2)).eachBefore(translateChild(1)); - } else { - root2.eachBefore(radiusLeaf(defaultRadius)).eachAfter(packChildrenRandom(constantZero, 1, random2)).eachAfter(packChildrenRandom(padding2, root2.r / Math.min(dx, dy), random2)).eachBefore(translateChild(Math.min(dx, dy) / (2 * root2.r))); - } - return root2; - } - pack.radius = function(x2) { - return arguments.length ? (radius = optional(x2), pack) : radius; - }; - pack.size = function(x2) { - return arguments.length ? (dx = +x2[0], dy = +x2[1], pack) : [dx, dy]; - }; - pack.padding = function(x2) { - return arguments.length ? (padding2 = typeof x2 === "function" ? x2 : constant$2(+x2), pack) : padding2; - }; - return pack; - } - function radiusLeaf(radius) { - return function(node2) { - if (!node2.children) { - node2.r = Math.max(0, +radius(node2) || 0); - } - }; - } - function packChildrenRandom(padding2, k2, random2) { - return function(node2) { - if (children2 = node2.children) { - var children2, i, n = children2.length, r = padding2(node2) * k2 || 0, e; - if (r) - for (i = 0; i < n; ++i) - children2[i].r += r; - e = packSiblingsRandom(children2, random2); - if (r) - for (i = 0; i < n; ++i) - children2[i].r -= r; - node2.r = e + r; - } - }; - } - function translateChild(k2) { - return function(node2) { - var parent = node2.parent; - node2.r *= k2; - if (parent) { - node2.x = parent.x + k2 * node2.x; - node2.y = parent.y + k2 * node2.y; - } - }; - } - function roundNode(node2) { - node2.x0 = Math.round(node2.x0); - node2.y0 = Math.round(node2.y0); - node2.x1 = Math.round(node2.x1); - node2.y1 = Math.round(node2.y1); - } - function treemapDice(parent, x02, y02, x12, y12) { - var nodes = parent.children, node2, i = -1, n = nodes.length, k2 = parent.value && (x12 - x02) / parent.value; - while (++i < n) { - node2 = nodes[i], node2.y0 = y02, node2.y1 = y12; - node2.x0 = x02, node2.x1 = x02 += node2.value * k2; - } - } - function partition() { - var dx = 1, dy = 1, padding2 = 0, round = false; - function partition2(root2) { - var n = root2.height + 1; - root2.x0 = root2.y0 = padding2; - root2.x1 = dx; - root2.y1 = dy / n; - root2.eachBefore(positionNode2(dy, n)); - if (round) - root2.eachBefore(roundNode); - return root2; - } - function positionNode2(dy2, n) { - return function(node2) { - if (node2.children) { - treemapDice(node2, node2.x0, dy2 * (node2.depth + 1) / n, node2.x1, dy2 * (node2.depth + 2) / n); - } - var x02 = node2.x0, y02 = node2.y0, x12 = node2.x1 - padding2, y12 = node2.y1 - padding2; - if (x12 < x02) - x02 = x12 = (x02 + x12) / 2; - if (y12 < y02) - y02 = y12 = (y02 + y12) / 2; - node2.x0 = x02; - node2.y0 = y02; - node2.x1 = x12; - node2.y1 = y12; - }; - } - partition2.round = function(x2) { - return arguments.length ? (round = !!x2, partition2) : round; - }; - partition2.size = function(x2) { - return arguments.length ? (dx = +x2[0], dy = +x2[1], partition2) : [dx, dy]; - }; - partition2.padding = function(x2) { - return arguments.length ? (padding2 = +x2, partition2) : padding2; - }; - return partition2; - } - var preroot = { depth: -1 }, ambiguous = {}, imputed = {}; - function defaultId(d) { - return d.id; - } - function defaultParentId(d) { - return d.parentId; - } - function stratify() { - var id2 = defaultId, parentId = defaultParentId, path2; - function stratify2(data) { - var nodes = Array.from(data), currentId = id2, currentParentId = parentId, n, d, i, root2, parent, node2, nodeId, nodeKey, nodeByKey = /* @__PURE__ */ new Map(); - if (path2 != null) { - const I = nodes.map((d2, i2) => normalize$2(path2(d2, i2, data))); - const P = I.map(parentof); - const S = new Set(I).add(""); - for (const i2 of P) { - if (!S.has(i2)) { - S.add(i2); - I.push(i2); - P.push(parentof(i2)); - nodes.push(imputed); - } - } - currentId = (_2, i2) => I[i2]; - currentParentId = (_2, i2) => P[i2]; - } - for (i = 0, n = nodes.length; i < n; ++i) { - d = nodes[i], node2 = nodes[i] = new Node$1(d); - if ((nodeId = currentId(d, i, data)) != null && (nodeId += "")) { - nodeKey = node2.id = nodeId; - nodeByKey.set(nodeKey, nodeByKey.has(nodeKey) ? ambiguous : node2); - } - if ((nodeId = currentParentId(d, i, data)) != null && (nodeId += "")) { - node2.parent = nodeId; - } - } - for (i = 0; i < n; ++i) { - node2 = nodes[i]; - if (nodeId = node2.parent) { - parent = nodeByKey.get(nodeId); - if (!parent) - throw new Error("missing: " + nodeId); - if (parent === ambiguous) - throw new Error("ambiguous: " + nodeId); - if (parent.children) - parent.children.push(node2); - else - parent.children = [node2]; - node2.parent = parent; - } else { - if (root2) - throw new Error("multiple roots"); - root2 = node2; - } - } - if (!root2) - throw new Error("no root"); - if (path2 != null) { - while (root2.data === imputed && root2.children.length === 1) { - root2 = root2.children[0], --n; - } - for (let i2 = nodes.length - 1; i2 >= 0; --i2) { - node2 = nodes[i2]; - if (node2.data !== imputed) - break; - node2.data = null; - } - } - root2.parent = preroot; - root2.eachBefore(function(node3) { - node3.depth = node3.parent.depth + 1; - --n; - }).eachBefore(computeHeight); - root2.parent = null; - if (n > 0) - throw new Error("cycle"); - return root2; - } - stratify2.id = function(x2) { - return arguments.length ? (id2 = optional(x2), stratify2) : id2; - }; - stratify2.parentId = function(x2) { - return arguments.length ? (parentId = optional(x2), stratify2) : parentId; - }; - stratify2.path = function(x2) { - return arguments.length ? (path2 = optional(x2), stratify2) : path2; - }; - return stratify2; - } - function normalize$2(path2) { - path2 = `${path2}`; - let i = path2.length; - if (slash(path2, i - 1) && !slash(path2, i - 2)) - path2 = path2.slice(0, -1); - return path2[0] === "/" ? path2 : `/${path2}`; - } - function parentof(path2) { - let i = path2.length; - if (i < 2) - return ""; - while (--i > 1) - if (slash(path2, i)) - break; - return path2.slice(0, i); - } - function slash(path2, i) { - if (path2[i] === "/") { - let k2 = 0; - while (i > 0 && path2[--i] === "\\") - ++k2; - if ((k2 & 1) === 0) - return true; - } - return false; - } - function defaultSeparation(a2, b) { - return a2.parent === b.parent ? 1 : 2; - } - function nextLeft(v) { - var children2 = v.children; - return children2 ? children2[0] : v.t; - } - function nextRight(v) { - var children2 = v.children; - return children2 ? children2[children2.length - 1] : v.t; - } - function moveSubtree(wm, wp, shift) { - var change2 = shift / (wp.i - wm.i); - wp.c -= change2; - wp.s += shift; - wm.c += change2; - wp.z += shift; - wp.m += shift; - } - function executeShifts(v) { - var shift = 0, change2 = 0, children2 = v.children, i = children2.length, w2; - while (--i >= 0) { - w2 = children2[i]; - w2.z += shift; - w2.m += shift; - shift += w2.s + (change2 += w2.c); - } - } - function nextAncestor(vim, v, ancestor) { - return vim.a.parent === v.parent ? vim.a : ancestor; - } - function TreeNode(node2, i) { - this._ = node2; - this.parent = null; - this.children = null; - this.A = null; - this.a = this; - this.z = 0; - this.m = 0; - this.c = 0; - this.s = 0; - this.t = null; - this.i = i; - } - TreeNode.prototype = Object.create(Node$1.prototype); - function treeRoot(root2) { - var tree2 = new TreeNode(root2, 0), node2, nodes = [tree2], child, children2, i, n; - while (node2 = nodes.pop()) { - if (children2 = node2._.children) { - node2.children = new Array(n = children2.length); - for (i = n - 1; i >= 0; --i) { - nodes.push(child = node2.children[i] = new TreeNode(children2[i], i)); - child.parent = node2; - } - } - } - (tree2.parent = new TreeNode(null, 0)).children = [tree2]; - return tree2; - } - function tree() { - var separation = defaultSeparation, dx = 1, dy = 1, nodeSize = null; - function tree2(root2) { - var t = treeRoot(root2); - t.eachAfter(firstWalk), t.parent.m = -t.z; - t.eachBefore(secondWalk); - if (nodeSize) - root2.eachBefore(sizeNode); - else { - var left2 = root2, right2 = root2, bottom2 = root2; - root2.eachBefore(function(node2) { - if (node2.x < left2.x) - left2 = node2; - if (node2.x > right2.x) - right2 = node2; - if (node2.depth > bottom2.depth) - bottom2 = node2; - }); - var s2 = left2 === right2 ? 1 : separation(left2, right2) / 2, tx = s2 - left2.x, kx2 = dx / (right2.x + s2 + tx), ky2 = dy / (bottom2.depth || 1); - root2.eachBefore(function(node2) { - node2.x = (node2.x + tx) * kx2; - node2.y = node2.depth * ky2; - }); - } - return root2; - } - function firstWalk(v) { - var children2 = v.children, siblings2 = v.parent.children, w2 = v.i ? siblings2[v.i - 1] : null; - if (children2) { - executeShifts(v); - var midpoint = (children2[0].z + children2[children2.length - 1].z) / 2; - if (w2) { - v.z = w2.z + separation(v._, w2._); - v.m = v.z - midpoint; - } else { - v.z = midpoint; - } - } else if (w2) { - v.z = w2.z + separation(v._, w2._); - } - v.parent.A = apportion(v, w2, v.parent.A || siblings2[0]); - } - function secondWalk(v) { - v._.x = v.z + v.parent.m; - v.m += v.parent.m; - } - function apportion(v, w2, ancestor) { - if (w2) { - var vip = v, vop = v, vim = w2, vom = vip.parent.children[0], sip = vip.m, sop = vop.m, sim = vim.m, som = vom.m, shift; - while (vim = nextRight(vim), vip = nextLeft(vip), vim && vip) { - vom = nextLeft(vom); - vop = nextRight(vop); - vop.a = v; - shift = vim.z + sim - vip.z - sip + separation(vim._, vip._); - if (shift > 0) { - moveSubtree(nextAncestor(vim, v, ancestor), v, shift); - sip += shift; - sop += shift; - } - sim += vim.m; - sip += vip.m; - som += vom.m; - sop += vop.m; - } - if (vim && !nextRight(vop)) { - vop.t = vim; - vop.m += sim - sop; - } - if (vip && !nextLeft(vom)) { - vom.t = vip; - vom.m += sip - som; - ancestor = v; - } - } - return ancestor; - } - function sizeNode(node2) { - node2.x *= dx; - node2.y = node2.depth * dy; - } - tree2.separation = function(x2) { - return arguments.length ? (separation = x2, tree2) : separation; - }; - tree2.size = function(x2) { - return arguments.length ? (nodeSize = false, dx = +x2[0], dy = +x2[1], tree2) : nodeSize ? null : [dx, dy]; - }; - tree2.nodeSize = function(x2) { - return arguments.length ? (nodeSize = true, dx = +x2[0], dy = +x2[1], tree2) : nodeSize ? [dx, dy] : null; - }; - return tree2; - } - function treemapSlice(parent, x02, y02, x12, y12) { - var nodes = parent.children, node2, i = -1, n = nodes.length, k2 = parent.value && (y12 - y02) / parent.value; - while (++i < n) { - node2 = nodes[i], node2.x0 = x02, node2.x1 = x12; - node2.y0 = y02, node2.y1 = y02 += node2.value * k2; - } - } - var phi = (1 + Math.sqrt(5)) / 2; - function squarifyRatio(ratio, parent, x02, y02, x12, y12) { - var rows = [], nodes = parent.children, row, nodeValue, i0 = 0, i1 = 0, n = nodes.length, dx, dy, value = parent.value, sumValue, minValue, maxValue, newRatio, minRatio, alpha, beta2; - while (i0 < n) { - dx = x12 - x02, dy = y12 - y02; - do - sumValue = nodes[i1++].value; - while (!sumValue && i1 < n); - minValue = maxValue = sumValue; - alpha = Math.max(dy / dx, dx / dy) / (value * ratio); - beta2 = sumValue * sumValue * alpha; - minRatio = Math.max(maxValue / beta2, beta2 / minValue); - for (; i1 < n; ++i1) { - sumValue += nodeValue = nodes[i1].value; - if (nodeValue < minValue) - minValue = nodeValue; - if (nodeValue > maxValue) - maxValue = nodeValue; - beta2 = sumValue * sumValue * alpha; - newRatio = Math.max(maxValue / beta2, beta2 / minValue); - if (newRatio > minRatio) { - sumValue -= nodeValue; - break; - } - minRatio = newRatio; - } - rows.push(row = { value: sumValue, dice: dx < dy, children: nodes.slice(i0, i1) }); - if (row.dice) - treemapDice(row, x02, y02, x12, value ? y02 += dy * sumValue / value : y12); - else - treemapSlice(row, x02, y02, value ? x02 += dx * sumValue / value : x12, y12); - value -= sumValue, i0 = i1; - } - return rows; - } - const squarify = function custom(ratio) { - function squarify2(parent, x02, y02, x12, y12) { - squarifyRatio(ratio, parent, x02, y02, x12, y12); - } - squarify2.ratio = function(x2) { - return custom((x2 = +x2) > 1 ? x2 : 1); - }; - return squarify2; - }(phi); - function index() { - var tile = squarify, round = false, dx = 1, dy = 1, paddingStack = [0], paddingInner = constantZero, paddingTop = constantZero, paddingRight = constantZero, paddingBottom = constantZero, paddingLeft = constantZero; - function treemap(root2) { - root2.x0 = root2.y0 = 0; - root2.x1 = dx; - root2.y1 = dy; - root2.eachBefore(positionNode2); - paddingStack = [0]; - if (round) - root2.eachBefore(roundNode); - return root2; - } - function positionNode2(node2) { - var p = paddingStack[node2.depth], x02 = node2.x0 + p, y02 = node2.y0 + p, x12 = node2.x1 - p, y12 = node2.y1 - p; - if (x12 < x02) - x02 = x12 = (x02 + x12) / 2; - if (y12 < y02) - y02 = y12 = (y02 + y12) / 2; - node2.x0 = x02; - node2.y0 = y02; - node2.x1 = x12; - node2.y1 = y12; - if (node2.children) { - p = paddingStack[node2.depth + 1] = paddingInner(node2) / 2; - x02 += paddingLeft(node2) - p; - y02 += paddingTop(node2) - p; - x12 -= paddingRight(node2) - p; - y12 -= paddingBottom(node2) - p; - if (x12 < x02) - x02 = x12 = (x02 + x12) / 2; - if (y12 < y02) - y02 = y12 = (y02 + y12) / 2; - tile(node2, x02, y02, x12, y12); - } - } - treemap.round = function(x2) { - return arguments.length ? (round = !!x2, treemap) : round; - }; - treemap.size = function(x2) { - return arguments.length ? (dx = +x2[0], dy = +x2[1], treemap) : [dx, dy]; - }; - treemap.tile = function(x2) { - return arguments.length ? (tile = required(x2), treemap) : tile; - }; - treemap.padding = function(x2) { - return arguments.length ? treemap.paddingInner(x2).paddingOuter(x2) : treemap.paddingInner(); - }; - treemap.paddingInner = function(x2) { - return arguments.length ? (paddingInner = typeof x2 === "function" ? x2 : constant$2(+x2), treemap) : paddingInner; - }; - treemap.paddingOuter = function(x2) { - return arguments.length ? treemap.paddingTop(x2).paddingRight(x2).paddingBottom(x2).paddingLeft(x2) : treemap.paddingTop(); - }; - treemap.paddingTop = function(x2) { - return arguments.length ? (paddingTop = typeof x2 === "function" ? x2 : constant$2(+x2), treemap) : paddingTop; - }; - treemap.paddingRight = function(x2) { - return arguments.length ? (paddingRight = typeof x2 === "function" ? x2 : constant$2(+x2), treemap) : paddingRight; - }; - treemap.paddingBottom = function(x2) { - return arguments.length ? (paddingBottom = typeof x2 === "function" ? x2 : constant$2(+x2), treemap) : paddingBottom; - }; - treemap.paddingLeft = function(x2) { - return arguments.length ? (paddingLeft = typeof x2 === "function" ? x2 : constant$2(+x2), treemap) : paddingLeft; - }; - return treemap; - } - function binary(parent, x02, y02, x12, y12) { - var nodes = parent.children, i, n = nodes.length, sum2, sums = new Array(n + 1); - for (sums[0] = sum2 = i = 0; i < n; ++i) { - sums[i + 1] = sum2 += nodes[i].value; - } - partition2(0, n, parent.value, x02, y02, x12, y12); - function partition2(i2, j, value, x03, y03, x13, y13) { - if (i2 >= j - 1) { - var node2 = nodes[i2]; - node2.x0 = x03, node2.y0 = y03; - node2.x1 = x13, node2.y1 = y13; - return; - } - var valueOffset = sums[i2], valueTarget = value / 2 + valueOffset, k2 = i2 + 1, hi = j - 1; - while (k2 < hi) { - var mid = k2 + hi >>> 1; - if (sums[mid] < valueTarget) - k2 = mid + 1; - else - hi = mid; - } - if (valueTarget - sums[k2 - 1] < sums[k2] - valueTarget && i2 + 1 < k2) - --k2; - var valueLeft = sums[k2] - valueOffset, valueRight = value - valueLeft; - if (x13 - x03 > y13 - y03) { - var xk = value ? (x03 * valueRight + x13 * valueLeft) / value : x13; - partition2(i2, k2, valueLeft, x03, y03, xk, y13); - partition2(k2, j, valueRight, xk, y03, x13, y13); - } else { - var yk = value ? (y03 * valueRight + y13 * valueLeft) / value : y13; - partition2(i2, k2, valueLeft, x03, y03, x13, yk); - partition2(k2, j, valueRight, x03, yk, x13, y13); - } - } - } - function sliceDice(parent, x02, y02, x12, y12) { - (parent.depth & 1 ? treemapSlice : treemapDice)(parent, x02, y02, x12, y12); - } - const resquarify = function custom(ratio) { - function resquarify2(parent, x02, y02, x12, y12) { - if ((rows = parent._squarify) && rows.ratio === ratio) { - var rows, row, nodes, i, j = -1, n, m2 = rows.length, value = parent.value; - while (++j < m2) { - row = rows[j], nodes = row.children; - for (i = row.value = 0, n = nodes.length; i < n; ++i) - row.value += nodes[i].value; - if (row.dice) - treemapDice(row, x02, y02, x12, value ? y02 += (y12 - y02) * row.value / value : y12); - else - treemapSlice(row, x02, y02, value ? x02 += (x12 - x02) * row.value / value : x12, y12); - value -= row.value; - } - } else { - parent._squarify = rows = squarifyRatio(ratio, parent, x02, y02, x12, y12); - rows.ratio = ratio; - } - } - resquarify2.ratio = function(x2) { - return custom((x2 = +x2) > 1 ? x2 : 1); - }; - return resquarify2; - }(phi); - function area$1(polygon) { - var i = -1, n = polygon.length, a2, b = polygon[n - 1], area2 = 0; - while (++i < n) { - a2 = b; - b = polygon[i]; - area2 += a2[1] * b[0] - a2[0] * b[1]; - } - return area2 / 2; - } - function centroid(polygon) { - var i = -1, n = polygon.length, x2 = 0, y2 = 0, a2, b = polygon[n - 1], c2, k2 = 0; - while (++i < n) { - a2 = b; - b = polygon[i]; - k2 += c2 = a2[0] * b[1] - b[0] * a2[1]; - x2 += (a2[0] + b[0]) * c2; - y2 += (a2[1] + b[1]) * c2; - } - return k2 *= 3, [x2 / k2, y2 / k2]; - } - function cross$2(a2, b, c2) { - return (b[0] - a2[0]) * (c2[1] - a2[1]) - (b[1] - a2[1]) * (c2[0] - a2[0]); - } - function lexicographicOrder(a2, b) { - return a2[0] - b[0] || a2[1] - b[1]; - } - function computeUpperHullIndexes(points) { - const n = points.length, indexes2 = [0, 1]; - let size = 2, i; - for (i = 2; i < n; ++i) { - while (size > 1 && cross$2(points[indexes2[size - 2]], points[indexes2[size - 1]], points[i]) <= 0) - --size; - indexes2[size++] = i; - } - return indexes2.slice(0, size); - } - function hull(points) { - if ((n = points.length) < 3) - return null; - var i, n, sortedPoints = new Array(n), flippedPoints = new Array(n); - for (i = 0; i < n; ++i) - sortedPoints[i] = [+points[i][0], +points[i][1], i]; - sortedPoints.sort(lexicographicOrder); - for (i = 0; i < n; ++i) - flippedPoints[i] = [sortedPoints[i][0], -sortedPoints[i][1]]; - var upperIndexes = computeUpperHullIndexes(sortedPoints), lowerIndexes = computeUpperHullIndexes(flippedPoints); - var skipLeft = lowerIndexes[0] === upperIndexes[0], skipRight = lowerIndexes[lowerIndexes.length - 1] === upperIndexes[upperIndexes.length - 1], hull2 = []; - for (i = upperIndexes.length - 1; i >= 0; --i) - hull2.push(points[sortedPoints[upperIndexes[i]][2]]); - for (i = +skipLeft; i < lowerIndexes.length - skipRight; ++i) - hull2.push(points[sortedPoints[lowerIndexes[i]][2]]); - return hull2; - } - function contains(polygon, point2) { - var n = polygon.length, p = polygon[n - 1], x2 = point2[0], y2 = point2[1], x02 = p[0], y02 = p[1], x12, y12, inside = false; - for (var i = 0; i < n; ++i) { - p = polygon[i], x12 = p[0], y12 = p[1]; - if (y12 > y2 !== y02 > y2 && x2 < (x02 - x12) * (y2 - y12) / (y02 - y12) + x12) - inside = !inside; - x02 = x12, y02 = y12; - } - return inside; - } - function length$1(polygon) { - var i = -1, n = polygon.length, b = polygon[n - 1], xa, ya, xb = b[0], yb = b[1], perimeter = 0; - while (++i < n) { - xa = xb; - ya = yb; - b = polygon[i]; - xb = b[0]; - yb = b[1]; - xa -= xb; - ya -= yb; - perimeter += Math.hypot(xa, ya); - } - return perimeter; - } - const defaultSource = Math.random; - const uniform = function sourceRandomUniform(source) { - function randomUniform(min2, max2) { - min2 = min2 == null ? 0 : +min2; - max2 = max2 == null ? 1 : +max2; - if (arguments.length === 1) - max2 = min2, min2 = 0; - else - max2 -= min2; - return function() { - return source() * max2 + min2; - }; - } - randomUniform.source = sourceRandomUniform; - return randomUniform; - }(defaultSource); - const int = function sourceRandomInt(source) { - function randomInt(min2, max2) { - if (arguments.length < 2) - max2 = min2, min2 = 0; - min2 = Math.floor(min2); - max2 = Math.floor(max2) - min2; - return function() { - return Math.floor(source() * max2 + min2); - }; - } - randomInt.source = sourceRandomInt; - return randomInt; - }(defaultSource); - const normal = function sourceRandomNormal(source) { - function randomNormal(mu, sigma) { - var x2, r; - mu = mu == null ? 0 : +mu; - sigma = sigma == null ? 1 : +sigma; - return function() { - var y2; - if (x2 != null) - y2 = x2, x2 = null; - else - do { - x2 = source() * 2 - 1; - y2 = source() * 2 - 1; - r = x2 * x2 + y2 * y2; - } while (!r || r > 1); - return mu + sigma * y2 * Math.sqrt(-2 * Math.log(r) / r); - }; - } - randomNormal.source = sourceRandomNormal; - return randomNormal; - }(defaultSource); - const logNormal = function sourceRandomLogNormal(source) { - var N = normal.source(source); - function randomLogNormal() { - var randomNormal = N.apply(this, arguments); - return function() { - return Math.exp(randomNormal()); - }; - } - randomLogNormal.source = sourceRandomLogNormal; - return randomLogNormal; - }(defaultSource); - const irwinHall = function sourceRandomIrwinHall(source) { - function randomIrwinHall(n) { - if ((n = +n) <= 0) - return () => 0; - return function() { - for (var sum2 = 0, i = n; i > 1; --i) - sum2 += source(); - return sum2 + i * source(); - }; - } - randomIrwinHall.source = sourceRandomIrwinHall; - return randomIrwinHall; - }(defaultSource); - const bates = function sourceRandomBates(source) { - var I = irwinHall.source(source); - function randomBates(n) { - if ((n = +n) === 0) - return source; - var randomIrwinHall = I(n); - return function() { - return randomIrwinHall() / n; - }; - } - randomBates.source = sourceRandomBates; - return randomBates; - }(defaultSource); - const exponential = function sourceRandomExponential(source) { - function randomExponential(lambda) { - return function() { - return -Math.log1p(-source()) / lambda; - }; - } - randomExponential.source = sourceRandomExponential; - return randomExponential; - }(defaultSource); - const pareto = function sourceRandomPareto(source) { - function randomPareto(alpha) { - if ((alpha = +alpha) < 0) - throw new RangeError("invalid alpha"); - alpha = 1 / -alpha; - return function() { - return Math.pow(1 - source(), alpha); - }; - } - randomPareto.source = sourceRandomPareto; - return randomPareto; - }(defaultSource); - const bernoulli = function sourceRandomBernoulli(source) { - function randomBernoulli(p) { - if ((p = +p) < 0 || p > 1) - throw new RangeError("invalid p"); - return function() { - return Math.floor(source() + p); - }; - } - randomBernoulli.source = sourceRandomBernoulli; - return randomBernoulli; - }(defaultSource); - const geometric = function sourceRandomGeometric(source) { - function randomGeometric(p) { - if ((p = +p) < 0 || p > 1) - throw new RangeError("invalid p"); - if (p === 0) - return () => Infinity; - if (p === 1) - return () => 1; - p = Math.log1p(-p); - return function() { - return 1 + Math.floor(Math.log1p(-source()) / p); - }; - } - randomGeometric.source = sourceRandomGeometric; - return randomGeometric; - }(defaultSource); - const gamma = function sourceRandomGamma(source) { - var randomNormal = normal.source(source)(); - function randomGamma(k2, theta) { - if ((k2 = +k2) < 0) - throw new RangeError("invalid k"); - if (k2 === 0) - return () => 0; - theta = theta == null ? 1 : +theta; - if (k2 === 1) - return () => -Math.log1p(-source()) * theta; - var d = (k2 < 1 ? k2 + 1 : k2) - 1 / 3, c2 = 1 / (3 * Math.sqrt(d)), multiplier = k2 < 1 ? () => Math.pow(source(), 1 / k2) : () => 1; - return function() { - do { - do { - var x2 = randomNormal(), v = 1 + c2 * x2; - } while (v <= 0); - v *= v * v; - var u2 = 1 - source(); - } while (u2 >= 1 - 0.0331 * x2 * x2 * x2 * x2 && Math.log(u2) >= 0.5 * x2 * x2 + d * (1 - v + Math.log(v))); - return d * v * multiplier() * theta; - }; - } - randomGamma.source = sourceRandomGamma; - return randomGamma; - }(defaultSource); - const beta = function sourceRandomBeta(source) { - var G = gamma.source(source); - function randomBeta(alpha, beta2) { - var X3 = G(alpha), Y3 = G(beta2); - return function() { - var x2 = X3(); - return x2 === 0 ? 0 : x2 / (x2 + Y3()); - }; - } - randomBeta.source = sourceRandomBeta; - return randomBeta; - }(defaultSource); - const binomial = function sourceRandomBinomial(source) { - var G = geometric.source(source), B2 = beta.source(source); - function randomBinomial(n, p) { - n = +n; - if ((p = +p) >= 1) - return () => n; - if (p <= 0) - return () => 0; - return function() { - var acc = 0, nn = n, pp = p; - while (nn * pp > 16 && nn * (1 - pp) > 16) { - var i = Math.floor((nn + 1) * pp), y2 = B2(i, nn - i + 1)(); - if (y2 <= pp) { - acc += i; - nn -= i; - pp = (pp - y2) / (1 - y2); - } else { - nn = i - 1; - pp /= y2; - } - } - var sign2 = pp < 0.5, pFinal = sign2 ? pp : 1 - pp, g = G(pFinal); - for (var s2 = g(), k2 = 0; s2 <= nn; ++k2) - s2 += g(); - return acc + (sign2 ? k2 : nn - k2); - }; - } - randomBinomial.source = sourceRandomBinomial; - return randomBinomial; - }(defaultSource); - const weibull = function sourceRandomWeibull(source) { - function randomWeibull(k2, a2, b) { - var outerFunc; - if ((k2 = +k2) === 0) { - outerFunc = (x2) => -Math.log(x2); - } else { - k2 = 1 / k2; - outerFunc = (x2) => Math.pow(x2, k2); - } - a2 = a2 == null ? 0 : +a2; - b = b == null ? 1 : +b; - return function() { - return a2 + b * outerFunc(-Math.log1p(-source())); - }; - } - randomWeibull.source = sourceRandomWeibull; - return randomWeibull; - }(defaultSource); - const cauchy = function sourceRandomCauchy(source) { - function randomCauchy(a2, b) { - a2 = a2 == null ? 0 : +a2; - b = b == null ? 1 : +b; - return function() { - return a2 + b * Math.tan(Math.PI * source()); - }; - } - randomCauchy.source = sourceRandomCauchy; - return randomCauchy; - }(defaultSource); - const logistic = function sourceRandomLogistic(source) { - function randomLogistic(a2, b) { - a2 = a2 == null ? 0 : +a2; - b = b == null ? 1 : +b; - return function() { - var u2 = source(); - return a2 + b * Math.log(u2 / (1 - u2)); - }; - } - randomLogistic.source = sourceRandomLogistic; - return randomLogistic; - }(defaultSource); - const poisson = function sourceRandomPoisson(source) { - var G = gamma.source(source), B2 = binomial.source(source); - function randomPoisson(lambda) { - return function() { - var acc = 0, l = lambda; - while (l > 16) { - var n = Math.floor(0.875 * l), t = G(n)(); - if (t > l) - return acc + B2(n - 1, l / t)(); - acc += n; - l -= t; - } - for (var s2 = -Math.log1p(-source()), k2 = 0; s2 <= l; ++k2) - s2 -= Math.log1p(-source()); - return acc + k2; - }; - } - randomPoisson.source = sourceRandomPoisson; - return randomPoisson; - }(defaultSource); - const mul = 1664525; - const inc = 1013904223; - const eps = 1 / 4294967296; - function lcg(seed = Math.random()) { - let state = (0 <= seed && seed < 1 ? seed / eps : Math.abs(seed)) | 0; - return () => (state = mul * state + inc | 0, eps * (state >>> 0)); - } - function initRange(domain, range2) { - switch (arguments.length) { - case 0: - break; - case 1: - this.range(domain); - break; - default: - this.range(range2).domain(domain); - break; - } - return this; - } - function initInterpolator(domain, interpolator) { - switch (arguments.length) { - case 0: - break; - case 1: { - if (typeof domain === "function") - this.interpolator(domain); - else - this.range(domain); - break; - } - default: { - this.domain(domain); - if (typeof interpolator === "function") - this.interpolator(interpolator); - else - this.range(interpolator); - break; - } - } - return this; - } - const implicit = Symbol("implicit"); - function ordinal() { - var index2 = new InternMap(), domain = [], range2 = [], unknown = implicit; - function scale(d) { - let i = index2.get(d); - if (i === void 0) { - if (unknown !== implicit) - return unknown; - index2.set(d, i = domain.push(d) - 1); - } - return range2[i % range2.length]; - } - scale.domain = function(_2) { - if (!arguments.length) - return domain.slice(); - domain = [], index2 = new InternMap(); - for (const value of _2) { - if (index2.has(value)) - continue; - index2.set(value, domain.push(value) - 1); - } - return scale; - }; - scale.range = function(_2) { - return arguments.length ? (range2 = Array.from(_2), scale) : range2.slice(); - }; - scale.unknown = function(_2) { - return arguments.length ? (unknown = _2, scale) : unknown; - }; - scale.copy = function() { - return ordinal(domain, range2).unknown(unknown); - }; - initRange.apply(scale, arguments); - return scale; - } - function band() { - var scale = ordinal().unknown(void 0), domain = scale.domain, ordinalRange = scale.range, r0 = 0, r1 = 1, step, bandwidth, round = false, paddingInner = 0, paddingOuter = 0, align = 0.5; - delete scale.unknown; - function rescale() { - var n = domain().length, reverse2 = r1 < r0, start2 = reverse2 ? r1 : r0, stop = reverse2 ? r0 : r1; - step = (stop - start2) / Math.max(1, n - paddingInner + paddingOuter * 2); - if (round) - step = Math.floor(step); - start2 += (stop - start2 - step * (n - paddingInner)) * align; - bandwidth = step * (1 - paddingInner); - if (round) - start2 = Math.round(start2), bandwidth = Math.round(bandwidth); - var values = range$2(n).map(function(i) { - return start2 + step * i; - }); - return ordinalRange(reverse2 ? values.reverse() : values); - } - scale.domain = function(_2) { - return arguments.length ? (domain(_2), rescale()) : domain(); - }; - scale.range = function(_2) { - return arguments.length ? ([r0, r1] = _2, r0 = +r0, r1 = +r1, rescale()) : [r0, r1]; - }; - scale.rangeRound = function(_2) { - return [r0, r1] = _2, r0 = +r0, r1 = +r1, round = true, rescale(); - }; - scale.bandwidth = function() { - return bandwidth; - }; - scale.step = function() { - return step; - }; - scale.round = function(_2) { - return arguments.length ? (round = !!_2, rescale()) : round; - }; - scale.padding = function(_2) { - return arguments.length ? (paddingInner = Math.min(1, paddingOuter = +_2), rescale()) : paddingInner; - }; - scale.paddingInner = function(_2) { - return arguments.length ? (paddingInner = Math.min(1, _2), rescale()) : paddingInner; - }; - scale.paddingOuter = function(_2) { - return arguments.length ? (paddingOuter = +_2, rescale()) : paddingOuter; - }; - scale.align = function(_2) { - return arguments.length ? (align = Math.max(0, Math.min(1, _2)), rescale()) : align; - }; - scale.copy = function() { - return band(domain(), [r0, r1]).round(round).paddingInner(paddingInner).paddingOuter(paddingOuter).align(align); - }; - return initRange.apply(rescale(), arguments); - } - function pointish(scale) { - var copy2 = scale.copy; - scale.padding = scale.paddingOuter; - delete scale.paddingInner; - delete scale.paddingOuter; - scale.copy = function() { - return pointish(copy2()); - }; - return scale; - } - function point$5() { - return pointish(band.apply(null, arguments).paddingInner(1)); - } - function constants(x2) { - return function() { - return x2; - }; - } - function number$1(x2) { - return +x2; - } - var unit$1 = [0, 1]; - function identity$3(x2) { - return x2; - } - function normalize$1(a2, b) { - return (b -= a2 = +a2) ? function(x2) { - return (x2 - a2) / b; - } : constants(isNaN(b) ? NaN : 0.5); - } - function clamper(a2, b) { - var t; - if (a2 > b) - t = a2, a2 = b, b = t; - return function(x2) { - return Math.max(a2, Math.min(b, x2)); - }; - } - function bimap(domain, range2, interpolate2) { - var d0 = domain[0], d1 = domain[1], r0 = range2[0], r1 = range2[1]; - if (d1 < d0) - d0 = normalize$1(d1, d0), r0 = interpolate2(r1, r0); - else - d0 = normalize$1(d0, d1), r0 = interpolate2(r0, r1); - return function(x2) { - return r0(d0(x2)); - }; - } - function polymap(domain, range2, interpolate2) { - var j = Math.min(domain.length, range2.length) - 1, d = new Array(j), r = new Array(j), i = -1; - if (domain[j] < domain[0]) { - domain = domain.slice().reverse(); - range2 = range2.slice().reverse(); - } - while (++i < j) { - d[i] = normalize$1(domain[i], domain[i + 1]); - r[i] = interpolate2(range2[i], range2[i + 1]); - } - return function(x2) { - var i2 = bisect(domain, x2, 1, j) - 1; - return r[i2](d[i2](x2)); - }; - } - function copy$2(source, target) { - return target.domain(source.domain()).range(source.range()).interpolate(source.interpolate()).clamp(source.clamp()).unknown(source.unknown()); - } - function transformer$2() { - var domain = unit$1, range2 = unit$1, interpolate2 = interpolate$2, transform2, untransform, unknown, clamp = identity$3, piecewise2, output, input; - function rescale() { - var n = Math.min(domain.length, range2.length); - if (clamp !== identity$3) - clamp = clamper(domain[0], domain[n - 1]); - piecewise2 = n > 2 ? polymap : bimap; - output = input = null; - return scale; - } - function scale(x2) { - return x2 == null || isNaN(x2 = +x2) ? unknown : (output || (output = piecewise2(domain.map(transform2), range2, interpolate2)))(transform2(clamp(x2))); - } - scale.invert = function(y2) { - return clamp(untransform((input || (input = piecewise2(range2, domain.map(transform2), interpolateNumber)))(y2))); - }; - scale.domain = function(_2) { - return arguments.length ? (domain = Array.from(_2, number$1), rescale()) : domain.slice(); - }; - scale.range = function(_2) { - return arguments.length ? (range2 = Array.from(_2), rescale()) : range2.slice(); - }; - scale.rangeRound = function(_2) { - return range2 = Array.from(_2), interpolate2 = interpolateRound, rescale(); - }; - scale.clamp = function(_2) { - return arguments.length ? (clamp = _2 ? true : identity$3, rescale()) : clamp !== identity$3; - }; - scale.interpolate = function(_2) { - return arguments.length ? (interpolate2 = _2, rescale()) : interpolate2; - }; - scale.unknown = function(_2) { - return arguments.length ? (unknown = _2, scale) : unknown; - }; - return function(t, u2) { - transform2 = t, untransform = u2; - return rescale(); - }; - } - function continuous() { - return transformer$2()(identity$3, identity$3); - } - function tickFormat(start2, stop, count2, specifier) { - var step = tickStep(start2, stop, count2), precision; - specifier = formatSpecifier(specifier == null ? ",f" : specifier); - switch (specifier.type) { - case "s": { - var value = Math.max(Math.abs(start2), Math.abs(stop)); - if (specifier.precision == null && !isNaN(precision = precisionPrefix(step, value))) - specifier.precision = precision; - return formatPrefix(specifier, value); - } - case "": - case "e": - case "g": - case "p": - case "r": { - if (specifier.precision == null && !isNaN(precision = precisionRound(step, Math.max(Math.abs(start2), Math.abs(stop))))) - specifier.precision = precision - (specifier.type === "e"); - break; - } - case "f": - case "%": { - if (specifier.precision == null && !isNaN(precision = precisionFixed(step))) - specifier.precision = precision - (specifier.type === "%") * 2; - break; - } - } - return format(specifier); - } - function linearish(scale) { - var domain = scale.domain; - scale.ticks = function(count2) { - var d = domain(); - return ticks(d[0], d[d.length - 1], count2 == null ? 10 : count2); - }; - scale.tickFormat = function(count2, specifier) { - var d = domain(); - return tickFormat(d[0], d[d.length - 1], count2 == null ? 10 : count2, specifier); - }; - scale.nice = function(count2) { - if (count2 == null) - count2 = 10; - var d = domain(); - var i0 = 0; - var i1 = d.length - 1; - var start2 = d[i0]; - var stop = d[i1]; - var prestep; - var step; - var maxIter = 10; - if (stop < start2) { - step = start2, start2 = stop, stop = step; - step = i0, i0 = i1, i1 = step; - } - while (maxIter-- > 0) { - step = tickIncrement(start2, stop, count2); - if (step === prestep) { - d[i0] = start2; - d[i1] = stop; - return domain(d); - } else if (step > 0) { - start2 = Math.floor(start2 / step) * step; - stop = Math.ceil(stop / step) * step; - } else if (step < 0) { - start2 = Math.ceil(start2 * step) / step; - stop = Math.floor(stop * step) / step; - } else { - break; - } - prestep = step; - } - return scale; - }; - return scale; - } - function linear() { - var scale = continuous(); - scale.copy = function() { - return copy$2(scale, linear()); - }; - initRange.apply(scale, arguments); - return linearish(scale); - } - function identity$2(domain) { - var unknown; - function scale(x2) { - return x2 == null || isNaN(x2 = +x2) ? unknown : x2; - } - scale.invert = scale; - scale.domain = scale.range = function(_2) { - return arguments.length ? (domain = Array.from(_2, number$1), scale) : domain.slice(); - }; - scale.unknown = function(_2) { - return arguments.length ? (unknown = _2, scale) : unknown; - }; - scale.copy = function() { - return identity$2(domain).unknown(unknown); - }; - domain = arguments.length ? Array.from(domain, number$1) : [0, 1]; - return linearish(scale); - } - function nice(domain, interval2) { - domain = domain.slice(); - var i0 = 0, i1 = domain.length - 1, x02 = domain[i0], x12 = domain[i1], t; - if (x12 < x02) { - t = i0, i0 = i1, i1 = t; - t = x02, x02 = x12, x12 = t; - } - domain[i0] = interval2.floor(x02); - domain[i1] = interval2.ceil(x12); - return domain; - } - function transformLog(x2) { - return Math.log(x2); - } - function transformExp(x2) { - return Math.exp(x2); - } - function transformLogn(x2) { - return -Math.log(-x2); - } - function transformExpn(x2) { - return -Math.exp(-x2); - } - function pow10(x2) { - return isFinite(x2) ? +("1e" + x2) : x2 < 0 ? 0 : x2; - } - function powp(base) { - return base === 10 ? pow10 : base === Math.E ? Math.exp : (x2) => Math.pow(base, x2); - } - function logp(base) { - return base === Math.E ? Math.log : base === 10 && Math.log10 || base === 2 && Math.log2 || (base = Math.log(base), (x2) => Math.log(x2) / base); - } - function reflect(f) { - return (x2, k2) => -f(-x2, k2); - } - function loggish(transform2) { - const scale = transform2(transformLog, transformExp); - const domain = scale.domain; - let base = 10; - let logs; - let pows; - function rescale() { - logs = logp(base), pows = powp(base); - if (domain()[0] < 0) { - logs = reflect(logs), pows = reflect(pows); - transform2(transformLogn, transformExpn); - } else { - transform2(transformLog, transformExp); - } - return scale; - } - scale.base = function(_2) { - return arguments.length ? (base = +_2, rescale()) : base; - }; - scale.domain = function(_2) { - return arguments.length ? (domain(_2), rescale()) : domain(); - }; - scale.ticks = (count2) => { - const d = domain(); - let u2 = d[0]; - let v = d[d.length - 1]; - const r = v < u2; - if (r) - [u2, v] = [v, u2]; - let i = logs(u2); - let j = logs(v); - let k2; - let t; - const n = count2 == null ? 10 : +count2; - let z = []; - if (!(base % 1) && j - i < n) { - i = Math.floor(i), j = Math.ceil(j); - if (u2 > 0) - for (; i <= j; ++i) { - for (k2 = 1; k2 < base; ++k2) { - t = i < 0 ? k2 / pows(-i) : k2 * pows(i); - if (t < u2) - continue; - if (t > v) - break; - z.push(t); - } - } - else - for (; i <= j; ++i) { - for (k2 = base - 1; k2 >= 1; --k2) { - t = i > 0 ? k2 / pows(-i) : k2 * pows(i); - if (t < u2) - continue; - if (t > v) - break; - z.push(t); - } - } - if (z.length * 2 < n) - z = ticks(u2, v, n); - } else { - z = ticks(i, j, Math.min(j - i, n)).map(pows); - } - return r ? z.reverse() : z; - }; - scale.tickFormat = (count2, specifier) => { - if (count2 == null) - count2 = 10; - if (specifier == null) - specifier = base === 10 ? "s" : ","; - if (typeof specifier !== "function") { - if (!(base % 1) && (specifier = formatSpecifier(specifier)).precision == null) - specifier.trim = true; - specifier = format(specifier); - } - if (count2 === Infinity) - return specifier; - const k2 = Math.max(1, base * count2 / scale.ticks().length); - return (d) => { - let i = d / pows(Math.round(logs(d))); - if (i * base < base - 0.5) - i *= base; - return i <= k2 ? specifier(d) : ""; - }; - }; - scale.nice = () => { - return domain(nice(domain(), { - floor: (x2) => pows(Math.floor(logs(x2))), - ceil: (x2) => pows(Math.ceil(logs(x2))) - })); - }; - return scale; - } - function log$1() { - const scale = loggish(transformer$2()).domain([1, 10]); - scale.copy = () => copy$2(scale, log$1()).base(scale.base()); - initRange.apply(scale, arguments); - return scale; - } - function transformSymlog(c2) { - return function(x2) { - return Math.sign(x2) * Math.log1p(Math.abs(x2 / c2)); - }; - } - function transformSymexp(c2) { - return function(x2) { - return Math.sign(x2) * Math.expm1(Math.abs(x2)) * c2; - }; - } - function symlogish(transform2) { - var c2 = 1, scale = transform2(transformSymlog(c2), transformSymexp(c2)); - scale.constant = function(_2) { - return arguments.length ? transform2(transformSymlog(c2 = +_2), transformSymexp(c2)) : c2; - }; - return linearish(scale); - } - function symlog() { - var scale = symlogish(transformer$2()); - scale.copy = function() { - return copy$2(scale, symlog()).constant(scale.constant()); - }; - return initRange.apply(scale, arguments); - } - function transformPow(exponent2) { - return function(x2) { - return x2 < 0 ? -Math.pow(-x2, exponent2) : Math.pow(x2, exponent2); - }; - } - function transformSqrt(x2) { - return x2 < 0 ? -Math.sqrt(-x2) : Math.sqrt(x2); - } - function transformSquare(x2) { - return x2 < 0 ? -x2 * x2 : x2 * x2; - } - function powish(transform2) { - var scale = transform2(identity$3, identity$3), exponent2 = 1; - function rescale() { - return exponent2 === 1 ? transform2(identity$3, identity$3) : exponent2 === 0.5 ? transform2(transformSqrt, transformSquare) : transform2(transformPow(exponent2), transformPow(1 / exponent2)); - } - scale.exponent = function(_2) { - return arguments.length ? (exponent2 = +_2, rescale()) : exponent2; - }; - return linearish(scale); - } - function pow() { - var scale = powish(transformer$2()); - scale.copy = function() { - return copy$2(scale, pow()).exponent(scale.exponent()); - }; - initRange.apply(scale, arguments); - return scale; - } - function sqrt$1() { - return pow.apply(null, arguments).exponent(0.5); - } - function square$1(x2) { - return Math.sign(x2) * x2 * x2; - } - function unsquare(x2) { - return Math.sign(x2) * Math.sqrt(Math.abs(x2)); - } - function radial() { - var squared = continuous(), range2 = [0, 1], round = false, unknown; - function scale(x2) { - var y2 = unsquare(squared(x2)); - return isNaN(y2) ? unknown : round ? Math.round(y2) : y2; - } - scale.invert = function(y2) { - return squared.invert(square$1(y2)); - }; - scale.domain = function(_2) { - return arguments.length ? (squared.domain(_2), scale) : squared.domain(); - }; - scale.range = function(_2) { - return arguments.length ? (squared.range((range2 = Array.from(_2, number$1)).map(square$1)), scale) : range2.slice(); - }; - scale.rangeRound = function(_2) { - return scale.range(_2).round(true); - }; - scale.round = function(_2) { - return arguments.length ? (round = !!_2, scale) : round; - }; - scale.clamp = function(_2) { - return arguments.length ? (squared.clamp(_2), scale) : squared.clamp(); - }; - scale.unknown = function(_2) { - return arguments.length ? (unknown = _2, scale) : unknown; - }; - scale.copy = function() { - return radial(squared.domain(), range2).round(round).clamp(squared.clamp()).unknown(unknown); - }; - initRange.apply(scale, arguments); - return linearish(scale); - } - function quantile() { - var domain = [], range2 = [], thresholds = [], unknown; - function rescale() { - var i = 0, n = Math.max(1, range2.length); - thresholds = new Array(n - 1); - while (++i < n) - thresholds[i - 1] = quantileSorted(domain, i / n); - return scale; - } - function scale(x2) { - return x2 == null || isNaN(x2 = +x2) ? unknown : range2[bisect(thresholds, x2)]; - } - scale.invertExtent = function(y2) { - var i = range2.indexOf(y2); - return i < 0 ? [NaN, NaN] : [ - i > 0 ? thresholds[i - 1] : domain[0], - i < thresholds.length ? thresholds[i] : domain[domain.length - 1] - ]; - }; - scale.domain = function(_2) { - if (!arguments.length) - return domain.slice(); - domain = []; - for (let d of _2) - if (d != null && !isNaN(d = +d)) - domain.push(d); - domain.sort(ascending$3); - return rescale(); - }; - scale.range = function(_2) { - return arguments.length ? (range2 = Array.from(_2), rescale()) : range2.slice(); - }; - scale.unknown = function(_2) { - return arguments.length ? (unknown = _2, scale) : unknown; - }; - scale.quantiles = function() { - return thresholds.slice(); - }; - scale.copy = function() { - return quantile().domain(domain).range(range2).unknown(unknown); - }; - return initRange.apply(scale, arguments); - } - function quantize() { - var x02 = 0, x12 = 1, n = 1, domain = [0.5], range2 = [0, 1], unknown; - function scale(x2) { - return x2 != null && x2 <= x2 ? range2[bisect(domain, x2, 0, n)] : unknown; - } - function rescale() { - var i = -1; - domain = new Array(n); - while (++i < n) - domain[i] = ((i + 1) * x12 - (i - n) * x02) / (n + 1); - return scale; - } - scale.domain = function(_2) { - return arguments.length ? ([x02, x12] = _2, x02 = +x02, x12 = +x12, rescale()) : [x02, x12]; - }; - scale.range = function(_2) { - return arguments.length ? (n = (range2 = Array.from(_2)).length - 1, rescale()) : range2.slice(); - }; - scale.invertExtent = function(y2) { - var i = range2.indexOf(y2); - return i < 0 ? [NaN, NaN] : i < 1 ? [x02, domain[0]] : i >= n ? [domain[n - 1], x12] : [domain[i - 1], domain[i]]; - }; - scale.unknown = function(_2) { - return arguments.length ? (unknown = _2, scale) : scale; - }; - scale.thresholds = function() { - return domain.slice(); - }; - scale.copy = function() { - return quantize().domain([x02, x12]).range(range2).unknown(unknown); - }; - return initRange.apply(linearish(scale), arguments); - } - function threshold() { - var domain = [0.5], range2 = [0, 1], unknown, n = 1; - function scale(x2) { - return x2 != null && x2 <= x2 ? range2[bisect(domain, x2, 0, n)] : unknown; - } - scale.domain = function(_2) { - return arguments.length ? (domain = Array.from(_2), n = Math.min(domain.length, range2.length - 1), scale) : domain.slice(); - }; - scale.range = function(_2) { - return arguments.length ? (range2 = Array.from(_2), n = Math.min(domain.length, range2.length - 1), scale) : range2.slice(); - }; - scale.invertExtent = function(y2) { - var i = range2.indexOf(y2); - return [domain[i - 1], domain[i]]; - }; - scale.unknown = function(_2) { - return arguments.length ? (unknown = _2, scale) : unknown; - }; - scale.copy = function() { - return threshold().domain(domain).range(range2).unknown(unknown); - }; - return initRange.apply(scale, arguments); - } - var t0 = new Date(), t1 = new Date(); - function newInterval(floori, offseti, count2, field) { - function interval2(date2) { - return floori(date2 = arguments.length === 0 ? new Date() : new Date(+date2)), date2; - } - interval2.floor = function(date2) { - return floori(date2 = new Date(+date2)), date2; - }; - interval2.ceil = function(date2) { - return floori(date2 = new Date(date2 - 1)), offseti(date2, 1), floori(date2), date2; - }; - interval2.round = function(date2) { - var d0 = interval2(date2), d1 = interval2.ceil(date2); - return date2 - d0 < d1 - date2 ? d0 : d1; - }; - interval2.offset = function(date2, step) { - return offseti(date2 = new Date(+date2), step == null ? 1 : Math.floor(step)), date2; - }; - interval2.range = function(start2, stop, step) { - var range2 = [], previous; - start2 = interval2.ceil(start2); - step = step == null ? 1 : Math.floor(step); - if (!(start2 < stop) || !(step > 0)) - return range2; - do - range2.push(previous = new Date(+start2)), offseti(start2, step), floori(start2); - while (previous < start2 && start2 < stop); - return range2; - }; - interval2.filter = function(test) { - return newInterval(function(date2) { - if (date2 >= date2) - while (floori(date2), !test(date2)) - date2.setTime(date2 - 1); - }, function(date2, step) { - if (date2 >= date2) { - if (step < 0) - while (++step <= 0) { - while (offseti(date2, -1), !test(date2)) { - } - } - else - while (--step >= 0) { - while (offseti(date2, 1), !test(date2)) { - } - } - } - }); - }; - if (count2) { - interval2.count = function(start2, end2) { - t0.setTime(+start2), t1.setTime(+end2); - floori(t0), floori(t1); - return Math.floor(count2(t0, t1)); - }; - interval2.every = function(step) { - step = Math.floor(step); - return !isFinite(step) || !(step > 0) ? null : !(step > 1) ? interval2 : interval2.filter(field ? function(d) { - return field(d) % step === 0; - } : function(d) { - return interval2.count(0, d) % step === 0; - }); - }; - } - return interval2; - } - var millisecond = newInterval(function() { - }, function(date2, step) { - date2.setTime(+date2 + step); - }, function(start2, end2) { - return end2 - start2; - }); - millisecond.every = function(k2) { - k2 = Math.floor(k2); - if (!isFinite(k2) || !(k2 > 0)) - return null; - if (!(k2 > 1)) - return millisecond; - return newInterval(function(date2) { - date2.setTime(Math.floor(date2 / k2) * k2); - }, function(date2, step) { - date2.setTime(+date2 + step * k2); - }, function(start2, end2) { - return (end2 - start2) / k2; - }); - }; - const millisecond$1 = millisecond; - var milliseconds = millisecond.range; - const durationSecond = 1e3; - const durationMinute = durationSecond * 60; - const durationHour = durationMinute * 60; - const durationDay = durationHour * 24; - const durationWeek = durationDay * 7; - const durationMonth = durationDay * 30; - const durationYear = durationDay * 365; - var second = newInterval(function(date2) { - date2.setTime(date2 - date2.getMilliseconds()); - }, function(date2, step) { - date2.setTime(+date2 + step * durationSecond); - }, function(start2, end2) { - return (end2 - start2) / durationSecond; - }, function(date2) { - return date2.getUTCSeconds(); - }); - const utcSecond = second; - var seconds = second.range; - var minute = newInterval(function(date2) { - date2.setTime(date2 - date2.getMilliseconds() - date2.getSeconds() * durationSecond); - }, function(date2, step) { - date2.setTime(+date2 + step * durationMinute); - }, function(start2, end2) { - return (end2 - start2) / durationMinute; - }, function(date2) { - return date2.getMinutes(); - }); - const timeMinute = minute; - var minutes = minute.range; - var hour = newInterval(function(date2) { - date2.setTime(date2 - date2.getMilliseconds() - date2.getSeconds() * durationSecond - date2.getMinutes() * durationMinute); - }, function(date2, step) { - date2.setTime(+date2 + step * durationHour); - }, function(start2, end2) { - return (end2 - start2) / durationHour; - }, function(date2) { - return date2.getHours(); - }); - const timeHour = hour; - var hours = hour.range; - var day = newInterval( - (date2) => date2.setHours(0, 0, 0, 0), - (date2, step) => date2.setDate(date2.getDate() + step), - (start2, end2) => (end2 - start2 - (end2.getTimezoneOffset() - start2.getTimezoneOffset()) * durationMinute) / durationDay, - (date2) => date2.getDate() - 1 - ); - const timeDay = day; - var days = day.range; - function weekday(i) { - return newInterval(function(date2) { - date2.setDate(date2.getDate() - (date2.getDay() + 7 - i) % 7); - date2.setHours(0, 0, 0, 0); - }, function(date2, step) { - date2.setDate(date2.getDate() + step * 7); - }, function(start2, end2) { - return (end2 - start2 - (end2.getTimezoneOffset() - start2.getTimezoneOffset()) * durationMinute) / durationWeek; - }); - } - var sunday = weekday(0); - var monday = weekday(1); - var tuesday = weekday(2); - var wednesday = weekday(3); - var thursday = weekday(4); - var friday = weekday(5); - var saturday = weekday(6); - var sundays = sunday.range; - var mondays = monday.range; - var tuesdays = tuesday.range; - var wednesdays = wednesday.range; - var thursdays = thursday.range; - var fridays = friday.range; - var saturdays = saturday.range; - var month = newInterval(function(date2) { - date2.setDate(1); - date2.setHours(0, 0, 0, 0); - }, function(date2, step) { - date2.setMonth(date2.getMonth() + step); - }, function(start2, end2) { - return end2.getMonth() - start2.getMonth() + (end2.getFullYear() - start2.getFullYear()) * 12; - }, function(date2) { - return date2.getMonth(); - }); - const timeMonth = month; - var months = month.range; - var year = newInterval(function(date2) { - date2.setMonth(0, 1); - date2.setHours(0, 0, 0, 0); - }, function(date2, step) { - date2.setFullYear(date2.getFullYear() + step); - }, function(start2, end2) { - return end2.getFullYear() - start2.getFullYear(); - }, function(date2) { - return date2.getFullYear(); - }); - year.every = function(k2) { - return !isFinite(k2 = Math.floor(k2)) || !(k2 > 0) ? null : newInterval(function(date2) { - date2.setFullYear(Math.floor(date2.getFullYear() / k2) * k2); - date2.setMonth(0, 1); - date2.setHours(0, 0, 0, 0); - }, function(date2, step) { - date2.setFullYear(date2.getFullYear() + step * k2); - }); - }; - const timeYear = year; - var years = year.range; - var utcMinute = newInterval(function(date2) { - date2.setUTCSeconds(0, 0); - }, function(date2, step) { - date2.setTime(+date2 + step * durationMinute); - }, function(start2, end2) { - return (end2 - start2) / durationMinute; - }, function(date2) { - return date2.getUTCMinutes(); - }); - const utcMinute$1 = utcMinute; - var utcMinutes = utcMinute.range; - var utcHour = newInterval(function(date2) { - date2.setUTCMinutes(0, 0, 0); - }, function(date2, step) { - date2.setTime(+date2 + step * durationHour); - }, function(start2, end2) { - return (end2 - start2) / durationHour; - }, function(date2) { - return date2.getUTCHours(); - }); - const utcHour$1 = utcHour; - var utcHours = utcHour.range; - var utcDay = newInterval(function(date2) { - date2.setUTCHours(0, 0, 0, 0); - }, function(date2, step) { - date2.setUTCDate(date2.getUTCDate() + step); - }, function(start2, end2) { - return (end2 - start2) / durationDay; - }, function(date2) { - return date2.getUTCDate() - 1; - }); - const utcDay$1 = utcDay; - var utcDays = utcDay.range; - function utcWeekday(i) { - return newInterval(function(date2) { - date2.setUTCDate(date2.getUTCDate() - (date2.getUTCDay() + 7 - i) % 7); - date2.setUTCHours(0, 0, 0, 0); - }, function(date2, step) { - date2.setUTCDate(date2.getUTCDate() + step * 7); - }, function(start2, end2) { - return (end2 - start2) / durationWeek; - }); - } - var utcSunday = utcWeekday(0); - var utcMonday = utcWeekday(1); - var utcTuesday = utcWeekday(2); - var utcWednesday = utcWeekday(3); - var utcThursday = utcWeekday(4); - var utcFriday = utcWeekday(5); - var utcSaturday = utcWeekday(6); - var utcSundays = utcSunday.range; - var utcMondays = utcMonday.range; - var utcTuesdays = utcTuesday.range; - var utcWednesdays = utcWednesday.range; - var utcThursdays = utcThursday.range; - var utcFridays = utcFriday.range; - var utcSaturdays = utcSaturday.range; - var utcMonth = newInterval(function(date2) { - date2.setUTCDate(1); - date2.setUTCHours(0, 0, 0, 0); - }, function(date2, step) { - date2.setUTCMonth(date2.getUTCMonth() + step); - }, function(start2, end2) { - return end2.getUTCMonth() - start2.getUTCMonth() + (end2.getUTCFullYear() - start2.getUTCFullYear()) * 12; - }, function(date2) { - return date2.getUTCMonth(); - }); - const utcMonth$1 = utcMonth; - var utcMonths = utcMonth.range; - var utcYear = newInterval(function(date2) { - date2.setUTCMonth(0, 1); - date2.setUTCHours(0, 0, 0, 0); - }, function(date2, step) { - date2.setUTCFullYear(date2.getUTCFullYear() + step); - }, function(start2, end2) { - return end2.getUTCFullYear() - start2.getUTCFullYear(); - }, function(date2) { - return date2.getUTCFullYear(); - }); - utcYear.every = function(k2) { - return !isFinite(k2 = Math.floor(k2)) || !(k2 > 0) ? null : newInterval(function(date2) { - date2.setUTCFullYear(Math.floor(date2.getUTCFullYear() / k2) * k2); - date2.setUTCMonth(0, 1); - date2.setUTCHours(0, 0, 0, 0); - }, function(date2, step) { - date2.setUTCFullYear(date2.getUTCFullYear() + step * k2); - }); - }; - const utcYear$1 = utcYear; - var utcYears = utcYear.range; - function ticker(year2, month2, week, day2, hour2, minute2) { - const tickIntervals = [ - [utcSecond, 1, durationSecond], - [utcSecond, 5, 5 * durationSecond], - [utcSecond, 15, 15 * durationSecond], - [utcSecond, 30, 30 * durationSecond], - [minute2, 1, durationMinute], - [minute2, 5, 5 * durationMinute], - [minute2, 15, 15 * durationMinute], - [minute2, 30, 30 * durationMinute], - [hour2, 1, durationHour], - [hour2, 3, 3 * durationHour], - [hour2, 6, 6 * durationHour], - [hour2, 12, 12 * durationHour], - [day2, 1, durationDay], - [day2, 2, 2 * durationDay], - [week, 1, durationWeek], - [month2, 1, durationMonth], - [month2, 3, 3 * durationMonth], - [year2, 1, durationYear] - ]; - function ticks2(start2, stop, count2) { - const reverse2 = stop < start2; - if (reverse2) - [start2, stop] = [stop, start2]; - const interval2 = count2 && typeof count2.range === "function" ? count2 : tickInterval(start2, stop, count2); - const ticks3 = interval2 ? interval2.range(start2, +stop + 1) : []; - return reverse2 ? ticks3.reverse() : ticks3; - } - function tickInterval(start2, stop, count2) { - const target = Math.abs(stop - start2) / count2; - const i = bisector(([, , step2]) => step2).right(tickIntervals, target); - if (i === tickIntervals.length) - return year2.every(tickStep(start2 / durationYear, stop / durationYear, count2)); - if (i === 0) - return millisecond$1.every(Math.max(tickStep(start2, stop, count2), 1)); - const [t, step] = tickIntervals[target / tickIntervals[i - 1][2] < tickIntervals[i][2] / target ? i - 1 : i]; - return t.every(step); - } - return [ticks2, tickInterval]; - } - const [utcTicks, utcTickInterval] = ticker(utcYear$1, utcMonth$1, utcSunday, utcDay$1, utcHour$1, utcMinute$1); - const [timeTicks, timeTickInterval] = ticker(timeYear, timeMonth, sunday, timeDay, timeHour, timeMinute); - function localDate(d) { - if (0 <= d.y && d.y < 100) { - var date2 = new Date(-1, d.m, d.d, d.H, d.M, d.S, d.L); - date2.setFullYear(d.y); - return date2; - } - return new Date(d.y, d.m, d.d, d.H, d.M, d.S, d.L); - } - function utcDate(d) { - if (0 <= d.y && d.y < 100) { - var date2 = new Date(Date.UTC(-1, d.m, d.d, d.H, d.M, d.S, d.L)); - date2.setUTCFullYear(d.y); - return date2; - } - return new Date(Date.UTC(d.y, d.m, d.d, d.H, d.M, d.S, d.L)); - } - function newDate(y2, m2, d) { - return { y: y2, m: m2, d, H: 0, M: 0, S: 0, L: 0 }; - } - function formatLocale(locale2) { - var locale_dateTime = locale2.dateTime, locale_date = locale2.date, locale_time = locale2.time, locale_periods = locale2.periods, locale_weekdays = locale2.days, locale_shortWeekdays = locale2.shortDays, locale_months = locale2.months, locale_shortMonths = locale2.shortMonths; - var periodRe = formatRe(locale_periods), periodLookup = formatLookup(locale_periods), weekdayRe = formatRe(locale_weekdays), weekdayLookup = formatLookup(locale_weekdays), shortWeekdayRe = formatRe(locale_shortWeekdays), shortWeekdayLookup = formatLookup(locale_shortWeekdays), monthRe = formatRe(locale_months), monthLookup = formatLookup(locale_months), shortMonthRe = formatRe(locale_shortMonths), shortMonthLookup = formatLookup(locale_shortMonths); - var formats = { - "a": formatShortWeekday, - "A": formatWeekday, - "b": formatShortMonth, - "B": formatMonth, - "c": null, - "d": formatDayOfMonth, - "e": formatDayOfMonth, - "f": formatMicroseconds, - "g": formatYearISO, - "G": formatFullYearISO, - "H": formatHour24, - "I": formatHour12, - "j": formatDayOfYear, - "L": formatMilliseconds, - "m": formatMonthNumber, - "M": formatMinutes, - "p": formatPeriod, - "q": formatQuarter, - "Q": formatUnixTimestamp, - "s": formatUnixTimestampSeconds, - "S": formatSeconds, - "u": formatWeekdayNumberMonday, - "U": formatWeekNumberSunday, - "V": formatWeekNumberISO, - "w": formatWeekdayNumberSunday, - "W": formatWeekNumberMonday, - "x": null, - "X": null, - "y": formatYear, - "Y": formatFullYear, - "Z": formatZone, - "%": formatLiteralPercent - }; - var utcFormats = { - "a": formatUTCShortWeekday, - "A": formatUTCWeekday, - "b": formatUTCShortMonth, - "B": formatUTCMonth, - "c": null, - "d": formatUTCDayOfMonth, - "e": formatUTCDayOfMonth, - "f": formatUTCMicroseconds, - "g": formatUTCYearISO, - "G": formatUTCFullYearISO, - "H": formatUTCHour24, - "I": formatUTCHour12, - "j": formatUTCDayOfYear, - "L": formatUTCMilliseconds, - "m": formatUTCMonthNumber, - "M": formatUTCMinutes, - "p": formatUTCPeriod, - "q": formatUTCQuarter, - "Q": formatUnixTimestamp, - "s": formatUnixTimestampSeconds, - "S": formatUTCSeconds, - "u": formatUTCWeekdayNumberMonday, - "U": formatUTCWeekNumberSunday, - "V": formatUTCWeekNumberISO, - "w": formatUTCWeekdayNumberSunday, - "W": formatUTCWeekNumberMonday, - "x": null, - "X": null, - "y": formatUTCYear, - "Y": formatUTCFullYear, - "Z": formatUTCZone, - "%": formatLiteralPercent - }; - var parses = { - "a": parseShortWeekday, - "A": parseWeekday, - "b": parseShortMonth, - "B": parseMonth, - "c": parseLocaleDateTime, - "d": parseDayOfMonth, - "e": parseDayOfMonth, - "f": parseMicroseconds, - "g": parseYear, - "G": parseFullYear, - "H": parseHour24, - "I": parseHour24, - "j": parseDayOfYear, - "L": parseMilliseconds, - "m": parseMonthNumber, - "M": parseMinutes, - "p": parsePeriod, - "q": parseQuarter, - "Q": parseUnixTimestamp, - "s": parseUnixTimestampSeconds, - "S": parseSeconds, - "u": parseWeekdayNumberMonday, - "U": parseWeekNumberSunday, - "V": parseWeekNumberISO, - "w": parseWeekdayNumberSunday, - "W": parseWeekNumberMonday, - "x": parseLocaleDate, - "X": parseLocaleTime, - "y": parseYear, - "Y": parseFullYear, - "Z": parseZone, - "%": parseLiteralPercent - }; - formats.x = newFormat(locale_date, formats); - formats.X = newFormat(locale_time, formats); - formats.c = newFormat(locale_dateTime, formats); - utcFormats.x = newFormat(locale_date, utcFormats); - utcFormats.X = newFormat(locale_time, utcFormats); - utcFormats.c = newFormat(locale_dateTime, utcFormats); - function newFormat(specifier, formats2) { - return function(date2) { - var string = [], i = -1, j = 0, n = specifier.length, c2, pad2, format2; - if (!(date2 instanceof Date)) - date2 = new Date(+date2); - while (++i < n) { - if (specifier.charCodeAt(i) === 37) { - string.push(specifier.slice(j, i)); - if ((pad2 = pads[c2 = specifier.charAt(++i)]) != null) - c2 = specifier.charAt(++i); - else - pad2 = c2 === "e" ? " " : "0"; - if (format2 = formats2[c2]) - c2 = format2(date2, pad2); - string.push(c2); - j = i + 1; - } - } - string.push(specifier.slice(j, i)); - return string.join(""); - }; - } - function newParse(specifier, Z) { - return function(string) { - var d = newDate(1900, void 0, 1), i = parseSpecifier(d, specifier, string += "", 0), week, day2; - if (i != string.length) - return null; - if ("Q" in d) - return new Date(d.Q); - if ("s" in d) - return new Date(d.s * 1e3 + ("L" in d ? d.L : 0)); - if (Z && !("Z" in d)) - d.Z = 0; - if ("p" in d) - d.H = d.H % 12 + d.p * 12; - if (d.m === void 0) - d.m = "q" in d ? d.q : 0; - if ("V" in d) { - if (d.V < 1 || d.V > 53) - return null; - if (!("w" in d)) - d.w = 1; - if ("Z" in d) { - week = utcDate(newDate(d.y, 0, 1)), day2 = week.getUTCDay(); - week = day2 > 4 || day2 === 0 ? utcMonday.ceil(week) : utcMonday(week); - week = utcDay$1.offset(week, (d.V - 1) * 7); - d.y = week.getUTCFullYear(); - d.m = week.getUTCMonth(); - d.d = week.getUTCDate() + (d.w + 6) % 7; - } else { - week = localDate(newDate(d.y, 0, 1)), day2 = week.getDay(); - week = day2 > 4 || day2 === 0 ? monday.ceil(week) : monday(week); - week = timeDay.offset(week, (d.V - 1) * 7); - d.y = week.getFullYear(); - d.m = week.getMonth(); - d.d = week.getDate() + (d.w + 6) % 7; - } - } else if ("W" in d || "U" in d) { - if (!("w" in d)) - d.w = "u" in d ? d.u % 7 : "W" in d ? 1 : 0; - day2 = "Z" in d ? utcDate(newDate(d.y, 0, 1)).getUTCDay() : localDate(newDate(d.y, 0, 1)).getDay(); - d.m = 0; - d.d = "W" in d ? (d.w + 6) % 7 + d.W * 7 - (day2 + 5) % 7 : d.w + d.U * 7 - (day2 + 6) % 7; - } - if ("Z" in d) { - d.H += d.Z / 100 | 0; - d.M += d.Z % 100; - return utcDate(d); - } - return localDate(d); - }; - } - function parseSpecifier(d, specifier, string, j) { - var i = 0, n = specifier.length, m2 = string.length, c2, parse2; - while (i < n) { - if (j >= m2) - return -1; - c2 = specifier.charCodeAt(i++); - if (c2 === 37) { - c2 = specifier.charAt(i++); - parse2 = parses[c2 in pads ? specifier.charAt(i++) : c2]; - if (!parse2 || (j = parse2(d, string, j)) < 0) - return -1; - } else if (c2 != string.charCodeAt(j++)) { - return -1; - } - } - return j; - } - function parsePeriod(d, string, i) { - var n = periodRe.exec(string.slice(i)); - return n ? (d.p = periodLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; - } - function parseShortWeekday(d, string, i) { - var n = shortWeekdayRe.exec(string.slice(i)); - return n ? (d.w = shortWeekdayLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; - } - function parseWeekday(d, string, i) { - var n = weekdayRe.exec(string.slice(i)); - return n ? (d.w = weekdayLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; - } - function parseShortMonth(d, string, i) { - var n = shortMonthRe.exec(string.slice(i)); - return n ? (d.m = shortMonthLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; - } - function parseMonth(d, string, i) { - var n = monthRe.exec(string.slice(i)); - return n ? (d.m = monthLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; - } - function parseLocaleDateTime(d, string, i) { - return parseSpecifier(d, locale_dateTime, string, i); - } - function parseLocaleDate(d, string, i) { - return parseSpecifier(d, locale_date, string, i); - } - function parseLocaleTime(d, string, i) { - return parseSpecifier(d, locale_time, string, i); - } - function formatShortWeekday(d) { - return locale_shortWeekdays[d.getDay()]; - } - function formatWeekday(d) { - return locale_weekdays[d.getDay()]; - } - function formatShortMonth(d) { - return locale_shortMonths[d.getMonth()]; - } - function formatMonth(d) { - return locale_months[d.getMonth()]; - } - function formatPeriod(d) { - return locale_periods[+(d.getHours() >= 12)]; - } - function formatQuarter(d) { - return 1 + ~~(d.getMonth() / 3); - } - function formatUTCShortWeekday(d) { - return locale_shortWeekdays[d.getUTCDay()]; - } - function formatUTCWeekday(d) { - return locale_weekdays[d.getUTCDay()]; - } - function formatUTCShortMonth(d) { - return locale_shortMonths[d.getUTCMonth()]; - } - function formatUTCMonth(d) { - return locale_months[d.getUTCMonth()]; - } - function formatUTCPeriod(d) { - return locale_periods[+(d.getUTCHours() >= 12)]; - } - function formatUTCQuarter(d) { - return 1 + ~~(d.getUTCMonth() / 3); - } - return { - format: function(specifier) { - var f = newFormat(specifier += "", formats); - f.toString = function() { - return specifier; - }; - return f; - }, - parse: function(specifier) { - var p = newParse(specifier += "", false); - p.toString = function() { - return specifier; - }; - return p; - }, - utcFormat: function(specifier) { - var f = newFormat(specifier += "", utcFormats); - f.toString = function() { - return specifier; - }; - return f; - }, - utcParse: function(specifier) { - var p = newParse(specifier += "", true); - p.toString = function() { - return specifier; - }; - return p; - } - }; - } - var pads = { "-": "", "_": " ", "0": "0" }, numberRe = /^\s*\d+/, percentRe = /^%/, requoteRe = /[\\^$*+?|[\]().{}]/g; - function pad(value, fill, width2) { - var sign2 = value < 0 ? "-" : "", string = (sign2 ? -value : value) + "", length2 = string.length; - return sign2 + (length2 < width2 ? new Array(width2 - length2 + 1).join(fill) + string : string); - } - function requote(s2) { - return s2.replace(requoteRe, "\\$&"); - } - function formatRe(names) { - return new RegExp("^(?:" + names.map(requote).join("|") + ")", "i"); - } - function formatLookup(names) { - return new Map(names.map((name2, i) => [name2.toLowerCase(), i])); - } - function parseWeekdayNumberSunday(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 1)); - return n ? (d.w = +n[0], i + n[0].length) : -1; - } - function parseWeekdayNumberMonday(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 1)); - return n ? (d.u = +n[0], i + n[0].length) : -1; - } - function parseWeekNumberSunday(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 2)); - return n ? (d.U = +n[0], i + n[0].length) : -1; - } - function parseWeekNumberISO(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 2)); - return n ? (d.V = +n[0], i + n[0].length) : -1; - } - function parseWeekNumberMonday(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 2)); - return n ? (d.W = +n[0], i + n[0].length) : -1; - } - function parseFullYear(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 4)); - return n ? (d.y = +n[0], i + n[0].length) : -1; - } - function parseYear(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 2)); - return n ? (d.y = +n[0] + (+n[0] > 68 ? 1900 : 2e3), i + n[0].length) : -1; - } - function parseZone(d, string, i) { - var n = /^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(string.slice(i, i + 6)); - return n ? (d.Z = n[1] ? 0 : -(n[2] + (n[3] || "00")), i + n[0].length) : -1; - } - function parseQuarter(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 1)); - return n ? (d.q = n[0] * 3 - 3, i + n[0].length) : -1; - } - function parseMonthNumber(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 2)); - return n ? (d.m = n[0] - 1, i + n[0].length) : -1; - } - function parseDayOfMonth(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 2)); - return n ? (d.d = +n[0], i + n[0].length) : -1; - } - function parseDayOfYear(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 3)); - return n ? (d.m = 0, d.d = +n[0], i + n[0].length) : -1; - } - function parseHour24(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 2)); - return n ? (d.H = +n[0], i + n[0].length) : -1; - } - function parseMinutes(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 2)); - return n ? (d.M = +n[0], i + n[0].length) : -1; - } - function parseSeconds(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 2)); - return n ? (d.S = +n[0], i + n[0].length) : -1; - } - function parseMilliseconds(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 3)); - return n ? (d.L = +n[0], i + n[0].length) : -1; - } - function parseMicroseconds(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 6)); - return n ? (d.L = Math.floor(n[0] / 1e3), i + n[0].length) : -1; - } - function parseLiteralPercent(d, string, i) { - var n = percentRe.exec(string.slice(i, i + 1)); - return n ? i + n[0].length : -1; - } - function parseUnixTimestamp(d, string, i) { - var n = numberRe.exec(string.slice(i)); - return n ? (d.Q = +n[0], i + n[0].length) : -1; - } - function parseUnixTimestampSeconds(d, string, i) { - var n = numberRe.exec(string.slice(i)); - return n ? (d.s = +n[0], i + n[0].length) : -1; - } - function formatDayOfMonth(d, p) { - return pad(d.getDate(), p, 2); - } - function formatHour24(d, p) { - return pad(d.getHours(), p, 2); - } - function formatHour12(d, p) { - return pad(d.getHours() % 12 || 12, p, 2); - } - function formatDayOfYear(d, p) { - return pad(1 + timeDay.count(timeYear(d), d), p, 3); - } - function formatMilliseconds(d, p) { - return pad(d.getMilliseconds(), p, 3); - } - function formatMicroseconds(d, p) { - return formatMilliseconds(d, p) + "000"; - } - function formatMonthNumber(d, p) { - return pad(d.getMonth() + 1, p, 2); - } - function formatMinutes(d, p) { - return pad(d.getMinutes(), p, 2); - } - function formatSeconds(d, p) { - return pad(d.getSeconds(), p, 2); - } - function formatWeekdayNumberMonday(d) { - var day2 = d.getDay(); - return day2 === 0 ? 7 : day2; - } - function formatWeekNumberSunday(d, p) { - return pad(sunday.count(timeYear(d) - 1, d), p, 2); - } - function dISO(d) { - var day2 = d.getDay(); - return day2 >= 4 || day2 === 0 ? thursday(d) : thursday.ceil(d); - } - function formatWeekNumberISO(d, p) { - d = dISO(d); - return pad(thursday.count(timeYear(d), d) + (timeYear(d).getDay() === 4), p, 2); - } - function formatWeekdayNumberSunday(d) { - return d.getDay(); - } - function formatWeekNumberMonday(d, p) { - return pad(monday.count(timeYear(d) - 1, d), p, 2); - } - function formatYear(d, p) { - return pad(d.getFullYear() % 100, p, 2); - } - function formatYearISO(d, p) { - d = dISO(d); - return pad(d.getFullYear() % 100, p, 2); - } - function formatFullYear(d, p) { - return pad(d.getFullYear() % 1e4, p, 4); - } - function formatFullYearISO(d, p) { - var day2 = d.getDay(); - d = day2 >= 4 || day2 === 0 ? thursday(d) : thursday.ceil(d); - return pad(d.getFullYear() % 1e4, p, 4); - } - function formatZone(d) { - var z = d.getTimezoneOffset(); - return (z > 0 ? "-" : (z *= -1, "+")) + pad(z / 60 | 0, "0", 2) + pad(z % 60, "0", 2); - } - function formatUTCDayOfMonth(d, p) { - return pad(d.getUTCDate(), p, 2); - } - function formatUTCHour24(d, p) { - return pad(d.getUTCHours(), p, 2); - } - function formatUTCHour12(d, p) { - return pad(d.getUTCHours() % 12 || 12, p, 2); - } - function formatUTCDayOfYear(d, p) { - return pad(1 + utcDay$1.count(utcYear$1(d), d), p, 3); - } - function formatUTCMilliseconds(d, p) { - return pad(d.getUTCMilliseconds(), p, 3); - } - function formatUTCMicroseconds(d, p) { - return formatUTCMilliseconds(d, p) + "000"; - } - function formatUTCMonthNumber(d, p) { - return pad(d.getUTCMonth() + 1, p, 2); - } - function formatUTCMinutes(d, p) { - return pad(d.getUTCMinutes(), p, 2); - } - function formatUTCSeconds(d, p) { - return pad(d.getUTCSeconds(), p, 2); - } - function formatUTCWeekdayNumberMonday(d) { - var dow = d.getUTCDay(); - return dow === 0 ? 7 : dow; - } - function formatUTCWeekNumberSunday(d, p) { - return pad(utcSunday.count(utcYear$1(d) - 1, d), p, 2); - } - function UTCdISO(d) { - var day2 = d.getUTCDay(); - return day2 >= 4 || day2 === 0 ? utcThursday(d) : utcThursday.ceil(d); - } - function formatUTCWeekNumberISO(d, p) { - d = UTCdISO(d); - return pad(utcThursday.count(utcYear$1(d), d) + (utcYear$1(d).getUTCDay() === 4), p, 2); - } - function formatUTCWeekdayNumberSunday(d) { - return d.getUTCDay(); - } - function formatUTCWeekNumberMonday(d, p) { - return pad(utcMonday.count(utcYear$1(d) - 1, d), p, 2); - } - function formatUTCYear(d, p) { - return pad(d.getUTCFullYear() % 100, p, 2); - } - function formatUTCYearISO(d, p) { - d = UTCdISO(d); - return pad(d.getUTCFullYear() % 100, p, 2); - } - function formatUTCFullYear(d, p) { - return pad(d.getUTCFullYear() % 1e4, p, 4); - } - function formatUTCFullYearISO(d, p) { - var day2 = d.getUTCDay(); - d = day2 >= 4 || day2 === 0 ? utcThursday(d) : utcThursday.ceil(d); - return pad(d.getUTCFullYear() % 1e4, p, 4); - } - function formatUTCZone() { - return "+0000"; - } - function formatLiteralPercent() { - return "%"; - } - function formatUnixTimestamp(d) { - return +d; - } - function formatUnixTimestampSeconds(d) { - return Math.floor(+d / 1e3); - } - var locale; - var timeFormat; - var timeParse; - var utcFormat; - var utcParse; - defaultLocale({ - dateTime: "%x, %X", - date: "%-m/%-d/%Y", - time: "%-I:%M:%S %p", - 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"] - }); - function defaultLocale(definition) { - locale = formatLocale(definition); - timeFormat = locale.format; - timeParse = locale.parse; - utcFormat = locale.utcFormat; - utcParse = locale.utcParse; - return locale; - } - var isoSpecifier = "%Y-%m-%dT%H:%M:%S.%LZ"; - function formatIsoNative(date2) { - return date2.toISOString(); - } - var formatIso = Date.prototype.toISOString ? formatIsoNative : utcFormat(isoSpecifier); - const formatIso$1 = formatIso; - function parseIsoNative(string) { - var date2 = new Date(string); - return isNaN(date2) ? null : date2; - } - var parseIso = +new Date("2000-01-01T00:00:00.000Z") ? parseIsoNative : utcParse(isoSpecifier); - const parseIso$1 = parseIso; - function date(t) { - return new Date(t); - } - function number(t) { - return t instanceof Date ? +t : +new Date(+t); - } - function calendar(ticks2, tickInterval, year2, month2, week, day2, hour2, minute2, second2, format2) { - var scale = continuous(), invert2 = scale.invert, domain = scale.domain; - var formatMillisecond = format2(".%L"), formatSecond = format2(":%S"), formatMinute = format2("%I:%M"), formatHour = format2("%I %p"), formatDay = format2("%a %d"), formatWeek = format2("%b %d"), formatMonth = format2("%B"), formatYear2 = format2("%Y"); - function tickFormat2(date2) { - return (second2(date2) < date2 ? formatMillisecond : minute2(date2) < date2 ? formatSecond : hour2(date2) < date2 ? formatMinute : day2(date2) < date2 ? formatHour : month2(date2) < date2 ? week(date2) < date2 ? formatDay : formatWeek : year2(date2) < date2 ? formatMonth : formatYear2)(date2); - } - scale.invert = function(y2) { - return new Date(invert2(y2)); - }; - scale.domain = function(_2) { - return arguments.length ? domain(Array.from(_2, number)) : domain().map(date); - }; - scale.ticks = function(interval2) { - var d = domain(); - return ticks2(d[0], d[d.length - 1], interval2 == null ? 10 : interval2); - }; - scale.tickFormat = function(count2, specifier) { - return specifier == null ? tickFormat2 : format2(specifier); - }; - scale.nice = function(interval2) { - var d = domain(); - if (!interval2 || typeof interval2.range !== "function") - interval2 = tickInterval(d[0], d[d.length - 1], interval2 == null ? 10 : interval2); - return interval2 ? domain(nice(d, interval2)) : scale; - }; - scale.copy = function() { - return copy$2(scale, calendar(ticks2, tickInterval, year2, month2, week, day2, hour2, minute2, second2, format2)); - }; - return scale; - } - function time() { - return initRange.apply(calendar(timeTicks, timeTickInterval, timeYear, timeMonth, sunday, timeDay, timeHour, timeMinute, utcSecond, timeFormat).domain([new Date(2e3, 0, 1), new Date(2e3, 0, 2)]), arguments); - } - function utcTime() { - return initRange.apply(calendar(utcTicks, utcTickInterval, utcYear$1, utcMonth$1, utcSunday, utcDay$1, utcHour$1, utcMinute$1, utcSecond, utcFormat).domain([Date.UTC(2e3, 0, 1), Date.UTC(2e3, 0, 2)]), arguments); - } - function transformer$1() { - var x02 = 0, x12 = 1, t02, t12, k10, transform2, interpolator = identity$3, clamp = false, unknown; - function scale(x2) { - return x2 == null || isNaN(x2 = +x2) ? unknown : interpolator(k10 === 0 ? 0.5 : (x2 = (transform2(x2) - t02) * k10, clamp ? Math.max(0, Math.min(1, x2)) : x2)); - } - scale.domain = function(_2) { - return arguments.length ? ([x02, x12] = _2, t02 = transform2(x02 = +x02), t12 = transform2(x12 = +x12), k10 = t02 === t12 ? 0 : 1 / (t12 - t02), scale) : [x02, x12]; - }; - scale.clamp = function(_2) { - return arguments.length ? (clamp = !!_2, scale) : clamp; - }; - scale.interpolator = function(_2) { - return arguments.length ? (interpolator = _2, scale) : interpolator; - }; - function range2(interpolate2) { - return function(_2) { - var r0, r1; - return arguments.length ? ([r0, r1] = _2, interpolator = interpolate2(r0, r1), scale) : [interpolator(0), interpolator(1)]; - }; - } - scale.range = range2(interpolate$2); - scale.rangeRound = range2(interpolateRound); - scale.unknown = function(_2) { - return arguments.length ? (unknown = _2, scale) : unknown; - }; - return function(t) { - transform2 = t, t02 = t(x02), t12 = t(x12), k10 = t02 === t12 ? 0 : 1 / (t12 - t02); - return scale; - }; - } - function copy$1(source, target) { - return target.domain(source.domain()).interpolator(source.interpolator()).clamp(source.clamp()).unknown(source.unknown()); - } - function sequential() { - var scale = linearish(transformer$1()(identity$3)); - scale.copy = function() { - return copy$1(scale, sequential()); - }; - return initInterpolator.apply(scale, arguments); - } - function sequentialLog() { - var scale = loggish(transformer$1()).domain([1, 10]); - scale.copy = function() { - return copy$1(scale, sequentialLog()).base(scale.base()); - }; - return initInterpolator.apply(scale, arguments); - } - function sequentialSymlog() { - var scale = symlogish(transformer$1()); - scale.copy = function() { - return copy$1(scale, sequentialSymlog()).constant(scale.constant()); - }; - return initInterpolator.apply(scale, arguments); - } - function sequentialPow() { - var scale = powish(transformer$1()); - scale.copy = function() { - return copy$1(scale, sequentialPow()).exponent(scale.exponent()); - }; - return initInterpolator.apply(scale, arguments); - } - function sequentialSqrt() { - return sequentialPow.apply(null, arguments).exponent(0.5); - } - function sequentialQuantile() { - var domain = [], interpolator = identity$3; - function scale(x2) { - if (x2 != null && !isNaN(x2 = +x2)) - return interpolator((bisect(domain, x2, 1) - 1) / (domain.length - 1)); - } - scale.domain = function(_2) { - if (!arguments.length) - return domain.slice(); - domain = []; - for (let d of _2) - if (d != null && !isNaN(d = +d)) - domain.push(d); - domain.sort(ascending$3); - return scale; - }; - scale.interpolator = function(_2) { - return arguments.length ? (interpolator = _2, scale) : interpolator; - }; - scale.range = function() { - return domain.map((d, i) => interpolator(i / (domain.length - 1))); - }; - scale.quantiles = function(n) { - return Array.from({ length: n + 1 }, (_2, i) => quantile$1(domain, i / n)); - }; - scale.copy = function() { - return sequentialQuantile(interpolator).domain(domain); - }; - return initInterpolator.apply(scale, arguments); - } - function transformer() { - var x02 = 0, x12 = 0.5, x2 = 1, s2 = 1, t02, t12, t22, k10, k21, interpolator = identity$3, transform2, clamp = false, unknown; - function scale(x3) { - return isNaN(x3 = +x3) ? unknown : (x3 = 0.5 + ((x3 = +transform2(x3)) - t12) * (s2 * x3 < s2 * t12 ? k10 : k21), interpolator(clamp ? Math.max(0, Math.min(1, x3)) : x3)); - } - scale.domain = function(_2) { - return arguments.length ? ([x02, x12, x2] = _2, t02 = transform2(x02 = +x02), t12 = transform2(x12 = +x12), t22 = transform2(x2 = +x2), k10 = t02 === t12 ? 0 : 0.5 / (t12 - t02), k21 = t12 === t22 ? 0 : 0.5 / (t22 - t12), s2 = t12 < t02 ? -1 : 1, scale) : [x02, x12, x2]; - }; - scale.clamp = function(_2) { - return arguments.length ? (clamp = !!_2, scale) : clamp; - }; - scale.interpolator = function(_2) { - return arguments.length ? (interpolator = _2, scale) : interpolator; - }; - function range2(interpolate2) { - return function(_2) { - var r0, r1, r2; - return arguments.length ? ([r0, r1, r2] = _2, interpolator = piecewise(interpolate2, [r0, r1, r2]), scale) : [interpolator(0), interpolator(0.5), interpolator(1)]; - }; - } - scale.range = range2(interpolate$2); - scale.rangeRound = range2(interpolateRound); - scale.unknown = function(_2) { - return arguments.length ? (unknown = _2, scale) : unknown; - }; - return function(t) { - transform2 = t, t02 = t(x02), t12 = t(x12), t22 = t(x2), k10 = t02 === t12 ? 0 : 0.5 / (t12 - t02), k21 = t12 === t22 ? 0 : 0.5 / (t22 - t12), s2 = t12 < t02 ? -1 : 1; - return scale; - }; - } - function diverging$1() { - var scale = linearish(transformer()(identity$3)); - scale.copy = function() { - return copy$1(scale, diverging$1()); - }; - return initInterpolator.apply(scale, arguments); - } - function divergingLog() { - var scale = loggish(transformer()).domain([0.1, 1, 10]); - scale.copy = function() { - return copy$1(scale, divergingLog()).base(scale.base()); - }; - return initInterpolator.apply(scale, arguments); - } - function divergingSymlog() { - var scale = symlogish(transformer()); - scale.copy = function() { - return copy$1(scale, divergingSymlog()).constant(scale.constant()); - }; - return initInterpolator.apply(scale, arguments); - } - function divergingPow() { - var scale = powish(transformer()); - scale.copy = function() { - return copy$1(scale, divergingPow()).exponent(scale.exponent()); - }; - return initInterpolator.apply(scale, arguments); - } - function divergingSqrt() { - return divergingPow.apply(null, arguments).exponent(0.5); - } - function colors(specifier) { - var n = specifier.length / 6 | 0, colors2 = new Array(n), i = 0; - while (i < n) - colors2[i] = "#" + specifier.slice(i * 6, ++i * 6); - return colors2; - } - const category10 = colors("1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf"); - const Accent = colors("7fc97fbeaed4fdc086ffff99386cb0f0027fbf5b17666666"); - const Dark2 = colors("1b9e77d95f027570b3e7298a66a61ee6ab02a6761d666666"); - const Paired = colors("a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928"); - const Pastel1 = colors("fbb4aeb3cde3ccebc5decbe4fed9a6ffffcce5d8bdfddaecf2f2f2"); - const Pastel2 = colors("b3e2cdfdcdaccbd5e8f4cae4e6f5c9fff2aef1e2cccccccc"); - const Set1 = colors("e41a1c377eb84daf4a984ea3ff7f00ffff33a65628f781bf999999"); - const Set2 = colors("66c2a5fc8d628da0cbe78ac3a6d854ffd92fe5c494b3b3b3"); - const Set3 = colors("8dd3c7ffffb3bebadafb807280b1d3fdb462b3de69fccde5d9d9d9bc80bdccebc5ffed6f"); - const Tableau10 = colors("4e79a7f28e2ce1575976b7b259a14fedc949af7aa1ff9da79c755fbab0ab"); - const ramp$1 = (scheme2) => rgbBasis(scheme2[scheme2.length - 1]); - var scheme$q = new Array(3).concat( - "d8b365f5f5f55ab4ac", - "a6611adfc27d80cdc1018571", - "a6611adfc27df5f5f580cdc1018571", - "8c510ad8b365f6e8c3c7eae55ab4ac01665e", - "8c510ad8b365f6e8c3f5f5f5c7eae55ab4ac01665e", - "8c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e", - "8c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e", - "5430058c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e003c30", - "5430058c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e003c30" - ).map(colors); - const BrBG = ramp$1(scheme$q); - var scheme$p = new Array(3).concat( - "af8dc3f7f7f77fbf7b", - "7b3294c2a5cfa6dba0008837", - "7b3294c2a5cff7f7f7a6dba0008837", - "762a83af8dc3e7d4e8d9f0d37fbf7b1b7837", - "762a83af8dc3e7d4e8f7f7f7d9f0d37fbf7b1b7837", - "762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b7837", - "762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b7837", - "40004b762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b783700441b", - "40004b762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b783700441b" - ).map(colors); - const PRGn = ramp$1(scheme$p); - var scheme$o = new Array(3).concat( - "e9a3c9f7f7f7a1d76a", - "d01c8bf1b6dab8e1864dac26", - "d01c8bf1b6daf7f7f7b8e1864dac26", - "c51b7de9a3c9fde0efe6f5d0a1d76a4d9221", - "c51b7de9a3c9fde0eff7f7f7e6f5d0a1d76a4d9221", - "c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221", - "c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221", - "8e0152c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221276419", - "8e0152c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221276419" - ).map(colors); - const PiYG = ramp$1(scheme$o); - var scheme$n = new Array(3).concat( - "998ec3f7f7f7f1a340", - "5e3c99b2abd2fdb863e66101", - "5e3c99b2abd2f7f7f7fdb863e66101", - "542788998ec3d8daebfee0b6f1a340b35806", - "542788998ec3d8daebf7f7f7fee0b6f1a340b35806", - "5427888073acb2abd2d8daebfee0b6fdb863e08214b35806", - "5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b35806", - "2d004b5427888073acb2abd2d8daebfee0b6fdb863e08214b358067f3b08", - "2d004b5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b358067f3b08" - ).map(colors); - const PuOr = ramp$1(scheme$n); - var scheme$m = new Array(3).concat( - "ef8a62f7f7f767a9cf", - "ca0020f4a58292c5de0571b0", - "ca0020f4a582f7f7f792c5de0571b0", - "b2182bef8a62fddbc7d1e5f067a9cf2166ac", - "b2182bef8a62fddbc7f7f7f7d1e5f067a9cf2166ac", - "b2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac", - "b2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac", - "67001fb2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac053061", - "67001fb2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac053061" - ).map(colors); - const RdBu = ramp$1(scheme$m); - var scheme$l = new Array(3).concat( - "ef8a62ffffff999999", - "ca0020f4a582bababa404040", - "ca0020f4a582ffffffbababa404040", - "b2182bef8a62fddbc7e0e0e09999994d4d4d", - "b2182bef8a62fddbc7ffffffe0e0e09999994d4d4d", - "b2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d", - "b2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d", - "67001fb2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d1a1a1a", - "67001fb2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d1a1a1a" - ).map(colors); - const RdGy = ramp$1(scheme$l); - var scheme$k = new Array(3).concat( - "fc8d59ffffbf91bfdb", - "d7191cfdae61abd9e92c7bb6", - "d7191cfdae61ffffbfabd9e92c7bb6", - "d73027fc8d59fee090e0f3f891bfdb4575b4", - "d73027fc8d59fee090ffffbfe0f3f891bfdb4575b4", - "d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4", - "d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4", - "a50026d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4313695", - "a50026d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4313695" - ).map(colors); - const RdYlBu = ramp$1(scheme$k); - var scheme$j = new Array(3).concat( - "fc8d59ffffbf91cf60", - "d7191cfdae61a6d96a1a9641", - "d7191cfdae61ffffbfa6d96a1a9641", - "d73027fc8d59fee08bd9ef8b91cf601a9850", - "d73027fc8d59fee08bffffbfd9ef8b91cf601a9850", - "d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850", - "d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850", - "a50026d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850006837", - "a50026d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850006837" - ).map(colors); - const RdYlGn = ramp$1(scheme$j); - var scheme$i = new Array(3).concat( - "fc8d59ffffbf99d594", - "d7191cfdae61abdda42b83ba", - "d7191cfdae61ffffbfabdda42b83ba", - "d53e4ffc8d59fee08be6f59899d5943288bd", - "d53e4ffc8d59fee08bffffbfe6f59899d5943288bd", - "d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd", - "d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd", - "9e0142d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd5e4fa2", - "9e0142d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd5e4fa2" - ).map(colors); - const Spectral = ramp$1(scheme$i); - var scheme$h = new Array(3).concat( - "e5f5f999d8c92ca25f", - "edf8fbb2e2e266c2a4238b45", - "edf8fbb2e2e266c2a42ca25f006d2c", - "edf8fbccece699d8c966c2a42ca25f006d2c", - "edf8fbccece699d8c966c2a441ae76238b45005824", - "f7fcfde5f5f9ccece699d8c966c2a441ae76238b45005824", - "f7fcfde5f5f9ccece699d8c966c2a441ae76238b45006d2c00441b" - ).map(colors); - const BuGn = ramp$1(scheme$h); - var scheme$g = new Array(3).concat( - "e0ecf49ebcda8856a7", - "edf8fbb3cde38c96c688419d", - "edf8fbb3cde38c96c68856a7810f7c", - "edf8fbbfd3e69ebcda8c96c68856a7810f7c", - "edf8fbbfd3e69ebcda8c96c68c6bb188419d6e016b", - "f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d6e016b", - "f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d810f7c4d004b" - ).map(colors); - const BuPu = ramp$1(scheme$g); - var scheme$f = new Array(3).concat( - "e0f3dba8ddb543a2ca", - "f0f9e8bae4bc7bccc42b8cbe", - "f0f9e8bae4bc7bccc443a2ca0868ac", - "f0f9e8ccebc5a8ddb57bccc443a2ca0868ac", - "f0f9e8ccebc5a8ddb57bccc44eb3d32b8cbe08589e", - "f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe08589e", - "f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe0868ac084081" - ).map(colors); - const GnBu = ramp$1(scheme$f); - var scheme$e = new Array(3).concat( - "fee8c8fdbb84e34a33", - "fef0d9fdcc8afc8d59d7301f", - "fef0d9fdcc8afc8d59e34a33b30000", - "fef0d9fdd49efdbb84fc8d59e34a33b30000", - "fef0d9fdd49efdbb84fc8d59ef6548d7301f990000", - "fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301f990000", - "fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301fb300007f0000" - ).map(colors); - const OrRd = ramp$1(scheme$e); - var scheme$d = new Array(3).concat( - "ece2f0a6bddb1c9099", - "f6eff7bdc9e167a9cf02818a", - "f6eff7bdc9e167a9cf1c9099016c59", - "f6eff7d0d1e6a6bddb67a9cf1c9099016c59", - "f6eff7d0d1e6a6bddb67a9cf3690c002818a016450", - "fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016450", - "fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016c59014636" - ).map(colors); - const PuBuGn = ramp$1(scheme$d); - var scheme$c = new Array(3).concat( - "ece7f2a6bddb2b8cbe", - "f1eef6bdc9e174a9cf0570b0", - "f1eef6bdc9e174a9cf2b8cbe045a8d", - "f1eef6d0d1e6a6bddb74a9cf2b8cbe045a8d", - "f1eef6d0d1e6a6bddb74a9cf3690c00570b0034e7b", - "fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0034e7b", - "fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0045a8d023858" - ).map(colors); - const PuBu = ramp$1(scheme$c); - var scheme$b = new Array(3).concat( - "e7e1efc994c7dd1c77", - "f1eef6d7b5d8df65b0ce1256", - "f1eef6d7b5d8df65b0dd1c77980043", - "f1eef6d4b9dac994c7df65b0dd1c77980043", - "f1eef6d4b9dac994c7df65b0e7298ace125691003f", - "f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125691003f", - "f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125698004367001f" - ).map(colors); - const PuRd = ramp$1(scheme$b); - var scheme$a = new Array(3).concat( - "fde0ddfa9fb5c51b8a", - "feebe2fbb4b9f768a1ae017e", - "feebe2fbb4b9f768a1c51b8a7a0177", - "feebe2fcc5c0fa9fb5f768a1c51b8a7a0177", - "feebe2fcc5c0fa9fb5f768a1dd3497ae017e7a0177", - "fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a0177", - "fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a017749006a" - ).map(colors); - const RdPu = ramp$1(scheme$a); - var scheme$9 = new Array(3).concat( - "edf8b17fcdbb2c7fb8", - "ffffcca1dab441b6c4225ea8", - "ffffcca1dab441b6c42c7fb8253494", - "ffffccc7e9b47fcdbb41b6c42c7fb8253494", - "ffffccc7e9b47fcdbb41b6c41d91c0225ea80c2c84", - "ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea80c2c84", - "ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea8253494081d58" - ).map(colors); - const YlGnBu = ramp$1(scheme$9); - var scheme$8 = new Array(3).concat( - "f7fcb9addd8e31a354", - "ffffccc2e69978c679238443", - "ffffccc2e69978c67931a354006837", - "ffffccd9f0a3addd8e78c67931a354006837", - "ffffccd9f0a3addd8e78c67941ab5d238443005a32", - "ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443005a32", - "ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443006837004529" - ).map(colors); - const YlGn = ramp$1(scheme$8); - var scheme$7 = new Array(3).concat( - "fff7bcfec44fd95f0e", - "ffffd4fed98efe9929cc4c02", - "ffffd4fed98efe9929d95f0e993404", - "ffffd4fee391fec44ffe9929d95f0e993404", - "ffffd4fee391fec44ffe9929ec7014cc4c028c2d04", - "ffffe5fff7bcfee391fec44ffe9929ec7014cc4c028c2d04", - "ffffe5fff7bcfee391fec44ffe9929ec7014cc4c02993404662506" - ).map(colors); - const YlOrBr = ramp$1(scheme$7); - var scheme$6 = new Array(3).concat( - "ffeda0feb24cf03b20", - "ffffb2fecc5cfd8d3ce31a1c", - "ffffb2fecc5cfd8d3cf03b20bd0026", - "ffffb2fed976feb24cfd8d3cf03b20bd0026", - "ffffb2fed976feb24cfd8d3cfc4e2ae31a1cb10026", - "ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cb10026", - "ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cbd0026800026" - ).map(colors); - const YlOrRd = ramp$1(scheme$6); - var scheme$5 = new Array(3).concat( - "deebf79ecae13182bd", - "eff3ffbdd7e76baed62171b5", - "eff3ffbdd7e76baed63182bd08519c", - "eff3ffc6dbef9ecae16baed63182bd08519c", - "eff3ffc6dbef9ecae16baed64292c62171b5084594", - "f7fbffdeebf7c6dbef9ecae16baed64292c62171b5084594", - "f7fbffdeebf7c6dbef9ecae16baed64292c62171b508519c08306b" - ).map(colors); - const Blues = ramp$1(scheme$5); - var scheme$4 = new Array(3).concat( - "e5f5e0a1d99b31a354", - "edf8e9bae4b374c476238b45", - "edf8e9bae4b374c47631a354006d2c", - "edf8e9c7e9c0a1d99b74c47631a354006d2c", - "edf8e9c7e9c0a1d99b74c47641ab5d238b45005a32", - "f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45005a32", - "f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45006d2c00441b" - ).map(colors); - const Greens = ramp$1(scheme$4); - var scheme$3 = new Array(3).concat( - "f0f0f0bdbdbd636363", - "f7f7f7cccccc969696525252", - "f7f7f7cccccc969696636363252525", - "f7f7f7d9d9d9bdbdbd969696636363252525", - "f7f7f7d9d9d9bdbdbd969696737373525252252525", - "fffffff0f0f0d9d9d9bdbdbd969696737373525252252525", - "fffffff0f0f0d9d9d9bdbdbd969696737373525252252525000000" - ).map(colors); - const Greys = ramp$1(scheme$3); - var scheme$2 = new Array(3).concat( - "efedf5bcbddc756bb1", - "f2f0f7cbc9e29e9ac86a51a3", - "f2f0f7cbc9e29e9ac8756bb154278f", - "f2f0f7dadaebbcbddc9e9ac8756bb154278f", - "f2f0f7dadaebbcbddc9e9ac8807dba6a51a34a1486", - "fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a34a1486", - "fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a354278f3f007d" - ).map(colors); - const Purples = ramp$1(scheme$2); - var scheme$1 = new Array(3).concat( - "fee0d2fc9272de2d26", - "fee5d9fcae91fb6a4acb181d", - "fee5d9fcae91fb6a4ade2d26a50f15", - "fee5d9fcbba1fc9272fb6a4ade2d26a50f15", - "fee5d9fcbba1fc9272fb6a4aef3b2ccb181d99000d", - "fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181d99000d", - "fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181da50f1567000d" - ).map(colors); - const Reds = ramp$1(scheme$1); - var scheme = new Array(3).concat( - "fee6cefdae6be6550d", - "feeddefdbe85fd8d3cd94701", - "feeddefdbe85fd8d3ce6550da63603", - "feeddefdd0a2fdae6bfd8d3ce6550da63603", - "feeddefdd0a2fdae6bfd8d3cf16913d948018c2d04", - "fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d948018c2d04", - "fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d94801a636037f2704" - ).map(colors); - const Oranges = ramp$1(scheme); - function cividis(t) { - t = Math.max(0, Math.min(1, t)); - return "rgb(" + Math.max(0, Math.min(255, Math.round(-4.54 - t * (35.34 - t * (2381.73 - t * (6402.7 - t * (7024.72 - t * 2710.57))))))) + ", " + Math.max(0, Math.min(255, Math.round(32.49 + t * (170.73 + t * (52.82 - t * (131.46 - t * (176.58 - t * 67.37))))))) + ", " + Math.max(0, Math.min(255, Math.round(81.24 + t * (442.36 - t * (2482.43 - t * (6167.24 - t * (6614.94 - t * 2475.67))))))) + ")"; - } - const cubehelix = cubehelixLong(cubehelix$3(300, 0.5, 0), cubehelix$3(-240, 0.5, 1)); - var warm = cubehelixLong(cubehelix$3(-100, 0.75, 0.35), cubehelix$3(80, 1.5, 0.8)); - var cool = cubehelixLong(cubehelix$3(260, 0.75, 0.35), cubehelix$3(80, 1.5, 0.8)); - var c$3 = cubehelix$3(); - function rainbow(t) { - if (t < 0 || t > 1) - t -= Math.floor(t); - var ts = Math.abs(t - 0.5); - c$3.h = 360 * t - 100; - c$3.s = 1.5 - 1.5 * ts; - c$3.l = 0.8 - 0.9 * ts; - return c$3 + ""; - } - var c$2 = rgb(), pi_1_3 = Math.PI / 3, pi_2_3 = Math.PI * 2 / 3; - function sinebow(t) { - var x2; - t = (0.5 - t) * Math.PI; - c$2.r = 255 * (x2 = Math.sin(t)) * x2; - c$2.g = 255 * (x2 = Math.sin(t + pi_1_3)) * x2; - c$2.b = 255 * (x2 = Math.sin(t + pi_2_3)) * x2; - return c$2 + ""; - } - function turbo(t) { - t = Math.max(0, Math.min(1, t)); - return "rgb(" + Math.max(0, Math.min(255, Math.round(34.61 + t * (1172.33 - t * (10793.56 - t * (33300.12 - t * (38394.49 - t * 14825.05))))))) + ", " + Math.max(0, Math.min(255, Math.round(23.31 + t * (557.33 + t * (1225.33 - t * (3574.96 - t * (1073.77 + t * 707.56))))))) + ", " + Math.max(0, Math.min(255, Math.round(27.2 + t * (3211.1 - t * (15327.97 - t * (27814 - t * (22569.18 - t * 6838.66))))))) + ")"; - } - function ramp(range2) { - var n = range2.length; - return function(t) { - return range2[Math.max(0, Math.min(n - 1, Math.floor(t * n)))]; - }; - } - const viridis = ramp(colors("44015444025645045745055946075a46085c460a5d460b5e470d60470e6147106347116447136548146748166848176948186a481a6c481b6d481c6e481d6f481f70482071482173482374482475482576482677482878482979472a7a472c7a472d7b472e7c472f7d46307e46327e46337f463480453581453781453882443983443a83443b84433d84433e85423f854240864241864142874144874045884046883f47883f48893e49893e4a893e4c8a3d4d8a3d4e8a3c4f8a3c508b3b518b3b528b3a538b3a548c39558c39568c38588c38598c375a8c375b8d365c8d365d8d355e8d355f8d34608d34618d33628d33638d32648e32658e31668e31678e31688e30698e306a8e2f6b8e2f6c8e2e6d8e2e6e8e2e6f8e2d708e2d718e2c718e2c728e2c738e2b748e2b758e2a768e2a778e2a788e29798e297a8e297b8e287c8e287d8e277e8e277f8e27808e26818e26828e26828e25838e25848e25858e24868e24878e23888e23898e238a8d228b8d228c8d228d8d218e8d218f8d21908d21918c20928c20928c20938c1f948c1f958b1f968b1f978b1f988b1f998a1f9a8a1e9b8a1e9c891e9d891f9e891f9f881fa0881fa1881fa1871fa28720a38620a48621a58521a68522a78522a88423a98324aa8325ab8225ac8226ad8127ad8128ae8029af7f2ab07f2cb17e2db27d2eb37c2fb47c31b57b32b67a34b67935b77937b87838b9773aba763bbb753dbc743fbc7340bd7242be7144bf7046c06f48c16e4ac16d4cc26c4ec36b50c46a52c56954c56856c66758c7655ac8645cc8635ec96260ca6063cb5f65cb5e67cc5c69cd5b6ccd5a6ece5870cf5773d05675d05477d1537ad1517cd2507fd34e81d34d84d44b86d54989d5488bd6468ed64590d74393d74195d84098d83e9bd93c9dd93ba0da39a2da37a5db36a8db34aadc32addc30b0dd2fb2dd2db5de2bb8de29bade28bddf26c0df25c2df23c5e021c8e020cae11fcde11dd0e11cd2e21bd5e21ad8e219dae319dde318dfe318e2e418e5e419e7e419eae51aece51befe51cf1e51df4e61ef6e620f8e621fbe723fde725")); - var magma = ramp(colors("00000401000501010601010802010902020b02020d03030f03031204041405041606051806051a07061c08071e0907200a08220b09240c09260d0a290e0b2b100b2d110c2f120d31130d34140e36150e38160f3b180f3d19103f1a10421c10441d11471e114920114b21114e22115024125325125527125829115a2a115c2c115f2d11612f116331116533106734106936106b38106c390f6e3b0f703d0f713f0f72400f74420f75440f764510774710784910784a10794c117a4e117b4f127b51127c52137c54137d56147d57157e59157e5a167e5c167f5d177f5f187f601880621980641a80651a80671b80681c816a1c816b1d816d1d816e1e81701f81721f817320817521817621817822817922827b23827c23827e24828025828125818326818426818627818827818928818b29818c29818e2a81902a81912b81932b80942c80962c80982d80992d809b2e7f9c2e7f9e2f7fa02f7fa1307ea3307ea5317ea6317da8327daa337dab337cad347cae347bb0357bb2357bb3367ab5367ab73779b83779ba3878bc3978bd3977bf3a77c03a76c23b75c43c75c53c74c73d73c83e73ca3e72cc3f71cd4071cf4070d0416fd2426fd3436ed5446dd6456cd8456cd9466bdb476adc4869de4968df4a68e04c67e24d66e34e65e44f64e55064e75263e85362e95462ea5661eb5760ec5860ed5a5fee5b5eef5d5ef05f5ef1605df2625df2645cf3655cf4675cf4695cf56b5cf66c5cf66e5cf7705cf7725cf8745cf8765cf9785df9795df97b5dfa7d5efa7f5efa815ffb835ffb8560fb8761fc8961fc8a62fc8c63fc8e64fc9065fd9266fd9467fd9668fd9869fd9a6afd9b6bfe9d6cfe9f6dfea16efea36ffea571fea772fea973feaa74feac76feae77feb078feb27afeb47bfeb67cfeb77efeb97ffebb81febd82febf84fec185fec287fec488fec68afec88cfeca8dfecc8ffecd90fecf92fed194fed395fed597fed799fed89afdda9cfddc9efddea0fde0a1fde2a3fde3a5fde5a7fde7a9fde9aafdebacfcecaefceeb0fcf0b2fcf2b4fcf4b6fcf6b8fcf7b9fcf9bbfcfbbdfcfdbf")); - var inferno = ramp(colors("00000401000501010601010802010a02020c02020e03021004031204031405041706041907051b08051d09061f0a07220b07240c08260d08290e092b10092d110a30120a32140b34150b37160b39180c3c190c3e1b0c411c0c431e0c451f0c48210c4a230c4c240c4f260c51280b53290b552b0b572d0b592f0a5b310a5c320a5e340a5f3609613809623909633b09643d09653e0966400a67420a68440a68450a69470b6a490b6a4a0c6b4c0c6b4d0d6c4f0d6c510e6c520e6d540f6d550f6d57106e59106e5a116e5c126e5d126e5f136e61136e62146e64156e65156e67166e69166e6a176e6c186e6d186e6f196e71196e721a6e741a6e751b6e771c6d781c6d7a1d6d7c1d6d7d1e6d7f1e6c801f6c82206c84206b85216b87216b88226a8a226a8c23698d23698f24699025689225689326679526679727669827669a28659b29649d29649f2a63a02a63a22b62a32c61a52c60a62d60a82e5fa92e5eab2f5ead305dae305cb0315bb1325ab3325ab43359b63458b73557b93556ba3655bc3754bd3853bf3952c03a51c13a50c33b4fc43c4ec63d4dc73e4cc83f4bca404acb4149cc4248ce4347cf4446d04545d24644d34743d44842d54a41d74b3fd84c3ed94d3dda4e3cdb503bdd513ade5238df5337e05536e15635e25734e35933e45a31e55c30e65d2fe75e2ee8602de9612bea632aeb6429eb6628ec6726ed6925ee6a24ef6c23ef6e21f06f20f1711ff1731df2741cf3761bf37819f47918f57b17f57d15f67e14f68013f78212f78410f8850ff8870ef8890cf98b0bf98c0af98e09fa9008fa9207fa9407fb9606fb9706fb9906fb9b06fb9d07fc9f07fca108fca309fca50afca60cfca80dfcaa0ffcac11fcae12fcb014fcb216fcb418fbb61afbb81dfbba1ffbbc21fbbe23fac026fac228fac42afac62df9c72ff9c932f9cb35f8cd37f8cf3af7d13df7d340f6d543f6d746f5d949f5db4cf4dd4ff4df53f4e156f3e35af3e55df2e661f2e865f2ea69f1ec6df1ed71f1ef75f1f179f2f27df2f482f3f586f3f68af4f88ef5f992f6fa96f8fb9af9fc9dfafda1fcffa4")); - var plasma = ramp(colors("0d088710078813078916078a19068c1b068d1d068e20068f2206902406912605912805922a05932c05942e05952f059631059733059735049837049938049a3a049a3c049b3e049c3f049c41049d43039e44039e46039f48039f4903a04b03a14c02a14e02a25002a25102a35302a35502a45601a45801a45901a55b01a55c01a65e01a66001a66100a76300a76400a76600a76700a86900a86a00a86c00a86e00a86f00a87100a87201a87401a87501a87701a87801a87a02a87b02a87d03a87e03a88004a88104a78305a78405a78606a68707a68808a68a09a58b0aa58d0ba58e0ca48f0da4910ea3920fa39410a29511a19613a19814a099159f9a169f9c179e9d189d9e199da01a9ca11b9ba21d9aa31e9aa51f99a62098a72197a82296aa2395ab2494ac2694ad2793ae2892b02991b12a90b22b8fb32c8eb42e8db52f8cb6308bb7318ab83289ba3388bb3488bc3587bd3786be3885bf3984c03a83c13b82c23c81c33d80c43e7fc5407ec6417dc7427cc8437bc9447aca457acb4679cc4778cc4977cd4a76ce4b75cf4c74d04d73d14e72d24f71d35171d45270d5536fd5546ed6556dd7566cd8576bd9586ada5a6ada5b69db5c68dc5d67dd5e66de5f65de6164df6263e06363e16462e26561e26660e3685fe4695ee56a5de56b5de66c5ce76e5be76f5ae87059e97158e97257ea7457eb7556eb7655ec7754ed7953ed7a52ee7b51ef7c51ef7e50f07f4ff0804ef1814df1834cf2844bf3854bf3874af48849f48948f58b47f58c46f68d45f68f44f79044f79143f79342f89441f89540f9973ff9983ef99a3efa9b3dfa9c3cfa9e3bfb9f3afba139fba238fca338fca537fca636fca835fca934fdab33fdac33fdae32fdaf31fdb130fdb22ffdb42ffdb52efeb72dfeb82cfeba2cfebb2bfebd2afebe2afec029fdc229fdc328fdc527fdc627fdc827fdca26fdcb26fccd25fcce25fcd025fcd225fbd324fbd524fbd724fad824fada24f9dc24f9dd25f8df25f8e125f7e225f7e425f6e626f6e826f5e926f5eb27f4ed27f3ee27f3f027f2f227f1f426f1f525f0f724f0f921")); - function constant$1(x2) { - return function constant2() { - return x2; - }; - } - const abs$1 = Math.abs; - const atan2 = Math.atan2; - const cos = Math.cos; - const max = Math.max; - const min = Math.min; - const sin = Math.sin; - const sqrt = Math.sqrt; - const epsilon = 1e-12; - const pi = Math.PI; - const halfPi = pi / 2; - const tau = 2 * pi; - function acos(x2) { - return x2 > 1 ? 0 : x2 < -1 ? pi : Math.acos(x2); - } - function asin(x2) { - return x2 >= 1 ? halfPi : x2 <= -1 ? -halfPi : Math.asin(x2); - } - function arcInnerRadius(d) { - return d.innerRadius; - } - function arcOuterRadius(d) { - return d.outerRadius; - } - function arcStartAngle(d) { - return d.startAngle; - } - function arcEndAngle(d) { - return d.endAngle; - } - function arcPadAngle(d) { - return d && d.padAngle; - } - function intersect$2(x02, y02, x12, y12, x2, y2, x3, y3) { - var x10 = x12 - x02, y10 = y12 - y02, x32 = x3 - x2, y32 = y3 - y2, t = y32 * x10 - x32 * y10; - if (t * t < epsilon) - return; - t = (x32 * (y02 - y2) - y32 * (x02 - x2)) / t; - return [x02 + t * x10, y02 + t * y10]; - } - function cornerTangents(x02, y02, x12, y12, r1, rc, cw) { - var x01 = x02 - x12, y01 = y02 - y12, lo = (cw ? rc : -rc) / sqrt(x01 * x01 + y01 * y01), ox = lo * y01, oy = -lo * x01, x11 = x02 + ox, y11 = y02 + oy, x10 = x12 + ox, y10 = y12 + oy, x002 = (x11 + x10) / 2, y002 = (y11 + y10) / 2, dx = x10 - x11, dy = y10 - y11, d2 = dx * dx + dy * dy, r = r1 - rc, D2 = x11 * y10 - x10 * y11, d = (dy < 0 ? -1 : 1) * sqrt(max(0, r * r * d2 - D2 * D2)), cx0 = (D2 * dy - dx * d) / d2, cy0 = (-D2 * dx - dy * d) / d2, cx1 = (D2 * dy + dx * d) / d2, cy1 = (-D2 * dx + dy * d) / d2, dx0 = cx0 - x002, dy0 = cy0 - y002, dx1 = cx1 - x002, dy1 = cy1 - y002; - if (dx0 * dx0 + dy0 * dy0 > dx1 * dx1 + dy1 * dy1) - cx0 = cx1, cy0 = cy1; - return { - cx: cx0, - cy: cy0, - x01: -ox, - y01: -oy, - x11: cx0 * (r1 / r - 1), - y11: cy0 * (r1 / r - 1) - }; - } - function d3arc() { - var innerRadius = arcInnerRadius, outerRadius = arcOuterRadius, cornerRadius = constant$1(0), padRadius = null, startAngle = arcStartAngle, endAngle = arcEndAngle, padAngle = arcPadAngle, context = null; - function arc() { - var buffer2, r, r0 = +innerRadius.apply(this, arguments), r1 = +outerRadius.apply(this, arguments), a0 = startAngle.apply(this, arguments) - halfPi, a1 = endAngle.apply(this, arguments) - halfPi, da = abs$1(a1 - a0), cw = a1 > a0; - if (!context) - context = buffer2 = path(); - if (r1 < r0) - r = r1, r1 = r0, r0 = r; - if (!(r1 > epsilon)) - context.moveTo(0, 0); - else if (da > tau - epsilon) { - context.moveTo(r1 * cos(a0), r1 * sin(a0)); - context.arc(0, 0, r1, a0, a1, !cw); - if (r0 > epsilon) { - context.moveTo(r0 * cos(a1), r0 * sin(a1)); - context.arc(0, 0, r0, a1, a0, cw); - } - } else { - var a01 = a0, a11 = a1, a00 = a0, a10 = a1, da0 = da, da1 = da, ap = padAngle.apply(this, arguments) / 2, rp = ap > epsilon && (padRadius ? +padRadius.apply(this, arguments) : sqrt(r0 * r0 + r1 * r1)), rc = min(abs$1(r1 - r0) / 2, +cornerRadius.apply(this, arguments)), rc0 = rc, rc1 = rc, t02, t12; - if (rp > epsilon) { - var p02 = asin(rp / r0 * sin(ap)), p1 = asin(rp / r1 * sin(ap)); - if ((da0 -= p02 * 2) > epsilon) - p02 *= cw ? 1 : -1, a00 += p02, a10 -= p02; - else - da0 = 0, a00 = a10 = (a0 + a1) / 2; - if ((da1 -= p1 * 2) > epsilon) - p1 *= cw ? 1 : -1, a01 += p1, a11 -= p1; - else - da1 = 0, a01 = a11 = (a0 + a1) / 2; - } - var x01 = r1 * cos(a01), y01 = r1 * sin(a01), x10 = r0 * cos(a10), y10 = r0 * sin(a10); - if (rc > epsilon) { - var x11 = r1 * cos(a11), y11 = r1 * sin(a11), x002 = r0 * cos(a00), y002 = r0 * sin(a00), oc; - if (da < pi && (oc = intersect$2(x01, y01, x002, y002, x11, y11, x10, y10))) { - var ax = x01 - oc[0], ay = y01 - oc[1], bx = x11 - oc[0], by = y11 - oc[1], kc = 1 / sin(acos((ax * bx + ay * by) / (sqrt(ax * ax + ay * ay) * sqrt(bx * bx + by * by))) / 2), lc = sqrt(oc[0] * oc[0] + oc[1] * oc[1]); - rc0 = min(rc, (r0 - lc) / (kc - 1)); - rc1 = min(rc, (r1 - lc) / (kc + 1)); - } - } - if (!(da1 > epsilon)) - context.moveTo(x01, y01); - else if (rc1 > epsilon) { - t02 = cornerTangents(x002, y002, x01, y01, r1, rc1, cw); - t12 = cornerTangents(x11, y11, x10, y10, r1, rc1, cw); - context.moveTo(t02.cx + t02.x01, t02.cy + t02.y01); - if (rc1 < rc) - context.arc(t02.cx, t02.cy, rc1, atan2(t02.y01, t02.x01), atan2(t12.y01, t12.x01), !cw); - else { - context.arc(t02.cx, t02.cy, rc1, atan2(t02.y01, t02.x01), atan2(t02.y11, t02.x11), !cw); - context.arc(0, 0, r1, atan2(t02.cy + t02.y11, t02.cx + t02.x11), atan2(t12.cy + t12.y11, t12.cx + t12.x11), !cw); - context.arc(t12.cx, t12.cy, rc1, atan2(t12.y11, t12.x11), atan2(t12.y01, t12.x01), !cw); - } - } else - context.moveTo(x01, y01), context.arc(0, 0, r1, a01, a11, !cw); - if (!(r0 > epsilon) || !(da0 > epsilon)) - context.lineTo(x10, y10); - else if (rc0 > epsilon) { - t02 = cornerTangents(x10, y10, x11, y11, r0, -rc0, cw); - t12 = cornerTangents(x01, y01, x002, y002, r0, -rc0, cw); - context.lineTo(t02.cx + t02.x01, t02.cy + t02.y01); - if (rc0 < rc) - context.arc(t02.cx, t02.cy, rc0, atan2(t02.y01, t02.x01), atan2(t12.y01, t12.x01), !cw); - else { - context.arc(t02.cx, t02.cy, rc0, atan2(t02.y01, t02.x01), atan2(t02.y11, t02.x11), !cw); - context.arc(0, 0, r0, atan2(t02.cy + t02.y11, t02.cx + t02.x11), atan2(t12.cy + t12.y11, t12.cx + t12.x11), cw); - context.arc(t12.cx, t12.cy, rc0, atan2(t12.y11, t12.x11), atan2(t12.y01, t12.x01), !cw); - } - } else - context.arc(0, 0, r0, a10, a00, cw); - } - context.closePath(); - if (buffer2) - return context = null, buffer2 + "" || null; - } - arc.centroid = function() { - var r = (+innerRadius.apply(this, arguments) + +outerRadius.apply(this, arguments)) / 2, a2 = (+startAngle.apply(this, arguments) + +endAngle.apply(this, arguments)) / 2 - pi / 2; - return [cos(a2) * r, sin(a2) * r]; - }; - arc.innerRadius = function(_2) { - return arguments.length ? (innerRadius = typeof _2 === "function" ? _2 : constant$1(+_2), arc) : innerRadius; - }; - arc.outerRadius = function(_2) { - return arguments.length ? (outerRadius = typeof _2 === "function" ? _2 : constant$1(+_2), arc) : outerRadius; - }; - arc.cornerRadius = function(_2) { - return arguments.length ? (cornerRadius = typeof _2 === "function" ? _2 : constant$1(+_2), arc) : cornerRadius; - }; - arc.padRadius = function(_2) { - return arguments.length ? (padRadius = _2 == null ? null : typeof _2 === "function" ? _2 : constant$1(+_2), arc) : padRadius; - }; - arc.startAngle = function(_2) { - return arguments.length ? (startAngle = typeof _2 === "function" ? _2 : constant$1(+_2), arc) : startAngle; - }; - arc.endAngle = function(_2) { - return arguments.length ? (endAngle = typeof _2 === "function" ? _2 : constant$1(+_2), arc) : endAngle; - }; - arc.padAngle = function(_2) { - return arguments.length ? (padAngle = typeof _2 === "function" ? _2 : constant$1(+_2), arc) : padAngle; - }; - arc.context = function(_2) { - return arguments.length ? (context = _2 == null ? null : _2, arc) : context; - }; - return arc; - } - var slice$1 = Array.prototype.slice; - function array(x2) { - return typeof x2 === "object" && "length" in x2 ? x2 : Array.from(x2); - } - function Linear(context) { - this._context = context; - } - Linear.prototype = { - areaStart: function() { - this._line = 0; - }, - areaEnd: function() { - this._line = NaN; - }, - lineStart: function() { - this._point = 0; - }, - lineEnd: function() { - if (this._line || this._line !== 0 && this._point === 1) - this._context.closePath(); - this._line = 1 - this._line; - }, - point: function(x2, y2) { - x2 = +x2, y2 = +y2; - switch (this._point) { - case 0: - this._point = 1; - this._line ? this._context.lineTo(x2, y2) : this._context.moveTo(x2, y2); - break; - case 1: - this._point = 2; - default: - this._context.lineTo(x2, y2); - break; - } - } - }; - function curveLinear(context) { - return new Linear(context); - } - function x$1(p) { - return p[0]; - } - function y(p) { - return p[1]; - } - function line$1(x2, y$12) { - var defined = constant$1(true), context = null, curve = curveLinear, output = null; - x2 = typeof x2 === "function" ? x2 : x2 === void 0 ? x$1 : constant$1(x2); - y$12 = typeof y$12 === "function" ? y$12 : y$12 === void 0 ? y : constant$1(y$12); - function line2(data) { - var i, n = (data = array(data)).length, d, defined0 = false, buffer2; - if (context == null) - output = curve(buffer2 = path()); - for (i = 0; i <= n; ++i) { - if (!(i < n && defined(d = data[i], i, data)) === defined0) { - if (defined0 = !defined0) - output.lineStart(); - else - output.lineEnd(); - } - if (defined0) - output.point(+x2(d, i, data), +y$12(d, i, data)); - } - if (buffer2) - return output = null, buffer2 + "" || null; - } - line2.x = function(_2) { - return arguments.length ? (x2 = typeof _2 === "function" ? _2 : constant$1(+_2), line2) : x2; - }; - line2.y = function(_2) { - return arguments.length ? (y$12 = typeof _2 === "function" ? _2 : constant$1(+_2), line2) : y$12; - }; - line2.defined = function(_2) { - return arguments.length ? (defined = typeof _2 === "function" ? _2 : constant$1(!!_2), line2) : defined; - }; - line2.curve = function(_2) { - return arguments.length ? (curve = _2, context != null && (output = curve(context)), line2) : curve; - }; - line2.context = function(_2) { - return arguments.length ? (_2 == null ? context = output = null : output = curve(context = _2), line2) : context; - }; - return line2; - } - function area(x02, y02, y12) { - var x12 = null, defined = constant$1(true), context = null, curve = curveLinear, output = null; - x02 = typeof x02 === "function" ? x02 : x02 === void 0 ? x$1 : constant$1(+x02); - y02 = typeof y02 === "function" ? y02 : y02 === void 0 ? constant$1(0) : constant$1(+y02); - y12 = typeof y12 === "function" ? y12 : y12 === void 0 ? y : constant$1(+y12); - function area2(data) { - var i, j, k2, n = (data = array(data)).length, d, defined0 = false, buffer2, x0z = new Array(n), y0z = new Array(n); - if (context == null) - output = curve(buffer2 = path()); - for (i = 0; i <= n; ++i) { - if (!(i < n && defined(d = data[i], i, data)) === defined0) { - if (defined0 = !defined0) { - j = i; - output.areaStart(); - output.lineStart(); - } else { - output.lineEnd(); - output.lineStart(); - for (k2 = i - 1; k2 >= j; --k2) { - output.point(x0z[k2], y0z[k2]); - } - output.lineEnd(); - output.areaEnd(); - } - } - if (defined0) { - x0z[i] = +x02(d, i, data), y0z[i] = +y02(d, i, data); - output.point(x12 ? +x12(d, i, data) : x0z[i], y12 ? +y12(d, i, data) : y0z[i]); - } - } - if (buffer2) - return output = null, buffer2 + "" || null; - } - function arealine() { - return line$1().defined(defined).curve(curve).context(context); - } - area2.x = function(_2) { - return arguments.length ? (x02 = typeof _2 === "function" ? _2 : constant$1(+_2), x12 = null, area2) : x02; - }; - area2.x0 = function(_2) { - return arguments.length ? (x02 = typeof _2 === "function" ? _2 : constant$1(+_2), area2) : x02; - }; - area2.x1 = function(_2) { - return arguments.length ? (x12 = _2 == null ? null : typeof _2 === "function" ? _2 : constant$1(+_2), area2) : x12; - }; - area2.y = function(_2) { - return arguments.length ? (y02 = typeof _2 === "function" ? _2 : constant$1(+_2), y12 = null, area2) : y02; - }; - area2.y0 = function(_2) { - return arguments.length ? (y02 = typeof _2 === "function" ? _2 : constant$1(+_2), area2) : y02; - }; - area2.y1 = function(_2) { - return arguments.length ? (y12 = _2 == null ? null : typeof _2 === "function" ? _2 : constant$1(+_2), area2) : y12; - }; - area2.lineX0 = area2.lineY0 = function() { - return arealine().x(x02).y(y02); - }; - area2.lineY1 = function() { - return arealine().x(x02).y(y12); - }; - area2.lineX1 = function() { - return arealine().x(x12).y(y02); - }; - area2.defined = function(_2) { - return arguments.length ? (defined = typeof _2 === "function" ? _2 : constant$1(!!_2), area2) : defined; - }; - area2.curve = function(_2) { - return arguments.length ? (curve = _2, context != null && (output = curve(context)), area2) : curve; - }; - area2.context = function(_2) { - return arguments.length ? (_2 == null ? context = output = null : output = curve(context = _2), area2) : context; - }; - return area2; - } - function descending$1(a2, b) { - return b < a2 ? -1 : b > a2 ? 1 : b >= a2 ? 0 : NaN; - } - function identity$1(d) { - return d; - } - function d3pie() { - var value = identity$1, sortValues = descending$1, sort2 = null, startAngle = constant$1(0), endAngle = constant$1(tau), padAngle = constant$1(0); - function pie(data) { - var i, n = (data = array(data)).length, j, k2, sum2 = 0, index2 = new Array(n), arcs = new Array(n), a0 = +startAngle.apply(this, arguments), da = Math.min(tau, Math.max(-tau, endAngle.apply(this, arguments) - a0)), a1, p = Math.min(Math.abs(da) / n, padAngle.apply(this, arguments)), pa = p * (da < 0 ? -1 : 1), v; - for (i = 0; i < n; ++i) { - if ((v = arcs[index2[i] = i] = +value(data[i], i, data)) > 0) { - sum2 += v; - } - } - if (sortValues != null) - index2.sort(function(i2, j2) { - return sortValues(arcs[i2], arcs[j2]); - }); - else if (sort2 != null) - index2.sort(function(i2, j2) { - return sort2(data[i2], data[j2]); - }); - for (i = 0, k2 = sum2 ? (da - n * pa) / sum2 : 0; i < n; ++i, a0 = a1) { - j = index2[i], v = arcs[j], a1 = a0 + (v > 0 ? v * k2 : 0) + pa, arcs[j] = { - data: data[j], - index: i, - value: v, - startAngle: a0, - endAngle: a1, - padAngle: p - }; - } - return arcs; - } - pie.value = function(_2) { - return arguments.length ? (value = typeof _2 === "function" ? _2 : constant$1(+_2), pie) : value; - }; - pie.sortValues = function(_2) { - return arguments.length ? (sortValues = _2, sort2 = null, pie) : sortValues; - }; - pie.sort = function(_2) { - return arguments.length ? (sort2 = _2, sortValues = null, pie) : sort2; - }; - pie.startAngle = function(_2) { - return arguments.length ? (startAngle = typeof _2 === "function" ? _2 : constant$1(+_2), pie) : startAngle; - }; - pie.endAngle = function(_2) { - return arguments.length ? (endAngle = typeof _2 === "function" ? _2 : constant$1(+_2), pie) : endAngle; - }; - pie.padAngle = function(_2) { - return arguments.length ? (padAngle = typeof _2 === "function" ? _2 : constant$1(+_2), pie) : padAngle; - }; - return pie; - } - var curveRadialLinear = curveRadial(curveLinear); - function Radial(curve) { - this._curve = curve; - } - Radial.prototype = { - areaStart: function() { - this._curve.areaStart(); - }, - areaEnd: function() { - this._curve.areaEnd(); - }, - lineStart: function() { - this._curve.lineStart(); - }, - lineEnd: function() { - this._curve.lineEnd(); - }, - point: function(a2, r) { - this._curve.point(r * Math.sin(a2), r * -Math.cos(a2)); - } - }; - function curveRadial(curve) { - function radial2(context) { - return new Radial(curve(context)); - } - radial2._curve = curve; - return radial2; - } - function lineRadial(l) { - var c2 = l.curve; - l.angle = l.x, delete l.x; - l.radius = l.y, delete l.y; - l.curve = function(_2) { - return arguments.length ? c2(curveRadial(_2)) : c2()._curve; - }; - return l; - } - function lineRadial$1() { - return lineRadial(line$1().curve(curveRadialLinear)); - } - function areaRadial() { - var a2 = area().curve(curveRadialLinear), c2 = a2.curve, x02 = a2.lineX0, x12 = a2.lineX1, y02 = a2.lineY0, y12 = a2.lineY1; - a2.angle = a2.x, delete a2.x; - a2.startAngle = a2.x0, delete a2.x0; - a2.endAngle = a2.x1, delete a2.x1; - a2.radius = a2.y, delete a2.y; - a2.innerRadius = a2.y0, delete a2.y0; - a2.outerRadius = a2.y1, delete a2.y1; - a2.lineStartAngle = function() { - return lineRadial(x02()); - }, delete a2.lineX0; - a2.lineEndAngle = function() { - return lineRadial(x12()); - }, delete a2.lineX1; - a2.lineInnerRadius = function() { - return lineRadial(y02()); - }, delete a2.lineY0; - a2.lineOuterRadius = function() { - return lineRadial(y12()); - }, delete a2.lineY1; - a2.curve = function(_2) { - return arguments.length ? c2(curveRadial(_2)) : c2()._curve; - }; - return a2; - } - function pointRadial(x2, y2) { - return [(y2 = +y2) * Math.cos(x2 -= Math.PI / 2), y2 * Math.sin(x2)]; - } - class Bump { - constructor(context, x2) { - this._context = context; - this._x = x2; - } - areaStart() { - this._line = 0; - } - areaEnd() { - this._line = NaN; - } - lineStart() { - this._point = 0; - } - lineEnd() { - if (this._line || this._line !== 0 && this._point === 1) - this._context.closePath(); - this._line = 1 - this._line; - } - point(x2, y2) { - x2 = +x2, y2 = +y2; - switch (this._point) { - case 0: { - this._point = 1; - if (this._line) - this._context.lineTo(x2, y2); - else - this._context.moveTo(x2, y2); - break; - } - case 1: - this._point = 2; - default: { - if (this._x) - this._context.bezierCurveTo(this._x0 = (this._x0 + x2) / 2, this._y0, this._x0, y2, x2, y2); - else - this._context.bezierCurveTo(this._x0, this._y0 = (this._y0 + y2) / 2, x2, this._y0, x2, y2); - break; - } - } - this._x0 = x2, this._y0 = y2; - } - } - class BumpRadial { - constructor(context) { - this._context = context; - } - lineStart() { - this._point = 0; - } - lineEnd() { - } - point(x2, y2) { - x2 = +x2, y2 = +y2; - if (this._point++ === 0) { - this._x0 = x2, this._y0 = y2; - } else { - const p02 = pointRadial(this._x0, this._y0); - const p1 = pointRadial(this._x0, this._y0 = (this._y0 + y2) / 2); - const p2 = pointRadial(x2, this._y0); - const p3 = pointRadial(x2, y2); - this._context.moveTo(...p02); - this._context.bezierCurveTo(...p1, ...p2, ...p3); - } - } - } - function bumpX(context) { - return new Bump(context, true); - } - function bumpY(context) { - return new Bump(context, false); - } - function bumpRadial(context) { - return new BumpRadial(context); - } - function linkSource(d) { - return d.source; - } - function linkTarget(d) { - return d.target; - } - function link(curve) { - let source = linkSource; - let target = linkTarget; - let x2 = x$1; - let y$12 = y; - let context = null; - let output = null; - function link2() { - let buffer2; - const argv = slice$1.call(arguments); - const s2 = source.apply(this, argv); - const t = target.apply(this, argv); - if (context == null) - output = curve(buffer2 = path()); - output.lineStart(); - argv[0] = s2, output.point(+x2.apply(this, argv), +y$12.apply(this, argv)); - argv[0] = t, output.point(+x2.apply(this, argv), +y$12.apply(this, argv)); - output.lineEnd(); - if (buffer2) - return output = null, buffer2 + "" || null; - } - link2.source = function(_2) { - return arguments.length ? (source = _2, link2) : source; - }; - link2.target = function(_2) { - return arguments.length ? (target = _2, link2) : target; - }; - link2.x = function(_2) { - return arguments.length ? (x2 = typeof _2 === "function" ? _2 : constant$1(+_2), link2) : x2; - }; - link2.y = function(_2) { - return arguments.length ? (y$12 = typeof _2 === "function" ? _2 : constant$1(+_2), link2) : y$12; - }; - link2.context = function(_2) { - return arguments.length ? (_2 == null ? context = output = null : output = curve(context = _2), link2) : context; - }; - return link2; - } - function linkHorizontal() { - return link(bumpX); - } - function linkVertical() { - return link(bumpY); - } - function linkRadial() { - const l = link(bumpRadial); - l.angle = l.x, delete l.x; - l.radius = l.y, delete l.y; - return l; - } - const sqrt3$2 = sqrt(3); - const asterisk = { - draw(context, size) { - const r = sqrt(size + min(size / 28, 0.75)) * 0.59436; - const t = r / 2; - const u2 = t * sqrt3$2; - context.moveTo(0, r); - context.lineTo(0, -r); - context.moveTo(-u2, -t); - context.lineTo(u2, t); - context.moveTo(-u2, t); - context.lineTo(u2, -t); - } - }; - const circle$2 = { - draw(context, size) { - const r = sqrt(size / pi); - context.moveTo(r, 0); - context.arc(0, 0, r, 0, tau); - } - }; - const cross$1 = { - draw(context, size) { - const r = sqrt(size / 5) / 2; - context.moveTo(-3 * r, -r); - context.lineTo(-r, -r); - context.lineTo(-r, -3 * r); - context.lineTo(r, -3 * r); - context.lineTo(r, -r); - context.lineTo(3 * r, -r); - context.lineTo(3 * r, r); - context.lineTo(r, r); - context.lineTo(r, 3 * r); - context.lineTo(-r, 3 * r); - context.lineTo(-r, r); - context.lineTo(-3 * r, r); - context.closePath(); - } - }; - const tan30 = sqrt(1 / 3); - const tan30_2 = tan30 * 2; - const diamond = { - draw(context, size) { - const y2 = sqrt(size / tan30_2); - const x2 = y2 * tan30; - context.moveTo(0, -y2); - context.lineTo(x2, 0); - context.lineTo(0, y2); - context.lineTo(-x2, 0); - context.closePath(); - } - }; - const diamond2 = { - draw(context, size) { - const r = sqrt(size) * 0.62625; - context.moveTo(0, -r); - context.lineTo(r, 0); - context.lineTo(0, r); - context.lineTo(-r, 0); - context.closePath(); - } - }; - const plus = { - draw(context, size) { - const r = sqrt(size - min(size / 7, 2)) * 0.87559; - context.moveTo(-r, 0); - context.lineTo(r, 0); - context.moveTo(0, r); - context.lineTo(0, -r); - } - }; - const square = { - draw(context, size) { - const w2 = sqrt(size); - const x2 = -w2 / 2; - context.rect(x2, x2, w2, w2); - } - }; - const square2 = { - draw(context, size) { - const r = sqrt(size) * 0.4431; - context.moveTo(r, r); - context.lineTo(r, -r); - context.lineTo(-r, -r); - context.lineTo(-r, r); - context.closePath(); - } - }; - const ka = 0.8908130915292852; - const kr = sin(pi / 10) / sin(7 * pi / 10); - const kx = sin(tau / 10) * kr; - const ky = -cos(tau / 10) * kr; - const star = { - draw(context, size) { - const r = sqrt(size * ka); - const x2 = kx * r; - const y2 = ky * r; - context.moveTo(0, -r); - context.lineTo(x2, y2); - for (let i = 1; i < 5; ++i) { - const a2 = tau * i / 5; - const c2 = cos(a2); - const s2 = sin(a2); - context.lineTo(s2 * r, -c2 * r); - context.lineTo(c2 * x2 - s2 * y2, s2 * x2 + c2 * y2); - } - context.closePath(); - } - }; - const sqrt3$1 = sqrt(3); - const triangle = { - draw(context, size) { - const y2 = -sqrt(size / (sqrt3$1 * 3)); - context.moveTo(0, y2 * 2); - context.lineTo(-sqrt3$1 * y2, -y2); - context.lineTo(sqrt3$1 * y2, -y2); - context.closePath(); - } - }; - const sqrt3 = sqrt(3); - const triangle2 = { - draw(context, size) { - const s2 = sqrt(size) * 0.6824; - const t = s2 / 2; - const u2 = s2 * sqrt3 / 2; - context.moveTo(0, -s2); - context.lineTo(u2, t); - context.lineTo(-u2, t); - context.closePath(); - } - }; - const c$1 = -0.5; - const s = sqrt(3) / 2; - const k = 1 / sqrt(12); - const a = (k / 2 + 1) * 3; - const wye = { - draw(context, size) { - const r = sqrt(size / a); - const x02 = r / 2, y02 = r * k; - const x12 = x02, y12 = r * k + r; - const x2 = -x12, y2 = y12; - context.moveTo(x02, y02); - context.lineTo(x12, y12); - context.lineTo(x2, y2); - context.lineTo(c$1 * x02 - s * y02, s * x02 + c$1 * y02); - context.lineTo(c$1 * x12 - s * y12, s * x12 + c$1 * y12); - context.lineTo(c$1 * x2 - s * y2, s * x2 + c$1 * y2); - context.lineTo(c$1 * x02 + s * y02, c$1 * y02 - s * x02); - context.lineTo(c$1 * x12 + s * y12, c$1 * y12 - s * x12); - context.lineTo(c$1 * x2 + s * y2, c$1 * y2 - s * x2); - context.closePath(); - } - }; - const x = { - draw(context, size) { - const r = sqrt(size - min(size / 6, 1.7)) * 0.6189; - context.moveTo(-r, -r); - context.lineTo(r, r); - context.moveTo(-r, r); - context.lineTo(r, -r); - } - }; - const symbolsFill = [ - circle$2, - cross$1, - diamond, - square, - star, - triangle, - wye - ]; - const symbolsStroke = [ - circle$2, - plus, - x, - triangle2, - asterisk, - square2, - diamond2 - ]; - function Symbol$1(type2, size) { - let context = null; - type2 = typeof type2 === "function" ? type2 : constant$1(type2 || circle$2); - size = typeof size === "function" ? size : constant$1(size === void 0 ? 64 : +size); - function symbol() { - let buffer2; - if (!context) - context = buffer2 = path(); - type2.apply(this, arguments).draw(context, +size.apply(this, arguments)); - if (buffer2) - return context = null, buffer2 + "" || null; - } - symbol.type = function(_2) { - return arguments.length ? (type2 = typeof _2 === "function" ? _2 : constant$1(_2), symbol) : type2; - }; - symbol.size = function(_2) { - return arguments.length ? (size = typeof _2 === "function" ? _2 : constant$1(+_2), symbol) : size; - }; - symbol.context = function(_2) { - return arguments.length ? (context = _2 == null ? null : _2, symbol) : context; - }; - return symbol; - } - function noop() { - } - function point$4(that, x2, y2) { - that._context.bezierCurveTo( - (2 * that._x0 + that._x1) / 3, - (2 * that._y0 + that._y1) / 3, - (that._x0 + 2 * that._x1) / 3, - (that._y0 + 2 * that._y1) / 3, - (that._x0 + 4 * that._x1 + x2) / 6, - (that._y0 + 4 * that._y1 + y2) / 6 - ); - } - function Basis(context) { - this._context = context; - } - Basis.prototype = { - areaStart: function() { - this._line = 0; - }, - areaEnd: function() { - this._line = NaN; - }, - lineStart: function() { - this._x0 = this._x1 = this._y0 = this._y1 = NaN; - this._point = 0; - }, - lineEnd: function() { - switch (this._point) { - case 3: - point$4(this, this._x1, this._y1); - case 2: - this._context.lineTo(this._x1, this._y1); - break; - } - if (this._line || this._line !== 0 && this._point === 1) - this._context.closePath(); - this._line = 1 - this._line; - }, - point: function(x2, y2) { - x2 = +x2, y2 = +y2; - switch (this._point) { - case 0: - this._point = 1; - this._line ? this._context.lineTo(x2, y2) : this._context.moveTo(x2, y2); - break; - case 1: - this._point = 2; - break; - case 2: - this._point = 3; - this._context.lineTo((5 * this._x0 + this._x1) / 6, (5 * this._y0 + this._y1) / 6); - default: - point$4(this, x2, y2); - break; - } - this._x0 = this._x1, this._x1 = x2; - this._y0 = this._y1, this._y1 = y2; - } - }; - function curveBasis(context) { - return new Basis(context); - } - function BasisClosed(context) { - this._context = context; - } - BasisClosed.prototype = { - areaStart: noop, - areaEnd: noop, - lineStart: function() { - this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = NaN; - this._point = 0; - }, - lineEnd: function() { - switch (this._point) { - case 1: { - this._context.moveTo(this._x2, this._y2); - this._context.closePath(); - break; - } - case 2: { - this._context.moveTo((this._x2 + 2 * this._x3) / 3, (this._y2 + 2 * this._y3) / 3); - this._context.lineTo((this._x3 + 2 * this._x2) / 3, (this._y3 + 2 * this._y2) / 3); - this._context.closePath(); - break; - } - case 3: { - this.point(this._x2, this._y2); - this.point(this._x3, this._y3); - this.point(this._x4, this._y4); - break; - } - } - }, - point: function(x2, y2) { - x2 = +x2, y2 = +y2; - switch (this._point) { - case 0: - this._point = 1; - this._x2 = x2, this._y2 = y2; - break; - case 1: - this._point = 2; - this._x3 = x2, this._y3 = y2; - break; - case 2: - this._point = 3; - this._x4 = x2, this._y4 = y2; - this._context.moveTo((this._x0 + 4 * this._x1 + x2) / 6, (this._y0 + 4 * this._y1 + y2) / 6); - break; - default: - point$4(this, x2, y2); - break; - } - this._x0 = this._x1, this._x1 = x2; - this._y0 = this._y1, this._y1 = y2; - } - }; - function curveBasisClosed(context) { - return new BasisClosed(context); - } - function BasisOpen(context) { - this._context = context; - } - BasisOpen.prototype = { - areaStart: function() { - this._line = 0; - }, - areaEnd: function() { - this._line = NaN; - }, - lineStart: function() { - this._x0 = this._x1 = this._y0 = this._y1 = NaN; - this._point = 0; - }, - lineEnd: function() { - if (this._line || this._line !== 0 && this._point === 3) - this._context.closePath(); - this._line = 1 - this._line; - }, - point: function(x2, y2) { - x2 = +x2, y2 = +y2; - switch (this._point) { - case 0: - this._point = 1; - break; - case 1: - this._point = 2; - break; - case 2: - this._point = 3; - var x02 = (this._x0 + 4 * this._x1 + x2) / 6, y02 = (this._y0 + 4 * this._y1 + y2) / 6; - this._line ? this._context.lineTo(x02, y02) : this._context.moveTo(x02, y02); - break; - case 3: - this._point = 4; - default: - point$4(this, x2, y2); - break; - } - this._x0 = this._x1, this._x1 = x2; - this._y0 = this._y1, this._y1 = y2; - } - }; - function curveBasisOpen(context) { - return new BasisOpen(context); - } - function Bundle(context, beta2) { - this._basis = new Basis(context); - this._beta = beta2; - } - Bundle.prototype = { - lineStart: function() { - this._x = []; - this._y = []; - this._basis.lineStart(); - }, - lineEnd: function() { - var x2 = this._x, y2 = this._y, j = x2.length - 1; - if (j > 0) { - var x02 = x2[0], y02 = y2[0], dx = x2[j] - x02, dy = y2[j] - y02, i = -1, t; - while (++i <= j) { - t = i / j; - this._basis.point( - this._beta * x2[i] + (1 - this._beta) * (x02 + t * dx), - this._beta * y2[i] + (1 - this._beta) * (y02 + t * dy) - ); - } - } - this._x = this._y = null; - this._basis.lineEnd(); - }, - point: function(x2, y2) { - this._x.push(+x2); - this._y.push(+y2); - } - }; - const bundle = function custom(beta2) { - function bundle2(context) { - return beta2 === 1 ? new Basis(context) : new Bundle(context, beta2); - } - bundle2.beta = function(beta3) { - return custom(+beta3); - }; - return bundle2; - }(0.85); - function point$3(that, x2, y2) { - that._context.bezierCurveTo( - that._x1 + that._k * (that._x2 - that._x0), - that._y1 + that._k * (that._y2 - that._y0), - that._x2 + that._k * (that._x1 - x2), - that._y2 + that._k * (that._y1 - y2), - that._x2, - that._y2 - ); - } - function Cardinal(context, tension) { - this._context = context; - this._k = (1 - tension) / 6; - } - Cardinal.prototype = { - areaStart: function() { - this._line = 0; - }, - areaEnd: function() { - this._line = NaN; - }, - lineStart: function() { - this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN; - this._point = 0; - }, - lineEnd: function() { - switch (this._point) { - case 2: - this._context.lineTo(this._x2, this._y2); - break; - case 3: - point$3(this, this._x1, this._y1); - break; - } - if (this._line || this._line !== 0 && this._point === 1) - this._context.closePath(); - this._line = 1 - this._line; - }, - point: function(x2, y2) { - x2 = +x2, y2 = +y2; - switch (this._point) { - case 0: - this._point = 1; - this._line ? this._context.lineTo(x2, y2) : this._context.moveTo(x2, y2); - break; - case 1: - this._point = 2; - this._x1 = x2, this._y1 = y2; - break; - case 2: - this._point = 3; - default: - point$3(this, x2, y2); - break; - } - this._x0 = this._x1, this._x1 = this._x2, this._x2 = x2; - this._y0 = this._y1, this._y1 = this._y2, this._y2 = y2; - } - }; - const cardinal = function custom(tension) { - function cardinal2(context) { - return new Cardinal(context, tension); - } - cardinal2.tension = function(tension2) { - return custom(+tension2); - }; - return cardinal2; - }(0); - function CardinalClosed(context, tension) { - this._context = context; - this._k = (1 - tension) / 6; - } - CardinalClosed.prototype = { - areaStart: noop, - areaEnd: noop, - lineStart: function() { - this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._x5 = this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = this._y5 = NaN; - this._point = 0; - }, - lineEnd: function() { - switch (this._point) { - case 1: { - this._context.moveTo(this._x3, this._y3); - this._context.closePath(); - break; - } - case 2: { - this._context.lineTo(this._x3, this._y3); - this._context.closePath(); - break; - } - case 3: { - this.point(this._x3, this._y3); - this.point(this._x4, this._y4); - this.point(this._x5, this._y5); - break; - } - } - }, - point: function(x2, y2) { - x2 = +x2, y2 = +y2; - switch (this._point) { - case 0: - this._point = 1; - this._x3 = x2, this._y3 = y2; - break; - case 1: - this._point = 2; - this._context.moveTo(this._x4 = x2, this._y4 = y2); - break; - case 2: - this._point = 3; - this._x5 = x2, this._y5 = y2; - break; - default: - point$3(this, x2, y2); - break; - } - this._x0 = this._x1, this._x1 = this._x2, this._x2 = x2; - this._y0 = this._y1, this._y1 = this._y2, this._y2 = y2; - } - }; - const cardinalClosed = function custom(tension) { - function cardinal2(context) { - return new CardinalClosed(context, tension); - } - cardinal2.tension = function(tension2) { - return custom(+tension2); - }; - return cardinal2; - }(0); - function CardinalOpen(context, tension) { - this._context = context; - this._k = (1 - tension) / 6; - } - CardinalOpen.prototype = { - areaStart: function() { - this._line = 0; - }, - areaEnd: function() { - this._line = NaN; - }, - lineStart: function() { - this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN; - this._point = 0; - }, - lineEnd: function() { - if (this._line || this._line !== 0 && this._point === 3) - this._context.closePath(); - this._line = 1 - this._line; - }, - point: function(x2, y2) { - x2 = +x2, y2 = +y2; - switch (this._point) { - case 0: - this._point = 1; - break; - case 1: - this._point = 2; - break; - case 2: - this._point = 3; - this._line ? this._context.lineTo(this._x2, this._y2) : this._context.moveTo(this._x2, this._y2); - break; - case 3: - this._point = 4; - default: - point$3(this, x2, y2); - break; - } - this._x0 = this._x1, this._x1 = this._x2, this._x2 = x2; - this._y0 = this._y1, this._y1 = this._y2, this._y2 = y2; - } - }; - const cardinalOpen = function custom(tension) { - function cardinal2(context) { - return new CardinalOpen(context, tension); - } - cardinal2.tension = function(tension2) { - return custom(+tension2); - }; - return cardinal2; - }(0); - function point$2(that, x2, y2) { - var x12 = that._x1, y12 = that._y1, x22 = that._x2, y22 = that._y2; - if (that._l01_a > epsilon) { - var a2 = 2 * that._l01_2a + 3 * that._l01_a * that._l12_a + that._l12_2a, n = 3 * that._l01_a * (that._l01_a + that._l12_a); - x12 = (x12 * a2 - that._x0 * that._l12_2a + that._x2 * that._l01_2a) / n; - y12 = (y12 * a2 - that._y0 * that._l12_2a + that._y2 * that._l01_2a) / n; - } - if (that._l23_a > epsilon) { - var b = 2 * that._l23_2a + 3 * that._l23_a * that._l12_a + that._l12_2a, m2 = 3 * that._l23_a * (that._l23_a + that._l12_a); - x22 = (x22 * b + that._x1 * that._l23_2a - x2 * that._l12_2a) / m2; - y22 = (y22 * b + that._y1 * that._l23_2a - y2 * that._l12_2a) / m2; - } - that._context.bezierCurveTo(x12, y12, x22, y22, that._x2, that._y2); - } - function CatmullRom(context, alpha) { - this._context = context; - this._alpha = alpha; - } - CatmullRom.prototype = { - areaStart: function() { - this._line = 0; - }, - areaEnd: function() { - this._line = NaN; - }, - lineStart: function() { - this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN; - this._l01_a = this._l12_a = this._l23_a = this._l01_2a = this._l12_2a = this._l23_2a = this._point = 0; - }, - lineEnd: function() { - switch (this._point) { - case 2: - this._context.lineTo(this._x2, this._y2); - break; - case 3: - this.point(this._x2, this._y2); - break; - } - if (this._line || this._line !== 0 && this._point === 1) - this._context.closePath(); - this._line = 1 - this._line; - }, - point: function(x2, y2) { - x2 = +x2, y2 = +y2; - if (this._point) { - var x23 = this._x2 - x2, y23 = this._y2 - y2; - this._l23_a = Math.sqrt(this._l23_2a = Math.pow(x23 * x23 + y23 * y23, this._alpha)); - } - switch (this._point) { - case 0: - this._point = 1; - this._line ? this._context.lineTo(x2, y2) : this._context.moveTo(x2, y2); - break; - case 1: - this._point = 2; - break; - case 2: - this._point = 3; - default: - point$2(this, x2, y2); - break; - } - this._l01_a = this._l12_a, this._l12_a = this._l23_a; - this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a; - this._x0 = this._x1, this._x1 = this._x2, this._x2 = x2; - this._y0 = this._y1, this._y1 = this._y2, this._y2 = y2; - } - }; - const catmullRom = function custom(alpha) { - function catmullRom2(context) { - return alpha ? new CatmullRom(context, alpha) : new Cardinal(context, 0); - } - catmullRom2.alpha = function(alpha2) { - return custom(+alpha2); - }; - return catmullRom2; - }(0.5); - function CatmullRomClosed(context, alpha) { - this._context = context; - this._alpha = alpha; - } - CatmullRomClosed.prototype = { - areaStart: noop, - areaEnd: noop, - lineStart: function() { - this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._x5 = this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = this._y5 = NaN; - this._l01_a = this._l12_a = this._l23_a = this._l01_2a = this._l12_2a = this._l23_2a = this._point = 0; - }, - lineEnd: function() { - switch (this._point) { - case 1: { - this._context.moveTo(this._x3, this._y3); - this._context.closePath(); - break; - } - case 2: { - this._context.lineTo(this._x3, this._y3); - this._context.closePath(); - break; - } - case 3: { - this.point(this._x3, this._y3); - this.point(this._x4, this._y4); - this.point(this._x5, this._y5); - break; - } - } - }, - point: function(x2, y2) { - x2 = +x2, y2 = +y2; - if (this._point) { - var x23 = this._x2 - x2, y23 = this._y2 - y2; - this._l23_a = Math.sqrt(this._l23_2a = Math.pow(x23 * x23 + y23 * y23, this._alpha)); - } - switch (this._point) { - case 0: - this._point = 1; - this._x3 = x2, this._y3 = y2; - break; - case 1: - this._point = 2; - this._context.moveTo(this._x4 = x2, this._y4 = y2); - break; - case 2: - this._point = 3; - this._x5 = x2, this._y5 = y2; - break; - default: - point$2(this, x2, y2); - break; - } - this._l01_a = this._l12_a, this._l12_a = this._l23_a; - this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a; - this._x0 = this._x1, this._x1 = this._x2, this._x2 = x2; - this._y0 = this._y1, this._y1 = this._y2, this._y2 = y2; - } - }; - const catmullRomClosed = function custom(alpha) { - function catmullRom2(context) { - return alpha ? new CatmullRomClosed(context, alpha) : new CardinalClosed(context, 0); - } - catmullRom2.alpha = function(alpha2) { - return custom(+alpha2); - }; - return catmullRom2; - }(0.5); - function CatmullRomOpen(context, alpha) { - this._context = context; - this._alpha = alpha; - } - CatmullRomOpen.prototype = { - areaStart: function() { - this._line = 0; - }, - areaEnd: function() { - this._line = NaN; - }, - lineStart: function() { - this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN; - this._l01_a = this._l12_a = this._l23_a = this._l01_2a = this._l12_2a = this._l23_2a = this._point = 0; - }, - lineEnd: function() { - if (this._line || this._line !== 0 && this._point === 3) - this._context.closePath(); - this._line = 1 - this._line; - }, - point: function(x2, y2) { - x2 = +x2, y2 = +y2; - if (this._point) { - var x23 = this._x2 - x2, y23 = this._y2 - y2; - this._l23_a = Math.sqrt(this._l23_2a = Math.pow(x23 * x23 + y23 * y23, this._alpha)); - } - switch (this._point) { - case 0: - this._point = 1; - break; - case 1: - this._point = 2; - break; - case 2: - this._point = 3; - this._line ? this._context.lineTo(this._x2, this._y2) : this._context.moveTo(this._x2, this._y2); - break; - case 3: - this._point = 4; - default: - point$2(this, x2, y2); - break; - } - this._l01_a = this._l12_a, this._l12_a = this._l23_a; - this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a; - this._x0 = this._x1, this._x1 = this._x2, this._x2 = x2; - this._y0 = this._y1, this._y1 = this._y2, this._y2 = y2; - } - }; - const catmullRomOpen = function custom(alpha) { - function catmullRom2(context) { - return alpha ? new CatmullRomOpen(context, alpha) : new CardinalOpen(context, 0); - } - catmullRom2.alpha = function(alpha2) { - return custom(+alpha2); - }; - return catmullRom2; - }(0.5); - function LinearClosed(context) { - this._context = context; - } - LinearClosed.prototype = { - areaStart: noop, - areaEnd: noop, - lineStart: function() { - this._point = 0; - }, - lineEnd: function() { - if (this._point) - this._context.closePath(); - }, - point: function(x2, y2) { - x2 = +x2, y2 = +y2; - if (this._point) - this._context.lineTo(x2, y2); - else - this._point = 1, this._context.moveTo(x2, y2); - } - }; - function curveLinearClosed(context) { - return new LinearClosed(context); - } - function sign(x2) { - return x2 < 0 ? -1 : 1; - } - function slope3(that, x2, y2) { - var h0 = that._x1 - that._x0, h1 = x2 - that._x1, s0 = (that._y1 - that._y0) / (h0 || h1 < 0 && -0), s1 = (y2 - that._y1) / (h1 || h0 < 0 && -0), p = (s0 * h1 + s1 * h0) / (h0 + h1); - return (sign(s0) + sign(s1)) * Math.min(Math.abs(s0), Math.abs(s1), 0.5 * Math.abs(p)) || 0; - } - function slope2(that, t) { - var h = that._x1 - that._x0; - return h ? (3 * (that._y1 - that._y0) / h - t) / 2 : t; - } - function point$1(that, t02, t12) { - var x02 = that._x0, y02 = that._y0, x12 = that._x1, y12 = that._y1, dx = (x12 - x02) / 3; - that._context.bezierCurveTo(x02 + dx, y02 + dx * t02, x12 - dx, y12 - dx * t12, x12, y12); - } - function MonotoneX(context) { - this._context = context; - } - MonotoneX.prototype = { - areaStart: function() { - this._line = 0; - }, - areaEnd: function() { - this._line = NaN; - }, - lineStart: function() { - this._x0 = this._x1 = this._y0 = this._y1 = this._t0 = NaN; - this._point = 0; - }, - lineEnd: function() { - switch (this._point) { - case 2: - this._context.lineTo(this._x1, this._y1); - break; - case 3: - point$1(this, this._t0, slope2(this, this._t0)); - break; - } - if (this._line || this._line !== 0 && this._point === 1) - this._context.closePath(); - this._line = 1 - this._line; - }, - point: function(x2, y2) { - var t12 = NaN; - x2 = +x2, y2 = +y2; - if (x2 === this._x1 && y2 === this._y1) - return; - switch (this._point) { - case 0: - this._point = 1; - this._line ? this._context.lineTo(x2, y2) : this._context.moveTo(x2, y2); - break; - case 1: - this._point = 2; - break; - case 2: - this._point = 3; - point$1(this, slope2(this, t12 = slope3(this, x2, y2)), t12); - break; - default: - point$1(this, this._t0, t12 = slope3(this, x2, y2)); - break; - } - this._x0 = this._x1, this._x1 = x2; - this._y0 = this._y1, this._y1 = y2; - this._t0 = t12; - } - }; - function MonotoneY(context) { - this._context = new ReflectContext(context); - } - (MonotoneY.prototype = Object.create(MonotoneX.prototype)).point = function(x2, y2) { - MonotoneX.prototype.point.call(this, y2, x2); - }; - function ReflectContext(context) { - this._context = context; - } - ReflectContext.prototype = { - moveTo: function(x2, y2) { - this._context.moveTo(y2, x2); - }, - closePath: function() { - this._context.closePath(); - }, - lineTo: function(x2, y2) { - this._context.lineTo(y2, x2); - }, - bezierCurveTo: function(x12, y12, x2, y2, x3, y3) { - this._context.bezierCurveTo(y12, x12, y2, x2, y3, x3); - } - }; - function monotoneX(context) { - return new MonotoneX(context); - } - function monotoneY(context) { - return new MonotoneY(context); - } - function Natural(context) { - this._context = context; - } - Natural.prototype = { - areaStart: function() { - this._line = 0; - }, - areaEnd: function() { - this._line = NaN; - }, - lineStart: function() { - this._x = []; - this._y = []; - }, - lineEnd: function() { - var x2 = this._x, y2 = this._y, n = x2.length; - if (n) { - this._line ? this._context.lineTo(x2[0], y2[0]) : this._context.moveTo(x2[0], y2[0]); - if (n === 2) { - this._context.lineTo(x2[1], y2[1]); - } else { - var px = controlPoints(x2), py = controlPoints(y2); - for (var i0 = 0, i1 = 1; i1 < n; ++i0, ++i1) { - this._context.bezierCurveTo(px[0][i0], py[0][i0], px[1][i0], py[1][i0], x2[i1], y2[i1]); - } - } - } - if (this._line || this._line !== 0 && n === 1) - this._context.closePath(); - this._line = 1 - this._line; - this._x = this._y = null; - }, - point: function(x2, y2) { - this._x.push(+x2); - this._y.push(+y2); - } - }; - function controlPoints(x2) { - var i, n = x2.length - 1, m2, a2 = new Array(n), b = new Array(n), r = new Array(n); - a2[0] = 0, b[0] = 2, r[0] = x2[0] + 2 * x2[1]; - for (i = 1; i < n - 1; ++i) - a2[i] = 1, b[i] = 4, r[i] = 4 * x2[i] + 2 * x2[i + 1]; - a2[n - 1] = 2, b[n - 1] = 7, r[n - 1] = 8 * x2[n - 1] + x2[n]; - for (i = 1; i < n; ++i) - m2 = a2[i] / b[i - 1], b[i] -= m2, r[i] -= m2 * r[i - 1]; - a2[n - 1] = r[n - 1] / b[n - 1]; - for (i = n - 2; i >= 0; --i) - a2[i] = (r[i] - a2[i + 1]) / b[i]; - b[n - 1] = (x2[n] + a2[n - 1]) / 2; - for (i = 0; i < n - 1; ++i) - b[i] = 2 * x2[i + 1] - a2[i + 1]; - return [a2, b]; - } - function curveNatural(context) { - return new Natural(context); - } - function Step(context, t) { - this._context = context; - this._t = t; - } - Step.prototype = { - areaStart: function() { - this._line = 0; - }, - areaEnd: function() { - this._line = NaN; - }, - lineStart: function() { - this._x = this._y = NaN; - this._point = 0; - }, - lineEnd: function() { - if (0 < this._t && this._t < 1 && this._point === 2) - this._context.lineTo(this._x, this._y); - if (this._line || this._line !== 0 && this._point === 1) - this._context.closePath(); - if (this._line >= 0) - this._t = 1 - this._t, this._line = 1 - this._line; - }, - point: function(x2, y2) { - x2 = +x2, y2 = +y2; - switch (this._point) { - case 0: - this._point = 1; - this._line ? this._context.lineTo(x2, y2) : this._context.moveTo(x2, y2); - break; - case 1: - this._point = 2; - default: { - if (this._t <= 0) { - this._context.lineTo(this._x, y2); - this._context.lineTo(x2, y2); - } else { - var x12 = this._x * (1 - this._t) + x2 * this._t; - this._context.lineTo(x12, this._y); - this._context.lineTo(x12, y2); - } - break; - } - } - this._x = x2, this._y = y2; - } - }; - function curveStep(context) { - return new Step(context, 0.5); - } - function stepBefore(context) { - return new Step(context, 0); - } - function stepAfter(context) { - return new Step(context, 1); - } - function none$1(series, order) { - if (!((n = series.length) > 1)) - return; - for (var i = 1, j, s0, s1 = series[order[0]], n, m2 = s1.length; i < n; ++i) { - s0 = s1, s1 = series[order[i]]; - for (j = 0; j < m2; ++j) { - s1[j][1] += s1[j][0] = isNaN(s0[j][1]) ? s0[j][0] : s0[j][1]; - } - } - } - function none(series) { - var n = series.length, o = new Array(n); - while (--n >= 0) - o[n] = n; - return o; - } - function stackValue(d, key) { - return d[key]; - } - function stackSeries(key) { - const series = []; - series.key = key; - return series; - } - function stack() { - var keys = constant$1([]), order = none, offset = none$1, value = stackValue; - function stack2(data) { - var sz = Array.from(keys.apply(this, arguments), stackSeries), i, n = sz.length, j = -1, oz; - for (const d of data) { - for (i = 0, ++j; i < n; ++i) { - (sz[i][j] = [0, +value(d, sz[i].key, j, data)]).data = d; - } - } - for (i = 0, oz = array(order(sz)); i < n; ++i) { - sz[oz[i]].index = i; - } - offset(sz, oz); - return sz; - } - stack2.keys = function(_2) { - return arguments.length ? (keys = typeof _2 === "function" ? _2 : constant$1(Array.from(_2)), stack2) : keys; - }; - stack2.value = function(_2) { - return arguments.length ? (value = typeof _2 === "function" ? _2 : constant$1(+_2), stack2) : value; - }; - stack2.order = function(_2) { - return arguments.length ? (order = _2 == null ? none : typeof _2 === "function" ? _2 : constant$1(Array.from(_2)), stack2) : order; - }; - stack2.offset = function(_2) { - return arguments.length ? (offset = _2 == null ? none$1 : _2, stack2) : offset; - }; - return stack2; - } - function expand(series, order) { - if (!((n = series.length) > 0)) - return; - for (var i, n, j = 0, m2 = series[0].length, y2; j < m2; ++j) { - for (y2 = i = 0; i < n; ++i) - y2 += series[i][j][1] || 0; - if (y2) - for (i = 0; i < n; ++i) - series[i][j][1] /= y2; - } - none$1(series, order); - } - function diverging(series, order) { - if (!((n = series.length) > 0)) - return; - for (var i, j = 0, d, dy, yp, yn, n, m2 = series[order[0]].length; j < m2; ++j) { - for (yp = yn = 0, i = 0; i < n; ++i) { - if ((dy = (d = series[order[i]][j])[1] - d[0]) > 0) { - d[0] = yp, d[1] = yp += dy; - } else if (dy < 0) { - d[1] = yn, d[0] = yn += dy; - } else { - d[0] = 0, d[1] = dy; - } - } - } - } - function silhouette(series, order) { - if (!((n = series.length) > 0)) - return; - for (var j = 0, s0 = series[order[0]], n, m2 = s0.length; j < m2; ++j) { - for (var i = 0, y2 = 0; i < n; ++i) - y2 += series[i][j][1] || 0; - s0[j][1] += s0[j][0] = -y2 / 2; - } - none$1(series, order); - } - function wiggle(series, order) { - if (!((n = series.length) > 0) || !((m2 = (s0 = series[order[0]]).length) > 0)) - return; - for (var y2 = 0, j = 1, s0, m2, n; j < m2; ++j) { - for (var i = 0, s1 = 0, s2 = 0; i < n; ++i) { - var si = series[order[i]], sij0 = si[j][1] || 0, sij1 = si[j - 1][1] || 0, s3 = (sij0 - sij1) / 2; - for (var k2 = 0; k2 < i; ++k2) { - var sk = series[order[k2]], skj0 = sk[j][1] || 0, skj1 = sk[j - 1][1] || 0; - s3 += skj0 - skj1; - } - s1 += sij0, s2 += s3 * sij0; - } - s0[j - 1][1] += s0[j - 1][0] = y2; - if (s1) - y2 -= s2 / s1; - } - s0[j - 1][1] += s0[j - 1][0] = y2; - none$1(series, order); - } - function appearance(series) { - var peaks = series.map(peak); - return none(series).sort(function(a2, b) { - return peaks[a2] - peaks[b]; - }); - } - function peak(series) { - var i = -1, j = 0, n = series.length, vi, vj = -Infinity; - while (++i < n) - if ((vi = +series[i][1]) > vj) - vj = vi, j = i; - return j; - } - function ascending(series) { - var sums = series.map(sum); - return none(series).sort(function(a2, b) { - return sums[a2] - sums[b]; - }); - } - function sum(series) { - var s2 = 0, i = -1, n = series.length, v; - while (++i < n) - if (v = +series[i][1]) - s2 += v; - return s2; - } - function descending(series) { - return ascending(series).reverse(); - } - function insideOut(series) { - var n = series.length, i, j, sums = series.map(sum), order = appearance(series), top2 = 0, bottom2 = 0, tops = [], bottoms = []; - for (i = 0; i < n; ++i) { - j = order[i]; - if (top2 < bottom2) { - top2 += sums[j]; - tops.push(j); - } else { - bottom2 += sums[j]; - bottoms.push(j); - } - } - return bottoms.reverse().concat(tops); - } - function reverse(series) { - return none(series).reverse(); - } - const constant = (x2) => () => x2; - function ZoomEvent(type2, { - sourceEvent: sourceEvent2, - target, - transform: transform2, - dispatch: dispatch2 - }) { - Object.defineProperties(this, { - type: { value: type2, enumerable: true, configurable: true }, - sourceEvent: { value: sourceEvent2, enumerable: true, configurable: true }, - target: { value: target, enumerable: true, configurable: true }, - transform: { value: transform2, enumerable: true, configurable: true }, - _: { value: dispatch2 } - }); - } - function Transform(k2, x2, y2) { - this.k = k2; - this.x = x2; - this.y = y2; - } - Transform.prototype = { - constructor: Transform, - scale: function(k2) { - return k2 === 1 ? this : new Transform(this.k * k2, this.x, this.y); - }, - translate: function(x2, y2) { - return x2 === 0 & y2 === 0 ? this : new Transform(this.k, this.x + this.k * x2, this.y + this.k * y2); - }, - apply: function(point2) { - return [point2[0] * this.k + this.x, point2[1] * this.k + this.y]; - }, - applyX: function(x2) { - return x2 * this.k + this.x; - }, - applyY: function(y2) { - return y2 * this.k + this.y; - }, - invert: function(location2) { - return [(location2[0] - this.x) / this.k, (location2[1] - this.y) / this.k]; - }, - invertX: function(x2) { - return (x2 - this.x) / this.k; - }, - invertY: function(y2) { - return (y2 - this.y) / this.k; - }, - rescaleX: function(x2) { - return x2.copy().domain(x2.range().map(this.invertX, this).map(x2.invert, x2)); - }, - rescaleY: function(y2) { - return y2.copy().domain(y2.range().map(this.invertY, this).map(y2.invert, y2)); - }, - toString: function() { - return "translate(" + this.x + "," + this.y + ") scale(" + this.k + ")"; - } - }; - var identity = new Transform(1, 0, 0); - transform.prototype = Transform.prototype; - function transform(node2) { - while (!node2.__zoom) - if (!(node2 = node2.parentNode)) - return identity; - return node2.__zoom; - } - function nopropagation(event) { - event.stopImmediatePropagation(); - } - function noevent(event) { - event.preventDefault(); - event.stopImmediatePropagation(); - } - function defaultFilter(event) { - return (!event.ctrlKey || event.type === "wheel") && !event.button; - } - function defaultExtent() { - var e = this; - if (e instanceof SVGElement) { - e = e.ownerSVGElement || e; - if (e.hasAttribute("viewBox")) { - e = e.viewBox.baseVal; - return [[e.x, e.y], [e.x + e.width, e.y + e.height]]; - } - return [[0, 0], [e.width.baseVal.value, e.height.baseVal.value]]; - } - return [[0, 0], [e.clientWidth, e.clientHeight]]; - } - function defaultTransform() { - return this.__zoom || identity; - } - function defaultWheelDelta(event) { - return -event.deltaY * (event.deltaMode === 1 ? 0.05 : event.deltaMode ? 1 : 2e-3) * (event.ctrlKey ? 10 : 1); - } - function defaultTouchable() { - return navigator.maxTouchPoints || "ontouchstart" in this; - } - function defaultConstrain(transform2, extent2, translateExtent) { - var dx0 = transform2.invertX(extent2[0][0]) - translateExtent[0][0], dx1 = transform2.invertX(extent2[1][0]) - translateExtent[1][0], dy0 = transform2.invertY(extent2[0][1]) - translateExtent[0][1], dy1 = transform2.invertY(extent2[1][1]) - translateExtent[1][1]; - return transform2.translate( - dx1 > dx0 ? (dx0 + dx1) / 2 : Math.min(0, dx0) || Math.max(0, dx1), - dy1 > dy0 ? (dy0 + dy1) / 2 : Math.min(0, dy0) || Math.max(0, dy1) - ); - } - function zoom() { - var filter2 = defaultFilter, extent2 = defaultExtent, constrain = defaultConstrain, wheelDelta = defaultWheelDelta, touchable = defaultTouchable, scaleExtent = [0, Infinity], translateExtent = [[-Infinity, -Infinity], [Infinity, Infinity]], duration = 250, interpolate2 = interpolateZoom, listeners = dispatch("start", "zoom", "end"), touchstarting, touchfirst, touchending, touchDelay = 500, wheelDelay = 150, clickDistance2 = 0, tapDistance = 10; - function zoom2(selection2) { - selection2.property("__zoom", defaultTransform).on("wheel.zoom", wheeled, { passive: false }).on("mousedown.zoom", mousedowned).on("dblclick.zoom", dblclicked).filter(touchable).on("touchstart.zoom", touchstarted).on("touchmove.zoom", touchmoved).on("touchend.zoom touchcancel.zoom", touchended).style("-webkit-tap-highlight-color", "rgba(0,0,0,0)"); - } - zoom2.transform = function(collection, transform2, point2, event) { - var selection2 = collection.selection ? collection.selection() : collection; - selection2.property("__zoom", defaultTransform); - if (collection !== selection2) { - schedule2(collection, transform2, point2, event); - } else { - selection2.interrupt().each(function() { - gesture(this, arguments).event(event).start().zoom(null, typeof transform2 === "function" ? transform2.apply(this, arguments) : transform2).end(); - }); - } - }; - zoom2.scaleBy = function(selection2, k2, p, event) { - zoom2.scaleTo(selection2, function() { - var k0 = this.__zoom.k, k1 = typeof k2 === "function" ? k2.apply(this, arguments) : k2; - return k0 * k1; - }, p, event); - }; - zoom2.scaleTo = function(selection2, k2, p, event) { - zoom2.transform(selection2, function() { - var e = extent2.apply(this, arguments), t02 = this.__zoom, p02 = p == null ? centroid2(e) : typeof p === "function" ? p.apply(this, arguments) : p, p1 = t02.invert(p02), k1 = typeof k2 === "function" ? k2.apply(this, arguments) : k2; - return constrain(translate(scale(t02, k1), p02, p1), e, translateExtent); - }, p, event); - }; - zoom2.translateBy = function(selection2, x2, y2, event) { - zoom2.transform(selection2, function() { - return constrain(this.__zoom.translate( - typeof x2 === "function" ? x2.apply(this, arguments) : x2, - typeof y2 === "function" ? y2.apply(this, arguments) : y2 - ), extent2.apply(this, arguments), translateExtent); - }, null, event); - }; - zoom2.translateTo = function(selection2, x2, y2, p, event) { - zoom2.transform(selection2, function() { - var e = extent2.apply(this, arguments), t = this.__zoom, p02 = p == null ? centroid2(e) : typeof p === "function" ? p.apply(this, arguments) : p; - return constrain(identity.translate(p02[0], p02[1]).scale(t.k).translate( - typeof x2 === "function" ? -x2.apply(this, arguments) : -x2, - typeof y2 === "function" ? -y2.apply(this, arguments) : -y2 - ), e, translateExtent); - }, p, event); - }; - function scale(transform2, k2) { - k2 = Math.max(scaleExtent[0], Math.min(scaleExtent[1], k2)); - return k2 === transform2.k ? transform2 : new Transform(k2, transform2.x, transform2.y); - } - function translate(transform2, p02, p1) { - var x2 = p02[0] - p1[0] * transform2.k, y2 = p02[1] - p1[1] * transform2.k; - return x2 === transform2.x && y2 === transform2.y ? transform2 : new Transform(transform2.k, x2, y2); - } - function centroid2(extent3) { - return [(+extent3[0][0] + +extent3[1][0]) / 2, (+extent3[0][1] + +extent3[1][1]) / 2]; - } - function schedule2(transition2, transform2, point2, event) { - transition2.on("start.zoom", function() { - gesture(this, arguments).event(event).start(); - }).on("interrupt.zoom end.zoom", function() { - gesture(this, arguments).event(event).end(); - }).tween("zoom", function() { - var that = this, args = arguments, g = gesture(that, args).event(event), e = extent2.apply(that, args), p = point2 == null ? centroid2(e) : typeof point2 === "function" ? point2.apply(that, args) : point2, w2 = Math.max(e[1][0] - e[0][0], e[1][1] - e[0][1]), a2 = that.__zoom, b = typeof transform2 === "function" ? transform2.apply(that, args) : transform2, i = interpolate2(a2.invert(p).concat(w2 / a2.k), b.invert(p).concat(w2 / b.k)); - return function(t) { - if (t === 1) - t = b; - else { - var l = i(t), k2 = w2 / l[2]; - t = new Transform(k2, p[0] - l[0] * k2, p[1] - l[1] * k2); - } - g.zoom(null, t); - }; - }); - } - function gesture(that, args, clean) { - return !clean && that.__zooming || new Gesture(that, args); - } - function Gesture(that, args) { - this.that = that; - this.args = args; - this.active = 0; - this.sourceEvent = null; - this.extent = extent2.apply(that, args); - this.taps = 0; - } - Gesture.prototype = { - event: function(event) { - if (event) - this.sourceEvent = event; - return this; - }, - start: function() { - if (++this.active === 1) { - this.that.__zooming = this; - this.emit("start"); - } - return this; - }, - zoom: function(key, transform2) { - if (this.mouse && key !== "mouse") - this.mouse[1] = transform2.invert(this.mouse[0]); - if (this.touch0 && key !== "touch") - this.touch0[1] = transform2.invert(this.touch0[0]); - if (this.touch1 && key !== "touch") - this.touch1[1] = transform2.invert(this.touch1[0]); - this.that.__zoom = transform2; - this.emit("zoom"); - return this; - }, - end: function() { - if (--this.active === 0) { - delete this.that.__zooming; - this.emit("end"); - } - return this; - }, - emit: function(type2) { - var d = select(this.that).datum(); - listeners.call( - type2, - this.that, - new ZoomEvent(type2, { - sourceEvent: this.sourceEvent, - target: zoom2, - type: type2, - transform: this.that.__zoom, - dispatch: listeners - }), - d - ); - } - }; - function wheeled(event, ...args) { - if (!filter2.apply(this, arguments)) - return; - var g = gesture(this, args).event(event), t = this.__zoom, k2 = Math.max(scaleExtent[0], Math.min(scaleExtent[1], t.k * Math.pow(2, wheelDelta.apply(this, arguments)))), p = pointer(event); - if (g.wheel) { - if (g.mouse[0][0] !== p[0] || g.mouse[0][1] !== p[1]) { - g.mouse[1] = t.invert(g.mouse[0] = p); - } - clearTimeout(g.wheel); - } else if (t.k === k2) - return; - else { - g.mouse = [p, t.invert(p)]; - interrupt(this); - g.start(); - } - noevent(event); - g.wheel = setTimeout(wheelidled, wheelDelay); - g.zoom("mouse", constrain(translate(scale(t, k2), g.mouse[0], g.mouse[1]), g.extent, translateExtent)); - function wheelidled() { - g.wheel = null; - g.end(); - } - } - function mousedowned(event, ...args) { - if (touchending || !filter2.apply(this, arguments)) - return; - var currentTarget = event.currentTarget, g = gesture(this, args, true).event(event), v = select(event.view).on("mousemove.zoom", mousemoved, true).on("mouseup.zoom", mouseupped, true), p = pointer(event, currentTarget), x02 = event.clientX, y02 = event.clientY; - dragDisable(event.view); - nopropagation(event); - g.mouse = [p, this.__zoom.invert(p)]; - interrupt(this); - g.start(); - function mousemoved(event2) { - noevent(event2); - if (!g.moved) { - var dx = event2.clientX - x02, dy = event2.clientY - y02; - g.moved = dx * dx + dy * dy > clickDistance2; - } - g.event(event2).zoom("mouse", constrain(translate(g.that.__zoom, g.mouse[0] = pointer(event2, currentTarget), g.mouse[1]), g.extent, translateExtent)); - } - function mouseupped(event2) { - v.on("mousemove.zoom mouseup.zoom", null); - yesdrag(event2.view, g.moved); - noevent(event2); - g.event(event2).end(); - } - } - function dblclicked(event, ...args) { - if (!filter2.apply(this, arguments)) - return; - var t02 = this.__zoom, p02 = pointer(event.changedTouches ? event.changedTouches[0] : event, this), p1 = t02.invert(p02), k1 = t02.k * (event.shiftKey ? 0.5 : 2), t12 = constrain(translate(scale(t02, k1), p02, p1), extent2.apply(this, args), translateExtent); - noevent(event); - if (duration > 0) - select(this).transition().duration(duration).call(schedule2, t12, p02, event); - else - select(this).call(zoom2.transform, t12, p02, event); - } - function touchstarted(event, ...args) { - if (!filter2.apply(this, arguments)) - return; - var touches = event.touches, n = touches.length, g = gesture(this, args, event.changedTouches.length === n).event(event), started, i, t, p; - nopropagation(event); - for (i = 0; i < n; ++i) { - t = touches[i], p = pointer(t, this); - p = [p, this.__zoom.invert(p), t.identifier]; - if (!g.touch0) - g.touch0 = p, started = true, g.taps = 1 + !!touchstarting; - else if (!g.touch1 && g.touch0[2] !== p[2]) - g.touch1 = p, g.taps = 0; - } - if (touchstarting) - touchstarting = clearTimeout(touchstarting); - if (started) { - if (g.taps < 2) - touchfirst = p[0], touchstarting = setTimeout(function() { - touchstarting = null; - }, touchDelay); - interrupt(this); - g.start(); - } - } - function touchmoved(event, ...args) { - if (!this.__zooming) - return; - var g = gesture(this, args).event(event), touches = event.changedTouches, n = touches.length, i, t, p, l; - noevent(event); - for (i = 0; i < n; ++i) { - t = touches[i], p = pointer(t, this); - if (g.touch0 && g.touch0[2] === t.identifier) - g.touch0[0] = p; - else if (g.touch1 && g.touch1[2] === t.identifier) - g.touch1[0] = p; - } - t = g.that.__zoom; - if (g.touch1) { - var p02 = g.touch0[0], l0 = g.touch0[1], p1 = g.touch1[0], l1 = g.touch1[1], dp = (dp = p1[0] - p02[0]) * dp + (dp = p1[1] - p02[1]) * dp, dl = (dl = l1[0] - l0[0]) * dl + (dl = l1[1] - l0[1]) * dl; - t = scale(t, Math.sqrt(dp / dl)); - p = [(p02[0] + p1[0]) / 2, (p02[1] + p1[1]) / 2]; - l = [(l0[0] + l1[0]) / 2, (l0[1] + l1[1]) / 2]; - } else if (g.touch0) - p = g.touch0[0], l = g.touch0[1]; - else - return; - g.zoom("touch", constrain(translate(t, p, l), g.extent, translateExtent)); - } - function touchended(event, ...args) { - if (!this.__zooming) - return; - var g = gesture(this, args).event(event), touches = event.changedTouches, n = touches.length, i, t; - nopropagation(event); - if (touchending) - clearTimeout(touchending); - touchending = setTimeout(function() { - touchending = null; - }, touchDelay); - for (i = 0; i < n; ++i) { - t = touches[i]; - if (g.touch0 && g.touch0[2] === t.identifier) - delete g.touch0; - else if (g.touch1 && g.touch1[2] === t.identifier) - delete g.touch1; - } - if (g.touch1 && !g.touch0) - g.touch0 = g.touch1, delete g.touch1; - if (g.touch0) - g.touch0[1] = this.__zoom.invert(g.touch0[0]); - else { - g.end(); - if (g.taps === 2) { - t = pointer(t, this); - if (Math.hypot(touchfirst[0] - t[0], touchfirst[1] - t[1]) < tapDistance) { - var p = select(this).on("dblclick.zoom"); - if (p) - p.apply(this, arguments); - } - } - } - } - zoom2.wheelDelta = function(_2) { - return arguments.length ? (wheelDelta = typeof _2 === "function" ? _2 : constant(+_2), zoom2) : wheelDelta; - }; - zoom2.filter = function(_2) { - return arguments.length ? (filter2 = typeof _2 === "function" ? _2 : constant(!!_2), zoom2) : filter2; - }; - zoom2.touchable = function(_2) { - return arguments.length ? (touchable = typeof _2 === "function" ? _2 : constant(!!_2), zoom2) : touchable; - }; - zoom2.extent = function(_2) { - return arguments.length ? (extent2 = typeof _2 === "function" ? _2 : constant([[+_2[0][0], +_2[0][1]], [+_2[1][0], +_2[1][1]]]), zoom2) : extent2; - }; - zoom2.scaleExtent = function(_2) { - return arguments.length ? (scaleExtent[0] = +_2[0], scaleExtent[1] = +_2[1], zoom2) : [scaleExtent[0], scaleExtent[1]]; - }; - zoom2.translateExtent = function(_2) { - return arguments.length ? (translateExtent[0][0] = +_2[0][0], translateExtent[1][0] = +_2[1][0], translateExtent[0][1] = +_2[0][1], translateExtent[1][1] = +_2[1][1], zoom2) : [[translateExtent[0][0], translateExtent[0][1]], [translateExtent[1][0], translateExtent[1][1]]]; - }; - zoom2.constrain = function(_2) { - return arguments.length ? (constrain = _2, zoom2) : constrain; - }; - zoom2.duration = function(_2) { - return arguments.length ? (duration = +_2, zoom2) : duration; - }; - zoom2.interpolate = function(_2) { - return arguments.length ? (interpolate2 = _2, zoom2) : interpolate2; - }; - zoom2.on = function() { - var value = listeners.on.apply(listeners, arguments); - return value === listeners ? zoom2 : value; - }; - zoom2.clickDistance = function(_2) { - return arguments.length ? (clickDistance2 = (_2 = +_2) * _2, zoom2) : Math.sqrt(clickDistance2); - }; - zoom2.tapDistance = function(_2) { - return arguments.length ? (tapDistance = +_2, zoom2) : tapDistance; - }; - return zoom2; - } - const src = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - bisect, - bisectRight, - bisectLeft, - bisectCenter, - ascending: ascending$3, - bisector, - blur, - blur2, - blurImage, - count: count$1, - cross: cross$3, - cumsum, - descending: descending$2, - deviation, - extent: extent$1, - Adder, - fsum, - fcumsum, - group, - flatGroup, - flatRollup, - groups, - index: index$4, - indexes, - rollup, - rollups, - groupSort, - bin, - histogram: bin, - thresholdFreedmanDiaconis, - thresholdScott, - thresholdSturges, - max: max$3, - maxIndex, - mean, - median, - medianIndex, - merge: merge$1, - min: min$2, - minIndex, - mode, - nice: nice$1, - pairs, - permute, - quantile: quantile$1, - quantileIndex, - quantileSorted, - quickselect, - range: range$2, - rank, - least, - leastIndex, - greatest, - greatestIndex, - scan, - shuffle: shuffle$1, - shuffler, - sum: sum$2, - ticks, - tickIncrement, - tickStep, - transpose, - variance, - zip, - every, - some, - filter: filter$1, - map: map$1, - reduce, - reverse: reverse$1, - sort, - difference, - disjoint, - intersection: intersection$1, - subset, - superset, - union, - InternMap, - InternSet, - axisTop, - axisRight, - axisBottom, - axisLeft, - brush, - brushX, - brushY, - brushSelection, - chord, - chordTranspose, - chordDirected, - ribbon: ribbon$1, - ribbonArrow, - color, - rgb, - hsl: hsl$2, - lab: lab$1, - hcl: hcl$1, - lch, - gray, - cubehelix: cubehelix$3, - contours: Contours, - contourDensity: density, - Delaunay, - Voronoi, - dispatch, - drag, - dragDisable, - dragEnable: yesdrag, - dsvFormat, - csvParse, - csvParseRows, - csvFormat, - csvFormatBody, - csvFormatRows, - csvFormatRow, - csvFormatValue, - tsvParse, - tsvParseRows, - tsvFormat, - tsvFormatBody, - tsvFormatRows, - tsvFormatRow, - tsvFormatValue, - autoType, - easeLinear: linear$1, - easeQuad: quadInOut, - easeQuadIn: quadIn, - easeQuadOut: quadOut, - easeQuadInOut: quadInOut, - easeCubic: cubicInOut, - easeCubicIn: cubicIn, - easeCubicOut: cubicOut, - easeCubicInOut: cubicInOut, - easePoly: polyInOut, - easePolyIn: polyIn, - easePolyOut: polyOut, - easePolyInOut: polyInOut, - easeSin: sinInOut, - easeSinIn: sinIn, - easeSinOut: sinOut, - easeSinInOut: sinInOut, - easeExp: expInOut, - easeExpIn: expIn, - easeExpOut: expOut, - easeExpInOut: expInOut, - easeCircle: circleInOut, - easeCircleIn: circleIn, - easeCircleOut: circleOut, - easeCircleInOut: circleInOut, - easeBounce: bounceOut, - easeBounceIn: bounceIn, - easeBounceOut: bounceOut, - easeBounceInOut: bounceInOut, - easeBack: backInOut, - easeBackIn: backIn, - easeBackOut: backOut, - easeBackInOut: backInOut, - easeElastic: elasticOut, - easeElasticIn: elasticIn, - easeElasticOut: elasticOut, - easeElasticInOut: elasticInOut, - blob, - buffer, - dsv, - csv, - tsv, - image, - json: json$1, - text: text$1, - xml: xml$1, - html: html$2, - svg: svg$2, - forceCenter: center, - forceCollide: collide, - forceLink: link$2, - forceManyBody: manyBody, - forceRadial: radial$1, - forceSimulation: simulation, - forceX: x$2, - forceY: y$1, - formatDefaultLocale: defaultLocale$1, - get format() { - return format; - }, - get formatPrefix() { - return formatPrefix; - }, - formatLocale: formatLocale$1, - formatSpecifier, - FormatSpecifier, - precisionFixed, - precisionPrefix, - precisionRound, - geoArea: area$2, - geoBounds: bounds$2, - geoCentroid: centroid$1, - geoCircle: circle$4, - geoClipAntimeridian: clipAntimeridian, - geoClipCircle: clipCircle, - geoClipExtent: extent, - geoClipRectangle: clipRectangle, - geoContains: contains$1, - geoDistance: distance$1, - geoGraticule: graticule, - geoGraticule10: graticule10, - geoInterpolate: interpolate, - geoLength: length$2, - geoPath: index$2, - geoAlbers: albers, - geoAlbersUsa: albersUsa, - geoAzimuthalEqualArea: azimuthalEqualArea, - geoAzimuthalEqualAreaRaw: azimuthalEqualAreaRaw, - geoAzimuthalEquidistant: azimuthalEquidistant, - geoAzimuthalEquidistantRaw: azimuthalEquidistantRaw, - geoConicConformal: conicConformal, - geoConicConformalRaw: conicConformalRaw, - geoConicEqualArea: conicEqualArea, - geoConicEqualAreaRaw: conicEqualAreaRaw, - geoConicEquidistant: conicEquidistant, - geoConicEquidistantRaw: conicEquidistantRaw, - geoEqualEarth: equalEarth, - geoEqualEarthRaw: equalEarthRaw, - geoEquirectangular: equirectangular, - geoEquirectangularRaw: equirectangularRaw, - geoGnomonic: gnomonic, - geoGnomonicRaw: gnomonicRaw, - geoIdentity: identity$4, - geoProjection: projection, - geoProjectionMutator: projectionMutator, - geoMercator: mercator, - geoMercatorRaw: mercatorRaw, - geoNaturalEarth1: naturalEarth1, - geoNaturalEarth1Raw: naturalEarth1Raw, - geoOrthographic: orthographic, - geoOrthographicRaw: orthographicRaw, - geoStereographic: stereographic, - geoStereographicRaw: stereographicRaw, - geoTransverseMercator: transverseMercator, - geoTransverseMercatorRaw: transverseMercatorRaw, - geoRotation: rotation, - geoStream, - geoTransform: transform$1, - cluster, - hierarchy, - Node: Node$1, - pack: index$1, - packSiblings: siblings, - packEnclose: enclose, - partition, - stratify, - tree, - treemap: index, - treemapBinary: binary, - treemapDice, - treemapSlice, - treemapSliceDice: sliceDice, - treemapSquarify: squarify, - treemapResquarify: resquarify, - interpolate: interpolate$2, - interpolateArray: array$3, - interpolateBasis: basis$1, - interpolateBasisClosed: basisClosed, - interpolateDate: date$1, - interpolateDiscrete: discrete, - interpolateHue: hue, - interpolateNumber, - interpolateNumberArray: numberArray, - interpolateObject: object$1, - interpolateRound, - interpolateString, - interpolateTransformCss, - interpolateTransformSvg, - interpolateZoom, - interpolateRgb, - interpolateRgbBasis: rgbBasis, - interpolateRgbBasisClosed: rgbBasisClosed, - interpolateHsl: hsl$1, - interpolateHslLong: hslLong, - interpolateLab: lab, - interpolateHcl, - interpolateHclLong: hclLong, - interpolateCubehelix: cubehelix$2, - interpolateCubehelixLong: cubehelixLong, - piecewise, - quantize: quantize$1, - path, - polygonArea: area$1, - polygonCentroid: centroid, - polygonHull: hull, - polygonContains: contains, - polygonLength: length$1, - quadtree, - randomUniform: uniform, - randomInt: int, - randomNormal: normal, - randomLogNormal: logNormal, - randomBates: bates, - randomIrwinHall: irwinHall, - randomExponential: exponential, - randomPareto: pareto, - randomBernoulli: bernoulli, - randomGeometric: geometric, - randomBinomial: binomial, - randomGamma: gamma, - randomBeta: beta, - randomWeibull: weibull, - randomCauchy: cauchy, - randomLogistic: logistic, - randomPoisson: poisson, - randomLcg: lcg, - scaleBand: band, - scalePoint: point$5, - scaleIdentity: identity$2, - scaleLinear: linear, - scaleLog: log$1, - scaleSymlog: symlog, - scaleOrdinal: ordinal, - scaleImplicit: implicit, - scalePow: pow, - scaleSqrt: sqrt$1, - scaleRadial: radial, - scaleQuantile: quantile, - scaleQuantize: quantize, - scaleThreshold: threshold, - scaleTime: time, - scaleUtc: utcTime, - scaleSequential: sequential, - scaleSequentialLog: sequentialLog, - scaleSequentialPow: sequentialPow, - scaleSequentialSqrt: sequentialSqrt, - scaleSequentialSymlog: sequentialSymlog, - scaleSequentialQuantile: sequentialQuantile, - scaleDiverging: diverging$1, - scaleDivergingLog: divergingLog, - scaleDivergingPow: divergingPow, - scaleDivergingSqrt: divergingSqrt, - scaleDivergingSymlog: divergingSymlog, - tickFormat, - schemeCategory10: category10, - schemeAccent: Accent, - schemeDark2: Dark2, - schemePaired: Paired, - schemePastel1: Pastel1, - schemePastel2: Pastel2, - schemeSet1: Set1, - schemeSet2: Set2, - schemeSet3: Set3, - schemeTableau10: Tableau10, - interpolateBrBG: BrBG, - schemeBrBG: scheme$q, - interpolatePRGn: PRGn, - schemePRGn: scheme$p, - interpolatePiYG: PiYG, - schemePiYG: scheme$o, - interpolatePuOr: PuOr, - schemePuOr: scheme$n, - interpolateRdBu: RdBu, - schemeRdBu: scheme$m, - interpolateRdGy: RdGy, - schemeRdGy: scheme$l, - interpolateRdYlBu: RdYlBu, - schemeRdYlBu: scheme$k, - interpolateRdYlGn: RdYlGn, - schemeRdYlGn: scheme$j, - interpolateSpectral: Spectral, - schemeSpectral: scheme$i, - interpolateBuGn: BuGn, - schemeBuGn: scheme$h, - interpolateBuPu: BuPu, - schemeBuPu: scheme$g, - interpolateGnBu: GnBu, - schemeGnBu: scheme$f, - interpolateOrRd: OrRd, - schemeOrRd: scheme$e, - interpolatePuBuGn: PuBuGn, - schemePuBuGn: scheme$d, - interpolatePuBu: PuBu, - schemePuBu: scheme$c, - interpolatePuRd: PuRd, - schemePuRd: scheme$b, - interpolateRdPu: RdPu, - schemeRdPu: scheme$a, - interpolateYlGnBu: YlGnBu, - schemeYlGnBu: scheme$9, - interpolateYlGn: YlGn, - schemeYlGn: scheme$8, - interpolateYlOrBr: YlOrBr, - schemeYlOrBr: scheme$7, - interpolateYlOrRd: YlOrRd, - schemeYlOrRd: scheme$6, - interpolateBlues: Blues, - schemeBlues: scheme$5, - interpolateGreens: Greens, - schemeGreens: scheme$4, - interpolateGreys: Greys, - schemeGreys: scheme$3, - interpolatePurples: Purples, - schemePurples: scheme$2, - interpolateReds: Reds, - schemeReds: scheme$1, - interpolateOranges: Oranges, - schemeOranges: scheme, - interpolateCividis: cividis, - interpolateCubehelixDefault: cubehelix, - interpolateRainbow: rainbow, - interpolateWarm: warm, - interpolateCool: cool, - interpolateSinebow: sinebow, - interpolateTurbo: turbo, - interpolateViridis: viridis, - interpolateMagma: magma, - interpolateInferno: inferno, - interpolatePlasma: plasma, - create: create$2, - creator, - local: local$1, - matcher, - namespace, - namespaces, - pointer, - pointers, - select, - selectAll, - selection, - selector, - selectorAll, - style: styleValue, - window: defaultView, - arc: d3arc, - area, - line: line$1, - pie: d3pie, - areaRadial, - radialArea: areaRadial, - lineRadial: lineRadial$1, - radialLine: lineRadial$1, - pointRadial, - link, - linkHorizontal, - linkVertical, - linkRadial, - symbol: Symbol$1, - symbolsStroke, - symbolsFill, - symbols: symbolsFill, - symbolAsterisk: asterisk, - symbolCircle: circle$2, - symbolCross: cross$1, - symbolDiamond: diamond, - symbolDiamond2: diamond2, - symbolPlus: plus, - symbolSquare: square, - symbolSquare2: square2, - symbolStar: star, - symbolTriangle: triangle, - symbolTriangle2: triangle2, - symbolWye: wye, - symbolX: x, - curveBasisClosed, - curveBasisOpen, - curveBasis, - curveBumpX: bumpX, - curveBumpY: bumpY, - curveBundle: bundle, - curveCardinalClosed: cardinalClosed, - curveCardinalOpen: cardinalOpen, - curveCardinal: cardinal, - curveCatmullRomClosed: catmullRomClosed, - curveCatmullRomOpen: catmullRomOpen, - curveCatmullRom: catmullRom, - curveLinearClosed, - curveLinear, - curveMonotoneX: monotoneX, - curveMonotoneY: monotoneY, - curveNatural, - curveStep, - curveStepAfter: stepAfter, - curveStepBefore: stepBefore, - stack, - stackOffsetExpand: expand, - stackOffsetDiverging: diverging, - stackOffsetNone: none$1, - stackOffsetSilhouette: silhouette, - stackOffsetWiggle: wiggle, - stackOrderAppearance: appearance, - stackOrderAscending: ascending, - stackOrderDescending: descending, - stackOrderInsideOut: insideOut, - stackOrderNone: none, - stackOrderReverse: reverse, - timeInterval: newInterval, - timeMillisecond: millisecond$1, - timeMilliseconds: milliseconds, - utcMillisecond: millisecond$1, - utcMilliseconds: milliseconds, - timeSecond: utcSecond, - timeSeconds: seconds, - utcSecond, - utcSeconds: seconds, - timeMinute, - timeMinutes: minutes, - timeHour, - timeHours: hours, - timeDay, - timeDays: days, - timeWeek: sunday, - timeWeeks: sundays, - timeSunday: sunday, - timeSundays: sundays, - timeMonday: monday, - timeMondays: mondays, - timeTuesday: tuesday, - timeTuesdays: tuesdays, - timeWednesday: wednesday, - timeWednesdays: wednesdays, - timeThursday: thursday, - timeThursdays: thursdays, - timeFriday: friday, - timeFridays: fridays, - timeSaturday: saturday, - timeSaturdays: saturdays, - timeMonth, - timeMonths: months, - timeYear, - timeYears: years, - utcMinute: utcMinute$1, - utcMinutes, - utcHour: utcHour$1, - utcHours, - utcDay: utcDay$1, - utcDays, - utcWeek: utcSunday, - utcWeeks: utcSundays, - utcSunday, - utcSundays, - utcMonday, - utcMondays, - utcTuesday, - utcTuesdays, - utcWednesday, - utcWednesdays, - utcThursday, - utcThursdays, - utcFriday, - utcFridays, - utcSaturday, - utcSaturdays, - utcMonth: utcMonth$1, - utcMonths, - utcYear: utcYear$1, - utcYears, - utcTicks, - utcTickInterval, - timeTicks, - timeTickInterval, - timeFormatDefaultLocale: defaultLocale, - get timeFormat() { - return timeFormat; - }, - get timeParse() { - return timeParse; - }, - get utcFormat() { - return utcFormat; - }, - get utcParse() { - return utcParse; - }, - timeFormatLocale: formatLocale, - isoFormat: formatIso$1, - isoParse: parseIso$1, - now, - timer, - timerFlush, - timeout, - interval, - transition, - active, - interrupt, - zoom, - zoomTransform: transform, - zoomIdentity: identity, - ZoomTransform: Transform - }, Symbol.toStringTag, { value: "Module" })); - /*! @license DOMPurify 2.4.0 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.4.0/LICENSE */ - function _typeof(obj) { - "@babel/helpers - typeof"; - return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) { - return typeof obj2; - } : function(obj2) { - return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2; - }, _typeof(obj); - } - function _setPrototypeOf(o, p) { - _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf2(o2, p2) { - o2.__proto__ = p2; - return o2; - }; - return _setPrototypeOf(o, p); - } - function _isNativeReflectConstruct() { - if (typeof Reflect === "undefined" || !Reflect.construct) - return false; - if (Reflect.construct.sham) - return false; - if (typeof Proxy === "function") - return true; - try { - Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() { - })); - return true; - } catch (e) { - return false; - } - } - function _construct(Parent, args, Class) { - if (_isNativeReflectConstruct()) { - _construct = Reflect.construct; - } else { - _construct = function _construct2(Parent2, args2, Class2) { - var a2 = [null]; - a2.push.apply(a2, args2); - var Constructor = Function.bind.apply(Parent2, a2); - var instance = new Constructor(); - if (Class2) - _setPrototypeOf(instance, Class2.prototype); - return instance; - }; - } - return _construct.apply(null, arguments); - } - function _toConsumableArray(arr) { - return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); - } - function _arrayWithoutHoles(arr) { - if (Array.isArray(arr)) - return _arrayLikeToArray(arr); - } - function _iterableToArray(iter) { - if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) - return Array.from(iter); - } - function _unsupportedIterableToArray(o, minLen) { - if (!o) - return; - if (typeof o === "string") - return _arrayLikeToArray(o, minLen); - var n = Object.prototype.toString.call(o).slice(8, -1); - if (n === "Object" && o.constructor) - n = o.constructor.name; - if (n === "Map" || n === "Set") - return Array.from(o); - if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) - return _arrayLikeToArray(o, minLen); - } - function _arrayLikeToArray(arr, len) { - if (len == null || len > arr.length) - len = arr.length; - for (var i = 0, arr2 = new Array(len); i < len; i++) - arr2[i] = arr[i]; - return arr2; - } - function _nonIterableSpread() { - throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); - } - var hasOwnProperty$3 = Object.hasOwnProperty, setPrototypeOf = Object.setPrototypeOf, isFrozen = Object.isFrozen, getPrototypeOf = Object.getPrototypeOf, getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; - var freeze = Object.freeze, seal = Object.seal, create = Object.create; - var _ref = typeof Reflect !== "undefined" && Reflect, apply$1 = _ref.apply, construct = _ref.construct; - if (!apply$1) { - apply$1 = function apply2(fun, thisValue, args) { - return fun.apply(thisValue, args); - }; - } - if (!freeze) { - freeze = function freeze2(x2) { - return x2; - }; - } - if (!seal) { - seal = function seal2(x2) { - return x2; - }; - } - if (!construct) { - construct = function construct2(Func, args) { - return _construct(Func, _toConsumableArray(args)); - }; - } - var arrayForEach = unapply(Array.prototype.forEach); - var arrayPop = unapply(Array.prototype.pop); - var arrayPush = unapply(Array.prototype.push); - var stringToLowerCase = unapply(String.prototype.toLowerCase); - var stringMatch = unapply(String.prototype.match); - var stringReplace = unapply(String.prototype.replace); - var stringIndexOf = unapply(String.prototype.indexOf); - var stringTrim = unapply(String.prototype.trim); - var regExpTest = unapply(RegExp.prototype.test); - var typeErrorCreate = unconstruct(TypeError); - function unapply(func) { - return function(thisArg) { - for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; - } - return apply$1(func, thisArg, args); - }; - } - function unconstruct(func) { - return function() { - for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } - return construct(func, args); - }; - } - function addToSet(set2, array2, transformCaseFunc) { - transformCaseFunc = transformCaseFunc ? transformCaseFunc : stringToLowerCase; - if (setPrototypeOf) { - setPrototypeOf(set2, null); - } - var l = array2.length; - while (l--) { - var element = array2[l]; - if (typeof element === "string") { - var lcElement = transformCaseFunc(element); - if (lcElement !== element) { - if (!isFrozen(array2)) { - array2[l] = lcElement; - } - element = lcElement; - } - } - set2[element] = true; - } - return set2; - } - function clone$1(object2) { - var newObject = create(null); - var property; - for (property in object2) { - if (apply$1(hasOwnProperty$3, object2, [property])) { - newObject[property] = object2[property]; - } - } - return newObject; - } - function lookupGetter(object2, prop) { - while (object2 !== null) { - var desc = getOwnPropertyDescriptor(object2, prop); - if (desc) { - if (desc.get) { - return unapply(desc.get); - } - if (typeof desc.value === "function") { - return unapply(desc.value); - } - } - object2 = getPrototypeOf(object2); - } - function fallbackValue(element) { - console.warn("fallback value for", element); - return null; - } - return fallbackValue; - } - var html$1 = freeze(["a", "abbr", "acronym", "address", "area", "article", "aside", "audio", "b", "bdi", "bdo", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "decorator", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "element", "em", "fieldset", "figcaption", "figure", "font", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "img", "input", "ins", "kbd", "label", "legend", "li", "main", "map", "mark", "marquee", "menu", "menuitem", "meter", "nav", "nobr", "ol", "optgroup", "option", "output", "p", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "section", "select", "shadow", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "tr", "track", "tt", "u", "ul", "var", "video", "wbr"]); - var svg$1 = freeze(["svg", "a", "altglyph", "altglyphdef", "altglyphitem", "animatecolor", "animatemotion", "animatetransform", "circle", "clippath", "defs", "desc", "ellipse", "filter", "font", "g", "glyph", "glyphref", "hkern", "image", "line", "lineargradient", "marker", "mask", "metadata", "mpath", "path", "pattern", "polygon", "polyline", "radialgradient", "rect", "stop", "style", "switch", "symbol", "text", "textpath", "title", "tref", "tspan", "view", "vkern"]); - var svgFilters = freeze(["feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence"]); - var svgDisallowed = freeze(["animate", "color-profile", "cursor", "discard", "fedropshadow", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignobject", "hatch", "hatchpath", "mesh", "meshgradient", "meshpatch", "meshrow", "missing-glyph", "script", "set", "solidcolor", "unknown", "use"]); - var mathMl$1 = freeze(["math", "menclose", "merror", "mfenced", "mfrac", "mglyph", "mi", "mlabeledtr", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msup", "msubsup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover"]); - var mathMlDisallowed = freeze(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]); - var text = freeze(["#text"]); - var html = freeze(["accept", "action", "align", "alt", "autocapitalize", "autocomplete", "autopictureinpicture", "autoplay", "background", "bgcolor", "border", "capture", "cellpadding", "cellspacing", "checked", "cite", "class", "clear", "color", "cols", "colspan", "controls", "controlslist", "coords", "crossorigin", "datetime", "decoding", "default", "dir", "disabled", "disablepictureinpicture", "disableremoteplayback", "download", "draggable", "enctype", "enterkeyhint", "face", "for", "headers", "height", "hidden", "high", "href", "hreflang", "id", "inputmode", "integrity", "ismap", "kind", "label", "lang", "list", "loading", "loop", "low", "max", "maxlength", "media", "method", "min", "minlength", "multiple", "muted", "name", "nonce", "noshade", "novalidate", "nowrap", "open", "optimum", "pattern", "placeholder", "playsinline", "poster", "preload", "pubdate", "radiogroup", "readonly", "rel", "required", "rev", "reversed", "role", "rows", "rowspan", "spellcheck", "scope", "selected", "shape", "size", "sizes", "span", "srclang", "start", "src", "srcset", "step", "style", "summary", "tabindex", "title", "translate", "type", "usemap", "valign", "value", "width", "xmlns", "slot"]); - var svg = freeze(["accent-height", "accumulate", "additive", "alignment-baseline", "ascent", "attributename", "attributetype", "azimuth", "basefrequency", "baseline-shift", "begin", "bias", "by", "class", "clip", "clippathunits", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cx", "cy", "d", "dx", "dy", "diffuseconstant", "direction", "display", "divisor", "dur", "edgemode", "elevation", "end", "fill", "fill-opacity", "fill-rule", "filter", "filterunits", "flood-color", "flood-opacity", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "fx", "fy", "g1", "g2", "glyph-name", "glyphref", "gradientunits", "gradienttransform", "height", "href", "id", "image-rendering", "in", "in2", "k", "k1", "k2", "k3", "k4", "kerning", "keypoints", "keysplines", "keytimes", "lang", "lengthadjust", "letter-spacing", "kernelmatrix", "kernelunitlength", "lighting-color", "local", "marker-end", "marker-mid", "marker-start", "markerheight", "markerunits", "markerwidth", "maskcontentunits", "maskunits", "max", "mask", "media", "method", "mode", "min", "name", "numoctaves", "offset", "operator", "opacity", "order", "orient", "orientation", "origin", "overflow", "paint-order", "path", "pathlength", "patterncontentunits", "patterntransform", "patternunits", "points", "preservealpha", "preserveaspectratio", "primitiveunits", "r", "rx", "ry", "radius", "refx", "refy", "repeatcount", "repeatdur", "restart", "result", "rotate", "scale", "seed", "shape-rendering", "specularconstant", "specularexponent", "spreadmethod", "startoffset", "stddeviation", "stitchtiles", "stop-color", "stop-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke", "stroke-width", "style", "surfacescale", "systemlanguage", "tabindex", "targetx", "targety", "transform", "transform-origin", "text-anchor", "text-decoration", "text-rendering", "textlength", "type", "u1", "u2", "unicode", "values", "viewbox", "visibility", "version", "vert-adv-y", "vert-origin-x", "vert-origin-y", "width", "word-spacing", "wrap", "writing-mode", "xchannelselector", "ychannelselector", "x", "x1", "x2", "xmlns", "y", "y1", "y2", "z", "zoomandpan"]); - var mathMl = freeze(["accent", "accentunder", "align", "bevelled", "close", "columnsalign", "columnlines", "columnspan", "denomalign", "depth", "dir", "display", "displaystyle", "encoding", "fence", "frame", "height", "href", "id", "largeop", "length", "linethickness", "lspace", "lquote", "mathbackground", "mathcolor", "mathsize", "mathvariant", "maxsize", "minsize", "movablelimits", "notation", "numalign", "open", "rowalign", "rowlines", "rowspacing", "rowspan", "rspace", "rquote", "scriptlevel", "scriptminsize", "scriptsizemultiplier", "selection", "separator", "separators", "stretchy", "subscriptshift", "supscriptshift", "symmetric", "voffset", "width", "xmlns"]); - var xml = freeze(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]); - var MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm); - var ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm); - var DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); - var ARIA_ATTR = seal(/^aria-[\-\w]+$/); - var IS_ALLOWED_URI = seal( - /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i - ); - var IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i); - var ATTR_WHITESPACE = seal( - /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g - ); - var DOCTYPE_NAME = seal(/^html$/i); - var getGlobal = function getGlobal2() { - return typeof window === "undefined" ? null : window; - }; - var _createTrustedTypesPolicy = function _createTrustedTypesPolicy2(trustedTypes, document2) { - if (_typeof(trustedTypes) !== "object" || typeof trustedTypes.createPolicy !== "function") { - return null; - } - var suffix = null; - var ATTR_NAME = "data-tt-policy-suffix"; - if (document2.currentScript && document2.currentScript.hasAttribute(ATTR_NAME)) { - suffix = document2.currentScript.getAttribute(ATTR_NAME); - } - var policyName = "dompurify" + (suffix ? "#" + suffix : ""); - try { - return trustedTypes.createPolicy(policyName, { - createHTML: function createHTML(html2) { - return html2; - }, - createScriptURL: function createScriptURL(scriptUrl) { - return scriptUrl; - } - }); - } catch (_2) { - console.warn("TrustedTypes policy " + policyName + " could not be created."); - return null; - } - }; - function createDOMPurify() { - var window2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : getGlobal(); - var DOMPurify = function DOMPurify2(root2) { - return createDOMPurify(root2); - }; - DOMPurify.version = "2.4.0"; - DOMPurify.removed = []; - if (!window2 || !window2.document || window2.document.nodeType !== 9) { - DOMPurify.isSupported = false; - return DOMPurify; - } - var originalDocument = window2.document; - var document2 = window2.document; - var DocumentFragment = window2.DocumentFragment, HTMLTemplateElement = window2.HTMLTemplateElement, Node2 = window2.Node, Element = window2.Element, NodeFilter = window2.NodeFilter, _window$NamedNodeMap = window2.NamedNodeMap, NamedNodeMap = _window$NamedNodeMap === void 0 ? window2.NamedNodeMap || window2.MozNamedAttrMap : _window$NamedNodeMap, HTMLFormElement = window2.HTMLFormElement, DOMParser2 = window2.DOMParser, trustedTypes = window2.trustedTypes; - var ElementPrototype = Element.prototype; - var cloneNode = lookupGetter(ElementPrototype, "cloneNode"); - var getNextSibling = lookupGetter(ElementPrototype, "nextSibling"); - var getChildNodes = lookupGetter(ElementPrototype, "childNodes"); - var getParentNode = lookupGetter(ElementPrototype, "parentNode"); - if (typeof HTMLTemplateElement === "function") { - var template = document2.createElement("template"); - if (template.content && template.content.ownerDocument) { - document2 = template.content.ownerDocument; - } - } - var trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, originalDocument); - var emptyHTML = trustedTypesPolicy ? trustedTypesPolicy.createHTML("") : ""; - var _document = document2, implementation = _document.implementation, createNodeIterator = _document.createNodeIterator, createDocumentFragment = _document.createDocumentFragment, getElementsByTagName = _document.getElementsByTagName; - var importNode = originalDocument.importNode; - var documentMode = {}; - try { - documentMode = clone$1(document2).documentMode ? document2.documentMode : {}; - } catch (_2) { - } - var hooks = {}; - DOMPurify.isSupported = typeof getParentNode === "function" && implementation && typeof implementation.createHTMLDocument !== "undefined" && documentMode !== 9; - var MUSTACHE_EXPR$1 = MUSTACHE_EXPR, ERB_EXPR$1 = ERB_EXPR, DATA_ATTR$1 = DATA_ATTR, ARIA_ATTR$1 = ARIA_ATTR, IS_SCRIPT_OR_DATA$1 = IS_SCRIPT_OR_DATA, ATTR_WHITESPACE$1 = ATTR_WHITESPACE; - var IS_ALLOWED_URI$1 = IS_ALLOWED_URI; - var ALLOWED_TAGS = null; - var DEFAULT_ALLOWED_TAGS = addToSet({}, [].concat(_toConsumableArray(html$1), _toConsumableArray(svg$1), _toConsumableArray(svgFilters), _toConsumableArray(mathMl$1), _toConsumableArray(text))); - var ALLOWED_ATTR = null; - var DEFAULT_ALLOWED_ATTR = addToSet({}, [].concat(_toConsumableArray(html), _toConsumableArray(svg), _toConsumableArray(mathMl), _toConsumableArray(xml))); - var CUSTOM_ELEMENT_HANDLING = Object.seal(Object.create(null, { - tagNameCheck: { - writable: true, - configurable: false, - enumerable: true, - value: null - }, - attributeNameCheck: { - writable: true, - configurable: false, - enumerable: true, - value: null - }, - allowCustomizedBuiltInElements: { - writable: true, - configurable: false, - enumerable: true, - value: false - } - })); - var FORBID_TAGS = null; - var FORBID_ATTR = null; - var ALLOW_ARIA_ATTR = true; - var ALLOW_DATA_ATTR = true; - var ALLOW_UNKNOWN_PROTOCOLS = false; - var SAFE_FOR_TEMPLATES = false; - var WHOLE_DOCUMENT = false; - var SET_CONFIG = false; - var FORCE_BODY = false; - var RETURN_DOM = false; - var RETURN_DOM_FRAGMENT = false; - var RETURN_TRUSTED_TYPE = false; - var SANITIZE_DOM = true; - var SANITIZE_NAMED_PROPS = false; - var SANITIZE_NAMED_PROPS_PREFIX = "user-content-"; - var KEEP_CONTENT = true; - var IN_PLACE = false; - var USE_PROFILES = {}; - var FORBID_CONTENTS = null; - var DEFAULT_FORBID_CONTENTS = addToSet({}, ["annotation-xml", "audio", "colgroup", "desc", "foreignobject", "head", "iframe", "math", "mi", "mn", "mo", "ms", "mtext", "noembed", "noframes", "noscript", "plaintext", "script", "style", "svg", "template", "thead", "title", "video", "xmp"]); - var DATA_URI_TAGS = null; - var DEFAULT_DATA_URI_TAGS = addToSet({}, ["audio", "video", "img", "source", "image", "track"]); - var URI_SAFE_ATTRIBUTES = null; - var DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]); - var MATHML_NAMESPACE = "http://www.w3.org/1998/Math/MathML"; - var SVG_NAMESPACE = "http://www.w3.org/2000/svg"; - var HTML_NAMESPACE = "http://www.w3.org/1999/xhtml"; - var NAMESPACE = HTML_NAMESPACE; - var IS_EMPTY_INPUT = false; - var PARSER_MEDIA_TYPE; - var SUPPORTED_PARSER_MEDIA_TYPES = ["application/xhtml+xml", "text/html"]; - var DEFAULT_PARSER_MEDIA_TYPE = "text/html"; - var transformCaseFunc; - var CONFIG = null; - var formElement = document2.createElement("form"); - var isRegexOrFunction = function isRegexOrFunction2(testValue) { - return testValue instanceof RegExp || testValue instanceof Function; - }; - var _parseConfig = function _parseConfig2(cfg) { - if (CONFIG && CONFIG === cfg) { - return; - } - if (!cfg || _typeof(cfg) !== "object") { - cfg = {}; - } - cfg = clone$1(cfg); - PARSER_MEDIA_TYPE = SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? PARSER_MEDIA_TYPE = DEFAULT_PARSER_MEDIA_TYPE : PARSER_MEDIA_TYPE = cfg.PARSER_MEDIA_TYPE; - transformCaseFunc = PARSER_MEDIA_TYPE === "application/xhtml+xml" ? function(x2) { - return x2; - } : stringToLowerCase; - ALLOWED_TAGS = "ALLOWED_TAGS" in cfg ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS; - ALLOWED_ATTR = "ALLOWED_ATTR" in cfg ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR; - URI_SAFE_ATTRIBUTES = "ADD_URI_SAFE_ATTR" in cfg ? addToSet( - clone$1(DEFAULT_URI_SAFE_ATTRIBUTES), - cfg.ADD_URI_SAFE_ATTR, - transformCaseFunc - ) : DEFAULT_URI_SAFE_ATTRIBUTES; - DATA_URI_TAGS = "ADD_DATA_URI_TAGS" in cfg ? addToSet( - clone$1(DEFAULT_DATA_URI_TAGS), - cfg.ADD_DATA_URI_TAGS, - transformCaseFunc - ) : DEFAULT_DATA_URI_TAGS; - FORBID_CONTENTS = "FORBID_CONTENTS" in cfg ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS; - FORBID_TAGS = "FORBID_TAGS" in cfg ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : {}; - FORBID_ATTR = "FORBID_ATTR" in cfg ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : {}; - USE_PROFILES = "USE_PROFILES" in cfg ? cfg.USE_PROFILES : false; - ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; - ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; - ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; - SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; - WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; - RETURN_DOM = cfg.RETURN_DOM || false; - RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; - RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; - FORCE_BODY = cfg.FORCE_BODY || false; - SANITIZE_DOM = cfg.SANITIZE_DOM !== false; - SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; - KEEP_CONTENT = cfg.KEEP_CONTENT !== false; - IN_PLACE = cfg.IN_PLACE || false; - IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI$1; - NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE; - if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) { - CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck; - } - if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) { - CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck; - } - if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === "boolean") { - CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements; - } - if (SAFE_FOR_TEMPLATES) { - ALLOW_DATA_ATTR = false; - } - if (RETURN_DOM_FRAGMENT) { - RETURN_DOM = true; - } - if (USE_PROFILES) { - ALLOWED_TAGS = addToSet({}, _toConsumableArray(text)); - ALLOWED_ATTR = []; - if (USE_PROFILES.html === true) { - addToSet(ALLOWED_TAGS, html$1); - addToSet(ALLOWED_ATTR, html); - } - if (USE_PROFILES.svg === true) { - addToSet(ALLOWED_TAGS, svg$1); - addToSet(ALLOWED_ATTR, svg); - addToSet(ALLOWED_ATTR, xml); - } - if (USE_PROFILES.svgFilters === true) { - addToSet(ALLOWED_TAGS, svgFilters); - addToSet(ALLOWED_ATTR, svg); - addToSet(ALLOWED_ATTR, xml); - } - if (USE_PROFILES.mathMl === true) { - addToSet(ALLOWED_TAGS, mathMl$1); - addToSet(ALLOWED_ATTR, mathMl); - addToSet(ALLOWED_ATTR, xml); - } - } - if (cfg.ADD_TAGS) { - if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) { - ALLOWED_TAGS = clone$1(ALLOWED_TAGS); - } - addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc); - } - if (cfg.ADD_ATTR) { - if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) { - ALLOWED_ATTR = clone$1(ALLOWED_ATTR); - } - addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc); - } - if (cfg.ADD_URI_SAFE_ATTR) { - addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc); - } - if (cfg.FORBID_CONTENTS) { - if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) { - FORBID_CONTENTS = clone$1(FORBID_CONTENTS); - } - addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc); - } - if (KEEP_CONTENT) { - ALLOWED_TAGS["#text"] = true; - } - if (WHOLE_DOCUMENT) { - addToSet(ALLOWED_TAGS, ["html", "head", "body"]); - } - if (ALLOWED_TAGS.table) { - addToSet(ALLOWED_TAGS, ["tbody"]); - delete FORBID_TAGS.tbody; - } - if (freeze) { - freeze(cfg); - } - CONFIG = cfg; - }; - var MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ["mi", "mo", "mn", "ms", "mtext"]); - var HTML_INTEGRATION_POINTS = addToSet({}, ["foreignobject", "desc", "title", "annotation-xml"]); - var COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ["title", "style", "font", "a", "script"]); - var ALL_SVG_TAGS = addToSet({}, svg$1); - addToSet(ALL_SVG_TAGS, svgFilters); - addToSet(ALL_SVG_TAGS, svgDisallowed); - var ALL_MATHML_TAGS = addToSet({}, mathMl$1); - addToSet(ALL_MATHML_TAGS, mathMlDisallowed); - var _checkValidNamespace = function _checkValidNamespace2(element) { - var parent = getParentNode(element); - if (!parent || !parent.tagName) { - parent = { - namespaceURI: HTML_NAMESPACE, - tagName: "template" - }; - } - var tagName = stringToLowerCase(element.tagName); - var parentTagName = stringToLowerCase(parent.tagName); - if (element.namespaceURI === SVG_NAMESPACE) { - if (parent.namespaceURI === HTML_NAMESPACE) { - return tagName === "svg"; - } - if (parent.namespaceURI === MATHML_NAMESPACE) { - return tagName === "svg" && (parentTagName === "annotation-xml" || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]); - } - return Boolean(ALL_SVG_TAGS[tagName]); - } - if (element.namespaceURI === MATHML_NAMESPACE) { - if (parent.namespaceURI === HTML_NAMESPACE) { - return tagName === "math"; - } - if (parent.namespaceURI === SVG_NAMESPACE) { - return tagName === "math" && HTML_INTEGRATION_POINTS[parentTagName]; - } - return Boolean(ALL_MATHML_TAGS[tagName]); - } - if (element.namespaceURI === HTML_NAMESPACE) { - if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) { - return false; - } - if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) { - return false; - } - return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]); - } - return false; - }; - var _forceRemove = function _forceRemove2(node2) { - arrayPush(DOMPurify.removed, { - element: node2 - }); - try { - node2.parentNode.removeChild(node2); - } catch (_2) { - try { - node2.outerHTML = emptyHTML; - } catch (_3) { - node2.remove(); - } - } - }; - var _removeAttribute = function _removeAttribute2(name2, node2) { - try { - arrayPush(DOMPurify.removed, { - attribute: node2.getAttributeNode(name2), - from: node2 - }); - } catch (_2) { - arrayPush(DOMPurify.removed, { - attribute: null, - from: node2 - }); - } - node2.removeAttribute(name2); - if (name2 === "is" && !ALLOWED_ATTR[name2]) { - if (RETURN_DOM || RETURN_DOM_FRAGMENT) { - try { - _forceRemove(node2); - } catch (_2) { - } - } else { - try { - node2.setAttribute(name2, ""); - } catch (_2) { - } - } - } - }; - var _initDocument = function _initDocument2(dirty) { - var doc; - var leadingWhitespace; - if (FORCE_BODY) { - dirty = "" + dirty; - } else { - var matches = stringMatch(dirty, /^[\r\n\t ]+/); - leadingWhitespace = matches && matches[0]; - } - if (PARSER_MEDIA_TYPE === "application/xhtml+xml") { - dirty = '' + dirty + ""; - } - var dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty; - if (NAMESPACE === HTML_NAMESPACE) { - try { - doc = new DOMParser2().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE); - } catch (_2) { - } - } - if (!doc || !doc.documentElement) { - doc = implementation.createDocument(NAMESPACE, "template", null); - try { - doc.documentElement.innerHTML = IS_EMPTY_INPUT ? "" : dirtyPayload; - } catch (_2) { - } - } - var body = doc.body || doc.documentElement; - if (dirty && leadingWhitespace) { - body.insertBefore(document2.createTextNode(leadingWhitespace), body.childNodes[0] || null); - } - if (NAMESPACE === HTML_NAMESPACE) { - return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? "html" : "body")[0]; - } - return WHOLE_DOCUMENT ? doc.documentElement : body; - }; - var _createIterator = function _createIterator2(root2) { - return createNodeIterator.call( - root2.ownerDocument || root2, - root2, - NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT, - null, - false - ); - }; - var _isClobbered = function _isClobbered2(elm) { - return elm instanceof HTMLFormElement && (typeof elm.nodeName !== "string" || typeof elm.textContent !== "string" || typeof elm.removeChild !== "function" || !(elm.attributes instanceof NamedNodeMap) || typeof elm.removeAttribute !== "function" || typeof elm.setAttribute !== "function" || typeof elm.namespaceURI !== "string" || typeof elm.insertBefore !== "function"); - }; - var _isNode = function _isNode2(object2) { - return _typeof(Node2) === "object" ? object2 instanceof Node2 : object2 && _typeof(object2) === "object" && typeof object2.nodeType === "number" && typeof object2.nodeName === "string"; - }; - var _executeHook = function _executeHook2(entryPoint, currentNode, data) { - if (!hooks[entryPoint]) { - return; - } - arrayForEach(hooks[entryPoint], function(hook) { - hook.call(DOMPurify, currentNode, data, CONFIG); - }); - }; - var _sanitizeElements = function _sanitizeElements2(currentNode) { - var content; - _executeHook("beforeSanitizeElements", currentNode, null); - if (_isClobbered(currentNode)) { - _forceRemove(currentNode); - return true; - } - if (regExpTest(/[\u0080-\uFFFF]/, currentNode.nodeName)) { - _forceRemove(currentNode); - return true; - } - var tagName = transformCaseFunc(currentNode.nodeName); - _executeHook("uponSanitizeElement", currentNode, { - tagName, - allowedTags: ALLOWED_TAGS - }); - if (currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && (!_isNode(currentNode.content) || !_isNode(currentNode.content.firstElementChild)) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) { - _forceRemove(currentNode); - return true; - } - if (tagName === "select" && regExpTest(/