@datagrok/eda 1.4.1 → 1.4.2

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/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 o(t,e,n){return o=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 o=[null];o.push.apply(o,e);var i=new(Function.bind.apply(t,o));return n&&r(i,n.prototype),i},o.apply(null,arguments)}function i(t){var e="function"==typeof Map?new Map:void 0;return i=function(t){if(null===t||(i=t,-1===Function.toString.call(i).indexOf("[native code]")))return t;var i;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 o(t,arguments,n(this).constructor)}return a.prototype=Object.create(t.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),r(a,t)},i(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 o=t._nodes.get(e),i=null;return o?i="mixed"===r?o.out&&o.out[n]||o.undirected&&o.undirected[n]:"directed"===r?o.out&&o.out[n]:o.undirected&&o.undirected[n]:i}function c(e){return"object"===t(e)&&null!==e}function l(t){var e;for(e in t)return!1;return!0}function h(t,e,n){Object.defineProperty(t,e,{enumerable:!1,configurable:!1,writable:!0,value:n})}function d(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 o(n){t.removeListener(e,i),r(n)}function i(){"function"==typeof t.removeListener&&t.removeListener("error",o),n([].slice.call(arguments))}T(t,e,i,{once:!0}),"error"!==e&&function(t,e){"function"==typeof t.on&&T(t,"error",e,{once:!0})}(t,o)}))},w.EventEmitter=w,w.prototype._events=void 0,w.prototype._eventsCount=0,w.prototype._maxListeners=void 0;var b=10;function E(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function A(t){return void 0===t._maxListeners?w.defaultMaxListeners:t._maxListeners}function C(t,e,n,r){var o,i,a,s;if(E(n),void 0===(i=t._events)?(i=t._events=Object.create(null),t._eventsCount=0):(void 0!==i.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),i=t._events),a=i[e]),void 0===a)a=i[e]=n,++t._eventsCount;else if("function"==typeof a?a=i[e]=r?[n,a]:[a,n]:r?a.unshift(n):a.push(n),(o=A(t))>0&&a.length>o&&!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 _(){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 S(t,e,n){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},o=_.bind(r);return o.listener=n,r.wrapFn=o,o}function N(t,e,n){var r=t._events;if(void 0===r)return[];var o=r[e];return void 0===o?[]:"function"==typeof o?n?[o.listener||o]:[o]: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}(o):M(o,o.length)}function I(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 M(t,e){for(var n=new Array(e),r=0;r<e;++r)n[r]=t[r];return n}function T(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 o(i){r.once&&t.removeEventListener(e,o),n(i)}))}}function O(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 A(this)},w.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++)e.push(arguments[n]);var r="error"===t,o=this._events;if(void 0!==o)r=r&&void 0===o.error;else if(!r)return!1;if(r){var i;if(e.length>0&&(i=e[0]),i instanceof Error)throw i;var a=new Error("Unhandled error."+(i?" ("+i.message+")":""));throw a.context=i,a}var s=o[t];if(void 0===s)return!1;if("function"==typeof s)y(s,this,e);else{var u=s.length,c=M(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 E(e),this.on(t,S(this,t,e)),this},w.prototype.prependOnceListener=function(t,e){return E(e),this.prependListener(t,S(this,t,e)),this},w.prototype.removeListener=function(t,e){var n,r,o,i,a;if(E(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(o=-1,i=n.length-1;i>=0;i--)if(n[i]===e||n[i].listener===e){a=n[i].listener,o=i;break}if(o<0)return this;0===o?n.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(n,o),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 o,i=Object.keys(n);for(r=0;r<i.length;++r)"removeListener"!==(o=i[r])&&this.removeAllListeners(o);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 N(this,t,!0)},w.prototype.rawListeners=function(t){return N(this,t,!1)},w.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):I.call(t,e)},w.prototype.listenerCount=I,w.prototype.eventNames=function(){return this._eventsCount>0?p(this._events):[]},"undefined"!=typeof Symbol&&(O.prototype[Symbol.iterator]=function(){return this}),O.of=function(){var t=arguments,e=t.length,n=0;return new O((function(){return n>=e?{done:!0}:{done:!1,value:t[n++]}}))},O.empty=function(){return new O((function(){return{done:!0}}))},O.fromSequence=function(t){var e=0,n=t.length;return new O((function(){return e>=n?{done:!0}:{done:!1,value:t[e++]}}))},O.is=function(t){return t instanceof O||"object"==typeof t&&null!==t&&"function"==typeof t.next};var L=O,P={};P.ARRAY_BUFFER_SUPPORT="undefined"!=typeof ArrayBuffer,P.SYMBOL_SUPPORT="undefined"!=typeof Symbol;var x=L,R=P,F=R.ARRAY_BUFFER_SUPPORT,D=R.SYMBOL_SUPPORT,U=function(t){var e=function(t){return"string"==typeof t||Array.isArray(t)||F&&ArrayBuffer.isView(t)?x.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},k=U,G=function(t,e){for(var n,r=arguments.length>1?e:1/0,o=r!==1/0?new Array(r):[],i=0,a=k(t);;){if(i===r)return o;if((n=a.next()).done)return i!==e&&(o.length=i),o;o[i++]=n.value}},B=function(t){function n(e){var n;return(n=t.call(this)||this).name="GraphError",n.message=e,n}return e(n,t),n}(i(Error)),V=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}(B),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}(B),H=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}(B);function j(t,e){this.key=t,this.attributes=e,this.clear()}function z(t,e){this.key=t,this.attributes=e,this.clear()}function q(t,e){this.key=t,this.attributes=e,this.clear()}function Y(t,e,n,r,o){this.key=e,this.attributes=o,this.undirected=t,this.source=n,this.target=r}function $(t,e,n,r,o,i,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=o,l=i}else if(3===n){if(o=""+o,!(u=t._edges.get(o)))throw new W("Graph.".concat(e,': could not find the "').concat(o,'" edge in the graph.'));var h=u.source.key,d=u.target.key;if(r===h)s=u.target;else{if(r!==d)throw new W("Graph.".concat(e,': the "').concat(r,'" node is not attached to the "').concat(o,'" edge (').concat(h,", ").concat(d,")."));s=u.source}c=i,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=o,l=i}return[s,c,l]}j.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}},z.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}},q.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}},Y.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)},Y.prototype.attachMulti=function(){var t="out",e="in",n=this.source.key,r=this.target.key;this.undirected&&(t=e="undirected");var o=this.source[t],i=o[r];if(void 0===i)return o[r]=this,void(this.undirected&&n===r||(this.target[e][n]=this));i.previous=this,this.next=i,o[r]=this,this.target[e][n]=this},Y.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]},Y.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 K=[{name:function(t){return"get".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,r,o){var i=$(this,e,n,t,r,o),a=i[0],s=i[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 $(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,o){var i=$(this,e,n,t,r,o),a=i[0],s=i[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,o,i){var a=$(this,e,n,t,r,o,i),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,o,i){var a=$(this,e,n,t,r,o,i),s=a[0],u=a[1],c=a[2];if("function"!=typeof c)throw new V("Graph.".concat(e,": updater should be a function."));var l=s.attributes,h=c(l[u]);return l[u]=h,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,o){var i=$(this,e,n,t,r,o),a=i[0],s=i[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,o){var i=$(this,e,n,t,r,o),a=i[0],s=i[1];if(!c(s))throw new V("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,o){var i=$(this,e,n,t,r,o),a=i[0],u=i[1];if(!c(u))throw new V("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,o){var i=$(this,e,n,t,r,o),a=i[0],s=i[1];if("function"!=typeof s)throw new V("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 o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new H("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new H("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,a=""+r;if(r=arguments[2],!(o=u(this,i,a,n)))throw new W("Graph.".concat(e,': could not find an edge for the given path ("').concat(i,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new H("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]}}},{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 H("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>1){if(this.multi)throw new H("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,i=""+arguments[1];if(!(r=u(this,o,i,n)))throw new W("Graph.".concat(e,': could not find an edge for the given path ("').concat(o,'" - "').concat(i,'").'))}else{if("mixed"!==n)throw new H("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 o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new H("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new H("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,a=""+r;if(r=arguments[2],!(o=u(this,i,a,n)))throw new W("Graph.".concat(e,': could not find an edge for the given path ("').concat(i,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new H("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.hasOwnProperty(r)}}},{name:function(t){return"set".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,r,o){var i;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new H("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>3){if(this.multi)throw new H("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],o=arguments[3],!(i=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 H("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]=o,this.emit("edgeAttributesUpdated",{key:i.key,type:"set",attributes:i.attributes,name:r}),this}}},{name:function(t){return"update".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,r,o){var i;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new H("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>3){if(this.multi)throw new H("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],o=arguments[3],!(i=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 H("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 o)throw new V("Graph.".concat(e,": updater should be a function."));return i.attributes[r]=o(i.attributes[r]),this.emit("edgeAttributesUpdated",{key:i.key,type:"set",attributes:i.attributes,name:r}),this}}},{name:function(t){return"remove".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,r){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new H("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new H("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,a=""+r;if(r=arguments[2],!(o=u(this,i,a,n)))throw new W("Graph.".concat(e,': could not find an edge for the given path ("').concat(i,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new H("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 delete o.attributes[r],this.emit("edgeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:r}),this}}},{name:function(t){return"replace".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,r){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new H("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new H("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,a=""+r;if(r=arguments[2],!(o=u(this,i,a,n)))throw new W("Graph.".concat(e,': could not find an edge for the given path ("').concat(i,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new H("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(!c(r))throw new V("Graph.".concat(e,": provided attributes are not a plain object."));return o.attributes=r,this.emit("edgeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}},{name:function(t){return"merge".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,r){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new H("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new H("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,a=""+r;if(r=arguments[2],!(o=u(this,i,a,n)))throw new W("Graph.".concat(e,': could not find an edge for the given path ("').concat(i,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new H("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(!c(r))throw new V("Graph.".concat(e,": provided attributes are not a plain object."));return s(o.attributes,r),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:r}),this}}},{name:function(t){return"update".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,r){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new H("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new H("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,a=""+r;if(r=arguments[2],!(o=u(this,i,a,n)))throw new W("Graph.".concat(e,': could not find an edge for the given path ("').concat(i,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new H("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 r)throw new V("Graph.".concat(e,": provided updater is not a function."));return o.attributes=r(o.attributes),this.emit("edgeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}}],J=L,Q=U,Z=function(){var t=arguments,e=null,n=-1;return new J((function(){for(var r=null;;){if(null===e){if(++n>=t.length)return{done:!0};e=Q(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 o=!1;for(var i in e)if(i!==r){var a=e[i];if(o=n(a.key,a.attributes,a.source.key,a.target.key,a.source.attributes,a.target.attributes,a.undirected),t&&o)return a.key}}function nt(t,e,n,r){var o,i,a,s=!1;for(var u in e)if(u!==r){o=e[u];do{if(i=o.source,a=o.target,s=n(o.key,o.attributes,i.key,a.key,i.attributes,a.attributes,o.undirected),t&&s)return o.key;o=o.next}while(void 0!==o)}}function rt(t,e){var n,r=Object.keys(t),o=r.length,i=0;return new L((function(){do{if(n)n=n.next;else{if(i>=o)return{done:!0};var a=r[i++];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 ot(t,e,n,r){var o=e[n];if(o){var i=o.source,a=o.target;return r(o.key,o.attributes,i.key,a.key,i.attributes,a.attributes,o.undirected)&&t?o.key:void 0}}function it(t,e,n,r){var o=e[n];if(o){var i=!1;do{if(i=r(o.key,o.attributes,o.source.key,o.target.key,o.source.attributes,o.target.attributes,o.undirected),t&&i)return o.key;o=o.next}while(void 0!==o)}}function at(t,e){var n=t[e];return void 0!==n.next?new L((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}})):L.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 o,i,a="mixed"!==n&&n!==e.type,s="undirected"===n,u=!1,c=e._edges.values();!0!==(o=c.next()).done;)if(i=o.value,!a||i.undirected===s){var l=i,h=l.key,d=l.attributes,f=l.source,p=l.target;if(u=r(h,d,f.key,p.key,f.attributes,p.attributes,i.undirected),t&&u)return h}}function ut(t,e,n,r,o,i){var a,s=e?nt:et;if("undirected"!==n){if("out"!==r&&(a=s(t,o.in,i),t&&a))return a;if("in"!==r&&(a=s(t,o.out,i,r?void 0:o.key),t&&a))return a}if("directed"!==n&&(a=s(t,o.undirected,i),t&&a))return a}function ct(t,e,n,r,o,i,a){var s,u=n?it:ot;if("undirected"!==e){if(void 0!==o.in&&"out"!==r&&(s=u(t,o.in,i,a),t&&s))return s;if(void 0!==o.out&&"in"!==r&&(r||o.key!==i)&&(s=u(t,o.out,i,a),t&&s))return s}if("directed"!==e&&void 0!==o.undirected&&(s=u(t,o.undirected,i,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 ht(){this.A=null,this.B=null}function dt(t,e,n,r,o){for(var i in r){var a=r[i],s=a.source,u=a.target,c=s===n?u:s;if(!e||!e.has(c.key)){var l=o(c.key,c.attributes);if(t&&l)return c.key}}}function ft(t,e,n,r,o){if("mixed"!==e){if("undirected"===e)return dt(t,null,r,r.undirected,o);if("string"==typeof n)return dt(t,null,r,r[n],o)}var i,a=new ht;if("undirected"!==e){if("out"!==n){if(i=dt(t,null,r,r.in,o),t&&i)return i;a.wrap(r.in)}if("in"!==n){if(i=dt(t,a,r,r.out,o),t&&i)return i;a.wrap(r.out)}}if("directed"!==e&&(i=dt(t,a,r,r.undirected,o),t&&i))return i}function pt(t,e,n){var r=Object.keys(n),o=r.length,i=0;return new L((function(){var a=null;do{if(i>=o)return t&&t.wrap(n),{done:!0};var s=n[r[i++]],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,o){for(var i,a,s,u,c,l,h,d=r._nodes.values(),f=r.type;!0!==(i=d.next()).done;){var p=!1;if(a=i.value,"undirected"!==f)for(s in u=a.out){c=u[s];do{if(l=c.target,p=!0,h=o(a.key,l.key,a.attributes,l.attributes,c.key,c.attributes,c.undirected),t&&h)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,h=o(a.key,l.key,a.attributes,l.attributes,c.key,c.attributes,c.undirected),t&&h)return c;c=c.next}while(c)}if(n&&!p&&(h=o(a.key,null,a.attributes,null,null,null,null),t&&h))return null}}function gt(t){if(!c(t))throw new V('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 V("Graph.import: serialized node is missing its key.");if("attributes"in t&&(!c(t.attributes)||null===t.attributes))throw new V("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function yt(t){if(!c(t))throw new V('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 V("Graph.import: serialized edge is missing its source.");if(!("target"in t))throw new V("Graph.import: serialized edge is missing its target.");if("attributes"in t&&(!c(t.attributes)||null===t.attributes))throw new V("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in t&&"boolean"!=typeof t.undirected)throw new V("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}ht.prototype.wrap=function(t){null===this.A?this.A=t:null===this.B&&(this.B=t)},ht.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"]),Et=new Set(["domain","_events","_eventsCount","_maxListeners"]),At={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 _t(t,e,n,r,o,i,a,s){if(!r&&"undirected"===t.type)throw new H("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 H("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 V("Graph.".concat(e,': invalid attributes. Expecting an object but got "').concat(s,'"'));if(i=""+i,a=""+a,s=s||{},!t.allowSelfLoops&&i===a)throw new H("Graph.".concat(e,': source & target are the same ("').concat(i,"\"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false."));var u=t._nodes.get(i),l=t._nodes.get(a);if(!u)throw new W("Graph.".concat(e,': source node "').concat(i,'" not found.'));if(!l)throw new W("Graph.".concat(e,': target node "').concat(a,'" not found.'));var h={key:null,undirected:r,source:i,target:a,attributes:s};if(n)o=t._edgeKeyGenerator();else if(o=""+o,t._edges.has(o))throw new H("Graph.".concat(e,': the "').concat(o,'" edge already exists in the graph.'));if(!t.multi&&(r?void 0!==u.undirected[a]:void 0!==u.out[a]))throw new H("Graph.".concat(e,': an edge linking "').concat(i,'" 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 d=new Y(r,o,u,l,s);t._edges.set(o,d);var f=i===a;return r?(u.undirectedDegree++,l.undirectedDegree++,f&&(u.undirectedLoops++,t._undirectedSelfLoopCount++)):(u.outDegree++,l.inDegree++,f&&(u.directedLoops++,t._directedSelfLoopCount++)),t.multi?d.attachMulti():d.attach(),r?t._undirectedSize++:t._directedSize++,h.key=o,t.emit("edgeAdded",h),o}function St(t,e,n,r,o,i,a,u,l){if(!r&&"undirected"===t.type)throw new H("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 H("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 V("Graph.".concat(e,': invalid updater function. Expecting a function but got "').concat(u,'"'))}else if(!c(u))throw new V("Graph.".concat(e,': invalid attributes. Expecting an object but got "').concat(u,'"'));var h;if(i=""+i,a=""+a,l&&(h=u,u=void 0),!t.allowSelfLoops&&i===a)throw new H("Graph.".concat(e,': source & target are the same ("').concat(i,"\"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false."));var d,f,p=t._nodes.get(i),m=t._nodes.get(a);if(!n&&(d=t._edges.get(o))){if(!(d.source.key===i&&d.target.key===a||r&&d.source.key===a&&d.target.key===i))throw new H("Graph.".concat(e,': inconsistency detected when attempting to merge the "').concat(o,'" edge with "').concat(i,'" source & "').concat(a,'" target vs. ("').concat(d.source.key,'", "').concat(d.target.key,'").'));f=d}if(f||t.multi||!p||(f=r?p.undirected[a]:p.out[a]),f){var g=[f.key,!1,!1,!1];if(l?!h:!u)return g;if(l){var y=f.attributes;f.attributes=h(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&&h&&(u=h(u));var v={key:null,undirected:r,source:i,target:a,attributes:u};if(n)o=t._edgeKeyGenerator();else if(o=""+o,t._edges.has(o))throw new H("Graph.".concat(e,': the "').concat(o,'" edge already exists in the graph.'));var w=!1,b=!1;p||(p=Ct(t,i,{}),w=!0,i===a&&(m=p,b=!0)),m||(m=Ct(t,a,{}),b=!0),d=new Y(r,o,p,m,u),t._edges.set(o,d);var E=i===a;return r?(p.undirectedDegree++,m.undirectedDegree++,E&&(p.undirectedLoops++,t._undirectedSelfLoopCount++)):(p.outDegree++,m.inDegree++,E&&(p.directedLoops++,t._directedSelfLoopCount++)),t.multi?d.attachMulti():d.attach(),r?t._undirectedSize++:t._directedSize++,v.key=o,t.emit("edgeAdded",v),[o,!0,w,b]}function Nt(t,e){t._edges.delete(e.key);var n=e.source,r=e.target,o=e.attributes,i=e.undirected,a=n===r;i?(n.undirectedDegree--,r.undirectedDegree--,a&&(n.undirectedLoops--,t._undirectedSelfLoopCount--)):(n.outDegree--,r.inDegree--,a&&(n.directedLoops--,t._directedSelfLoopCount--)),t.multi?e.detachMulti():e.detach(),i?t._undirectedSize--:t._directedSize--,t.emit("edgeDropped",{key:e.key,attributes:o,source:n.key,target:r.key,undirected:i})}var It=function(n){function r(t){var e;if(e=n.call(this)||this,"boolean"!=typeof(t=s({},At,t)).multi)throw new V("Graph.constructor: invalid 'multi' option. Expecting a boolean but got \"".concat(t.multi,'".'));if(!bt.has(t.type))throw new V('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 V("Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got \"".concat(t.allowSelfLoops,'".'));var r="mixed"===t.type?j:"directed"===t.type?z:q;h(a(e),"NodeDataClass",r);var o="geid_"+wt()+"_",i=0;return h(a(e),"_attributes",{}),h(a(e),"_nodes",new Map),h(a(e),"_edges",new Map),h(a(e),"_directedSize",0),h(a(e),"_undirectedSize",0),h(a(e),"_directedSelfLoopCount",0),h(a(e),"_undirectedSelfLoopCount",0),h(a(e),"_edgeKeyGenerator",(function(){var t;do{t=o+i++}while(e._edges.has(t));return t})),h(a(e),"_options",t),Et.forEach((function(t){return h(a(e),t,e[t])})),d(a(e),"order",(function(){return e._nodes.size})),d(a(e),"size",(function(){return e._edges.size})),d(a(e),"directedSize",(function(){return e._directedSize})),d(a(e),"undirectedSize",(function(){return e._undirectedSize})),d(a(e),"selfLoopCount",(function(){return e._directedSelfLoopCount+e._undirectedSelfLoopCount})),d(a(e),"directedSelfLoopCount",(function(){return e._directedSelfLoopCount})),d(a(e),"undirectedSelfLoopCount",(function(){return e._undirectedSelfLoopCount})),d(a(e),"multi",e._options.multi),d(a(e),"type",e._options.type),d(a(e),"allowSelfLoops",e._options.allowSelfLoops),d(a(e),"implementation",(function(){return"graphology"})),e}e(r,n);var o=r.prototype;return o._resetInstanceCounters=function(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0},o.hasNode=function(t){return this._nodes.has(""+t)},o.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 o=this._nodes.get(t);return!!o&&o.out.hasOwnProperty(e)}throw new V("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."))},o.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 o=this._nodes.get(t);return!!o&&o.undirected.hasOwnProperty(e)}throw new V("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."))},o.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 V("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."))},o.directedEdge=function(t,e){if("undirected"!==this.type){if(t=""+t,e=""+e,this.multi)throw new H("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}},o.undirectedEdge=function(t,e){if("directed"!==this.type){if(t=""+t,e=""+e,this.multi)throw new H("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}},o.edge=function(t,e){if(this.multi)throw new H("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},o.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)},o.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},o.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},o.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},o.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},o.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},o.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},o.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},o.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},o.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},o.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},o.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},o.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},o.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},o.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},o.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},o.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},o.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},o.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},o.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},o.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},o.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},o.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},o.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]},o.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,o=n.target.key;if(t===r)return o;if(t===o)return r;throw new W('Graph.opposite: the "'.concat(t,'" node is not attached to the "').concat(e,'" edge (').concat(r,", ").concat(o,")."))},o.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},o.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},o.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},o.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},o.addNode=function(t,e){var n=function(t,e,n){if(n&&!c(n))throw new V('Graph.addNode: invalid attributes. Expecting an object but got "'.concat(n,'"'));if(e=""+e,n=n||{},t._nodes.has(e))throw new H('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},o.mergeNode=function(t,e){if(e&&!c(e))throw new V('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])},o.updateNode=function(t,e){if(e&&"function"!=typeof e)throw new V('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 o=e?e({}):{};return n=new this.NodeDataClass(t,o),this._nodes.set(t,n),this.emit("nodeAdded",{key:t,attributes:o}),[t,!0]},o.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{Nt(this,e),e=e.next}while(e)}for(var o in n.in){e=n.in[o];do{Nt(this,e),e=e.next}while(e)}}if("directed"!==this.type)for(var i in n.undirected){e=n.undirected[i];do{Nt(this,e),e=e.next}while(e)}this._nodes.delete(t),this.emit("nodeDropped",{key:t,attributes:n.attributes})},o.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 Nt(this,e),this},o.dropDirectedEdge=function(t,e){if(arguments.length<2)throw new H("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 H("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 Nt(this,n),this},o.dropUndirectedEdge=function(t,e){if(arguments.length<2)throw new H("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 H("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 Nt(this,n),this},o.clear=function(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")},o.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")},o.getAttribute=function(t){return this._attributes[t]},o.getAttributes=function(){return this._attributes},o.hasAttribute=function(t){return this._attributes.hasOwnProperty(t)},o.setAttribute=function(t,e){return this._attributes[t]=e,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:t}),this},o.updateAttribute=function(t,e){if("function"!=typeof e)throw new V("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},o.removeAttribute=function(t){return delete this._attributes[t],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:t}),this},o.replaceAttributes=function(t){if(!c(t))throw new V("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=t,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this},o.mergeAttributes=function(t){if(!c(t))throw new V("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},o.updateAttributes=function(t){if("function"!=typeof t)throw new V("Graph.updateAttributes: provided updater is not a function.");return this._attributes=t(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this},o.updateEachNodeAttributes=function(t,e){if("function"!=typeof t)throw new V("Graph.updateEachNodeAttributes: expecting an updater function.");if(e&&!f(e))throw new V("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");for(var n,r,o=this._nodes.values();!0!==(n=o.next()).done;)(r=n.value).attributes=t(r.key,r.attributes);this.emit("eachNodeAttributesUpdated",{hints:e||null})},o.updateEachEdgeAttributes=function(t,e){if("function"!=typeof t)throw new V("Graph.updateEachEdgeAttributes: expecting an updater function.");if(e&&!f(e))throw new V("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");for(var n,r,o,i,a=this._edges.values();!0!==(n=a.next()).done;)o=(r=n.value).source,i=r.target,r.attributes=t(r.key,r.attributes,o.key,i.key,o.attributes,i.attributes,r.undirected);this.emit("eachEdgeAttributesUpdated",{hints:e||null})},o.forEachAdjacencyEntry=function(t){if("function"!=typeof t)throw new V("Graph.forEachAdjacencyEntry: expecting a callback.");mt(!1,!1,!1,this,t)},o.forEachAdjacencyEntryWithOrphans=function(t){if("function"!=typeof t)throw new V("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");mt(!1,!1,!0,this,t)},o.forEachAssymetricAdjacencyEntry=function(t){if("function"!=typeof t)throw new V("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");mt(!1,!0,!1,this,t)},o.forEachAssymetricAdjacencyEntryWithOrphans=function(t){if("function"!=typeof t)throw new V("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");mt(!1,!0,!0,this,t)},o.nodes=function(){return"function"==typeof Array.from?Array.from(this._nodes.keys()):G(this._nodes.keys(),this._nodes.size)},o.forEachNode=function(t){if("function"!=typeof t)throw new V("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)},o.findNode=function(t){if("function"!=typeof t)throw new V("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},o.mapNodes=function(t){if("function"!=typeof t)throw new V("Graph.mapNode: expecting a callback.");for(var e,n,r=this._nodes.values(),o=new Array(this.order),i=0;!0!==(e=r.next()).done;)n=e.value,o[i++]=t(n.key,n.attributes);return o},o.someNode=function(t){if("function"!=typeof t)throw new V("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},o.everyNode=function(t){if("function"!=typeof t)throw new V("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},o.filterNodes=function(t){if("function"!=typeof t)throw new V("Graph.filterNodes: expecting a callback.");for(var e,n,r=this._nodes.values(),o=[];!0!==(e=r.next()).done;)t((n=e.value).key,n.attributes)&&o.push(n.key);return o},o.reduceNodes=function(t,e){if("function"!=typeof t)throw new V("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new V("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,o=e,i=this._nodes.values();!0!==(n=i.next()).done;)o=t(o,(r=n.value).key,r.attributes);return o},o.nodeEntries=function(){var t=this._nodes.values();return new L((function(){var e=t.next();if(e.done)return e;var n=e.value;return{value:{node:n.key,attributes:n.attributes},done:!1}}))},o.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,o){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,o,e)})),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:e,edges:r}},o.import=function(t){var e,n,o,i,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,o,i,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 V("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(t.attributes){if(!c(t.attributes))throw new V("Graph.import: invalid attributes. Expecting a plain object.");u?this.mergeAttributes(t.attributes):this.replaceAttributes(t.attributes)}if(t.nodes){if(o=t.nodes,!Array.isArray(o))throw new V("Graph.import: invalid nodes. Expecting an array.");for(e=0,n=o.length;e<n;e++){gt(i=o[e]);var l=i,h=l.key,d=l.attributes;u?this.mergeNode(h,d):this.addNode(h,d)}}if(t.edges){var f=!1;if("undirected"===this.type&&(f=!0),o=t.edges,!Array.isArray(o))throw new V("Graph.import: invalid edges. Expecting an array.");for(e=0,n=o.length;e<n;e++){yt(a=o[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},o.nullCopy=function(t){var e=new r(s({},this._options,t));return e.replaceAttributes(s({},this.getAttributes())),e},o.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},o.copy=function(t){if("string"==typeof(t=t||{}).type&&t.type!==this.type&&"mixed"!==t.type)throw new H('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 H("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 H("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),o=this._edges.values();!0!==(e=o.next()).done;)_t(r,"copy",!1,(n=e.value).undirected,n.key,n.source.key,n.target.key,s({},n.attributes));return r},o.toJSON=function(){return this.export()},o.toString=function(){return"[object Graph]"},o.inspect=function(){var e=this,n={};this._nodes.forEach((function(t,e){n[e]=t.attributes}));var r={},o={};this._edges.forEach((function(t,n){var i,a=t.undirected?"--":"->",s="",u=t.source.key,c=t.target.key;t.undirected&&u>c&&(i=u,u=c,c=i);var l="(".concat(u,")").concat(a,"(").concat(c,")");n.startsWith("geid_")?e.multi&&(void 0===o[l]?o[l]=0:o[l]++,s+="".concat(o[l],". ")):s+="[".concat(n,"]: "),r[s+=l]=t.attributes}));var i={};for(var a in this)this.hasOwnProperty(a)&&!Et.has(a)&&"function"!=typeof this[a]&&"symbol"!==t(a)&&(i[a]=this[a]);return i.attributes=this._attributes,i.nodes=n,i.edges=r,h(i,"constructor",this.constructor),i},r}(m.exports.EventEmitter);"undefined"!=typeof Symbol&&(It.prototype[Symbol.for("nodejs.util.inspect.custom")]=It.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?_t:St;t.generateKey?It.prototype[n]=function(o,i,a){return r(this,n,!0,"undirected"===(t.type||this.type),null,o,i,a,"update"===e)}:It.prototype[n]=function(o,i,a,s){return r(this,n,!1,"undirected"===(t.type||this.type),o,i,a,s,"update"===e)}}))})),function(t){K.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)}))}(It),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")}))}(It),function(t){tt.forEach((function(e){!function(t,e){var n=e.name,r=e.type,o=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,o="undirected"===e?t.undirectedSize:t.directedSize,i=new Array(o),a="undirected"===e,s=t._edges.values(),u=0;!0!==(n=s.next()).done;)(r=n.value).undirected===a&&(i[u++]=r.key);return i}(this,r);if(1===arguments.length){t=""+t;var i=this._nodes.get(t);if(void 0===i)throw new W("Graph.".concat(n,': could not find the "').concat(t,'" node in the graph.'));return function(t,e,n,r){var o=[];return ut(!1,t,e,n,r,(function(t){o.push(t)})),o}(this.multi,"mixed"===r?this.type:r,o,i)}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,o){var i=[];return ct(!1,t,e,n,r,o,(function(t){i.push(t)})),i}(r,this.multi,o,a,e)}throw new V("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,o=e.direction,i="forEach"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[i]=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(i,': could not find the "').concat(t,'" node in the graph.'));return ut(!1,this.multi,"mixed"===r?this.type:r,o,a,n)}if(3===arguments.length){t=""+t,e=""+e;var s=this._nodes.get(t);if(!s)throw new W("Graph.".concat(i,': could not find the "').concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new W("Graph.".concat(i,': could not find the "').concat(e,'" target node in the graph.'));return ct(!1,r,this.multi,o,s,e,n)}throw new V("Graph.".concat(i,": 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 o=0;"directed"!==r&&(o+=this.undirectedSize),"undirected"!==r&&(o+=this.directedSize),t=new Array(o);var a=0;e.push((function(e,r,o,i,s,u,c){t[a++]=n(e,r,o,i,s,u,c)}))}else t=[],e.push((function(e,r,o,i,a,s,u){t.push(n(e,r,o,i,a,s,u))}));return this[i].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,o,i,a,s,u){e(t,r,o,i,a,s,u)&&n.push(t)})),this[i].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 V("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 V("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,o,i,a,s,u){r=t(r,e,n,o,i,a,s,u)})),this[i].apply(this,n),r}}(t,e),function(t,e){var n=e.name,r=e.type,o=e.direction,i="find"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[i]=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(i,': could not find the "').concat(t,'" node in the graph.'));return ut(!0,this.multi,"mixed"===r?this.type:r,o,a,n)}if(3===arguments.length){t=""+t,e=""+e;var s=this._nodes.get(t);if(!s)throw new W("Graph.".concat(i,': could not find the "').concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new W("Graph.".concat(i,': could not find the "').concat(e,'" target node in the graph.'));return ct(!0,r,this.multi,o,s,e,n)}throw new V("Graph.".concat(i,": 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,o,i,a,s){return e(t,n,r,o,i,a,s)})),!!this[i].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,o,i,a,s){return!e(t,n,r,o,i,a,s)})),!this[i].apply(this,t)}}(t,e),function(t,e){var n=e.name,r=e.type,o=e.direction,i=n.slice(0,-1)+"Entries";t.prototype[i]=function(t,e){if("mixed"!==r&&"mixed"!==this.type&&r!==this.type)return L.empty();if(!arguments.length)return function(t,e){if(0===t.size)return L.empty();var n="mixed"!==e&&e!==t.type,r="undirected"===e,o=t._edges.values();return new L((function(){for(var t,e;;){if((t=o.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(i,': could not find the "').concat(t,'" node in the graph.'));return function(t,e,n){var r=L.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,o,n)}if(2===arguments.length){t=""+t,e=""+e;var a=this._nodes.get(t);if(!a)throw new W("Graph.".concat(i,': could not find the "').concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new W("Graph.".concat(i,': could not find the "').concat(e,'" target node in the graph.'));return function(t,e,n,r){var o=L.empty();return"undirected"!==t&&(void 0!==n.in&&"out"!==e&&r in n.in&&(o=Z(o,at(n.in,r))),void 0!==n.out&&"in"!==e&&r in n.out&&(e||n.key!==r)&&(o=Z(o,at(n.out,r)))),"directed"!==t&&void 0!==n.undirected&&r in n.undirected&&(o=Z(o,at(n.undirected,r))),o}(r,o,a,e)}throw new V("Graph.".concat(i,": too many arguments (expecting 0, 1 or 2 and got ").concat(arguments.length,")."))}}(t,e)}))}(It),function(t){lt.forEach((function(e){(function(t,e){var n=e.name,r=e.type,o=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,o,e)}})(t,e),function(t,e){var n=e.name,r=e.type,o=e.direction,i="forEach"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[i]=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(i,': could not find the "').concat(t,'" node in the graph.'));ft(!1,"mixed"===r?this.type:r,o,n,e)}};var a="map"+n[0].toUpperCase()+n.slice(1);t.prototype[a]=function(t,e){var n=[];return this[i](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[i](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 V("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[i](t,(function(t,n){r=e(r,t,n)})),r}}(t,e),function(t,e){var n=e.name,r=e.type,o=e.direction,i=n[0].toUpperCase()+n.slice(1,-1),a="find"+i;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,o,n,e)}};var s="some"+i;t.prototype[s]=function(t,e){return!!this[a](t,e)};var u="every"+i;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,o=e.direction,i=n.slice(0,-1)+"Entries";t.prototype[i]=function(t){if("mixed"!==r&&"mixed"!==this.type&&r!==this.type)return L.empty();t=""+t;var e=this._nodes.get(t);if(void 0===e)throw new W("Graph.".concat(i,': 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=L.empty(),o=new ht;return"undirected"!==t&&("out"!==e&&(r=Z(r,pt(o,n,n.in))),"in"!==e&&(r=Z(r,pt(o,n,n.out)))),"directed"!==t&&(r=Z(r,pt(o,n,n.undirected))),r}("mixed"===r?this.type:r,o,e)}}(t,e)}))}(It);var Mt=function(t){function n(e){var n=s({type:"directed"},e);if("multi"in n&&!1!==n.multi)throw new V("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if("directed"!==n.type)throw new V('DirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return t.call(this,n)||this}return e(n,t),n}(It),Tt=function(t){function n(e){var n=s({type:"undirected"},e);if("multi"in n&&!1!==n.multi)throw new V("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if("undirected"!==n.type)throw new V('UndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return t.call(this,n)||this}return e(n,t),n}(It),Ot=function(t){function n(e){var n=s({multi:!0},e);if("multi"in n&&!0!==n.multi)throw new V("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");return t.call(this,n)||this}return e(n,t),n}(It),Lt=function(t){function n(e){var n=s({type:"directed",multi:!0},e);if("multi"in n&&!0!==n.multi)throw new V("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if("directed"!==n.type)throw new V('MultiDirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return t.call(this,n)||this}return e(n,t),n}(It),Pt=function(t){function n(e){var n=s({type:"undirected",multi:!0},e);if("multi"in n&&!0!==n.multi)throw new V("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if("undirected"!==n.type)throw new V('MultiUndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return t.call(this,n)||this}return e(n,t),n}(It);function xt(t){t.from=function(e,n){var r=s({},e.options,n),o=new t(r);return o.import(e),o}}return xt(It),xt(Mt),xt(Tt),xt(Ot),xt(Lt),xt(Pt),It.Graph=It,It.DirectedGraph=Mt,It.UndirectedGraph=Tt,It.MultiGraph=Ot,It.MultiDirectedGraph=Lt,It.MultiUndirectedGraph=Pt,It.InvalidArgumentsGraphError=V,It.NotFoundGraphError=W,It.UsageGraphError=H,It}()},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,o=t.length,i=e.length,a=Math.floor(Math.max(o,i)/2)-1,s=new Array(o),u=new Array(i),c=0;c<o;c++)for(var l=Math.max(0,c-a);l<=Math.min(i,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 h=0,d=0;for(c=0;c<o;c++)if(s[c]){for(;!u[d];)d++;t.charAt(c)!==e.charAt(d++)&&h++}return(r/o+r/i+(r-(h/=2))/r)/3}(t,e,n),o=0;if(r>.7){for(var i=Math.min(t.length,e.length),a=0;t[a]===e[a]&&a<4&&a<i;)++o,a++;r+=.1*o*(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)))),o="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(r),i="/*# ".concat(o," */");return[e].concat([i]).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,o=Array.prototype.slice.call(arguments).slice(1);for(e=0,r=o.length;e<r;e++)if(o[e])for(n in o[e])t[n]=o[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,o=t.size,i={},a=new Float32Array(10*r),s=new Float32Array(3*o);return n=0,t.forEachNode((function(t,e){i[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,o,u,c,l,h){var d=i[o],f=i[u],p=e(t,r,o,u,c,l,h);a[d+6]+=p,a[f+6]+=p,s[n]=d,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,o){return o.x=e[r],o.y=e[r+1],r+=10,n?n(t,o):o}))},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(),o={},i=0,a=0,s=e.length;i<s;i+=10){if(n){var u=Object.assign({},t.getNodeAttributes(r[a]));u.x=e[i],u.y=e[i+1],u=n(r[a],u),o[r[a]]={x:u.x,y:u.y}}else o[r[a]]={x:e[i],y:e[i+1]};a++}return o},e.createWorker=function(t){var e=window.URL||window.webkitURL,n=t.toString(),r=e.createObjectURL(new Blob(["("+n+").call(this);"],{type:"text/javascript"})),o=new Worker(r);return e.revokeObjectURL(r),o}},2561:t=>{var e=10;t.exports=function(t,n,r){var o,i,a,s,u,c,l,h,d,f,p,m,g,y,v,w,b,E,A,C,_,S,N,I=n.length,M=r.length,T=t.adjustSizes,O=t.barnesHutTheta*t.barnesHutTheta,L=[];for(a=0;a<I;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<I;a+=e)p+=n[a+6];p/=I/e}if(t.barnesHutOptimize){var P,x,R,F=1/0,D=-1/0,U=1/0,k=-1/0;for(a=0;a<I;a+=e)F=Math.min(F,n[a+0]),D=Math.max(D,n[a+0]),U=Math.min(U,n[a+1]),k=Math.max(k,n[a+1]);var G=D-F,B=k-U;for(G>B?k=(U-=(G-B)/2)+G:D=(F-=(B-G)/2)+B,L[0]=-1,L[1]=(F+D)/2,L[2]=(U+k)/2,L[3]=Math.max(D-F,k-U),L[4]=-1,L[5]=-1,L[6]=0,L[7]=0,L[8]=0,o=1,a=0;a<I;a+=e)for(i=0,R=3;;){if(!(L[i+5]>=0)){if(L[i+0]<0){L[i+0]=a;break}if(L[i+5]=9*o,h=L[i+3]/2,L[(d=L[i+5])+0]=-1,L[d+1]=L[i+1]-h,L[d+2]=L[i+2]-h,L[d+3]=h,L[d+4]=d+9,L[d+5]=-1,L[d+6]=0,L[d+7]=0,L[d+8]=0,L[(d+=9)+0]=-1,L[d+1]=L[i+1]-h,L[d+2]=L[i+2]+h,L[d+3]=h,L[d+4]=d+9,L[d+5]=-1,L[d+6]=0,L[d+7]=0,L[d+8]=0,L[(d+=9)+0]=-1,L[d+1]=L[i+1]+h,L[d+2]=L[i+2]-h,L[d+3]=h,L[d+4]=d+9,L[d+5]=-1,L[d+6]=0,L[d+7]=0,L[d+8]=0,L[(d+=9)+0]=-1,L[d+1]=L[i+1]+h,L[d+2]=L[i+2]+h,L[d+3]=h,L[d+4]=L[i+4],L[d+5]=-1,L[d+6]=0,L[d+7]=0,L[d+8]=0,o+=4,P=n[L[i+0]+0]<L[i+1]?n[L[i+0]+1]<L[i+2]?L[i+5]:L[i+5]+9:n[L[i+0]+1]<L[i+2]?L[i+5]+18:L[i+5]+27,L[i+6]=n[L[i+0]+6],L[i+7]=n[L[i+0]+0],L[i+8]=n[L[i+0]+1],L[P+0]=L[i+0],L[i+0]=-1,P===(x=n[a+0]<L[i+1]?n[a+1]<L[i+2]?L[i+5]:L[i+5]+9:n[a+1]<L[i+2]?L[i+5]+18:L[i+5]+27)){if(R--){i=P;continue}R=3;break}L[x+0]=a;break}P=n[a+0]<L[i+1]?n[a+1]<L[i+2]?L[i+5]:L[i+5]+9:n[a+1]<L[i+2]?L[i+5]+18:L[i+5]+27,L[i+7]=(L[i+7]*L[i+6]+n[a+0]*n[a+6])/(L[i+6]+n[a+6]),L[i+8]=(L[i+8]*L[i+6]+n[a+1]*n[a+6])/(L[i+6]+n[a+6]),L[i+6]+=n[a+6],i=P}}if(t.barnesHutOptimize){for(m=t.scalingRatio,a=0;a<I;a+=e)for(i=0;;)if(L[i+5]>=0){if(w=Math.pow(n[a+0]-L[i+7],2)+Math.pow(n[a+1]-L[i+8],2),4*(f=L[i+3])*f/w<O){if(g=n[a+0]-L[i+7],y=n[a+1]-L[i+8],!0===T?w>0?(b=m*n[a+6]*L[i+6]/w,n[a+2]+=g*b,n[a+3]+=y*b):w<0&&(b=-m*n[a+6]*L[i+6]/Math.sqrt(w),n[a+2]+=g*b,n[a+3]+=y*b):w>0&&(b=m*n[a+6]*L[i+6]/w,n[a+2]+=g*b,n[a+3]+=y*b),(i=L[i+4])<0)break;continue}i=L[i+5]}else if((c=L[i+0])>=0&&c!==a&&(w=(g=n[a+0]-n[c+0])*g+(y=n[a+1]-n[c+1])*y,!0===T?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)),(i=L[i+4])<0)break}else for(m=t.scalingRatio,s=0;s<I;s+=e)for(u=0;u<s;u+=e)g=n[s+0]-n[u+0],y=n[s+1]-n[u+1],!0===T?(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(d=t.gravity/t.scalingRatio,m=t.scalingRatio,a=0;a<I;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]*d):w>0&&(b=m*n[a+6]*d/w),n[a+2]-=g*b,n[a+3]-=y*b;for(m=1*(t.outboundAttractionDistribution?p:1),l=0;l<M;l+=3)s=r[l+0],u=r[l+1],h=r[l+2],v=Math.pow(h,t.edgeWeightInfluence),g=n[s+0]-n[u+0],y=n[s+1]-n[u+1],!0===T?(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===T)for(a=0;a<I;a+=e)1!==n[a+9]&&((E=Math.sqrt(Math.pow(n[a+2],2)+Math.pow(n[a+3],2)))>10&&(n[a+2]=10*n[a+2]/E,n[a+3]=10*n[a+3]/E),A=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,_=.1*Math.log(1+C)/(1+Math.sqrt(A)),S=n[a+0]+n[a+2]*(_/t.slowDown),n[a+0]=S,N=n[a+1]+n[a+3]*(_/t.slowDown),n[a+1]=N);else for(a=0;a<I;a+=e)1!==n[a+9]&&(A=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,_=n[a+7]*Math.log(1+C)/(1+Math.sqrt(A)),n[a+7]=Math.min(1,Math.sqrt(_*(Math.pow(n[a+2],2)+Math.pow(n[a+3],2))/(1+Math.sqrt(A)))),S=n[a+0]+n[a+2]*(_/t.slowDown),n[a+0]=S,N=n[a+1]+n[a+3]*(_/t.slowDown),n[a+1]=N);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 i={},a=[],s=0;s<t.length;s++){var u=t[s],c=r.base?u[0]+r.base:u[0],l=i[c]||0,h="".concat(c," ").concat(l);i[c]=l+1;var d=n(h),f={css:u[1],media:u[2],sourceMap:u[3],supports:u[4],layer:u[5]};if(-1!==d)e[d].references++,e[d].updater(f);else{var p=o(f,r);r.byIndex=s,e.splice(s,0,{identifier:h,updater:p,references:1})}a.push(h)}return a}function o(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,o){var i=r(t=t||[],o=o||{});return function(t){t=t||[];for(var a=0;a<i.length;a++){var s=n(i[a]);e[s].references--}for(var u=r(t,o),c=0;c<i.length;c++){var l=n(i[c]);0===e[l].references&&(e[l].updater(),e.splice(l,1))}i=u}}},5540:(t,e,n)=>{"use strict";t=n.hmd(t);var r,o=(r="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,function(t={}){var e,n,o=void 0!==t?t:{};o.ready=new Promise((function(t,r){e=t,n=r}));var i,a=Object.assign({},o),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&&(i=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)})),o.print||console.log.bind(console);var l,h,d=o.printErr||console.warn.bind(console);Object.assign(o,a),a=null,o.arguments&&o.arguments,o.thisProgram&&o.thisProgram,o.quit&&o.quit,o.wasmBinary&&(l=o.wasmBinary),o.noExitRuntime,"object"!=typeof WebAssembly&&N("no native wasm support detected");var f,p,m,g=!1;function y(){var t=h.buffer;o.HEAP8=f=new Int8Array(t),o.HEAP16=new Int16Array(t),o.HEAP32=new Int32Array(t),o.HEAPU8=p=new Uint8Array(t),o.HEAPU16=new Uint16Array(t),o.HEAPU32=m=new Uint32Array(t),o.HEAPF32=new Float32Array(t),o.HEAPF64=new Float64Array(t)}var v,w,b=[],E=[],A=[],C=0,_=null,S=null;function N(t){o.onAbort&&o.onAbort(t),d(t="Aborted("+t+")"),g=!0,t+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(t);throw n(e),e}function I(t){return t.startsWith("data:application/octet-stream;base64,")}function M(t){try{if(t==v&&l)return new Uint8Array(l);if(i)return i(t);throw"both async and sync fetching of the wasm failed"}catch(t){N(t)}}function T(t,e,n){return function(t){return l||!s&&!u||"function"!=typeof fetch?Promise.resolve().then((function(){return M(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 M(t)}))}(t).then((function(t){return WebAssembly.instantiate(t,e)})).then((function(t){return t})).then(n,(function(t){d("failed to asynchronously prepare wasm: "+t),N(t)}))}function O(t){for(;t.length>0;)t.shift()(o)}function L(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(V(this.get_type()))return m[this.excPtr>>2];var t=this.get_adjusted_ptr();return 0!==t?t:this.excPtr}}function P(t){var e=h.buffer;try{return h.grow(t-e.byteLength+65535>>>16),y(),1}catch(t){}}function x(t){return o["_"+t]}I(v="wasmDbscan.wasm")||(w=v,v=o.locateFile?o.locateFile(w,c):c+w);var R="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function F(t,e,n,r,o){var i={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=B(e);return function(t,e,n){!function(t,e,n,r){if(!(r>0))return 0;for(var o=n+r-1,i=0;i<t.length;++i){var a=t.charCodeAt(i);if(a>=55296&&a<=57343&&(a=65536+((1023&a)<<10)|1023&t.charCodeAt(++i)),a<=127){if(n>=o)break;e[n++]=a}else if(a<=2047){if(n+1>=o)break;e[n++]=192|a>>6,e[n++]=128|63&a}else if(a<=65535){if(n+2>=o)break;e[n++]=224|a>>12,e[n++]=128|a>>6&63,e[n++]=128|63&a}else{if(n+3>=o)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=B(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=i[n[c]];l?(0===u&&(u=k()),s[c]=l(r[c])):s[c]=r[c]}var h=a.apply(null,s);return function(t){return 0!==u&&G(u),function(t){return"string"===e?(n=t)?function(t,e,n){for(var r=e+n,o=e;t[o]&&!(o>=r);)++o;if(o-e>16&&t.buffer&&R)return R.decode(t.subarray(e,o));for(var i="";e<o;){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)i+=String.fromCharCode(a);else{var c=a-65536;i+=String.fromCharCode(55296|c>>10,56320|1023&c)}}else i+=String.fromCharCode((31&a)<<6|s)}else i+=String.fromCharCode(a)}return i}(p,n,r):"":"boolean"===e?Boolean(t):t;var n,r}(t)}(h)}var D,U={__cxa_throw:function(t,e,n){throw new L(t).init(e,n),t},abort:function(){N("")},emscripten_memcpy_big:function(t,e,n){p.copyWithin(t,e,e+n)},emscripten_resize_heap:function(t){var e,n=p.length,r=2147483648;if((t>>>=0)>r)return!1;for(var o=1;o<=4;o*=2){var i=n*(1+.2/o);if(i=Math.min(i,t+100663296),P(Math.min(r,(e=Math.max(t,i))+(65536-e%65536)%65536)))return!0}return!1}},k=(function(){var t,e,r,i,a={env:U,wasi_snapshot_preview1:U};function s(t,e){var n,r=t.exports;return o.asm=r,h=o.asm.memory,y(),o.asm.__indirect_function_table,n=o.asm.__wasm_call_ctors,E.unshift(n),function(){if(C--,o.monitorRunDependencies&&o.monitorRunDependencies(C),0==C&&(null!==_&&(clearInterval(_),_=null),S)){var t=S;S=null,t()}}(),r}if(C++,o.monitorRunDependencies&&o.monitorRunDependencies(C),o.instantiateWasm)try{return o.instantiateWasm(a,s)}catch(t){d("Module.instantiateWasm callback failed with error: "+t),n(t)}(t=l,e=v,r=a,i=function(t){s(t.instance)},t||"function"!=typeof WebAssembly.instantiateStreaming||I(e)||"function"!=typeof fetch?T(e,r,i):fetch(e,{credentials:"same-origin"}).then((function(t){return WebAssembly.instantiateStreaming(t,r).then(i,(function(t){return d("wasm streaming compile failed: "+t),d("falling back to ArrayBuffer instantiation"),T(e,r,i)}))}))).catch(n)}(),o._dbscan=function(){return(o._dbscan=o.asm.dbscan).apply(null,arguments)},o._malloc=function(){return(o._malloc=o.asm.malloc).apply(null,arguments)},o._free=function(){return(o._free=o.asm.free).apply(null,arguments)},function(){return(k=o.asm.stackSave).apply(null,arguments)}),G=function(){return(G=o.asm.stackRestore).apply(null,arguments)},B=function(){return(B=o.asm.stackAlloc).apply(null,arguments)},V=function(){return(V=o.asm.__cxa_is_pointer_type).apply(null,arguments)};function W(){function t(){D||(D=!0,o.calledRun=!0,g||(O(E),e(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),function(){if(o.postRun)for("function"==typeof o.postRun&&(o.postRun=[o.postRun]);o.postRun.length;)t=o.postRun.shift(),A.unshift(t);var t;O(A)}()))}C>0||(function(){if(o.preRun)for("function"==typeof o.preRun&&(o.preRun=[o.preRun]);o.preRun.length;)t=o.preRun.shift(),b.unshift(t);var t;O(b)}(),C>0||(o.setStatus?(o.setStatus("Running..."),setTimeout((function(){setTimeout((function(){o.setStatus("")}),1),t()}),1)):t()))}if(o.ccall=F,o.cwrap=function(t,e,n,r){var o=!n||n.every((t=>"number"===t||"boolean"===t));return"string"!==e&&o&&!r?x(t):function(){return F(t,e,n,arguments)}},S=function t(){D||W(),D||(S=t)},o.preInit)for("function"==typeof o.preInit&&(o.preInit=[o.preInit]);o.preInit.length>0;)o.preInit.pop()();return W(),t.ready});"object"==typeof exports?t.exports=o:"function"==typeof define&&n.amdO?define([],(function(){return o})):"object"==typeof exports&&(exports.exportCppDbscanLib=o)},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,o,i){"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!==i&&(void 0===l[5]||(l[1]="@layer".concat(l[5].length>0?" ".concat(l[5]):""," {").concat(l[1],"}")),l[5]=i),n&&(l[2]?(l[1]="@media ".concat(l[2]," {").concat(l[1],"}"),l[2]=n):l[2]=n),o&&(l[4]?(l[1]="@supports (".concat(l[4],") {").concat(l[1],"}"),l[4]=o):l[4]="".concat(o)),e.push(l))}},e}},6572:function(t){var e;t.exports=(e=function(t,e){var n=Array.prototype.concat,r=Array.prototype.slice,o=Object.prototype.toString;function i(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]"===o.call(t)};function s(t){return"[object Function]"===o.call(t)}function u(t){return"number"==typeof t&&t-t==0}function c(){return new c._init(arguments)}function l(){return 0}function h(){return 1}function d(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:i,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(o){n[o][r]=t[o][e]}))})),n}for(var r=new Array(t.length),o=0;o<t.length;o++)r[o]=[t[o][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,o,i,s=[];for(a(t[0])||(t=[t]),n=t.length,r=t[0].length,i=0;i<r;i++){for(e=new Array(n),o=0;o<n;o++)e[o]=t[o][i];s.push(e)}return 1===s.length?s[0]:s},c.map=function(t,e,n){var r,o,i,s,u;for(a(t[0])||(t=[t]),o=t.length,i=t[0].length,s=n?t:new Array(o),r=0;r<o;r++)for(s[r]||(s[r]=new Array(i)),u=0;u<i;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,o,i,s,u;for(a(t[0])||(t=[t]),o=t.length,i=t[0].length,s=n?t:new Array(o),r=0;r<o;r++)for(s[r]||(s[r]=new Array(i)),i>0&&(s[r][0]=t[r][0]),u=1;u<i;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,o,i=new Array(t);for(s(e)&&(n=e,e=t),r=0;r<t;r++)for(i[r]=new Array(e),o=0;o<e;o++)i[r][o]=n(r,o);return i},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,h)},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,d)},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 o,a=[],u=i(t,e),c=(e*u-t*u)/((n-1)*u),l=t;for(o=0;l<=e&&o<n;l=(t*u+c*u*++o)/u)a.push(r?r(l,o):l);return a},c.arange=function(t,n,r){var o,i=[];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(o=t;o<n;o+=r)i.push(o);else for(o=t;o>n;o+=r)i.push(o);return i},c.slice=function(){function t(t,n,r,o){var i,a=[],s=t.length;if(n===e&&r===e&&o===e)return c.copy(t);if(o=o||1,(n=(n=n||0)>=0?n:s+n)===(r=(r=r||t.length)>=0?r:s+r)||0===o)return[];if(n<r&&o<0)return[];if(n>r&&o>0)return[];if(o>0)for(i=n;i<r;i+=o)a.push(t[i]);else for(i=n;i>r;i+=o)a.push(t[i]);return a}return function(e,n){var r,o;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),(o=n.row||{}).start,o.end,o.step):(o=n.row||{},r=n.col||{},t(e,o.start,o.end,o.step).map((function(e){return t(e,r.start,r.end,r.step)})))}}(),c.sliceAssign=function(n,r,o){var i,a;if(u(r.row)){if(u(r.col))return n[r.row][r.col]=o;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,i=c.arange(r.col.start,t.min(n.length,r.col.end),r.col.step);var s=r.row;return i.forEach((function(t,e){n[s][t]=o[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]=o[e]})),n}return o[0].length===e&&(o=[o]),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),i=c.arange(r.col.start,t.min(n[0].length,r.col.end),r.col.step),a.forEach((function(t,e){i.forEach((function(r,i){n[t][r]=o[e][i]}))})),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 o(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),o=0,i=e.length;--i>=0;)o+=(n=e[i]-r)*n;return o},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),o=t.mean(r);return e.exp(o)},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=[],o={};for(e=0;e<t.length;e++)o[u=t[e]]?o[u]++:(o[u]=1,n.push(u));var i=n.sort(r),a={},s=1;for(e=0;e<i.length;e++){var u,c=o[u=i[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,o=t.slice().sort(r),i=1,a=0,s=0,u=[];for(e=0;e<n;e++)o[e]===o[e+1]?i++:(i>a?(u=[o[e]],a=i,s=0):i===a&&(u.push(o[e]),s++),i=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,o=new Array(r),i=0;i<r;i++)o[i]=e[i]-n;return o},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),o=[],i=n.length-1;i>=0;i--)o.push(e.abs(n[i]-r));return t.mean(o)},t.meddev=function(n){for(var r=t.median(n),o=[],i=n.length-1;i>=0;i--)o.push(e.abs(n[i]-r));return t.median(o)},t.coeffvar=function(e){return t.stdev(e)/t.mean(e)},t.quartiles=function(t){var n=t.length,o=t.slice().sort(r);return[o[e.round(n/4)-1],o[e.round(n/2)-1],o[e.round(3*n/4)-1]]},t.quantiles=function(t,n,i,a){var s,u,c,l,h,d=t.slice().sort(r),f=[n.length],p=t.length;for(void 0===i&&(i=3/8),void 0===a&&(a=3/8),s=0;s<n.length;s++)c=p*(u=n[s])+(i+u*(1-i-a)),l=e.floor(o(c,1,p-1)),h=o(c-l,0,1),f[s]=(1-h)*d[l-1]+h*d[l];return f},t.percentile=function(t,e,n){var o=t.slice().sort(r),i=e*(o.length+(n?1:-1))+(n?0:1),a=parseInt(i),s=i-a;return a+1<o.length?o[a-1]+s*(o[a]-o[a-1]):o[a-1]},t.percentileOfScore=function(t,e,n){var r,o,i=0,a=t.length,s=!1;for("strict"===n&&(s=!0),o=0;o<a;o++)r=t[o],(s&&r<e||!s&&r<=e)&&i++;return i/a},t.histogram=function(n,r){r=r||4;var o,i=t.min(n),a=(t.max(n)-i)/r,s=n.length,u=[];for(o=0;o<r;o++)u[o]=0;for(o=0;o<s;o++)u[e.min(e.floor((n[o]-i)/a),r-1)]+=1;return u},t.covariance=function(e,n){var r,o=t.mean(e),i=t.mean(n),a=e.length,s=new Array(a);for(r=0;r<a;r++)s[r]=(e[r]-o)*(n[r]-i);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 o=t.mean(n),i=t.stdev(n),a=n.length,s=0,u=0;u<a;u++)s+=e.pow((n[u]-o)/i,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 i=t.prototype;!function(e){for(var r=0;r<e.length;r++)!function(e){i[e]=function(r,o){var a=[],s=0,u=this;if(n(r)&&(o=r,r=!1),o)return setTimeout((function(){o.call(u,i[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){i[e]=function(r,o){var a=[],s=0,u=this;if(n(r)&&(o=r,r=!1),o)return setTimeout((function(){o.call(u,i[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){i[e]=function(){var r,o=[],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,i[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++)o[a]=l(s[a]);return o}return l(this[0])}}(e[r])}("quantiles percentileOfScore".split(" "))}(e,Math),function(t,e){t.gammaln=function(t){var n,r,o,i=0,a=[76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18],s=1.000000000190015;for(o=(r=n=t)+5.5,o-=(n+.5)*e.log(o);i<6;i++)s+=a[i]/++r;return e.log(2.5066282746310007*s/n)-o},t.loggam=function(t){var n,r,o,i,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),o=2*e.PI,a=c[9],s=8;s>=0;s--)a*=r,a+=c[s];if(i=a/n+.5*e.log(o)+(n-.5)*e.log(n)-n,t<=7)for(s=1;s<=u;s++)i-=e.log(n-1),n-=1;return i},t.gammafn=function(t){var n,r,o,i,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,h=0,d=t;if(t>171.6243769536076)return 1/0;if(d<=0){if(!(i=d%1+36e-17))return 1/0;u=(1&d?-1:1)*e.PI/e.sin(e.PI*i),d=1-d}for(o=d,r=d<1?d++:(d-=c=(0|d)-1)-1,n=0;n<8;++n)h=(h+a[n])*r,l=l*r+s[n];if(i=h/l+1,o<d)i/=o;else if(o>d)for(n=0;n<c;++n)i*=d,d++;return u&&(i=u/i),i},t.gammap=function(e,n){return t.lowRegGamma(e,n)*t.gammafn(e)},t.lowRegGamma=function(n,r){var o,i=t.gammaln(n),a=n,s=1/n,u=s,c=r+1-n,l=1/1e-30,h=1/c,d=h,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)-i)}for(;f<=p;f++)d*=(h=1/(h=(o=-f*(f-n))*h+(c+=2)))*(l=c+o/l);return 1-d*e.exp(-r+n*e.log(r)-i)},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 o,i,a,s,u=1e-30,c=1,l=n+r,h=n+1,d=n-1,f=1,p=1-l*t/h;for(e.abs(p)<u&&(p=u),s=p=1/p;c<=100&&(p=1+(i=c*(r-c)*t/((d+(o=2*c))*(n+o)))*p,e.abs(p)<u&&(p=u),f=1+i/f,e.abs(f)<u&&(f=u),s*=(p=1/p)*f,p=1+(i=-(n+c)*(l+c)*t/((n+o)*(h+o)))*p,e.abs(p)<u&&(p=u),f=1+i/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 o,i,a,s,u,c,l=0,h=r-1,d=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(h),c=e.exp(h*(u-1)-d),s=n<.5?n:1-n,o=(2.30753+.27061*(i=e.sqrt(-2*e.log(s))))/(1+i*(.99229+.04481*i))-i,n<.5&&(o=-o),o=e.max(.001,r*e.pow(1-1/(9*r)-o/(3*e.sqrt(r)),3))):o=n<(i=1-r*(.253+.12*r))?e.pow(n/i,1/r):1-e.log(1-(n-i)/(1-i));l<12;l++){if(o<=0)return 0;if((o-=i=(a=(t.lowRegGamma(r,o)-n)/(i=r>1?c*e.exp(-(o-h)+h*(e.log(o)-u)):e.exp(-o+h*e.log(o)-d)))/(1-.5*e.min(1,a*((r-1)/o-1))))<=0&&(o=.5*(o+i)),e.abs(i)<1e-8*o)break}return o},t.erf=function(t){var n,r,o,i,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--)o=c,c=r*c-l+a[s],l=o;return i=n*e.exp(-t*t+.5*(a[0]+r*c)-l),u?i-1:1-i},t.erfc=function(e){return 1-t.erf(e)},t.erfcinv=function(n){var r,o,i,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*(i=e.sqrt(-2*e.log(a/2))))/(1+i*(.99229+.04481*i))-i);s<2;s++)r+=(o=t.erfc(r)-a)/(1.1283791670955126*e.exp(-r*r)-r*o);return n<1?r:-r},t.ibetainv=function(n,r,o){var i,a,s,u,c,l,h,d,f,p,m=r-1,g=o-1,y=0;if(n<=0)return 0;if(n>=1)return 1;for(r>=1&&o>=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),h=(l*l-3)/6,d=2/(1/(2*r-1)+1/(2*o-1)),f=l*e.sqrt(h+d)/d-(1/(2*o-1)-1/(2*r-1))*(h+5/6-2/(3*d)),l=r/(r+o*e.exp(2*f))):(i=e.log(r/(r+o)),a=e.log(o/(r+o)),l=n<(u=e.exp(r*i)/r)/(f=u+(c=e.exp(o*a)/o))?e.pow(r*f*n,1/r):1-e.pow(o*f*(1-n),1/o)),p=-t.gammaln(r)-t.gammaln(o)+t.gammaln(r+o);y<10;y++){if(0===l||1===l)return l;if((l-=u=(c=(t.ibeta(l,r,o)-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,o){var i=0===n||1===n?0:e.exp(t.gammaln(r+o)-t.gammaln(r)-t.gammaln(o)+r*e.log(n)+o*e.log(1-n));return!(n<0||n>1)&&(n<(r+1)/(r+o+2)?i*t.betacf(n,r,o)/r:1-i*t.betacf(1-n,o,r)/o)},t.randn=function(n,r){var o,i,a,s,u;if(r||(r=n),n)return t.create(n,r,(function(){return t.randn()}));do{o=t._random_fn(),i=1.7156*(t._random_fn()-.5),u=(a=o-.449871)*a+(s=e.abs(i)+.386595)*(.196*s-.25472*a)}while(u>.27597&&(u>.27846||i*i>-4*e.log(o)*o*o));return i/o},t.randg=function(n,r,o){var i,a,s,u,c,l,h=n;if(o||(o=r),n||(n=1),r)return(l=t.zeros(r,o)).alter((function(){return t.randg(n)})),l;n<1&&(n+=1),i=n-1/3,a=1/e.sqrt(9*i);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+i*(1-u+e.log(u)));if(n==h)return i*u;do{s=t._random_fn()}while(0===s);return e.pow(s,1/h)*i*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,o){for(var i,a=0,s=1,u=1,c=1,l=0,h=0;e.abs((u-h)/u)>o;)h=u,s=c+(i=-(n+l)*(n+r+l)*t/(n+2*l)/(n+2*l+1))*s,u=(a=u+i*a)+(i=(l+=1)*(r-l)*t/(n+2*l-1)/(n+2*l))*u,a/=c=s+i*c,s/=c,u/=c,c=1;return u/n}function r(n,r,o){var i=[.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/o)?e.pow(c,o):0;for(var l=s,h=(8-s)/(u=n>3?2:3),d=l+h,f=0,p=o-1,m=1;m<=u;m++){for(var g=0,y=.5*(d+l),v=.5*(d-l),w=1;w<=12;w++){var b,E=y+v*(6<w?i[(b=12-w+1)-1]:-i[(b=w)-1]),A=E*E;if(A>60)break;var C=2*t.normal.cdf(E,0,1,1,0)*.5-2*t.normal.cdf(E,n,1,1,0)*.5;C>=e.exp(-30/p)&&(g+=C=a[b-1]*e.exp(-.5*A)*e.pow(C,p))}f+=g*=2*v*o/e.sqrt(2*e.PI),l=d,d+=h}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,o){var i=t[e](n,r,o);return i.data=this,i},t[e].prototype.sample=function(n){var r=this._a,o=this._b,i=this._c;return n?t.alter(n,(function(){return t[e].sample(r,o,i)})):t[e].sample(r,o,i)},function(n){for(var r=0;r<n.length;r++)!function(n){t[e].prototype[n]=function(r){var o=this._a,i=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,o,i,a)})):t[e][n](r,o,i,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,o){return n>1||n<0?0:1==r&&1==o?1:r<512&&o<512?e.pow(n,r-1)*e.pow(1-n,o-1)/t.betafn(r,o):e.exp((r-1)*e.log(n)+(o-1)*e.log(1-n)-t.betaln(r,o))},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,o){var i;return n<0?0:r<=2?0===n&&r<2?1/0:0===n&&2===r?1:1/t.betafn(r/2,o/2)*e.pow(r/o,r/2)*e.pow(n,r/2-1)*e.pow(1+r/o*n,-(r+o)/2):(i=r*n/(o+n*r),r*(o/(o+n*r))/2*t.binomial.pdf((r-2)/2,(r+o-2)/2,i))},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,o){return n<0?0:0===n&&1===r?1/o:e.exp((r-1)*e.log(n)-n/o-t.gammaln(r)-r*e.log(o))},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,o){return n<=0?0:e.exp(-(r+1)*e.log(n)-o/n-t.gammaln(r)+r*e.log(o))},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,o){return n<0?0:.5+.5*t.erf((e.log(n)-r)/e.sqrt(2*o*o))},inv:function(n,r,o){return e.exp(-1.4142135623730951*o*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,o){return e.abs(o)<1e-14?t.studentt.pdf(n,r):e.abs(n)<1e-14?e.exp(t.gammaln((r+1)/2)-o*o/2-.5*e.log(e.PI*r)-t.gammaln(r/2)):r/n*(t.noncentralt.cdf(n*e.sqrt(1+2/r),r+2,o)-t.noncentralt.cdf(n,r,o))},cdf:function(n,r,o){var i=1e-14;if(e.abs(o)<i)return t.studentt.cdf(n,r);var a=!1;n<0&&(a=!0,o=-o);for(var s=t.normal.cdf(-o,0,1),u=i+1,c=u,l=n*n/(n*n+r),h=0,d=e.exp(-o*o/2),f=e.exp(-o*o/2-.5*e.log(2)-t.gammaln(1.5))*o;h<200||c>i||u>i;)c=u,h>0&&(d*=o*o/(2*h),f*=o*o/(2*(h+.5))),s+=.5*(u=d*t.beta.cdf(l,h+.5,r/2)+f*t.beta.cdf(l,h+1,r/2)),h++;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,o){return.5*(1+t.erf((n-r)/e.sqrt(2*o*o)))},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 o=r/2;return t.ibeta((n+e.sqrt(n*n+r))/(2*e.sqrt(n*n+r)),o,o)},inv:function(n,r){var o=t.ibetainv(2*e.min(n,1-n),.5*r,.5);return o=e.sqrt(r*(1-o)/o),n>.5?o:-o},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,o){return 0===o||1===o?r*o===n?1:0:t.combination(r,n)*e.pow(o,n)*e.pow(1-o,r-n)},cdf:function(r,o,i){var a,s=1e-10;if(r<0)return 0;if(r>=o)return 1;if(i<0||i>1||o<=0)return NaN;var u=i,c=(r=e.floor(r))+1,l=o-r,h=c+l,d=e.exp(t.gammaln(h)-t.gammaln(l)-t.gammaln(c)+c*e.log(u)+l*e.log(1-u));return a=u<(c+1)/(h+2)?d*n(u,c,l,s):1-d*n(1-u,l,c,s),e.round(1/s*(1-a))/(1/s)}}),t.extend(t.negbin,{pdf:function(n,r,o){return n===n>>>0&&(n<0?0:t.combination(n+r-1,r-1)*e.pow(1-o,n)*e.pow(o,r))},cdf:function(e,n,r){var o=0,i=0;if(e<0)return 0;for(;i<=e;i++)o+=t.negbin.pdf(i,n,r);return o}}),t.extend(t.hypgeom,{pdf:function(n,r,o,i){if(n!=n|0)return!1;if(n<0||n<o-(r-i))return 0;if(n>i||n>o)return 0;if(2*o>r)return 2*i>r?t.hypgeom.pdf(r-o-i+n,r,r-o,r-i):t.hypgeom.pdf(i-n,r,r-o,i);if(2*i>r)return t.hypgeom.pdf(o-n,r,o,r-i);if(o<i)return t.hypgeom.pdf(n,r,i,o);for(var a=1,s=0,u=0;u<n;u++){for(;a>1&&s<i;)a*=1-o/(r-s),s++;a*=(i-u)*(o-u)/((u+1)*(r-o-i+u+1))}for(;s<i;s++)a*=1-o/(r-s);return e.min(1,e.max(0,a))},cdf:function(n,r,o,i){if(n<0||n<o-(r-i))return 0;if(n>=i||n>=o)return 1;if(2*o>r)return 2*i>r?t.hypgeom.cdf(r-o-i+n,r,r-o,r-i):1-t.hypgeom.cdf(i-n-1,r,r-o,i);if(2*i>r)return 1-t.hypgeom.cdf(o-n-1,r,o,r-i);if(o<i)return t.hypgeom.cdf(n,r,i,o);for(var a=1,s=1,u=0,c=0;c<n;c++){for(;a>1&&u<i;){var l=1-o/(r-u);s*=l,a*=l,u++}a+=s*=(i-c)*(o-c)/((c+1)*(r-o-i+c+1))}for(;u<i;u++)a*=1-o/(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=[],o=0;if(e<0)return 0;for(;o<=e;o++)r.push(t.poisson.pdf(o,n));return t.sum(r)},mean:function(t){return t},variance:function(t){return t},sampleSmall:function(n){var r=1,o=0,i=e.exp(-n);do{o++,r*=t._random_fn()}while(r>i);return o-1},sampleLarge:function(n){var r,o,i,a,s,u,c,l,h,d,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),h=.9277-3.6224/(c-2);;){if(o=e.random()-.5,i=e.random(),d=.5-e.abs(o),r=e.floor((2*u/d+c)*o+f+.43),d>=.07&&i<=h)return r;if(!(r<0||d<.013&&i>d)&&e.log(i)+e.log(l)-e.log(u/(d*d)+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,o){return r<=n||o<n||o>r?NaN:t<=n?0:t>=r?1:t<=o?e.pow(t-n,2)/((r-n)*(o-n)):1-e.pow(r-t,2)/((r-n)*(r-o))},inv:function(t,n,r,o){return r<=n||o<n||o>r?NaN:t<=(o-n)/(r-n)?n+(r-n)*e.sqrt(t*((o-n)/(r-n))):n+(r-n)*(1-e.sqrt((1-t)*(1-(o-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,o){var i=t._random_fn();return i<(o-n)/(r-n)?n+e.sqrt(i*(r-n)*(o-n)):r-e.sqrt((1-i)*(r-n)*(r-o))},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 o,i=t._random_fn()-.5;return n-r*((o=i)/e.abs(o))*e.log(1-2*e.abs(i))}}),t.extend(t.tukey,{cdf:function(n,o,i){var a=o,s=[.9894009349916499,.9445750230732326,.8656312023878318,.755404408355003,.6178762444026438,.45801677765722737,.2816035507792589,.09501250983763744],u=[.027152459411754096,.062253523938647894,.09515851168249279,.12462897125553388,.14959598881657674,.16915651939500254,.18260341504492358,.1894506104550685];if(n<=0)return 0;if(i<2||a<2)return NaN;if(!Number.isFinite(n))return 1;if(i>25e3)return r(n,1,a);var c,l=.5*i,h=l*e.log(i)-i*e.log(2)-t.gammaln(l),d=l-1,f=.25*i;c=i<=100?1:i<=800?.5:i<=5e3?.25:.125,h+=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=h+d*e.log(y+s[w]*c)-(s[w]*c+y)*f):(w=v-1,b=h+d*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,o){if(o<2||r<2)return NaN;if(n<0||n>1)return NaN;if(0===n)return 0;if(1===n)return 1/0;var i,a=function(t,n,r){var o=.5-.5*t,i=e.sqrt(e.log(1/(o*o))),a=i+((((-453642210148e-16*i-.204231210125)*i-.342242088547)*i-1)*i+.322232421088)/((((.0038560700634*i+.10353775285)*i+.531103462366)*i+.588581570495)*i+.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,o),s=t.tukey.cdf(a,r,o)-n;i=s>0?e.max(0,a-1):a+1;for(var u,c=t.tukey.cdf(i,r,o)-n,l=1;l<50;l++)if(u=i-c*(i-a)/(c-s),s=c,a=i,u<0&&(u=0,c=-n),c=t.tukey.cdf(u,r,o)-n,i=u,e.abs(i-a)<1e-4)return u;throw new Error("tukey.inv failed to converge")}})}(e,Math),function(t,e){var n,r,o=Array.prototype.push,i=t.utils.isArray;function a(e){return i(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,o,i,s,u,c,l,h;if(void 0===e.length&&void 0===n.length)return e*n;if(u=e.length,c=e[0].length,l=t.zeros(u,i=a(n)?n[0].length:c),h=0,a(n)){for(;h<i;h++)for(r=0;r<u;r++){for(s=0,o=0;o<c;o++)s+=e[r][o]*n[o][h];l[r][h]=s}return 1===u&&1===h?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,o,i=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=i.length,h=i[0].length;c<l;c++){for(u[c]=[],r=0,o=0;o<h;o++)r+=i[c][o]*s[c][o];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,o=0;for(isNaN(n)&&(n=2),a(t[0])&&(t=t[0]);o<t.length;o++)r+=e.pow(e.abs(t[o]),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++)o.apply(r[n],e[n]);return r},inv:function(e){for(var n,r=e.length,o=e[0].length,i=t.identity(r,o),a=t.gauss_jordan(e,i),s=[],u=0;u<r;u++)for(s[u]=[],n=o;n<a[0].length;n++)s[u][n-o]=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 o=[],i=1;i<e.length;i++){o[i-1]=[];for(var a=0;a<e.length;a++)a<r?o[i-1][a]=e[i][a]:a>r&&(o[i-1][a-1]=e[i][a])}var s=r%2?-1:1;n+=t(o)*e[0][r]*s}return n},gauss_elimination:function(n,r){var o,i,a,s,u=0,c=0,l=n.length,h=n[0].length,d=1,f=0,p=[];for(o=(n=t.aug(n,r))[0].length,u=0;u<l;u++){for(i=n[u][u],c=u,s=u+1;s<h;s++)i<e.abs(n[s][u])&&(i=n[s][u],c=s);if(c!=u)for(s=0;s<o;s++)a=n[u][s],n[u][s]=n[c][s],n[c][s]=a;for(c=u+1;c<l;c++)for(d=n[c][u]/n[u][u],s=u;s<o;s++)n[c][s]=n[c][s]-d*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][o-1]-f)/n[u][u]}return p},gauss_jordan:function(n,r){var o,i,a,s=t.aug(n,r),u=s.length,c=s[0].length,l=0;for(i=0;i<u;i++){var h=i;for(a=i+1;a<u;a++)e.abs(s[a][i])>e.abs(s[h][i])&&(h=a);var d=s[i];for(s[i]=s[h],s[h]=d,a=i+1;a<u;a++)for(l=s[a][i]/s[i][i],o=i;o<c;o++)s[a][o]-=s[i][o]*l}for(i=u-1;i>=0;i--){for(l=s[i][i],a=0;a<i;a++)for(o=c-1;o>i-1;o--)s[a][o]-=s[i][o]*s[a][i]/l;for(s[i][i]/=l,o=u;o<c;o++)s[i][o]/=l}return s},triaUpSolve:function(e,n){var r,o=e[0].length,i=t.zeros(1,o)[0],a=!1;return null!=n[0].length&&(n=n.map((function(t){return t[0]})),a=!0),t.arange(o-1,-1,-1).forEach((function(a){r=t.arange(a+1,o).map((function(t){return i[t]*e[a][t]})),i[a]=(n[a]-t.sum(r))/e[a][a]})),a?i.map((function(t){return[t]})):i},triaLowSolve:function(e,n){var r,o=e[0].length,i=t.zeros(1,o)[0],a=!1;return null!=n[0].length&&(n=n.map((function(t){return t[0]})),a=!0),t.arange(o).forEach((function(o){r=t.arange(o).map((function(t){return e[o][t]*i[t]})),i[o]=(n[o]-t.sum(r))/e[o][o]})),a?i.map((function(t){return[t]})):i},lu:function(e){var n,r=e.length,o=t.identity(r),i=t.zeros(e.length,e[0].length);return t.arange(r).forEach((function(t){i[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 o[a][t]*i[t][r]})),o[a][r]=(e[a][r]-t.sum(n))/i[r][r]})),t.arange(a,r).forEach((function(r){n=t.arange(a).map((function(t){return o[a][t]*i[t][r]})),i[a][r]=e[n.length][r]-t.sum(n)}))})),[o,i]},cholesky:function(n){var r,o=n.length,i=t.zeros(n.length,n[0].length);return t.arange(o).forEach((function(a){r=t.arange(a).map((function(t){return e.pow(i[a][t],2)})),i[a][a]=e.sqrt(n[a][a]-t.sum(r)),t.arange(a+1,o).forEach((function(e){r=t.arange(a).map((function(t){return i[a][t]*i[e][t]})),i[e][a]=(n[a][e]-t.sum(r))/i[a][a]}))})),i},gauss_jacobi:function(n,r,o,i){for(var a,s,u,c,l=0,h=0,d=n.length,f=[],p=[],m=[];l<d;l++)for(f[l]=[],p[l]=[],m[l]=[],h=0;h<d;h++)l>h?(f[l][h]=n[l][h],p[l][h]=m[l][h]=0):l<h?(p[l][h]=n[l][h],f[l][h]=m[l][h]=0):(m[l][h]=n[l][h],f[l][h]=p[l][h]=0);for(u=t.multiply(t.multiply(t.inv(m),t.add(f,p)),-1),s=t.multiply(t.inv(m),r),a=o,c=t.add(t.multiply(u,o),s),l=2;e.abs(t.norm(t.subtract(c,a)))>i;)a=c,c=t.add(t.multiply(u,a),s),l++;return c},gauss_seidel:function(n,r,o,i){for(var a,s,u,c,l,h=0,d=n.length,f=[],p=[],m=[];h<d;h++)for(f[h]=[],p[h]=[],m[h]=[],a=0;a<d;a++)h>a?(f[h][a]=n[h][a],p[h][a]=m[h][a]=0):h<a?(p[h][a]=n[h][a],f[h][a]=m[h][a]=0):(m[h][a]=n[h][a],f[h][a]=p[h][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=o,l=t.add(t.multiply(c,o),u),h=2;e.abs(t.norm(t.subtract(l,s)))>i;)s=l,l=t.add(t.multiply(c,s),u),h+=1;return l},SOR:function(n,r,o,i,a){for(var s,u,c,l,h,d=0,f=n.length,p=[],m=[],g=[];d<f;d++)for(p[d]=[],m[d]=[],g[d]=[],s=0;s<f;s++)d>s?(p[d][s]=n[d][s],m[d][s]=g[d][s]=0):d<s?(m[d][s]=n[d][s],p[d][s]=g[d][s]=0):(g[d][s]=n[d][s],p[d][s]=m[d][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=o,h=t.add(t.multiply(l,o),c),d=2;e.abs(t.norm(t.subtract(h,u)))>i;)u=h,h=t.add(t.multiply(l,u),c),d++;return h},householder:function(n){for(var r,o,i,a,s=n.length,u=n[0].length,c=0,l=[],h=[];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),o=e.sqrt((r*r-n[c+1][c]*r)/2),(l=t.zeros(s,1))[c+1][0]=(n[c+1][c]-r)/(2*o),i=c+2;i<s;i++)l[i][0]=n[i][c]/(2*o);h=t.subtract(t.identity(s,u),t.multiply(t.multiply(l,t.transpose(l)),2)),n=t.multiply(h,t.multiply(n,h))}return n},QR:(n=t.sum,r=t.arange,function(o){var i,a,s,u=o.length,c=o[0].length,l=t.zeros(c,c);for(o=t.copy(o),a=0;a<c;a++){for(l[a][a]=e.sqrt(n(r(u).map((function(t){return o[t][a]*o[t][a]})))),i=0;i<u;i++)o[i][a]=o[i][a]/l[a][a];for(s=a+1;s<c;s++)for(l[a][s]=n(r(u).map((function(t){return o[t][a]*o[t][s]}))),i=0;i<u;i++)o[i][s]=o[i][s]-o[i][a]*l[a][s]}return[o,l]}),lstsq:function(e,n){var r=!1;void 0===n[0].length&&(n=n.map((function(t){return[t]})),r=!0);var o=t.QR(e),i=o[0],a=o[1],s=e[0].length,u=t.slice(i,{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(o){var i=t.multiply(e[o][n],-1),a=t.slice(e,{row:o}),s=t.multiply(t.slice(e,{row:n}),i);t.sliceAssign(e,{row:o},t.add(a,s));var u=t.slice(r,{row:o}),c=t.multiply(t.slice(r,{row:n}),i);t.sliceAssign(r,{row:o},t.add(u,c))}))})),r}(t.slice(a,{row:{end:s}})),l=t.transpose(u);void 0===l[0].length&&(l=[l]);var h=t.multiply(t.multiply(c,l),n);return void 0===h.length&&(h=[[h]]),r?h.map((function(t){return t[0]})):h},jacobi:function(n){for(var r,o,i,a,s,u,c,l=1,h=n.length,d=t.identity(h,h),f=[];1===l;){for(s=n[0][1],i=0,a=1,r=0;r<h;r++)for(o=0;o<h;o++)r!=o&&s<e.abs(n[r][o])&&(s=e.abs(n[r][o]),i=r,a=o);for(u=n[i][i]===n[a][a]?n[i][a]>0?e.PI/4:-e.PI/4:e.atan(2*n[i][a]/(n[i][i]-n[a][a]))/2,(c=t.identity(h,h))[i][i]=e.cos(u),c[i][a]=-e.sin(u),c[a][i]=e.sin(u),c[a][a]=e.cos(u),d=t.multiply(d,c),n=t.multiply(t.multiply(t.inv(c),n),c),l=0,r=1;r<h;r++)for(o=1;o<h;o++)r!=o&&e.abs(n[r][o])>.001&&(l=1)}for(r=0;r<h;r++)f.push(n[r][r]);return[d,f]},rungekutta:function(t,e,n,r,o,i){var a,s,u;if(2===i)for(;r<=n;)o+=((a=e*t(r,o))+(s=e*t(r+e,o+a)))/2,r+=e;if(4===i)for(;r<=n;)o+=((a=e*t(r,o))+2*(s=e*t(r+e/2,o+a/2))+2*(u=e*t(r+e/2,o+s/2))+e*t(r+e,o+u))/6,r+=e;return o},romberg:function(t,n,r,o){for(var i,a,s,u,c,l=0,h=(r-n)/2,d=[],f=[],p=[];l<o/2;){for(c=t(n),s=n,u=0;s<=r;s+=h,u++)d[u]=s;for(i=d.length,s=1;s<i-1;s++)c+=(s%2!=0?4:2)*t(d[s]);c=h/3*(c+t(r)),p[l]=c,h/=2,l++}for(a=p.length,i=1;1!==a;){for(s=0;s<a-1;s++)f[s]=(e.pow(4,i)*p[s+1]-p[s])/(e.pow(4,i)-1);a=f.length,p=f,f=[],i++}return p},richardson:function(t,n,r,o){function i(t,e){for(var n,r=0,o=t.length;r<o;r++)t[r]===e&&(n=r);return n}for(var a,s,u,c,l,h=e.abs(r-t[i(t,r)+1]),d=0,f=[],p=[];o>=h;)a=i(t,r+o),s=i(t,r),f[d]=(n[a]-2*n[s]+n[2*s-a])/(o*o),o/=2,d++;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 o,i=(n-e)/r,a=t(e),s=[],u=e,c=0,l=1;u<=n;u+=i,c++)s[c]=u;for(o=s.length;l<o-1;l++)a+=(l%2!=0?4:2)*t(s[l]);return i/3*(a+t(n))},hermite:function(t,e,n,r){for(var o,i=t.length,a=0,s=0,u=[],c=[],l=[],h=[];s<i;s++){for(u[s]=1,o=0;o<i;o++)s!=o&&(u[s]*=(r-t[o])/(t[s]-t[o]));for(c[s]=0,o=0;o<i;o++)s!=o&&(c[s]+=1/(t[s]-t[o]));l[s]=(1-2*(r-t[s])*c[s])*(u[s]*u[s]),h[s]=(r-t[s])*(u[s]*u[s]),a+=l[s]*e[s]+h[s]*n[s]}return a},lagrange:function(t,e,n){for(var r,o,i=0,a=0,s=t.length;a<s;a++){for(o=e[a],r=0;r<s;r++)a!=r&&(o*=(n-t[r])/(t[a]-t[r]));i+=o}return i},cubic_spline:function(e,n,r){for(var o,i,a=e.length,s=0,u=[],c=[],l=[],h=[],d=[],f=[];s<a-1;s++)h[s]=e[s+1]-e[s];for(l[0]=0,s=1;s<a-1;s++)l[s]=3/h[s]*(n[s+1]-n[s])-3/h[s-1]*(n[s]-n[s-1]);for(s=1;s<a-1;s++)u[s]=[],c[s]=[],u[s][s-1]=h[s-1],u[s][s]=2*(h[s-1]+h[s]),u[s][s+1]=h[s],c[s][0]=l[s];for(i=t.multiply(t.inv(u),c),o=0;o<a-1;o++)d[o]=(n[o+1]-n[o])/h[o]-h[o]*(i[o+1][0]+2*i[o][0])/3,f[o]=(i[o+1][0]-i[o][0])/(3*h[o]);for(o=0;o<a&&!(e[o]>r);o++);return n[o-=1]+(r-e[o])*d[o]+t.sq(r-e[o])*i[o]+(r-e[o])*t.sq(r-e[o])*f[o]},gauss_quadrature:function(){throw new Error("gauss_quadrature not yet implemented")},PCA:function(e){var n,r,o,i,a,s=e.length,u=e[0].length,c=0,l=[],h=[],d=[],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=(o=t.jacobi(m))[0],h=o[1],g=t.transpose(a),c=0;c<h.length;c++)for(n=c;n<h.length;n++)h[c]<h[n]&&(r=h[c],h[c]=h[n],h[n]=r,d=g[c],g[c]=g[n],g[n]=d);for(i=t.transpose(p),c=0;c<s;c++)for(f[c]=[],n=0;n<i.length;n++)f[c][n]=t.dot([g[c]],[i[n]]);return[e,h,g,f]}}),function(e){for(var n=0;n<e.length;n++)!function(e){t.fn[e]=function(n,r){var o=this;return r?(setTimeout((function(){r.call(o,t.fn[e].call(o,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,o=t.utils.isArray;function i(t,n,r,o){if(t>1||r>1||t<=0||r<=0)throw new Error("Proportions should be greater than 0 and less than 1");var i=(t*n+r*o)/(n+o);return(t-r)/e.sqrt(i*(1-i)*(1/n+1/o))}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,i=n.call(arguments);return o(i[1])?(r=t.zscore(i[0],i[1],i[3]),1===i[2]?t.normal.cdf(-e.abs(r),0,1):2*t.normal.cdf(-e.abs(r),0,1)):i.length>2?(r=t.zscore(i[0],i[1],i[2]),1===i[3]?t.normal.cdf(-e.abs(r),0,1):2*t.normal.cdf(-e.abs(r),0,1)):(r=i[0],1===i[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,o){var i=e.abs(this.zscore(n,o));return 1===r?t.normal.cdf(-i,0,1):2*t.normal.cdf(-i,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 o,i=n.call(arguments);return 5===i.length?(o=e.abs(t.tscore(i[0],i[1],i[2],i[3])),1===i[4]?t.studentt.cdf(-o,i[3]-1):2*t.studentt.cdf(-o,i[3]-1)):r(i[1])?(o=e.abs(i[0]),1==i[2]?t.studentt.cdf(-o,i[1]-1):2*t.studentt.cdf(-o,i[1]-1)):(o=e.abs(t.tscore(i[0],i[1])),1==i[2]?t.studentt.cdf(-o,i[1].length-1):2*t.studentt.cdf(-o,i[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,o,i,a,s,u,c,l,h=n.call(arguments);if(1===h.length){for(s=new Array(h[0].length),c=0;c<h[0].length;c++)s[c]=h[0][c];h=s}for(o=new Array,c=0;c<h.length;c++)o=o.concat(h[c]);for(i=t.mean(o),r=0,c=0;c<h.length;c++)r+=h[c].length*e.pow(t.mean(h[c])-i,2);for(r/=h.length-1,u=0,c=0;c<h.length;c++)for(a=t.mean(h[c]),l=0;l<h[c].length;l++)u+=e.pow(h[c][l]-a,2);return r/(u/(o.length-h.length))},anovaftest:function(){var e,o,i,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,i=0,a=0;a<s.length;a++)i+=s[a].length;return o=i-e-1,1-t.centralF.cdf(u,e,o)},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 o,i,a,s,u,c=n.call(arguments);return r(c[0])?(o=c[0],i=c[1],a=c[2],s=c[3],u=c[4]):(o=t.mean(c[0]),i=t.mean(c[1]),a=c[0].length,s=c[1].length,u=c[2]),e.abs(o-i)/(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 o=r[0],i=r[1];return 1-t.tukey.cdf(e,i,o-i)},tukeyhsd:function(e){for(var n=t.pooledstdev(e),r=e.map((function(e){return t.mean(e)})),o=e.reduce((function(t,e){return t+e.length}),0),i=[],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,o,e.length);i.push([[a,s],u])}return i}}),t.extend({normalci:function(){var r,o=n.call(arguments),i=new Array(2);return r=4===o.length?e.abs(t.normal.inv(o[1]/2,0,1)*o[2]/e.sqrt(o[3])):e.abs(t.normal.inv(o[1]/2,0,1)*t.stdev(o[2])/e.sqrt(o[2].length)),i[0]=o[0]-r,i[1]=o[0]+r,i},tci:function(){var r,o=n.call(arguments),i=new Array(2);return r=4===o.length?e.abs(t.studentt.inv(o[1]/2,o[3]-1)*o[2]/e.sqrt(o[3])):e.abs(t.studentt.inv(o[1]/2,o[2].length-1)*t.stdev(o[2],!0)/e.sqrt(o[2].length)),i[0]=o[0]-r,i[1]=o[0]+r,i},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,o){var a=i(e,n,r,o);return t.ztest(a,1)},twoSidedDifferenceOfProportions:function(e,n,r,o){var a=i(e,n,r,o);return t.ztest(a,2)}})}(e,Math),e.models=function(){function t(t,n){var r=t.length,o=n[0].length-1,i=r-o-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)}))),h=e.sum(t.map((function(t,e){return Math.pow(t-s[e],2)}))),d=l+h;return{exog:n,endog:t,nobs:r,df_model:o,df_resid:i,coef:a,predict:s,resid:u,ybar:c,SST:d,SSE:l,SSR:h,R2:l/d}}function n(n){var r,o,i=(r=n.exog,o=r[0].length,e.arange(o).map((function(n){var i=e.arange(o).filter((function(t){return t!==n}));return t(e.col(r,n).map((function(t){return t[0]})),e.col(r,i))}))),a=Math.sqrt(n.SSR/n.df_resid),s=i.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),h=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:h}}return{ols:function(r,o){var i=t(r,o),a=n(i),s=function(t){var n,r,o,i=t.R2/t.df_model/((1-t.R2)/t.df_resid);return{F_statistic:i,pvalue:1-(n=i,r=t.df_model,o=t.df_resid,e.beta.cdf(n/(o/r+n),r/2,o/2))}}(i),u=1-(1-i.R2)*((i.nobs-1)/i.df_resid);return i.t=a,i.f=s,i.adjust_R2=u,i}}}(),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,o,i,a,s;if(t.cols()==n.rows()){if(n.rows()>1){for(a=[],r=0;r<t.rows();r++)for(a[r]=[],o=0;o<n.cols();o++){for(s=0,i=0;i<t.cols();i++)s+=t.toArray()[r][i]*n.toArray()[i][o];a[r][o]=s}return e(a)}for(a=[],r=0;r<t.rows();r++)for(a[r]=[],o=0;o<n.cols();o++){for(s=0,i=0;i<t.cols();i++)s+=t.toArray()[r][i]*n.toArray()[o];a[r][o]=s}return e(a)}},regress:function(t,n){var r=e.xtranspxinv(t),o=t.transpose(),i=e.matrixmult(e(r),o);return e.matrixmult(i,n)},regresst:function(t,n,r){var o=e.regress(t,n),i={anova:{}},a=e.jMatYBar(t,o);i.yBar=a;var s=n.mean();i.anova.residuals=e.residuals(n,a),i.anova.ssr=e.ssr(a,s),i.anova.msr=i.anova.ssr/(t[0].length-1),i.anova.sse=e.sse(n,a),i.anova.mse=i.anova.sse/(n.length-(t[0].length-1)-1),i.anova.sst=e.sst(n,s),i.anova.mst=i.anova.sst/(n.length-1),i.anova.r2=1-i.anova.sse/i.anova.sst,i.anova.r2<0&&(i.anova.r2=0),i.anova.fratio=i.anova.msr/i.anova.mse,i.anova.pvalue=e.anovaftest(i.anova.fratio,t[0].length-1,n.length-(t[0].length-1)-1),i.anova.rmse=Math.sqrt(i.anova.mse),i.anova.r2adj=1-i.anova.mse/i.anova.mst,i.anova.r2adj<0&&(i.anova.r2adj=0),i.stats=new Array(t[0].length);for(var u,c,l,h=e.xtranspxinv(t),d=0;d<o.length;d++)u=Math.sqrt(i.anova.mse*Math.abs(h[d][d])),c=Math.abs(o[d]/u),l=e.ttest(c,n.length-t[0].length-1,r),i.stats[d]=[o[d],u,c,l];return i.regress=o,i},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),o=0;o<t.length;o++){r[o]=new Array(t[o].length);for(var i=0;i<t[o].length;i++)r[o][i]=t[o][i]-n[o][i]}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 o=void 0!==n.layer;o&&(r+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),r+=n.css,o&&(r+="}"),n.media&&(r+="}"),n.supports&&(r+="}");var i=n.sourceMap;i&&"undefined"!=typeof btoa&&(r+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(i))))," */")),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),o=n.n(r),i=n(6314),a=n.n(i)()(o());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 o=function(e){return r(e[t])},i=function(){return r(void 0)};return"string"==typeof t?(n.fromAttributes=o,n.fromGraph=function(t,e){return o(t.getEdgeAttributes(e))},n.fromEntry=function(t,e){return o(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 o=e.extremities(n);return r(t(n,e.getEdgeAttributes(n),o[0],o[1],e.getNodeAttributes(o[0]),e.getNodeAttributes(o[1]),e.isUndirected(n)))},n.fromEntry=function(e,n,o,i,a,s,u){return r(t(e,n,o,i,a,s,u))},n.fromPartialEntry=function(e,n,o,i){return r(t(e,n,o,i))},n.fromMinimalEntry=function(e,n){return r(t(e,n))}):(n.fromAttributes=i,n.fromGraph=i,n.fromEntry=i,n.fromMinimalEntry=i),n}(t,n)}},8903:(t,e,n)=>{var r=n(1736),o=n(8153).Fd,i=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=o("getEdgeWeight"in n?n.getEdgeWeight:"weight").fromEntry,l="function"==typeof n.outputReducer?n.outputReducer:null,h=a.assign({},s,n.settings),d=a.validateSettings(h);if(d)throw new Error("graphology-layout-forceatlas2: "+d.message);var f,p=a.graphToByteArrays(e,c);for(f=0;f<u;f++)i(h,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 o=e[r];if(void 0!==o)return o.exports;var i=e[r]={id:r,loaded:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.loaded=!0,i.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 o=r.length-1;o>-1&&(!t||!/^http(s?):/.test(t));)t=r[o--].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:()=>oo,MCLClustering:()=>io,MVA:()=>co,PCA:()=>Zr,PLS:()=>so,_package:()=>Kr,anova:()=>Po,applyLinearKernelSVM:()=>fo,applyLinearRegression:()=>Do,applyPLSRegression:()=>jo,applyPolynomialKernelSVM:()=>Co,applyRBFkernelSVM:()=>vo,applySigmoidKernelSVM:()=>Mo,applySoftmax:()=>Bo,applyXGBooster:()=>Ko,dbScan:()=>Qr,dbscanPostProcessingFunction:()=>to,demoMultivariateAnalysis:()=>lo,info:()=>Xr,init:()=>Jr,isApplicableLinearKernelSVM:()=>po,isApplicableLinearRegression:()=>Uo,isApplicablePLSRegression:()=>zo,isApplicablePolynomialKernelSVM:()=>_o,isApplicableRBFkernelSVM:()=>wo,isApplicableSigmoidKernelSVM:()=>To,isApplicableSoftmax:()=>Vo,isApplicableXGBooster:()=>Jo,isInteractiveLinearKernelSVM:()=>mo,isInteractiveLinearRegression:()=>ko,isInteractivePLSRegression:()=>Yo,isInteractivePolynomialKernelSVM:()=>So,isInteractiveRBFkernelSVM:()=>bo,isInteractiveSigmoidKernelSVM:()=>Oo,isInteractiveSoftmax:()=>Wo,isInteractiveXGBooster:()=>Xo,kNNImputation:()=>xo,kNNImputationForTable:()=>Ro,markovClusteringViewer:()=>ao,numberPreprocessingFunction:()=>eo,reduceDimensionality:()=>ro,stringPreprocessingFunction:()=>no,topMenuPLS:()=>uo,trainLinearKernelSVM:()=>ho,trainLinearRegression:()=>Fo,trainPLSRegression:()=>Ho,trainPolynomialKernelSVM:()=>Ao,trainRBFkernelSVM:()=>yo,trainSigmoidKernelSVM:()=>Io,trainSoftmax:()=>Go,trainXGBooster:()=>$o,visualizeLinearKernelSVM:()=>go,visualizePLSRegression:()=>qo,visualizePolynomialKernelSVM:()=>No,visualizeRBFkernelSVM:()=>Eo,visualizeSigmoidKernelSVM:()=>Lo});const t=grok,e=ui,o=DG,i={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[i[e]];let o=null;const u=this.data;o="int"==u.type&&"i32"==e||"double"==u.type&&"f32"==e?u.getRawData():new a[e](u.getRawData()),o&&r.set(o,this.buf>>n)}}getDataFromBuffer(t){if(this.toUpdate&&this.isMemoryForBufferAllocated()){const e=this.type,n=t[i[e]],r=this.buf,o=a[e].BYTES_PER_ELEMENT,s=this.data.getRawData();for(let t=0;t<this.numOfRows;t++)s[t]=n[r/o+t]}}freeBuffer(t){this.isMemoryForBufferAllocated()&&(t._free(this.buf),this.buf=0)}}class h 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[i[e]],r=this.buf,o=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=o("name",s)}}}class d 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[i[e]],o=a[e].BYTES_PER_ELEMENT;for(let t=0;t<this.numOfColumns;t++){let i=null;const s=this.data[t];i="int"==s.type&&"i32"==e||"double"==s.type&&"f32"==e?s.getRawData():new a[e](s.getRawData()),null!=i&&r.set(i,this.buf+t*this.numOfRows*o>>n)}}}getDataFromBuffer(t){if(this.toUpdate&&this.isMemoryForBufferAllocated()){const e=this.type,n=t[i[e]],r=this.numOfRows,o=this.numOfColumns,s=new a[e](n.buffer,this.buf,r*o);for(let t=0;t<o;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 d{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[i[e]],r=this.numOfRows,o=this.numOfColumns,s=a[e].BYTES_PER_ELEMENT,c=u[e],l=this.buf;for(let t=0;t<o;t++){const o=new a[e](r);for(let e=0;e<r;e++)o[e]=n[l/s+e+t*r];this.data.push(c((t+1).toString(),o))}}}}const p={intColumn:t=>new l(t,"i32"),newIntColumn:t=>new h("i32",t),intColumns:t=>new d(t.toList(),"i32"),newIntColumns:(t,e)=>new f("i32",t,e),floatColumn:t=>new l(t,"f32"),newFloatColumn:t=>new h("f32",t),floatColumns:t=>new d(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],o=r.arguments,i=[];let a=0;for(const t in o){const e=o[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=o[e.numOfRows.ref].data[e.numOfRows.value],r=o[e.numOfColumns.ref].data[e.numOfColumns.value];e.data=p[e.type](t,r);break;case"newFloatColumn":case"newIntColumn":const i=o[e.numOfRows.ref].data[e.numOfRows.value];e.data=p[e.type](i)}i.push(o[t].data)}}const s=function(t,e,n,r){let o;for(const e of r)e.allocateMemoryForBuffer(t);let i=!0;for(const t of r)i&=t.isMemoryForBufferAllocated();if(i){const n=[],i=[];for(const e of r)e.complementArrOfParams(n),e.complementArrOfTypes(i),e.putDataToBuffer(t);const a="number";o=t.ccall(e,a,i,n);for(const e of r)e.getDataFromBuffer(t)}for(const e of r)e.freeBuffer(t);if(null!=o)return o}(t,e,0,i);o._callResult=p.num(s);const u=r.output;if("objects"!=u.type)return m[u.type](o[u.source].data);const c=[];for(const t of u.source)c.push(o[t].data.data);return c}const y="num",v="floatColumn",w="intColumn",b="floatColumns",E="newFloatColumns",A="intColumns",C="newIntColumns",_="newFloatColumn",S="newIntColumn",N="column",I="_callResult",M="numOfRows",T="numOfColumns",O="ref",L="value",P="tableFromColumns",x="objects",R="int",F="double",D={intColumn:Int32Array,floatColumn:Float32Array,floatColumns:Float32Array,newFloatColumns:Float32Array,intColumns:Int32Array,newIntColumns:Int32Array,newFloatColumn:Float32Array,newIntColumn:Int32Array};function U(t,e){let n,r=[],o=0;for(const i in t){const a=t[i],s=a.type;if(i!==I){switch(s){case y:case R:case F:a.data=e[o],o++;break;case w:case v:let r;const i=e[o],u=i.length;r=i.type===R&&s===w||i.type===F&&s===v?i.getRawData().slice(0,u):new D[s](i.getRawData().slice(0,u)),a.data={array:r,numOfRows:u},o++;break;case S:case _:let c=0;n=a[M][O],c=t[n].type===y?t[n].data:t[n].data[a[M][L]],a.data={numOfRows:c},o++;break;case A:case b:let l=[];const h=e[o].byIndex(0).length;for(const t of e[o].toList())t.type===R&&s===w||t.type===F&&s===v?l.push(t.getRawData().slice(0,h)):l.push(new D[s](t.getRawData().slice(0,h)));a.data={arrays:l,numOfRows:h,numOfColumns:l.length},o++;break;case C:case E:let d=0,f=0;n=a[M][O],d=t[n].type===y?t[n].data:t[n].data[a[M][L]],n=a[T][O],f=t[n].type===y?t[n].data:t[n].data[a[T][L]],a.data={numOfRows:d,numOfColumns:f},o++;break;default:return}r.push(a)}}return r}function k(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 o in t){const i=t[o];switch(i.type){case y:case R:case F:case w:case v:case b:case A:break;case _:case S:let t;null==i.name?t=(0).toString():s=i.name,i.column=n[i.type](t,e[r].array);break;case C:case E:let o=[],a=e[r].arrays.length,s=[];if(null==i.names)for(let t=1;t<=a;t++)s.push(t.toString());else s=i.names;for(let t=0;t<a;t++)o.push(n[i.type](s[t],e[r].arrays[t]));i.columns=o}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 R:case F:return t.arguments[e.source];case N:return t.arguments[e.source].column;case P:return DG.DataFrame.fromColumns(t.arguments[e.source].columns);case x:let r=[];for(let o of e.source){let e=t.arguments[o];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 R:case F:case w:case v:case A:case b:break;case S:case _:n.column=null;break;case C:case E:n.columns=null}}}(t.arguments),n}async function G(t,e,r){return new Promise(((t,o)=>{const i=new Worker(new URL(n.p+n.u(128),n.b));i.postMessage(U(EDA.principalComponentAnalysisNipals.arguments,[e,r])),i.onmessage=function(e){i.terminate(),t(k(EDA.principalComponentAnalysisNipals,e.data))}}))}const B=1,V=1e8,W=900,H=1e-6,j="components must be positive.",z="components must not be greater than features count.",q="dataframe is too big.",Y="unsupported column type: ";function $(t){if(t.type!=o.COLUMN_TYPE.FLOAT&&t.type!=o.COLUMN_TYPE.INT)throw new Error(Y+t.type)}function K(t){if(t.stats.missingValueCount>0)throw new Error(`The column '${t.name}' has missing values.`)}function X(t,e){if(function(t,e){if(e<B)throw new Error(j);if(e>t.length)throw new Error(z);for(const e of t)$(e),K(e)}(t,e),t.length*t.byIndex(0).length>V)throw new Error(q)}function J(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,o=n.getRawData();if(t>0)for(let n=0;n<e;++n)o[n]=(o[n]-r)/t;else for(let t=0;t<e;++t)o[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)>H){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)>H&&t>0){const r=n.getRawData();for(let n=0;n<e;++n)r[n]/=t}}return t}(t):t}var Q=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function s(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(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 Z=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function s(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(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 tt=0,et=1,nt=2,rt=3,ot=4,it=0,at=1,st=2,ut=3,ct=4,lt=5,ht=6,dt=7,ft=0,pt=1,mt=2,gt=3,yt=0,vt=0,wt=1,bt=0,Et=1,At=0,Ct=0,_t=0,St=0,Nt="gamma must be strictly positive.",It="sigma must be strictly positive.",Mt="c must be strictly positive.",Tt="d must be strictly positive.",Ot="incorrect kernel.",Lt="labels must be strings of two categories.",Pt="Labels",xt="predicted",Rt="correctness",Ft="Confusion matrix",Dt="mean",Ut="std dev",kt="alpha",Gt="weight",Bt="Gamma",Vt="Kernel",Wt="Kernel params",Ht="Kernel parameter 1",jt="Kernel parameter 2",zt="Features count",qt="Train samples count",Yt="Train error, %",$t=["linear","polynomial","RBF","sigmoid"],Kt="Sensitivity",Xt="Specificity",Jt="Balanced accuracy",Qt="Positive predicitve value",Zt="Negative predicitve value",te="prediction",ee=4,ne=3,re=2,oe=0,ie=1,ae=2,se=0,ue=1;function ce(t,e,r){return Z(this,void 0,void 0,(function*(){const i=e.columns;if(2!=r.categories.length)throw new Error(Lt);const a=o.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 Z(this,void 0,void 0,(function*(){!function(t){if(t.gamma<=At)throw new Error(Nt);switch(t.kernel){case tt:return;case nt:if(t.sigma<=Ct)throw new Error(It);return;case et:if(t.cParam<=_t)throw new Error(Mt);if(t.dParam<=St)throw new Error(Tt);return;case rt:return;default:throw new Error(Ot)}}(t);const i=[se,se];switch(t.kernel){case tt:break;case nt:i[yt]=t.sigma;break;case et:i[vt]=t.cParam,i[wt]=t.dParam;break;case rt:i[bt]=t.kappa,i[Et]=t.theta;break;default:throw new Error(Ot)}const a=o.Column.fromList("double",Wt,i),s=e.toList(),u=s[0].length+ue,c=s.length+ue,l=ot;let h;const d=async function(t,e,r,o,i,a,s,u){return new Promise(((c,l)=>{const h=new Worker(new URL(n.p+n.u(656),n.b));h.postMessage(U(EDA.trainAndAnalyzeLSSVM.arguments,[t,e,r,o,i,a,s,u])),h.onmessage=function(t){h.terminate(),c(k(EDA.trainAndAnalyzeLSSVM,t.data))}}))}(t.gamma,t.kernel,a,u,c,l,e,r);yield d.then((t=>{h=t}),(t=>{throw new Error(`Error: ${t}`)})),h[at].name=Dt,h[st].name=Ut,h[ut].name=kt,h[ct].name=Gt,h[lt].name=xt,h[ht].name=Rt,h[dt].name=Ft;const f={trainGamma:t.gamma,kernelType:t.kernel,kernelParams:a,trainLabels:r,normalizedTrainData:o.DataFrame.fromColumns(h[it]),means:h[at],stdDevs:h[st],modelParams:h[ut],modelWeights:h[ct],predictedLabels:h[lt],correctness:h[ht],confusionMatrix:h[dt],trainError:void 0,featuresCount:s.length,trainSamplesCount:s[0].length};return function(t){const e=t.confusionMatrix.getRawData(),n=e[ft],r=e[gt],o=e[mt],i=e[pt],a=n+i,s=o+r,u=n/a,c=r/s,l=n/(n+o),h=r/(r+i),d=(n+r)/(a+s),f=(u+c)/2;t.sensitivity=u,t.specificity=c,t.balancedAccuracy=f,t.positivePredicitveValue=l,t.negativePredicitveValue=h,t.trainError=100*(1-d)}(f),f}))}(t,i,a);return s.realLabels=r,s}))}function le(t,e){const n=de(e);return o.Viewer.form(n.modelInfo,{showNavigation:!1}).root}function he(t){const e=t.normalizedTrainData.columns,n=t.trainSamplesCount,r=t.featuresCount,i=o.DataFrame.fromColumns([t.realLabels]).toByteArray(),a=ee+i.length+4-i.length%4,s=function(t){const e=t.kernelParams.getRawData();return o.DataFrame.fromColumns([o.Column.fromList("double",Bt,[t.trainGamma]),o.Column.fromStrings(Vt,[$t[t.kernelType]]),o.Column.fromList("double",Ht,[e[0]]),o.Column.fromList("double",jt,[e[1]]),o.Column.fromList("double",zt,[t.featuresCount]),o.Column.fromList("double",qt,[t.trainSamplesCount]),o.Column.fromList("double",Yt,[t.trainError]),o.Column.fromList("double",Jt,[t.balancedAccuracy]),o.Column.fromList("double",Kt,[t.sensitivity]),o.Column.fromList("double",Xt,[t.specificity]),o.Column.fromList("double",Qt,[t.positivePredicitveValue]),o.Column.fromList("double",Zt,[t.negativePredicitveValue])])}(t).toByteArray(),u=ee+s.length+4-s.length%4,c=new Uint8Array(ee*(ne+re+n+r+r+n+ue+r+ue+r*n)+a+u),l=c.buffer;let h=0,d=new Int32Array(l,h,ne);d[oe]=t.kernelType,d[ie]=n,d[ae]=r,h+=ne*ee;let f=new Float32Array(l,h,re);f.set(t.kernelParams.getRawData()),h+=re*ee,f=new Float32Array(l,h,n),f.set(t.trainLabels.getRawData()),h+=n*ee,f=new Float32Array(l,h,r),f.set(t.means.getRawData()),h+=r*ee,f=new Float32Array(l,h,r),f.set(t.stdDevs.getRawData()),h+=r*ee,f=new Float32Array(l,h,n+ue),f.set(t.modelParams.getRawData()),h+=(n+ue)*ee,f=new Float32Array(l,h,r+ue),f.set(t.modelWeights.getRawData()),h+=(r+ue)*ee;for(const t of e)f=new Float32Array(l,h,r),f.set(t.getRawData()),h+=r*ee;return d=new Int32Array(l,h,1),d[0]=i.length,c.set(i,h+ee),h+=a,d=new Int32Array(l,h,1),d[0]=s.length,c.set(s,h+ee),h+=u,c}function de(t){const e=t.buffer;let n=0;const r=new Int32Array(e,n,ne);n+=ne*ee;const i=r[ie],a=r[ae],s=o.Column.fromFloat32Array(Wt,new Float32Array(e,n,re));n+=re*ee;const u=o.Column.fromFloat32Array(Pt,new Float32Array(e,n,i));n+=i*ee;const c=o.Column.fromFloat32Array(Dt,new Float32Array(e,n,a));n+=a*ee;const l=o.Column.fromFloat32Array(Ut,new Float32Array(e,n,a));n+=a*ee;const h=o.Column.fromFloat32Array(kt,new Float32Array(e,n,i+ue));n+=(i+ue)*ee;const d=o.Column.fromFloat32Array(Gt,new Float32Array(e,n,a+ue));n+=(a+ue)*ee;const f=[];for(let t=0;t<i;t++)f.push(o.Column.fromFloat32Array(t.toString(),new Float32Array(e,n,a))),n+=a*ee;const p=o.DataFrame.fromColumns(f),m=new Int32Array(e,n,1)[0],g=m+4-m%4;n+=ee;const y=o.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+=ee;const b=o.DataFrame.fromByteArray(new Uint8Array(e,n,v));return n+=w,{kernelType:r[oe],kernelParams:s,trainLabels:u,realLabels:y,means:c,stdDevs:l,modelParams:h,modelWeights:d,normalizedTrainData:p,modelInfo:b}}function fe(t,e){return Z(this,void 0,void 0,(function*(){const r=de(new Uint8Array(e)),i=yield function(t,e){return Z(this,void 0,void 0,(function*(){let r;const o=async function(t,e,r,o,i,a,s,u,c){return new Promise(((l,h)=>{const d=new Worker(new URL(n.p+n.u(763),n.b));d.postMessage(U(EDA.predictByLSSVM.arguments,[t,e,r,o,i,a,s,u,c])),d.onmessage=function(t){d.terminate(),l(k(EDA.predictByLSSVM,t.data))}}))}(t.kernelType,t.kernelParams,t.normalizedTrainData.columns,t.trainLabels,t.means,t.stdDevs,t.modelParams,t.modelWeights,e);return yield o.then((t=>{r=t}),(t=>{throw new Error(`Error: ${t}`)})),r}))}(r,t.columns),a=o.Column.string(te,i.length),s=r.realLabels.categories;for(let t=0;t<a.length;t++)a.set(t,-1==i.get(t)?s[0]:s[1]);return o.DataFrame.fromColumns([a])}))}function pe(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 me(t,e){return t.rowCount<=1e3}var ge,ye,ve,we,be,Ee,Ae,Ce;!function(t){t[t.COMPUTE_COMPONENTS=0]="COMPUTE_COMPONENTS",t[t.PERFORM_MVA=1]="PERFORM_MVA",t[t.DEMO=2]="DEMO"}(ge||(ge={})),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"}(ye||(ye={})),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"}(ve||(ve={})),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"}(we||(we={})),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"}(be||(be={})),function(t){t[t.DEFAULT=3]="DEFAULT",t[t.MIN=1]="MIN"}(Ee||(Ee={})),function(t){t.PREFIX="PLS",t.SUFFIX="(predicted)",t.COMP="component",t.COMPS="components"}(Ae||(Ae={})),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"}(Ce||(Ce={}));const _e="Int",Se=6,Ne=[.49,.79,.99],Ie=1,Me=200,Te=200;var Oe;!function(t){t.AXIS="#838383",t.CIRCLE="#0000FF"}(Oe||(Oe={}));const Le="# 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",Pe=[{caption:ve.MODEL,text:"Closer to the line means better price prediction."},{caption:ve.SCORES,text:"The latent factor values for each sample reflect the similarities and dissimilarities among observations."},{caption:ve.LOADINGS,text:"The impact of each feature on the latent factors: higher loading means stronger influence."},{caption:ve.REGR_COEFS,text:"Parameters of the obtained linear model: features make different contribution to the prediction."},{caption:ve.EXPL_VAR,text:"How well the latent components fit source data: closer to one means better fit."}],xe=Pe.map((t=>`# ${t.caption}\n\n${t.text}`)).join("\n\n")+`\n\n# Learn more\n \n * [Multivariate analysis](${be.MVA}),\n * [ANOVA](https://datagrok.ai/help/explore/anova)`;var Re=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function s(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(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 Fe=Math.min,De=Math.max;function Ue(t){const e=[],n=(t,n)=>{e.push({type:"line",formula:t,width:Ie,visible:!0,title:" ",min:-n,max:n,color:Oe.CIRCLE})};return t.forEach((r=>{const o="${"+r+"}";e.push({type:"line",formula:`${o} = 0`,width:Ie,visible:!0,title:" ",color:Oe.AXIS}),t.forEach((t=>{const e="${"+t+"}";Ne.forEach((t=>{n(e+` = sqrt(${t*t} - ${o} * ${o})`,t),n(e+` = -sqrt(${t*t} - ${o} * ${o})`,t)}))}))})),e}function ke(t){return Re(this,void 0,void 0,(function*(){X(t.features,t.components),$(t.predict),K(t.predict);const e=yield async function(t,e,r,o){return new Promise(((t,i)=>{const a=new Worker(new URL(n.p+n.u(412),n.b));a.postMessage(U(EDA.partialLeastSquareRegression.arguments,[e,r,o])),a.onmessage=function(e){a.terminate(),t(k(EDA.partialLeastSquareRegression,e.data))}}))}(t.table,t.features,t.predict,t.components);return{prediction:e[Ce.PREDICTION],regressionCoefficients:e[Ce.REGR_COEFFS],tScores:e[Ce.T_SCORES],uScores:e[Ce.U_SCORES],xLoadings:e[Ce.X_LOADINGS],yLoadings:e[Ce.Y_LOADINGS]}}))}function Ge(n){return Re(this,void 0,void 0,(function*(){const r=t.shell.t;if(null===r)return void t.shell.warning(ye.NO_DF);if(0===r.rowCount)return void t.shell.warning(ye.EMPTY_DF);const i=[],a=[],s=[],u=t=>(t.type===o.COLUMN_TYPE.INT||t.type===o.COLUMN_TYPE.FLOAT)&&0===t.stats.missingValueCount;if(r.columns.toList().forEach((t=>{u(t)?(i.push(t.name),a.push(t)):t.type===o.COLUMN_TYPE.STRING&&s.push(t)})),0===i.length)return void t.shell.warning(ye.NO_COLS);if(1===i.length)return void t.shell.warning(ye.ONE_COL);let c=a[a.length-1];const l=e.input.column(ve.PREDICT,{table:r,value:c,onValueChanged:t=>{c=t,v()},filter:t=>u(t)});let h;l.setTooltip(we.PREDICT);const d=e.input.columns(ve.USING,{table:r,available:i});d.onInput.subscribe((()=>v())),d.setTooltip(we.FEATURES);let f=Fe(i.length-1,Ee.DEFAULT);const p=e.input.forProperty(o.Property.fromOptions({name:ve.COMPONENTS,inputType:_e,defaultValue:f,showPlusMinus:!0,min:Ee.MIN}));let m,g,y;p.onInput.subscribe((()=>v())),p.setTooltip(we.COMPONENTS),n===ge.COMPUTE_COMPONENTS?(m=ve.PLS,g=be.PLS,y=we.PLS):(m=ve.MVA,g=be.MVA,y=we.MVA);const v=()=>{var t;d.value=d.value.filter((t=>t!==c)),h=d.value,p.value=Fe(De(null!==(t=p.value)&&void 0!==t?t:f,Ee.MIN),h.length),f=p.value,E.getButton(ve.RUN).disabled=0===h.length||f<=0};let w=s.length>0?s[0]:void 0;const b=e.input.column(ve.NAMES,{table:r,value:w,onValueChanged:t=>w=null!=t?t:void 0,filter:t=>t.type===o.COLUMN_TYPE.STRING});b.setTooltip(we.NAMES),b.root.hidden=0===s.length||n===ge.COMPUTE_COMPONENTS;const E=e.dialog({title:m,helpUrl:g}).add(e.form([l,d,p,b])).addButton(ve.RUN,(()=>Re(this,void 0,void 0,(function*(){E.close(),yield function(n,r){return Re(this,void 0,void 0,(function*(){var i,a;const s=yield ke(n),u=s.tScores,c=n.table.columns,l=n.features,h=l.names(),d=r===ge.COMPUTE_COMPONENTS?Ae.PREFIX:ve.XSCORE;if(u.forEach(((t,e)=>{t.name=c.getUnusedName(`${d}${e+1}`),c.add(t)})),r===ge.COMPUTE_COMPONENTS)return;const f=t.shell.tableView(n.table.name),p=o.DataFrame.fromColumns([o.Column.fromStrings(ve.FEATURE,h),s.regressionCoefficients]);p.name=`${n.table.name}(${ve.ANALYSIS})`,t.shell.addTable(p),s.xLoadings.forEach(((t,e)=>{t.name=p.columns.getUnusedName(`${ve.XLOADING}${e+1}`),p.columns.add(t)}));const m=function(t,e,n,r){const i=n.length,a=t.length,s=e.getRawData(),u=new Float32Array(i),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<i;++t)u[t]=l+c[t];return o.Column.fromFloat32Array("Debiased",u,i)}(l,s.regressionCoefficients,n.predict,s.prediction);m.name=c.getUnusedName(`${n.predict.name} ${Ae.SUFFIX}`),c.add(m);const g=f.addViewer(o.Viewer.scatterPlot(n.table,{title:ve.MODEL,xColumnName:n.predict.name,yColumnName:m.name,showRegressionLine:!0,markerType:o.MARKER_TYPE.CIRCLE,showLabels:"Always",help:be.MODEL}));void 0!==n.names&&null!==n.names&&g.setOptions({labelColumnNames:[null===(i=n.names)||void 0===i?void 0:i.name]}),s.regressionCoefficients.name=ve.REGR_COEFS;const y=f.addViewer(o.Viewer.barChart(p,{table:p.name,title:ve.REGR_COEFS,splitColumnName:ve.FEATURE,valueColumnName:s.regressionCoefficients.name,valueAggrType:o.AGG.AVG,help:be.COEFFS,showValueSelector:!1,showStackSelector:!1}));s.xLoadings.forEach(((t,e)=>t.name=`${ve.XLOADING}${e+1}`));const v=f.addViewer(o.Viewer.scatterPlot(p,{table:p.name,title:ve.LOADINGS,xColumnName:`${ve.XLOADING}1`,yColumnName:`${ve.XLOADING}${s.xLoadings.length>1?"2":"1"}`,markerType:o.MARKER_TYPE.CIRCLE,labelColumnNames:[ve.FEATURE],help:be.LOADINGS})),w=u.map((t=>t.name));s.uScores.forEach(((t,e)=>{t.name=c.getUnusedName(`${ve.YSCORE}${e+1}`),c.add(t),w.push(t.name)}));const b=o.Viewer.scatterPlot(n.table,{title:ve.SCORES,xColumnName:u[0].name,yColumnName:u.length>1?u[1].name:s.uScores[0].name,markerType:o.MARKER_TYPE.CIRCLE,help:be.SCORES,showViewerFormulaLines:!0,labelColumnNames:void 0!==n.names&&null!==n.names?[null===(a=n.names)||void 0===a?void 0:a.name]:void 0});f.addViewer(b),b.meta.formulaLines.addAll(Ue(w));const E=s.yLoadings.getRawData(),A=s.xLoadings.map((t=>t.getRawData())),C=n.table.rowCount,_=h.length,S=n.components,N=new Float32Array(S),I=[],M=[];for(let t=0;t<_;++t)M.push(new Float32Array(S));N[0]=Math.pow(E[0],2)/C,I.push(`1 ${Ae.COMP}`),M.forEach(((t,e)=>{t[0]=Math.pow(A[0][e],2)/C}));for(let t=1;t<S;++t)N[t]=N[t-1]+Math.pow(E[t],2)/C,M.forEach(((e,n)=>e[t]=e[t-1]+Math.pow(A[t][n],2)/C)),I.push(`${t+1} ${Ae.COMPS}`);const T=o.DataFrame.fromColumns([o.Column.fromStrings(ve.COMPONENTS,I),o.Column.fromFloat32Array(n.predict.name,N)]);T.name=`${n.table.name}(${ve.EXPL_VAR})`,t.shell.addTable(T),M.forEach(((t,e)=>T.columns.add(o.Column.fromFloat32Array(h[e],t))));const O=f.addViewer(o.Viewer.barChart(T,{table:T.name,title:ve.EXPL_VAR,splitColumnName:ve.COMPONENTS,valueColumnName:n.predict.name,valueAggrType:o.AGG.AVG,help:be.EXPL_VARS,showCategorySelector:!1,showStackSelector:!1}));r===ge.DEMO&&(t.shell.windows.help.showHelp(e.markdown(xe)),function(t,n,r){if(t.length!==n.length)throw new Error("Non-equal size of viewer roots and descriptions");let o,i,a,s=0;const u=e.button("next",(()=>{a.remove(),++s,d()}),"Go to the next viewer"),c=e.button("prev",(()=>{s-=1,a.remove(),d()}),"Go to the previous viewer"),l=e.button("done",(()=>a.remove()),"Go to the next step"),h=e.divH([c,u,l]);h.style.marginLeft="auto",h.style.marginRight="0px";const d=()=>{s<t.length&&(i=e.divV([e.markdown(n[s]),h]),a=e.hints.addHint(t[s],i,r[s]),l.hidden=s<t.length-1,u.hidden=s===t.length-1,c.hidden=s<1,o=a.querySelector("i"),o.onclick=()=>l.click())};d()}([g,b,v,y,O].map((t=>t.root)),Pe.map((t=>`<b>${t.caption}</b>\n\n${t.text}`)),["left","left","right","right","left"]))}))}({table:r,features:o.DataFrame.fromColumns(h).columns,predict:c,components:f,names:w},n)}))),void 0,y).show({x:Me,y:Te});setTimeout((()=>{d.value=a.filter((t=>t!==c)),h=d.value}),Se),t.shell.v.append(E.root)}))}var Be,Ve=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"}(Be||(Be={}));const We="copy";var He;!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"}(He||(He={}));const je="/help/explore/missing-values-imputation#the-k-nn-method";var ze;!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"}(ze||(ze={}));const qe=15,Ye=[o.COLUMN_TYPE.INT,o.COLUMN_TYPE.FLOAT,o.COLUMN_TYPE.STRING,o.COLUMN_TYPE.DATE_TIME,o.COLUMN_TYPE.QNUM];function $e(t){switch(t.type){case o.COLUMN_TYPE.INT:return o.INT_NULL;case o.COLUMN_TYPE.FLOAT:case o.COLUMN_TYPE.QNUM:case o.COLUMN_TYPE.DATE_TIME:return o.FLOAT_NULL;case o.COLUMN_TYPE.STRING:return t.max;default:throw new Error(Be.UNSUPPORTED_COLUMN_TYPE)}}var Ke,Xe,Je;!function(t){t.ONE_HOT="One-hot",t.DIFFERENCE="Difference"}(Ke||(Ke={})),function(t){t.EUCLIDEAN="Euclidean",t.MANHATTAN="Manhattan"}(Xe||(Xe={})),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"}(Je||(Je={}));const Qe=1;function Ze(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(Be.FAILS_TO_PREDICT_IMPUTATION_FAILS);for(const r of t){let t=!0;for(const o of e){const e=n.get(o);if(void 0===e)throw new Error(Be.FAILS_TO_PREDICT_IMPUTATION_FAILS);if(!e.includes(r)){t=!1;break}}if(t)return!0}}return!1}var tn;function en(t){if(t<=0||t>=1)throw new Error(tn.INCORRECT_SIGNIFICANCE_LEVEL)}function nn(t){const e=t.size;return e<=1?0:(t.sumOfSquares-Math.pow(t.sum,2)/e)/(e-1)}function rn(t,e,n){en(n);const r=nn(t),o=nn(e);return 0===r||0===o?r===o:r/o<Ve.centralF.inv(1-n,t.size-1,e.size-1)}!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"}(tn||(tn={}));class on{constructor(t,e,n){if(this.nullsCount=0,t.length!==e.length)throw new Error(tn.NON_EQUAL_FACTORS_VALUES_SIZE);if(!(e.stats.stdev>0))throw new Error(tn.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(!rn(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,o=r;for(let i=0;i<r;++i)0!==this.subSampleSizes[i]?(t+=this.sums[i],e+=this.sumsOfSquares[i],n+=Math.pow(this.sums[i],2)/this.subSampleSizes[i]):--o;if(r=o,1===r)throw new Error(tn.SINGLE_FACTOR);const i=this.size-this.nullsCount;if(i===r)throw new Error(tn.CATS_EQUAL_SIZE);const a=e-Math.pow(t,2)/i,s=n-Math.pow(t,2)/i,u=a-s;if(0===u)throw new Error(tn.NO_FEATURE_VARIATION_WITHIN_GROUPS);const c=r-1,l=i-r,h=s/c,d=u/l,f=h/d;return{ssBn:s,ssWn:u,ssTot:a,dfBn:c,dfWn:l,dfTot:i-1,msBn:h,msWn:d,fStat:f,pValue:1-Ve.centralF.cdf(f,c,l)}}setStats(t,e,n){const r=e.type,i=e.length,a=$e(e);switch(r){case o.COLUMN_TYPE.INT:case o.COLUMN_TYPE.FLOAT:const r=n;this.catCount=r,this.size=i;const s=e.getRawData(),u=t.getRawData(),c=new Float64Array(r).fill(0),l=new Float64Array(r).fill(0),h=new Int32Array(r).fill(0);let d;if(t.type==o.COLUMN_TYPE.BOOL){let t=0,e=0,n=u[0];const r=8*u.BYTES_PER_ELEMENT-1;for(let o=0;o<i;++o)d=1&n>>e,s[o]!==a?(c[d]+=s[o],l[d]+=Math.pow(s[o],2),++h[d]):++this.nullsCount,++e,e>r&&(e=0,++t,n=u[t])}else{const e=t.stats.missingValueCount>0?$e(t):-1;for(let t=0;t<i;++t)d=u[t],d!==e&&s[t]!==a?(c[d]+=s[t],l[d]+=Math.pow(s[t],2),++h[d]):++this.nullsCount}this.sums=c,this.sumsOfSquares=l,this.subSampleSizes=h;break;default:throw new Error(tn.UNSUPPORTED_COLUMN_TYPE)}}}const an=[o.COLUMN_TYPE.INT,o.COLUMN_TYPE.FLOAT],sn=[o.COLUMN_TYPE.STRING,o.COLUMN_TYPE.BOOL],un="/help/explore/anova";var cn,ln;function hn(){const n=t.shell.t;if(null===n)return void t.shell.warning("No dataframe is opened");const r=n.columns,i=[],a=[];for(const t of r)an.includes(t.type)?a.push(t.name):sn.includes(t.type)&&i.push(t.name);const s=i.length;if(s<1)return void t.shell.warning(e.markdown(`No acceptable factor columns:\n\n - type: ${sn.join(", ")} \n - at least two categories`));let u=n.col(ln.FACTOR);if(null===u){let t,e=0,n=r.byName(i[0]).categories.length;for(let o=1;o<s;++o)t=r.byName(i[o]).categories.length,t<n&&(n=t,e=o);u=r.byName(i[e])}if(a.length<1)return void t.shell.warning(e.markdown(`No acceptable feature columns:\n \n - type: ${an.join(", ")}`));const c=e.input.column("Category",{table:n,value:u,tooltipText:"Column with factor values",onValueChanged:t=>u=t,filter:t=>i.includes(t.name),nullable:!1});let l=n.col(ln.FEATURE);null===l&&(l=r.byName(a[0]));const h=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 d=cn.DEFAULT;const f=e.input.float("Alpha",{min:cn.MIN,max:cn.MAX,value:d,nullable:!1,tooltipText:"Significance level",onValueChanged:t=>{d=t,g.disabled=d<=cn.INFIMUM||d>=cn.SUPREMUM}}),p=e.dialog({title:"ANOVA",helpUrl:un}),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){en(n);const o=t.stats.uniqueCount;if(o<2)throw new Error(tn.SINGLE_FACTOR);const i=new on(t,e,o);if(r&&!i.areVarsEqual(n))throw new Error(tn.NON_EQUAL_VARIANCES);const a=i.getOneWayAnova();return{anovaTable:a,fCritical:Ve.centralF.inv(1-n,a.dfBn,a.dfWn),significance:n}}(u,l,d);!function(n,r,i,a){const s=a.anovaTable.fStat>a.fCritical,u=s?`"${r}" affects the "${i}"`:`"${r}" doesn't affect the "${i}"`,c=t.shell.getTableView(n.name),l=o.Viewer.boxPlot(n,{categoryColumnNames:[r],valueColumnName:i,showPValue:!1,showStatistics:!1,description:u,showColorSelector:!1}),h=c.dockManager.dock(l.root,o.DOCK_TYPE.RIGHT,null,"ANOVA"),d=e.markdown(`**H0:** the "${r}" \n factor does not produce a significant difference in the "${i}" feature.`);e.tooltip.bind(d,"Null hypothesis");const f=e.markdown("**Test result:** "+(s?"means differ significantly.":"means do not differ significantly.")),p=s?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(f,(()=>p));const m=e.divV([d,f,e.link("Learn more",(()=>window.open("https://en.wikipedia.org/wiki/F-test","_blank")),"Click to open in a new tab")]);m.style.marginLeft="20px";const g=t.shell.dockManager.dock(m,o.DOCK_TYPE.DOWN,h,"F-test",.3),y=function(t){const n=t.anovaTable,r=o.Viewer.grid(o.DataFrame.fromColumns([o.Column.fromStrings("Source of variance",["Between groups","Within groups","Total"]),o.Column.fromList(o.COLUMN_TYPE.FLOAT,"SS",[n.ssBn,n.ssWn,n.ssTot]),o.Column.fromList(o.COLUMN_TYPE.INT,"DF",[n.dfBn,n.dfWn,n.dfTot]),o.Column.fromList(o.COLUMN_TYPE.FLOAT,"MS",[n.msBn,n.msWn,null]),o.Column.fromList(o.COLUMN_TYPE.FLOAT,"F",[n.fStat,null,null]),o.Column.fromList(o.COLUMN_TYPE.FLOAT,"F-critical",[t.fCritical,null,null]),o.Column.fromList(o.COLUMN_TYPE.FLOAT,"p-value",[n.pValue,null,null])])),i=new Map([["Source of variance","List of the explored variation sources"],["SS","Sum of squares (SS)"],["DF","Degrees of freedom (DF)"],["MS","Mean square (MS)"],["F","F-statistics (F)"],["F-critical",`${t.significance}-critical value of F-statistics (F)`],["p-value","Probability to obtain F-statistics (F) greater than the actual observation."]]);return r.onCellTooltip((function(t,n,r){if(t.isColHeader)return e.tooltip.show(e.divV([e.p(i.get(t.tableColumn.name))]),n,r),!0})),r.helpUrl=un,r}(a);t.shell.dockManager.dock(y.root,o.DOCK_TYPE.FILL,g,"Analysis")}(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(o.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(h).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"}(cn||(cn={})),function(t){t.FACTOR="race",t.FEATURE="age"}(ln||(ln={}));var dn=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function s(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(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 fn(t,e,r,o){return dn(this,void 0,void 0,(function*(){return new Promise((function(i,a){const s=new Worker(new URL(n.p+n.u(682),n.b));s.postMessage({embedX:t,embedY:e,minPts:o,epsilon:r}),s.onmessage=({data:{error:t,clusters:e}})=>{s.terminate(),t?a(t):i(e)}}))}))}n(5540);let pn=null;function mn(){return t=this,e=void 0,r=function*(){if(!navigator.gpu)return console.error("WebGPU is not supported in this browser"),null;if(!pn&&(pn=yield navigator.gpu.requestAdapter(),null==pn))return null;let t=null;return"info"in pn&&(t=pn.info),t?gn(t.description,gn(t.vendor,"No GPU description available")):"No GPU description available"},new((n=void 0)||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function s(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(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 gn(t,e){return t&&""!=t?t:e}var yn,vn,wn,bn,En,An,Cn,_n,Sn;(vn=yn||(yn={})).EUCLIDEAN="EUCLIDEAN",vn.MANHATTAN="MANHATTAN",yn.EUCLIDEAN,yn.MANHATTAN,(bn=wn||(wn={})).HAMMING="Hamming",bn.EUCLIDEAN="Euclidean",bn.VECTOR_COSINE="Vector Cosine",bn.MANHATTAN="Manhattan",bn.TANIMOTO="Tanimoto",bn.LEVENSTEIN="Levenshtein",bn.NEEDLEMAN_WUNSCH="Needlemann-Wunsch",bn.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance",bn.SOKAL="Sokal",bn.COSINE="Cosine",bn.ASYMMETRIC="Asymmetric",bn.Difference="Difference",bn.OneHot="One-Hot",wn.HAMMING,wn.EUCLIDEAN,wn.MANHATTAN,wn.VECTOR_COSINE,wn.TANIMOTO,wn.LEVENSTEIN,wn.NEEDLEMAN_WUNSCH,wn.MONOMER_CHEMICAL_DISTANCE,wn.SOKAL,wn.COSINE,wn.ASYMMETRIC,wn.Difference,wn.OneHot,wn.HAMMING,wn.EUCLIDEAN,wn.MANHATTAN,wn.TANIMOTO,wn.SOKAL,wn.COSINE,wn.ASYMMETRIC,wn.LEVENSTEIN,wn.NEEDLEMAN_WUNSCH,wn.MONOMER_CHEMICAL_DISTANCE,wn.Difference,wn.OneHot,wn.VECTOR_COSINE,new Set([wn.HAMMING,wn.LEVENSTEIN,wn.NEEDLEMAN_WUNSCH,wn.MONOMER_CHEMICAL_DISTANCE,wn.OneHot]),new Set([wn.HAMMING,wn.EUCLIDEAN,wn.MANHATTAN,wn.MONOMER_CHEMICAL_DISTANCE,wn.LEVENSTEIN,wn.NEEDLEMAN_WUNSCH,wn.TANIMOTO,wn.COSINE,wn.VECTOR_COSINE,wn.SOKAL,wn.ASYMMETRIC,wn.OneHot,wn.Difference]),new Set([wn.EUCLIDEAN,wn.MANHATTAN,wn.OneHot,wn.Difference,wn.VECTOR_COSINE]),new Set([wn.EUCLIDEAN,wn.MANHATTAN,wn.Difference,wn.VECTOR_COSINE]),new Set([wn.EUCLIDEAN,wn.MANHATTAN,wn.Difference]),new Set([wn.TANIMOTO,wn.COSINE,wn.SOKAL,wn.ASYMMETRIC]),function(t){t.ADD="ADD",t.SUB="SUB",t.MULT="MULT"}(En||(En={})),function(t){t.SQUARE="SQUARE",t.INVERSE="INVERSE",t.TRANSPOSE="TRANSPOSE",t.NORM="NORM",t.COLUMN_NORM="COLUMN_NORM"}(An||(An={})),function(t){t.SCALARMULT="SCALARMULT",t.SCALARADD="SCALARADD",t.SCALARPOW="SCALARPOW"}(Cn||(Cn={})),Object.prototype.toString,(Sn=_n||(_n={})).UMAP="UMAP",Sn.T_SNE="t-SNE",Promise.resolve(),n(934),n(8903);const Nn=2;o.SEMTYPE.MOLECULE,o.SEMTYPE.MACROMOLECULE;class In{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 Mn="bypassLargeDataWarning",Tn="show-scatterplot-progress";var On,Ln;(Ln=On||(On={})).EUCLIDEAN="EUCLIDEAN",Ln.MANHATTAN="MANHATTAN";const Pn=rxjs;var xn,Rn,Fn,Dn,Un,kn,Gn,Bn,Vn=n(5072),Wn=n.n(Vn),Hn=n(7825),jn=n.n(Hn),zn=n(7659),qn=n.n(zn),Yn=n(5056),$n=n.n(Yn),Kn=n(540),Xn=n.n(Kn),Jn=n(1113),Qn=n.n(Jn),Zn=n(7939),tr={};tr.styleTagTransform=Qn(),tr.setAttributes=$n(),tr.insert=qn().bind(null,"head"),tr.domAPI=jn(),tr.insertStyleElement=Xn(),Wn()(Zn.A,tr),Zn.A&&Zn.A.locals&&Zn.A.locals,function(t){t.Levenshtein="Levenshtein",t.JaroWinkler="Jaro-Winkler",t.Manhattan="Manhattan String",t.Onehot="One-Hot"}(xn||(xn={})),function(t){t.Euclidean="Euclidean",t.Manhattan="Manhattan",t.Cosine="Vector Cosine"}(Rn||(Rn={})),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"}(Fn||(Fn={})),function(t){t.TanimotoIntArray="TanimotoIntArray"}(Dn||(Dn={})),(Bn=Un||(Un={})).Vector="Vector",Bn.String="String",Bn.BitArray="BitArray",Bn.MacroMolecule="MacroMolecule",Bn.Number="Number",Bn.IntArray="IntArray",Bn.NumberArray="NumberArray",function(t){t.Difference="Difference"}(kn||(kn={})),function(t){t.CommonItems="Common Items"}(Gn||(Gn={}));const er=new Uint32Array(65536),nr=(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,o=1<<n-1;let i=-1,a=0,s=n,u=n;for(;u--;)er[t.charCodeAt(u)]|=1<<u;for(u=0;u<r;u++){let t=er[e.charCodeAt(u)];const n=t|a;t|=(t&i)+i^i,a|=~(t|i),i&=t,a&o&&s++,i&o&&s--,a=a<<1|1,i=i<<1|~(n|a),a&=n}for(u=n;u--;)er[t.charCodeAt(u)]=0;return s})(t,e):((t,e)=>{const n=e.length,r=t.length,o=[],i=[],a=Math.ceil(n/32),s=Math.ceil(r/32);for(let t=0;t<a;t++)i[t]=-1,o[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++)er[t.charCodeAt(e)]|=1<<e;for(let t=0;t<n;t++){const n=er[e.charCodeAt(t)],r=i[t/32|0]>>>t&1,u=o[t/32|0]>>>t&1,c=n|a,l=((n|u)&s)+s^s|n|u;let h=a|~(l|s),d=s&l;h>>>31^r&&(i[t/32|0]^=1<<t),d>>>31^u&&(o[t/32|0]^=1<<t),h=h<<1|r,d=d<<1|u,s=d|~(c|h),a=h&c}for(let e=c;e<l;e++)er[t.charCodeAt(e)]=0}let c=0,l=-1;const h=32*u,d=Math.min(32,r-h)+h;for(let e=h;e<d;e++)er[t.charCodeAt(e)]|=1<<e;let f=r;for(let t=0;t<n;t++){const n=er[e.charCodeAt(t)],a=i[t/32|0]>>>t&1,s=o[t/32|0]>>>t&1,u=n|c,h=((n|s)&l)+l^l|n|s;let d=c|~(h|l),p=l&h;f+=d>>>r-1&1,f-=p>>>r-1&1,d>>>31^a&&(i[t/32|0]^=1<<t),p>>>31^s&&(o[t/32|0]^=1<<t),d=d<<1|a,p=p<<1|s,l=p|~(u|d),c=d&u}for(let e=h;e<d;e++)er[t.charCodeAt(e)]=0;return f})(t,e)};var rr=n(944);class or{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=or._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 or(t._length);n._length=t._length,n._data=or._createBuffer(n._length),n._version=0;const r=t.lengthInInts;for(let o=0;o<r;o++)n._data[o]=t._data[o]&e._data[o];return n}static _createBuffer(t){return new Uint32Array(Math.floor((t+31)/32))}static fromValues(t){const e=new or(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 or(t);for(let r=0;r<t;++r)n.setBit(r,e(r));return n._version=0,n}static fromString(t){return or.fromSeq(t.length,(e=>"1"==t.charAt(e)))}static fromUint32Array(t,e){const n=new or(t);return n._data=e,n}static fromBytes(t){const e=t.length,n=new or(8*e);n._data=new Uint32Array(Math.floor((e+3)/4)),n._length=8*e;let r=0,o=0;for(;e-o>=4;)n._data[r++]=255&t[o]|(255&t[o+1])<<8|(255&t[o+2])<<16|(255&t[o+3])<<24,o+=4;return e-o==3&&(n._data[r]=(255&t[o+2])<<16),e-o==2&&(n._data[r]|=(255&t[o+1])<<8),e-o==1&&(n._data[r]|=255&t[o]),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 or(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,o=!0){if(n&&o&&this.setAll(!e,!1),o)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 or.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 o=Math.min(t,e),i=Math.max(t,e);if(n)for(let t=o;t<=i;t++)this.setTrue(t);else for(let t=o;t<=i;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+=or._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+=or._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 o=0;for(;o<r-1;o++)for(let e=this._data[o]&t._data[o];0!=e;e>>>=8)n+=or._onBitCount[255&e];let i=this._data[o]&t._data[o];const a=31&this._length;for(0!=a&&(i&=~(4294967295<<a));0!=i;i>>>=8)n+=or._onBitCount[255&i];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 o=Math.floor(t/32);o<r;o++){let r=e?this._data[o]:~this._data[o];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=or._firstOnBit[255&r];if(n>=0)return(t=n+32*o+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=or._lastOnBit[t>>>24];if(n>=0)return n+32*r+e}}return-1}}function ir(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,o=new Float32Array((n.length+r)*(n.length+r));return Object.entries(e).forEach((([t,r])=>{const i=n[r];Object.entries(e).forEach((([e,r])=>{o[t.charCodeAt(0)*n.length+e.charCodeAt(0)]=i[r]}))})),(t,e)=>1-o[t.charCodeAt(0)*n.length+e.charCodeAt(0)]}(),n=t?.threshold??0;return(t,r)=>{let o=0;const i=t.length,a=r.length,s=Math.ceil(Math.max(i,a)*(1-n));i!==a&&(o=Math.abs(i-a));let u=0;for(let n=0;n<Math.min(i,a);n++)if(t[n]!==r[n]&&(u+=e(t[n],r[n]),u>s))return 1;return u+=o,u/=Math.max(i,a),u}}or._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]),or._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]),or._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 ar={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 sr;!function(t){t.HAMMING="Hamming",t.LEVENSHTEIN="Levenshtein",t.NEEDLEMANN_WUNSCH="Needlemann-Wunsch",t.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance"}(sr||(sr={}));const ur={[sr.HAMMING]:ir,[sr.LEVENSHTEIN]:function(){return(t,e)=>nr(t,e)/Math.max(t.length,e.length)},[sr.NEEDLEMANN_WUNSCH]:function(t){const e=new Uint16Array(65536),{gapOpen:n,gapExtend:r,scoringMatrix:o,alphabetIndexes:i}={...ar,...t};Object.entries(i).forEach((([t,n])=>e[t.charCodeAt(0)]=n));const a=[new Float32Array(1e4),new Float32Array(1e4)];return(t,i)=>{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 h=1;h<i.length+1;h++){a[l][0]=-r-(h-1)*r;for(let d=1;d<t.length+1;d++){const f=a[c][d-1]+o[e[t.charCodeAt(d-1)]][e[i.charCodeAt(h-1)]],p=a[c][d]-(s[d]||1===h||h===i.length?r:n),m=a[l][d-1]-(u[d-1]||1===d||d===t.length?r:n);a[l][d]=Math.max(f,m,p),a[l][d]===f?(s[d]=!1,u[d]=!1):a[l][d]===m?(s[d]=!1,u[d]=!0):(s[d]=!0,u[d]=!1)}c=l,l=(l+1)%2}const h=Math.min(t.length,i.length);return(h-a[c][t.length])/h}},[sr.MONOMER_CHEMICAL_DISTANCE]:ir};function cr(t,e){const n=t.trueCount()+e.trueCount();if(0==n)return 1;const r=t.andWithCountBits(e,!0);return r/(n-r)}function lr(t){return t<=0?3402823e32:1/t-1}Fn.Tanimoto,Fn.Dice,Fn.Asymmetric,Fn.BraunBlanquet,Fn.Cosine,Fn.Kulczynski,Fn.McConnaughey,Fn.RogotGoldberg,Fn.Russel,Fn.Sokal,Fn.Hamming,Fn.Euclidean,Fn.Tanimoto,Fn.Dice,Fn.Asymmetric,Fn.BraunBlanquet,Fn.Cosine,Fn.Kulczynski,Fn.McConnaughey,Fn.RogotGoldberg,Fn.Russel,Fn.Sokal,Fn.Hamming,Fn.Euclidean,Fn.Tanimoto,Fn.Dice,Fn.Cosine,Fn.Tanimoto,Fn.Asymmetric,Fn.Cosine,Fn.Sokal,sr.HAMMING,sr.LEVENSHTEIN,sr.MONOMER_CHEMICAL_DISTANCE,sr.NEEDLEMANN_WUNSCH;const hr={[Rn.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)},[Rn.Manhattan]:function(t,e){let n=0;for(let r=0;r<t.length;r++)n+=Math.abs(t[r]-e[r]);return n},[Rn.Cosine]:function(t,e){let n=0,r=0,o=0;for(let i=0;i<t.length;i++)n+=t[i]*e[i],r+=t[i]*t[i],o+=e[i]*e[i];return(1-n/(Math.sqrt(r)*Math.sqrt(o)))/2}},dr={[xn.Levenshtein]:nr,[xn.JaroWinkler]:rr.Vb,[xn.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}},[xn.Onehot]:function(t,e){return t===e?0:1}},fr={[Fn.Tanimoto]:function(t,e){return 1-cr(t,e)},[Fn.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)},[Fn.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)},[Fn.BraunBlanquet]:function(t,e){return lr(function(t,e){const n=Math.max(t.trueCount(),e.trueCount());return 0==n?0:t.andWithCountBits(e,!0)/n}(t,e))},[Fn.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)},[Fn.Kulczynski]:function(t,e){return lr(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))},[Fn.McConnaughey]:function(t,e){return lr(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))},[Fn.RogotGoldberg]:function(t,e){return lr(function(t,e){const n=t.andWithCountBits(e,!0),r=t.countBits(!0)+e.countBits(!0),o=t.length,i=o-r+n;return n==o||i==o?1:n/r+i/(2*o-r)}(t,e))},[Fn.Russel]:function(t,e){return lr(function(t,e){return 0==t.length?0:t.andWithCountBits(e,!0)/t.length}(t,e))},[Fn.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)},[Fn.Hamming]:function(t,e){return t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0)},[Fn.Euclidean]:function(t,e){return Math.sqrt(t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0))}},pr={[Dn.TanimotoIntArray]:function(t,e){return lr(cr(new or(t,32*t.length),new or(e,32*e.length)))}},mr={[kn.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)}},gr={[Gn.CommonItems]:function(t){const e=function(t){const e=t?.mostCommon??new Set;return(t,n)=>{const r=t.length,o=n.length;let i=0,a=0,s=0;for(;a<r&&s<o;)t[a]===n[s]?(e?.has(t[a])||++i,++a,++s):t[a]<n[s]?++a:++s;return i}}(t);return(t,n)=>0===n.length||0===t.length?1e4:Math.min(t.length,n.length)/(e(t,n)+1e-4)}},yr={[Un.Vector]:{[Rn.Euclidean]:hr[Rn.Euclidean],[Rn.Manhattan]:hr[Rn.Manhattan],[Rn.Cosine]:hr[Rn.Cosine]},[Un.String]:{[xn.Levenshtein]:dr[xn.Levenshtein],[xn.JaroWinkler]:dr[xn.JaroWinkler],[xn.Manhattan]:dr[xn.Manhattan],[xn.Onehot]:dr[xn.Onehot]},[Un.BitArray]:{[Fn.Tanimoto]:fr[Fn.Tanimoto],[Fn.Dice]:fr[Fn.Dice],[Fn.Asymmetric]:fr[Fn.Asymmetric],[Fn.BraunBlanquet]:fr[Fn.BraunBlanquet],[Fn.Cosine]:fr[Fn.Cosine],[Fn.Kulczynski]:fr[Fn.Kulczynski],[Fn.McConnaughey]:fr[Fn.McConnaughey],[Fn.RogotGoldberg]:fr[Fn.RogotGoldberg],[Fn.Russel]:fr[Fn.Russel],[Fn.Sokal]:fr[Fn.Sokal]},[Un.MacroMolecule]:{[sr.HAMMING]:ur[sr.HAMMING],[sr.LEVENSHTEIN]:ur[sr.LEVENSHTEIN],[sr.NEEDLEMANN_WUNSCH]:ur[sr.NEEDLEMANN_WUNSCH],[sr.MONOMER_CHEMICAL_DISTANCE]:ur[sr.MONOMER_CHEMICAL_DISTANCE]},[Un.Number]:{[kn.Difference]:mr[kn.Difference]},[Un.IntArray]:{[Dn.TanimotoIntArray]:pr[Dn.TanimotoIntArray]},[Un.NumberArray]:{[Gn.CommonItems]:gr[Gn.CommonItems]}};Object.keys(yr).reduce(((t,e)=>{for(const n of Object.keys(yr[e]))t[n]=e;return t}),{});class vr{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"},mn().then((t=>{t?(this.useWebGPU.tooltip+=` (${t})`,this.useWebGPU.value=!0):(this.useWebGPU.value=!1,this.useWebGPU.disable=!0)}))}}class wr{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 br{constructor(n={}){this.editorSettings={},this.columnOptEditors=[],this.columnOptEditorsRoot=e.div(),this.columnParamsEditorRoot=e.div(),this.columnFunctionsMap={},this.methodsParams={[_n.UMAP]:new vr,[_n.T_SNE]:new wr},this.dbScanParams=new In,this.methodSettingsDivs=[],this.supportedFunctions={},this.methodSettingsAnchor=e.div(),this.plotEmbeddingsInput=e.input.bool("Plot embeddings",{value:!0}),this.aggregationMethodInput=e.input.choice("Aggregation",{value:On.EUCLIDEAN,items:[On.EUCLIDEAN,On.MANHATTAN]}),this.vectorDistanceInput=e.input.choice("Distance metric",{value:Rn.Euclidean,items:[Rn.Euclidean,Rn.Manhattan,Rn.Cosine]}),this.aggregationMethodInput.setTooltip("Aggregation method for combining distances between columns"),this.vectorDistanceInput.root.style.display="none",this.onColumnsChanged=new Pn.Subject,this.editorSettings=n,this.columnParamsEditorAccordion=e.accordion(),o.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")??"",o=t.options.get("supportedUnits")??"",i=t.options.get("supportedDistanceFunctions")??"";this.editorSettings.semtype&&!e.includes(this.editorSettings.semtype)||this.editorSettings.type&&!r.includes(this.editorSettings.type)||this.editorSettings.units&&!o.includes(this.editorSettings.units)||(this.supportedFunctions[n]={func:t,semTypes:e?e.split(","):[],types:r?r.split(","):[],units:o?o.split(","):[],distanceFunctions:i?i.split(","):[]})})),this.postProcessingEditor=new Cr,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:_n.UMAP,items:[_n.UMAP,_n.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,o=this.supportedFunctions[e].units,i=!n.length||t.semType&&n.includes(t.semType),a=!r.length||r.includes(t.type),s=!o.length||t.meta.units&&o.includes(t.meta.units);i&&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 Er(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 o=0;const i=e.table(r,(t=>(o++,t&&t.length>0?t:[this.columnOptEditors[Math.floor((o-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"),i.classList.add("ml-dim-reduction-column-editor-table-root"),this.columnOptEditorsRoot.appendChild(i),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((o=>{const i=t[o],a="string"===i.type?e.input.string(i.uiName,{value:i.value??"",onValueChanged:t=>{i.value=t}}):"boolean"===i.type?e.input.bool(i.uiName,{value:i.value??!1,onValueChanged:t=>{i.value=t}}):e.input.float(i.uiName,{value:i.value,onValueChanged:t=>{i.value=t}});i.disable?(a.enabled=!1,e.tooltip.bind(a.input??a.root,i.disableTooltip??"")):e.tooltip.bind(a.input??a.root,i.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 Er{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[Ar(t.func)]=t.func})),this.preprocessingFunctionInput=e.input.choice("Encoding function",{value:Ar(this.supportedFunctions[0].func),items:this.supportedFunctions.map((t=>Ar(t.func))),onValueChanged:t=>{const n=this.functionsMap[t];this.preprocessingFunctionSettings={},this.hasExtraSettings=n.inputs.length>2;const o=this.supportedFunctions.find((e=>Ar(e.func)===t));this.getSimilarityMetricInput(o),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 o=e.h3(this.column.name,{classes:"ml-dim-reduction-column-editor-column-title"});this.colOptEditors=[o,this.preprocessingFunctionInput.root,this.similarityMetricInputRoot,this.weightInput.root],e.tooltip.bind(o,this.column.name),this.colOptEditors.forEach((t=>t.classList.add("ml-dim-reduction-column-editor-input-root")));const i=e.divH(this.colOptEditors,{classes:"ml-dim-reduction-column-editor-root"});this.accordionDiv=e.divV([]),this.editorDiv.appendChild(i),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(),o=await r.buildEditor(e.div());for(let e=2;e<n.inputs.length;e++){const i=n.inputs[e],a=this.preprocessingFunctionSettings[i.name]||r.inputParams[n.inputs[e].name].value||i.defaultValue;a&&(this.preprocessingFunctionSettings[i.name]=a);const s=o.find((t=>t.property.name===i.name));s&&(null!==this.preprocessingFunctionSettings[i.name]&&void 0!==this.preprocessingFunctionSettings[i.name]&&(s.value=this.preprocessingFunctionSettings[i.name]),s.onChanged.subscribe((t=>{this.preprocessingFunctionSettings[i.name]=t})),t.append(s.root))}return t.style.marginBottom="10px",t}}function Ar(t){return t.friendlyName??t.name}class Cr{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",o.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),o=await r.buildEditor(e.div());for(let e=2;e<t.inputs.length;e++){const n=t.inputs[e],i=this._postProcessingArgs[n.name]||r.inputParams[t.inputs[e].name].value||n.defaultValue;i&&(this._postProcessingArgs[n.name]=i);const a=o.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 _r="dimensionality-reducer-terminate-event",Sr=t=>null==t;function Nr(t,e){return`${e} (${t.length>4?`${t.length} columns`:t.map((t=>t.name)).join(", ")})`}var Ir=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function s(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(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 Mr(n){return Ir(this,void 0,void 0,(function*(){if(null!=n||(n=t.shell.t),null===n)return void t.shell.warning(Be.NO_DATAFRAME);const r=[],i=[],a=[];n.columns.toList().filter((t=>Ye.includes(t.type))).forEach((t=>{const e=t.stats.missingValueCount;e!==t.length&&(a.push(t.name),e>0&&(r.push(t),i.push(t.name)))}));const s=function(t){const e=new Map;for(const n of t){if(!Ye.includes(n.type))throw new Error(Be.UNSUPPORTED_COLUMN_TYPE);if(0===n.stats.missingValueCount)continue;const t=[],r=$e(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(Be.NO_MISSING_VALUES);if(1===a.length)return void t.shell.error(Be.ONE_AVAILABLE_FEATURE);let u=Je.IN_PLACE>0;const c=e.input.bool(He.IN_PLACE,{value:u,onValueChanged:t=>{u=null!=t&&t}});c.setTooltip(ze.IN_PLACE);let l=Je.KEEP_EMPTY>0;const h=e.input.bool(He.KEEP_EMPTY,{value:l,onValueChanged:t=>{l=null!=t&&t}});h.setTooltip(ze.KEEP_EMPTY);let d=Je.NEIGHBORS;const f=e.input.int(He.NEIGHBORS,{value:d,showPlusMinus:!0,min:Qe,nullable:!1,onValueChanged:t=>{null!==t&&t>=Qe&&(d=t),E()}});f.setTooltip(ze.NEIGHBORS);let p=Xe.EUCLIDEAN;const m=e.input.choice(He.DISTANCE,{value:p,items:[Xe.EUCLIDEAN,Xe.MANHATTAN],onValueChanged:t=>p=null!=t?t:Xe.EUCLIDEAN});m.setTooltip(ze.DISTANCE);let g=r.map((t=>t.name));const y=e.input.columns(He.COLUMNS,{table:n,value:n.columns.byNames(i),onValueChanged:t=>{g=t.map((t=>t.name)),E()},available:i});y.setTooltip(ze.TARGET);let v=a;const w=e.input.columns(He.FEATURES,{value:n.columns.byNames(a),table:n,onValueChanged:t=>{v=t.map((t=>t.name)),v.length>0?(E(),C.forEach(((t,e)=>t.hidden=!v.includes(e)))):b()},available:a});w.setTooltip(ze.FEATURES);const b=()=>{S.getButton(He.RUN).disabled=!0,c.root.hidden=!0,h.root.hidden=!0,f.root.hidden=!0,I.hidden=!0,_.hidden=!0},E=()=>{S.getButton(He.RUN).disabled=null===f.value||f.value<Qe,I.hidden=!1,c.root.hidden=!1,f.root.hidden=!1,m.root.hidden=!1,h.root.hidden=!Ze(g,v,s),1===v.length&&g.forEach((e=>{v[0]===e&&(b(),t.shell.warning(`${Be.ONE_FEATURE_SELECTED} the column '${e}'`))})),g.length<1&&b()},A=new Map,C=new Map,_=e.divV([]);_.style.overflow="auto",a.forEach((t=>{const r=function(t){switch(t){case o.COLUMN_TYPE.STRING:case o.COLUMN_TYPE.DATE_TIME:return{defaultWeight:Je.WEIGHT,defaultMetric:Ke.ONE_HOT,availableMetrics:[Ke.ONE_HOT]};case o.COLUMN_TYPE.INT:case o.COLUMN_TYPE.FLOAT:case o.COLUMN_TYPE.QNUM:return{defaultWeight:Je.WEIGHT,defaultMetric:Ke.DIFFERENCE,availableMetrics:[Ke.DIFFERENCE,Ke.ONE_HOT]};default:throw new Error(Be.UNSUPPORTED_COLUMN_TYPE)}}(n.col(t).type);A.set(t,{weight:r.defaultWeight,type:r.defaultMetric});const i=e.input.choice(t,{value:r.defaultMetric,items:r.availableMetrics,onValueChanged:e=>{var n;const o=null!==(n=A.get(t))&&void 0!==n?n:{weight:r.defaultWeight,type:r.defaultMetric};o.type=null!=e?e:r.defaultMetric,A.set(t,o)}});i.root.style.width="50%",i.setTooltip(ze.METRIC),i.root.hidden=!0;const a=o.Property.fromOptions({name:t.length<qe?t:t.slice(0,qe).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 o=null!==(n=A.get(t))&&void 0!==n?n:{weight:r.defaultWeight,type:r.defaultMetric};o.weight=null!=e?e:r.defaultWeight,A.set(t,o)})),e.tooltip.bind(s.captionLabel,t),e.tooltip.bind(s.input,ze.WEIGHT),C.set(t,s.root),_.append(s.root)}));const S=e.dialog({title:He.KNN_IMPUTER,helpUrl:je});t.shell.v.root.appendChild(S.root),_.hidden=!0,h.root.hidden=!Ze(g,v,s);const N=e.icons.settings((()=>{_.hidden=!_.hidden}),ze.METRIC_SETTINGS),I=e.divH([m.root,N]);let M,T,O=!1;const L=new Promise(((t,e)=>{M=t,T=e}));return S.addButton(He.RUN,(()=>{O=!0,S.close(),a.filter((t=>!v.includes(t))).forEach((t=>A.delete(t)));try{const e=function(e,n,r,i,a,s,u){if(s<Qe)throw new Error(Be.INCORRECT_NEIGHBORS);if(e.rowCount<2)throw new Error(Be.KNN_NOT_ENOUGH_OF_ROWS);if(0===n.length)throw new Error(Be.KNN_NO_TARGET_COLUMNS);if(0===r.size)throw new Error(Be.KNN_NO_FEATURE_COLUMNS);1===r.size&&n.forEach((t=>{if(r.has(t))throw new Error(`${Be.KNN_NO_FEATURE_COLUMNS} can be used for the column '${t}'`)})),n.forEach((t=>{if(!i.has(t))throw new Error(`${Be.KNN_FAILS}: ${Be.WRONG_PREDICTIONS}`)}));const c=e.columns;n.forEach((t=>{if(!Ye.includes(c.byName(t).type))throw new Error(Be.UNSUPPORTED_COLUMN_TYPE)})),r.forEach(((t,n)=>{if(!Ye.includes(e.getCol(n).type))throw new Error(Be.UNSUPPORTED_COLUMN_TYPE)}));const l=new Map;return n.forEach((n=>{const h=c.byName(n),d=$e(h),f=h.length,p=h.getRawData(),m=new Uint16Array(h.categories.length),g=[],y=[],v=[],w=[];r.forEach(((t,e)=>{if(e!==h.name){const n=c.byName(e);switch(g.push(n.getRawData()),y.push($e(n)),t.type){case Ke.DIFFERENCE:v.push(((e,n)=>t.weight*Math.abs(e-n)));break;case Ke.ONE_HOT:v.push(((e,n)=>t.weight*(e===n?0:1)))}}}));const b=g.length,E=new Uint32Array(g.length),A=new Float32Array(g.length);let C=0;const _=new Array(s);let S=0,N=0,I=0,M=0,T=0;const O=(t,e)=>{E.forEach(((n,r)=>{A[r]=v[n](g[n][t],g[n][e])}))},L=a===Xe.EUCLIDEAN?()=>{let t=0;for(let e=0;e<C;++e)t+=A[e]*A[e];return Math.sqrt(t)}:()=>{let t=0;for(let e=0;e<C;++e)t+=Math.abs(A[e]);return Math.sqrt(t)},P=t=>{if(p[t]===d)return!1;for(let e=0;e<C;++e)if(g[E[e]][t]===y[E[e]])return!1;return!0},x=t=>{if((t=>{C=0;for(let e=0;e<b;++e)g[e][t]!==y[e]&&(E[C]=e,++C)})(t),0===C)throw new Error(`${Be.KNN_IMPOSSIBLE_IMPUTATION}: the column "${h.name}", row ${t+1}`);S=0;for(let e=0;e<f;++e)if(P(e)&&e!==t){O(t,e);const n=L();if(S<s)_[S]={index:e,dist:n},++S;else{N=0,I=_[0].dist;for(let t=1;t<S;++t)I<_[t].dist&&(I=_[t].dist,N=t);n<I&&(_[N]={index:e,dist:n})}}if(0===S)throw new Error(`${Be.KNN_IMPOSSIBLE_IMPUTATION}: the column "${h.name}", row ${t+1}`);if(h.type===o.COLUMN_TYPE.STRING)return(()=>{m.forEach(((t,e,n)=>n[e]=0));let t=0;for(t=0;t<S;++t)++m[p[_[t].index]];let e=m[0],n=0;return m.forEach(((t,r)=>{t>e&&(e=t,n=r)})),n})();M=0;for(let t=0;t<S;++t)M+=p[_[t].index];return T=M/S,h.type===o.COLUMN_TYPE.INT?Math.round(T):T};if(u){for(const e of i.get(n))try{p[e]=x(e)}catch(n){w.push(e),n instanceof Error||t.shell.error(Be.CORE_ISSUE)}w.length>0&&l.set(n,w),h.set(0,h.get(0))}else{const r=h.clone();let o=1,a=`${n}(${We})`;for(;e.columns.contains(a);)a=`${n}(${We} ${o})`,++o;r.name=a;const s=r.getRawData();for(const e of i.get(n))try{s[e]=x(e)}catch(n){w.push(e),n instanceof Error||t.shell.error(Be.CORE_ISSUE)}w.length>0&&l.set(a,w),r.set(0,r.get(0)),e.columns.add(r)}})),l}(n,g,A,s,p,d,u);l||function(t,e){e.forEach(((e,n)=>{const r=t.col(n);if(null!==r){if(!Ye.includes(r.type))throw new Error(Be.UNSUPPORTED_COLUMN_TYPE);const t=function(t){switch(t.type){case o.COLUMN_TYPE.STRING:case o.COLUMN_TYPE.DATE_TIME:return function(t){const e=$e(t),n=t.getRawData(),r=n.length;for(let o=0;o<r;++o)if(n[o]!==e)return t.get(o);throw new Error(Be.EMPTY_COLUMN)}(t);case o.COLUMN_TYPE.INT:case o.COLUMN_TYPE.FLOAT:case o.COLUMN_TYPE.QNUM:return t.stats.avg;default:throw new Error(Be.UNSUPPORTED_COLUMN_TYPE)}}(r);e.forEach((e=>r.set(e,t)))}}))}(n,e),M()}catch(e){e instanceof Error?t.shell.error(`${Be.KNN_FAILS}: ${e.message}`):t.shell.error(`${Be.KNN_FAILS}: ${Be.CORE_ISSUE}`),T(e)}}),void 0,ze.RUN),S.add(y).add(w).add(I).add(_).add(f).add(c).add(h).show().onClose.subscribe((()=>!O&&M())),L}))}class Tr extends br{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:Nn}),this.minClusterSizeInput=e.input.int("Min Cluster Size",{value:5}),mn().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??Nn,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??Nn,minClusterSize:this.minClusterSizeInput.value??5}}}class Or{constructor(t,e,n,r,i,a){this.sc=t,this.from=e,this.to=n,this.shortLineThreshold=r,this.width=i,this.color=a,this.renderFlag=!1,this.renderSub=o.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,o)=>t.isNone(o)||e.isNone(o)||!n.get(o)?null:this.sc.pointToScreen(o))),o=this.sc.canvas.getContext("2d");if(!o)return;o.strokeStyle=`rgba(${this.color}, 0.3)`,o.lineWidth=this.width;const i=this.shortLineThreshold*this.shortLineThreshold;for(let t=0;t<this.from.length;t++){o.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<i)continue;o.moveTo(t.x,t.y),o.lineTo(a.x,a.y),o.stroke(),o.closePath()}}}destroy(){this.renderSub.unsubscribe()}}class Lr extends o.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(o.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),i=r.cols.map((t=>this.dataFrame.columns.byName(t))),a=r.preprocessingFuncs.map((t=>t?o.Func.byName(t):null)),s=await async function(r,i,a,s,u,c,l,h=80,d=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:o,options:s}=await e.apply({[n]:i[t],[r]:a[t],...l[t]??{}});b.push({entries:o,options:s}),w.push(s??{})}else{const e=i[t].toList(),n={};b.push({entries:e,options:n}),w.push(n)}}const E=function(t,e,r,o,i,a,s=10,u=!1,c=2){const l=new Worker(new URL(n.p+n.u(980),n.b));let h;return l.postMessage({data:t,threshold:e,weights:r,aggregationMethod:o,distanceFns:i,distanceFnArgs:a,maxIterations:s,useWebGPU:u,inflate:c}),{promise:new Promise(((t,e)=>{h=t,l.onmessage=e=>{setTimeout((()=>l.terminate()),100),t(e.data.res)},l.onerror=t=>{setTimeout((()=>l.terminate()),100),e(t)}})),terminate:()=>{try{h(null),l.terminate()}catch(t){console.error(t)}}}}(b.map((t=>t.entries)),h,s,u,a,w,d,f,p),A=t.events.onViewerClosed.subscribe((t=>{t.args.viewer?.props?.title===v.props.title&&v.type===t.args?.viewer?.type&&(A.unsubscribe(),E.terminate())})),C=await E.promise;if(!C)return;const _=r.columns.getUnusedName("Cluster (MCL)"),S=r.columns.getUnusedName("EmbedX (MCL)"),N=r.columns.getUnusedName("EmbedY (MCL)"),I={};C.clusters.forEach((t=>{I[t]||(I[t]=0),I[t]++}));const M=new Uint32Array(C.embedX.length);for(let t=0;t<C.is.length;t++)M[C.is[t]]++,M[C.js[t]]++;const T=r.columns.getUnusedName("Cluster size (MCL)"),O=r.columns.getUnusedName("Connectivity (MCL)"),L=r.columns.addNewFloat(S);L.init((t=>C.embedX[t]));const P=r.columns.addNewFloat(N);P.init((t=>C.embedY[t]));const x=r.columns.addNewString(_);x.init((t=>I[C.clusters[t]]>=m?C.clusters[t].toString():"-1"));const R={"-1":o.Color.setAlpha(o.Color.lightBlue,100)};x.setTag(o.TAGS.COLOR_CODING_CATEGORICAL,JSON.stringify(R)),x.temp[o.TAGS.COLOR_CODING_CATEGORICAL]=R;const F=r.columns.addNewInt(T);F.init((t=>I[C.clusters[t]]));const D=r.columns.addNewInt(O);D.init((t=>M[t])),v.props.xColumnName=S,v.props.yColumnName=N,v.props.colorColumnName=_,v.props.markerDefaultSize=6,A.unsubscribe();const U=[],k=[],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){U.push(C.is[t]),k.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 o=r.get(n);o||(o=0),o>=20||(o++,r.set(n,o),U.push(C.is[t]),k.push(C.js[t]))}return e.setUpdateIndicator(v.root,!1),{sc:v,embedXCol:L,embedYCol:P,clusterCol:x,clusterCounterCol:F,connectivityCol:D,i:U,j:k}}(this.dataFrame,i,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 Or(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 Or(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 Pr=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function s(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(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 xr(t,e){const n=t.length;if(n!==e.length-1)throw new Error("Incorrect parameters count");const r=t.byIndex(0),i=r.length,a=new Float32Array(i);let s=r.getRawData();const u=e[n];let c=e[0];for(let t=0;t<i;++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<i;++t)a[t]+=c*s[t]}return o.Column.fromFloat32Array(t.getUnusedName("prediction"),a,i)}const Rr=(t,e)=>e<=t?Math.min(10,e):Math.min(10,t);var Fr;!function(t){t[t.MAX_SAMLPES=1e5]="MAX_SAMLPES",t[t.MAX_FEATURES=1e3]="MAX_FEATURES"}(Fr||(Fr={}));class Dr{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<=Fr.MAX_FEATURES&&e.length<=Fr.MAX_SAMLPES}constructor(t){if(this.specn=null,t)try{const e=new Uint32Array(t.buffer,0,2),n=e[0],r=e[1],i=new Uint8Array(t.buffer,8,n),a=o.DataFrame.fromByteArray(i),s=a.rowCount,u=a.columns,c=u.length,l=new Uint8Array(t.buffer,8+n,r),h=o.DataFrame.fromByteArray(l);if(c<3)throw new Error("incorrect columns count");const d=u.byName(ve.FEATURES).toList(),f=new Float32Array(s);f.set(u.byName(ve.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:d,dim:s-1,components:c-2,scores:h}}catch(t){throw new Error(`Failed to load model: ${t instanceof Error?t.message:"the platform issue"}`)}}fit(t,e,n){return r=this,i=void 0,s=function*(){const r=yield ke({table:o.DataFrame.fromColumns([e]),features:t,predict:e,components:n,names:void 0}),i=t.names();i.push("_");const a=this.getRegrCoeffs(t,e,r.regressionCoefficients),s=this.getLoadings(n,r.xLoadings);this.specn={names:i,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 o(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,o)}u((s=s.apply(r,i||[])).next())}));var r,i,a,s}getLoadings(t,e){const n=Array(t),r=e[0].length+1;for(let o=0;o<t;++o)n[o]=new Float32Array(r),n[o].set(e[o].getRawData());return n}getRegrCoeffs(t,e,n){const r=t.length,o=new Float32Array(r+1),i=n.getRawData();let a=0;for(let e=0;e<r;++e)o[e]=i[e],a+=i[e]*t.byIndex(e).stats.avg;return o[r]=e.stats.avg-a,o}computeExplVars(t,e,n){if(null===this.specn)throw new Error("Failed to compute explained variances");const r=n.getRawData(),o=this.specn.loadings[0].length-1;let i=Math.pow(r[0],2)/t;this.specn.loadings[0][o]=i;for(let n=1;n<e;++n)i+=Math.pow(r[n],2)/t,this.specn.loadings[n][o]=i}toBytes(){if(null===this.specn)throw new Error("Failed to pack untrained model");const t=o.DataFrame.fromColumns([o.Column.fromStrings(ve.FEATURES,this.specn.names),o.Column.fromFloat32Array(ve.REGR_COEFS,this.specn.params)]);this.specn.loadings.forEach(((e,n)=>t.columns.add(o.Column.fromFloat32Array(`${ve.XLOADING}${n+1}`,e))));const e=t.toByteArray(),n=e.length,r=this.specn.scores.toByteArray(),i=r.length,a=n+i+8,s=new Uint8Array(64*(Math.ceil(a/64)+1)),u=new Uint32Array(s.buffer,0,2);return u[0]=n,u[1]=i,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 xr(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=o.DataFrame.fromColumns([o.Column.fromStrings(ve.FEATURES,this.specn.names.slice(0,-1)),o.Column.fromFloat32Array(ve.REGR_COEFS,this.specn.params,e)]),r=n.columns,i=r.length,a=this.specn.components;return this.specn.loadings.forEach(((t,r)=>n.columns.add(o.Column.fromFloat32Array(`${ve.XLOADING}${r+1}`,t,e)))),t.push(o.Viewer.scatterPlot(n,{title:ve.LOADINGS,xColumnName:r.byIndex(i).name,yColumnName:r.byIndex(i+(a>1?1:0)).name,markerType:o.MARKER_TYPE.CIRCLE,labelFormColumnNames:[ve.FEATURES],help:be.LOADINGS})),t.push(o.Viewer.barChart(n,{title:ve.REGR_COEFS,splitColumnName:ve.FEATURES,valueColumnName:ve.REGR_COEFS,valueAggrType:o.AGG.AVG,help:be.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]=`${Ae.COMP} 1`,r[0]=this.specn.loadings[0][e];for(let o=1;o<t;++o)n[o]=`${Ae.COMPS} ${o+1}`,r[o]=this.specn.loadings[o][e];return o.Viewer.barChart(o.DataFrame.fromColumns([o.Column.fromStrings(Ae.COMPS,n),o.Column.fromFloat32Array(ve.EXPL_VAR,r)]),{title:ve.EXPL_VAR,splitColumnName:Ae.COMPS,valueColumnName:ve.EXPL_VAR,valueAggrType:o.AGG.AVG,help:be.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=`${ve.XSCORE}${e+1}`)),n.forEach(((t,e)=>t.name=`${ve.YSCORE}${e+1}`)),o.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=o.Viewer.scatterPlot(this.specn.scores,{title:ve.SCORES,xColumnName:t[0],yColumnName:t[1],markerType:o.MARKER_TYPE.CIRCLE,help:be.SCORES,showViewerFormulaLines:!0});return e.meta.formulaLines.addAll(Ue(t)),e}}var Ur=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function s(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(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 kr="Avg-s",Gr="Stddev-s";var Br;!function(t){t[t.MAX_SAMLPES=5e4]="MAX_SAMLPES",t[t.MAX_FEATURES=100]="MAX_FEATURES"}(Br||(Br={}));class Vr{static isApplicable(t,e){for(const e of t)if(!e.matches("numerical"))return!1;return e.type===o.COLUMN_TYPE.STRING}static isInteractive(t,e){return t.length<=Br.MAX_FEATURES&&e.length<=Br.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=o.DataFrame.fromByteArray(n),i=r.columns,a=i.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=i.byIndex(t);if(this.categories[t]=e.name,e.type!==o.COLUMN_TYPE.FLOAT)throw new Error(`Incorrect input column type. Expected: float, passed: ${e.type}`);this.params[t]=e.getRawData()}const u=i.byName(kr);if(u.type!==o.COLUMN_TYPE.FLOAT)throw new Error("incorrect average values column type");this.avgs=u.getRawData();const c=i.byName(Gr);if(c.type!==o.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]=o.Column.fromFloat32Array(this.categories[n],this.params[n]);e[t]=o.Column.fromFloat32Array(kr,this.avgs),e[t+1]=o.Column.fromFloat32Array(Gr,this.stdevs);const n=o.DataFrame.fromColumns(e).toByteArray(),r=n.length,i=new Uint8Array(r+4);return new Uint32Array(i.buffer,0,1)[0]=r,i.set(n,4),i}fit(t,e){return Ur(this,arguments,void 0,(function*(t,e,n=1,r=100,i=.1,a=.001){if(t.length!==this.featuresCount)throw new Error("Training failes - incorrect features count");if(n<=0||r<1||i<=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,o,i,a,s,u,c,l){return g(EDA,"fitSoftmax",[t,e,n,r,o,i,a,s,u,c,l])}(t,o.Column.fromFloat32Array("avgs",this.avgs,this.featuresCount),o.Column.fromFloat32Array("stdevs",this.stdevs,this.featuresCount),o.Column.fromInt32Array("targets",e.getRawData(),s),u,r,n,i,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(o){try{this.params=yield this.fitSoftmaxParams(t,e,r,n,i,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!==o.COLUMN_TYPE.INT&&n.type!==o.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 i of t){if(i.type!==o.COLUMN_TYPE.INT&&i.type!==o.COLUMN_TYPE.FLOAT)throw new Error("Training failes - incorrect features type");const t=i.getRawData(),a=this.avgs[r],s=this.stdevs[r];if(s>0)for(let o=0;o<e;++o)n[o][r]=(t[o]-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 i=0;for(const n of t){if(n.type!==o.COLUMN_TYPE.INT&&n.type!==o.COLUMN_TYPE.FLOAT)throw new Error("Training failes - incorrect features type");const t=n.getRawData(),a=this.avgs[i],s=this.stdevs[i];if(s>0)for(let n=0;n<e;++n)r[i][n]=(t[n]-a)/s;else for(let t=0;t<e;++t)r[i][t]=0;++i}return r}preprocessedTargets(t){if(t.type!==o.COLUMN_TYPE.STRING)throw new Error("Training failes - incorrect target type");const e=this.classesCount,n=t.length,r=t.getRawData(),i=new Array(n),a=new Uint32Array(e).fill(0);for(let t=0;t<n;++t)i[t]=new Uint8Array(e).fill(0);for(let t=0;t<n;++t)i[t][r[t]]=1,++a[r[t]];return{oneHot:i,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,i=this.classesCount;let a,s;const u=new Float32Array(i);let c,l,h;const d=new Array(n);for(let t=0;t<n;++t){a=e[t],c=0;for(let t=0;t<i;++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],h=0;for(let t=1;t<i;++t)l<u[t]&&(l=u[t],h=t);d[t]=this.categories[h]}return o.Column.fromStrings("predicted",d)}fitSoftmaxParams(t,e,r,o,i,a){return Ur(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:o,penalty:i,tolerance:a}),l.onmessage=function(t){l.terminate(),u(t.data.params),console.log(`Loss: ${t.data.loss}`)}}))}))}}var Wr,Hr,jr;!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"}(Wr||(Wr={})),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"}(Hr||(Hr={})),function(t){t[t.MODEL=1e7]="MODEL",t[t.UTILS=1]="UTILS",t[t.PACK=128]="PACK",t[t.SIZE=4]="SIZE"}(jr||(jr={}));const zr=o.FLOAT_NULL;var qr;!function(t){t.PREDICT="Prediction",t.TYPE="Type",t.PARAMS="Params count",t.CATS="Categories",t.CATS_SIZE="Categories size"}(qr||(qr={}));class Yr{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<=Hr.SAMPLES_LOW?n<=Hr.FEATURES_LOW:r<=Hr.SAMLPES_MID?n<=Hr.FEATURES_MID:r<=Hr.SAMLPES_HIGH&&n<=Hr.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+=jr.SIZE;const i=o.DataFrame.fromByteArray(new Uint8Array(t.buffer,n,r));n+=r,this.targetType=i.get(qr.TYPE,0);const a=i.get(qr.PARAMS,0),s=i.get(qr.CATS_SIZE,0);if(s>0){const r=o.DataFrame.fromByteArray(new Uint8Array(t.buffer,n,s));this.targetCategories=null===(e=r.col(qr.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,i=arguments,s=function*(t,e,r=Wr.ITERATIONS,i=Wr.ETA,a=Wr.MAX_DEPTH,s=Wr.LAMBDA,u=Wr.ALPHA){this.targetType=e.type,this.targetType===o.COLUMN_TYPE.STRING&&(this.targetCategories=e.categories),this.modelParams=yield async function(t,e,r,o,i,a,s,u,c,l){return new Promise(((h,d)=>{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:o,eta:i,maxDepth:a,lambda:s,alpha:u,missingValue:r}),v.onmessage=function(t){v.terminate(),h(t.data.params)}}))}(t,e,zr,r,i,a,s,u,jr.MODEL,jr.UTILS)},new((a=void 0)||(a=Promise))((function(t,e){function n(t){try{u(s.next(t))}catch(t){e(t)}}function o(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,o)}u((s=s.apply(r,i||[])).next())}));var r,i,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,o=t.length,i=n.length;let a=XGBoostModule.HEAPF32;const s=XGBoostModule.HEAP32,u=XGBoostModule._malloc(r*o*4),c=XGBoostModule._malloc(4*r),l=XGBoostModule._malloc(4*i);for(let e=0;e<o;++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<i;++t)s[l/4+t]=n[t];XGBoostModule._predict(u,r,o,e,l,i,c,r),a=XGBoostModule.HEAPF32;const h=new Float32Array(r);for(let t=0;t<r;++t)h[t]=a[c/4+t];return XGBoostModule._free(u),XGBoostModule._free(c),XGBoostModule._free(l),h}(t,zr,this.modelParams);switch(this.targetType){case o.COLUMN_TYPE.STRING:return this.stringColPrediction(e);case o.COLUMN_TYPE.INT:return this.intColPrediction(e);case o.COLUMN_TYPE.BIG_INT:return this.bigIntColPrediction(e);default:return o.Column.fromFloat32Array(qr.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?o.DataFrame.fromColumns([o.Column.fromList(o.COLUMN_TYPE.STRING,qr.CATS,this.targetCategories)]).toByteArray():void 0,e=void 0!==t?t.length:0,n=this.modelParams.length*this.modelParams.BYTES_PER_ELEMENT,r=o.DataFrame.fromColumns([o.Column.fromStrings(qr.TYPE,[this.targetType]),o.Column.fromInt32Array(qr.PARAMS,new Int32Array([this.modelParams.length])),o.Column.fromInt32Array(qr.CATS_SIZE,new Int32Array([e]))]).toByteArray(),i=r.length,a=64*Math.ceil((jr.SIZE+i+e+n+jr.PACK)/64),s=new Uint8Array(a);let u=0;return new Uint32Array(s.buffer,u,1)[0]=i,u+=jr.SIZE,s.set(r,u),u+=i,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;for(let o=0;o<e;++o)n[o]=this.targetCategories[(i=Math.round(t[o]),Math.max(0,Math.min(i,r)))];var i;return o.Column.fromList(o.COLUMN_TYPE.STRING,qr.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 o.Column.fromInt32Array(qr.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 o.Column.fromBigInt64Array(qr.PREDICT,n)}}var $r=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function s(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(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 Kr=new o.Package;function Xr(){t.shell.info(Kr.webRoot)}function Jr(){return $r(this,void 0,void 0,(function*(){yield async function(){await initEDA()}(),yield async function(){await initXGBoostModule()}()}))}function Qr(t,e,n,r,i){return $r(this,void 0,void 0,(function*(){const a=e.getRawData(),s=n.getRawData(),u=yield fn(a,s,r,i),c=t.columns.getUnusedName("Cluster (DBSCAN)"),l=o.Column.fromInt32Array(c,u);return t.columns.add(l),l}))}function Zr(e,r,i,a,s){return $r(this,void 0,void 0,(function*(){try{const u=yield function(t,e,r,i,a){return Q(this,void 0,void 0,(function*(){X(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 o.DataFrame.fromColumns(e)}(e),c=u.columns.length;if(0===c){const t=[];for(let e=0;e<r;++e)t.push(o.Column.fromFloat32Array(`${e+1}`,new Float32Array(s).fill(0)));return o.DataFrame.fromColumns(t)}const l=c<r?r-c:0,h=Math.min(r,c);let d;if(c>W)d=yield G(0,e,h);else{const t=yield async function(t,e,r){return new Promise(((t,o)=>{const i=new Worker(new URL(n.p+n.u(860),n.b));i.postMessage(U(EDA.principalComponentAnalysis.arguments,[e,r,1,0])),i.onmessage=function(e){i.terminate(),0===e.data.callResult?t(k(EDA.principalComponentAnalysis,e.data)):t(-1)}}))}(0,e,h);d=-1!==t?J(t,i,a):yield G(0,e,h)}if(void 0===d)throw new Error("Failed to compute PCA");d=J(d,i,a);const f=d.columns,p=f.length;for(let t=0;t<l;++t)f.add(o.Column.fromFloat32Array(`${p+t+1}`,new Float32Array(s).fill(0)));return d}))}(e,r,i,a,s);if(function(t,e){for(const t of e.toList())t.name="PC"+t.name}(0,u.columns),null===e.id)t.shell.addTableView(u);else{const t=e.columns;for(const e of u.columns)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"}`)}}))}function to(e,n,r,i){return $r(this,void 0,void 0,(function*(){const a=e.dataFrame;if(null===a)return;const s=yield Qr(a,e,n,r,i);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 o.ScatterPlotViewer&&u.includes(t.props.xColumnName)&&u.includes(t.props.yColumnName))return void(t.props.colorColumnName=s.name)}))}function eo(t,e){const n=t.stats.max-t.stats.min;return{entries:t.toList(),options:{range:n}}}function no(t,e){return{entries:t.toList(),options:{}}}function ro(){return $r(this,void 0,void 0,(function*(){const r=new br,i=e.dialog("Dimensionality reduction").add(r.getEditor()).onOK((()=>$r(this,void 0,void 0,(function*(){const i=r.getParams();0!==i.columns.length&&(yield async function(r,i,a,s,u,c,l,h=!0,d=!1,f={preprocessingFuncArgs:[]},p={},m=null,g={},y){const v={showXAxis:!1,showYAxis:!1,showXSelector:!1,showYSelector:!1};if(i.length!==s.length||i.length!==c.length||i.length!==u.length||i.length!==f.preprocessingFuncArgs.length)throw new Error("columns, metrics and preprocessing functions, weights and function argumentsmust have the same length");const w=h?p.tableView??t.shell.tableView(r.name)??t.shell.addTableView(r):null,b=async()=>{const b=o.TaskBarProgressIndicator.create(`Initializing ${p.scatterPlotName??"dimensionality reduction"} ...`);let E;try{const A=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(A[0])?(u=r.columns.byName(A[0]),c=r.columns.byName(A[1])):(u=r.columns.add(o.Column.float(A[0],r.rowCount)),c=r.columns.add(o.Column.float(A[1],r.rowCount)),h&&!E&&(E=w.scatterPlot({...v,x:A[0],y:A[1],title:p.scatterPlotName??Nr(i,a)}))),p[Tn]&&(E?.root&&e.setUpdateIndicator(E.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 _(){r.columns.add(o.Column.float(A[0],r.rowCount)),r.columns.add(o.Column.float(A[1],r.rowCount));let d=null;h&&(E=w.scatterPlot({...v,x:A[0],y:A[1],title:p.scatterPlotName??Nr(i,a)}),e.setUpdateIndicator(E.root,!0));const m=t.events.onViewerClosed.subscribe((e=>{const n=e.args.viewer;n?.getOptions()?.look?.title&&E?.getOptions()?.look?.title&&n?.getOptions()?.look?.title===E?.getOptions()?.look?.title&&(t.events.fireCustomEvent(_r,{}),m.unsubscribe(),d?.(),b.close())})),g=new Promise((async(e,o)=>{try{d=e;const o=[];let h=s,m=u,g=l;if(y&&i.every((t=>t.isNumerical))){const t=i.map((t=>t.toList())),e=new Array(r.rowCount).fill(0).map(((t,e)=>new Float32Array(i.length)));for(let n=0;n<i.length;++n)for(let o=0;o<r.rowCount;++o)e[o][n]=t[n][o];f.distanceFnArgs=[{}],o.push({entries:e,options:{}}),h=[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]:i[t],[r]:s[t],...f.preprocessingFuncArgs[t]??{}});o.push({entries:a,options:u}),f.distanceFnArgs.push(u)}else{const e=i[t].toList(),n={};o.push({entries:e,options:n}),f.distanceFnArgs.push(n)}}e(await async function(e,r,o,i,a,s,u){let c=await async function(e,r,o,i,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!==i.length)throw new Error("data, metrics and options and weights must have the same length");return new Promise((function(c,l){const h=new Worker(new URL(n.p+n.u(234),n.b));h.postMessage({columnsData:e,distanceMetrics:r,method:o,options:s,weights:i,aggregationMethod:a});const d=t.events.onCustomEvent(_r).subscribe((()=>{try{h?.terminate()}finally{d.unsubscribe()}}));h.onmessage=({data:{error:t,embedding:e,epochNum:n,epochsLength:r}})=>{Sr(n)||Sr(r)?(d.unsubscribe(),t?l(t):c(e),setTimeout((()=>h.terminate()),100)):u&&u(n,r,e)}}))}(e,o,r,i,a,s,u);return c=c.map((t=>function(t){const e=t.length;let n=0,r=0;for(let o=0;o<e;++o)n+=t[o],r+=Math.pow(t[o],2);const o=n/e,i=1/Math.sqrt(r/e-Math.pow(o,2));for(let n=0;n<e;++n)t[n]=(t[n]-o)*i;return t}(t))),c}(o.map((t=>t.entries)),a,h,m,l,f,p[Mn]?void 0:C))}catch(t){o(t)}})),_=await g;return b.close(),m.unsubscribe(),_}const S=await _();if(d&&S){const N=o.TaskBarProgressIndicator.create("Clustering embeddings ...");try{const I=await fn(S[0],S[1],f.dbScanEpsilon??.01,f.dbScanMinPts??4),M=r.columns.getUnusedName("Cluster (DBSCAN)");r.columns.addNewString(M).init((t=>I[t].toString())),E&&(E.props.colorColumnName=M)}catch(T){t.shell.error("Clustering embeddings failed"),console.error(T)}finally{N.close()}}if(S){const O=r.columns.byName(A[0]),L=r.columns.byName(A[1]);if(O.init((t=>S[0][t])),L.init((t=>S[1][t])),m)try{const P=m.inputs[0].name,x=m.inputs[1].name;await m.prepare({[P]:O,[x]:L,...g}).call(!0)}catch(R){t.shell.error("Post-processing failed"),console.error(R)}if(E)return e.setUpdateIndicator(E.root,!1),E.helpUrl="/help/compute/sequence-space",E}}catch(F){t.shell.error("Dimensionality reduction failed"),console.error(F),b.close(),E&&e.setUpdateIndicator(E.root,!1)}};return new Promise((async(t,n)=>{try{if(p.fastRowCount&&r.rowCount>p.fastRowCount&&!p[Mn])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)}}))}(i.table,i.columns,i.methodName,i.distanceMetrics,i.weights,i.preprocessingFunctions,i.aggreaggregationMethod,!!i.plotEmbeddings,!!i.clusterEmbeddings,i.options,{fastRowCount:1e4},i.postProcessingFunction,i.postProcessingFunctionArgs,i.vectorDistanceMetric))})))).show();i.helpUrl="https://datagrok.ai/help/explore/dim-reduction.md";const a=()=>{const t=r.columnsInput.value,e=i.getButton("OK");e&&(t&&0!==t.length?e.classList.remove("disabled"):e.classList.add("disabled"))};i.history((()=>({editorSettings:r.getStringInput()})),(t=>r.applyStringInput(t.editorSettings))),r.onColumnsChanged.subscribe((()=>{try{a()}catch(t){console.error(t)}})),a()}))}function oo(n){try{const t=new Tr;e.dialog("Markov clustering").add(t.getEditor()).onOK((()=>$r(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}`),Kr.logger.error(n,void 0,r)}}function io(e,n,r,o,i,a,s){return $r(this,arguments,void 0,(function*(e,n,r,o,i,a,s,u=80,c=10,l=!1,h=0,d=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:o,aggregationMethod:i,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:h,minClusterSize:null!=d?d:5});return p.addViewer("MCL",{mclProps:m})}))}function ao(){return new Lr}function so(t,e,n,r,o){return $r(this,void 0,void 0,(function*(){return yield ke({table:t,features:e,predict:n,components:r,names:o})}))}function uo(){return $r(this,void 0,void 0,(function*(){yield Ge(ge.COMPUTE_COMPONENTS)}))}function co(){return $r(this,void 0,void 0,(function*(){yield Ge(ge.PERFORM_MVA)}))}function lo(){return $r(this,void 0,void 0,(function*(){yield function(){return Re(this,void 0,void 0,(function*(){t.shell.addTableView(o.DataFrame.fromColumns([o.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"]),o.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])),o.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])),o.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])),o.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])),o.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])),o.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])),o.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])),o.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])),o.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])),o.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])),o.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])),o.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])),o.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])),o.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])),o.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])),o.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(Le)),t.shell.windows.showContextPanel=!1,t.shell.windows.showProperties=!1,yield Ge(ge.DEMO)}))}()}))}function ho(t,e,n){return $r(this,void 0,void 0,(function*(){return he(yield ce({gamma:n,kernel:tt},t,e))}))}function fo(t,e){return $r(this,void 0,void 0,(function*(){return yield fe(t,e)}))}function po(t,e){return $r(this,void 0,void 0,(function*(){return pe(t,e)}))}function mo(t,e){return $r(this,void 0,void 0,(function*(){return me(t)}))}function go(t,e,n,r){return $r(this,void 0,void 0,(function*(){return le(0,r)}))}function yo(t,e,n,r){return $r(this,void 0,void 0,(function*(){return he(yield ce({gamma:n,kernel:nt,sigma:r},t,e))}))}function vo(t,e){return $r(this,void 0,void 0,(function*(){return yield fe(t,e)}))}function wo(t,e){return $r(this,void 0,void 0,(function*(){return pe(t,e)}))}function bo(t,e){return $r(this,void 0,void 0,(function*(){return me(t)}))}function Eo(t,e,n,r){return $r(this,void 0,void 0,(function*(){return le(0,r)}))}function Ao(t,e,n,r,o){return $r(this,void 0,void 0,(function*(){return he(yield ce({gamma:n,kernel:et,cParam:r,dParam:o},t,e))}))}function Co(t,e){return $r(this,void 0,void 0,(function*(){return yield fe(t,e)}))}function _o(t,e){return $r(this,void 0,void 0,(function*(){return pe(t,e)}))}function So(t,e){return $r(this,void 0,void 0,(function*(){return me(t)}))}function No(t,e,n,r){return $r(this,void 0,void 0,(function*(){return le(0,r)}))}function Io(t,e,n,r,o){return $r(this,void 0,void 0,(function*(){return he(yield ce({gamma:n,kernel:rt,kappa:r,theta:o},t,e))}))}function Mo(t,e){return $r(this,void 0,void 0,(function*(){return yield fe(t,e)}))}function To(t,e){return $r(this,void 0,void 0,(function*(){return pe(t,e)}))}function Oo(t,e){return $r(this,void 0,void 0,(function*(){return me(t)}))}function Lo(t,e,n,r){return $r(this,void 0,void 0,(function*(){return le(0,r)}))}function Po(){hn()}function xo(){Mr()}function Ro(t){return $r(this,void 0,void 0,(function*(){yield Mr(t)}))}function Fo(t,e){return $r(this,void 0,void 0,(function*(){const n=t.columns,r=yield function(t,e){return Pr(this,void 0,void 0,(function*(){const n=t.length,r=e.length,i=e.stats.avg,a=e.stats.stdev,s=new Float32Array(n+1).fill(0);if(s[n]=i,0===a||1===r)return s;try{const r=[],u=[],c=new Float32Array(n),l=new Float32Array(n);let h=0,d=0;for(const e of t){const t=e.stats;t.stdev>0&&(r.push(h),u.push(e),c[d]=t.avg,l[d]=t.stdev,++d),++h}if(0===d)return s;const f=function(t,e,n,r,o,i,a){return g(EDA,"fitLinearRegressionParamsWithDataNormalizing",[t,e,n,r,o,i,a])}(o.DataFrame.fromColumns(u).columns,o.Column.fromFloat32Array("xAvgs",c,d),o.Column.fromFloat32Array("xStdevs",l,d),e,i,a,d+1).getRawData();for(let t=0;t<d;++t)s[r[t]]=f[t];s[n]=f[d]}catch(r){const i=yield function(t,e,n){return Pr(this,void 0,void 0,(function*(){return(yield ke({table:o.DataFrame.fromColumns([e]),features:t,predict:e,components:n,names:void 0})).regressionCoefficients.getRawData()}))}(t,e,Rr(t.length,e.length));let a=0;for(let e=0;e<n;++e)s[e]=i[e],a+=i[e]*t.byIndex(e).stats.avg;s[n]-=a}return s}))}(n,e);return new Uint8Array(r.buffer)}))}function Do(t,e){const n=t.columns,r=new Float32Array(e.buffer);return o.DataFrame.fromColumns([xr(n,r)])}function Uo(t,e){for(const e of t.columns)if(!e.matches("numerical"))return!1;return e.matches("numerical")}function ko(t,e){return t.rowCount<=1e5}function Go(t,e,n,r,o,i){return $r(this,void 0,void 0,(function*(){const a=t.columns,s=new Vr({classesCount:e.categories.length,featuresCount:a.length});return yield s.fit(a,e,n,r,o,i),s.toBytes()}))}function Bo(t,e){const n=t.columns,r=new Vr(void 0,e);return o.DataFrame.fromColumns([r.predict(n)])}function Vo(t,e){return Vr.isApplicable(t.columns,e)}function Wo(t,e){return Vr.isInteractive(t.columns,e)}function Ho(t,e,n){return $r(this,void 0,void 0,(function*(){const r=t.columns,o=new Dr;return yield o.fit(r,e,Math.min(n,r.length)),o.toBytes()}))}function jo(t,e){const n=new Dr(e);return o.DataFrame.fromColumns([n.predict(t.columns)])}function zo(t,e){return Dr.isApplicable(t.columns,e)}function qo(t,e,n,r){return $r(this,void 0,void 0,(function*(){return new Dr(r).viewers().map((t=>t.root))}))}function Yo(t,e){return Dr.isInteractive(t.columns,e)}function $o(t,e,n,r,o,i,a){return $r(this,void 0,void 0,(function*(){const s=t.columns,u=new Yr;return yield u.fit(s,e,n,r,o,i,a),u.toBytes()}))}function Ko(t,e){const n=new Yr(e);return o.DataFrame.fromColumns([n.predict(t.columns)])}function Xo(t,e){return Yr.isInteractive(t.columns,e)}function Jo(t,e){return Yr.isApplicable(t.columns,e)}})(),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 o(t,e,n){return o=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 o=[null];o.push.apply(o,e);var i=new(Function.bind.apply(t,o));return n&&r(i,n.prototype),i},o.apply(null,arguments)}function i(t){var e="function"==typeof Map?new Map:void 0;return i=function(t){if(null===t||(i=t,-1===Function.toString.call(i).indexOf("[native code]")))return t;var i;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 o(t,arguments,n(this).constructor)}return a.prototype=Object.create(t.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),r(a,t)},i(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 o=t._nodes.get(e),i=null;return o?i="mixed"===r?o.out&&o.out[n]||o.undirected&&o.undirected[n]:"directed"===r?o.out&&o.out[n]:o.undirected&&o.undirected[n]:i}function c(e){return"object"===t(e)&&null!==e}function l(t){var e;for(e in t)return!1;return!0}function h(t,e,n){Object.defineProperty(t,e,{enumerable:!1,configurable:!1,writable:!0,value:n})}function d(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 o(n){t.removeListener(e,i),r(n)}function i(){"function"==typeof t.removeListener&&t.removeListener("error",o),n([].slice.call(arguments))}T(t,e,i,{once:!0}),"error"!==e&&function(t,e){"function"==typeof t.on&&T(t,"error",e,{once:!0})}(t,o)}))},w.EventEmitter=w,w.prototype._events=void 0,w.prototype._eventsCount=0,w.prototype._maxListeners=void 0;var b=10;function E(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function A(t){return void 0===t._maxListeners?w.defaultMaxListeners:t._maxListeners}function C(t,e,n,r){var o,i,a,s;if(E(n),void 0===(i=t._events)?(i=t._events=Object.create(null),t._eventsCount=0):(void 0!==i.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),i=t._events),a=i[e]),void 0===a)a=i[e]=n,++t._eventsCount;else if("function"==typeof a?a=i[e]=r?[n,a]:[a,n]:r?a.unshift(n):a.push(n),(o=A(t))>0&&a.length>o&&!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 _(){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 S(t,e,n){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},o=_.bind(r);return o.listener=n,r.wrapFn=o,o}function N(t,e,n){var r=t._events;if(void 0===r)return[];var o=r[e];return void 0===o?[]:"function"==typeof o?n?[o.listener||o]:[o]: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}(o):M(o,o.length)}function I(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 M(t,e){for(var n=new Array(e),r=0;r<e;++r)n[r]=t[r];return n}function T(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 o(i){r.once&&t.removeEventListener(e,o),n(i)}))}}function O(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 A(this)},w.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++)e.push(arguments[n]);var r="error"===t,o=this._events;if(void 0!==o)r=r&&void 0===o.error;else if(!r)return!1;if(r){var i;if(e.length>0&&(i=e[0]),i instanceof Error)throw i;var a=new Error("Unhandled error."+(i?" ("+i.message+")":""));throw a.context=i,a}var s=o[t];if(void 0===s)return!1;if("function"==typeof s)y(s,this,e);else{var u=s.length,c=M(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 E(e),this.on(t,S(this,t,e)),this},w.prototype.prependOnceListener=function(t,e){return E(e),this.prependListener(t,S(this,t,e)),this},w.prototype.removeListener=function(t,e){var n,r,o,i,a;if(E(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(o=-1,i=n.length-1;i>=0;i--)if(n[i]===e||n[i].listener===e){a=n[i].listener,o=i;break}if(o<0)return this;0===o?n.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(n,o),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 o,i=Object.keys(n);for(r=0;r<i.length;++r)"removeListener"!==(o=i[r])&&this.removeAllListeners(o);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 N(this,t,!0)},w.prototype.rawListeners=function(t){return N(this,t,!1)},w.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):I.call(t,e)},w.prototype.listenerCount=I,w.prototype.eventNames=function(){return this._eventsCount>0?p(this._events):[]},"undefined"!=typeof Symbol&&(O.prototype[Symbol.iterator]=function(){return this}),O.of=function(){var t=arguments,e=t.length,n=0;return new O((function(){return n>=e?{done:!0}:{done:!1,value:t[n++]}}))},O.empty=function(){return new O((function(){return{done:!0}}))},O.fromSequence=function(t){var e=0,n=t.length;return new O((function(){return e>=n?{done:!0}:{done:!1,value:t[e++]}}))},O.is=function(t){return t instanceof O||"object"==typeof t&&null!==t&&"function"==typeof t.next};var L=O,P={};P.ARRAY_BUFFER_SUPPORT="undefined"!=typeof ArrayBuffer,P.SYMBOL_SUPPORT="undefined"!=typeof Symbol;var x=L,R=P,F=R.ARRAY_BUFFER_SUPPORT,D=R.SYMBOL_SUPPORT,U=function(t){var e=function(t){return"string"==typeof t||Array.isArray(t)||F&&ArrayBuffer.isView(t)?x.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},k=U,G=function(t,e){for(var n,r=arguments.length>1?e:1/0,o=r!==1/0?new Array(r):[],i=0,a=k(t);;){if(i===r)return o;if((n=a.next()).done)return i!==e&&(o.length=i),o;o[i++]=n.value}},B=function(t){function n(e){var n;return(n=t.call(this)||this).name="GraphError",n.message=e,n}return e(n,t),n}(i(Error)),V=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}(B),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}(B),H=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}(B);function j(t,e){this.key=t,this.attributes=e,this.clear()}function q(t,e){this.key=t,this.attributes=e,this.clear()}function z(t,e){this.key=t,this.attributes=e,this.clear()}function Y(t,e,n,r,o){this.key=e,this.attributes=o,this.undirected=t,this.source=n,this.target=r}function $(t,e,n,r,o,i,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=o,l=i}else if(3===n){if(o=""+o,!(u=t._edges.get(o)))throw new W("Graph.".concat(e,': could not find the "').concat(o,'" edge in the graph.'));var h=u.source.key,d=u.target.key;if(r===h)s=u.target;else{if(r!==d)throw new W("Graph.".concat(e,': the "').concat(r,'" node is not attached to the "').concat(o,'" edge (').concat(h,", ").concat(d,")."));s=u.source}c=i,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=o,l=i}return[s,c,l]}j.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}},q.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}},z.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}},Y.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)},Y.prototype.attachMulti=function(){var t="out",e="in",n=this.source.key,r=this.target.key;this.undirected&&(t=e="undirected");var o=this.source[t],i=o[r];if(void 0===i)return o[r]=this,void(this.undirected&&n===r||(this.target[e][n]=this));i.previous=this,this.next=i,o[r]=this,this.target[e][n]=this},Y.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]},Y.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 K=[{name:function(t){return"get".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,r,o){var i=$(this,e,n,t,r,o),a=i[0],s=i[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 $(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,o){var i=$(this,e,n,t,r,o),a=i[0],s=i[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,o,i){var a=$(this,e,n,t,r,o,i),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,o,i){var a=$(this,e,n,t,r,o,i),s=a[0],u=a[1],c=a[2];if("function"!=typeof c)throw new V("Graph.".concat(e,": updater should be a function."));var l=s.attributes,h=c(l[u]);return l[u]=h,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,o){var i=$(this,e,n,t,r,o),a=i[0],s=i[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,o){var i=$(this,e,n,t,r,o),a=i[0],s=i[1];if(!c(s))throw new V("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,o){var i=$(this,e,n,t,r,o),a=i[0],u=i[1];if(!c(u))throw new V("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,o){var i=$(this,e,n,t,r,o),a=i[0],s=i[1];if("function"!=typeof s)throw new V("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 o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new H("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new H("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,a=""+r;if(r=arguments[2],!(o=u(this,i,a,n)))throw new W("Graph.".concat(e,': could not find an edge for the given path ("').concat(i,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new H("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]}}},{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 H("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>1){if(this.multi)throw new H("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,i=""+arguments[1];if(!(r=u(this,o,i,n)))throw new W("Graph.".concat(e,': could not find an edge for the given path ("').concat(o,'" - "').concat(i,'").'))}else{if("mixed"!==n)throw new H("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 o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new H("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new H("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,a=""+r;if(r=arguments[2],!(o=u(this,i,a,n)))throw new W("Graph.".concat(e,': could not find an edge for the given path ("').concat(i,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new H("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.hasOwnProperty(r)}}},{name:function(t){return"set".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,r,o){var i;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new H("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>3){if(this.multi)throw new H("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],o=arguments[3],!(i=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 H("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]=o,this.emit("edgeAttributesUpdated",{key:i.key,type:"set",attributes:i.attributes,name:r}),this}}},{name:function(t){return"update".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,r,o){var i;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new H("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>3){if(this.multi)throw new H("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],o=arguments[3],!(i=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 H("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 o)throw new V("Graph.".concat(e,": updater should be a function."));return i.attributes[r]=o(i.attributes[r]),this.emit("edgeAttributesUpdated",{key:i.key,type:"set",attributes:i.attributes,name:r}),this}}},{name:function(t){return"remove".concat(t,"Attribute")},attacher:function(t,e,n){t.prototype[e]=function(t,r){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new H("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new H("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,a=""+r;if(r=arguments[2],!(o=u(this,i,a,n)))throw new W("Graph.".concat(e,': could not find an edge for the given path ("').concat(i,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new H("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 delete o.attributes[r],this.emit("edgeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:r}),this}}},{name:function(t){return"replace".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,r){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new H("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new H("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,a=""+r;if(r=arguments[2],!(o=u(this,i,a,n)))throw new W("Graph.".concat(e,': could not find an edge for the given path ("').concat(i,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new H("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(!c(r))throw new V("Graph.".concat(e,": provided attributes are not a plain object."));return o.attributes=r,this.emit("edgeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}},{name:function(t){return"merge".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,r){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new H("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new H("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,a=""+r;if(r=arguments[2],!(o=u(this,i,a,n)))throw new W("Graph.".concat(e,': could not find an edge for the given path ("').concat(i,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new H("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(!c(r))throw new V("Graph.".concat(e,": provided attributes are not a plain object."));return s(o.attributes,r),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:r}),this}}},{name:function(t){return"update".concat(t,"Attributes")},attacher:function(t,e,n){t.prototype[e]=function(t,r){var o;if("mixed"!==this.type&&"mixed"!==n&&n!==this.type)throw new H("Graph.".concat(e,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new H("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,a=""+r;if(r=arguments[2],!(o=u(this,i,a,n)))throw new W("Graph.".concat(e,': could not find an edge for the given path ("').concat(i,'" - "').concat(a,'").'))}else{if("mixed"!==n)throw new H("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 r)throw new V("Graph.".concat(e,": provided updater is not a function."));return o.attributes=r(o.attributes),this.emit("edgeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}}],Q=L,J=U,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 o=!1;for(var i in e)if(i!==r){var a=e[i];if(o=n(a.key,a.attributes,a.source.key,a.target.key,a.source.attributes,a.target.attributes,a.undirected),t&&o)return a.key}}function nt(t,e,n,r){var o,i,a,s=!1;for(var u in e)if(u!==r){o=e[u];do{if(i=o.source,a=o.target,s=n(o.key,o.attributes,i.key,a.key,i.attributes,a.attributes,o.undirected),t&&s)return o.key;o=o.next}while(void 0!==o)}}function rt(t,e){var n,r=Object.keys(t),o=r.length,i=0;return new L((function(){do{if(n)n=n.next;else{if(i>=o)return{done:!0};var a=r[i++];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 ot(t,e,n,r){var o=e[n];if(o){var i=o.source,a=o.target;return r(o.key,o.attributes,i.key,a.key,i.attributes,a.attributes,o.undirected)&&t?o.key:void 0}}function it(t,e,n,r){var o=e[n];if(o){var i=!1;do{if(i=r(o.key,o.attributes,o.source.key,o.target.key,o.source.attributes,o.target.attributes,o.undirected),t&&i)return o.key;o=o.next}while(void 0!==o)}}function at(t,e){var n=t[e];return void 0!==n.next?new L((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}})):L.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 o,i,a="mixed"!==n&&n!==e.type,s="undirected"===n,u=!1,c=e._edges.values();!0!==(o=c.next()).done;)if(i=o.value,!a||i.undirected===s){var l=i,h=l.key,d=l.attributes,f=l.source,p=l.target;if(u=r(h,d,f.key,p.key,f.attributes,p.attributes,i.undirected),t&&u)return h}}function ut(t,e,n,r,o,i){var a,s=e?nt:et;if("undirected"!==n){if("out"!==r&&(a=s(t,o.in,i),t&&a))return a;if("in"!==r&&(a=s(t,o.out,i,r?void 0:o.key),t&&a))return a}if("directed"!==n&&(a=s(t,o.undirected,i),t&&a))return a}function ct(t,e,n,r,o,i,a){var s,u=n?it:ot;if("undirected"!==e){if(void 0!==o.in&&"out"!==r&&(s=u(t,o.in,i,a),t&&s))return s;if(void 0!==o.out&&"in"!==r&&(r||o.key!==i)&&(s=u(t,o.out,i,a),t&&s))return s}if("directed"!==e&&void 0!==o.undirected&&(s=u(t,o.undirected,i,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 ht(){this.A=null,this.B=null}function dt(t,e,n,r,o){for(var i in r){var a=r[i],s=a.source,u=a.target,c=s===n?u:s;if(!e||!e.has(c.key)){var l=o(c.key,c.attributes);if(t&&l)return c.key}}}function ft(t,e,n,r,o){if("mixed"!==e){if("undirected"===e)return dt(t,null,r,r.undirected,o);if("string"==typeof n)return dt(t,null,r,r[n],o)}var i,a=new ht;if("undirected"!==e){if("out"!==n){if(i=dt(t,null,r,r.in,o),t&&i)return i;a.wrap(r.in)}if("in"!==n){if(i=dt(t,a,r,r.out,o),t&&i)return i;a.wrap(r.out)}}if("directed"!==e&&(i=dt(t,a,r,r.undirected,o),t&&i))return i}function pt(t,e,n){var r=Object.keys(n),o=r.length,i=0;return new L((function(){var a=null;do{if(i>=o)return t&&t.wrap(n),{done:!0};var s=n[r[i++]],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,o){for(var i,a,s,u,c,l,h,d=r._nodes.values(),f=r.type;!0!==(i=d.next()).done;){var p=!1;if(a=i.value,"undirected"!==f)for(s in u=a.out){c=u[s];do{if(l=c.target,p=!0,h=o(a.key,l.key,a.attributes,l.attributes,c.key,c.attributes,c.undirected),t&&h)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,h=o(a.key,l.key,a.attributes,l.attributes,c.key,c.attributes,c.undirected),t&&h)return c;c=c.next}while(c)}if(n&&!p&&(h=o(a.key,null,a.attributes,null,null,null,null),t&&h))return null}}function gt(t){if(!c(t))throw new V('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 V("Graph.import: serialized node is missing its key.");if("attributes"in t&&(!c(t.attributes)||null===t.attributes))throw new V("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function yt(t){if(!c(t))throw new V('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 V("Graph.import: serialized edge is missing its source.");if(!("target"in t))throw new V("Graph.import: serialized edge is missing its target.");if("attributes"in t&&(!c(t.attributes)||null===t.attributes))throw new V("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in t&&"boolean"!=typeof t.undirected)throw new V("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}ht.prototype.wrap=function(t){null===this.A?this.A=t:null===this.B&&(this.B=t)},ht.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"]),Et=new Set(["domain","_events","_eventsCount","_maxListeners"]),At={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 _t(t,e,n,r,o,i,a,s){if(!r&&"undirected"===t.type)throw new H("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 H("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 V("Graph.".concat(e,': invalid attributes. Expecting an object but got "').concat(s,'"'));if(i=""+i,a=""+a,s=s||{},!t.allowSelfLoops&&i===a)throw new H("Graph.".concat(e,': source & target are the same ("').concat(i,"\"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false."));var u=t._nodes.get(i),l=t._nodes.get(a);if(!u)throw new W("Graph.".concat(e,': source node "').concat(i,'" not found.'));if(!l)throw new W("Graph.".concat(e,': target node "').concat(a,'" not found.'));var h={key:null,undirected:r,source:i,target:a,attributes:s};if(n)o=t._edgeKeyGenerator();else if(o=""+o,t._edges.has(o))throw new H("Graph.".concat(e,': the "').concat(o,'" edge already exists in the graph.'));if(!t.multi&&(r?void 0!==u.undirected[a]:void 0!==u.out[a]))throw new H("Graph.".concat(e,': an edge linking "').concat(i,'" 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 d=new Y(r,o,u,l,s);t._edges.set(o,d);var f=i===a;return r?(u.undirectedDegree++,l.undirectedDegree++,f&&(u.undirectedLoops++,t._undirectedSelfLoopCount++)):(u.outDegree++,l.inDegree++,f&&(u.directedLoops++,t._directedSelfLoopCount++)),t.multi?d.attachMulti():d.attach(),r?t._undirectedSize++:t._directedSize++,h.key=o,t.emit("edgeAdded",h),o}function St(t,e,n,r,o,i,a,u,l){if(!r&&"undirected"===t.type)throw new H("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 H("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 V("Graph.".concat(e,': invalid updater function. Expecting a function but got "').concat(u,'"'))}else if(!c(u))throw new V("Graph.".concat(e,': invalid attributes. Expecting an object but got "').concat(u,'"'));var h;if(i=""+i,a=""+a,l&&(h=u,u=void 0),!t.allowSelfLoops&&i===a)throw new H("Graph.".concat(e,': source & target are the same ("').concat(i,"\"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false."));var d,f,p=t._nodes.get(i),m=t._nodes.get(a);if(!n&&(d=t._edges.get(o))){if(!(d.source.key===i&&d.target.key===a||r&&d.source.key===a&&d.target.key===i))throw new H("Graph.".concat(e,': inconsistency detected when attempting to merge the "').concat(o,'" edge with "').concat(i,'" source & "').concat(a,'" target vs. ("').concat(d.source.key,'", "').concat(d.target.key,'").'));f=d}if(f||t.multi||!p||(f=r?p.undirected[a]:p.out[a]),f){var g=[f.key,!1,!1,!1];if(l?!h:!u)return g;if(l){var y=f.attributes;f.attributes=h(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&&h&&(u=h(u));var v={key:null,undirected:r,source:i,target:a,attributes:u};if(n)o=t._edgeKeyGenerator();else if(o=""+o,t._edges.has(o))throw new H("Graph.".concat(e,': the "').concat(o,'" edge already exists in the graph.'));var w=!1,b=!1;p||(p=Ct(t,i,{}),w=!0,i===a&&(m=p,b=!0)),m||(m=Ct(t,a,{}),b=!0),d=new Y(r,o,p,m,u),t._edges.set(o,d);var E=i===a;return r?(p.undirectedDegree++,m.undirectedDegree++,E&&(p.undirectedLoops++,t._undirectedSelfLoopCount++)):(p.outDegree++,m.inDegree++,E&&(p.directedLoops++,t._directedSelfLoopCount++)),t.multi?d.attachMulti():d.attach(),r?t._undirectedSize++:t._directedSize++,v.key=o,t.emit("edgeAdded",v),[o,!0,w,b]}function Nt(t,e){t._edges.delete(e.key);var n=e.source,r=e.target,o=e.attributes,i=e.undirected,a=n===r;i?(n.undirectedDegree--,r.undirectedDegree--,a&&(n.undirectedLoops--,t._undirectedSelfLoopCount--)):(n.outDegree--,r.inDegree--,a&&(n.directedLoops--,t._directedSelfLoopCount--)),t.multi?e.detachMulti():e.detach(),i?t._undirectedSize--:t._directedSize--,t.emit("edgeDropped",{key:e.key,attributes:o,source:n.key,target:r.key,undirected:i})}var It=function(n){function r(t){var e;if(e=n.call(this)||this,"boolean"!=typeof(t=s({},At,t)).multi)throw new V("Graph.constructor: invalid 'multi' option. Expecting a boolean but got \"".concat(t.multi,'".'));if(!bt.has(t.type))throw new V('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 V("Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got \"".concat(t.allowSelfLoops,'".'));var r="mixed"===t.type?j:"directed"===t.type?q:z;h(a(e),"NodeDataClass",r);var o="geid_"+wt()+"_",i=0;return h(a(e),"_attributes",{}),h(a(e),"_nodes",new Map),h(a(e),"_edges",new Map),h(a(e),"_directedSize",0),h(a(e),"_undirectedSize",0),h(a(e),"_directedSelfLoopCount",0),h(a(e),"_undirectedSelfLoopCount",0),h(a(e),"_edgeKeyGenerator",(function(){var t;do{t=o+i++}while(e._edges.has(t));return t})),h(a(e),"_options",t),Et.forEach((function(t){return h(a(e),t,e[t])})),d(a(e),"order",(function(){return e._nodes.size})),d(a(e),"size",(function(){return e._edges.size})),d(a(e),"directedSize",(function(){return e._directedSize})),d(a(e),"undirectedSize",(function(){return e._undirectedSize})),d(a(e),"selfLoopCount",(function(){return e._directedSelfLoopCount+e._undirectedSelfLoopCount})),d(a(e),"directedSelfLoopCount",(function(){return e._directedSelfLoopCount})),d(a(e),"undirectedSelfLoopCount",(function(){return e._undirectedSelfLoopCount})),d(a(e),"multi",e._options.multi),d(a(e),"type",e._options.type),d(a(e),"allowSelfLoops",e._options.allowSelfLoops),d(a(e),"implementation",(function(){return"graphology"})),e}e(r,n);var o=r.prototype;return o._resetInstanceCounters=function(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0},o.hasNode=function(t){return this._nodes.has(""+t)},o.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 o=this._nodes.get(t);return!!o&&o.out.hasOwnProperty(e)}throw new V("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."))},o.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 o=this._nodes.get(t);return!!o&&o.undirected.hasOwnProperty(e)}throw new V("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."))},o.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 V("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."))},o.directedEdge=function(t,e){if("undirected"!==this.type){if(t=""+t,e=""+e,this.multi)throw new H("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}},o.undirectedEdge=function(t,e){if("directed"!==this.type){if(t=""+t,e=""+e,this.multi)throw new H("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}},o.edge=function(t,e){if(this.multi)throw new H("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},o.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)},o.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},o.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},o.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},o.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},o.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},o.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},o.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},o.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},o.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},o.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},o.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},o.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},o.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},o.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},o.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},o.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},o.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},o.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},o.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},o.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},o.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},o.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},o.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]},o.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,o=n.target.key;if(t===r)return o;if(t===o)return r;throw new W('Graph.opposite: the "'.concat(t,'" node is not attached to the "').concat(e,'" edge (').concat(r,", ").concat(o,")."))},o.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},o.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},o.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},o.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},o.addNode=function(t,e){var n=function(t,e,n){if(n&&!c(n))throw new V('Graph.addNode: invalid attributes. Expecting an object but got "'.concat(n,'"'));if(e=""+e,n=n||{},t._nodes.has(e))throw new H('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},o.mergeNode=function(t,e){if(e&&!c(e))throw new V('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])},o.updateNode=function(t,e){if(e&&"function"!=typeof e)throw new V('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 o=e?e({}):{};return n=new this.NodeDataClass(t,o),this._nodes.set(t,n),this.emit("nodeAdded",{key:t,attributes:o}),[t,!0]},o.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{Nt(this,e),e=e.next}while(e)}for(var o in n.in){e=n.in[o];do{Nt(this,e),e=e.next}while(e)}}if("directed"!==this.type)for(var i in n.undirected){e=n.undirected[i];do{Nt(this,e),e=e.next}while(e)}this._nodes.delete(t),this.emit("nodeDropped",{key:t,attributes:n.attributes})},o.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 Nt(this,e),this},o.dropDirectedEdge=function(t,e){if(arguments.length<2)throw new H("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 H("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 Nt(this,n),this},o.dropUndirectedEdge=function(t,e){if(arguments.length<2)throw new H("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 H("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 Nt(this,n),this},o.clear=function(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")},o.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")},o.getAttribute=function(t){return this._attributes[t]},o.getAttributes=function(){return this._attributes},o.hasAttribute=function(t){return this._attributes.hasOwnProperty(t)},o.setAttribute=function(t,e){return this._attributes[t]=e,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:t}),this},o.updateAttribute=function(t,e){if("function"!=typeof e)throw new V("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},o.removeAttribute=function(t){return delete this._attributes[t],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:t}),this},o.replaceAttributes=function(t){if(!c(t))throw new V("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=t,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this},o.mergeAttributes=function(t){if(!c(t))throw new V("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},o.updateAttributes=function(t){if("function"!=typeof t)throw new V("Graph.updateAttributes: provided updater is not a function.");return this._attributes=t(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this},o.updateEachNodeAttributes=function(t,e){if("function"!=typeof t)throw new V("Graph.updateEachNodeAttributes: expecting an updater function.");if(e&&!f(e))throw new V("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");for(var n,r,o=this._nodes.values();!0!==(n=o.next()).done;)(r=n.value).attributes=t(r.key,r.attributes);this.emit("eachNodeAttributesUpdated",{hints:e||null})},o.updateEachEdgeAttributes=function(t,e){if("function"!=typeof t)throw new V("Graph.updateEachEdgeAttributes: expecting an updater function.");if(e&&!f(e))throw new V("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");for(var n,r,o,i,a=this._edges.values();!0!==(n=a.next()).done;)o=(r=n.value).source,i=r.target,r.attributes=t(r.key,r.attributes,o.key,i.key,o.attributes,i.attributes,r.undirected);this.emit("eachEdgeAttributesUpdated",{hints:e||null})},o.forEachAdjacencyEntry=function(t){if("function"!=typeof t)throw new V("Graph.forEachAdjacencyEntry: expecting a callback.");mt(!1,!1,!1,this,t)},o.forEachAdjacencyEntryWithOrphans=function(t){if("function"!=typeof t)throw new V("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");mt(!1,!1,!0,this,t)},o.forEachAssymetricAdjacencyEntry=function(t){if("function"!=typeof t)throw new V("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");mt(!1,!0,!1,this,t)},o.forEachAssymetricAdjacencyEntryWithOrphans=function(t){if("function"!=typeof t)throw new V("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");mt(!1,!0,!0,this,t)},o.nodes=function(){return"function"==typeof Array.from?Array.from(this._nodes.keys()):G(this._nodes.keys(),this._nodes.size)},o.forEachNode=function(t){if("function"!=typeof t)throw new V("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)},o.findNode=function(t){if("function"!=typeof t)throw new V("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},o.mapNodes=function(t){if("function"!=typeof t)throw new V("Graph.mapNode: expecting a callback.");for(var e,n,r=this._nodes.values(),o=new Array(this.order),i=0;!0!==(e=r.next()).done;)n=e.value,o[i++]=t(n.key,n.attributes);return o},o.someNode=function(t){if("function"!=typeof t)throw new V("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},o.everyNode=function(t){if("function"!=typeof t)throw new V("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},o.filterNodes=function(t){if("function"!=typeof t)throw new V("Graph.filterNodes: expecting a callback.");for(var e,n,r=this._nodes.values(),o=[];!0!==(e=r.next()).done;)t((n=e.value).key,n.attributes)&&o.push(n.key);return o},o.reduceNodes=function(t,e){if("function"!=typeof t)throw new V("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new V("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,o=e,i=this._nodes.values();!0!==(n=i.next()).done;)o=t(o,(r=n.value).key,r.attributes);return o},o.nodeEntries=function(){var t=this._nodes.values();return new L((function(){var e=t.next();if(e.done)return e;var n=e.value;return{value:{node:n.key,attributes:n.attributes},done:!1}}))},o.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,o){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,o,e)})),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:e,edges:r}},o.import=function(t){var e,n,o,i,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,o,i,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 V("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(t.attributes){if(!c(t.attributes))throw new V("Graph.import: invalid attributes. Expecting a plain object.");u?this.mergeAttributes(t.attributes):this.replaceAttributes(t.attributes)}if(t.nodes){if(o=t.nodes,!Array.isArray(o))throw new V("Graph.import: invalid nodes. Expecting an array.");for(e=0,n=o.length;e<n;e++){gt(i=o[e]);var l=i,h=l.key,d=l.attributes;u?this.mergeNode(h,d):this.addNode(h,d)}}if(t.edges){var f=!1;if("undirected"===this.type&&(f=!0),o=t.edges,!Array.isArray(o))throw new V("Graph.import: invalid edges. Expecting an array.");for(e=0,n=o.length;e<n;e++){yt(a=o[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},o.nullCopy=function(t){var e=new r(s({},this._options,t));return e.replaceAttributes(s({},this.getAttributes())),e},o.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},o.copy=function(t){if("string"==typeof(t=t||{}).type&&t.type!==this.type&&"mixed"!==t.type)throw new H('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 H("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 H("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),o=this._edges.values();!0!==(e=o.next()).done;)_t(r,"copy",!1,(n=e.value).undirected,n.key,n.source.key,n.target.key,s({},n.attributes));return r},o.toJSON=function(){return this.export()},o.toString=function(){return"[object Graph]"},o.inspect=function(){var e=this,n={};this._nodes.forEach((function(t,e){n[e]=t.attributes}));var r={},o={};this._edges.forEach((function(t,n){var i,a=t.undirected?"--":"->",s="",u=t.source.key,c=t.target.key;t.undirected&&u>c&&(i=u,u=c,c=i);var l="(".concat(u,")").concat(a,"(").concat(c,")");n.startsWith("geid_")?e.multi&&(void 0===o[l]?o[l]=0:o[l]++,s+="".concat(o[l],". ")):s+="[".concat(n,"]: "),r[s+=l]=t.attributes}));var i={};for(var a in this)this.hasOwnProperty(a)&&!Et.has(a)&&"function"!=typeof this[a]&&"symbol"!==t(a)&&(i[a]=this[a]);return i.attributes=this._attributes,i.nodes=n,i.edges=r,h(i,"constructor",this.constructor),i},r}(m.exports.EventEmitter);"undefined"!=typeof Symbol&&(It.prototype[Symbol.for("nodejs.util.inspect.custom")]=It.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?_t:St;t.generateKey?It.prototype[n]=function(o,i,a){return r(this,n,!0,"undirected"===(t.type||this.type),null,o,i,a,"update"===e)}:It.prototype[n]=function(o,i,a,s){return r(this,n,!1,"undirected"===(t.type||this.type),o,i,a,s,"update"===e)}}))})),function(t){K.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)}))}(It),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")}))}(It),function(t){tt.forEach((function(e){!function(t,e){var n=e.name,r=e.type,o=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,o="undirected"===e?t.undirectedSize:t.directedSize,i=new Array(o),a="undirected"===e,s=t._edges.values(),u=0;!0!==(n=s.next()).done;)(r=n.value).undirected===a&&(i[u++]=r.key);return i}(this,r);if(1===arguments.length){t=""+t;var i=this._nodes.get(t);if(void 0===i)throw new W("Graph.".concat(n,': could not find the "').concat(t,'" node in the graph.'));return function(t,e,n,r){var o=[];return ut(!1,t,e,n,r,(function(t){o.push(t)})),o}(this.multi,"mixed"===r?this.type:r,o,i)}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,o){var i=[];return ct(!1,t,e,n,r,o,(function(t){i.push(t)})),i}(r,this.multi,o,a,e)}throw new V("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,o=e.direction,i="forEach"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[i]=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(i,': could not find the "').concat(t,'" node in the graph.'));return ut(!1,this.multi,"mixed"===r?this.type:r,o,a,n)}if(3===arguments.length){t=""+t,e=""+e;var s=this._nodes.get(t);if(!s)throw new W("Graph.".concat(i,': could not find the "').concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new W("Graph.".concat(i,': could not find the "').concat(e,'" target node in the graph.'));return ct(!1,r,this.multi,o,s,e,n)}throw new V("Graph.".concat(i,": 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 o=0;"directed"!==r&&(o+=this.undirectedSize),"undirected"!==r&&(o+=this.directedSize),t=new Array(o);var a=0;e.push((function(e,r,o,i,s,u,c){t[a++]=n(e,r,o,i,s,u,c)}))}else t=[],e.push((function(e,r,o,i,a,s,u){t.push(n(e,r,o,i,a,s,u))}));return this[i].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,o,i,a,s,u){e(t,r,o,i,a,s,u)&&n.push(t)})),this[i].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 V("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 V("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,o,i,a,s,u){r=t(r,e,n,o,i,a,s,u)})),this[i].apply(this,n),r}}(t,e),function(t,e){var n=e.name,r=e.type,o=e.direction,i="find"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[i]=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(i,': could not find the "').concat(t,'" node in the graph.'));return ut(!0,this.multi,"mixed"===r?this.type:r,o,a,n)}if(3===arguments.length){t=""+t,e=""+e;var s=this._nodes.get(t);if(!s)throw new W("Graph.".concat(i,': could not find the "').concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new W("Graph.".concat(i,': could not find the "').concat(e,'" target node in the graph.'));return ct(!0,r,this.multi,o,s,e,n)}throw new V("Graph.".concat(i,": 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,o,i,a,s){return e(t,n,r,o,i,a,s)})),!!this[i].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,o,i,a,s){return!e(t,n,r,o,i,a,s)})),!this[i].apply(this,t)}}(t,e),function(t,e){var n=e.name,r=e.type,o=e.direction,i=n.slice(0,-1)+"Entries";t.prototype[i]=function(t,e){if("mixed"!==r&&"mixed"!==this.type&&r!==this.type)return L.empty();if(!arguments.length)return function(t,e){if(0===t.size)return L.empty();var n="mixed"!==e&&e!==t.type,r="undirected"===e,o=t._edges.values();return new L((function(){for(var t,e;;){if((t=o.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(i,': could not find the "').concat(t,'" node in the graph.'));return function(t,e,n){var r=L.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,o,n)}if(2===arguments.length){t=""+t,e=""+e;var a=this._nodes.get(t);if(!a)throw new W("Graph.".concat(i,': could not find the "').concat(t,'" source node in the graph.'));if(!this._nodes.has(e))throw new W("Graph.".concat(i,': could not find the "').concat(e,'" target node in the graph.'));return function(t,e,n,r){var o=L.empty();return"undirected"!==t&&(void 0!==n.in&&"out"!==e&&r in n.in&&(o=Z(o,at(n.in,r))),void 0!==n.out&&"in"!==e&&r in n.out&&(e||n.key!==r)&&(o=Z(o,at(n.out,r)))),"directed"!==t&&void 0!==n.undirected&&r in n.undirected&&(o=Z(o,at(n.undirected,r))),o}(r,o,a,e)}throw new V("Graph.".concat(i,": too many arguments (expecting 0, 1 or 2 and got ").concat(arguments.length,")."))}}(t,e)}))}(It),function(t){lt.forEach((function(e){(function(t,e){var n=e.name,r=e.type,o=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,o,e)}})(t,e),function(t,e){var n=e.name,r=e.type,o=e.direction,i="forEach"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[i]=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(i,': could not find the "').concat(t,'" node in the graph.'));ft(!1,"mixed"===r?this.type:r,o,n,e)}};var a="map"+n[0].toUpperCase()+n.slice(1);t.prototype[a]=function(t,e){var n=[];return this[i](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[i](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 V("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[i](t,(function(t,n){r=e(r,t,n)})),r}}(t,e),function(t,e){var n=e.name,r=e.type,o=e.direction,i=n[0].toUpperCase()+n.slice(1,-1),a="find"+i;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,o,n,e)}};var s="some"+i;t.prototype[s]=function(t,e){return!!this[a](t,e)};var u="every"+i;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,o=e.direction,i=n.slice(0,-1)+"Entries";t.prototype[i]=function(t){if("mixed"!==r&&"mixed"!==this.type&&r!==this.type)return L.empty();t=""+t;var e=this._nodes.get(t);if(void 0===e)throw new W("Graph.".concat(i,': 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=L.empty(),o=new ht;return"undirected"!==t&&("out"!==e&&(r=Z(r,pt(o,n,n.in))),"in"!==e&&(r=Z(r,pt(o,n,n.out)))),"directed"!==t&&(r=Z(r,pt(o,n,n.undirected))),r}("mixed"===r?this.type:r,o,e)}}(t,e)}))}(It);var Mt=function(t){function n(e){var n=s({type:"directed"},e);if("multi"in n&&!1!==n.multi)throw new V("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if("directed"!==n.type)throw new V('DirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return t.call(this,n)||this}return e(n,t),n}(It),Tt=function(t){function n(e){var n=s({type:"undirected"},e);if("multi"in n&&!1!==n.multi)throw new V("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if("undirected"!==n.type)throw new V('UndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return t.call(this,n)||this}return e(n,t),n}(It),Ot=function(t){function n(e){var n=s({multi:!0},e);if("multi"in n&&!0!==n.multi)throw new V("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");return t.call(this,n)||this}return e(n,t),n}(It),Lt=function(t){function n(e){var n=s({type:"directed",multi:!0},e);if("multi"in n&&!0!==n.multi)throw new V("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if("directed"!==n.type)throw new V('MultiDirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return t.call(this,n)||this}return e(n,t),n}(It),Pt=function(t){function n(e){var n=s({type:"undirected",multi:!0},e);if("multi"in n&&!0!==n.multi)throw new V("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if("undirected"!==n.type)throw new V('MultiUndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');return t.call(this,n)||this}return e(n,t),n}(It);function xt(t){t.from=function(e,n){var r=s({},e.options,n),o=new t(r);return o.import(e),o}}return xt(It),xt(Mt),xt(Tt),xt(Ot),xt(Lt),xt(Pt),It.Graph=It,It.DirectedGraph=Mt,It.UndirectedGraph=Tt,It.MultiGraph=Ot,It.MultiDirectedGraph=Lt,It.MultiUndirectedGraph=Pt,It.InvalidArgumentsGraphError=V,It.NotFoundGraphError=W,It.UsageGraphError=H,It}()},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,o=t.length,i=e.length,a=Math.floor(Math.max(o,i)/2)-1,s=new Array(o),u=new Array(i),c=0;c<o;c++)for(var l=Math.max(0,c-a);l<=Math.min(i,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 h=0,d=0;for(c=0;c<o;c++)if(s[c]){for(;!u[d];)d++;t.charAt(c)!==e.charAt(d++)&&h++}return(r/o+r/i+(r-(h/=2))/r)/3}(t,e,n),o=0;if(r>.7){for(var i=Math.min(t.length,e.length),a=0;t[a]===e[a]&&a<4&&a<i;)++o,a++;r+=.1*o*(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)))),o="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(r),i="/*# ".concat(o," */");return[e].concat([i]).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,o=Array.prototype.slice.call(arguments).slice(1);for(e=0,r=o.length;e<r;e++)if(o[e])for(n in o[e])t[n]=o[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,o=t.size,i={},a=new Float32Array(10*r),s=new Float32Array(3*o);return n=0,t.forEachNode((function(t,e){i[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,o,u,c,l,h){var d=i[o],f=i[u],p=e(t,r,o,u,c,l,h);a[d+6]+=p,a[f+6]+=p,s[n]=d,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,o){return o.x=e[r],o.y=e[r+1],r+=10,n?n(t,o):o}))},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(),o={},i=0,a=0,s=e.length;i<s;i+=10){if(n){var u=Object.assign({},t.getNodeAttributes(r[a]));u.x=e[i],u.y=e[i+1],u=n(r[a],u),o[r[a]]={x:u.x,y:u.y}}else o[r[a]]={x:e[i],y:e[i+1]};a++}return o},e.createWorker=function(t){var e=window.URL||window.webkitURL,n=t.toString(),r=e.createObjectURL(new Blob(["("+n+").call(this);"],{type:"text/javascript"})),o=new Worker(r);return e.revokeObjectURL(r),o}},2561:t=>{var e=10;t.exports=function(t,n,r){var o,i,a,s,u,c,l,h,d,f,p,m,g,y,v,w,b,E,A,C,_,S,N,I=n.length,M=r.length,T=t.adjustSizes,O=t.barnesHutTheta*t.barnesHutTheta,L=[];for(a=0;a<I;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<I;a+=e)p+=n[a+6];p/=I/e}if(t.barnesHutOptimize){var P,x,R,F=1/0,D=-1/0,U=1/0,k=-1/0;for(a=0;a<I;a+=e)F=Math.min(F,n[a+0]),D=Math.max(D,n[a+0]),U=Math.min(U,n[a+1]),k=Math.max(k,n[a+1]);var G=D-F,B=k-U;for(G>B?k=(U-=(G-B)/2)+G:D=(F-=(B-G)/2)+B,L[0]=-1,L[1]=(F+D)/2,L[2]=(U+k)/2,L[3]=Math.max(D-F,k-U),L[4]=-1,L[5]=-1,L[6]=0,L[7]=0,L[8]=0,o=1,a=0;a<I;a+=e)for(i=0,R=3;;){if(!(L[i+5]>=0)){if(L[i+0]<0){L[i+0]=a;break}if(L[i+5]=9*o,h=L[i+3]/2,L[(d=L[i+5])+0]=-1,L[d+1]=L[i+1]-h,L[d+2]=L[i+2]-h,L[d+3]=h,L[d+4]=d+9,L[d+5]=-1,L[d+6]=0,L[d+7]=0,L[d+8]=0,L[(d+=9)+0]=-1,L[d+1]=L[i+1]-h,L[d+2]=L[i+2]+h,L[d+3]=h,L[d+4]=d+9,L[d+5]=-1,L[d+6]=0,L[d+7]=0,L[d+8]=0,L[(d+=9)+0]=-1,L[d+1]=L[i+1]+h,L[d+2]=L[i+2]-h,L[d+3]=h,L[d+4]=d+9,L[d+5]=-1,L[d+6]=0,L[d+7]=0,L[d+8]=0,L[(d+=9)+0]=-1,L[d+1]=L[i+1]+h,L[d+2]=L[i+2]+h,L[d+3]=h,L[d+4]=L[i+4],L[d+5]=-1,L[d+6]=0,L[d+7]=0,L[d+8]=0,o+=4,P=n[L[i+0]+0]<L[i+1]?n[L[i+0]+1]<L[i+2]?L[i+5]:L[i+5]+9:n[L[i+0]+1]<L[i+2]?L[i+5]+18:L[i+5]+27,L[i+6]=n[L[i+0]+6],L[i+7]=n[L[i+0]+0],L[i+8]=n[L[i+0]+1],L[P+0]=L[i+0],L[i+0]=-1,P===(x=n[a+0]<L[i+1]?n[a+1]<L[i+2]?L[i+5]:L[i+5]+9:n[a+1]<L[i+2]?L[i+5]+18:L[i+5]+27)){if(R--){i=P;continue}R=3;break}L[x+0]=a;break}P=n[a+0]<L[i+1]?n[a+1]<L[i+2]?L[i+5]:L[i+5]+9:n[a+1]<L[i+2]?L[i+5]+18:L[i+5]+27,L[i+7]=(L[i+7]*L[i+6]+n[a+0]*n[a+6])/(L[i+6]+n[a+6]),L[i+8]=(L[i+8]*L[i+6]+n[a+1]*n[a+6])/(L[i+6]+n[a+6]),L[i+6]+=n[a+6],i=P}}if(t.barnesHutOptimize){for(m=t.scalingRatio,a=0;a<I;a+=e)for(i=0;;)if(L[i+5]>=0){if(w=Math.pow(n[a+0]-L[i+7],2)+Math.pow(n[a+1]-L[i+8],2),4*(f=L[i+3])*f/w<O){if(g=n[a+0]-L[i+7],y=n[a+1]-L[i+8],!0===T?w>0?(b=m*n[a+6]*L[i+6]/w,n[a+2]+=g*b,n[a+3]+=y*b):w<0&&(b=-m*n[a+6]*L[i+6]/Math.sqrt(w),n[a+2]+=g*b,n[a+3]+=y*b):w>0&&(b=m*n[a+6]*L[i+6]/w,n[a+2]+=g*b,n[a+3]+=y*b),(i=L[i+4])<0)break;continue}i=L[i+5]}else if((c=L[i+0])>=0&&c!==a&&(w=(g=n[a+0]-n[c+0])*g+(y=n[a+1]-n[c+1])*y,!0===T?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)),(i=L[i+4])<0)break}else for(m=t.scalingRatio,s=0;s<I;s+=e)for(u=0;u<s;u+=e)g=n[s+0]-n[u+0],y=n[s+1]-n[u+1],!0===T?(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(d=t.gravity/t.scalingRatio,m=t.scalingRatio,a=0;a<I;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]*d):w>0&&(b=m*n[a+6]*d/w),n[a+2]-=g*b,n[a+3]-=y*b;for(m=1*(t.outboundAttractionDistribution?p:1),l=0;l<M;l+=3)s=r[l+0],u=r[l+1],h=r[l+2],v=Math.pow(h,t.edgeWeightInfluence),g=n[s+0]-n[u+0],y=n[s+1]-n[u+1],!0===T?(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===T)for(a=0;a<I;a+=e)1!==n[a+9]&&((E=Math.sqrt(Math.pow(n[a+2],2)+Math.pow(n[a+3],2)))>10&&(n[a+2]=10*n[a+2]/E,n[a+3]=10*n[a+3]/E),A=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,_=.1*Math.log(1+C)/(1+Math.sqrt(A)),S=n[a+0]+n[a+2]*(_/t.slowDown),n[a+0]=S,N=n[a+1]+n[a+3]*(_/t.slowDown),n[a+1]=N);else for(a=0;a<I;a+=e)1!==n[a+9]&&(A=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,_=n[a+7]*Math.log(1+C)/(1+Math.sqrt(A)),n[a+7]=Math.min(1,Math.sqrt(_*(Math.pow(n[a+2],2)+Math.pow(n[a+3],2))/(1+Math.sqrt(A)))),S=n[a+0]+n[a+2]*(_/t.slowDown),n[a+0]=S,N=n[a+1]+n[a+3]*(_/t.slowDown),n[a+1]=N);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 i={},a=[],s=0;s<t.length;s++){var u=t[s],c=r.base?u[0]+r.base:u[0],l=i[c]||0,h="".concat(c," ").concat(l);i[c]=l+1;var d=n(h),f={css:u[1],media:u[2],sourceMap:u[3],supports:u[4],layer:u[5]};if(-1!==d)e[d].references++,e[d].updater(f);else{var p=o(f,r);r.byIndex=s,e.splice(s,0,{identifier:h,updater:p,references:1})}a.push(h)}return a}function o(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,o){var i=r(t=t||[],o=o||{});return function(t){t=t||[];for(var a=0;a<i.length;a++){var s=n(i[a]);e[s].references--}for(var u=r(t,o),c=0;c<i.length;c++){var l=n(i[c]);0===e[l].references&&(e[l].updater(),e.splice(l,1))}i=u}}},5540:(t,e,n)=>{"use strict";t=n.hmd(t);var r,o=(r="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,function(t={}){var e,n,o=void 0!==t?t:{};o.ready=new Promise((function(t,r){e=t,n=r}));var i,a=Object.assign({},o),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&&(i=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)})),o.print||console.log.bind(console);var l,h,d=o.printErr||console.warn.bind(console);Object.assign(o,a),a=null,o.arguments&&o.arguments,o.thisProgram&&o.thisProgram,o.quit&&o.quit,o.wasmBinary&&(l=o.wasmBinary),o.noExitRuntime,"object"!=typeof WebAssembly&&N("no native wasm support detected");var f,p,m,g=!1;function y(){var t=h.buffer;o.HEAP8=f=new Int8Array(t),o.HEAP16=new Int16Array(t),o.HEAP32=new Int32Array(t),o.HEAPU8=p=new Uint8Array(t),o.HEAPU16=new Uint16Array(t),o.HEAPU32=m=new Uint32Array(t),o.HEAPF32=new Float32Array(t),o.HEAPF64=new Float64Array(t)}var v,w,b=[],E=[],A=[],C=0,_=null,S=null;function N(t){o.onAbort&&o.onAbort(t),d(t="Aborted("+t+")"),g=!0,t+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(t);throw n(e),e}function I(t){return t.startsWith("data:application/octet-stream;base64,")}function M(t){try{if(t==v&&l)return new Uint8Array(l);if(i)return i(t);throw"both async and sync fetching of the wasm failed"}catch(t){N(t)}}function T(t,e,n){return function(t){return l||!s&&!u||"function"!=typeof fetch?Promise.resolve().then((function(){return M(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 M(t)}))}(t).then((function(t){return WebAssembly.instantiate(t,e)})).then((function(t){return t})).then(n,(function(t){d("failed to asynchronously prepare wasm: "+t),N(t)}))}function O(t){for(;t.length>0;)t.shift()(o)}function L(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(V(this.get_type()))return m[this.excPtr>>2];var t=this.get_adjusted_ptr();return 0!==t?t:this.excPtr}}function P(t){var e=h.buffer;try{return h.grow(t-e.byteLength+65535>>>16),y(),1}catch(t){}}function x(t){return o["_"+t]}I(v="wasmDbscan.wasm")||(w=v,v=o.locateFile?o.locateFile(w,c):c+w);var R="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function F(t,e,n,r,o){var i={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=B(e);return function(t,e,n){!function(t,e,n,r){if(!(r>0))return 0;for(var o=n+r-1,i=0;i<t.length;++i){var a=t.charCodeAt(i);if(a>=55296&&a<=57343&&(a=65536+((1023&a)<<10)|1023&t.charCodeAt(++i)),a<=127){if(n>=o)break;e[n++]=a}else if(a<=2047){if(n+1>=o)break;e[n++]=192|a>>6,e[n++]=128|63&a}else if(a<=65535){if(n+2>=o)break;e[n++]=224|a>>12,e[n++]=128|a>>6&63,e[n++]=128|63&a}else{if(n+3>=o)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=B(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=i[n[c]];l?(0===u&&(u=k()),s[c]=l(r[c])):s[c]=r[c]}var h=a.apply(null,s);return function(t){return 0!==u&&G(u),function(t){return"string"===e?(n=t)?function(t,e,n){for(var r=e+n,o=e;t[o]&&!(o>=r);)++o;if(o-e>16&&t.buffer&&R)return R.decode(t.subarray(e,o));for(var i="";e<o;){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)i+=String.fromCharCode(a);else{var c=a-65536;i+=String.fromCharCode(55296|c>>10,56320|1023&c)}}else i+=String.fromCharCode((31&a)<<6|s)}else i+=String.fromCharCode(a)}return i}(p,n,r):"":"boolean"===e?Boolean(t):t;var n,r}(t)}(h)}var D,U={__cxa_throw:function(t,e,n){throw new L(t).init(e,n),t},abort:function(){N("")},emscripten_memcpy_big:function(t,e,n){p.copyWithin(t,e,e+n)},emscripten_resize_heap:function(t){var e,n=p.length,r=2147483648;if((t>>>=0)>r)return!1;for(var o=1;o<=4;o*=2){var i=n*(1+.2/o);if(i=Math.min(i,t+100663296),P(Math.min(r,(e=Math.max(t,i))+(65536-e%65536)%65536)))return!0}return!1}},k=(function(){var t,e,r,i,a={env:U,wasi_snapshot_preview1:U};function s(t,e){var n,r=t.exports;return o.asm=r,h=o.asm.memory,y(),o.asm.__indirect_function_table,n=o.asm.__wasm_call_ctors,E.unshift(n),function(){if(C--,o.monitorRunDependencies&&o.monitorRunDependencies(C),0==C&&(null!==_&&(clearInterval(_),_=null),S)){var t=S;S=null,t()}}(),r}if(C++,o.monitorRunDependencies&&o.monitorRunDependencies(C),o.instantiateWasm)try{return o.instantiateWasm(a,s)}catch(t){d("Module.instantiateWasm callback failed with error: "+t),n(t)}(t=l,e=v,r=a,i=function(t){s(t.instance)},t||"function"!=typeof WebAssembly.instantiateStreaming||I(e)||"function"!=typeof fetch?T(e,r,i):fetch(e,{credentials:"same-origin"}).then((function(t){return WebAssembly.instantiateStreaming(t,r).then(i,(function(t){return d("wasm streaming compile failed: "+t),d("falling back to ArrayBuffer instantiation"),T(e,r,i)}))}))).catch(n)}(),o._dbscan=function(){return(o._dbscan=o.asm.dbscan).apply(null,arguments)},o._malloc=function(){return(o._malloc=o.asm.malloc).apply(null,arguments)},o._free=function(){return(o._free=o.asm.free).apply(null,arguments)},function(){return(k=o.asm.stackSave).apply(null,arguments)}),G=function(){return(G=o.asm.stackRestore).apply(null,arguments)},B=function(){return(B=o.asm.stackAlloc).apply(null,arguments)},V=function(){return(V=o.asm.__cxa_is_pointer_type).apply(null,arguments)};function W(){function t(){D||(D=!0,o.calledRun=!0,g||(O(E),e(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),function(){if(o.postRun)for("function"==typeof o.postRun&&(o.postRun=[o.postRun]);o.postRun.length;)t=o.postRun.shift(),A.unshift(t);var t;O(A)}()))}C>0||(function(){if(o.preRun)for("function"==typeof o.preRun&&(o.preRun=[o.preRun]);o.preRun.length;)t=o.preRun.shift(),b.unshift(t);var t;O(b)}(),C>0||(o.setStatus?(o.setStatus("Running..."),setTimeout((function(){setTimeout((function(){o.setStatus("")}),1),t()}),1)):t()))}if(o.ccall=F,o.cwrap=function(t,e,n,r){var o=!n||n.every((t=>"number"===t||"boolean"===t));return"string"!==e&&o&&!r?x(t):function(){return F(t,e,n,arguments)}},S=function t(){D||W(),D||(S=t)},o.preInit)for("function"==typeof o.preInit&&(o.preInit=[o.preInit]);o.preInit.length>0;)o.preInit.pop()();return W(),t.ready});"object"==typeof exports?t.exports=o:"function"==typeof define&&n.amdO?define([],(function(){return o})):"object"==typeof exports&&(exports.exportCppDbscanLib=o)},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,o,i){"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!==i&&(void 0===l[5]||(l[1]="@layer".concat(l[5].length>0?" ".concat(l[5]):""," {").concat(l[1],"}")),l[5]=i),n&&(l[2]?(l[1]="@media ".concat(l[2]," {").concat(l[1],"}"),l[2]=n):l[2]=n),o&&(l[4]?(l[1]="@supports (".concat(l[4],") {").concat(l[1],"}"),l[4]=o):l[4]="".concat(o)),e.push(l))}},e}},6572:function(t){var e;t.exports=(e=function(t,e){var n=Array.prototype.concat,r=Array.prototype.slice,o=Object.prototype.toString;function i(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]"===o.call(t)};function s(t){return"[object Function]"===o.call(t)}function u(t){return"number"==typeof t&&t-t==0}function c(){return new c._init(arguments)}function l(){return 0}function h(){return 1}function d(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:i,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(o){n[o][r]=t[o][e]}))})),n}for(var r=new Array(t.length),o=0;o<t.length;o++)r[o]=[t[o][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,o,i,s=[];for(a(t[0])||(t=[t]),n=t.length,r=t[0].length,i=0;i<r;i++){for(e=new Array(n),o=0;o<n;o++)e[o]=t[o][i];s.push(e)}return 1===s.length?s[0]:s},c.map=function(t,e,n){var r,o,i,s,u;for(a(t[0])||(t=[t]),o=t.length,i=t[0].length,s=n?t:new Array(o),r=0;r<o;r++)for(s[r]||(s[r]=new Array(i)),u=0;u<i;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,o,i,s,u;for(a(t[0])||(t=[t]),o=t.length,i=t[0].length,s=n?t:new Array(o),r=0;r<o;r++)for(s[r]||(s[r]=new Array(i)),i>0&&(s[r][0]=t[r][0]),u=1;u<i;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,o,i=new Array(t);for(s(e)&&(n=e,e=t),r=0;r<t;r++)for(i[r]=new Array(e),o=0;o<e;o++)i[r][o]=n(r,o);return i},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,h)},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,d)},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 o,a=[],u=i(t,e),c=(e*u-t*u)/((n-1)*u),l=t;for(o=0;l<=e&&o<n;l=(t*u+c*u*++o)/u)a.push(r?r(l,o):l);return a},c.arange=function(t,n,r){var o,i=[];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(o=t;o<n;o+=r)i.push(o);else for(o=t;o>n;o+=r)i.push(o);return i},c.slice=function(){function t(t,n,r,o){var i,a=[],s=t.length;if(n===e&&r===e&&o===e)return c.copy(t);if(o=o||1,(n=(n=n||0)>=0?n:s+n)===(r=(r=r||t.length)>=0?r:s+r)||0===o)return[];if(n<r&&o<0)return[];if(n>r&&o>0)return[];if(o>0)for(i=n;i<r;i+=o)a.push(t[i]);else for(i=n;i>r;i+=o)a.push(t[i]);return a}return function(e,n){var r,o;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),(o=n.row||{}).start,o.end,o.step):(o=n.row||{},r=n.col||{},t(e,o.start,o.end,o.step).map((function(e){return t(e,r.start,r.end,r.step)})))}}(),c.sliceAssign=function(n,r,o){var i,a;if(u(r.row)){if(u(r.col))return n[r.row][r.col]=o;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,i=c.arange(r.col.start,t.min(n.length,r.col.end),r.col.step);var s=r.row;return i.forEach((function(t,e){n[s][t]=o[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]=o[e]})),n}return o[0].length===e&&(o=[o]),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),i=c.arange(r.col.start,t.min(n[0].length,r.col.end),r.col.step),a.forEach((function(t,e){i.forEach((function(r,i){n[t][r]=o[e][i]}))})),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 o(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),o=0,i=e.length;--i>=0;)o+=(n=e[i]-r)*n;return o},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),o=t.mean(r);return e.exp(o)},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=[],o={};for(e=0;e<t.length;e++)o[u=t[e]]?o[u]++:(o[u]=1,n.push(u));var i=n.sort(r),a={},s=1;for(e=0;e<i.length;e++){var u,c=o[u=i[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,o=t.slice().sort(r),i=1,a=0,s=0,u=[];for(e=0;e<n;e++)o[e]===o[e+1]?i++:(i>a?(u=[o[e]],a=i,s=0):i===a&&(u.push(o[e]),s++),i=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,o=new Array(r),i=0;i<r;i++)o[i]=e[i]-n;return o},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),o=[],i=n.length-1;i>=0;i--)o.push(e.abs(n[i]-r));return t.mean(o)},t.meddev=function(n){for(var r=t.median(n),o=[],i=n.length-1;i>=0;i--)o.push(e.abs(n[i]-r));return t.median(o)},t.coeffvar=function(e){return t.stdev(e)/t.mean(e)},t.quartiles=function(t){var n=t.length,o=t.slice().sort(r);return[o[e.round(n/4)-1],o[e.round(n/2)-1],o[e.round(3*n/4)-1]]},t.quantiles=function(t,n,i,a){var s,u,c,l,h,d=t.slice().sort(r),f=[n.length],p=t.length;for(void 0===i&&(i=3/8),void 0===a&&(a=3/8),s=0;s<n.length;s++)c=p*(u=n[s])+(i+u*(1-i-a)),l=e.floor(o(c,1,p-1)),h=o(c-l,0,1),f[s]=(1-h)*d[l-1]+h*d[l];return f},t.percentile=function(t,e,n){var o=t.slice().sort(r),i=e*(o.length+(n?1:-1))+(n?0:1),a=parseInt(i),s=i-a;return a+1<o.length?o[a-1]+s*(o[a]-o[a-1]):o[a-1]},t.percentileOfScore=function(t,e,n){var r,o,i=0,a=t.length,s=!1;for("strict"===n&&(s=!0),o=0;o<a;o++)r=t[o],(s&&r<e||!s&&r<=e)&&i++;return i/a},t.histogram=function(n,r){r=r||4;var o,i=t.min(n),a=(t.max(n)-i)/r,s=n.length,u=[];for(o=0;o<r;o++)u[o]=0;for(o=0;o<s;o++)u[e.min(e.floor((n[o]-i)/a),r-1)]+=1;return u},t.covariance=function(e,n){var r,o=t.mean(e),i=t.mean(n),a=e.length,s=new Array(a);for(r=0;r<a;r++)s[r]=(e[r]-o)*(n[r]-i);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 o=t.mean(n),i=t.stdev(n),a=n.length,s=0,u=0;u<a;u++)s+=e.pow((n[u]-o)/i,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 i=t.prototype;!function(e){for(var r=0;r<e.length;r++)!function(e){i[e]=function(r,o){var a=[],s=0,u=this;if(n(r)&&(o=r,r=!1),o)return setTimeout((function(){o.call(u,i[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){i[e]=function(r,o){var a=[],s=0,u=this;if(n(r)&&(o=r,r=!1),o)return setTimeout((function(){o.call(u,i[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){i[e]=function(){var r,o=[],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,i[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++)o[a]=l(s[a]);return o}return l(this[0])}}(e[r])}("quantiles percentileOfScore".split(" "))}(e,Math),function(t,e){t.gammaln=function(t){var n,r,o,i=0,a=[76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18],s=1.000000000190015;for(o=(r=n=t)+5.5,o-=(n+.5)*e.log(o);i<6;i++)s+=a[i]/++r;return e.log(2.5066282746310007*s/n)-o},t.loggam=function(t){var n,r,o,i,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),o=2*e.PI,a=c[9],s=8;s>=0;s--)a*=r,a+=c[s];if(i=a/n+.5*e.log(o)+(n-.5)*e.log(n)-n,t<=7)for(s=1;s<=u;s++)i-=e.log(n-1),n-=1;return i},t.gammafn=function(t){var n,r,o,i,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,h=0,d=t;if(t>171.6243769536076)return 1/0;if(d<=0){if(!(i=d%1+36e-17))return 1/0;u=(1&d?-1:1)*e.PI/e.sin(e.PI*i),d=1-d}for(o=d,r=d<1?d++:(d-=c=(0|d)-1)-1,n=0;n<8;++n)h=(h+a[n])*r,l=l*r+s[n];if(i=h/l+1,o<d)i/=o;else if(o>d)for(n=0;n<c;++n)i*=d,d++;return u&&(i=u/i),i},t.gammap=function(e,n){return t.lowRegGamma(e,n)*t.gammafn(e)},t.lowRegGamma=function(n,r){var o,i=t.gammaln(n),a=n,s=1/n,u=s,c=r+1-n,l=1/1e-30,h=1/c,d=h,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)-i)}for(;f<=p;f++)d*=(h=1/(h=(o=-f*(f-n))*h+(c+=2)))*(l=c+o/l);return 1-d*e.exp(-r+n*e.log(r)-i)},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 o,i,a,s,u=1e-30,c=1,l=n+r,h=n+1,d=n-1,f=1,p=1-l*t/h;for(e.abs(p)<u&&(p=u),s=p=1/p;c<=100&&(p=1+(i=c*(r-c)*t/((d+(o=2*c))*(n+o)))*p,e.abs(p)<u&&(p=u),f=1+i/f,e.abs(f)<u&&(f=u),s*=(p=1/p)*f,p=1+(i=-(n+c)*(l+c)*t/((n+o)*(h+o)))*p,e.abs(p)<u&&(p=u),f=1+i/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 o,i,a,s,u,c,l=0,h=r-1,d=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(h),c=e.exp(h*(u-1)-d),s=n<.5?n:1-n,o=(2.30753+.27061*(i=e.sqrt(-2*e.log(s))))/(1+i*(.99229+.04481*i))-i,n<.5&&(o=-o),o=e.max(.001,r*e.pow(1-1/(9*r)-o/(3*e.sqrt(r)),3))):o=n<(i=1-r*(.253+.12*r))?e.pow(n/i,1/r):1-e.log(1-(n-i)/(1-i));l<12;l++){if(o<=0)return 0;if((o-=i=(a=(t.lowRegGamma(r,o)-n)/(i=r>1?c*e.exp(-(o-h)+h*(e.log(o)-u)):e.exp(-o+h*e.log(o)-d)))/(1-.5*e.min(1,a*((r-1)/o-1))))<=0&&(o=.5*(o+i)),e.abs(i)<1e-8*o)break}return o},t.erf=function(t){var n,r,o,i,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--)o=c,c=r*c-l+a[s],l=o;return i=n*e.exp(-t*t+.5*(a[0]+r*c)-l),u?i-1:1-i},t.erfc=function(e){return 1-t.erf(e)},t.erfcinv=function(n){var r,o,i,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*(i=e.sqrt(-2*e.log(a/2))))/(1+i*(.99229+.04481*i))-i);s<2;s++)r+=(o=t.erfc(r)-a)/(1.1283791670955126*e.exp(-r*r)-r*o);return n<1?r:-r},t.ibetainv=function(n,r,o){var i,a,s,u,c,l,h,d,f,p,m=r-1,g=o-1,y=0;if(n<=0)return 0;if(n>=1)return 1;for(r>=1&&o>=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),h=(l*l-3)/6,d=2/(1/(2*r-1)+1/(2*o-1)),f=l*e.sqrt(h+d)/d-(1/(2*o-1)-1/(2*r-1))*(h+5/6-2/(3*d)),l=r/(r+o*e.exp(2*f))):(i=e.log(r/(r+o)),a=e.log(o/(r+o)),l=n<(u=e.exp(r*i)/r)/(f=u+(c=e.exp(o*a)/o))?e.pow(r*f*n,1/r):1-e.pow(o*f*(1-n),1/o)),p=-t.gammaln(r)-t.gammaln(o)+t.gammaln(r+o);y<10;y++){if(0===l||1===l)return l;if((l-=u=(c=(t.ibeta(l,r,o)-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,o){var i=0===n||1===n?0:e.exp(t.gammaln(r+o)-t.gammaln(r)-t.gammaln(o)+r*e.log(n)+o*e.log(1-n));return!(n<0||n>1)&&(n<(r+1)/(r+o+2)?i*t.betacf(n,r,o)/r:1-i*t.betacf(1-n,o,r)/o)},t.randn=function(n,r){var o,i,a,s,u;if(r||(r=n),n)return t.create(n,r,(function(){return t.randn()}));do{o=t._random_fn(),i=1.7156*(t._random_fn()-.5),u=(a=o-.449871)*a+(s=e.abs(i)+.386595)*(.196*s-.25472*a)}while(u>.27597&&(u>.27846||i*i>-4*e.log(o)*o*o));return i/o},t.randg=function(n,r,o){var i,a,s,u,c,l,h=n;if(o||(o=r),n||(n=1),r)return(l=t.zeros(r,o)).alter((function(){return t.randg(n)})),l;n<1&&(n+=1),i=n-1/3,a=1/e.sqrt(9*i);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+i*(1-u+e.log(u)));if(n==h)return i*u;do{s=t._random_fn()}while(0===s);return e.pow(s,1/h)*i*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,o){for(var i,a=0,s=1,u=1,c=1,l=0,h=0;e.abs((u-h)/u)>o;)h=u,s=c+(i=-(n+l)*(n+r+l)*t/(n+2*l)/(n+2*l+1))*s,u=(a=u+i*a)+(i=(l+=1)*(r-l)*t/(n+2*l-1)/(n+2*l))*u,a/=c=s+i*c,s/=c,u/=c,c=1;return u/n}function r(n,r,o){var i=[.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/o)?e.pow(c,o):0;for(var l=s,h=(8-s)/(u=n>3?2:3),d=l+h,f=0,p=o-1,m=1;m<=u;m++){for(var g=0,y=.5*(d+l),v=.5*(d-l),w=1;w<=12;w++){var b,E=y+v*(6<w?i[(b=12-w+1)-1]:-i[(b=w)-1]),A=E*E;if(A>60)break;var C=2*t.normal.cdf(E,0,1,1,0)*.5-2*t.normal.cdf(E,n,1,1,0)*.5;C>=e.exp(-30/p)&&(g+=C=a[b-1]*e.exp(-.5*A)*e.pow(C,p))}f+=g*=2*v*o/e.sqrt(2*e.PI),l=d,d+=h}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,o){var i=t[e](n,r,o);return i.data=this,i},t[e].prototype.sample=function(n){var r=this._a,o=this._b,i=this._c;return n?t.alter(n,(function(){return t[e].sample(r,o,i)})):t[e].sample(r,o,i)},function(n){for(var r=0;r<n.length;r++)!function(n){t[e].prototype[n]=function(r){var o=this._a,i=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,o,i,a)})):t[e][n](r,o,i,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,o){return n>1||n<0?0:1==r&&1==o?1:r<512&&o<512?e.pow(n,r-1)*e.pow(1-n,o-1)/t.betafn(r,o):e.exp((r-1)*e.log(n)+(o-1)*e.log(1-n)-t.betaln(r,o))},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,o){var i;return n<0?0:r<=2?0===n&&r<2?1/0:0===n&&2===r?1:1/t.betafn(r/2,o/2)*e.pow(r/o,r/2)*e.pow(n,r/2-1)*e.pow(1+r/o*n,-(r+o)/2):(i=r*n/(o+n*r),r*(o/(o+n*r))/2*t.binomial.pdf((r-2)/2,(r+o-2)/2,i))},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,o){return n<0?0:0===n&&1===r?1/o:e.exp((r-1)*e.log(n)-n/o-t.gammaln(r)-r*e.log(o))},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,o){return n<=0?0:e.exp(-(r+1)*e.log(n)-o/n-t.gammaln(r)+r*e.log(o))},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,o){return n<0?0:.5+.5*t.erf((e.log(n)-r)/e.sqrt(2*o*o))},inv:function(n,r,o){return e.exp(-1.4142135623730951*o*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,o){return e.abs(o)<1e-14?t.studentt.pdf(n,r):e.abs(n)<1e-14?e.exp(t.gammaln((r+1)/2)-o*o/2-.5*e.log(e.PI*r)-t.gammaln(r/2)):r/n*(t.noncentralt.cdf(n*e.sqrt(1+2/r),r+2,o)-t.noncentralt.cdf(n,r,o))},cdf:function(n,r,o){var i=1e-14;if(e.abs(o)<i)return t.studentt.cdf(n,r);var a=!1;n<0&&(a=!0,o=-o);for(var s=t.normal.cdf(-o,0,1),u=i+1,c=u,l=n*n/(n*n+r),h=0,d=e.exp(-o*o/2),f=e.exp(-o*o/2-.5*e.log(2)-t.gammaln(1.5))*o;h<200||c>i||u>i;)c=u,h>0&&(d*=o*o/(2*h),f*=o*o/(2*(h+.5))),s+=.5*(u=d*t.beta.cdf(l,h+.5,r/2)+f*t.beta.cdf(l,h+1,r/2)),h++;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,o){return.5*(1+t.erf((n-r)/e.sqrt(2*o*o)))},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 o=r/2;return t.ibeta((n+e.sqrt(n*n+r))/(2*e.sqrt(n*n+r)),o,o)},inv:function(n,r){var o=t.ibetainv(2*e.min(n,1-n),.5*r,.5);return o=e.sqrt(r*(1-o)/o),n>.5?o:-o},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,o){return 0===o||1===o?r*o===n?1:0:t.combination(r,n)*e.pow(o,n)*e.pow(1-o,r-n)},cdf:function(r,o,i){var a,s=1e-10;if(r<0)return 0;if(r>=o)return 1;if(i<0||i>1||o<=0)return NaN;var u=i,c=(r=e.floor(r))+1,l=o-r,h=c+l,d=e.exp(t.gammaln(h)-t.gammaln(l)-t.gammaln(c)+c*e.log(u)+l*e.log(1-u));return a=u<(c+1)/(h+2)?d*n(u,c,l,s):1-d*n(1-u,l,c,s),e.round(1/s*(1-a))/(1/s)}}),t.extend(t.negbin,{pdf:function(n,r,o){return n===n>>>0&&(n<0?0:t.combination(n+r-1,r-1)*e.pow(1-o,n)*e.pow(o,r))},cdf:function(e,n,r){var o=0,i=0;if(e<0)return 0;for(;i<=e;i++)o+=t.negbin.pdf(i,n,r);return o}}),t.extend(t.hypgeom,{pdf:function(n,r,o,i){if(n!=n|0)return!1;if(n<0||n<o-(r-i))return 0;if(n>i||n>o)return 0;if(2*o>r)return 2*i>r?t.hypgeom.pdf(r-o-i+n,r,r-o,r-i):t.hypgeom.pdf(i-n,r,r-o,i);if(2*i>r)return t.hypgeom.pdf(o-n,r,o,r-i);if(o<i)return t.hypgeom.pdf(n,r,i,o);for(var a=1,s=0,u=0;u<n;u++){for(;a>1&&s<i;)a*=1-o/(r-s),s++;a*=(i-u)*(o-u)/((u+1)*(r-o-i+u+1))}for(;s<i;s++)a*=1-o/(r-s);return e.min(1,e.max(0,a))},cdf:function(n,r,o,i){if(n<0||n<o-(r-i))return 0;if(n>=i||n>=o)return 1;if(2*o>r)return 2*i>r?t.hypgeom.cdf(r-o-i+n,r,r-o,r-i):1-t.hypgeom.cdf(i-n-1,r,r-o,i);if(2*i>r)return 1-t.hypgeom.cdf(o-n-1,r,o,r-i);if(o<i)return t.hypgeom.cdf(n,r,i,o);for(var a=1,s=1,u=0,c=0;c<n;c++){for(;a>1&&u<i;){var l=1-o/(r-u);s*=l,a*=l,u++}a+=s*=(i-c)*(o-c)/((c+1)*(r-o-i+c+1))}for(;u<i;u++)a*=1-o/(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=[],o=0;if(e<0)return 0;for(;o<=e;o++)r.push(t.poisson.pdf(o,n));return t.sum(r)},mean:function(t){return t},variance:function(t){return t},sampleSmall:function(n){var r=1,o=0,i=e.exp(-n);do{o++,r*=t._random_fn()}while(r>i);return o-1},sampleLarge:function(n){var r,o,i,a,s,u,c,l,h,d,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),h=.9277-3.6224/(c-2);;){if(o=e.random()-.5,i=e.random(),d=.5-e.abs(o),r=e.floor((2*u/d+c)*o+f+.43),d>=.07&&i<=h)return r;if(!(r<0||d<.013&&i>d)&&e.log(i)+e.log(l)-e.log(u/(d*d)+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,o){return r<=n||o<n||o>r?NaN:t<=n?0:t>=r?1:t<=o?e.pow(t-n,2)/((r-n)*(o-n)):1-e.pow(r-t,2)/((r-n)*(r-o))},inv:function(t,n,r,o){return r<=n||o<n||o>r?NaN:t<=(o-n)/(r-n)?n+(r-n)*e.sqrt(t*((o-n)/(r-n))):n+(r-n)*(1-e.sqrt((1-t)*(1-(o-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,o){var i=t._random_fn();return i<(o-n)/(r-n)?n+e.sqrt(i*(r-n)*(o-n)):r-e.sqrt((1-i)*(r-n)*(r-o))},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 o,i=t._random_fn()-.5;return n-r*((o=i)/e.abs(o))*e.log(1-2*e.abs(i))}}),t.extend(t.tukey,{cdf:function(n,o,i){var a=o,s=[.9894009349916499,.9445750230732326,.8656312023878318,.755404408355003,.6178762444026438,.45801677765722737,.2816035507792589,.09501250983763744],u=[.027152459411754096,.062253523938647894,.09515851168249279,.12462897125553388,.14959598881657674,.16915651939500254,.18260341504492358,.1894506104550685];if(n<=0)return 0;if(i<2||a<2)return NaN;if(!Number.isFinite(n))return 1;if(i>25e3)return r(n,1,a);var c,l=.5*i,h=l*e.log(i)-i*e.log(2)-t.gammaln(l),d=l-1,f=.25*i;c=i<=100?1:i<=800?.5:i<=5e3?.25:.125,h+=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=h+d*e.log(y+s[w]*c)-(s[w]*c+y)*f):(w=v-1,b=h+d*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,o){if(o<2||r<2)return NaN;if(n<0||n>1)return NaN;if(0===n)return 0;if(1===n)return 1/0;var i,a=function(t,n,r){var o=.5-.5*t,i=e.sqrt(e.log(1/(o*o))),a=i+((((-453642210148e-16*i-.204231210125)*i-.342242088547)*i-1)*i+.322232421088)/((((.0038560700634*i+.10353775285)*i+.531103462366)*i+.588581570495)*i+.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,o),s=t.tukey.cdf(a,r,o)-n;i=s>0?e.max(0,a-1):a+1;for(var u,c=t.tukey.cdf(i,r,o)-n,l=1;l<50;l++)if(u=i-c*(i-a)/(c-s),s=c,a=i,u<0&&(u=0,c=-n),c=t.tukey.cdf(u,r,o)-n,i=u,e.abs(i-a)<1e-4)return u;throw new Error("tukey.inv failed to converge")}})}(e,Math),function(t,e){var n,r,o=Array.prototype.push,i=t.utils.isArray;function a(e){return i(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,o,i,s,u,c,l,h;if(void 0===e.length&&void 0===n.length)return e*n;if(u=e.length,c=e[0].length,l=t.zeros(u,i=a(n)?n[0].length:c),h=0,a(n)){for(;h<i;h++)for(r=0;r<u;r++){for(s=0,o=0;o<c;o++)s+=e[r][o]*n[o][h];l[r][h]=s}return 1===u&&1===h?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,o,i=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=i.length,h=i[0].length;c<l;c++){for(u[c]=[],r=0,o=0;o<h;o++)r+=i[c][o]*s[c][o];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,o=0;for(isNaN(n)&&(n=2),a(t[0])&&(t=t[0]);o<t.length;o++)r+=e.pow(e.abs(t[o]),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++)o.apply(r[n],e[n]);return r},inv:function(e){for(var n,r=e.length,o=e[0].length,i=t.identity(r,o),a=t.gauss_jordan(e,i),s=[],u=0;u<r;u++)for(s[u]=[],n=o;n<a[0].length;n++)s[u][n-o]=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 o=[],i=1;i<e.length;i++){o[i-1]=[];for(var a=0;a<e.length;a++)a<r?o[i-1][a]=e[i][a]:a>r&&(o[i-1][a-1]=e[i][a])}var s=r%2?-1:1;n+=t(o)*e[0][r]*s}return n},gauss_elimination:function(n,r){var o,i,a,s,u=0,c=0,l=n.length,h=n[0].length,d=1,f=0,p=[];for(o=(n=t.aug(n,r))[0].length,u=0;u<l;u++){for(i=n[u][u],c=u,s=u+1;s<h;s++)i<e.abs(n[s][u])&&(i=n[s][u],c=s);if(c!=u)for(s=0;s<o;s++)a=n[u][s],n[u][s]=n[c][s],n[c][s]=a;for(c=u+1;c<l;c++)for(d=n[c][u]/n[u][u],s=u;s<o;s++)n[c][s]=n[c][s]-d*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][o-1]-f)/n[u][u]}return p},gauss_jordan:function(n,r){var o,i,a,s=t.aug(n,r),u=s.length,c=s[0].length,l=0;for(i=0;i<u;i++){var h=i;for(a=i+1;a<u;a++)e.abs(s[a][i])>e.abs(s[h][i])&&(h=a);var d=s[i];for(s[i]=s[h],s[h]=d,a=i+1;a<u;a++)for(l=s[a][i]/s[i][i],o=i;o<c;o++)s[a][o]-=s[i][o]*l}for(i=u-1;i>=0;i--){for(l=s[i][i],a=0;a<i;a++)for(o=c-1;o>i-1;o--)s[a][o]-=s[i][o]*s[a][i]/l;for(s[i][i]/=l,o=u;o<c;o++)s[i][o]/=l}return s},triaUpSolve:function(e,n){var r,o=e[0].length,i=t.zeros(1,o)[0],a=!1;return null!=n[0].length&&(n=n.map((function(t){return t[0]})),a=!0),t.arange(o-1,-1,-1).forEach((function(a){r=t.arange(a+1,o).map((function(t){return i[t]*e[a][t]})),i[a]=(n[a]-t.sum(r))/e[a][a]})),a?i.map((function(t){return[t]})):i},triaLowSolve:function(e,n){var r,o=e[0].length,i=t.zeros(1,o)[0],a=!1;return null!=n[0].length&&(n=n.map((function(t){return t[0]})),a=!0),t.arange(o).forEach((function(o){r=t.arange(o).map((function(t){return e[o][t]*i[t]})),i[o]=(n[o]-t.sum(r))/e[o][o]})),a?i.map((function(t){return[t]})):i},lu:function(e){var n,r=e.length,o=t.identity(r),i=t.zeros(e.length,e[0].length);return t.arange(r).forEach((function(t){i[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 o[a][t]*i[t][r]})),o[a][r]=(e[a][r]-t.sum(n))/i[r][r]})),t.arange(a,r).forEach((function(r){n=t.arange(a).map((function(t){return o[a][t]*i[t][r]})),i[a][r]=e[n.length][r]-t.sum(n)}))})),[o,i]},cholesky:function(n){var r,o=n.length,i=t.zeros(n.length,n[0].length);return t.arange(o).forEach((function(a){r=t.arange(a).map((function(t){return e.pow(i[a][t],2)})),i[a][a]=e.sqrt(n[a][a]-t.sum(r)),t.arange(a+1,o).forEach((function(e){r=t.arange(a).map((function(t){return i[a][t]*i[e][t]})),i[e][a]=(n[a][e]-t.sum(r))/i[a][a]}))})),i},gauss_jacobi:function(n,r,o,i){for(var a,s,u,c,l=0,h=0,d=n.length,f=[],p=[],m=[];l<d;l++)for(f[l]=[],p[l]=[],m[l]=[],h=0;h<d;h++)l>h?(f[l][h]=n[l][h],p[l][h]=m[l][h]=0):l<h?(p[l][h]=n[l][h],f[l][h]=m[l][h]=0):(m[l][h]=n[l][h],f[l][h]=p[l][h]=0);for(u=t.multiply(t.multiply(t.inv(m),t.add(f,p)),-1),s=t.multiply(t.inv(m),r),a=o,c=t.add(t.multiply(u,o),s),l=2;e.abs(t.norm(t.subtract(c,a)))>i;)a=c,c=t.add(t.multiply(u,a),s),l++;return c},gauss_seidel:function(n,r,o,i){for(var a,s,u,c,l,h=0,d=n.length,f=[],p=[],m=[];h<d;h++)for(f[h]=[],p[h]=[],m[h]=[],a=0;a<d;a++)h>a?(f[h][a]=n[h][a],p[h][a]=m[h][a]=0):h<a?(p[h][a]=n[h][a],f[h][a]=m[h][a]=0):(m[h][a]=n[h][a],f[h][a]=p[h][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=o,l=t.add(t.multiply(c,o),u),h=2;e.abs(t.norm(t.subtract(l,s)))>i;)s=l,l=t.add(t.multiply(c,s),u),h+=1;return l},SOR:function(n,r,o,i,a){for(var s,u,c,l,h,d=0,f=n.length,p=[],m=[],g=[];d<f;d++)for(p[d]=[],m[d]=[],g[d]=[],s=0;s<f;s++)d>s?(p[d][s]=n[d][s],m[d][s]=g[d][s]=0):d<s?(m[d][s]=n[d][s],p[d][s]=g[d][s]=0):(g[d][s]=n[d][s],p[d][s]=m[d][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=o,h=t.add(t.multiply(l,o),c),d=2;e.abs(t.norm(t.subtract(h,u)))>i;)u=h,h=t.add(t.multiply(l,u),c),d++;return h},householder:function(n){for(var r,o,i,a,s=n.length,u=n[0].length,c=0,l=[],h=[];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),o=e.sqrt((r*r-n[c+1][c]*r)/2),(l=t.zeros(s,1))[c+1][0]=(n[c+1][c]-r)/(2*o),i=c+2;i<s;i++)l[i][0]=n[i][c]/(2*o);h=t.subtract(t.identity(s,u),t.multiply(t.multiply(l,t.transpose(l)),2)),n=t.multiply(h,t.multiply(n,h))}return n},QR:(n=t.sum,r=t.arange,function(o){var i,a,s,u=o.length,c=o[0].length,l=t.zeros(c,c);for(o=t.copy(o),a=0;a<c;a++){for(l[a][a]=e.sqrt(n(r(u).map((function(t){return o[t][a]*o[t][a]})))),i=0;i<u;i++)o[i][a]=o[i][a]/l[a][a];for(s=a+1;s<c;s++)for(l[a][s]=n(r(u).map((function(t){return o[t][a]*o[t][s]}))),i=0;i<u;i++)o[i][s]=o[i][s]-o[i][a]*l[a][s]}return[o,l]}),lstsq:function(e,n){var r=!1;void 0===n[0].length&&(n=n.map((function(t){return[t]})),r=!0);var o=t.QR(e),i=o[0],a=o[1],s=e[0].length,u=t.slice(i,{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(o){var i=t.multiply(e[o][n],-1),a=t.slice(e,{row:o}),s=t.multiply(t.slice(e,{row:n}),i);t.sliceAssign(e,{row:o},t.add(a,s));var u=t.slice(r,{row:o}),c=t.multiply(t.slice(r,{row:n}),i);t.sliceAssign(r,{row:o},t.add(u,c))}))})),r}(t.slice(a,{row:{end:s}})),l=t.transpose(u);void 0===l[0].length&&(l=[l]);var h=t.multiply(t.multiply(c,l),n);return void 0===h.length&&(h=[[h]]),r?h.map((function(t){return t[0]})):h},jacobi:function(n){for(var r,o,i,a,s,u,c,l=1,h=n.length,d=t.identity(h,h),f=[];1===l;){for(s=n[0][1],i=0,a=1,r=0;r<h;r++)for(o=0;o<h;o++)r!=o&&s<e.abs(n[r][o])&&(s=e.abs(n[r][o]),i=r,a=o);for(u=n[i][i]===n[a][a]?n[i][a]>0?e.PI/4:-e.PI/4:e.atan(2*n[i][a]/(n[i][i]-n[a][a]))/2,(c=t.identity(h,h))[i][i]=e.cos(u),c[i][a]=-e.sin(u),c[a][i]=e.sin(u),c[a][a]=e.cos(u),d=t.multiply(d,c),n=t.multiply(t.multiply(t.inv(c),n),c),l=0,r=1;r<h;r++)for(o=1;o<h;o++)r!=o&&e.abs(n[r][o])>.001&&(l=1)}for(r=0;r<h;r++)f.push(n[r][r]);return[d,f]},rungekutta:function(t,e,n,r,o,i){var a,s,u;if(2===i)for(;r<=n;)o+=((a=e*t(r,o))+(s=e*t(r+e,o+a)))/2,r+=e;if(4===i)for(;r<=n;)o+=((a=e*t(r,o))+2*(s=e*t(r+e/2,o+a/2))+2*(u=e*t(r+e/2,o+s/2))+e*t(r+e,o+u))/6,r+=e;return o},romberg:function(t,n,r,o){for(var i,a,s,u,c,l=0,h=(r-n)/2,d=[],f=[],p=[];l<o/2;){for(c=t(n),s=n,u=0;s<=r;s+=h,u++)d[u]=s;for(i=d.length,s=1;s<i-1;s++)c+=(s%2!=0?4:2)*t(d[s]);c=h/3*(c+t(r)),p[l]=c,h/=2,l++}for(a=p.length,i=1;1!==a;){for(s=0;s<a-1;s++)f[s]=(e.pow(4,i)*p[s+1]-p[s])/(e.pow(4,i)-1);a=f.length,p=f,f=[],i++}return p},richardson:function(t,n,r,o){function i(t,e){for(var n,r=0,o=t.length;r<o;r++)t[r]===e&&(n=r);return n}for(var a,s,u,c,l,h=e.abs(r-t[i(t,r)+1]),d=0,f=[],p=[];o>=h;)a=i(t,r+o),s=i(t,r),f[d]=(n[a]-2*n[s]+n[2*s-a])/(o*o),o/=2,d++;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 o,i=(n-e)/r,a=t(e),s=[],u=e,c=0,l=1;u<=n;u+=i,c++)s[c]=u;for(o=s.length;l<o-1;l++)a+=(l%2!=0?4:2)*t(s[l]);return i/3*(a+t(n))},hermite:function(t,e,n,r){for(var o,i=t.length,a=0,s=0,u=[],c=[],l=[],h=[];s<i;s++){for(u[s]=1,o=0;o<i;o++)s!=o&&(u[s]*=(r-t[o])/(t[s]-t[o]));for(c[s]=0,o=0;o<i;o++)s!=o&&(c[s]+=1/(t[s]-t[o]));l[s]=(1-2*(r-t[s])*c[s])*(u[s]*u[s]),h[s]=(r-t[s])*(u[s]*u[s]),a+=l[s]*e[s]+h[s]*n[s]}return a},lagrange:function(t,e,n){for(var r,o,i=0,a=0,s=t.length;a<s;a++){for(o=e[a],r=0;r<s;r++)a!=r&&(o*=(n-t[r])/(t[a]-t[r]));i+=o}return i},cubic_spline:function(e,n,r){for(var o,i,a=e.length,s=0,u=[],c=[],l=[],h=[],d=[],f=[];s<a-1;s++)h[s]=e[s+1]-e[s];for(l[0]=0,s=1;s<a-1;s++)l[s]=3/h[s]*(n[s+1]-n[s])-3/h[s-1]*(n[s]-n[s-1]);for(s=1;s<a-1;s++)u[s]=[],c[s]=[],u[s][s-1]=h[s-1],u[s][s]=2*(h[s-1]+h[s]),u[s][s+1]=h[s],c[s][0]=l[s];for(i=t.multiply(t.inv(u),c),o=0;o<a-1;o++)d[o]=(n[o+1]-n[o])/h[o]-h[o]*(i[o+1][0]+2*i[o][0])/3,f[o]=(i[o+1][0]-i[o][0])/(3*h[o]);for(o=0;o<a&&!(e[o]>r);o++);return n[o-=1]+(r-e[o])*d[o]+t.sq(r-e[o])*i[o]+(r-e[o])*t.sq(r-e[o])*f[o]},gauss_quadrature:function(){throw new Error("gauss_quadrature not yet implemented")},PCA:function(e){var n,r,o,i,a,s=e.length,u=e[0].length,c=0,l=[],h=[],d=[],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=(o=t.jacobi(m))[0],h=o[1],g=t.transpose(a),c=0;c<h.length;c++)for(n=c;n<h.length;n++)h[c]<h[n]&&(r=h[c],h[c]=h[n],h[n]=r,d=g[c],g[c]=g[n],g[n]=d);for(i=t.transpose(p),c=0;c<s;c++)for(f[c]=[],n=0;n<i.length;n++)f[c][n]=t.dot([g[c]],[i[n]]);return[e,h,g,f]}}),function(e){for(var n=0;n<e.length;n++)!function(e){t.fn[e]=function(n,r){var o=this;return r?(setTimeout((function(){r.call(o,t.fn[e].call(o,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,o=t.utils.isArray;function i(t,n,r,o){if(t>1||r>1||t<=0||r<=0)throw new Error("Proportions should be greater than 0 and less than 1");var i=(t*n+r*o)/(n+o);return(t-r)/e.sqrt(i*(1-i)*(1/n+1/o))}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,i=n.call(arguments);return o(i[1])?(r=t.zscore(i[0],i[1],i[3]),1===i[2]?t.normal.cdf(-e.abs(r),0,1):2*t.normal.cdf(-e.abs(r),0,1)):i.length>2?(r=t.zscore(i[0],i[1],i[2]),1===i[3]?t.normal.cdf(-e.abs(r),0,1):2*t.normal.cdf(-e.abs(r),0,1)):(r=i[0],1===i[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,o){var i=e.abs(this.zscore(n,o));return 1===r?t.normal.cdf(-i,0,1):2*t.normal.cdf(-i,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 o,i=n.call(arguments);return 5===i.length?(o=e.abs(t.tscore(i[0],i[1],i[2],i[3])),1===i[4]?t.studentt.cdf(-o,i[3]-1):2*t.studentt.cdf(-o,i[3]-1)):r(i[1])?(o=e.abs(i[0]),1==i[2]?t.studentt.cdf(-o,i[1]-1):2*t.studentt.cdf(-o,i[1]-1)):(o=e.abs(t.tscore(i[0],i[1])),1==i[2]?t.studentt.cdf(-o,i[1].length-1):2*t.studentt.cdf(-o,i[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,o,i,a,s,u,c,l,h=n.call(arguments);if(1===h.length){for(s=new Array(h[0].length),c=0;c<h[0].length;c++)s[c]=h[0][c];h=s}for(o=new Array,c=0;c<h.length;c++)o=o.concat(h[c]);for(i=t.mean(o),r=0,c=0;c<h.length;c++)r+=h[c].length*e.pow(t.mean(h[c])-i,2);for(r/=h.length-1,u=0,c=0;c<h.length;c++)for(a=t.mean(h[c]),l=0;l<h[c].length;l++)u+=e.pow(h[c][l]-a,2);return r/(u/(o.length-h.length))},anovaftest:function(){var e,o,i,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,i=0,a=0;a<s.length;a++)i+=s[a].length;return o=i-e-1,1-t.centralF.cdf(u,e,o)},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 o,i,a,s,u,c=n.call(arguments);return r(c[0])?(o=c[0],i=c[1],a=c[2],s=c[3],u=c[4]):(o=t.mean(c[0]),i=t.mean(c[1]),a=c[0].length,s=c[1].length,u=c[2]),e.abs(o-i)/(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 o=r[0],i=r[1];return 1-t.tukey.cdf(e,i,o-i)},tukeyhsd:function(e){for(var n=t.pooledstdev(e),r=e.map((function(e){return t.mean(e)})),o=e.reduce((function(t,e){return t+e.length}),0),i=[],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,o,e.length);i.push([[a,s],u])}return i}}),t.extend({normalci:function(){var r,o=n.call(arguments),i=new Array(2);return r=4===o.length?e.abs(t.normal.inv(o[1]/2,0,1)*o[2]/e.sqrt(o[3])):e.abs(t.normal.inv(o[1]/2,0,1)*t.stdev(o[2])/e.sqrt(o[2].length)),i[0]=o[0]-r,i[1]=o[0]+r,i},tci:function(){var r,o=n.call(arguments),i=new Array(2);return r=4===o.length?e.abs(t.studentt.inv(o[1]/2,o[3]-1)*o[2]/e.sqrt(o[3])):e.abs(t.studentt.inv(o[1]/2,o[2].length-1)*t.stdev(o[2],!0)/e.sqrt(o[2].length)),i[0]=o[0]-r,i[1]=o[0]+r,i},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,o){var a=i(e,n,r,o);return t.ztest(a,1)},twoSidedDifferenceOfProportions:function(e,n,r,o){var a=i(e,n,r,o);return t.ztest(a,2)}})}(e,Math),e.models=function(){function t(t,n){var r=t.length,o=n[0].length-1,i=r-o-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)}))),h=e.sum(t.map((function(t,e){return Math.pow(t-s[e],2)}))),d=l+h;return{exog:n,endog:t,nobs:r,df_model:o,df_resid:i,coef:a,predict:s,resid:u,ybar:c,SST:d,SSE:l,SSR:h,R2:l/d}}function n(n){var r,o,i=(r=n.exog,o=r[0].length,e.arange(o).map((function(n){var i=e.arange(o).filter((function(t){return t!==n}));return t(e.col(r,n).map((function(t){return t[0]})),e.col(r,i))}))),a=Math.sqrt(n.SSR/n.df_resid),s=i.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),h=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:h}}return{ols:function(r,o){var i=t(r,o),a=n(i),s=function(t){var n,r,o,i=t.R2/t.df_model/((1-t.R2)/t.df_resid);return{F_statistic:i,pvalue:1-(n=i,r=t.df_model,o=t.df_resid,e.beta.cdf(n/(o/r+n),r/2,o/2))}}(i),u=1-(1-i.R2)*((i.nobs-1)/i.df_resid);return i.t=a,i.f=s,i.adjust_R2=u,i}}}(),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,o,i,a,s;if(t.cols()==n.rows()){if(n.rows()>1){for(a=[],r=0;r<t.rows();r++)for(a[r]=[],o=0;o<n.cols();o++){for(s=0,i=0;i<t.cols();i++)s+=t.toArray()[r][i]*n.toArray()[i][o];a[r][o]=s}return e(a)}for(a=[],r=0;r<t.rows();r++)for(a[r]=[],o=0;o<n.cols();o++){for(s=0,i=0;i<t.cols();i++)s+=t.toArray()[r][i]*n.toArray()[o];a[r][o]=s}return e(a)}},regress:function(t,n){var r=e.xtranspxinv(t),o=t.transpose(),i=e.matrixmult(e(r),o);return e.matrixmult(i,n)},regresst:function(t,n,r){var o=e.regress(t,n),i={anova:{}},a=e.jMatYBar(t,o);i.yBar=a;var s=n.mean();i.anova.residuals=e.residuals(n,a),i.anova.ssr=e.ssr(a,s),i.anova.msr=i.anova.ssr/(t[0].length-1),i.anova.sse=e.sse(n,a),i.anova.mse=i.anova.sse/(n.length-(t[0].length-1)-1),i.anova.sst=e.sst(n,s),i.anova.mst=i.anova.sst/(n.length-1),i.anova.r2=1-i.anova.sse/i.anova.sst,i.anova.r2<0&&(i.anova.r2=0),i.anova.fratio=i.anova.msr/i.anova.mse,i.anova.pvalue=e.anovaftest(i.anova.fratio,t[0].length-1,n.length-(t[0].length-1)-1),i.anova.rmse=Math.sqrt(i.anova.mse),i.anova.r2adj=1-i.anova.mse/i.anova.mst,i.anova.r2adj<0&&(i.anova.r2adj=0),i.stats=new Array(t[0].length);for(var u,c,l,h=e.xtranspxinv(t),d=0;d<o.length;d++)u=Math.sqrt(i.anova.mse*Math.abs(h[d][d])),c=Math.abs(o[d]/u),l=e.ttest(c,n.length-t[0].length-1,r),i.stats[d]=[o[d],u,c,l];return i.regress=o,i},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),o=0;o<t.length;o++){r[o]=new Array(t[o].length);for(var i=0;i<t[o].length;i++)r[o][i]=t[o][i]-n[o][i]}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 o=void 0!==n.layer;o&&(r+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),r+=n.css,o&&(r+="}"),n.media&&(r+="}"),n.supports&&(r+="}");var i=n.sourceMap;i&&"undefined"!=typeof btoa&&(r+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(i))))," */")),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),o=n.n(r),i=n(6314),a=n.n(i)()(o());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 o=function(e){return r(e[t])},i=function(){return r(void 0)};return"string"==typeof t?(n.fromAttributes=o,n.fromGraph=function(t,e){return o(t.getEdgeAttributes(e))},n.fromEntry=function(t,e){return o(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 o=e.extremities(n);return r(t(n,e.getEdgeAttributes(n),o[0],o[1],e.getNodeAttributes(o[0]),e.getNodeAttributes(o[1]),e.isUndirected(n)))},n.fromEntry=function(e,n,o,i,a,s,u){return r(t(e,n,o,i,a,s,u))},n.fromPartialEntry=function(e,n,o,i){return r(t(e,n,o,i))},n.fromMinimalEntry=function(e,n){return r(t(e,n))}):(n.fromAttributes=i,n.fromGraph=i,n.fromEntry=i,n.fromMinimalEntry=i),n}(t,n)}},8903:(t,e,n)=>{var r=n(1736),o=n(8153).Fd,i=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=o("getEdgeWeight"in n?n.getEdgeWeight:"weight").fromEntry,l="function"==typeof n.outputReducer?n.outputReducer:null,h=a.assign({},s,n.settings),d=a.validateSettings(h);if(d)throw new Error("graphology-layout-forceatlas2: "+d.message);var f,p=a.graphToByteArrays(e,c);for(f=0;f<u;f++)i(h,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 o=e[r];if(void 0!==o)return o.exports;var i=e[r]={id:r,loaded:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.loaded=!0,i.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 o=r.length-1;o>-1&&(!t||!/^http(s?):/.test(t));)t=r[o--].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:()=>no,MCLClustering:()=>ro,MVA:()=>so,PCA:()=>Qr,PLS:()=>io,_package:()=>Yr,anova:()=>Oo,applyLinearKernelSVM:()=>lo,applyLinearRegression:()=>Ro,applyPLSRegression:()=>Wo,applyPolynomialKernelSVM:()=>Eo,applyRBFkernelSVM:()=>go,applySigmoidKernelSVM:()=>No,applySoftmax:()=>ko,applyXGBooster:()=>Yo,dbScan:()=>Xr,dbscanPostProcessingFunction:()=>Jr,demoMultivariateAnalysis:()=>uo,info:()=>$r,init:()=>Kr,isApplicableLinearKernelSVM:()=>ho,isApplicableLinearRegression:()=>Fo,isApplicablePLSRegression:()=>Ho,isApplicablePolynomialKernelSVM:()=>Ao,isApplicableRBFkernelSVM:()=>yo,isApplicableSigmoidKernelSVM:()=>Io,isApplicableSoftmax:()=>Go,isApplicableXGBooster:()=>Ko,isInteractiveLinearKernelSVM:()=>fo,isInteractiveLinearRegression:()=>Do,isInteractivePLSRegression:()=>qo,isInteractivePolynomialKernelSVM:()=>Co,isInteractiveRBFkernelSVM:()=>vo,isInteractiveSigmoidKernelSVM:()=>Mo,isInteractiveSoftmax:()=>Bo,isInteractiveXGBooster:()=>$o,kNNImputation:()=>Lo,kNNImputationForTable:()=>Po,markovClusteringViewer:()=>oo,numberPreprocessingFunction:()=>Zr,reduceDimensionality:()=>eo,stringPreprocessingFunction:()=>to,topMenuPLS:()=>ao,trainLinearKernelSVM:()=>co,trainLinearRegression:()=>xo,trainPLSRegression:()=>Vo,trainPolynomialKernelSVM:()=>bo,trainRBFkernelSVM:()=>mo,trainSigmoidKernelSVM:()=>So,trainSoftmax:()=>Uo,trainXGBooster:()=>zo,visualizeLinearKernelSVM:()=>po,visualizePLSRegression:()=>jo,visualizePolynomialKernelSVM:()=>_o,visualizeRBFkernelSVM:()=>wo,visualizeSigmoidKernelSVM:()=>To});const t=grok,e=ui,o=DG,i={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[i[e]];let o=null;const u=this.data;o="int"==u.type&&"i32"==e||"double"==u.type&&"f32"==e?u.getRawData():new a[e](u.getRawData()),o&&r.set(o,this.buf>>n)}}getDataFromBuffer(t){if(this.toUpdate&&this.isMemoryForBufferAllocated()){const e=this.type,n=t[i[e]],r=this.buf,o=a[e].BYTES_PER_ELEMENT,s=this.data.getRawData();for(let t=0;t<this.numOfRows;t++)s[t]=n[r/o+t]}}freeBuffer(t){this.isMemoryForBufferAllocated()&&(t._free(this.buf),this.buf=0)}}class h 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[i[e]],r=this.buf,o=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=o("name",s)}}}class d 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[i[e]],o=a[e].BYTES_PER_ELEMENT;for(let t=0;t<this.numOfColumns;t++){let i=null;const s=this.data[t];i="int"==s.type&&"i32"==e||"double"==s.type&&"f32"==e?s.getRawData():new a[e](s.getRawData()),null!=i&&r.set(i,this.buf+t*this.numOfRows*o>>n)}}}getDataFromBuffer(t){if(this.toUpdate&&this.isMemoryForBufferAllocated()){const e=this.type,n=t[i[e]],r=this.numOfRows,o=this.numOfColumns,s=new a[e](n.buffer,this.buf,r*o);for(let t=0;t<o;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 d{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[i[e]],r=this.numOfRows,o=this.numOfColumns,s=a[e].BYTES_PER_ELEMENT,c=u[e],l=this.buf;for(let t=0;t<o;t++){const o=new a[e](r);for(let e=0;e<r;e++)o[e]=n[l/s+e+t*r];this.data.push(c((t+1).toString(),o))}}}}const p={intColumn:t=>new l(t,"i32"),newIntColumn:t=>new h("i32",t),intColumns:t=>new d(t.toList(),"i32"),newIntColumns:(t,e)=>new f("i32",t,e),floatColumn:t=>new l(t,"f32"),newFloatColumn:t=>new h("f32",t),floatColumns:t=>new d(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],o=r.arguments,i=[];let a=0;for(const t in o){const e=o[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=o[e.numOfRows.ref].data[e.numOfRows.value],r=o[e.numOfColumns.ref].data[e.numOfColumns.value];e.data=p[e.type](t,r);break;case"newFloatColumn":case"newIntColumn":const i=o[e.numOfRows.ref].data[e.numOfRows.value];e.data=p[e.type](i)}i.push(o[t].data)}}const s=function(t,e,n,r){let o;for(const e of r)e.allocateMemoryForBuffer(t);let i=!0;for(const t of r)i&=t.isMemoryForBufferAllocated();if(i){const n=[],i=[];for(const e of r)e.complementArrOfParams(n),e.complementArrOfTypes(i),e.putDataToBuffer(t);const a="number";o=t.ccall(e,a,i,n);for(const e of r)e.getDataFromBuffer(t)}for(const e of r)e.freeBuffer(t);if(null!=o)return o}(t,e,0,i);o._callResult=p.num(s);const u=r.output;if("objects"!=u.type)return m[u.type](o[u.source].data);const c=[];for(const t of u.source)c.push(o[t].data.data);return c}const y="num",v="floatColumn",w="intColumn",b="floatColumns",E="newFloatColumns",A="intColumns",C="newIntColumns",_="newFloatColumn",S="newIntColumn",N="column",I="_callResult",M="numOfRows",T="numOfColumns",O="ref",L="value",P="tableFromColumns",x="objects",R="int",F="double",D={intColumn:Int32Array,floatColumn:Float32Array,floatColumns:Float32Array,newFloatColumns:Float32Array,intColumns:Int32Array,newIntColumns:Int32Array,newFloatColumn:Float32Array,newIntColumn:Int32Array};function U(t,e){let n,r=[],o=0;for(const i in t){const a=t[i],s=a.type;if(i!==I){switch(s){case y:case R:case F:a.data=e[o],o++;break;case w:case v:let r;const i=e[o],u=i.length;r=i.type===R&&s===w||i.type===F&&s===v?i.getRawData().slice(0,u):new D[s](i.getRawData().slice(0,u)),a.data={array:r,numOfRows:u},o++;break;case S:case _:let c=0;n=a[M][O],c=t[n].type===y?t[n].data:t[n].data[a[M][L]],a.data={numOfRows:c},o++;break;case A:case b:let l=[];const h=e[o].byIndex(0).length;for(const t of e[o].toList())t.type===R&&s===w||t.type===F&&s===v?l.push(t.getRawData().slice(0,h)):l.push(new D[s](t.getRawData().slice(0,h)));a.data={arrays:l,numOfRows:h,numOfColumns:l.length},o++;break;case C:case E:let d=0,f=0;n=a[M][O],d=t[n].type===y?t[n].data:t[n].data[a[M][L]],n=a[T][O],f=t[n].type===y?t[n].data:t[n].data[a[T][L]],a.data={numOfRows:d,numOfColumns:f},o++;break;default:return}r.push(a)}}return r}function k(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 o in t){const i=t[o];switch(i.type){case y:case R:case F:case w:case v:case b:case A:break;case _:case S:let t;null==i.name?t=(0).toString():s=i.name,i.column=n[i.type](t,e[r].array);break;case C:case E:let o=[],a=e[r].arrays.length,s=[];if(null==i.names)for(let t=1;t<=a;t++)s.push(t.toString());else s=i.names;for(let t=0;t<a;t++)o.push(n[i.type](s[t],e[r].arrays[t]));i.columns=o}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 R:case F:return t.arguments[e.source];case N:return t.arguments[e.source].column;case P:return DG.DataFrame.fromColumns(t.arguments[e.source].columns);case x:let r=[];for(let o of e.source){let e=t.arguments[o];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 R:case F:case w:case v:case A:case b:break;case S:case _:n.column=null;break;case C:case E:n.columns=null}}}(t.arguments),n}async function G(t,e,r){return new Promise(((t,o)=>{const i=new Worker(new URL(n.p+n.u(128),n.b));i.postMessage(U(EDA.principalComponentAnalysisNipals.arguments,[e,r])),i.onmessage=function(e){i.terminate(),t(k(EDA.principalComponentAnalysisNipals,e.data))}}))}const B=1,V=1e8,W=900,H=1e-6,j="components must be positive.",q="components must not be greater than features count.",z="dataframe is too big.",Y="unsupported column type: ";function $(t){if(t.type!=o.COLUMN_TYPE.FLOAT&&t.type!=o.COLUMN_TYPE.INT)throw new Error(Y+t.type)}function K(t){if(t.stats.missingValueCount>0)throw new Error(`The column '${t.name}' has missing values.`)}function X(t,e){if(function(t,e){if(e<B)throw new Error(j);if(e>t.length)throw new Error(q);for(const e of t)$(e),K(e)}(t,e),t.length*t.byIndex(0).length>V)throw new Error(z)}function Q(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,o=n.getRawData();if(t>0)for(let n=0;n<e;++n)o[n]=(o[n]-r)/t;else for(let t=0;t<e;++t)o[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)>H){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)>H&&t>0){const r=n.getRawData();for(let n=0;n<e;++n)r[n]/=t}}return t}(t):t}var J=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function s(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(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 Z=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function s(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(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 tt=0,et=1,nt=2,rt=3,ot=4,it=0,at=1,st=2,ut=3,ct=4,lt=5,ht=6,dt=7,ft=0,pt=1,mt=2,gt=3,yt=0,vt=0,wt=1,bt=0,Et=1,At=0,Ct=0,_t=0,St=0,Nt="gamma must be strictly positive.",It="sigma must be strictly positive.",Mt="c must be strictly positive.",Tt="d must be strictly positive.",Ot="incorrect kernel.",Lt="labels must be strings of two categories.",Pt="Labels",xt="predicted",Rt="correctness",Ft="Confusion matrix",Dt="mean",Ut="std dev",kt="alpha",Gt="weight",Bt="Gamma",Vt="Kernel",Wt="Kernel params",Ht="Kernel parameter 1",jt="Kernel parameter 2",qt="Features count",zt="Train samples count",Yt="Train error, %",$t=["linear","polynomial","RBF","sigmoid"],Kt="Sensitivity",Xt="Specificity",Qt="Balanced accuracy",Jt="Positive predicitve value",Zt="Negative predicitve value",te="prediction",ee=4,ne=3,re=2,oe=0,ie=1,ae=2,se=0,ue=1;function ce(t,e,r){return Z(this,void 0,void 0,(function*(){const i=e.columns;if(2!=r.categories.length)throw new Error(Lt);const a=o.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 Z(this,void 0,void 0,(function*(){!function(t){if(t.gamma<=At)throw new Error(Nt);switch(t.kernel){case tt:return;case nt:if(t.sigma<=Ct)throw new Error(It);return;case et:if(t.cParam<=_t)throw new Error(Mt);if(t.dParam<=St)throw new Error(Tt);return;case rt:return;default:throw new Error(Ot)}}(t);const i=[se,se];switch(t.kernel){case tt:break;case nt:i[yt]=t.sigma;break;case et:i[vt]=t.cParam,i[wt]=t.dParam;break;case rt:i[bt]=t.kappa,i[Et]=t.theta;break;default:throw new Error(Ot)}const a=o.Column.fromList("double",Wt,i),s=e.toList(),u=s[0].length+ue,c=s.length+ue,l=ot;let h;const d=async function(t,e,r,o,i,a,s,u){return new Promise(((c,l)=>{const h=new Worker(new URL(n.p+n.u(656),n.b));h.postMessage(U(EDA.trainAndAnalyzeLSSVM.arguments,[t,e,r,o,i,a,s,u])),h.onmessage=function(t){h.terminate(),c(k(EDA.trainAndAnalyzeLSSVM,t.data))}}))}(t.gamma,t.kernel,a,u,c,l,e,r);yield d.then((t=>{h=t}),(t=>{throw new Error(`Error: ${t}`)})),h[at].name=Dt,h[st].name=Ut,h[ut].name=kt,h[ct].name=Gt,h[lt].name=xt,h[ht].name=Rt,h[dt].name=Ft;const f={trainGamma:t.gamma,kernelType:t.kernel,kernelParams:a,trainLabels:r,normalizedTrainData:o.DataFrame.fromColumns(h[it]),means:h[at],stdDevs:h[st],modelParams:h[ut],modelWeights:h[ct],predictedLabels:h[lt],correctness:h[ht],confusionMatrix:h[dt],trainError:void 0,featuresCount:s.length,trainSamplesCount:s[0].length};return function(t){const e=t.confusionMatrix.getRawData(),n=e[ft],r=e[gt],o=e[mt],i=e[pt],a=n+i,s=o+r,u=n/a,c=r/s,l=n/(n+o),h=r/(r+i),d=(n+r)/(a+s),f=(u+c)/2;t.sensitivity=u,t.specificity=c,t.balancedAccuracy=f,t.positivePredicitveValue=l,t.negativePredicitveValue=h,t.trainError=100*(1-d)}(f),f}))}(t,i,a);return s.realLabels=r,s}))}function le(t,e){const n=de(e);return o.Viewer.form(n.modelInfo,{showNavigation:!1}).root}function he(t){const e=t.normalizedTrainData.columns,n=t.trainSamplesCount,r=t.featuresCount,i=o.DataFrame.fromColumns([t.realLabels]).toByteArray(),a=ee+i.length+4-i.length%4,s=function(t){const e=t.kernelParams.getRawData();return o.DataFrame.fromColumns([o.Column.fromList("double",Bt,[t.trainGamma]),o.Column.fromStrings(Vt,[$t[t.kernelType]]),o.Column.fromList("double",Ht,[e[0]]),o.Column.fromList("double",jt,[e[1]]),o.Column.fromList("double",qt,[t.featuresCount]),o.Column.fromList("double",zt,[t.trainSamplesCount]),o.Column.fromList("double",Yt,[t.trainError]),o.Column.fromList("double",Qt,[t.balancedAccuracy]),o.Column.fromList("double",Kt,[t.sensitivity]),o.Column.fromList("double",Xt,[t.specificity]),o.Column.fromList("double",Jt,[t.positivePredicitveValue]),o.Column.fromList("double",Zt,[t.negativePredicitveValue])])}(t).toByteArray(),u=ee+s.length+4-s.length%4,c=new Uint8Array(ee*(ne+re+n+r+r+n+ue+r+ue+r*n)+a+u),l=c.buffer;let h=0,d=new Int32Array(l,h,ne);d[oe]=t.kernelType,d[ie]=n,d[ae]=r,h+=ne*ee;let f=new Float32Array(l,h,re);f.set(t.kernelParams.getRawData()),h+=re*ee,f=new Float32Array(l,h,n),f.set(t.trainLabels.getRawData()),h+=n*ee,f=new Float32Array(l,h,r),f.set(t.means.getRawData()),h+=r*ee,f=new Float32Array(l,h,r),f.set(t.stdDevs.getRawData()),h+=r*ee,f=new Float32Array(l,h,n+ue),f.set(t.modelParams.getRawData()),h+=(n+ue)*ee,f=new Float32Array(l,h,r+ue),f.set(t.modelWeights.getRawData()),h+=(r+ue)*ee;for(const t of e)f=new Float32Array(l,h,r),f.set(t.getRawData()),h+=r*ee;return d=new Int32Array(l,h,1),d[0]=i.length,c.set(i,h+ee),h+=a,d=new Int32Array(l,h,1),d[0]=s.length,c.set(s,h+ee),h+=u,c}function de(t){const e=t.buffer;let n=0;const r=new Int32Array(e,n,ne);n+=ne*ee;const i=r[ie],a=r[ae],s=o.Column.fromFloat32Array(Wt,new Float32Array(e,n,re));n+=re*ee;const u=o.Column.fromFloat32Array(Pt,new Float32Array(e,n,i));n+=i*ee;const c=o.Column.fromFloat32Array(Dt,new Float32Array(e,n,a));n+=a*ee;const l=o.Column.fromFloat32Array(Ut,new Float32Array(e,n,a));n+=a*ee;const h=o.Column.fromFloat32Array(kt,new Float32Array(e,n,i+ue));n+=(i+ue)*ee;const d=o.Column.fromFloat32Array(Gt,new Float32Array(e,n,a+ue));n+=(a+ue)*ee;const f=[];for(let t=0;t<i;t++)f.push(o.Column.fromFloat32Array(t.toString(),new Float32Array(e,n,a))),n+=a*ee;const p=o.DataFrame.fromColumns(f),m=new Int32Array(e,n,1)[0],g=m+4-m%4;n+=ee;const y=o.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+=ee;const b=o.DataFrame.fromByteArray(new Uint8Array(e,n,v));return n+=w,{kernelType:r[oe],kernelParams:s,trainLabels:u,realLabels:y,means:c,stdDevs:l,modelParams:h,modelWeights:d,normalizedTrainData:p,modelInfo:b}}function fe(t,e){return Z(this,void 0,void 0,(function*(){const r=de(new Uint8Array(e)),i=yield function(t,e){return Z(this,void 0,void 0,(function*(){let r;const o=async function(t,e,r,o,i,a,s,u,c){return new Promise(((l,h)=>{const d=new Worker(new URL(n.p+n.u(763),n.b));d.postMessage(U(EDA.predictByLSSVM.arguments,[t,e,r,o,i,a,s,u,c])),d.onmessage=function(t){d.terminate(),l(k(EDA.predictByLSSVM,t.data))}}))}(t.kernelType,t.kernelParams,t.normalizedTrainData.columns,t.trainLabels,t.means,t.stdDevs,t.modelParams,t.modelWeights,e);return yield o.then((t=>{r=t}),(t=>{throw new Error(`Error: ${t}`)})),r}))}(r,t.columns),a=o.Column.string(te,i.length),s=r.realLabels.categories;for(let t=0;t<a.length;t++)a.set(t,-1==i.get(t)?s[0]:s[1]);return o.DataFrame.fromColumns([a])}))}function pe(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 me(t,e){return t.rowCount<=1e3}var ge,ye,ve,we,be,Ee,Ae,Ce;!function(t){t[t.COMPUTE_COMPONENTS=0]="COMPUTE_COMPONENTS",t[t.PERFORM_MVA=1]="PERFORM_MVA",t[t.DEMO=2]="DEMO"}(ge||(ge={})),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"}(ye||(ye={})),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"}(ve||(ve={})),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"}(we||(we={})),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"}(be||(be={})),function(t){t[t.DEFAULT=3]="DEFAULT",t[t.MIN=1]="MIN"}(Ee||(Ee={})),function(t){t.PREFIX="PLS",t.SUFFIX="(predicted)",t.COMP="component",t.COMPS="components"}(Ae||(Ae={})),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"}(Ce||(Ce={}));const _e=6,Se=[.49,.79,.99],Ne=1,Ie=200,Me=200;var Te;!function(t){t.AXIS="#838383",t.CIRCLE="#0000FF",t.INVALID="#EB6767",t.VALID_TEXT="#4d5261",t.VALID_LINE="#dbdcdf"}(Te||(Te={}));const Oe="# 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",Le=[{caption:ve.MODEL,text:"Closer to the line means better price prediction."},{caption:ve.SCORES,text:"The latent factor values for each sample reflect the similarities and dissimilarities among observations."},{caption:ve.LOADINGS,text:"The impact of each feature on the latent factors: higher loading means stronger influence."},{caption:ve.REGR_COEFS,text:"Parameters of the obtained model: features make different contribution to the prediction."},{caption:ve.EXPL_VAR,text:"How well the latent components fit source data: closer to one means better fit."}],Pe=Le.map((t=>`# ${t.caption}\n\n${t.text}`)).join("\n\n")+`\n\n# Learn more\n \n * [Multivariate analysis](${be.MVA}),\n * [ANOVA](https://datagrok.ai/help/explore/anova)`;var xe=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function s(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(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 Re=Math.min;function Fe(t){const e=[],n=(t,n)=>{e.push({type:"line",formula:t,width:Ne,visible:!0,title:" ",min:-n,max:n,color:Te.CIRCLE})};return t.forEach((r=>{const o="${"+r+"}";e.push({type:"line",formula:`${o} = 0`,width:Ne,visible:!0,title:" ",color:Te.AXIS}),t.forEach((t=>{const e="${"+t+"}";Se.forEach((t=>{n(e+` = sqrt(${t*t} - ${o} * ${o})`,t),n(e+` = -sqrt(${t*t} - ${o} * ${o})`,t)}))}))})),e}function De(t){return xe(this,void 0,void 0,(function*(){X(t.features,t.components),$(t.predict),K(t.predict);const e=yield async function(t,e,r,o){return new Promise(((t,i)=>{const a=new Worker(new URL(n.p+n.u(412),n.b));a.postMessage(U(EDA.partialLeastSquareRegression.arguments,[e,r,o])),a.onmessage=function(e){a.terminate(),t(k(EDA.partialLeastSquareRegression,e.data))}}))}(t.table,t.features,t.predict,t.components);return{prediction:e[Ce.PREDICTION],regressionCoefficients:e[Ce.REGR_COEFFS],tScores:e[Ce.T_SCORES],uScores:e[Ce.U_SCORES],xLoadings:e[Ce.X_LOADINGS],yLoadings:e[Ce.Y_LOADINGS]}}))}function Ue(n){return xe(this,void 0,void 0,(function*(){const r=t.shell.t;if(null===r)return void t.shell.warning(ye.NO_DF);if(0===r.rowCount)return void t.shell.warning(ye.EMPTY_DF);const i=[],a=[],s=[],u=t=>(t.type===o.COLUMN_TYPE.INT||t.type===o.COLUMN_TYPE.FLOAT)&&0===t.stats.missingValueCount;if(r.columns.toList().forEach((t=>{u(t)?(i.push(t.name),a.push(t)):t.type===o.COLUMN_TYPE.STRING&&s.push(t)})),0===i.length)return void t.shell.warning(ye.NO_COLS);if(1===i.length)return void t.shell.warning(ye.ONE_COL);let c=a.slice(0,a.length-1),l=a[a.length-1],h=Re(i.length-1,Ee.DEFAULT),d=!1;const f=e.input.column(ve.PREDICT,{table:r,value:l,nullable:!1,onValueChanged:t=>{l=t,b()},filter:t=>u(t),tooltipText:we.PREDICT}),p=e.input.columns(ve.USING,{table:r,available:i,value:c,onValueChanged:t=>{c=t,b()},tooltipText:we.FEATURES}),m=e.input.int(ve.COMPONENTS,{value:h,showPlusMinus:!0,onValueChanged:t=>{h=t,b()},tooltipText:we.COMPONENTS});let g,y,v;n===ge.COMPUTE_COMPONENTS?(g=ve.PLS,y=be.PLS,v=we.PLS):(g=ve.MVA,y=be.MVA,v=we.MVA);const w=(t,n,r,o)=>{t?(n.style.color=Te.VALID_TEXT,n.style.borderBottomColor=Te.VALID_LINE,e.tooltip.bind(n,r)):(n.style.color=Te.INVALID,n.style.borderBottomColor=Te.INVALID,e.tooltip.bind(n,(()=>{const t=e.label(r),n=e.label(o);return n.style.color=Te.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,we.PREDICT,""),w(!0,p.input,we.FEATURES,"")):(w(!1,f.input,we.PREDICT,ye.PREDICT),w(!1,p.input,we.FEATURES,ye.PREDICT)),h<1)w(!1,m.input,we.COMPONENTS,ye.COMPONENTS),e=!1;else if(e=(()=>{if(h<1)return!1;const t=c.length;return d?h<=(t+1)*t/2+t:h<=t})(),e)w(!0,m.input,we.COMPONENTS,""),t&&w(!0,p.input,we.FEATURES,"");else{const t=d?ye.COMP_QUA_PLS:ye.COMP_LIN_PLS;w(!1,m.input,we.COMPONENTS,t),w(!1,p.input,we.FEATURES,ye.ENOUGH)}const n=t&&e;return _.getButton(ve.RUN).disabled=!n,n};let E=s.length>0?s[0]:void 0;const A=e.input.column(ve.NAMES,{table:r,value:E,onValueChanged:t=>E=null!=t?t:void 0,filter:t=>t.type===o.COLUMN_TYPE.STRING});A.setTooltip(we.NAMES),A.root.hidden=0===s.length||n===ge.COMPUTE_COMPONENTS;const C=e.input.bool(ve.QUADRATIC,{value:d,tooltipText:we.QUADRATIC,onValueChanged:t=>{d=t,b()}}),_=e.dialog({title:g,helpUrl:y}).add(e.form([f,p,m,C,A])).addButton(ve.RUN,(()=>xe(this,void 0,void 0,(function*(){_.close(),yield function(n,r){return xe(this,void 0,void 0,(function*(){var i,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,i=[];let a,s,u,c,l;for(let t=0;t<n;++t){a=e[t],s=a.getRawData();for(let h=t;h<n;++h){u=e[h],c=u.getRawData(),l=new Float32Array(r);for(let t=0;t<r;++t)l[t]=s[t]*c[t];const t=o.Column.fromFloat32Array(`${a.name} x ${u.name}`,l);t.stats.stdev>0&&i.push(t)}}const h=o.DataFrame.fromColumns(e.concat(i));return{table:h,features:h.columns,isQuadratic:!0,names:t.names,predict:t.predict,components:t.components}}(n));const u=yield De(n),c=u.tScores,l=s.columns,h=n.features,d=h.names(),f=r===ge.COMPUTE_COMPONENTS?Ae.PREFIX:ve.XSCORE;if(c.forEach(((t,e)=>{t.name=l.getUnusedName(`${f}${e+1}`),l.add(t)})),r===ge.COMPUTE_COMPONENTS)return;const p=t.shell.tableView(s.name),m=o.DataFrame.fromColumns([o.Column.fromStrings(ve.FEATURE,d),u.regressionCoefficients]);m.name=`${s.name}(${ve.ANALYSIS})`,t.shell.addTable(m),u.xLoadings.forEach(((t,e)=>{t.name=m.columns.getUnusedName(`${ve.XLOADING}${e+1}`),m.columns.add(t)}));const g=function(t,e,n,r){const i=n.length,a=t.length,s=e.getRawData(),u=new Float32Array(i),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<i;++t)u[t]=l+c[t];return o.Column.fromFloat32Array("Debiased",u,i)}(h,u.regressionCoefficients,n.predict,u.prediction);g.name=l.getUnusedName(`${n.predict.name} ${Ae.SUFFIX}`),l.add(g);const y=p.addViewer(o.Viewer.scatterPlot(s,{title:ve.MODEL,xColumnName:n.predict.name,yColumnName:g.name,showRegressionLine:!0,markerType:o.MARKER_TYPE.CIRCLE,showLabels:"Always",help:be.MODEL}));void 0!==n.names&&null!==n.names&&y.setOptions({labelColumnNames:[null===(i=n.names)||void 0===i?void 0:i.name]}),u.regressionCoefficients.name=ve.REGR_COEFS;const v=p.addViewer(o.Viewer.barChart(m,{table:m.name,title:ve.REGR_COEFS,splitColumnName:ve.FEATURE,valueColumnName:u.regressionCoefficients.name,valueAggrType:o.AGG.AVG,help:be.COEFFS,showValueSelector:!1,showStackSelector:!1}));u.xLoadings.forEach(((t,e)=>t.name=`${ve.XLOADING}${e+1}`));const w=p.addViewer(o.Viewer.scatterPlot(m,{table:m.name,title:ve.LOADINGS,xColumnName:`${ve.XLOADING}1`,yColumnName:`${ve.XLOADING}${u.xLoadings.length>1?"2":"1"}`,markerType:o.MARKER_TYPE.CIRCLE,labelColumnNames:[ve.FEATURE],help:be.LOADINGS})),b=c.map((t=>t.name));u.uScores.forEach(((t,e)=>{t.name=l.getUnusedName(`${ve.YSCORE}${e+1}`),l.add(t),b.push(t.name)}));const E=o.Viewer.scatterPlot(s,{title:ve.SCORES,xColumnName:c[0].name,yColumnName:c.length>1?c[1].name:u.uScores[0].name,markerType:o.MARKER_TYPE.CIRCLE,help:be.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(E),E.meta.formulaLines.addAll(Fe(b));const A=u.yLoadings.getRawData(),C=u.xLoadings.map((t=>t.getRawData())),_=s.rowCount,S=d.length,N=n.components,I=new Float32Array(N),M=[],T=[];for(let t=0;t<S;++t)T.push(new Float32Array(N));I[0]=Math.pow(A[0],2)/_,M.push(`1 ${Ae.COMP}`),T.forEach(((t,e)=>{t[0]=Math.pow(C[0][e],2)/_}));for(let t=1;t<N;++t)I[t]=I[t-1]+Math.pow(A[t],2)/_,T.forEach(((e,n)=>e[t]=e[t-1]+Math.pow(C[t][n],2)/_)),M.push(`${t+1} ${Ae.COMPS}`);const O=o.DataFrame.fromColumns([o.Column.fromStrings(ve.COMPONENTS,M),o.Column.fromFloat32Array(n.predict.name,I)]);O.name=`${s.name}(${ve.EXPL_VAR})`,t.shell.addTable(O),T.forEach(((t,e)=>O.columns.add(o.Column.fromFloat32Array(d[e],t))));const L=p.addViewer(o.Viewer.barChart(O,{table:O.name,title:ve.EXPL_VAR,splitColumnName:ve.COMPONENTS,valueColumnName:n.predict.name,valueAggrType:o.AGG.AVG,help:be.EXPL_VARS,showCategorySelector:!1,showStackSelector:!1}));r===ge.DEMO&&(t.shell.windows.help.showHelp(e.markdown(Pe)),function(t,n,r){if(t.length!==n.length)throw new Error("Non-equal size of viewer roots and descriptions");let o,i,a,s=0;const u=e.button("next",(()=>{a.remove(),++s,d()}),"Go to the next viewer"),c=e.button("prev",(()=>{s-=1,a.remove(),d()}),"Go to the previous viewer"),l=e.button("done",(()=>a.remove()),"Go to the next step"),h=e.divH([c,u,l]);h.style.marginLeft="auto",h.style.marginRight="0px";const d=()=>{s<t.length&&(i=e.divV([e.markdown(n[s]),h]),a=e.hints.addHint(t[s],i,r[s]),l.hidden=s<t.length-1,u.hidden=s===t.length-1,c.hidden=s<1,o=a.querySelector("i"),o.onclick=()=>l.click())};d()}([y,E,w,v,L].map((t=>t.root)),Le.map((t=>`<b>${t.caption}</b>\n\n${t.text}`)),["left","left","right","right","left"]))}))}({table:r,features:o.DataFrame.fromColumns(c).columns,predict:l,components:h,isQuadratic:d,names:E},n)}))),void 0,v).show({x:Ie,y:Me});setTimeout((()=>{p.value=a.filter((t=>t!==l)),c=p.value}),_e),t.shell.v.append(_.root)}))}Math.max;var ke,Ge=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"}(ke||(ke={}));const Be="copy";var Ve;!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"}(Ve||(Ve={}));const We="/help/explore/missing-values-imputation#the-k-nn-method";var He;!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"}(He||(He={}));const je=15,qe=[o.COLUMN_TYPE.INT,o.COLUMN_TYPE.FLOAT,o.COLUMN_TYPE.STRING,o.COLUMN_TYPE.DATE_TIME,o.COLUMN_TYPE.QNUM];function ze(t){switch(t.type){case o.COLUMN_TYPE.INT:return o.INT_NULL;case o.COLUMN_TYPE.FLOAT:case o.COLUMN_TYPE.QNUM:case o.COLUMN_TYPE.DATE_TIME:return o.FLOAT_NULL;case o.COLUMN_TYPE.STRING:return t.max;default:throw new Error(ke.UNSUPPORTED_COLUMN_TYPE)}}var Ye,$e,Ke;!function(t){t.ONE_HOT="One-hot",t.DIFFERENCE="Difference"}(Ye||(Ye={})),function(t){t.EUCLIDEAN="Euclidean",t.MANHATTAN="Manhattan"}($e||($e={})),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"}(Ke||(Ke={}));const Xe=1;function Qe(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(ke.FAILS_TO_PREDICT_IMPUTATION_FAILS);for(const r of t){let t=!0;for(const o of e){const e=n.get(o);if(void 0===e)throw new Error(ke.FAILS_TO_PREDICT_IMPUTATION_FAILS);if(!e.includes(r)){t=!1;break}}if(t)return!0}}return!1}var Je;function Ze(t){if(t<=0||t>=1)throw new Error(Je.INCORRECT_SIGNIFICANCE_LEVEL)}function tn(t){const e=t.size;return e<=1?0:(t.sumOfSquares-Math.pow(t.sum,2)/e)/(e-1)}function en(t,e,n){Ze(n);const r=tn(t),o=tn(e);return 0===r||0===o?r===o:r/o<Ge.centralF.inv(1-n,t.size-1,e.size-1)}!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"}(Je||(Je={}));class nn{constructor(t,e,n){if(this.nullsCount=0,t.length!==e.length)throw new Error(Je.NON_EQUAL_FACTORS_VALUES_SIZE);if(!(e.stats.stdev>0))throw new Error(Je.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(!en(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,o=r;for(let i=0;i<r;++i)0!==this.subSampleSizes[i]?(t+=this.sums[i],e+=this.sumsOfSquares[i],n+=Math.pow(this.sums[i],2)/this.subSampleSizes[i]):--o;if(r=o,1===r)throw new Error(Je.SINGLE_FACTOR);const i=this.size-this.nullsCount;if(i===r)throw new Error(Je.CATS_EQUAL_SIZE);const a=e-Math.pow(t,2)/i,s=n-Math.pow(t,2)/i,u=a-s;if(0===u)throw new Error(Je.NO_FEATURE_VARIATION_WITHIN_GROUPS);const c=r-1,l=i-r,h=s/c,d=u/l,f=h/d;return{ssBn:s,ssWn:u,ssTot:a,dfBn:c,dfWn:l,dfTot:i-1,msBn:h,msWn:d,fStat:f,pValue:1-Ge.centralF.cdf(f,c,l)}}setStats(t,e,n){const r=e.type,i=e.length,a=ze(e);switch(r){case o.COLUMN_TYPE.INT:case o.COLUMN_TYPE.FLOAT:const r=n;this.catCount=r,this.size=i;const s=e.getRawData(),u=t.getRawData(),c=new Float64Array(r).fill(0),l=new Float64Array(r).fill(0),h=new Int32Array(r).fill(0);let d;if(t.type==o.COLUMN_TYPE.BOOL){let t=0,e=0,n=u[0];const r=8*u.BYTES_PER_ELEMENT-1;for(let o=0;o<i;++o)d=1&n>>e,s[o]!==a?(c[d]+=s[o],l[d]+=Math.pow(s[o],2),++h[d]):++this.nullsCount,++e,e>r&&(e=0,++t,n=u[t])}else{const e=t.stats.missingValueCount>0?ze(t):-1;for(let t=0;t<i;++t)d=u[t],d!==e&&s[t]!==a?(c[d]+=s[t],l[d]+=Math.pow(s[t],2),++h[d]):++this.nullsCount}this.sums=c,this.sumsOfSquares=l,this.subSampleSizes=h;break;default:throw new Error(Je.UNSUPPORTED_COLUMN_TYPE)}}}const rn=[o.COLUMN_TYPE.INT,o.COLUMN_TYPE.FLOAT],on=[o.COLUMN_TYPE.STRING,o.COLUMN_TYPE.BOOL],an="/help/explore/anova";var sn,un;function cn(){const n=t.shell.t;if(null===n)return void t.shell.warning("No dataframe is opened");const r=n.columns,i=[],a=[];for(const t of r)rn.includes(t.type)?a.push(t.name):on.includes(t.type)&&i.push(t.name);const s=i.length;if(s<1)return void t.shell.warning(e.markdown(`No acceptable factor columns:\n\n - type: ${on.join(", ")} \n - at least two categories`));let u=n.col(un.FACTOR);if(null===u){let t,e=0,n=r.byName(i[0]).categories.length;for(let o=1;o<s;++o)t=r.byName(i[o]).categories.length,t<n&&(n=t,e=o);u=r.byName(i[e])}if(a.length<1)return void t.shell.warning(e.markdown(`No acceptable feature columns:\n \n - type: ${rn.join(", ")}`));const c=e.input.column("Category",{table:n,value:u,tooltipText:"Column with factor values",onValueChanged:t=>u=t,filter:t=>i.includes(t.name),nullable:!1});let l=n.col(un.FEATURE);null===l&&(l=r.byName(a[0]));const h=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 d=sn.DEFAULT;const f=e.input.float("Alpha",{min:sn.MIN,max:sn.MAX,value:d,nullable:!1,tooltipText:"Significance level",onValueChanged:t=>{d=t,g.disabled=d<=sn.INFIMUM||d>=sn.SUPREMUM}}),p=e.dialog({title:"ANOVA",helpUrl:an}),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){Ze(n);const o=t.stats.uniqueCount;if(o<2)throw new Error(Je.SINGLE_FACTOR);const i=new nn(t,e,o);if(r&&!i.areVarsEqual(n))throw new Error(Je.NON_EQUAL_VARIANCES);const a=i.getOneWayAnova();return{anovaTable:a,fCritical:Ge.centralF.inv(1-n,a.dfBn,a.dfWn),significance:n}}(u,l,d);!function(n,r,i,a){const s=a.anovaTable.fStat>a.fCritical,u=s?`"${r}" affects the "${i}"`:`"${r}" doesn't affect the "${i}"`,c=t.shell.getTableView(n.name),l=o.Viewer.boxPlot(n,{categoryColumnNames:[r],valueColumnName:i,showPValue:!1,showStatistics:!1,description:u,showColorSelector:!1}),h=c.dockManager.dock(l.root,o.DOCK_TYPE.RIGHT,null,"ANOVA"),d=e.markdown(`**H0:** the "${r}" \n factor does not produce a significant difference in the "${i}" feature.`);e.tooltip.bind(d,"Null hypothesis");const f=e.markdown("**Test result:** "+(s?"means differ significantly.":"means do not differ significantly.")),p=s?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(f,(()=>p));const m=e.divV([d,f,e.link("Learn more",(()=>window.open("https://en.wikipedia.org/wiki/F-test","_blank")),"Click to open in a new tab")]);m.style.marginLeft="20px";const g=t.shell.dockManager.dock(m,o.DOCK_TYPE.DOWN,h,"F-test",.3),y=function(t){const n=t.anovaTable,r=o.Viewer.grid(o.DataFrame.fromColumns([o.Column.fromStrings("Source of variance",["Between groups","Within groups","Total"]),o.Column.fromList(o.COLUMN_TYPE.FLOAT,"SS",[n.ssBn,n.ssWn,n.ssTot]),o.Column.fromList(o.COLUMN_TYPE.INT,"DF",[n.dfBn,n.dfWn,n.dfTot]),o.Column.fromList(o.COLUMN_TYPE.FLOAT,"MS",[n.msBn,n.msWn,null]),o.Column.fromList(o.COLUMN_TYPE.FLOAT,"F",[n.fStat,null,null]),o.Column.fromList(o.COLUMN_TYPE.FLOAT,"F-critical",[t.fCritical,null,null]),o.Column.fromList(o.COLUMN_TYPE.FLOAT,"p-value",[n.pValue,null,null])])),i=new Map([["Source of variance","List of the explored variation sources"],["SS","Sum of squares (SS)"],["DF","Degrees of freedom (DF)"],["MS","Mean square (MS)"],["F","F-statistics (F)"],["F-critical",`${t.significance}-critical value of F-statistics (F)`],["p-value","Probability to obtain F-statistics (F) greater than the actual observation."]]);return r.onCellTooltip((function(t,n,r){if(t.isColHeader)return e.tooltip.show(e.divV([e.p(i.get(t.tableColumn.name))]),n,r),!0})),r.helpUrl=an,r}(a);t.shell.dockManager.dock(y.root,o.DOCK_TYPE.FILL,g,"Analysis")}(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(o.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(h).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"}(sn||(sn={})),function(t){t.FACTOR="race",t.FEATURE="age"}(un||(un={}));var ln=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function s(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(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 hn(t,e,r,o){return ln(this,void 0,void 0,(function*(){return new Promise((function(i,a){const s=new Worker(new URL(n.p+n.u(682),n.b));s.postMessage({embedX:t,embedY:e,minPts:o,epsilon:r}),s.onmessage=({data:{error:t,clusters:e}})=>{s.terminate(),t?a(t):i(e)}}))}))}n(5540);let dn=null;function fn(){return t=this,e=void 0,r=function*(){if(!navigator.gpu)return console.error("WebGPU is not supported in this browser"),null;if(!dn&&(dn=yield navigator.gpu.requestAdapter(),null==dn))return null;let t=null;return"info"in dn&&(t=dn.info),t?pn(t.description,pn(t.vendor,"No GPU description available")):"No GPU description available"},new((n=void 0)||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function s(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(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 pn(t,e){return t&&""!=t?t:e}var mn,gn,yn,vn,wn,bn,En,An,Cn;(gn=mn||(mn={})).EUCLIDEAN="EUCLIDEAN",gn.MANHATTAN="MANHATTAN",mn.EUCLIDEAN,mn.MANHATTAN,(vn=yn||(yn={})).HAMMING="Hamming",vn.EUCLIDEAN="Euclidean",vn.VECTOR_COSINE="Vector Cosine",vn.MANHATTAN="Manhattan",vn.TANIMOTO="Tanimoto",vn.LEVENSTEIN="Levenshtein",vn.NEEDLEMAN_WUNSCH="Needlemann-Wunsch",vn.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance",vn.SOKAL="Sokal",vn.COSINE="Cosine",vn.ASYMMETRIC="Asymmetric",vn.Difference="Difference",vn.OneHot="One-Hot",yn.HAMMING,yn.EUCLIDEAN,yn.MANHATTAN,yn.VECTOR_COSINE,yn.TANIMOTO,yn.LEVENSTEIN,yn.NEEDLEMAN_WUNSCH,yn.MONOMER_CHEMICAL_DISTANCE,yn.SOKAL,yn.COSINE,yn.ASYMMETRIC,yn.Difference,yn.OneHot,yn.HAMMING,yn.EUCLIDEAN,yn.MANHATTAN,yn.TANIMOTO,yn.SOKAL,yn.COSINE,yn.ASYMMETRIC,yn.LEVENSTEIN,yn.NEEDLEMAN_WUNSCH,yn.MONOMER_CHEMICAL_DISTANCE,yn.Difference,yn.OneHot,yn.VECTOR_COSINE,new Set([yn.HAMMING,yn.LEVENSTEIN,yn.NEEDLEMAN_WUNSCH,yn.MONOMER_CHEMICAL_DISTANCE,yn.OneHot]),new Set([yn.HAMMING,yn.EUCLIDEAN,yn.MANHATTAN,yn.MONOMER_CHEMICAL_DISTANCE,yn.LEVENSTEIN,yn.NEEDLEMAN_WUNSCH,yn.TANIMOTO,yn.COSINE,yn.VECTOR_COSINE,yn.SOKAL,yn.ASYMMETRIC,yn.OneHot,yn.Difference]),new Set([yn.EUCLIDEAN,yn.MANHATTAN,yn.OneHot,yn.Difference,yn.VECTOR_COSINE]),new Set([yn.EUCLIDEAN,yn.MANHATTAN,yn.Difference,yn.VECTOR_COSINE]),new Set([yn.EUCLIDEAN,yn.MANHATTAN,yn.Difference]),new Set([yn.TANIMOTO,yn.COSINE,yn.SOKAL,yn.ASYMMETRIC]),function(t){t.ADD="ADD",t.SUB="SUB",t.MULT="MULT"}(wn||(wn={})),function(t){t.SQUARE="SQUARE",t.INVERSE="INVERSE",t.TRANSPOSE="TRANSPOSE",t.NORM="NORM",t.COLUMN_NORM="COLUMN_NORM"}(bn||(bn={})),function(t){t.SCALARMULT="SCALARMULT",t.SCALARADD="SCALARADD",t.SCALARPOW="SCALARPOW"}(En||(En={})),Object.prototype.toString,(Cn=An||(An={})).UMAP="UMAP",Cn.T_SNE="t-SNE",Promise.resolve(),n(934),n(8903);const _n=2;o.SEMTYPE.MOLECULE,o.SEMTYPE.MACROMOLECULE;class Sn{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 Nn="bypassLargeDataWarning",In="show-scatterplot-progress";var Mn,Tn;(Tn=Mn||(Mn={})).EUCLIDEAN="EUCLIDEAN",Tn.MANHATTAN="MANHATTAN";const On=rxjs;var Ln,Pn,xn,Rn,Fn,Dn,Un,kn,Gn=n(5072),Bn=n.n(Gn),Vn=n(7825),Wn=n.n(Vn),Hn=n(7659),jn=n.n(Hn),qn=n(5056),zn=n.n(qn),Yn=n(540),$n=n.n(Yn),Kn=n(1113),Xn=n.n(Kn),Qn=n(7939),Jn={};Jn.styleTagTransform=Xn(),Jn.setAttributes=zn(),Jn.insert=jn().bind(null,"head"),Jn.domAPI=Wn(),Jn.insertStyleElement=$n(),Bn()(Qn.A,Jn),Qn.A&&Qn.A.locals&&Qn.A.locals,function(t){t.Levenshtein="Levenshtein",t.JaroWinkler="Jaro-Winkler",t.Manhattan="Manhattan String",t.Onehot="One-Hot"}(Ln||(Ln={})),function(t){t.Euclidean="Euclidean",t.Manhattan="Manhattan",t.Cosine="Vector Cosine"}(Pn||(Pn={})),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"}(xn||(xn={})),function(t){t.TanimotoIntArray="TanimotoIntArray"}(Rn||(Rn={})),(kn=Fn||(Fn={})).Vector="Vector",kn.String="String",kn.BitArray="BitArray",kn.MacroMolecule="MacroMolecule",kn.Number="Number",kn.IntArray="IntArray",kn.NumberArray="NumberArray",function(t){t.Difference="Difference"}(Dn||(Dn={})),function(t){t.CommonItems="Common Items"}(Un||(Un={}));const Zn=new Uint32Array(65536),tr=(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,o=1<<n-1;let i=-1,a=0,s=n,u=n;for(;u--;)Zn[t.charCodeAt(u)]|=1<<u;for(u=0;u<r;u++){let t=Zn[e.charCodeAt(u)];const n=t|a;t|=(t&i)+i^i,a|=~(t|i),i&=t,a&o&&s++,i&o&&s--,a=a<<1|1,i=i<<1|~(n|a),a&=n}for(u=n;u--;)Zn[t.charCodeAt(u)]=0;return s})(t,e):((t,e)=>{const n=e.length,r=t.length,o=[],i=[],a=Math.ceil(n/32),s=Math.ceil(r/32);for(let t=0;t<a;t++)i[t]=-1,o[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++)Zn[t.charCodeAt(e)]|=1<<e;for(let t=0;t<n;t++){const n=Zn[e.charCodeAt(t)],r=i[t/32|0]>>>t&1,u=o[t/32|0]>>>t&1,c=n|a,l=((n|u)&s)+s^s|n|u;let h=a|~(l|s),d=s&l;h>>>31^r&&(i[t/32|0]^=1<<t),d>>>31^u&&(o[t/32|0]^=1<<t),h=h<<1|r,d=d<<1|u,s=d|~(c|h),a=h&c}for(let e=c;e<l;e++)Zn[t.charCodeAt(e)]=0}let c=0,l=-1;const h=32*u,d=Math.min(32,r-h)+h;for(let e=h;e<d;e++)Zn[t.charCodeAt(e)]|=1<<e;let f=r;for(let t=0;t<n;t++){const n=Zn[e.charCodeAt(t)],a=i[t/32|0]>>>t&1,s=o[t/32|0]>>>t&1,u=n|c,h=((n|s)&l)+l^l|n|s;let d=c|~(h|l),p=l&h;f+=d>>>r-1&1,f-=p>>>r-1&1,d>>>31^a&&(i[t/32|0]^=1<<t),p>>>31^s&&(o[t/32|0]^=1<<t),d=d<<1|a,p=p<<1|s,l=p|~(u|d),c=d&u}for(let e=h;e<d;e++)Zn[t.charCodeAt(e)]=0;return f})(t,e)};var er=n(944);class nr{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=nr._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 nr(t._length);n._length=t._length,n._data=nr._createBuffer(n._length),n._version=0;const r=t.lengthInInts;for(let o=0;o<r;o++)n._data[o]=t._data[o]&e._data[o];return n}static _createBuffer(t){return new Uint32Array(Math.floor((t+31)/32))}static fromValues(t){const e=new nr(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 nr(t);for(let r=0;r<t;++r)n.setBit(r,e(r));return n._version=0,n}static fromString(t){return nr.fromSeq(t.length,(e=>"1"==t.charAt(e)))}static fromUint32Array(t,e){const n=new nr(t);return n._data=e,n}static fromBytes(t){const e=t.length,n=new nr(8*e);n._data=new Uint32Array(Math.floor((e+3)/4)),n._length=8*e;let r=0,o=0;for(;e-o>=4;)n._data[r++]=255&t[o]|(255&t[o+1])<<8|(255&t[o+2])<<16|(255&t[o+3])<<24,o+=4;return e-o==3&&(n._data[r]=(255&t[o+2])<<16),e-o==2&&(n._data[r]|=(255&t[o+1])<<8),e-o==1&&(n._data[r]|=255&t[o]),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 nr(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,o=!0){if(n&&o&&this.setAll(!e,!1),o)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 nr.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 o=Math.min(t,e),i=Math.max(t,e);if(n)for(let t=o;t<=i;t++)this.setTrue(t);else for(let t=o;t<=i;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+=nr._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+=nr._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 o=0;for(;o<r-1;o++)for(let e=this._data[o]&t._data[o];0!=e;e>>>=8)n+=nr._onBitCount[255&e];let i=this._data[o]&t._data[o];const a=31&this._length;for(0!=a&&(i&=~(4294967295<<a));0!=i;i>>>=8)n+=nr._onBitCount[255&i];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 o=Math.floor(t/32);o<r;o++){let r=e?this._data[o]:~this._data[o];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=nr._firstOnBit[255&r];if(n>=0)return(t=n+32*o+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=nr._lastOnBit[t>>>24];if(n>=0)return n+32*r+e}}return-1}}function rr(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,o=new Float32Array((n.length+r)*(n.length+r));return Object.entries(e).forEach((([t,r])=>{const i=n[r];Object.entries(e).forEach((([e,r])=>{o[t.charCodeAt(0)*n.length+e.charCodeAt(0)]=i[r]}))})),(t,e)=>1-o[t.charCodeAt(0)*n.length+e.charCodeAt(0)]}(),n=t?.threshold??0;return(t,r)=>{let o=0;const i=t.length,a=r.length,s=Math.ceil(Math.max(i,a)*(1-n));i!==a&&(o=Math.abs(i-a));let u=0;for(let n=0;n<Math.min(i,a);n++)if(t[n]!==r[n]&&(u+=e(t[n],r[n]),u>s))return 1;return u+=o,u/=Math.max(i,a),u}}nr._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]),nr._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]),nr._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 or={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 ir;!function(t){t.HAMMING="Hamming",t.LEVENSHTEIN="Levenshtein",t.NEEDLEMANN_WUNSCH="Needlemann-Wunsch",t.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance"}(ir||(ir={}));const ar={[ir.HAMMING]:rr,[ir.LEVENSHTEIN]:function(){return(t,e)=>tr(t,e)/Math.max(t.length,e.length)},[ir.NEEDLEMANN_WUNSCH]:function(t){const e=new Uint16Array(65536),{gapOpen:n,gapExtend:r,scoringMatrix:o,alphabetIndexes:i}={...or,...t};Object.entries(i).forEach((([t,n])=>e[t.charCodeAt(0)]=n));const a=[new Float32Array(1e4),new Float32Array(1e4)];return(t,i)=>{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 h=1;h<i.length+1;h++){a[l][0]=-r-(h-1)*r;for(let d=1;d<t.length+1;d++){const f=a[c][d-1]+o[e[t.charCodeAt(d-1)]][e[i.charCodeAt(h-1)]],p=a[c][d]-(s[d]||1===h||h===i.length?r:n),m=a[l][d-1]-(u[d-1]||1===d||d===t.length?r:n);a[l][d]=Math.max(f,m,p),a[l][d]===f?(s[d]=!1,u[d]=!1):a[l][d]===m?(s[d]=!1,u[d]=!0):(s[d]=!0,u[d]=!1)}c=l,l=(l+1)%2}const h=Math.min(t.length,i.length);return(h-a[c][t.length])/h}},[ir.MONOMER_CHEMICAL_DISTANCE]:rr};function sr(t,e){const n=t.trueCount()+e.trueCount();if(0==n)return 1;const r=t.andWithCountBits(e,!0);return r/(n-r)}function ur(t){return t<=0?3402823e32:1/t-1}xn.Tanimoto,xn.Dice,xn.Asymmetric,xn.BraunBlanquet,xn.Cosine,xn.Kulczynski,xn.McConnaughey,xn.RogotGoldberg,xn.Russel,xn.Sokal,xn.Hamming,xn.Euclidean,xn.Tanimoto,xn.Dice,xn.Asymmetric,xn.BraunBlanquet,xn.Cosine,xn.Kulczynski,xn.McConnaughey,xn.RogotGoldberg,xn.Russel,xn.Sokal,xn.Hamming,xn.Euclidean,xn.Tanimoto,xn.Dice,xn.Cosine,xn.Tanimoto,xn.Asymmetric,xn.Cosine,xn.Sokal,ir.HAMMING,ir.LEVENSHTEIN,ir.MONOMER_CHEMICAL_DISTANCE,ir.NEEDLEMANN_WUNSCH;const cr={[Pn.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)},[Pn.Manhattan]:function(t,e){let n=0;for(let r=0;r<t.length;r++)n+=Math.abs(t[r]-e[r]);return n},[Pn.Cosine]:function(t,e){let n=0,r=0,o=0;for(let i=0;i<t.length;i++)n+=t[i]*e[i],r+=t[i]*t[i],o+=e[i]*e[i];return(1-n/(Math.sqrt(r)*Math.sqrt(o)))/2}},lr={[Ln.Levenshtein]:tr,[Ln.JaroWinkler]:er.Vb,[Ln.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}},[Ln.Onehot]:function(t,e){return t===e?0:1}},hr={[xn.Tanimoto]:function(t,e){return 1-sr(t,e)},[xn.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)},[xn.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)},[xn.BraunBlanquet]:function(t,e){return ur(function(t,e){const n=Math.max(t.trueCount(),e.trueCount());return 0==n?0:t.andWithCountBits(e,!0)/n}(t,e))},[xn.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)},[xn.Kulczynski]:function(t,e){return ur(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))},[xn.McConnaughey]:function(t,e){return ur(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))},[xn.RogotGoldberg]:function(t,e){return ur(function(t,e){const n=t.andWithCountBits(e,!0),r=t.countBits(!0)+e.countBits(!0),o=t.length,i=o-r+n;return n==o||i==o?1:n/r+i/(2*o-r)}(t,e))},[xn.Russel]:function(t,e){return ur(function(t,e){return 0==t.length?0:t.andWithCountBits(e,!0)/t.length}(t,e))},[xn.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)},[xn.Hamming]:function(t,e){return t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0)},[xn.Euclidean]:function(t,e){return Math.sqrt(t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0))}},dr={[Rn.TanimotoIntArray]:function(t,e){return ur(sr(new nr(t,32*t.length),new nr(e,32*e.length)))}},fr={[Dn.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)}},pr={[Un.CommonItems]:function(t){const e=function(t){const e=t?.mostCommon??new Set;return(t,n)=>{const r=t.length,o=n.length;let i=0,a=0,s=0;for(;a<r&&s<o;)t[a]===n[s]?(e?.has(t[a])||++i,++a,++s):t[a]<n[s]?++a:++s;return i}}(t);return(t,n)=>0===n.length||0===t.length?1e4:Math.min(t.length,n.length)/(e(t,n)+1e-4)}},mr={[Fn.Vector]:{[Pn.Euclidean]:cr[Pn.Euclidean],[Pn.Manhattan]:cr[Pn.Manhattan],[Pn.Cosine]:cr[Pn.Cosine]},[Fn.String]:{[Ln.Levenshtein]:lr[Ln.Levenshtein],[Ln.JaroWinkler]:lr[Ln.JaroWinkler],[Ln.Manhattan]:lr[Ln.Manhattan],[Ln.Onehot]:lr[Ln.Onehot]},[Fn.BitArray]:{[xn.Tanimoto]:hr[xn.Tanimoto],[xn.Dice]:hr[xn.Dice],[xn.Asymmetric]:hr[xn.Asymmetric],[xn.BraunBlanquet]:hr[xn.BraunBlanquet],[xn.Cosine]:hr[xn.Cosine],[xn.Kulczynski]:hr[xn.Kulczynski],[xn.McConnaughey]:hr[xn.McConnaughey],[xn.RogotGoldberg]:hr[xn.RogotGoldberg],[xn.Russel]:hr[xn.Russel],[xn.Sokal]:hr[xn.Sokal]},[Fn.MacroMolecule]:{[ir.HAMMING]:ar[ir.HAMMING],[ir.LEVENSHTEIN]:ar[ir.LEVENSHTEIN],[ir.NEEDLEMANN_WUNSCH]:ar[ir.NEEDLEMANN_WUNSCH],[ir.MONOMER_CHEMICAL_DISTANCE]:ar[ir.MONOMER_CHEMICAL_DISTANCE]},[Fn.Number]:{[Dn.Difference]:fr[Dn.Difference]},[Fn.IntArray]:{[Rn.TanimotoIntArray]:dr[Rn.TanimotoIntArray]},[Fn.NumberArray]:{[Un.CommonItems]:pr[Un.CommonItems]}};Object.keys(mr).reduce(((t,e)=>{for(const n of Object.keys(mr[e]))t[n]=e;return t}),{});class gr{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"},fn().then((t=>{t?(this.useWebGPU.tooltip+=` (${t})`,this.useWebGPU.value=!0):(this.useWebGPU.value=!1,this.useWebGPU.disable=!0)}))}}class yr{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 vr{constructor(n={}){this.editorSettings={},this.columnOptEditors=[],this.columnOptEditorsRoot=e.div(),this.columnParamsEditorRoot=e.div(),this.columnFunctionsMap={},this.methodsParams={[An.UMAP]:new gr,[An.T_SNE]:new yr},this.dbScanParams=new Sn,this.methodSettingsDivs=[],this.supportedFunctions={},this.methodSettingsAnchor=e.div(),this.plotEmbeddingsInput=e.input.bool("Plot embeddings",{value:!0}),this.aggregationMethodInput=e.input.choice("Aggregation",{value:Mn.EUCLIDEAN,items:[Mn.EUCLIDEAN,Mn.MANHATTAN]}),this.vectorDistanceInput=e.input.choice("Distance metric",{value:Pn.Euclidean,items:[Pn.Euclidean,Pn.Manhattan,Pn.Cosine]}),this.aggregationMethodInput.setTooltip("Aggregation method for combining distances between columns"),this.vectorDistanceInput.root.style.display="none",this.onColumnsChanged=new On.Subject,this.editorSettings=n,this.columnParamsEditorAccordion=e.accordion(),o.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")??"",o=t.options.get("supportedUnits")??"",i=t.options.get("supportedDistanceFunctions")??"";this.editorSettings.semtype&&!e.includes(this.editorSettings.semtype)||this.editorSettings.type&&!r.includes(this.editorSettings.type)||this.editorSettings.units&&!o.includes(this.editorSettings.units)||(this.supportedFunctions[n]={func:t,semTypes:e?e.split(","):[],types:r?r.split(","):[],units:o?o.split(","):[],distanceFunctions:i?i.split(","):[]})})),this.postProcessingEditor=new Er,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:An.UMAP,items:[An.UMAP,An.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,o=this.supportedFunctions[e].units,i=!n.length||t.semType&&n.includes(t.semType),a=!r.length||r.includes(t.type),s=!o.length||t.meta.units&&o.includes(t.meta.units);i&&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 wr(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 o=0;const i=e.table(r,(t=>(o++,t&&t.length>0?t:[this.columnOptEditors[Math.floor((o-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"),i.classList.add("ml-dim-reduction-column-editor-table-root"),this.columnOptEditorsRoot.appendChild(i),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((o=>{const i=t[o],a="string"===i.type?e.input.string(i.uiName,{value:i.value??"",onValueChanged:t=>{i.value=t}}):"boolean"===i.type?e.input.bool(i.uiName,{value:i.value??!1,onValueChanged:t=>{i.value=t}}):e.input.float(i.uiName,{value:i.value,onValueChanged:t=>{i.value=t}});i.disable?(a.enabled=!1,e.tooltip.bind(a.input??a.root,i.disableTooltip??"")):e.tooltip.bind(a.input??a.root,i.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 wr{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[br(t.func)]=t.func})),this.preprocessingFunctionInput=e.input.choice("Encoding function",{value:br(this.supportedFunctions[0].func),items:this.supportedFunctions.map((t=>br(t.func))),onValueChanged:t=>{const n=this.functionsMap[t];this.preprocessingFunctionSettings={},this.hasExtraSettings=n.inputs.length>2;const o=this.supportedFunctions.find((e=>br(e.func)===t));this.getSimilarityMetricInput(o),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 o=e.h3(this.column.name,{classes:"ml-dim-reduction-column-editor-column-title"});this.colOptEditors=[o,this.preprocessingFunctionInput.root,this.similarityMetricInputRoot,this.weightInput.root],e.tooltip.bind(o,this.column.name),this.colOptEditors.forEach((t=>t.classList.add("ml-dim-reduction-column-editor-input-root")));const i=e.divH(this.colOptEditors,{classes:"ml-dim-reduction-column-editor-root"});this.accordionDiv=e.divV([]),this.editorDiv.appendChild(i),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(),o=await r.buildEditor(e.div());for(let e=2;e<n.inputs.length;e++){const i=n.inputs[e],a=this.preprocessingFunctionSettings[i.name]||r.inputParams[n.inputs[e].name].value||i.defaultValue;a&&(this.preprocessingFunctionSettings[i.name]=a);const s=o.find((t=>t.property.name===i.name));s&&(null!==this.preprocessingFunctionSettings[i.name]&&void 0!==this.preprocessingFunctionSettings[i.name]&&(s.value=this.preprocessingFunctionSettings[i.name]),s.onChanged.subscribe((t=>{this.preprocessingFunctionSettings[i.name]=t})),t.append(s.root))}return t.style.marginBottom="10px",t}}function br(t){return t.friendlyName??t.name}class Er{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",o.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),o=await r.buildEditor(e.div());for(let e=2;e<t.inputs.length;e++){const n=t.inputs[e],i=this._postProcessingArgs[n.name]||r.inputParams[t.inputs[e].name].value||n.defaultValue;i&&(this._postProcessingArgs[n.name]=i);const a=o.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 Ar="dimensionality-reducer-terminate-event",Cr=t=>null==t;function _r(t,e){return`${e} (${t.length>4?`${t.length} columns`:t.map((t=>t.name)).join(", ")})`}var Sr=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function s(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(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 Nr(n){return Sr(this,void 0,void 0,(function*(){if(null!=n||(n=t.shell.t),null===n)return void t.shell.warning(ke.NO_DATAFRAME);const r=[],i=[],a=[];n.columns.toList().filter((t=>qe.includes(t.type))).forEach((t=>{const e=t.stats.missingValueCount;e!==t.length&&(a.push(t.name),e>0&&(r.push(t),i.push(t.name)))}));const s=function(t){const e=new Map;for(const n of t){if(!qe.includes(n.type))throw new Error(ke.UNSUPPORTED_COLUMN_TYPE);if(0===n.stats.missingValueCount)continue;const t=[],r=ze(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(ke.NO_MISSING_VALUES);if(1===a.length)return void t.shell.error(ke.ONE_AVAILABLE_FEATURE);let u=Ke.IN_PLACE>0;const c=e.input.bool(Ve.IN_PLACE,{value:u,onValueChanged:t=>{u=null!=t&&t}});c.setTooltip(He.IN_PLACE);let l=Ke.KEEP_EMPTY>0;const h=e.input.bool(Ve.KEEP_EMPTY,{value:l,onValueChanged:t=>{l=null!=t&&t}});h.setTooltip(He.KEEP_EMPTY);let d=Ke.NEIGHBORS;const f=e.input.int(Ve.NEIGHBORS,{value:d,showPlusMinus:!0,min:Xe,nullable:!1,onValueChanged:t=>{null!==t&&t>=Xe&&(d=t),E()}});f.setTooltip(He.NEIGHBORS);let p=$e.EUCLIDEAN;const m=e.input.choice(Ve.DISTANCE,{value:p,items:[$e.EUCLIDEAN,$e.MANHATTAN],onValueChanged:t=>p=null!=t?t:$e.EUCLIDEAN});m.setTooltip(He.DISTANCE);let g=r.map((t=>t.name));const y=e.input.columns(Ve.COLUMNS,{table:n,value:n.columns.byNames(i),onValueChanged:t=>{g=t.map((t=>t.name)),E()},available:i});y.setTooltip(He.TARGET);let v=a;const w=e.input.columns(Ve.FEATURES,{value:n.columns.byNames(a),table:n,onValueChanged:t=>{v=t.map((t=>t.name)),v.length>0?(E(),C.forEach(((t,e)=>t.hidden=!v.includes(e)))):b()},available:a});w.setTooltip(He.FEATURES);const b=()=>{S.getButton(Ve.RUN).disabled=!0,c.root.hidden=!0,h.root.hidden=!0,f.root.hidden=!0,I.hidden=!0,_.hidden=!0},E=()=>{S.getButton(Ve.RUN).disabled=null===f.value||f.value<Xe,I.hidden=!1,c.root.hidden=!1,f.root.hidden=!1,m.root.hidden=!1,h.root.hidden=!Qe(g,v,s),1===v.length&&g.forEach((e=>{v[0]===e&&(b(),t.shell.warning(`${ke.ONE_FEATURE_SELECTED} the column '${e}'`))})),g.length<1&&b()},A=new Map,C=new Map,_=e.divV([]);_.style.overflow="auto",a.forEach((t=>{const r=function(t){switch(t){case o.COLUMN_TYPE.STRING:case o.COLUMN_TYPE.DATE_TIME:return{defaultWeight:Ke.WEIGHT,defaultMetric:Ye.ONE_HOT,availableMetrics:[Ye.ONE_HOT]};case o.COLUMN_TYPE.INT:case o.COLUMN_TYPE.FLOAT:case o.COLUMN_TYPE.QNUM:return{defaultWeight:Ke.WEIGHT,defaultMetric:Ye.DIFFERENCE,availableMetrics:[Ye.DIFFERENCE,Ye.ONE_HOT]};default:throw new Error(ke.UNSUPPORTED_COLUMN_TYPE)}}(n.col(t).type);A.set(t,{weight:r.defaultWeight,type:r.defaultMetric});const i=e.input.choice(t,{value:r.defaultMetric,items:r.availableMetrics,onValueChanged:e=>{var n;const o=null!==(n=A.get(t))&&void 0!==n?n:{weight:r.defaultWeight,type:r.defaultMetric};o.type=null!=e?e:r.defaultMetric,A.set(t,o)}});i.root.style.width="50%",i.setTooltip(He.METRIC),i.root.hidden=!0;const a=o.Property.fromOptions({name:t.length<je?t:t.slice(0,je).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 o=null!==(n=A.get(t))&&void 0!==n?n:{weight:r.defaultWeight,type:r.defaultMetric};o.weight=null!=e?e:r.defaultWeight,A.set(t,o)})),e.tooltip.bind(s.captionLabel,t),e.tooltip.bind(s.input,He.WEIGHT),C.set(t,s.root),_.append(s.root)}));const S=e.dialog({title:Ve.KNN_IMPUTER,helpUrl:We});t.shell.v.root.appendChild(S.root),_.hidden=!0,h.root.hidden=!Qe(g,v,s);const N=e.icons.settings((()=>{_.hidden=!_.hidden}),He.METRIC_SETTINGS),I=e.divH([m.root,N]);let M,T,O=!1;const L=new Promise(((t,e)=>{M=t,T=e}));return S.addButton(Ve.RUN,(()=>{O=!0,S.close(),a.filter((t=>!v.includes(t))).forEach((t=>A.delete(t)));try{const e=function(e,n,r,i,a,s,u){if(s<Xe)throw new Error(ke.INCORRECT_NEIGHBORS);if(e.rowCount<2)throw new Error(ke.KNN_NOT_ENOUGH_OF_ROWS);if(0===n.length)throw new Error(ke.KNN_NO_TARGET_COLUMNS);if(0===r.size)throw new Error(ke.KNN_NO_FEATURE_COLUMNS);1===r.size&&n.forEach((t=>{if(r.has(t))throw new Error(`${ke.KNN_NO_FEATURE_COLUMNS} can be used for the column '${t}'`)})),n.forEach((t=>{if(!i.has(t))throw new Error(`${ke.KNN_FAILS}: ${ke.WRONG_PREDICTIONS}`)}));const c=e.columns;n.forEach((t=>{if(!qe.includes(c.byName(t).type))throw new Error(ke.UNSUPPORTED_COLUMN_TYPE)})),r.forEach(((t,n)=>{if(!qe.includes(e.getCol(n).type))throw new Error(ke.UNSUPPORTED_COLUMN_TYPE)}));const l=new Map;return n.forEach((n=>{const h=c.byName(n),d=ze(h),f=h.length,p=h.getRawData(),m=new Uint16Array(h.categories.length),g=[],y=[],v=[],w=[];r.forEach(((t,e)=>{if(e!==h.name){const n=c.byName(e);switch(g.push(n.getRawData()),y.push(ze(n)),t.type){case Ye.DIFFERENCE:v.push(((e,n)=>t.weight*Math.abs(e-n)));break;case Ye.ONE_HOT:v.push(((e,n)=>t.weight*(e===n?0:1)))}}}));const b=g.length,E=new Uint32Array(g.length),A=new Float32Array(g.length);let C=0;const _=new Array(s);let S=0,N=0,I=0,M=0,T=0;const O=(t,e)=>{E.forEach(((n,r)=>{A[r]=v[n](g[n][t],g[n][e])}))},L=a===$e.EUCLIDEAN?()=>{let t=0;for(let e=0;e<C;++e)t+=A[e]*A[e];return Math.sqrt(t)}:()=>{let t=0;for(let e=0;e<C;++e)t+=Math.abs(A[e]);return Math.sqrt(t)},P=t=>{if(p[t]===d)return!1;for(let e=0;e<C;++e)if(g[E[e]][t]===y[E[e]])return!1;return!0},x=t=>{if((t=>{C=0;for(let e=0;e<b;++e)g[e][t]!==y[e]&&(E[C]=e,++C)})(t),0===C)throw new Error(`${ke.KNN_IMPOSSIBLE_IMPUTATION}: the column "${h.name}", row ${t+1}`);S=0;for(let e=0;e<f;++e)if(P(e)&&e!==t){O(t,e);const n=L();if(S<s)_[S]={index:e,dist:n},++S;else{N=0,I=_[0].dist;for(let t=1;t<S;++t)I<_[t].dist&&(I=_[t].dist,N=t);n<I&&(_[N]={index:e,dist:n})}}if(0===S)throw new Error(`${ke.KNN_IMPOSSIBLE_IMPUTATION}: the column "${h.name}", row ${t+1}`);if(h.type===o.COLUMN_TYPE.STRING)return(()=>{m.forEach(((t,e,n)=>n[e]=0));let t=0;for(t=0;t<S;++t)++m[p[_[t].index]];let e=m[0],n=0;return m.forEach(((t,r)=>{t>e&&(e=t,n=r)})),n})();M=0;for(let t=0;t<S;++t)M+=p[_[t].index];return T=M/S,h.type===o.COLUMN_TYPE.INT?Math.round(T):T};if(u){for(const e of i.get(n))try{p[e]=x(e)}catch(n){w.push(e),n instanceof Error||t.shell.error(ke.CORE_ISSUE)}w.length>0&&l.set(n,w),h.set(0,h.get(0))}else{const r=h.clone();let o=1,a=`${n}(${Be})`;for(;e.columns.contains(a);)a=`${n}(${Be} ${o})`,++o;r.name=a;const s=r.getRawData();for(const e of i.get(n))try{s[e]=x(e)}catch(n){w.push(e),n instanceof Error||t.shell.error(ke.CORE_ISSUE)}w.length>0&&l.set(a,w),r.set(0,r.get(0)),e.columns.add(r)}})),l}(n,g,A,s,p,d,u);l||function(t,e){e.forEach(((e,n)=>{const r=t.col(n);if(null!==r){if(!qe.includes(r.type))throw new Error(ke.UNSUPPORTED_COLUMN_TYPE);const t=function(t){switch(t.type){case o.COLUMN_TYPE.STRING:case o.COLUMN_TYPE.DATE_TIME:return function(t){const e=ze(t),n=t.getRawData(),r=n.length;for(let o=0;o<r;++o)if(n[o]!==e)return t.get(o);throw new Error(ke.EMPTY_COLUMN)}(t);case o.COLUMN_TYPE.INT:case o.COLUMN_TYPE.FLOAT:case o.COLUMN_TYPE.QNUM:return t.stats.avg;default:throw new Error(ke.UNSUPPORTED_COLUMN_TYPE)}}(r);e.forEach((e=>r.set(e,t)))}}))}(n,e),M()}catch(e){e instanceof Error?t.shell.error(`${ke.KNN_FAILS}: ${e.message}`):t.shell.error(`${ke.KNN_FAILS}: ${ke.CORE_ISSUE}`),T(e)}}),void 0,He.RUN),S.add(y).add(w).add(I).add(_).add(f).add(c).add(h).show().onClose.subscribe((()=>!O&&M())),L}))}class Ir extends vr{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:_n}),this.minClusterSizeInput=e.input.int("Min Cluster Size",{value:5}),fn().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??_n,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??_n,minClusterSize:this.minClusterSizeInput.value??5}}}class Mr{constructor(t,e,n,r,i,a){this.sc=t,this.from=e,this.to=n,this.shortLineThreshold=r,this.width=i,this.color=a,this.renderFlag=!1,this.renderSub=o.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,o)=>t.isNone(o)||e.isNone(o)||!n.get(o)?null:this.sc.pointToScreen(o))),o=this.sc.canvas.getContext("2d");if(!o)return;o.strokeStyle=`rgba(${this.color}, 0.3)`,o.lineWidth=this.width;const i=this.shortLineThreshold*this.shortLineThreshold;for(let t=0;t<this.from.length;t++){o.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<i)continue;o.moveTo(t.x,t.y),o.lineTo(a.x,a.y),o.stroke(),o.closePath()}}}destroy(){this.renderSub.unsubscribe()}}class Tr extends o.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(o.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),i=r.cols.map((t=>this.dataFrame.columns.byName(t))),a=r.preprocessingFuncs.map((t=>t?o.Func.byName(t):null)),s=await async function(r,i,a,s,u,c,l,h=80,d=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:o,options:s}=await e.apply({[n]:i[t],[r]:a[t],...l[t]??{}});b.push({entries:o,options:s}),w.push(s??{})}else{const e=i[t].toList(),n={};b.push({entries:e,options:n}),w.push(n)}}const E=function(t,e,r,o,i,a,s=10,u=!1,c=2){const l=new Worker(new URL(n.p+n.u(980),n.b));let h;return l.postMessage({data:t,threshold:e,weights:r,aggregationMethod:o,distanceFns:i,distanceFnArgs:a,maxIterations:s,useWebGPU:u,inflate:c}),{promise:new Promise(((t,e)=>{h=t,l.onmessage=e=>{setTimeout((()=>l.terminate()),100),t(e.data.res)},l.onerror=t=>{setTimeout((()=>l.terminate()),100),e(t)}})),terminate:()=>{try{h(null),l.terminate()}catch(t){console.error(t)}}}}(b.map((t=>t.entries)),h,s,u,a,w,d,f,p),A=t.events.onViewerClosed.subscribe((t=>{t.args.viewer?.props?.title===v.props.title&&v.type===t.args?.viewer?.type&&(A.unsubscribe(),E.terminate())})),C=await E.promise;if(!C)return;const _=r.columns.getUnusedName("Cluster (MCL)"),S=r.columns.getUnusedName("EmbedX (MCL)"),N=r.columns.getUnusedName("EmbedY (MCL)"),I={};C.clusters.forEach((t=>{I[t]||(I[t]=0),I[t]++}));const M=new Uint32Array(C.embedX.length);for(let t=0;t<C.is.length;t++)M[C.is[t]]++,M[C.js[t]]++;const T=r.columns.getUnusedName("Cluster size (MCL)"),O=r.columns.getUnusedName("Connectivity (MCL)"),L=r.columns.addNewFloat(S);L.init((t=>C.embedX[t]));const P=r.columns.addNewFloat(N);P.init((t=>C.embedY[t]));const x=r.columns.addNewString(_);x.init((t=>I[C.clusters[t]]>=m?C.clusters[t].toString():"-1"));const R={"-1":o.Color.setAlpha(o.Color.lightBlue,100)};x.setTag(o.TAGS.COLOR_CODING_CATEGORICAL,JSON.stringify(R)),x.temp[o.TAGS.COLOR_CODING_CATEGORICAL]=R;const F=r.columns.addNewInt(T);F.init((t=>I[C.clusters[t]]));const D=r.columns.addNewInt(O);D.init((t=>M[t])),v.props.xColumnName=S,v.props.yColumnName=N,v.props.colorColumnName=_,v.props.markerDefaultSize=6,A.unsubscribe();const U=[],k=[],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){U.push(C.is[t]),k.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 o=r.get(n);o||(o=0),o>=20||(o++,r.set(n,o),U.push(C.is[t]),k.push(C.js[t]))}return e.setUpdateIndicator(v.root,!1),{sc:v,embedXCol:L,embedYCol:P,clusterCol:x,clusterCounterCol:F,connectivityCol:D,i:U,j:k}}(this.dataFrame,i,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 Mr(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 Mr(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 Or=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function s(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(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 Lr(t,e){const n=t.length;if(n!==e.length-1)throw new Error("Incorrect parameters count");const r=t.byIndex(0),i=r.length,a=new Float32Array(i);let s=r.getRawData();const u=e[n];let c=e[0];for(let t=0;t<i;++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<i;++t)a[t]+=c*s[t]}return o.Column.fromFloat32Array(t.getUnusedName("prediction"),a,i)}const Pr=(t,e)=>e<=t?Math.min(10,e):Math.min(10,t);var xr;!function(t){t[t.MAX_SAMLPES=1e5]="MAX_SAMLPES",t[t.MAX_FEATURES=1e3]="MAX_FEATURES"}(xr||(xr={}));class Rr{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<=xr.MAX_FEATURES&&e.length<=xr.MAX_SAMLPES}constructor(t){if(this.specn=null,t)try{const e=new Uint32Array(t.buffer,0,2),n=e[0],r=e[1],i=new Uint8Array(t.buffer,8,n),a=o.DataFrame.fromByteArray(i),s=a.rowCount,u=a.columns,c=u.length,l=new Uint8Array(t.buffer,8+n,r),h=o.DataFrame.fromByteArray(l);if(c<3)throw new Error("incorrect columns count");const d=u.byName(ve.FEATURES).toList(),f=new Float32Array(s);f.set(u.byName(ve.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:d,dim:s-1,components:c-2,scores:h}}catch(t){throw new Error(`Failed to load model: ${t instanceof Error?t.message:"the platform issue"}`)}}fit(t,e,n){return r=this,i=void 0,s=function*(){const r=yield De({table:o.DataFrame.fromColumns([e]),features:t,predict:e,components:n,names:void 0,isQuadratic:!1}),i=t.names();i.push("_");const a=this.getRegrCoeffs(t,e,r.regressionCoefficients),s=this.getLoadings(n,r.xLoadings);this.specn={names:i,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 o(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,o)}u((s=s.apply(r,i||[])).next())}));var r,i,a,s}getLoadings(t,e){const n=Array(t),r=e[0].length+1;for(let o=0;o<t;++o)n[o]=new Float32Array(r),n[o].set(e[o].getRawData());return n}getRegrCoeffs(t,e,n){const r=t.length,o=new Float32Array(r+1),i=n.getRawData();let a=0;for(let e=0;e<r;++e)o[e]=i[e],a+=i[e]*t.byIndex(e).stats.avg;return o[r]=e.stats.avg-a,o}computeExplVars(t,e,n){if(null===this.specn)throw new Error("Failed to compute explained variances");const r=n.getRawData(),o=this.specn.loadings[0].length-1;let i=Math.pow(r[0],2)/t;this.specn.loadings[0][o]=i;for(let n=1;n<e;++n)i+=Math.pow(r[n],2)/t,this.specn.loadings[n][o]=i}toBytes(){if(null===this.specn)throw new Error("Failed to pack untrained model");const t=o.DataFrame.fromColumns([o.Column.fromStrings(ve.FEATURES,this.specn.names),o.Column.fromFloat32Array(ve.REGR_COEFS,this.specn.params)]);this.specn.loadings.forEach(((e,n)=>t.columns.add(o.Column.fromFloat32Array(`${ve.XLOADING}${n+1}`,e))));const e=t.toByteArray(),n=e.length,r=this.specn.scores.toByteArray(),i=r.length,a=n+i+8,s=new Uint8Array(64*(Math.ceil(a/64)+1)),u=new Uint32Array(s.buffer,0,2);return u[0]=n,u[1]=i,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 Lr(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=o.DataFrame.fromColumns([o.Column.fromStrings(ve.FEATURES,this.specn.names.slice(0,-1)),o.Column.fromFloat32Array(ve.REGR_COEFS,this.specn.params,e)]),r=n.columns,i=r.length,a=this.specn.components;return this.specn.loadings.forEach(((t,r)=>n.columns.add(o.Column.fromFloat32Array(`${ve.XLOADING}${r+1}`,t,e)))),t.push(o.Viewer.scatterPlot(n,{title:ve.LOADINGS,xColumnName:r.byIndex(i).name,yColumnName:r.byIndex(i+(a>1?1:0)).name,markerType:o.MARKER_TYPE.CIRCLE,labelFormColumnNames:[ve.FEATURES],help:be.LOADINGS})),t.push(o.Viewer.barChart(n,{title:ve.REGR_COEFS,splitColumnName:ve.FEATURES,valueColumnName:ve.REGR_COEFS,valueAggrType:o.AGG.AVG,help:be.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]=`${Ae.COMP} 1`,r[0]=this.specn.loadings[0][e];for(let o=1;o<t;++o)n[o]=`${Ae.COMPS} ${o+1}`,r[o]=this.specn.loadings[o][e];return o.Viewer.barChart(o.DataFrame.fromColumns([o.Column.fromStrings(Ae.COMPS,n),o.Column.fromFloat32Array(ve.EXPL_VAR,r)]),{title:ve.EXPL_VAR,splitColumnName:Ae.COMPS,valueColumnName:ve.EXPL_VAR,valueAggrType:o.AGG.AVG,help:be.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=`${ve.XSCORE}${e+1}`)),n.forEach(((t,e)=>t.name=`${ve.YSCORE}${e+1}`)),o.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=o.Viewer.scatterPlot(this.specn.scores,{title:ve.SCORES,xColumnName:t[0],yColumnName:t[1],markerType:o.MARKER_TYPE.CIRCLE,help:be.SCORES,showViewerFormulaLines:!0});return e.meta.formulaLines.addAll(Fe(t)),e}}var Fr=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function s(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(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 Dr="Avg-s",Ur="Stddev-s";var kr;!function(t){t[t.MAX_SAMLPES=5e4]="MAX_SAMLPES",t[t.MAX_FEATURES=100]="MAX_FEATURES"}(kr||(kr={}));class Gr{static isApplicable(t,e){for(const e of t)if(!e.matches("numerical"))return!1;return e.type===o.COLUMN_TYPE.STRING}static isInteractive(t,e){return t.length<=kr.MAX_FEATURES&&e.length<=kr.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=o.DataFrame.fromByteArray(n),i=r.columns,a=i.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=i.byIndex(t);if(this.categories[t]=e.name,e.type!==o.COLUMN_TYPE.FLOAT)throw new Error(`Incorrect input column type. Expected: float, passed: ${e.type}`);this.params[t]=e.getRawData()}const u=i.byName(Dr);if(u.type!==o.COLUMN_TYPE.FLOAT)throw new Error("incorrect average values column type");this.avgs=u.getRawData();const c=i.byName(Ur);if(c.type!==o.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]=o.Column.fromFloat32Array(this.categories[n],this.params[n]);e[t]=o.Column.fromFloat32Array(Dr,this.avgs),e[t+1]=o.Column.fromFloat32Array(Ur,this.stdevs);const n=o.DataFrame.fromColumns(e).toByteArray(),r=n.length,i=new Uint8Array(r+4);return new Uint32Array(i.buffer,0,1)[0]=r,i.set(n,4),i}fit(t,e){return Fr(this,arguments,void 0,(function*(t,e,n=1,r=100,i=.1,a=.001){if(t.length!==this.featuresCount)throw new Error("Training failes - incorrect features count");if(n<=0||r<1||i<=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,o,i,a,s,u,c,l){return g(EDA,"fitSoftmax",[t,e,n,r,o,i,a,s,u,c,l])}(t,o.Column.fromFloat32Array("avgs",this.avgs,this.featuresCount),o.Column.fromFloat32Array("stdevs",this.stdevs,this.featuresCount),o.Column.fromInt32Array("targets",e.getRawData(),s),u,r,n,i,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(o){try{this.params=yield this.fitSoftmaxParams(t,e,r,n,i,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!==o.COLUMN_TYPE.INT&&n.type!==o.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 i of t){if(i.type!==o.COLUMN_TYPE.INT&&i.type!==o.COLUMN_TYPE.FLOAT)throw new Error("Training failes - incorrect features type");const t=i.getRawData(),a=this.avgs[r],s=this.stdevs[r];if(s>0)for(let o=0;o<e;++o)n[o][r]=(t[o]-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 i=0;for(const n of t){if(n.type!==o.COLUMN_TYPE.INT&&n.type!==o.COLUMN_TYPE.FLOAT)throw new Error("Training failes - incorrect features type");const t=n.getRawData(),a=this.avgs[i],s=this.stdevs[i];if(s>0)for(let n=0;n<e;++n)r[i][n]=(t[n]-a)/s;else for(let t=0;t<e;++t)r[i][t]=0;++i}return r}preprocessedTargets(t){if(t.type!==o.COLUMN_TYPE.STRING)throw new Error("Training failes - incorrect target type");const e=this.classesCount,n=t.length,r=t.getRawData(),i=new Array(n),a=new Uint32Array(e).fill(0);for(let t=0;t<n;++t)i[t]=new Uint8Array(e).fill(0);for(let t=0;t<n;++t)i[t][r[t]]=1,++a[r[t]];return{oneHot:i,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,i=this.classesCount;let a,s;const u=new Float32Array(i);let c,l,h;const d=new Array(n);for(let t=0;t<n;++t){a=e[t],c=0;for(let t=0;t<i;++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],h=0;for(let t=1;t<i;++t)l<u[t]&&(l=u[t],h=t);d[t]=this.categories[h]}return o.Column.fromStrings("predicted",d)}fitSoftmaxParams(t,e,r,o,i,a){return Fr(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:o,penalty:i,tolerance:a}),l.onmessage=function(t){l.terminate(),u(t.data.params),console.log(`Loss: ${t.data.loss}`)}}))}))}}var Br,Vr,Wr;!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"}(Br||(Br={})),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"}(Vr||(Vr={})),function(t){t[t.MODEL=1e7]="MODEL",t[t.UTILS=1]="UTILS",t[t.PACK=128]="PACK",t[t.SIZE=4]="SIZE"}(Wr||(Wr={}));const Hr=o.FLOAT_NULL;var jr;!function(t){t.PREDICT="Prediction",t.TYPE="Type",t.PARAMS="Params count",t.CATS="Categories",t.CATS_SIZE="Categories size"}(jr||(jr={}));class qr{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<=Vr.SAMPLES_LOW?n<=Vr.FEATURES_LOW:r<=Vr.SAMLPES_MID?n<=Vr.FEATURES_MID:r<=Vr.SAMLPES_HIGH&&n<=Vr.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+=Wr.SIZE;const i=o.DataFrame.fromByteArray(new Uint8Array(t.buffer,n,r));n+=r,this.targetType=i.get(jr.TYPE,0);const a=i.get(jr.PARAMS,0),s=i.get(jr.CATS_SIZE,0);if(s>0){const r=o.DataFrame.fromByteArray(new Uint8Array(t.buffer,n,s));this.targetCategories=null===(e=r.col(jr.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,i=arguments,s=function*(t,e,r=Br.ITERATIONS,i=Br.ETA,a=Br.MAX_DEPTH,s=Br.LAMBDA,u=Br.ALPHA){this.targetType=e.type,this.targetType===o.COLUMN_TYPE.STRING&&(this.targetCategories=e.categories),this.modelParams=yield async function(t,e,r,o,i,a,s,u,c,l){return new Promise(((h,d)=>{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:o,eta:i,maxDepth:a,lambda:s,alpha:u,missingValue:r}),v.onmessage=function(t){v.terminate(),h(t.data.params)}}))}(t,e,Hr,r,i,a,s,u,Wr.MODEL,Wr.UTILS)},new((a=void 0)||(a=Promise))((function(t,e){function n(t){try{u(s.next(t))}catch(t){e(t)}}function o(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,o)}u((s=s.apply(r,i||[])).next())}));var r,i,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,o=t.length,i=n.length;let a=XGBoostModule.HEAPF32;const s=XGBoostModule.HEAP32,u=XGBoostModule._malloc(r*o*4),c=XGBoostModule._malloc(4*r),l=XGBoostModule._malloc(4*i);for(let e=0;e<o;++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<i;++t)s[l/4+t]=n[t];XGBoostModule._predict(u,r,o,e,l,i,c,r),a=XGBoostModule.HEAPF32;const h=new Float32Array(r);for(let t=0;t<r;++t)h[t]=a[c/4+t];return XGBoostModule._free(u),XGBoostModule._free(c),XGBoostModule._free(l),h}(t,Hr,this.modelParams);switch(this.targetType){case o.COLUMN_TYPE.STRING:return this.stringColPrediction(e);case o.COLUMN_TYPE.INT:return this.intColPrediction(e);case o.COLUMN_TYPE.BIG_INT:return this.bigIntColPrediction(e);default:return o.Column.fromFloat32Array(jr.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?o.DataFrame.fromColumns([o.Column.fromList(o.COLUMN_TYPE.STRING,jr.CATS,this.targetCategories)]).toByteArray():void 0,e=void 0!==t?t.length:0,n=this.modelParams.length*this.modelParams.BYTES_PER_ELEMENT,r=o.DataFrame.fromColumns([o.Column.fromStrings(jr.TYPE,[this.targetType]),o.Column.fromInt32Array(jr.PARAMS,new Int32Array([this.modelParams.length])),o.Column.fromInt32Array(jr.CATS_SIZE,new Int32Array([e]))]).toByteArray(),i=r.length,a=64*Math.ceil((Wr.SIZE+i+e+n+Wr.PACK)/64),s=new Uint8Array(a);let u=0;return new Uint32Array(s.buffer,u,1)[0]=i,u+=Wr.SIZE,s.set(r,u),u+=i,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;for(let o=0;o<e;++o)n[o]=this.targetCategories[(i=Math.round(t[o]),Math.max(0,Math.min(i,r)))];var i;return o.Column.fromList(o.COLUMN_TYPE.STRING,jr.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 o.Column.fromInt32Array(jr.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 o.Column.fromBigInt64Array(jr.PREDICT,n)}}var zr=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function s(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(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 Yr=new o.Package;function $r(){t.shell.info(Yr.webRoot)}function Kr(){return zr(this,void 0,void 0,(function*(){yield async function(){await initEDA()}(),yield async function(){await initXGBoostModule()}()}))}function Xr(t,e,n,r,i){return zr(this,void 0,void 0,(function*(){const a=e.getRawData(),s=n.getRawData(),u=yield hn(a,s,r,i),c=t.columns.getUnusedName("Cluster (DBSCAN)"),l=o.Column.fromInt32Array(c,u);return t.columns.add(l),l}))}function Qr(e,r,i,a,s){return zr(this,void 0,void 0,(function*(){try{const u=yield function(t,e,r,i,a){return J(this,void 0,void 0,(function*(){X(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 o.DataFrame.fromColumns(e)}(e),c=u.columns.length;if(0===c){const t=[];for(let e=0;e<r;++e)t.push(o.Column.fromFloat32Array(`${e+1}`,new Float32Array(s).fill(0)));return o.DataFrame.fromColumns(t)}const l=c<r?r-c:0,h=Math.min(r,c);let d;if(c>W)d=yield G(0,e,h);else{const t=yield async function(t,e,r){return new Promise(((t,o)=>{const i=new Worker(new URL(n.p+n.u(860),n.b));i.postMessage(U(EDA.principalComponentAnalysis.arguments,[e,r,1,0])),i.onmessage=function(e){i.terminate(),0===e.data.callResult?t(k(EDA.principalComponentAnalysis,e.data)):t(-1)}}))}(0,e,h);d=-1!==t?Q(t,i,a):yield G(0,e,h)}if(void 0===d)throw new Error("Failed to compute PCA");d=Q(d,i,a);const f=d.columns,p=f.length;for(let t=0;t<l;++t)f.add(o.Column.fromFloat32Array(`${p+t+1}`,new Float32Array(s).fill(0)));return d}))}(e,r,i,a,s);if(function(t,e){for(const t of e.toList())t.name="PC"+t.name}(0,u.columns),null===e.id)t.shell.addTableView(u);else{const t=e.columns;for(const e of u.columns)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"}`)}}))}function Jr(e,n,r,i){return zr(this,void 0,void 0,(function*(){const a=e.dataFrame;if(null===a)return;const s=yield Xr(a,e,n,r,i);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 o.ScatterPlotViewer&&u.includes(t.props.xColumnName)&&u.includes(t.props.yColumnName))return void(t.props.colorColumnName=s.name)}))}function Zr(t,e){const n=t.stats.max-t.stats.min;return{entries:t.toList(),options:{range:n}}}function to(t,e){return{entries:t.toList(),options:{}}}function eo(){return zr(this,void 0,void 0,(function*(){const r=new vr,i=e.dialog("Dimensionality reduction").add(r.getEditor()).onOK((()=>zr(this,void 0,void 0,(function*(){const i=r.getParams();0!==i.columns.length&&(yield async function(r,i,a,s,u,c,l,h=!0,d=!1,f={preprocessingFuncArgs:[]},p={},m=null,g={},y){const v={showXAxis:!1,showYAxis:!1,showXSelector:!1,showYSelector:!1};if(i.length!==s.length||i.length!==c.length||i.length!==u.length||i.length!==f.preprocessingFuncArgs.length)throw new Error("columns, metrics and preprocessing functions, weights and function argumentsmust have the same length");const w=h?p.tableView??t.shell.tableView(r.name)??t.shell.addTableView(r):null,b=async()=>{const b=o.TaskBarProgressIndicator.create(`Initializing ${p.scatterPlotName??"dimensionality reduction"} ...`);let E;try{const A=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(A[0])?(u=r.columns.byName(A[0]),c=r.columns.byName(A[1])):(u=r.columns.add(o.Column.float(A[0],r.rowCount)),c=r.columns.add(o.Column.float(A[1],r.rowCount)),h&&!E&&(E=w.scatterPlot({...v,x:A[0],y:A[1],title:p.scatterPlotName??_r(i,a)}))),p[In]&&(E?.root&&e.setUpdateIndicator(E.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 _(){r.columns.add(o.Column.float(A[0],r.rowCount)),r.columns.add(o.Column.float(A[1],r.rowCount));let d=null;h&&(E=w.scatterPlot({...v,x:A[0],y:A[1],title:p.scatterPlotName??_r(i,a)}),e.setUpdateIndicator(E.root,!0));const m=t.events.onViewerClosed.subscribe((e=>{const n=e.args.viewer;n?.getOptions()?.look?.title&&E?.getOptions()?.look?.title&&n?.getOptions()?.look?.title===E?.getOptions()?.look?.title&&(t.events.fireCustomEvent(Ar,{}),m.unsubscribe(),d?.(),b.close())})),g=new Promise((async(e,o)=>{try{d=e;const o=[];let h=s,m=u,g=l;if(y&&i.every((t=>t.isNumerical))){const t=i.map((t=>t.toList())),e=new Array(r.rowCount).fill(0).map(((t,e)=>new Float32Array(i.length)));for(let n=0;n<i.length;++n)for(let o=0;o<r.rowCount;++o)e[o][n]=t[n][o];f.distanceFnArgs=[{}],o.push({entries:e,options:{}}),h=[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]:i[t],[r]:s[t],...f.preprocessingFuncArgs[t]??{}});o.push({entries:a,options:u}),f.distanceFnArgs.push(u)}else{const e=i[t].toList(),n={};o.push({entries:e,options:n}),f.distanceFnArgs.push(n)}}e(await async function(e,r,o,i,a,s,u){let c=await async function(e,r,o,i,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!==i.length)throw new Error("data, metrics and options and weights must have the same length");return new Promise((function(c,l){const h=new Worker(new URL(n.p+n.u(234),n.b));h.postMessage({columnsData:e,distanceMetrics:r,method:o,options:s,weights:i,aggregationMethod:a});const d=t.events.onCustomEvent(Ar).subscribe((()=>{try{h?.terminate()}finally{d.unsubscribe()}}));h.onmessage=({data:{error:t,embedding:e,epochNum:n,epochsLength:r}})=>{Cr(n)||Cr(r)?(d.unsubscribe(),t?l(t):c(e),setTimeout((()=>h.terminate()),100)):u&&u(n,r,e)}}))}(e,o,r,i,a,s,u);return c=c.map((t=>function(t){const e=t.length;let n=0,r=0;for(let o=0;o<e;++o)n+=t[o],r+=Math.pow(t[o],2);const o=n/e,i=1/Math.sqrt(r/e-Math.pow(o,2));for(let n=0;n<e;++n)t[n]=(t[n]-o)*i;return t}(t))),c}(o.map((t=>t.entries)),a,h,m,l,f,p[Nn]?void 0:C))}catch(t){o(t)}})),_=await g;return b.close(),m.unsubscribe(),_}const S=await _();if(d&&S){const N=o.TaskBarProgressIndicator.create("Clustering embeddings ...");try{const I=await hn(S[0],S[1],f.dbScanEpsilon??.01,f.dbScanMinPts??4),M=r.columns.getUnusedName("Cluster (DBSCAN)");r.columns.addNewString(M).init((t=>I[t].toString())),E&&(E.props.colorColumnName=M)}catch(T){t.shell.error("Clustering embeddings failed"),console.error(T)}finally{N.close()}}if(S){const O=r.columns.byName(A[0]),L=r.columns.byName(A[1]);if(O.init((t=>S[0][t])),L.init((t=>S[1][t])),m)try{const P=m.inputs[0].name,x=m.inputs[1].name;await m.prepare({[P]:O,[x]:L,...g}).call(!0)}catch(R){t.shell.error("Post-processing failed"),console.error(R)}if(E)return e.setUpdateIndicator(E.root,!1),E.helpUrl="/help/compute/sequence-space",E}}catch(F){t.shell.error("Dimensionality reduction failed"),console.error(F),b.close(),E&&e.setUpdateIndicator(E.root,!1)}};return new Promise((async(t,n)=>{try{if(p.fastRowCount&&r.rowCount>p.fastRowCount&&!p[Nn])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)}}))}(i.table,i.columns,i.methodName,i.distanceMetrics,i.weights,i.preprocessingFunctions,i.aggreaggregationMethod,!!i.plotEmbeddings,!!i.clusterEmbeddings,i.options,{fastRowCount:1e4},i.postProcessingFunction,i.postProcessingFunctionArgs,i.vectorDistanceMetric))})))).show();i.helpUrl="https://datagrok.ai/help/explore/dim-reduction.md";const a=()=>{const t=r.columnsInput.value,e=i.getButton("OK");e&&(t&&0!==t.length?e.classList.remove("disabled"):e.classList.add("disabled"))};i.history((()=>({editorSettings:r.getStringInput()})),(t=>r.applyStringInput(t.editorSettings))),r.onColumnsChanged.subscribe((()=>{try{a()}catch(t){console.error(t)}})),a()}))}function no(n){try{const t=new Ir;e.dialog("Markov clustering").add(t.getEditor()).onOK((()=>zr(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}`),Yr.logger.error(n,void 0,r)}}function ro(e,n,r,o,i,a,s){return zr(this,arguments,void 0,(function*(e,n,r,o,i,a,s,u=80,c=10,l=!1,h=0,d=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:o,aggregationMethod:i,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:h,minClusterSize:null!=d?d:5});return p.addViewer("MCL",{mclProps:m})}))}function oo(){return new Tr}function io(t,e,n,r,o){return zr(this,void 0,void 0,(function*(){return yield De({table:t,features:e,predict:n,components:r,isQuadratic:!1,names:o})}))}function ao(){return zr(this,void 0,void 0,(function*(){yield Ue(ge.COMPUTE_COMPONENTS)}))}function so(){return zr(this,void 0,void 0,(function*(){yield Ue(ge.PERFORM_MVA)}))}function uo(){return zr(this,void 0,void 0,(function*(){yield function(){return xe(this,void 0,void 0,(function*(){t.shell.addTableView(o.DataFrame.fromColumns([o.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"]),o.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])),o.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])),o.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])),o.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])),o.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])),o.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])),o.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])),o.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])),o.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])),o.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])),o.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])),o.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])),o.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])),o.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])),o.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])),o.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(Oe)),t.shell.windows.showContextPanel=!1,t.shell.windows.showProperties=!1,yield Ue(ge.DEMO)}))}()}))}function co(t,e,n){return zr(this,void 0,void 0,(function*(){return he(yield ce({gamma:n,kernel:tt},t,e))}))}function lo(t,e){return zr(this,void 0,void 0,(function*(){return yield fe(t,e)}))}function ho(t,e){return zr(this,void 0,void 0,(function*(){return pe(t,e)}))}function fo(t,e){return zr(this,void 0,void 0,(function*(){return me(t)}))}function po(t,e,n,r){return zr(this,void 0,void 0,(function*(){return le(0,r)}))}function mo(t,e,n,r){return zr(this,void 0,void 0,(function*(){return he(yield ce({gamma:n,kernel:nt,sigma:r},t,e))}))}function go(t,e){return zr(this,void 0,void 0,(function*(){return yield fe(t,e)}))}function yo(t,e){return zr(this,void 0,void 0,(function*(){return pe(t,e)}))}function vo(t,e){return zr(this,void 0,void 0,(function*(){return me(t)}))}function wo(t,e,n,r){return zr(this,void 0,void 0,(function*(){return le(0,r)}))}function bo(t,e,n,r,o){return zr(this,void 0,void 0,(function*(){return he(yield ce({gamma:n,kernel:et,cParam:r,dParam:o},t,e))}))}function Eo(t,e){return zr(this,void 0,void 0,(function*(){return yield fe(t,e)}))}function Ao(t,e){return zr(this,void 0,void 0,(function*(){return pe(t,e)}))}function Co(t,e){return zr(this,void 0,void 0,(function*(){return me(t)}))}function _o(t,e,n,r){return zr(this,void 0,void 0,(function*(){return le(0,r)}))}function So(t,e,n,r,o){return zr(this,void 0,void 0,(function*(){return he(yield ce({gamma:n,kernel:rt,kappa:r,theta:o},t,e))}))}function No(t,e){return zr(this,void 0,void 0,(function*(){return yield fe(t,e)}))}function Io(t,e){return zr(this,void 0,void 0,(function*(){return pe(t,e)}))}function Mo(t,e){return zr(this,void 0,void 0,(function*(){return me(t)}))}function To(t,e,n,r){return zr(this,void 0,void 0,(function*(){return le(0,r)}))}function Oo(){cn()}function Lo(){Nr()}function Po(t){return zr(this,void 0,void 0,(function*(){yield Nr(t)}))}function xo(t,e){return zr(this,void 0,void 0,(function*(){const n=t.columns,r=yield function(t,e){return Or(this,void 0,void 0,(function*(){const n=t.length,r=e.length,i=e.stats.avg,a=e.stats.stdev,s=new Float32Array(n+1).fill(0);if(s[n]=i,0===a||1===r)return s;try{const r=[],u=[],c=new Float32Array(n),l=new Float32Array(n);let h=0,d=0;for(const e of t){const t=e.stats;t.stdev>0&&(r.push(h),u.push(e),c[d]=t.avg,l[d]=t.stdev,++d),++h}if(0===d)return s;const f=function(t,e,n,r,o,i,a){return g(EDA,"fitLinearRegressionParamsWithDataNormalizing",[t,e,n,r,o,i,a])}(o.DataFrame.fromColumns(u).columns,o.Column.fromFloat32Array("xAvgs",c,d),o.Column.fromFloat32Array("xStdevs",l,d),e,i,a,d+1).getRawData();for(let t=0;t<d;++t)s[r[t]]=f[t];s[n]=f[d]}catch(r){const i=yield function(t,e,n){return Or(this,void 0,void 0,(function*(){return(yield De({table:o.DataFrame.fromColumns([e]),features:t,predict:e,components:n,names:void 0,isQuadratic:!1})).regressionCoefficients.getRawData()}))}(t,e,Pr(t.length,e.length));let a=0;for(let e=0;e<n;++e)s[e]=i[e],a+=i[e]*t.byIndex(e).stats.avg;s[n]-=a}return s}))}(n,e);return new Uint8Array(r.buffer)}))}function Ro(t,e){const n=t.columns,r=new Float32Array(e.buffer);return o.DataFrame.fromColumns([Lr(n,r)])}function Fo(t,e){for(const e of t.columns)if(!e.matches("numerical"))return!1;return e.matches("numerical")}function Do(t,e){return t.rowCount<=1e5}function Uo(t,e,n,r,o,i){return zr(this,void 0,void 0,(function*(){const a=t.columns,s=new Gr({classesCount:e.categories.length,featuresCount:a.length});return yield s.fit(a,e,n,r,o,i),s.toBytes()}))}function ko(t,e){const n=t.columns,r=new Gr(void 0,e);return o.DataFrame.fromColumns([r.predict(n)])}function Go(t,e){return Gr.isApplicable(t.columns,e)}function Bo(t,e){return Gr.isInteractive(t.columns,e)}function Vo(t,e,n){return zr(this,void 0,void 0,(function*(){const r=t.columns,o=new Rr;return yield o.fit(r,e,Math.min(n,r.length)),o.toBytes()}))}function Wo(t,e){const n=new Rr(e);return o.DataFrame.fromColumns([n.predict(t.columns)])}function Ho(t,e){return Rr.isApplicable(t.columns,e)}function jo(t,e,n,r){return zr(this,void 0,void 0,(function*(){return new Rr(r).viewers().map((t=>t.root))}))}function qo(t,e){return Rr.isInteractive(t.columns,e)}function zo(t,e,n,r,o,i,a){return zr(this,void 0,void 0,(function*(){const s=t.columns,u=new qr;return yield u.fit(s,e,n,r,o,i,a),u.toBytes()}))}function Yo(t,e){const n=new qr(e);return o.DataFrame.fromColumns([n.predict(t.columns)])}function $o(t,e){return qr.isInteractive(t.columns,e)}function Ko(t,e){return qr.isApplicable(t.columns,e)}})(),eda=r})();
2
2
  //# sourceMappingURL=package.js.map