@datagrok/eda 1.4.7 → 1.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/dist/package.js +1 -1
- package/dist/package.js.map +1 -1
- package/package.json +6 -5
- package/src/package.g.ts +1 -0
- package/src/package.ts +4 -3
- package/test-console-output-1.log +45 -45
- package/test-record-1.mp4 +0 -0
package/dist/package.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var eda;(()=>{var t={540:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},934:function(t){t.exports=function(){"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}function e(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,r(t,e)}function n(t){return n=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},n(t)}function r(t,e){return r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},r(t,e)}function i(t,e,n){return i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,n){var i=[null];i.push.apply(i,e);var o=new(Function.bind.apply(t,i));return n&&r(o,n.prototype),o},i.apply(null,arguments)}function o(t){var e="function"==typeof Map?new Map:void 0;return o=function(t){if(null===t||(o=t,-1===Function.toString.call(o).indexOf("[native code]")))return t;var o;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,a)}function a(){return i(t,arguments,n(this).constructor)}return a.prototype=Object.create(t.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),r(a,t)},o(t)}function a(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var s=function(){for(var t=arguments[0],e=1,n=arguments.length;e<n;e++)if(arguments[e])for(var r in arguments[e])t[r]=arguments[e][r];return t};function u(t,e,n,r){var i=t._nodes.get(e),o=null;return i?o="mixed"===r?i.out&&i.out[n]||i.undirected&&i.undirected[n]:"directed"===r?i.out&&i.out[n]:i.undirected&&i.undirected[n]:o}function c(e){return"object"===t(e)&&null!==e}function l(t){var e;for(e in t)return!1;return!0}function d(t,e,n){Object.defineProperty(t,e,{enumerable:!1,configurable:!1,writable:!0,value:n})}function h(t,e,n){var r={enumerable:!0,configurable:!0};"function"==typeof n?r.get=n:(r.value=n,r.writable=!1),Object.defineProperty(t,e,r)}function f(t){return!(!c(t)||t.attributes&&!Array.isArray(t.attributes))}"function"==typeof Object.assign&&(s=Object.assign);var p,m={exports:{}},g="object"==typeof Reflect?Reflect:null,y=g&&"function"==typeof g.apply?g.apply:function(t,e,n){return Function.prototype.apply.call(t,e,n)};p=g&&"function"==typeof g.ownKeys?g.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var v=Number.isNaN||function(t){return t!=t};function w(){w.init.call(this)}m.exports=w,m.exports.once=function(t,e){return new Promise(function(n,r){function i(n){t.removeListener(e,o),r(n)}function o(){"function"==typeof t.removeListener&&t.removeListener("error",i),n([].slice.call(arguments))}L(t,e,o,{once:!0}),"error"!==e&&function(t,e){"function"==typeof t.on&&L(t,"error",e,{once:!0})}(t,i)})},w.EventEmitter=w,w.prototype._events=void 0,w.prototype._eventsCount=0,w.prototype._maxListeners=void 0;var b=10;function A(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function E(t){return void 0===t._maxListeners?w.defaultMaxListeners:t._maxListeners}function C(t,e,n,r){var i,o,a,s;if(A(n),void 0===(o=t._events)?(o=t._events=Object.create(null),t._eventsCount=0):(void 0!==o.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),o=t._events),a=o[e]),void 0===a)a=o[e]=n,++t._eventsCount;else if("function"==typeof a?a=o[e]=r?[n,a]:[a,n]:r?a.unshift(n):a.push(n),(i=E(t))>0&&a.length>i&&!a.warned){a.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=a.length,s=u,console&&console.warn&&console.warn(s)}return t}function S(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function _(t,e,n){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},i=S.bind(r);return i.listener=n,r.wrapFn=i,i}function M(t,e,n){var r=t._events;if(void 0===r)return[];var i=r[e];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(t){for(var e=new Array(t.length),n=0;n<e.length;++n)e[n]=t[n].listener||t[n];return e}(i):I(i,i.length)}function N(t){var e=this._events;if(void 0!==e){var n=e[t];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function I(t,e){for(var n=new Array(e),r=0;r<e;++r)n[r]=t[r];return n}function L(t,e,n,r){if("function"==typeof t.on)r.once?t.once(e,n):t.on(e,n);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,function i(o){r.once&&t.removeEventListener(e,i),n(o)})}}function P(t){if("function"!=typeof t)throw new Error("obliterator/iterator: expecting a function!");this.next=t}Object.defineProperty(w,"defaultMaxListeners",{enumerable:!0,get:function(){return b},set:function(t){if("number"!=typeof t||t<0||v(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");b=t}}),w.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},w.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||v(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},w.prototype.getMaxListeners=function(){return E(this)},w.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++)e.push(arguments[n]);var r="error"===t,i=this._events;if(void 0!==i)r=r&&void 0===i.error;else if(!r)return!1;if(r){var o;if(e.length>0&&(o=e[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var s=i[t];if(void 0===s)return!1;if("function"==typeof s)y(s,this,e);else{var u=s.length,c=I(s,u);for(n=0;n<u;++n)y(c[n],this,e)}return!0},w.prototype.addListener=function(t,e){return C(this,t,e,!1)},w.prototype.on=w.prototype.addListener,w.prototype.prependListener=function(t,e){return C(this,t,e,!0)},w.prototype.once=function(t,e){return A(e),this.on(t,_(this,t,e)),this},w.prototype.prependOnceListener=function(t,e){return A(e),this.prependListener(t,_(this,t,e)),this},w.prototype.removeListener=function(t,e){var n,r,i,o,a;if(A(e),void 0===(r=this._events))return this;if(void 0===(n=r[t]))return this;if(n===e||n.listener===e)0==--this._eventsCount?this._events=Object.create(null):(delete r[t],r.removeListener&&this.emit("removeListener",t,n.listener||e));else if("function"!=typeof n){for(i=-1,o=n.length-1;o>=0;o--)if(n[o]===e||n[o].listener===e){a=n[o].listener,i=o;break}if(i<0)return this;0===i?n.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(n,i),1===n.length&&(r[t]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",t,a||e)}return this},w.prototype.off=w.prototype.removeListener,w.prototype.removeAllListeners=function(t){var e,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[t]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[t]),this;if(0===arguments.length){var i,o=Object.keys(n);for(r=0;r<o.length;++r)"removeListener"!==(i=o[r])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=n[t]))this.removeListener(t,e);else if(void 0!==e)for(r=e.length-1;r>=0;r--)this.removeListener(t,e[r]);return this},w.prototype.listeners=function(t){return M(this,t,!0)},w.prototype.rawListeners=function(t){return M(this,t,!1)},w.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):N.call(t,e)},w.prototype.listenerCount=N,w.prototype.eventNames=function(){return this._eventsCount>0?p(this._events):[]},"undefined"!=typeof Symbol&&(P.prototype[Symbol.iterator]=function(){return this}),P.of=function(){var t=arguments,e=t.length,n=0;return new P(function(){return n>=e?{done:!0}:{done:!1,value:t[n++]}})},P.empty=function(){return new P(function(){return{done:!0}})},P.fromSequence=function(t){var e=0,n=t.length;return new P(function(){return e>=n?{done:!0}:{done:!1,value:t[e++]}})},P.is=function(t){return t instanceof P||"object"==typeof t&&null!==t&&"function"==typeof t.next};var T=P,F={};F.ARRAY_BUFFER_SUPPORT="undefined"!=typeof ArrayBuffer,F.SYMBOL_SUPPORT="undefined"!=typeof Symbol;var O=T,R=F,x=R.ARRAY_BUFFER_SUPPORT,D=R.SYMBOL_SUPPORT,k=function(t){var e=function(t){return"string"==typeof t||Array.isArray(t)||x&&ArrayBuffer.isView(t)?O.fromSequence(t):"object"!=typeof t||null===t?null:D&&"function"==typeof t[Symbol.iterator]?t[Symbol.iterator]():"function"==typeof t.next?t:null}(t);if(!e)throw new Error("obliterator: target is not iterable nor a valid iterator.");return e},U=k,G=function(t,e){for(var n,r=arguments.length>1?e:1/0,i=r!==1/0?new Array(r):[],o=0,a=U(t);;){if(o===r)return i;if((n=a.next()).done)return o!==e&&(i.length=o),i;i[o++]=n.value}},V=function(t){function n(e){var n;return(n=t.call(this)||this).name="GraphError",n.message=e,n}return e(n,t),n}(o(Error)),B=function(t){function n(e){var r;return(r=t.call(this,e)||this).name="InvalidArgumentsGraphError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(a(r),n.prototype.constructor),r}return e(n,t),n}(V),W=function(t){function n(e){var r;return(r=t.call(this,e)||this).name="NotFoundGraphError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(a(r),n.prototype.constructor),r}return e(n,t),n}(V),z=function(t){function n(e){var r;return(r=t.call(this,e)||this).name="UsageGraphError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(a(r),n.prototype.constructor),r}return e(n,t),n}(V);function H(t,e){this.key=t,this.attributes=e,this.clear()}function j(t,e){this.key=t,this.attributes=e,this.clear()}function K(t,e){this.key=t,this.attributes=e,this.clear()}function q(t,e,n,r,i){this.key=e,this.attributes=i,this.undirected=t,this.source=n,this.target=r}function Y(t,e,n,r,i,o,a){var s,u,c,l;if(r=""+r,0===n){if(!(s=t._nodes.get(r)))throw new W("Graph.".concat(e,': could not find the "').concat(r,'" node in the graph.'));c=i,l=o}else if(3===n){if(i=""+i,!(u=t._edges.get(i)))throw new W("Graph.".concat(e,': could not find the "').concat(i,'" edge in the graph.'));var d=u.source.key,h=u.target.key;if(r===d)s=u.target;else{if(r!==h)throw new W("Graph.".concat(e,': the "').concat(r,'" node is not attached to the "').concat(i,'" edge (').concat(d,", ").concat(h,")."));s=u.source}c=o,l=a}else{if(!(u=t._edges.get(r)))throw new W("Graph.".concat(e,': could not find the "').concat(r,'" edge in the graph.'));s=1===n?u.source:u.target,c=i,l=o}return[s,c,l]}H.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}},j.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}},K.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}},q.prototype.attach=function(){var t="out",e="in";this.undirected&&(t=e="undirected");var n=this.source.key,r=this.target.key;this.source[t][r]=this,this.undirected&&n===r||(this.target[e][n]=this)},q.prototype.attachMulti=function(){var t="out",e="in",n=this.source.key,r=this.target.key;this.undirected&&(t=e="undirected");var i=this.source[t],o=i[r];if(void 0===o)return i[r]=this,void(this.undirected&&n===r||(this.target[e][n]=this));o.previous=this,this.next=o,i[r]=this,this.target[e][n]=this},q.prototype.detach=function(){var t=this.source.key,e=this.target.key,n="out",r="in";this.undirected&&(n=r="undirected"),delete this.source[n][e],delete this.target[r][t]},q.prototype.detachMulti=function(){var t=this.source.key,e=this.target.key,n="out",r="in";this.undirected&&(n=r="undirected"),void 0===this.previous?void 0===this.next?(delete this.source[n][e],delete this.target[r][t]):(this.next.previous=void 0,this.source[n][e]=this.next,this.target[r][t]=this.next):(this.previous.next=this.next,void 0!==this.next&&(this.next.previous=this.previous))};var $=[{name:function(t){return"get".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,r,i){var o=Y(this,e,n,t,r,i),a=o[0],s=o[1];return a.attributes[s]}}},{name:function(t){return"get".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,r){return Y(this,e,n,t,r)[0].attributes}}},{name:function(t){return"has".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,r,i){var o=Y(this,e,n,t,r,i),a=o[0],s=o[1];return a.attributes.hasOwnProperty(s)}}},{name:function(t){return"set".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,r,i,o){var a=Y(this,e,n,t,r,i,o),s=a[0],u=a[1],c=a[2];return s.attributes[u]=c,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:u}),this}}},{name:function(t){return"update".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,r,i,o){var a=Y(this,e,n,t,r,i,o),s=a[0],u=a[1],c=a[2];if("function"!=typeof c)throw new B("Graph.".concat(e,": updater should be a function."));var l=s.attributes,d=c(l[u]);return l[u]=d,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:u}),this}}},{name:function(t){return"remove".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,r,i){var o=Y(this,e,n,t,r,i),a=o[0],s=o[1];return delete a.attributes[s],this.emit("nodeAttributesUpdated",{key:a.key,type:"remove",attributes:a.attributes,name:s}),this}}},{name:function(t){return"replace".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,r,i){var o=Y(this,e,n,t,r,i),a=o[0],s=o[1];if(!c(s))throw new B("Graph.".concat(e,": provided attributes are not a plain object."));return a.attributes=s,this.emit("nodeAttributesUpdated",{key:a.key,type:"replace",attributes:a.attributes}),this}}},{name:function(t){return"merge".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,r,i){var o=Y(this,e,n,t,r,i),a=o[0],u=o[1];if(!c(u))throw new B("Graph.".concat(e,": provided attributes are not a plain object."));return s(a.attributes,u),this.emit("nodeAttributesUpdated",{key:a.key,type:"merge",attributes:a.attributes,data:u}),this}}},{name:function(t){return"update".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,r,i){var o=Y(this,e,n,t,r,i),a=o[0],s=o[1];if("function"!=typeof s)throw new B("Graph.".concat(e,": provided updater is not a function."));return a.attributes=s(a.attributes),this.emit("nodeAttributesUpdated",{key:a.key,type:"update",attributes:a.attributes}),this}}}],X=[{name:function(t){return"get".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,r){var i;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new z("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new z("Graph.".concat(e,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var o=""+t,a=""+r;if(r=arguments[2],!(i=u(this,o,a,n)))throw new W("Graph.".concat(e,': could not find an edge for the given path ("').concat(o,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new z("Graph.".concat(e,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(t=""+t,!(i=this._edges.get(t)))throw new W("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}return i.attributes[r]}}},{name:function(t){return"get".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t){var r;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new z("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>1){if(this.multi)throw new z("Graph.".concat(e,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var i=""+t,o=""+arguments[1];if(!(r=u(this,i,o,n)))throw new W("Graph.".concat(e,': could not find an edge for the given path ("').concat(i,'" - "').concat(o,'").'))}else{if("mixed"!==n)throw new z("Graph.".concat(e,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(t=""+t,!(r=this._edges.get(t)))throw new W("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}return r.attributes}}},{name:function(t){return"has".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,r){var i;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new z("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new z("Graph.".concat(e,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var o=""+t,a=""+r;if(r=arguments[2],!(i=u(this,o,a,n)))throw new W("Graph.".concat(e,': could not find an edge for the given path ("').concat(o,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new z("Graph.".concat(e,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(t=""+t,!(i=this._edges.get(t)))throw new W("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}return i.attributes.hasOwnProperty(r)}}},{name:function(t){return"set".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,r,i){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new z("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>3){if(this.multi)throw new z("Graph.".concat(e,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var a=""+t,s=""+r;if(r=arguments[2],i=arguments[3],!(o=u(this,a,s,n)))throw new W("Graph.".concat(e,': could not find an edge for the given path ("').concat(a,'" - "').concat(s,'").'))}else{if("mixed"!==n)throw new z("Graph.".concat(e,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(t=""+t,!(o=this._edges.get(t)))throw new W("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}return o.attributes[r]=i,this.emit("edgeAttributesUpdated",{key:o.key,type:"set",attributes:o.attributes,name:r}),this}}},{name:function(t){return"update".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,r,i){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new z("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>3){if(this.multi)throw new z("Graph.".concat(e,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var a=""+t,s=""+r;if(r=arguments[2],i=arguments[3],!(o=u(this,a,s,n)))throw new W("Graph.".concat(e,': could not find an edge for the given path ("').concat(a,'" - "').concat(s,'").'))}else{if("mixed"!==n)throw new z("Graph.".concat(e,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(t=""+t,!(o=this._edges.get(t)))throw new W("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}if("function"!=typeof i)throw new B("Graph.".concat(e,": updater should be a function."));return o.attributes[r]=i(o.attributes[r]),this.emit("edgeAttributesUpdated",{key:o.key,type:"set",attributes:o.attributes,name:r}),this}}},{name:function(t){return"remove".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,r){var i;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new z("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new z("Graph.".concat(e,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var o=""+t,a=""+r;if(r=arguments[2],!(i=u(this,o,a,n)))throw new W("Graph.".concat(e,': could not find an edge for the given path ("').concat(o,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new z("Graph.".concat(e,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(t=""+t,!(i=this._edges.get(t)))throw new W("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}return delete i.attributes[r],this.emit("edgeAttributesUpdated",{key:i.key,type:"remove",attributes:i.attributes,name:r}),this}}},{name:function(t){return"replace".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,r){var i;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new z("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new z("Graph.".concat(e,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var o=""+t,a=""+r;if(r=arguments[2],!(i=u(this,o,a,n)))throw new W("Graph.".concat(e,': could not find an edge for the given path ("').concat(o,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new z("Graph.".concat(e,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(t=""+t,!(i=this._edges.get(t)))throw new W("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}if(!c(r))throw new B("Graph.".concat(e,": provided attributes are not a plain object."));return i.attributes=r,this.emit("edgeAttributesUpdated",{key:i.key,type:"replace",attributes:i.attributes}),this}}},{name:function(t){return"merge".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,r){var i;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new z("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new z("Graph.".concat(e,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var o=""+t,a=""+r;if(r=arguments[2],!(i=u(this,o,a,n)))throw new W("Graph.".concat(e,': could not find an edge for the given path ("').concat(o,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new z("Graph.".concat(e,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(t=""+t,!(i=this._edges.get(t)))throw new W("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}if(!c(r))throw new B("Graph.".concat(e,": provided attributes are not a plain object."));return s(i.attributes,r),this.emit("edgeAttributesUpdated",{key:i.key,type:"merge",attributes:i.attributes,data:r}),this}}},{name:function(t){return"update".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,r){var i;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new z("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new z("Graph.".concat(e,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var o=""+t,a=""+r;if(r=arguments[2],!(i=u(this,o,a,n)))throw new W("Graph.".concat(e,': could not find an edge for the given path ("').concat(o,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new z("Graph.".concat(e,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(t=""+t,!(i=this._edges.get(t)))throw new W("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}if("function"!=typeof r)throw new B("Graph.".concat(e,": provided updater is not a function."));return i.attributes=r(i.attributes),this.emit("edgeAttributesUpdated",{key:i.key,type:"update",attributes:i.attributes}),this}}}],Q=T,J=k,Z=function(){var t=arguments,e=null,n=-1;return new Q(function(){for(var r=null;;){if(null===e){if(++n>=t.length)return{done:!0};e=J(t[n])}if(!0!==(r=e.next()).done)break;e=null}return r})},tt=[{name:"edges",type:"mixed"},{name:"inEdges",type:"directed",direction:"in"},{name:"outEdges",type:"directed",direction:"out"},{name:"inboundEdges",type:"mixed",direction:"in"},{name:"outboundEdges",type:"mixed",direction:"out"},{name:"directedEdges",type:"directed"},{name:"undirectedEdges",type:"undirected"}];function et(t,e,n,r){var i=!1;for(var o in e)if(o!==r){var a=e[o];if(i=n(a.key,a.attributes,a.source.key,a.target.key,a.source.attributes,a.target.attributes,a.undirected),t&&i)return a.key}}function nt(t,e,n,r){var i,o,a,s=!1;for(var u in e)if(u!==r){i=e[u];do{if(o=i.source,a=i.target,s=n(i.key,i.attributes,o.key,a.key,o.attributes,a.attributes,i.undirected),t&&s)return i.key;i=i.next}while(void 0!==i)}}function rt(t,e){var n,r=Object.keys(t),i=r.length,o=0;return new T(function(){do{if(n)n=n.next;else{if(o>=i)return{done:!0};var a=r[o++];if(a===e){n=void 0;continue}n=t[a]}}while(!n);return{done:!1,value:{edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected}}})}function it(t,e,n,r){var i=e[n];if(i){var o=i.source,a=i.target;return r(i.key,i.attributes,o.key,a.key,o.attributes,a.attributes,i.undirected)&&t?i.key:void 0}}function ot(t,e,n,r){var i=e[n];if(i){var o=!1;do{if(o=r(i.key,i.attributes,i.source.key,i.target.key,i.source.attributes,i.target.attributes,i.undirected),t&&o)return i.key;i=i.next}while(void 0!==i)}}function at(t,e){var n=t[e];return void 0!==n.next?new T(function(){if(!n)return{done:!0};var t={edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected};return n=n.next,{done:!1,value:t}}):T.of({edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected})}function st(t,e,n,r){if(0!==e.size)for(var i,o,a="mixed"!==n&&n!==e.type,s="undirected"===n,u=!1,c=e._edges.values();!0!==(i=c.next()).done;)if(o=i.value,!a||o.undirected===s){var l=o,d=l.key,h=l.attributes,f=l.source,p=l.target;if(u=r(d,h,f.key,p.key,f.attributes,p.attributes,o.undirected),t&&u)return d}}function ut(t,e,n,r,i,o){var a,s=e?nt:et;if("undirected"!==n){if("out"!==r&&(a=s(t,i.in,o),t&&a))return a;if("in"!==r&&(a=s(t,i.out,o,r?void 0:i.key),t&&a))return a}if("directed"!==n&&(a=s(t,i.undirected,o),t&&a))return a}function ct(t,e,n,r,i,o,a){var s,u=n?ot:it;if("undirected"!==e){if(void 0!==i.in&&"out"!==r&&(s=u(t,i.in,o,a),t&&s))return s;if(void 0!==i.out&&"in"!==r&&(r||i.key!==o)&&(s=u(t,i.out,o,a),t&&s))return s}if("directed"!==e&&void 0!==i.undirected&&(s=u(t,i.undirected,o,a),t&&s))return s}var lt=[{name:"neighbors",type:"mixed"},{name:"inNeighbors",type:"directed",direction:"in"},{name:"outNeighbors",type:"directed",direction:"out"},{name:"inboundNeighbors",type:"mixed",direction:"in"},{name:"outboundNeighbors",type:"mixed",direction:"out"},{name:"directedNeighbors",type:"directed"},{name:"undirectedNeighbors",type:"undirected"}];function dt(){this.A=null,this.B=null}function ht(t,e,n,r,i){for(var o in r){var a=r[o],s=a.source,u=a.target,c=s===n?u:s;if(!e||!e.has(c.key)){var l=i(c.key,c.attributes);if(t&&l)return c.key}}}function ft(t,e,n,r,i){if("mixed"!==e){if("undirected"===e)return ht(t,null,r,r.undirected,i);if("string"==typeof n)return ht(t,null,r,r[n],i)}var o,a=new dt;if("undirected"!==e){if("out"!==n){if(o=ht(t,null,r,r.in,i),t&&o)return o;a.wrap(r.in)}if("in"!==n){if(o=ht(t,a,r,r.out,i),t&&o)return o;a.wrap(r.out)}}if("directed"!==e&&(o=ht(t,a,r,r.undirected,i),t&&o))return o}function pt(t,e,n){var r=Object.keys(n),i=r.length,o=0;return new T(function(){var a=null;do{if(o>=i)return t&&t.wrap(n),{done:!0};var s=n[r[o++]],u=s.source,c=s.target;a=u===e?c:u,t&&t.has(a.key)&&(a=null)}while(null===a);return{done:!1,value:{neighbor:a.key,attributes:a.attributes}}})}function mt(t,e,n,r,i){for(var o,a,s,u,c,l,d,h=r._nodes.values(),f=r.type;!0!==(o=h.next()).done;){var p=!1;if(a=o.value,"undirected"!==f)for(s in u=a.out){c=u[s];do{if(l=c.target,p=!0,d=i(a.key,l.key,a.attributes,l.attributes,c.key,c.attributes,c.undirected),t&&d)return c;c=c.next}while(c)}if("directed"!==f)for(s in u=a.undirected)if(!(e&&a.key>s)){c=u[s];do{if((l=c.target).key!==s&&(l=c.source),p=!0,d=i(a.key,l.key,a.attributes,l.attributes,c.key,c.attributes,c.undirected),t&&d)return c;c=c.next}while(c)}if(n&&!p&&(d=i(a.key,null,a.attributes,null,null,null,null),t&&d))return null}}function gt(t){if(!c(t))throw new B('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in t))throw new B("Graph.import: serialized node is missing its key.");if("attributes"in t&&(!c(t.attributes)||null===t.attributes))throw new B("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function yt(t){if(!c(t))throw new B('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in t))throw new B("Graph.import: serialized edge is missing its source.");if(!("target"in t))throw new B("Graph.import: serialized edge is missing its target.");if("attributes"in t&&(!c(t.attributes)||null===t.attributes))throw new B("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in t&&"boolean"!=typeof t.undirected)throw new B("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}dt.prototype.wrap=function(t){null===this.A?this.A=t:null===this.B&&(this.B=t)},dt.prototype.has=function(t){return null!==this.A&&t in this.A||null!==this.B&&t in this.B};var vt,wt=(vt=255&Math.floor(256*Math.random()),function(){return vt++}),bt=new Set(["directed","undirected","mixed"]),At=new Set(["domain","_events","_eventsCount","_maxListeners"]),Et={allowSelfLoops:!0,multi:!1,type:"mixed"};function Ct(t,e,n){var r=new t.NodeDataClass(e,n);return t._nodes.set(e,r),t.emit("nodeAdded",{key:e,attributes:n}),r}function St(t,e,n,r,i,o,a,s){if(!r&&"undirected"===t.type)throw new z("Graph.".concat(e,": you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead."));if(r&&"directed"===t.type)throw new z("Graph.".concat(e,": you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead."));if(s&&!c(s))throw new B("Graph.".concat(e,': invalid attributes. Expecting an object but got "').concat(s,'"'));if(o=""+o,a=""+a,s=s||{},!t.allowSelfLoops&&o===a)throw new z("Graph.".concat(e,': source & target are the same ("').concat(o,"\"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false."));var u=t._nodes.get(o),l=t._nodes.get(a);if(!u)throw new W("Graph.".concat(e,': source node "').concat(o,'" not found.'));if(!l)throw new W("Graph.".concat(e,': target node "').concat(a,'" not found.'));var d={key:null,undirected:r,source:o,target:a,attributes:s};if(n)i=t._edgeKeyGenerator();else if(i=""+i,t._edges.has(i))throw new z("Graph.".concat(e,': the "').concat(i,'" edge already exists in the graph.'));if(!t.multi&&(r?void 0!==u.undirected[a]:void 0!==u.out[a]))throw new z("Graph.".concat(e,': an edge linking "').concat(o,'" to "').concat(a,"\" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option."));var h=new q(r,i,u,l,s);t._edges.set(i,h);var f=o===a;return r?(u.undirectedDegree++,l.undirectedDegree++,f&&(u.undirectedLoops++,t._undirectedSelfLoopCount++)):(u.outDegree++,l.inDegree++,f&&(u.directedLoops++,t._directedSelfLoopCount++)),t.multi?h.attachMulti():h.attach(),r?t._undirectedSize++:t._directedSize++,d.key=i,t.emit("edgeAdded",d),i}function _t(t,e,n,r,i,o,a,u,l){if(!r&&"undirected"===t.type)throw new z("Graph.".concat(e,": you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead."));if(r&&"directed"===t.type)throw new z("Graph.".concat(e,": you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead."));if(u)if(l){if("function"!=typeof u)throw new B("Graph.".concat(e,': invalid updater function. Expecting a function but got "').concat(u,'"'))}else if(!c(u))throw new B("Graph.".concat(e,': invalid attributes. Expecting an object but got "').concat(u,'"'));var d;if(o=""+o,a=""+a,l&&(d=u,u=void 0),!t.allowSelfLoops&&o===a)throw new z("Graph.".concat(e,': source & target are the same ("').concat(o,"\"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false."));var h,f,p=t._nodes.get(o),m=t._nodes.get(a);if(!n&&(h=t._edges.get(i))){if(!(h.source.key===o&&h.target.key===a||r&&h.source.key===a&&h.target.key===o))throw new z("Graph.".concat(e,': inconsistency detected when attempting to merge the "').concat(i,'" edge with "').concat(o,'" source & "').concat(a,'" target vs. ("').concat(h.source.key,'", "').concat(h.target.key,'").'));f=h}if(f||t.multi||!p||(f=r?p.undirected[a]:p.out[a]),f){var g=[f.key,!1,!1,!1];if(l?!d:!u)return g;if(l){var y=f.attributes;f.attributes=d(y),t.emit("edgeAttributesUpdated",{type:"replace",key:f.key,attributes:f.attributes})}else s(f.attributes,u),t.emit("edgeAttributesUpdated",{type:"merge",key:f.key,attributes:f.attributes,data:u});return g}u=u||{},l&&d&&(u=d(u));var v={key:null,undirected:r,source:o,target:a,attributes:u};if(n)i=t._edgeKeyGenerator();else if(i=""+i,t._edges.has(i))throw new z("Graph.".concat(e,': the "').concat(i,'" edge already exists in the graph.'));var w=!1,b=!1;p||(p=Ct(t,o,{}),w=!0,o===a&&(m=p,b=!0)),m||(m=Ct(t,a,{}),b=!0),h=new q(r,i,p,m,u),t._edges.set(i,h);var A=o===a;return r?(p.undirectedDegree++,m.undirectedDegree++,A&&(p.undirectedLoops++,t._undirectedSelfLoopCount++)):(p.outDegree++,m.inDegree++,A&&(p.directedLoops++,t._directedSelfLoopCount++)),t.multi?h.attachMulti():h.attach(),r?t._undirectedSize++:t._directedSize++,v.key=i,t.emit("edgeAdded",v),[i,!0,w,b]}function Mt(t,e){t._edges.delete(e.key);var n=e.source,r=e.target,i=e.attributes,o=e.undirected,a=n===r;o?(n.undirectedDegree--,r.undirectedDegree--,a&&(n.undirectedLoops--,t._undirectedSelfLoopCount--)):(n.outDegree--,r.inDegree--,a&&(n.directedLoops--,t._directedSelfLoopCount--)),t.multi?e.detachMulti():e.detach(),o?t._undirectedSize--:t._directedSize--,t.emit("edgeDropped",{key:e.key,attributes:i,source:n.key,target:r.key,undirected:o})}var Nt=function(n){function r(t){var e;if(e=n.call(this)||this,"boolean"!=typeof(t=s({},Et,t)).multi)throw new B("Graph.constructor: invalid 'multi' option. Expecting a boolean but got \"".concat(t.multi,'".'));if(!bt.has(t.type))throw new B('Graph.constructor: invalid \'type\' option. Should be one of "mixed", "directed" or "undirected" but got "'.concat(t.type,'".'));if("boolean"!=typeof t.allowSelfLoops)throw new B("Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got \"".concat(t.allowSelfLoops,'".'));var r="mixed"===t.type?H:"directed"===t.type?j:K;d(a(e),"NodeDataClass",r);var i="geid_"+wt()+"_",o=0;return d(a(e),"_attributes",{}),d(a(e),"_nodes",new Map),d(a(e),"_edges",new Map),d(a(e),"_directedSize",0),d(a(e),"_undirectedSize",0),d(a(e),"_directedSelfLoopCount",0),d(a(e),"_undirectedSelfLoopCount",0),d(a(e),"_edgeKeyGenerator",function(){var t;do{t=i+o++}while(e._edges.has(t));return t}),d(a(e),"_options",t),At.forEach(function(t){return d(a(e),t,e[t])}),h(a(e),"order",function(){return e._nodes.size}),h(a(e),"size",function(){return e._edges.size}),h(a(e),"directedSize",function(){return e._directedSize}),h(a(e),"undirectedSize",function(){return e._undirectedSize}),h(a(e),"selfLoopCount",function(){return e._directedSelfLoopCount+e._undirectedSelfLoopCount}),h(a(e),"directedSelfLoopCount",function(){return e._directedSelfLoopCount}),h(a(e),"undirectedSelfLoopCount",function(){return e._undirectedSelfLoopCount}),h(a(e),"multi",e._options.multi),h(a(e),"type",e._options.type),h(a(e),"allowSelfLoops",e._options.allowSelfLoops),h(a(e),"implementation",function(){return"graphology"}),e}e(r,n);var i=r.prototype;return i._resetInstanceCounters=function(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0},i.hasNode=function(t){return this._nodes.has(""+t)},i.hasDirectedEdge=function(t,e){if("undirected"===this.type)return!1;if(1===arguments.length){var n=""+t,r=this._edges.get(n);return!!r&&!r.undirected}if(2===arguments.length){t=""+t,e=""+e;var i=this._nodes.get(t);return!!i&&i.out.hasOwnProperty(e)}throw new B("Graph.hasDirectedEdge: invalid arity (".concat(arguments.length,", instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target."))},i.hasUndirectedEdge=function(t,e){if("directed"===this.type)return!1;if(1===arguments.length){var n=""+t,r=this._edges.get(n);return!!r&&r.undirected}if(2===arguments.length){t=""+t,e=""+e;var i=this._nodes.get(t);return!!i&&i.undirected.hasOwnProperty(e)}throw new B("Graph.hasDirectedEdge: invalid arity (".concat(arguments.length,", instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target."))},i.hasEdge=function(t,e){if(1===arguments.length){var n=""+t;return this._edges.has(n)}if(2===arguments.length){t=""+t,e=""+e;var r=this._nodes.get(t);return!!r&&(void 0!==r.out&&r.out.hasOwnProperty(e)||void 0!==r.undirected&&r.undirected.hasOwnProperty(e))}throw new B("Graph.hasEdge: invalid arity (".concat(arguments.length,", instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target."))},i.directedEdge=function(t,e){if("undirected"!==this.type){if(t=""+t,e=""+e,this.multi)throw new z("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");var n=this._nodes.get(t);if(!n)throw new W('Graph.directedEdge: could not find the "'.concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new W('Graph.directedEdge: could not find the "'.concat(e,'" target node in the graph.'));var r=n.out&&n.out[e]||void 0;return r?r.key:void 0}},i.undirectedEdge=function(t,e){if("directed"!==this.type){if(t=""+t,e=""+e,this.multi)throw new z("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");var n=this._nodes.get(t);if(!n)throw new W('Graph.undirectedEdge: could not find the "'.concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new W('Graph.undirectedEdge: could not find the "'.concat(e,'" target node in the graph.'));var r=n.undirected&&n.undirected[e]||void 0;return r?r.key:void 0}},i.edge=function(t,e){if(this.multi)throw new z("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new W('Graph.edge: could not find the "'.concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new W('Graph.edge: could not find the "'.concat(e,'" target node in the graph.'));var r=n.out&&n.out[e]||n.undirected&&n.undirected[e]||void 0;if(r)return r.key},i.areDirectedNeighbors=function(t,e){t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new W('Graph.areDirectedNeighbors: could not find the "'.concat(t,'" node in the graph.'));return"undirected"!==this.type&&(e in n.in||e in n.out)},i.areOutNeighbors=function(t,e){t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new W('Graph.areOutNeighbors: could not find the "'.concat(t,'" node in the graph.'));return"undirected"!==this.type&&e in n.out},i.areInNeighbors=function(t,e){t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new W('Graph.areInNeighbors: could not find the "'.concat(t,'" node in the graph.'));return"undirected"!==this.type&&e in n.in},i.areUndirectedNeighbors=function(t,e){t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new W('Graph.areUndirectedNeighbors: could not find the "'.concat(t,'" node in the graph.'));return"directed"!==this.type&&e in n.undirected},i.areNeighbors=function(t,e){t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new W('Graph.areNeighbors: could not find the "'.concat(t,'" node in the graph.'));return"undirected"!==this.type&&(e in n.in||e in n.out)||"directed"!==this.type&&e in n.undirected},i.areInboundNeighbors=function(t,e){t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new W('Graph.areInboundNeighbors: could not find the "'.concat(t,'" node in the graph.'));return"undirected"!==this.type&&e in n.in||"directed"!==this.type&&e in n.undirected},i.areOutboundNeighbors=function(t,e){t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new W('Graph.areOutboundNeighbors: could not find the "'.concat(t,'" node in the graph.'));return"undirected"!==this.type&&e in n.out||"directed"!==this.type&&e in n.undirected},i.inDegree=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new W('Graph.inDegree: could not find the "'.concat(t,'" node in the graph.'));return"undirected"===this.type?0:e.inDegree},i.outDegree=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new W('Graph.outDegree: could not find the "'.concat(t,'" node in the graph.'));return"undirected"===this.type?0:e.outDegree},i.directedDegree=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new W('Graph.directedDegree: could not find the "'.concat(t,'" node in the graph.'));return"undirected"===this.type?0:e.inDegree+e.outDegree},i.undirectedDegree=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new W('Graph.undirectedDegree: could not find the "'.concat(t,'" node in the graph.'));return"directed"===this.type?0:e.undirectedDegree},i.inboundDegree=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new W('Graph.inboundDegree: could not find the "'.concat(t,'" node in the graph.'));var n=0;return"directed"!==this.type&&(n+=e.undirectedDegree),"undirected"!==this.type&&(n+=e.inDegree),n},i.outboundDegree=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new W('Graph.outboundDegree: could not find the "'.concat(t,'" node in the graph.'));var n=0;return"directed"!==this.type&&(n+=e.undirectedDegree),"undirected"!==this.type&&(n+=e.outDegree),n},i.degree=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new W('Graph.degree: could not find the "'.concat(t,'" node in the graph.'));var n=0;return"directed"!==this.type&&(n+=e.undirectedDegree),"undirected"!==this.type&&(n+=e.inDegree+e.outDegree),n},i.inDegreeWithoutSelfLoops=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new W('Graph.inDegreeWithoutSelfLoops: could not find the "'.concat(t,'" node in the graph.'));return"undirected"===this.type?0:e.inDegree-e.directedLoops},i.outDegreeWithoutSelfLoops=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new W('Graph.outDegreeWithoutSelfLoops: could not find the "'.concat(t,'" node in the graph.'));return"undirected"===this.type?0:e.outDegree-e.directedLoops},i.directedDegreeWithoutSelfLoops=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new W('Graph.directedDegreeWithoutSelfLoops: could not find the "'.concat(t,'" node in the graph.'));return"undirected"===this.type?0:e.inDegree+e.outDegree-2*e.directedLoops},i.undirectedDegreeWithoutSelfLoops=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new W('Graph.undirectedDegreeWithoutSelfLoops: could not find the "'.concat(t,'" node in the graph.'));return"directed"===this.type?0:e.undirectedDegree-2*e.undirectedLoops},i.inboundDegreeWithoutSelfLoops=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new W('Graph.inboundDegreeWithoutSelfLoops: could not find the "'.concat(t,'" node in the graph.'));var n=0,r=0;return"directed"!==this.type&&(n+=e.undirectedDegree,r+=2*e.undirectedLoops),"undirected"!==this.type&&(n+=e.inDegree,r+=e.directedLoops),n-r},i.outboundDegreeWithoutSelfLoops=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new W('Graph.outboundDegreeWithoutSelfLoops: could not find the "'.concat(t,'" node in the graph.'));var n=0,r=0;return"directed"!==this.type&&(n+=e.undirectedDegree,r+=2*e.undirectedLoops),"undirected"!==this.type&&(n+=e.outDegree,r+=e.directedLoops),n-r},i.degreeWithoutSelfLoops=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new W('Graph.degreeWithoutSelfLoops: could not find the "'.concat(t,'" node in the graph.'));var n=0,r=0;return"directed"!==this.type&&(n+=e.undirectedDegree,r+=2*e.undirectedLoops),"undirected"!==this.type&&(n+=e.inDegree+e.outDegree,r+=2*e.directedLoops),n-r},i.source=function(t){t=""+t;var e=this._edges.get(t);if(!e)throw new W('Graph.source: could not find the "'.concat(t,'" edge in the graph.'));return e.source.key},i.target=function(t){t=""+t;var e=this._edges.get(t);if(!e)throw new W('Graph.target: could not find the "'.concat(t,'" edge in the graph.'));return e.target.key},i.extremities=function(t){t=""+t;var e=this._edges.get(t);if(!e)throw new W('Graph.extremities: could not find the "'.concat(t,'" edge in the graph.'));return[e.source.key,e.target.key]},i.opposite=function(t,e){t=""+t,e=""+e;var n=this._edges.get(e);if(!n)throw new W('Graph.opposite: could not find the "'.concat(e,'" edge in the graph.'));var r=n.source.key,i=n.target.key;if(t===r)return i;if(t===i)return r;throw new W('Graph.opposite: the "'.concat(t,'" node is not attached to the "').concat(e,'" edge (').concat(r,", ").concat(i,")."))},i.hasExtremity=function(t,e){t=""+t,e=""+e;var n=this._edges.get(t);if(!n)throw new W('Graph.hasExtremity: could not find the "'.concat(t,'" edge in the graph.'));return n.source.key===e||n.target.key===e},i.isUndirected=function(t){t=""+t;var e=this._edges.get(t);if(!e)throw new W('Graph.isUndirected: could not find the "'.concat(t,'" edge in the graph.'));return e.undirected},i.isDirected=function(t){t=""+t;var e=this._edges.get(t);if(!e)throw new W('Graph.isDirected: could not find the "'.concat(t,'" edge in the graph.'));return!e.undirected},i.isSelfLoop=function(t){t=""+t;var e=this._edges.get(t);if(!e)throw new W('Graph.isSelfLoop: could not find the "'.concat(t,'" edge in the graph.'));return e.source===e.target},i.addNode=function(t,e){var n=function(t,e,n){if(n&&!c(n))throw new B('Graph.addNode: invalid attributes. Expecting an object but got "'.concat(n,'"'));if(e=""+e,n=n||{},t._nodes.has(e))throw new z('Graph.addNode: the "'.concat(e,'" node already exist in the graph.'));var r=new t.NodeDataClass(e,n);return t._nodes.set(e,r),t.emit("nodeAdded",{key:e,attributes:n}),r}(this,t,e);return n.key},i.mergeNode=function(t,e){if(e&&!c(e))throw new B('Graph.mergeNode: invalid attributes. Expecting an object but got "'.concat(e,'"'));t=""+t,e=e||{};var n=this._nodes.get(t);return n?(e&&(s(n.attributes,e),this.emit("nodeAttributesUpdated",{type:"merge",key:t,attributes:n.attributes,data:e})),[t,!1]):(n=new this.NodeDataClass(t,e),this._nodes.set(t,n),this.emit("nodeAdded",{key:t,attributes:e}),[t,!0])},i.updateNode=function(t,e){if(e&&"function"!=typeof e)throw new B('Graph.updateNode: invalid updater function. Expecting a function but got "'.concat(e,'"'));t=""+t;var n=this._nodes.get(t);if(n){if(e){var r=n.attributes;n.attributes=e(r),this.emit("nodeAttributesUpdated",{type:"replace",key:t,attributes:n.attributes})}return[t,!1]}var i=e?e({}):{};return n=new this.NodeDataClass(t,i),this._nodes.set(t,n),this.emit("nodeAdded",{key:t,attributes:i}),[t,!0]},i.dropNode=function(t){t=""+t;var e,n=this._nodes.get(t);if(!n)throw new W('Graph.dropNode: could not find the "'.concat(t,'" node in the graph.'));if("undirected"!==this.type){for(var r in n.out){e=n.out[r];do{Mt(this,e),e=e.next}while(e)}for(var i in n.in){e=n.in[i];do{Mt(this,e),e=e.next}while(e)}}if("directed"!==this.type)for(var o in n.undirected){e=n.undirected[o];do{Mt(this,e),e=e.next}while(e)}this._nodes.delete(t),this.emit("nodeDropped",{key:t,attributes:n.attributes})},i.dropEdge=function(t){var e;if(arguments.length>1){var n=""+arguments[0],r=""+arguments[1];if(!(e=u(this,n,r,this.type)))throw new W('Graph.dropEdge: could not find the "'.concat(n,'" -> "').concat(r,'" edge in the graph.'))}else if(t=""+t,!(e=this._edges.get(t)))throw new W('Graph.dropEdge: could not find the "'.concat(t,'" edge in the graph.'));return Mt(this,e),this},i.dropDirectedEdge=function(t,e){if(arguments.length<2)throw new z("Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new z("Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");var n=u(this,t=""+t,e=""+e,"directed");if(!n)throw new W('Graph.dropDirectedEdge: could not find a "'.concat(t,'" -> "').concat(e,'" edge in the graph.'));return Mt(this,n),this},i.dropUndirectedEdge=function(t,e){if(arguments.length<2)throw new z("Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new z("Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");var n=u(this,t,e,"undirected");if(!n)throw new W('Graph.dropUndirectedEdge: could not find a "'.concat(t,'" -> "').concat(e,'" edge in the graph.'));return Mt(this,n),this},i.clear=function(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")},i.clearEdges=function(){for(var t,e=this._nodes.values();!0!==(t=e.next()).done;)t.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")},i.getAttribute=function(t){return this._attributes[t]},i.getAttributes=function(){return this._attributes},i.hasAttribute=function(t){return this._attributes.hasOwnProperty(t)},i.setAttribute=function(t,e){return this._attributes[t]=e,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:t}),this},i.updateAttribute=function(t,e){if("function"!=typeof e)throw new B("Graph.updateAttribute: updater should be a function.");var n=this._attributes[t];return this._attributes[t]=e(n),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:t}),this},i.removeAttribute=function(t){return delete this._attributes[t],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:t}),this},i.replaceAttributes=function(t){if(!c(t))throw new B("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=t,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this},i.mergeAttributes=function(t){if(!c(t))throw new B("Graph.mergeAttributes: provided attributes are not a plain object.");return s(this._attributes,t),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:t}),this},i.updateAttributes=function(t){if("function"!=typeof t)throw new B("Graph.updateAttributes: provided updater is not a function.");return this._attributes=t(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this},i.updateEachNodeAttributes=function(t,e){if("function"!=typeof t)throw new B("Graph.updateEachNodeAttributes: expecting an updater function.");if(e&&!f(e))throw new B("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");for(var n,r,i=this._nodes.values();!0!==(n=i.next()).done;)(r=n.value).attributes=t(r.key,r.attributes);this.emit("eachNodeAttributesUpdated",{hints:e||null})},i.updateEachEdgeAttributes=function(t,e){if("function"!=typeof t)throw new B("Graph.updateEachEdgeAttributes: expecting an updater function.");if(e&&!f(e))throw new B("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");for(var n,r,i,o,a=this._edges.values();!0!==(n=a.next()).done;)i=(r=n.value).source,o=r.target,r.attributes=t(r.key,r.attributes,i.key,o.key,i.attributes,o.attributes,r.undirected);this.emit("eachEdgeAttributesUpdated",{hints:e||null})},i.forEachAdjacencyEntry=function(t){if("function"!=typeof t)throw new B("Graph.forEachAdjacencyEntry: expecting a callback.");mt(!1,!1,!1,this,t)},i.forEachAdjacencyEntryWithOrphans=function(t){if("function"!=typeof t)throw new B("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");mt(!1,!1,!0,this,t)},i.forEachAssymetricAdjacencyEntry=function(t){if("function"!=typeof t)throw new B("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");mt(!1,!0,!1,this,t)},i.forEachAssymetricAdjacencyEntryWithOrphans=function(t){if("function"!=typeof t)throw new B("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");mt(!1,!0,!0,this,t)},i.nodes=function(){return"function"==typeof Array.from?Array.from(this._nodes.keys()):G(this._nodes.keys(),this._nodes.size)},i.forEachNode=function(t){if("function"!=typeof t)throw new B("Graph.forEachNode: expecting a callback.");for(var e,n,r=this._nodes.values();!0!==(e=r.next()).done;)t((n=e.value).key,n.attributes)},i.findNode=function(t){if("function"!=typeof t)throw new B("Graph.findNode: expecting a callback.");for(var e,n,r=this._nodes.values();!0!==(e=r.next()).done;)if(t((n=e.value).key,n.attributes))return n.key},i.mapNodes=function(t){if("function"!=typeof t)throw new B("Graph.mapNode: expecting a callback.");for(var e,n,r=this._nodes.values(),i=new Array(this.order),o=0;!0!==(e=r.next()).done;)n=e.value,i[o++]=t(n.key,n.attributes);return i},i.someNode=function(t){if("function"!=typeof t)throw new B("Graph.someNode: expecting a callback.");for(var e,n,r=this._nodes.values();!0!==(e=r.next()).done;)if(t((n=e.value).key,n.attributes))return!0;return!1},i.everyNode=function(t){if("function"!=typeof t)throw new B("Graph.everyNode: expecting a callback.");for(var e,n,r=this._nodes.values();!0!==(e=r.next()).done;)if(!t((n=e.value).key,n.attributes))return!1;return!0},i.filterNodes=function(t){if("function"!=typeof t)throw new B("Graph.filterNodes: expecting a callback.");for(var e,n,r=this._nodes.values(),i=[];!0!==(e=r.next()).done;)t((n=e.value).key,n.attributes)&&i.push(n.key);return i},i.reduceNodes=function(t,e){if("function"!=typeof t)throw new B("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new B("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");for(var n,r,i=e,o=this._nodes.values();!0!==(n=o.next()).done;)i=t(i,(r=n.value).key,r.attributes);return i},i.nodeEntries=function(){var t=this._nodes.values();return new T(function(){var e=t.next();if(e.done)return e;var n=e.value;return{value:{node:n.key,attributes:n.attributes},done:!1}})},i.export=function(){var t=this,e=new Array(this._nodes.size),n=0;this._nodes.forEach(function(t,r){e[n++]=function(t,e){var n={key:t};return l(e.attributes)||(n.attributes=s({},e.attributes)),n}(r,t)});var r=new Array(this._edges.size);return n=0,this._edges.forEach(function(e,i){r[n++]=function(t,e,n){var r={key:e,source:n.source.key,target:n.target.key};return l(n.attributes)||(r.attributes=s({},n.attributes)),"mixed"===t&&n.undirected&&(r.undirected=!0),r}(t.type,i,e)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:e,edges:r}},i.import=function(t){var e,n,i,o,a,s=this,u=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(t instanceof r)return t.forEachNode(function(t,e){u?s.mergeNode(t,e):s.addNode(t,e)}),t.forEachEdge(function(t,e,n,r,i,o,a){u?a?s.mergeUndirectedEdgeWithKey(t,n,r,e):s.mergeDirectedEdgeWithKey(t,n,r,e):a?s.addUndirectedEdgeWithKey(t,n,r,e):s.addDirectedEdgeWithKey(t,n,r,e)}),this;if(!c(t))throw new B("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(t.attributes){if(!c(t.attributes))throw new B("Graph.import: invalid attributes. Expecting a plain object.");u?this.mergeAttributes(t.attributes):this.replaceAttributes(t.attributes)}if(t.nodes){if(i=t.nodes,!Array.isArray(i))throw new B("Graph.import: invalid nodes. Expecting an array.");for(e=0,n=i.length;e<n;e++){gt(o=i[e]);var l=o,d=l.key,h=l.attributes;u?this.mergeNode(d,h):this.addNode(d,h)}}if(t.edges){var f=!1;if("undirected"===this.type&&(f=!0),i=t.edges,!Array.isArray(i))throw new B("Graph.import: invalid edges. Expecting an array.");for(e=0,n=i.length;e<n;e++){yt(a=i[e]);var p=a,m=p.source,g=p.target,y=p.attributes,v=p.undirected,w=void 0===v?f:v;"key"in a?(u?w?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:w?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey).call(this,a.key,m,g,y):(u?w?this.mergeUndirectedEdge:this.mergeDirectedEdge:w?this.addUndirectedEdge:this.addDirectedEdge).call(this,m,g,y)}}return this},i.nullCopy=function(t){var e=new r(s({},this._options,t));return e.replaceAttributes(s({},this.getAttributes())),e},i.emptyCopy=function(t){var e=this.nullCopy(t);return this._nodes.forEach(function(t,n){var r=s({},t.attributes);t=new e.NodeDataClass(n,r),e._nodes.set(n,t)}),e},i.copy=function(t){if("string"==typeof(t=t||{}).type&&t.type!==this.type&&"mixed"!==t.type)throw new z('Graph.copy: cannot create an incompatible copy from "'.concat(this.type,'" type to "').concat(t.type,'" because this would mean losing information about the current graph.'));if("boolean"==typeof t.multi&&t.multi!==this.multi&&!0!==t.multi)throw new z("Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.");if("boolean"==typeof t.allowSelfLoops&&t.allowSelfLoops!==this.allowSelfLoops&&!0!==t.allowSelfLoops)throw new z("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");for(var e,n,r=this.emptyCopy(t),i=this._edges.values();!0!==(e=i.next()).done;)St(r,"copy",!1,(n=e.value).undirected,n.key,n.source.key,n.target.key,s({},n.attributes));return r},i.toJSON=function(){return this.export()},i.toString=function(){return"[object Graph]"},i.inspect=function(){var e=this,n={};this._nodes.forEach(function(t,e){n[e]=t.attributes});var r={},i={};this._edges.forEach(function(t,n){var o,a=t.undirected?"--":"->",s="",u=t.source.key,c=t.target.key;t.undirected&&u>c&&(o=u,u=c,c=o);var l="(".concat(u,")").concat(a,"(").concat(c,")");n.startsWith("geid_")?e.multi&&(void 0===i[l]?i[l]=0:i[l]++,s+="".concat(i[l],". ")):s+="[".concat(n,"]: "),r[s+=l]=t.attributes});var o={};for(var a in this)this.hasOwnProperty(a)&&!At.has(a)&&"function"!=typeof this[a]&&"symbol"!==t(a)&&(o[a]=this[a]);return o.attributes=this._attributes,o.nodes=n,o.edges=r,d(o,"constructor",this.constructor),o},r}(m.exports.EventEmitter);"undefined"!=typeof Symbol&&(Nt.prototype[Symbol.for("nodejs.util.inspect.custom")]=Nt.prototype.inspect),[{name:function(t){return"".concat(t,"Edge")},generateKey:!0},{name:function(t){return"".concat(t,"DirectedEdge")},generateKey:!0,type:"directed"},{name:function(t){return"".concat(t,"UndirectedEdge")},generateKey:!0,type:"undirected"},{name:function(t){return"".concat(t,"EdgeWithKey")}},{name:function(t){return"".concat(t,"DirectedEdgeWithKey")},type:"directed"},{name:function(t){return"".concat(t,"UndirectedEdgeWithKey")},type:"undirected"}].forEach(function(t){["add","merge","update"].forEach(function(e){var n=t.name(e),r="add"===e?St:_t;t.generateKey?Nt.prototype[n]=function(i,o,a){return r(this,n,!0,"undirected"===(t.type||this.type),null,i,o,a,"update"===e)}:Nt.prototype[n]=function(i,o,a,s){return r(this,n,!1,"undirected"===(t.type||this.type),i,o,a,s,"update"===e)}})}),function(t){$.forEach(function(e){var n=e.name,r=e.attacher;r(t,n("Node"),0),r(t,n("Source"),1),r(t,n("Target"),2),r(t,n("Opposite"),3)})}(Nt),function(t){X.forEach(function(e){var n=e.name,r=e.attacher;r(t,n("Edge"),"mixed"),r(t,n("DirectedEdge"),"directed"),r(t,n("UndirectedEdge"),"undirected")})}(Nt),function(t){tt.forEach(function(e){!function(t,e){var n=e.name,r=e.type,i=e.direction;t.prototype[n]=function(t,e){if("mixed"!==r&&"mixed"!==this.type&&r!==this.type)return[];if(!arguments.length)return function(t,e){if(0===t.size)return[];if("mixed"===e||e===t.type)return"function"==typeof Array.from?Array.from(t._edges.keys()):G(t._edges.keys(),t._edges.size);for(var n,r,i="undirected"===e?t.undirectedSize:t.directedSize,o=new Array(i),a="undirected"===e,s=t._edges.values(),u=0;!0!==(n=s.next()).done;)(r=n.value).undirected===a&&(o[u++]=r.key);return o}(this,r);if(1===arguments.length){t=""+t;var o=this._nodes.get(t);if(void 0===o)throw new W("Graph.".concat(n,': could not find the "').concat(t,'" node in the graph.'));return function(t,e,n,r){var i=[];return ut(!1,t,e,n,r,function(t){i.push(t)}),i}(this.multi,"mixed"===r?this.type:r,i,o)}if(2===arguments.length){t=""+t,e=""+e;var a=this._nodes.get(t);if(!a)throw new W("Graph.".concat(n,': could not find the "').concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new W("Graph.".concat(n,': could not find the "').concat(e,'" target node in the graph.'));return function(t,e,n,r,i){var o=[];return ct(!1,t,e,n,r,i,function(t){o.push(t)}),o}(r,this.multi,i,a,e)}throw new B("Graph.".concat(n,": too many arguments (expecting 0, 1 or 2 and got ").concat(arguments.length,")."))}}(t,e),function(t,e){var n=e.name,r=e.type,i=e.direction,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[o]=function(t,e,n){if("mixed"===r||"mixed"===this.type||r===this.type){if(1===arguments.length)return st(!1,this,r,n=t);if(2===arguments.length){t=""+t,n=e;var a=this._nodes.get(t);if(void 0===a)throw new W("Graph.".concat(o,': could not find the "').concat(t,'" node in the graph.'));return ut(!1,this.multi,"mixed"===r?this.type:r,i,a,n)}if(3===arguments.length){t=""+t,e=""+e;var s=this._nodes.get(t);if(!s)throw new W("Graph.".concat(o,': could not find the "').concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new W("Graph.".concat(o,': could not find the "').concat(e,'" target node in the graph.'));return ct(!1,r,this.multi,i,s,e,n)}throw new B("Graph.".concat(o,": too many arguments (expecting 1, 2 or 3 and got ").concat(arguments.length,")."))}};var a="map"+n[0].toUpperCase()+n.slice(1);t.prototype[a]=function(){var t,e=Array.prototype.slice.call(arguments),n=e.pop();if(0===e.length){var i=0;"directed"!==r&&(i+=this.undirectedSize),"undirected"!==r&&(i+=this.directedSize),t=new Array(i);var a=0;e.push(function(e,r,i,o,s,u,c){t[a++]=n(e,r,i,o,s,u,c)})}else t=[],e.push(function(e,r,i,o,a,s,u){t.push(n(e,r,i,o,a,s,u))});return this[o].apply(this,e),t};var s="filter"+n[0].toUpperCase()+n.slice(1);t.prototype[s]=function(){var t=Array.prototype.slice.call(arguments),e=t.pop(),n=[];return t.push(function(t,r,i,o,a,s,u){e(t,r,i,o,a,s,u)&&n.push(t)}),this[o].apply(this,t),n};var u="reduce"+n[0].toUpperCase()+n.slice(1);t.prototype[u]=function(){var t,e,n=Array.prototype.slice.call(arguments);if(n.length<2||n.length>4)throw new B("Graph.".concat(u,": invalid number of arguments (expecting 2, 3 or 4 and got ").concat(n.length,")."));if("function"==typeof n[n.length-1]&&"function"!=typeof n[n.length-2])throw new B("Graph.".concat(u,": missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array."));2===n.length?(t=n[0],e=n[1],n=[]):3===n.length?(t=n[1],e=n[2],n=[n[0]]):4===n.length&&(t=n[2],e=n[3],n=[n[0],n[1]]);var r=e;return n.push(function(e,n,i,o,a,s,u){r=t(r,e,n,i,o,a,s,u)}),this[o].apply(this,n),r}}(t,e),function(t,e){var n=e.name,r=e.type,i=e.direction,o="find"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[o]=function(t,e,n){if("mixed"!==r&&"mixed"!==this.type&&r!==this.type)return!1;if(1===arguments.length)return st(!0,this,r,n=t);if(2===arguments.length){t=""+t,n=e;var a=this._nodes.get(t);if(void 0===a)throw new W("Graph.".concat(o,': could not find the "').concat(t,'" node in the graph.'));return ut(!0,this.multi,"mixed"===r?this.type:r,i,a,n)}if(3===arguments.length){t=""+t,e=""+e;var s=this._nodes.get(t);if(!s)throw new W("Graph.".concat(o,': could not find the "').concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new W("Graph.".concat(o,': could not find the "').concat(e,'" target node in the graph.'));return ct(!0,r,this.multi,i,s,e,n)}throw new B("Graph.".concat(o,": too many arguments (expecting 1, 2 or 3 and got ").concat(arguments.length,")."))};var a="some"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[a]=function(){var t=Array.prototype.slice.call(arguments),e=t.pop();return t.push(function(t,n,r,i,o,a,s){return e(t,n,r,i,o,a,s)}),!!this[o].apply(this,t)};var s="every"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[s]=function(){var t=Array.prototype.slice.call(arguments),e=t.pop();return t.push(function(t,n,r,i,o,a,s){return!e(t,n,r,i,o,a,s)}),!this[o].apply(this,t)}}(t,e),function(t,e){var n=e.name,r=e.type,i=e.direction,o=n.slice(0,-1)+"Entries";t.prototype[o]=function(t,e){if("mixed"!==r&&"mixed"!==this.type&&r!==this.type)return T.empty();if(!arguments.length)return function(t,e){if(0===t.size)return T.empty();var n="mixed"!==e&&e!==t.type,r="undirected"===e,i=t._edges.values();return new T(function(){for(var t,e;;){if((t=i.next()).done)return t;if(e=t.value,!n||e.undirected===r)break}return{value:{edge:e.key,attributes:e.attributes,source:e.source.key,target:e.target.key,sourceAttributes:e.source.attributes,targetAttributes:e.target.attributes,undirected:e.undirected},done:!1}})}(this,r);if(1===arguments.length){t=""+t;var n=this._nodes.get(t);if(!n)throw new W("Graph.".concat(o,': could not find the "').concat(t,'" node in the graph.'));return function(t,e,n){var r=T.empty();return"undirected"!==t&&("out"!==e&&void 0!==n.in&&(r=Z(r,rt(n.in))),"in"!==e&&void 0!==n.out&&(r=Z(r,rt(n.out,e?void 0:n.key)))),"directed"!==t&&void 0!==n.undirected&&(r=Z(r,rt(n.undirected))),r}(r,i,n)}if(2===arguments.length){t=""+t,e=""+e;var a=this._nodes.get(t);if(!a)throw new W("Graph.".concat(o,': could not find the "').concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new W("Graph.".concat(o,': could not find the "').concat(e,'" target node in the graph.'));return function(t,e,n,r){var i=T.empty();return"undirected"!==t&&(void 0!==n.in&&"out"!==e&&r in n.in&&(i=Z(i,at(n.in,r))),void 0!==n.out&&"in"!==e&&r in n.out&&(e||n.key!==r)&&(i=Z(i,at(n.out,r)))),"directed"!==t&&void 0!==n.undirected&&r in n.undirected&&(i=Z(i,at(n.undirected,r))),i}(r,i,a,e)}throw new B("Graph.".concat(o,": too many arguments (expecting 0, 1 or 2 and got ").concat(arguments.length,")."))}}(t,e)})}(Nt),function(t){lt.forEach(function(e){(function(t,e){var n=e.name,r=e.type,i=e.direction;t.prototype[n]=function(t){if("mixed"!==r&&"mixed"!==this.type&&r!==this.type)return[];t=""+t;var e=this._nodes.get(t);if(void 0===e)throw new W("Graph.".concat(n,': could not find the "').concat(t,'" node in the graph.'));return function(t,e,n){if("mixed"!==t){if("undirected"===t)return Object.keys(n.undirected);if("string"==typeof e)return Object.keys(n[e])}var r=[];return ft(!1,t,e,n,function(t){r.push(t)}),r}("mixed"===r?this.type:r,i,e)}})(t,e),function(t,e){var n=e.name,r=e.type,i=e.direction,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[o]=function(t,e){if("mixed"===r||"mixed"===this.type||r===this.type){t=""+t;var n=this._nodes.get(t);if(void 0===n)throw new W("Graph.".concat(o,': could not find the "').concat(t,'" node in the graph.'));ft(!1,"mixed"===r?this.type:r,i,n,e)}};var a="map"+n[0].toUpperCase()+n.slice(1);t.prototype[a]=function(t,e){var n=[];return this[o](t,function(t,r){n.push(e(t,r))}),n};var s="filter"+n[0].toUpperCase()+n.slice(1);t.prototype[s]=function(t,e){var n=[];return this[o](t,function(t,r){e(t,r)&&n.push(t)}),n};var u="reduce"+n[0].toUpperCase()+n.slice(1);t.prototype[u]=function(t,e,n){if(arguments.length<3)throw new B("Graph.".concat(u,": missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array."));var r=n;return this[o](t,function(t,n){r=e(r,t,n)}),r}}(t,e),function(t,e){var n=e.name,r=e.type,i=e.direction,o=n[0].toUpperCase()+n.slice(1,-1),a="find"+o;t.prototype[a]=function(t,e){if("mixed"===r||"mixed"===this.type||r===this.type){t=""+t;var n=this._nodes.get(t);if(void 0===n)throw new W("Graph.".concat(a,': could not find the "').concat(t,'" node in the graph.'));return ft(!0,"mixed"===r?this.type:r,i,n,e)}};var s="some"+o;t.prototype[s]=function(t,e){return!!this[a](t,e)};var u="every"+o;t.prototype[u]=function(t,e){return!this[a](t,function(t,n){return!e(t,n)})}}(t,e),function(t,e){var n=e.name,r=e.type,i=e.direction,o=n.slice(0,-1)+"Entries";t.prototype[o]=function(t){if("mixed"!==r&&"mixed"!==this.type&&r!==this.type)return T.empty();t=""+t;var e=this._nodes.get(t);if(void 0===e)throw new W("Graph.".concat(o,': could not find the "').concat(t,'" node in the graph.'));return function(t,e,n){if("mixed"!==t){if("undirected"===t)return pt(null,n,n.undirected);if("string"==typeof e)return pt(null,n,n[e])}var r=T.empty(),i=new dt;return"undirected"!==t&&("out"!==e&&(r=Z(r,pt(i,n,n.in))),"in"!==e&&(r=Z(r,pt(i,n,n.out)))),"directed"!==t&&(r=Z(r,pt(i,n,n.undirected))),r}("mixed"===r?this.type:r,i,e)}}(t,e)})}(Nt);var It=function(t){function n(e){var n=s({type:"directed"},e);if("multi"in n&&!1!==n.multi)throw new B("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if("directed"!==n.type)throw new B('DirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return t.call(this,n)||this}return e(n,t),n}(Nt),Lt=function(t){function n(e){var n=s({type:"undirected"},e);if("multi"in n&&!1!==n.multi)throw new B("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if("undirected"!==n.type)throw new B('UndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return t.call(this,n)||this}return e(n,t),n}(Nt),Pt=function(t){function n(e){var n=s({multi:!0},e);if("multi"in n&&!0!==n.multi)throw new B("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");return t.call(this,n)||this}return e(n,t),n}(Nt),Tt=function(t){function n(e){var n=s({type:"directed",multi:!0},e);if("multi"in n&&!0!==n.multi)throw new B("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if("directed"!==n.type)throw new B('MultiDirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return t.call(this,n)||this}return e(n,t),n}(Nt),Ft=function(t){function n(e){var n=s({type:"undirected",multi:!0},e);if("multi"in n&&!0!==n.multi)throw new B("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if("undirected"!==n.type)throw new B('MultiUndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return t.call(this,n)||this}return e(n,t),n}(Nt);function Ot(t){t.from=function(e,n){var r=s({},e.options,n),i=new t(r);return i.import(e),i}}return Ot(Nt),Ot(It),Ot(Lt),Ot(Pt),Ot(Tt),Ot(Ft),Nt.Graph=Nt,Nt.DirectedGraph=It,Nt.UndirectedGraph=Lt,Nt.MultiGraph=Pt,Nt.MultiDirectedGraph=Tt,Nt.MultiUndirectedGraph=Ft,Nt.InvalidArgumentsGraphError=B,Nt.NotFoundGraphError=W,Nt.UsageGraphError=z,Nt}()},944:(t,e)=>{"use strict";e.Vb=void 0,e.Vb=function(t,e,n){var r=function(t,e,n){if(0===t.length||0===e.length)return 0;if(n&&!n.caseSensitive&&(t=t.toUpperCase(),e=e.toUpperCase()),t===e)return 1;for(var r=0,i=t.length,o=e.length,a=Math.floor(Math.max(i,o)/2)-1,s=new Array(i),u=new Array(o),c=0;c<i;c++)for(var l=Math.max(0,c-a);l<=Math.min(o,c+a+1);l++)if(!s[c]&&!u[l]&&t[c]===e[l]){++r,s[c]=u[l]=!0;break}if(0===r)return 0;var d=0,h=0;for(c=0;c<i;c++)if(s[c]){for(;!u[h];)h++;t.charAt(c)!==e.charAt(h++)&&d++}return(r/i+r/o+(r-(d/=2))/r)/3}(t,e,n),i=0;if(r>.7){for(var o=Math.min(t.length,e.length),a=0;t[a]===e[a]&&a<4&&a<o;)++i,a++;r+=.1*i*(1-r)}return r}},1113:t=>{"use strict";t.exports=function(t,e){if(e.styleSheet)e.styleSheet.cssText=t;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}}},1354:t=>{"use strict";t.exports=function(t){var e=t[1],n=t[3];if(!n)return e;if("function"==typeof btoa){var r=btoa(unescape(encodeURIComponent(JSON.stringify(n)))),i="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(r),o="/*# ".concat(i," */");return[e].concat([o]).join("\n")}return[e].join("\n")}},1736:t=>{t.exports=function(t){return null!==t&&"object"==typeof t&&"function"==typeof t.addUndirectedEdgeWithKey&&"function"==typeof t.dropNode&&"boolean"==typeof t.multi}},1782:(t,e)=>{e.assign=function(t){t=t||{};var e,n,r,i=Array.prototype.slice.call(arguments).slice(1);for(e=0,r=i.length;e<r;e++)if(i[e])for(n in i[e])t[n]=i[e][n];return t},e.validateSettings=function(t){return"linLogMode"in t&&"boolean"!=typeof t.linLogMode?{message:"the `linLogMode` setting should be a boolean."}:"outboundAttractionDistribution"in t&&"boolean"!=typeof t.outboundAttractionDistribution?{message:"the `outboundAttractionDistribution` setting should be a boolean."}:"adjustSizes"in t&&"boolean"!=typeof t.adjustSizes?{message:"the `adjustSizes` setting should be a boolean."}:"edgeWeightInfluence"in t&&"number"!=typeof t.edgeWeightInfluence?{message:"the `edgeWeightInfluence` setting should be a number."}:!("scalingRatio"in t)||"number"==typeof t.scalingRatio&&t.scalingRatio>=0?"strongGravityMode"in t&&"boolean"!=typeof t.strongGravityMode?{message:"the `strongGravityMode` setting should be a boolean."}:!("gravity"in t)||"number"==typeof t.gravity&&t.gravity>=0?"slowDown"in t&&!("number"==typeof t.slowDown||t.slowDown>=0)?{message:"the `slowDown` setting should be a number >= 0."}:"barnesHutOptimize"in t&&"boolean"!=typeof t.barnesHutOptimize?{message:"the `barnesHutOptimize` setting should be a boolean."}:!("barnesHutTheta"in t)||"number"==typeof t.barnesHutTheta&&t.barnesHutTheta>=0?null:{message:"the `barnesHutTheta` setting should be a number >= 0."}:{message:"the `gravity` setting should be a number >= 0."}:{message:"the `scalingRatio` setting should be a number >= 0."}},e.graphToByteArrays=function(t,e){var n,r=t.order,i=t.size,o={},a=new Float32Array(10*r),s=new Float32Array(3*i);return n=0,t.forEachNode(function(t,e){o[t]=n,a[n]=e.x,a[n+1]=e.y,a[n+2]=0,a[n+3]=0,a[n+4]=0,a[n+5]=0,a[n+6]=1,a[n+7]=1,a[n+8]=e.size||1,a[n+9]=e.fixed?1:0,n+=10}),n=0,t.forEachEdge(function(t,r,i,u,c,l,d){var h=o[i],f=o[u],p=e(t,r,i,u,c,l,d);a[h+6]+=p,a[f+6]+=p,s[n]=h,s[n+1]=f,s[n+2]=p,n+=3}),{nodes:a,edges:s}},e.assignLayoutChanges=function(t,e,n){var r=0;t.updateEachNodeAttributes(function(t,i){return i.x=e[r],i.y=e[r+1],r+=10,n?n(t,i):i})},e.readGraphPositions=function(t,e){var n=0;t.forEachNode(function(t,r){e[n]=r.x,e[n+1]=r.y,n+=10})},e.collectLayoutChanges=function(t,e,n){for(var r=t.nodes(),i={},o=0,a=0,s=e.length;o<s;o+=10){if(n){var u=Object.assign({},t.getNodeAttributes(r[a]));u.x=e[o],u.y=e[o+1],u=n(r[a],u),i[r[a]]={x:u.x,y:u.y}}else i[r[a]]={x:e[o],y:e[o+1]};a++}return i},e.createWorker=function(t){var e=window.URL||window.webkitURL,n=t.toString(),r=e.createObjectURL(new Blob(["("+n+").call(this);"],{type:"text/javascript"})),i=new Worker(r);return e.revokeObjectURL(r),i}},2561:t=>{var e=10;t.exports=function(t,n,r){var i,o,a,s,u,c,l,d,h,f,p,m,g,y,v,w,b,A,E,C,S,_,M,N=n.length,I=r.length,L=t.adjustSizes,P=t.barnesHutTheta*t.barnesHutTheta,T=[];for(a=0;a<N;a+=e)n[a+4]=n[a+2],n[a+5]=n[a+3],n[a+2]=0,n[a+3]=0;if(t.outboundAttractionDistribution){for(p=0,a=0;a<N;a+=e)p+=n[a+6];p/=N/e}if(t.barnesHutOptimize){var F,O,R,x=1/0,D=-1/0,k=1/0,U=-1/0;for(a=0;a<N;a+=e)x=Math.min(x,n[a+0]),D=Math.max(D,n[a+0]),k=Math.min(k,n[a+1]),U=Math.max(U,n[a+1]);var G=D-x,V=U-k;for(G>V?U=(k-=(G-V)/2)+G:D=(x-=(V-G)/2)+V,T[0]=-1,T[1]=(x+D)/2,T[2]=(k+U)/2,T[3]=Math.max(D-x,U-k),T[4]=-1,T[5]=-1,T[6]=0,T[7]=0,T[8]=0,i=1,a=0;a<N;a+=e)for(o=0,R=3;;){if(!(T[o+5]>=0)){if(T[o+0]<0){T[o+0]=a;break}if(T[o+5]=9*i,d=T[o+3]/2,T[(h=T[o+5])+0]=-1,T[h+1]=T[o+1]-d,T[h+2]=T[o+2]-d,T[h+3]=d,T[h+4]=h+9,T[h+5]=-1,T[h+6]=0,T[h+7]=0,T[h+8]=0,T[(h+=9)+0]=-1,T[h+1]=T[o+1]-d,T[h+2]=T[o+2]+d,T[h+3]=d,T[h+4]=h+9,T[h+5]=-1,T[h+6]=0,T[h+7]=0,T[h+8]=0,T[(h+=9)+0]=-1,T[h+1]=T[o+1]+d,T[h+2]=T[o+2]-d,T[h+3]=d,T[h+4]=h+9,T[h+5]=-1,T[h+6]=0,T[h+7]=0,T[h+8]=0,T[(h+=9)+0]=-1,T[h+1]=T[o+1]+d,T[h+2]=T[o+2]+d,T[h+3]=d,T[h+4]=T[o+4],T[h+5]=-1,T[h+6]=0,T[h+7]=0,T[h+8]=0,i+=4,F=n[T[o+0]+0]<T[o+1]?n[T[o+0]+1]<T[o+2]?T[o+5]:T[o+5]+9:n[T[o+0]+1]<T[o+2]?T[o+5]+18:T[o+5]+27,T[o+6]=n[T[o+0]+6],T[o+7]=n[T[o+0]+0],T[o+8]=n[T[o+0]+1],T[F+0]=T[o+0],T[o+0]=-1,F===(O=n[a+0]<T[o+1]?n[a+1]<T[o+2]?T[o+5]:T[o+5]+9:n[a+1]<T[o+2]?T[o+5]+18:T[o+5]+27)){if(R--){o=F;continue}R=3;break}T[O+0]=a;break}F=n[a+0]<T[o+1]?n[a+1]<T[o+2]?T[o+5]:T[o+5]+9:n[a+1]<T[o+2]?T[o+5]+18:T[o+5]+27,T[o+7]=(T[o+7]*T[o+6]+n[a+0]*n[a+6])/(T[o+6]+n[a+6]),T[o+8]=(T[o+8]*T[o+6]+n[a+1]*n[a+6])/(T[o+6]+n[a+6]),T[o+6]+=n[a+6],o=F}}if(t.barnesHutOptimize){for(m=t.scalingRatio,a=0;a<N;a+=e)for(o=0;;)if(T[o+5]>=0){if(w=Math.pow(n[a+0]-T[o+7],2)+Math.pow(n[a+1]-T[o+8],2),4*(f=T[o+3])*f/w<P){if(g=n[a+0]-T[o+7],y=n[a+1]-T[o+8],!0===L?w>0?(b=m*n[a+6]*T[o+6]/w,n[a+2]+=g*b,n[a+3]+=y*b):w<0&&(b=-m*n[a+6]*T[o+6]/Math.sqrt(w),n[a+2]+=g*b,n[a+3]+=y*b):w>0&&(b=m*n[a+6]*T[o+6]/w,n[a+2]+=g*b,n[a+3]+=y*b),(o=T[o+4])<0)break;continue}o=T[o+5]}else if((c=T[o+0])>=0&&c!==a&&(w=(g=n[a+0]-n[c+0])*g+(y=n[a+1]-n[c+1])*y,!0===L?w>0?(b=m*n[a+6]*n[c+6]/w,n[a+2]+=g*b,n[a+3]+=y*b):w<0&&(b=-m*n[a+6]*n[c+6]/Math.sqrt(w),n[a+2]+=g*b,n[a+3]+=y*b):w>0&&(b=m*n[a+6]*n[c+6]/w,n[a+2]+=g*b,n[a+3]+=y*b)),(o=T[o+4])<0)break}else for(m=t.scalingRatio,s=0;s<N;s+=e)for(u=0;u<s;u+=e)g=n[s+0]-n[u+0],y=n[s+1]-n[u+1],!0===L?(w=Math.sqrt(g*g+y*y)-n[s+8]-n[u+8])>0?(b=m*n[s+6]*n[u+6]/w/w,n[s+2]+=g*b,n[s+3]+=y*b,n[u+2]-=g*b,n[u+3]-=y*b):w<0&&(b=100*m*n[s+6]*n[u+6],n[s+2]+=g*b,n[s+3]+=y*b,n[u+2]-=g*b,n[u+3]-=y*b):(w=Math.sqrt(g*g+y*y))>0&&(b=m*n[s+6]*n[u+6]/w/w,n[s+2]+=g*b,n[s+3]+=y*b,n[u+2]-=g*b,n[u+3]-=y*b);for(h=t.gravity/t.scalingRatio,m=t.scalingRatio,a=0;a<N;a+=e)b=0,g=n[a+0],y=n[a+1],w=Math.sqrt(Math.pow(g,2)+Math.pow(y,2)),t.strongGravityMode?w>0&&(b=m*n[a+6]*h):w>0&&(b=m*n[a+6]*h/w),n[a+2]-=g*b,n[a+3]-=y*b;for(m=1*(t.outboundAttractionDistribution?p:1),l=0;l<I;l+=3)s=r[l+0],u=r[l+1],d=r[l+2],v=Math.pow(d,t.edgeWeightInfluence),g=n[s+0]-n[u+0],y=n[s+1]-n[u+1],!0===L?(w=Math.sqrt(g*g+y*y)-n[s+8]-n[u+8],t.linLogMode?t.outboundAttractionDistribution?w>0&&(b=-m*v*Math.log(1+w)/w/n[s+6]):w>0&&(b=-m*v*Math.log(1+w)/w):t.outboundAttractionDistribution?w>0&&(b=-m*v/n[s+6]):w>0&&(b=-m*v)):(w=Math.sqrt(Math.pow(g,2)+Math.pow(y,2)),t.linLogMode?t.outboundAttractionDistribution?w>0&&(b=-m*v*Math.log(1+w)/w/n[s+6]):w>0&&(b=-m*v*Math.log(1+w)/w):t.outboundAttractionDistribution?(w=1,b=-m*v/n[s+6]):(w=1,b=-m*v)),w>0&&(n[s+2]+=g*b,n[s+3]+=y*b,n[u+2]-=g*b,n[u+3]-=y*b);if(!0===L)for(a=0;a<N;a+=e)1!==n[a+9]&&((A=Math.sqrt(Math.pow(n[a+2],2)+Math.pow(n[a+3],2)))>10&&(n[a+2]=10*n[a+2]/A,n[a+3]=10*n[a+3]/A),E=n[a+6]*Math.sqrt((n[a+4]-n[a+2])*(n[a+4]-n[a+2])+(n[a+5]-n[a+3])*(n[a+5]-n[a+3])),C=Math.sqrt((n[a+4]+n[a+2])*(n[a+4]+n[a+2])+(n[a+5]+n[a+3])*(n[a+5]+n[a+3]))/2,S=.1*Math.log(1+C)/(1+Math.sqrt(E)),_=n[a+0]+n[a+2]*(S/t.slowDown),n[a+0]=_,M=n[a+1]+n[a+3]*(S/t.slowDown),n[a+1]=M);else for(a=0;a<N;a+=e)1!==n[a+9]&&(E=n[a+6]*Math.sqrt((n[a+4]-n[a+2])*(n[a+4]-n[a+2])+(n[a+5]-n[a+3])*(n[a+5]-n[a+3])),C=Math.sqrt((n[a+4]+n[a+2])*(n[a+4]+n[a+2])+(n[a+5]+n[a+3])*(n[a+5]+n[a+3]))/2,S=n[a+7]*Math.log(1+C)/(1+Math.sqrt(E)),n[a+7]=Math.min(1,Math.sqrt(S*(Math.pow(n[a+2],2)+Math.pow(n[a+3],2))/(1+Math.sqrt(E)))),_=n[a+0]+n[a+2]*(S/t.slowDown),n[a+0]=_,M=n[a+1]+n[a+3]*(S/t.slowDown),n[a+1]=M);return{}}},5056:(t,e,n)=>{"use strict";t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},5072:t=>{"use strict";var e=[];function n(t){for(var n=-1,r=0;r<e.length;r++)if(e[r].identifier===t){n=r;break}return n}function r(t,r){for(var o={},a=[],s=0;s<t.length;s++){var u=t[s],c=r.base?u[0]+r.base:u[0],l=o[c]||0,d="".concat(c," ").concat(l);o[c]=l+1;var h=n(d),f={css:u[1],media:u[2],sourceMap:u[3],supports:u[4],layer:u[5]};if(-1!==h)e[h].references++,e[h].updater(f);else{var p=i(f,r);r.byIndex=s,e.splice(s,0,{identifier:d,updater:p,references:1})}a.push(d)}return a}function i(t,e){var n=e.domAPI(e);return n.update(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap&&e.supports===t.supports&&e.layer===t.layer)return;n.update(t=e)}else n.remove()}}t.exports=function(t,i){var o=r(t=t||[],i=i||{});return function(t){t=t||[];for(var a=0;a<o.length;a++){var s=n(o[a]);e[s].references--}for(var u=r(t,i),c=0;c<o.length;c++){var l=n(o[c]);0===e[l].references&&(e[l].updater(),e.splice(l,1))}o=u}}},5540:(t,e,n)=>{"use strict";t=n.hmd(t);var r,i=(r="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,function(t={}){var e,n,i=void 0!==t?t:{};i.ready=new Promise(function(t,r){e=t,n=r});var o,a=Object.assign({},i),s="object"==typeof window,u="function"==typeof importScripts,c=("object"==typeof process&&"object"==typeof process.versions&&process.versions.node,"");(s||u)&&(u?c=self.location.href:"undefined"!=typeof document&&document.currentScript&&(c=document.currentScript.src),r&&(c=r),c=0!==c.indexOf("blob:")?c.substr(0,c.replace(/[?#].*/,"").lastIndexOf("/")+1):"",u&&(o=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)})),i.print||console.log.bind(console);var l,d,h=i.printErr||console.warn.bind(console);Object.assign(i,a),a=null,i.arguments&&i.arguments,i.thisProgram&&i.thisProgram,i.quit&&i.quit,i.wasmBinary&&(l=i.wasmBinary),i.noExitRuntime,"object"!=typeof WebAssembly&&I("no native wasm support detected");var f,p,m,g=!1;function y(){var t=d.buffer;i.HEAP8=f=new Int8Array(t),i.HEAP16=new Int16Array(t),i.HEAP32=new Int32Array(t),i.HEAPU8=p=new Uint8Array(t),i.HEAPU16=new Uint16Array(t),i.HEAPU32=m=new Uint32Array(t),i.HEAPF32=new Float32Array(t),i.HEAPF64=new Float64Array(t)}var v=[],w=[],b=[];function A(t){v.unshift(t)}function E(t){b.unshift(t)}var C,S,_=0,M=null,N=null;function I(t){i.onAbort&&i.onAbort(t),h(t="Aborted("+t+")"),g=!0,t+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(t);throw n(e),e}function L(t){return t.startsWith("data:application/octet-stream;base64,")}function P(t){try{if(t==C&&l)return new Uint8Array(l);if(o)return o(t);throw"both async and sync fetching of the wasm failed"}catch(t){I(t)}}function T(t,e,n){return function(t){return l||!s&&!u||"function"!=typeof fetch?Promise.resolve().then(function(){return P(t)}):fetch(t,{credentials:"same-origin"}).then(function(e){if(!e.ok)throw"failed to load wasm binary file at '"+t+"'";return e.arrayBuffer()}).catch(function(){return P(t)})}(t).then(function(t){return WebAssembly.instantiate(t,e)}).then(function(t){return t}).then(n,function(t){h("failed to asynchronously prepare wasm: "+t),I(t)})}function F(t){for(;t.length>0;)t.shift()(i)}function O(t){this.excPtr=t,this.ptr=t-24,this.set_type=function(t){m[this.ptr+4>>2]=t},this.get_type=function(){return m[this.ptr+4>>2]},this.set_destructor=function(t){m[this.ptr+8>>2]=t},this.get_destructor=function(){return m[this.ptr+8>>2]},this.set_caught=function(t){t=t?1:0,f[this.ptr+12|0]=t},this.get_caught=function(){return 0!=f[this.ptr+12|0]},this.set_rethrown=function(t){t=t?1:0,f[this.ptr+13|0]=t},this.get_rethrown=function(){return 0!=f[this.ptr+13|0]},this.init=function(t,e){this.set_adjusted_ptr(0),this.set_type(t),this.set_destructor(e)},this.set_adjusted_ptr=function(t){m[this.ptr+16>>2]=t},this.get_adjusted_ptr=function(){return m[this.ptr+16>>2]},this.get_exception_ptr=function(){if(z(this.get_type()))return m[this.excPtr>>2];var t=this.get_adjusted_ptr();return 0!==t?t:this.excPtr}}function R(t){var e=d.buffer;try{return d.grow(t-e.byteLength+65535>>>16),y(),1}catch(t){}}function x(t){return i["_"+t]}L(C="wasmDbscan.wasm")||(S=C,C=i.locateFile?i.locateFile(S,c):c+S);var D="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function k(t,e,n,r,i){var o={string:t=>{var e=0;return null!=t&&0!==t&&(e=function(t){var e=function(t){for(var e=0,n=0;n<t.length;++n){var r=t.charCodeAt(n);r<=127?e++:r<=2047?e+=2:r>=55296&&r<=57343?(e+=4,++n):e+=3}return e}(t)+1,n=W(e);return function(t,e,n){!function(t,e,n,r){if(!(r>0))return 0;for(var i=n+r-1,o=0;o<t.length;++o){var a=t.charCodeAt(o);if(a>=55296&&a<=57343&&(a=65536+((1023&a)<<10)|1023&t.charCodeAt(++o)),a<=127){if(n>=i)break;e[n++]=a}else if(a<=2047){if(n+1>=i)break;e[n++]=192|a>>6,e[n++]=128|63&a}else if(a<=65535){if(n+2>=i)break;e[n++]=224|a>>12,e[n++]=128|a>>6&63,e[n++]=128|63&a}else{if(n+3>=i)break;e[n++]=240|a>>18,e[n++]=128|a>>12&63,e[n++]=128|a>>6&63,e[n++]=128|63&a}}e[n]=0}(t,p,e,n)}(t,n,e),n}(t)),e},array:t=>{var e,n,r=W(t.length);return e=t,n=r,f.set(e,n),r}},a=x(t),s=[],u=0;if(r)for(var c=0;c<r.length;c++){var l=o[n[c]];l?(0===u&&(u=V()),s[c]=l(r[c])):s[c]=r[c]}var d=a.apply(null,s);return function(t){return 0!==u&&B(u),function(t){return"string"===e?(n=t)?function(t,e,n){for(var r=e+n,i=e;t[i]&&!(i>=r);)++i;if(i-e>16&&t.buffer&&D)return D.decode(t.subarray(e,i));for(var o="";e<i;){var a=t[e++];if(128&a){var s=63&t[e++];if(192!=(224&a)){var u=63&t[e++];if((a=224==(240&a)?(15&a)<<12|s<<6|u:(7&a)<<18|s<<12|u<<6|63&t[e++])<65536)o+=String.fromCharCode(a);else{var c=a-65536;o+=String.fromCharCode(55296|c>>10,56320|1023&c)}}else o+=String.fromCharCode((31&a)<<6|s)}else o+=String.fromCharCode(a)}return o}(p,n,r):"":"boolean"===e?Boolean(t):t;var n,r}(t)}(d)}var U,G={__cxa_throw:function(t,e,n){throw new O(t).init(e,n),t},abort:function(){I("")},emscripten_memcpy_big:function(t,e,n){p.copyWithin(t,e,e+n)},emscripten_resize_heap:function(t){var e=p.length,n=2147483648;if((t>>>=0)>n)return!1;let r=(t,e)=>t+(e-t%e)%e;for(var i=1;i<=4;i*=2){var o=e*(1+.2/i);if(o=Math.min(o,t+100663296),R(Math.min(n,r(Math.max(t,o),65536))))return!0}return!1}},V=(function(){var t,e,r,o,a={env:G,wasi_snapshot_preview1:G};function s(t,e){var n,r=t.exports;return i.asm=r,d=i.asm.memory,y(),i.asm.__indirect_function_table,n=i.asm.__wasm_call_ctors,w.unshift(n),function(){if(_--,i.monitorRunDependencies&&i.monitorRunDependencies(_),0==_&&(null!==M&&(clearInterval(M),M=null),N)){var t=N;N=null,t()}}(),r}if(_++,i.monitorRunDependencies&&i.monitorRunDependencies(_),i.instantiateWasm)try{return i.instantiateWasm(a,s)}catch(t){h("Module.instantiateWasm callback failed with error: "+t),n(t)}(t=l,e=C,r=a,o=function(t){s(t.instance)},t||"function"!=typeof WebAssembly.instantiateStreaming||L(e)||"function"!=typeof fetch?T(e,r,o):fetch(e,{credentials:"same-origin"}).then(function(t){return WebAssembly.instantiateStreaming(t,r).then(o,function(t){return h("wasm streaming compile failed: "+t),h("falling back to ArrayBuffer instantiation"),T(e,r,o)})})).catch(n)}(),i._dbscan=function(){return(i._dbscan=i.asm.dbscan).apply(null,arguments)},i._malloc=function(){return(i._malloc=i.asm.malloc).apply(null,arguments)},i._free=function(){return(i._free=i.asm.free).apply(null,arguments)},function(){return(V=i.asm.stackSave).apply(null,arguments)}),B=function(){return(B=i.asm.stackRestore).apply(null,arguments)},W=function(){return(W=i.asm.stackAlloc).apply(null,arguments)},z=function(){return(z=i.asm.__cxa_is_pointer_type).apply(null,arguments)};function H(){function t(){U||(U=!0,i.calledRun=!0,g||(F(w),e(i),i.onRuntimeInitialized&&i.onRuntimeInitialized(),function(){if(i.postRun)for("function"==typeof i.postRun&&(i.postRun=[i.postRun]);i.postRun.length;)E(i.postRun.shift());F(b)}()))}_>0||(function(){if(i.preRun)for("function"==typeof i.preRun&&(i.preRun=[i.preRun]);i.preRun.length;)A(i.preRun.shift());F(v)}(),_>0||(i.setStatus?(i.setStatus("Running..."),setTimeout(function(){setTimeout(function(){i.setStatus("")},1),t()},1)):t()))}if(i.ccall=k,i.cwrap=function(t,e,n,r){var i=!n||n.every(t=>"number"===t||"boolean"===t);return"string"!==e&&i&&!r?x(t):function(){return k(t,e,n,arguments)}},N=function t(){U||H(),U||(N=t)},i.preInit)for("function"==typeof i.preInit&&(i.preInit=[i.preInit]);i.preInit.length>0;)i.preInit.pop()();return H(),t.ready});"object"==typeof exports?t.exports=i:"function"==typeof define&&n.amdO?define([],function(){return i}):"object"==typeof exports&&(exports.exportCppDbscanLib=i)},6314:t=>{"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map(function(e){var n="",r=void 0!==e[5];return e[4]&&(n+="@supports (".concat(e[4],") {")),e[2]&&(n+="@media ".concat(e[2]," {")),r&&(n+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),n+=t(e),r&&(n+="}"),e[2]&&(n+="}"),e[4]&&(n+="}"),n}).join("")},e.i=function(t,n,r,i,o){"string"==typeof t&&(t=[[null,t,void 0]]);var a={};if(r)for(var s=0;s<this.length;s++){var u=this[s][0];null!=u&&(a[u]=!0)}for(var c=0;c<t.length;c++){var l=[].concat(t[c]);r&&a[l[0]]||(void 0!==o&&(void 0===l[5]||(l[1]="@layer".concat(l[5].length>0?" ".concat(l[5]):""," {").concat(l[1],"}")),l[5]=o),n&&(l[2]?(l[1]="@media ".concat(l[2]," {").concat(l[1],"}"),l[2]=n):l[2]=n),i&&(l[4]?(l[1]="@supports (".concat(l[4],") {").concat(l[1],"}"),l[4]=i):l[4]="".concat(i)),e.push(l))}},e}},6572:function(t){var e;t.exports=(e=function(t,e){var n=Array.prototype.concat,r=Array.prototype.slice,i=Object.prototype.toString;function o(e,n){var r=e>n?e:n;return t.pow(10,17-~~(t.log(r>0?r:-r)*t.LOG10E))}var a=Array.isArray||function(t){return"[object Array]"===i.call(t)};function s(t){return"[object Function]"===i.call(t)}function u(t){return"number"==typeof t&&t-t===0}function c(){return new c._init(arguments)}function l(){return 0}function d(){return 1}function h(t,e){return t===e?1:0}c.fn=c.prototype,c._init=function(t){if(a(t[0]))if(a(t[0][0])){s(t[1])&&(t[0]=c.map(t[0],t[1]));for(var e=0;e<t[0].length;e++)this[e]=t[0][e];this.length=t[0].length}else this[0]=s(t[1])?c.map(t[0],t[1]):t[0],this.length=1;else if(u(t[0]))this[0]=c.seq.apply(null,t),this.length=1;else{if(t[0]instanceof c)return c(t[0].toArray());this[0]=[],this.length=1}return this},c._init.prototype=c.prototype,c._init.constructor=c,c.utils={calcRdx:o,isArray:a,isFunction:s,isNumber:u,toVector:function(t){return n.apply([],t)}},c._random_fn=t.random,c.setRandom=function(t){if("function"!=typeof t)throw new TypeError("fn is not a function");c._random_fn=t},c.extend=function(t){var e,n;if(1===arguments.length){for(n in t)c[n]=t[n];return this}for(e=1;e<arguments.length;e++)for(n in arguments[e])t[n]=arguments[e][n];return t},c.rows=function(t){return t.length||1},c.cols=function(t){return t[0].length||1},c.dimensions=function(t){return{rows:c.rows(t),cols:c.cols(t)}},c.row=function(t,e){return a(e)?e.map(function(e){return c.row(t,e)}):t[e]},c.rowa=function(t,e){return c.row(t,e)},c.col=function(t,e){if(a(e)){var n=c.arange(t.length).map(function(){return new Array(e.length)});return e.forEach(function(e,r){c.arange(t.length).forEach(function(i){n[i][r]=t[i][e]})}),n}for(var r=new Array(t.length),i=0;i<t.length;i++)r[i]=[t[i][e]];return r},c.cola=function(t,e){return c.col(t,e).map(function(t){return t[0]})},c.diag=function(t){for(var e=c.rows(t),n=new Array(e),r=0;r<e;r++)n[r]=[t[r][r]];return n},c.antidiag=function(t){for(var e=c.rows(t)-1,n=new Array(e),r=0;e>=0;e--,r++)n[r]=[t[r][e]];return n},c.transpose=function(t){var e,n,r,i,o,s=[];for(a(t[0])||(t=[t]),n=t.length,r=t[0].length,o=0;o<r;o++){for(e=new Array(n),i=0;i<n;i++)e[i]=t[i][o];s.push(e)}return 1===s.length?s[0]:s},c.map=function(t,e,n){var r,i,o,s,u;for(a(t[0])||(t=[t]),i=t.length,o=t[0].length,s=n?t:new Array(i),r=0;r<i;r++)for(s[r]||(s[r]=new Array(o)),u=0;u<o;u++)s[r][u]=e(t[r][u],r,u);return 1===s.length?s[0]:s},c.cumreduce=function(t,e,n){var r,i,o,s,u;for(a(t[0])||(t=[t]),i=t.length,o=t[0].length,s=n?t:new Array(i),r=0;r<i;r++)for(s[r]||(s[r]=new Array(o)),o>0&&(s[r][0]=t[r][0]),u=1;u<o;u++)s[r][u]=e(s[r][u-1],t[r][u]);return 1===s.length?s[0]:s},c.alter=function(t,e){return c.map(t,e,!0)},c.create=function(t,e,n){var r,i,o=new Array(t);for(s(e)&&(n=e,e=t),r=0;r<t;r++)for(o[r]=new Array(e),i=0;i<e;i++)o[r][i]=n(r,i);return o},c.zeros=function(t,e){return u(e)||(e=t),c.create(t,e,l)},c.ones=function(t,e){return u(e)||(e=t),c.create(t,e,d)},c.rand=function(t,e){return u(e)||(e=t),c.create(t,e,c._random_fn)},c.identity=function(t,e){return u(e)||(e=t),c.create(t,e,h)},c.symmetric=function(t){var e,n,r=t.length;if(t.length!==t[0].length)return!1;for(e=0;e<r;e++)for(n=0;n<r;n++)if(t[n][e]!==t[e][n])return!1;return!0},c.clear=function(t){return c.alter(t,l)},c.seq=function(t,e,n,r){s(r)||(r=!1);var i,a=[],u=o(t,e),c=(e*u-t*u)/((n-1)*u),l=t;for(i=0;l<=e&&i<n;l=(t*u+c*u*++i)/u)a.push(r?r(l,i):l);return a},c.arange=function(t,n,r){var i,o=[];if(r=r||1,n===e&&(n=t,t=0),t===n||0===r)return[];if(t<n&&r<0)return[];if(t>n&&r>0)return[];if(r>0)for(i=t;i<n;i+=r)o.push(i);else for(i=t;i>n;i+=r)o.push(i);return o},c.slice=function(){function t(t,n,r,i){var o,a=[],s=t.length;if(n===e&&r===e&&i===e)return c.copy(t);if(i=i||1,(n=(n=n||0)>=0?n:s+n)===(r=(r=r||t.length)>=0?r:s+r)||0===i)return[];if(n<r&&i<0)return[];if(n>r&&i>0)return[];if(i>0)for(o=n;o<r;o+=i)a.push(t[o]);else for(o=n;o>r;o+=i)a.push(t[o]);return a}return function(e,n){var r,i;return u((n=n||{}).row)?u(n.col)?e[n.row][n.col]:t(c.rowa(e,n.row),(r=n.col||{}).start,r.end,r.step):u(n.col)?t(c.cola(e,n.col),(i=n.row||{}).start,i.end,i.step):(i=n.row||{},r=n.col||{},t(e,i.start,i.end,i.step).map(function(e){return t(e,r.start,r.end,r.step)}))}}(),c.sliceAssign=function(n,r,i){var o,a;if(u(r.row)){if(u(r.col))return n[r.row][r.col]=i;r.col=r.col||{},r.col.start=r.col.start||0,r.col.end=r.col.end||n[0].length,r.col.step=r.col.step||1,o=c.arange(r.col.start,t.min(n.length,r.col.end),r.col.step);var s=r.row;return o.forEach(function(t,e){n[s][t]=i[e]}),n}if(u(r.col)){r.row=r.row||{},r.row.start=r.row.start||0,r.row.end=r.row.end||n.length,r.row.step=r.row.step||1,a=c.arange(r.row.start,t.min(n[0].length,r.row.end),r.row.step);var l=r.col;return a.forEach(function(t,e){n[t][l]=i[e]}),n}return i[0].length===e&&(i=[i]),r.row.start=r.row.start||0,r.row.end=r.row.end||n.length,r.row.step=r.row.step||1,r.col.start=r.col.start||0,r.col.end=r.col.end||n[0].length,r.col.step=r.col.step||1,a=c.arange(r.row.start,t.min(n.length,r.row.end),r.row.step),o=c.arange(r.col.start,t.min(n[0].length,r.col.end),r.col.step),a.forEach(function(t,e){o.forEach(function(r,o){n[t][r]=i[e][o]})}),n},c.diagonal=function(t){var e=c.zeros(t.length,t.length);return t.forEach(function(t,n){e[n][n]=t}),e},c.copy=function(t){return t.map(function(t){return u(t)?t:t.map(function(t){return t})})};var f=c.prototype;return f.length=0,f.push=Array.prototype.push,f.sort=Array.prototype.sort,f.splice=Array.prototype.splice,f.slice=Array.prototype.slice,f.toArray=function(){return this.length>1?r.call(this):r.call(this)[0]},f.map=function(t,e){return c(c.map(this,t,e))},f.cumreduce=function(t,e){return c(c.cumreduce(this,t,e))},f.alter=function(t){return c.alter(this,t),this},function(t){for(var e=0;e<t.length;e++)(function(t){f[t]=function(e){var n,r=this;return e?(setTimeout(function(){e.call(r,f[t].call(r))}),this):(n=c[t](this),a(n)?c(n):n)}})(t[e])}("transpose clear symmetric rows cols dimensions diag antidiag".split(" ")),function(t){for(var e=0;e<t.length;e++)(function(t){f[t]=function(e,n){var r=this;return n?(setTimeout(function(){n.call(r,f[t].call(r,e))}),this):c(c[t](this,e))}})(t[e])}("row col".split(" ")),function(t){for(var e=0;e<t.length;e++)(function(t){f[t]=function(){return c(c[t].apply(null,arguments))}})(t[e])}("create zeros ones rand identity".split(" ")),c}(Math),function(t,e){var n=t.utils.isFunction;function r(t,e){return t-e}function i(t,n,r){return e.max(n,e.min(t,r))}t.sum=function(t){for(var e=0,n=t.length;--n>=0;)e+=t[n];return e},t.sumsqrd=function(t){for(var e=0,n=t.length;--n>=0;)e+=t[n]*t[n];return e},t.sumsqerr=function(e){for(var n,r=t.mean(e),i=0,o=e.length;--o>=0;)i+=(n=e[o]-r)*n;return i},t.sumrow=function(t){for(var e=0,n=t.length;--n>=0;)e+=t[n];return e},t.product=function(t){for(var e=1,n=t.length;--n>=0;)e*=t[n];return e},t.min=function(t){for(var e=t[0],n=0;++n<t.length;)t[n]<e&&(e=t[n]);return e},t.max=function(t){for(var e=t[0],n=0;++n<t.length;)t[n]>e&&(e=t[n]);return e},t.unique=function(t){for(var e={},n=[],r=0;r<t.length;r++)e[t[r]]||(e[t[r]]=!0,n.push(t[r]));return n},t.mean=function(e){return t.sum(e)/e.length},t.meansqerr=function(e){return t.sumsqerr(e)/e.length},t.geomean=function(n){var r=n.map(e.log),i=t.mean(r);return e.exp(i)},t.median=function(t){var e=t.length,n=t.slice().sort(r);return 1&e?n[e/2|0]:(n[e/2-1]+n[e/2])/2},t.cumsum=function(e){return t.cumreduce(e,function(t,e){return t+e})},t.cumprod=function(e){return t.cumreduce(e,function(t,e){return t*e})},t.diff=function(t){var e,n=[],r=t.length;for(e=1;e<r;e++)n.push(t[e]-t[e-1]);return n},t.rank=function(t){var e,n=[],i={};for(e=0;e<t.length;e++)i[u=t[e]]?i[u]++:(i[u]=1,n.push(u));var o=n.sort(r),a={},s=1;for(e=0;e<o.length;e++){var u,c=i[u=o[e]],l=(s+(s+c-1))/2;a[u]=l,s+=c}return t.map(function(t){return a[t]})},t.mode=function(t){var e,n=t.length,i=t.slice().sort(r),o=1,a=0,s=0,u=[];for(e=0;e<n;e++)i[e]===i[e+1]?o++:(o>a?(u=[i[e]],a=o,s=0):o===a&&(u.push(i[e]),s++),o=1);return 0===s?u[0]:u},t.range=function(e){return t.max(e)-t.min(e)},t.variance=function(e,n){return t.sumsqerr(e)/(e.length-(n?1:0))},t.pooledvariance=function(e){return e.reduce(function(e,n){return e+t.sumsqerr(n)},0)/(e.reduce(function(t,e){return t+e.length},0)-e.length)},t.deviation=function(e){for(var n=t.mean(e),r=e.length,i=new Array(r),o=0;o<r;o++)i[o]=e[o]-n;return i},t.stdev=function(n,r){return e.sqrt(t.variance(n,r))},t.pooledstdev=function(n){return e.sqrt(t.pooledvariance(n))},t.meandev=function(n){for(var r=t.mean(n),i=[],o=n.length-1;o>=0;o--)i.push(e.abs(n[o]-r));return t.mean(i)},t.meddev=function(n){for(var r=t.median(n),i=[],o=n.length-1;o>=0;o--)i.push(e.abs(n[o]-r));return t.median(i)},t.coeffvar=function(e){return t.stdev(e)/t.mean(e)},t.quartiles=function(t){var n=t.length,i=t.slice().sort(r);return[i[e.round(n/4)-1],i[e.round(n/2)-1],i[e.round(3*n/4)-1]]},t.quantiles=function(t,n,o,a){var s,u,c,l,d,h=t.slice().sort(r),f=[n.length],p=t.length;for(void 0===o&&(o=3/8),void 0===a&&(a=3/8),s=0;s<n.length;s++)c=p*(u=n[s])+(o+u*(1-o-a)),l=e.floor(i(c,1,p-1)),d=i(c-l,0,1),f[s]=(1-d)*h[l-1]+d*h[l];return f},t.percentile=function(t,e,n){var i=t.slice().sort(r),o=e*(i.length+(n?1:-1))+(n?0:1),a=parseInt(o),s=o-a;return a+1<i.length?i[a-1]+s*(i[a]-i[a-1]):i[a-1]},t.percentileOfScore=function(t,e,n){var r,i,o=0,a=t.length,s=!1;for("strict"===n&&(s=!0),i=0;i<a;i++)r=t[i],(s&&r<e||!s&&r<=e)&&o++;return o/a},t.histogram=function(n,r){r=r||4;var i,o=t.min(n),a=(t.max(n)-o)/r,s=n.length,u=[];for(i=0;i<r;i++)u[i]=0;for(i=0;i<s;i++)u[e.min(e.floor((n[i]-o)/a),r-1)]+=1;return u},t.covariance=function(e,n){var r,i=t.mean(e),o=t.mean(n),a=e.length,s=new Array(a);for(r=0;r<a;r++)s[r]=(e[r]-i)*(n[r]-o);return t.sum(s)/(a-1)},t.corrcoeff=function(e,n){return t.covariance(e,n)/t.stdev(e,1)/t.stdev(n,1)},t.spearmancoeff=function(e,n){return e=t.rank(e),n=t.rank(n),t.corrcoeff(e,n)},t.stanMoment=function(n,r){for(var i=t.mean(n),o=t.stdev(n),a=n.length,s=0,u=0;u<a;u++)s+=e.pow((n[u]-i)/o,r);return s/n.length},t.skewness=function(e){return t.stanMoment(e,3)},t.kurtosis=function(e){return t.stanMoment(e,4)-3};var o=t.prototype;!function(e){for(var r=0;r<e.length;r++)(function(e){o[e]=function(r,i){var a=[],s=0,u=this;if(n(r)&&(i=r,r=!1),i)return setTimeout(function(){i.call(u,o[e].call(u,r))}),this;if(this.length>1){for(u=!0===r?this:this.transpose();s<u.length;s++)a[s]=t[e](u[s]);return a}return t[e](this[0],r)}})(e[r])}("cumsum cumprod".split(" ")),function(e){for(var r=0;r<e.length;r++)(function(e){o[e]=function(r,i){var a=[],s=0,u=this;if(n(r)&&(i=r,r=!1),i)return setTimeout(function(){i.call(u,o[e].call(u,r))}),this;if(this.length>1){for("sumrow"!==e&&(u=!0===r?this:this.transpose());s<u.length;s++)a[s]=t[e](u[s]);return!0===r?t[e](t.utils.toVector(a)):a}return t[e](this[0],r)}})(e[r])}("sum sumsqrd sumsqerr sumrow product min max unique mean meansqerr geomean median diff rank mode range variance deviation stdev meandev meddev coeffvar quartiles histogram skewness kurtosis".split(" ")),function(e){for(var r=0;r<e.length;r++)(function(e){o[e]=function(){var r,i=[],a=0,s=this,u=Array.prototype.slice.call(arguments);if(n(u[u.length-1])){r=u[u.length-1];var c=u.slice(0,u.length-1);return setTimeout(function(){r.call(s,o[e].apply(s,c))}),this}r=void 0;var l=function(n){return t[e].apply(s,[n].concat(u))};if(this.length>1){for(s=s.transpose();a<s.length;a++)i[a]=l(s[a]);return i}return l(this[0])}})(e[r])}("quantiles percentileOfScore".split(" "))}(e,Math),function(t,e){t.gammaln=function(t){var n,r,i,o=0,a=[76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18],s=1.000000000190015;for(i=(r=n=t)+5.5,i-=(n+.5)*e.log(i);o<6;o++)s+=a[o]/++r;return e.log(2.5066282746310007*s/n)-i},t.loggam=function(t){var n,r,i,o,a,s,u,c=[.08333333333333333,-.002777777777777778,.0007936507936507937,-.0005952380952380952,.0008417508417508418,-.001917526917526918,.00641025641025641,-.02955065359477124,.1796443723688307,-1.3924322169059];if(n=t,u=0,1==t||2==t)return 0;for(t<=7&&(n=t+(u=e.floor(7-t))),r=1/(n*n),i=2*e.PI,a=c[9],s=8;s>=0;s--)a*=r,a+=c[s];if(o=a/n+.5*e.log(i)+(n-.5)*e.log(n)-n,t<=7)for(s=1;s<=u;s++)o-=e.log(n-1),n-=1;return o},t.gammafn=function(t){var n,r,i,o,a=[-1.716185138865495,24.76565080557592,-379.80425647094563,629.3311553128184,866.9662027904133,-31451.272968848367,-36144.413418691176,66456.14382024054],s=[-30.8402300119739,315.35062697960416,-1015.1563674902192,-3107.771671572311,22538.11842098015,4755.846277527881,-134659.9598649693,-115132.2596755535],u=!1,c=0,l=0,d=0,h=t;if(t>171.6243769536076)return 1/0;if(h<=0){if(!(o=h%1+36e-17))return 1/0;u=(1&h?-1:1)*e.PI/e.sin(e.PI*o),h=1-h}for(i=h,r=h<1?h++:(h-=c=(0|h)-1)-1,n=0;n<8;++n)d=(d+a[n])*r,l=l*r+s[n];if(o=d/l+1,i<h)o/=i;else if(i>h)for(n=0;n<c;++n)o*=h,h++;return u&&(o=u/o),o},t.gammap=function(e,n){return t.lowRegGamma(e,n)*t.gammafn(e)},t.lowRegGamma=function(n,r){var i,o=t.gammaln(n),a=n,s=1/n,u=s,c=r+1-n,l=1/1e-30,d=1/c,h=d,f=1,p=-~(8.5*e.log(n>=1?n:1/n)+.4*n+17);if(r<0||n<=0)return NaN;if(r<n+1){for(;f<=p;f++)s+=u*=r/++a;return s*e.exp(-r+n*e.log(r)-o)}for(;f<=p;f++)h*=(d=1/(d=(i=-f*(f-n))*d+(c+=2)))*(l=c+i/l);return 1-h*e.exp(-r+n*e.log(r)-o)},t.factorialln=function(e){return e<0?NaN:t.gammaln(e+1)},t.factorial=function(e){return e<0?NaN:t.gammafn(e+1)},t.combination=function(n,r){return n>170||r>170?e.exp(t.combinationln(n,r)):t.factorial(n)/t.factorial(r)/t.factorial(n-r)},t.combinationln=function(e,n){return t.factorialln(e)-t.factorialln(n)-t.factorialln(e-n)},t.permutation=function(e,n){return t.factorial(e)/t.factorial(e-n)},t.betafn=function(n,r){if(!(n<=0||r<=0))return n+r>170?e.exp(t.betaln(n,r)):t.gammafn(n)*t.gammafn(r)/t.gammafn(n+r)},t.betaln=function(e,n){return t.gammaln(e)+t.gammaln(n)-t.gammaln(e+n)},t.betacf=function(t,n,r){var i,o,a,s,u=1e-30,c=1,l=n+r,d=n+1,h=n-1,f=1,p=1-l*t/d;for(e.abs(p)<u&&(p=u),s=p=1/p;c<=100&&(p=1+(o=c*(r-c)*t/((h+(i=2*c))*(n+i)))*p,e.abs(p)<u&&(p=u),f=1+o/f,e.abs(f)<u&&(f=u),s*=(p=1/p)*f,p=1+(o=-(n+c)*(l+c)*t/((n+i)*(d+i)))*p,e.abs(p)<u&&(p=u),f=1+o/f,e.abs(f)<u&&(f=u),s*=a=(p=1/p)*f,!(e.abs(a-1)<3e-7));c++);return s},t.gammapinv=function(n,r){var i,o,a,s,u,c,l=0,d=r-1,h=t.gammaln(r);if(n>=1)return e.max(100,r+100*e.sqrt(r));if(n<=0)return 0;for(r>1?(u=e.log(d),c=e.exp(d*(u-1)-h),s=n<.5?n:1-n,i=(2.30753+.27061*(o=e.sqrt(-2*e.log(s))))/(1+o*(.99229+.04481*o))-o,n<.5&&(i=-i),i=e.max(.001,r*e.pow(1-1/(9*r)-i/(3*e.sqrt(r)),3))):i=n<(o=1-r*(.253+.12*r))?e.pow(n/o,1/r):1-e.log(1-(n-o)/(1-o));l<12;l++){if(i<=0)return 0;if((i-=o=(a=(t.lowRegGamma(r,i)-n)/(o=r>1?c*e.exp(-(i-d)+d*(e.log(i)-u)):e.exp(-i+d*e.log(i)-h)))/(1-.5*e.min(1,a*((r-1)/i-1))))<=0&&(i=.5*(i+o)),e.abs(o)<1e-8*i)break}return i},t.erf=function(t){var n,r,i,o,a=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,1.5626441722e-8,-8.5238095915e-8,6.529054439e-9,5.059343495e-9,-9.91364156e-10,-2.27365122e-10,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18,-1523e-18,-94e-18,121e-18,-28e-18],s=a.length-1,u=!1,c=0,l=0;for(t<0&&(t=-t,u=!0),r=4*(n=2/(2+t))-2;s>0;s--)i=c,c=r*c-l+a[s],l=i;return o=n*e.exp(-t*t+.5*(a[0]+r*c)-l),u?o-1:1-o},t.erfc=function(e){return 1-t.erf(e)},t.erfcinv=function(n){var r,i,o,a,s=0;if(n>=2)return-100;if(n<=0)return 100;for(a=n<1?n:2-n,r=-.70711*((2.30753+.27061*(o=e.sqrt(-2*e.log(a/2))))/(1+o*(.99229+.04481*o))-o);s<2;s++)r+=(i=t.erfc(r)-a)/(1.1283791670955126*e.exp(-r*r)-r*i);return n<1?r:-r},t.ibetainv=function(n,r,i){var o,a,s,u,c,l,d,h,f,p,m=r-1,g=i-1,y=0;if(n<=0)return 0;if(n>=1)return 1;for(r>=1&&i>=1?(s=n<.5?n:1-n,l=(2.30753+.27061*(u=e.sqrt(-2*e.log(s))))/(1+u*(.99229+.04481*u))-u,n<.5&&(l=-l),d=(l*l-3)/6,h=2/(1/(2*r-1)+1/(2*i-1)),f=l*e.sqrt(d+h)/h-(1/(2*i-1)-1/(2*r-1))*(d+5/6-2/(3*h)),l=r/(r+i*e.exp(2*f))):(o=e.log(r/(r+i)),a=e.log(i/(r+i)),l=n<(u=e.exp(r*o)/r)/(f=u+(c=e.exp(i*a)/i))?e.pow(r*f*n,1/r):1-e.pow(i*f*(1-n),1/i)),p=-t.gammaln(r)-t.gammaln(i)+t.gammaln(r+i);y<10;y++){if(0===l||1===l)return l;if((l-=u=(c=(t.ibeta(l,r,i)-n)/(u=e.exp(m*e.log(l)+g*e.log(1-l)+p)))/(1-.5*e.min(1,c*(m/l-g/(1-l)))))<=0&&(l=.5*(l+u)),l>=1&&(l=.5*(l+u+1)),e.abs(u)<1e-8*l&&y>0)break}return l},t.ibeta=function(n,r,i){var o=0===n||1===n?0:e.exp(t.gammaln(r+i)-t.gammaln(r)-t.gammaln(i)+r*e.log(n)+i*e.log(1-n));return!(n<0||n>1)&&(n<(r+1)/(r+i+2)?o*t.betacf(n,r,i)/r:1-o*t.betacf(1-n,i,r)/i)},t.randn=function(n,r){var i,o,a,s,u;if(r||(r=n),n)return t.create(n,r,function(){return t.randn()});do{i=t._random_fn(),o=1.7156*(t._random_fn()-.5),u=(a=i-.449871)*a+(s=e.abs(o)+.386595)*(.196*s-.25472*a)}while(u>.27597&&(u>.27846||o*o>-4*e.log(i)*i*i));return o/i},t.randg=function(n,r,i){var o,a,s,u,c,l,d=n;if(i||(i=r),n||(n=1),r)return(l=t.zeros(r,i)).alter(function(){return t.randg(n)}),l;n<1&&(n+=1),o=n-1/3,a=1/e.sqrt(9*o);do{do{u=1+a*(c=t.randn())}while(u<=0);u*=u*u,s=t._random_fn()}while(s>1-.331*e.pow(c,4)&&e.log(s)>.5*c*c+o*(1-u+e.log(u)));if(n==d)return o*u;do{s=t._random_fn()}while(0===s);return e.pow(s,1/d)*o*u},function(e){for(var n=0;n<e.length;n++)(function(e){t.fn[e]=function(){return t(t.map(this,function(n){return t[e](n)}))}})(e[n])}("gammaln gammafn factorial factorialln".split(" ")),function(e){for(var n=0;n<e.length;n++)(function(e){t.fn[e]=function(){return t(t[e].apply(null,arguments))}})(e[n])}("randn".split(" "))}(e,Math),function(t,e){function n(t,n,r,i){for(var o,a=0,s=1,u=1,c=1,l=0,d=0;e.abs((u-d)/u)>i;)d=u,s=c+(o=-(n+l)*(n+r+l)*t/(n+2*l)/(n+2*l+1))*s,u=(a=u+o*a)+(o=(l+=1)*(r-l)*t/(n+2*l-1)/(n+2*l))*u,a/=c=s+o*c,s/=c,u/=c,c=1;return u/n}function r(n,r,i){var o=[.9815606342467192,.9041172563704749,.7699026741943047,.5873179542866175,.3678314989981802,.1252334085114689],a=[.04717533638651183,.10693932599531843,.16007832854334622,.20316742672306592,.2334925365383548,.24914704581340277],s=.5*n;if(s>=8)return 1;var u,c=2*t.normal.cdf(s,0,1,1,0)-1;c=c>=e.exp(-50/i)?e.pow(c,i):0;for(var l=s,d=(8-s)/(u=n>3?2:3),h=l+d,f=0,p=i-1,m=1;m<=u;m++){for(var g=0,y=.5*(h+l),v=.5*(h-l),w=1;w<=12;w++){var b,A=y+v*(6<w?o[(b=12-w+1)-1]:-o[(b=w)-1]),E=A*A;if(E>60)break;var C=2*t.normal.cdf(A,0,1,1,0)*.5-2*t.normal.cdf(A,n,1,1,0)*.5;C>=e.exp(-30/p)&&(g+=C=a[b-1]*e.exp(-.5*E)*e.pow(C,p))}f+=g*=2*v*i/e.sqrt(2*e.PI),l=h,h+=d}return(c+=f)<=e.exp(-30/r)?0:(c=e.pow(c,r))>=1?1:c}!function(e){for(var n=0;n<e.length;n++)(function(e){t[e]=function t(e,n,r){return this instanceof t?(this._a=e,this._b=n,this._c=r,this):new t(e,n,r)},t.fn[e]=function(n,r,i){var o=t[e](n,r,i);return o.data=this,o},t[e].prototype.sample=function(n){var r=this._a,i=this._b,o=this._c;return n?t.alter(n,function(){return t[e].sample(r,i,o)}):t[e].sample(r,i,o)},function(n){for(var r=0;r<n.length;r++)(function(n){t[e].prototype[n]=function(r){var i=this._a,o=this._b,a=this._c;return r||0===r||(r=this.data),"number"!=typeof r?t.fn.map.call(r,function(r){return t[e][n](r,i,o,a)}):t[e][n](r,i,o,a)}})(n[r])}("pdf cdf inv".split(" ")),function(n){for(var r=0;r<n.length;r++)(function(n){t[e].prototype[n]=function(){return t[e][n](this._a,this._b,this._c)}})(n[r])}("mean median mode variance".split(" "))})(e[n])}("beta centralF cauchy chisquare exponential gamma invgamma kumaraswamy laplace lognormal noncentralt normal pareto studentt weibull uniform binomial negbin hypgeom poisson triangular tukey arcsine".split(" ")),t.extend(t.beta,{pdf:function(n,r,i){return n>1||n<0?0:1==r&&1==i?1:r<512&&i<512?e.pow(n,r-1)*e.pow(1-n,i-1)/t.betafn(r,i):e.exp((r-1)*e.log(n)+(i-1)*e.log(1-n)-t.betaln(r,i))},cdf:function(e,n,r){return e>1||e<0?1*(e>1):t.ibeta(e,n,r)},inv:function(e,n,r){return t.ibetainv(e,n,r)},mean:function(t,e){return t/(t+e)},median:function(e,n){return t.ibetainv(.5,e,n)},mode:function(t,e){return(t-1)/(t+e-2)},sample:function(e,n){var r=t.randg(e);return r/(r+t.randg(n))},variance:function(t,n){return t*n/(e.pow(t+n,2)*(t+n+1))}}),t.extend(t.centralF,{pdf:function(n,r,i){var o;return n<0?0:r<=2?0===n&&r<2?1/0:0===n&&2===r?1:1/t.betafn(r/2,i/2)*e.pow(r/i,r/2)*e.pow(n,r/2-1)*e.pow(1+r/i*n,-(r+i)/2):(o=r*n/(i+n*r),r*(i/(i+n*r))/2*t.binomial.pdf((r-2)/2,(r+i-2)/2,o))},cdf:function(e,n,r){return e<0?0:t.ibeta(n*e/(n*e+r),n/2,r/2)},inv:function(e,n,r){return r/(n*(1/t.ibetainv(e,n/2,r/2)-1))},mean:function(t,e){return e>2?e/(e-2):void 0},mode:function(t,e){return t>2?e*(t-2)/(t*(e+2)):void 0},sample:function(e,n){return 2*t.randg(e/2)/e/(2*t.randg(n/2)/n)},variance:function(t,e){if(!(e<=4))return 2*e*e*(t+e-2)/(t*(e-2)*(e-2)*(e-4))}}),t.extend(t.cauchy,{pdf:function(t,n,r){return r<0?0:r/(e.pow(t-n,2)+e.pow(r,2))/e.PI},cdf:function(t,n,r){return e.atan((t-n)/r)/e.PI+.5},inv:function(t,n,r){return n+r*e.tan(e.PI*(t-.5))},median:function(t){return t},mode:function(t){return t},sample:function(n,r){return t.randn()*e.sqrt(1/(2*t.randg(.5)))*r+n}}),t.extend(t.chisquare,{pdf:function(n,r){return n<0?0:0===n&&2===r?.5:e.exp((r/2-1)*e.log(n)-n/2-r/2*e.log(2)-t.gammaln(r/2))},cdf:function(e,n){return e<0?0:t.lowRegGamma(n/2,e/2)},inv:function(e,n){return 2*t.gammapinv(e,.5*n)},mean:function(t){return t},median:function(t){return t*e.pow(1-2/(9*t),3)},mode:function(t){return t-2>0?t-2:0},sample:function(e){return 2*t.randg(e/2)},variance:function(t){return 2*t}}),t.extend(t.exponential,{pdf:function(t,n){return t<0?0:n*e.exp(-n*t)},cdf:function(t,n){return t<0?0:1-e.exp(-n*t)},inv:function(t,n){return-e.log(1-t)/n},mean:function(t){return 1/t},median:function(t){return 1/t*e.log(2)},mode:function(){return 0},sample:function(n){return-1/n*e.log(t._random_fn())},variance:function(t){return e.pow(t,-2)}}),t.extend(t.gamma,{pdf:function(n,r,i){return n<0?0:0===n&&1===r?1/i:e.exp((r-1)*e.log(n)-n/i-t.gammaln(r)-r*e.log(i))},cdf:function(e,n,r){return e<0?0:t.lowRegGamma(n,e/r)},inv:function(e,n,r){return t.gammapinv(e,n)*r},mean:function(t,e){return t*e},mode:function(t,e){if(t>1)return(t-1)*e},sample:function(e,n){return t.randg(e)*n},variance:function(t,e){return t*e*e}}),t.extend(t.invgamma,{pdf:function(n,r,i){return n<=0?0:e.exp(-(r+1)*e.log(n)-i/n-t.gammaln(r)+r*e.log(i))},cdf:function(e,n,r){return e<=0?0:1-t.lowRegGamma(n,r/e)},inv:function(e,n,r){return r/t.gammapinv(1-e,n)},mean:function(t,e){return t>1?e/(t-1):void 0},mode:function(t,e){return e/(t+1)},sample:function(e,n){return n/t.randg(e)},variance:function(t,e){if(!(t<=2))return e*e/((t-1)*(t-1)*(t-2))}}),t.extend(t.kumaraswamy,{pdf:function(t,n,r){return 0===t&&1===n?r:1===t&&1===r?n:e.exp(e.log(n)+e.log(r)+(n-1)*e.log(t)+(r-1)*e.log(1-e.pow(t,n)))},cdf:function(t,n,r){return t<0?0:t>1?1:1-e.pow(1-e.pow(t,n),r)},inv:function(t,n,r){return e.pow(1-e.pow(1-t,1/r),1/n)},mean:function(e,n){return n*t.gammafn(1+1/e)*t.gammafn(n)/t.gammafn(1+1/e+n)},median:function(t,n){return e.pow(1-e.pow(2,-1/n),1/t)},mode:function(t,n){if(t>=1&&n>=1&&1!==t&&1!==n)return e.pow((t-1)/(t*n-1),1/t)},variance:function(){throw new Error("variance not yet implemented")}}),t.extend(t.lognormal,{pdf:function(t,n,r){return t<=0?0:e.exp(-e.log(t)-.5*e.log(2*e.PI)-e.log(r)-e.pow(e.log(t)-n,2)/(2*r*r))},cdf:function(n,r,i){return n<0?0:.5+.5*t.erf((e.log(n)-r)/e.sqrt(2*i*i))},inv:function(n,r,i){return e.exp(-1.4142135623730951*i*t.erfcinv(2*n)+r)},mean:function(t,n){return e.exp(t+n*n/2)},median:function(t){return e.exp(t)},mode:function(t,n){return e.exp(t-n*n)},sample:function(n,r){return e.exp(t.randn()*r+n)},variance:function(t,n){return(e.exp(n*n)-1)*e.exp(2*t+n*n)}}),t.extend(t.noncentralt,{pdf:function(n,r,i){return e.abs(i)<1e-14?t.studentt.pdf(n,r):e.abs(n)<1e-14?e.exp(t.gammaln((r+1)/2)-i*i/2-.5*e.log(e.PI*r)-t.gammaln(r/2)):r/n*(t.noncentralt.cdf(n*e.sqrt(1+2/r),r+2,i)-t.noncentralt.cdf(n,r,i))},cdf:function(n,r,i){var o=1e-14;if(e.abs(i)<o)return t.studentt.cdf(n,r);var a=!1;n<0&&(a=!0,i=-i);for(var s=t.normal.cdf(-i,0,1),u=o+1,c=u,l=n*n/(n*n+r),d=0,h=e.exp(-i*i/2),f=e.exp(-i*i/2-.5*e.log(2)-t.gammaln(1.5))*i;d<200||c>o||u>o;)c=u,d>0&&(h*=i*i/(2*d),f*=i*i/(2*(d+.5))),s+=.5*(u=h*t.beta.cdf(l,d+.5,r/2)+f*t.beta.cdf(l,d+1,r/2)),d++;return a?1-s:s}}),t.extend(t.normal,{pdf:function(t,n,r){return e.exp(-.5*e.log(2*e.PI)-e.log(r)-e.pow(t-n,2)/(2*r*r))},cdf:function(n,r,i){return.5*(1+t.erf((n-r)/e.sqrt(2*i*i)))},inv:function(e,n,r){return-1.4142135623730951*r*t.erfcinv(2*e)+n},mean:function(t){return t},median:function(t){return t},mode:function(t){return t},sample:function(e,n){return t.randn()*n+e},variance:function(t,e){return e*e}}),t.extend(t.pareto,{pdf:function(t,n,r){return t<n?0:r*e.pow(n,r)/e.pow(t,r+1)},cdf:function(t,n,r){return t<n?0:1-e.pow(n/t,r)},inv:function(t,n,r){return n/e.pow(1-t,1/r)},mean:function(t,n){if(!(n<=1))return n*e.pow(t,n)/(n-1)},median:function(t,n){return t*(n*e.SQRT2)},mode:function(t){return t},variance:function(t,n){if(!(n<=2))return t*t*n/(e.pow(n-1,2)*(n-2))}}),t.extend(t.studentt,{pdf:function(n,r){return r=r>1e100?1e100:r,1/(e.sqrt(r)*t.betafn(.5,r/2))*e.pow(1+n*n/r,-(r+1)/2)},cdf:function(n,r){var i=r/2;return t.ibeta((n+e.sqrt(n*n+r))/(2*e.sqrt(n*n+r)),i,i)},inv:function(n,r){var i=t.ibetainv(2*e.min(n,1-n),.5*r,.5);return i=e.sqrt(r*(1-i)/i),n>.5?i:-i},mean:function(t){return t>1?0:void 0},median:function(){return 0},mode:function(){return 0},sample:function(n){return t.randn()*e.sqrt(n/(2*t.randg(n/2)))},variance:function(t){return t>2?t/(t-2):t>1?1/0:void 0}}),t.extend(t.weibull,{pdf:function(t,n,r){return t<0||n<0||r<0?0:r/n*e.pow(t/n,r-1)*e.exp(-e.pow(t/n,r))},cdf:function(t,n,r){return t<0?0:1-e.exp(-e.pow(t/n,r))},inv:function(t,n,r){return n*e.pow(-e.log(1-t),1/r)},mean:function(e,n){return e*t.gammafn(1+1/n)},median:function(t,n){return t*e.pow(e.log(2),1/n)},mode:function(t,n){return n<=1?0:t*e.pow((n-1)/n,1/n)},sample:function(n,r){return n*e.pow(-e.log(t._random_fn()),1/r)},variance:function(n,r){return n*n*t.gammafn(1+2/r)-e.pow(t.weibull.mean(n,r),2)}}),t.extend(t.uniform,{pdf:function(t,e,n){return t<e||t>n?0:1/(n-e)},cdf:function(t,e,n){return t<e?0:t<n?(t-e)/(n-e):1},inv:function(t,e,n){return e+t*(n-e)},mean:function(t,e){return.5*(t+e)},median:function(e,n){return t.mean(e,n)},mode:function(){throw new Error("mode is not yet implemented")},sample:function(e,n){return e/2+n/2+(n/2-e/2)*(2*t._random_fn()-1)},variance:function(t,n){return e.pow(n-t,2)/12}}),t.extend(t.binomial,{pdf:function(n,r,i){return 0===i||1===i?r*i===n?1:0:t.combination(r,n)*e.pow(i,n)*e.pow(1-i,r-n)},cdf:function(r,i,o){var a,s=1e-10;if(r<0)return 0;if(r>=i)return 1;if(o<0||o>1||i<=0)return NaN;var u=o,c=(r=e.floor(r))+1,l=i-r,d=c+l,h=e.exp(t.gammaln(d)-t.gammaln(l)-t.gammaln(c)+c*e.log(u)+l*e.log(1-u));return a=u<(c+1)/(d+2)?h*n(u,c,l,s):1-h*n(1-u,l,c,s),e.round(1/s*(1-a))/(1/s)}}),t.extend(t.negbin,{pdf:function(n,r,i){return n===n>>>0&&(n<0?0:t.combination(n+r-1,r-1)*e.pow(1-i,n)*e.pow(i,r))},cdf:function(e,n,r){var i=0,o=0;if(e<0)return 0;for(;o<=e;o++)i+=t.negbin.pdf(o,n,r);return i}}),t.extend(t.hypgeom,{pdf:function(n,r,i,o){if(n!=n|0)return!1;if(n<0||n<i-(r-o))return 0;if(n>o||n>i)return 0;if(2*i>r)return 2*o>r?t.hypgeom.pdf(r-i-o+n,r,r-i,r-o):t.hypgeom.pdf(o-n,r,r-i,o);if(2*o>r)return t.hypgeom.pdf(i-n,r,i,r-o);if(i<o)return t.hypgeom.pdf(n,r,o,i);for(var a=1,s=0,u=0;u<n;u++){for(;a>1&&s<o;)a*=1-i/(r-s),s++;a*=(o-u)*(i-u)/((u+1)*(r-i-o+u+1))}for(;s<o;s++)a*=1-i/(r-s);return e.min(1,e.max(0,a))},cdf:function(n,r,i,o){if(n<0||n<i-(r-o))return 0;if(n>=o||n>=i)return 1;if(2*i>r)return 2*o>r?t.hypgeom.cdf(r-i-o+n,r,r-i,r-o):1-t.hypgeom.cdf(o-n-1,r,r-i,o);if(2*o>r)return 1-t.hypgeom.cdf(i-n-1,r,i,r-o);if(i<o)return t.hypgeom.cdf(n,r,o,i);for(var a=1,s=1,u=0,c=0;c<n;c++){for(;a>1&&u<o;){var l=1-i/(r-u);s*=l,a*=l,u++}a+=s*=(o-c)*(i-c)/((c+1)*(r-i-o+c+1))}for(;u<o;u++)a*=1-i/(r-u);return e.min(1,e.max(0,a))}}),t.extend(t.poisson,{pdf:function(n,r){return r<0||n%1!=0||n<0?0:e.pow(r,n)*e.exp(-r)/t.factorial(n)},cdf:function(e,n){var r=[],i=0;if(e<0)return 0;for(;i<=e;i++)r.push(t.poisson.pdf(i,n));return t.sum(r)},mean:function(t){return t},variance:function(t){return t},sampleSmall:function(n){var r=1,i=0,o=e.exp(-n);do{i++,r*=t._random_fn()}while(r>o);return i-1},sampleLarge:function(n){var r,i,o,a,s,u,c,l,d,h,f=n;for(a=e.sqrt(f),s=e.log(f),u=.02483*(c=.931+2.53*a)-.059,l=1.1239+1.1328/(c-3.4),d=.9277-3.6224/(c-2);;){if(i=e.random()-.5,o=e.random(),h=.5-e.abs(i),r=e.floor((2*u/h+c)*i+f+.43),h>=.07&&o<=d)return r;if(!(r<0||h<.013&&o>h)&&e.log(o)+e.log(l)-e.log(u/(h*h)+c)<=r*s-f-t.loggam(r+1))return r}},sample:function(t){return t<10?this.sampleSmall(t):this.sampleLarge(t)}}),t.extend(t.triangular,{pdf:function(t,e,n,r){return n<=e||r<e||r>n?NaN:t<e||t>n?0:t<r?2*(t-e)/((n-e)*(r-e)):t===r?2/(n-e):2*(n-t)/((n-e)*(n-r))},cdf:function(t,n,r,i){return r<=n||i<n||i>r?NaN:t<=n?0:t>=r?1:t<=i?e.pow(t-n,2)/((r-n)*(i-n)):1-e.pow(r-t,2)/((r-n)*(r-i))},inv:function(t,n,r,i){return r<=n||i<n||i>r?NaN:t<=(i-n)/(r-n)?n+(r-n)*e.sqrt(t*((i-n)/(r-n))):n+(r-n)*(1-e.sqrt((1-t)*(1-(i-n)/(r-n))))},mean:function(t,e,n){return(t+e+n)/3},median:function(t,n,r){return r<=(t+n)/2?n-e.sqrt((n-t)*(n-r))/e.sqrt(2):r>(t+n)/2?t+e.sqrt((n-t)*(r-t))/e.sqrt(2):void 0},mode:function(t,e,n){return n},sample:function(n,r,i){var o=t._random_fn();return o<(i-n)/(r-n)?n+e.sqrt(o*(r-n)*(i-n)):r-e.sqrt((1-o)*(r-n)*(r-i))},variance:function(t,e,n){return(t*t+e*e+n*n-t*e-t*n-e*n)/18}}),t.extend(t.arcsine,{pdf:function(t,n,r){return r<=n?NaN:t<=n||t>=r?0:2/e.PI*e.pow(e.pow(r-n,2)-e.pow(2*t-n-r,2),-.5)},cdf:function(t,n,r){return t<n?0:t<r?2/e.PI*e.asin(e.sqrt((t-n)/(r-n))):1},inv:function(t,n,r){return n+(.5-.5*e.cos(e.PI*t))*(r-n)},mean:function(t,e){return e<=t?NaN:(t+e)/2},median:function(t,e){return e<=t?NaN:(t+e)/2},mode:function(){throw new Error("mode is not yet implemented")},sample:function(n,r){return(n+r)/2+(r-n)/2*e.sin(2*e.PI*t.uniform.sample(0,1))},variance:function(t,n){return n<=t?NaN:e.pow(n-t,2)/8}}),t.extend(t.laplace,{pdf:function(t,n,r){return r<=0?0:e.exp(-e.abs(t-n)/r)/(2*r)},cdf:function(t,n,r){return r<=0?0:t<n?.5*e.exp((t-n)/r):1-.5*e.exp(-(t-n)/r)},mean:function(t){return t},median:function(t){return t},mode:function(t){return t},variance:function(t,e){return 2*e*e},sample:function(n,r){var i,o=t._random_fn()-.5;return n-r*((i=o)/e.abs(i))*e.log(1-2*e.abs(o))}}),t.extend(t.tukey,{cdf:function(n,i,o){var a=i,s=[.9894009349916499,.9445750230732326,.8656312023878318,.755404408355003,.6178762444026438,.45801677765722737,.2816035507792589,.09501250983763744],u=[.027152459411754096,.062253523938647894,.09515851168249279,.12462897125553388,.14959598881657674,.16915651939500254,.18260341504492358,.1894506104550685];if(n<=0)return 0;if(o<2||a<2)return NaN;if(!Number.isFinite(n))return 1;if(o>25e3)return r(n,1,a);var c,l=.5*o,d=l*e.log(o)-o*e.log(2)-t.gammaln(l),h=l-1,f=.25*o;c=o<=100?1:o<=800?.5:o<=5e3?.25:.125,d+=e.log(c);for(var p=0,m=1;m<=50;m++){for(var g=0,y=(2*m-1)*c,v=1;v<=16;v++){var w,b;8<v?(w=v-8-1,b=d+h*e.log(y+s[w]*c)-(s[w]*c+y)*f):(w=v-1,b=d+h*e.log(y-s[w]*c)+(s[w]*c-y)*f),b>=-30&&(g+=r(8<v?n*e.sqrt(.5*(s[w]*c+y)):n*e.sqrt(.5*(-s[w]*c+y)),1,a)*u[w]*e.exp(b))}if(m*c>=1&&g<=1e-14)break;p+=g}if(g>1e-14)throw new Error("tukey.cdf failed to converge");return p>1&&(p=1),p},inv:function(n,r,i){if(i<2||r<2)return NaN;if(n<0||n>1)return NaN;if(0===n)return 0;if(1===n)return 1/0;var o,a=function(t,n,r){var i=.5-.5*t,o=e.sqrt(e.log(1/(i*i))),a=o+((((-453642210148e-16*o-.204231210125)*o-.342242088547)*o-1)*o+.322232421088)/((((.0038560700634*o+.10353775285)*o+.531103462366)*o+.588581570495)*o+.099348462606);r<120&&(a+=(a*a*a+a)/r/4);var s=.8832-.2368*a;return r<120&&(s+=-1.214/r+1.208*a/r),a*(s*e.log(n-1)+1.4142)}(n,r,i),s=t.tukey.cdf(a,r,i)-n;o=s>0?e.max(0,a-1):a+1;for(var u,c=t.tukey.cdf(o,r,i)-n,l=1;l<50;l++)if(u=o-c*(o-a)/(c-s),s=c,a=o,u<0&&(u=0,c=-n),c=t.tukey.cdf(u,r,i)-n,o=u,e.abs(o-a)<1e-4)return u;throw new Error("tukey.inv failed to converge")}})}(e,Math),function(t,e){var n,r,i=Array.prototype.push,o=t.utils.isArray;function a(e){return o(e)||e instanceof t}t.extend({add:function(e,n){return a(n)?(a(n[0])||(n=[n]),t.map(e,function(t,e,r){return t+n[e][r]})):t.map(e,function(t){return t+n})},subtract:function(e,n){return a(n)?(a(n[0])||(n=[n]),t.map(e,function(t,e,r){return t-n[e][r]||0})):t.map(e,function(t){return t-n})},divide:function(e,n){return a(n)?(a(n[0])||(n=[n]),t.multiply(e,t.inv(n))):t.map(e,function(t){return t/n})},multiply:function(e,n){var r,i,o,s,u,c,l,d;if(void 0===e.length&&void 0===n.length)return e*n;if(u=e.length,c=e[0].length,l=t.zeros(u,o=a(n)?n[0].length:c),d=0,a(n)){for(;d<o;d++)for(r=0;r<u;r++){for(s=0,i=0;i<c;i++)s+=e[r][i]*n[i][d];l[r][d]=s}return 1===u&&1===d?l[0][0]:l}return t.map(e,function(t){return t*n})},outer:function(e,n){return t.multiply(e.map(function(t){return[t]}),[n])},dot:function(e,n){a(e[0])||(e=[e]),a(n[0])||(n=[n]);for(var r,i,o=1===e[0].length&&1!==e.length?t.transpose(e):e,s=1===n[0].length&&1!==n.length?t.transpose(n):n,u=[],c=0,l=o.length,d=o[0].length;c<l;c++){for(u[c]=[],r=0,i=0;i<d;i++)r+=o[c][i]*s[c][i];u[c]=r}return 1===u.length?u[0]:u},pow:function(n,r){return t.map(n,function(t){return e.pow(t,r)})},exp:function(n){return t.map(n,function(t){return e.exp(t)})},log:function(n){return t.map(n,function(t){return e.log(t)})},abs:function(n){return t.map(n,function(t){return e.abs(t)})},norm:function(t,n){var r=0,i=0;for(isNaN(n)&&(n=2),a(t[0])&&(t=t[0]);i<t.length;i++)r+=e.pow(e.abs(t[i]),n);return e.pow(r,1/n)},angle:function(n,r){return e.acos(t.dot(n,r)/(t.norm(n)*t.norm(r)))},aug:function(t,e){var n,r=[];for(n=0;n<t.length;n++)r.push(t[n].slice());for(n=0;n<r.length;n++)i.apply(r[n],e[n]);return r},inv:function(e){for(var n,r=e.length,i=e[0].length,o=t.identity(r,i),a=t.gauss_jordan(e,o),s=[],u=0;u<r;u++)for(s[u]=[],n=i;n<a[0].length;n++)s[u][n-i]=a[u][n];return s},det:function t(e){if(2===e.length)return e[0][0]*e[1][1]-e[0][1]*e[1][0];for(var n=0,r=0;r<e.length;r++){for(var i=[],o=1;o<e.length;o++){i[o-1]=[];for(var a=0;a<e.length;a++)a<r?i[o-1][a]=e[o][a]:a>r&&(i[o-1][a-1]=e[o][a])}var s=r%2?-1:1;n+=t(i)*e[0][r]*s}return n},gauss_elimination:function(n,r){var i,o,a,s,u=0,c=0,l=n.length,d=n[0].length,h=1,f=0,p=[];for(i=(n=t.aug(n,r))[0].length,u=0;u<l;u++){for(o=n[u][u],c=u,s=u+1;s<d;s++)o<e.abs(n[s][u])&&(o=n[s][u],c=s);if(c!=u)for(s=0;s<i;s++)a=n[u][s],n[u][s]=n[c][s],n[c][s]=a;for(c=u+1;c<l;c++)for(h=n[c][u]/n[u][u],s=u;s<i;s++)n[c][s]=n[c][s]-h*n[u][s]}for(u=l-1;u>=0;u--){for(f=0,c=u+1;c<=l-1;c++)f+=p[c]*n[u][c];p[u]=(n[u][i-1]-f)/n[u][u]}return p},gauss_jordan:function(n,r){var i,o,a,s=t.aug(n,r),u=s.length,c=s[0].length,l=0;for(o=0;o<u;o++){var d=o;for(a=o+1;a<u;a++)e.abs(s[a][o])>e.abs(s[d][o])&&(d=a);var h=s[o];for(s[o]=s[d],s[d]=h,a=o+1;a<u;a++)for(l=s[a][o]/s[o][o],i=o;i<c;i++)s[a][i]-=s[o][i]*l}for(o=u-1;o>=0;o--){for(l=s[o][o],a=0;a<o;a++)for(i=c-1;i>o-1;i--)s[a][i]-=s[o][i]*s[a][o]/l;for(s[o][o]/=l,i=u;i<c;i++)s[o][i]/=l}return s},triaUpSolve:function(e,n){var r,i=e[0].length,o=t.zeros(1,i)[0],a=!1;return null!=n[0].length&&(n=n.map(function(t){return t[0]}),a=!0),t.arange(i-1,-1,-1).forEach(function(a){r=t.arange(a+1,i).map(function(t){return o[t]*e[a][t]}),o[a]=(n[a]-t.sum(r))/e[a][a]}),a?o.map(function(t){return[t]}):o},triaLowSolve:function(e,n){var r,i=e[0].length,o=t.zeros(1,i)[0],a=!1;return null!=n[0].length&&(n=n.map(function(t){return t[0]}),a=!0),t.arange(i).forEach(function(i){r=t.arange(i).map(function(t){return e[i][t]*o[t]}),o[i]=(n[i]-t.sum(r))/e[i][i]}),a?o.map(function(t){return[t]}):o},lu:function(e){var n,r=e.length,i=t.identity(r),o=t.zeros(e.length,e[0].length);return t.arange(r).forEach(function(t){o[0][t]=e[0][t]}),t.arange(1,r).forEach(function(a){t.arange(a).forEach(function(r){n=t.arange(r).map(function(t){return i[a][t]*o[t][r]}),i[a][r]=(e[a][r]-t.sum(n))/o[r][r]}),t.arange(a,r).forEach(function(r){n=t.arange(a).map(function(t){return i[a][t]*o[t][r]}),o[a][r]=e[n.length][r]-t.sum(n)})}),[i,o]},cholesky:function(n){var r,i=n.length,o=t.zeros(n.length,n[0].length);return t.arange(i).forEach(function(a){r=t.arange(a).map(function(t){return e.pow(o[a][t],2)}),o[a][a]=e.sqrt(n[a][a]-t.sum(r)),t.arange(a+1,i).forEach(function(e){r=t.arange(a).map(function(t){return o[a][t]*o[e][t]}),o[e][a]=(n[a][e]-t.sum(r))/o[a][a]})}),o},gauss_jacobi:function(n,r,i,o){for(var a,s,u,c,l=0,d=0,h=n.length,f=[],p=[],m=[];l<h;l++)for(f[l]=[],p[l]=[],m[l]=[],d=0;d<h;d++)l>d?(f[l][d]=n[l][d],p[l][d]=m[l][d]=0):l<d?(p[l][d]=n[l][d],f[l][d]=m[l][d]=0):(m[l][d]=n[l][d],f[l][d]=p[l][d]=0);for(u=t.multiply(t.multiply(t.inv(m),t.add(f,p)),-1),s=t.multiply(t.inv(m),r),a=i,c=t.add(t.multiply(u,i),s),l=2;e.abs(t.norm(t.subtract(c,a)))>o;)a=c,c=t.add(t.multiply(u,a),s),l++;return c},gauss_seidel:function(n,r,i,o){for(var a,s,u,c,l,d=0,h=n.length,f=[],p=[],m=[];d<h;d++)for(f[d]=[],p[d]=[],m[d]=[],a=0;a<h;a++)d>a?(f[d][a]=n[d][a],p[d][a]=m[d][a]=0):d<a?(p[d][a]=n[d][a],f[d][a]=m[d][a]=0):(m[d][a]=n[d][a],f[d][a]=p[d][a]=0);for(c=t.multiply(t.multiply(t.inv(t.add(m,f)),p),-1),u=t.multiply(t.inv(t.add(m,f)),r),s=i,l=t.add(t.multiply(c,i),u),d=2;e.abs(t.norm(t.subtract(l,s)))>o;)s=l,l=t.add(t.multiply(c,s),u),d+=1;return l},SOR:function(n,r,i,o,a){for(var s,u,c,l,d,h=0,f=n.length,p=[],m=[],g=[];h<f;h++)for(p[h]=[],m[h]=[],g[h]=[],s=0;s<f;s++)h>s?(p[h][s]=n[h][s],m[h][s]=g[h][s]=0):h<s?(m[h][s]=n[h][s],p[h][s]=g[h][s]=0):(g[h][s]=n[h][s],p[h][s]=m[h][s]=0);for(l=t.multiply(t.inv(t.add(g,t.multiply(p,a))),t.subtract(t.multiply(g,1-a),t.multiply(m,a))),c=t.multiply(t.multiply(t.inv(t.add(g,t.multiply(p,a))),r),a),u=i,d=t.add(t.multiply(l,i),c),h=2;e.abs(t.norm(t.subtract(d,u)))>o;)u=d,d=t.add(t.multiply(l,u),c),h++;return d},householder:function(n){for(var r,i,o,a,s=n.length,u=n[0].length,c=0,l=[],d=[];c<s-1;c++){for(r=0,a=c+1;a<u;a++)r+=n[a][c]*n[a][c];for(r=(n[c+1][c]>0?-1:1)*e.sqrt(r),i=e.sqrt((r*r-n[c+1][c]*r)/2),(l=t.zeros(s,1))[c+1][0]=(n[c+1][c]-r)/(2*i),o=c+2;o<s;o++)l[o][0]=n[o][c]/(2*i);d=t.subtract(t.identity(s,u),t.multiply(t.multiply(l,t.transpose(l)),2)),n=t.multiply(d,t.multiply(n,d))}return n},QR:(n=t.sum,r=t.arange,function(i){var o,a,s,u=i.length,c=i[0].length,l=t.zeros(c,c);for(i=t.copy(i),a=0;a<c;a++){for(l[a][a]=e.sqrt(n(r(u).map(function(t){return i[t][a]*i[t][a]}))),o=0;o<u;o++)i[o][a]=i[o][a]/l[a][a];for(s=a+1;s<c;s++)for(l[a][s]=n(r(u).map(function(t){return i[t][a]*i[t][s]})),o=0;o<u;o++)i[o][s]=i[o][s]-i[o][a]*l[a][s]}return[i,l]}),lstsq:function(e,n){var r=!1;void 0===n[0].length&&(n=n.map(function(t){return[t]}),r=!0);var i=t.QR(e),o=i[0],a=i[1],s=e[0].length,u=t.slice(o,{col:{end:s}}),c=function(e){var n=(e=t.copy(e)).length,r=t.identity(n);return t.arange(n-1,-1,-1).forEach(function(n){t.sliceAssign(r,{row:n},t.divide(t.slice(r,{row:n}),e[n][n])),t.sliceAssign(e,{row:n},t.divide(t.slice(e,{row:n}),e[n][n])),t.arange(n).forEach(function(i){var o=t.multiply(e[i][n],-1),a=t.slice(e,{row:i}),s=t.multiply(t.slice(e,{row:n}),o);t.sliceAssign(e,{row:i},t.add(a,s));var u=t.slice(r,{row:i}),c=t.multiply(t.slice(r,{row:n}),o);t.sliceAssign(r,{row:i},t.add(u,c))})}),r}(t.slice(a,{row:{end:s}})),l=t.transpose(u);void 0===l[0].length&&(l=[l]);var d=t.multiply(t.multiply(c,l),n);return void 0===d.length&&(d=[[d]]),r?d.map(function(t){return t[0]}):d},jacobi:function(n){for(var r,i,o,a,s,u,c,l=1,d=n.length,h=t.identity(d,d),f=[];1===l;){for(s=n[0][1],o=0,a=1,r=0;r<d;r++)for(i=0;i<d;i++)r!=i&&s<e.abs(n[r][i])&&(s=e.abs(n[r][i]),o=r,a=i);for(u=n[o][o]===n[a][a]?n[o][a]>0?e.PI/4:-e.PI/4:e.atan(2*n[o][a]/(n[o][o]-n[a][a]))/2,(c=t.identity(d,d))[o][o]=e.cos(u),c[o][a]=-e.sin(u),c[a][o]=e.sin(u),c[a][a]=e.cos(u),h=t.multiply(h,c),n=t.multiply(t.multiply(t.inv(c),n),c),l=0,r=1;r<d;r++)for(i=1;i<d;i++)r!=i&&e.abs(n[r][i])>.001&&(l=1)}for(r=0;r<d;r++)f.push(n[r][r]);return[h,f]},rungekutta:function(t,e,n,r,i,o){var a,s,u;if(2===o)for(;r<=n;)i+=((a=e*t(r,i))+(s=e*t(r+e,i+a)))/2,r+=e;if(4===o)for(;r<=n;)i+=((a=e*t(r,i))+2*(s=e*t(r+e/2,i+a/2))+2*(u=e*t(r+e/2,i+s/2))+e*t(r+e,i+u))/6,r+=e;return i},romberg:function(t,n,r,i){for(var o,a,s,u,c,l=0,d=(r-n)/2,h=[],f=[],p=[];l<i/2;){for(c=t(n),s=n,u=0;s<=r;s+=d,u++)h[u]=s;for(o=h.length,s=1;s<o-1;s++)c+=(s%2!=0?4:2)*t(h[s]);c=d/3*(c+t(r)),p[l]=c,d/=2,l++}for(a=p.length,o=1;1!==a;){for(s=0;s<a-1;s++)f[s]=(e.pow(4,o)*p[s+1]-p[s])/(e.pow(4,o)-1);a=f.length,p=f,f=[],o++}return p},richardson:function(t,n,r,i){function o(t,e){for(var n,r=0,i=t.length;r<i;r++)t[r]===e&&(n=r);return n}for(var a,s,u,c,l,d=e.abs(r-t[o(t,r)+1]),h=0,f=[],p=[];i>=d;)a=o(t,r+i),s=o(t,r),f[h]=(n[a]-2*n[s]+n[2*s-a])/(i*i),i/=2,h++;for(c=f.length,u=1;1!=c;){for(l=0;l<c-1;l++)p[l]=(e.pow(4,u)*f[l+1]-f[l])/(e.pow(4,u)-1);c=p.length,f=p,p=[],u++}return f},simpson:function(t,e,n,r){for(var i,o=(n-e)/r,a=t(e),s=[],u=e,c=0,l=1;u<=n;u+=o,c++)s[c]=u;for(i=s.length;l<i-1;l++)a+=(l%2!=0?4:2)*t(s[l]);return o/3*(a+t(n))},hermite:function(t,e,n,r){for(var i,o=t.length,a=0,s=0,u=[],c=[],l=[],d=[];s<o;s++){for(u[s]=1,i=0;i<o;i++)s!=i&&(u[s]*=(r-t[i])/(t[s]-t[i]));for(c[s]=0,i=0;i<o;i++)s!=i&&(c[s]+=1/(t[s]-t[i]));l[s]=(1-2*(r-t[s])*c[s])*(u[s]*u[s]),d[s]=(r-t[s])*(u[s]*u[s]),a+=l[s]*e[s]+d[s]*n[s]}return a},lagrange:function(t,e,n){for(var r,i,o=0,a=0,s=t.length;a<s;a++){for(i=e[a],r=0;r<s;r++)a!=r&&(i*=(n-t[r])/(t[a]-t[r]));o+=i}return o},cubic_spline:function(e,n,r){for(var i,o,a=e.length,s=0,u=[],c=[],l=[],d=[],h=[],f=[];s<a-1;s++)d[s]=e[s+1]-e[s];for(l[0]=0,s=1;s<a-1;s++)l[s]=3/d[s]*(n[s+1]-n[s])-3/d[s-1]*(n[s]-n[s-1]);for(s=1;s<a-1;s++)u[s]=[],c[s]=[],u[s][s-1]=d[s-1],u[s][s]=2*(d[s-1]+d[s]),u[s][s+1]=d[s],c[s][0]=l[s];for(o=t.multiply(t.inv(u),c),i=0;i<a-1;i++)h[i]=(n[i+1]-n[i])/d[i]-d[i]*(o[i+1][0]+2*o[i][0])/3,f[i]=(o[i+1][0]-o[i][0])/(3*d[i]);for(i=0;i<a&&!(e[i]>r);i++);return n[i-=1]+(r-e[i])*h[i]+t.sq(r-e[i])*o[i]+(r-e[i])*t.sq(r-e[i])*f[i]},gauss_quadrature:function(){throw new Error("gauss_quadrature not yet implemented")},PCA:function(e){var n,r,i,o,a,s=e.length,u=e[0].length,c=0,l=[],d=[],h=[],f=[],p=[],m=[],g=[];for(c=0;c<s;c++)l[c]=t.sum(e[c])/u;for(c=0;c<u;c++)for(p[c]=[],n=0;n<s;n++)p[c][n]=e[n][c]-l[n];for(p=t.transpose(p),c=0;c<s;c++)for(m[c]=[],n=0;n<s;n++)m[c][n]=t.dot([p[c]],[p[n]])/(u-1);for(a=(i=t.jacobi(m))[0],d=i[1],g=t.transpose(a),c=0;c<d.length;c++)for(n=c;n<d.length;n++)d[c]<d[n]&&(r=d[c],d[c]=d[n],d[n]=r,h=g[c],g[c]=g[n],g[n]=h);for(o=t.transpose(p),c=0;c<s;c++)for(f[c]=[],n=0;n<o.length;n++)f[c][n]=t.dot([g[c]],[o[n]]);return[e,d,g,f]}}),function(e){for(var n=0;n<e.length;n++)(function(e){t.fn[e]=function(n,r){var i=this;return r?(setTimeout(function(){r.call(i,t.fn[e].call(i,n))},15),this):"number"==typeof t[e](this,n)?t[e](this,n):t(t[e](this,n))}})(e[n])}("add divide multiply subtract dot pow exp log abs norm angle".split(" "))}(e,Math),function(t,e){var n=[].slice,r=t.utils.isNumber,i=t.utils.isArray;function o(t,n,r,i){if(t>1||r>1||t<=0||r<=0)throw new Error("Proportions should be greater than 0 and less than 1");var o=(t*n+r*i)/(n+i);return(t-r)/e.sqrt(o*(1-o)*(1/n+1/i))}t.extend({zscore:function(){var e=n.call(arguments);return r(e[1])?(e[0]-e[1])/e[2]:(e[0]-t.mean(e[1]))/t.stdev(e[1],e[2])},ztest:function(){var r,o=n.call(arguments);return i(o[1])?(r=t.zscore(o[0],o[1],o[3]),1===o[2]?t.normal.cdf(-e.abs(r),0,1):2*t.normal.cdf(-e.abs(r),0,1)):o.length>2?(r=t.zscore(o[0],o[1],o[2]),1===o[3]?t.normal.cdf(-e.abs(r),0,1):2*t.normal.cdf(-e.abs(r),0,1)):(r=o[0],1===o[1]?t.normal.cdf(-e.abs(r),0,1):2*t.normal.cdf(-e.abs(r),0,1))}}),t.extend(t.fn,{zscore:function(t,e){return(t-this.mean())/this.stdev(e)},ztest:function(n,r,i){var o=e.abs(this.zscore(n,i));return 1===r?t.normal.cdf(-o,0,1):2*t.normal.cdf(-o,0,1)}}),t.extend({tscore:function(){var r=n.call(arguments);return 4===r.length?(r[0]-r[1])/(r[2]/e.sqrt(r[3])):(r[0]-t.mean(r[1]))/(t.stdev(r[1],!0)/e.sqrt(r[1].length))},ttest:function(){var i,o=n.call(arguments);return 5===o.length?(i=e.abs(t.tscore(o[0],o[1],o[2],o[3])),1===o[4]?t.studentt.cdf(-i,o[3]-1):2*t.studentt.cdf(-i,o[3]-1)):r(o[1])?(i=e.abs(o[0]),1==o[2]?t.studentt.cdf(-i,o[1]-1):2*t.studentt.cdf(-i,o[1]-1)):(i=e.abs(t.tscore(o[0],o[1])),1==o[2]?t.studentt.cdf(-i,o[1].length-1):2*t.studentt.cdf(-i,o[1].length-1))}}),t.extend(t.fn,{tscore:function(t){return(t-this.mean())/(this.stdev(!0)/e.sqrt(this.cols()))},ttest:function(n,r){return 1===r?1-t.studentt.cdf(e.abs(this.tscore(n)),this.cols()-1):2*t.studentt.cdf(-e.abs(this.tscore(n)),this.cols()-1)}}),t.extend({anovafscore:function(){var r,i,o,a,s,u,c,l,d=n.call(arguments);if(1===d.length){for(s=new Array(d[0].length),c=0;c<d[0].length;c++)s[c]=d[0][c];d=s}for(i=new Array,c=0;c<d.length;c++)i=i.concat(d[c]);for(o=t.mean(i),r=0,c=0;c<d.length;c++)r+=d[c].length*e.pow(t.mean(d[c])-o,2);for(r/=d.length-1,u=0,c=0;c<d.length;c++)for(a=t.mean(d[c]),l=0;l<d[c].length;l++)u+=e.pow(d[c][l]-a,2);return r/(u/(i.length-d.length))},anovaftest:function(){var e,i,o,a,s=n.call(arguments);if(r(s[0]))return 1-t.centralF.cdf(s[0],s[1],s[2]);var u=t.anovafscore(s);for(e=s.length-1,o=0,a=0;a<s.length;a++)o+=s[a].length;return i=o-e-1,1-t.centralF.cdf(u,e,i)},ftest:function(e,n,r){return 1-t.centralF.cdf(e,n,r)}}),t.extend(t.fn,{anovafscore:function(){return t.anovafscore(this.toArray())},anovaftes:function(){var e,n=0;for(e=0;e<this.length;e++)n+=this[e].length;return t.ftest(this.anovafscore(),this.length-1,n-this.length)}}),t.extend({qscore:function(){var i,o,a,s,u,c=n.call(arguments);return r(c[0])?(i=c[0],o=c[1],a=c[2],s=c[3],u=c[4]):(i=t.mean(c[0]),o=t.mean(c[1]),a=c[0].length,s=c[1].length,u=c[2]),e.abs(i-o)/(u*e.sqrt((1/a+1/s)/2))},qtest:function(){var e,r=n.call(arguments);3===r.length?(e=r[0],r=r.slice(1)):7===r.length?(e=t.qscore(r[0],r[1],r[2],r[3],r[4]),r=r.slice(5)):(e=t.qscore(r[0],r[1],r[2]),r=r.slice(3));var i=r[0],o=r[1];return 1-t.tukey.cdf(e,o,i-o)},tukeyhsd:function(e){for(var n=t.pooledstdev(e),r=e.map(function(e){return t.mean(e)}),i=e.reduce(function(t,e){return t+e.length},0),o=[],a=0;a<e.length;++a)for(var s=a+1;s<e.length;++s){var u=t.qtest(r[a],r[s],e[a].length,e[s].length,n,i,e.length);o.push([[a,s],u])}return o}}),t.extend({normalci:function(){var r,i=n.call(arguments),o=new Array(2);return r=4===i.length?e.abs(t.normal.inv(i[1]/2,0,1)*i[2]/e.sqrt(i[3])):e.abs(t.normal.inv(i[1]/2,0,1)*t.stdev(i[2])/e.sqrt(i[2].length)),o[0]=i[0]-r,o[1]=i[0]+r,o},tci:function(){var r,i=n.call(arguments),o=new Array(2);return r=4===i.length?e.abs(t.studentt.inv(i[1]/2,i[3]-1)*i[2]/e.sqrt(i[3])):e.abs(t.studentt.inv(i[1]/2,i[2].length-1)*t.stdev(i[2],!0)/e.sqrt(i[2].length)),o[0]=i[0]-r,o[1]=i[0]+r,o},significant:function(t,e){return t<e}}),t.extend(t.fn,{normalci:function(e,n){return t.normalci(e,n,this.toArray())},tci:function(e,n){return t.tci(e,n,this.toArray())}}),t.extend(t.fn,{oneSidedDifferenceOfProportions:function(e,n,r,i){var a=o(e,n,r,i);return t.ztest(a,1)},twoSidedDifferenceOfProportions:function(e,n,r,i){var a=o(e,n,r,i);return t.ztest(a,2)}})}(e,Math),e.models=function(){function t(t,n){var r=t.length,i=n[0].length-1,o=r-i-1,a=e.lstsq(n,t),s=e.multiply(n,a.map(function(t){return[t]})).map(function(t){return t[0]}),u=e.subtract(t,s),c=e.mean(t),l=e.sum(s.map(function(t){return Math.pow(t-c,2)})),d=e.sum(t.map(function(t,e){return Math.pow(t-s[e],2)})),h=l+d;return{exog:n,endog:t,nobs:r,df_model:i,df_resid:o,coef:a,predict:s,resid:u,ybar:c,SST:h,SSE:l,SSR:d,R2:l/h}}function n(n){var r,i,o=(r=n.exog,i=r[0].length,e.arange(i).map(function(n){var o=e.arange(i).filter(function(t){return t!==n});return t(e.col(r,n).map(function(t){return t[0]}),e.col(r,o))})),a=Math.sqrt(n.SSR/n.df_resid),s=o.map(function(t){var e=t.SST,n=t.R2;return a/Math.sqrt(e*(1-n))}),u=n.coef.map(function(t,e){return(t-0)/s[e]}),c=u.map(function(t){var r=e.studentt.cdf(t,n.df_resid);return 2*(r>.5?1-r:r)}),l=e.studentt.inv(.975,n.df_resid),d=n.coef.map(function(t,e){var n=l*s[e];return[t-n,t+n]});return{se:s,t:u,p:c,sigmaHat:a,interval95:d}}return{ols:function(r,i){var o=t(r,i),a=n(o),s=function(t){var n,r,i,o=t.R2/t.df_model/((1-t.R2)/t.df_resid);return{F_statistic:o,pvalue:1-(n=o,r=t.df_model,i=t.df_resid,e.beta.cdf(n/(i/r+n),r/2,i/2))}}(o),u=1-(1-o.R2)*((o.nobs-1)/o.df_resid);return o.t=a,o.f=s,o.adjust_R2=u,o}}}(),e.extend({buildxmatrix:function(){for(var t=new Array(arguments.length),n=0;n<arguments.length;n++){t[n]=[1].concat(arguments[n])}return e(t)},builddxmatrix:function(){for(var t=new Array(arguments[0].length),n=0;n<arguments[0].length;n++){t[n]=[1].concat(arguments[0][n])}return e(t)},buildjxmatrix:function(t){for(var n=new Array(t.length),r=0;r<t.length;r++)n[r]=t[r];return e.builddxmatrix(n)},buildymatrix:function(t){return e(t).transpose()},buildjymatrix:function(t){return t.transpose()},matrixmult:function(t,n){var r,i,o,a,s;if(t.cols()==n.rows()){if(n.rows()>1){for(a=[],r=0;r<t.rows();r++)for(a[r]=[],i=0;i<n.cols();i++){for(s=0,o=0;o<t.cols();o++)s+=t.toArray()[r][o]*n.toArray()[o][i];a[r][i]=s}return e(a)}for(a=[],r=0;r<t.rows();r++)for(a[r]=[],i=0;i<n.cols();i++){for(s=0,o=0;o<t.cols();o++)s+=t.toArray()[r][o]*n.toArray()[i];a[r][i]=s}return e(a)}},regress:function(t,n){var r=e.xtranspxinv(t),i=t.transpose(),o=e.matrixmult(e(r),i);return e.matrixmult(o,n)},regresst:function(t,n,r){var i=e.regress(t,n),o={anova:{}},a=e.jMatYBar(t,i);o.yBar=a;var s=n.mean();o.anova.residuals=e.residuals(n,a),o.anova.ssr=e.ssr(a,s),o.anova.msr=o.anova.ssr/(t[0].length-1),o.anova.sse=e.sse(n,a),o.anova.mse=o.anova.sse/(n.length-(t[0].length-1)-1),o.anova.sst=e.sst(n,s),o.anova.mst=o.anova.sst/(n.length-1),o.anova.r2=1-o.anova.sse/o.anova.sst,o.anova.r2<0&&(o.anova.r2=0),o.anova.fratio=o.anova.msr/o.anova.mse,o.anova.pvalue=e.anovaftest(o.anova.fratio,t[0].length-1,n.length-(t[0].length-1)-1),o.anova.rmse=Math.sqrt(o.anova.mse),o.anova.r2adj=1-o.anova.mse/o.anova.mst,o.anova.r2adj<0&&(o.anova.r2adj=0),o.stats=new Array(t[0].length);for(var u,c,l,d=e.xtranspxinv(t),h=0;h<i.length;h++)u=Math.sqrt(o.anova.mse*Math.abs(d[h][h])),c=Math.abs(i[h]/u),l=e.ttest(c,n.length-t[0].length-1,r),o.stats[h]=[i[h],u,c,l];return o.regress=i,o},xtranspx:function(t){return e.matrixmult(t.transpose(),t)},xtranspxinv:function(t){var n=e.matrixmult(t.transpose(),t);return e.inv(n)},jMatYBar:function(t,n){var r=e.matrixmult(t,n);return new e(r)},residuals:function(t,n){return e.matrixsubtract(t,n)},ssr:function(t,e){for(var n=0,r=0;r<t.length;r++)n+=Math.pow(t[r]-e,2);return n},sse:function(t,e){for(var n=0,r=0;r<t.length;r++)n+=Math.pow(t[r]-e[r],2);return n},sst:function(t,e){for(var n=0,r=0;r<t.length;r++)n+=Math.pow(t[r]-e,2);return n},matrixsubtract:function(t,n){for(var r=new Array(t.length),i=0;i<t.length;i++){r[i]=new Array(t[i].length);for(var o=0;o<t[i].length;o++)r[i][o]=t[i][o]-n[i][o]}return e(r)}}),e.jStat=e,e)},7659:t=>{"use strict";var e={};t.exports=function(t,n){var r=function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}e[t]=n}return e[t]}(t);if(!r)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");r.appendChild(n)}},7825:t=>{"use strict";t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(n){!function(t,e,n){var r="";n.supports&&(r+="@supports (".concat(n.supports,") {")),n.media&&(r+="@media ".concat(n.media," {"));var i=void 0!==n.layer;i&&(r+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),r+=n.css,i&&(r+="}"),n.media&&(r+="}"),n.supports&&(r+="}");var o=n.sourceMap;o&&"undefined"!=typeof btoa&&(r+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(o))))," */")),e.styleTagTransform(r,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},7939:(t,e,n)=>{"use strict";n.d(e,{A:()=>s});var r=n(1354),i=n.n(r),o=n(6314),a=n.n(o)()(i());a.push([t.id,".scatter_plot_link {\n right: 10px;\n}\n\n.cliffs_div {\n flex-grow: initial!important;\n justify-content: flex-end;\n flex-wrap: wrap;\n}\n\n.cliffs_grid {\n margin: 0!important;\n}\n\n.ml-dim-reduction-settings-input i.grok-icon.grok-font-icon-settings {\n font-size: 18px;\n position: absolute;\n height: 28px;\n}\n\n.ml-dim-reduction-settings-input i.grok-icon.grok-font-icon-settings:not(.ml-dim-reduction-column-editor-input-root i) {\n left: -20px;\n}\n.dlg-dimensionality-reduction.ui-form, .dlg-markov-clustering.ui-form, .dlg-markov-clustering.ui-form .ui-form, .dlg-dimensionality-reduction.ui-form .ui-form {\n max-width: unset;\n}\n\n.ml-dim-reduction-column-editor-input-root label {\n display: none !important;\n}\n\n.dim-reduction-dialog-form > .ui-input-root, .dim-reduction-dialog-form > div > .ui-input-root {\n margin-left: 10px;\n}\n\n.ml-dim-reduction-column-editor-input-root input, .ml-dim-reduction-column-editor-input-root select {\n margin-left: 20px !important;\n}\n\nh3.ml-dim-reduction-column-editor-input-root {\n margin: 0 !important;\n}\n\n.ml-dim-reduction-column-editor-root, .ml-dim-reduction-column-editor-header-root {\n display: flex;\n flex-direction: row;\n align-items: center;\n margin-bottom: 10px !important;\n width: 700px !important;\n}\n\n.ml-dim-reduction-column-editor-column-title {\n text-overflow: ellipsis;\n overflow: hidden;\n}\n\n.ml-dim-reduction-column-editor-header-root > h1:not(:first-child) {\n margin-left: 20px !important;\n}\n\n.ml-dim-reduction-column-editor-table-root .header > td:not(:first-child) {\n padding-left: 32px;\n}","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/ml/css/styles.css"],names:[],mappings:"AAAA;IACI,WAAW;AACf;;AAEA;IACI,4BAA4B;IAC5B,yBAAyB;IACzB,eAAe;AACnB;;AAEA;GACG,mBAAmB;AACtB;;AAEA;IACI,eAAe;IACf,kBAAkB;IAClB,YAAY;AAChB;;AAEA;IACI,WAAW;AACf;AACA;IACI,gBAAgB;AACpB;;AAEA;IACI,wBAAwB;AAC5B;;AAEA;IACI,iBAAiB;AACrB;;AAEA;IACI,4BAA4B;AAChC;;AAEA;IACI,oBAAoB;AACxB;;AAEA;IACI,aAAa;IACb,mBAAmB;IACnB,mBAAmB;IACnB,8BAA8B;IAC9B,uBAAuB;AAC3B;;AAEA;IACI,uBAAuB;IACvB,gBAAgB;AACpB;;AAEA;IACI,4BAA4B;AAChC;;AAEA;IACI,kBAAkB;AACtB",sourcesContent:[".scatter_plot_link {\n right: 10px;\n}\n\n.cliffs_div {\n flex-grow: initial!important;\n justify-content: flex-end;\n flex-wrap: wrap;\n}\n\n.cliffs_grid {\n margin: 0!important;\n}\n\n.ml-dim-reduction-settings-input i.grok-icon.grok-font-icon-settings {\n font-size: 18px;\n position: absolute;\n height: 28px;\n}\n\n.ml-dim-reduction-settings-input i.grok-icon.grok-font-icon-settings:not(.ml-dim-reduction-column-editor-input-root i) {\n left: -20px;\n}\n.dlg-dimensionality-reduction.ui-form, .dlg-markov-clustering.ui-form, .dlg-markov-clustering.ui-form .ui-form, .dlg-dimensionality-reduction.ui-form .ui-form {\n max-width: unset;\n}\n\n.ml-dim-reduction-column-editor-input-root label {\n display: none !important;\n}\n\n.dim-reduction-dialog-form > .ui-input-root, .dim-reduction-dialog-form > div > .ui-input-root {\n margin-left: 10px;\n}\n\n.ml-dim-reduction-column-editor-input-root input, .ml-dim-reduction-column-editor-input-root select {\n margin-left: 20px !important;\n}\n\nh3.ml-dim-reduction-column-editor-input-root {\n margin: 0 !important;\n}\n\n.ml-dim-reduction-column-editor-root, .ml-dim-reduction-column-editor-header-root {\n display: flex;\n flex-direction: row;\n align-items: center;\n margin-bottom: 10px !important;\n width: 700px !important;\n}\n\n.ml-dim-reduction-column-editor-column-title {\n text-overflow: ellipsis;\n overflow: hidden;\n}\n\n.ml-dim-reduction-column-editor-header-root > h1:not(:first-child) {\n margin-left: 20px !important;\n}\n\n.ml-dim-reduction-column-editor-table-root .header > td:not(:first-child) {\n padding-left: 32px;\n}"],sourceRoot:""}]);const s=a},8153:(t,e)=>{function n(t){return"number"!=typeof t||isNaN(t)?1:t}e.Fd=function(t){return function(t,e){var n={},r=function(t){return void 0===t?e:t};"function"==typeof e&&(r=e);var i=function(e){return r(e[t])},o=function(){return r(void 0)};return"string"==typeof t?(n.fromAttributes=i,n.fromGraph=function(t,e){return i(t.getEdgeAttributes(e))},n.fromEntry=function(t,e){return i(e)},n.fromPartialEntry=n.fromEntry,n.fromMinimalEntry=n.fromEntry):"function"==typeof t?(n.fromAttributes=function(){throw new Error("graphology-utils/getters/createEdgeValueGetter: irrelevant usage.")},n.fromGraph=function(e,n){var i=e.extremities(n);return r(t(n,e.getEdgeAttributes(n),i[0],i[1],e.getNodeAttributes(i[0]),e.getNodeAttributes(i[1]),e.isUndirected(n)))},n.fromEntry=function(e,n,i,o,a,s,u){return r(t(e,n,i,o,a,s,u))},n.fromPartialEntry=function(e,n,i,o){return r(t(e,n,i,o))},n.fromMinimalEntry=function(e,n){return r(t(e,n))}):(n.fromAttributes=o,n.fromGraph=o,n.fromEntry=o,n.fromMinimalEntry=o),n}(t,n)}},8903:(t,e,n)=>{var r=n(1736),i=n(8153).Fd,o=n(2561),a=n(1782),s=n(9937);function u(t,e,n){if(!r(e))throw new Error("graphology-layout-forceatlas2: the given graph is not a valid graphology instance.");"number"==typeof n&&(n={iterations:n});var u=n.iterations;if("number"!=typeof u)throw new Error("graphology-layout-forceatlas2: invalid number of iterations.");if(u<=0)throw new Error("graphology-layout-forceatlas2: you should provide a positive number of iterations.");var c=i("getEdgeWeight"in n?n.getEdgeWeight:"weight").fromEntry,l="function"==typeof n.outputReducer?n.outputReducer:null,d=a.assign({},s,n.settings),h=a.validateSettings(d);if(h)throw new Error("graphology-layout-forceatlas2: "+h.message);var f,p=a.graphToByteArrays(e,c);for(f=0;f<u;f++)o(d,p.nodes,p.edges);if(!t)return a.collectLayoutChanges(e,p.nodes);a.assignLayoutChanges(e,p.nodes,l)}var c=u.bind(null,!1);c.assign=u.bind(null,!0),c.inferSettings=function(t){var e="number"==typeof t?t:t.order;return{barnesHutOptimize:e>2e3,strongGravityMode:!0,gravity:.05,scalingRatio:10,slowDown:1+Math.log(e)}},t.exports=c},9937:t=>{t.exports={linLogMode:!1,outboundAttractionDistribution:!1,adjustSizes:!1,edgeWeightInfluence:1,scalingRatio:1,strongGravityMode:!1,gravity:1,slowDown:1,barnesHutOptimize:!1,barnesHutTheta:.5}}},e={};function n(r){var i=e[r];if(void 0!==i)return i.exports;var o=e[r]={id:r,loaded:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}n.m=t,n.amdO={},n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.u=t=>t+".js",n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.hmd=t=>((t=Object.create(t)).children||(t.children=[]),Object.defineProperty(t,"exports",{enumerable:!0,set:()=>{throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+t.id)}}),t),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{var t;n.g.importScripts&&(t=n.g.location+"");var e=n.g.document;if(!t&&e&&(e.currentScript&&"SCRIPT"===e.currentScript.tagName.toUpperCase()&&(t=e.currentScript.src),!t)){var r=e.getElementsByTagName("script");if(r.length)for(var i=r.length-1;i>-1&&(!t||!/^http(s?):/.test(t));)t=r[i--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=t})(),n.b=document.baseURI||self.location.href,n.nc=void 0;var r={};(()=>{"use strict";n.r(r),n.d(r,{GetMCLEditor:()=>Tn,MCLClustering:()=>Fn,MVA:()=>Dn,PCA:()=>Mn,PLS:()=>Rn,PackageFunctions:()=>Lr,_package:()=>Ir,anova:()=>ir,applyLinearKernelSVM:()=>Gn,applyLinearRegression:()=>ur,applyPLSRegression:()=>gr,applyPolynomialKernelSVM:()=>$n,applyRBFkernelSVM:()=>Hn,applySigmoidKernelSVM:()=>tr,applySoftmax:()=>hr,applyXGBooster:()=>Ar,dbScan:()=>_n,dbscanPostProcessingFunction:()=>Nn,demoMultivariateAnalysis:()=>kn,info:()=>Cn,init:()=>Sn,isApplicableLinearKernelSVM:()=>Vn,isApplicableLinearRegression:()=>cr,isApplicablePLSRegression:()=>yr,isApplicablePolynomialKernelSVM:()=>Xn,isApplicableRBFkernelSVM:()=>jn,isApplicableSigmoidKernelSVM:()=>er,isApplicableSoftmax:()=>fr,isApplicableXGBooster:()=>Cr,isInteractiveLinearKernelSVM:()=>Bn,isInteractiveLinearRegression:()=>lr,isInteractivePLSRegression:()=>wr,isInteractivePolynomialKernelSVM:()=>Qn,isInteractiveRBFkernelSVM:()=>Kn,isInteractiveSigmoidKernelSVM:()=>nr,isInteractiveSoftmax:()=>pr,isInteractiveXGBooster:()=>Er,kNNImputation:()=>or,kNNImputationForTable:()=>ar,markovClusteringViewer:()=>On,numberPreprocessingFunction:()=>In,reduceDimensionality:()=>Pn,stringPreprocessingFunction:()=>Ln,topMenuPLS:()=>xn,trainLinearKernelSVM:()=>Un,trainLinearRegression:()=>sr,trainPLSRegression:()=>mr,trainPolynomialKernelSVM:()=>Yn,trainRBFkernelSVM:()=>zn,trainSigmoidKernelSVM:()=>Zn,trainSoftmax:()=>dr,trainXGBooster:()=>br,visualizeLinearKernelSVM:()=>Wn,visualizePLSRegression:()=>vr,visualizePolynomialKernelSVM:()=>Jn,visualizeRBFkernelSVM:()=>qn,visualizeSigmoidKernelSVM:()=>rr});const t=grok,e=ui,i=DG,o={i32:"HEAP32",f32:"HEAPF32"},a={i32:Int32Array,f32:Float32Array},s={i32:2,f32:2},u={i32:DG.Column.fromInt32Array,f32:DG.Column.fromFloat32Array};class c{constructor(t){this.data=t}complementArrOfParams(t){t.push(this.data)}complementArrOfTypes(t){t.push("number")}allocateMemoryForBuffer(t){}isMemoryForBufferAllocated(){return!0}putDataToBuffer(t){}getDataFromBuffer(t){}freeBuffer(t){}}class l extends c{constructor(t,e,n=!1){super(t),this.type=e,this.toUpdate=n,this.buf=0,this.numOfRows=t.length}complementArrOfParams(t){t.push(this.buf),t.push(this.numOfRows)}complementArrOfTypes(t){t.push("number"),t.push("number")}allocateMemoryForBuffer(t){this.buf=t._malloc(this.numOfRows*a[this.type].BYTES_PER_ELEMENT)}isMemoryForBufferAllocated(){return 0!=this.buf}putDataToBuffer(t){if(this.isMemoryForBufferAllocated()){const e=this.type,n=s[e],r=t[o[e]];let i=null;const u=this.data;i="int"==u.type&&"i32"==e||"double"==u.type&&"f32"==e?u.getRawData():new a[e](u.getRawData()),i&&r.set(i,this.buf>>n)}}getDataFromBuffer(t){if(this.toUpdate&&this.isMemoryForBufferAllocated()){const e=this.type,n=t[o[e]],r=this.buf,i=a[e].BYTES_PER_ELEMENT,s=this.data.getRawData();for(let t=0;t<this.numOfRows;t++)s[t]=n[r/i+t]}}freeBuffer(t){this.isMemoryForBufferAllocated()&&(t._free(this.buf),this.buf=0)}}class d extends l{constructor(t,e){super([],t,!0),this.numOfRows=e}putDataToBuffer(t){}getDataFromBuffer(t){if(this.toUpdate&&this.isMemoryForBufferAllocated()){const e=this.type,n=t[o[e]],r=this.buf,i=u[e],s=new a[e](this.numOfRows);for(let t=0;t<s.length;t++)s[t]=n[r/s.BYTES_PER_ELEMENT+t];this.data=i("name",s)}}}class h extends c{constructor(t,e,n=!1){super(t),this.type=e,this.toUpdate=n,this.buf=0,this.numOfColumns=t.length,this.numOfRows=t[0].length}complementArrOfParams(t){t.push(this.buf),t.push(this.numOfRows),t.push(this.numOfColumns)}complementArrOfTypes(t){t.push("number"),t.push("number"),t.push("number")}allocateMemoryForBuffer(t){this.buf=t._malloc(this.numOfRows*this.numOfColumns*a[this.type].BYTES_PER_ELEMENT)}isMemoryForBufferAllocated(){return 0!=this.buf}putDataToBuffer(t){if(this.isMemoryForBufferAllocated()){const e=this.type,n=s[e],r=t[o[e]],i=a[e].BYTES_PER_ELEMENT;for(let t=0;t<this.numOfColumns;t++){let o=null;const s=this.data[t];o="int"==s.type&&"i32"==e||"double"==s.type&&"f32"==e?s.getRawData():new a[e](s.getRawData()),null!=o&&r.set(o,this.buf+t*this.numOfRows*i>>n)}}}getDataFromBuffer(t){if(this.toUpdate&&this.isMemoryForBufferAllocated()){const e=this.type,n=t[o[e]],r=this.numOfRows,i=this.numOfColumns,s=new a[e](n.buffer,this.buf,r*i);for(let t=0;t<i;t++){const e=this.data[t].getRawData();for(let n=0;n<r;n++)e[n]=s[n+t*r]}}}freeBuffer(t){this.isMemoryForBufferAllocated()&&(t._free(this.buf),this.buf=0)}}class f extends h{constructor(t,e,n){super([[]],t,!0),this.data=[],this.numOfColumns=n,this.numOfRows=e}putDataToBuffer(t){}getDataFromBuffer(t){if(this.toUpdate&&this.isMemoryForBufferAllocated()){const e=this.type,n=t[o[e]],r=this.numOfRows,i=this.numOfColumns,s=a[e].BYTES_PER_ELEMENT,c=u[e],l=this.buf;for(let t=0;t<i;t++){const i=new a[e](r);for(let e=0;e<r;e++)i[e]=n[l/s+e+t*r];this.data.push(c((t+1).toString(),i))}}}}const p={intColumn:t=>new l(t,"i32"),newIntColumn:t=>new d("i32",t),intColumns:t=>new h(t.toList(),"i32"),newIntColumns:(t,e)=>new f("i32",t,e),floatColumn:t=>new l(t,"f32"),newFloatColumn:t=>new d("f32",t),floatColumns:t=>new h(t.toList(),"f32"),newFloatColumns:(t,e)=>new f("f32",t,e),int:t=>new c(t),num:t=>new c(t)},m={tableFromColumns:t=>DG.DataFrame.fromColumns(t.data),num:t=>t,int:t=>t,double:t=>t,column:t=>t.data};function g(t,e,n){const r=t[e],i=r.arguments,o=[];let a=0;for(const t in i){const e=i[t];if("_callResult"!=t){switch(e.type){case"floatColumns":case"int":case"num":case"floatColumn":case"intColumn":case"intColumns":e.data=p[e.type](n[a]),a++;break;case"newFloatColumns":case"newIntColumns":const t=i[e.numOfRows.ref].data[e.numOfRows.value],r=i[e.numOfColumns.ref].data[e.numOfColumns.value];e.data=p[e.type](t,r);break;case"newFloatColumn":case"newIntColumn":const o=i[e.numOfRows.ref].data[e.numOfRows.value];e.data=p[e.type](o)}o.push(i[t].data)}}const s=function(t,e,n,r){let i;for(const e of r)e.allocateMemoryForBuffer(t);let o=!0;for(const t of r)o&=t.isMemoryForBufferAllocated();if(o){const n=[],o=[];for(const e of r)e.complementArrOfParams(n),e.complementArrOfTypes(o),e.putDataToBuffer(t);const a="number";i=t.ccall(e,a,o,n);for(const e of r)e.getDataFromBuffer(t)}for(const e of r)e.freeBuffer(t);if(null!=i)return i}(t,e,0,o);i._callResult=p.num(s);const u=r.output;if("objects"!=u.type)return m[u.type](i[u.source].data);const c=[];for(const t of u.source)c.push(i[t].data.data);return c}const y="num",v="floatColumn",w="intColumn",b="floatColumns",A="newFloatColumns",E="intColumns",C="newIntColumns",S="newFloatColumn",_="newIntColumn",M="numOfRows",N="numOfColumns",I="ref",L="value",P="int",T="double",F={intColumn:Int32Array,floatColumn:Float32Array,floatColumns:Float32Array,newFloatColumns:Float32Array,intColumns:Int32Array,newIntColumns:Int32Array,newFloatColumn:Float32Array,newIntColumn:Int32Array};function O(t,e){let n,r=[],i=0;for(const o in t){const a=t[o],s=a.type;if("_callResult"!==o){switch(s){case y:case P:case T:a.data=e[i],i++;break;case w:case v:let r;const o=e[i],u=o.length;r=o.type===P&&s===w||o.type===T&&s===v?o.getRawData().slice(0,u):new F[s](o.getRawData().slice(0,u)),a.data={array:r,numOfRows:u},i++;break;case _:case S:let c=0;n=a[M][I],c=t[n].type===y?t[n].data:t[n].data[a[M][L]],a.data={numOfRows:c},i++;break;case E:case b:let l=[];const d=e[i].byIndex(0).length;for(const t of e[i].toList())t.type===P&&s===w||t.type===T&&s===v?l.push(t.getRawData().slice(0,d)):l.push(new F[s](t.getRawData().slice(0,d)));a.data={arrays:l,numOfRows:d,numOfColumns:l.length},i++;break;case C:case A:let h=0,f=0;n=a[M][I],h=t[n].type===y?t[n].data:t[n].data[a[M][L]],n=a[N][I],f=t[n].type===y?t[n].data:t[n].data[a[N][L]],a.data={numOfRows:h,numOfColumns:f},i++;break;default:return}r.push(a)}}return r}function R(t,e){t.arguments._callResult=e.callResult,function(t,e){const n={newFloatColumns:DG.Column.fromFloat32Array,newIntColumns:DG.Column.fromInt32Array,newFloatColumn:DG.Column.fromFloat32Array,newIntColumn:DG.Column.fromInt32Array};let r=0;for(const i in t){const o=t[i];switch(o.type){case y:case P:case T:case w:case v:case b:case E:break;case S:case _:let t;null==o.name?t=(0).toString():s=o.name,o.column=n[o.type](t,e[r].array);break;case C:case A:let i=[],a=e[r].arrays.length,s=[];if(null==o.names)for(let t=1;t<=a;t++)s.push(t.toString());else s=o.names;for(let t=0;t<a;t++)i.push(n[o.type](s[t],e[r].arrays[t]));o.columns=i}r++}}(t.arguments,e.args);let n=function(t){let e=t.output;const n={newFloatColumns:"columns",newIntColumns:"columns",newFloatColumn:"column",newIntColumn:"column"};switch(e.type){case y:case P:case T:return t.arguments[e.source];case"column":return t.arguments[e.source].column;case"tableFromColumns":return DG.DataFrame.fromColumns(t.arguments[e.source].columns);case"objects":let r=[];for(let i of e.source){let e=t.arguments[i];r.push(e[n[e.type]])}return r}}(t);return function(t){for(const e in t){const n=t[e];switch(n.type){case y:case P:case T:case w:case v:case E:case b:break;case _:case S:n.column=null;break;case C:case A:n.columns=null}}}(t.arguments),n}async function x(t,e,r){return new Promise((t,i)=>{const o=new Worker(new URL(n.p+n.u(128),n.b));o.postMessage(O(EDA.principalComponentAnalysisNipals.arguments,[e,r])),o.onmessage=function(e){o.terminate(),t(R(EDA.principalComponentAnalysisNipals,e.data))}})}const D=1e-6;function k(t){if(t.type!=i.COLUMN_TYPE.FLOAT&&t.type!=i.COLUMN_TYPE.INT)throw new Error("unsupported column type: "+t.type)}function U(t){if(t.stats.missingValueCount>0)throw new Error(`The column '${t.name}' has missing values.`)}function G(t,e){if(function(t,e){if(e<1)throw new Error("components must be positive.");if(e>t.length)throw new Error("components must not be greater than features count.");for(const e of t)k(e),U(e)}(t,e),t.length*t.byIndex(0).length>1e8)throw new Error("dataframe is too big.")}function V(t,e,n){return e?n?function(t){const e=t.rowCount;for(const n of t.columns)if(n.isNumerical){const t=n.stats.stdev,r=n.stats.avg,i=n.getRawData();if(t>0)for(let n=0;n<e;++n)i[n]=(i[n]-r)/t;else for(let t=0;t<e;++t)i[t]-=r}return t}(t):function(t){const e=t.rowCount;for(const n of t.columns)if(n.isNumerical){const t=n.stats.avg;if(Math.abs(t)>D){const r=n.getRawData();for(let n=0;n<e;++n)r[n]-=t}}return t}(t):n?function(t){const e=t.rowCount;for(const n of t.columns)if(n.isNumerical){const t=n.stats.stdev;if(Math.abs(t-1)>D&&t>0){const r=n.getRawData();for(let n=0;n<e;++n)r[n]/=t}}return t}(t):t}function B(t,e,r,o,a){return s=this,u=void 0,l=function*(){G(e,r);const s=t.rowCount,u=function(t){const e=[];for(const n of t)n.stats.stdev>0&&n.stats.missingValueCount<1&&e.push(n);return i.DataFrame.fromColumns(e)}(e),c=u.columns.length;if(0===c){const t=[];for(let e=0;e<r;++e)t.push(i.Column.fromFloat32Array(`${e+1}`,new Float32Array(s).fill(0)));return i.DataFrame.fromColumns(t)}const l=c<r?r-c:0,d=Math.min(r,c);let h;if(c>900)h=yield x(0,e,d);else{const t=yield async function(t,e,r){return new Promise((t,i)=>{const o=new Worker(new URL(n.p+n.u(860),n.b));o.postMessage(O(EDA.principalComponentAnalysis.arguments,[e,r,1,0])),o.onmessage=function(e){o.terminate(),0===e.data.callResult?t(R(EDA.principalComponentAnalysis,e.data)):t(-1)}})}(0,e,d);h=-1!==t?V(t,o,a):yield x(0,e,d)}if(void 0===h)throw new Error("Failed to compute PCA");h=V(h,o,a);const f=h.columns,p=f.length;for(let t=0;t<l;++t)f.add(i.Column.fromFloat32Array(`${p+t+1}`,new Float32Array(s).fill(0)));return h},new((c=void 0)||(c=Promise))(function(t,e){function n(t){try{i(l.next(t))}catch(t){e(t)}}function r(t){try{i(l.throw(t))}catch(t){e(t)}}function i(e){var i;e.done?t(e.value):(i=e.value,i instanceof c?i:new c(function(t){t(i)})).then(n,r)}i((l=l.apply(s,u||[])).next())});var s,u,c,l}var W=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}u((r=r.apply(t,e||[])).next())})};const z="incorrect kernel.",H="mean",j="std dev",K="alpha",q="weight",Y="Kernel params",$=["linear","polynomial","RBF","sigmoid"];function X(t,e,r){return W(this,void 0,void 0,function*(){const o=e.columns;if(2!=r.categories.length)throw new Error("labels must be strings of two categories.");const a=i.Column.float(r.name,r.length);for(let t=0;t<r.length;t++)a.set(t,r.get(t)==r.categories[0]?-1:1,!1);const s=yield function(t,e,r){return W(this,void 0,void 0,function*(){!function(t){if(t.gamma<=0)throw new Error("gamma must be strictly positive.");switch(t.kernel){case 0:case 3:return;case 2:if(t.sigma<=0)throw new Error("sigma must be strictly positive.");return;case 1:if(t.cParam<=0)throw new Error("c must be strictly positive.");if(t.dParam<=0)throw new Error("d must be strictly positive.");return;default:throw new Error(z)}}(t);const o=[0,0];switch(t.kernel){case 0:break;case 2:o[0]=t.sigma;break;case 1:o[0]=t.cParam,o[1]=t.dParam;break;case 3:o[0]=t.kappa,o[1]=t.theta;break;default:throw new Error(z)}const a=i.Column.fromList("double",Y,o),s=e.toList(),u=s[0].length+1,c=s.length+1;let l;const d=async function(t,e,r,i,o,a,s,u){return new Promise((a,c)=>{const l=new Worker(new URL(n.p+n.u(656),n.b));l.postMessage(O(EDA.trainAndAnalyzeLSSVM.arguments,[t,e,r,i,o,4,s,u])),l.onmessage=function(t){l.terminate(),a(R(EDA.trainAndAnalyzeLSSVM,t.data))}})}(t.gamma,t.kernel,a,u,c,0,e,r);yield d.then(t=>{l=t},t=>{throw new Error(`Error: ${t}`)}),l[1].name=H,l[2].name=j,l[3].name=K,l[4].name=q,l[5].name="predicted",l[6].name="correctness",l[7].name="Confusion matrix";const h={trainGamma:t.gamma,kernelType:t.kernel,kernelParams:a,trainLabels:r,normalizedTrainData:i.DataFrame.fromColumns(l[0]),means:l[1],stdDevs:l[2],modelParams:l[3],modelWeights:l[4],predictedLabels:l[5],correctness:l[6],confusionMatrix:l[7],trainError:void 0,featuresCount:s.length,trainSamplesCount:s[0].length};return function(t){const e=t.confusionMatrix.getRawData(),n=e[0],r=e[3],i=e[2],o=e[1],a=n+o,s=i+r,u=n/a,c=r/s,l=n/(n+i),d=r/(r+o),h=(n+r)/(a+s),f=(u+c)/2;t.sensitivity=u,t.specificity=c,t.balancedAccuracy=f,t.positivePredicitveValue=l,t.negativePredicitveValue=d,t.trainError=100*(1-h)}(h),h})}(t,o,a);return s.realLabels=r,s})}function Q(t,e){const n=Z(e);return i.Viewer.form(n.modelInfo,{showNavigation:!1}).root}function J(t){const e=t.normalizedTrainData.columns,n=t.trainSamplesCount,r=t.featuresCount,o=i.DataFrame.fromColumns([t.realLabels]).toByteArray(),a=4+o.length+4-o.length%4,s=function(t){const e=t.kernelParams.getRawData();return i.DataFrame.fromColumns([i.Column.fromList("double","Gamma",[t.trainGamma]),i.Column.fromStrings("Kernel",[$[t.kernelType]]),i.Column.fromList("double","Kernel parameter 1",[e[0]]),i.Column.fromList("double","Kernel parameter 2",[e[1]]),i.Column.fromList("double","Features count",[t.featuresCount]),i.Column.fromList("double","Train samples count",[t.trainSamplesCount]),i.Column.fromList("double","Train error, %",[t.trainError]),i.Column.fromList("double","Balanced accuracy",[t.balancedAccuracy]),i.Column.fromList("double","Sensitivity",[t.sensitivity]),i.Column.fromList("double","Specificity",[t.specificity]),i.Column.fromList("double","Positive predicitve value",[t.positivePredicitveValue]),i.Column.fromList("double","Negative predicitve value",[t.negativePredicitveValue])])}(t).toByteArray(),u=4+s.length+4-s.length%4,c=new Uint8Array(4*(5+n+r+r+n+1+r+1+r*n)+a+u),l=c.buffer;let d=0,h=new Int32Array(l,d,3);h[0]=t.kernelType,h[1]=n,h[2]=r,d+=12;let f=new Float32Array(l,d,2);f.set(t.kernelParams.getRawData()),d+=8,f=new Float32Array(l,d,n),f.set(t.trainLabels.getRawData()),d+=4*n,f=new Float32Array(l,d,r),f.set(t.means.getRawData()),d+=4*r,f=new Float32Array(l,d,r),f.set(t.stdDevs.getRawData()),d+=4*r,f=new Float32Array(l,d,n+1),f.set(t.modelParams.getRawData()),d+=4*(n+1),f=new Float32Array(l,d,r+1),f.set(t.modelWeights.getRawData()),d+=4*(r+1);for(const t of e)f=new Float32Array(l,d,r),f.set(t.getRawData()),d+=4*r;return h=new Int32Array(l,d,1),h[0]=o.length,c.set(o,d+4),d+=a,h=new Int32Array(l,d,1),h[0]=s.length,c.set(s,d+4),d+=u,c}function Z(t){const e=t.buffer;let n=0;const r=new Int32Array(e,n,3);n+=12;const o=r[1],a=r[2],s=i.Column.fromFloat32Array(Y,new Float32Array(e,n,2));n+=8;const u=i.Column.fromFloat32Array("Labels",new Float32Array(e,n,o));n+=4*o;const c=i.Column.fromFloat32Array(H,new Float32Array(e,n,a));n+=4*a;const l=i.Column.fromFloat32Array(j,new Float32Array(e,n,a));n+=4*a;const d=i.Column.fromFloat32Array(K,new Float32Array(e,n,o+1));n+=4*(o+1);const h=i.Column.fromFloat32Array(q,new Float32Array(e,n,a+1));n+=4*(a+1);const f=[];for(let t=0;t<o;t++)f.push(i.Column.fromFloat32Array(t.toString(),new Float32Array(e,n,a))),n+=4*a;const p=i.DataFrame.fromColumns(f),m=new Int32Array(e,n,1)[0],g=m+4-m%4;n+=4;const y=i.DataFrame.fromByteArray(new Uint8Array(e,n,m)).columns.byIndex(0);n+=g;const v=new Int32Array(e,n,1)[0],w=v+4-v%4;n+=4;const b=i.DataFrame.fromByteArray(new Uint8Array(e,n,v));return n+=w,{kernelType:r[0],kernelParams:s,trainLabels:u,realLabels:y,means:c,stdDevs:l,modelParams:d,modelWeights:h,normalizedTrainData:p,modelInfo:b}}function tt(t,e){return W(this,void 0,void 0,function*(){const r=Z(new Uint8Array(e)),o=yield function(t,e){return W(this,void 0,void 0,function*(){let r;const i=async function(t,e,r,i,o,a,s,u,c){return new Promise((l,d)=>{const h=new Worker(new URL(n.p+n.u(763),n.b));h.postMessage(O(EDA.predictByLSSVM.arguments,[t,e,r,i,o,a,s,u,c])),h.onmessage=function(t){h.terminate(),l(R(EDA.predictByLSSVM,t.data))}})}(t.kernelType,t.kernelParams,t.normalizedTrainData.columns,t.trainLabels,t.means,t.stdDevs,t.modelParams,t.modelWeights,e);return yield i.then(t=>{r=t},t=>{throw new Error(`Error: ${t}`)}),r})}(r,t.columns),a=i.Column.string("prediction",o.length),s=r.realLabels.categories;for(let t=0;t<a.length;t++)a.set(t,-1==o.get(t)?s[0]:s[1]);return i.DataFrame.fromColumns([a])})}function et(t,e){const n=t.columns;if(!e.matches("categorical")||e.categories.length>2)return!1;let r=!0;for(let t=0;t<n.length;t++)r=r&&n.byIndex(t).matches("numerical");return r}function nt(t,e){return t.rowCount<=1e3}var rt,it,ot,at,st,ut,ct,lt;!function(t){t[t.COMPUTE_COMPONENTS=0]="COMPUTE_COMPONENTS",t[t.PERFORM_MVA=1]="PERFORM_MVA",t[t.DEMO=2]="DEMO"}(rt||(rt={})),function(t){t.NO_DF="No dataframe is opened",t.NO_COLS="No numeric columns without missing values",t.ONE_COL="No columns to be used as features (just one numeric columns without missing values)",t.EMPTY_DF="Dataframe is empty",t.PREDICT="Predictors must not contain a response variable",t.ENOUGH="Not enough of features",t.COMP_LIN_PLS="Components count must be less than the number of features",t.COMP_QUA_PLS="Too large components count for the quadratic PLS regression",t.COMPONENTS="Components count must be greater than 1",t.INV_INP="Invalid inputs"}(it||(it={})),function(t){t.PREDICT="Predict",t.USING="Using",t.COMPONENTS="Components",t.PLS="PLS",t.MVA="Multivariate Analysis (PLS)",t.RUN="RUN",t.NAMES="Names",t.MODEL="Observed vs. Predicted",t.FEATURE="Feature",t.REGR_COEFS="Regression Coefficients",t.XLOADING="x.loading.p",t.LOADINGS="Loadings",t.XSCORE="x.score.t",t.YSCORE="y.score.u",t.SCORES="Scores",t.EXPL_VAR="Explained Variance",t.EXPLORE="Explore",t.FEATURES="Feature names",t.BROWSE="Browse",t.ANALYSIS="Features Analysis",t.QUADRATIC="Quadratic"}(ot||(ot={})),function(t){t.PREDICT="Column with the response variable",t.FEATURES="Predictors (features)",t.COMPONENTS="Number of PLS components",t.PLS="Compute PLS components",t.MVA="Perform multivariate analysis",t.NAMES="Names of data samples",t.QUADRATIC="Specifies whether to include squared terms as additional predictors in the PLS model"}(at||(at={})),function(t){t.PLS="/help/explore/multivariate-analysis#pls-components",t.MVA="/help/explore/multivariate-analysis",t.MODEL="/help/explore/multivariate-analysis#observed-vs-predicted",t.COEFFS="/help/explore/multivariate-analysis#regression-coefficients",t.LOADINGS="/help/explore/multivariate-analysis#loadings",t.EXPL_VARS="/help/explore/multivariate-analysis#explained-variance",t.SCORES="/help/explore/multivariate-analysis#scores"}(st||(st={})),function(t){t[t.DEFAULT=3]="DEFAULT",t[t.MIN=1]="MIN"}(ut||(ut={})),function(t){t.PREFIX="PLS",t.SUFFIX="(predicted)",t.COMP="component",t.COMPS="components"}(ct||(ct={})),function(t){t[t.PREDICTION=0]="PREDICTION",t[t.REGR_COEFFS=1]="REGR_COEFFS",t[t.T_SCORES=2]="T_SCORES",t[t.U_SCORES=3]="U_SCORES",t[t.X_LOADINGS=4]="X_LOADINGS",t[t.Y_LOADINGS=5]="Y_LOADINGS"}(lt||(lt={}));const dt=[.49,.79,.99];var ht;!function(t){t.AXIS="#838383",t.CIRCLE="#0000FF",t.INVALID="#EB6767",t.VALID_TEXT="#4d5261",t.VALID_LINE="#dbdcdf"}(ht||(ht={}));const ft=[{caption:ot.MODEL,text:"Closer to the line means better price prediction."},{caption:ot.SCORES,text:"The latent factor values for each sample reflect the similarities and dissimilarities among observations."},{caption:ot.LOADINGS,text:"The impact of each feature on the latent factors: higher loading means stronger influence."},{caption:ot.REGR_COEFS,text:"Parameters of the obtained model: features make different contribution to the prediction."},{caption:ot.EXPL_VAR,text:"How well the latent components fit source data: closer to one means better fit."}],pt=ft.map(t=>`# ${t.caption}\n\n${t.text}`).join("\n\n")+`\n\n# Learn more\n \n * [Multivariate analysis](${st.MVA}),\n * [ANOVA](https://datagrok.ai/help/explore/anova)`;var mt=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}u((r=r.apply(t,e||[])).next())})};const gt=Math.min;function yt(t){const e=[],n=(t,n)=>{e.push({type:"line",formula:t,width:1,visible:!0,title:" ",min:-n,max:n,color:ht.CIRCLE})};return t.forEach(r=>{const i="${"+r+"}";e.push({type:"line",formula:`${i} = 0`,width:1,visible:!0,title:" ",color:ht.AXIS}),t.forEach(t=>{const e="${"+t+"}";dt.forEach(t=>{n(e+` = sqrt(${t*t} - ${i} * ${i})`,t),n(e+` = -sqrt(${t*t} - ${i} * ${i})`,t)})})}),e}function vt(t){return mt(this,void 0,void 0,function*(){G(t.features,t.components),k(t.predict),U(t.predict);const e=yield async function(t,e,r,i){return new Promise((t,o)=>{const a=new Worker(new URL(n.p+n.u(412),n.b));a.postMessage(O(EDA.partialLeastSquareRegression.arguments,[e,r,i])),a.onmessage=function(e){a.terminate(),t(R(EDA.partialLeastSquareRegression,e.data))}})}(t.table,t.features,t.predict,t.components);return{prediction:e[lt.PREDICTION],regressionCoefficients:e[lt.REGR_COEFFS],tScores:e[lt.T_SCORES],uScores:e[lt.U_SCORES],xLoadings:e[lt.X_LOADINGS],yLoadings:e[lt.Y_LOADINGS]}})}function wt(n){return mt(this,void 0,void 0,function*(){const r=t.shell.t;if(null===r)return void t.shell.warning(it.NO_DF);if(0===r.rowCount)return void t.shell.warning(it.EMPTY_DF);const o=[],a=[],s=[],u=t=>(t.type===i.COLUMN_TYPE.INT||t.type===i.COLUMN_TYPE.FLOAT)&&0===t.stats.missingValueCount;if(r.columns.toList().forEach(t=>{u(t)?(o.push(t.name),a.push(t)):t.type===i.COLUMN_TYPE.STRING&&s.push(t)}),0===o.length)return void t.shell.warning(it.NO_COLS);if(1===o.length)return void t.shell.warning(it.ONE_COL);let c=a.slice(0,a.length-1),l=a[a.length-1],d=gt(o.length-1,ut.DEFAULT),h=!1;const f=e.input.column(ot.PREDICT,{table:r,value:l,nullable:!1,onValueChanged:t=>{l=t,b()},filter:t=>u(t),tooltipText:at.PREDICT}),p=e.input.columns(ot.USING,{table:r,available:o,value:c,onValueChanged:t=>{c=t,b()},tooltipText:at.FEATURES}),m=e.input.int(ot.COMPONENTS,{value:d,showPlusMinus:!0,onValueChanged:t=>{d=t,b()},tooltipText:at.COMPONENTS});let g,y,v;n===rt.COMPUTE_COMPONENTS?(g=ot.PLS,y=st.PLS,v=at.PLS):(g=ot.MVA,y=st.MVA,v=at.MVA);const w=(t,n,r,i)=>{t?(n.style.color=ht.VALID_TEXT,n.style.borderBottomColor=ht.VALID_LINE,e.tooltip.bind(n,r)):(n.style.color=ht.INVALID,n.style.borderBottomColor=ht.INVALID,e.tooltip.bind(n,()=>{const t=e.label(r),n=e.label(i);return n.style.color=ht.INVALID,e.divV([t,n])}))},b=()=>{const t=(()=>{for(const t of c)if(t.name===l.name)return!1;return!0})();let e;if(t?(w(!0,f.input,at.PREDICT,""),w(!0,p.input,at.FEATURES,"")):(w(!1,f.input,at.PREDICT,it.PREDICT),w(!1,p.input,at.FEATURES,it.PREDICT)),d<1)w(!1,m.input,at.COMPONENTS,it.COMPONENTS),e=!1;else if(e=(()=>{if(d<1)return!1;const t=c.length;return h?d<=(t+1)*t/2+t:d<=t})(),e)w(!0,m.input,at.COMPONENTS,""),t&&w(!0,p.input,at.FEATURES,"");else{const t=h?it.COMP_QUA_PLS:it.COMP_LIN_PLS;w(!1,m.input,at.COMPONENTS,t),w(!1,p.input,at.FEATURES,it.ENOUGH)}const n=t&&e;return S.getButton(ot.RUN).disabled=!n,n};let A=s.length>0?s[0]:void 0;const E=e.input.column(ot.NAMES,{table:r,value:A,onValueChanged:t=>A=null!=t?t:void 0,filter:t=>t.type===i.COLUMN_TYPE.STRING});E.setTooltip(at.NAMES),E.root.hidden=0===s.length||n===rt.COMPUTE_COMPONENTS;const C=e.input.bool(ot.QUADRATIC,{value:h,tooltipText:at.QUADRATIC,onValueChanged:t=>{h=t,b()}}),S=e.dialog({title:g,helpUrl:y}).add(e.form([f,p,m,C,E])).addButton(ot.RUN,()=>mt(this,void 0,void 0,function*(){S.close(),yield function(n,r){return mt(this,void 0,void 0,function*(){var o,a;const s=n.table;n.isQuadratic&&(n=function(t){if(!t.isQuadratic)return t;const e=t.features.toList(),n=e.length,r=t.table.rowCount,o=[];let a,s,u,c,l;for(let t=0;t<n;++t){a=e[t],s=a.getRawData();for(let d=t;d<n;++d){u=e[d],c=u.getRawData(),l=new Float32Array(r);for(let t=0;t<r;++t)l[t]=s[t]*c[t];const t=i.Column.fromFloat32Array(`${a.name} x ${u.name}`,l);t.stats.stdev>0&&o.push(t)}}const d=i.DataFrame.fromColumns(e.concat(o));return{table:d,features:d.columns,isQuadratic:!0,names:t.names,predict:t.predict,components:t.components}}(n));const u=yield vt(n),c=u.tScores,l=s.columns,d=n.features,h=d.names(),f=r===rt.COMPUTE_COMPONENTS?ct.PREFIX:ot.XSCORE;if(c.forEach((t,e)=>{t.name=l.getUnusedName(`${f}${e+1}`),l.add(t)}),r===rt.COMPUTE_COMPONENTS)return;const p=t.shell.tableView(s.name),m=i.DataFrame.fromColumns([i.Column.fromStrings(ot.FEATURE,h),u.regressionCoefficients]);m.name=`${s.name}(${ot.ANALYSIS})`,t.shell.addTable(m),u.xLoadings.forEach((t,e)=>{t.name=m.columns.getUnusedName(`${ot.XLOADING}${e+1}`),m.columns.add(t)});const g=function(t,e,n,r){const o=n.length,a=t.length,s=e.getRawData(),u=new Float32Array(o),c=r.getRawData();let l=n.stats.avg;for(let e=0;e<a;++e)l-=s[e]*t.byIndex(e).stats.avg;for(let t=0;t<o;++t)u[t]=l+c[t];return i.Column.fromFloat32Array("Debiased",u,o)}(d,u.regressionCoefficients,n.predict,u.prediction);g.name=l.getUnusedName(`${n.predict.name} ${ct.SUFFIX}`),l.add(g);const y=p.addViewer(i.Viewer.scatterPlot(s,{title:ot.MODEL,xColumnName:n.predict.name,yColumnName:g.name,showRegressionLine:!0,markerType:i.MARKER_TYPE.CIRCLE,showLabels:"Always",help:st.MODEL}));void 0!==n.names&&null!==n.names&&y.setOptions({labelColumnNames:[null===(o=n.names)||void 0===o?void 0:o.name]}),u.regressionCoefficients.name=ot.REGR_COEFS;const v=p.addViewer(i.Viewer.barChart(m,{table:m.name,title:ot.REGR_COEFS,splitColumnName:ot.FEATURE,valueColumnName:u.regressionCoefficients.name,valueAggrType:i.AGG.AVG,help:st.COEFFS,showValueSelector:!1,showStackSelector:!1}));u.xLoadings.forEach((t,e)=>t.name=`${ot.XLOADING}${e+1}`);const w=p.addViewer(i.Viewer.scatterPlot(m,{table:m.name,title:ot.LOADINGS,xColumnName:`${ot.XLOADING}1`,yColumnName:`${ot.XLOADING}${u.xLoadings.length>1?"2":"1"}`,markerType:i.MARKER_TYPE.CIRCLE,labelColumnNames:[ot.FEATURE],help:st.LOADINGS})),b=c.map(t=>t.name);u.uScores.forEach((t,e)=>{t.name=l.getUnusedName(`${ot.YSCORE}${e+1}`),l.add(t),b.push(t.name)});const A=i.Viewer.scatterPlot(s,{title:ot.SCORES,xColumnName:c[0].name,yColumnName:c.length>1?c[1].name:u.uScores[0].name,markerType:i.MARKER_TYPE.CIRCLE,help:st.SCORES,showViewerFormulaLines:!0,labelColumnNames:void 0!==n.names&&null!==n.names?[null===(a=n.names)||void 0===a?void 0:a.name]:void 0});p.addViewer(A),A.meta.formulaLines.addAll(yt(b));const E=u.yLoadings.getRawData(),C=u.xLoadings.map(t=>t.getRawData()),S=s.rowCount,_=h.length,M=n.components,N=new Float32Array(M),I=[],L=[];for(let t=0;t<_;++t)L.push(new Float32Array(M));N[0]=Math.pow(E[0],2)/S,I.push(`1 ${ct.COMP}`),L.forEach((t,e)=>{t[0]=Math.pow(C[0][e],2)/S});for(let t=1;t<M;++t)N[t]=N[t-1]+Math.pow(E[t],2)/S,L.forEach((e,n)=>e[t]=e[t-1]+Math.pow(C[t][n],2)/S),I.push(`${t+1} ${ct.COMPS}`);const P=i.DataFrame.fromColumns([i.Column.fromStrings(ot.COMPONENTS,I),i.Column.fromFloat32Array(n.predict.name,N)]);P.name=`${s.name}(${ot.EXPL_VAR})`,t.shell.addTable(P),L.forEach((t,e)=>P.columns.add(i.Column.fromFloat32Array(h[e],t)));const T=p.addViewer(i.Viewer.barChart(P,{table:P.name,title:ot.EXPL_VAR,splitColumnName:ot.COMPONENTS,valueColumnName:n.predict.name,valueAggrType:i.AGG.AVG,help:st.EXPL_VARS,showCategorySelector:!1,showStackSelector:!1}));r===rt.DEMO&&(t.shell.windows.help.showHelp(e.markdown(pt)),function(t,n,r){if(t.length!==n.length)throw new Error("Non-equal size of viewer roots and descriptions");let i,o,a,s=0;const u=e.button("next",()=>{a.remove(),++s,h()},"Go to the next viewer"),c=e.button("prev",()=>{s-=1,a.remove(),h()},"Go to the previous viewer"),l=e.button("done",()=>a.remove(),"Go to the next step"),d=e.divH([c,u,l]);d.style.marginLeft="auto",d.style.marginRight="0px";const h=()=>{s<t.length&&(o=e.divV([e.markdown(n[s]),d]),a=e.hints.addHint(t[s],o,r[s]),l.hidden=s<t.length-1,u.hidden=s===t.length-1,c.hidden=s<1,i=a.querySelector("i"),i.onclick=()=>l.click())};h()}([y,A,w,v,T].map(t=>t.root),ft.map(t=>`<b>${t.caption}</b>\n\n${t.text}`),["left","left","right","right","left"]))})}({table:r,features:i.DataFrame.fromColumns(c).columns,predict:l,components:d,isQuadratic:h,names:A},n)}),void 0,v).show({x:200,y:200});setTimeout(()=>{p.value=a.filter(t=>t!==l),c=p.value},6),t.shell.v.append(S.root)})}Math.max;var bt,At=n(6572);!function(t){t.NO_DATAFRAME="No dataframe is opened",t.NO_MISSING_VALUES="No missing values",t.ONE_AVAILABLE_FEATURE="Not enough of feature columns to apply imputation using the KNN method",t.ONE_FEATURE_SELECTED="Imputation cannot be applied to",t.UNSUPPORTED_COLUMN_TYPE="Unsupported column type",t.UNSUPPORTED_IMPUTATION_STRATEGY="Unsupported imputation strategy",t.KNN_CANNOT_BE_APPLIED="KNN imputer cannot be applied: no columns to be used as features",t.KNN_NO_TARGET_COLUMNS="KNN imputer cannot be applied: no columns with missing values",t.KNN_NO_FEATURE_COLUMNS="KNN imputer cannot be applied: no feature columns",t.KNN_NOT_ENOUGH_OF_ROWS="KNN imputer cannot be applied: not enough of rows",t.KNN_IMPOSSIBLE_IMPUTATION="Imputation is impossible, no features can be used",t.INCORRECT_NEIGHBORS="Incorrect number of neighbors",t.KNN_FAILS="KNN IMPUTATION FAILS",t.CORE_ISSUE="Core issue",t.FAILED_TO_IMPUTE="Failed to impute",t.UNSUPPORTED_FILL_VALUE_TYPE="Unsupported fill value type",t.EMPTY_COLUMN="Column contains just null values",t.FAILS_TO_PREDICT_IMPUTATION_FAILS="Failed to predict imputation fails",t.WRONG_PREDICTIONS="wrong evaluation of KNN imputation fails"}(bt||(bt={}));const Et="copy";var Ct,St;!function(t){t.KNN_IMPUTER="k-NN Imputation",t.TABLE="Table",t.IN_PLACE="In-place",t.COLUMNS="Impute",t.FEATURES="Using",t.CANCEL="CANCEL",t.RUN="RUN",t.OK="OK",t.NEIGHBORS="Neighbors",t.DISTANCE="Distance",t.FILL="Fill",t.MARK="Mark",t.SIMPLE_IMPUTER="Simple impute",t.SETTINGS="Settings",t.KEEP_EMPTY="Keep empty"}(Ct||(Ct={})),function(t){t.TARGET="Columns with missing values that must be filled",t.FEATURES="Columns with features to be used for determining the 'nearest' elements in the k-NN method",t.IN_PLACE="Defines whether to use in-place imputation or add a new column without missing values",t.METRIC="Type of metric between the feature values",t.WEIGHT="Weight",t.NEIGHBORS="Neighbors count used in the KNN method",t.DISTANCE="Type of distance between elements with the specified features",t.METRIC_SETTINGS="Show additional options",t.FILL_FAILED_ITEMS="Impute missing values using a simple approach: mean, median or most frequent",t.MARK_FAILED_ITEMS="Mark missing values cells with a color",t.FILL_VALUE="Fill value",t.IMPUTATION_SETTINGS="Simple imputation settings",t.KEEP_EMPTY="Defines whether to keep empty missing values failed to be imputed OR fill them using simple imputation",t.RUN="Run imputation using the k-NN method"}(St||(St={}));const _t=[i.COLUMN_TYPE.INT,i.COLUMN_TYPE.FLOAT,i.COLUMN_TYPE.STRING,i.COLUMN_TYPE.DATE_TIME,i.COLUMN_TYPE.QNUM];function Mt(t){switch(t.type){case i.COLUMN_TYPE.INT:return i.INT_NULL;case i.COLUMN_TYPE.FLOAT:case i.COLUMN_TYPE.QNUM:case i.COLUMN_TYPE.DATE_TIME:return i.FLOAT_NULL;case i.COLUMN_TYPE.STRING:return t.max;default:throw new Error(bt.UNSUPPORTED_COLUMN_TYPE)}}var Nt,It,Lt,Pt;function Tt(t,e,n){for(const t of e)if(!n.has(t))return!1;for(const r of t){const t=n.get(r);if(void 0===t)throw new Error(bt.FAILS_TO_PREDICT_IMPUTATION_FAILS);for(const r of t){let t=!0;for(const i of e){const e=n.get(i);if(void 0===e)throw new Error(bt.FAILS_TO_PREDICT_IMPUTATION_FAILS);if(!e.includes(r)){t=!1;break}}if(t)return!0}}return!1}function Ft(t){if(t<=0||t>=1)throw new Error(Pt.INCORRECT_SIGNIFICANCE_LEVEL)}function Ot(t){const e=t.size;return e<=1?0:(t.sumOfSquares-Math.pow(t.sum,2)/e)/(e-1)}function Rt(t,e,n){Ft(n);const r=Ot(t),i=Ot(e);return 0===r||0===i?r===i:r/i<At.centralF.inv(1-n,t.size-1,e.size-1)}!function(t){t.ONE_HOT="One-hot",t.DIFFERENCE="Difference"}(Nt||(Nt={})),function(t){t.EUCLIDEAN="Euclidean",t.MANHATTAN="Manhattan"}(It||(It={})),function(t){t[t.WEIGHT=1]="WEIGHT",t[t.NEIGHBORS=4]="NEIGHBORS",t[t.IN_PLACE=1]="IN_PLACE",t[t.SELECTED=1]="SELECTED",t[t.KEEP_EMPTY=0]="KEEP_EMPTY"}(Lt||(Lt={})),function(t){t.NON_EQUAL_FACTORS_VALUES_SIZE="non-equal sizes of factor and values arrays",t.INCORRECT_SIGNIFICANCE_LEVEL="incorrect significance level",t.NON_EQUAL_VARIANCES="non-equal variances",t.NON_NORMAL_DISTRIB="non-normal distribution",t.UNSUPPORTED_COLUMN_TYPE="unsupported feature column type",t.INCORRECT_CATEGORIES_COL_TYPE="incorrect categories column type",t.SINGLE_FACTOR="single category features",t.CATS_EQUAL_SIZE="single value in each category",t.NO_FEATURE_VARIATION="no feature variation",t.NO_FEATURE_VARIATION_WITHIN_GROUPS="no feature variation within groups"}(Pt||(Pt={}));class xt{constructor(t,e,n){if(this.nullsCount=0,t.length!==e.length)throw new Error(Pt.NON_EQUAL_FACTORS_VALUES_SIZE);if(!(e.stats.stdev>0))throw new Error(Pt.NO_FEATURE_VARIATION);this.setStats(t,e,n)}areVarsEqual(t){const e=this.catCount;if(1===e)return!0;const n={sum:this.sums[0],sumOfSquares:this.sumsOfSquares[0],size:this.subSampleSizes[0]};for(let r=1;r<e;++r)if(!Rt(n,{sum:this.sums[r],sumOfSquares:this.sumsOfSquares[r],size:this.subSampleSizes[r]},t))return!1;return!0}getOneWayAnova(){let t=0,e=0,n=0,r=this.catCount,i=r;for(let o=0;o<r;++o)0!==this.subSampleSizes[o]?(t+=this.sums[o],e+=this.sumsOfSquares[o],n+=Math.pow(this.sums[o],2)/this.subSampleSizes[o]):--i;if(r=i,1===r)throw new Error(Pt.SINGLE_FACTOR);const o=this.size-this.nullsCount;if(o===r)throw new Error(Pt.CATS_EQUAL_SIZE);const a=e-Math.pow(t,2)/o,s=n-Math.pow(t,2)/o,u=a-s;if(0===u)throw new Error(Pt.NO_FEATURE_VARIATION_WITHIN_GROUPS);const c=r-1,l=o-r,d=s/c,h=u/l,f=d/h;return{ssBn:s,ssWn:u,ssTot:a,dfBn:c,dfWn:l,dfTot:o-1,msBn:d,msWn:h,fStat:f,pValue:1-At.centralF.cdf(f,c,l)}}setStats(t,e,n){const r=e.type,o=e.length,a=Mt(e);switch(r){case i.COLUMN_TYPE.INT:case i.COLUMN_TYPE.FLOAT:const r=n;this.catCount=r,this.size=o;const s=e.getRawData(),u=t.getRawData(),c=new Float64Array(r).fill(0),l=new Float64Array(r).fill(0),d=new Int32Array(r).fill(0);let h;if(t.type==i.COLUMN_TYPE.BOOL){let t=0,e=0,n=u[0];const r=8*u.BYTES_PER_ELEMENT-1;for(let i=0;i<o;++i)h=1&n>>e,s[i]!==a?(c[h]+=s[i],l[h]+=Math.pow(s[i],2),++d[h]):++this.nullsCount,++e,e>r&&(e=0,++t,n=u[t])}else{const e=t.stats.missingValueCount>0?Mt(t):-1;for(let t=0;t<o;++t)h=u[t],h!==e&&s[t]!==a?(c[h]+=s[t],l[h]+=Math.pow(s[t],2),++d[h]):++this.nullsCount}this.sums=c,this.sumsOfSquares=l,this.subSampleSizes=d;break;default:throw new Error(Pt.UNSUPPORTED_COLUMN_TYPE)}}}const Dt=[i.COLUMN_TYPE.INT,i.COLUMN_TYPE.FLOAT],kt=[i.COLUMN_TYPE.STRING,i.COLUMN_TYPE.BOOL],Ut="/help/explore/anova";var Gt,Vt;function Bt(){const n=t.shell.t;if(null===n)return void t.shell.warning("No dataframe is opened");const r=n.columns,o=[],a=[];for(const t of r)Dt.includes(t.type)?a.push(t.name):kt.includes(t.type)&&o.push(t.name);const s=o.length;if(s<1)return void t.shell.warning(e.markdown(`No acceptable factor columns:\n\n - type: ${kt.join(", ")} \n - at least two categories`));let u=n.col(Vt.FACTOR);if(null===u){let t,e=0,n=r.byName(o[0]).categories.length;for(let i=1;i<s;++i)t=r.byName(o[i]).categories.length,t<n&&(n=t,e=i);u=r.byName(o[e])}if(a.length<1)return void t.shell.warning(e.markdown(`No acceptable feature columns:\n \n - type: ${Dt.join(", ")}`));const c=e.input.column("Category",{table:n,value:u,tooltipText:"Column with factor values",onValueChanged:t=>u=t,filter:t=>o.includes(t.name),nullable:!1});let l=n.col(Vt.FEATURE);null===l&&(l=r.byName(a[0]));const d=e.input.column("Feature",{table:n,value:l,tooltipText:"Column with feature values",onValueChanged:t=>l=t,filter:t=>a.includes(t.name),nullable:!1});let h=Gt.DEFAULT;const f=e.input.float("Alpha",{min:Gt.MIN,max:Gt.MAX,value:h,nullable:!1,tooltipText:"Significance level",onValueChanged:t=>{h=t,g.disabled=h<=Gt.INFIMUM||h>=Gt.SUPREMUM}}),p=e.dialog({title:"ANOVA",helpUrl:Ut}),m=t.shell.getTableView(n.name);m.root.appendChild(p.root),p.addButton("Run",()=>{p.close();try{const r=function(t,e,n,r=!0){Ft(n);const i=t.stats.uniqueCount;if(i<2)throw new Error(Pt.SINGLE_FACTOR);const o=new xt(t,e,i);if(r&&!o.areVarsEqual(n))throw new Error(Pt.NON_EQUAL_VARIANCES);const a=o.getOneWayAnova();return{anovaTable:a,fCritical:At.centralF.inv(1-n,a.dfBn,a.dfWn),significance:n}}(u,l,h);!function(n,r,o,a){const s=t.shell.getTableView(n.name);t.shell.v=s;const u=a.anovaTable.fStat>a.fCritical,c=u?`"${r}" affects the "${o}"`:`"${r}" doesn't affect the "${o}"`,l=i.Viewer.boxPlot(n,{categoryColumnNames:[r],valueColumnName:o,showPValue:!1,showStatistics:!1,description:c,showColorSelector:!1,autoLayout:!1});let d=s.dockManager.dock(l,i.DOCK_TYPE.RIGHT,null,"ANOVA");const h=e.markdown("**Null Hypothesis:** all group means are equal.");e.tooltip.bind(h,`The "${r}" factor does not produce a significant difference in the "${o}" feature.`);const f=e.markdown("**Alternative Hypothesis:** at least one group mean differs significantly.");e.tooltip.bind(f,`The "${r}" factor produces a significant difference in the "${o}" feature.`);const p=e.markdown("**Conclusion:** "+(u?"significant differences exist between groups.":"no significant differences detected.")),m=u?e.divV([e.p(`Reject the null hypothesis, since F > F-critical: \n ${a.anovaTable.fStat.toFixed(2)} > ${a.fCritical.toFixed(2)}.`),e.h2("There is a significant difference among sample averages.")]):e.divV([e.p(`Fail to reject the null hypothesis, since F < F-critical: \n ${a.anovaTable.fStat.toFixed(2)} < ${a.fCritical.toFixed(2)}.`),e.h2("There is no significant difference among sample averages.")]);e.tooltip.bind(p,()=>m);const g=e.divV([h,f,p,e.link("Learn more",()=>window.open("https://en.wikipedia.org/wiki/F-test","_blank"),"Click to open in a new tab.")]);g.style.marginLeft="20px";const y=function(t){const n=t.anovaTable,r=i.Viewer.grid(i.DataFrame.fromColumns([i.Column.fromStrings("Source of variance",["Between groups","Within groups","Total"]),i.Column.fromList(i.COLUMN_TYPE.FLOAT,"SS",[n.ssBn,n.ssWn,n.ssTot]),i.Column.fromList(i.COLUMN_TYPE.INT,"DF",[n.dfBn,n.dfWn,n.dfTot]),i.Column.fromList(i.COLUMN_TYPE.FLOAT,"MS",[n.msBn,n.msWn,null]),i.Column.fromList(i.COLUMN_TYPE.FLOAT,"F",[n.fStat,null,null]),i.Column.fromList(i.COLUMN_TYPE.FLOAT,"F-critical",[t.fCritical,null,null]),i.Column.fromList(i.COLUMN_TYPE.FLOAT,"p-value",[n.pValue,null,null])])),o=new Map([["Source of variance","List of the explored variation sources."],["SS","Sum of squares (SS). Measure of total variation in the data."],["DF","Degrees of freedom (DF). Number of independent values that can vary."],["MS","Mean square (MS). Sum of squares divided by degrees of freedom."],["F","F-statistics (F). Ratio of between-group to within-group variance."],["F-critical",`${t.significance}-critical value of F-statistics.`],["p-value","Probability of observing this result if groups have equal means."]]);return r.onCellTooltip(function(t,n,r){if(t.isColHeader)return e.tooltip.show(e.divV([e.p(o.get(t.tableColumn.name))]),n,r),!0}),r.helpUrl=Ut,r}(a),v=e.tabControl({Analysis:e.panel([y.root]),"F-test":e.panel([g])});e.tooltip.bind(v.getPane("Analysis").header,"ANOVA results summary."),e.tooltip.bind(v.getPane("F-test").header,"Null hypothesis testing."),s.dockManager.dock(v.root,i.DOCK_TYPE.DOWN,d,"",.25),y.root.style.width="100%"}(n,u.name,l.name,r)}catch(n){n instanceof Error?(t.shell.warning((r=n.message,e.divV([e.markdown(`ANOVA cannot be performed:\n \n ${r}`),e.link("Learn more",()=>window.open("https://en.wikipedia.org/wiki/Analysis_of_variance#Assumptions","_blank"),"Click to open in a new tab")]))),m.addViewer(i.VIEWER.BOX_PLOT,{categoryColumnNames:[u.name],valueColumnName:l.name,showStatistics:!1,showPValue:!1})):t.shell.error("ANOVA fails: the platform issue")}var r},void 0,"Perform analysis of variances");const g=p.getButton("Run");p.add(c).add(d).add(f).show()}!function(t){t[t.DEFAULT=.05]="DEFAULT",t[t.MIN=.01]="MIN",t[t.MAX=.99]="MAX",t[t.INFIMUM=0]="INFIMUM",t[t.SUPREMUM=1]="SUPREMUM"}(Gt||(Gt={})),function(t){t.FACTOR="race",t.FEATURE="age"}(Vt||(Vt={}));function Wt(t,e,r,i){return o=this,a=void 0,u=function*(){return new Promise(function(o,a){const s=new Worker(new URL(n.p+n.u(682),n.b));s.postMessage({embedX:t,embedY:e,minPts:i,epsilon:r}),s.onmessage=({data:{error:t,clusters:e}})=>{s.terminate(),t?a(t):o(e)}})},new((s=void 0)||(s=Promise))(function(t,e){function n(t){try{i(u.next(t))}catch(t){e(t)}}function r(t){try{i(u.throw(t))}catch(t){e(t)}}function i(e){var i;e.done?t(e.value):(i=e.value,i instanceof s?i:new s(function(t){t(i)})).then(n,r)}i((u=u.apply(o,a||[])).next())});var o,a,s,u}n(5540);let zt=null;function Ht(){return t=this,e=void 0,r=function*(){if(!navigator.gpu)return console.error("WebGPU is not supported in this browser"),null;if(!zt&&(zt=yield navigator.gpu.requestAdapter(),null==zt))return null;let t=null;return"info"in zt&&(t=zt.info),t?jt(t.description,jt(t.vendor,"No GPU description available")):"No GPU description available"},new((n=void 0)||(n=Promise))(function(i,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}u((r=r.apply(t,e||[])).next())});var t,e,n,r}function jt(t,e){return t&&""!=t?t:e}var Kt,qt,Yt,$t,Xt,Qt,Jt,Zt,te;(qt=Kt||(Kt={})).EUCLIDEAN="EUCLIDEAN",qt.MANHATTAN="MANHATTAN",Kt.EUCLIDEAN,Kt.MANHATTAN,($t=Yt||(Yt={})).HAMMING="Hamming",$t.EUCLIDEAN="Euclidean",$t.VECTOR_COSINE="Vector Cosine",$t.MANHATTAN="Manhattan",$t.TANIMOTO="Tanimoto",$t.LEVENSTEIN="Levenshtein",$t.NEEDLEMAN_WUNSCH="Needlemann-Wunsch",$t.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance",$t.SOKAL="Sokal",$t.COSINE="Cosine",$t.ASYMMETRIC="Asymmetric",$t.Difference="Difference",$t.OneHot="One-Hot",Yt.HAMMING,Yt.EUCLIDEAN,Yt.MANHATTAN,Yt.VECTOR_COSINE,Yt.TANIMOTO,Yt.LEVENSTEIN,Yt.NEEDLEMAN_WUNSCH,Yt.MONOMER_CHEMICAL_DISTANCE,Yt.SOKAL,Yt.COSINE,Yt.ASYMMETRIC,Yt.Difference,Yt.OneHot,Yt.HAMMING,Yt.EUCLIDEAN,Yt.MANHATTAN,Yt.TANIMOTO,Yt.SOKAL,Yt.COSINE,Yt.ASYMMETRIC,Yt.LEVENSTEIN,Yt.NEEDLEMAN_WUNSCH,Yt.MONOMER_CHEMICAL_DISTANCE,Yt.Difference,Yt.OneHot,Yt.VECTOR_COSINE,new Set([Yt.HAMMING,Yt.LEVENSTEIN,Yt.NEEDLEMAN_WUNSCH,Yt.MONOMER_CHEMICAL_DISTANCE,Yt.OneHot]),new Set([Yt.HAMMING,Yt.EUCLIDEAN,Yt.MANHATTAN,Yt.MONOMER_CHEMICAL_DISTANCE,Yt.LEVENSTEIN,Yt.NEEDLEMAN_WUNSCH,Yt.TANIMOTO,Yt.COSINE,Yt.VECTOR_COSINE,Yt.SOKAL,Yt.ASYMMETRIC,Yt.OneHot,Yt.Difference]),new Set([Yt.EUCLIDEAN,Yt.MANHATTAN,Yt.OneHot,Yt.Difference,Yt.VECTOR_COSINE]),new Set([Yt.EUCLIDEAN,Yt.MANHATTAN,Yt.Difference,Yt.VECTOR_COSINE]),new Set([Yt.EUCLIDEAN,Yt.MANHATTAN,Yt.Difference]),new Set([Yt.TANIMOTO,Yt.COSINE,Yt.SOKAL,Yt.ASYMMETRIC]),function(t){t.ADD="ADD",t.SUB="SUB",t.MULT="MULT"}(Xt||(Xt={})),function(t){t.SQUARE="SQUARE",t.INVERSE="INVERSE",t.TRANSPOSE="TRANSPOSE",t.NORM="NORM",t.COLUMN_NORM="COLUMN_NORM"}(Qt||(Qt={})),function(t){t.SCALARMULT="SCALARMULT",t.SCALARADD="SCALARADD",t.SCALARPOW="SCALARPOW"}(Jt||(Jt={})),Object.prototype.toString,(te=Zt||(Zt={})).UMAP="UMAP",te.T_SNE="t-SNE",Promise.resolve(),n(934),n(8903);const ee=2;wu,i.SEMTYPE.MOLECULE,i.SEMTYPE.MACROMOLECULE;class ne{constructor(){this.epsilon={uiName:"Epsilon",value:.01,tooltip:"Minimum distance between cluster points",min:0,max:2,step:.005},this.minPts={uiName:"Minimum points",value:4,tooltip:"Minimum number of points in cluster",min:1,max:1e3,step:1}}}const re="bypassLargeDataWarning";var ie,oe;(oe=ie||(ie={})).EUCLIDEAN="EUCLIDEAN",oe.MANHATTAN="MANHATTAN";const ae=rxjs;var se,ue,ce,le,de,he,fe,pe,me=n(5072),ge=n.n(me),ye=n(7825),ve=n.n(ye),we=n(7659),be=n.n(we),Ae=n(5056),Ee=n.n(Ae),Ce=n(540),Se=n.n(Ce),_e=n(1113),Me=n.n(_e),Ne=n(7939),Ie={};Ie.styleTagTransform=Me(),Ie.setAttributes=Ee(),Ie.insert=be().bind(null,"head"),Ie.domAPI=ve(),Ie.insertStyleElement=Se(),ge()(Ne.A,Ie),Ne.A&&Ne.A.locals&&Ne.A.locals,function(t){t.Levenshtein="Levenshtein",t.JaroWinkler="Jaro-Winkler",t.Manhattan="Manhattan String",t.Onehot="One-Hot"}(se||(se={})),function(t){t.Euclidean="Euclidean",t.Manhattan="Manhattan",t.Cosine="Vector Cosine"}(ue||(ue={})),function(t){t.Tanimoto="Tanimoto",t.Dice="Dice",t.Asymmetric="Asymmetric",t.BraunBlanquet="Braun-Blanquet",t.Cosine="Cosine",t.Kulczynski="Kulczynski",t.McConnaughey="Mc-Connaughey",t.RogotGoldberg="Rogot-Goldberg",t.Russel="Russel",t.Sokal="Sokal",t.Hamming="Hamming",t.Euclidean="Euclidean BitArray"}(ce||(ce={})),function(t){t.TanimotoIntArray="TanimotoIntArray"}(le||(le={})),(pe=de||(de={})).Vector="Vector",pe.String="String",pe.BitArray="BitArray",pe.MacroMolecule="MacroMolecule",pe.Number="Number",pe.IntArray="IntArray",pe.NumberArray="NumberArray",function(t){t.Difference="Difference"}(he||(he={})),function(t){t.CommonItems="Common Items"}(fe||(fe={}));const Le=new Uint32Array(65536),Pe=(t,e)=>{if(t.length<e.length){const n=e;e=t,t=n}return 0===e.length?t.length:t.length<=32?((t,e)=>{const n=t.length,r=e.length,i=1<<n-1;let o=-1,a=0,s=n,u=n;for(;u--;)Le[t.charCodeAt(u)]|=1<<u;for(u=0;u<r;u++){let t=Le[e.charCodeAt(u)];const n=t|a;t|=(t&o)+o^o,a|=~(t|o),o&=t,a&i&&s++,o&i&&s--,a=a<<1|1,o=o<<1|~(n|a),a&=n}for(u=n;u--;)Le[t.charCodeAt(u)]=0;return s})(t,e):((t,e)=>{const n=e.length,r=t.length,i=[],o=[],a=Math.ceil(n/32),s=Math.ceil(r/32);for(let t=0;t<a;t++)o[t]=-1,i[t]=0;let u=0;for(;u<s-1;u++){let a=0,s=-1;const c=32*u,l=Math.min(32,r)+c;for(let e=c;e<l;e++)Le[t.charCodeAt(e)]|=1<<e;for(let t=0;t<n;t++){const n=Le[e.charCodeAt(t)],r=o[t/32|0]>>>t&1,u=i[t/32|0]>>>t&1,c=n|a,l=((n|u)&s)+s^s|n|u;let d=a|~(l|s),h=s&l;d>>>31^r&&(o[t/32|0]^=1<<t),h>>>31^u&&(i[t/32|0]^=1<<t),d=d<<1|r,h=h<<1|u,s=h|~(c|d),a=d&c}for(let e=c;e<l;e++)Le[t.charCodeAt(e)]=0}let c=0,l=-1;const d=32*u,h=Math.min(32,r-d)+d;for(let e=d;e<h;e++)Le[t.charCodeAt(e)]|=1<<e;let f=r;for(let t=0;t<n;t++){const n=Le[e.charCodeAt(t)],a=o[t/32|0]>>>t&1,s=i[t/32|0]>>>t&1,u=n|c,d=((n|s)&l)+l^l|n|s;let h=c|~(d|l),p=l&d;f+=h>>>r-1&1,f-=p>>>r-1&1,h>>>31^a&&(o[t/32|0]^=1<<t),p>>>31^s&&(i[t/32|0]^=1<<t),h=h<<1|a,p=p<<1|s,l=p|~(u|h),c=h&u}for(let e=d;e<h;e++)Le[t.charCodeAt(e)]=0;return f})(t,e)};var Te=n(944);class Fe{constructor(t,e=!1){if(this._length=0,this._version=0,this._updateLevel=0,this._selectedCount=0,this._selectedCountVersion=-1,this._selectedIndexesVersion=-1,this._versionedName="",this._versionedNameVersion=-1,this.SHRINK_THRESHOLD=256,"number"==typeof t){const n=t,r=Fe._createBuffer(n);if(e)for(let t=0;t<r.length;t++)r[t]=-1;this._data=r,this._length=n}else{if(!(t instanceof Uint32Array))throw new Error("Invalid constructor");this._data=t,this._length=e}}getRawData(){return this._data}assureGoez(t,e){if(t<0)throw new Error(`${e} should be greater than zero`)}assureInRange(t,e,n,r){if(t<e||t>n)throw new Error(`Argument ${r} (${t}) out of range (${e}, ${n})`)}copy(t,e,n){for(let r=0;r<n;r++)e[r]=t[r]}copyFrom(t){if(this._length!=t._length)throw new Error(`Lengths differ (${this._length} != ${t._length})`);this.copy(t._data,this._data,this.lengthInInts),this._version++}get length(){return this._length}get buffer(){return this._data}set buffer(t){this._data=t,this._version++}get version(){return this._version}set version(t){this._version=t}incrementVersion(t=!0){this._version++}get lengthInInts(){return Math.floor((this._length+31)/32)}get versionedName(){return this._version==this._versionedNameVersion?this._versionedName:""}set versionedName(t){this._versionedName=t,this._versionedNameVersion=this._version}get self(){return this}setLength(t){if(t<0)throw new Error("should be >= 0");if(t==this._length)return;const e=Math.floor((t+31)/32);if(e>this._data.length||e+this.SHRINK_THRESHOLD<this._data.length){const t=new Uint32Array(e);this.copy(this._data,t,e>this._data.length?this._data.length:e),this._data=t}t>this._length&&(this._length%32>0&&(this._data[this.lengthInInts-1]&=(1<<(this._length%32&31))-1),this._data.fill(0,this.lengthInInts,e)),this._length=t,this._version++}static fromAnd(t,e){if(t._length!=e._length)throw new Error(`Lengths differ (${t._length} != ${e._length})`);const n=new Fe(t._length);n._length=t._length,n._data=Fe._createBuffer(n._length),n._version=0;const r=t.lengthInInts;for(let i=0;i<r;i++)n._data[i]=t._data[i]&e._data[i];return n}static _createBuffer(t){return new Uint32Array(Math.floor((t+31)/32))}static fromValues(t){const e=new Fe(t.length);e._version=0;for(let n=0;n<e._length;n++)t[n]&&(e._data[Math.floor(n/32)]|=1<<(n%32&31));return e}static fromSeq(t,e){const n=new Fe(t);for(let r=0;r<t;++r)n.setBit(r,e(r));return n._version=0,n}static fromString(t){return Fe.fromSeq(t.length,e=>"1"==t.charAt(e))}static fromUint32Array(t,e){const n=new Fe(t);return n._data=e,n}static fromBytes(t){const e=t.length,n=new Fe(8*e);n._data=new Uint32Array(Math.floor((e+3)/4)),n._length=8*e;let r=0,i=0;for(;e-i>=4;)n._data[r++]=255&t[i]|(255&t[i+1])<<8|(255&t[i+2])<<16|(255&t[i+3])<<24,i+=4;return e-i==3&&(n._data[r]=(255&t[i+2])<<16),e-i==2&&(n._data[r]|=(255&t[i+1])<<8),e-i==1&&(n._data[r]|=255&t[i]),n._version=0,n}toString(){return`${this._length} bits, ${this.countBits(!0)} set`}equals(t){if(this==t)return!0;if(null==t)return!1;if(this._length!=t._length)return!1;if(0==this._length)return!0;for(let e=0;e<this._data.length-1;e++)if(this._data[e]!=t._data[e])return!1;for(let e=8*(this._data.length-1);e<this._length;e++)if(this.getBit(e)!=t.getBit(e))return!1;return!0}clone(){const t=new Fe(0,!1);return t._data=Uint32Array.from(this._data),t._length=this._length,t._version=this._version,t}init(t,e){this.setAll(!1,!1);for(let e=0;e<this._length;e++)t(e)&&(this._data[Math.floor(e/32)]|=1<<(e%32&31));return this.incrementVersion(e),this}invert(t=!0){for(let t=0;t<this._data.length;t++)this._data[t]^=-1;this.incrementVersion(t)}setAll(t,e=!1){const n=t?-1:0,r=this.lengthInInts;for(let t=0;t<r;t++)this._data[t]=n;this.incrementVersion(e)}setIndexes(t,e=!0,n=!0,r=!0){n&&this.setAll(!e,!1);for(const n of t)this.setFast(n,e);this.incrementVersion(r)}everyIndex(t,e=!0){for(const n of t)if(this.getBit(n)!=e)return!1;return!0}anyIndex(t,e=!0){for(const n of t)if(this.getBit(n)==e)return!0;return!1}setWhere(t,e=!0,n=!0,r=!0,i=!0){if(n&&i&&this.setAll(!e,!1),i)for(let n=0;n<this._length;n++)t(n)&&this.setFast(n,e);else for(let n=0;n<this._length;n++)this.setFast(n,t(n)?e:!e);this.incrementVersion(r)}getRange(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const n=[];for(let r=t;r<e;++r)n.push(this.getBit(r));return Fe.fromValues(n)}getRangeAsList(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const n=[];for(let r=t;r<e;++r)n.push(this.getBit(r));return n}setRange(t,e,n,r=!0){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length-1,"to");const i=Math.min(t,e),o=Math.max(t,e);if(n)for(let t=i;t<=o;t++)this.setTrue(t);else for(let t=i;t<=o;t++)this.setFalse(t);return this.incrementVersion(r),this}setRandom(t,e,n=!0){if(t<0||t>this._length)throw new Error("n must be >= 0 && <= Count");t>this._length/2&&this.setRandom(this._length-t,!e),this.setAll(!e);for(let n=0;n<t;){const t=Math.floor(Math.random()*this._length);this.getBit(t)!=e&&(this.setFast(t,e),n++)}this.incrementVersion(n)}and(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]&=t._data[e];return this.incrementVersion(e),this}andNot(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");const n=this.lengthInInts;for(let e=0;e<n;e++)this._data[e]&=~t._data[e];return this.incrementVersion(e),this}notAnd(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]=~this._data[e]&t._data[e];return this.incrementVersion(e),this}not(t=!0){for(let t=0,e=this.lengthInInts;t<e;t++)this._data[t]=~this._data[t];return this.incrementVersion(t),this}or(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]|=t._data[e];return this.incrementVersion(e),this}xor(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]^=t._data[e];return this.incrementVersion(e),this}insertAt(t,e,n=!1){if(this.assureInRange(t,0,this._length,"pos"),0==e)return;const r=this._length;this.setLength(this._length+e);for(let n=r-1;n>=t;n--)this.setBit(n+e,this.getBit(n));for(let r=t;r<t+e;r++)this.setBit(r,n)}removeAt(t,e=1){if(e<0)throw new Error("n cannot be negative");if(this.assureInRange(t,0,this._length-e,"pos"),this.contains(!0))for(let n=t;n<this._length-e;n++)this.setBit(n,this.getBit(n+e));this.setLength(this._length-e)}removeByMask(t,e=!0){if(this._length!=t.length)throw new Error("length != mask.length");if(t==this)this.setLength(t.countBits(!e)),this.setAll(!e);else{let n=0;for(let r=-1;-1!=(r=t.findNext(r,!e));)this.setFast(n++,this.getBit(r));this._length=n,this._version++}return this}getBit(t){return!!(this._data[Math.floor(t/32)]&1<<(31&t))}setBit(t,e,n=!0){this.setFast(t,e),this._version++}setFast(t,e){e?this._data[Math.floor(t/32)]|=1<<(31&t):this._data[Math.floor(t/32)]&=~(1<<(31&t))}setTrue(t){this._data[Math.floor(t/32)]|=1<<(31&t)}setFalse(t){this._data[Math.floor(t/32)]&=~(1<<(31&t))}trueCount(){return this.countBits(!0)}falseCount(){return this.countBits(!1)}countBits(t){if(0==this._length)return 0;if(this._selectedCountVersion!=this._version){this._selectedCount=0;const t=this.lengthInInts;let e=0;for(;e<t-1;e++)for(let t=this._data[e];0!=t;t>>>=8)this._selectedCount+=Fe._onBitCount[255&t];let n=this._data[e];const r=31&this._length;for(0!=r&&(n&=~(4294967295<<r));0!=n;n>>>=8)this._selectedCount+=Fe._onBitCount[255&n];this._selectedCountVersion=this._version}return t?this._selectedCount:this._length-this._selectedCount}countWhere(t){let e=0;if(this.trueCount()==this._length)for(let n=0;n<this._length;n++)e+=t(n)?1:0;else for(let n=-1;-1!=(n=this.findNext(n,!0));)e+=t(n)?1:0;return e}andWithCountBits(t,e){if(0==this._length)return 0;let n=0;const r=this.lengthInInts;let i=0;for(;i<r-1;i++)for(let e=this._data[i]&t._data[i];0!=e;e>>>=8)n+=Fe._onBitCount[255&e];let o=this._data[i]&t._data[i];const a=31&this._length;for(0!=a&&(o&=~(4294967295<<a));0!=o;o>>>=8)n+=Fe._onBitCount[255&o];return e?n:this._length-n}clear(){this.setLength(0)}contains(t){return this.findNext(-1,t)>=0}get allTrue(){return this.countBits(!0)==this._length}get allFalse(){return this.countBits(!1)==this._length}get anyTrue(){return this.countBits(!0)>0}get anyFalse(){return this.countBits(!1)>0}findNext(t,e=!0){if(this.assureInRange(t,-1,this._length,"index"),t>=this._length-1)return-1;let n=31&(t=t<0?0:t+1);const r=this.lengthInInts;for(let i=Math.floor(t/32);i<r;i++){let r=e?this._data[i]:~this._data[i];if(0!=n)r&=4294967295<<n&4294967295,n=0;else if(!e&&-4294967296==r)continue;for(let e=0;0!=r;e+=8,r>>>=8){const n=Fe._firstOnBit[255&r];if(n>=0)return(t=n+32*i+e)>=this._length?-1:t}}return-1}findPrev(t,e=!0){if(0==t)return-1;this.assureInRange(t,-1,this._length,"index");let n=1+(t=t<0?this._length-1:t-1)&31;for(let r=Math.floor(t/32);r>=0;r--){let t=e?this._data[r]:~this._data[r];0!=n&&(t&=~(4294967295<<n),n=0);for(let e=24;0!=t;e-=8,t<<=8){const n=Fe._lastOnBit[t>>>24];if(n>=0)return n+32*r+e}}return-1}}function Oe(t={}){const e=function(){if(!t||!t.scoringMatrix||!t.alphabetIndexes)return(t,e)=>t===e?0:1;if(t.scoringMatrix.length!==Object.keys(t.alphabetIndexes).length)throw new Error("Scoring matrix and alphabet indexes should have the same length");const e=t.alphabetIndexes,n=t.scoringMatrix,r=Math.min(...Object.keys(e).map(t=>t.charCodeAt(0)))+1,i=new Float32Array((n.length+r)*(n.length+r));return Object.entries(e).forEach(([t,r])=>{const o=n[r];Object.entries(e).forEach(([e,r])=>{i[t.charCodeAt(0)*n.length+e.charCodeAt(0)]=o[r]})}),(t,e)=>1-i[t.charCodeAt(0)*n.length+e.charCodeAt(0)]}(),n=t?.threshold??0;return(t,r)=>{let i=0;const o=t.length,a=r.length,s=Math.ceil(Math.max(o,a)*(1-n));o!==a&&(i=Math.abs(o-a));let u=0;for(let n=0;n<Math.min(o,a);n++)if(t[n]!==r[n]&&(u+=e(t[n],r[n]),u>s))return 1;return u+=i,u/=Math.max(o,a),u}}Fe._onBitCount=Int8Array.from([0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8]),Fe._firstOnBit=Int8Array.from([-1,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0]),Fe._lastOnBit=Int8Array.from([-1,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7]);const Re={gapOpen:1,gapExtend:.6,scoringMatrix:[[4,-1,-2,-2,0,-1,-1,0,-2,-1,-1,-1,-1,-2,-1,1,0,-3,-2,0,-2,-1,0,-4],[-1,5,0,-2,-3,1,0,-2,0,-3,-2,2,-1,-3,-2,-1,-1,-3,-2,-3,-1,0,-1,-4],[-2,0,6,1,-3,0,0,0,1,-3,-3,0,-2,-3,-2,1,0,-4,-2,-3,3,0,-1,-4],[-2,-2,1,6,-3,0,2,-1,-1,-3,-4,-1,-3,-3,-1,0,-1,-4,-3,-3,4,1,-1,-4],[0,-3,-3,-3,9,-3,-4,-3,-3,-1,-1,-3,-1,-2,-3,-1,-1,-2,-2,-1,-3,-3,-2,-4],[-1,1,0,0,-3,5,2,-2,0,-3,-2,1,0,-3,-1,0,-1,-2,-1,-2,0,3,-1,-4],[-1,0,0,2,-4,2,5,-2,0,-3,-3,1,-2,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-2,0,-1,-3,-2,-2,6,-2,-4,-4,-2,-3,-3,-2,0,-2,-2,-3,-3,-1,-2,-1,-4],[-2,0,1,-1,-3,0,0,-2,8,-3,-3,-1,-2,-1,-2,-1,-2,-2,2,-3,0,0,-1,-4],[-1,-3,-3,-3,-1,-3,-3,-4,-3,4,2,-3,1,0,-3,-2,-1,-3,-1,3,-3,-3,-1,-4],[-1,-2,-3,-4,-1,-2,-3,-4,-3,2,4,-2,2,0,-3,-2,-1,-2,-1,1,-4,-3,-1,-4],[-1,2,0,-1,-3,1,1,-2,-1,-3,-2,5,-1,-3,-1,0,-1,-3,-2,-2,0,1,-1,-4],[-1,-1,-2,-3,-1,0,-2,-3,-2,1,2,-1,5,0,-2,-1,-1,-1,-1,1,-3,-1,-1,-4],[-2,-3,-3,-3,-2,-3,-3,-3,-1,0,0,-3,0,6,-4,-2,-2,1,3,-1,-3,-3,-1,-4],[-1,-2,-2,-1,-3,-1,-1,-2,-2,-3,-3,-1,-2,-4,7,-1,-1,-4,-3,-2,-2,-1,-2,-4],[1,-1,1,0,-1,0,0,0,-1,-2,-2,0,-1,-2,-1,4,1,-3,-2,-2,0,0,0,-4],[0,-1,0,-1,-1,-1,-1,-2,-2,-1,-1,-1,-1,-2,-1,1,5,-2,-2,0,-1,-1,0,-4],[-3,-3,-4,-4,-2,-2,-3,-2,-2,-3,-2,-3,-1,1,-4,-3,-2,11,2,-3,-4,-3,-2,-4],[-2,-2,-2,-3,-2,-1,-2,-3,2,-1,-1,-2,-1,3,-3,-2,-2,2,7,-1,-3,-2,-1,-4],[0,-3,-3,-3,-1,-2,-2,-3,-3,3,1,-2,1,-1,-2,-2,0,-3,-1,4,-3,-2,-1,-4],[-2,-1,3,4,-3,0,1,-1,0,-3,-4,0,-3,-3,-2,0,-1,-4,-3,-3,4,1,-1,-4],[-1,0,0,1,-3,3,4,-2,0,-3,-3,1,-1,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-1,-1,-1,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-2,0,0,-2,-1,-1,-1,-1,-1,-4],[-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,1]],alphabetIndexes:{A:0,R:1,N:2,D:3,C:4,Q:5,E:6,G:7,H:8,I:9,L:10,K:11,M:12,F:13,P:14,S:15,T:16,W:17,Y:18,V:19,B:20,Z:21,X:22,"*":23}};var xe;!function(t){t.HAMMING="Hamming",t.LEVENSHTEIN="Levenshtein",t.NEEDLEMANN_WUNSCH="Needlemann-Wunsch",t.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance"}(xe||(xe={}));const De={[xe.HAMMING]:Oe,[xe.LEVENSHTEIN]:function(){return(t,e)=>Pe(t,e)/Math.max(t.length,e.length)},[xe.NEEDLEMANN_WUNSCH]:function(t){const e=new Uint16Array(65536),{gapOpen:n,gapExtend:r,scoringMatrix:i,alphabetIndexes:o}={...Re,...t};Object.entries(o).forEach(([t,n])=>e[t.charCodeAt(0)]=n);const a=[new Float32Array(1e4),new Float32Array(1e4)];return(t,o)=>{const s=new Array(t.length+1).fill(!1),u=new Array(t.length+1).fill(!1);let c=0,l=1;for(let e=1;e<t.length+1;e++)a[0][e]=-r-(e-1)*r,a[1][e]=0;a[0][0]=0;for(let d=1;d<o.length+1;d++){a[l][0]=-r-(d-1)*r;for(let h=1;h<t.length+1;h++){const f=a[c][h-1]+i[e[t.charCodeAt(h-1)]][e[o.charCodeAt(d-1)]],p=a[c][h]-(s[h]||1===d||d===o.length?r:n),m=a[l][h-1]-(u[h-1]||1===h||h===t.length?r:n);a[l][h]=Math.max(f,m,p),a[l][h]===f?(s[h]=!1,u[h]=!1):a[l][h]===m?(s[h]=!1,u[h]=!0):(s[h]=!0,u[h]=!1)}c=l,l=(l+1)%2}const d=Math.min(t.length,o.length);return(d-a[c][t.length])/d}},[xe.MONOMER_CHEMICAL_DISTANCE]:Oe};function ke(t,e){const n=t.trueCount()+e.trueCount();if(0==n)return 1;const r=t.andWithCountBits(e,!0);return r/(n-r)}function Ue(t){return t<=0?3402823e32:1/t-1}ce.Tanimoto,ce.Dice,ce.Asymmetric,ce.BraunBlanquet,ce.Cosine,ce.Kulczynski,ce.McConnaughey,ce.RogotGoldberg,ce.Russel,ce.Sokal,ce.Hamming,ce.Euclidean,ce.Tanimoto,ce.Dice,ce.Asymmetric,ce.BraunBlanquet,ce.Cosine,ce.Kulczynski,ce.McConnaughey,ce.RogotGoldberg,ce.Russel,ce.Sokal,ce.Hamming,ce.Euclidean,ce.Tanimoto,ce.Dice,ce.Cosine,ce.Tanimoto,ce.Asymmetric,ce.Cosine,ce.Sokal,xe.HAMMING,xe.LEVENSHTEIN,xe.MONOMER_CHEMICAL_DISTANCE,xe.NEEDLEMANN_WUNSCH;const Ge={[ue.Euclidean]:function(t,e){let n=0;for(let r=0;r<t.length;r++)n+=Math.pow(t[r]-e[r],2);return Math.sqrt(n)},[ue.Manhattan]:function(t,e){let n=0;for(let r=0;r<t.length;r++)n+=Math.abs(t[r]-e[r]);return n},[ue.Cosine]:function(t,e){let n=0,r=0,i=0;for(let o=0;o<t.length;o++)n+=t[o]*e[o],r+=t[o]*t[o],i+=e[o]*e[o];return(1-n/(Math.sqrt(r)*Math.sqrt(i)))/2}},Ve={[se.Levenshtein]:Pe,[se.JaroWinkler]:Te.Vb,[se.Manhattan]:function(t,e){if(t.length!==e.length)return 1;{let n=0;for(let r=1;r<t.length;r++)n+=t[r]==e[r]?0:1;return n/t.length}},[se.Onehot]:function(t,e){return t===e?0:1}},Be={[ce.Tanimoto]:function(t,e){return 1-ke(t,e)},[ce.Dice]:function(t,e){return 1-function(t,e){const n=t.trueCount()+e.trueCount();return 0==n?0:2*t.andWithCountBits(e,!0)/n}(t,e)},[ce.Asymmetric]:function(t,e){return 1-function(t,e){const n=Math.min(t.trueCount(),e.trueCount());return 0==n?0:t.andWithCountBits(e,!0)/n}(t,e)},[ce.BraunBlanquet]:function(t,e){return Ue(function(t,e){const n=Math.max(t.trueCount(),e.trueCount());return 0==n?0:t.andWithCountBits(e,!0)/n}(t,e))},[ce.Cosine]:function(t,e){return 1-function(t,e){const n=t.trueCount()*e.trueCount();return 0==n?0:t.andWithCountBits(e,!0)/Math.sqrt(n)}(t,e)},[ce.Kulczynski]:function(t,e){return Ue(function(t,e){const n=t.trueCount()+e.trueCount(),r=t.trueCount()*e.trueCount();return 0==r?0:t.andWithCountBits(e,!0)*n/(2*r)}(t,e))},[ce.McConnaughey]:function(t,e){return Ue(function(t,e){const n=t.trueCount()+e.trueCount(),r=t.trueCount()*e.trueCount();return 0==r?0:(t.andWithCountBits(e,!0)*n-r)/r}(t,e))},[ce.RogotGoldberg]:function(t,e){return Ue(function(t,e){const n=t.andWithCountBits(e,!0),r=t.countBits(!0)+e.countBits(!0),i=t.length,o=i-r+n;return n==i||o==i?1:n/r+o/(2*i-r)}(t,e))},[ce.Russel]:function(t,e){return Ue(function(t,e){return 0==t.length?0:t.andWithCountBits(e,!0)/t.length}(t,e))},[ce.Sokal]:function(t,e){return 1-function(t,e){const n=t.trueCount()+e.trueCount(),r=t.andWithCountBits(e,!0);return r/(2*n-3*r)}(t,e)},[ce.Hamming]:function(t,e){return t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0)},[ce.Euclidean]:function(t,e){return Math.sqrt(t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0))}},We={[le.TanimotoIntArray]:function(t,e){return Ue(ke(new Fe(t,32*t.length),new Fe(e,32*e.length)))}},ze={[he.Difference]:function(t){if(t&&null!=t.range&&t.range>0){const e=t.range;return(t,n)=>Math.abs(t-n)/e}return(t,e)=>Math.abs(t-e)}},He={[fe.CommonItems]:function(t){const e=function(t){const e=t?.mostCommon??new Set;return(t,n)=>{const r=t.length,i=n.length;let o=0,a=0,s=0;for(;a<r&&s<i;)t[a]===n[s]?(e?.has(t[a])||++o,++a,++s):t[a]<n[s]?++a:++s;return o}}(t);return(t,n)=>0===n.length||0===t.length?1e4:Math.min(t.length,n.length)/(e(t,n)+1e-4)}},je={[de.Vector]:{[ue.Euclidean]:Ge[ue.Euclidean],[ue.Manhattan]:Ge[ue.Manhattan],[ue.Cosine]:Ge[ue.Cosine]},[de.String]:{[se.Levenshtein]:Ve[se.Levenshtein],[se.JaroWinkler]:Ve[se.JaroWinkler],[se.Manhattan]:Ve[se.Manhattan],[se.Onehot]:Ve[se.Onehot]},[de.BitArray]:{[ce.Tanimoto]:Be[ce.Tanimoto],[ce.Dice]:Be[ce.Dice],[ce.Asymmetric]:Be[ce.Asymmetric],[ce.BraunBlanquet]:Be[ce.BraunBlanquet],[ce.Cosine]:Be[ce.Cosine],[ce.Kulczynski]:Be[ce.Kulczynski],[ce.McConnaughey]:Be[ce.McConnaughey],[ce.RogotGoldberg]:Be[ce.RogotGoldberg],[ce.Russel]:Be[ce.Russel],[ce.Sokal]:Be[ce.Sokal]},[de.MacroMolecule]:{[xe.HAMMING]:De[xe.HAMMING],[xe.LEVENSHTEIN]:De[xe.LEVENSHTEIN],[xe.NEEDLEMANN_WUNSCH]:De[xe.NEEDLEMANN_WUNSCH],[xe.MONOMER_CHEMICAL_DISTANCE]:De[xe.MONOMER_CHEMICAL_DISTANCE]},[de.Number]:{[he.Difference]:ze[he.Difference]},[de.IntArray]:{[le.TanimotoIntArray]:We[le.TanimotoIntArray]},[de.NumberArray]:{[fe.CommonItems]:He[fe.CommonItems]}};Object.keys(je).reduce((t,e)=>{for(const n of Object.keys(je[e]))t[n]=e;return t},{});class Ke{constructor(){this.learningRate={uiName:"Learninig rate",value:1,tooltip:"The initial learning rate for the embedding optimization"},this.nEpochs={uiName:"Epochs",value:0,tooltip:"The number of epochs to optimize embeddings via SGD. Computed automatically if set to 0"},this.nNeighbors={uiName:"Neighbors",value:15,tooltip:"The number of nearest neighbors to construct the fuzzy manifold"},this.spread={uiName:"Spread",value:1,tooltip:"The effective scale of embedded points, used with min distance to control \n the clumped/dispersed nature of the embedding"},this.minDist={uiName:"Min distance",value:.1,tooltip:"The effective minimum distance between embedded points, \n used with spread to control the clumped/dispersed nature of the embedding"},this.randomSeed={uiName:"Random seed",value:null,tooltip:"Random seed",type:"string"},this.useWebGPU={uiName:"Use WebGPU",value:!1,tooltip:"Use WebGPU for Distance and UMAP computations",type:"boolean",disableTooltip:"WebGPU is not available"},Ht().then(t=>{t?(this.useWebGPU.tooltip+=` (${t})`,this.useWebGPU.value=!0):(this.useWebGPU.value=!1,this.useWebGPU.disable=!0)})}}class qe{constructor(){this.epsilon={uiName:"Epsilon",value:10,tooltip:"Epsilon is learning rate"},this.perplexity={uiName:"Perplexity",value:30,tooltip:"Roughly how many neighbors each point influences"}}}class Ye{constructor(n={}){this.editorSettings={},this.columnOptEditors=[],this.columnOptEditorsRoot=e.div(),this.columnParamsEditorRoot=e.div(),this.columnFunctionsMap={},this.methodsParams={[Zt.UMAP]:new Ke,[Zt.T_SNE]:new qe},this.dbScanParams=new ne,this.methodSettingsDivs=[],this.supportedFunctions={},this.methodSettingsAnchor=e.div(),this.plotEmbeddingsInput=e.input.bool("Plot embeddings",{value:!0}),this.aggregationMethodInput=e.input.choice("Aggregation",{value:ie.EUCLIDEAN,items:[ie.EUCLIDEAN,ie.MANHATTAN]}),this.vectorDistanceInput=e.input.choice("Distance metric",{value:ue.Euclidean,items:[ue.Euclidean,ue.Manhattan,ue.Cosine]}),this.aggregationMethodInput.setTooltip("Aggregation method for combining distances between columns"),this.vectorDistanceInput.root.style.display="none",this.onColumnsChanged=new ae.Subject,this.editorSettings=n,this.columnParamsEditorAccordion=e.accordion(),i.Func.find({tags:["dim-red-preprocessing-function"]}).forEach(t=>{const e=t.options.get("supportedSemTypes")??"",n=t.friendlyName??t.name,r=t.options.get("supportedTypes")??"",i=t.options.get("supportedUnits")??"",o=t.options.get("supportedDistanceFunctions")??"";this.editorSettings.semtype&&!e.includes(this.editorSettings.semtype)||this.editorSettings.type&&!r.includes(this.editorSettings.type)||this.editorSettings.units&&!i.includes(this.editorSettings.units)||(this.supportedFunctions[n]={func:t,semTypes:e?e.split(","):[],types:r?r.split(","):[],units:i?i.split(","):[],distanceFunctions:o?o.split(","):[]})}),this.postProcessingEditor=new Qe,this.tableInput=e.input.table("Table",{value:t.shell.tv.dataFrame,items:t.shell.tables,onValueChanged:()=>{this.onTableInputChanged()}}),this.onTableInputChanged();let r=!1;this.methodInput=e.input.choice("Method",{value:Zt.UMAP,items:[Zt.UMAP,Zt.T_SNE],onValueChanged:t=>{r&&this.createAlgorithmSettingsDiv(this.methodsParams[t])}}),this.methodSettingsIcon=e.icons.settings(()=>{r=!r,r?this.createAlgorithmSettingsDiv(this.methodsParams[this.methodInput.value]):(this.methodSettingsDivs.forEach(t=>t.remove()),this.methodSettingsDivs=[])},"Modify methods parameters"),this.methodInput.root.classList.add("ml-dim-reduction-settings-input"),this.methodInput.root.prepend(this.methodSettingsIcon),this.columnParamsEditorAccordion.addPane("Column options",()=>this.columnOptEditorsRoot,!0,null,!1),this.columnParamsEditorAccordion.root.style.display="none",this.columnParamsEditorRoot.appendChild(this.columnParamsEditorAccordion.root),this.columnParamsEditorRoot.appendChild(this.vectorDistanceInput.root)}onTableInputChanged(){const t=this.tableInput.value;if(!t)return;e.empty(this.columnOptEditorsRoot),this.columnFunctionsMap={},t.columns.toList().forEach(t=>{Object.keys(this.supportedFunctions).forEach(e=>{const n=this.supportedFunctions[e].semTypes,r=this.supportedFunctions[e].types,i=this.supportedFunctions[e].units,o=!n.length||t.semType&&n.includes(t.semType),a=!r.length||r.includes(t.type),s=!i.length||t.meta.units&&i.includes(t.meta.units);o&&a&&s&&(this.columnFunctionsMap[t.name]||(this.columnFunctionsMap[t.name]=[]),this.columnFunctionsMap[t.name].push(e))})});const n=Object.keys(this.columnFunctionsMap),r=e.input.columns("Columns",{table:t,onValueChanged:t=>{if(this.onColumnsChanged.next(),e.empty(this.columnOptEditorsRoot),this.aggregationMethodInput.root.style.display=!t||t?.length<2?"none":"flex",!t||0===t.length)return void(this.columnParamsEditorAccordion.root.style.display="none");this.columnOptEditors=t.map(t=>new $e(t,this.columnFunctionsMap[t.name].map(t=>this.supportedFunctions[t])));const n=e.divV([],{style:{maxHeight:"400px",overflow:"auto"}});this.columnOptEditors.forEach(t=>{n.appendChild(t.accordionDiv)});const r=new Array(2*this.columnOptEditors.length).fill(null).map((t,e)=>e%2==0?this.columnOptEditors[e/2].colOptEditors:[]);let i=0;const o=e.table(r,t=>(i++,t&&t.length>0?t:[this.columnOptEditors[Math.floor((i-1)/2)].preprocessingFuncSettingsDiv=e.div([]),e.div(),e.div(),e.div()]),["Column","Encoding function","Similarity metric","Weight"]);this.columnOptEditors.forEach(t=>{t.preprocessingFuncSettingsDiv?.parentElement?.setAttribute("colspan","4"),t.preprocessingFuncSettingsDiv?.parentElement?.parentElement?.style?.setProperty("height","unset")}),this.columnOptEditors.length>0&&(this.columnParamsEditorAccordion.root.style.display="flex"),o.classList.add("ml-dim-reduction-column-editor-table-root"),this.columnOptEditorsRoot.appendChild(o),t.every(t=>t.isNumerical)?(this.aggregationMethodInput.root.style.display="none",this.columnParamsEditorAccordion.root.style.display="none",this.vectorDistanceInput.root.style.display="flex"):this.vectorDistanceInput.root.style.display="none"},available:n});r.fireChanged(),this.columnsInputRoot?(e.empty(this.columnsInputRoot),this.columnsInput=r,Array.from(this.columnsInput.root.children).forEach(t=>this.columnsInputRoot.appendChild(t))):(this.columnsInputRoot=r.root,this.columnsInput=r)}createAlgorithmSettingsDiv(t){this.methodSettingsDivs.forEach(t=>t.remove()),this.methodSettingsDivs=[];const n=this.methodSettingsAnchor,r=n.parentElement;r&&Object.keys(t).forEach(i=>{const o=t[i],a="string"===o.type?e.input.string(o.uiName,{value:o.value??"",onValueChanged:t=>{o.value=t}}):"boolean"===o.type?e.input.bool(o.uiName,{value:o.value??!1,onValueChanged:t=>{o.value=t}}):e.input.float(o.uiName,{value:o.value,onValueChanged:t=>{o.value=t}});o.disable?(a.enabled=!1,e.tooltip.bind(a.input??a.root,o.disableTooltip??"")):e.tooltip.bind(a.input??a.root,o.tooltip),r.insertBefore(a.root,n),this.methodSettingsDivs.push(a.root)})}get algorithmOptions(){const t=this.methodsParams[this.methodInput.value],e={};return Object.keys(t).forEach(n=>{null!=t[n].value&&(e[n]=t[n].value)}),e}get dbScanOptions(){return{dbScanEpsilon:this.dbScanParams.epsilon.value??.01,dbScanMinPts:this.dbScanParams.minPts.value??4}}getEditor(){return e.div([this.tableInput.root,this.columnsInputRoot,this.columnParamsEditorRoot,this.aggregationMethodInput.root,this.methodInput.root,this.methodSettingsAnchor,this.plotEmbeddingsInput,this.postProcessingEditor.root],{style:{minWidth:"420px"},classes:"dim-reduction-dialog-form"})}getParams(){return{table:this.tableInput.value,columns:this.columnsInput.value,methodName:this.methodInput.value,preprocessingFunctions:this.columnOptEditors.map(t=>t.preProcessingFunction),distanceMetrics:this.columnOptEditors.map(t=>t.similarityMetricInput.value),weights:this.columnOptEditors.map(t=>t.weight??1),options:{...this.algorithmOptions,...this.dbScanOptions,preprocessingFuncArgs:this.columnOptEditors.map(t=>t.preprocessingFunctionSettings)},plotEmbeddings:this.plotEmbeddingsInput.value,clusterEmbeddings:!1,postProcessingFunction:this.postProcessingEditor.postProcessingFunction,postProcessingFunctionArgs:this.postProcessingEditor.args,aggreaggregationMethod:this.aggregationMethodInput.value,vectorDistanceMetric:this.vectorDistanceInput.value}}getInput(){return{columns:this.columnsInput.value.map(t=>t.name),method:this.methodInput.value,preprocessingFunctions:this.columnOptEditors.map(t=>t.preprocessingFunctionInput.value),distanceMetrics:this.columnOptEditors.map(t=>t.similarityMetricInput.value),weights:this.columnOptEditors.map(t=>t.weight??1),options:{...this.algorithmOptions,...this.dbScanOptions,preprocessingFuncArgs:this.columnOptEditors.map(t=>t.preprocessingFunctionSettings)},plotEmbeddings:this.plotEmbeddingsInput.value,postProcessingFunction:this.postProcessingEditor.postProcessingFunctionInput.value??null,postProcessingFunctionArgs:this.postProcessingEditor.args,aggreaggregationMethod:this.aggregationMethodInput.value,vectorDistanceMetric:this.vectorDistanceInput.value}}getStringInput(){return JSON.stringify(this.getInput())}async applyStringInput(e){try{const t=JSON.parse(e);await this.applyInput(t)}catch(e){t.shell.error("Error applying input from history"),console.error(e)}}async applyInput(e){try{const t=e.columns.map(t=>this.tableInput.value.col(t));if(t.some(t=>!t))throw new Error("Some columns are not found");this.columnsInput.value=t,this.columnsInput.fireChanged(),this.methodInput.value=e.method,this.columnOptEditors.forEach((t,n)=>{t.preprocessingFunctionInput.value=e.preprocessingFunctions[n],t.similarityMetricInput.value=e.distanceMetrics[n],t.weightInput.value=e.weights[n],t.preprocessingFunctionSettings=e.options.preprocessingFuncArgs[n]}),this.plotEmbeddingsInput.value=e.plotEmbeddings,this.postProcessingEditor.postProcessingFunctionInput.value=e.postProcessingFunction,await this.postProcessingEditor._prevChangePromise,this.postProcessingEditor._postProcessingArgs=e.postProcessingFunctionArgs,this.aggregationMethodInput.value=e.aggreaggregationMethod;const n={};Object.keys(this.methodsParams[e.method]).forEach(t=>{n[t]=e.options[t]}),Object.keys(this.methodsParams[e.method]).forEach(t=>{this.methodsParams[e.method][t].value=n[t]});const r=this.methodSettingsDivs.length>0;this.createAlgorithmSettingsDiv(this.methodsParams[e.method]),r||(this.methodSettingsDivs.forEach(t=>t.remove()),this.methodSettingsDivs=[]),await this.postProcessingEditor.onFunctionChanged(e.postProcessingFunctionArgs),this.vectorDistanceInput.value=e.vectorDistanceMetric}catch(e){t.shell.error("Error applying input from history"),console.error(e)}}}class $e{constructor(t,n){this.preprocessingFuncSettingsDiv=e.div([]),this.preprocessingFunctionSettings={},this.editorDiv=e.div([]),this.hasExtraSettings=!0,this.functionsMap={},this.needsConfiguration=!1,this.weight=1,this.colOptEditors=[],this.weightInput=e.input.float("Weight",{value:1,onValueChanged:t=>{this.weight=t??1}}),this.column=t,this.supportedFunctions=n.sort((t,e)=>0!==t.units.length&&0!==e.units.length||t.units.length===e.units.length?t.units.length!==e.units.length?t.units.length-e.units.length:0===t.semTypes.length||0===e.semTypes.length?e.semTypes.length-t.semTypes.length:t.semTypes.length!==e.semTypes.length?t.semTypes.length-e.semTypes.length:t.types.length-e.types.length:e.units.length-t.units.length),this.supportedFunctions.forEach(t=>{this.functionsMap[Xe(t.func)]=t.func}),this.preprocessingFunctionInput=e.input.choice("Encoding function",{value:Xe(this.supportedFunctions[0].func),items:this.supportedFunctions.map(t=>Xe(t.func)),onValueChanged:t=>{const n=this.functionsMap[t];this.preprocessingFunctionSettings={},this.hasExtraSettings=n.inputs.length>2;const i=this.supportedFunctions.find(e=>Xe(e.func)===t);this.getSimilarityMetricInput(i),e.empty(this.preprocessingFuncSettingsDiv),r=!1,this.hasExtraSettings?this.preprocessingFuncSettingsIcon.style.display="flex":this.preprocessingFuncSettingsIcon.style.display="none"}}),this.preprocessingFunctionInput.root.style.display="flex",this.createSettingsDiv(this.preprocessingFuncSettingsDiv,this.supportedFunctions[0].func).then(()=>{e.empty(this.preprocessingFuncSettingsDiv)}),this.getSimilarityMetricInput(this.supportedFunctions[0]),this.hasExtraSettings=this.supportedFunctions[0].func.inputs.length>2;let r=!1;this.preprocessingFuncSettingsIcon=e.icons.settings(async()=>{r=!r,r?await this.createSettingsDiv(this.preprocessingFuncSettingsDiv,this.functionsMap[this.preprocessingFunctionInput.value]):e.empty(this.preprocessingFuncSettingsDiv)},"Modify encoding function parameters"),this.preprocessingFunctionInput.root.classList.add("ml-dim-reduction-settings-input"),this.preprocessingFunctionInput.root.prepend(this.preprocessingFuncSettingsIcon),this.hasExtraSettings?this.preprocessingFuncSettingsIcon.style.display="flex":this.preprocessingFuncSettingsIcon.style.display="none",this.needsConfiguration=!(n.length<2&&!this.hasExtraSettings&&n[0].distanceFunctions.length<2);const i=e.h3(this.column.name,{classes:"ml-dim-reduction-column-editor-column-title"});this.colOptEditors=[i,this.preprocessingFunctionInput.root,this.similarityMetricInputRoot,this.weightInput.root],e.tooltip.bind(i,this.column.name),this.colOptEditors.forEach(t=>t.classList.add("ml-dim-reduction-column-editor-input-root"));const o=e.divH(this.colOptEditors,{classes:"ml-dim-reduction-column-editor-root"});this.accordionDiv=e.divV([]),this.editorDiv.appendChild(o),this.editorDiv.appendChild(this.preprocessingFuncSettingsDiv),this.accordionDiv.appendChild(this.editorDiv)}getSimilarityMetricInput(t){const n=e.input.choice("Similarity metric",{value:t.distanceFunctions[0],items:t.distanceFunctions});this.similarityMetricInputRoot?(e.empty(this.similarityMetricInputRoot),this.similarityMetricInput=n,Array.from(this.similarityMetricInput.root.children).forEach(t=>this.similarityMetricInputRoot.appendChild(t))):(this.similarityMetricInputRoot=n.root,this.similarityMetricInput=n)}get preProcessingFunction(){return this.functionsMap[this.preprocessingFunctionInput.value]}async createSettingsDiv(t,n){if(e.empty(t),n.inputs.length<3)return e.div();const r=n.prepare(),i=await r.buildEditor(e.div());for(let e=2;e<n.inputs.length;e++){const o=n.inputs[e],a=this.preprocessingFunctionSettings[o.name]||r.inputParams[n.inputs[e].name].value||o.defaultValue;a&&(this.preprocessingFunctionSettings[o.name]=a);const s=i.find(t=>t.property.name===o.name);s&&(null!==this.preprocessingFunctionSettings[o.name]&&void 0!==this.preprocessingFunctionSettings[o.name]&&(s.value=this.preprocessingFunctionSettings[o.name]),s.onChanged.subscribe(t=>{this.preprocessingFunctionSettings[o.name]=t}),t.append(s.root))}return t.style.marginBottom="10px",t}}function Xe(t){return t.friendlyName??t.name}class Qe{constructor(){this.postProcessingFunctionsMap={},this._root=e.div([]),this._postProcessingArgs={},this._argsElement=e.div([]),this._settingsOpened=!1,this._prevChangePromise=Promise.resolve(),this._settingsIcon=e.icons.settings(async()=>{this._settingsOpened=!this._settingsOpened,this._settingsOpened?this._argsElement.style.display="block":this._argsElement.style.display="none"}),this._argsElement.style.display="none",i.Func.find({tags:["dim-red-postprocessing-function"]}).filter(t=>t.inputs.length>=2).forEach(t=>{const e=t.friendlyName??t.name;this.postProcessingFunctionsMap[e]=t}),this.postProcessingFunctionsMap.None=null;const t=Object.keys(this.postProcessingFunctionsMap).find(t=>!!this.postProcessingFunctionsMap[t]?.options?.defaultPostProcessingFunction)??"None";this.postProcessingFunctionInput=e.input.choice("Postprocessing",{value:t,items:Object.keys(this.postProcessingFunctionsMap),onValueChanged:async()=>{await this.onFunctionChanged()},nullable:!1}),this.onFunctionChanged(),this.postProcessingFunctionInput.nullable=!1,this.postProcessingFunctionInput.classList.add("ml-dim-reduction-settings-input"),this.postProcessingFunctionInput.root.prepend(this._settingsIcon),this._root.appendChild(this.postProcessingFunctionInput.root),this._root.appendChild(this._argsElement)}get postProcessingFunction(){return this.postProcessingFunctionInput.value?this.postProcessingFunctionsMap[this.postProcessingFunctionInput.value]:null}async onFunctionChanged(n={}){let r;await this._prevChangePromise,this._prevChangePromise=new Promise(t=>r=t);try{const t=this.postProcessingFunction;if(e.empty(this._argsElement),this._postProcessingArgs={},!t||t.inputs.length<3)return void(this._settingsIcon.style.display="none");this._settingsIcon.style.display="flex";const r=t.prepare(n),i=await r.buildEditor(e.div());for(let e=2;e<t.inputs.length;e++){const n=t.inputs[e],o=this._postProcessingArgs[n.name]||r.inputParams[t.inputs[e].name].value||n.defaultValue;o&&(this._postProcessingArgs[n.name]=o);const a=i.find(t=>t.property.name===n.name);a&&(a.onChanged.subscribe(t=>{this._postProcessingArgs[n.name]=t}),this._argsElement.append(a.root))}}catch(e){t.shell.error("Error applying postprocessing function"),console.error(e)}finally{r()}}get root(){return this._root}get args(){return this._postProcessingArgs}}const Je="dimensionality-reducer-terminate-event",Ze=t=>null==t;function tn(t,e){return`${e} (${t.length>4?`${t.length} columns`:t.map(t=>t.name).join(", ")})`}function en(n){return r=this,o=void 0,s=function*(){if(null!=n||(n=t.shell.t),null===n)return void t.shell.warning(bt.NO_DATAFRAME);const r=[],o=[],a=[];n.columns.toList().filter(t=>_t.includes(t.type)).forEach(t=>{const e=t.stats.missingValueCount;e!==t.length&&(a.push(t.name),e>0&&(r.push(t),o.push(t.name)))});const s=function(t){const e=new Map;for(const n of t){if(!_t.includes(n.type))throw new Error(bt.UNSUPPORTED_COLUMN_TYPE);if(0===n.stats.missingValueCount)continue;const t=[],r=Mt(n);n.getRawData().forEach((e,n)=>{e===r&&t.push(n)}),e.set(n.name,t)}return e}(r);if(0===r.length)return void t.shell.info(bt.NO_MISSING_VALUES);if(1===a.length)return void t.shell.error(bt.ONE_AVAILABLE_FEATURE);let u=Lt.IN_PLACE>0;const c=e.input.bool(Ct.IN_PLACE,{value:u,onValueChanged:t=>{u=null!=t&&t}});c.setTooltip(St.IN_PLACE);let l=Lt.KEEP_EMPTY>0;const d=e.input.bool(Ct.KEEP_EMPTY,{value:l,onValueChanged:t=>{l=null!=t&&t}});d.setTooltip(St.KEEP_EMPTY);let h=Lt.NEIGHBORS;const f=e.input.int(Ct.NEIGHBORS,{value:h,showPlusMinus:!0,min:1,nullable:!1,onValueChanged:t=>{null!==t&&t>=1&&(h=t),A()}});f.setTooltip(St.NEIGHBORS);let p=It.EUCLIDEAN;const m=e.input.choice(Ct.DISTANCE,{value:p,items:[It.EUCLIDEAN,It.MANHATTAN],onValueChanged:t=>p=null!=t?t:It.EUCLIDEAN});m.setTooltip(St.DISTANCE);let g=r.map(t=>t.name);const y=e.input.columns(Ct.COLUMNS,{table:n,value:n.columns.byNames(o),onValueChanged:t=>{g=t.map(t=>t.name),A()},available:o});y.setTooltip(St.TARGET);let v=a;const w=e.input.columns(Ct.FEATURES,{value:n.columns.byNames(a),table:n,onValueChanged:t=>{v=t.map(t=>t.name),v.length>0?(A(),C.forEach((t,e)=>t.hidden=!v.includes(e))):b()},available:a});w.setTooltip(St.FEATURES);const b=()=>{_.getButton(Ct.RUN).disabled=!0,c.root.hidden=!0,d.root.hidden=!0,f.root.hidden=!0,N.hidden=!0,S.hidden=!0},A=()=>{_.getButton(Ct.RUN).disabled=null===f.value||f.value<1,N.hidden=!1,c.root.hidden=!1,f.root.hidden=!1,m.root.hidden=!1,d.root.hidden=!Tt(g,v,s),1===v.length&&g.forEach(e=>{v[0]===e&&(b(),t.shell.warning(`${bt.ONE_FEATURE_SELECTED} the column '${e}'`))}),g.length<1&&b()},E=new Map,C=new Map,S=e.divV([]);S.style.overflow="auto",a.forEach(t=>{const r=function(t){switch(t){case i.COLUMN_TYPE.STRING:case i.COLUMN_TYPE.DATE_TIME:return{defaultWeight:Lt.WEIGHT,defaultMetric:Nt.ONE_HOT,availableMetrics:[Nt.ONE_HOT]};case i.COLUMN_TYPE.INT:case i.COLUMN_TYPE.FLOAT:case i.COLUMN_TYPE.QNUM:return{defaultWeight:Lt.WEIGHT,defaultMetric:Nt.DIFFERENCE,availableMetrics:[Nt.DIFFERENCE,Nt.ONE_HOT]};default:throw new Error(bt.UNSUPPORTED_COLUMN_TYPE)}}(n.col(t).type);E.set(t,{weight:r.defaultWeight,type:r.defaultMetric});const o=e.input.choice(t,{value:r.defaultMetric,items:r.availableMetrics,onValueChanged:e=>{var n;const i=null!==(n=E.get(t))&&void 0!==n?n:{weight:r.defaultWeight,type:r.defaultMetric};i.type=null!=e?e:r.defaultMetric,E.set(t,i)}});o.root.style.width="50%",o.setTooltip(St.METRIC),o.root.hidden=!0;const a=i.Property.fromOptions({name:t.length<15?t:t.slice(0,15).concat("..."),inputType:"Float",min:0,max:10,showSlider:!0,step:1}),s=e.input.forProperty(a);s.value=r.defaultWeight,s.onChanged.subscribe(e=>{var n;const i=null!==(n=E.get(t))&&void 0!==n?n:{weight:r.defaultWeight,type:r.defaultMetric};i.weight=null!=e?e:r.defaultWeight,E.set(t,i)}),e.tooltip.bind(s.captionLabel,t),e.tooltip.bind(s.input,St.WEIGHT),C.set(t,s.root),S.append(s.root)});const _=e.dialog({title:Ct.KNN_IMPUTER,helpUrl:"/help/explore/missing-values-imputation#the-k-nn-method"});t.shell.v.root.appendChild(_.root),S.hidden=!0,d.root.hidden=!Tt(g,v,s);const M=e.icons.settings(()=>{S.hidden=!S.hidden},St.METRIC_SETTINGS),N=e.divH([m.root,M]);let I,L,P=!1;const T=new Promise((t,e)=>{I=t,L=e});return _.addButton(Ct.RUN,()=>{P=!0,_.close(),a.filter(t=>!v.includes(t)).forEach(t=>E.delete(t));try{const e=function(e,n,r,o,a,s,u){if(s<1)throw new Error(bt.INCORRECT_NEIGHBORS);if(e.rowCount<2)throw new Error(bt.KNN_NOT_ENOUGH_OF_ROWS);if(0===n.length)throw new Error(bt.KNN_NO_TARGET_COLUMNS);if(0===r.size)throw new Error(bt.KNN_NO_FEATURE_COLUMNS);1===r.size&&n.forEach(t=>{if(r.has(t))throw new Error(`${bt.KNN_NO_FEATURE_COLUMNS} can be used for the column '${t}'`)}),n.forEach(t=>{if(!o.has(t))throw new Error(`${bt.KNN_FAILS}: ${bt.WRONG_PREDICTIONS}`)});const c=e.columns;n.forEach(t=>{if(!_t.includes(c.byName(t).type))throw new Error(bt.UNSUPPORTED_COLUMN_TYPE)}),r.forEach((t,n)=>{if(!_t.includes(e.getCol(n).type))throw new Error(bt.UNSUPPORTED_COLUMN_TYPE)});const l=new Map;return n.forEach(n=>{const d=c.byName(n),h=Mt(d),f=d.length,p=d.getRawData(),m=new Uint16Array(d.categories.length),g=[],y=[],v=[],w=[];r.forEach((t,e)=>{if(e!==d.name){const n=c.byName(e);switch(g.push(n.getRawData()),y.push(Mt(n)),t.type){case Nt.DIFFERENCE:v.push((e,n)=>t.weight*Math.abs(e-n));break;case Nt.ONE_HOT:v.push((e,n)=>t.weight*(e===n?0:1))}}});const b=g.length,A=new Uint32Array(g.length),E=new Float32Array(g.length);let C=0;const S=new Array(s);let _=0,M=0,N=0,I=0,L=0;const P=(t,e)=>{A.forEach((n,r)=>{E[r]=v[n](g[n][t],g[n][e])})},T=a===It.EUCLIDEAN?()=>{let t=0;for(let e=0;e<C;++e)t+=E[e]*E[e];return Math.sqrt(t)}:()=>{let t=0;for(let e=0;e<C;++e)t+=Math.abs(E[e]);return Math.sqrt(t)},F=t=>{if(p[t]===h)return!1;for(let e=0;e<C;++e)if(g[A[e]][t]===y[A[e]])return!1;return!0},O=t=>{if((t=>{C=0;for(let e=0;e<b;++e)g[e][t]!==y[e]&&(A[C]=e,++C)})(t),0===C)throw new Error(`${bt.KNN_IMPOSSIBLE_IMPUTATION}: the column "${d.name}", row ${t+1}`);_=0;for(let e=0;e<f;++e)if(F(e)&&e!==t){P(t,e);const n=T();if(_<s)S[_]={index:e,dist:n},++_;else{M=0,N=S[0].dist;for(let t=1;t<_;++t)N<S[t].dist&&(N=S[t].dist,M=t);n<N&&(S[M]={index:e,dist:n})}}if(0===_)throw new Error(`${bt.KNN_IMPOSSIBLE_IMPUTATION}: the column "${d.name}", row ${t+1}`);if(d.type===i.COLUMN_TYPE.STRING)return(()=>{m.forEach((t,e,n)=>n[e]=0);let t=0;for(t=0;t<_;++t)++m[p[S[t].index]];let e=m[0],n=0;return m.forEach((t,r)=>{t>e&&(e=t,n=r)}),n})();I=0;for(let t=0;t<_;++t)I+=p[S[t].index];return L=I/_,d.type===i.COLUMN_TYPE.INT?Math.round(L):L};if(u){for(const e of o.get(n))try{p[e]=O(e)}catch(n){w.push(e),n instanceof Error||t.shell.error(bt.CORE_ISSUE)}w.length>0&&l.set(n,w),d.set(0,d.get(0))}else{const r=d.clone();let i=1,a=`${n}(${Et})`;for(;e.columns.contains(a);)a=`${n}(${Et} ${i})`,++i;r.name=a;const s=r.getRawData();for(const e of o.get(n))try{s[e]=O(e)}catch(n){w.push(e),n instanceof Error||t.shell.error(bt.CORE_ISSUE)}w.length>0&&l.set(a,w),r.set(0,r.get(0)),e.columns.add(r)}}),l}(n,g,E,s,p,h,u);l||function(t,e){e.forEach((e,n)=>{const r=t.col(n);if(null!==r){if(!_t.includes(r.type))throw new Error(bt.UNSUPPORTED_COLUMN_TYPE);const t=function(t){switch(t.type){case i.COLUMN_TYPE.STRING:case i.COLUMN_TYPE.DATE_TIME:return function(t){const e=Mt(t),n=t.getRawData(),r=n.length;for(let i=0;i<r;++i)if(n[i]!==e)return t.get(i);throw new Error(bt.EMPTY_COLUMN)}(t);case i.COLUMN_TYPE.INT:case i.COLUMN_TYPE.FLOAT:case i.COLUMN_TYPE.QNUM:return t.stats.avg;default:throw new Error(bt.UNSUPPORTED_COLUMN_TYPE)}}(r);e.forEach(e=>r.set(e,t))}})}(n,e),I()}catch(e){e instanceof Error?t.shell.error(`${bt.KNN_FAILS}: ${e.message}`):t.shell.error(`${bt.KNN_FAILS}: ${bt.CORE_ISSUE}`),L(e)}},void 0,St.RUN),_.add(y).add(w).add(N).add(S).add(f).add(c).add(d).show().onClose.subscribe(()=>!P&&I()),T},new((a=void 0)||(a=Promise))(function(t,e){function n(t){try{u(s.next(t))}catch(t){e(t)}}function i(t){try{u(s.throw(t))}catch(t){e(t)}}function u(e){var r;e.done?t(e.value):(r=e.value,r instanceof a?r:new a(function(t){t(r)})).then(n,i)}u((s=s.apply(r,o||[])).next())});var r,o,a,s}class nn extends Ye{constructor(t={}){super(t),this.similarityThresholdInput=e.input.int("Similarity Threshold",{value:80}),this.maxIterationsInput=e.input.int("Max Iterations",{value:5}),this.useWebGPUInput=e.input.bool("Use WebGPU",{value:!1}),this.inflateInput=e.input.float("Inflation Factor",{value:ee}),this.minClusterSizeInput=e.input.int("Min Cluster Size",{value:5}),Ht().then(t=>{t?(this.useWebGPUInput.setTooltip(`Use webGPU for MCL calculation (${t})`),this.useWebGPUInput.value=!0):(this.useWebGPUInput.value=!1,this.useWebGPUInput.setTooltip("WebGPU is not available"),this.useWebGPUInput.enabled=!1)})}getEditor(){return e.div([this.tableInput.root,this.columnsInputRoot,this.columnParamsEditorRoot,this.aggregationMethodInput.root,this.similarityThresholdInput.root,this.inflateInput.root,this.maxIterationsInput.root,this.minClusterSizeInput.root,this.useWebGPUInput.root],{style:{minWidth:"420px"},classes:"ui-form"})}getInput(){const t=super.getInput();return t.similarityThreshold=this.similarityThresholdInput.value,t.maxIterations=this.maxIterationsInput.value,t.useWebGPU=this.useWebGPUInput.value??!1,t.inflateFactor=this.inflateInput.value??ee,t.minClusterSize=this.minClusterSizeInput.value??5,t}async applyInput(t){await super.applyInput(t),this.similarityThresholdInput.value=t.similarityThreshold,this.maxIterationsInput.value=t.maxIterations,this.useWebGPUInput.value=t.useWebGPU,this.inflateInput.value=t.inflateFactor,this.minClusterSizeInput.value=t.minClusterSize}get params(){return{table:this.tableInput.value,columns:this.columnsInput.value,methodName:this.methodInput.value,preprocessingFunctions:this.columnOptEditors.map(t=>t.preProcessingFunction),distanceMetrics:this.columnOptEditors.map(t=>t.similarityMetricInput.value),weights:this.columnOptEditors.map(t=>t.weight),preprocessingFuncArgs:this.columnOptEditors.map(t=>t.preprocessingFunctionSettings),aggreaggregationMethod:this.aggregationMethodInput.value,threshold:this.similarityThresholdInput.value,maxIterations:this.maxIterationsInput.value??5,useWebGPU:this.useWebGPUInput.value??!1,inflateFactor:this.inflateInput.value??ee,minClusterSize:this.minClusterSizeInput.value??5}}}class rn{constructor(t,e,n,r,o,a){this.sc=t,this.from=e,this.to=n,this.shortLineThreshold=r,this.width=o,this.color=a,this.renderFlag=!1,this.renderSub=i.debounce(t.onAfterDrawScene,200).subscribe(()=>{if(this.renderFlag)return void(this.renderFlag=!1);this.renderFlag=!0;const e=t.onBeforeDrawScene.subscribe(t=>{this.render(),e.unsubscribe()});setTimeout(()=>{this.sc.invalidateCanvas()})}),t.subs.push(this.renderSub)}render(){const t=this.sc.dataFrame.getCol(this.sc.props.xColumnName),e=this.sc.dataFrame.getCol(this.sc.props.yColumnName),n=this.sc.filter,r=new Array(this.sc.dataFrame.rowCount).fill(null).map((r,i)=>t.isNone(i)||e.isNone(i)||!n.get(i)?null:this.sc.pointToScreen(i)),i=this.sc.canvas.getContext("2d");if(!i)return;i.strokeStyle=`rgba(${this.color}, 0.3)`,i.lineWidth=this.width;const o=this.shortLineThreshold*this.shortLineThreshold;for(let t=0;t<this.from.length;t++){i.beginPath();const e=this.from[t],n=this.to[t];if(r[e]&&r[n]){const t=r[e],a=r[n],s=a.x-t.x,u=a.y-t.y;if(s*s+u*u<o)continue;i.moveTo(t.x,t.y),i.lineTo(a.x,a.y),i.stroke(),i.closePath()}}}destroy(){this.renderSub.unsubscribe()}}class on extends i.JsViewer{constructor(){super(),this.initPromise=Promise.resolve(),this.initialized=!1,this.reseolver=()=>{},this.scratchCallTimer=null,this.mclProps=this.string("mclProps",null,{includeInLayout:!1,userEditable:!1,nullable:!0}),this.lines=this.string("lines",null,{includeInLayout:!1,userEditable:!1,nullable:!0}),this.scProps=this.string("scProps",null,{includeInLayout:!1,userEditable:!1,nullable:!0}),this.initPromise=new Promise(t=>{this.reseolver=t})}onFrameAttached(e){if(e.rowCount>65535)throw new Error("MCL viewer supports only dataframes with less than 65535 rows");this.sc=e.plot.scatter({showXAxis:!1,showYAxis:!1,showXSelector:!1,showYSelector:!1,title:"MCL"}),this.root.appendChild(this.sc.root),this.subs.push(t.events.onCurrentObjectChanged.subscribe(e=>{this.sc&&t.shell.o===this&&setTimeout(()=>{t.shell.o=this.sc})})),this.subs.push(i.debounce(this.sc.onPropertyValueChanged,1e3).subscribe(t=>{this.sc&&this.getProperty("scProps").set(this,JSON.stringify(Object.assign({},this.sc.props)))}))}setScProps(){if(!this.sc)return;const t=this.scProps;if(!t)return;const e=this.sc.props;if(t===JSON.stringify(Object.assign({},e)))return;const n=JSON.parse(t);Object.entries(n).forEach(([t,n])=>{e.hasProperty(t)&&e[t]!==n&&(this.sc.props[t]=n)})}onPropertyChanged(t){null!==t&&("scProps"===t.name?this.setScProps():"lines"===t.name?this.decodeLines():"mclProps"===t.name&&(this.scratchCallTimer&&clearTimeout(this.scratchCallTimer),this.scratchCallTimer=setTimeout(()=>{this.initFromScratch()},300)))}async initFromScratch(){if(!this.mclProps||!this.sc||!this.dataFrame||this.initialized)return;if(this.lines)return void this.decodeLines();const r=JSON.parse(this.mclProps),o=r.cols.map(t=>this.dataFrame.columns.byName(t)),a=r.preprocessingFuncs.map(t=>t?i.Func.byName(t):null),s=await async function(r,o,a,s,u,c,l,d=80,h=10,f=!1,p=2,m=5,g){let y=null,v=g;v||(y=t.shell.tableView(r.name)??t.shell.addTableView(r),v=y.scatterPlot({showXAxis:!1,showYAxis:!1,showXSelector:!1,showYSelector:!1,title:"MCL"})),e.setUpdateIndicator(v.root,!0);const w=[],b=[];for(let t=0;t<c.length;++t){const e=c[t];if(e){const n=e.inputs[0].name,r=e.inputs[1].name,{entries:i,options:s}=await e.apply({[n]:o[t],[r]:a[t],...l[t]??{}});b.push({entries:i,options:s}),w.push(s??{})}else{const e=o[t].toList(),n={};b.push({entries:e,options:n}),w.push(n)}}const A=function(t,e,r,i,o,a,s=10,u=!1,c=2){const l=new Worker(new URL(n.p+n.u(980),n.b));let d;return l.postMessage({data:t,threshold:e,weights:r,aggregationMethod:i,distanceFns:o,distanceFnArgs:a,maxIterations:s,useWebGPU:u,inflate:c}),{promise:new Promise((t,e)=>{d=t,l.onmessage=e=>{setTimeout(()=>l.terminate(),100),t(e.data.res)},l.onerror=t=>{setTimeout(()=>l.terminate(),100),e(t)}}),terminate:()=>{try{d(null),l.terminate()}catch(t){console.error(t)}}}}(b.map(t=>t.entries),d,s,u,a,w,h,f,p),E=t.events.onViewerClosed.subscribe(t=>{t.args.viewer?.props?.title===v.props.title&&v.type===t.args?.viewer?.type&&(E.unsubscribe(),A.terminate())}),C=await A.promise;if(!C)return;const S=r.columns.getUnusedName("Cluster (MCL)"),_=r.columns.getUnusedName("EmbedX (MCL)"),M=r.columns.getUnusedName("EmbedY (MCL)"),N={};C.clusters.forEach(t=>{N[t]||(N[t]=0),N[t]++});const I=new Uint32Array(C.embedX.length);for(let t=0;t<C.is.length;t++)I[C.is[t]]++,I[C.js[t]]++;const L=r.columns.getUnusedName("Cluster size (MCL)"),P=r.columns.getUnusedName("Connectivity (MCL)"),T=r.columns.addNewFloat(_);T.init(t=>C.embedX[t]);const F=r.columns.addNewFloat(M);F.init(t=>C.embedY[t]);const O=r.columns.addNewString(S);O.init(t=>N[C.clusters[t]]>=m?C.clusters[t].toString():"-1");const R={"-1":i.Color.setAlpha(i.Color.lightBlue,100)};O.setTag(i.TAGS.COLOR_CODING_CATEGORICAL,JSON.stringify(R)),O.temp[i.TAGS.COLOR_CODING_CATEGORICAL]=R;const x=r.columns.addNewInt(L);x.init(t=>N[C.clusters[t]]);const D=r.columns.addNewInt(P);D.init(t=>I[t]),v.props.xColumnName=_,v.props.yColumnName=M,v.props.colorColumnName=S,v.props.markerDefaultSize=6,E.unsubscribe();const k=[],U=[],G=new Map;for(let t=0;t<C.is.length;t++){let e=C.clusters[C.is[t]],n=C.clusters[C.js[t]];if(e===n){k.push(C.is[t]),U.push(C.js[t]);continue}if(e>n){const t=e;e=n,n=t}let r=G.get(e);r||(r=new Map,G.set(e,r));let i=r.get(n);i||(i=0),i>=20||(i++,r.set(n,i),k.push(C.is[t]),U.push(C.js[t]))}return e.setUpdateIndicator(v.root,!1),{sc:v,embedXCol:T,embedYCol:F,clusterCol:O,clusterCounterCol:x,connectivityCol:D,i:k,j:U}}(this.dataFrame,o,r.metrics,r.weights,r.aggregationMethod,a,r.preprocessingFuncArgs,r.threshold,r.maxIterations,r.useWebGPU,r.inflate,r.minClusterSize,this.sc);return s?this.dataFrame.getTag(".script")?(this.linesRenderer?.destroy(),this.linesRenderer=new rn(this.sc,s.i,s.j,6,.75,"128,128,128"),this.initialized=!0,void this.reseolver()):void this.encodeLines(s.i,s.j):void 0}decodeLines(){if(!this.lines)return;const t=this.lines.length;if(t%2!=0)throw new Error("Invalid lines string");const e=new Array(t/2).fill(null).map((t,e)=>this.lines.charCodeAt(2*e)),n=new Array(t/2).fill(null).map((t,e)=>this.lines.charCodeAt(2*e+1));this.linesRenderer?.destroy(),this.linesRenderer=new rn(this.sc,e,n,6,.75,"128,128,128"),this.initialized=!0,this.reseolver()}encodeLines(t,e){const n=new Array(t.length).fill(null).map((n,r)=>`${String.fromCharCode(t[r])}${String.fromCharCode(e[r])}`).join("");this.getProperty("lines").set(this,n)}}var an=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}u((r=r.apply(t,e||[])).next())})};function sn(t,e){const n=t.length;if(n!==e.length-1)throw new Error("Incorrect parameters count");const r=t.byIndex(0),o=r.length,a=new Float32Array(o);let s=r.getRawData();const u=e[n];let c=e[0];for(let t=0;t<o;++t)a[t]=u+c*s[t];for(let r=1;r<n;++r){s=t.byIndex(r).getRawData(),c=e[r];for(let t=0;t<o;++t)a[t]+=c*s[t]}return i.Column.fromFloat32Array(t.getUnusedName("prediction"),a,o)}const un=(t,e)=>e<=t?Math.min(10,e):Math.min(10,t);var cn;!function(t){t[t.MAX_SAMLPES=1e5]="MAX_SAMLPES",t[t.MAX_FEATURES=1e3]="MAX_FEATURES"}(cn||(cn={}));class ln{static isApplicable(t,e){for(const e of t)if(!e.matches("numerical"))return!1;return!!e.matches("numerical")}static isInteractive(t,e){return t.length<=cn.MAX_FEATURES&&e.length<=cn.MAX_SAMLPES}constructor(t){if(this.specn=null,t)try{const e=new Uint32Array(t.buffer,0,2),n=e[0],r=e[1],o=new Uint8Array(t.buffer,8,n),a=i.DataFrame.fromByteArray(o),s=a.rowCount,u=a.columns,c=u.length,l=new Uint8Array(t.buffer,8+n,r),d=i.DataFrame.fromByteArray(l);if(c<3)throw new Error("incorrect columns count");const h=u.byName(ot.FEATURES).toList(),f=new Float32Array(s);f.set(u.byName(ot.REGR_COEFS).getRawData());const p=c-2,m=new Array(p);for(let t=0;t<p;++t)m[t]=new Float32Array(s),m[t].set(u.byIndex(t+2).getRawData());this.specn={params:f,loadings:m,names:h,dim:s-1,components:c-2,scores:d}}catch(t){throw new Error(`Failed to load model: ${t instanceof Error?t.message:"the platform issue"}`)}}fit(t,e,n){return r=this,o=void 0,s=function*(){const r=yield vt({table:i.DataFrame.fromColumns([e]),features:t,predict:e,components:n,names:void 0,isQuadratic:!1}),o=t.names();o.push("_");const a=this.getRegrCoeffs(t,e,r.regressionCoefficients),s=this.getLoadings(n,r.xLoadings);this.specn={names:o,params:a,loadings:s,components:n,dim:t.length,scores:this.getScoresDf(r)},this.computeExplVars(e.length,n,r.yLoadings)},new((a=void 0)||(a=Promise))(function(t,e){function n(t){try{u(s.next(t))}catch(t){e(t)}}function i(t){try{u(s.throw(t))}catch(t){e(t)}}function u(e){var r;e.done?t(e.value):(r=e.value,r instanceof a?r:new a(function(t){t(r)})).then(n,i)}u((s=s.apply(r,o||[])).next())});var r,o,a,s}getLoadings(t,e){const n=Array(t),r=e[0].length+1;for(let i=0;i<t;++i)n[i]=new Float32Array(r),n[i].set(e[i].getRawData());return n}getRegrCoeffs(t,e,n){const r=t.length,i=new Float32Array(r+1),o=n.getRawData();let a=0;for(let e=0;e<r;++e)i[e]=o[e],a+=o[e]*t.byIndex(e).stats.avg;return i[r]=e.stats.avg-a,i}computeExplVars(t,e,n){if(null===this.specn)throw new Error("Failed to compute explained variances");const r=n.getRawData(),i=this.specn.loadings[0].length-1;let o=Math.pow(r[0],2)/t;this.specn.loadings[0][i]=o;for(let n=1;n<e;++n)o+=Math.pow(r[n],2)/t,this.specn.loadings[n][i]=o}toBytes(){if(null===this.specn)throw new Error("Failed to pack untrained model");const t=i.DataFrame.fromColumns([i.Column.fromStrings(ot.FEATURES,this.specn.names),i.Column.fromFloat32Array(ot.REGR_COEFS,this.specn.params)]);this.specn.loadings.forEach((e,n)=>t.columns.add(i.Column.fromFloat32Array(`${ot.XLOADING}${n+1}`,e)));const e=t.toByteArray(),n=e.length,r=this.specn.scores.toByteArray(),o=r.length,a=n+o+8,s=new Uint8Array(64*(Math.ceil(a/64)+1)),u=new Uint32Array(s.buffer,0,2);return u[0]=n,u[1]=o,s.set(e,8),s.set(r,8+n),s}predict(t){if(null===this.specn)throw new Error("Predicting failed: model is not trained");return sn(t,this.specn.params)}loadingsParamsViewers(){if(null===this.specn)throw new Error("Failed to create loadings and parameters viewers: untrained model");const t=[],e=this.specn.dim,n=i.DataFrame.fromColumns([i.Column.fromStrings(ot.FEATURES,this.specn.names.slice(0,-1)),i.Column.fromFloat32Array(ot.REGR_COEFS,this.specn.params,e)]),r=n.columns,o=r.length,a=this.specn.components;return this.specn.loadings.forEach((t,r)=>n.columns.add(i.Column.fromFloat32Array(`${ot.XLOADING}${r+1}`,t,e))),t.push(i.Viewer.scatterPlot(n,{title:ot.LOADINGS,xColumnName:r.byIndex(o).name,yColumnName:r.byIndex(o+(a>1?1:0)).name,markerType:i.MARKER_TYPE.CIRCLE,labelFormColumnNames:[ot.FEATURES],help:st.LOADINGS})),t.push(i.Viewer.barChart(n,{title:ot.REGR_COEFS,splitColumnName:ot.FEATURES,valueColumnName:ot.REGR_COEFS,valueAggrType:i.AGG.AVG,help:st.COEFFS,showValueSelector:!1,showStackSelector:!1})),t}explVarsViewer(){if(null===this.specn)throw new Error("Failed to create exaplained variances viewer: untrained model");const t=this.specn.components,e=this.specn.dim,n=new Array(t),r=new Float32Array(t);n[0]=`${ct.COMP} 1`,r[0]=this.specn.loadings[0][e];for(let i=1;i<t;++i)n[i]=`${ct.COMPS} ${i+1}`,r[i]=this.specn.loadings[i][e];return i.Viewer.barChart(i.DataFrame.fromColumns([i.Column.fromStrings(ct.COMPS,n),i.Column.fromFloat32Array(ot.EXPL_VAR,r)]),{title:ot.EXPL_VAR,splitColumnName:ct.COMPS,valueColumnName:ot.EXPL_VAR,valueAggrType:i.AGG.AVG,help:st.EXPL_VARS,showCategorySelector:!1,showStackSelector:!1,showValueSelector:!1})}viewers(){if(null===this.specn)throw new Error("Failed to create viewers: untrained model");const t=this.loadingsParamsViewers();return t.push(this.explVarsViewer(),this.getScoresScatter()),t}getScoresDf(t){const e=t.tScores,n=t.uScores;return e.forEach((t,e)=>t.name=`${ot.XSCORE}${e+1}`),n.forEach((t,e)=>t.name=`${ot.YSCORE}${e+1}`),i.DataFrame.fromColumns(e.concat(n))}getScoresScatter(){if(null===this.specn)throw new Error("Failed to create scores scatter: untrained model");const t=this.specn.scores.columns.names(),e=i.Viewer.scatterPlot(this.specn.scores,{title:ot.SCORES,xColumnName:t[0],yColumnName:t[1],markerType:i.MARKER_TYPE.CIRCLE,help:st.SCORES,showViewerFormulaLines:!0});return e.meta.formulaLines.addAll(yt(t)),e}}var dn=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}u((r=r.apply(t,e||[])).next())})};const hn="Avg-s",fn="Stddev-s";var pn;!function(t){t[t.MAX_SAMLPES=5e4]="MAX_SAMLPES",t[t.MAX_FEATURES=100]="MAX_FEATURES"}(pn||(pn={}));class mn{static isApplicable(t,e){for(const e of t)if(!e.matches("numerical"))return!1;return e.type===i.COLUMN_TYPE.STRING}static isInteractive(t,e){return t.length<=pn.MAX_FEATURES&&e.length<=pn.MAX_SAMLPES}constructor(t,e){if(this.params=void 0,this.classesCount=1,this.featuresCount=1,void 0!==t){const e=t.featuresCount,n=t.classesCount;if(e<1)throw new Error("Incorrect features count");if(n<1)throw new Error("Incorrect classes count");const r=e+1;this.avgs=new Float32Array(r),this.stdevs=new Float32Array(r),this.categories=new Array(r),this.featuresCount=e,this.classesCount=n}else{if(void 0===e)throw new Error("Softmax classifier not initialized");try{const t=new Uint32Array(e.buffer,0,1)[0],n=new Uint8Array(e.buffer,4,t),r=i.DataFrame.fromByteArray(n),o=r.columns,a=o.length;if(a<3)throw new Error("incorrect columns count");this.classesCount=a-2,this.featuresCount=r.rowCount-1;const s=this.classesCount;this.params=new Array(s),this.categories=new Array(r.rowCount);for(let t=0;t<s;++t){const e=o.byIndex(t);if(this.categories[t]=e.name,e.type!==i.COLUMN_TYPE.FLOAT)throw new Error(`Incorrect input column type. Expected: float, passed: ${e.type}`);this.params[t]=e.getRawData()}const u=o.byName(hn);if(u.type!==i.COLUMN_TYPE.FLOAT)throw new Error("incorrect average values column type");this.avgs=u.getRawData();const c=o.byName(fn);if(c.type!==i.COLUMN_TYPE.FLOAT)throw new Error("incorrect standard deviations column type");this.stdevs=c.getRawData()}catch(t){throw new Error(`Failed to load model: ${t instanceof Error?t.message:"the platform issue"}`)}}}toBytes(){if(void 0===this.params)throw new Error("Non-trained model");const t=this.classesCount,e=new Array(t+2);for(let n=0;n<t;++n)e[n]=i.Column.fromFloat32Array(this.categories[n],this.params[n]);e[t]=i.Column.fromFloat32Array(hn,this.avgs),e[t+1]=i.Column.fromFloat32Array(fn,this.stdevs);const n=i.DataFrame.fromColumns(e).toByteArray(),r=n.length,o=new Uint8Array(r+4);return new Uint32Array(o.buffer,0,1)[0]=r,o.set(n,4),o}fit(t,e){return dn(this,arguments,void 0,function*(t,e,n=1,r=100,o=.1,a=.001){if(t.length!==this.featuresCount)throw new Error("Training failes - incorrect features count");if(n<=0||r<1||o<=0||a<=0)throw new Error("Training failes - incorrect fitting hyperparameters");this.extractStats(t);const s=e.length,u=e.categories.length,c=e.categories;for(let t=0;t<u;++t)this.categories[t]=c[t];try{const c=function(t,e,n,r,i,o,a,s,u,c,l){return g(EDA,"fitSoftmax",[t,e,n,r,i,o,a,s,u,c,l])}(t,i.Column.fromFloat32Array("avgs",this.avgs,this.featuresCount),i.Column.fromFloat32Array("stdevs",this.stdevs,this.featuresCount),i.Column.fromInt32Array("targets",e.getRawData(),s),u,r,n,o,a,this.featuresCount+1,u).columns;this.params=new Array(u);for(let t=0;t<u;++t)this.params[t]=c.byIndex(t).getRawData()}catch(i){try{this.params=yield this.fitSoftmaxParams(t,e,r,n,o,a)}catch(t){throw new Error("Training failes")}}if(void 0===this.params)throw new Error("Training failes")})}extractStats(t){let e=0;for(const n of t){if(n.type!==i.COLUMN_TYPE.INT&&n.type!==i.COLUMN_TYPE.FLOAT)throw new Error("Training failes - incorrect features type");this.avgs[e]=n.stats.avg,this.stdevs[e]=n.stats.stdev,++e}}normalized(t){const e=t.byIndex(0).length,n=new Array(e);for(let t=0;t<e;++t)n[t]=new Float32Array(this.featuresCount);let r=0;for(const o of t){if(o.type!==i.COLUMN_TYPE.INT&&o.type!==i.COLUMN_TYPE.FLOAT)throw new Error("Training failes - incorrect features type");const t=o.getRawData(),a=this.avgs[r],s=this.stdevs[r];if(s>0)for(let i=0;i<e;++i)n[i][r]=(t[i]-a)/s;else for(let t=0;t<e;++t)n[t][r]=0;++r}return n}transposed(t){const e=t.byIndex(0).length,n=this.featuresCount,r=new Array(n);for(let t=0;t<n;++t)r[t]=new Float32Array(e);let o=0;for(const n of t){if(n.type!==i.COLUMN_TYPE.INT&&n.type!==i.COLUMN_TYPE.FLOAT)throw new Error("Training failes - incorrect features type");const t=n.getRawData(),a=this.avgs[o],s=this.stdevs[o];if(s>0)for(let n=0;n<e;++n)r[o][n]=(t[n]-a)/s;else for(let t=0;t<e;++t)r[o][t]=0;++o}return r}preprocessedTargets(t){if(t.type!==i.COLUMN_TYPE.STRING)throw new Error("Training failes - incorrect target type");const e=this.classesCount,n=t.length,r=t.getRawData(),o=new Array(n),a=new Uint32Array(e).fill(0);for(let t=0;t<n;++t)o[t]=new Uint8Array(e).fill(0);for(let t=0;t<n;++t)o[t][r[t]]=1,++a[r[t]];return{oneHot:o,weights:a}}predict(t){if(void 0===this.params)throw new Error("Non-trained model");if(t.length!==this.featuresCount)throw new Error("Predcition fails: incorrect features count");const e=this.normalized(t),n=e.length,r=this.featuresCount,o=this.classesCount;let a,s;const u=new Float32Array(o);let c,l,d;const h=new Array(n);for(let t=0;t<n;++t){a=e[t],c=0;for(let t=0;t<o;++t){s=this.params[t],c=s[r];for(let t=0;t<r;++t)c+=s[t]*a[t];u[t]=Math.exp(c)}l=u[0],d=0;for(let t=1;t<o;++t)l<u[t]&&(l=u[t],d=t);h[t]=this.categories[d]}return i.Column.fromStrings("predicted",h)}fitSoftmaxParams(t,e,r,i,o,a){return dn(this,void 0,void 0,function*(){const s=this.preprocessedTargets(e);return new Promise((u,c)=>{const l=new Worker(new URL(n.p+n.u(501),n.b));l.postMessage({features:this.normalized(t),transposed:this.transposed(t),oneHot:s.oneHot,classesWeights:s.weights,targetRaw:e.getRawData(),iterations:r,rate:i,penalty:o,tolerance:a}),l.onmessage=function(t){l.terminate(),u(t.data.params),console.log(`Loss: ${t.data.loss}`)}})})}}var gn,yn,vn;!function(t){t[t.ITERATIONS=20]="ITERATIONS",t[t.ETA=.3]="ETA",t[t.MAX_DEPTH=6]="MAX_DEPTH",t[t.LAMBDA=1]="LAMBDA",t[t.ALPHA=0]="ALPHA"}(gn||(gn={})),function(t){t[t.SAMLPES_HIGH=1e5]="SAMLPES_HIGH",t[t.SAMLPES_MID=5e4]="SAMLPES_MID",t[t.SAMPLES_LOW=1e4]="SAMPLES_LOW",t[t.FEATURES_HIGH=10]="FEATURES_HIGH",t[t.FEATURES_MID=20]="FEATURES_MID",t[t.FEATURES_LOW=100]="FEATURES_LOW"}(yn||(yn={})),function(t){t[t.MODEL=1e7]="MODEL",t[t.UTILS=1]="UTILS",t[t.PACK=128]="PACK",t[t.SIZE=4]="SIZE"}(vn||(vn={}));const wn=i.FLOAT_NULL;var bn;!function(t){t.PREDICT="Prediction",t.TYPE="Type",t.PARAMS="Params count",t.CATS="Categories",t.CATS_SIZE="Categories size"}(bn||(bn={}));class An{static isApplicable(t,e){for(const e of t)if(!e.matches("numerical"))return!1;return!(!e.matches("numerical")&&!e.matches("string"))}static isInteractive(t,e){const n=t.length,r=e.length;return r<=yn.SAMPLES_LOW?n<=yn.FEATURES_LOW:r<=yn.SAMLPES_MID?n<=yn.FEATURES_MID:r<=yn.SAMLPES_HIGH&&n<=yn.FEATURES_HIGH}constructor(t){var e;if(this.modelParams=void 0,this.targetType=void 0,this.targetCategories=void 0,t)try{let n=0;const r=new Uint32Array(t.buffer,n,1)[0];n+=vn.SIZE;const o=i.DataFrame.fromByteArray(new Uint8Array(t.buffer,n,r));n+=r,this.targetType=o.get(bn.TYPE,0);const a=o.get(bn.PARAMS,0),s=o.get(bn.CATS_SIZE,0);if(s>0){const r=i.DataFrame.fromByteArray(new Uint8Array(t.buffer,n,s));this.targetCategories=null===(e=r.col(bn.CATS))||void 0===e?void 0:e.toList()}n+=s,n=4*Math.ceil(n/4),this.modelParams=new Int32Array(t.buffer,n,a)}catch(t){throw new Error(`Failed to load model: ${t instanceof Error?t.message:"the platform issue"}`)}}fit(t,e){return r=this,o=arguments,s=function*(t,e,r=gn.ITERATIONS,o=gn.ETA,a=gn.MAX_DEPTH,s=gn.LAMBDA,u=gn.ALPHA){this.targetType=e.type,this.targetType===i.COLUMN_TYPE.STRING&&(this.targetCategories=e.categories),this.modelParams=yield async function(t,e,r,i,o,a,s,u,c,l){return new Promise((d,h)=>{const f=e.length,p=t.length,m=new Float32Array(f*p);let g,y;for(let e=0;e<p;++e){y=t.byIndex(e).getRawData(),g=e*f;for(let t=0;t<f;++t)m[t+g]=y[t]}const v=new Worker(new URL(n.p+n.u(990),n.b));v.postMessage({features:m,target:e.getRawData(),samplesCount:f,featuresCount:p,modelReserve:c,utilsLength:l,iterations:i,eta:o,maxDepth:a,lambda:s,alpha:u,missingValue:r}),v.onmessage=function(t){v.terminate(),d(t.data.params)}})}(t,e,wn,r,o,a,s,u,vn.MODEL,vn.UTILS)},new((a=void 0)||(a=Promise))(function(t,e){function n(t){try{u(s.next(t))}catch(t){e(t)}}function i(t){try{u(s.throw(t))}catch(t){e(t)}}function u(e){var r;e.done?t(e.value):(r=e.value,r instanceof a?r:new a(function(t){t(r)})).then(n,i)}u((s=s.apply(r,o||[])).next())});var r,o,a,s}predict(t){if(void 0===this.modelParams)throw new Error("Failed to apply non-trained model");const e=function(t,e,n){const r=t.byIndex(0).length,i=t.length,o=n.length;let a=XGBoostModule.HEAPF32;const s=XGBoostModule.HEAP32,u=XGBoostModule._malloc(r*i*4),c=XGBoostModule._malloc(4*r),l=XGBoostModule._malloc(4*o);for(let e=0;e<i;++e){const n=t.byIndex(e).getRawData();for(let t=0;t<r;++t)a[u/4+t+e*r]=n[t]}for(let t=0;t<o;++t)s[l/4+t]=n[t];XGBoostModule._predict(u,r,i,e,l,o,c,r),a=XGBoostModule.HEAPF32;const d=new Float32Array(r);for(let t=0;t<r;++t)d[t]=a[c/4+t];return XGBoostModule._free(u),XGBoostModule._free(c),XGBoostModule._free(l),d}(t,wn,this.modelParams);switch(this.targetType){case i.COLUMN_TYPE.STRING:return this.stringColPrediction(e);case i.COLUMN_TYPE.INT:return this.intColPrediction(e);case i.COLUMN_TYPE.BIG_INT:return this.bigIntColPrediction(e);default:return i.Column.fromFloat32Array(bn.PREDICT,e)}}toBytes(){if(void 0===this.modelParams||void 0===this.targetType)throw new Error("Failed to pack non-trained model");const t=void 0!==this.targetCategories?i.DataFrame.fromColumns([i.Column.fromList(i.COLUMN_TYPE.STRING,bn.CATS,this.targetCategories)]).toByteArray():void 0,e=void 0!==t?t.length:0,n=this.modelParams.length*this.modelParams.BYTES_PER_ELEMENT,r=i.DataFrame.fromColumns([i.Column.fromStrings(bn.TYPE,[this.targetType]),i.Column.fromInt32Array(bn.PARAMS,new Int32Array([this.modelParams.length])),i.Column.fromInt32Array(bn.CATS_SIZE,new Int32Array([e]))]).toByteArray(),o=r.length,a=64*Math.ceil((vn.SIZE+o+e+n+vn.PACK)/64),s=new Uint8Array(a);let u=0;return new Uint32Array(s.buffer,u,1)[0]=o,u+=vn.SIZE,s.set(r,u),u+=o,e>0&&s.set(t,u),u+=e,u=4*Math.ceil(u/4),s.set(new Uint8Array(this.modelParams.buffer),u),s}stringColPrediction(t){const e=t.length;if(void 0===this.targetCategories)throw new Error("Predicting fails: undefined categories");const n=new Array(e),r=this.targetCategories.length-1,o=t=>Math.max(0,Math.min(t,r));for(let r=0;r<e;++r)n[r]=this.targetCategories[o(Math.round(t[r]))];return i.Column.fromList(i.COLUMN_TYPE.STRING,bn.PREDICT,n)}intColPrediction(t){const e=t.length,n=new Int32Array(e);for(let r=0;r<e;++r)n[r]=Math.round(t[r]);return i.Column.fromInt32Array(bn.PREDICT,n,e)}bigIntColPrediction(t){const e=t.length,n=new BigInt64Array(e);for(let r=0;r<e;++r)n[r]=BigInt(Math.round(t[r]));return i.Column.fromBigInt64Array(bn.PREDICT,n)}}var En=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}u((r=r.apply(t,e||[])).next())})};function Cn(){Lr.info()}function Sn(){return En(this,void 0,void 0,function*(){yield Lr.init()})}function _n(t,e,n,r,i){return En(this,void 0,void 0,function*(){return yield Lr.dbScan(t,e,n,r,i)})}function Mn(t,e,n,r,i){return En(this,void 0,void 0,function*(){yield Lr.PCA(t,e,n,r,i)})}function Nn(t,e,n,r){return En(this,void 0,void 0,function*(){yield Lr.dbscanPostProcessingFunction(t,e,n,r)})}function In(t,e){return Lr.numberPreprocessingFunction(t,e)}function Ln(t,e){return Lr.stringPreprocessingFunction(t,e)}function Pn(){return En(this,void 0,void 0,function*(){yield Lr.reduceDimensionality()})}function Tn(t){Lr.GetMCLEditor(t)}function Fn(t,e,n,r,i,o,a,s,u,c,l,d){return En(this,void 0,void 0,function*(){return yield Lr.MCLClustering(t,e,n,r,i,o,a,s,u,c,l,d)})}function On(){return Lr.markovClusteringViewer()}function Rn(t,e,n,r,i){return En(this,void 0,void 0,function*(){return yield Lr.PLS(t,e,n,r,i)})}function xn(){return En(this,void 0,void 0,function*(){yield Lr.topMenuPLS()})}function Dn(){return En(this,void 0,void 0,function*(){yield Lr.MVA()})}function kn(){return En(this,void 0,void 0,function*(){yield Lr.demoMultivariateAnalysis()})}function Un(t,e,n){return En(this,void 0,void 0,function*(){return yield Lr.trainLinearKernelSVM(t,e,n)})}function Gn(t,e){return En(this,void 0,void 0,function*(){return yield Lr.applyLinearKernelSVM(t,e)})}function Vn(t,e){return En(this,void 0,void 0,function*(){return yield Lr.isApplicableLinearKernelSVM(t,e)})}function Bn(t,e){return En(this,void 0,void 0,function*(){return yield Lr.isInteractiveLinearKernelSVM(t,e)})}function Wn(t,e,n,r){return En(this,void 0,void 0,function*(){return yield Lr.visualizeLinearKernelSVM(t,e,n,r)})}function zn(t,e,n,r){return En(this,void 0,void 0,function*(){return yield Lr.trainRBFkernelSVM(t,e,n,r)})}function Hn(t,e){return En(this,void 0,void 0,function*(){return yield Lr.applyRBFkernelSVM(t,e)})}function jn(t,e){return En(this,void 0,void 0,function*(){return yield Lr.isApplicableRBFkernelSVM(t,e)})}function Kn(t,e){return En(this,void 0,void 0,function*(){return yield Lr.isInteractiveRBFkernelSVM(t,e)})}function qn(t,e,n,r){return En(this,void 0,void 0,function*(){return yield Lr.visualizeRBFkernelSVM(t,e,n,r)})}function Yn(t,e,n,r,i){return En(this,void 0,void 0,function*(){return yield Lr.trainPolynomialKernelSVM(t,e,n,r,i)})}function $n(t,e){return En(this,void 0,void 0,function*(){return yield Lr.applyPolynomialKernelSVM(t,e)})}function Xn(t,e){return En(this,void 0,void 0,function*(){return yield Lr.isApplicablePolynomialKernelSVM(t,e)})}function Qn(t,e){return En(this,void 0,void 0,function*(){return yield Lr.isInteractivePolynomialKernelSVM(t,e)})}function Jn(t,e,n,r){return En(this,void 0,void 0,function*(){return yield Lr.visualizePolynomialKernelSVM(t,e,n,r)})}function Zn(t,e,n,r,i){return En(this,void 0,void 0,function*(){return yield Lr.trainSigmoidKernelSVM(t,e,n,r,i)})}function tr(t,e){return En(this,void 0,void 0,function*(){return yield Lr.applySigmoidKernelSVM(t,e)})}function er(t,e){return En(this,void 0,void 0,function*(){return yield Lr.isApplicableSigmoidKernelSVM(t,e)})}function nr(t,e){return En(this,void 0,void 0,function*(){return yield Lr.isInteractiveSigmoidKernelSVM(t,e)})}function rr(t,e,n,r){return En(this,void 0,void 0,function*(){return yield Lr.visualizeSigmoidKernelSVM(t,e,n,r)})}function ir(){Lr.anova()}function or(){Lr.kNNImputation()}function ar(t){return En(this,void 0,void 0,function*(){yield Lr.kNNImputationForTable(t)})}function sr(t,e){return En(this,void 0,void 0,function*(){return yield Lr.trainLinearRegression(t,e)})}function ur(t,e){return Lr.applyLinearRegression(t,e)}function cr(t,e){return Lr.isApplicableLinearRegression(t,e)}function lr(t,e){return Lr.isInteractiveLinearRegression(t,e)}function dr(t,e,n,r,i,o){return En(this,void 0,void 0,function*(){return yield Lr.trainSoftmax(t,e,n,r,i,o)})}function hr(t,e){return Lr.applySoftmax(t,e)}function fr(t,e){return Lr.isApplicableSoftmax(t,e)}function pr(t,e){return Lr.isInteractiveSoftmax(t,e)}function mr(t,e,n){return En(this,void 0,void 0,function*(){return yield Lr.trainPLSRegression(t,e,n)})}function gr(t,e){return Lr.applyPLSRegression(t,e)}function yr(t,e){return Lr.isApplicablePLSRegression(t,e)}function vr(t,e,n,r){return En(this,void 0,void 0,function*(){return yield Lr.visualizePLSRegression(t,e,n,r)})}function wr(t,e){return Lr.isInteractivePLSRegression(t,e)}function br(t,e,n,r,i,o,a){return En(this,void 0,void 0,function*(){return yield Lr.trainXGBooster(t,e,n,r,i,o,a)})}function Ar(t,e){return Lr.applyXGBooster(t,e)}function Er(t,e){return Lr.isInteractiveXGBooster(t,e)}function Cr(t,e){return Lr.isApplicableXGBooster(t,e)}var Sr=function(t,e,n,r){var i,o=arguments.length,a=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(a=(o<3?i(a):o>3?i(e,n,a):i(e,n))||a);return o>3&&a&&Object.defineProperty(e,n,a),a},_r=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},Mr=function(t,e){return function(n,r){e(n,r,t)}},Nr=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}u((r=r.apply(t,e||[])).next())})};const Ir=new i.Package;class Lr{static info(){t.shell.info(Ir.webRoot)}static init(){return Nr(this,void 0,void 0,function*(){yield async function(){await initEDA()}(),yield async function(){await initXGBoostModule()}()})}static dbScan(t,e,n,r,o){return Nr(this,void 0,void 0,function*(){const a=e.getRawData(),s=n.getRawData(),u=yield Wt(a,s,r,o),c=t.columns.getUnusedName("Cluster (DBSCAN)"),l=i.Column.fromInt32Array(c,u);return t.columns.add(l),l})}static PCA(e,n,r,i,o){return Nr(this,void 0,void 0,function*(){try{const a=yield B(e,n,r,i,o);if(function(t,e){for(const t of e.toList())t.name="PC"+t.name}(0,a.columns),null===e.id)t.shell.addTableView(a);else{const t=e.columns,n=a.columns.toList();for(const e of n)a.columns.remove(e.name),e.name=t.getUnusedName(e.name),t.add(e)}}catch(e){t.shell.warning(`Failed to compute PCA: ${e instanceof Error?e.message:"platform issue"}`)}})}static dbscanPostProcessingFunction(e,n,r,o){return Nr(this,void 0,void 0,function*(){const a=e.dataFrame;if(null===a)return;const s=yield Lr.dbScan(a,e,n,r,o);a.changeColumnType(s,"string");const u=[e.name,n.name],c=t.shell.tableView(a.name);if(c)for(const t of c.viewers)if(t instanceof i.ScatterPlotViewer&&u.includes(t.props.xColumnName)&&u.includes(t.props.yColumnName))return void(t.props.colorColumnName=s.name)})}static numberPreprocessingFunction(t,e){const n=t.stats.max-t.stats.min;return{entries:t.toList(),options:{range:n}}}static stringPreprocessingFunction(t,e){return{entries:t.toList(),options:{}}}static reduceDimensionality(){return Nr(this,void 0,void 0,function*(){const r=new Ye,o=e.dialog("Dimensionality reduction").add(r.getEditor()).onOK(()=>Nr(this,void 0,void 0,function*(){const o=r.getParams();0!==o.columns.length&&(yield async function(r,o,a,s,u,c,l,d=!0,h=!1,f={preprocessingFuncArgs:[]},p={},m=null,g={},y){const v={showXAxis:!1,showYAxis:!1,showXSelector:!1,showYSelector:!1};if(o.length!==s.length||o.length!==c.length||o.length!==u.length||o.length!==f.preprocessingFuncArgs.length)throw new Error("columns, metrics and preprocessing functions, weights and function argumentsmust have the same length");const w=d?p.tableView??t.shell.tableView(r.name)??t.shell.addTableView(r):null,b=async()=>{const b=i.TaskBarProgressIndicator.create(`Initializing ${p.scatterPlotName??"dimensionality reduction"} ...`);let A;try{const E=function(t){const e=["Embed_X","Embed_Y"],n=t.columns.names().filter(t=>t.includes(e[0])).length+1;return e.map(t=>`${t}_${n}`)}(r);function C(t,n,s){let u=null,c=null;r.columns.names().includes(E[0])?(u=r.columns.byName(E[0]),c=r.columns.byName(E[1])):(u=r.columns.add(i.Column.float(E[0],r.rowCount)),c=r.columns.add(i.Column.float(E[1],r.rowCount)),d&&!A&&(A=w.scatterPlot({...v,x:E[0],y:E[1],title:p.scatterPlotName??tn(o,a)}))),p["show-scatterplot-progress"]&&(A?.root&&e.setUpdateIndicator(A.root,!1),u.init(t=>s[0]?s[0][t]:void 0),c.init(t=>s[1]?s[1][t]:void 0));const l=t/n*100;b.update(l,`Running ${p.scatterPlotName??"dimensionality reduction"}... ${l.toFixed(0)}%`)}async function S(){r.columns.add(i.Column.float(E[0],r.rowCount)),r.columns.add(i.Column.float(E[1],r.rowCount));let h=null;d&&(A=w.scatterPlot({...v,x:E[0],y:E[1],title:p.scatterPlotName??tn(o,a)}),e.setUpdateIndicator(A.root,!0));const m=t.events.onViewerClosed.subscribe(e=>{const n=e.args.viewer;n?.getOptions()?.look?.title&&A?.getOptions()?.look?.title&&n?.getOptions()?.look?.title===A?.getOptions()?.look?.title&&(t.events.fireCustomEvent(Je,{}),m.unsubscribe(),h?.(),b.close())}),g=new Promise(async(e,i)=>{try{h=e;const i=[];let d=s,m=u,g=l;if(y&&o.every(t=>t.isNumerical)){const t=o.map(t=>t.toList()),e=new Array(r.rowCount).fill(0).map((t,e)=>new Float32Array(o.length));for(let n=0;n<o.length;++n)for(let i=0;i<r.rowCount;++i)e[i][n]=t[n][i];f.distanceFnArgs=[{}],i.push({entries:e,options:{}}),d=[y],m=[1],g="MANHATTAN"}else for(let t=0;t<c.length;++t){const e=c[t];if(f.distanceFnArgs||(f.distanceFnArgs=[]),e){const n=e.inputs[0].name,r=e.inputs[1].name,{entries:a,options:u}=await e.apply({[n]:o[t],[r]:s[t],...f.preprocessingFuncArgs[t]??{}});i.push({entries:a,options:u}),f.distanceFnArgs.push(u)}else{const e=o[t].toList(),n={};i.push({entries:e,options:n}),f.distanceFnArgs.push(n)}}e(await async function(e,r,i,o,a,s,u){let c=await async function(e,r,i,o,a,s,u){if(!s.distanceFnArgs)throw new Error("options.distanceFnArgs must be defined");if(e.length!==r.length||e.length!==s.distanceFnArgs.length||e.length!==o.length)throw new Error("data, metrics and options and weights must have the same length");return new Promise(function(c,l){const d=new Worker(new URL(n.p+n.u(234),n.b));d.postMessage({columnsData:e,distanceMetrics:r,method:i,options:s,weights:o,aggregationMethod:a});const h=t.events.onCustomEvent(Je).subscribe(()=>{try{d?.terminate()}finally{h.unsubscribe()}});d.onmessage=({data:{error:t,embedding:e,epochNum:n,epochsLength:r}})=>{Ze(n)||Ze(r)?(h.unsubscribe(),t?l(t):c(e),setTimeout(()=>d.terminate(),100)):u&&u(n,r,e)}})}(e,i,r,o,a,s,u);return c=c.map(t=>function(t){const e=t.length;let n=0,r=0;for(let i=0;i<e;++i)n+=t[i],r+=Math.pow(t[i],2);const i=n/e,o=1/Math.sqrt(r/e-Math.pow(i,2));for(let n=0;n<e;++n)t[n]=(t[n]-i)*o;return t}(t)),c}(i.map(t=>t.entries),a,d,m,l,f,p[re]?void 0:C))}catch(t){i(t)}}),S=await g;return b.close(),m.unsubscribe(),S}const _=await S();if(h&&_){const M=i.TaskBarProgressIndicator.create("Clustering embeddings ...");try{const N=await Wt(_[0],_[1],f.dbScanEpsilon??.01,f.dbScanMinPts??4),I=r.columns.getUnusedName("Cluster (DBSCAN)");r.columns.addNewString(I).init(t=>N[t].toString()),A&&(A.props.colorColumnName=I)}catch(L){t.shell.error("Clustering embeddings failed"),console.error(L)}finally{M.close()}}if(_){const P=r.columns.byName(E[0]),T=r.columns.byName(E[1]);if(P.init(t=>_[0][t]),T.init(t=>_[1][t]),m)try{const F=m.inputs[0].name,O=m.inputs[1].name;await m.prepare({[F]:P,[O]:T,...g}).call(!0)}catch(R){t.shell.error("Post-processing failed"),console.error(R)}if(A)return e.setUpdateIndicator(A.root,!1),A.helpUrl="/help/compute/sequence-space",A}}catch(x){t.shell.error("Dimensionality reduction failed"),console.error(x),b.close(),A&&e.setUpdateIndicator(A.root,!1)}};return new Promise(async(t,n)=>{try{if(p.fastRowCount&&r.rowCount>p.fastRowCount&&!p[re])e.dialog().add(e.divText("Analysis might take several minutes. Do you want to continue?")).onOK(async()=>{try{const e=await b();t(e)}catch(t){n(t)}}).onCancel(()=>t(void 0)).show();else{const e=await b();t(e)}}catch(t){n(t)}})}(o.table,o.columns,o.methodName,o.distanceMetrics,o.weights,o.preprocessingFunctions,o.aggreaggregationMethod,!!o.plotEmbeddings,!!o.clusterEmbeddings,o.options,{fastRowCount:1e4},o.postProcessingFunction,o.postProcessingFunctionArgs,o.vectorDistanceMetric))})).show();o.helpUrl="https://datagrok.ai/help/explore/dim-reduction.md";const a=()=>{const t=r.columnsInput.value,e=o.getButton("OK");e&&(t&&0!==t.length?e.classList.remove("disabled"):e.classList.add("disabled"))};o.history(()=>({editorSettings:r.getStringInput()}),t=>r.applyStringInput(t.editorSettings)),r.onColumnsChanged.subscribe(()=>{try{a()}catch(t){console.error(t)}}),a()})}static GetMCLEditor(n){try{const t=new nn;e.dialog("Markov clustering").add(t.getEditor()).onOK(()=>Nr(this,void 0,void 0,function*(){const e=t.params;return n.func.prepare({df:e.table,cols:e.columns,metrics:e.distanceMetrics,weights:e.weights,aggregationMethod:e.aggreaggregationMethod,preprocessingFuncs:e.preprocessingFunctions,preprocessingFuncArgs:e.preprocessingFuncArgs,threshold:e.threshold,maxIterations:e.maxIterations,useWebGPU:e.useWebGPU,inflate:e.inflateFactor,minClusterSize:e.minClusterSize}).call(!0)})).show().history(()=>({editorSettings:t.getStringInput()}),e=>t.applyStringInput(e.editorSettings))}catch(e){const n=e instanceof Error?e.message:e.toString(),r=e instanceof Error?e.stack:void 0;t.shell.error(`Get region editor error: ${n}`),Ir.logger.error(n,void 0,r)}}static MCLClustering(e,n,r,i,o,a,s){return Nr(this,arguments,void 0,function*(e,n,r,i,o,a,s,u=80,c=10,l=!1,d=0,h=5){var f;const p=null!==(f=t.shell.tableView(e.name))&&void 0!==f?f:t.shell.addTableView(e),m=JSON.stringify({cols:n.map(t=>t.name),metrics:r,weights:i,aggregationMethod:o,preprocessingFuncs:a.map(t=>{var e;return null!==(e=null==t?void 0:t.name)&&void 0!==e?e:null}),preprocessingFuncArgs:s,threshold:u,maxIterations:c,useWebGPU:l,inflate:d,minClusterSize:null!=h?h:5});return p.addViewer("MCL",{mclProps:m})})}static markovClusteringViewer(){return new on}static PLS(t,e,n,r,i){return Nr(this,void 0,void 0,function*(){return yield vt({table:t,features:e,predict:n,components:r,isQuadratic:!1,names:i})})}static topMenuPLS(){return Nr(this,void 0,void 0,function*(){yield wt(rt.COMPUTE_COMPONENTS)})}static MVA(){return Nr(this,void 0,void 0,function*(){yield wt(rt.PERFORM_MVA)})}static demoMultivariateAnalysis(){return Nr(this,void 0,void 0,function*(){yield function(){return mt(this,void 0,void 0,function*(){t.shell.addTableView(i.DataFrame.fromColumns([i.Column.fromStrings("model",["alfaromeo","audi","bmw","chevrolet","dodge1","dodge2","honda1","honda2","isuzu","jaguar","mazda","mercedes","mercury","mitsubishi","nissan1","nissan2","peugot","plymouth","porsche","saab","subaru","toyota1","toyota2","toyota3","toyota4","volkswagen1","volkswagen2","volvo1","volvo2","volvo3"]),i.Column.fromInt32Array("diesel",new Int32Array([0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,1,0,1,1,0,0,0,1])),i.Column.fromInt32Array("turbo",new Int32Array([0,0,0,0,1,0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,1,1])),i.Column.fromInt32Array("two.doors",new Int32Array([1,0,1,0,1,0,1,0,0,0,0,0,1,1,0,1,0,0,1,0,0,1,0,1,0,1,0,0,0,0])),i.Column.fromInt32Array("hatchback",new Int32Array([1,0,0,0,1,1,1,0,0,0,0,0,1,1,0,0,1,0,0,0,0,1,0,1,0,0,0,0,0,0])),i.Column.fromFloat32Array("wheel.base",new Float32Array([94.5,105.80000305175781,101.19999694824219,94.5,93.69999694824219,93.69999694824219,93.69999694824219,96.5,94.30000305175781,113,93.0999984741211,115.5999984741211,102.69999694824219,93.69999694824219,94.5,94.5,93.69999694824219,114.19999694824219,89.5,99.0999984741211,97.19999694824219,95.69999694824219,95.69999694824219,98.4000015258789,102.4000015258789,97.30000305175781,100.4000015258789,104.30000305175781,109.0999984741211,109.0999984741211])),i.Column.fromFloat32Array("length",new Float32Array([171.1999969482422,192.6999969482422,176.8000030517578,158.8000030517578,157.3000030517578,157.3000030517578,150,175.39999389648438,170.6999969482422,199.60000610351562,166.8000030517578,202.60000610351562,178.39999389648438,157.3000030517578,170.1999969482422,165.3000030517578,157.3000030517578,198.89999389648438,168.89999389648438,186.60000610351562,172,158.6999969482422,166.3000030517578,176.1999969482422,175.60000610351562,171.6999969482422,180.1999969482422,188.8000030517578,188.8000030517578,188.8000030517578])),i.Column.fromFloat32Array("width",new Float32Array([65.5,71.4000015258789,64.80000305175781,63.599998474121094,63.79999923706055,63.79999923706055,64,65.19999694824219,61.79999923706055,69.5999984741211,64.19999694824219,71.69999694824219,68,64.4000015258789,63.79999923706055,63.79999923706055,63.79999923706055,68.4000015258789,65,66.5,65.4000015258789,63.599998474121094,64.4000015258789,65.5999984741211,66.5,65.5,66.9000015258789,67.19999694824219,68.80000305175781,68.9000015258789])),i.Column.fromFloat32Array("height",new Float32Array([52.400001525878906,55.70000076293945,54.29999923706055,52,50.79999923706055,50.599998474121094,52.599998474121094,54.099998474121094,53.5,52.79999923706055,54.099998474121094,56.29999923706055,54.79999923706055,50.79999923706055,53.5,54.5,50.599998474121094,58.70000076293945,51.599998474121094,56.099998474121094,52.5,54.5,53,52,54.900001525878906,55.70000076293945,55.099998474121094,56.20000076293945,55.5,55.5])),i.Column.fromInt32Array("curb.weight",new Int32Array([2823,2844,2395,1909,2128,1967,1956,2304,2337,4066,1950,3770,2910,1918,2024,1951,1967,3430,2800,2695,2190,1985,2275,2551,2480,2261,2661,2912,3049,3217])),i.Column.fromInt32Array("eng.size",new Int32Array([152,136,108,90,98,90,92,110,111,258,91,183,140,92,97,97,90,152,194,121,108,92,110,146,110,97,136,141,141,145])),i.Column.fromInt32Array("horsepower",new Int32Array([154,110,101,70,102,68,76,86,78,176,68,123,175,68,69,69,68,95,207,110,82,62,56,116,73,52,110,114,160,106])),i.Column.fromInt32Array("peak.rpm",new Int32Array([5e3,5500,5800,5400,5500,5500,6e3,5800,4800,4750,5e3,4350,5e3,5500,5200,5200,5500,4150,5900,5250,4400,4800,4500,4800,4500,4800,5500,5400,5300,4800])),i.Column.fromInt32Array("symbol",new Int32Array([1,1,2,0,1,1,1,0,0,0,1,-1,1,2,1,1,1,0,3,2,0,1,0,2,-1,2,0,-2,-1,-1])),i.Column.fromInt32Array("city.mpg",new Int32Array([19,19,23,38,24,31,30,27,24,15,31,22,19,37,31,31,31,25,17,21,28,35,34,24,30,37,19,23,19,26])),i.Column.fromInt32Array("highway.mpg",new Int32Array([26,25,29,43,30,38,34,33,29,19,38,25,24,41,37,37,38,25,25,28,33,39,36,30,33,46,24,28,25,27])),i.Column.fromInt32Array("price",new Int32Array([16500,17710,16430,6575,7957,6229,7129,8845,6785,35550,7395,31600,16503,5389,7349,7299,6229,13860,37028,12170,7775,5348,7898,9989,10698,7775,13295,12940,19045,22470]))])),t.shell.windows.help.visible=!0,t.shell.windows.help.showHelp(e.markdown("# Data\nEach car has many features - patterns extraction is complicated.\n\n# Model\nPredict car price by its other features.\n\n# Try\nPress 'RUN' to perform multivariate analysis using partial least squares\n([PLS](https://en.wikipedia.org/wiki/Partial_least_squares_regression)) regression.\n\n# Essence\nThe method finds the latent factors that\n\n* capture the maximum variance in the features\n* maximize correlation with the response variable")),t.shell.windows.showContextPanel=!1,t.shell.windows.showProperties=!1,yield wt(rt.DEMO)})}()})}static trainLinearKernelSVM(t,e,n){return Nr(this,void 0,void 0,function*(){return J(yield X({gamma:n,kernel:0},t,e))})}static applyLinearKernelSVM(t,e){return Nr(this,void 0,void 0,function*(){return yield tt(t,e)})}static isApplicableLinearKernelSVM(t,e){return Nr(this,void 0,void 0,function*(){return et(t,e)})}static isInteractiveLinearKernelSVM(t,e){return Nr(this,void 0,void 0,function*(){return nt(t)})}static visualizeLinearKernelSVM(t,e,n,r){return Nr(this,void 0,void 0,function*(){return Q(0,r)})}static trainRBFkernelSVM(t,e,n,r){return Nr(this,void 0,void 0,function*(){return J(yield X({gamma:n,kernel:2,sigma:r},t,e))})}static applyRBFkernelSVM(t,e){return Nr(this,void 0,void 0,function*(){return yield tt(t,e)})}static isApplicableRBFkernelSVM(t,e){return Nr(this,void 0,void 0,function*(){return et(t,e)})}static isInteractiveRBFkernelSVM(t,e){return Nr(this,void 0,void 0,function*(){return nt(t)})}static visualizeRBFkernelSVM(t,e,n,r){return Nr(this,void 0,void 0,function*(){return Q(0,r)})}static trainPolynomialKernelSVM(t,e,n,r,i){return Nr(this,void 0,void 0,function*(){return J(yield X({gamma:n,kernel:1,cParam:r,dParam:i},t,e))})}static applyPolynomialKernelSVM(t,e){return Nr(this,void 0,void 0,function*(){return yield tt(t,e)})}static isApplicablePolynomialKernelSVM(t,e){return Nr(this,void 0,void 0,function*(){return et(t,e)})}static isInteractivePolynomialKernelSVM(t,e){return Nr(this,void 0,void 0,function*(){return nt(t)})}static visualizePolynomialKernelSVM(t,e,n,r){return Nr(this,void 0,void 0,function*(){return Q(0,r)})}static trainSigmoidKernelSVM(t,e,n,r,i){return Nr(this,void 0,void 0,function*(){return J(yield X({gamma:n,kernel:3,kappa:r,theta:i},t,e))})}static applySigmoidKernelSVM(t,e){return Nr(this,void 0,void 0,function*(){return yield tt(t,e)})}static isApplicableSigmoidKernelSVM(t,e){return Nr(this,void 0,void 0,function*(){return et(t,e)})}static isInteractiveSigmoidKernelSVM(t,e){return Nr(this,void 0,void 0,function*(){return nt(t)})}static visualizeSigmoidKernelSVM(t,e,n,r){return Nr(this,void 0,void 0,function*(){return Q(0,r)})}static anova(){Bt()}static kNNImputation(){en()}static kNNImputationForTable(t){return Nr(this,void 0,void 0,function*(){yield en(t)})}static trainLinearRegression(t,e){return Nr(this,void 0,void 0,function*(){const n=t.columns,r=yield function(t,e){return an(this,void 0,void 0,function*(){const n=t.length,r=e.length,o=e.stats.avg,a=e.stats.stdev,s=new Float32Array(n+1).fill(0);if(s[n]=o,0===a||1===r)return s;try{const r=[],u=[],c=new Float32Array(n),l=new Float32Array(n);let d=0,h=0;for(const e of t){const t=e.stats;t.stdev>0&&(r.push(d),u.push(e),c[h]=t.avg,l[h]=t.stdev,++h),++d}if(0===h)return s;const f=function(t,e,n,r,i,o,a){return g(EDA,"fitLinearRegressionParamsWithDataNormalizing",[t,e,n,r,i,o,a])}(i.DataFrame.fromColumns(u).columns,i.Column.fromFloat32Array("xAvgs",c,h),i.Column.fromFloat32Array("xStdevs",l,h),e,o,a,h+1).getRawData();for(let t=0;t<h;++t)s[r[t]]=f[t];s[n]=f[h]}catch(r){const o=yield function(t,e,n){return an(this,void 0,void 0,function*(){return(yield vt({table:i.DataFrame.fromColumns([e]),features:t,predict:e,components:n,names:void 0,isQuadratic:!1})).regressionCoefficients.getRawData()})}(t,e,un(t.length,e.length));let a=0;for(let e=0;e<n;++e)s[e]=o[e],a+=o[e]*t.byIndex(e).stats.avg;s[n]-=a}return s})}(n,e);return new Uint8Array(r.buffer)})}static applyLinearRegression(t,e){const n=t.columns,r=new Float32Array(e.buffer);return i.DataFrame.fromColumns([sn(n,r)])}static isApplicableLinearRegression(t,e){for(const e of t.columns)if(!e.matches("numerical"))return!1;return e.matches("numerical")}static isInteractiveLinearRegression(t,e){return t.rowCount<=1e5}static trainSoftmax(t,e,n,r,i,o){return Nr(this,void 0,void 0,function*(){const a=t.columns,s=new mn({classesCount:e.categories.length,featuresCount:a.length});return yield s.fit(a,e,n,r,i,o),s.toBytes()})}static applySoftmax(t,e){const n=t.columns,r=new mn(void 0,e);return i.DataFrame.fromColumns([r.predict(n)])}static isApplicableSoftmax(t,e){return mn.isApplicable(t.columns,e)}static isInteractiveSoftmax(t,e){return mn.isInteractive(t.columns,e)}static trainPLSRegression(t,e,n){return Nr(this,void 0,void 0,function*(){const r=t.columns,i=new ln;return yield i.fit(r,e,Math.min(n,r.length)),i.toBytes()})}static applyPLSRegression(t,e){const n=new ln(e);return i.DataFrame.fromColumns([n.predict(t.columns)])}static isApplicablePLSRegression(t,e){return ln.isApplicable(t.columns,e)}static visualizePLSRegression(t,e,n,r){return Nr(this,void 0,void 0,function*(){return new ln(r).viewers().map(t=>t.root)})}static isInteractivePLSRegression(t,e){return ln.isInteractive(t.columns,e)}static trainXGBooster(t,e,n,r,i,o,a){return Nr(this,void 0,void 0,function*(){const s=t.columns,u=new An;return yield u.fit(s,e,n,r,i,o,a),u.toBytes()})}static applyXGBooster(t,e){const n=new An(e);return i.DataFrame.fromColumns([n.predict(t.columns)])}static isInteractiveXGBooster(t,e){return An.isInteractive(t.columns,e)}static isApplicableXGBooster(t,e){return An.isApplicable(t.columns,e)}}Sr([t.decorators.func({name:"info"}),_r("design:type",Function),_r("design:paramtypes",[]),_r("design:returntype",void 0)],Lr,"info",null),Sr([t.decorators.init({}),_r("design:type",Function),_r("design:paramtypes",[]),_r("design:returntype",Promise)],Lr,"init",null),Sr([t.decorators.func({"top-menu":"ML | Cluster | DBSCAN...",name:"DBSCAN",description:"Density-based spatial clustering of applications with noise (DBSCAN)"}),Mr(1,t.decorators.param({type:"column",options:{type:"numerical"}})),Mr(2,t.decorators.param({type:"column",options:{type:"numerical"}})),Mr(3,t.decorators.param({options:{caption:"Epsilon",initialValue:"0.02",description:"The maximum distance between two samples for them to be considered as in the same neighborhood."}})),Mr(4,t.decorators.param({type:"int",options:{caption:"Minimum points",initialValue:"4",description:"The number of samples (or total weight) in a neighborhood for a point to be considered as a core point."}})),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column,i.Column,Number,Number]),_r("design:returntype",Promise)],Lr,"dbScan",null),Sr([t.decorators.func({"top-menu":"ML | Analyze | PCA...",description:"Principal component analysis (PCA)",helpUrl:"/help/explore/dim-reduction#pca"}),Mr(0,t.decorators.param({type:"dataframe",options:{caption:"Table"}})),Mr(1,t.decorators.param({type:"column_list",options:{type:"numerical",nullable:!1}})),Mr(2,t.decorators.param({type:"int",options:{showPlusMinus:!0,caption:"Components",nullable:!1,min:"1",initialValue:"2",description:"Number of components."}})),Mr(3,t.decorators.param({type:"bool",options:{caption:"Center",initialValue:"false",description:"Indicating whether the variables should be shifted to be zero centered."}})),Mr(4,t.decorators.param({type:"bool",options:{caption:"Scale",initialValue:"false",description:"Indicating whether the variables should be scaled to have unit variance."}})),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.ColumnList,Number,Boolean,Boolean]),_r("design:returntype",Promise)],Lr,"PCA",null),Sr([t.decorators.func({meta:{defaultPostProcessingFunction:"true"},tags:["dim-red-postprocessing-function"],name:"DBSCAN clustering"}),Mr(2,t.decorators.param({options:{initialValue:"0.01",description:"Minimum distance between two points to be considered as in the same neighborhood."}})),Mr(3,t.decorators.param({type:"int",options:{initialValue:"5",description:"Minimum number of points to form a dense region."}})),_r("design:type",Function),_r("design:paramtypes",[i.Column,i.Column,Number,Number]),_r("design:returntype",Promise)],Lr,"dbscanPostProcessingFunction",null),Sr([t.decorators.func({meta:{supportedTypes:"int,float,double,qnum",supportedDistanceFunctions:"Difference"},tags:["dim-red-preprocessing-function"],name:"None (number)",outputs:[{name:"result",type:"object"}]}),Mr(1,t.decorators.param({options:{optional:!0}})),_r("design:type",Function),_r("design:paramtypes",[i.Column,String]),_r("design:returntype",void 0)],Lr,"numberPreprocessingFunction",null),Sr([t.decorators.func({meta:{supportedTypes:"string",supportedDistanceFunctions:"One-Hot,Levenshtein,Hamming"},tags:["dim-red-preprocessing-function"],name:"None (string)",outputs:[{name:"result",type:"object"}]}),Mr(1,t.decorators.param({options:{optional:!0}})),_r("design:type",Function),_r("design:paramtypes",[i.Column,String]),_r("design:returntype",void 0)],Lr,"stringPreprocessingFunction",null),Sr([t.decorators.func({"top-menu":"ML | Reduce Dimensionality...",name:"Multi Column Dimensionality Reduction"}),_r("design:type",Function),_r("design:paramtypes",[]),_r("design:returntype",Promise)],Lr,"reduceDimensionality",null),Sr([t.decorators.editor(),_r("design:type",Function),_r("design:paramtypes",[i.FuncCall]),_r("design:returntype",void 0)],Lr,"GetMCLEditor",null),Sr([t.decorators.func({"top-menu":"ML | Cluster | MCL...",name:"MCLClustering",description:"Markov clustering (MCL) is an unsupervised clustering algorithm for graphs based on simulation of stochastic flow.",editor:"EDA:GetMCLEditor",outputs:[]}),Mr(2,t.decorators.param({type:"list<string>"})),Mr(4,t.decorators.param({type:"string"})),Mr(5,t.decorators.param({type:"list<func>"})),Mr(6,t.decorators.param({type:"object"})),Mr(7,t.decorators.param({type:"int",options:{initialValue:"80"}})),Mr(8,t.decorators.param({type:"int",options:{initialValue:"10"}})),Mr(9,t.decorators.param({type:"bool",options:{initialValue:"false"}})),Mr(10,t.decorators.param({type:"double",options:{initialValue:"2"}})),Mr(11,t.decorators.param({type:"int",options:{initialValue:"5"}})),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,Array,Array,Array,String,Array,Array,Number,Number,Boolean,Number,Number]),_r("design:returntype",Promise)],Lr,"MCLClustering",null),Sr([t.decorators.func({outputs:[{name:"result",type:"viewer"}],tags:["viewer"],name:"MCL",description:"Markov clustering viewer"}),_r("design:type",Function),_r("design:paramtypes",[]),_r("design:returntype",on)],Lr,"markovClusteringViewer",null),Sr([t.decorators.func({outputs:[{name:"plsResults",type:"object"}],description:"Compute partial least squares (PLS) regression analysis components: prediction, regression coefficients, T- & U-scores, X-loadings."}),Mr(1,t.decorators.param({type:"column_list",options:{type:"numerical"}})),Mr(2,t.decorators.param({type:"column",options:{type:"numerical"}})),Mr(3,t.decorators.param({type:"int",options:{initialValue:"3"}})),Mr(4,t.decorators.param({type:"column",options:{type:"string"}})),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.ColumnList,i.Column,Number,i.Column]),_r("design:returntype",Promise)],Lr,"PLS",null),Sr([t.decorators.func({"top-menu":"ML | Analyze | PLS...",description:"Compute partial least squares (PLS) regression components. They maximally summarize the variation of the predictors while maximizing correlation with the response variable."}),_r("design:type",Function),_r("design:paramtypes",[]),_r("design:returntype",Promise)],Lr,"topMenuPLS",null),Sr([t.decorators.func({"top-menu":"ML | Analyze | Multivariate Analysis...",name:"multivariateAnalysis",description:"Multidimensional data analysis using partial least squares (PLS) regression."}),_r("design:type",Function),_r("design:paramtypes",[]),_r("design:returntype",Promise)],Lr,"MVA",null),Sr([t.decorators.func({meta:{demoPath:"Compute | Multivariate Analysis"},name:"MVA demo",description:"Multidimensional data analysis using partial least squares (PLS) regression. It identifies latent factors and constructs a linear model based on them."}),_r("design:type",Function),_r("design:paramtypes",[]),_r("design:returntype",Promise)],Lr,"demoMultivariateAnalysis",null),Sr([t.decorators.func({meta:{mlname:"linear kernel LS-SVM",mlrole:"train"}}),Mr(2,t.decorators.param({options:{category:"Hyperparameters",initialValue:"1.0"}})),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column,Number]),_r("design:returntype",Promise)],Lr,"trainLinearKernelSVM",null),Sr([t.decorators.func({meta:{mlname:"linear kernel LS-SVM",mlrole:"apply"}}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,Object]),_r("design:returntype",Promise)],Lr,"applyLinearKernelSVM",null),Sr([t.decorators.func({meta:{mlname:"linear kernel LS-SVM",mlrole:"isApplicable"}}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column]),_r("design:returntype",Promise)],Lr,"isApplicableLinearKernelSVM",null),Sr([t.decorators.func({meta:{mlname:"linear kernel LS-SVM",mlrole:"isInteractive"}}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column]),_r("design:returntype",Promise)],Lr,"isInteractiveLinearKernelSVM",null),Sr([t.decorators.func({meta:{mlname:"linear kernel LS-SVM",mlrole:"visualize"}}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column,i.Column,Object]),_r("design:returntype",Promise)],Lr,"visualizeLinearKernelSVM",null),Sr([t.decorators.func({meta:{mlname:"RBF-kernel LS-SVM",mlrole:"train"}}),Mr(2,t.decorators.param({options:{category:"Hyperparameters",initialValue:"1.0"}})),Mr(3,t.decorators.param({options:{category:"Hyperparameters",initialValue:"1.5"}})),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column,Number,Number]),_r("design:returntype",Promise)],Lr,"trainRBFkernelSVM",null),Sr([t.decorators.func({meta:{mlname:"RBF-kernel LS-SVM",mlrole:"apply"}}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,Object]),_r("design:returntype",Promise)],Lr,"applyRBFkernelSVM",null),Sr([t.decorators.func({meta:{mlname:"RBF-kernel LS-SVM",mlrole:"isApplicable"}}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column]),_r("design:returntype",Promise)],Lr,"isApplicableRBFkernelSVM",null),Sr([t.decorators.func({meta:{mlname:"RBF-kernel LS-SVM",mlrole:"isInteractive"}}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column]),_r("design:returntype",Promise)],Lr,"isInteractiveRBFkernelSVM",null),Sr([t.decorators.func({meta:{mlname:"RBF-kernel LS-SVM",mlrole:"visualize"}}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column,i.Column,Object]),_r("design:returntype",Promise)],Lr,"visualizeRBFkernelSVM",null),Sr([t.decorators.func({meta:{mlname:"polynomial kernel LS-SVM",mlrole:"train"}}),Mr(2,t.decorators.param({options:{category:"Hyperparameters",initialValue:"1.0"}})),Mr(3,t.decorators.param({options:{category:"Hyperparameters",initialValue:"1"}})),Mr(4,t.decorators.param({options:{category:"Hyperparameters",initialValue:"2"}})),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column,Number,Number,Number]),_r("design:returntype",Promise)],Lr,"trainPolynomialKernelSVM",null),Sr([t.decorators.func({meta:{mlname:"polynomial kernel LS-SVM",mlrole:"apply"}}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,Object]),_r("design:returntype",Promise)],Lr,"applyPolynomialKernelSVM",null),Sr([t.decorators.func({meta:{mlname:"polynomial kernel LS-SVM",mlrole:"isApplicable"}}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column]),_r("design:returntype",Promise)],Lr,"isApplicablePolynomialKernelSVM",null),Sr([t.decorators.func({meta:{mlname:"polynomial kernel LS-SVM",mlrole:"isInteractive"}}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column]),_r("design:returntype",Promise)],Lr,"isInteractivePolynomialKernelSVM",null),Sr([t.decorators.func({meta:{mlname:"polynomial kernel LS-SVM",mlrole:"visualize"},outputs:[{name:"widget",type:"dynamic"}],name:"visualizePolynomialKernelSVM"}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column,i.Column,Object]),_r("design:returntype",Promise)],Lr,"visualizePolynomialKernelSVM",null),Sr([t.decorators.func({meta:{mlname:"sigmoid kernel LS-SVM",mlrole:"train"},name:"trainSigmoidKernelSVM"}),Mr(2,t.decorators.param({options:{category:"Hyperparameters",initialValue:"1.0"}})),Mr(3,t.decorators.param({options:{category:"Hyperparameters",initialValue:"1"}})),Mr(4,t.decorators.param({options:{category:"Hyperparameters",initialValue:"1"}})),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column,Number,Number,Number]),_r("design:returntype",Promise)],Lr,"trainSigmoidKernelSVM",null),Sr([t.decorators.func({meta:{mlname:"sigmoid kernel LS-SVM",mlrole:"apply"},name:"applySigmoidKernelSVM"}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,Object]),_r("design:returntype",Promise)],Lr,"applySigmoidKernelSVM",null),Sr([t.decorators.func({meta:{mlname:"sigmoid kernel LS-SVM",mlrole:"isApplicable"},name:"isApplicableSigmoidKernelSVM"}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column]),_r("design:returntype",Promise)],Lr,"isApplicableSigmoidKernelSVM",null),Sr([t.decorators.func({meta:{mlname:"sigmoid kernel LS-SVM",mlrole:"isInteractive"},name:"isInteractiveSigmoidKernelSVM"}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column]),_r("design:returntype",Promise)],Lr,"isInteractiveSigmoidKernelSVM",null),Sr([t.decorators.func({meta:{mlname:"sigmoid kernel LS-SVM",mlrole:"visualize"},name:"visualizeSigmoidKernelSVM"}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column,i.Column,Object]),_r("design:returntype",Promise)],Lr,"visualizeSigmoidKernelSVM",null),Sr([t.decorators.func({"top-menu":"ML | Analyze | ANOVA...",name:"ANOVA",description:"One-way analysis of variances (ANOVA) determines whether the examined factor has a significant impact on the explored feature."}),_r("design:type",Function),_r("design:paramtypes",[]),_r("design:returntype",void 0)],Lr,"anova",null),Sr([t.decorators.func({"top-menu":"ML | Impute Missing Values...",name:"KNN impute",description:"Missing values imputation using the k-nearest neighbors method (KNN)"}),_r("design:type",Function),_r("design:paramtypes",[]),_r("design:returntype",void 0)],Lr,"kNNImputation",null),Sr([t.decorators.func({name:"KNN imputation for a table",description:"Missing values imputation using the k-nearest neighbors method"}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame]),_r("design:returntype",Promise)],Lr,"kNNImputationForTable",null),Sr([t.decorators.func({meta:{mlname:"Linear Regression",mlrole:"train"},name:"trainLinearRegression",outputs:[{type:"dynamic",name:"model"}]}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column]),_r("design:returntype",Promise)],Lr,"trainLinearRegression",null),Sr([t.decorators.func({meta:{mlname:"Linear Regression",mlrole:"apply"},name:"applyLinearRegression"}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,Object]),_r("design:returntype",i.DataFrame)],Lr,"applyLinearRegression",null),Sr([t.decorators.func({meta:{mlname:"Linear Regression",mlrole:"isApplicable"},name:"isApplicableLinearRegression"}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column]),_r("design:returntype",Boolean)],Lr,"isApplicableLinearRegression",null),Sr([t.decorators.func({meta:{mlname:"Linear Regression",mlrole:"isInteractive"},name:"isInteractiveLinearRegression"}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column]),_r("design:returntype",Boolean)],Lr,"isInteractiveLinearRegression",null),Sr([t.decorators.func({meta:{mlname:"Softmax",mlrole:"train"},name:"trainSoftmax",outputs:[{type:"dynamic",name:"model"}]}),Mr(2,t.decorators.param({options:{category:"Hyperparameters",initialValue:"1.0",min:"0.001",max:"20",description:"Learning rate."}})),Mr(3,t.decorators.param({options:{category:"Hyperparameters",initialValue:"100",min:"1",max:"10000",step:"10",description:"Fitting iterations count"}})),Mr(4,t.decorators.param({options:{category:"Hyperparameters",initialValue:"0.1",min:"0.0001",max:"1",description:"Regularization rate."}})),Mr(5,t.decorators.param({options:{category:"Hyperparameters",initialValue:"0.001",min:"0.00001",max:"0.1",description:"Fitting tolerance."}})),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column,Number,Number,Number,Number]),_r("design:returntype",Promise)],Lr,"trainSoftmax",null),Sr([t.decorators.func({meta:{mlname:"Softmax",mlrole:"apply"},name:"applySoftmax"}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,Object]),_r("design:returntype",i.DataFrame)],Lr,"applySoftmax",null),Sr([t.decorators.func({meta:{mlname:"Softmax",mlrole:"isApplicable"},name:"isApplicableSoftmax"}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column]),_r("design:returntype",Boolean)],Lr,"isApplicableSoftmax",null),Sr([t.decorators.func({meta:{mlname:"Softmax",mlrole:"isInteractive"},name:"isInteractiveSoftmax"}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column]),_r("design:returntype",Boolean)],Lr,"isInteractiveSoftmax",null),Sr([t.decorators.func({meta:{mlname:"PLS Regression",mlrole:"train"},name:"trainPLSRegression",outputs:[{name:"model",type:"dynamic"}]}),Mr(2,t.decorators.param({type:"int",options:{min:"1",max:"10",initialValue:"3",description:"Number of latent components."}})),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column,Number]),_r("design:returntype",Promise)],Lr,"trainPLSRegression",null),Sr([t.decorators.func({meta:{mlname:"PLS Regression",mlrole:"apply"},name:"applyPLSRegression"}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,Object]),_r("design:returntype",i.DataFrame)],Lr,"applyPLSRegression",null),Sr([t.decorators.func({meta:{mlname:"PLS Regression",mlrole:"isApplicable"},name:"isApplicablePLSRegression"}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column]),_r("design:returntype",Boolean)],Lr,"isApplicablePLSRegression",null),Sr([t.decorators.func({meta:{mlname:"PLS Regression",mlrole:"visualize"},name:"visualizePLSRegression"}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column,i.Column,Object]),_r("design:returntype",Promise)],Lr,"visualizePLSRegression",null),Sr([t.decorators.func({meta:{mlname:"PLS Regression",mlrole:"isInteractive"},name:"isInteractivePLSRegression"}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column]),_r("design:returntype",Boolean)],Lr,"isInteractivePLSRegression",null),Sr([t.decorators.func({meta:{mlname:"XGBoost",mlrole:"train"},name:"trainXGBooster",outputs:[{name:"model",type:"dynamic"}]}),Mr(2,t.decorators.param({type:"int",options:{min:"1",max:"100",initialValue:"20",description:"Number of training iterations."}})),Mr(3,t.decorators.param({type:"double",options:{caption:"Rate",min:"0",max:"1",initialValue:"0.3",description:"Learning rate."}})),Mr(4,t.decorators.param({type:"int",options:{min:"0",max:"20",initialValue:"6",description:"Maximum depth of a tree."}})),Mr(5,t.decorators.param({type:"double",options:{min:"0",max:"100",initialValue:"1",description:"L2 regularization term."}})),Mr(6,t.decorators.param({type:"double",options:{min:"0",max:"100",initialValue:"0",description:"L1 regularization term."}})),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column,Number,Number,Number,Number,Number]),_r("design:returntype",Promise)],Lr,"trainXGBooster",null),Sr([t.decorators.func({meta:{mlname:"XGBoost",mlrole:"apply"},name:"applyXGBooster"}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,Object]),_r("design:returntype",i.DataFrame)],Lr,"applyXGBooster",null),Sr([t.decorators.func({meta:{mlname:"XGBoost",mlrole:"isInteractive"},name:"isInteractiveXGBooster"}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column]),_r("design:returntype",Boolean)],Lr,"isInteractiveXGBooster",null),Sr([t.decorators.func({meta:{mlname:"XGBoost",mlrole:"isApplicable"},name:"isApplicableXGBooster"}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column]),_r("design:returntype",Boolean)],Lr,"isApplicableXGBooster",null)})(),eda=r})();
|
|
1
|
+
var eda;(()=>{var t={540:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},934:function(t){t.exports=function(){"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}function e(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,r(t,e)}function n(t){return n=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},n(t)}function r(t,e){return r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},r(t,e)}function i(t,e,n){return i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,n){var i=[null];i.push.apply(i,e);var o=new(Function.bind.apply(t,i));return n&&r(o,n.prototype),o},i.apply(null,arguments)}function o(t){var e="function"==typeof Map?new Map:void 0;return o=function(t){if(null===t||(o=t,-1===Function.toString.call(o).indexOf("[native code]")))return t;var o;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,a)}function a(){return i(t,arguments,n(this).constructor)}return a.prototype=Object.create(t.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),r(a,t)},o(t)}function a(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var s=function(){for(var t=arguments[0],e=1,n=arguments.length;e<n;e++)if(arguments[e])for(var r in arguments[e])t[r]=arguments[e][r];return t};function u(t,e,n,r){var i=t._nodes.get(e),o=null;return i?o="mixed"===r?i.out&&i.out[n]||i.undirected&&i.undirected[n]:"directed"===r?i.out&&i.out[n]:i.undirected&&i.undirected[n]:o}function c(e){return"object"===t(e)&&null!==e}function l(t){var e;for(e in t)return!1;return!0}function d(t,e,n){Object.defineProperty(t,e,{enumerable:!1,configurable:!1,writable:!0,value:n})}function h(t,e,n){var r={enumerable:!0,configurable:!0};"function"==typeof n?r.get=n:(r.value=n,r.writable=!1),Object.defineProperty(t,e,r)}function f(t){return!(!c(t)||t.attributes&&!Array.isArray(t.attributes))}"function"==typeof Object.assign&&(s=Object.assign);var p,m={exports:{}},g="object"==typeof Reflect?Reflect:null,y=g&&"function"==typeof g.apply?g.apply:function(t,e,n){return Function.prototype.apply.call(t,e,n)};p=g&&"function"==typeof g.ownKeys?g.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var v=Number.isNaN||function(t){return t!=t};function w(){w.init.call(this)}m.exports=w,m.exports.once=function(t,e){return new Promise(function(n,r){function i(n){t.removeListener(e,o),r(n)}function o(){"function"==typeof t.removeListener&&t.removeListener("error",i),n([].slice.call(arguments))}L(t,e,o,{once:!0}),"error"!==e&&function(t,e){"function"==typeof t.on&&L(t,"error",e,{once:!0})}(t,i)})},w.EventEmitter=w,w.prototype._events=void 0,w.prototype._eventsCount=0,w.prototype._maxListeners=void 0;var b=10;function A(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function E(t){return void 0===t._maxListeners?w.defaultMaxListeners:t._maxListeners}function C(t,e,n,r){var i,o,a,s;if(A(n),void 0===(o=t._events)?(o=t._events=Object.create(null),t._eventsCount=0):(void 0!==o.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),o=t._events),a=o[e]),void 0===a)a=o[e]=n,++t._eventsCount;else if("function"==typeof a?a=o[e]=r?[n,a]:[a,n]:r?a.unshift(n):a.push(n),(i=E(t))>0&&a.length>i&&!a.warned){a.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=a.length,s=u,console&&console.warn&&console.warn(s)}return t}function S(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function _(t,e,n){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},i=S.bind(r);return i.listener=n,r.wrapFn=i,i}function M(t,e,n){var r=t._events;if(void 0===r)return[];var i=r[e];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(t){for(var e=new Array(t.length),n=0;n<e.length;++n)e[n]=t[n].listener||t[n];return e}(i):I(i,i.length)}function N(t){var e=this._events;if(void 0!==e){var n=e[t];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function I(t,e){for(var n=new Array(e),r=0;r<e;++r)n[r]=t[r];return n}function L(t,e,n,r){if("function"==typeof t.on)r.once?t.once(e,n):t.on(e,n);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,function i(o){r.once&&t.removeEventListener(e,i),n(o)})}}function P(t){if("function"!=typeof t)throw new Error("obliterator/iterator: expecting a function!");this.next=t}Object.defineProperty(w,"defaultMaxListeners",{enumerable:!0,get:function(){return b},set:function(t){if("number"!=typeof t||t<0||v(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");b=t}}),w.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},w.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||v(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},w.prototype.getMaxListeners=function(){return E(this)},w.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++)e.push(arguments[n]);var r="error"===t,i=this._events;if(void 0!==i)r=r&&void 0===i.error;else if(!r)return!1;if(r){var o;if(e.length>0&&(o=e[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var s=i[t];if(void 0===s)return!1;if("function"==typeof s)y(s,this,e);else{var u=s.length,c=I(s,u);for(n=0;n<u;++n)y(c[n],this,e)}return!0},w.prototype.addListener=function(t,e){return C(this,t,e,!1)},w.prototype.on=w.prototype.addListener,w.prototype.prependListener=function(t,e){return C(this,t,e,!0)},w.prototype.once=function(t,e){return A(e),this.on(t,_(this,t,e)),this},w.prototype.prependOnceListener=function(t,e){return A(e),this.prependListener(t,_(this,t,e)),this},w.prototype.removeListener=function(t,e){var n,r,i,o,a;if(A(e),void 0===(r=this._events))return this;if(void 0===(n=r[t]))return this;if(n===e||n.listener===e)0==--this._eventsCount?this._events=Object.create(null):(delete r[t],r.removeListener&&this.emit("removeListener",t,n.listener||e));else if("function"!=typeof n){for(i=-1,o=n.length-1;o>=0;o--)if(n[o]===e||n[o].listener===e){a=n[o].listener,i=o;break}if(i<0)return this;0===i?n.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(n,i),1===n.length&&(r[t]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",t,a||e)}return this},w.prototype.off=w.prototype.removeListener,w.prototype.removeAllListeners=function(t){var e,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[t]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[t]),this;if(0===arguments.length){var i,o=Object.keys(n);for(r=0;r<o.length;++r)"removeListener"!==(i=o[r])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=n[t]))this.removeListener(t,e);else if(void 0!==e)for(r=e.length-1;r>=0;r--)this.removeListener(t,e[r]);return this},w.prototype.listeners=function(t){return M(this,t,!0)},w.prototype.rawListeners=function(t){return M(this,t,!1)},w.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):N.call(t,e)},w.prototype.listenerCount=N,w.prototype.eventNames=function(){return this._eventsCount>0?p(this._events):[]},"undefined"!=typeof Symbol&&(P.prototype[Symbol.iterator]=function(){return this}),P.of=function(){var t=arguments,e=t.length,n=0;return new P(function(){return n>=e?{done:!0}:{done:!1,value:t[n++]}})},P.empty=function(){return new P(function(){return{done:!0}})},P.fromSequence=function(t){var e=0,n=t.length;return new P(function(){return e>=n?{done:!0}:{done:!1,value:t[e++]}})},P.is=function(t){return t instanceof P||"object"==typeof t&&null!==t&&"function"==typeof t.next};var T=P,F={};F.ARRAY_BUFFER_SUPPORT="undefined"!=typeof ArrayBuffer,F.SYMBOL_SUPPORT="undefined"!=typeof Symbol;var O=T,R=F,x=R.ARRAY_BUFFER_SUPPORT,D=R.SYMBOL_SUPPORT,k=function(t){var e=function(t){return"string"==typeof t||Array.isArray(t)||x&&ArrayBuffer.isView(t)?O.fromSequence(t):"object"!=typeof t||null===t?null:D&&"function"==typeof t[Symbol.iterator]?t[Symbol.iterator]():"function"==typeof t.next?t:null}(t);if(!e)throw new Error("obliterator: target is not iterable nor a valid iterator.");return e},U=k,G=function(t,e){for(var n,r=arguments.length>1?e:1/0,i=r!==1/0?new Array(r):[],o=0,a=U(t);;){if(o===r)return i;if((n=a.next()).done)return o!==e&&(i.length=o),i;i[o++]=n.value}},V=function(t){function n(e){var n;return(n=t.call(this)||this).name="GraphError",n.message=e,n}return e(n,t),n}(o(Error)),B=function(t){function n(e){var r;return(r=t.call(this,e)||this).name="InvalidArgumentsGraphError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(a(r),n.prototype.constructor),r}return e(n,t),n}(V),W=function(t){function n(e){var r;return(r=t.call(this,e)||this).name="NotFoundGraphError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(a(r),n.prototype.constructor),r}return e(n,t),n}(V),z=function(t){function n(e){var r;return(r=t.call(this,e)||this).name="UsageGraphError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(a(r),n.prototype.constructor),r}return e(n,t),n}(V);function H(t,e){this.key=t,this.attributes=e,this.clear()}function j(t,e){this.key=t,this.attributes=e,this.clear()}function K(t,e){this.key=t,this.attributes=e,this.clear()}function q(t,e,n,r,i){this.key=e,this.attributes=i,this.undirected=t,this.source=n,this.target=r}function Y(t,e,n,r,i,o,a){var s,u,c,l;if(r=""+r,0===n){if(!(s=t._nodes.get(r)))throw new W("Graph.".concat(e,': could not find the "').concat(r,'" node in the graph.'));c=i,l=o}else if(3===n){if(i=""+i,!(u=t._edges.get(i)))throw new W("Graph.".concat(e,': could not find the "').concat(i,'" edge in the graph.'));var d=u.source.key,h=u.target.key;if(r===d)s=u.target;else{if(r!==h)throw new W("Graph.".concat(e,': the "').concat(r,'" node is not attached to the "').concat(i,'" edge (').concat(d,", ").concat(h,")."));s=u.source}c=o,l=a}else{if(!(u=t._edges.get(r)))throw new W("Graph.".concat(e,': could not find the "').concat(r,'" edge in the graph.'));s=1===n?u.source:u.target,c=i,l=o}return[s,c,l]}H.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}},j.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}},K.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}},q.prototype.attach=function(){var t="out",e="in";this.undirected&&(t=e="undirected");var n=this.source.key,r=this.target.key;this.source[t][r]=this,this.undirected&&n===r||(this.target[e][n]=this)},q.prototype.attachMulti=function(){var t="out",e="in",n=this.source.key,r=this.target.key;this.undirected&&(t=e="undirected");var i=this.source[t],o=i[r];if(void 0===o)return i[r]=this,void(this.undirected&&n===r||(this.target[e][n]=this));o.previous=this,this.next=o,i[r]=this,this.target[e][n]=this},q.prototype.detach=function(){var t=this.source.key,e=this.target.key,n="out",r="in";this.undirected&&(n=r="undirected"),delete this.source[n][e],delete this.target[r][t]},q.prototype.detachMulti=function(){var t=this.source.key,e=this.target.key,n="out",r="in";this.undirected&&(n=r="undirected"),void 0===this.previous?void 0===this.next?(delete this.source[n][e],delete this.target[r][t]):(this.next.previous=void 0,this.source[n][e]=this.next,this.target[r][t]=this.next):(this.previous.next=this.next,void 0!==this.next&&(this.next.previous=this.previous))};var $=[{name:function(t){return"get".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,r,i){var o=Y(this,e,n,t,r,i),a=o[0],s=o[1];return a.attributes[s]}}},{name:function(t){return"get".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,r){return Y(this,e,n,t,r)[0].attributes}}},{name:function(t){return"has".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,r,i){var o=Y(this,e,n,t,r,i),a=o[0],s=o[1];return a.attributes.hasOwnProperty(s)}}},{name:function(t){return"set".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,r,i,o){var a=Y(this,e,n,t,r,i,o),s=a[0],u=a[1],c=a[2];return s.attributes[u]=c,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:u}),this}}},{name:function(t){return"update".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,r,i,o){var a=Y(this,e,n,t,r,i,o),s=a[0],u=a[1],c=a[2];if("function"!=typeof c)throw new B("Graph.".concat(e,": updater should be a function."));var l=s.attributes,d=c(l[u]);return l[u]=d,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:u}),this}}},{name:function(t){return"remove".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,r,i){var o=Y(this,e,n,t,r,i),a=o[0],s=o[1];return delete a.attributes[s],this.emit("nodeAttributesUpdated",{key:a.key,type:"remove",attributes:a.attributes,name:s}),this}}},{name:function(t){return"replace".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,r,i){var o=Y(this,e,n,t,r,i),a=o[0],s=o[1];if(!c(s))throw new B("Graph.".concat(e,": provided attributes are not a plain object."));return a.attributes=s,this.emit("nodeAttributesUpdated",{key:a.key,type:"replace",attributes:a.attributes}),this}}},{name:function(t){return"merge".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,r,i){var o=Y(this,e,n,t,r,i),a=o[0],u=o[1];if(!c(u))throw new B("Graph.".concat(e,": provided attributes are not a plain object."));return s(a.attributes,u),this.emit("nodeAttributesUpdated",{key:a.key,type:"merge",attributes:a.attributes,data:u}),this}}},{name:function(t){return"update".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,r,i){var o=Y(this,e,n,t,r,i),a=o[0],s=o[1];if("function"!=typeof s)throw new B("Graph.".concat(e,": provided updater is not a function."));return a.attributes=s(a.attributes),this.emit("nodeAttributesUpdated",{key:a.key,type:"update",attributes:a.attributes}),this}}}],X=[{name:function(t){return"get".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,r){var i;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new z("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new z("Graph.".concat(e,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var o=""+t,a=""+r;if(r=arguments[2],!(i=u(this,o,a,n)))throw new W("Graph.".concat(e,': could not find an edge for the given path ("').concat(o,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new z("Graph.".concat(e,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(t=""+t,!(i=this._edges.get(t)))throw new W("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}return i.attributes[r]}}},{name:function(t){return"get".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t){var r;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new z("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>1){if(this.multi)throw new z("Graph.".concat(e,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var i=""+t,o=""+arguments[1];if(!(r=u(this,i,o,n)))throw new W("Graph.".concat(e,': could not find an edge for the given path ("').concat(i,'" - "').concat(o,'").'))}else{if("mixed"!==n)throw new z("Graph.".concat(e,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(t=""+t,!(r=this._edges.get(t)))throw new W("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}return r.attributes}}},{name:function(t){return"has".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,r){var i;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new z("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new z("Graph.".concat(e,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var o=""+t,a=""+r;if(r=arguments[2],!(i=u(this,o,a,n)))throw new W("Graph.".concat(e,': could not find an edge for the given path ("').concat(o,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new z("Graph.".concat(e,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(t=""+t,!(i=this._edges.get(t)))throw new W("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}return i.attributes.hasOwnProperty(r)}}},{name:function(t){return"set".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,r,i){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new z("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>3){if(this.multi)throw new z("Graph.".concat(e,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var a=""+t,s=""+r;if(r=arguments[2],i=arguments[3],!(o=u(this,a,s,n)))throw new W("Graph.".concat(e,': could not find an edge for the given path ("').concat(a,'" - "').concat(s,'").'))}else{if("mixed"!==n)throw new z("Graph.".concat(e,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(t=""+t,!(o=this._edges.get(t)))throw new W("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}return o.attributes[r]=i,this.emit("edgeAttributesUpdated",{key:o.key,type:"set",attributes:o.attributes,name:r}),this}}},{name:function(t){return"update".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,r,i){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new z("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>3){if(this.multi)throw new z("Graph.".concat(e,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var a=""+t,s=""+r;if(r=arguments[2],i=arguments[3],!(o=u(this,a,s,n)))throw new W("Graph.".concat(e,': could not find an edge for the given path ("').concat(a,'" - "').concat(s,'").'))}else{if("mixed"!==n)throw new z("Graph.".concat(e,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(t=""+t,!(o=this._edges.get(t)))throw new W("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}if("function"!=typeof i)throw new B("Graph.".concat(e,": updater should be a function."));return o.attributes[r]=i(o.attributes[r]),this.emit("edgeAttributesUpdated",{key:o.key,type:"set",attributes:o.attributes,name:r}),this}}},{name:function(t){return"remove".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,r){var i;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new z("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new z("Graph.".concat(e,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var o=""+t,a=""+r;if(r=arguments[2],!(i=u(this,o,a,n)))throw new W("Graph.".concat(e,': could not find an edge for the given path ("').concat(o,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new z("Graph.".concat(e,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(t=""+t,!(i=this._edges.get(t)))throw new W("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}return delete i.attributes[r],this.emit("edgeAttributesUpdated",{key:i.key,type:"remove",attributes:i.attributes,name:r}),this}}},{name:function(t){return"replace".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,r){var i;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new z("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new z("Graph.".concat(e,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var o=""+t,a=""+r;if(r=arguments[2],!(i=u(this,o,a,n)))throw new W("Graph.".concat(e,': could not find an edge for the given path ("').concat(o,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new z("Graph.".concat(e,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(t=""+t,!(i=this._edges.get(t)))throw new W("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}if(!c(r))throw new B("Graph.".concat(e,": provided attributes are not a plain object."));return i.attributes=r,this.emit("edgeAttributesUpdated",{key:i.key,type:"replace",attributes:i.attributes}),this}}},{name:function(t){return"merge".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,r){var i;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new z("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new z("Graph.".concat(e,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var o=""+t,a=""+r;if(r=arguments[2],!(i=u(this,o,a,n)))throw new W("Graph.".concat(e,': could not find an edge for the given path ("').concat(o,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new z("Graph.".concat(e,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(t=""+t,!(i=this._edges.get(t)))throw new W("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}if(!c(r))throw new B("Graph.".concat(e,": provided attributes are not a plain object."));return s(i.attributes,r),this.emit("edgeAttributesUpdated",{key:i.key,type:"merge",attributes:i.attributes,data:r}),this}}},{name:function(t){return"update".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,r){var i;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new z("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new z("Graph.".concat(e,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var o=""+t,a=""+r;if(r=arguments[2],!(i=u(this,o,a,n)))throw new W("Graph.".concat(e,': could not find an edge for the given path ("').concat(o,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new z("Graph.".concat(e,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(t=""+t,!(i=this._edges.get(t)))throw new W("Graph.".concat(e,': could not find the "').concat(t,'" edge in the graph.'))}if("function"!=typeof r)throw new B("Graph.".concat(e,": provided updater is not a function."));return i.attributes=r(i.attributes),this.emit("edgeAttributesUpdated",{key:i.key,type:"update",attributes:i.attributes}),this}}}],Q=T,J=k,Z=function(){var t=arguments,e=null,n=-1;return new Q(function(){for(var r=null;;){if(null===e){if(++n>=t.length)return{done:!0};e=J(t[n])}if(!0!==(r=e.next()).done)break;e=null}return r})},tt=[{name:"edges",type:"mixed"},{name:"inEdges",type:"directed",direction:"in"},{name:"outEdges",type:"directed",direction:"out"},{name:"inboundEdges",type:"mixed",direction:"in"},{name:"outboundEdges",type:"mixed",direction:"out"},{name:"directedEdges",type:"directed"},{name:"undirectedEdges",type:"undirected"}];function et(t,e,n,r){var i=!1;for(var o in e)if(o!==r){var a=e[o];if(i=n(a.key,a.attributes,a.source.key,a.target.key,a.source.attributes,a.target.attributes,a.undirected),t&&i)return a.key}}function nt(t,e,n,r){var i,o,a,s=!1;for(var u in e)if(u!==r){i=e[u];do{if(o=i.source,a=i.target,s=n(i.key,i.attributes,o.key,a.key,o.attributes,a.attributes,i.undirected),t&&s)return i.key;i=i.next}while(void 0!==i)}}function rt(t,e){var n,r=Object.keys(t),i=r.length,o=0;return new T(function(){do{if(n)n=n.next;else{if(o>=i)return{done:!0};var a=r[o++];if(a===e){n=void 0;continue}n=t[a]}}while(!n);return{done:!1,value:{edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected}}})}function it(t,e,n,r){var i=e[n];if(i){var o=i.source,a=i.target;return r(i.key,i.attributes,o.key,a.key,o.attributes,a.attributes,i.undirected)&&t?i.key:void 0}}function ot(t,e,n,r){var i=e[n];if(i){var o=!1;do{if(o=r(i.key,i.attributes,i.source.key,i.target.key,i.source.attributes,i.target.attributes,i.undirected),t&&o)return i.key;i=i.next}while(void 0!==i)}}function at(t,e){var n=t[e];return void 0!==n.next?new T(function(){if(!n)return{done:!0};var t={edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected};return n=n.next,{done:!1,value:t}}):T.of({edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected})}function st(t,e,n,r){if(0!==e.size)for(var i,o,a="mixed"!==n&&n!==e.type,s="undirected"===n,u=!1,c=e._edges.values();!0!==(i=c.next()).done;)if(o=i.value,!a||o.undirected===s){var l=o,d=l.key,h=l.attributes,f=l.source,p=l.target;if(u=r(d,h,f.key,p.key,f.attributes,p.attributes,o.undirected),t&&u)return d}}function ut(t,e,n,r,i,o){var a,s=e?nt:et;if("undirected"!==n){if("out"!==r&&(a=s(t,i.in,o),t&&a))return a;if("in"!==r&&(a=s(t,i.out,o,r?void 0:i.key),t&&a))return a}if("directed"!==n&&(a=s(t,i.undirected,o),t&&a))return a}function ct(t,e,n,r,i,o,a){var s,u=n?ot:it;if("undirected"!==e){if(void 0!==i.in&&"out"!==r&&(s=u(t,i.in,o,a),t&&s))return s;if(void 0!==i.out&&"in"!==r&&(r||i.key!==o)&&(s=u(t,i.out,o,a),t&&s))return s}if("directed"!==e&&void 0!==i.undirected&&(s=u(t,i.undirected,o,a),t&&s))return s}var lt=[{name:"neighbors",type:"mixed"},{name:"inNeighbors",type:"directed",direction:"in"},{name:"outNeighbors",type:"directed",direction:"out"},{name:"inboundNeighbors",type:"mixed",direction:"in"},{name:"outboundNeighbors",type:"mixed",direction:"out"},{name:"directedNeighbors",type:"directed"},{name:"undirectedNeighbors",type:"undirected"}];function dt(){this.A=null,this.B=null}function ht(t,e,n,r,i){for(var o in r){var a=r[o],s=a.source,u=a.target,c=s===n?u:s;if(!e||!e.has(c.key)){var l=i(c.key,c.attributes);if(t&&l)return c.key}}}function ft(t,e,n,r,i){if("mixed"!==e){if("undirected"===e)return ht(t,null,r,r.undirected,i);if("string"==typeof n)return ht(t,null,r,r[n],i)}var o,a=new dt;if("undirected"!==e){if("out"!==n){if(o=ht(t,null,r,r.in,i),t&&o)return o;a.wrap(r.in)}if("in"!==n){if(o=ht(t,a,r,r.out,i),t&&o)return o;a.wrap(r.out)}}if("directed"!==e&&(o=ht(t,a,r,r.undirected,i),t&&o))return o}function pt(t,e,n){var r=Object.keys(n),i=r.length,o=0;return new T(function(){var a=null;do{if(o>=i)return t&&t.wrap(n),{done:!0};var s=n[r[o++]],u=s.source,c=s.target;a=u===e?c:u,t&&t.has(a.key)&&(a=null)}while(null===a);return{done:!1,value:{neighbor:a.key,attributes:a.attributes}}})}function mt(t,e,n,r,i){for(var o,a,s,u,c,l,d,h=r._nodes.values(),f=r.type;!0!==(o=h.next()).done;){var p=!1;if(a=o.value,"undirected"!==f)for(s in u=a.out){c=u[s];do{if(l=c.target,p=!0,d=i(a.key,l.key,a.attributes,l.attributes,c.key,c.attributes,c.undirected),t&&d)return c;c=c.next}while(c)}if("directed"!==f)for(s in u=a.undirected)if(!(e&&a.key>s)){c=u[s];do{if((l=c.target).key!==s&&(l=c.source),p=!0,d=i(a.key,l.key,a.attributes,l.attributes,c.key,c.attributes,c.undirected),t&&d)return c;c=c.next}while(c)}if(n&&!p&&(d=i(a.key,null,a.attributes,null,null,null,null),t&&d))return null}}function gt(t){if(!c(t))throw new B('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in t))throw new B("Graph.import: serialized node is missing its key.");if("attributes"in t&&(!c(t.attributes)||null===t.attributes))throw new B("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function yt(t){if(!c(t))throw new B('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in t))throw new B("Graph.import: serialized edge is missing its source.");if(!("target"in t))throw new B("Graph.import: serialized edge is missing its target.");if("attributes"in t&&(!c(t.attributes)||null===t.attributes))throw new B("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in t&&"boolean"!=typeof t.undirected)throw new B("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}dt.prototype.wrap=function(t){null===this.A?this.A=t:null===this.B&&(this.B=t)},dt.prototype.has=function(t){return null!==this.A&&t in this.A||null!==this.B&&t in this.B};var vt,wt=(vt=255&Math.floor(256*Math.random()),function(){return vt++}),bt=new Set(["directed","undirected","mixed"]),At=new Set(["domain","_events","_eventsCount","_maxListeners"]),Et={allowSelfLoops:!0,multi:!1,type:"mixed"};function Ct(t,e,n){var r=new t.NodeDataClass(e,n);return t._nodes.set(e,r),t.emit("nodeAdded",{key:e,attributes:n}),r}function St(t,e,n,r,i,o,a,s){if(!r&&"undirected"===t.type)throw new z("Graph.".concat(e,": you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead."));if(r&&"directed"===t.type)throw new z("Graph.".concat(e,": you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead."));if(s&&!c(s))throw new B("Graph.".concat(e,': invalid attributes. Expecting an object but got "').concat(s,'"'));if(o=""+o,a=""+a,s=s||{},!t.allowSelfLoops&&o===a)throw new z("Graph.".concat(e,': source & target are the same ("').concat(o,"\"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false."));var u=t._nodes.get(o),l=t._nodes.get(a);if(!u)throw new W("Graph.".concat(e,': source node "').concat(o,'" not found.'));if(!l)throw new W("Graph.".concat(e,': target node "').concat(a,'" not found.'));var d={key:null,undirected:r,source:o,target:a,attributes:s};if(n)i=t._edgeKeyGenerator();else if(i=""+i,t._edges.has(i))throw new z("Graph.".concat(e,': the "').concat(i,'" edge already exists in the graph.'));if(!t.multi&&(r?void 0!==u.undirected[a]:void 0!==u.out[a]))throw new z("Graph.".concat(e,': an edge linking "').concat(o,'" to "').concat(a,"\" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option."));var h=new q(r,i,u,l,s);t._edges.set(i,h);var f=o===a;return r?(u.undirectedDegree++,l.undirectedDegree++,f&&(u.undirectedLoops++,t._undirectedSelfLoopCount++)):(u.outDegree++,l.inDegree++,f&&(u.directedLoops++,t._directedSelfLoopCount++)),t.multi?h.attachMulti():h.attach(),r?t._undirectedSize++:t._directedSize++,d.key=i,t.emit("edgeAdded",d),i}function _t(t,e,n,r,i,o,a,u,l){if(!r&&"undirected"===t.type)throw new z("Graph.".concat(e,": you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead."));if(r&&"directed"===t.type)throw new z("Graph.".concat(e,": you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead."));if(u)if(l){if("function"!=typeof u)throw new B("Graph.".concat(e,': invalid updater function. Expecting a function but got "').concat(u,'"'))}else if(!c(u))throw new B("Graph.".concat(e,': invalid attributes. Expecting an object but got "').concat(u,'"'));var d;if(o=""+o,a=""+a,l&&(d=u,u=void 0),!t.allowSelfLoops&&o===a)throw new z("Graph.".concat(e,': source & target are the same ("').concat(o,"\"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false."));var h,f,p=t._nodes.get(o),m=t._nodes.get(a);if(!n&&(h=t._edges.get(i))){if(!(h.source.key===o&&h.target.key===a||r&&h.source.key===a&&h.target.key===o))throw new z("Graph.".concat(e,': inconsistency detected when attempting to merge the "').concat(i,'" edge with "').concat(o,'" source & "').concat(a,'" target vs. ("').concat(h.source.key,'", "').concat(h.target.key,'").'));f=h}if(f||t.multi||!p||(f=r?p.undirected[a]:p.out[a]),f){var g=[f.key,!1,!1,!1];if(l?!d:!u)return g;if(l){var y=f.attributes;f.attributes=d(y),t.emit("edgeAttributesUpdated",{type:"replace",key:f.key,attributes:f.attributes})}else s(f.attributes,u),t.emit("edgeAttributesUpdated",{type:"merge",key:f.key,attributes:f.attributes,data:u});return g}u=u||{},l&&d&&(u=d(u));var v={key:null,undirected:r,source:o,target:a,attributes:u};if(n)i=t._edgeKeyGenerator();else if(i=""+i,t._edges.has(i))throw new z("Graph.".concat(e,': the "').concat(i,'" edge already exists in the graph.'));var w=!1,b=!1;p||(p=Ct(t,o,{}),w=!0,o===a&&(m=p,b=!0)),m||(m=Ct(t,a,{}),b=!0),h=new q(r,i,p,m,u),t._edges.set(i,h);var A=o===a;return r?(p.undirectedDegree++,m.undirectedDegree++,A&&(p.undirectedLoops++,t._undirectedSelfLoopCount++)):(p.outDegree++,m.inDegree++,A&&(p.directedLoops++,t._directedSelfLoopCount++)),t.multi?h.attachMulti():h.attach(),r?t._undirectedSize++:t._directedSize++,v.key=i,t.emit("edgeAdded",v),[i,!0,w,b]}function Mt(t,e){t._edges.delete(e.key);var n=e.source,r=e.target,i=e.attributes,o=e.undirected,a=n===r;o?(n.undirectedDegree--,r.undirectedDegree--,a&&(n.undirectedLoops--,t._undirectedSelfLoopCount--)):(n.outDegree--,r.inDegree--,a&&(n.directedLoops--,t._directedSelfLoopCount--)),t.multi?e.detachMulti():e.detach(),o?t._undirectedSize--:t._directedSize--,t.emit("edgeDropped",{key:e.key,attributes:i,source:n.key,target:r.key,undirected:o})}var Nt=function(n){function r(t){var e;if(e=n.call(this)||this,"boolean"!=typeof(t=s({},Et,t)).multi)throw new B("Graph.constructor: invalid 'multi' option. Expecting a boolean but got \"".concat(t.multi,'".'));if(!bt.has(t.type))throw new B('Graph.constructor: invalid \'type\' option. Should be one of "mixed", "directed" or "undirected" but got "'.concat(t.type,'".'));if("boolean"!=typeof t.allowSelfLoops)throw new B("Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got \"".concat(t.allowSelfLoops,'".'));var r="mixed"===t.type?H:"directed"===t.type?j:K;d(a(e),"NodeDataClass",r);var i="geid_"+wt()+"_",o=0;return d(a(e),"_attributes",{}),d(a(e),"_nodes",new Map),d(a(e),"_edges",new Map),d(a(e),"_directedSize",0),d(a(e),"_undirectedSize",0),d(a(e),"_directedSelfLoopCount",0),d(a(e),"_undirectedSelfLoopCount",0),d(a(e),"_edgeKeyGenerator",function(){var t;do{t=i+o++}while(e._edges.has(t));return t}),d(a(e),"_options",t),At.forEach(function(t){return d(a(e),t,e[t])}),h(a(e),"order",function(){return e._nodes.size}),h(a(e),"size",function(){return e._edges.size}),h(a(e),"directedSize",function(){return e._directedSize}),h(a(e),"undirectedSize",function(){return e._undirectedSize}),h(a(e),"selfLoopCount",function(){return e._directedSelfLoopCount+e._undirectedSelfLoopCount}),h(a(e),"directedSelfLoopCount",function(){return e._directedSelfLoopCount}),h(a(e),"undirectedSelfLoopCount",function(){return e._undirectedSelfLoopCount}),h(a(e),"multi",e._options.multi),h(a(e),"type",e._options.type),h(a(e),"allowSelfLoops",e._options.allowSelfLoops),h(a(e),"implementation",function(){return"graphology"}),e}e(r,n);var i=r.prototype;return i._resetInstanceCounters=function(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0},i.hasNode=function(t){return this._nodes.has(""+t)},i.hasDirectedEdge=function(t,e){if("undirected"===this.type)return!1;if(1===arguments.length){var n=""+t,r=this._edges.get(n);return!!r&&!r.undirected}if(2===arguments.length){t=""+t,e=""+e;var i=this._nodes.get(t);return!!i&&i.out.hasOwnProperty(e)}throw new B("Graph.hasDirectedEdge: invalid arity (".concat(arguments.length,", instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target."))},i.hasUndirectedEdge=function(t,e){if("directed"===this.type)return!1;if(1===arguments.length){var n=""+t,r=this._edges.get(n);return!!r&&r.undirected}if(2===arguments.length){t=""+t,e=""+e;var i=this._nodes.get(t);return!!i&&i.undirected.hasOwnProperty(e)}throw new B("Graph.hasDirectedEdge: invalid arity (".concat(arguments.length,", instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target."))},i.hasEdge=function(t,e){if(1===arguments.length){var n=""+t;return this._edges.has(n)}if(2===arguments.length){t=""+t,e=""+e;var r=this._nodes.get(t);return!!r&&(void 0!==r.out&&r.out.hasOwnProperty(e)||void 0!==r.undirected&&r.undirected.hasOwnProperty(e))}throw new B("Graph.hasEdge: invalid arity (".concat(arguments.length,", instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target."))},i.directedEdge=function(t,e){if("undirected"!==this.type){if(t=""+t,e=""+e,this.multi)throw new z("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");var n=this._nodes.get(t);if(!n)throw new W('Graph.directedEdge: could not find the "'.concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new W('Graph.directedEdge: could not find the "'.concat(e,'" target node in the graph.'));var r=n.out&&n.out[e]||void 0;return r?r.key:void 0}},i.undirectedEdge=function(t,e){if("directed"!==this.type){if(t=""+t,e=""+e,this.multi)throw new z("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");var n=this._nodes.get(t);if(!n)throw new W('Graph.undirectedEdge: could not find the "'.concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new W('Graph.undirectedEdge: could not find the "'.concat(e,'" target node in the graph.'));var r=n.undirected&&n.undirected[e]||void 0;return r?r.key:void 0}},i.edge=function(t,e){if(this.multi)throw new z("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new W('Graph.edge: could not find the "'.concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new W('Graph.edge: could not find the "'.concat(e,'" target node in the graph.'));var r=n.out&&n.out[e]||n.undirected&&n.undirected[e]||void 0;if(r)return r.key},i.areDirectedNeighbors=function(t,e){t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new W('Graph.areDirectedNeighbors: could not find the "'.concat(t,'" node in the graph.'));return"undirected"!==this.type&&(e in n.in||e in n.out)},i.areOutNeighbors=function(t,e){t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new W('Graph.areOutNeighbors: could not find the "'.concat(t,'" node in the graph.'));return"undirected"!==this.type&&e in n.out},i.areInNeighbors=function(t,e){t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new W('Graph.areInNeighbors: could not find the "'.concat(t,'" node in the graph.'));return"undirected"!==this.type&&e in n.in},i.areUndirectedNeighbors=function(t,e){t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new W('Graph.areUndirectedNeighbors: could not find the "'.concat(t,'" node in the graph.'));return"directed"!==this.type&&e in n.undirected},i.areNeighbors=function(t,e){t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new W('Graph.areNeighbors: could not find the "'.concat(t,'" node in the graph.'));return"undirected"!==this.type&&(e in n.in||e in n.out)||"directed"!==this.type&&e in n.undirected},i.areInboundNeighbors=function(t,e){t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new W('Graph.areInboundNeighbors: could not find the "'.concat(t,'" node in the graph.'));return"undirected"!==this.type&&e in n.in||"directed"!==this.type&&e in n.undirected},i.areOutboundNeighbors=function(t,e){t=""+t,e=""+e;var n=this._nodes.get(t);if(!n)throw new W('Graph.areOutboundNeighbors: could not find the "'.concat(t,'" node in the graph.'));return"undirected"!==this.type&&e in n.out||"directed"!==this.type&&e in n.undirected},i.inDegree=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new W('Graph.inDegree: could not find the "'.concat(t,'" node in the graph.'));return"undirected"===this.type?0:e.inDegree},i.outDegree=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new W('Graph.outDegree: could not find the "'.concat(t,'" node in the graph.'));return"undirected"===this.type?0:e.outDegree},i.directedDegree=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new W('Graph.directedDegree: could not find the "'.concat(t,'" node in the graph.'));return"undirected"===this.type?0:e.inDegree+e.outDegree},i.undirectedDegree=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new W('Graph.undirectedDegree: could not find the "'.concat(t,'" node in the graph.'));return"directed"===this.type?0:e.undirectedDegree},i.inboundDegree=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new W('Graph.inboundDegree: could not find the "'.concat(t,'" node in the graph.'));var n=0;return"directed"!==this.type&&(n+=e.undirectedDegree),"undirected"!==this.type&&(n+=e.inDegree),n},i.outboundDegree=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new W('Graph.outboundDegree: could not find the "'.concat(t,'" node in the graph.'));var n=0;return"directed"!==this.type&&(n+=e.undirectedDegree),"undirected"!==this.type&&(n+=e.outDegree),n},i.degree=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new W('Graph.degree: could not find the "'.concat(t,'" node in the graph.'));var n=0;return"directed"!==this.type&&(n+=e.undirectedDegree),"undirected"!==this.type&&(n+=e.inDegree+e.outDegree),n},i.inDegreeWithoutSelfLoops=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new W('Graph.inDegreeWithoutSelfLoops: could not find the "'.concat(t,'" node in the graph.'));return"undirected"===this.type?0:e.inDegree-e.directedLoops},i.outDegreeWithoutSelfLoops=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new W('Graph.outDegreeWithoutSelfLoops: could not find the "'.concat(t,'" node in the graph.'));return"undirected"===this.type?0:e.outDegree-e.directedLoops},i.directedDegreeWithoutSelfLoops=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new W('Graph.directedDegreeWithoutSelfLoops: could not find the "'.concat(t,'" node in the graph.'));return"undirected"===this.type?0:e.inDegree+e.outDegree-2*e.directedLoops},i.undirectedDegreeWithoutSelfLoops=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new W('Graph.undirectedDegreeWithoutSelfLoops: could not find the "'.concat(t,'" node in the graph.'));return"directed"===this.type?0:e.undirectedDegree-2*e.undirectedLoops},i.inboundDegreeWithoutSelfLoops=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new W('Graph.inboundDegreeWithoutSelfLoops: could not find the "'.concat(t,'" node in the graph.'));var n=0,r=0;return"directed"!==this.type&&(n+=e.undirectedDegree,r+=2*e.undirectedLoops),"undirected"!==this.type&&(n+=e.inDegree,r+=e.directedLoops),n-r},i.outboundDegreeWithoutSelfLoops=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new W('Graph.outboundDegreeWithoutSelfLoops: could not find the "'.concat(t,'" node in the graph.'));var n=0,r=0;return"directed"!==this.type&&(n+=e.undirectedDegree,r+=2*e.undirectedLoops),"undirected"!==this.type&&(n+=e.outDegree,r+=e.directedLoops),n-r},i.degreeWithoutSelfLoops=function(t){t=""+t;var e=this._nodes.get(t);if(!e)throw new W('Graph.degreeWithoutSelfLoops: could not find the "'.concat(t,'" node in the graph.'));var n=0,r=0;return"directed"!==this.type&&(n+=e.undirectedDegree,r+=2*e.undirectedLoops),"undirected"!==this.type&&(n+=e.inDegree+e.outDegree,r+=2*e.directedLoops),n-r},i.source=function(t){t=""+t;var e=this._edges.get(t);if(!e)throw new W('Graph.source: could not find the "'.concat(t,'" edge in the graph.'));return e.source.key},i.target=function(t){t=""+t;var e=this._edges.get(t);if(!e)throw new W('Graph.target: could not find the "'.concat(t,'" edge in the graph.'));return e.target.key},i.extremities=function(t){t=""+t;var e=this._edges.get(t);if(!e)throw new W('Graph.extremities: could not find the "'.concat(t,'" edge in the graph.'));return[e.source.key,e.target.key]},i.opposite=function(t,e){t=""+t,e=""+e;var n=this._edges.get(e);if(!n)throw new W('Graph.opposite: could not find the "'.concat(e,'" edge in the graph.'));var r=n.source.key,i=n.target.key;if(t===r)return i;if(t===i)return r;throw new W('Graph.opposite: the "'.concat(t,'" node is not attached to the "').concat(e,'" edge (').concat(r,", ").concat(i,")."))},i.hasExtremity=function(t,e){t=""+t,e=""+e;var n=this._edges.get(t);if(!n)throw new W('Graph.hasExtremity: could not find the "'.concat(t,'" edge in the graph.'));return n.source.key===e||n.target.key===e},i.isUndirected=function(t){t=""+t;var e=this._edges.get(t);if(!e)throw new W('Graph.isUndirected: could not find the "'.concat(t,'" edge in the graph.'));return e.undirected},i.isDirected=function(t){t=""+t;var e=this._edges.get(t);if(!e)throw new W('Graph.isDirected: could not find the "'.concat(t,'" edge in the graph.'));return!e.undirected},i.isSelfLoop=function(t){t=""+t;var e=this._edges.get(t);if(!e)throw new W('Graph.isSelfLoop: could not find the "'.concat(t,'" edge in the graph.'));return e.source===e.target},i.addNode=function(t,e){var n=function(t,e,n){if(n&&!c(n))throw new B('Graph.addNode: invalid attributes. Expecting an object but got "'.concat(n,'"'));if(e=""+e,n=n||{},t._nodes.has(e))throw new z('Graph.addNode: the "'.concat(e,'" node already exist in the graph.'));var r=new t.NodeDataClass(e,n);return t._nodes.set(e,r),t.emit("nodeAdded",{key:e,attributes:n}),r}(this,t,e);return n.key},i.mergeNode=function(t,e){if(e&&!c(e))throw new B('Graph.mergeNode: invalid attributes. Expecting an object but got "'.concat(e,'"'));t=""+t,e=e||{};var n=this._nodes.get(t);return n?(e&&(s(n.attributes,e),this.emit("nodeAttributesUpdated",{type:"merge",key:t,attributes:n.attributes,data:e})),[t,!1]):(n=new this.NodeDataClass(t,e),this._nodes.set(t,n),this.emit("nodeAdded",{key:t,attributes:e}),[t,!0])},i.updateNode=function(t,e){if(e&&"function"!=typeof e)throw new B('Graph.updateNode: invalid updater function. Expecting a function but got "'.concat(e,'"'));t=""+t;var n=this._nodes.get(t);if(n){if(e){var r=n.attributes;n.attributes=e(r),this.emit("nodeAttributesUpdated",{type:"replace",key:t,attributes:n.attributes})}return[t,!1]}var i=e?e({}):{};return n=new this.NodeDataClass(t,i),this._nodes.set(t,n),this.emit("nodeAdded",{key:t,attributes:i}),[t,!0]},i.dropNode=function(t){t=""+t;var e,n=this._nodes.get(t);if(!n)throw new W('Graph.dropNode: could not find the "'.concat(t,'" node in the graph.'));if("undirected"!==this.type){for(var r in n.out){e=n.out[r];do{Mt(this,e),e=e.next}while(e)}for(var i in n.in){e=n.in[i];do{Mt(this,e),e=e.next}while(e)}}if("directed"!==this.type)for(var o in n.undirected){e=n.undirected[o];do{Mt(this,e),e=e.next}while(e)}this._nodes.delete(t),this.emit("nodeDropped",{key:t,attributes:n.attributes})},i.dropEdge=function(t){var e;if(arguments.length>1){var n=""+arguments[0],r=""+arguments[1];if(!(e=u(this,n,r,this.type)))throw new W('Graph.dropEdge: could not find the "'.concat(n,'" -> "').concat(r,'" edge in the graph.'))}else if(t=""+t,!(e=this._edges.get(t)))throw new W('Graph.dropEdge: could not find the "'.concat(t,'" edge in the graph.'));return Mt(this,e),this},i.dropDirectedEdge=function(t,e){if(arguments.length<2)throw new z("Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new z("Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");var n=u(this,t=""+t,e=""+e,"directed");if(!n)throw new W('Graph.dropDirectedEdge: could not find a "'.concat(t,'" -> "').concat(e,'" edge in the graph.'));return Mt(this,n),this},i.dropUndirectedEdge=function(t,e){if(arguments.length<2)throw new z("Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new z("Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");var n=u(this,t,e,"undirected");if(!n)throw new W('Graph.dropUndirectedEdge: could not find a "'.concat(t,'" -> "').concat(e,'" edge in the graph.'));return Mt(this,n),this},i.clear=function(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")},i.clearEdges=function(){for(var t,e=this._nodes.values();!0!==(t=e.next()).done;)t.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")},i.getAttribute=function(t){return this._attributes[t]},i.getAttributes=function(){return this._attributes},i.hasAttribute=function(t){return this._attributes.hasOwnProperty(t)},i.setAttribute=function(t,e){return this._attributes[t]=e,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:t}),this},i.updateAttribute=function(t,e){if("function"!=typeof e)throw new B("Graph.updateAttribute: updater should be a function.");var n=this._attributes[t];return this._attributes[t]=e(n),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:t}),this},i.removeAttribute=function(t){return delete this._attributes[t],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:t}),this},i.replaceAttributes=function(t){if(!c(t))throw new B("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=t,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this},i.mergeAttributes=function(t){if(!c(t))throw new B("Graph.mergeAttributes: provided attributes are not a plain object.");return s(this._attributes,t),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:t}),this},i.updateAttributes=function(t){if("function"!=typeof t)throw new B("Graph.updateAttributes: provided updater is not a function.");return this._attributes=t(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this},i.updateEachNodeAttributes=function(t,e){if("function"!=typeof t)throw new B("Graph.updateEachNodeAttributes: expecting an updater function.");if(e&&!f(e))throw new B("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");for(var n,r,i=this._nodes.values();!0!==(n=i.next()).done;)(r=n.value).attributes=t(r.key,r.attributes);this.emit("eachNodeAttributesUpdated",{hints:e||null})},i.updateEachEdgeAttributes=function(t,e){if("function"!=typeof t)throw new B("Graph.updateEachEdgeAttributes: expecting an updater function.");if(e&&!f(e))throw new B("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");for(var n,r,i,o,a=this._edges.values();!0!==(n=a.next()).done;)i=(r=n.value).source,o=r.target,r.attributes=t(r.key,r.attributes,i.key,o.key,i.attributes,o.attributes,r.undirected);this.emit("eachEdgeAttributesUpdated",{hints:e||null})},i.forEachAdjacencyEntry=function(t){if("function"!=typeof t)throw new B("Graph.forEachAdjacencyEntry: expecting a callback.");mt(!1,!1,!1,this,t)},i.forEachAdjacencyEntryWithOrphans=function(t){if("function"!=typeof t)throw new B("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");mt(!1,!1,!0,this,t)},i.forEachAssymetricAdjacencyEntry=function(t){if("function"!=typeof t)throw new B("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");mt(!1,!0,!1,this,t)},i.forEachAssymetricAdjacencyEntryWithOrphans=function(t){if("function"!=typeof t)throw new B("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");mt(!1,!0,!0,this,t)},i.nodes=function(){return"function"==typeof Array.from?Array.from(this._nodes.keys()):G(this._nodes.keys(),this._nodes.size)},i.forEachNode=function(t){if("function"!=typeof t)throw new B("Graph.forEachNode: expecting a callback.");for(var e,n,r=this._nodes.values();!0!==(e=r.next()).done;)t((n=e.value).key,n.attributes)},i.findNode=function(t){if("function"!=typeof t)throw new B("Graph.findNode: expecting a callback.");for(var e,n,r=this._nodes.values();!0!==(e=r.next()).done;)if(t((n=e.value).key,n.attributes))return n.key},i.mapNodes=function(t){if("function"!=typeof t)throw new B("Graph.mapNode: expecting a callback.");for(var e,n,r=this._nodes.values(),i=new Array(this.order),o=0;!0!==(e=r.next()).done;)n=e.value,i[o++]=t(n.key,n.attributes);return i},i.someNode=function(t){if("function"!=typeof t)throw new B("Graph.someNode: expecting a callback.");for(var e,n,r=this._nodes.values();!0!==(e=r.next()).done;)if(t((n=e.value).key,n.attributes))return!0;return!1},i.everyNode=function(t){if("function"!=typeof t)throw new B("Graph.everyNode: expecting a callback.");for(var e,n,r=this._nodes.values();!0!==(e=r.next()).done;)if(!t((n=e.value).key,n.attributes))return!1;return!0},i.filterNodes=function(t){if("function"!=typeof t)throw new B("Graph.filterNodes: expecting a callback.");for(var e,n,r=this._nodes.values(),i=[];!0!==(e=r.next()).done;)t((n=e.value).key,n.attributes)&&i.push(n.key);return i},i.reduceNodes=function(t,e){if("function"!=typeof t)throw new B("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new B("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");for(var n,r,i=e,o=this._nodes.values();!0!==(n=o.next()).done;)i=t(i,(r=n.value).key,r.attributes);return i},i.nodeEntries=function(){var t=this._nodes.values();return new T(function(){var e=t.next();if(e.done)return e;var n=e.value;return{value:{node:n.key,attributes:n.attributes},done:!1}})},i.export=function(){var t=this,e=new Array(this._nodes.size),n=0;this._nodes.forEach(function(t,r){e[n++]=function(t,e){var n={key:t};return l(e.attributes)||(n.attributes=s({},e.attributes)),n}(r,t)});var r=new Array(this._edges.size);return n=0,this._edges.forEach(function(e,i){r[n++]=function(t,e,n){var r={key:e,source:n.source.key,target:n.target.key};return l(n.attributes)||(r.attributes=s({},n.attributes)),"mixed"===t&&n.undirected&&(r.undirected=!0),r}(t.type,i,e)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:e,edges:r}},i.import=function(t){var e,n,i,o,a,s=this,u=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(t instanceof r)return t.forEachNode(function(t,e){u?s.mergeNode(t,e):s.addNode(t,e)}),t.forEachEdge(function(t,e,n,r,i,o,a){u?a?s.mergeUndirectedEdgeWithKey(t,n,r,e):s.mergeDirectedEdgeWithKey(t,n,r,e):a?s.addUndirectedEdgeWithKey(t,n,r,e):s.addDirectedEdgeWithKey(t,n,r,e)}),this;if(!c(t))throw new B("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(t.attributes){if(!c(t.attributes))throw new B("Graph.import: invalid attributes. Expecting a plain object.");u?this.mergeAttributes(t.attributes):this.replaceAttributes(t.attributes)}if(t.nodes){if(i=t.nodes,!Array.isArray(i))throw new B("Graph.import: invalid nodes. Expecting an array.");for(e=0,n=i.length;e<n;e++){gt(o=i[e]);var l=o,d=l.key,h=l.attributes;u?this.mergeNode(d,h):this.addNode(d,h)}}if(t.edges){var f=!1;if("undirected"===this.type&&(f=!0),i=t.edges,!Array.isArray(i))throw new B("Graph.import: invalid edges. Expecting an array.");for(e=0,n=i.length;e<n;e++){yt(a=i[e]);var p=a,m=p.source,g=p.target,y=p.attributes,v=p.undirected,w=void 0===v?f:v;"key"in a?(u?w?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:w?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey).call(this,a.key,m,g,y):(u?w?this.mergeUndirectedEdge:this.mergeDirectedEdge:w?this.addUndirectedEdge:this.addDirectedEdge).call(this,m,g,y)}}return this},i.nullCopy=function(t){var e=new r(s({},this._options,t));return e.replaceAttributes(s({},this.getAttributes())),e},i.emptyCopy=function(t){var e=this.nullCopy(t);return this._nodes.forEach(function(t,n){var r=s({},t.attributes);t=new e.NodeDataClass(n,r),e._nodes.set(n,t)}),e},i.copy=function(t){if("string"==typeof(t=t||{}).type&&t.type!==this.type&&"mixed"!==t.type)throw new z('Graph.copy: cannot create an incompatible copy from "'.concat(this.type,'" type to "').concat(t.type,'" because this would mean losing information about the current graph.'));if("boolean"==typeof t.multi&&t.multi!==this.multi&&!0!==t.multi)throw new z("Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.");if("boolean"==typeof t.allowSelfLoops&&t.allowSelfLoops!==this.allowSelfLoops&&!0!==t.allowSelfLoops)throw new z("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");for(var e,n,r=this.emptyCopy(t),i=this._edges.values();!0!==(e=i.next()).done;)St(r,"copy",!1,(n=e.value).undirected,n.key,n.source.key,n.target.key,s({},n.attributes));return r},i.toJSON=function(){return this.export()},i.toString=function(){return"[object Graph]"},i.inspect=function(){var e=this,n={};this._nodes.forEach(function(t,e){n[e]=t.attributes});var r={},i={};this._edges.forEach(function(t,n){var o,a=t.undirected?"--":"->",s="",u=t.source.key,c=t.target.key;t.undirected&&u>c&&(o=u,u=c,c=o);var l="(".concat(u,")").concat(a,"(").concat(c,")");n.startsWith("geid_")?e.multi&&(void 0===i[l]?i[l]=0:i[l]++,s+="".concat(i[l],". ")):s+="[".concat(n,"]: "),r[s+=l]=t.attributes});var o={};for(var a in this)this.hasOwnProperty(a)&&!At.has(a)&&"function"!=typeof this[a]&&"symbol"!==t(a)&&(o[a]=this[a]);return o.attributes=this._attributes,o.nodes=n,o.edges=r,d(o,"constructor",this.constructor),o},r}(m.exports.EventEmitter);"undefined"!=typeof Symbol&&(Nt.prototype[Symbol.for("nodejs.util.inspect.custom")]=Nt.prototype.inspect),[{name:function(t){return"".concat(t,"Edge")},generateKey:!0},{name:function(t){return"".concat(t,"DirectedEdge")},generateKey:!0,type:"directed"},{name:function(t){return"".concat(t,"UndirectedEdge")},generateKey:!0,type:"undirected"},{name:function(t){return"".concat(t,"EdgeWithKey")}},{name:function(t){return"".concat(t,"DirectedEdgeWithKey")},type:"directed"},{name:function(t){return"".concat(t,"UndirectedEdgeWithKey")},type:"undirected"}].forEach(function(t){["add","merge","update"].forEach(function(e){var n=t.name(e),r="add"===e?St:_t;t.generateKey?Nt.prototype[n]=function(i,o,a){return r(this,n,!0,"undirected"===(t.type||this.type),null,i,o,a,"update"===e)}:Nt.prototype[n]=function(i,o,a,s){return r(this,n,!1,"undirected"===(t.type||this.type),i,o,a,s,"update"===e)}})}),function(t){$.forEach(function(e){var n=e.name,r=e.attacher;r(t,n("Node"),0),r(t,n("Source"),1),r(t,n("Target"),2),r(t,n("Opposite"),3)})}(Nt),function(t){X.forEach(function(e){var n=e.name,r=e.attacher;r(t,n("Edge"),"mixed"),r(t,n("DirectedEdge"),"directed"),r(t,n("UndirectedEdge"),"undirected")})}(Nt),function(t){tt.forEach(function(e){!function(t,e){var n=e.name,r=e.type,i=e.direction;t.prototype[n]=function(t,e){if("mixed"!==r&&"mixed"!==this.type&&r!==this.type)return[];if(!arguments.length)return function(t,e){if(0===t.size)return[];if("mixed"===e||e===t.type)return"function"==typeof Array.from?Array.from(t._edges.keys()):G(t._edges.keys(),t._edges.size);for(var n,r,i="undirected"===e?t.undirectedSize:t.directedSize,o=new Array(i),a="undirected"===e,s=t._edges.values(),u=0;!0!==(n=s.next()).done;)(r=n.value).undirected===a&&(o[u++]=r.key);return o}(this,r);if(1===arguments.length){t=""+t;var o=this._nodes.get(t);if(void 0===o)throw new W("Graph.".concat(n,': could not find the "').concat(t,'" node in the graph.'));return function(t,e,n,r){var i=[];return ut(!1,t,e,n,r,function(t){i.push(t)}),i}(this.multi,"mixed"===r?this.type:r,i,o)}if(2===arguments.length){t=""+t,e=""+e;var a=this._nodes.get(t);if(!a)throw new W("Graph.".concat(n,': could not find the "').concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new W("Graph.".concat(n,': could not find the "').concat(e,'" target node in the graph.'));return function(t,e,n,r,i){var o=[];return ct(!1,t,e,n,r,i,function(t){o.push(t)}),o}(r,this.multi,i,a,e)}throw new B("Graph.".concat(n,": too many arguments (expecting 0, 1 or 2 and got ").concat(arguments.length,")."))}}(t,e),function(t,e){var n=e.name,r=e.type,i=e.direction,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[o]=function(t,e,n){if("mixed"===r||"mixed"===this.type||r===this.type){if(1===arguments.length)return st(!1,this,r,n=t);if(2===arguments.length){t=""+t,n=e;var a=this._nodes.get(t);if(void 0===a)throw new W("Graph.".concat(o,': could not find the "').concat(t,'" node in the graph.'));return ut(!1,this.multi,"mixed"===r?this.type:r,i,a,n)}if(3===arguments.length){t=""+t,e=""+e;var s=this._nodes.get(t);if(!s)throw new W("Graph.".concat(o,': could not find the "').concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new W("Graph.".concat(o,': could not find the "').concat(e,'" target node in the graph.'));return ct(!1,r,this.multi,i,s,e,n)}throw new B("Graph.".concat(o,": too many arguments (expecting 1, 2 or 3 and got ").concat(arguments.length,")."))}};var a="map"+n[0].toUpperCase()+n.slice(1);t.prototype[a]=function(){var t,e=Array.prototype.slice.call(arguments),n=e.pop();if(0===e.length){var i=0;"directed"!==r&&(i+=this.undirectedSize),"undirected"!==r&&(i+=this.directedSize),t=new Array(i);var a=0;e.push(function(e,r,i,o,s,u,c){t[a++]=n(e,r,i,o,s,u,c)})}else t=[],e.push(function(e,r,i,o,a,s,u){t.push(n(e,r,i,o,a,s,u))});return this[o].apply(this,e),t};var s="filter"+n[0].toUpperCase()+n.slice(1);t.prototype[s]=function(){var t=Array.prototype.slice.call(arguments),e=t.pop(),n=[];return t.push(function(t,r,i,o,a,s,u){e(t,r,i,o,a,s,u)&&n.push(t)}),this[o].apply(this,t),n};var u="reduce"+n[0].toUpperCase()+n.slice(1);t.prototype[u]=function(){var t,e,n=Array.prototype.slice.call(arguments);if(n.length<2||n.length>4)throw new B("Graph.".concat(u,": invalid number of arguments (expecting 2, 3 or 4 and got ").concat(n.length,")."));if("function"==typeof n[n.length-1]&&"function"!=typeof n[n.length-2])throw new B("Graph.".concat(u,": missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array."));2===n.length?(t=n[0],e=n[1],n=[]):3===n.length?(t=n[1],e=n[2],n=[n[0]]):4===n.length&&(t=n[2],e=n[3],n=[n[0],n[1]]);var r=e;return n.push(function(e,n,i,o,a,s,u){r=t(r,e,n,i,o,a,s,u)}),this[o].apply(this,n),r}}(t,e),function(t,e){var n=e.name,r=e.type,i=e.direction,o="find"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[o]=function(t,e,n){if("mixed"!==r&&"mixed"!==this.type&&r!==this.type)return!1;if(1===arguments.length)return st(!0,this,r,n=t);if(2===arguments.length){t=""+t,n=e;var a=this._nodes.get(t);if(void 0===a)throw new W("Graph.".concat(o,': could not find the "').concat(t,'" node in the graph.'));return ut(!0,this.multi,"mixed"===r?this.type:r,i,a,n)}if(3===arguments.length){t=""+t,e=""+e;var s=this._nodes.get(t);if(!s)throw new W("Graph.".concat(o,': could not find the "').concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new W("Graph.".concat(o,': could not find the "').concat(e,'" target node in the graph.'));return ct(!0,r,this.multi,i,s,e,n)}throw new B("Graph.".concat(o,": too many arguments (expecting 1, 2 or 3 and got ").concat(arguments.length,")."))};var a="some"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[a]=function(){var t=Array.prototype.slice.call(arguments),e=t.pop();return t.push(function(t,n,r,i,o,a,s){return e(t,n,r,i,o,a,s)}),!!this[o].apply(this,t)};var s="every"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[s]=function(){var t=Array.prototype.slice.call(arguments),e=t.pop();return t.push(function(t,n,r,i,o,a,s){return!e(t,n,r,i,o,a,s)}),!this[o].apply(this,t)}}(t,e),function(t,e){var n=e.name,r=e.type,i=e.direction,o=n.slice(0,-1)+"Entries";t.prototype[o]=function(t,e){if("mixed"!==r&&"mixed"!==this.type&&r!==this.type)return T.empty();if(!arguments.length)return function(t,e){if(0===t.size)return T.empty();var n="mixed"!==e&&e!==t.type,r="undirected"===e,i=t._edges.values();return new T(function(){for(var t,e;;){if((t=i.next()).done)return t;if(e=t.value,!n||e.undirected===r)break}return{value:{edge:e.key,attributes:e.attributes,source:e.source.key,target:e.target.key,sourceAttributes:e.source.attributes,targetAttributes:e.target.attributes,undirected:e.undirected},done:!1}})}(this,r);if(1===arguments.length){t=""+t;var n=this._nodes.get(t);if(!n)throw new W("Graph.".concat(o,': could not find the "').concat(t,'" node in the graph.'));return function(t,e,n){var r=T.empty();return"undirected"!==t&&("out"!==e&&void 0!==n.in&&(r=Z(r,rt(n.in))),"in"!==e&&void 0!==n.out&&(r=Z(r,rt(n.out,e?void 0:n.key)))),"directed"!==t&&void 0!==n.undirected&&(r=Z(r,rt(n.undirected))),r}(r,i,n)}if(2===arguments.length){t=""+t,e=""+e;var a=this._nodes.get(t);if(!a)throw new W("Graph.".concat(o,': could not find the "').concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new W("Graph.".concat(o,': could not find the "').concat(e,'" target node in the graph.'));return function(t,e,n,r){var i=T.empty();return"undirected"!==t&&(void 0!==n.in&&"out"!==e&&r in n.in&&(i=Z(i,at(n.in,r))),void 0!==n.out&&"in"!==e&&r in n.out&&(e||n.key!==r)&&(i=Z(i,at(n.out,r)))),"directed"!==t&&void 0!==n.undirected&&r in n.undirected&&(i=Z(i,at(n.undirected,r))),i}(r,i,a,e)}throw new B("Graph.".concat(o,": too many arguments (expecting 0, 1 or 2 and got ").concat(arguments.length,")."))}}(t,e)})}(Nt),function(t){lt.forEach(function(e){(function(t,e){var n=e.name,r=e.type,i=e.direction;t.prototype[n]=function(t){if("mixed"!==r&&"mixed"!==this.type&&r!==this.type)return[];t=""+t;var e=this._nodes.get(t);if(void 0===e)throw new W("Graph.".concat(n,': could not find the "').concat(t,'" node in the graph.'));return function(t,e,n){if("mixed"!==t){if("undirected"===t)return Object.keys(n.undirected);if("string"==typeof e)return Object.keys(n[e])}var r=[];return ft(!1,t,e,n,function(t){r.push(t)}),r}("mixed"===r?this.type:r,i,e)}})(t,e),function(t,e){var n=e.name,r=e.type,i=e.direction,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[o]=function(t,e){if("mixed"===r||"mixed"===this.type||r===this.type){t=""+t;var n=this._nodes.get(t);if(void 0===n)throw new W("Graph.".concat(o,': could not find the "').concat(t,'" node in the graph.'));ft(!1,"mixed"===r?this.type:r,i,n,e)}};var a="map"+n[0].toUpperCase()+n.slice(1);t.prototype[a]=function(t,e){var n=[];return this[o](t,function(t,r){n.push(e(t,r))}),n};var s="filter"+n[0].toUpperCase()+n.slice(1);t.prototype[s]=function(t,e){var n=[];return this[o](t,function(t,r){e(t,r)&&n.push(t)}),n};var u="reduce"+n[0].toUpperCase()+n.slice(1);t.prototype[u]=function(t,e,n){if(arguments.length<3)throw new B("Graph.".concat(u,": missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array."));var r=n;return this[o](t,function(t,n){r=e(r,t,n)}),r}}(t,e),function(t,e){var n=e.name,r=e.type,i=e.direction,o=n[0].toUpperCase()+n.slice(1,-1),a="find"+o;t.prototype[a]=function(t,e){if("mixed"===r||"mixed"===this.type||r===this.type){t=""+t;var n=this._nodes.get(t);if(void 0===n)throw new W("Graph.".concat(a,': could not find the "').concat(t,'" node in the graph.'));return ft(!0,"mixed"===r?this.type:r,i,n,e)}};var s="some"+o;t.prototype[s]=function(t,e){return!!this[a](t,e)};var u="every"+o;t.prototype[u]=function(t,e){return!this[a](t,function(t,n){return!e(t,n)})}}(t,e),function(t,e){var n=e.name,r=e.type,i=e.direction,o=n.slice(0,-1)+"Entries";t.prototype[o]=function(t){if("mixed"!==r&&"mixed"!==this.type&&r!==this.type)return T.empty();t=""+t;var e=this._nodes.get(t);if(void 0===e)throw new W("Graph.".concat(o,': could not find the "').concat(t,'" node in the graph.'));return function(t,e,n){if("mixed"!==t){if("undirected"===t)return pt(null,n,n.undirected);if("string"==typeof e)return pt(null,n,n[e])}var r=T.empty(),i=new dt;return"undirected"!==t&&("out"!==e&&(r=Z(r,pt(i,n,n.in))),"in"!==e&&(r=Z(r,pt(i,n,n.out)))),"directed"!==t&&(r=Z(r,pt(i,n,n.undirected))),r}("mixed"===r?this.type:r,i,e)}}(t,e)})}(Nt);var It=function(t){function n(e){var n=s({type:"directed"},e);if("multi"in n&&!1!==n.multi)throw new B("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if("directed"!==n.type)throw new B('DirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return t.call(this,n)||this}return e(n,t),n}(Nt),Lt=function(t){function n(e){var n=s({type:"undirected"},e);if("multi"in n&&!1!==n.multi)throw new B("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if("undirected"!==n.type)throw new B('UndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return t.call(this,n)||this}return e(n,t),n}(Nt),Pt=function(t){function n(e){var n=s({multi:!0},e);if("multi"in n&&!0!==n.multi)throw new B("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");return t.call(this,n)||this}return e(n,t),n}(Nt),Tt=function(t){function n(e){var n=s({type:"directed",multi:!0},e);if("multi"in n&&!0!==n.multi)throw new B("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if("directed"!==n.type)throw new B('MultiDirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return t.call(this,n)||this}return e(n,t),n}(Nt),Ft=function(t){function n(e){var n=s({type:"undirected",multi:!0},e);if("multi"in n&&!0!==n.multi)throw new B("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if("undirected"!==n.type)throw new B('MultiUndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return t.call(this,n)||this}return e(n,t),n}(Nt);function Ot(t){t.from=function(e,n){var r=s({},e.options,n),i=new t(r);return i.import(e),i}}return Ot(Nt),Ot(It),Ot(Lt),Ot(Pt),Ot(Tt),Ot(Ft),Nt.Graph=Nt,Nt.DirectedGraph=It,Nt.UndirectedGraph=Lt,Nt.MultiGraph=Pt,Nt.MultiDirectedGraph=Tt,Nt.MultiUndirectedGraph=Ft,Nt.InvalidArgumentsGraphError=B,Nt.NotFoundGraphError=W,Nt.UsageGraphError=z,Nt}()},944:(t,e)=>{"use strict";e.Vb=void 0,e.Vb=function(t,e,n){var r=function(t,e,n){if(0===t.length||0===e.length)return 0;if(n&&!n.caseSensitive&&(t=t.toUpperCase(),e=e.toUpperCase()),t===e)return 1;for(var r=0,i=t.length,o=e.length,a=Math.floor(Math.max(i,o)/2)-1,s=new Array(i),u=new Array(o),c=0;c<i;c++)for(var l=Math.max(0,c-a);l<=Math.min(o,c+a+1);l++)if(!s[c]&&!u[l]&&t[c]===e[l]){++r,s[c]=u[l]=!0;break}if(0===r)return 0;var d=0,h=0;for(c=0;c<i;c++)if(s[c]){for(;!u[h];)h++;t.charAt(c)!==e.charAt(h++)&&d++}return(r/i+r/o+(r-(d/=2))/r)/3}(t,e,n),i=0;if(r>.7){for(var o=Math.min(t.length,e.length),a=0;t[a]===e[a]&&a<4&&a<o;)++i,a++;r+=.1*i*(1-r)}return r}},1113:t=>{"use strict";t.exports=function(t,e){if(e.styleSheet)e.styleSheet.cssText=t;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}}},1354:t=>{"use strict";t.exports=function(t){var e=t[1],n=t[3];if(!n)return e;if("function"==typeof btoa){var r=btoa(unescape(encodeURIComponent(JSON.stringify(n)))),i="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(r),o="/*# ".concat(i," */");return[e].concat([o]).join("\n")}return[e].join("\n")}},1736:t=>{t.exports=function(t){return null!==t&&"object"==typeof t&&"function"==typeof t.addUndirectedEdgeWithKey&&"function"==typeof t.dropNode&&"boolean"==typeof t.multi}},1782:(t,e)=>{e.assign=function(t){t=t||{};var e,n,r,i=Array.prototype.slice.call(arguments).slice(1);for(e=0,r=i.length;e<r;e++)if(i[e])for(n in i[e])t[n]=i[e][n];return t},e.validateSettings=function(t){return"linLogMode"in t&&"boolean"!=typeof t.linLogMode?{message:"the `linLogMode` setting should be a boolean."}:"outboundAttractionDistribution"in t&&"boolean"!=typeof t.outboundAttractionDistribution?{message:"the `outboundAttractionDistribution` setting should be a boolean."}:"adjustSizes"in t&&"boolean"!=typeof t.adjustSizes?{message:"the `adjustSizes` setting should be a boolean."}:"edgeWeightInfluence"in t&&"number"!=typeof t.edgeWeightInfluence?{message:"the `edgeWeightInfluence` setting should be a number."}:!("scalingRatio"in t)||"number"==typeof t.scalingRatio&&t.scalingRatio>=0?"strongGravityMode"in t&&"boolean"!=typeof t.strongGravityMode?{message:"the `strongGravityMode` setting should be a boolean."}:!("gravity"in t)||"number"==typeof t.gravity&&t.gravity>=0?"slowDown"in t&&!("number"==typeof t.slowDown||t.slowDown>=0)?{message:"the `slowDown` setting should be a number >= 0."}:"barnesHutOptimize"in t&&"boolean"!=typeof t.barnesHutOptimize?{message:"the `barnesHutOptimize` setting should be a boolean."}:!("barnesHutTheta"in t)||"number"==typeof t.barnesHutTheta&&t.barnesHutTheta>=0?null:{message:"the `barnesHutTheta` setting should be a number >= 0."}:{message:"the `gravity` setting should be a number >= 0."}:{message:"the `scalingRatio` setting should be a number >= 0."}},e.graphToByteArrays=function(t,e){var n,r=t.order,i=t.size,o={},a=new Float32Array(10*r),s=new Float32Array(3*i);return n=0,t.forEachNode(function(t,e){o[t]=n,a[n]=e.x,a[n+1]=e.y,a[n+2]=0,a[n+3]=0,a[n+4]=0,a[n+5]=0,a[n+6]=1,a[n+7]=1,a[n+8]=e.size||1,a[n+9]=e.fixed?1:0,n+=10}),n=0,t.forEachEdge(function(t,r,i,u,c,l,d){var h=o[i],f=o[u],p=e(t,r,i,u,c,l,d);a[h+6]+=p,a[f+6]+=p,s[n]=h,s[n+1]=f,s[n+2]=p,n+=3}),{nodes:a,edges:s}},e.assignLayoutChanges=function(t,e,n){var r=0;t.updateEachNodeAttributes(function(t,i){return i.x=e[r],i.y=e[r+1],r+=10,n?n(t,i):i})},e.readGraphPositions=function(t,e){var n=0;t.forEachNode(function(t,r){e[n]=r.x,e[n+1]=r.y,n+=10})},e.collectLayoutChanges=function(t,e,n){for(var r=t.nodes(),i={},o=0,a=0,s=e.length;o<s;o+=10){if(n){var u=Object.assign({},t.getNodeAttributes(r[a]));u.x=e[o],u.y=e[o+1],u=n(r[a],u),i[r[a]]={x:u.x,y:u.y}}else i[r[a]]={x:e[o],y:e[o+1]};a++}return i},e.createWorker=function(t){var e=window.URL||window.webkitURL,n=t.toString(),r=e.createObjectURL(new Blob(["("+n+").call(this);"],{type:"text/javascript"})),i=new Worker(r);return e.revokeObjectURL(r),i}},2561:t=>{var e=10;t.exports=function(t,n,r){var i,o,a,s,u,c,l,d,h,f,p,m,g,y,v,w,b,A,E,C,S,_,M,N=n.length,I=r.length,L=t.adjustSizes,P=t.barnesHutTheta*t.barnesHutTheta,T=[];for(a=0;a<N;a+=e)n[a+4]=n[a+2],n[a+5]=n[a+3],n[a+2]=0,n[a+3]=0;if(t.outboundAttractionDistribution){for(p=0,a=0;a<N;a+=e)p+=n[a+6];p/=N/e}if(t.barnesHutOptimize){var F,O,R,x=1/0,D=-1/0,k=1/0,U=-1/0;for(a=0;a<N;a+=e)x=Math.min(x,n[a+0]),D=Math.max(D,n[a+0]),k=Math.min(k,n[a+1]),U=Math.max(U,n[a+1]);var G=D-x,V=U-k;for(G>V?U=(k-=(G-V)/2)+G:D=(x-=(V-G)/2)+V,T[0]=-1,T[1]=(x+D)/2,T[2]=(k+U)/2,T[3]=Math.max(D-x,U-k),T[4]=-1,T[5]=-1,T[6]=0,T[7]=0,T[8]=0,i=1,a=0;a<N;a+=e)for(o=0,R=3;;){if(!(T[o+5]>=0)){if(T[o+0]<0){T[o+0]=a;break}if(T[o+5]=9*i,d=T[o+3]/2,T[(h=T[o+5])+0]=-1,T[h+1]=T[o+1]-d,T[h+2]=T[o+2]-d,T[h+3]=d,T[h+4]=h+9,T[h+5]=-1,T[h+6]=0,T[h+7]=0,T[h+8]=0,T[(h+=9)+0]=-1,T[h+1]=T[o+1]-d,T[h+2]=T[o+2]+d,T[h+3]=d,T[h+4]=h+9,T[h+5]=-1,T[h+6]=0,T[h+7]=0,T[h+8]=0,T[(h+=9)+0]=-1,T[h+1]=T[o+1]+d,T[h+2]=T[o+2]-d,T[h+3]=d,T[h+4]=h+9,T[h+5]=-1,T[h+6]=0,T[h+7]=0,T[h+8]=0,T[(h+=9)+0]=-1,T[h+1]=T[o+1]+d,T[h+2]=T[o+2]+d,T[h+3]=d,T[h+4]=T[o+4],T[h+5]=-1,T[h+6]=0,T[h+7]=0,T[h+8]=0,i+=4,F=n[T[o+0]+0]<T[o+1]?n[T[o+0]+1]<T[o+2]?T[o+5]:T[o+5]+9:n[T[o+0]+1]<T[o+2]?T[o+5]+18:T[o+5]+27,T[o+6]=n[T[o+0]+6],T[o+7]=n[T[o+0]+0],T[o+8]=n[T[o+0]+1],T[F+0]=T[o+0],T[o+0]=-1,F===(O=n[a+0]<T[o+1]?n[a+1]<T[o+2]?T[o+5]:T[o+5]+9:n[a+1]<T[o+2]?T[o+5]+18:T[o+5]+27)){if(R--){o=F;continue}R=3;break}T[O+0]=a;break}F=n[a+0]<T[o+1]?n[a+1]<T[o+2]?T[o+5]:T[o+5]+9:n[a+1]<T[o+2]?T[o+5]+18:T[o+5]+27,T[o+7]=(T[o+7]*T[o+6]+n[a+0]*n[a+6])/(T[o+6]+n[a+6]),T[o+8]=(T[o+8]*T[o+6]+n[a+1]*n[a+6])/(T[o+6]+n[a+6]),T[o+6]+=n[a+6],o=F}}if(t.barnesHutOptimize){for(m=t.scalingRatio,a=0;a<N;a+=e)for(o=0;;)if(T[o+5]>=0){if(w=Math.pow(n[a+0]-T[o+7],2)+Math.pow(n[a+1]-T[o+8],2),4*(f=T[o+3])*f/w<P){if(g=n[a+0]-T[o+7],y=n[a+1]-T[o+8],!0===L?w>0?(b=m*n[a+6]*T[o+6]/w,n[a+2]+=g*b,n[a+3]+=y*b):w<0&&(b=-m*n[a+6]*T[o+6]/Math.sqrt(w),n[a+2]+=g*b,n[a+3]+=y*b):w>0&&(b=m*n[a+6]*T[o+6]/w,n[a+2]+=g*b,n[a+3]+=y*b),(o=T[o+4])<0)break;continue}o=T[o+5]}else if((c=T[o+0])>=0&&c!==a&&(w=(g=n[a+0]-n[c+0])*g+(y=n[a+1]-n[c+1])*y,!0===L?w>0?(b=m*n[a+6]*n[c+6]/w,n[a+2]+=g*b,n[a+3]+=y*b):w<0&&(b=-m*n[a+6]*n[c+6]/Math.sqrt(w),n[a+2]+=g*b,n[a+3]+=y*b):w>0&&(b=m*n[a+6]*n[c+6]/w,n[a+2]+=g*b,n[a+3]+=y*b)),(o=T[o+4])<0)break}else for(m=t.scalingRatio,s=0;s<N;s+=e)for(u=0;u<s;u+=e)g=n[s+0]-n[u+0],y=n[s+1]-n[u+1],!0===L?(w=Math.sqrt(g*g+y*y)-n[s+8]-n[u+8])>0?(b=m*n[s+6]*n[u+6]/w/w,n[s+2]+=g*b,n[s+3]+=y*b,n[u+2]-=g*b,n[u+3]-=y*b):w<0&&(b=100*m*n[s+6]*n[u+6],n[s+2]+=g*b,n[s+3]+=y*b,n[u+2]-=g*b,n[u+3]-=y*b):(w=Math.sqrt(g*g+y*y))>0&&(b=m*n[s+6]*n[u+6]/w/w,n[s+2]+=g*b,n[s+3]+=y*b,n[u+2]-=g*b,n[u+3]-=y*b);for(h=t.gravity/t.scalingRatio,m=t.scalingRatio,a=0;a<N;a+=e)b=0,g=n[a+0],y=n[a+1],w=Math.sqrt(Math.pow(g,2)+Math.pow(y,2)),t.strongGravityMode?w>0&&(b=m*n[a+6]*h):w>0&&(b=m*n[a+6]*h/w),n[a+2]-=g*b,n[a+3]-=y*b;for(m=1*(t.outboundAttractionDistribution?p:1),l=0;l<I;l+=3)s=r[l+0],u=r[l+1],d=r[l+2],v=Math.pow(d,t.edgeWeightInfluence),g=n[s+0]-n[u+0],y=n[s+1]-n[u+1],!0===L?(w=Math.sqrt(g*g+y*y)-n[s+8]-n[u+8],t.linLogMode?t.outboundAttractionDistribution?w>0&&(b=-m*v*Math.log(1+w)/w/n[s+6]):w>0&&(b=-m*v*Math.log(1+w)/w):t.outboundAttractionDistribution?w>0&&(b=-m*v/n[s+6]):w>0&&(b=-m*v)):(w=Math.sqrt(Math.pow(g,2)+Math.pow(y,2)),t.linLogMode?t.outboundAttractionDistribution?w>0&&(b=-m*v*Math.log(1+w)/w/n[s+6]):w>0&&(b=-m*v*Math.log(1+w)/w):t.outboundAttractionDistribution?(w=1,b=-m*v/n[s+6]):(w=1,b=-m*v)),w>0&&(n[s+2]+=g*b,n[s+3]+=y*b,n[u+2]-=g*b,n[u+3]-=y*b);if(!0===L)for(a=0;a<N;a+=e)1!==n[a+9]&&((A=Math.sqrt(Math.pow(n[a+2],2)+Math.pow(n[a+3],2)))>10&&(n[a+2]=10*n[a+2]/A,n[a+3]=10*n[a+3]/A),E=n[a+6]*Math.sqrt((n[a+4]-n[a+2])*(n[a+4]-n[a+2])+(n[a+5]-n[a+3])*(n[a+5]-n[a+3])),C=Math.sqrt((n[a+4]+n[a+2])*(n[a+4]+n[a+2])+(n[a+5]+n[a+3])*(n[a+5]+n[a+3]))/2,S=.1*Math.log(1+C)/(1+Math.sqrt(E)),_=n[a+0]+n[a+2]*(S/t.slowDown),n[a+0]=_,M=n[a+1]+n[a+3]*(S/t.slowDown),n[a+1]=M);else for(a=0;a<N;a+=e)1!==n[a+9]&&(E=n[a+6]*Math.sqrt((n[a+4]-n[a+2])*(n[a+4]-n[a+2])+(n[a+5]-n[a+3])*(n[a+5]-n[a+3])),C=Math.sqrt((n[a+4]+n[a+2])*(n[a+4]+n[a+2])+(n[a+5]+n[a+3])*(n[a+5]+n[a+3]))/2,S=n[a+7]*Math.log(1+C)/(1+Math.sqrt(E)),n[a+7]=Math.min(1,Math.sqrt(S*(Math.pow(n[a+2],2)+Math.pow(n[a+3],2))/(1+Math.sqrt(E)))),_=n[a+0]+n[a+2]*(S/t.slowDown),n[a+0]=_,M=n[a+1]+n[a+3]*(S/t.slowDown),n[a+1]=M);return{}}},5056:(t,e,n)=>{"use strict";t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},5072:t=>{"use strict";var e=[];function n(t){for(var n=-1,r=0;r<e.length;r++)if(e[r].identifier===t){n=r;break}return n}function r(t,r){for(var o={},a=[],s=0;s<t.length;s++){var u=t[s],c=r.base?u[0]+r.base:u[0],l=o[c]||0,d="".concat(c," ").concat(l);o[c]=l+1;var h=n(d),f={css:u[1],media:u[2],sourceMap:u[3],supports:u[4],layer:u[5]};if(-1!==h)e[h].references++,e[h].updater(f);else{var p=i(f,r);r.byIndex=s,e.splice(s,0,{identifier:d,updater:p,references:1})}a.push(d)}return a}function i(t,e){var n=e.domAPI(e);return n.update(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap&&e.supports===t.supports&&e.layer===t.layer)return;n.update(t=e)}else n.remove()}}t.exports=function(t,i){var o=r(t=t||[],i=i||{});return function(t){t=t||[];for(var a=0;a<o.length;a++){var s=n(o[a]);e[s].references--}for(var u=r(t,i),c=0;c<o.length;c++){var l=n(o[c]);0===e[l].references&&(e[l].updater(),e.splice(l,1))}o=u}}},5540:(t,e,n)=>{"use strict";t=n.hmd(t);var r,i=(r="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,function(t={}){var e,n,i=void 0!==t?t:{};i.ready=new Promise(function(t,r){e=t,n=r});var o,a=Object.assign({},i),s="object"==typeof window,u="function"==typeof importScripts,c=("object"==typeof process&&"object"==typeof process.versions&&process.versions.node,"");(s||u)&&(u?c=self.location.href:"undefined"!=typeof document&&document.currentScript&&(c=document.currentScript.src),r&&(c=r),c=0!==c.indexOf("blob:")?c.substr(0,c.replace(/[?#].*/,"").lastIndexOf("/")+1):"",u&&(o=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)})),i.print||console.log.bind(console);var l,d,h=i.printErr||console.warn.bind(console);Object.assign(i,a),a=null,i.arguments&&i.arguments,i.thisProgram&&i.thisProgram,i.quit&&i.quit,i.wasmBinary&&(l=i.wasmBinary),i.noExitRuntime,"object"!=typeof WebAssembly&&I("no native wasm support detected");var f,p,m,g=!1;function y(){var t=d.buffer;i.HEAP8=f=new Int8Array(t),i.HEAP16=new Int16Array(t),i.HEAP32=new Int32Array(t),i.HEAPU8=p=new Uint8Array(t),i.HEAPU16=new Uint16Array(t),i.HEAPU32=m=new Uint32Array(t),i.HEAPF32=new Float32Array(t),i.HEAPF64=new Float64Array(t)}var v=[],w=[],b=[];function A(t){v.unshift(t)}function E(t){b.unshift(t)}var C,S,_=0,M=null,N=null;function I(t){i.onAbort&&i.onAbort(t),h(t="Aborted("+t+")"),g=!0,t+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(t);throw n(e),e}function L(t){return t.startsWith("data:application/octet-stream;base64,")}function P(t){try{if(t==C&&l)return new Uint8Array(l);if(o)return o(t);throw"both async and sync fetching of the wasm failed"}catch(t){I(t)}}function T(t,e,n){return function(t){return l||!s&&!u||"function"!=typeof fetch?Promise.resolve().then(function(){return P(t)}):fetch(t,{credentials:"same-origin"}).then(function(e){if(!e.ok)throw"failed to load wasm binary file at '"+t+"'";return e.arrayBuffer()}).catch(function(){return P(t)})}(t).then(function(t){return WebAssembly.instantiate(t,e)}).then(function(t){return t}).then(n,function(t){h("failed to asynchronously prepare wasm: "+t),I(t)})}function F(t){for(;t.length>0;)t.shift()(i)}function O(t){this.excPtr=t,this.ptr=t-24,this.set_type=function(t){m[this.ptr+4>>2]=t},this.get_type=function(){return m[this.ptr+4>>2]},this.set_destructor=function(t){m[this.ptr+8>>2]=t},this.get_destructor=function(){return m[this.ptr+8>>2]},this.set_caught=function(t){t=t?1:0,f[this.ptr+12|0]=t},this.get_caught=function(){return 0!=f[this.ptr+12|0]},this.set_rethrown=function(t){t=t?1:0,f[this.ptr+13|0]=t},this.get_rethrown=function(){return 0!=f[this.ptr+13|0]},this.init=function(t,e){this.set_adjusted_ptr(0),this.set_type(t),this.set_destructor(e)},this.set_adjusted_ptr=function(t){m[this.ptr+16>>2]=t},this.get_adjusted_ptr=function(){return m[this.ptr+16>>2]},this.get_exception_ptr=function(){if(z(this.get_type()))return m[this.excPtr>>2];var t=this.get_adjusted_ptr();return 0!==t?t:this.excPtr}}function R(t){var e=d.buffer;try{return d.grow(t-e.byteLength+65535>>>16),y(),1}catch(t){}}function x(t){return i["_"+t]}L(C="wasmDbscan.wasm")||(S=C,C=i.locateFile?i.locateFile(S,c):c+S);var D="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function k(t,e,n,r,i){var o={string:t=>{var e=0;return null!=t&&0!==t&&(e=function(t){var e=function(t){for(var e=0,n=0;n<t.length;++n){var r=t.charCodeAt(n);r<=127?e++:r<=2047?e+=2:r>=55296&&r<=57343?(e+=4,++n):e+=3}return e}(t)+1,n=W(e);return function(t,e,n){!function(t,e,n,r){if(!(r>0))return 0;for(var i=n+r-1,o=0;o<t.length;++o){var a=t.charCodeAt(o);if(a>=55296&&a<=57343&&(a=65536+((1023&a)<<10)|1023&t.charCodeAt(++o)),a<=127){if(n>=i)break;e[n++]=a}else if(a<=2047){if(n+1>=i)break;e[n++]=192|a>>6,e[n++]=128|63&a}else if(a<=65535){if(n+2>=i)break;e[n++]=224|a>>12,e[n++]=128|a>>6&63,e[n++]=128|63&a}else{if(n+3>=i)break;e[n++]=240|a>>18,e[n++]=128|a>>12&63,e[n++]=128|a>>6&63,e[n++]=128|63&a}}e[n]=0}(t,p,e,n)}(t,n,e),n}(t)),e},array:t=>{var e,n,r=W(t.length);return e=t,n=r,f.set(e,n),r}},a=x(t),s=[],u=0;if(r)for(var c=0;c<r.length;c++){var l=o[n[c]];l?(0===u&&(u=V()),s[c]=l(r[c])):s[c]=r[c]}var d=a.apply(null,s);return function(t){return 0!==u&&B(u),function(t){return"string"===e?(n=t)?function(t,e,n){for(var r=e+n,i=e;t[i]&&!(i>=r);)++i;if(i-e>16&&t.buffer&&D)return D.decode(t.subarray(e,i));for(var o="";e<i;){var a=t[e++];if(128&a){var s=63&t[e++];if(192!=(224&a)){var u=63&t[e++];if((a=224==(240&a)?(15&a)<<12|s<<6|u:(7&a)<<18|s<<12|u<<6|63&t[e++])<65536)o+=String.fromCharCode(a);else{var c=a-65536;o+=String.fromCharCode(55296|c>>10,56320|1023&c)}}else o+=String.fromCharCode((31&a)<<6|s)}else o+=String.fromCharCode(a)}return o}(p,n,r):"":"boolean"===e?Boolean(t):t;var n,r}(t)}(d)}var U,G={__cxa_throw:function(t,e,n){throw new O(t).init(e,n),t},abort:function(){I("")},emscripten_memcpy_big:function(t,e,n){p.copyWithin(t,e,e+n)},emscripten_resize_heap:function(t){var e=p.length,n=2147483648;if((t>>>=0)>n)return!1;let r=(t,e)=>t+(e-t%e)%e;for(var i=1;i<=4;i*=2){var o=e*(1+.2/i);if(o=Math.min(o,t+100663296),R(Math.min(n,r(Math.max(t,o),65536))))return!0}return!1}},V=(function(){var t,e,r,o,a={env:G,wasi_snapshot_preview1:G};function s(t,e){var n,r=t.exports;return i.asm=r,d=i.asm.memory,y(),i.asm.__indirect_function_table,n=i.asm.__wasm_call_ctors,w.unshift(n),function(){if(_--,i.monitorRunDependencies&&i.monitorRunDependencies(_),0==_&&(null!==M&&(clearInterval(M),M=null),N)){var t=N;N=null,t()}}(),r}if(_++,i.monitorRunDependencies&&i.monitorRunDependencies(_),i.instantiateWasm)try{return i.instantiateWasm(a,s)}catch(t){h("Module.instantiateWasm callback failed with error: "+t),n(t)}(t=l,e=C,r=a,o=function(t){s(t.instance)},t||"function"!=typeof WebAssembly.instantiateStreaming||L(e)||"function"!=typeof fetch?T(e,r,o):fetch(e,{credentials:"same-origin"}).then(function(t){return WebAssembly.instantiateStreaming(t,r).then(o,function(t){return h("wasm streaming compile failed: "+t),h("falling back to ArrayBuffer instantiation"),T(e,r,o)})})).catch(n)}(),i._dbscan=function(){return(i._dbscan=i.asm.dbscan).apply(null,arguments)},i._malloc=function(){return(i._malloc=i.asm.malloc).apply(null,arguments)},i._free=function(){return(i._free=i.asm.free).apply(null,arguments)},function(){return(V=i.asm.stackSave).apply(null,arguments)}),B=function(){return(B=i.asm.stackRestore).apply(null,arguments)},W=function(){return(W=i.asm.stackAlloc).apply(null,arguments)},z=function(){return(z=i.asm.__cxa_is_pointer_type).apply(null,arguments)};function H(){function t(){U||(U=!0,i.calledRun=!0,g||(F(w),e(i),i.onRuntimeInitialized&&i.onRuntimeInitialized(),function(){if(i.postRun)for("function"==typeof i.postRun&&(i.postRun=[i.postRun]);i.postRun.length;)E(i.postRun.shift());F(b)}()))}_>0||(function(){if(i.preRun)for("function"==typeof i.preRun&&(i.preRun=[i.preRun]);i.preRun.length;)A(i.preRun.shift());F(v)}(),_>0||(i.setStatus?(i.setStatus("Running..."),setTimeout(function(){setTimeout(function(){i.setStatus("")},1),t()},1)):t()))}if(i.ccall=k,i.cwrap=function(t,e,n,r){var i=!n||n.every(t=>"number"===t||"boolean"===t);return"string"!==e&&i&&!r?x(t):function(){return k(t,e,n,arguments)}},N=function t(){U||H(),U||(N=t)},i.preInit)for("function"==typeof i.preInit&&(i.preInit=[i.preInit]);i.preInit.length>0;)i.preInit.pop()();return H(),t.ready});"object"==typeof exports?t.exports=i:"function"==typeof define&&n.amdO?define([],function(){return i}):"object"==typeof exports&&(exports.exportCppDbscanLib=i)},6314:t=>{"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map(function(e){var n="",r=void 0!==e[5];return e[4]&&(n+="@supports (".concat(e[4],") {")),e[2]&&(n+="@media ".concat(e[2]," {")),r&&(n+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),n+=t(e),r&&(n+="}"),e[2]&&(n+="}"),e[4]&&(n+="}"),n}).join("")},e.i=function(t,n,r,i,o){"string"==typeof t&&(t=[[null,t,void 0]]);var a={};if(r)for(var s=0;s<this.length;s++){var u=this[s][0];null!=u&&(a[u]=!0)}for(var c=0;c<t.length;c++){var l=[].concat(t[c]);r&&a[l[0]]||(void 0!==o&&(void 0===l[5]||(l[1]="@layer".concat(l[5].length>0?" ".concat(l[5]):""," {").concat(l[1],"}")),l[5]=o),n&&(l[2]?(l[1]="@media ".concat(l[2]," {").concat(l[1],"}"),l[2]=n):l[2]=n),i&&(l[4]?(l[1]="@supports (".concat(l[4],") {").concat(l[1],"}"),l[4]=i):l[4]="".concat(i)),e.push(l))}},e}},6572:function(t){var e;t.exports=(e=function(t,e){var n=Array.prototype.concat,r=Array.prototype.slice,i=Object.prototype.toString;function o(e,n){var r=e>n?e:n;return t.pow(10,17-~~(t.log(r>0?r:-r)*t.LOG10E))}var a=Array.isArray||function(t){return"[object Array]"===i.call(t)};function s(t){return"[object Function]"===i.call(t)}function u(t){return"number"==typeof t&&t-t===0}function c(){return new c._init(arguments)}function l(){return 0}function d(){return 1}function h(t,e){return t===e?1:0}c.fn=c.prototype,c._init=function(t){if(a(t[0]))if(a(t[0][0])){s(t[1])&&(t[0]=c.map(t[0],t[1]));for(var e=0;e<t[0].length;e++)this[e]=t[0][e];this.length=t[0].length}else this[0]=s(t[1])?c.map(t[0],t[1]):t[0],this.length=1;else if(u(t[0]))this[0]=c.seq.apply(null,t),this.length=1;else{if(t[0]instanceof c)return c(t[0].toArray());this[0]=[],this.length=1}return this},c._init.prototype=c.prototype,c._init.constructor=c,c.utils={calcRdx:o,isArray:a,isFunction:s,isNumber:u,toVector:function(t){return n.apply([],t)}},c._random_fn=t.random,c.setRandom=function(t){if("function"!=typeof t)throw new TypeError("fn is not a function");c._random_fn=t},c.extend=function(t){var e,n;if(1===arguments.length){for(n in t)c[n]=t[n];return this}for(e=1;e<arguments.length;e++)for(n in arguments[e])t[n]=arguments[e][n];return t},c.rows=function(t){return t.length||1},c.cols=function(t){return t[0].length||1},c.dimensions=function(t){return{rows:c.rows(t),cols:c.cols(t)}},c.row=function(t,e){return a(e)?e.map(function(e){return c.row(t,e)}):t[e]},c.rowa=function(t,e){return c.row(t,e)},c.col=function(t,e){if(a(e)){var n=c.arange(t.length).map(function(){return new Array(e.length)});return e.forEach(function(e,r){c.arange(t.length).forEach(function(i){n[i][r]=t[i][e]})}),n}for(var r=new Array(t.length),i=0;i<t.length;i++)r[i]=[t[i][e]];return r},c.cola=function(t,e){return c.col(t,e).map(function(t){return t[0]})},c.diag=function(t){for(var e=c.rows(t),n=new Array(e),r=0;r<e;r++)n[r]=[t[r][r]];return n},c.antidiag=function(t){for(var e=c.rows(t)-1,n=new Array(e),r=0;e>=0;e--,r++)n[r]=[t[r][e]];return n},c.transpose=function(t){var e,n,r,i,o,s=[];for(a(t[0])||(t=[t]),n=t.length,r=t[0].length,o=0;o<r;o++){for(e=new Array(n),i=0;i<n;i++)e[i]=t[i][o];s.push(e)}return 1===s.length?s[0]:s},c.map=function(t,e,n){var r,i,o,s,u;for(a(t[0])||(t=[t]),i=t.length,o=t[0].length,s=n?t:new Array(i),r=0;r<i;r++)for(s[r]||(s[r]=new Array(o)),u=0;u<o;u++)s[r][u]=e(t[r][u],r,u);return 1===s.length?s[0]:s},c.cumreduce=function(t,e,n){var r,i,o,s,u;for(a(t[0])||(t=[t]),i=t.length,o=t[0].length,s=n?t:new Array(i),r=0;r<i;r++)for(s[r]||(s[r]=new Array(o)),o>0&&(s[r][0]=t[r][0]),u=1;u<o;u++)s[r][u]=e(s[r][u-1],t[r][u]);return 1===s.length?s[0]:s},c.alter=function(t,e){return c.map(t,e,!0)},c.create=function(t,e,n){var r,i,o=new Array(t);for(s(e)&&(n=e,e=t),r=0;r<t;r++)for(o[r]=new Array(e),i=0;i<e;i++)o[r][i]=n(r,i);return o},c.zeros=function(t,e){return u(e)||(e=t),c.create(t,e,l)},c.ones=function(t,e){return u(e)||(e=t),c.create(t,e,d)},c.rand=function(t,e){return u(e)||(e=t),c.create(t,e,c._random_fn)},c.identity=function(t,e){return u(e)||(e=t),c.create(t,e,h)},c.symmetric=function(t){var e,n,r=t.length;if(t.length!==t[0].length)return!1;for(e=0;e<r;e++)for(n=0;n<r;n++)if(t[n][e]!==t[e][n])return!1;return!0},c.clear=function(t){return c.alter(t,l)},c.seq=function(t,e,n,r){s(r)||(r=!1);var i,a=[],u=o(t,e),c=(e*u-t*u)/((n-1)*u),l=t;for(i=0;l<=e&&i<n;l=(t*u+c*u*++i)/u)a.push(r?r(l,i):l);return a},c.arange=function(t,n,r){var i,o=[];if(r=r||1,n===e&&(n=t,t=0),t===n||0===r)return[];if(t<n&&r<0)return[];if(t>n&&r>0)return[];if(r>0)for(i=t;i<n;i+=r)o.push(i);else for(i=t;i>n;i+=r)o.push(i);return o},c.slice=function(){function t(t,n,r,i){var o,a=[],s=t.length;if(n===e&&r===e&&i===e)return c.copy(t);if(i=i||1,(n=(n=n||0)>=0?n:s+n)===(r=(r=r||t.length)>=0?r:s+r)||0===i)return[];if(n<r&&i<0)return[];if(n>r&&i>0)return[];if(i>0)for(o=n;o<r;o+=i)a.push(t[o]);else for(o=n;o>r;o+=i)a.push(t[o]);return a}return function(e,n){var r,i;return u((n=n||{}).row)?u(n.col)?e[n.row][n.col]:t(c.rowa(e,n.row),(r=n.col||{}).start,r.end,r.step):u(n.col)?t(c.cola(e,n.col),(i=n.row||{}).start,i.end,i.step):(i=n.row||{},r=n.col||{},t(e,i.start,i.end,i.step).map(function(e){return t(e,r.start,r.end,r.step)}))}}(),c.sliceAssign=function(n,r,i){var o,a;if(u(r.row)){if(u(r.col))return n[r.row][r.col]=i;r.col=r.col||{},r.col.start=r.col.start||0,r.col.end=r.col.end||n[0].length,r.col.step=r.col.step||1,o=c.arange(r.col.start,t.min(n.length,r.col.end),r.col.step);var s=r.row;return o.forEach(function(t,e){n[s][t]=i[e]}),n}if(u(r.col)){r.row=r.row||{},r.row.start=r.row.start||0,r.row.end=r.row.end||n.length,r.row.step=r.row.step||1,a=c.arange(r.row.start,t.min(n[0].length,r.row.end),r.row.step);var l=r.col;return a.forEach(function(t,e){n[t][l]=i[e]}),n}return i[0].length===e&&(i=[i]),r.row.start=r.row.start||0,r.row.end=r.row.end||n.length,r.row.step=r.row.step||1,r.col.start=r.col.start||0,r.col.end=r.col.end||n[0].length,r.col.step=r.col.step||1,a=c.arange(r.row.start,t.min(n.length,r.row.end),r.row.step),o=c.arange(r.col.start,t.min(n[0].length,r.col.end),r.col.step),a.forEach(function(t,e){o.forEach(function(r,o){n[t][r]=i[e][o]})}),n},c.diagonal=function(t){var e=c.zeros(t.length,t.length);return t.forEach(function(t,n){e[n][n]=t}),e},c.copy=function(t){return t.map(function(t){return u(t)?t:t.map(function(t){return t})})};var f=c.prototype;return f.length=0,f.push=Array.prototype.push,f.sort=Array.prototype.sort,f.splice=Array.prototype.splice,f.slice=Array.prototype.slice,f.toArray=function(){return this.length>1?r.call(this):r.call(this)[0]},f.map=function(t,e){return c(c.map(this,t,e))},f.cumreduce=function(t,e){return c(c.cumreduce(this,t,e))},f.alter=function(t){return c.alter(this,t),this},function(t){for(var e=0;e<t.length;e++)(function(t){f[t]=function(e){var n,r=this;return e?(setTimeout(function(){e.call(r,f[t].call(r))}),this):(n=c[t](this),a(n)?c(n):n)}})(t[e])}("transpose clear symmetric rows cols dimensions diag antidiag".split(" ")),function(t){for(var e=0;e<t.length;e++)(function(t){f[t]=function(e,n){var r=this;return n?(setTimeout(function(){n.call(r,f[t].call(r,e))}),this):c(c[t](this,e))}})(t[e])}("row col".split(" ")),function(t){for(var e=0;e<t.length;e++)(function(t){f[t]=function(){return c(c[t].apply(null,arguments))}})(t[e])}("create zeros ones rand identity".split(" ")),c}(Math),function(t,e){var n=t.utils.isFunction;function r(t,e){return t-e}function i(t,n,r){return e.max(n,e.min(t,r))}t.sum=function(t){for(var e=0,n=t.length;--n>=0;)e+=t[n];return e},t.sumsqrd=function(t){for(var e=0,n=t.length;--n>=0;)e+=t[n]*t[n];return e},t.sumsqerr=function(e){for(var n,r=t.mean(e),i=0,o=e.length;--o>=0;)i+=(n=e[o]-r)*n;return i},t.sumrow=function(t){for(var e=0,n=t.length;--n>=0;)e+=t[n];return e},t.product=function(t){for(var e=1,n=t.length;--n>=0;)e*=t[n];return e},t.min=function(t){for(var e=t[0],n=0;++n<t.length;)t[n]<e&&(e=t[n]);return e},t.max=function(t){for(var e=t[0],n=0;++n<t.length;)t[n]>e&&(e=t[n]);return e},t.unique=function(t){for(var e={},n=[],r=0;r<t.length;r++)e[t[r]]||(e[t[r]]=!0,n.push(t[r]));return n},t.mean=function(e){return t.sum(e)/e.length},t.meansqerr=function(e){return t.sumsqerr(e)/e.length},t.geomean=function(n){var r=n.map(e.log),i=t.mean(r);return e.exp(i)},t.median=function(t){var e=t.length,n=t.slice().sort(r);return 1&e?n[e/2|0]:(n[e/2-1]+n[e/2])/2},t.cumsum=function(e){return t.cumreduce(e,function(t,e){return t+e})},t.cumprod=function(e){return t.cumreduce(e,function(t,e){return t*e})},t.diff=function(t){var e,n=[],r=t.length;for(e=1;e<r;e++)n.push(t[e]-t[e-1]);return n},t.rank=function(t){var e,n=[],i={};for(e=0;e<t.length;e++)i[u=t[e]]?i[u]++:(i[u]=1,n.push(u));var o=n.sort(r),a={},s=1;for(e=0;e<o.length;e++){var u,c=i[u=o[e]],l=(s+(s+c-1))/2;a[u]=l,s+=c}return t.map(function(t){return a[t]})},t.mode=function(t){var e,n=t.length,i=t.slice().sort(r),o=1,a=0,s=0,u=[];for(e=0;e<n;e++)i[e]===i[e+1]?o++:(o>a?(u=[i[e]],a=o,s=0):o===a&&(u.push(i[e]),s++),o=1);return 0===s?u[0]:u},t.range=function(e){return t.max(e)-t.min(e)},t.variance=function(e,n){return t.sumsqerr(e)/(e.length-(n?1:0))},t.pooledvariance=function(e){return e.reduce(function(e,n){return e+t.sumsqerr(n)},0)/(e.reduce(function(t,e){return t+e.length},0)-e.length)},t.deviation=function(e){for(var n=t.mean(e),r=e.length,i=new Array(r),o=0;o<r;o++)i[o]=e[o]-n;return i},t.stdev=function(n,r){return e.sqrt(t.variance(n,r))},t.pooledstdev=function(n){return e.sqrt(t.pooledvariance(n))},t.meandev=function(n){for(var r=t.mean(n),i=[],o=n.length-1;o>=0;o--)i.push(e.abs(n[o]-r));return t.mean(i)},t.meddev=function(n){for(var r=t.median(n),i=[],o=n.length-1;o>=0;o--)i.push(e.abs(n[o]-r));return t.median(i)},t.coeffvar=function(e){return t.stdev(e)/t.mean(e)},t.quartiles=function(t){var n=t.length,i=t.slice().sort(r);return[i[e.round(n/4)-1],i[e.round(n/2)-1],i[e.round(3*n/4)-1]]},t.quantiles=function(t,n,o,a){var s,u,c,l,d,h=t.slice().sort(r),f=[n.length],p=t.length;for(void 0===o&&(o=3/8),void 0===a&&(a=3/8),s=0;s<n.length;s++)c=p*(u=n[s])+(o+u*(1-o-a)),l=e.floor(i(c,1,p-1)),d=i(c-l,0,1),f[s]=(1-d)*h[l-1]+d*h[l];return f},t.percentile=function(t,e,n){var i=t.slice().sort(r),o=e*(i.length+(n?1:-1))+(n?0:1),a=parseInt(o),s=o-a;return a+1<i.length?i[a-1]+s*(i[a]-i[a-1]):i[a-1]},t.percentileOfScore=function(t,e,n){var r,i,o=0,a=t.length,s=!1;for("strict"===n&&(s=!0),i=0;i<a;i++)r=t[i],(s&&r<e||!s&&r<=e)&&o++;return o/a},t.histogram=function(n,r){r=r||4;var i,o=t.min(n),a=(t.max(n)-o)/r,s=n.length,u=[];for(i=0;i<r;i++)u[i]=0;for(i=0;i<s;i++)u[e.min(e.floor((n[i]-o)/a),r-1)]+=1;return u},t.covariance=function(e,n){var r,i=t.mean(e),o=t.mean(n),a=e.length,s=new Array(a);for(r=0;r<a;r++)s[r]=(e[r]-i)*(n[r]-o);return t.sum(s)/(a-1)},t.corrcoeff=function(e,n){return t.covariance(e,n)/t.stdev(e,1)/t.stdev(n,1)},t.spearmancoeff=function(e,n){return e=t.rank(e),n=t.rank(n),t.corrcoeff(e,n)},t.stanMoment=function(n,r){for(var i=t.mean(n),o=t.stdev(n),a=n.length,s=0,u=0;u<a;u++)s+=e.pow((n[u]-i)/o,r);return s/n.length},t.skewness=function(e){return t.stanMoment(e,3)},t.kurtosis=function(e){return t.stanMoment(e,4)-3};var o=t.prototype;!function(e){for(var r=0;r<e.length;r++)(function(e){o[e]=function(r,i){var a=[],s=0,u=this;if(n(r)&&(i=r,r=!1),i)return setTimeout(function(){i.call(u,o[e].call(u,r))}),this;if(this.length>1){for(u=!0===r?this:this.transpose();s<u.length;s++)a[s]=t[e](u[s]);return a}return t[e](this[0],r)}})(e[r])}("cumsum cumprod".split(" ")),function(e){for(var r=0;r<e.length;r++)(function(e){o[e]=function(r,i){var a=[],s=0,u=this;if(n(r)&&(i=r,r=!1),i)return setTimeout(function(){i.call(u,o[e].call(u,r))}),this;if(this.length>1){for("sumrow"!==e&&(u=!0===r?this:this.transpose());s<u.length;s++)a[s]=t[e](u[s]);return!0===r?t[e](t.utils.toVector(a)):a}return t[e](this[0],r)}})(e[r])}("sum sumsqrd sumsqerr sumrow product min max unique mean meansqerr geomean median diff rank mode range variance deviation stdev meandev meddev coeffvar quartiles histogram skewness kurtosis".split(" ")),function(e){for(var r=0;r<e.length;r++)(function(e){o[e]=function(){var r,i=[],a=0,s=this,u=Array.prototype.slice.call(arguments);if(n(u[u.length-1])){r=u[u.length-1];var c=u.slice(0,u.length-1);return setTimeout(function(){r.call(s,o[e].apply(s,c))}),this}r=void 0;var l=function(n){return t[e].apply(s,[n].concat(u))};if(this.length>1){for(s=s.transpose();a<s.length;a++)i[a]=l(s[a]);return i}return l(this[0])}})(e[r])}("quantiles percentileOfScore".split(" "))}(e,Math),function(t,e){t.gammaln=function(t){var n,r,i,o=0,a=[76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18],s=1.000000000190015;for(i=(r=n=t)+5.5,i-=(n+.5)*e.log(i);o<6;o++)s+=a[o]/++r;return e.log(2.5066282746310007*s/n)-i},t.loggam=function(t){var n,r,i,o,a,s,u,c=[.08333333333333333,-.002777777777777778,.0007936507936507937,-.0005952380952380952,.0008417508417508418,-.001917526917526918,.00641025641025641,-.02955065359477124,.1796443723688307,-1.3924322169059];if(n=t,u=0,1==t||2==t)return 0;for(t<=7&&(n=t+(u=e.floor(7-t))),r=1/(n*n),i=2*e.PI,a=c[9],s=8;s>=0;s--)a*=r,a+=c[s];if(o=a/n+.5*e.log(i)+(n-.5)*e.log(n)-n,t<=7)for(s=1;s<=u;s++)o-=e.log(n-1),n-=1;return o},t.gammafn=function(t){var n,r,i,o,a=[-1.716185138865495,24.76565080557592,-379.80425647094563,629.3311553128184,866.9662027904133,-31451.272968848367,-36144.413418691176,66456.14382024054],s=[-30.8402300119739,315.35062697960416,-1015.1563674902192,-3107.771671572311,22538.11842098015,4755.846277527881,-134659.9598649693,-115132.2596755535],u=!1,c=0,l=0,d=0,h=t;if(t>171.6243769536076)return 1/0;if(h<=0){if(!(o=h%1+36e-17))return 1/0;u=(1&h?-1:1)*e.PI/e.sin(e.PI*o),h=1-h}for(i=h,r=h<1?h++:(h-=c=(0|h)-1)-1,n=0;n<8;++n)d=(d+a[n])*r,l=l*r+s[n];if(o=d/l+1,i<h)o/=i;else if(i>h)for(n=0;n<c;++n)o*=h,h++;return u&&(o=u/o),o},t.gammap=function(e,n){return t.lowRegGamma(e,n)*t.gammafn(e)},t.lowRegGamma=function(n,r){var i,o=t.gammaln(n),a=n,s=1/n,u=s,c=r+1-n,l=1/1e-30,d=1/c,h=d,f=1,p=-~(8.5*e.log(n>=1?n:1/n)+.4*n+17);if(r<0||n<=0)return NaN;if(r<n+1){for(;f<=p;f++)s+=u*=r/++a;return s*e.exp(-r+n*e.log(r)-o)}for(;f<=p;f++)h*=(d=1/(d=(i=-f*(f-n))*d+(c+=2)))*(l=c+i/l);return 1-h*e.exp(-r+n*e.log(r)-o)},t.factorialln=function(e){return e<0?NaN:t.gammaln(e+1)},t.factorial=function(e){return e<0?NaN:t.gammafn(e+1)},t.combination=function(n,r){return n>170||r>170?e.exp(t.combinationln(n,r)):t.factorial(n)/t.factorial(r)/t.factorial(n-r)},t.combinationln=function(e,n){return t.factorialln(e)-t.factorialln(n)-t.factorialln(e-n)},t.permutation=function(e,n){return t.factorial(e)/t.factorial(e-n)},t.betafn=function(n,r){if(!(n<=0||r<=0))return n+r>170?e.exp(t.betaln(n,r)):t.gammafn(n)*t.gammafn(r)/t.gammafn(n+r)},t.betaln=function(e,n){return t.gammaln(e)+t.gammaln(n)-t.gammaln(e+n)},t.betacf=function(t,n,r){var i,o,a,s,u=1e-30,c=1,l=n+r,d=n+1,h=n-1,f=1,p=1-l*t/d;for(e.abs(p)<u&&(p=u),s=p=1/p;c<=100&&(p=1+(o=c*(r-c)*t/((h+(i=2*c))*(n+i)))*p,e.abs(p)<u&&(p=u),f=1+o/f,e.abs(f)<u&&(f=u),s*=(p=1/p)*f,p=1+(o=-(n+c)*(l+c)*t/((n+i)*(d+i)))*p,e.abs(p)<u&&(p=u),f=1+o/f,e.abs(f)<u&&(f=u),s*=a=(p=1/p)*f,!(e.abs(a-1)<3e-7));c++);return s},t.gammapinv=function(n,r){var i,o,a,s,u,c,l=0,d=r-1,h=t.gammaln(r);if(n>=1)return e.max(100,r+100*e.sqrt(r));if(n<=0)return 0;for(r>1?(u=e.log(d),c=e.exp(d*(u-1)-h),s=n<.5?n:1-n,i=(2.30753+.27061*(o=e.sqrt(-2*e.log(s))))/(1+o*(.99229+.04481*o))-o,n<.5&&(i=-i),i=e.max(.001,r*e.pow(1-1/(9*r)-i/(3*e.sqrt(r)),3))):i=n<(o=1-r*(.253+.12*r))?e.pow(n/o,1/r):1-e.log(1-(n-o)/(1-o));l<12;l++){if(i<=0)return 0;if((i-=o=(a=(t.lowRegGamma(r,i)-n)/(o=r>1?c*e.exp(-(i-d)+d*(e.log(i)-u)):e.exp(-i+d*e.log(i)-h)))/(1-.5*e.min(1,a*((r-1)/i-1))))<=0&&(i=.5*(i+o)),e.abs(o)<1e-8*i)break}return i},t.erf=function(t){var n,r,i,o,a=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,1.5626441722e-8,-8.5238095915e-8,6.529054439e-9,5.059343495e-9,-9.91364156e-10,-2.27365122e-10,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18,-1523e-18,-94e-18,121e-18,-28e-18],s=a.length-1,u=!1,c=0,l=0;for(t<0&&(t=-t,u=!0),r=4*(n=2/(2+t))-2;s>0;s--)i=c,c=r*c-l+a[s],l=i;return o=n*e.exp(-t*t+.5*(a[0]+r*c)-l),u?o-1:1-o},t.erfc=function(e){return 1-t.erf(e)},t.erfcinv=function(n){var r,i,o,a,s=0;if(n>=2)return-100;if(n<=0)return 100;for(a=n<1?n:2-n,r=-.70711*((2.30753+.27061*(o=e.sqrt(-2*e.log(a/2))))/(1+o*(.99229+.04481*o))-o);s<2;s++)r+=(i=t.erfc(r)-a)/(1.1283791670955126*e.exp(-r*r)-r*i);return n<1?r:-r},t.ibetainv=function(n,r,i){var o,a,s,u,c,l,d,h,f,p,m=r-1,g=i-1,y=0;if(n<=0)return 0;if(n>=1)return 1;for(r>=1&&i>=1?(s=n<.5?n:1-n,l=(2.30753+.27061*(u=e.sqrt(-2*e.log(s))))/(1+u*(.99229+.04481*u))-u,n<.5&&(l=-l),d=(l*l-3)/6,h=2/(1/(2*r-1)+1/(2*i-1)),f=l*e.sqrt(d+h)/h-(1/(2*i-1)-1/(2*r-1))*(d+5/6-2/(3*h)),l=r/(r+i*e.exp(2*f))):(o=e.log(r/(r+i)),a=e.log(i/(r+i)),l=n<(u=e.exp(r*o)/r)/(f=u+(c=e.exp(i*a)/i))?e.pow(r*f*n,1/r):1-e.pow(i*f*(1-n),1/i)),p=-t.gammaln(r)-t.gammaln(i)+t.gammaln(r+i);y<10;y++){if(0===l||1===l)return l;if((l-=u=(c=(t.ibeta(l,r,i)-n)/(u=e.exp(m*e.log(l)+g*e.log(1-l)+p)))/(1-.5*e.min(1,c*(m/l-g/(1-l)))))<=0&&(l=.5*(l+u)),l>=1&&(l=.5*(l+u+1)),e.abs(u)<1e-8*l&&y>0)break}return l},t.ibeta=function(n,r,i){var o=0===n||1===n?0:e.exp(t.gammaln(r+i)-t.gammaln(r)-t.gammaln(i)+r*e.log(n)+i*e.log(1-n));return!(n<0||n>1)&&(n<(r+1)/(r+i+2)?o*t.betacf(n,r,i)/r:1-o*t.betacf(1-n,i,r)/i)},t.randn=function(n,r){var i,o,a,s,u;if(r||(r=n),n)return t.create(n,r,function(){return t.randn()});do{i=t._random_fn(),o=1.7156*(t._random_fn()-.5),u=(a=i-.449871)*a+(s=e.abs(o)+.386595)*(.196*s-.25472*a)}while(u>.27597&&(u>.27846||o*o>-4*e.log(i)*i*i));return o/i},t.randg=function(n,r,i){var o,a,s,u,c,l,d=n;if(i||(i=r),n||(n=1),r)return(l=t.zeros(r,i)).alter(function(){return t.randg(n)}),l;n<1&&(n+=1),o=n-1/3,a=1/e.sqrt(9*o);do{do{u=1+a*(c=t.randn())}while(u<=0);u*=u*u,s=t._random_fn()}while(s>1-.331*e.pow(c,4)&&e.log(s)>.5*c*c+o*(1-u+e.log(u)));if(n==d)return o*u;do{s=t._random_fn()}while(0===s);return e.pow(s,1/d)*o*u},function(e){for(var n=0;n<e.length;n++)(function(e){t.fn[e]=function(){return t(t.map(this,function(n){return t[e](n)}))}})(e[n])}("gammaln gammafn factorial factorialln".split(" ")),function(e){for(var n=0;n<e.length;n++)(function(e){t.fn[e]=function(){return t(t[e].apply(null,arguments))}})(e[n])}("randn".split(" "))}(e,Math),function(t,e){function n(t,n,r,i){for(var o,a=0,s=1,u=1,c=1,l=0,d=0;e.abs((u-d)/u)>i;)d=u,s=c+(o=-(n+l)*(n+r+l)*t/(n+2*l)/(n+2*l+1))*s,u=(a=u+o*a)+(o=(l+=1)*(r-l)*t/(n+2*l-1)/(n+2*l))*u,a/=c=s+o*c,s/=c,u/=c,c=1;return u/n}function r(n,r,i){var o=[.9815606342467192,.9041172563704749,.7699026741943047,.5873179542866175,.3678314989981802,.1252334085114689],a=[.04717533638651183,.10693932599531843,.16007832854334622,.20316742672306592,.2334925365383548,.24914704581340277],s=.5*n;if(s>=8)return 1;var u,c=2*t.normal.cdf(s,0,1,1,0)-1;c=c>=e.exp(-50/i)?e.pow(c,i):0;for(var l=s,d=(8-s)/(u=n>3?2:3),h=l+d,f=0,p=i-1,m=1;m<=u;m++){for(var g=0,y=.5*(h+l),v=.5*(h-l),w=1;w<=12;w++){var b,A=y+v*(6<w?o[(b=12-w+1)-1]:-o[(b=w)-1]),E=A*A;if(E>60)break;var C=2*t.normal.cdf(A,0,1,1,0)*.5-2*t.normal.cdf(A,n,1,1,0)*.5;C>=e.exp(-30/p)&&(g+=C=a[b-1]*e.exp(-.5*E)*e.pow(C,p))}f+=g*=2*v*i/e.sqrt(2*e.PI),l=h,h+=d}return(c+=f)<=e.exp(-30/r)?0:(c=e.pow(c,r))>=1?1:c}!function(e){for(var n=0;n<e.length;n++)(function(e){t[e]=function t(e,n,r){return this instanceof t?(this._a=e,this._b=n,this._c=r,this):new t(e,n,r)},t.fn[e]=function(n,r,i){var o=t[e](n,r,i);return o.data=this,o},t[e].prototype.sample=function(n){var r=this._a,i=this._b,o=this._c;return n?t.alter(n,function(){return t[e].sample(r,i,o)}):t[e].sample(r,i,o)},function(n){for(var r=0;r<n.length;r++)(function(n){t[e].prototype[n]=function(r){var i=this._a,o=this._b,a=this._c;return r||0===r||(r=this.data),"number"!=typeof r?t.fn.map.call(r,function(r){return t[e][n](r,i,o,a)}):t[e][n](r,i,o,a)}})(n[r])}("pdf cdf inv".split(" ")),function(n){for(var r=0;r<n.length;r++)(function(n){t[e].prototype[n]=function(){return t[e][n](this._a,this._b,this._c)}})(n[r])}("mean median mode variance".split(" "))})(e[n])}("beta centralF cauchy chisquare exponential gamma invgamma kumaraswamy laplace lognormal noncentralt normal pareto studentt weibull uniform binomial negbin hypgeom poisson triangular tukey arcsine".split(" ")),t.extend(t.beta,{pdf:function(n,r,i){return n>1||n<0?0:1==r&&1==i?1:r<512&&i<512?e.pow(n,r-1)*e.pow(1-n,i-1)/t.betafn(r,i):e.exp((r-1)*e.log(n)+(i-1)*e.log(1-n)-t.betaln(r,i))},cdf:function(e,n,r){return e>1||e<0?1*(e>1):t.ibeta(e,n,r)},inv:function(e,n,r){return t.ibetainv(e,n,r)},mean:function(t,e){return t/(t+e)},median:function(e,n){return t.ibetainv(.5,e,n)},mode:function(t,e){return(t-1)/(t+e-2)},sample:function(e,n){var r=t.randg(e);return r/(r+t.randg(n))},variance:function(t,n){return t*n/(e.pow(t+n,2)*(t+n+1))}}),t.extend(t.centralF,{pdf:function(n,r,i){var o;return n<0?0:r<=2?0===n&&r<2?1/0:0===n&&2===r?1:1/t.betafn(r/2,i/2)*e.pow(r/i,r/2)*e.pow(n,r/2-1)*e.pow(1+r/i*n,-(r+i)/2):(o=r*n/(i+n*r),r*(i/(i+n*r))/2*t.binomial.pdf((r-2)/2,(r+i-2)/2,o))},cdf:function(e,n,r){return e<0?0:t.ibeta(n*e/(n*e+r),n/2,r/2)},inv:function(e,n,r){return r/(n*(1/t.ibetainv(e,n/2,r/2)-1))},mean:function(t,e){return e>2?e/(e-2):void 0},mode:function(t,e){return t>2?e*(t-2)/(t*(e+2)):void 0},sample:function(e,n){return 2*t.randg(e/2)/e/(2*t.randg(n/2)/n)},variance:function(t,e){if(!(e<=4))return 2*e*e*(t+e-2)/(t*(e-2)*(e-2)*(e-4))}}),t.extend(t.cauchy,{pdf:function(t,n,r){return r<0?0:r/(e.pow(t-n,2)+e.pow(r,2))/e.PI},cdf:function(t,n,r){return e.atan((t-n)/r)/e.PI+.5},inv:function(t,n,r){return n+r*e.tan(e.PI*(t-.5))},median:function(t){return t},mode:function(t){return t},sample:function(n,r){return t.randn()*e.sqrt(1/(2*t.randg(.5)))*r+n}}),t.extend(t.chisquare,{pdf:function(n,r){return n<0?0:0===n&&2===r?.5:e.exp((r/2-1)*e.log(n)-n/2-r/2*e.log(2)-t.gammaln(r/2))},cdf:function(e,n){return e<0?0:t.lowRegGamma(n/2,e/2)},inv:function(e,n){return 2*t.gammapinv(e,.5*n)},mean:function(t){return t},median:function(t){return t*e.pow(1-2/(9*t),3)},mode:function(t){return t-2>0?t-2:0},sample:function(e){return 2*t.randg(e/2)},variance:function(t){return 2*t}}),t.extend(t.exponential,{pdf:function(t,n){return t<0?0:n*e.exp(-n*t)},cdf:function(t,n){return t<0?0:1-e.exp(-n*t)},inv:function(t,n){return-e.log(1-t)/n},mean:function(t){return 1/t},median:function(t){return 1/t*e.log(2)},mode:function(){return 0},sample:function(n){return-1/n*e.log(t._random_fn())},variance:function(t){return e.pow(t,-2)}}),t.extend(t.gamma,{pdf:function(n,r,i){return n<0?0:0===n&&1===r?1/i:e.exp((r-1)*e.log(n)-n/i-t.gammaln(r)-r*e.log(i))},cdf:function(e,n,r){return e<0?0:t.lowRegGamma(n,e/r)},inv:function(e,n,r){return t.gammapinv(e,n)*r},mean:function(t,e){return t*e},mode:function(t,e){if(t>1)return(t-1)*e},sample:function(e,n){return t.randg(e)*n},variance:function(t,e){return t*e*e}}),t.extend(t.invgamma,{pdf:function(n,r,i){return n<=0?0:e.exp(-(r+1)*e.log(n)-i/n-t.gammaln(r)+r*e.log(i))},cdf:function(e,n,r){return e<=0?0:1-t.lowRegGamma(n,r/e)},inv:function(e,n,r){return r/t.gammapinv(1-e,n)},mean:function(t,e){return t>1?e/(t-1):void 0},mode:function(t,e){return e/(t+1)},sample:function(e,n){return n/t.randg(e)},variance:function(t,e){if(!(t<=2))return e*e/((t-1)*(t-1)*(t-2))}}),t.extend(t.kumaraswamy,{pdf:function(t,n,r){return 0===t&&1===n?r:1===t&&1===r?n:e.exp(e.log(n)+e.log(r)+(n-1)*e.log(t)+(r-1)*e.log(1-e.pow(t,n)))},cdf:function(t,n,r){return t<0?0:t>1?1:1-e.pow(1-e.pow(t,n),r)},inv:function(t,n,r){return e.pow(1-e.pow(1-t,1/r),1/n)},mean:function(e,n){return n*t.gammafn(1+1/e)*t.gammafn(n)/t.gammafn(1+1/e+n)},median:function(t,n){return e.pow(1-e.pow(2,-1/n),1/t)},mode:function(t,n){if(t>=1&&n>=1&&1!==t&&1!==n)return e.pow((t-1)/(t*n-1),1/t)},variance:function(){throw new Error("variance not yet implemented")}}),t.extend(t.lognormal,{pdf:function(t,n,r){return t<=0?0:e.exp(-e.log(t)-.5*e.log(2*e.PI)-e.log(r)-e.pow(e.log(t)-n,2)/(2*r*r))},cdf:function(n,r,i){return n<0?0:.5+.5*t.erf((e.log(n)-r)/e.sqrt(2*i*i))},inv:function(n,r,i){return e.exp(-1.4142135623730951*i*t.erfcinv(2*n)+r)},mean:function(t,n){return e.exp(t+n*n/2)},median:function(t){return e.exp(t)},mode:function(t,n){return e.exp(t-n*n)},sample:function(n,r){return e.exp(t.randn()*r+n)},variance:function(t,n){return(e.exp(n*n)-1)*e.exp(2*t+n*n)}}),t.extend(t.noncentralt,{pdf:function(n,r,i){return e.abs(i)<1e-14?t.studentt.pdf(n,r):e.abs(n)<1e-14?e.exp(t.gammaln((r+1)/2)-i*i/2-.5*e.log(e.PI*r)-t.gammaln(r/2)):r/n*(t.noncentralt.cdf(n*e.sqrt(1+2/r),r+2,i)-t.noncentralt.cdf(n,r,i))},cdf:function(n,r,i){var o=1e-14;if(e.abs(i)<o)return t.studentt.cdf(n,r);var a=!1;n<0&&(a=!0,i=-i);for(var s=t.normal.cdf(-i,0,1),u=o+1,c=u,l=n*n/(n*n+r),d=0,h=e.exp(-i*i/2),f=e.exp(-i*i/2-.5*e.log(2)-t.gammaln(1.5))*i;d<200||c>o||u>o;)c=u,d>0&&(h*=i*i/(2*d),f*=i*i/(2*(d+.5))),s+=.5*(u=h*t.beta.cdf(l,d+.5,r/2)+f*t.beta.cdf(l,d+1,r/2)),d++;return a?1-s:s}}),t.extend(t.normal,{pdf:function(t,n,r){return e.exp(-.5*e.log(2*e.PI)-e.log(r)-e.pow(t-n,2)/(2*r*r))},cdf:function(n,r,i){return.5*(1+t.erf((n-r)/e.sqrt(2*i*i)))},inv:function(e,n,r){return-1.4142135623730951*r*t.erfcinv(2*e)+n},mean:function(t){return t},median:function(t){return t},mode:function(t){return t},sample:function(e,n){return t.randn()*n+e},variance:function(t,e){return e*e}}),t.extend(t.pareto,{pdf:function(t,n,r){return t<n?0:r*e.pow(n,r)/e.pow(t,r+1)},cdf:function(t,n,r){return t<n?0:1-e.pow(n/t,r)},inv:function(t,n,r){return n/e.pow(1-t,1/r)},mean:function(t,n){if(!(n<=1))return n*e.pow(t,n)/(n-1)},median:function(t,n){return t*(n*e.SQRT2)},mode:function(t){return t},variance:function(t,n){if(!(n<=2))return t*t*n/(e.pow(n-1,2)*(n-2))}}),t.extend(t.studentt,{pdf:function(n,r){return r=r>1e100?1e100:r,1/(e.sqrt(r)*t.betafn(.5,r/2))*e.pow(1+n*n/r,-(r+1)/2)},cdf:function(n,r){var i=r/2;return t.ibeta((n+e.sqrt(n*n+r))/(2*e.sqrt(n*n+r)),i,i)},inv:function(n,r){var i=t.ibetainv(2*e.min(n,1-n),.5*r,.5);return i=e.sqrt(r*(1-i)/i),n>.5?i:-i},mean:function(t){return t>1?0:void 0},median:function(){return 0},mode:function(){return 0},sample:function(n){return t.randn()*e.sqrt(n/(2*t.randg(n/2)))},variance:function(t){return t>2?t/(t-2):t>1?1/0:void 0}}),t.extend(t.weibull,{pdf:function(t,n,r){return t<0||n<0||r<0?0:r/n*e.pow(t/n,r-1)*e.exp(-e.pow(t/n,r))},cdf:function(t,n,r){return t<0?0:1-e.exp(-e.pow(t/n,r))},inv:function(t,n,r){return n*e.pow(-e.log(1-t),1/r)},mean:function(e,n){return e*t.gammafn(1+1/n)},median:function(t,n){return t*e.pow(e.log(2),1/n)},mode:function(t,n){return n<=1?0:t*e.pow((n-1)/n,1/n)},sample:function(n,r){return n*e.pow(-e.log(t._random_fn()),1/r)},variance:function(n,r){return n*n*t.gammafn(1+2/r)-e.pow(t.weibull.mean(n,r),2)}}),t.extend(t.uniform,{pdf:function(t,e,n){return t<e||t>n?0:1/(n-e)},cdf:function(t,e,n){return t<e?0:t<n?(t-e)/(n-e):1},inv:function(t,e,n){return e+t*(n-e)},mean:function(t,e){return.5*(t+e)},median:function(e,n){return t.mean(e,n)},mode:function(){throw new Error("mode is not yet implemented")},sample:function(e,n){return e/2+n/2+(n/2-e/2)*(2*t._random_fn()-1)},variance:function(t,n){return e.pow(n-t,2)/12}}),t.extend(t.binomial,{pdf:function(n,r,i){return 0===i||1===i?r*i===n?1:0:t.combination(r,n)*e.pow(i,n)*e.pow(1-i,r-n)},cdf:function(r,i,o){var a,s=1e-10;if(r<0)return 0;if(r>=i)return 1;if(o<0||o>1||i<=0)return NaN;var u=o,c=(r=e.floor(r))+1,l=i-r,d=c+l,h=e.exp(t.gammaln(d)-t.gammaln(l)-t.gammaln(c)+c*e.log(u)+l*e.log(1-u));return a=u<(c+1)/(d+2)?h*n(u,c,l,s):1-h*n(1-u,l,c,s),e.round(1/s*(1-a))/(1/s)}}),t.extend(t.negbin,{pdf:function(n,r,i){return n===n>>>0&&(n<0?0:t.combination(n+r-1,r-1)*e.pow(1-i,n)*e.pow(i,r))},cdf:function(e,n,r){var i=0,o=0;if(e<0)return 0;for(;o<=e;o++)i+=t.negbin.pdf(o,n,r);return i}}),t.extend(t.hypgeom,{pdf:function(n,r,i,o){if(n!=n|0)return!1;if(n<0||n<i-(r-o))return 0;if(n>o||n>i)return 0;if(2*i>r)return 2*o>r?t.hypgeom.pdf(r-i-o+n,r,r-i,r-o):t.hypgeom.pdf(o-n,r,r-i,o);if(2*o>r)return t.hypgeom.pdf(i-n,r,i,r-o);if(i<o)return t.hypgeom.pdf(n,r,o,i);for(var a=1,s=0,u=0;u<n;u++){for(;a>1&&s<o;)a*=1-i/(r-s),s++;a*=(o-u)*(i-u)/((u+1)*(r-i-o+u+1))}for(;s<o;s++)a*=1-i/(r-s);return e.min(1,e.max(0,a))},cdf:function(n,r,i,o){if(n<0||n<i-(r-o))return 0;if(n>=o||n>=i)return 1;if(2*i>r)return 2*o>r?t.hypgeom.cdf(r-i-o+n,r,r-i,r-o):1-t.hypgeom.cdf(o-n-1,r,r-i,o);if(2*o>r)return 1-t.hypgeom.cdf(i-n-1,r,i,r-o);if(i<o)return t.hypgeom.cdf(n,r,o,i);for(var a=1,s=1,u=0,c=0;c<n;c++){for(;a>1&&u<o;){var l=1-i/(r-u);s*=l,a*=l,u++}a+=s*=(o-c)*(i-c)/((c+1)*(r-i-o+c+1))}for(;u<o;u++)a*=1-i/(r-u);return e.min(1,e.max(0,a))}}),t.extend(t.poisson,{pdf:function(n,r){return r<0||n%1!=0||n<0?0:e.pow(r,n)*e.exp(-r)/t.factorial(n)},cdf:function(e,n){var r=[],i=0;if(e<0)return 0;for(;i<=e;i++)r.push(t.poisson.pdf(i,n));return t.sum(r)},mean:function(t){return t},variance:function(t){return t},sampleSmall:function(n){var r=1,i=0,o=e.exp(-n);do{i++,r*=t._random_fn()}while(r>o);return i-1},sampleLarge:function(n){var r,i,o,a,s,u,c,l,d,h,f=n;for(a=e.sqrt(f),s=e.log(f),u=.02483*(c=.931+2.53*a)-.059,l=1.1239+1.1328/(c-3.4),d=.9277-3.6224/(c-2);;){if(i=e.random()-.5,o=e.random(),h=.5-e.abs(i),r=e.floor((2*u/h+c)*i+f+.43),h>=.07&&o<=d)return r;if(!(r<0||h<.013&&o>h)&&e.log(o)+e.log(l)-e.log(u/(h*h)+c)<=r*s-f-t.loggam(r+1))return r}},sample:function(t){return t<10?this.sampleSmall(t):this.sampleLarge(t)}}),t.extend(t.triangular,{pdf:function(t,e,n,r){return n<=e||r<e||r>n?NaN:t<e||t>n?0:t<r?2*(t-e)/((n-e)*(r-e)):t===r?2/(n-e):2*(n-t)/((n-e)*(n-r))},cdf:function(t,n,r,i){return r<=n||i<n||i>r?NaN:t<=n?0:t>=r?1:t<=i?e.pow(t-n,2)/((r-n)*(i-n)):1-e.pow(r-t,2)/((r-n)*(r-i))},inv:function(t,n,r,i){return r<=n||i<n||i>r?NaN:t<=(i-n)/(r-n)?n+(r-n)*e.sqrt(t*((i-n)/(r-n))):n+(r-n)*(1-e.sqrt((1-t)*(1-(i-n)/(r-n))))},mean:function(t,e,n){return(t+e+n)/3},median:function(t,n,r){return r<=(t+n)/2?n-e.sqrt((n-t)*(n-r))/e.sqrt(2):r>(t+n)/2?t+e.sqrt((n-t)*(r-t))/e.sqrt(2):void 0},mode:function(t,e,n){return n},sample:function(n,r,i){var o=t._random_fn();return o<(i-n)/(r-n)?n+e.sqrt(o*(r-n)*(i-n)):r-e.sqrt((1-o)*(r-n)*(r-i))},variance:function(t,e,n){return(t*t+e*e+n*n-t*e-t*n-e*n)/18}}),t.extend(t.arcsine,{pdf:function(t,n,r){return r<=n?NaN:t<=n||t>=r?0:2/e.PI*e.pow(e.pow(r-n,2)-e.pow(2*t-n-r,2),-.5)},cdf:function(t,n,r){return t<n?0:t<r?2/e.PI*e.asin(e.sqrt((t-n)/(r-n))):1},inv:function(t,n,r){return n+(.5-.5*e.cos(e.PI*t))*(r-n)},mean:function(t,e){return e<=t?NaN:(t+e)/2},median:function(t,e){return e<=t?NaN:(t+e)/2},mode:function(){throw new Error("mode is not yet implemented")},sample:function(n,r){return(n+r)/2+(r-n)/2*e.sin(2*e.PI*t.uniform.sample(0,1))},variance:function(t,n){return n<=t?NaN:e.pow(n-t,2)/8}}),t.extend(t.laplace,{pdf:function(t,n,r){return r<=0?0:e.exp(-e.abs(t-n)/r)/(2*r)},cdf:function(t,n,r){return r<=0?0:t<n?.5*e.exp((t-n)/r):1-.5*e.exp(-(t-n)/r)},mean:function(t){return t},median:function(t){return t},mode:function(t){return t},variance:function(t,e){return 2*e*e},sample:function(n,r){var i,o=t._random_fn()-.5;return n-r*((i=o)/e.abs(i))*e.log(1-2*e.abs(o))}}),t.extend(t.tukey,{cdf:function(n,i,o){var a=i,s=[.9894009349916499,.9445750230732326,.8656312023878318,.755404408355003,.6178762444026438,.45801677765722737,.2816035507792589,.09501250983763744],u=[.027152459411754096,.062253523938647894,.09515851168249279,.12462897125553388,.14959598881657674,.16915651939500254,.18260341504492358,.1894506104550685];if(n<=0)return 0;if(o<2||a<2)return NaN;if(!Number.isFinite(n))return 1;if(o>25e3)return r(n,1,a);var c,l=.5*o,d=l*e.log(o)-o*e.log(2)-t.gammaln(l),h=l-1,f=.25*o;c=o<=100?1:o<=800?.5:o<=5e3?.25:.125,d+=e.log(c);for(var p=0,m=1;m<=50;m++){for(var g=0,y=(2*m-1)*c,v=1;v<=16;v++){var w,b;8<v?(w=v-8-1,b=d+h*e.log(y+s[w]*c)-(s[w]*c+y)*f):(w=v-1,b=d+h*e.log(y-s[w]*c)+(s[w]*c-y)*f),b>=-30&&(g+=r(8<v?n*e.sqrt(.5*(s[w]*c+y)):n*e.sqrt(.5*(-s[w]*c+y)),1,a)*u[w]*e.exp(b))}if(m*c>=1&&g<=1e-14)break;p+=g}if(g>1e-14)throw new Error("tukey.cdf failed to converge");return p>1&&(p=1),p},inv:function(n,r,i){if(i<2||r<2)return NaN;if(n<0||n>1)return NaN;if(0===n)return 0;if(1===n)return 1/0;var o,a=function(t,n,r){var i=.5-.5*t,o=e.sqrt(e.log(1/(i*i))),a=o+((((-453642210148e-16*o-.204231210125)*o-.342242088547)*o-1)*o+.322232421088)/((((.0038560700634*o+.10353775285)*o+.531103462366)*o+.588581570495)*o+.099348462606);r<120&&(a+=(a*a*a+a)/r/4);var s=.8832-.2368*a;return r<120&&(s+=-1.214/r+1.208*a/r),a*(s*e.log(n-1)+1.4142)}(n,r,i),s=t.tukey.cdf(a,r,i)-n;o=s>0?e.max(0,a-1):a+1;for(var u,c=t.tukey.cdf(o,r,i)-n,l=1;l<50;l++)if(u=o-c*(o-a)/(c-s),s=c,a=o,u<0&&(u=0,c=-n),c=t.tukey.cdf(u,r,i)-n,o=u,e.abs(o-a)<1e-4)return u;throw new Error("tukey.inv failed to converge")}})}(e,Math),function(t,e){var n,r,i=Array.prototype.push,o=t.utils.isArray;function a(e){return o(e)||e instanceof t}t.extend({add:function(e,n){return a(n)?(a(n[0])||(n=[n]),t.map(e,function(t,e,r){return t+n[e][r]})):t.map(e,function(t){return t+n})},subtract:function(e,n){return a(n)?(a(n[0])||(n=[n]),t.map(e,function(t,e,r){return t-n[e][r]||0})):t.map(e,function(t){return t-n})},divide:function(e,n){return a(n)?(a(n[0])||(n=[n]),t.multiply(e,t.inv(n))):t.map(e,function(t){return t/n})},multiply:function(e,n){var r,i,o,s,u,c,l,d;if(void 0===e.length&&void 0===n.length)return e*n;if(u=e.length,c=e[0].length,l=t.zeros(u,o=a(n)?n[0].length:c),d=0,a(n)){for(;d<o;d++)for(r=0;r<u;r++){for(s=0,i=0;i<c;i++)s+=e[r][i]*n[i][d];l[r][d]=s}return 1===u&&1===d?l[0][0]:l}return t.map(e,function(t){return t*n})},outer:function(e,n){return t.multiply(e.map(function(t){return[t]}),[n])},dot:function(e,n){a(e[0])||(e=[e]),a(n[0])||(n=[n]);for(var r,i,o=1===e[0].length&&1!==e.length?t.transpose(e):e,s=1===n[0].length&&1!==n.length?t.transpose(n):n,u=[],c=0,l=o.length,d=o[0].length;c<l;c++){for(u[c]=[],r=0,i=0;i<d;i++)r+=o[c][i]*s[c][i];u[c]=r}return 1===u.length?u[0]:u},pow:function(n,r){return t.map(n,function(t){return e.pow(t,r)})},exp:function(n){return t.map(n,function(t){return e.exp(t)})},log:function(n){return t.map(n,function(t){return e.log(t)})},abs:function(n){return t.map(n,function(t){return e.abs(t)})},norm:function(t,n){var r=0,i=0;for(isNaN(n)&&(n=2),a(t[0])&&(t=t[0]);i<t.length;i++)r+=e.pow(e.abs(t[i]),n);return e.pow(r,1/n)},angle:function(n,r){return e.acos(t.dot(n,r)/(t.norm(n)*t.norm(r)))},aug:function(t,e){var n,r=[];for(n=0;n<t.length;n++)r.push(t[n].slice());for(n=0;n<r.length;n++)i.apply(r[n],e[n]);return r},inv:function(e){for(var n,r=e.length,i=e[0].length,o=t.identity(r,i),a=t.gauss_jordan(e,o),s=[],u=0;u<r;u++)for(s[u]=[],n=i;n<a[0].length;n++)s[u][n-i]=a[u][n];return s},det:function t(e){if(2===e.length)return e[0][0]*e[1][1]-e[0][1]*e[1][0];for(var n=0,r=0;r<e.length;r++){for(var i=[],o=1;o<e.length;o++){i[o-1]=[];for(var a=0;a<e.length;a++)a<r?i[o-1][a]=e[o][a]:a>r&&(i[o-1][a-1]=e[o][a])}var s=r%2?-1:1;n+=t(i)*e[0][r]*s}return n},gauss_elimination:function(n,r){var i,o,a,s,u=0,c=0,l=n.length,d=n[0].length,h=1,f=0,p=[];for(i=(n=t.aug(n,r))[0].length,u=0;u<l;u++){for(o=n[u][u],c=u,s=u+1;s<d;s++)o<e.abs(n[s][u])&&(o=n[s][u],c=s);if(c!=u)for(s=0;s<i;s++)a=n[u][s],n[u][s]=n[c][s],n[c][s]=a;for(c=u+1;c<l;c++)for(h=n[c][u]/n[u][u],s=u;s<i;s++)n[c][s]=n[c][s]-h*n[u][s]}for(u=l-1;u>=0;u--){for(f=0,c=u+1;c<=l-1;c++)f+=p[c]*n[u][c];p[u]=(n[u][i-1]-f)/n[u][u]}return p},gauss_jordan:function(n,r){var i,o,a,s=t.aug(n,r),u=s.length,c=s[0].length,l=0;for(o=0;o<u;o++){var d=o;for(a=o+1;a<u;a++)e.abs(s[a][o])>e.abs(s[d][o])&&(d=a);var h=s[o];for(s[o]=s[d],s[d]=h,a=o+1;a<u;a++)for(l=s[a][o]/s[o][o],i=o;i<c;i++)s[a][i]-=s[o][i]*l}for(o=u-1;o>=0;o--){for(l=s[o][o],a=0;a<o;a++)for(i=c-1;i>o-1;i--)s[a][i]-=s[o][i]*s[a][o]/l;for(s[o][o]/=l,i=u;i<c;i++)s[o][i]/=l}return s},triaUpSolve:function(e,n){var r,i=e[0].length,o=t.zeros(1,i)[0],a=!1;return null!=n[0].length&&(n=n.map(function(t){return t[0]}),a=!0),t.arange(i-1,-1,-1).forEach(function(a){r=t.arange(a+1,i).map(function(t){return o[t]*e[a][t]}),o[a]=(n[a]-t.sum(r))/e[a][a]}),a?o.map(function(t){return[t]}):o},triaLowSolve:function(e,n){var r,i=e[0].length,o=t.zeros(1,i)[0],a=!1;return null!=n[0].length&&(n=n.map(function(t){return t[0]}),a=!0),t.arange(i).forEach(function(i){r=t.arange(i).map(function(t){return e[i][t]*o[t]}),o[i]=(n[i]-t.sum(r))/e[i][i]}),a?o.map(function(t){return[t]}):o},lu:function(e){var n,r=e.length,i=t.identity(r),o=t.zeros(e.length,e[0].length);return t.arange(r).forEach(function(t){o[0][t]=e[0][t]}),t.arange(1,r).forEach(function(a){t.arange(a).forEach(function(r){n=t.arange(r).map(function(t){return i[a][t]*o[t][r]}),i[a][r]=(e[a][r]-t.sum(n))/o[r][r]}),t.arange(a,r).forEach(function(r){n=t.arange(a).map(function(t){return i[a][t]*o[t][r]}),o[a][r]=e[n.length][r]-t.sum(n)})}),[i,o]},cholesky:function(n){var r,i=n.length,o=t.zeros(n.length,n[0].length);return t.arange(i).forEach(function(a){r=t.arange(a).map(function(t){return e.pow(o[a][t],2)}),o[a][a]=e.sqrt(n[a][a]-t.sum(r)),t.arange(a+1,i).forEach(function(e){r=t.arange(a).map(function(t){return o[a][t]*o[e][t]}),o[e][a]=(n[a][e]-t.sum(r))/o[a][a]})}),o},gauss_jacobi:function(n,r,i,o){for(var a,s,u,c,l=0,d=0,h=n.length,f=[],p=[],m=[];l<h;l++)for(f[l]=[],p[l]=[],m[l]=[],d=0;d<h;d++)l>d?(f[l][d]=n[l][d],p[l][d]=m[l][d]=0):l<d?(p[l][d]=n[l][d],f[l][d]=m[l][d]=0):(m[l][d]=n[l][d],f[l][d]=p[l][d]=0);for(u=t.multiply(t.multiply(t.inv(m),t.add(f,p)),-1),s=t.multiply(t.inv(m),r),a=i,c=t.add(t.multiply(u,i),s),l=2;e.abs(t.norm(t.subtract(c,a)))>o;)a=c,c=t.add(t.multiply(u,a),s),l++;return c},gauss_seidel:function(n,r,i,o){for(var a,s,u,c,l,d=0,h=n.length,f=[],p=[],m=[];d<h;d++)for(f[d]=[],p[d]=[],m[d]=[],a=0;a<h;a++)d>a?(f[d][a]=n[d][a],p[d][a]=m[d][a]=0):d<a?(p[d][a]=n[d][a],f[d][a]=m[d][a]=0):(m[d][a]=n[d][a],f[d][a]=p[d][a]=0);for(c=t.multiply(t.multiply(t.inv(t.add(m,f)),p),-1),u=t.multiply(t.inv(t.add(m,f)),r),s=i,l=t.add(t.multiply(c,i),u),d=2;e.abs(t.norm(t.subtract(l,s)))>o;)s=l,l=t.add(t.multiply(c,s),u),d+=1;return l},SOR:function(n,r,i,o,a){for(var s,u,c,l,d,h=0,f=n.length,p=[],m=[],g=[];h<f;h++)for(p[h]=[],m[h]=[],g[h]=[],s=0;s<f;s++)h>s?(p[h][s]=n[h][s],m[h][s]=g[h][s]=0):h<s?(m[h][s]=n[h][s],p[h][s]=g[h][s]=0):(g[h][s]=n[h][s],p[h][s]=m[h][s]=0);for(l=t.multiply(t.inv(t.add(g,t.multiply(p,a))),t.subtract(t.multiply(g,1-a),t.multiply(m,a))),c=t.multiply(t.multiply(t.inv(t.add(g,t.multiply(p,a))),r),a),u=i,d=t.add(t.multiply(l,i),c),h=2;e.abs(t.norm(t.subtract(d,u)))>o;)u=d,d=t.add(t.multiply(l,u),c),h++;return d},householder:function(n){for(var r,i,o,a,s=n.length,u=n[0].length,c=0,l=[],d=[];c<s-1;c++){for(r=0,a=c+1;a<u;a++)r+=n[a][c]*n[a][c];for(r=(n[c+1][c]>0?-1:1)*e.sqrt(r),i=e.sqrt((r*r-n[c+1][c]*r)/2),(l=t.zeros(s,1))[c+1][0]=(n[c+1][c]-r)/(2*i),o=c+2;o<s;o++)l[o][0]=n[o][c]/(2*i);d=t.subtract(t.identity(s,u),t.multiply(t.multiply(l,t.transpose(l)),2)),n=t.multiply(d,t.multiply(n,d))}return n},QR:(n=t.sum,r=t.arange,function(i){var o,a,s,u=i.length,c=i[0].length,l=t.zeros(c,c);for(i=t.copy(i),a=0;a<c;a++){for(l[a][a]=e.sqrt(n(r(u).map(function(t){return i[t][a]*i[t][a]}))),o=0;o<u;o++)i[o][a]=i[o][a]/l[a][a];for(s=a+1;s<c;s++)for(l[a][s]=n(r(u).map(function(t){return i[t][a]*i[t][s]})),o=0;o<u;o++)i[o][s]=i[o][s]-i[o][a]*l[a][s]}return[i,l]}),lstsq:function(e,n){var r=!1;void 0===n[0].length&&(n=n.map(function(t){return[t]}),r=!0);var i=t.QR(e),o=i[0],a=i[1],s=e[0].length,u=t.slice(o,{col:{end:s}}),c=function(e){var n=(e=t.copy(e)).length,r=t.identity(n);return t.arange(n-1,-1,-1).forEach(function(n){t.sliceAssign(r,{row:n},t.divide(t.slice(r,{row:n}),e[n][n])),t.sliceAssign(e,{row:n},t.divide(t.slice(e,{row:n}),e[n][n])),t.arange(n).forEach(function(i){var o=t.multiply(e[i][n],-1),a=t.slice(e,{row:i}),s=t.multiply(t.slice(e,{row:n}),o);t.sliceAssign(e,{row:i},t.add(a,s));var u=t.slice(r,{row:i}),c=t.multiply(t.slice(r,{row:n}),o);t.sliceAssign(r,{row:i},t.add(u,c))})}),r}(t.slice(a,{row:{end:s}})),l=t.transpose(u);void 0===l[0].length&&(l=[l]);var d=t.multiply(t.multiply(c,l),n);return void 0===d.length&&(d=[[d]]),r?d.map(function(t){return t[0]}):d},jacobi:function(n){for(var r,i,o,a,s,u,c,l=1,d=n.length,h=t.identity(d,d),f=[];1===l;){for(s=n[0][1],o=0,a=1,r=0;r<d;r++)for(i=0;i<d;i++)r!=i&&s<e.abs(n[r][i])&&(s=e.abs(n[r][i]),o=r,a=i);for(u=n[o][o]===n[a][a]?n[o][a]>0?e.PI/4:-e.PI/4:e.atan(2*n[o][a]/(n[o][o]-n[a][a]))/2,(c=t.identity(d,d))[o][o]=e.cos(u),c[o][a]=-e.sin(u),c[a][o]=e.sin(u),c[a][a]=e.cos(u),h=t.multiply(h,c),n=t.multiply(t.multiply(t.inv(c),n),c),l=0,r=1;r<d;r++)for(i=1;i<d;i++)r!=i&&e.abs(n[r][i])>.001&&(l=1)}for(r=0;r<d;r++)f.push(n[r][r]);return[h,f]},rungekutta:function(t,e,n,r,i,o){var a,s,u;if(2===o)for(;r<=n;)i+=((a=e*t(r,i))+(s=e*t(r+e,i+a)))/2,r+=e;if(4===o)for(;r<=n;)i+=((a=e*t(r,i))+2*(s=e*t(r+e/2,i+a/2))+2*(u=e*t(r+e/2,i+s/2))+e*t(r+e,i+u))/6,r+=e;return i},romberg:function(t,n,r,i){for(var o,a,s,u,c,l=0,d=(r-n)/2,h=[],f=[],p=[];l<i/2;){for(c=t(n),s=n,u=0;s<=r;s+=d,u++)h[u]=s;for(o=h.length,s=1;s<o-1;s++)c+=(s%2!=0?4:2)*t(h[s]);c=d/3*(c+t(r)),p[l]=c,d/=2,l++}for(a=p.length,o=1;1!==a;){for(s=0;s<a-1;s++)f[s]=(e.pow(4,o)*p[s+1]-p[s])/(e.pow(4,o)-1);a=f.length,p=f,f=[],o++}return p},richardson:function(t,n,r,i){function o(t,e){for(var n,r=0,i=t.length;r<i;r++)t[r]===e&&(n=r);return n}for(var a,s,u,c,l,d=e.abs(r-t[o(t,r)+1]),h=0,f=[],p=[];i>=d;)a=o(t,r+i),s=o(t,r),f[h]=(n[a]-2*n[s]+n[2*s-a])/(i*i),i/=2,h++;for(c=f.length,u=1;1!=c;){for(l=0;l<c-1;l++)p[l]=(e.pow(4,u)*f[l+1]-f[l])/(e.pow(4,u)-1);c=p.length,f=p,p=[],u++}return f},simpson:function(t,e,n,r){for(var i,o=(n-e)/r,a=t(e),s=[],u=e,c=0,l=1;u<=n;u+=o,c++)s[c]=u;for(i=s.length;l<i-1;l++)a+=(l%2!=0?4:2)*t(s[l]);return o/3*(a+t(n))},hermite:function(t,e,n,r){for(var i,o=t.length,a=0,s=0,u=[],c=[],l=[],d=[];s<o;s++){for(u[s]=1,i=0;i<o;i++)s!=i&&(u[s]*=(r-t[i])/(t[s]-t[i]));for(c[s]=0,i=0;i<o;i++)s!=i&&(c[s]+=1/(t[s]-t[i]));l[s]=(1-2*(r-t[s])*c[s])*(u[s]*u[s]),d[s]=(r-t[s])*(u[s]*u[s]),a+=l[s]*e[s]+d[s]*n[s]}return a},lagrange:function(t,e,n){for(var r,i,o=0,a=0,s=t.length;a<s;a++){for(i=e[a],r=0;r<s;r++)a!=r&&(i*=(n-t[r])/(t[a]-t[r]));o+=i}return o},cubic_spline:function(e,n,r){for(var i,o,a=e.length,s=0,u=[],c=[],l=[],d=[],h=[],f=[];s<a-1;s++)d[s]=e[s+1]-e[s];for(l[0]=0,s=1;s<a-1;s++)l[s]=3/d[s]*(n[s+1]-n[s])-3/d[s-1]*(n[s]-n[s-1]);for(s=1;s<a-1;s++)u[s]=[],c[s]=[],u[s][s-1]=d[s-1],u[s][s]=2*(d[s-1]+d[s]),u[s][s+1]=d[s],c[s][0]=l[s];for(o=t.multiply(t.inv(u),c),i=0;i<a-1;i++)h[i]=(n[i+1]-n[i])/d[i]-d[i]*(o[i+1][0]+2*o[i][0])/3,f[i]=(o[i+1][0]-o[i][0])/(3*d[i]);for(i=0;i<a&&!(e[i]>r);i++);return n[i-=1]+(r-e[i])*h[i]+t.sq(r-e[i])*o[i]+(r-e[i])*t.sq(r-e[i])*f[i]},gauss_quadrature:function(){throw new Error("gauss_quadrature not yet implemented")},PCA:function(e){var n,r,i,o,a,s=e.length,u=e[0].length,c=0,l=[],d=[],h=[],f=[],p=[],m=[],g=[];for(c=0;c<s;c++)l[c]=t.sum(e[c])/u;for(c=0;c<u;c++)for(p[c]=[],n=0;n<s;n++)p[c][n]=e[n][c]-l[n];for(p=t.transpose(p),c=0;c<s;c++)for(m[c]=[],n=0;n<s;n++)m[c][n]=t.dot([p[c]],[p[n]])/(u-1);for(a=(i=t.jacobi(m))[0],d=i[1],g=t.transpose(a),c=0;c<d.length;c++)for(n=c;n<d.length;n++)d[c]<d[n]&&(r=d[c],d[c]=d[n],d[n]=r,h=g[c],g[c]=g[n],g[n]=h);for(o=t.transpose(p),c=0;c<s;c++)for(f[c]=[],n=0;n<o.length;n++)f[c][n]=t.dot([g[c]],[o[n]]);return[e,d,g,f]}}),function(e){for(var n=0;n<e.length;n++)(function(e){t.fn[e]=function(n,r){var i=this;return r?(setTimeout(function(){r.call(i,t.fn[e].call(i,n))},15),this):"number"==typeof t[e](this,n)?t[e](this,n):t(t[e](this,n))}})(e[n])}("add divide multiply subtract dot pow exp log abs norm angle".split(" "))}(e,Math),function(t,e){var n=[].slice,r=t.utils.isNumber,i=t.utils.isArray;function o(t,n,r,i){if(t>1||r>1||t<=0||r<=0)throw new Error("Proportions should be greater than 0 and less than 1");var o=(t*n+r*i)/(n+i);return(t-r)/e.sqrt(o*(1-o)*(1/n+1/i))}t.extend({zscore:function(){var e=n.call(arguments);return r(e[1])?(e[0]-e[1])/e[2]:(e[0]-t.mean(e[1]))/t.stdev(e[1],e[2])},ztest:function(){var r,o=n.call(arguments);return i(o[1])?(r=t.zscore(o[0],o[1],o[3]),1===o[2]?t.normal.cdf(-e.abs(r),0,1):2*t.normal.cdf(-e.abs(r),0,1)):o.length>2?(r=t.zscore(o[0],o[1],o[2]),1===o[3]?t.normal.cdf(-e.abs(r),0,1):2*t.normal.cdf(-e.abs(r),0,1)):(r=o[0],1===o[1]?t.normal.cdf(-e.abs(r),0,1):2*t.normal.cdf(-e.abs(r),0,1))}}),t.extend(t.fn,{zscore:function(t,e){return(t-this.mean())/this.stdev(e)},ztest:function(n,r,i){var o=e.abs(this.zscore(n,i));return 1===r?t.normal.cdf(-o,0,1):2*t.normal.cdf(-o,0,1)}}),t.extend({tscore:function(){var r=n.call(arguments);return 4===r.length?(r[0]-r[1])/(r[2]/e.sqrt(r[3])):(r[0]-t.mean(r[1]))/(t.stdev(r[1],!0)/e.sqrt(r[1].length))},ttest:function(){var i,o=n.call(arguments);return 5===o.length?(i=e.abs(t.tscore(o[0],o[1],o[2],o[3])),1===o[4]?t.studentt.cdf(-i,o[3]-1):2*t.studentt.cdf(-i,o[3]-1)):r(o[1])?(i=e.abs(o[0]),1==o[2]?t.studentt.cdf(-i,o[1]-1):2*t.studentt.cdf(-i,o[1]-1)):(i=e.abs(t.tscore(o[0],o[1])),1==o[2]?t.studentt.cdf(-i,o[1].length-1):2*t.studentt.cdf(-i,o[1].length-1))}}),t.extend(t.fn,{tscore:function(t){return(t-this.mean())/(this.stdev(!0)/e.sqrt(this.cols()))},ttest:function(n,r){return 1===r?1-t.studentt.cdf(e.abs(this.tscore(n)),this.cols()-1):2*t.studentt.cdf(-e.abs(this.tscore(n)),this.cols()-1)}}),t.extend({anovafscore:function(){var r,i,o,a,s,u,c,l,d=n.call(arguments);if(1===d.length){for(s=new Array(d[0].length),c=0;c<d[0].length;c++)s[c]=d[0][c];d=s}for(i=new Array,c=0;c<d.length;c++)i=i.concat(d[c]);for(o=t.mean(i),r=0,c=0;c<d.length;c++)r+=d[c].length*e.pow(t.mean(d[c])-o,2);for(r/=d.length-1,u=0,c=0;c<d.length;c++)for(a=t.mean(d[c]),l=0;l<d[c].length;l++)u+=e.pow(d[c][l]-a,2);return r/(u/(i.length-d.length))},anovaftest:function(){var e,i,o,a,s=n.call(arguments);if(r(s[0]))return 1-t.centralF.cdf(s[0],s[1],s[2]);var u=t.anovafscore(s);for(e=s.length-1,o=0,a=0;a<s.length;a++)o+=s[a].length;return i=o-e-1,1-t.centralF.cdf(u,e,i)},ftest:function(e,n,r){return 1-t.centralF.cdf(e,n,r)}}),t.extend(t.fn,{anovafscore:function(){return t.anovafscore(this.toArray())},anovaftes:function(){var e,n=0;for(e=0;e<this.length;e++)n+=this[e].length;return t.ftest(this.anovafscore(),this.length-1,n-this.length)}}),t.extend({qscore:function(){var i,o,a,s,u,c=n.call(arguments);return r(c[0])?(i=c[0],o=c[1],a=c[2],s=c[3],u=c[4]):(i=t.mean(c[0]),o=t.mean(c[1]),a=c[0].length,s=c[1].length,u=c[2]),e.abs(i-o)/(u*e.sqrt((1/a+1/s)/2))},qtest:function(){var e,r=n.call(arguments);3===r.length?(e=r[0],r=r.slice(1)):7===r.length?(e=t.qscore(r[0],r[1],r[2],r[3],r[4]),r=r.slice(5)):(e=t.qscore(r[0],r[1],r[2]),r=r.slice(3));var i=r[0],o=r[1];return 1-t.tukey.cdf(e,o,i-o)},tukeyhsd:function(e){for(var n=t.pooledstdev(e),r=e.map(function(e){return t.mean(e)}),i=e.reduce(function(t,e){return t+e.length},0),o=[],a=0;a<e.length;++a)for(var s=a+1;s<e.length;++s){var u=t.qtest(r[a],r[s],e[a].length,e[s].length,n,i,e.length);o.push([[a,s],u])}return o}}),t.extend({normalci:function(){var r,i=n.call(arguments),o=new Array(2);return r=4===i.length?e.abs(t.normal.inv(i[1]/2,0,1)*i[2]/e.sqrt(i[3])):e.abs(t.normal.inv(i[1]/2,0,1)*t.stdev(i[2])/e.sqrt(i[2].length)),o[0]=i[0]-r,o[1]=i[0]+r,o},tci:function(){var r,i=n.call(arguments),o=new Array(2);return r=4===i.length?e.abs(t.studentt.inv(i[1]/2,i[3]-1)*i[2]/e.sqrt(i[3])):e.abs(t.studentt.inv(i[1]/2,i[2].length-1)*t.stdev(i[2],!0)/e.sqrt(i[2].length)),o[0]=i[0]-r,o[1]=i[0]+r,o},significant:function(t,e){return t<e}}),t.extend(t.fn,{normalci:function(e,n){return t.normalci(e,n,this.toArray())},tci:function(e,n){return t.tci(e,n,this.toArray())}}),t.extend(t.fn,{oneSidedDifferenceOfProportions:function(e,n,r,i){var a=o(e,n,r,i);return t.ztest(a,1)},twoSidedDifferenceOfProportions:function(e,n,r,i){var a=o(e,n,r,i);return t.ztest(a,2)}})}(e,Math),e.models=function(){function t(t,n){var r=t.length,i=n[0].length-1,o=r-i-1,a=e.lstsq(n,t),s=e.multiply(n,a.map(function(t){return[t]})).map(function(t){return t[0]}),u=e.subtract(t,s),c=e.mean(t),l=e.sum(s.map(function(t){return Math.pow(t-c,2)})),d=e.sum(t.map(function(t,e){return Math.pow(t-s[e],2)})),h=l+d;return{exog:n,endog:t,nobs:r,df_model:i,df_resid:o,coef:a,predict:s,resid:u,ybar:c,SST:h,SSE:l,SSR:d,R2:l/h}}function n(n){var r,i,o=(r=n.exog,i=r[0].length,e.arange(i).map(function(n){var o=e.arange(i).filter(function(t){return t!==n});return t(e.col(r,n).map(function(t){return t[0]}),e.col(r,o))})),a=Math.sqrt(n.SSR/n.df_resid),s=o.map(function(t){var e=t.SST,n=t.R2;return a/Math.sqrt(e*(1-n))}),u=n.coef.map(function(t,e){return(t-0)/s[e]}),c=u.map(function(t){var r=e.studentt.cdf(t,n.df_resid);return 2*(r>.5?1-r:r)}),l=e.studentt.inv(.975,n.df_resid),d=n.coef.map(function(t,e){var n=l*s[e];return[t-n,t+n]});return{se:s,t:u,p:c,sigmaHat:a,interval95:d}}return{ols:function(r,i){var o=t(r,i),a=n(o),s=function(t){var n,r,i,o=t.R2/t.df_model/((1-t.R2)/t.df_resid);return{F_statistic:o,pvalue:1-(n=o,r=t.df_model,i=t.df_resid,e.beta.cdf(n/(i/r+n),r/2,i/2))}}(o),u=1-(1-o.R2)*((o.nobs-1)/o.df_resid);return o.t=a,o.f=s,o.adjust_R2=u,o}}}(),e.extend({buildxmatrix:function(){for(var t=new Array(arguments.length),n=0;n<arguments.length;n++){t[n]=[1].concat(arguments[n])}return e(t)},builddxmatrix:function(){for(var t=new Array(arguments[0].length),n=0;n<arguments[0].length;n++){t[n]=[1].concat(arguments[0][n])}return e(t)},buildjxmatrix:function(t){for(var n=new Array(t.length),r=0;r<t.length;r++)n[r]=t[r];return e.builddxmatrix(n)},buildymatrix:function(t){return e(t).transpose()},buildjymatrix:function(t){return t.transpose()},matrixmult:function(t,n){var r,i,o,a,s;if(t.cols()==n.rows()){if(n.rows()>1){for(a=[],r=0;r<t.rows();r++)for(a[r]=[],i=0;i<n.cols();i++){for(s=0,o=0;o<t.cols();o++)s+=t.toArray()[r][o]*n.toArray()[o][i];a[r][i]=s}return e(a)}for(a=[],r=0;r<t.rows();r++)for(a[r]=[],i=0;i<n.cols();i++){for(s=0,o=0;o<t.cols();o++)s+=t.toArray()[r][o]*n.toArray()[i];a[r][i]=s}return e(a)}},regress:function(t,n){var r=e.xtranspxinv(t),i=t.transpose(),o=e.matrixmult(e(r),i);return e.matrixmult(o,n)},regresst:function(t,n,r){var i=e.regress(t,n),o={anova:{}},a=e.jMatYBar(t,i);o.yBar=a;var s=n.mean();o.anova.residuals=e.residuals(n,a),o.anova.ssr=e.ssr(a,s),o.anova.msr=o.anova.ssr/(t[0].length-1),o.anova.sse=e.sse(n,a),o.anova.mse=o.anova.sse/(n.length-(t[0].length-1)-1),o.anova.sst=e.sst(n,s),o.anova.mst=o.anova.sst/(n.length-1),o.anova.r2=1-o.anova.sse/o.anova.sst,o.anova.r2<0&&(o.anova.r2=0),o.anova.fratio=o.anova.msr/o.anova.mse,o.anova.pvalue=e.anovaftest(o.anova.fratio,t[0].length-1,n.length-(t[0].length-1)-1),o.anova.rmse=Math.sqrt(o.anova.mse),o.anova.r2adj=1-o.anova.mse/o.anova.mst,o.anova.r2adj<0&&(o.anova.r2adj=0),o.stats=new Array(t[0].length);for(var u,c,l,d=e.xtranspxinv(t),h=0;h<i.length;h++)u=Math.sqrt(o.anova.mse*Math.abs(d[h][h])),c=Math.abs(i[h]/u),l=e.ttest(c,n.length-t[0].length-1,r),o.stats[h]=[i[h],u,c,l];return o.regress=i,o},xtranspx:function(t){return e.matrixmult(t.transpose(),t)},xtranspxinv:function(t){var n=e.matrixmult(t.transpose(),t);return e.inv(n)},jMatYBar:function(t,n){var r=e.matrixmult(t,n);return new e(r)},residuals:function(t,n){return e.matrixsubtract(t,n)},ssr:function(t,e){for(var n=0,r=0;r<t.length;r++)n+=Math.pow(t[r]-e,2);return n},sse:function(t,e){for(var n=0,r=0;r<t.length;r++)n+=Math.pow(t[r]-e[r],2);return n},sst:function(t,e){for(var n=0,r=0;r<t.length;r++)n+=Math.pow(t[r]-e,2);return n},matrixsubtract:function(t,n){for(var r=new Array(t.length),i=0;i<t.length;i++){r[i]=new Array(t[i].length);for(var o=0;o<t[i].length;o++)r[i][o]=t[i][o]-n[i][o]}return e(r)}}),e.jStat=e,e)},7659:t=>{"use strict";var e={};t.exports=function(t,n){var r=function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}e[t]=n}return e[t]}(t);if(!r)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");r.appendChild(n)}},7825:t=>{"use strict";t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(n){!function(t,e,n){var r="";n.supports&&(r+="@supports (".concat(n.supports,") {")),n.media&&(r+="@media ".concat(n.media," {"));var i=void 0!==n.layer;i&&(r+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),r+=n.css,i&&(r+="}"),n.media&&(r+="}"),n.supports&&(r+="}");var o=n.sourceMap;o&&"undefined"!=typeof btoa&&(r+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(o))))," */")),e.styleTagTransform(r,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},7939:(t,e,n)=>{"use strict";n.d(e,{A:()=>s});var r=n(1354),i=n.n(r),o=n(6314),a=n.n(o)()(i());a.push([t.id,".scatter_plot_link {\n right: 10px;\n}\n\n.cliffs_div {\n flex-grow: initial!important;\n justify-content: flex-end;\n flex-wrap: wrap;\n}\n\n.cliffs_grid {\n margin: 0!important;\n}\n\n.ml-dim-reduction-settings-input i.grok-icon.grok-font-icon-settings {\n font-size: 18px;\n position: absolute;\n height: 28px;\n}\n\n.ml-dim-reduction-settings-input i.grok-icon.grok-font-icon-settings:not(.ml-dim-reduction-column-editor-input-root i) {\n left: -20px;\n}\n.dlg-dimensionality-reduction.ui-form, .dlg-markov-clustering.ui-form, .dlg-markov-clustering.ui-form .ui-form, .dlg-dimensionality-reduction.ui-form .ui-form {\n max-width: unset;\n}\n\n.ml-dim-reduction-column-editor-input-root label {\n display: none !important;\n}\n\n.dim-reduction-dialog-form > .ui-input-root, .dim-reduction-dialog-form > div > .ui-input-root {\n margin-left: 10px;\n}\n\n.ml-dim-reduction-column-editor-input-root input, .ml-dim-reduction-column-editor-input-root select {\n margin-left: 20px !important;\n}\n\nh3.ml-dim-reduction-column-editor-input-root {\n margin: 0 !important;\n}\n\n.ml-dim-reduction-column-editor-root, .ml-dim-reduction-column-editor-header-root {\n display: flex;\n flex-direction: row;\n align-items: center;\n margin-bottom: 10px !important;\n width: 700px !important;\n}\n\n.ml-dim-reduction-column-editor-column-title {\n text-overflow: ellipsis;\n overflow: hidden;\n}\n\n.ml-dim-reduction-column-editor-header-root > h1:not(:first-child) {\n margin-left: 20px !important;\n}\n\n.ml-dim-reduction-column-editor-table-root .header > td:not(:first-child) {\n padding-left: 32px;\n}","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/ml/css/styles.css"],names:[],mappings:"AAAA;IACI,WAAW;AACf;;AAEA;IACI,4BAA4B;IAC5B,yBAAyB;IACzB,eAAe;AACnB;;AAEA;GACG,mBAAmB;AACtB;;AAEA;IACI,eAAe;IACf,kBAAkB;IAClB,YAAY;AAChB;;AAEA;IACI,WAAW;AACf;AACA;IACI,gBAAgB;AACpB;;AAEA;IACI,wBAAwB;AAC5B;;AAEA;IACI,iBAAiB;AACrB;;AAEA;IACI,4BAA4B;AAChC;;AAEA;IACI,oBAAoB;AACxB;;AAEA;IACI,aAAa;IACb,mBAAmB;IACnB,mBAAmB;IACnB,8BAA8B;IAC9B,uBAAuB;AAC3B;;AAEA;IACI,uBAAuB;IACvB,gBAAgB;AACpB;;AAEA;IACI,4BAA4B;AAChC;;AAEA;IACI,kBAAkB;AACtB",sourcesContent:[".scatter_plot_link {\n right: 10px;\n}\n\n.cliffs_div {\n flex-grow: initial!important;\n justify-content: flex-end;\n flex-wrap: wrap;\n}\n\n.cliffs_grid {\n margin: 0!important;\n}\n\n.ml-dim-reduction-settings-input i.grok-icon.grok-font-icon-settings {\n font-size: 18px;\n position: absolute;\n height: 28px;\n}\n\n.ml-dim-reduction-settings-input i.grok-icon.grok-font-icon-settings:not(.ml-dim-reduction-column-editor-input-root i) {\n left: -20px;\n}\n.dlg-dimensionality-reduction.ui-form, .dlg-markov-clustering.ui-form, .dlg-markov-clustering.ui-form .ui-form, .dlg-dimensionality-reduction.ui-form .ui-form {\n max-width: unset;\n}\n\n.ml-dim-reduction-column-editor-input-root label {\n display: none !important;\n}\n\n.dim-reduction-dialog-form > .ui-input-root, .dim-reduction-dialog-form > div > .ui-input-root {\n margin-left: 10px;\n}\n\n.ml-dim-reduction-column-editor-input-root input, .ml-dim-reduction-column-editor-input-root select {\n margin-left: 20px !important;\n}\n\nh3.ml-dim-reduction-column-editor-input-root {\n margin: 0 !important;\n}\n\n.ml-dim-reduction-column-editor-root, .ml-dim-reduction-column-editor-header-root {\n display: flex;\n flex-direction: row;\n align-items: center;\n margin-bottom: 10px !important;\n width: 700px !important;\n}\n\n.ml-dim-reduction-column-editor-column-title {\n text-overflow: ellipsis;\n overflow: hidden;\n}\n\n.ml-dim-reduction-column-editor-header-root > h1:not(:first-child) {\n margin-left: 20px !important;\n}\n\n.ml-dim-reduction-column-editor-table-root .header > td:not(:first-child) {\n padding-left: 32px;\n}"],sourceRoot:""}]);const s=a},8153:(t,e)=>{function n(t){return"number"!=typeof t||isNaN(t)?1:t}e.Fd=function(t){return function(t,e){var n={},r=function(t){return void 0===t?e:t};"function"==typeof e&&(r=e);var i=function(e){return r(e[t])},o=function(){return r(void 0)};return"string"==typeof t?(n.fromAttributes=i,n.fromGraph=function(t,e){return i(t.getEdgeAttributes(e))},n.fromEntry=function(t,e){return i(e)},n.fromPartialEntry=n.fromEntry,n.fromMinimalEntry=n.fromEntry):"function"==typeof t?(n.fromAttributes=function(){throw new Error("graphology-utils/getters/createEdgeValueGetter: irrelevant usage.")},n.fromGraph=function(e,n){var i=e.extremities(n);return r(t(n,e.getEdgeAttributes(n),i[0],i[1],e.getNodeAttributes(i[0]),e.getNodeAttributes(i[1]),e.isUndirected(n)))},n.fromEntry=function(e,n,i,o,a,s,u){return r(t(e,n,i,o,a,s,u))},n.fromPartialEntry=function(e,n,i,o){return r(t(e,n,i,o))},n.fromMinimalEntry=function(e,n){return r(t(e,n))}):(n.fromAttributes=o,n.fromGraph=o,n.fromEntry=o,n.fromMinimalEntry=o),n}(t,n)}},8903:(t,e,n)=>{var r=n(1736),i=n(8153).Fd,o=n(2561),a=n(1782),s=n(9937);function u(t,e,n){if(!r(e))throw new Error("graphology-layout-forceatlas2: the given graph is not a valid graphology instance.");"number"==typeof n&&(n={iterations:n});var u=n.iterations;if("number"!=typeof u)throw new Error("graphology-layout-forceatlas2: invalid number of iterations.");if(u<=0)throw new Error("graphology-layout-forceatlas2: you should provide a positive number of iterations.");var c=i("getEdgeWeight"in n?n.getEdgeWeight:"weight").fromEntry,l="function"==typeof n.outputReducer?n.outputReducer:null,d=a.assign({},s,n.settings),h=a.validateSettings(d);if(h)throw new Error("graphology-layout-forceatlas2: "+h.message);var f,p=a.graphToByteArrays(e,c);for(f=0;f<u;f++)o(d,p.nodes,p.edges);if(!t)return a.collectLayoutChanges(e,p.nodes);a.assignLayoutChanges(e,p.nodes,l)}var c=u.bind(null,!1);c.assign=u.bind(null,!0),c.inferSettings=function(t){var e="number"==typeof t?t:t.order;return{barnesHutOptimize:e>2e3,strongGravityMode:!0,gravity:.05,scalingRatio:10,slowDown:1+Math.log(e)}},t.exports=c},9937:t=>{t.exports={linLogMode:!1,outboundAttractionDistribution:!1,adjustSizes:!1,edgeWeightInfluence:1,scalingRatio:1,strongGravityMode:!1,gravity:1,slowDown:1,barnesHutOptimize:!1,barnesHutTheta:.5}}},e={};function n(r){var i=e[r];if(void 0!==i)return i.exports;var o=e[r]={id:r,loaded:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}n.m=t,n.amdO={},n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.u=t=>t+".js",n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.hmd=t=>((t=Object.create(t)).children||(t.children=[]),Object.defineProperty(t,"exports",{enumerable:!0,set:()=>{throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+t.id)}}),t),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{var t;n.g.importScripts&&(t=n.g.location+"");var e=n.g.document;if(!t&&e&&(e.currentScript&&"SCRIPT"===e.currentScript.tagName.toUpperCase()&&(t=e.currentScript.src),!t)){var r=e.getElementsByTagName("script");if(r.length)for(var i=r.length-1;i>-1&&(!t||!/^http(s?):/.test(t));)t=r[i--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=t})(),n.b=document.baseURI||self.location.href,n.nc=void 0;var r={};(()=>{"use strict";n.r(r),n.d(r,{GetMCLEditor:()=>Tn,MCLClustering:()=>Fn,MVA:()=>Dn,PCA:()=>Mn,PLS:()=>Rn,PackageFunctions:()=>Lr,_package:()=>Ir,anova:()=>ir,applyLinearKernelSVM:()=>Gn,applyLinearRegression:()=>ur,applyPLSRegression:()=>gr,applyPolynomialKernelSVM:()=>$n,applyRBFkernelSVM:()=>Hn,applySigmoidKernelSVM:()=>tr,applySoftmax:()=>hr,applyXGBooster:()=>Ar,dbScan:()=>_n,dbscanPostProcessingFunction:()=>Nn,demoMultivariateAnalysis:()=>kn,info:()=>Cn,init:()=>Sn,isApplicableLinearKernelSVM:()=>Vn,isApplicableLinearRegression:()=>cr,isApplicablePLSRegression:()=>yr,isApplicablePolynomialKernelSVM:()=>Xn,isApplicableRBFkernelSVM:()=>jn,isApplicableSigmoidKernelSVM:()=>er,isApplicableSoftmax:()=>fr,isApplicableXGBooster:()=>Cr,isInteractiveLinearKernelSVM:()=>Bn,isInteractiveLinearRegression:()=>lr,isInteractivePLSRegression:()=>wr,isInteractivePolynomialKernelSVM:()=>Qn,isInteractiveRBFkernelSVM:()=>Kn,isInteractiveSigmoidKernelSVM:()=>nr,isInteractiveSoftmax:()=>pr,isInteractiveXGBooster:()=>Er,kNNImputation:()=>or,kNNImputationForTable:()=>ar,markovClusteringViewer:()=>On,numberPreprocessingFunction:()=>In,reduceDimensionality:()=>Pn,stringPreprocessingFunction:()=>Ln,topMenuPLS:()=>xn,trainLinearKernelSVM:()=>Un,trainLinearRegression:()=>sr,trainPLSRegression:()=>mr,trainPolynomialKernelSVM:()=>Yn,trainRBFkernelSVM:()=>zn,trainSigmoidKernelSVM:()=>Zn,trainSoftmax:()=>dr,trainXGBooster:()=>br,visualizeLinearKernelSVM:()=>Wn,visualizePLSRegression:()=>vr,visualizePolynomialKernelSVM:()=>Jn,visualizeRBFkernelSVM:()=>qn,visualizeSigmoidKernelSVM:()=>rr});const t=grok,e=ui,i=DG,o={i32:"HEAP32",f32:"HEAPF32"},a={i32:Int32Array,f32:Float32Array},s={i32:2,f32:2},u={i32:DG.Column.fromInt32Array,f32:DG.Column.fromFloat32Array};class c{constructor(t){this.data=t}complementArrOfParams(t){t.push(this.data)}complementArrOfTypes(t){t.push("number")}allocateMemoryForBuffer(t){}isMemoryForBufferAllocated(){return!0}putDataToBuffer(t){}getDataFromBuffer(t){}freeBuffer(t){}}class l extends c{constructor(t,e,n=!1){super(t),this.type=e,this.toUpdate=n,this.buf=0,this.numOfRows=t.length}complementArrOfParams(t){t.push(this.buf),t.push(this.numOfRows)}complementArrOfTypes(t){t.push("number"),t.push("number")}allocateMemoryForBuffer(t){this.buf=t._malloc(this.numOfRows*a[this.type].BYTES_PER_ELEMENT)}isMemoryForBufferAllocated(){return 0!=this.buf}putDataToBuffer(t){if(this.isMemoryForBufferAllocated()){const e=this.type,n=s[e],r=t[o[e]];let i=null;const u=this.data;i="int"==u.type&&"i32"==e||"double"==u.type&&"f32"==e?u.getRawData():new a[e](u.getRawData()),i&&r.set(i,this.buf>>n)}}getDataFromBuffer(t){if(this.toUpdate&&this.isMemoryForBufferAllocated()){const e=this.type,n=t[o[e]],r=this.buf,i=a[e].BYTES_PER_ELEMENT,s=this.data.getRawData();for(let t=0;t<this.numOfRows;t++)s[t]=n[r/i+t]}}freeBuffer(t){this.isMemoryForBufferAllocated()&&(t._free(this.buf),this.buf=0)}}class d extends l{constructor(t,e){super([],t,!0),this.numOfRows=e}putDataToBuffer(t){}getDataFromBuffer(t){if(this.toUpdate&&this.isMemoryForBufferAllocated()){const e=this.type,n=t[o[e]],r=this.buf,i=u[e],s=new a[e](this.numOfRows);for(let t=0;t<s.length;t++)s[t]=n[r/s.BYTES_PER_ELEMENT+t];this.data=i("name",s)}}}class h extends c{constructor(t,e,n=!1){super(t),this.type=e,this.toUpdate=n,this.buf=0,this.numOfColumns=t.length,this.numOfRows=t[0].length}complementArrOfParams(t){t.push(this.buf),t.push(this.numOfRows),t.push(this.numOfColumns)}complementArrOfTypes(t){t.push("number"),t.push("number"),t.push("number")}allocateMemoryForBuffer(t){this.buf=t._malloc(this.numOfRows*this.numOfColumns*a[this.type].BYTES_PER_ELEMENT)}isMemoryForBufferAllocated(){return 0!=this.buf}putDataToBuffer(t){if(this.isMemoryForBufferAllocated()){const e=this.type,n=s[e],r=t[o[e]],i=a[e].BYTES_PER_ELEMENT;for(let t=0;t<this.numOfColumns;t++){let o=null;const s=this.data[t];o="int"==s.type&&"i32"==e||"double"==s.type&&"f32"==e?s.getRawData():new a[e](s.getRawData()),null!=o&&r.set(o,this.buf+t*this.numOfRows*i>>n)}}}getDataFromBuffer(t){if(this.toUpdate&&this.isMemoryForBufferAllocated()){const e=this.type,n=t[o[e]],r=this.numOfRows,i=this.numOfColumns,s=new a[e](n.buffer,this.buf,r*i);for(let t=0;t<i;t++){const e=this.data[t].getRawData();for(let n=0;n<r;n++)e[n]=s[n+t*r]}}}freeBuffer(t){this.isMemoryForBufferAllocated()&&(t._free(this.buf),this.buf=0)}}class f extends h{constructor(t,e,n){super([[]],t,!0),this.data=[],this.numOfColumns=n,this.numOfRows=e}putDataToBuffer(t){}getDataFromBuffer(t){if(this.toUpdate&&this.isMemoryForBufferAllocated()){const e=this.type,n=t[o[e]],r=this.numOfRows,i=this.numOfColumns,s=a[e].BYTES_PER_ELEMENT,c=u[e],l=this.buf;for(let t=0;t<i;t++){const i=new a[e](r);for(let e=0;e<r;e++)i[e]=n[l/s+e+t*r];this.data.push(c((t+1).toString(),i))}}}}const p={intColumn:t=>new l(t,"i32"),newIntColumn:t=>new d("i32",t),intColumns:t=>new h(t.toList(),"i32"),newIntColumns:(t,e)=>new f("i32",t,e),floatColumn:t=>new l(t,"f32"),newFloatColumn:t=>new d("f32",t),floatColumns:t=>new h(t.toList(),"f32"),newFloatColumns:(t,e)=>new f("f32",t,e),int:t=>new c(t),num:t=>new c(t)},m={tableFromColumns:t=>DG.DataFrame.fromColumns(t.data),num:t=>t,int:t=>t,double:t=>t,column:t=>t.data};function g(t,e,n){const r=t[e],i=r.arguments,o=[];let a=0;for(const t in i){const e=i[t];if("_callResult"!=t){switch(e.type){case"floatColumns":case"int":case"num":case"floatColumn":case"intColumn":case"intColumns":e.data=p[e.type](n[a]),a++;break;case"newFloatColumns":case"newIntColumns":const t=i[e.numOfRows.ref].data[e.numOfRows.value],r=i[e.numOfColumns.ref].data[e.numOfColumns.value];e.data=p[e.type](t,r);break;case"newFloatColumn":case"newIntColumn":const o=i[e.numOfRows.ref].data[e.numOfRows.value];e.data=p[e.type](o)}o.push(i[t].data)}}const s=function(t,e,n,r){let i;for(const e of r)e.allocateMemoryForBuffer(t);let o=!0;for(const t of r)o&=t.isMemoryForBufferAllocated();if(o){const n=[],o=[];for(const e of r)e.complementArrOfParams(n),e.complementArrOfTypes(o),e.putDataToBuffer(t);const a="number";i=t.ccall(e,a,o,n);for(const e of r)e.getDataFromBuffer(t)}for(const e of r)e.freeBuffer(t);if(null!=i)return i}(t,e,0,o);i._callResult=p.num(s);const u=r.output;if("objects"!=u.type)return m[u.type](i[u.source].data);const c=[];for(const t of u.source)c.push(i[t].data.data);return c}const y="num",v="floatColumn",w="intColumn",b="floatColumns",A="newFloatColumns",E="intColumns",C="newIntColumns",S="newFloatColumn",_="newIntColumn",M="numOfRows",N="numOfColumns",I="ref",L="value",P="int",T="double",F={intColumn:Int32Array,floatColumn:Float32Array,floatColumns:Float32Array,newFloatColumns:Float32Array,intColumns:Int32Array,newIntColumns:Int32Array,newFloatColumn:Float32Array,newIntColumn:Int32Array};function O(t,e){let n,r=[],i=0;for(const o in t){const a=t[o],s=a.type;if("_callResult"!==o){switch(s){case y:case P:case T:a.data=e[i],i++;break;case w:case v:let r;const o=e[i],u=o.length;r=o.type===P&&s===w||o.type===T&&s===v?o.getRawData().slice(0,u):new F[s](o.getRawData().slice(0,u)),a.data={array:r,numOfRows:u},i++;break;case _:case S:let c=0;n=a[M][I],c=t[n].type===y?t[n].data:t[n].data[a[M][L]],a.data={numOfRows:c},i++;break;case E:case b:let l=[];const d=e[i].byIndex(0).length;for(const t of e[i].toList())t.type===P&&s===w||t.type===T&&s===v?l.push(t.getRawData().slice(0,d)):l.push(new F[s](t.getRawData().slice(0,d)));a.data={arrays:l,numOfRows:d,numOfColumns:l.length},i++;break;case C:case A:let h=0,f=0;n=a[M][I],h=t[n].type===y?t[n].data:t[n].data[a[M][L]],n=a[N][I],f=t[n].type===y?t[n].data:t[n].data[a[N][L]],a.data={numOfRows:h,numOfColumns:f},i++;break;default:return}r.push(a)}}return r}function R(t,e){t.arguments._callResult=e.callResult,function(t,e){const n={newFloatColumns:DG.Column.fromFloat32Array,newIntColumns:DG.Column.fromInt32Array,newFloatColumn:DG.Column.fromFloat32Array,newIntColumn:DG.Column.fromInt32Array};let r=0;for(const i in t){const o=t[i];switch(o.type){case y:case P:case T:case w:case v:case b:case E:break;case S:case _:let t;null==o.name?t=(0).toString():s=o.name,o.column=n[o.type](t,e[r].array);break;case C:case A:let i=[],a=e[r].arrays.length,s=[];if(null==o.names)for(let t=1;t<=a;t++)s.push(t.toString());else s=o.names;for(let t=0;t<a;t++)i.push(n[o.type](s[t],e[r].arrays[t]));o.columns=i}r++}}(t.arguments,e.args);let n=function(t){let e=t.output;const n={newFloatColumns:"columns",newIntColumns:"columns",newFloatColumn:"column",newIntColumn:"column"};switch(e.type){case y:case P:case T:return t.arguments[e.source];case"column":return t.arguments[e.source].column;case"tableFromColumns":return DG.DataFrame.fromColumns(t.arguments[e.source].columns);case"objects":let r=[];for(let i of e.source){let e=t.arguments[i];r.push(e[n[e.type]])}return r}}(t);return function(t){for(const e in t){const n=t[e];switch(n.type){case y:case P:case T:case w:case v:case E:case b:break;case _:case S:n.column=null;break;case C:case A:n.columns=null}}}(t.arguments),n}async function x(t,e,r){return new Promise((t,i)=>{const o=new Worker(new URL(n.p+n.u(128),n.b));o.postMessage(O(EDA.principalComponentAnalysisNipals.arguments,[e,r])),o.onmessage=function(e){o.terminate(),t(R(EDA.principalComponentAnalysisNipals,e.data))}})}const D=1e-6;function k(t){if(t.type!=i.COLUMN_TYPE.FLOAT&&t.type!=i.COLUMN_TYPE.INT)throw new Error("unsupported column type: "+t.type)}function U(t){if(t.stats.missingValueCount>0)throw new Error(`The column '${t.name}' has missing values.`)}function G(t,e){if(function(t,e){if(e<1)throw new Error("components must be positive.");if(e>t.length)throw new Error("components must not be greater than features count.");for(const e of t)k(e),U(e)}(t,e),t.length*t.byIndex(0).length>1e8)throw new Error("dataframe is too big.")}function V(t,e,n){return e?n?function(t){const e=t.rowCount;for(const n of t.columns)if(n.isNumerical){const t=n.stats.stdev,r=n.stats.avg,i=n.getRawData();if(t>0)for(let n=0;n<e;++n)i[n]=(i[n]-r)/t;else for(let t=0;t<e;++t)i[t]-=r}return t}(t):function(t){const e=t.rowCount;for(const n of t.columns)if(n.isNumerical){const t=n.stats.avg;if(Math.abs(t)>D){const r=n.getRawData();for(let n=0;n<e;++n)r[n]-=t}}return t}(t):n?function(t){const e=t.rowCount;for(const n of t.columns)if(n.isNumerical){const t=n.stats.stdev;if(Math.abs(t-1)>D&&t>0){const r=n.getRawData();for(let n=0;n<e;++n)r[n]/=t}}return t}(t):t}function B(t,e,r,o,a){return s=this,u=void 0,l=function*(){G(e,r);const s=t.rowCount,u=function(t){const e=[];for(const n of t)n.stats.stdev>0&&n.stats.missingValueCount<1&&e.push(n);return i.DataFrame.fromColumns(e)}(e),c=u.columns.length;if(0===c){const t=[];for(let e=0;e<r;++e)t.push(i.Column.fromFloat32Array(`${e+1}`,new Float32Array(s).fill(0)));return i.DataFrame.fromColumns(t)}const l=c<r?r-c:0,d=Math.min(r,c);let h;if(c>900)h=yield x(0,e,d);else{const t=yield async function(t,e,r){return new Promise((t,i)=>{const o=new Worker(new URL(n.p+n.u(860),n.b));o.postMessage(O(EDA.principalComponentAnalysis.arguments,[e,r,1,0])),o.onmessage=function(e){o.terminate(),0===e.data.callResult?t(R(EDA.principalComponentAnalysis,e.data)):t(-1)}})}(0,e,d);h=-1!==t?V(t,o,a):yield x(0,e,d)}if(void 0===h)throw new Error("Failed to compute PCA");h=V(h,o,a);const f=h.columns,p=f.length;for(let t=0;t<l;++t)f.add(i.Column.fromFloat32Array(`${p+t+1}`,new Float32Array(s).fill(0)));return h},new((c=void 0)||(c=Promise))(function(t,e){function n(t){try{i(l.next(t))}catch(t){e(t)}}function r(t){try{i(l.throw(t))}catch(t){e(t)}}function i(e){var i;e.done?t(e.value):(i=e.value,i instanceof c?i:new c(function(t){t(i)})).then(n,r)}i((l=l.apply(s,u||[])).next())});var s,u,c,l}var W=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}u((r=r.apply(t,e||[])).next())})};const z="incorrect kernel.",H="mean",j="std dev",K="alpha",q="weight",Y="Kernel params",$=["linear","polynomial","RBF","sigmoid"];function X(t,e,r){return W(this,void 0,void 0,function*(){const o=e.columns;if(2!=r.categories.length)throw new Error("labels must be strings of two categories.");const a=i.Column.float(r.name,r.length);for(let t=0;t<r.length;t++)a.set(t,r.get(t)==r.categories[0]?-1:1,!1);const s=yield function(t,e,r){return W(this,void 0,void 0,function*(){!function(t){if(t.gamma<=0)throw new Error("gamma must be strictly positive.");switch(t.kernel){case 0:case 3:return;case 2:if(t.sigma<=0)throw new Error("sigma must be strictly positive.");return;case 1:if(t.cParam<=0)throw new Error("c must be strictly positive.");if(t.dParam<=0)throw new Error("d must be strictly positive.");return;default:throw new Error(z)}}(t);const o=[0,0];switch(t.kernel){case 0:break;case 2:o[0]=t.sigma;break;case 1:o[0]=t.cParam,o[1]=t.dParam;break;case 3:o[0]=t.kappa,o[1]=t.theta;break;default:throw new Error(z)}const a=i.Column.fromList("double",Y,o),s=e.toList(),u=s[0].length+1,c=s.length+1;let l;const d=async function(t,e,r,i,o,a,s,u){return new Promise((a,c)=>{const l=new Worker(new URL(n.p+n.u(656),n.b));l.postMessage(O(EDA.trainAndAnalyzeLSSVM.arguments,[t,e,r,i,o,4,s,u])),l.onmessage=function(t){l.terminate(),a(R(EDA.trainAndAnalyzeLSSVM,t.data))}})}(t.gamma,t.kernel,a,u,c,0,e,r);yield d.then(t=>{l=t},t=>{throw new Error(`Error: ${t}`)}),l[1].name=H,l[2].name=j,l[3].name=K,l[4].name=q,l[5].name="predicted",l[6].name="correctness",l[7].name="Confusion matrix";const h={trainGamma:t.gamma,kernelType:t.kernel,kernelParams:a,trainLabels:r,normalizedTrainData:i.DataFrame.fromColumns(l[0]),means:l[1],stdDevs:l[2],modelParams:l[3],modelWeights:l[4],predictedLabels:l[5],correctness:l[6],confusionMatrix:l[7],trainError:void 0,featuresCount:s.length,trainSamplesCount:s[0].length};return function(t){const e=t.confusionMatrix.getRawData(),n=e[0],r=e[3],i=e[2],o=e[1],a=n+o,s=i+r,u=n/a,c=r/s,l=n/(n+i),d=r/(r+o),h=(n+r)/(a+s),f=(u+c)/2;t.sensitivity=u,t.specificity=c,t.balancedAccuracy=f,t.positivePredicitveValue=l,t.negativePredicitveValue=d,t.trainError=100*(1-h)}(h),h})}(t,o,a);return s.realLabels=r,s})}function Q(t,e){const n=Z(e);return i.Viewer.form(n.modelInfo,{showNavigation:!1}).root}function J(t){const e=t.normalizedTrainData.columns,n=t.trainSamplesCount,r=t.featuresCount,o=i.DataFrame.fromColumns([t.realLabels]).toByteArray(),a=4+o.length+4-o.length%4,s=function(t){const e=t.kernelParams.getRawData();return i.DataFrame.fromColumns([i.Column.fromList("double","Gamma",[t.trainGamma]),i.Column.fromStrings("Kernel",[$[t.kernelType]]),i.Column.fromList("double","Kernel parameter 1",[e[0]]),i.Column.fromList("double","Kernel parameter 2",[e[1]]),i.Column.fromList("double","Features count",[t.featuresCount]),i.Column.fromList("double","Train samples count",[t.trainSamplesCount]),i.Column.fromList("double","Train error, %",[t.trainError]),i.Column.fromList("double","Balanced accuracy",[t.balancedAccuracy]),i.Column.fromList("double","Sensitivity",[t.sensitivity]),i.Column.fromList("double","Specificity",[t.specificity]),i.Column.fromList("double","Positive predicitve value",[t.positivePredicitveValue]),i.Column.fromList("double","Negative predicitve value",[t.negativePredicitveValue])])}(t).toByteArray(),u=4+s.length+4-s.length%4,c=new Uint8Array(4*(5+n+r+r+n+1+r+1+r*n)+a+u),l=c.buffer;let d=0,h=new Int32Array(l,d,3);h[0]=t.kernelType,h[1]=n,h[2]=r,d+=12;let f=new Float32Array(l,d,2);f.set(t.kernelParams.getRawData()),d+=8,f=new Float32Array(l,d,n),f.set(t.trainLabels.getRawData()),d+=4*n,f=new Float32Array(l,d,r),f.set(t.means.getRawData()),d+=4*r,f=new Float32Array(l,d,r),f.set(t.stdDevs.getRawData()),d+=4*r,f=new Float32Array(l,d,n+1),f.set(t.modelParams.getRawData()),d+=4*(n+1),f=new Float32Array(l,d,r+1),f.set(t.modelWeights.getRawData()),d+=4*(r+1);for(const t of e)f=new Float32Array(l,d,r),f.set(t.getRawData()),d+=4*r;return h=new Int32Array(l,d,1),h[0]=o.length,c.set(o,d+4),d+=a,h=new Int32Array(l,d,1),h[0]=s.length,c.set(s,d+4),d+=u,c}function Z(t){const e=t.buffer;let n=0;const r=new Int32Array(e,n,3);n+=12;const o=r[1],a=r[2],s=i.Column.fromFloat32Array(Y,new Float32Array(e,n,2));n+=8;const u=i.Column.fromFloat32Array("Labels",new Float32Array(e,n,o));n+=4*o;const c=i.Column.fromFloat32Array(H,new Float32Array(e,n,a));n+=4*a;const l=i.Column.fromFloat32Array(j,new Float32Array(e,n,a));n+=4*a;const d=i.Column.fromFloat32Array(K,new Float32Array(e,n,o+1));n+=4*(o+1);const h=i.Column.fromFloat32Array(q,new Float32Array(e,n,a+1));n+=4*(a+1);const f=[];for(let t=0;t<o;t++)f.push(i.Column.fromFloat32Array(t.toString(),new Float32Array(e,n,a))),n+=4*a;const p=i.DataFrame.fromColumns(f),m=new Int32Array(e,n,1)[0],g=m+4-m%4;n+=4;const y=i.DataFrame.fromByteArray(new Uint8Array(e,n,m)).columns.byIndex(0);n+=g;const v=new Int32Array(e,n,1)[0],w=v+4-v%4;n+=4;const b=i.DataFrame.fromByteArray(new Uint8Array(e,n,v));return n+=w,{kernelType:r[0],kernelParams:s,trainLabels:u,realLabels:y,means:c,stdDevs:l,modelParams:d,modelWeights:h,normalizedTrainData:p,modelInfo:b}}function tt(t,e){return W(this,void 0,void 0,function*(){const r=Z(new Uint8Array(e)),o=yield function(t,e){return W(this,void 0,void 0,function*(){let r;const i=async function(t,e,r,i,o,a,s,u,c){return new Promise((l,d)=>{const h=new Worker(new URL(n.p+n.u(763),n.b));h.postMessage(O(EDA.predictByLSSVM.arguments,[t,e,r,i,o,a,s,u,c])),h.onmessage=function(t){h.terminate(),l(R(EDA.predictByLSSVM,t.data))}})}(t.kernelType,t.kernelParams,t.normalizedTrainData.columns,t.trainLabels,t.means,t.stdDevs,t.modelParams,t.modelWeights,e);return yield i.then(t=>{r=t},t=>{throw new Error(`Error: ${t}`)}),r})}(r,t.columns),a=i.Column.string("prediction",o.length),s=r.realLabels.categories;for(let t=0;t<a.length;t++)a.set(t,-1==o.get(t)?s[0]:s[1]);return i.DataFrame.fromColumns([a])})}function et(t,e){const n=t.columns;if(!e.matches("categorical")||e.categories.length>2)return!1;let r=!0;for(let t=0;t<n.length;t++)r=r&&n.byIndex(t).matches("numerical");return r}function nt(t,e){return t.rowCount<=1e3}var rt,it,ot,at,st,ut,ct,lt;!function(t){t[t.COMPUTE_COMPONENTS=0]="COMPUTE_COMPONENTS",t[t.PERFORM_MVA=1]="PERFORM_MVA",t[t.DEMO=2]="DEMO"}(rt||(rt={})),function(t){t.NO_DF="No dataframe is opened",t.NO_COLS="No numeric columns without missing values",t.ONE_COL="No columns to be used as features (just one numeric columns without missing values)",t.EMPTY_DF="Dataframe is empty",t.PREDICT="Predictors must not contain a response variable",t.ENOUGH="Not enough of features",t.COMP_LIN_PLS="Components count must be less than the number of features",t.COMP_QUA_PLS="Too large components count for the quadratic PLS regression",t.COMPONENTS="Components count must be greater than 1",t.INV_INP="Invalid inputs"}(it||(it={})),function(t){t.PREDICT="Predict",t.USING="Using",t.COMPONENTS="Components",t.PLS="PLS",t.MVA="Multivariate Analysis (PLS)",t.RUN="RUN",t.NAMES="Names",t.MODEL="Observed vs. Predicted",t.FEATURE="Feature",t.REGR_COEFS="Regression Coefficients",t.XLOADING="x.loading.p",t.LOADINGS="Loadings",t.XSCORE="x.score.t",t.YSCORE="y.score.u",t.SCORES="Scores",t.EXPL_VAR="Explained Variance",t.EXPLORE="Explore",t.FEATURES="Feature names",t.BROWSE="Browse",t.ANALYSIS="Features Analysis",t.QUADRATIC="Quadratic"}(ot||(ot={})),function(t){t.PREDICT="Column with the response variable",t.FEATURES="Predictors (features)",t.COMPONENTS="Number of PLS components",t.PLS="Compute PLS components",t.MVA="Perform multivariate analysis",t.NAMES="Names of data samples",t.QUADRATIC="Specifies whether to include squared terms as additional predictors in the PLS model"}(at||(at={})),function(t){t.PLS="/help/explore/multivariate-analysis#pls-components",t.MVA="/help/explore/multivariate-analysis",t.MODEL="/help/explore/multivariate-analysis#observed-vs-predicted",t.COEFFS="/help/explore/multivariate-analysis#regression-coefficients",t.LOADINGS="/help/explore/multivariate-analysis#loadings",t.EXPL_VARS="/help/explore/multivariate-analysis#explained-variance",t.SCORES="/help/explore/multivariate-analysis#scores"}(st||(st={})),function(t){t[t.DEFAULT=3]="DEFAULT",t[t.MIN=1]="MIN"}(ut||(ut={})),function(t){t.PREFIX="PLS",t.SUFFIX="(predicted)",t.COMP="component",t.COMPS="components"}(ct||(ct={})),function(t){t[t.PREDICTION=0]="PREDICTION",t[t.REGR_COEFFS=1]="REGR_COEFFS",t[t.T_SCORES=2]="T_SCORES",t[t.U_SCORES=3]="U_SCORES",t[t.X_LOADINGS=4]="X_LOADINGS",t[t.Y_LOADINGS=5]="Y_LOADINGS"}(lt||(lt={}));const dt=[.49,.79,.99];var ht;!function(t){t.AXIS="#838383",t.CIRCLE="#0000FF",t.INVALID="#EB6767",t.VALID_TEXT="#4d5261",t.VALID_LINE="#dbdcdf"}(ht||(ht={}));const ft=[{caption:ot.MODEL,text:"Closer to the line means better price prediction."},{caption:ot.SCORES,text:"The latent factor values for each sample reflect the similarities and dissimilarities among observations."},{caption:ot.LOADINGS,text:"The impact of each feature on the latent factors: higher loading means stronger influence."},{caption:ot.REGR_COEFS,text:"Parameters of the obtained model: features make different contribution to the prediction."},{caption:ot.EXPL_VAR,text:"How well the latent components fit source data: closer to one means better fit."}],pt=ft.map(t=>`# ${t.caption}\n\n${t.text}`).join("\n\n")+`\n\n# Learn more\n \n * [Multivariate analysis](${st.MVA}),\n * [ANOVA](https://datagrok.ai/help/explore/anova)`;var mt=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}u((r=r.apply(t,e||[])).next())})};const gt=Math.min;function yt(t){const e=[],n=(t,n)=>{e.push({type:"line",formula:t,width:1,visible:!0,title:" ",min:-n,max:n,color:ht.CIRCLE})};return t.forEach(r=>{const i="${"+r+"}";e.push({type:"line",formula:`${i} = 0`,width:1,visible:!0,title:" ",color:ht.AXIS}),t.forEach(t=>{const e="${"+t+"}";dt.forEach(t=>{n(e+` = sqrt(${t*t} - ${i} * ${i})`,t),n(e+` = -sqrt(${t*t} - ${i} * ${i})`,t)})})}),e}function vt(t){return mt(this,void 0,void 0,function*(){G(t.features,t.components),k(t.predict),U(t.predict);const e=yield async function(t,e,r,i){return new Promise((t,o)=>{const a=new Worker(new URL(n.p+n.u(412),n.b));a.postMessage(O(EDA.partialLeastSquareRegression.arguments,[e,r,i])),a.onmessage=function(e){a.terminate(),t(R(EDA.partialLeastSquareRegression,e.data))}})}(t.table,t.features,t.predict,t.components);return{prediction:e[lt.PREDICTION],regressionCoefficients:e[lt.REGR_COEFFS],tScores:e[lt.T_SCORES],uScores:e[lt.U_SCORES],xLoadings:e[lt.X_LOADINGS],yLoadings:e[lt.Y_LOADINGS]}})}function wt(n){return mt(this,void 0,void 0,function*(){const r=t.shell.t;if(null===r)return void t.shell.warning(it.NO_DF);if(0===r.rowCount)return void t.shell.warning(it.EMPTY_DF);const o=[],a=[],s=[],u=t=>(t.type===i.COLUMN_TYPE.INT||t.type===i.COLUMN_TYPE.FLOAT)&&0===t.stats.missingValueCount;if(r.columns.toList().forEach(t=>{u(t)?(o.push(t.name),a.push(t)):t.type===i.COLUMN_TYPE.STRING&&s.push(t)}),0===o.length)return void t.shell.warning(it.NO_COLS);if(1===o.length)return void t.shell.warning(it.ONE_COL);let c=a.slice(0,a.length-1),l=a[a.length-1],d=gt(o.length-1,ut.DEFAULT),h=!1;const f=e.input.column(ot.PREDICT,{table:r,value:l,nullable:!1,onValueChanged:t=>{l=t,b()},filter:t=>u(t),tooltipText:at.PREDICT}),p=e.input.columns(ot.USING,{table:r,available:o,value:c,onValueChanged:t=>{c=t,b()},tooltipText:at.FEATURES}),m=e.input.int(ot.COMPONENTS,{value:d,showPlusMinus:!0,onValueChanged:t=>{d=t,b()},tooltipText:at.COMPONENTS});let g,y,v;n===rt.COMPUTE_COMPONENTS?(g=ot.PLS,y=st.PLS,v=at.PLS):(g=ot.MVA,y=st.MVA,v=at.MVA);const w=(t,n,r,i)=>{t?(n.style.color=ht.VALID_TEXT,n.style.borderBottomColor=ht.VALID_LINE,e.tooltip.bind(n,r)):(n.style.color=ht.INVALID,n.style.borderBottomColor=ht.INVALID,e.tooltip.bind(n,()=>{const t=e.label(r),n=e.label(i);return n.style.color=ht.INVALID,e.divV([t,n])}))},b=()=>{const t=(()=>{for(const t of c)if(t.name===l.name)return!1;return!0})();let e;if(t?(w(!0,f.input,at.PREDICT,""),w(!0,p.input,at.FEATURES,"")):(w(!1,f.input,at.PREDICT,it.PREDICT),w(!1,p.input,at.FEATURES,it.PREDICT)),d<1)w(!1,m.input,at.COMPONENTS,it.COMPONENTS),e=!1;else if(e=(()=>{if(d<1)return!1;const t=c.length;return h?d<=(t+1)*t/2+t:d<=t})(),e)w(!0,m.input,at.COMPONENTS,""),t&&w(!0,p.input,at.FEATURES,"");else{const t=h?it.COMP_QUA_PLS:it.COMP_LIN_PLS;w(!1,m.input,at.COMPONENTS,t),w(!1,p.input,at.FEATURES,it.ENOUGH)}const n=t&&e;return S.getButton(ot.RUN).disabled=!n,n};let A=s.length>0?s[0]:void 0;const E=e.input.column(ot.NAMES,{table:r,value:A,onValueChanged:t=>A=null!=t?t:void 0,filter:t=>t.type===i.COLUMN_TYPE.STRING});E.setTooltip(at.NAMES),E.root.hidden=0===s.length||n===rt.COMPUTE_COMPONENTS;const C=e.input.bool(ot.QUADRATIC,{value:h,tooltipText:at.QUADRATIC,onValueChanged:t=>{h=t,b()}}),S=e.dialog({title:g,helpUrl:y}).add(e.form([f,p,m,C,E])).addButton(ot.RUN,()=>mt(this,void 0,void 0,function*(){S.close(),yield function(n,r){return mt(this,void 0,void 0,function*(){var o,a;const s=n.table;n.isQuadratic&&(n=function(t){if(!t.isQuadratic)return t;const e=t.features.toList(),n=e.length,r=t.table.rowCount,o=[];let a,s,u,c,l;for(let t=0;t<n;++t){a=e[t],s=a.getRawData();for(let d=t;d<n;++d){u=e[d],c=u.getRawData(),l=new Float32Array(r);for(let t=0;t<r;++t)l[t]=s[t]*c[t];const t=i.Column.fromFloat32Array(`${a.name} x ${u.name}`,l);t.stats.stdev>0&&o.push(t)}}const d=i.DataFrame.fromColumns(e.concat(o));return{table:d,features:d.columns,isQuadratic:!0,names:t.names,predict:t.predict,components:t.components}}(n));const u=yield vt(n),c=u.tScores,l=s.columns,d=n.features,h=d.names(),f=r===rt.COMPUTE_COMPONENTS?ct.PREFIX:ot.XSCORE;if(c.forEach((t,e)=>{t.name=l.getUnusedName(`${f}${e+1}`),l.add(t)}),r===rt.COMPUTE_COMPONENTS)return;const p=t.shell.tableView(s.name),m=i.DataFrame.fromColumns([i.Column.fromStrings(ot.FEATURE,h),u.regressionCoefficients]);m.name=`${s.name}(${ot.ANALYSIS})`,t.shell.addTable(m),u.xLoadings.forEach((t,e)=>{t.name=m.columns.getUnusedName(`${ot.XLOADING}${e+1}`),m.columns.add(t)});const g=function(t,e,n,r){const o=n.length,a=t.length,s=e.getRawData(),u=new Float32Array(o),c=r.getRawData();let l=n.stats.avg;for(let e=0;e<a;++e)l-=s[e]*t.byIndex(e).stats.avg;for(let t=0;t<o;++t)u[t]=l+c[t];return i.Column.fromFloat32Array("Debiased",u,o)}(d,u.regressionCoefficients,n.predict,u.prediction);g.name=l.getUnusedName(`${n.predict.name} ${ct.SUFFIX}`),l.add(g);const y=p.addViewer(i.Viewer.scatterPlot(s,{title:ot.MODEL,xColumnName:n.predict.name,yColumnName:g.name,showRegressionLine:!0,markerType:i.MARKER_TYPE.CIRCLE,showLabels:"Always",help:st.MODEL}));void 0!==n.names&&null!==n.names&&y.setOptions({labelColumnNames:[null===(o=n.names)||void 0===o?void 0:o.name]}),u.regressionCoefficients.name=ot.REGR_COEFS;const v=p.addViewer(i.Viewer.barChart(m,{table:m.name,title:ot.REGR_COEFS,splitColumnName:ot.FEATURE,valueColumnName:u.regressionCoefficients.name,valueAggrType:i.AGG.AVG,help:st.COEFFS,showValueSelector:!1,showStackSelector:!1}));u.xLoadings.forEach((t,e)=>t.name=`${ot.XLOADING}${e+1}`);const w=p.addViewer(i.Viewer.scatterPlot(m,{table:m.name,title:ot.LOADINGS,xColumnName:`${ot.XLOADING}1`,yColumnName:`${ot.XLOADING}${u.xLoadings.length>1?"2":"1"}`,markerType:i.MARKER_TYPE.CIRCLE,labelColumnNames:[ot.FEATURE],help:st.LOADINGS})),b=c.map(t=>t.name);u.uScores.forEach((t,e)=>{t.name=l.getUnusedName(`${ot.YSCORE}${e+1}`),l.add(t),b.push(t.name)});const A=i.Viewer.scatterPlot(s,{title:ot.SCORES,xColumnName:c[0].name,yColumnName:c.length>1?c[1].name:u.uScores[0].name,markerType:i.MARKER_TYPE.CIRCLE,help:st.SCORES,showViewerFormulaLines:!0,labelColumnNames:void 0!==n.names&&null!==n.names?[null===(a=n.names)||void 0===a?void 0:a.name]:void 0});p.addViewer(A),A.meta.formulaLines.addAll(yt(b));const E=u.yLoadings.getRawData(),C=u.xLoadings.map(t=>t.getRawData()),S=s.rowCount,_=h.length,M=n.components,N=new Float32Array(M),I=[],L=[];for(let t=0;t<_;++t)L.push(new Float32Array(M));N[0]=Math.pow(E[0],2)/S,I.push(`1 ${ct.COMP}`),L.forEach((t,e)=>{t[0]=Math.pow(C[0][e],2)/S});for(let t=1;t<M;++t)N[t]=N[t-1]+Math.pow(E[t],2)/S,L.forEach((e,n)=>e[t]=e[t-1]+Math.pow(C[t][n],2)/S),I.push(`${t+1} ${ct.COMPS}`);const P=i.DataFrame.fromColumns([i.Column.fromStrings(ot.COMPONENTS,I),i.Column.fromFloat32Array(n.predict.name,N)]);P.name=`${s.name}(${ot.EXPL_VAR})`,t.shell.addTable(P),L.forEach((t,e)=>P.columns.add(i.Column.fromFloat32Array(h[e],t)));const T=p.addViewer(i.Viewer.barChart(P,{table:P.name,title:ot.EXPL_VAR,splitColumnName:ot.COMPONENTS,valueColumnName:n.predict.name,valueAggrType:i.AGG.AVG,help:st.EXPL_VARS,showCategorySelector:!1,showStackSelector:!1}));r===rt.DEMO&&(t.shell.windows.help.showHelp(e.markdown(pt)),function(t,n,r){if(t.length!==n.length)throw new Error("Non-equal size of viewer roots and descriptions");let i,o,a,s=0;const u=e.button("next",()=>{a.remove(),++s,h()},"Go to the next viewer"),c=e.button("prev",()=>{s-=1,a.remove(),h()},"Go to the previous viewer"),l=e.button("done",()=>a.remove(),"Go to the next step"),d=e.divH([c,u,l]);d.style.marginLeft="auto",d.style.marginRight="0px";const h=()=>{s<t.length&&(o=e.divV([e.markdown(n[s]),d]),a=e.hints.addHint(t[s],o,r[s]),l.hidden=s<t.length-1,u.hidden=s===t.length-1,c.hidden=s<1,i=a.querySelector("i"),i.onclick=()=>l.click())};h()}([y,A,w,v,T].map(t=>t.root),ft.map(t=>`<b>${t.caption}</b>\n\n${t.text}`),["left","left","right","right","left"]))})}({table:r,features:i.DataFrame.fromColumns(c).columns,predict:l,components:d,isQuadratic:h,names:A},n)}),void 0,v).show({x:200,y:200});setTimeout(()=>{p.value=a.filter(t=>t!==l),c=p.value},6),t.shell.v.append(S.root)})}Math.max;var bt,At=n(6572);!function(t){t.NO_DATAFRAME="No dataframe is opened",t.NO_MISSING_VALUES="No missing values",t.ONE_AVAILABLE_FEATURE="Not enough of feature columns to apply imputation using the KNN method",t.ONE_FEATURE_SELECTED="Imputation cannot be applied to",t.UNSUPPORTED_COLUMN_TYPE="Unsupported column type",t.UNSUPPORTED_IMPUTATION_STRATEGY="Unsupported imputation strategy",t.KNN_CANNOT_BE_APPLIED="KNN imputer cannot be applied: no columns to be used as features",t.KNN_NO_TARGET_COLUMNS="KNN imputer cannot be applied: no columns with missing values",t.KNN_NO_FEATURE_COLUMNS="KNN imputer cannot be applied: no feature columns",t.KNN_NOT_ENOUGH_OF_ROWS="KNN imputer cannot be applied: not enough of rows",t.KNN_IMPOSSIBLE_IMPUTATION="Imputation is impossible, no features can be used",t.INCORRECT_NEIGHBORS="Incorrect number of neighbors",t.KNN_FAILS="KNN IMPUTATION FAILS",t.CORE_ISSUE="Core issue",t.FAILED_TO_IMPUTE="Failed to impute",t.UNSUPPORTED_FILL_VALUE_TYPE="Unsupported fill value type",t.EMPTY_COLUMN="Column contains just null values",t.FAILS_TO_PREDICT_IMPUTATION_FAILS="Failed to predict imputation fails",t.WRONG_PREDICTIONS="wrong evaluation of KNN imputation fails"}(bt||(bt={}));const Et="copy";var Ct,St;!function(t){t.KNN_IMPUTER="k-NN Imputation",t.TABLE="Table",t.IN_PLACE="In-place",t.COLUMNS="Impute",t.FEATURES="Using",t.CANCEL="CANCEL",t.RUN="RUN",t.OK="OK",t.NEIGHBORS="Neighbors",t.DISTANCE="Distance",t.FILL="Fill",t.MARK="Mark",t.SIMPLE_IMPUTER="Simple impute",t.SETTINGS="Settings",t.KEEP_EMPTY="Keep empty"}(Ct||(Ct={})),function(t){t.TARGET="Columns with missing values that must be filled",t.FEATURES="Columns with features to be used for determining the 'nearest' elements in the k-NN method",t.IN_PLACE="Defines whether to use in-place imputation or add a new column without missing values",t.METRIC="Type of metric between the feature values",t.WEIGHT="Weight",t.NEIGHBORS="Neighbors count used in the KNN method",t.DISTANCE="Type of distance between elements with the specified features",t.METRIC_SETTINGS="Show additional options",t.FILL_FAILED_ITEMS="Impute missing values using a simple approach: mean, median or most frequent",t.MARK_FAILED_ITEMS="Mark missing values cells with a color",t.FILL_VALUE="Fill value",t.IMPUTATION_SETTINGS="Simple imputation settings",t.KEEP_EMPTY="Defines whether to keep empty missing values failed to be imputed OR fill them using simple imputation",t.RUN="Run imputation using the k-NN method"}(St||(St={}));const _t=[i.COLUMN_TYPE.INT,i.COLUMN_TYPE.FLOAT,i.COLUMN_TYPE.STRING,i.COLUMN_TYPE.DATE_TIME,i.COLUMN_TYPE.QNUM];function Mt(t){switch(t.type){case i.COLUMN_TYPE.INT:return i.INT_NULL;case i.COLUMN_TYPE.FLOAT:case i.COLUMN_TYPE.QNUM:case i.COLUMN_TYPE.DATE_TIME:return i.FLOAT_NULL;case i.COLUMN_TYPE.STRING:return t.max;default:throw new Error(bt.UNSUPPORTED_COLUMN_TYPE)}}var Nt,It,Lt,Pt;function Tt(t,e,n){for(const t of e)if(!n.has(t))return!1;for(const r of t){const t=n.get(r);if(void 0===t)throw new Error(bt.FAILS_TO_PREDICT_IMPUTATION_FAILS);for(const r of t){let t=!0;for(const i of e){const e=n.get(i);if(void 0===e)throw new Error(bt.FAILS_TO_PREDICT_IMPUTATION_FAILS);if(!e.includes(r)){t=!1;break}}if(t)return!0}}return!1}function Ft(t){if(t<=0||t>=1)throw new Error(Pt.INCORRECT_SIGNIFICANCE_LEVEL)}function Ot(t){const e=t.size;return e<=1?0:(t.sumOfSquares-Math.pow(t.sum,2)/e)/(e-1)}function Rt(t,e,n){Ft(n);const r=Ot(t),i=Ot(e);return 0===r||0===i?r===i:r/i<At.centralF.inv(1-n,t.size-1,e.size-1)}!function(t){t.ONE_HOT="One-hot",t.DIFFERENCE="Difference"}(Nt||(Nt={})),function(t){t.EUCLIDEAN="Euclidean",t.MANHATTAN="Manhattan"}(It||(It={})),function(t){t[t.WEIGHT=1]="WEIGHT",t[t.NEIGHBORS=4]="NEIGHBORS",t[t.IN_PLACE=1]="IN_PLACE",t[t.SELECTED=1]="SELECTED",t[t.KEEP_EMPTY=0]="KEEP_EMPTY"}(Lt||(Lt={})),function(t){t.NON_EQUAL_FACTORS_VALUES_SIZE="non-equal sizes of factor and values arrays",t.INCORRECT_SIGNIFICANCE_LEVEL="incorrect significance level",t.NON_EQUAL_VARIANCES="non-equal variances",t.NON_NORMAL_DISTRIB="non-normal distribution",t.UNSUPPORTED_COLUMN_TYPE="unsupported feature column type",t.INCORRECT_CATEGORIES_COL_TYPE="incorrect categories column type",t.SINGLE_FACTOR="single category features",t.CATS_EQUAL_SIZE="single value in each category",t.NO_FEATURE_VARIATION="no feature variation",t.NO_FEATURE_VARIATION_WITHIN_GROUPS="no feature variation within groups"}(Pt||(Pt={}));class xt{constructor(t,e,n){if(this.nullsCount=0,t.length!==e.length)throw new Error(Pt.NON_EQUAL_FACTORS_VALUES_SIZE);if(!(e.stats.stdev>0))throw new Error(Pt.NO_FEATURE_VARIATION);this.setStats(t,e,n)}areVarsEqual(t){const e=this.catCount;if(1===e)return!0;const n={sum:this.sums[0],sumOfSquares:this.sumsOfSquares[0],size:this.subSampleSizes[0]};for(let r=1;r<e;++r)if(!Rt(n,{sum:this.sums[r],sumOfSquares:this.sumsOfSquares[r],size:this.subSampleSizes[r]},t))return!1;return!0}getOneWayAnova(){let t=0,e=0,n=0,r=this.catCount,i=r;for(let o=0;o<r;++o)0!==this.subSampleSizes[o]?(t+=this.sums[o],e+=this.sumsOfSquares[o],n+=Math.pow(this.sums[o],2)/this.subSampleSizes[o]):--i;if(r=i,1===r)throw new Error(Pt.SINGLE_FACTOR);const o=this.size-this.nullsCount;if(o===r)throw new Error(Pt.CATS_EQUAL_SIZE);const a=e-Math.pow(t,2)/o,s=n-Math.pow(t,2)/o,u=a-s;if(0===u)throw new Error(Pt.NO_FEATURE_VARIATION_WITHIN_GROUPS);const c=r-1,l=o-r,d=s/c,h=u/l,f=d/h;return{ssBn:s,ssWn:u,ssTot:a,dfBn:c,dfWn:l,dfTot:o-1,msBn:d,msWn:h,fStat:f,pValue:1-At.centralF.cdf(f,c,l)}}setStats(t,e,n){const r=e.type,o=e.length,a=Mt(e);switch(r){case i.COLUMN_TYPE.INT:case i.COLUMN_TYPE.FLOAT:const r=n;this.catCount=r,this.size=o;const s=e.getRawData(),u=t.getRawData(),c=new Float64Array(r).fill(0),l=new Float64Array(r).fill(0),d=new Int32Array(r).fill(0);let h;if(t.type==i.COLUMN_TYPE.BOOL){let t=0,e=0,n=u[0];const r=8*u.BYTES_PER_ELEMENT-1;for(let i=0;i<o;++i)h=1&n>>e,s[i]!==a?(c[h]+=s[i],l[h]+=Math.pow(s[i],2),++d[h]):++this.nullsCount,++e,e>r&&(e=0,++t,n=u[t])}else{const e=t.stats.missingValueCount>0?Mt(t):-1;for(let t=0;t<o;++t)h=u[t],h!==e&&s[t]!==a?(c[h]+=s[t],l[h]+=Math.pow(s[t],2),++d[h]):++this.nullsCount}this.sums=c,this.sumsOfSquares=l,this.subSampleSizes=d;break;default:throw new Error(Pt.UNSUPPORTED_COLUMN_TYPE)}}}const Dt=[i.COLUMN_TYPE.INT,i.COLUMN_TYPE.FLOAT],kt=[i.COLUMN_TYPE.STRING,i.COLUMN_TYPE.BOOL],Ut="/help/explore/anova";var Gt,Vt;function Bt(){const n=t.shell.t;if(null===n)return void t.shell.warning("No dataframe is opened");const r=n.columns,o=[],a=[];for(const t of r)Dt.includes(t.type)?a.push(t.name):kt.includes(t.type)&&o.push(t.name);const s=o.length;if(s<1)return void t.shell.warning(e.markdown(`No acceptable factor columns:\n\n - type: ${kt.join(", ")} \n - at least two categories`));let u=n.col(Vt.FACTOR);if(null===u){let t,e=0,n=r.byName(o[0]).categories.length;for(let i=1;i<s;++i)t=r.byName(o[i]).categories.length,t<n&&(n=t,e=i);u=r.byName(o[e])}if(a.length<1)return void t.shell.warning(e.markdown(`No acceptable feature columns:\n \n - type: ${Dt.join(", ")}`));const c=e.input.column("Category",{table:n,value:u,tooltipText:"Column with factor values",onValueChanged:t=>u=t,filter:t=>o.includes(t.name),nullable:!1});let l=n.col(Vt.FEATURE);null===l&&(l=r.byName(a[0]));const d=e.input.column("Feature",{table:n,value:l,tooltipText:"Column with feature values",onValueChanged:t=>l=t,filter:t=>a.includes(t.name),nullable:!1});let h=Gt.DEFAULT;const f=e.input.float("Alpha",{min:Gt.MIN,max:Gt.MAX,value:h,nullable:!1,tooltipText:"Significance level",onValueChanged:t=>{h=t,g.disabled=h<=Gt.INFIMUM||h>=Gt.SUPREMUM}}),p=e.dialog({title:"ANOVA",helpUrl:Ut}),m=t.shell.getTableView(n.name);m.root.appendChild(p.root),p.addButton("Run",()=>{p.close();try{const r=function(t,e,n,r=!0){Ft(n);const i=t.stats.uniqueCount;if(i<2)throw new Error(Pt.SINGLE_FACTOR);const o=new xt(t,e,i);if(r&&!o.areVarsEqual(n))throw new Error(Pt.NON_EQUAL_VARIANCES);const a=o.getOneWayAnova();return{anovaTable:a,fCritical:At.centralF.inv(1-n,a.dfBn,a.dfWn),significance:n}}(u,l,h);!function(n,r,o,a){const s=t.shell.getTableView(n.name);t.shell.v=s;const u=a.anovaTable.fStat>a.fCritical,c=u?`"${r}" affects the "${o}"`:`"${r}" doesn't affect the "${o}"`,l=i.Viewer.boxPlot(n,{categoryColumnNames:[r],valueColumnName:o,showPValue:!1,showStatistics:!1,description:c,showColorSelector:!1,autoLayout:!1});let d=s.dockManager.dock(l,i.DOCK_TYPE.RIGHT,null,"ANOVA");const h=e.markdown("**Null Hypothesis:** all group means are equal.");e.tooltip.bind(h,`The "${r}" factor does not produce a significant difference in the "${o}" feature.`);const f=e.markdown("**Alternative Hypothesis:** at least one group mean differs significantly.");e.tooltip.bind(f,`The "${r}" factor produces a significant difference in the "${o}" feature.`);const p=e.markdown("**Conclusion:** "+(u?"significant differences exist between groups.":"no significant differences detected.")),m=u?e.divV([e.p(`Reject the null hypothesis, since F > F-critical: \n ${a.anovaTable.fStat.toFixed(2)} > ${a.fCritical.toFixed(2)}.`),e.h2("There is a significant difference among sample averages.")]):e.divV([e.p(`Fail to reject the null hypothesis, since F < F-critical: \n ${a.anovaTable.fStat.toFixed(2)} < ${a.fCritical.toFixed(2)}.`),e.h2("There is no significant difference among sample averages.")]);e.tooltip.bind(p,()=>m);const g=e.divV([h,f,p,e.link("Learn more",()=>window.open("https://en.wikipedia.org/wiki/F-test","_blank"),"Click to open in a new tab.")]);g.style.marginLeft="20px";const y=function(t){const n=t.anovaTable,r=i.Viewer.grid(i.DataFrame.fromColumns([i.Column.fromStrings("Source of variance",["Between groups","Within groups","Total"]),i.Column.fromList(i.COLUMN_TYPE.FLOAT,"SS",[n.ssBn,n.ssWn,n.ssTot]),i.Column.fromList(i.COLUMN_TYPE.INT,"DF",[n.dfBn,n.dfWn,n.dfTot]),i.Column.fromList(i.COLUMN_TYPE.FLOAT,"MS",[n.msBn,n.msWn,null]),i.Column.fromList(i.COLUMN_TYPE.FLOAT,"F",[n.fStat,null,null]),i.Column.fromList(i.COLUMN_TYPE.FLOAT,"F-critical",[t.fCritical,null,null]),i.Column.fromList(i.COLUMN_TYPE.FLOAT,"p-value",[n.pValue,null,null])])),o=new Map([["Source of variance","List of the explored variation sources."],["SS","Sum of squares (SS). Measure of total variation in the data."],["DF","Degrees of freedom (DF). Number of independent values that can vary."],["MS","Mean square (MS). Sum of squares divided by degrees of freedom."],["F","F-statistics (F). Ratio of between-group to within-group variance."],["F-critical",`${t.significance}-critical value of F-statistics.`],["p-value","Probability of observing this result if groups have equal means."]]);return r.onCellTooltip(function(t,n,r){if(t.isColHeader)return e.tooltip.show(e.divV([e.p(o.get(t.tableColumn.name))]),n,r),!0}),r.helpUrl=Ut,r}(a),v=e.tabControl({Analysis:e.panel([y.root]),"F-test":e.panel([g])});e.tooltip.bind(v.getPane("Analysis").header,"ANOVA results summary."),e.tooltip.bind(v.getPane("F-test").header,"Null hypothesis testing."),s.dockManager.dock(v.root,i.DOCK_TYPE.DOWN,d,"",.25),y.root.style.width="100%"}(n,u.name,l.name,r)}catch(n){n instanceof Error?(t.shell.warning((r=n.message,e.divV([e.markdown(`ANOVA cannot be performed:\n \n ${r}`),e.link("Learn more",()=>window.open("https://en.wikipedia.org/wiki/Analysis_of_variance#Assumptions","_blank"),"Click to open in a new tab")]))),m.addViewer(i.VIEWER.BOX_PLOT,{categoryColumnNames:[u.name],valueColumnName:l.name,showStatistics:!1,showPValue:!1})):t.shell.error("ANOVA fails: the platform issue")}var r},void 0,"Perform analysis of variances");const g=p.getButton("Run");p.add(c).add(d).add(f).show()}!function(t){t[t.DEFAULT=.05]="DEFAULT",t[t.MIN=.01]="MIN",t[t.MAX=.99]="MAX",t[t.INFIMUM=0]="INFIMUM",t[t.SUPREMUM=1]="SUPREMUM"}(Gt||(Gt={})),function(t){t.FACTOR="race",t.FEATURE="age"}(Vt||(Vt={}));function Wt(t,e,r,i){return o=this,a=void 0,u=function*(){return new Promise(function(o,a){const s=new Worker(new URL(n.p+n.u(682),n.b));s.postMessage({embedX:t,embedY:e,minPts:i,epsilon:r}),s.onmessage=({data:{error:t,clusters:e}})=>{s.terminate(),t?a(t):o(e)}})},new((s=void 0)||(s=Promise))(function(t,e){function n(t){try{i(u.next(t))}catch(t){e(t)}}function r(t){try{i(u.throw(t))}catch(t){e(t)}}function i(e){var i;e.done?t(e.value):(i=e.value,i instanceof s?i:new s(function(t){t(i)})).then(n,r)}i((u=u.apply(o,a||[])).next())});var o,a,s,u}n(5540);let zt=null;function Ht(){return t=this,e=void 0,r=function*(){if(!navigator.gpu)return console.error("WebGPU is not supported in this browser"),null;if(!zt&&(zt=yield navigator.gpu.requestAdapter(),null==zt))return null;let t=null;return"info"in zt&&(t=zt.info),t?jt(t.description,jt(t.vendor,"No GPU description available")):"No GPU description available"},new((n=void 0)||(n=Promise))(function(i,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}u((r=r.apply(t,e||[])).next())});var t,e,n,r}function jt(t,e){return t&&""!=t?t:e}var Kt,qt,Yt,$t,Xt,Qt,Jt,Zt,te;(qt=Kt||(Kt={})).EUCLIDEAN="EUCLIDEAN",qt.MANHATTAN="MANHATTAN",Kt.EUCLIDEAN,Kt.MANHATTAN,($t=Yt||(Yt={})).HAMMING="Hamming",$t.EUCLIDEAN="Euclidean",$t.VECTOR_COSINE="Vector Cosine",$t.MANHATTAN="Manhattan",$t.TANIMOTO="Tanimoto",$t.LEVENSTEIN="Levenshtein",$t.NEEDLEMAN_WUNSCH="Needlemann-Wunsch",$t.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance",$t.SOKAL="Sokal",$t.COSINE="Cosine",$t.ASYMMETRIC="Asymmetric",$t.Difference="Difference",$t.OneHot="One-Hot",Yt.HAMMING,Yt.EUCLIDEAN,Yt.MANHATTAN,Yt.VECTOR_COSINE,Yt.TANIMOTO,Yt.LEVENSTEIN,Yt.NEEDLEMAN_WUNSCH,Yt.MONOMER_CHEMICAL_DISTANCE,Yt.SOKAL,Yt.COSINE,Yt.ASYMMETRIC,Yt.Difference,Yt.OneHot,Yt.HAMMING,Yt.EUCLIDEAN,Yt.MANHATTAN,Yt.TANIMOTO,Yt.SOKAL,Yt.COSINE,Yt.ASYMMETRIC,Yt.LEVENSTEIN,Yt.NEEDLEMAN_WUNSCH,Yt.MONOMER_CHEMICAL_DISTANCE,Yt.Difference,Yt.OneHot,Yt.VECTOR_COSINE,new Set([Yt.HAMMING,Yt.LEVENSTEIN,Yt.NEEDLEMAN_WUNSCH,Yt.MONOMER_CHEMICAL_DISTANCE,Yt.OneHot]),new Set([Yt.HAMMING,Yt.EUCLIDEAN,Yt.MANHATTAN,Yt.MONOMER_CHEMICAL_DISTANCE,Yt.LEVENSTEIN,Yt.NEEDLEMAN_WUNSCH,Yt.TANIMOTO,Yt.COSINE,Yt.VECTOR_COSINE,Yt.SOKAL,Yt.ASYMMETRIC,Yt.OneHot,Yt.Difference]),new Set([Yt.EUCLIDEAN,Yt.MANHATTAN,Yt.OneHot,Yt.Difference,Yt.VECTOR_COSINE]),new Set([Yt.EUCLIDEAN,Yt.MANHATTAN,Yt.Difference,Yt.VECTOR_COSINE]),new Set([Yt.EUCLIDEAN,Yt.MANHATTAN,Yt.Difference]),new Set([Yt.TANIMOTO,Yt.COSINE,Yt.SOKAL,Yt.ASYMMETRIC]),function(t){t.ADD="ADD",t.SUB="SUB",t.MULT="MULT"}(Xt||(Xt={})),function(t){t.SQUARE="SQUARE",t.INVERSE="INVERSE",t.TRANSPOSE="TRANSPOSE",t.NORM="NORM",t.COLUMN_NORM="COLUMN_NORM"}(Qt||(Qt={})),function(t){t.SCALARMULT="SCALARMULT",t.SCALARADD="SCALARADD",t.SCALARPOW="SCALARPOW"}(Jt||(Jt={})),Object.prototype.toString,(te=Zt||(Zt={})).UMAP="UMAP",te.T_SNE="t-SNE",Promise.resolve(),n(934),n(8903);const ee=2;i.SEMTYPE.MOLECULE,i.SEMTYPE.MACROMOLECULE;class ne{constructor(){this.epsilon={uiName:"Epsilon",value:.01,tooltip:"Minimum distance between cluster points",min:0,max:2,step:.005},this.minPts={uiName:"Minimum points",value:4,tooltip:"Minimum number of points in cluster",min:1,max:1e3,step:1}}}const re="bypassLargeDataWarning";var ie,oe;(oe=ie||(ie={})).EUCLIDEAN="EUCLIDEAN",oe.MANHATTAN="MANHATTAN";const ae=rxjs;var se,ue,ce,le,de,he,fe,pe,me=n(5072),ge=n.n(me),ye=n(7825),ve=n.n(ye),we=n(7659),be=n.n(we),Ae=n(5056),Ee=n.n(Ae),Ce=n(540),Se=n.n(Ce),_e=n(1113),Me=n.n(_e),Ne=n(7939),Ie={};Ie.styleTagTransform=Me(),Ie.setAttributes=Ee(),Ie.insert=be().bind(null,"head"),Ie.domAPI=ve(),Ie.insertStyleElement=Se(),ge()(Ne.A,Ie),Ne.A&&Ne.A.locals&&Ne.A.locals,function(t){t.Levenshtein="Levenshtein",t.JaroWinkler="Jaro-Winkler",t.Manhattan="Manhattan String",t.Onehot="One-Hot"}(se||(se={})),function(t){t.Euclidean="Euclidean",t.Manhattan="Manhattan",t.Cosine="Vector Cosine"}(ue||(ue={})),function(t){t.Tanimoto="Tanimoto",t.Dice="Dice",t.Asymmetric="Asymmetric",t.BraunBlanquet="Braun-Blanquet",t.Cosine="Cosine",t.Kulczynski="Kulczynski",t.McConnaughey="Mc-Connaughey",t.RogotGoldberg="Rogot-Goldberg",t.Russel="Russel",t.Sokal="Sokal",t.Hamming="Hamming",t.Euclidean="Euclidean BitArray"}(ce||(ce={})),function(t){t.TanimotoIntArray="TanimotoIntArray"}(le||(le={})),(pe=de||(de={})).Vector="Vector",pe.String="String",pe.BitArray="BitArray",pe.MacroMolecule="MacroMolecule",pe.Number="Number",pe.IntArray="IntArray",pe.NumberArray="NumberArray",function(t){t.Difference="Difference"}(he||(he={})),function(t){t.CommonItems="Common Items"}(fe||(fe={}));const Le=new Uint32Array(65536),Pe=(t,e)=>{if(t.length<e.length){const n=e;e=t,t=n}return 0===e.length?t.length:t.length<=32?((t,e)=>{const n=t.length,r=e.length,i=1<<n-1;let o=-1,a=0,s=n,u=n;for(;u--;)Le[t.charCodeAt(u)]|=1<<u;for(u=0;u<r;u++){let t=Le[e.charCodeAt(u)];const n=t|a;t|=(t&o)+o^o,a|=~(t|o),o&=t,a&i&&s++,o&i&&s--,a=a<<1|1,o=o<<1|~(n|a),a&=n}for(u=n;u--;)Le[t.charCodeAt(u)]=0;return s})(t,e):((t,e)=>{const n=e.length,r=t.length,i=[],o=[],a=Math.ceil(n/32),s=Math.ceil(r/32);for(let t=0;t<a;t++)o[t]=-1,i[t]=0;let u=0;for(;u<s-1;u++){let a=0,s=-1;const c=32*u,l=Math.min(32,r)+c;for(let e=c;e<l;e++)Le[t.charCodeAt(e)]|=1<<e;for(let t=0;t<n;t++){const n=Le[e.charCodeAt(t)],r=o[t/32|0]>>>t&1,u=i[t/32|0]>>>t&1,c=n|a,l=((n|u)&s)+s^s|n|u;let d=a|~(l|s),h=s&l;d>>>31^r&&(o[t/32|0]^=1<<t),h>>>31^u&&(i[t/32|0]^=1<<t),d=d<<1|r,h=h<<1|u,s=h|~(c|d),a=d&c}for(let e=c;e<l;e++)Le[t.charCodeAt(e)]=0}let c=0,l=-1;const d=32*u,h=Math.min(32,r-d)+d;for(let e=d;e<h;e++)Le[t.charCodeAt(e)]|=1<<e;let f=r;for(let t=0;t<n;t++){const n=Le[e.charCodeAt(t)],a=o[t/32|0]>>>t&1,s=i[t/32|0]>>>t&1,u=n|c,d=((n|s)&l)+l^l|n|s;let h=c|~(d|l),p=l&d;f+=h>>>r-1&1,f-=p>>>r-1&1,h>>>31^a&&(o[t/32|0]^=1<<t),p>>>31^s&&(i[t/32|0]^=1<<t),h=h<<1|a,p=p<<1|s,l=p|~(u|h),c=h&u}for(let e=d;e<h;e++)Le[t.charCodeAt(e)]=0;return f})(t,e)};var Te=n(944);class Fe{constructor(t,e=!1){if(this._length=0,this._version=0,this._updateLevel=0,this._selectedCount=0,this._selectedCountVersion=-1,this._selectedIndexesVersion=-1,this._versionedName="",this._versionedNameVersion=-1,this.SHRINK_THRESHOLD=256,"number"==typeof t){const n=t,r=Fe._createBuffer(n);if(e)for(let t=0;t<r.length;t++)r[t]=-1;this._data=r,this._length=n}else{if(!(t instanceof Uint32Array))throw new Error("Invalid constructor");this._data=t,this._length=e}}getRawData(){return this._data}assureGoez(t,e){if(t<0)throw new Error(`${e} should be greater than zero`)}assureInRange(t,e,n,r){if(t<e||t>n)throw new Error(`Argument ${r} (${t}) out of range (${e}, ${n})`)}copy(t,e,n){for(let r=0;r<n;r++)e[r]=t[r]}copyFrom(t){if(this._length!=t._length)throw new Error(`Lengths differ (${this._length} != ${t._length})`);this.copy(t._data,this._data,this.lengthInInts),this._version++}get length(){return this._length}get buffer(){return this._data}set buffer(t){this._data=t,this._version++}get version(){return this._version}set version(t){this._version=t}incrementVersion(t=!0){this._version++}get lengthInInts(){return Math.floor((this._length+31)/32)}get versionedName(){return this._version==this._versionedNameVersion?this._versionedName:""}set versionedName(t){this._versionedName=t,this._versionedNameVersion=this._version}get self(){return this}setLength(t){if(t<0)throw new Error("should be >= 0");if(t==this._length)return;const e=Math.floor((t+31)/32);if(e>this._data.length||e+this.SHRINK_THRESHOLD<this._data.length){const t=new Uint32Array(e);this.copy(this._data,t,e>this._data.length?this._data.length:e),this._data=t}t>this._length&&(this._length%32>0&&(this._data[this.lengthInInts-1]&=(1<<(this._length%32&31))-1),this._data.fill(0,this.lengthInInts,e)),this._length=t,this._version++}static fromAnd(t,e){if(t._length!=e._length)throw new Error(`Lengths differ (${t._length} != ${e._length})`);const n=new Fe(t._length);n._length=t._length,n._data=Fe._createBuffer(n._length),n._version=0;const r=t.lengthInInts;for(let i=0;i<r;i++)n._data[i]=t._data[i]&e._data[i];return n}static _createBuffer(t){return new Uint32Array(Math.floor((t+31)/32))}static fromValues(t){const e=new Fe(t.length);e._version=0;for(let n=0;n<e._length;n++)t[n]&&(e._data[Math.floor(n/32)]|=1<<(n%32&31));return e}static fromSeq(t,e){const n=new Fe(t);for(let r=0;r<t;++r)n.setBit(r,e(r));return n._version=0,n}static fromString(t){return Fe.fromSeq(t.length,e=>"1"==t.charAt(e))}static fromUint32Array(t,e){const n=new Fe(t);return n._data=e,n}static fromBytes(t){const e=t.length,n=new Fe(8*e);n._data=new Uint32Array(Math.floor((e+3)/4)),n._length=8*e;let r=0,i=0;for(;e-i>=4;)n._data[r++]=255&t[i]|(255&t[i+1])<<8|(255&t[i+2])<<16|(255&t[i+3])<<24,i+=4;return e-i==3&&(n._data[r]=(255&t[i+2])<<16),e-i==2&&(n._data[r]|=(255&t[i+1])<<8),e-i==1&&(n._data[r]|=255&t[i]),n._version=0,n}toString(){return`${this._length} bits, ${this.countBits(!0)} set`}equals(t){if(this==t)return!0;if(null==t)return!1;if(this._length!=t._length)return!1;if(0==this._length)return!0;for(let e=0;e<this._data.length-1;e++)if(this._data[e]!=t._data[e])return!1;for(let e=8*(this._data.length-1);e<this._length;e++)if(this.getBit(e)!=t.getBit(e))return!1;return!0}clone(){const t=new Fe(0,!1);return t._data=Uint32Array.from(this._data),t._length=this._length,t._version=this._version,t}init(t,e){this.setAll(!1,!1);for(let e=0;e<this._length;e++)t(e)&&(this._data[Math.floor(e/32)]|=1<<(e%32&31));return this.incrementVersion(e),this}invert(t=!0){for(let t=0;t<this._data.length;t++)this._data[t]^=-1;this.incrementVersion(t)}setAll(t,e=!1){const n=t?-1:0,r=this.lengthInInts;for(let t=0;t<r;t++)this._data[t]=n;this.incrementVersion(e)}setIndexes(t,e=!0,n=!0,r=!0){n&&this.setAll(!e,!1);for(const n of t)this.setFast(n,e);this.incrementVersion(r)}everyIndex(t,e=!0){for(const n of t)if(this.getBit(n)!=e)return!1;return!0}anyIndex(t,e=!0){for(const n of t)if(this.getBit(n)==e)return!0;return!1}setWhere(t,e=!0,n=!0,r=!0,i=!0){if(n&&i&&this.setAll(!e,!1),i)for(let n=0;n<this._length;n++)t(n)&&this.setFast(n,e);else for(let n=0;n<this._length;n++)this.setFast(n,t(n)?e:!e);this.incrementVersion(r)}getRange(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const n=[];for(let r=t;r<e;++r)n.push(this.getBit(r));return Fe.fromValues(n)}getRangeAsList(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const n=[];for(let r=t;r<e;++r)n.push(this.getBit(r));return n}setRange(t,e,n,r=!0){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length-1,"to");const i=Math.min(t,e),o=Math.max(t,e);if(n)for(let t=i;t<=o;t++)this.setTrue(t);else for(let t=i;t<=o;t++)this.setFalse(t);return this.incrementVersion(r),this}setRandom(t,e,n=!0){if(t<0||t>this._length)throw new Error("n must be >= 0 && <= Count");t>this._length/2&&this.setRandom(this._length-t,!e),this.setAll(!e);for(let n=0;n<t;){const t=Math.floor(Math.random()*this._length);this.getBit(t)!=e&&(this.setFast(t,e),n++)}this.incrementVersion(n)}and(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]&=t._data[e];return this.incrementVersion(e),this}andNot(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");const n=this.lengthInInts;for(let e=0;e<n;e++)this._data[e]&=~t._data[e];return this.incrementVersion(e),this}notAnd(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]=~this._data[e]&t._data[e];return this.incrementVersion(e),this}not(t=!0){for(let t=0,e=this.lengthInInts;t<e;t++)this._data[t]=~this._data[t];return this.incrementVersion(t),this}or(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]|=t._data[e];return this.incrementVersion(e),this}xor(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]^=t._data[e];return this.incrementVersion(e),this}insertAt(t,e,n=!1){if(this.assureInRange(t,0,this._length,"pos"),0==e)return;const r=this._length;this.setLength(this._length+e);for(let n=r-1;n>=t;n--)this.setBit(n+e,this.getBit(n));for(let r=t;r<t+e;r++)this.setBit(r,n)}removeAt(t,e=1){if(e<0)throw new Error("n cannot be negative");if(this.assureInRange(t,0,this._length-e,"pos"),this.contains(!0))for(let n=t;n<this._length-e;n++)this.setBit(n,this.getBit(n+e));this.setLength(this._length-e)}removeByMask(t,e=!0){if(this._length!=t.length)throw new Error("length != mask.length");if(t==this)this.setLength(t.countBits(!e)),this.setAll(!e);else{let n=0;for(let r=-1;-1!=(r=t.findNext(r,!e));)this.setFast(n++,this.getBit(r));this._length=n,this._version++}return this}getBit(t){return!!(this._data[Math.floor(t/32)]&1<<(31&t))}setBit(t,e,n=!0){this.setFast(t,e),this._version++}setFast(t,e){e?this._data[Math.floor(t/32)]|=1<<(31&t):this._data[Math.floor(t/32)]&=~(1<<(31&t))}setTrue(t){this._data[Math.floor(t/32)]|=1<<(31&t)}setFalse(t){this._data[Math.floor(t/32)]&=~(1<<(31&t))}trueCount(){return this.countBits(!0)}falseCount(){return this.countBits(!1)}countBits(t){if(0==this._length)return 0;if(this._selectedCountVersion!=this._version){this._selectedCount=0;const t=this.lengthInInts;let e=0;for(;e<t-1;e++)for(let t=this._data[e];0!=t;t>>>=8)this._selectedCount+=Fe._onBitCount[255&t];let n=this._data[e];const r=31&this._length;for(0!=r&&(n&=~(4294967295<<r));0!=n;n>>>=8)this._selectedCount+=Fe._onBitCount[255&n];this._selectedCountVersion=this._version}return t?this._selectedCount:this._length-this._selectedCount}countWhere(t){let e=0;if(this.trueCount()==this._length)for(let n=0;n<this._length;n++)e+=t(n)?1:0;else for(let n=-1;-1!=(n=this.findNext(n,!0));)e+=t(n)?1:0;return e}andWithCountBits(t,e){if(0==this._length)return 0;let n=0;const r=this.lengthInInts;let i=0;for(;i<r-1;i++)for(let e=this._data[i]&t._data[i];0!=e;e>>>=8)n+=Fe._onBitCount[255&e];let o=this._data[i]&t._data[i];const a=31&this._length;for(0!=a&&(o&=~(4294967295<<a));0!=o;o>>>=8)n+=Fe._onBitCount[255&o];return e?n:this._length-n}clear(){this.setLength(0)}contains(t){return this.findNext(-1,t)>=0}get allTrue(){return this.countBits(!0)==this._length}get allFalse(){return this.countBits(!1)==this._length}get anyTrue(){return this.countBits(!0)>0}get anyFalse(){return this.countBits(!1)>0}findNext(t,e=!0){if(this.assureInRange(t,-1,this._length,"index"),t>=this._length-1)return-1;let n=31&(t=t<0?0:t+1);const r=this.lengthInInts;for(let i=Math.floor(t/32);i<r;i++){let r=e?this._data[i]:~this._data[i];if(0!=n)r&=4294967295<<n&4294967295,n=0;else if(!e&&-4294967296==r)continue;for(let e=0;0!=r;e+=8,r>>>=8){const n=Fe._firstOnBit[255&r];if(n>=0)return(t=n+32*i+e)>=this._length?-1:t}}return-1}findPrev(t,e=!0){if(0==t)return-1;this.assureInRange(t,-1,this._length,"index");let n=1+(t=t<0?this._length-1:t-1)&31;for(let r=Math.floor(t/32);r>=0;r--){let t=e?this._data[r]:~this._data[r];0!=n&&(t&=~(4294967295<<n),n=0);for(let e=24;0!=t;e-=8,t<<=8){const n=Fe._lastOnBit[t>>>24];if(n>=0)return n+32*r+e}}return-1}}function Oe(t={}){const e=function(){if(!t||!t.scoringMatrix||!t.alphabetIndexes)return(t,e)=>t===e?0:1;if(t.scoringMatrix.length!==Object.keys(t.alphabetIndexes).length)throw new Error("Scoring matrix and alphabet indexes should have the same length");const e=t.alphabetIndexes,n=t.scoringMatrix,r=Math.min(...Object.keys(e).map(t=>t.charCodeAt(0)))+1,i=new Float32Array((n.length+r)*(n.length+r));return Object.entries(e).forEach(([t,r])=>{const o=n[r];Object.entries(e).forEach(([e,r])=>{i[t.charCodeAt(0)*n.length+e.charCodeAt(0)]=o[r]})}),(t,e)=>1-i[t.charCodeAt(0)*n.length+e.charCodeAt(0)]}(),n=t?.threshold??0;return(t,r)=>{let i=0;const o=t.length,a=r.length,s=Math.ceil(Math.max(o,a)*(1-n));o!==a&&(i=Math.abs(o-a));let u=0;for(let n=0;n<Math.min(o,a);n++)if(t[n]!==r[n]&&(u+=e(t[n],r[n]),u>s))return 1;return u+=i,u/=Math.max(o,a),u}}Fe._onBitCount=Int8Array.from([0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8]),Fe._firstOnBit=Int8Array.from([-1,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0]),Fe._lastOnBit=Int8Array.from([-1,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7]);const Re={gapOpen:1,gapExtend:.6,scoringMatrix:[[4,-1,-2,-2,0,-1,-1,0,-2,-1,-1,-1,-1,-2,-1,1,0,-3,-2,0,-2,-1,0,-4],[-1,5,0,-2,-3,1,0,-2,0,-3,-2,2,-1,-3,-2,-1,-1,-3,-2,-3,-1,0,-1,-4],[-2,0,6,1,-3,0,0,0,1,-3,-3,0,-2,-3,-2,1,0,-4,-2,-3,3,0,-1,-4],[-2,-2,1,6,-3,0,2,-1,-1,-3,-4,-1,-3,-3,-1,0,-1,-4,-3,-3,4,1,-1,-4],[0,-3,-3,-3,9,-3,-4,-3,-3,-1,-1,-3,-1,-2,-3,-1,-1,-2,-2,-1,-3,-3,-2,-4],[-1,1,0,0,-3,5,2,-2,0,-3,-2,1,0,-3,-1,0,-1,-2,-1,-2,0,3,-1,-4],[-1,0,0,2,-4,2,5,-2,0,-3,-3,1,-2,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-2,0,-1,-3,-2,-2,6,-2,-4,-4,-2,-3,-3,-2,0,-2,-2,-3,-3,-1,-2,-1,-4],[-2,0,1,-1,-3,0,0,-2,8,-3,-3,-1,-2,-1,-2,-1,-2,-2,2,-3,0,0,-1,-4],[-1,-3,-3,-3,-1,-3,-3,-4,-3,4,2,-3,1,0,-3,-2,-1,-3,-1,3,-3,-3,-1,-4],[-1,-2,-3,-4,-1,-2,-3,-4,-3,2,4,-2,2,0,-3,-2,-1,-2,-1,1,-4,-3,-1,-4],[-1,2,0,-1,-3,1,1,-2,-1,-3,-2,5,-1,-3,-1,0,-1,-3,-2,-2,0,1,-1,-4],[-1,-1,-2,-3,-1,0,-2,-3,-2,1,2,-1,5,0,-2,-1,-1,-1,-1,1,-3,-1,-1,-4],[-2,-3,-3,-3,-2,-3,-3,-3,-1,0,0,-3,0,6,-4,-2,-2,1,3,-1,-3,-3,-1,-4],[-1,-2,-2,-1,-3,-1,-1,-2,-2,-3,-3,-1,-2,-4,7,-1,-1,-4,-3,-2,-2,-1,-2,-4],[1,-1,1,0,-1,0,0,0,-1,-2,-2,0,-1,-2,-1,4,1,-3,-2,-2,0,0,0,-4],[0,-1,0,-1,-1,-1,-1,-2,-2,-1,-1,-1,-1,-2,-1,1,5,-2,-2,0,-1,-1,0,-4],[-3,-3,-4,-4,-2,-2,-3,-2,-2,-3,-2,-3,-1,1,-4,-3,-2,11,2,-3,-4,-3,-2,-4],[-2,-2,-2,-3,-2,-1,-2,-3,2,-1,-1,-2,-1,3,-3,-2,-2,2,7,-1,-3,-2,-1,-4],[0,-3,-3,-3,-1,-2,-2,-3,-3,3,1,-2,1,-1,-2,-2,0,-3,-1,4,-3,-2,-1,-4],[-2,-1,3,4,-3,0,1,-1,0,-3,-4,0,-3,-3,-2,0,-1,-4,-3,-3,4,1,-1,-4],[-1,0,0,1,-3,3,4,-2,0,-3,-3,1,-1,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-1,-1,-1,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-2,0,0,-2,-1,-1,-1,-1,-1,-4],[-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,1]],alphabetIndexes:{A:0,R:1,N:2,D:3,C:4,Q:5,E:6,G:7,H:8,I:9,L:10,K:11,M:12,F:13,P:14,S:15,T:16,W:17,Y:18,V:19,B:20,Z:21,X:22,"*":23}};var xe;!function(t){t.HAMMING="Hamming",t.LEVENSHTEIN="Levenshtein",t.NEEDLEMANN_WUNSCH="Needlemann-Wunsch",t.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance"}(xe||(xe={}));const De={[xe.HAMMING]:Oe,[xe.LEVENSHTEIN]:function(){return(t,e)=>Pe(t,e)/Math.max(t.length,e.length)},[xe.NEEDLEMANN_WUNSCH]:function(t){const e=new Uint16Array(65536),{gapOpen:n,gapExtend:r,scoringMatrix:i,alphabetIndexes:o}={...Re,...t};Object.entries(o).forEach(([t,n])=>e[t.charCodeAt(0)]=n);const a=[new Float32Array(1e4),new Float32Array(1e4)];return(t,o)=>{const s=new Array(t.length+1).fill(!1),u=new Array(t.length+1).fill(!1);let c=0,l=1;for(let e=1;e<t.length+1;e++)a[0][e]=-r-(e-1)*r,a[1][e]=0;a[0][0]=0;for(let d=1;d<o.length+1;d++){a[l][0]=-r-(d-1)*r;for(let h=1;h<t.length+1;h++){const f=a[c][h-1]+i[e[t.charCodeAt(h-1)]][e[o.charCodeAt(d-1)]],p=a[c][h]-(s[h]||1===d||d===o.length?r:n),m=a[l][h-1]-(u[h-1]||1===h||h===t.length?r:n);a[l][h]=Math.max(f,m,p),a[l][h]===f?(s[h]=!1,u[h]=!1):a[l][h]===m?(s[h]=!1,u[h]=!0):(s[h]=!0,u[h]=!1)}c=l,l=(l+1)%2}const d=Math.min(t.length,o.length);return(d-a[c][t.length])/d}},[xe.MONOMER_CHEMICAL_DISTANCE]:Oe};function ke(t,e){const n=t.trueCount()+e.trueCount();if(0==n)return 1;const r=t.andWithCountBits(e,!0);return r/(n-r)}function Ue(t){return t<=0?3402823e32:1/t-1}ce.Tanimoto,ce.Dice,ce.Asymmetric,ce.BraunBlanquet,ce.Cosine,ce.Kulczynski,ce.McConnaughey,ce.RogotGoldberg,ce.Russel,ce.Sokal,ce.Hamming,ce.Euclidean,ce.Tanimoto,ce.Dice,ce.Asymmetric,ce.BraunBlanquet,ce.Cosine,ce.Kulczynski,ce.McConnaughey,ce.RogotGoldberg,ce.Russel,ce.Sokal,ce.Hamming,ce.Euclidean,ce.Tanimoto,ce.Dice,ce.Cosine,ce.Tanimoto,ce.Asymmetric,ce.Cosine,ce.Sokal,xe.HAMMING,xe.LEVENSHTEIN,xe.MONOMER_CHEMICAL_DISTANCE,xe.NEEDLEMANN_WUNSCH;const Ge={[ue.Euclidean]:function(t,e){let n=0;for(let r=0;r<t.length;r++)n+=Math.pow(t[r]-e[r],2);return Math.sqrt(n)},[ue.Manhattan]:function(t,e){let n=0;for(let r=0;r<t.length;r++)n+=Math.abs(t[r]-e[r]);return n},[ue.Cosine]:function(t,e){let n=0,r=0,i=0;for(let o=0;o<t.length;o++)n+=t[o]*e[o],r+=t[o]*t[o],i+=e[o]*e[o];return(1-n/(Math.sqrt(r)*Math.sqrt(i)))/2}},Ve={[se.Levenshtein]:Pe,[se.JaroWinkler]:Te.Vb,[se.Manhattan]:function(t,e){if(t.length!==e.length)return 1;{let n=0;for(let r=1;r<t.length;r++)n+=t[r]==e[r]?0:1;return n/t.length}},[se.Onehot]:function(t,e){return t===e?0:1}},Be={[ce.Tanimoto]:function(t,e){return 1-ke(t,e)},[ce.Dice]:function(t,e){return 1-function(t,e){const n=t.trueCount()+e.trueCount();return 0==n?0:2*t.andWithCountBits(e,!0)/n}(t,e)},[ce.Asymmetric]:function(t,e){return 1-function(t,e){const n=Math.min(t.trueCount(),e.trueCount());return 0==n?0:t.andWithCountBits(e,!0)/n}(t,e)},[ce.BraunBlanquet]:function(t,e){return Ue(function(t,e){const n=Math.max(t.trueCount(),e.trueCount());return 0==n?0:t.andWithCountBits(e,!0)/n}(t,e))},[ce.Cosine]:function(t,e){return 1-function(t,e){const n=t.trueCount()*e.trueCount();return 0==n?0:t.andWithCountBits(e,!0)/Math.sqrt(n)}(t,e)},[ce.Kulczynski]:function(t,e){return Ue(function(t,e){const n=t.trueCount()+e.trueCount(),r=t.trueCount()*e.trueCount();return 0==r?0:t.andWithCountBits(e,!0)*n/(2*r)}(t,e))},[ce.McConnaughey]:function(t,e){return Ue(function(t,e){const n=t.trueCount()+e.trueCount(),r=t.trueCount()*e.trueCount();return 0==r?0:(t.andWithCountBits(e,!0)*n-r)/r}(t,e))},[ce.RogotGoldberg]:function(t,e){return Ue(function(t,e){const n=t.andWithCountBits(e,!0),r=t.countBits(!0)+e.countBits(!0),i=t.length,o=i-r+n;return n==i||o==i?1:n/r+o/(2*i-r)}(t,e))},[ce.Russel]:function(t,e){return Ue(function(t,e){return 0==t.length?0:t.andWithCountBits(e,!0)/t.length}(t,e))},[ce.Sokal]:function(t,e){return 1-function(t,e){const n=t.trueCount()+e.trueCount(),r=t.andWithCountBits(e,!0);return r/(2*n-3*r)}(t,e)},[ce.Hamming]:function(t,e){return t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0)},[ce.Euclidean]:function(t,e){return Math.sqrt(t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0))}},We={[le.TanimotoIntArray]:function(t,e){return Ue(ke(new Fe(t,32*t.length),new Fe(e,32*e.length)))}},ze={[he.Difference]:function(t){if(t&&null!=t.range&&t.range>0){const e=t.range;return(t,n)=>Math.abs(t-n)/e}return(t,e)=>Math.abs(t-e)}},He={[fe.CommonItems]:function(t){const e=function(t){const e=t?.mostCommon??new Set;return(t,n)=>{const r=t.length,i=n.length;let o=0,a=0,s=0;for(;a<r&&s<i;)t[a]===n[s]?(e?.has(t[a])||++o,++a,++s):t[a]<n[s]?++a:++s;return o}}(t);return(t,n)=>0===n.length||0===t.length?1e4:Math.min(t.length,n.length)/(e(t,n)+1e-4)}},je={[de.Vector]:{[ue.Euclidean]:Ge[ue.Euclidean],[ue.Manhattan]:Ge[ue.Manhattan],[ue.Cosine]:Ge[ue.Cosine]},[de.String]:{[se.Levenshtein]:Ve[se.Levenshtein],[se.JaroWinkler]:Ve[se.JaroWinkler],[se.Manhattan]:Ve[se.Manhattan],[se.Onehot]:Ve[se.Onehot]},[de.BitArray]:{[ce.Tanimoto]:Be[ce.Tanimoto],[ce.Dice]:Be[ce.Dice],[ce.Asymmetric]:Be[ce.Asymmetric],[ce.BraunBlanquet]:Be[ce.BraunBlanquet],[ce.Cosine]:Be[ce.Cosine],[ce.Kulczynski]:Be[ce.Kulczynski],[ce.McConnaughey]:Be[ce.McConnaughey],[ce.RogotGoldberg]:Be[ce.RogotGoldberg],[ce.Russel]:Be[ce.Russel],[ce.Sokal]:Be[ce.Sokal]},[de.MacroMolecule]:{[xe.HAMMING]:De[xe.HAMMING],[xe.LEVENSHTEIN]:De[xe.LEVENSHTEIN],[xe.NEEDLEMANN_WUNSCH]:De[xe.NEEDLEMANN_WUNSCH],[xe.MONOMER_CHEMICAL_DISTANCE]:De[xe.MONOMER_CHEMICAL_DISTANCE]},[de.Number]:{[he.Difference]:ze[he.Difference]},[de.IntArray]:{[le.TanimotoIntArray]:We[le.TanimotoIntArray]},[de.NumberArray]:{[fe.CommonItems]:He[fe.CommonItems]}};Object.keys(je).reduce((t,e)=>{for(const n of Object.keys(je[e]))t[n]=e;return t},{});class Ke{constructor(){this.learningRate={uiName:"Learninig Rate",value:1,tooltip:"The initial learning rate for the embedding optimization"},this.nEpochs={uiName:"Epochs",value:0,tooltip:"The number of epochs to optimize embeddings via SGD. Computed automatically if set to 0"},this.nNeighbors={uiName:"Neighbors",value:15,tooltip:"The number of nearest neighbors to construct the fuzzy manifold"},this.spread={uiName:"Spread",value:1,tooltip:"The effective scale of embedded points, used with min distance to control \n the clumped/dispersed nature of the embedding"},this.minDist={uiName:"Min Distance",value:.1,tooltip:"The effective minimum distance between embedded points, \n used with spread to control the clumped/dispersed nature of the embedding"},this.randomSeed={uiName:"Random Seed",value:null,tooltip:"Random seed",type:"string"},this.useWebGPU={uiName:"Use WebGPU",value:!1,tooltip:"Use WebGPU for Distance and UMAP computations",type:"boolean",disableTooltip:"WebGPU is not available"},Ht().then(t=>{t?(this.useWebGPU.tooltip+=` (${t})`,this.useWebGPU.value=!0):(this.useWebGPU.value=!1,this.useWebGPU.disable=!0)})}}class qe{constructor(){this.epsilon={uiName:"Epsilon",value:10,tooltip:"Epsilon is learning rate"},this.perplexity={uiName:"Perplexity",value:30,tooltip:"Roughly how many neighbors each point influences"}}}class Ye{constructor(n={}){this.editorSettings={},this.columnOptEditors=[],this.columnOptEditorsRoot=e.div(),this.columnParamsEditorRoot=e.div(),this.columnFunctionsMap={},this.methodsParams={[Zt.UMAP]:new Ke,[Zt.T_SNE]:new qe},this.dbScanParams=new ne,this.methodSettingsDivs=[],this.supportedFunctions={},this.methodSettingsAnchor=e.div(),this.plotEmbeddingsInput=e.input.bool("Plot Embeddings",{value:!0}),this.aggregationMethodInput=e.input.choice("Aggregation",{value:ie.EUCLIDEAN,items:[ie.EUCLIDEAN,ie.MANHATTAN]}),this.vectorDistanceInput=e.input.choice("Distance metric",{value:ue.Euclidean,items:[ue.Euclidean,ue.Manhattan,ue.Cosine]}),this.aggregationMethodInput.setTooltip("Aggregation method for combining distances between columns"),this.vectorDistanceInput.root.style.display="none",this.onColumnsChanged=new ae.Subject,this.editorSettings=n,this.columnParamsEditorAccordion=e.accordion(),i.Func.find({tags:["dim-red-preprocessing-function"]}).forEach(t=>{const e=t.options.get("supportedSemTypes")??"",n=t.friendlyName??t.name,r=t.options.get("supportedTypes")??"",i=t.options.get("supportedUnits")??"",o=t.options.get("supportedDistanceFunctions")??"";this.editorSettings.semtype&&!e.includes(this.editorSettings.semtype)||this.editorSettings.type&&!r.includes(this.editorSettings.type)||this.editorSettings.units&&!i.includes(this.editorSettings.units)||(this.supportedFunctions[n]={func:t,semTypes:e?e.split(","):[],types:r?r.split(","):[],units:i?i.split(","):[],distanceFunctions:o?o.split(","):[]})}),this.postProcessingEditor=new Qe,this.tableInput=e.input.table("Table",{value:t.shell.tv.dataFrame,items:t.shell.tables,onValueChanged:()=>{this.onTableInputChanged()}}),this.onTableInputChanged();let r=!1;this.methodInput=e.input.choice("Method",{value:Zt.UMAP,items:[Zt.UMAP,Zt.T_SNE],onValueChanged:t=>{r&&this.createAlgorithmSettingsDiv(this.methodsParams[t])}}),this.methodSettingsIcon=e.icons.settings(()=>{r=!r,r?this.createAlgorithmSettingsDiv(this.methodsParams[this.methodInput.value]):(this.methodSettingsDivs.forEach(t=>t.remove()),this.methodSettingsDivs=[])},"Modify methods parameters"),this.methodInput.root.classList.add("ml-dim-reduction-settings-input"),this.methodInput.root.prepend(this.methodSettingsIcon),this.columnParamsEditorAccordion.addPane("Column options",()=>this.columnOptEditorsRoot,!0,null,!1),this.columnParamsEditorAccordion.root.style.display="none",this.columnParamsEditorRoot.appendChild(this.columnParamsEditorAccordion.root),this.columnParamsEditorRoot.appendChild(this.vectorDistanceInput.root)}onTableInputChanged(){const t=this.tableInput.value;if(!t)return;e.empty(this.columnOptEditorsRoot),this.columnFunctionsMap={},t.columns.toList().forEach(t=>{Object.keys(this.supportedFunctions).forEach(e=>{const n=this.supportedFunctions[e].semTypes,r=this.supportedFunctions[e].types,i=this.supportedFunctions[e].units,o=!n.length||t.semType&&n.includes(t.semType),a=!r.length||r.includes(t.type),s=!i.length||t.meta.units&&i.includes(t.meta.units);o&&a&&s&&(this.columnFunctionsMap[t.name]||(this.columnFunctionsMap[t.name]=[]),this.columnFunctionsMap[t.name].push(e))})});const n=Object.keys(this.columnFunctionsMap),r=e.input.columns("Columns",{table:t,onValueChanged:t=>{if(this.onColumnsChanged.next(),e.empty(this.columnOptEditorsRoot),this.aggregationMethodInput.root.style.display=!t||t?.length<2?"none":"flex",!t||0===t.length)return void(this.columnParamsEditorAccordion.root.style.display="none");this.columnOptEditors=t.map(t=>new $e(t,this.columnFunctionsMap[t.name].map(t=>this.supportedFunctions[t])));const n=e.divV([],{style:{maxHeight:"400px",overflow:"auto"}});this.columnOptEditors.forEach(t=>{n.appendChild(t.accordionDiv)});const r=new Array(2*this.columnOptEditors.length).fill(null).map((t,e)=>e%2==0?this.columnOptEditors[e/2].colOptEditors:[]);let i=0;const o=e.table(r,t=>(i++,t&&t.length>0?t:[this.columnOptEditors[Math.floor((i-1)/2)].preprocessingFuncSettingsDiv=e.div([]),e.div(),e.div(),e.div()]),["Column","Encoding function","Similarity metric","Weight"]);this.columnOptEditors.forEach(t=>{t.preprocessingFuncSettingsDiv?.parentElement?.setAttribute("colspan","4"),t.preprocessingFuncSettingsDiv?.parentElement?.parentElement?.style?.setProperty("height","unset")}),this.columnOptEditors.length>0&&(this.columnParamsEditorAccordion.root.style.display="flex"),o.classList.add("ml-dim-reduction-column-editor-table-root"),this.columnOptEditorsRoot.appendChild(o),t.every(t=>t.isNumerical)?(this.aggregationMethodInput.root.style.display="none",this.columnParamsEditorAccordion.root.style.display="none",this.vectorDistanceInput.root.style.display="flex"):this.vectorDistanceInput.root.style.display="none"},available:n});r.fireChanged(),this.columnsInputRoot?(e.empty(this.columnsInputRoot),this.columnsInput=r,Array.from(this.columnsInput.root.children).forEach(t=>this.columnsInputRoot.appendChild(t))):(this.columnsInputRoot=r.root,this.columnsInput=r)}createAlgorithmSettingsDiv(t){this.methodSettingsDivs.forEach(t=>t.remove()),this.methodSettingsDivs=[];const n=this.methodSettingsAnchor,r=n.parentElement;r&&Object.keys(t).forEach(i=>{const o=t[i],a="string"===o.type?e.input.string(o.uiName,{value:o.value??"",onValueChanged:t=>{o.value=t}}):"boolean"===o.type?e.input.bool(o.uiName,{value:o.value??!1,onValueChanged:t=>{o.value=t}}):e.input.float(o.uiName,{value:o.value,onValueChanged:t=>{o.value=t}});o.disable?(a.enabled=!1,e.tooltip.bind(a.input??a.root,o.disableTooltip??"")):e.tooltip.bind(a.input??a.root,o.tooltip),r.insertBefore(a.root,n),this.methodSettingsDivs.push(a.root)})}get algorithmOptions(){const t=this.methodsParams[this.methodInput.value],e={};return Object.keys(t).forEach(n=>{null!=t[n].value&&(e[n]=t[n].value)}),e}get dbScanOptions(){return{dbScanEpsilon:this.dbScanParams.epsilon.value??.01,dbScanMinPts:this.dbScanParams.minPts.value??4}}getEditor(){return e.div([this.tableInput.root,this.columnsInputRoot,this.columnParamsEditorRoot,this.aggregationMethodInput.root,this.methodInput.root,this.methodSettingsAnchor,this.plotEmbeddingsInput,this.postProcessingEditor.root],{style:{minWidth:"420px"},classes:"dim-reduction-dialog-form"})}getParams(){return{table:this.tableInput.value,columns:this.columnsInput.value,methodName:this.methodInput.value,preprocessingFunctions:this.columnOptEditors.map(t=>t.preProcessingFunction),distanceMetrics:this.columnOptEditors.map(t=>t.similarityMetricInput.value),weights:this.columnOptEditors.map(t=>t.weight??1),options:{...this.algorithmOptions,...this.dbScanOptions,preprocessingFuncArgs:this.columnOptEditors.map(t=>t.preprocessingFunctionSettings)},plotEmbeddings:this.plotEmbeddingsInput.value,clusterEmbeddings:!1,postProcessingFunction:this.postProcessingEditor.postProcessingFunction,postProcessingFunctionArgs:this.postProcessingEditor.args,aggreaggregationMethod:this.aggregationMethodInput.value,vectorDistanceMetric:this.vectorDistanceInput.value}}getInput(){return{columns:this.columnsInput.value.map(t=>t.name),method:this.methodInput.value,preprocessingFunctions:this.columnOptEditors.map(t=>t.preprocessingFunctionInput.value),distanceMetrics:this.columnOptEditors.map(t=>t.similarityMetricInput.value),weights:this.columnOptEditors.map(t=>t.weight??1),options:{...this.algorithmOptions,...this.dbScanOptions,preprocessingFuncArgs:this.columnOptEditors.map(t=>t.preprocessingFunctionSettings)},plotEmbeddings:this.plotEmbeddingsInput.value,postProcessingFunction:this.postProcessingEditor.postProcessingFunctionInput.value??null,postProcessingFunctionArgs:this.postProcessingEditor.args,aggreaggregationMethod:this.aggregationMethodInput.value,vectorDistanceMetric:this.vectorDistanceInput.value}}getStringInput(){return JSON.stringify(this.getInput())}async applyStringInput(e){try{const t=JSON.parse(e);await this.applyInput(t)}catch(e){t.shell.error("Error applying input from history"),console.error(e)}}async applyInput(e){try{const t=e.columns.map(t=>this.tableInput.value.col(t));if(t.some(t=>!t))throw new Error("Some columns are not found");this.columnsInput.value=t,this.columnsInput.fireChanged(),this.methodInput.value=e.method,this.columnOptEditors.forEach((t,n)=>{t.preprocessingFunctionInput.value=e.preprocessingFunctions[n],t.similarityMetricInput.value=e.distanceMetrics[n],t.weightInput.value=e.weights[n],t.preprocessingFunctionSettings=e.options.preprocessingFuncArgs[n]}),this.plotEmbeddingsInput.value=e.plotEmbeddings,this.postProcessingEditor.postProcessingFunctionInput.value=e.postProcessingFunction,await this.postProcessingEditor._prevChangePromise,this.postProcessingEditor._postProcessingArgs=e.postProcessingFunctionArgs,this.aggregationMethodInput.value=e.aggreaggregationMethod;const n={};Object.keys(this.methodsParams[e.method]).forEach(t=>{n[t]=e.options[t]}),Object.keys(this.methodsParams[e.method]).forEach(t=>{this.methodsParams[e.method][t].value=n[t]});const r=this.methodSettingsDivs.length>0;this.createAlgorithmSettingsDiv(this.methodsParams[e.method]),r||(this.methodSettingsDivs.forEach(t=>t.remove()),this.methodSettingsDivs=[]),await this.postProcessingEditor.onFunctionChanged(e.postProcessingFunctionArgs),this.vectorDistanceInput.value=e.vectorDistanceMetric}catch(e){t.shell.error("Error applying input from history"),console.error(e)}}}class $e{constructor(t,n){this.preprocessingFuncSettingsDiv=e.div([]),this.preprocessingFunctionSettings={},this.editorDiv=e.div([]),this.hasExtraSettings=!0,this.functionsMap={},this.needsConfiguration=!1,this.weight=1,this.colOptEditors=[],this.weightInput=e.input.float("Weight",{value:1,onValueChanged:t=>{this.weight=t??1}}),this.column=t,this.supportedFunctions=n.sort((t,e)=>0!==t.units.length&&0!==e.units.length||t.units.length===e.units.length?t.units.length!==e.units.length?t.units.length-e.units.length:0===t.semTypes.length||0===e.semTypes.length?e.semTypes.length-t.semTypes.length:t.semTypes.length!==e.semTypes.length?t.semTypes.length-e.semTypes.length:t.types.length-e.types.length:e.units.length-t.units.length),this.supportedFunctions.forEach(t=>{this.functionsMap[Xe(t.func)]=t.func}),this.preprocessingFunctionInput=e.input.choice("Encoding function",{value:Xe(this.supportedFunctions[0].func),items:this.supportedFunctions.map(t=>Xe(t.func)),onValueChanged:t=>{const n=this.functionsMap[t];this.preprocessingFunctionSettings={},this.hasExtraSettings=n.inputs.length>2;const i=this.supportedFunctions.find(e=>Xe(e.func)===t);this.getSimilarityMetricInput(i),e.empty(this.preprocessingFuncSettingsDiv),r=!1,this.hasExtraSettings?this.preprocessingFuncSettingsIcon.style.display="flex":this.preprocessingFuncSettingsIcon.style.display="none"}}),this.preprocessingFunctionInput.root.style.display="flex",this.createSettingsDiv(this.preprocessingFuncSettingsDiv,this.supportedFunctions[0].func).then(()=>{e.empty(this.preprocessingFuncSettingsDiv)}),this.getSimilarityMetricInput(this.supportedFunctions[0]),this.hasExtraSettings=this.supportedFunctions[0].func.inputs.length>2;let r=!1;this.preprocessingFuncSettingsIcon=e.icons.settings(async()=>{r=!r,r?await this.createSettingsDiv(this.preprocessingFuncSettingsDiv,this.functionsMap[this.preprocessingFunctionInput.value]):e.empty(this.preprocessingFuncSettingsDiv)},"Modify encoding function parameters"),this.preprocessingFunctionInput.root.classList.add("ml-dim-reduction-settings-input"),this.preprocessingFunctionInput.root.prepend(this.preprocessingFuncSettingsIcon),this.hasExtraSettings?this.preprocessingFuncSettingsIcon.style.display="flex":this.preprocessingFuncSettingsIcon.style.display="none",this.needsConfiguration=!(n.length<2&&!this.hasExtraSettings&&n[0].distanceFunctions.length<2);const i=e.h3(this.column.name,{classes:"ml-dim-reduction-column-editor-column-title"});this.colOptEditors=[i,this.preprocessingFunctionInput.root,this.similarityMetricInputRoot,this.weightInput.root],e.tooltip.bind(i,this.column.name),this.colOptEditors.forEach(t=>t.classList.add("ml-dim-reduction-column-editor-input-root"));const o=e.divH(this.colOptEditors,{classes:"ml-dim-reduction-column-editor-root"});this.accordionDiv=e.divV([]),this.editorDiv.appendChild(o),this.editorDiv.appendChild(this.preprocessingFuncSettingsDiv),this.accordionDiv.appendChild(this.editorDiv)}getSimilarityMetricInput(t){const n=e.input.choice("Similarity metric",{value:t.distanceFunctions[0],items:t.distanceFunctions});this.similarityMetricInputRoot?(e.empty(this.similarityMetricInputRoot),this.similarityMetricInput=n,Array.from(this.similarityMetricInput.root.children).forEach(t=>this.similarityMetricInputRoot.appendChild(t))):(this.similarityMetricInputRoot=n.root,this.similarityMetricInput=n)}get preProcessingFunction(){return this.functionsMap[this.preprocessingFunctionInput.value]}async createSettingsDiv(t,n){if(e.empty(t),n.inputs.length<3)return e.div();const r=n.prepare(),i=await r.buildEditor(e.div());for(let e=2;e<n.inputs.length;e++){const o=n.inputs[e],a=this.preprocessingFunctionSettings[o.name]||r.inputParams[n.inputs[e].name].value||o.defaultValue;a&&(this.preprocessingFunctionSettings[o.name]=a);const s=i.find(t=>t.property.name===o.name);s&&(null!==this.preprocessingFunctionSettings[o.name]&&void 0!==this.preprocessingFunctionSettings[o.name]&&(s.value=this.preprocessingFunctionSettings[o.name]),s.onChanged.subscribe(t=>{this.preprocessingFunctionSettings[o.name]=t}),t.append(s.root))}return t.style.marginBottom="10px",t}}function Xe(t){return t.friendlyName??t.name}class Qe{constructor(){this.postProcessingFunctionsMap={},this._root=e.div([]),this._postProcessingArgs={},this._argsElement=e.div([]),this._settingsOpened=!1,this._prevChangePromise=Promise.resolve(),this._settingsIcon=e.icons.settings(async()=>{this._settingsOpened=!this._settingsOpened,this._settingsOpened?this._argsElement.style.display="block":this._argsElement.style.display="none"}),this._argsElement.style.display="none",i.Func.find({tags:["dim-red-postprocessing-function"]}).filter(t=>t.inputs.length>=2).forEach(t=>{const e=t.friendlyName??t.name;this.postProcessingFunctionsMap[e]=t}),this.postProcessingFunctionsMap.None=null;const t=Object.keys(this.postProcessingFunctionsMap).find(t=>!!this.postProcessingFunctionsMap[t]?.options?.defaultPostProcessingFunction)??"None";this.postProcessingFunctionInput=e.input.choice("Postprocessing",{value:t,items:Object.keys(this.postProcessingFunctionsMap),onValueChanged:async()=>{await this.onFunctionChanged()},nullable:!1}),this.onFunctionChanged(),this.postProcessingFunctionInput.nullable=!1,this.postProcessingFunctionInput.classList.add("ml-dim-reduction-settings-input"),this.postProcessingFunctionInput.root.prepend(this._settingsIcon),this._root.appendChild(this.postProcessingFunctionInput.root),this._root.appendChild(this._argsElement)}get postProcessingFunction(){return this.postProcessingFunctionInput.value?this.postProcessingFunctionsMap[this.postProcessingFunctionInput.value]:null}async onFunctionChanged(n={}){let r;await this._prevChangePromise,this._prevChangePromise=new Promise(t=>r=t);try{const t=this.postProcessingFunction;if(e.empty(this._argsElement),this._postProcessingArgs={},!t||t.inputs.length<3)return void(this._settingsIcon.style.display="none");this._settingsIcon.style.display="flex";const r=t.prepare(n),i=await r.buildEditor(e.div());for(let e=2;e<t.inputs.length;e++){const n=t.inputs[e],o=this._postProcessingArgs[n.name]||r.inputParams[t.inputs[e].name].value||n.defaultValue;o&&(this._postProcessingArgs[n.name]=o);const a=i.find(t=>t.property.name===n.name);a&&(a.onChanged.subscribe(t=>{this._postProcessingArgs[n.name]=t}),this._argsElement.append(a.root))}}catch(e){t.shell.error("Error applying postprocessing function"),console.error(e)}finally{r()}}get root(){return this._root}get args(){return this._postProcessingArgs}}const Je="dimensionality-reducer-terminate-event",Ze=t=>null==t;function tn(t,e){return`${e} (${t.length>4?`${t.length} columns`:t.map(t=>t.name).join(", ")})`}function en(n){return r=this,o=void 0,s=function*(){if(null!=n||(n=t.shell.t),null===n)return void t.shell.warning(bt.NO_DATAFRAME);const r=[],o=[],a=[];n.columns.toList().filter(t=>_t.includes(t.type)).forEach(t=>{const e=t.stats.missingValueCount;e!==t.length&&(a.push(t.name),e>0&&(r.push(t),o.push(t.name)))});const s=function(t){const e=new Map;for(const n of t){if(!_t.includes(n.type))throw new Error(bt.UNSUPPORTED_COLUMN_TYPE);if(0===n.stats.missingValueCount)continue;const t=[],r=Mt(n);n.getRawData().forEach((e,n)=>{e===r&&t.push(n)}),e.set(n.name,t)}return e}(r);if(0===r.length)return void t.shell.info(bt.NO_MISSING_VALUES);if(1===a.length)return void t.shell.error(bt.ONE_AVAILABLE_FEATURE);let u=Lt.IN_PLACE>0;const c=e.input.bool(Ct.IN_PLACE,{value:u,onValueChanged:t=>{u=null!=t&&t}});c.setTooltip(St.IN_PLACE);let l=Lt.KEEP_EMPTY>0;const d=e.input.bool(Ct.KEEP_EMPTY,{value:l,onValueChanged:t=>{l=null!=t&&t}});d.setTooltip(St.KEEP_EMPTY);let h=Lt.NEIGHBORS;const f=e.input.int(Ct.NEIGHBORS,{value:h,showPlusMinus:!0,min:1,nullable:!1,onValueChanged:t=>{null!==t&&t>=1&&(h=t),A()}});f.setTooltip(St.NEIGHBORS);let p=It.EUCLIDEAN;const m=e.input.choice(Ct.DISTANCE,{value:p,items:[It.EUCLIDEAN,It.MANHATTAN],onValueChanged:t=>p=null!=t?t:It.EUCLIDEAN});m.setTooltip(St.DISTANCE);let g=r.map(t=>t.name);const y=e.input.columns(Ct.COLUMNS,{table:n,value:n.columns.byNames(o),onValueChanged:t=>{g=t.map(t=>t.name),A()},available:o});y.setTooltip(St.TARGET);let v=a;const w=e.input.columns(Ct.FEATURES,{value:n.columns.byNames(a),table:n,onValueChanged:t=>{v=t.map(t=>t.name),v.length>0?(A(),C.forEach((t,e)=>t.hidden=!v.includes(e))):b()},available:a});w.setTooltip(St.FEATURES);const b=()=>{_.getButton(Ct.RUN).disabled=!0,c.root.hidden=!0,d.root.hidden=!0,f.root.hidden=!0,N.hidden=!0,S.hidden=!0},A=()=>{_.getButton(Ct.RUN).disabled=null===f.value||f.value<1,N.hidden=!1,c.root.hidden=!1,f.root.hidden=!1,m.root.hidden=!1,d.root.hidden=!Tt(g,v,s),1===v.length&&g.forEach(e=>{v[0]===e&&(b(),t.shell.warning(`${bt.ONE_FEATURE_SELECTED} the column '${e}'`))}),g.length<1&&b()},E=new Map,C=new Map,S=e.divV([]);S.style.overflow="auto",a.forEach(t=>{const r=function(t){switch(t){case i.COLUMN_TYPE.STRING:case i.COLUMN_TYPE.DATE_TIME:return{defaultWeight:Lt.WEIGHT,defaultMetric:Nt.ONE_HOT,availableMetrics:[Nt.ONE_HOT]};case i.COLUMN_TYPE.INT:case i.COLUMN_TYPE.FLOAT:case i.COLUMN_TYPE.QNUM:return{defaultWeight:Lt.WEIGHT,defaultMetric:Nt.DIFFERENCE,availableMetrics:[Nt.DIFFERENCE,Nt.ONE_HOT]};default:throw new Error(bt.UNSUPPORTED_COLUMN_TYPE)}}(n.col(t).type);E.set(t,{weight:r.defaultWeight,type:r.defaultMetric});const o=e.input.choice(t,{value:r.defaultMetric,items:r.availableMetrics,onValueChanged:e=>{var n;const i=null!==(n=E.get(t))&&void 0!==n?n:{weight:r.defaultWeight,type:r.defaultMetric};i.type=null!=e?e:r.defaultMetric,E.set(t,i)}});o.root.style.width="50%",o.setTooltip(St.METRIC),o.root.hidden=!0;const a=i.Property.fromOptions({name:t.length<15?t:t.slice(0,15).concat("..."),inputType:"Float",min:0,max:10,showSlider:!0,step:1}),s=e.input.forProperty(a);s.value=r.defaultWeight,s.onChanged.subscribe(e=>{var n;const i=null!==(n=E.get(t))&&void 0!==n?n:{weight:r.defaultWeight,type:r.defaultMetric};i.weight=null!=e?e:r.defaultWeight,E.set(t,i)}),e.tooltip.bind(s.captionLabel,t),e.tooltip.bind(s.input,St.WEIGHT),C.set(t,s.root),S.append(s.root)});const _=e.dialog({title:Ct.KNN_IMPUTER,helpUrl:"/help/explore/missing-values-imputation#the-k-nn-method"});t.shell.v.root.appendChild(_.root),S.hidden=!0,d.root.hidden=!Tt(g,v,s);const M=e.icons.settings(()=>{S.hidden=!S.hidden},St.METRIC_SETTINGS),N=e.divH([m.root,M]);let I,L,P=!1;const T=new Promise((t,e)=>{I=t,L=e});return _.addButton(Ct.RUN,()=>{P=!0,_.close(),a.filter(t=>!v.includes(t)).forEach(t=>E.delete(t));try{const e=function(e,n,r,o,a,s,u){if(s<1)throw new Error(bt.INCORRECT_NEIGHBORS);if(e.rowCount<2)throw new Error(bt.KNN_NOT_ENOUGH_OF_ROWS);if(0===n.length)throw new Error(bt.KNN_NO_TARGET_COLUMNS);if(0===r.size)throw new Error(bt.KNN_NO_FEATURE_COLUMNS);1===r.size&&n.forEach(t=>{if(r.has(t))throw new Error(`${bt.KNN_NO_FEATURE_COLUMNS} can be used for the column '${t}'`)}),n.forEach(t=>{if(!o.has(t))throw new Error(`${bt.KNN_FAILS}: ${bt.WRONG_PREDICTIONS}`)});const c=e.columns;n.forEach(t=>{if(!_t.includes(c.byName(t).type))throw new Error(bt.UNSUPPORTED_COLUMN_TYPE)}),r.forEach((t,n)=>{if(!_t.includes(e.getCol(n).type))throw new Error(bt.UNSUPPORTED_COLUMN_TYPE)});const l=new Map;return n.forEach(n=>{const d=c.byName(n),h=Mt(d),f=d.length,p=d.getRawData(),m=new Uint16Array(d.categories.length),g=[],y=[],v=[],w=[];r.forEach((t,e)=>{if(e!==d.name){const n=c.byName(e);switch(g.push(n.getRawData()),y.push(Mt(n)),t.type){case Nt.DIFFERENCE:v.push((e,n)=>t.weight*Math.abs(e-n));break;case Nt.ONE_HOT:v.push((e,n)=>t.weight*(e===n?0:1))}}});const b=g.length,A=new Uint32Array(g.length),E=new Float32Array(g.length);let C=0;const S=new Array(s);let _=0,M=0,N=0,I=0,L=0;const P=(t,e)=>{A.forEach((n,r)=>{E[r]=v[n](g[n][t],g[n][e])})},T=a===It.EUCLIDEAN?()=>{let t=0;for(let e=0;e<C;++e)t+=E[e]*E[e];return Math.sqrt(t)}:()=>{let t=0;for(let e=0;e<C;++e)t+=Math.abs(E[e]);return Math.sqrt(t)},F=t=>{if(p[t]===h)return!1;for(let e=0;e<C;++e)if(g[A[e]][t]===y[A[e]])return!1;return!0},O=t=>{if((t=>{C=0;for(let e=0;e<b;++e)g[e][t]!==y[e]&&(A[C]=e,++C)})(t),0===C)throw new Error(`${bt.KNN_IMPOSSIBLE_IMPUTATION}: the column "${d.name}", row ${t+1}`);_=0;for(let e=0;e<f;++e)if(F(e)&&e!==t){P(t,e);const n=T();if(_<s)S[_]={index:e,dist:n},++_;else{M=0,N=S[0].dist;for(let t=1;t<_;++t)N<S[t].dist&&(N=S[t].dist,M=t);n<N&&(S[M]={index:e,dist:n})}}if(0===_)throw new Error(`${bt.KNN_IMPOSSIBLE_IMPUTATION}: the column "${d.name}", row ${t+1}`);if(d.type===i.COLUMN_TYPE.STRING)return(()=>{m.forEach((t,e,n)=>n[e]=0);let t=0;for(t=0;t<_;++t)++m[p[S[t].index]];let e=m[0],n=0;return m.forEach((t,r)=>{t>e&&(e=t,n=r)}),n})();I=0;for(let t=0;t<_;++t)I+=p[S[t].index];return L=I/_,d.type===i.COLUMN_TYPE.INT?Math.round(L):L};if(u){for(const e of o.get(n))try{p[e]=O(e)}catch(n){w.push(e),n instanceof Error||t.shell.error(bt.CORE_ISSUE)}w.length>0&&l.set(n,w),d.set(0,d.get(0))}else{const r=d.clone();let i=1,a=`${n}(${Et})`;for(;e.columns.contains(a);)a=`${n}(${Et} ${i})`,++i;r.name=a;const s=r.getRawData();for(const e of o.get(n))try{s[e]=O(e)}catch(n){w.push(e),n instanceof Error||t.shell.error(bt.CORE_ISSUE)}w.length>0&&l.set(a,w),r.set(0,r.get(0)),e.columns.add(r)}}),l}(n,g,E,s,p,h,u);l||function(t,e){e.forEach((e,n)=>{const r=t.col(n);if(null!==r){if(!_t.includes(r.type))throw new Error(bt.UNSUPPORTED_COLUMN_TYPE);const t=function(t){switch(t.type){case i.COLUMN_TYPE.STRING:case i.COLUMN_TYPE.DATE_TIME:return function(t){const e=Mt(t),n=t.getRawData(),r=n.length;for(let i=0;i<r;++i)if(n[i]!==e)return t.get(i);throw new Error(bt.EMPTY_COLUMN)}(t);case i.COLUMN_TYPE.INT:case i.COLUMN_TYPE.FLOAT:case i.COLUMN_TYPE.QNUM:return t.stats.avg;default:throw new Error(bt.UNSUPPORTED_COLUMN_TYPE)}}(r);e.forEach(e=>r.set(e,t))}})}(n,e),I()}catch(e){e instanceof Error?t.shell.error(`${bt.KNN_FAILS}: ${e.message}`):t.shell.error(`${bt.KNN_FAILS}: ${bt.CORE_ISSUE}`),L(e)}},void 0,St.RUN),_.add(y).add(w).add(N).add(S).add(f).add(c).add(d).show().onClose.subscribe(()=>!P&&I()),T},new((a=void 0)||(a=Promise))(function(t,e){function n(t){try{u(s.next(t))}catch(t){e(t)}}function i(t){try{u(s.throw(t))}catch(t){e(t)}}function u(e){var r;e.done?t(e.value):(r=e.value,r instanceof a?r:new a(function(t){t(r)})).then(n,i)}u((s=s.apply(r,o||[])).next())});var r,o,a,s}class nn extends Ye{constructor(t={}){super(t),this.similarityThresholdInput=e.input.int("Similarity Threshold",{value:80}),this.maxIterationsInput=e.input.int("Max Iterations",{value:5}),this.useWebGPUInput=e.input.bool("Use WebGPU",{value:!1}),this.inflateInput=e.input.float("Inflation Factor",{value:ee}),this.minClusterSizeInput=e.input.int("Min Cluster Size",{value:5}),Ht().then(t=>{t?(this.useWebGPUInput.setTooltip(`Use webGPU for MCL calculation (${t})`),this.useWebGPUInput.value=!0):(this.useWebGPUInput.value=!1,this.useWebGPUInput.setTooltip("WebGPU is not available"),this.useWebGPUInput.enabled=!1)})}getEditor(){return e.div([this.tableInput.root,this.columnsInputRoot,this.columnParamsEditorRoot,this.aggregationMethodInput.root,this.similarityThresholdInput.root,this.inflateInput.root,this.maxIterationsInput.root,this.minClusterSizeInput.root,this.useWebGPUInput.root],{style:{minWidth:"420px"},classes:"ui-form"})}getInput(){const t=super.getInput();return t.similarityThreshold=this.similarityThresholdInput.value,t.maxIterations=this.maxIterationsInput.value,t.useWebGPU=this.useWebGPUInput.value??!1,t.inflateFactor=this.inflateInput.value??ee,t.minClusterSize=this.minClusterSizeInput.value??5,t}async applyInput(t){await super.applyInput(t),this.similarityThresholdInput.value=t.similarityThreshold,this.maxIterationsInput.value=t.maxIterations,this.useWebGPUInput.value=t.useWebGPU,this.inflateInput.value=t.inflateFactor,this.minClusterSizeInput.value=t.minClusterSize}get params(){return{table:this.tableInput.value,columns:this.columnsInput.value,methodName:this.methodInput.value,preprocessingFunctions:this.columnOptEditors.map(t=>t.preProcessingFunction),distanceMetrics:this.columnOptEditors.map(t=>t.similarityMetricInput.value),weights:this.columnOptEditors.map(t=>t.weight),preprocessingFuncArgs:this.columnOptEditors.map(t=>t.preprocessingFunctionSettings),aggreaggregationMethod:this.aggregationMethodInput.value,threshold:this.similarityThresholdInput.value,maxIterations:this.maxIterationsInput.value??5,useWebGPU:this.useWebGPUInput.value??!1,inflateFactor:this.inflateInput.value??ee,minClusterSize:this.minClusterSizeInput.value??5}}}class rn{constructor(t,e,n,r,o,a){this.sc=t,this.from=e,this.to=n,this.shortLineThreshold=r,this.width=o,this.color=a,this.renderFlag=!1,this.renderSub=i.debounce(t.onAfterDrawScene,200).subscribe(()=>{if(this.renderFlag)return void(this.renderFlag=!1);this.renderFlag=!0;const e=t.onBeforeDrawScene.subscribe(t=>{this.render(),e.unsubscribe()});setTimeout(()=>{this.sc.invalidateCanvas()})}),t.subs.push(this.renderSub)}render(){const t=this.sc.dataFrame.getCol(this.sc.props.xColumnName),e=this.sc.dataFrame.getCol(this.sc.props.yColumnName),n=this.sc.filter,r=new Array(this.sc.dataFrame.rowCount).fill(null).map((r,i)=>t.isNone(i)||e.isNone(i)||!n.get(i)?null:this.sc.pointToScreen(i)),i=this.sc.canvas.getContext("2d");if(!i)return;i.strokeStyle=`rgba(${this.color}, 0.3)`,i.lineWidth=this.width;const o=this.shortLineThreshold*this.shortLineThreshold;for(let t=0;t<this.from.length;t++){i.beginPath();const e=this.from[t],n=this.to[t];if(r[e]&&r[n]){const t=r[e],a=r[n],s=a.x-t.x,u=a.y-t.y;if(s*s+u*u<o)continue;i.moveTo(t.x,t.y),i.lineTo(a.x,a.y),i.stroke(),i.closePath()}}}destroy(){this.renderSub.unsubscribe()}}class on extends i.JsViewer{constructor(){super(),this.initPromise=Promise.resolve(),this.initialized=!1,this.reseolver=()=>{},this.scratchCallTimer=null,this.mclProps=this.string("mclProps",null,{includeInLayout:!1,userEditable:!1,nullable:!0}),this.lines=this.string("lines",null,{includeInLayout:!1,userEditable:!1,nullable:!0}),this.scProps=this.string("scProps",null,{includeInLayout:!1,userEditable:!1,nullable:!0}),this.initPromise=new Promise(t=>{this.reseolver=t})}onFrameAttached(e){this.sc=e.plot.scatter({showXAxis:!1,showYAxis:!1,showXSelector:!1,showYSelector:!1,title:"MCL"}),this.root.appendChild(this.sc.root),this.subs.push(t.events.onCurrentObjectChanged.subscribe(e=>{this.sc&&t.shell.o===this&&setTimeout(()=>{t.shell.o=this.sc})})),this.subs.push(i.debounce(this.sc.onPropertyValueChanged,1e3).subscribe(t=>{this.sc&&this.getProperty("scProps").set(this,JSON.stringify(Object.assign({},this.sc.props)))}))}setScProps(){if(!this.sc)return;const t=this.scProps;if(!t)return;const e=this.sc.props;if(t===JSON.stringify(Object.assign({},e)))return;const n=JSON.parse(t);Object.entries(n).forEach(([t,n])=>{e.hasProperty(t)&&e[t]!==n&&(this.sc.props[t]=n)})}onPropertyChanged(t){null!==t&&("scProps"===t.name?this.setScProps():"lines"===t.name?this.decodeLines():"mclProps"===t.name&&(this.scratchCallTimer&&clearTimeout(this.scratchCallTimer),this.scratchCallTimer=setTimeout(()=>{this.initFromScratch()},300)))}isDataFrameSavable(){return null!=this.dataFrame&&this.dataFrame.rowCount<65534}async initFromScratch(){if(!this.mclProps||!this.sc||!this.dataFrame||this.initialized)return;if(this.lines)return void this.decodeLines();const r=JSON.parse(this.mclProps),o=r.cols.map(t=>this.dataFrame.columns.byName(t)),a=r.preprocessingFuncs.map(t=>t?i.Func.byName(t):null),s=await async function(r,o,a,s,u,c,l,d=80,h=10,f=!1,p=2,m=5,g){let y=null,v=g;v||(y=t.shell.tableView(r.name)??t.shell.addTableView(r),v=y.scatterPlot({showXAxis:!1,showYAxis:!1,showXSelector:!1,showYSelector:!1,title:"MCL"})),e.setUpdateIndicator(v.root,!0);const w=[],b=[];for(let t=0;t<c.length;++t){const e=c[t];if(e){const n=e.inputs[0].name,r=e.inputs[1].name,{entries:i,options:s}=await e.apply({[n]:o[t],[r]:a[t],...l[t]??{}});b.push({entries:i,options:s}),w.push(s??{})}else{const e=o[t].toList(),n={};b.push({entries:e,options:n}),w.push(n)}}const A=function(t,e,r,i,o,a,s=10,u=!1,c=2){const l=new Worker(new URL(n.p+n.u(980),n.b));let d;return l.postMessage({data:t,threshold:e,weights:r,aggregationMethod:i,distanceFns:o,distanceFnArgs:a,maxIterations:s,useWebGPU:u,inflate:c}),{promise:new Promise((t,e)=>{d=t,l.onmessage=e=>{setTimeout(()=>l.terminate(),100),t(e.data.res)},l.onerror=t=>{setTimeout(()=>l.terminate(),100),e(t)}}),terminate:()=>{try{d(null),l.terminate()}catch(t){console.error(t)}}}}(b.map(t=>t.entries),d,s,u,a,w,h,f,p),E=t.events.onViewerClosed.subscribe(t=>{t.args.viewer?.props?.title===v.props.title&&v.type===t.args?.viewer?.type&&(E.unsubscribe(),A.terminate())}),C=await A.promise;if(!C)return;const S=r.columns.getUnusedName("Cluster (MCL)"),_=r.columns.getUnusedName("EmbedX (MCL)"),M=r.columns.getUnusedName("EmbedY (MCL)"),N={};C.clusters.forEach(t=>{N[t]||(N[t]=0),N[t]++});const I=new Uint32Array(C.embedX.length);for(let t=0;t<C.is.length;t++)I[C.is[t]]++,I[C.js[t]]++;const L=r.columns.getUnusedName("Cluster size (MCL)"),P=r.columns.getUnusedName("Connectivity (MCL)"),T=r.columns.addNewFloat(_);T.init(t=>C.embedX[t]);const F=r.columns.addNewFloat(M);F.init(t=>C.embedY[t]);const O=r.columns.addNewString(S);O.init(t=>N[C.clusters[t]]>=m?C.clusters[t].toString():"-1");const R={"-1":i.Color.setAlpha(i.Color.lightBlue,100)};O.setTag(i.TAGS.COLOR_CODING_CATEGORICAL,JSON.stringify(R)),O.temp[i.TAGS.COLOR_CODING_CATEGORICAL]=R;const x=r.columns.addNewInt(L);x.init(t=>N[C.clusters[t]]);const D=r.columns.addNewInt(P);D.init(t=>I[t]),v.props.xColumnName=_,v.props.yColumnName=M,v.props.colorColumnName=S,v.props.markerDefaultSize=6,E.unsubscribe();const k=[],U=[],G=new Map;for(let t=0;t<C.is.length;t++){let e=C.clusters[C.is[t]],n=C.clusters[C.js[t]];if(e===n){k.push(C.is[t]),U.push(C.js[t]);continue}if(e>n){const t=e;e=n,n=t}let r=G.get(e);r||(r=new Map,G.set(e,r));let i=r.get(n);i||(i=0),i>=20||(i++,r.set(n,i),k.push(C.is[t]),U.push(C.js[t]))}return e.setUpdateIndicator(v.root,!1),{sc:v,embedXCol:T,embedYCol:F,clusterCol:O,clusterCounterCol:x,connectivityCol:D,i:k,j:U}}(this.dataFrame,o,r.metrics,r.weights,r.aggregationMethod,a,r.preprocessingFuncArgs,r.threshold,r.maxIterations,r.useWebGPU,r.inflate,r.minClusterSize,this.sc);return s?this.dataFrame.getTag(".script")||!this.isDataFrameSavable()?(this.linesRenderer?.destroy(),this.linesRenderer=new rn(this.sc,s.i,s.j,6,.75,"128,128,128"),this.initialized=!0,void this.reseolver()):void this.encodeLines(s.i,s.j):void 0}decodeLines(){if(!this.lines)return;const t=this.lines.length;if(t%2!=0)throw new Error("Invalid lines string");const e=new Array(t/2).fill(null).map((t,e)=>this.lines.charCodeAt(2*e)),n=new Array(t/2).fill(null).map((t,e)=>this.lines.charCodeAt(2*e+1));this.linesRenderer?.destroy(),this.linesRenderer=new rn(this.sc,e,n,6,.75,"128,128,128"),this.initialized=!0,this.reseolver()}encodeLines(t,e){const n=new Array(t.length).fill(null).map((n,r)=>`${String.fromCharCode(t[r])}${String.fromCharCode(e[r])}`).join("");this.getProperty("lines").set(this,n)}}var an=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}u((r=r.apply(t,e||[])).next())})};function sn(t,e){const n=t.length;if(n!==e.length-1)throw new Error("Incorrect parameters count");const r=t.byIndex(0),o=r.length,a=new Float32Array(o);let s=r.getRawData();const u=e[n];let c=e[0];for(let t=0;t<o;++t)a[t]=u+c*s[t];for(let r=1;r<n;++r){s=t.byIndex(r).getRawData(),c=e[r];for(let t=0;t<o;++t)a[t]+=c*s[t]}return i.Column.fromFloat32Array(t.getUnusedName("prediction"),a,o)}const un=(t,e)=>e<=t?Math.min(10,e):Math.min(10,t);var cn;!function(t){t[t.MAX_SAMLPES=1e5]="MAX_SAMLPES",t[t.MAX_FEATURES=1e3]="MAX_FEATURES"}(cn||(cn={}));class ln{static isApplicable(t,e){for(const e of t)if(!e.matches("numerical"))return!1;return!!e.matches("numerical")}static isInteractive(t,e){return t.length<=cn.MAX_FEATURES&&e.length<=cn.MAX_SAMLPES}constructor(t){if(this.specn=null,t)try{const e=new Uint32Array(t.buffer,0,2),n=e[0],r=e[1],o=new Uint8Array(t.buffer,8,n),a=i.DataFrame.fromByteArray(o),s=a.rowCount,u=a.columns,c=u.length,l=new Uint8Array(t.buffer,8+n,r),d=i.DataFrame.fromByteArray(l);if(c<3)throw new Error("incorrect columns count");const h=u.byName(ot.FEATURES).toList(),f=new Float32Array(s);f.set(u.byName(ot.REGR_COEFS).getRawData());const p=c-2,m=new Array(p);for(let t=0;t<p;++t)m[t]=new Float32Array(s),m[t].set(u.byIndex(t+2).getRawData());this.specn={params:f,loadings:m,names:h,dim:s-1,components:c-2,scores:d}}catch(t){throw new Error(`Failed to load model: ${t instanceof Error?t.message:"the platform issue"}`)}}fit(t,e,n){return r=this,o=void 0,s=function*(){const r=yield vt({table:i.DataFrame.fromColumns([e]),features:t,predict:e,components:n,names:void 0,isQuadratic:!1}),o=t.names();o.push("_");const a=this.getRegrCoeffs(t,e,r.regressionCoefficients),s=this.getLoadings(n,r.xLoadings);this.specn={names:o,params:a,loadings:s,components:n,dim:t.length,scores:this.getScoresDf(r)},this.computeExplVars(e.length,n,r.yLoadings)},new((a=void 0)||(a=Promise))(function(t,e){function n(t){try{u(s.next(t))}catch(t){e(t)}}function i(t){try{u(s.throw(t))}catch(t){e(t)}}function u(e){var r;e.done?t(e.value):(r=e.value,r instanceof a?r:new a(function(t){t(r)})).then(n,i)}u((s=s.apply(r,o||[])).next())});var r,o,a,s}getLoadings(t,e){const n=Array(t),r=e[0].length+1;for(let i=0;i<t;++i)n[i]=new Float32Array(r),n[i].set(e[i].getRawData());return n}getRegrCoeffs(t,e,n){const r=t.length,i=new Float32Array(r+1),o=n.getRawData();let a=0;for(let e=0;e<r;++e)i[e]=o[e],a+=o[e]*t.byIndex(e).stats.avg;return i[r]=e.stats.avg-a,i}computeExplVars(t,e,n){if(null===this.specn)throw new Error("Failed to compute explained variances");const r=n.getRawData(),i=this.specn.loadings[0].length-1;let o=Math.pow(r[0],2)/t;this.specn.loadings[0][i]=o;for(let n=1;n<e;++n)o+=Math.pow(r[n],2)/t,this.specn.loadings[n][i]=o}toBytes(){if(null===this.specn)throw new Error("Failed to pack untrained model");const t=i.DataFrame.fromColumns([i.Column.fromStrings(ot.FEATURES,this.specn.names),i.Column.fromFloat32Array(ot.REGR_COEFS,this.specn.params)]);this.specn.loadings.forEach((e,n)=>t.columns.add(i.Column.fromFloat32Array(`${ot.XLOADING}${n+1}`,e)));const e=t.toByteArray(),n=e.length,r=this.specn.scores.toByteArray(),o=r.length,a=n+o+8,s=new Uint8Array(64*(Math.ceil(a/64)+1)),u=new Uint32Array(s.buffer,0,2);return u[0]=n,u[1]=o,s.set(e,8),s.set(r,8+n),s}predict(t){if(null===this.specn)throw new Error("Predicting failed: model is not trained");return sn(t,this.specn.params)}loadingsParamsViewers(){if(null===this.specn)throw new Error("Failed to create loadings and parameters viewers: untrained model");const t=[],e=this.specn.dim,n=i.DataFrame.fromColumns([i.Column.fromStrings(ot.FEATURES,this.specn.names.slice(0,-1)),i.Column.fromFloat32Array(ot.REGR_COEFS,this.specn.params,e)]),r=n.columns,o=r.length,a=this.specn.components;return this.specn.loadings.forEach((t,r)=>n.columns.add(i.Column.fromFloat32Array(`${ot.XLOADING}${r+1}`,t,e))),t.push(i.Viewer.scatterPlot(n,{title:ot.LOADINGS,xColumnName:r.byIndex(o).name,yColumnName:r.byIndex(o+(a>1?1:0)).name,markerType:i.MARKER_TYPE.CIRCLE,labelFormColumnNames:[ot.FEATURES],help:st.LOADINGS})),t.push(i.Viewer.barChart(n,{title:ot.REGR_COEFS,splitColumnName:ot.FEATURES,valueColumnName:ot.REGR_COEFS,valueAggrType:i.AGG.AVG,help:st.COEFFS,showValueSelector:!1,showStackSelector:!1})),t}explVarsViewer(){if(null===this.specn)throw new Error("Failed to create exaplained variances viewer: untrained model");const t=this.specn.components,e=this.specn.dim,n=new Array(t),r=new Float32Array(t);n[0]=`${ct.COMP} 1`,r[0]=this.specn.loadings[0][e];for(let i=1;i<t;++i)n[i]=`${ct.COMPS} ${i+1}`,r[i]=this.specn.loadings[i][e];return i.Viewer.barChart(i.DataFrame.fromColumns([i.Column.fromStrings(ct.COMPS,n),i.Column.fromFloat32Array(ot.EXPL_VAR,r)]),{title:ot.EXPL_VAR,splitColumnName:ct.COMPS,valueColumnName:ot.EXPL_VAR,valueAggrType:i.AGG.AVG,help:st.EXPL_VARS,showCategorySelector:!1,showStackSelector:!1,showValueSelector:!1})}viewers(){if(null===this.specn)throw new Error("Failed to create viewers: untrained model");const t=this.loadingsParamsViewers();return t.push(this.explVarsViewer(),this.getScoresScatter()),t}getScoresDf(t){const e=t.tScores,n=t.uScores;return e.forEach((t,e)=>t.name=`${ot.XSCORE}${e+1}`),n.forEach((t,e)=>t.name=`${ot.YSCORE}${e+1}`),i.DataFrame.fromColumns(e.concat(n))}getScoresScatter(){if(null===this.specn)throw new Error("Failed to create scores scatter: untrained model");const t=this.specn.scores.columns.names(),e=i.Viewer.scatterPlot(this.specn.scores,{title:ot.SCORES,xColumnName:t[0],yColumnName:t[1],markerType:i.MARKER_TYPE.CIRCLE,help:st.SCORES,showViewerFormulaLines:!0});return e.meta.formulaLines.addAll(yt(t)),e}}var dn=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}u((r=r.apply(t,e||[])).next())})};const hn="Avg-s",fn="Stddev-s";var pn;!function(t){t[t.MAX_SAMLPES=5e4]="MAX_SAMLPES",t[t.MAX_FEATURES=100]="MAX_FEATURES"}(pn||(pn={}));class mn{static isApplicable(t,e){for(const e of t)if(!e.matches("numerical"))return!1;return e.type===i.COLUMN_TYPE.STRING}static isInteractive(t,e){return t.length<=pn.MAX_FEATURES&&e.length<=pn.MAX_SAMLPES}constructor(t,e){if(this.params=void 0,this.classesCount=1,this.featuresCount=1,void 0!==t){const e=t.featuresCount,n=t.classesCount;if(e<1)throw new Error("Incorrect features count");if(n<1)throw new Error("Incorrect classes count");const r=e+1;this.avgs=new Float32Array(r),this.stdevs=new Float32Array(r),this.categories=new Array(r),this.featuresCount=e,this.classesCount=n}else{if(void 0===e)throw new Error("Softmax classifier not initialized");try{const t=new Uint32Array(e.buffer,0,1)[0],n=new Uint8Array(e.buffer,4,t),r=i.DataFrame.fromByteArray(n),o=r.columns,a=o.length;if(a<3)throw new Error("incorrect columns count");this.classesCount=a-2,this.featuresCount=r.rowCount-1;const s=this.classesCount;this.params=new Array(s),this.categories=new Array(r.rowCount);for(let t=0;t<s;++t){const e=o.byIndex(t);if(this.categories[t]=e.name,e.type!==i.COLUMN_TYPE.FLOAT)throw new Error(`Incorrect input column type. Expected: float, passed: ${e.type}`);this.params[t]=e.getRawData()}const u=o.byName(hn);if(u.type!==i.COLUMN_TYPE.FLOAT)throw new Error("incorrect average values column type");this.avgs=u.getRawData();const c=o.byName(fn);if(c.type!==i.COLUMN_TYPE.FLOAT)throw new Error("incorrect standard deviations column type");this.stdevs=c.getRawData()}catch(t){throw new Error(`Failed to load model: ${t instanceof Error?t.message:"the platform issue"}`)}}}toBytes(){if(void 0===this.params)throw new Error("Non-trained model");const t=this.classesCount,e=new Array(t+2);for(let n=0;n<t;++n)e[n]=i.Column.fromFloat32Array(this.categories[n],this.params[n]);e[t]=i.Column.fromFloat32Array(hn,this.avgs),e[t+1]=i.Column.fromFloat32Array(fn,this.stdevs);const n=i.DataFrame.fromColumns(e).toByteArray(),r=n.length,o=new Uint8Array(r+4);return new Uint32Array(o.buffer,0,1)[0]=r,o.set(n,4),o}fit(t,e){return dn(this,arguments,void 0,function*(t,e,n=1,r=100,o=.1,a=.001){if(t.length!==this.featuresCount)throw new Error("Training failes - incorrect features count");if(n<=0||r<1||o<=0||a<=0)throw new Error("Training failes - incorrect fitting hyperparameters");this.extractStats(t);const s=e.length,u=e.categories.length,c=e.categories;for(let t=0;t<u;++t)this.categories[t]=c[t];try{const c=function(t,e,n,r,i,o,a,s,u,c,l){return g(EDA,"fitSoftmax",[t,e,n,r,i,o,a,s,u,c,l])}(t,i.Column.fromFloat32Array("avgs",this.avgs,this.featuresCount),i.Column.fromFloat32Array("stdevs",this.stdevs,this.featuresCount),i.Column.fromInt32Array("targets",e.getRawData(),s),u,r,n,o,a,this.featuresCount+1,u).columns;this.params=new Array(u);for(let t=0;t<u;++t)this.params[t]=c.byIndex(t).getRawData()}catch(i){try{this.params=yield this.fitSoftmaxParams(t,e,r,n,o,a)}catch(t){throw new Error("Training failes")}}if(void 0===this.params)throw new Error("Training failes")})}extractStats(t){let e=0;for(const n of t){if(n.type!==i.COLUMN_TYPE.INT&&n.type!==i.COLUMN_TYPE.FLOAT)throw new Error("Training failes - incorrect features type");this.avgs[e]=n.stats.avg,this.stdevs[e]=n.stats.stdev,++e}}normalized(t){const e=t.byIndex(0).length,n=new Array(e);for(let t=0;t<e;++t)n[t]=new Float32Array(this.featuresCount);let r=0;for(const o of t){if(o.type!==i.COLUMN_TYPE.INT&&o.type!==i.COLUMN_TYPE.FLOAT)throw new Error("Training failes - incorrect features type");const t=o.getRawData(),a=this.avgs[r],s=this.stdevs[r];if(s>0)for(let i=0;i<e;++i)n[i][r]=(t[i]-a)/s;else for(let t=0;t<e;++t)n[t][r]=0;++r}return n}transposed(t){const e=t.byIndex(0).length,n=this.featuresCount,r=new Array(n);for(let t=0;t<n;++t)r[t]=new Float32Array(e);let o=0;for(const n of t){if(n.type!==i.COLUMN_TYPE.INT&&n.type!==i.COLUMN_TYPE.FLOAT)throw new Error("Training failes - incorrect features type");const t=n.getRawData(),a=this.avgs[o],s=this.stdevs[o];if(s>0)for(let n=0;n<e;++n)r[o][n]=(t[n]-a)/s;else for(let t=0;t<e;++t)r[o][t]=0;++o}return r}preprocessedTargets(t){if(t.type!==i.COLUMN_TYPE.STRING)throw new Error("Training failes - incorrect target type");const e=this.classesCount,n=t.length,r=t.getRawData(),o=new Array(n),a=new Uint32Array(e).fill(0);for(let t=0;t<n;++t)o[t]=new Uint8Array(e).fill(0);for(let t=0;t<n;++t)o[t][r[t]]=1,++a[r[t]];return{oneHot:o,weights:a}}predict(t){if(void 0===this.params)throw new Error("Non-trained model");if(t.length!==this.featuresCount)throw new Error("Predcition fails: incorrect features count");const e=this.normalized(t),n=e.length,r=this.featuresCount,o=this.classesCount;let a,s;const u=new Float32Array(o);let c,l,d;const h=new Array(n);for(let t=0;t<n;++t){a=e[t],c=0;for(let t=0;t<o;++t){s=this.params[t],c=s[r];for(let t=0;t<r;++t)c+=s[t]*a[t];u[t]=Math.exp(c)}l=u[0],d=0;for(let t=1;t<o;++t)l<u[t]&&(l=u[t],d=t);h[t]=this.categories[d]}return i.Column.fromStrings("predicted",h)}fitSoftmaxParams(t,e,r,i,o,a){return dn(this,void 0,void 0,function*(){const s=this.preprocessedTargets(e);return new Promise((u,c)=>{const l=new Worker(new URL(n.p+n.u(501),n.b));l.postMessage({features:this.normalized(t),transposed:this.transposed(t),oneHot:s.oneHot,classesWeights:s.weights,targetRaw:e.getRawData(),iterations:r,rate:i,penalty:o,tolerance:a}),l.onmessage=function(t){l.terminate(),u(t.data.params),console.log(`Loss: ${t.data.loss}`)}})})}}var gn,yn,vn;!function(t){t[t.ITERATIONS=20]="ITERATIONS",t[t.ETA=.3]="ETA",t[t.MAX_DEPTH=6]="MAX_DEPTH",t[t.LAMBDA=1]="LAMBDA",t[t.ALPHA=0]="ALPHA"}(gn||(gn={})),function(t){t[t.SAMLPES_HIGH=1e5]="SAMLPES_HIGH",t[t.SAMLPES_MID=5e4]="SAMLPES_MID",t[t.SAMPLES_LOW=1e4]="SAMPLES_LOW",t[t.FEATURES_HIGH=10]="FEATURES_HIGH",t[t.FEATURES_MID=20]="FEATURES_MID",t[t.FEATURES_LOW=100]="FEATURES_LOW"}(yn||(yn={})),function(t){t[t.MODEL=1e7]="MODEL",t[t.UTILS=1]="UTILS",t[t.PACK=128]="PACK",t[t.SIZE=4]="SIZE"}(vn||(vn={}));const wn=i.FLOAT_NULL;var bn;!function(t){t.PREDICT="Prediction",t.TYPE="Type",t.PARAMS="Params count",t.CATS="Categories",t.CATS_SIZE="Categories size"}(bn||(bn={}));class An{static isApplicable(t,e){for(const e of t)if(!e.matches("numerical"))return!1;return!(!e.matches("numerical")&&!e.matches("string"))}static isInteractive(t,e){const n=t.length,r=e.length;return r<=yn.SAMPLES_LOW?n<=yn.FEATURES_LOW:r<=yn.SAMLPES_MID?n<=yn.FEATURES_MID:r<=yn.SAMLPES_HIGH&&n<=yn.FEATURES_HIGH}constructor(t){var e;if(this.modelParams=void 0,this.targetType=void 0,this.targetCategories=void 0,t)try{let n=0;const r=new Uint32Array(t.buffer,n,1)[0];n+=vn.SIZE;const o=i.DataFrame.fromByteArray(new Uint8Array(t.buffer,n,r));n+=r,this.targetType=o.get(bn.TYPE,0);const a=o.get(bn.PARAMS,0),s=o.get(bn.CATS_SIZE,0);if(s>0){const r=i.DataFrame.fromByteArray(new Uint8Array(t.buffer,n,s));this.targetCategories=null===(e=r.col(bn.CATS))||void 0===e?void 0:e.toList()}n+=s,n=4*Math.ceil(n/4),this.modelParams=new Int32Array(t.buffer,n,a)}catch(t){throw new Error(`Failed to load model: ${t instanceof Error?t.message:"the platform issue"}`)}}fit(t,e){return r=this,o=arguments,s=function*(t,e,r=gn.ITERATIONS,o=gn.ETA,a=gn.MAX_DEPTH,s=gn.LAMBDA,u=gn.ALPHA){this.targetType=e.type,this.targetType===i.COLUMN_TYPE.STRING&&(this.targetCategories=e.categories),this.modelParams=yield async function(t,e,r,i,o,a,s,u,c,l){return new Promise((d,h)=>{const f=e.length,p=t.length,m=new Float32Array(f*p);let g,y;for(let e=0;e<p;++e){y=t.byIndex(e).getRawData(),g=e*f;for(let t=0;t<f;++t)m[t+g]=y[t]}const v=new Worker(new URL(n.p+n.u(990),n.b));v.postMessage({features:m,target:e.getRawData(),samplesCount:f,featuresCount:p,modelReserve:c,utilsLength:l,iterations:i,eta:o,maxDepth:a,lambda:s,alpha:u,missingValue:r}),v.onmessage=function(t){v.terminate(),d(t.data.params)}})}(t,e,wn,r,o,a,s,u,vn.MODEL,vn.UTILS)},new((a=void 0)||(a=Promise))(function(t,e){function n(t){try{u(s.next(t))}catch(t){e(t)}}function i(t){try{u(s.throw(t))}catch(t){e(t)}}function u(e){var r;e.done?t(e.value):(r=e.value,r instanceof a?r:new a(function(t){t(r)})).then(n,i)}u((s=s.apply(r,o||[])).next())});var r,o,a,s}predict(t){if(void 0===this.modelParams)throw new Error("Failed to apply non-trained model");const e=function(t,e,n){const r=t.byIndex(0).length,i=t.length,o=n.length;let a=XGBoostModule.HEAPF32;const s=XGBoostModule.HEAP32,u=XGBoostModule._malloc(r*i*4),c=XGBoostModule._malloc(4*r),l=XGBoostModule._malloc(4*o);for(let e=0;e<i;++e){const n=t.byIndex(e).getRawData();for(let t=0;t<r;++t)a[u/4+t+e*r]=n[t]}for(let t=0;t<o;++t)s[l/4+t]=n[t];XGBoostModule._predict(u,r,i,e,l,o,c,r),a=XGBoostModule.HEAPF32;const d=new Float32Array(r);for(let t=0;t<r;++t)d[t]=a[c/4+t];return XGBoostModule._free(u),XGBoostModule._free(c),XGBoostModule._free(l),d}(t,wn,this.modelParams);switch(this.targetType){case i.COLUMN_TYPE.STRING:return this.stringColPrediction(e);case i.COLUMN_TYPE.INT:return this.intColPrediction(e);case i.COLUMN_TYPE.BIG_INT:return this.bigIntColPrediction(e);default:return i.Column.fromFloat32Array(bn.PREDICT,e)}}toBytes(){if(void 0===this.modelParams||void 0===this.targetType)throw new Error("Failed to pack non-trained model");const t=void 0!==this.targetCategories?i.DataFrame.fromColumns([i.Column.fromList(i.COLUMN_TYPE.STRING,bn.CATS,this.targetCategories)]).toByteArray():void 0,e=void 0!==t?t.length:0,n=this.modelParams.length*this.modelParams.BYTES_PER_ELEMENT,r=i.DataFrame.fromColumns([i.Column.fromStrings(bn.TYPE,[this.targetType]),i.Column.fromInt32Array(bn.PARAMS,new Int32Array([this.modelParams.length])),i.Column.fromInt32Array(bn.CATS_SIZE,new Int32Array([e]))]).toByteArray(),o=r.length,a=64*Math.ceil((vn.SIZE+o+e+n+vn.PACK)/64),s=new Uint8Array(a);let u=0;return new Uint32Array(s.buffer,u,1)[0]=o,u+=vn.SIZE,s.set(r,u),u+=o,e>0&&s.set(t,u),u+=e,u=4*Math.ceil(u/4),s.set(new Uint8Array(this.modelParams.buffer),u),s}stringColPrediction(t){const e=t.length;if(void 0===this.targetCategories)throw new Error("Predicting fails: undefined categories");const n=new Array(e),r=this.targetCategories.length-1,o=t=>Math.max(0,Math.min(t,r));for(let r=0;r<e;++r)n[r]=this.targetCategories[o(Math.round(t[r]))];return i.Column.fromList(i.COLUMN_TYPE.STRING,bn.PREDICT,n)}intColPrediction(t){const e=t.length,n=new Int32Array(e);for(let r=0;r<e;++r)n[r]=Math.round(t[r]);return i.Column.fromInt32Array(bn.PREDICT,n,e)}bigIntColPrediction(t){const e=t.length,n=new BigInt64Array(e);for(let r=0;r<e;++r)n[r]=BigInt(Math.round(t[r]));return i.Column.fromBigInt64Array(bn.PREDICT,n)}}var En=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}u((r=r.apply(t,e||[])).next())})};function Cn(){Lr.info()}function Sn(){return En(this,void 0,void 0,function*(){yield Lr.init()})}function _n(t,e,n,r,i){return En(this,void 0,void 0,function*(){return yield Lr.dbScan(t,e,n,r,i)})}function Mn(t,e,n,r,i){return En(this,void 0,void 0,function*(){yield Lr.PCA(t,e,n,r,i)})}function Nn(t,e,n,r){return En(this,void 0,void 0,function*(){yield Lr.dbscanPostProcessingFunction(t,e,n,r)})}function In(t,e){return Lr.numberPreprocessingFunction(t,e)}function Ln(t,e){return Lr.stringPreprocessingFunction(t,e)}function Pn(){return En(this,void 0,void 0,function*(){yield Lr.reduceDimensionality()})}function Tn(t){Lr.GetMCLEditor(t)}function Fn(t,e,n,r,i,o,a,s,u,c,l,d){return En(this,void 0,void 0,function*(){return yield Lr.MCLClustering(t,e,n,r,i,o,a,s,u,c,l,d)})}function On(){return Lr.markovClusteringViewer()}function Rn(t,e,n,r,i){return En(this,void 0,void 0,function*(){return yield Lr.PLS(t,e,n,r,i)})}function xn(){return En(this,void 0,void 0,function*(){yield Lr.topMenuPLS()})}function Dn(){return En(this,void 0,void 0,function*(){yield Lr.MVA()})}function kn(){return En(this,void 0,void 0,function*(){yield Lr.demoMultivariateAnalysis()})}function Un(t,e,n){return En(this,void 0,void 0,function*(){return yield Lr.trainLinearKernelSVM(t,e,n)})}function Gn(t,e){return En(this,void 0,void 0,function*(){return yield Lr.applyLinearKernelSVM(t,e)})}function Vn(t,e){return En(this,void 0,void 0,function*(){return yield Lr.isApplicableLinearKernelSVM(t,e)})}function Bn(t,e){return En(this,void 0,void 0,function*(){return yield Lr.isInteractiveLinearKernelSVM(t,e)})}function Wn(t,e,n,r){return En(this,void 0,void 0,function*(){return yield Lr.visualizeLinearKernelSVM(t,e,n,r)})}function zn(t,e,n,r){return En(this,void 0,void 0,function*(){return yield Lr.trainRBFkernelSVM(t,e,n,r)})}function Hn(t,e){return En(this,void 0,void 0,function*(){return yield Lr.applyRBFkernelSVM(t,e)})}function jn(t,e){return En(this,void 0,void 0,function*(){return yield Lr.isApplicableRBFkernelSVM(t,e)})}function Kn(t,e){return En(this,void 0,void 0,function*(){return yield Lr.isInteractiveRBFkernelSVM(t,e)})}function qn(t,e,n,r){return En(this,void 0,void 0,function*(){return yield Lr.visualizeRBFkernelSVM(t,e,n,r)})}function Yn(t,e,n,r,i){return En(this,void 0,void 0,function*(){return yield Lr.trainPolynomialKernelSVM(t,e,n,r,i)})}function $n(t,e){return En(this,void 0,void 0,function*(){return yield Lr.applyPolynomialKernelSVM(t,e)})}function Xn(t,e){return En(this,void 0,void 0,function*(){return yield Lr.isApplicablePolynomialKernelSVM(t,e)})}function Qn(t,e){return En(this,void 0,void 0,function*(){return yield Lr.isInteractivePolynomialKernelSVM(t,e)})}function Jn(t,e,n,r){return En(this,void 0,void 0,function*(){return yield Lr.visualizePolynomialKernelSVM(t,e,n,r)})}function Zn(t,e,n,r,i){return En(this,void 0,void 0,function*(){return yield Lr.trainSigmoidKernelSVM(t,e,n,r,i)})}function tr(t,e){return En(this,void 0,void 0,function*(){return yield Lr.applySigmoidKernelSVM(t,e)})}function er(t,e){return En(this,void 0,void 0,function*(){return yield Lr.isApplicableSigmoidKernelSVM(t,e)})}function nr(t,e){return En(this,void 0,void 0,function*(){return yield Lr.isInteractiveSigmoidKernelSVM(t,e)})}function rr(t,e,n,r){return En(this,void 0,void 0,function*(){return yield Lr.visualizeSigmoidKernelSVM(t,e,n,r)})}function ir(){Lr.anova()}function or(){Lr.kNNImputation()}function ar(t){return En(this,void 0,void 0,function*(){yield Lr.kNNImputationForTable(t)})}function sr(t,e){return En(this,void 0,void 0,function*(){return yield Lr.trainLinearRegression(t,e)})}function ur(t,e){return Lr.applyLinearRegression(t,e)}function cr(t,e){return Lr.isApplicableLinearRegression(t,e)}function lr(t,e){return Lr.isInteractiveLinearRegression(t,e)}function dr(t,e,n,r,i,o){return En(this,void 0,void 0,function*(){return yield Lr.trainSoftmax(t,e,n,r,i,o)})}function hr(t,e){return Lr.applySoftmax(t,e)}function fr(t,e){return Lr.isApplicableSoftmax(t,e)}function pr(t,e){return Lr.isInteractiveSoftmax(t,e)}function mr(t,e,n){return En(this,void 0,void 0,function*(){return yield Lr.trainPLSRegression(t,e,n)})}function gr(t,e){return Lr.applyPLSRegression(t,e)}function yr(t,e){return Lr.isApplicablePLSRegression(t,e)}function vr(t,e,n,r){return En(this,void 0,void 0,function*(){return yield Lr.visualizePLSRegression(t,e,n,r)})}function wr(t,e){return Lr.isInteractivePLSRegression(t,e)}function br(t,e,n,r,i,o,a){return En(this,void 0,void 0,function*(){return yield Lr.trainXGBooster(t,e,n,r,i,o,a)})}function Ar(t,e){return Lr.applyXGBooster(t,e)}function Er(t,e){return Lr.isInteractiveXGBooster(t,e)}function Cr(t,e){return Lr.isApplicableXGBooster(t,e)}var Sr=function(t,e,n,r){var i,o=arguments.length,a=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(a=(o<3?i(a):o>3?i(e,n,a):i(e,n))||a);return o>3&&a&&Object.defineProperty(e,n,a),a},_r=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},Mr=function(t,e){return function(n,r){e(n,r,t)}},Nr=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}u((r=r.apply(t,e||[])).next())})};const Ir=new i.Package;class Lr{static info(){t.shell.info(Ir.webRoot)}static init(){return Nr(this,void 0,void 0,function*(){yield async function(){await initEDA()}(),yield async function(){await initXGBoostModule()}()})}static dbScan(t,e,n,r,o){return Nr(this,void 0,void 0,function*(){const a=e.getRawData(),s=n.getRawData(),u=yield Wt(a,s,r,o),c=t.columns.getUnusedName("Cluster (DBSCAN)"),l=i.Column.fromInt32Array(c,u);return t.columns.add(l),l})}static PCA(e,n,r,i,o){return Nr(this,void 0,void 0,function*(){try{const a=yield B(e,n,r,i,o);if(function(t,e){for(const t of e.toList())t.name="PC"+t.name}(0,a.columns),null===e.id)t.shell.addTableView(a);else{const t=e.columns,n=a.columns.toList();for(const e of n)a.columns.remove(e.name),e.name=t.getUnusedName(e.name),t.add(e)}}catch(e){t.shell.warning(`Failed to compute PCA: ${e instanceof Error?e.message:"platform issue"}`)}})}static dbscanPostProcessingFunction(e,n,r,o){return Nr(this,void 0,void 0,function*(){const a=e.dataFrame;if(null===a)return;const s=yield Lr.dbScan(a,e,n,r,o);a.changeColumnType(s,"string");const u=[e.name,n.name],c=t.shell.tableView(a.name);if(c)for(const t of c.viewers)if(t instanceof i.ScatterPlotViewer&&u.includes(t.props.xColumnName)&&u.includes(t.props.yColumnName))return void(t.props.colorColumnName=s.name)})}static numberPreprocessingFunction(t,e){const n=t.stats.max-t.stats.min;return{entries:t.toList(),options:{range:n}}}static stringPreprocessingFunction(t,e){return{entries:t.toList(),options:{}}}static reduceDimensionality(){return Nr(this,void 0,void 0,function*(){const r=new Ye,o=e.dialog("Reduce Dimensionality").add(r.getEditor()).onOK(()=>Nr(this,void 0,void 0,function*(){const o=r.getParams();0!==o.columns.length&&(yield async function(r,o,a,s,u,c,l,d=!0,h=!1,f={preprocessingFuncArgs:[]},p={},m=null,g={},y){const v={showXAxis:!1,showYAxis:!1,showXSelector:!1,showYSelector:!1};if(o.length!==s.length||o.length!==c.length||o.length!==u.length||o.length!==f.preprocessingFuncArgs.length)throw new Error("columns, metrics and preprocessing functions, weights and function argumentsmust have the same length");const w=d?p.tableView??t.shell.tableView(r.name)??t.shell.addTableView(r):null,b=async()=>{const b=i.TaskBarProgressIndicator.create(`Initializing ${p.scatterPlotName??"dimensionality reduction"} ...`);let A;try{const E=function(t){const e=["Embed_X","Embed_Y"],n=t.columns.names().filter(t=>t.includes(e[0])).length+1;return e.map(t=>`${t}_${n}`)}(r);function C(t,n,s){let u=null,c=null;r.columns.names().includes(E[0])?(u=r.columns.byName(E[0]),c=r.columns.byName(E[1])):(u=r.columns.add(i.Column.float(E[0],r.rowCount)),c=r.columns.add(i.Column.float(E[1],r.rowCount)),d&&!A&&(A=w.scatterPlot({...v,x:E[0],y:E[1],title:p.scatterPlotName??tn(o,a)}))),p["show-scatterplot-progress"]&&(A?.root&&e.setUpdateIndicator(A.root,!1),u.init(t=>s[0]?s[0][t]:void 0),c.init(t=>s[1]?s[1][t]:void 0));const l=t/n*100;b.update(l,`Running ${p.scatterPlotName??"dimensionality reduction"}... ${l.toFixed(0)}%`)}async function S(){r.columns.add(i.Column.float(E[0],r.rowCount)),r.columns.add(i.Column.float(E[1],r.rowCount));let h=null;d&&(A=w.scatterPlot({...v,x:E[0],y:E[1],title:p.scatterPlotName??tn(o,a)}),e.setUpdateIndicator(A.root,!0));const m=t.events.onViewerClosed.subscribe(e=>{const n=e.args.viewer;n?.getOptions()?.look?.title&&A?.getOptions()?.look?.title&&n?.getOptions()?.look?.title===A?.getOptions()?.look?.title&&(t.events.fireCustomEvent(Je,{}),m.unsubscribe(),h?.(),b.close())}),g=new Promise(async(e,i)=>{try{h=e;const i=[];let d=s,m=u,g=l;if(y&&o.every(t=>t.isNumerical)){const t=o.map(t=>t.toList()),e=new Array(r.rowCount).fill(0).map((t,e)=>new Float32Array(o.length));for(let n=0;n<o.length;++n)for(let i=0;i<r.rowCount;++i)e[i][n]=t[n][i];f.distanceFnArgs=[{}],i.push({entries:e,options:{}}),d=[y],m=[1],g="MANHATTAN"}else for(let t=0;t<c.length;++t){const e=c[t];if(f.distanceFnArgs||(f.distanceFnArgs=[]),e){const n=e.inputs[0].name,r=e.inputs[1].name,{entries:a,options:u}=await e.apply({[n]:o[t],[r]:s[t],...f.preprocessingFuncArgs[t]??{}});i.push({entries:a,options:u}),f.distanceFnArgs.push(u)}else{const e=o[t].toList(),n={};i.push({entries:e,options:n}),f.distanceFnArgs.push(n)}}e(await async function(e,r,i,o,a,s,u){let c=await async function(e,r,i,o,a,s,u){if(!s.distanceFnArgs)throw new Error("options.distanceFnArgs must be defined");if(e.length!==r.length||e.length!==s.distanceFnArgs.length||e.length!==o.length)throw new Error("data, metrics and options and weights must have the same length");return new Promise(function(c,l){const d=new Worker(new URL(n.p+n.u(234),n.b));d.postMessage({columnsData:e,distanceMetrics:r,method:i,options:s,weights:o,aggregationMethod:a});const h=t.events.onCustomEvent(Je).subscribe(()=>{try{d?.terminate()}finally{h.unsubscribe()}});d.onmessage=({data:{error:t,embedding:e,epochNum:n,epochsLength:r}})=>{Ze(n)||Ze(r)?(h.unsubscribe(),t?l(t):c(e),setTimeout(()=>d.terminate(),100)):u&&u(n,r,e)}})}(e,i,r,o,a,s,u);return c=c.map(t=>function(t){const e=t.length;let n=0,r=0;for(let i=0;i<e;++i)n+=t[i],r+=Math.pow(t[i],2);const i=n/e,o=1/Math.sqrt(r/e-Math.pow(i,2));for(let n=0;n<e;++n)t[n]=(t[n]-i)*o;return t}(t)),c}(i.map(t=>t.entries),a,d,m,l,f,p[re]?void 0:C))}catch(t){i(t)}}),S=await g;return b.close(),m.unsubscribe(),S}const _=await S();if(h&&_){const M=i.TaskBarProgressIndicator.create("Clustering embeddings ...");try{const N=await Wt(_[0],_[1],f.dbScanEpsilon??.01,f.dbScanMinPts??4),I=r.columns.getUnusedName("Cluster (DBSCAN)");r.columns.addNewString(I).init(t=>N[t].toString()),A&&(A.props.colorColumnName=I)}catch(L){t.shell.error("Clustering embeddings failed"),console.error(L)}finally{M.close()}}if(_){const P=r.columns.byName(E[0]),T=r.columns.byName(E[1]);if(P.init(t=>_[0][t]),T.init(t=>_[1][t]),m)try{const F=m.inputs[0].name,O=m.inputs[1].name;await m.prepare({[F]:P,[O]:T,...g}).call(!0)}catch(R){t.shell.error("Post-processing failed"),console.error(R)}if(A)return e.setUpdateIndicator(A.root,!1),A.helpUrl="/help/compute/sequence-space",A}}catch(x){t.shell.error("Dimensionality reduction failed"),console.error(x),b.close(),A&&e.setUpdateIndicator(A.root,!1)}};return new Promise(async(t,n)=>{try{if(p.fastRowCount&&r.rowCount>p.fastRowCount&&!p[re])e.dialog().add(e.divText("Analysis might take several minutes. Do you want to continue?")).onOK(async()=>{try{const e=await b();t(e)}catch(t){n(t)}}).onCancel(()=>t(void 0)).show();else{const e=await b();t(e)}}catch(t){n(t)}})}(o.table,o.columns,o.methodName,o.distanceMetrics,o.weights,o.preprocessingFunctions,o.aggreaggregationMethod,!!o.plotEmbeddings,!!o.clusterEmbeddings,o.options,{fastRowCount:1e4},o.postProcessingFunction,o.postProcessingFunctionArgs,o.vectorDistanceMetric))})).show();o.helpUrl="https://datagrok.ai/help/explore/dim-reduction.md";const a=()=>{const t=r.columnsInput.value,e=o.getButton("OK");e&&(t&&0!==t.length?e.classList.remove("disabled"):e.classList.add("disabled"))};o.history(()=>({editorSettings:r.getStringInput()}),t=>r.applyStringInput(t.editorSettings)),r.onColumnsChanged.subscribe(()=>{try{a()}catch(t){console.error(t)}}),a()})}static GetMCLEditor(n){try{const t=new nn;e.dialog("Markov clustering").add(t.getEditor()).onOK(()=>Nr(this,void 0,void 0,function*(){const e=t.params;return n.func.prepare({df:e.table,cols:e.columns,metrics:e.distanceMetrics,weights:e.weights,aggregationMethod:e.aggreaggregationMethod,preprocessingFuncs:e.preprocessingFunctions,preprocessingFuncArgs:e.preprocessingFuncArgs,threshold:e.threshold,maxIterations:e.maxIterations,useWebGPU:e.useWebGPU,inflate:e.inflateFactor,minClusterSize:e.minClusterSize}).call(!0)})).show().history(()=>({editorSettings:t.getStringInput()}),e=>t.applyStringInput(e.editorSettings))}catch(e){const n=e instanceof Error?e.message:e.toString(),r=e instanceof Error?e.stack:void 0;t.shell.error(`Get region editor error: ${n}`),Ir.logger.error(n,void 0,r)}}static MCLClustering(e,n,r,i,o,a,s){return Nr(this,arguments,void 0,function*(e,n,r,i,o,a,s,u=80,c=10,l=!1,d=0,h=5){var f;const p=null!==(f=t.shell.tableView(e.name))&&void 0!==f?f:t.shell.addTableView(e),m=JSON.stringify({cols:n.map(t=>t.name),metrics:r,weights:i,aggregationMethod:o,preprocessingFuncs:a.map(t=>{var e;return null!==(e=null==t?void 0:t.name)&&void 0!==e?e:null}),preprocessingFuncArgs:s,threshold:u,maxIterations:c,useWebGPU:l,inflate:d,minClusterSize:null!=h?h:5});return p.addViewer("MCL",{mclProps:m})})}static markovClusteringViewer(){return new on}static PLS(t,e,n,r,i){return Nr(this,void 0,void 0,function*(){return yield vt({table:t,features:e,predict:n,components:r,isQuadratic:!1,names:i})})}static topMenuPLS(){return Nr(this,void 0,void 0,function*(){yield wt(rt.COMPUTE_COMPONENTS)})}static MVA(){return Nr(this,void 0,void 0,function*(){yield wt(rt.PERFORM_MVA)})}static demoMultivariateAnalysis(){return Nr(this,void 0,void 0,function*(){yield function(){return mt(this,void 0,void 0,function*(){t.shell.addTableView(i.DataFrame.fromColumns([i.Column.fromStrings("model",["alfaromeo","audi","bmw","chevrolet","dodge1","dodge2","honda1","honda2","isuzu","jaguar","mazda","mercedes","mercury","mitsubishi","nissan1","nissan2","peugot","plymouth","porsche","saab","subaru","toyota1","toyota2","toyota3","toyota4","volkswagen1","volkswagen2","volvo1","volvo2","volvo3"]),i.Column.fromInt32Array("diesel",new Int32Array([0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,1,0,1,1,0,0,0,1])),i.Column.fromInt32Array("turbo",new Int32Array([0,0,0,0,1,0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,1,1])),i.Column.fromInt32Array("two.doors",new Int32Array([1,0,1,0,1,0,1,0,0,0,0,0,1,1,0,1,0,0,1,0,0,1,0,1,0,1,0,0,0,0])),i.Column.fromInt32Array("hatchback",new Int32Array([1,0,0,0,1,1,1,0,0,0,0,0,1,1,0,0,1,0,0,0,0,1,0,1,0,0,0,0,0,0])),i.Column.fromFloat32Array("wheel.base",new Float32Array([94.5,105.80000305175781,101.19999694824219,94.5,93.69999694824219,93.69999694824219,93.69999694824219,96.5,94.30000305175781,113,93.0999984741211,115.5999984741211,102.69999694824219,93.69999694824219,94.5,94.5,93.69999694824219,114.19999694824219,89.5,99.0999984741211,97.19999694824219,95.69999694824219,95.69999694824219,98.4000015258789,102.4000015258789,97.30000305175781,100.4000015258789,104.30000305175781,109.0999984741211,109.0999984741211])),i.Column.fromFloat32Array("length",new Float32Array([171.1999969482422,192.6999969482422,176.8000030517578,158.8000030517578,157.3000030517578,157.3000030517578,150,175.39999389648438,170.6999969482422,199.60000610351562,166.8000030517578,202.60000610351562,178.39999389648438,157.3000030517578,170.1999969482422,165.3000030517578,157.3000030517578,198.89999389648438,168.89999389648438,186.60000610351562,172,158.6999969482422,166.3000030517578,176.1999969482422,175.60000610351562,171.6999969482422,180.1999969482422,188.8000030517578,188.8000030517578,188.8000030517578])),i.Column.fromFloat32Array("width",new Float32Array([65.5,71.4000015258789,64.80000305175781,63.599998474121094,63.79999923706055,63.79999923706055,64,65.19999694824219,61.79999923706055,69.5999984741211,64.19999694824219,71.69999694824219,68,64.4000015258789,63.79999923706055,63.79999923706055,63.79999923706055,68.4000015258789,65,66.5,65.4000015258789,63.599998474121094,64.4000015258789,65.5999984741211,66.5,65.5,66.9000015258789,67.19999694824219,68.80000305175781,68.9000015258789])),i.Column.fromFloat32Array("height",new Float32Array([52.400001525878906,55.70000076293945,54.29999923706055,52,50.79999923706055,50.599998474121094,52.599998474121094,54.099998474121094,53.5,52.79999923706055,54.099998474121094,56.29999923706055,54.79999923706055,50.79999923706055,53.5,54.5,50.599998474121094,58.70000076293945,51.599998474121094,56.099998474121094,52.5,54.5,53,52,54.900001525878906,55.70000076293945,55.099998474121094,56.20000076293945,55.5,55.5])),i.Column.fromInt32Array("curb.weight",new Int32Array([2823,2844,2395,1909,2128,1967,1956,2304,2337,4066,1950,3770,2910,1918,2024,1951,1967,3430,2800,2695,2190,1985,2275,2551,2480,2261,2661,2912,3049,3217])),i.Column.fromInt32Array("eng.size",new Int32Array([152,136,108,90,98,90,92,110,111,258,91,183,140,92,97,97,90,152,194,121,108,92,110,146,110,97,136,141,141,145])),i.Column.fromInt32Array("horsepower",new Int32Array([154,110,101,70,102,68,76,86,78,176,68,123,175,68,69,69,68,95,207,110,82,62,56,116,73,52,110,114,160,106])),i.Column.fromInt32Array("peak.rpm",new Int32Array([5e3,5500,5800,5400,5500,5500,6e3,5800,4800,4750,5e3,4350,5e3,5500,5200,5200,5500,4150,5900,5250,4400,4800,4500,4800,4500,4800,5500,5400,5300,4800])),i.Column.fromInt32Array("symbol",new Int32Array([1,1,2,0,1,1,1,0,0,0,1,-1,1,2,1,1,1,0,3,2,0,1,0,2,-1,2,0,-2,-1,-1])),i.Column.fromInt32Array("city.mpg",new Int32Array([19,19,23,38,24,31,30,27,24,15,31,22,19,37,31,31,31,25,17,21,28,35,34,24,30,37,19,23,19,26])),i.Column.fromInt32Array("highway.mpg",new Int32Array([26,25,29,43,30,38,34,33,29,19,38,25,24,41,37,37,38,25,25,28,33,39,36,30,33,46,24,28,25,27])),i.Column.fromInt32Array("price",new Int32Array([16500,17710,16430,6575,7957,6229,7129,8845,6785,35550,7395,31600,16503,5389,7349,7299,6229,13860,37028,12170,7775,5348,7898,9989,10698,7775,13295,12940,19045,22470]))])),t.shell.windows.help.visible=!0,t.shell.windows.help.showHelp(e.markdown("# Data\nEach car has many features - patterns extraction is complicated.\n\n# Model\nPredict car price by its other features.\n\n# Try\nPress 'RUN' to perform multivariate analysis using partial least squares\n([PLS](https://en.wikipedia.org/wiki/Partial_least_squares_regression)) regression.\n\n# Essence\nThe method finds the latent factors that\n\n* capture the maximum variance in the features\n* maximize correlation with the response variable")),t.shell.windows.showContextPanel=!1,t.shell.windows.showProperties=!1,yield wt(rt.DEMO)})}()})}static trainLinearKernelSVM(t,e,n){return Nr(this,void 0,void 0,function*(){return J(yield X({gamma:n,kernel:0},t,e))})}static applyLinearKernelSVM(t,e){return Nr(this,void 0,void 0,function*(){return yield tt(t,e)})}static isApplicableLinearKernelSVM(t,e){return Nr(this,void 0,void 0,function*(){return et(t,e)})}static isInteractiveLinearKernelSVM(t,e){return Nr(this,void 0,void 0,function*(){return nt(t)})}static visualizeLinearKernelSVM(t,e,n,r){return Nr(this,void 0,void 0,function*(){return Q(0,r)})}static trainRBFkernelSVM(t,e,n,r){return Nr(this,void 0,void 0,function*(){return J(yield X({gamma:n,kernel:2,sigma:r},t,e))})}static applyRBFkernelSVM(t,e){return Nr(this,void 0,void 0,function*(){return yield tt(t,e)})}static isApplicableRBFkernelSVM(t,e){return Nr(this,void 0,void 0,function*(){return et(t,e)})}static isInteractiveRBFkernelSVM(t,e){return Nr(this,void 0,void 0,function*(){return nt(t)})}static visualizeRBFkernelSVM(t,e,n,r){return Nr(this,void 0,void 0,function*(){return Q(0,r)})}static trainPolynomialKernelSVM(t,e,n,r,i){return Nr(this,void 0,void 0,function*(){return J(yield X({gamma:n,kernel:1,cParam:r,dParam:i},t,e))})}static applyPolynomialKernelSVM(t,e){return Nr(this,void 0,void 0,function*(){return yield tt(t,e)})}static isApplicablePolynomialKernelSVM(t,e){return Nr(this,void 0,void 0,function*(){return et(t,e)})}static isInteractivePolynomialKernelSVM(t,e){return Nr(this,void 0,void 0,function*(){return nt(t)})}static visualizePolynomialKernelSVM(t,e,n,r){return Nr(this,void 0,void 0,function*(){return Q(0,r)})}static trainSigmoidKernelSVM(t,e,n,r,i){return Nr(this,void 0,void 0,function*(){return J(yield X({gamma:n,kernel:3,kappa:r,theta:i},t,e))})}static applySigmoidKernelSVM(t,e){return Nr(this,void 0,void 0,function*(){return yield tt(t,e)})}static isApplicableSigmoidKernelSVM(t,e){return Nr(this,void 0,void 0,function*(){return et(t,e)})}static isInteractiveSigmoidKernelSVM(t,e){return Nr(this,void 0,void 0,function*(){return nt(t)})}static visualizeSigmoidKernelSVM(t,e,n,r){return Nr(this,void 0,void 0,function*(){return Q(0,r)})}static anova(){Bt()}static kNNImputation(){en()}static kNNImputationForTable(t){return Nr(this,void 0,void 0,function*(){yield en(t)})}static trainLinearRegression(t,e){return Nr(this,void 0,void 0,function*(){const n=t.columns,r=yield function(t,e){return an(this,void 0,void 0,function*(){const n=t.length,r=e.length,o=e.stats.avg,a=e.stats.stdev,s=new Float32Array(n+1).fill(0);if(s[n]=o,0===a||1===r)return s;try{const r=[],u=[],c=new Float32Array(n),l=new Float32Array(n);let d=0,h=0;for(const e of t){const t=e.stats;t.stdev>0&&(r.push(d),u.push(e),c[h]=t.avg,l[h]=t.stdev,++h),++d}if(0===h)return s;const f=function(t,e,n,r,i,o,a){return g(EDA,"fitLinearRegressionParamsWithDataNormalizing",[t,e,n,r,i,o,a])}(i.DataFrame.fromColumns(u).columns,i.Column.fromFloat32Array("xAvgs",c,h),i.Column.fromFloat32Array("xStdevs",l,h),e,o,a,h+1).getRawData();for(let t=0;t<h;++t)s[r[t]]=f[t];s[n]=f[h]}catch(r){const o=yield function(t,e,n){return an(this,void 0,void 0,function*(){return(yield vt({table:i.DataFrame.fromColumns([e]),features:t,predict:e,components:n,names:void 0,isQuadratic:!1})).regressionCoefficients.getRawData()})}(t,e,un(t.length,e.length));let a=0;for(let e=0;e<n;++e)s[e]=o[e],a+=o[e]*t.byIndex(e).stats.avg;s[n]-=a}return s})}(n,e);return new Uint8Array(r.buffer)})}static applyLinearRegression(t,e){const n=t.columns,r=new Float32Array(e.buffer);return i.DataFrame.fromColumns([sn(n,r)])}static isApplicableLinearRegression(t,e){for(const e of t.columns)if(!e.matches("numerical"))return!1;return e.matches("numerical")}static isInteractiveLinearRegression(t,e){return t.rowCount<=1e5}static trainSoftmax(t,e,n,r,i,o){return Nr(this,void 0,void 0,function*(){const a=t.columns,s=new mn({classesCount:e.categories.length,featuresCount:a.length});return yield s.fit(a,e,n,r,i,o),s.toBytes()})}static applySoftmax(t,e){const n=t.columns,r=new mn(void 0,e);return i.DataFrame.fromColumns([r.predict(n)])}static isApplicableSoftmax(t,e){return mn.isApplicable(t.columns,e)}static isInteractiveSoftmax(t,e){return mn.isInteractive(t.columns,e)}static trainPLSRegression(t,e,n){return Nr(this,void 0,void 0,function*(){const r=t.columns,i=new ln;return yield i.fit(r,e,Math.min(n,r.length)),i.toBytes()})}static applyPLSRegression(t,e){const n=new ln(e);return i.DataFrame.fromColumns([n.predict(t.columns)])}static isApplicablePLSRegression(t,e){return ln.isApplicable(t.columns,e)}static visualizePLSRegression(t,e,n,r){return Nr(this,void 0,void 0,function*(){return new ln(r).viewers().map(t=>t.root)})}static isInteractivePLSRegression(t,e){return ln.isInteractive(t.columns,e)}static trainXGBooster(t,e,n,r,i,o,a){return Nr(this,void 0,void 0,function*(){const s=t.columns,u=new An;return yield u.fit(s,e,n,r,i,o,a),u.toBytes()})}static applyXGBooster(t,e){const n=new An(e);return i.DataFrame.fromColumns([n.predict(t.columns)])}static isInteractiveXGBooster(t,e){return An.isInteractive(t.columns,e)}static isApplicableXGBooster(t,e){return An.isApplicable(t.columns,e)}}Sr([t.decorators.func({name:"info"}),_r("design:type",Function),_r("design:paramtypes",[]),_r("design:returntype",void 0)],Lr,"info",null),Sr([t.decorators.init({}),_r("design:type",Function),_r("design:paramtypes",[]),_r("design:returntype",Promise)],Lr,"init",null),Sr([t.decorators.func({"top-menu":"ML | Cluster | DBSCAN...",name:"DBSCAN",description:"Density-based spatial clustering of applications with noise (DBSCAN)"}),Mr(1,t.decorators.param({type:"column",options:{type:"numerical"}})),Mr(2,t.decorators.param({type:"column",options:{type:"numerical"}})),Mr(3,t.decorators.param({options:{caption:"Epsilon",initialValue:"0.02",description:"The maximum distance between two samples for them to be considered as in the same neighborhood."}})),Mr(4,t.decorators.param({type:"int",options:{caption:"Minimum points",initialValue:"4",description:"The number of samples (or total weight) in a neighborhood for a point to be considered as a core point."}})),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column,i.Column,Number,Number]),_r("design:returntype",Promise)],Lr,"dbScan",null),Sr([t.decorators.func({"top-menu":"ML | Analyze | PCA...",description:"Principal component analysis (PCA)",helpUrl:"/help/explore/dim-reduction#pca"}),Mr(0,t.decorators.param({type:"dataframe",options:{caption:"Table"}})),Mr(1,t.decorators.param({type:"column_list",options:{type:"numerical",nullable:!1}})),Mr(2,t.decorators.param({type:"int",options:{showPlusMinus:!0,caption:"Components",nullable:!1,min:"1",initialValue:"2",description:"Number of components."}})),Mr(3,t.decorators.param({type:"bool",options:{caption:"Center",initialValue:"false",description:"Indicating whether the variables should be shifted to be zero centered."}})),Mr(4,t.decorators.param({type:"bool",options:{caption:"Scale",initialValue:"false",description:"Indicating whether the variables should be scaled to have unit variance."}})),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.ColumnList,Number,Boolean,Boolean]),_r("design:returntype",Promise)],Lr,"PCA",null),Sr([t.decorators.func({meta:{defaultPostProcessingFunction:"true"},tags:["dim-red-postprocessing-function"],name:"DBSCAN clustering"}),Mr(2,t.decorators.param({options:{initialValue:"0.01",description:"Minimum distance between two points to be considered as in the same neighborhood."}})),Mr(3,t.decorators.param({type:"int",options:{initialValue:"5",description:"Minimum number of points to form a dense region."}})),_r("design:type",Function),_r("design:paramtypes",[i.Column,i.Column,Number,Number]),_r("design:returntype",Promise)],Lr,"dbscanPostProcessingFunction",null),Sr([t.decorators.func({meta:{supportedTypes:"int,float,double,qnum",supportedDistanceFunctions:"Difference"},tags:["dim-red-preprocessing-function"],name:"None (number)",outputs:[{name:"result",type:"object"}]}),Mr(1,t.decorators.param({options:{optional:!0}})),_r("design:type",Function),_r("design:paramtypes",[i.Column,String]),_r("design:returntype",void 0)],Lr,"numberPreprocessingFunction",null),Sr([t.decorators.func({meta:{supportedTypes:"string",supportedDistanceFunctions:"One-Hot,Levenshtein,Hamming"},tags:["dim-red-preprocessing-function"],name:"None (string)",outputs:[{name:"result",type:"object"}]}),Mr(1,t.decorators.param({options:{optional:!0}})),_r("design:type",Function),_r("design:paramtypes",[i.Column,String]),_r("design:returntype",void 0)],Lr,"stringPreprocessingFunction",null),Sr([t.decorators.func({"top-menu":"ML | Reduce Dimensionality...",name:"Multi Column Dimensionality Reduction"}),_r("design:type",Function),_r("design:paramtypes",[]),_r("design:returntype",Promise)],Lr,"reduceDimensionality",null),Sr([t.decorators.editor(),_r("design:type",Function),_r("design:paramtypes",[i.FuncCall]),_r("design:returntype",void 0)],Lr,"GetMCLEditor",null),Sr([t.decorators.func({"top-menu":"ML | Cluster | MCL...",name:"MCLClustering",description:"Markov clustering (MCL) is an unsupervised clustering algorithm for graphs based on simulation of stochastic flow.",editor:"EDA:GetMCLEditor",outputs:[]}),Mr(2,t.decorators.param({type:"list<string>"})),Mr(4,t.decorators.param({type:"string"})),Mr(5,t.decorators.param({type:"list<func>"})),Mr(6,t.decorators.param({type:"object"})),Mr(7,t.decorators.param({type:"int",options:{initialValue:"80"}})),Mr(8,t.decorators.param({type:"int",options:{initialValue:"10"}})),Mr(9,t.decorators.param({type:"bool",options:{initialValue:"false"}})),Mr(10,t.decorators.param({type:"double",options:{initialValue:"2"}})),Mr(11,t.decorators.param({type:"int",options:{initialValue:"5"}})),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,Array,Array,Array,String,Array,Array,Number,Number,Boolean,Number,Number]),_r("design:returntype",Promise)],Lr,"MCLClustering",null),Sr([t.decorators.func({outputs:[{name:"result",type:"viewer"}],tags:["viewer"],meta:{showInGallery:"false"},name:"MCL",description:"Markov clustering viewer"}),_r("design:type",Function),_r("design:paramtypes",[]),_r("design:returntype",on)],Lr,"markovClusteringViewer",null),Sr([t.decorators.func({outputs:[{name:"plsResults",type:"object"}],description:"Compute partial least squares (PLS) regression analysis components: prediction, regression coefficients, T- & U-scores, X-loadings."}),Mr(1,t.decorators.param({type:"column_list",options:{type:"numerical"}})),Mr(2,t.decorators.param({type:"column",options:{type:"numerical"}})),Mr(3,t.decorators.param({type:"int",options:{initialValue:"3"}})),Mr(4,t.decorators.param({type:"column",options:{type:"string"}})),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.ColumnList,i.Column,Number,i.Column]),_r("design:returntype",Promise)],Lr,"PLS",null),Sr([t.decorators.func({"top-menu":"ML | Analyze | PLS...",description:"Compute partial least squares (PLS) regression components. They maximally summarize the variation of the predictors while maximizing correlation with the response variable."}),_r("design:type",Function),_r("design:paramtypes",[]),_r("design:returntype",Promise)],Lr,"topMenuPLS",null),Sr([t.decorators.func({"top-menu":"ML | Analyze | Multivariate Analysis...",name:"multivariateAnalysis",description:"Multidimensional data analysis using partial least squares (PLS) regression."}),_r("design:type",Function),_r("design:paramtypes",[]),_r("design:returntype",Promise)],Lr,"MVA",null),Sr([t.decorators.func({meta:{demoPath:"Compute | Multivariate Analysis"},name:"MVA demo",description:"Multidimensional data analysis using partial least squares (PLS) regression. It identifies latent factors and constructs a linear model based on them."}),_r("design:type",Function),_r("design:paramtypes",[]),_r("design:returntype",Promise)],Lr,"demoMultivariateAnalysis",null),Sr([t.decorators.func({meta:{mlname:"linear kernel LS-SVM",mlrole:"train"}}),Mr(2,t.decorators.param({options:{category:"Hyperparameters",initialValue:"1.0"}})),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column,Number]),_r("design:returntype",Promise)],Lr,"trainLinearKernelSVM",null),Sr([t.decorators.func({meta:{mlname:"linear kernel LS-SVM",mlrole:"apply"}}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,Object]),_r("design:returntype",Promise)],Lr,"applyLinearKernelSVM",null),Sr([t.decorators.func({meta:{mlname:"linear kernel LS-SVM",mlrole:"isApplicable"}}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column]),_r("design:returntype",Promise)],Lr,"isApplicableLinearKernelSVM",null),Sr([t.decorators.func({meta:{mlname:"linear kernel LS-SVM",mlrole:"isInteractive"}}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column]),_r("design:returntype",Promise)],Lr,"isInteractiveLinearKernelSVM",null),Sr([t.decorators.func({meta:{mlname:"linear kernel LS-SVM",mlrole:"visualize"}}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column,i.Column,Object]),_r("design:returntype",Promise)],Lr,"visualizeLinearKernelSVM",null),Sr([t.decorators.func({meta:{mlname:"RBF-kernel LS-SVM",mlrole:"train"}}),Mr(2,t.decorators.param({options:{category:"Hyperparameters",initialValue:"1.0"}})),Mr(3,t.decorators.param({options:{category:"Hyperparameters",initialValue:"1.5"}})),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column,Number,Number]),_r("design:returntype",Promise)],Lr,"trainRBFkernelSVM",null),Sr([t.decorators.func({meta:{mlname:"RBF-kernel LS-SVM",mlrole:"apply"}}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,Object]),_r("design:returntype",Promise)],Lr,"applyRBFkernelSVM",null),Sr([t.decorators.func({meta:{mlname:"RBF-kernel LS-SVM",mlrole:"isApplicable"}}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column]),_r("design:returntype",Promise)],Lr,"isApplicableRBFkernelSVM",null),Sr([t.decorators.func({meta:{mlname:"RBF-kernel LS-SVM",mlrole:"isInteractive"}}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column]),_r("design:returntype",Promise)],Lr,"isInteractiveRBFkernelSVM",null),Sr([t.decorators.func({meta:{mlname:"RBF-kernel LS-SVM",mlrole:"visualize"}}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column,i.Column,Object]),_r("design:returntype",Promise)],Lr,"visualizeRBFkernelSVM",null),Sr([t.decorators.func({meta:{mlname:"polynomial kernel LS-SVM",mlrole:"train"}}),Mr(2,t.decorators.param({options:{category:"Hyperparameters",initialValue:"1.0"}})),Mr(3,t.decorators.param({options:{category:"Hyperparameters",initialValue:"1"}})),Mr(4,t.decorators.param({options:{category:"Hyperparameters",initialValue:"2"}})),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column,Number,Number,Number]),_r("design:returntype",Promise)],Lr,"trainPolynomialKernelSVM",null),Sr([t.decorators.func({meta:{mlname:"polynomial kernel LS-SVM",mlrole:"apply"}}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,Object]),_r("design:returntype",Promise)],Lr,"applyPolynomialKernelSVM",null),Sr([t.decorators.func({meta:{mlname:"polynomial kernel LS-SVM",mlrole:"isApplicable"}}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column]),_r("design:returntype",Promise)],Lr,"isApplicablePolynomialKernelSVM",null),Sr([t.decorators.func({meta:{mlname:"polynomial kernel LS-SVM",mlrole:"isInteractive"}}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column]),_r("design:returntype",Promise)],Lr,"isInteractivePolynomialKernelSVM",null),Sr([t.decorators.func({meta:{mlname:"polynomial kernel LS-SVM",mlrole:"visualize"},outputs:[{name:"widget",type:"dynamic"}],name:"visualizePolynomialKernelSVM"}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column,i.Column,Object]),_r("design:returntype",Promise)],Lr,"visualizePolynomialKernelSVM",null),Sr([t.decorators.func({meta:{mlname:"sigmoid kernel LS-SVM",mlrole:"train"},name:"trainSigmoidKernelSVM"}),Mr(2,t.decorators.param({options:{category:"Hyperparameters",initialValue:"1.0"}})),Mr(3,t.decorators.param({options:{category:"Hyperparameters",initialValue:"1"}})),Mr(4,t.decorators.param({options:{category:"Hyperparameters",initialValue:"1"}})),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column,Number,Number,Number]),_r("design:returntype",Promise)],Lr,"trainSigmoidKernelSVM",null),Sr([t.decorators.func({meta:{mlname:"sigmoid kernel LS-SVM",mlrole:"apply"},name:"applySigmoidKernelSVM"}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,Object]),_r("design:returntype",Promise)],Lr,"applySigmoidKernelSVM",null),Sr([t.decorators.func({meta:{mlname:"sigmoid kernel LS-SVM",mlrole:"isApplicable"},name:"isApplicableSigmoidKernelSVM"}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column]),_r("design:returntype",Promise)],Lr,"isApplicableSigmoidKernelSVM",null),Sr([t.decorators.func({meta:{mlname:"sigmoid kernel LS-SVM",mlrole:"isInteractive"},name:"isInteractiveSigmoidKernelSVM"}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column]),_r("design:returntype",Promise)],Lr,"isInteractiveSigmoidKernelSVM",null),Sr([t.decorators.func({meta:{mlname:"sigmoid kernel LS-SVM",mlrole:"visualize"},name:"visualizeSigmoidKernelSVM"}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column,i.Column,Object]),_r("design:returntype",Promise)],Lr,"visualizeSigmoidKernelSVM",null),Sr([t.decorators.func({"top-menu":"ML | Analyze | ANOVA...",name:"ANOVA",description:"One-way analysis of variances (ANOVA) determines whether the examined factor has a significant impact on the explored feature."}),_r("design:type",Function),_r("design:paramtypes",[]),_r("design:returntype",void 0)],Lr,"anova",null),Sr([t.decorators.func({"top-menu":"ML | Impute Missing Values...",name:"KNN impute",description:"Missing values imputation using the k-nearest neighbors method (KNN)"}),_r("design:type",Function),_r("design:paramtypes",[]),_r("design:returntype",void 0)],Lr,"kNNImputation",null),Sr([t.decorators.func({name:"KNN imputation for a table",description:"Missing values imputation using the k-nearest neighbors method"}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame]),_r("design:returntype",Promise)],Lr,"kNNImputationForTable",null),Sr([t.decorators.func({meta:{mlname:"Linear Regression",mlrole:"train"},name:"trainLinearRegression",outputs:[{type:"dynamic",name:"model"}]}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column]),_r("design:returntype",Promise)],Lr,"trainLinearRegression",null),Sr([t.decorators.func({meta:{mlname:"Linear Regression",mlrole:"apply"},name:"applyLinearRegression"}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,Object]),_r("design:returntype",i.DataFrame)],Lr,"applyLinearRegression",null),Sr([t.decorators.func({meta:{mlname:"Linear Regression",mlrole:"isApplicable"},name:"isApplicableLinearRegression"}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column]),_r("design:returntype",Boolean)],Lr,"isApplicableLinearRegression",null),Sr([t.decorators.func({meta:{mlname:"Linear Regression",mlrole:"isInteractive"},name:"isInteractiveLinearRegression"}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column]),_r("design:returntype",Boolean)],Lr,"isInteractiveLinearRegression",null),Sr([t.decorators.func({meta:{mlname:"Softmax",mlrole:"train"},name:"trainSoftmax",outputs:[{type:"dynamic",name:"model"}]}),Mr(2,t.decorators.param({options:{category:"Hyperparameters",initialValue:"1.0",min:"0.001",max:"20",description:"Learning rate."}})),Mr(3,t.decorators.param({options:{category:"Hyperparameters",initialValue:"100",min:"1",max:"10000",step:"10",description:"Fitting iterations count"}})),Mr(4,t.decorators.param({options:{category:"Hyperparameters",initialValue:"0.1",min:"0.0001",max:"1",description:"Regularization rate."}})),Mr(5,t.decorators.param({options:{category:"Hyperparameters",initialValue:"0.001",min:"0.00001",max:"0.1",description:"Fitting tolerance."}})),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column,Number,Number,Number,Number]),_r("design:returntype",Promise)],Lr,"trainSoftmax",null),Sr([t.decorators.func({meta:{mlname:"Softmax",mlrole:"apply"},name:"applySoftmax"}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,Object]),_r("design:returntype",i.DataFrame)],Lr,"applySoftmax",null),Sr([t.decorators.func({meta:{mlname:"Softmax",mlrole:"isApplicable"},name:"isApplicableSoftmax"}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column]),_r("design:returntype",Boolean)],Lr,"isApplicableSoftmax",null),Sr([t.decorators.func({meta:{mlname:"Softmax",mlrole:"isInteractive"},name:"isInteractiveSoftmax"}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column]),_r("design:returntype",Boolean)],Lr,"isInteractiveSoftmax",null),Sr([t.decorators.func({meta:{mlname:"PLS Regression",mlrole:"train"},name:"trainPLSRegression",outputs:[{name:"model",type:"dynamic"}]}),Mr(2,t.decorators.param({type:"int",options:{min:"1",max:"10",initialValue:"3",description:"Number of latent components."}})),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column,Number]),_r("design:returntype",Promise)],Lr,"trainPLSRegression",null),Sr([t.decorators.func({meta:{mlname:"PLS Regression",mlrole:"apply"},name:"applyPLSRegression"}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,Object]),_r("design:returntype",i.DataFrame)],Lr,"applyPLSRegression",null),Sr([t.decorators.func({meta:{mlname:"PLS Regression",mlrole:"isApplicable"},name:"isApplicablePLSRegression"}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column]),_r("design:returntype",Boolean)],Lr,"isApplicablePLSRegression",null),Sr([t.decorators.func({meta:{mlname:"PLS Regression",mlrole:"visualize"},name:"visualizePLSRegression"}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column,i.Column,Object]),_r("design:returntype",Promise)],Lr,"visualizePLSRegression",null),Sr([t.decorators.func({meta:{mlname:"PLS Regression",mlrole:"isInteractive"},name:"isInteractivePLSRegression"}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column]),_r("design:returntype",Boolean)],Lr,"isInteractivePLSRegression",null),Sr([t.decorators.func({meta:{mlname:"XGBoost",mlrole:"train"},name:"trainXGBooster",outputs:[{name:"model",type:"dynamic"}]}),Mr(2,t.decorators.param({type:"int",options:{min:"1",max:"100",initialValue:"20",description:"Number of training iterations."}})),Mr(3,t.decorators.param({type:"double",options:{caption:"Rate",min:"0",max:"1",initialValue:"0.3",description:"Learning rate."}})),Mr(4,t.decorators.param({type:"int",options:{min:"0",max:"20",initialValue:"6",description:"Maximum depth of a tree."}})),Mr(5,t.decorators.param({type:"double",options:{min:"0",max:"100",initialValue:"1",description:"L2 regularization term."}})),Mr(6,t.decorators.param({type:"double",options:{min:"0",max:"100",initialValue:"0",description:"L1 regularization term."}})),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column,Number,Number,Number,Number,Number]),_r("design:returntype",Promise)],Lr,"trainXGBooster",null),Sr([t.decorators.func({meta:{mlname:"XGBoost",mlrole:"apply"},name:"applyXGBooster"}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,Object]),_r("design:returntype",i.DataFrame)],Lr,"applyXGBooster",null),Sr([t.decorators.func({meta:{mlname:"XGBoost",mlrole:"isInteractive"},name:"isInteractiveXGBooster"}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column]),_r("design:returntype",Boolean)],Lr,"isInteractiveXGBooster",null),Sr([t.decorators.func({meta:{mlname:"XGBoost",mlrole:"isApplicable"},name:"isApplicableXGBooster"}),_r("design:type",Function),_r("design:paramtypes",[i.DataFrame,i.Column]),_r("design:returntype",Boolean)],Lr,"isApplicableXGBooster",null)})(),eda=r})();
|
|
2
2
|
//# sourceMappingURL=package.js.map
|