diff --git a/package.json b/package.json index 4b8fa9de0..e9c953104 100644 --- a/package.json +++ b/package.json @@ -14,8 +14,7 @@ "fetch-mock": "^9.11.0", "happen": "~0.1.3", "lebab": "^3.2.1", - "mocha": "^10.3.0", - "optimist": "~0.4.0", + "mocha": "10.7.3", "sinon": "^15.1.0", "uglify-js": "~3.17.4" }, @@ -38,11 +37,11 @@ "homepage": "http://wiki.openstreetmap.org/wiki/UMap", "dependencies": { "@dwayneparton/geojson-to-gpx": "^0.2.0", - "@placemarkio/tokml": "^0.3.3", + "@placemarkio/tokml": "0.3.4", "@tmcw/togeojson": "^5.8.0", - "colorbrewer": "^1.5.6", + "colorbrewer": "1.5.7", "csv2geojson": "5.1.2", - "dompurify": "^3.0.11", + "dompurify": "3.1.7", "georsstogeojson": "^0.2.0", "jsdom": "^24.0.0", "leaflet": "1.9.4", @@ -58,12 +57,12 @@ "leaflet-minimap": "^3.6.1", "leaflet-toolbar": "umap-project/Leaflet.toolbar", "leaflet.heat": "0.2.0", - "leaflet.locatecontrol": "^0.79.0", + "leaflet.locatecontrol": "0.81.1", "leaflet.markercluster": "^1.5.3", "leaflet.path.drag": "0.0.6", "leaflet.photon": "0.9.1", "osmtogeojson": "^3.0.0-beta.5", - "simple-statistics": "^7.8.3" + "simple-statistics": "7.8.5" }, "browserslist": [ "> 0.5%, last 2 versions, Firefox ESR, not dead, not op_mini all" diff --git a/umap/static/umap/vendors/colorbrewer/colorbrewer.js b/umap/static/umap/vendors/colorbrewer/colorbrewer.js index ee2f86fa5..c23233dde 100644 --- a/umap/static/umap/vendors/colorbrewer/colorbrewer.js +++ b/umap/static/umap/vendors/colorbrewer/colorbrewer.js @@ -1,8 +1,8 @@ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.colorbrewer = factory()); -}(this, (function () { 'use strict'; + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.colorbewer = factory()); +})(this, (function () { 'use strict'; var index = { schemeGroups: { @@ -315,4 +315,4 @@ return index; -}))); +})); diff --git a/umap/static/umap/vendors/dompurify/purify.es.js b/umap/static/umap/vendors/dompurify/purify.es.js index c19b8c19f..7a42ce635 100644 --- a/umap/static/umap/vendors/dompurify/purify.es.js +++ b/umap/static/umap/vendors/dompurify/purify.es.js @@ -1,4 +1,4 @@ -/*! @license DOMPurify 3.1.5 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.1.5/LICENSE */ +/*! @license DOMPurify 3.1.7 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.1.7/LICENSE */ const { entries, @@ -197,7 +197,7 @@ const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongd const text = freeze(['#text']); const 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', 'popover', 'popovertarget', 'popovertargetaction', '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', 'wrap', 'xmlns', 'slot']); -const 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']); +const svg = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'amplitude', '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', 'exponent', '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', 'intercept', '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', 'slope', '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', 'tablevalues', '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']); const 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']); const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']); @@ -209,11 +209,9 @@ const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); // eslint-disable-line no- const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape const IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape ); - const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i); const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex ); - const DOCTYPE_NAME = seal(/^html$/i); const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i); @@ -248,7 +246,6 @@ const NODE_TYPE = { documentFragment: 11, notation: 12 // Deprecated }; - const getGlobal = function getGlobal() { return typeof window === 'undefined' ? null : window; }; @@ -300,7 +297,7 @@ function createDOMPurify() { * Version label, exposed for easier checks * if DOMPurify is up to date or not */ - DOMPurify.version = '3.1.5'; + DOMPurify.version = '3.1.7'; /** * Array of elements that DOMPurify removed during sanitation. @@ -331,6 +328,7 @@ function createDOMPurify() { } = window; const ElementPrototype = Element.prototype; const cloneNode = lookupGetter(ElementPrototype, 'cloneNode'); + const remove = lookupGetter(ElementPrototype, 'remove'); const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling'); const getChildNodes = lookupGetter(ElementPrototype, 'childNodes'); const getParentNode = lookupGetter(ElementPrototype, 'parentNode'); @@ -719,7 +717,7 @@ function createDOMPurify() { CONFIG = cfg; }; const MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']); - const HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', 'annotation-xml']); + const HTML_INTEGRATION_POINTS = addToSet({}, ['annotation-xml']); // Certain elements are allowed in both SVG and HTML // namespace. We need to specify them explicitly @@ -831,9 +829,9 @@ function createDOMPurify() { }); try { // eslint-disable-next-line unicorn/prefer-dom-node-remove - node.parentNode.removeChild(node); + getParentNode(node).removeChild(node); } catch (_) { - node.remove(); + remove(node); } }; @@ -1010,7 +1008,7 @@ function createDOMPurify() { return true; } - /* Remove any ocurrence of processing instructions */ + /* Remove any occurrence of processing instructions */ if (currentNode.nodeType === NODE_TYPE.progressingInstruction) { _forceRemove(currentNode); return true; @@ -1179,6 +1177,7 @@ function createDOMPurify() { hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set _executeHook('uponSanitizeAttribute', currentNode, hookEvent); value = hookEvent.attrValue; + /* Did the hooks approve of the attribute? */ if (hookEvent.forceKeepAttr) { continue; @@ -1198,12 +1197,6 @@ function createDOMPurify() { continue; } - /* Work around a security issue with comments inside attributes */ - if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title)/i, value)) { - _removeAttribute(name, currentNode); - continue; - } - /* Sanitize attribute content to be template-safe */ if (SAFE_FOR_TEMPLATES) { arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => { @@ -1228,6 +1221,12 @@ function createDOMPurify() { value = SANITIZE_NAMED_PROPS_PREFIX + value; } + /* Work around a security issue with comments inside attributes */ + if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title)/i, value)) { + _removeAttribute(name, currentNode); + continue; + } + /* Handle attributes that require Trusted Types */ if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') { if (namespaceURI) ; else { diff --git a/umap/static/umap/vendors/dompurify/purify.es.mjs.map b/umap/static/umap/vendors/dompurify/purify.es.mjs.map index 92db0d9ba..2e86263db 100644 --- a/umap/static/umap/vendors/dompurify/purify.es.mjs.map +++ b/umap/static/umap/vendors/dompurify/purify.es.mjs.map @@ -1 +1 @@ -{"version":3,"file":"purify.es.mjs","sources":["../src/utils.js","../src/tags.js","../src/attrs.js","../src/regexp.js","../src/purify.js"],"sourcesContent":["const {\n entries,\n setPrototypeOf,\n isFrozen,\n getPrototypeOf,\n getOwnPropertyDescriptor,\n} = Object;\n\nlet { freeze, seal, create } = Object; // eslint-disable-line import/no-mutable-exports\nlet { apply, construct } = typeof Reflect !== 'undefined' && Reflect;\n\nif (!freeze) {\n freeze = function (x) {\n return x;\n };\n}\n\nif (!seal) {\n seal = function (x) {\n return x;\n };\n}\n\nif (!apply) {\n apply = function (fun, thisValue, args) {\n return fun.apply(thisValue, args);\n };\n}\n\nif (!construct) {\n construct = function (Func, args) {\n return new Func(...args);\n };\n}\n\nconst arrayForEach = unapply(Array.prototype.forEach);\nconst arrayIndexOf = unapply(Array.prototype.indexOf);\nconst arrayPop = unapply(Array.prototype.pop);\nconst arrayPush = unapply(Array.prototype.push);\nconst arraySlice = unapply(Array.prototype.slice);\n\nconst stringToLowerCase = unapply(String.prototype.toLowerCase);\nconst stringToString = unapply(String.prototype.toString);\nconst stringMatch = unapply(String.prototype.match);\nconst stringReplace = unapply(String.prototype.replace);\nconst stringIndexOf = unapply(String.prototype.indexOf);\nconst stringTrim = unapply(String.prototype.trim);\n\nconst objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);\n\nconst regExpTest = unapply(RegExp.prototype.test);\n\nconst typeErrorCreate = unconstruct(TypeError);\n\n/**\n * Creates a new function that calls the given function with a specified thisArg and arguments.\n *\n * @param {Function} func - The function to be wrapped and called.\n * @returns {Function} A new function that calls the given function with a specified thisArg and arguments.\n */\nfunction unapply(func) {\n return (thisArg, ...args) => apply(func, thisArg, args);\n}\n\n/**\n * Creates a new function that constructs an instance of the given constructor function with the provided arguments.\n *\n * @param {Function} func - The constructor function to be wrapped and called.\n * @returns {Function} A new function that constructs an instance of the given constructor function with the provided arguments.\n */\nfunction unconstruct(func) {\n return (...args) => construct(func, args);\n}\n\n/**\n * Add properties to a lookup table\n *\n * @param {Object} set - The set to which elements will be added.\n * @param {Array} array - The array containing elements to be added to the set.\n * @param {Function} transformCaseFunc - An optional function to transform the case of each element before adding to the set.\n * @returns {Object} The modified set with added elements.\n */\nfunction addToSet(set, array, transformCaseFunc = stringToLowerCase) {\n if (setPrototypeOf) {\n // Make 'in' and truthy checks like Boolean(set.constructor)\n // independent of any properties defined on Object.prototype.\n // Prevent prototype setters from intercepting set as a this value.\n setPrototypeOf(set, null);\n }\n\n let l = array.length;\n while (l--) {\n let element = array[l];\n if (typeof element === 'string') {\n const lcElement = transformCaseFunc(element);\n if (lcElement !== element) {\n // Config presets (e.g. tags.js, attrs.js) are immutable.\n if (!isFrozen(array)) {\n array[l] = lcElement;\n }\n\n element = lcElement;\n }\n }\n\n set[element] = true;\n }\n\n return set;\n}\n\n/**\n * Clean up an array to harden against CSPP\n *\n * @param {Array} array - The array to be cleaned.\n * @returns {Array} The cleaned version of the array\n */\nfunction cleanArray(array) {\n for (let index = 0; index < array.length; index++) {\n const isPropertyExist = objectHasOwnProperty(array, index);\n\n if (!isPropertyExist) {\n array[index] = null;\n }\n }\n\n return array;\n}\n\n/**\n * Shallow clone an object\n *\n * @param {Object} object - The object to be cloned.\n * @returns {Object} A new object that copies the original.\n */\nfunction clone(object) {\n const newObject = create(null);\n\n for (const [property, value] of entries(object)) {\n const isPropertyExist = objectHasOwnProperty(object, property);\n\n if (isPropertyExist) {\n if (Array.isArray(value)) {\n newObject[property] = cleanArray(value);\n } else if (\n value &&\n typeof value === 'object' &&\n value.constructor === Object\n ) {\n newObject[property] = clone(value);\n } else {\n newObject[property] = value;\n }\n }\n }\n\n return newObject;\n}\n\n/**\n * This method automatically checks if the prop is function or getter and behaves accordingly.\n *\n * @param {Object} object - The object to look up the getter function in its prototype chain.\n * @param {String} prop - The property name for which to find the getter function.\n * @returns {Function} The getter function found in the prototype chain or a fallback function.\n */\nfunction lookupGetter(object, prop) {\n while (object !== null) {\n const desc = getOwnPropertyDescriptor(object, prop);\n\n if (desc) {\n if (desc.get) {\n return unapply(desc.get);\n }\n\n if (typeof desc.value === 'function') {\n return unapply(desc.value);\n }\n }\n\n object = getPrototypeOf(object);\n }\n\n function fallbackValue() {\n return null;\n }\n\n return fallbackValue;\n}\n\nexport {\n // Array\n arrayForEach,\n arrayIndexOf,\n arrayPop,\n arrayPush,\n arraySlice,\n // Object\n entries,\n freeze,\n getPrototypeOf,\n getOwnPropertyDescriptor,\n isFrozen,\n setPrototypeOf,\n seal,\n clone,\n create,\n objectHasOwnProperty,\n // RegExp\n regExpTest,\n // String\n stringIndexOf,\n stringMatch,\n stringReplace,\n stringToLowerCase,\n stringToString,\n stringTrim,\n // Errors\n typeErrorCreate,\n // Other\n lookupGetter,\n addToSet,\n // Reflect\n unapply,\n unconstruct,\n};\n","import { freeze } from './utils.js';\n\nexport const html = freeze([\n 'a',\n 'abbr',\n 'acronym',\n 'address',\n 'area',\n 'article',\n 'aside',\n 'audio',\n 'b',\n 'bdi',\n 'bdo',\n 'big',\n 'blink',\n 'blockquote',\n 'body',\n 'br',\n 'button',\n 'canvas',\n 'caption',\n 'center',\n 'cite',\n 'code',\n 'col',\n 'colgroup',\n 'content',\n 'data',\n 'datalist',\n 'dd',\n 'decorator',\n 'del',\n 'details',\n 'dfn',\n 'dialog',\n 'dir',\n 'div',\n 'dl',\n 'dt',\n 'element',\n 'em',\n 'fieldset',\n 'figcaption',\n 'figure',\n 'font',\n 'footer',\n 'form',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'head',\n 'header',\n 'hgroup',\n 'hr',\n 'html',\n 'i',\n 'img',\n 'input',\n 'ins',\n 'kbd',\n 'label',\n 'legend',\n 'li',\n 'main',\n 'map',\n 'mark',\n 'marquee',\n 'menu',\n 'menuitem',\n 'meter',\n 'nav',\n 'nobr',\n 'ol',\n 'optgroup',\n 'option',\n 'output',\n 'p',\n 'picture',\n 'pre',\n 'progress',\n 'q',\n 'rp',\n 'rt',\n 'ruby',\n 's',\n 'samp',\n 'section',\n 'select',\n 'shadow',\n 'small',\n 'source',\n 'spacer',\n 'span',\n 'strike',\n 'strong',\n 'style',\n 'sub',\n 'summary',\n 'sup',\n 'table',\n 'tbody',\n 'td',\n 'template',\n 'textarea',\n 'tfoot',\n 'th',\n 'thead',\n 'time',\n 'tr',\n 'track',\n 'tt',\n 'u',\n 'ul',\n 'var',\n 'video',\n 'wbr',\n]);\n\n// SVG\nexport const svg = freeze([\n 'svg',\n 'a',\n 'altglyph',\n 'altglyphdef',\n 'altglyphitem',\n 'animatecolor',\n 'animatemotion',\n 'animatetransform',\n 'circle',\n 'clippath',\n 'defs',\n 'desc',\n 'ellipse',\n 'filter',\n 'font',\n 'g',\n 'glyph',\n 'glyphref',\n 'hkern',\n 'image',\n 'line',\n 'lineargradient',\n 'marker',\n 'mask',\n 'metadata',\n 'mpath',\n 'path',\n 'pattern',\n 'polygon',\n 'polyline',\n 'radialgradient',\n 'rect',\n 'stop',\n 'style',\n 'switch',\n 'symbol',\n 'text',\n 'textpath',\n 'title',\n 'tref',\n 'tspan',\n 'view',\n 'vkern',\n]);\n\nexport const svgFilters = freeze([\n 'feBlend',\n 'feColorMatrix',\n 'feComponentTransfer',\n 'feComposite',\n 'feConvolveMatrix',\n 'feDiffuseLighting',\n 'feDisplacementMap',\n 'feDistantLight',\n 'feDropShadow',\n 'feFlood',\n 'feFuncA',\n 'feFuncB',\n 'feFuncG',\n 'feFuncR',\n 'feGaussianBlur',\n 'feImage',\n 'feMerge',\n 'feMergeNode',\n 'feMorphology',\n 'feOffset',\n 'fePointLight',\n 'feSpecularLighting',\n 'feSpotLight',\n 'feTile',\n 'feTurbulence',\n]);\n\n// List of SVG elements that are disallowed by default.\n// We still need to know them so that we can do namespace\n// checks properly in case one wants to add them to\n// allow-list.\nexport const svgDisallowed = freeze([\n 'animate',\n 'color-profile',\n 'cursor',\n 'discard',\n 'font-face',\n 'font-face-format',\n 'font-face-name',\n 'font-face-src',\n 'font-face-uri',\n 'foreignobject',\n 'hatch',\n 'hatchpath',\n 'mesh',\n 'meshgradient',\n 'meshpatch',\n 'meshrow',\n 'missing-glyph',\n 'script',\n 'set',\n 'solidcolor',\n 'unknown',\n 'use',\n]);\n\nexport const mathMl = freeze([\n 'math',\n 'menclose',\n 'merror',\n 'mfenced',\n 'mfrac',\n 'mglyph',\n 'mi',\n 'mlabeledtr',\n 'mmultiscripts',\n 'mn',\n 'mo',\n 'mover',\n 'mpadded',\n 'mphantom',\n 'mroot',\n 'mrow',\n 'ms',\n 'mspace',\n 'msqrt',\n 'mstyle',\n 'msub',\n 'msup',\n 'msubsup',\n 'mtable',\n 'mtd',\n 'mtext',\n 'mtr',\n 'munder',\n 'munderover',\n 'mprescripts',\n]);\n\n// Similarly to SVG, we want to know all MathML elements,\n// even those that we disallow by default.\nexport const mathMlDisallowed = freeze([\n 'maction',\n 'maligngroup',\n 'malignmark',\n 'mlongdiv',\n 'mscarries',\n 'mscarry',\n 'msgroup',\n 'mstack',\n 'msline',\n 'msrow',\n 'semantics',\n 'annotation',\n 'annotation-xml',\n 'mprescripts',\n 'none',\n]);\n\nexport const text = freeze(['#text']);\n","import { freeze } from './utils.js';\n\nexport const html = freeze([\n 'accept',\n 'action',\n 'align',\n 'alt',\n 'autocapitalize',\n 'autocomplete',\n 'autopictureinpicture',\n 'autoplay',\n 'background',\n 'bgcolor',\n 'border',\n 'capture',\n 'cellpadding',\n 'cellspacing',\n 'checked',\n 'cite',\n 'class',\n 'clear',\n 'color',\n 'cols',\n 'colspan',\n 'controls',\n 'controlslist',\n 'coords',\n 'crossorigin',\n 'datetime',\n 'decoding',\n 'default',\n 'dir',\n 'disabled',\n 'disablepictureinpicture',\n 'disableremoteplayback',\n 'download',\n 'draggable',\n 'enctype',\n 'enterkeyhint',\n 'face',\n 'for',\n 'headers',\n 'height',\n 'hidden',\n 'high',\n 'href',\n 'hreflang',\n 'id',\n 'inputmode',\n 'integrity',\n 'ismap',\n 'kind',\n 'label',\n 'lang',\n 'list',\n 'loading',\n 'loop',\n 'low',\n 'max',\n 'maxlength',\n 'media',\n 'method',\n 'min',\n 'minlength',\n 'multiple',\n 'muted',\n 'name',\n 'nonce',\n 'noshade',\n 'novalidate',\n 'nowrap',\n 'open',\n 'optimum',\n 'pattern',\n 'placeholder',\n 'playsinline',\n 'popover',\n 'popovertarget',\n 'popovertargetaction',\n 'poster',\n 'preload',\n 'pubdate',\n 'radiogroup',\n 'readonly',\n 'rel',\n 'required',\n 'rev',\n 'reversed',\n 'role',\n 'rows',\n 'rowspan',\n 'spellcheck',\n 'scope',\n 'selected',\n 'shape',\n 'size',\n 'sizes',\n 'span',\n 'srclang',\n 'start',\n 'src',\n 'srcset',\n 'step',\n 'style',\n 'summary',\n 'tabindex',\n 'title',\n 'translate',\n 'type',\n 'usemap',\n 'valign',\n 'value',\n 'width',\n 'wrap',\n 'xmlns',\n 'slot',\n]);\n\nexport const svg = freeze([\n 'accent-height',\n 'accumulate',\n 'additive',\n 'alignment-baseline',\n 'ascent',\n 'attributename',\n 'attributetype',\n 'azimuth',\n 'basefrequency',\n 'baseline-shift',\n 'begin',\n 'bias',\n 'by',\n 'class',\n 'clip',\n 'clippathunits',\n 'clip-path',\n 'clip-rule',\n 'color',\n 'color-interpolation',\n 'color-interpolation-filters',\n 'color-profile',\n 'color-rendering',\n 'cx',\n 'cy',\n 'd',\n 'dx',\n 'dy',\n 'diffuseconstant',\n 'direction',\n 'display',\n 'divisor',\n 'dur',\n 'edgemode',\n 'elevation',\n 'end',\n 'fill',\n 'fill-opacity',\n 'fill-rule',\n 'filter',\n 'filterunits',\n 'flood-color',\n 'flood-opacity',\n 'font-family',\n 'font-size',\n 'font-size-adjust',\n 'font-stretch',\n 'font-style',\n 'font-variant',\n 'font-weight',\n 'fx',\n 'fy',\n 'g1',\n 'g2',\n 'glyph-name',\n 'glyphref',\n 'gradientunits',\n 'gradienttransform',\n 'height',\n 'href',\n 'id',\n 'image-rendering',\n 'in',\n 'in2',\n 'k',\n 'k1',\n 'k2',\n 'k3',\n 'k4',\n 'kerning',\n 'keypoints',\n 'keysplines',\n 'keytimes',\n 'lang',\n 'lengthadjust',\n 'letter-spacing',\n 'kernelmatrix',\n 'kernelunitlength',\n 'lighting-color',\n 'local',\n 'marker-end',\n 'marker-mid',\n 'marker-start',\n 'markerheight',\n 'markerunits',\n 'markerwidth',\n 'maskcontentunits',\n 'maskunits',\n 'max',\n 'mask',\n 'media',\n 'method',\n 'mode',\n 'min',\n 'name',\n 'numoctaves',\n 'offset',\n 'operator',\n 'opacity',\n 'order',\n 'orient',\n 'orientation',\n 'origin',\n 'overflow',\n 'paint-order',\n 'path',\n 'pathlength',\n 'patterncontentunits',\n 'patterntransform',\n 'patternunits',\n 'points',\n 'preservealpha',\n 'preserveaspectratio',\n 'primitiveunits',\n 'r',\n 'rx',\n 'ry',\n 'radius',\n 'refx',\n 'refy',\n 'repeatcount',\n 'repeatdur',\n 'restart',\n 'result',\n 'rotate',\n 'scale',\n 'seed',\n 'shape-rendering',\n 'specularconstant',\n 'specularexponent',\n 'spreadmethod',\n 'startoffset',\n 'stddeviation',\n 'stitchtiles',\n 'stop-color',\n 'stop-opacity',\n 'stroke-dasharray',\n 'stroke-dashoffset',\n 'stroke-linecap',\n 'stroke-linejoin',\n 'stroke-miterlimit',\n 'stroke-opacity',\n 'stroke',\n 'stroke-width',\n 'style',\n 'surfacescale',\n 'systemlanguage',\n 'tabindex',\n 'targetx',\n 'targety',\n 'transform',\n 'transform-origin',\n 'text-anchor',\n 'text-decoration',\n 'text-rendering',\n 'textlength',\n 'type',\n 'u1',\n 'u2',\n 'unicode',\n 'values',\n 'viewbox',\n 'visibility',\n 'version',\n 'vert-adv-y',\n 'vert-origin-x',\n 'vert-origin-y',\n 'width',\n 'word-spacing',\n 'wrap',\n 'writing-mode',\n 'xchannelselector',\n 'ychannelselector',\n 'x',\n 'x1',\n 'x2',\n 'xmlns',\n 'y',\n 'y1',\n 'y2',\n 'z',\n 'zoomandpan',\n]);\n\nexport const mathMl = freeze([\n 'accent',\n 'accentunder',\n 'align',\n 'bevelled',\n 'close',\n 'columnsalign',\n 'columnlines',\n 'columnspan',\n 'denomalign',\n 'depth',\n 'dir',\n 'display',\n 'displaystyle',\n 'encoding',\n 'fence',\n 'frame',\n 'height',\n 'href',\n 'id',\n 'largeop',\n 'length',\n 'linethickness',\n 'lspace',\n 'lquote',\n 'mathbackground',\n 'mathcolor',\n 'mathsize',\n 'mathvariant',\n 'maxsize',\n 'minsize',\n 'movablelimits',\n 'notation',\n 'numalign',\n 'open',\n 'rowalign',\n 'rowlines',\n 'rowspacing',\n 'rowspan',\n 'rspace',\n 'rquote',\n 'scriptlevel',\n 'scriptminsize',\n 'scriptsizemultiplier',\n 'selection',\n 'separator',\n 'separators',\n 'stretchy',\n 'subscriptshift',\n 'supscriptshift',\n 'symmetric',\n 'voffset',\n 'width',\n 'xmlns',\n]);\n\nexport const xml = freeze([\n 'xlink:href',\n 'xml:id',\n 'xlink:title',\n 'xml:space',\n 'xmlns:xlink',\n]);\n","import { seal } from './utils.js';\n\n// eslint-disable-next-line unicorn/better-regex\nexport const MUSTACHE_EXPR = seal(/\\{\\{[\\w\\W]*|[\\w\\W]*\\}\\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode\nexport const ERB_EXPR = seal(/<%[\\w\\W]*|[\\w\\W]*%>/gm);\nexport const TMPLIT_EXPR = seal(/\\${[\\w\\W]*}/gm);\nexport const DATA_ATTR = seal(/^data-[\\-\\w.\\u00B7-\\uFFFF]/); // eslint-disable-line no-useless-escape\nexport const ARIA_ATTR = seal(/^aria-[\\-\\w]+$/); // eslint-disable-line no-useless-escape\nexport const IS_ALLOWED_URI = seal(\n /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\\-]+(?:[^a-z+.\\-:]|$))/i // eslint-disable-line no-useless-escape\n);\nexport const IS_SCRIPT_OR_DATA = seal(/^(?:\\w+script|data):/i);\nexport const ATTR_WHITESPACE = seal(\n /[\\u0000-\\u0020\\u00A0\\u1680\\u180E\\u2000-\\u2029\\u205F\\u3000]/g // eslint-disable-line no-control-regex\n);\nexport const DOCTYPE_NAME = seal(/^html$/i);\nexport const CUSTOM_ELEMENT = seal(/^[a-z][.\\w]*(-[.\\w]+)+$/i);\n","import * as TAGS from './tags.js';\nimport * as ATTRS from './attrs.js';\nimport * as EXPRESSIONS from './regexp.js';\nimport {\n addToSet,\n clone,\n entries,\n freeze,\n arrayForEach,\n arrayPop,\n arrayPush,\n stringMatch,\n stringReplace,\n stringToLowerCase,\n stringToString,\n stringIndexOf,\n stringTrim,\n regExpTest,\n typeErrorCreate,\n lookupGetter,\n create,\n objectHasOwnProperty,\n} from './utils.js';\n\n// https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType\nconst NODE_TYPE = {\n element: 1,\n attribute: 2,\n text: 3,\n cdataSection: 4,\n entityReference: 5, // Deprecated\n entityNode: 6, // Deprecated\n progressingInstruction: 7,\n comment: 8,\n document: 9,\n documentType: 10,\n documentFragment: 11,\n notation: 12, // Deprecated\n};\n\nconst getGlobal = function () {\n return typeof window === 'undefined' ? null : window;\n};\n\n/**\n * Creates a no-op policy for internal use only.\n * Don't export this function outside this module!\n * @param {TrustedTypePolicyFactory} trustedTypes The policy factory.\n * @param {HTMLScriptElement} purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).\n * @return {TrustedTypePolicy} The policy created (or null, if Trusted Types\n * are not supported or creating the policy failed).\n */\nconst _createTrustedTypesPolicy = function (trustedTypes, purifyHostElement) {\n if (\n typeof trustedTypes !== 'object' ||\n typeof trustedTypes.createPolicy !== 'function'\n ) {\n return null;\n }\n\n // Allow the callers to control the unique policy name\n // by adding a data-tt-policy-suffix to the script element with the DOMPurify.\n // Policy creation with duplicate names throws in Trusted Types.\n let suffix = null;\n const ATTR_NAME = 'data-tt-policy-suffix';\n if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {\n suffix = purifyHostElement.getAttribute(ATTR_NAME);\n }\n\n const policyName = 'dompurify' + (suffix ? '#' + suffix : '');\n\n try {\n return trustedTypes.createPolicy(policyName, {\n createHTML(html) {\n return html;\n },\n createScriptURL(scriptUrl) {\n return scriptUrl;\n },\n });\n } catch (_) {\n // Policy creation failed (most likely another DOMPurify script has\n // already run). Skip creating the policy, as this will only cause errors\n // if TT are enforced.\n console.warn(\n 'TrustedTypes policy ' + policyName + ' could not be created.'\n );\n return null;\n }\n};\n\nfunction createDOMPurify(window = getGlobal()) {\n const DOMPurify = (root) => createDOMPurify(root);\n\n /**\n * Version label, exposed for easier checks\n * if DOMPurify is up to date or not\n */\n DOMPurify.version = VERSION;\n\n /**\n * Array of elements that DOMPurify removed during sanitation.\n * Empty if nothing was removed.\n */\n DOMPurify.removed = [];\n\n if (\n !window ||\n !window.document ||\n window.document.nodeType !== NODE_TYPE.document\n ) {\n // Not running in a browser, provide a factory function\n // so that you can pass your own Window\n DOMPurify.isSupported = false;\n\n return DOMPurify;\n }\n\n let { document } = window;\n\n const originalDocument = document;\n const currentScript = originalDocument.currentScript;\n const {\n DocumentFragment,\n HTMLTemplateElement,\n Node,\n Element,\n NodeFilter,\n NamedNodeMap = window.NamedNodeMap || window.MozNamedAttrMap,\n HTMLFormElement,\n DOMParser,\n trustedTypes,\n } = window;\n\n const ElementPrototype = Element.prototype;\n\n const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');\n const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');\n const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');\n const getParentNode = lookupGetter(ElementPrototype, 'parentNode');\n\n // As per issue #47, the web-components registry is inherited by a\n // new document created via createHTMLDocument. As per the spec\n // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)\n // a new empty registry is used when creating a template contents owner\n // document, so we use that as our parent document to ensure nothing\n // is inherited.\n if (typeof HTMLTemplateElement === 'function') {\n const template = document.createElement('template');\n if (template.content && template.content.ownerDocument) {\n document = template.content.ownerDocument;\n }\n }\n\n let trustedTypesPolicy;\n let emptyHTML = '';\n\n const {\n implementation,\n createNodeIterator,\n createDocumentFragment,\n getElementsByTagName,\n } = document;\n const { importNode } = originalDocument;\n\n let hooks = {};\n\n /**\n * Expose whether this browser supports running the full DOMPurify.\n */\n DOMPurify.isSupported =\n typeof entries === 'function' &&\n typeof getParentNode === 'function' &&\n implementation &&\n implementation.createHTMLDocument !== undefined;\n\n const {\n MUSTACHE_EXPR,\n ERB_EXPR,\n TMPLIT_EXPR,\n DATA_ATTR,\n ARIA_ATTR,\n IS_SCRIPT_OR_DATA,\n ATTR_WHITESPACE,\n CUSTOM_ELEMENT,\n } = EXPRESSIONS;\n\n let { IS_ALLOWED_URI } = EXPRESSIONS;\n\n /**\n * We consider the elements and attributes below to be safe. Ideally\n * don't add any new ones but feel free to remove unwanted ones.\n */\n\n /* allowed element names */\n let ALLOWED_TAGS = null;\n const DEFAULT_ALLOWED_TAGS = addToSet({}, [\n ...TAGS.html,\n ...TAGS.svg,\n ...TAGS.svgFilters,\n ...TAGS.mathMl,\n ...TAGS.text,\n ]);\n\n /* Allowed attribute names */\n let ALLOWED_ATTR = null;\n const DEFAULT_ALLOWED_ATTR = addToSet({}, [\n ...ATTRS.html,\n ...ATTRS.svg,\n ...ATTRS.mathMl,\n ...ATTRS.xml,\n ]);\n\n /*\n * Configure how DOMPUrify should handle custom elements and their attributes as well as customized built-in elements.\n * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)\n * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)\n * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.\n */\n let CUSTOM_ELEMENT_HANDLING = Object.seal(\n create(null, {\n tagNameCheck: {\n writable: true,\n configurable: false,\n enumerable: true,\n value: null,\n },\n attributeNameCheck: {\n writable: true,\n configurable: false,\n enumerable: true,\n value: null,\n },\n allowCustomizedBuiltInElements: {\n writable: true,\n configurable: false,\n enumerable: true,\n value: false,\n },\n })\n );\n\n /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */\n let FORBID_TAGS = null;\n\n /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */\n let FORBID_ATTR = null;\n\n /* Decide if ARIA attributes are okay */\n let ALLOW_ARIA_ATTR = true;\n\n /* Decide if custom data attributes are okay */\n let ALLOW_DATA_ATTR = true;\n\n /* Decide if unknown protocols are okay */\n let ALLOW_UNKNOWN_PROTOCOLS = false;\n\n /* Decide if self-closing tags in attributes are allowed.\n * Usually removed due to a mXSS issue in jQuery 3.0 */\n let ALLOW_SELF_CLOSE_IN_ATTR = true;\n\n /* Output should be safe for common template engines.\n * This means, DOMPurify removes data attributes, mustaches and ERB\n */\n let SAFE_FOR_TEMPLATES = false;\n\n /* Output should be safe even for XML used within HTML and alike.\n * This means, DOMPurify removes comments when containing risky content.\n */\n let SAFE_FOR_XML = true;\n\n /* Decide if document with ... should be returned */\n let WHOLE_DOCUMENT = false;\n\n /* Track whether config is already set on this instance of DOMPurify. */\n let SET_CONFIG = false;\n\n /* Decide if all elements (e.g. style, script) must be children of\n * document.body. By default, browsers might move them to document.head */\n let FORCE_BODY = false;\n\n /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html\n * string (or a TrustedHTML object if Trusted Types are supported).\n * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead\n */\n let RETURN_DOM = false;\n\n /* Decide if a DOM `DocumentFragment` should be returned, instead of a html\n * string (or a TrustedHTML object if Trusted Types are supported) */\n let RETURN_DOM_FRAGMENT = false;\n\n /* Try to return a Trusted Type object instead of a string, return a string in\n * case Trusted Types are not supported */\n let RETURN_TRUSTED_TYPE = false;\n\n /* Output should be free from DOM clobbering attacks?\n * This sanitizes markups named with colliding, clobberable built-in DOM APIs.\n */\n let SANITIZE_DOM = true;\n\n /* Achieve full DOM Clobbering protection by isolating the namespace of named\n * properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules.\n *\n * HTML/DOM spec rules that enable DOM Clobbering:\n * - Named Access on Window (§7.3.3)\n * - DOM Tree Accessors (§3.1.5)\n * - Form Element Parent-Child Relations (§4.10.3)\n * - Iframe srcdoc / Nested WindowProxies (§4.8.5)\n * - HTMLCollection (§4.2.10.2)\n *\n * Namespace isolation is implemented by prefixing `id` and `name` attributes\n * with a constant string, i.e., `user-content-`\n */\n let SANITIZE_NAMED_PROPS = false;\n const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';\n\n /* Keep element content when removing element? */\n let KEEP_CONTENT = true;\n\n /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead\n * of importing it into a new Document and returning a sanitized copy */\n let IN_PLACE = false;\n\n /* Allow usage of profiles like html, svg and mathMl */\n let USE_PROFILES = {};\n\n /* Tags to ignore content of when KEEP_CONTENT is true */\n let FORBID_CONTENTS = null;\n const DEFAULT_FORBID_CONTENTS = addToSet({}, [\n 'annotation-xml',\n 'audio',\n 'colgroup',\n 'desc',\n 'foreignobject',\n 'head',\n 'iframe',\n 'math',\n 'mi',\n 'mn',\n 'mo',\n 'ms',\n 'mtext',\n 'noembed',\n 'noframes',\n 'noscript',\n 'plaintext',\n 'script',\n 'style',\n 'svg',\n 'template',\n 'thead',\n 'title',\n 'video',\n 'xmp',\n ]);\n\n /* Tags that are safe for data: URIs */\n let DATA_URI_TAGS = null;\n const DEFAULT_DATA_URI_TAGS = addToSet({}, [\n 'audio',\n 'video',\n 'img',\n 'source',\n 'image',\n 'track',\n ]);\n\n /* Attributes safe for values like \"javascript:\" */\n let URI_SAFE_ATTRIBUTES = null;\n const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, [\n 'alt',\n 'class',\n 'for',\n 'id',\n 'label',\n 'name',\n 'pattern',\n 'placeholder',\n 'role',\n 'summary',\n 'title',\n 'value',\n 'style',\n 'xmlns',\n ]);\n\n const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';\n const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';\n const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';\n /* Document namespace */\n let NAMESPACE = HTML_NAMESPACE;\n let IS_EMPTY_INPUT = false;\n\n /* Allowed XHTML+XML namespaces */\n let ALLOWED_NAMESPACES = null;\n const DEFAULT_ALLOWED_NAMESPACES = addToSet(\n {},\n [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE],\n stringToString\n );\n\n /* Parsing of strict XHTML documents */\n let PARSER_MEDIA_TYPE = null;\n const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];\n const DEFAULT_PARSER_MEDIA_TYPE = 'text/html';\n let transformCaseFunc = null;\n\n /* Keep a reference to config to pass to hooks */\n let CONFIG = null;\n\n /* Ideally, do not touch anything below this line */\n /* ______________________________________________ */\n\n const formElement = document.createElement('form');\n\n const isRegexOrFunction = function (testValue) {\n return testValue instanceof RegExp || testValue instanceof Function;\n };\n\n /**\n * _parseConfig\n *\n * @param {Object} cfg optional config literal\n */\n // eslint-disable-next-line complexity\n const _parseConfig = function (cfg = {}) {\n if (CONFIG && CONFIG === cfg) {\n return;\n }\n\n /* Shield configuration object from tampering */\n if (!cfg || typeof cfg !== 'object') {\n cfg = {};\n }\n\n /* Shield configuration object from prototype pollution */\n cfg = clone(cfg);\n\n PARSER_MEDIA_TYPE =\n // eslint-disable-next-line unicorn/prefer-includes\n SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1\n ? DEFAULT_PARSER_MEDIA_TYPE\n : cfg.PARSER_MEDIA_TYPE;\n\n // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.\n transformCaseFunc =\n PARSER_MEDIA_TYPE === 'application/xhtml+xml'\n ? stringToString\n : stringToLowerCase;\n\n /* Set configuration parameters */\n ALLOWED_TAGS = objectHasOwnProperty(cfg, 'ALLOWED_TAGS')\n ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc)\n : DEFAULT_ALLOWED_TAGS;\n ALLOWED_ATTR = objectHasOwnProperty(cfg, 'ALLOWED_ATTR')\n ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc)\n : DEFAULT_ALLOWED_ATTR;\n ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, 'ALLOWED_NAMESPACES')\n ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString)\n : DEFAULT_ALLOWED_NAMESPACES;\n URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR')\n ? addToSet(\n clone(DEFAULT_URI_SAFE_ATTRIBUTES), // eslint-disable-line indent\n cfg.ADD_URI_SAFE_ATTR, // eslint-disable-line indent\n transformCaseFunc // eslint-disable-line indent\n ) // eslint-disable-line indent\n : DEFAULT_URI_SAFE_ATTRIBUTES;\n DATA_URI_TAGS = objectHasOwnProperty(cfg, 'ADD_DATA_URI_TAGS')\n ? addToSet(\n clone(DEFAULT_DATA_URI_TAGS), // eslint-disable-line indent\n cfg.ADD_DATA_URI_TAGS, // eslint-disable-line indent\n transformCaseFunc // eslint-disable-line indent\n ) // eslint-disable-line indent\n : DEFAULT_DATA_URI_TAGS;\n FORBID_CONTENTS = objectHasOwnProperty(cfg, 'FORBID_CONTENTS')\n ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc)\n : DEFAULT_FORBID_CONTENTS;\n FORBID_TAGS = objectHasOwnProperty(cfg, 'FORBID_TAGS')\n ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc)\n : {};\n FORBID_ATTR = objectHasOwnProperty(cfg, 'FORBID_ATTR')\n ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc)\n : {};\n USE_PROFILES = objectHasOwnProperty(cfg, 'USE_PROFILES')\n ? cfg.USE_PROFILES\n : false;\n ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true\n ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true\n ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false\n ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true\n SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false\n SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false; // Default true\n WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false\n RETURN_DOM = cfg.RETURN_DOM || false; // Default false\n RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false\n RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false\n FORCE_BODY = cfg.FORCE_BODY || false; // Default false\n SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true\n SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false\n KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true\n IN_PLACE = cfg.IN_PLACE || false; // Default false\n IS_ALLOWED_URI = cfg.ALLOWED_URI_REGEXP || EXPRESSIONS.IS_ALLOWED_URI;\n NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;\n CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {};\n if (\n cfg.CUSTOM_ELEMENT_HANDLING &&\n isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)\n ) {\n CUSTOM_ELEMENT_HANDLING.tagNameCheck =\n cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;\n }\n\n if (\n cfg.CUSTOM_ELEMENT_HANDLING &&\n isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)\n ) {\n CUSTOM_ELEMENT_HANDLING.attributeNameCheck =\n cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck;\n }\n\n if (\n cfg.CUSTOM_ELEMENT_HANDLING &&\n typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements ===\n 'boolean'\n ) {\n CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements =\n cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements;\n }\n\n if (SAFE_FOR_TEMPLATES) {\n ALLOW_DATA_ATTR = false;\n }\n\n if (RETURN_DOM_FRAGMENT) {\n RETURN_DOM = true;\n }\n\n /* Parse profile info */\n if (USE_PROFILES) {\n ALLOWED_TAGS = addToSet({}, TAGS.text);\n ALLOWED_ATTR = [];\n if (USE_PROFILES.html === true) {\n addToSet(ALLOWED_TAGS, TAGS.html);\n addToSet(ALLOWED_ATTR, ATTRS.html);\n }\n\n if (USE_PROFILES.svg === true) {\n addToSet(ALLOWED_TAGS, TAGS.svg);\n addToSet(ALLOWED_ATTR, ATTRS.svg);\n addToSet(ALLOWED_ATTR, ATTRS.xml);\n }\n\n if (USE_PROFILES.svgFilters === true) {\n addToSet(ALLOWED_TAGS, TAGS.svgFilters);\n addToSet(ALLOWED_ATTR, ATTRS.svg);\n addToSet(ALLOWED_ATTR, ATTRS.xml);\n }\n\n if (USE_PROFILES.mathMl === true) {\n addToSet(ALLOWED_TAGS, TAGS.mathMl);\n addToSet(ALLOWED_ATTR, ATTRS.mathMl);\n addToSet(ALLOWED_ATTR, ATTRS.xml);\n }\n }\n\n /* Merge configuration parameters */\n if (cfg.ADD_TAGS) {\n if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {\n ALLOWED_TAGS = clone(ALLOWED_TAGS);\n }\n\n addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);\n }\n\n if (cfg.ADD_ATTR) {\n if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {\n ALLOWED_ATTR = clone(ALLOWED_ATTR);\n }\n\n addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);\n }\n\n if (cfg.ADD_URI_SAFE_ATTR) {\n addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);\n }\n\n if (cfg.FORBID_CONTENTS) {\n if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {\n FORBID_CONTENTS = clone(FORBID_CONTENTS);\n }\n\n addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);\n }\n\n /* Add #text in case KEEP_CONTENT is set to true */\n if (KEEP_CONTENT) {\n ALLOWED_TAGS['#text'] = true;\n }\n\n /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */\n if (WHOLE_DOCUMENT) {\n addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);\n }\n\n /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */\n if (ALLOWED_TAGS.table) {\n addToSet(ALLOWED_TAGS, ['tbody']);\n delete FORBID_TAGS.tbody;\n }\n\n if (cfg.TRUSTED_TYPES_POLICY) {\n if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') {\n throw typeErrorCreate(\n 'TRUSTED_TYPES_POLICY configuration option must provide a \"createHTML\" hook.'\n );\n }\n\n if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {\n throw typeErrorCreate(\n 'TRUSTED_TYPES_POLICY configuration option must provide a \"createScriptURL\" hook.'\n );\n }\n\n // Overwrite existing TrustedTypes policy.\n trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;\n\n // Sign local variables required by `sanitize`.\n emptyHTML = trustedTypesPolicy.createHTML('');\n } else {\n // Uninitialized policy, attempt to initialize the internal dompurify policy.\n if (trustedTypesPolicy === undefined) {\n trustedTypesPolicy = _createTrustedTypesPolicy(\n trustedTypes,\n currentScript\n );\n }\n\n // If creating the internal policy succeeded sign internal variables.\n if (trustedTypesPolicy !== null && typeof emptyHTML === 'string') {\n emptyHTML = trustedTypesPolicy.createHTML('');\n }\n }\n\n // Prevent further manipulation of configuration.\n // Not available in IE8, Safari 5, etc.\n if (freeze) {\n freeze(cfg);\n }\n\n CONFIG = cfg;\n };\n\n const MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, [\n 'mi',\n 'mo',\n 'mn',\n 'ms',\n 'mtext',\n ]);\n\n const HTML_INTEGRATION_POINTS = addToSet({}, [\n 'foreignobject',\n 'annotation-xml',\n ]);\n\n // Certain elements are allowed in both SVG and HTML\n // namespace. We need to specify them explicitly\n // so that they don't get erroneously deleted from\n // HTML namespace.\n const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, [\n 'title',\n 'style',\n 'font',\n 'a',\n 'script',\n ]);\n\n /* Keep track of all possible SVG and MathML tags\n * so that we can perform the namespace checks\n * correctly. */\n const ALL_SVG_TAGS = addToSet({}, [\n ...TAGS.svg,\n ...TAGS.svgFilters,\n ...TAGS.svgDisallowed,\n ]);\n const ALL_MATHML_TAGS = addToSet({}, [\n ...TAGS.mathMl,\n ...TAGS.mathMlDisallowed,\n ]);\n\n /**\n * @param {Element} element a DOM element whose namespace is being checked\n * @returns {boolean} Return false if the element has a\n * namespace that a spec-compliant parser would never\n * return. Return true otherwise.\n */\n const _checkValidNamespace = function (element) {\n let parent = getParentNode(element);\n\n // In JSDOM, if we're inside shadow DOM, then parentNode\n // can be null. We just simulate parent in this case.\n if (!parent || !parent.tagName) {\n parent = {\n namespaceURI: NAMESPACE,\n tagName: 'template',\n };\n }\n\n const tagName = stringToLowerCase(element.tagName);\n const parentTagName = stringToLowerCase(parent.tagName);\n\n if (!ALLOWED_NAMESPACES[element.namespaceURI]) {\n return false;\n }\n\n if (element.namespaceURI === SVG_NAMESPACE) {\n // The only way to switch from HTML namespace to SVG\n // is via . If it happens via any other tag, then\n // it should be killed.\n if (parent.namespaceURI === HTML_NAMESPACE) {\n return tagName === 'svg';\n }\n\n // The only way to switch from MathML to SVG is via`\n // svg if parent is either or MathML\n // text integration points.\n if (parent.namespaceURI === MATHML_NAMESPACE) {\n return (\n tagName === 'svg' &&\n (parentTagName === 'annotation-xml' ||\n MATHML_TEXT_INTEGRATION_POINTS[parentTagName])\n );\n }\n\n // We only allow elements that are defined in SVG\n // spec. All others are disallowed in SVG namespace.\n return Boolean(ALL_SVG_TAGS[tagName]);\n }\n\n if (element.namespaceURI === MATHML_NAMESPACE) {\n // The only way to switch from HTML namespace to MathML\n // is via . If it happens via any other tag, then\n // it should be killed.\n if (parent.namespaceURI === HTML_NAMESPACE) {\n return tagName === 'math';\n }\n\n // The only way to switch from SVG to MathML is via\n // and HTML integration points\n if (parent.namespaceURI === SVG_NAMESPACE) {\n return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];\n }\n\n // We only allow elements that are defined in MathML\n // spec. All others are disallowed in MathML namespace.\n return Boolean(ALL_MATHML_TAGS[tagName]);\n }\n\n if (element.namespaceURI === HTML_NAMESPACE) {\n // The only way to switch from SVG to HTML is via\n // HTML integration points, and from MathML to HTML\n // is via MathML text integration points\n if (\n parent.namespaceURI === SVG_NAMESPACE &&\n !HTML_INTEGRATION_POINTS[parentTagName]\n ) {\n return false;\n }\n\n if (\n parent.namespaceURI === MATHML_NAMESPACE &&\n !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]\n ) {\n return false;\n }\n\n // We disallow tags that are specific for MathML\n // or SVG and should never appear in HTML namespace\n return (\n !ALL_MATHML_TAGS[tagName] &&\n (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName])\n );\n }\n\n // For XHTML and XML documents that support custom namespaces\n if (\n PARSER_MEDIA_TYPE === 'application/xhtml+xml' &&\n ALLOWED_NAMESPACES[element.namespaceURI]\n ) {\n return true;\n }\n\n // The code should never reach this place (this means\n // that the element somehow got namespace that is not\n // HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES).\n // Return false just in case.\n return false;\n };\n\n /**\n * _forceRemove\n *\n * @param {Node} node a DOM node\n */\n const _forceRemove = function (node) {\n arrayPush(DOMPurify.removed, { element: node });\n\n try {\n // eslint-disable-next-line unicorn/prefer-dom-node-remove\n node.parentNode.removeChild(node);\n } catch (_) {\n node.remove();\n }\n };\n\n /**\n * _removeAttribute\n *\n * @param {String} name an Attribute name\n * @param {Node} node a DOM node\n */\n const _removeAttribute = function (name, node) {\n try {\n arrayPush(DOMPurify.removed, {\n attribute: node.getAttributeNode(name),\n from: node,\n });\n } catch (_) {\n arrayPush(DOMPurify.removed, {\n attribute: null,\n from: node,\n });\n }\n\n node.removeAttribute(name);\n\n // We void attribute values for unremovable \"is\"\" attributes\n if (name === 'is' && !ALLOWED_ATTR[name]) {\n if (RETURN_DOM || RETURN_DOM_FRAGMENT) {\n try {\n _forceRemove(node);\n } catch (_) {}\n } else {\n try {\n node.setAttribute(name, '');\n } catch (_) {}\n }\n }\n };\n\n /**\n * _initDocument\n *\n * @param {String} dirty a string of dirty markup\n * @return {Document} a DOM, filled with the dirty markup\n */\n const _initDocument = function (dirty) {\n /* Create a HTML document */\n let doc = null;\n let leadingWhitespace = null;\n\n if (FORCE_BODY) {\n dirty = '' + dirty;\n } else {\n /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */\n const matches = stringMatch(dirty, /^[\\r\\n\\t ]+/);\n leadingWhitespace = matches && matches[0];\n }\n\n if (\n PARSER_MEDIA_TYPE === 'application/xhtml+xml' &&\n NAMESPACE === HTML_NAMESPACE\n ) {\n // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)\n dirty =\n '' +\n dirty +\n '';\n }\n\n const dirtyPayload = trustedTypesPolicy\n ? trustedTypesPolicy.createHTML(dirty)\n : dirty;\n /*\n * Use the DOMParser API by default, fallback later if needs be\n * DOMParser not work for svg when has multiple root element.\n */\n if (NAMESPACE === HTML_NAMESPACE) {\n try {\n doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);\n } catch (_) {}\n }\n\n /* Use createHTMLDocument in case DOMParser is not available */\n if (!doc || !doc.documentElement) {\n doc = implementation.createDocument(NAMESPACE, 'template', null);\n try {\n doc.documentElement.innerHTML = IS_EMPTY_INPUT\n ? emptyHTML\n : dirtyPayload;\n } catch (_) {\n // Syntax error if dirtyPayload is invalid xml\n }\n }\n\n const body = doc.body || doc.documentElement;\n\n if (dirty && leadingWhitespace) {\n body.insertBefore(\n document.createTextNode(leadingWhitespace),\n body.childNodes[0] || null\n );\n }\n\n /* Work on whole document or just its body */\n if (NAMESPACE === HTML_NAMESPACE) {\n return getElementsByTagName.call(\n doc,\n WHOLE_DOCUMENT ? 'html' : 'body'\n )[0];\n }\n\n return WHOLE_DOCUMENT ? doc.documentElement : body;\n };\n\n /**\n * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document.\n *\n * @param {Node} root The root element or node to start traversing on.\n * @return {NodeIterator} The created NodeIterator\n */\n const _createNodeIterator = function (root) {\n return createNodeIterator.call(\n root.ownerDocument || root,\n root,\n // eslint-disable-next-line no-bitwise\n NodeFilter.SHOW_ELEMENT |\n NodeFilter.SHOW_COMMENT |\n NodeFilter.SHOW_TEXT |\n NodeFilter.SHOW_PROCESSING_INSTRUCTION |\n NodeFilter.SHOW_CDATA_SECTION,\n null\n );\n };\n\n /**\n * _isClobbered\n *\n * @param {Node} elm element to check for clobbering attacks\n * @return {Boolean} true if clobbered, false if safe\n */\n const _isClobbered = function (elm) {\n return (\n elm instanceof HTMLFormElement &&\n (typeof elm.nodeName !== 'string' ||\n typeof elm.textContent !== 'string' ||\n typeof elm.removeChild !== 'function' ||\n !(elm.attributes instanceof NamedNodeMap) ||\n typeof elm.removeAttribute !== 'function' ||\n typeof elm.setAttribute !== 'function' ||\n typeof elm.namespaceURI !== 'string' ||\n typeof elm.insertBefore !== 'function' ||\n typeof elm.hasChildNodes !== 'function')\n );\n };\n\n /**\n * Checks whether the given object is a DOM node.\n *\n * @param {Node} object object to check whether it's a DOM node\n * @return {Boolean} true is object is a DOM node\n */\n const _isNode = function (object) {\n return typeof Node === 'function' && object instanceof Node;\n };\n\n /**\n * _executeHook\n * Execute user configurable hooks\n *\n * @param {String} entryPoint Name of the hook's entry point\n * @param {Node} currentNode node to work on with the hook\n * @param {Object} data additional hook parameters\n */\n const _executeHook = function (entryPoint, currentNode, data) {\n if (!hooks[entryPoint]) {\n return;\n }\n\n arrayForEach(hooks[entryPoint], (hook) => {\n hook.call(DOMPurify, currentNode, data, CONFIG);\n });\n };\n\n /**\n * _sanitizeElements\n *\n * @protect nodeName\n * @protect textContent\n * @protect removeChild\n *\n * @param {Node} currentNode to check for permission to exist\n * @return {Boolean} true if node was killed, false if left alive\n */\n const _sanitizeElements = function (currentNode) {\n let content = null;\n\n /* Execute a hook if present */\n _executeHook('beforeSanitizeElements', currentNode, null);\n\n /* Check if element is clobbered or can clobber */\n if (_isClobbered(currentNode)) {\n _forceRemove(currentNode);\n return true;\n }\n\n /* Now let's check the element's type and name */\n const tagName = transformCaseFunc(currentNode.nodeName);\n\n /* Execute a hook if present */\n _executeHook('uponSanitizeElement', currentNode, {\n tagName,\n allowedTags: ALLOWED_TAGS,\n });\n\n /* Detect mXSS attempts abusing namespace confusion */\n if (\n currentNode.hasChildNodes() &&\n !_isNode(currentNode.firstElementChild) &&\n regExpTest(/<[/\\w]/g, currentNode.innerHTML) &&\n regExpTest(/<[/\\w]/g, currentNode.textContent)\n ) {\n _forceRemove(currentNode);\n return true;\n }\n\n /* Remove any ocurrence of processing instructions */\n if (currentNode.nodeType === NODE_TYPE.progressingInstruction) {\n _forceRemove(currentNode);\n return true;\n }\n\n /* Remove any kind of possibly harmful comments */\n if (\n SAFE_FOR_XML &&\n currentNode.nodeType === NODE_TYPE.comment &&\n regExpTest(/<[/\\w]/g, currentNode.data)\n ) {\n _forceRemove(currentNode);\n return true;\n }\n\n /* Remove element if anything forbids its presence */\n if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {\n /* Check if we have a custom element to handle */\n if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {\n if (\n CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp &&\n regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)\n ) {\n return false;\n }\n\n if (\n CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function &&\n CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)\n ) {\n return false;\n }\n }\n\n /* Keep content except for bad-listed elements */\n if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {\n const parentNode = getParentNode(currentNode) || currentNode.parentNode;\n const childNodes = getChildNodes(currentNode) || currentNode.childNodes;\n\n if (childNodes && parentNode) {\n const childCount = childNodes.length;\n\n for (let i = childCount - 1; i >= 0; --i) {\n const childClone = cloneNode(childNodes[i], true);\n childClone.__removalCount = (currentNode.__removalCount || 0) + 1;\n parentNode.insertBefore(childClone, getNextSibling(currentNode));\n }\n }\n }\n\n _forceRemove(currentNode);\n return true;\n }\n\n /* Check whether element has a valid namespace */\n if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {\n _forceRemove(currentNode);\n return true;\n }\n\n /* Make sure that older browsers don't get fallback-tag mXSS */\n if (\n (tagName === 'noscript' ||\n tagName === 'noembed' ||\n tagName === 'noframes') &&\n regExpTest(/<\\/no(script|embed|frames)/i, currentNode.innerHTML)\n ) {\n _forceRemove(currentNode);\n return true;\n }\n\n /* Sanitize element content to be template-safe */\n if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {\n /* Get the element's text content */\n content = currentNode.textContent;\n\n arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], (expr) => {\n content = stringReplace(content, expr, ' ');\n });\n\n if (currentNode.textContent !== content) {\n arrayPush(DOMPurify.removed, { element: currentNode.cloneNode() });\n currentNode.textContent = content;\n }\n }\n\n /* Execute a hook if present */\n _executeHook('afterSanitizeElements', currentNode, null);\n\n return false;\n };\n\n /**\n * _isValidAttribute\n *\n * @param {string} lcTag Lowercase tag name of containing element.\n * @param {string} lcName Lowercase attribute name.\n * @param {string} value Attribute value.\n * @return {Boolean} Returns true if `value` is valid, otherwise false.\n */\n // eslint-disable-next-line complexity\n const _isValidAttribute = function (lcTag, lcName, value) {\n /* Make sure attribute cannot clobber */\n if (\n SANITIZE_DOM &&\n (lcName === 'id' || lcName === 'name') &&\n (value in document || value in formElement)\n ) {\n return false;\n }\n\n /* Allow valid data-* attributes: At least one character after \"-\"\n (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)\n XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)\n We don't need to check the value; it's always URI safe. */\n if (\n ALLOW_DATA_ATTR &&\n !FORBID_ATTR[lcName] &&\n regExpTest(DATA_ATTR, lcName)\n ) {\n // This attribute is safe\n } else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR, lcName)) {\n // This attribute is safe\n /* Otherwise, check the name is permitted */\n } else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) {\n if (\n // First condition does a very basic check if a) it's basically a valid custom element tagname AND\n // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck\n // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck\n (_isBasicCustomElement(lcTag) &&\n ((CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp &&\n regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag)) ||\n (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function &&\n CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag))) &&\n ((CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp &&\n regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName)) ||\n (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function &&\n CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName)))) ||\n // Alternative, second condition checks if it's an `is`-attribute, AND\n // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck\n (lcName === 'is' &&\n CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements &&\n ((CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp &&\n regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value)) ||\n (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function &&\n CUSTOM_ELEMENT_HANDLING.tagNameCheck(value))))\n ) {\n // If user has supplied a regexp or function in CUSTOM_ELEMENT_HANDLING.tagNameCheck, we need to also allow derived custom elements using the same tagName test.\n // Additionally, we need to allow attributes passing the CUSTOM_ELEMENT_HANDLING.attributeNameCheck user has configured, as custom elements can define these at their own discretion.\n } else {\n return false;\n }\n /* Check value is safe. First, is attr inert? If so, is safe */\n } else if (URI_SAFE_ATTRIBUTES[lcName]) {\n // This attribute is safe\n /* Check no script, data or unknown possibly unsafe URI\n unless we know URI values are safe for that attribute */\n } else if (\n regExpTest(IS_ALLOWED_URI, stringReplace(value, ATTR_WHITESPACE, ''))\n ) {\n // This attribute is safe\n /* Keep image data URIs alive if src/xlink:href is allowed */\n /* Further prevent gadget XSS for dynamically built script tags */\n } else if (\n (lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') &&\n lcTag !== 'script' &&\n stringIndexOf(value, 'data:') === 0 &&\n DATA_URI_TAGS[lcTag]\n ) {\n // This attribute is safe\n /* Allow unknown protocols: This provides support for links that\n are handled by protocol handlers which may be unknown ahead of\n time, e.g. fb:, spotify: */\n } else if (\n ALLOW_UNKNOWN_PROTOCOLS &&\n !regExpTest(IS_SCRIPT_OR_DATA, stringReplace(value, ATTR_WHITESPACE, ''))\n ) {\n // This attribute is safe\n /* Check for binary attributes */\n } else if (value) {\n return false;\n } else {\n // Binary attributes are safe at this point\n /* Anything else, presume unsafe, do not add it back */\n }\n\n return true;\n };\n\n /**\n * _isBasicCustomElement\n * checks if at least one dash is included in tagName, and it's not the first char\n * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name\n *\n * @param {string} tagName name of the tag of the node to sanitize\n * @returns {boolean} Returns true if the tag name meets the basic criteria for a custom element, otherwise false.\n */\n const _isBasicCustomElement = function (tagName) {\n return tagName !== 'annotation-xml' && stringMatch(tagName, CUSTOM_ELEMENT);\n };\n\n /**\n * _sanitizeAttributes\n *\n * @protect attributes\n * @protect nodeName\n * @protect removeAttribute\n * @protect setAttribute\n *\n * @param {Node} currentNode to sanitize\n */\n const _sanitizeAttributes = function (currentNode) {\n /* Execute a hook if present */\n _executeHook('beforeSanitizeAttributes', currentNode, null);\n\n const { attributes } = currentNode;\n\n /* Check if we have attributes; if not we might have a text node */\n if (!attributes) {\n return;\n }\n\n const hookEvent = {\n attrName: '',\n attrValue: '',\n keepAttr: true,\n allowedAttributes: ALLOWED_ATTR,\n };\n let l = attributes.length;\n\n /* Go backwards over all attributes; safely remove bad ones */\n while (l--) {\n const attr = attributes[l];\n const { name, namespaceURI, value: attrValue } = attr;\n const lcName = transformCaseFunc(name);\n\n let value = name === 'value' ? attrValue : stringTrim(attrValue);\n\n /* Execute a hook if present */\n hookEvent.attrName = lcName;\n hookEvent.attrValue = value;\n hookEvent.keepAttr = true;\n hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set\n _executeHook('uponSanitizeAttribute', currentNode, hookEvent);\n value = hookEvent.attrValue;\n /* Did the hooks approve of the attribute? */\n if (hookEvent.forceKeepAttr) {\n continue;\n }\n\n /* Remove attribute */\n _removeAttribute(name, currentNode);\n\n /* Did the hooks approve of the attribute? */\n if (!hookEvent.keepAttr) {\n continue;\n }\n\n /* Work around a security issue in jQuery 3.0 */\n if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\\/>/i, value)) {\n _removeAttribute(name, currentNode);\n continue;\n }\n\n /* Work around a security issue with comments inside attributes */\n if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\\/(style|title)/i, value)) {\n _removeAttribute(name, currentNode);\n continue;\n }\n\n /* Sanitize attribute content to be template-safe */\n if (SAFE_FOR_TEMPLATES) {\n arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], (expr) => {\n value = stringReplace(value, expr, ' ');\n });\n }\n\n /* Is `value` valid for this attribute? */\n const lcTag = transformCaseFunc(currentNode.nodeName);\n if (!_isValidAttribute(lcTag, lcName, value)) {\n continue;\n }\n\n /* Full DOM Clobbering protection via namespace isolation,\n * Prefix id and name attributes with `user-content-`\n */\n if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) {\n // Remove the attribute with this value\n _removeAttribute(name, currentNode);\n\n // Prefix the value and later re-create the attribute with the sanitized value\n value = SANITIZE_NAMED_PROPS_PREFIX + value;\n }\n\n /* Handle attributes that require Trusted Types */\n if (\n trustedTypesPolicy &&\n typeof trustedTypes === 'object' &&\n typeof trustedTypes.getAttributeType === 'function'\n ) {\n if (namespaceURI) {\n /* Namespaces are not yet supported, see https://bugs.chromium.org/p/chromium/issues/detail?id=1305293 */\n } else {\n switch (trustedTypes.getAttributeType(lcTag, lcName)) {\n case 'TrustedHTML': {\n value = trustedTypesPolicy.createHTML(value);\n break;\n }\n\n case 'TrustedScriptURL': {\n value = trustedTypesPolicy.createScriptURL(value);\n break;\n }\n\n default: {\n break;\n }\n }\n }\n }\n\n /* Handle invalid data-* attribute set by try-catching it */\n try {\n if (namespaceURI) {\n currentNode.setAttributeNS(namespaceURI, name, value);\n } else {\n /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. \"x-schema\". */\n currentNode.setAttribute(name, value);\n }\n\n if (_isClobbered(currentNode)) {\n _forceRemove(currentNode);\n } else {\n arrayPop(DOMPurify.removed);\n }\n } catch (_) {}\n }\n\n /* Execute a hook if present */\n _executeHook('afterSanitizeAttributes', currentNode, null);\n };\n\n /**\n * _sanitizeShadowDOM\n *\n * @param {DocumentFragment} fragment to iterate over recursively\n */\n const _sanitizeShadowDOM = function (fragment) {\n let shadowNode = null;\n const shadowIterator = _createNodeIterator(fragment);\n\n /* Execute a hook if present */\n _executeHook('beforeSanitizeShadowDOM', fragment, null);\n\n while ((shadowNode = shadowIterator.nextNode())) {\n /* Execute a hook if present */\n _executeHook('uponSanitizeShadowNode', shadowNode, null);\n\n /* Sanitize tags and elements */\n if (_sanitizeElements(shadowNode)) {\n continue;\n }\n\n /* Deep shadow DOM detected */\n if (shadowNode.content instanceof DocumentFragment) {\n _sanitizeShadowDOM(shadowNode.content);\n }\n\n /* Check attributes, sanitize if necessary */\n _sanitizeAttributes(shadowNode);\n }\n\n /* Execute a hook if present */\n _executeHook('afterSanitizeShadowDOM', fragment, null);\n };\n\n /**\n * Sanitize\n * Public method providing core sanitation functionality\n *\n * @param {String|Node} dirty string or DOM node\n * @param {Object} cfg object\n */\n // eslint-disable-next-line complexity\n DOMPurify.sanitize = function (dirty, cfg = {}) {\n let body = null;\n let importedNode = null;\n let currentNode = null;\n let returnNode = null;\n /* Make sure we have a string to sanitize.\n DO NOT return early, as this will return the wrong type if\n the user has requested a DOM object rather than a string */\n IS_EMPTY_INPUT = !dirty;\n if (IS_EMPTY_INPUT) {\n dirty = '';\n }\n\n /* Stringify, in case dirty is an object */\n if (typeof dirty !== 'string' && !_isNode(dirty)) {\n if (typeof dirty.toString === 'function') {\n dirty = dirty.toString();\n if (typeof dirty !== 'string') {\n throw typeErrorCreate('dirty is not a string, aborting');\n }\n } else {\n throw typeErrorCreate('toString is not a function');\n }\n }\n\n /* Return dirty HTML if DOMPurify cannot run */\n if (!DOMPurify.isSupported) {\n return dirty;\n }\n\n /* Assign config vars */\n if (!SET_CONFIG) {\n _parseConfig(cfg);\n }\n\n /* Clean up removed elements */\n DOMPurify.removed = [];\n\n /* Check if dirty is correctly typed for IN_PLACE */\n if (typeof dirty === 'string') {\n IN_PLACE = false;\n }\n\n if (IN_PLACE) {\n /* Do some early pre-sanitization to avoid unsafe root nodes */\n if (dirty.nodeName) {\n const tagName = transformCaseFunc(dirty.nodeName);\n if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {\n throw typeErrorCreate(\n 'root node is forbidden and cannot be sanitized in-place'\n );\n }\n }\n } else if (dirty instanceof Node) {\n /* If dirty is a DOM element, append to an empty document to avoid\n elements being stripped by the parser */\n body = _initDocument('');\n importedNode = body.ownerDocument.importNode(dirty, true);\n if (\n importedNode.nodeType === NODE_TYPE.element &&\n importedNode.nodeName === 'BODY'\n ) {\n /* Node is already a body, use as is */\n body = importedNode;\n } else if (importedNode.nodeName === 'HTML') {\n body = importedNode;\n } else {\n // eslint-disable-next-line unicorn/prefer-dom-node-append\n body.appendChild(importedNode);\n }\n } else {\n /* Exit directly if we have nothing to do */\n if (\n !RETURN_DOM &&\n !SAFE_FOR_TEMPLATES &&\n !WHOLE_DOCUMENT &&\n // eslint-disable-next-line unicorn/prefer-includes\n dirty.indexOf('<') === -1\n ) {\n return trustedTypesPolicy && RETURN_TRUSTED_TYPE\n ? trustedTypesPolicy.createHTML(dirty)\n : dirty;\n }\n\n /* Initialize the document to work on */\n body = _initDocument(dirty);\n\n /* Check we have a DOM node from the data */\n if (!body) {\n return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';\n }\n }\n\n /* Remove first element node (ours) if FORCE_BODY is set */\n if (body && FORCE_BODY) {\n _forceRemove(body.firstChild);\n }\n\n /* Get node iterator */\n const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body);\n\n /* Now start iterating over the created document */\n while ((currentNode = nodeIterator.nextNode())) {\n /* Sanitize tags and elements */\n if (_sanitizeElements(currentNode)) {\n continue;\n }\n\n /* Shadow DOM detected, sanitize it */\n if (currentNode.content instanceof DocumentFragment) {\n _sanitizeShadowDOM(currentNode.content);\n }\n\n /* Check attributes, sanitize if necessary */\n _sanitizeAttributes(currentNode);\n }\n\n /* If we sanitized `dirty` in-place, return it. */\n if (IN_PLACE) {\n return dirty;\n }\n\n /* Return sanitized string or DOM */\n if (RETURN_DOM) {\n if (RETURN_DOM_FRAGMENT) {\n returnNode = createDocumentFragment.call(body.ownerDocument);\n\n while (body.firstChild) {\n // eslint-disable-next-line unicorn/prefer-dom-node-append\n returnNode.appendChild(body.firstChild);\n }\n } else {\n returnNode = body;\n }\n\n if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {\n /*\n AdoptNode() is not used because internal state is not reset\n (e.g. the past names map of a HTMLFormElement), this is safe\n in theory but we would rather not risk another attack vector.\n The state that is cloned by importNode() is explicitly defined\n by the specs.\n */\n returnNode = importNode.call(originalDocument, returnNode, true);\n }\n\n return returnNode;\n }\n\n let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;\n\n /* Serialize doctype if allowed */\n if (\n WHOLE_DOCUMENT &&\n ALLOWED_TAGS['!doctype'] &&\n body.ownerDocument &&\n body.ownerDocument.doctype &&\n body.ownerDocument.doctype.name &&\n regExpTest(EXPRESSIONS.DOCTYPE_NAME, body.ownerDocument.doctype.name)\n ) {\n serializedHTML =\n '\\n' + serializedHTML;\n }\n\n /* Sanitize final string template-safe */\n if (SAFE_FOR_TEMPLATES) {\n arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], (expr) => {\n serializedHTML = stringReplace(serializedHTML, expr, ' ');\n });\n }\n\n return trustedTypesPolicy && RETURN_TRUSTED_TYPE\n ? trustedTypesPolicy.createHTML(serializedHTML)\n : serializedHTML;\n };\n\n /**\n * Public method to set the configuration once\n * setConfig\n *\n * @param {Object} cfg configuration object\n */\n DOMPurify.setConfig = function (cfg = {}) {\n _parseConfig(cfg);\n SET_CONFIG = true;\n };\n\n /**\n * Public method to remove the configuration\n * clearConfig\n *\n */\n DOMPurify.clearConfig = function () {\n CONFIG = null;\n SET_CONFIG = false;\n };\n\n /**\n * Public method to check if an attribute value is valid.\n * Uses last set config, if any. Otherwise, uses config defaults.\n * isValidAttribute\n *\n * @param {String} tag Tag name of containing element.\n * @param {String} attr Attribute name.\n * @param {String} value Attribute value.\n * @return {Boolean} Returns true if `value` is valid. Otherwise, returns false.\n */\n DOMPurify.isValidAttribute = function (tag, attr, value) {\n /* Initialize shared config vars if necessary. */\n if (!CONFIG) {\n _parseConfig({});\n }\n\n const lcTag = transformCaseFunc(tag);\n const lcName = transformCaseFunc(attr);\n return _isValidAttribute(lcTag, lcName, value);\n };\n\n /**\n * AddHook\n * Public method to add DOMPurify hooks\n *\n * @param {String} entryPoint entry point for the hook to add\n * @param {Function} hookFunction function to execute\n */\n DOMPurify.addHook = function (entryPoint, hookFunction) {\n if (typeof hookFunction !== 'function') {\n return;\n }\n\n hooks[entryPoint] = hooks[entryPoint] || [];\n arrayPush(hooks[entryPoint], hookFunction);\n };\n\n /**\n * RemoveHook\n * Public method to remove a DOMPurify hook at a given entryPoint\n * (pops it from the stack of hooks if more are present)\n *\n * @param {String} entryPoint entry point for the hook to remove\n * @return {Function} removed(popped) hook\n */\n DOMPurify.removeHook = function (entryPoint) {\n if (hooks[entryPoint]) {\n return arrayPop(hooks[entryPoint]);\n }\n };\n\n /**\n * RemoveHooks\n * Public method to remove all DOMPurify hooks at a given entryPoint\n *\n * @param {String} entryPoint entry point for the hooks to remove\n */\n DOMPurify.removeHooks = function (entryPoint) {\n if (hooks[entryPoint]) {\n hooks[entryPoint] = [];\n }\n };\n\n /**\n * RemoveAllHooks\n * Public method to remove all DOMPurify hooks\n */\n DOMPurify.removeAllHooks = function () {\n hooks = {};\n };\n\n return DOMPurify;\n}\n\nexport default createDOMPurify();\n"],"names":["entries","setPrototypeOf","isFrozen","getPrototypeOf","getOwnPropertyDescriptor","Object","freeze","seal","create","apply","construct","Reflect","x","fun","thisValue","args","Func","arrayForEach","unapply","Array","prototype","forEach","arrayPop","pop","arrayPush","push","stringToLowerCase","String","toLowerCase","stringToString","toString","stringMatch","match","stringReplace","replace","stringIndexOf","indexOf","stringTrim","trim","objectHasOwnProperty","hasOwnProperty","regExpTest","RegExp","test","typeErrorCreate","unconstruct","TypeError","func","thisArg","_len","arguments","length","_key","_len2","_key2","addToSet","set","array","transformCaseFunc","undefined","l","element","lcElement","cleanArray","index","isPropertyExist","clone","object","newObject","property","value","isArray","constructor","lookupGetter","prop","desc","get","fallbackValue","html","svg","svgFilters","svgDisallowed","mathMl","mathMlDisallowed","text","xml","MUSTACHE_EXPR","ERB_EXPR","TMPLIT_EXPR","DATA_ATTR","ARIA_ATTR","IS_ALLOWED_URI","IS_SCRIPT_OR_DATA","ATTR_WHITESPACE","DOCTYPE_NAME","CUSTOM_ELEMENT","NODE_TYPE","attribute","cdataSection","entityReference","entityNode","progressingInstruction","comment","document","documentType","documentFragment","notation","getGlobal","window","_createTrustedTypesPolicy","trustedTypes","purifyHostElement","createPolicy","suffix","ATTR_NAME","hasAttribute","getAttribute","policyName","createHTML","createScriptURL","scriptUrl","_","console","warn","createDOMPurify","DOMPurify","root","version","VERSION","removed","nodeType","isSupported","originalDocument","currentScript","DocumentFragment","HTMLTemplateElement","Node","Element","NodeFilter","NamedNodeMap","MozNamedAttrMap","HTMLFormElement","DOMParser","ElementPrototype","cloneNode","getNextSibling","getChildNodes","getParentNode","template","createElement","content","ownerDocument","trustedTypesPolicy","emptyHTML","implementation","createNodeIterator","createDocumentFragment","getElementsByTagName","importNode","hooks","createHTMLDocument","EXPRESSIONS","ALLOWED_TAGS","DEFAULT_ALLOWED_TAGS","TAGS","ALLOWED_ATTR","DEFAULT_ALLOWED_ATTR","ATTRS","CUSTOM_ELEMENT_HANDLING","tagNameCheck","writable","configurable","enumerable","attributeNameCheck","allowCustomizedBuiltInElements","FORBID_TAGS","FORBID_ATTR","ALLOW_ARIA_ATTR","ALLOW_DATA_ATTR","ALLOW_UNKNOWN_PROTOCOLS","ALLOW_SELF_CLOSE_IN_ATTR","SAFE_FOR_TEMPLATES","SAFE_FOR_XML","WHOLE_DOCUMENT","SET_CONFIG","FORCE_BODY","RETURN_DOM","RETURN_DOM_FRAGMENT","RETURN_TRUSTED_TYPE","SANITIZE_DOM","SANITIZE_NAMED_PROPS","SANITIZE_NAMED_PROPS_PREFIX","KEEP_CONTENT","IN_PLACE","USE_PROFILES","FORBID_CONTENTS","DEFAULT_FORBID_CONTENTS","DATA_URI_TAGS","DEFAULT_DATA_URI_TAGS","URI_SAFE_ATTRIBUTES","DEFAULT_URI_SAFE_ATTRIBUTES","MATHML_NAMESPACE","SVG_NAMESPACE","HTML_NAMESPACE","NAMESPACE","IS_EMPTY_INPUT","ALLOWED_NAMESPACES","DEFAULT_ALLOWED_NAMESPACES","PARSER_MEDIA_TYPE","SUPPORTED_PARSER_MEDIA_TYPES","DEFAULT_PARSER_MEDIA_TYPE","CONFIG","formElement","isRegexOrFunction","testValue","Function","_parseConfig","cfg","ADD_URI_SAFE_ATTR","ADD_DATA_URI_TAGS","ALLOWED_URI_REGEXP","ADD_TAGS","ADD_ATTR","table","tbody","TRUSTED_TYPES_POLICY","MATHML_TEXT_INTEGRATION_POINTS","HTML_INTEGRATION_POINTS","COMMON_SVG_AND_HTML_ELEMENTS","ALL_SVG_TAGS","ALL_MATHML_TAGS","_checkValidNamespace","parent","tagName","namespaceURI","parentTagName","Boolean","_forceRemove","node","parentNode","removeChild","remove","_removeAttribute","name","getAttributeNode","from","removeAttribute","setAttribute","_initDocument","dirty","doc","leadingWhitespace","matches","dirtyPayload","parseFromString","documentElement","createDocument","innerHTML","body","insertBefore","createTextNode","childNodes","call","_createNodeIterator","SHOW_ELEMENT","SHOW_COMMENT","SHOW_TEXT","SHOW_PROCESSING_INSTRUCTION","SHOW_CDATA_SECTION","_isClobbered","elm","nodeName","textContent","attributes","hasChildNodes","_isNode","_executeHook","entryPoint","currentNode","data","hook","_sanitizeElements","allowedTags","firstElementChild","_isBasicCustomElement","childCount","i","childClone","__removalCount","expr","_isValidAttribute","lcTag","lcName","_sanitizeAttributes","hookEvent","attrName","attrValue","keepAttr","allowedAttributes","attr","forceKeepAttr","getAttributeType","setAttributeNS","_sanitizeShadowDOM","fragment","shadowNode","shadowIterator","nextNode","sanitize","importedNode","returnNode","appendChild","firstChild","nodeIterator","shadowroot","shadowrootmode","serializedHTML","outerHTML","doctype","setConfig","clearConfig","isValidAttribute","tag","addHook","hookFunction","removeHook","removeHooks","removeAllHooks"],"mappings":";;AAAA,MAAM;EACJA,OAAO;EACPC,cAAc;EACdC,QAAQ;EACRC,cAAc;AACdC,EAAAA,wBAAAA;AACF,CAAC,GAAGC,MAAM,CAAA;AAEV,IAAI;EAAEC,MAAM;EAAEC,IAAI;AAAEC,EAAAA,MAAA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AA;AACpC,KAAA;GACD,CAAA;;AAED;AACF;AACA;AACA;AACA;AACA;AACExJ,EAAAA,SAAS,CAACyM,WAAW,GAAG,UAAUjD,UAAU,EAAE;AAC5C,IAAA,IAAItH,KAAK,CAACsH,UAAU,CAAC,EAAE;AACrBtH,MAAAA,KAAK,CAACsH,UAAU,CAAC,GAAG,EAAE,CAAA;AACxB,KAAA;GACD,CAAA;;AAED;AACF;AACA;AACA;EACExJ,SAAS,CAAC0M,cAAc,GAAG,YAAY;IACrCxK,KAAK,GAAG,EAAE,CAAA;GACX,CAAA;AAED,EAAA,OAAOlC,SAAS,CAAA;AAClB,CAAA;AAEA,aAAeD,eAAe,EAAE;;;;"} \ No newline at end of file +{"version":3,"file":"purify.es.mjs","sources":["../src/utils.js","../src/tags.js","../src/attrs.js","../src/regexp.js","../src/purify.js"],"sourcesContent":["const {\n entries,\n setPrototypeOf,\n isFrozen,\n getPrototypeOf,\n getOwnPropertyDescriptor,\n} = Object;\n\nlet { freeze, seal, create } = Object; // eslint-disable-line import/no-mutable-exports\nlet { apply, construct } = typeof Reflect !== 'undefined' && Reflect;\n\nif (!freeze) {\n freeze = function (x) {\n return x;\n };\n}\n\nif (!seal) {\n seal = function (x) {\n return x;\n };\n}\n\nif (!apply) {\n apply = function (fun, thisValue, args) {\n return fun.apply(thisValue, args);\n };\n}\n\nif (!construct) {\n construct = function (Func, args) {\n return new Func(...args);\n };\n}\n\nconst arrayForEach = unapply(Array.prototype.forEach);\nconst arrayIndexOf = unapply(Array.prototype.indexOf);\nconst arrayPop = unapply(Array.prototype.pop);\nconst arrayPush = unapply(Array.prototype.push);\nconst arraySlice = unapply(Array.prototype.slice);\n\nconst stringToLowerCase = unapply(String.prototype.toLowerCase);\nconst stringToString = unapply(String.prototype.toString);\nconst stringMatch = unapply(String.prototype.match);\nconst stringReplace = unapply(String.prototype.replace);\nconst stringIndexOf = unapply(String.prototype.indexOf);\nconst stringTrim = unapply(String.prototype.trim);\n\nconst objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);\n\nconst regExpTest = unapply(RegExp.prototype.test);\n\nconst typeErrorCreate = unconstruct(TypeError);\n\n/**\n * Creates a new function that calls the given function with a specified thisArg and arguments.\n *\n * @param {Function} func - The function to be wrapped and called.\n * @returns {Function} A new function that calls the given function with a specified thisArg and arguments.\n */\nfunction unapply(func) {\n return (thisArg, ...args) => apply(func, thisArg, args);\n}\n\n/**\n * Creates a new function that constructs an instance of the given constructor function with the provided arguments.\n *\n * @param {Function} func - The constructor function to be wrapped and called.\n * @returns {Function} A new function that constructs an instance of the given constructor function with the provided arguments.\n */\nfunction unconstruct(func) {\n return (...args) => construct(func, args);\n}\n\n/**\n * Add properties to a lookup table\n *\n * @param {Object} set - The set to which elements will be added.\n * @param {Array} array - The array containing elements to be added to the set.\n * @param {Function} transformCaseFunc - An optional function to transform the case of each element before adding to the set.\n * @returns {Object} The modified set with added elements.\n */\nfunction addToSet(set, array, transformCaseFunc = stringToLowerCase) {\n if (setPrototypeOf) {\n // Make 'in' and truthy checks like Boolean(set.constructor)\n // independent of any properties defined on Object.prototype.\n // Prevent prototype setters from intercepting set as a this value.\n setPrototypeOf(set, null);\n }\n\n let l = array.length;\n while (l--) {\n let element = array[l];\n if (typeof element === 'string') {\n const lcElement = transformCaseFunc(element);\n if (lcElement !== element) {\n // Config presets (e.g. tags.js, attrs.js) are immutable.\n if (!isFrozen(array)) {\n array[l] = lcElement;\n }\n\n element = lcElement;\n }\n }\n\n set[element] = true;\n }\n\n return set;\n}\n\n/**\n * Clean up an array to harden against CSPP\n *\n * @param {Array} array - The array to be cleaned.\n * @returns {Array} The cleaned version of the array\n */\nfunction cleanArray(array) {\n for (let index = 0; index < array.length; index++) {\n const isPropertyExist = objectHasOwnProperty(array, index);\n\n if (!isPropertyExist) {\n array[index] = null;\n }\n }\n\n return array;\n}\n\n/**\n * Shallow clone an object\n *\n * @param {Object} object - The object to be cloned.\n * @returns {Object} A new object that copies the original.\n */\nfunction clone(object) {\n const newObject = create(null);\n\n for (const [property, value] of entries(object)) {\n const isPropertyExist = objectHasOwnProperty(object, property);\n\n if (isPropertyExist) {\n if (Array.isArray(value)) {\n newObject[property] = cleanArray(value);\n } else if (\n value &&\n typeof value === 'object' &&\n value.constructor === Object\n ) {\n newObject[property] = clone(value);\n } else {\n newObject[property] = value;\n }\n }\n }\n\n return newObject;\n}\n\n/**\n * This method automatically checks if the prop is function or getter and behaves accordingly.\n *\n * @param {Object} object - The object to look up the getter function in its prototype chain.\n * @param {String} prop - The property name for which to find the getter function.\n * @returns {Function} The getter function found in the prototype chain or a fallback function.\n */\nfunction lookupGetter(object, prop) {\n while (object !== null) {\n const desc = getOwnPropertyDescriptor(object, prop);\n\n if (desc) {\n if (desc.get) {\n return unapply(desc.get);\n }\n\n if (typeof desc.value === 'function') {\n return unapply(desc.value);\n }\n }\n\n object = getPrototypeOf(object);\n }\n\n function fallbackValue() {\n return null;\n }\n\n return fallbackValue;\n}\n\nexport {\n // Array\n arrayForEach,\n arrayIndexOf,\n arrayPop,\n arrayPush,\n arraySlice,\n // Object\n entries,\n freeze,\n getPrototypeOf,\n getOwnPropertyDescriptor,\n isFrozen,\n setPrototypeOf,\n seal,\n clone,\n create,\n objectHasOwnProperty,\n // RegExp\n regExpTest,\n // String\n stringIndexOf,\n stringMatch,\n stringReplace,\n stringToLowerCase,\n stringToString,\n stringTrim,\n // Errors\n typeErrorCreate,\n // Other\n lookupGetter,\n addToSet,\n // Reflect\n unapply,\n unconstruct,\n};\n","import { freeze } from './utils.js';\n\nexport const html = freeze([\n 'a',\n 'abbr',\n 'acronym',\n 'address',\n 'area',\n 'article',\n 'aside',\n 'audio',\n 'b',\n 'bdi',\n 'bdo',\n 'big',\n 'blink',\n 'blockquote',\n 'body',\n 'br',\n 'button',\n 'canvas',\n 'caption',\n 'center',\n 'cite',\n 'code',\n 'col',\n 'colgroup',\n 'content',\n 'data',\n 'datalist',\n 'dd',\n 'decorator',\n 'del',\n 'details',\n 'dfn',\n 'dialog',\n 'dir',\n 'div',\n 'dl',\n 'dt',\n 'element',\n 'em',\n 'fieldset',\n 'figcaption',\n 'figure',\n 'font',\n 'footer',\n 'form',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'head',\n 'header',\n 'hgroup',\n 'hr',\n 'html',\n 'i',\n 'img',\n 'input',\n 'ins',\n 'kbd',\n 'label',\n 'legend',\n 'li',\n 'main',\n 'map',\n 'mark',\n 'marquee',\n 'menu',\n 'menuitem',\n 'meter',\n 'nav',\n 'nobr',\n 'ol',\n 'optgroup',\n 'option',\n 'output',\n 'p',\n 'picture',\n 'pre',\n 'progress',\n 'q',\n 'rp',\n 'rt',\n 'ruby',\n 's',\n 'samp',\n 'section',\n 'select',\n 'shadow',\n 'small',\n 'source',\n 'spacer',\n 'span',\n 'strike',\n 'strong',\n 'style',\n 'sub',\n 'summary',\n 'sup',\n 'table',\n 'tbody',\n 'td',\n 'template',\n 'textarea',\n 'tfoot',\n 'th',\n 'thead',\n 'time',\n 'tr',\n 'track',\n 'tt',\n 'u',\n 'ul',\n 'var',\n 'video',\n 'wbr',\n]);\n\n// SVG\nexport const svg = freeze([\n 'svg',\n 'a',\n 'altglyph',\n 'altglyphdef',\n 'altglyphitem',\n 'animatecolor',\n 'animatemotion',\n 'animatetransform',\n 'circle',\n 'clippath',\n 'defs',\n 'desc',\n 'ellipse',\n 'filter',\n 'font',\n 'g',\n 'glyph',\n 'glyphref',\n 'hkern',\n 'image',\n 'line',\n 'lineargradient',\n 'marker',\n 'mask',\n 'metadata',\n 'mpath',\n 'path',\n 'pattern',\n 'polygon',\n 'polyline',\n 'radialgradient',\n 'rect',\n 'stop',\n 'style',\n 'switch',\n 'symbol',\n 'text',\n 'textpath',\n 'title',\n 'tref',\n 'tspan',\n 'view',\n 'vkern',\n]);\n\nexport const svgFilters = freeze([\n 'feBlend',\n 'feColorMatrix',\n 'feComponentTransfer',\n 'feComposite',\n 'feConvolveMatrix',\n 'feDiffuseLighting',\n 'feDisplacementMap',\n 'feDistantLight',\n 'feDropShadow',\n 'feFlood',\n 'feFuncA',\n 'feFuncB',\n 'feFuncG',\n 'feFuncR',\n 'feGaussianBlur',\n 'feImage',\n 'feMerge',\n 'feMergeNode',\n 'feMorphology',\n 'feOffset',\n 'fePointLight',\n 'feSpecularLighting',\n 'feSpotLight',\n 'feTile',\n 'feTurbulence',\n]);\n\n// List of SVG elements that are disallowed by default.\n// We still need to know them so that we can do namespace\n// checks properly in case one wants to add them to\n// allow-list.\nexport const svgDisallowed = freeze([\n 'animate',\n 'color-profile',\n 'cursor',\n 'discard',\n 'font-face',\n 'font-face-format',\n 'font-face-name',\n 'font-face-src',\n 'font-face-uri',\n 'foreignobject',\n 'hatch',\n 'hatchpath',\n 'mesh',\n 'meshgradient',\n 'meshpatch',\n 'meshrow',\n 'missing-glyph',\n 'script',\n 'set',\n 'solidcolor',\n 'unknown',\n 'use',\n]);\n\nexport const mathMl = freeze([\n 'math',\n 'menclose',\n 'merror',\n 'mfenced',\n 'mfrac',\n 'mglyph',\n 'mi',\n 'mlabeledtr',\n 'mmultiscripts',\n 'mn',\n 'mo',\n 'mover',\n 'mpadded',\n 'mphantom',\n 'mroot',\n 'mrow',\n 'ms',\n 'mspace',\n 'msqrt',\n 'mstyle',\n 'msub',\n 'msup',\n 'msubsup',\n 'mtable',\n 'mtd',\n 'mtext',\n 'mtr',\n 'munder',\n 'munderover',\n 'mprescripts',\n]);\n\n// Similarly to SVG, we want to know all MathML elements,\n// even those that we disallow by default.\nexport const mathMlDisallowed = freeze([\n 'maction',\n 'maligngroup',\n 'malignmark',\n 'mlongdiv',\n 'mscarries',\n 'mscarry',\n 'msgroup',\n 'mstack',\n 'msline',\n 'msrow',\n 'semantics',\n 'annotation',\n 'annotation-xml',\n 'mprescripts',\n 'none',\n]);\n\nexport const text = freeze(['#text']);\n","import { freeze } from './utils.js';\n\nexport const html = freeze([\n 'accept',\n 'action',\n 'align',\n 'alt',\n 'autocapitalize',\n 'autocomplete',\n 'autopictureinpicture',\n 'autoplay',\n 'background',\n 'bgcolor',\n 'border',\n 'capture',\n 'cellpadding',\n 'cellspacing',\n 'checked',\n 'cite',\n 'class',\n 'clear',\n 'color',\n 'cols',\n 'colspan',\n 'controls',\n 'controlslist',\n 'coords',\n 'crossorigin',\n 'datetime',\n 'decoding',\n 'default',\n 'dir',\n 'disabled',\n 'disablepictureinpicture',\n 'disableremoteplayback',\n 'download',\n 'draggable',\n 'enctype',\n 'enterkeyhint',\n 'face',\n 'for',\n 'headers',\n 'height',\n 'hidden',\n 'high',\n 'href',\n 'hreflang',\n 'id',\n 'inputmode',\n 'integrity',\n 'ismap',\n 'kind',\n 'label',\n 'lang',\n 'list',\n 'loading',\n 'loop',\n 'low',\n 'max',\n 'maxlength',\n 'media',\n 'method',\n 'min',\n 'minlength',\n 'multiple',\n 'muted',\n 'name',\n 'nonce',\n 'noshade',\n 'novalidate',\n 'nowrap',\n 'open',\n 'optimum',\n 'pattern',\n 'placeholder',\n 'playsinline',\n 'popover',\n 'popovertarget',\n 'popovertargetaction',\n 'poster',\n 'preload',\n 'pubdate',\n 'radiogroup',\n 'readonly',\n 'rel',\n 'required',\n 'rev',\n 'reversed',\n 'role',\n 'rows',\n 'rowspan',\n 'spellcheck',\n 'scope',\n 'selected',\n 'shape',\n 'size',\n 'sizes',\n 'span',\n 'srclang',\n 'start',\n 'src',\n 'srcset',\n 'step',\n 'style',\n 'summary',\n 'tabindex',\n 'title',\n 'translate',\n 'type',\n 'usemap',\n 'valign',\n 'value',\n 'width',\n 'wrap',\n 'xmlns',\n 'slot',\n]);\n\nexport const svg = freeze([\n 'accent-height',\n 'accumulate',\n 'additive',\n 'alignment-baseline',\n 'amplitude',\n 'ascent',\n 'attributename',\n 'attributetype',\n 'azimuth',\n 'basefrequency',\n 'baseline-shift',\n 'begin',\n 'bias',\n 'by',\n 'class',\n 'clip',\n 'clippathunits',\n 'clip-path',\n 'clip-rule',\n 'color',\n 'color-interpolation',\n 'color-interpolation-filters',\n 'color-profile',\n 'color-rendering',\n 'cx',\n 'cy',\n 'd',\n 'dx',\n 'dy',\n 'diffuseconstant',\n 'direction',\n 'display',\n 'divisor',\n 'dur',\n 'edgemode',\n 'elevation',\n 'end',\n 'exponent',\n 'fill',\n 'fill-opacity',\n 'fill-rule',\n 'filter',\n 'filterunits',\n 'flood-color',\n 'flood-opacity',\n 'font-family',\n 'font-size',\n 'font-size-adjust',\n 'font-stretch',\n 'font-style',\n 'font-variant',\n 'font-weight',\n 'fx',\n 'fy',\n 'g1',\n 'g2',\n 'glyph-name',\n 'glyphref',\n 'gradientunits',\n 'gradienttransform',\n 'height',\n 'href',\n 'id',\n 'image-rendering',\n 'in',\n 'in2',\n 'intercept',\n 'k',\n 'k1',\n 'k2',\n 'k3',\n 'k4',\n 'kerning',\n 'keypoints',\n 'keysplines',\n 'keytimes',\n 'lang',\n 'lengthadjust',\n 'letter-spacing',\n 'kernelmatrix',\n 'kernelunitlength',\n 'lighting-color',\n 'local',\n 'marker-end',\n 'marker-mid',\n 'marker-start',\n 'markerheight',\n 'markerunits',\n 'markerwidth',\n 'maskcontentunits',\n 'maskunits',\n 'max',\n 'mask',\n 'media',\n 'method',\n 'mode',\n 'min',\n 'name',\n 'numoctaves',\n 'offset',\n 'operator',\n 'opacity',\n 'order',\n 'orient',\n 'orientation',\n 'origin',\n 'overflow',\n 'paint-order',\n 'path',\n 'pathlength',\n 'patterncontentunits',\n 'patterntransform',\n 'patternunits',\n 'points',\n 'preservealpha',\n 'preserveaspectratio',\n 'primitiveunits',\n 'r',\n 'rx',\n 'ry',\n 'radius',\n 'refx',\n 'refy',\n 'repeatcount',\n 'repeatdur',\n 'restart',\n 'result',\n 'rotate',\n 'scale',\n 'seed',\n 'shape-rendering',\n 'slope',\n 'specularconstant',\n 'specularexponent',\n 'spreadmethod',\n 'startoffset',\n 'stddeviation',\n 'stitchtiles',\n 'stop-color',\n 'stop-opacity',\n 'stroke-dasharray',\n 'stroke-dashoffset',\n 'stroke-linecap',\n 'stroke-linejoin',\n 'stroke-miterlimit',\n 'stroke-opacity',\n 'stroke',\n 'stroke-width',\n 'style',\n 'surfacescale',\n 'systemlanguage',\n 'tabindex',\n 'tablevalues',\n 'targetx',\n 'targety',\n 'transform',\n 'transform-origin',\n 'text-anchor',\n 'text-decoration',\n 'text-rendering',\n 'textlength',\n 'type',\n 'u1',\n 'u2',\n 'unicode',\n 'values',\n 'viewbox',\n 'visibility',\n 'version',\n 'vert-adv-y',\n 'vert-origin-x',\n 'vert-origin-y',\n 'width',\n 'word-spacing',\n 'wrap',\n 'writing-mode',\n 'xchannelselector',\n 'ychannelselector',\n 'x',\n 'x1',\n 'x2',\n 'xmlns',\n 'y',\n 'y1',\n 'y2',\n 'z',\n 'zoomandpan',\n]);\n\nexport const mathMl = freeze([\n 'accent',\n 'accentunder',\n 'align',\n 'bevelled',\n 'close',\n 'columnsalign',\n 'columnlines',\n 'columnspan',\n 'denomalign',\n 'depth',\n 'dir',\n 'display',\n 'displaystyle',\n 'encoding',\n 'fence',\n 'frame',\n 'height',\n 'href',\n 'id',\n 'largeop',\n 'length',\n 'linethickness',\n 'lspace',\n 'lquote',\n 'mathbackground',\n 'mathcolor',\n 'mathsize',\n 'mathvariant',\n 'maxsize',\n 'minsize',\n 'movablelimits',\n 'notation',\n 'numalign',\n 'open',\n 'rowalign',\n 'rowlines',\n 'rowspacing',\n 'rowspan',\n 'rspace',\n 'rquote',\n 'scriptlevel',\n 'scriptminsize',\n 'scriptsizemultiplier',\n 'selection',\n 'separator',\n 'separators',\n 'stretchy',\n 'subscriptshift',\n 'supscriptshift',\n 'symmetric',\n 'voffset',\n 'width',\n 'xmlns',\n]);\n\nexport const xml = freeze([\n 'xlink:href',\n 'xml:id',\n 'xlink:title',\n 'xml:space',\n 'xmlns:xlink',\n]);\n","import { seal } from './utils.js';\n\n// eslint-disable-next-line unicorn/better-regex\nexport const MUSTACHE_EXPR = seal(/\\{\\{[\\w\\W]*|[\\w\\W]*\\}\\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode\nexport const ERB_EXPR = seal(/<%[\\w\\W]*|[\\w\\W]*%>/gm);\nexport const TMPLIT_EXPR = seal(/\\${[\\w\\W]*}/gm);\nexport const DATA_ATTR = seal(/^data-[\\-\\w.\\u00B7-\\uFFFF]/); // eslint-disable-line no-useless-escape\nexport const ARIA_ATTR = seal(/^aria-[\\-\\w]+$/); // eslint-disable-line no-useless-escape\nexport const IS_ALLOWED_URI = seal(\n /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\\-]+(?:[^a-z+.\\-:]|$))/i // eslint-disable-line no-useless-escape\n);\nexport const IS_SCRIPT_OR_DATA = seal(/^(?:\\w+script|data):/i);\nexport const ATTR_WHITESPACE = seal(\n /[\\u0000-\\u0020\\u00A0\\u1680\\u180E\\u2000-\\u2029\\u205F\\u3000]/g // eslint-disable-line no-control-regex\n);\nexport const DOCTYPE_NAME = seal(/^html$/i);\nexport const CUSTOM_ELEMENT = seal(/^[a-z][.\\w]*(-[.\\w]+)+$/i);\n","import * as TAGS from './tags.js';\nimport * as ATTRS from './attrs.js';\nimport * as EXPRESSIONS from './regexp.js';\nimport {\n addToSet,\n clone,\n entries,\n freeze,\n arrayForEach,\n arrayPop,\n arrayPush,\n stringMatch,\n stringReplace,\n stringToLowerCase,\n stringToString,\n stringIndexOf,\n stringTrim,\n regExpTest,\n typeErrorCreate,\n lookupGetter,\n create,\n objectHasOwnProperty,\n} from './utils.js';\n\n// https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType\nconst NODE_TYPE = {\n element: 1,\n attribute: 2,\n text: 3,\n cdataSection: 4,\n entityReference: 5, // Deprecated\n entityNode: 6, // Deprecated\n progressingInstruction: 7,\n comment: 8,\n document: 9,\n documentType: 10,\n documentFragment: 11,\n notation: 12, // Deprecated\n};\n\nconst getGlobal = function () {\n return typeof window === 'undefined' ? null : window;\n};\n\n/**\n * Creates a no-op policy for internal use only.\n * Don't export this function outside this module!\n * @param {TrustedTypePolicyFactory} trustedTypes The policy factory.\n * @param {HTMLScriptElement} purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).\n * @return {TrustedTypePolicy} The policy created (or null, if Trusted Types\n * are not supported or creating the policy failed).\n */\nconst _createTrustedTypesPolicy = function (trustedTypes, purifyHostElement) {\n if (\n typeof trustedTypes !== 'object' ||\n typeof trustedTypes.createPolicy !== 'function'\n ) {\n return null;\n }\n\n // Allow the callers to control the unique policy name\n // by adding a data-tt-policy-suffix to the script element with the DOMPurify.\n // Policy creation with duplicate names throws in Trusted Types.\n let suffix = null;\n const ATTR_NAME = 'data-tt-policy-suffix';\n if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {\n suffix = purifyHostElement.getAttribute(ATTR_NAME);\n }\n\n const policyName = 'dompurify' + (suffix ? '#' + suffix : '');\n\n try {\n return trustedTypes.createPolicy(policyName, {\n createHTML(html) {\n return html;\n },\n createScriptURL(scriptUrl) {\n return scriptUrl;\n },\n });\n } catch (_) {\n // Policy creation failed (most likely another DOMPurify script has\n // already run). Skip creating the policy, as this will only cause errors\n // if TT are enforced.\n console.warn(\n 'TrustedTypes policy ' + policyName + ' could not be created.'\n );\n return null;\n }\n};\n\nfunction createDOMPurify(window = getGlobal()) {\n const DOMPurify = (root) => createDOMPurify(root);\n\n /**\n * Version label, exposed for easier checks\n * if DOMPurify is up to date or not\n */\n DOMPurify.version = VERSION;\n\n /**\n * Array of elements that DOMPurify removed during sanitation.\n * Empty if nothing was removed.\n */\n DOMPurify.removed = [];\n\n if (\n !window ||\n !window.document ||\n window.document.nodeType !== NODE_TYPE.document\n ) {\n // Not running in a browser, provide a factory function\n // so that you can pass your own Window\n DOMPurify.isSupported = false;\n\n return DOMPurify;\n }\n\n let { document } = window;\n\n const originalDocument = document;\n const currentScript = originalDocument.currentScript;\n const {\n DocumentFragment,\n HTMLTemplateElement,\n Node,\n Element,\n NodeFilter,\n NamedNodeMap = window.NamedNodeMap || window.MozNamedAttrMap,\n HTMLFormElement,\n DOMParser,\n trustedTypes,\n } = window;\n\n const ElementPrototype = Element.prototype;\n\n const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');\n const remove = lookupGetter(ElementPrototype, 'remove');\n const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');\n const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');\n const getParentNode = lookupGetter(ElementPrototype, 'parentNode');\n\n // As per issue #47, the web-components registry is inherited by a\n // new document created via createHTMLDocument. As per the spec\n // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)\n // a new empty registry is used when creating a template contents owner\n // document, so we use that as our parent document to ensure nothing\n // is inherited.\n if (typeof HTMLTemplateElement === 'function') {\n const template = document.createElement('template');\n if (template.content && template.content.ownerDocument) {\n document = template.content.ownerDocument;\n }\n }\n\n let trustedTypesPolicy;\n let emptyHTML = '';\n\n const {\n implementation,\n createNodeIterator,\n createDocumentFragment,\n getElementsByTagName,\n } = document;\n const { importNode } = originalDocument;\n\n let hooks = {};\n\n /**\n * Expose whether this browser supports running the full DOMPurify.\n */\n DOMPurify.isSupported =\n typeof entries === 'function' &&\n typeof getParentNode === 'function' &&\n implementation &&\n implementation.createHTMLDocument !== undefined;\n\n const {\n MUSTACHE_EXPR,\n ERB_EXPR,\n TMPLIT_EXPR,\n DATA_ATTR,\n ARIA_ATTR,\n IS_SCRIPT_OR_DATA,\n ATTR_WHITESPACE,\n CUSTOM_ELEMENT,\n } = EXPRESSIONS;\n\n let { IS_ALLOWED_URI } = EXPRESSIONS;\n\n /**\n * We consider the elements and attributes below to be safe. Ideally\n * don't add any new ones but feel free to remove unwanted ones.\n */\n\n /* allowed element names */\n let ALLOWED_TAGS = null;\n const DEFAULT_ALLOWED_TAGS = addToSet({}, [\n ...TAGS.html,\n ...TAGS.svg,\n ...TAGS.svgFilters,\n ...TAGS.mathMl,\n ...TAGS.text,\n ]);\n\n /* Allowed attribute names */\n let ALLOWED_ATTR = null;\n const DEFAULT_ALLOWED_ATTR = addToSet({}, [\n ...ATTRS.html,\n ...ATTRS.svg,\n ...ATTRS.mathMl,\n ...ATTRS.xml,\n ]);\n\n /*\n * Configure how DOMPUrify should handle custom elements and their attributes as well as customized built-in elements.\n * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)\n * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)\n * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.\n */\n let CUSTOM_ELEMENT_HANDLING = Object.seal(\n create(null, {\n tagNameCheck: {\n writable: true,\n configurable: false,\n enumerable: true,\n value: null,\n },\n attributeNameCheck: {\n writable: true,\n configurable: false,\n enumerable: true,\n value: null,\n },\n allowCustomizedBuiltInElements: {\n writable: true,\n configurable: false,\n enumerable: true,\n value: false,\n },\n })\n );\n\n /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */\n let FORBID_TAGS = null;\n\n /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */\n let FORBID_ATTR = null;\n\n /* Decide if ARIA attributes are okay */\n let ALLOW_ARIA_ATTR = true;\n\n /* Decide if custom data attributes are okay */\n let ALLOW_DATA_ATTR = true;\n\n /* Decide if unknown protocols are okay */\n let ALLOW_UNKNOWN_PROTOCOLS = false;\n\n /* Decide if self-closing tags in attributes are allowed.\n * Usually removed due to a mXSS issue in jQuery 3.0 */\n let ALLOW_SELF_CLOSE_IN_ATTR = true;\n\n /* Output should be safe for common template engines.\n * This means, DOMPurify removes data attributes, mustaches and ERB\n */\n let SAFE_FOR_TEMPLATES = false;\n\n /* Output should be safe even for XML used within HTML and alike.\n * This means, DOMPurify removes comments when containing risky content.\n */\n let SAFE_FOR_XML = true;\n\n /* Decide if document with ... should be returned */\n let WHOLE_DOCUMENT = false;\n\n /* Track whether config is already set on this instance of DOMPurify. */\n let SET_CONFIG = false;\n\n /* Decide if all elements (e.g. style, script) must be children of\n * document.body. By default, browsers might move them to document.head */\n let FORCE_BODY = false;\n\n /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html\n * string (or a TrustedHTML object if Trusted Types are supported).\n * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead\n */\n let RETURN_DOM = false;\n\n /* Decide if a DOM `DocumentFragment` should be returned, instead of a html\n * string (or a TrustedHTML object if Trusted Types are supported) */\n let RETURN_DOM_FRAGMENT = false;\n\n /* Try to return a Trusted Type object instead of a string, return a string in\n * case Trusted Types are not supported */\n let RETURN_TRUSTED_TYPE = false;\n\n /* Output should be free from DOM clobbering attacks?\n * This sanitizes markups named with colliding, clobberable built-in DOM APIs.\n */\n let SANITIZE_DOM = true;\n\n /* Achieve full DOM Clobbering protection by isolating the namespace of named\n * properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules.\n *\n * HTML/DOM spec rules that enable DOM Clobbering:\n * - Named Access on Window (§7.3.3)\n * - DOM Tree Accessors (§3.1.5)\n * - Form Element Parent-Child Relations (§4.10.3)\n * - Iframe srcdoc / Nested WindowProxies (§4.8.5)\n * - HTMLCollection (§4.2.10.2)\n *\n * Namespace isolation is implemented by prefixing `id` and `name` attributes\n * with a constant string, i.e., `user-content-`\n */\n let SANITIZE_NAMED_PROPS = false;\n const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';\n\n /* Keep element content when removing element? */\n let KEEP_CONTENT = true;\n\n /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead\n * of importing it into a new Document and returning a sanitized copy */\n let IN_PLACE = false;\n\n /* Allow usage of profiles like html, svg and mathMl */\n let USE_PROFILES = {};\n\n /* Tags to ignore content of when KEEP_CONTENT is true */\n let FORBID_CONTENTS = null;\n const DEFAULT_FORBID_CONTENTS = addToSet({}, [\n 'annotation-xml',\n 'audio',\n 'colgroup',\n 'desc',\n 'foreignobject',\n 'head',\n 'iframe',\n 'math',\n 'mi',\n 'mn',\n 'mo',\n 'ms',\n 'mtext',\n 'noembed',\n 'noframes',\n 'noscript',\n 'plaintext',\n 'script',\n 'style',\n 'svg',\n 'template',\n 'thead',\n 'title',\n 'video',\n 'xmp',\n ]);\n\n /* Tags that are safe for data: URIs */\n let DATA_URI_TAGS = null;\n const DEFAULT_DATA_URI_TAGS = addToSet({}, [\n 'audio',\n 'video',\n 'img',\n 'source',\n 'image',\n 'track',\n ]);\n\n /* Attributes safe for values like \"javascript:\" */\n let URI_SAFE_ATTRIBUTES = null;\n const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, [\n 'alt',\n 'class',\n 'for',\n 'id',\n 'label',\n 'name',\n 'pattern',\n 'placeholder',\n 'role',\n 'summary',\n 'title',\n 'value',\n 'style',\n 'xmlns',\n ]);\n\n const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';\n const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';\n const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';\n /* Document namespace */\n let NAMESPACE = HTML_NAMESPACE;\n let IS_EMPTY_INPUT = false;\n\n /* Allowed XHTML+XML namespaces */\n let ALLOWED_NAMESPACES = null;\n const DEFAULT_ALLOWED_NAMESPACES = addToSet(\n {},\n [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE],\n stringToString\n );\n\n /* Parsing of strict XHTML documents */\n let PARSER_MEDIA_TYPE = null;\n const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];\n const DEFAULT_PARSER_MEDIA_TYPE = 'text/html';\n let transformCaseFunc = null;\n\n /* Keep a reference to config to pass to hooks */\n let CONFIG = null;\n\n /* Ideally, do not touch anything below this line */\n /* ______________________________________________ */\n\n const formElement = document.createElement('form');\n\n const isRegexOrFunction = function (testValue) {\n return testValue instanceof RegExp || testValue instanceof Function;\n };\n\n /**\n * _parseConfig\n *\n * @param {Object} cfg optional config literal\n */\n // eslint-disable-next-line complexity\n const _parseConfig = function (cfg = {}) {\n if (CONFIG && CONFIG === cfg) {\n return;\n }\n\n /* Shield configuration object from tampering */\n if (!cfg || typeof cfg !== 'object') {\n cfg = {};\n }\n\n /* Shield configuration object from prototype pollution */\n cfg = clone(cfg);\n\n PARSER_MEDIA_TYPE =\n // eslint-disable-next-line unicorn/prefer-includes\n SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1\n ? DEFAULT_PARSER_MEDIA_TYPE\n : cfg.PARSER_MEDIA_TYPE;\n\n // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.\n transformCaseFunc =\n PARSER_MEDIA_TYPE === 'application/xhtml+xml'\n ? stringToString\n : stringToLowerCase;\n\n /* Set configuration parameters */\n ALLOWED_TAGS = objectHasOwnProperty(cfg, 'ALLOWED_TAGS')\n ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc)\n : DEFAULT_ALLOWED_TAGS;\n ALLOWED_ATTR = objectHasOwnProperty(cfg, 'ALLOWED_ATTR')\n ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc)\n : DEFAULT_ALLOWED_ATTR;\n ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, 'ALLOWED_NAMESPACES')\n ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString)\n : DEFAULT_ALLOWED_NAMESPACES;\n URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR')\n ? addToSet(\n clone(DEFAULT_URI_SAFE_ATTRIBUTES), // eslint-disable-line indent\n cfg.ADD_URI_SAFE_ATTR, // eslint-disable-line indent\n transformCaseFunc // eslint-disable-line indent\n ) // eslint-disable-line indent\n : DEFAULT_URI_SAFE_ATTRIBUTES;\n DATA_URI_TAGS = objectHasOwnProperty(cfg, 'ADD_DATA_URI_TAGS')\n ? addToSet(\n clone(DEFAULT_DATA_URI_TAGS), // eslint-disable-line indent\n cfg.ADD_DATA_URI_TAGS, // eslint-disable-line indent\n transformCaseFunc // eslint-disable-line indent\n ) // eslint-disable-line indent\n : DEFAULT_DATA_URI_TAGS;\n FORBID_CONTENTS = objectHasOwnProperty(cfg, 'FORBID_CONTENTS')\n ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc)\n : DEFAULT_FORBID_CONTENTS;\n FORBID_TAGS = objectHasOwnProperty(cfg, 'FORBID_TAGS')\n ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc)\n : {};\n FORBID_ATTR = objectHasOwnProperty(cfg, 'FORBID_ATTR')\n ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc)\n : {};\n USE_PROFILES = objectHasOwnProperty(cfg, 'USE_PROFILES')\n ? cfg.USE_PROFILES\n : false;\n ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true\n ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true\n ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false\n ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true\n SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false\n SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false; // Default true\n WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false\n RETURN_DOM = cfg.RETURN_DOM || false; // Default false\n RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false\n RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false\n FORCE_BODY = cfg.FORCE_BODY || false; // Default false\n SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true\n SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false\n KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true\n IN_PLACE = cfg.IN_PLACE || false; // Default false\n IS_ALLOWED_URI = cfg.ALLOWED_URI_REGEXP || EXPRESSIONS.IS_ALLOWED_URI;\n NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;\n CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {};\n if (\n cfg.CUSTOM_ELEMENT_HANDLING &&\n isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)\n ) {\n CUSTOM_ELEMENT_HANDLING.tagNameCheck =\n cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;\n }\n\n if (\n cfg.CUSTOM_ELEMENT_HANDLING &&\n isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)\n ) {\n CUSTOM_ELEMENT_HANDLING.attributeNameCheck =\n cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck;\n }\n\n if (\n cfg.CUSTOM_ELEMENT_HANDLING &&\n typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements ===\n 'boolean'\n ) {\n CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements =\n cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements;\n }\n\n if (SAFE_FOR_TEMPLATES) {\n ALLOW_DATA_ATTR = false;\n }\n\n if (RETURN_DOM_FRAGMENT) {\n RETURN_DOM = true;\n }\n\n /* Parse profile info */\n if (USE_PROFILES) {\n ALLOWED_TAGS = addToSet({}, TAGS.text);\n ALLOWED_ATTR = [];\n if (USE_PROFILES.html === true) {\n addToSet(ALLOWED_TAGS, TAGS.html);\n addToSet(ALLOWED_ATTR, ATTRS.html);\n }\n\n if (USE_PROFILES.svg === true) {\n addToSet(ALLOWED_TAGS, TAGS.svg);\n addToSet(ALLOWED_ATTR, ATTRS.svg);\n addToSet(ALLOWED_ATTR, ATTRS.xml);\n }\n\n if (USE_PROFILES.svgFilters === true) {\n addToSet(ALLOWED_TAGS, TAGS.svgFilters);\n addToSet(ALLOWED_ATTR, ATTRS.svg);\n addToSet(ALLOWED_ATTR, ATTRS.xml);\n }\n\n if (USE_PROFILES.mathMl === true) {\n addToSet(ALLOWED_TAGS, TAGS.mathMl);\n addToSet(ALLOWED_ATTR, ATTRS.mathMl);\n addToSet(ALLOWED_ATTR, ATTRS.xml);\n }\n }\n\n /* Merge configuration parameters */\n if (cfg.ADD_TAGS) {\n if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {\n ALLOWED_TAGS = clone(ALLOWED_TAGS);\n }\n\n addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);\n }\n\n if (cfg.ADD_ATTR) {\n if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {\n ALLOWED_ATTR = clone(ALLOWED_ATTR);\n }\n\n addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);\n }\n\n if (cfg.ADD_URI_SAFE_ATTR) {\n addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);\n }\n\n if (cfg.FORBID_CONTENTS) {\n if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {\n FORBID_CONTENTS = clone(FORBID_CONTENTS);\n }\n\n addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);\n }\n\n /* Add #text in case KEEP_CONTENT is set to true */\n if (KEEP_CONTENT) {\n ALLOWED_TAGS['#text'] = true;\n }\n\n /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */\n if (WHOLE_DOCUMENT) {\n addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);\n }\n\n /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */\n if (ALLOWED_TAGS.table) {\n addToSet(ALLOWED_TAGS, ['tbody']);\n delete FORBID_TAGS.tbody;\n }\n\n if (cfg.TRUSTED_TYPES_POLICY) {\n if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') {\n throw typeErrorCreate(\n 'TRUSTED_TYPES_POLICY configuration option must provide a \"createHTML\" hook.'\n );\n }\n\n if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {\n throw typeErrorCreate(\n 'TRUSTED_TYPES_POLICY configuration option must provide a \"createScriptURL\" hook.'\n );\n }\n\n // Overwrite existing TrustedTypes policy.\n trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;\n\n // Sign local variables required by `sanitize`.\n emptyHTML = trustedTypesPolicy.createHTML('');\n } else {\n // Uninitialized policy, attempt to initialize the internal dompurify policy.\n if (trustedTypesPolicy === undefined) {\n trustedTypesPolicy = _createTrustedTypesPolicy(\n trustedTypes,\n currentScript\n );\n }\n\n // If creating the internal policy succeeded sign internal variables.\n if (trustedTypesPolicy !== null && typeof emptyHTML === 'string') {\n emptyHTML = trustedTypesPolicy.createHTML('');\n }\n }\n\n // Prevent further manipulation of configuration.\n // Not available in IE8, Safari 5, etc.\n if (freeze) {\n freeze(cfg);\n }\n\n CONFIG = cfg;\n };\n\n const MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, [\n 'mi',\n 'mo',\n 'mn',\n 'ms',\n 'mtext',\n ]);\n\n const HTML_INTEGRATION_POINTS = addToSet({}, ['annotation-xml']);\n\n // Certain elements are allowed in both SVG and HTML\n // namespace. We need to specify them explicitly\n // so that they don't get erroneously deleted from\n // HTML namespace.\n const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, [\n 'title',\n 'style',\n 'font',\n 'a',\n 'script',\n ]);\n\n /* Keep track of all possible SVG and MathML tags\n * so that we can perform the namespace checks\n * correctly. */\n const ALL_SVG_TAGS = addToSet({}, [\n ...TAGS.svg,\n ...TAGS.svgFilters,\n ...TAGS.svgDisallowed,\n ]);\n const ALL_MATHML_TAGS = addToSet({}, [\n ...TAGS.mathMl,\n ...TAGS.mathMlDisallowed,\n ]);\n\n /**\n * @param {Element} element a DOM element whose namespace is being checked\n * @returns {boolean} Return false if the element has a\n * namespace that a spec-compliant parser would never\n * return. Return true otherwise.\n */\n const _checkValidNamespace = function (element) {\n let parent = getParentNode(element);\n\n // In JSDOM, if we're inside shadow DOM, then parentNode\n // can be null. We just simulate parent in this case.\n if (!parent || !parent.tagName) {\n parent = {\n namespaceURI: NAMESPACE,\n tagName: 'template',\n };\n }\n\n const tagName = stringToLowerCase(element.tagName);\n const parentTagName = stringToLowerCase(parent.tagName);\n\n if (!ALLOWED_NAMESPACES[element.namespaceURI]) {\n return false;\n }\n\n if (element.namespaceURI === SVG_NAMESPACE) {\n // The only way to switch from HTML namespace to SVG\n // is via . If it happens via any other tag, then\n // it should be killed.\n if (parent.namespaceURI === HTML_NAMESPACE) {\n return tagName === 'svg';\n }\n\n // The only way to switch from MathML to SVG is via`\n // svg if parent is either or MathML\n // text integration points.\n if (parent.namespaceURI === MATHML_NAMESPACE) {\n return (\n tagName === 'svg' &&\n (parentTagName === 'annotation-xml' ||\n MATHML_TEXT_INTEGRATION_POINTS[parentTagName])\n );\n }\n\n // We only allow elements that are defined in SVG\n // spec. All others are disallowed in SVG namespace.\n return Boolean(ALL_SVG_TAGS[tagName]);\n }\n\n if (element.namespaceURI === MATHML_NAMESPACE) {\n // The only way to switch from HTML namespace to MathML\n // is via . If it happens via any other tag, then\n // it should be killed.\n if (parent.namespaceURI === HTML_NAMESPACE) {\n return tagName === 'math';\n }\n\n // The only way to switch from SVG to MathML is via\n // and HTML integration points\n if (parent.namespaceURI === SVG_NAMESPACE) {\n return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];\n }\n\n // We only allow elements that are defined in MathML\n // spec. All others are disallowed in MathML namespace.\n return Boolean(ALL_MATHML_TAGS[tagName]);\n }\n\n if (element.namespaceURI === HTML_NAMESPACE) {\n // The only way to switch from SVG to HTML is via\n // HTML integration points, and from MathML to HTML\n // is via MathML text integration points\n if (\n parent.namespaceURI === SVG_NAMESPACE &&\n !HTML_INTEGRATION_POINTS[parentTagName]\n ) {\n return false;\n }\n\n if (\n parent.namespaceURI === MATHML_NAMESPACE &&\n !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]\n ) {\n return false;\n }\n\n // We disallow tags that are specific for MathML\n // or SVG and should never appear in HTML namespace\n return (\n !ALL_MATHML_TAGS[tagName] &&\n (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName])\n );\n }\n\n // For XHTML and XML documents that support custom namespaces\n if (\n PARSER_MEDIA_TYPE === 'application/xhtml+xml' &&\n ALLOWED_NAMESPACES[element.namespaceURI]\n ) {\n return true;\n }\n\n // The code should never reach this place (this means\n // that the element somehow got namespace that is not\n // HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES).\n // Return false just in case.\n return false;\n };\n\n /**\n * _forceRemove\n *\n * @param {Node} node a DOM node\n */\n const _forceRemove = function (node) {\n arrayPush(DOMPurify.removed, { element: node });\n\n try {\n // eslint-disable-next-line unicorn/prefer-dom-node-remove\n getParentNode(node).removeChild(node);\n } catch (_) {\n remove(node);\n }\n };\n\n /**\n * _removeAttribute\n *\n * @param {String} name an Attribute name\n * @param {Node} node a DOM node\n */\n const _removeAttribute = function (name, node) {\n try {\n arrayPush(DOMPurify.removed, {\n attribute: node.getAttributeNode(name),\n from: node,\n });\n } catch (_) {\n arrayPush(DOMPurify.removed, {\n attribute: null,\n from: node,\n });\n }\n\n node.removeAttribute(name);\n\n // We void attribute values for unremovable \"is\"\" attributes\n if (name === 'is' && !ALLOWED_ATTR[name]) {\n if (RETURN_DOM || RETURN_DOM_FRAGMENT) {\n try {\n _forceRemove(node);\n } catch (_) {}\n } else {\n try {\n node.setAttribute(name, '');\n } catch (_) {}\n }\n }\n };\n\n /**\n * _initDocument\n *\n * @param {String} dirty a string of dirty markup\n * @return {Document} a DOM, filled with the dirty markup\n */\n const _initDocument = function (dirty) {\n /* Create a HTML document */\n let doc = null;\n let leadingWhitespace = null;\n\n if (FORCE_BODY) {\n dirty = '' + dirty;\n } else {\n /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */\n const matches = stringMatch(dirty, /^[\\r\\n\\t ]+/);\n leadingWhitespace = matches && matches[0];\n }\n\n if (\n PARSER_MEDIA_TYPE === 'application/xhtml+xml' &&\n NAMESPACE === HTML_NAMESPACE\n ) {\n // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)\n dirty =\n '' +\n dirty +\n '';\n }\n\n const dirtyPayload = trustedTypesPolicy\n ? trustedTypesPolicy.createHTML(dirty)\n : dirty;\n /*\n * Use the DOMParser API by default, fallback later if needs be\n * DOMParser not work for svg when has multiple root element.\n */\n if (NAMESPACE === HTML_NAMESPACE) {\n try {\n doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);\n } catch (_) {}\n }\n\n /* Use createHTMLDocument in case DOMParser is not available */\n if (!doc || !doc.documentElement) {\n doc = implementation.createDocument(NAMESPACE, 'template', null);\n try {\n doc.documentElement.innerHTML = IS_EMPTY_INPUT\n ? emptyHTML\n : dirtyPayload;\n } catch (_) {\n // Syntax error if dirtyPayload is invalid xml\n }\n }\n\n const body = doc.body || doc.documentElement;\n\n if (dirty && leadingWhitespace) {\n body.insertBefore(\n document.createTextNode(leadingWhitespace),\n body.childNodes[0] || null\n );\n }\n\n /* Work on whole document or just its body */\n if (NAMESPACE === HTML_NAMESPACE) {\n return getElementsByTagName.call(\n doc,\n WHOLE_DOCUMENT ? 'html' : 'body'\n )[0];\n }\n\n return WHOLE_DOCUMENT ? doc.documentElement : body;\n };\n\n /**\n * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document.\n *\n * @param {Node} root The root element or node to start traversing on.\n * @return {NodeIterator} The created NodeIterator\n */\n const _createNodeIterator = function (root) {\n return createNodeIterator.call(\n root.ownerDocument || root,\n root,\n // eslint-disable-next-line no-bitwise\n NodeFilter.SHOW_ELEMENT |\n NodeFilter.SHOW_COMMENT |\n NodeFilter.SHOW_TEXT |\n NodeFilter.SHOW_PROCESSING_INSTRUCTION |\n NodeFilter.SHOW_CDATA_SECTION,\n null\n );\n };\n\n /**\n * _isClobbered\n *\n * @param {Node} elm element to check for clobbering attacks\n * @return {Boolean} true if clobbered, false if safe\n */\n const _isClobbered = function (elm) {\n return (\n elm instanceof HTMLFormElement &&\n (typeof elm.nodeName !== 'string' ||\n typeof elm.textContent !== 'string' ||\n typeof elm.removeChild !== 'function' ||\n !(elm.attributes instanceof NamedNodeMap) ||\n typeof elm.removeAttribute !== 'function' ||\n typeof elm.setAttribute !== 'function' ||\n typeof elm.namespaceURI !== 'string' ||\n typeof elm.insertBefore !== 'function' ||\n typeof elm.hasChildNodes !== 'function')\n );\n };\n\n /**\n * Checks whether the given object is a DOM node.\n *\n * @param {Node} object object to check whether it's a DOM node\n * @return {Boolean} true is object is a DOM node\n */\n const _isNode = function (object) {\n return typeof Node === 'function' && object instanceof Node;\n };\n\n /**\n * _executeHook\n * Execute user configurable hooks\n *\n * @param {String} entryPoint Name of the hook's entry point\n * @param {Node} currentNode node to work on with the hook\n * @param {Object} data additional hook parameters\n */\n const _executeHook = function (entryPoint, currentNode, data) {\n if (!hooks[entryPoint]) {\n return;\n }\n\n arrayForEach(hooks[entryPoint], (hook) => {\n hook.call(DOMPurify, currentNode, data, CONFIG);\n });\n };\n\n /**\n * _sanitizeElements\n *\n * @protect nodeName\n * @protect textContent\n * @protect removeChild\n *\n * @param {Node} currentNode to check for permission to exist\n * @return {Boolean} true if node was killed, false if left alive\n */\n const _sanitizeElements = function (currentNode) {\n let content = null;\n\n /* Execute a hook if present */\n _executeHook('beforeSanitizeElements', currentNode, null);\n\n /* Check if element is clobbered or can clobber */\n if (_isClobbered(currentNode)) {\n _forceRemove(currentNode);\n return true;\n }\n\n /* Now let's check the element's type and name */\n const tagName = transformCaseFunc(currentNode.nodeName);\n\n /* Execute a hook if present */\n _executeHook('uponSanitizeElement', currentNode, {\n tagName,\n allowedTags: ALLOWED_TAGS,\n });\n\n /* Detect mXSS attempts abusing namespace confusion */\n if (\n currentNode.hasChildNodes() &&\n !_isNode(currentNode.firstElementChild) &&\n regExpTest(/<[/\\w]/g, currentNode.innerHTML) &&\n regExpTest(/<[/\\w]/g, currentNode.textContent)\n ) {\n _forceRemove(currentNode);\n return true;\n }\n\n /* Remove any occurrence of processing instructions */\n if (currentNode.nodeType === NODE_TYPE.progressingInstruction) {\n _forceRemove(currentNode);\n return true;\n }\n\n /* Remove any kind of possibly harmful comments */\n if (\n SAFE_FOR_XML &&\n currentNode.nodeType === NODE_TYPE.comment &&\n regExpTest(/<[/\\w]/g, currentNode.data)\n ) {\n _forceRemove(currentNode);\n return true;\n }\n\n /* Remove element if anything forbids its presence */\n if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {\n /* Check if we have a custom element to handle */\n if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {\n if (\n CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp &&\n regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)\n ) {\n return false;\n }\n\n if (\n CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function &&\n CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)\n ) {\n return false;\n }\n }\n\n /* Keep content except for bad-listed elements */\n if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {\n const parentNode = getParentNode(currentNode) || currentNode.parentNode;\n const childNodes = getChildNodes(currentNode) || currentNode.childNodes;\n\n if (childNodes && parentNode) {\n const childCount = childNodes.length;\n\n for (let i = childCount - 1; i >= 0; --i) {\n const childClone = cloneNode(childNodes[i], true);\n childClone.__removalCount = (currentNode.__removalCount || 0) + 1;\n parentNode.insertBefore(childClone, getNextSibling(currentNode));\n }\n }\n }\n\n _forceRemove(currentNode);\n return true;\n }\n\n /* Check whether element has a valid namespace */\n if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {\n _forceRemove(currentNode);\n return true;\n }\n\n /* Make sure that older browsers don't get fallback-tag mXSS */\n if (\n (tagName === 'noscript' ||\n tagName === 'noembed' ||\n tagName === 'noframes') &&\n regExpTest(/<\\/no(script|embed|frames)/i, currentNode.innerHTML)\n ) {\n _forceRemove(currentNode);\n return true;\n }\n\n /* Sanitize element content to be template-safe */\n if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {\n /* Get the element's text content */\n content = currentNode.textContent;\n\n arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], (expr) => {\n content = stringReplace(content, expr, ' ');\n });\n\n if (currentNode.textContent !== content) {\n arrayPush(DOMPurify.removed, { element: currentNode.cloneNode() });\n currentNode.textContent = content;\n }\n }\n\n /* Execute a hook if present */\n _executeHook('afterSanitizeElements', currentNode, null);\n\n return false;\n };\n\n /**\n * _isValidAttribute\n *\n * @param {string} lcTag Lowercase tag name of containing element.\n * @param {string} lcName Lowercase attribute name.\n * @param {string} value Attribute value.\n * @return {Boolean} Returns true if `value` is valid, otherwise false.\n */\n // eslint-disable-next-line complexity\n const _isValidAttribute = function (lcTag, lcName, value) {\n /* Make sure attribute cannot clobber */\n if (\n SANITIZE_DOM &&\n (lcName === 'id' || lcName === 'name') &&\n (value in document || value in formElement)\n ) {\n return false;\n }\n\n /* Allow valid data-* attributes: At least one character after \"-\"\n (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)\n XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)\n We don't need to check the value; it's always URI safe. */\n if (\n ALLOW_DATA_ATTR &&\n !FORBID_ATTR[lcName] &&\n regExpTest(DATA_ATTR, lcName)\n ) {\n // This attribute is safe\n } else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR, lcName)) {\n // This attribute is safe\n /* Otherwise, check the name is permitted */\n } else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) {\n if (\n // First condition does a very basic check if a) it's basically a valid custom element tagname AND\n // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck\n // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck\n (_isBasicCustomElement(lcTag) &&\n ((CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp &&\n regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag)) ||\n (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function &&\n CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag))) &&\n ((CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp &&\n regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName)) ||\n (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function &&\n CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName)))) ||\n // Alternative, second condition checks if it's an `is`-attribute, AND\n // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck\n (lcName === 'is' &&\n CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements &&\n ((CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp &&\n regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value)) ||\n (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function &&\n CUSTOM_ELEMENT_HANDLING.tagNameCheck(value))))\n ) {\n // If user has supplied a regexp or function in CUSTOM_ELEMENT_HANDLING.tagNameCheck, we need to also allow derived custom elements using the same tagName test.\n // Additionally, we need to allow attributes passing the CUSTOM_ELEMENT_HANDLING.attributeNameCheck user has configured, as custom elements can define these at their own discretion.\n } else {\n return false;\n }\n /* Check value is safe. First, is attr inert? If so, is safe */\n } else if (URI_SAFE_ATTRIBUTES[lcName]) {\n // This attribute is safe\n /* Check no script, data or unknown possibly unsafe URI\n unless we know URI values are safe for that attribute */\n } else if (\n regExpTest(IS_ALLOWED_URI, stringReplace(value, ATTR_WHITESPACE, ''))\n ) {\n // This attribute is safe\n /* Keep image data URIs alive if src/xlink:href is allowed */\n /* Further prevent gadget XSS for dynamically built script tags */\n } else if (\n (lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') &&\n lcTag !== 'script' &&\n stringIndexOf(value, 'data:') === 0 &&\n DATA_URI_TAGS[lcTag]\n ) {\n // This attribute is safe\n /* Allow unknown protocols: This provides support for links that\n are handled by protocol handlers which may be unknown ahead of\n time, e.g. fb:, spotify: */\n } else if (\n ALLOW_UNKNOWN_PROTOCOLS &&\n !regExpTest(IS_SCRIPT_OR_DATA, stringReplace(value, ATTR_WHITESPACE, ''))\n ) {\n // This attribute is safe\n /* Check for binary attributes */\n } else if (value) {\n return false;\n } else {\n // Binary attributes are safe at this point\n /* Anything else, presume unsafe, do not add it back */\n }\n\n return true;\n };\n\n /**\n * _isBasicCustomElement\n * checks if at least one dash is included in tagName, and it's not the first char\n * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name\n *\n * @param {string} tagName name of the tag of the node to sanitize\n * @returns {boolean} Returns true if the tag name meets the basic criteria for a custom element, otherwise false.\n */\n const _isBasicCustomElement = function (tagName) {\n return tagName !== 'annotation-xml' && stringMatch(tagName, CUSTOM_ELEMENT);\n };\n\n /**\n * _sanitizeAttributes\n *\n * @protect attributes\n * @protect nodeName\n * @protect removeAttribute\n * @protect setAttribute\n *\n * @param {Node} currentNode to sanitize\n */\n const _sanitizeAttributes = function (currentNode) {\n /* Execute a hook if present */\n _executeHook('beforeSanitizeAttributes', currentNode, null);\n\n const { attributes } = currentNode;\n\n /* Check if we have attributes; if not we might have a text node */\n if (!attributes) {\n return;\n }\n\n const hookEvent = {\n attrName: '',\n attrValue: '',\n keepAttr: true,\n allowedAttributes: ALLOWED_ATTR,\n };\n let l = attributes.length;\n\n /* Go backwards over all attributes; safely remove bad ones */\n while (l--) {\n const attr = attributes[l];\n const { name, namespaceURI, value: attrValue } = attr;\n const lcName = transformCaseFunc(name);\n\n let value = name === 'value' ? attrValue : stringTrim(attrValue);\n\n /* Execute a hook if present */\n hookEvent.attrName = lcName;\n hookEvent.attrValue = value;\n hookEvent.keepAttr = true;\n hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set\n _executeHook('uponSanitizeAttribute', currentNode, hookEvent);\n value = hookEvent.attrValue;\n\n /* Did the hooks approve of the attribute? */\n if (hookEvent.forceKeepAttr) {\n continue;\n }\n\n /* Remove attribute */\n _removeAttribute(name, currentNode);\n\n /* Did the hooks approve of the attribute? */\n if (!hookEvent.keepAttr) {\n continue;\n }\n\n /* Work around a security issue in jQuery 3.0 */\n if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\\/>/i, value)) {\n _removeAttribute(name, currentNode);\n continue;\n }\n\n /* Sanitize attribute content to be template-safe */\n if (SAFE_FOR_TEMPLATES) {\n arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], (expr) => {\n value = stringReplace(value, expr, ' ');\n });\n }\n\n /* Is `value` valid for this attribute? */\n const lcTag = transformCaseFunc(currentNode.nodeName);\n if (!_isValidAttribute(lcTag, lcName, value)) {\n continue;\n }\n\n /* Full DOM Clobbering protection via namespace isolation,\n * Prefix id and name attributes with `user-content-`\n */\n if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) {\n // Remove the attribute with this value\n _removeAttribute(name, currentNode);\n\n // Prefix the value and later re-create the attribute with the sanitized value\n value = SANITIZE_NAMED_PROPS_PREFIX + value;\n }\n\n /* Work around a security issue with comments inside attributes */\n if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\\/(style|title)/i, value)) {\n _removeAttribute(name, currentNode);\n continue;\n }\n\n /* Handle attributes that require Trusted Types */\n if (\n trustedTypesPolicy &&\n typeof trustedTypes === 'object' &&\n typeof trustedTypes.getAttributeType === 'function'\n ) {\n if (namespaceURI) {\n /* Namespaces are not yet supported, see https://bugs.chromium.org/p/chromium/issues/detail?id=1305293 */\n } else {\n switch (trustedTypes.getAttributeType(lcTag, lcName)) {\n case 'TrustedHTML': {\n value = trustedTypesPolicy.createHTML(value);\n break;\n }\n\n case 'TrustedScriptURL': {\n value = trustedTypesPolicy.createScriptURL(value);\n break;\n }\n\n default: {\n break;\n }\n }\n }\n }\n\n /* Handle invalid data-* attribute set by try-catching it */\n try {\n if (namespaceURI) {\n currentNode.setAttributeNS(namespaceURI, name, value);\n } else {\n /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. \"x-schema\". */\n currentNode.setAttribute(name, value);\n }\n\n if (_isClobbered(currentNode)) {\n _forceRemove(currentNode);\n } else {\n arrayPop(DOMPurify.removed);\n }\n } catch (_) {}\n }\n\n /* Execute a hook if present */\n _executeHook('afterSanitizeAttributes', currentNode, null);\n };\n\n /**\n * _sanitizeShadowDOM\n *\n * @param {DocumentFragment} fragment to iterate over recursively\n */\n const _sanitizeShadowDOM = function (fragment) {\n let shadowNode = null;\n const shadowIterator = _createNodeIterator(fragment);\n\n /* Execute a hook if present */\n _executeHook('beforeSanitizeShadowDOM', fragment, null);\n\n while ((shadowNode = shadowIterator.nextNode())) {\n /* Execute a hook if present */\n _executeHook('uponSanitizeShadowNode', shadowNode, null);\n\n /* Sanitize tags and elements */\n if (_sanitizeElements(shadowNode)) {\n continue;\n }\n\n /* Deep shadow DOM detected */\n if (shadowNode.content instanceof DocumentFragment) {\n _sanitizeShadowDOM(shadowNode.content);\n }\n\n /* Check attributes, sanitize if necessary */\n _sanitizeAttributes(shadowNode);\n }\n\n /* Execute a hook if present */\n _executeHook('afterSanitizeShadowDOM', fragment, null);\n };\n\n /**\n * Sanitize\n * Public method providing core sanitation functionality\n *\n * @param {String|Node} dirty string or DOM node\n * @param {Object} cfg object\n */\n // eslint-disable-next-line complexity\n DOMPurify.sanitize = function (dirty, cfg = {}) {\n let body = null;\n let importedNode = null;\n let currentNode = null;\n let returnNode = null;\n /* Make sure we have a string to sanitize.\n DO NOT return early, as this will return the wrong type if\n the user has requested a DOM object rather than a string */\n IS_EMPTY_INPUT = !dirty;\n if (IS_EMPTY_INPUT) {\n dirty = '';\n }\n\n /* Stringify, in case dirty is an object */\n if (typeof dirty !== 'string' && !_isNode(dirty)) {\n if (typeof dirty.toString === 'function') {\n dirty = dirty.toString();\n if (typeof dirty !== 'string') {\n throw typeErrorCreate('dirty is not a string, aborting');\n }\n } else {\n throw typeErrorCreate('toString is not a function');\n }\n }\n\n /* Return dirty HTML if DOMPurify cannot run */\n if (!DOMPurify.isSupported) {\n return dirty;\n }\n\n /* Assign config vars */\n if (!SET_CONFIG) {\n _parseConfig(cfg);\n }\n\n /* Clean up removed elements */\n DOMPurify.removed = [];\n\n /* Check if dirty is correctly typed for IN_PLACE */\n if (typeof dirty === 'string') {\n IN_PLACE = false;\n }\n\n if (IN_PLACE) {\n /* Do some early pre-sanitization to avoid unsafe root nodes */\n if (dirty.nodeName) {\n const tagName = transformCaseFunc(dirty.nodeName);\n if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {\n throw typeErrorCreate(\n 'root node is forbidden and cannot be sanitized in-place'\n );\n }\n }\n } else if (dirty instanceof Node) {\n /* If dirty is a DOM element, append to an empty document to avoid\n elements being stripped by the parser */\n body = _initDocument('');\n importedNode = body.ownerDocument.importNode(dirty, true);\n if (\n importedNode.nodeType === NODE_TYPE.element &&\n importedNode.nodeName === 'BODY'\n ) {\n /* Node is already a body, use as is */\n body = importedNode;\n } else if (importedNode.nodeName === 'HTML') {\n body = importedNode;\n } else {\n // eslint-disable-next-line unicorn/prefer-dom-node-append\n body.appendChild(importedNode);\n }\n } else {\n /* Exit directly if we have nothing to do */\n if (\n !RETURN_DOM &&\n !SAFE_FOR_TEMPLATES &&\n !WHOLE_DOCUMENT &&\n // eslint-disable-next-line unicorn/prefer-includes\n dirty.indexOf('<') === -1\n ) {\n return trustedTypesPolicy && RETURN_TRUSTED_TYPE\n ? trustedTypesPolicy.createHTML(dirty)\n : dirty;\n }\n\n /* Initialize the document to work on */\n body = _initDocument(dirty);\n\n /* Check we have a DOM node from the data */\n if (!body) {\n return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';\n }\n }\n\n /* Remove first element node (ours) if FORCE_BODY is set */\n if (body && FORCE_BODY) {\n _forceRemove(body.firstChild);\n }\n\n /* Get node iterator */\n const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body);\n\n /* Now start iterating over the created document */\n while ((currentNode = nodeIterator.nextNode())) {\n /* Sanitize tags and elements */\n if (_sanitizeElements(currentNode)) {\n continue;\n }\n\n /* Shadow DOM detected, sanitize it */\n if (currentNode.content instanceof DocumentFragment) {\n _sanitizeShadowDOM(currentNode.content);\n }\n\n /* Check attributes, sanitize if necessary */\n _sanitizeAttributes(currentNode);\n }\n\n /* If we sanitized `dirty` in-place, return it. */\n if (IN_PLACE) {\n return dirty;\n }\n\n /* Return sanitized string or DOM */\n if (RETURN_DOM) {\n if (RETURN_DOM_FRAGMENT) {\n returnNode = createDocumentFragment.call(body.ownerDocument);\n\n while (body.firstChild) {\n // eslint-disable-next-line unicorn/prefer-dom-node-append\n returnNode.appendChild(body.firstChild);\n }\n } else {\n returnNode = body;\n }\n\n if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {\n /*\n AdoptNode() is not used because internal state is not reset\n (e.g. the past names map of a HTMLFormElement), this is safe\n in theory but we would rather not risk another attack vector.\n The state that is cloned by importNode() is explicitly defined\n by the specs.\n */\n returnNode = importNode.call(originalDocument, returnNode, true);\n }\n\n return returnNode;\n }\n\n let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;\n\n /* Serialize doctype if allowed */\n if (\n WHOLE_DOCUMENT &&\n ALLOWED_TAGS['!doctype'] &&\n body.ownerDocument &&\n body.ownerDocument.doctype &&\n body.ownerDocument.doctype.name &&\n regExpTest(EXPRESSIONS.DOCTYPE_NAME, body.ownerDocument.doctype.name)\n ) {\n serializedHTML =\n '\\n' + serializedHTML;\n }\n\n /* Sanitize final string template-safe */\n if (SAFE_FOR_TEMPLATES) {\n arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], (expr) => {\n serializedHTML = stringReplace(serializedHTML, expr, ' ');\n });\n }\n\n return trustedTypesPolicy && RETURN_TRUSTED_TYPE\n ? trustedTypesPolicy.createHTML(serializedHTML)\n : serializedHTML;\n };\n\n /**\n * Public method to set the configuration once\n * setConfig\n *\n * @param {Object} cfg configuration object\n */\n DOMPurify.setConfig = function (cfg = {}) {\n _parseConfig(cfg);\n SET_CONFIG = true;\n };\n\n /**\n * Public method to remove the configuration\n * clearConfig\n *\n */\n DOMPurify.clearConfig = function () {\n CONFIG = null;\n SET_CONFIG = false;\n };\n\n /**\n * Public method to check if an attribute value is valid.\n * Uses last set config, if any. Otherwise, uses config defaults.\n * isValidAttribute\n *\n * @param {String} tag Tag name of containing element.\n * @param {String} attr Attribute name.\n * @param {String} value Attribute value.\n * @return {Boolean} Returns true if `value` is valid. Otherwise, returns false.\n */\n DOMPurify.isValidAttribute = function (tag, attr, value) {\n /* Initialize shared config vars if necessary. */\n if (!CONFIG) {\n _parseConfig({});\n }\n\n const lcTag = transformCaseFunc(tag);\n const lcName = transformCaseFunc(attr);\n return _isValidAttribute(lcTag, lcName, value);\n };\n\n /**\n * AddHook\n * Public method to add DOMPurify hooks\n *\n * @param {String} entryPoint entry point for the hook to add\n * @param {Function} hookFunction function to execute\n */\n DOMPurify.addHook = function (entryPoint, hookFunction) {\n if (typeof hookFunction !== 'function') {\n return;\n }\n\n hooks[entryPoint] = hooks[entryPoint] || [];\n arrayPush(hooks[entryPoint], hookFunction);\n };\n\n /**\n * RemoveHook\n * Public method to remove a DOMPurify hook at a given entryPoint\n * (pops it from the stack of hooks if more are present)\n *\n * @param {String} entryPoint entry point for the hook to remove\n * @return {Function} removed(popped) hook\n */\n DOMPurify.removeHook = function (entryPoint) {\n if (hooks[entryPoint]) {\n return arrayPop(hooks[entryPoint]);\n }\n };\n\n /**\n * RemoveHooks\n * Public method to remove all DOMPurify hooks at a given entryPoint\n *\n * @param {String} entryPoint entry point for the hooks to remove\n */\n DOMPurify.removeHooks = function (entryPoint) {\n if (hooks[entryPoint]) {\n hooks[entryPoint] = [];\n }\n };\n\n /**\n * RemoveAllHooks\n * Public method to remove all DOMPurify hooks\n */\n DOMPurify.removeAllHooks = function () {\n hooks = {};\n };\n\n return DOMPurify;\n}\n\nexport default createDOMPurify();\n"],"names":["entries","setPrototypeOf","isFrozen","getPrototypeOf","getOwnPropertyDescriptor","Object","freeze","seal","create","apply","construct","Reflect","x","fun","thisValue","args","Func","arrayForEach","unapply","Array","prototype","forEach","arrayPop","pop","arrayPush","push","stringToLowerCase","String","toLowerCase","stringToString","toString","stringMatch","match","stringReplace","replace","stringIndexOf","indexOf","stringTrim","trim","objectHasOwnProperty","hasOwnProperty","regExpTest","RegExp","test","typeErrorCreate","unconstruct","TypeError","func","thisArg","_len","arguments","length","_key","_len2","_key2","addToSet","set","array","transformCaseFunc","undefined","l","element","lcElement","cleanArray","index","isPropertyExist","clone","object","newObject","property","value","isArray","constructor","lookupGetter","prop","desc","get","fallbackValue","html","svg","svgFilters","svgDisallowed","mathMl","mathMlDisallowed","text","xml","MUSTACHE_EXPR","ERB_EXPR","TMPLIT_EXPR","DATA_ATTR","ARIA_ATTR","IS_ALLOWED_URI","IS_SCRIPT_OR_DATA","ATTR_WHITESPACE","DOCTYPE_NAME","CUSTOM_ELEMENT","NODE_TYPE","attribute","cdataSection","entityReference","entityNode","progressingInstruction","comment","document","documentType","documentFragment","notation","getGlobal","window","_createTrustedTypesPolicy","trustedTypes","purifyHostElement","createPolicy","suffix","ATTR_NAME","hasAttribute","getAttribute","policyName","createHTML","createScriptURL","scriptUrl","_","console","warn","createDOMPurify","DOMPurify","root","version","VERSION","removed","nodeType","isSupported","originalDocument","currentScript","DocumentFragment","HTMLTemplateElement","Node","Element","NodeFilter","NamedNodeMap","MozNamedAttrMap","HTMLFormElement","DOMParser","ElementPrototype","cloneNode","remove","getNextSibling","getChildNodes","getParentNode","template","createElement","content","ownerDocument","trustedTypesPolicy","emptyHTML","implementation","createNodeIterator","createDocumentFragment","getElementsByTagName","importNode","hooks","createHTMLDocument","EXPRESSIONS","ALLOWED_TAGS","DEFAULT_ALLOWED_TAGS","TAGS","ALLOWED_ATTR","DEFAULT_ALLOWED_ATTR","ATTRS","CUSTOM_ELEMENT_HANDLING","tagNameCheck","writable","configurable","enumerable","attributeNameCheck","allowCustomizedBuiltInElements","FORBID_TAGS","FORBID_ATTR","ALLOW_ARIA_ATTR","ALLOW_DATA_ATTR","ALLOW_UNKNOWN_PROTOCOLS","ALLOW_SELF_CLOSE_IN_ATTR","SAFE_FOR_TEMPLATES","SAFE_FOR_XML","WHOLE_DOCUMENT","SET_CONFIG","FORCE_BODY","RETURN_DOM","RETURN_DOM_FRAGMENT","RETURN_TRUSTED_TYPE","SANITIZE_DOM","SANITIZE_NAMED_PROPS","SANITIZE_NAMED_PROPS_PREFIX","KEEP_CONTENT","IN_PLACE","USE_PROFILES","FORBID_CONTENTS","DEFAULT_FORBID_CONTENTS","DATA_URI_TAGS","DEFAULT_DATA_URI_TAGS","URI_SAFE_ATTRIBUTES","DEFAULT_URI_SAFE_ATTRIBUTES","MATHML_NAMESPACE","SVG_NAMESPACE","HTML_NAMESPACE","NAMESPACE","IS_EMPTY_INPUT","ALLOWED_NAMESPACES","DEFAULT_ALLOWED_NAMESPACES","PARSER_MEDIA_TYPE","SUPPORTED_PARSER_MEDIA_TYPES","DEFAULT_PARSER_MEDIA_TYPE","CONFIG","formElement","isRegexOrFunction","testValue","Function","_parseConfig","cfg","ADD_URI_SAFE_ATTR","ADD_DATA_URI_TAGS","ALLOWED_URI_REGEXP","ADD_TAGS","ADD_ATTR","table","tbody","TRUSTED_TYPES_POLICY","MATHML_TEXT_INTEGRATION_POINTS","HTML_INTEGRATION_POINTS","COMMON_SVG_AND_HTML_ELEMENTS","ALL_SVG_TAGS","ALL_MATHML_TAGS","_checkValidNamespace","parent","tagName","namespaceURI","parentTagName","Boolean","_forceRemove","node","removeChild","_removeAttribute","name","getAttributeNode","from","removeAttribute","setAttribute","_initDocument","dirty","doc","leadingWhitespace","matches","dirtyPayload","parseFromString","documentElement","createDocument","innerHTML","body","insertBefore","createTextNode","childNodes","call","_createNodeIterator","SHOW_ELEMENT","SHOW_COMMENT","SHOW_TEXT","SHOW_PROCESSING_INSTRUCTION","SHOW_CDATA_SECTION","_isClobbered","elm","nodeName","textContent","attributes","hasChildNodes","_isNode","_executeHook","entryPoint","currentNode","data","hook","_sanitizeElements","allowedTags","firstElementChild","_isBasicCustomElement","parentNode","childCount","i","childClone","__removalCount","expr","_isValidAttribute","lcTag","lcName","_sanitizeAttributes","hookEvent","attrName","attrValue","keepAttr","allowedAttributes","attr","forceKeepAttr","getAttributeType","setAttributeNS","_sanitizeShadowDOM","fragment","shadowNode","shadowIterator","nextNode","sanitize","importedNode","returnNode","appendChild","firstChild","nodeIterator","shadowroot","shadowrootmode","serializedHTML","outerHTML","doctype","setConfig","clearConfig","isValidAttribute","tag","addHook","hookFunction","removeHook","removeHooks","removeAllHooks"],"mappings":";;AAAA,MAAM;EACJA,OAAO;EACPC,cAAc;EACdC,QAAQ;EACRC,cAAc;AACdC,EAAAA,wBAAAA;AACF,CAAC,GAAGC,MAAM,CAAA;AAEV,IAAI;EAAEC,MAAM;EAAEC,IAAI;AAAEC,EAAAA,MAAAA;AAAO,CAAC,GAAGH,MAAM,CAAC;AACtC,IAAI;EAAEI,KAAK;AAAEC,EAAAA,SAAAA;AAAU,CAAC,GAAG,OAAOC,OAAO,KAAK,WAAW,IAAIA,OAAO,CAAA;AAEpE,IAAI,CAACL,MAAM,EAAE;AACXA,EAAAA,MAAM,GAAG,SAAAA,MAAUM,CAAAA,CAAC,EAAE;AACpB,IAAA,OAAOA,CAAC,CAAA;GACT,CAAA;AACH,CAAA;AAEA,IAAI,CAACL,IAAI,EAAE;AACTA,EAAAA,IAAI,GAAG,SAAAA,IAAUK,CAAAA,CAAC,EAAE;AAClB,IAAA,OAAOA,CAAC,CAAA;GACT,CAAA;AACH,CAAA;AAEA,IAAI,CAACH,KAAK,EAAE;EACVA,KAAK,GA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EAAE,CAAA;GACX,CAAA;AAED,EAAA,OAAOnC,SAAS,CAAA;AAClB,CAAA;AAEA,aAAeD,eAAe,EAAE;;;;"} \ No newline at end of file diff --git a/umap/static/umap/vendors/locatecontrol/L.Control.Locate.min.js b/umap/static/umap/vendors/locatecontrol/L.Control.Locate.min.js index d73bae46f..6a48bbeb8 100644 --- a/umap/static/umap/vendors/locatecontrol/L.Control.Locate.min.js +++ b/umap/static/umap/vendors/locatecontrol/L.Control.Locate.min.js @@ -1,4 +1,4 @@ -/*! Version: 0.79.0 +/*! Version: 0.81.1 Copyright (c) 2016 Dominik Moritz */ -!function(t,i){"function"==typeof define&&define.amd?define(["leaflet"],t):"object"==typeof exports&&(void 0!==i&&i.L?module.exports=t(L):module.exports=t(require("leaflet"))),void 0!==i&&i.L&&(i.L.Control.Locate=t(L))}(function(l){const s=(i,s,t)=>{(t=t.split(" ")).forEach(function(t){l.DomUtil[i].call(this,s,t)})},i=(t,i)=>s("addClass",t,i),o=(t,i)=>s("removeClass",t,i);var t=l.Marker.extend({initialize(t,i){l.Util.setOptions(this,i),this._latlng=t,this.createIcon()},createIcon(){var t=this.options;let i="";void 0!==t.color&&(i+=`stroke:${t.color};`),void 0!==t.weight&&(i+=`stroke-width:${t.weight};`),void 0!==t.fillColor&&(i+=`fill:${t.fillColor};`),void 0!==t.fillOpacity&&(i+=`fill-opacity:${t.fillOpacity};`),void 0!==t.opacity&&(i+=`opacity:${t.opacity};`);t=this._getIconSVG(t,i);this._locationIcon=l.divIcon({className:t.className,html:t.svg,iconSize:[t.w,t.h]}),this.setIcon(this._locationIcon)},_getIconSVG(t,i){var s=t.radius,t=s+t.weight,o=2*t;return{className:"leaflet-control-locate-location",svg:``+'',w:o,h:o}},setStyle(t){l.Util.setOptions(this,t),this.createIcon()}}),e=t.extend({initialize(t,i,s){l.Util.setOptions(this,s),this._latlng=t,this._heading=i,this.createIcon()},setHeading(t){this._heading=t},_getIconSVG(t,i){var s=t.radius,o=t.width+t.weight,s=2*(s+t.depth+t.weight),t=`M0,0 l${t.width/2},${t.depth} l-${o},0 z`;return{className:"leaflet-control-locate-heading",svg:``+'',w:o,h:s}}}),t=l.Control.extend({options:{position:"topleft",layer:void 0,setView:"untilPanOrZoom",keepCurrentZoomLevel:!1,initialZoomLevel:!1,getLocationBounds(t){return t.bounds},flyTo:!1,clickBehavior:{inView:"stop",outOfView:"setView",inViewNotFollowing:"inView"},returnToPrevBounds:!1,cacheLocation:!0,drawCircle:!0,drawMarker:!0,showCompass:!0,markerClass:t,compassClass:e,circleStyle:{className:"leaflet-control-locate-circle",color:"#136AEC",fillColor:"#136AEC",fillOpacity:.15,weight:0},markerStyle:{className:"leaflet-control-locate-marker",color:"#fff",fillColor:"#2A93EE",fillOpacity:1,weight:3,opacity:1,radius:9},compassStyle:{fillColor:"#2A93EE",fillOpacity:1,weight:0,color:"#fff",opacity:1,radius:9,width:9,depth:6},followCircleStyle:{},followMarkerStyle:{},followCompassStyle:{},icon:"leaflet-control-locate-location-arrow",iconLoading:"leaflet-control-locate-spinner",iconElementTag:"span",textElementTag:"small",circlePadding:[0,0],metric:!0,createButtonCallback(t,i){var t=l.DomUtil.create("a","leaflet-bar-part leaflet-bar-part-single",t),s=(t.title=i.strings.title,t.href="#",t.setAttribute("role","button"),l.DomUtil.create(i.iconElementTag,i.icon,t));return void 0!==i.strings.text&&(l.DomUtil.create(i.textElementTag,"leaflet-locate-text",t).textContent=i.strings.text,t.classList.add("leaflet-locate-text-active"),t.parentNode.style.display="flex",0new l.Control.Locate(t),t},window); +!function(t,i){"function"==typeof define&&define.amd?define(["leaflet"],t):"object"==typeof exports&&(void 0!==i&&i.L?module.exports=t(L):module.exports=t(require("leaflet"))),void 0!==i&&i.L&&(i.L.Control.Locate=t(L))}(function(l){const s=(i,s,t)=>{(t=t.split(" ")).forEach(function(t){l.DomUtil[i].call(this,s,t)})},i=(t,i)=>s("addClass",t,i),o=(t,i)=>s("removeClass",t,i);var t=l.Marker.extend({initialize(t,i){l.Util.setOptions(this,i),this._latlng=t,this.createIcon()},createIcon(){var t=this.options;let i="";void 0!==t.color&&(i+=`stroke:${t.color};`),void 0!==t.weight&&(i+=`stroke-width:${t.weight};`),void 0!==t.fillColor&&(i+=`fill:${t.fillColor};`),void 0!==t.fillOpacity&&(i+=`fill-opacity:${t.fillOpacity};`),void 0!==t.opacity&&(i+=`opacity:${t.opacity};`);t=this._getIconSVG(t,i);this._locationIcon=l.divIcon({className:t.className,html:t.svg,iconSize:[t.w,t.h]}),this.setIcon(this._locationIcon)},_getIconSVG(t,i){var s=t.radius,t=s+t.weight,o=2*t;return{className:"leaflet-control-locate-location",svg:``+'',w:o,h:o}},setStyle(t){l.Util.setOptions(this,t),this.createIcon()}}),e=t.extend({initialize(t,i,s){l.Util.setOptions(this,s),this._latlng=t,this._heading=i,this.createIcon()},setHeading(t){this._heading=t},_getIconSVG(t,i){var s=t.radius,o=t.width+t.weight,s=2*(s+t.depth+t.weight),t=`M0,0 l${t.width/2},${t.depth} l-${o},0 z`;return{className:"leaflet-control-locate-heading",svg:``+'',w:o,h:s}}}),t=l.Control.extend({options:{position:"topleft",layer:void 0,setView:"untilPanOrZoom",keepCurrentZoomLevel:!1,initialZoomLevel:!1,getLocationBounds(t){return t.bounds},flyTo:!1,clickBehavior:{inView:"stop",outOfView:"setView",inViewNotFollowing:"inView"},returnToPrevBounds:!1,cacheLocation:!0,drawCircle:!0,drawMarker:!0,showCompass:!0,markerClass:t,compassClass:e,circleStyle:{className:"leaflet-control-locate-circle",color:"#136AEC",fillColor:"#136AEC",fillOpacity:.15,weight:0},markerStyle:{className:"leaflet-control-locate-marker",color:"#fff",fillColor:"#2A93EE",fillOpacity:1,weight:3,opacity:1,radius:9},compassStyle:{fillColor:"#2A93EE",fillOpacity:1,weight:0,color:"#fff",opacity:1,radius:9,width:9,depth:6},followCircleStyle:{},followMarkerStyle:{},followCompassStyle:{},icon:"leaflet-control-locate-location-arrow",iconLoading:"leaflet-control-locate-spinner",iconElementTag:"span",textElementTag:"small",circlePadding:[0,0],metric:!0,createButtonCallback(t,i){var t=l.DomUtil.create("a","leaflet-bar-part leaflet-bar-part-single",t),s=(t.title=i.strings.title,t.href="#",t.setAttribute("role","button"),l.DomUtil.create(i.iconElementTag,i.icon,t));return void 0!==i.strings.text&&(l.DomUtil.create(i.textElementTag,"leaflet-locate-text",t).textContent=i.strings.text,t.classList.add("leaflet-locate-text-active"),t.parentNode.style.display="flex",0new l.Control.Locate(t),t},window); //# sourceMappingURL=L.Control.Locate.min.js.map \ No newline at end of file diff --git a/umap/static/umap/vendors/locatecontrol/L.Control.Locate.min.js.map b/umap/static/umap/vendors/locatecontrol/L.Control.Locate.min.js.map index c42de2ffa..c99f4ff18 100644 --- a/umap/static/umap/vendors/locatecontrol/L.Control.Locate.min.js.map +++ b/umap/static/umap/vendors/locatecontrol/L.Control.Locate.min.js.map @@ -1 +1 @@ -{"version":3,"file":"L.Control.Locate.min.js","sources":["../src/L.Control.Locate.js"],"names":["factory","window","define","amd","exports","L","module","require","Control","Locate","LDomUtilApplyClassesMethod","method","element","classNames","split","forEach","className","DomUtil","call","this","addClasses","el","names","removeClasses","LocationMarker","Marker","extend","initialize","latlng","options","Util","setOptions","_latlng","createIcon","opt","let","style","undefined","color","weight","fillColor","fillOpacity","opacity","icon","_getIconSVG","_locationIcon","divIcon","html","svg","iconSize","w","h","setIcon","r","radius","s","s2","setStyle","CompassMarker","heading","_heading","setHeading","width","depth","path","LocateControl","position","layer","setView","keepCurrentZoomLevel","initialZoomLevel","getLocationBounds","locationEvent","bounds","flyTo","clickBehavior","inView","outOfView","inViewNotFollowing","returnToPrevBounds","cacheLocation","drawCircle","drawMarker","showCompass","markerClass","compassClass","circleStyle","markerStyle","compassStyle","followCircleStyle","followMarkerStyle","followCompassStyle","iconLoading","iconElementTag","textElementTag","circlePadding","metric","createButtonCallback","container","link","create","title","strings","href","setAttribute","text","textContent","classList","add","parentNode","display","length","onLocationError","err","control","alert","message","onLocationOutsideMapBounds","stop","outsideMapBoundsMsg","showPopup","metersUnit","feetUnit","popup","locateOptions","maxZoom","Infinity","watch","i","onAdd","map","linkAndIcon","_container","_map","_layer","LayerGroup","addTo","_event","_compassHeading","_prevBounds","_link","_icon","DomEvent","on","ev","stopPropagation","preventDefault","_onClick","_resetVariables","_unload","_justClicked","wasFollowing","_isFollowing","_userPanned","_userZoomed","_active","behaviors","behavior","getBounds","contains","flyToBounds","fitBounds","bind","start","_updateContainerStyle","_activate","_drawMarker","_deactivate","_cleanClasses","_removeMarker","stopFollowing","locate","fire","_onLocationFound","_onLocationError","_onDrag","_onZoom","_onZoomEnd","oriAbs","_this","deviceorientation","_onDeviceOrientation","DeviceOrientationEvent","requestPermission","then","permissionState","stopLocate","off","f","_isOutsideMapBounds","latitude","longitude","panTo","_ignoreEvent","padding","requestAnimFrame","_drawCompass","cStyle","_compass","setLatLng","removeFrom","accuracy","mStyle","_circle","setRadius","circle","distance","unit","toFixed","_marker","t","getPopupText","template","bindPopup","_popup","clearLayers","_setCompassHeading","angle","isNaN","parseFloat","isFinite","Math","round","_onCompassNeedsCalibration","e","webkitCompassHeading","absolute","alpha","code","lat","lng","pad","getLatLng","maxBounds","_setClasses","state","removeClass"],"mappings":";;AAMA,CAAA,SAAWA,EAASC,GAKI,YAAlB,OAAOC,QAAyBA,OAAOC,IACzCD,OAAO,CAAC,WAAYF,CAAO,EAGC,UAAnB,OAAOI,UACM,KAAA,IAAXH,GAA0BA,EAAOI,EAC1CC,OAAOF,QAAUJ,EAAQK,CAAC,EAE1BC,OAAOF,QAAUJ,EAAQO,QAAQ,SAAS,CAAC,GAKzB,KAAA,IAAXN,GAA0BA,EAAOI,IAC1CJ,EAAOI,EAAEG,QAAQC,OAAST,EAAQK,CAAC,EAEtC,EAAE,SAAUA,GACX,MAAMK,EAA6B,CAACC,EAAQC,EAASC,MACnDA,EAAaA,EAAWC,MAAM,GAAG,GACtBC,QAAQ,SAAUC,GAC3BX,EAAEY,QAAQN,GAAQO,KAAKC,KAAMP,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line at end of file +{"version":3,"file":"L.Control.Locate.min.js","sources":["../src/L.Control.Locate.js"],"names":["factory","window","define","amd","exports","L","module","require","Control","Locate","LDomUtilApplyClassesMethod","method","element","classNames","split","forEach","className","DomUtil","call","this","addClasses","el","names","removeClasses","LocationMarker","Marker","extend","initialize","latlng","options","Util","setOptions","_latlng","createIcon","opt","let","style","undefined","color","weight","fillColor","fillOpacity","opacity","icon","_getIconSVG","_locationIcon","divIcon","html","svg","iconSize","w","h","setIcon","r","radius","s","s2","setStyle","CompassMarker","heading","_heading","setHeading","width","depth","path","LocateControl","position","layer","setView","keepCurrentZoomLevel","initialZoomLevel","getLocationBounds","locationEvent","bounds","flyTo","clickBehavior","inView","outOfView","inViewNotFollowing","returnToPrevBounds","cacheLocation","drawCircle","drawMarker","showCompass","markerClass","compassClass","circleStyle","markerStyle","compassStyle","followCircleStyle","followMarkerStyle","followCompassStyle","iconLoading","iconElementTag","textElementTag","circlePadding","metric","createButtonCallback","container","link","create","title","strings","href","setAttribute","text","textContent","classList","add","parentNode","display","length","onLocationError","err","control","alert","message","onLocationOutsideMapBounds","stop","outsideMapBoundsMsg","showPopup","metersUnit","feetUnit","popup","locateOptions","maxZoom","Infinity","watch","i","onAdd","map","linkAndIcon","_container","_map","_layer","LayerGroup","addTo","_event","_compassHeading","_prevBounds","_link","_icon","DomEvent","on","ev","stopPropagation","preventDefault","_onClick","_resetVariables","_unload","_justClicked","wasFollowing","_isFollowing","_userPanned","_userZoomed","_active","behaviors","behavior","getBounds","contains","flyToBounds","fitBounds","bind","start","_updateContainerStyle","_activate","_drawMarker","_deactivate","_cleanClasses","_removeMarker","stopFollowing","locate","fire","_onLocationFound","_onLocationError","_onDrag","_onZoom","_onZoomEnd","oriAbs","_this","deviceorientation","_onDeviceOrientation","DeviceOrientationEvent","requestPermission","then","permissionState","stopLocate","off","f","_isOutsideMapBounds","latitude","longitude","panTo","_ignoreEvent","padding","requestAnimFrame","_drawCompass","cStyle","_compass","setLatLng","removeFrom","accuracy","mStyle","_circle","setRadius","circle","distance","unit","toFixed","_marker","t","getPopupText","template","bindPopup","_popup","clearLayers","_setCompassHeading","angle","isNaN","parseFloat","isFinite","Math","round","_onCompassNeedsCalibration","e","webkitCompassHeading","absolute","alpha","code","lat","lng","pad","getLatLng","maxBounds","_setClasses","state","removeClass"],"mappings":";;AAMA,CAAA,SAAWA,EAASC,GAKI,YAAlB,OAAOC,QAAyBA,OAAOC,IACzCD,OAAO,CAAC,WAAYF,CAAO,EAGC,UAAnB,OAAOI,UACM,KAAA,IAAXH,GAA0BA,EAAOI,EAC1CC,OAAOF,QAAUJ,EAAQK,CAAC,EAE1BC,OAAOF,QAAUJ,EAAQO,QAAQ,SAAS,CAAC,GAKzB,KAAA,IAAXN,GAA0BA,EAAOI,IAC1CJ,EAAOI,EAAEG,QAAQC,OAAST,EAAQK,CAAC,EAEtC,EAAE,SAAUA,GACX,MAAMK,EAA6B,CAACC,EAAQC,EAASC,MACnDA,EAAaA,EAAWC,MAAM,GAAG,GACtBC,QAAQ,SAAUC,GAC3BX,EAAEY,QAAQN,GAAQO,KAAKC,KAAMP,EAASI,CAAS,CACjD,CAAC,CACH,EAEMI,EAAa,CAACC,EAAIC,IAAUZ,EAA2B,WAAYW,EAAIC,CAAK,EAC5EC,EAAgB,CAACF,EAAIC,IAAUZ,EAA2B,cAAeW,EAAIC,CAAK,EAKxF,IAAME,EAAiBnB,EAAEoB,OAAOC,OAAO,CACrCC,WAAWC,EAAQC,GACjBxB,EAAEyB,KAAKC,WAAWZ,KAAMU,CAAO,EAC/BV,KAAKa,QAAUJ,EACfT,KAAKc,WAAW,CAClB,EAKAA,aACE,IAAMC,EAAMf,KAAKU,QAEjBM,IAAIC,EAAQ,GAEMC,KAAAA,IAAdH,EAAII,QACNF,aAAmBF,EAAII,UAEND,KAAAA,IAAfH,EAAIK,SACNH,mBAAyBF,EAAIK,WAETF,KAAAA,IAAlBH,EAAIM,YACNJ,WAAiBF,EAAIM,cAECH,KAAAA,IAApBH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EAC3ChH,EAAWD,KAAKiH,WAAY,kBAAkB,EAE9C7G,EAAcJ,KAAK0H,MAAO1H,KAAKU,QAAQ+D,WAAW,EAClDxE,EAAWD,KAAK0H,MAAO1H,KAAKU,QAAQc,IAAI,EAE5C,EAKA6H,gBACEnK,EAAEY,QAAQ2N,YAAYzN,KAAKiH,WAAY,YAAY,EACnD/H,EAAEY,QAAQ2N,YAAYzN,KAAKiH,WAAY,QAAQ,EAC/C/H,EAAEY,QAAQ2N,YAAYzN,KAAKiH,WAAY,WAAW,EAElD7G,EAAcJ,KAAK0H,MAAO1H,KAAKU,QAAQ+D,WAAW,EAClDxE,EAAWD,KAAK0H,MAAO1H,KAAKU,QAAQc,IAAI,CAC1C,EAKAyG,kBAEEjI,KAAKwI,QAAU,CAAA,EAIfxI,KAAKmI,aAAe,CAAA,EAGpBnI,KAAKsI,YAAc,CAAA,EAGnBtI,KAAKuI,YAAc,CAAA,CACrB,CACF,CAAC,EAID,OAFArJ,EAAE6G,QAAQyD,OAAS,GAAa,IAAItK,EAAEG,QAAQC,OAAOoB,CAAO,EAErDoC,CACT,EAAGhE,MAAM"} \ No newline at end of file diff --git a/umap/static/umap/vendors/simple-statistics/simple-statistics.min.js b/umap/static/umap/vendors/simple-statistics/simple-statistics.min.js index 1ac567705..86d7c0bf8 100644 --- a/umap/static/umap/vendors/simple-statistics/simple-statistics.min.js +++ b/umap/static/umap/vendors/simple-statistics/simple-statistics.min.js @@ -1,2 +1,2 @@ -!function(r,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((r="undefined"!=typeof globalThis?globalThis:r||self).ss={})}(this,(function(r){"use strict";function t(r){if(0===r.length)return 0;var t,n=r[0],e=0;if("number"!=typeof n)return NaN;for(var a=1;a=Math.abs(r[a])?e+=n-t+r[a]:e+=r[a]-t+n,n=t}return n+e}function n(r){if(0===r.length)throw new Error("mean requires at least one data point");return t(r)/r.length}function e(r,t){var e,a,o=n(r),i=0;if(2===t)for(a=0;ae&&(e=a,n=t),a=1,t=r[o]):a++;return n}function u(r){return r.slice().sort((function(r,t){return r-t}))}function h(r){if(0===r.length)throw new Error("min requires at least one data point");for(var t=r[0],n=1;nt&&(t=r[n]);return t}function l(r){for(var t=0,n=0;n1)throw new Error("quantiles must be between 0 and 1");return 1===t?r[r.length-1]:0===t?r[0]:n%1!=0?r[Math.ceil(n)-1]:r.length%2==0?(r[n-1]+r[n])/2:r[n]}function c(r,t,n,e){for(n=n||0,e=e||r.length-1;e>n;){if(e-n>600){var a=e-n+1,o=t-n+1,i=Math.log(a),u=.5*Math.exp(2*i/3),h=.5*Math.sqrt(i*u*(a-u)/a);o-a/2<0&&(h*=-1),c(r,t,Math.max(n,Math.floor(t-o*u/a+h)),Math.min(e,Math.floor(t+(a-o)*u/a+h)))}var f=r[t],l=n,s=e;for(g(r,n,t),r[e]>f&&g(r,n,e);lf;)s--}r[n]===f?g(r,n,s):g(r,++s,e),s<=t&&(n=s+1),t<=s&&(e=s-1)}}function g(r,t,n){var e=r[t];r[t]=r[n],r[n]=e}function v(r,t){var n=r.slice();if(Array.isArray(t)){!function(r,t){for(var n=[0],e=0;er[r.length-1])return 1;var n=function(r,t){var n=0,e=0,a=r.length;for(;e>>1]?a=n:e=-~n;return e}(r,t);if(r[n]!==t)return n/r.length;n++;var e=function(r,t){var n=0,e=0,a=r.length;for(;e=r[n=e+a>>>1]?e=-~n:a=n;return e}(r,t);if(e===n)return n/r.length;var a=e-n+1;return a*(e+n)/2/a/r.length}function d(r){var t=v(r,.75),n=v(r,.25);if("number"==typeof t&&"number"==typeof n)return t-n}function b(r){return+v(r,.5)}function q(r){for(var t=b(r),n=[],e=0;e0;)e=Math.floor(t()*a--),n=r[a],r[a]=r[e],r[e]=n;return r}function E(r,t){return y(r.slice(),t)}function x(r,t,n){return E(r,n).slice(0,t)}function S(r,t){for(var n=[],e=0;e0){var o=(n[t]-n[r-1])/(t-r+1);a=e[t]-e[r-1]-(t-r+1)*o*o}else a=e[t]-n[t]*n[t]/(t+1);return a<0?0:a}function N(r,t,n,e,a,o,i){if(!(r>t)){var u=Math.floor((r+t)/2);e[n][u]=e[n-1][u-1],a[n][u]=u;var h=n;r>n&&(h=Math.max(h,a[n][r-1]||0)),h=Math.max(h,a[n-1][u]||0);var f,l,s,c=u-1;t=h&&!((f=A(g,u,o,i))+e[n-1][h-1]>=e[n][u]);--g)(l=A(h,u,o,i)+e[n-1][h-1])0?1:0},V.prototype.train=function(r,t){if(0!==t&&1!==t)return null;r.length!==this.weights.length&&(this.weights=r,this.bias=1);var n=this.predict(r);if("number"==typeof n&&n!==t){for(var e=t-n,a=0;a=0?1-n:n-1}function Z(r){var t=8*(Math.PI-3)/(3*Math.PI*(4-Math.PI)),n=Math.sqrt(Math.sqrt(Math.pow(2/(Math.PI*t)+Math.log(1-r*r)/2,2)-Math.log(1-r*r)/t)-(2/(Math.PI*t)+Math.log(1-r*r)/2));return r>=0?n:-n}function $(r){if("number"==typeof r)return r<0?-1:0===r?0:1;throw new TypeError("not a number")}function rr(r,t){for(var n=0,e=0;e1){var u=ir(o,n[t[o]],e),h=or(o,t,n,e);i=(h-u)/Math.max(u,h)}a.push(i)}return a}function or(r,t,n,e){for(var a=t[r],o=Number.MAX_VALUE,i=0;i1)throw new Error("bernoulliDistribution requires probability to be between 0 and 1 inclusive");return[1-r,r]},r.binomialDistribution=function(r,t){if(!(t<0||t>1||r<=0||r%1!=0)){var n=0,e=0,a=[],o=1;do{a[n]=o*Math.pow(t,n)*Math.pow(1-t,r-n),e+=a[n],o=o*(r-++n+1)/n}while(e<.9999);return a}},r.bisect=function(r,t,n,e,a){if("function"!=typeof r)throw new TypeError("func must be a function");for(var o=0;o=0;s--)u[s]<3&&(u[s-1]+=u[s],u.pop(),i[s-1]+=i[s],i.pop());for(var c=0;cr.length)throw new Error("cannot generate more classes than there are data values");var n=u(r);if(1===k(n))return[n];var e=S(t,n.length),a=S(t,n.length);!function(r,t,n){for(var e=t[0].length,a=r[Math.floor(e/2)],o=[],i=[],u=0,h=void 0;u=0;h--){var f=a[h][i];o[h]=n.slice(f,i+1),h>0&&(i=f-1)}return o},r.coefficientOfVariation=function(r){return I(r)/n(r)},r.combinations=function r(t,n){var e,a,o,i,u=[];for(e=0;e=0?J[n]:+(1-J[n]).toFixed(4)},r.epsilon=F,r.equalIntervalBreaks=function(r,t){if(r.length<2)return r;for(var n=h(r),e=f(r),a=[n],o=(e-n)/t,i=1;in&&(n=r[e]),r[e]r.length)return null;var n=function(r,t){var n,e,a=[],o=[],i=0;for(n=0;n=i+o[g][e-1]&&(a[f][e]=p,o[f][e]=i+o[g][e-1])}a[f][1]=1,o[f][1]=i}return{lowerClassLimits:a,varianceCombinations:o}}(r=r.slice().sort((function(r,t){return r-t})),t);return function(r,t,n){var e=r.length,a=[],o=n;for(a[n]=r[r.length-1];o>0;)a[o-1]=r[t[e][o]-1],e=t[e][o]-1,o--;return a}(r,n.lowerClassLimits,t)},r.kMeansCluster=function(r,t,n){void 0===n&&(n=Math.random);for(var e=null,a=x(r,t,n),o=null,i=Number.MAX_VALUE;0!==i;)e=a,i=er(a=nr(r,o=tr(r,a),t),e);return{labels:o,centroids:a}},r.kde=G,r.kernelDensityEstimation=G,r.linearRegression=function(r){var t,n,e=r.length;if(1===e)t=0,n=r[0][1];else{for(var a,o,i,u=0,h=0,f=0,l=0,s=0;s=1)throw new Error("p must be strictly between zero and one");return Math.log(r/(1-r))},r.mad=q,r.max=f,r.maxSorted=function(r){return r[r.length-1]},r.mean=n,r.meanSimple=R,r.median=b,r.medianAbsoluteDeviation=q,r.medianSorted=function(r){return s(r,.5)},r.min=h,r.minSorted=function(r){return r[0]},r.mode=function(r){return i(u(r))},r.modeFast=function(r){for(var t,n=new Map,e=0,a=0;ae&&(t=r[a],e=o),n.set(r[a],o)}if(0===e)throw new Error("mode requires at last one data point");return t},r.modeSorted=i,r.numericSort=u,r.perceptron=V,r.permutationTest=function(r,t,e,a,o){if(void 0===a&&(a=1e4),void 0===e&&(e="two_side"),"two_side"!==e&&"greater"!==e&&"less"!==e)throw new Error("`alternative` must be either 'two_side', 'greater', or 'less'.");for(var i=n(r)-n(t),u=new Array(a),h=r.concat(t),f=Math.floor(h.length/2),l=0;l=Math.abs(i)&&(v+=1);else if("greater"===e)for(var m=0;m<=a;m++)u[m]>=i&&(v+=1);else for(var w=0;w<=a;w++)u[w]<=i&&(v+=1);return v/a},r.permutationsHeap=function(r){for(var t=new Array(r.length),n=[r.slice()],e=0;e=1&&(r=.9999),Math.sqrt(2)*Z(2*r-1)},r.product=function(r){for(var t=1,n=0;n1?i(n,a):a=[n[o].rank];function i(r,t){for(var n=(t[0]+t[t.length-1])/2,e=0;e=Math.abs(r[a])?e+=n-t+r[a]:e+=r[a]-t+n,n=t}return n+e}function n(r){if(0===r.length)throw new Error("mean requires at least one data point");return t(r)/r.length}function e(r,t){var e,a,o=n(r),i=0;if(2===t)for(a=0;ae&&(e=a,n=t),a=1,t=r[o]):a++;return n}function u(r){return r.slice().sort((function(r,t){return r-t}))}function h(r){if(0===r.length)throw new Error("min requires at least one data point");for(var t=r[0],n=1;nt&&(t=r[n]);return t}function l(r){for(var t=0,n=0;n1)throw new Error("quantiles must be between 0 and 1");return 1===t?r[r.length-1]:0===t?r[0]:n%1!=0?r[Math.ceil(n)-1]:r.length%2==0?(r[n-1]+r[n])/2:r[n]}function c(r,t,n,e){for(n=n||0,e=e||r.length-1;e>n;){if(e-n>600){var a=e-n+1,o=t-n+1,i=Math.log(a),u=.5*Math.exp(2*i/3),h=.5*Math.sqrt(i*u*(a-u)/a);o-a/2<0&&(h*=-1),c(r,t,Math.max(n,Math.floor(t-o*u/a+h)),Math.min(e,Math.floor(t+(a-o)*u/a+h)))}var f=r[t],l=n,s=e;for(g(r,n,t),r[e]>f&&g(r,n,e);lf;)s--}r[n]===f?g(r,n,s):g(r,++s,e),s<=t&&(n=s+1),t<=s&&(e=s-1)}}function g(r,t,n){var e=r[t];r[t]=r[n],r[n]=e}function v(r,t){var n=r.slice();if(Array.isArray(t)){!function(r,t){for(var n=[0],e=0;er[r.length-1])return 1;var n=function(r,t){var n=0,e=0,a=r.length;for(;e>>1]?a=n:e=-~n;return e}(r,t);if(r[n]!==t)return n/r.length;n++;var e=function(r,t){var n=0,e=0,a=r.length;for(;e=r[n=e+a>>>1]?e=-~n:a=n;return e}(r,t);if(e===n)return n/r.length;var a=e-n+1;return a*(e+n)/2/a/r.length}function d(r){var t=v(r,.75),n=v(r,.25);if("number"==typeof t&&"number"==typeof n)return t-n}function b(r){return+v(r,.5)}function q(r){for(var t=b(r),n=[],e=0;e0;)e=Math.floor(t()*a--),n=r[a],r[a]=r[e],r[e]=n;return r}function y(r,t){return E(r.slice(),t)}function N(r,t,n){return y(r,n).slice(0,t)}function S(r,t){for(var n=[],e=0;e0){var o=(n[t]-n[r-1])/(t-r+1);a=e[t]-e[r-1]-(t-r+1)*o*o}else a=e[t]-n[t]*n[t]/(t+1);return a<0?0:a}function I(r,t,n,e,a,o,i){if(!(r>t)){var u=Math.floor((r+t)/2);e[n][u]=e[n-1][u-1],a[n][u]=u;var h=n;r>n&&(h=Math.max(h,a[n][r-1]||0)),h=Math.max(h,a[n-1][u]||0);var f,l,s,c=u-1;t=h&&!((f=k(g,u,o,i))+e[n-1][h-1]>=e[n][u]);--g)(l=k(h,u,o,i)+e[n-1][h-1])0?1:0},F.prototype.train=function(r,t){if(0!==t&&1!==t)return null;r.length!==this.weights.length&&(this.weights=r,this.bias=1);var n=this.predict(r);if("number"==typeof n&&n!==t){for(var e=t-n,a=0;a=0?1-n:n-1}function Z(r){var t=8*(Math.PI-3)/(3*Math.PI*(4-Math.PI)),n=Math.sqrt(Math.sqrt(Math.pow(2/(Math.PI*t)+Math.log(1-r*r)/2,2)-Math.log(1-r*r)/t)-(2/(Math.PI*t)+Math.log(1-r*r)/2));return r>=0?n:-n}function $(r){if("number"==typeof r)return r<0?-1:0===r?0:1;throw new TypeError("not a number")}function rr(r,t){for(var n=0,e=0;e1){var u=ir(o,n[t[o]],e),h=or(o,t,n,e);i=(h-u)/Math.max(u,h)}a.push(i)}return a}function or(r,t,n,e){for(var a=t[r],o=Number.MAX_VALUE,i=0;i1)throw new Error("bernoulliDistribution requires probability to be between 0 and 1 inclusive");return[1-r,r]},r.binomialDistribution=function(r,t){if(!(t<0||t>1||r<=0||r%1!=0)){var n=0,e=0,a=[],o=1;do{a[n]=o*Math.pow(t,n)*Math.pow(1-t,r-n),e+=a[n],o=o*(r-++n+1)/n}while(e<.9999);return a}},r.bisect=function(r,t,n,e,a){if("function"!=typeof r)throw new TypeError("func must be a function");for(var o=0;o=0;s--)u[s]<3&&(u[s-1]+=u[s],u.pop(),i[s-1]+=i[s],i.pop());for(var c=0;cr.length)throw new Error("cannot generate more classes than there are data values");var n=u(r);if(1===x(n))return[n];var e=S(t,n.length),a=S(t,n.length);!function(r,t,n){for(var e=t[0].length,a=r[Math.floor(e/2)],o=[],i=[],u=0,h=void 0;u=0;h--){var f=a[h][i];o[h]=n.slice(f,i+1),h>0&&(i=f-1)}return o},r.coefficientOfVariation=function(r){return C(r)/n(r)},r.combinations=function r(t,n){var e,a,o,i,u=[];for(e=0;e=0?W[n]:Math.round(1e4*(1-W[n]))/1e4},r.epsilon=L,r.equalIntervalBreaks=function(r,t){if(r.length<2)return r;for(var n=h(r),e=f(r),a=[n],o=(e-n)/t,i=1;in&&(n=r[e]),r[e]r.length)return null;var n=function(r,t){var n,e,a=[],o=[],i=0;for(n=0;n=i+o[g][e-1]&&(a[f][e]=p,o[f][e]=i+o[g][e-1])}a[f][1]=1,o[f][1]=i}return{lowerClassLimits:a,varianceCombinations:o}}(r=r.slice().sort((function(r,t){return r-t})),t);return function(r,t,n){var e=r.length,a=[],o=n;for(a[n]=r[r.length-1];o>0;)a[o-1]=r[t[e][o]-1],e=t[e][o]-1,o--;return a}(r,n.lowerClassLimits,t)},r.kMeansCluster=function(r,t,n){void 0===n&&(n=Math.random);for(var e=null,a=N(r,t,n),o=null,i=Number.MAX_VALUE;0!==i;)e=a,i=er(a=nr(r,o=tr(r,a),t),e);return{labels:o,centroids:a}},r.kde=Y,r.kernelDensityEstimation=Y,r.linearRegression=function(r){var t,n,e=r.length;if(1===e)t=0,n=r[0][1];else{for(var a,o,i,u=0,h=0,f=0,l=0,s=0;s=1)throw new Error("p must be strictly between zero and one");return Math.log(r/(1-r))},r.mad=q,r.max=f,r.maxSorted=function(r){return r[r.length-1]},r.mean=n,r.meanSimple=D,r.median=b,r.medianAbsoluteDeviation=q,r.medianSorted=function(r){return s(r,.5)},r.min=h,r.minSorted=function(r){return r[0]},r.mode=function(r){return i(u(r))},r.modeFast=function(r){for(var t,n=new Map,e=0,a=0;ae&&(t=r[a],e=o),n.set(r[a],o)}if(0===e)throw new Error("mode requires at last one data point");return t},r.modeSorted=i,r.numericSort=u,r.perceptron=F,r.permutationTest=function(r,t,e,a,o){if(void 0===a&&(a=1e4),void 0===e&&(e="two_side"),"two_side"!==e&&"greater"!==e&&"less"!==e)throw new Error("`alternative` must be either 'two_side', 'greater', or 'less'.");for(var i=n(r)-n(t),u=new Array(a),h=r.concat(t),f=Math.floor(h.length/2),l=0;l=Math.abs(i)&&(v+=1);else if("greater"===e)for(var m=0;m<=a;m++)u[m]>=i&&(v+=1);else for(var w=0;w<=a;w++)u[w]<=i&&(v+=1);return v/a},r.permutationsHeap=function(r){for(var t=new Array(r.length),n=[r.slice()],e=0;e=1&&(r=.9999),Math.sqrt(2)*Z(2*r-1)},r.product=function(r){for(var t=1,n=0;n1?i(n,a):a=[n[o].rank];function i(r,t){for(var n=(t[0]+t[t.length-1])/2,e=0;e} x input\n * @return {number} sum of all input numbers\n * @example\n * sum([1, 2, 3]); // => 6\n */\nfunction sum(x) {\n // If the array is empty, we needn't bother computing its sum\n if (x.length === 0) {\n return 0;\n }\n\n // Initializing the sum as the first number in the array\n let sum = x[0];\n\n // Keeping track of the floating-point error correction\n let correction = 0;\n\n let transition;\n\n if (typeof sum !== \"number\") {\n return NaN;\n }\n\n for (let i = 1; i < x.length; i++) {\n if (typeof x[i] !== \"number\") {\n return NaN;\n }\n transition = sum + x[i];\n\n // Here we need to update the correction in a different fashion\n // if the new absolute value is greater than the absolute sum\n if (Math.abs(sum) >= Math.abs(x[i])) {\n correction += sum - transition + x[i];\n } else {\n correction += x[i] - transition + sum;\n }\n\n sum = transition;\n }\n\n // Returning the corrected sum\n return sum + correction;\n}\n\nexport default sum;\n","import sum from \"./sum.js\";\n\n/**\n * The mean, _also known as average_,\n * is the sum of all values over the number of values.\n * This is a [measure of central tendency](https://en.wikipedia.org/wiki/Central_tendency):\n * a method of finding a typical or central value of a set of numbers.\n *\n * This runs in `O(n)`, linear time, with respect to the length of the array.\n *\n * @param {Array} x sample of one or more data points\n * @throws {Error} if the length of x is less than one\n * @returns {number} mean\n * @example\n * mean([0, 10]); // => 5\n */\nfunction mean(x) {\n if (x.length === 0) {\n throw new Error(\"mean requires at least one data point\");\n }\n\n return sum(x) / x.length;\n}\n\nexport default mean;\n","import mean from \"./mean.js\";\n\n/**\n * The sum of deviations to the Nth power.\n * When n=2 it's the sum of squared deviations.\n * When n=3 it's the sum of cubed deviations.\n *\n * @param {Array} x\n * @param {number} n power\n * @returns {number} sum of nth power deviations\n *\n * @example\n * var input = [1, 2, 3];\n * // since the variance of a set is the mean squared\n * // deviations, we can calculate that with sumNthPowerDeviations:\n * sumNthPowerDeviations(input, 2) / input.length;\n */\nfunction sumNthPowerDeviations(x, n) {\n const meanValue = mean(x);\n let sum = 0;\n let tempValue;\n let i;\n\n // This is an optimization: when n is 2 (we're computing a number squared),\n // multiplying the number by itself is significantly faster than using\n // the Math.pow method.\n if (n === 2) {\n for (i = 0; i < x.length; i++) {\n tempValue = x[i] - meanValue;\n sum += tempValue * tempValue;\n }\n } else {\n for (i = 0; i < x.length; i++) {\n sum += Math.pow(x[i] - meanValue, n);\n }\n }\n\n return sum;\n}\n\nexport default sumNthPowerDeviations;\n","import sumNthPowerDeviations from \"./sum_nth_power_deviations.js\";\n\n/**\n * The [variance](http://en.wikipedia.org/wiki/Variance)\n * is the sum of squared deviations from the mean.\n *\n * This is an implementation of variance, not sample variance:\n * see the `sampleVariance` method if you want a sample measure.\n *\n * @param {Array} x a population of one or more data points\n * @returns {number} variance: a value greater than or equal to zero.\n * zero indicates that all values are identical.\n * @throws {Error} if x's length is 0\n * @example\n * variance([1, 2, 3, 4, 5, 6]); // => 2.9166666666666665\n */\nfunction variance(x) {\n if (x.length === 0) {\n throw new Error(\"variance requires at least one data point\");\n }\n\n // Find the mean of squared deviations between the\n // mean value and each value.\n return sumNthPowerDeviations(x, 2) / x.length;\n}\n\nexport default variance;\n","import variance from \"./variance.js\";\n\n/**\n * The [standard deviation](http://en.wikipedia.org/wiki/Standard_deviation)\n * is the square root of the variance. This is also known as the population\n * standard deviation. It's useful for measuring the amount\n * of variation or dispersion in a set of values.\n *\n * Standard deviation is only appropriate for full-population knowledge: for\n * samples of a population, {@link sampleStandardDeviation} is\n * more appropriate.\n *\n * @param {Array} x input\n * @returns {number} standard deviation\n * @example\n * variance([2, 4, 4, 4, 5, 5, 7, 9]); // => 4\n * standardDeviation([2, 4, 4, 4, 5, 5, 7, 9]); // => 2\n */\nfunction standardDeviation(x) {\n if (x.length === 1) {\n return 0;\n }\n const v = variance(x);\n return Math.sqrt(v);\n}\n\nexport default standardDeviation;\n","/**\n * The [mode](https://en.wikipedia.org/wiki/Mode_%28statistics%29) is the number\n * that appears in a list the highest number of times.\n * There can be multiple modes in a list: in the event of a tie, this\n * algorithm will return the most recently seen mode.\n *\n * This is a [measure of central tendency](https://en.wikipedia.org/wiki/Central_tendency):\n * a method of finding a typical or central value of a set of numbers.\n *\n * This runs in `O(n)` because the input is sorted.\n *\n * @param {Array} sorted a sample of one or more data points\n * @returns {number} mode\n * @throws {Error} if sorted is empty\n * @example\n * modeSorted([0, 0, 1]); // => 0\n */\nfunction modeSorted(sorted) {\n // Handle edge cases:\n // The mode of an empty list is undefined\n if (sorted.length === 0) {\n throw new Error(\"mode requires at least one data point\");\n } else if (sorted.length === 1) {\n return sorted[0];\n }\n\n // This assumes it is dealing with an array of size > 1, since size\n // 0 and 1 are handled immediately. Hence it starts at index 1 in the\n // array.\n let last = sorted[0],\n // store the mode as we find new modes\n value = NaN,\n // store how many times we've seen the mode\n maxSeen = 0,\n // how many times the current candidate for the mode\n // has been seen\n seenThis = 1;\n\n // end at sorted.length + 1 to fix the case in which the mode is\n // the highest number that occurs in the sequence. the last iteration\n // compares sorted[i], which is undefined, to the highest number\n // in the series\n for (let i = 1; i < sorted.length + 1; i++) {\n // we're seeing a new number pass by\n if (sorted[i] !== last) {\n // the last number is the new mode since we saw it more\n // often than the old one\n if (seenThis > maxSeen) {\n maxSeen = seenThis;\n value = last;\n }\n seenThis = 1;\n last = sorted[i];\n // if this isn't a new number, it's one more occurrence of\n // the potential mode\n } else {\n seenThis++;\n }\n }\n return value;\n}\n\nexport default modeSorted;\n","/**\n * Sort an array of numbers by their numeric value, ensuring that the\n * array is not changed in place.\n *\n * This is necessary because the default behavior of .sort\n * in JavaScript is to sort arrays as string values\n *\n * [1, 10, 12, 102, 20].sort()\n * // output\n * [1, 10, 102, 12, 20]\n *\n * @param {Array} x input array\n * @return {Array} sorted array\n * @private\n * @example\n * numericSort([3, 2, 1]) // => [1, 2, 3]\n */\nfunction numericSort(x) {\n return (\n x\n // ensure the array is not changed in-place\n .slice()\n // comparator function that treats input as numeric\n .sort(function (a, b) {\n return a - b;\n })\n );\n}\n\nexport default numericSort;\n","/**\n * The min is the lowest number in the array.\n * This runs in `O(n)`, linear time, with respect to the length of the array.\n *\n * @param {Array} x sample of one or more data points\n * @throws {Error} if the length of x is less than one\n * @returns {number} minimum value\n * @example\n * min([1, 5, -10, 100, 2]); // => -10\n */\nfunction min(x) {\n if (x.length === 0) {\n throw new Error(\"min requires at least one data point\");\n }\n\n let value = x[0];\n for (let i = 1; i < x.length; i++) {\n if (x[i] < value) {\n value = x[i];\n }\n }\n return value;\n}\n\nexport default min;\n","/**\n * This computes the maximum number in an array.\n *\n * This runs in `O(n)`, linear time, with respect to the length of the array.\n *\n * @param {Array} x sample of one or more data points\n * @returns {number} maximum value\n * @throws {Error} if the length of x is less than one\n * @example\n * max([1, 2, 3, 4]);\n * // => 4\n */\nfunction max(x) {\n if (x.length === 0) {\n throw new Error(\"max requires at least one data point\");\n }\n\n let value = x[0];\n for (let i = 1; i < x.length; i++) {\n if (x[i] > value) {\n value = x[i];\n }\n }\n return value;\n}\n\nexport default max;\n","/**\n * The simple [sum](https://en.wikipedia.org/wiki/Summation) of an array\n * is the result of adding all numbers together, starting from zero.\n *\n * This runs in `O(n)`, linear time, with respect to the length of the array.\n *\n * @param {Array} x input\n * @return {number} sum of all input numbers\n * @example\n * sumSimple([1, 2, 3]); // => 6\n */\nfunction sumSimple(x) {\n let value = 0;\n for (let i = 0; i < x.length; i++) {\n if (typeof x[i] !== \"number\") {\n return NaN;\n }\n value += x[i];\n }\n return value;\n}\n\nexport default sumSimple;\n","/**\n * This is the internal implementation of quantiles: when you know\n * that the order is sorted, you don't need to re-sort it, and the computations\n * are faster.\n *\n * @param {Array} x sample of one or more data points\n * @param {number} p desired quantile: a number between 0 to 1, inclusive\n * @returns {number} quantile value\n * @throws {Error} if p ix outside of the range from 0 to 1\n * @throws {Error} if x is empty\n * @example\n * quantileSorted([3, 6, 7, 8, 8, 9, 10, 13, 15, 16, 20], 0.5); // => 9\n */\nfunction quantileSorted(x, p) {\n const idx = x.length * p;\n if (x.length === 0) {\n throw new Error(\"quantile requires at least one data point.\");\n } else if (p < 0 || p > 1) {\n throw new Error(\"quantiles must be between 0 and 1\");\n } else if (p === 1) {\n // If p is 1, directly return the last element\n return x[x.length - 1];\n } else if (p === 0) {\n // If p is 0, directly return the first element\n return x[0];\n } else if (idx % 1 !== 0) {\n // If p is not integer, return the next element in array\n return x[Math.ceil(idx) - 1];\n } else if (x.length % 2 === 0) {\n // If the list has even-length, we'll take the average of this number\n // and the next value, if there is one\n return (x[idx - 1] + x[idx]) / 2;\n } else {\n // Finally, in the simple case of an integer value\n // with an odd-length list, return the x value at the index.\n return x[idx];\n }\n}\n\nexport default quantileSorted;\n","/**\n * Rearrange items in `arr` so that all items in `[left, k]` range are the smallest.\n * The `k`-th element will have the `(k - left + 1)`-th smallest value in `[left, right]`.\n *\n * Implements Floyd-Rivest selection algorithm https://en.wikipedia.org/wiki/Floyd-Rivest_algorithm\n *\n * @param {Array} arr input array\n * @param {number} k pivot index\n * @param {number} [left] left index\n * @param {number} [right] right index\n * @returns {void} mutates input array\n * @example\n * var arr = [65, 28, 59, 33, 21, 56, 22, 95, 50, 12, 90, 53, 28, 77, 39];\n * quickselect(arr, 8);\n * // = [39, 28, 28, 33, 21, 12, 22, 50, 53, 56, 59, 65, 90, 77, 95]\n */\nfunction quickselect(arr, k, left, right) {\n left = left || 0;\n right = right || arr.length - 1;\n\n while (right > left) {\n // 600 and 0.5 are arbitrary constants chosen in the original paper to minimize execution time\n if (right - left > 600) {\n const n = right - left + 1;\n const m = k - left + 1;\n const z = Math.log(n);\n const s = 0.5 * Math.exp((2 * z) / 3);\n let sd = 0.5 * Math.sqrt((z * s * (n - s)) / n);\n if (m - n / 2 < 0) sd *= -1;\n const newLeft = Math.max(left, Math.floor(k - (m * s) / n + sd));\n const newRight = Math.min(\n right,\n Math.floor(k + ((n - m) * s) / n + sd)\n );\n quickselect(arr, k, newLeft, newRight);\n }\n\n const t = arr[k];\n let i = left;\n let j = right;\n\n swap(arr, left, k);\n if (arr[right] > t) swap(arr, left, right);\n\n while (i < j) {\n swap(arr, i, j);\n i++;\n j--;\n while (arr[i] < t) i++;\n while (arr[j] > t) j--;\n }\n\n if (arr[left] === t) swap(arr, left, j);\n else {\n j++;\n swap(arr, j, right);\n }\n\n if (j <= k) left = j + 1;\n if (k <= j) right = j - 1;\n }\n}\n\nfunction swap(arr, i, j) {\n const tmp = arr[i];\n arr[i] = arr[j];\n arr[j] = tmp;\n}\n\nexport default quickselect;\n","import quantileSorted from \"./quantile_sorted.js\";\nimport quickselect from \"./quickselect.js\";\n\n/**\n * The [quantile](https://en.wikipedia.org/wiki/Quantile):\n * this is a population quantile, since we assume to know the entire\n * dataset in this library. This is an implementation of the\n * [Quantiles of a Population](http://en.wikipedia.org/wiki/Quantile#Quantiles_of_a_population)\n * algorithm from wikipedia.\n *\n * Sample is a one-dimensional array of numbers,\n * and p is either a decimal number from 0 to 1 or an array of decimal\n * numbers from 0 to 1.\n * In terms of a k/q quantile, p = k/q - it's just dealing with fractions or dealing\n * with decimal values.\n * When p is an array, the result of the function is also an array containing the appropriate\n * quantiles in input order\n *\n * @param {Array} x sample of one or more numbers\n * @param {Array | number} p the desired quantile, as a number between 0 and 1\n * @returns {number} quantile\n * @example\n * quantile([3, 6, 7, 8, 8, 9, 10, 13, 15, 16, 20], 0.5); // => 9\n */\nfunction quantile(x, p) {\n const copy = x.slice();\n\n if (Array.isArray(p)) {\n // rearrange elements so that each element corresponding to a requested\n // quantile is on a place it would be if the array was fully sorted\n multiQuantileSelect(copy, p);\n // Initialize the result array\n const results = [];\n // For each requested quantile\n for (let i = 0; i < p.length; i++) {\n results[i] = quantileSorted(copy, p[i]);\n }\n return results;\n } else {\n const idx = quantileIndex(copy.length, p);\n quantileSelect(copy, idx, 0, copy.length - 1);\n return quantileSorted(copy, p);\n }\n}\n\nfunction quantileSelect(arr, k, left, right) {\n if (k % 1 === 0) {\n quickselect(arr, k, left, right);\n } else {\n k = Math.floor(k);\n quickselect(arr, k, left, right);\n quickselect(arr, k + 1, k + 1, right);\n }\n}\n\nfunction multiQuantileSelect(arr, p) {\n const indices = [0];\n for (let i = 0; i < p.length; i++) {\n indices.push(quantileIndex(arr.length, p[i]));\n }\n indices.push(arr.length - 1);\n indices.sort(compare);\n\n const stack = [0, indices.length - 1];\n\n while (stack.length) {\n const r = Math.ceil(stack.pop());\n const l = Math.floor(stack.pop());\n if (r - l <= 1) continue;\n\n const m = Math.floor((l + r) / 2);\n quantileSelect(\n arr,\n indices[m],\n Math.floor(indices[l]),\n Math.ceil(indices[r])\n );\n\n stack.push(l, m, m, r);\n }\n}\n\nfunction compare(a, b) {\n return a - b;\n}\n\nfunction quantileIndex(len, p) {\n const idx = len * p;\n if (p === 1) {\n // If p is 1, directly return the last index\n return len - 1;\n } else if (p === 0) {\n // If p is 0, directly return the first index\n return 0;\n } else if (idx % 1 !== 0) {\n // If index is not integer, return the next index in array\n return Math.ceil(idx) - 1;\n } else if (len % 2 === 0) {\n // If the list has even-length, we'll return the middle of two indices\n // around quantile to indicate that we need an average value of the two\n return idx - 0.5;\n } else {\n // Finally, in the simple case of an integer index\n // with an odd-length list, return the index\n return idx;\n }\n}\n\nexport default quantile;\n","/* eslint no-bitwise: 0 */\n\n/**\n * This function returns the quantile in which one would find the given value in\n * the given array. With a sorted array, leveraging binary search, we can find\n * this information in logarithmic time.\n *\n * @param {Array} x input\n * @returns {number} value value\n * @example\n * quantileRankSorted([1, 2, 3, 4], 3); // => 0.75\n * quantileRankSorted([1, 2, 3, 3, 4], 3); // => 0.7\n * quantileRankSorted([1, 2, 3, 4], 6); // => 1\n * quantileRankSorted([1, 2, 3, 3, 5], 4); // => 0.8\n */\nfunction quantileRankSorted(x, value) {\n // Value is lesser than any value in the array\n if (value < x[0]) {\n return 0;\n }\n\n // Value is greater than any value in the array\n if (value > x[x.length - 1]) {\n return 1;\n }\n\n let l = lowerBound(x, value);\n\n // Value is not in the array\n if (x[l] !== value) {\n return l / x.length;\n }\n\n l++;\n\n const u = upperBound(x, value);\n\n // The value exists only once in the array\n if (u === l) {\n return l / x.length;\n }\n\n // Here, we are basically computing the mean of the range of indices\n // containing our searched value. But, instead, of initializing an\n // array and looping over it, there is a dedicated math formula that\n // we apply below to get the result.\n const r = u - l + 1;\n const sum = (r * (u + l)) / 2;\n const mean = sum / r;\n\n return mean / x.length;\n}\n\nfunction lowerBound(x, value) {\n let mid = 0;\n let lo = 0;\n let hi = x.length;\n\n while (lo < hi) {\n mid = (lo + hi) >>> 1;\n\n if (value <= x[mid]) {\n hi = mid;\n } else {\n lo = -~mid;\n }\n }\n\n return lo;\n}\n\nfunction upperBound(x, value) {\n let mid = 0;\n let lo = 0;\n let hi = x.length;\n\n while (lo < hi) {\n mid = (lo + hi) >>> 1;\n\n if (value >= x[mid]) {\n lo = -~mid;\n } else {\n hi = mid;\n }\n }\n\n return lo;\n}\n\nexport default quantileRankSorted;\n","import quantile from \"./quantile.js\";\n\n/**\n * The [Interquartile range](http://en.wikipedia.org/wiki/Interquartile_range) is\n * a measure of statistical dispersion, or how scattered, spread, or\n * concentrated a distribution is. It's computed as the difference between\n * the third quartile and first quartile.\n *\n * @param {Array} x sample of one or more numbers\n * @returns {number} interquartile range: the span between lower and upper quartile,\n * 0.25 and 0.75\n * @example\n * interquartileRange([0, 1, 2, 3]); // => 2\n */\nfunction interquartileRange(x) {\n // Interquartile range is the span between the upper quartile,\n // at `0.75`, and lower quartile, `0.25`\n const q1 = quantile(x, 0.75);\n const q2 = quantile(x, 0.25);\n\n if (typeof q1 === \"number\" && typeof q2 === \"number\") {\n return q1 - q2;\n }\n}\n\nexport default interquartileRange;\n","import quantile from \"./quantile.js\";\n\n/**\n * The [median](http://en.wikipedia.org/wiki/Median) is\n * the middle number of a list. This is often a good indicator of 'the middle'\n * when there are outliers that skew the `mean()` value.\n * This is a [measure of central tendency](https://en.wikipedia.org/wiki/Central_tendency):\n * a method of finding a typical or central value of a set of numbers.\n *\n * The median isn't necessarily one of the elements in the list: the value\n * can be the average of two elements if the list has an even length\n * and the two central values are different.\n *\n * @param {Array} x input\n * @returns {number} median value\n * @example\n * median([10, 2, 5, 100, 2, 1]); // => 3.5\n */\nfunction median(x) {\n return +quantile(x, 0.5);\n}\n\nexport default median;\n","import median from \"./median.js\";\n\n/**\n * The [Median Absolute Deviation](http://en.wikipedia.org/wiki/Median_absolute_deviation) is\n * a robust measure of statistical\n * dispersion. It is more resilient to outliers than the standard deviation.\n *\n * @param {Array} x input array\n * @returns {number} median absolute deviation\n * @example\n * medianAbsoluteDeviation([1, 1, 2, 2, 4, 6, 9]); // => 1\n */\nfunction medianAbsoluteDeviation(x) {\n const medianValue = median(x);\n const medianAbsoluteDeviations = [];\n\n // Make a list of absolute deviations from the median\n for (let i = 0; i < x.length; i++) {\n medianAbsoluteDeviations.push(Math.abs(x[i] - medianValue));\n }\n\n // Find the median value of that list\n return median(medianAbsoluteDeviations);\n}\n\nexport default medianAbsoluteDeviation;\n","/**\n * A [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle)\n * in-place - which means that it **will change the order of the original\n * array by reference**.\n *\n * This is an algorithm that generates a random [permutation](https://en.wikipedia.org/wiki/Permutation)\n * of a set.\n *\n * @param {Array} x sample of one or more numbers\n * @param {Function} [randomSource=Math.random] an optional entropy source that\n * returns numbers between 0 inclusive and 1 exclusive: the range [0, 1)\n * @returns {Array} x\n * @example\n * var x = [1, 2, 3, 4];\n * shuffleInPlace(x);\n * // x is shuffled to a value like [2, 1, 4, 3]\n */\nfunction shuffleInPlace(x, randomSource) {\n // a custom random number source can be provided if you want to use\n // a fixed seed or another random number generator, like\n // [random-js](https://www.npmjs.org/package/random-js)\n randomSource = randomSource || Math.random;\n\n // store the current length of the x to determine\n // when no elements remain to shuffle.\n let length = x.length;\n\n // temporary is used to hold an item when it is being\n // swapped between indices.\n let temporary;\n\n // The index to swap at each stage.\n let index;\n\n // While there are still items to shuffle\n while (length > 0) {\n // choose a random index within the subset of the array\n // that is not yet shuffled\n index = Math.floor(randomSource() * length--);\n\n // store the value that we'll move temporarily\n temporary = x[length];\n\n // swap the value at `x[length]` with `x[index]`\n x[length] = x[index];\n x[index] = temporary;\n }\n\n return x;\n}\n\nexport default shuffleInPlace;\n","import shuffleInPlace from \"./shuffle_in_place.js\";\n\n/**\n * A [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle)\n * is a fast way to create a random permutation of a finite set. This is\n * a function around `shuffle_in_place` that adds the guarantee that\n * it will not modify its input.\n *\n * @param {Array} x sample of 0 or more numbers\n * @param {Function} [randomSource=Math.random] an optional entropy source that\n * returns numbers between 0 inclusive and 1 exclusive: the range [0, 1)\n * @return {Array} shuffled version of input\n * @example\n * var shuffled = shuffle([1, 2, 3, 4]);\n * shuffled; // = [2, 3, 1, 4] or any other random permutation\n */\nfunction shuffle(x, randomSource) {\n // slice the original array so that it is not modified\n const sample = x.slice();\n\n // and then shuffle that shallow-copied array, in place\n return shuffleInPlace(sample, randomSource);\n}\n\nexport default shuffle;\n","import shuffle from \"./shuffle.js\";\n\n/**\n * Create a [simple random sample](http://en.wikipedia.org/wiki/Simple_random_sample)\n * from a given array of `n` elements.\n *\n * The sampled values will be in any order, not necessarily the order\n * they appear in the input.\n *\n * @param {Array} x input array. can contain any type\n * @param {number} n count of how many elements to take\n * @param {Function} [randomSource=Math.random] an optional entropy source that\n * returns numbers between 0 inclusive and 1 exclusive: the range [0, 1)\n * @return {Array} subset of n elements in original array\n *\n * @example\n * var values = [1, 2, 4, 5, 6, 7, 8, 9];\n * sample(values, 3); // returns 3 random values, like [2, 5, 8];\n */\nfunction sample(x, n, randomSource) {\n // shuffle the original array using a fisher-yates shuffle\n const shuffled = shuffle(x, randomSource);\n\n // and then return a subset of it - the first `n` elements.\n return shuffled.slice(0, n);\n}\n\nexport default sample;\n","/**\n * Create a new column x row matrix.\n *\n * @private\n * @param {number} columns\n * @param {number} rows\n * @return {Array>} matrix\n * @example\n * makeMatrix(10, 10);\n */\nfunction makeMatrix(columns, rows) {\n const matrix = [];\n for (let i = 0; i < columns; i++) {\n const column = [];\n for (let j = 0; j < rows; j++) {\n column.push(0);\n }\n matrix.push(column);\n }\n return matrix;\n}\n\nexport default makeMatrix;\n","/**\n * For a sorted input, counting the number of unique values\n * is possible in constant time and constant memory. This is\n * a simple implementation of the algorithm.\n *\n * Values are compared with `===`, so objects and non-primitive objects\n * are not handled in any special way.\n *\n * @param {Array<*>} x an array of any kind of value\n * @returns {number} count of unique values\n * @example\n * uniqueCountSorted([1, 2, 3]); // => 3\n * uniqueCountSorted([1, 1, 1]); // => 1\n */\nfunction uniqueCountSorted(x) {\n let uniqueValueCount = 0,\n lastSeenValue;\n for (let i = 0; i < x.length; i++) {\n if (i === 0 || x[i] !== lastSeenValue) {\n lastSeenValue = x[i];\n uniqueValueCount++;\n }\n }\n return uniqueValueCount;\n}\n\nexport default uniqueCountSorted;\n","import makeMatrix from \"./make_matrix.js\";\nimport numericSort from \"./numeric_sort.js\";\nimport uniqueCountSorted from \"./unique_count_sorted.js\";\n\n/**\n * Generates incrementally computed values based on the sums and sums of\n * squares for the data array\n *\n * @private\n * @param {number} j\n * @param {number} i\n * @param {Array} sums\n * @param {Array} sumsOfSquares\n * @return {number}\n * @example\n * ssq(0, 1, [-1, 0, 2], [1, 1, 5]);\n */\nfunction ssq(j, i, sums, sumsOfSquares) {\n let sji; // s(j, i)\n if (j > 0) {\n const muji = (sums[i] - sums[j - 1]) / (i - j + 1); // mu(j, i)\n sji =\n sumsOfSquares[i] - sumsOfSquares[j - 1] - (i - j + 1) * muji * muji;\n } else {\n sji = sumsOfSquares[i] - (sums[i] * sums[i]) / (i + 1);\n }\n if (sji < 0) {\n return 0;\n }\n return sji;\n}\n\n/**\n * Function that recursively divides and conquers computations\n * for cluster j\n *\n * @private\n * @param {number} iMin Minimum index in cluster to be computed\n * @param {number} iMax Maximum index in cluster to be computed\n * @param {number} cluster Index of the cluster currently being computed\n * @param {Array>} matrix\n * @param {Array>} backtrackMatrix\n * @param {Array} sums\n * @param {Array} sumsOfSquares\n */\nfunction fillMatrixColumn(\n iMin,\n iMax,\n cluster,\n matrix,\n backtrackMatrix,\n sums,\n sumsOfSquares\n) {\n if (iMin > iMax) {\n return;\n }\n\n // Start at midpoint between iMin and iMax\n const i = Math.floor((iMin + iMax) / 2);\n\n matrix[cluster][i] = matrix[cluster - 1][i - 1];\n backtrackMatrix[cluster][i] = i;\n\n let jlow = cluster; // the lower end for j\n\n if (iMin > cluster) {\n jlow = Math.max(jlow, backtrackMatrix[cluster][iMin - 1] || 0);\n }\n jlow = Math.max(jlow, backtrackMatrix[cluster - 1][i] || 0);\n\n let jhigh = i - 1; // the upper end for j\n if (iMax < matrix[0].length - 1) {\n jhigh = Math.min(jhigh, backtrackMatrix[cluster][iMax + 1] || 0);\n }\n\n let sji;\n let sjlowi;\n let ssqjlow;\n let ssqj;\n for (let j = jhigh; j >= jlow; --j) {\n sji = ssq(j, i, sums, sumsOfSquares);\n\n if (sji + matrix[cluster - 1][jlow - 1] >= matrix[cluster][i]) {\n break;\n }\n\n // Examine the lower bound of the cluster border\n sjlowi = ssq(jlow, i, sums, sumsOfSquares);\n\n ssqjlow = sjlowi + matrix[cluster - 1][jlow - 1];\n\n if (ssqjlow < matrix[cluster][i]) {\n // Shrink the lower bound\n matrix[cluster][i] = ssqjlow;\n backtrackMatrix[cluster][i] = jlow;\n }\n jlow++;\n\n ssqj = sji + matrix[cluster - 1][j - 1];\n if (ssqj < matrix[cluster][i]) {\n matrix[cluster][i] = ssqj;\n backtrackMatrix[cluster][i] = j;\n }\n }\n\n fillMatrixColumn(\n iMin,\n i - 1,\n cluster,\n matrix,\n backtrackMatrix,\n sums,\n sumsOfSquares\n );\n fillMatrixColumn(\n i + 1,\n iMax,\n cluster,\n matrix,\n backtrackMatrix,\n sums,\n sumsOfSquares\n );\n}\n\n/**\n * Initializes the main matrices used in Ckmeans and kicks\n * off the divide and conquer cluster computation strategy\n *\n * @private\n * @param {Array} data sorted array of values\n * @param {Array>} matrix\n * @param {Array>} backtrackMatrix\n */\nfunction fillMatrices(data, matrix, backtrackMatrix) {\n const nValues = matrix[0].length;\n\n // Shift values by the median to improve numeric stability\n const shift = data[Math.floor(nValues / 2)];\n\n // Cumulative sum and cumulative sum of squares for all values in data array\n const sums = [];\n const sumsOfSquares = [];\n\n // Initialize first column in matrix & backtrackMatrix\n for (let i = 0, shiftedValue; i < nValues; ++i) {\n shiftedValue = data[i] - shift;\n if (i === 0) {\n sums.push(shiftedValue);\n sumsOfSquares.push(shiftedValue * shiftedValue);\n } else {\n sums.push(sums[i - 1] + shiftedValue);\n sumsOfSquares.push(\n sumsOfSquares[i - 1] + shiftedValue * shiftedValue\n );\n }\n\n // Initialize for cluster = 0\n matrix[0][i] = ssq(0, i, sums, sumsOfSquares);\n backtrackMatrix[0][i] = 0;\n }\n\n // Initialize the rest of the columns\n let iMin;\n for (let cluster = 1; cluster < matrix.length; ++cluster) {\n if (cluster < matrix.length - 1) {\n iMin = cluster;\n } else {\n // No need to compute matrix[K-1][0] ... matrix[K-1][N-2]\n iMin = nValues - 1;\n }\n\n fillMatrixColumn(\n iMin,\n nValues - 1,\n cluster,\n matrix,\n backtrackMatrix,\n sums,\n sumsOfSquares\n );\n }\n}\n\n/**\n * Ckmeans clustering is an improvement on heuristic-based clustering\n * approaches like Jenks. The algorithm was developed in\n * [Haizhou Wang and Mingzhou Song](http://journal.r-project.org/archive/2011-2/RJournal_2011-2_Wang+Song.pdf)\n * as a [dynamic programming](https://en.wikipedia.org/wiki/Dynamic_programming) approach\n * to the problem of clustering numeric data into groups with the least\n * within-group sum-of-squared-deviations.\n *\n * Minimizing the difference within groups - what Wang & Song refer to as\n * `withinss`, or within sum-of-squares, means that groups are optimally\n * homogenous within and the data is split into representative groups.\n * This is very useful for visualization, where you may want to represent\n * a continuous variable in discrete color or style groups. This function\n * can provide groups that emphasize differences between data.\n *\n * Being a dynamic approach, this algorithm is based on two matrices that\n * store incrementally-computed values for squared deviations and backtracking\n * indexes.\n *\n * This implementation is based on Ckmeans 3.4.6, which introduced a new divide\n * and conquer approach that improved runtime from O(kn^2) to O(kn log(n)).\n *\n * Unlike the [original implementation](https://cran.r-project.org/web/packages/Ckmeans.1d.dp/index.html),\n * this implementation does not include any code to automatically determine\n * the optimal number of clusters: this information needs to be explicitly\n * provided.\n *\n * ### References\n * _Ckmeans.1d.dp: Optimal k-means Clustering in One Dimension by Dynamic\n * Programming_ Haizhou Wang and Mingzhou Song ISSN 2073-4859\n *\n * from The R Journal Vol. 3/2, December 2011\n * @param {Array} x input data, as an array of number values\n * @param {number} nClusters number of desired classes. This cannot be\n * greater than the number of values in the data array.\n * @returns {Array>} clustered input\n * @throws {Error} if the number of requested clusters is higher than the size of the data\n * @example\n * ckmeans([-1, 2, -1, 2, 4, 5, 6, -1, 2, -1], 3);\n * // The input, clustered into groups of similar numbers.\n * //= [[-1, -1, -1, -1], [2, 2, 2], [4, 5, 6]]);\n */\nfunction ckmeans(x, nClusters) {\n if (nClusters > x.length) {\n throw new Error(\n \"cannot generate more classes than there are data values\"\n );\n }\n\n const sorted = numericSort(x);\n // we'll use this as the maximum number of clusters\n const uniqueCount = uniqueCountSorted(sorted);\n\n // if all of the input values are identical, there's one cluster\n // with all of the input in it.\n if (uniqueCount === 1) {\n return [sorted];\n }\n\n // named 'S' originally\n const matrix = makeMatrix(nClusters, sorted.length);\n // named 'J' originally\n const backtrackMatrix = makeMatrix(nClusters, sorted.length);\n\n // This is a dynamic programming way to solve the problem of minimizing\n // within-cluster sum of squares. It's similar to linear regression\n // in this way, and this calculation incrementally computes the\n // sum of squares that are later read.\n fillMatrices(sorted, matrix, backtrackMatrix);\n\n // The real work of Ckmeans clustering happens in the matrix generation:\n // the generated matrices encode all possible clustering combinations, and\n // once they're generated we can solve for the best clustering groups\n // very quickly.\n const clusters = [];\n let clusterRight = backtrackMatrix[0].length - 1;\n\n // Backtrack the clusters from the dynamic programming matrix. This\n // starts at the bottom-right corner of the matrix (if the top-left is 0, 0),\n // and moves the cluster target with the loop.\n for (let cluster = backtrackMatrix.length - 1; cluster >= 0; cluster--) {\n const clusterLeft = backtrackMatrix[cluster][clusterRight];\n\n // fill the cluster from the sorted input by taking a slice of the\n // array. the backtrack matrix makes this easy - it stores the\n // indexes where the cluster should start and end.\n clusters[cluster] = sorted.slice(clusterLeft, clusterRight + 1);\n\n if (cluster > 0) {\n clusterRight = clusterLeft - 1;\n }\n }\n\n return clusters;\n}\n\nexport default ckmeans;\n","import mean from \"./mean.js\";\n\n/**\n * [Sample covariance](https://en.wikipedia.org/wiki/Sample_mean_and_covariance) of two datasets:\n * how much do the two datasets move together?\n * x and y are two datasets, represented as arrays of numbers.\n *\n * @param {Array} x a sample of two or more data points\n * @param {Array} y a sample of two or more data points\n * @throws {Error} if x and y do not have equal lengths\n * @throws {Error} if x or y have length of one or less\n * @returns {number} sample covariance\n * @example\n * sampleCovariance([1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1]); // => -3.5\n */\nfunction sampleCovariance(x, y) {\n // The two datasets must have the same length which must be more than 1\n if (x.length !== y.length) {\n throw new Error(\"sampleCovariance requires samples with equal lengths\");\n }\n\n if (x.length < 2) {\n throw new Error(\n \"sampleCovariance requires at least two data points in each sample\"\n );\n }\n\n // determine the mean of each dataset so that we can judge each\n // value of the dataset fairly as the difference from the mean. this\n // way, if one dataset is [1, 2, 3] and [2, 3, 4], their covariance\n // does not suffer because of the difference in absolute values\n const xmean = mean(x);\n const ymean = mean(y);\n let sum = 0;\n\n // for each pair of values, the covariance increases when their\n // difference from the mean is associated - if both are well above\n // or if both are well below\n // the mean, the covariance increases significantly.\n for (let i = 0; i < x.length; i++) {\n sum += (x[i] - xmean) * (y[i] - ymean);\n }\n\n // this is Bessels' Correction: an adjustment made to sample statistics\n // that allows for the reduced degree of freedom entailed in calculating\n // values from samples rather than complete populations.\n const besselsCorrection = x.length - 1;\n\n // the covariance is weighted by the length of the datasets.\n return sum / besselsCorrection;\n}\n\nexport default sampleCovariance;\n","import sumNthPowerDeviations from \"./sum_nth_power_deviations.js\";\n\n/**\n * The [sample variance](https://en.wikipedia.org/wiki/Variance#Sample_variance)\n * is the sum of squared deviations from the mean. The sample variance\n * is distinguished from the variance by the usage of [Bessel's Correction](https://en.wikipedia.org/wiki/Bessel's_correction):\n * instead of dividing the sum of squared deviations by the length of the input,\n * it is divided by the length minus one. This corrects the bias in estimating\n * a value from a set that you don't know if full.\n *\n * References:\n * * [Wolfram MathWorld on Sample Variance](http://mathworld.wolfram.com/SampleVariance.html)\n *\n * @param {Array} x a sample of two or more data points\n * @throws {Error} if the length of x is less than 2\n * @return {number} sample variance\n * @example\n * sampleVariance([1, 2, 3, 4, 5]); // => 2.5\n */\nfunction sampleVariance(x) {\n if (x.length < 2) {\n throw new Error(\"sampleVariance requires at least two data points\");\n }\n\n const sumSquaredDeviationsValue = sumNthPowerDeviations(x, 2);\n\n // this is Bessels' Correction: an adjustment made to sample statistics\n // that allows for the reduced degree of freedom entailed in calculating\n // values from samples rather than complete populations.\n const besselsCorrection = x.length - 1;\n\n // Find the mean value of that list\n return sumSquaredDeviationsValue / besselsCorrection;\n}\n\nexport default sampleVariance;\n","import sampleVariance from \"./sample_variance.js\";\n\n/**\n * The [sample standard deviation](http://en.wikipedia.org/wiki/Standard_deviation#Sample_standard_deviation)\n * is the square root of the sample variance.\n *\n * @param {Array} x input array\n * @returns {number} sample standard deviation\n * @example\n * sampleStandardDeviation([2, 4, 4, 4, 5, 5, 7, 9]).toFixed(2);\n * // => '2.14'\n */\nfunction sampleStandardDeviation(x) {\n const sampleVarianceX = sampleVariance(x);\n return Math.sqrt(sampleVarianceX);\n}\n\nexport default sampleStandardDeviation;\n","import sampleCovariance from \"./sample_covariance.js\";\nimport sampleStandardDeviation from \"./sample_standard_deviation.js\";\n\n/**\n * The [correlation](http://en.wikipedia.org/wiki/Correlation_and_dependence) is\n * a measure of how correlated two datasets are, between -1 and 1\n *\n * @param {Array} x first input\n * @param {Array} y second input\n * @returns {number} sample correlation\n * @example\n * sampleCorrelation([1, 2, 3, 4, 5, 6], [2, 2, 3, 4, 5, 60]).toFixed(2);\n * // => '0.69'\n */\nfunction sampleCorrelation(x, y) {\n const cov = sampleCovariance(x, y);\n const xstd = sampleStandardDeviation(x);\n const ystd = sampleStandardDeviation(y);\n\n return cov / xstd / ystd;\n}\n\nexport default sampleCorrelation;\n","/**\n * When combining two lists of values for which one already knows the means,\n * one does not have to necessary recompute the mean of the combined lists in\n * linear time. They can instead use this function to compute the combined\n * mean by providing the mean & number of values of the first list and the mean\n * & number of values of the second list.\n *\n * @since 3.0.0\n * @param {number} mean1 mean of the first list\n * @param {number} n1 number of items in the first list\n * @param {number} mean2 mean of the second list\n * @param {number} n2 number of items in the second list\n * @returns {number} the combined mean\n *\n * @example\n * combineMeans(5, 3, 4, 3); // => 4.5\n */\nfunction combineMeans(mean1, n1, mean2, n2) {\n return (mean1 * n1 + mean2 * n2) / (n1 + n2);\n}\n\nexport default combineMeans;\n","import sumSimple from \"./sum_simple.js\";\n\n/**\n * The mean, _also known as average_,\n * is the sum of all values over the number of values.\n * This is a [measure of central tendency](https://en.wikipedia.org/wiki/Central_tendency):\n * a method of finding a typical or central value of a set of numbers.\n *\n * The simple mean uses the successive addition method internally\n * to calculate it's result. Errors in floating-point addition are\n * not accounted for, so if precision is required, the standard {@link mean}\n * method should be used instead.\n *\n * This runs in `O(n)`, linear time, with respect to the length of the array.\n *\n *\n * @param {Array} x sample of one or more data points\n * @throws {Error} if the length of x is less than one\n * @returns {number} mean\n * @example\n * mean([0, 10]); // => 5\n */\nfunction meanSimple(x) {\n if (x.length === 0) {\n throw new Error(\"meanSimple requires at least one data point\");\n }\n\n return sumSimple(x) / x.length;\n}\n\nexport default meanSimple;\n","/**\n * The Root Mean Square (RMS) is\n * a mean function used as a measure of the magnitude of a set\n * of numbers, regardless of their sign.\n * This is the square root of the mean of the squares of the\n * input numbers.\n * This runs in `O(n)`, linear time, with respect to the length of the array.\n *\n * @param {Array} x a sample of one or more data points\n * @returns {number} root mean square\n * @throws {Error} if x is empty\n * @example\n * rootMeanSquare([-1, 1, -1, 1]); // => 1\n */\nfunction rootMeanSquare(x) {\n if (x.length === 0) {\n throw new Error(\"rootMeanSquare requires at least one data point\");\n }\n\n let sumOfSquares = 0;\n for (let i = 0; i < x.length; i++) {\n sumOfSquares += Math.pow(x[i], 2);\n }\n\n return Math.sqrt(sumOfSquares / x.length);\n}\n\nexport default rootMeanSquare;\n","/**\n * [Bayesian Classifier](http://en.wikipedia.org/wiki/Naive_Bayes_classifier)\n *\n * This is a naïve bayesian classifier that takes\n * singly-nested objects.\n *\n * @class\n * @example\n * var bayes = new BayesianClassifier();\n * bayes.train({\n * species: 'Cat'\n * }, 'animal');\n * var result = bayes.score({\n * species: 'Cat'\n * })\n * // result\n * // {\n * // animal: 1\n * // }\n */\nclass BayesianClassifier {\n /*:: totalCount: number */\n /*:: data: Object */\n constructor() {\n // The number of items that are currently\n // classified in the model\n this.totalCount = 0;\n // Every item classified in the model\n this.data = {};\n }\n\n /**\n * Train the classifier with a new item, which has a single\n * dimension of Javascript literal keys and values.\n *\n * @param {Object} item an object with singly-deep properties\n * @param {string} category the category this item belongs to\n * @return {undefined} adds the item to the classifier\n */\n train(item, category) {\n // If the data object doesn't have any values\n // for this category, create a new object for it.\n if (!this.data[category]) {\n this.data[category] = {};\n }\n\n // Iterate through each key in the item.\n for (const k in item) {\n const v = item[k];\n // Initialize the nested object `data[category][k][item[k]]`\n // with an object of keys that equal 0.\n if (this.data[category][k] === undefined) {\n this.data[category][k] = {};\n }\n if (this.data[category][k][v] === undefined) {\n this.data[category][k][v] = 0;\n }\n\n // And increment the key for this key/value combination.\n this.data[category][k][v]++;\n }\n\n // Increment the number of items classified\n this.totalCount++;\n }\n\n /**\n * Generate a score of how well this item matches all\n * possible categories based on its attributes\n *\n * @param {Object} item an item in the same format as with train\n * @returns {Object} of probabilities that this item belongs to a\n * given category.\n */\n score(item) {\n // Initialize an empty array of odds per category.\n const odds = {};\n let category;\n // Iterate through each key in the item,\n // then iterate through each category that has been used\n // in previous calls to `.train()`\n for (const k in item) {\n const v = item[k];\n for (category in this.data) {\n // Create an empty object for storing key - value combinations\n // for this category.\n odds[category] = {};\n\n // If this item doesn't even have a property, it counts for nothing,\n // but if it does have the property that we're looking for from\n // the item to categorize, it counts based on how popular it is\n // versus the whole population.\n if (this.data[category][k]) {\n odds[category][k + \"_\" + v] =\n (this.data[category][k][v] || 0) / this.totalCount;\n } else {\n odds[category][k + \"_\" + v] = 0;\n }\n }\n }\n\n // Set up a new object that will contain sums of these odds by category\n const oddsSums = {};\n\n for (category in odds) {\n // Tally all of the odds for each category-combination pair -\n // the non-existence of a category does not add anything to the\n // score.\n oddsSums[category] = 0;\n for (const combination in odds[category]) {\n oddsSums[category] += odds[category][combination];\n }\n }\n\n return oddsSums;\n }\n}\n\nexport default BayesianClassifier;\n","/**\n * This is a single-layer [Perceptron Classifier](http://en.wikipedia.org/wiki/Perceptron) that takes\n * arrays of numbers and predicts whether they should be classified\n * as either 0 or 1 (negative or positive examples).\n * @class\n * @example\n * // Create the model\n * var p = new PerceptronModel();\n * // Train the model with input with a diagonal boundary.\n * for (var i = 0; i < 5; i++) {\n * p.train([1, 1], 1);\n * p.train([0, 1], 0);\n * p.train([1, 0], 0);\n * p.train([0, 0], 0);\n * }\n * p.predict([0, 0]); // 0\n * p.predict([0, 1]); // 0\n * p.predict([1, 0]); // 0\n * p.predict([1, 1]); // 1\n */\nclass PerceptronModel {\n /*:: bias: number */\n /*:: weights: Array */\n constructor() {\n // The weights, or coefficients of the model;\n // weights are only populated when training with data.\n this.weights = [];\n // The bias term, or intercept; it is also a weight but\n // it's stored separately for convenience as it is always\n // multiplied by one.\n this.bias = 0;\n }\n /**\n * **Predict**: Use an array of features with the weight array and bias\n * to predict whether an example is labeled 0 or 1.\n *\n * @param {Array} features an array of features as numbers\n * @returns {number} 1 if the score is over 0, otherwise 0\n */\n predict(features) {\n // Only predict if previously trained\n // on the same size feature array(s).\n if (features.length !== this.weights.length) {\n return null;\n }\n\n // Calculate the sum of features times weights,\n // with the bias added (implicitly times one).\n let score = 0;\n for (let i = 0; i < this.weights.length; i++) {\n score += this.weights[i] * features[i];\n }\n score += this.bias;\n\n // Classify as 1 if the score is over 0, otherwise 0.\n if (score > 0) {\n return 1;\n } else {\n return 0;\n }\n }\n\n /**\n * **Train** the classifier with a new example, which is\n * a numeric array of features and a 0 or 1 label.\n *\n * @param {Array} features an array of features as numbers\n * @param {number} label either 0 or 1\n * @returns {PerceptronModel} this\n */\n train(features, label) {\n // Require that only labels of 0 or 1 are considered.\n if (label !== 0 && label !== 1) {\n return null;\n }\n // The length of the feature array determines\n // the length of the weight array.\n // The perceptron will continue learning as long as\n // it keeps seeing feature arrays of the same length.\n // When it sees a new data shape, it initializes.\n if (features.length !== this.weights.length) {\n this.weights = features;\n this.bias = 1;\n }\n // Make a prediction based on current weights.\n const prediction = this.predict(features);\n // Update the weights if the prediction is wrong.\n if (typeof prediction === \"number\" && prediction !== label) {\n const gradient = label - prediction;\n for (let i = 0; i < this.weights.length; i++) {\n this.weights[i] += gradient * features[i];\n }\n this.bias += gradient;\n }\n return this;\n }\n}\n\nexport default PerceptronModel;\n","/**\n * We use `ε`, epsilon, as a stopping criterion when we want to iterate\n * until we're \"close enough\". Epsilon is a very small number: for\n * simple statistics, that number is **0.0001**\n *\n * This is used in calculations like the binomialDistribution, in which\n * the process of finding a value is [iterative](https://en.wikipedia.org/wiki/Iterative_method):\n * it progresses until it is close enough.\n *\n * Below is an example of using epsilon in [gradient descent](https://en.wikipedia.org/wiki/Gradient_descent),\n * where we're trying to find a local minimum of a function's derivative,\n * given by the `fDerivative` method.\n *\n * @example\n * // From calculation, we expect that the local minimum occurs at x=9/4\n * var x_old = 0;\n * // The algorithm starts at x=6\n * var x_new = 6;\n * var stepSize = 0.01;\n *\n * function fDerivative(x) {\n * return 4 * Math.pow(x, 3) - 9 * Math.pow(x, 2);\n * }\n *\n * // The loop runs until the difference between the previous\n * // value and the current value is smaller than epsilon - a rough\n * // meaure of 'close enough'\n * while (Math.abs(x_new - x_old) > ss.epsilon) {\n * x_old = x_new;\n * x_new = x_old - stepSize * fDerivative(x_old);\n * }\n *\n * console.log('Local minimum occurs at', x_new);\n */\nconst epsilon = 0.0001;\n\nexport default epsilon;\n","/**\n * A [Factorial](https://en.wikipedia.org/wiki/Factorial), usually written n!, is the product of all positive\n * integers less than or equal to n. Often factorial is implemented\n * recursively, but this iterative approach is significantly faster\n * and simpler.\n *\n * @param {number} n input, must be an integer number 1 or greater\n * @returns {number} factorial: n!\n * @throws {Error} if n is less than 0 or not an integer\n * @example\n * factorial(5); // => 120\n */\nfunction factorial(n) {\n // factorial is mathematically undefined for negative numbers\n if (n < 0) {\n throw new Error(\"factorial requires a non-negative value\");\n }\n\n if (Math.floor(n) !== n) {\n throw new Error(\"factorial requires an integer input\");\n }\n\n // typically you'll expand the factorial function going down, like\n // 5! = 5 * 4 * 3 * 2 * 1. This is going in the opposite direction,\n // counting from 2 up to the number in question, and since anything\n // multiplied by 1 is itself, the loop only needs to start at 2.\n let accumulator = 1;\n for (let i = 2; i <= n; i++) {\n // for each number up to and including the number `n`, multiply\n // the accumulator my that number.\n accumulator *= i;\n }\n return accumulator;\n}\n\nexport default factorial;\n","// Define series coefficients\nconst COEFFICIENTS = [\n 0.99999999999999709182, 57.156235665862923517, -59.597960355475491248,\n 14.136097974741747174, -0.49191381609762019978, 0.33994649984811888699e-4,\n 0.46523628927048575665e-4, -0.98374475304879564677e-4,\n 0.15808870322491248884e-3, -0.21026444172410488319e-3,\n 0.2174396181152126432e-3, -0.16431810653676389022e-3,\n 0.84418223983852743293e-4, -0.2619083840158140867e-4,\n 0.36899182659531622704e-5\n];\n\nconst g = 607 / 128;\nconst LOGSQRT2PI = Math.log(Math.sqrt(2 * Math.PI));\n\n/**\n * Compute the logarithm of the [gamma function](https://en.wikipedia.org/wiki/Gamma_function) of a value using Lanczos' approximation.\n * This function takes as input any real-value n greater than 0.\n * This function is useful for values of n too large for the normal gamma function (n > 165).\n * The code is based on Lanczo's Gamma approximation, defined [here](http://my.fit.edu/~gabdo/gamma.txt).\n *\n * @param {number} n Any real number greater than zero.\n * @returns {number} The logarithm of gamma of the input value.\n *\n * @example\n * gammaln(500); // 2605.1158503617335\n * gammaln(2.4); // 0.21685932244884043\n */\nfunction gammaln(n) {\n // Return infinity if value not in domain\n if (n <= 0) {\n return Infinity;\n }\n\n // Decrement n, because approximation is defined for n - 1\n n--;\n\n // Create series approximation\n let a = COEFFICIENTS[0];\n\n for (let i = 1; i < 15; i++) {\n a += COEFFICIENTS[i] / (n + i);\n }\n\n const tmp = g + 0.5 + n;\n\n // Return natural logarithm of gamma(n)\n return LOGSQRT2PI + Math.log(a) - tmp + (n + 0.5) * Math.log(tmp);\n}\n\nexport default gammaln;\n","/**\n * **Percentage Points of the χ2 (Chi-Squared) Distribution**\n *\n * The [χ2 (Chi-Squared) Distribution](http://en.wikipedia.org/wiki/Chi-squared_distribution) is used in the common\n * chi-squared tests for goodness of fit of an observed distribution to a theoretical one, the independence of two\n * criteria of classification of qualitative data, and in confidence interval estimation for a population standard\n * deviation of a normal distribution from a sample standard deviation.\n *\n * Values from Appendix 1, Table III of William W. Hines & Douglas C. Montgomery, \"Probability and Statistics in\n * Engineering and Management Science\", Wiley (1980).\n */\nconst chiSquaredDistributionTable = {\n 1: {\n 0.995: 0,\n 0.99: 0,\n 0.975: 0,\n 0.95: 0,\n 0.9: 0.02,\n 0.5: 0.45,\n 0.1: 2.71,\n 0.05: 3.84,\n 0.025: 5.02,\n 0.01: 6.63,\n 0.005: 7.88\n },\n 2: {\n 0.995: 0.01,\n 0.99: 0.02,\n 0.975: 0.05,\n 0.95: 0.1,\n 0.9: 0.21,\n 0.5: 1.39,\n 0.1: 4.61,\n 0.05: 5.99,\n 0.025: 7.38,\n 0.01: 9.21,\n 0.005: 10.6\n },\n 3: {\n 0.995: 0.07,\n 0.99: 0.11,\n 0.975: 0.22,\n 0.95: 0.35,\n 0.9: 0.58,\n 0.5: 2.37,\n 0.1: 6.25,\n 0.05: 7.81,\n 0.025: 9.35,\n 0.01: 11.34,\n 0.005: 12.84\n },\n 4: {\n 0.995: 0.21,\n 0.99: 0.3,\n 0.975: 0.48,\n 0.95: 0.71,\n 0.9: 1.06,\n 0.5: 3.36,\n 0.1: 7.78,\n 0.05: 9.49,\n 0.025: 11.14,\n 0.01: 13.28,\n 0.005: 14.86\n },\n 5: {\n 0.995: 0.41,\n 0.99: 0.55,\n 0.975: 0.83,\n 0.95: 1.15,\n 0.9: 1.61,\n 0.5: 4.35,\n 0.1: 9.24,\n 0.05: 11.07,\n 0.025: 12.83,\n 0.01: 15.09,\n 0.005: 16.75\n },\n 6: {\n 0.995: 0.68,\n 0.99: 0.87,\n 0.975: 1.24,\n 0.95: 1.64,\n 0.9: 2.2,\n 0.5: 5.35,\n 0.1: 10.65,\n 0.05: 12.59,\n 0.025: 14.45,\n 0.01: 16.81,\n 0.005: 18.55\n },\n 7: {\n 0.995: 0.99,\n 0.99: 1.25,\n 0.975: 1.69,\n 0.95: 2.17,\n 0.9: 2.83,\n 0.5: 6.35,\n 0.1: 12.02,\n 0.05: 14.07,\n 0.025: 16.01,\n 0.01: 18.48,\n 0.005: 20.28\n },\n 8: {\n 0.995: 1.34,\n 0.99: 1.65,\n 0.975: 2.18,\n 0.95: 2.73,\n 0.9: 3.49,\n 0.5: 7.34,\n 0.1: 13.36,\n 0.05: 15.51,\n 0.025: 17.53,\n 0.01: 20.09,\n 0.005: 21.96\n },\n 9: {\n 0.995: 1.73,\n 0.99: 2.09,\n 0.975: 2.7,\n 0.95: 3.33,\n 0.9: 4.17,\n 0.5: 8.34,\n 0.1: 14.68,\n 0.05: 16.92,\n 0.025: 19.02,\n 0.01: 21.67,\n 0.005: 23.59\n },\n 10: {\n 0.995: 2.16,\n 0.99: 2.56,\n 0.975: 3.25,\n 0.95: 3.94,\n 0.9: 4.87,\n 0.5: 9.34,\n 0.1: 15.99,\n 0.05: 18.31,\n 0.025: 20.48,\n 0.01: 23.21,\n 0.005: 25.19\n },\n 11: {\n 0.995: 2.6,\n 0.99: 3.05,\n 0.975: 3.82,\n 0.95: 4.57,\n 0.9: 5.58,\n 0.5: 10.34,\n 0.1: 17.28,\n 0.05: 19.68,\n 0.025: 21.92,\n 0.01: 24.72,\n 0.005: 26.76\n },\n 12: {\n 0.995: 3.07,\n 0.99: 3.57,\n 0.975: 4.4,\n 0.95: 5.23,\n 0.9: 6.3,\n 0.5: 11.34,\n 0.1: 18.55,\n 0.05: 21.03,\n 0.025: 23.34,\n 0.01: 26.22,\n 0.005: 28.3\n },\n 13: {\n 0.995: 3.57,\n 0.99: 4.11,\n 0.975: 5.01,\n 0.95: 5.89,\n 0.9: 7.04,\n 0.5: 12.34,\n 0.1: 19.81,\n 0.05: 22.36,\n 0.025: 24.74,\n 0.01: 27.69,\n 0.005: 29.82\n },\n 14: {\n 0.995: 4.07,\n 0.99: 4.66,\n 0.975: 5.63,\n 0.95: 6.57,\n 0.9: 7.79,\n 0.5: 13.34,\n 0.1: 21.06,\n 0.05: 23.68,\n 0.025: 26.12,\n 0.01: 29.14,\n 0.005: 31.32\n },\n 15: {\n 0.995: 4.6,\n 0.99: 5.23,\n 0.975: 6.27,\n 0.95: 7.26,\n 0.9: 8.55,\n 0.5: 14.34,\n 0.1: 22.31,\n 0.05: 25,\n 0.025: 27.49,\n 0.01: 30.58,\n 0.005: 32.8\n },\n 16: {\n 0.995: 5.14,\n 0.99: 5.81,\n 0.975: 6.91,\n 0.95: 7.96,\n 0.9: 9.31,\n 0.5: 15.34,\n 0.1: 23.54,\n 0.05: 26.3,\n 0.025: 28.85,\n 0.01: 32,\n 0.005: 34.27\n },\n 17: {\n 0.995: 5.7,\n 0.99: 6.41,\n 0.975: 7.56,\n 0.95: 8.67,\n 0.9: 10.09,\n 0.5: 16.34,\n 0.1: 24.77,\n 0.05: 27.59,\n 0.025: 30.19,\n 0.01: 33.41,\n 0.005: 35.72\n },\n 18: {\n 0.995: 6.26,\n 0.99: 7.01,\n 0.975: 8.23,\n 0.95: 9.39,\n 0.9: 10.87,\n 0.5: 17.34,\n 0.1: 25.99,\n 0.05: 28.87,\n 0.025: 31.53,\n 0.01: 34.81,\n 0.005: 37.16\n },\n 19: {\n 0.995: 6.84,\n 0.99: 7.63,\n 0.975: 8.91,\n 0.95: 10.12,\n 0.9: 11.65,\n 0.5: 18.34,\n 0.1: 27.2,\n 0.05: 30.14,\n 0.025: 32.85,\n 0.01: 36.19,\n 0.005: 38.58\n },\n 20: {\n 0.995: 7.43,\n 0.99: 8.26,\n 0.975: 9.59,\n 0.95: 10.85,\n 0.9: 12.44,\n 0.5: 19.34,\n 0.1: 28.41,\n 0.05: 31.41,\n 0.025: 34.17,\n 0.01: 37.57,\n 0.005: 40\n },\n 21: {\n 0.995: 8.03,\n 0.99: 8.9,\n 0.975: 10.28,\n 0.95: 11.59,\n 0.9: 13.24,\n 0.5: 20.34,\n 0.1: 29.62,\n 0.05: 32.67,\n 0.025: 35.48,\n 0.01: 38.93,\n 0.005: 41.4\n },\n 22: {\n 0.995: 8.64,\n 0.99: 9.54,\n 0.975: 10.98,\n 0.95: 12.34,\n 0.9: 14.04,\n 0.5: 21.34,\n 0.1: 30.81,\n 0.05: 33.92,\n 0.025: 36.78,\n 0.01: 40.29,\n 0.005: 42.8\n },\n 23: {\n 0.995: 9.26,\n 0.99: 10.2,\n 0.975: 11.69,\n 0.95: 13.09,\n 0.9: 14.85,\n 0.5: 22.34,\n 0.1: 32.01,\n 0.05: 35.17,\n 0.025: 38.08,\n 0.01: 41.64,\n 0.005: 44.18\n },\n 24: {\n 0.995: 9.89,\n 0.99: 10.86,\n 0.975: 12.4,\n 0.95: 13.85,\n 0.9: 15.66,\n 0.5: 23.34,\n 0.1: 33.2,\n 0.05: 36.42,\n 0.025: 39.36,\n 0.01: 42.98,\n 0.005: 45.56\n },\n 25: {\n 0.995: 10.52,\n 0.99: 11.52,\n 0.975: 13.12,\n 0.95: 14.61,\n 0.9: 16.47,\n 0.5: 24.34,\n 0.1: 34.28,\n 0.05: 37.65,\n 0.025: 40.65,\n 0.01: 44.31,\n 0.005: 46.93\n },\n 26: {\n 0.995: 11.16,\n 0.99: 12.2,\n 0.975: 13.84,\n 0.95: 15.38,\n 0.9: 17.29,\n 0.5: 25.34,\n 0.1: 35.56,\n 0.05: 38.89,\n 0.025: 41.92,\n 0.01: 45.64,\n 0.005: 48.29\n },\n 27: {\n 0.995: 11.81,\n 0.99: 12.88,\n 0.975: 14.57,\n 0.95: 16.15,\n 0.9: 18.11,\n 0.5: 26.34,\n 0.1: 36.74,\n 0.05: 40.11,\n 0.025: 43.19,\n 0.01: 46.96,\n 0.005: 49.65\n },\n 28: {\n 0.995: 12.46,\n 0.99: 13.57,\n 0.975: 15.31,\n 0.95: 16.93,\n 0.9: 18.94,\n 0.5: 27.34,\n 0.1: 37.92,\n 0.05: 41.34,\n 0.025: 44.46,\n 0.01: 48.28,\n 0.005: 50.99\n },\n 29: {\n 0.995: 13.12,\n 0.99: 14.26,\n 0.975: 16.05,\n 0.95: 17.71,\n 0.9: 19.77,\n 0.5: 28.34,\n 0.1: 39.09,\n 0.05: 42.56,\n 0.025: 45.72,\n 0.01: 49.59,\n 0.005: 52.34\n },\n 30: {\n 0.995: 13.79,\n 0.99: 14.95,\n 0.975: 16.79,\n 0.95: 18.49,\n 0.9: 20.6,\n 0.5: 29.34,\n 0.1: 40.26,\n 0.05: 43.77,\n 0.025: 46.98,\n 0.01: 50.89,\n 0.005: 53.67\n },\n 40: {\n 0.995: 20.71,\n 0.99: 22.16,\n 0.975: 24.43,\n 0.95: 26.51,\n 0.9: 29.05,\n 0.5: 39.34,\n 0.1: 51.81,\n 0.05: 55.76,\n 0.025: 59.34,\n 0.01: 63.69,\n 0.005: 66.77\n },\n 50: {\n 0.995: 27.99,\n 0.99: 29.71,\n 0.975: 32.36,\n 0.95: 34.76,\n 0.9: 37.69,\n 0.5: 49.33,\n 0.1: 63.17,\n 0.05: 67.5,\n 0.025: 71.42,\n 0.01: 76.15,\n 0.005: 79.49\n },\n 60: {\n 0.995: 35.53,\n 0.99: 37.48,\n 0.975: 40.48,\n 0.95: 43.19,\n 0.9: 46.46,\n 0.5: 59.33,\n 0.1: 74.4,\n 0.05: 79.08,\n 0.025: 83.3,\n 0.01: 88.38,\n 0.005: 91.95\n },\n 70: {\n 0.995: 43.28,\n 0.99: 45.44,\n 0.975: 48.76,\n 0.95: 51.74,\n 0.9: 55.33,\n 0.5: 69.33,\n 0.1: 85.53,\n 0.05: 90.53,\n 0.025: 95.02,\n 0.01: 100.42,\n 0.005: 104.22\n },\n 80: {\n 0.995: 51.17,\n 0.99: 53.54,\n 0.975: 57.15,\n 0.95: 60.39,\n 0.9: 64.28,\n 0.5: 79.33,\n 0.1: 96.58,\n 0.05: 101.88,\n 0.025: 106.63,\n 0.01: 112.33,\n 0.005: 116.32\n },\n 90: {\n 0.995: 59.2,\n 0.99: 61.75,\n 0.975: 65.65,\n 0.95: 69.13,\n 0.9: 73.29,\n 0.5: 89.33,\n 0.1: 107.57,\n 0.05: 113.14,\n 0.025: 118.14,\n 0.01: 124.12,\n 0.005: 128.3\n },\n 100: {\n 0.995: 67.33,\n 0.99: 70.06,\n 0.975: 74.22,\n 0.95: 77.93,\n 0.9: 82.36,\n 0.5: 99.33,\n 0.1: 118.5,\n 0.05: 124.34,\n 0.025: 129.56,\n 0.01: 135.81,\n 0.005: 140.17\n }\n};\n\nexport default chiSquaredDistributionTable;\n","import interquartileRange from \"./interquartile_range.js\";\nimport stddev from \"./sample_standard_deviation.js\";\n\nconst SQRT_2PI = Math.sqrt(2 * Math.PI);\n\n/**\n * [Well-known kernels](https://en.wikipedia.org/wiki/Kernel_(statistics)#Kernel_functions_in_common_use)\n * @private\n */\nconst kernels = {\n /**\n * The gaussian kernel.\n * @private\n */\n gaussian: function (u) {\n return Math.exp(-0.5 * u * u) / SQRT_2PI;\n }\n};\n\n/**\n * Well known bandwidth selection methods\n * @private\n */\nconst bandwidthMethods = {\n /**\n * The [\"normal reference distribution\"\n * rule-of-thumb](https://stat.ethz.ch/R-manual/R-devel/library/MASS/html/bandwidth.nrd.html),\n * a commonly used version of [Silverman's\n * rule-of-thumb](https://en.wikipedia.org/wiki/Kernel_density_estimation#A_rule-of-thumb_bandwidth_estimator).\n * @private\n */\n nrd: function (x) {\n let s = stddev(x);\n const iqr = interquartileRange(x);\n if (typeof iqr === \"number\") {\n s = Math.min(s, iqr / 1.34);\n }\n return 1.06 * s * Math.pow(x.length, -0.2);\n }\n};\n\n/**\n * [Kernel density estimation](https://en.wikipedia.org/wiki/Kernel_density_estimation)\n * is a useful tool for, among other things, estimating the shape of the\n * underlying probability distribution from a sample.\n *\n * @name kernelDensityEstimation\n * @param X sample values\n * @param kernel The kernel function to use. If a function is provided, it should return non-negative values and integrate to 1. Defaults to 'gaussian'.\n * @param bandwidthMethod The \"bandwidth selection\" method to use, or a fixed bandwidth value. Defaults to \"nrd\", the commonly-used [\"normal reference distribution\" rule-of-thumb](https://stat.ethz.ch/R-manual/R-devel/library/MASS/html/bandwidth.nrd.html).\n * @returns {Function} An estimated [probability density function](https://en.wikipedia.org/wiki/Probability_density_function) for the given sample. The returned function runs in `O(X.length)`.\n */\nfunction kernelDensityEstimation(X, kernel, bandwidthMethod) {\n let kernelFn;\n if (kernel === undefined) {\n kernelFn = kernels.gaussian;\n } else if (typeof kernel === \"string\") {\n if (!kernels[kernel]) {\n throw new Error('Unknown kernel \"' + kernel + '\"');\n }\n kernelFn = kernels[kernel];\n } else {\n kernelFn = kernel;\n }\n\n let bandwidth;\n if (typeof bandwidthMethod === \"undefined\") {\n bandwidth = bandwidthMethods.nrd(X);\n } else if (typeof bandwidthMethod === \"string\") {\n if (!bandwidthMethods[bandwidthMethod]) {\n throw new Error(\n 'Unknown bandwidth method \"' + bandwidthMethod + '\"'\n );\n }\n bandwidth = bandwidthMethods[bandwidthMethod](X);\n } else {\n bandwidth = bandwidthMethod;\n }\n\n return function (x) {\n let i = 0;\n let sum = 0;\n for (i = 0; i < X.length; i++) {\n sum += kernelFn((x - X[i]) / bandwidth);\n }\n return sum / bandwidth / X.length;\n };\n}\n\nexport default kernelDensityEstimation;\n","const SQRT_2PI = Math.sqrt(2 * Math.PI);\n\nfunction cumulativeDistribution(z) {\n let sum = z,\n tmp = z;\n\n // 15 iterations are enough for 4-digit precision\n for (let i = 1; i < 15; i++) {\n tmp *= (z * z) / (2 * i + 1);\n sum += tmp;\n }\n return (\n Math.round((0.5 + (sum / SQRT_2PI) * Math.exp((-z * z) / 2)) * 1e4) /\n 1e4\n );\n}\n\n/**\n * A standard normal table, also called the unit normal table or Z table,\n * is a mathematical table for the values of Φ (phi), which are the values of\n * the [cumulative distribution function](https://en.wikipedia.org/wiki/Normal_distribution#Cumulative_distribution_function)\n * of the normal distribution. It is used to find the probability that a\n * statistic is observed below, above, or between values on the standard\n * normal distribution, and by extension, any normal distribution.\n */\nconst standardNormalTable = [];\n\nfor (let z = 0; z <= 3.09; z += 0.01) {\n standardNormalTable.push(cumulativeDistribution(z));\n}\n\nexport default standardNormalTable;\n","/**\n * **[Gaussian error function](http://en.wikipedia.org/wiki/Error_function)**\n *\n * The `errorFunction(x/(sd * Math.sqrt(2)))` is the probability that a value in a\n * normal distribution with standard deviation sd is within x of the mean.\n *\n * This function returns a numerical approximation to the exact value.\n * It uses Horner's method to evaluate the polynomial of τ (tau).\n *\n * @param {number} x input\n * @return {number} error estimation\n * @example\n * errorFunction(1).toFixed(2); // => '0.84'\n */\nfunction errorFunction(x) {\n const t = 1 / (1 + 0.5 * Math.abs(x));\n const tau =\n t *\n Math.exp(\n -x * x +\n ((((((((0.17087277 * t - 0.82215223) * t + 1.48851587) * t -\n 1.13520398) *\n t +\n 0.27886807) *\n t -\n 0.18628806) *\n t +\n 0.09678418) *\n t +\n 0.37409196) *\n t +\n 1.00002368) *\n t -\n 1.26551223\n );\n if (x >= 0) {\n return 1 - tau;\n } else {\n return tau - 1;\n }\n}\n\nexport default errorFunction;\n","/**\n * The Inverse [Gaussian error function](http://en.wikipedia.org/wiki/Error_function)\n * returns a numerical approximation to the value that would have caused\n * `errorFunction()` to return x.\n *\n * @param {number} x value of error function\n * @returns {number} estimated inverted value\n */\nfunction inverseErrorFunction(x) {\n const a = (8 * (Math.PI - 3)) / (3 * Math.PI * (4 - Math.PI));\n\n const inv = Math.sqrt(\n Math.sqrt(\n Math.pow(2 / (Math.PI * a) + Math.log(1 - x * x) / 2, 2) -\n Math.log(1 - x * x) / a\n ) -\n (2 / (Math.PI * a) + Math.log(1 - x * x) / 2)\n );\n\n if (x >= 0) {\n return inv;\n } else {\n return -inv;\n }\n}\n\nexport default inverseErrorFunction;\n","/**\n * [Sign](https://en.wikipedia.org/wiki/Sign_function) is a function\n * that extracts the sign of a real number\n *\n * @param {number} x input value\n * @returns {number} sign value either 1, 0 or -1\n * @throws {TypeError} if the input argument x is not a number\n * @private\n *\n * @example\n * sign(2); // => 1\n */\nfunction sign(x) {\n if (typeof x === \"number\") {\n if (x < 0) {\n return -1;\n } else if (x === 0) {\n return 0;\n } else {\n return 1;\n }\n } else {\n throw new TypeError(\"not a number\");\n }\n}\n\nexport default sign;\n","/**\n * Calculate Euclidean distance between two points.\n * @param {Array} left First N-dimensional point.\n * @param {Array} right Second N-dimensional point.\n * @returns {number} Distance.\n */\nfunction euclideanDistance(left, right) {\n let sum = 0;\n for (let i = 0; i < left.length; i++) {\n const diff = left[i] - right[i];\n sum += diff * diff;\n }\n return Math.sqrt(sum);\n}\n\nexport default euclideanDistance;\n","import euclideanDistance from \"./euclidean_distance.js\";\nimport makeMatrix from \"./make_matrix.js\";\nimport sample from \"./sample.js\";\n\n/**\n * @typedef {Object} kMeansReturn\n * @property {Array} labels The labels.\n * @property {Array>} centroids The cluster centroids.\n */\n\n/**\n * Perform k-means clustering.\n *\n * @param {Array>} points N-dimensional coordinates of points to be clustered.\n * @param {number} numCluster How many clusters to create.\n * @param {Function} randomSource An optional entropy source that generates uniform values in [0, 1).\n * @return {kMeansReturn} Labels (same length as data) and centroids (same length as numCluster).\n * @throws {Error} If any centroids wind up friendless (i.e., without associated points).\n *\n * @example\n * kMeansCluster([[0.0, 0.5], [1.0, 0.5]], 2); // => {labels: [0, 1], centroids: [[0.0, 0.5], [1.0 0.5]]}\n */\nfunction kMeansCluster(points, numCluster, randomSource = Math.random) {\n let oldCentroids = null;\n let newCentroids = sample(points, numCluster, randomSource);\n let labels = null;\n let change = Number.MAX_VALUE;\n while (change !== 0) {\n labels = labelPoints(points, newCentroids);\n oldCentroids = newCentroids;\n newCentroids = calculateCentroids(points, labels, numCluster);\n change = calculateChange(newCentroids, oldCentroids);\n }\n return {\n labels: labels,\n centroids: newCentroids\n };\n}\n\n/**\n * Label each point according to which centroid it is closest to.\n *\n * @private\n * @param {Array>} points Array of XY coordinates.\n * @param {Array>} centroids Current centroids.\n * @return {Array} Group labels.\n */\nfunction labelPoints(points, centroids) {\n return points.map((p) => {\n let minDist = Number.MAX_VALUE;\n let label = -1;\n for (let i = 0; i < centroids.length; i++) {\n const dist = euclideanDistance(p, centroids[i]);\n if (dist < minDist) {\n minDist = dist;\n label = i;\n }\n }\n return label;\n });\n}\n\n/**\n * Calculate centroids for points given labels.\n *\n * @private\n * @param {Array>} points Array of XY coordinates.\n * @param {Array} labels Which groups points belong to.\n * @param {number} numCluster Number of clusters being created.\n * @return {Array>} Centroid for each group.\n * @throws {Error} If any centroids wind up friendless (i.e., without associated points).\n */\nfunction calculateCentroids(points, labels, numCluster) {\n // Initialize accumulators.\n const dimension = points[0].length;\n const centroids = makeMatrix(numCluster, dimension);\n const counts = Array(numCluster).fill(0);\n\n // Add points to centroids' accumulators and count points per centroid.\n const numPoints = points.length;\n for (let i = 0; i < numPoints; i++) {\n const point = points[i];\n const label = labels[i];\n const current = centroids[label];\n for (let j = 0; j < dimension; j++) {\n current[j] += point[j];\n }\n counts[label] += 1;\n }\n\n // Rescale centroids, checking for any that have no points.\n for (let i = 0; i < numCluster; i++) {\n if (counts[i] === 0) {\n throw new Error(`Centroid ${i} has no friends`);\n }\n const centroid = centroids[i];\n for (let j = 0; j < dimension; j++) {\n centroid[j] /= counts[i];\n }\n }\n\n return centroids;\n}\n\n/**\n * Calculate the difference between old centroids and new centroids.\n *\n * @private\n * @param {Array>} left One list of centroids.\n * @param {Array>} right Another list of centroids.\n * @return {number} Distance between centroids.\n */\nfunction calculateChange(left, right) {\n let total = 0;\n for (let i = 0; i < left.length; i++) {\n total += euclideanDistance(left[i], right[i]);\n }\n return total;\n}\n\nexport default kMeansCluster;\n","import euclideanDistance from \"./euclidean_distance.js\";\nimport makeMatrix from \"./make_matrix.js\";\nimport max from \"./max.js\";\n\n/**\n * Calculate the [silhouette values](https://en.wikipedia.org/wiki/Silhouette_(clustering))\n * for clustered data.\n *\n * @param {Array>} points N-dimensional coordinates of points.\n * @param {Array} labels Labels of points. This must be the same length as `points`,\n * and values must lie in [0..G-1], where G is the number of groups.\n * @return {Array} The silhouette value for each point.\n *\n * @example\n * silhouette([[0.25], [0.75]], [0, 0]); // => [1.0, 1.0]\n */\nfunction silhouette(points, labels) {\n if (points.length !== labels.length) {\n throw new Error(\"must have exactly as many labels as points\");\n }\n const groupings = createGroups(labels);\n const distances = calculateAllDistances(points);\n const result = [];\n for (let i = 0; i < points.length; i++) {\n let s = 0;\n if (groupings[labels[i]].length > 1) {\n const a = meanDistanceFromPointToGroup(\n i,\n groupings[labels[i]],\n distances\n );\n const b = meanDistanceToNearestGroup(\n i,\n labels,\n groupings,\n distances\n );\n s = (b - a) / Math.max(a, b);\n }\n result.push(s);\n }\n return result;\n}\n\n/**\n * Create a lookup table mapping group IDs to point IDs.\n *\n * @private\n * @param {Array} labels Labels of points. This must be the same length as `points`,\n * and values must lie in [0..G-1], where G is the number of groups.\n * @return {Array>} An array of length G, each of whose entries is an array\n * containing the indices of the points in that group.\n */\nfunction createGroups(labels) {\n const numGroups = 1 + max(labels);\n const result = Array(numGroups);\n for (let i = 0; i < labels.length; i++) {\n const label = labels[i];\n if (result[label] === undefined) {\n result[label] = [];\n }\n result[label].push(i);\n }\n return result;\n}\n\n/**\n * Create a lookup table of all inter-point distances.\n *\n * @private\n * @param {Array>} points N-dimensional coordinates of points.\n * @return {Array>} A symmetric square array of inter-point distances\n * (zero on the diagonal).\n */\nfunction calculateAllDistances(points) {\n const numPoints = points.length;\n const result = makeMatrix(numPoints, numPoints);\n for (let i = 0; i < numPoints; i++) {\n for (let j = 0; j < i; j++) {\n result[i][j] = euclideanDistance(points[i], points[j]);\n result[j][i] = result[i][j];\n }\n }\n return result;\n}\n\n/**\n * Calculate the mean distance between this point and all the points in the\n * nearest group (as determined by which point in another group is closest).\n *\n * @private\n * @param {number} which The index of this point.\n * @param {Array} labels Labels of points.\n * @param {Array>} groupings An array whose entries are arrays\n * containing the indices of the points in that group.\n * @param {Array>} distances A symmetric square array of inter-point\n * distances.\n * @return {number} The mean distance from this point to others in the nearest\n * group.\n */\nfunction meanDistanceToNearestGroup(which, labels, groupings, distances) {\n const label = labels[which];\n let result = Number.MAX_VALUE;\n for (let i = 0; i < groupings.length; i++) {\n if (i !== label) {\n const d = meanDistanceFromPointToGroup(\n which,\n groupings[i],\n distances\n );\n if (d < result) {\n result = d;\n }\n }\n }\n return result;\n}\n\n/**\n * Calculate the mean distance between a point and all the points in a group\n * (possibly its own).\n *\n * @private\n * @param {number} which The index of this point.\n * @param {Array} group The indices of all the points in the group in\n * question.\n * @param {Array>} distances A symmetric square array of inter-point\n * distances.\n * @return {number} The mean distance from this point to others in the\n * specified group.\n */\nfunction meanDistanceFromPointToGroup(which, group, distances) {\n let total = 0;\n for (let i = 0; i < group.length; i++) {\n total += distances[which][group[i]];\n }\n return total / group.length;\n}\n\nexport default silhouette;\n","/**\n * Relative error.\n *\n * This is more difficult to calculate than it first appears [1,2]. The usual\n * formula for the relative error between an actual value A and an expected\n * value E is `|(A-E)/E|`, but:\n *\n * 1. If the expected value is 0, any other value has infinite relative error,\n * which is counter-intuitive: if the expected voltage is 0, getting 1/10th\n * of a volt doesn't feel like an infinitely large error.\n *\n * 2. This formula does not satisfy the mathematical definition of a metric [3].\n * [4] solved this problem by defining the relative error as `|ln(|A/E|)|`,\n * but that formula only works if all values are positive: for example, it\n * reports the relative error of -10 and 10 as 0.\n *\n * Our implementation sticks with convention and returns:\n *\n * - 0 if the actual and expected values are both zero\n * - Infinity if the actual value is non-zero and the expected value is zero\n * - `|(A-E)/E|` in all other cases\n *\n * [1] https://math.stackexchange.com/questions/677852/how-to-calculate-relative-error-when-true-value-is-zero\n * [2] https://en.wikipedia.org/wiki/Relative_change_and_difference\n * [3] https://en.wikipedia.org/wiki/Metric_(mathematics)#Definition\n * [4] F.W.J. Olver: \"A New Approach to Error Arithmetic.\" SIAM Journal on\n * Numerical Analysis, 15(2), 1978, 10.1137/0715024.\n *\n * @param {number} actual The actual value.\n * @param {number} expected The expected value.\n * @return {number} The relative error.\n */\nfunction relativeError(actual, expected) {\n if (actual === 0 && expected === 0) {\n return 0;\n }\n return Math.abs((actual - expected) / expected);\n}\n\nexport default relativeError;\n","/**\n * When adding a new value to a list, one does not have to necessary\n * recompute the mean of the list in linear time. They can instead use\n * this function to compute the new mean by providing the current mean,\n * the number of elements in the list that produced it and the new\n * value to add.\n *\n * @since 2.5.0\n * @param {number} mean current mean\n * @param {number} n number of items in the list\n * @param {number} newValue the added value\n * @returns {number} the new mean\n *\n * @example\n * addToMean(14, 5, 53); // => 20.5\n */\nfunction addToMean(mean, n, newValue) {\n return mean + (newValue - mean) / (n + 1);\n}\n\nexport default addToMean;\n","import epsilon from \"./epsilon.js\";\nimport relativeError from \"./relative_error.js\";\n\n/**\n * Approximate equality.\n *\n * @param {number} actual The value to be tested.\n * @param {number} expected The reference value.\n * @param {number} tolerance The acceptable relative difference.\n * @return {boolean} Whether numbers are within tolerance.\n */\nfunction approxEqual(actual, expected, tolerance = epsilon) {\n return relativeError(actual, expected) <= tolerance;\n}\n\nexport default approxEqual;\n","/**\n * The [Bernoulli distribution](http://en.wikipedia.org/wiki/Bernoulli_distribution)\n * is the probability discrete\n * distribution of a random variable which takes value 1 with success\n * probability `p` and value 0 with failure\n * probability `q` = 1 - `p`. It can be used, for example, to represent the\n * toss of a coin, where \"1\" is defined to mean \"heads\" and \"0\" is defined\n * to mean \"tails\" (or vice versa). It is\n * a special case of a Binomial Distribution\n * where `n` = 1.\n *\n * @param {number} p input value, between 0 and 1 inclusive\n * @returns {number[]} values of bernoulli distribution at this point\n * @throws {Error} if p is outside 0 and 1\n * @example\n * bernoulliDistribution(0.3); // => [0.7, 0.3]\n */\nfunction bernoulliDistribution(p) /*: number[] */ {\n // Check that `p` is a valid probability (0 ≤ p ≤ 1)\n if (p < 0 || p > 1) {\n throw new Error(\n \"bernoulliDistribution requires probability to be between 0 and 1 inclusive\"\n );\n }\n\n return [1 - p, p];\n}\n\nexport default bernoulliDistribution;\n","import epsilon from \"./epsilon.js\";\n\n/**\n * The [Binomial Distribution](http://en.wikipedia.org/wiki/Binomial_distribution) is the discrete probability\n * distribution of the number of successes in a sequence of n independent yes/no experiments, each of which yields\n * success with probability `probability`. Such a success/failure experiment is also called a Bernoulli experiment or\n * Bernoulli trial; when trials = 1, the Binomial Distribution is a Bernoulli Distribution.\n *\n * @param {number} trials number of trials to simulate\n * @param {number} probability\n * @returns {number[]} output\n */\nfunction binomialDistribution(trials, probability) /*: ?number[] */ {\n // Check that `p` is a valid probability (0 ≤ p ≤ 1),\n // that `n` is an integer, strictly positive.\n if (probability < 0 || probability > 1 || trials <= 0 || trials % 1 !== 0) {\n return undefined;\n }\n\n // We initialize `x`, the random variable, and `accumulator`, an accumulator\n // for the cumulative distribution function to 0. `distribution_functions`\n // is the object we'll return with the `probability_of_x` and the\n // `cumulativeProbability_of_x`, as well as the calculated mean &\n // variance. We iterate until the `cumulativeProbability_of_x` is\n // within `epsilon` of 1.0.\n let x = 0;\n let cumulativeProbability = 0;\n const cells = [];\n let binomialCoefficient = 1;\n\n // This algorithm iterates through each potential outcome,\n // until the `cumulativeProbability` is very close to 1, at\n // which point we've defined the vast majority of outcomes\n do {\n // a [probability mass function](https://en.wikipedia.org/wiki/Probability_mass_function)\n cells[x] =\n binomialCoefficient *\n Math.pow(probability, x) *\n Math.pow(1 - probability, trials - x);\n cumulativeProbability += cells[x];\n x++;\n binomialCoefficient = (binomialCoefficient * (trials - x + 1)) / x;\n // when the cumulativeProbability is nearly 1, we've calculated\n // the useful range of this distribution\n } while (cumulativeProbability < 1 - epsilon);\n\n return cells;\n}\n\nexport default binomialDistribution;\n","import sign from \"./sign.js\";\n\n/**\n * [Bisection method](https://en.wikipedia.org/wiki/Bisection_method) is a root-finding\n * method that repeatedly bisects an interval to find the root.\n *\n * This function returns a numerical approximation to the exact value.\n *\n * @param {Function} func input function\n * @param {number} start - start of interval\n * @param {number} end - end of interval\n * @param {number} maxIterations - the maximum number of iterations\n * @param {number} errorTolerance - the error tolerance\n * @returns {number} estimated root value\n * @throws {TypeError} Argument func must be a function\n *\n * @example\n * bisect(Math.cos,0,4,100,0.003); // => 1.572265625\n */\nfunction bisect(func, start, end, maxIterations, errorTolerance) {\n if (typeof func !== \"function\")\n throw new TypeError(\"func must be a function\");\n\n for (let i = 0; i < maxIterations; i++) {\n const output = (start + end) / 2;\n\n if (\n func(output) === 0 ||\n Math.abs((end - start) / 2) < errorTolerance\n ) {\n return output;\n }\n\n if (sign(func(output)) === sign(func(start))) {\n start = output;\n } else {\n end = output;\n }\n }\n\n throw new Error(\"maximum number of iterations exceeded\");\n}\n\nexport default bisect;\n","import chiSquaredDistributionTable from \"./chi_squared_distribution_table.js\";\nimport mean from \"./mean.js\";\n\n/**\n * The [χ2 (Chi-Squared) Goodness-of-Fit Test](http://en.wikipedia.org/wiki/Goodness_of_fit#Pearson.27s_chi-squared_test)\n * uses a measure of goodness of fit which is the sum of differences between observed and expected outcome frequencies\n * (that is, counts of observations), each squared and divided by the number of observations expected given the\n * hypothesized distribution. The resulting χ2 statistic, `chiSquared`, can be compared to the chi-squared distribution\n * to determine the goodness of fit. In order to determine the degrees of freedom of the chi-squared distribution, one\n * takes the total number of observed frequencies and subtracts the number of estimated parameters. The test statistic\n * follows, approximately, a chi-square distribution with (k − c) degrees of freedom where `k` is the number of non-empty\n * cells and `c` is the number of estimated parameters for the distribution.\n *\n * @param {Array} data\n * @param {Function} distributionType a function that returns a point in a distribution:\n * for instance, binomial, bernoulli, or poisson\n * @param {number} significance\n * @returns {number} chi squared goodness of fit\n * @example\n * // Data from Poisson goodness-of-fit example 10-19 in William W. Hines & Douglas C. Montgomery,\n * // \"Probability and Statistics in Engineering and Management Science\", Wiley (1980).\n * var data1019 = [\n * 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n * 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n * 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n * 2, 2, 2, 2, 2, 2, 2, 2, 2,\n * 3, 3, 3, 3\n * ];\n * ss.chiSquaredGoodnessOfFit(data1019, ss.poissonDistribution, 0.05); //= false\n */\nfunction chiSquaredGoodnessOfFit(data, distributionType, significance) {\n // Estimate from the sample data, a weighted mean.\n const inputMean = mean(data);\n // Calculated value of the χ2 statistic.\n let chiSquared = 0;\n // Number of hypothesized distribution parameters estimated, expected to be supplied in the distribution test.\n // Lose one degree of freedom for estimating `lambda` from the sample data.\n const c = 1;\n // The hypothesized distribution.\n // Generate the hypothesized distribution.\n const hypothesizedDistribution = distributionType(inputMean);\n const observedFrequencies = [];\n const expectedFrequencies = [];\n\n // Create an array holding a histogram from the sample data, of\n // the form `{ value: numberOfOcurrences }`\n for (let i = 0; i < data.length; i++) {\n if (observedFrequencies[data[i]] === undefined) {\n observedFrequencies[data[i]] = 0;\n }\n observedFrequencies[data[i]]++;\n }\n\n // The histogram we created might be sparse - there might be gaps\n // between values. So we iterate through the histogram, making\n // sure that instead of undefined, gaps have 0 values.\n for (let i = 0; i < observedFrequencies.length; i++) {\n if (observedFrequencies[i] === undefined) {\n observedFrequencies[i] = 0;\n }\n }\n\n // Create an array holding a histogram of expected data given the\n // sample size and hypothesized distribution.\n for (const k in hypothesizedDistribution) {\n if (k in observedFrequencies) {\n expectedFrequencies[+k] = hypothesizedDistribution[k] * data.length;\n }\n }\n\n // Working backward through the expected frequencies, collapse classes\n // if less than three observations are expected for a class.\n // This transformation is applied to the observed frequencies as well.\n for (let k = expectedFrequencies.length - 1; k >= 0; k--) {\n if (expectedFrequencies[k] < 3) {\n expectedFrequencies[k - 1] += expectedFrequencies[k];\n expectedFrequencies.pop();\n\n observedFrequencies[k - 1] += observedFrequencies[k];\n observedFrequencies.pop();\n }\n }\n\n // Iterate through the squared differences between observed & expected\n // frequencies, accumulating the `chiSquared` statistic.\n for (let k = 0; k < observedFrequencies.length; k++) {\n chiSquared +=\n Math.pow(observedFrequencies[k] - expectedFrequencies[k], 2) /\n expectedFrequencies[k];\n }\n\n // Calculate degrees of freedom for this test and look it up in the\n // `chiSquaredDistributionTable` in order to\n // accept or reject the goodness-of-fit of the hypothesized distribution.\n // Degrees of freedom, calculated as (number of class intervals -\n // number of hypothesized distribution parameters estimated - 1)\n const degreesOfFreedom = observedFrequencies.length - c - 1;\n return (\n chiSquaredDistributionTable[degreesOfFreedom][significance] < chiSquared\n );\n}\n\nexport default chiSquaredGoodnessOfFit;\n","/**\n * Split an array into chunks of a specified size. This function\n * has the same behavior as [PHP's array_chunk](http://php.net/manual/en/function.array-chunk.php)\n * function, and thus will insert smaller-sized chunks at the end if\n * the input size is not divisible by the chunk size.\n *\n * `x` is expected to be an array, and `chunkSize` a number.\n * The `x` array can contain any kind of data.\n *\n * @param {Array} x a sample\n * @param {number} chunkSize size of each output array. must be a positive integer\n * @returns {Array} a chunked array\n * @throws {Error} if chunk size is less than 1 or not an integer\n * @example\n * chunk([1, 2, 3, 4, 5, 6], 2);\n * // => [[1, 2], [3, 4], [5, 6]]\n */\nfunction chunk(x, chunkSize) {\n // a list of result chunks, as arrays in an array\n const output = [];\n\n // `chunkSize` must be zero or higher - otherwise the loop below,\n // in which we call `start += chunkSize`, will loop infinitely.\n // So, we'll detect and throw in that case to indicate\n // invalid input.\n if (chunkSize < 1) {\n throw new Error(\"chunk size must be a positive number\");\n }\n\n if (Math.floor(chunkSize) !== chunkSize) {\n throw new Error(\"chunk size must be an integer\");\n }\n\n // `start` is the index at which `.slice` will start selecting\n // new array elements\n for (let start = 0; start < x.length; start += chunkSize) {\n // for each chunk, slice that part of the array and add it\n // to the output. The `.slice` function does not change\n // the original array.\n output.push(x.slice(start, start + chunkSize));\n }\n return output;\n}\n\nexport default chunk;\n","import mean from \"./mean.js\";\nimport sampleStandardDeviation from \"./sample_standard_deviation.js\";\n\n/**\n * The`coefficient of variation`_ is the ratio of the standard deviation to the mean.\n * .._`coefficient of variation`: https://en.wikipedia.org/wiki/Coefficient_of_variation\n *\n *\n * @param {Array} x input\n * @returns {number} coefficient of variation\n * @example\n * coefficientOfVariation([1, 2, 3, 4]).toFixed(3); // => 0.516\n * coefficientOfVariation([1, 2, 3, 4, 5]).toFixed(3); // => 0.527\n * coefficientOfVariation([-1, 0, 1, 2, 3, 4]).toFixed(3); // => 1.247\n */\nfunction coefficientOfVariation(x) {\n return sampleStandardDeviation(x) / mean(x);\n}\n\nexport default coefficientOfVariation;\n","/**\n * Implementation of Combinations\n * Combinations are unique subsets of a collection - in this case, k x from a collection at a time.\n * https://en.wikipedia.org/wiki/Combination\n * @param {Array} x any type of data\n * @param {int} k the number of objects in each group (without replacement)\n * @returns {Array} array of permutations\n * @example\n * combinations([1, 2, 3], 2); // => [[1,2], [1,3], [2,3]]\n */\n\nfunction combinations(x, k) {\n let i;\n let subI;\n const combinationList = [];\n let subsetCombinations;\n let next;\n\n for (i = 0; i < x.length; i++) {\n if (k === 1) {\n combinationList.push([x[i]]);\n } else {\n subsetCombinations = combinations(x.slice(i + 1, x.length), k - 1);\n for (subI = 0; subI < subsetCombinations.length; subI++) {\n next = subsetCombinations[subI];\n next.unshift(x[i]);\n combinationList.push(next);\n }\n }\n }\n return combinationList;\n}\n\nexport default combinations;\n","/**\n * Implementation of [Combinations](https://en.wikipedia.org/wiki/Combination) with replacement\n * Combinations are unique subsets of a collection - in this case, k x from a collection at a time.\n * 'With replacement' means that a given element can be chosen multiple times.\n * Unlike permutation, order doesn't matter for combinations.\n *\n * @param {Array} x any type of data\n * @param {int} k the number of objects in each group (without replacement)\n * @returns {Array} array of permutations\n * @example\n * combinationsReplacement([1, 2], 2); // => [[1, 1], [1, 2], [2, 2]]\n */\nfunction combinationsReplacement(x, k) {\n const combinationList = [];\n\n for (let i = 0; i < x.length; i++) {\n if (k === 1) {\n // If we're requested to find only one element, we don't need\n // to recurse: just push `x[i]` onto the list of combinations.\n combinationList.push([x[i]]);\n } else {\n // Otherwise, recursively find combinations, given `k - 1`. Note that\n // we request `k - 1`, so if you were looking for k=3 combinations, we're\n // requesting k=2. This -1 gets reversed in the for loop right after this\n // code, since we concatenate `x[i]` onto the selected combinations,\n // bringing `k` back up to your requested level.\n // This recursion may go many levels deep, since it only stops once\n // k=1.\n const subsetCombinations = combinationsReplacement(\n x.slice(i, x.length),\n k - 1\n );\n\n for (let j = 0; j < subsetCombinations.length; j++) {\n combinationList.push([x[i]].concat(subsetCombinations[j]));\n }\n }\n }\n\n return combinationList;\n}\n\nexport default combinationsReplacement;\n","import combineMeans from \"./combine_means.js\";\n\n/**\n * When combining two lists of values for which one already knows the variances,\n * one does not have to necessary recompute the variance of the combined lists\n * in linear time. They can instead use this function to compute the combined\n * variance by providing the variance, mean & number of values of the first list\n * and the variance, mean & number of values of the second list.\n *\n * @since 3.0.0\n * @param {number} variance1 variance of the first list\n * @param {number} mean1 mean of the first list\n * @param {number} n1 number of items in the first list\n * @param {number} variance2 variance of the second list\n * @param {number} mean2 mean of the second list\n * @param {number} n2 number of items in the second list\n * @returns {number} the combined mean\n *\n * @example\n * combineVariances(14 / 3, 5, 3, 8 / 3, 4, 3); // => 47 / 12\n */\nfunction combineVariances(variance1, mean1, n1, variance2, mean2, n2) {\n const newMean = combineMeans(mean1, n1, mean2, n2);\n\n return (\n (n1 * (variance1 + Math.pow(mean1 - newMean, 2)) +\n n2 * (variance2 + Math.pow(mean2 - newMean, 2))) /\n (n1 + n2)\n );\n}\n\nexport default combineVariances;\n","/**\n * **[Logistic Cumulative Distribution Function](https://en.wikipedia.org/wiki/Logistic_distribution)**\n *\n * @param {number} x\n * @returns {number} cumulative standard logistic probability\n */\nfunction cumulativeStdLogisticProbability(x) {\n return 1 / (Math.exp(-x) + 1);\n}\n\nexport default cumulativeStdLogisticProbability;\n","import standardNormalTable from \"./standard_normal_table.js\";\n\n/**\n * **[Cumulative Standard Normal Probability](http://en.wikipedia.org/wiki/Standard_normal_table)**\n *\n * Since probability tables cannot be\n * printed for every normal distribution, as there are an infinite variety\n * of normal distributions, it is common practice to convert a normal to a\n * standard normal and then use the standard normal table to find probabilities.\n *\n * You can use `.5 + .5 * errorFunction(x / Math.sqrt(2))` to calculate the probability\n * instead of looking it up in a table.\n *\n * @param {number} z\n * @returns {number} cumulative standard normal probability\n */\nfunction cumulativeStdNormalProbability(z) {\n // Calculate the position of this value.\n const absZ = Math.abs(z);\n // Each row begins with a different\n // significant digit: 0.5, 0.6, 0.7, and so on. Each value in the table\n // corresponds to a range of 0.01 in the input values, so the value is\n // multiplied by 100.\n const index = Math.min(\n Math.round(absZ * 100),\n standardNormalTable.length - 1\n );\n\n // The index we calculate must be in the table as a positive value,\n // but we still pay attention to whether the input is positive\n // or negative, and flip the output value as a last step.\n if (z >= 0) {\n return standardNormalTable[index];\n } else {\n // due to floating-point arithmetic, values in the table with\n // 4 significant figures can nevertheless end up as repeating\n // fractions when they're computed here.\n return +(1 - standardNormalTable[index]).toFixed(4);\n }\n}\n\nexport default cumulativeStdNormalProbability;\n","import max from \"./max.js\";\nimport min from \"./min.js\";\n\n/**\n * Given an array of x, this will find the extent of the\n * x and return an array of breaks that can be used\n * to categorize the x into a number of classes. The\n * returned array will always be 1 longer than the number of\n * classes because it includes the minimum value.\n *\n * @param {Array} x an array of number values\n * @param {number} nClasses number of desired classes\n * @returns {Array} array of class break positions\n * @example\n * equalIntervalBreaks([1, 2, 3, 4, 5, 6], 4); // => [1, 2.25, 3.5, 4.75, 6]\n */\nfunction equalIntervalBreaks(x, nClasses) {\n if (x.length < 2) {\n return x;\n }\n\n const theMin = min(x);\n const theMax = max(x);\n\n // the first break will always be the minimum value\n // in the xset\n const breaks = [theMin];\n\n // The size of each break is the full range of the x\n // divided by the number of classes requested\n const breakSize = (theMax - theMin) / nClasses;\n\n // In the case of nClasses = 1, this loop won't run\n // and the returned breaks will be [min, max]\n for (let i = 1; i < nClasses; i++) {\n breaks.push(breaks[0] + breakSize * i);\n }\n\n // the last break will always be the\n // maximum.\n breaks.push(theMax);\n\n return breaks;\n}\n\nexport default equalIntervalBreaks;\n","/**\n * This computes the minimum & maximum number in an array.\n *\n * This runs in `O(n)`, linear time, with respect to the length of the array.\n *\n * @param {Array} x sample of one or more data points\n * @returns {Array} minimum & maximum value\n * @throws {Error} if the length of x is less than one\n * @example\n * extent([1, 2, 3, 4]);\n * // => [1, 4]\n */\nfunction extent(x) {\n if (x.length === 0) {\n throw new Error(\"extent requires at least one data point\");\n }\n\n let min = x[0];\n let max = x[0];\n for (let i = 1; i < x.length; i++) {\n if (x[i] > max) {\n max = x[i];\n }\n if (x[i] < min) {\n min = x[i];\n }\n }\n return [min, max];\n}\n\nexport default extent;\n","/**\n * The extent is the lowest & highest number in the array. With a sorted array,\n * the first element in the array is always the lowest while the last element is always the largest, so this calculation\n * can be done in one step, or constant time.\n *\n * @param {Array} x input\n * @returns {Array} minimum & maximum value\n * @example\n * extentSorted([-100, -10, 1, 2, 5]); // => [-100, 5]\n */\nfunction extentSorted(x) {\n return [x[0], x[x.length - 1]];\n}\n\nexport default extentSorted;\n","import factorial from \"./factorial.js\";\n\n/**\n * Compute the [gamma function](https://en.wikipedia.org/wiki/Gamma_function) of a value using Nemes' approximation.\n * The gamma of n is equivalent to (n-1)!, but unlike the factorial function, gamma is defined for all real n except zero\n * and negative integers (where NaN is returned). Note, the gamma function is also well-defined for complex numbers,\n * though this implementation currently does not handle complex numbers as input values.\n * Nemes' approximation is defined [here](https://arxiv.org/abs/1003.6020) as Theorem 2.2.\n * Negative values use [Euler's reflection formula](https://en.wikipedia.org/wiki/Gamma_function#Properties) for computation.\n *\n * @param {number} n Any real number except for zero and negative integers.\n * @returns {number} The gamma of the input value.\n *\n * @example\n * gamma(11.5); // 11899423.084037038\n * gamma(-11.5); // 2.29575810481609e-8\n * gamma(5); // 24\n */\nfunction gamma(n) {\n if (Number.isInteger(n)) {\n if (n <= 0) {\n // gamma not defined for zero or negative integers\n return NaN;\n } else {\n // use factorial for integer inputs\n return factorial(n - 1);\n }\n }\n\n // Decrement n, because approximation is defined for n - 1\n n--;\n\n if (n < 0) {\n // Use Euler's reflection formula for negative inputs\n // see: https://en.wikipedia.org/wiki/Gamma_function#Properties\n return Math.PI / (Math.sin(Math.PI * -n) * gamma(-n));\n } else {\n // Nemes' expansion approximation\n const seriesCoefficient =\n Math.pow(n / Math.E, n) * Math.sqrt(2 * Math.PI * (n + 1 / 6));\n\n const seriesDenom = n + 1 / 4;\n\n const seriesExpansion =\n 1 +\n 1 / 144 / Math.pow(seriesDenom, 2) -\n 1 / 12960 / Math.pow(seriesDenom, 3) -\n 257 / 207360 / Math.pow(seriesDenom, 4) -\n 52 / 2612736 / Math.pow(seriesDenom, 5) +\n 5741173 / 9405849600 / Math.pow(seriesDenom, 6) +\n 37529 / 18811699200 / Math.pow(seriesDenom, 7);\n\n return seriesCoefficient * seriesExpansion;\n }\n}\n\nexport default gamma;\n","/**\n * The [Geometric Mean](https://en.wikipedia.org/wiki/Geometric_mean) is\n * a mean function that is more useful for numbers in different\n * ranges.\n *\n * This is the nth root of the input numbers multiplied by each other.\n *\n * The geometric mean is often useful for\n * **[proportional growth](https://en.wikipedia.org/wiki/Geometric_mean#Proportional_growth)**: given\n * growth rates for multiple years, like _80%, 16.66% and 42.85%_, a simple\n * mean will incorrectly estimate an average growth rate, whereas a geometric\n * mean will correctly estimate a growth rate that, over those years,\n * will yield the same end value.\n *\n * This runs in `O(n)`, linear time, with respect to the length of the array.\n *\n * @param {Array} x sample of one or more data points\n * @returns {number} geometric mean\n * @throws {Error} if x is empty\n * @throws {Error} if x contains a negative number\n * @example\n * var growthRates = [1.80, 1.166666, 1.428571];\n * var averageGrowth = ss.geometricMean(growthRates);\n * var averageGrowthRates = [averageGrowth, averageGrowth, averageGrowth];\n * var startingValue = 10;\n * var startingValueMean = 10;\n * growthRates.forEach(function(rate) {\n * startingValue *= rate;\n * });\n * averageGrowthRates.forEach(function(rate) {\n * startingValueMean *= rate;\n * });\n * startingValueMean === startingValue;\n */\nfunction geometricMean(x) {\n if (x.length === 0) {\n throw new Error(\"geometricMean requires at least one data point\");\n }\n\n // the starting value.\n let value = 1;\n\n for (let i = 0; i < x.length; i++) {\n // the geometric mean is only valid for positive numbers\n if (x[i] < 0) {\n throw new Error(\n \"geometricMean requires only non-negative numbers as input\"\n );\n }\n\n // repeatedly multiply the value by each number\n value *= x[i];\n }\n\n return Math.pow(value, 1 / x.length);\n}\n\nexport default geometricMean;\n","/**\n * The [Harmonic Mean](https://en.wikipedia.org/wiki/Harmonic_mean) is\n * a mean function typically used to find the average of rates.\n * This mean is calculated by taking the reciprocal of the arithmetic mean\n * of the reciprocals of the input numbers.\n *\n * This is a [measure of central tendency](https://en.wikipedia.org/wiki/Central_tendency):\n * a method of finding a typical or central value of a set of numbers.\n *\n * This runs in `O(n)`, linear time, with respect to the length of the array.\n *\n * @param {Array} x sample of one or more data points\n * @returns {number} harmonic mean\n * @throws {Error} if x is empty\n * @throws {Error} if x contains a negative number\n * @example\n * harmonicMean([2, 3]).toFixed(2) // => '2.40'\n */\nfunction harmonicMean(x) {\n if (x.length === 0) {\n throw new Error(\"harmonicMean requires at least one data point\");\n }\n\n let reciprocalSum = 0;\n\n for (let i = 0; i < x.length; i++) {\n // the harmonic mean is only valid for positive numbers\n if (x[i] <= 0) {\n throw new Error(\n \"harmonicMean requires only positive numbers as input\"\n );\n }\n\n reciprocalSum += 1 / x[i];\n }\n\n // divide n by the reciprocal sum\n return x.length / reciprocalSum;\n}\n\nexport default harmonicMean;\n","import jenksBreaks from \"./jenks_breaks.js\";\nimport jenksMatrices from \"./jenks_matrices.js\";\n\n/**\n * The **[jenks natural breaks optimization](http://en.wikipedia.org/wiki/Jenks_natural_breaks_optimization)**\n * is an algorithm commonly used in cartography and visualization to decide\n * upon groupings of data values that minimize variance within themselves\n * and maximize variation between themselves.\n *\n * For instance, cartographers often use jenks in order to choose which\n * values are assigned to which colors in a [choropleth](https://en.wikipedia.org/wiki/Choropleth_map)\n * map.\n *\n * @param {Array} data input data, as an array of number values\n * @param {number} nClasses number of desired classes\n * @returns {Array} array of class break positions\n * // split data into 3 break points\n * jenks([1, 2, 4, 5, 7, 9, 10, 20], 3) // = [1, 7, 20, 20]\n */\nfunction jenks(data, nClasses) {\n if (nClasses > data.length) {\n return null;\n }\n\n // sort data in numerical order, since this is expected\n // by the matrices function\n data = data.slice().sort(function (a, b) {\n return a - b;\n });\n\n // get our basic matrices\n const matrices = jenksMatrices(data, nClasses);\n // we only need lower class limits here\n const lowerClassLimits = matrices.lowerClassLimits;\n\n // extract nClasses out of the computed matrices\n return jenksBreaks(data, lowerClassLimits, nClasses);\n}\n\nexport default jenks;\n","/*\n * Compute Matrices for Jenks\n *\n * Compute the matrices required for Jenks breaks. These matrices\n * can be used for any classing of data with `classes <= nClasses`\n *\n * @private\n */\nfunction jenksMatrices(data, nClasses) {\n // in the original implementation, these matrices are referred to\n // as `LC` and `OP`\n //\n // * lowerClassLimits (LC): optimal lower class limits\n // * varianceCombinations (OP): optimal variance combinations for all classes\n const lowerClassLimits = [];\n const varianceCombinations = [];\n // loop counters\n let i, j;\n // the variance, as computed at each step in the calculation\n let variance = 0;\n\n // Initialize and fill each matrix with zeroes\n for (i = 0; i < data.length + 1; i++) {\n const tmp1 = [];\n const tmp2 = [];\n // despite these arrays having the same values, we need\n // to keep them separate so that changing one does not change\n // the other\n for (j = 0; j < nClasses + 1; j++) {\n tmp1.push(0);\n tmp2.push(0);\n }\n lowerClassLimits.push(tmp1);\n varianceCombinations.push(tmp2);\n }\n\n for (i = 1; i < nClasses + 1; i++) {\n lowerClassLimits[1][i] = 1;\n varianceCombinations[1][i] = 0;\n // in the original implementation, 9999999 is used but\n // since Javascript has `Infinity`, we use that.\n for (j = 2; j < data.length + 1; j++) {\n varianceCombinations[j][i] = Infinity;\n }\n }\n\n for (let l = 2; l < data.length + 1; l++) {\n // `SZ` originally. this is the sum of the values seen thus\n // far when calculating variance.\n let sum = 0;\n // `ZSQ` originally. the sum of squares of values seen\n // thus far\n let sumSquares = 0;\n // `WT` originally. This is the number of\n let w = 0;\n // `IV` originally\n let i4 = 0;\n\n // in several instances, you could say `Math.pow(x, 2)`\n // instead of `x * x`, but this is slower in some browsers\n // introduces an unnecessary concept.\n for (let m = 1; m < l + 1; m++) {\n // `III` originally\n const lowerClassLimit = l - m + 1;\n const val = data[lowerClassLimit - 1];\n\n // here we're estimating variance for each potential classing\n // of the data, for each potential number of classes. `w`\n // is the number of data points considered so far.\n w++;\n\n // increase the current sum and sum-of-squares\n sum += val;\n sumSquares += val * val;\n\n // the variance at this point in the sequence is the difference\n // between the sum of squares and the total x 2, over the number\n // of samples.\n variance = sumSquares - (sum * sum) / w;\n\n i4 = lowerClassLimit - 1;\n\n if (i4 !== 0) {\n for (j = 2; j < nClasses + 1; j++) {\n // if adding this element to an existing class\n // will increase its variance beyond the limit, break\n // the class at this point, setting the `lowerClassLimit`\n // at this point.\n if (\n varianceCombinations[l][j] >=\n variance + varianceCombinations[i4][j - 1]\n ) {\n lowerClassLimits[l][j] = lowerClassLimit;\n varianceCombinations[l][j] =\n variance + varianceCombinations[i4][j - 1];\n }\n }\n }\n }\n\n lowerClassLimits[l][1] = 1;\n varianceCombinations[l][1] = variance;\n }\n\n // return the two matrices. for just providing breaks, only\n // `lowerClassLimits` is needed, but variances can be useful to\n // evaluate goodness of fit.\n return {\n lowerClassLimits: lowerClassLimits,\n varianceCombinations: varianceCombinations\n };\n}\n\nexport default jenksMatrices;\n","/*\n * Pull Breaks Values for Jenks\n *\n * the second part of the jenks recipe: take the calculated matrices\n * and derive an array of n breaks.\n *\n * @private\n */\nfunction jenksBreaks(data, lowerClassLimits, nClasses) {\n let k = data.length;\n const kclass = [];\n let countNum = nClasses;\n\n // the calculation of classes will never include the upper\n // bound, so we need to explicitly set it\n kclass[nClasses] = data[data.length - 1];\n\n // the lowerClassLimits matrix is used as indices into itself\n // here: the `k` variable is reused in each iteration.\n while (countNum > 0) {\n kclass[countNum - 1] = data[lowerClassLimits[k][countNum] - 1];\n k = lowerClassLimits[k][countNum] - 1;\n countNum--;\n }\n\n return kclass;\n}\n\nexport default jenksBreaks;\n","/**\n * [Simple linear regression](http://en.wikipedia.org/wiki/Simple_linear_regression)\n * is a simple way to find a fitted line\n * between a set of coordinates. This algorithm finds the slope and y-intercept of a regression line\n * using the least sum of squares.\n *\n * @param {Array>} data an array of two-element of arrays,\n * like `[[0, 1], [2, 3]]`\n * @returns {Object} object containing slope and intersect of regression line\n * @example\n * linearRegression([[0, 0], [1, 1]]); // => { m: 1, b: 0 }\n */\nfunction linearRegression(data) {\n let m, b;\n\n // Store data length in a local variable to reduce\n // repeated object property lookups\n const dataLength = data.length;\n\n //if there's only one point, arbitrarily choose a slope of 0\n //and a y-intercept of whatever the y of the initial point is\n if (dataLength === 1) {\n m = 0;\n b = data[0][1];\n } else {\n // Initialize our sums and scope the `m` and `b`\n // variables that define the line.\n let sumX = 0,\n sumY = 0,\n sumXX = 0,\n sumXY = 0;\n\n // Use local variables to grab point values\n // with minimal object property lookups\n let point, x, y;\n\n // Gather the sum of all x values, the sum of all\n // y values, and the sum of x^2 and (x*y) for each\n // value.\n //\n // In math notation, these would be SS_x, SS_y, SS_xx, and SS_xy\n for (let i = 0; i < dataLength; i++) {\n point = data[i];\n x = point[0];\n y = point[1];\n\n sumX += x;\n sumY += y;\n\n sumXX += x * x;\n sumXY += x * y;\n }\n\n // `m` is the slope of the regression line\n m =\n (dataLength * sumXY - sumX * sumY) /\n (dataLength * sumXX - sumX * sumX);\n\n // `b` is the y-intercept of the line.\n b = sumY / dataLength - (m * sumX) / dataLength;\n }\n\n // Return both values as an object.\n return {\n m: m,\n b: b\n };\n}\n\nexport default linearRegression;\n","/**\n * Given the output of `linearRegression`: an object\n * with `m` and `b` values indicating slope and intercept,\n * respectively, generate a line function that translates\n * x values into y values.\n *\n * @param {Object} mb object with `m` and `b` members, representing\n * slope and intersect of desired line\n * @returns {Function} method that computes y-value at any given\n * x-value on the line.\n * @example\n * var l = linearRegressionLine(linearRegression([[0, 0], [1, 1]]));\n * l(0) // = 0\n * l(2) // = 2\n * linearRegressionLine({ b: 0, m: 1 })(1); // => 1\n * linearRegressionLine({ b: 1, m: 1 })(1); // => 2\n */\nfunction linearRegressionLine(mb /*: { b: number, m: number }*/) {\n // Return a function that computes a `y` value for each\n // x value it is given, based on the values of `b` and `a`\n // that we just computed.\n return function (x) {\n return mb.b + mb.m * x;\n };\n}\n\nexport default linearRegressionLine;\n","/**\n * The [log average](https://en.wikipedia.org/wiki/https://en.wikipedia.org/wiki/Geometric_mean#Relationship_with_logarithms)\n * is an equivalent way of computing the geometric mean of an array suitable for large or small products.\n *\n * It's found by calculating the average logarithm of the elements and exponentiating.\n *\n * @param {Array} x sample of one or more data points\n * @returns {number} geometric mean\n * @throws {Error} if x is empty\n * @throws {Error} if x contains a negative number\n */\nfunction logAverage(x) {\n if (x.length === 0) {\n throw new Error(\"logAverage requires at least one data point\");\n }\n\n let value = 0;\n for (let i = 0; i < x.length; i++) {\n if (x[i] < 0) {\n throw new Error(\n \"logAverage requires only non-negative numbers as input\"\n );\n }\n value += Math.log(x[i]);\n }\n\n return Math.exp(value / x.length);\n}\n\nexport default logAverage;\n","/**\n * The [Logit](https://en.wikipedia.org/wiki/Logit)\n * is the inverse of cumulativeStdLogisticProbability,\n * and is also known as the logistic quantile function.\n *\n * @param {number} p\n * @returns {number} logit\n */\nfunction logit(p) {\n if (p <= 0 || p >= 1) {\n throw new Error(\"p must be strictly between zero and one\");\n }\n return Math.log(p / (1 - p));\n}\n\nexport default logit;\n","/**\n * The maximum is the highest number in the array. With a sorted array,\n * the last element in the array is always the largest, so this calculation\n * can be done in one step, or constant time.\n *\n * @param {Array} x input\n * @returns {number} maximum value\n * @example\n * maxSorted([-100, -10, 1, 2, 5]); // => 5\n */\nfunction maxSorted(x) {\n return x[x.length - 1];\n}\n\nexport default maxSorted;\n","import quantileSorted from \"./quantile_sorted.js\";\n\n/**\n * The [median](http://en.wikipedia.org/wiki/Median) is\n * the middle number of a list. This is often a good indicator of 'the middle'\n * when there are outliers that skew the `mean()` value.\n * This is a [measure of central tendency](https://en.wikipedia.org/wiki/Central_tendency):\n * a method of finding a typical or central value of a set of numbers.\n *\n * The median isn't necessarily one of the elements in the list: the value\n * can be the average of two elements if the list has an even length\n * and the two central values are different.\n *\n * @param {Array} sorted input\n * @returns {number} median value\n * @example\n * medianSorted([10, 2, 5, 100, 2, 1]); // => 52.5\n */\nfunction medianSorted(sorted) {\n return quantileSorted(sorted, 0.5);\n}\n\nexport default medianSorted;\n","/**\n * The minimum is the lowest number in the array. With a sorted array,\n * the first element in the array is always the smallest, so this calculation\n * can be done in one step, or constant time.\n *\n * @param {Array} x input\n * @returns {number} minimum value\n * @example\n * minSorted([-100, -10, 1, 2, 5]); // => -100\n */\nfunction minSorted(x) {\n return x[0];\n}\n\nexport default minSorted;\n","import modeSorted from \"./mode_sorted.js\";\nimport numericSort from \"./numeric_sort.js\";\n\n/**\n * The [mode](https://en.wikipedia.org/wiki/Mode_%28statistics%29) is the number\n * that appears in a list the highest number of times.\n * There can be multiple modes in a list: in the event of a tie, this\n * algorithm will return the most recently seen mode.\n *\n * This is a [measure of central tendency](https://en.wikipedia.org/wiki/Central_tendency):\n * a method of finding a typical or central value of a set of numbers.\n *\n * This runs in `O(n log(n))` because it needs to sort the array internally\n * before running an `O(n)` search to find the mode.\n *\n * @param {Array} x input\n * @returns {number} mode\n * @example\n * mode([0, 0, 1]); // => 0\n */\nfunction mode(x) {\n // Sorting the array lets us iterate through it below and be sure\n // that every time we see a new number it's new and we'll never\n // see the same number twice\n return modeSorted(numericSort(x));\n}\n\nexport default mode;\n","/* globals Map: false */\n\n/**\n * The [mode](https://en.wikipedia.org/wiki/Mode_%28statistics%29) is the number\n * that appears in a list the highest number of times.\n * There can be multiple modes in a list: in the event of a tie, this\n * algorithm will return the most recently seen mode.\n *\n * modeFast uses a Map object to keep track of the mode, instead of the approach\n * used with `mode`, a sorted array. As a result, it is faster\n * than `mode` and supports any data type that can be compared with `==`.\n * It also requires a\n * [JavaScript environment with support for Map](https://kangax.github.io/compat-table/es6/#test-Map),\n * and will throw an error if Map is not available.\n *\n * This is a [measure of central tendency](https://en.wikipedia.org/wiki/Central_tendency):\n * a method of finding a typical or central value of a set of numbers.\n *\n * @param {Array<*>} x a sample of one or more data points\n * @returns {?*} mode\n * @throws {ReferenceError} if the JavaScript environment doesn't support Map\n * @throws {Error} if x is empty\n * @example\n * modeFast(['rabbits', 'rabbits', 'squirrels']); // => 'rabbits'\n */\nfunction modeFast(x) {\n // This index will reflect the incidence of different values, indexing\n // them like\n // { value: count }\n const index = new Map();\n\n // A running `mode` and the number of times it has been encountered.\n let mode;\n let modeCount = 0;\n\n for (let i = 0; i < x.length; i++) {\n let newCount = index.get(x[i]);\n if (newCount === undefined) {\n newCount = 1;\n } else {\n newCount++;\n }\n if (newCount > modeCount) {\n mode = x[i];\n modeCount = newCount;\n }\n index.set(x[i], newCount);\n }\n\n if (modeCount === 0) {\n throw new Error(\"mode requires at last one data point\");\n }\n\n return mode;\n}\n\nexport default modeFast;\n","import mean from \"./mean.js\";\nimport shuffleInPlace from \"./shuffle_in_place.js\";\n\n/**\n * Conducts a [permutation test](https://en.wikipedia.org/wiki/Resampling_(statistics)#Permutation_tests)\n * to determine if two data sets are *significantly* different from each other, using\n * the difference of means between the groups as the test statistic.\n * The function allows for the following hypotheses:\n * - two_tail = Null hypothesis: the two distributions are equal.\n * - greater = Null hypothesis: observations from sampleX tend to be smaller than those from sampleY.\n * - less = Null hypothesis: observations from sampleX tend to be greater than those from sampleY.\n * [Learn more about one-tail vs two-tail tests.](https://en.wikipedia.org/wiki/One-_and_two-tailed_tests)\n *\n * @param {Array} sampleX first dataset (e.g. treatment data)\n * @param {Array} sampleY second dataset (e.g. control data)\n * @param {string} alternative alternative hypothesis, either 'two_sided' (default), 'greater', or 'less'\n * @param {number} k number of values in permutation distribution.\n * @param {Function} [randomSource=Math.random] an optional entropy source\n * @returns {number} p-value The probability of observing the difference between groups (as or more extreme than what we did), assuming the null hypothesis.\n *\n * @example\n * var control = [2, 5, 3, 6, 7, 2, 5];\n * var treatment = [20, 5, 13, 12, 7, 2, 2];\n * permutationTest(control, treatment); // ~0.1324\n */\nfunction permutationTest(sampleX, sampleY, alternative, k, randomSource) {\n // Set default arguments\n if (k === undefined) {\n k = 10000;\n }\n if (alternative === undefined) {\n alternative = \"two_side\";\n }\n if (\n alternative !== \"two_side\" &&\n alternative !== \"greater\" &&\n alternative !== \"less\"\n ) {\n throw new Error(\n \"`alternative` must be either 'two_side', 'greater', or 'less'.\"\n );\n }\n\n // get means for each sample\n const meanX = mean(sampleX);\n const meanY = mean(sampleY);\n\n // calculate initial test statistic. This will be our point of comparison with\n // the generated test statistics.\n const testStatistic = meanX - meanY;\n\n // create test-statistic distribution\n const testStatDsn = new Array(k);\n\n // combine datsets so we can easily shuffle later\n const allData = sampleX.concat(sampleY);\n const midIndex = Math.floor(allData.length / 2);\n\n for (let i = 0; i < k; i++) {\n // 1. shuffle data assignments\n shuffleInPlace(allData, randomSource);\n const permLeft = allData.slice(0, midIndex);\n const permRight = allData.slice(midIndex, allData.length);\n\n // 2.re-calculate test statistic\n const permTestStatistic = mean(permLeft) - mean(permRight);\n\n // 3. store test statistic to build test statistic distribution\n testStatDsn[i] = permTestStatistic;\n }\n\n // Calculate p-value depending on alternative\n // For this test, we calculate the percentage of 'extreme' test statistics (subject to our hypothesis)\n // more info on permutation test p-value calculations: https://onlinecourses.science.psu.edu/stat464/node/35\n let numExtremeTStats = 0;\n if (alternative === \"two_side\") {\n for (let i = 0; i <= k; i++) {\n if (Math.abs(testStatDsn[i]) >= Math.abs(testStatistic)) {\n numExtremeTStats += 1;\n }\n }\n } else if (alternative === \"greater\") {\n for (let i = 0; i <= k; i++) {\n if (testStatDsn[i] >= testStatistic) {\n numExtremeTStats += 1;\n }\n }\n } else {\n // alternative === 'less'\n for (let i = 0; i <= k; i++) {\n if (testStatDsn[i] <= testStatistic) {\n numExtremeTStats += 1;\n }\n }\n }\n\n return numExtremeTStats / k;\n}\n\nexport default permutationTest;\n","/**\n * Implementation of [Heap's Algorithm](https://en.wikipedia.org/wiki/Heap%27s_algorithm)\n * for generating permutations.\n *\n * @param {Array} elements any type of data\n * @returns {Array} array of permutations\n */\nfunction permutationsHeap(elements) {\n const indexes = new Array(elements.length);\n const permutations = [elements.slice()];\n\n for (let i = 0; i < elements.length; i++) {\n indexes[i] = 0;\n }\n\n for (let i = 0; i < elements.length; ) {\n if (indexes[i] < i) {\n // At odd indexes, swap from indexes[i] instead\n // of from the beginning of the array\n let swapFrom = 0;\n if (i % 2 !== 0) {\n swapFrom = indexes[i];\n }\n\n // swap between swapFrom and i, using\n // a temporary variable as storage.\n const temp = elements[swapFrom];\n elements[swapFrom] = elements[i];\n elements[i] = temp;\n\n permutations.push(elements.slice());\n indexes[i]++;\n i = 0;\n } else {\n indexes[i] = 0;\n i++;\n }\n }\n\n return permutations;\n}\n\nexport default permutationsHeap;\n","import epsilon from \"./epsilon.js\";\n\n/**\n * The [Poisson Distribution](http://en.wikipedia.org/wiki/Poisson_distribution)\n * is a discrete probability distribution that expresses the probability\n * of a given number of events occurring in a fixed interval of time\n * and/or space if these events occur with a known average rate and\n * independently of the time since the last event.\n *\n * The Poisson Distribution is characterized by the strictly positive\n * mean arrival or occurrence rate, `λ`.\n *\n * @param {number} lambda location poisson distribution\n * @returns {number[]} values of poisson distribution at that point\n */\nfunction poissonDistribution(lambda) /*: ?number[] */ {\n // Check that lambda is strictly positive\n if (lambda <= 0) {\n return undefined;\n }\n\n // our current place in the distribution\n let x = 0;\n // and we keep track of the current cumulative probability, in\n // order to know when to stop calculating chances.\n let cumulativeProbability = 0;\n // the calculated cells to be returned\n const cells = [];\n let factorialX = 1;\n\n // This algorithm iterates through each potential outcome,\n // until the `cumulativeProbability` is very close to 1, at\n // which point we've defined the vast majority of outcomes\n do {\n // a [probability mass function](https://en.wikipedia.org/wiki/Probability_mass_function)\n cells[x] = (Math.exp(-lambda) * Math.pow(lambda, x)) / factorialX;\n cumulativeProbability += cells[x];\n x++;\n factorialX *= x;\n // when the cumulativeProbability is nearly 1, we've calculated\n // the useful range of this distribution\n } while (cumulativeProbability < 1 - epsilon);\n\n return cells;\n}\n\nexport default poissonDistribution;\n","import epsilon from \"./epsilon.js\";\nimport inverseErrorFunction from \"./inverse_error_function.js\";\n\n/**\n * The [Probit](http://en.wikipedia.org/wiki/Probit)\n * is the inverse of cumulativeStdNormalProbability(),\n * and is also known as the normal quantile function.\n *\n * It returns the number of standard deviations from the mean\n * where the p'th quantile of values can be found in a normal distribution.\n * So, for example, probit(0.5 + 0.6827/2) ≈ 1 because 68.27% of values are\n * normally found within 1 standard deviation above or below the mean.\n *\n * @param {number} p\n * @returns {number} probit\n */\nfunction probit(p) {\n if (p === 0) {\n p = epsilon;\n } else if (p >= 1) {\n p = 1 - epsilon;\n }\n return Math.sqrt(2) * inverseErrorFunction(2 * p - 1);\n}\n\nexport default probit;\n","/**\n * The [product](https://en.wikipedia.org/wiki/Product_(mathematics)) of an array\n * is the result of multiplying all numbers together, starting using one as the multiplicative identity.\n *\n * This runs in `O(n)`, linear time, with respect to the length of the array.\n *\n * @param {Array} x input\n * @return {number} product of all input numbers\n * @example\n * product([1, 2, 3, 4]); // => 24\n */\nfunction product(x) {\n let value = 1;\n for (let i = 0; i < x.length; i++) {\n value *= x[i];\n }\n return value;\n}\n\nexport default product;\n","import numericSort from \"./numeric_sort.js\";\nimport quantileRankSorted from \"./quantile_rank_sorted.js\";\n\n/**\n * This function returns the quantile in which one would find the given value in\n * the given array. It will copy and sort your array before each run, so\n * if you know your array is already sorted, you should use `quantileRankSorted`\n * instead.\n *\n * @param {Array} x input\n * @returns {number} value value\n * @example\n * quantileRank([4, 3, 1, 2], 3); // => 0.75\n * quantileRank([4, 3, 2, 3, 1], 3); // => 0.7\n * quantileRank([2, 4, 1, 3], 6); // => 1\n * quantileRank([5, 3, 1, 2, 3], 4); // => 0.8\n */\nfunction quantileRank(x, value) {\n // Cloning and sorting the array\n const sortedCopy = numericSort(x);\n\n return quantileRankSorted(sortedCopy, value);\n}\n\nexport default quantileRank;\n","/**\n * The [R Squared](http://en.wikipedia.org/wiki/Coefficient_of_determination)\n * value of data compared with a function `f`\n * is the sum of the squared differences between the prediction\n * and the actual value.\n *\n * @param {Array>} x input data: this should be doubly-nested\n * @param {Function} func function called on `[i][0]` values within the dataset\n * @returns {number} r-squared value\n * @example\n * var samples = [[0, 0], [1, 1]];\n * var regressionLine = linearRegressionLine(linearRegression(samples));\n * rSquared(samples, regressionLine); // = 1 this line is a perfect fit\n */\nfunction rSquared(x, func) {\n if (x.length < 2) {\n return 1;\n }\n\n // Compute the average y value for the actual\n // data set in order to compute the\n // _total sum of squares_\n let sum = 0;\n for (let i = 0; i < x.length; i++) {\n sum += x[i][1];\n }\n const average = sum / x.length;\n\n // Compute the total sum of squares - the\n // squared difference between each point\n // and the average of all points.\n let sumOfSquares = 0;\n for (let j = 0; j < x.length; j++) {\n sumOfSquares += Math.pow(average - x[j][1], 2);\n }\n\n // Finally estimate the error: the squared\n // difference between the estimate and the actual data\n // value at each point.\n let err = 0;\n for (let k = 0; k < x.length; k++) {\n err += Math.pow(x[k][1] - func(x[k][0]), 2);\n }\n\n // As the error grows larger, its ratio to the\n // sum of squares increases and the r squared\n // value grows lower.\n return 1 - err / sumOfSquares;\n}\n\nexport default rSquared;\n","import mean from \"./mean.js\";\n\n/**\n * [Kurtosis](http://en.wikipedia.org/wiki/Kurtosis) is\n * a measure of the heaviness of a distribution's tails relative to its\n * variance. The kurtosis value can be positive or negative, or even undefined.\n *\n * Implementation is based on Fisher's excess kurtosis definition and uses\n * unbiased moment estimators. This is the version found in Excel and available\n * in several statistical packages, including SAS and SciPy.\n *\n * @param {Array} x a sample of 4 or more data points\n * @returns {number} sample kurtosis\n * @throws {Error} if x has length less than 4\n * @example\n * sampleKurtosis([1, 2, 2, 3, 5]); // => 1.4555765595463122\n */\nfunction sampleKurtosis(x) {\n const n = x.length;\n\n if (n < 4) {\n throw new Error(\"sampleKurtosis requires at least four data points\");\n }\n\n const meanValue = mean(x);\n let tempValue;\n let secondCentralMoment = 0;\n let fourthCentralMoment = 0;\n\n for (let i = 0; i < n; i++) {\n tempValue = x[i] - meanValue;\n secondCentralMoment += tempValue * tempValue;\n fourthCentralMoment += tempValue * tempValue * tempValue * tempValue;\n }\n\n return (\n ((n - 1) / ((n - 2) * (n - 3))) *\n ((n * (n + 1) * fourthCentralMoment) /\n (secondCentralMoment * secondCentralMoment) -\n 3 * (n - 1))\n );\n}\n\nexport default sampleKurtosis;\n","import sampleCorrelation from \"./sample_correlation.js\";\n\n/**\n * The [rank correlation](https://en.wikipedia.org/wiki/Rank_correlation) is\n * a measure of the strength of monotonic relationship between two arrays\n *\n * @param {Array} x first input\n * @param {Array} y second input\n * @returns {number} sample rank correlation\n */\nfunction sampleRankCorrelation(x, y) {\n const xIndexes = x\n .map((value, index) => [value, index])\n .sort((a, b) => a[0] - b[0])\n .map((pair) => pair[1]);\n const yIndexes = y\n .map((value, index) => [value, index])\n .sort((a, b) => a[0] - b[0])\n .map((pair) => pair[1]);\n\n // At this step, we have an array of indexes\n // that map from sorted numbers to their original indexes. We reverse\n // that so that it is an array of the sorted destination index.\n const xRanks = Array(xIndexes.length);\n const yRanks = Array(xIndexes.length);\n for (let i = 0; i < xIndexes.length; i++) {\n xRanks[xIndexes[i]] = i;\n yRanks[yIndexes[i]] = i;\n }\n\n return sampleCorrelation(xRanks, yRanks);\n}\n\nexport default sampleRankCorrelation;\n","import mean from \"./mean.js\";\n\n/**\n * [Skewness](http://en.wikipedia.org/wiki/Skewness) is\n * a measure of the extent to which a probability distribution of a\n * real-valued random variable \"leans\" to one side of the mean.\n * The skewness value can be positive or negative, or even undefined.\n *\n * Implementation is based on the adjusted Fisher-Pearson standardized\n * moment coefficient, which is the version found in Excel and several\n * statistical packages including Minitab, SAS and SPSS.\n *\n * @since 4.1.0\n * @param {Array} x a sample of 3 or more data points\n * @returns {number} sample skewness\n * @throws {Error} if x has length less than 3\n * @example\n * sampleSkewness([2, 4, 6, 3, 1]); // => 0.590128656384365\n */\nfunction sampleSkewness(x) {\n if (x.length < 3) {\n throw new Error(\"sampleSkewness requires at least three data points\");\n }\n\n const meanValue = mean(x);\n let tempValue;\n let sumSquaredDeviations = 0;\n let sumCubedDeviations = 0;\n\n for (let i = 0; i < x.length; i++) {\n tempValue = x[i] - meanValue;\n sumSquaredDeviations += tempValue * tempValue;\n sumCubedDeviations += tempValue * tempValue * tempValue;\n }\n\n // this is Bessels' Correction: an adjustment made to sample statistics\n // that allows for the reduced degree of freedom entailed in calculating\n // values from samples rather than complete populations.\n const besselsCorrection = x.length - 1;\n\n // Find the mean value of that list\n const theSampleStandardDeviation = Math.sqrt(\n sumSquaredDeviations / besselsCorrection\n );\n\n const n = x.length;\n const cubedS = Math.pow(theSampleStandardDeviation, 3);\n\n return (n * sumCubedDeviations) / ((n - 1) * (n - 2) * cubedS);\n}\n\nexport default sampleSkewness;\n","/**\n * Sampling with replacement is a type of sampling that allows the same\n * item to be picked out of a population more than once.\n *\n * @param {Array<*>} x an array of any kind of value\n * @param {number} n count of how many elements to take\n * @param {Function} [randomSource=Math.random] an optional entropy source that\n * returns numbers between 0 inclusive and 1 exclusive: the range [0, 1)\n * @return {Array} n sampled items from the population\n * @example\n * var values = [1, 2, 3, 4];\n * sampleWithReplacement(values, 2); // returns 2 random values, like [2, 4];\n */\nfunction sampleWithReplacement(x, n, randomSource) {\n if (x.length === 0) {\n return [];\n }\n\n // a custom random number source can be provided if you want to use\n // a fixed seed or another random number generator, like\n // [random-js](https://www.npmjs.org/package/random-js)\n randomSource = randomSource || Math.random;\n\n const length = x.length;\n const sample = [];\n\n for (let i = 0; i < n; i++) {\n const index = Math.floor(randomSource() * length);\n\n sample.push(x[index]);\n }\n\n return sample;\n}\n\nexport default sampleWithReplacement;\n","import max from \"./max.js\";\nimport silhouette from \"./silhouette.js\";\n\n/**\n * Calculate the [silhouette metric](https://en.wikipedia.org/wiki/Silhouette_(clustering))\n * for a set of N-dimensional points arranged in groups. The metric is the largest\n * individual silhouette value for the data.\n *\n * @param {Array>} points N-dimensional coordinates of points.\n * @param {Array} labels Labels of points. This must be the same length as `points`,\n * and values must lie in [0..G-1], where G is the number of groups.\n * @return {number} The silhouette metric for the groupings.\n *\n * @example\n * silhouetteMetric([[0.25], [0.75]], [0, 0]); // => 1.0\n */\nfunction silhouetteMetric(points, labels) {\n const values = silhouette(points, labels);\n return max(values);\n}\n\nexport default silhouetteMetric;\n","/**\n * When removing a value from a list, one does not have to necessary\n * recompute the mean of the list in linear time. They can instead use\n * this function to compute the new mean by providing the current mean,\n * the number of elements in the list that produced it and the value to remove.\n *\n * @since 3.0.0\n * @param {number} mean current mean\n * @param {number} n number of items in the list\n * @param {number} value the value to remove\n * @returns {number} the new mean\n *\n * @example\n * subtractFromMean(20.5, 6, 53); // => 14\n */\nfunction subtractFromMean(mean, n, value) {\n return (mean * n - value) / (n - 1);\n}\n\nexport default subtractFromMean;\n","import mean from \"./mean.js\";\nimport standardDeviation from \"./standard_deviation.js\";\n\n/**\n * This is to compute [a one-sample t-test](https://en.wikipedia.org/wiki/Student%27s_t-test#One-sample_t-test), comparing the mean\n * of a sample to a known value, x.\n *\n * in this case, we're trying to determine whether the\n * population mean is equal to the value that we know, which is `x`\n * here. Usually the results here are used to look up a\n * [p-value](http://en.wikipedia.org/wiki/P-value), which, for\n * a certain level of significance, will let you determine that the\n * null hypothesis can or cannot be rejected.\n *\n * @param {Array} x sample of one or more numbers\n * @param {number} expectedValue expected value of the population mean\n * @returns {number} value\n * @example\n * tTest([1, 2, 3, 4, 5, 6], 3.385).toFixed(2); // => '0.16'\n */\nfunction tTest(x, expectedValue) {\n // The mean of the sample\n const sampleMean = mean(x);\n\n // The standard deviation of the sample\n const sd = standardDeviation(x);\n\n // Square root the length of the sample\n const rootN = Math.sqrt(x.length);\n\n // returning the t value\n return (sampleMean - expectedValue) / (sd / rootN);\n}\n\nexport default tTest;\n","import mean from \"./mean.js\";\nimport sampleVariance from \"./sample_variance.js\";\n\n/**\n * This is to compute [two sample t-test](http://en.wikipedia.org/wiki/Student's_t-test).\n * Tests whether \"mean(X)-mean(Y) = difference\", (\n * in the most common case, we often have `difference == 0` to test if two samples\n * are likely to be taken from populations with the same mean value) with\n * no prior knowledge on standard deviations of both samples\n * other than the fact that they have the same standard deviation.\n *\n * Usually the results here are used to look up a\n * [p-value](http://en.wikipedia.org/wiki/P-value), which, for\n * a certain level of significance, will let you determine that the\n * null hypothesis can or cannot be rejected.\n *\n * `diff` can be omitted if it equals 0.\n *\n * [This is used to reject](https://en.wikipedia.org/wiki/Exclusion_of_the_null_hypothesis)\n * a null hypothesis that the two populations that have been sampled into\n * `sampleX` and `sampleY` are equal to each other.\n *\n * @param {Array} sampleX a sample as an array of numbers\n * @param {Array} sampleY a sample as an array of numbers\n * @param {number} [difference=0]\n * @returns {number|null} test result\n *\n * @example\n * tTestTwoSample([1, 2, 3, 4], [3, 4, 5, 6], 0); // => -2.1908902300206643\n */\nfunction tTestTwoSample(sampleX, sampleY, difference) {\n const n = sampleX.length;\n const m = sampleY.length;\n\n // If either sample doesn't actually have any values, we can't\n // compute this at all, so we return `null`.\n if (!n || !m) {\n return null;\n }\n\n // default difference (mu) is zero\n if (!difference) {\n difference = 0;\n }\n\n const meanX = mean(sampleX);\n const meanY = mean(sampleY);\n const sampleVarianceX = sampleVariance(sampleX);\n const sampleVarianceY = sampleVariance(sampleY);\n\n if (\n typeof meanX === \"number\" &&\n typeof meanY === \"number\" &&\n typeof sampleVarianceX === \"number\" &&\n typeof sampleVarianceY === \"number\"\n ) {\n const weightedVariance =\n ((n - 1) * sampleVarianceX + (m - 1) * sampleVarianceY) /\n (n + m - 2);\n\n return (\n (meanX - meanY - difference) /\n Math.sqrt(weightedVariance * (1 / n + 1 / m))\n );\n }\n}\n\nexport default tTestTwoSample;\n","/**\n * This function calculates the Wilcoxon rank sum statistic for the first sample\n * with respect to the second. The Wilcoxon rank sum test is a non-parametric\n * alternative to the t-test which is equivalent to the\n * [Mann-Whitney U test](https://en.wikipedia.org/wiki/Mann%E2%80%93Whitney_U_test).\n * The statistic is calculated by pooling all the observations together, ranking them,\n * and then summing the ranks associated with one of the samples. If this rank sum is\n * sufficiently large or small we reject the hypothesis that the two samples come\n * from the same distribution in favor of the alternative that one is shifted with\n * respect to the other.\n *\n * @param {Array} sampleX a sample as an array of numbers\n * @param {Array} sampleY a sample as an array of numbers\n * @returns {number} rank sum for sampleX\n *\n * @example\n * wilcoxonRankSum([1, 4, 8], [9, 12, 15]); // => 6\n */\nfunction wilcoxonRankSum(sampleX, sampleY) {\n if (!sampleX.length || !sampleY.length) {\n throw new Error(\"Neither sample can be empty\");\n }\n\n const pooledSamples = sampleX\n .map((x) => ({ label: \"x\", value: x }))\n .concat(sampleY.map((y) => ({ label: \"y\", value: y })))\n .sort((a, b) => a.value - b.value);\n\n for (let rank = 0; rank < pooledSamples.length; rank++) {\n pooledSamples[rank].rank = rank;\n }\n\n let tiedRanks = [pooledSamples[0].rank];\n for (let i = 1; i < pooledSamples.length; i++) {\n if (pooledSamples[i].value === pooledSamples[i - 1].value) {\n tiedRanks.push(pooledSamples[i].rank);\n if (i === pooledSamples.length - 1) {\n replaceRanksInPlace(pooledSamples, tiedRanks);\n }\n } else if (tiedRanks.length > 1) {\n replaceRanksInPlace(pooledSamples, tiedRanks);\n } else {\n tiedRanks = [pooledSamples[i].rank];\n }\n }\n\n function replaceRanksInPlace(pooledSamples, tiedRanks) {\n const average = (tiedRanks[0] + tiedRanks[tiedRanks.length - 1]) / 2;\n for (let i = 0; i < tiedRanks.length; i++) {\n pooledSamples[tiedRanks[i]].rank = average;\n }\n }\n\n let rankSum = 0;\n\n for (let i = 0; i < pooledSamples.length; i++) {\n const sample = pooledSamples[i];\n if (sample.label === \"x\") {\n rankSum += sample.rank + 1;\n }\n }\n\n return rankSum;\n}\n\nexport default wilcoxonRankSum;\n","/**\n * The [Z-Score, or Standard Score](http://en.wikipedia.org/wiki/Standard_score).\n *\n * The standard score is the number of standard deviations an observation\n * or datum is above or below the mean. Thus, a positive standard score\n * represents a datum above the mean, while a negative standard score\n * represents a datum below the mean. It is a dimensionless quantity\n * obtained by subtracting the population mean from an individual raw\n * score and then dividing the difference by the population standard\n * deviation.\n *\n * The z-score is only defined if one knows the population parameters;\n * if one only has a sample set, then the analogous computation with\n * sample mean and sample standard deviation yields the\n * Student's t-statistic.\n *\n * @param {number} x\n * @param {number} mean\n * @param {number} standardDeviation\n * @return {number} z score\n * @example\n * zScore(78, 80, 5); // => -0.4\n */\nfunction zScore(x, mean, standardDeviation) {\n return (x - mean) / standardDeviation;\n}\n\nexport default zScore;\n"],"names":["sum","x","length","let","transition","correction","NaN","i","Math","abs","mean","Error","sumNthPowerDeviations","n","const","tempValue","meanValue","pow","variance","standardDeviation","v","sqrt","modeSorted","sorted","last","value","maxSeen","seenThis","numericSort","slice","sort","a","b","min","max","sumSimple","quantileSorted","p","idx","ceil","quickselect","arr","k","left","right","m","z","log","s","exp","sd","floor","t","j","swap","tmp","quantile","copy","Array","isArray","indices","push","quantileIndex","compare","stack","r","pop","l","quantileSelect","multiQuantileSelect","results","len","quantileRankSorted","mid","lo","hi","lowerBound","u","upperBound","interquartileRange","q1","q2","median","medianAbsoluteDeviation","medianValue","medianAbsoluteDeviations","shuffleInPlace","randomSource","random","temporary","index","shuffle","sample","makeMatrix","columns","rows","matrix","column","uniqueCountSorted","lastSeenValue","uniqueValueCount","ssq","sums","sumsOfSquares","sji","muji","fillMatrixColumn","iMin","iMax","cluster","backtrackMatrix","jlow","ssqjlow","ssqj","jhigh","sampleCovariance","y","xmean","ymean","sampleVariance","sampleStandardDeviation","sampleVarianceX","sampleCorrelation","combineMeans","mean1","n1","mean2","n2","meanSimple","rootMeanSquare","sumOfSquares","BayesianClassifier","this","totalCount","data","prototype","train","item","category","undefined","score","odds","oddsSums","combination","PerceptronModel","weights","bias","predict","features","label","prediction","gradient","epsilon","factorial","accumulator","COEFFICIENTS","LOGSQRT2PI","PI","chiSquaredDistributionTable","SQRT_2PI","kernels","gaussian","bandwidthMethods","nrd","stddev","iqr","kernelDensityEstimation","X","kernel","bandwidthMethod","kernelFn","bandwidth","cumulativeDistribution","round","standardNormalTable","errorFunction","tau","inverseErrorFunction","inv","sign","TypeError","euclideanDistance","diff","labelPoints","points","centroids","map","minDist","Number","MAX_VALUE","dist","calculateCentroids","labels","numCluster","dimension","counts","fill","numPoints","point","current","centroid","calculateChange","total","silhouette","groupings","numGroups","result","createGroups","distances","calculateAllDistances","meanDistanceFromPointToGroup","meanDistanceToNearestGroup","which","d","group","relativeError","actual","expected","newValue","tolerance","trials","probability","cumulativeProbability","cells","binomialCoefficient","func","start","end","maxIterations","errorTolerance","output","distributionType","significance","chiSquared","hypothesizedDistribution","observedFrequencies","expectedFrequencies","degreesOfFreedom","chunkSize","nClusters","nValues","shift","shiftedValue","fillMatrices","clusters","clusterRight","clusterLeft","combinations","subI","subsetCombinations","next","combinationList","unshift","combinationsReplacement","concat","variance1","variance2","newMean","absZ","toFixed","nClasses","theMin","theMax","breaks","breakSize","gamma","isInteger","sin","seriesDenom","E","Infinity","g","reciprocalSum","matrices","lowerClassLimits","varianceCombinations","tmp1","tmp2","sumSquares","w","i4","lowerClassLimit","val","jenksMatrices","kclass","countNum","jenksBreaks","oldCentroids","newCentroids","change","dataLength","sumX","sumY","sumXX","sumXY","mb","mode","Map","modeCount","newCount","get","set","sampleX","sampleY","alternative","testStatistic","testStatDsn","allData","midIndex","permLeft","permRight","permTestStatistic","numExtremeTStats","elements","indexes","permutations","swapFrom","temp","lambda","factorialX","average","err","secondCentralMoment","fourthCentralMoment","xIndexes","pair","yIndexes","xRanks","yRanks","sumSquaredDeviations","sumCubedDeviations","besselsCorrection","theSampleStandardDeviation","expectedValue","difference","meanX","meanY","sampleVarianceY","weightedVariance","pooledSamples","rank","tiedRanks","replaceRanksInPlace","rankSum"],"mappings":"0OAkBA,SAASA,EAAIC,GAET,GAAiB,IAAbA,EAAEC,OACF,OAAO,EAIXC,IAKIC,EALAJ,EAAMC,EAAE,GAGRI,EAAa,EAIjB,GAAmB,iBAARL,EACP,OAAOM,IAGX,IAAKH,IAAII,EAAI,EAAGA,EAAIN,EAAEC,OAAQK,IAAK,CAC/B,GAAoB,iBAATN,EAAEM,GACT,OAAOD,IAEXF,EAAaJ,EAAMC,EAAEM,GAIjBC,KAAKC,IAAIT,IAAQQ,KAAKC,IAAIR,EAAEM,IAC5BF,GAAcL,EAAMI,EAAaH,EAAEM,GAEnCF,GAAcJ,EAAEM,GAAKH,EAAaJ,EAGtCA,EAAMI,CACT,CAGD,OAAOJ,EAAMK,CACjB,CCvCA,SAASK,EAAKT,GACV,GAAiB,IAAbA,EAAEC,OACF,MAAM,IAAIS,MAAM,yCAGpB,OAAOX,EAAIC,GAAKA,EAAEC,MACtB,CCLA,SAASU,EAAsBX,EAAGY,GAC9BC,IAEIC,EACAR,EAHES,EAAYN,EAAKT,GACnBD,EAAM,EAOV,GAAU,IAANa,EACA,IAAKN,EAAI,EAAGA,EAAIN,EAAEC,OAAQK,IAEtBP,IADAe,EAAYd,EAAEM,GAAKS,GACAD,OAGvB,IAAKR,EAAI,EAAGA,EAAIN,EAAEC,OAAQK,IACtBP,GAAOQ,KAAKS,IAAIhB,EAAEM,GAAKS,EAAWH,GAI1C,OAAOb,CACX,CCtBA,SAASkB,EAASjB,GACd,GAAiB,IAAbA,EAAEC,OACF,MAAM,IAAIS,MAAM,6CAKpB,OAAOC,EAAsBX,EAAG,GAAKA,EAAEC,MAC3C,CCNA,SAASiB,EAAkBlB,GACvB,GAAiB,IAAbA,EAAEC,OACF,OAAO,EAEXY,IAAMM,EAAIF,EA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M,MACN,KAAO,OAEX,EAAG,CACC,KAAO,KACP,IAAM,KACN,KAAO,IACP,IAAM,KACN,GAAK,KACL,GAAK,KACL,GAAK,MACL,IAAM,MACN,KAAO,MACP,IAAM,MACN,KAAO,OAEX,GAAI,CACA,KAAO,KACP,IAAM,KACN,KAAO,KACP,IAAM,KACN,GAAK,KACL,GAAK,KACL,GAAK,MACL,IAAM,MACN,KAAO,MACP,IAAM,MACN,KAAO,OAEX,GAAI,CACA,KAAO,IACP,IAAM,KACN,KAAO,KACP,IAAM,KACN,GAAK,KACL,GAAK,MACL,GAAK,MACL,IAAM,MACN,KAAO,MACP,IAAM,MACN,KAAO,OAEX,GAAI,CACA,KAAO,KACP,IAAM,KACN,KAAO,IACP,IAAM,KACN,GAAK,IACL,GAAK,MACL,GAAK,MACL,IAAM,MACN,KAAO,MACP,IAAM,MACN,KAAO,MAEX,GAAI,CACA,KAAO,KACP,IAAM,KACN,KAAO,KACP,IAAM,KACN,GAAK,KACL,GAAK,MACL,GAAK,MACL,IAAM,MACN,KAAO,MACP,IAAM,MACN,KAAO,OAEX,GAAI,CACA,KAAO,KACP,IAAM,KACN,KAAO,KACP,IAAM,KACN,GAAK,KACL,GAAK,MACL,GAAK,MACL,IAAM,MACN,KAAO,MACP,IAAM,MACN,KAAO,OAEX,GAAI,CACA,KAAO,IACP,IAAM,KACN,KAAO,KACP,IAAM,KACN,GAAK,KACL,GAAK,MACL,GAAK,MACL,IAAM,GACN,KAAO,MACP,IAAM,MACN,KAAO,MAEX,GAAI,CACA,KAAO,KACP,IAAM,KACN,KAAO,KACP,IAAM,KACN,GAAK,KACL,GAAK,MACL,GAAK,MACL,IAAM,KACN,KAAO,MACP,IAAM,GACN,KAAO,OAEX,GAAI,CACA,KAAO,IACP,IAAM,KACN,KAAO,KACP,IAAM,KACN,GAAK,MACL,GAAK,MACL,GAAK,MACL,IAAM,MACN,KAAO,MACP,IAAM,MACN,KAAO,OAEX,GAAI,CACA,KAAO,KACP,IAAM,KACN,KAAO,KACP,IAAM,KACN,GAAK,MACL,GAAK,MACL,GAAK,MACL,IAAM,MACN,KAAO,MACP,IAAM,MACN,KAAO,OAEX,GAAI,CACA,KAAO,KACP,IAAM,KACN,KAAO,KACP,IAAM,MACN,GAAK,MACL,GAAK,MACL,GAAK,KACL,IAAM,MACN,KAAO,MACP,IAAM,MACN,KAAO,OAEX,GAAI,CACA,KAAO,KACP,IAAM,KACN,KAAO,KACP,IAAM,MACN,GAAK,MACL,GAAK,MACL,GAAK,MACL,IAAM,MACN,KAAO,MACP,IAAM,MACN,KAAO,IAEX,GAAI,CACA,KAAO,KACP,IAAM,IACN,KAAO,MACP,IAAM,MACN,GAAK,MACL,GAAK,MACL,GAAK,MACL,IAAM,MACN,KAAO,MACP,IAAM,MACN,KAAO,MAEX,GAAI,CACA,KAAO,KACP,IAAM,KACN,KAAO,MACP,IAAM,MACN,GAAK,MACL,GAAK,MACL,GAAK,MACL,IAAM,MACN,KAAO,MACP,IAAM,MACN,KAAO,MAEX,GAAI,CACA,KAAO,KACP,IAAM,KACN,KAAO,MACP,IAAM,MACN,GAAK,MACL,GAAK,MACL,GAAK,MACL,IAAM,MACN,KAAO,MACP,IAAM,MACN,KAAO,OAEX,GAAI,CACA,KAAO,KACP,IAAM,MACN,KAAO,KACP,IAAM,MACN,GAAK,MACL,GAAK,MACL,GAAK,KACL,IAAM,MACN,KAAO,MACP,IAAM,MACN,KAAO,OAEX,GAAI,CACA,KAAO,MACP,IAAM,MACN,KAAO,MACP,IAAM,MACN,GAAK,MACL,GAAK,MACL,GAAK,MACL,IAAM,MACN,KAAO,MACP,IAAM,MACN,KAAO,OAEX,GAAI,CACA,KAAO,MACP,IAAM,KACN,KAAO,MACP,IAAM,MACN,GAAK,MACL,GAAK,MACL,GAAK,MACL,IAAM,MACN,KAAO,MACP,IAAM,MACN,KAAO,OAEX,GAAI,CACA,KAAO,MACP,IAAM,MACN,KAAO,MACP,IAAM,MACN,GAAK,MACL,GAAK,MACL,GAAK,MAC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,MAC5B7U,IAAM4U,EAAcjV,OAAS,GAC7BoV,EAAoBH,EAAeE,IAEhCA,EAAUnV,OAAS,EAC1BoV,EAAoBH,EAAeE,GAEnCA,EAAY,CAACF,EAAc5U,GAAG6U,MAItC,SAASE,EAAoBH,EAAeE,GAExC,IADAvU,IAAMkT,GAAWqB,EAAU,GAAKA,EAAUA,EAAUnV,OAAS,IAAM,EAC1DK,EAAI,EAAGA,EAAI8U,EAAUnV,OAAQK,IAClC4U,EAAcE,EAAU9U,IAAI6U,KAAOpB,CAE1C,CAID,IAFA7T,IAAIoV,EAAU,EAELhV,EAAI,EAAGA,EAAI4U,EAAcjV,OAAQK,IAAK,CAC3CO,IAAM8E,EAASuP,EAAc5U,GACR,MAAjBqF,EAAOyD,QACPkM,GAAW3P,EAAOwP,KAAO,EAEhC,CAED,OAAOG,CACX,WCxCA,SAAgBtV,EAAGS,EAAMS,GACrB,OAAQlB,EAAIS,GAAQS,CACxB"} \ No newline at end of file +{"version":3,"file":"simple-statistics.min.js","sources":["../src/sum.js","../src/mean.js","../src/sum_nth_power_deviations.js","../src/variance.js","../src/standard_deviation.js","../src/mode_sorted.js","../src/numeric_sort.js","../src/min.js","../src/max.js","../src/sum_simple.js","../src/quantile_sorted.js","../src/quickselect.js","../src/quantile.js","../src/quantile_rank_sorted.js","../src/interquartile_range.js","../src/median.js","../src/median_absolute_deviation.js","../src/shuffle_in_place.js","../src/shuffle.js","../src/sample.js","../src/make_matrix.js","../src/unique_count_sorted.js","../src/ckmeans.js","../src/sample_covariance.js","../src/sample_variance.js","../src/sample_standard_deviation.js","../src/sample_correlation.js","../src/combine_means.js","../src/mean_simple.js","../src/root_mean_square.js","../src/bayesian_classifier.js","../src/perceptron.js","../src/epsilon.js","../src/factorial.js","../src/gammaln.js","../src/chi_squared_distribution_table.js","../src/kernel_density_estimation.js","../src/standard_normal_table.js","../src/error_function.js","../src/inverse_error_function.js","../src/sign.js","../src/euclidean_distance.js","../src/k_means_cluster.js","../src/silhouette.js","../src/relative_error.js","../src/add_to_mean.js","../src/approx_equal.js","../src/bernoulli_distribution.js","../src/binomial_distribution.js","../src/bisect.js","../src/chi_squared_goodness_of_fit.js","../src/chunk.js","../src/coefficient_of_variation.js","../src/combinations.js","../src/combinations_replacement.js","../src/combine_variances.js","../src/cumulative_std_logistic_probability.js","../src/cumulative_std_normal_probability.js","../src/equal_interval_breaks.js","../src/extent.js","../src/extent_sorted.js","../src/gamma.js","../src/geometric_mean.js","../src/harmonic_mean.js","../src/jenks.js","../src/jenks_matrices.js","../src/jenks_breaks.js","../src/linear_regression.js","../src/linear_regression_line.js","../src/log_average.js","../src/logit.js","../src/max_sorted.js","../src/median_sorted.js","../src/min_sorted.js","../src/mode.js","../src/mode_fast.js","../src/permutation_test.js","../src/permutations_heap.js","../src/poisson_distribution.js","../src/probit.js","../src/product.js","../src/quantile_rank.js","../src/r_squared.js","../src/sample_kurtosis.js","../src/sample_rank_correlation.js","../src/sample_skewness.js","../src/sample_with_replacement.js","../src/silhouette_metric.js","../src/subtract_from_mean.js","../src/t_test.js","../src/t_test_two_sample.js","../src/wilcoxon_rank_sum.js","../src/z_score.js"],"sourcesContent":["/**\n * Our default sum is the [Kahan-Babuska algorithm](https://pdfs.semanticscholar.org/1760/7d467cda1d0277ad272deb2113533131dc09.pdf).\n * This method is an improvement over the classical\n * [Kahan summation algorithm](https://en.wikipedia.org/wiki/Kahan_summation_algorithm).\n * It aims at computing the sum of a list of numbers while correcting for\n * floating-point errors. Traditionally, sums are calculated as many\n * successive additions, each one with its own floating-point roundoff. These\n * losses in precision add up as the number of numbers increases. This alternative\n * algorithm is more accurate than the simple way of calculating sums by simple\n * addition.\n *\n * This runs in `O(n)`, linear time, with respect to the length of the array.\n *\n * @param {Array} x input\n * @return {number} sum of all input numbers\n * @example\n * sum([1, 2, 3]); // => 6\n */\nfunction sum(x) {\n // If the array is empty, we needn't bother computing its sum\n if (x.length === 0) {\n return 0;\n }\n\n // Initializing the sum as the first number in the array\n let sum = x[0];\n\n // Keeping track of the floating-point error correction\n let correction = 0;\n\n let transition;\n\n if (typeof sum !== \"number\") {\n return Number.NaN;\n }\n\n for (let i = 1; i < x.length; i++) {\n if (typeof x[i] !== \"number\") {\n return Number.NaN;\n }\n transition = sum + x[i];\n\n // Here we need to update the correction in a different fashion\n // if the new absolute value is greater than the absolute sum\n if (Math.abs(sum) >= Math.abs(x[i])) {\n correction += sum - transition + x[i];\n } else {\n correction += x[i] - transition + sum;\n }\n\n sum = transition;\n }\n\n // Returning the corrected sum\n return sum + correction;\n}\n\nexport default sum;\n","import sum from \"./sum.js\";\n\n/**\n * The mean, _also known as average_,\n * is the sum of all values over the number of values.\n * This is a [measure of central tendency](https://en.wikipedia.org/wiki/Central_tendency):\n * a method of finding a typical or central value of a set of numbers.\n *\n * This runs in `O(n)`, linear time, with respect to the length of the array.\n *\n * @param {Array} x sample of one or more data points\n * @throws {Error} if the length of x is less than one\n * @returns {number} mean\n * @example\n * mean([0, 10]); // => 5\n */\nfunction mean(x) {\n if (x.length === 0) {\n throw new Error(\"mean requires at least one data point\");\n }\n\n return sum(x) / x.length;\n}\n\nexport default mean;\n","import mean from \"./mean.js\";\n\n/**\n * The sum of deviations to the Nth power.\n * When n=2 it's the sum of squared deviations.\n * When n=3 it's the sum of cubed deviations.\n *\n * @param {Array} x\n * @param {number} n power\n * @returns {number} sum of nth power deviations\n *\n * @example\n * var input = [1, 2, 3];\n * // since the variance of a set is the mean squared\n * // deviations, we can calculate that with sumNthPowerDeviations:\n * sumNthPowerDeviations(input, 2) / input.length;\n */\nfunction sumNthPowerDeviations(x, n) {\n const meanValue = mean(x);\n let sum = 0;\n let tempValue;\n let i;\n\n // This is an optimization: when n is 2 (we're computing a number squared),\n // multiplying the number by itself is significantly faster than using\n // the Math.pow method.\n if (n === 2) {\n for (i = 0; i < x.length; i++) {\n tempValue = x[i] - meanValue;\n sum += tempValue * tempValue;\n }\n } else {\n for (i = 0; i < x.length; i++) {\n sum += Math.pow(x[i] - meanValue, n);\n }\n }\n\n return sum;\n}\n\nexport default sumNthPowerDeviations;\n","import sumNthPowerDeviations from \"./sum_nth_power_deviations.js\";\n\n/**\n * The [variance](http://en.wikipedia.org/wiki/Variance)\n * is the sum of squared deviations from the mean.\n *\n * This is an implementation of variance, not sample variance:\n * see the `sampleVariance` method if you want a sample measure.\n *\n * @param {Array} x a population of one or more data points\n * @returns {number} variance: a value greater than or equal to zero.\n * zero indicates that all values are identical.\n * @throws {Error} if x's length is 0\n * @example\n * variance([1, 2, 3, 4, 5, 6]); // => 2.9166666666666665\n */\nfunction variance(x) {\n if (x.length === 0) {\n throw new Error(\"variance requires at least one data point\");\n }\n\n // Find the mean of squared deviations between the\n // mean value and each value.\n return sumNthPowerDeviations(x, 2) / x.length;\n}\n\nexport default variance;\n","import variance from \"./variance.js\";\n\n/**\n * The [standard deviation](http://en.wikipedia.org/wiki/Standard_deviation)\n * is the square root of the variance. This is also known as the population\n * standard deviation. It's useful for measuring the amount\n * of variation or dispersion in a set of values.\n *\n * Standard deviation is only appropriate for full-population knowledge: for\n * samples of a population, {@link sampleStandardDeviation} is\n * more appropriate.\n *\n * @param {Array} x input\n * @returns {number} standard deviation\n * @example\n * variance([2, 4, 4, 4, 5, 5, 7, 9]); // => 4\n * standardDeviation([2, 4, 4, 4, 5, 5, 7, 9]); // => 2\n */\nfunction standardDeviation(x) {\n if (x.length === 1) {\n return 0;\n }\n const v = variance(x);\n return Math.sqrt(v);\n}\n\nexport default standardDeviation;\n","/**\n * The [mode](https://en.wikipedia.org/wiki/Mode_%28statistics%29) is the number\n * that appears in a list the highest number of times.\n * There can be multiple modes in a list: in the event of a tie, this\n * algorithm will return the most recently seen mode.\n *\n * This is a [measure of central tendency](https://en.wikipedia.org/wiki/Central_tendency):\n * a method of finding a typical or central value of a set of numbers.\n *\n * This runs in `O(n)` because the input is sorted.\n *\n * @param {Array} sorted a sample of one or more data points\n * @returns {number} mode\n * @throws {Error} if sorted is empty\n * @example\n * modeSorted([0, 0, 1]); // => 0\n */\nfunction modeSorted(sorted) {\n // Handle edge cases:\n // The mode of an empty list is undefined\n if (sorted.length === 0) {\n throw new Error(\"mode requires at least one data point\");\n }\n if (sorted.length === 1) {\n return sorted[0];\n }\n\n // This assumes it is dealing with an array of size > 1, since size\n // 0 and 1 are handled immediately. Hence it starts at index 1 in the\n // array.\n let last = sorted[0];\n // store the mode as we find new modes\n let value = Number.NaN;\n // store how many times we've seen the mode\n let maxSeen = 0;\n // how many times the current candidate for the mode\n // has been seen\n let seenThis = 1;\n\n // end at sorted.length + 1 to fix the case in which the mode is\n // the highest number that occurs in the sequence. the last iteration\n // compares sorted[i], which is undefined, to the highest number\n // in the series\n for (let i = 1; i < sorted.length + 1; i++) {\n // we're seeing a new number pass by\n if (sorted[i] !== last) {\n // the last number is the new mode since we saw it more\n // often than the old one\n if (seenThis > maxSeen) {\n maxSeen = seenThis;\n value = last;\n }\n seenThis = 1;\n last = sorted[i];\n // if this isn't a new number, it's one more occurrence of\n // the potential mode\n } else {\n seenThis++;\n }\n }\n return value;\n}\n\nexport default modeSorted;\n","/**\n * Sort an array of numbers by their numeric value, ensuring that the\n * array is not changed in place.\n *\n * This is necessary because the default behavior of .sort\n * in JavaScript is to sort arrays as string values\n *\n * [1, 10, 12, 102, 20].sort()\n * // output\n * [1, 10, 102, 12, 20]\n *\n * @param {Array} x input array\n * @return {Array} sorted array\n * @private\n * @example\n * numericSort([3, 2, 1]) // => [1, 2, 3]\n */\nfunction numericSort(x) {\n return (\n x\n // ensure the array is not changed in-place\n .slice()\n // comparator function that treats input as numeric\n .sort(function (a, b) {\n return a - b;\n })\n );\n}\n\nexport default numericSort;\n","/**\n * The min is the lowest number in the array.\n * This runs in `O(n)`, linear time, with respect to the length of the array.\n *\n * @param {Array} x sample of one or more data points\n * @throws {Error} if the length of x is less than one\n * @returns {number} minimum value\n * @example\n * min([1, 5, -10, 100, 2]); // => -10\n */\nfunction min(x) {\n if (x.length === 0) {\n throw new Error(\"min requires at least one data point\");\n }\n\n let value = x[0];\n for (let i = 1; i < x.length; i++) {\n if (x[i] < value) {\n value = x[i];\n }\n }\n return value;\n}\n\nexport default min;\n","/**\n * This computes the maximum number in an array.\n *\n * This runs in `O(n)`, linear time, with respect to the length of the array.\n *\n * @param {Array} x sample of one or more data points\n * @returns {number} maximum value\n * @throws {Error} if the length of x is less than one\n * @example\n * max([1, 2, 3, 4]);\n * // => 4\n */\nfunction max(x) {\n if (x.length === 0) {\n throw new Error(\"max requires at least one data point\");\n }\n\n let value = x[0];\n for (let i = 1; i < x.length; i++) {\n if (x[i] > value) {\n value = x[i];\n }\n }\n return value;\n}\n\nexport default max;\n","/**\n * The simple [sum](https://en.wikipedia.org/wiki/Summation) of an array\n * is the result of adding all numbers together, starting from zero.\n *\n * This runs in `O(n)`, linear time, with respect to the length of the array.\n *\n * @param {Array} x input\n * @return {number} sum of all input numbers\n * @example\n * sumSimple([1, 2, 3]); // => 6\n */\nfunction sumSimple(x) {\n let value = 0;\n for (let i = 0; i < x.length; i++) {\n if (typeof x[i] !== \"number\") {\n return Number.NaN;\n }\n value += x[i];\n }\n return value;\n}\n\nexport default sumSimple;\n","/**\n * This is the internal implementation of quantiles: when you know\n * that the order is sorted, you don't need to re-sort it, and the computations\n * are faster.\n *\n * @param {Array} x sample of one or more data points\n * @param {number} p desired quantile: a number between 0 to 1, inclusive\n * @returns {number} quantile value\n * @throws {Error} if p ix outside of the range from 0 to 1\n * @throws {Error} if x is empty\n * @example\n * quantileSorted([3, 6, 7, 8, 8, 9, 10, 13, 15, 16, 20], 0.5); // => 9\n */\nfunction quantileSorted(x, p) {\n const idx = x.length * p;\n if (x.length === 0) {\n throw new Error(\"quantile requires at least one data point.\");\n } else if (p < 0 || p > 1) {\n throw new Error(\"quantiles must be between 0 and 1\");\n } else if (p === 1) {\n // If p is 1, directly return the last element\n return x[x.length - 1];\n } else if (p === 0) {\n // If p is 0, directly return the first element\n return x[0];\n } else if (idx % 1 !== 0) {\n // If p is not integer, return the next element in array\n return x[Math.ceil(idx) - 1];\n } else if (x.length % 2 === 0) {\n // If the list has even-length, we'll take the average of this number\n // and the next value, if there is one\n return (x[idx - 1] + x[idx]) / 2;\n } else {\n // Finally, in the simple case of an integer value\n // with an odd-length list, return the x value at the index.\n return x[idx];\n }\n}\n\nexport default quantileSorted;\n","/**\n * Rearrange items in `arr` so that all items in `[left, k]` range are the smallest.\n * The `k`-th element will have the `(k - left + 1)`-th smallest value in `[left, right]`.\n *\n * Implements Floyd-Rivest selection algorithm https://en.wikipedia.org/wiki/Floyd-Rivest_algorithm\n *\n * @param {Array} arr input array\n * @param {number} k pivot index\n * @param {number} [left] left index\n * @param {number} [right] right index\n * @returns {void} mutates input array\n * @example\n * var arr = [65, 28, 59, 33, 21, 56, 22, 95, 50, 12, 90, 53, 28, 77, 39];\n * quickselect(arr, 8);\n * // = [39, 28, 28, 33, 21, 12, 22, 50, 53, 56, 59, 65, 90, 77, 95]\n */\nfunction quickselect(arr, k, left, right) {\n left = left || 0;\n right = right || arr.length - 1;\n\n while (right > left) {\n // 600 and 0.5 are arbitrary constants chosen in the original paper to minimize execution time\n if (right - left > 600) {\n const n = right - left + 1;\n const m = k - left + 1;\n const z = Math.log(n);\n const s = 0.5 * Math.exp((2 * z) / 3);\n let sd = 0.5 * Math.sqrt((z * s * (n - s)) / n);\n if (m - n / 2 < 0) sd *= -1;\n const newLeft = Math.max(left, Math.floor(k - (m * s) / n + sd));\n const newRight = Math.min(\n right,\n Math.floor(k + ((n - m) * s) / n + sd),\n );\n quickselect(arr, k, newLeft, newRight);\n }\n\n const t = arr[k];\n let i = left;\n let j = right;\n\n swap(arr, left, k);\n if (arr[right] > t) swap(arr, left, right);\n\n while (i < j) {\n swap(arr, i, j);\n i++;\n j--;\n while (arr[i] < t) i++;\n while (arr[j] > t) j--;\n }\n\n if (arr[left] === t) swap(arr, left, j);\n else {\n j++;\n swap(arr, j, right);\n }\n\n if (j <= k) left = j + 1;\n if (k <= j) right = j - 1;\n }\n}\n\nfunction swap(arr, i, j) {\n const tmp = arr[i];\n arr[i] = arr[j];\n arr[j] = tmp;\n}\n\nexport default quickselect;\n","import quantileSorted from \"./quantile_sorted.js\";\nimport quickselect from \"./quickselect.js\";\n\n/**\n * The [quantile](https://en.wikipedia.org/wiki/Quantile):\n * this is a population quantile, since we assume to know the entire\n * dataset in this library. This is an implementation of the\n * [Quantiles of a Population](http://en.wikipedia.org/wiki/Quantile#Quantiles_of_a_population)\n * algorithm from wikipedia.\n *\n * Sample is a one-dimensional array of numbers,\n * and p is either a decimal number from 0 to 1 or an array of decimal\n * numbers from 0 to 1.\n * In terms of a k/q quantile, p = k/q - it's just dealing with fractions or dealing\n * with decimal values.\n * When p is an array, the result of the function is also an array containing the appropriate\n * quantiles in input order\n *\n * @param {Array} x sample of one or more numbers\n * @param {Array | number} p the desired quantile, as a number between 0 and 1\n * @returns {number} quantile\n * @example\n * quantile([3, 6, 7, 8, 8, 9, 10, 13, 15, 16, 20], 0.5); // => 9\n */\nfunction quantile(x, p) {\n const copy = x.slice();\n\n if (Array.isArray(p)) {\n // rearrange elements so that each element corresponding to a requested\n // quantile is on a place it would be if the array was fully sorted\n multiQuantileSelect(copy, p);\n // Initialize the result array\n const results = [];\n // For each requested quantile\n for (let i = 0; i < p.length; i++) {\n results[i] = quantileSorted(copy, p[i]);\n }\n return results;\n } else {\n const idx = quantileIndex(copy.length, p);\n quantileSelect(copy, idx, 0, copy.length - 1);\n return quantileSorted(copy, p);\n }\n}\n\nfunction quantileSelect(arr, k, left, right) {\n if (k % 1 === 0) {\n quickselect(arr, k, left, right);\n } else {\n k = Math.floor(k);\n quickselect(arr, k, left, right);\n quickselect(arr, k + 1, k + 1, right);\n }\n}\n\nfunction multiQuantileSelect(arr, p) {\n const indices = [0];\n for (let i = 0; i < p.length; i++) {\n indices.push(quantileIndex(arr.length, p[i]));\n }\n indices.push(arr.length - 1);\n indices.sort(compare);\n\n const stack = [0, indices.length - 1];\n\n while (stack.length) {\n const r = Math.ceil(stack.pop());\n const l = Math.floor(stack.pop());\n if (r - l <= 1) continue;\n\n const m = Math.floor((l + r) / 2);\n quantileSelect(\n arr,\n indices[m],\n Math.floor(indices[l]),\n Math.ceil(indices[r]),\n );\n\n stack.push(l, m, m, r);\n }\n}\n\nfunction compare(a, b) {\n return a - b;\n}\n\nfunction quantileIndex(len, p) {\n const idx = len * p;\n if (p === 1) {\n // If p is 1, directly return the last index\n return len - 1;\n } else if (p === 0) {\n // If p is 0, directly return the first index\n return 0;\n } else if (idx % 1 !== 0) {\n // If index is not integer, return the next index in array\n return Math.ceil(idx) - 1;\n } else if (len % 2 === 0) {\n // If the list has even-length, we'll return the middle of two indices\n // around quantile to indicate that we need an average value of the two\n return idx - 0.5;\n } else {\n // Finally, in the simple case of an integer index\n // with an odd-length list, return the index\n return idx;\n }\n}\n\nexport default quantile;\n","/* eslint no-bitwise: 0 */\n\n/**\n * This function returns the quantile in which one would find the given value in\n * the given array. With a sorted array, leveraging binary search, we can find\n * this information in logarithmic time.\n *\n * @param {Array} x input\n * @returns {number} value value\n * @example\n * quantileRankSorted([1, 2, 3, 4], 3); // => 0.75\n * quantileRankSorted([1, 2, 3, 3, 4], 3); // => 0.7\n * quantileRankSorted([1, 2, 3, 4], 6); // => 1\n * quantileRankSorted([1, 2, 3, 3, 5], 4); // => 0.8\n */\nfunction quantileRankSorted(x, value) {\n // Value is lesser than any value in the array\n if (value < x[0]) {\n return 0;\n }\n\n // Value is greater than any value in the array\n if (value > x[x.length - 1]) {\n return 1;\n }\n\n let l = lowerBound(x, value);\n\n // Value is not in the array\n if (x[l] !== value) {\n return l / x.length;\n }\n\n l++;\n\n const u = upperBound(x, value);\n\n // The value exists only once in the array\n if (u === l) {\n return l / x.length;\n }\n\n // Here, we are basically computing the mean of the range of indices\n // containing our searched value. But, instead, of initializing an\n // array and looping over it, there is a dedicated math formula that\n // we apply below to get the result.\n const r = u - l + 1;\n const sum = (r * (u + l)) / 2;\n const mean = sum / r;\n\n return mean / x.length;\n}\n\nfunction lowerBound(x, value) {\n let mid = 0;\n let lo = 0;\n let hi = x.length;\n\n while (lo < hi) {\n mid = (lo + hi) >>> 1;\n\n if (value <= x[mid]) {\n hi = mid;\n } else {\n lo = -~mid;\n }\n }\n\n return lo;\n}\n\nfunction upperBound(x, value) {\n let mid = 0;\n let lo = 0;\n let hi = x.length;\n\n while (lo < hi) {\n mid = (lo + hi) >>> 1;\n\n if (value >= x[mid]) {\n lo = -~mid;\n } else {\n hi = mid;\n }\n }\n\n return lo;\n}\n\nexport default quantileRankSorted;\n","import quantile from \"./quantile.js\";\n\n/**\n * The [Interquartile range](http://en.wikipedia.org/wiki/Interquartile_range) is\n * a measure of statistical dispersion, or how scattered, spread, or\n * concentrated a distribution is. It's computed as the difference between\n * the third quartile and first quartile.\n *\n * @param {Array} x sample of one or more numbers\n * @returns {number} interquartile range: the span between lower and upper quartile,\n * 0.25 and 0.75\n * @example\n * interquartileRange([0, 1, 2, 3]); // => 2\n */\nfunction interquartileRange(x) {\n // Interquartile range is the span between the upper quartile,\n // at `0.75`, and lower quartile, `0.25`\n const q1 = quantile(x, 0.75);\n const q2 = quantile(x, 0.25);\n\n if (typeof q1 === \"number\" && typeof q2 === \"number\") {\n return q1 - q2;\n }\n}\n\nexport default interquartileRange;\n","import quantile from \"./quantile.js\";\n\n/**\n * The [median](http://en.wikipedia.org/wiki/Median) is\n * the middle number of a list. This is often a good indicator of 'the middle'\n * when there are outliers that skew the `mean()` value.\n * This is a [measure of central tendency](https://en.wikipedia.org/wiki/Central_tendency):\n * a method of finding a typical or central value of a set of numbers.\n *\n * The median isn't necessarily one of the elements in the list: the value\n * can be the average of two elements if the list has an even length\n * and the two central values are different.\n *\n * @param {Array} x input\n * @returns {number} median value\n * @example\n * median([10, 2, 5, 100, 2, 1]); // => 3.5\n */\nfunction median(x) {\n return +quantile(x, 0.5);\n}\n\nexport default median;\n","import median from \"./median.js\";\n\n/**\n * The [Median Absolute Deviation](http://en.wikipedia.org/wiki/Median_absolute_deviation) is\n * a robust measure of statistical\n * dispersion. It is more resilient to outliers than the standard deviation.\n *\n * @param {Array} x input array\n * @returns {number} median absolute deviation\n * @example\n * medianAbsoluteDeviation([1, 1, 2, 2, 4, 6, 9]); // => 1\n */\nfunction medianAbsoluteDeviation(x) {\n const medianValue = median(x);\n const medianAbsoluteDeviations = [];\n\n // Make a list of absolute deviations from the median\n for (let i = 0; i < x.length; i++) {\n medianAbsoluteDeviations.push(Math.abs(x[i] - medianValue));\n }\n\n // Find the median value of that list\n return median(medianAbsoluteDeviations);\n}\n\nexport default medianAbsoluteDeviation;\n","/**\n * A [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle)\n * in-place - which means that it **will change the order of the original\n * array by reference**.\n *\n * This is an algorithm that generates a random [permutation](https://en.wikipedia.org/wiki/Permutation)\n * of a set.\n *\n * @param {Array} x sample of one or more numbers\n * @param {Function} [randomSource=Math.random] an optional entropy source that\n * returns numbers between 0 inclusive and 1 exclusive: the range [0, 1)\n * @returns {Array} x\n * @example\n * var x = [1, 2, 3, 4];\n * shuffleInPlace(x);\n * // x is shuffled to a value like [2, 1, 4, 3]\n */\nfunction shuffleInPlace(x, randomSource) {\n // a custom random number source can be provided if you want to use\n // a fixed seed or another random number generator, like\n // [random-js](https://www.npmjs.org/package/random-js)\n randomSource = randomSource || Math.random;\n\n // store the current length of the x to determine\n // when no elements remain to shuffle.\n let length = x.length;\n\n // temporary is used to hold an item when it is being\n // swapped between indices.\n let temporary;\n\n // The index to swap at each stage.\n let index;\n\n // While there are still items to shuffle\n while (length > 0) {\n // choose a random index within the subset of the array\n // that is not yet shuffled\n index = Math.floor(randomSource() * length--);\n\n // store the value that we'll move temporarily\n temporary = x[length];\n\n // swap the value at `x[length]` with `x[index]`\n x[length] = x[index];\n x[index] = temporary;\n }\n\n return x;\n}\n\nexport default shuffleInPlace;\n","import shuffleInPlace from \"./shuffle_in_place.js\";\n\n/**\n * A [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle)\n * is a fast way to create a random permutation of a finite set. This is\n * a function around `shuffle_in_place` that adds the guarantee that\n * it will not modify its input.\n *\n * @param {Array} x sample of 0 or more numbers\n * @param {Function} [randomSource=Math.random] an optional entropy source that\n * returns numbers between 0 inclusive and 1 exclusive: the range [0, 1)\n * @return {Array} shuffled version of input\n * @example\n * var shuffled = shuffle([1, 2, 3, 4]);\n * shuffled; // = [2, 3, 1, 4] or any other random permutation\n */\nfunction shuffle(x, randomSource) {\n // slice the original array so that it is not modified\n const sample = x.slice();\n\n // and then shuffle that shallow-copied array, in place\n return shuffleInPlace(sample, randomSource);\n}\n\nexport default shuffle;\n","import shuffle from \"./shuffle.js\";\n\n/**\n * Create a [simple random sample](http://en.wikipedia.org/wiki/Simple_random_sample)\n * from a given array of `n` elements.\n *\n * The sampled values will be in any order, not necessarily the order\n * they appear in the input.\n *\n * @param {Array} x input array. can contain any type\n * @param {number} n count of how many elements to take\n * @param {Function} [randomSource=Math.random] an optional entropy source that\n * returns numbers between 0 inclusive and 1 exclusive: the range [0, 1)\n * @return {Array} subset of n elements in original array\n *\n * @example\n * var values = [1, 2, 4, 5, 6, 7, 8, 9];\n * sample(values, 3); // returns 3 random values, like [2, 5, 8];\n */\nfunction sample(x, n, randomSource) {\n // shuffle the original array using a fisher-yates shuffle\n const shuffled = shuffle(x, randomSource);\n\n // and then return a subset of it - the first `n` elements.\n return shuffled.slice(0, n);\n}\n\nexport default sample;\n","/**\n * Create a new column x row matrix.\n *\n * @private\n * @param {number} columns\n * @param {number} rows\n * @return {Array>} matrix\n * @example\n * makeMatrix(10, 10);\n */\nfunction makeMatrix(columns, rows) {\n const matrix = [];\n for (let i = 0; i < columns; i++) {\n const column = [];\n for (let j = 0; j < rows; j++) {\n column.push(0);\n }\n matrix.push(column);\n }\n return matrix;\n}\n\nexport default makeMatrix;\n","/**\n * For a sorted input, counting the number of unique values\n * is possible in constant time and constant memory. This is\n * a simple implementation of the algorithm.\n *\n * Values are compared with `===`, so objects and non-primitive objects\n * are not handled in any special way.\n *\n * @param {Array<*>} x an array of any kind of value\n * @returns {number} count of unique values\n * @example\n * uniqueCountSorted([1, 2, 3]); // => 3\n * uniqueCountSorted([1, 1, 1]); // => 1\n */\nfunction uniqueCountSorted(x) {\n let uniqueValueCount = 0;\n let lastSeenValue;\n for (let i = 0; i < x.length; i++) {\n if (i === 0 || x[i] !== lastSeenValue) {\n lastSeenValue = x[i];\n uniqueValueCount++;\n }\n }\n return uniqueValueCount;\n}\n\nexport default uniqueCountSorted;\n","import makeMatrix from \"./make_matrix.js\";\nimport numericSort from \"./numeric_sort.js\";\nimport uniqueCountSorted from \"./unique_count_sorted.js\";\n\n/**\n * Generates incrementally computed values based on the sums and sums of\n * squares for the data array\n *\n * @private\n * @param {number} j\n * @param {number} i\n * @param {Array} sums\n * @param {Array} sumsOfSquares\n * @return {number}\n * @example\n * ssq(0, 1, [-1, 0, 2], [1, 1, 5]);\n */\nfunction ssq(j, i, sums, sumsOfSquares) {\n let sji; // s(j, i)\n if (j > 0) {\n const muji = (sums[i] - sums[j - 1]) / (i - j + 1); // mu(j, i)\n sji =\n sumsOfSquares[i] - sumsOfSquares[j - 1] - (i - j + 1) * muji * muji;\n } else {\n sji = sumsOfSquares[i] - (sums[i] * sums[i]) / (i + 1);\n }\n if (sji < 0) {\n return 0;\n }\n return sji;\n}\n\n/**\n * Function that recursively divides and conquers computations\n * for cluster j\n *\n * @private\n * @param {number} iMin Minimum index in cluster to be computed\n * @param {number} iMax Maximum index in cluster to be computed\n * @param {number} cluster Index of the cluster currently being computed\n * @param {Array>} matrix\n * @param {Array>} backtrackMatrix\n * @param {Array} sums\n * @param {Array} sumsOfSquares\n */\nfunction fillMatrixColumn(\n iMin,\n iMax,\n cluster,\n matrix,\n backtrackMatrix,\n sums,\n sumsOfSquares,\n) {\n if (iMin > iMax) {\n return;\n }\n\n // Start at midpoint between iMin and iMax\n const i = Math.floor((iMin + iMax) / 2);\n\n matrix[cluster][i] = matrix[cluster - 1][i - 1];\n backtrackMatrix[cluster][i] = i;\n\n let jlow = cluster; // the lower end for j\n\n if (iMin > cluster) {\n jlow = Math.max(jlow, backtrackMatrix[cluster][iMin - 1] || 0);\n }\n jlow = Math.max(jlow, backtrackMatrix[cluster - 1][i] || 0);\n\n let jhigh = i - 1; // the upper end for j\n if (iMax < matrix[0].length - 1) {\n /* c8 ignore start */\n jhigh = Math.min(jhigh, backtrackMatrix[cluster][iMax + 1] || 0);\n /* c8 ignore end */\n }\n\n let sji;\n let sjlowi;\n let ssqjlow;\n let ssqj;\n for (let j = jhigh; j >= jlow; --j) {\n sji = ssq(j, i, sums, sumsOfSquares);\n\n if (sji + matrix[cluster - 1][jlow - 1] >= matrix[cluster][i]) {\n break;\n }\n\n // Examine the lower bound of the cluster border\n sjlowi = ssq(jlow, i, sums, sumsOfSquares);\n\n ssqjlow = sjlowi + matrix[cluster - 1][jlow - 1];\n\n if (ssqjlow < matrix[cluster][i]) {\n // Shrink the lower bound\n matrix[cluster][i] = ssqjlow;\n backtrackMatrix[cluster][i] = jlow;\n }\n jlow++;\n\n ssqj = sji + matrix[cluster - 1][j - 1];\n if (ssqj < matrix[cluster][i]) {\n matrix[cluster][i] = ssqj;\n backtrackMatrix[cluster][i] = j;\n }\n }\n\n fillMatrixColumn(\n iMin,\n i - 1,\n cluster,\n matrix,\n backtrackMatrix,\n sums,\n sumsOfSquares,\n );\n fillMatrixColumn(\n i + 1,\n iMax,\n cluster,\n matrix,\n backtrackMatrix,\n sums,\n sumsOfSquares,\n );\n}\n\n/**\n * Initializes the main matrices used in Ckmeans and kicks\n * off the divide and conquer cluster computation strategy\n *\n * @private\n * @param {Array} data sorted array of values\n * @param {Array>} matrix\n * @param {Array>} backtrackMatrix\n */\nfunction fillMatrices(data, matrix, backtrackMatrix) {\n const nValues = matrix[0].length;\n\n // Shift values by the median to improve numeric stability\n const shift = data[Math.floor(nValues / 2)];\n\n // Cumulative sum and cumulative sum of squares for all values in data array\n const sums = [];\n const sumsOfSquares = [];\n\n // Initialize first column in matrix & backtrackMatrix\n for (let i = 0, shiftedValue; i < nValues; ++i) {\n shiftedValue = data[i] - shift;\n if (i === 0) {\n sums.push(shiftedValue);\n sumsOfSquares.push(shiftedValue * shiftedValue);\n } else {\n sums.push(sums[i - 1] + shiftedValue);\n sumsOfSquares.push(\n sumsOfSquares[i - 1] + shiftedValue * shiftedValue,\n );\n }\n\n // Initialize for cluster = 0\n matrix[0][i] = ssq(0, i, sums, sumsOfSquares);\n backtrackMatrix[0][i] = 0;\n }\n\n // Initialize the rest of the columns\n let iMin;\n for (let cluster = 1; cluster < matrix.length; ++cluster) {\n if (cluster < matrix.length - 1) {\n iMin = cluster;\n } else {\n // No need to compute matrix[K-1][0] ... matrix[K-1][N-2]\n iMin = nValues - 1;\n }\n\n fillMatrixColumn(\n iMin,\n nValues - 1,\n cluster,\n matrix,\n backtrackMatrix,\n sums,\n sumsOfSquares,\n );\n }\n}\n\n/**\n * Ckmeans clustering is an improvement on heuristic-based clustering\n * approaches like Jenks. The algorithm was developed in\n * [Haizhou Wang and Mingzhou Song](http://journal.r-project.org/archive/2011-2/RJournal_2011-2_Wang+Song.pdf)\n * as a [dynamic programming](https://en.wikipedia.org/wiki/Dynamic_programming) approach\n * to the problem of clustering numeric data into groups with the least\n * within-group sum-of-squared-deviations.\n *\n * Minimizing the difference within groups - what Wang & Song refer to as\n * `withinss`, or within sum-of-squares, means that groups are optimally\n * homogenous within and the data is split into representative groups.\n * This is very useful for visualization, where you may want to represent\n * a continuous variable in discrete color or style groups. This function\n * can provide groups that emphasize differences between data.\n *\n * Being a dynamic approach, this algorithm is based on two matrices that\n * store incrementally-computed values for squared deviations and backtracking\n * indexes.\n *\n * This implementation is based on Ckmeans 3.4.6, which introduced a new divide\n * and conquer approach that improved runtime from O(kn^2) to O(kn log(n)).\n *\n * Unlike the [original implementation](https://cran.r-project.org/web/packages/Ckmeans.1d.dp/index.html),\n * this implementation does not include any code to automatically determine\n * the optimal number of clusters: this information needs to be explicitly\n * provided.\n *\n * ### References\n * _Ckmeans.1d.dp: Optimal k-means Clustering in One Dimension by Dynamic\n * Programming_ Haizhou Wang and Mingzhou Song ISSN 2073-4859\n *\n * from The R Journal Vol. 3/2, December 2011\n * @param {Array} x input data, as an array of number values\n * @param {number} nClusters number of desired classes. This cannot be\n * greater than the number of values in the data array.\n * @returns {Array>} clustered input\n * @throws {Error} if the number of requested clusters is higher than the size of the data\n * @example\n * ckmeans([-1, 2, -1, 2, 4, 5, 6, -1, 2, -1], 3);\n * // The input, clustered into groups of similar numbers.\n * //= [[-1, -1, -1, -1], [2, 2, 2], [4, 5, 6]]);\n */\nfunction ckmeans(x, nClusters) {\n if (nClusters > x.length) {\n throw new Error(\n \"cannot generate more classes than there are data values\",\n );\n }\n\n const sorted = numericSort(x);\n // we'll use this as the maximum number of clusters\n const uniqueCount = uniqueCountSorted(sorted);\n\n // if all of the input values are identical, there's one cluster\n // with all of the input in it.\n if (uniqueCount === 1) {\n return [sorted];\n }\n\n // named 'S' originally\n const matrix = makeMatrix(nClusters, sorted.length);\n // named 'J' originally\n const backtrackMatrix = makeMatrix(nClusters, sorted.length);\n\n // This is a dynamic programming way to solve the problem of minimizing\n // within-cluster sum of squares. It's similar to linear regression\n // in this way, and this calculation incrementally computes the\n // sum of squares that are later read.\n fillMatrices(sorted, matrix, backtrackMatrix);\n\n // The real work of Ckmeans clustering happens in the matrix generation:\n // the generated matrices encode all possible clustering combinations, and\n // once they're generated we can solve for the best clustering groups\n // very quickly.\n const clusters = [];\n let clusterRight = backtrackMatrix[0].length - 1;\n\n // Backtrack the clusters from the dynamic programming matrix. This\n // starts at the bottom-right corner of the matrix (if the top-left is 0, 0),\n // and moves the cluster target with the loop.\n for (let cluster = backtrackMatrix.length - 1; cluster >= 0; cluster--) {\n const clusterLeft = backtrackMatrix[cluster][clusterRight];\n\n // fill the cluster from the sorted input by taking a slice of the\n // array. the backtrack matrix makes this easy - it stores the\n // indexes where the cluster should start and end.\n clusters[cluster] = sorted.slice(clusterLeft, clusterRight + 1);\n\n if (cluster > 0) {\n clusterRight = clusterLeft - 1;\n }\n }\n\n return clusters;\n}\n\nexport default ckmeans;\n","import mean from \"./mean.js\";\n\n/**\n * [Sample covariance](https://en.wikipedia.org/wiki/Sample_mean_and_covariance) of two datasets:\n * how much do the two datasets move together?\n * x and y are two datasets, represented as arrays of numbers.\n *\n * @param {Array} x a sample of two or more data points\n * @param {Array} y a sample of two or more data points\n * @throws {Error} if x and y do not have equal lengths\n * @throws {Error} if x or y have length of one or less\n * @returns {number} sample covariance\n * @example\n * sampleCovariance([1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1]); // => -3.5\n */\nfunction sampleCovariance(x, y) {\n // The two datasets must have the same length which must be more than 1\n if (x.length !== y.length) {\n throw new Error(\"sampleCovariance requires samples with equal lengths\");\n }\n\n if (x.length < 2) {\n throw new Error(\n \"sampleCovariance requires at least two data points in each sample\",\n );\n }\n\n // determine the mean of each dataset so that we can judge each\n // value of the dataset fairly as the difference from the mean. this\n // way, if one dataset is [1, 2, 3] and [2, 3, 4], their covariance\n // does not suffer because of the difference in absolute values\n const xmean = mean(x);\n const ymean = mean(y);\n let sum = 0;\n\n // for each pair of values, the covariance increases when their\n // difference from the mean is associated - if both are well above\n // or if both are well below\n // the mean, the covariance increases significantly.\n for (let i = 0; i < x.length; i++) {\n sum += (x[i] - xmean) * (y[i] - ymean);\n }\n\n // this is Bessels' Correction: an adjustment made to sample statistics\n // that allows for the reduced degree of freedom entailed in calculating\n // values from samples rather than complete populations.\n const besselsCorrection = x.length - 1;\n\n // the covariance is weighted by the length of the datasets.\n return sum / besselsCorrection;\n}\n\nexport default sampleCovariance;\n","import sumNthPowerDeviations from \"./sum_nth_power_deviations.js\";\n\n/**\n * The [sample variance](https://en.wikipedia.org/wiki/Variance#Sample_variance)\n * is the sum of squared deviations from the mean. The sample variance\n * is distinguished from the variance by the usage of [Bessel's Correction](https://en.wikipedia.org/wiki/Bessel's_correction):\n * instead of dividing the sum of squared deviations by the length of the input,\n * it is divided by the length minus one. This corrects the bias in estimating\n * a value from a set that you don't know if full.\n *\n * References:\n * * [Wolfram MathWorld on Sample Variance](http://mathworld.wolfram.com/SampleVariance.html)\n *\n * @param {Array} x a sample of two or more data points\n * @throws {Error} if the length of x is less than 2\n * @return {number} sample variance\n * @example\n * sampleVariance([1, 2, 3, 4, 5]); // => 2.5\n */\nfunction sampleVariance(x) {\n if (x.length < 2) {\n throw new Error(\"sampleVariance requires at least two data points\");\n }\n\n const sumSquaredDeviationsValue = sumNthPowerDeviations(x, 2);\n\n // this is Bessels' Correction: an adjustment made to sample statistics\n // that allows for the reduced degree of freedom entailed in calculating\n // values from samples rather than complete populations.\n const besselsCorrection = x.length - 1;\n\n // Find the mean value of that list\n return sumSquaredDeviationsValue / besselsCorrection;\n}\n\nexport default sampleVariance;\n","import sampleVariance from \"./sample_variance.js\";\n\n/**\n * The [sample standard deviation](http://en.wikipedia.org/wiki/Standard_deviation#Sample_standard_deviation)\n * is the square root of the sample variance.\n *\n * @param {Array} x input array\n * @returns {number} sample standard deviation\n * @example\n * sampleStandardDeviation([2, 4, 4, 4, 5, 5, 7, 9]).toFixed(2);\n * // => '2.14'\n */\nfunction sampleStandardDeviation(x) {\n const sampleVarianceX = sampleVariance(x);\n return Math.sqrt(sampleVarianceX);\n}\n\nexport default sampleStandardDeviation;\n","import sampleCovariance from \"./sample_covariance.js\";\nimport sampleStandardDeviation from \"./sample_standard_deviation.js\";\n\n/**\n * The [correlation](http://en.wikipedia.org/wiki/Correlation_and_dependence) is\n * a measure of how correlated two datasets are, between -1 and 1\n *\n * @param {Array} x first input\n * @param {Array} y second input\n * @returns {number} sample correlation\n * @example\n * sampleCorrelation([1, 2, 3, 4, 5, 6], [2, 2, 3, 4, 5, 60]).toFixed(2);\n * // => '0.69'\n */\nfunction sampleCorrelation(x, y) {\n const cov = sampleCovariance(x, y);\n const xstd = sampleStandardDeviation(x);\n const ystd = sampleStandardDeviation(y);\n\n return cov / xstd / ystd;\n}\n\nexport default sampleCorrelation;\n","/**\n * When combining two lists of values for which one already knows the means,\n * one does not have to necessary recompute the mean of the combined lists in\n * linear time. They can instead use this function to compute the combined\n * mean by providing the mean & number of values of the first list and the mean\n * & number of values of the second list.\n *\n * @since 3.0.0\n * @param {number} mean1 mean of the first list\n * @param {number} n1 number of items in the first list\n * @param {number} mean2 mean of the second list\n * @param {number} n2 number of items in the second list\n * @returns {number} the combined mean\n *\n * @example\n * combineMeans(5, 3, 4, 3); // => 4.5\n */\nfunction combineMeans(mean1, n1, mean2, n2) {\n return (mean1 * n1 + mean2 * n2) / (n1 + n2);\n}\n\nexport default combineMeans;\n","import sumSimple from \"./sum_simple.js\";\n\n/**\n * The mean, _also known as average_,\n * is the sum of all values over the number of values.\n * This is a [measure of central tendency](https://en.wikipedia.org/wiki/Central_tendency):\n * a method of finding a typical or central value of a set of numbers.\n *\n * The simple mean uses the successive addition method internally\n * to calculate it's result. Errors in floating-point addition are\n * not accounted for, so if precision is required, the standard {@link mean}\n * method should be used instead.\n *\n * This runs in `O(n)`, linear time, with respect to the length of the array.\n *\n *\n * @param {Array} x sample of one or more data points\n * @throws {Error} if the length of x is less than one\n * @returns {number} mean\n * @example\n * mean([0, 10]); // => 5\n */\nfunction meanSimple(x) {\n if (x.length === 0) {\n throw new Error(\"meanSimple requires at least one data point\");\n }\n\n return sumSimple(x) / x.length;\n}\n\nexport default meanSimple;\n","/**\n * The Root Mean Square (RMS) is\n * a mean function used as a measure of the magnitude of a set\n * of numbers, regardless of their sign.\n * This is the square root of the mean of the squares of the\n * input numbers.\n * This runs in `O(n)`, linear time, with respect to the length of the array.\n *\n * @param {Array} x a sample of one or more data points\n * @returns {number} root mean square\n * @throws {Error} if x is empty\n * @example\n * rootMeanSquare([-1, 1, -1, 1]); // => 1\n */\nfunction rootMeanSquare(x) {\n if (x.length === 0) {\n throw new Error(\"rootMeanSquare requires at least one data point\");\n }\n\n let sumOfSquares = 0;\n for (let i = 0; i < x.length; i++) {\n sumOfSquares += Math.pow(x[i], 2);\n }\n\n return Math.sqrt(sumOfSquares / x.length);\n}\n\nexport default rootMeanSquare;\n","/**\n * [Bayesian Classifier](http://en.wikipedia.org/wiki/Naive_Bayes_classifier)\n *\n * This is a naïve bayesian classifier that takes\n * singly-nested objects.\n *\n * @class\n * @example\n * var bayes = new BayesianClassifier();\n * bayes.train({\n * species: 'Cat'\n * }, 'animal');\n * var result = bayes.score({\n * species: 'Cat'\n * })\n * // result\n * // {\n * // animal: 1\n * // }\n */\nclass BayesianClassifier {\n /*:: totalCount: number */\n /*:: data: Object */\n constructor() {\n // The number of items that are currently\n // classified in the model\n this.totalCount = 0;\n // Every item classified in the model\n this.data = {};\n }\n\n /**\n * Train the classifier with a new item, which has a single\n * dimension of Javascript literal keys and values.\n *\n * @param {Object} item an object with singly-deep properties\n * @param {string} category the category this item belongs to\n * @return {undefined} adds the item to the classifier\n */\n train(item, category) {\n // If the data object doesn't have any values\n // for this category, create a new object for it.\n if (!this.data[category]) {\n this.data[category] = {};\n }\n\n // Iterate through each key in the item.\n for (const k in item) {\n const v = item[k];\n // Initialize the nested object `data[category][k][item[k]]`\n // with an object of keys that equal 0.\n if (this.data[category][k] === undefined) {\n this.data[category][k] = {};\n }\n if (this.data[category][k][v] === undefined) {\n this.data[category][k][v] = 0;\n }\n\n // And increment the key for this key/value combination.\n this.data[category][k][v]++;\n }\n\n // Increment the number of items classified\n this.totalCount++;\n }\n\n /**\n * Generate a score of how well this item matches all\n * possible categories based on its attributes\n *\n * @param {Object} item an item in the same format as with train\n * @returns {Object} of probabilities that this item belongs to a\n * given category.\n */\n score(item) {\n // Initialize an empty array of odds per category.\n const odds = {};\n let category;\n // Iterate through each key in the item,\n // then iterate through each category that has been used\n // in previous calls to `.train()`\n for (const k in item) {\n const v = item[k];\n for (category in this.data) {\n // Create an empty object for storing key - value combinations\n // for this category.\n odds[category] = {};\n\n // If this item doesn't even have a property, it counts for nothing,\n // but if it does have the property that we're looking for from\n // the item to categorize, it counts based on how popular it is\n // versus the whole population.\n if (this.data[category][k]) {\n odds[category][k + \"_\" + v] =\n (this.data[category][k][v] || 0) / this.totalCount;\n } else {\n odds[category][k + \"_\" + v] = 0;\n }\n }\n }\n\n // Set up a new object that will contain sums of these odds by category\n const oddsSums = {};\n\n for (category in odds) {\n // Tally all of the odds for each category-combination pair -\n // the non-existence of a category does not add anything to the\n // score.\n oddsSums[category] = 0;\n for (const combination in odds[category]) {\n oddsSums[category] += odds[category][combination];\n }\n }\n\n return oddsSums;\n }\n}\n\nexport default BayesianClassifier;\n","/**\n * This is a single-layer [Perceptron Classifier](http://en.wikipedia.org/wiki/Perceptron) that takes\n * arrays of numbers and predicts whether they should be classified\n * as either 0 or 1 (negative or positive examples).\n * @class\n * @example\n * // Create the model\n * var p = new PerceptronModel();\n * // Train the model with input with a diagonal boundary.\n * for (var i = 0; i < 5; i++) {\n * p.train([1, 1], 1);\n * p.train([0, 1], 0);\n * p.train([1, 0], 0);\n * p.train([0, 0], 0);\n * }\n * p.predict([0, 0]); // 0\n * p.predict([0, 1]); // 0\n * p.predict([1, 0]); // 0\n * p.predict([1, 1]); // 1\n */\nclass PerceptronModel {\n /*:: bias: number */\n /*:: weights: Array */\n constructor() {\n // The weights, or coefficients of the model;\n // weights are only populated when training with data.\n this.weights = [];\n // The bias term, or intercept; it is also a weight but\n // it's stored separately for convenience as it is always\n // multiplied by one.\n this.bias = 0;\n }\n /**\n * **Predict**: Use an array of features with the weight array and bias\n * to predict whether an example is labeled 0 or 1.\n *\n * @param {Array} features an array of features as numbers\n * @returns {number} 1 if the score is over 0, otherwise 0\n */\n predict(features) {\n // Only predict if previously trained\n // on the same size feature array(s).\n if (features.length !== this.weights.length) {\n return null;\n }\n\n // Calculate the sum of features times weights,\n // with the bias added (implicitly times one).\n let score = 0;\n for (let i = 0; i < this.weights.length; i++) {\n score += this.weights[i] * features[i];\n }\n score += this.bias;\n\n // Classify as 1 if the score is over 0, otherwise 0.\n if (score > 0) {\n return 1;\n } else {\n return 0;\n }\n }\n\n /**\n * **Train** the classifier with a new example, which is\n * a numeric array of features and a 0 or 1 label.\n *\n * @param {Array} features an array of features as numbers\n * @param {number} label either 0 or 1\n * @returns {PerceptronModel} this\n */\n train(features, label) {\n // Require that only labels of 0 or 1 are considered.\n if (label !== 0 && label !== 1) {\n return null;\n }\n // The length of the feature array determines\n // the length of the weight array.\n // The perceptron will continue learning as long as\n // it keeps seeing feature arrays of the same length.\n // When it sees a new data shape, it initializes.\n if (features.length !== this.weights.length) {\n this.weights = features;\n this.bias = 1;\n }\n // Make a prediction based on current weights.\n const prediction = this.predict(features);\n // Update the weights if the prediction is wrong.\n if (typeof prediction === \"number\" && prediction !== label) {\n const gradient = label - prediction;\n for (let i = 0; i < this.weights.length; i++) {\n this.weights[i] += gradient * features[i];\n }\n this.bias += gradient;\n }\n return this;\n }\n}\n\nexport default PerceptronModel;\n","/**\n * We use `ε`, epsilon, as a stopping criterion when we want to iterate\n * until we're \"close enough\". Epsilon is a very small number: for\n * simple statistics, that number is **0.0001**\n *\n * This is used in calculations like the binomialDistribution, in which\n * the process of finding a value is [iterative](https://en.wikipedia.org/wiki/Iterative_method):\n * it progresses until it is close enough.\n *\n * Below is an example of using epsilon in [gradient descent](https://en.wikipedia.org/wiki/Gradient_descent),\n * where we're trying to find a local minimum of a function's derivative,\n * given by the `fDerivative` method.\n *\n * @example\n * // From calculation, we expect that the local minimum occurs at x=9/4\n * var x_old = 0;\n * // The algorithm starts at x=6\n * var x_new = 6;\n * var stepSize = 0.01;\n *\n * function fDerivative(x) {\n * return 4 * Math.pow(x, 3) - 9 * Math.pow(x, 2);\n * }\n *\n * // The loop runs until the difference between the previous\n * // value and the current value is smaller than epsilon - a rough\n * // meaure of 'close enough'\n * while (Math.abs(x_new - x_old) > ss.epsilon) {\n * x_old = x_new;\n * x_new = x_old - stepSize * fDerivative(x_old);\n * }\n *\n * console.log('Local minimum occurs at', x_new);\n */\nconst epsilon = 0.0001;\n\nexport default epsilon;\n","/**\n * A [Factorial](https://en.wikipedia.org/wiki/Factorial), usually written n!, is the product of all positive\n * integers less than or equal to n. Often factorial is implemented\n * recursively, but this iterative approach is significantly faster\n * and simpler.\n *\n * @param {number} n input, must be an integer number 1 or greater\n * @returns {number} factorial: n!\n * @throws {Error} if n is less than 0 or not an integer\n * @example\n * factorial(5); // => 120\n */\nfunction factorial(n) {\n // factorial is mathematically undefined for negative numbers\n if (n < 0) {\n throw new Error(\"factorial requires a non-negative value\");\n }\n\n if (Math.floor(n) !== n) {\n throw new Error(\"factorial requires an integer input\");\n }\n\n // typically you'll expand the factorial function going down, like\n // 5! = 5 * 4 * 3 * 2 * 1. This is going in the opposite direction,\n // counting from 2 up to the number in question, and since anything\n // multiplied by 1 is itself, the loop only needs to start at 2.\n let accumulator = 1;\n for (let i = 2; i <= n; i++) {\n // for each number up to and including the number `n`, multiply\n // the accumulator my that number.\n accumulator *= i;\n }\n return accumulator;\n}\n\nexport default factorial;\n","// Define series coefficients\nconst COEFFICIENTS = [\n 0.99999999999999709182, 57.156235665862923517, -59.597960355475491248,\n 14.136097974741747174, -0.49191381609762019978, 0.33994649984811888699e-4,\n 0.46523628927048575665e-4, -0.98374475304879564677e-4,\n 0.15808870322491248884e-3, -0.21026444172410488319e-3,\n 0.2174396181152126432e-3, -0.16431810653676389022e-3,\n 0.84418223983852743293e-4, -0.2619083840158140867e-4,\n 0.36899182659531622704e-5,\n];\n\nconst g = 607 / 128;\nconst LOGSQRT2PI = Math.log(Math.sqrt(2 * Math.PI));\n\n/**\n * Compute the logarithm of the [gamma function](https://en.wikipedia.org/wiki/Gamma_function) of a value using Lanczos' approximation.\n * This function takes as input any real-value n greater than 0.\n * This function is useful for values of n too large for the normal gamma function (n > 165).\n * The code is based on Lanczo's Gamma approximation, defined [here](http://my.fit.edu/~gabdo/gamma.txt).\n *\n * @param {number} n Any real number greater than zero.\n * @returns {number} The logarithm of gamma of the input value.\n *\n * @example\n * gammaln(500); // 2605.1158503617335\n * gammaln(2.4); // 0.21685932244884043\n */\nfunction gammaln(n) {\n // Return infinity if value not in domain\n if (n <= 0) {\n return Number.POSITIVE_INFINITY;\n }\n\n // Decrement n, because approximation is defined for n - 1\n n--;\n\n // Create series approximation\n let a = COEFFICIENTS[0];\n\n for (let i = 1; i < 15; i++) {\n a += COEFFICIENTS[i] / (n + i);\n }\n\n const tmp = g + 0.5 + n;\n\n // Return natural logarithm of gamma(n)\n return LOGSQRT2PI + Math.log(a) - tmp + (n + 0.5) * Math.log(tmp);\n}\n\nexport default gammaln;\n","/**\n * **Percentage Points of the χ2 (Chi-Squared) Distribution**\n *\n * The [χ2 (Chi-Squared) Distribution](http://en.wikipedia.org/wiki/Chi-squared_distribution) is used in the common\n * chi-squared tests for goodness of fit of an observed distribution to a theoretical one, the independence of two\n * criteria of classification of qualitative data, and in confidence interval estimation for a population standard\n * deviation of a normal distribution from a sample standard deviation.\n *\n * Values from Appendix 1, Table III of William W. Hines & Douglas C. Montgomery, \"Probability and Statistics in\n * Engineering and Management Science\", Wiley (1980).\n */\nconst chiSquaredDistributionTable = {\n 1: {\n 0.995: 0,\n 0.99: 0,\n 0.975: 0,\n 0.95: 0,\n 0.9: 0.02,\n 0.5: 0.45,\n 0.1: 2.71,\n 0.05: 3.84,\n 0.025: 5.02,\n 0.01: 6.63,\n 0.005: 7.88,\n },\n 2: {\n 0.995: 0.01,\n 0.99: 0.02,\n 0.975: 0.05,\n 0.95: 0.1,\n 0.9: 0.21,\n 0.5: 1.39,\n 0.1: 4.61,\n 0.05: 5.99,\n 0.025: 7.38,\n 0.01: 9.21,\n 0.005: 10.6,\n },\n 3: {\n 0.995: 0.07,\n 0.99: 0.11,\n 0.975: 0.22,\n 0.95: 0.35,\n 0.9: 0.58,\n 0.5: 2.37,\n 0.1: 6.25,\n 0.05: 7.81,\n 0.025: 9.35,\n 0.01: 11.34,\n 0.005: 12.84,\n },\n 4: {\n 0.995: 0.21,\n 0.99: 0.3,\n 0.975: 0.48,\n 0.95: 0.71,\n 0.9: 1.06,\n 0.5: 3.36,\n 0.1: 7.78,\n 0.05: 9.49,\n 0.025: 11.14,\n 0.01: 13.28,\n 0.005: 14.86,\n },\n 5: {\n 0.995: 0.41,\n 0.99: 0.55,\n 0.975: 0.83,\n 0.95: 1.15,\n 0.9: 1.61,\n 0.5: 4.35,\n 0.1: 9.24,\n 0.05: 11.07,\n 0.025: 12.83,\n 0.01: 15.09,\n 0.005: 16.75,\n },\n 6: {\n 0.995: 0.68,\n 0.99: 0.87,\n 0.975: 1.24,\n 0.95: 1.64,\n 0.9: 2.2,\n 0.5: 5.35,\n 0.1: 10.65,\n 0.05: 12.59,\n 0.025: 14.45,\n 0.01: 16.81,\n 0.005: 18.55,\n },\n 7: {\n 0.995: 0.99,\n 0.99: 1.25,\n 0.975: 1.69,\n 0.95: 2.17,\n 0.9: 2.83,\n 0.5: 6.35,\n 0.1: 12.02,\n 0.05: 14.07,\n 0.025: 16.01,\n 0.01: 18.48,\n 0.005: 20.28,\n },\n 8: {\n 0.995: 1.34,\n 0.99: 1.65,\n 0.975: 2.18,\n 0.95: 2.73,\n 0.9: 3.49,\n 0.5: 7.34,\n 0.1: 13.36,\n 0.05: 15.51,\n 0.025: 17.53,\n 0.01: 20.09,\n 0.005: 21.96,\n },\n 9: {\n 0.995: 1.73,\n 0.99: 2.09,\n 0.975: 2.7,\n 0.95: 3.33,\n 0.9: 4.17,\n 0.5: 8.34,\n 0.1: 14.68,\n 0.05: 16.92,\n 0.025: 19.02,\n 0.01: 21.67,\n 0.005: 23.59,\n },\n 10: {\n 0.995: 2.16,\n 0.99: 2.56,\n 0.975: 3.25,\n 0.95: 3.94,\n 0.9: 4.87,\n 0.5: 9.34,\n 0.1: 15.99,\n 0.05: 18.31,\n 0.025: 20.48,\n 0.01: 23.21,\n 0.005: 25.19,\n },\n 11: {\n 0.995: 2.6,\n 0.99: 3.05,\n 0.975: 3.82,\n 0.95: 4.57,\n 0.9: 5.58,\n 0.5: 10.34,\n 0.1: 17.28,\n 0.05: 19.68,\n 0.025: 21.92,\n 0.01: 24.72,\n 0.005: 26.76,\n },\n 12: {\n 0.995: 3.07,\n 0.99: 3.57,\n 0.975: 4.4,\n 0.95: 5.23,\n 0.9: 6.3,\n 0.5: 11.34,\n 0.1: 18.55,\n 0.05: 21.03,\n 0.025: 23.34,\n 0.01: 26.22,\n 0.005: 28.3,\n },\n 13: {\n 0.995: 3.57,\n 0.99: 4.11,\n 0.975: 5.01,\n 0.95: 5.89,\n 0.9: 7.04,\n 0.5: 12.34,\n 0.1: 19.81,\n 0.05: 22.36,\n 0.025: 24.74,\n 0.01: 27.69,\n 0.005: 29.82,\n },\n 14: {\n 0.995: 4.07,\n 0.99: 4.66,\n 0.975: 5.63,\n 0.95: 6.57,\n 0.9: 7.79,\n 0.5: 13.34,\n 0.1: 21.06,\n 0.05: 23.68,\n 0.025: 26.12,\n 0.01: 29.14,\n 0.005: 31.32,\n },\n 15: {\n 0.995: 4.6,\n 0.99: 5.23,\n 0.975: 6.27,\n 0.95: 7.26,\n 0.9: 8.55,\n 0.5: 14.34,\n 0.1: 22.31,\n 0.05: 25,\n 0.025: 27.49,\n 0.01: 30.58,\n 0.005: 32.8,\n },\n 16: {\n 0.995: 5.14,\n 0.99: 5.81,\n 0.975: 6.91,\n 0.95: 7.96,\n 0.9: 9.31,\n 0.5: 15.34,\n 0.1: 23.54,\n 0.05: 26.3,\n 0.025: 28.85,\n 0.01: 32,\n 0.005: 34.27,\n },\n 17: {\n 0.995: 5.7,\n 0.99: 6.41,\n 0.975: 7.56,\n 0.95: 8.67,\n 0.9: 10.09,\n 0.5: 16.34,\n 0.1: 24.77,\n 0.05: 27.59,\n 0.025: 30.19,\n 0.01: 33.41,\n 0.005: 35.72,\n },\n 18: {\n 0.995: 6.26,\n 0.99: 7.01,\n 0.975: 8.23,\n 0.95: 9.39,\n 0.9: 10.87,\n 0.5: 17.34,\n 0.1: 25.99,\n 0.05: 28.87,\n 0.025: 31.53,\n 0.01: 34.81,\n 0.005: 37.16,\n },\n 19: {\n 0.995: 6.84,\n 0.99: 7.63,\n 0.975: 8.91,\n 0.95: 10.12,\n 0.9: 11.65,\n 0.5: 18.34,\n 0.1: 27.2,\n 0.05: 30.14,\n 0.025: 32.85,\n 0.01: 36.19,\n 0.005: 38.58,\n },\n 20: {\n 0.995: 7.43,\n 0.99: 8.26,\n 0.975: 9.59,\n 0.95: 10.85,\n 0.9: 12.44,\n 0.5: 19.34,\n 0.1: 28.41,\n 0.05: 31.41,\n 0.025: 34.17,\n 0.01: 37.57,\n 0.005: 40,\n },\n 21: {\n 0.995: 8.03,\n 0.99: 8.9,\n 0.975: 10.28,\n 0.95: 11.59,\n 0.9: 13.24,\n 0.5: 20.34,\n 0.1: 29.62,\n 0.05: 32.67,\n 0.025: 35.48,\n 0.01: 38.93,\n 0.005: 41.4,\n },\n 22: {\n 0.995: 8.64,\n 0.99: 9.54,\n 0.975: 10.98,\n 0.95: 12.34,\n 0.9: 14.04,\n 0.5: 21.34,\n 0.1: 30.81,\n 0.05: 33.92,\n 0.025: 36.78,\n 0.01: 40.29,\n 0.005: 42.8,\n },\n 23: {\n 0.995: 9.26,\n 0.99: 10.2,\n 0.975: 11.69,\n 0.95: 13.09,\n 0.9: 14.85,\n 0.5: 22.34,\n 0.1: 32.01,\n 0.05: 35.17,\n 0.025: 38.08,\n 0.01: 41.64,\n 0.005: 44.18,\n },\n 24: {\n 0.995: 9.89,\n 0.99: 10.86,\n 0.975: 12.4,\n 0.95: 13.85,\n 0.9: 15.66,\n 0.5: 23.34,\n 0.1: 33.2,\n 0.05: 36.42,\n 0.025: 39.36,\n 0.01: 42.98,\n 0.005: 45.56,\n },\n 25: {\n 0.995: 10.52,\n 0.99: 11.52,\n 0.975: 13.12,\n 0.95: 14.61,\n 0.9: 16.47,\n 0.5: 24.34,\n 0.1: 34.28,\n 0.05: 37.65,\n 0.025: 40.65,\n 0.01: 44.31,\n 0.005: 46.93,\n },\n 26: {\n 0.995: 11.16,\n 0.99: 12.2,\n 0.975: 13.84,\n 0.95: 15.38,\n 0.9: 17.29,\n 0.5: 25.34,\n 0.1: 35.56,\n 0.05: 38.89,\n 0.025: 41.92,\n 0.01: 45.64,\n 0.005: 48.29,\n },\n 27: {\n 0.995: 11.81,\n 0.99: 12.88,\n 0.975: 14.57,\n 0.95: 16.15,\n 0.9: 18.11,\n 0.5: 26.34,\n 0.1: 36.74,\n 0.05: 40.11,\n 0.025: 43.19,\n 0.01: 46.96,\n 0.005: 49.65,\n },\n 28: {\n 0.995: 12.46,\n 0.99: 13.57,\n 0.975: 15.31,\n 0.95: 16.93,\n 0.9: 18.94,\n 0.5: 27.34,\n 0.1: 37.92,\n 0.05: 41.34,\n 0.025: 44.46,\n 0.01: 48.28,\n 0.005: 50.99,\n },\n 29: {\n 0.995: 13.12,\n 0.99: 14.26,\n 0.975: 16.05,\n 0.95: 17.71,\n 0.9: 19.77,\n 0.5: 28.34,\n 0.1: 39.09,\n 0.05: 42.56,\n 0.025: 45.72,\n 0.01: 49.59,\n 0.005: 52.34,\n },\n 30: {\n 0.995: 13.79,\n 0.99: 14.95,\n 0.975: 16.79,\n 0.95: 18.49,\n 0.9: 20.6,\n 0.5: 29.34,\n 0.1: 40.26,\n 0.05: 43.77,\n 0.025: 46.98,\n 0.01: 50.89,\n 0.005: 53.67,\n },\n 40: {\n 0.995: 20.71,\n 0.99: 22.16,\n 0.975: 24.43,\n 0.95: 26.51,\n 0.9: 29.05,\n 0.5: 39.34,\n 0.1: 51.81,\n 0.05: 55.76,\n 0.025: 59.34,\n 0.01: 63.69,\n 0.005: 66.77,\n },\n 50: {\n 0.995: 27.99,\n 0.99: 29.71,\n 0.975: 32.36,\n 0.95: 34.76,\n 0.9: 37.69,\n 0.5: 49.33,\n 0.1: 63.17,\n 0.05: 67.5,\n 0.025: 71.42,\n 0.01: 76.15,\n 0.005: 79.49,\n },\n 60: {\n 0.995: 35.53,\n 0.99: 37.48,\n 0.975: 40.48,\n 0.95: 43.19,\n 0.9: 46.46,\n 0.5: 59.33,\n 0.1: 74.4,\n 0.05: 79.08,\n 0.025: 83.3,\n 0.01: 88.38,\n 0.005: 91.95,\n },\n 70: {\n 0.995: 43.28,\n 0.99: 45.44,\n 0.975: 48.76,\n 0.95: 51.74,\n 0.9: 55.33,\n 0.5: 69.33,\n 0.1: 85.53,\n 0.05: 90.53,\n 0.025: 95.02,\n 0.01: 100.42,\n 0.005: 104.22,\n },\n 80: {\n 0.995: 51.17,\n 0.99: 53.54,\n 0.975: 57.15,\n 0.95: 60.39,\n 0.9: 64.28,\n 0.5: 79.33,\n 0.1: 96.58,\n 0.05: 101.88,\n 0.025: 106.63,\n 0.01: 112.33,\n 0.005: 116.32,\n },\n 90: {\n 0.995: 59.2,\n 0.99: 61.75,\n 0.975: 65.65,\n 0.95: 69.13,\n 0.9: 73.29,\n 0.5: 89.33,\n 0.1: 107.57,\n 0.05: 113.14,\n 0.025: 118.14,\n 0.01: 124.12,\n 0.005: 128.3,\n },\n 100: {\n 0.995: 67.33,\n 0.99: 70.06,\n 0.975: 74.22,\n 0.95: 77.93,\n 0.9: 82.36,\n 0.5: 99.33,\n 0.1: 118.5,\n 0.05: 124.34,\n 0.025: 129.56,\n 0.01: 135.81,\n 0.005: 140.17,\n },\n};\n\nexport default chiSquaredDistributionTable;\n","import interquartileRange from \"./interquartile_range.js\";\nimport stddev from \"./sample_standard_deviation.js\";\n\nconst SQRT_2PI = Math.sqrt(2 * Math.PI);\n\n/**\n * [Well-known kernels](https://en.wikipedia.org/wiki/Kernel_(statistics)#Kernel_functions_in_common_use)\n * @private\n */\nconst kernels = {\n /**\n * The gaussian kernel.\n * @private\n */\n gaussian: function (u) {\n return Math.exp(-0.5 * u * u) / SQRT_2PI;\n },\n};\n\n/**\n * Well known bandwidth selection methods\n * @private\n */\nconst bandwidthMethods = {\n /**\n * The [\"normal reference distribution\"\n * rule-of-thumb](https://stat.ethz.ch/R-manual/R-devel/library/MASS/html/bandwidth.nrd.html),\n * a commonly used version of [Silverman's\n * rule-of-thumb](https://en.wikipedia.org/wiki/Kernel_density_estimation#A_rule-of-thumb_bandwidth_estimator).\n * @private\n */\n nrd: function (x) {\n let s = stddev(x);\n const iqr = interquartileRange(x);\n if (typeof iqr === \"number\") {\n s = Math.min(s, iqr / 1.34);\n }\n return 1.06 * s * Math.pow(x.length, -0.2);\n },\n};\n\n/**\n * [Kernel density estimation](https://en.wikipedia.org/wiki/Kernel_density_estimation)\n * is a useful tool for, among other things, estimating the shape of the\n * underlying probability distribution from a sample.\n *\n * @name kernelDensityEstimation\n * @param X sample values\n * @param kernel The kernel function to use. If a function is provided, it should return non-negative values and integrate to 1. Defaults to 'gaussian'.\n * @param bandwidthMethod The \"bandwidth selection\" method to use, or a fixed bandwidth value. Defaults to \"nrd\", the commonly-used [\"normal reference distribution\" rule-of-thumb](https://stat.ethz.ch/R-manual/R-devel/library/MASS/html/bandwidth.nrd.html).\n * @returns {Function} An estimated [probability density function](https://en.wikipedia.org/wiki/Probability_density_function) for the given sample. The returned function runs in `O(X.length)`.\n */\nfunction kernelDensityEstimation(X, kernel, bandwidthMethod) {\n let kernelFn;\n if (kernel === undefined) {\n kernelFn = kernels.gaussian;\n } else if (typeof kernel === \"string\") {\n if (!kernels[kernel]) {\n throw new Error('Unknown kernel \"' + kernel + '\"');\n }\n kernelFn = kernels[kernel];\n } else {\n kernelFn = kernel;\n }\n\n let bandwidth;\n if (typeof bandwidthMethod === \"undefined\") {\n bandwidth = bandwidthMethods.nrd(X);\n } else if (typeof bandwidthMethod === \"string\") {\n if (!bandwidthMethods[bandwidthMethod]) {\n throw new Error(\n 'Unknown bandwidth method \"' + bandwidthMethod + '\"',\n );\n }\n bandwidth = bandwidthMethods[bandwidthMethod](X);\n } else {\n bandwidth = bandwidthMethod;\n }\n\n return function (x) {\n let i = 0;\n let sum = 0;\n for (i = 0; i < X.length; i++) {\n sum += kernelFn((x - X[i]) / bandwidth);\n }\n return sum / bandwidth / X.length;\n };\n}\n\nexport default kernelDensityEstimation;\n","const SQRT_2PI = Math.sqrt(2 * Math.PI);\n\nfunction cumulativeDistribution(z) {\n let sum = z;\n let tmp = z;\n\n // 15 iterations are enough for 4-digit precision\n for (let i = 1; i < 15; i++) {\n tmp *= (z * z) / (2 * i + 1);\n sum += tmp;\n }\n return (\n Math.round((0.5 + (sum / SQRT_2PI) * Math.exp((-z * z) / 2)) * 1e4) /\n 1e4\n );\n}\n\n/**\n * A standard normal table, also called the unit normal table or Z table,\n * is a mathematical table for the values of Φ (phi), which are the values of\n * the [cumulative distribution function](https://en.wikipedia.org/wiki/Normal_distribution#Cumulative_distribution_function)\n * of the normal distribution. It is used to find the probability that a\n * statistic is observed below, above, or between values on the standard\n * normal distribution, and by extension, any normal distribution.\n */\nconst standardNormalTable = [];\n\nfor (let z = 0; z <= 3.09; z += 0.01) {\n standardNormalTable.push(cumulativeDistribution(z));\n}\n\nexport default standardNormalTable;\n","/**\n * **[Gaussian error function](http://en.wikipedia.org/wiki/Error_function)**\n *\n * The `errorFunction(x/(sd * Math.sqrt(2)))` is the probability that a value in a\n * normal distribution with standard deviation sd is within x of the mean.\n *\n * This function returns a numerical approximation to the exact value.\n * It uses Horner's method to evaluate the polynomial of τ (tau).\n *\n * @param {number} x input\n * @return {number} error estimation\n * @example\n * errorFunction(1).toFixed(2); // => '0.84'\n */\nfunction errorFunction(x) {\n const t = 1 / (1 + 0.5 * Math.abs(x));\n const tau =\n t *\n Math.exp(\n -x * x +\n ((((((((0.17087277 * t - 0.82215223) * t + 1.48851587) * t -\n 1.13520398) *\n t +\n 0.27886807) *\n t -\n 0.18628806) *\n t +\n 0.09678418) *\n t +\n 0.37409196) *\n t +\n 1.00002368) *\n t -\n 1.26551223,\n );\n if (x >= 0) {\n return 1 - tau;\n } else {\n return tau - 1;\n }\n}\n\nexport default errorFunction;\n","/**\n * The Inverse [Gaussian error function](http://en.wikipedia.org/wiki/Error_function)\n * returns a numerical approximation to the value that would have caused\n * `errorFunction()` to return x.\n *\n * @param {number} x value of error function\n * @returns {number} estimated inverted value\n */\nfunction inverseErrorFunction(x) {\n const a = (8 * (Math.PI - 3)) / (3 * Math.PI * (4 - Math.PI));\n\n const inv = Math.sqrt(\n Math.sqrt(\n Math.pow(2 / (Math.PI * a) + Math.log(1 - x * x) / 2, 2) -\n Math.log(1 - x * x) / a,\n ) -\n (2 / (Math.PI * a) + Math.log(1 - x * x) / 2),\n );\n\n if (x >= 0) {\n return inv;\n } else {\n return -inv;\n }\n}\n\nexport default inverseErrorFunction;\n","/**\n * [Sign](https://en.wikipedia.org/wiki/Sign_function) is a function\n * that extracts the sign of a real number\n *\n * @param {number} x input value\n * @returns {number} sign value either 1, 0 or -1\n * @throws {TypeError} if the input argument x is not a number\n * @private\n *\n * @example\n * sign(2); // => 1\n */\nfunction sign(x) {\n if (typeof x === \"number\") {\n if (x < 0) {\n return -1;\n } else if (x === 0) {\n return 0;\n } else {\n return 1;\n }\n } else {\n throw new TypeError(\"not a number\");\n }\n}\n\nexport default sign;\n","/**\n * Calculate Euclidean distance between two points.\n * @param {Array} left First N-dimensional point.\n * @param {Array} right Second N-dimensional point.\n * @returns {number} Distance.\n */\nfunction euclideanDistance(left, right) {\n let sum = 0;\n for (let i = 0; i < left.length; i++) {\n const diff = left[i] - right[i];\n sum += diff * diff;\n }\n return Math.sqrt(sum);\n}\n\nexport default euclideanDistance;\n","import euclideanDistance from \"./euclidean_distance.js\";\nimport makeMatrix from \"./make_matrix.js\";\nimport sample from \"./sample.js\";\n\n/**\n * @typedef {Object} kMeansReturn\n * @property {Array} labels The labels.\n * @property {Array>} centroids The cluster centroids.\n */\n\n/**\n * Perform k-means clustering.\n *\n * @param {Array>} points N-dimensional coordinates of points to be clustered.\n * @param {number} numCluster How many clusters to create.\n * @param {Function} randomSource An optional entropy source that generates uniform values in [0, 1).\n * @return {kMeansReturn} Labels (same length as data) and centroids (same length as numCluster).\n * @throws {Error} If any centroids wind up friendless (i.e., without associated points).\n *\n * @example\n * kMeansCluster([[0.0, 0.5], [1.0, 0.5]], 2); // => {labels: [0, 1], centroids: [[0.0, 0.5], [1.0 0.5]]}\n */\nfunction kMeansCluster(points, numCluster, randomSource = Math.random) {\n let oldCentroids = null;\n let newCentroids = sample(points, numCluster, randomSource);\n let labels = null;\n let change = Number.MAX_VALUE;\n while (change !== 0) {\n labels = labelPoints(points, newCentroids);\n oldCentroids = newCentroids;\n newCentroids = calculateCentroids(points, labels, numCluster);\n change = calculateChange(newCentroids, oldCentroids);\n }\n return {\n labels: labels,\n centroids: newCentroids,\n };\n}\n\n/**\n * Label each point according to which centroid it is closest to.\n *\n * @private\n * @param {Array>} points Array of XY coordinates.\n * @param {Array>} centroids Current centroids.\n * @return {Array} Group labels.\n */\nfunction labelPoints(points, centroids) {\n return points.map((p) => {\n let minDist = Number.MAX_VALUE;\n let label = -1;\n for (let i = 0; i < centroids.length; i++) {\n const dist = euclideanDistance(p, centroids[i]);\n if (dist < minDist) {\n minDist = dist;\n label = i;\n }\n }\n return label;\n });\n}\n\n/**\n * Calculate centroids for points given labels.\n *\n * @private\n * @param {Array>} points Array of XY coordinates.\n * @param {Array} labels Which groups points belong to.\n * @param {number} numCluster Number of clusters being created.\n * @return {Array>} Centroid for each group.\n * @throws {Error} If any centroids wind up friendless (i.e., without associated points).\n */\nfunction calculateCentroids(points, labels, numCluster) {\n // Initialize accumulators.\n const dimension = points[0].length;\n const centroids = makeMatrix(numCluster, dimension);\n const counts = Array(numCluster).fill(0);\n\n // Add points to centroids' accumulators and count points per centroid.\n const numPoints = points.length;\n for (let i = 0; i < numPoints; i++) {\n const point = points[i];\n const label = labels[i];\n const current = centroids[label];\n for (let j = 0; j < dimension; j++) {\n current[j] += point[j];\n }\n counts[label] += 1;\n }\n\n // Rescale centroids, checking for any that have no points.\n for (let i = 0; i < numCluster; i++) {\n if (counts[i] === 0) {\n throw new Error(`Centroid ${i} has no friends`);\n }\n const centroid = centroids[i];\n for (let j = 0; j < dimension; j++) {\n centroid[j] /= counts[i];\n }\n }\n\n return centroids;\n}\n\n/**\n * Calculate the difference between old centroids and new centroids.\n *\n * @private\n * @param {Array>} left One list of centroids.\n * @param {Array>} right Another list of centroids.\n * @return {number} Distance between centroids.\n */\nfunction calculateChange(left, right) {\n let total = 0;\n for (let i = 0; i < left.length; i++) {\n total += euclideanDistance(left[i], right[i]);\n }\n return total;\n}\n\nexport default kMeansCluster;\n","import euclideanDistance from \"./euclidean_distance.js\";\nimport makeMatrix from \"./make_matrix.js\";\nimport max from \"./max.js\";\n\n/**\n * Calculate the [silhouette values](https://en.wikipedia.org/wiki/Silhouette_(clustering))\n * for clustered data.\n *\n * @param {Array>} points N-dimensional coordinates of points.\n * @param {Array} labels Labels of points. This must be the same length as `points`,\n * and values must lie in [0..G-1], where G is the number of groups.\n * @return {Array} The silhouette value for each point.\n *\n * @example\n * silhouette([[0.25], [0.75]], [0, 0]); // => [1.0, 1.0]\n */\nfunction silhouette(points, labels) {\n if (points.length !== labels.length) {\n throw new Error(\"must have exactly as many labels as points\");\n }\n const groupings = createGroups(labels);\n const distances = calculateAllDistances(points);\n const result = [];\n for (let i = 0; i < points.length; i++) {\n let s = 0;\n if (groupings[labels[i]].length > 1) {\n const a = meanDistanceFromPointToGroup(\n i,\n groupings[labels[i]],\n distances,\n );\n const b = meanDistanceToNearestGroup(\n i,\n labels,\n groupings,\n distances,\n );\n s = (b - a) / Math.max(a, b);\n }\n result.push(s);\n }\n return result;\n}\n\n/**\n * Create a lookup table mapping group IDs to point IDs.\n *\n * @private\n * @param {Array} labels Labels of points. This must be the same length as `points`,\n * and values must lie in [0..G-1], where G is the number of groups.\n * @return {Array>} An array of length G, each of whose entries is an array\n * containing the indices of the points in that group.\n */\nfunction createGroups(labels) {\n const numGroups = 1 + max(labels);\n const result = Array(numGroups);\n for (let i = 0; i < labels.length; i++) {\n const label = labels[i];\n if (result[label] === undefined) {\n result[label] = [];\n }\n result[label].push(i);\n }\n return result;\n}\n\n/**\n * Create a lookup table of all inter-point distances.\n *\n * @private\n * @param {Array>} points N-dimensional coordinates of points.\n * @return {Array>} A symmetric square array of inter-point distances\n * (zero on the diagonal).\n */\nfunction calculateAllDistances(points) {\n const numPoints = points.length;\n const result = makeMatrix(numPoints, numPoints);\n for (let i = 0; i < numPoints; i++) {\n for (let j = 0; j < i; j++) {\n result[i][j] = euclideanDistance(points[i], points[j]);\n result[j][i] = result[i][j];\n }\n }\n return result;\n}\n\n/**\n * Calculate the mean distance between this point and all the points in the\n * nearest group (as determined by which point in another group is closest).\n *\n * @private\n * @param {number} which The index of this point.\n * @param {Array} labels Labels of points.\n * @param {Array>} groupings An array whose entries are arrays\n * containing the indices of the points in that group.\n * @param {Array>} distances A symmetric square array of inter-point\n * distances.\n * @return {number} The mean distance from this point to others in the nearest\n * group.\n */\nfunction meanDistanceToNearestGroup(which, labels, groupings, distances) {\n const label = labels[which];\n let result = Number.MAX_VALUE;\n for (let i = 0; i < groupings.length; i++) {\n if (i !== label) {\n const d = meanDistanceFromPointToGroup(\n which,\n groupings[i],\n distances,\n );\n if (d < result) {\n result = d;\n }\n }\n }\n return result;\n}\n\n/**\n * Calculate the mean distance between a point and all the points in a group\n * (possibly its own).\n *\n * @private\n * @param {number} which The index of this point.\n * @param {Array} group The indices of all the points in the group in\n * question.\n * @param {Array>} distances A symmetric square array of inter-point\n * distances.\n * @return {number} The mean distance from this point to others in the\n * specified group.\n */\nfunction meanDistanceFromPointToGroup(which, group, distances) {\n let total = 0;\n for (let i = 0; i < group.length; i++) {\n total += distances[which][group[i]];\n }\n return total / group.length;\n}\n\nexport default silhouette;\n","/**\n * Relative error.\n *\n * This is more difficult to calculate than it first appears [1,2]. The usual\n * formula for the relative error between an actual value A and an expected\n * value E is `|(A-E)/E|`, but:\n *\n * 1. If the expected value is 0, any other value has infinite relative error,\n * which is counter-intuitive: if the expected voltage is 0, getting 1/10th\n * of a volt doesn't feel like an infinitely large error.\n *\n * 2. This formula does not satisfy the mathematical definition of a metric [3].\n * [4] solved this problem by defining the relative error as `|ln(|A/E|)|`,\n * but that formula only works if all values are positive: for example, it\n * reports the relative error of -10 and 10 as 0.\n *\n * Our implementation sticks with convention and returns:\n *\n * - 0 if the actual and expected values are both zero\n * - Infinity if the actual value is non-zero and the expected value is zero\n * - `|(A-E)/E|` in all other cases\n *\n * [1] https://math.stackexchange.com/questions/677852/how-to-calculate-relative-error-when-true-value-is-zero\n * [2] https://en.wikipedia.org/wiki/Relative_change_and_difference\n * [3] https://en.wikipedia.org/wiki/Metric_(mathematics)#Definition\n * [4] F.W.J. Olver: \"A New Approach to Error Arithmetic.\" SIAM Journal on\n * Numerical Analysis, 15(2), 1978, 10.1137/0715024.\n *\n * @param {number} actual The actual value.\n * @param {number} expected The expected value.\n * @return {number} The relative error.\n */\nfunction relativeError(actual, expected) {\n // These lines are actually covered by tests, but it seems\n // like c8 has a bug that marks them as not covered.\n /* c8 ignore start */\n if (actual === 0 && expected === 0) {\n return 0;\n }\n /* c8 ignore end */\n return Math.abs((actual - expected) / expected);\n}\n\nexport default relativeError;\n","/**\n * When adding a new value to a list, one does not have to necessary\n * recompute the mean of the list in linear time. They can instead use\n * this function to compute the new mean by providing the current mean,\n * the number of elements in the list that produced it and the new\n * value to add.\n *\n * @since 2.5.0\n * @param {number} mean current mean\n * @param {number} n number of items in the list\n * @param {number} newValue the added value\n * @returns {number} the new mean\n *\n * @example\n * addToMean(14, 5, 53); // => 20.5\n */\nfunction addToMean(mean, n, newValue) {\n return mean + (newValue - mean) / (n + 1);\n}\n\nexport default addToMean;\n","import epsilon from \"./epsilon.js\";\nimport relativeError from \"./relative_error.js\";\n\n/**\n * Approximate equality.\n *\n * @param {number} actual The value to be tested.\n * @param {number} expected The reference value.\n * @param {number} tolerance The acceptable relative difference.\n * @return {boolean} Whether numbers are within tolerance.\n */\nfunction approxEqual(actual, expected, tolerance = epsilon) {\n return relativeError(actual, expected) <= tolerance;\n}\n\nexport default approxEqual;\n","/**\n * The [Bernoulli distribution](http://en.wikipedia.org/wiki/Bernoulli_distribution)\n * is the probability discrete\n * distribution of a random variable which takes value 1 with success\n * probability `p` and value 0 with failure\n * probability `q` = 1 - `p`. It can be used, for example, to represent the\n * toss of a coin, where \"1\" is defined to mean \"heads\" and \"0\" is defined\n * to mean \"tails\" (or vice versa). It is\n * a special case of a Binomial Distribution\n * where `n` = 1.\n *\n * @param {number} p input value, between 0 and 1 inclusive\n * @returns {number[]} values of bernoulli distribution at this point\n * @throws {Error} if p is outside 0 and 1\n * @example\n * bernoulliDistribution(0.3); // => [0.7, 0.3]\n */\nfunction bernoulliDistribution(p) /*: number[] */ {\n // Check that `p` is a valid probability (0 ≤ p ≤ 1)\n if (p < 0 || p > 1) {\n throw new Error(\n \"bernoulliDistribution requires probability to be between 0 and 1 inclusive\",\n );\n }\n\n return [1 - p, p];\n}\n\nexport default bernoulliDistribution;\n","import epsilon from \"./epsilon.js\";\n\n/**\n * The [Binomial Distribution](http://en.wikipedia.org/wiki/Binomial_distribution) is the discrete probability\n * distribution of the number of successes in a sequence of n independent yes/no experiments, each of which yields\n * success with probability `probability`. Such a success/failure experiment is also called a Bernoulli experiment or\n * Bernoulli trial; when trials = 1, the Binomial Distribution is a Bernoulli Distribution.\n *\n * @param {number} trials number of trials to simulate\n * @param {number} probability\n * @returns {number[]} output\n */\nfunction binomialDistribution(trials, probability) /*: ?number[] */ {\n // Check that `p` is a valid probability (0 ≤ p ≤ 1),\n // that `n` is an integer, strictly positive.\n if (probability < 0 || probability > 1 || trials <= 0 || trials % 1 !== 0) {\n return undefined;\n }\n\n // We initialize `x`, the random variable, and `accumulator`, an accumulator\n // for the cumulative distribution function to 0. `distribution_functions`\n // is the object we'll return with the `probability_of_x` and the\n // `cumulativeProbability_of_x`, as well as the calculated mean &\n // variance. We iterate until the `cumulativeProbability_of_x` is\n // within `epsilon` of 1.0.\n let x = 0;\n let cumulativeProbability = 0;\n const cells = [];\n let binomialCoefficient = 1;\n\n // This algorithm iterates through each potential outcome,\n // until the `cumulativeProbability` is very close to 1, at\n // which point we've defined the vast majority of outcomes\n do {\n // a [probability mass function](https://en.wikipedia.org/wiki/Probability_mass_function)\n cells[x] =\n binomialCoefficient *\n Math.pow(probability, x) *\n Math.pow(1 - probability, trials - x);\n cumulativeProbability += cells[x];\n x++;\n binomialCoefficient = (binomialCoefficient * (trials - x + 1)) / x;\n // when the cumulativeProbability is nearly 1, we've calculated\n // the useful range of this distribution\n } while (cumulativeProbability < 1 - epsilon);\n\n return cells;\n}\n\nexport default binomialDistribution;\n","import sign from \"./sign.js\";\n\n/**\n * [Bisection method](https://en.wikipedia.org/wiki/Bisection_method) is a root-finding\n * method that repeatedly bisects an interval to find the root.\n *\n * This function returns a numerical approximation to the exact value.\n *\n * @param {Function} func input function\n * @param {number} start - start of interval\n * @param {number} end - end of interval\n * @param {number} maxIterations - the maximum number of iterations\n * @param {number} errorTolerance - the error tolerance\n * @returns {number} estimated root value\n * @throws {TypeError} Argument func must be a function\n *\n * @example\n * bisect(Math.cos,0,4,100,0.003); // => 1.572265625\n */\nfunction bisect(func, start, end, maxIterations, errorTolerance) {\n if (typeof func !== \"function\")\n throw new TypeError(\"func must be a function\");\n\n for (let i = 0; i < maxIterations; i++) {\n const output = (start + end) / 2;\n\n if (\n func(output) === 0 ||\n Math.abs((end - start) / 2) < errorTolerance\n ) {\n return output;\n }\n\n if (sign(func(output)) === sign(func(start))) {\n start = output;\n } else {\n end = output;\n }\n }\n\n throw new Error(\"maximum number of iterations exceeded\");\n}\n\nexport default bisect;\n","import chiSquaredDistributionTable from \"./chi_squared_distribution_table.js\";\nimport mean from \"./mean.js\";\n\n/**\n * The [χ2 (Chi-Squared) Goodness-of-Fit Test](http://en.wikipedia.org/wiki/Goodness_of_fit#Pearson.27s_chi-squared_test)\n * uses a measure of goodness of fit which is the sum of differences between observed and expected outcome frequencies\n * (that is, counts of observations), each squared and divided by the number of observations expected given the\n * hypothesized distribution. The resulting χ2 statistic, `chiSquared`, can be compared to the chi-squared distribution\n * to determine the goodness of fit. In order to determine the degrees of freedom of the chi-squared distribution, one\n * takes the total number of observed frequencies and subtracts the number of estimated parameters. The test statistic\n * follows, approximately, a chi-square distribution with (k − c) degrees of freedom where `k` is the number of non-empty\n * cells and `c` is the number of estimated parameters for the distribution.\n *\n * @param {Array} data\n * @param {Function} distributionType a function that returns a point in a distribution:\n * for instance, binomial, bernoulli, or poisson\n * @param {number} significance\n * @returns {number} chi squared goodness of fit\n * @example\n * // Data from Poisson goodness-of-fit example 10-19 in William W. Hines & Douglas C. Montgomery,\n * // \"Probability and Statistics in Engineering and Management Science\", Wiley (1980).\n * var data1019 = [\n * 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n * 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n * 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n * 2, 2, 2, 2, 2, 2, 2, 2, 2,\n * 3, 3, 3, 3\n * ];\n * ss.chiSquaredGoodnessOfFit(data1019, ss.poissonDistribution, 0.05); //= false\n */\nfunction chiSquaredGoodnessOfFit(data, distributionType, significance) {\n // Estimate from the sample data, a weighted mean.\n const inputMean = mean(data);\n // Calculated value of the χ2 statistic.\n let chiSquared = 0;\n // Number of hypothesized distribution parameters estimated, expected to be supplied in the distribution test.\n // Lose one degree of freedom for estimating `lambda` from the sample data.\n const c = 1;\n // The hypothesized distribution.\n // Generate the hypothesized distribution.\n const hypothesizedDistribution = distributionType(inputMean);\n const observedFrequencies = [];\n const expectedFrequencies = [];\n\n // Create an array holding a histogram from the sample data, of\n // the form `{ value: numberOfOcurrences }`\n for (let i = 0; i < data.length; i++) {\n if (observedFrequencies[data[i]] === undefined) {\n observedFrequencies[data[i]] = 0;\n }\n observedFrequencies[data[i]]++;\n }\n\n // The histogram we created might be sparse - there might be gaps\n // between values. So we iterate through the histogram, making\n // sure that instead of undefined, gaps have 0 values.\n for (let i = 0; i < observedFrequencies.length; i++) {\n if (observedFrequencies[i] === undefined) {\n observedFrequencies[i] = 0;\n }\n }\n\n // Create an array holding a histogram of expected data given the\n // sample size and hypothesized distribution.\n for (const k in hypothesizedDistribution) {\n if (k in observedFrequencies) {\n expectedFrequencies[+k] = hypothesizedDistribution[k] * data.length;\n }\n }\n\n // Working backward through the expected frequencies, collapse classes\n // if less than three observations are expected for a class.\n // This transformation is applied to the observed frequencies as well.\n for (let k = expectedFrequencies.length - 1; k >= 0; k--) {\n if (expectedFrequencies[k] < 3) {\n expectedFrequencies[k - 1] += expectedFrequencies[k];\n expectedFrequencies.pop();\n\n observedFrequencies[k - 1] += observedFrequencies[k];\n observedFrequencies.pop();\n }\n }\n\n // Iterate through the squared differences between observed & expected\n // frequencies, accumulating the `chiSquared` statistic.\n for (let k = 0; k < observedFrequencies.length; k++) {\n chiSquared +=\n Math.pow(observedFrequencies[k] - expectedFrequencies[k], 2) /\n expectedFrequencies[k];\n }\n\n // Calculate degrees of freedom for this test and look it up in the\n // `chiSquaredDistributionTable` in order to\n // accept or reject the goodness-of-fit of the hypothesized distribution.\n // Degrees of freedom, calculated as (number of class intervals -\n // number of hypothesized distribution parameters estimated - 1)\n const degreesOfFreedom = observedFrequencies.length - c - 1;\n return (\n chiSquaredDistributionTable[degreesOfFreedom][significance] < chiSquared\n );\n}\n\nexport default chiSquaredGoodnessOfFit;\n","/**\n * Split an array into chunks of a specified size. This function\n * has the same behavior as [PHP's array_chunk](http://php.net/manual/en/function.array-chunk.php)\n * function, and thus will insert smaller-sized chunks at the end if\n * the input size is not divisible by the chunk size.\n *\n * `x` is expected to be an array, and `chunkSize` a number.\n * The `x` array can contain any kind of data.\n *\n * @param {Array} x a sample\n * @param {number} chunkSize size of each output array. must be a positive integer\n * @returns {Array} a chunked array\n * @throws {Error} if chunk size is less than 1 or not an integer\n * @example\n * chunk([1, 2, 3, 4, 5, 6], 2);\n * // => [[1, 2], [3, 4], [5, 6]]\n */\nfunction chunk(x, chunkSize) {\n // a list of result chunks, as arrays in an array\n const output = [];\n\n // `chunkSize` must be zero or higher - otherwise the loop below,\n // in which we call `start += chunkSize`, will loop infinitely.\n // So, we'll detect and throw in that case to indicate\n // invalid input.\n if (chunkSize < 1) {\n throw new Error(\"chunk size must be a positive number\");\n }\n\n if (Math.floor(chunkSize) !== chunkSize) {\n throw new Error(\"chunk size must be an integer\");\n }\n\n // `start` is the index at which `.slice` will start selecting\n // new array elements\n for (let start = 0; start < x.length; start += chunkSize) {\n // for each chunk, slice that part of the array and add it\n // to the output. The `.slice` function does not change\n // the original array.\n output.push(x.slice(start, start + chunkSize));\n }\n return output;\n}\n\nexport default chunk;\n","import mean from \"./mean.js\";\nimport sampleStandardDeviation from \"./sample_standard_deviation.js\";\n\n/**\n * The`coefficient of variation`_ is the ratio of the standard deviation to the mean.\n * .._`coefficient of variation`: https://en.wikipedia.org/wiki/Coefficient_of_variation\n *\n *\n * @param {Array} x input\n * @returns {number} coefficient of variation\n * @example\n * coefficientOfVariation([1, 2, 3, 4]).toFixed(3); // => 0.516\n * coefficientOfVariation([1, 2, 3, 4, 5]).toFixed(3); // => 0.527\n * coefficientOfVariation([-1, 0, 1, 2, 3, 4]).toFixed(3); // => 1.247\n */\nfunction coefficientOfVariation(x) {\n return sampleStandardDeviation(x) / mean(x);\n}\n\nexport default coefficientOfVariation;\n","/**\n * Implementation of Combinations\n * Combinations are unique subsets of a collection - in this case, k x from a collection at a time.\n * https://en.wikipedia.org/wiki/Combination\n * @param {Array} x any type of data\n * @param {int} k the number of objects in each group (without replacement)\n * @returns {Array} array of permutations\n * @example\n * combinations([1, 2, 3], 2); // => [[1,2], [1,3], [2,3]]\n */\n\nfunction combinations(x, k) {\n let i;\n let subI;\n const combinationList = [];\n let subsetCombinations;\n let next;\n\n for (i = 0; i < x.length; i++) {\n if (k === 1) {\n combinationList.push([x[i]]);\n } else {\n subsetCombinations = combinations(x.slice(i + 1, x.length), k - 1);\n for (subI = 0; subI < subsetCombinations.length; subI++) {\n next = subsetCombinations[subI];\n next.unshift(x[i]);\n combinationList.push(next);\n }\n }\n }\n return combinationList;\n}\n\nexport default combinations;\n","/**\n * Implementation of [Combinations](https://en.wikipedia.org/wiki/Combination) with replacement\n * Combinations are unique subsets of a collection - in this case, k x from a collection at a time.\n * 'With replacement' means that a given element can be chosen multiple times.\n * Unlike permutation, order doesn't matter for combinations.\n *\n * @param {Array} x any type of data\n * @param {int} k the number of objects in each group (without replacement)\n * @returns {Array} array of permutations\n * @example\n * combinationsReplacement([1, 2], 2); // => [[1, 1], [1, 2], [2, 2]]\n */\nfunction combinationsReplacement(x, k) {\n const combinationList = [];\n\n for (let i = 0; i < x.length; i++) {\n if (k === 1) {\n // If we're requested to find only one element, we don't need\n // to recurse: just push `x[i]` onto the list of combinations.\n combinationList.push([x[i]]);\n } else {\n // Otherwise, recursively find combinations, given `k - 1`. Note that\n // we request `k - 1`, so if you were looking for k=3 combinations, we're\n // requesting k=2. This -1 gets reversed in the for loop right after this\n // code, since we concatenate `x[i]` onto the selected combinations,\n // bringing `k` back up to your requested level.\n // This recursion may go many levels deep, since it only stops once\n // k=1.\n const subsetCombinations = combinationsReplacement(\n x.slice(i, x.length),\n k - 1,\n );\n\n for (let j = 0; j < subsetCombinations.length; j++) {\n combinationList.push([x[i]].concat(subsetCombinations[j]));\n }\n }\n }\n\n return combinationList;\n}\n\nexport default combinationsReplacement;\n","import combineMeans from \"./combine_means.js\";\n\n/**\n * When combining two lists of values for which one already knows the variances,\n * one does not have to necessary recompute the variance of the combined lists\n * in linear time. They can instead use this function to compute the combined\n * variance by providing the variance, mean & number of values of the first list\n * and the variance, mean & number of values of the second list.\n *\n * @since 3.0.0\n * @param {number} variance1 variance of the first list\n * @param {number} mean1 mean of the first list\n * @param {number} n1 number of items in the first list\n * @param {number} variance2 variance of the second list\n * @param {number} mean2 mean of the second list\n * @param {number} n2 number of items in the second list\n * @returns {number} the combined mean\n *\n * @example\n * combineVariances(14 / 3, 5, 3, 8 / 3, 4, 3); // => 47 / 12\n */\nfunction combineVariances(variance1, mean1, n1, variance2, mean2, n2) {\n const newMean = combineMeans(mean1, n1, mean2, n2);\n\n return (\n (n1 * (variance1 + Math.pow(mean1 - newMean, 2)) +\n n2 * (variance2 + Math.pow(mean2 - newMean, 2))) /\n (n1 + n2)\n );\n}\n\nexport default combineVariances;\n","/**\n * **[Logistic Cumulative Distribution Function](https://en.wikipedia.org/wiki/Logistic_distribution)**\n *\n * @param {number} x\n * @returns {number} cumulative standard logistic probability\n */\nfunction cumulativeStdLogisticProbability(x) {\n return 1 / (Math.exp(-x) + 1);\n}\n\nexport default cumulativeStdLogisticProbability;\n","import standardNormalTable from \"./standard_normal_table.js\";\n\n/**\n * **[Cumulative Standard Normal Probability](http://en.wikipedia.org/wiki/Standard_normal_table)**\n *\n * Since probability tables cannot be\n * printed for every normal distribution, as there are an infinite variety\n * of normal distributions, it is common practice to convert a normal to a\n * standard normal and then use the standard normal table to find probabilities.\n *\n * You can use `.5 + .5 * errorFunction(x / Math.sqrt(2))` to calculate the probability\n * instead of looking it up in a table.\n *\n * @param {number} z\n * @returns {number} cumulative standard normal probability\n */\nfunction cumulativeStdNormalProbability(z) {\n // Calculate the position of this value.\n const absZ = Math.abs(z);\n // Each row begins with a different\n // significant digit: 0.5, 0.6, 0.7, and so on. Each value in the table\n // corresponds to a range of 0.01 in the input values, so the value is\n // multiplied by 100.\n const index = Math.min(\n Math.round(absZ * 100),\n standardNormalTable.length - 1,\n );\n\n // The index we calculate must be in the table as a positive value,\n // but we still pay attention to whether the input is positive\n // or negative, and flip the output value as a last step.\n if (z >= 0) {\n return standardNormalTable[index];\n } else {\n // due to floating-point arithmetic, values in the table with\n // 4 significant figures can nevertheless end up as repeating\n // fractions when they're computed here.\n return Math.round((1 - standardNormalTable[index]) * 1e4) / 1e4;\n }\n}\n\nexport default cumulativeStdNormalProbability;\n","import max from \"./max.js\";\nimport min from \"./min.js\";\n\n/**\n * Given an array of x, this will find the extent of the\n * x and return an array of breaks that can be used\n * to categorize the x into a number of classes. The\n * returned array will always be 1 longer than the number of\n * classes because it includes the minimum value.\n *\n * @param {Array} x an array of number values\n * @param {number} nClasses number of desired classes\n * @returns {Array} array of class break positions\n * @example\n * equalIntervalBreaks([1, 2, 3, 4, 5, 6], 4); // => [1, 2.25, 3.5, 4.75, 6]\n */\nfunction equalIntervalBreaks(x, nClasses) {\n if (x.length < 2) {\n return x;\n }\n\n const theMin = min(x);\n const theMax = max(x);\n\n // the first break will always be the minimum value\n // in the xset\n const breaks = [theMin];\n\n // The size of each break is the full range of the x\n // divided by the number of classes requested\n const breakSize = (theMax - theMin) / nClasses;\n\n // In the case of nClasses = 1, this loop won't run\n // and the returned breaks will be [min, max]\n for (let i = 1; i < nClasses; i++) {\n breaks.push(breaks[0] + breakSize * i);\n }\n\n // the last break will always be the\n // maximum.\n breaks.push(theMax);\n\n return breaks;\n}\n\nexport default equalIntervalBreaks;\n","/**\n * This computes the minimum & maximum number in an array.\n *\n * This runs in `O(n)`, linear time, with respect to the length of the array.\n *\n * @param {Array} x sample of one or more data points\n * @returns {Array} minimum & maximum value\n * @throws {Error} if the length of x is less than one\n * @example\n * extent([1, 2, 3, 4]);\n * // => [1, 4]\n */\nfunction extent(x) {\n if (x.length === 0) {\n throw new Error(\"extent requires at least one data point\");\n }\n\n let min = x[0];\n let max = x[0];\n for (let i = 1; i < x.length; i++) {\n if (x[i] > max) {\n max = x[i];\n }\n if (x[i] < min) {\n min = x[i];\n }\n }\n return [min, max];\n}\n\nexport default extent;\n","/**\n * The extent is the lowest & highest number in the array. With a sorted array,\n * the first element in the array is always the lowest while the last element is always the largest, so this calculation\n * can be done in one step, or constant time.\n *\n * @param {Array} x input\n * @returns {Array} minimum & maximum value\n * @example\n * extentSorted([-100, -10, 1, 2, 5]); // => [-100, 5]\n */\nfunction extentSorted(x) {\n return [x[0], x[x.length - 1]];\n}\n\nexport default extentSorted;\n","import factorial from \"./factorial.js\";\n\n/**\n * Compute the [gamma function](https://en.wikipedia.org/wiki/Gamma_function) of a value using Nemes' approximation.\n * The gamma of n is equivalent to (n-1)!, but unlike the factorial function, gamma is defined for all real n except zero\n * and negative integers (where NaN is returned). Note, the gamma function is also well-defined for complex numbers,\n * though this implementation currently does not handle complex numbers as input values.\n * Nemes' approximation is defined [here](https://arxiv.org/abs/1003.6020) as Theorem 2.2.\n * Negative values use [Euler's reflection formula](https://en.wikipedia.org/wiki/Gamma_function#Properties) for computation.\n *\n * @param {number} n Any real number except for zero and negative integers.\n * @returns {number} The gamma of the input value.\n *\n * @example\n * gamma(11.5); // 11899423.084037038\n * gamma(-11.5); // 2.29575810481609e-8\n * gamma(5); // 24\n */\nfunction gamma(n) {\n if (Number.isInteger(n)) {\n if (n <= 0) {\n // gamma not defined for zero or negative integers\n return Number.NaN;\n } else {\n // use factorial for integer inputs\n return factorial(n - 1);\n }\n }\n\n // Decrement n, because approximation is defined for n - 1\n n--;\n\n if (n < 0) {\n // Use Euler's reflection formula for negative inputs\n // see: https://en.wikipedia.org/wiki/Gamma_function#Properties\n return Math.PI / (Math.sin(Math.PI * -n) * gamma(-n));\n } else {\n // Nemes' expansion approximation\n const seriesCoefficient =\n Math.pow(n / Math.E, n) * Math.sqrt(2 * Math.PI * (n + 1 / 6));\n\n const seriesDenom = n + 1 / 4;\n\n const seriesExpansion =\n 1 +\n 1 / 144 / Math.pow(seriesDenom, 2) -\n 1 / 12960 / Math.pow(seriesDenom, 3) -\n 257 / 207360 / Math.pow(seriesDenom, 4) -\n 52 / 2612736 / Math.pow(seriesDenom, 5) +\n 5741173 / 9405849600 / Math.pow(seriesDenom, 6) +\n 37529 / 18811699200 / Math.pow(seriesDenom, 7);\n\n return seriesCoefficient * seriesExpansion;\n }\n}\n\nexport default gamma;\n","/**\n * The [Geometric Mean](https://en.wikipedia.org/wiki/Geometric_mean) is\n * a mean function that is more useful for numbers in different\n * ranges.\n *\n * This is the nth root of the input numbers multiplied by each other.\n *\n * The geometric mean is often useful for\n * **[proportional growth](https://en.wikipedia.org/wiki/Geometric_mean#Proportional_growth)**: given\n * growth rates for multiple years, like _80%, 16.66% and 42.85%_, a simple\n * mean will incorrectly estimate an average growth rate, whereas a geometric\n * mean will correctly estimate a growth rate that, over those years,\n * will yield the same end value.\n *\n * This runs in `O(n)`, linear time, with respect to the length of the array.\n *\n * @param {Array} x sample of one or more data points\n * @returns {number} geometric mean\n * @throws {Error} if x is empty\n * @throws {Error} if x contains a negative number\n * @example\n * var growthRates = [1.80, 1.166666, 1.428571];\n * var averageGrowth = ss.geometricMean(growthRates);\n * var averageGrowthRates = [averageGrowth, averageGrowth, averageGrowth];\n * var startingValue = 10;\n * var startingValueMean = 10;\n * growthRates.forEach(function(rate) {\n * startingValue *= rate;\n * });\n * averageGrowthRates.forEach(function(rate) {\n * startingValueMean *= rate;\n * });\n * startingValueMean === startingValue;\n */\nfunction geometricMean(x) {\n if (x.length === 0) {\n throw new Error(\"geometricMean requires at least one data point\");\n }\n\n // the starting value.\n let value = 1;\n\n for (let i = 0; i < x.length; i++) {\n // the geometric mean is only valid for positive numbers\n if (x[i] < 0) {\n throw new Error(\n \"geometricMean requires only non-negative numbers as input\",\n );\n }\n\n // repeatedly multiply the value by each number\n value *= x[i];\n }\n\n return Math.pow(value, 1 / x.length);\n}\n\nexport default geometricMean;\n","/**\n * The [Harmonic Mean](https://en.wikipedia.org/wiki/Harmonic_mean) is\n * a mean function typically used to find the average of rates.\n * This mean is calculated by taking the reciprocal of the arithmetic mean\n * of the reciprocals of the input numbers.\n *\n * This is a [measure of central tendency](https://en.wikipedia.org/wiki/Central_tendency):\n * a method of finding a typical or central value of a set of numbers.\n *\n * This runs in `O(n)`, linear time, with respect to the length of the array.\n *\n * @param {Array} x sample of one or more data points\n * @returns {number} harmonic mean\n * @throws {Error} if x is empty\n * @throws {Error} if x contains a negative number\n * @example\n * harmonicMean([2, 3]).toFixed(2) // => '2.40'\n */\nfunction harmonicMean(x) {\n if (x.length === 0) {\n throw new Error(\"harmonicMean requires at least one data point\");\n }\n\n let reciprocalSum = 0;\n\n for (let i = 0; i < x.length; i++) {\n // the harmonic mean is only valid for positive numbers\n if (x[i] <= 0) {\n throw new Error(\n \"harmonicMean requires only positive numbers as input\",\n );\n }\n\n reciprocalSum += 1 / x[i];\n }\n\n // divide n by the reciprocal sum\n return x.length / reciprocalSum;\n}\n\nexport default harmonicMean;\n","import jenksBreaks from \"./jenks_breaks.js\";\nimport jenksMatrices from \"./jenks_matrices.js\";\n\n/**\n * The **[jenks natural breaks optimization](http://en.wikipedia.org/wiki/Jenks_natural_breaks_optimization)**\n * is an algorithm commonly used in cartography and visualization to decide\n * upon groupings of data values that minimize variance within themselves\n * and maximize variation between themselves.\n *\n * For instance, cartographers often use jenks in order to choose which\n * values are assigned to which colors in a [choropleth](https://en.wikipedia.org/wiki/Choropleth_map)\n * map.\n *\n * @param {Array} data input data, as an array of number values\n * @param {number} nClasses number of desired classes\n * @returns {Array} array of class break positions\n * // split data into 3 break points\n * jenks([1, 2, 4, 5, 7, 9, 10, 20], 3) // = [1, 7, 20, 20]\n */\nfunction jenks(data, nClasses) {\n if (nClasses > data.length) {\n return null;\n }\n\n // sort data in numerical order, since this is expected\n // by the matrices function\n data = data.slice().sort(function (a, b) {\n return a - b;\n });\n\n // get our basic matrices\n const matrices = jenksMatrices(data, nClasses);\n // we only need lower class limits here\n const lowerClassLimits = matrices.lowerClassLimits;\n\n // extract nClasses out of the computed matrices\n return jenksBreaks(data, lowerClassLimits, nClasses);\n}\n\nexport default jenks;\n","/*\n * Compute Matrices for Jenks\n *\n * Compute the matrices required for Jenks breaks. These matrices\n * can be used for any classing of data with `classes <= nClasses`\n *\n * @private\n */\nfunction jenksMatrices(data, nClasses) {\n // in the original implementation, these matrices are referred to\n // as `LC` and `OP`\n //\n // * lowerClassLimits (LC): optimal lower class limits\n // * varianceCombinations (OP): optimal variance combinations for all classes\n const lowerClassLimits = [];\n const varianceCombinations = [];\n // loop counters\n let i;\n let j;\n // the variance, as computed at each step in the calculation\n let variance = 0;\n\n // Initialize and fill each matrix with zeroes\n for (i = 0; i < data.length + 1; i++) {\n const tmp1 = [];\n const tmp2 = [];\n // despite these arrays having the same values, we need\n // to keep them separate so that changing one does not change\n // the other\n for (j = 0; j < nClasses + 1; j++) {\n tmp1.push(0);\n tmp2.push(0);\n }\n lowerClassLimits.push(tmp1);\n varianceCombinations.push(tmp2);\n }\n\n for (i = 1; i < nClasses + 1; i++) {\n lowerClassLimits[1][i] = 1;\n varianceCombinations[1][i] = 0;\n // in the original implementation, 9999999 is used but\n // since Javascript has `Infinity`, we use that.\n for (j = 2; j < data.length + 1; j++) {\n varianceCombinations[j][i] = Number.POSITIVE_INFINITY;\n }\n }\n\n for (let l = 2; l < data.length + 1; l++) {\n // `SZ` originally. this is the sum of the values seen thus\n // far when calculating variance.\n let sum = 0;\n // `ZSQ` originally. the sum of squares of values seen\n // thus far\n let sumSquares = 0;\n // `WT` originally. This is the number of\n let w = 0;\n // `IV` originally\n let i4 = 0;\n\n // in several instances, you could say `Math.pow(x, 2)`\n // instead of `x * x`, but this is slower in some browsers\n // introduces an unnecessary concept.\n for (let m = 1; m < l + 1; m++) {\n // `III` originally\n const lowerClassLimit = l - m + 1;\n const val = data[lowerClassLimit - 1];\n\n // here we're estimating variance for each potential classing\n // of the data, for each potential number of classes. `w`\n // is the number of data points considered so far.\n w++;\n\n // increase the current sum and sum-of-squares\n sum += val;\n sumSquares += val * val;\n\n // the variance at this point in the sequence is the difference\n // between the sum of squares and the total x 2, over the number\n // of samples.\n variance = sumSquares - (sum * sum) / w;\n\n i4 = lowerClassLimit - 1;\n\n if (i4 !== 0) {\n for (j = 2; j < nClasses + 1; j++) {\n // if adding this element to an existing class\n // will increase its variance beyond the limit, break\n // the class at this point, setting the `lowerClassLimit`\n // at this point.\n if (\n varianceCombinations[l][j] >=\n variance + varianceCombinations[i4][j - 1]\n ) {\n lowerClassLimits[l][j] = lowerClassLimit;\n varianceCombinations[l][j] =\n variance + varianceCombinations[i4][j - 1];\n }\n }\n }\n }\n\n lowerClassLimits[l][1] = 1;\n varianceCombinations[l][1] = variance;\n }\n\n // return the two matrices. for just providing breaks, only\n // `lowerClassLimits` is needed, but variances can be useful to\n // evaluate goodness of fit.\n return {\n lowerClassLimits: lowerClassLimits,\n varianceCombinations: varianceCombinations,\n };\n}\n\nexport default jenksMatrices;\n","/*\n * Pull Breaks Values for Jenks\n *\n * the second part of the jenks recipe: take the calculated matrices\n * and derive an array of n breaks.\n *\n * @private\n */\nfunction jenksBreaks(data, lowerClassLimits, nClasses) {\n let k = data.length;\n const kclass = [];\n let countNum = nClasses;\n\n // the calculation of classes will never include the upper\n // bound, so we need to explicitly set it\n kclass[nClasses] = data[data.length - 1];\n\n // the lowerClassLimits matrix is used as indices into itself\n // here: the `k` variable is reused in each iteration.\n while (countNum > 0) {\n kclass[countNum - 1] = data[lowerClassLimits[k][countNum] - 1];\n k = lowerClassLimits[k][countNum] - 1;\n countNum--;\n }\n\n return kclass;\n}\n\nexport default jenksBreaks;\n","/**\n * [Simple linear regression](http://en.wikipedia.org/wiki/Simple_linear_regression)\n * is a simple way to find a fitted line\n * between a set of coordinates. This algorithm finds the slope and y-intercept of a regression line\n * using the least sum of squares.\n *\n * @param {Array>} data an array of two-element of arrays,\n * like `[[0, 1], [2, 3]]`\n * @returns {Object} object containing slope and intersect of regression line\n * @example\n * linearRegression([[0, 0], [1, 1]]); // => { m: 1, b: 0 }\n */\nfunction linearRegression(data) {\n let m;\n let b;\n\n // Store data length in a local variable to reduce\n // repeated object property lookups\n const dataLength = data.length;\n\n //if there's only one point, arbitrarily choose a slope of 0\n //and a y-intercept of whatever the y of the initial point is\n if (dataLength === 1) {\n m = 0;\n b = data[0][1];\n } else {\n // Initialize our sums and scope the `m` and `b`\n // variables that define the line.\n let sumX = 0;\n let sumY = 0;\n let sumXX = 0;\n let sumXY = 0;\n\n // Use local variables to grab point values\n // with minimal object property lookups\n let point;\n let x;\n let y;\n\n // Gather the sum of all x values, the sum of all\n // y values, and the sum of x^2 and (x*y) for each\n // value.\n //\n // In math notation, these would be SS_x, SS_y, SS_xx, and SS_xy\n for (let i = 0; i < dataLength; i++) {\n point = data[i];\n x = point[0];\n y = point[1];\n\n sumX += x;\n sumY += y;\n\n sumXX += x * x;\n sumXY += x * y;\n }\n\n // `m` is the slope of the regression line\n m =\n (dataLength * sumXY - sumX * sumY) /\n (dataLength * sumXX - sumX * sumX);\n\n // `b` is the y-intercept of the line.\n b = sumY / dataLength - (m * sumX) / dataLength;\n }\n\n // Return both values as an object.\n return {\n m: m,\n b: b,\n };\n}\n\nexport default linearRegression;\n","/**\n * Given the output of `linearRegression`: an object\n * with `m` and `b` values indicating slope and intercept,\n * respectively, generate a line function that translates\n * x values into y values.\n *\n * @param {Object} mb object with `m` and `b` members, representing\n * slope and intersect of desired line\n * @returns {Function} method that computes y-value at any given\n * x-value on the line.\n * @example\n * var l = linearRegressionLine(linearRegression([[0, 0], [1, 1]]));\n * l(0) // = 0\n * l(2) // = 2\n * linearRegressionLine({ b: 0, m: 1 })(1); // => 1\n * linearRegressionLine({ b: 1, m: 1 })(1); // => 2\n */\nfunction linearRegressionLine(mb /*: { b: number, m: number }*/) {\n // Return a function that computes a `y` value for each\n // x value it is given, based on the values of `b` and `a`\n // that we just computed.\n return function (x) {\n return mb.b + mb.m * x;\n };\n}\n\nexport default linearRegressionLine;\n","/**\n * The [log average](https://en.wikipedia.org/wiki/https://en.wikipedia.org/wiki/Geometric_mean#Relationship_with_logarithms)\n * is an equivalent way of computing the geometric mean of an array suitable for large or small products.\n *\n * It's found by calculating the average logarithm of the elements and exponentiating.\n *\n * @param {Array} x sample of one or more data points\n * @returns {number} geometric mean\n * @throws {Error} if x is empty\n * @throws {Error} if x contains a negative number\n */\nfunction logAverage(x) {\n if (x.length === 0) {\n throw new Error(\"logAverage requires at least one data point\");\n }\n\n let value = 0;\n for (let i = 0; i < x.length; i++) {\n if (x[i] < 0) {\n throw new Error(\n \"logAverage requires only non-negative numbers as input\",\n );\n }\n value += Math.log(x[i]);\n }\n\n return Math.exp(value / x.length);\n}\n\nexport default logAverage;\n","/**\n * The [Logit](https://en.wikipedia.org/wiki/Logit)\n * is the inverse of cumulativeStdLogisticProbability,\n * and is also known as the logistic quantile function.\n *\n * @param {number} p\n * @returns {number} logit\n */\nfunction logit(p) {\n if (p <= 0 || p >= 1) {\n throw new Error(\"p must be strictly between zero and one\");\n }\n return Math.log(p / (1 - p));\n}\n\nexport default logit;\n","/**\n * The maximum is the highest number in the array. With a sorted array,\n * the last element in the array is always the largest, so this calculation\n * can be done in one step, or constant time.\n *\n * @param {Array} x input\n * @returns {number} maximum value\n * @example\n * maxSorted([-100, -10, 1, 2, 5]); // => 5\n */\nfunction maxSorted(x) {\n return x[x.length - 1];\n}\n\nexport default maxSorted;\n","import quantileSorted from \"./quantile_sorted.js\";\n\n/**\n * The [median](http://en.wikipedia.org/wiki/Median) is\n * the middle number of a list. This is often a good indicator of 'the middle'\n * when there are outliers that skew the `mean()` value.\n * This is a [measure of central tendency](https://en.wikipedia.org/wiki/Central_tendency):\n * a method of finding a typical or central value of a set of numbers.\n *\n * The median isn't necessarily one of the elements in the list: the value\n * can be the average of two elements if the list has an even length\n * and the two central values are different.\n *\n * @param {Array} sorted input\n * @returns {number} median value\n * @example\n * medianSorted([10, 2, 5, 100, 2, 1]); // => 52.5\n */\nfunction medianSorted(sorted) {\n return quantileSorted(sorted, 0.5);\n}\n\nexport default medianSorted;\n","/**\n * The minimum is the lowest number in the array. With a sorted array,\n * the first element in the array is always the smallest, so this calculation\n * can be done in one step, or constant time.\n *\n * @param {Array} x input\n * @returns {number} minimum value\n * @example\n * minSorted([-100, -10, 1, 2, 5]); // => -100\n */\nfunction minSorted(x) {\n return x[0];\n}\n\nexport default minSorted;\n","import modeSorted from \"./mode_sorted.js\";\nimport numericSort from \"./numeric_sort.js\";\n\n/**\n * The [mode](https://en.wikipedia.org/wiki/Mode_%28statistics%29) is the number\n * that appears in a list the highest number of times.\n * There can be multiple modes in a list: in the event of a tie, this\n * algorithm will return the most recently seen mode.\n *\n * This is a [measure of central tendency](https://en.wikipedia.org/wiki/Central_tendency):\n * a method of finding a typical or central value of a set of numbers.\n *\n * This runs in `O(n log(n))` because it needs to sort the array internally\n * before running an `O(n)` search to find the mode.\n *\n * @param {Array} x input\n * @returns {number} mode\n * @example\n * mode([0, 0, 1]); // => 0\n */\nfunction mode(x) {\n // Sorting the array lets us iterate through it below and be sure\n // that every time we see a new number it's new and we'll never\n // see the same number twice\n return modeSorted(numericSort(x));\n}\n\nexport default mode;\n","/* globals Map: false */\n\n/**\n * The [mode](https://en.wikipedia.org/wiki/Mode_%28statistics%29) is the number\n * that appears in a list the highest number of times.\n * There can be multiple modes in a list: in the event of a tie, this\n * algorithm will return the most recently seen mode.\n *\n * modeFast uses a Map object to keep track of the mode, instead of the approach\n * used with `mode`, a sorted array. As a result, it is faster\n * than `mode` and supports any data type that can be compared with `==`.\n * It also requires a\n * [JavaScript environment with support for Map](https://kangax.github.io/compat-table/es6/#test-Map),\n * and will throw an error if Map is not available.\n *\n * This is a [measure of central tendency](https://en.wikipedia.org/wiki/Central_tendency):\n * a method of finding a typical or central value of a set of numbers.\n *\n * @param {Array<*>} x a sample of one or more data points\n * @returns {?*} mode\n * @throws {ReferenceError} if the JavaScript environment doesn't support Map\n * @throws {Error} if x is empty\n * @example\n * modeFast(['rabbits', 'rabbits', 'squirrels']); // => 'rabbits'\n */\nfunction modeFast(x) {\n // This index will reflect the incidence of different values, indexing\n // them like\n // { value: count }\n const index = new Map();\n\n // A running `mode` and the number of times it has been encountered.\n let mode;\n let modeCount = 0;\n\n for (let i = 0; i < x.length; i++) {\n let newCount = index.get(x[i]);\n if (newCount === undefined) {\n newCount = 1;\n } else {\n newCount++;\n }\n if (newCount > modeCount) {\n mode = x[i];\n modeCount = newCount;\n }\n index.set(x[i], newCount);\n }\n\n if (modeCount === 0) {\n throw new Error(\"mode requires at last one data point\");\n }\n\n return mode;\n}\n\nexport default modeFast;\n","import mean from \"./mean.js\";\nimport shuffleInPlace from \"./shuffle_in_place.js\";\n\n/**\n * Conducts a [permutation test](https://en.wikipedia.org/wiki/Resampling_(statistics)#Permutation_tests)\n * to determine if two data sets are *significantly* different from each other, using\n * the difference of means between the groups as the test statistic.\n * The function allows for the following hypotheses:\n * - two_tail = Null hypothesis: the two distributions are equal.\n * - greater = Null hypothesis: observations from sampleX tend to be smaller than those from sampleY.\n * - less = Null hypothesis: observations from sampleX tend to be greater than those from sampleY.\n * [Learn more about one-tail vs two-tail tests.](https://en.wikipedia.org/wiki/One-_and_two-tailed_tests)\n *\n * @param {Array} sampleX first dataset (e.g. treatment data)\n * @param {Array} sampleY second dataset (e.g. control data)\n * @param {string} alternative alternative hypothesis, either 'two_sided' (default), 'greater', or 'less'\n * @param {number} k number of values in permutation distribution.\n * @param {Function} [randomSource=Math.random] an optional entropy source\n * @returns {number} p-value The probability of observing the difference between groups (as or more extreme than what we did), assuming the null hypothesis.\n *\n * @example\n * var control = [2, 5, 3, 6, 7, 2, 5];\n * var treatment = [20, 5, 13, 12, 7, 2, 2];\n * permutationTest(control, treatment); // ~0.1324\n */\nfunction permutationTest(sampleX, sampleY, alternative, k, randomSource) {\n // Set default arguments\n if (k === undefined) {\n k = 10000;\n }\n if (alternative === undefined) {\n alternative = \"two_side\";\n }\n if (\n alternative !== \"two_side\" &&\n alternative !== \"greater\" &&\n alternative !== \"less\"\n ) {\n throw new Error(\n \"`alternative` must be either 'two_side', 'greater', or 'less'.\",\n );\n }\n\n // get means for each sample\n const meanX = mean(sampleX);\n const meanY = mean(sampleY);\n\n // calculate initial test statistic. This will be our point of comparison with\n // the generated test statistics.\n const testStatistic = meanX - meanY;\n\n // create test-statistic distribution\n const testStatDsn = new Array(k);\n\n // combine datsets so we can easily shuffle later\n const allData = sampleX.concat(sampleY);\n const midIndex = Math.floor(allData.length / 2);\n\n for (let i = 0; i < k; i++) {\n // 1. shuffle data assignments\n shuffleInPlace(allData, randomSource);\n const permLeft = allData.slice(0, midIndex);\n const permRight = allData.slice(midIndex, allData.length);\n\n // 2.re-calculate test statistic\n const permTestStatistic = mean(permLeft) - mean(permRight);\n\n // 3. store test statistic to build test statistic distribution\n testStatDsn[i] = permTestStatistic;\n }\n\n // Calculate p-value depending on alternative\n // For this test, we calculate the percentage of 'extreme' test statistics (subject to our hypothesis)\n // more info on permutation test p-value calculations: https://onlinecourses.science.psu.edu/stat464/node/35\n let numExtremeTStats = 0;\n if (alternative === \"two_side\") {\n for (let i = 0; i <= k; i++) {\n if (Math.abs(testStatDsn[i]) >= Math.abs(testStatistic)) {\n numExtremeTStats += 1;\n }\n }\n } else if (alternative === \"greater\") {\n for (let i = 0; i <= k; i++) {\n if (testStatDsn[i] >= testStatistic) {\n numExtremeTStats += 1;\n }\n }\n } else {\n // alternative === 'less'\n for (let i = 0; i <= k; i++) {\n /* c8 ignore start */\n if (testStatDsn[i] <= testStatistic) {\n numExtremeTStats += 1;\n }\n /* c8 ignore end */\n }\n }\n\n return numExtremeTStats / k;\n}\n\nexport default permutationTest;\n","/**\n * Implementation of [Heap's Algorithm](https://en.wikipedia.org/wiki/Heap%27s_algorithm)\n * for generating permutations.\n *\n * @param {Array} elements any type of data\n * @returns {Array} array of permutations\n */\nfunction permutationsHeap(elements) {\n const indexes = new Array(elements.length);\n const permutations = [elements.slice()];\n\n for (let i = 0; i < elements.length; i++) {\n indexes[i] = 0;\n }\n\n for (let i = 0; i < elements.length; ) {\n if (indexes[i] < i) {\n // At odd indexes, swap from indexes[i] instead\n // of from the beginning of the array\n let swapFrom = 0;\n if (i % 2 !== 0) {\n swapFrom = indexes[i];\n }\n\n // swap between swapFrom and i, using\n // a temporary variable as storage.\n const temp = elements[swapFrom];\n elements[swapFrom] = elements[i];\n elements[i] = temp;\n\n permutations.push(elements.slice());\n indexes[i]++;\n i = 0;\n } else {\n indexes[i] = 0;\n i++;\n }\n }\n\n return permutations;\n}\n\nexport default permutationsHeap;\n","import epsilon from \"./epsilon.js\";\n\n/**\n * The [Poisson Distribution](http://en.wikipedia.org/wiki/Poisson_distribution)\n * is a discrete probability distribution that expresses the probability\n * of a given number of events occurring in a fixed interval of time\n * and/or space if these events occur with a known average rate and\n * independently of the time since the last event.\n *\n * The Poisson Distribution is characterized by the strictly positive\n * mean arrival or occurrence rate, `λ`.\n *\n * @param {number} lambda location poisson distribution\n * @returns {number[]} values of poisson distribution at that point\n */\nfunction poissonDistribution(lambda) /*: ?number[] */ {\n // Check that lambda is strictly positive\n if (lambda <= 0) {\n return undefined;\n }\n\n // our current place in the distribution\n let x = 0;\n // and we keep track of the current cumulative probability, in\n // order to know when to stop calculating chances.\n let cumulativeProbability = 0;\n // the calculated cells to be returned\n const cells = [];\n let factorialX = 1;\n\n // This algorithm iterates through each potential outcome,\n // until the `cumulativeProbability` is very close to 1, at\n // which point we've defined the vast majority of outcomes\n do {\n // a [probability mass function](https://en.wikipedia.org/wiki/Probability_mass_function)\n cells[x] = (Math.exp(-lambda) * Math.pow(lambda, x)) / factorialX;\n cumulativeProbability += cells[x];\n x++;\n factorialX *= x;\n // when the cumulativeProbability is nearly 1, we've calculated\n // the useful range of this distribution\n } while (cumulativeProbability < 1 - epsilon);\n\n return cells;\n}\n\nexport default poissonDistribution;\n","import epsilon from \"./epsilon.js\";\nimport inverseErrorFunction from \"./inverse_error_function.js\";\n\n/**\n * The [Probit](http://en.wikipedia.org/wiki/Probit)\n * is the inverse of cumulativeStdNormalProbability(),\n * and is also known as the normal quantile function.\n *\n * It returns the number of standard deviations from the mean\n * where the p'th quantile of values can be found in a normal distribution.\n * So, for example, probit(0.5 + 0.6827/2) ≈ 1 because 68.27% of values are\n * normally found within 1 standard deviation above or below the mean.\n *\n * @param {number} p\n * @returns {number} probit\n */\nfunction probit(p) {\n if (p === 0) {\n p = epsilon;\n } else if (p >= 1) {\n p = 1 - epsilon;\n }\n return Math.sqrt(2) * inverseErrorFunction(2 * p - 1);\n}\n\nexport default probit;\n","/**\n * The [product](https://en.wikipedia.org/wiki/Product_(mathematics)) of an array\n * is the result of multiplying all numbers together, starting using one as the multiplicative identity.\n *\n * This runs in `O(n)`, linear time, with respect to the length of the array.\n *\n * @param {Array} x input\n * @return {number} product of all input numbers\n * @example\n * product([1, 2, 3, 4]); // => 24\n */\nfunction product(x) {\n let value = 1;\n for (let i = 0; i < x.length; i++) {\n value *= x[i];\n }\n return value;\n}\n\nexport default product;\n","import numericSort from \"./numeric_sort.js\";\nimport quantileRankSorted from \"./quantile_rank_sorted.js\";\n\n/**\n * This function returns the quantile in which one would find the given value in\n * the given array. It will copy and sort your array before each run, so\n * if you know your array is already sorted, you should use `quantileRankSorted`\n * instead.\n *\n * @param {Array} x input\n * @returns {number} value value\n * @example\n * quantileRank([4, 3, 1, 2], 3); // => 0.75\n * quantileRank([4, 3, 2, 3, 1], 3); // => 0.7\n * quantileRank([2, 4, 1, 3], 6); // => 1\n * quantileRank([5, 3, 1, 2, 3], 4); // => 0.8\n */\nfunction quantileRank(x, value) {\n // Cloning and sorting the array\n const sortedCopy = numericSort(x);\n\n return quantileRankSorted(sortedCopy, value);\n}\n\nexport default quantileRank;\n","/**\n * The [R Squared](http://en.wikipedia.org/wiki/Coefficient_of_determination)\n * value of data compared with a function `f`\n * is the sum of the squared differences between the prediction\n * and the actual value.\n *\n * @param {Array>} x input data: this should be doubly-nested\n * @param {Function} func function called on `[i][0]` values within the dataset\n * @returns {number} r-squared value\n * @example\n * var samples = [[0, 0], [1, 1]];\n * var regressionLine = linearRegressionLine(linearRegression(samples));\n * rSquared(samples, regressionLine); // = 1 this line is a perfect fit\n */\nfunction rSquared(x, func) {\n if (x.length < 2) {\n return 1;\n }\n\n // Compute the average y value for the actual\n // data set in order to compute the\n // _total sum of squares_\n let sum = 0;\n for (let i = 0; i < x.length; i++) {\n sum += x[i][1];\n }\n const average = sum / x.length;\n\n // Compute the total sum of squares - the\n // squared difference between each point\n // and the average of all points.\n let sumOfSquares = 0;\n for (let j = 0; j < x.length; j++) {\n sumOfSquares += Math.pow(average - x[j][1], 2);\n }\n\n // Finally estimate the error: the squared\n // difference between the estimate and the actual data\n // value at each point.\n let err = 0;\n for (let k = 0; k < x.length; k++) {\n err += Math.pow(x[k][1] - func(x[k][0]), 2);\n }\n\n // As the error grows larger, its ratio to the\n // sum of squares increases and the r squared\n // value grows lower.\n return 1 - err / sumOfSquares;\n}\n\nexport default rSquared;\n","import mean from \"./mean.js\";\n\n/**\n * [Kurtosis](http://en.wikipedia.org/wiki/Kurtosis) is\n * a measure of the heaviness of a distribution's tails relative to its\n * variance. The kurtosis value can be positive or negative, or even undefined.\n *\n * Implementation is based on Fisher's excess kurtosis definition and uses\n * unbiased moment estimators. This is the version found in Excel and available\n * in several statistical packages, including SAS and SciPy.\n *\n * @param {Array} x a sample of 4 or more data points\n * @returns {number} sample kurtosis\n * @throws {Error} if x has length less than 4\n * @example\n * sampleKurtosis([1, 2, 2, 3, 5]); // => 1.4555765595463122\n */\nfunction sampleKurtosis(x) {\n const n = x.length;\n\n if (n < 4) {\n throw new Error(\"sampleKurtosis requires at least four data points\");\n }\n\n const meanValue = mean(x);\n let tempValue;\n let secondCentralMoment = 0;\n let fourthCentralMoment = 0;\n\n for (let i = 0; i < n; i++) {\n tempValue = x[i] - meanValue;\n secondCentralMoment += tempValue * tempValue;\n fourthCentralMoment += tempValue * tempValue * tempValue * tempValue;\n }\n\n return (\n ((n - 1) / ((n - 2) * (n - 3))) *\n ((n * (n + 1) * fourthCentralMoment) /\n (secondCentralMoment * secondCentralMoment) -\n 3 * (n - 1))\n );\n}\n\nexport default sampleKurtosis;\n","import sampleCorrelation from \"./sample_correlation.js\";\n\n/**\n * The [rank correlation](https://en.wikipedia.org/wiki/Rank_correlation) is\n * a measure of the strength of monotonic relationship between two arrays\n *\n * @param {Array} x first input\n * @param {Array} y second input\n * @returns {number} sample rank correlation\n */\nfunction sampleRankCorrelation(x, y) {\n const xIndexes = x\n .map((value, index) => [value, index])\n .sort((a, b) => a[0] - b[0])\n .map((pair) => pair[1]);\n const yIndexes = y\n .map((value, index) => [value, index])\n .sort((a, b) => a[0] - b[0])\n .map((pair) => pair[1]);\n\n // At this step, we have an array of indexes\n // that map from sorted numbers to their original indexes. We reverse\n // that so that it is an array of the sorted destination index.\n const xRanks = Array(xIndexes.length);\n const yRanks = Array(xIndexes.length);\n for (let i = 0; i < xIndexes.length; i++) {\n xRanks[xIndexes[i]] = i;\n yRanks[yIndexes[i]] = i;\n }\n\n return sampleCorrelation(xRanks, yRanks);\n}\n\nexport default sampleRankCorrelation;\n","import mean from \"./mean.js\";\n\n/**\n * [Skewness](http://en.wikipedia.org/wiki/Skewness) is\n * a measure of the extent to which a probability distribution of a\n * real-valued random variable \"leans\" to one side of the mean.\n * The skewness value can be positive or negative, or even undefined.\n *\n * Implementation is based on the adjusted Fisher-Pearson standardized\n * moment coefficient, which is the version found in Excel and several\n * statistical packages including Minitab, SAS and SPSS.\n *\n * @since 4.1.0\n * @param {Array} x a sample of 3 or more data points\n * @returns {number} sample skewness\n * @throws {Error} if x has length less than 3\n * @example\n * sampleSkewness([2, 4, 6, 3, 1]); // => 0.590128656384365\n */\nfunction sampleSkewness(x) {\n if (x.length < 3) {\n throw new Error(\"sampleSkewness requires at least three data points\");\n }\n\n const meanValue = mean(x);\n let tempValue;\n let sumSquaredDeviations = 0;\n let sumCubedDeviations = 0;\n\n for (let i = 0; i < x.length; i++) {\n tempValue = x[i] - meanValue;\n sumSquaredDeviations += tempValue * tempValue;\n sumCubedDeviations += tempValue * tempValue * tempValue;\n }\n\n // this is Bessels' Correction: an adjustment made to sample statistics\n // that allows for the reduced degree of freedom entailed in calculating\n // values from samples rather than complete populations.\n const besselsCorrection = x.length - 1;\n\n // Find the mean value of that list\n const theSampleStandardDeviation = Math.sqrt(\n sumSquaredDeviations / besselsCorrection,\n );\n\n const n = x.length;\n const cubedS = Math.pow(theSampleStandardDeviation, 3);\n\n return (n * sumCubedDeviations) / ((n - 1) * (n - 2) * cubedS);\n}\n\nexport default sampleSkewness;\n","/**\n * Sampling with replacement is a type of sampling that allows the same\n * item to be picked out of a population more than once.\n *\n * @param {Array<*>} x an array of any kind of value\n * @param {number} n count of how many elements to take\n * @param {Function} [randomSource=Math.random] an optional entropy source that\n * returns numbers between 0 inclusive and 1 exclusive: the range [0, 1)\n * @return {Array} n sampled items from the population\n * @example\n * var values = [1, 2, 3, 4];\n * sampleWithReplacement(values, 2); // returns 2 random values, like [2, 4];\n */\nfunction sampleWithReplacement(x, n, randomSource) {\n if (x.length === 0) {\n return [];\n }\n\n // a custom random number source can be provided if you want to use\n // a fixed seed or another random number generator, like\n // [random-js](https://www.npmjs.org/package/random-js)\n randomSource = randomSource || Math.random;\n\n const length = x.length;\n const sample = [];\n\n for (let i = 0; i < n; i++) {\n const index = Math.floor(randomSource() * length);\n\n sample.push(x[index]);\n }\n\n return sample;\n}\n\nexport default sampleWithReplacement;\n","import max from \"./max.js\";\nimport silhouette from \"./silhouette.js\";\n\n/**\n * Calculate the [silhouette metric](https://en.wikipedia.org/wiki/Silhouette_(clustering))\n * for a set of N-dimensional points arranged in groups. The metric is the largest\n * individual silhouette value for the data.\n *\n * @param {Array>} points N-dimensional coordinates of points.\n * @param {Array} labels Labels of points. This must be the same length as `points`,\n * and values must lie in [0..G-1], where G is the number of groups.\n * @return {number} The silhouette metric for the groupings.\n *\n * @example\n * silhouetteMetric([[0.25], [0.75]], [0, 0]); // => 1.0\n */\nfunction silhouetteMetric(points, labels) {\n const values = silhouette(points, labels);\n return max(values);\n}\n\nexport default silhouetteMetric;\n","/**\n * When removing a value from a list, one does not have to necessary\n * recompute the mean of the list in linear time. They can instead use\n * this function to compute the new mean by providing the current mean,\n * the number of elements in the list that produced it and the value to remove.\n *\n * @since 3.0.0\n * @param {number} mean current mean\n * @param {number} n number of items in the list\n * @param {number} value the value to remove\n * @returns {number} the new mean\n *\n * @example\n * subtractFromMean(20.5, 6, 53); // => 14\n */\nfunction subtractFromMean(mean, n, value) {\n return (mean * n - value) / (n - 1);\n}\n\nexport default subtractFromMean;\n","import mean from \"./mean.js\";\nimport standardDeviation from \"./standard_deviation.js\";\n\n/**\n * This is to compute [a one-sample t-test](https://en.wikipedia.org/wiki/Student%27s_t-test#One-sample_t-test), comparing the mean\n * of a sample to a known value, x.\n *\n * in this case, we're trying to determine whether the\n * population mean is equal to the value that we know, which is `x`\n * here. Usually the results here are used to look up a\n * [p-value](http://en.wikipedia.org/wiki/P-value), which, for\n * a certain level of significance, will let you determine that the\n * null hypothesis can or cannot be rejected.\n *\n * @param {Array} x sample of one or more numbers\n * @param {number} expectedValue expected value of the population mean\n * @returns {number} value\n * @example\n * tTest([1, 2, 3, 4, 5, 6], 3.385).toFixed(2); // => '0.16'\n */\nfunction tTest(x, expectedValue) {\n // The mean of the sample\n const sampleMean = mean(x);\n\n // The standard deviation of the sample\n const sd = standardDeviation(x);\n\n // Square root the length of the sample\n const rootN = Math.sqrt(x.length);\n\n // returning the t value\n return (sampleMean - expectedValue) / (sd / rootN);\n}\n\nexport default tTest;\n","import mean from \"./mean.js\";\nimport sampleVariance from \"./sample_variance.js\";\n\n/**\n * This is to compute [two sample t-test](http://en.wikipedia.org/wiki/Student's_t-test).\n * Tests whether \"mean(X)-mean(Y) = difference\", (\n * in the most common case, we often have `difference == 0` to test if two samples\n * are likely to be taken from populations with the same mean value) with\n * no prior knowledge on standard deviations of both samples\n * other than the fact that they have the same standard deviation.\n *\n * Usually the results here are used to look up a\n * [p-value](http://en.wikipedia.org/wiki/P-value), which, for\n * a certain level of significance, will let you determine that the\n * null hypothesis can or cannot be rejected.\n *\n * `diff` can be omitted if it equals 0.\n *\n * [This is used to reject](https://en.wikipedia.org/wiki/Exclusion_of_the_null_hypothesis)\n * a null hypothesis that the two populations that have been sampled into\n * `sampleX` and `sampleY` are equal to each other.\n *\n * @param {Array} sampleX a sample as an array of numbers\n * @param {Array} sampleY a sample as an array of numbers\n * @param {number} [difference=0]\n * @returns {number|null} test result\n *\n * @example\n * tTestTwoSample([1, 2, 3, 4], [3, 4, 5, 6], 0); // => -2.1908902300206643\n */\nfunction tTestTwoSample(sampleX, sampleY, difference) {\n const n = sampleX.length;\n const m = sampleY.length;\n\n // If either sample doesn't actually have any values, we can't\n // compute this at all, so we return `null`.\n if (!n || !m) {\n return null;\n }\n\n // default difference (mu) is zero\n if (!difference) {\n difference = 0;\n }\n\n const meanX = mean(sampleX);\n const meanY = mean(sampleY);\n const sampleVarianceX = sampleVariance(sampleX);\n const sampleVarianceY = sampleVariance(sampleY);\n\n if (\n typeof meanX === \"number\" &&\n typeof meanY === \"number\" &&\n typeof sampleVarianceX === \"number\" &&\n typeof sampleVarianceY === \"number\"\n ) {\n const weightedVariance =\n ((n - 1) * sampleVarianceX + (m - 1) * sampleVarianceY) /\n (n + m - 2);\n\n return (\n (meanX - meanY - difference) /\n Math.sqrt(weightedVariance * (1 / n + 1 / m))\n );\n }\n}\n\nexport default tTestTwoSample;\n","/**\n * This function calculates the Wilcoxon rank sum statistic for the first sample\n * with respect to the second. The Wilcoxon rank sum test is a non-parametric\n * alternative to the t-test which is equivalent to the\n * [Mann-Whitney U test](https://en.wikipedia.org/wiki/Mann%E2%80%93Whitney_U_test).\n * The statistic is calculated by pooling all the observations together, ranking them,\n * and then summing the ranks associated with one of the samples. If this rank sum is\n * sufficiently large or small we reject the hypothesis that the two samples come\n * from the same distribution in favor of the alternative that one is shifted with\n * respect to the other.\n *\n * @param {Array} sampleX a sample as an array of numbers\n * @param {Array} sampleY a sample as an array of numbers\n * @returns {number} rank sum for sampleX\n *\n * @example\n * wilcoxonRankSum([1, 4, 8], [9, 12, 15]); // => 6\n */\nfunction wilcoxonRankSum(sampleX, sampleY) {\n if (!sampleX.length || !sampleY.length) {\n throw new Error(\"Neither sample can be empty\");\n }\n\n const pooledSamples = sampleX\n .map((x) => ({ label: \"x\", value: x }))\n .concat(sampleY.map((y) => ({ label: \"y\", value: y })))\n .sort((a, b) => a.value - b.value);\n\n for (let rank = 0; rank < pooledSamples.length; rank++) {\n pooledSamples[rank].rank = rank;\n }\n\n let tiedRanks = [pooledSamples[0].rank];\n for (let i = 1; i < pooledSamples.length; i++) {\n if (pooledSamples[i].value === pooledSamples[i - 1].value) {\n tiedRanks.push(pooledSamples[i].rank);\n if (i === pooledSamples.length - 1) {\n replaceRanksInPlace(pooledSamples, tiedRanks);\n }\n } else if (tiedRanks.length > 1) {\n replaceRanksInPlace(pooledSamples, tiedRanks);\n } else {\n tiedRanks = [pooledSamples[i].rank];\n }\n }\n\n function replaceRanksInPlace(pooledSamples, tiedRanks) {\n const average = (tiedRanks[0] + tiedRanks[tiedRanks.length - 1]) / 2;\n for (let i = 0; i < tiedRanks.length; i++) {\n pooledSamples[tiedRanks[i]].rank = average;\n }\n }\n\n let rankSum = 0;\n\n for (let i = 0; i < pooledSamples.length; i++) {\n const sample = pooledSamples[i];\n if (sample.label === \"x\") {\n rankSum += sample.rank + 1;\n }\n }\n\n return rankSum;\n}\n\nexport default wilcoxonRankSum;\n","/**\n * The [Z-Score, or Standard Score](http://en.wikipedia.org/wiki/Standard_score).\n *\n * The standard score is the number of standard deviations an observation\n * or datum is above or below the mean. Thus, a positive standard score\n * represents a datum above the mean, while a negative standard score\n * represents a datum below the mean. It is a dimensionless quantity\n * obtained by subtracting the population mean from an individual raw\n * score and then dividing the difference by the population standard\n * deviation.\n *\n * The z-score is only defined if one knows the population parameters;\n * if one only has a sample set, then the analogous computation with\n * sample mean and sample standard deviation yields the\n * Student's t-statistic.\n *\n * @param {number} x\n * @param {number} mean\n * @param {number} standardDeviation\n * @return {number} z score\n * @example\n * zScore(78, 80, 5); // => -0.4\n */\nfunction zScore(x, mean, standardDeviation) {\n return (x - mean) / standardDeviation;\n}\n\nexport default zScore;\n"],"names":["sum","x","length","let","transition","correction","Number","NaN","i","Math","abs","mean","Error","sumNthPowerDeviations","n","const","tempValue","meanValue","pow","variance","standardDeviation","v","sqrt","modeSorted","sorted","last","value","maxSeen","seenThis","numericSort","slice","sort","a","b","min","max","sumSimple","quantileSorted","p","idx","ceil","quickselect","arr","k","left","right","m","z","log","s","exp","sd","floor","t","j","swap","tmp","quantile","copy","Array","isArray","indices","push","quantileIndex","compare","stack","r","pop","l","quantileSelect","multiQuantileSelect","results","len","quantileRankSorted","mid","lo","hi","lowerBound","u","upperBound","interquartileRange","q1","q2","median","medianAbsoluteDeviation","medianValue","medianAbsoluteDeviations","shuffleInPlace","randomSource","random","temporary","index","shuffle","sample","makeMatrix","columns","rows","matrix","column","uniqueCountSorted","lastSeenValue","uniqueValueCount","ssq","sums","sumsOfSquares","sji","muji","fillMatrixColumn","iMin","iMax","cluster","backtrackMatrix","jlow","ssqjlow","ssqj","jhigh","sampleCovariance","y","xmean","ymean","sampleVariance","sampleStandardDeviation","sampleVarianceX","sampleCorrelation","combineMeans","mean1","n1","mean2","n2","meanSimple","rootMeanSquare","sumOfSquares","BayesianClassifier","this","totalCount","data","prototype","train","item","category","undefined","score","odds","oddsSums","combination","PerceptronModel","weights","bias","predict","features","label","prediction","gradient","epsilon","factorial","accumulator","COEFFICIENTS","LOGSQRT2PI","PI","chiSquaredDistributionTable","SQRT_2PI","kernels","gaussian","bandwidthMethods","nrd","stddev","iqr","kernelDensityEstimation","X","kernel","bandwidthMethod","kernelFn","bandwidth","cumulativeDistribution","round","standardNormalTable","errorFunction","tau","inverseErrorFunction","inv","sign","TypeError","euclideanDistance","diff","labelPoints","points","centroids","map","minDist","MAX_VALUE","dist","calculateCentroids","labels","numCluster","dimension","counts","fill","numPoints","point","current","centroid","calculateChange","total","silhouette","groupings","numGroups","result","createGroups","distances","calculateAllDistances","meanDistanceFromPointToGroup","meanDistanceToNearestGroup","which","d","group","relativeError","actual","expected","newValue","tolerance","trials","probability","cumulativeProbability","cells","binomialCoefficient","func","start","end","maxIterations","errorTolerance","output","distributionType","significance","chiSquared","hypothesizedDistribution","observedFrequencies","expectedFrequencies","degreesOfFreedom","chunkSize","nClusters","nValues","shift","shiftedValue","fillMatrices","clusters","clusterRight","clusterLeft","combinations","subI","subsetCombinations","next","combinationList","unshift","combinationsReplacement","concat","variance1","variance2","newMean","absZ","nClasses","theMin","theMax","breaks","breakSize","gamma","isInteger","sin","seriesDenom","E","POSITIVE_INFINITY","g","reciprocalSum","matrices","lowerClassLimits","varianceCombinations","tmp1","tmp2","sumSquares","w","i4","lowerClassLimit","val","jenksMatrices","kclass","countNum","jenksBreaks","oldCentroids","newCentroids","change","dataLength","sumX","sumY","sumXX","sumXY","mb","mode","Map","modeCount","newCount","get","set","sampleX","sampleY","alternative","testStatistic","testStatDsn","allData","midIndex","permLeft","permRight","permTestStatistic","numExtremeTStats","elements","indexes","permutations","swapFrom","temp","lambda","factorialX","average","err","secondCentralMoment","fourthCentralMoment","xIndexes","pair","yIndexes","xRanks","yRanks","sumSquaredDeviations","sumCubedDeviations","besselsCorrection","theSampleStandardDeviation","expectedValue","difference","meanX","meanY","sampleVarianceY","weightedVariance","pooledSamples","rank","tiedRanks","replaceRanksInPlace","rankSum"],"mappings":"0OAkBA,SAASA,EAAIC,GAET,GAAiB,IAAbA,EAAEC,OACF,OAAO,EAIXC,IAKIC,EALAJ,EAAMC,EAAE,GAGRI,EAAa,EAIjB,GAAmB,iBAARL,EACP,OAAOM,OAAOC,IAGlB,IAAKJ,IAAIK,EAAI,EAAGA,EAAIP,EAAEC,OAAQM,IAAK,CAC/B,GAAoB,iBAATP,EAAEO,GACT,OAAOF,OAAOC,IAElBH,EAAaJ,EAAMC,EAAEO,GAIjBC,KAAKC,IAAIV,IAAQS,KAAKC,IAAIT,EAAEO,IAC5BH,GAAcL,EAAMI,EAAaH,EAAEO,GAEnCH,GAAcJ,EAAEO,GAAKJ,EAAaJ,EAGtCA,EAAMI,CACT,CAGD,OAAOJ,EAAMK,CACjB,CCvCA,SAASM,EAAKV,GACV,GAAiB,IAAbA,EAAEC,OACF,MAAM,IAAIU,MAAM,yCAGpB,OAAOZ,EAAIC,GAAKA,EAAEC,MACtB,CCLA,SAASW,EAAsBZ,EAAGa,GAC9BC,IAEIC,EACAR,EAHES,EAAYN,EAAKV,GACnBD,EAAM,EAOV,GAAU,IAANc,EACA,IAAKN,EAAI,EAAGA,EAAI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ACN,KAAO,MACP,IAAM,MACN,KAAO,OAEX,EAAG,CACC,KAAO,IACP,IAAM,IACN,KAAO,KACP,IAAM,KACN,GAAK,IACL,GAAK,KACL,GAAK,MACL,IAAM,MACN,KAAO,MACP,IAAM,MACN,KAAO,OAEX,EAAG,CACC,KAAO,IACP,IAAM,KACN,KAAO,KACP,IAAM,KACN,GAAK,KACL,GAAK,KACL,GAAK,MACL,IAAM,MACN,KAAO,MACP,IAAM,MACN,KAAO,OAEX,EAAG,CACC,KAAO,KACP,IAAM,KACN,KAAO,KACP,IAAM,KACN,GAAK,KACL,GAAK,KACL,GAAK,MACL,IAAM,MACN,KAAO,MACP,IAAM,MACN,KAAO,OAEX,EAAG,CACC,KAAO,KACP,IAAM,KACN,KAAO,IACP,IAAM,KACN,GAAK,KACL,GAAK,KACL,GAAK,MACL,IAAM,MACN,KAAO,MACP,IAAM,MACN,KAAO,OAEX,GAAI,CACA,KAAO,KACP,IAAM,KACN,KAAO,KACP,IAAM,KACN,GAAK,KACL,GAAK,KACL,GAAK,MACL,IAAM,MACN,KAAO,MACP,IAAM,MACN,KAAO,OAEX,GAAI,CACA,KAAO,IACP,IAAM,KACN,KAAO,KACP,IAAM,KACN,GAAK,KACL,GAAK,MACL,GAAK,MACL,IAAM,MACN,KAAO,MACP,IAAM,MACN,KAAO,OAEX,GAAI,CACA,KAAO,KACP,IAAM,KACN,KAAO,IACP,IAAM,KACN,GAAK,IACL,GAAK,MACL,GAAK,MACL,IAAM,MACN,KAAO,MACP,IAAM,MACN,KAAO,MAEX,GAAI,CACA,KAAO,KACP,IAAM,KACN,KAAO,KACP,IAAM,KACN,GAAK,KACL,GAAK,MACL,GAAK,MACL,IAAM,MACN,KAAO,MACP,IAAM,MACN,KAAO,OAEX,GAAI,CACA,KAAO,KACP,IAAM,KACN,KAAO,KACP,IAAM,KACN,GAAK,KACL,GAAK,MACL,GAAK,MACL,IAAM,MACN,KAAO,MACP,IAAM,MACN,KAAO,OAEX,GAAI,CACA,KAAO,IACP,IAAM,KACN,KAAO,KACP,IAAM,KACN,GAAK,KACL,GAAK,MACL,GAAK,MACL,IAAM,GACN,KAAO,MACP,IAAM,MACN,KAAO,MAEX,GAAI,CACA,KAAO,KACP,IAAM,KACN,KAAO,KACP,IAAM,KACN,GAAK,KACL,GAAK,MACL,GAAK,MACL,IAAM,KACN,KAAO,MACP,IAAM,GACN,KAAO,OAEX,GAAI,CACA,KAAO,IACP,IAAM,KACN,KAAO,KACP,IAAM,KACN,GAAK,MACL,GAAK,MACL,GAAK,MACL,IAAM,MACN,KAAO,MACP,IAAM,MACN,KAAO,OAEX,GAAI,CACA,KAAO,KACP,IAAM,KACN,KAAO,KACP,IAAM,KACN,GAAK,MACL,GAAK,MACL,GAAK,MACL,IAAM,MACN,KAAO,MACP,IAAM,MACN,KAAO,OAEX,GAAI,CACA,KAAO,KACP,IAAM,KACN,KAAO,KACP,IAAM,MACN,GAAK,MACL,GAAK,MACL,GAAK,KACL,IAAM,MACN,KAAO,MACP,IAAM,MACN,KAAO,OAEX,GAAI,CACA,KAAO,KACP,IAAM,KACN,KAAO,KACP,IAAM,MACN,GAAK,MACL,GAAK,MACL,GAAK,MACL,IAAM,MACN,KAAO,MACP,IAAM,MACN,KAAO,IAEX,GAAI,CACA,KAAO,KACP,IAAM,IACN,KAAO,MACP,IAAM,MACN,GAAK,MACL,GAAK,MACL,GAAK,MACL,IAAM,MACN,KAAO,MACP,IAAM,MACN,KAAO,MAEX,GAAI,CACA,KAAO,KACP,IAAM,KACN,KAAO,MACP,IAAM,MACN,GAAK,MACL,GAAK,MACL,GAAK,MACL,IAAM,MACN,KAAO,MACP,IAAM,MACN,KAAO,MAEX,GAAI,CACA,KAAO,KACP,IAAM,KACN,KAAO,MACP,IAAM,MACN,GAAK,MACL,GAAK,MACL,GAAK,MACL,IAAM,MACN,KAAO,MACP,IAAM,MACN,KAAO,OAEX,GAAI,CACA,KAAO,KACP,IAAM,MACN,KAAO,KACP,IAAM,MACN,GAAK,MACL,GAAK,MACL,GAAK,KACL,IAAM,MACN,KAAO,MACP,IAAM,MACN,KAAO,OAEX,GAAI,CACA,KAAO,MACP,IAAM,MACN,KAAO,MACP,IAAM,MACN,GAAK,MACL,GAAK,MACL,GAAK,MACL,IAAM,MACN,KAAO,MACP,IAAM,MACN,KAAO,OAEX,GAAI,CACA,KAAO,MACP,IAAM,KACN,KAAO,MACP,IAAM,MACN,GAAK,MACL,GAAK,MACL,GAAK,MACL,IAAM,MACN,KAAO,MACP,IAAM,MACN,KAAO,OAEX,GAAI,CACA,KAAO,MACP,IAAM,MACN,KAAO,MACP,IAAM,MACN,GAAK,MACL,GAAK,MACL,GAAK,MACL,IAAM,MACN,KAAO,MACP,IAAM,MACN,KAAO,OAEX,GAAI,CACA,KAAO,MACP,IAAM,MACN,KAAO,MACP,IAAM,MACN,GAAK,MACL,GAAK,MACL,GAAK,MACL,IAAM,MACN,KAAO,MACP,IAAM,MACN,KAAO,OAEX,GAAI,CACA,KAAO,MACP,IAAM,MACN,KAAO,MACP,IAAM,MACN,GAAK,MACL,GAAK,MACL,GAAK,MACL,IAAM,MACN,KAAO,MACP,IAAM,MACN,KAAO,OAEX,GAAI,CACA,KAAO,MACP,IAAM,MACN,KAAO,MACP,IAAM,MACN,GAAK,KACL,GAAK,MACL,GAAK,MACL,IAAM,MACN,KAAO,MACP,IAAM,MACN,KAAO,OAEX,GAAI,CACA,KAAO,MACP,IAAM,MACN,KAAO,MACP,IAAM,MACN,GAAK,MACL,GAAK,MACL,GAAK,MACL,IAAM,MACN,KAAO,MACP,IAAM,MACN,KAAO,OAEX,GAAI,CACA,KAAO,MACP,IAAM,MACN,KAAO,MACP,IAAM,MACN,GAAK,MACL,GAAK,MACL,GAAK,MACL,IAAM,KACN,KAAO,MACP,IAAM,MACN,KAAO,OAEX,GAAI,CACA,KAAO,MACP,IAAM,MACN,KAAO,MACP,IAAM,MACN,GAAK,MACL,GAAK,MACL,GAAK,KACL,IAAM,MACN,KAAO,KACP,IAAM,MACN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