@datagrok/eda 1.4.13 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -5
- package/dist/111.js +1 -1
- package/dist/111.js.map +1 -1
- package/dist/128.js +1 -1
- package/dist/128.js.map +1 -1
- package/dist/153.js +1 -1
- package/dist/153.js.map +1 -1
- package/dist/23.js +1 -1
- package/dist/23.js.map +1 -1
- package/dist/234.js +1 -1
- package/dist/234.js.map +1 -1
- package/dist/242.js +1 -1
- package/dist/242.js.map +1 -1
- package/dist/260.js +1 -1
- package/dist/260.js.map +1 -1
- package/dist/33.js +1 -1
- package/dist/33.js.map +1 -1
- package/dist/348.js +1 -1
- package/dist/348.js.map +1 -1
- package/dist/377.js +1 -1
- package/dist/377.js.map +1 -1
- package/dist/397.js +2 -0
- package/dist/397.js.map +1 -0
- package/dist/412.js +1 -1
- package/dist/412.js.map +1 -1
- package/dist/415.js +1 -1
- package/dist/415.js.map +1 -1
- package/dist/501.js +1 -1
- package/dist/501.js.map +1 -1
- package/dist/531.js +1 -1
- package/dist/531.js.map +1 -1
- package/dist/583.js +1 -1
- package/dist/583.js.map +1 -1
- package/dist/589.js +1 -1
- package/dist/589.js.map +1 -1
- package/dist/603.js +1 -1
- package/dist/603.js.map +1 -1
- package/dist/656.js +1 -1
- package/dist/656.js.map +1 -1
- package/dist/682.js +1 -1
- package/dist/682.js.map +1 -1
- package/dist/705.js +1 -1
- package/dist/705.js.map +1 -1
- package/dist/727.js +1 -1
- package/dist/727.js.map +1 -1
- package/dist/731.js +1 -1
- package/dist/731.js.map +1 -1
- package/dist/738.js +1 -1
- package/dist/738.js.map +1 -1
- package/dist/763.js +1 -1
- package/dist/763.js.map +1 -1
- package/dist/778.js +1 -1
- package/dist/778.js.map +1 -1
- package/dist/783.js +1 -1
- package/dist/783.js.map +1 -1
- package/dist/793.js +1 -1
- package/dist/793.js.map +1 -1
- package/dist/810.js +1 -1
- package/dist/810.js.map +1 -1
- package/dist/860.js +1 -1
- package/dist/860.js.map +1 -1
- package/dist/907.js +1 -1
- package/dist/907.js.map +1 -1
- package/dist/950.js +1 -1
- package/dist/950.js.map +1 -1
- package/dist/980.js +1 -1
- package/dist/980.js.map +1 -1
- package/dist/990.js +1 -1
- package/dist/990.js.map +1 -1
- package/dist/package-test.js +1 -1
- package/dist/package-test.js.map +1 -1
- package/dist/package.js +1 -1
- package/dist/package.js.map +1 -1
- package/package.json +5 -5
- package/src/package.ts +2 -1
- package/src/pareto-optimization/pareto-optimizer.ts +1 -1
- package/src/pls/pls-constants.ts +8 -1
- package/src/pls/pls-tools.ts +176 -74
- package/src/probabilistic-scoring/data-generator.ts +48 -3
- package/src/probabilistic-scoring/pmpo-defs.ts +30 -2
- package/src/probabilistic-scoring/pmpo-utils.ts +143 -52
- package/src/probabilistic-scoring/prob-scoring.ts +477 -104
- package/src/probabilistic-scoring/stat-tools.ts +1 -1
- package/src/tests/pareto-tests.ts +13 -15
- package/src/tests/pmpo-tests.ts +643 -3
- package/test-console-output-1.log +224 -86
- package/test-record-1.mp4 +0 -0
package/dist/package-test.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var eda_test;(()=>{var t={517:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Solarize=void 0,e.Solarize=function(t){const e=t.data,n=t.width,r=4*n;let i=t.height;do{const t=(i-1)*r;let o=n;do{const n=t+4*(o-1);let r=e[n],i=e[n+1],a=e[n+2];r>127&&(r=255-r),i>127&&(i=255-i),a>127&&(a=255-a),e[n]=r,e[n+1]=i,e[n+2]=a}while(--o)}while(--i)}},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}},661:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Threshold=void 0;const r=n(4892),i=n(6536),o=n(5483);e.Threshold=function(t){const e=255*this.threshold(),n=t.data,r=n.length;for(let t=0;t<r;t+=1)n[t]=n[t]<e?0:255},r.Factory.addGetterSetter(i.Node,"threshold",.5,(0,o.getNumberValidator)(),r.Factory.afterSetFilter)},680:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Konva=void 0;const r=n(8871),i=n(4060),o=n(6536),a=n(4473),s=n(7324),l=n(6267),c=n(7457),h=n(7949),u=n(1268),d=n(4723),f=n(9696),g=n(8665),p=n(9869),m=n(8604);e.Konva=i.Util._assign(r.Konva,{Util:i.Util,Transform:i.Transform,Node:o.Node,Container:a.Container,Stage:s.Stage,stages:s.stages,Layer:l.Layer,FastLayer:c.FastLayer,Group:h.Group,DD:u.DD,Shape:d.Shape,shapes:d.shapes,Animation:f.Animation,Tween:g.Tween,Easings:g.Easings,Context:p.Context,Canvas:m.Canvas}),e.default=e.Konva},944:(t,e)=>{"use strict";e.Vb=void 0,e.Vb=function(t,e,n){var r=function(t,e,n){if(0===t.length||0===e.length)return 0;if(n&&!n.caseSensitive&&(t=t.toUpperCase(),e=e.toUpperCase()),t===e)return 1;for(var r=0,i=t.length,o=e.length,a=Math.floor(Math.max(i,o)/2)-1,s=new Array(i),l=new Array(o),c=0;c<i;c++)for(var h=Math.max(0,c-a);h<=Math.min(o,c+a+1);h++)if(!s[c]&&!l[h]&&t[c]===e[h]){++r,s[c]=l[h]=!0;break}if(0===r)return 0;var u=0,d=0;for(c=0;c<i;c++)if(s[c]){for(;!l[d];)d++;t.charAt(c)!==e.charAt(d++)&&u++}return(r/i+r/o+(r-(u/=2))/r)/3}(t,e,n),i=0;if(r>.7){for(var o=Math.min(t.length,e.length),a=0;t[a]===e[a]&&a<4&&a<o;)++i,a++;r+=.1*i*(1-r)}return r}},983:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Emboss=void 0;const r=n(4892),i=n(6536),o=n(4060),a=n(5483);e.Emboss=function(t){const e=10*this.embossStrength(),n=255*this.embossWhiteLevel(),r=this.embossDirection(),i=this.embossBlend(),a=t.data,s=t.width,l=t.height,c=4*s;let h=0,u=0,d=l;switch(r){case"top-left":h=-1,u=-1;break;case"top":h=-1,u=0;break;case"top-right":h=-1,u=1;break;case"right":h=0,u=1;break;case"bottom-right":h=1,u=1;break;case"bottom":h=1,u=0;break;case"bottom-left":h=1,u=-1;break;case"left":h=0,u=-1;break;default:o.Util.error("Unknown emboss direction: "+r)}do{const t=(d-1)*c;let r=h;d+r<1&&(r=0),d+r>l&&(r=0);const o=(d-1+r)*s*4;let f=s;do{const r=t+4*(f-1);let l=u;f+l<1&&(l=0),f+l>s&&(l=0);const c=o+4*(f-1+l),h=a[r]-a[c],d=a[r+1]-a[c+1],g=a[r+2]-a[c+2];let p=h;const m=p>0?p:-p;if((d>0?d:-d)>m&&(p=d),(g>0?g:-g)>m&&(p=g),p*=e,i){const t=a[r]+p,e=a[r+1]+p,n=a[r+2]+p;a[r]=t>255?255:t<0?0:t,a[r+1]=e>255?255:e<0?0:e,a[r+2]=n>255?255:n<0?0:n}else{let t=n-p;t<0?t=0:t>255&&(t=255),a[r]=a[r+1]=a[r+2]=t}}while(--f)}while(--d)},r.Factory.addGetterSetter(i.Node,"embossStrength",.5,(0,a.getNumberValidator)(),r.Factory.afterSetFilter),r.Factory.addGetterSetter(i.Node,"embossWhiteLevel",.5,(0,a.getNumberValidator)(),r.Factory.afterSetFilter),r.Factory.addGetterSetter(i.Node,"embossDirection","top-left",void 0,r.Factory.afterSetFilter),r.Factory.addGetterSetter(i.Node,"embossBlend",!1,void 0,r.Factory.afterSetFilter)},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))}}},1268:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.DD=void 0;const r=n(8871),i=n(4060);e.DD={get isDragging(){let t=!1;return e.DD._dragElements.forEach(e=>{"dragging"===e.dragStatus&&(t=!0)}),t},justDragged:!1,get node(){let t;return e.DD._dragElements.forEach(e=>{t=e.node}),t},_dragElements:new Map,_drag(t){const n=[];e.DD._dragElements.forEach((e,r)=>{const{node:o}=e,a=o.getStage();a.setPointersPositions(t),void 0===e.pointerId&&(e.pointerId=i.Util._getFirstPointerId(t));const s=a._changedPointerPositions.find(t=>t.id===e.pointerId);if(s){if("dragging"!==e.dragStatus){const n=o.dragDistance();if(Math.max(Math.abs(s.x-e.startPointerPos.x),Math.abs(s.y-e.startPointerPos.y))<n)return;if(o.startDrag({evt:t}),!o.isDragging())return}o._setDragPosition(t,e),n.push(o)}}),n.forEach(e=>{e.fire("dragmove",{type:"dragmove",target:e,evt:t},!0)})},_endDragBefore(t){const n=[];e.DD._dragElements.forEach(i=>{const{node:o}=i,a=o.getStage();if(t&&a.setPointersPositions(t),!a._changedPointerPositions.find(t=>t.id===i.pointerId))return;"dragging"!==i.dragStatus&&"stopped"!==i.dragStatus||(e.DD.justDragged=!0,r.Konva._mouseListenClick=!1,r.Konva._touchListenClick=!1,r.Konva._pointerListenClick=!1,i.dragStatus="stopped");const s=i.node.getLayer()||i.node instanceof r.Konva.Stage&&i.node;s&&-1===n.indexOf(s)&&n.push(s)}),n.forEach(t=>{t.draw()})},_endDragAfter(t){e.DD._dragElements.forEach((n,r)=>{"stopped"===n.dragStatus&&n.node.fire("dragend",{type:"dragend",target:n.node,evt:t},!0),"dragging"!==n.dragStatus&&e.DD._dragElements.delete(r)})}},r.Konva.isBrowser&&(window.addEventListener("mouseup",e.DD._endDragBefore,!0),window.addEventListener("touchend",e.DD._endDragBefore,!0),window.addEventListener("touchcancel",e.DD._endDragBefore,!0),window.addEventListener("mousemove",e.DD._drag),window.addEventListener("touchmove",e.DD._drag),window.addEventListener("mouseup",e.DD._endDragAfter,!1),window.addEventListener("touchend",e.DD._endDragAfter,!1),window.addEventListener("touchcancel",e.DD._endDragAfter,!1))},1354:t=>{"use strict";t.exports=function(t){var e=t[1],n=t[3];if(!n)return e;if("function"==typeof btoa){var r=btoa(unescape(encodeURIComponent(JSON.stringify(n)))),i="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(r),o="/*# ".concat(i," */");return[e].concat([o]).join("\n")}return[e].join("\n")}},1486:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Path=void 0;const r=n(4892),i=n(8871),o=n(4723),a=n(5570);class s extends o.Shape{constructor(t){super(t),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute()})}_readDataAttribute(){this.dataArray=s.parsePathData(this.data()),this.pathLength=s.getPathLength(this.dataArray)}_sceneFunc(t){const e=this.dataArray;t.beginPath();let n=!1;for(let r=0;r<e.length;r++){const i=e[r].command,o=e[r].points;switch(i){case"L":t.lineTo(o[0],o[1]);break;case"M":t.moveTo(o[0],o[1]);break;case"C":t.bezierCurveTo(o[0],o[1],o[2],o[3],o[4],o[5]);break;case"Q":t.quadraticCurveTo(o[0],o[1],o[2],o[3]);break;case"A":const e=o[0],r=o[1],i=o[2],a=o[3],s=o[4],l=o[5],c=o[6],h=o[7],u=i>a?i:a,d=i>a?1:i/a,f=i>a?a/i:1;t.translate(e,r),t.rotate(c),t.scale(d,f),t.arc(0,0,u,s,s+l,1-h),t.scale(1/d,1/f),t.rotate(-c),t.translate(-e,-r);break;case"z":n=!0,t.closePath()}}n||this.hasFill()?t.fillStrokeShape(this):t.strokeShape(this)}getSelfRect(){let t=[];this.dataArray.forEach(function(e){if("A"===e.command){const n=e.points[4],r=e.points[5],i=e.points[4]+r;let o=Math.PI/180;if(Math.abs(n-i)<o&&(o=Math.abs(n-i)),r<0)for(let r=n-o;r>i;r-=o){const n=s.getPointOnEllipticalArc(e.points[0],e.points[1],e.points[2],e.points[3],r,0);t.push(n.x,n.y)}else for(let r=n+o;r<i;r+=o){const n=s.getPointOnEllipticalArc(e.points[0],e.points[1],e.points[2],e.points[3],r,0);t.push(n.x,n.y)}}else if("C"===e.command)for(let n=0;n<=1;n+=.01){const r=s.getPointOnCubicBezier(n,e.start.x,e.start.y,e.points[0],e.points[1],e.points[2],e.points[3],e.points[4],e.points[5]);t.push(r.x,r.y)}else t=t.concat(e.points)});let e,n,r=t[0],i=t[0],o=t[1],a=t[1];for(let s=0;s<t.length/2;s++)e=t[2*s],n=t[2*s+1],isNaN(e)||(r=Math.min(r,e),i=Math.max(i,e)),isNaN(n)||(o=Math.min(o,n),a=Math.max(a,n));return{x:r,y:o,width:i-r,height:a-o}}getLength(){return this.pathLength}getPointAtLength(t){return s.getPointAtLengthOfDataArray(t,this.dataArray)}static getLineLength(t,e,n,r){return Math.sqrt((n-t)*(n-t)+(r-e)*(r-e))}static getPathLength(t){let e=0;for(let n=0;n<t.length;++n)e+=t[n].pathLength;return e}static getPointAtLengthOfDataArray(t,e){let n,r=0,i=e.length;if(!i)return null;for(;r<i&&t>e[r].pathLength;)t-=e[r].pathLength,++r;if(r===i)return n=e[r-1].points.slice(-2),{x:n[0],y:n[1]};if(t<.01)return"M"===e[r].command?(n=e[r].points.slice(0,2),{x:n[0],y:n[1]}):{x:e[r].start.x,y:e[r].start.y};const o=e[r],l=o.points;switch(o.command){case"L":return s.getPointOnLine(t,o.start.x,o.start.y,l[0],l[1]);case"C":return s.getPointOnCubicBezier((0,a.t2length)(t,s.getPathLength(e),t=>(0,a.getCubicArcLength)([o.start.x,l[0],l[2],l[4]],[o.start.y,l[1],l[3],l[5]],t)),o.start.x,o.start.y,l[0],l[1],l[2],l[3],l[4],l[5]);case"Q":return s.getPointOnQuadraticBezier((0,a.t2length)(t,s.getPathLength(e),t=>(0,a.getQuadraticArcLength)([o.start.x,l[0],l[2]],[o.start.y,l[1],l[3]],t)),o.start.x,o.start.y,l[0],l[1],l[2],l[3]);case"A":const n=l[0],r=l[1],i=l[2],c=l[3],h=l[5],u=l[6];let d=l[4];return d+=h*t/o.pathLength,s.getPointOnEllipticalArc(n,r,i,c,d,u)}return null}static getPointOnLine(t,e,n,r,i,o,a){o=null!=o?o:e,a=null!=a?a:n;const s=this.getLineLength(e,n,r,i);if(s<1e-10)return{x:e,y:n};if(r===e)return{x:o,y:a+(i>n?t:-t)};const l=(i-n)/(r-e),c=Math.sqrt(t*t/(1+l*l))*(r<e?-1:1),h=l*c;if(Math.abs(a-n-l*(o-e))<1e-10)return{x:o+c,y:a+h};const u=((o-e)*(r-e)+(a-n)*(i-n))/(s*s),d=e+u*(r-e),f=n+u*(i-n),g=this.getLineLength(o,a,d,f),p=Math.sqrt(t*t-g*g),m=Math.sqrt(p*p/(1+l*l))*(r<e?-1:1);return{x:d+m,y:f+l*m}}static getPointOnCubicBezier(t,e,n,r,i,o,a,s,l){function c(t){return t*t*t}function h(t){return 3*t*t*(1-t)}function u(t){return 3*t*(1-t)*(1-t)}function d(t){return(1-t)*(1-t)*(1-t)}return{x:s*c(t)+o*h(t)+r*u(t)+e*d(t),y:l*c(t)+a*h(t)+i*u(t)+n*d(t)}}static getPointOnQuadraticBezier(t,e,n,r,i,o,a){function s(t){return t*t}function l(t){return 2*t*(1-t)}function c(t){return(1-t)*(1-t)}return{x:o*s(t)+r*l(t)+e*c(t),y:a*s(t)+i*l(t)+n*c(t)}}static getPointOnEllipticalArc(t,e,n,r,i,o){const a=Math.cos(o),s=Math.sin(o),l=n*Math.cos(i),c=r*Math.sin(i);return{x:t+(l*a-c*s),y:e+(l*s+c*a)}}static parsePathData(t){if(!t)return[];let e=t;const n=["m","M","l","L","v","V","h","H","z","Z","c","C","q","Q","t","T","s","S","a","A"];e=e.replace(new RegExp(" ","g"),",");for(let t=0;t<n.length;t++)e=e.replace(new RegExp(n[t],"g"),"|"+n[t]);const r=e.split("|"),i=[],o=[];let a=0,s=0;const l=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;let c;for(let t=1;t<r.length;t++){let e=r[t],n=e.charAt(0);for(e=e.slice(1),o.length=0;c=l.exec(e);)o.push(c[0]);const h=[];for(let t=0,e=o.length;t<e;t++){if("00"===o[t]){h.push(0,0);continue}const e=parseFloat(o[t]);isNaN(e)?h.push(0):h.push(e)}for(;h.length>0&&!isNaN(h[0]);){let t="",e=[];const r=a,o=s;let l,c,u,d,f,g,p,m,y,v;switch(n){case"l":a+=h.shift(),s+=h.shift(),t="L",e.push(a,s);break;case"L":a=h.shift(),s=h.shift(),e.push(a,s);break;case"m":const r=h.shift(),o=h.shift();if(a+=r,s+=o,t="M",i.length>2&&"z"===i[i.length-1].command)for(let t=i.length-2;t>=0;t--)if("M"===i[t].command){a=i[t].points[0]+r,s=i[t].points[1]+o;break}e.push(a,s),n="l";break;case"M":a=h.shift(),s=h.shift(),t="M",e.push(a,s),n="L";break;case"h":a+=h.shift(),t="L",e.push(a,s);break;case"H":a=h.shift(),t="L",e.push(a,s);break;case"v":s+=h.shift(),t="L",e.push(a,s);break;case"V":s=h.shift(),t="L",e.push(a,s);break;case"C":e.push(h.shift(),h.shift(),h.shift(),h.shift()),a=h.shift(),s=h.shift(),e.push(a,s);break;case"c":e.push(a+h.shift(),s+h.shift(),a+h.shift(),s+h.shift()),a+=h.shift(),s+=h.shift(),t="C",e.push(a,s);break;case"S":c=a,u=s,l=i[i.length-1],"C"===l.command&&(c=a+(a-l.points[2]),u=s+(s-l.points[3])),e.push(c,u,h.shift(),h.shift()),a=h.shift(),s=h.shift(),t="C",e.push(a,s);break;case"s":c=a,u=s,l=i[i.length-1],"C"===l.command&&(c=a+(a-l.points[2]),u=s+(s-l.points[3])),e.push(c,u,a+h.shift(),s+h.shift()),a+=h.shift(),s+=h.shift(),t="C",e.push(a,s);break;case"Q":e.push(h.shift(),h.shift()),a=h.shift(),s=h.shift(),e.push(a,s);break;case"q":e.push(a+h.shift(),s+h.shift()),a+=h.shift(),s+=h.shift(),t="Q",e.push(a,s);break;case"T":c=a,u=s,l=i[i.length-1],"Q"===l.command&&(c=a+(a-l.points[0]),u=s+(s-l.points[1])),a=h.shift(),s=h.shift(),t="Q",e.push(c,u,a,s);break;case"t":c=a,u=s,l=i[i.length-1],"Q"===l.command&&(c=a+(a-l.points[0]),u=s+(s-l.points[1])),a+=h.shift(),s+=h.shift(),t="Q",e.push(c,u,a,s);break;case"A":d=h.shift(),f=h.shift(),g=h.shift(),p=h.shift(),m=h.shift(),y=a,v=s,a=h.shift(),s=h.shift(),t="A",e=this.convertEndpointToCenterParameterization(y,v,a,s,p,m,d,f,g);break;case"a":d=h.shift(),f=h.shift(),g=h.shift(),p=h.shift(),m=h.shift(),y=a,v=s,a+=h.shift(),s+=h.shift(),t="A",e=this.convertEndpointToCenterParameterization(y,v,a,s,p,m,d,f,g)}i.push({command:t||n,points:e,start:{x:r,y:o},pathLength:this.calcLength(r,o,t||n,e)})}"z"!==n&&"Z"!==n||i.push({command:"z",points:[],start:void 0,pathLength:0})}return i}static calcLength(t,e,n,r){let i,o,l,c;const h=s;switch(n){case"L":return h.getLineLength(t,e,r[0],r[1]);case"C":return(0,a.getCubicArcLength)([t,r[0],r[2],r[4]],[e,r[1],r[3],r[5]],1);case"Q":return(0,a.getQuadraticArcLength)([t,r[0],r[2]],[e,r[1],r[3]],1);case"A":i=0;const n=r[4],s=r[5],u=r[4]+s;let d=Math.PI/180;if(Math.abs(n-u)<d&&(d=Math.abs(n-u)),o=h.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],n,0),s<0)for(c=n-d;c>u;c-=d)l=h.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],c,0),i+=h.getLineLength(o.x,o.y,l.x,l.y),o=l;else for(c=n+d;c<u;c+=d)l=h.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],c,0),i+=h.getLineLength(o.x,o.y,l.x,l.y),o=l;return l=h.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],u,0),i+=h.getLineLength(o.x,o.y,l.x,l.y),i}return 0}static convertEndpointToCenterParameterization(t,e,n,r,i,o,a,s,l){const c=l*(Math.PI/180),h=Math.cos(c)*(t-n)/2+Math.sin(c)*(e-r)/2,u=-1*Math.sin(c)*(t-n)/2+Math.cos(c)*(e-r)/2,d=h*h/(a*a)+u*u/(s*s);d>1&&(a*=Math.sqrt(d),s*=Math.sqrt(d));let f=Math.sqrt((a*a*(s*s)-a*a*(u*u)-s*s*(h*h))/(a*a*(u*u)+s*s*(h*h)));i===o&&(f*=-1),isNaN(f)&&(f=0);const g=f*a*u/s,p=f*-s*h/a,m=(t+n)/2+Math.cos(c)*g-Math.sin(c)*p,y=(e+r)/2+Math.sin(c)*g+Math.cos(c)*p,v=function(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])},_=function(t,e){return(t[0]*e[0]+t[1]*e[1])/(v(t)*v(e))},w=function(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(_(t,e))},b=w([1,0],[(h-g)/a,(u-p)/s]),C=[(h-g)/a,(u-p)/s],x=[(-1*h-g)/a,(-1*u-p)/s];let S=w(C,x);return _(C,x)<=-1&&(S=Math.PI),_(C,x)>=1&&(S=0),0===o&&S>0&&(S-=2*Math.PI),1===o&&S<0&&(S+=2*Math.PI),[m,y,a,s,b,S,c,o]}}e.Path=s,s.prototype.className="Path",s.prototype._attrsAffectingSize=["data"],(0,i._registerNode)(s),r.Factory.addGetterSetter(s,"data")},1958:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Text=void 0,e.stringToArray=c;const r=n(4060),i=n(4892),o=n(4723),a=n(8871),s=n(5483),l=n(8871);function c(t){return[...t].reduce((t,e,n,r)=>{if(/\p{Emoji}/u.test(e)){const i=r[n+1];i&&/\p{Emoji_Modifier}|\u200D/u.test(i)?(t.push(e+i),r[n+1]=""):t.push(e)}else/\p{Regional_Indicator}{2}/u.test(e+(r[n+1]||""))?t.push(e+r[n+1]):n>0&&/\p{Mn}|\p{Me}|\p{Mc}/u.test(e)?t[t.length-1]+=e:e&&t.push(e);return t},[])}const h="auto",u="inherit",d="justify",f="left",g="middle",p="normal",m=" ",y="none",v=["direction","fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],_=v.length;let w;function b(){return w||(w=r.Util.createCanvasElement().getContext("2d"),w)}class C extends o.Shape{constructor(t){super(function(t){return(t=t||{}).fillLinearGradientColorStops||t.fillRadialGradientColorStops||t.fillPatternImage||(t.fill=t.fill||"black"),t}(t)),this._partialTextX=0,this._partialTextY=0;for(let t=0;t<_;t++)this.on(v[t]+"Change.konva",this._setTextData);this._setTextData()}_sceneFunc(t){const e=this.textArr,n=e.length;if(!this.text())return;let r,i=this.padding(),o=this.fontSize(),s=this.lineHeight()*o,l=this.verticalAlign(),h=this.direction(),p=0,m=this.align(),y=this.getWidth(),v=this.letterSpacing(),_=this.fill(),w=this.textDecoration(),b=-1!==w.indexOf("underline"),C=-1!==w.indexOf("line-through");h=h===u?t.direction:h;let x=s/2,S=g;if(a.Konva._fixTextRendering){const t=this.measureSize("M");S="alphabetic",x=(t.fontBoundingBoxAscent-t.fontBoundingBoxDescent)/2+s/2}for("rtl"===h&&t.setAttr("direction",h),t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",S),t.setAttr("textAlign",f),l===g?p=(this.getHeight()-n*s-2*i)/2:"bottom"===l&&(p=this.getHeight()-n*s-2*i),t.translate(i,p+i),r=0;r<n;r++){let l=0,u=0;const f=e[r],g=f.text,p=f.width,w=f.lastInParagraph;if(t.save(),"right"===m?l+=y-p-2*i:"center"===m&&(l+=(y-p-2*i)/2),b){t.save(),t.beginPath();const e=l,n=x+u+(a.Konva._fixTextRendering?Math.round(o/4):Math.round(o/2));t.moveTo(e,n);const r=m!==d||w?p:y-2*i;t.lineTo(e+Math.round(r),n),t.lineWidth=o/15;const s=this._getLinearGradient();t.strokeStyle=s||_,t.stroke(),t.restore()}if(C){t.save(),t.beginPath();const e=a.Konva._fixTextRendering?-Math.round(o/4):0;t.moveTo(l,x+u+e);const n=m!==d||w?p:y-2*i;t.lineTo(l+Math.round(n),x+u+e),t.lineWidth=o/15;const r=this._getLinearGradient();t.strokeStyle=r||_,t.stroke(),t.restore()}if("rtl"===h||0===v&&m!==d)0!==v&&t.setAttr("letterSpacing",`${v}px`),this._partialTextX=l,this._partialTextY=x+u,this._partialText=g,t.fillStrokeShape(this);else{const e=g.split(" ").length-1,n=c(g);for(let r=0;r<n.length;r++){const o=n[r];" "!==o||w||m!==d||(l+=(y-2*i-p)/e),this._partialTextX=l,this._partialTextY=x+u,this._partialText=o,t.fillStrokeShape(this),l+=this.measureSize(o).width+v}}t.restore(),n>1&&(x+=s)}}_hitFunc(t){const e=this.getWidth(),n=this.getHeight();t.beginPath(),t.rect(0,0,e,n),t.closePath(),t.fillStrokeShape(this)}setText(t){const e=r.Util._isString(t)?t:null==t?"":t+"";return this._setAttr("text",e),this}getWidth(){return this.attrs.width===h||void 0===this.attrs.width?this.getTextWidth()+2*this.padding():this.attrs.width}getHeight(){return this.attrs.height===h||void 0===this.attrs.height?this.fontSize()*this.textArr.length*this.lineHeight()+2*this.padding():this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return r.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}measureSize(t){var e,n,r,i,o,a,s,l,c,h,u;let d,f=b(),g=this.fontSize();f.save(),f.font=this._getContextFont(),d=f.measureText(t),f.restore();const p=g/100;return{actualBoundingBoxAscent:null!==(e=d.actualBoundingBoxAscent)&&void 0!==e?e:71.58203125*p,actualBoundingBoxDescent:null!==(n=d.actualBoundingBoxDescent)&&void 0!==n?n:0,actualBoundingBoxLeft:null!==(r=d.actualBoundingBoxLeft)&&void 0!==r?r:-7.421875*p,actualBoundingBoxRight:null!==(i=d.actualBoundingBoxRight)&&void 0!==i?i:75.732421875*p,alphabeticBaseline:null!==(o=d.alphabeticBaseline)&&void 0!==o?o:0,emHeightAscent:null!==(a=d.emHeightAscent)&&void 0!==a?a:100*p,emHeightDescent:null!==(s=d.emHeightDescent)&&void 0!==s?s:-20*p,fontBoundingBoxAscent:null!==(l=d.fontBoundingBoxAscent)&&void 0!==l?l:91*p,fontBoundingBoxDescent:null!==(c=d.fontBoundingBoxDescent)&&void 0!==c?c:21*p,hangingBaseline:null!==(h=d.hangingBaseline)&&void 0!==h?h:72.80000305175781*p,ideographicBaseline:null!==(u=d.ideographicBaseline)&&void 0!==u?u:-21*p,width:d.width,height:g}}_getContextFont(){return this.fontStyle()+m+this.fontVariant()+m+(this.fontSize()+"px ")+this.fontFamily().split(",").map(t=>{const e=(t=t.trim()).indexOf(" ")>=0,n=t.indexOf('"')>=0||t.indexOf("'")>=0;return e&&!n&&(t=`"${t}"`),t}).join(", ")}_addTextLine(t){this.align()===d&&(t=t.trim());const e=this._getTextWidth(t);return this.textArr.push({text:t,width:e,lastInParagraph:!1})}_getTextWidth(t){const e=this.letterSpacing(),n=t.length;return b().measureText(t).width+e*n}_setTextData(){let t=this.text().split("\n"),e=+this.fontSize(),n=0,r=this.lineHeight()*e,i=this.attrs.width,o=this.attrs.height,a=i!==h&&void 0!==i,s=o!==h&&void 0!==o,l=this.padding(),u=i-2*l,d=o-2*l,f=0,g=this.wrap(),p="char"!==g&&g!==y,v=this.ellipsis();this.textArr=[],b().font=this._getContextFont();const _=v?this._getTextWidth("…"):0;for(let e=0,i=t.length;e<i;++e){let o=t[e],l=this._getTextWidth(o);if(a&&l>u)for(;o.length>0;){let t=0,e=c(o).length,i="",a=0;for(;t<e;){const n=t+e>>>1,l=c(o).slice(0,n+1).join(""),h=this._getTextWidth(l);(v&&s&&f+r>d?h+_:h)<=u?(t=n+1,i=l,a=h):e=n}if(!i)break;if(p){const e=c(o),n=c(i),r=e[n.length];let s;if((r===m||"-"===r)&&a<=u)s=n.length;else{const t=n.lastIndexOf(m),e=n.lastIndexOf("-");s=Math.max(t,e)+1}s>0&&(t=s,i=e.slice(0,t).join(""),a=this._getTextWidth(i))}if(i=i.trimRight(),this._addTextLine(i),n=Math.max(n,a),f+=r,this._shouldHandleEllipsis(f)){this._tryToAddEllipsisToLastLine();break}if(o=c(o).slice(t).join("").trimLeft(),o.length>0&&(l=this._getTextWidth(o),l<=u)){this._addTextLine(o),f+=r,n=Math.max(n,l);break}}else this._addTextLine(o),f+=r,n=Math.max(n,l),this._shouldHandleEllipsis(f)&&e<i-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),s&&f+r>d)break}this.textHeight=e,this.textWidth=n}_shouldHandleEllipsis(t){const e=+this.fontSize(),n=this.lineHeight()*e,r=this.attrs.height,i=r!==h&&void 0!==r,o=r-2*this.padding();return!(this.wrap()!==y)||i&&t+n>o}_tryToAddEllipsisToLastLine(){const t=this.attrs.width,e=t!==h&&void 0!==t,n=t-2*this.padding(),r=this.ellipsis(),i=this.textArr[this.textArr.length-1];i&&r&&(e&&(this._getTextWidth(i.text+"…")<n||(i.text=i.text.slice(0,i.text.length-3))),this.textArr.splice(this.textArr.length-1,1),this._addTextLine(i.text+"…"))}getStrokeScaleEnabled(){return!0}_useBufferCanvas(){const t=-1!==this.textDecoration().indexOf("underline")||-1!==this.textDecoration().indexOf("line-through"),e=this.hasShadow();return!(!t||!e)||super._useBufferCanvas()}}e.Text=C,C.prototype._fillFunc=function(t){t.fillText(this._partialText,this._partialTextX,this._partialTextY)},C.prototype._strokeFunc=function(t){t.setAttr("miterLimit",2),t.strokeText(this._partialText,this._partialTextX,this._partialTextY)},C.prototype.className="Text",C.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],(0,l._registerNode)(C),i.Factory.overWriteSetter(C,"width",(0,s.getNumberOrAutoValidator)()),i.Factory.overWriteSetter(C,"height",(0,s.getNumberOrAutoValidator)()),i.Factory.addGetterSetter(C,"direction",u),i.Factory.addGetterSetter(C,"fontFamily","Arial"),i.Factory.addGetterSetter(C,"fontSize",12,(0,s.getNumberValidator)()),i.Factory.addGetterSetter(C,"fontStyle",p),i.Factory.addGetterSetter(C,"fontVariant",p),i.Factory.addGetterSetter(C,"padding",0,(0,s.getNumberValidator)()),i.Factory.addGetterSetter(C,"align",f),i.Factory.addGetterSetter(C,"verticalAlign","top"),i.Factory.addGetterSetter(C,"lineHeight",1,(0,s.getNumberValidator)()),i.Factory.addGetterSetter(C,"wrap","word"),i.Factory.addGetterSetter(C,"ellipsis",!1,(0,s.getBooleanValidator)()),i.Factory.addGetterSetter(C,"letterSpacing",0,(0,s.getNumberValidator)()),i.Factory.addGetterSetter(C,"text","",(0,s.getStringValidator)()),i.Factory.addGetterSetter(C,"textDecoration","")},2512:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Sepia=void 0,e.Sepia=function(t){const e=t.data,n=e.length;for(let t=0;t<n;t+=4){const n=e[t+0],r=e[t+1],i=e[t+2];e[t+0]=Math.min(255,.393*n+.769*r+.189*i),e[t+1]=Math.min(255,.349*n+.686*r+.168*i),e[t+2]=Math.min(255,.272*n+.534*r+.131*i)}}},2650:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Contrast=void 0;const r=n(4892),i=n(6536),o=n(5483);e.Contrast=function(t){const e=Math.pow((this.contrast()+100)/100,2),n=t.data,r=n.length;let i=150,o=150,a=150;for(let t=0;t<r;t+=4)i=n[t],o=n[t+1],a=n[t+2],i/=255,i-=.5,i*=e,i+=.5,i*=255,o/=255,o-=.5,o*=e,o+=.5,o*=255,a/=255,a-=.5,a*=e,a+=.5,a*=255,i=i<0?0:i>255?255:i,o=o<0?0:o>255?255:o,a=a<0?0:a>255?255:a,n[t]=i,n[t+1]=o,n[t+2]=a},r.Factory.addGetterSetter(i.Node,"contrast",0,(0,o.getNumberValidator)(),r.Factory.afterSetFilter)},3443:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Line=void 0;const r=n(4892),i=n(8871),o=n(4723),a=n(5483);function s(t,e,n,r,i,o,a){const s=Math.sqrt(Math.pow(n-t,2)+Math.pow(r-e,2)),l=Math.sqrt(Math.pow(i-n,2)+Math.pow(o-r,2)),c=a*s/(s+l),h=a*l/(s+l);return[n-c*(i-t),r-c*(o-e),n+h*(i-t),r+h*(o-e)]}function l(t,e){const n=t.length,r=[];for(let i=2;i<n-2;i+=2){const n=s(t[i-2],t[i-1],t[i],t[i+1],t[i+2],t[i+3],e);isNaN(n[0])||(r.push(n[0]),r.push(n[1]),r.push(t[i]),r.push(t[i+1]),r.push(n[2]),r.push(n[3]))}return r}class c extends o.Shape{constructor(t){super(t),this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",function(){this._clearCache("tensionPoints")})}_sceneFunc(t){const e=this.points(),n=e.length,r=this.tension(),i=this.closed(),o=this.bezier();if(!n)return;let a=0;if(t.beginPath(),t.moveTo(e[0],e[1]),0!==r&&n>4){const r=this.getTensionPoints(),o=r.length;for(a=i?0:4,i||t.quadraticCurveTo(r[0],r[1],r[2],r[3]);a<o-2;)t.bezierCurveTo(r[a++],r[a++],r[a++],r[a++],r[a++],r[a++]);i||t.quadraticCurveTo(r[o-2],r[o-1],e[n-2],e[n-1])}else if(o)for(a=2;a<n;)t.bezierCurveTo(e[a++],e[a++],e[a++],e[a++],e[a++],e[a++]);else for(a=2;a<n;a+=2)t.lineTo(e[a],e[a+1]);i?(t.closePath(),t.fillStrokeShape(this)):t.strokeShape(this)}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():l(this.points(),this.tension())}_getTensionPointsClosed(){const t=this.points(),e=t.length,n=this.tension(),r=s(t[e-2],t[e-1],t[0],t[1],t[2],t[3],n),i=s(t[e-4],t[e-3],t[e-2],t[e-1],t[0],t[1],n),o=l(t,n);return[r[2],r[3]].concat(o).concat([i[0],i[1],t[e-2],t[e-1],i[2],i[3],r[0],r[1],t[0],t[1]])}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){let t=this.points();if(t.length<4)return{x:t[0]||0,y:t[1]||0,width:0,height:0};t=0!==this.tension()?[t[0],t[1],...this._getTensionPoints(),t[t.length-2],t[t.length-1]]:this.points();let e,n,r=t[0],i=t[0],o=t[1],a=t[1];for(let s=0;s<t.length/2;s++)e=t[2*s],n=t[2*s+1],r=Math.min(r,e),i=Math.max(i,e),o=Math.min(o,n),a=Math.max(a,n);return{x:r,y:o,width:i-r,height:a-o}}}e.Line=c,c.prototype.className="Line",c.prototype._attrsAffectingSize=["points","bezier","tension"],(0,i._registerNode)(c),r.Factory.addGetterSetter(c,"closed",!1),r.Factory.addGetterSetter(c,"bezier",!1),r.Factory.addGetterSetter(c,"tension",0,(0,a.getNumberValidator)()),r.Factory.addGetterSetter(c,"points",[],(0,a.getNumberArrayValidator)())},3862:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RGBA=void 0;const r=n(4892),i=n(6536),o=n(5483);e.RGBA=function(t){const e=t.data,n=e.length,r=this.red(),i=this.green(),o=this.blue(),a=this.alpha();for(let t=0;t<n;t+=4){const n=1-a;e[t]=r*a+e[t]*n,e[t+1]=i*a+e[t+1]*n,e[t+2]=o*a+e[t+2]*n}},r.Factory.addGetterSetter(i.Node,"red",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),r.Factory.addGetterSetter(i.Node,"green",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),r.Factory.addGetterSetter(i.Node,"blue",0,o.RGBComponent,r.Factory.afterSetFilter),r.Factory.addGetterSetter(i.Node,"alpha",1,function(t){return this._filterUpToDate=!1,t>1?1:t<0?0:t})},4060:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Util=e.Transform=void 0;const r=n(8871);class i{constructor(t=[1,0,0,1,0,0]){this.dirty=!1,this.m=t&&t.slice()||[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new i(this.m)}copyInto(t){t.m[0]=this.m[0],t.m[1]=this.m[1],t.m[2]=this.m[2],t.m[3]=this.m[3],t.m[4]=this.m[4],t.m[5]=this.m[5]}point(t){const e=this.m;return{x:e[0]*t.x+e[2]*t.y+e[4],y:e[1]*t.x+e[3]*t.y+e[5]}}translate(t,e){return this.m[4]+=this.m[0]*t+this.m[2]*e,this.m[5]+=this.m[1]*t+this.m[3]*e,this}scale(t,e){return this.m[0]*=t,this.m[1]*=t,this.m[2]*=e,this.m[3]*=e,this}rotate(t){const e=Math.cos(t),n=Math.sin(t),r=this.m[0]*e+this.m[2]*n,i=this.m[1]*e+this.m[3]*n,o=this.m[0]*-n+this.m[2]*e,a=this.m[1]*-n+this.m[3]*e;return this.m[0]=r,this.m[1]=i,this.m[2]=o,this.m[3]=a,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(t,e){const n=this.m[0]+this.m[2]*e,r=this.m[1]+this.m[3]*e,i=this.m[2]+this.m[0]*t,o=this.m[3]+this.m[1]*t;return this.m[0]=n,this.m[1]=r,this.m[2]=i,this.m[3]=o,this}multiply(t){const e=this.m[0]*t.m[0]+this.m[2]*t.m[1],n=this.m[1]*t.m[0]+this.m[3]*t.m[1],r=this.m[0]*t.m[2]+this.m[2]*t.m[3],i=this.m[1]*t.m[2]+this.m[3]*t.m[3],o=this.m[0]*t.m[4]+this.m[2]*t.m[5]+this.m[4],a=this.m[1]*t.m[4]+this.m[3]*t.m[5]+this.m[5];return this.m[0]=e,this.m[1]=n,this.m[2]=r,this.m[3]=i,this.m[4]=o,this.m[5]=a,this}invert(){const t=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),e=this.m[3]*t,n=-this.m[1]*t,r=-this.m[2]*t,i=this.m[0]*t,o=t*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),a=t*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=e,this.m[1]=n,this.m[2]=r,this.m[3]=i,this.m[4]=o,this.m[5]=a,this}getMatrix(){return this.m}decompose(){const t=this.m[0],n=this.m[1],r=this.m[2],i=this.m[3],o=t*i-n*r,a={x:this.m[4],y:this.m[5],rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(0!=t||0!=n){const e=Math.sqrt(t*t+n*n);a.rotation=n>0?Math.acos(t/e):-Math.acos(t/e),a.scaleX=e,a.scaleY=o/e,a.skewX=(t*r+n*i)/o,a.skewY=0}else if(0!=r||0!=i){const e=Math.sqrt(r*r+i*i);a.rotation=Math.PI/2-(i>0?Math.acos(-r/e):-Math.acos(r/e)),a.scaleX=o/e,a.scaleY=e,a.skewX=0,a.skewY=(t*r+n*i)/o}return a.rotation=e.Util._getRotation(a.rotation),a}}e.Transform=i;const o=Math.PI/180,a=180/Math.PI,s="Konva error: ",l={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,132,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,255,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[119,128,144],slategrey:[119,128,144],snow:[255,255,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,5]},c=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/;let h=[];const u="undefined"!=typeof requestAnimationFrame&&requestAnimationFrame||function(t){setTimeout(t,60)};e.Util={_isElement:t=>!(!t||1!=t.nodeType),_isFunction:t=>!!(t&&t.constructor&&t.call&&t.apply),_isPlainObject:t=>!!t&&t.constructor===Object,_isArray:t=>"[object Array]"===Object.prototype.toString.call(t),_isNumber:t=>"[object Number]"===Object.prototype.toString.call(t)&&!isNaN(t)&&isFinite(t),_isString:t=>"[object String]"===Object.prototype.toString.call(t),_isBoolean:t=>"[object Boolean]"===Object.prototype.toString.call(t),isObject:t=>t instanceof Object,isValidSelector(t){if("string"!=typeof t)return!1;const e=t[0];return"#"===e||"."===e||e===e.toUpperCase()},_sign:t=>0===t||t>0?1:-1,requestAnimFrame(t){h.push(t),1===h.length&&u(function(){const t=h;h=[],t.forEach(function(t){t()})})},createCanvasElement(){const t=document.createElement("canvas");try{t.style=t.style||{}}catch(t){}return t},createImageElement:()=>document.createElement("img"),_isInDocument(t){for(;t=t.parentNode;)if(t==document)return!0;return!1},_urlToImage(t,n){const r=e.Util.createImageElement();r.onload=function(){n(r)},r.src=t},_rgbToHex:(t,e,n)=>((1<<24)+(t<<16)+(e<<8)+n).toString(16).slice(1),_hexToRgb(t){t=t.replace("#","");const e=parseInt(t,16);return{r:e>>16&255,g:e>>8&255,b:255&e}},getRandomColor(){let t=(16777215*Math.random()|0).toString(16);for(;t.length<6;)t="0"+t;return"#"+t},getRGB(t){let e;return t in l?(e=l[t],{r:e[0],g:e[1],b:e[2]}):"#"===t[0]?this._hexToRgb(t.substring(1)):"rgb("===t.substr(0,4)?(e=c.exec(t.replace(/ /g,"")),{r:parseInt(e[1],10),g:parseInt(e[2],10),b:parseInt(e[3],10)}):{r:0,g:0,b:0}},colorToRGBA:t=>(t=t||"black",e.Util._namedColorToRBA(t)||e.Util._hex3ColorToRGBA(t)||e.Util._hex4ColorToRGBA(t)||e.Util._hex6ColorToRGBA(t)||e.Util._hex8ColorToRGBA(t)||e.Util._rgbColorToRGBA(t)||e.Util._rgbaColorToRGBA(t)||e.Util._hslColorToRGBA(t)),_namedColorToRBA(t){const e=l[t.toLowerCase()];return e?{r:e[0],g:e[1],b:e[2],a:1}:null},_rgbColorToRGBA(t){if(0===t.indexOf("rgb(")){const e=(t=t.match(/rgb\(([^)]+)\)/)[1]).split(/ *, */).map(Number);return{r:e[0],g:e[1],b:e[2],a:1}}},_rgbaColorToRGBA(t){if(0===t.indexOf("rgba(")){const e=(t=t.match(/rgba\(([^)]+)\)/)[1]).split(/ *, */).map((t,e)=>"%"===t.slice(-1)?3===e?parseInt(t)/100:parseInt(t)/100*255:Number(t));return{r:e[0],g:e[1],b:e[2],a:e[3]}}},_hex8ColorToRGBA(t){if("#"===t[0]&&9===t.length)return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:parseInt(t.slice(7,9),16)/255}},_hex6ColorToRGBA(t){if("#"===t[0]&&7===t.length)return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:1}},_hex4ColorToRGBA(t){if("#"===t[0]&&5===t.length)return{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:parseInt(t[4]+t[4],16)/255}},_hex3ColorToRGBA(t){if("#"===t[0]&&4===t.length)return{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:1}},_hslColorToRGBA(t){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(t)){const[e,...n]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(t),r=Number(n[0])/360,i=Number(n[1])/100,o=Number(n[2])/100;let a,s,l;if(0===i)return l=255*o,{r:Math.round(l),g:Math.round(l),b:Math.round(l),a:1};a=o<.5?o*(1+i):o+i-o*i;const c=2*o-a,h=[0,0,0];for(let t=0;t<3;t++)s=r+1/3*-(t-1),s<0&&s++,s>1&&s--,l=6*s<1?c+6*(a-c)*s:2*s<1?a:3*s<2?c+(a-c)*(2/3-s)*6:c,h[t]=255*l;return{r:Math.round(h[0]),g:Math.round(h[1]),b:Math.round(h[2]),a:1}}},haveIntersection:(t,e)=>!(e.x>t.x+t.width||e.x+e.width<t.x||e.y>t.y+t.height||e.y+e.height<t.y),cloneObject(t){const e={};for(const n in t)this._isPlainObject(t[n])?e[n]=this.cloneObject(t[n]):this._isArray(t[n])?e[n]=this.cloneArray(t[n]):e[n]=t[n];return e},cloneArray:t=>t.slice(0),degToRad:t=>t*o,radToDeg:t=>t*a,_degToRad:t=>(e.Util.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),e.Util.degToRad(t)),_radToDeg:t=>(e.Util.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),e.Util.radToDeg(t)),_getRotation:t=>r.Konva.angleDeg?e.Util.radToDeg(t):t,_capitalize:t=>t.charAt(0).toUpperCase()+t.slice(1),throw(t){throw new Error(s+t)},error(t){console.error(s+t)},warn(t){r.Konva.showWarnings&&console.warn("Konva warning: "+t)},each(t,e){for(const n in t)e(n,t[n])},_inRange:(t,e,n)=>e<=t&&t<n,_getProjectionToSegment(t,e,n,r,i,o){let a,s,l;const c=(t-n)*(t-n)+(e-r)*(e-r);if(0==c)a=t,s=e,l=(i-n)*(i-n)+(o-r)*(o-r);else{const h=((i-t)*(n-t)+(o-e)*(r-e))/c;h<0?(a=t,s=e,l=(t-i)*(t-i)+(e-o)*(e-o)):h>1?(a=n,s=r,l=(n-i)*(n-i)+(r-o)*(r-o)):(a=t+h*(n-t),s=e+h*(r-e),l=(a-i)*(a-i)+(s-o)*(s-o))}return[a,s,l]},_getProjectionToLine(t,n,r){const i=e.Util.cloneObject(t);let o=Number.MAX_VALUE;return n.forEach(function(a,s){if(!r&&s===n.length-1)return;const l=n[(s+1)%n.length],c=e.Util._getProjectionToSegment(a.x,a.y,l.x,l.y,t.x,t.y),h=c[0],u=c[1],d=c[2];d<o&&(i.x=h,i.y=u,o=d)}),i},_prepareArrayForTween(t,n,r){const i=[],o=[];if(t.length>n.length){const e=n;n=t,t=e}for(let e=0;e<t.length;e+=2)i.push({x:t[e],y:t[e+1]});for(let t=0;t<n.length;t+=2)o.push({x:n[t],y:n[t+1]});const a=[];return o.forEach(function(t){const n=e.Util._getProjectionToLine(t,i,r);a.push(n.x),a.push(n.y)}),a},_prepareToStringify(t){let n;t.visitedByCircularReferenceRemoval=!0;for(const r in t)if(t.hasOwnProperty(r)&&t[r]&&"object"==typeof t[r])if(n=Object.getOwnPropertyDescriptor(t,r),t[r].visitedByCircularReferenceRemoval||e.Util._isElement(t[r])){if(!n.configurable)return null;delete t[r]}else if(null===e.Util._prepareToStringify(t[r])){if(!n.configurable)return null;delete t[r]}return delete t.visitedByCircularReferenceRemoval,t},_assign(t,e){for(const n in e)t[n]=e[n];return t},_getFirstPointerId:t=>t.touches?t.changedTouches[0].identifier:t.pointerId||999,releaseCanvas(...t){r.Konva.releaseCanvasOnDestroy&&t.forEach(t=>{t.width=0,t.height=0})},drawRoundedRectPath(t,e,n,r){let i=0,o=0,a=0,s=0;"number"==typeof r?i=o=a=s=Math.min(r,e/2,n/2):(i=Math.min(r[0]||0,e/2,n/2),o=Math.min(r[1]||0,e/2,n/2),s=Math.min(r[2]||0,e/2,n/2),a=Math.min(r[3]||0,e/2,n/2)),t.moveTo(i,0),t.lineTo(e-o,0),t.arc(e-o,o,o,3*Math.PI/2,0,!1),t.lineTo(e,n-s),t.arc(e-s,n-s,s,0,Math.PI/2,!1),t.lineTo(a,n),t.arc(a,n-a,a,Math.PI/2,Math.PI,!1),t.lineTo(0,i),t.arc(i,i,i,Math.PI,3*Math.PI/2,!1)}}},4473:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Container=void 0;const r=n(4892),i=n(6536),o=n(5483);class a extends i.Node{constructor(){super(...arguments),this.children=[]}getChildren(t){const e=this.children||[];return t?e.filter(t):e}hasChildren(){return this.getChildren().length>0}removeChildren(){return this.getChildren().forEach(t=>{t.parent=null,t.index=0,t.remove()}),this.children=[],this._requestDraw(),this}destroyChildren(){return this.getChildren().forEach(t=>{t.parent=null,t.index=0,t.destroy()}),this.children=[],this._requestDraw(),this}add(...t){if(0===t.length)return this;if(t.length>1){for(let e=0;e<t.length;e++)this.add(t[e]);return this}const e=t[0];return e.getParent()?(e.moveTo(this),this):(this._validateAdd(e),e.index=this.getChildren().length,e.parent=this,e._clearCaches(),this.getChildren().push(e),this._fire("add",{child:e}),this._requestDraw(),this)}destroy(){return this.hasChildren()&&this.destroyChildren(),super.destroy(),this}find(t){return this._generalFind(t,!1)}findOne(t){const e=this._generalFind(t,!0);return e.length>0?e[0]:void 0}_generalFind(t,e){const n=[];return this._descendants(r=>{const i=r._isMatch(t);return i&&n.push(r),!(!i||!e)}),n}_descendants(t){let e=!1;const n=this.getChildren();for(const r of n){if(e=t(r),e)return!0;if(r.hasChildren()&&(e=r._descendants(t),e))return!0}return!1}toObject(){const t=i.Node.prototype.toObject.call(this);return t.children=[],this.getChildren().forEach(e=>{t.children.push(e.toObject())}),t}isAncestorOf(t){let e=t.getParent();for(;e;){if(e._id===this._id)return!0;e=e.getParent()}return!1}clone(t){const e=i.Node.prototype.clone.call(this,t);return this.getChildren().forEach(function(t){e.add(t.clone())}),e}getAllIntersections(t){const e=[];return this.find("Shape").forEach(n=>{n.isVisible()&&n.intersects(t)&&e.push(n)}),e}_clearSelfAndDescendantCache(t){var e;super._clearSelfAndDescendantCache(t),this.isCached()||null===(e=this.children)||void 0===e||e.forEach(function(e){e._clearSelfAndDescendantCache(t)})}_setChildrenIndices(){var t;null===(t=this.children)||void 0===t||t.forEach(function(t,e){t.index=e}),this._requestDraw()}drawScene(t,e,n){const r=this.getLayer(),i=t||r&&r.getCanvas(),o=i&&i.getContext(),a=this._getCanvasCache(),s=a&&a.scene,l=i&&i.isCache;if(!this.isVisible()&&!l)return this;if(s){o.save();const t=this.getAbsoluteTransform(e).getMatrix();o.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedSceneCanvas(o),o.restore()}else this._drawChildren("drawScene",i,e,n);return this}drawHit(t,e){if(!this.shouldDrawHit(e))return this;const n=this.getLayer(),r=t||n&&n.hitCanvas,i=r&&r.getContext(),o=this._getCanvasCache();if(o&&o.hit){i.save();const t=this.getAbsoluteTransform(e).getMatrix();i.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedHitCanvas(i),i.restore()}else this._drawChildren("drawHit",r,e);return this}_drawChildren(t,e,n,r){var i;const o=e&&e.getContext(),a=this.clipWidth(),s=this.clipHeight(),l=this.clipFunc(),c="number"==typeof a&&"number"==typeof s||l,h=n===this;if(c){o.save();const t=this.getAbsoluteTransform(n);let e,r=t.getMatrix();if(o.transform(r[0],r[1],r[2],r[3],r[4],r[5]),o.beginPath(),l)e=l.call(this,o,this);else{const t=this.clipX(),e=this.clipY();o.rect(t||0,e||0,a,s)}o.clip.apply(o,e),r=t.copy().invert().getMatrix(),o.transform(r[0],r[1],r[2],r[3],r[4],r[5])}const u=!h&&"source-over"!==this.globalCompositeOperation()&&"drawScene"===t;u&&(o.save(),o._applyGlobalCompositeOperation(this)),null===(i=this.children)||void 0===i||i.forEach(function(i){i[t](e,n,r)}),u&&o.restore(),c&&o.restore()}getClientRect(t={}){var e;const n=t.skipTransform,r=t.relativeTo;let i,o,a,s,l={x:1/0,y:1/0,width:0,height:0};const c=this;null===(e=this.children)||void 0===e||e.forEach(function(e){if(!e.visible())return;const n=e.getClientRect({relativeTo:c,skipShadow:t.skipShadow,skipStroke:t.skipStroke});0===n.width&&0===n.height||(void 0===i?(i=n.x,o=n.y,a=n.x+n.width,s=n.y+n.height):(i=Math.min(i,n.x),o=Math.min(o,n.y),a=Math.max(a,n.x+n.width),s=Math.max(s,n.y+n.height)))});const h=this.find("Shape");let u=!1;for(let t=0;t<h.length;t++)if(h[t]._isVisible(this)){u=!0;break}return l=u&&void 0!==i?{x:i,y:o,width:a-i,height:s-o}:{x:0,y:0,width:0,height:0},n?l:this._transformedRect(l,r)}}e.Container=a,r.Factory.addComponentsGetterSetter(a,"clip",["x","y","width","height"]),r.Factory.addGetterSetter(a,"clipX",void 0,(0,o.getNumberValidator)()),r.Factory.addGetterSetter(a,"clipY",void 0,(0,o.getNumberValidator)()),r.Factory.addGetterSetter(a,"clipWidth",void 0,(0,o.getNumberValidator)()),r.Factory.addGetterSetter(a,"clipHeight",void 0,(0,o.getNumberValidator)()),r.Factory.addGetterSetter(a,"clipFunc")},4481:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Star=void 0;const r=n(4892),i=n(4723),o=n(5483),a=n(8871);class s extends i.Shape{_sceneFunc(t){const e=this.innerRadius(),n=this.outerRadius(),r=this.numPoints();t.beginPath(),t.moveTo(0,0-n);for(let i=1;i<2*r;i++){const o=i%2==0?n:e,a=o*Math.sin(i*Math.PI/r),s=-1*o*Math.cos(i*Math.PI/r);t.lineTo(a,s)}t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}}e.Star=s,s.prototype.className="Star",s.prototype._centroid=!0,s.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,a._registerNode)(s),r.Factory.addGetterSetter(s,"numPoints",5,(0,o.getNumberValidator)()),r.Factory.addGetterSetter(s,"innerRadius",0,(0,o.getNumberValidator)()),r.Factory.addGetterSetter(s,"outerRadius",0,(0,o.getNumberValidator)())},4723:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Shape=e.shapes=void 0;const r=n(8871),i=n(4060),o=n(4892),a=n(6536),s=n(5483),l=n(8871),c=n(8722),h="hasShadow",u="shadowRGBA",d="patternImage",f="linearGradient",g="radialGradient";let p;function m(){return p||(p=i.Util.createCanvasElement().getContext("2d"),p)}e.shapes={};class y extends a.Node{constructor(t){let n;for(super(t);n=i.Util.getRandomColor(),!n||n in e.shapes;);this.colorKey=n,e.shapes[n]=this}getContext(){return i.Util.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return i.Util.warn("shape.getCanvas() method is deprecated. Please do not use it."),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(h,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&0!==this.shadowOpacity()&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(d,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){const t=m().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(t&&t.setTransform){const e=new i.Transform;e.translate(this.fillPatternX(),this.fillPatternY()),e.rotate(r.Konva.getAngle(this.fillPatternRotation())),e.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),e.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const n=e.getMatrix(),o="undefined"==typeof DOMMatrix?{a:n[0],b:n[1],c:n[2],d:n[3],e:n[4],f:n[5]}:new DOMMatrix(n);t.setTransform(o)}return t}}_getLinearGradient(){return this._getCache(f,this.__getLinearGradient)}__getLinearGradient(){const t=this.fillLinearGradientColorStops();if(t){const e=m(),n=this.fillLinearGradientStartPoint(),r=this.fillLinearGradientEndPoint(),i=e.createLinearGradient(n.x,n.y,r.x,r.y);for(let e=0;e<t.length;e+=2)i.addColorStop(t[e],t[e+1]);return i}}_getRadialGradient(){return this._getCache(g,this.__getRadialGradient)}__getRadialGradient(){const t=this.fillRadialGradientColorStops();if(t){const e=m(),n=this.fillRadialGradientStartPoint(),r=this.fillRadialGradientEndPoint(),i=e.createRadialGradient(n.x,n.y,this.fillRadialGradientStartRadius(),r.x,r.y,this.fillRadialGradientEndRadius());for(let e=0;e<t.length;e+=2)i.addColorStop(t[e],t[e+1]);return i}}getShadowRGBA(){return this._getCache(u,this._getShadowRGBA)}_getShadowRGBA(){if(!this.hasShadow())return;const t=i.Util.colorToRGBA(this.shadowColor());return t?"rgba("+t.r+","+t.g+","+t.b+","+t.a*(this.shadowOpacity()||1)+")":void 0}hasFill(){return this._calculate("hasFill",["fillEnabled","fill","fillPatternImage","fillLinearGradientColorStops","fillRadialGradientColorStops"],()=>this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops()))}hasStroke(){return this._calculate("hasStroke",["strokeEnabled","strokeWidth","stroke","strokeLinearGradientColorStops"],()=>this.strokeEnabled()&&this.strokeWidth()&&!(!this.stroke()&&!this.strokeLinearGradientColorStops()))}hasHitStroke(){const t=this.hitStrokeWidth();return"auto"===t?this.hasStroke():this.strokeEnabled()&&!!t}intersects(t){const e=this.getStage();if(!e)return!1;const n=e.bufferHitCanvas;return n.getContext().clear(),this.drawHit(n,void 0,!0),n.context.getImageData(Math.round(t.x),Math.round(t.y),1,1).data[3]>0}destroy(){return a.Node.prototype.destroy.call(this),delete e.shapes[this.colorKey],delete this.colorKey,this}_useBufferCanvas(t){var e;if(null!==(e=this.attrs.perfectDrawEnabled)&&void 0!==e&&!e)return!1;const n=t||this.hasFill(),r=this.hasStroke(),i=1!==this.getAbsoluteOpacity();if(n&&r&&i)return!0;const o=this.hasShadow(),a=this.shadowForStrokeEnabled();return!!(n&&r&&o&&a)}setStrokeHitEnabled(t){i.Util.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),t?this.hitStrokeWidth("auto"):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return 0!==this.hitStrokeWidth()}getSelfRect(){const t=this.size();return{x:this._centroid?-t.width/2:0,y:this._centroid?-t.height/2:0,width:t.width,height:t.height}}getClientRect(t={}){let e=!1,n=this.getParent();for(;n;){if(n.isCached()){e=!0;break}n=n.getParent()}const r=t.skipTransform,i=t.relativeTo||e&&this.getStage()||void 0,o=this.getSelfRect(),a=!t.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,s=o.width+a,l=o.height+a,c=!t.skipShadow&&this.hasShadow(),h=c?this.shadowOffsetX():0,u=c?this.shadowOffsetY():0,d=s+Math.abs(h),f=l+Math.abs(u),g=c&&this.shadowBlur()||0,p={width:d+2*g,height:f+2*g,x:-(a/2+g)+Math.min(h,0)+o.x,y:-(a/2+g)+Math.min(u,0)+o.y};return r?p:this._transformedRect(p,i)}drawScene(t,e,n){const r=this.getLayer(),i=(t||r.getCanvas()).getContext(),o=this._getCanvasCache(),a=this.getSceneFunc(),s=this.hasShadow();let l;const c=e===this;if(!this.isVisible()&&!c)return this;if(o){i.save();const t=this.getAbsoluteTransform(e).getMatrix();return i.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedSceneCanvas(i),i.restore(),this}if(!a)return this;if(i.save(),this._useBufferCanvas()){l=this.getStage();const t=n||l.bufferCanvas,r=t.getContext();r.clear(),r.save(),r._applyLineJoin(this);const o=this.getAbsoluteTransform(e).getMatrix();r.transform(o[0],o[1],o[2],o[3],o[4],o[5]),a.call(this,r,this),r.restore();const c=t.pixelRatio;s&&i._applyShadow(this),i._applyOpacity(this),i._applyGlobalCompositeOperation(this),i.drawImage(t._canvas,t.x||0,t.y||0,t.width/c,t.height/c)}else{if(i._applyLineJoin(this),!c){const t=this.getAbsoluteTransform(e).getMatrix();i.transform(t[0],t[1],t[2],t[3],t[4],t[5]),i._applyOpacity(this),i._applyGlobalCompositeOperation(this)}s&&i._applyShadow(this),a.call(this,i,this)}return i.restore(),this}drawHit(t,e,n=!1){if(!this.shouldDrawHit(e,n))return this;const r=this.getLayer(),o=t||r.hitCanvas,a=o&&o.getContext(),s=this.hitFunc()||this.sceneFunc(),l=this._getCanvasCache(),c=l&&l.hit;if(this.colorKey||i.Util.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"),c){a.save();const t=this.getAbsoluteTransform(e).getMatrix();return a.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedHitCanvas(a),a.restore(),this}if(!s)return this;if(a.save(),a._applyLineJoin(this),this!==e){const t=this.getAbsoluteTransform(e).getMatrix();a.transform(t[0],t[1],t[2],t[3],t[4],t[5])}return s.call(this,a,this),a.restore(),this}drawHitFromCache(t=0){const e=this._getCanvasCache(),n=this._getCachedSceneCanvas(),r=e.hit,o=r.getContext(),a=r.getWidth(),s=r.getHeight();o.clear(),o.drawImage(n._canvas,0,0,a,s);try{const e=o.getImageData(0,0,a,s),n=e.data,r=n.length,l=i.Util._hexToRgb(this.colorKey);for(let e=0;e<r;e+=4)n[e+3]>t?(n[e]=l.r,n[e+1]=l.g,n[e+2]=l.b,n[e+3]=255):n[e+3]=0;o.putImageData(e,0,0)}catch(t){i.Util.error("Unable to draw hit graph from cached scene canvas. "+t.message)}return this}hasPointerCapture(t){return c.hasPointerCapture(t,this)}setPointerCapture(t){c.setPointerCapture(t,this)}releaseCapture(t){c.releaseCapture(t,this)}}e.Shape=y,y.prototype._fillFunc=function(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()},y.prototype._strokeFunc=function(t){t.stroke()},y.prototype._fillFuncHit=function(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()},y.prototype._strokeFuncHit=function(t){t.stroke()},y.prototype._centroid=!1,y.prototype.nodeType="Shape",(0,l._registerNode)(y),y.prototype.eventListeners={},y.prototype.on.call(y.prototype,"shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",function(){this._clearCache(h)}),y.prototype.on.call(y.prototype,"shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",function(){this._clearCache(u)}),y.prototype.on.call(y.prototype,"fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",function(){this._clearCache(d)}),y.prototype.on.call(y.prototype,"fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",function(){this._clearCache(f)}),y.prototype.on.call(y.prototype,"fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",function(){this._clearCache(g)}),o.Factory.addGetterSetter(y,"stroke",void 0,(0,s.getStringOrGradientValidator)()),o.Factory.addGetterSetter(y,"strokeWidth",2,(0,s.getNumberValidator)()),o.Factory.addGetterSetter(y,"fillAfterStrokeEnabled",!1),o.Factory.addGetterSetter(y,"hitStrokeWidth","auto",(0,s.getNumberOrAutoValidator)()),o.Factory.addGetterSetter(y,"strokeHitEnabled",!0,(0,s.getBooleanValidator)()),o.Factory.addGetterSetter(y,"perfectDrawEnabled",!0,(0,s.getBooleanValidator)()),o.Factory.addGetterSetter(y,"shadowForStrokeEnabled",!0,(0,s.getBooleanValidator)()),o.Factory.addGetterSetter(y,"lineJoin"),o.Factory.addGetterSetter(y,"lineCap"),o.Factory.addGetterSetter(y,"sceneFunc"),o.Factory.addGetterSetter(y,"hitFunc"),o.Factory.addGetterSetter(y,"dash"),o.Factory.addGetterSetter(y,"dashOffset",0,(0,s.getNumberValidator)()),o.Factory.addGetterSetter(y,"shadowColor",void 0,(0,s.getStringValidator)()),o.Factory.addGetterSetter(y,"shadowBlur",0,(0,s.getNumberValidator)()),o.Factory.addGetterSetter(y,"shadowOpacity",1,(0,s.getNumberValidator)()),o.Factory.addComponentsGetterSetter(y,"shadowOffset",["x","y"]),o.Factory.addGetterSetter(y,"shadowOffsetX",0,(0,s.getNumberValidator)()),o.Factory.addGetterSetter(y,"shadowOffsetY",0,(0,s.getNumberValidator)()),o.Factory.addGetterSetter(y,"fillPatternImage"),o.Factory.addGetterSetter(y,"fill",void 0,(0,s.getStringOrGradientValidator)()),o.Factory.addGetterSetter(y,"fillPatternX",0,(0,s.getNumberValidator)()),o.Factory.addGetterSetter(y,"fillPatternY",0,(0,s.getNumberValidator)()),o.Factory.addGetterSetter(y,"fillLinearGradientColorStops"),o.Factory.addGetterSetter(y,"strokeLinearGradientColorStops"),o.Factory.addGetterSetter(y,"fillRadialGradientStartRadius",0),o.Factory.addGetterSetter(y,"fillRadialGradientEndRadius",0),o.Factory.addGetterSetter(y,"fillRadialGradientColorStops"),o.Factory.addGetterSetter(y,"fillPatternRepeat","repeat"),o.Factory.addGetterSetter(y,"fillEnabled",!0),o.Factory.addGetterSetter(y,"strokeEnabled",!0),o.Factory.addGetterSetter(y,"shadowEnabled",!0),o.Factory.addGetterSetter(y,"dashEnabled",!0),o.Factory.addGetterSetter(y,"strokeScaleEnabled",!0),o.Factory.addGetterSetter(y,"fillPriority","color"),o.Factory.addComponentsGetterSetter(y,"fillPatternOffset",["x","y"]),o.Factory.addGetterSetter(y,"fillPatternOffsetX",0,(0,s.getNumberValidator)()),o.Factory.addGetterSetter(y,"fillPatternOffsetY",0,(0,s.getNumberValidator)()),o.Factory.addComponentsGetterSetter(y,"fillPatternScale",["x","y"]),o.Factory.addGetterSetter(y,"fillPatternScaleX",1,(0,s.getNumberValidator)()),o.Factory.addGetterSetter(y,"fillPatternScaleY",1,(0,s.getNumberValidator)()),o.Factory.addComponentsGetterSetter(y,"fillLinearGradientStartPoint",["x","y"]),o.Factory.addComponentsGetterSetter(y,"strokeLinearGradientStartPoint",["x","y"]),o.Factory.addGetterSetter(y,"fillLinearGradientStartPointX",0),o.Factory.addGetterSetter(y,"strokeLinearGradientStartPointX",0),o.Factory.addGetterSetter(y,"fillLinearGradientStartPointY",0),o.Factory.addGetterSetter(y,"strokeLinearGradientStartPointY",0),o.Factory.addComponentsGetterSetter(y,"fillLinearGradientEndPoint",["x","y"]),o.Factory.addComponentsGetterSetter(y,"strokeLinearGradientEndPoint",["x","y"]),o.Factory.addGetterSetter(y,"fillLinearGradientEndPointX",0),o.Factory.addGetterSetter(y,"strokeLinearGradientEndPointX",0),o.Factory.addGetterSetter(y,"fillLinearGradientEndPointY",0),o.Factory.addGetterSetter(y,"strokeLinearGradientEndPointY",0),o.Factory.addComponentsGetterSetter(y,"fillRadialGradientStartPoint",["x","y"]),o.Factory.addGetterSetter(y,"fillRadialGradientStartPointX",0),o.Factory.addGetterSetter(y,"fillRadialGradientStartPointY",0),o.Factory.addComponentsGetterSetter(y,"fillRadialGradientEndPoint",["x","y"]),o.Factory.addGetterSetter(y,"fillRadialGradientEndPointX",0),o.Factory.addGetterSetter(y,"fillRadialGradientEndPointY",0),o.Factory.addGetterSetter(y,"fillPatternRotation",0),o.Factory.addGetterSetter(y,"fillRule",void 0,(0,s.getStringValidator)()),o.Factory.backCompat(y,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"})},4821:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Arc=void 0;const r=n(4892),i=n(4723),o=n(8871),a=n(5483),s=n(8871);class l extends i.Shape{_sceneFunc(t){const e=o.Konva.getAngle(this.angle()),n=this.clockwise();t.beginPath(),t.arc(0,0,this.outerRadius(),0,e,n),t.arc(0,0,this.innerRadius(),e,0,!n),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}getSelfRect(){const t=this.innerRadius(),e=this.outerRadius(),n=this.clockwise(),r=o.Konva.getAngle(n?360-this.angle():this.angle()),i=Math.cos(Math.min(r,Math.PI)),a=Math.sin(Math.min(Math.max(Math.PI,r),3*Math.PI/2)),s=Math.sin(Math.min(r,Math.PI/2)),l=i*(i>0?t:e),c=a*(a>0?t:e),h=s*(s>0?e:t);return{x:l,y:n?-1*h:c,width:1*e-l,height:h-c}}}e.Arc=l,l.prototype._centroid=!0,l.prototype.className="Arc",l.prototype._attrsAffectingSize=["innerRadius","outerRadius","angle","clockwise"],(0,s._registerNode)(l),r.Factory.addGetterSetter(l,"innerRadius",0,(0,a.getNumberValidator)()),r.Factory.addGetterSetter(l,"outerRadius",0,(0,a.getNumberValidator)()),r.Factory.addGetterSetter(l,"angle",0,(0,a.getNumberValidator)()),r.Factory.addGetterSetter(l,"clockwise",!1,(0,a.getBooleanValidator)())},4843:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.HSV=void 0;const r=n(4892),i=n(6536),o=n(5483);e.HSV=function(t){const e=t.data,n=e.length,r=Math.pow(2,this.value()),i=Math.pow(2,this.saturation()),o=Math.abs(this.hue()+360)%360,a=r*i*Math.cos(o*Math.PI/180),s=r*i*Math.sin(o*Math.PI/180),l=.299*r+.701*a+.167*s,c=.587*r-.587*a+.33*s,h=.114*r-.114*a-.497*s,u=.299*r-.299*a-.328*s,d=.587*r+.413*a+.035*s,f=.114*r-.114*a+.293*s,g=.299*r-.3*a+1.25*s,p=.587*r-.586*a-1.05*s,m=.114*r+.886*a-.2*s;for(let t=0;t<n;t+=4){const n=e[t+0],r=e[t+1],i=e[t+2],o=e[t+3];e[t+0]=l*n+c*r+h*i,e[t+1]=u*n+d*r+f*i,e[t+2]=g*n+p*r+m*i,e[t+3]=o}},r.Factory.addGetterSetter(i.Node,"hue",0,(0,o.getNumberValidator)(),r.Factory.afterSetFilter),r.Factory.addGetterSetter(i.Node,"saturation",0,(0,o.getNumberValidator)(),r.Factory.afterSetFilter),r.Factory.addGetterSetter(i.Node,"value",0,(0,o.getNumberValidator)(),r.Factory.afterSetFilter)},4884:(t,e,n)=>{"use strict";n.d(e,{A:()=>s});var r=n(1354),i=n.n(r),o=n(6314),a=n.n(o)()(i());a.push([t.id,".eda-pmpo-tooltip-line {\n display: flex;\n align-items: center;\n gap: 6px;\n margin-left: 6px;\n}\n\n.eda-pmpo-box {\n width: 10px;\n height: 10px;\n}\n\n.eda-pmpo-input-form {\n padding-left: 10px;\n padding-right: 5px;\n}\n\n.eda-pmpo-title {\n font-size: 14.5px;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n pointer-events: none;\n white-space: nowrap;\n}\n\n.eda-pmpo-centered-text {\n display: flex;\n justify-content: center;\n align-items: center;\n height: 100%;\n width: 100%;\n text-align: center;\n}","",{version:3,sources:["webpack://./css/pmpo.css"],names:[],mappings:"AAAA;EACE,aAAa;EACb,mBAAmB;EACnB,QAAQ;EACR,gBAAgB;AAClB;;AAEA;EACE,WAAW;EACX,YAAY;AACd;;AAEA;EACE,kBAAkB;EAClB,kBAAkB;AACpB;;AAEA;EACE,iBAAiB;EACjB,kBAAkB;EAClB,QAAQ;EACR,SAAS;EACT,gCAAgC;EAChC,oBAAoB;EACpB,mBAAmB;AACrB;;AAEA;EACE,aAAa;EACb,uBAAuB;EACvB,mBAAmB;EACnB,YAAY;EACZ,WAAW;EACX,kBAAkB;AACpB",sourcesContent:[".eda-pmpo-tooltip-line {\n display: flex;\n align-items: center;\n gap: 6px;\n margin-left: 6px;\n}\n\n.eda-pmpo-box {\n width: 10px;\n height: 10px;\n}\n\n.eda-pmpo-input-form {\n padding-left: 10px;\n padding-right: 5px;\n}\n\n.eda-pmpo-title {\n font-size: 14.5px;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n pointer-events: none;\n white-space: nowrap;\n}\n\n.eda-pmpo-centered-text {\n display: flex;\n justify-content: center;\n align-items: center;\n height: 100%;\n width: 100%;\n text-align: center;\n}"],sourceRoot:""}]);const s=a},4892:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Factory=void 0;const r=n(4060),i=n(5483),o="get",a="set";e.Factory={addGetterSetter(t,n,r,i,o){e.Factory.addGetter(t,n,r),e.Factory.addSetter(t,n,i,o),e.Factory.addOverloadedGetterSetter(t,n)},addGetter(t,e,n){const i=o+r.Util._capitalize(e);t.prototype[i]=t.prototype[i]||function(){const t=this.attrs[e];return void 0===t?n:t}},addSetter(t,n,i,o){const s=a+r.Util._capitalize(n);t.prototype[s]||e.Factory.overWriteSetter(t,n,i,o)},overWriteSetter(t,e,n,i){const o=a+r.Util._capitalize(e);t.prototype[o]=function(t){return n&&null!=t&&(t=n.call(this,t,e)),this._setAttr(e,t),i&&i.call(this),this}},addComponentsGetterSetter(t,n,s,l,c){const h=s.length,u=r.Util._capitalize,d=o+u(n),f=a+u(n);t.prototype[d]=function(){const t={};for(let e=0;e<h;e++){const r=s[e];t[r]=this.getAttr(n+u(r))}return t};const g=(0,i.getComponentValidator)(s);t.prototype[f]=function(t){const e=this.attrs[n];l&&(t=l.call(this,t,n)),g&&g.call(this,t,n);for(const e in t)t.hasOwnProperty(e)&&this._setAttr(n+u(e),t[e]);return t||s.forEach(t=>{this._setAttr(n+u(t),void 0)}),this._fireChangeEvent(n,e,t),c&&c.call(this),this},e.Factory.addOverloadedGetterSetter(t,n)},addOverloadedGetterSetter(t,e){const n=r.Util._capitalize(e),i=a+n,s=o+n;t.prototype[e]=function(){return arguments.length?(this[i](arguments[0]),this):this[s]()}},addDeprecatedGetterSetter(t,n,i,a){r.Util.error("Adding deprecated "+n);const s=o+r.Util._capitalize(n),l=n+" property is deprecated and will be removed soon. Look at Konva change log for more information.";t.prototype[s]=function(){r.Util.error(l);const t=this.attrs[n];return void 0===t?i:t},e.Factory.addSetter(t,n,a,function(){r.Util.error(l)}),e.Factory.addOverloadedGetterSetter(t,n)},backCompat(t,e){r.Util.each(e,function(e,n){const i=t.prototype[n],s=o+r.Util._capitalize(e),l=a+r.Util._capitalize(e);function c(){i.apply(this,arguments),r.Util.error('"'+e+'" method is deprecated and will be removed soon. Use ""'+n+'" instead.')}t.prototype[e]=c,t.prototype[s]=c,t.prototype[l]=c})},afterSetFilter(){this._filterUpToDate=!1}}},4943:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Pixelate=void 0;const r=n(4892),i=n(4060),o=n(6536),a=n(5483);e.Pixelate=function(t){let e=Math.ceil(this.pixelSize()),n=t.width,r=t.height,o=Math.ceil(n/e),a=Math.ceil(r/e),s=t.data;if(e<=0)i.Util.error("pixelSize value can not be <= 0");else for(let t=0;t<o;t+=1)for(let i=0;i<a;i+=1){let o=0,a=0,l=0,c=0;const h=t*e,u=h+e,d=i*e,f=d+e;let g=0;for(let t=h;t<u;t+=1)if(!(t>=n))for(let e=d;e<f;e+=1){if(e>=r)continue;const i=4*(n*e+t);o+=s[i+0],a+=s[i+1],l+=s[i+2],c+=s[i+3],g+=1}o/=g,a/=g,l/=g,c/=g;for(let t=h;t<u;t+=1)if(!(t>=n))for(let e=d;e<f;e+=1){if(e>=r)continue;const i=4*(n*e+t);s[i+0]=o,s[i+1]=a,s[i+2]=l,s[i+3]=c}}},r.Factory.addGetterSetter(o.Node,"pixelSize",8,(0,a.getNumberValidator)(),r.Factory.afterSetFilter)},5056:(t,e,n)=>{"use strict";t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},5058:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Transformer=void 0;const r=n(4060),i=n(4892),o=n(6536),a=n(4723),s=n(5155),l=n(7949),c=n(8871),h=n(5483),u=n(8871),d="tr-konva",f=["resizeEnabledChange","rotateAnchorOffsetChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange"].map(t=>t+`.${d}`).join(" "),g="nodesRect",p=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange"],m={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},y="ontouchstart"in c.Konva._global,v=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"];function _(t,e,n){const r=n.x+(t.x-n.x)*Math.cos(e)-(t.y-n.y)*Math.sin(e),i=n.y+(t.x-n.x)*Math.sin(e)+(t.y-n.y)*Math.cos(e);return{...t,rotation:t.rotation+e,x:r,y:i}}let w=0;class b extends l.Group{constructor(t){super(t),this._movingAnchorName=null,this._transforming=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(f,this.update),this.getNode()&&this.update()}attachTo(t){return this.setNode(t),this}setNode(t){return r.Util.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([t])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return d+this._id}setNodes(t=[]){this._nodes&&this._nodes.length&&this.detach();const e=t.filter(t=>!t.isAncestorOf(this)||(r.Util.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1));return this._nodes=t=e,1===t.length&&this.useSingleNodeRotation()?this.rotation(t[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach(t=>{const e=()=>{1===this.nodes().length&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),this._transforming||this.isDragging()||this.update()};if(t._attrsAffectingSize.length){const n=t._attrsAffectingSize.map(t=>t+"Change."+this._getEventNamespace()).join(" ");t.on(n,e)}t.on(p.map(t=>t+`.${this._getEventNamespace()}`).join(" "),e),t.on(`absoluteTransformChange.${this._getEventNamespace()}`,e),this._proxyDrag(t)}),this._resetTransformCache(),!!this.findOne(".top-left")&&this.update(),this}_proxyDrag(t){let e;t.on(`dragstart.${this._getEventNamespace()}`,n=>{e=t.getAbsolutePosition(),this.isDragging()||t===this.findOne(".back")||this.startDrag(n,!1)}),t.on(`dragmove.${this._getEventNamespace()}`,n=>{if(!e)return;const r=t.getAbsolutePosition(),i=r.x-e.x,o=r.y-e.y;this.nodes().forEach(e=>{if(e===t)return;if(e.isDragging())return;const r=e.getAbsolutePosition();e.setAbsolutePosition({x:r.x+i,y:r.y+o}),e.startDrag(n)}),e=null})}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){this._nodes&&this._nodes.forEach(t=>{t.off("."+this._getEventNamespace())}),this._nodes=[],this._resetTransformCache()}_resetTransformCache(){this._clearCache(g),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(g,this.__getNodeRect)}__getNodeShape(t,e=this.rotation(),n){const r=t.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),i=t.getAbsoluteScale(n),o=t.getAbsolutePosition(n),a=r.x*i.x-t.offsetX()*i.x,s=r.y*i.y-t.offsetY()*i.y,l=(c.Konva.getAngle(t.getAbsoluteRotation())+2*Math.PI)%(2*Math.PI);return _({x:o.x+a*Math.cos(l)+s*Math.sin(-l),y:o.y+s*Math.cos(l)+a*Math.sin(l),width:r.width*i.x,height:r.height*i.y,rotation:l},-c.Konva.getAngle(e),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-1e8,y:-1e8,width:0,height:0,rotation:0};const t=[];this.nodes().map(e=>{const n=e.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),r=[{x:n.x,y:n.y},{x:n.x+n.width,y:n.y},{x:n.x+n.width,y:n.y+n.height},{x:n.x,y:n.y+n.height}],i=e.getAbsoluteTransform();r.forEach(function(e){const n=i.point(e);t.push(n)})});const e=new r.Transform;e.rotate(-c.Konva.getAngle(this.rotation()));let n=1/0,i=1/0,o=-1/0,a=-1/0;t.forEach(function(t){const r=e.point(t);void 0===n&&(n=o=r.x,i=a=r.y),n=Math.min(n,r.x),i=Math.min(i,r.y),o=Math.max(o,r.x),a=Math.max(a,r.y)}),e.invert();const s=e.point({x:n,y:i});return{x:s.x,y:s.y,width:o-n,height:a-i,rotation:c.Konva.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),v.forEach(t=>{this._createAnchor(t)}),this._createAnchor("rotater")}_createAnchor(t){const e=new s.Rect({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:t+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:y?10:"auto"}),n=this;e.on("mousedown touchstart",function(t){n._handleMouseDown(t)}),e.on("dragstart",t=>{e.stopDrag(),t.cancelBubble=!0}),e.on("dragend",t=>{t.cancelBubble=!0}),e.on("mouseenter",()=>{const n=c.Konva.getAngle(this.rotation()),i=this.rotateAnchorCursor(),o=function(t,e,n){if("rotater"===t)return n;e+=r.Util.degToRad(m[t]||0);const i=(r.Util.radToDeg(e)%360+360)%360;return r.Util._inRange(i,337.5,360)||r.Util._inRange(i,0,22.5)?"ns-resize":r.Util._inRange(i,22.5,67.5)?"nesw-resize":r.Util._inRange(i,67.5,112.5)?"ew-resize":r.Util._inRange(i,112.5,157.5)?"nwse-resize":r.Util._inRange(i,157.5,202.5)?"ns-resize":r.Util._inRange(i,202.5,247.5)?"nesw-resize":r.Util._inRange(i,247.5,292.5)?"ew-resize":r.Util._inRange(i,292.5,337.5)?"nwse-resize":(r.Util.error("Transformer has unknown angle for cursor detection: "+i),"pointer")}(t,n,i);e.getStage().content&&(e.getStage().content.style.cursor=o),this._cursorChange=!0}),e.on("mouseout",()=>{e.getStage().content&&(e.getStage().content.style.cursor=""),this._cursorChange=!1}),this.add(e)}_createBack(){const t=new a.Shape({name:"back",width:0,height:0,draggable:!0,sceneFunc(t,e){const n=e.getParent(),i=n.padding();t.beginPath(),t.rect(-i,-i,e.width()+2*i,e.height()+2*i),t.moveTo(e.width()/2,-i),n.rotateEnabled()&&n.rotateLineVisible()&&t.lineTo(e.width()/2,-n.rotateAnchorOffset()*r.Util._sign(e.height())-i),t.fillStrokeShape(e)},hitFunc:(t,e)=>{if(!this.shouldOverdrawWholeArea())return;const n=this.padding();t.beginPath(),t.rect(-n,-n,e.width()+2*n,e.height()+2*n),t.fillStrokeShape(e)}});this.add(t),this._proxyDrag(t),t.on("dragstart",t=>{t.cancelBubble=!0}),t.on("dragmove",t=>{t.cancelBubble=!0}),t.on("dragend",t=>{t.cancelBubble=!0}),this.on("dragmove",t=>{this.update()})}_handleMouseDown(t){if(this._transforming)return;this._movingAnchorName=t.target.name().split(" ")[0];const e=this._getNodeRect(),n=e.width,r=e.height,i=Math.sqrt(Math.pow(n,2)+Math.pow(r,2));this.sin=Math.abs(r/i),this.cos=Math.abs(n/i),"undefined"!=typeof window&&(window.addEventListener("mousemove",this._handleMouseMove),window.addEventListener("touchmove",this._handleMouseMove),window.addEventListener("mouseup",this._handleMouseUp,!0),window.addEventListener("touchend",this._handleMouseUp,!0)),this._transforming=!0;const o=t.target.getAbsolutePosition(),a=t.target.getStage().getPointerPosition();this._anchorDragOffset={x:a.x-o.x,y:a.y-o.y},w++,this._fire("transformstart",{evt:t.evt,target:this.getNode()}),this._nodes.forEach(e=>{e._fire("transformstart",{evt:t.evt,target:e})})}_handleMouseMove(t){let e,n,r;const i=this.findOne("."+this._movingAnchorName),o=i.getStage();o.setPointersPositions(t);const a=o.getPointerPosition();let s={x:a.x-this._anchorDragOffset.x,y:a.y-this._anchorDragOffset.y};const l=i.getAbsolutePosition();this.anchorDragBoundFunc()&&(s=this.anchorDragBoundFunc()(l,s,t)),i.setAbsolutePosition(s);const h=i.getAbsolutePosition();if(l.x===h.x&&l.y===h.y)return;if("rotater"===this._movingAnchorName){const r=this._getNodeRect();e=i.x()-r.width/2,n=-i.y()+r.height/2;let o=Math.atan2(-n,e)+Math.PI/2;r.height<0&&(o-=Math.PI);const a=c.Konva.getAngle(this.rotation())+o,s=c.Konva.getAngle(this.rotationSnapTolerance()),l=function(t,e,n){let r=e;for(let i=0;i<t.length;i++){const o=c.Konva.getAngle(t[i]),a=Math.abs(o-e)%(2*Math.PI);Math.min(a,2*Math.PI-a)<n&&(r=o)}return r}(this.rotationSnaps(),a,s),h=function(t,e){const n=function(t){return{x:t.x+t.width/2*Math.cos(t.rotation)+t.height/2*Math.sin(-t.rotation),y:t.y+t.height/2*Math.cos(t.rotation)+t.width/2*Math.sin(t.rotation)}}(t);return _(t,e,n)}(r,l-r.rotation);return void this._fitNodesInto(h,t)}const u=this.shiftBehavior();let d;d="inverted"===u?this.keepRatio()&&!t.shiftKey:"none"===u?this.keepRatio():this.keepRatio()||t.shiftKey;let f=this.centeredScaling()||t.altKey;if("top-left"===this._movingAnchorName){if(d){const t=f?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};r=Math.sqrt(Math.pow(t.x-i.x(),2)+Math.pow(t.y-i.y(),2));const o=this.findOne(".top-left").x()>t.x?-1:1,a=this.findOne(".top-left").y()>t.y?-1:1;e=r*this.cos*o,n=r*this.sin*a,this.findOne(".top-left").x(t.x-e),this.findOne(".top-left").y(t.y-n)}}else if("top-center"===this._movingAnchorName)this.findOne(".top-left").y(i.y());else if("top-right"===this._movingAnchorName){if(d){const t=f?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()};r=Math.sqrt(Math.pow(i.x()-t.x,2)+Math.pow(t.y-i.y(),2));const o=this.findOne(".top-right").x()<t.x?-1:1,a=this.findOne(".top-right").y()>t.y?-1:1;e=r*this.cos*o,n=r*this.sin*a,this.findOne(".top-right").x(t.x+e),this.findOne(".top-right").y(t.y-n)}var g=i.position();this.findOne(".top-left").y(g.y),this.findOne(".bottom-right").x(g.x)}else if("middle-left"===this._movingAnchorName)this.findOne(".top-left").x(i.x());else if("middle-right"===this._movingAnchorName)this.findOne(".bottom-right").x(i.x());else if("bottom-left"===this._movingAnchorName){if(d){const t=f?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()};r=Math.sqrt(Math.pow(t.x-i.x(),2)+Math.pow(i.y()-t.y,2));const o=t.x<i.x()?-1:1,a=i.y()<t.y?-1:1;e=r*this.cos*o,n=r*this.sin*a,i.x(t.x-e),i.y(t.y+n)}g=i.position(),this.findOne(".top-left").x(g.x),this.findOne(".bottom-right").y(g.y)}else if("bottom-center"===this._movingAnchorName)this.findOne(".bottom-right").y(i.y());else if("bottom-right"===this._movingAnchorName){if(d){const t=f?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()};r=Math.sqrt(Math.pow(i.x()-t.x,2)+Math.pow(i.y()-t.y,2));const o=this.findOne(".bottom-right").x()<t.x?-1:1,a=this.findOne(".bottom-right").y()<t.y?-1:1;e=r*this.cos*o,n=r*this.sin*a,this.findOne(".bottom-right").x(t.x+e),this.findOne(".bottom-right").y(t.y+n)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(f=this.centeredScaling()||t.altKey,f){const t=this.findOne(".top-left"),e=this.findOne(".bottom-right"),n=t.x(),r=t.y(),i=this.getWidth()-e.x(),o=this.getHeight()-e.y();e.move({x:-n,y:-r}),t.move({x:i,y:o})}const p=this.findOne(".top-left").getAbsolutePosition();e=p.x,n=p.y;const m=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),y=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:e,y:n,width:m,height:y,rotation:c.Konva.getAngle(this.rotation())},t)}_handleMouseUp(t){this._removeEvents(t)}getAbsoluteTransform(){return this.getTransform()}_removeEvents(t){var e;if(this._transforming){this._transforming=!1,"undefined"!=typeof window&&(window.removeEventListener("mousemove",this._handleMouseMove),window.removeEventListener("touchmove",this._handleMouseMove),window.removeEventListener("mouseup",this._handleMouseUp,!0),window.removeEventListener("touchend",this._handleMouseUp,!0));const n=this.getNode();w--,this._fire("transformend",{evt:t,target:n}),null===(e=this.getLayer())||void 0===e||e.batchDraw(),n&&this._nodes.forEach(e=>{var n;e._fire("transformend",{evt:t,target:e}),null===(n=e.getLayer())||void 0===n||n.batchDraw()}),this._movingAnchorName=null}}_fitNodesInto(t,e){const n=this._getNodeRect();if(r.Util._inRange(t.width,2*-this.padding()-1,1))return void this.update();if(r.Util._inRange(t.height,2*-this.padding()-1,1))return void this.update();const i=new r.Transform;if(i.rotate(c.Konva.getAngle(this.rotation())),this._movingAnchorName&&t.width<0&&this._movingAnchorName.indexOf("left")>=0){const e=i.point({x:2*-this.padding(),y:0});t.x+=e.x,t.y+=e.y,t.width+=2*this.padding(),this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y}else if(this._movingAnchorName&&t.width<0&&this._movingAnchorName.indexOf("right")>=0){const e=i.point({x:2*this.padding(),y:0});this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y,t.width+=2*this.padding()}if(this._movingAnchorName&&t.height<0&&this._movingAnchorName.indexOf("top")>=0){const e=i.point({x:0,y:2*-this.padding()});t.x+=e.x,t.y+=e.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y,t.height+=2*this.padding()}else if(this._movingAnchorName&&t.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const e=i.point({x:0,y:2*this.padding()});this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y,t.height+=2*this.padding()}if(this.boundBoxFunc()){const e=this.boundBoxFunc()(n,t);e?t=e:r.Util.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const o=1e7,a=new r.Transform;a.translate(n.x,n.y),a.rotate(n.rotation),a.scale(n.width/o,n.height/o);const s=new r.Transform,l=t.width/o,h=t.height/o;!1===this.flipEnabled()?(s.translate(t.x,t.y),s.rotate(t.rotation),s.translate(t.width<0?t.width:0,t.height<0?t.height:0),s.scale(Math.abs(l),Math.abs(h))):(s.translate(t.x,t.y),s.rotate(t.rotation),s.scale(l,h));const u=s.multiply(a.invert());this._nodes.forEach(t=>{var e;const n=t.getParent().getAbsoluteTransform(),i=t.getTransform().copy();i.translate(t.offsetX(),t.offsetY());const o=new r.Transform;o.multiply(n.copy().invert()).multiply(u).multiply(n).multiply(i);const a=o.decompose();t.setAttrs(a),null===(e=t.getLayer())||void 0===e||e.batchDraw()}),this.rotation(r.Util._getRotation(t.rotation)),this._nodes.forEach(t=>{this._fire("transform",{evt:e,target:t}),t._fire("transform",{evt:e,target:t})}),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(t,e){this.findOne(t).setAttrs(e)}update(){var t;const e=this._getNodeRect();this.rotation(r.Util._getRotation(e.rotation));const n=e.width,i=e.height,o=this.enabledAnchors(),a=this.resizeEnabled(),s=this.padding(),l=this.anchorSize(),c=this.find("._anchor");c.forEach(t=>{t.setAttrs({width:l,height:l,offsetX:l/2,offsetY:l/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})}),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:l/2+s,offsetY:l/2+s,visible:a&&o.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:n/2,y:0,offsetY:l/2+s,visible:a&&o.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:n,y:0,offsetX:l/2-s,offsetY:l/2+s,visible:a&&o.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:i/2,offsetX:l/2+s,visible:a&&o.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:n,y:i/2,offsetX:l/2-s,visible:a&&o.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:i,offsetX:l/2+s,offsetY:l/2-s,visible:a&&o.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:n/2,y:i,offsetY:l/2-s,visible:a&&o.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:n,y:i,offsetX:l/2-s,offsetY:l/2-s,visible:a&&o.indexOf("bottom-right")>=0}),this._batchChangeChild(".rotater",{x:n/2,y:-this.rotateAnchorOffset()*r.Util._sign(i)-s,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:n,height:i,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),x:0,y:0});const h=this.anchorStyleFunc();h&&c.forEach(t=>{h(t)}),null===(t=this.getLayer())||void 0===t||t.batchDraw()}isTransforming(){return this._transforming}stopTransform(){if(this._transforming){this._removeEvents();const t=this.findOne("."+this._movingAnchorName);t&&t.stopDrag()}}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=""),l.Group.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}toObject(){return o.Node.prototype.toObject.call(this)}clone(t){return o.Node.prototype.clone.call(this,t)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}}e.Transformer=b,b.isTransforming=()=>w>0,b.prototype.className="Transformer",(0,u._registerNode)(b),i.Factory.addGetterSetter(b,"enabledAnchors",v,function(t){return t instanceof Array||r.Util.warn("enabledAnchors value should be an array"),t instanceof Array&&t.forEach(function(t){-1===v.indexOf(t)&&r.Util.warn("Unknown anchor name: "+t+". Available names are: "+v.join(", "))}),t||[]}),i.Factory.addGetterSetter(b,"flipEnabled",!0,(0,h.getBooleanValidator)()),i.Factory.addGetterSetter(b,"resizeEnabled",!0),i.Factory.addGetterSetter(b,"anchorSize",10,(0,h.getNumberValidator)()),i.Factory.addGetterSetter(b,"rotateEnabled",!0),i.Factory.addGetterSetter(b,"rotateLineVisible",!0),i.Factory.addGetterSetter(b,"rotationSnaps",[]),i.Factory.addGetterSetter(b,"rotateAnchorOffset",50,(0,h.getNumberValidator)()),i.Factory.addGetterSetter(b,"rotateAnchorCursor","crosshair"),i.Factory.addGetterSetter(b,"rotationSnapTolerance",5,(0,h.getNumberValidator)()),i.Factory.addGetterSetter(b,"borderEnabled",!0),i.Factory.addGetterSetter(b,"anchorStroke","rgb(0, 161, 255)"),i.Factory.addGetterSetter(b,"anchorStrokeWidth",1,(0,h.getNumberValidator)()),i.Factory.addGetterSetter(b,"anchorFill","white"),i.Factory.addGetterSetter(b,"anchorCornerRadius",0,(0,h.getNumberValidator)()),i.Factory.addGetterSetter(b,"borderStroke","rgb(0, 161, 255)"),i.Factory.addGetterSetter(b,"borderStrokeWidth",1,(0,h.getNumberValidator)()),i.Factory.addGetterSetter(b,"borderDash"),i.Factory.addGetterSetter(b,"keepRatio",!0),i.Factory.addGetterSetter(b,"shiftBehavior","default"),i.Factory.addGetterSetter(b,"centeredScaling",!1),i.Factory.addGetterSetter(b,"ignoreStroke",!1),i.Factory.addGetterSetter(b,"padding",0,(0,h.getNumberValidator)()),i.Factory.addGetterSetter(b,"nodes"),i.Factory.addGetterSetter(b,"node"),i.Factory.addGetterSetter(b,"boundBoxFunc"),i.Factory.addGetterSetter(b,"anchorDragBoundFunc"),i.Factory.addGetterSetter(b,"anchorStyleFunc"),i.Factory.addGetterSetter(b,"shouldOverdrawWholeArea",!1),i.Factory.addGetterSetter(b,"useSingleNodeRotation",!0),i.Factory.backCompat(b,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"})},5072:t=>{"use strict";var e=[];function n(t){for(var n=-1,r=0;r<e.length;r++)if(e[r].identifier===t){n=r;break}return n}function r(t,r){for(var o={},a=[],s=0;s<t.length;s++){var l=t[s],c=r.base?l[0]+r.base:l[0],h=o[c]||0,u="".concat(c," ").concat(h);o[c]=h+1;var d=n(u),f={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==d)e[d].references++,e[d].updater(f);else{var g=i(f,r);r.byIndex=s,e.splice(s,0,{identifier:u,updater:g,references:1})}a.push(u)}return a}function i(t,e){var n=e.domAPI(e);return n.update(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap&&e.supports===t.supports&&e.layer===t.layer)return;n.update(t=e)}else n.remove()}}t.exports=function(t,i){var o=r(t=t||[],i=i||{});return function(t){t=t||[];for(var a=0;a<o.length;a++){var s=n(o[a]);e[s].references--}for(var l=r(t,i),c=0;c<o.length;c++){var h=n(o[c]);0===e[h].references&&(e[h].updater(),e.splice(h,1))}o=l}}},5155:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Rect=void 0;const r=n(4892),i=n(4723),o=n(8871),a=n(4060),s=n(5483);class l extends i.Shape{_sceneFunc(t){const e=this.cornerRadius(),n=this.width(),r=this.height();t.beginPath(),e?a.Util.drawRoundedRectPath(t,n,r,e):t.rect(0,0,n,r),t.closePath(),t.fillStrokeShape(this)}}e.Rect=l,l.prototype.className="Rect",(0,o._registerNode)(l),r.Factory.addGetterSetter(l,"cornerRadius",0,(0,s.getNumberOrArrayOfNumbersValidator)(4))},5451:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Ring=void 0;const r=n(4892),i=n(4723),o=n(5483),a=n(8871),s=2*Math.PI;class l extends i.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.innerRadius(),0,s,!1),t.moveTo(this.outerRadius(),0),t.arc(0,0,this.outerRadius(),s,0,!0),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}}e.Ring=l,l.prototype.className="Ring",l.prototype._centroid=!0,l.prototype._attrsAffectingSize=["innerRadius","outerRadius"],(0,a._registerNode)(l),r.Factory.addGetterSetter(l,"innerRadius",0,(0,o.getNumberValidator)()),r.Factory.addGetterSetter(l,"outerRadius",0,(0,o.getNumberValidator)())},5461:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.HSL=void 0;const r=n(4892),i=n(6536),o=n(5483);r.Factory.addGetterSetter(i.Node,"hue",0,(0,o.getNumberValidator)(),r.Factory.afterSetFilter),r.Factory.addGetterSetter(i.Node,"saturation",0,(0,o.getNumberValidator)(),r.Factory.afterSetFilter),r.Factory.addGetterSetter(i.Node,"luminance",0,(0,o.getNumberValidator)(),r.Factory.afterSetFilter),e.HSL=function(t){const e=t.data,n=e.length,r=Math.pow(2,this.saturation()),i=Math.abs(this.hue()+360)%360,o=127*this.luminance(),a=1*r*Math.cos(i*Math.PI/180),s=1*r*Math.sin(i*Math.PI/180),l=.299+.701*a+.167*s,c=.587-.587*a+.33*s,h=.114-.114*a-.497*s,u=.299-.299*a-.328*s,d=.587+.413*a+.035*s,f=.114-.114*a+.293*s,g=.299-.3*a+1.25*s,p=.587-.586*a-1.05*s,m=.114+.886*a-.2*s;let y,v,_,w;for(let t=0;t<n;t+=4)y=e[t+0],v=e[t+1],_=e[t+2],w=e[t+3],e[t+0]=l*y+c*v+h*_+o,e[t+1]=u*y+d*v+f*_+o,e[t+2]=g*y+p*v+m*_+o,e[t+3]=w}},5483:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RGBComponent=function(t){return t>255?255:t<0?0:Math.round(t)},e.alphaComponent=function(t){return t>1?1:t<1e-4?1e-4:t},e.getNumberValidator=function(){if(r.Konva.isUnminified)return function(t,e){return i.Util._isNumber(t)||i.Util.warn(o(t)+' is a not valid value for "'+e+'" attribute. The value should be a number.'),t}},e.getNumberOrArrayOfNumbersValidator=function(t){if(r.Konva.isUnminified)return function(e,n){let r=i.Util._isNumber(e),a=i.Util._isArray(e)&&e.length==t;return r||a||i.Util.warn(o(e)+' is a not valid value for "'+n+'" attribute. The value should be a number or Array<number>('+t+")"),e}},e.getNumberOrAutoValidator=function(){if(r.Konva.isUnminified)return function(t,e){return i.Util._isNumber(t)||"auto"===t||i.Util.warn(o(t)+' is a not valid value for "'+e+'" attribute. The value should be a number or "auto".'),t}},e.getStringValidator=function(){if(r.Konva.isUnminified)return function(t,e){return i.Util._isString(t)||i.Util.warn(o(t)+' is a not valid value for "'+e+'" attribute. The value should be a string.'),t}},e.getStringOrGradientValidator=function(){if(r.Konva.isUnminified)return function(t,e){const n=i.Util._isString(t),r="[object CanvasGradient]"===Object.prototype.toString.call(t)||t&&t.addColorStop;return n||r||i.Util.warn(o(t)+' is a not valid value for "'+e+'" attribute. The value should be a string or a native gradient.'),t}},e.getFunctionValidator=function(){if(r.Konva.isUnminified)return function(t,e){return i.Util._isFunction(t)||i.Util.warn(o(t)+' is a not valid value for "'+e+'" attribute. The value should be a function.'),t}},e.getNumberArrayValidator=function(){if(r.Konva.isUnminified)return function(t,e){const n=Int8Array?Object.getPrototypeOf(Int8Array):null;return n&&t instanceof n||(i.Util._isArray(t)?t.forEach(function(t){i.Util._isNumber(t)||i.Util.warn('"'+e+'" attribute has non numeric element '+t+". Make sure that all elements are numbers.")}):i.Util.warn(o(t)+' is a not valid value for "'+e+'" attribute. The value should be a array of numbers.')),t}},e.getBooleanValidator=function(){if(r.Konva.isUnminified)return function(t,e){return!0===t||!1===t||i.Util.warn(o(t)+' is a not valid value for "'+e+'" attribute. The value should be a boolean.'),t}},e.getComponentValidator=function(t){if(r.Konva.isUnminified)return function(e,n){return null==e||i.Util.isObject(e)||i.Util.warn(o(e)+' is a not valid value for "'+n+'" attribute. The value should be an object with properties '+t),e}};const r=n(8871),i=n(4060);function o(t){return i.Util._isString(t)?'"'+t+'"':"[object Number]"===Object.prototype.toString.call(t)||i.Util._isBoolean(t)?t:Object.prototype.toString.call(t)}},5540:(t,e,n)=>{"use strict";t=n.hmd(t);var r,i=(r="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,function(t={}){var e,n,i=void 0!==t?t:{};i.ready=new Promise(function(t,r){e=t,n=r});var o,a=Object.assign({},i),s="object"==typeof window,l="function"==typeof importScripts,c=("object"==typeof process&&"object"==typeof process.versions&&process.versions.node,"");(s||l)&&(l?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):"",l&&(o=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)})),i.print||console.log.bind(console);var h,u,d=i.printErr||console.warn.bind(console);Object.assign(i,a),a=null,i.arguments&&i.arguments,i.thisProgram&&i.thisProgram,i.quit&&i.quit,i.wasmBinary&&(h=i.wasmBinary),i.noExitRuntime,"object"!=typeof WebAssembly&&M("no native wasm support detected");var f,g,p,m=!1;function y(){var t=u.buffer;i.HEAP8=f=new Int8Array(t),i.HEAP16=new Int16Array(t),i.HEAP32=new Int32Array(t),i.HEAPU8=g=new Uint8Array(t),i.HEAPU16=new Uint16Array(t),i.HEAPU32=p=new Uint32Array(t),i.HEAPF32=new Float32Array(t),i.HEAPF64=new Float64Array(t)}var v=[],_=[],w=[];function b(t){v.unshift(t)}function C(t){w.unshift(t)}var x,S,A=0,E=null,T=null;function M(t){i.onAbort&&i.onAbort(t),d(t="Aborted("+t+")"),m=!0,t+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(t);throw n(e),e}function P(t){return t.startsWith("data:application/octet-stream;base64,")}function N(t){try{if(t==x&&h)return new Uint8Array(h);if(o)return o(t);throw"both async and sync fetching of the wasm failed"}catch(t){M(t)}}function O(t,e,n){return function(t){return h||!s&&!l||"function"!=typeof fetch?Promise.resolve().then(function(){return N(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 N(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),M(t)})}function F(t){for(;t.length>0;)t.shift()(i)}function R(t){this.excPtr=t,this.ptr=t-24,this.set_type=function(t){p[this.ptr+4>>2]=t},this.get_type=function(){return p[this.ptr+4>>2]},this.set_destructor=function(t){p[this.ptr+8>>2]=t},this.get_destructor=function(){return p[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){p[this.ptr+16>>2]=t},this.get_adjusted_ptr=function(){return p[this.ptr+16>>2]},this.get_exception_ptr=function(){if(W(this.get_type()))return p[this.excPtr>>2];var t=this.get_adjusted_ptr();return 0!==t?t:this.excPtr}}function I(t){var e=u.buffer;try{return u.grow(t-e.byteLength+65535>>>16),y(),1}catch(t){}}function D(t){return i["_"+t]}P(x="wasmDbscan.wasm")||(S=x,x=i.locateFile?i.locateFile(S,c):c+S);var L="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function k(t,e,n,r,i){var o={string:t=>{var e=0;return null!=t&&0!==t&&(e=function(t){var e=function(t){for(var e=0,n=0;n<t.length;++n){var r=t.charCodeAt(n);r<=127?e++:r<=2047?e+=2:r>=55296&&r<=57343?(e+=4,++n):e+=3}return e}(t)+1,n=H(e);return function(t,e,n){!function(t,e,n,r){if(!(r>0))return 0;for(var i=n+r-1,o=0;o<t.length;++o){var a=t.charCodeAt(o);if(a>=55296&&a<=57343&&(a=65536+((1023&a)<<10)|1023&t.charCodeAt(++o)),a<=127){if(n>=i)break;e[n++]=a}else if(a<=2047){if(n+1>=i)break;e[n++]=192|a>>6,e[n++]=128|63&a}else if(a<=65535){if(n+2>=i)break;e[n++]=224|a>>12,e[n++]=128|a>>6&63,e[n++]=128|63&a}else{if(n+3>=i)break;e[n++]=240|a>>18,e[n++]=128|a>>12&63,e[n++]=128|a>>6&63,e[n++]=128|63&a}}e[n]=0}(t,g,e,n)}(t,n,e),n}(t)),e},array:t=>{var e,n,r=H(t.length);return e=t,n=r,f.set(e,n),r}},a=D(t),s=[],l=0;if(r)for(var c=0;c<r.length;c++){var h=o[n[c]];h?(0===l&&(l=B()),s[c]=h(r[c])):s[c]=r[c]}var u=a.apply(null,s);return function(t){return 0!==l&&V(l),function(t){return"string"===e?(n=t)?function(t,e,n){for(var r=e+n,i=e;t[i]&&!(i>=r);)++i;if(i-e>16&&t.buffer&&L)return L.decode(t.subarray(e,i));for(var o="";e<i;){var a=t[e++];if(128&a){var s=63&t[e++];if(192!=(224&a)){var l=63&t[e++];if((a=224==(240&a)?(15&a)<<12|s<<6|l:(7&a)<<18|s<<12|l<<6|63&t[e++])<65536)o+=String.fromCharCode(a);else{var c=a-65536;o+=String.fromCharCode(55296|c>>10,56320|1023&c)}}else o+=String.fromCharCode((31&a)<<6|s)}else o+=String.fromCharCode(a)}return o}(g,n,r):"":"boolean"===e?Boolean(t):t;var n,r}(t)}(u)}var U,G={__cxa_throw:function(t,e,n){throw new R(t).init(e,n),t},abort:function(){M("")},emscripten_memcpy_big:function(t,e,n){g.copyWithin(t,e,e+n)},emscripten_resize_heap:function(t){var e=g.length,n=2147483648;if((t>>>=0)>n)return!1;let r=(t,e)=>t+(e-t%e)%e;for(var i=1;i<=4;i*=2){var o=e*(1+.2/i);if(o=Math.min(o,t+100663296),I(Math.min(n,r(Math.max(t,o),65536))))return!0}return!1}},B=(function(){var t,e,r,o,a={env:G,wasi_snapshot_preview1:G};function s(t,e){var n,r=t.exports;return i.asm=r,u=i.asm.memory,y(),i.asm.__indirect_function_table,n=i.asm.__wasm_call_ctors,_.unshift(n),function(){if(A--,i.monitorRunDependencies&&i.monitorRunDependencies(A),0==A&&(null!==E&&(clearInterval(E),E=null),T)){var t=T;T=null,t()}}(),r}if(A++,i.monitorRunDependencies&&i.monitorRunDependencies(A),i.instantiateWasm)try{return i.instantiateWasm(a,s)}catch(t){d("Module.instantiateWasm callback failed with error: "+t),n(t)}(t=h,e=x,r=a,o=function(t){s(t.instance)},t||"function"!=typeof WebAssembly.instantiateStreaming||P(e)||"function"!=typeof fetch?O(e,r,o):fetch(e,{credentials:"same-origin"}).then(function(t){return WebAssembly.instantiateStreaming(t,r).then(o,function(t){return d("wasm streaming compile failed: "+t),d("falling back to ArrayBuffer instantiation"),O(e,r,o)})})).catch(n)}(),i._dbscan=function(){return(i._dbscan=i.asm.dbscan).apply(null,arguments)},i._malloc=function(){return(i._malloc=i.asm.malloc).apply(null,arguments)},i._free=function(){return(i._free=i.asm.free).apply(null,arguments)},function(){return(B=i.asm.stackSave).apply(null,arguments)}),V=function(){return(V=i.asm.stackRestore).apply(null,arguments)},H=function(){return(H=i.asm.stackAlloc).apply(null,arguments)},W=function(){return(W=i.asm.__cxa_is_pointer_type).apply(null,arguments)};function Y(){function t(){U||(U=!0,i.calledRun=!0,m||(F(_),e(i),i.onRuntimeInitialized&&i.onRuntimeInitialized(),function(){if(i.postRun)for("function"==typeof i.postRun&&(i.postRun=[i.postRun]);i.postRun.length;)C(i.postRun.shift());F(w)}()))}A>0||(function(){if(i.preRun)for("function"==typeof i.preRun&&(i.preRun=[i.preRun]);i.preRun.length;)b(i.preRun.shift());F(v)}(),A>0||(i.setStatus?(i.setStatus("Running..."),setTimeout(function(){setTimeout(function(){i.setStatus("")},1),t()},1)):t()))}if(i.ccall=k,i.cwrap=function(t,e,n,r){var i=!n||n.every(t=>"number"===t||"boolean"===t);return"string"!==e&&i&&!r?D(t):function(){return k(t,e,n,arguments)}},T=function t(){U||Y(),U||(T=t)},i.preInit)for("function"==typeof i.preInit&&(i.preInit=[i.preInit]);i.preInit.length>0;)i.preInit.pop()();return Y(),t.ready});"object"==typeof exports?t.exports=i:"function"==typeof define&&n.amdO?define([],function(){return i}):"object"==typeof exports&&(exports.exportCppDbscanLib=i)},5553:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Kaleidoscope=void 0;const r=n(4892),i=n(6536),o=n(4060),a=n(5483);e.Kaleidoscope=function(t){const e=t.width,n=t.height;let r,i,a,s,l,c,h,u,d,f,g=Math.round(this.kaleidoscopePower());const p=Math.round(this.kaleidoscopeAngle()),m=Math.floor(e*(p%360)/360);if(g<1)return;const y=o.Util.createCanvasElement();y.width=e,y.height=n;const v=y.getContext("2d").getImageData(0,0,e,n);o.Util.releaseCanvas(y),function(t,e,n){const r=t.data,i=e.data,o=t.width,a=t.height,s=n.polarCenterX||o/2,l=n.polarCenterY||a/2;let c=Math.sqrt(s*s+l*l),h=o-s,u=a-l;const d=Math.sqrt(h*h+u*u);c=d>c?d:c;const f=a,g=o,p=360/g*Math.PI/180;for(let t=0;t<g;t+=1){const e=Math.sin(t*p),n=Math.cos(t*p);for(let a=0;a<f;a+=1){h=Math.floor(s+c*a/f*n),u=Math.floor(l+c*a/f*e);let d=4*(u*o+h);const g=r[d+0],p=r[d+1],m=r[d+2],y=r[d+3];d=4*(t+a*o),i[d+0]=g,i[d+1]=p,i[d+2]=m,i[d+3]=y}}}(t,v,{polarCenterX:e/2,polarCenterY:n/2});let _=e/Math.pow(2,g);for(;_<=8;)_*=2,g-=1;_=Math.ceil(_);let w=_,b=0,C=w,x=1;for(m+_>e&&(b=w,C=0,x=-1),i=0;i<n;i+=1)for(r=b;r!==C;r+=x)a=Math.round(r+m)%e,d=4*(e*i+a),l=v.data[d+0],c=v.data[d+1],h=v.data[d+2],u=v.data[d+3],f=4*(e*i+r),v.data[f+0]=l,v.data[f+1]=c,v.data[f+2]=h,v.data[f+3]=u;for(i=0;i<n;i+=1)for(w=Math.floor(_),s=0;s<g;s+=1){for(r=0;r<w+1;r+=1)d=4*(e*i+r),l=v.data[d+0],c=v.data[d+1],h=v.data[d+2],u=v.data[d+3],f=4*(e*i+2*w-r-1),v.data[f+0]=l,v.data[f+1]=c,v.data[f+2]=h,v.data[f+3]=u;w*=2}!function(t,e,n){const r=t.data,i=e.data,o=t.width,a=t.height,s=n.polarCenterX||o/2,l=n.polarCenterY||a/2;let c=Math.sqrt(s*s+l*l),h=o-s,u=a-l;const d=Math.sqrt(h*h+u*u);c=d>c?d:c;const f=a,g=o,p=n.polarRotation||0;let m,y;for(h=0;h<o;h+=1)for(u=0;u<a;u+=1){const t=h-s,e=u-l,n=Math.sqrt(t*t+e*e)*f/c;let a=(180*Math.atan2(e,t)/Math.PI+360+p)%360;a=a*g/360,m=Math.floor(a),y=Math.floor(n);let d=4*(y*o+m);const v=r[d+0],_=r[d+1],w=r[d+2],b=r[d+3];d=4*(u*o+h),i[d+0]=v,i[d+1]=_,i[d+2]=w,i[d+3]=b}}(v,t,{polarRotation:0})},r.Factory.addGetterSetter(i.Node,"kaleidoscopePower",2,(0,a.getNumberValidator)(),r.Factory.afterSetFilter),r.Factory.addGetterSetter(i.Node,"kaleidoscopeAngle",0,(0,a.getNumberValidator)(),r.Factory.afterSetFilter)},5570:(t,e)=>{"use strict";function n(t,e,n){const i=r(1,n,t),o=r(1,n,e),a=i*i+o*o;return Math.sqrt(a)}Object.defineProperty(e,"__esModule",{value:!0}),e.t2length=e.getQuadraticArcLength=e.getCubicArcLength=e.binomialCoefficients=e.cValues=e.tValues=void 0,e.tValues=[[],[],[-.5773502691896257,.5773502691896257],[0,-.7745966692414834,.7745966692414834],[-.33998104358485626,.33998104358485626,-.8611363115940526,.8611363115940526],[0,-.5384693101056831,.5384693101056831,-.906179845938664,.906179845938664],[.6612093864662645,-.6612093864662645,-.2386191860831969,.2386191860831969,-.932469514203152,.932469514203152],[0,.4058451513773972,-.4058451513773972,-.7415311855993945,.7415311855993945,-.9491079123427585,.9491079123427585],[-.1834346424956498,.1834346424956498,-.525532409916329,.525532409916329,-.7966664774136267,.7966664774136267,-.9602898564975363,.9602898564975363],[0,-.8360311073266358,.8360311073266358,-.9681602395076261,.9681602395076261,-.3242534234038089,.3242534234038089,-.6133714327005904,.6133714327005904],[-.14887433898163122,.14887433898163122,-.4333953941292472,.4333953941292472,-.6794095682990244,.6794095682990244,-.8650633666889845,.8650633666889845,-.9739065285171717,.9739065285171717],[0,-.26954315595234496,.26954315595234496,-.5190961292068118,.5190961292068118,-.7301520055740494,.7301520055740494,-.8870625997680953,.8870625997680953,-.978228658146057,.978228658146057],[-.1252334085114689,.1252334085114689,-.3678314989981802,.3678314989981802,-.5873179542866175,.5873179542866175,-.7699026741943047,.7699026741943047,-.9041172563704749,.9041172563704749,-.9815606342467192,.9815606342467192],[0,-.2304583159551348,.2304583159551348,-.44849275103644687,.44849275103644687,-.6423493394403402,.6423493394403402,-.8015780907333099,.8015780907333099,-.9175983992229779,.9175983992229779,-.9841830547185881,.9841830547185881],[-.10805494870734367,.10805494870734367,-.31911236892788974,.31911236892788974,-.5152486363581541,.5152486363581541,-.6872929048116855,.6872929048116855,-.827201315069765,.827201315069765,-.9284348836635735,.9284348836635735,-.9862838086968123,.9862838086968123],[0,-.20119409399743451,.20119409399743451,-.3941513470775634,.3941513470775634,-.5709721726085388,.5709721726085388,-.7244177313601701,.7244177313601701,-.8482065834104272,.8482065834104272,-.937273392400706,.937273392400706,-.9879925180204854,.9879925180204854],[-.09501250983763744,.09501250983763744,-.2816035507792589,.2816035507792589,-.45801677765722737,.45801677765722737,-.6178762444026438,.6178762444026438,-.755404408355003,.755404408355003,-.8656312023878318,.8656312023878318,-.9445750230732326,.9445750230732326,-.9894009349916499,.9894009349916499],[0,-.17848418149584785,.17848418149584785,-.3512317634538763,.3512317634538763,-.5126905370864769,.5126905370864769,-.6576711592166907,.6576711592166907,-.7815140038968014,.7815140038968014,-.8802391537269859,.8802391537269859,-.9506755217687678,.9506755217687678,-.9905754753144174,.9905754753144174],[-.0847750130417353,.0847750130417353,-.2518862256915055,.2518862256915055,-.41175116146284263,.41175116146284263,-.5597708310739475,.5597708310739475,-.6916870430603532,.6916870430603532,-.8037049589725231,.8037049589725231,-.8926024664975557,.8926024664975557,-.9558239495713977,.9558239495713977,-.9915651684209309,.9915651684209309],[0,-.16035864564022537,.16035864564022537,-.31656409996362983,.31656409996362983,-.46457074137596094,.46457074137596094,-.600545304661681,.600545304661681,-.7209661773352294,.7209661773352294,-.8227146565371428,.8227146565371428,-.9031559036148179,.9031559036148179,-.96020815213483,.96020815213483,-.9924068438435844,.9924068438435844],[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],[0,-.1455618541608951,.1455618541608951,-.2880213168024011,.2880213168024011,-.4243421202074388,.4243421202074388,-.5516188358872198,.5516188358872198,-.6671388041974123,.6671388041974123,-.7684399634756779,.7684399634756779,-.8533633645833173,.8533633645833173,-.9200993341504008,.9200993341504008,-.9672268385663063,.9672268385663063,-.9937521706203895,.9937521706203895],[-.06973927331972223,.06973927331972223,-.20786042668822127,.20786042668822127,-.34193582089208424,.34193582089208424,-.469355837986757,.469355837986757,-.5876404035069116,.5876404035069116,-.6944872631866827,.6944872631866827,-.7878168059792081,.7878168059792081,-.8658125777203002,.8658125777203002,-.926956772187174,.926956772187174,-.9700604978354287,.9700604978354287,-.9942945854823992,.9942945854823992],[0,-.1332568242984661,.1332568242984661,-.26413568097034495,.26413568097034495,-.3903010380302908,.3903010380302908,-.5095014778460075,.5095014778460075,-.6196098757636461,.6196098757636461,-.7186613631319502,.7186613631319502,-.8048884016188399,.8048884016188399,-.8767523582704416,.8767523582704416,-.9329710868260161,.9329710868260161,-.9725424712181152,.9725424712181152,-.9947693349975522,.9947693349975522],[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213]],e.cValues=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.12255520671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],e.binomialCoefficients=[[1],[1,1],[1,2,1],[1,3,3,1]],e.getCubicArcLength=(t,r,i)=>{let o,a;const s=i/2;o=0;for(let i=0;i<20;i++)a=s*e.tValues[20][i]+s,o+=e.cValues[20][i]*n(t,r,a);return s*o},e.getQuadraticArcLength=(t,e,n)=>{void 0===n&&(n=1);const r=t[0]-2*t[1]+t[2],i=e[0]-2*e[1]+e[2],o=2*t[1]-2*t[0],a=2*e[1]-2*e[0],s=4*(r*r+i*i),l=4*(r*o+i*a),c=o*o+a*a;if(0===s)return n*Math.sqrt(Math.pow(t[2]-t[0],2)+Math.pow(e[2]-e[0],2));const h=l/(2*s),u=n+h,d=c/s-h*h,f=u*u+d>0?Math.sqrt(u*u+d):0,g=h*h+d>0?Math.sqrt(h*h+d):0,p=h+Math.sqrt(h*h+d)!==0?d*Math.log(Math.abs((u+f)/(h+g))):0;return Math.sqrt(s)/2*(u*f-h*g+p)};const r=(t,n,i)=>{const o=i.length-1;let a,s;if(0===o)return 0;if(0===t){s=0;for(let t=0;t<=o;t++)s+=e.binomialCoefficients[o][t]*Math.pow(1-n,o-t)*Math.pow(n,t)*i[t];return s}a=new Array(o);for(let t=0;t<o;t++)a[t]=o*(i[t+1]-i[t]);return r(t-1,n,a)};e.t2length=(t,e,n)=>{let r=1,i=t/e,o=(t-n(i))/e,a=0;for(;r>.001;){const s=n(i+o),l=Math.abs(t-s)/e;if(l<r)r=l,i+=o;else{const a=n(i-o),s=Math.abs(t-a)/e;s<r?(r=s,i-=o):o/=2}if(a++,a>500)break}return i}},5778:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const r=n(8558);t.exports=r.Konva},5992:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Noise=void 0;const r=n(4892),i=n(6536),o=n(5483);e.Noise=function(t){const e=255*this.noise(),n=t.data,r=n.length,i=e/2;for(let t=0;t<r;t+=4)n[t+0]+=i-2*i*Math.random(),n[t+1]+=i-2*i*Math.random(),n[t+2]+=i-2*i*Math.random()},r.Factory.addGetterSetter(i.Node,"noise",.2,(0,o.getNumberValidator)(),r.Factory.afterSetFilter)},6261:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Blur=void 0;const r=n(4892),i=n(6536),o=n(5483);function a(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}const s=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],l=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];e.Blur=function(t){const e=Math.round(this.blurRadius());e>0&&function(t,e){const n=t.data,r=t.width,i=t.height;let o,c,h,u,d,f,g,p,m,y,v,_,w,b,C,x,S,A,E,T;const M=e+e+1,P=r-1,N=i-1,O=e+1,F=O*(O+1)/2,R=new a,I=s[e],D=l[e];let L=null,k=R,U=null,G=null;for(let t=1;t<M;t++)k=k.next=new a,t===O&&(L=k);k.next=R,h=c=0;for(let t=0;t<i;t++){_=w=b=C=u=d=f=g=0,p=O*(x=n[c]),m=O*(S=n[c+1]),y=O*(A=n[c+2]),v=O*(E=n[c+3]),u+=F*x,d+=F*S,f+=F*A,g+=F*E,k=R;for(let t=0;t<O;t++)k.r=x,k.g=S,k.b=A,k.a=E,k=k.next;for(let t=1;t<O;t++)o=c+((P<t?P:t)<<2),u+=(k.r=x=n[o])*(T=O-t),d+=(k.g=S=n[o+1])*T,f+=(k.b=A=n[o+2])*T,g+=(k.a=E=n[o+3])*T,_+=x,w+=S,b+=A,C+=E,k=k.next;U=R,G=L;for(let t=0;t<r;t++)n[c+3]=E=g*I>>D,0!==E?(E=255/E,n[c]=(u*I>>D)*E,n[c+1]=(d*I>>D)*E,n[c+2]=(f*I>>D)*E):n[c]=n[c+1]=n[c+2]=0,u-=p,d-=m,f-=y,g-=v,p-=U.r,m-=U.g,y-=U.b,v-=U.a,o=h+((o=t+e+1)<P?o:P)<<2,_+=U.r=n[o],w+=U.g=n[o+1],b+=U.b=n[o+2],C+=U.a=n[o+3],u+=_,d+=w,f+=b,g+=C,U=U.next,p+=x=G.r,m+=S=G.g,y+=A=G.b,v+=E=G.a,_-=x,w-=S,b-=A,C-=E,G=G.next,c+=4;h+=r}for(let t=0;t<r;t++){w=b=C=_=d=f=g=u=0,c=t<<2,p=O*(x=n[c]),m=O*(S=n[c+1]),y=O*(A=n[c+2]),v=O*(E=n[c+3]),u+=F*x,d+=F*S,f+=F*A,g+=F*E,k=R;for(let t=0;t<O;t++)k.r=x,k.g=S,k.b=A,k.a=E,k=k.next;let a=r;for(let i=1;i<=e;i++)c=a+t<<2,u+=(k.r=x=n[c])*(T=O-i),d+=(k.g=S=n[c+1])*T,f+=(k.b=A=n[c+2])*T,g+=(k.a=E=n[c+3])*T,_+=x,w+=S,b+=A,C+=E,k=k.next,i<N&&(a+=r);c=t,U=R,G=L;for(let e=0;e<i;e++)o=c<<2,n[o+3]=E=g*I>>D,E>0?(E=255/E,n[o]=(u*I>>D)*E,n[o+1]=(d*I>>D)*E,n[o+2]=(f*I>>D)*E):n[o]=n[o+1]=n[o+2]=0,u-=p,d-=m,f-=y,g-=v,p-=U.r,m-=U.g,y-=U.b,v-=U.a,o=t+((o=e+O)<N?o:N)*r<<2,u+=_+=U.r=n[o],d+=w+=U.g=n[o+1],f+=b+=U.b=n[o+2],g+=C+=U.a=n[o+3],U=U.next,p+=x=G.r,m+=S=G.g,y+=A=G.b,v+=E=G.a,_-=x,w-=S,b-=A,C-=E,G=G.next,c+=r}}(t,e)},r.Factory.addGetterSetter(i.Node,"blurRadius",0,(0,o.getNumberValidator)(),r.Factory.afterSetFilter)},6267:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Layer=void 0;const r=n(4060),i=n(4473),o=n(6536),a=n(4892),s=n(8604),l=n(5483),c=n(4723),h=n(8871),u=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],d=u.length;class f extends i.Container{constructor(t){super(t),this.canvas=new s.SceneCanvas,this.hitCanvas=new s.HitCanvas({pixelRatio:1}),this._waitingForDraw=!1,this.on("visibleChange.konva",this._checkVisibility),this._checkVisibility(),this.on("imageSmoothingEnabledChange.konva",this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(t){return this.getContext().clear(t),this.getHitCanvas().getContext().clear(t),this}setZIndex(t){super.setZIndex(t);const e=this.getStage();return e&&e.content&&(e.content.removeChild(this.getNativeCanvasElement()),t<e.children.length-1?e.content.insertBefore(this.getNativeCanvasElement(),e.children[t+1].getCanvas()._canvas):e.content.appendChild(this.getNativeCanvasElement())),this}moveToTop(){o.Node.prototype.moveToTop.call(this);const t=this.getStage();return t&&t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.appendChild(this.getNativeCanvasElement())),!0}moveUp(){if(!o.Node.prototype.moveUp.call(this))return!1;const t=this.getStage();return!(!t||!t.content||(t.content.removeChild(this.getNativeCanvasElement()),this.index<t.children.length-1?t.content.insertBefore(this.getNativeCanvasElement(),t.children[this.index+1].getCanvas()._canvas):t.content.appendChild(this.getNativeCanvasElement()),0))}moveDown(){if(o.Node.prototype.moveDown.call(this)){const t=this.getStage();if(t){const e=t.children;t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.insertBefore(this.getNativeCanvasElement(),e[this.index+1].getCanvas()._canvas))}return!0}return!1}moveToBottom(){if(o.Node.prototype.moveToBottom.call(this)){const t=this.getStage();if(t){const e=t.children;t.content&&(t.content.removeChild(this.getNativeCanvasElement()),t.content.insertBefore(this.getNativeCanvasElement(),e[1].getCanvas()._canvas))}return!0}return!1}getLayer(){return this}remove(){const t=this.getNativeCanvasElement();return o.Node.prototype.remove.call(this),t&&t.parentNode&&r.Util._isInDocument(t)&&t.parentNode.removeChild(t),this}getStage(){return this.parent}setSize({width:t,height:e}){return this.canvas.setSize(t,e),this.hitCanvas.setSize(t,e),this._setSmoothEnabled(),this}_validateAdd(t){const e=t.getType();"Group"!==e&&"Shape"!==e&&r.Util.throw("You may only add groups and shapes to a layer.")}_toKonvaCanvas(t){return(t=t||{}).width=t.width||this.getWidth(),t.height=t.height||this.getHeight(),t.x=void 0!==t.x?t.x:this.x(),t.y=void 0!==t.y?t.y:this.y(),o.Node.prototype._toKonvaCanvas.call(this,t)}_checkVisibility(){const t=this.visible();this.canvas._canvas.style.display=t?"block":"none"}_setSmoothEnabled(){this.getContext()._context.imageSmoothingEnabled=this.imageSmoothingEnabled()}getWidth(){if(this.parent)return this.parent.width()}setWidth(){r.Util.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){r.Util.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,r.Util.requestAnimFrame(()=>{this.draw(),this._waitingForDraw=!1})),this}getIntersection(t){if(!this.isListening()||!this.isVisible())return null;let e=1,n=!1;for(;;){for(let r=0;r<d;r++){const i=u[r],o=this._getIntersection({x:t.x+i.x*e,y:t.y+i.y*e}),a=o.shape;if(a)return a;if(n=!!o.antialiased,!o.antialiased)break}if(!n)return null;e+=1}}_getIntersection(t){const e=this.hitCanvas.pixelRatio,n=this.hitCanvas.context.getImageData(Math.round(t.x*e),Math.round(t.y*e),1,1).data,i=n[3];if(255===i){const t=r.Util._rgbToHex(n[0],n[1],n[2]),e=c.shapes["#"+t];return e?{shape:e}:{antialiased:!0}}return i>0?{antialiased:!0}:{}}drawScene(t,e,n){const r=this.getLayer(),o=t||r&&r.getCanvas();return this._fire("beforeDraw",{node:this}),this.clearBeforeDraw()&&o.getContext().clear(),i.Container.prototype.drawScene.call(this,o,e,n),this._fire("draw",{node:this}),this}drawHit(t,e){const n=this.getLayer(),r=t||n&&n.hitCanvas;return n&&n.clearBeforeDraw()&&n.getHitCanvas().getContext().clear(),i.Container.prototype.drawHit.call(this,r,e),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(t){r.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(t)}getHitGraphEnabled(t){return r.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening()}toggleHitCanvas(){if(!this.parent||!this.parent.content)return;const t=this.parent;this.hitCanvas._canvas.parentNode?t.content.removeChild(this.hitCanvas._canvas):t.content.appendChild(this.hitCanvas._canvas)}destroy(){return r.Util.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}}e.Layer=f,f.prototype.nodeType="Layer",(0,h._registerNode)(f),a.Factory.addGetterSetter(f,"imageSmoothingEnabled",!0),a.Factory.addGetterSetter(f,"clearBeforeDraw",!0),a.Factory.addGetterSetter(f,"hitGraphEnabled",!0,(0,l.getBooleanValidator)())},6314:t=>{"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map(function(e){var n="",r=void 0!==e[5];return e[4]&&(n+="@supports (".concat(e[4],") {")),e[2]&&(n+="@media ".concat(e[2]," {")),r&&(n+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),n+=t(e),r&&(n+="}"),e[2]&&(n+="}"),e[4]&&(n+="}"),n}).join("")},e.i=function(t,n,r,i,o){"string"==typeof t&&(t=[[null,t,void 0]]);var a={};if(r)for(var s=0;s<this.length;s++){var l=this[s][0];null!=l&&(a[l]=!0)}for(var c=0;c<t.length;c++){var h=[].concat(t[c]);r&&a[h[0]]||(void 0!==o&&(void 0===h[5]||(h[1]="@layer".concat(h[5].length>0?" ".concat(h[5]):""," {").concat(h[1],"}")),h[5]=o),n&&(h[2]?(h[1]="@media ".concat(h[2]," {").concat(h[1],"}"),h[2]=n):h[2]=n),i&&(h[4]?(h[1]="@supports (".concat(h[4],") {").concat(h[1],"}"),h[4]=i):h[4]="".concat(i)),e.push(h))}},e}},6536:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Node=void 0;const r=n(8604),i=n(1268),o=n(4892),a=n(8871),s=n(4060),l=n(5483),c="absoluteOpacity",h="allEventListeners",u="absoluteTransform",d="absoluteScale",f="canvas",g="listening",p="Shape",m=" ",y="stage",v="transform",_="visible",w=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(m);let b=1;class C{constructor(t){this._id=b++,this.eventListeners={},this.attrs={},this.index=0,this._allEventListeners=null,this.parent=null,this._cache=new Map,this._attachedDepsListeners=new Map,this._lastPos=null,this._batchingTransformChange=!1,this._needClearTransformCache=!1,this._filterUpToDate=!1,this._isUnderCache=!1,this._dragEventId=null,this._shouldFireChangeEvents=!1,this.setAttrs(t),this._shouldFireChangeEvents=!0}hasChildren(){return!1}_clearCache(t){t!==v&&t!==u||!this._cache.get(t)?t?this._cache.delete(t):this._cache.clear():this._cache.get(t).dirty=!0}_getCache(t,e){let n=this._cache.get(t);return(void 0===n||(t===v||t===u)&&!0===n.dirty)&&(n=e.call(this),this._cache.set(t,n)),n}_calculate(t,e,n){if(!this._attachedDepsListeners.get(t)){const n=e.map(t=>t+"Change.konva").join(m);this.on(n,()=>{this._clearCache(t)}),this._attachedDepsListeners.set(t,!0)}return this._getCache(t,n)}_getCanvasCache(){return this._cache.get(f)}_clearSelfAndDescendantCache(t){this._clearCache(t),t===u&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(f)){const{scene:t,filter:e,hit:n,buffer:r}=this._cache.get(f);s.Util.releaseCanvas(t,e,n,r),this._cache.delete(f)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(t){const e=t||{};let n={};void 0!==e.x&&void 0!==e.y&&void 0!==e.width&&void 0!==e.height||(n=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}));let i=Math.ceil(e.width||n.width),o=Math.ceil(e.height||n.height),a=e.pixelRatio,l=void 0===e.x?Math.floor(n.x):e.x,h=void 0===e.y?Math.floor(n.y):e.y,u=e.offset||0,g=e.drawBorder||!1,p=e.hitCanvasPixelRatio||1;if(!i||!o)return void s.Util.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");i+=2*u+(Math.abs(Math.round(n.x)-l)>.5?1:0),o+=2*u+(Math.abs(Math.round(n.y)-h)>.5?1:0),l-=u,h-=u;const m=new r.SceneCanvas({pixelRatio:a,width:i,height:o}),y=new r.SceneCanvas({pixelRatio:a,width:0,height:0,willReadFrequently:!0}),v=new r.HitCanvas({pixelRatio:p,width:i,height:o}),_=m.getContext(),w=v.getContext(),b=new r.SceneCanvas({width:m.width/m.pixelRatio+Math.abs(l),height:m.height/m.pixelRatio+Math.abs(h),pixelRatio:m.pixelRatio}),C=b.getContext();return v.isCache=!0,m.isCache=!0,this._cache.delete(f),this._filterUpToDate=!1,!1===e.imageSmoothingEnabled&&(m.getContext()._context.imageSmoothingEnabled=!1,y.getContext()._context.imageSmoothingEnabled=!1),_.save(),w.save(),C.save(),_.translate(-l,-h),w.translate(-l,-h),C.translate(-l,-h),b.x=l,b.y=h,this._isUnderCache=!0,this._clearSelfAndDescendantCache(c),this._clearSelfAndDescendantCache(d),this.drawScene(m,this,b),this.drawHit(v,this),this._isUnderCache=!1,_.restore(),w.restore(),g&&(_.save(),_.beginPath(),_.rect(0,0,i,o),_.closePath(),_.setAttr("strokeStyle","red"),_.setAttr("lineWidth",5),_.stroke(),_.restore()),this._cache.set(f,{scene:m,filter:y,hit:v,buffer:b,x:l,y:h}),this._requestDraw(),this}isCached(){return this._cache.has(f)}getClientRect(t){throw new Error('abstract "getClientRect" method call')}_transformedRect(t,e){const n=[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height},{x:t.x,y:t.y+t.height}];let r=1/0,i=1/0,o=-1/0,a=-1/0;const s=this.getAbsoluteTransform(e);return n.forEach(function(t){const e=s.point(t);void 0===r&&(r=o=e.x,i=a=e.y),r=Math.min(r,e.x),i=Math.min(i,e.y),o=Math.max(o,e.x),a=Math.max(a,e.y)}),{x:r,y:i,width:o-r,height:a-i}}_drawCachedSceneCanvas(t){t.save(),t._applyOpacity(this),t._applyGlobalCompositeOperation(this);const e=this._getCanvasCache();t.translate(e.x,e.y);const n=this._getCachedSceneCanvas(),r=n.pixelRatio;t.drawImage(n._canvas,0,0,n.width/r,n.height/r),t.restore()}_drawCachedHitCanvas(t){const e=this._getCanvasCache(),n=e.hit;t.save(),t.translate(e.x,e.y),t.drawImage(n._canvas,0,0,n.width/n.pixelRatio,n.height/n.pixelRatio),t.restore()}_getCachedSceneCanvas(){let t,e,n,r,i=this.filters(),o=this._getCanvasCache(),a=o.scene,l=o.filter,c=l.getContext();if(i){if(!this._filterUpToDate){const o=a.pixelRatio;l.setSize(a.width/a.pixelRatio,a.height/a.pixelRatio);try{for(t=i.length,c.clear(),c.drawImage(a._canvas,0,0,a.getWidth()/o,a.getHeight()/o),e=c.getImageData(0,0,l.getWidth(),l.getHeight()),n=0;n<t;n++)r=i[n],"function"==typeof r?(r.call(this,e),c.putImageData(e,0,0)):s.Util.error("Filter should be type of function, but got "+typeof r+" instead. Please check correct filters")}catch(t){s.Util.error("Unable to apply filter. "+t.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}this._filterUpToDate=!0}return l}return a}on(t,e){if(this._cache&&this._cache.delete(h),3===arguments.length)return this._delegate.apply(this,arguments);const n=t.split(m);for(let t=0;t<n.length;t++){const r=n[t].split("."),i=r[0],o=r[1]||"";this.eventListeners[i]||(this.eventListeners[i]=[]),this.eventListeners[i].push({name:o,handler:e})}return this}off(t,e){let n,r,i,o,a,s,l=(t||"").split(m),c=l.length;if(this._cache&&this._cache.delete(h),!t)for(r in this.eventListeners)this._off(r);for(n=0;n<c;n++)if(i=l[n],o=i.split("."),a=o[0],s=o[1],a)this.eventListeners[a]&&this._off(a,s,e);else for(r in this.eventListeners)this._off(r,s,e);return this}dispatchEvent(t){const e={target:this,type:t.type,evt:t};return this.fire(t.type,e),this}addEventListener(t,e){return this.on(t,function(t){e.call(this,t.evt)}),this}removeEventListener(t){return this.off(t),this}_delegate(t,e,n){const r=this;this.on(t,function(t){const i=t.target.findAncestors(e,!0,r);for(let e=0;e<i.length;e++)(t=s.Util.cloneObject(t)).currentTarget=i[e],n.call(i[e],t)})}remove(){return this.isDragging()&&this.stopDrag(),i.DD._dragElements.delete(this._id),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(u),this._clearSelfAndDescendantCache(c),this._clearSelfAndDescendantCache(d),this._clearSelfAndDescendantCache(y),this._clearSelfAndDescendantCache(_),this._clearSelfAndDescendantCache(g)}_remove(){this._clearCaches();const t=this.getParent();t&&t.children&&(t.children.splice(this.index,1),t._setChildrenIndices(),this.parent=null)}destroy(){return this.remove(),this.clearCache(),this}getAttr(t){const e="get"+s.Util._capitalize(t);return s.Util._isFunction(this[e])?this[e]():this.attrs[t]}getAncestors(){let t=this.getParent(),e=[];for(;t;)e.push(t),t=t.getParent();return e}getAttrs(){return this.attrs||{}}setAttrs(t){return this._batchTransformChanges(()=>{let e,n;if(!t)return this;for(e in t)"children"!==e&&(n="set"+s.Util._capitalize(e),s.Util._isFunction(this[n])?this[n](t[e]):this._setAttr(e,t[e]))}),this}isListening(){return this._getCache(g,this._isListening)}_isListening(t){if(!this.listening())return!1;const e=this.getParent();return!e||e===t||this===t||e._isListening(t)}isVisible(){return this._getCache(_,this._isVisible)}_isVisible(t){if(!this.visible())return!1;const e=this.getParent();return!e||e===t||this===t||e._isVisible(t)}shouldDrawHit(t,e=!1){if(t)return this._isVisible(t)&&this._isListening(t);const n=this.getLayer();let r=!1;i.DD._dragElements.forEach(t=>{"dragging"===t.dragStatus&&("Stage"===t.node.nodeType||t.node.getLayer()===n)&&(r=!0)});const o=!e&&!a.Konva.hitOnDragEnabled&&(r||a.Konva.isTransforming());return this.isListening()&&this.isVisible()&&!o}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){let t,e,n,r,i=this.getDepth(),o=this,a=0;const s=this.getStage();return"Stage"!==o.nodeType&&s&&function s(l){for(t=[],e=l.length,n=0;n<e;n++)r=l[n],a++,r.nodeType!==p&&(t=t.concat(r.getChildren().slice())),r._id===o._id&&(n=e);t.length>0&&t[0].getDepth()<=i&&s(t)}(s.getChildren()),a}getDepth(){let t=0,e=this.parent;for(;e;)t++,e=e.parent;return t}_batchTransformChanges(t){this._batchingTransformChange=!0,t(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(v),this._clearSelfAndDescendantCache(u)),this._needClearTransformCache=!1}setPosition(t){return this._batchTransformChanges(()=>{this.x(t.x),this.y(t.y)}),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){const t=this.getStage();if(!t)return null;const e=t.getPointerPosition();if(!e)return null;const n=this.getAbsoluteTransform().copy();return n.invert(),n.point(e)}getAbsolutePosition(t){let e=!1,n=this.parent;for(;n;){if(n.isCached()){e=!0;break}n=n.parent}e&&!t&&(t=!0);const r=this.getAbsoluteTransform(t).getMatrix(),i=new s.Transform,o=this.offset();return i.m=r.slice(),i.translate(o.x,o.y),i.getTranslation()}setAbsolutePosition(t){const{x:e,y:n,...r}=this._clearTransform();this.attrs.x=e,this.attrs.y=n,this._clearCache(v);const i=this._getAbsoluteTransform().copy();return i.invert(),i.translate(t.x,t.y),t={x:this.attrs.x+i.getTranslation().x,y:this.attrs.y+i.getTranslation().y},this._setTransform(r),this.setPosition({x:t.x,y:t.y}),this._clearCache(v),this._clearSelfAndDescendantCache(u),this}_setTransform(t){let e;for(e in t)this.attrs[e]=t[e]}_clearTransform(){const t={x:this.x(),y:this.y(),rotation:this.rotation(),scaleX:this.scaleX(),scaleY:this.scaleY(),offsetX:this.offsetX(),offsetY:this.offsetY(),skewX:this.skewX(),skewY:this.skewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,t}move(t){let e=t.x,n=t.y,r=this.x(),i=this.y();return void 0!==e&&(r+=e),void 0!==n&&(i+=n),this.setPosition({x:r,y:i}),this}_eachAncestorReverse(t,e){let n,r,i=[],o=this.getParent();if(!e||e._id!==this._id){for(i.unshift(this);o&&(!e||o._id!==e._id);)i.unshift(o),o=o.parent;for(n=i.length,r=0;r<n;r++)t(i[r])}}rotate(t){return this.rotation(this.rotation()+t),this}moveToTop(){if(!this.parent)return s.Util.warn("Node has no parent. moveToTop function is ignored."),!1;const t=this.index;return t<this.parent.getChildren().length-1&&(this.parent.children.splice(t,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0)}moveUp(){if(!this.parent)return s.Util.warn("Node has no parent. moveUp function is ignored."),!1;const t=this.index;return t<this.parent.getChildren().length-1&&(this.parent.children.splice(t,1),this.parent.children.splice(t+1,0,this),this.parent._setChildrenIndices(),!0)}moveDown(){if(!this.parent)return s.Util.warn("Node has no parent. moveDown function is ignored."),!1;const t=this.index;return t>0&&(this.parent.children.splice(t,1),this.parent.children.splice(t-1,0,this),this.parent._setChildrenIndices(),!0)}moveToBottom(){if(!this.parent)return s.Util.warn("Node has no parent. moveToBottom function is ignored."),!1;const t=this.index;return t>0&&(this.parent.children.splice(t,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0)}setZIndex(t){if(!this.parent)return s.Util.warn("Node has no parent. zIndex parameter is ignored."),this;(t<0||t>=this.parent.children.length)&&s.Util.warn("Unexpected value "+t+" for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to "+(this.parent.children.length-1)+".");const e=this.index;return this.parent.children.splice(e,1),this.parent.children.splice(t,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(c,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){let t=this.opacity();const e=this.getParent();return e&&!e._isUnderCache&&(t*=e.getAbsoluteOpacity()),t}moveTo(t){return this.getParent()!==t&&(this._remove(),t.add(this)),this}toObject(){let t,e,n,r,i,o=this.getAttrs();const a={attrs:{},className:this.getClassName()};for(t in o)e=o[t],i=s.Util.isObject(e)&&!s.Util._isPlainObject(e)&&!s.Util._isArray(e),i||(n="function"==typeof this[t]&&this[t],delete o[t],r=n?n.call(this):null,o[t]=e,r!==e&&(a.attrs[t]=e));return s.Util._prepareToStringify(a)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(t,e,n){const r=[];e&&this._isMatch(t)&&r.push(this);let i=this.parent;for(;i;){if(i===n)return r;i._isMatch(t)&&r.push(i),i=i.parent}return r}isAncestorOf(t){return!1}findAncestor(t,e,n){return this.findAncestors(t,e,n)[0]}_isMatch(t){if(!t)return!1;if("function"==typeof t)return t(this);let e,n,r=t.replace(/ /g,"").split(","),i=r.length;for(e=0;e<i;e++)if(n=r[e],s.Util.isValidSelector(n)||(s.Util.warn('Selector "'+n+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),s.Util.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),s.Util.warn("Konva is awesome, right?")),"#"===n.charAt(0)){if(this.id()===n.slice(1))return!0}else if("."===n.charAt(0)){if(this.hasName(n.slice(1)))return!0}else if(this.className===n||this.nodeType===n)return!0;return!1}getLayer(){const t=this.getParent();return t?t.getLayer():null}getStage(){return this._getCache(y,this._getStage)}_getStage(){const t=this.getParent();return t?t.getStage():null}fire(t,e={},n){return e.target=e.target||this,n?this._fireAndBubble(t,e):this._fire(t,e),this}getAbsoluteTransform(t){return t?this._getAbsoluteTransform(t):this._getCache(u,this._getAbsoluteTransform)}_getAbsoluteTransform(t){let e;if(t)return e=new s.Transform,this._eachAncestorReverse(function(t){const n=t.transformsEnabled();"all"===n?e.multiply(t.getTransform()):"position"===n&&e.translate(t.x()-t.offsetX(),t.y()-t.offsetY())},t),e;{e=this._cache.get(u)||new s.Transform,this.parent?this.parent.getAbsoluteTransform().copyInto(e):e.reset();const t=this.transformsEnabled();if("all"===t)e.multiply(this.getTransform());else if("position"===t){const t=this.attrs.x||0,n=this.attrs.y||0,r=this.attrs.offsetX||0,i=this.attrs.offsetY||0;e.translate(t-r,n-i)}return e.dirty=!1,e}}getAbsoluteScale(t){let e=this;for(;e;)e._isUnderCache&&(t=e),e=e.getParent();const n=this.getAbsoluteTransform(t).decompose();return{x:n.scaleX,y:n.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(v,this._getTransform)}_getTransform(){var t,e;const n=this._cache.get(v)||new s.Transform;n.reset();const r=this.x(),i=this.y(),o=a.Konva.getAngle(this.rotation()),l=null!==(t=this.attrs.scaleX)&&void 0!==t?t:1,c=null!==(e=this.attrs.scaleY)&&void 0!==e?e:1,h=this.attrs.skewX||0,u=this.attrs.skewY||0,d=this.attrs.offsetX||0,f=this.attrs.offsetY||0;return 0===r&&0===i||n.translate(r,i),0!==o&&n.rotate(o),0===h&&0===u||n.skew(h,u),1===l&&1===c||n.scale(l,c),0===d&&0===f||n.translate(-1*d,-1*f),n.dirty=!1,n}clone(t){let e,n,r,i,o,a=s.Util.cloneObject(this.attrs);for(e in t)a[e]=t[e];const l=new this.constructor(a);for(e in this.eventListeners)for(n=this.eventListeners[e],r=n.length,i=0;i<r;i++)o=n[i],o.name.indexOf("konva")<0&&(l.eventListeners[e]||(l.eventListeners[e]=[]),l.eventListeners[e].push(o));return l}_toKonvaCanvas(t){t=t||{};const e=this.getClientRect(),n=this.getStage(),i=void 0!==t.x?t.x:Math.floor(e.x),o=void 0!==t.y?t.y:Math.floor(e.y),a=t.pixelRatio||1,s=new r.SceneCanvas({width:t.width||Math.ceil(e.width)||(n?n.width():0),height:t.height||Math.ceil(e.height)||(n?n.height():0),pixelRatio:a}),l=s.getContext(),c=new r.SceneCanvas({width:s.width/s.pixelRatio+Math.abs(i),height:s.height/s.pixelRatio+Math.abs(o),pixelRatio:s.pixelRatio});return!1===t.imageSmoothingEnabled&&(l._context.imageSmoothingEnabled=!1),l.save(),(i||o)&&l.translate(-1*i,-1*o),this.drawScene(s,void 0,c),l.restore(),s}toCanvas(t){return this._toKonvaCanvas(t)._canvas}toDataURL(t){const e=(t=t||{}).mimeType||null,n=t.quality||null,r=this._toKonvaCanvas(t).toDataURL(e,n);return t.callback&&t.callback(r),r}toImage(t){return new Promise((e,n)=>{try{const n=null==t?void 0:t.callback;n&&delete t.callback,s.Util._urlToImage(this.toDataURL(t),function(t){e(t),null==n||n(t)})}catch(t){n(t)}})}toBlob(t){return new Promise((e,n)=>{try{const n=null==t?void 0:t.callback;n&&delete t.callback,this.toCanvas(t).toBlob(t=>{e(t),null==n||n(t)},null==t?void 0:t.mimeType,null==t?void 0:t.quality)}catch(t){n(t)}})}setSize(t){return this.width(t.width),this.height(t.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){return void 0!==this.attrs.dragDistance?this.attrs.dragDistance:this.parent?this.parent.getDragDistance():a.Konva.dragDistance}_off(t,e,n){let r,i,o,a=this.eventListeners[t];for(r=0;r<a.length;r++)if(i=a[r].name,o=a[r].handler,!("konva"===i&&"konva"!==e||e&&i!==e||n&&n!==o)){if(a.splice(r,1),0===a.length){delete this.eventListeners[t];break}r--}}_fireChangeEvent(t,e,n){this._fire(t+"Change",{oldVal:e,newVal:n})}addName(t){if(!this.hasName(t)){const e=this.name(),n=e?e+" "+t:t;this.name(n)}return this}hasName(t){if(!t)return!1;const e=this.name();return!!e&&-1!==(e||"").split(/\s/g).indexOf(t)}removeName(t){const e=(this.name()||"").split(/\s/g),n=e.indexOf(t);return-1!==n&&(e.splice(n,1),this.name(e.join(" "))),this}setAttr(t,e){const n=this["set"+s.Util._capitalize(t)];return s.Util._isFunction(n)?n.call(this,e):this._setAttr(t,e),this}_requestDraw(){if(a.Konva.autoDrawEnabled){const t=this.getLayer()||this.getStage();null==t||t.batchDraw()}}_setAttr(t,e){const n=this.attrs[t];(n!==e||s.Util.isObject(e))&&(null==e?delete this.attrs[t]:this.attrs[t]=e,this._shouldFireChangeEvents&&this._fireChangeEvent(t,n,e),this._requestDraw())}_setComponentAttr(t,e,n){let r;void 0!==n&&(r=this.attrs[t],r||(this.attrs[t]=this.getAttr(t)),this.attrs[t][e]=n,this._fireChangeEvent(t,r,n))}_fireAndBubble(t,e,n){e&&this.nodeType===p&&(e.target=this);const r=["mouseenter","mouseleave","pointerenter","pointerleave","touchenter","touchleave"];if(-1===r.indexOf(t)||!(n&&(this===n||this.isAncestorOf&&this.isAncestorOf(n))||"Stage"===this.nodeType&&!n)){this._fire(t,e);const i=-1!==r.indexOf(t)&&n&&n.isAncestorOf&&n.isAncestorOf(this)&&!n.isAncestorOf(this.parent);(e&&!e.cancelBubble||!e)&&this.parent&&this.parent.isListening()&&!i&&(n&&n.parent?this._fireAndBubble.call(this.parent,t,e,n):this._fireAndBubble.call(this.parent,t,e))}}_getProtoListeners(t){var e,n,r;const i=null!==(e=this._cache.get(h))&&void 0!==e?e:{};let o=null==i?void 0:i[t];if(void 0===o){o=[];let e=Object.getPrototypeOf(this);for(;e;){const i=null!==(r=null===(n=e.eventListeners)||void 0===n?void 0:n[t])&&void 0!==r?r:[];o.push(...i),e=Object.getPrototypeOf(e)}i[t]=o,this._cache.set(h,i)}return o}_fire(t,e){(e=e||{}).currentTarget=this,e.type=t;const n=this._getProtoListeners(t);if(n)for(let t=0;t<n.length;t++)n[t].handler.call(this,e);const r=this.eventListeners[t];if(r)for(let t=0;t<r.length;t++)r[t].handler.call(this,e)}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(t){const e=t?t.pointerId:void 0,n=this.getStage(),r=this.getAbsolutePosition();if(!n)return;const o=n._getPointerById(e)||n._changedPointerPositions[0]||r;i.DD._dragElements.set(this._id,{node:this,startPointerPos:o,offset:{x:o.x-r.x,y:o.y-r.y},dragStatus:"ready",pointerId:e})}startDrag(t,e=!0){i.DD._dragElements.has(this._id)||this._createDragElement(t),i.DD._dragElements.get(this._id).dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:t&&t.evt},e)}_setDragPosition(t,e){const n=this.getStage()._getPointerById(e.pointerId);if(!n)return;let r={x:n.x-e.offset.x,y:n.y-e.offset.y};const i=this.dragBoundFunc();if(void 0!==i){const e=i.call(this,r,t);e?r=e:s.Util.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}this._lastPos&&this._lastPos.x===r.x&&this._lastPos.y===r.y||(this.setAbsolutePosition(r),this._requestDraw()),this._lastPos=r}stopDrag(t){const e=i.DD._dragElements.get(this._id);e&&(e.dragStatus="stopped"),i.DD._endDragBefore(t),i.DD._endDragAfter(t)}setDraggable(t){this._setAttr("draggable",t),this._dragChange()}isDragging(){const t=i.DD._dragElements.get(this._id);return!!t&&"dragging"===t.dragStatus}_listenDrag(){this._dragCleanup(),this.on("mousedown.konva touchstart.konva",function(t){if(!(void 0===t.evt.button||a.Konva.dragButtons.indexOf(t.evt.button)>=0))return;if(this.isDragging())return;let e=!1;i.DD._dragElements.forEach(t=>{this.isAncestorOf(t.node)&&(e=!0)}),e||this._createDragElement(t)})}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{if(this._dragCleanup(),!this.getStage())return;const t=i.DD._dragElements.get(this._id),e=t&&"dragging"===t.dragStatus,n=t&&"ready"===t.dragStatus;e?this.stopDrag():n&&i.DD._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(t={x:0,y:0}){const e=this.getStage();if(!e)return!1;const n={x:-t.x,y:-t.y,width:e.width()+2*t.x,height:e.height()+2*t.y};return s.Util.haveIntersection(n,this.getClientRect())}static create(t,e){return s.Util._isString(t)&&(t=JSON.parse(t)),this._createNode(t,e)}static _createNode(t,e){let n,r,i,o=C.prototype.getClassName.call(t),l=t.children;if(e&&(t.attrs.container=e),a.Konva[o]||(s.Util.warn('Can not find a node with class name "'+o+'". Fallback to "Shape".'),o="Shape"),n=new(0,a.Konva[o])(t.attrs),l)for(r=l.length,i=0;i<r;i++)n.add(C._createNode(l[i]));return n}}e.Node=C,C.prototype.nodeType="Node",C.prototype._attrsAffectingSize=[],C.prototype.eventListeners={},C.prototype.on.call(C.prototype,w,function(){this._batchingTransformChange?this._needClearTransformCache=!0:(this._clearCache(v),this._clearSelfAndDescendantCache(u))}),C.prototype.on.call(C.prototype,"visibleChange.konva",function(){this._clearSelfAndDescendantCache(_)}),C.prototype.on.call(C.prototype,"listeningChange.konva",function(){this._clearSelfAndDescendantCache(g)}),C.prototype.on.call(C.prototype,"opacityChange.konva",function(){this._clearSelfAndDescendantCache(c)});const x=o.Factory.addGetterSetter;x(C,"zIndex"),x(C,"absolutePosition"),x(C,"position"),x(C,"x",0,(0,l.getNumberValidator)()),x(C,"y",0,(0,l.getNumberValidator)()),x(C,"globalCompositeOperation","source-over",(0,l.getStringValidator)()),x(C,"opacity",1,(0,l.getNumberValidator)()),x(C,"name","",(0,l.getStringValidator)()),x(C,"id","",(0,l.getStringValidator)()),x(C,"rotation",0,(0,l.getNumberValidator)()),o.Factory.addComponentsGetterSetter(C,"scale",["x","y"]),x(C,"scaleX",1,(0,l.getNumberValidator)()),x(C,"scaleY",1,(0,l.getNumberValidator)()),o.Factory.addComponentsGetterSetter(C,"skew",["x","y"]),x(C,"skewX",0,(0,l.getNumberValidator)()),x(C,"skewY",0,(0,l.getNumberValidator)()),o.Factory.addComponentsGetterSetter(C,"offset",["x","y"]),x(C,"offsetX",0,(0,l.getNumberValidator)()),x(C,"offsetY",0,(0,l.getNumberValidator)()),x(C,"dragDistance",void 0,(0,l.getNumberValidator)()),x(C,"width",0,(0,l.getNumberValidator)()),x(C,"height",0,(0,l.getNumberValidator)()),x(C,"listening",!0,(0,l.getBooleanValidator)()),x(C,"preventDefault",!0,(0,l.getBooleanValidator)()),x(C,"filters",void 0,function(t){return this._filterUpToDate=!1,t}),x(C,"visible",!0,(0,l.getBooleanValidator)()),x(C,"transformsEnabled","all",(0,l.getStringValidator)()),x(C,"size"),x(C,"dragBoundFunc"),x(C,"draggable",!1,(0,l.getBooleanValidator)()),o.Factory.backCompat(C,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"})},6564:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Invert=void 0,e.Invert=function(t){const e=t.data,n=e.length;for(let t=0;t<n;t+=4)e[t]=255-e[t],e[t+1]=255-e[t+1],e[t+2]=255-e[t+2]}},6572:function(t){var e;t.exports=(e=function(t,e){var n=Array.prototype.concat,r=Array.prototype.slice,i=Object.prototype.toString;function o(e,n){var r=e>n?e:n;return t.pow(10,17-~~(t.log(r>0?r:-r)*t.LOG10E))}var a=Array.isArray||function(t){return"[object Array]"===i.call(t)};function s(t){return"[object Function]"===i.call(t)}function l(t){return"number"==typeof t&&t-t===0}function c(){return new c._init(arguments)}function h(){return 0}function u(){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(l(t[0]))this[0]=c.seq.apply(null,t),this.length=1;else{if(t[0]instanceof c)return c(t[0].toArray());this[0]=[],this.length=1}return this},c._init.prototype=c.prototype,c._init.constructor=c,c.utils={calcRdx:o,isArray:a,isFunction:s,isNumber:l,toVector:function(t){return n.apply([],t)}},c._random_fn=t.random,c.setRandom=function(t){if("function"!=typeof t)throw new TypeError("fn is not a function");c._random_fn=t},c.extend=function(t){var e,n;if(1===arguments.length){for(n in t)c[n]=t[n];return this}for(e=1;e<arguments.length;e++)for(n in arguments[e])t[n]=arguments[e][n];return t},c.rows=function(t){return t.length||1},c.cols=function(t){return t[0].length||1},c.dimensions=function(t){return{rows:c.rows(t),cols:c.cols(t)}},c.row=function(t,e){return a(e)?e.map(function(e){return c.row(t,e)}):t[e]},c.rowa=function(t,e){return c.row(t,e)},c.col=function(t,e){if(a(e)){var n=c.arange(t.length).map(function(){return new Array(e.length)});return e.forEach(function(e,r){c.arange(t.length).forEach(function(i){n[i][r]=t[i][e]})}),n}for(var r=new Array(t.length),i=0;i<t.length;i++)r[i]=[t[i][e]];return r},c.cola=function(t,e){return c.col(t,e).map(function(t){return t[0]})},c.diag=function(t){for(var e=c.rows(t),n=new Array(e),r=0;r<e;r++)n[r]=[t[r][r]];return n},c.antidiag=function(t){for(var e=c.rows(t)-1,n=new Array(e),r=0;e>=0;e--,r++)n[r]=[t[r][e]];return n},c.transpose=function(t){var e,n,r,i,o,s=[];for(a(t[0])||(t=[t]),n=t.length,r=t[0].length,o=0;o<r;o++){for(e=new Array(n),i=0;i<n;i++)e[i]=t[i][o];s.push(e)}return 1===s.length?s[0]:s},c.map=function(t,e,n){var r,i,o,s,l;for(a(t[0])||(t=[t]),i=t.length,o=t[0].length,s=n?t:new Array(i),r=0;r<i;r++)for(s[r]||(s[r]=new Array(o)),l=0;l<o;l++)s[r][l]=e(t[r][l],r,l);return 1===s.length?s[0]:s},c.cumreduce=function(t,e,n){var r,i,o,s,l;for(a(t[0])||(t=[t]),i=t.length,o=t[0].length,s=n?t:new Array(i),r=0;r<i;r++)for(s[r]||(s[r]=new Array(o)),o>0&&(s[r][0]=t[r][0]),l=1;l<o;l++)s[r][l]=e(s[r][l-1],t[r][l]);return 1===s.length?s[0]:s},c.alter=function(t,e){return c.map(t,e,!0)},c.create=function(t,e,n){var r,i,o=new Array(t);for(s(e)&&(n=e,e=t),r=0;r<t;r++)for(o[r]=new Array(e),i=0;i<e;i++)o[r][i]=n(r,i);return o},c.zeros=function(t,e){return l(e)||(e=t),c.create(t,e,h)},c.ones=function(t,e){return l(e)||(e=t),c.create(t,e,u)},c.rand=function(t,e){return l(e)||(e=t),c.create(t,e,c._random_fn)},c.identity=function(t,e){return l(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,h)},c.seq=function(t,e,n,r){s(r)||(r=!1);var i,a=[],l=o(t,e),c=(e*l-t*l)/((n-1)*l),h=t;for(i=0;h<=e&&i<n;h=(t*l+c*l*++i)/l)a.push(r?r(h,i):h);return a},c.arange=function(t,n,r){var i,o=[];if(r=r||1,n===e&&(n=t,t=0),t===n||0===r)return[];if(t<n&&r<0)return[];if(t>n&&r>0)return[];if(r>0)for(i=t;i<n;i+=r)o.push(i);else for(i=t;i>n;i+=r)o.push(i);return o},c.slice=function(){function t(t,n,r,i){var o,a=[],s=t.length;if(n===e&&r===e&&i===e)return c.copy(t);if(i=i||1,(n=(n=n||0)>=0?n:s+n)===(r=(r=r||t.length)>=0?r:s+r)||0===i)return[];if(n<r&&i<0)return[];if(n>r&&i>0)return[];if(i>0)for(o=n;o<r;o+=i)a.push(t[o]);else for(o=n;o>r;o+=i)a.push(t[o]);return a}return function(e,n){var r,i;return l((n=n||{}).row)?l(n.col)?e[n.row][n.col]:t(c.rowa(e,n.row),(r=n.col||{}).start,r.end,r.step):l(n.col)?t(c.cola(e,n.col),(i=n.row||{}).start,i.end,i.step):(i=n.row||{},r=n.col||{},t(e,i.start,i.end,i.step).map(function(e){return t(e,r.start,r.end,r.step)}))}}(),c.sliceAssign=function(n,r,i){var o,a;if(l(r.row)){if(l(r.col))return n[r.row][r.col]=i;r.col=r.col||{},r.col.start=r.col.start||0,r.col.end=r.col.end||n[0].length,r.col.step=r.col.step||1,o=c.arange(r.col.start,t.min(n.length,r.col.end),r.col.step);var s=r.row;return o.forEach(function(t,e){n[s][t]=i[e]}),n}if(l(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 h=r.col;return a.forEach(function(t,e){n[t][h]=i[e]}),n}return i[0].length===e&&(i=[i]),r.row.start=r.row.start||0,r.row.end=r.row.end||n.length,r.row.step=r.row.step||1,r.col.start=r.col.start||0,r.col.end=r.col.end||n[0].length,r.col.step=r.col.step||1,a=c.arange(r.row.start,t.min(n.length,r.row.end),r.row.step),o=c.arange(r.col.start,t.min(n[0].length,r.col.end),r.col.step),a.forEach(function(t,e){o.forEach(function(r,o){n[t][r]=i[e][o]})}),n},c.diagonal=function(t){var e=c.zeros(t.length,t.length);return t.forEach(function(t,n){e[n][n]=t}),e},c.copy=function(t){return t.map(function(t){return l(t)?t:t.map(function(t){return t})})};var f=c.prototype;return f.length=0,f.push=Array.prototype.push,f.sort=Array.prototype.sort,f.splice=Array.prototype.splice,f.slice=Array.prototype.slice,f.toArray=function(){return this.length>1?r.call(this):r.call(this)[0]},f.map=function(t,e){return c(c.map(this,t,e))},f.cumreduce=function(t,e){return c(c.cumreduce(this,t,e))},f.alter=function(t){return c.alter(this,t),this},function(t){for(var e=0;e<t.length;e++)(function(t){f[t]=function(e){var n,r=this;return e?(setTimeout(function(){e.call(r,f[t].call(r))}),this):(n=c[t](this),a(n)?c(n):n)}})(t[e])}("transpose clear symmetric rows cols dimensions diag antidiag".split(" ")),function(t){for(var e=0;e<t.length;e++)(function(t){f[t]=function(e,n){var r=this;return n?(setTimeout(function(){n.call(r,f[t].call(r,e))}),this):c(c[t](this,e))}})(t[e])}("row col".split(" ")),function(t){for(var e=0;e<t.length;e++)(function(t){f[t]=function(){return c(c[t].apply(null,arguments))}})(t[e])}("create zeros ones rand identity".split(" ")),c}(Math),function(t,e){var n=t.utils.isFunction;function r(t,e){return t-e}function i(t,n,r){return e.max(n,e.min(t,r))}t.sum=function(t){for(var e=0,n=t.length;--n>=0;)e+=t[n];return e},t.sumsqrd=function(t){for(var e=0,n=t.length;--n>=0;)e+=t[n]*t[n];return e},t.sumsqerr=function(e){for(var n,r=t.mean(e),i=0,o=e.length;--o>=0;)i+=(n=e[o]-r)*n;return i},t.sumrow=function(t){for(var e=0,n=t.length;--n>=0;)e+=t[n];return e},t.product=function(t){for(var e=1,n=t.length;--n>=0;)e*=t[n];return e},t.min=function(t){for(var e=t[0],n=0;++n<t.length;)t[n]<e&&(e=t[n]);return e},t.max=function(t){for(var e=t[0],n=0;++n<t.length;)t[n]>e&&(e=t[n]);return e},t.unique=function(t){for(var e={},n=[],r=0;r<t.length;r++)e[t[r]]||(e[t[r]]=!0,n.push(t[r]));return n},t.mean=function(e){return t.sum(e)/e.length},t.meansqerr=function(e){return t.sumsqerr(e)/e.length},t.geomean=function(n){var r=n.map(e.log),i=t.mean(r);return e.exp(i)},t.median=function(t){var e=t.length,n=t.slice().sort(r);return 1&e?n[e/2|0]:(n[e/2-1]+n[e/2])/2},t.cumsum=function(e){return t.cumreduce(e,function(t,e){return t+e})},t.cumprod=function(e){return t.cumreduce(e,function(t,e){return t*e})},t.diff=function(t){var e,n=[],r=t.length;for(e=1;e<r;e++)n.push(t[e]-t[e-1]);return n},t.rank=function(t){var e,n=[],i={};for(e=0;e<t.length;e++)i[l=t[e]]?i[l]++:(i[l]=1,n.push(l));var o=n.sort(r),a={},s=1;for(e=0;e<o.length;e++){var l,c=i[l=o[e]],h=(s+(s+c-1))/2;a[l]=h,s+=c}return t.map(function(t){return a[t]})},t.mode=function(t){var e,n=t.length,i=t.slice().sort(r),o=1,a=0,s=0,l=[];for(e=0;e<n;e++)i[e]===i[e+1]?o++:(o>a?(l=[i[e]],a=o,s=0):o===a&&(l.push(i[e]),s++),o=1);return 0===s?l[0]:l},t.range=function(e){return t.max(e)-t.min(e)},t.variance=function(e,n){return t.sumsqerr(e)/(e.length-(n?1:0))},t.pooledvariance=function(e){return e.reduce(function(e,n){return e+t.sumsqerr(n)},0)/(e.reduce(function(t,e){return t+e.length},0)-e.length)},t.deviation=function(e){for(var n=t.mean(e),r=e.length,i=new Array(r),o=0;o<r;o++)i[o]=e[o]-n;return i},t.stdev=function(n,r){return e.sqrt(t.variance(n,r))},t.pooledstdev=function(n){return e.sqrt(t.pooledvariance(n))},t.meandev=function(n){for(var r=t.mean(n),i=[],o=n.length-1;o>=0;o--)i.push(e.abs(n[o]-r));return t.mean(i)},t.meddev=function(n){for(var r=t.median(n),i=[],o=n.length-1;o>=0;o--)i.push(e.abs(n[o]-r));return t.median(i)},t.coeffvar=function(e){return t.stdev(e)/t.mean(e)},t.quartiles=function(t){var n=t.length,i=t.slice().sort(r);return[i[e.round(n/4)-1],i[e.round(n/2)-1],i[e.round(3*n/4)-1]]},t.quantiles=function(t,n,o,a){var s,l,c,h,u,d=t.slice().sort(r),f=[n.length],g=t.length;for(void 0===o&&(o=3/8),void 0===a&&(a=3/8),s=0;s<n.length;s++)c=g*(l=n[s])+(o+l*(1-o-a)),h=e.floor(i(c,1,g-1)),u=i(c-h,0,1),f[s]=(1-u)*d[h-1]+u*d[h];return f},t.percentile=function(t,e,n){var i=t.slice().sort(r),o=e*(i.length+(n?1:-1))+(n?0:1),a=parseInt(o),s=o-a;return a+1<i.length?i[a-1]+s*(i[a]-i[a-1]):i[a-1]},t.percentileOfScore=function(t,e,n){var r,i,o=0,a=t.length,s=!1;for("strict"===n&&(s=!0),i=0;i<a;i++)r=t[i],(s&&r<e||!s&&r<=e)&&o++;return o/a},t.histogram=function(n,r){r=r||4;var i,o=t.min(n),a=(t.max(n)-o)/r,s=n.length,l=[];for(i=0;i<r;i++)l[i]=0;for(i=0;i<s;i++)l[e.min(e.floor((n[i]-o)/a),r-1)]+=1;return l},t.covariance=function(e,n){var r,i=t.mean(e),o=t.mean(n),a=e.length,s=new Array(a);for(r=0;r<a;r++)s[r]=(e[r]-i)*(n[r]-o);return t.sum(s)/(a-1)},t.corrcoeff=function(e,n){return t.covariance(e,n)/t.stdev(e,1)/t.stdev(n,1)},t.spearmancoeff=function(e,n){return e=t.rank(e),n=t.rank(n),t.corrcoeff(e,n)},t.stanMoment=function(n,r){for(var i=t.mean(n),o=t.stdev(n),a=n.length,s=0,l=0;l<a;l++)s+=e.pow((n[l]-i)/o,r);return s/n.length},t.skewness=function(e){return t.stanMoment(e,3)},t.kurtosis=function(e){return t.stanMoment(e,4)-3};var o=t.prototype;!function(e){for(var r=0;r<e.length;r++)(function(e){o[e]=function(r,i){var a=[],s=0,l=this;if(n(r)&&(i=r,r=!1),i)return setTimeout(function(){i.call(l,o[e].call(l,r))}),this;if(this.length>1){for(l=!0===r?this:this.transpose();s<l.length;s++)a[s]=t[e](l[s]);return a}return t[e](this[0],r)}})(e[r])}("cumsum cumprod".split(" ")),function(e){for(var r=0;r<e.length;r++)(function(e){o[e]=function(r,i){var a=[],s=0,l=this;if(n(r)&&(i=r,r=!1),i)return setTimeout(function(){i.call(l,o[e].call(l,r))}),this;if(this.length>1){for("sumrow"!==e&&(l=!0===r?this:this.transpose());s<l.length;s++)a[s]=t[e](l[s]);return!0===r?t[e](t.utils.toVector(a)):a}return t[e](this[0],r)}})(e[r])}("sum sumsqrd sumsqerr sumrow product min max unique mean meansqerr geomean median diff rank mode range variance deviation stdev meandev meddev coeffvar quartiles histogram skewness kurtosis".split(" ")),function(e){for(var r=0;r<e.length;r++)(function(e){o[e]=function(){var r,i=[],a=0,s=this,l=Array.prototype.slice.call(arguments);if(n(l[l.length-1])){r=l[l.length-1];var c=l.slice(0,l.length-1);return setTimeout(function(){r.call(s,o[e].apply(s,c))}),this}r=void 0;var h=function(n){return t[e].apply(s,[n].concat(l))};if(this.length>1){for(s=s.transpose();a<s.length;a++)i[a]=h(s[a]);return i}return h(this[0])}})(e[r])}("quantiles percentileOfScore".split(" "))}(e,Math),function(t,e){t.gammaln=function(t){var n,r,i,o=0,a=[76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18],s=1.000000000190015;for(i=(r=n=t)+5.5,i-=(n+.5)*e.log(i);o<6;o++)s+=a[o]/++r;return e.log(2.5066282746310007*s/n)-i},t.loggam=function(t){var n,r,i,o,a,s,l,c=[.08333333333333333,-.002777777777777778,.0007936507936507937,-.0005952380952380952,.0008417508417508418,-.001917526917526918,.00641025641025641,-.02955065359477124,.1796443723688307,-1.3924322169059];if(n=t,l=0,1==t||2==t)return 0;for(t<=7&&(n=t+(l=e.floor(7-t))),r=1/(n*n),i=2*e.PI,a=c[9],s=8;s>=0;s--)a*=r,a+=c[s];if(o=a/n+.5*e.log(i)+(n-.5)*e.log(n)-n,t<=7)for(s=1;s<=l;s++)o-=e.log(n-1),n-=1;return o},t.gammafn=function(t){var n,r,i,o,a=[-1.716185138865495,24.76565080557592,-379.80425647094563,629.3311553128184,866.9662027904133,-31451.272968848367,-36144.413418691176,66456.14382024054],s=[-30.8402300119739,315.35062697960416,-1015.1563674902192,-3107.771671572311,22538.11842098015,4755.846277527881,-134659.9598649693,-115132.2596755535],l=!1,c=0,h=0,u=0,d=t;if(t>171.6243769536076)return 1/0;if(d<=0){if(!(o=d%1+36e-17))return 1/0;l=(1&d?-1:1)*e.PI/e.sin(e.PI*o),d=1-d}for(i=d,r=d<1?d++:(d-=c=(0|d)-1)-1,n=0;n<8;++n)u=(u+a[n])*r,h=h*r+s[n];if(o=u/h+1,i<d)o/=i;else if(i>d)for(n=0;n<c;++n)o*=d,d++;return l&&(o=l/o),o},t.gammap=function(e,n){return t.lowRegGamma(e,n)*t.gammafn(e)},t.lowRegGamma=function(n,r){var i,o=t.gammaln(n),a=n,s=1/n,l=s,c=r+1-n,h=1/1e-30,u=1/c,d=u,f=1,g=-~(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<=g;f++)s+=l*=r/++a;return s*e.exp(-r+n*e.log(r)-o)}for(;f<=g;f++)d*=(u=1/(u=(i=-f*(f-n))*u+(c+=2)))*(h=c+i/h);return 1-d*e.exp(-r+n*e.log(r)-o)},t.factorialln=function(e){return e<0?NaN:t.gammaln(e+1)},t.factorial=function(e){return e<0?NaN:t.gammafn(e+1)},t.combination=function(n,r){return n>170||r>170?e.exp(t.combinationln(n,r)):t.factorial(n)/t.factorial(r)/t.factorial(n-r)},t.combinationln=function(e,n){return t.factorialln(e)-t.factorialln(n)-t.factorialln(e-n)},t.permutation=function(e,n){return t.factorial(e)/t.factorial(e-n)},t.betafn=function(n,r){if(!(n<=0||r<=0))return n+r>170?e.exp(t.betaln(n,r)):t.gammafn(n)*t.gammafn(r)/t.gammafn(n+r)},t.betaln=function(e,n){return t.gammaln(e)+t.gammaln(n)-t.gammaln(e+n)},t.betacf=function(t,n,r){var i,o,a,s,l=1e-30,c=1,h=n+r,u=n+1,d=n-1,f=1,g=1-h*t/u;for(e.abs(g)<l&&(g=l),s=g=1/g;c<=100&&(g=1+(o=c*(r-c)*t/((d+(i=2*c))*(n+i)))*g,e.abs(g)<l&&(g=l),f=1+o/f,e.abs(f)<l&&(f=l),s*=(g=1/g)*f,g=1+(o=-(n+c)*(h+c)*t/((n+i)*(u+i)))*g,e.abs(g)<l&&(g=l),f=1+o/f,e.abs(f)<l&&(f=l),s*=a=(g=1/g)*f,!(e.abs(a-1)<3e-7));c++);return s},t.gammapinv=function(n,r){var i,o,a,s,l,c,h=0,u=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?(l=e.log(u),c=e.exp(u*(l-1)-d),s=n<.5?n:1-n,i=(2.30753+.27061*(o=e.sqrt(-2*e.log(s))))/(1+o*(.99229+.04481*o))-o,n<.5&&(i=-i),i=e.max(.001,r*e.pow(1-1/(9*r)-i/(3*e.sqrt(r)),3))):i=n<(o=1-r*(.253+.12*r))?e.pow(n/o,1/r):1-e.log(1-(n-o)/(1-o));h<12;h++){if(i<=0)return 0;if((i-=o=(a=(t.lowRegGamma(r,i)-n)/(o=r>1?c*e.exp(-(i-u)+u*(e.log(i)-l)):e.exp(-i+u*e.log(i)-d)))/(1-.5*e.min(1,a*((r-1)/i-1))))<=0&&(i=.5*(i+o)),e.abs(o)<1e-8*i)break}return i},t.erf=function(t){var n,r,i,o,a=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,1.5626441722e-8,-8.5238095915e-8,6.529054439e-9,5.059343495e-9,-9.91364156e-10,-2.27365122e-10,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18,-1523e-18,-94e-18,121e-18,-28e-18],s=a.length-1,l=!1,c=0,h=0;for(t<0&&(t=-t,l=!0),r=4*(n=2/(2+t))-2;s>0;s--)i=c,c=r*c-h+a[s],h=i;return o=n*e.exp(-t*t+.5*(a[0]+r*c)-h),l?o-1:1-o},t.erfc=function(e){return 1-t.erf(e)},t.erfcinv=function(n){var r,i,o,a,s=0;if(n>=2)return-100;if(n<=0)return 100;for(a=n<1?n:2-n,r=-.70711*((2.30753+.27061*(o=e.sqrt(-2*e.log(a/2))))/(1+o*(.99229+.04481*o))-o);s<2;s++)r+=(i=t.erfc(r)-a)/(1.1283791670955126*e.exp(-r*r)-r*i);return n<1?r:-r},t.ibetainv=function(n,r,i){var o,a,s,l,c,h,u,d,f,g,p=r-1,m=i-1,y=0;if(n<=0)return 0;if(n>=1)return 1;for(r>=1&&i>=1?(s=n<.5?n:1-n,h=(2.30753+.27061*(l=e.sqrt(-2*e.log(s))))/(1+l*(.99229+.04481*l))-l,n<.5&&(h=-h),u=(h*h-3)/6,d=2/(1/(2*r-1)+1/(2*i-1)),f=h*e.sqrt(u+d)/d-(1/(2*i-1)-1/(2*r-1))*(u+5/6-2/(3*d)),h=r/(r+i*e.exp(2*f))):(o=e.log(r/(r+i)),a=e.log(i/(r+i)),h=n<(l=e.exp(r*o)/r)/(f=l+(c=e.exp(i*a)/i))?e.pow(r*f*n,1/r):1-e.pow(i*f*(1-n),1/i)),g=-t.gammaln(r)-t.gammaln(i)+t.gammaln(r+i);y<10;y++){if(0===h||1===h)return h;if((h-=l=(c=(t.ibeta(h,r,i)-n)/(l=e.exp(p*e.log(h)+m*e.log(1-h)+g)))/(1-.5*e.min(1,c*(p/h-m/(1-h)))))<=0&&(h=.5*(h+l)),h>=1&&(h=.5*(h+l+1)),e.abs(l)<1e-8*h&&y>0)break}return h},t.ibeta=function(n,r,i){var o=0===n||1===n?0:e.exp(t.gammaln(r+i)-t.gammaln(r)-t.gammaln(i)+r*e.log(n)+i*e.log(1-n));return!(n<0||n>1)&&(n<(r+1)/(r+i+2)?o*t.betacf(n,r,i)/r:1-o*t.betacf(1-n,i,r)/i)},t.randn=function(n,r){var i,o,a,s,l;if(r||(r=n),n)return t.create(n,r,function(){return t.randn()});do{i=t._random_fn(),o=1.7156*(t._random_fn()-.5),l=(a=i-.449871)*a+(s=e.abs(o)+.386595)*(.196*s-.25472*a)}while(l>.27597&&(l>.27846||o*o>-4*e.log(i)*i*i));return o/i},t.randg=function(n,r,i){var o,a,s,l,c,h,u=n;if(i||(i=r),n||(n=1),r)return(h=t.zeros(r,i)).alter(function(){return t.randg(n)}),h;n<1&&(n+=1),o=n-1/3,a=1/e.sqrt(9*o);do{do{l=1+a*(c=t.randn())}while(l<=0);l*=l*l,s=t._random_fn()}while(s>1-.331*e.pow(c,4)&&e.log(s)>.5*c*c+o*(1-l+e.log(l)));if(n==u)return o*l;do{s=t._random_fn()}while(0===s);return e.pow(s,1/u)*o*l},function(e){for(var n=0;n<e.length;n++)(function(e){t.fn[e]=function(){return t(t.map(this,function(n){return t[e](n)}))}})(e[n])}("gammaln gammafn factorial factorialln".split(" ")),function(e){for(var n=0;n<e.length;n++)(function(e){t.fn[e]=function(){return t(t[e].apply(null,arguments))}})(e[n])}("randn".split(" "))}(e,Math),function(t,e){function n(t,n,r,i){for(var o,a=0,s=1,l=1,c=1,h=0,u=0;e.abs((l-u)/l)>i;)u=l,s=c+(o=-(n+h)*(n+r+h)*t/(n+2*h)/(n+2*h+1))*s,l=(a=l+o*a)+(o=(h+=1)*(r-h)*t/(n+2*h-1)/(n+2*h))*l,a/=c=s+o*c,s/=c,l/=c,c=1;return l/n}function r(n,r,i){var o=[.9815606342467192,.9041172563704749,.7699026741943047,.5873179542866175,.3678314989981802,.1252334085114689],a=[.04717533638651183,.10693932599531843,.16007832854334622,.20316742672306592,.2334925365383548,.24914704581340277],s=.5*n;if(s>=8)return 1;var l,c=2*t.normal.cdf(s,0,1,1,0)-1;c=c>=e.exp(-50/i)?e.pow(c,i):0;for(var h=s,u=(8-s)/(l=n>3?2:3),d=h+u,f=0,g=i-1,p=1;p<=l;p++){for(var m=0,y=.5*(d+h),v=.5*(d-h),_=1;_<=12;_++){var w,b=y+v*(6<_?o[(w=12-_+1)-1]:-o[(w=_)-1]),C=b*b;if(C>60)break;var x=2*t.normal.cdf(b,0,1,1,0)*.5-2*t.normal.cdf(b,n,1,1,0)*.5;x>=e.exp(-30/g)&&(m+=x=a[w-1]*e.exp(-.5*C)*e.pow(x,g))}f+=m*=2*v*i/e.sqrt(2*e.PI),h=d,d+=u}return(c+=f)<=e.exp(-30/r)?0:(c=e.pow(c,r))>=1?1:c}!function(e){for(var n=0;n<e.length;n++)(function(e){t[e]=function t(e,n,r){return this instanceof t?(this._a=e,this._b=n,this._c=r,this):new t(e,n,r)},t.fn[e]=function(n,r,i){var o=t[e](n,r,i);return o.data=this,o},t[e].prototype.sample=function(n){var r=this._a,i=this._b,o=this._c;return n?t.alter(n,function(){return t[e].sample(r,i,o)}):t[e].sample(r,i,o)},function(n){for(var r=0;r<n.length;r++)(function(n){t[e].prototype[n]=function(r){var i=this._a,o=this._b,a=this._c;return r||0===r||(r=this.data),"number"!=typeof r?t.fn.map.call(r,function(r){return t[e][n](r,i,o,a)}):t[e][n](r,i,o,a)}})(n[r])}("pdf cdf inv".split(" ")),function(n){for(var r=0;r<n.length;r++)(function(n){t[e].prototype[n]=function(){return t[e][n](this._a,this._b,this._c)}})(n[r])}("mean median mode variance".split(" "))})(e[n])}("beta centralF cauchy chisquare exponential gamma invgamma kumaraswamy laplace lognormal noncentralt normal pareto studentt weibull uniform binomial negbin hypgeom poisson triangular tukey arcsine".split(" ")),t.extend(t.beta,{pdf:function(n,r,i){return n>1||n<0?0:1==r&&1==i?1:r<512&&i<512?e.pow(n,r-1)*e.pow(1-n,i-1)/t.betafn(r,i):e.exp((r-1)*e.log(n)+(i-1)*e.log(1-n)-t.betaln(r,i))},cdf:function(e,n,r){return e>1||e<0?1*(e>1):t.ibeta(e,n,r)},inv:function(e,n,r){return t.ibetainv(e,n,r)},mean:function(t,e){return t/(t+e)},median:function(e,n){return t.ibetainv(.5,e,n)},mode:function(t,e){return(t-1)/(t+e-2)},sample:function(e,n){var r=t.randg(e);return r/(r+t.randg(n))},variance:function(t,n){return t*n/(e.pow(t+n,2)*(t+n+1))}}),t.extend(t.centralF,{pdf:function(n,r,i){var o;return n<0?0:r<=2?0===n&&r<2?1/0:0===n&&2===r?1:1/t.betafn(r/2,i/2)*e.pow(r/i,r/2)*e.pow(n,r/2-1)*e.pow(1+r/i*n,-(r+i)/2):(o=r*n/(i+n*r),r*(i/(i+n*r))/2*t.binomial.pdf((r-2)/2,(r+i-2)/2,o))},cdf:function(e,n,r){return e<0?0:t.ibeta(n*e/(n*e+r),n/2,r/2)},inv:function(e,n,r){return r/(n*(1/t.ibetainv(e,n/2,r/2)-1))},mean:function(t,e){return e>2?e/(e-2):void 0},mode:function(t,e){return t>2?e*(t-2)/(t*(e+2)):void 0},sample:function(e,n){return 2*t.randg(e/2)/e/(2*t.randg(n/2)/n)},variance:function(t,e){if(!(e<=4))return 2*e*e*(t+e-2)/(t*(e-2)*(e-2)*(e-4))}}),t.extend(t.cauchy,{pdf:function(t,n,r){return r<0?0:r/(e.pow(t-n,2)+e.pow(r,2))/e.PI},cdf:function(t,n,r){return e.atan((t-n)/r)/e.PI+.5},inv:function(t,n,r){return n+r*e.tan(e.PI*(t-.5))},median:function(t){return t},mode:function(t){return t},sample:function(n,r){return t.randn()*e.sqrt(1/(2*t.randg(.5)))*r+n}}),t.extend(t.chisquare,{pdf:function(n,r){return n<0?0:0===n&&2===r?.5:e.exp((r/2-1)*e.log(n)-n/2-r/2*e.log(2)-t.gammaln(r/2))},cdf:function(e,n){return e<0?0:t.lowRegGamma(n/2,e/2)},inv:function(e,n){return 2*t.gammapinv(e,.5*n)},mean:function(t){return t},median:function(t){return t*e.pow(1-2/(9*t),3)},mode:function(t){return t-2>0?t-2:0},sample:function(e){return 2*t.randg(e/2)},variance:function(t){return 2*t}}),t.extend(t.exponential,{pdf:function(t,n){return t<0?0:n*e.exp(-n*t)},cdf:function(t,n){return t<0?0:1-e.exp(-n*t)},inv:function(t,n){return-e.log(1-t)/n},mean:function(t){return 1/t},median:function(t){return 1/t*e.log(2)},mode:function(){return 0},sample:function(n){return-1/n*e.log(t._random_fn())},variance:function(t){return e.pow(t,-2)}}),t.extend(t.gamma,{pdf:function(n,r,i){return n<0?0:0===n&&1===r?1/i:e.exp((r-1)*e.log(n)-n/i-t.gammaln(r)-r*e.log(i))},cdf:function(e,n,r){return e<0?0:t.lowRegGamma(n,e/r)},inv:function(e,n,r){return t.gammapinv(e,n)*r},mean:function(t,e){return t*e},mode:function(t,e){if(t>1)return(t-1)*e},sample:function(e,n){return t.randg(e)*n},variance:function(t,e){return t*e*e}}),t.extend(t.invgamma,{pdf:function(n,r,i){return n<=0?0:e.exp(-(r+1)*e.log(n)-i/n-t.gammaln(r)+r*e.log(i))},cdf:function(e,n,r){return e<=0?0:1-t.lowRegGamma(n,r/e)},inv:function(e,n,r){return r/t.gammapinv(1-e,n)},mean:function(t,e){return t>1?e/(t-1):void 0},mode:function(t,e){return e/(t+1)},sample:function(e,n){return n/t.randg(e)},variance:function(t,e){if(!(t<=2))return e*e/((t-1)*(t-1)*(t-2))}}),t.extend(t.kumaraswamy,{pdf:function(t,n,r){return 0===t&&1===n?r:1===t&&1===r?n:e.exp(e.log(n)+e.log(r)+(n-1)*e.log(t)+(r-1)*e.log(1-e.pow(t,n)))},cdf:function(t,n,r){return t<0?0:t>1?1:1-e.pow(1-e.pow(t,n),r)},inv:function(t,n,r){return e.pow(1-e.pow(1-t,1/r),1/n)},mean:function(e,n){return n*t.gammafn(1+1/e)*t.gammafn(n)/t.gammafn(1+1/e+n)},median:function(t,n){return e.pow(1-e.pow(2,-1/n),1/t)},mode:function(t,n){if(t>=1&&n>=1&&1!==t&&1!==n)return e.pow((t-1)/(t*n-1),1/t)},variance:function(){throw new Error("variance not yet implemented")}}),t.extend(t.lognormal,{pdf:function(t,n,r){return t<=0?0:e.exp(-e.log(t)-.5*e.log(2*e.PI)-e.log(r)-e.pow(e.log(t)-n,2)/(2*r*r))},cdf:function(n,r,i){return n<0?0:.5+.5*t.erf((e.log(n)-r)/e.sqrt(2*i*i))},inv:function(n,r,i){return e.exp(-1.4142135623730951*i*t.erfcinv(2*n)+r)},mean:function(t,n){return e.exp(t+n*n/2)},median:function(t){return e.exp(t)},mode:function(t,n){return e.exp(t-n*n)},sample:function(n,r){return e.exp(t.randn()*r+n)},variance:function(t,n){return(e.exp(n*n)-1)*e.exp(2*t+n*n)}}),t.extend(t.noncentralt,{pdf:function(n,r,i){return e.abs(i)<1e-14?t.studentt.pdf(n,r):e.abs(n)<1e-14?e.exp(t.gammaln((r+1)/2)-i*i/2-.5*e.log(e.PI*r)-t.gammaln(r/2)):r/n*(t.noncentralt.cdf(n*e.sqrt(1+2/r),r+2,i)-t.noncentralt.cdf(n,r,i))},cdf:function(n,r,i){var o=1e-14;if(e.abs(i)<o)return t.studentt.cdf(n,r);var a=!1;n<0&&(a=!0,i=-i);for(var s=t.normal.cdf(-i,0,1),l=o+1,c=l,h=n*n/(n*n+r),u=0,d=e.exp(-i*i/2),f=e.exp(-i*i/2-.5*e.log(2)-t.gammaln(1.5))*i;u<200||c>o||l>o;)c=l,u>0&&(d*=i*i/(2*u),f*=i*i/(2*(u+.5))),s+=.5*(l=d*t.beta.cdf(h,u+.5,r/2)+f*t.beta.cdf(h,u+1,r/2)),u++;return a?1-s:s}}),t.extend(t.normal,{pdf:function(t,n,r){return e.exp(-.5*e.log(2*e.PI)-e.log(r)-e.pow(t-n,2)/(2*r*r))},cdf:function(n,r,i){return.5*(1+t.erf((n-r)/e.sqrt(2*i*i)))},inv:function(e,n,r){return-1.4142135623730951*r*t.erfcinv(2*e)+n},mean:function(t){return t},median:function(t){return t},mode:function(t){return t},sample:function(e,n){return t.randn()*n+e},variance:function(t,e){return e*e}}),t.extend(t.pareto,{pdf:function(t,n,r){return t<n?0:r*e.pow(n,r)/e.pow(t,r+1)},cdf:function(t,n,r){return t<n?0:1-e.pow(n/t,r)},inv:function(t,n,r){return n/e.pow(1-t,1/r)},mean:function(t,n){if(!(n<=1))return n*e.pow(t,n)/(n-1)},median:function(t,n){return t*(n*e.SQRT2)},mode:function(t){return t},variance:function(t,n){if(!(n<=2))return t*t*n/(e.pow(n-1,2)*(n-2))}}),t.extend(t.studentt,{pdf:function(n,r){return r=r>1e100?1e100:r,1/(e.sqrt(r)*t.betafn(.5,r/2))*e.pow(1+n*n/r,-(r+1)/2)},cdf:function(n,r){var i=r/2;return t.ibeta((n+e.sqrt(n*n+r))/(2*e.sqrt(n*n+r)),i,i)},inv:function(n,r){var i=t.ibetainv(2*e.min(n,1-n),.5*r,.5);return i=e.sqrt(r*(1-i)/i),n>.5?i:-i},mean:function(t){return t>1?0:void 0},median:function(){return 0},mode:function(){return 0},sample:function(n){return t.randn()*e.sqrt(n/(2*t.randg(n/2)))},variance:function(t){return t>2?t/(t-2):t>1?1/0:void 0}}),t.extend(t.weibull,{pdf:function(t,n,r){return t<0||n<0||r<0?0:r/n*e.pow(t/n,r-1)*e.exp(-e.pow(t/n,r))},cdf:function(t,n,r){return t<0?0:1-e.exp(-e.pow(t/n,r))},inv:function(t,n,r){return n*e.pow(-e.log(1-t),1/r)},mean:function(e,n){return e*t.gammafn(1+1/n)},median:function(t,n){return t*e.pow(e.log(2),1/n)},mode:function(t,n){return n<=1?0:t*e.pow((n-1)/n,1/n)},sample:function(n,r){return n*e.pow(-e.log(t._random_fn()),1/r)},variance:function(n,r){return n*n*t.gammafn(1+2/r)-e.pow(t.weibull.mean(n,r),2)}}),t.extend(t.uniform,{pdf:function(t,e,n){return t<e||t>n?0:1/(n-e)},cdf:function(t,e,n){return t<e?0:t<n?(t-e)/(n-e):1},inv:function(t,e,n){return e+t*(n-e)},mean:function(t,e){return.5*(t+e)},median:function(e,n){return t.mean(e,n)},mode:function(){throw new Error("mode is not yet implemented")},sample:function(e,n){return e/2+n/2+(n/2-e/2)*(2*t._random_fn()-1)},variance:function(t,n){return e.pow(n-t,2)/12}}),t.extend(t.binomial,{pdf:function(n,r,i){return 0===i||1===i?r*i===n?1:0:t.combination(r,n)*e.pow(i,n)*e.pow(1-i,r-n)},cdf:function(r,i,o){var a,s=1e-10;if(r<0)return 0;if(r>=i)return 1;if(o<0||o>1||i<=0)return NaN;var l=o,c=(r=e.floor(r))+1,h=i-r,u=c+h,d=e.exp(t.gammaln(u)-t.gammaln(h)-t.gammaln(c)+c*e.log(l)+h*e.log(1-l));return a=l<(c+1)/(u+2)?d*n(l,c,h,s):1-d*n(1-l,h,c,s),e.round(1/s*(1-a))/(1/s)}}),t.extend(t.negbin,{pdf:function(n,r,i){return n===n>>>0&&(n<0?0:t.combination(n+r-1,r-1)*e.pow(1-i,n)*e.pow(i,r))},cdf:function(e,n,r){var i=0,o=0;if(e<0)return 0;for(;o<=e;o++)i+=t.negbin.pdf(o,n,r);return i}}),t.extend(t.hypgeom,{pdf:function(n,r,i,o){if(n!=n|0)return!1;if(n<0||n<i-(r-o))return 0;if(n>o||n>i)return 0;if(2*i>r)return 2*o>r?t.hypgeom.pdf(r-i-o+n,r,r-i,r-o):t.hypgeom.pdf(o-n,r,r-i,o);if(2*o>r)return t.hypgeom.pdf(i-n,r,i,r-o);if(i<o)return t.hypgeom.pdf(n,r,o,i);for(var a=1,s=0,l=0;l<n;l++){for(;a>1&&s<o;)a*=1-i/(r-s),s++;a*=(o-l)*(i-l)/((l+1)*(r-i-o+l+1))}for(;s<o;s++)a*=1-i/(r-s);return e.min(1,e.max(0,a))},cdf:function(n,r,i,o){if(n<0||n<i-(r-o))return 0;if(n>=o||n>=i)return 1;if(2*i>r)return 2*o>r?t.hypgeom.cdf(r-i-o+n,r,r-i,r-o):1-t.hypgeom.cdf(o-n-1,r,r-i,o);if(2*o>r)return 1-t.hypgeom.cdf(i-n-1,r,i,r-o);if(i<o)return t.hypgeom.cdf(n,r,o,i);for(var a=1,s=1,l=0,c=0;c<n;c++){for(;a>1&&l<o;){var h=1-i/(r-l);s*=h,a*=h,l++}a+=s*=(o-c)*(i-c)/((c+1)*(r-i-o+c+1))}for(;l<o;l++)a*=1-i/(r-l);return e.min(1,e.max(0,a))}}),t.extend(t.poisson,{pdf:function(n,r){return r<0||n%1!=0||n<0?0:e.pow(r,n)*e.exp(-r)/t.factorial(n)},cdf:function(e,n){var r=[],i=0;if(e<0)return 0;for(;i<=e;i++)r.push(t.poisson.pdf(i,n));return t.sum(r)},mean:function(t){return t},variance:function(t){return t},sampleSmall:function(n){var r=1,i=0,o=e.exp(-n);do{i++,r*=t._random_fn()}while(r>o);return i-1},sampleLarge:function(n){var r,i,o,a,s,l,c,h,u,d,f=n;for(a=e.sqrt(f),s=e.log(f),l=.02483*(c=.931+2.53*a)-.059,h=1.1239+1.1328/(c-3.4),u=.9277-3.6224/(c-2);;){if(i=e.random()-.5,o=e.random(),d=.5-e.abs(i),r=e.floor((2*l/d+c)*i+f+.43),d>=.07&&o<=u)return r;if(!(r<0||d<.013&&o>d)&&e.log(o)+e.log(h)-e.log(l/(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,i){return r<=n||i<n||i>r?NaN:t<=n?0:t>=r?1:t<=i?e.pow(t-n,2)/((r-n)*(i-n)):1-e.pow(r-t,2)/((r-n)*(r-i))},inv:function(t,n,r,i){return r<=n||i<n||i>r?NaN:t<=(i-n)/(r-n)?n+(r-n)*e.sqrt(t*((i-n)/(r-n))):n+(r-n)*(1-e.sqrt((1-t)*(1-(i-n)/(r-n))))},mean:function(t,e,n){return(t+e+n)/3},median:function(t,n,r){return r<=(t+n)/2?n-e.sqrt((n-t)*(n-r))/e.sqrt(2):r>(t+n)/2?t+e.sqrt((n-t)*(r-t))/e.sqrt(2):void 0},mode:function(t,e,n){return n},sample:function(n,r,i){var o=t._random_fn();return o<(i-n)/(r-n)?n+e.sqrt(o*(r-n)*(i-n)):r-e.sqrt((1-o)*(r-n)*(r-i))},variance:function(t,e,n){return(t*t+e*e+n*n-t*e-t*n-e*n)/18}}),t.extend(t.arcsine,{pdf:function(t,n,r){return r<=n?NaN:t<=n||t>=r?0:2/e.PI*e.pow(e.pow(r-n,2)-e.pow(2*t-n-r,2),-.5)},cdf:function(t,n,r){return t<n?0:t<r?2/e.PI*e.asin(e.sqrt((t-n)/(r-n))):1},inv:function(t,n,r){return n+(.5-.5*e.cos(e.PI*t))*(r-n)},mean:function(t,e){return e<=t?NaN:(t+e)/2},median:function(t,e){return e<=t?NaN:(t+e)/2},mode:function(){throw new Error("mode is not yet implemented")},sample:function(n,r){return(n+r)/2+(r-n)/2*e.sin(2*e.PI*t.uniform.sample(0,1))},variance:function(t,n){return n<=t?NaN:e.pow(n-t,2)/8}}),t.extend(t.laplace,{pdf:function(t,n,r){return r<=0?0:e.exp(-e.abs(t-n)/r)/(2*r)},cdf:function(t,n,r){return r<=0?0:t<n?.5*e.exp((t-n)/r):1-.5*e.exp(-(t-n)/r)},mean:function(t){return t},median:function(t){return t},mode:function(t){return t},variance:function(t,e){return 2*e*e},sample:function(n,r){var i,o=t._random_fn()-.5;return n-r*((i=o)/e.abs(i))*e.log(1-2*e.abs(o))}}),t.extend(t.tukey,{cdf:function(n,i,o){var a=i,s=[.9894009349916499,.9445750230732326,.8656312023878318,.755404408355003,.6178762444026438,.45801677765722737,.2816035507792589,.09501250983763744],l=[.027152459411754096,.062253523938647894,.09515851168249279,.12462897125553388,.14959598881657674,.16915651939500254,.18260341504492358,.1894506104550685];if(n<=0)return 0;if(o<2||a<2)return NaN;if(!Number.isFinite(n))return 1;if(o>25e3)return r(n,1,a);var c,h=.5*o,u=h*e.log(o)-o*e.log(2)-t.gammaln(h),d=h-1,f=.25*o;c=o<=100?1:o<=800?.5:o<=5e3?.25:.125,u+=e.log(c);for(var g=0,p=1;p<=50;p++){for(var m=0,y=(2*p-1)*c,v=1;v<=16;v++){var _,w;8<v?(_=v-8-1,w=u+d*e.log(y+s[_]*c)-(s[_]*c+y)*f):(_=v-1,w=u+d*e.log(y-s[_]*c)+(s[_]*c-y)*f),w>=-30&&(m+=r(8<v?n*e.sqrt(.5*(s[_]*c+y)):n*e.sqrt(.5*(-s[_]*c+y)),1,a)*l[_]*e.exp(w))}if(p*c>=1&&m<=1e-14)break;g+=m}if(m>1e-14)throw new Error("tukey.cdf failed to converge");return g>1&&(g=1),g},inv:function(n,r,i){if(i<2||r<2)return NaN;if(n<0||n>1)return NaN;if(0===n)return 0;if(1===n)return 1/0;var o,a=function(t,n,r){var i=.5-.5*t,o=e.sqrt(e.log(1/(i*i))),a=o+((((-453642210148e-16*o-.204231210125)*o-.342242088547)*o-1)*o+.322232421088)/((((.0038560700634*o+.10353775285)*o+.531103462366)*o+.588581570495)*o+.099348462606);r<120&&(a+=(a*a*a+a)/r/4);var s=.8832-.2368*a;return r<120&&(s+=-1.214/r+1.208*a/r),a*(s*e.log(n-1)+1.4142)}(n,r,i),s=t.tukey.cdf(a,r,i)-n;o=s>0?e.max(0,a-1):a+1;for(var l,c=t.tukey.cdf(o,r,i)-n,h=1;h<50;h++)if(l=o-c*(o-a)/(c-s),s=c,a=o,l<0&&(l=0,c=-n),c=t.tukey.cdf(l,r,i)-n,o=l,e.abs(o-a)<1e-4)return l;throw new Error("tukey.inv failed to converge")}})}(e,Math),function(t,e){var n,r,i=Array.prototype.push,o=t.utils.isArray;function a(e){return o(e)||e instanceof t}t.extend({add:function(e,n){return a(n)?(a(n[0])||(n=[n]),t.map(e,function(t,e,r){return t+n[e][r]})):t.map(e,function(t){return t+n})},subtract:function(e,n){return a(n)?(a(n[0])||(n=[n]),t.map(e,function(t,e,r){return t-n[e][r]||0})):t.map(e,function(t){return t-n})},divide:function(e,n){return a(n)?(a(n[0])||(n=[n]),t.multiply(e,t.inv(n))):t.map(e,function(t){return t/n})},multiply:function(e,n){var r,i,o,s,l,c,h,u;if(void 0===e.length&&void 0===n.length)return e*n;if(l=e.length,c=e[0].length,h=t.zeros(l,o=a(n)?n[0].length:c),u=0,a(n)){for(;u<o;u++)for(r=0;r<l;r++){for(s=0,i=0;i<c;i++)s+=e[r][i]*n[i][u];h[r][u]=s}return 1===l&&1===u?h[0][0]:h}return t.map(e,function(t){return t*n})},outer:function(e,n){return t.multiply(e.map(function(t){return[t]}),[n])},dot:function(e,n){a(e[0])||(e=[e]),a(n[0])||(n=[n]);for(var r,i,o=1===e[0].length&&1!==e.length?t.transpose(e):e,s=1===n[0].length&&1!==n.length?t.transpose(n):n,l=[],c=0,h=o.length,u=o[0].length;c<h;c++){for(l[c]=[],r=0,i=0;i<u;i++)r+=o[c][i]*s[c][i];l[c]=r}return 1===l.length?l[0]:l},pow:function(n,r){return t.map(n,function(t){return e.pow(t,r)})},exp:function(n){return t.map(n,function(t){return e.exp(t)})},log:function(n){return t.map(n,function(t){return e.log(t)})},abs:function(n){return t.map(n,function(t){return e.abs(t)})},norm:function(t,n){var r=0,i=0;for(isNaN(n)&&(n=2),a(t[0])&&(t=t[0]);i<t.length;i++)r+=e.pow(e.abs(t[i]),n);return e.pow(r,1/n)},angle:function(n,r){return e.acos(t.dot(n,r)/(t.norm(n)*t.norm(r)))},aug:function(t,e){var n,r=[];for(n=0;n<t.length;n++)r.push(t[n].slice());for(n=0;n<r.length;n++)i.apply(r[n],e[n]);return r},inv:function(e){for(var n,r=e.length,i=e[0].length,o=t.identity(r,i),a=t.gauss_jordan(e,o),s=[],l=0;l<r;l++)for(s[l]=[],n=i;n<a[0].length;n++)s[l][n-i]=a[l][n];return s},det:function t(e){if(2===e.length)return e[0][0]*e[1][1]-e[0][1]*e[1][0];for(var n=0,r=0;r<e.length;r++){for(var i=[],o=1;o<e.length;o++){i[o-1]=[];for(var a=0;a<e.length;a++)a<r?i[o-1][a]=e[o][a]:a>r&&(i[o-1][a-1]=e[o][a])}var s=r%2?-1:1;n+=t(i)*e[0][r]*s}return n},gauss_elimination:function(n,r){var i,o,a,s,l=0,c=0,h=n.length,u=n[0].length,d=1,f=0,g=[];for(i=(n=t.aug(n,r))[0].length,l=0;l<h;l++){for(o=n[l][l],c=l,s=l+1;s<u;s++)o<e.abs(n[s][l])&&(o=n[s][l],c=s);if(c!=l)for(s=0;s<i;s++)a=n[l][s],n[l][s]=n[c][s],n[c][s]=a;for(c=l+1;c<h;c++)for(d=n[c][l]/n[l][l],s=l;s<i;s++)n[c][s]=n[c][s]-d*n[l][s]}for(l=h-1;l>=0;l--){for(f=0,c=l+1;c<=h-1;c++)f+=g[c]*n[l][c];g[l]=(n[l][i-1]-f)/n[l][l]}return g},gauss_jordan:function(n,r){var i,o,a,s=t.aug(n,r),l=s.length,c=s[0].length,h=0;for(o=0;o<l;o++){var u=o;for(a=o+1;a<l;a++)e.abs(s[a][o])>e.abs(s[u][o])&&(u=a);var d=s[o];for(s[o]=s[u],s[u]=d,a=o+1;a<l;a++)for(h=s[a][o]/s[o][o],i=o;i<c;i++)s[a][i]-=s[o][i]*h}for(o=l-1;o>=0;o--){for(h=s[o][o],a=0;a<o;a++)for(i=c-1;i>o-1;i--)s[a][i]-=s[o][i]*s[a][o]/h;for(s[o][o]/=h,i=l;i<c;i++)s[o][i]/=h}return s},triaUpSolve:function(e,n){var r,i=e[0].length,o=t.zeros(1,i)[0],a=!1;return null!=n[0].length&&(n=n.map(function(t){return t[0]}),a=!0),t.arange(i-1,-1,-1).forEach(function(a){r=t.arange(a+1,i).map(function(t){return o[t]*e[a][t]}),o[a]=(n[a]-t.sum(r))/e[a][a]}),a?o.map(function(t){return[t]}):o},triaLowSolve:function(e,n){var r,i=e[0].length,o=t.zeros(1,i)[0],a=!1;return null!=n[0].length&&(n=n.map(function(t){return t[0]}),a=!0),t.arange(i).forEach(function(i){r=t.arange(i).map(function(t){return e[i][t]*o[t]}),o[i]=(n[i]-t.sum(r))/e[i][i]}),a?o.map(function(t){return[t]}):o},lu:function(e){var n,r=e.length,i=t.identity(r),o=t.zeros(e.length,e[0].length);return t.arange(r).forEach(function(t){o[0][t]=e[0][t]}),t.arange(1,r).forEach(function(a){t.arange(a).forEach(function(r){n=t.arange(r).map(function(t){return i[a][t]*o[t][r]}),i[a][r]=(e[a][r]-t.sum(n))/o[r][r]}),t.arange(a,r).forEach(function(r){n=t.arange(a).map(function(t){return i[a][t]*o[t][r]}),o[a][r]=e[n.length][r]-t.sum(n)})}),[i,o]},cholesky:function(n){var r,i=n.length,o=t.zeros(n.length,n[0].length);return t.arange(i).forEach(function(a){r=t.arange(a).map(function(t){return e.pow(o[a][t],2)}),o[a][a]=e.sqrt(n[a][a]-t.sum(r)),t.arange(a+1,i).forEach(function(e){r=t.arange(a).map(function(t){return o[a][t]*o[e][t]}),o[e][a]=(n[a][e]-t.sum(r))/o[a][a]})}),o},gauss_jacobi:function(n,r,i,o){for(var a,s,l,c,h=0,u=0,d=n.length,f=[],g=[],p=[];h<d;h++)for(f[h]=[],g[h]=[],p[h]=[],u=0;u<d;u++)h>u?(f[h][u]=n[h][u],g[h][u]=p[h][u]=0):h<u?(g[h][u]=n[h][u],f[h][u]=p[h][u]=0):(p[h][u]=n[h][u],f[h][u]=g[h][u]=0);for(l=t.multiply(t.multiply(t.inv(p),t.add(f,g)),-1),s=t.multiply(t.inv(p),r),a=i,c=t.add(t.multiply(l,i),s),h=2;e.abs(t.norm(t.subtract(c,a)))>o;)a=c,c=t.add(t.multiply(l,a),s),h++;return c},gauss_seidel:function(n,r,i,o){for(var a,s,l,c,h,u=0,d=n.length,f=[],g=[],p=[];u<d;u++)for(f[u]=[],g[u]=[],p[u]=[],a=0;a<d;a++)u>a?(f[u][a]=n[u][a],g[u][a]=p[u][a]=0):u<a?(g[u][a]=n[u][a],f[u][a]=p[u][a]=0):(p[u][a]=n[u][a],f[u][a]=g[u][a]=0);for(c=t.multiply(t.multiply(t.inv(t.add(p,f)),g),-1),l=t.multiply(t.inv(t.add(p,f)),r),s=i,h=t.add(t.multiply(c,i),l),u=2;e.abs(t.norm(t.subtract(h,s)))>o;)s=h,h=t.add(t.multiply(c,s),l),u+=1;return h},SOR:function(n,r,i,o,a){for(var s,l,c,h,u,d=0,f=n.length,g=[],p=[],m=[];d<f;d++)for(g[d]=[],p[d]=[],m[d]=[],s=0;s<f;s++)d>s?(g[d][s]=n[d][s],p[d][s]=m[d][s]=0):d<s?(p[d][s]=n[d][s],g[d][s]=m[d][s]=0):(m[d][s]=n[d][s],g[d][s]=p[d][s]=0);for(h=t.multiply(t.inv(t.add(m,t.multiply(g,a))),t.subtract(t.multiply(m,1-a),t.multiply(p,a))),c=t.multiply(t.multiply(t.inv(t.add(m,t.multiply(g,a))),r),a),l=i,u=t.add(t.multiply(h,i),c),d=2;e.abs(t.norm(t.subtract(u,l)))>o;)l=u,u=t.add(t.multiply(h,l),c),d++;return u},householder:function(n){for(var r,i,o,a,s=n.length,l=n[0].length,c=0,h=[],u=[];c<s-1;c++){for(r=0,a=c+1;a<l;a++)r+=n[a][c]*n[a][c];for(r=(n[c+1][c]>0?-1:1)*e.sqrt(r),i=e.sqrt((r*r-n[c+1][c]*r)/2),(h=t.zeros(s,1))[c+1][0]=(n[c+1][c]-r)/(2*i),o=c+2;o<s;o++)h[o][0]=n[o][c]/(2*i);u=t.subtract(t.identity(s,l),t.multiply(t.multiply(h,t.transpose(h)),2)),n=t.multiply(u,t.multiply(n,u))}return n},QR:(n=t.sum,r=t.arange,function(i){var o,a,s,l=i.length,c=i[0].length,h=t.zeros(c,c);for(i=t.copy(i),a=0;a<c;a++){for(h[a][a]=e.sqrt(n(r(l).map(function(t){return i[t][a]*i[t][a]}))),o=0;o<l;o++)i[o][a]=i[o][a]/h[a][a];for(s=a+1;s<c;s++)for(h[a][s]=n(r(l).map(function(t){return i[t][a]*i[t][s]})),o=0;o<l;o++)i[o][s]=i[o][s]-i[o][a]*h[a][s]}return[i,h]}),lstsq:function(e,n){var r=!1;void 0===n[0].length&&(n=n.map(function(t){return[t]}),r=!0);var i=t.QR(e),o=i[0],a=i[1],s=e[0].length,l=t.slice(o,{col:{end:s}}),c=function(e){var n=(e=t.copy(e)).length,r=t.identity(n);return t.arange(n-1,-1,-1).forEach(function(n){t.sliceAssign(r,{row:n},t.divide(t.slice(r,{row:n}),e[n][n])),t.sliceAssign(e,{row:n},t.divide(t.slice(e,{row:n}),e[n][n])),t.arange(n).forEach(function(i){var o=t.multiply(e[i][n],-1),a=t.slice(e,{row:i}),s=t.multiply(t.slice(e,{row:n}),o);t.sliceAssign(e,{row:i},t.add(a,s));var l=t.slice(r,{row:i}),c=t.multiply(t.slice(r,{row:n}),o);t.sliceAssign(r,{row:i},t.add(l,c))})}),r}(t.slice(a,{row:{end:s}})),h=t.transpose(l);void 0===h[0].length&&(h=[h]);var u=t.multiply(t.multiply(c,h),n);return void 0===u.length&&(u=[[u]]),r?u.map(function(t){return t[0]}):u},jacobi:function(n){for(var r,i,o,a,s,l,c,h=1,u=n.length,d=t.identity(u,u),f=[];1===h;){for(s=n[0][1],o=0,a=1,r=0;r<u;r++)for(i=0;i<u;i++)r!=i&&s<e.abs(n[r][i])&&(s=e.abs(n[r][i]),o=r,a=i);for(l=n[o][o]===n[a][a]?n[o][a]>0?e.PI/4:-e.PI/4:e.atan(2*n[o][a]/(n[o][o]-n[a][a]))/2,(c=t.identity(u,u))[o][o]=e.cos(l),c[o][a]=-e.sin(l),c[a][o]=e.sin(l),c[a][a]=e.cos(l),d=t.multiply(d,c),n=t.multiply(t.multiply(t.inv(c),n),c),h=0,r=1;r<u;r++)for(i=1;i<u;i++)r!=i&&e.abs(n[r][i])>.001&&(h=1)}for(r=0;r<u;r++)f.push(n[r][r]);return[d,f]},rungekutta:function(t,e,n,r,i,o){var a,s,l;if(2===o)for(;r<=n;)i+=((a=e*t(r,i))+(s=e*t(r+e,i+a)))/2,r+=e;if(4===o)for(;r<=n;)i+=((a=e*t(r,i))+2*(s=e*t(r+e/2,i+a/2))+2*(l=e*t(r+e/2,i+s/2))+e*t(r+e,i+l))/6,r+=e;return i},romberg:function(t,n,r,i){for(var o,a,s,l,c,h=0,u=(r-n)/2,d=[],f=[],g=[];h<i/2;){for(c=t(n),s=n,l=0;s<=r;s+=u,l++)d[l]=s;for(o=d.length,s=1;s<o-1;s++)c+=(s%2!=0?4:2)*t(d[s]);c=u/3*(c+t(r)),g[h]=c,u/=2,h++}for(a=g.length,o=1;1!==a;){for(s=0;s<a-1;s++)f[s]=(e.pow(4,o)*g[s+1]-g[s])/(e.pow(4,o)-1);a=f.length,g=f,f=[],o++}return g},richardson:function(t,n,r,i){function o(t,e){for(var n,r=0,i=t.length;r<i;r++)t[r]===e&&(n=r);return n}for(var a,s,l,c,h,u=e.abs(r-t[o(t,r)+1]),d=0,f=[],g=[];i>=u;)a=o(t,r+i),s=o(t,r),f[d]=(n[a]-2*n[s]+n[2*s-a])/(i*i),i/=2,d++;for(c=f.length,l=1;1!=c;){for(h=0;h<c-1;h++)g[h]=(e.pow(4,l)*f[h+1]-f[h])/(e.pow(4,l)-1);c=g.length,f=g,g=[],l++}return f},simpson:function(t,e,n,r){for(var i,o=(n-e)/r,a=t(e),s=[],l=e,c=0,h=1;l<=n;l+=o,c++)s[c]=l;for(i=s.length;h<i-1;h++)a+=(h%2!=0?4:2)*t(s[h]);return o/3*(a+t(n))},hermite:function(t,e,n,r){for(var i,o=t.length,a=0,s=0,l=[],c=[],h=[],u=[];s<o;s++){for(l[s]=1,i=0;i<o;i++)s!=i&&(l[s]*=(r-t[i])/(t[s]-t[i]));for(c[s]=0,i=0;i<o;i++)s!=i&&(c[s]+=1/(t[s]-t[i]));h[s]=(1-2*(r-t[s])*c[s])*(l[s]*l[s]),u[s]=(r-t[s])*(l[s]*l[s]),a+=h[s]*e[s]+u[s]*n[s]}return a},lagrange:function(t,e,n){for(var r,i,o=0,a=0,s=t.length;a<s;a++){for(i=e[a],r=0;r<s;r++)a!=r&&(i*=(n-t[r])/(t[a]-t[r]));o+=i}return o},cubic_spline:function(e,n,r){for(var i,o,a=e.length,s=0,l=[],c=[],h=[],u=[],d=[],f=[];s<a-1;s++)u[s]=e[s+1]-e[s];for(h[0]=0,s=1;s<a-1;s++)h[s]=3/u[s]*(n[s+1]-n[s])-3/u[s-1]*(n[s]-n[s-1]);for(s=1;s<a-1;s++)l[s]=[],c[s]=[],l[s][s-1]=u[s-1],l[s][s]=2*(u[s-1]+u[s]),l[s][s+1]=u[s],c[s][0]=h[s];for(o=t.multiply(t.inv(l),c),i=0;i<a-1;i++)d[i]=(n[i+1]-n[i])/u[i]-u[i]*(o[i+1][0]+2*o[i][0])/3,f[i]=(o[i+1][0]-o[i][0])/(3*u[i]);for(i=0;i<a&&!(e[i]>r);i++);return n[i-=1]+(r-e[i])*d[i]+t.sq(r-e[i])*o[i]+(r-e[i])*t.sq(r-e[i])*f[i]},gauss_quadrature:function(){throw new Error("gauss_quadrature not yet implemented")},PCA:function(e){var n,r,i,o,a,s=e.length,l=e[0].length,c=0,h=[],u=[],d=[],f=[],g=[],p=[],m=[];for(c=0;c<s;c++)h[c]=t.sum(e[c])/l;for(c=0;c<l;c++)for(g[c]=[],n=0;n<s;n++)g[c][n]=e[n][c]-h[n];for(g=t.transpose(g),c=0;c<s;c++)for(p[c]=[],n=0;n<s;n++)p[c][n]=t.dot([g[c]],[g[n]])/(l-1);for(a=(i=t.jacobi(p))[0],u=i[1],m=t.transpose(a),c=0;c<u.length;c++)for(n=c;n<u.length;n++)u[c]<u[n]&&(r=u[c],u[c]=u[n],u[n]=r,d=m[c],m[c]=m[n],m[n]=d);for(o=t.transpose(g),c=0;c<s;c++)for(f[c]=[],n=0;n<o.length;n++)f[c][n]=t.dot([m[c]],[o[n]]);return[e,u,m,f]}}),function(e){for(var n=0;n<e.length;n++)(function(e){t.fn[e]=function(n,r){var i=this;return r?(setTimeout(function(){r.call(i,t.fn[e].call(i,n))},15),this):"number"==typeof t[e](this,n)?t[e](this,n):t(t[e](this,n))}})(e[n])}("add divide multiply subtract dot pow exp log abs norm angle".split(" "))}(e,Math),function(t,e){var n=[].slice,r=t.utils.isNumber,i=t.utils.isArray;function o(t,n,r,i){if(t>1||r>1||t<=0||r<=0)throw new Error("Proportions should be greater than 0 and less than 1");var o=(t*n+r*i)/(n+i);return(t-r)/e.sqrt(o*(1-o)*(1/n+1/i))}t.extend({zscore:function(){var e=n.call(arguments);return r(e[1])?(e[0]-e[1])/e[2]:(e[0]-t.mean(e[1]))/t.stdev(e[1],e[2])},ztest:function(){var r,o=n.call(arguments);return i(o[1])?(r=t.zscore(o[0],o[1],o[3]),1===o[2]?t.normal.cdf(-e.abs(r),0,1):2*t.normal.cdf(-e.abs(r),0,1)):o.length>2?(r=t.zscore(o[0],o[1],o[2]),1===o[3]?t.normal.cdf(-e.abs(r),0,1):2*t.normal.cdf(-e.abs(r),0,1)):(r=o[0],1===o[1]?t.normal.cdf(-e.abs(r),0,1):2*t.normal.cdf(-e.abs(r),0,1))}}),t.extend(t.fn,{zscore:function(t,e){return(t-this.mean())/this.stdev(e)},ztest:function(n,r,i){var o=e.abs(this.zscore(n,i));return 1===r?t.normal.cdf(-o,0,1):2*t.normal.cdf(-o,0,1)}}),t.extend({tscore:function(){var r=n.call(arguments);return 4===r.length?(r[0]-r[1])/(r[2]/e.sqrt(r[3])):(r[0]-t.mean(r[1]))/(t.stdev(r[1],!0)/e.sqrt(r[1].length))},ttest:function(){var i,o=n.call(arguments);return 5===o.length?(i=e.abs(t.tscore(o[0],o[1],o[2],o[3])),1===o[4]?t.studentt.cdf(-i,o[3]-1):2*t.studentt.cdf(-i,o[3]-1)):r(o[1])?(i=e.abs(o[0]),1==o[2]?t.studentt.cdf(-i,o[1]-1):2*t.studentt.cdf(-i,o[1]-1)):(i=e.abs(t.tscore(o[0],o[1])),1==o[2]?t.studentt.cdf(-i,o[1].length-1):2*t.studentt.cdf(-i,o[1].length-1))}}),t.extend(t.fn,{tscore:function(t){return(t-this.mean())/(this.stdev(!0)/e.sqrt(this.cols()))},ttest:function(n,r){return 1===r?1-t.studentt.cdf(e.abs(this.tscore(n)),this.cols()-1):2*t.studentt.cdf(-e.abs(this.tscore(n)),this.cols()-1)}}),t.extend({anovafscore:function(){var r,i,o,a,s,l,c,h,u=n.call(arguments);if(1===u.length){for(s=new Array(u[0].length),c=0;c<u[0].length;c++)s[c]=u[0][c];u=s}for(i=new Array,c=0;c<u.length;c++)i=i.concat(u[c]);for(o=t.mean(i),r=0,c=0;c<u.length;c++)r+=u[c].length*e.pow(t.mean(u[c])-o,2);for(r/=u.length-1,l=0,c=0;c<u.length;c++)for(a=t.mean(u[c]),h=0;h<u[c].length;h++)l+=e.pow(u[c][h]-a,2);return r/(l/(i.length-u.length))},anovaftest:function(){var e,i,o,a,s=n.call(arguments);if(r(s[0]))return 1-t.centralF.cdf(s[0],s[1],s[2]);var l=t.anovafscore(s);for(e=s.length-1,o=0,a=0;a<s.length;a++)o+=s[a].length;return i=o-e-1,1-t.centralF.cdf(l,e,i)},ftest:function(e,n,r){return 1-t.centralF.cdf(e,n,r)}}),t.extend(t.fn,{anovafscore:function(){return t.anovafscore(this.toArray())},anovaftes:function(){var e,n=0;for(e=0;e<this.length;e++)n+=this[e].length;return t.ftest(this.anovafscore(),this.length-1,n-this.length)}}),t.extend({qscore:function(){var i,o,a,s,l,c=n.call(arguments);return r(c[0])?(i=c[0],o=c[1],a=c[2],s=c[3],l=c[4]):(i=t.mean(c[0]),o=t.mean(c[1]),a=c[0].length,s=c[1].length,l=c[2]),e.abs(i-o)/(l*e.sqrt((1/a+1/s)/2))},qtest:function(){var e,r=n.call(arguments);3===r.length?(e=r[0],r=r.slice(1)):7===r.length?(e=t.qscore(r[0],r[1],r[2],r[3],r[4]),r=r.slice(5)):(e=t.qscore(r[0],r[1],r[2]),r=r.slice(3));var i=r[0],o=r[1];return 1-t.tukey.cdf(e,o,i-o)},tukeyhsd:function(e){for(var n=t.pooledstdev(e),r=e.map(function(e){return t.mean(e)}),i=e.reduce(function(t,e){return t+e.length},0),o=[],a=0;a<e.length;++a)for(var s=a+1;s<e.length;++s){var l=t.qtest(r[a],r[s],e[a].length,e[s].length,n,i,e.length);o.push([[a,s],l])}return o}}),t.extend({normalci:function(){var r,i=n.call(arguments),o=new Array(2);return r=4===i.length?e.abs(t.normal.inv(i[1]/2,0,1)*i[2]/e.sqrt(i[3])):e.abs(t.normal.inv(i[1]/2,0,1)*t.stdev(i[2])/e.sqrt(i[2].length)),o[0]=i[0]-r,o[1]=i[0]+r,o},tci:function(){var r,i=n.call(arguments),o=new Array(2);return r=4===i.length?e.abs(t.studentt.inv(i[1]/2,i[3]-1)*i[2]/e.sqrt(i[3])):e.abs(t.studentt.inv(i[1]/2,i[2].length-1)*t.stdev(i[2],!0)/e.sqrt(i[2].length)),o[0]=i[0]-r,o[1]=i[0]+r,o},significant:function(t,e){return t<e}}),t.extend(t.fn,{normalci:function(e,n){return t.normalci(e,n,this.toArray())},tci:function(e,n){return t.tci(e,n,this.toArray())}}),t.extend(t.fn,{oneSidedDifferenceOfProportions:function(e,n,r,i){var a=o(e,n,r,i);return t.ztest(a,1)},twoSidedDifferenceOfProportions:function(e,n,r,i){var a=o(e,n,r,i);return t.ztest(a,2)}})}(e,Math),e.models=function(){function t(t,n){var r=t.length,i=n[0].length-1,o=r-i-1,a=e.lstsq(n,t),s=e.multiply(n,a.map(function(t){return[t]})).map(function(t){return t[0]}),l=e.subtract(t,s),c=e.mean(t),h=e.sum(s.map(function(t){return Math.pow(t-c,2)})),u=e.sum(t.map(function(t,e){return Math.pow(t-s[e],2)})),d=h+u;return{exog:n,endog:t,nobs:r,df_model:i,df_resid:o,coef:a,predict:s,resid:l,ybar:c,SST:d,SSE:h,SSR:u,R2:h/d}}function n(n){var r,i,o=(r=n.exog,i=r[0].length,e.arange(i).map(function(n){var o=e.arange(i).filter(function(t){return t!==n});return t(e.col(r,n).map(function(t){return t[0]}),e.col(r,o))})),a=Math.sqrt(n.SSR/n.df_resid),s=o.map(function(t){var e=t.SST,n=t.R2;return a/Math.sqrt(e*(1-n))}),l=n.coef.map(function(t,e){return(t-0)/s[e]}),c=l.map(function(t){var r=e.studentt.cdf(t,n.df_resid);return 2*(r>.5?1-r:r)}),h=e.studentt.inv(.975,n.df_resid),u=n.coef.map(function(t,e){var n=h*s[e];return[t-n,t+n]});return{se:s,t:l,p:c,sigmaHat:a,interval95:u}}return{ols:function(r,i){var o=t(r,i),a=n(o),s=function(t){var n,r,i,o=t.R2/t.df_model/((1-t.R2)/t.df_resid);return{F_statistic:o,pvalue:1-(n=o,r=t.df_model,i=t.df_resid,e.beta.cdf(n/(i/r+n),r/2,i/2))}}(o),l=1-(1-o.R2)*((o.nobs-1)/o.df_resid);return o.t=a,o.f=s,o.adjust_R2=l,o}}}(),e.extend({buildxmatrix:function(){for(var t=new Array(arguments.length),n=0;n<arguments.length;n++){t[n]=[1].concat(arguments[n])}return e(t)},builddxmatrix:function(){for(var t=new Array(arguments[0].length),n=0;n<arguments[0].length;n++){t[n]=[1].concat(arguments[0][n])}return e(t)},buildjxmatrix:function(t){for(var n=new Array(t.length),r=0;r<t.length;r++)n[r]=t[r];return e.builddxmatrix(n)},buildymatrix:function(t){return e(t).transpose()},buildjymatrix:function(t){return t.transpose()},matrixmult:function(t,n){var r,i,o,a,s;if(t.cols()==n.rows()){if(n.rows()>1){for(a=[],r=0;r<t.rows();r++)for(a[r]=[],i=0;i<n.cols();i++){for(s=0,o=0;o<t.cols();o++)s+=t.toArray()[r][o]*n.toArray()[o][i];a[r][i]=s}return e(a)}for(a=[],r=0;r<t.rows();r++)for(a[r]=[],i=0;i<n.cols();i++){for(s=0,o=0;o<t.cols();o++)s+=t.toArray()[r][o]*n.toArray()[i];a[r][i]=s}return e(a)}},regress:function(t,n){var r=e.xtranspxinv(t),i=t.transpose(),o=e.matrixmult(e(r),i);return e.matrixmult(o,n)},regresst:function(t,n,r){var i=e.regress(t,n),o={anova:{}},a=e.jMatYBar(t,i);o.yBar=a;var s=n.mean();o.anova.residuals=e.residuals(n,a),o.anova.ssr=e.ssr(a,s),o.anova.msr=o.anova.ssr/(t[0].length-1),o.anova.sse=e.sse(n,a),o.anova.mse=o.anova.sse/(n.length-(t[0].length-1)-1),o.anova.sst=e.sst(n,s),o.anova.mst=o.anova.sst/(n.length-1),o.anova.r2=1-o.anova.sse/o.anova.sst,o.anova.r2<0&&(o.anova.r2=0),o.anova.fratio=o.anova.msr/o.anova.mse,o.anova.pvalue=e.anovaftest(o.anova.fratio,t[0].length-1,n.length-(t[0].length-1)-1),o.anova.rmse=Math.sqrt(o.anova.mse),o.anova.r2adj=1-o.anova.mse/o.anova.mst,o.anova.r2adj<0&&(o.anova.r2adj=0),o.stats=new Array(t[0].length);for(var l,c,h,u=e.xtranspxinv(t),d=0;d<i.length;d++)l=Math.sqrt(o.anova.mse*Math.abs(u[d][d])),c=Math.abs(i[d]/l),h=e.ttest(c,n.length-t[0].length-1,r),o.stats[d]=[i[d],l,c,h];return o.regress=i,o},xtranspx:function(t){return e.matrixmult(t.transpose(),t)},xtranspxinv:function(t){var n=e.matrixmult(t.transpose(),t);return e.inv(n)},jMatYBar:function(t,n){var r=e.matrixmult(t,n);return new e(r)},residuals:function(t,n){return e.matrixsubtract(t,n)},ssr:function(t,e){for(var n=0,r=0;r<t.length;r++)n+=Math.pow(t[r]-e,2);return n},sse:function(t,e){for(var n=0,r=0;r<t.length;r++)n+=Math.pow(t[r]-e[r],2);return n},sst:function(t,e){for(var n=0,r=0;r<t.length;r++)n+=Math.pow(t[r]-e,2);return n},matrixsubtract:function(t,n){for(var r=new Array(t.length),i=0;i<t.length;i++){r[i]=new Array(t[i].length);for(var o=0;o<t[i].length;o++)r[i][o]=t[i][o]-n[i][o]}return e(r)}}),e.jStat=e,e)},6619:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Tag=e.Label=void 0;const r=n(4892),i=n(4723),o=n(7949),a=n(5483),s=n(8871),l=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],c="up",h="right",u="down",d="left",f=l.length;class g extends o.Group{constructor(t){super(t),this.on("add.konva",function(t){this._addListeners(t.child),this._sync()})}getText(){return this.find("Text")[0]}getTag(){return this.find("Tag")[0]}_addListeners(t){let e,n=this;const r=function(){n._sync()};for(e=0;e<f;e++)t.on(l[e]+"Change.konva",r)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){let t,e,n,r,i,o,a,s=this.getText(),l=this.getTag();if(s&&l){switch(t=s.width(),e=s.height(),n=l.pointerDirection(),r=l.pointerWidth(),a=l.pointerHeight(),i=0,o=0,n){case c:i=t/2,o=-1*a;break;case h:i=t+r,o=e/2;break;case u:i=t/2,o=e+a;break;case d:i=-1*r,o=e/2}l.setAttrs({x:-1*i,y:-1*o,width:t,height:e}),s.setAttrs({x:-1*i,y:-1*o})}}}e.Label=g,g.prototype.className="Label",(0,s._registerNode)(g);class p extends i.Shape{_sceneFunc(t){const e=this.width(),n=this.height(),r=this.pointerDirection(),i=this.pointerWidth(),o=this.pointerHeight(),a=this.cornerRadius();let s=0,l=0,f=0,g=0;"number"==typeof a?s=l=f=g=Math.min(a,e/2,n/2):(s=Math.min(a[0]||0,e/2,n/2),l=Math.min(a[1]||0,e/2,n/2),g=Math.min(a[2]||0,e/2,n/2),f=Math.min(a[3]||0,e/2,n/2)),t.beginPath(),t.moveTo(s,0),r===c&&(t.lineTo((e-i)/2,0),t.lineTo(e/2,-1*o),t.lineTo((e+i)/2,0)),t.lineTo(e-l,0),t.arc(e-l,l,l,3*Math.PI/2,0,!1),r===h&&(t.lineTo(e,(n-o)/2),t.lineTo(e+i,n/2),t.lineTo(e,(n+o)/2)),t.lineTo(e,n-g),t.arc(e-g,n-g,g,0,Math.PI/2,!1),r===u&&(t.lineTo((e+i)/2,n),t.lineTo(e/2,n+o),t.lineTo((e-i)/2,n)),t.lineTo(f,n),t.arc(f,n-f,f,Math.PI/2,Math.PI,!1),r===d&&(t.lineTo(0,(n+o)/2),t.lineTo(-1*i,n/2),t.lineTo(0,(n-o)/2)),t.lineTo(0,s),t.arc(s,s,s,Math.PI,3*Math.PI/2,!1),t.closePath(),t.fillStrokeShape(this)}getSelfRect(){let t=0,e=0,n=this.pointerWidth(),r=this.pointerHeight(),i=this.pointerDirection(),o=this.width(),a=this.height();return i===c?(e-=r,a+=r):i===u?a+=r:i===d?(t-=1.5*n,o+=n):i===h&&(o+=1.5*n),{x:t,y:e,width:o,height:a}}}e.Tag=p,p.prototype.className="Tag",(0,s._registerNode)(p),r.Factory.addGetterSetter(p,"pointerDirection","none"),r.Factory.addGetterSetter(p,"pointerWidth",0,(0,a.getNumberValidator)()),r.Factory.addGetterSetter(p,"pointerHeight",0,(0,a.getNumberValidator)()),r.Factory.addGetterSetter(p,"cornerRadius",0,(0,a.getNumberOrArrayOfNumbersValidator)(4))},6627:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Brighten=void 0;const r=n(4892),i=n(6536),o=n(5483);e.Brighten=function(t){const e=255*this.brightness(),n=t.data,r=n.length;for(let t=0;t<r;t+=4)n[t]+=e,n[t+1]+=e,n[t+2]+=e},r.Factory.addGetterSetter(i.Node,"brightness",0,(0,o.getNumberValidator)(),r.Factory.afterSetFilter)},6921:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RGB=void 0;const r=n(4892),i=n(6536),o=n(5483);e.RGB=function(t){const e=t.data,n=e.length,r=this.red(),i=this.green(),o=this.blue();for(let t=0;t<n;t+=4){const n=(.34*e[t]+.5*e[t+1]+.16*e[t+2])/255;e[t]=n*r,e[t+1]=n*i,e[t+2]=n*o,e[t+3]=e[t+3]}},r.Factory.addGetterSetter(i.Node,"red",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),r.Factory.addGetterSetter(i.Node,"green",0,function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)}),r.Factory.addGetterSetter(i.Node,"blue",0,o.RGBComponent,r.Factory.afterSetFilter)},6955:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Ellipse=void 0;const r=n(4892),i=n(4723),o=n(5483),a=n(8871);class s extends i.Shape{_sceneFunc(t){const e=this.radiusX(),n=this.radiusY();t.beginPath(),t.save(),e!==n&&t.scale(1,n/e),t.arc(0,0,e,0,2*Math.PI,!1),t.restore(),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radiusX()}getHeight(){return 2*this.radiusY()}setWidth(t){this.radiusX(t/2)}setHeight(t){this.radiusY(t/2)}}e.Ellipse=s,s.prototype.className="Ellipse",s.prototype._centroid=!0,s.prototype._attrsAffectingSize=["radiusX","radiusY"],(0,a._registerNode)(s),r.Factory.addComponentsGetterSetter(s,"radius",["x","y"]),r.Factory.addGetterSetter(s,"radiusX",0,(0,o.getNumberValidator)()),r.Factory.addGetterSetter(s,"radiusY",0,(0,o.getNumberValidator)())},7019:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Posterize=void 0;const r=n(4892),i=n(6536),o=n(5483);e.Posterize=function(t){const e=Math.round(254*this.levels())+1,n=t.data,r=n.length,i=255/e;for(let t=0;t<r;t+=1)n[t]=Math.floor(n[t]/i)*i},r.Factory.addGetterSetter(i.Node,"levels",.5,(0,o.getNumberValidator)(),r.Factory.afterSetFilter)},7241:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Grayscale=void 0,e.Grayscale=function(t){const e=t.data,n=e.length;for(let t=0;t<n;t+=4){const n=.34*e[t]+.5*e[t+1]+.16*e[t+2];e[t]=n,e[t+1]=n,e[t+2]=n}}},7256:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Image=void 0;const r=n(4060),i=n(4892),o=n(4723),a=n(8871),s=n(5483);class l extends o.Shape{constructor(t){super(t),this._loadListener=()=>{this._requestDraw()},this.on("imageChange.konva",t=>{this._removeImageLoad(t.oldVal),this._setImageLoad()}),this._setImageLoad()}_setImageLoad(){const t=this.image();t&&t.complete||t&&4===t.readyState||t&&t.addEventListener&&t.addEventListener("load",this._loadListener)}_removeImageLoad(t){t&&t.removeEventListener&&t.removeEventListener("load",this._loadListener)}destroy(){return this._removeImageLoad(this.image()),super.destroy(),this}_useBufferCanvas(){const t=!!this.cornerRadius(),e=this.hasShadow();return!(!t||!e)||super._useBufferCanvas(!0)}_sceneFunc(t){const e=this.getWidth(),n=this.getHeight(),i=this.cornerRadius(),o=this.attrs.image;let a;if(o){const t=this.attrs.cropWidth,r=this.attrs.cropHeight;a=t&&r?[o,this.cropX(),this.cropY(),t,r,0,0,e,n]:[o,0,0,e,n]}(this.hasFill()||this.hasStroke()||i)&&(t.beginPath(),i?r.Util.drawRoundedRectPath(t,e,n,i):t.rect(0,0,e,n),t.closePath(),t.fillStrokeShape(this)),o&&(i&&t.clip(),t.drawImage.apply(t,a))}_hitFunc(t){const e=this.width(),n=this.height(),i=this.cornerRadius();t.beginPath(),i?r.Util.drawRoundedRectPath(t,e,n,i):t.rect(0,0,e,n),t.closePath(),t.fillStrokeShape(this)}getWidth(){var t,e;return null!==(t=this.attrs.width)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.width}getHeight(){var t,e;return null!==(t=this.attrs.height)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.height}static fromURL(t,e,n=null){const i=r.Util.createImageElement();i.onload=function(){const t=new l({image:i});e(t)},i.onerror=n,i.crossOrigin="Anonymous",i.src=t}}e.Image=l,l.prototype.className="Image",(0,a._registerNode)(l),i.Factory.addGetterSetter(l,"cornerRadius",0,(0,s.getNumberOrArrayOfNumbersValidator)(4)),i.Factory.addGetterSetter(l,"image"),i.Factory.addComponentsGetterSetter(l,"crop",["x","y","width","height"]),i.Factory.addGetterSetter(l,"cropX",0,(0,s.getNumberValidator)()),i.Factory.addGetterSetter(l,"cropY",0,(0,s.getNumberValidator)()),i.Factory.addGetterSetter(l,"cropWidth",0,(0,s.getNumberValidator)()),i.Factory.addGetterSetter(l,"cropHeight",0,(0,s.getNumberValidator)())},7324:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Stage=e.stages=void 0;const r=n(4060),i=n(4892),o=n(4473),a=n(8871),s=n(8604),l=n(1268),c=n(8871),h=n(8722),u="mouseleave",d="mouseover",f="mouseenter",g="mousemove",p="mousedown",m="mouseup",y="pointermove",v="pointerdown",_="pointerup",w="pointercancel",b="pointerout",C="pointerleave",x="pointerover",S="pointerenter",A="contextmenu",E="touchstart",T="touchend",M="touchmove",P="touchcancel",N="wheel",O=[[f,"_pointerenter"],[p,"_pointerdown"],[g,"_pointermove"],[m,"_pointerup"],[u,"_pointerleave"],[E,"_pointerdown"],[M,"_pointermove"],[T,"_pointerup"],[P,"_pointercancel"],[d,"_pointerover"],[N,"_wheel"],[A,"_contextmenu"],[v,"_pointerdown"],[y,"_pointermove"],[_,"_pointerup"],[w,"_pointercancel"],[C,"_pointerleave"],["lostpointercapture","_lostpointercapture"]],F={mouse:{[b]:"mouseout",[C]:u,[x]:d,[S]:f,[y]:g,[v]:p,[_]:m,[w]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[b]:"touchout",[C]:"touchleave",[x]:"touchover",[S]:"touchenter",[y]:M,[v]:E,[_]:T,[w]:P,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[b]:b,[C]:C,[x]:x,[S]:S,[y]:y,[v]:v,[_]:_,[w]:w,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},R=t=>t.indexOf("pointer")>=0?"pointer":t.indexOf("touch")>=0?"touch":"mouse",I=t=>{const e=R(t);return"pointer"===e?a.Konva.pointerEventsEnabled&&F.pointer:"touch"===e?F.touch:"mouse"===e?F.mouse:void 0};function D(t={}){return(t.clipFunc||t.clipWidth||t.clipHeight)&&r.Util.warn("Stage does not support clipping. Please use clip for Layers or Groups."),t}e.stages=[];class L extends o.Container{constructor(t){super(D(t)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),e.stages.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",()=>{D(this.attrs)}),this._checkVisibility()}_validateAdd(t){const e="Layer"===t.getType(),n="FastLayer"===t.getType();e||n||r.Util.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;const t=this.visible()?"":"none";this.content.style.display=t}setContainer(t){if("string"==typeof t){let e;if("."===t.charAt(0)){const e=t.slice(1);t=document.getElementsByClassName(e)[0]}else e="#"!==t.charAt(0)?t:t.slice(1),t=document.getElementById(e);if(!t)throw"Can not find container in document with id "+e}return this._setAttr("container",t),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),t.appendChild(this.content)),this}shouldDrawHit(){return!0}clear(){const t=this.children,e=t.length;for(let n=0;n<e;n++)t[n].clear();return this}clone(t){return t||(t={}),t.container="undefined"!=typeof document&&document.createElement("div"),o.Container.prototype.clone.call(this,t)}destroy(){super.destroy();const t=this.content;t&&r.Util._isInDocument(t)&&this.container().removeChild(t);const n=e.stages.indexOf(this);return n>-1&&e.stages.splice(n,1),r.Util.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){const t=this._pointerPositions[0]||this._changedPointerPositions[0];return t?{x:t.x,y:t.y}:(r.Util.warn("Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);"),null)}_getPointerById(t){return this._pointerPositions.find(e=>e.id===t)}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(t){(t=t||{}).x=t.x||0,t.y=t.y||0,t.width=t.width||this.width(),t.height=t.height||this.height();const e=new s.SceneCanvas({width:t.width,height:t.height,pixelRatio:t.pixelRatio||1}),n=e.getContext()._context,r=this.children;return(t.x||t.y)&&n.translate(-1*t.x,-1*t.y),r.forEach(function(e){if(!e.isVisible())return;const r=e._toKonvaCanvas(t);n.drawImage(r._canvas,t.x,t.y,r.getWidth()/r.getPixelRatio(),r.getHeight()/r.getPixelRatio())}),e}getIntersection(t){if(!t)return null;const e=this.children;for(let n=e.length-1;n>=0;n--){const r=e[n].getIntersection(t);if(r)return r}return null}_resizeDOM(){const t=this.width(),e=this.height();this.content&&(this.content.style.width=t+"px",this.content.style.height=e+"px"),this.bufferCanvas.setSize(t,e),this.bufferHitCanvas.setSize(t,e),this.children.forEach(n=>{n.setSize({width:t,height:e}),n.draw()})}add(t,...e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}super.add(t);const n=this.children.length;return n>5&&r.Util.warn("The stage has "+n+" layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group."),t.setSize({width:this.width(),height:this.height()}),t.draw(),a.Konva.isBrowser&&this.content.appendChild(t.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(t){return h.hasPointerCapture(t,this)}setPointerCapture(t){h.setPointerCapture(t,this)}releaseCapture(t){h.releaseCapture(t,this)}getLayers(){return this.children}_bindContentEvents(){a.Konva.isBrowser&&O.forEach(([t,e])=>{this.content.addEventListener(t,t=>{this[e](t)},{passive:!1})})}_pointerenter(t){this.setPointersPositions(t);const e=I(t.type);e&&this._fire(e.pointerenter,{evt:t,target:this,currentTarget:this})}_pointerover(t){this.setPointersPositions(t);const e=I(t.type);e&&this._fire(e.pointerover,{evt:t,target:this,currentTarget:this})}_getTargetShape(t){let e=this[t+"targetShape"];return e&&!e.getStage()&&(e=null),e}_pointerleave(t){const e=I(t.type),n=R(t.type);if(!e)return;this.setPointersPositions(t);const r=this._getTargetShape(n),i=!(a.Konva.isDragging()||a.Konva.isTransforming())||a.Konva.hitOnDragEnabled;r&&i?(r._fireAndBubble(e.pointerout,{evt:t}),r._fireAndBubble(e.pointerleave,{evt:t}),this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this[n+"targetShape"]=null):i&&(this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this._fire(e.pointerout,{evt:t,target:this,currentTarget:this})),this.pointerPos=null,this._pointerPositions=[]}_pointerdown(t){const e=I(t.type),n=R(t.type);if(!e)return;this.setPointersPositions(t);let r=!1;this._changedPointerPositions.forEach(i=>{const o=this.getIntersection(i);if(l.DD.justDragged=!1,a.Konva["_"+n+"ListenClick"]=!0,!o||!o.isListening())return void(this[n+"ClickStartShape"]=void 0);a.Konva.capturePointerEventsEnabled&&o.setPointerCapture(i.id),this[n+"ClickStartShape"]=o,o._fireAndBubble(e.pointerdown,{evt:t,pointerId:i.id}),r=!0;const s=t.type.indexOf("touch")>=0;o.preventDefault()&&t.cancelable&&s&&t.preventDefault()}),r||this._fire(e.pointerdown,{evt:t,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}_pointermove(t){const e=I(t.type),n=R(t.type);if(!e)return;if(a.Konva.isDragging()&&l.DD.node.preventDefault()&&t.cancelable&&t.preventDefault(),this.setPointersPositions(t),(a.Konva.isDragging()||a.Konva.isTransforming())&&!a.Konva.hitOnDragEnabled)return;const r={};let i=!1;const o=this._getTargetShape(n);this._changedPointerPositions.forEach(a=>{const s=h.getCapturedShape(a.id)||this.getIntersection(a),l=a.id,c={evt:t,pointerId:l},u=o!==s;if(u&&o&&(o._fireAndBubble(e.pointerout,{...c},s),o._fireAndBubble(e.pointerleave,{...c},s)),s){if(r[s._id])return;r[s._id]=!0}s&&s.isListening()?(i=!0,u&&(s._fireAndBubble(e.pointerover,{...c},o),s._fireAndBubble(e.pointerenter,{...c},o),this[n+"targetShape"]=s),s._fireAndBubble(e.pointermove,{...c})):o&&(this._fire(e.pointerover,{evt:t,target:this,currentTarget:this,pointerId:l}),this[n+"targetShape"]=null)}),i||this._fire(e.pointermove,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(t){const e=I(t.type),n=R(t.type);if(!e)return;this.setPointersPositions(t);const r=this[n+"ClickStartShape"],i=this[n+"ClickEndShape"],o={};let s=!1;this._changedPointerPositions.forEach(c=>{const u=h.getCapturedShape(c.id)||this.getIntersection(c);if(u){if(u.releaseCapture(c.id),o[u._id])return;o[u._id]=!0}const d=c.id,f={evt:t,pointerId:d};let g=!1;a.Konva["_"+n+"InDblClickWindow"]?(g=!0,clearTimeout(this[n+"DblTimeout"])):l.DD.justDragged||(a.Konva["_"+n+"InDblClickWindow"]=!0,clearTimeout(this[n+"DblTimeout"])),this[n+"DblTimeout"]=setTimeout(function(){a.Konva["_"+n+"InDblClickWindow"]=!1},a.Konva.dblClickWindow),u&&u.isListening()?(s=!0,this[n+"ClickEndShape"]=u,u._fireAndBubble(e.pointerup,{...f}),a.Konva["_"+n+"ListenClick"]&&r&&r===u&&(u._fireAndBubble(e.pointerclick,{...f}),g&&i&&i===u&&u._fireAndBubble(e.pointerdblclick,{...f}))):(this[n+"ClickEndShape"]=null,a.Konva["_"+n+"ListenClick"]&&this._fire(e.pointerclick,{evt:t,target:this,currentTarget:this,pointerId:d}),g&&this._fire(e.pointerdblclick,{evt:t,target:this,currentTarget:this,pointerId:d}))}),s||this._fire(e.pointerup,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),a.Konva["_"+n+"ListenClick"]=!1,t.cancelable&&"touch"!==n&&"pointer"!==n&&t.preventDefault()}_contextmenu(t){this.setPointersPositions(t);const e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(A,{evt:t}):this._fire(A,{evt:t,target:this,currentTarget:this})}_wheel(t){this.setPointersPositions(t);const e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(N,{evt:t}):this._fire(N,{evt:t,target:this,currentTarget:this})}_pointercancel(t){this.setPointersPositions(t);const e=h.getCapturedShape(t.pointerId)||this.getIntersection(this.getPointerPosition());e&&e._fireAndBubble(_,h.createEvent(t)),h.releaseCapture(t.pointerId)}_lostpointercapture(t){h.releaseCapture(t.pointerId)}setPointersPositions(t){const e=this._getContentPosition();let n=null,i=null;void 0!==(t=t||window.event).touches?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(t.touches,t=>{this._pointerPositions.push({id:t.identifier,x:(t.clientX-e.left)/e.scaleX,y:(t.clientY-e.top)/e.scaleY})}),Array.prototype.forEach.call(t.changedTouches||t.touches,t=>{this._changedPointerPositions.push({id:t.identifier,x:(t.clientX-e.left)/e.scaleX,y:(t.clientY-e.top)/e.scaleY})})):(n=(t.clientX-e.left)/e.scaleX,i=(t.clientY-e.top)/e.scaleY,this.pointerPos={x:n,y:i},this._pointerPositions=[{x:n,y:i,id:r.Util._getFirstPointerId(t)}],this._changedPointerPositions=[{x:n,y:i,id:r.Util._getFirstPointerId(t)}])}_setPointerPosition(t){r.Util.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'),this.setPointersPositions(t)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};const t=this.content.getBoundingClientRect();return{top:t.top,left:t.left,scaleX:t.width/this.content.clientWidth||1,scaleY:t.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferCanvas=new s.SceneCanvas({width:this.width(),height:this.height()}),this.bufferHitCanvas=new s.HitCanvas({pixelRatio:1,width:this.width(),height:this.height()}),!a.Konva.isBrowser)return;const t=this.container();if(!t)throw"Stage has no container. A container is required.";t.innerHTML="",this.content=document.createElement("div"),this.content.style.position="relative",this.content.style.userSelect="none",this.content.className="konvajs-content",this.content.setAttribute("role","presentation"),t.appendChild(this.content),this._resizeDOM()}cache(){return r.Util.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."),this}clearCache(){return this}batchDraw(){return this.getChildren().forEach(function(t){t.batchDraw()}),this}}e.Stage=L,L.prototype.nodeType="Stage",(0,c._registerNode)(L),i.Factory.addGetterSetter(L,"container"),a.Konva.isBrowser&&document.addEventListener("visibilitychange",()=>{e.stages.forEach(t=>{t.batchDraw()})})},7457:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.FastLayer=void 0;const r=n(4060),i=n(6267),o=n(8871);class a extends i.Layer{constructor(t){super(t),this.listening(!1),r.Util.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}}e.FastLayer=a,a.prototype.nodeType="FastLayer",(0,o._registerNode)(a)},7659:t=>{"use strict";var e={};t.exports=function(t,n){var r=function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}e[t]=n}return e[t]}(t);if(!r)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");r.appendChild(n)}},7825:t=>{"use strict";t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(n){!function(t,e,n){var r="";n.supports&&(r+="@supports (".concat(n.supports,") {")),n.media&&(r+="@media ".concat(n.media," {"));var i=void 0!==n.layer;i&&(r+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),r+=n.css,i&&(r+="}"),n.media&&(r+="}"),n.supports&&(r+="}");var o=n.sourceMap;o&&"undefined"!=typeof btoa&&(r+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(o))))," */")),e.styleTagTransform(r,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},7928:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Enhance=void 0;const r=n(4892),i=n(6536),o=n(5483);function a(t,e,n,r,i){const o=n-e,a=i-r;if(0===o)return r+a/2;if(0===a)return r;let s=(t-e)/o;return s=a*s+r,s}e.Enhance=function(t){const e=t.data,n=e.length;let r,i,o,s=e[0],l=s,c=e[1],h=c,u=e[2],d=u;const f=this.enhance();if(0===f)return;for(let t=0;t<n;t+=4)r=e[t+0],r<s?s=r:r>l&&(l=r),i=e[t+1],i<c?c=i:i>h&&(h=i),o=e[t+2],o<u?u=o:o>d&&(d=o);let g,p,m,y,v,_;if(l===s&&(l=255,s=0),h===c&&(h=255,c=0),d===u&&(d=255,u=0),f>0)g=l+f*(255-l),p=s-f*(s-0),m=h+f*(255-h),y=c-f*(c-0),v=d+f*(255-d),_=u-f*(u-0);else{const t=.5*(l+s);g=l+f*(l-t),p=s+f*(s-t);const e=.5*(h+c);m=h+f*(h-e),y=c+f*(c-e);const n=.5*(d+u);v=d+f*(d-n),_=u+f*(u-n)}for(let t=0;t<n;t+=4)e[t+0]=a(e[t+0],s,l,p,g),e[t+1]=a(e[t+1],c,h,y,m),e[t+2]=a(e[t+2],u,d,_,v)},r.Factory.addGetterSetter(i.Node,"enhance",0,(0,o.getNumberValidator)(),r.Factory.afterSetFilter)},7949:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Group=void 0;const r=n(4060),i=n(4473),o=n(8871);class a extends i.Container{_validateAdd(t){const e=t.getType();"Group"!==e&&"Shape"!==e&&r.Util.throw("You may only add groups and shapes to groups.")}}e.Group=a,a.prototype.nodeType="Group",(0,o._registerNode)(a)},8001:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Wedge=void 0;const r=n(4892),i=n(4723),o=n(8871),a=n(5483),s=n(8871);class l extends i.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.radius(),0,o.Konva.getAngle(this.angle()),this.clockwise()),t.lineTo(0,0),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}}e.Wedge=l,l.prototype.className="Wedge",l.prototype._centroid=!0,l.prototype._attrsAffectingSize=["radius"],(0,s._registerNode)(l),r.Factory.addGetterSetter(l,"radius",0,(0,a.getNumberValidator)()),r.Factory.addGetterSetter(l,"angle",0,(0,a.getNumberValidator)()),r.Factory.addGetterSetter(l,"clockwise",!1),r.Factory.backCompat(l,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"})},8137:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TextPath=void 0;const r=n(4060),i=n(4892),o=n(4723),a=n(1486),s=n(1958),l=n(5483),c=n(8871),h="normal";function u(t){t.fillText(this.partialText,0,0)}function d(t){t.strokeText(this.partialText,0,0)}class f extends o.Shape{constructor(t){super(t),this.dummyCanvas=r.Util.createCanvasElement(),this.dataArray=[],this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute(),this._setTextData()}),this.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva",this._setTextData),this._setTextData()}_getTextPathLength(){return a.Path.getPathLength(this.dataArray)}_getPointAtLength(t){return this.attrs.data?t-1>this.pathLength?null:a.Path.getPointAtLengthOfDataArray(t,this.dataArray):null}_readDataAttribute(){this.dataArray=a.Path.parsePathData(this.attrs.data),this.pathLength=this._getTextPathLength()}_sceneFunc(t){t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",this.textBaseline()),t.setAttr("textAlign","left"),t.save();const e=this.textDecoration(),n=this.fill(),r=this.fontSize(),i=this.glyphInfo;"underline"===e&&t.beginPath();for(let n=0;n<i.length;n++){t.save();const o=i[n].p0;t.translate(o.x,o.y),t.rotate(i[n].rotation),this.partialText=i[n].text,t.fillStrokeShape(this),"underline"===e&&(0===n&&t.moveTo(0,r/2+1),t.lineTo(r,r/2+1)),t.restore()}"underline"===e&&(t.strokeStyle=n,t.lineWidth=r/20,t.stroke()),t.restore()}_hitFunc(t){t.beginPath();const e=this.glyphInfo;if(e.length>=1){const n=e[0].p0;t.moveTo(n.x,n.y)}for(let n=0;n<e.length;n++){const r=e[n].p1;t.lineTo(r.x,r.y)}t.setAttr("lineWidth",this.fontSize()),t.setAttr("strokeStyle",this.colorKey),t.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return r.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(t){return s.Text.prototype.setText.call(this,t)}_getContextFont(){return s.Text.prototype._getContextFont.call(this)}_getTextSize(t){const e=this.dummyCanvas.getContext("2d");e.save(),e.font=this._getContextFont();const n=e.measureText(t);return e.restore(),{width:n.width,height:parseInt(`${this.fontSize()}`,10)}}_setTextData(){const{width:t,height:e}=this._getTextSize(this.attrs.text);if(this.textWidth=t,this.textHeight=e,this.glyphInfo=[],!this.attrs.data)return null;const n=this.letterSpacing(),r=this.align(),i=this.kerningFunc(),o=Math.max(this.textWidth+((this.attrs.text||"").length-1)*n,0);let l=0;"center"===r&&(l=Math.max(0,this.pathLength/2-o/2)),"right"===r&&(l=Math.max(0,this.pathLength-o));const c=(0,s.stringToArray)(this.text());let h=l;for(let t=0;t<c.length;t++){const e=this._getPointAtLength(h);if(!e)return;let s=this._getTextSize(c[t]).width+n;if(" "===c[t]&&"justify"===r){const t=this.text().split(" ").length-1;s+=(this.pathLength-o)/t}const l=this._getPointAtLength(h+s);if(!l)return;const u=a.Path.getLineLength(e.x,e.y,l.x,l.y);let d=0;if(i)try{d=i(c[t-1],c[t])*this.fontSize()}catch(t){d=0}e.x+=d,l.x+=d,this.textWidth+=d;const f=a.Path.getPointOnLine(d+u/2,e.x,e.y,l.x,l.y),g=Math.atan2(l.y-e.y,l.x-e.x);this.glyphInfo.push({transposeX:f.x,transposeY:f.y,text:c[t],rotation:g,p0:e,p1:l}),h+=s}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};const t=[];this.glyphInfo.forEach(function(e){t.push(e.p0.x),t.push(e.p0.y),t.push(e.p1.x),t.push(e.p1.y)});let e,n,r=t[0]||0,i=t[0]||0,o=t[1]||0,a=t[1]||0;for(let s=0;s<t.length/2;s++)e=t[2*s],n=t[2*s+1],r=Math.min(r,e),i=Math.max(i,e),o=Math.min(o,n),a=Math.max(a,n);const s=this.fontSize();return{x:r-s/2,y:o-s/2,width:i-r+s,height:a-o+s}}destroy(){return r.Util.releaseCanvas(this.dummyCanvas),super.destroy()}}e.TextPath=f,f.prototype._fillFunc=u,f.prototype._strokeFunc=d,f.prototype._fillFuncHit=u,f.prototype._strokeFuncHit=d,f.prototype.className="TextPath",f.prototype._attrsAffectingSize=["text","fontSize","data"],(0,c._registerNode)(f),i.Factory.addGetterSetter(f,"data"),i.Factory.addGetterSetter(f,"fontFamily","Arial"),i.Factory.addGetterSetter(f,"fontSize",12,(0,l.getNumberValidator)()),i.Factory.addGetterSetter(f,"fontStyle",h),i.Factory.addGetterSetter(f,"align","left"),i.Factory.addGetterSetter(f,"letterSpacing",0,(0,l.getNumberValidator)()),i.Factory.addGetterSetter(f,"textBaseline","middle"),i.Factory.addGetterSetter(f,"fontVariant",h),i.Factory.addGetterSetter(f,"text",""),i.Factory.addGetterSetter(f,"textDecoration",""),i.Factory.addGetterSetter(f,"kerningFunc",void 0)},8558:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Konva=void 0;const r=n(680),i=n(4821),o=n(9456),a=n(9729),s=n(6955),l=n(7256),c=n(6619),h=n(3443),u=n(1486),d=n(5155),f=n(9131),g=n(5451),p=n(9308),m=n(4481),y=n(1958),v=n(8137),_=n(5058),w=n(8001),b=n(6261),C=n(6627),x=n(2650),S=n(983),A=n(7928),E=n(7241),T=n(5461),M=n(4843),P=n(6564),N=n(5553),O=n(8624),F=n(5992),R=n(4943),I=n(7019),D=n(6921),L=n(3862),k=n(2512),U=n(517),G=n(661);e.Konva=r.Konva.Util._assign(r.Konva,{Arc:i.Arc,Arrow:o.Arrow,Circle:a.Circle,Ellipse:s.Ellipse,Image:l.Image,Label:c.Label,Tag:c.Tag,Line:h.Line,Path:u.Path,Rect:d.Rect,RegularPolygon:f.RegularPolygon,Ring:g.Ring,Sprite:p.Sprite,Star:m.Star,Text:y.Text,TextPath:v.TextPath,Transformer:_.Transformer,Wedge:w.Wedge,Filters:{Blur:b.Blur,Brighten:C.Brighten,Contrast:x.Contrast,Emboss:S.Emboss,Enhance:A.Enhance,Grayscale:E.Grayscale,HSL:T.HSL,HSV:M.HSV,Invert:P.Invert,Kaleidoscope:N.Kaleidoscope,Mask:O.Mask,Noise:F.Noise,Pixelate:R.Pixelate,Posterize:I.Posterize,RGB:D.RGB,RGBA:L.RGBA,Sepia:k.Sepia,Solarize:U.Solarize,Threshold:G.Threshold}})},8604:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.HitCanvas=e.SceneCanvas=e.Canvas=void 0;const r=n(4060),i=n(9869),o=n(8871);let a;class s{constructor(t){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;const e=(t||{}).pixelRatio||o.Konva.pixelRatio||function(){if(a)return a;const t=r.Util.createCanvasElement(),e=t.getContext("2d");return a=(o.Konva._global.devicePixelRatio||1)/(e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1),r.Util.releaseCanvas(t),a}();this.pixelRatio=e,this._canvas=r.Util.createCanvasElement(),this._canvas.style.padding="0",this._canvas.style.margin="0",this._canvas.style.border="0",this._canvas.style.background="transparent",this._canvas.style.position="absolute",this._canvas.style.top="0",this._canvas.style.left="0"}getContext(){return this.context}getPixelRatio(){return this.pixelRatio}setPixelRatio(t){const e=this.pixelRatio;this.pixelRatio=t,this.setSize(this.getWidth()/e,this.getHeight()/e)}setWidth(t){this.width=this._canvas.width=t*this.pixelRatio,this._canvas.style.width=t+"px";const e=this.pixelRatio;this.getContext()._context.scale(e,e)}setHeight(t){this.height=this._canvas.height=t*this.pixelRatio,this._canvas.style.height=t+"px";const e=this.pixelRatio;this.getContext()._context.scale(e,e)}getWidth(){return this.width}getHeight(){return this.height}setSize(t,e){this.setWidth(t||0),this.setHeight(e||0)}toDataURL(t,e){try{return this._canvas.toDataURL(t,e)}catch(t){try{return this._canvas.toDataURL()}catch(t){return r.Util.error("Unable to get data URL. "+t.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}}e.Canvas=s,e.SceneCanvas=class extends s{constructor(t={width:0,height:0,willReadFrequently:!1}){super(t),this.context=new i.SceneContext(this,{willReadFrequently:t.willReadFrequently}),this.setSize(t.width,t.height)}},e.HitCanvas=class extends s{constructor(t={width:0,height:0}){super(t),this.hitCanvas=!0,this.context=new i.HitContext(this),this.setSize(t.width,t.height)}}},8624:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Mask=void 0;const r=n(4892),i=n(6536),o=n(5483);function a(t,e,n){let r=4*(n*t.width+e);const i=[];return i.push(t.data[r++],t.data[r++],t.data[r++],t.data[r++]),i}function s(t,e){return Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)+Math.pow(t[2]-e[2],2))}e.Mask=function(t){let e=function(t,e){const n=a(t,0,0),r=a(t,t.width-1,0),i=a(t,0,t.height-1),o=a(t,t.width-1,t.height-1),l=e||10;if(s(n,r)<l&&s(r,o)<l&&s(o,i)<l&&s(i,n)<l){const e=function(t){const e=[0,0,0];for(let n=0;n<t.length;n++)e[0]+=t[n][0],e[1]+=t[n][1],e[2]+=t[n][2];return e[0]/=t.length,e[1]/=t.length,e[2]/=t.length,e}([r,n,o,i]),a=[];for(let n=0;n<t.width*t.height;n++){const r=s(e,[t.data[4*n],t.data[4*n+1],t.data[4*n+2]]);a[n]=r<l?0:255}return a}}(t,this.threshold());return e&&(e=function(t,e,n){const r=[1,1,1,1,0,1,1,1,1],i=Math.round(Math.sqrt(r.length)),o=Math.floor(i/2),a=[];for(let s=0;s<n;s++)for(let l=0;l<e;l++){const c=s*e+l;let h=0;for(let a=0;a<i;a++)for(let c=0;c<i;c++){const u=s+a-o,d=l+c-o;if(u>=0&&u<n&&d>=0&&d<e){const n=r[a*i+c];h+=t[u*e+d]*n}}a[c]=2040===h?255:0}return a}(e,t.width,t.height),e=function(t,e,n){const r=[1,1,1,1,1,1,1,1,1],i=Math.round(Math.sqrt(r.length)),o=Math.floor(i/2),a=[];for(let s=0;s<n;s++)for(let l=0;l<e;l++){const c=s*e+l;let h=0;for(let a=0;a<i;a++)for(let c=0;c<i;c++){const u=s+a-o,d=l+c-o;if(u>=0&&u<n&&d>=0&&d<e){const n=r[a*i+c];h+=t[u*e+d]*n}}a[c]=h>=1020?255:0}return a}(e,t.width,t.height),e=function(t,e,n){const r=[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],i=Math.round(Math.sqrt(r.length)),o=Math.floor(i/2),a=[];for(let s=0;s<n;s++)for(let l=0;l<e;l++){const c=s*e+l;let h=0;for(let a=0;a<i;a++)for(let c=0;c<i;c++){const u=s+a-o,d=l+c-o;if(u>=0&&u<n&&d>=0&&d<e){const n=r[a*i+c];h+=t[u*e+d]*n}}a[c]=h}return a}(e,t.width,t.height),function(t,e){for(let n=0;n<t.width*t.height;n++)t.data[4*n+3]=e[n]}(t,e)),t},r.Factory.addGetterSetter(i.Node,"threshold",0,(0,o.getNumberValidator)(),r.Factory.afterSetFilter)},8665:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Easings=e.Tween=void 0;const r=n(4060),i=n(9696),o=n(6536),a=n(8871),s={node:1,duration:1,easing:1,onFinish:1,yoyo:1},l=["fill","stroke","shadowColor"];let c=0;class h{constructor(t,e,n,r,i,o,a){this.prop=t,this.propFunc=e,this.begin=r,this._pos=r,this.duration=o,this._change=0,this.prevPos=0,this.yoyo=a,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=n,this._change=i-this.begin,this.pause()}fire(t){const e=this[t];e&&e()}setTime(t){t>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():t<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=t,this.update())}getTime(){return this._time}setPosition(t){this.prevPos=this._pos,this.propFunc(t),this._pos=t}getPosition(t){return void 0===t&&(t=this._time),this.func(t,this.begin,this._change,this.duration)}play(){this.state=2,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=3,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")}seek(t){this.pause(),this._time=t,this.update(),this.fire("onSeek")}reset(){this.pause(),this._time=0,this.update(),this.fire("onReset")}finish(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")}update(){this.setPosition(this.getPosition(this._time)),this.fire("onUpdate")}onEnterFrame(){const t=this.getTimer()-this._startTime;2===this.state?this.setTime(t):3===this.state&&this.setTime(this.duration-t)}pause(){this.state=1,this.fire("onPause")}getTimer(){return(new Date).getTime()}}class u{constructor(t){const n=this,o=t.node,l=o._id,d=t.easing||e.Easings.Linear,f=!!t.yoyo;let g,p;g=void 0===t.duration?.3:0===t.duration?.001:t.duration,this.node=o,this._id=c++;const m=o.getLayer()||(o instanceof a.Konva.Stage?o.getLayers():null);for(p in m||r.Util.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new i.Animation(function(){n.tween.onEnterFrame()},m),this.tween=new h(p,function(t){n._tweenFunc(t)},d,0,1,1e3*g,f),this._addListeners(),u.attrs[l]||(u.attrs[l]={}),u.attrs[l][this._id]||(u.attrs[l][this._id]={}),u.tweens[l]||(u.tweens[l]={}),t)void 0===s[p]&&this._addAttr(p,t[p]);this.reset(),this.onFinish=t.onFinish,this.onReset=t.onReset,this.onUpdate=t.onUpdate}_addAttr(t,e){const n=this.node,i=n._id;let o,a,s,c,h;const d=u.tweens[i][t];d&&delete u.attrs[i][d][t];let f=n.getAttr(t);if(r.Util._isArray(e))if(o=[],a=Math.max(e.length,f.length),"points"===t&&e.length!==f.length&&(e.length>f.length?(c=f,f=r.Util._prepareArrayForTween(f,e,n.closed())):(s=e,e=r.Util._prepareArrayForTween(e,f,n.closed()))),0===t.indexOf("fill"))for(let t=0;t<a;t++)if(t%2==0)o.push(e[t]-f[t]);else{const n=r.Util.colorToRGBA(f[t]);h=r.Util.colorToRGBA(e[t]),f[t]=n,o.push({r:h.r-n.r,g:h.g-n.g,b:h.b-n.b,a:h.a-n.a})}else for(let t=0;t<a;t++)o.push(e[t]-f[t]);else-1!==l.indexOf(t)?(f=r.Util.colorToRGBA(f),h=r.Util.colorToRGBA(e),o={r:h.r-f.r,g:h.g-f.g,b:h.b-f.b,a:h.a-f.a}):o=e-f;u.attrs[i][this._id][t]={start:f,diff:o,end:e,trueEnd:s,trueStart:c},u.tweens[i][t]=this._id}_tweenFunc(t){const e=this.node,n=u.attrs[e._id][this._id];let i,o,a,s,c,h,d,f;for(i in n){if(o=n[i],a=o.start,s=o.diff,f=o.end,r.Util._isArray(a))if(c=[],d=Math.max(a.length,f.length),0===i.indexOf("fill"))for(h=0;h<d;h++)h%2==0?c.push((a[h]||0)+s[h]*t):c.push("rgba("+Math.round(a[h].r+s[h].r*t)+","+Math.round(a[h].g+s[h].g*t)+","+Math.round(a[h].b+s[h].b*t)+","+(a[h].a+s[h].a*t)+")");else for(h=0;h<d;h++)c.push((a[h]||0)+s[h]*t);else c=-1!==l.indexOf(i)?"rgba("+Math.round(a.r+s.r*t)+","+Math.round(a.g+s.g*t)+","+Math.round(a.b+s.b*t)+","+(a.a+s.a*t)+")":a+s*t;e.setAttr(i,c)}}_addListeners(){this.tween.onPlay=()=>{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{const t=this.node,e=u.attrs[t._id][this._id];e.points&&e.points.trueEnd&&t.setAttr("points",e.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{const t=this.node,e=u.attrs[t._id][this._id];e.points&&e.points.trueStart&&t.points(e.points.trueStart),this.onReset&&this.onReset()},this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(t){return this.tween.seek(1e3*t),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){const t=this.node._id,e=this._id,n=u.tweens[t];this.pause(),this.anim&&this.anim.stop();for(const e in n)delete u.tweens[t][e];delete u.attrs[t][e],u.tweens[t]&&(0===Object.keys(u.tweens[t]).length&&delete u.tweens[t],0===Object.keys(u.attrs[t]).length&&delete u.attrs[t])}}e.Tween=u,u.attrs={},u.tweens={},o.Node.prototype.to=function(t){const e=t.onFinish;t.node=this,t.onFinish=function(){this.destroy(),e&&e()},new u(t).play()},e.Easings={BackEaseIn(t,e,n,r){const i=1.70158;return n*(t/=r)*t*((i+1)*t-i)+e},BackEaseOut(t,e,n,r){const i=1.70158;return n*((t=t/r-1)*t*((i+1)*t+i)+1)+e},BackEaseInOut(t,e,n,r){let i=1.70158;return(t/=r/2)<1?n/2*(t*t*((1+(i*=1.525))*t-i))+e:n/2*((t-=2)*t*((1+(i*=1.525))*t+i)+2)+e},ElasticEaseIn(t,e,n,r,i,o){let a=0;return 0===t?e:1===(t/=r)?e+n:(o||(o=.3*r),!i||i<Math.abs(n)?(i=n,a=o/4):a=o/(2*Math.PI)*Math.asin(n/i),-i*Math.pow(2,10*(t-=1))*Math.sin((t*r-a)*(2*Math.PI)/o)+e)},ElasticEaseOut(t,e,n,r,i,o){let a=0;return 0===t?e:1===(t/=r)?e+n:(o||(o=.3*r),!i||i<Math.abs(n)?(i=n,a=o/4):a=o/(2*Math.PI)*Math.asin(n/i),i*Math.pow(2,-10*t)*Math.sin((t*r-a)*(2*Math.PI)/o)+n+e)},ElasticEaseInOut(t,e,n,r,i,o){let a=0;return 0===t?e:2==(t/=r/2)?e+n:(o||(o=r*(.3*1.5)),!i||i<Math.abs(n)?(i=n,a=o/4):a=o/(2*Math.PI)*Math.asin(n/i),t<1?i*Math.pow(2,10*(t-=1))*Math.sin((t*r-a)*(2*Math.PI)/o)*-.5+e:i*Math.pow(2,-10*(t-=1))*Math.sin((t*r-a)*(2*Math.PI)/o)*.5+n+e)},BounceEaseOut:(t,e,n,r)=>(t/=r)<1/2.75?n*(7.5625*t*t)+e:t<2/2.75?n*(7.5625*(t-=1.5/2.75)*t+.75)+e:t<2.5/2.75?n*(7.5625*(t-=2.25/2.75)*t+.9375)+e:n*(7.5625*(t-=2.625/2.75)*t+.984375)+e,BounceEaseIn:(t,n,r,i)=>r-e.Easings.BounceEaseOut(i-t,0,r,i)+n,BounceEaseInOut:(t,n,r,i)=>t<i/2?.5*e.Easings.BounceEaseIn(2*t,0,r,i)+n:.5*e.Easings.BounceEaseOut(2*t-i,0,r,i)+.5*r+n,EaseIn:(t,e,n,r)=>n*(t/=r)*t+e,EaseOut:(t,e,n,r)=>-n*(t/=r)*(t-2)+e,EaseInOut:(t,e,n,r)=>(t/=r/2)<1?n/2*t*t+e:-n/2*(--t*(t-2)-1)+e,StrongEaseIn:(t,e,n,r)=>n*(t/=r)*t*t*t*t+e,StrongEaseOut:(t,e,n,r)=>n*((t=t/r-1)*t*t*t*t+1)+e,StrongEaseInOut:(t,e,n,r)=>(t/=r/2)<1?n/2*t*t*t*t*t+e:n/2*((t-=2)*t*t*t*t+2)+e,Linear:(t,e,n,r)=>n*t/r+e}},8722:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getCapturedShape=function(t){return i.get(t)},e.createEvent=a,e.hasPointerCapture=function(t,e){return i.get(t)===e},e.setPointerCapture=function(t,e){s(t),e.getStage()&&(i.set(t,e),o&&e._fire("gotpointercapture",a(new PointerEvent("gotpointercapture"))))},e.releaseCapture=s;const r=n(8871),i=new Map,o=void 0!==r.Konva._global.PointerEvent;function a(t){return{evt:t,pointerId:t.pointerId}}function s(t,e){const n=i.get(t);if(!n)return;const r=n.getStage();r&&r.content,i.delete(t),o&&n._fire("lostpointercapture",a(new PointerEvent("lostpointercapture")))}},8871:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e._registerNode=e.Konva=e.glob=void 0;const r=Math.PI/180;e.glob=void 0!==n.g?n.g:"undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope?self:{},e.Konva={_global:e.glob,version:"9.3.22",isBrowser:"undefined"!=typeof window&&("[object Window]"==={}.toString.call(window)||"[object global]"==={}.toString.call(window)),isUnminified:/param/.test(function(t){}.toString()),dblClickWindow:400,getAngle:t=>e.Konva.angleDeg?t*r:t,enableTrace:!1,pointerEventsEnabled:!0,autoDrawEnabled:!0,hitOnDragEnabled:!1,capturePointerEventsEnabled:!1,_mouseListenClick:!1,_touchListenClick:!1,_pointerListenClick:!1,_mouseInDblClickWindow:!1,_touchInDblClickWindow:!1,_pointerInDblClickWindow:!1,_mouseDblClickPointerId:null,_touchDblClickPointerId:null,_pointerDblClickPointerId:null,_fixTextRendering:!1,pixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging:()=>e.Konva.DD.isDragging,isTransforming(){var t;return null===(t=e.Konva.Transformer)||void 0===t?void 0:t.isTransforming()},isDragReady:()=>!!e.Konva.DD.node,releaseCanvasOnDestroy:!0,document:e.glob.document,_injectGlobal(t){e.glob.Konva=t}},e._registerNode=t=>{e.Konva[t.prototype.getClassName()]=t},e.Konva._injectGlobal(e.Konva)},9131:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RegularPolygon=void 0;const r=n(4892),i=n(4723),o=n(5483),a=n(8871);class s extends i.Shape{_sceneFunc(t){const e=this._getPoints();t.beginPath(),t.moveTo(e[0].x,e[0].y);for(let n=1;n<e.length;n++)t.lineTo(e[n].x,e[n].y);t.closePath(),t.fillStrokeShape(this)}_getPoints(){const t=this.attrs.sides,e=this.attrs.radius||0,n=[];for(let r=0;r<t;r++)n.push({x:e*Math.sin(2*r*Math.PI/t),y:-1*e*Math.cos(2*r*Math.PI/t)});return n}getSelfRect(){const t=this._getPoints();let e=t[0].x,n=t[0].y,r=t[0].x,i=t[0].y;return t.forEach(t=>{e=Math.min(e,t.x),n=Math.max(n,t.x),r=Math.min(r,t.y),i=Math.max(i,t.y)}),{x:e,y:r,width:n-e,height:i-r}}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}}e.RegularPolygon=s,s.prototype.className="RegularPolygon",s.prototype._centroid=!0,s.prototype._attrsAffectingSize=["radius"],(0,a._registerNode)(s),r.Factory.addGetterSetter(s,"radius",0,(0,o.getNumberValidator)()),r.Factory.addGetterSetter(s,"sides",0,(0,o.getNumberValidator)())},9308:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Sprite=void 0;const r=n(4892),i=n(4723),o=n(9696),a=n(5483),s=n(8871);class l extends i.Shape{constructor(t){super(t),this._updated=!0,this.anim=new o.Animation(()=>{const t=this._updated;return this._updated=!1,t}),this.on("animationChange.konva",function(){this.frameIndex(0)}),this.on("frameIndexChange.konva",function(){this._updated=!0}),this.on("frameRateChange.konva",function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())})}_sceneFunc(t){const e=this.animation(),n=this.frameIndex(),r=4*n,i=this.animations()[e],o=this.frameOffsets(),a=i[r+0],s=i[r+1],l=i[r+2],c=i[r+3],h=this.image();if((this.hasFill()||this.hasStroke())&&(t.beginPath(),t.rect(0,0,l,c),t.closePath(),t.fillStrokeShape(this)),h)if(o){const r=o[e],i=2*n;t.drawImage(h,a,s,l,c,r[i+0],r[i+1],l,c)}else t.drawImage(h,a,s,l,c,0,0,l,c)}_hitFunc(t){const e=this.animation(),n=this.frameIndex(),r=4*n,i=this.animations()[e],o=this.frameOffsets(),a=i[r+2],s=i[r+3];if(t.beginPath(),o){const r=o[e],i=2*n;t.rect(r[i+0],r[i+1],a,s)}else t.rect(0,0,a,s);t.closePath(),t.fillShape(this)}_useBufferCanvas(){return super._useBufferCanvas(!0)}_setInterval(){const t=this;this.interval=setInterval(function(){t._updateIndex()},1e3/this.frameRate())}start(){if(this.isRunning())return;const t=this.getLayer();this.anim.setLayers(t),this._setInterval(),this.anim.start()}stop(){this.anim.stop(),clearInterval(this.interval)}isRunning(){return this.anim.isRunning()}_updateIndex(){const t=this.frameIndex(),e=this.animation();t<this.animations()[e].length/4-1?this.frameIndex(t+1):this.frameIndex(0)}}e.Sprite=l,l.prototype.className="Sprite",(0,s._registerNode)(l),r.Factory.addGetterSetter(l,"animation"),r.Factory.addGetterSetter(l,"animations"),r.Factory.addGetterSetter(l,"frameOffsets"),r.Factory.addGetterSetter(l,"image"),r.Factory.addGetterSetter(l,"frameIndex",0,(0,a.getNumberValidator)()),r.Factory.addGetterSetter(l,"frameRate",17,(0,a.getNumberValidator)()),r.Factory.backCompat(l,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"})},9456:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Arrow=void 0;const r=n(4892),i=n(3443),o=n(5483),a=n(8871),s=n(1486);class l extends i.Line{_sceneFunc(t){super._sceneFunc(t);const e=2*Math.PI,n=this.points();let r=n;const i=0!==this.tension()&&n.length>4;i&&(r=this.getTensionPoints());const o=this.pointerLength(),a=n.length;let l,c;if(i){const t=[r[r.length-4],r[r.length-3],r[r.length-2],r[r.length-1],n[a-2],n[a-1]],e=s.Path.calcLength(r[r.length-4],r[r.length-3],"C",t),i=s.Path.getPointOnQuadraticBezier(Math.min(1,1-o/e),t[0],t[1],t[2],t[3],t[4],t[5]);l=n[a-2]-i.x,c=n[a-1]-i.y}else l=n[a-2]-n[a-4],c=n[a-1]-n[a-3];const h=(Math.atan2(c,l)+e)%e,u=this.pointerWidth();this.pointerAtEnding()&&(t.save(),t.beginPath(),t.translate(n[a-2],n[a-1]),t.rotate(h),t.moveTo(0,0),t.lineTo(-o,u/2),t.lineTo(-o,-u/2),t.closePath(),t.restore(),this.__fillStroke(t)),this.pointerAtBeginning()&&(t.save(),t.beginPath(),t.translate(n[0],n[1]),i?(l=(r[0]+r[2])/2-n[0],c=(r[1]+r[3])/2-n[1]):(l=n[2]-n[0],c=n[3]-n[1]),t.rotate((Math.atan2(-c,-l)+e)%e),t.moveTo(0,0),t.lineTo(-o,u/2),t.lineTo(-o,-u/2),t.closePath(),t.restore(),this.__fillStroke(t))}__fillStroke(t){const e=this.dashEnabled();e&&(this.attrs.dashEnabled=!1,t.setLineDash([])),t.fillStrokeShape(this),e&&(this.attrs.dashEnabled=!0)}getSelfRect(){const t=super.getSelfRect(),e=this.pointerWidth()/2;return{x:t.x,y:t.y-e,width:t.width,height:t.height+2*e}}}e.Arrow=l,l.prototype.className="Arrow",(0,a._registerNode)(l),r.Factory.addGetterSetter(l,"pointerLength",10,(0,o.getNumberValidator)()),r.Factory.addGetterSetter(l,"pointerWidth",10,(0,o.getNumberValidator)()),r.Factory.addGetterSetter(l,"pointerAtBeginning",!1),r.Factory.addGetterSetter(l,"pointerAtEnding",!0)},9696:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Animation=void 0;const r=n(8871),i=n(4060),o=r.glob.performance&&r.glob.performance.now?function(){return r.glob.performance.now()}:function(){return(new Date).getTime()};class a{constructor(t,e){this.id=a.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:o(),frameRate:0},this.func=t,this.setLayers(e)}setLayers(t){let e=[];return t&&(e=Array.isArray(t)?t:[t]),this.layers=e,this}getLayers(){return this.layers}addLayer(t){const e=this.layers,n=e.length;for(let r=0;r<n;r++)if(e[r]._id===t._id)return!1;return this.layers.push(t),!0}isRunning(){const t=a.animations,e=t.length;for(let n=0;n<e;n++)if(t[n].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=o(),a._addAnimation(this),this}stop(){return a._removeAnimation(this),this}_updateFrameObject(t){this.frame.timeDiff=t-this.frame.lastTime,this.frame.lastTime=t,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1e3/this.frame.timeDiff}static _addAnimation(t){this.animations.push(t),this._handleAnimation()}static _removeAnimation(t){const e=t.id,n=this.animations,r=n.length;for(let t=0;t<r;t++)if(n[t].id===e){this.animations.splice(t,1);break}}static _runFrames(){const t={},e=this.animations;for(let n=0;n<e.length;n++){const r=e[n],i=r.layers,a=r.func;r._updateFrameObject(o());const s=i.length;let l;if(l=!a||!1!==a.call(r,r.frame),l)for(let e=0;e<s;e++){const n=i[e];void 0!==n._id&&(t[n._id]=n)}}for(const e in t)t.hasOwnProperty(e)&&t[e].batchDraw()}static _animationLoop(){const t=a;t.animations.length?(t._runFrames(),i.Util.requestAnimFrame(t._animationLoop)):t.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,i.Util.requestAnimFrame(this._animationLoop))}}e.Animation=a,a.animations=[],a.animIdCounter=0,a.animRunning=!1},9729:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Circle=void 0;const r=n(4892),i=n(4723),o=n(5483),a=n(8871);class s extends i.Shape{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.attrs.radius||0,0,2*Math.PI,!1),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius()!==t/2&&this.radius(t/2)}setHeight(t){this.radius()!==t/2&&this.radius(t/2)}}e.Circle=s,s.prototype._centroid=!0,s.prototype.className="Circle",s.prototype._attrsAffectingSize=["radius"],(0,a._registerNode)(s),r.Factory.addGetterSetter(s,"radius",0,(0,o.getNumberValidator)())},9869:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.HitContext=e.SceneContext=e.Context=void 0;const r=n(4060),i=n(8871),o=["arc","arcTo","beginPath","bezierCurveTo","clearRect","clip","closePath","createLinearGradient","createPattern","createRadialGradient","drawImage","ellipse","fill","fillText","getImageData","createImageData","lineTo","moveTo","putImageData","quadraticCurveTo","rect","roundRect","restore","rotate","save","scale","setLineDash","setTransform","stroke","strokeText","transform","translate"];class a{constructor(t){this.canvas=t,i.Konva.enableTrace&&(this.traceArr=[],this._enableTrace())}fillShape(t){t.fillEnabled()&&this._fill(t)}_fill(t){}strokeShape(t){t.hasStroke()&&this._stroke(t)}_stroke(t){}fillStrokeShape(t){t.attrs.fillAfterStrokeEnabled?(this.strokeShape(t),this.fillShape(t)):(this.fillShape(t),this.strokeShape(t))}getTrace(t,e){let n,i,o,a,s=this.traceArr,l=s.length,c="";for(n=0;n<l;n++)i=s[n],o=i.method,o?(a=i.args,c+=o,t?c+="()":r.Util._isArray(a[0])?c+="(["+a.join(",")+"])":(e&&(a=a.map(t=>"number"==typeof t?Math.floor(t):t)),c+="("+a.join(",")+")")):(c+=i.property,t||(c+="="+i.val)),c+=";";return c}clearTrace(){this.traceArr=[]}_trace(t){let e,n=this.traceArr;n.push(t),e=n.length,e>=100&&n.shift()}reset(){const t=this.getCanvas().getPixelRatio();this.setTransform(1*t,0,0,1*t,0,0)}getCanvas(){return this.canvas}clear(t){const e=this.getCanvas();t?this.clearRect(t.x||0,t.y||0,t.width||0,t.height||0):this.clearRect(0,0,e.getWidth()/e.pixelRatio,e.getHeight()/e.pixelRatio)}_applyLineCap(t){const e=t.attrs.lineCap;e&&this.setAttr("lineCap",e)}_applyOpacity(t){const e=t.getAbsoluteOpacity();1!==e&&this.setAttr("globalAlpha",e)}_applyLineJoin(t){const e=t.attrs.lineJoin;e&&this.setAttr("lineJoin",e)}setAttr(t,e){this._context[t]=e}arc(t,e,n,r,i,o){this._context.arc(t,e,n,r,i,o)}arcTo(t,e,n,r,i){this._context.arcTo(t,e,n,r,i)}beginPath(){this._context.beginPath()}bezierCurveTo(t,e,n,r,i,o){this._context.bezierCurveTo(t,e,n,r,i,o)}clearRect(t,e,n,r){this._context.clearRect(t,e,n,r)}clip(...t){this._context.clip.apply(this._context,t)}closePath(){this._context.closePath()}createImageData(t,e){const n=arguments;return 2===n.length?this._context.createImageData(t,e):1===n.length?this._context.createImageData(t):void 0}createLinearGradient(t,e,n,r){return this._context.createLinearGradient(t,e,n,r)}createPattern(t,e){return this._context.createPattern(t,e)}createRadialGradient(t,e,n,r,i,o){return this._context.createRadialGradient(t,e,n,r,i,o)}drawImage(t,e,n,r,i,o,a,s,l){const c=arguments,h=this._context;3===c.length?h.drawImage(t,e,n):5===c.length?h.drawImage(t,e,n,r,i):9===c.length&&h.drawImage(t,e,n,r,i,o,a,s,l)}ellipse(t,e,n,r,i,o,a,s){this._context.ellipse(t,e,n,r,i,o,a,s)}isPointInPath(t,e,n,r){return n?this._context.isPointInPath(n,t,e,r):this._context.isPointInPath(t,e,r)}fill(...t){this._context.fill.apply(this._context,t)}fillRect(t,e,n,r){this._context.fillRect(t,e,n,r)}strokeRect(t,e,n,r){this._context.strokeRect(t,e,n,r)}fillText(t,e,n,r){r?this._context.fillText(t,e,n,r):this._context.fillText(t,e,n)}measureText(t){return this._context.measureText(t)}getImageData(t,e,n,r){return this._context.getImageData(t,e,n,r)}lineTo(t,e){this._context.lineTo(t,e)}moveTo(t,e){this._context.moveTo(t,e)}rect(t,e,n,r){this._context.rect(t,e,n,r)}roundRect(t,e,n,r,i){this._context.roundRect(t,e,n,r,i)}putImageData(t,e,n){this._context.putImageData(t,e,n)}quadraticCurveTo(t,e,n,r){this._context.quadraticCurveTo(t,e,n,r)}restore(){this._context.restore()}rotate(t){this._context.rotate(t)}save(){this._context.save()}scale(t,e){this._context.scale(t,e)}setLineDash(t){this._context.setLineDash?this._context.setLineDash(t):"mozDash"in this._context?this._context.mozDash=t:"webkitLineDash"in this._context&&(this._context.webkitLineDash=t)}getLineDash(){return this._context.getLineDash()}setTransform(t,e,n,r,i,o){this._context.setTransform(t,e,n,r,i,o)}stroke(t){t?this._context.stroke(t):this._context.stroke()}strokeText(t,e,n,r){this._context.strokeText(t,e,n,r)}transform(t,e,n,r,i,o){this._context.transform(t,e,n,r,i,o)}translate(t,e){this._context.translate(t,e)}_enableTrace(){let t,e,n=this,i=o.length,a=this.setAttr;const s=function(t){let i,o=n[t];n[t]=function(){return e=function(t){const e=[],n=t.length,i=r.Util;for(let r=0;r<n;r++){let n=t[r];i._isNumber(n)?n=Math.round(1e3*n)/1e3:i._isString(n)||(n+=""),e.push(n)}return e}(Array.prototype.slice.call(arguments,0)),i=o.apply(n,arguments),n._trace({method:t,args:e}),i}};for(t=0;t<i;t++)s(o[t]);n.setAttr=function(){a.apply(n,arguments);const t=arguments[0];let e=arguments[1];"shadowOffsetX"!==t&&"shadowOffsetY"!==t&&"shadowBlur"!==t||(e/=this.canvas.getPixelRatio()),n._trace({property:t,val:e})}}_applyGlobalCompositeOperation(t){const e=t.attrs.globalCompositeOperation;!e||"source-over"===e||this.setAttr("globalCompositeOperation",e)}}e.Context=a,["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled"].forEach(function(t){Object.defineProperty(a.prototype,t,{get(){return this._context[t]},set(e){this._context[t]=e}})}),e.SceneContext=class extends a{constructor(t,{willReadFrequently:e=!1}={}){super(t),this._context=t._canvas.getContext("2d",{willReadFrequently:e})}_fillColor(t){const e=t.fill();this.setAttr("fillStyle",e),t._fillFunc(this)}_fillPattern(t){this.setAttr("fillStyle",t._getFillPattern()),t._fillFunc(this)}_fillLinearGradient(t){const e=t._getLinearGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this))}_fillRadialGradient(t){const e=t._getRadialGradient();e&&(this.setAttr("fillStyle",e),t._fillFunc(this))}_fill(t){const e=t.fill(),n=t.getFillPriority();if(e&&"color"===n)return void this._fillColor(t);const r=t.getFillPatternImage();if(r&&"pattern"===n)return void this._fillPattern(t);const i=t.getFillLinearGradientColorStops();if(i&&"linear-gradient"===n)return void this._fillLinearGradient(t);const o=t.getFillRadialGradientColorStops();o&&"radial-gradient"===n?this._fillRadialGradient(t):e?this._fillColor(t):r?this._fillPattern(t):i?this._fillLinearGradient(t):o&&this._fillRadialGradient(t)}_strokeLinearGradient(t){const e=t.getStrokeLinearGradientStartPoint(),n=t.getStrokeLinearGradientEndPoint(),r=t.getStrokeLinearGradientColorStops(),i=this.createLinearGradient(e.x,e.y,n.x,n.y);if(r){for(let t=0;t<r.length;t+=2)i.addColorStop(r[t],r[t+1]);this.setAttr("strokeStyle",i)}}_stroke(t){const e=t.dash(),n=t.getStrokeScaleEnabled();if(t.hasStroke()){if(!n){this.save();const t=this.getCanvas().getPixelRatio();this.setTransform(t,0,0,t,0,0)}this._applyLineCap(t),e&&t.dashEnabled()&&(this.setLineDash(e),this.setAttr("lineDashOffset",t.dashOffset())),this.setAttr("lineWidth",t.strokeWidth()),t.getShadowForStrokeEnabled()||this.setAttr("shadowColor","rgba(0,0,0,0)"),t.getStrokeLinearGradientColorStops()?this._strokeLinearGradient(t):this.setAttr("strokeStyle",t.stroke()),t._strokeFunc(this),n||this.restore()}}_applyShadow(t){var e,n,r;const i=null!==(e=t.getShadowRGBA())&&void 0!==e?e:"black",o=null!==(n=t.getShadowBlur())&&void 0!==n?n:5,a=null!==(r=t.getShadowOffset())&&void 0!==r?r:{x:0,y:0},s=t.getAbsoluteScale(),l=this.canvas.getPixelRatio(),c=s.x*l,h=s.y*l;this.setAttr("shadowColor",i),this.setAttr("shadowBlur",o*Math.min(Math.abs(c),Math.abs(h))),this.setAttr("shadowOffsetX",a.x*c),this.setAttr("shadowOffsetY",a.y*h)}},e.HitContext=class extends a{constructor(t){super(t),this._context=t._canvas.getContext("2d",{willReadFrequently:!0})}_fill(t){this.save(),this.setAttr("fillStyle",t.colorKey),t._fillFuncHit(this),this.restore()}strokeShape(t){t.hasHitStroke()&&this._stroke(t)}_stroke(t){if(t.hasHitStroke()){const e=t.getStrokeScaleEnabled();if(!e){this.save();const t=this.getCanvas().getPixelRatio();this.setTransform(t,0,0,t,0,0)}this._applyLineCap(t);const n=t.hitStrokeWidth(),r="auto"===n?t.strokeWidth():n;this.setAttr("lineWidth",r),this.setAttr("strokeStyle",t.colorKey),t._strokeFuncHit(this),e||this.restore()}}}},9982:function(t,e,n){var r;!function(){var e={};!function(t){"use strict";t.__esModule=!0,t.digestLength=32,t.blockSize=64;var e=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function n(t,n,r,i,o){for(var a,s,l,c,h,u,d,f,g,p,m,y,v;o>=64;){for(a=n[0],s=n[1],l=n[2],c=n[3],h=n[4],u=n[5],d=n[6],f=n[7],p=0;p<16;p++)m=i+4*p,t[p]=(255&r[m])<<24|(255&r[m+1])<<16|(255&r[m+2])<<8|255&r[m+3];for(p=16;p<64;p++)y=((g=t[p-2])>>>17|g<<15)^(g>>>19|g<<13)^g>>>10,v=((g=t[p-15])>>>7|g<<25)^(g>>>18|g<<14)^g>>>3,t[p]=(y+t[p-7]|0)+(v+t[p-16]|0);for(p=0;p<64;p++)y=(((h>>>6|h<<26)^(h>>>11|h<<21)^(h>>>25|h<<7))+(h&u^~h&d)|0)+(f+(e[p]+t[p]|0)|0)|0,v=((a>>>2|a<<30)^(a>>>13|a<<19)^(a>>>22|a<<10))+(a&s^a&l^s&l)|0,f=d,d=u,u=h,h=c+y|0,c=l,l=s,s=a,a=y+v|0;n[0]+=a,n[1]+=s,n[2]+=l,n[3]+=c,n[4]+=h,n[5]+=u,n[6]+=d,n[7]+=f,i+=64,o-=64}return i}var r=function(){function e(){this.digestLength=t.digestLength,this.blockSize=t.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return e.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this},e.prototype.clean=function(){for(var t=0;t<this.buffer.length;t++)this.buffer[t]=0;for(t=0;t<this.temp.length;t++)this.temp[t]=0;this.reset()},e.prototype.update=function(t,e){if(void 0===e&&(e=t.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");var r=0;if(this.bytesHashed+=e,this.bufferLength>0){for(;this.bufferLength<64&&e>0;)this.buffer[this.bufferLength++]=t[r++],e--;64===this.bufferLength&&(n(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(e>=64&&(r=n(this.temp,this.state,t,r,e),e%=64);e>0;)this.buffer[this.bufferLength++]=t[r++],e--;return this},e.prototype.finish=function(t){if(!this.finished){var e=this.bytesHashed,r=this.bufferLength,i=e/536870912|0,o=e<<3,a=e%64<56?64:128;this.buffer[r]=128;for(var s=r+1;s<a-8;s++)this.buffer[s]=0;this.buffer[a-8]=i>>>24&255,this.buffer[a-7]=i>>>16&255,this.buffer[a-6]=i>>>8&255,this.buffer[a-5]=i>>>0&255,this.buffer[a-4]=o>>>24&255,this.buffer[a-3]=o>>>16&255,this.buffer[a-2]=o>>>8&255,this.buffer[a-1]=o>>>0&255,n(this.temp,this.state,this.buffer,0,a),this.finished=!0}for(s=0;s<8;s++)t[4*s+0]=this.state[s]>>>24&255,t[4*s+1]=this.state[s]>>>16&255,t[4*s+2]=this.state[s]>>>8&255,t[4*s+3]=this.state[s]>>>0&255;return this},e.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},e.prototype._saveState=function(t){for(var e=0;e<this.state.length;e++)t[e]=this.state[e]},e.prototype._restoreState=function(t,e){for(var n=0;n<this.state.length;n++)this.state[n]=t[n];this.bytesHashed=e,this.finished=!1,this.bufferLength=0},e}();t.Hash=r;var i=function(){function t(t){this.inner=new r,this.outer=new r,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var e=new Uint8Array(this.blockSize);if(t.length>this.blockSize)(new r).update(t).finish(e).clean();else for(var n=0;n<t.length;n++)e[n]=t[n];for(n=0;n<e.length;n++)e[n]^=54;for(this.inner.update(e),n=0;n<e.length;n++)e[n]^=106;for(this.outer.update(e),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate),n=0;n<e.length;n++)e[n]=0}return t.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},t.prototype.clean=function(){for(var t=0;t<this.istate.length;t++)this.ostate[t]=this.istate[t]=0;this.inner.clean(),this.outer.clean()},t.prototype.update=function(t){return this.inner.update(t),this},t.prototype.finish=function(t){return this.outer.finished?this.outer.finish(t):(this.inner.finish(t),this.outer.update(t,this.digestLength).finish(t)),this},t.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},t}();function o(t){var e=(new r).update(t),n=e.digest();return e.clean(),n}function a(t,e){var n=new i(t).update(e),r=n.digest();return n.clean(),r}function s(t,e,n,r){var i=r[0];if(0===i)throw new Error("hkdf: cannot expand more");e.reset(),i>1&&e.update(t),n&&e.update(n),e.update(r),e.finish(t),r[0]++}t.HMAC=i,t.hash=o,t.default=o,t.hmac=a;var l=new Uint8Array(t.digestLength);t.hkdf=function(t,e,n,r){void 0===e&&(e=l),void 0===r&&(r=32);for(var o=new Uint8Array([1]),c=a(e,t),h=new i(c),u=new Uint8Array(h.digestLength),d=u.length,f=new Uint8Array(r),g=0;g<r;g++)d===u.length&&(s(u,h,n,o),d=0),f[g]=u[d++];return h.clean(),u.fill(0),o.fill(0),f},t.pbkdf2=function(t,e,n,r){for(var o=new i(t),a=o.digestLength,s=new Uint8Array(4),l=new Uint8Array(a),c=new Uint8Array(a),h=new Uint8Array(r),u=0;u*a<r;u++){var d=u+1;s[0]=d>>>24&255,s[1]=d>>>16&255,s[2]=d>>>8&255,s[3]=d>>>0&255,o.reset(),o.update(e),o.update(s),o.finish(c);for(var f=0;f<a;f++)l[f]=c[f];for(f=2;f<=n;f++){o.reset(),o.update(c).finish(c);for(var g=0;g<a;g++)l[g]^=c[g]}for(f=0;f<a&&u*a+f<r;f++)h[u*a+f]=l[f]}for(u=0;u<a;u++)l[u]=c[u]=0;for(u=0;u<4;u++)s[u]=0;return o.clean(),h}}(e);var i=e.default;for(var o in e)i[o]=e[o];"object"==typeof t.exports?t.exports=i:void 0===(r=function(){return i}.call(e,n,e,t))||(t.exports=r)}()}},e={};function n(r){var i=e[r];if(void 0!==i)return i.exports;var o=e[r]={id:r,loaded:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}n.m=t,n.amdO={},n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.u=t=>t+".js",n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.hmd=t=>((t=Object.create(t)).children||(t.children=[]),Object.defineProperty(t,"exports",{enumerable:!0,set:()=>{throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+t.id)}}),t),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{var t;n.g.importScripts&&(t=n.g.location+"");var e=n.g.document;if(!t&&e&&(e.currentScript&&"SCRIPT"===e.currentScript.tagName.toUpperCase()&&(t=e.currentScript.src),!t)){var r=e.getElementsByTagName("script");if(r.length)for(var i=r.length-1;i>-1&&(!t||!/^http(s?):/.test(t));)t=r[i--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=t})(),n.b=document.baseURI||self.location.href,n.nc=void 0;var r={};(()=>{"use strict";n.r(r),n.d(r,{_package:()=>Mi,initAutoTests:()=>Ni,test:()=>Pi,tests:()=>u});const t=DG;n(9982);const e=DG.DataFrame.fromCsv('countries,fasta,smiles,molregno,LON,Zip Code,Street Address Line 1,ImageUrl,user_id,error_message,xray,flag,magnitude,CS-id,pdb_id,accel_a,time_offset,chart,fit,Questions,empty_number,empty_string\nBelgium,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C(=O)OCCCc1cccnc1)c2cccc(c2)C(=O)c3ccccc3,1480014,36.276729583740234,995042300,14016 ROUTE 31W,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,1,1,1QBS,1,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.497360340644872, 1.7058694986686864, 5.278052678195135, 0.16000320889028383],""points"":[{""x"":0.10000000149011612,""y"":2.374499797821045},{""x"":0.6000000238418579,""y"":2.6242473125457764},{""x"":1.100000023841858,""y"":2.367267608642578},{""x"":1.600000023841858,""y"":2.6723148822784424},{""x"":2.0999999046325684,""y"":2.6537344455718994},{""x"":2.5999999046325684,""y"":2.3651671409606934},{""x"":3.0999999046325684,""y"":2.5654284954071045},{""x"":3.5999999046325684,""y"":2.4160959720611572},{""x"":4.099999904632568,""y"":2.286726713180542},{""x"":4.599999904632568,""y"":2.5100042819976807},{""x"":5.099999904632568,""y"":1.6676985025405884},{""x"":5.599999904632568,""y"":0.680136501789093},{""x"":6.099999904632568,""y"":0.3391543924808502},{""x"":6.599999904632568,""y"":0.09038983285427094},{""x"":7.099999904632568,""y"":0.19802775979042053}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[7.525235855508179, 1.3186911876809984, 5.335672608564294, 0.7860743343958098],""points"":[{""x"":0.10000000149011612,""y"":7.988070487976074},{""x"":0.6000000238418579,""y"":7.018453121185303},{""x"":1.100000023841858,""y"":8.115279197692871},{""x"":1.600000023841858,""y"":7.486658096313477},{""x"":2.0999999046325684,""y"":7.396438121795654},{""x"":2.5999999046325684,""y"":7.477052211761475},{""x"":3.0999999046325684,""y"":6.913095474243164},{""x"":3.5999999046325684,""y"":8.01385498046875},{""x"":4.099999904632568,""y"":6.985900402069092},{""x"":4.599999904632568,""y"":6.970335960388184},{""x"":5.099999904632568,""y"":5.448817253112793},{""x"":5.599999904632568,""y"":2.5534818172454834},{""x"":6.099999904632568,""y"":1.893947958946228},{""x"":6.599999904632568,""y"":0.6340042352676392},{""x"":7.099999904632568,""y"":0.8403874039649963}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,100,abc\nBurundi,MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW,COc1ccc2cc(ccc2c1)C(C)C(=O)Oc3ccc(C)cc3OC,1480015,36.276729583740234,995073444,80 STATE HIGHWAY 310,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,2,2,1ZP8,2,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.431460753103398, 2.1691498799246745, 5.266445597102774, 0.7825762827017926],""points"":[{""x"":0.10000000149011612,""y"":4.751083850860596},{""x"":0.6000000238418579,""y"":4.203000068664551},{""x"":1.100000023841858,""y"":4.415858745574951},{""x"":1.600000023841858,""y"":4.68414306640625},{""x"":2.0999999046325684,""y"":4.198400974273682},{""x"":2.5999999046325684,""y"":4.179222106933594},{""x"":3.0999999046325684,""y"":4.638473987579346},{""x"":3.5999999046325684,""y"":4.708553314208984},{""x"":4.099999904632568,""y"":4.291589260101318},{""x"":4.599999904632568,""y"":4.038082599639893},{""x"":5.099999904632568,""y"":3.4349939823150635},{""x"":5.599999904632568,""y"":1.2194708585739136},{""x"":6.099999904632568,""y"":1.1920831203460693},{""x"":6.599999904632568,""y"":0.5352635979652405},{""x"":7.099999904632568,""y"":0.3346920311450958}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.339458017970126, -1.0734184310171178, 4.746332950550934, 0.2482416857595658],""points"":[{""x"":0.10000000149011612,""y"":0.2139337658882141},{""x"":0.6000000238418579,""y"":0.4269562065601349},{""x"":1.100000023841858,""y"":0.2441573292016983},{""x"":1.600000023841858,""y"":0.146635964512825},{""x"":2.0999999046325684,""y"":0.08818462491035461},{""x"":2.5999999046325684,""y"":0.2560656666755676},{""x"":3.0999999046325684,""y"":0.42434045672416687},{""x"":3.5999999046325684,""y"":0.37111231684684753},{""x"":4.099999904632568,""y"":0.5581737160682678},{""x"":4.599999904632568,""y"":1.183590054512024},{""x"":5.099999904632568,""y"":1.5629843473434448},{""x"":5.599999904632568,""y"":2.3211288452148438},{""x"":6.099999904632568,""y"":2.229961633682251},{""x"":6.599999904632568,""y"":2.2560226917266846},{""x"":7.099999904632568,""y"":2.2142398357391357}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCameroon,MIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL,COc1ccc2cc(ccc2c1)C(C)C(=O)OCCCc3cccnc3,1480016,36.26095962524414,995153596,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,3,3,2BDJ,3,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.6760652578642325, 0.9046956320756703, 5.651408971856738, 0.07738846012184185],""points"":[{""x"":0.10000000149011612,""y"":4.32425594329834},{""x"":0.6000000238418579,""y"":4.668442249298096},{""x"":1.100000023841858,""y"":4.379785060882568},{""x"":1.600000023841858,""y"":5.0345139503479},{""x"":2.0999999046325684,""y"":4.878653526306152},{""x"":2.5999999046325684,""y"":4.3451313972473145},{""x"":3.0999999046325684,""y"":4.336992263793945},{""x"":3.5999999046325684,""y"":5.037430286407471},{""x"":4.099999904632568,""y"":5.0092692375183105},{""x"":4.599999904632568,""y"":4.151902675628662},{""x"":5.099999904632568,""y"":3.4066951274871826},{""x"":5.599999904632568,""y"":2.3732759952545166},{""x"":6.099999904632568,""y"":1.673728108406067},{""x"":6.599999904632568,""y"":0.48574790358543396},{""x"":7.099999904632568,""y"":0.2783052325248718}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.938395863010111, -1.4658480661392117, 5.462702751996584, 0.3473139023615039],""points"":[{""x"":0.10000000149011612,""y"":0.4941710829734802},{""x"":0.6000000238418579,""y"":0.15323974192142487},{""x"":1.100000023841858,""y"":0.46373432874679565},{""x"":1.600000023841858,""y"":0.3370431363582611},{""x"":2.0999999046325684,""y"":0.5179030299186707},{""x"":2.5999999046325684,""y"":0.27899765968322754},{""x"":3.0999999046325684,""y"":0.22075064480304718},{""x"":3.5999999046325684,""y"":0.5789918899536133},{""x"":4.099999904632568,""y"":0.21169911324977875},{""x"":4.599999904632568,""y"":0.27857646346092224},{""x"":5.099999904632568,""y"":1.0906332731246948},{""x"":5.599999904632568,""y"":1.8520300388336182},{""x"":6.099999904632568,""y"":2.7177059650421143},{""x"":6.599999904632568,""y"":2.8680918216705322},{""x"":7.099999904632568,""y"":3.2413077354431152}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCanada,MMELVLKTIIGPIVVGVVLRIVDKWLNKDK,CC(C(=O)NCCS)c1cccc(c1)C(=O)c2ccccc2,1480017,36.26095962524414,99515,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,4,4,1IAN,4,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[0.8597390975430008, 1.0957625732481946, 5.260537067987958, 0.07974187998177736],""points"":[{""x"":0.10000000149011612,""y"":0.8190152645111084},{""x"":0.6000000238418579,""y"":0.8421689867973328},{""x"":1.100000023841858,""y"":0.8740922212600708},{""x"":1.600000023841858,""y"":0.8924275040626526},{""x"":2.0999999046325684,""y"":0.8249067664146423},{""x"":2.5999999046325684,""y"":0.9327669143676758},{""x"":3.0999999046325684,""y"":0.8522974252700806},{""x"":3.5999999046325684,""y"":0.8174492716789246},{""x"":4.099999904632568,""y"":0.8394647240638733},{""x"":4.599999904632568,""y"":0.7139387726783752},{""x"":5.099999904632568,""y"":0.5561167597770691},{""x"":5.599999904632568,""y"":0.3276226818561554},{""x"":6.099999904632568,""y"":0.12479474395513535},{""x"":6.599999904632568,""y"":0.13006797432899475},{""x"":7.099999904632568,""y"":0.059702079743146896}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.760930219582546, 1.6591793293833013, 4.667155929720851, 0.7858109544121652],""points"":[{""x"":0.10000000149011612,""y"":6.156993389129639},{""x"":0.6000000238418579,""y"":5.236701965332031},{""x"":1.100000023841858,""y"":6.010560512542725},{""x"":1.600000023841858,""y"":5.495512962341309},{""x"":2.0999999046325684,""y"":6.087770462036133},{""x"":2.5999999046325684,""y"":5.79986572265625},{""x"":3.0999999046325684,""y"":5.597546577453613},{""x"":3.5999999046325684,""y"":5.520902156829834},{""x"":4.099999904632568,""y"":5.360654354095459},{""x"":4.599999904632568,""y"":3.5539746284484863},{""x"":5.099999904632568,""y"":1.577236294746399},{""x"":5.599999904632568,""y"":1.0001264810562134},{""x"":6.099999904632568,""y"":0.9305797815322876},{""x"":6.599999904632568,""y"":0.6033638715744019},{""x"":7.099999904632568,""y"":0.4203685522079468}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nColombia,MDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN,FC(F)(F)c1ccc(OC2CCNCC2)cc1,1480029,36.3309440612793,995152050,1 COURT HOUSE SQUARE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,5,5,4UJ1,5,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[6.4995088314153655, 2.4270351004539914, 5.178659535348579, 0.625653346241577],""points"":[{""x"":0.10000000149011612,""y"":6.496231555938721},{""x"":0.6000000238418579,""y"":6.42543363571167},{""x"":1.100000023841858,""y"":7.040063858032227},{""x"":1.600000023841858,""y"":6.1115403175354},{""x"":2.0999999046325684,""y"":6.680728435516357},{""x"":2.5999999046325684,""y"":6.406774520874023},{""x"":3.0999999046325684,""y"":6.611269474029541},{""x"":3.5999999046325684,""y"":5.889094352722168},{""x"":4.099999904632568,""y"":6.75344705581665},{""x"":4.599999904632568,""y"":6.361435890197754},{""x"":5.099999904632568,""y"":4.1666975021362305},{""x"":5.599999904632568,""y"":1.172118902206421},{""x"":6.099999904632568,""y"":0.801048994064331},{""x"":6.599999904632568,""y"":0.4640021026134491},{""x"":7.099999904632568,""y"":0.0010357667924836278}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[1.4734381347446401, 1.1649805188074196, 4.82958608866421, 0.09500545496710007],""points"":[{""x"":0.10000000149011612,""y"":1.5279096364974976},{""x"":0.6000000238418579,""y"":1.3559974431991577},{""x"":1.100000023841858,""y"":1.5246378183364868},{""x"":1.600000023841858,""y"":1.5567657947540283},{""x"":2.0999999046325684,""y"":1.4114240407943726},{""x"":2.5999999046325684,""y"":1.4045010805130005},{""x"":3.0999999046325684,""y"":1.4769829511642456},{""x"":3.5999999046325684,""y"":1.4875500202178955},{""x"":4.099999904632568,""y"":1.2991987466812134},{""x"":4.599999904632568,""y"":0.922961413860321},{""x"":5.099999904632568,""y"":0.6520044803619385},{""x"":5.599999904632568,""y"":0.15350978076457977},{""x"":6.099999904632568,""y"":0.1078903079032898},{""x"":6.599999904632568,""y"":0.17276449501514435},{""x"":7.099999904632568,""y"":0.14066608250141144}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCosta Rica,MKSTKEEIQTIKTLLKDSRTAKYHKRLQIVL,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCCc3ccccc3,1480018,36.3309440612793,995084218,4041 SOUTHWESTERN BLVD,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,6,6,2BPW,6,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.4833641843311227, -1.8945978742090062, 4.671127708092568, 0.24159861311815153],""points"":[{""x"":0.10000000149011612,""y"":0.0969524160027504},{""x"":0.6000000238418579,""y"":0.028483040630817413},{""x"":1.100000023841858,""y"":0.22087176144123077},{""x"":1.600000023841858,""y"":0.0068915546871721745},{""x"":2.0999999046325684,""y"":0.4305879771709442},{""x"":2.5999999046325684,""y"":0.44774115085601807},{""x"":3.0999999046325684,""y"":0.45346319675445557},{""x"":3.5999999046325684,""y"":0.2370593100786209},{""x"":4.099999904632568,""y"":0.4657953977584839},{""x"":4.599999904632568,""y"":1.155200719833374},{""x"":5.099999904632568,""y"":2.2294070720672607},{""x"":5.599999904632568,""y"":2.4311530590057373},{""x"":6.099999904632568,""y"":2.33846116065979},{""x"":6.599999904632568,""y"":2.608201026916504},{""x"":7.099999904632568,""y"":2.8136143684387207}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.224573521642033, 1.4454033924198528, 5.6014197746076535, 0.2823216054197577],""points"":[{""x"":0.10000000149011612,""y"":4.95027494430542},{""x"":0.6000000238418579,""y"":5.1754679679870605},{""x"":1.100000023841858,""y"":5.276752948760986},{""x"":1.600000023841858,""y"":5.589294910430908},{""x"":2.0999999046325684,""y"":5.616994857788086},{""x"":2.5999999046325684,""y"":5.120813846588135},{""x"":3.0999999046325684,""y"":5.340766906738281},{""x"":3.5999999046325684,""y"":4.876471042633057},{""x"":4.099999904632568,""y"":4.94999361038208},{""x"":4.599999904632568,""y"":5.162564754486084},{""x"":5.099999904632568,""y"":4.399557590484619},{""x"":5.599999904632568,""y"":2.7977969646453857},{""x"":6.099999904632568,""y"":1.0229872465133667},{""x"":6.599999904632568,""y"":0.48275601863861084},{""x"":7.099999904632568,""y"":0.10408931970596313}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCuba,MHAILRYFIRRLFYHIFYKIYSLISKKHQSLPSDVRQF,COc1ccc2c(c1)c(CC(=O)N3CCCC3C(=O)Oc4ccc(C)cc4OC)c(C)n2C(=O)c5ccc(Cl)cc5,1480019,36.33115768432617,995081928,1227 US HIGHWAY 11,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,7,7,1QBS,7,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.320838679713925, -1.2421619987316728, 4.831325425225256, 0.3236011098403072],""points"":[{""x"":0.10000000149011612,""y"":0.3727470338344574},{""x"":0.6000000238418579,""y"":0.12365014106035233},{""x"":1.100000023841858,""y"":0.48422467708587646},{""x"":1.600000023841858,""y"":0.2264465093612671},{""x"":2.0999999046325684,""y"":0.16821794211864471},{""x"":2.5999999046325684,""y"":0.3879014551639557},{""x"":3.0999999046325684,""y"":0.5470244884490967},{""x"":3.5999999046325684,""y"":0.3419053554534912},{""x"":4.099999904632568,""y"":0.7655120491981506},{""x"":4.599999904632568,""y"":1.2346516847610474},{""x"":5.099999904632568,""y"":2.453336715698242},{""x"":5.599999904632568,""y"":2.9565491676330566},{""x"":6.099999904632568,""y"":3.335299491882324},{""x"":6.599999904632568,""y"":3.240290880203247},{""x"":7.099999904632568,""y"":3.1107218265533447}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.6401853521511094, 1.26211588875013, 5.399028074402744, 0.5089580830068091],""points"":[{""x"":0.10000000149011612,""y"":3.8585598468780518},{""x"":0.6000000238418579,""y"":3.6077206134796143},{""x"":1.100000023841858,""y"":3.855252265930176},{""x"":1.600000023841858,""y"":3.619039297103882},{""x"":2.0999999046325684,""y"":3.839388370513916},{""x"":2.5999999046325684,""y"":3.335283041000366},{""x"":3.0999999046325684,""y"":3.571141481399536},{""x"":3.5999999046325684,""y"":3.4155046939849854},{""x"":4.099999904632568,""y"":3.7316646575927734},{""x"":4.599999904632568,""y"":3.0680155754089355},{""x"":5.099999904632568,""y"":2.891066551208496},{""x"":5.599999904632568,""y"":1.6022753715515137},{""x"":6.099999904632568,""y"":0.7652576565742493},{""x"":6.599999904632568,""y"":0.6875326037406921},{""x"":7.099999904632568,""y"":0.5828871726989746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nItaly,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO[N+](=O)[O-],1480020,36.33115768432617,99502,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,8,8,1ZP8,8,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.293592105923809, 1.3781586549141835, 5.1025898038676605, 0.03493851245291291],""points"":[{""x"":0.10000000149011612,""y"":2.1287283897399902},{""x"":0.6000000238418579,""y"":2.267972230911255},{""x"":1.100000023841858,""y"":2.398442506790161},{""x"":1.600000023841858,""y"":2.5130622386932373},{""x"":2.0999999046325684,""y"":2.3255116939544678},{""x"":2.5999999046325684,""y"":2.127340793609619},{""x"":3.0999999046325684,""y"":2.47259783744812},{""x"":3.5999999046325684,""y"":2.131181478500366},{""x"":4.099999904632568,""y"":2.090421438217163},{""x"":4.599999904632568,""y"":2.02299165725708},{""x"":5.099999904632568,""y"":1.1105059385299683},{""x"":5.599999904632568,""y"":0.4494485855102539},{""x"":6.099999904632568,""y"":0.1375635862350464},{""x"":6.599999904632568,""y"":0.036351121962070465},{""x"":7.099999904632568,""y"":0.1619771122932434}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.953125499439879, 1.2528620255306528, 5.187637440149802, 0.3110348753260886],""points"":[{""x"":0.10000000149011612,""y"":5.6585283279418945},{""x"":0.6000000238418579,""y"":5.911152362823486},{""x"":1.100000023841858,""y"":5.924920082092285},{""x"":1.600000023841858,""y"":5.8469438552856445},{""x"":2.0999999046325684,""y"":5.929472923278809},{""x"":2.5999999046325684,""y"":6.190037727355957},{""x"":3.0999999046325684,""y"":6.236179828643799},{""x"":3.5999999046325684,""y"":6.141019344329834},{""x"":4.099999904632568,""y"":5.295210838317871},{""x"":4.599999904632568,""y"":5.265801906585693},{""x"":5.099999904632568,""y"":3.3722851276397705},{""x"":5.599999904632568,""y"":1.8299226760864258},{""x"":6.099999904632568,""y"":0.32690900564193726},{""x"":6.599999904632568,""y"":0.6274543404579163},{""x"":7.099999904632568,""y"":0.8441857099533081}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nRwanda,MPNSEPASLLELFNSIATQGELVRSLKAGNASK,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO,1480021,36.33137130737305,995037247,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,9,2BDJ,9,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.8209972202654474, 1.3779216716448506, 5.299882228439686, 0.06040645519069608],""points"":[{""x"":0.10000000149011612,""y"":3.7821109294891357},{""x"":0.6000000238418579,""y"":3.542433023452759},{""x"":1.100000023841858,""y"":3.7008674144744873},{""x"":1.600000023841858,""y"":3.717301607131958},{""x"":2.0999999046325684,""y"":4.024452209472656},{""x"":2.5999999046325684,""y"":4.013899326324463},{""x"":3.0999999046325684,""y"":3.945094347000122},{""x"":3.5999999046325684,""y"":3.866621971130371},{""x"":4.099999904632568,""y"":3.7461626529693604},{""x"":4.599999904632568,""y"":3.3454740047454834},{""x"":5.099999904632568,""y"":2.61944317817688},{""x"":5.599999904632568,""y"":0.999405026435852},{""x"":6.099999904632568,""y"":0.46259793639183044},{""x"":6.599999904632568,""y"":0.054134611040353775},{""x"":7.099999904632568,""y"":0.05711187422275543}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.6318079657726035, 1.8495493770000595, 5.391793312471116, 0.17060707587348442],""points"":[{""x"":0.10000000149011612,""y"":5.458079814910889},{""x"":0.6000000238418579,""y"":5.554427146911621},{""x"":1.100000023841858,""y"":5.799983024597168},{""x"":1.600000023841858,""y"":5.364140033721924},{""x"":2.0999999046325684,""y"":5.864485740661621},{""x"":2.5999999046325684,""y"":5.4509806632995605},{""x"":3.0999999046325684,""y"":5.702574729919434},{""x"":3.5999999046325684,""y"":5.7314534187316895},{""x"":4.099999904632568,""y"":5.5123443603515625},{""x"":4.599999904632568,""y"":5.724395751953125},{""x"":5.099999904632568,""y"":4.354506969451904},{""x"":5.599999904632568,""y"":1.7307666540145874},{""x"":6.099999904632568,""y"":0.6305936574935913},{""x"":6.599999904632568,""y"":0.035183437168598175},{""x"":7.099999904632568,""y"":0.7575169205665588}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nSwitzerland,IRVVGRYLIEVWKAAGMDMDKVLFLWSSDEI,CN1CCC(CC1)Oc2ccc(cc2)C(F)(F)F,1480028,36.33137130737305,99504,92-11 179TH PLACE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,10,1IAN,10,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[1.1190255865097471, 2.3163895161544437, 5.4968866182279195, 0.2035204047289052],""points"":[{""x"":0.10000000149011612,""y"":1.1057683229446411},{""x"":0.6000000238418579,""y"":1.1019697189331055},{""x"":1.100000023841858,""y"":1.0818607807159424},{""x"":1.600000023841858,""y"":1.062997817993164},{""x"":2.0999999046325684,""y"":1.046447515487671},{""x"":2.5999999046325684,""y"":1.1217249631881714},{""x"":3.0999999046325684,""y"":1.2166996002197266},{""x"":3.5999999046325684,""y"":1.215477705001831},{""x"":4.099999904632568,""y"":1.0581893920898438},{""x"":4.599999904632568,""y"":1.1747995615005493},{""x"":5.099999904632568,""y"":1.0181127786636353},{""x"":5.599999904632568,""y"":0.5344523191452026},{""x"":6.099999904632568,""y"":0.2569526433944702},{""x"":6.599999904632568,""y"":0.1912207305431366},{""x"":7.099999904632568,""y"":0.15060538053512573}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.1038581025805785, 2.0032224204185245, 5.087602825989163, 0.13277988512492753],""points"":[{""x"":0.10000000149011612,""y"":3.0498509407043457},{""x"":0.6000000238418579,""y"":2.805217742919922},{""x"":1.100000023841858,""y"":3.3415253162384033},{""x"":1.600000023841858,""y"":3.0549843311309814},{""x"":2.0999999046325684,""y"":3.250074863433838},{""x"":2.5999999046325684,""y"":3.0432586669921875},{""x"":3.0999999046325684,""y"":3.265852451324463},{""x"":3.5999999046325684,""y"":2.9475724697113037},{""x"":4.099999904632568,""y"":3.1929898262023926},{""x"":4.599999904632568,""y"":2.7460060119628906},{""x"":5.099999904632568,""y"":1.6175861358642578},{""x"":5.599999904632568,""y"":0.3006608486175537},{""x"":6.099999904632568,""y"":0.3444803059101105},{""x"":6.599999904632568,""y"":0.015537971630692482},{""x"":7.099999904632568,""y"":0.5527358055114746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\n,,,,,,,,,,,,,,,,,,,,,');e.columns.add(DG.Column.fromList(DG.TYPE.BYTE_ARRAY,"BinaryImage",Array.from(new Uint8Array(11))));var i=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{l(r.next(t))}catch(t){o(t)}}function s(t){try{l(r.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}l((r=r.apply(t,e||[])).next())})};const o=3e4,a=108e5,s=console.log.bind(console),l=console.info.bind(console),c=console.warn.bind(console),h=console.error.bind(console),u={},d="Auto Tests",f="Demo",g="Detectors",p="Core",m={};let y;var v;!function(t){t.notNull=function(t,e){if(null==t)throw new Error(`${null==e?"Value":e} not defined`)}}(v||(v={}));class _{constructor(t,e,n){this.catchUnhandled=!0,this.report=!1,this.returnOnFail=!1,void 0!==t&&(this.catchUnhandled=t),void 0!==e&&(this.report=e),void 0!==n&&(this.returnOnFail=n)}}class w{constructor(t,e,n,r){var a;this.category=t,this.name=e,null!=r||(r={}),null!==(a=r.timeout)&&void 0!==a||(r.timeout=o),this.options=r,this.test=()=>i(this,void 0,void 0,function*(){return new Promise((t,e)=>i(this,void 0,void 0,function*(){var r;let i="";try{DG.Test.isInDebug;let t=yield n();try{i=null!==(r=null==t?void 0:t.toString())&&void 0!==r?r:""}catch(t){i="Can't convert test's result to string",console.error(`Can't convert test's result to string in the ${this.category}:${this.name} test`)}}catch(t){e(t)}t(i)}))})}}function b(t,e,n){null==u[y]&&(u[y]={}),null==u[y].tests&&(u[y].tests=[]),u[y].tests.push(new w(y,t,e,n))}function C(t,e=!0,n){if(n=n?`${n}, `:"",t!==e)throw new Error(`${n}Expected "${e}", got "${t}"`)}function x(t,e,n){var r;y=t,e(),u[y]&&(u[y].clear=null===(r=null==n?void 0:n.clear)||void 0===r||r,u[y].timeout=null==n?void 0:n.timeout,u[y].benchmarks=null==n?void 0:n.benchmarks,u[y].stressTests=null==n?void 0:n.stressTests,u[y].owner=null==n?void 0:n.owner)}function S(t,e){return t.replace(new RegExp(e.name,"gi"),e.nqName)}function A(t,n){var r,s,l,c,h,y,v,_,b,x;return i(this,void 0,void 0,function*(){const A=t.id;if(m[A])return;const E=n?n.tests:u;if("DevTools"===t.name||n&&"DevTools"===n._package.name)for(const t of window.dartTests){const e=t.name.split(/\s*\|\s*!/g);let n=null!==(r=e.pop())&&void 0!==r?r:t.name,i=e.length?p+": "+e.join(": "):p,a=n.split(" | ");n=a[a.length-1],a.unshift(i),a.pop(),i=a.join(": "),void 0===E[i]&&(E[i]={tests:[],clear:!0}),E[i].tests.push(new w(i,n,t.test,{isAggregated:!1,timeout:null!==(l=null===(s=t.options)||void 0===s?void 0:s.timeout)&&void 0!==l?l:o,skipReason:null===(c=t.options)||void 0===c?void 0:c.skipReason,owner:null===(h=t.options)||void 0===h?void 0:h.owner,benchmark:null!==(v=null===(y=t.options)||void 0===y?void 0:y.benchmark)&&void 0!==v&&v}))}const T=[],M=[],N=[],O=yield grok.dapi.functions.filter(`package.id = "${A}"`).list(),F=new RegExp(/skip:\s*([^,\s]+)|wait:\s*(\d+)|cat:\s*([^,\s]+)|timeout:\s*(\d+)/g);for(const n of O){const r=n.options.test,s=n.options.demoPath;if(r&&Array.isArray(r)&&r.length)for(let t=0;t<r.length;t++){const e=r[t].matchAll(F),s={};Array.from(e).forEach(t=>{t[0].startsWith("skip")?s.skip=t[1]:t[0].startsWith("wait")?s.wait=parseInt(t[2]):t[0].startsWith("cat")?s.cat=t[3]:t[0].startsWith("timeout")&&(s.timeout=parseInt(t[4]))});const l=new w(null!==(_=s.cat)&&void 0!==_?_:d,1===r.length?n.name:`${n.name} ${t+1}`,()=>i(this,void 0,void 0,function*(){const e=yield grok.functions.eval(S(r[t],n));if(s.wait&&(yield P(s.wait)),"boolean"==typeof e&&!e)throw`Failed: ${r[t]}, expected true, got ${e}`}),{skipReason:s.skip,timeout:DG.Test.isInBenchmark?null!==(b=s.benchmarkTimeout)&&void 0!==b?b:a:null!==(x=s.timeout)&&void 0!==x?x:o});if(s.cat){const t=s.cat;void 0===E[t]&&(E[t]={tests:[],clear:!0}),E[t].tests||(E[t].tests=[]),E[t].tests.push(l)}else T.push(l)}if(s){const t=n.options.demoWait?parseInt(n.options.demoWait):void 0,e=new w(f,n.friendlyName,()=>i(this,void 0,void 0,function*(){yield P(300),grok.shell.clearLastError(),yield n.apply(),yield P(t||2e3);const e=yield grok.shell.lastError;if(e)throw new Error(e)}),{skipReason:n.options.demoSkip});M.push(e)}if(n.hasTag("semTypeDetector")){let r=e;n.options.testData&&(r=yield grok.data.files.openTable(`System:AppData/${t.nqName}/${n.options.testData}`));const o=new w(g,n.friendlyName,()=>i(this,void 0,void 0,function*(){const e=[];console.log(`System:AppData/${t.nqName}/${n.options.testData}`);for(const t of r.clone().columns){const r=yield n.apply([t]);e.push(r||t.semType)}const i=e.filter(t=>t);C(i.length,1),n.options.testDataColumnName&&C(i[0],n.options.testDataColumnName)}),{skipReason:n.options.skipTest});N.push(o)}}m[A]=!0,T.length>0&&(E[d]={tests:T,clear:!0}),M.length>0&&(E[f]={tests:M,clear:!0}),N.length>0&&(E[g]={tests:N,clear:!1})})}function E(t){return i(this,void 0,void 0,function*(){return`${t.toString()}\n${t.stack?yield DG.Logger.translateStackTrace(t.stack):""}`})}function T(t,e,n,r,a,l){var c,u,d,f,g,p,m,y,v,_,w,b,C,x;return i(this,void 0,void 0,function*(){let i;n.length=0;const S=null!=e&&t.name.toLowerCase()!==e.toLowerCase();let A=(null===(c=t.options)||void 0===c?void 0:c.skipReason)||S,T=S?"skipped":null===(u=t.options)||void 0===u?void 0:u.skipReason;if(DG.Test.isInBenchmark&&!(null===(d=t.options)||void 0===d?void 0:d.benchmark))return void s(`Package testing: Skipped {{${t.category}}} {{${t.name}}} doesnt available in benchmark mode`);A&&!DG.Test.isInBenchmark&&s(`Package testing: Skipped {{${t.category}}} {{${t.name}}}`),A||s(`Package testing: Started {{${t.category}}} {{${t.name}}}`);const M=Date.now(),P=new Date(M).toISOString();try{if(A)i={name:t.name,owner:null!==(g=null===(f=t.options)||void 0===f?void 0:f.owner)&&void 0!==g?g:"",category:t.category,logs:"",date:P,success:!0,result:T,ms:0,skipped:!0,package:null!=a?a:"",flaking:DG.Test.isReproducing};else{let e=null!=r?r:o;DG.Test.isProfiling&&console.profile(`${t.category}: ${t.name}`),i={name:t.name,owner:null!==(m=null===(p=t.options)||void 0===p?void 0:p.owner)&&void 0!==m?m:"",category:t.category,logs:"",date:P,success:!0,result:null!==(y=(yield N(t.test,e)).toString())&&void 0!==y?y:"OK",ms:0,skipped:!1,package:null!=a?a:"",flaking:DG.Test.isReproducing},DG.Test.isProfiling&&(console.profileEnd(`${t.category}: ${t.name}`),grok.shell.info(`Profiling of ${t.category}: ${t.name} finished \n Please ensure that you have opened DevTools (F12) / Performance panel before test starts.`))}}catch(e){h(e),i={name:t.name,owner:null!==(_=null===(v=t.options)||void 0===v?void 0:v.owner)&&void 0!==_?_:"",category:t.category,logs:"",date:P,success:!1,result:yield E(e),ms:0,skipped:!1,package:null!=a?a:"",flaking:!1}}if((null===(w=t.options)||void 0===w?void 0:w.isAggregated)&&i.result.constructor===DG.DataFrame){const t=i.result.col("success");if(t&&(i.success=t.stats.sum===t.length),!l){const t=i.result;t.columns.remove("stack"),t.rows.removeWhere(t=>t.get("success")),i.result=t}i.result=i.result.toCsv()}if(i.logs=n.join("\n"),i.ms=Date.now()-M,A||s(`Package testing: Finished {{${t.category}}} {{${t.name}}} with {{${i.success?"success":"error"}}} for ${i.ms} ms`),i.success||s(`Package testing: Result for {{${t.category}}} {{${t.name}}}: ${i.result}`),i.category=t.category,i.name=t.name,i.owner=null!==(C=null===(b=t.options)||void 0===b?void 0:b.owner)&&void 0!==C?C:"",!S){let e={success:i.success,result:i.result,ms:i.ms,date:i.date,skipped:i.skipped,category:t.category,name:t.name,logs:i.logs,owner:i.owner,flaking:DG.Test.isReproducing&&i.success,package:i.package};if(i.result.constructor==Object){const t=Object.keys(i.result).reduce((t,e)=>Object.assign(Object.assign({},t),{["result."+e]:i.result[e]}),{});e=Object.assign(Object.assign({},e),t)}e.result instanceof DG.DataFrame&&(e.result=JSON.stringify(null===(x=e.result)||void 0===x?void 0:x.toJson())||""),yield grok.shell.reportTest("package",e)}return i})}function M(t){const e=t.slice();return e.sort(()=>Math.random()-.5),e}function P(t){return i(this,void 0,void 0,function*(){yield new Promise(e=>setTimeout(e,t))})}function N(t,e,n="EXECUTION TIMEOUT"){return i(this,void 0,void 0,function*(){let r=null;const i=new Promise((t,i)=>{r=setTimeout(()=>{i(n)},e)});try{return yield Promise.race([t(),i])}finally{r&&clearTimeout(r)}})}DG.DataFrame.fromColumns([DG.Column.fromStrings("col",["val1","val2","val3"])]);const O=grok;var F,R,I,D,L,k,U,G,B;!function(t){t.UMAP="UMAP",t.T_SNE="t-SNE"}(F||(F={})),function(t){t.Levenshtein="Levenshtein",t.JaroWinkler="Jaro-Winkler",t.Manhattan="Manhattan String",t.Onehot="One-Hot"}(R||(R={})),function(t){t.Euclidean="Euclidean",t.Manhattan="Manhattan",t.Cosine="Vector Cosine"}(I||(I={})),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"}(D||(D={})),function(t){t.TanimotoIntArray="TanimotoIntArray"}(L||(L={})),(B=k||(k={})).Vector="Vector",B.String="String",B.BitArray="BitArray",B.MacroMolecule="MacroMolecule",B.Number="Number",B.IntArray="IntArray",B.NumberArray="NumberArray",function(t){t.Difference="Difference"}(U||(U={})),function(t){t.CommonItems="Common Items"}(G||(G={}));const V=new Uint32Array(65536),H=(t,e)=>{if(t.length<e.length){const n=e;e=t,t=n}return 0===e.length?t.length:t.length<=32?((t,e)=>{const n=t.length,r=e.length,i=1<<n-1;let o=-1,a=0,s=n,l=n;for(;l--;)V[t.charCodeAt(l)]|=1<<l;for(l=0;l<r;l++){let t=V[e.charCodeAt(l)];const n=t|a;t|=(t&o)+o^o,a|=~(t|o),o&=t,a&i&&s++,o&i&&s--,a=a<<1|1,o=o<<1|~(n|a),a&=n}for(l=n;l--;)V[t.charCodeAt(l)]=0;return s})(t,e):((t,e)=>{const n=e.length,r=t.length,i=[],o=[],a=Math.ceil(n/32),s=Math.ceil(r/32);for(let t=0;t<a;t++)o[t]=-1,i[t]=0;let l=0;for(;l<s-1;l++){let a=0,s=-1;const c=32*l,h=Math.min(32,r)+c;for(let e=c;e<h;e++)V[t.charCodeAt(e)]|=1<<e;for(let t=0;t<n;t++){const n=V[e.charCodeAt(t)],r=o[t/32|0]>>>t&1,l=i[t/32|0]>>>t&1,c=n|a,h=((n|l)&s)+s^s|n|l;let u=a|~(h|s),d=s&h;u>>>31^r&&(o[t/32|0]^=1<<t),d>>>31^l&&(i[t/32|0]^=1<<t),u=u<<1|r,d=d<<1|l,s=d|~(c|u),a=u&c}for(let e=c;e<h;e++)V[t.charCodeAt(e)]=0}let c=0,h=-1;const u=32*l,d=Math.min(32,r-u)+u;for(let e=u;e<d;e++)V[t.charCodeAt(e)]|=1<<e;let f=r;for(let t=0;t<n;t++){const n=V[e.charCodeAt(t)],a=o[t/32|0]>>>t&1,s=i[t/32|0]>>>t&1,l=n|c,u=((n|s)&h)+h^h|n|s;let d=c|~(u|h),g=h&u;f+=d>>>r-1&1,f-=g>>>r-1&1,d>>>31^a&&(o[t/32|0]^=1<<t),g>>>31^s&&(i[t/32|0]^=1<<t),d=d<<1|a,g=g<<1|s,h=g|~(l|d),c=d&l}for(let e=u;e<d;e++)V[t.charCodeAt(e)]=0;return f})(t,e)};var W=n(944);class Y{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=Y._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 Y(t._length);n._length=t._length,n._data=Y._createBuffer(n._length),n._version=0;const r=t.lengthInInts;for(let i=0;i<r;i++)n._data[i]=t._data[i]&e._data[i];return n}static _createBuffer(t){return new Uint32Array(Math.floor((t+31)/32))}static fromValues(t){const e=new Y(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 Y(t);for(let r=0;r<t;++r)n.setBit(r,e(r));return n._version=0,n}static fromString(t){return Y.fromSeq(t.length,e=>"1"==t.charAt(e))}static fromUint32Array(t,e){const n=new Y(t);return n._data=e,n}static fromBytes(t){const e=t.length,n=new Y(8*e);n._data=new Uint32Array(Math.floor((e+3)/4)),n._length=8*e;let r=0,i=0;for(;e-i>=4;)n._data[r++]=255&t[i]|(255&t[i+1])<<8|(255&t[i+2])<<16|(255&t[i+3])<<24,i+=4;return e-i==3&&(n._data[r]=(255&t[i+2])<<16),e-i==2&&(n._data[r]|=(255&t[i+1])<<8),e-i==1&&(n._data[r]|=255&t[i]),n._version=0,n}toString(){return`${this._length} bits, ${this.countBits(!0)} set`}equals(t){if(this==t)return!0;if(null==t)return!1;if(this._length!=t._length)return!1;if(0==this._length)return!0;for(let e=0;e<this._data.length-1;e++)if(this._data[e]!=t._data[e])return!1;for(let e=8*(this._data.length-1);e<this._length;e++)if(this.getBit(e)!=t.getBit(e))return!1;return!0}clone(){const t=new Y(0,!1);return t._data=Uint32Array.from(this._data),t._length=this._length,t._version=this._version,t}init(t,e){this.setAll(!1,!1);for(let e=0;e<this._length;e++)t(e)&&(this._data[Math.floor(e/32)]|=1<<(e%32&31));return this.incrementVersion(e),this}invert(t=!0){for(let t=0;t<this._data.length;t++)this._data[t]^=-1;this.incrementVersion(t)}setAll(t,e=!1){const n=t?-1:0,r=this.lengthInInts;for(let t=0;t<r;t++)this._data[t]=n;this.incrementVersion(e)}setIndexes(t,e=!0,n=!0,r=!0){n&&this.setAll(!e,!1);for(const n of t)this.setFast(n,e);this.incrementVersion(r)}everyIndex(t,e=!0){for(const n of t)if(this.getBit(n)!=e)return!1;return!0}anyIndex(t,e=!0){for(const n of t)if(this.getBit(n)==e)return!0;return!1}setWhere(t,e=!0,n=!0,r=!0,i=!0){if(n&&i&&this.setAll(!e,!1),i)for(let n=0;n<this._length;n++)t(n)&&this.setFast(n,e);else for(let n=0;n<this._length;n++)this.setFast(n,t(n)?e:!e);this.incrementVersion(r)}getRange(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const n=[];for(let r=t;r<e;++r)n.push(this.getBit(r));return Y.fromValues(n)}getRangeAsList(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const n=[];for(let r=t;r<e;++r)n.push(this.getBit(r));return n}setRange(t,e,n,r=!0){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length-1,"to");const i=Math.min(t,e),o=Math.max(t,e);if(n)for(let t=i;t<=o;t++)this.setTrue(t);else for(let t=i;t<=o;t++)this.setFalse(t);return this.incrementVersion(r),this}setRandom(t,e,n=!0){if(t<0||t>this._length)throw new Error("n must be >= 0 && <= Count");t>this._length/2&&this.setRandom(this._length-t,!e),this.setAll(!e);for(let n=0;n<t;){const t=Math.floor(Math.random()*this._length);this.getBit(t)!=e&&(this.setFast(t,e),n++)}this.incrementVersion(n)}and(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]&=t._data[e];return this.incrementVersion(e),this}andNot(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");const n=this.lengthInInts;for(let e=0;e<n;e++)this._data[e]&=~t._data[e];return this.incrementVersion(e),this}notAnd(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]=~this._data[e]&t._data[e];return this.incrementVersion(e),this}not(t=!0){for(let t=0,e=this.lengthInInts;t<e;t++)this._data[t]=~this._data[t];return this.incrementVersion(t),this}or(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]|=t._data[e];return this.incrementVersion(e),this}xor(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]^=t._data[e];return this.incrementVersion(e),this}insertAt(t,e,n=!1){if(this.assureInRange(t,0,this._length,"pos"),0==e)return;const r=this._length;this.setLength(this._length+e);for(let n=r-1;n>=t;n--)this.setBit(n+e,this.getBit(n));for(let r=t;r<t+e;r++)this.setBit(r,n)}removeAt(t,e=1){if(e<0)throw new Error("n cannot be negative");if(this.assureInRange(t,0,this._length-e,"pos"),this.contains(!0))for(let n=t;n<this._length-e;n++)this.setBit(n,this.getBit(n+e));this.setLength(this._length-e)}removeByMask(t,e=!0){if(this._length!=t.length)throw new Error("length != mask.length");if(t==this)this.setLength(t.countBits(!e)),this.setAll(!e);else{let n=0;for(let r=-1;-1!=(r=t.findNext(r,!e));)this.setFast(n++,this.getBit(r));this._length=n,this._version++}return this}getBit(t){return!!(this._data[Math.floor(t/32)]&1<<(31&t))}setBit(t,e,n=!0){this.setFast(t,e),this._version++}setFast(t,e){e?this._data[Math.floor(t/32)]|=1<<(31&t):this._data[Math.floor(t/32)]&=~(1<<(31&t))}setTrue(t){this._data[Math.floor(t/32)]|=1<<(31&t)}setFalse(t){this._data[Math.floor(t/32)]&=~(1<<(31&t))}trueCount(){return this.countBits(!0)}falseCount(){return this.countBits(!1)}countBits(t){if(0==this._length)return 0;if(this._selectedCountVersion!=this._version){this._selectedCount=0;const t=this.lengthInInts;let e=0;for(;e<t-1;e++)for(let t=this._data[e];0!=t;t>>>=8)this._selectedCount+=Y._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+=Y._onBitCount[255&n];this._selectedCountVersion=this._version}return t?this._selectedCount:this._length-this._selectedCount}countWhere(t){let e=0;if(this.trueCount()==this._length)for(let n=0;n<this._length;n++)e+=t(n)?1:0;else for(let n=-1;-1!=(n=this.findNext(n,!0));)e+=t(n)?1:0;return e}andWithCountBits(t,e){if(0==this._length)return 0;let n=0;const r=this.lengthInInts;let i=0;for(;i<r-1;i++)for(let e=this._data[i]&t._data[i];0!=e;e>>>=8)n+=Y._onBitCount[255&e];let o=this._data[i]&t._data[i];const a=31&this._length;for(0!=a&&(o&=~(4294967295<<a));0!=o;o>>>=8)n+=Y._onBitCount[255&o];return e?n:this._length-n}clear(){this.setLength(0)}contains(t){return this.findNext(-1,t)>=0}get allTrue(){return this.countBits(!0)==this._length}get allFalse(){return this.countBits(!1)==this._length}get anyTrue(){return this.countBits(!0)>0}get anyFalse(){return this.countBits(!1)>0}findNext(t,e=!0){if(this.assureInRange(t,-1,this._length,"index"),t>=this._length-1)return-1;let n=31&(t=t<0?0:t+1);const r=this.lengthInInts;for(let i=Math.floor(t/32);i<r;i++){let r=e?this._data[i]:~this._data[i];if(0!=n)r&=4294967295<<n&4294967295,n=0;else if(!e&&-4294967296==r)continue;for(let e=0;0!=r;e+=8,r>>>=8){const n=Y._firstOnBit[255&r];if(n>=0)return(t=n+32*i+e)>=this._length?-1:t}}return-1}findPrev(t,e=!0){if(0==t)return-1;this.assureInRange(t,-1,this._length,"index");let n=1+(t=t<0?this._length-1:t-1)&31;for(let r=Math.floor(t/32);r>=0;r--){let t=e?this._data[r]:~this._data[r];0!=n&&(t&=~(4294967295<<n),n=0);for(let e=24;0!=t;e-=8,t<<=8){const n=Y._lastOnBit[t>>>24];if(n>=0)return n+32*r+e}}return-1}}function j(t={}){const e=function(){if(!t||!t.scoringMatrix||!t.alphabetIndexes)return(t,e)=>t===e?0:1;if(t.scoringMatrix.length!==Object.keys(t.alphabetIndexes).length)throw new Error("Scoring matrix and alphabet indexes should have the same length");const e=t.alphabetIndexes,n=t.scoringMatrix,r=Math.min(...Object.keys(e).map(t=>t.charCodeAt(0)))+1,i=new Float32Array((n.length+r)*(n.length+r));return Object.entries(e).forEach(([t,r])=>{const o=n[r];Object.entries(e).forEach(([e,r])=>{i[t.charCodeAt(0)*n.length+e.charCodeAt(0)]=o[r]})}),(t,e)=>1-i[t.charCodeAt(0)*n.length+e.charCodeAt(0)]}(),n=t?.threshold??0;return(t,r)=>{let i=0;const o=t.length,a=r.length,s=Math.ceil(Math.max(o,a)*(1-n));o!==a&&(i=Math.abs(o-a));let l=0;for(let n=0;n<Math.min(o,a);n++)if(t[n]!==r[n]&&(l+=e(t[n],r[n]),l>s))return 1;return l+=i,l/=Math.max(o,a),l}}Y._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]),Y._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]),Y._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 q={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 K;!function(t){t.HAMMING="Hamming",t.LEVENSHTEIN="Levenshtein",t.NEEDLEMANN_WUNSCH="Needlemann-Wunsch",t.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance"}(K||(K={}));const z={[K.HAMMING]:j,[K.LEVENSHTEIN]:function(){return(t,e)=>H(t,e)/Math.max(t.length,e.length)},[K.NEEDLEMANN_WUNSCH]:function(t){const e=new Uint16Array(65536),{gapOpen:n,gapExtend:r,scoringMatrix:i,alphabetIndexes:o}={...q,...t};Object.entries(o).forEach(([t,n])=>e[t.charCodeAt(0)]=n);const a=[new Float32Array(1e4),new Float32Array(1e4)];return(t,o)=>{const s=new Array(t.length+1).fill(!1),l=new Array(t.length+1).fill(!1);let c=0,h=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 u=1;u<o.length+1;u++){a[h][0]=-r-(u-1)*r;for(let d=1;d<t.length+1;d++){const f=a[c][d-1]+i[e[t.charCodeAt(d-1)]][e[o.charCodeAt(u-1)]],g=a[c][d]-(s[d]||1===u||u===o.length?r:n),p=a[h][d-1]-(l[d-1]||1===d||d===t.length?r:n);a[h][d]=Math.max(f,p,g),a[h][d]===f?(s[d]=!1,l[d]=!1):a[h][d]===p?(s[d]=!1,l[d]=!0):(s[d]=!0,l[d]=!1)}c=h,h=(h+1)%2}const u=Math.min(t.length,o.length);return(u-a[c][t.length])/u}},[K.MONOMER_CHEMICAL_DISTANCE]:j};function $(t,e){const n=t.trueCount()+e.trueCount();if(0==n)return 1;const r=t.andWithCountBits(e,!0);return r/(n-r)}function X(t){return t<=0?3402823e32:1/t-1}D.Tanimoto,D.Dice,D.Asymmetric,D.BraunBlanquet,D.Cosine,D.Kulczynski,D.McConnaughey,D.RogotGoldberg,D.Russel,D.Sokal,D.Hamming,D.Euclidean,D.Tanimoto,D.Dice,D.Asymmetric,D.BraunBlanquet,D.Cosine,D.Kulczynski,D.McConnaughey,D.RogotGoldberg,D.Russel,D.Sokal,D.Hamming,D.Euclidean,D.Tanimoto,D.Dice,D.Cosine,D.Tanimoto,D.Asymmetric,D.Cosine,D.Sokal,K.HAMMING,K.LEVENSHTEIN,K.MONOMER_CHEMICAL_DISTANCE,K.NEEDLEMANN_WUNSCH;const Q={[I.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)},[I.Manhattan]:function(t,e){let n=0;for(let r=0;r<t.length;r++)n+=Math.abs(t[r]-e[r]);return n},[I.Cosine]:function(t,e){let n=0,r=0,i=0;for(let o=0;o<t.length;o++)n+=t[o]*e[o],r+=t[o]*t[o],i+=e[o]*e[o];return(1-n/(Math.sqrt(r)*Math.sqrt(i)))/2}},J={[R.Levenshtein]:H,[R.JaroWinkler]:W.Vb,[R.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}},[R.Onehot]:function(t,e){return t===e?0:1}},Z={[D.Tanimoto]:function(t,e){return 1-$(t,e)},[D.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)},[D.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)},[D.BraunBlanquet]:function(t,e){return X(function(t,e){const n=Math.max(t.trueCount(),e.trueCount());return 0==n?0:t.andWithCountBits(e,!0)/n}(t,e))},[D.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)},[D.Kulczynski]:function(t,e){return X(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))},[D.McConnaughey]:function(t,e){return X(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))},[D.RogotGoldberg]:function(t,e){return X(function(t,e){const n=t.andWithCountBits(e,!0),r=t.countBits(!0)+e.countBits(!0),i=t.length,o=i-r+n;return n==i||o==i?1:n/r+o/(2*i-r)}(t,e))},[D.Russel]:function(t,e){return X(function(t,e){return 0==t.length?0:t.andWithCountBits(e,!0)/t.length}(t,e))},[D.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)},[D.Hamming]:function(t,e){return t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0)},[D.Euclidean]:function(t,e){return Math.sqrt(t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0))}},tt={[L.TanimotoIntArray]:function(t,e){return X($(new Y(t,32*t.length),new Y(e,32*e.length)))}},et={[U.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)}},nt={[G.CommonItems]:function(t){const e=function(t){const e=t?.mostCommon??new Set;return(t,n)=>{const r=t.length,i=n.length;let o=0,a=0,s=0;for(;a<r&&s<i;)t[a]===n[s]?(e?.has(t[a])||++o,++a,++s):t[a]<n[s]?++a:++s;return o}}(t);return(t,n)=>0===n.length||0===t.length?1e4:Math.min(t.length,n.length)/(e(t,n)+1e-4)}},rt={[k.Vector]:{[I.Euclidean]:Q[I.Euclidean],[I.Manhattan]:Q[I.Manhattan],[I.Cosine]:Q[I.Cosine]},[k.String]:{[R.Levenshtein]:J[R.Levenshtein],[R.JaroWinkler]:J[R.JaroWinkler],[R.Manhattan]:J[R.Manhattan],[R.Onehot]:J[R.Onehot]},[k.BitArray]:{[D.Tanimoto]:Z[D.Tanimoto],[D.Dice]:Z[D.Dice],[D.Asymmetric]:Z[D.Asymmetric],[D.BraunBlanquet]:Z[D.BraunBlanquet],[D.Cosine]:Z[D.Cosine],[D.Kulczynski]:Z[D.Kulczynski],[D.McConnaughey]:Z[D.McConnaughey],[D.RogotGoldberg]:Z[D.RogotGoldberg],[D.Russel]:Z[D.Russel],[D.Sokal]:Z[D.Sokal]},[k.MacroMolecule]:{[K.HAMMING]:z[K.HAMMING],[K.LEVENSHTEIN]:z[K.LEVENSHTEIN],[K.NEEDLEMANN_WUNSCH]:z[K.NEEDLEMANN_WUNSCH],[K.MONOMER_CHEMICAL_DISTANCE]:z[K.MONOMER_CHEMICAL_DISTANCE]},[k.Number]:{[U.Difference]:et[U.Difference]},[k.IntArray]:{[L.TanimotoIntArray]:tt[L.TanimotoIntArray]},[k.NumberArray]:{[G.CommonItems]:nt[G.CommonItems]}};Object.keys(rt).reduce((t,e)=>{for(const n of Object.keys(rt[e]))t[n]=e;return t},{});const it=ui,ot="bypassLargeDataWarning";var at,st,lt,ct,ht,ut,dt;n(5540),(st=at||(at={})).EUCLIDEAN="EUCLIDEAN",st.MANHATTAN="MANHATTAN",at.EUCLIDEAN,at.MANHATTAN,(ct=lt||(lt={})).HAMMING="Hamming",ct.EUCLIDEAN="Euclidean",ct.VECTOR_COSINE="Vector Cosine",ct.MANHATTAN="Manhattan",ct.TANIMOTO="Tanimoto",ct.LEVENSTEIN="Levenshtein",ct.NEEDLEMAN_WUNSCH="Needlemann-Wunsch",ct.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance",ct.SOKAL="Sokal",ct.COSINE="Cosine",ct.ASYMMETRIC="Asymmetric",ct.Difference="Difference",ct.OneHot="One-Hot",lt.HAMMING,lt.EUCLIDEAN,lt.MANHATTAN,lt.VECTOR_COSINE,lt.TANIMOTO,lt.LEVENSTEIN,lt.NEEDLEMAN_WUNSCH,lt.MONOMER_CHEMICAL_DISTANCE,lt.SOKAL,lt.COSINE,lt.ASYMMETRIC,lt.Difference,lt.OneHot,lt.HAMMING,lt.EUCLIDEAN,lt.MANHATTAN,lt.TANIMOTO,lt.SOKAL,lt.COSINE,lt.ASYMMETRIC,lt.LEVENSTEIN,lt.NEEDLEMAN_WUNSCH,lt.MONOMER_CHEMICAL_DISTANCE,lt.Difference,lt.OneHot,lt.VECTOR_COSINE,new Set([lt.HAMMING,lt.LEVENSTEIN,lt.NEEDLEMAN_WUNSCH,lt.MONOMER_CHEMICAL_DISTANCE,lt.OneHot]),new Set([lt.HAMMING,lt.EUCLIDEAN,lt.MANHATTAN,lt.MONOMER_CHEMICAL_DISTANCE,lt.LEVENSTEIN,lt.NEEDLEMAN_WUNSCH,lt.TANIMOTO,lt.COSINE,lt.VECTOR_COSINE,lt.SOKAL,lt.ASYMMETRIC,lt.OneHot,lt.Difference]),new Set([lt.EUCLIDEAN,lt.MANHATTAN,lt.OneHot,lt.Difference,lt.VECTOR_COSINE]),new Set([lt.EUCLIDEAN,lt.MANHATTAN,lt.Difference,lt.VECTOR_COSINE]),new Set([lt.EUCLIDEAN,lt.MANHATTAN,lt.Difference]),new Set([lt.TANIMOTO,lt.COSINE,lt.SOKAL,lt.ASYMMETRIC]),function(t){t.ADD="ADD",t.SUB="SUB",t.MULT="MULT"}(ht||(ht={})),function(t){t.SQUARE="SQUARE",t.INVERSE="INVERSE",t.TRANSPOSE="TRANSPOSE",t.NORM="NORM",t.COLUMN_NORM="COLUMN_NORM"}(ut||(ut={})),function(t){t.SCALARMULT="SCALARMULT",t.SCALARADD="SCALARADD",t.SCALARPOW="SCALARPOW"}(dt||(dt={})),Object.prototype.toString;const ft="dimensionality-reducer-terminate-event";var gt,pt;(pt=gt||(gt={})).EUCLIDEAN="EUCLIDEAN",pt.MANHATTAN="MANHATTAN";const mt=t=>null==t;function yt(t,e){return`${e} (${t.length>4?`${t.length} columns`:t.map(t=>t.name).join(", ")})`}async function vt(e,r,i,o,a,s,l,c=!0,h=!1,u={preprocessingFuncArgs:[]},d={},f=null,g={},p){const m={showXAxis:!1,showYAxis:!1,showXSelector:!1,showYSelector:!1};if(r.length!==o.length||r.length!==s.length||r.length!==a.length||r.length!==u.preprocessingFuncArgs.length)throw new Error("columns, metrics and preprocessing functions, weights and function argumentsmust have the same length");const y=c?d.tableView??O.shell.tableView(e.name)??O.shell.addTableView(e):null,v=async()=>{const v=t.TaskBarProgressIndicator.create(`Initializing ${d.scatterPlotName??"dimensionality reduction"} ...`);let _;try{const w=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}`)}(e);function b(n,o,a){let s=null,l=null;e.columns.names().includes(w[0])?(s=e.columns.byName(w[0]),l=e.columns.byName(w[1])):(s=e.columns.add(t.Column.float(w[0],e.rowCount)),l=e.columns.add(t.Column.float(w[1],e.rowCount)),c&&!_&&(_=y.scatterPlot({...m,x:w[0],y:w[1],title:d.scatterPlotName??yt(r,i)}))),d["show-scatterplot-progress"]&&(_?.root&&it.setUpdateIndicator(_.root,!1),s.init(t=>a[0]?a[0][t]:void 0),l.init(t=>a[1]?a[1][t]:void 0));const h=n/o*100;v.update(h,`Running ${d.scatterPlotName??"dimensionality reduction"}... ${h.toFixed(0)}%`)}async function C(){e.columns.add(t.Column.float(w[0],e.rowCount)),e.columns.add(t.Column.float(w[1],e.rowCount));let h=null;c&&(_=y.scatterPlot({...m,x:w[0],y:w[1],title:d.scatterPlotName??yt(r,i)}),it.setUpdateIndicator(_.root,!0));const f=O.events.onViewerClosed.subscribe(t=>{const e=t.args.viewer;e?.getOptions()?.look?.title&&_?.getOptions()?.look?.title&&e?.getOptions()?.look?.title===_?.getOptions()?.look?.title&&(O.events.fireCustomEvent(ft,{}),f.unsubscribe(),h?.(),v.close())}),g=new Promise(async(t,c)=>{try{h=t;const c=[];let f=o,g=a,m=l;if(p&&r.every(t=>t.isNumerical)){const t=r.map(t=>t.toList()),n=new Array(e.rowCount).fill(0).map((t,e)=>new Float32Array(r.length));for(let i=0;i<r.length;++i)for(let r=0;r<e.rowCount;++r)n[r][i]=t[i][r];u.distanceFnArgs=[{}],c.push({entries:n,options:{}}),f=[p],g=[1],m="MANHATTAN"}else for(let t=0;t<s.length;++t){const e=s[t];if(u.distanceFnArgs||(u.distanceFnArgs=[]),e){const n=e.inputs[0].name,i=e.inputs[1].name,{entries:a,options:s}=await e.apply({[n]:r[t],[i]:o[t],...u.preprocessingFuncArgs[t]??{}});c.push({entries:a,options:s}),u.distanceFnArgs.push(s)}else{const e=r[t].toList(),n={};c.push({entries:e,options:n}),u.distanceFnArgs.push(n)}}t(await async function(t,e,r,i,o,a,s){let l=await async function(t,e,r,i,o,a,s){if(!a.distanceFnArgs)throw new Error("options.distanceFnArgs must be defined");if(t.length!==e.length||t.length!==a.distanceFnArgs.length||t.length!==i.length)throw new Error("data, metrics and options and weights must have the same length");return new Promise(function(l,c){const h=new Worker(new URL(n.p+n.u(234),n.b));h.postMessage({columnsData:t,distanceMetrics:e,method:r,options:a,weights:i,aggregationMethod:o});const u=O.events.onCustomEvent(ft).subscribe(()=>{try{h?.terminate()}finally{u.unsubscribe()}});h.onmessage=({data:{error:t,embedding:e,epochNum:n,epochsLength:r}})=>{mt(n)||mt(r)?(u.unsubscribe(),t?c(t):l(e),setTimeout(()=>h.terminate(),100)):s&&s(n,r,e)}})}(t,r,e,i,o,a,s);return l=l.map(t=>function(t){const e=t.length;let n=0,r=0;for(let i=0;i<e;++i)n+=t[i],r+=Math.pow(t[i],2);const i=n/e,o=1/Math.sqrt(r/e-Math.pow(i,2));for(let n=0;n<e;++n)t[n]=(t[n]-i)*o;return t}(t)),l}(c.map(t=>t.entries),i,f,g,l,u,d[ot]?void 0:b))}catch(t){c(t)}}),C=await g;return v.close(),f.unsubscribe(),C}const x=await C();if(h&&x){const S=t.TaskBarProgressIndicator.create("Clustering embeddings ...");try{const A=await function(t,e,r,i){return o=this,a=void 0,l=function*(){return new Promise(function(o,a){const s=new Worker(new URL(n.p+n.u(682),n.b));s.postMessage({embedX:t,embedY:e,minPts:i,epsilon:r}),s.onmessage=({data:{error:t,clusters:e}})=>{s.terminate(),t?a(t):o(e)}})},new((s=void 0)||(s=Promise))(function(t,e){function n(t){try{i(l.next(t))}catch(t){e(t)}}function r(t){try{i(l.throw(t))}catch(t){e(t)}}function i(e){var i;e.done?t(e.value):(i=e.value,i instanceof s?i:new s(function(t){t(i)})).then(n,r)}i((l=l.apply(o,a||[])).next())});var o,a,s,l}(x[0],x[1],u.dbScanEpsilon??.01,u.dbScanMinPts??4),E=e.columns.getUnusedName("Cluster (DBSCAN)");e.columns.addNewString(E).init(t=>A[t].toString()),_&&(_.props.colorColumnName=E)}catch(T){O.shell.error("Clustering embeddings failed"),console.error(T)}finally{S.close()}}if(x){const M=e.columns.byName(w[0]),P=e.columns.byName(w[1]);if(M.init(t=>x[0][t]),P.init(t=>x[1][t]),f)try{const N=f.inputs[0].name,F=f.inputs[1].name;await f.prepare({[N]:M,[F]:P,...g}).call(!0)}catch(R){O.shell.error("Post-processing failed"),console.error(R)}if(_)return it.setUpdateIndicator(_.root,!1),_.helpUrl="/help/compute/sequence-space",_}}catch(I){O.shell.error("Dimensionality reduction failed"),console.error(I),v.close(),_&&it.setUpdateIndicator(_.root,!1)}};return new Promise(async(t,n)=>{try{if(d.fastRowCount&&e.rowCount>d.fastRowCount&&!d[ot])it.dialog().add(it.divText("Analysis might take several minutes. Do you want to continue?")).onOK(async()=>{try{const e=await v();t(e)}catch(t){n(t)}}).onCancel(()=>t(void 0)).show();else{const e=await v();t(e)}}catch(t){n(t)}})}var _t=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{l(r.next(t))}catch(t){o(t)}}function s(t){try{l(r.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}l((r=r.apply(t,e||[])).next())})};const wt={SUBJ:"subj",STUDY:"study",SITE:"site",AGE:"age",SEX:"sex",RACE:"race",DISEASE:"disease",WEIGHT:"weight",HEIGHT:"height"};function bt(t,e,n){return _t(this,void 0,void 0,function*(){const r=O.data.demo.demog(100);O.shell.addTableView(r),C(!!(yield vt(r,t.map(t=>r.col(t)),e,n,t.map(()=>1),t.map(()=>{}),"EUCLIDEAN",!0,!0,{preprocessingFuncArgs:t.map(()=>({}))})),!0,"No scatterplot returned");const i=r.columns.names().filter(t=>t.toLowerCase().startsWith("embed"));C(i.length,2,"Wrong number of embeddings added"),C(!!r.columns.names().find(t=>t.toLowerCase().startsWith("cluster")),!0,"No cluster column added");for(const t of i){const e=r.col(t);C(new Array(e.length).fill(null).every((t,n)=>!e.isNone(n)&&!isNaN(e.get(n))),!0,"Embedding column has null-ish values")}yield new Promise(t=>setTimeout(t,500))})}x("Dimensionality reduction: UMAP",()=>{b("Numeric column",()=>_t(void 0,void 0,void 0,function*(){yield bt([wt.AGE],F.UMAP,[U.Difference])}),{timeout:3e4}),b("String column",()=>_t(void 0,void 0,void 0,function*(){yield bt([wt.SEX],F.UMAP,[R.Onehot])}),{timeout:3e4}),b("Numeric and string columns",()=>_t(void 0,void 0,void 0,function*(){yield bt([wt.SEX,wt.AGE],F.UMAP,[R.Onehot,U.Difference])})),b("All demog columns",()=>_t(void 0,void 0,void 0,function*(){const e=O.data.demo.demog(10).columns.toList().filter(t=>Object.values(wt).includes(t.name)),n=e.map(e=>e.type===t.COLUMN_TYPE.STRING?R.Onehot:U.Difference),r=e.map(t=>t.name);yield bt(r,F.UMAP,n)}))}),x("Dimensionality reduction: T-SNE",()=>{b("Numeric column",()=>_t(void 0,void 0,void 0,function*(){yield bt([wt.AGE],F.T_SNE,[U.Difference])}),{timeout:3e4}),b("String column",()=>_t(void 0,void 0,void 0,function*(){yield bt([wt.SEX],F.T_SNE,[R.Onehot])}),{timeout:3e4}),b("Numeric and string columns",()=>_t(void 0,void 0,void 0,function*(){yield bt([wt.SEX,wt.AGE],F.T_SNE,[R.Onehot,U.Difference])})),b("All demog columns",()=>_t(void 0,void 0,void 0,function*(){const e=O.data.demo.demog(10).columns.toList().filter(t=>Object.values(wt).includes(t.name)),n=e.map(e=>e.type===t.COLUMN_TYPE.STRING?R.Onehot:U.Difference),r=e.map(t=>t.name);yield bt(r,F.T_SNE,n)}))});const Ct={i32:"HEAP32",f32:"HEAPF32"},xt={i32:Int32Array,f32:Float32Array},St={i32:2,f32:2},At={i32:DG.Column.fromInt32Array,f32:DG.Column.fromFloat32Array};class Et{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 Tt extends Et{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*xt[this.type].BYTES_PER_ELEMENT)}isMemoryForBufferAllocated(){return 0!=this.buf}putDataToBuffer(t){if(this.isMemoryForBufferAllocated()){const e=this.type,n=St[e],r=t[Ct[e]];let i=null;const o=this.data;i="int"==o.type&&"i32"==e||"double"==o.type&&"f32"==e?o.getRawData():new xt[e](o.getRawData()),i&&r.set(i,this.buf>>n)}}getDataFromBuffer(t){if(this.toUpdate&&this.isMemoryForBufferAllocated()){const e=this.type,n=t[Ct[e]],r=this.buf,i=xt[e].BYTES_PER_ELEMENT,o=this.data.getRawData();for(let t=0;t<this.numOfRows;t++)o[t]=n[r/i+t]}}freeBuffer(t){this.isMemoryForBufferAllocated()&&(t._free(this.buf),this.buf=0)}}class Mt extends Tt{constructor(t,e){super([],t,!0),this.numOfRows=e}putDataToBuffer(t){}getDataFromBuffer(t){if(this.toUpdate&&this.isMemoryForBufferAllocated()){const e=this.type,n=t[Ct[e]],r=this.buf,i=At[e],o=new xt[e](this.numOfRows);for(let t=0;t<o.length;t++)o[t]=n[r/o.BYTES_PER_ELEMENT+t];this.data=i("name",o)}}}class Pt extends Et{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*xt[this.type].BYTES_PER_ELEMENT)}isMemoryForBufferAllocated(){return 0!=this.buf}putDataToBuffer(t){if(this.isMemoryForBufferAllocated()){const e=this.type,n=St[e],r=t[Ct[e]],i=xt[e].BYTES_PER_ELEMENT;for(let t=0;t<this.numOfColumns;t++){let o=null;const a=this.data[t];o="int"==a.type&&"i32"==e||"double"==a.type&&"f32"==e?a.getRawData():new xt[e](a.getRawData()),null!=o&&r.set(o,this.buf+t*this.numOfRows*i>>n)}}}getDataFromBuffer(t){if(this.toUpdate&&this.isMemoryForBufferAllocated()){const e=this.type,n=t[Ct[e]],r=this.numOfRows,i=this.numOfColumns,o=new xt[e](n.buffer,this.buf,r*i);for(let t=0;t<i;t++){const e=this.data[t].getRawData();for(let n=0;n<r;n++)e[n]=o[n+t*r]}}}freeBuffer(t){this.isMemoryForBufferAllocated()&&(t._free(this.buf),this.buf=0)}}class Nt extends Pt{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[Ct[e]],r=this.numOfRows,i=this.numOfColumns,o=xt[e].BYTES_PER_ELEMENT,a=At[e],s=this.buf;for(let t=0;t<i;t++){const i=new xt[e](r);for(let e=0;e<r;e++)i[e]=n[s/o+e+t*r];this.data.push(a((t+1).toString(),i))}}}}const Ot={intColumn:t=>new Tt(t,"i32"),newIntColumn:t=>new Mt("i32",t),intColumns:t=>new Pt(t.toList(),"i32"),newIntColumns:(t,e)=>new Nt("i32",t,e),floatColumn:t=>new Tt(t,"f32"),newFloatColumn:t=>new Mt("f32",t),floatColumns:t=>new Pt(t.toList(),"f32"),newFloatColumns:(t,e)=>new Nt("f32",t,e),int:t=>new Et(t),num:t=>new Et(t)},Ft={tableFromColumns:t=>DG.DataFrame.fromColumns(t.data),num:t=>t,int:t=>t,double:t=>t,column:t=>t.data};function Rt(t,e,n){const r=t[e],i=r.arguments,o=[];let a=0;for(const t in i){const e=i[t];if("_callResult"!=t){switch(e.type){case"floatColumns":case"int":case"num":case"floatColumn":case"intColumn":case"intColumns":e.data=Ot[e.type](n[a]),a++;break;case"newFloatColumns":case"newIntColumns":const t=i[e.numOfRows.ref].data[e.numOfRows.value],r=i[e.numOfColumns.ref].data[e.numOfColumns.value];e.data=Ot[e.type](t,r);break;case"newFloatColumn":case"newIntColumn":const o=i[e.numOfRows.ref].data[e.numOfRows.value];e.data=Ot[e.type](o)}o.push(i[t].data)}}const s=function(t,e,n,r){let i;for(const e of r)e.allocateMemoryForBuffer(t);let o=!0;for(const t of r)o&=t.isMemoryForBufferAllocated();if(o){const n=[],o=[];for(const e of r)e.complementArrOfParams(n),e.complementArrOfTypes(o),e.putDataToBuffer(t);const a="number";i=t.ccall(e,a,o,n);for(const e of r)e.getDataFromBuffer(t)}for(const e of r)e.freeBuffer(t);if(null!=i)return i}(t,e,0,o);i._callResult=Ot.num(s);const l=r.output;if("objects"!=l.type)return Ft[l.type](i[l.source].data);const c=[];for(const t of l.source)c.push(i[t].data.data);return c}const It="num",Dt="floatColumn",Lt="intColumn",kt="floatColumns",Ut="newFloatColumns",Gt="intColumns",Bt="newIntColumns",Vt="newFloatColumn",Ht="newIntColumn",Wt="numOfRows",Yt="numOfColumns",jt="ref",qt="value",Kt="int",zt="double",$t={intColumn:Int32Array,floatColumn:Float32Array,floatColumns:Float32Array,newFloatColumns:Float32Array,intColumns:Int32Array,newIntColumns:Int32Array,newFloatColumn:Float32Array,newIntColumn:Int32Array};function Xt(t,e){let n,r=[],i=0;for(const o in t){const a=t[o],s=a.type;if("_callResult"!==o){switch(s){case It:case Kt:case zt:a.data=e[i],i++;break;case Lt:case Dt:let r;const o=e[i],l=o.length;r=o.type===Kt&&s===Lt||o.type===zt&&s===Dt?o.getRawData().slice(0,l):new $t[s](o.getRawData().slice(0,l)),a.data={array:r,numOfRows:l},i++;break;case Ht:case Vt:let c=0;n=a[Wt][jt],c=t[n].type===It?t[n].data:t[n].data[a[Wt][qt]],a.data={numOfRows:c},i++;break;case Gt:case kt:let h=[];const u=e[i].byIndex(0).length;for(const t of e[i].toList())t.type===Kt&&s===Lt||t.type===zt&&s===Dt?h.push(t.getRawData().slice(0,u)):h.push(new $t[s](t.getRawData().slice(0,u)));a.data={arrays:h,numOfRows:u,numOfColumns:h.length},i++;break;case Bt:case Ut:let d=0,f=0;n=a[Wt][jt],d=t[n].type===It?t[n].data:t[n].data[a[Wt][qt]],n=a[Yt][jt],f=t[n].type===It?t[n].data:t[n].data[a[Yt][qt]],a.data={numOfRows:d,numOfColumns:f},i++;break;default:return}r.push(a)}}return r}function Qt(t,e){t.arguments._callResult=e.callResult,function(t,e){const n={newFloatColumns:DG.Column.fromFloat32Array,newIntColumns:DG.Column.fromInt32Array,newFloatColumn:DG.Column.fromFloat32Array,newIntColumn:DG.Column.fromInt32Array};let r=0;for(const i in t){const o=t[i];switch(o.type){case It:case Kt:case zt:case Lt:case Dt:case kt:case Gt:break;case Vt:case Ht:let t;null==o.name?t=(0).toString():s=o.name,o.column=n[o.type](t,e[r].array);break;case Bt:case Ut:let i=[],a=e[r].arrays.length,s=[];if(null==o.names)for(let t=1;t<=a;t++)s.push(t.toString());else s=o.names;for(let t=0;t<a;t++)i.push(n[o.type](s[t],e[r].arrays[t]));o.columns=i}r++}}(t.arguments,e.args);let n=function(t){let e=t.output;const n={newFloatColumns:"columns",newIntColumns:"columns",newFloatColumn:"column",newIntColumn:"column"};switch(e.type){case It:case Kt:case zt:return t.arguments[e.source];case"column":return t.arguments[e.source].column;case"tableFromColumns":return DG.DataFrame.fromColumns(t.arguments[e.source].columns);case"objects":let r=[];for(let i of e.source){let e=t.arguments[i];r.push(e[n[e.type]])}return r}}(t);return function(t){for(const e in t){const n=t[e];switch(n.type){case It:case Kt:case zt:case Lt:case Dt:case Gt:case kt:break;case Ht:case Vt:n.column=null;break;case Bt:case Ut:n.columns=null}}}(t.arguments),n}async function Jt(t,e,r){return new Promise((t,i)=>{const o=new Worker(new URL(n.p+n.u(128),n.b));o.postMessage(Xt(EDA.principalComponentAnalysisNipals.arguments,[e,r])),o.onmessage=function(e){o.terminate(),t(Qt(EDA.principalComponentAnalysisNipals,e.data))}})}const Zt=1e-6;function te(e){if(e.type!=t.COLUMN_TYPE.FLOAT&&e.type!=t.COLUMN_TYPE.INT)throw new Error("unsupported column type: "+e.type)}function ee(t){if(t.stats.missingValueCount>0)throw new Error(`The column '${t.name}' has missing values.`)}function ne(t,e){if(function(t,e){if(e<1)throw new Error("components must be positive.");if(e>t.length)throw new Error("components must not be greater than features count.");for(const e of t)te(e),ee(e)}(t,e),t.length*t.byIndex(0).length>1e8)throw new Error("dataframe is too big.")}function re(t,e,n){return e?n?function(t){const e=t.rowCount;for(const n of t.columns)if(n.isNumerical){const t=n.stats.stdev,r=n.stats.avg,i=n.getRawData();if(t>0)for(let n=0;n<e;++n)i[n]=(i[n]-r)/t;else for(let t=0;t<e;++t)i[t]-=r}return t}(t):function(t){const e=t.rowCount;for(const n of t.columns)if(n.isNumerical){const t=n.stats.avg;if(Math.abs(t)>Zt){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)>Zt&&t>0){const r=n.getRawData();for(let n=0;n<e;++n)r[n]/=t}}return t}(t):t}var ie,oe,ae,se,le,ce,he,ue,de,fe,ge,pe,me,ye,ve;function _e(e,r,i,o,a){return s=this,l=void 0,h=function*(){ne(r,i);const s=e.rowCount,l=function(e){const n=[];for(const t of e)t.stats.stdev>0&&t.stats.missingValueCount<1&&n.push(t);return t.DataFrame.fromColumns(n)}(r),c=l.columns.length;if(0===c){const e=[];for(let n=0;n<i;++n)e.push(t.Column.fromFloat32Array(`${n+1}`,new Float32Array(s).fill(0)));return t.DataFrame.fromColumns(e)}const h=c<i?i-c:0,u=Math.min(i,c);let d;if(c>900)d=yield Jt(0,r,u);else{const t=yield async function(t,e,r){return new Promise((t,i)=>{const o=new Worker(new URL(n.p+n.u(860),n.b));o.postMessage(Xt(EDA.principalComponentAnalysis.arguments,[e,r,1,0])),o.onmessage=function(e){o.terminate(),0===e.data.callResult?t(Qt(EDA.principalComponentAnalysis,e.data)):t(-1)}})}(0,r,u);d=-1!==t?re(t,o,a):yield Jt(0,r,u)}if(void 0===d)throw new Error("Failed to compute PCA");d=re(d,o,a);const f=d.columns,g=f.length;for(let e=0;e<h;++e)f.add(t.Column.fromFloat32Array(`${g+e+1}`,new Float32Array(s).fill(0)));return d},new((c=void 0)||(c=Promise))(function(t,e){function n(t){try{i(h.next(t))}catch(t){e(t)}}function r(t){try{i(h.throw(t))}catch(t){e(t)}}function i(e){var i;e.done?t(e.value):(i=e.value,i instanceof c?i:new c(function(t){t(i)})).then(n,r)}i((h=h.apply(s,l||[])).next())});var s,l,c,h}(ve=ie||(ie={}))[ve.COMPUTE_COMPONENTS=0]="COMPUTE_COMPONENTS",ve[ve.PERFORM_MVA=1]="PERFORM_MVA",ve[ve.DEMO=2]="DEMO",(ye=oe||(oe={})).NO_DF="No dataframe is opened",ye.NO_COLS="No numeric columns without missing values",ye.ONE_COL="No columns to be used as features (just one numeric columns without missing values)",ye.EMPTY_DF="Dataframe is empty",ye.PREDICT="Predictors must not contain a response variable",ye.ENOUGH="Not enough of features",ye.COMP_LIN_PLS="Components count must be less than the number of features",ye.COMP_QUA_PLS="Too large components count for the quadratic PLS regression",ye.COMPONENTS="Components count must be greater than 1",ye.INV_INP="Invalid inputs",(me=ae||(ae={})).PREDICT="Predict",me.USING="Using",me.COMPONENTS="Components",me.PLS="PLS",me.MVA="Multivariate Analysis (PLS)",me.RUN="RUN",me.NAMES="Names",me.MODEL="Observed vs. Predicted",me.FEATURE="Feature",me.REGR_COEFS="Regression Coefficients",me.XLOADING="x.loading.p",me.LOADINGS="Loadings",me.XSCORE="x.score.t",me.YSCORE="y.score.u",me.SCORES="Scores",me.EXPL_VAR="Explained Variance",me.EXPLORE="Explore",me.FEATURES="Feature names",me.BROWSE="Browse",me.ANALYSIS="Features Analysis",me.QUADRATIC="Quadratic",(pe=se||(se={})).PREDICT="Column with the response variable",pe.FEATURES="Predictors (features)",pe.COMPONENTS="Number of PLS components",pe.PLS="Compute PLS components",pe.MVA="Perform multivariate analysis",pe.NAMES="Names of data samples",pe.QUADRATIC="Specifies whether to include squared terms as additional predictors in the PLS model",(ge=le||(le={})).PLS="/help/explore/multivariate-analysis#pls-components",ge.MVA="/help/explore/multivariate-analysis",ge.MODEL="/help/explore/multivariate-analysis#observed-vs-predicted",ge.COEFFS="/help/explore/multivariate-analysis#regression-coefficients",ge.LOADINGS="/help/explore/multivariate-analysis#loadings",ge.EXPL_VARS="/help/explore/multivariate-analysis#explained-variance",ge.SCORES="/help/explore/multivariate-analysis#scores",(fe=ce||(ce={}))[fe.DEFAULT=3]="DEFAULT",fe[fe.MIN=1]="MIN",(de=he||(he={})).PREFIX="PLS",de.SUFFIX="(predicted)",de.COMP="component",de.COMPS="components",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"}(ue||(ue={}));const we=[.49,.79,.99];var be,Ce;(Ce=be||(be={})).AXIS="#838383",Ce.CIRCLE="#0000FF",Ce.INVALID="#EB6767",Ce.VALID_TEXT="#4d5261",Ce.VALID_LINE="#dbdcdf",[{caption:ae.MODEL,text:"Closer to the line means better price prediction."},{caption:ae.SCORES,text:"The latent factor values for each sample reflect the similarities and dissimilarities among observations."},{caption:ae.LOADINGS,text:"The impact of each feature on the latent factors: higher loading means stronger influence."},{caption:ae.REGR_COEFS,text:"Parameters of the obtained model: features make different contribution to the prediction."},{caption:ae.EXPL_VAR,text:"How well the latent components fit source data: closer to one means better fit."}].map(t=>`# ${t.caption}\n\n${t.text}`).join("\n\n"),le.MVA;function xe(t){return e=this,r=void 0,o=function*(){ne(t.features,t.components),te(t.predict),ee(t.predict);const e=yield async function(t,e,r,i){return new Promise((t,o)=>{const a=new Worker(new URL(n.p+n.u(412),n.b));a.postMessage(Xt(EDA.partialLeastSquareRegression.arguments,[e,r,i])),a.onmessage=function(e){a.terminate(),t(Qt(EDA.partialLeastSquareRegression,e.data))}})}(t.table,t.features,t.predict,t.components);return{prediction:e[ue.PREDICTION],regressionCoefficients:e[ue.REGR_COEFFS],tScores:e[ue.T_SCORES],uScores:e[ue.U_SCORES],xLoadings:e[ue.X_LOADINGS],yLoadings:e[ue.Y_LOADINGS]}},new((i=void 0)||(i=Promise))(function(t,n){function a(t){try{l(o.next(t))}catch(t){n(t)}}function s(t){try{l(o.throw(t))}catch(t){n(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof i?n:new i(function(t){t(n)})).then(a,s)}l((o=o.apply(e,r||[])).next())});var e,r,i,o}Math.min,Math.max;var Se=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{l(r.next(t))}catch(t){o(t)}}function s(t){try{l(r.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}l((r=r.apply(t,e||[])).next())})};function Ae(e,n){return Se(this,void 0,void 0,function*(){const r=e.length,i=n.length,o=n.stats.avg,a=n.stats.stdev,s=new Float32Array(r+1).fill(0);if(s[r]=o,0===a||1===i)return s;try{const i=[],l=[],c=new Float32Array(r),h=new Float32Array(r);let u=0,d=0;for(const t of e){const e=t.stats;e.stdev>0&&(i.push(u),l.push(t),c[d]=e.avg,h[d]=e.stdev,++d),++u}if(0===d)return s;const f=function(t,e,n,r,i,o,a){return Rt(EDA,"fitLinearRegressionParamsWithDataNormalizing",[t,e,n,r,i,o,a])}(t.DataFrame.fromColumns(l).columns,t.Column.fromFloat32Array("xAvgs",c,d),t.Column.fromFloat32Array("xStdevs",h,d),n,o,a,d+1).getRawData();for(let t=0;t<d;++t)s[i[t]]=f[t];s[r]=f[d]}catch(i){const o=yield function(e,n,r){return Se(this,void 0,void 0,function*(){return(yield xe({table:t.DataFrame.fromColumns([n]),features:e,predict:n,components:r,names:void 0,isQuadratic:!1})).regressionCoefficients.getRawData()})}(e,n,Te(e.length,n.length));let a=0;for(let t=0;t<r;++t)s[t]=o[t],a+=o[t]*e.byIndex(t).stats.avg;s[r]-=a}return s})}function Ee(e,n){const r=e.length;if(r!==n.length-1)throw new Error("Incorrect parameters count");const i=e.byIndex(0),o=i.length,a=new Float32Array(o);let s=i.getRawData();const l=n[r];let c=n[0];for(let t=0;t<o;++t)a[t]=l+c*s[t];for(let t=1;t<r;++t){s=e.byIndex(t).getRawData(),c=n[t];for(let t=0;t<o;++t)a[t]+=c*s[t]}return t.Column.fromFloat32Array(e.getUnusedName("prediction"),a,o)}const Te=(t,e)=>e<=t?Math.min(10,e):Math.min(10,t);var Me;!function(t){t[t.MAX_SAMLPES=1e5]="MAX_SAMLPES",t[t.MAX_FEATURES=1e3]="MAX_FEATURES"}(Me||(Me={}));class Pe{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<=Me.MAX_FEATURES&&e.length<=Me.MAX_SAMLPES}constructor(e){if(this.specn=null,e)try{const n=new Uint32Array(e.buffer,0,2),r=n[0],i=n[1],o=new Uint8Array(e.buffer,8,r),a=t.DataFrame.fromByteArray(o),s=a.rowCount,l=a.columns,c=l.length,h=new Uint8Array(e.buffer,8+r,i),u=t.DataFrame.fromByteArray(h);if(c<3)throw new Error("incorrect columns count");const d=l.byName(ae.FEATURES).toList(),f=new Float32Array(s);f.set(l.byName(ae.REGR_COEFS).getRawData());const g=c-2,p=new Array(g);for(let t=0;t<g;++t)p[t]=new Float32Array(s),p[t].set(l.byIndex(t+2).getRawData());this.specn={params:f,loadings:p,names:d,dim:s-1,components:c-2,scores:u}}catch(t){throw new Error(`Failed to load model: ${t instanceof Error?t.message:"the platform issue"}`)}}fit(e,n,r){return i=this,o=void 0,s=function*(){const i=yield xe({table:t.DataFrame.fromColumns([n]),features:e,predict:n,components:r,names:void 0,isQuadratic:!1}),o=e.names();o.push("_");const a=this.getRegrCoeffs(e,n,i.regressionCoefficients),s=this.getLoadings(r,i.xLoadings);this.specn={names:o,params:a,loadings:s,components:r,dim:e.length,scores:this.getScoresDf(i)},this.computeExplVars(n.length,r,i.yLoadings)},new((a=void 0)||(a=Promise))(function(t,e){function n(t){try{l(s.next(t))}catch(t){e(t)}}function r(t){try{l(s.throw(t))}catch(t){e(t)}}function l(e){var i;e.done?t(e.value):(i=e.value,i instanceof a?i:new a(function(t){t(i)})).then(n,r)}l((s=s.apply(i,o||[])).next())});var i,o,a,s}getLoadings(t,e){const n=Array(t),r=e[0].length+1;for(let i=0;i<t;++i)n[i]=new Float32Array(r),n[i].set(e[i].getRawData());return n}getRegrCoeffs(t,e,n){const r=t.length,i=new Float32Array(r+1),o=n.getRawData();let a=0;for(let e=0;e<r;++e)i[e]=o[e],a+=o[e]*t.byIndex(e).stats.avg;return i[r]=e.stats.avg-a,i}computeExplVars(t,e,n){if(null===this.specn)throw new Error("Failed to compute explained variances");const r=n.getRawData(),i=this.specn.loadings[0].length-1;let o=Math.pow(r[0],2)/t;this.specn.loadings[0][i]=o;for(let n=1;n<e;++n)o+=Math.pow(r[n],2)/t,this.specn.loadings[n][i]=o}toBytes(){if(null===this.specn)throw new Error("Failed to pack untrained model");const e=t.DataFrame.fromColumns([t.Column.fromStrings(ae.FEATURES,this.specn.names),t.Column.fromFloat32Array(ae.REGR_COEFS,this.specn.params)]);this.specn.loadings.forEach((n,r)=>e.columns.add(t.Column.fromFloat32Array(`${ae.XLOADING}${r+1}`,n)));const n=e.toByteArray(),r=n.length,i=this.specn.scores.toByteArray(),o=i.length,a=r+o+8,s=new Uint8Array(64*(Math.ceil(a/64)+1)),l=new Uint32Array(s.buffer,0,2);return l[0]=r,l[1]=o,s.set(n,8),s.set(i,8+r),s}predict(t){if(null===this.specn)throw new Error("Predicting failed: model is not trained");return Ee(t,this.specn.params)}loadingsParamsViewers(){if(null===this.specn)throw new Error("Failed to create loadings and parameters viewers: untrained model");const e=[],n=this.specn.dim,r=t.DataFrame.fromColumns([t.Column.fromStrings(ae.FEATURES,this.specn.names.slice(0,-1)),t.Column.fromFloat32Array(ae.REGR_COEFS,this.specn.params,n)]),i=r.columns,o=i.length,a=this.specn.components;return this.specn.loadings.forEach((e,i)=>r.columns.add(t.Column.fromFloat32Array(`${ae.XLOADING}${i+1}`,e,n))),e.push(t.Viewer.scatterPlot(r,{title:ae.LOADINGS,xColumnName:i.byIndex(o).name,yColumnName:i.byIndex(o+(a>1?1:0)).name,markerType:t.MARKER_TYPE.CIRCLE,labelFormColumnNames:[ae.FEATURES],help:le.LOADINGS})),e.push(t.Viewer.barChart(r,{title:ae.REGR_COEFS,splitColumnName:ae.FEATURES,valueColumnName:ae.REGR_COEFS,valueAggrType:t.AGG.AVG,help:le.COEFFS,showValueSelector:!1,showStackSelector:!1})),e}explVarsViewer(){if(null===this.specn)throw new Error("Failed to create exaplained variances viewer: untrained model");const e=this.specn.components,n=this.specn.dim,r=new Array(e),i=new Float32Array(e);r[0]=`${he.COMP} 1`,i[0]=this.specn.loadings[0][n];for(let t=1;t<e;++t)r[t]=`${he.COMPS} ${t+1}`,i[t]=this.specn.loadings[t][n];return t.Viewer.barChart(t.DataFrame.fromColumns([t.Column.fromStrings(he.COMPS,r),t.Column.fromFloat32Array(ae.EXPL_VAR,i)]),{title:ae.EXPL_VAR,splitColumnName:he.COMPS,valueColumnName:ae.EXPL_VAR,valueAggrType:t.AGG.AVG,help:le.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(e){const n=e.tScores,r=e.uScores;return n.forEach((t,e)=>t.name=`${ae.XSCORE}${e+1}`),r.forEach((t,e)=>t.name=`${ae.YSCORE}${e+1}`),t.DataFrame.fromColumns(n.concat(r))}getScoresScatter(){if(null===this.specn)throw new Error("Failed to create scores scatter: untrained model");const e=this.specn.scores.columns.names(),n=t.Viewer.scatterPlot(this.specn.scores,{title:ae.SCORES,xColumnName:e[0],yColumnName:e[1],markerType:t.MARKER_TYPE.CIRCLE,help:le.SCORES,showViewerFormulaLines:!0});return n.meta.formulaLines.addAll(function(t){const e=[],n=(t,n)=>{e.push({type:"line",formula:t,width:1,visible:!0,title:" ",min:-n,max:n,color:be.CIRCLE})};return t.forEach(r=>{const i="${"+r+"}";e.push({type:"line",formula:`${i} = 0`,width:1,visible:!0,title:" ",color:be.AXIS}),t.forEach(t=>{const e="${"+t+"}";we.forEach(t=>{n(e+` = sqrt(${t*t} - ${i} * ${i})`,t),n(e+` = -sqrt(${t*t} - ${i} * ${i})`,t)})})}),e}(e)),n}}const Ne=["Alpha","Beta","Gamma","Delta"];function Oe(t,e){if(t.length!==e.length)throw new Error(`Non-equal elements count: ${t.length} vs. ${e.length}`)}function Fe(e,n,r){const i=O.data.demo.randomWalk(e,n),o=i.columns,a=new Float32Array(n),s=new Array(n);for(let t=0;t<n;++t)s[t]=o.byIndex(t).getRawData();for(let i=0;i<r;++i){const r=new Float32Array(e);for(let t=0;t<n;++t)a[t]=Math.random();for(let t=0;t<e;++t)for(let e=0;e<n;++e)r[t]+=a[e]*s[e][t];o.add(t.Column.fromFloat32Array(`y${i}`,r))}return i}function Re(t,e){Oe(t,e);let n=0;const r=t.length,i=t.getRawData(),o=e.getRawData();for(let t=0;t<r;++t)n=Math.max(n,Math.abs(i[t]-o[t]));return n}function Ie(e,n,r){const i=new Array(e),o=new Array(n);for(let t=0;t<n;++t){const n=new Float32Array(e);for(let t=0;t<e;++t)n[t]=Math.random();o[t]=n}const a=t.DataFrame.fromColumns(o.map((e,n)=>t.Column.fromFloat32Array(`#${n}`,e)));for(let t=0;t<e;++t)i[t]=o.slice(0,2).map(e=>e[t]>.5?"A":"B").join("");if(a.columns.add(t.Column.fromStrings("Labels",i)),r)for(let t=0;t<n;++t)for(let n=0;n<e;++n)o[t][n]+=1*(o[t][n]>0?1:-1);return a}function De(t,e){Oe(t,e);let n=0;const r=t.length;if(r<1)return 1;for(let i=0;i<r;++i)t.get(i)===e.get(i)&&++n;return n/r}var Le=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{l(r.next(t))}catch(t){o(t)}}function s(t){try{l(r.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}l((r=r.apply(t,e||[])).next())})};const ke=100,Ue=9e3,Ge=.1;x("Principal component analysis",()=>{b("Performance: 100K rows, 100 cols, 3 components",()=>Le(void 0,void 0,void 0,function*(){const t=O.data.demo.randomWalk(1e5,ke);yield _e(t,t.columns,3,!1,!1)}),{timeout:Ue,benchmark:!0}),b("Performance: 1K rows, 5K cols, 3 components",()=>Le(void 0,void 0,void 0,function*(){const t=O.data.demo.randomWalk(1e3,5e3);yield _e(t,t.columns,3,!1,!1)}),{timeout:Ue,benchmark:!0}),b("Correctness",()=>Le(void 0,void 0,void 0,function*(){const t=Fe(100,3,5);C(function(t){let e=0;const n=t.length,r=t.getRawData();for(let t=0;t<n;++t)e=Math.max(e,Math.abs(r[t]));return e}((yield _e(t,t.columns,4,!1,!1)).columns.byIndex(3))<Ge,!0,"Incorrect PCA computations")}),{timeout:Ue})}),x("Partial least squares regression",()=>{b("Performance: 100K rows, 100 cols, 3 components",()=>Le(void 0,void 0,void 0,function*(){const t=O.data.demo.randomWalk(1e5,ke),e=t.columns;yield xe({table:t,features:e,predict:e.byIndex(99),components:3,names:void 0,isQuadratic:!1})}),{timeout:Ue,benchmark:!0}),b("Correctness",()=>Le(void 0,void 0,void 0,function*(){const t=Fe(100,3,5),e=t.columns,n=e.byIndex(7),r=Re(n,(yield xe({table:t,features:e,predict:n,components:3,isQuadratic:!1,names:void 0})).prediction);C(r<Ge,!0,`Incorrect PLS computations, error is too big: ${r}; expected: < 0.1`)}),{timeout:Ue}),b("Predictive modeling: 100K samples, 100 features, 3 components",()=>Le(void 0,void 0,void 0,function*(){const t=Fe(1e5,3,98).columns,e=t.byIndex(ke);t.remove(e.name);const n=new Pe;yield n.fit(t,e,3);const r=n.toBytes(),i=Re(e,new Pe(r).predict(t));C(i<Ge,!0,`Incorrect PLS (ML) computations, error is too big: ${i}; expected: < 0.1`)}),{timeout:Ue,benchmark:!0})}),x("Linear regression",()=>{b("Performance: 100K samples, 100 features",()=>Le(void 0,void 0,void 0,function*(){const t=Fe(1e5,ke,1).columns,e=t.byIndex(ke),n=yield Ae(t,e),r=new Uint8Array(n.buffer);Ee(t,new Float32Array(r.buffer))}),{timeout:Ue,benchmark:!0}),b("Correctness",()=>Le(void 0,void 0,void 0,function*(){const t=Fe(100,2,1).columns,e=t.byIndex(2),n=yield Ae(t,e),r=new Uint8Array(n.buffer),i=Ee(t,new Float32Array(r.buffer)),o=Re(i,i);C(o<Ge,!0,`Incorrect linear regression computations, error is too big: ${o}; expected: < 0.1`)}),{timeout:Ue})});var Be=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{l(r.next(t))}catch(t){o(t)}}function s(t){try{l(r.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}l((r=r.apply(t,e||[])).next())})};const Ve="Avg-s",He="Stddev-s";var We;!function(t){t[t.MAX_SAMLPES=5e4]="MAX_SAMLPES",t[t.MAX_FEATURES=100]="MAX_FEATURES"}(We||(We={}));class Ye{static isApplicable(e,n){for(const t of e)if(!t.matches("numerical"))return!1;return n.type===t.COLUMN_TYPE.STRING}static isInteractive(t,e){return t.length<=We.MAX_FEATURES&&e.length<=We.MAX_SAMLPES}constructor(e,n){if(this.params=void 0,this.classesCount=1,this.featuresCount=1,void 0!==e){const t=e.featuresCount,n=e.classesCount;if(t<1)throw new Error("Incorrect features count");if(n<1)throw new Error("Incorrect classes count");const r=t+1;this.avgs=new Float32Array(r),this.stdevs=new Float32Array(r),this.categories=new Array(r),this.featuresCount=t,this.classesCount=n}else{if(void 0===n)throw new Error("Softmax classifier not initialized");try{const e=new Uint32Array(n.buffer,0,1)[0],r=new Uint8Array(n.buffer,4,e),i=t.DataFrame.fromByteArray(r),o=i.columns,a=o.length;if(a<3)throw new Error("incorrect columns count");this.classesCount=a-2,this.featuresCount=i.rowCount-1;const s=this.classesCount;this.params=new Array(s),this.categories=new Array(i.rowCount);for(let e=0;e<s;++e){const n=o.byIndex(e);if(this.categories[e]=n.name,n.type!==t.COLUMN_TYPE.FLOAT)throw new Error(`Incorrect input column type. Expected: float, passed: ${n.type}`);this.params[e]=n.getRawData()}const l=o.byName(Ve);if(l.type!==t.COLUMN_TYPE.FLOAT)throw new Error("incorrect average values column type");this.avgs=l.getRawData();const c=o.byName(He);if(c.type!==t.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 e=this.classesCount,n=new Array(e+2);for(let r=0;r<e;++r)n[r]=t.Column.fromFloat32Array(this.categories[r],this.params[r]);n[e]=t.Column.fromFloat32Array(Ve,this.avgs),n[e+1]=t.Column.fromFloat32Array(He,this.stdevs);const r=t.DataFrame.fromColumns(n).toByteArray(),i=r.length,o=new Uint8Array(i+4);return new Uint32Array(o.buffer,0,1)[0]=i,o.set(r,4),o}fit(e,n){return Be(this,arguments,void 0,function*(e,n,r=1,i=100,o=.1,a=.001){if(e.length!==this.featuresCount)throw new Error("Training failes - incorrect features count");if(r<=0||i<1||o<=0||a<=0)throw new Error("Training failes - incorrect fitting hyperparameters");this.extractStats(e);const s=n.length,l=n.categories.length,c=n.categories;for(let t=0;t<l;++t)this.categories[t]=c[t];try{const c=function(t,e,n,r,i,o,a,s,l,c,h){return Rt(EDA,"fitSoftmax",[t,e,n,r,i,o,a,s,l,c,h])}(e,t.Column.fromFloat32Array("avgs",this.avgs,this.featuresCount),t.Column.fromFloat32Array("stdevs",this.stdevs,this.featuresCount),t.Column.fromInt32Array("targets",n.getRawData(),s),l,i,r,o,a,this.featuresCount+1,l).columns;this.params=new Array(l);for(let t=0;t<l;++t)this.params[t]=c.byIndex(t).getRawData()}catch(t){try{this.params=yield this.fitSoftmaxParams(e,n,i,r,o,a)}catch(t){throw new Error("Training failes")}}if(void 0===this.params)throw new Error("Training failes")})}extractStats(e){let n=0;for(const r of e){if(r.type!==t.COLUMN_TYPE.INT&&r.type!==t.COLUMN_TYPE.FLOAT)throw new Error("Training failes - incorrect features type");this.avgs[n]=r.stats.avg,this.stdevs[n]=r.stats.stdev,++n}}normalized(e){const n=e.byIndex(0).length,r=new Array(n);for(let t=0;t<n;++t)r[t]=new Float32Array(this.featuresCount);let i=0;for(const o of e){if(o.type!==t.COLUMN_TYPE.INT&&o.type!==t.COLUMN_TYPE.FLOAT)throw new Error("Training failes - incorrect features type");const e=o.getRawData(),a=this.avgs[i],s=this.stdevs[i];if(s>0)for(let t=0;t<n;++t)r[t][i]=(e[t]-a)/s;else for(let t=0;t<n;++t)r[t][i]=0;++i}return r}transposed(e){const n=e.byIndex(0).length,r=this.featuresCount,i=new Array(r);for(let t=0;t<r;++t)i[t]=new Float32Array(n);let o=0;for(const r of e){if(r.type!==t.COLUMN_TYPE.INT&&r.type!==t.COLUMN_TYPE.FLOAT)throw new Error("Training failes - incorrect features type");const e=r.getRawData(),a=this.avgs[o],s=this.stdevs[o];if(s>0)for(let t=0;t<n;++t)i[o][t]=(e[t]-a)/s;else for(let t=0;t<n;++t)i[o][t]=0;++o}return i}preprocessedTargets(e){if(e.type!==t.COLUMN_TYPE.STRING)throw new Error("Training failes - incorrect target type");const n=this.classesCount,r=e.length,i=e.getRawData(),o=new Array(r),a=new Uint32Array(n).fill(0);for(let t=0;t<r;++t)o[t]=new Uint8Array(n).fill(0);for(let t=0;t<r;++t)o[t][i[t]]=1,++a[i[t]];return{oneHot:o,weights:a}}predict(e){if(void 0===this.params)throw new Error("Non-trained model");if(e.length!==this.featuresCount)throw new Error("Predcition fails: incorrect features count");const n=this.normalized(e),r=n.length,i=this.featuresCount,o=this.classesCount;let a,s;const l=new Float32Array(o);let c,h,u;const d=new Array(r);for(let t=0;t<r;++t){a=n[t],c=0;for(let t=0;t<o;++t){s=this.params[t],c=s[i];for(let t=0;t<i;++t)c+=s[t]*a[t];l[t]=Math.exp(c)}h=l[0],u=0;for(let t=1;t<o;++t)h<l[t]&&(h=l[t],u=t);d[t]=this.categories[u]}return t.Column.fromStrings("predicted",d)}fitSoftmaxParams(t,e,r,i,o,a){return Be(this,void 0,void 0,function*(){const s=this.preprocessedTargets(e);return new Promise((l,c)=>{const h=new Worker(new URL(n.p+n.u(501),n.b));h.postMessage({features:this.normalized(t),transposed:this.transposed(t),oneHot:s.oneHot,classesWeights:s.weights,targetRaw:e.getRawData(),iterations:r,rate:i,penalty:o,tolerance:a}),h.onmessage=function(t){h.terminate(),l(t.data.params),console.log(`Loss: ${t.data.loss}`)}})})}}var je,qe,Ke,ze;(ze=je||(je={}))[ze.ITERATIONS=20]="ITERATIONS",ze[ze.ETA=.3]="ETA",ze[ze.MAX_DEPTH=6]="MAX_DEPTH",ze[ze.LAMBDA=1]="LAMBDA",ze[ze.ALPHA=0]="ALPHA",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"}(qe||(qe={})),function(t){t[t.MODEL=1e7]="MODEL",t[t.UTILS=1]="UTILS",t[t.PACK=128]="PACK",t[t.SIZE=4]="SIZE"}(Ke||(Ke={}));const $e=t.FLOAT_NULL;var Xe;!function(t){t.PREDICT="Prediction",t.TYPE="Type",t.PARAMS="Params count",t.CATS="Categories",t.CATS_SIZE="Categories size"}(Xe||(Xe={}));class Qe{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<=qe.SAMPLES_LOW?n<=qe.FEATURES_LOW:r<=qe.SAMLPES_MID?n<=qe.FEATURES_MID:r<=qe.SAMLPES_HIGH&&n<=qe.FEATURES_HIGH}constructor(e){var n;if(this.modelParams=void 0,this.targetType=void 0,this.targetCategories=void 0,e)try{let r=0;const i=new Uint32Array(e.buffer,r,1)[0];r+=Ke.SIZE;const o=t.DataFrame.fromByteArray(new Uint8Array(e.buffer,r,i));r+=i,this.targetType=o.get(Xe.TYPE,0);const a=o.get(Xe.PARAMS,0),s=o.get(Xe.CATS_SIZE,0);if(s>0){const i=t.DataFrame.fromByteArray(new Uint8Array(e.buffer,r,s));this.targetCategories=null===(n=i.col(Xe.CATS))||void 0===n?void 0:n.toList()}r+=s,r=4*Math.ceil(r/4),this.modelParams=new Int32Array(e.buffer,r,a)}catch(t){throw new Error(`Failed to load model: ${t instanceof Error?t.message:"the platform issue"}`)}}fit(e,r){return i=this,o=arguments,s=function*(e,r,i=je.ITERATIONS,o=je.ETA,a=je.MAX_DEPTH,s=je.LAMBDA,l=je.ALPHA){this.targetType=r.type,this.targetType===t.COLUMN_TYPE.STRING&&(this.targetCategories=r.categories),this.modelParams=yield async function(t,e,r,i,o,a,s,l,c,h){return new Promise((u,d)=>{const f=e.length,g=t.length,p=new Float32Array(f*g);let m,y;for(let e=0;e<g;++e){y=t.byIndex(e).getRawData(),m=e*f;for(let t=0;t<f;++t)p[t+m]=y[t]}const v=new Worker(new URL(n.p+n.u(990),n.b));v.postMessage({features:p,target:e.getRawData(),samplesCount:f,featuresCount:g,modelReserve:c,utilsLength:h,iterations:i,eta:o,maxDepth:a,lambda:s,alpha:l,missingValue:r}),v.onmessage=function(t){v.terminate(),u(t.data.params)}})}(e,r,$e,i,o,a,s,l,Ke.MODEL,Ke.UTILS)},new((a=void 0)||(a=Promise))(function(t,e){function n(t){try{l(s.next(t))}catch(t){e(t)}}function r(t){try{l(s.throw(t))}catch(t){e(t)}}function l(e){var i;e.done?t(e.value):(i=e.value,i instanceof a?i:new a(function(t){t(i)})).then(n,r)}l((s=s.apply(i,o||[])).next())});var i,o,a,s}predict(e){if(void 0===this.modelParams)throw new Error("Failed to apply non-trained model");const n=function(t,e,n){const r=t.byIndex(0).length,i=t.length,o=n.length;let a=XGBoostModule.HEAPF32;const s=XGBoostModule.HEAP32,l=XGBoostModule._malloc(r*i*4),c=XGBoostModule._malloc(4*r),h=XGBoostModule._malloc(4*o);for(let e=0;e<i;++e){const n=t.byIndex(e).getRawData();for(let t=0;t<r;++t)a[l/4+t+e*r]=n[t]}for(let t=0;t<o;++t)s[h/4+t]=n[t];XGBoostModule._predict(l,r,i,e,h,o,c,r),a=XGBoostModule.HEAPF32;const u=new Float32Array(r);for(let t=0;t<r;++t)u[t]=a[c/4+t];return XGBoostModule._free(l),XGBoostModule._free(c),XGBoostModule._free(h),u}(e,$e,this.modelParams);switch(this.targetType){case t.COLUMN_TYPE.STRING:return this.stringColPrediction(n);case t.COLUMN_TYPE.INT:return this.intColPrediction(n);case t.COLUMN_TYPE.BIG_INT:return this.bigIntColPrediction(n);default:return t.Column.fromFloat32Array(Xe.PREDICT,n)}}toBytes(){if(void 0===this.modelParams||void 0===this.targetType)throw new Error("Failed to pack non-trained model");const e=void 0!==this.targetCategories?t.DataFrame.fromColumns([t.Column.fromList(t.COLUMN_TYPE.STRING,Xe.CATS,this.targetCategories)]).toByteArray():void 0,n=void 0!==e?e.length:0,r=this.modelParams.length*this.modelParams.BYTES_PER_ELEMENT,i=t.DataFrame.fromColumns([t.Column.fromStrings(Xe.TYPE,[this.targetType]),t.Column.fromInt32Array(Xe.PARAMS,new Int32Array([this.modelParams.length])),t.Column.fromInt32Array(Xe.CATS_SIZE,new Int32Array([n]))]).toByteArray(),o=i.length,a=64*Math.ceil((Ke.SIZE+o+n+r+Ke.PACK)/64),s=new Uint8Array(a);let l=0;return new Uint32Array(s.buffer,l,1)[0]=o,l+=Ke.SIZE,s.set(i,l),l+=o,n>0&&s.set(e,l),l+=n,l=4*Math.ceil(l/4),s.set(new Uint8Array(this.modelParams.buffer),l),s}stringColPrediction(e){const n=e.length;if(void 0===this.targetCategories)throw new Error("Predicting fails: undefined categories");const r=new Array(n),i=this.targetCategories.length-1,o=t=>Math.max(0,Math.min(t,i));for(let t=0;t<n;++t)r[t]=this.targetCategories[o(Math.round(e[t]))];return t.Column.fromList(t.COLUMN_TYPE.STRING,Xe.PREDICT,r)}intColPrediction(e){const n=e.length,r=new Int32Array(n);for(let t=0;t<n;++t)r[t]=Math.round(e[t]);return t.Column.fromInt32Array(Xe.PREDICT,r,n)}bigIntColPrediction(e){const n=e.length,r=new BigInt64Array(n);for(let t=0;t<n;++t)r[t]=BigInt(Math.round(e[t]));return t.Column.fromBigInt64Array(Xe.PREDICT,r)}}var Je=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{l(r.next(t))}catch(t){o(t)}}function s(t){try{l(r.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}l((r=r.apply(t,e||[])).next())})};const Ze=100,tn=8e3;var en;x("Softmax",()=>{b("Performance: 50K samples, 100 features",()=>Je(void 0,void 0,void 0,function*(){const t=Ie(5e4,Ze,!1).columns,e=t.byIndex(Ze);t.remove(e.name);const n=new Ye({classesCount:e.categories.length,featuresCount:t.length});yield n.fit(t,e);const r=n.toBytes();new Ye(void 0,r).predict(t)}),{timeout:tn,benchmark:!0}),b("Correctness",()=>Je(void 0,void 0,void 0,function*(){const t=Ie(50,2,!0).columns,e=t.byIndex(2);t.remove(e.name);const n=new Ye({classesCount:e.categories.length,featuresCount:t.length});yield n.fit(t,e);const r=n.toBytes(),i=De(e,new Ye(void 0,r).predict(t));C(i>.9,!0,`Softmax failed, too small accuracy: ${i}; expected: <= 0.9`)}),{timeout:tn})}),x("XGBoost",()=>{b("Performance: 50K samples, 100 features",()=>Je(void 0,void 0,void 0,function*(){const t=Ie(5e4,Ze,!1).columns,e=t.byIndex(Ze);t.remove(e.name);const n=new Qe;yield n.fit(t,e);const r=n.toBytes();new Qe(r).predict(t)}),{timeout:tn,benchmark:!0}),b("Correctness",()=>Je(void 0,void 0,void 0,function*(){const t=Ie(50,2,!0).columns,e=t.byIndex(2);t.remove(e.name);const n=new Qe;yield n.fit(t,e);const r=n.toBytes(),i=De(e,new Qe(r).predict(t));C(i>.9,!0,`XGBoost failed, too small accuracy: ${i}; expected: <= 0.9`)}),{timeout:tn})}),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"}(en||(en={}));const nn="copy";var rn,on;!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"}(rn||(rn={})),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"}(on||(on={}));const an=[t.COLUMN_TYPE.INT,t.COLUMN_TYPE.FLOAT,t.COLUMN_TYPE.STRING,t.COLUMN_TYPE.DATE_TIME,t.COLUMN_TYPE.QNUM];function sn(e){switch(e.type){case t.COLUMN_TYPE.INT:return t.INT_NULL;case t.COLUMN_TYPE.FLOAT:case t.COLUMN_TYPE.QNUM:case t.COLUMN_TYPE.DATE_TIME:return t.FLOAT_NULL;case t.COLUMN_TYPE.STRING:return e.max;default:throw new Error(en.UNSUPPORTED_COLUMN_TYPE)}}var ln,cn,hn,un;function dn(e){switch(e){case t.COLUMN_TYPE.STRING:case t.COLUMN_TYPE.DATE_TIME:return{defaultWeight:hn.WEIGHT,defaultMetric:ln.ONE_HOT,availableMetrics:[ln.ONE_HOT]};case t.COLUMN_TYPE.INT:case t.COLUMN_TYPE.FLOAT:case t.COLUMN_TYPE.QNUM:return{defaultWeight:hn.WEIGHT,defaultMetric:ln.DIFFERENCE,availableMetrics:[ln.DIFFERENCE,ln.ONE_HOT]};default:throw new Error(en.UNSUPPORTED_COLUMN_TYPE)}}!function(t){t.ONE_HOT="One-hot",t.DIFFERENCE="Difference"}(ln||(ln={})),(un=cn||(cn={})).EUCLIDEAN="Euclidean",un.MANHATTAN="Manhattan",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"}(hn||(hn={}));const fn=e=>{b(`${e} dist, 100K rows, 15 cols, 75 missing vals`,()=>{return n=void 0,r=void 0,o=function*(){const n=function(e){const n=Ne.length,r=[];let i=0;const o=new Map;for(let n=0;n<5;++n){const a=new Int32Array(e),s=`int #${n+1}`,l=[];for(let t=0;t<e;++t)a[t]=Math.floor(10*Math.random());for(let n=0;n<5;++n)i=Math.floor(e*Math.random()),a[i]=t.INT_NULL,l.push(i);r.push(t.Column.fromInt32Array(s,a)),o.set(s,l)}for(let n=0;n<5;++n){const a=new Float32Array(e),s=`float #${n+1}`,l=[];for(let t=0;t<e;++t)a[t]=10*Math.random();for(let n=0;n<5;++n)i=Math.floor(e*Math.random()),a[i]=t.FLOAT_NULL,l.push(i);r.push(t.Column.fromFloat32Array(s,a)),o.set(s,l)}for(let a=0;a<5;++a){const s=new Array(e),l=`str #${a+1}`,c=[];for(let t=0;t<e;++t)s[t]=Ne[Math.floor(Math.random()*n)];const h=t.Column.fromStrings(l,s);for(let t=0;t<5;++t)i=Math.floor(e*Math.random()),h.set(i,null),c.push(i);r.push(h),o.set(l,c)}return{df:t.DataFrame.fromColumns(r),misValsIds:o}}(1e5),r=n.df,i=r.columns.names(),o=new Map,a=n.misValsIds;for(const t of r.columns){const e=dn(t.type);o.set(t.name,{weight:e.defaultWeight,type:e.defaultMetric})}const s=function(e,n,r,i,o,a,s){if(a<1)throw new Error(en.INCORRECT_NEIGHBORS);if(e.rowCount<2)throw new Error(en.KNN_NOT_ENOUGH_OF_ROWS);if(0===n.length)throw new Error(en.KNN_NO_TARGET_COLUMNS);if(0===r.size)throw new Error(en.KNN_NO_FEATURE_COLUMNS);1===r.size&&n.forEach(t=>{if(r.has(t))throw new Error(`${en.KNN_NO_FEATURE_COLUMNS} can be used for the column '${t}'`)}),n.forEach(t=>{if(!i.has(t))throw new Error(`${en.KNN_FAILS}: ${en.WRONG_PREDICTIONS}`)});const l=e.columns;n.forEach(t=>{if(!an.includes(l.byName(t).type))throw new Error(en.UNSUPPORTED_COLUMN_TYPE)}),r.forEach((t,n)=>{if(!an.includes(e.getCol(n).type))throw new Error(en.UNSUPPORTED_COLUMN_TYPE)});const c=new Map;return n.forEach(n=>{const h=l.byName(n),u=sn(h),d=h.length,f=h.getRawData(),g=new Uint16Array(h.categories.length),p=[],m=[],y=[],v=[];r.forEach((t,e)=>{if(e!==h.name){const n=l.byName(e);switch(p.push(n.getRawData()),m.push(sn(n)),t.type){case ln.DIFFERENCE:y.push((e,n)=>t.weight*Math.abs(e-n));break;case ln.ONE_HOT:y.push((e,n)=>t.weight*(e===n?0:1))}}});const _=p.length,w=new Uint32Array(p.length),b=new Float32Array(p.length);let C=0;const x=new Array(a);let S=0,A=0,E=0,T=0,M=0;const P=(t,e)=>{w.forEach((n,r)=>{b[r]=y[n](p[n][t],p[n][e])})},N=o===cn.EUCLIDEAN?()=>{let t=0;for(let e=0;e<C;++e)t+=b[e]*b[e];return Math.sqrt(t)}:()=>{let t=0;for(let e=0;e<C;++e)t+=Math.abs(b[e]);return Math.sqrt(t)},F=t=>{if(f[t]===u)return!1;for(let e=0;e<C;++e)if(p[w[e]][t]===m[w[e]])return!1;return!0},R=e=>{if((t=>{C=0;for(let e=0;e<_;++e)p[e][t]!==m[e]&&(w[C]=e,++C)})(e),0===C)throw new Error(`${en.KNN_IMPOSSIBLE_IMPUTATION}: the column "${h.name}", row ${e+1}`);S=0;for(let t=0;t<d;++t)if(F(t)&&t!==e){P(e,t);const n=N();if(S<a)x[S]={index:t,dist:n},++S;else{A=0,E=x[0].dist;for(let t=1;t<S;++t)E<x[t].dist&&(E=x[t].dist,A=t);n<E&&(x[A]={index:t,dist:n})}}if(0===S)throw new Error(`${en.KNN_IMPOSSIBLE_IMPUTATION}: the column "${h.name}", row ${e+1}`);if(h.type===t.COLUMN_TYPE.STRING)return(()=>{g.forEach((t,e,n)=>n[e]=0);let t=0;for(t=0;t<S;++t)++g[f[x[t].index]];let e=g[0],n=0;return g.forEach((t,r)=>{t>e&&(e=t,n=r)}),n})();T=0;for(let t=0;t<S;++t)T+=f[x[t].index];return M=T/S,h.type===t.COLUMN_TYPE.INT?Math.round(M):M};if(s){for(const t of i.get(n))try{f[t]=R(t)}catch(e){v.push(t),e instanceof Error||O.shell.error(en.CORE_ISSUE)}v.length>0&&c.set(n,v),h.set(0,h.get(0))}else{const t=h.clone();let r=1,o=`${n}(${nn})`;for(;e.columns.contains(o);)o=`${n}(${nn} ${r})`,++r;t.name=o;const a=t.getRawData();for(const t of i.get(n))try{a[t]=R(t)}catch(e){v.push(t),e instanceof Error||O.shell.error(en.CORE_ISSUE)}v.length>0&&c.set(o,v),t.set(0,t.get(0)),e.columns.add(t)}}),c}(r,i,o,a,e,5,!0);let l=0;s.forEach((t,e)=>l+=t.length),C(l,0,`Failed to impute ${l} missing values`)},new((i=void 0)||(i=Promise))(function(t,e){function a(t){try{l(o.next(t))}catch(t){e(t)}}function s(t){try{l(o.throw(t))}catch(t){e(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof i?n:new i(function(t){t(n)})).then(a,s)}l((o=o.apply(n,r||[])).next())});var n,r,i,o},{timeout:1e4,benchmark:!0})};x("Missing values imputation",()=>{fn(cn.EUCLIDEAN),fn(cn.MANHATTAN)});var gn,pn=n(6572);function mn(t){if(t<=0||t>=1)throw new Error(gn.INCORRECT_SIGNIFICANCE_LEVEL)}function yn(t){const e=t.size;return e<=1?0:(t.sumOfSquares-Math.pow(t.sum,2)/e)/(e-1)}function vn(t,e,n){mn(n);const r=yn(t),i=yn(e);return 0===r||0===i?r===i:r/i<pn.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"}(gn||(gn={}));class _n{constructor(t,e,n){if(this.nullsCount=0,t.length!==e.length)throw new Error(gn.NON_EQUAL_FACTORS_VALUES_SIZE);if(!(e.stats.stdev>0))throw new Error(gn.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(!vn(n,{sum:this.sums[r],sumOfSquares:this.sumsOfSquares[r],size:this.subSampleSizes[r]},t))return!1;return!0}getOneWayAnova(){let t=0,e=0,n=0,r=this.catCount,i=r;for(let o=0;o<r;++o)0!==this.subSampleSizes[o]?(t+=this.sums[o],e+=this.sumsOfSquares[o],n+=Math.pow(this.sums[o],2)/this.subSampleSizes[o]):--i;if(r=i,1===r)throw new Error(gn.SINGLE_FACTOR);const o=this.size-this.nullsCount;if(o===r)throw new Error(gn.CATS_EQUAL_SIZE);const a=e-Math.pow(t,2)/o,s=n-Math.pow(t,2)/o,l=a-s;if(0===l)throw new Error(gn.NO_FEATURE_VARIATION_WITHIN_GROUPS);const c=r-1,h=o-r,u=s/c,d=l/h,f=u/d;return{ssBn:s,ssWn:l,ssTot:a,dfBn:c,dfWn:h,dfTot:o-1,msBn:u,msWn:d,fStat:f,pValue:1-pn.centralF.cdf(f,c,h)}}setStats(e,n,r){const i=n.type,o=n.length,a=sn(n);switch(i){case t.COLUMN_TYPE.INT:case t.COLUMN_TYPE.FLOAT:const i=r;this.catCount=i,this.size=o;const s=n.getRawData(),l=e.getRawData(),c=new Float64Array(i).fill(0),h=new Float64Array(i).fill(0),u=new Int32Array(i).fill(0);let d;if(e.type==t.COLUMN_TYPE.BOOL){let t=0,e=0,n=l[0];const r=8*l.BYTES_PER_ELEMENT-1;for(let i=0;i<o;++i)d=1&n>>e,s[i]!==a?(c[d]+=s[i],h[d]+=Math.pow(s[i],2),++u[d]):++this.nullsCount,++e,e>r&&(e=0,++t,n=l[t])}else{const t=e.stats.missingValueCount>0?sn(e):-1;for(let e=0;e<o;++e)d=l[e],d!==t&&s[e]!==a?(c[d]+=s[e],h[d]+=Math.pow(s[e],2),++u[d]):++this.nullsCount}this.sums=c,this.sumsOfSquares=h,this.subSampleSizes=u;break;default:throw new Error(gn.UNSUPPORTED_COLUMN_TYPE)}}}function wn(t,e,n,r=!0){mn(n);const i=t.stats.uniqueCount;if(i<2)throw new Error(gn.SINGLE_FACTOR);const o=new _n(t,e,i);if(r&&!o.areVarsEqual(n))throw new Error(gn.NON_EQUAL_VARIANCES);const a=o.getOneWayAnova();return{anovaTable:a,fCritical:pn.centralF.inv(1-n,a.dfBn,a.dfWn),significance:n}}var bn=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{l(r.next(t))}catch(t){o(t)}}function s(t){try{l(r.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}l((r=r.apply(t,e||[])).next())})};const Cn=.05,xn=!1,Sn=t.Column.fromList(t.COLUMN_TYPE.INT,"features",[9,12,4,8,7,4,6,8,2,10,1,3,4,5,2]),An=t.Column.fromStrings("features",["A","A","A","A","A","B","B","B","B","B","C","C","C","C","C"]);var En;!function(t){t[t.DF_BN=2]="DF_BN",t[t.DF_TOT=14]="DF_TOT",t[t.DF_WN=12]="DF_WN",t[t.SS_BN=63.333]="SS_BN",t[t.SS_TOT=147.333]="SS_TOT",t[t.SS_WN=84]="SS_WN",t[t.MS_BN=31.666]="MS_BN",t[t.MS_WN=7]="MS_WN",t[t.F_STAT=4.523]="F_STAT",t[t.F_CRIT=3.885]="F_CRIT",t[t.P_VAL=.034]="P_VAL"}(En||(En={})),x("ANOVA",()=>{b("Performance: 1M rows demog",()=>bn(void 0,void 0,void 0,function*(){const t=O.data.demo.demog(1e6),e=t.col("race"),n=t.col("height");new _n(e,n,e.stats.uniqueCount).areVarsEqual(Cn),wn(e,n,Cn,xn)}),{timeout:4e3,benchmark:!0}),b("Correctness",()=>bn(void 0,void 0,void 0,function*(){const t=wn(An,Sn,Cn,xn),e=t.anovaTable;C(e.dfBn,En.DF_BN,"Incorrect degrees of freedom: dfBn"),C(e.dfTot,En.DF_TOT,"Incorrect degrees of freedom: dfTot"),C(e.dfWn,En.DF_WN,"Incorrect degrees of freedom: dfWn");const n=(t,e)=>Math.abs(t-e)<.01;C(n(e.ssBn,En.SS_BN),!0,"Incorrect sum of squares: ssBn"),C(n(e.ssTot,En.SS_TOT),!0,"Incorrect sum of squares: ssTot"),C(n(e.ssWn,En.SS_WN),!0,"Incorrect sum of squares: ssWn"),C(n(e.msBn,En.MS_BN),!0,"Incorrect mean squares: msBn"),C(n(e.msWn,En.MS_WN),!0,"Incorrect mean squares: msWn"),C(n(e.fStat,En.F_STAT),!0,"Incorrect F-statistics value"),C(n(e.pValue,En.P_VAL),!0,"Incorrect p-value"),C(n(t.fCritical,En.F_CRIT),!0,"Incorrect F-critical")}),{timeout:4e3})});var Tn=n(5778),Mn=n.n(Tn);const Pn=rxjs,Nn=10,On=10,Fn=20,Rn=30;class In{constructor(t,e,n){this.root=it.div(),this.onChanged=new Pn.Subject,this._prop=t,this.root.style.width=`${e}px`,this.root.style.height=`${n}px`,this.root.style.position="relative";const r=this;setTimeout(()=>{var i,o;if(!this.root.parentElement)return void console.warn("Konva this.container not attached to DOM yet.");const a=new(Mn().Stage)({container:this.root,width:e,height:n}),s=new(Mn().Layer);a.add(s);const l=null!==(i=t.min)&&void 0!==i?i:Math.min(...t.line.map(t=>t[0])),c=null!==(o=t.max)&&void 0!==o?o:Math.max(...t.line.map(t=>t[0])),h=new(Mn().Line)({points:[Rn,n-Fn,e-On,n-Fn],stroke:"grey",strokeWidth:1}),u=new(Mn().Line)({points:[Rn,Nn,Rn,n-Fn],stroke:"grey",strokeWidth:1});s.add(h,u);const d=new(Mn().Text)({x:Rn,y:n-Fn+3,text:l.toFixed(1),fontSize:9,fill:"grey"}),f=new(Mn().Text)({x:e-On-15,y:n-Fn+3,text:c.toFixed(1),fontSize:9,align:"right",fill:"grey"}),g=new(Mn().Text)({x:10,y:n-Fn-5,text:"0.0",fontSize:9,fill:"grey"}),p=new(Mn().Text)({x:10,y:5,text:"1.0",fontSize:9,fill:"grey"});s.add(d,f,g,p);const m=new(Mn().Line)({points:[],stroke:"#2077b4",strokeWidth:2,lineCap:"round",lineJoin:"round"});s.add(m);const y=new(Mn().Group);function v(i=!0){y.destroyChildren();const o=[];t.line.sort((t,e)=>t[0]-e[0]),t.line.forEach((r,i)=>{const h=Dn(r[0],r[1],l,c,e,n);o.push(h.x,h.y);const u=new(Mn().Circle)({x:h.x,y:h.y,radius:3,fill:"#d72f30",stroke:"black",strokeWidth:1,draggable:!0,hitStrokeWidth:5});u.setAttr("_pointIndex",i),u.on("dragmove",r=>{const i=r.target,o=i.position(),a=i.getAttr("_pointIndex"),h=a>0?t.line[a-1][0]:l,u=a<t.line.length-1?t.line[a+1][0]:c,d=c-l===0?0:.001*(c-l),f=Dn(h+(a>0?d:0),0,l,c,e,n).x,g=Dn(u-(a<t.line.length-1?d:0),0,l,c,e,n).x;o.x=Math.max(f,Math.min(g,o.x));const p=n-Fn;o.y=Math.max(10,Math.min(p,o.y)),i.position(o);const y=Ln(o.x,o.y,l,c,e,n);t.line[a][0]=y.x,t.line[a][1]=y.y;const v=t.line.map((t,r)=>{if(r===a)return[o.x,o.y];{const r=Dn(t[0],t[1],l,c,e,n);return[r.x,r.y]}}).flat();m.points(v),s.batchDraw()}),u.on("dragend",e=>{t.line.sort((t,e)=>t[0]-e[0]),v()}),u.on("contextmenu",e=>{if(e.evt.preventDefault(),t.line.length<=2)return void O.shell.warning("Cannot remove points, minimum of 2 required.");const n=e.target.getAttr("_pointIndex");t.line.splice(n,1),v()}),u.on("mouseenter",t=>{a.container().style.cursor="pointer";const r=t.target.position(),i=Ln(r.x,r.y,l,c,e,n),o=`X: ${i.x.toFixed(2)}, Y: ${i.y.toFixed(2)}<br><br>Drag to move, right-click to delete`;it.tooltip.show(o,t.evt.clientX,t.evt.clientY)}),u.on("mouseleave",t=>{a.container().style.cursor="default",it.tooltip.hide()}),y.add(u)}),m.points(o),s.batchDraw(),i&&r.onChanged.next()}s.add(y),a.on("click tap",r=>{if(r.target instanceof Mn().Circle||0!==r.evt.button)return;const i=a.getPointerPosition();if(!i)return;if(i.x<Rn||i.x>e-On||i.y<Nn||i.y>n-Fn)return;const o=Ln(i.x,i.y,l,c,e,n);t.line.push([o.x,o.y]),v()}),a.on("mouseenter",t=>{if(!(t.target instanceof Mn().Circle)){const t=a.getPointerPosition();t&&t.x>=Rn&&t.x<=e-On&&t.y>=Nn&&t.y<=n-Fn&&(a.container().style.cursor="crosshair")}}),a.on("mouseleave",t=>{t.target instanceof Mn().Circle||(a.container().style.cursor="default")}),a.on("mousemove",t=>{if(!(t.target instanceof Mn().Circle)){const t=a.getPointerPosition();t&&t.x>=Rn&&t.x<=e-On&&t.y>=Nn&&t.y<=n-Fn?a.container().style.cursor="crosshair":a.container().style.cursor="default"}}),a.on("mouseout",t=>it.tooltip.hide()),v(!1)},0)}get line(){return this._prop.line}}function Dn(t,e,n,r,i,o){const a=o-Nn-Fn;return{x:Rn+(t-n)*(r-n===0?1:(i-Rn-On)/(r-n)),y:Nn+a-e*a}}function Ln(t,e,n,r,i,o){const a=o-Nn-Fn;let s=n+(t-Rn)/(r-n===0?1:(i-Rn-On)/(r-n)),l=(Nn+a-e)/a;return s=Math.max(n,Math.min(r,s)),l=Math.max(0,Math.min(1,l)),{x:s,y:l}}class kn{constructor(t){this.root=it.div([]),this.onChanged=new Pn.Subject,this.dataFrame=t,this.setProfile()}getProfile(){return this.profile}setProfile(t){if(this.profile=t,it.empty(this.root),!t)return void this.root.append(it.divText("No profile specified."));const e=it.divH([it.divText("Property",{style:{fontWeight:"bold",width:"150px"}}),it.divText("Weight",{style:{fontWeight:"bold",width:"60px"}}),it.divText("Desirability",{style:{fontWeight:"bold",flexGrow:"1"}})],{style:{marginTop:"10px",paddingBottom:"5px",borderBottom:"1px solid #ccc"}}),n=Object.entries(t.properties).map(([e,n])=>{var r,i,o;const a=new In(n,300,80);a.onChanged.subscribe(t=>this.onChanged.next());const s=it.input.float("",{value:n.weight,min:0,max:1,onValueChanged:n=>{if(t&&t.properties[e]){let r=null!=n?n:0;r=Math.max(0,Math.min(1,r)),t.properties[e].weight=r}}});s.root.style.width="60px",s.root.style.marginTop="21px";const l=this.dataFrame?this.dataFrame.columns.names().find(t=>t.toLowerCase()==e.toLowerCase()):null,c=it.input.choice("",{nullable:!0,items:null!==(o=null===(i=null===(r=this.dataFrame)||void 0===r?void 0:r.columns)||void 0===i?void 0:i.names())&&void 0!==o?o:[""],value:null!=l?l:""}),h=it.divH([it.divV([it.divText(e,{style:{width:"150px",paddingTop:"5px",marginLeft:"4px"}}),this.dataFrame?c.root:null]),s.root,a.root]);return h.style.alignItems="center",h.style.marginBottom="5px",h.style.minHeight="70px",h}).filter(t=>null!==t);n.length>0?(this.root.append(e),this.root.append(it.divV(n))):this.root.append(it.divText("No matching properties found in the table for this template."))}}var Un=n(5072),Gn=n.n(Un),Bn=n(7825),Vn=n.n(Bn),Hn=n(7659),Wn=n.n(Hn),Yn=n(5056),jn=n.n(Yn),qn=n(540),Kn=n.n(qn),zn=n(1113),$n=n.n(zn),Xn=n(4884),Qn={};Qn.styleTagTransform=$n(),Qn.setAttributes=jn(),Qn.insert=Wn().bind(null,"head"),Qn.domAPI=Vn(),Qn.insertStyleElement=Kn(),Gn()(Xn.A,Qn),Xn.A&&Xn.A.locals&&Xn.A.locals;const Jn="pMPO is not applicable",Zn="Failed to compute pMPO parameters",tr="desired",er="non-desired",nr="Mean",rr="p-value",ir=new Map([["desAvg",`${nr}(${tr})`],["desStd",`Std(${tr})`],["nonDesAvg",`${nr}(${er})`],["nonDesStd",`Std(${er})`],["tstat","t-statistics"],["pValue",rr]]),or="Descriptor",ar=or+" Statistics",sr="Selected",lr="Weight",cr="pMPO score",hr="Desirability Curve",ur=.001,dr=.001,fr=.53,gr=.01,pr=.05,mr=.01,yr="0.000";var vr;!function(t){t.SELECTED="rgb(26, 146, 26)",t.SKIPPED="rgb(208, 57, 67)"}(vr||(vr={}));const _r=[0,.25,.5,1,1.5,2,2.5,3,4,5],wr=_r.slice(1).map(t=>-t).reverse().concat(_r),br=_r.concat([.12,.37,.63,.75,.88,1.25,1.75,2.25,2.75]).sort(),Cr=br.slice(1).map(t=>-t).reverse().concat(br),xr="TPR (Sensitivity)",Sr="FPR (1 - Specificity)",Ar=101,Er=new Float32Array(Array.from({length:Ar},(t,e)=>e/100)),Tr="System:AppData/Eda/drugs-props-train.csv",Mr="System:AppData/Eda/drugs-props-train-scores.csv",Pr=new Map([["tolerance",.001],["maxIter",25],["nonZeroParam",1e-4],["initialScale",.02],["scaleReflaction",1],["scaleExpansion",2],["scaleContraction",-.5]]),Nr=new Float32Array([.5,mr]),Or=new Float32Array([1,1]);function Fr(t,e){const n=t.groupBy([e.name]).getGroups();let r,i;for(const t in n)t.toLowerCase().includes("true")?r=n[t]:i=n[t];return{desired:r,nonDesired:i}}function Rr(t,e){const n=t.length,r=e.length;if(n<2||r<2)throw new Error(`Failed to compute the "${t.name}" descriptor statistics: \n both samples must have at least two observations.`);const i=t.stats.avg,o=e.stats.avg,a=t.stats.variance,s=e.stats.variance,l=t.stats.stdev,c=e.stats.stdev,h=Math.sqrt(a/n+s/r);if(0===h)throw new Error(`Failed to compute the "${t.name}" descriptor statistics: \n zero variance.`);const u=(i-o)/h,d=Math.pow(a/n+s/r,2)/(a*a/(n*n*(n-1))+s*s/(r*r*(r-1))),f=2*(1-pn.studentt.cdf(Math.abs(u),d));return{desAvg:i,desStd:l,desLen:n,nonDesAvg:o,nonDesStd:c,nonSesLen:r,min:Math.min(t.stats.min,e.stats.min),max:Math.max(t.stats.max,e.stats.max),tstat:u,pValue:f}}function Ir(e,n,r){if(e.length!==n.length)throw new Error("Failed to compute confusion matrix: columns have different lengths.");if(e.type!==t.COLUMN_TYPE.BOOL)throw new Error("Failed to compute confusion matrix: desirability column must be boolean.");if(!n.isNumerical)throw new Error("Failed to compute confusion matrix: prediction column must be numerical.");let i=0,o=0,a=0,s=0;const l=e.getRawData(),c=n.getRawData();let h=0,u=0,d=l[0];for(let t=0;t<n.length;++t)1==(d>>>u&1)?c[t]>=r?++i:++s:c[t]>=r?++a:++o,++u,u>=32&&(u=0,++h,d=l[h]);return{TP:i,TN:o,FP:a,FN:s}}function Dr(t,e){if(t.length!==e.length)throw new Error("Failed to compute AUC: TPR and FPR arrays have different lengths.");let n=0;for(let r=1;r<t.length;++r)n+=Math.abs(e[r]-e[r-1])*((t[r]+t[r-1])/2);return n}function Lr(t,e){const n=new Float32Array(Ar),r=new Float32Array(Ar);let i=-1,o=-1,a=Er[0];for(let s=0;s<Ar;++s){const l=Ir(t,e,Er[s]);n[s]=l.TP+l.FN>0?l.TP/(l.TP+l.FN):0,r[s]=l.FP+l.TN>0?l.FP/(l.FP+l.TN):0,o=n[s]-r[s],o>i&&(i=o,a=Er[s])}return{auc:Dr(n,r),threshold:a,tpr:n,fpr:r}}var kr,Ur,Gr,Br,Vr;!function(t){t.MIN="minimize",t.MAX="maximize"}(kr||(kr={})),function(t){t.OPTIMAL="optimal",t.NON_OPT="non-optimal"}(Ur||(Ur={})),function(t){t[t.FORM=.15]="FORM",t[t.VIEWER=.5]="VIEWER"}(Gr||(Gr={})),function(t){t.OPT="Pareto optimality",t.SIZE="Pareto size"}(Br||(Br={})),function(t){t[t.OPTIMAL=8]="OPTIMAL",t[t.NON_OPT=4]="NON_OPT"}(Vr||(Vr={}));const Hr=[t.Color.darkGreen,t.Color.yellow,t.Color.darkRed];function Wr(t){return t===kr.MIN?[...Hr]:[...Hr].reverse()}function Yr(e,n=!0){const r=it.label("Color scale:");r.style.paddingRight="7px";const i=[r],o=it.label(n?"min":"worst"),a=it.label(". . ."),s=it.label(n?"max":"best"),l=Wr(e),c=[o,a,s].map((e,n)=>(1!==n&&(e.style.fontWeight="bold",e.style.color=t.Color.toRgb(l[n])),e.style.marginRight="5px",e));return i.push(...c),it.divH(i)}var jr=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{l(r.next(t))}catch(t){o(t)}}function s(t){try{l(r.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}l((r=r.apply(t,e||[])).next())})};function qr(e){const n=e.size,r=new Map;ir.forEach((t,e)=>{r.set(e,new Float64Array(n))});const i=[...e.keys()],o=[t.Column.fromStrings(or,i),t.Column.fromInt32Array(hr,new Int32Array(n)),t.Column.fromFloat32Array(lr,new Float32Array(n).fill(t.FLOAT_NULL))];i.forEach((t,n)=>{const i=e.get(t);null!=i&&ir.forEach((t,e)=>{const o=i[e];r.get(e)[n]=o})}),ir.forEach((e,n)=>{o.push(t.Column.fromFloat64Array(e,r.get(n)))});const a=t.DataFrame.fromColumns(o);return a.name=ar,a}function Kr(t,e){const n=[],r=t.col(or);if(null==r)throw new Error(`No column "${or} in the table with descriptors statistics.`);const i=r.toList(),o=t.col(rr);if(null==o)throw new Error(`No column "${rr} in the table with descriptors statistics.`);const a=o.getRawData();for(let r=0;r<t.rowCount;++r)a[r]<e&&n.push(i[r]);return n}function zr(t,e,n,r){const i=it.div();i.classList.add("eda-pmpo-tooltip-line");const o=it.div();o.classList.add("eda-pmpo-box"),o.style.backgroundColor=vr.SELECTED;const a=it.span([]);a.textContent=`- ${n}`,i.appendChild(o),i.appendChild(a);const s=it.div();s.classList.add("eda-pmpo-tooltip-line");const l=it.div();l.classList.add("eda-pmpo-box"),l.style.backgroundColor=vr.SKIPPED;const c=it.span([]);return c.textContent=`- ${r}`,s.appendChild(l),s.appendChild(c),it.divV([it.h2(t),it.divText(e),i,s])}function $r(t,e){const n=[];for(let r=0;r<e.length;++r)for(let i=r+1;i<e.length;++i)n.push([e[r],e[i],Math.pow(t.byName(e[r]).stats.corr(t.byName(e[i])),2)]);return n}function Xr(t,e,n,r,i){const o=i.sort((t,e)=>e[2]-t[2]),a=new Set(e);return o.filter(t=>t[2]>r).forEach(t=>{const[e,r,i]=t,o=n.get(e).pValue,s=n.get(r).pValue,l=n.get(e).tstat,c=n.get(r).tstat;o>s?a.delete(e):o<s||Math.abs(l)>Math.abs(c)?a.delete(r):a.delete(e)}),[...a]}function Qr(t,e,n,r){const i=new Map;let o=0;return n.forEach(n=>{const a=t.rowCount,s=e.rowCount,l=t.col(n);if(null==l)throw new Error(Zn+`: no column "${n}" in the desired table.`);const c=e.col(n);if(null==c)throw new Error(Zn+`: no column "${n}" in the non-desired table.`);const h=l.stats.avg,u=l.stats.stdev*Math.sqrt((a-1)/a),d=c.stats.avg,f=c.stats.stdev*Math.sqrt((s-1)/s),g=(m=u,v=f,(p=h)<(y=d)?{cutoff:(y-p)/(m+v)*m+p,cutoffDesired:Math.max(p,y-v),cutoffNotDesired:Math.max(p+m,y)}:{cutoff:(p-y)/(m+v)*v+y,cutoffDesired:Math.min(y+v,p),cutoffNotDesired:Math.max(y,p-m)});var p,m,y,v;const _=Math.exp(-Math.pow(g.cutoff-h,2)/(2*Math.pow(u,2))),w=function(t,e,n,r){const i=1/(2*Math.pow(e,2))-1/(2*Math.pow(r,2)),o=n/Math.pow(r,2)-t/Math.pow(e,2),a=Math.pow(t,2)/(2*Math.pow(e,2))-Math.pow(n,2)/(2*Math.pow(r,2))-Math.log(r/e);if(Math.abs(i)<1e-12)return Math.abs(o)<1e-12?[]:[-a/o];const s=o*o-4*i*a;if(s<0)return[];const l=Math.sqrt(s);return[(-o+l)/(2*i),(-o-l)/(2*i)]}(h,u,d,f),b=Math.pow(_,-1)-1,C=Math.pow(r,-1)-1,x=Math.pow(10,Math.log10(C/b)/(-1*(d-g.cutoff)));let S=null;if(w.length>0){for(const t of w){const e=Math.min(h,d),n=Math.max(h,d);if(e-1e-8<=t&&t<=n+1e-8){S=t;break}}null==S&&(S=w[0])}else S=g.cutoff;const A=g.cutoffNotDesired,E=function(t,e,n,r,i=.05){let o;if(e<=0)o=n===t?1:0;else{const r=1/(e*Math.sqrt(2*Math.PI)),i=-.5*Math.pow((n-t)/e,2);o=r*Math.exp(i)}o=Math.max(o,1e-12);const a=Math.max(1/o-1,1e-12),s=1/i-1,l=r-n;let c;if(Math.abs(l)<1e-12)c=1;else{const t=s/a;if(t<=0)c=1;else try{c=Math.exp(-Math.log(t)/l)}catch(t){c=1}}return{pX0:o,b:a,c}}(h,u,S,A,r),T=Math.abs(h-d)/(u+f);o+=T,i.set(n,{desAvg:h,desStd:u,nonDesAvg:d,nonDesStd:f,min:Math.min(l.stats.min,c.stats.min),max:Math.max(l.stats.max,c.stats.max),cutoff:g.cutoff,cutoffDesired:g.cutoffDesired,cutoffNotDesired:g.cutoffNotDesired,pX0:E.pX0,b,c:x,zScore:T,weight:T,intersections:w,x0:S,xBound:A,inflection:_})}),i.forEach(t=>{t.weight=t.zScore/o}),i}function Jr(t,e,n,r,i){return{type:"MPO Desirability Profile",name:n,description:r,properties:Zr(t,e,i)}}function Zr(t,e,n){const r={};return t.forEach((t,i)=>{const o=ni(t,n);r[i]={weight:t.weight,line:ei(t,e,n),min:Math.min(...o),max:Math.max(...o)}}),r}function ti(t,e,n){return function(t,e,n){return Math.exp(-Math.pow(t-e,2)/(2*Math.pow(n,2)))}(t,e.desAvg,e.desStd)*(n?function(t,e,n,r){return r>0?1/(1+n*Math.pow(r,-(t-e))):1/(1+n)}(t,e.cutoff,e.b,e.c):1)}function ei(t,e,n){return ni(t,n).map(n=>[n,ti(n,t,e)])}function ni(t,e){const n=function(t,e,n){return n?wr.map(n=>t+n*e):Cr.map(n=>t+n*e)}(t.desAvg,t.desStd,e);if(e){const e=Math.min(t.min,t.desAvg-3*t.desStd),r=Math.max(t.max,t.desAvg+3*t.desStd);return n.filter(t=>e<=t&&t<=r).sort()}return n}class ri extends Error{constructor(t){super(t),this.name="PmpoError"}}function ii(t,e,n,r){for(let i=0;i<e;i++){let o=0;for(let t=0;t<e+1;t++)t!=n&&(o+=r[t][i]);t[i]=o/e}}function oi(t,e,n,r,i,o,a,s){for(let l=0;l<o;l++)e[l]=t[l],e[l]+=i*(t[l]-r[n][l]),e[l]<a[l]?e[l]=a[l]:e[l]>s[l]&&(e[l]=s[l])}function ai(t,e,n,r,i,o){return a=this,s=void 0,c=function*(){const a=r.get("tolerance"),s=r.get("maxIter"),l=r.get("scaleReflaction"),c=r.get("scaleExpansion"),h=r.get("scaleContraction"),u=n.length+1,d=n.length,[f,g]=function(t,e,n,r,i){const o=n.length+1,a=n.length,s=e.get("nonZeroParam"),l=e.get("initialScale"),c=new Array(o),h=new Array(o);for(let e=0;e<o;e++){c[e]=new Float32Array(a);for(let t=0;t<a;t++)c[e][t]=n[t],0!=e&&e-1===t&&(0==n[t]?c[e][t]=s:c[e][t]+=l*n[e-1],c[e][t]<r[t]?c[e][t]=r[t]:c[e][t]>i[t]&&(c[e][t]=i[t]));h[e]=t(c[e])}return[c,h]}(e,r,n,i,o),p=new Array(u);for(let t=0;t<u;t++)p[t]=t;const m=p.length-1;let y=0,v=0,_=0,w=0;const b=new Float32Array(d),C=new Float32Array(d),x=new Float32Array(d),S=new Float32Array(d),A=new Array(s);if(u>1){let n=0;for(;p.sort((t,e)=>g[t]-g[e]),n=Math.min(100,Math.floor(100*y/s)),t.update(n,`Optimizing pMPO... (${n}%)`),yield new Promise(t=>setTimeout(t,1)),!(t.canceled||y>s);){if(0==y&&(v=g[0],_=2*g[p[0]]),A[y]=v,++y,v=g[p[0]],_-v>a)w=0;else if(++w,w>2*u)break;_=v,ii(b,d,p[m],f),oi(b,C,p[m],f,l,d,i,o);const t=e(C);if(t<g[p[m]]){oi(b,x,p[m],f,c,d,i,o);const n=e(x);if(n<t){g[p[m]]=n;for(let t=0;t<d;t++)f[p[m]][t]=x[t];continue}g[p[m]]=t;for(let t=0;t<d;t++)f[p[m]][t]=C[t];continue}oi(b,S,p[m],f,h,d,i,o);const n=e(S);if(!(n<g[p[m]]))break;g[p[m]]=n;for(let t=0;t<d;t++)f[p[m]][t]=S[t]}for(let t=y;t<s;t++)A[t]=g[p[0]]}return{optimalPoint:f[p[0]],iterations:y}},new((l=void 0)||(l=Promise))(function(t,e){function n(t){try{i(c.next(t))}catch(t){e(t)}}function r(t){try{i(c.throw(t))}catch(t){e(t)}}function i(e){var i;e.done?t(e.value):(i=e.value,i instanceof l?i:new l(function(t){t(i)})).then(n,r)}i((c=c.apply(a,s||[])).next())});var a,s,l,c}var si=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{l(r.next(t))}catch(t){o(t)}}function s(t){try{l(r.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}l((r=r.apply(t,e||[])).next())})};class li{static isApplicable(e,n,r,i,o,a=!1){const s=n.length,l=t=>{a&&O.shell.warning(Jn+t)};if(r<dr)return l(`: too small p-value threshold - ${r}, minimum - 0.001`),!1;if(i<gr)return l(`: too small R² threshold - ${i}, minimum - 0.01`),!1;if(o<mr)return l(`: too small q-cutoff - ${o}, minimum - 0.01`),!1;if(s<10)return l(`: not enough of samples - ${s}, minimum - 10`),!1;if(n.type!==t.COLUMN_TYPE.BOOL)return l(`: "${n.name}" must be boolean column.`),!1;if(0===n.stats.stdev)return l(`: "${n.name}" has a single category.`),!1;let c=0;for(const t of e){if(!t.isNumerical)return l(`: "${t.name}" is not numerical.`),!1;if(t.stats.missingValueCount>0)return l(`: "${t.name}" contains missing values.`),!1;t.stats.stdev>0&&++c}return!(c<1&&(l(": not enough of non-constant descriptors."),1))}static isTableValid(e,n=!0){if(e.rowCount<2)return n&&O.shell.warning(Jn+`. Not enough of samples: ${e.rowCount}, minimum: 2.`),!1;let r=0,i=0;for(const n of e.columns)n.isNumerical?n.stats.missingValueCount<1&&n.stats.stdev>0&&++i:n.type==t.COLUMN_TYPE.BOOL&&++r;return r<1?(n&&O.shell.warning(Jn+": no boolean columns."),!1):!(i<1&&(n&&O.shell.warning(Jn+": no numeric columns without missing values and non-zero variance."),1))}static fit(e,n,r,i,o,a,s=!0){if(s&&!li.isApplicable(n,r,i,o,a))throw new Error("Failed to train pMPO model: the method is not applicable to the inputs");const l=n.names(),{desired:c,nonDesired:h}=Fr(e,r),u=new Map;l.forEach(t=>{u.set(t,Rr(c.col(t),h.col(t)))});const d=qr(u);!function(t,e){const n=t.col(rr);if(null==n)return;const r={};r[`<${e}`]=vr.SELECTED,r[`>=${e}`]=vr.SKIPPED,n.meta.colors.setConditional(r)}(d,i);const f=Kr(d,i);if(f.length<1)throw new ri("Cannot train pMPO model: all descriptors have high p-values (not significant).");const g=$r(n,f),p=Xr(0,f,u,o,g);return function(e,n){if(n.length<1)throw new Error("Empty list of selected descriptors.");const r=e.rowCount,i=new Array(r),o=e.col(or);if(null==o)throw new Error(`No column "${or} in the table with descriptors statistics.`);const a=o.toList();let s=!0;const l={};for(let t=0;t<r;++t)s=n.includes(a[t]),i[t]=s,l[a[t]]=s?vr.SELECTED:vr.SKIPPED;o.colors.setCategorical(l),e.columns.add(t.Column.fromList(t.COLUMN_TYPE.BOOL,sr,i))}(d,p),function(e,n,r,i){const o=new Map;n.forEach(e=>{o.set(e,new Float32Array(n.length).fill(t.FLOAT_NULL))});const a=e.col(or).toList();r.forEach(t=>{const[e,n,r]=t;o.get(e)[a.indexOf(n)]=r,o.get(n)[a.indexOf(e)]=r,o.get(e)[a.indexOf(e)]=1,o.get(n)[a.indexOf(n)]=1}),i.forEach(n=>{e.columns.add(t.Column.fromFloat32Array(n,o.get(n)))})}(d,l,g,p),function(t,e,n){e.forEach(e=>{const r=t.col(e);if(null==r)return;const i={};i[`>=${n}`]=vr.SKIPPED,i[`<${n}`]=vr.SELECTED,r.meta.colors.setConditional(i)})}(d,l,o),{params:Qr(c,h,p,a),descrStatsTable:d,selectedByPvalue:f,selectedByCorr:p}}static predict(e,n,r,i){const o=e.rowCount,a=new Float64Array(o).fill(0);return n.forEach((t,n)=>{const i=e.col(n),s=t.b,l=t.c,c=t.cutoff;let h=t.weight;const u=t.desAvg,d=t.desStd,f=1/(2*Math.pow(d,2));if(null==i)throw new Error(`Failed to apply pMPO: inconsistent data, no column "${n}" in the table "${e.name}"`);const g=i.getRawData();if(r)if(l>0)for(let t=0;t<o;++t)a[t]+=h*Math.exp(-Math.pow(g[t]-u,2)*f)/(1+s*Math.pow(l,-(g[t]-c)));else{h/=1+s;for(let t=0;t<o;++t)a[t]+=h*Math.exp(-Math.pow(g[t]-u,2)*f)}else for(let t=0;t<o;++t)a[t]+=h*Math.exp(-Math.pow(g[t]-u,2)*f)}),t.Column.fromFloat64Array(i,a)}constructor(e,n){var r;this.params=null,this.initTable=t.DataFrame.create(),this.statGrid=t.Viewer.grid(this.initTable,{showTitle:!0,title:ar}),this.predictionName=cr,this.boolPredictionName="",this.desirabilityProfileRoots=new Map,this.rocCurve=t.Viewer.scatterPlot(this.initTable,{showTitle:!0,showSizeSelector:!1,showColorSelector:!1}),this.confusionMatrix=t.Viewer.fromType("Confusion matrix",this.initTable,{xColumnName:"control",yColumnName:"control",showTitle:!0,title:"Confusion Matrix",descriptionPosition:"Bottom",description:"Confusion matrix for the predicted vs actual desirability labels.",descriptionVisibilityMode:"Always"}),this.table=e,this.view=null!=n?n:null!==(r=O.shell.tableView(e.name))&&void 0!==r?r:O.shell.addTableView(e),this.boolCols=this.getBoolCols(),this.numericCols=this.getValidNumericCols(),this.predictionName=e.columns.getUnusedName(cr)}setRibbons(){const t=this.view.getRibbonPanels();t.length<1||this.view.setRibbonPanels(t.slice(1))}updateStatisticsGrid(t,e,n,r){const i=this.statGrid;i.dataFrame=t,i.setOptions({showTitle:!0,title:t.name}),i.sort([sr],[!1]),i.col(rr).format="scientific",i.col(or).isTextColorCoded=!0,i.col(rr).isTextColorCoded=!0,e.forEach(t=>{const e=i.col(t);null!=e&&(e.isTextColorCoded=!0,e.format="0.000")}),i.onCellTooltip((t,o,a)=>{if(t.isColHeader){const n=t.tableColumn;if(null==n)return!1;const r=n.name;switch(r){case or:return it.tooltip.show(zr(or,"Use of descriptors in model construction:","selected","excluded"),o,a),!0;case hr:return it.tooltip.show(it.divV([it.h2(hr),it.divText("Desirability profile charts for each descriptor. Only profiles for selected descriptors are shown.")]),o,a),!0;case lr:return it.tooltip.show(it.divV([it.h2(lr),it.divText("Weights of selected descriptors.")]),o,a),!0;case rr:return it.tooltip.show(zr(rr,"Filtering descriptors by p-value:","selected","excluded"),o,a),!0;default:return!!e.includes(r)&&(it.tooltip.show(zr(r,`Correlation of ${r} with other descriptors, measured by R²:`,"weakly correlated","highly correlated"),o,a),!0)}}else if(t.isTableCell){const s=t.tableColumn;if(null==s)return!1;const l=s.name,c=t.value;if(l===or)return r.includes(c)?it.tooltip.show("Selected for model construction.",o,a):n.includes(c)?it.tooltip.show("Excluded due to a high correlation with other descriptors.",o,a):it.tooltip.show("Excluded due to a high p-value.",o,a),!0;{const r=i.cell(or,t.gridRow).value;if(l===lr)return!this.desirabilityProfileRoots.has(r)&&(n.includes(r)?it.tooltip.show(`No weight: <b>${r}</b> is excluded due to a high correlation with other descriptors.`,o,a):it.tooltip.show(`No weight: <b>${r}</b> is excluded due to a high p-value.`,o,a),!0);if(e.includes(l)&&!n.includes(r))return it.tooltip.show(`<b>${r}</b> is excluded due to a high p-value; so correlation with <b>${l}</b> is not needed.`,o,a),!0}return!1}});const o=i.col(hr);i.setOptions({rowHeight:75}),o.width=305,o.cellType="html",i.onCellPrepare(t=>{if(null==t.tableColumn)return;if(null==t.tableColumn)return;if(!t.isTableCell)return;if(t.tableColumn.name!==hr)return;const e=i.cell(or,t.gridRow).value,r=this.desirabilityProfileRoots.get(e);if(null!=r)t.element=r;else{const r=n.includes(e),i=r?"highly correlated with other descriptors":"statistically insignificant",o=r?`No chart shown: <b>${e}</b> is excluded due to a high correlation with other descriptors.`:`No chart shown: <b>${e}</b> is excluded due to a high p-value.`,a=it.divText(i);a.style.color=vr.SKIPPED,a.classList.add("eda-pmpo-centered-text"),it.tooltip.bind(a,o),t.element=a}})}updateGrid(){const t=this.view.grid,e=this.predictionName;t.sort([this.predictionName],[!1]),t.col(e).format="0.0000",t.onCellTooltip((t,n,r)=>{if(t.isColHeader&&t.tableColumn)return t.tableColumn.name===e&&(it.tooltip.show(it.divV([it.h2(cr),it.divText("Scores computed using the trained probabilistic multi-parameter optimization (pMPO) model."),Yr(kr.MAX,!1)]),n,r),!0)})}updateDesirabilityProfileData(t,e){if(null==this.params)return;this.desirabilityProfileRoots.forEach(t=>t.remove()),this.desirabilityProfileRoots.clear();const n=Jr(this.params,e,"","",!0),r=t.col(or).toList(),i=t.col(lr).getRawData(),o=n.properties;for(const t of Object.keys(o))i[r.indexOf(t)]=o[t].weight;const a=new kn;a.setProfile(n);const s=a.root.querySelector("div.d4-flex-col.ui-div");null!=s&&s.querySelectorAll("div.d4-flex-row.ui-div").forEach(t=>{const e=t.children;if(e.length<2)return;const n=e[0].children;if(n.length<1)return;const r=n[0].innerText;this.desirabilityProfileRoots.set(r,e[2])})}updateRocCurve(e,n){const r=Lr(e,n),i=t.DataFrame.fromColumns([t.Column.fromFloat32Array("Threshold",Er),t.Column.fromFloat32Array(Sr,r.fpr),t.Column.fromFloat32Array(xr,r.tpr)]);return i.meta.formulaLines.addLine({title:"Non-informative baseline",formula:`\${${xr}} = \${${Sr}}`,width:1,style:"dashed",min:0,max:1}),this.rocCurve.dataFrame=i,this.rocCurve.setOptions({xColumnName:Sr,yColumnName:xr,linesOrderColumnName:Sr,linesWidth:5,markerType:"dot",title:`ROC Curve (AUC = ${r.auc.toFixed(3)})`}),r.threshold}updateConfusionMatrix(t,e,n){this.confusionMatrix.dataFrame=t,this.confusionMatrix.setOptions({xColumnName:e,yColumnName:this.boolPredictionName,description:`Threshold: ${n.toFixed(3)} (optimized via Youden's J)`,title:e+" Confusion Matrix"})}fitAndUpdateViewers(e,n,r,i,o,a,s){const l=li.fit(e,n,r,i,o,a);this.params=l.params;const c=l.descrStatsTable,h=l.selectedByPvalue,u=l.selectedByCorr,d=n.names(),f=li.predict(e,this.params,s,this.predictionName);f.colors.setLinear(Wr(kr.MAX),{min:f.stats.min,max:f.stats.max}),e.columns.remove(this.predictionName),e.columns.add(f),this.updateGrid(),this.updateDesirabilityProfileData(c,s),this.updateStatisticsGrid(c,d,h,u);const g=this.updateRocCurve(r,f),p=r.name;e.columns.remove(this.boolPredictionName),this.boolPredictionName=e.columns.getUnusedName(p+"(predicted)");const m=function(e,n,r){if(!e.isNumerical)throw new Error("Failed to compute confusion matrix: prediction column must be numerical.");const i=e.length,o=new Array(i),a=e.getRawData();for(let t=0;t<i;++t)o[t]=a[t]>=n;return t.Column.fromList(t.COLUMN_TYPE.BOOL,r,o)}(f,g,this.boolPredictionName);e.columns.add(m),this.updateConfusionMatrix(e,p,g),this.view.dataFrame.selection.setAll(!1,!0)}runTrainingApp(){const e=this.view.dockManager;e.dock(this.getInputForm(!0).form,t.DOCK_TYPE.LEFT,null,void 0,.1);const n=e.findNode(this.view.grid.root);if(null==n)throw new Error("Failed to train pMPO: missing a grid in the table view.");const r=e.dock(this.statGrid,t.DOCK_TYPE.DOWN,n,void 0,.5),i=e.dock(this.rocCurve,t.DOCK_TYPE.RIGHT,r,void 0,.3);e.dock(this.confusionMatrix,t.DOCK_TYPE.RIGHT,i,void 0,.2),this.setRibbons()}getPmpoAppItems(){return{statsGrid:this.statGrid,rocCurve:this.rocCurve,confusionMatrix:this.confusionMatrix,controls:this.getInputForm(!1)}}getInputForm(e){const n=it.form([]);n.append(it.h2("Training data"));const r=this.numericCols.map(t=>t.name),i=()=>{try{this.fitAndUpdateViewers(this.table,t.DataFrame.fromColumns(o.value).columns,this.table.col(a.value),g.value,p.value,m.value,l.value)}catch(t){t instanceof ri?O.shell.warning(t.message):O.shell.error(t instanceof Error?t.message:Zn+": the platform issue.")}},o=it.input.columns("Descriptors",{table:this.table,nullable:!1,available:r,checked:r,tooltipText:"Descriptor columns used for model construction.",onValueChanged:t=>{null!=t&&(h=!1,d())}});n.append(o.root);const a=it.input.choice("Desirability",{nullable:!1,value:this.boolCols[0].name,items:this.boolCols.map(t=>t.name),tooltipText:"Desirability column.",onValueChanged:t=>{null!=t&&(h=!1,d())}});n.append(a.root);const s=it.h2("Settings");n.append(s),it.tooltip.bind(s,"Settings of the pMPO model.");const l=it.input.bool("σ correction",{value:!0,tooltipText:"Use the sigmoidal correction to the weighted Gaussian scores.",onValueChanged:t=>{h=!1,d()}});n.append(l.root);const c=this.table.rowCount<=1e4;let h=!1;const u=()=>si(this,void 0,void 0,function*(){if(!h){const e=yield this.getOptimalSettings(t.DataFrame.fromColumns(o.value).columns,this.table.col(a.value),l.value);e.success?(g.value=Math.max(e.pValTresh,dr),p.value=Math.max(e.r2Tresh,gr),m.value=Math.max(e.qCutoff,mr),h=!0):f.value=!1}i()}),d=()=>{f.value?u():i()},f=it.input.bool("Auto-tuning",{value:!1,tooltipText:"Automatically select optimal p-value, R², and q-cutoff by maximizing AUC.",onValueChanged:t=>si(this,void 0,void 0,function*(){y(!t),h||t&&(yield u())})});n.append(f.root);const g=it.input.float("p-value",{nullable:!1,min:dr,max:1,step:.001,value:ur,format:yr,tooltipText:"P-value threshold. Descriptors with p-values above this threshold are excluded.",onValueChanged:t=>{f.value||(h=!1,null!=t&&t>=dr&&t<=1&&i())}});n.append(g.root);const p=it.input.float("R²",{format:yr,nullable:!1,min:gr,value:fr,max:1,step:.01,tooltipText:"Squared correlation threshold. Descriptors with squared correlation above this threshold are considered highly correlated. Among them, the descriptor with the lower p-value is retained.",onValueChanged:t=>{f.value||(h=!1,null!=t&&t>=gr&&t<=1&&i())}});n.append(p.root);const m=it.input.float("q-cutoff",{format:yr,nullable:!1,min:mr,value:pr,max:1,step:.01,tooltipText:"Q-cutoff for the pMPO model computation.",onValueChanged:t=>{f.value||(h=!1,null!=t&&t>=mr&&t<=1&&i())}});n.append(m.root);const y=t=>{g.enabled=t,p.enabled=t,m.enabled=t};setTimeout(()=>{i(),c?f.value=!0:i()},10);const v=it.button("Save",()=>si(this,void 0,void 0,function*(){null!=this.params?function(t,e,n){jr(this,void 0,void 0,function*(){let r=e;const i=it.input.string("File",{value:r,nullable:!1,onValueChanged:t=>{r=t,d.getButton("Save").disabled=r.length<1||o.length<1}});let o="System:AppData/Chem/mpo";const a=it.input.string("Folder",{value:o,nullable:!1,onValueChanged:t=>{o=t,d.getButton("Save").disabled=r.length<1||o.length<1}}),s=()=>jr(this,void 0,void 0,function*(){const t=`${o}/${r}.json`;try{const e=JSON.stringify(l(),null,2);yield O.dapi.files.writeAsText(t,e),O.shell.info(`Saved to ${t}`)}catch(t){O.shell.error(`Failed to save: ${t instanceof Error?t.message:"the platform issue"}.`)}d.close()}),l=()=>u.value?Jr(t,n,i.value,h.value,!1):{type:"Probabilistic MPO Model",name:i.value,description:h.value,properties:Object.fromEntries(t)},c=it.input.string("Name",{value:e,nullable:!0}),h=it.input.textArea("Description",{value:" ",nullable:!0}),u=it.input.bool("Desirability Profile",{value:!0,tooltipText:"Save the model as an MPO Desirability Profile. If disabled, the model is saved in the pMPO format."}),d=it.dialog({title:"Save model"}).add(it.h2("Path")).add(a).add(i).add(it.h2("Model")).add(c).add(h).add(u).addButton("Save",()=>jr(this,void 0,void 0,function*(){(yield O.dapi.files.exists(`${o}/${r}.json`))?it.dialog({title:"Warning"}).add(it.label("Overwrite existing file?")).onOK(()=>jr(this,void 0,void 0,function*(){return yield s()})).show():yield s()})).show()})}(this.params,this.table.name,l.value):O.shell.warning("Failed to save pMPO model: null parameters.")}),"Save model as platform file.");e&&n.append(v);const _=it.div([n]);return _.classList.add("eda-pmpo-input-form"),{form:_,saveBtn:v}}getBoolCols(){const e=[];for(const n of this.table.columns)n.type===t.COLUMN_TYPE.BOOL&&n.stats.stdev>0&&e.push(n);return e}getValidNumericCols(){const t=[];for(const e of this.table.columns)e.isNumerical&&e.stats.missingValueCount<1&&e.stats.stdev>0&&t.push(e);return t}getOptimalSettings(e,n,r){return si(this,void 0,void 0,function*(){const i={pValTresh:0,r2Tresh:0,qCutoff:0,success:!1},o=e.names(),{desired:a,nonDesired:s}=Fr(this.table,n),l=new Map;o.forEach(t=>{l.set(t,Rr(a.col(t),s.col(t)))});const c=Kr(qr(l),ur);if(c.length<1)return i;const h=$r(e,c),u=t=>{const e=Xr(0,c,l,t[0],h),i=Qr(a,s,e,t[1]),o=li.predict(this.table,i,r,this.predictionName);return 1-Lr(n,o).auc},d=t.TaskBarProgressIndicator.create("Optimizing... ",{cancelable:!0});try{const t=yield ai(d,u,new Float32Array([fr,pr]),Pr,Nr,Or),e=!d.canceled;return d.close(),e?{pValTresh:ur,r2Tresh:t.optimalPoint[0],qCutoff:t.optimalPoint[1],success:!0}:i}catch(t){return d.close(),i}})}}class ci{constructor(t,e,n,r){this.sourceDf=t,this.drugName=e,this.desirabilityColName=n,this.smilesColName=r;const i=t.columns.toList().filter(t=>t.isNumerical).map(t=>t.name),{desired:o,nonDesired:a}=Fr(t,t.col(n));this.descriptorStats=new Map,i.forEach(t=>{this.descriptorStats.set(t,Rr(o.col(t),a.col(t)))}),this.desiredProbability=o.rowCount/t.rowCount}getGenerated(e){if(e<=1)throw new Error("Failed to generate pMPO data: sample count must be greater than 1.");let n;if(e<=this.sourceDf.rowCount){const r=t.BitSet.create(this.sourceDf.rowCount);for(let t=0;t<e;++t)r.set(t,!0);n=this.sourceDf.clone(r)}else n=this.getClonedSourceDfWithFloatNumericCols().append(this.getSyntheticTable(e-this.sourceDf.rowCount));for(const e of n.columns)if(e.type===t.COLUMN_TYPE.BOOL&&0===e.stats.stdev){let t=e.get(0);e.set(0,!t),t=e.get(1),e.set(1,!t)}return n}getSyntheticTable(e){const n=new Array(e);for(let t=0;t<e;++t)n[t]=Math.random()<this.desiredProbability;const r=[this.getDrugColumn(e),this.getSmilesColumn(e),t.Column.fromList(t.COLUMN_TYPE.BOOL,this.desirabilityColName,n)];return this.descriptorStats.forEach((i,o)=>{const a=new Float32Array(e);for(let t=0;t<e;++t)n[t]?a[t]=pn.normal.sample(i.desAvg,i.desStd):a[t]=pn.normal.sample(i.nonDesAvg,i.nonDesStd);r.push(t.Column.fromFloat32Array(o,a))}),t.DataFrame.fromColumns(r)}getDrugColumn(e){return t.Column.fromList(t.COLUMN_TYPE.STRING,this.drugName,Array.from({length:e},(t,e)=>`Synthetic drug ${e+1}`))}getSmilesColumn(e){return t.Column.fromList(t.COLUMN_TYPE.STRING,this.smilesColName,Array.from({length:e},()=>"C"))}getClonedSourceDfWithFloatNumericCols(){const e=[];this.sourceDf.columns.toList().forEach(n=>{n.isNumerical?e.push(n.clone().convertTo(t.COLUMN_TYPE.FLOAT)):e.push(n.clone())});const n=t.DataFrame.fromColumns(e);return n.name=this.sourceDf.name,n}}var hi=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{l(r.next(t))}catch(t){o(t)}}function s(t){try{l(r.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}l((r=r.apply(t,e||[])).next())})};const di="CNS",fi=["TPSA","TPSA_S","HBA","HBD","MW","nAtoms","cLogD_ACD_v15","mapKa","cLogP_Biobyte","mbpKa","cLogP_ACD_v15","ALogP98"],gi="Score",pi="Drug",mi="Sigmoidal",yi=[mi,"Gaussian"];function vi(t,e,n,r){if(0===n)return[];const i=t.length;if(e.length!==i)throw new Error("Sense array length must match number of dimensions");const o=new Uint32Array(n);for(let t=0;t<n;t++)o[t]=t;o.sort((n,r)=>e[0]===kr.MIN?t[0][n]-t[0][r]:t[0][r]-t[0][n]);const a=Array(n).fill(!0),s=[];null==r||r.forEach(t=>a[t]=!1);for(const n of o){if(!a[n])continue;let r=!1;for(const o of s){let a=!0,s=!1;for(let r=0;r<i;r++){const i=t[r][o],l=t[r][n];e[r]===kr.MIN?(i>l&&(a=!1),i<l&&(s=!0)):(i<l&&(a=!1),i>l&&(s=!0))}if(a&&s){r=!0;break}}r?a[n]=!1:s.push(n)}return a}x("Probabilistic MPO",()=>{yi.forEach(e=>{const n=e==mi;b("Correctness: "+e,()=>hi(void 0,void 0,void 0,function*(){let r=null,i=null,o=null,a=[],s=null,l=null,c=null,h=null;try{if(r=yield O.dapi.files.readCsv(Tr),i=yield O.dapi.files.readCsv(Mr),o=r.col(di),a=r.columns.byNames(fi),null==o)throw new Error;const u=li.fit(r,t.DataFrame.fromColumns(a).columns,o,ur,fr,pr),d=li.predict(r,u.params,n,gi);s=r.col(pi),l=i.col(pi),c=i.col(e),h=function(t,e,n,r){let i=0;const o=t.toList(),a=n.toList(),s=e.getRawData(),l=r.getRawData();return o.forEach((t,e)=>{const n=a.indexOf(t);if(n<0)throw new Error(`Failed to compare pMPO scores: the "${t}" drug is missing in the reference data.`);i=Math.max(i,Math.abs(s[e]-l[n]))}),i}(s,d,l,c)}catch(t){O.shell.error(t.message)}C(null!==r,!0,"Failed to load the source data: "+Tr),C(null!==i,!0,"Failed to load the scores data: "+Mr),C(null!==o,!0,"Inconsistent source data: no column "+di),C(a.length,fi.length,"Inconsistent source data: no enough of columns"),C(null!==s,!0,"Inconsistent source data: no column "+pi),C(null!==l,!0,"Inconsistent reference data: no column "+pi),C(null!==c,!0,"Inconsistent reference data: no column "+gi),C(null!==h,!0,"Failed to compare pMPO scores with the reference data"),C(h<1e-6,!0,"Max absolute deviation of pMPO scores exceeds the threshold (0.000001)")}),{timeout:1e4})}),b("Performance: 100K drugs, "+fi.length+" descriptors",()=>hi(void 0,void 0,void 0,function*(){let e=null,n=null,r=[];try{if(e=yield function(){return t=this,e=void 0,r=function*(){const t=yield O.dapi.files.readCsv(Tr);return new ci(t,"Drug","CNS","Smiles").getGenerated(1e5)},new((n=void 0)||(n=Promise))(function(i,o){function a(t){try{l(r.next(t))}catch(t){o(t)}}function s(t){try{l(r.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}l((r=r.apply(t,e||[])).next())});var t,e,n,r}(),n=e.col(di),r=e.columns.byNames(fi),null==n)throw new Error;const i=li.fit(e,t.DataFrame.fromColumns(r).columns,n,ur,fr,pr);li.predict(e,i.params,!0,gi)}catch(t){O.shell.error(t.message)}C(null!==e,!0,"Failed to load the source data: "+Tr),C(null!==n,!0,"Inconsistent source data: no column "+di),C(r.length,fi.length,"Inconsistent source data: no enough of columns")}),{timeout:1e4})});var _i=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{l(r.next(t))}catch(t){o(t)}}function s(t){try{l(r.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}l((r=r.apply(t,e||[])).next())})};const wi=5e3,bi=1e6,Ci="1M points, 2D";function xi(t,e,n=42){const r=[];let i=n;const o=()=>(i=(1664525*i+1013904223)%4294967296,i/4294967296);for(let n=0;n<e;n++){const e=new Float32Array(t);for(let r=0;r<t;r++)e[r]=100*o()+10*n;r.push(e)}return r}function Si(t,e){const n=[];for(let r=0;r<t;r++)"all-min"===e?n.push(kr.MIN):"all-max"===e?n.push(kr.MAX):n.push(r%2==0?kr.MIN:kr.MAX);return n}function Ai(t,e){const n=Math.floor(t*e),r=new Set,i=Math.floor(t/n);for(let t=0;t<n;t++)r.add(t*i);return r}function Ei(t,e){if(t.length!==e)throw new Error(`Invalid mask length: expected ${e}, got ${t.length}`);const n=t.filter(t=>t).length;if(0===n)throw new Error("No optimal points found");n===e&&O.shell.warning("All points are optimal - data may be degenerate")}x("Pareto optimization",()=>{b(`Performance: ${Ci}`,()=>_i(void 0,void 0,void 0,function*(){var t;let e=null,n=null;try{e=vi(xi(bi,2),Si(2,"mixed"),bi),Ei(e,bi)}catch(t){n=t,O.shell.error(n.message)}C(null!==e,!0,"Failed to compute Pareto mask"),C(null===n,!0,null!==(t=null==n?void 0:n.message)&&void 0!==t?t:"")}),{timeout:wi}),b(`Performance: ${Ci}, all minimize`,()=>_i(void 0,void 0,void 0,function*(){var t;let e=null,n=null;try{e=vi(xi(bi,2),Si(2,"all-min"),bi),Ei(e,bi)}catch(t){n=t,O.shell.error(n.message)}C(null!==e,!0,"Failed to compute Pareto mask"),C(null===n,!0,null!==(t=null==n?void 0:n.message)&&void 0!==t?t:"")}),{timeout:wi}),b(`Performance: ${Ci}, all maximize`,()=>_i(void 0,void 0,void 0,function*(){var t;let e=null,n=null;try{e=vi(xi(bi,2),Si(2,"all-max"),bi),Ei(e,bi)}catch(t){n=t,O.shell.error(n.message)}C(null!==e,!0,"Failed to compute Pareto mask"),C(null===n,!0,null!==(t=null==n?void 0:n.message)&&void 0!==t?t:"")}),{timeout:wi}),b(`Performance: ${Ci} with 10% null indices`,()=>_i(void 0,void 0,void 0,function*(){var t;let e=null,n=null;try{const t=xi(bi,2),n=Si(2,"mixed"),r=Ai(bi,.1);e=vi(t,n,bi,r),Ei(e,bi)}catch(t){n=t,O.shell.error(n.message)}C(null!==e,!0,"Failed to compute Pareto mask"),C(null===n,!0,null!==(t=null==n?void 0:n.message)&&void 0!==t?t:"")}),{timeout:wi}),b(`Performance: ${Ci} with 25% null indices`,()=>_i(void 0,void 0,void 0,function*(){var t;let e=null,n=null;try{const t=xi(bi,2),n=Si(2,"mixed"),r=Ai(bi,.25);e=vi(t,n,bi,r),Ei(e,bi)}catch(t){n=t,O.shell.error(n.message)}C(null!==e,!0,"Failed to compute Pareto mask"),C(null===n,!0,null!==(t=null==n?void 0:n.message)&&void 0!==t?t:"")}),{timeout:wi}),b("Edge case: Empty dataset",()=>_i(void 0,void 0,void 0,function*(){var t;let e=null,n=null;try{e=vi([new Float32Array(0),new Float32Array(0)],Si(2,"mixed"),0)}catch(t){n=t,O.shell.error(n.message)}C(null!==e,!0,"Failed to compute Pareto mask"),C(e.length,0,"Empty dataset should return empty mask"),C(null===n,!0,null!==(t=null==n?void 0:n.message)&&void 0!==t?t:"")}),{timeout:wi}),b("Edge case: Single point",()=>_i(void 0,void 0,void 0,function*(){var t;let e=null,n=null;try{e=vi([new Float32Array([1]),new Float32Array([2])],Si(2,"mixed"),1)}catch(t){n=t,O.shell.error(n.message)}C(null!==e,!0,"Failed to compute Pareto mask"),C(e.length,1,"Single point dataset should return mask with one element"),C(e[0],!0,"Single point should be optimal"),C(null===n,!0,null!==(t=null==n?void 0:n.message)&&void 0!==t?t:"")}),{timeout:wi}),b("Edge case: All identical points",()=>_i(void 0,void 0,void 0,function*(){var t;let e=null,n=null;try{const t=100;e=vi([new Float32Array(t).fill(5),new Float32Array(t).fill(10)],Si(2,"mixed"),t)}catch(t){n=t,O.shell.error(n.message)}C(null!==e,!0,"Failed to compute Pareto mask"),C(e.length,100,"Should return mask with correct length"),C(e.filter(t=>t).length>0,!0,"At least some identical points should be optimal"),C(null===n,!0,null!==(t=null==n?void 0:n.message)&&void 0!==t?t:"")}),{timeout:wi})});var Ti=function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{l(r.next(t))}catch(t){o(t)}}function s(t){try{l(r.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}l((r=r.apply(t,e||[])).next())})};const Mi=new t.Package;function Pi(e,n,r){return Ti(this,void 0,void 0,function*(){const d=yield function(t){var e,n,r;return i(this,void 0,void 0,function*(){const d=(null==t?void 0:t.nodeOptions)?t.nodeOptions.package:grok.functions.getCurrentCall().func.package;if(!d)throw new Error("Can't run tests outside of the package");const f=null===(e=d.packageOwner)||void 0===e?void 0:e.match(/<([^>]*)>/),g=f?f[1]:"";null!=d&&(yield A(d));const p=[];console.log("Running tests..."),console.log(t),null!=t||(t={}),null!==(n=(r=t).testContext)&&void 0!==n||(r.testContext=new _),grok.shell.clearLastError();const m=function(){const t=[];return console.log=(...e)=>{t.push(...e),s(...e)},console.info=(...e)=>{t.push(...e),l(...e)},console.warn=(...e)=>{t.push(...e),c(...e)},console.error=(...e)=>{t.push(...e),h(...e)},t}();yield function(t,e){var n,r,o,a,u,f;return i(this,void 0,void 0,function*(){try{let l=null!=(null==e?void 0:e.skipToCategory),c=!1;for(const[h,m]of Object.entries(t)){if(null===(n=e.exclude)||void 0===n?void 0:n.some(t=>h.startsWith(t)))continue;if(null!=(null==e?void 0:e.category)&&!h.toLowerCase().startsWith(null==e?void 0:e.category.toLowerCase().trim()))continue;if(l)if(c)l=!1;else{if(null==(null==e?void 0:e.skipToCategory)||h.toLowerCase().trim()!==(null==e?void 0:e.skipToCategory.toLowerCase().trim()))continue;c=!0}const t=null===(r=m.tests)||void 0===r?void 0:r.every(t=>{var n;return(null===(n=t.options)||void 0===n?void 0:n.skipReason)||null!=(null==e?void 0:e.test)&&e.test.toLowerCase()!==t.name.toLowerCase()});if(!t){const t=(null!==(o=m.tests)&&void 0!==o?o:[]).filter(t=>{var n;return(null===(n=t.options)||void 0===n?void 0:n.skipReason)||null!=(null==e?void 0:e.test)&&e.test.toLowerCase()!==t.name.toLowerCase()}).length;s(`Package testing: Started {{${h}}}${t>0?` skipped {{${t}}}`:""}`),m.beforeStatus=yield y(m.before,h)}let _,w=null!==(a=m.tests)&&void 0!==a?a:[];e.stressTest&&(w=w.filter(t=>{var e;return null===(e=t.options)||void 0===e?void 0:e.stressTest}),w=M(w)),(null!==(f=null===(u=e.tags)||void 0===u?void 0:u.length)&&void 0!==f?f:0)>0&&(w=w.filter(t=>{var n,r;return null===(r=null===(n=t.options)||void 0===n?void 0:n.tags)||void 0===r?void 0:r.some(t=>{var n;return(null!==(n=null==e?void 0:e.tags)&&void 0!==n?n:[]).includes(t)})})),m.beforeStatus?(_=Array.from(w.map(t=>({date:(new Date).toISOString(),category:h,name:t.name,success:!1,result:"before() failed",ms:0,skipped:!1,logs:"",owner:g,package:d.name,widgetsDifference:0,flaking:DG.Test.isReproducing}))),_.forEach(t=>i(this,void 0,void 0,function*(){return yield grok.shell.reportTest("package",t)}))):_=yield v(m,e,l);const b=_.filter(t=>"skipped"!=t.result);if(t||(m.afterStatus=yield y(m.after,h)),m.afterStatus&&(s(`Package testing: Category after() {{${h}}} failed`),s(`Package testing: Result for {{${h}}} after: ${m.afterStatus}`),b.push({date:(new Date).toISOString(),category:h,name:"after",success:!1,result:m.afterStatus,ms:0,skipped:!1,logs:"",owner:g,package:d.name,widgetsDifference:0,flaking:DG.Test.isReproducing})),m.beforeStatus&&(s(`Package testing: Category before() {{${h}}} failed`),s(`Package testing: Result for {{${h}}} before: ${m.beforeStatus}`),b.push({date:(new Date).toISOString(),category:h,name:"before",success:!1,result:m.beforeStatus,ms:0,skipped:!1,logs:"",owner:g,package:d.name,widgetsDifference:0,flaking:DG.Test.isReproducing})),p.push(...b),e.returnOnFail&&b.some(t=>!t.success&&!t.skipped&&t.name!==e.skipToTest))break}}finally{console.log=s,console.info=l,console.warn=c,console.error=h}if(e.testContext.catchUnhandled&&!DG.Test.isInBenchmark){yield P(1e3);const t=yield grok.shell.lastError;if(null!=t){const e={logs:"",date:(new Date).toISOString(),category:"Unhandled exceptions",name:"Exception",result:null!=t?t:"",success:!t,ms:0,skipped:!1,owner:null!=g?g:"",package:d.name,widgetsDifference:0};s(`Package testing: Unhandled Exception: ${t}`),p.push(Object.assign(Object.assign({},e),{flaking:DG.Test.isReproducing&&!t})),e.package=d.name,yield grok.shell.reportTest("package",e)}}})}(u,t);for(let t of p)t.result=t.result.toString().replace(/"/g,"'"),null!=t.logs&&(t.logs=t.logs.toString().replace(/"/g,"'"));return p;function y(t,e){return i(this,void 0,void 0,function*(){let n;try{void 0!==t&&(yield N(()=>i(this,void 0,void 0,function*(){yield t()}),1e5,`before ${e}: timeout error`))}catch(t){n=yield E(t)}return n})}function v(t,e,n){var r,s,l,c,h,u,f,p,y,v,_,b,C,x,S,A,E,M;return i(this,void 0,void 0,function*(){let i=null!==(r=t.tests)&&void 0!==r?r:[];const P=[],N=w();if(t.clear){let r=n&&null!=e.skipToTest;for(let n=0;n<i.length;n++){i[n].options&&void 0===(null===(s=i[n].options)||void 0===s?void 0:s.benchmark)&&(i[n].options||(i[n].options={}),i[n].options.benchmark=null!==(l=t.benchmarks)&&void 0!==l&&l);let b=i[n];if(e.test&&e.test.toLowerCase()!==b.name.toLowerCase())continue;if(r){if(null==(null==e?void 0:e.skipToTest)||b.name.toLowerCase().trim()!==(null==e?void 0:e.skipToTest.toLowerCase().trim()))continue;r=!1}(null==b?void 0:b.options)&&(b.options.owner=null!==(f=null!==(u=null!==(h=null===(c=i[n].options)||void 0===c?void 0:c.owner)&&void 0!==h?h:null==t?void 0:t.owner)&&void 0!==u?u:g)&&void 0!==f?f:"");let C=yield T(b,null==e?void 0:e.test,m,DG.Test.isInBenchmark?null!==(y=null===(p=i[n].options)||void 0===p?void 0:p.benchmarkTimeout)&&void 0!==y?y:a:null!==(_=null===(v=i[n].options)||void 0===v?void 0:v.timeout)&&void 0!==_?_:o,d.name,e.verbose);if(C&&(P.push(Object.assign(Object.assign({},C),{widgetsDifference:w()-N})),e.returnOnFail&&e.skipToTest!==b.name&&!C.success&&!C.skipped))return P;e.nodeOptions||(grok.shell.closeAll(),DG.Balloon.closeAll())}}else{let r=n&&null!=e.skipToTest;for(let n=0;n<i.length;n++){let o=i[n];if(e.test&&e.test.toLowerCase()!==o.name.toLowerCase())continue;if(r){null!=(null==e?void 0:e.skipToTest)&&o.name.toLowerCase().trim()===(null==e?void 0:e.skipToTest.toLowerCase().trim())&&(r=!1);continue}(null==o?void 0:o.options)&&(o.options.owner=null!==(S=null!==(x=null!==(C=null===(b=i[n].options)||void 0===b?void 0:b.owner)&&void 0!==C?C:null==t?void 0:t.owner)&&void 0!==x?x:g)&&void 0!==S?S:"");let s=yield T(o,null==e?void 0:e.test,m,DG.Test.isInBenchmark?null!==(E=null===(A=i[n].options)||void 0===A?void 0:A.benchmarkTimeout)&&void 0!==E?E:a:null===(M=i[n].options)||void 0===M?void 0:M.timeout,d.name,e.verbose);if(s&&(P.push(Object.assign(Object.assign({},s),{widgetsDifference:w()-N})),e.returnOnFail&&e.skipToTest!==o.name&&!s.success&&!s.skipped))return P}}return P})}function w(){var t;if("undefined"!=typeof process)return 0;let e=-1;try{e=DG.Widget.getAll().length}catch(e){console.warn(null!==(t=e.message)&&void 0!==t?t:e)}return e}})}({category:e,test:n,testContext:r});return t.DataFrame.fromObjects(d)})}function Ni(){return Ti(this,void 0,void 0,function*(){yield A(Mi,Mi.getModule("package-test.js"))})}})(),eda_test=r})();
|
|
1
|
+
var eda_test;(()=>{var t,e,n,o,r={5540(t,e,n){"use strict";t=n.hmd(t);var o,r=(o="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,function(t={}){var e,n,r=void 0!==t?t:{};r.ready=new Promise(function(t,o){e=t,n=o});var i,s=Object.assign({},r),a="object"==typeof window,l="function"==typeof importScripts,u=("object"==typeof process&&"object"==typeof process.versions&&process.versions.node,"");(a||l)&&(l?u=self.location.href:"undefined"!=typeof document&&document.currentScript&&(u=document.currentScript.src),o&&(u=o),u=0!==u.indexOf("blob:")?u.substr(0,u.replace(/[?#].*/,"").lastIndexOf("/")+1):"",l&&(i=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)})),r.print||console.log.bind(console);var c,f,d=r.printErr||console.warn.bind(console);Object.assign(r,s),s=null,r.arguments&&r.arguments,r.thisProgram&&r.thisProgram,r.quit&&r.quit,r.wasmBinary&&(c=r.wasmBinary),r.noExitRuntime,"object"!=typeof WebAssembly&&T("no native wasm support detected");var h,m,p,g=!1;function v(){var t=f.buffer;r.HEAP8=h=new Int8Array(t),r.HEAP16=new Int16Array(t),r.HEAP32=new Int32Array(t),r.HEAPU8=m=new Uint8Array(t),r.HEAPU16=new Uint16Array(t),r.HEAPU32=p=new Uint32Array(t),r.HEAPF32=new Float32Array(t),r.HEAPF64=new Float64Array(t)}var y=[],A=[],w=[];function C(t){y.unshift(t)}function E(t){w.unshift(t)}var b,x,_=0,N=null,M=null;function T(t){r.onAbort&&r.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 S(t){return t.startsWith("data:application/octet-stream;base64,")}function O(t){try{if(t==b&&c)return new Uint8Array(c);if(i)return i(t);throw"both async and sync fetching of the wasm failed"}catch(t){T(t)}}function I(t,e,n){return function(t){return c||!a&&!l||"function"!=typeof fetch?Promise.resolve().then(function(){return O(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 O(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),T(t)})}function L(t){for(;t.length>0;)t.shift()(r)}function P(t){this.excPtr=t,this.ptr=t-24,this.set_type=function(t){p[this.ptr+4>>2]=t},this.get_type=function(){return p[this.ptr+4>>2]},this.set_destructor=function(t){p[this.ptr+8>>2]=t},this.get_destructor=function(){return p[this.ptr+8>>2]},this.set_caught=function(t){t=t?1:0,h[this.ptr+12|0]=t},this.get_caught=function(){return 0!=h[this.ptr+12|0]},this.set_rethrown=function(t){t=t?1:0,h[this.ptr+13|0]=t},this.get_rethrown=function(){return 0!=h[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){p[this.ptr+16>>2]=t},this.get_adjusted_ptr=function(){return p[this.ptr+16>>2]},this.get_exception_ptr=function(){if(H(this.get_type()))return p[this.excPtr>>2];var t=this.get_adjusted_ptr();return 0!==t?t:this.excPtr}}function R(t){var e=f.buffer;try{return f.grow(t-e.byteLength+65535>>>16),v(),1}catch(t){}}function F(t){return r["_"+t]}S(b="wasmDbscan.wasm")||(x=b,b=r.locateFile?r.locateFile(x,u):u+x);var D="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function B(t,e,n,o,r){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 o=t.charCodeAt(n);o<=127?e++:o<=2047?e+=2:o>=55296&&o<=57343?(e+=4,++n):e+=3}return e}(t)+1,n=$(e);return function(t,e,n){!function(t,e,n,o){if(!(o>0))return 0;for(var r=n+o-1,i=0;i<t.length;++i){var s=t.charCodeAt(i);if(s>=55296&&s<=57343&&(s=65536+((1023&s)<<10)|1023&t.charCodeAt(++i)),s<=127){if(n>=r)break;e[n++]=s}else if(s<=2047){if(n+1>=r)break;e[n++]=192|s>>6,e[n++]=128|63&s}else if(s<=65535){if(n+2>=r)break;e[n++]=224|s>>12,e[n++]=128|s>>6&63,e[n++]=128|63&s}else{if(n+3>=r)break;e[n++]=240|s>>18,e[n++]=128|s>>12&63,e[n++]=128|s>>6&63,e[n++]=128|63&s}}e[n]=0}(t,m,e,n)}(t,n,e),n}(t)),e},array:t=>{var e,n,o=$(t.length);return e=t,n=o,h.set(e,n),o}},s=F(t),a=[],l=0;if(o)for(var u=0;u<o.length;u++){var c=i[n[u]];c?(0===l&&(l=V()),a[u]=c(o[u])):a[u]=o[u]}var f=s.apply(null,a);return function(t){return 0!==l&&G(l),function(t){return"string"===e?(n=t)?function(t,e,n){for(var o=e+n,r=e;t[r]&&!(r>=o);)++r;if(r-e>16&&t.buffer&&D)return D.decode(t.subarray(e,r));for(var i="";e<r;){var s=t[e++];if(128&s){var a=63&t[e++];if(192!=(224&s)){var l=63&t[e++];if((s=224==(240&s)?(15&s)<<12|a<<6|l:(7&s)<<18|a<<12|l<<6|63&t[e++])<65536)i+=String.fromCharCode(s);else{var u=s-65536;i+=String.fromCharCode(55296|u>>10,56320|1023&u)}}else i+=String.fromCharCode((31&s)<<6|a)}else i+=String.fromCharCode(s)}return i}(m,n,o):"":"boolean"===e?Boolean(t):t;var n,o}(t)}(f)}var k,U={__cxa_throw:function(t,e,n){throw new P(t).init(e,n),t},abort:function(){T("")},emscripten_memcpy_big:function(t,e,n){m.copyWithin(t,e,e+n)},emscripten_resize_heap:function(t){var e=m.length,n=2147483648;if((t>>>=0)>n)return!1;let o=(t,e)=>t+(e-t%e)%e;for(var r=1;r<=4;r*=2){var i=e*(1+.2/r);if(i=Math.min(i,t+100663296),R(Math.min(n,o(Math.max(t,i),65536))))return!0}return!1}},V=(function(){var t,e,o,i,s={env:U,wasi_snapshot_preview1:U};function a(t,e){var n,o=t.exports;return r.asm=o,f=r.asm.memory,v(),r.asm.__indirect_function_table,n=r.asm.__wasm_call_ctors,A.unshift(n),function(){if(_--,r.monitorRunDependencies&&r.monitorRunDependencies(_),0==_&&(null!==N&&(clearInterval(N),N=null),M)){var t=M;M=null,t()}}(),o}if(_++,r.monitorRunDependencies&&r.monitorRunDependencies(_),r.instantiateWasm)try{return r.instantiateWasm(s,a)}catch(t){d("Module.instantiateWasm callback failed with error: "+t),n(t)}(t=c,e=b,o=s,i=function(t){a(t.instance)},t||"function"!=typeof WebAssembly.instantiateStreaming||S(e)||"function"!=typeof fetch?I(e,o,i):fetch(e,{credentials:"same-origin"}).then(function(t){return WebAssembly.instantiateStreaming(t,o).then(i,function(t){return d("wasm streaming compile failed: "+t),d("falling back to ArrayBuffer instantiation"),I(e,o,i)})})).catch(n)}(),r._dbscan=function(){return(r._dbscan=r.asm.dbscan).apply(null,arguments)},r._malloc=function(){return(r._malloc=r.asm.malloc).apply(null,arguments)},r._free=function(){return(r._free=r.asm.free).apply(null,arguments)},function(){return(V=r.asm.stackSave).apply(null,arguments)}),G=function(){return(G=r.asm.stackRestore).apply(null,arguments)},$=function(){return($=r.asm.stackAlloc).apply(null,arguments)},H=function(){return(H=r.asm.__cxa_is_pointer_type).apply(null,arguments)};function q(){function t(){k||(k=!0,r.calledRun=!0,g||(L(A),e(r),r.onRuntimeInitialized&&r.onRuntimeInitialized(),function(){if(r.postRun)for("function"==typeof r.postRun&&(r.postRun=[r.postRun]);r.postRun.length;)E(r.postRun.shift());L(w)}()))}_>0||(function(){if(r.preRun)for("function"==typeof r.preRun&&(r.preRun=[r.preRun]);r.preRun.length;)C(r.preRun.shift());L(y)}(),_>0||(r.setStatus?(r.setStatus("Running..."),setTimeout(function(){setTimeout(function(){r.setStatus("")},1),t()},1)):t()))}if(r.ccall=B,r.cwrap=function(t,e,n,o){var r=!n||n.every(t=>"number"===t||"boolean"===t);return"string"!==e&&r&&!o?F(t):function(){return B(t,e,n,arguments)}},M=function t(){k||q(),k||(M=t)},r.preInit)for("function"==typeof r.preInit&&(r.preInit=[r.preInit]);r.preInit.length>0;)r.preInit.pop()();return q(),t.ready});"object"==typeof exports?t.exports=r:"function"==typeof define&&n.amdO?define([],function(){return r}):"object"==typeof exports&&(exports.exportCppDbscanLib=r)},4884(t,e,n){"use strict";n.d(e,{A:()=>a});var o=n(1354),r=n.n(o),i=n(6314),s=n.n(i)()(r());s.push([t.id,".eda-pmpo-tooltip-line {\n display: flex;\n align-items: center;\n gap: 6px;\n margin-left: 6px;\n}\n\n.eda-pmpo-box {\n width: 10px;\n height: 10px;\n}\n\n.eda-pmpo-input-form {\n padding-left: 10px;\n padding-right: 5px;\n}\n\n.eda-pmpo-title {\n font-size: 14.5px;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n pointer-events: none;\n white-space: nowrap;\n}\n\n.eda-pmpo-centered-text {\n display: flex;\n justify-content: center;\n align-items: center;\n height: 100%;\n width: 100%;\n text-align: center;\n}","",{version:3,sources:["webpack://./css/pmpo.css"],names:[],mappings:"AAAA;EACE,aAAa;EACb,mBAAmB;EACnB,QAAQ;EACR,gBAAgB;AAClB;;AAEA;EACE,WAAW;EACX,YAAY;AACd;;AAEA;EACE,kBAAkB;EAClB,kBAAkB;AACpB;;AAEA;EACE,iBAAiB;EACjB,kBAAkB;EAClB,QAAQ;EACR,SAAS;EACT,gCAAgC;EAChC,oBAAoB;EACpB,mBAAmB;AACrB;;AAEA;EACE,aAAa;EACb,uBAAuB;EACvB,mBAAmB;EACnB,YAAY;EACZ,WAAW;EACX,kBAAkB;AACpB",sourcesContent:[".eda-pmpo-tooltip-line {\n display: flex;\n align-items: center;\n gap: 6px;\n margin-left: 6px;\n}\n\n.eda-pmpo-box {\n width: 10px;\n height: 10px;\n}\n\n.eda-pmpo-input-form {\n padding-left: 10px;\n padding-right: 5px;\n}\n\n.eda-pmpo-title {\n font-size: 14.5px;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n pointer-events: none;\n white-space: nowrap;\n}\n\n.eda-pmpo-centered-text {\n display: flex;\n justify-content: center;\n align-items: center;\n height: 100%;\n width: 100%;\n text-align: center;\n}"],sourceRoot:""}]);const a=s},6801(t,e,n){"use strict";n.d(e,{A:()=>a});var o=n(1354),r=n.n(o),i=n(6314),s=n.n(i)()(r());s.push([t.id,".statistics-mpo-header {\n margin-top: 10px;\n padding-bottom: 5px;\n border-bottom: 1px solid var(--grey-2);\n gap: 10px;\n}\n\n.statistics-mpo-header > * {\n font-weight: bold;\n}\n\n.statistics-mpo-header > *:first-child {\n width: 130px;\n}\n\n.statistics-mpo-header > *:nth-child(2) {\n width: 120px;\n min-width: 60px;\n}\n\n.statistics-mpo-header > *:nth-child(3) {\n flex-grow: 1;\n}\n\n.statistics-mpo-property-cell {\n width: 130px;\n max-width: 130px;\n align-self: flex-end;\n margin-bottom: 20px !important;\n}\n\n.ui-form .statistics-mpo-property-cell > div:first-child {\n padding-left: 4px;\n}\n\n.statistics-mpo-property-cell > div:first-child {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.statistics-mpo-weight-input {\n width: 100px;\n}\n\n.statistics-mpo-weight-cell {\n align-self: flex-end;\n margin-bottom: 20px !important;\n align-items: center;\n gap: 4px;\n}\n\n.statistics-mpo-control-buttons {\n gap: 10px;\n margin-left: 10px;\n color: var(--blue-1);\n visibility: hidden;\n white-space: nowrap;\n flex-shrink: 0;\n}\n\n.statistics-mpo-row:hover .statistics-mpo-control-buttons,\n.statistics-mpo-cat-row:hover .statistics-mpo-control-buttons {\n visibility: visible;\n}\n\n.statistics-mpo-range-input {\n width: 70px;\n}\n\n.statistics-mpo-row {\n display: flex;\n align-items: center;\n justify-content: flex-start;\n padding: 8px 0;\n min-height: 70px;\n gap: 10px;\n\n flex-wrap: wrap;\n}\n\n.statistics-mpo-row > * {\n flex: 0 0 auto;\n}\n\n\n.statistics-mpo-row .ui-input-choice .ui-input-editor {\n width: 100px !important;\n max-width: none !important;\n}\n\n.ui-form .statistics-mpo-row .ui-input-root {\n margin-bottom: 0 !important;\n padding: 0 !important;\n}\n\n.statistics-mpo-editor-fill {\n width: 100%;\n height: 100%;\n}\n\n.statistics-mpo-cat-editor {\n width: 280px;\n margin-left: 30px;\n}\n\n.statistics-mpo-cat-row {\n display: flex;\n align-items: center;\n gap: 4px;\n margin-bottom: 2px;\n}\n\n.statistics-mpo-cat-name {\n width: 120px;\n}\n\n.statistics-mpo-cat-col-header {\n font-size: 11px;\n color: var(--grey-3);\n text-transform: uppercase;\n letter-spacing: 0.3px;\n}\n\n.statistics-mpo-desirability-dialog .statistics-mpo-cat-editor {\n width: auto;\n margin-left: 0;\n}\n\n.statistics-mpo-desirability-dialog .statistics-mpo-cat-name {\n flex: 1;\n width: auto;\n}\n\n.statistics-mpo-cat-desirability {\n width: 70px;\n}\n\n.statistics-mpo-weight-toggle {\n cursor: pointer;\n color: var(--grey-3);\n font-size: 12px;\n}\n\n.statistics-mpo-weight-toggle:hover {\n color: var(--grey-5);\n}\n\n.statistics-mpo-weight-toggle-active {\n color: var(--blue-1);\n}\n\n.statistics-mpo-weight-toggle-active:hover {\n color: var(--blue-2);\n}\n\n.statistics-mpo-hidden {\n display: none !important;\n}\n\n.statistics-mpo-empty-state {\n text-align: center;\n padding: 48px 24px;\n color: var(--grey-4);\n border: 1px dashed var(--grey-2);\n border-radius: 8px;\n margin: 16px 12px;\n}\n\n.statistics-mpo-empty-state i {\n font-size: 48px;\n margin-bottom: 16px;\n display: block;\n color: var(--blue-1);\n opacity: 0.3;\n cursor: default;\n pointer-events: none;\n}\n\n.statistics-mpo-empty-state h3 {\n color: var(--grey-5);\n}\n\n.statistics-mpo-empty-state p {\n color: var(--grey-3);\n max-width: 360px;\n margin-inline: auto;\n}\n\n.statistics-mpo-dialog-header-row {\n gap: 12px;\n align-items: flex-end;\n margin-bottom: 8px;\n}\n\n.statistics-mpo-dialog-header-row .ui-input-root {\n flex: 0 1 auto;\n}\n\n.statistics-mpo-section-header {\n font-size: 11px;\n text-transform: uppercase;\n color: var(--blue-1);\n letter-spacing: 0.5px;\n border-bottom: 1px solid var(--grey-2);\n padding-bottom: 4px;\n margin: 12px 0 8px;\n}\n\n.statistics-mpo-param-grid.ui-form {\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 0 8px;\n}\n\n.statistics-mpo-desirability-dialog .statistics-mpo-plot {\n margin: 0 auto;\n}\n\n@media (max-width: 500px) {\n .statistics-mpo-row {\n flex-direction: column;\n align-items: flex-start;\n }\n\n .statistics-mpo-row > * {\n width: 100% !important;\n margin-bottom: 5px;\n }\n\n .statistics-mpo-weight-cell {\n margin-top: 0 !important;\n }\n}\n","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/statistics/css/styles.css"],names:[],mappings:"AAAA;EACE,gBAAgB;EAChB,mBAAmB;EACnB,sCAAsC;EACtC,SAAS;AACX;;AAEA;EACE,iBAAiB;AACnB;;AAEA;EACE,YAAY;AACd;;AAEA;EACE,YAAY;EACZ,eAAe;AACjB;;AAEA;EACE,YAAY;AACd;;AAEA;EACE,YAAY;EACZ,gBAAgB;EAChB,oBAAoB;EACpB,8BAA8B;AAChC;;AAEA;EACE,iBAAiB;AACnB;;AAEA;EACE,gBAAgB;EAChB,uBAAuB;EACvB,mBAAmB;AACrB;;AAEA;EACE,YAAY;AACd;;AAEA;EACE,oBAAoB;EACpB,8BAA8B;EAC9B,mBAAmB;EACnB,QAAQ;AACV;;AAEA;EACE,SAAS;EACT,iBAAiB;EACjB,oBAAoB;EACpB,kBAAkB;EAClB,mBAAmB;EACnB,cAAc;AAChB;;AAEA;;EAEE,mBAAmB;AACrB;;AAEA;EACE,WAAW;AACb;;AAEA;EACE,aAAa;EACb,mBAAmB;EACnB,2BAA2B;EAC3B,cAAc;EACd,gBAAgB;EAChB,SAAS;;EAET,eAAe;AACjB;;AAEA;EACE,cAAc;AAChB;;;AAGA;EACE,uBAAuB;EACvB,0BAA0B;AAC5B;;AAEA;EACE,2BAA2B;EAC3B,qBAAqB;AACvB;;AAEA;EACE,WAAW;EACX,YAAY;AACd;;AAEA;EACE,YAAY;EACZ,iBAAiB;AACnB;;AAEA;EACE,aAAa;EACb,mBAAmB;EACnB,QAAQ;EACR,kBAAkB;AACpB;;AAEA;EACE,YAAY;AACd;;AAEA;EACE,eAAe;EACf,oBAAoB;EACpB,yBAAyB;EACzB,qBAAqB;AACvB;;AAEA;EACE,WAAW;EACX,cAAc;AAChB;;AAEA;EACE,OAAO;EACP,WAAW;AACb;;AAEA;EACE,WAAW;AACb;;AAEA;EACE,eAAe;EACf,oBAAoB;EACpB,eAAe;AACjB;;AAEA;EACE,oBAAoB;AACtB;;AAEA;EACE,oBAAoB;AACtB;;AAEA;EACE,oBAAoB;AACtB;;AAEA;EACE,wBAAwB;AAC1B;;AAEA;EACE,kBAAkB;EAClB,kBAAkB;EAClB,oBAAoB;EACpB,gCAAgC;EAChC,kBAAkB;EAClB,iBAAiB;AACnB;;AAEA;EACE,eAAe;EACf,mBAAmB;EACnB,cAAc;EACd,oBAAoB;EACpB,YAAY;EACZ,eAAe;EACf,oBAAoB;AACtB;;AAEA;EACE,oBAAoB;AACtB;;AAEA;EACE,oBAAoB;EACpB,gBAAgB;EAChB,mBAAmB;AACrB;;AAEA;EACE,SAAS;EACT,qBAAqB;EACrB,kBAAkB;AACpB;;AAEA;EACE,cAAc;AAChB;;AAEA;EACE,eAAe;EACf,yBAAyB;EACzB,oBAAoB;EACpB,qBAAqB;EACrB,sCAAsC;EACtC,mBAAmB;EACnB,kBAAkB;AACpB;;AAEA;EACE,aAAa;EACb,8BAA8B;EAC9B,UAAU;AACZ;;AAEA;EACE,cAAc;AAChB;;AAEA;EACE;IACE,sBAAsB;IACtB,uBAAuB;EACzB;;EAEA;IACE,sBAAsB;IACtB,kBAAkB;EACpB;;EAEA;IACE,wBAAwB;EAC1B;AACF",sourcesContent:[".statistics-mpo-header {\n margin-top: 10px;\n padding-bottom: 5px;\n border-bottom: 1px solid var(--grey-2);\n gap: 10px;\n}\n\n.statistics-mpo-header > * {\n font-weight: bold;\n}\n\n.statistics-mpo-header > *:first-child {\n width: 130px;\n}\n\n.statistics-mpo-header > *:nth-child(2) {\n width: 120px;\n min-width: 60px;\n}\n\n.statistics-mpo-header > *:nth-child(3) {\n flex-grow: 1;\n}\n\n.statistics-mpo-property-cell {\n width: 130px;\n max-width: 130px;\n align-self: flex-end;\n margin-bottom: 20px !important;\n}\n\n.ui-form .statistics-mpo-property-cell > div:first-child {\n padding-left: 4px;\n}\n\n.statistics-mpo-property-cell > div:first-child {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.statistics-mpo-weight-input {\n width: 100px;\n}\n\n.statistics-mpo-weight-cell {\n align-self: flex-end;\n margin-bottom: 20px !important;\n align-items: center;\n gap: 4px;\n}\n\n.statistics-mpo-control-buttons {\n gap: 10px;\n margin-left: 10px;\n color: var(--blue-1);\n visibility: hidden;\n white-space: nowrap;\n flex-shrink: 0;\n}\n\n.statistics-mpo-row:hover .statistics-mpo-control-buttons,\n.statistics-mpo-cat-row:hover .statistics-mpo-control-buttons {\n visibility: visible;\n}\n\n.statistics-mpo-range-input {\n width: 70px;\n}\n\n.statistics-mpo-row {\n display: flex;\n align-items: center;\n justify-content: flex-start;\n padding: 8px 0;\n min-height: 70px;\n gap: 10px;\n\n flex-wrap: wrap;\n}\n\n.statistics-mpo-row > * {\n flex: 0 0 auto;\n}\n\n\n.statistics-mpo-row .ui-input-choice .ui-input-editor {\n width: 100px !important;\n max-width: none !important;\n}\n\n.ui-form .statistics-mpo-row .ui-input-root {\n margin-bottom: 0 !important;\n padding: 0 !important;\n}\n\n.statistics-mpo-editor-fill {\n width: 100%;\n height: 100%;\n}\n\n.statistics-mpo-cat-editor {\n width: 280px;\n margin-left: 30px;\n}\n\n.statistics-mpo-cat-row {\n display: flex;\n align-items: center;\n gap: 4px;\n margin-bottom: 2px;\n}\n\n.statistics-mpo-cat-name {\n width: 120px;\n}\n\n.statistics-mpo-cat-col-header {\n font-size: 11px;\n color: var(--grey-3);\n text-transform: uppercase;\n letter-spacing: 0.3px;\n}\n\n.statistics-mpo-desirability-dialog .statistics-mpo-cat-editor {\n width: auto;\n margin-left: 0;\n}\n\n.statistics-mpo-desirability-dialog .statistics-mpo-cat-name {\n flex: 1;\n width: auto;\n}\n\n.statistics-mpo-cat-desirability {\n width: 70px;\n}\n\n.statistics-mpo-weight-toggle {\n cursor: pointer;\n color: var(--grey-3);\n font-size: 12px;\n}\n\n.statistics-mpo-weight-toggle:hover {\n color: var(--grey-5);\n}\n\n.statistics-mpo-weight-toggle-active {\n color: var(--blue-1);\n}\n\n.statistics-mpo-weight-toggle-active:hover {\n color: var(--blue-2);\n}\n\n.statistics-mpo-hidden {\n display: none !important;\n}\n\n.statistics-mpo-empty-state {\n text-align: center;\n padding: 48px 24px;\n color: var(--grey-4);\n border: 1px dashed var(--grey-2);\n border-radius: 8px;\n margin: 16px 12px;\n}\n\n.statistics-mpo-empty-state i {\n font-size: 48px;\n margin-bottom: 16px;\n display: block;\n color: var(--blue-1);\n opacity: 0.3;\n cursor: default;\n pointer-events: none;\n}\n\n.statistics-mpo-empty-state h3 {\n color: var(--grey-5);\n}\n\n.statistics-mpo-empty-state p {\n color: var(--grey-3);\n max-width: 360px;\n margin-inline: auto;\n}\n\n.statistics-mpo-dialog-header-row {\n gap: 12px;\n align-items: flex-end;\n margin-bottom: 8px;\n}\n\n.statistics-mpo-dialog-header-row .ui-input-root {\n flex: 0 1 auto;\n}\n\n.statistics-mpo-section-header {\n font-size: 11px;\n text-transform: uppercase;\n color: var(--blue-1);\n letter-spacing: 0.5px;\n border-bottom: 1px solid var(--grey-2);\n padding-bottom: 4px;\n margin: 12px 0 8px;\n}\n\n.statistics-mpo-param-grid.ui-form {\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 0 8px;\n}\n\n.statistics-mpo-desirability-dialog .statistics-mpo-plot {\n margin: 0 auto;\n}\n\n@media (max-width: 500px) {\n .statistics-mpo-row {\n flex-direction: column;\n align-items: flex-start;\n }\n\n .statistics-mpo-row > * {\n width: 100% !important;\n margin-bottom: 5px;\n }\n\n .statistics-mpo-weight-cell {\n margin-top: 0 !important;\n }\n}\n"],sourceRoot:""}]);const a=s},6314(t){"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map(function(e){var n="",o=void 0!==e[5];return e[4]&&(n+="@supports (".concat(e[4],") {")),e[2]&&(n+="@media ".concat(e[2]," {")),o&&(n+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),n+=t(e),o&&(n+="}"),e[2]&&(n+="}"),e[4]&&(n+="}"),n}).join("")},e.i=function(t,n,o,r,i){"string"==typeof t&&(t=[[null,t,void 0]]);var s={};if(o)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(s[l]=!0)}for(var u=0;u<t.length;u++){var c=[].concat(t[u]);o&&s[c[0]]||(void 0!==i&&(void 0===c[5]||(c[1]="@layer".concat(c[5].length>0?" ".concat(c[5]):""," {").concat(c[1],"}")),c[5]=i),n&&(c[2]?(c[1]="@media ".concat(c[2]," {").concat(c[1],"}"),c[2]=n):c[2]=n),r&&(c[4]?(c[1]="@supports (".concat(c[4],") {").concat(c[1],"}"),c[4]=r):c[4]="".concat(r)),e.push(c))}},e}},1354(t){"use strict";t.exports=function(t){var e=t[1],n=t[3];if(!n)return e;if("function"==typeof btoa){var o=btoa(unescape(encodeURIComponent(JSON.stringify(n)))),r="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(o),i="/*# ".concat(r," */");return[e].concat([i]).join("\n")}return[e].join("\n")}},9982(t,e,n){var o;!function(){var e={};!function(t){"use strict";t.__esModule=!0,t.digestLength=32,t.blockSize=64;var e=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function n(t,n,o,r,i){for(var s,a,l,u,c,f,d,h,m,p,g,v,y;i>=64;){for(s=n[0],a=n[1],l=n[2],u=n[3],c=n[4],f=n[5],d=n[6],h=n[7],p=0;p<16;p++)g=r+4*p,t[p]=(255&o[g])<<24|(255&o[g+1])<<16|(255&o[g+2])<<8|255&o[g+3];for(p=16;p<64;p++)v=((m=t[p-2])>>>17|m<<15)^(m>>>19|m<<13)^m>>>10,y=((m=t[p-15])>>>7|m<<25)^(m>>>18|m<<14)^m>>>3,t[p]=(v+t[p-7]|0)+(y+t[p-16]|0);for(p=0;p<64;p++)v=(((c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7))+(c&f^~c&d)|0)+(h+(e[p]+t[p]|0)|0)|0,y=((s>>>2|s<<30)^(s>>>13|s<<19)^(s>>>22|s<<10))+(s&a^s&l^a&l)|0,h=d,d=f,f=c,c=u+v|0,u=l,l=a,a=s,s=v+y|0;n[0]+=s,n[1]+=a,n[2]+=l,n[3]+=u,n[4]+=c,n[5]+=f,n[6]+=d,n[7]+=h,r+=64,i-=64}return r}var o=function(){function e(){this.digestLength=t.digestLength,this.blockSize=t.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return e.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this},e.prototype.clean=function(){for(var t=0;t<this.buffer.length;t++)this.buffer[t]=0;for(t=0;t<this.temp.length;t++)this.temp[t]=0;this.reset()},e.prototype.update=function(t,e){if(void 0===e&&(e=t.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");var o=0;if(this.bytesHashed+=e,this.bufferLength>0){for(;this.bufferLength<64&&e>0;)this.buffer[this.bufferLength++]=t[o++],e--;64===this.bufferLength&&(n(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(e>=64&&(o=n(this.temp,this.state,t,o,e),e%=64);e>0;)this.buffer[this.bufferLength++]=t[o++],e--;return this},e.prototype.finish=function(t){if(!this.finished){var e=this.bytesHashed,o=this.bufferLength,r=e/536870912|0,i=e<<3,s=e%64<56?64:128;this.buffer[o]=128;for(var a=o+1;a<s-8;a++)this.buffer[a]=0;this.buffer[s-8]=r>>>24&255,this.buffer[s-7]=r>>>16&255,this.buffer[s-6]=r>>>8&255,this.buffer[s-5]=r>>>0&255,this.buffer[s-4]=i>>>24&255,this.buffer[s-3]=i>>>16&255,this.buffer[s-2]=i>>>8&255,this.buffer[s-1]=i>>>0&255,n(this.temp,this.state,this.buffer,0,s),this.finished=!0}for(a=0;a<8;a++)t[4*a+0]=this.state[a]>>>24&255,t[4*a+1]=this.state[a]>>>16&255,t[4*a+2]=this.state[a]>>>8&255,t[4*a+3]=this.state[a]>>>0&255;return this},e.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},e.prototype._saveState=function(t){for(var e=0;e<this.state.length;e++)t[e]=this.state[e]},e.prototype._restoreState=function(t,e){for(var n=0;n<this.state.length;n++)this.state[n]=t[n];this.bytesHashed=e,this.finished=!1,this.bufferLength=0},e}();t.Hash=o;var r=function(){function t(t){this.inner=new o,this.outer=new o,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var e=new Uint8Array(this.blockSize);if(t.length>this.blockSize)(new o).update(t).finish(e).clean();else for(var n=0;n<t.length;n++)e[n]=t[n];for(n=0;n<e.length;n++)e[n]^=54;for(this.inner.update(e),n=0;n<e.length;n++)e[n]^=106;for(this.outer.update(e),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate),n=0;n<e.length;n++)e[n]=0}return t.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},t.prototype.clean=function(){for(var t=0;t<this.istate.length;t++)this.ostate[t]=this.istate[t]=0;this.inner.clean(),this.outer.clean()},t.prototype.update=function(t){return this.inner.update(t),this},t.prototype.finish=function(t){return this.outer.finished?this.outer.finish(t):(this.inner.finish(t),this.outer.update(t,this.digestLength).finish(t)),this},t.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},t}();function i(t){var e=(new o).update(t),n=e.digest();return e.clean(),n}function s(t,e){var n=new r(t).update(e),o=n.digest();return n.clean(),o}function a(t,e,n,o){var r=o[0];if(0===r)throw new Error("hkdf: cannot expand more");e.reset(),r>1&&e.update(t),n&&e.update(n),e.update(o),e.finish(t),o[0]++}t.HMAC=r,t.hash=i,t.default=i,t.hmac=s;var l=new Uint8Array(t.digestLength);t.hkdf=function(t,e,n,o){void 0===e&&(e=l),void 0===o&&(o=32);for(var i=new Uint8Array([1]),u=s(e,t),c=new r(u),f=new Uint8Array(c.digestLength),d=f.length,h=new Uint8Array(o),m=0;m<o;m++)d===f.length&&(a(f,c,n,i),d=0),h[m]=f[d++];return c.clean(),f.fill(0),i.fill(0),h},t.pbkdf2=function(t,e,n,o){for(var i=new r(t),s=i.digestLength,a=new Uint8Array(4),l=new Uint8Array(s),u=new Uint8Array(s),c=new Uint8Array(o),f=0;f*s<o;f++){var d=f+1;a[0]=d>>>24&255,a[1]=d>>>16&255,a[2]=d>>>8&255,a[3]=d>>>0&255,i.reset(),i.update(e),i.update(a),i.finish(u);for(var h=0;h<s;h++)l[h]=u[h];for(h=2;h<=n;h++){i.reset(),i.update(u).finish(u);for(var m=0;m<s;m++)l[m]^=u[m]}for(h=0;h<s&&f*s+h<o;h++)c[f*s+h]=l[h]}for(f=0;f<s;f++)l[f]=u[f]=0;for(f=0;f<4;f++)a[f]=0;return i.clean(),c}}(e);var r=e.default;for(var i in e)r[i]=e[i];"object"==typeof t.exports?t.exports=r:void 0===(o=function(){return r}.call(e,n,e,t))||(t.exports=o)}()},944(t,e){"use strict";e.Vb=void 0,e.Vb=function(t,e,n){var o=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 o=0,r=t.length,i=e.length,s=Math.floor(Math.max(r,i)/2)-1,a=new Array(r),l=new Array(i),u=0;u<r;u++)for(var c=Math.max(0,u-s);c<=Math.min(i,u+s+1);c++)if(!a[u]&&!l[c]&&t[u]===e[c]){++o,a[u]=l[c]=!0;break}if(0===o)return 0;var f=0,d=0;for(u=0;u<r;u++)if(a[u]){for(;!l[d];)d++;t.charAt(u)!==e.charAt(d++)&&f++}return(o/r+o/i+(o-(f/=2))/o)/3}(t,e,n),r=0;if(o>.7){for(var i=Math.min(t.length,e.length),s=0;t[s]===e[s]&&s<4&&s<i;)++r,s++;o+=.1*r*(1-o)}return o}},6572(t){var e;t.exports=(e=function(t,e){var n=Array.prototype.concat,o=Array.prototype.slice,r=Object.prototype.toString;function i(e,n){var o=e>n?e:n;return t.pow(10,17-~~(t.log(o>0?o:-o)*t.LOG10E))}var s=Array.isArray||function(t){return"[object Array]"===r.call(t)};function a(t){return"[object Function]"===r.call(t)}function l(t){return"number"==typeof t&&t-t===0}function u(){return new u._init(arguments)}function c(){return 0}function f(){return 1}function d(t,e){return t===e?1:0}u.fn=u.prototype,u._init=function(t){if(s(t[0]))if(s(t[0][0])){a(t[1])&&(t[0]=u.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]=a(t[1])?u.map(t[0],t[1]):t[0],this.length=1;else if(l(t[0]))this[0]=u.seq.apply(null,t),this.length=1;else{if(t[0]instanceof u)return u(t[0].toArray());this[0]=[],this.length=1}return this},u._init.prototype=u.prototype,u._init.constructor=u,u.utils={calcRdx:i,isArray:s,isFunction:a,isNumber:l,toVector:function(t){return n.apply([],t)}},u._random_fn=t.random,u.setRandom=function(t){if("function"!=typeof t)throw new TypeError("fn is not a function");u._random_fn=t},u.extend=function(t){var e,n;if(1===arguments.length){for(n in t)u[n]=t[n];return this}for(e=1;e<arguments.length;e++)for(n in arguments[e])t[n]=arguments[e][n];return t},u.rows=function(t){return t.length||1},u.cols=function(t){return t[0].length||1},u.dimensions=function(t){return{rows:u.rows(t),cols:u.cols(t)}},u.row=function(t,e){return s(e)?e.map(function(e){return u.row(t,e)}):t[e]},u.rowa=function(t,e){return u.row(t,e)},u.col=function(t,e){if(s(e)){var n=u.arange(t.length).map(function(){return new Array(e.length)});return e.forEach(function(e,o){u.arange(t.length).forEach(function(r){n[r][o]=t[r][e]})}),n}for(var o=new Array(t.length),r=0;r<t.length;r++)o[r]=[t[r][e]];return o},u.cola=function(t,e){return u.col(t,e).map(function(t){return t[0]})},u.diag=function(t){for(var e=u.rows(t),n=new Array(e),o=0;o<e;o++)n[o]=[t[o][o]];return n},u.antidiag=function(t){for(var e=u.rows(t)-1,n=new Array(e),o=0;e>=0;e--,o++)n[o]=[t[o][e]];return n},u.transpose=function(t){var e,n,o,r,i,a=[];for(s(t[0])||(t=[t]),n=t.length,o=t[0].length,i=0;i<o;i++){for(e=new Array(n),r=0;r<n;r++)e[r]=t[r][i];a.push(e)}return 1===a.length?a[0]:a},u.map=function(t,e,n){var o,r,i,a,l;for(s(t[0])||(t=[t]),r=t.length,i=t[0].length,a=n?t:new Array(r),o=0;o<r;o++)for(a[o]||(a[o]=new Array(i)),l=0;l<i;l++)a[o][l]=e(t[o][l],o,l);return 1===a.length?a[0]:a},u.cumreduce=function(t,e,n){var o,r,i,a,l;for(s(t[0])||(t=[t]),r=t.length,i=t[0].length,a=n?t:new Array(r),o=0;o<r;o++)for(a[o]||(a[o]=new Array(i)),i>0&&(a[o][0]=t[o][0]),l=1;l<i;l++)a[o][l]=e(a[o][l-1],t[o][l]);return 1===a.length?a[0]:a},u.alter=function(t,e){return u.map(t,e,!0)},u.create=function(t,e,n){var o,r,i=new Array(t);for(a(e)&&(n=e,e=t),o=0;o<t;o++)for(i[o]=new Array(e),r=0;r<e;r++)i[o][r]=n(o,r);return i},u.zeros=function(t,e){return l(e)||(e=t),u.create(t,e,c)},u.ones=function(t,e){return l(e)||(e=t),u.create(t,e,f)},u.rand=function(t,e){return l(e)||(e=t),u.create(t,e,u._random_fn)},u.identity=function(t,e){return l(e)||(e=t),u.create(t,e,d)},u.symmetric=function(t){var e,n,o=t.length;if(t.length!==t[0].length)return!1;for(e=0;e<o;e++)for(n=0;n<o;n++)if(t[n][e]!==t[e][n])return!1;return!0},u.clear=function(t){return u.alter(t,c)},u.seq=function(t,e,n,o){a(o)||(o=!1);var r,s=[],l=i(t,e),u=(e*l-t*l)/((n-1)*l),c=t;for(r=0;c<=e&&r<n;c=(t*l+u*l*++r)/l)s.push(o?o(c,r):c);return s},u.arange=function(t,n,o){var r,i=[];if(o=o||1,n===e&&(n=t,t=0),t===n||0===o)return[];if(t<n&&o<0)return[];if(t>n&&o>0)return[];if(o>0)for(r=t;r<n;r+=o)i.push(r);else for(r=t;r>n;r+=o)i.push(r);return i},u.slice=function(){function t(t,n,o,r){var i,s=[],a=t.length;if(n===e&&o===e&&r===e)return u.copy(t);if(r=r||1,(n=(n=n||0)>=0?n:a+n)===(o=(o=o||t.length)>=0?o:a+o)||0===r)return[];if(n<o&&r<0)return[];if(n>o&&r>0)return[];if(r>0)for(i=n;i<o;i+=r)s.push(t[i]);else for(i=n;i>o;i+=r)s.push(t[i]);return s}return function(e,n){var o,r;return l((n=n||{}).row)?l(n.col)?e[n.row][n.col]:t(u.rowa(e,n.row),(o=n.col||{}).start,o.end,o.step):l(n.col)?t(u.cola(e,n.col),(r=n.row||{}).start,r.end,r.step):(r=n.row||{},o=n.col||{},t(e,r.start,r.end,r.step).map(function(e){return t(e,o.start,o.end,o.step)}))}}(),u.sliceAssign=function(n,o,r){var i,s;if(l(o.row)){if(l(o.col))return n[o.row][o.col]=r;o.col=o.col||{},o.col.start=o.col.start||0,o.col.end=o.col.end||n[0].length,o.col.step=o.col.step||1,i=u.arange(o.col.start,t.min(n.length,o.col.end),o.col.step);var a=o.row;return i.forEach(function(t,e){n[a][t]=r[e]}),n}if(l(o.col)){o.row=o.row||{},o.row.start=o.row.start||0,o.row.end=o.row.end||n.length,o.row.step=o.row.step||1,s=u.arange(o.row.start,t.min(n[0].length,o.row.end),o.row.step);var c=o.col;return s.forEach(function(t,e){n[t][c]=r[e]}),n}return r[0].length===e&&(r=[r]),o.row.start=o.row.start||0,o.row.end=o.row.end||n.length,o.row.step=o.row.step||1,o.col.start=o.col.start||0,o.col.end=o.col.end||n[0].length,o.col.step=o.col.step||1,s=u.arange(o.row.start,t.min(n.length,o.row.end),o.row.step),i=u.arange(o.col.start,t.min(n[0].length,o.col.end),o.col.step),s.forEach(function(t,e){i.forEach(function(o,i){n[t][o]=r[e][i]})}),n},u.diagonal=function(t){var e=u.zeros(t.length,t.length);return t.forEach(function(t,n){e[n][n]=t}),e},u.copy=function(t){return t.map(function(t){return l(t)?t:t.map(function(t){return t})})};var h=u.prototype;return h.length=0,h.push=Array.prototype.push,h.sort=Array.prototype.sort,h.splice=Array.prototype.splice,h.slice=Array.prototype.slice,h.toArray=function(){return this.length>1?o.call(this):o.call(this)[0]},h.map=function(t,e){return u(u.map(this,t,e))},h.cumreduce=function(t,e){return u(u.cumreduce(this,t,e))},h.alter=function(t){return u.alter(this,t),this},function(t){for(var e=0;e<t.length;e++)(function(t){h[t]=function(e){var n,o=this;return e?(setTimeout(function(){e.call(o,h[t].call(o))}),this):(n=u[t](this),s(n)?u(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){h[t]=function(e,n){var o=this;return n?(setTimeout(function(){n.call(o,h[t].call(o,e))}),this):u(u[t](this,e))}})(t[e])}("row col".split(" ")),function(t){for(var e=0;e<t.length;e++)(function(t){h[t]=function(){return u(u[t].apply(null,arguments))}})(t[e])}("create zeros ones rand identity".split(" ")),u}(Math),function(t,e){var n=t.utils.isFunction;function o(t,e){return t-e}function r(t,n,o){return e.max(n,e.min(t,o))}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,o=t.mean(e),r=0,i=e.length;--i>=0;)r+=(n=e[i]-o)*n;return r},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=[],o=0;o<t.length;o++)e[t[o]]||(e[t[o]]=!0,n.push(t[o]));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 o=n.map(e.log),r=t.mean(o);return e.exp(r)},t.median=function(t){var e=t.length,n=t.slice().sort(o);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=[],o=t.length;for(e=1;e<o;e++)n.push(t[e]-t[e-1]);return n},t.rank=function(t){var e,n=[],r={};for(e=0;e<t.length;e++)r[l=t[e]]?r[l]++:(r[l]=1,n.push(l));var i=n.sort(o),s={},a=1;for(e=0;e<i.length;e++){var l,u=r[l=i[e]],c=(a+(a+u-1))/2;s[l]=c,a+=u}return t.map(function(t){return s[t]})},t.mode=function(t){var e,n=t.length,r=t.slice().sort(o),i=1,s=0,a=0,l=[];for(e=0;e<n;e++)r[e]===r[e+1]?i++:(i>s?(l=[r[e]],s=i,a=0):i===s&&(l.push(r[e]),a++),i=1);return 0===a?l[0]:l},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),o=e.length,r=new Array(o),i=0;i<o;i++)r[i]=e[i]-n;return r},t.stdev=function(n,o){return e.sqrt(t.variance(n,o))},t.pooledstdev=function(n){return e.sqrt(t.pooledvariance(n))},t.meandev=function(n){for(var o=t.mean(n),r=[],i=n.length-1;i>=0;i--)r.push(e.abs(n[i]-o));return t.mean(r)},t.meddev=function(n){for(var o=t.median(n),r=[],i=n.length-1;i>=0;i--)r.push(e.abs(n[i]-o));return t.median(r)},t.coeffvar=function(e){return t.stdev(e)/t.mean(e)},t.quartiles=function(t){var n=t.length,r=t.slice().sort(o);return[r[e.round(n/4)-1],r[e.round(n/2)-1],r[e.round(3*n/4)-1]]},t.quantiles=function(t,n,i,s){var a,l,u,c,f,d=t.slice().sort(o),h=[n.length],m=t.length;for(void 0===i&&(i=3/8),void 0===s&&(s=3/8),a=0;a<n.length;a++)u=m*(l=n[a])+(i+l*(1-i-s)),c=e.floor(r(u,1,m-1)),f=r(u-c,0,1),h[a]=(1-f)*d[c-1]+f*d[c];return h},t.percentile=function(t,e,n){var r=t.slice().sort(o),i=e*(r.length+(n?1:-1))+(n?0:1),s=parseInt(i),a=i-s;return s+1<r.length?r[s-1]+a*(r[s]-r[s-1]):r[s-1]},t.percentileOfScore=function(t,e,n){var o,r,i=0,s=t.length,a=!1;for("strict"===n&&(a=!0),r=0;r<s;r++)o=t[r],(a&&o<e||!a&&o<=e)&&i++;return i/s},t.histogram=function(n,o){o=o||4;var r,i=t.min(n),s=(t.max(n)-i)/o,a=n.length,l=[];for(r=0;r<o;r++)l[r]=0;for(r=0;r<a;r++)l[e.min(e.floor((n[r]-i)/s),o-1)]+=1;return l},t.covariance=function(e,n){var o,r=t.mean(e),i=t.mean(n),s=e.length,a=new Array(s);for(o=0;o<s;o++)a[o]=(e[o]-r)*(n[o]-i);return t.sum(a)/(s-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,o){for(var r=t.mean(n),i=t.stdev(n),s=n.length,a=0,l=0;l<s;l++)a+=e.pow((n[l]-r)/i,o);return a/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 o=0;o<e.length;o++)(function(e){i[e]=function(o,r){var s=[],a=0,l=this;if(n(o)&&(r=o,o=!1),r)return setTimeout(function(){r.call(l,i[e].call(l,o))}),this;if(this.length>1){for(l=!0===o?this:this.transpose();a<l.length;a++)s[a]=t[e](l[a]);return s}return t[e](this[0],o)}})(e[o])}("cumsum cumprod".split(" ")),function(e){for(var o=0;o<e.length;o++)(function(e){i[e]=function(o,r){var s=[],a=0,l=this;if(n(o)&&(r=o,o=!1),r)return setTimeout(function(){r.call(l,i[e].call(l,o))}),this;if(this.length>1){for("sumrow"!==e&&(l=!0===o?this:this.transpose());a<l.length;a++)s[a]=t[e](l[a]);return!0===o?t[e](t.utils.toVector(s)):s}return t[e](this[0],o)}})(e[o])}("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 o=0;o<e.length;o++)(function(e){i[e]=function(){var o,r=[],s=0,a=this,l=Array.prototype.slice.call(arguments);if(n(l[l.length-1])){o=l[l.length-1];var u=l.slice(0,l.length-1);return setTimeout(function(){o.call(a,i[e].apply(a,u))}),this}o=void 0;var c=function(n){return t[e].apply(a,[n].concat(l))};if(this.length>1){for(a=a.transpose();s<a.length;s++)r[s]=c(a[s]);return r}return c(this[0])}})(e[o])}("quantiles percentileOfScore".split(" "))}(e,Math),function(t,e){t.gammaln=function(t){var n,o,r,i=0,s=[76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18],a=1.000000000190015;for(r=(o=n=t)+5.5,r-=(n+.5)*e.log(r);i<6;i++)a+=s[i]/++o;return e.log(2.5066282746310007*a/n)-r},t.loggam=function(t){var n,o,r,i,s,a,l,u=[.08333333333333333,-.002777777777777778,.0007936507936507937,-.0005952380952380952,.0008417508417508418,-.001917526917526918,.00641025641025641,-.02955065359477124,.1796443723688307,-1.3924322169059];if(n=t,l=0,1==t||2==t)return 0;for(t<=7&&(n=t+(l=e.floor(7-t))),o=1/(n*n),r=2*e.PI,s=u[9],a=8;a>=0;a--)s*=o,s+=u[a];if(i=s/n+.5*e.log(r)+(n-.5)*e.log(n)-n,t<=7)for(a=1;a<=l;a++)i-=e.log(n-1),n-=1;return i},t.gammafn=function(t){var n,o,r,i,s=[-1.716185138865495,24.76565080557592,-379.80425647094563,629.3311553128184,866.9662027904133,-31451.272968848367,-36144.413418691176,66456.14382024054],a=[-30.8402300119739,315.35062697960416,-1015.1563674902192,-3107.771671572311,22538.11842098015,4755.846277527881,-134659.9598649693,-115132.2596755535],l=!1,u=0,c=0,f=0,d=t;if(t>171.6243769536076)return 1/0;if(d<=0){if(!(i=d%1+36e-17))return 1/0;l=(1&d?-1:1)*e.PI/e.sin(e.PI*i),d=1-d}for(r=d,o=d<1?d++:(d-=u=(0|d)-1)-1,n=0;n<8;++n)f=(f+s[n])*o,c=c*o+a[n];if(i=f/c+1,r<d)i/=r;else if(r>d)for(n=0;n<u;++n)i*=d,d++;return l&&(i=l/i),i},t.gammap=function(e,n){return t.lowRegGamma(e,n)*t.gammafn(e)},t.lowRegGamma=function(n,o){var r,i=t.gammaln(n),s=n,a=1/n,l=a,u=o+1-n,c=1/1e-30,f=1/u,d=f,h=1,m=-~(8.5*e.log(n>=1?n:1/n)+.4*n+17);if(o<0||n<=0)return NaN;if(o<n+1){for(;h<=m;h++)a+=l*=o/++s;return a*e.exp(-o+n*e.log(o)-i)}for(;h<=m;h++)d*=(f=1/(f=(r=-h*(h-n))*f+(u+=2)))*(c=u+r/c);return 1-d*e.exp(-o+n*e.log(o)-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,o){return n>170||o>170?e.exp(t.combinationln(n,o)):t.factorial(n)/t.factorial(o)/t.factorial(n-o)},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,o){if(!(n<=0||o<=0))return n+o>170?e.exp(t.betaln(n,o)):t.gammafn(n)*t.gammafn(o)/t.gammafn(n+o)},t.betaln=function(e,n){return t.gammaln(e)+t.gammaln(n)-t.gammaln(e+n)},t.betacf=function(t,n,o){var r,i,s,a,l=1e-30,u=1,c=n+o,f=n+1,d=n-1,h=1,m=1-c*t/f;for(e.abs(m)<l&&(m=l),a=m=1/m;u<=100&&(m=1+(i=u*(o-u)*t/((d+(r=2*u))*(n+r)))*m,e.abs(m)<l&&(m=l),h=1+i/h,e.abs(h)<l&&(h=l),a*=(m=1/m)*h,m=1+(i=-(n+u)*(c+u)*t/((n+r)*(f+r)))*m,e.abs(m)<l&&(m=l),h=1+i/h,e.abs(h)<l&&(h=l),a*=s=(m=1/m)*h,!(e.abs(s-1)<3e-7));u++);return a},t.gammapinv=function(n,o){var r,i,s,a,l,u,c=0,f=o-1,d=t.gammaln(o);if(n>=1)return e.max(100,o+100*e.sqrt(o));if(n<=0)return 0;for(o>1?(l=e.log(f),u=e.exp(f*(l-1)-d),a=n<.5?n:1-n,r=(2.30753+.27061*(i=e.sqrt(-2*e.log(a))))/(1+i*(.99229+.04481*i))-i,n<.5&&(r=-r),r=e.max(.001,o*e.pow(1-1/(9*o)-r/(3*e.sqrt(o)),3))):r=n<(i=1-o*(.253+.12*o))?e.pow(n/i,1/o):1-e.log(1-(n-i)/(1-i));c<12;c++){if(r<=0)return 0;if((r-=i=(s=(t.lowRegGamma(o,r)-n)/(i=o>1?u*e.exp(-(r-f)+f*(e.log(r)-l)):e.exp(-r+f*e.log(r)-d)))/(1-.5*e.min(1,s*((o-1)/r-1))))<=0&&(r=.5*(r+i)),e.abs(i)<1e-8*r)break}return r},t.erf=function(t){var n,o,r,i,s=[-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],a=s.length-1,l=!1,u=0,c=0;for(t<0&&(t=-t,l=!0),o=4*(n=2/(2+t))-2;a>0;a--)r=u,u=o*u-c+s[a],c=r;return i=n*e.exp(-t*t+.5*(s[0]+o*u)-c),l?i-1:1-i},t.erfc=function(e){return 1-t.erf(e)},t.erfcinv=function(n){var o,r,i,s,a=0;if(n>=2)return-100;if(n<=0)return 100;for(s=n<1?n:2-n,o=-.70711*((2.30753+.27061*(i=e.sqrt(-2*e.log(s/2))))/(1+i*(.99229+.04481*i))-i);a<2;a++)o+=(r=t.erfc(o)-s)/(1.1283791670955126*e.exp(-o*o)-o*r);return n<1?o:-o},t.ibetainv=function(n,o,r){var i,s,a,l,u,c,f,d,h,m,p=o-1,g=r-1,v=0;if(n<=0)return 0;if(n>=1)return 1;for(o>=1&&r>=1?(a=n<.5?n:1-n,c=(2.30753+.27061*(l=e.sqrt(-2*e.log(a))))/(1+l*(.99229+.04481*l))-l,n<.5&&(c=-c),f=(c*c-3)/6,d=2/(1/(2*o-1)+1/(2*r-1)),h=c*e.sqrt(f+d)/d-(1/(2*r-1)-1/(2*o-1))*(f+5/6-2/(3*d)),c=o/(o+r*e.exp(2*h))):(i=e.log(o/(o+r)),s=e.log(r/(o+r)),c=n<(l=e.exp(o*i)/o)/(h=l+(u=e.exp(r*s)/r))?e.pow(o*h*n,1/o):1-e.pow(r*h*(1-n),1/r)),m=-t.gammaln(o)-t.gammaln(r)+t.gammaln(o+r);v<10;v++){if(0===c||1===c)return c;if((c-=l=(u=(t.ibeta(c,o,r)-n)/(l=e.exp(p*e.log(c)+g*e.log(1-c)+m)))/(1-.5*e.min(1,u*(p/c-g/(1-c)))))<=0&&(c=.5*(c+l)),c>=1&&(c=.5*(c+l+1)),e.abs(l)<1e-8*c&&v>0)break}return c},t.ibeta=function(n,o,r){var i=0===n||1===n?0:e.exp(t.gammaln(o+r)-t.gammaln(o)-t.gammaln(r)+o*e.log(n)+r*e.log(1-n));return!(n<0||n>1)&&(n<(o+1)/(o+r+2)?i*t.betacf(n,o,r)/o:1-i*t.betacf(1-n,r,o)/r)},t.randn=function(n,o){var r,i,s,a,l;if(o||(o=n),n)return t.create(n,o,function(){return t.randn()});do{r=t._random_fn(),i=1.7156*(t._random_fn()-.5),l=(s=r-.449871)*s+(a=e.abs(i)+.386595)*(.196*a-.25472*s)}while(l>.27597&&(l>.27846||i*i>-4*e.log(r)*r*r));return i/r},t.randg=function(n,o,r){var i,s,a,l,u,c,f=n;if(r||(r=o),n||(n=1),o)return(c=t.zeros(o,r)).alter(function(){return t.randg(n)}),c;n<1&&(n+=1),i=n-1/3,s=1/e.sqrt(9*i);do{do{l=1+s*(u=t.randn())}while(l<=0);l*=l*l,a=t._random_fn()}while(a>1-.331*e.pow(u,4)&&e.log(a)>.5*u*u+i*(1-l+e.log(l)));if(n==f)return i*l;do{a=t._random_fn()}while(0===a);return e.pow(a,1/f)*i*l},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,o,r){for(var i,s=0,a=1,l=1,u=1,c=0,f=0;e.abs((l-f)/l)>r;)f=l,a=u+(i=-(n+c)*(n+o+c)*t/(n+2*c)/(n+2*c+1))*a,l=(s=l+i*s)+(i=(c+=1)*(o-c)*t/(n+2*c-1)/(n+2*c))*l,s/=u=a+i*u,a/=u,l/=u,u=1;return l/n}function o(n,o,r){var i=[.9815606342467192,.9041172563704749,.7699026741943047,.5873179542866175,.3678314989981802,.1252334085114689],s=[.04717533638651183,.10693932599531843,.16007832854334622,.20316742672306592,.2334925365383548,.24914704581340277],a=.5*n;if(a>=8)return 1;var l,u=2*t.normal.cdf(a,0,1,1,0)-1;u=u>=e.exp(-50/r)?e.pow(u,r):0;for(var c=a,f=(8-a)/(l=n>3?2:3),d=c+f,h=0,m=r-1,p=1;p<=l;p++){for(var g=0,v=.5*(d+c),y=.5*(d-c),A=1;A<=12;A++){var w,C=v+y*(6<A?i[(w=12-A+1)-1]:-i[(w=A)-1]),E=C*C;if(E>60)break;var b=2*t.normal.cdf(C,0,1,1,0)*.5-2*t.normal.cdf(C,n,1,1,0)*.5;b>=e.exp(-30/m)&&(g+=b=s[w-1]*e.exp(-.5*E)*e.pow(b,m))}h+=g*=2*y*r/e.sqrt(2*e.PI),c=d,d+=f}return(u+=h)<=e.exp(-30/o)?0:(u=e.pow(u,o))>=1?1:u}!function(e){for(var n=0;n<e.length;n++)(function(e){t[e]=function t(e,n,o){return this instanceof t?(this._a=e,this._b=n,this._c=o,this):new t(e,n,o)},t.fn[e]=function(n,o,r){var i=t[e](n,o,r);return i.data=this,i},t[e].prototype.sample=function(n){var o=this._a,r=this._b,i=this._c;return n?t.alter(n,function(){return t[e].sample(o,r,i)}):t[e].sample(o,r,i)},function(n){for(var o=0;o<n.length;o++)(function(n){t[e].prototype[n]=function(o){var r=this._a,i=this._b,s=this._c;return o||0===o||(o=this.data),"number"!=typeof o?t.fn.map.call(o,function(o){return t[e][n](o,r,i,s)}):t[e][n](o,r,i,s)}})(n[o])}("pdf cdf inv".split(" ")),function(n){for(var o=0;o<n.length;o++)(function(n){t[e].prototype[n]=function(){return t[e][n](this._a,this._b,this._c)}})(n[o])}("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,o,r){return n>1||n<0?0:1==o&&1==r?1:o<512&&r<512?e.pow(n,o-1)*e.pow(1-n,r-1)/t.betafn(o,r):e.exp((o-1)*e.log(n)+(r-1)*e.log(1-n)-t.betaln(o,r))},cdf:function(e,n,o){return e>1||e<0?1*(e>1):t.ibeta(e,n,o)},inv:function(e,n,o){return t.ibetainv(e,n,o)},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 o=t.randg(e);return o/(o+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,o,r){var i;return n<0?0:o<=2?0===n&&o<2?1/0:0===n&&2===o?1:1/t.betafn(o/2,r/2)*e.pow(o/r,o/2)*e.pow(n,o/2-1)*e.pow(1+o/r*n,-(o+r)/2):(i=o*n/(r+n*o),o*(r/(r+n*o))/2*t.binomial.pdf((o-2)/2,(o+r-2)/2,i))},cdf:function(e,n,o){return e<0?0:t.ibeta(n*e/(n*e+o),n/2,o/2)},inv:function(e,n,o){return o/(n*(1/t.ibetainv(e,n/2,o/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,o){return o<0?0:o/(e.pow(t-n,2)+e.pow(o,2))/e.PI},cdf:function(t,n,o){return e.atan((t-n)/o)/e.PI+.5},inv:function(t,n,o){return n+o*e.tan(e.PI*(t-.5))},median:function(t){return t},mode:function(t){return t},sample:function(n,o){return t.randn()*e.sqrt(1/(2*t.randg(.5)))*o+n}}),t.extend(t.chisquare,{pdf:function(n,o){return n<0?0:0===n&&2===o?.5:e.exp((o/2-1)*e.log(n)-n/2-o/2*e.log(2)-t.gammaln(o/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,o,r){return n<0?0:0===n&&1===o?1/r:e.exp((o-1)*e.log(n)-n/r-t.gammaln(o)-o*e.log(r))},cdf:function(e,n,o){return e<0?0:t.lowRegGamma(n,e/o)},inv:function(e,n,o){return t.gammapinv(e,n)*o},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,o,r){return n<=0?0:e.exp(-(o+1)*e.log(n)-r/n-t.gammaln(o)+o*e.log(r))},cdf:function(e,n,o){return e<=0?0:1-t.lowRegGamma(n,o/e)},inv:function(e,n,o){return o/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,o){return 0===t&&1===n?o:1===t&&1===o?n:e.exp(e.log(n)+e.log(o)+(n-1)*e.log(t)+(o-1)*e.log(1-e.pow(t,n)))},cdf:function(t,n,o){return t<0?0:t>1?1:1-e.pow(1-e.pow(t,n),o)},inv:function(t,n,o){return e.pow(1-e.pow(1-t,1/o),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,o){return t<=0?0:e.exp(-e.log(t)-.5*e.log(2*e.PI)-e.log(o)-e.pow(e.log(t)-n,2)/(2*o*o))},cdf:function(n,o,r){return n<0?0:.5+.5*t.erf((e.log(n)-o)/e.sqrt(2*r*r))},inv:function(n,o,r){return e.exp(-1.4142135623730951*r*t.erfcinv(2*n)+o)},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,o){return e.exp(t.randn()*o+n)},variance:function(t,n){return(e.exp(n*n)-1)*e.exp(2*t+n*n)}}),t.extend(t.noncentralt,{pdf:function(n,o,r){return e.abs(r)<1e-14?t.studentt.pdf(n,o):e.abs(n)<1e-14?e.exp(t.gammaln((o+1)/2)-r*r/2-.5*e.log(e.PI*o)-t.gammaln(o/2)):o/n*(t.noncentralt.cdf(n*e.sqrt(1+2/o),o+2,r)-t.noncentralt.cdf(n,o,r))},cdf:function(n,o,r){var i=1e-14;if(e.abs(r)<i)return t.studentt.cdf(n,o);var s=!1;n<0&&(s=!0,r=-r);for(var a=t.normal.cdf(-r,0,1),l=i+1,u=l,c=n*n/(n*n+o),f=0,d=e.exp(-r*r/2),h=e.exp(-r*r/2-.5*e.log(2)-t.gammaln(1.5))*r;f<200||u>i||l>i;)u=l,f>0&&(d*=r*r/(2*f),h*=r*r/(2*(f+.5))),a+=.5*(l=d*t.beta.cdf(c,f+.5,o/2)+h*t.beta.cdf(c,f+1,o/2)),f++;return s?1-a:a}}),t.extend(t.normal,{pdf:function(t,n,o){return e.exp(-.5*e.log(2*e.PI)-e.log(o)-e.pow(t-n,2)/(2*o*o))},cdf:function(n,o,r){return.5*(1+t.erf((n-o)/e.sqrt(2*r*r)))},inv:function(e,n,o){return-1.4142135623730951*o*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,o){return t<n?0:o*e.pow(n,o)/e.pow(t,o+1)},cdf:function(t,n,o){return t<n?0:1-e.pow(n/t,o)},inv:function(t,n,o){return n/e.pow(1-t,1/o)},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,o){return o=o>1e100?1e100:o,1/(e.sqrt(o)*t.betafn(.5,o/2))*e.pow(1+n*n/o,-(o+1)/2)},cdf:function(n,o){var r=o/2;return t.ibeta((n+e.sqrt(n*n+o))/(2*e.sqrt(n*n+o)),r,r)},inv:function(n,o){var r=t.ibetainv(2*e.min(n,1-n),.5*o,.5);return r=e.sqrt(o*(1-r)/r),n>.5?r:-r},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,o){return t<0||n<0||o<0?0:o/n*e.pow(t/n,o-1)*e.exp(-e.pow(t/n,o))},cdf:function(t,n,o){return t<0?0:1-e.exp(-e.pow(t/n,o))},inv:function(t,n,o){return n*e.pow(-e.log(1-t),1/o)},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,o){return n*e.pow(-e.log(t._random_fn()),1/o)},variance:function(n,o){return n*n*t.gammafn(1+2/o)-e.pow(t.weibull.mean(n,o),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,o,r){return 0===r||1===r?o*r===n?1:0:t.combination(o,n)*e.pow(r,n)*e.pow(1-r,o-n)},cdf:function(o,r,i){var s,a=1e-10;if(o<0)return 0;if(o>=r)return 1;if(i<0||i>1||r<=0)return NaN;var l=i,u=(o=e.floor(o))+1,c=r-o,f=u+c,d=e.exp(t.gammaln(f)-t.gammaln(c)-t.gammaln(u)+u*e.log(l)+c*e.log(1-l));return s=l<(u+1)/(f+2)?d*n(l,u,c,a):1-d*n(1-l,c,u,a),e.round(1/a*(1-s))/(1/a)}}),t.extend(t.negbin,{pdf:function(n,o,r){return n===n>>>0&&(n<0?0:t.combination(n+o-1,o-1)*e.pow(1-r,n)*e.pow(r,o))},cdf:function(e,n,o){var r=0,i=0;if(e<0)return 0;for(;i<=e;i++)r+=t.negbin.pdf(i,n,o);return r}}),t.extend(t.hypgeom,{pdf:function(n,o,r,i){if(n!=n|0)return!1;if(n<0||n<r-(o-i))return 0;if(n>i||n>r)return 0;if(2*r>o)return 2*i>o?t.hypgeom.pdf(o-r-i+n,o,o-r,o-i):t.hypgeom.pdf(i-n,o,o-r,i);if(2*i>o)return t.hypgeom.pdf(r-n,o,r,o-i);if(r<i)return t.hypgeom.pdf(n,o,i,r);for(var s=1,a=0,l=0;l<n;l++){for(;s>1&&a<i;)s*=1-r/(o-a),a++;s*=(i-l)*(r-l)/((l+1)*(o-r-i+l+1))}for(;a<i;a++)s*=1-r/(o-a);return e.min(1,e.max(0,s))},cdf:function(n,o,r,i){if(n<0||n<r-(o-i))return 0;if(n>=i||n>=r)return 1;if(2*r>o)return 2*i>o?t.hypgeom.cdf(o-r-i+n,o,o-r,o-i):1-t.hypgeom.cdf(i-n-1,o,o-r,i);if(2*i>o)return 1-t.hypgeom.cdf(r-n-1,o,r,o-i);if(r<i)return t.hypgeom.cdf(n,o,i,r);for(var s=1,a=1,l=0,u=0;u<n;u++){for(;s>1&&l<i;){var c=1-r/(o-l);a*=c,s*=c,l++}s+=a*=(i-u)*(r-u)/((u+1)*(o-r-i+u+1))}for(;l<i;l++)s*=1-r/(o-l);return e.min(1,e.max(0,s))}}),t.extend(t.poisson,{pdf:function(n,o){return o<0||n%1!=0||n<0?0:e.pow(o,n)*e.exp(-o)/t.factorial(n)},cdf:function(e,n){var o=[],r=0;if(e<0)return 0;for(;r<=e;r++)o.push(t.poisson.pdf(r,n));return t.sum(o)},mean:function(t){return t},variance:function(t){return t},sampleSmall:function(n){var o=1,r=0,i=e.exp(-n);do{r++,o*=t._random_fn()}while(o>i);return r-1},sampleLarge:function(n){var o,r,i,s,a,l,u,c,f,d,h=n;for(s=e.sqrt(h),a=e.log(h),l=.02483*(u=.931+2.53*s)-.059,c=1.1239+1.1328/(u-3.4),f=.9277-3.6224/(u-2);;){if(r=e.random()-.5,i=e.random(),d=.5-e.abs(r),o=e.floor((2*l/d+u)*r+h+.43),d>=.07&&i<=f)return o;if(!(o<0||d<.013&&i>d)&&e.log(i)+e.log(c)-e.log(l/(d*d)+u)<=o*a-h-t.loggam(o+1))return o}},sample:function(t){return t<10?this.sampleSmall(t):this.sampleLarge(t)}}),t.extend(t.triangular,{pdf:function(t,e,n,o){return n<=e||o<e||o>n?NaN:t<e||t>n?0:t<o?2*(t-e)/((n-e)*(o-e)):t===o?2/(n-e):2*(n-t)/((n-e)*(n-o))},cdf:function(t,n,o,r){return o<=n||r<n||r>o?NaN:t<=n?0:t>=o?1:t<=r?e.pow(t-n,2)/((o-n)*(r-n)):1-e.pow(o-t,2)/((o-n)*(o-r))},inv:function(t,n,o,r){return o<=n||r<n||r>o?NaN:t<=(r-n)/(o-n)?n+(o-n)*e.sqrt(t*((r-n)/(o-n))):n+(o-n)*(1-e.sqrt((1-t)*(1-(r-n)/(o-n))))},mean:function(t,e,n){return(t+e+n)/3},median:function(t,n,o){return o<=(t+n)/2?n-e.sqrt((n-t)*(n-o))/e.sqrt(2):o>(t+n)/2?t+e.sqrt((n-t)*(o-t))/e.sqrt(2):void 0},mode:function(t,e,n){return n},sample:function(n,o,r){var i=t._random_fn();return i<(r-n)/(o-n)?n+e.sqrt(i*(o-n)*(r-n)):o-e.sqrt((1-i)*(o-n)*(o-r))},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,o){return o<=n?NaN:t<=n||t>=o?0:2/e.PI*e.pow(e.pow(o-n,2)-e.pow(2*t-n-o,2),-.5)},cdf:function(t,n,o){return t<n?0:t<o?2/e.PI*e.asin(e.sqrt((t-n)/(o-n))):1},inv:function(t,n,o){return n+(.5-.5*e.cos(e.PI*t))*(o-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,o){return(n+o)/2+(o-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,o){return o<=0?0:e.exp(-e.abs(t-n)/o)/(2*o)},cdf:function(t,n,o){return o<=0?0:t<n?.5*e.exp((t-n)/o):1-.5*e.exp(-(t-n)/o)},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,o){var r,i=t._random_fn()-.5;return n-o*((r=i)/e.abs(r))*e.log(1-2*e.abs(i))}}),t.extend(t.tukey,{cdf:function(n,r,i){var s=r,a=[.9894009349916499,.9445750230732326,.8656312023878318,.755404408355003,.6178762444026438,.45801677765722737,.2816035507792589,.09501250983763744],l=[.027152459411754096,.062253523938647894,.09515851168249279,.12462897125553388,.14959598881657674,.16915651939500254,.18260341504492358,.1894506104550685];if(n<=0)return 0;if(i<2||s<2)return NaN;if(!Number.isFinite(n))return 1;if(i>25e3)return o(n,1,s);var u,c=.5*i,f=c*e.log(i)-i*e.log(2)-t.gammaln(c),d=c-1,h=.25*i;u=i<=100?1:i<=800?.5:i<=5e3?.25:.125,f+=e.log(u);for(var m=0,p=1;p<=50;p++){for(var g=0,v=(2*p-1)*u,y=1;y<=16;y++){var A,w;8<y?(A=y-8-1,w=f+d*e.log(v+a[A]*u)-(a[A]*u+v)*h):(A=y-1,w=f+d*e.log(v-a[A]*u)+(a[A]*u-v)*h),w>=-30&&(g+=o(8<y?n*e.sqrt(.5*(a[A]*u+v)):n*e.sqrt(.5*(-a[A]*u+v)),1,s)*l[A]*e.exp(w))}if(p*u>=1&&g<=1e-14)break;m+=g}if(g>1e-14)throw new Error("tukey.cdf failed to converge");return m>1&&(m=1),m},inv:function(n,o,r){if(r<2||o<2)return NaN;if(n<0||n>1)return NaN;if(0===n)return 0;if(1===n)return 1/0;var i,s=function(t,n,o){var r=.5-.5*t,i=e.sqrt(e.log(1/(r*r))),s=i+((((-453642210148e-16*i-.204231210125)*i-.342242088547)*i-1)*i+.322232421088)/((((.0038560700634*i+.10353775285)*i+.531103462366)*i+.588581570495)*i+.099348462606);o<120&&(s+=(s*s*s+s)/o/4);var a=.8832-.2368*s;return o<120&&(a+=-1.214/o+1.208*s/o),s*(a*e.log(n-1)+1.4142)}(n,o,r),a=t.tukey.cdf(s,o,r)-n;i=a>0?e.max(0,s-1):s+1;for(var l,u=t.tukey.cdf(i,o,r)-n,c=1;c<50;c++)if(l=i-u*(i-s)/(u-a),a=u,s=i,l<0&&(l=0,u=-n),u=t.tukey.cdf(l,o,r)-n,i=l,e.abs(i-s)<1e-4)return l;throw new Error("tukey.inv failed to converge")}})}(e,Math),function(t,e){var n,o,r=Array.prototype.push,i=t.utils.isArray;function s(e){return i(e)||e instanceof t}t.extend({add:function(e,n){return s(n)?(s(n[0])||(n=[n]),t.map(e,function(t,e,o){return t+n[e][o]})):t.map(e,function(t){return t+n})},subtract:function(e,n){return s(n)?(s(n[0])||(n=[n]),t.map(e,function(t,e,o){return t-n[e][o]||0})):t.map(e,function(t){return t-n})},divide:function(e,n){return s(n)?(s(n[0])||(n=[n]),t.multiply(e,t.inv(n))):t.map(e,function(t){return t/n})},multiply:function(e,n){var o,r,i,a,l,u,c,f;if(void 0===e.length&&void 0===n.length)return e*n;if(l=e.length,u=e[0].length,c=t.zeros(l,i=s(n)?n[0].length:u),f=0,s(n)){for(;f<i;f++)for(o=0;o<l;o++){for(a=0,r=0;r<u;r++)a+=e[o][r]*n[r][f];c[o][f]=a}return 1===l&&1===f?c[0][0]:c}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){s(e[0])||(e=[e]),s(n[0])||(n=[n]);for(var o,r,i=1===e[0].length&&1!==e.length?t.transpose(e):e,a=1===n[0].length&&1!==n.length?t.transpose(n):n,l=[],u=0,c=i.length,f=i[0].length;u<c;u++){for(l[u]=[],o=0,r=0;r<f;r++)o+=i[u][r]*a[u][r];l[u]=o}return 1===l.length?l[0]:l},pow:function(n,o){return t.map(n,function(t){return e.pow(t,o)})},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 o=0,r=0;for(isNaN(n)&&(n=2),s(t[0])&&(t=t[0]);r<t.length;r++)o+=e.pow(e.abs(t[r]),n);return e.pow(o,1/n)},angle:function(n,o){return e.acos(t.dot(n,o)/(t.norm(n)*t.norm(o)))},aug:function(t,e){var n,o=[];for(n=0;n<t.length;n++)o.push(t[n].slice());for(n=0;n<o.length;n++)r.apply(o[n],e[n]);return o},inv:function(e){for(var n,o=e.length,r=e[0].length,i=t.identity(o,r),s=t.gauss_jordan(e,i),a=[],l=0;l<o;l++)for(a[l]=[],n=r;n<s[0].length;n++)a[l][n-r]=s[l][n];return a},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,o=0;o<e.length;o++){for(var r=[],i=1;i<e.length;i++){r[i-1]=[];for(var s=0;s<e.length;s++)s<o?r[i-1][s]=e[i][s]:s>o&&(r[i-1][s-1]=e[i][s])}var a=o%2?-1:1;n+=t(r)*e[0][o]*a}return n},gauss_elimination:function(n,o){var r,i,s,a,l=0,u=0,c=n.length,f=n[0].length,d=1,h=0,m=[];for(r=(n=t.aug(n,o))[0].length,l=0;l<c;l++){for(i=n[l][l],u=l,a=l+1;a<f;a++)i<e.abs(n[a][l])&&(i=n[a][l],u=a);if(u!=l)for(a=0;a<r;a++)s=n[l][a],n[l][a]=n[u][a],n[u][a]=s;for(u=l+1;u<c;u++)for(d=n[u][l]/n[l][l],a=l;a<r;a++)n[u][a]=n[u][a]-d*n[l][a]}for(l=c-1;l>=0;l--){for(h=0,u=l+1;u<=c-1;u++)h+=m[u]*n[l][u];m[l]=(n[l][r-1]-h)/n[l][l]}return m},gauss_jordan:function(n,o){var r,i,s,a=t.aug(n,o),l=a.length,u=a[0].length,c=0;for(i=0;i<l;i++){var f=i;for(s=i+1;s<l;s++)e.abs(a[s][i])>e.abs(a[f][i])&&(f=s);var d=a[i];for(a[i]=a[f],a[f]=d,s=i+1;s<l;s++)for(c=a[s][i]/a[i][i],r=i;r<u;r++)a[s][r]-=a[i][r]*c}for(i=l-1;i>=0;i--){for(c=a[i][i],s=0;s<i;s++)for(r=u-1;r>i-1;r--)a[s][r]-=a[i][r]*a[s][i]/c;for(a[i][i]/=c,r=l;r<u;r++)a[i][r]/=c}return a},triaUpSolve:function(e,n){var o,r=e[0].length,i=t.zeros(1,r)[0],s=!1;return null!=n[0].length&&(n=n.map(function(t){return t[0]}),s=!0),t.arange(r-1,-1,-1).forEach(function(s){o=t.arange(s+1,r).map(function(t){return i[t]*e[s][t]}),i[s]=(n[s]-t.sum(o))/e[s][s]}),s?i.map(function(t){return[t]}):i},triaLowSolve:function(e,n){var o,r=e[0].length,i=t.zeros(1,r)[0],s=!1;return null!=n[0].length&&(n=n.map(function(t){return t[0]}),s=!0),t.arange(r).forEach(function(r){o=t.arange(r).map(function(t){return e[r][t]*i[t]}),i[r]=(n[r]-t.sum(o))/e[r][r]}),s?i.map(function(t){return[t]}):i},lu:function(e){var n,o=e.length,r=t.identity(o),i=t.zeros(e.length,e[0].length);return t.arange(o).forEach(function(t){i[0][t]=e[0][t]}),t.arange(1,o).forEach(function(s){t.arange(s).forEach(function(o){n=t.arange(o).map(function(t){return r[s][t]*i[t][o]}),r[s][o]=(e[s][o]-t.sum(n))/i[o][o]}),t.arange(s,o).forEach(function(o){n=t.arange(s).map(function(t){return r[s][t]*i[t][o]}),i[s][o]=e[n.length][o]-t.sum(n)})}),[r,i]},cholesky:function(n){var o,r=n.length,i=t.zeros(n.length,n[0].length);return t.arange(r).forEach(function(s){o=t.arange(s).map(function(t){return e.pow(i[s][t],2)}),i[s][s]=e.sqrt(n[s][s]-t.sum(o)),t.arange(s+1,r).forEach(function(e){o=t.arange(s).map(function(t){return i[s][t]*i[e][t]}),i[e][s]=(n[s][e]-t.sum(o))/i[s][s]})}),i},gauss_jacobi:function(n,o,r,i){for(var s,a,l,u,c=0,f=0,d=n.length,h=[],m=[],p=[];c<d;c++)for(h[c]=[],m[c]=[],p[c]=[],f=0;f<d;f++)c>f?(h[c][f]=n[c][f],m[c][f]=p[c][f]=0):c<f?(m[c][f]=n[c][f],h[c][f]=p[c][f]=0):(p[c][f]=n[c][f],h[c][f]=m[c][f]=0);for(l=t.multiply(t.multiply(t.inv(p),t.add(h,m)),-1),a=t.multiply(t.inv(p),o),s=r,u=t.add(t.multiply(l,r),a),c=2;e.abs(t.norm(t.subtract(u,s)))>i;)s=u,u=t.add(t.multiply(l,s),a),c++;return u},gauss_seidel:function(n,o,r,i){for(var s,a,l,u,c,f=0,d=n.length,h=[],m=[],p=[];f<d;f++)for(h[f]=[],m[f]=[],p[f]=[],s=0;s<d;s++)f>s?(h[f][s]=n[f][s],m[f][s]=p[f][s]=0):f<s?(m[f][s]=n[f][s],h[f][s]=p[f][s]=0):(p[f][s]=n[f][s],h[f][s]=m[f][s]=0);for(u=t.multiply(t.multiply(t.inv(t.add(p,h)),m),-1),l=t.multiply(t.inv(t.add(p,h)),o),a=r,c=t.add(t.multiply(u,r),l),f=2;e.abs(t.norm(t.subtract(c,a)))>i;)a=c,c=t.add(t.multiply(u,a),l),f+=1;return c},SOR:function(n,o,r,i,s){for(var a,l,u,c,f,d=0,h=n.length,m=[],p=[],g=[];d<h;d++)for(m[d]=[],p[d]=[],g[d]=[],a=0;a<h;a++)d>a?(m[d][a]=n[d][a],p[d][a]=g[d][a]=0):d<a?(p[d][a]=n[d][a],m[d][a]=g[d][a]=0):(g[d][a]=n[d][a],m[d][a]=p[d][a]=0);for(c=t.multiply(t.inv(t.add(g,t.multiply(m,s))),t.subtract(t.multiply(g,1-s),t.multiply(p,s))),u=t.multiply(t.multiply(t.inv(t.add(g,t.multiply(m,s))),o),s),l=r,f=t.add(t.multiply(c,r),u),d=2;e.abs(t.norm(t.subtract(f,l)))>i;)l=f,f=t.add(t.multiply(c,l),u),d++;return f},householder:function(n){for(var o,r,i,s,a=n.length,l=n[0].length,u=0,c=[],f=[];u<a-1;u++){for(o=0,s=u+1;s<l;s++)o+=n[s][u]*n[s][u];for(o=(n[u+1][u]>0?-1:1)*e.sqrt(o),r=e.sqrt((o*o-n[u+1][u]*o)/2),(c=t.zeros(a,1))[u+1][0]=(n[u+1][u]-o)/(2*r),i=u+2;i<a;i++)c[i][0]=n[i][u]/(2*r);f=t.subtract(t.identity(a,l),t.multiply(t.multiply(c,t.transpose(c)),2)),n=t.multiply(f,t.multiply(n,f))}return n},QR:(n=t.sum,o=t.arange,function(r){var i,s,a,l=r.length,u=r[0].length,c=t.zeros(u,u);for(r=t.copy(r),s=0;s<u;s++){for(c[s][s]=e.sqrt(n(o(l).map(function(t){return r[t][s]*r[t][s]}))),i=0;i<l;i++)r[i][s]=r[i][s]/c[s][s];for(a=s+1;a<u;a++)for(c[s][a]=n(o(l).map(function(t){return r[t][s]*r[t][a]})),i=0;i<l;i++)r[i][a]=r[i][a]-r[i][s]*c[s][a]}return[r,c]}),lstsq:function(e,n){var o=!1;void 0===n[0].length&&(n=n.map(function(t){return[t]}),o=!0);var r=t.QR(e),i=r[0],s=r[1],a=e[0].length,l=t.slice(i,{col:{end:a}}),u=function(e){var n=(e=t.copy(e)).length,o=t.identity(n);return t.arange(n-1,-1,-1).forEach(function(n){t.sliceAssign(o,{row:n},t.divide(t.slice(o,{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(r){var i=t.multiply(e[r][n],-1),s=t.slice(e,{row:r}),a=t.multiply(t.slice(e,{row:n}),i);t.sliceAssign(e,{row:r},t.add(s,a));var l=t.slice(o,{row:r}),u=t.multiply(t.slice(o,{row:n}),i);t.sliceAssign(o,{row:r},t.add(l,u))})}),o}(t.slice(s,{row:{end:a}})),c=t.transpose(l);void 0===c[0].length&&(c=[c]);var f=t.multiply(t.multiply(u,c),n);return void 0===f.length&&(f=[[f]]),o?f.map(function(t){return t[0]}):f},jacobi:function(n){for(var o,r,i,s,a,l,u,c=1,f=n.length,d=t.identity(f,f),h=[];1===c;){for(a=n[0][1],i=0,s=1,o=0;o<f;o++)for(r=0;r<f;r++)o!=r&&a<e.abs(n[o][r])&&(a=e.abs(n[o][r]),i=o,s=r);for(l=n[i][i]===n[s][s]?n[i][s]>0?e.PI/4:-e.PI/4:e.atan(2*n[i][s]/(n[i][i]-n[s][s]))/2,(u=t.identity(f,f))[i][i]=e.cos(l),u[i][s]=-e.sin(l),u[s][i]=e.sin(l),u[s][s]=e.cos(l),d=t.multiply(d,u),n=t.multiply(t.multiply(t.inv(u),n),u),c=0,o=1;o<f;o++)for(r=1;r<f;r++)o!=r&&e.abs(n[o][r])>.001&&(c=1)}for(o=0;o<f;o++)h.push(n[o][o]);return[d,h]},rungekutta:function(t,e,n,o,r,i){var s,a,l;if(2===i)for(;o<=n;)r+=((s=e*t(o,r))+(a=e*t(o+e,r+s)))/2,o+=e;if(4===i)for(;o<=n;)r+=((s=e*t(o,r))+2*(a=e*t(o+e/2,r+s/2))+2*(l=e*t(o+e/2,r+a/2))+e*t(o+e,r+l))/6,o+=e;return r},romberg:function(t,n,o,r){for(var i,s,a,l,u,c=0,f=(o-n)/2,d=[],h=[],m=[];c<r/2;){for(u=t(n),a=n,l=0;a<=o;a+=f,l++)d[l]=a;for(i=d.length,a=1;a<i-1;a++)u+=(a%2!=0?4:2)*t(d[a]);u=f/3*(u+t(o)),m[c]=u,f/=2,c++}for(s=m.length,i=1;1!==s;){for(a=0;a<s-1;a++)h[a]=(e.pow(4,i)*m[a+1]-m[a])/(e.pow(4,i)-1);s=h.length,m=h,h=[],i++}return m},richardson:function(t,n,o,r){function i(t,e){for(var n,o=0,r=t.length;o<r;o++)t[o]===e&&(n=o);return n}for(var s,a,l,u,c,f=e.abs(o-t[i(t,o)+1]),d=0,h=[],m=[];r>=f;)s=i(t,o+r),a=i(t,o),h[d]=(n[s]-2*n[a]+n[2*a-s])/(r*r),r/=2,d++;for(u=h.length,l=1;1!=u;){for(c=0;c<u-1;c++)m[c]=(e.pow(4,l)*h[c+1]-h[c])/(e.pow(4,l)-1);u=m.length,h=m,m=[],l++}return h},simpson:function(t,e,n,o){for(var r,i=(n-e)/o,s=t(e),a=[],l=e,u=0,c=1;l<=n;l+=i,u++)a[u]=l;for(r=a.length;c<r-1;c++)s+=(c%2!=0?4:2)*t(a[c]);return i/3*(s+t(n))},hermite:function(t,e,n,o){for(var r,i=t.length,s=0,a=0,l=[],u=[],c=[],f=[];a<i;a++){for(l[a]=1,r=0;r<i;r++)a!=r&&(l[a]*=(o-t[r])/(t[a]-t[r]));for(u[a]=0,r=0;r<i;r++)a!=r&&(u[a]+=1/(t[a]-t[r]));c[a]=(1-2*(o-t[a])*u[a])*(l[a]*l[a]),f[a]=(o-t[a])*(l[a]*l[a]),s+=c[a]*e[a]+f[a]*n[a]}return s},lagrange:function(t,e,n){for(var o,r,i=0,s=0,a=t.length;s<a;s++){for(r=e[s],o=0;o<a;o++)s!=o&&(r*=(n-t[o])/(t[s]-t[o]));i+=r}return i},cubic_spline:function(e,n,o){for(var r,i,s=e.length,a=0,l=[],u=[],c=[],f=[],d=[],h=[];a<s-1;a++)f[a]=e[a+1]-e[a];for(c[0]=0,a=1;a<s-1;a++)c[a]=3/f[a]*(n[a+1]-n[a])-3/f[a-1]*(n[a]-n[a-1]);for(a=1;a<s-1;a++)l[a]=[],u[a]=[],l[a][a-1]=f[a-1],l[a][a]=2*(f[a-1]+f[a]),l[a][a+1]=f[a],u[a][0]=c[a];for(i=t.multiply(t.inv(l),u),r=0;r<s-1;r++)d[r]=(n[r+1]-n[r])/f[r]-f[r]*(i[r+1][0]+2*i[r][0])/3,h[r]=(i[r+1][0]-i[r][0])/(3*f[r]);for(r=0;r<s&&!(e[r]>o);r++);return n[r-=1]+(o-e[r])*d[r]+t.sq(o-e[r])*i[r]+(o-e[r])*t.sq(o-e[r])*h[r]},gauss_quadrature:function(){throw new Error("gauss_quadrature not yet implemented")},PCA:function(e){var n,o,r,i,s,a=e.length,l=e[0].length,u=0,c=[],f=[],d=[],h=[],m=[],p=[],g=[];for(u=0;u<a;u++)c[u]=t.sum(e[u])/l;for(u=0;u<l;u++)for(m[u]=[],n=0;n<a;n++)m[u][n]=e[n][u]-c[n];for(m=t.transpose(m),u=0;u<a;u++)for(p[u]=[],n=0;n<a;n++)p[u][n]=t.dot([m[u]],[m[n]])/(l-1);for(s=(r=t.jacobi(p))[0],f=r[1],g=t.transpose(s),u=0;u<f.length;u++)for(n=u;n<f.length;n++)f[u]<f[n]&&(o=f[u],f[u]=f[n],f[n]=o,d=g[u],g[u]=g[n],g[n]=d);for(i=t.transpose(m),u=0;u<a;u++)for(h[u]=[],n=0;n<i.length;n++)h[u][n]=t.dot([g[u]],[i[n]]);return[e,f,g,h]}}),function(e){for(var n=0;n<e.length;n++)(function(e){t.fn[e]=function(n,o){var r=this;return o?(setTimeout(function(){o.call(r,t.fn[e].call(r,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,o=t.utils.isNumber,r=t.utils.isArray;function i(t,n,o,r){if(t>1||o>1||t<=0||o<=0)throw new Error("Proportions should be greater than 0 and less than 1");var i=(t*n+o*r)/(n+r);return(t-o)/e.sqrt(i*(1-i)*(1/n+1/r))}t.extend({zscore:function(){var e=n.call(arguments);return o(e[1])?(e[0]-e[1])/e[2]:(e[0]-t.mean(e[1]))/t.stdev(e[1],e[2])},ztest:function(){var o,i=n.call(arguments);return r(i[1])?(o=t.zscore(i[0],i[1],i[3]),1===i[2]?t.normal.cdf(-e.abs(o),0,1):2*t.normal.cdf(-e.abs(o),0,1)):i.length>2?(o=t.zscore(i[0],i[1],i[2]),1===i[3]?t.normal.cdf(-e.abs(o),0,1):2*t.normal.cdf(-e.abs(o),0,1)):(o=i[0],1===i[1]?t.normal.cdf(-e.abs(o),0,1):2*t.normal.cdf(-e.abs(o),0,1))}}),t.extend(t.fn,{zscore:function(t,e){return(t-this.mean())/this.stdev(e)},ztest:function(n,o,r){var i=e.abs(this.zscore(n,r));return 1===o?t.normal.cdf(-i,0,1):2*t.normal.cdf(-i,0,1)}}),t.extend({tscore:function(){var o=n.call(arguments);return 4===o.length?(o[0]-o[1])/(o[2]/e.sqrt(o[3])):(o[0]-t.mean(o[1]))/(t.stdev(o[1],!0)/e.sqrt(o[1].length))},ttest:function(){var r,i=n.call(arguments);return 5===i.length?(r=e.abs(t.tscore(i[0],i[1],i[2],i[3])),1===i[4]?t.studentt.cdf(-r,i[3]-1):2*t.studentt.cdf(-r,i[3]-1)):o(i[1])?(r=e.abs(i[0]),1==i[2]?t.studentt.cdf(-r,i[1]-1):2*t.studentt.cdf(-r,i[1]-1)):(r=e.abs(t.tscore(i[0],i[1])),1==i[2]?t.studentt.cdf(-r,i[1].length-1):2*t.studentt.cdf(-r,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,o){return 1===o?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 o,r,i,s,a,l,u,c,f=n.call(arguments);if(1===f.length){for(a=new Array(f[0].length),u=0;u<f[0].length;u++)a[u]=f[0][u];f=a}for(r=new Array,u=0;u<f.length;u++)r=r.concat(f[u]);for(i=t.mean(r),o=0,u=0;u<f.length;u++)o+=f[u].length*e.pow(t.mean(f[u])-i,2);for(o/=f.length-1,l=0,u=0;u<f.length;u++)for(s=t.mean(f[u]),c=0;c<f[u].length;c++)l+=e.pow(f[u][c]-s,2);return o/(l/(r.length-f.length))},anovaftest:function(){var e,r,i,s,a=n.call(arguments);if(o(a[0]))return 1-t.centralF.cdf(a[0],a[1],a[2]);var l=t.anovafscore(a);for(e=a.length-1,i=0,s=0;s<a.length;s++)i+=a[s].length;return r=i-e-1,1-t.centralF.cdf(l,e,r)},ftest:function(e,n,o){return 1-t.centralF.cdf(e,n,o)}}),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 r,i,s,a,l,u=n.call(arguments);return o(u[0])?(r=u[0],i=u[1],s=u[2],a=u[3],l=u[4]):(r=t.mean(u[0]),i=t.mean(u[1]),s=u[0].length,a=u[1].length,l=u[2]),e.abs(r-i)/(l*e.sqrt((1/s+1/a)/2))},qtest:function(){var e,o=n.call(arguments);3===o.length?(e=o[0],o=o.slice(1)):7===o.length?(e=t.qscore(o[0],o[1],o[2],o[3],o[4]),o=o.slice(5)):(e=t.qscore(o[0],o[1],o[2]),o=o.slice(3));var r=o[0],i=o[1];return 1-t.tukey.cdf(e,i,r-i)},tukeyhsd:function(e){for(var n=t.pooledstdev(e),o=e.map(function(e){return t.mean(e)}),r=e.reduce(function(t,e){return t+e.length},0),i=[],s=0;s<e.length;++s)for(var a=s+1;a<e.length;++a){var l=t.qtest(o[s],o[a],e[s].length,e[a].length,n,r,e.length);i.push([[s,a],l])}return i}}),t.extend({normalci:function(){var o,r=n.call(arguments),i=new Array(2);return o=4===r.length?e.abs(t.normal.inv(r[1]/2,0,1)*r[2]/e.sqrt(r[3])):e.abs(t.normal.inv(r[1]/2,0,1)*t.stdev(r[2])/e.sqrt(r[2].length)),i[0]=r[0]-o,i[1]=r[0]+o,i},tci:function(){var o,r=n.call(arguments),i=new Array(2);return o=4===r.length?e.abs(t.studentt.inv(r[1]/2,r[3]-1)*r[2]/e.sqrt(r[3])):e.abs(t.studentt.inv(r[1]/2,r[2].length-1)*t.stdev(r[2],!0)/e.sqrt(r[2].length)),i[0]=r[0]-o,i[1]=r[0]+o,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,o,r){var s=i(e,n,o,r);return t.ztest(s,1)},twoSidedDifferenceOfProportions:function(e,n,o,r){var s=i(e,n,o,r);return t.ztest(s,2)}})}(e,Math),e.models=function(){function t(t,n){var o=t.length,r=n[0].length-1,i=o-r-1,s=e.lstsq(n,t),a=e.multiply(n,s.map(function(t){return[t]})).map(function(t){return t[0]}),l=e.subtract(t,a),u=e.mean(t),c=e.sum(a.map(function(t){return Math.pow(t-u,2)})),f=e.sum(t.map(function(t,e){return Math.pow(t-a[e],2)})),d=c+f;return{exog:n,endog:t,nobs:o,df_model:r,df_resid:i,coef:s,predict:a,resid:l,ybar:u,SST:d,SSE:c,SSR:f,R2:c/d}}function n(n){var o,r,i=(o=n.exog,r=o[0].length,e.arange(r).map(function(n){var i=e.arange(r).filter(function(t){return t!==n});return t(e.col(o,n).map(function(t){return t[0]}),e.col(o,i))})),s=Math.sqrt(n.SSR/n.df_resid),a=i.map(function(t){var e=t.SST,n=t.R2;return s/Math.sqrt(e*(1-n))}),l=n.coef.map(function(t,e){return(t-0)/a[e]}),u=l.map(function(t){var o=e.studentt.cdf(t,n.df_resid);return 2*(o>.5?1-o:o)}),c=e.studentt.inv(.975,n.df_resid),f=n.coef.map(function(t,e){var n=c*a[e];return[t-n,t+n]});return{se:a,t:l,p:u,sigmaHat:s,interval95:f}}return{ols:function(o,r){var i=t(o,r),s=n(i),a=function(t){var n,o,r,i=t.R2/t.df_model/((1-t.R2)/t.df_resid);return{F_statistic:i,pvalue:1-(n=i,o=t.df_model,r=t.df_resid,e.beta.cdf(n/(r/o+n),o/2,r/2))}}(i),l=1-(1-i.R2)*((i.nobs-1)/i.df_resid);return i.t=s,i.f=a,i.adjust_R2=l,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),o=0;o<t.length;o++)n[o]=t[o];return e.builddxmatrix(n)},buildymatrix:function(t){return e(t).transpose()},buildjymatrix:function(t){return t.transpose()},matrixmult:function(t,n){var o,r,i,s,a;if(t.cols()==n.rows()){if(n.rows()>1){for(s=[],o=0;o<t.rows();o++)for(s[o]=[],r=0;r<n.cols();r++){for(a=0,i=0;i<t.cols();i++)a+=t.toArray()[o][i]*n.toArray()[i][r];s[o][r]=a}return e(s)}for(s=[],o=0;o<t.rows();o++)for(s[o]=[],r=0;r<n.cols();r++){for(a=0,i=0;i<t.cols();i++)a+=t.toArray()[o][i]*n.toArray()[r];s[o][r]=a}return e(s)}},regress:function(t,n){var o=e.xtranspxinv(t),r=t.transpose(),i=e.matrixmult(e(o),r);return e.matrixmult(i,n)},regresst:function(t,n,o){var r=e.regress(t,n),i={anova:{}},s=e.jMatYBar(t,r);i.yBar=s;var a=n.mean();i.anova.residuals=e.residuals(n,s),i.anova.ssr=e.ssr(s,a),i.anova.msr=i.anova.ssr/(t[0].length-1),i.anova.sse=e.sse(n,s),i.anova.mse=i.anova.sse/(n.length-(t[0].length-1)-1),i.anova.sst=e.sst(n,a),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 l,u,c,f=e.xtranspxinv(t),d=0;d<r.length;d++)l=Math.sqrt(i.anova.mse*Math.abs(f[d][d])),u=Math.abs(r[d]/l),c=e.ttest(u,n.length-t[0].length-1,o),i.stats[d]=[r[d],l,u,c];return i.regress=r,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 o=e.matrixmult(t,n);return new e(o)},residuals:function(t,n){return e.matrixsubtract(t,n)},ssr:function(t,e){for(var n=0,o=0;o<t.length;o++)n+=Math.pow(t[o]-e,2);return n},sse:function(t,e){for(var n=0,o=0;o<t.length;o++)n+=Math.pow(t[o]-e[o],2);return n},sst:function(t,e){for(var n=0,o=0;o<t.length;o++)n+=Math.pow(t[o]-e,2);return n},matrixsubtract:function(t,n){for(var o=new Array(t.length),r=0;r<t.length;r++){o[r]=new Array(t[r].length);for(var i=0;i<t[r].length;i++)o[r][i]=t[r][i]-n[r][i]}return e(o)}}),e.jStat=e,e)},5072(t){"use strict";var e=[];function n(t){for(var n=-1,o=0;o<e.length;o++)if(e[o].identifier===t){n=o;break}return n}function o(t,o){for(var i={},s=[],a=0;a<t.length;a++){var l=t[a],u=o.base?l[0]+o.base:l[0],c=i[u]||0,f="".concat(u," ").concat(c);i[u]=c+1;var d=n(f),h={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==d)e[d].references++,e[d].updater(h);else{var m=r(h,o);o.byIndex=a,e.splice(a,0,{identifier:f,updater:m,references:1})}s.push(f)}return s}function r(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,r){var i=o(t=t||[],r=r||{});return function(t){t=t||[];for(var s=0;s<i.length;s++){var a=n(i[s]);e[a].references--}for(var l=o(t,r),u=0;u<i.length;u++){var c=n(i[u]);0===e[c].references&&(e[c].updater(),e.splice(c,1))}i=l}}},7659(t){"use strict";var e={};t.exports=function(t,n){var o=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(!o)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");o.appendChild(n)}},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}},5056(t,e,n){"use strict";t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},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 o="";n.supports&&(o+="@supports (".concat(n.supports,") {")),n.media&&(o+="@media ".concat(n.media," {"));var r=void 0!==n.layer;r&&(o+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),o+=n.css,r&&(o+="}"),n.media&&(o+="}"),n.supports&&(o+="}");var i=n.sourceMap;i&&"undefined"!=typeof btoa&&(o+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(i))))," */")),e.styleTagTransform(o,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},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))}}}},i={};function s(t){var e=i[t];if(void 0!==e)return e.exports;var n=i[t]={id:t,loaded:!1,exports:{}};return r[t].call(n.exports,n,n.exports,s),n.loaded=!0,n.exports}s.m=r,s.amdO={},s.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return s.d(e,{a:e}),e},e=Object.getPrototypeOf?t=>Object.getPrototypeOf(t):t=>t.__proto__,s.t=function(n,o){if(1&o&&(n=this(n)),8&o)return n;if("object"==typeof n&&n){if(4&o&&n.__esModule)return n;if(16&o&&"function"==typeof n.then)return n}var r=Object.create(null);s.r(r);var i={};t=t||[null,e({}),e([]),e(e)];for(var a=2&o&&n;("object"==typeof a||"function"==typeof a)&&!~t.indexOf(a);a=e(a))Object.getOwnPropertyNames(a).forEach(t=>i[t]=()=>n[t]);return i.default=()=>n,s.d(r,i),r},s.d=(t,e)=>{for(var n in e)s.o(e,n)&&!s.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},s.f={},s.e=t=>Promise.all(Object.keys(s.f).reduce((e,n)=>(s.f[n](t,e),e),[])),s.u=t=>t+".js",s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),s.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),s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n={},o="eda:",s.l=(t,e,r,i)=>{if(n[t])n[t].push(e);else{var a,l;if(void 0!==r)for(var u=document.getElementsByTagName("script"),c=0;c<u.length;c++){var f=u[c];if(f.getAttribute("src")==t||f.getAttribute("data-webpack")==o+r){a=f;break}}a||(l=!0,(a=document.createElement("script")).charset="utf-8",s.nc&&a.setAttribute("nonce",s.nc),a.setAttribute("data-webpack",o+r),a.src=t),n[t]=[e];var d=(e,o)=>{a.onerror=a.onload=null,clearTimeout(h);var r=n[t];if(delete n[t],a.parentNode&&a.parentNode.removeChild(a),r&&r.forEach(t=>t(o)),e)return e(o)},h=setTimeout(d.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=d.bind(null,a.onerror),a.onload=d.bind(null,a.onload),l&&document.head.appendChild(a)}},s.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{var t;s.g.importScripts&&(t=s.g.location+"");var e=s.g.document;if(!t&&e&&(e.currentScript&&"SCRIPT"===e.currentScript.tagName.toUpperCase()&&(t=e.currentScript.src),!t)){var n=e.getElementsByTagName("script");if(n.length)for(var o=n.length-1;o>-1&&(!t||!/^http(s?):/.test(t));)t=n[o--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),s.p=t})(),(()=>{s.b="undefined"!=typeof document&&document.baseURI||self.location.href;var t={255:0};s.f.j=(e,n)=>{var o=s.o(t,e)?t[e]:void 0;if(0!==o)if(o)n.push(o[2]);else{var r=new Promise((n,r)=>o=t[e]=[n,r]);n.push(o[2]=r);var i=s.p+s.u(e),a=new Error;s.l(i,n=>{if(s.o(t,e)&&(0!==(o=t[e])&&(t[e]=void 0),o)){var r=n&&("load"===n.type?"missing":n.type),i=n&&n.target&&n.target.src;a.message="Loading chunk "+e+" failed.\n("+r+": "+i+")",a.name="ChunkLoadError",a.type=r,a.request=i,o[1](a)}},"chunk-"+e,e)}};var e=(e,n)=>{var o,r,[i,a,l]=n,u=0;if(i.some(e=>0!==t[e])){for(o in a)s.o(a,o)&&(s.m[o]=a[o]);l&&l(s)}for(e&&e(n);u<i.length;u++)r=i[u],s.o(t,r)&&t[r]&&t[r][0](),t[r]=0},n=self.webpackChunkeda=self.webpackChunkeda||[];n.forEach(e.bind(null,0)),n.push=e.bind(null,n.push.bind(n))})(),s.nc=void 0;var a={};(()=>{"use strict";s.r(a),s.d(a,{_package:()=>Br,initAutoTests:()=>Ur,test:()=>kr,tests:()=>f});const t=DG;s(9982);const e=DG.DataFrame.fromCsv('countries,fasta,smiles,molregno,LON,Zip Code,Street Address Line 1,ImageUrl,user_id,error_message,xray,flag,magnitude,CS-id,pdb_id,accel_a,time_offset,chart,fit,Questions,empty_number,empty_string\nBelgium,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C(=O)OCCCc1cccnc1)c2cccc(c2)C(=O)c3ccccc3,1480014,36.276729583740234,995042300,14016 ROUTE 31W,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,1,1,1QBS,1,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.497360340644872, 1.7058694986686864, 5.278052678195135, 0.16000320889028383],""points"":[{""x"":0.10000000149011612,""y"":2.374499797821045},{""x"":0.6000000238418579,""y"":2.6242473125457764},{""x"":1.100000023841858,""y"":2.367267608642578},{""x"":1.600000023841858,""y"":2.6723148822784424},{""x"":2.0999999046325684,""y"":2.6537344455718994},{""x"":2.5999999046325684,""y"":2.3651671409606934},{""x"":3.0999999046325684,""y"":2.5654284954071045},{""x"":3.5999999046325684,""y"":2.4160959720611572},{""x"":4.099999904632568,""y"":2.286726713180542},{""x"":4.599999904632568,""y"":2.5100042819976807},{""x"":5.099999904632568,""y"":1.6676985025405884},{""x"":5.599999904632568,""y"":0.680136501789093},{""x"":6.099999904632568,""y"":0.3391543924808502},{""x"":6.599999904632568,""y"":0.09038983285427094},{""x"":7.099999904632568,""y"":0.19802775979042053}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[7.525235855508179, 1.3186911876809984, 5.335672608564294, 0.7860743343958098],""points"":[{""x"":0.10000000149011612,""y"":7.988070487976074},{""x"":0.6000000238418579,""y"":7.018453121185303},{""x"":1.100000023841858,""y"":8.115279197692871},{""x"":1.600000023841858,""y"":7.486658096313477},{""x"":2.0999999046325684,""y"":7.396438121795654},{""x"":2.5999999046325684,""y"":7.477052211761475},{""x"":3.0999999046325684,""y"":6.913095474243164},{""x"":3.5999999046325684,""y"":8.01385498046875},{""x"":4.099999904632568,""y"":6.985900402069092},{""x"":4.599999904632568,""y"":6.970335960388184},{""x"":5.099999904632568,""y"":5.448817253112793},{""x"":5.599999904632568,""y"":2.5534818172454834},{""x"":6.099999904632568,""y"":1.893947958946228},{""x"":6.599999904632568,""y"":0.6340042352676392},{""x"":7.099999904632568,""y"":0.8403874039649963}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,100,abc\nBurundi,MDYKETLLMPKTDFPMRGGLPNKEPQIQEKW,COc1ccc2cc(ccc2c1)C(C)C(=O)Oc3ccc(C)cc3OC,1480015,36.276729583740234,995073444,80 STATE HIGHWAY 310,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,2,2,1ZP8,2,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.431460753103398, 2.1691498799246745, 5.266445597102774, 0.7825762827017926],""points"":[{""x"":0.10000000149011612,""y"":4.751083850860596},{""x"":0.6000000238418579,""y"":4.203000068664551},{""x"":1.100000023841858,""y"":4.415858745574951},{""x"":1.600000023841858,""y"":4.68414306640625},{""x"":2.0999999046325684,""y"":4.198400974273682},{""x"":2.5999999046325684,""y"":4.179222106933594},{""x"":3.0999999046325684,""y"":4.638473987579346},{""x"":3.5999999046325684,""y"":4.708553314208984},{""x"":4.099999904632568,""y"":4.291589260101318},{""x"":4.599999904632568,""y"":4.038082599639893},{""x"":5.099999904632568,""y"":3.4349939823150635},{""x"":5.599999904632568,""y"":1.2194708585739136},{""x"":6.099999904632568,""y"":1.1920831203460693},{""x"":6.599999904632568,""y"":0.5352635979652405},{""x"":7.099999904632568,""y"":0.3346920311450958}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.339458017970126, -1.0734184310171178, 4.746332950550934, 0.2482416857595658],""points"":[{""x"":0.10000000149011612,""y"":0.2139337658882141},{""x"":0.6000000238418579,""y"":0.4269562065601349},{""x"":1.100000023841858,""y"":0.2441573292016983},{""x"":1.600000023841858,""y"":0.146635964512825},{""x"":2.0999999046325684,""y"":0.08818462491035461},{""x"":2.5999999046325684,""y"":0.2560656666755676},{""x"":3.0999999046325684,""y"":0.42434045672416687},{""x"":3.5999999046325684,""y"":0.37111231684684753},{""x"":4.099999904632568,""y"":0.5581737160682678},{""x"":4.599999904632568,""y"":1.183590054512024},{""x"":5.099999904632568,""y"":1.5629843473434448},{""x"":5.599999904632568,""y"":2.3211288452148438},{""x"":6.099999904632568,""y"":2.229961633682251},{""x"":6.599999904632568,""y"":2.2560226917266846},{""x"":7.099999904632568,""y"":2.2142398357391357}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCameroon,MIEVFLFGIVLGLIPITLAGLFVTAYLQYRRGDQLDL,COc1ccc2cc(ccc2c1)C(C)C(=O)OCCCc3cccnc3,1480016,36.26095962524414,995153596,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,3,3,2BDJ,3,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[4.6760652578642325, 0.9046956320756703, 5.651408971856738, 0.07738846012184185],""points"":[{""x"":0.10000000149011612,""y"":4.32425594329834},{""x"":0.6000000238418579,""y"":4.668442249298096},{""x"":1.100000023841858,""y"":4.379785060882568},{""x"":1.600000023841858,""y"":5.0345139503479},{""x"":2.0999999046325684,""y"":4.878653526306152},{""x"":2.5999999046325684,""y"":4.3451313972473145},{""x"":3.0999999046325684,""y"":4.336992263793945},{""x"":3.5999999046325684,""y"":5.037430286407471},{""x"":4.099999904632568,""y"":5.0092692375183105},{""x"":4.599999904632568,""y"":4.151902675628662},{""x"":5.099999904632568,""y"":3.4066951274871826},{""x"":5.599999904632568,""y"":2.3732759952545166},{""x"":6.099999904632568,""y"":1.673728108406067},{""x"":6.599999904632568,""y"":0.48574790358543396},{""x"":7.099999904632568,""y"":0.2783052325248718}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[2.938395863010111, -1.4658480661392117, 5.462702751996584, 0.3473139023615039],""points"":[{""x"":0.10000000149011612,""y"":0.4941710829734802},{""x"":0.6000000238418579,""y"":0.15323974192142487},{""x"":1.100000023841858,""y"":0.46373432874679565},{""x"":1.600000023841858,""y"":0.3370431363582611},{""x"":2.0999999046325684,""y"":0.5179030299186707},{""x"":2.5999999046325684,""y"":0.27899765968322754},{""x"":3.0999999046325684,""y"":0.22075064480304718},{""x"":3.5999999046325684,""y"":0.5789918899536133},{""x"":4.099999904632568,""y"":0.21169911324977875},{""x"":4.599999904632568,""y"":0.27857646346092224},{""x"":5.099999904632568,""y"":1.0906332731246948},{""x"":5.599999904632568,""y"":1.8520300388336182},{""x"":6.099999904632568,""y"":2.7177059650421143},{""x"":6.599999904632568,""y"":2.8680918216705322},{""x"":7.099999904632568,""y"":3.2413077354431152}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCanada,MMELVLKTIIGPIVVGVVLRIVDKWLNKDK,CC(C(=O)NCCS)c1cccc(c1)C(=O)c2ccccc2,1480017,36.26095962524414,99515,30-56 WHITESTONE EXPY,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,4,4,1IAN,4,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[0.8597390975430008, 1.0957625732481946, 5.260537067987958, 0.07974187998177736],""points"":[{""x"":0.10000000149011612,""y"":0.8190152645111084},{""x"":0.6000000238418579,""y"":0.8421689867973328},{""x"":1.100000023841858,""y"":0.8740922212600708},{""x"":1.600000023841858,""y"":0.8924275040626526},{""x"":2.0999999046325684,""y"":0.8249067664146423},{""x"":2.5999999046325684,""y"":0.9327669143676758},{""x"":3.0999999046325684,""y"":0.8522974252700806},{""x"":3.5999999046325684,""y"":0.8174492716789246},{""x"":4.099999904632568,""y"":0.8394647240638733},{""x"":4.599999904632568,""y"":0.7139387726783752},{""x"":5.099999904632568,""y"":0.5561167597770691},{""x"":5.599999904632568,""y"":0.3276226818561554},{""x"":6.099999904632568,""y"":0.12479474395513535},{""x"":6.599999904632568,""y"":0.13006797432899475},{""x"":7.099999904632568,""y"":0.059702079743146896}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.760930219582546, 1.6591793293833013, 4.667155929720851, 0.7858109544121652],""points"":[{""x"":0.10000000149011612,""y"":6.156993389129639},{""x"":0.6000000238418579,""y"":5.236701965332031},{""x"":1.100000023841858,""y"":6.010560512542725},{""x"":1.600000023841858,""y"":5.495512962341309},{""x"":2.0999999046325684,""y"":6.087770462036133},{""x"":2.5999999046325684,""y"":5.79986572265625},{""x"":3.0999999046325684,""y"":5.597546577453613},{""x"":3.5999999046325684,""y"":5.520902156829834},{""x"":4.099999904632568,""y"":5.360654354095459},{""x"":4.599999904632568,""y"":3.5539746284484863},{""x"":5.099999904632568,""y"":1.577236294746399},{""x"":5.599999904632568,""y"":1.0001264810562134},{""x"":6.099999904632568,""y"":0.9305797815322876},{""x"":6.599999904632568,""y"":0.6033638715744019},{""x"":7.099999904632568,""y"":0.4203685522079468}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nColombia,MDRTDEVSNHTHDKPTLTWFEEIFEEYHSPFHN,FC(F)(F)c1ccc(OC2CCNCC2)cc1,1480029,36.3309440612793,995152050,1 COURT HOUSE SQUARE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,5,5,4UJ1,5,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[6.4995088314153655, 2.4270351004539914, 5.178659535348579, 0.625653346241577],""points"":[{""x"":0.10000000149011612,""y"":6.496231555938721},{""x"":0.6000000238418579,""y"":6.42543363571167},{""x"":1.100000023841858,""y"":7.040063858032227},{""x"":1.600000023841858,""y"":6.1115403175354},{""x"":2.0999999046325684,""y"":6.680728435516357},{""x"":2.5999999046325684,""y"":6.406774520874023},{""x"":3.0999999046325684,""y"":6.611269474029541},{""x"":3.5999999046325684,""y"":5.889094352722168},{""x"":4.099999904632568,""y"":6.75344705581665},{""x"":4.599999904632568,""y"":6.361435890197754},{""x"":5.099999904632568,""y"":4.1666975021362305},{""x"":5.599999904632568,""y"":1.172118902206421},{""x"":6.099999904632568,""y"":0.801048994064331},{""x"":6.599999904632568,""y"":0.4640021026134491},{""x"":7.099999904632568,""y"":0.0010357667924836278}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[1.4734381347446401, 1.1649805188074196, 4.82958608866421, 0.09500545496710007],""points"":[{""x"":0.10000000149011612,""y"":1.5279096364974976},{""x"":0.6000000238418579,""y"":1.3559974431991577},{""x"":1.100000023841858,""y"":1.5246378183364868},{""x"":1.600000023841858,""y"":1.5567657947540283},{""x"":2.0999999046325684,""y"":1.4114240407943726},{""x"":2.5999999046325684,""y"":1.4045010805130005},{""x"":3.0999999046325684,""y"":1.4769829511642456},{""x"":3.5999999046325684,""y"":1.4875500202178955},{""x"":4.099999904632568,""y"":1.2991987466812134},{""x"":4.599999904632568,""y"":0.922961413860321},{""x"":5.099999904632568,""y"":0.6520044803619385},{""x"":5.599999904632568,""y"":0.15350978076457977},{""x"":6.099999904632568,""y"":0.1078903079032898},{""x"":6.599999904632568,""y"":0.17276449501514435},{""x"":7.099999904632568,""y"":0.14066608250141144}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCosta Rica,MKSTKEEIQTIKTLLKDSRTAKYHKRLQIVL,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCCc3ccccc3,1480018,36.3309440612793,995084218,4041 SOUTHWESTERN BLVD,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,6,6,2BPW,6,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.4833641843311227, -1.8945978742090062, 4.671127708092568, 0.24159861311815153],""points"":[{""x"":0.10000000149011612,""y"":0.0969524160027504},{""x"":0.6000000238418579,""y"":0.028483040630817413},{""x"":1.100000023841858,""y"":0.22087176144123077},{""x"":1.600000023841858,""y"":0.0068915546871721745},{""x"":2.0999999046325684,""y"":0.4305879771709442},{""x"":2.5999999046325684,""y"":0.44774115085601807},{""x"":3.0999999046325684,""y"":0.45346319675445557},{""x"":3.5999999046325684,""y"":0.2370593100786209},{""x"":4.099999904632568,""y"":0.4657953977584839},{""x"":4.599999904632568,""y"":1.155200719833374},{""x"":5.099999904632568,""y"":2.2294070720672607},{""x"":5.599999904632568,""y"":2.4311530590057373},{""x"":6.099999904632568,""y"":2.33846116065979},{""x"":6.599999904632568,""y"":2.608201026916504},{""x"":7.099999904632568,""y"":2.8136143684387207}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.224573521642033, 1.4454033924198528, 5.6014197746076535, 0.2823216054197577],""points"":[{""x"":0.10000000149011612,""y"":4.95027494430542},{""x"":0.6000000238418579,""y"":5.1754679679870605},{""x"":1.100000023841858,""y"":5.276752948760986},{""x"":1.600000023841858,""y"":5.589294910430908},{""x"":2.0999999046325684,""y"":5.616994857788086},{""x"":2.5999999046325684,""y"":5.120813846588135},{""x"":3.0999999046325684,""y"":5.340766906738281},{""x"":3.5999999046325684,""y"":4.876471042633057},{""x"":4.099999904632568,""y"":4.94999361038208},{""x"":4.599999904632568,""y"":5.162564754486084},{""x"":5.099999904632568,""y"":4.399557590484619},{""x"":5.599999904632568,""y"":2.7977969646453857},{""x"":6.099999904632568,""y"":1.0229872465133667},{""x"":6.599999904632568,""y"":0.48275601863861084},{""x"":7.099999904632568,""y"":0.10408931970596313}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nCuba,MHAILRYFIRRLFYHIFYKIYSLISKKHQSLPSDVRQF,COc1ccc2c(c1)c(CC(=O)N3CCCC3C(=O)Oc4ccc(C)cc4OC)c(C)n2C(=O)c5ccc(Cl)cc5,1480019,36.33115768432617,995081928,1227 US HIGHWAY 11,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,7,7,1QBS,7,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.320838679713925, -1.2421619987316728, 4.831325425225256, 0.3236011098403072],""points"":[{""x"":0.10000000149011612,""y"":0.3727470338344574},{""x"":0.6000000238418579,""y"":0.12365014106035233},{""x"":1.100000023841858,""y"":0.48422467708587646},{""x"":1.600000023841858,""y"":0.2264465093612671},{""x"":2.0999999046325684,""y"":0.16821794211864471},{""x"":2.5999999046325684,""y"":0.3879014551639557},{""x"":3.0999999046325684,""y"":0.5470244884490967},{""x"":3.5999999046325684,""y"":0.3419053554534912},{""x"":4.099999904632568,""y"":0.7655120491981506},{""x"":4.599999904632568,""y"":1.2346516847610474},{""x"":5.099999904632568,""y"":2.453336715698242},{""x"":5.599999904632568,""y"":2.9565491676330566},{""x"":6.099999904632568,""y"":3.335299491882324},{""x"":6.599999904632568,""y"":3.240290880203247},{""x"":7.099999904632568,""y"":3.1107218265533447}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.6401853521511094, 1.26211588875013, 5.399028074402744, 0.5089580830068091],""points"":[{""x"":0.10000000149011612,""y"":3.8585598468780518},{""x"":0.6000000238418579,""y"":3.6077206134796143},{""x"":1.100000023841858,""y"":3.855252265930176},{""x"":1.600000023841858,""y"":3.619039297103882},{""x"":2.0999999046325684,""y"":3.839388370513916},{""x"":2.5999999046325684,""y"":3.335283041000366},{""x"":3.0999999046325684,""y"":3.571141481399536},{""x"":3.5999999046325684,""y"":3.4155046939849854},{""x"":4.099999904632568,""y"":3.7316646575927734},{""x"":4.599999904632568,""y"":3.0680155754089355},{""x"":5.099999904632568,""y"":2.891066551208496},{""x"":5.599999904632568,""y"":1.6022753715515137},{""x"":6.099999904632568,""y"":0.7652576565742493},{""x"":6.599999904632568,""y"":0.6875326037406921},{""x"":7.099999904632568,""y"":0.5828871726989746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nItaly,MSNFHNEHVMQFYRNNLKTKGVFGRQ,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO[N+](=O)[O-],1480020,36.33115768432617,99502,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,8,8,1ZP8,8,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[2.293592105923809, 1.3781586549141835, 5.1025898038676605, 0.03493851245291291],""points"":[{""x"":0.10000000149011612,""y"":2.1287283897399902},{""x"":0.6000000238418579,""y"":2.267972230911255},{""x"":1.100000023841858,""y"":2.398442506790161},{""x"":1.600000023841858,""y"":2.5130622386932373},{""x"":2.0999999046325684,""y"":2.3255116939544678},{""x"":2.5999999046325684,""y"":2.127340793609619},{""x"":3.0999999046325684,""y"":2.47259783744812},{""x"":3.5999999046325684,""y"":2.131181478500366},{""x"":4.099999904632568,""y"":2.090421438217163},{""x"":4.599999904632568,""y"":2.02299165725708},{""x"":5.099999904632568,""y"":1.1105059385299683},{""x"":5.599999904632568,""y"":0.4494485855102539},{""x"":6.099999904632568,""y"":0.1375635862350464},{""x"":6.599999904632568,""y"":0.036351121962070465},{""x"":7.099999904632568,""y"":0.1619771122932434}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.953125499439879, 1.2528620255306528, 5.187637440149802, 0.3110348753260886],""points"":[{""x"":0.10000000149011612,""y"":5.6585283279418945},{""x"":0.6000000238418579,""y"":5.911152362823486},{""x"":1.100000023841858,""y"":5.924920082092285},{""x"":1.600000023841858,""y"":5.8469438552856445},{""x"":2.0999999046325684,""y"":5.929472923278809},{""x"":2.5999999046325684,""y"":6.190037727355957},{""x"":3.0999999046325684,""y"":6.236179828643799},{""x"":3.5999999046325684,""y"":6.141019344329834},{""x"":4.099999904632568,""y"":5.295210838317871},{""x"":4.599999904632568,""y"":5.265801906585693},{""x"":5.099999904632568,""y"":3.3722851276397705},{""x"":5.599999904632568,""y"":1.8299226760864258},{""x"":6.099999904632568,""y"":0.32690900564193726},{""x"":6.599999904632568,""y"":0.6274543404579163},{""x"":7.099999904632568,""y"":0.8441857099533081}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nRwanda,MPNSEPASLLELFNSIATQGELVRSLKAGNASK,CC(C)Cc1ccc(cc1)C(C)C(=O)N2CCCC2C(=O)OCCO,1480021,36.33137130737305,995037247,"168-46 91ST AVE., 2ND FLR",https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,9,2BDJ,9,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[3.8209972202654474, 1.3779216716448506, 5.299882228439686, 0.06040645519069608],""points"":[{""x"":0.10000000149011612,""y"":3.7821109294891357},{""x"":0.6000000238418579,""y"":3.542433023452759},{""x"":1.100000023841858,""y"":3.7008674144744873},{""x"":1.600000023841858,""y"":3.717301607131958},{""x"":2.0999999046325684,""y"":4.024452209472656},{""x"":2.5999999046325684,""y"":4.013899326324463},{""x"":3.0999999046325684,""y"":3.945094347000122},{""x"":3.5999999046325684,""y"":3.866621971130371},{""x"":4.099999904632568,""y"":3.7461626529693604},{""x"":4.599999904632568,""y"":3.3454740047454834},{""x"":5.099999904632568,""y"":2.61944317817688},{""x"":5.599999904632568,""y"":0.999405026435852},{""x"":6.099999904632568,""y"":0.46259793639183044},{""x"":6.599999904632568,""y"":0.054134611040353775},{""x"":7.099999904632568,""y"":0.05711187422275543}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[5.6318079657726035, 1.8495493770000595, 5.391793312471116, 0.17060707587348442],""points"":[{""x"":0.10000000149011612,""y"":5.458079814910889},{""x"":0.6000000238418579,""y"":5.554427146911621},{""x"":1.100000023841858,""y"":5.799983024597168},{""x"":1.600000023841858,""y"":5.364140033721924},{""x"":2.0999999046325684,""y"":5.864485740661621},{""x"":2.5999999046325684,""y"":5.4509806632995605},{""x"":3.0999999046325684,""y"":5.702574729919434},{""x"":3.5999999046325684,""y"":5.7314534187316895},{""x"":4.099999904632568,""y"":5.5123443603515625},{""x"":4.599999904632568,""y"":5.724395751953125},{""x"":5.099999904632568,""y"":4.354506969451904},{""x"":5.599999904632568,""y"":1.7307666540145874},{""x"":6.099999904632568,""y"":0.6305936574935913},{""x"":6.599999904632568,""y"":0.035183437168598175},{""x"":7.099999904632568,""y"":0.7575169205665588}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\nSwitzerland,IRVVGRYLIEVWKAAGMDMDKVLFLWSSDEI,CN1CCC(CC1)Oc2ccc(cc2)C(F)(F)F,1480028,36.33137130737305,99504,92-11 179TH PLACE,https://datagrok.ai/img/slides/access-db-connect.png,id,ErrorMessage,"COMPND \nATOM \nEND",flag,9,10,1IAN,10,1.23,<chart></chart>,"{""series"":[{""name"":""Run:2023-08-08"",""fitFunction"":""sigmoid"",""fitLineColor"":""#1f77b4"",""pointColor"":""#1f77b4"",""showPoints"":""points"",""parameters"":[1.1190255865097471, 2.3163895161544437, 5.4968866182279195, 0.2035204047289052],""points"":[{""x"":0.10000000149011612,""y"":1.1057683229446411},{""x"":0.6000000238418579,""y"":1.1019697189331055},{""x"":1.100000023841858,""y"":1.0818607807159424},{""x"":1.600000023841858,""y"":1.062997817993164},{""x"":2.0999999046325684,""y"":1.046447515487671},{""x"":2.5999999046325684,""y"":1.1217249631881714},{""x"":3.0999999046325684,""y"":1.2166996002197266},{""x"":3.5999999046325684,""y"":1.215477705001831},{""x"":4.099999904632568,""y"":1.0581893920898438},{""x"":4.599999904632568,""y"":1.1747995615005493},{""x"":5.099999904632568,""y"":1.0181127786636353},{""x"":5.599999904632568,""y"":0.5344523191452026},{""x"":6.099999904632568,""y"":0.2569526433944702},{""x"":6.599999904632568,""y"":0.1912207305431366},{""x"":7.099999904632568,""y"":0.15060538053512573}]},{""name"":""Run:2023-08-08"",""fitLineColor"":""#ffbb78"",""pointColor"":""#ffbb78"",""showPoints"":""points"",""parameters"":[3.1038581025805785, 2.0032224204185245, 5.087602825989163, 0.13277988512492753],""points"":[{""x"":0.10000000149011612,""y"":3.0498509407043457},{""x"":0.6000000238418579,""y"":2.805217742919922},{""x"":1.100000023841858,""y"":3.3415253162384033},{""x"":1.600000023841858,""y"":3.0549843311309814},{""x"":2.0999999046325684,""y"":3.250074863433838},{""x"":2.5999999046325684,""y"":3.0432586669921875},{""x"":3.0999999046325684,""y"":3.265852451324463},{""x"":3.5999999046325684,""y"":2.9475724697113037},{""x"":4.099999904632568,""y"":3.1929898262023926},{""x"":4.599999904632568,""y"":2.7460060119628906},{""x"":5.099999904632568,""y"":1.6175861358642578},{""x"":5.599999904632568,""y"":0.3006608486175537},{""x"":6.099999904632568,""y"":0.3444803059101105},{""x"":6.599999904632568,""y"":0.015537971630692482},{""x"":7.099999904632568,""y"":0.5527358055114746}]}],""chartOptions"":{""xAxisName"":""Conc."",""yAxisName"":""Activity"",""title"":""Dose-Response curves""}}",text,,\n,,,,,,,,,,,,,,,,,,,,,');e.columns.add(DG.Column.fromList(DG.TYPE.BYTE_ARRAY,"BinaryImage",Array.from(new Uint8Array(11))));var n=function(t,e,n,o){return new(n||(n=Promise))(function(r,i){function s(t){try{l(o.next(t))}catch(t){i(t)}}function a(t){try{l(o.throw(t))}catch(t){i(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(s,a)}l((o=o.apply(t,e||[])).next())})};const o=3e4,r=108e5,i=console.log.bind(console),l=console.info.bind(console),u=console.warn.bind(console),c=console.error.bind(console),f={},d="Auto Tests",h="Demo",m="Detectors",p="Core",g={};let v;var y;!function(t){t.notNull=function(t,e){if(null==t)throw new Error(`${null==e?"Value":e} not defined`)}}(y||(y={}));class A{constructor(t,e,n){this.catchUnhandled=!0,this.report=!1,this.returnOnFail=!1,void 0!==t&&(this.catchUnhandled=t),void 0!==e&&(this.report=e),void 0!==n&&(this.returnOnFail=n)}}class w{constructor(t,e,r,i){var s;this.category=t,this.name=e,null!=i||(i={}),null!==(s=i.timeout)&&void 0!==s||(i.timeout=o),this.options=i,this.test=()=>n(this,void 0,void 0,function*(){return new Promise((t,e)=>n(this,void 0,void 0,function*(){var n;let o="";try{DG.Test.isInDebug;let t=yield r();try{o=null!==(n=null==t?void 0:t.toString())&&void 0!==n?n:""}catch(t){o="Can't convert test's result to string",console.error(`Can't convert test's result to string in the ${this.category}:${this.name} test`)}}catch(t){e(t)}t(o)}))})}}function C(t,e,n){null==f[v]&&(f[v]={}),null==f[v].tests&&(f[v].tests=[]),f[v].tests.push(new w(v,t,e,n))}function E(t,e=!0,n){if(n=n?`${n}, `:"",t!==e)throw new Error(`${n}Expected "${e}", got "${t}"`)}function b(t,e,n){var o;v=t,e(),f[v]&&(f[v].clear=null===(o=null==n?void 0:n.clear)||void 0===o||o,f[v].timeout=null==n?void 0:n.timeout,f[v].benchmarks=null==n?void 0:n.benchmarks,f[v].stressTests=null==n?void 0:n.stressTests,f[v].owner=null==n?void 0:n.owner)}function x(t,e){return t.replace(new RegExp(e.name,"gi"),e.nqName)}function _(t,i){var s,a,l,u,c,v,y,A,C,b;return n(this,void 0,void 0,function*(){const _=t.id;if(g[_])return;const N=i?i.tests:f;if("DevTools"===t.name||i&&"DevTools"===i._package.name)for(const t of window.dartTests){const e=t.name.split(/\s*\|\s*!/g);let n=null!==(s=e.pop())&&void 0!==s?s:t.name,r=e.length?p+": "+e.join(": "):p,i=n.split(" | ");n=i[i.length-1],i.unshift(r),i.pop(),r=i.join(": "),void 0===N[r]&&(N[r]={tests:[],clear:!0}),N[r].tests.push(new w(r,n,t.test,{isAggregated:!1,timeout:null!==(l=null===(a=t.options)||void 0===a?void 0:a.timeout)&&void 0!==l?l:o,skipReason:null===(u=t.options)||void 0===u?void 0:u.skipReason,owner:null===(c=t.options)||void 0===c?void 0:c.owner,benchmark:null!==(y=null===(v=t.options)||void 0===v?void 0:v.benchmark)&&void 0!==y&&y}))}const M=[],T=[],O=[],I=yield grok.dapi.functions.filter(`package.id = "${_}"`).list(),L=new RegExp(/skip:\s*([^,\s]+)|wait:\s*(\d+)|cat:\s*([^,\s]+)|timeout:\s*(\d+)/g);for(const i of I){const s=i.options.test,a=i.options.demoPath;if(s&&Array.isArray(s)&&s.length)for(let t=0;t<s.length;t++){const e=s[t].matchAll(L),a={};Array.from(e).forEach(t=>{t[0].startsWith("skip")?a.skip=t[1]:t[0].startsWith("wait")?a.wait=parseInt(t[2]):t[0].startsWith("cat")?a.cat=t[3]:t[0].startsWith("timeout")&&(a.timeout=parseInt(t[4]))});const l=new w(null!==(A=a.cat)&&void 0!==A?A:d,1===s.length?i.name:`${i.name} ${t+1}`,()=>n(this,void 0,void 0,function*(){const e=yield grok.functions.eval(x(s[t],i));if(a.wait&&(yield S(a.wait)),"boolean"==typeof e&&!e)throw`Failed: ${s[t]}, expected true, got ${e}`}),{skipReason:a.skip,timeout:DG.Test.isInBenchmark?null!==(C=a.benchmarkTimeout)&&void 0!==C?C:r:null!==(b=a.timeout)&&void 0!==b?b:o});if(a.cat){const t=a.cat;void 0===N[t]&&(N[t]={tests:[],clear:!0}),N[t].tests||(N[t].tests=[]),N[t].tests.push(l)}else M.push(l)}if(a){const t=i.options.demoWait?parseInt(i.options.demoWait):void 0,e=new w(h,i.friendlyName,()=>n(this,void 0,void 0,function*(){yield S(300),grok.shell.clearLastError(),yield i.apply(),yield S(t||2e3);const e=yield grok.shell.lastError;if(e)throw new Error(e)}),{skipReason:i.options.demoSkip});T.push(e)}if(i.hasTag("semTypeDetector")){let o=e;i.options.testData&&(o=yield grok.data.files.openTable(`System:AppData/${t.nqName}/${i.options.testData}`));const r=new w(m,i.friendlyName,()=>n(this,void 0,void 0,function*(){const e=[];console.log(`System:AppData/${t.nqName}/${i.options.testData}`);for(const t of o.clone().columns){const n=yield i.apply([t]);e.push(n||t.semType)}const n=e.filter(t=>t);E(n.length,1),i.options.testDataColumnName&&E(n[0],i.options.testDataColumnName)}),{skipReason:i.options.skipTest});O.push(r)}}g[_]=!0,M.length>0&&(N[d]={tests:M,clear:!0}),T.length>0&&(N[h]={tests:T,clear:!0}),O.length>0&&(N[m]={tests:O,clear:!1})})}function N(t){return n(this,void 0,void 0,function*(){return`${t.toString()}\n${t.stack?yield DG.Logger.translateStackTrace(t.stack):""}`})}function M(t,e,r,s,a,l){var u,f,d,h,m,p,g,v,y,A,w,C,E,b;return n(this,void 0,void 0,function*(){let n;r.length=0;const x=null!=e&&t.name.toLowerCase()!==e.toLowerCase();let _=(null===(u=t.options)||void 0===u?void 0:u.skipReason)||x,M=x?"skipped":null===(f=t.options)||void 0===f?void 0:f.skipReason;if(DG.Test.isInBenchmark&&!(null===(d=t.options)||void 0===d?void 0:d.benchmark))return void i(`Package testing: Skipped {{${t.category}}} {{${t.name}}} doesnt available in benchmark mode`);_&&!DG.Test.isInBenchmark&&i(`Package testing: Skipped {{${t.category}}} {{${t.name}}}`),_||i(`Package testing: Started {{${t.category}}} {{${t.name}}}`);const T=Date.now(),S=new Date(T).toISOString();try{if(_)n={name:t.name,owner:null!==(m=null===(h=t.options)||void 0===h?void 0:h.owner)&&void 0!==m?m:"",category:t.category,logs:"",date:S,success:!0,result:M,ms:0,skipped:!0,package:null!=a?a:"",flaking:DG.Test.isReproducing};else{let e=null!=s?s:o;DG.Test.isProfiling&&console.profile(`${t.category}: ${t.name}`),n={name:t.name,owner:null!==(g=null===(p=t.options)||void 0===p?void 0:p.owner)&&void 0!==g?g:"",category:t.category,logs:"",date:S,success:!0,result:null!==(v=(yield O(t.test,e)).toString())&&void 0!==v?v:"OK",ms:0,skipped:!1,package:null!=a?a:"",flaking:DG.Test.isReproducing},DG.Test.isProfiling&&(console.profileEnd(`${t.category}: ${t.name}`),grok.shell.info(`Profiling of ${t.category}: ${t.name} finished \n Please ensure that you have opened DevTools (F12) / Performance panel before test starts.`))}}catch(e){c(e),n={name:t.name,owner:null!==(A=null===(y=t.options)||void 0===y?void 0:y.owner)&&void 0!==A?A:"",category:t.category,logs:"",date:S,success:!1,result:yield N(e),ms:0,skipped:!1,package:null!=a?a:"",flaking:!1}}if((null===(w=t.options)||void 0===w?void 0:w.isAggregated)&&n.result.constructor===DG.DataFrame){const t=n.result.col("success");if(t&&(n.success=t.stats.sum===t.length),!l){const t=n.result;t.columns.remove("stack"),t.rows.removeWhere(t=>t.get("success")),n.result=t}n.result=n.result.toCsv()}if(n.logs=r.join("\n"),n.ms=Date.now()-T,_||i(`Package testing: Finished {{${t.category}}} {{${t.name}}} with {{${n.success?"success":"error"}}} for ${n.ms} ms`),n.success||i(`Package testing: Result for {{${t.category}}} {{${t.name}}}: ${n.result}`),n.category=t.category,n.name=t.name,n.owner=null!==(E=null===(C=t.options)||void 0===C?void 0:C.owner)&&void 0!==E?E:"",!x){let e={success:n.success,result:n.result,ms:n.ms,date:n.date,skipped:n.skipped,category:t.category,name:t.name,logs:n.logs,owner:n.owner,flaking:DG.Test.isReproducing&&n.success,package:n.package};if(n.result.constructor==Object){const t=Object.keys(n.result).reduce((t,e)=>Object.assign(Object.assign({},t),{["result."+e]:n.result[e]}),{});e=Object.assign(Object.assign({},e),t)}e.result instanceof DG.DataFrame&&(e.result=JSON.stringify(null===(b=e.result)||void 0===b?void 0:b.toJson())||""),yield grok.shell.reportTest("package",e)}return n})}function T(t){const e=t.slice();return e.sort(()=>Math.random()-.5),e}function S(t){return n(this,void 0,void 0,function*(){yield new Promise(e=>setTimeout(e,t))})}function O(t,e,o="EXECUTION TIMEOUT"){return n(this,void 0,void 0,function*(){let n=null;const r=new Promise((t,r)=>{n=setTimeout(()=>{r(o)},e)});try{return yield Promise.race([t(),r])}finally{n&&clearTimeout(n)}})}DG.DataFrame.fromColumns([DG.Column.fromStrings("col",["val1","val2","val3"])]);const I=grok;var L,P,R,F,D,B,k,U;!function(t){t.UMAP="UMAP",t.T_SNE="t-SNE"}(L||(L={})),function(t){t.Levenshtein="Levenshtein",t.JaroWinkler="Jaro-Winkler",t.Manhattan="Manhattan String",t.Onehot="One-Hot"}(P||(P={})),function(t){t.Euclidean="Euclidean",t.Manhattan="Manhattan",t.Cosine="Vector Cosine"}(R||(R={})),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"}(F||(F={})),function(t){t.TanimotoIntArray="TanimotoIntArray"}(D||(D={})),function(t){t.Vector="Vector",t.String="String",t.BitArray="BitArray",t.MacroMolecule="MacroMolecule",t.Number="Number",t.IntArray="IntArray",t.NumberArray="NumberArray"}(B||(B={})),function(t){t.Difference="Difference"}(k||(k={})),function(t){t.CommonItems="Common Items"}(U||(U={}));const V=new Uint32Array(65536),G=(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,o=e.length,r=1<<n-1;let i=-1,s=0,a=n,l=n;for(;l--;)V[t.charCodeAt(l)]|=1<<l;for(l=0;l<o;l++){let t=V[e.charCodeAt(l)];const n=t|s;t|=(t&i)+i^i,s|=~(t|i),i&=t,s&r&&a++,i&r&&a--,s=s<<1|1,i=i<<1|~(n|s),s&=n}for(l=n;l--;)V[t.charCodeAt(l)]=0;return a})(t,e):((t,e)=>{const n=e.length,o=t.length,r=[],i=[],s=Math.ceil(n/32),a=Math.ceil(o/32);for(let t=0;t<s;t++)i[t]=-1,r[t]=0;let l=0;for(;l<a-1;l++){let s=0,a=-1;const u=32*l,c=Math.min(32,o)+u;for(let e=u;e<c;e++)V[t.charCodeAt(e)]|=1<<e;for(let t=0;t<n;t++){const n=V[e.charCodeAt(t)],o=i[t/32|0]>>>t&1,l=r[t/32|0]>>>t&1,u=n|s,c=((n|l)&a)+a^a|n|l;let f=s|~(c|a),d=a&c;f>>>31^o&&(i[t/32|0]^=1<<t),d>>>31^l&&(r[t/32|0]^=1<<t),f=f<<1|o,d=d<<1|l,a=d|~(u|f),s=f&u}for(let e=u;e<c;e++)V[t.charCodeAt(e)]=0}let u=0,c=-1;const f=32*l,d=Math.min(32,o-f)+f;for(let e=f;e<d;e++)V[t.charCodeAt(e)]|=1<<e;let h=o;for(let t=0;t<n;t++){const n=V[e.charCodeAt(t)],s=i[t/32|0]>>>t&1,a=r[t/32|0]>>>t&1,l=n|u,f=((n|a)&c)+c^c|n|a;let d=u|~(f|c),m=c&f;h+=d>>>o-1&1,h-=m>>>o-1&1,d>>>31^s&&(i[t/32|0]^=1<<t),m>>>31^a&&(r[t/32|0]^=1<<t),d=d<<1|s,m=m<<1|a,c=m|~(l|d),u=d&l}for(let e=f;e<d;e++)V[t.charCodeAt(e)]=0;return h})(t,e)};var $=s(944);class H{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,o=H._createBuffer(n);if(e)for(let t=0;t<o.length;t++)o[t]=-1;this._data=o,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,o){if(t<e||t>n)throw new Error(`Argument ${o} (${t}) out of range (${e}, ${n})`)}copy(t,e,n){for(let o=0;o<n;o++)e[o]=t[o]}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 H(t._length);n._length=t._length,n._data=H._createBuffer(n._length),n._version=0;const o=t.lengthInInts;for(let r=0;r<o;r++)n._data[r]=t._data[r]&e._data[r];return n}static _createBuffer(t){return new Uint32Array(Math.floor((t+31)/32))}static fromValues(t){const e=new H(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 H(t);for(let o=0;o<t;++o)n.setBit(o,e(o));return n._version=0,n}static fromString(t){return H.fromSeq(t.length,e=>"1"==t.charAt(e))}static fromUint32Array(t,e){const n=new H(t);return n._data=e,n}static fromBytes(t){const e=t.length,n=new H(8*e);n._data=new Uint32Array(Math.floor((e+3)/4)),n._length=8*e;let o=0,r=0;for(;e-r>=4;)n._data[o++]=255&t[r]|(255&t[r+1])<<8|(255&t[r+2])<<16|(255&t[r+3])<<24,r+=4;return e-r==3&&(n._data[o]=(255&t[r+2])<<16),e-r==2&&(n._data[o]|=(255&t[r+1])<<8),e-r==1&&(n._data[o]|=255&t[r]),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 H(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,o=this.lengthInInts;for(let t=0;t<o;t++)this._data[t]=n;this.incrementVersion(e)}setIndexes(t,e=!0,n=!0,o=!0){n&&this.setAll(!e,!1);for(const n of t)this.setFast(n,e);this.incrementVersion(o)}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,o=!0,r=!0){if(n&&r&&this.setAll(!e,!1),r)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(o)}getRange(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const n=[];for(let o=t;o<e;++o)n.push(this.getBit(o));return H.fromValues(n)}getRangeAsList(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const n=[];for(let o=t;o<e;++o)n.push(this.getBit(o));return n}setRange(t,e,n,o=!0){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length-1,"to");const r=Math.min(t,e),i=Math.max(t,e);if(n)for(let t=r;t<=i;t++)this.setTrue(t);else for(let t=r;t<=i;t++)this.setFalse(t);return this.incrementVersion(o),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 o=this._length;this.setLength(this._length+e);for(let n=o-1;n>=t;n--)this.setBit(n+e,this.getBit(n));for(let o=t;o<t+e;o++)this.setBit(o,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 o=-1;-1!=(o=t.findNext(o,!e));)this.setFast(n++,this.getBit(o));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+=H._onBitCount[255&t];let n=this._data[e];const o=31&this._length;for(0!=o&&(n&=~(4294967295<<o));0!=n;n>>>=8)this._selectedCount+=H._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 o=this.lengthInInts;let r=0;for(;r<o-1;r++)for(let e=this._data[r]&t._data[r];0!=e;e>>>=8)n+=H._onBitCount[255&e];let i=this._data[r]&t._data[r];const s=31&this._length;for(0!=s&&(i&=~(4294967295<<s));0!=i;i>>>=8)n+=H._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 o=this.lengthInInts;for(let r=Math.floor(t/32);r<o;r++){let o=e?this._data[r]:~this._data[r];if(0!=n)o&=4294967295<<n&4294967295,n=0;else if(!e&&-4294967296==o)continue;for(let e=0;0!=o;e+=8,o>>>=8){const n=H._firstOnBit[255&o];if(n>=0)return(t=n+32*r+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 o=Math.floor(t/32);o>=0;o--){let t=e?this._data[o]:~this._data[o];0!=n&&(t&=~(4294967295<<n),n=0);for(let e=24;0!=t;e-=8,t<<=8){const n=H._lastOnBit[t>>>24];if(n>=0)return n+32*o+e}}return-1}}function q(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,o=Math.min(...Object.keys(e).map(t=>t.charCodeAt(0)))+1,r=new Float32Array((n.length+o)*(n.length+o));return Object.entries(e).forEach(([t,o])=>{const i=n[o];Object.entries(e).forEach(([e,o])=>{r[t.charCodeAt(0)*n.length+e.charCodeAt(0)]=i[o]})}),(t,e)=>1-r[t.charCodeAt(0)*n.length+e.charCodeAt(0)]}(),n=t?.threshold??0;return(t,o)=>{let r=0;const i=t.length,s=o.length,a=Math.ceil(Math.max(i,s)*(1-n));i!==s&&(r=Math.abs(i-s));let l=0;for(let n=0;n<Math.min(i,s);n++)if(t[n]!==o[n]&&(l+=e(t[n],o[n]),l>a))return 1;return l+=r,l/=Math.max(i,s),l}}H._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]),H._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]),H._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 Y={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 W;!function(t){t.HAMMING="Hamming",t.LEVENSHTEIN="Levenshtein",t.NEEDLEMANN_WUNSCH="Needlemann-Wunsch",t.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance"}(W||(W={}));const j={[W.HAMMING]:q,[W.LEVENSHTEIN]:function(){return(t,e)=>G(t,e)/Math.max(t.length,e.length)},[W.NEEDLEMANN_WUNSCH]:function(t){const e=new Uint16Array(65536),{gapOpen:n,gapExtend:o,scoringMatrix:r,alphabetIndexes:i}={...Y,...t};Object.entries(i).forEach(([t,n])=>e[t.charCodeAt(0)]=n);const s=[new Float32Array(1e4),new Float32Array(1e4)];return(t,i)=>{const a=new Array(t.length+1).fill(!1),l=new Array(t.length+1).fill(!1);let u=0,c=1;for(let e=1;e<t.length+1;e++)s[0][e]=-o-(e-1)*o,s[1][e]=0;s[0][0]=0;for(let f=1;f<i.length+1;f++){s[c][0]=-o-(f-1)*o;for(let d=1;d<t.length+1;d++){const h=s[u][d-1]+r[e[t.charCodeAt(d-1)]][e[i.charCodeAt(f-1)]],m=s[u][d]-(a[d]||1===f||f===i.length?o:n),p=s[c][d-1]-(l[d-1]||1===d||d===t.length?o:n);s[c][d]=Math.max(h,p,m),s[c][d]===h?(a[d]=!1,l[d]=!1):s[c][d]===p?(a[d]=!1,l[d]=!0):(a[d]=!0,l[d]=!1)}u=c,c=(c+1)%2}const f=Math.min(t.length,i.length);return(f-s[u][t.length])/f}},[W.MONOMER_CHEMICAL_DISTANCE]:q};function X(t,e){const n=t.trueCount()+e.trueCount();if(0==n)return 1;const o=t.andWithCountBits(e,!0);return o/(n-o)}function z(t){return t<=0?3402823e32:1/t-1}F.Tanimoto,F.Dice,F.Asymmetric,F.BraunBlanquet,F.Cosine,F.Kulczynski,F.McConnaughey,F.RogotGoldberg,F.Russel,F.Sokal,F.Hamming,F.Euclidean,F.Tanimoto,F.Dice,F.Asymmetric,F.BraunBlanquet,F.Cosine,F.Kulczynski,F.McConnaughey,F.RogotGoldberg,F.Russel,F.Sokal,F.Hamming,F.Euclidean,F.Tanimoto,F.Dice,F.Cosine,F.Tanimoto,F.Asymmetric,F.Cosine,F.Sokal,W.HAMMING,W.LEVENSHTEIN,W.MONOMER_CHEMICAL_DISTANCE,W.NEEDLEMANN_WUNSCH;const K={[R.Euclidean]:function(t,e){let n=0;for(let o=0;o<t.length;o++)n+=Math.pow(t[o]-e[o],2);return Math.sqrt(n)},[R.Manhattan]:function(t,e){let n=0;for(let o=0;o<t.length;o++)n+=Math.abs(t[o]-e[o]);return n},[R.Cosine]:function(t,e){let n=0,o=0,r=0;for(let i=0;i<t.length;i++)n+=t[i]*e[i],o+=t[i]*t[i],r+=e[i]*e[i];return(1-n/(Math.sqrt(o)*Math.sqrt(r)))/2}},Q={[P.Levenshtein]:G,[P.JaroWinkler]:$.Vb,[P.Manhattan]:function(t,e){if(t.length!==e.length)return 1;{let n=0;for(let o=1;o<t.length;o++)n+=t[o]==e[o]?0:1;return n/t.length}},[P.Onehot]:function(t,e){return t===e?0:1}},Z={[F.Tanimoto]:function(t,e){return 1-X(t,e)},[F.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)},[F.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)},[F.BraunBlanquet]:function(t,e){return z(function(t,e){const n=Math.max(t.trueCount(),e.trueCount());return 0==n?0:t.andWithCountBits(e,!0)/n}(t,e))},[F.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)},[F.Kulczynski]:function(t,e){return z(function(t,e){const n=t.trueCount()+e.trueCount(),o=t.trueCount()*e.trueCount();return 0==o?0:t.andWithCountBits(e,!0)*n/(2*o)}(t,e))},[F.McConnaughey]:function(t,e){return z(function(t,e){const n=t.trueCount()+e.trueCount(),o=t.trueCount()*e.trueCount();return 0==o?0:(t.andWithCountBits(e,!0)*n-o)/o}(t,e))},[F.RogotGoldberg]:function(t,e){return z(function(t,e){const n=t.andWithCountBits(e,!0),o=t.countBits(!0)+e.countBits(!0),r=t.length,i=r-o+n;return n==r||i==r?1:n/o+i/(2*r-o)}(t,e))},[F.Russel]:function(t,e){return z(function(t,e){return 0==t.length?0:t.andWithCountBits(e,!0)/t.length}(t,e))},[F.Sokal]:function(t,e){return 1-function(t,e){const n=t.trueCount()+e.trueCount(),o=t.andWithCountBits(e,!0);return o/(2*n-3*o)}(t,e)},[F.Hamming]:function(t,e){return t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0)},[F.Euclidean]:function(t,e){return Math.sqrt(t.trueCount()+e.trueCount()-2*t.andWithCountBits(e,!0))}},J={[D.TanimotoIntArray]:function(t,e){return z(X(new H(t,32*t.length),new H(e,32*e.length)))}},tt={[k.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)}},et={[U.CommonItems]:function(t){const e=function(t){const e=t?.mostCommon??new Set;return(t,n)=>{const o=t.length,r=n.length;let i=0,s=0,a=0;for(;s<o&&a<r;)t[s]===n[a]?(e?.has(t[s])||++i,++s,++a):t[s]<n[a]?++s:++a;return i}}(t);return(t,n)=>0===n.length||0===t.length?1e4:Math.min(t.length,n.length)/(e(t,n)+1e-4)}},nt={[B.Vector]:{[R.Euclidean]:K[R.Euclidean],[R.Manhattan]:K[R.Manhattan],[R.Cosine]:K[R.Cosine]},[B.String]:{[P.Levenshtein]:Q[P.Levenshtein],[P.JaroWinkler]:Q[P.JaroWinkler],[P.Manhattan]:Q[P.Manhattan],[P.Onehot]:Q[P.Onehot]},[B.BitArray]:{[F.Tanimoto]:Z[F.Tanimoto],[F.Dice]:Z[F.Dice],[F.Asymmetric]:Z[F.Asymmetric],[F.BraunBlanquet]:Z[F.BraunBlanquet],[F.Cosine]:Z[F.Cosine],[F.Kulczynski]:Z[F.Kulczynski],[F.McConnaughey]:Z[F.McConnaughey],[F.RogotGoldberg]:Z[F.RogotGoldberg],[F.Russel]:Z[F.Russel],[F.Sokal]:Z[F.Sokal]},[B.MacroMolecule]:{[W.HAMMING]:j[W.HAMMING],[W.LEVENSHTEIN]:j[W.LEVENSHTEIN],[W.NEEDLEMANN_WUNSCH]:j[W.NEEDLEMANN_WUNSCH],[W.MONOMER_CHEMICAL_DISTANCE]:j[W.MONOMER_CHEMICAL_DISTANCE]},[B.Number]:{[k.Difference]:tt[k.Difference]},[B.IntArray]:{[D.TanimotoIntArray]:J[D.TanimotoIntArray]},[B.NumberArray]:{[U.CommonItems]:et[U.CommonItems]}};Object.keys(nt).reduce((t,e)=>{for(const n of Object.keys(nt[e]))t[n]=e;return t},{});const ot=ui,rt="bypassLargeDataWarning";var it,st,at,lt,ut;s(5540),function(t){t.EUCLIDEAN="EUCLIDEAN",t.MANHATTAN="MANHATTAN"}(it||(it={})),it.EUCLIDEAN,it.MANHATTAN,function(t){t.HAMMING="Hamming",t.EUCLIDEAN="Euclidean",t.VECTOR_COSINE="Vector Cosine",t.MANHATTAN="Manhattan",t.TANIMOTO="Tanimoto",t.LEVENSTEIN="Levenshtein",t.NEEDLEMAN_WUNSCH="Needlemann-Wunsch",t.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance",t.SOKAL="Sokal",t.COSINE="Cosine",t.ASYMMETRIC="Asymmetric",t.Difference="Difference",t.OneHot="One-Hot"}(st||(st={})),st.HAMMING,st.EUCLIDEAN,st.MANHATTAN,st.VECTOR_COSINE,st.TANIMOTO,st.LEVENSTEIN,st.NEEDLEMAN_WUNSCH,st.MONOMER_CHEMICAL_DISTANCE,st.SOKAL,st.COSINE,st.ASYMMETRIC,st.Difference,st.OneHot,st.HAMMING,st.EUCLIDEAN,st.MANHATTAN,st.TANIMOTO,st.SOKAL,st.COSINE,st.ASYMMETRIC,st.LEVENSTEIN,st.NEEDLEMAN_WUNSCH,st.MONOMER_CHEMICAL_DISTANCE,st.Difference,st.OneHot,st.VECTOR_COSINE,new Set([st.HAMMING,st.LEVENSTEIN,st.NEEDLEMAN_WUNSCH,st.MONOMER_CHEMICAL_DISTANCE,st.OneHot]),new Set([st.HAMMING,st.EUCLIDEAN,st.MANHATTAN,st.MONOMER_CHEMICAL_DISTANCE,st.LEVENSTEIN,st.NEEDLEMAN_WUNSCH,st.TANIMOTO,st.COSINE,st.VECTOR_COSINE,st.SOKAL,st.ASYMMETRIC,st.OneHot,st.Difference]),new Set([st.EUCLIDEAN,st.MANHATTAN,st.OneHot,st.Difference,st.VECTOR_COSINE]),new Set([st.EUCLIDEAN,st.MANHATTAN,st.Difference,st.VECTOR_COSINE]),new Set([st.EUCLIDEAN,st.MANHATTAN,st.Difference]),new Set([st.TANIMOTO,st.COSINE,st.SOKAL,st.ASYMMETRIC]),function(t){t.ADD="ADD",t.SUB="SUB",t.MULT="MULT"}(at||(at={})),function(t){t.SQUARE="SQUARE",t.INVERSE="INVERSE",t.TRANSPOSE="TRANSPOSE",t.NORM="NORM",t.COLUMN_NORM="COLUMN_NORM"}(lt||(lt={})),function(t){t.SCALARMULT="SCALARMULT",t.SCALARADD="SCALARADD",t.SCALARPOW="SCALARPOW"}(ut||(ut={})),Object.prototype.toString;const ct="dimensionality-reducer-terminate-event";var ft;!function(t){t.EUCLIDEAN="EUCLIDEAN",t.MANHATTAN="MANHATTAN"}(ft||(ft={}));const dt=t=>null==t;function ht(t,e){return`${e} (${t.length>4?`${t.length} columns`:t.map(t=>t.name).join(", ")})`}async function mt(e,n,o,r,i,a,l,u=!0,c=!1,f={preprocessingFuncArgs:[]},d={},h=null,m={},p){const g={showXAxis:!1,showYAxis:!1,showXSelector:!1,showYSelector:!1};if(n.length!==r.length||n.length!==a.length||n.length!==i.length||n.length!==f.preprocessingFuncArgs.length)throw new Error("columns, metrics and preprocessing functions, weights and function argumentsmust have the same length");const v=u?d.tableView??I.shell.tableView(e.name)??I.shell.addTableView(e):null,y=async()=>{const y=t.TaskBarProgressIndicator.create(`Initializing ${d.scatterPlotName??"dimensionality reduction"} ...`);let A;try{const w=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}`)}(e);function C(r,i,s){let a=null,l=null;e.columns.names().includes(w[0])?(a=e.columns.byName(w[0]),l=e.columns.byName(w[1])):(a=e.columns.add(t.Column.float(w[0],e.rowCount)),l=e.columns.add(t.Column.float(w[1],e.rowCount)),u&&!A&&(A=v.scatterPlot({...g,x:w[0],y:w[1],title:d.scatterPlotName??ht(n,o)}))),d["show-scatterplot-progress"]&&(A?.root&&ot.setUpdateIndicator(A.root,!1),a.init(t=>s[0]?s[0][t]:void 0),l.init(t=>s[1]?s[1][t]:void 0));const c=r/i*100;y.update(c,`Running ${d.scatterPlotName??"dimensionality reduction"}... ${c.toFixed(0)}%`)}async function E(){e.columns.add(t.Column.float(w[0],e.rowCount)),e.columns.add(t.Column.float(w[1],e.rowCount));let c=null;u&&(A=v.scatterPlot({...g,x:w[0],y:w[1],title:d.scatterPlotName??ht(n,o)}),ot.setUpdateIndicator(A.root,!0));const h=I.events.onViewerClosed.subscribe(t=>{const e=t.args.viewer;e?.getOptions()?.look?.title&&A?.getOptions()?.look?.title&&e?.getOptions()?.look?.title===A?.getOptions()?.look?.title&&(I.events.fireCustomEvent(ct,{}),h.unsubscribe(),c?.(),y.close())}),m=new Promise(async(t,u)=>{try{c=t;const u=[];let h=r,m=i,g=l;if(p&&n.every(t=>t.isNumerical)){const t=n.map(t=>t.toList()),o=new Array(e.rowCount).fill(0).map((t,e)=>new Float32Array(n.length));for(let r=0;r<n.length;++r)for(let n=0;n<e.rowCount;++n)o[n][r]=t[r][n];f.distanceFnArgs=[{}],u.push({entries:o,options:{}}),h=[p],m=[1],g="MANHATTAN"}else for(let t=0;t<a.length;++t){const e=a[t];if(f.distanceFnArgs||(f.distanceFnArgs=[]),e){const o=e.inputs[0].name,i=e.inputs[1].name,{entries:s,options:a}=await e.apply({[o]:n[t],[i]:r[t],...f.preprocessingFuncArgs[t]??{}});u.push({entries:s,options:a}),f.distanceFnArgs.push(a)}else{const e=n[t].toList(),o={};u.push({entries:e,options:o}),f.distanceFnArgs.push(o)}}t(await async function(t,e,n,o,r,i,a){let l=await async function(t,e,n,o,r,i,a){if(!i.distanceFnArgs)throw new Error("options.distanceFnArgs must be defined");if(t.length!==e.length||t.length!==i.distanceFnArgs.length||t.length!==o.length)throw new Error("data, metrics and options and weights must have the same length");return new Promise(function(l,u){const c=new Worker(new URL(s.p+s.u(234),s.b));c.postMessage({columnsData:t,distanceMetrics:e,method:n,options:i,weights:o,aggregationMethod:r});const f=I.events.onCustomEvent(ct).subscribe(()=>{try{c?.terminate()}finally{f.unsubscribe()}});c.onmessage=({data:{error:t,embedding:e,epochNum:n,epochsLength:o}})=>{dt(n)||dt(o)?(f.unsubscribe(),t?u(t):l(e),setTimeout(()=>c.terminate(),100)):a&&a(n,o,e)}})}(t,n,e,o,r,i,a);return l=l.map(t=>function(t){const e=t.length;let n=0,o=0;for(let r=0;r<e;++r)n+=t[r],o+=Math.pow(t[r],2);const r=n/e,i=1/Math.sqrt(o/e-Math.pow(r,2));for(let n=0;n<e;++n)t[n]=(t[n]-r)*i;return t}(t)),l}(u.map(t=>t.entries),o,h,m,l,f,d[rt]?void 0:C))}catch(t){u(t)}}),E=await m;return y.close(),h.unsubscribe(),E}const b=await E();if(c&&b){const x=t.TaskBarProgressIndicator.create("Clustering embeddings ...");try{const _=await function(t,e,n,o){return r=this,i=void 0,l=function*(){return new Promise(function(r,i){const a=new Worker(new URL(s.p+s.u(682),s.b));a.postMessage({embedX:t,embedY:e,minPts:o,epsilon:n}),a.onmessage=({data:{error:t,clusters:e}})=>{a.terminate(),t?i(t):r(e)}})},new((a=void 0)||(a=Promise))(function(t,e){function n(t){try{s(l.next(t))}catch(t){e(t)}}function o(t){try{s(l.throw(t))}catch(t){e(t)}}function s(e){var r;e.done?t(e.value):(r=e.value,r instanceof a?r:new a(function(t){t(r)})).then(n,o)}s((l=l.apply(r,i||[])).next())});var r,i,a,l}(b[0],b[1],f.dbScanEpsilon??.01,f.dbScanMinPts??4),N=e.columns.getUnusedName("Cluster (DBSCAN)");e.columns.addNewString(N).init(t=>_[t].toString()),A&&(A.props.colorColumnName=N)}catch(M){I.shell.error("Clustering embeddings failed"),console.error(M)}finally{x.close()}}if(b){const T=e.columns.byName(w[0]),S=e.columns.byName(w[1]);if(T.init(t=>b[0][t]),S.init(t=>b[1][t]),h)try{const O=h.inputs[0].name,L=h.inputs[1].name;await h.prepare({[O]:T,[L]:S,...m}).call(!0)}catch(P){I.shell.error("Post-processing failed"),console.error(P)}if(A)return ot.setUpdateIndicator(A.root,!1),A.helpUrl="/help/compute/sequence-space",A}}catch(R){I.shell.error("Dimensionality reduction failed"),console.error(R),y.close(),A&&ot.setUpdateIndicator(A.root,!1)}};return new Promise(async(t,n)=>{try{if(d.fastRowCount&&e.rowCount>d.fastRowCount&&!d[rt])ot.dialog().add(ot.divText("Analysis might take several minutes. Do you want to continue?")).onOK(async()=>{try{const e=await y();t(e)}catch(t){n(t)}}).onCancel(()=>t(void 0)).show();else{const e=await y();t(e)}}catch(t){n(t)}})}var pt=function(t,e,n,o){return new(n||(n=Promise))(function(r,i){function s(t){try{l(o.next(t))}catch(t){i(t)}}function a(t){try{l(o.throw(t))}catch(t){i(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(s,a)}l((o=o.apply(t,e||[])).next())})};const gt={SUBJ:"subj",STUDY:"study",SITE:"site",AGE:"age",SEX:"sex",RACE:"race",DISEASE:"disease",WEIGHT:"weight",HEIGHT:"height"};function vt(t,e,n){return pt(this,void 0,void 0,function*(){const o=I.data.demo.demog(100);I.shell.addTableView(o),E(!!(yield mt(o,t.map(t=>o.col(t)),e,n,t.map(()=>1),t.map(()=>{}),"EUCLIDEAN",!0,!0,{preprocessingFuncArgs:t.map(()=>({}))})),!0,"No scatterplot returned");const r=o.columns.names().filter(t=>t.toLowerCase().startsWith("embed"));E(r.length,2,"Wrong number of embeddings added"),E(!!o.columns.names().find(t=>t.toLowerCase().startsWith("cluster")),!0,"No cluster column added");for(const t of r){const e=o.col(t);E(new Array(e.length).fill(null).every((t,n)=>!e.isNone(n)&&!isNaN(e.get(n))),!0,"Embedding column has null-ish values")}yield new Promise(t=>setTimeout(t,500))})}b("Dimensionality reduction: UMAP",()=>{C("Numeric column",()=>pt(void 0,void 0,void 0,function*(){yield vt([gt.AGE],L.UMAP,[k.Difference])}),{timeout:3e4}),C("String column",()=>pt(void 0,void 0,void 0,function*(){yield vt([gt.SEX],L.UMAP,[P.Onehot])}),{timeout:3e4}),C("Numeric and string columns",()=>pt(void 0,void 0,void 0,function*(){yield vt([gt.SEX,gt.AGE],L.UMAP,[P.Onehot,k.Difference])})),C("All demog columns",()=>pt(void 0,void 0,void 0,function*(){const e=I.data.demo.demog(10).columns.toList().filter(t=>Object.values(gt).includes(t.name)),n=e.map(e=>e.type===t.COLUMN_TYPE.STRING?P.Onehot:k.Difference),o=e.map(t=>t.name);yield vt(o,L.UMAP,n)}))}),b("Dimensionality reduction: T-SNE",()=>{C("Numeric column",()=>pt(void 0,void 0,void 0,function*(){yield vt([gt.AGE],L.T_SNE,[k.Difference])}),{timeout:3e4}),C("String column",()=>pt(void 0,void 0,void 0,function*(){yield vt([gt.SEX],L.T_SNE,[P.Onehot])}),{timeout:3e4}),C("Numeric and string columns",()=>pt(void 0,void 0,void 0,function*(){yield vt([gt.SEX,gt.AGE],L.T_SNE,[P.Onehot,k.Difference])})),C("All demog columns",()=>pt(void 0,void 0,void 0,function*(){const e=I.data.demo.demog(10).columns.toList().filter(t=>Object.values(gt).includes(t.name)),n=e.map(e=>e.type===t.COLUMN_TYPE.STRING?P.Onehot:k.Difference),o=e.map(t=>t.name);yield vt(o,L.T_SNE,n)}))});const yt={i32:"HEAP32",f32:"HEAPF32"},At={i32:Int32Array,f32:Float32Array},wt={i32:2,f32:2},Ct={i32:DG.Column.fromInt32Array,f32:DG.Column.fromFloat32Array};class Et{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 bt extends Et{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*At[this.type].BYTES_PER_ELEMENT)}isMemoryForBufferAllocated(){return 0!=this.buf}putDataToBuffer(t){if(this.isMemoryForBufferAllocated()){const e=this.type,n=wt[e],o=t[yt[e]];let r=null;const i=this.data;r="int"==i.type&&"i32"==e||"double"==i.type&&"f32"==e?i.getRawData():new At[e](i.getRawData()),r&&o.set(r,this.buf>>n)}}getDataFromBuffer(t){if(this.toUpdate&&this.isMemoryForBufferAllocated()){const e=this.type,n=t[yt[e]],o=this.buf,r=At[e].BYTES_PER_ELEMENT,i=this.data.getRawData();for(let t=0;t<this.numOfRows;t++)i[t]=n[o/r+t]}}freeBuffer(t){this.isMemoryForBufferAllocated()&&(t._free(this.buf),this.buf=0)}}class xt extends bt{constructor(t,e){super([],t,!0),this.numOfRows=e}putDataToBuffer(t){}getDataFromBuffer(t){if(this.toUpdate&&this.isMemoryForBufferAllocated()){const e=this.type,n=t[yt[e]],o=this.buf,r=Ct[e],i=new At[e](this.numOfRows);for(let t=0;t<i.length;t++)i[t]=n[o/i.BYTES_PER_ELEMENT+t];this.data=r("name",i)}}}class _t extends Et{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*At[this.type].BYTES_PER_ELEMENT)}isMemoryForBufferAllocated(){return 0!=this.buf}putDataToBuffer(t){if(this.isMemoryForBufferAllocated()){const e=this.type,n=wt[e],o=t[yt[e]],r=At[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 At[e](s.getRawData()),null!=i&&o.set(i,this.buf+t*this.numOfRows*r>>n)}}}getDataFromBuffer(t){if(this.toUpdate&&this.isMemoryForBufferAllocated()){const e=this.type,n=t[yt[e]],o=this.numOfRows,r=this.numOfColumns,i=new At[e](n.buffer,this.buf,o*r);for(let t=0;t<r;t++){const e=this.data[t].getRawData();for(let n=0;n<o;n++)e[n]=i[n+t*o]}}}freeBuffer(t){this.isMemoryForBufferAllocated()&&(t._free(this.buf),this.buf=0)}}class Nt extends _t{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[yt[e]],o=this.numOfRows,r=this.numOfColumns,i=At[e].BYTES_PER_ELEMENT,s=Ct[e],a=this.buf;for(let t=0;t<r;t++){const r=new At[e](o);for(let e=0;e<o;e++)r[e]=n[a/i+e+t*o];this.data.push(s((t+1).toString(),r))}}}}const Mt={intColumn:t=>new bt(t,"i32"),newIntColumn:t=>new xt("i32",t),intColumns:t=>new _t(t.toList(),"i32"),newIntColumns:(t,e)=>new Nt("i32",t,e),floatColumn:t=>new bt(t,"f32"),newFloatColumn:t=>new xt("f32",t),floatColumns:t=>new _t(t.toList(),"f32"),newFloatColumns:(t,e)=>new Nt("f32",t,e),int:t=>new Et(t),num:t=>new Et(t)},Tt={tableFromColumns:t=>DG.DataFrame.fromColumns(t.data),num:t=>t,int:t=>t,double:t=>t,column:t=>t.data};function St(t,e,n){const o=t[e],r=o.arguments,i=[];let s=0;for(const t in r){const e=r[t];if("_callResult"!=t){switch(e.type){case"floatColumns":case"int":case"num":case"floatColumn":case"intColumn":case"intColumns":e.data=Mt[e.type](n[s]),s++;break;case"newFloatColumns":case"newIntColumns":const t=r[e.numOfRows.ref].data[e.numOfRows.value],o=r[e.numOfColumns.ref].data[e.numOfColumns.value];e.data=Mt[e.type](t,o);break;case"newFloatColumn":case"newIntColumn":const i=r[e.numOfRows.ref].data[e.numOfRows.value];e.data=Mt[e.type](i)}i.push(r[t].data)}}const a=function(t,e,n,o){let r;for(const e of o)e.allocateMemoryForBuffer(t);let i=!0;for(const t of o)i&=t.isMemoryForBufferAllocated();if(i){const n=[],i=[];for(const e of o)e.complementArrOfParams(n),e.complementArrOfTypes(i),e.putDataToBuffer(t);const s="number";r=t.ccall(e,s,i,n);for(const e of o)e.getDataFromBuffer(t)}for(const e of o)e.freeBuffer(t);if(null!=r)return r}(t,e,0,i);r._callResult=Mt.num(a);const l=o.output;if("objects"!=l.type)return Tt[l.type](r[l.source].data);const u=[];for(const t of l.source)u.push(r[t].data.data);return u}const Ot="num",It="floatColumn",Lt="intColumn",Pt="floatColumns",Rt="newFloatColumns",Ft="intColumns",Dt="newIntColumns",Bt="newFloatColumn",kt="newIntColumn",Ut="numOfRows",Vt="numOfColumns",Gt="ref",$t="value",Ht="int",qt="double",Yt={intColumn:Int32Array,floatColumn:Float32Array,floatColumns:Float32Array,newFloatColumns:Float32Array,intColumns:Int32Array,newIntColumns:Int32Array,newFloatColumn:Float32Array,newIntColumn:Int32Array};function Wt(t,e){let n,o=[],r=0;for(const i in t){const s=t[i],a=s.type;if("_callResult"!==i){switch(a){case Ot:case Ht:case qt:s.data=e[r],r++;break;case Lt:case It:let o;const i=e[r],l=i.length;o=i.type===Ht&&a===Lt||i.type===qt&&a===It?i.getRawData().slice(0,l):new Yt[a](i.getRawData().slice(0,l)),s.data={array:o,numOfRows:l},r++;break;case kt:case Bt:let u=0;n=s[Ut][Gt],u=t[n].type===Ot?t[n].data:t[n].data[s[Ut][$t]],s.data={numOfRows:u},r++;break;case Ft:case Pt:let c=[];const f=e[r].byIndex(0).length;for(const t of e[r].toList())t.type===Ht&&a===Lt||t.type===qt&&a===It?c.push(t.getRawData().slice(0,f)):c.push(new Yt[a](t.getRawData().slice(0,f)));s.data={arrays:c,numOfRows:f,numOfColumns:c.length},r++;break;case Dt:case Rt:let d=0,h=0;n=s[Ut][Gt],d=t[n].type===Ot?t[n].data:t[n].data[s[Ut][$t]],n=s[Vt][Gt],h=t[n].type===Ot?t[n].data:t[n].data[s[Vt][$t]],s.data={numOfRows:d,numOfColumns:h},r++;break;default:return}o.push(s)}}return o}function jt(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 o=0;for(const r in t){const i=t[r];switch(i.type){case Ot:case Ht:case qt:case Lt:case It:case Pt:case Ft:break;case Bt:case kt:let t;null==i.name?t=(0).toString():a=i.name,i.column=n[i.type](t,e[o].array);break;case Dt:case Rt:let r=[],s=e[o].arrays.length,a=[];if(null==i.names)for(let t=1;t<=s;t++)a.push(t.toString());else a=i.names;for(let t=0;t<s;t++)r.push(n[i.type](a[t],e[o].arrays[t]));i.columns=r}o++}}(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 Ot:case Ht:case qt:return t.arguments[e.source];case"column":return t.arguments[e.source].column;case"tableFromColumns":return DG.DataFrame.fromColumns(t.arguments[e.source].columns);case"objects":let o=[];for(let r of e.source){let e=t.arguments[r];o.push(e[n[e.type]])}return o}}(t);return function(t){for(const e in t){const n=t[e];switch(n.type){case Ot:case Ht:case qt:case Lt:case It:case Ft:case Pt:break;case kt:case Bt:n.column=null;break;case Dt:case Rt:n.columns=null}}}(t.arguments),n}async function Xt(t,e,n){return new Promise((t,o)=>{const r=new Worker(new URL(s.p+s.u(128),s.b));r.postMessage(Wt(EDA.principalComponentAnalysisNipals.arguments,[e,n])),r.onmessage=function(e){r.terminate(),t(jt(EDA.principalComponentAnalysisNipals,e.data))}})}const zt=1e-6;function Kt(e){if(e.type!=t.COLUMN_TYPE.FLOAT&&e.type!=t.COLUMN_TYPE.INT)throw new Error("unsupported column type: "+e.type)}function Qt(t){if(t.stats.missingValueCount>0)throw new Error(`The column '${t.name}' has missing values.`)}function Zt(t,e){if(function(t,e){if(e<1)throw new Error("components must be positive.");if(e>t.length)throw new Error("components must not be greater than features count.");for(const e of t)Kt(e),Qt(e)}(t,e),t.length*t.byIndex(0).length>1e8)throw new Error("dataframe is too big.")}function Jt(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,o=n.stats.avg,r=n.getRawData();if(t>0)for(let n=0;n<e;++n)r[n]=(r[n]-o)/t;else for(let t=0;t<e;++t)r[t]-=o}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)>zt){const o=n.getRawData();for(let n=0;n<e;++n)o[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)>zt&&t>0){const o=n.getRawData();for(let n=0;n<e;++n)o[n]/=t}}return t}(t):t}var te,ee,ne,oe,re,ie,se,ae;function le(e,n,o,r,i){return a=this,l=void 0,c=function*(){Zt(n,o);const a=e.rowCount,l=function(e){const n=[];for(const t of e)t.stats.stdev>0&&t.stats.missingValueCount<1&&n.push(t);return t.DataFrame.fromColumns(n)}(n),u=l.columns.length;if(0===u){const e=[];for(let n=0;n<o;++n)e.push(t.Column.fromFloat32Array(`${n+1}`,new Float32Array(a).fill(0)));return t.DataFrame.fromColumns(e)}const c=u<o?o-u:0,f=Math.min(o,u);let d;if(u>900)d=yield Xt(0,n,f);else{const t=yield async function(t,e,n){return new Promise((t,o)=>{const r=new Worker(new URL(s.p+s.u(860),s.b));r.postMessage(Wt(EDA.principalComponentAnalysis.arguments,[e,n,1,0])),r.onmessage=function(e){r.terminate(),0===e.data.callResult?t(jt(EDA.principalComponentAnalysis,e.data)):t(-1)}})}(0,n,f);d=-1!==t?Jt(t,r,i):yield Xt(0,n,f)}if(void 0===d)throw new Error("Failed to compute PCA");d=Jt(d,r,i);const h=d.columns,m=h.length;for(let e=0;e<c;++e)h.add(t.Column.fromFloat32Array(`${m+e+1}`,new Float32Array(a).fill(0)));return d},new((u=void 0)||(u=Promise))(function(t,e){function n(t){try{r(c.next(t))}catch(t){e(t)}}function o(t){try{r(c.throw(t))}catch(t){e(t)}}function r(e){var r;e.done?t(e.value):(r=e.value,r instanceof u?r:new u(function(t){t(r)})).then(n,o)}r((c=c.apply(a,l||[])).next())});var a,l,u,c}!function(t){t[t.COMPUTE_COMPONENTS=0]="COMPUTE_COMPONENTS",t[t.PERFORM_MVA=1]="PERFORM_MVA",t[t.DEMO=2]="DEMO"}(te||(te={})),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.COMP_ROWS="Components count must not exceed the number of rows",t.COMPONENTS="Components count must be at least 1",t.INV_INP="Invalid inputs",t.NULL_COMPS="Components count is not specified"}(ee||(ee={})),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",t.BIAS="bias"}(ne||(ne={})),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"}(oe||(oe={})),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"}(re||(re={})),function(t){t[t.DEFAULT=3]="DEFAULT",t[t.MIN=1]="MIN"}(ie||(ie={})),function(t){t.PREFIX="PLS",t.SUFFIX="(predicted)",t.COMP="component",t.COMPS="components"}(se||(se={})),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"}(ae||(ae={}));const ue=[.49,.79,.99];var ce;!function(t){t.AXIS="#838383",t.CIRCLE="#0000FF",t.INVALID="#EB6767",t.VALID_TEXT="#4d5261",t.VALID_LINE="#dbdcdf"}(ce||(ce={})),[{caption:ne.MODEL,text:"Closer to the line means better price prediction."},{caption:ne.SCORES,text:"The latent factor values for each sample reflect the similarities and dissimilarities among observations."},{caption:ne.LOADINGS,text:"The impact of each feature on the latent factors: higher loading means stronger influence."},{caption:ne.REGR_COEFS,text:"Parameters of the obtained model: features make different contribution to the prediction."},{caption:ne.EXPL_VAR,text:"How well the latent components fit source data: closer to one means better fit."}].map(t=>`# ${t.caption}\n\n${t.text}`).join("\n\n"),re.MVA;function fe(t){return e=this,n=void 0,r=function*(){Zt(t.features,t.components),Kt(t.predict),Qt(t.predict);const e=yield async function(t,e,n,o){return new Promise((t,r)=>{const i=new Worker(new URL(s.p+s.u(412),s.b));i.postMessage(Wt(EDA.partialLeastSquareRegression.arguments,[e,n,o])),i.onmessage=function(e){i.terminate(),t(jt(EDA.partialLeastSquareRegression,e.data))}})}(t.table,t.features,t.predict,t.components);return{prediction:e[ae.PREDICTION],regressionCoefficients:e[ae.REGR_COEFFS],tScores:e[ae.T_SCORES],uScores:e[ae.U_SCORES],xLoadings:e[ae.X_LOADINGS],yLoadings:e[ae.Y_LOADINGS]}},new((o=void 0)||(o=Promise))(function(t,i){function s(t){try{l(r.next(t))}catch(t){i(t)}}function a(t){try{l(r.throw(t))}catch(t){i(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o(function(t){t(n)})).then(s,a)}l((r=r.apply(e,n||[])).next())});var e,n,o,r}Math.min,Math.max;var de=function(t,e,n,o){return new(n||(n=Promise))(function(r,i){function s(t){try{l(o.next(t))}catch(t){i(t)}}function a(t){try{l(o.throw(t))}catch(t){i(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(s,a)}l((o=o.apply(t,e||[])).next())})};function he(e,n){return de(this,void 0,void 0,function*(){const o=e.length,r=n.length,i=n.stats.avg,s=n.stats.stdev,a=new Float32Array(o+1).fill(0);if(a[o]=i,0===s||1===r)return a;try{const r=[],l=[],u=new Float32Array(o),c=new Float32Array(o);let f=0,d=0;for(const t of e){const e=t.stats;e.stdev>0&&(r.push(f),l.push(t),u[d]=e.avg,c[d]=e.stdev,++d),++f}if(0===d)return a;const h=function(t,e,n,o,r,i,s){return St(EDA,"fitLinearRegressionParamsWithDataNormalizing",[t,e,n,o,r,i,s])}(t.DataFrame.fromColumns(l).columns,t.Column.fromFloat32Array("xAvgs",u,d),t.Column.fromFloat32Array("xStdevs",c,d),n,i,s,d+1).getRawData();for(let t=0;t<d;++t)a[r[t]]=h[t];a[o]=h[d]}catch(r){const i=yield function(e,n,o){return de(this,void 0,void 0,function*(){return(yield fe({table:t.DataFrame.fromColumns([n]),features:e,predict:n,components:o,names:void 0,isQuadratic:!1})).regressionCoefficients.getRawData()})}(e,n,pe(e.length,n.length));let s=0;for(let t=0;t<o;++t)a[t]=i[t],s+=i[t]*e.byIndex(t).stats.avg;a[o]-=s}return a})}function me(e,n){const o=e.length;if(o!==n.length-1)throw new Error("Incorrect parameters count");const r=e.byIndex(0),i=r.length,s=new Float32Array(i);let a=r.getRawData();const l=n[o];let u=n[0];for(let t=0;t<i;++t)s[t]=l+u*a[t];for(let t=1;t<o;++t){a=e.byIndex(t).getRawData(),u=n[t];for(let t=0;t<i;++t)s[t]+=u*a[t]}return t.Column.fromFloat32Array(e.getUnusedName("prediction"),s,i)}const pe=(t,e)=>e<=t?Math.min(10,e):Math.min(10,t);var ge;!function(t){t[t.MAX_SAMLPES=1e5]="MAX_SAMLPES",t[t.MAX_FEATURES=1e3]="MAX_FEATURES"}(ge||(ge={}));class ve{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<=ge.MAX_FEATURES&&e.length<=ge.MAX_SAMLPES}constructor(e){if(this.specn=null,e)try{const n=new Uint32Array(e.buffer,0,2),o=n[0],r=n[1],i=new Uint8Array(e.buffer,8,o),s=t.DataFrame.fromByteArray(i),a=s.rowCount,l=s.columns,u=l.length,c=new Uint8Array(e.buffer,8+o,r),f=t.DataFrame.fromByteArray(c);if(u<3)throw new Error("incorrect columns count");const d=l.byName(ne.FEATURES).toList(),h=new Float32Array(a);h.set(l.byName(ne.REGR_COEFS).getRawData());const m=u-2,p=new Array(m);for(let t=0;t<m;++t)p[t]=new Float32Array(a),p[t].set(l.byIndex(t+2).getRawData());this.specn={params:h,loadings:p,names:d,dim:a-1,components:u-2,scores:f}}catch(t){throw new Error(`Failed to load model: ${t instanceof Error?t.message:"the platform issue"}`)}}fit(e,n,o){return r=this,i=void 0,a=function*(){const r=yield fe({table:t.DataFrame.fromColumns([n]),features:e,predict:n,components:o,names:void 0,isQuadratic:!1}),i=e.names();i.push("_");const s=this.getRegrCoeffs(e,n,r.regressionCoefficients),a=this.getLoadings(o,r.xLoadings);this.specn={names:i,params:s,loadings:a,components:o,dim:e.length,scores:this.getScoresDf(r)},this.computeExplVars(n.length,o,r.yLoadings)},new((s=void 0)||(s=Promise))(function(t,e){function n(t){try{l(a.next(t))}catch(t){e(t)}}function o(t){try{l(a.throw(t))}catch(t){e(t)}}function l(e){var r;e.done?t(e.value):(r=e.value,r instanceof s?r:new s(function(t){t(r)})).then(n,o)}l((a=a.apply(r,i||[])).next())});var r,i,s,a}getLoadings(t,e){const n=Array(t),o=e[0].length+1;for(let r=0;r<t;++r)n[r]=new Float32Array(o),n[r].set(e[r].getRawData());return n}getRegrCoeffs(t,e,n){const o=t.length,r=new Float32Array(o+1),i=n.getRawData();let s=0;for(let e=0;e<o;++e)r[e]=i[e],s+=i[e]*t.byIndex(e).stats.avg;return r[o]=e.stats.avg-s,r}computeExplVars(t,e,n){if(null===this.specn)throw new Error("Failed to compute explained variances");const o=n.getRawData(),r=this.specn.loadings[0].length-1;let i=Math.pow(o[0],2)/t;this.specn.loadings[0][r]=i;for(let n=1;n<e;++n)i+=Math.pow(o[n],2)/t,this.specn.loadings[n][r]=i}toBytes(){if(null===this.specn)throw new Error("Failed to pack untrained model");const e=t.DataFrame.fromColumns([t.Column.fromStrings(ne.FEATURES,this.specn.names),t.Column.fromFloat32Array(ne.REGR_COEFS,this.specn.params)]);this.specn.loadings.forEach((n,o)=>e.columns.add(t.Column.fromFloat32Array(`${ne.XLOADING}${o+1}`,n)));const n=e.toByteArray(),o=n.length,r=this.specn.scores.toByteArray(),i=r.length,s=o+i+8,a=new Uint8Array(64*(Math.ceil(s/64)+1)),l=new Uint32Array(a.buffer,0,2);return l[0]=o,l[1]=i,a.set(n,8),a.set(r,8+o),a}predict(t){if(null===this.specn)throw new Error("Predicting failed: model is not trained");return me(t,this.specn.params)}loadingsParamsViewers(){if(null===this.specn)throw new Error("Failed to create loadings and parameters viewers: untrained model");const e=[],n=this.specn.dim,o=t.DataFrame.fromColumns([t.Column.fromStrings(ne.FEATURES,this.specn.names.slice(0,-1)),t.Column.fromFloat32Array(ne.REGR_COEFS,this.specn.params,n)]),r=o.columns,i=r.length,s=this.specn.components;return this.specn.loadings.forEach((e,r)=>o.columns.add(t.Column.fromFloat32Array(`${ne.XLOADING}${r+1}`,e,n))),e.push(t.Viewer.scatterPlot(o,{title:ne.LOADINGS,xColumnName:r.byIndex(i).name,yColumnName:r.byIndex(i+(s>1?1:0)).name,markerType:t.MARKER_TYPE.CIRCLE,labelFormColumnNames:[ne.FEATURES],help:re.LOADINGS})),e.push(t.Viewer.barChart(o,{title:ne.REGR_COEFS,splitColumnName:ne.FEATURES,valueColumnName:ne.REGR_COEFS,valueAggrType:t.AGG.AVG,help:re.COEFFS,showValueSelector:!1,showStackSelector:!1})),e}explVarsViewer(){if(null===this.specn)throw new Error("Failed to create exaplained variances viewer: untrained model");const e=this.specn.components,n=this.specn.dim,o=new Array(e),r=new Float32Array(e);o[0]=`${se.COMP} 1`,r[0]=this.specn.loadings[0][n];for(let t=1;t<e;++t)o[t]=`${se.COMPS} ${t+1}`,r[t]=this.specn.loadings[t][n];return t.Viewer.barChart(t.DataFrame.fromColumns([t.Column.fromStrings(se.COMPS,o),t.Column.fromFloat32Array(ne.EXPL_VAR,r)]),{title:ne.EXPL_VAR,splitColumnName:se.COMPS,valueColumnName:ne.EXPL_VAR,valueAggrType:t.AGG.AVG,help:re.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(e){const n=e.tScores,o=e.uScores;return n.forEach((t,e)=>t.name=`${ne.XSCORE}${e+1}`),o.forEach((t,e)=>t.name=`${ne.YSCORE}${e+1}`),t.DataFrame.fromColumns(n.concat(o))}getScoresScatter(){if(null===this.specn)throw new Error("Failed to create scores scatter: untrained model");const e=this.specn.scores.columns.names(),n=t.Viewer.scatterPlot(this.specn.scores,{title:ne.SCORES,xColumnName:e[0],yColumnName:e[1],markerType:t.MARKER_TYPE.CIRCLE,help:re.SCORES,showViewerFormulaLines:!0});return n.meta.formulaLines.addAll(function(t){const e=[],n=(t,n)=>{e.push({type:"line",formula:t,width:1,visible:!0,title:" ",min:-n,max:n,color:ce.CIRCLE})};return t.forEach(o=>{const r="${"+o+"}";e.push({type:"line",formula:`${r} = 0`,width:1,visible:!0,title:" ",color:ce.AXIS}),t.forEach(t=>{const e="${"+t+"}";ue.forEach(t=>{n(e+` = sqrt(${t*t} - ${r} * ${r})`,t),n(e+` = -sqrt(${t*t} - ${r} * ${r})`,t)})})}),e}(e)),n}}const ye=["Alpha","Beta","Gamma","Delta"];function Ae(t,e){if(t.length!==e.length)throw new Error(`Non-equal elements count: ${t.length} vs. ${e.length}`)}function we(e,n,o){const r=I.data.demo.randomWalk(e,n),i=r.columns,s=new Float32Array(n),a=new Array(n);for(let t=0;t<n;++t)a[t]=i.byIndex(t).getRawData();for(let r=0;r<o;++r){const o=new Float32Array(e);for(let t=0;t<n;++t)s[t]=Math.random();for(let t=0;t<e;++t)for(let e=0;e<n;++e)o[t]+=s[e]*a[e][t];i.add(t.Column.fromFloat32Array(`y${r}`,o))}return r}function Ce(t,e){Ae(t,e);let n=0;const o=t.length,r=t.getRawData(),i=e.getRawData();for(let t=0;t<o;++t)n=Math.max(n,Math.abs(r[t]-i[t]));return n}function Ee(e,n,o){const r=new Array(e),i=new Array(n);for(let t=0;t<n;++t){const n=new Float32Array(e);for(let t=0;t<e;++t)n[t]=Math.random();i[t]=n}const s=t.DataFrame.fromColumns(i.map((e,n)=>t.Column.fromFloat32Array(`#${n}`,e)));for(let t=0;t<e;++t)r[t]=i.slice(0,2).map(e=>e[t]>.5?"A":"B").join("");if(s.columns.add(t.Column.fromStrings("Labels",r)),o)for(let t=0;t<n;++t)for(let n=0;n<e;++n)i[t][n]+=1*(i[t][n]>0?1:-1);return s}function be(t,e){Ae(t,e);let n=0;const o=t.length;if(o<1)return 1;for(let r=0;r<o;++r)t.get(r)===e.get(r)&&++n;return n/o}var xe=function(t,e,n,o){return new(n||(n=Promise))(function(r,i){function s(t){try{l(o.next(t))}catch(t){i(t)}}function a(t){try{l(o.throw(t))}catch(t){i(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(s,a)}l((o=o.apply(t,e||[])).next())})};const _e=100,Ne=9e3,Me=.1;b("Principal component analysis",()=>{C("Performance: 100K rows, 100 cols, 3 components",()=>xe(void 0,void 0,void 0,function*(){const t=I.data.demo.randomWalk(1e5,_e);yield le(t,t.columns,3,!1,!1)}),{timeout:Ne,benchmark:!0}),C("Performance: 1K rows, 5K cols, 3 components",()=>xe(void 0,void 0,void 0,function*(){const t=I.data.demo.randomWalk(1e3,5e3);yield le(t,t.columns,3,!1,!1)}),{timeout:Ne,benchmark:!0}),C("Correctness",()=>xe(void 0,void 0,void 0,function*(){const t=we(100,3,5);E(function(t){let e=0;const n=t.length,o=t.getRawData();for(let t=0;t<n;++t)e=Math.max(e,Math.abs(o[t]));return e}((yield le(t,t.columns,4,!1,!1)).columns.byIndex(3))<Me,!0,"Incorrect PCA computations")}),{timeout:Ne})}),b("Partial least squares regression",()=>{C("Performance: 100K rows, 100 cols, 3 components",()=>xe(void 0,void 0,void 0,function*(){const t=I.data.demo.randomWalk(1e5,_e),e=t.columns;yield fe({table:t,features:e,predict:e.byIndex(99),components:3,names:void 0,isQuadratic:!1})}),{timeout:Ne,benchmark:!0}),C("Correctness",()=>xe(void 0,void 0,void 0,function*(){const t=we(100,3,5),e=t.columns,n=e.byIndex(7),o=Ce(n,(yield fe({table:t,features:e,predict:n,components:3,isQuadratic:!1,names:void 0})).prediction);E(o<Me,!0,`Incorrect PLS computations, error is too big: ${o}; expected: < 0.1`)}),{timeout:Ne}),C("Predictive modeling: 100K samples, 100 features, 3 components",()=>xe(void 0,void 0,void 0,function*(){const t=we(1e5,3,98).columns,e=t.byIndex(_e);t.remove(e.name);const n=new ve;yield n.fit(t,e,3);const o=n.toBytes(),r=Ce(e,new ve(o).predict(t));E(r<Me,!0,`Incorrect PLS (ML) computations, error is too big: ${r}; expected: < 0.1`)}),{timeout:Ne,benchmark:!0})}),b("Linear regression",()=>{C("Performance: 100K samples, 100 features",()=>xe(void 0,void 0,void 0,function*(){const t=we(1e5,_e,1).columns,e=t.byIndex(_e),n=yield he(t,e),o=new Uint8Array(n.buffer);me(t,new Float32Array(o.buffer))}),{timeout:Ne,benchmark:!0}),C("Correctness",()=>xe(void 0,void 0,void 0,function*(){const t=we(100,2,1).columns,e=t.byIndex(2),n=yield he(t,e),o=new Uint8Array(n.buffer),r=me(t,new Float32Array(o.buffer)),i=Ce(r,r);E(i<Me,!0,`Incorrect linear regression computations, error is too big: ${i}; expected: < 0.1`)}),{timeout:Ne})});var Te=function(t,e,n,o){return new(n||(n=Promise))(function(r,i){function s(t){try{l(o.next(t))}catch(t){i(t)}}function a(t){try{l(o.throw(t))}catch(t){i(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(s,a)}l((o=o.apply(t,e||[])).next())})};const Se="Avg-s",Oe="Stddev-s";var Ie;!function(t){t[t.MAX_SAMLPES=5e4]="MAX_SAMLPES",t[t.MAX_FEATURES=100]="MAX_FEATURES"}(Ie||(Ie={}));class Le{static isApplicable(e,n){for(const t of e)if(!t.matches("numerical"))return!1;return n.type===t.COLUMN_TYPE.STRING}static isInteractive(t,e){return t.length<=Ie.MAX_FEATURES&&e.length<=Ie.MAX_SAMLPES}constructor(e,n){if(this.params=void 0,this.classesCount=1,this.featuresCount=1,void 0!==e){const t=e.featuresCount,n=e.classesCount;if(t<1)throw new Error("Incorrect features count");if(n<1)throw new Error("Incorrect classes count");const o=t+1;this.avgs=new Float32Array(o),this.stdevs=new Float32Array(o),this.categories=new Array(o),this.featuresCount=t,this.classesCount=n}else{if(void 0===n)throw new Error("Softmax classifier not initialized");try{const e=new Uint32Array(n.buffer,0,1)[0],o=new Uint8Array(n.buffer,4,e),r=t.DataFrame.fromByteArray(o),i=r.columns,s=i.length;if(s<3)throw new Error("incorrect columns count");this.classesCount=s-2,this.featuresCount=r.rowCount-1;const a=this.classesCount;this.params=new Array(a),this.categories=new Array(r.rowCount);for(let e=0;e<a;++e){const n=i.byIndex(e);if(this.categories[e]=n.name,n.type!==t.COLUMN_TYPE.FLOAT)throw new Error(`Incorrect input column type. Expected: float, passed: ${n.type}`);this.params[e]=n.getRawData()}const l=i.byName(Se);if(l.type!==t.COLUMN_TYPE.FLOAT)throw new Error("incorrect average values column type");this.avgs=l.getRawData();const u=i.byName(Oe);if(u.type!==t.COLUMN_TYPE.FLOAT)throw new Error("incorrect standard deviations column type");this.stdevs=u.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 e=this.classesCount,n=new Array(e+2);for(let o=0;o<e;++o)n[o]=t.Column.fromFloat32Array(this.categories[o],this.params[o]);n[e]=t.Column.fromFloat32Array(Se,this.avgs),n[e+1]=t.Column.fromFloat32Array(Oe,this.stdevs);const o=t.DataFrame.fromColumns(n).toByteArray(),r=o.length,i=new Uint8Array(r+4);return new Uint32Array(i.buffer,0,1)[0]=r,i.set(o,4),i}fit(e,n){return Te(this,arguments,void 0,function*(e,n,o=1,r=100,i=.1,s=.001){if(e.length!==this.featuresCount)throw new Error("Training failes - incorrect features count");if(o<=0||r<1||i<=0||s<=0)throw new Error("Training failes - incorrect fitting hyperparameters");this.extractStats(e);const a=n.length,l=n.categories.length,u=n.categories;for(let t=0;t<l;++t)this.categories[t]=u[t];try{const u=function(t,e,n,o,r,i,s,a,l,u,c){return St(EDA,"fitSoftmax",[t,e,n,o,r,i,s,a,l,u,c])}(e,t.Column.fromFloat32Array("avgs",this.avgs,this.featuresCount),t.Column.fromFloat32Array("stdevs",this.stdevs,this.featuresCount),t.Column.fromInt32Array("targets",n.getRawData(),a),l,r,o,i,s,this.featuresCount+1,l).columns;this.params=new Array(l);for(let t=0;t<l;++t)this.params[t]=u.byIndex(t).getRawData()}catch(t){try{this.params=yield this.fitSoftmaxParams(e,n,r,o,i,s)}catch(t){throw new Error("Training failes")}}if(void 0===this.params)throw new Error("Training failes")})}extractStats(e){let n=0;for(const o of e){if(o.type!==t.COLUMN_TYPE.INT&&o.type!==t.COLUMN_TYPE.FLOAT)throw new Error("Training failes - incorrect features type");this.avgs[n]=o.stats.avg,this.stdevs[n]=o.stats.stdev,++n}}normalized(e){const n=e.byIndex(0).length,o=new Array(n);for(let t=0;t<n;++t)o[t]=new Float32Array(this.featuresCount);let r=0;for(const i of e){if(i.type!==t.COLUMN_TYPE.INT&&i.type!==t.COLUMN_TYPE.FLOAT)throw new Error("Training failes - incorrect features type");const e=i.getRawData(),s=this.avgs[r],a=this.stdevs[r];if(a>0)for(let t=0;t<n;++t)o[t][r]=(e[t]-s)/a;else for(let t=0;t<n;++t)o[t][r]=0;++r}return o}transposed(e){const n=e.byIndex(0).length,o=this.featuresCount,r=new Array(o);for(let t=0;t<o;++t)r[t]=new Float32Array(n);let i=0;for(const o of e){if(o.type!==t.COLUMN_TYPE.INT&&o.type!==t.COLUMN_TYPE.FLOAT)throw new Error("Training failes - incorrect features type");const e=o.getRawData(),s=this.avgs[i],a=this.stdevs[i];if(a>0)for(let t=0;t<n;++t)r[i][t]=(e[t]-s)/a;else for(let t=0;t<n;++t)r[i][t]=0;++i}return r}preprocessedTargets(e){if(e.type!==t.COLUMN_TYPE.STRING)throw new Error("Training failes - incorrect target type");const n=this.classesCount,o=e.length,r=e.getRawData(),i=new Array(o),s=new Uint32Array(n).fill(0);for(let t=0;t<o;++t)i[t]=new Uint8Array(n).fill(0);for(let t=0;t<o;++t)i[t][r[t]]=1,++s[r[t]];return{oneHot:i,weights:s}}predict(e){if(void 0===this.params)throw new Error("Non-trained model");if(e.length!==this.featuresCount)throw new Error("Predcition fails: incorrect features count");const n=this.normalized(e),o=n.length,r=this.featuresCount,i=this.classesCount;let s,a;const l=new Float32Array(i);let u,c,f;const d=new Array(o);for(let t=0;t<o;++t){s=n[t],u=0;for(let t=0;t<i;++t){a=this.params[t],u=a[r];for(let t=0;t<r;++t)u+=a[t]*s[t];l[t]=Math.exp(u)}c=l[0],f=0;for(let t=1;t<i;++t)c<l[t]&&(c=l[t],f=t);d[t]=this.categories[f]}return t.Column.fromStrings("predicted",d)}fitSoftmaxParams(t,e,n,o,r,i){return Te(this,void 0,void 0,function*(){const a=this.preprocessedTargets(e);return new Promise((l,u)=>{const c=new Worker(new URL(s.p+s.u(501),s.b));c.postMessage({features:this.normalized(t),transposed:this.transposed(t),oneHot:a.oneHot,classesWeights:a.weights,targetRaw:e.getRawData(),iterations:n,rate:o,penalty:r,tolerance:i}),c.onmessage=function(t){c.terminate(),l(t.data.params),console.log(`Loss: ${t.data.loss}`)}})})}}var Pe,Re,Fe;!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"}(Pe||(Pe={})),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"}(Re||(Re={})),function(t){t[t.MODEL=1e7]="MODEL",t[t.UTILS=1]="UTILS",t[t.PACK=128]="PACK",t[t.SIZE=4]="SIZE"}(Fe||(Fe={}));const De=t.FLOAT_NULL;var Be;!function(t){t.PREDICT="Prediction",t.TYPE="Type",t.PARAMS="Params count",t.CATS="Categories",t.CATS_SIZE="Categories size"}(Be||(Be={}));class ke{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,o=e.length;return o<=Re.SAMPLES_LOW?n<=Re.FEATURES_LOW:o<=Re.SAMLPES_MID?n<=Re.FEATURES_MID:o<=Re.SAMLPES_HIGH&&n<=Re.FEATURES_HIGH}constructor(e){var n;if(this.modelParams=void 0,this.targetType=void 0,this.targetCategories=void 0,e)try{let o=0;const r=new Uint32Array(e.buffer,o,1)[0];o+=Fe.SIZE;const i=t.DataFrame.fromByteArray(new Uint8Array(e.buffer,o,r));o+=r,this.targetType=i.get(Be.TYPE,0);const s=i.get(Be.PARAMS,0),a=i.get(Be.CATS_SIZE,0);if(a>0){const r=t.DataFrame.fromByteArray(new Uint8Array(e.buffer,o,a));this.targetCategories=null===(n=r.col(Be.CATS))||void 0===n?void 0:n.toList()}o+=a,o=4*Math.ceil(o/4),this.modelParams=new Int32Array(e.buffer,o,s)}catch(t){throw new Error(`Failed to load model: ${t instanceof Error?t.message:"the platform issue"}`)}}fit(e,n){return o=this,r=arguments,a=function*(e,n,o=Pe.ITERATIONS,r=Pe.ETA,i=Pe.MAX_DEPTH,a=Pe.LAMBDA,l=Pe.ALPHA){this.targetType=n.type,this.targetType===t.COLUMN_TYPE.STRING&&(this.targetCategories=n.categories),this.modelParams=yield async function(t,e,n,o,r,i,a,l,u,c){return new Promise((f,d)=>{const h=e.length,m=t.length,p=new Float32Array(h*m);let g,v;for(let e=0;e<m;++e){v=t.byIndex(e).getRawData(),g=e*h;for(let t=0;t<h;++t)p[t+g]=v[t]}const y=new Worker(new URL(s.p+s.u(990),s.b));y.postMessage({features:p,target:e.getRawData(),samplesCount:h,featuresCount:m,modelReserve:u,utilsLength:c,iterations:o,eta:r,maxDepth:i,lambda:a,alpha:l,missingValue:n}),y.onmessage=function(t){y.terminate(),f(t.data.params)}})}(e,n,De,o,r,i,a,l,Fe.MODEL,Fe.UTILS)},new((i=void 0)||(i=Promise))(function(t,e){function n(t){try{l(a.next(t))}catch(t){e(t)}}function s(t){try{l(a.throw(t))}catch(t){e(t)}}function l(e){var o;e.done?t(e.value):(o=e.value,o instanceof i?o:new i(function(t){t(o)})).then(n,s)}l((a=a.apply(o,r||[])).next())});var o,r,i,a}predict(e){if(void 0===this.modelParams)throw new Error("Failed to apply non-trained model");const n=function(t,e,n){const o=t.byIndex(0).length,r=t.length,i=n.length;let s=XGBoostModule.HEAPF32;const a=XGBoostModule.HEAP32,l=XGBoostModule._malloc(o*r*4),u=XGBoostModule._malloc(4*o),c=XGBoostModule._malloc(4*i);for(let e=0;e<r;++e){const n=t.byIndex(e).getRawData();for(let t=0;t<o;++t)s[l/4+t+e*o]=n[t]}for(let t=0;t<i;++t)a[c/4+t]=n[t];XGBoostModule._predict(l,o,r,e,c,i,u,o),s=XGBoostModule.HEAPF32;const f=new Float32Array(o);for(let t=0;t<o;++t)f[t]=s[u/4+t];return XGBoostModule._free(l),XGBoostModule._free(u),XGBoostModule._free(c),f}(e,De,this.modelParams);switch(this.targetType){case t.COLUMN_TYPE.STRING:return this.stringColPrediction(n);case t.COLUMN_TYPE.INT:return this.intColPrediction(n);case t.COLUMN_TYPE.BIG_INT:return this.bigIntColPrediction(n);default:return t.Column.fromFloat32Array(Be.PREDICT,n)}}toBytes(){if(void 0===this.modelParams||void 0===this.targetType)throw new Error("Failed to pack non-trained model");const e=void 0!==this.targetCategories?t.DataFrame.fromColumns([t.Column.fromList(t.COLUMN_TYPE.STRING,Be.CATS,this.targetCategories)]).toByteArray():void 0,n=void 0!==e?e.length:0,o=this.modelParams.length*this.modelParams.BYTES_PER_ELEMENT,r=t.DataFrame.fromColumns([t.Column.fromStrings(Be.TYPE,[this.targetType]),t.Column.fromInt32Array(Be.PARAMS,new Int32Array([this.modelParams.length])),t.Column.fromInt32Array(Be.CATS_SIZE,new Int32Array([n]))]).toByteArray(),i=r.length,s=64*Math.ceil((Fe.SIZE+i+n+o+Fe.PACK)/64),a=new Uint8Array(s);let l=0;return new Uint32Array(a.buffer,l,1)[0]=i,l+=Fe.SIZE,a.set(r,l),l+=i,n>0&&a.set(e,l),l+=n,l=4*Math.ceil(l/4),a.set(new Uint8Array(this.modelParams.buffer),l),a}stringColPrediction(e){const n=e.length;if(void 0===this.targetCategories)throw new Error("Predicting fails: undefined categories");const o=new Array(n),r=this.targetCategories.length-1,i=t=>Math.max(0,Math.min(t,r));for(let t=0;t<n;++t)o[t]=this.targetCategories[i(Math.round(e[t]))];return t.Column.fromList(t.COLUMN_TYPE.STRING,Be.PREDICT,o)}intColPrediction(e){const n=e.length,o=new Int32Array(n);for(let t=0;t<n;++t)o[t]=Math.round(e[t]);return t.Column.fromInt32Array(Be.PREDICT,o,n)}bigIntColPrediction(e){const n=e.length,o=new BigInt64Array(n);for(let t=0;t<n;++t)o[t]=BigInt(Math.round(e[t]));return t.Column.fromBigInt64Array(Be.PREDICT,o)}}var Ue=function(t,e,n,o){return new(n||(n=Promise))(function(r,i){function s(t){try{l(o.next(t))}catch(t){i(t)}}function a(t){try{l(o.throw(t))}catch(t){i(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(s,a)}l((o=o.apply(t,e||[])).next())})};const Ve=100,Ge=8e3;var $e;b("Softmax",()=>{C("Performance: 50K samples, 100 features",()=>Ue(void 0,void 0,void 0,function*(){const t=Ee(5e4,Ve,!1).columns,e=t.byIndex(Ve);t.remove(e.name);const n=new Le({classesCount:e.categories.length,featuresCount:t.length});yield n.fit(t,e);const o=n.toBytes();new Le(void 0,o).predict(t)}),{timeout:Ge,benchmark:!0}),C("Correctness",()=>Ue(void 0,void 0,void 0,function*(){const t=Ee(50,2,!0).columns,e=t.byIndex(2);t.remove(e.name);const n=new Le({classesCount:e.categories.length,featuresCount:t.length});yield n.fit(t,e);const o=n.toBytes(),r=be(e,new Le(void 0,o).predict(t));E(r>.9,!0,`Softmax failed, too small accuracy: ${r}; expected: <= 0.9`)}),{timeout:Ge})}),b("XGBoost",()=>{C("Performance: 50K samples, 100 features",()=>Ue(void 0,void 0,void 0,function*(){const t=Ee(5e4,Ve,!1).columns,e=t.byIndex(Ve);t.remove(e.name);const n=new ke;yield n.fit(t,e);const o=n.toBytes();new ke(o).predict(t)}),{timeout:Ge,benchmark:!0}),C("Correctness",()=>Ue(void 0,void 0,void 0,function*(){const t=Ee(50,2,!0).columns,e=t.byIndex(2);t.remove(e.name);const n=new ke;yield n.fit(t,e);const o=n.toBytes(),r=be(e,new ke(o).predict(t));E(r>.9,!0,`XGBoost failed, too small accuracy: ${r}; expected: <= 0.9`)}),{timeout:Ge})}),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"}($e||($e={}));const He="copy";var qe,Ye;!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"}(qe||(qe={})),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"}(Ye||(Ye={}));const We=[t.COLUMN_TYPE.INT,t.COLUMN_TYPE.FLOAT,t.COLUMN_TYPE.STRING,t.COLUMN_TYPE.DATE_TIME,t.COLUMN_TYPE.QNUM];function je(e){switch(e.type){case t.COLUMN_TYPE.INT:return t.INT_NULL;case t.COLUMN_TYPE.FLOAT:case t.COLUMN_TYPE.QNUM:case t.COLUMN_TYPE.DATE_TIME:return t.FLOAT_NULL;case t.COLUMN_TYPE.STRING:return e.max;default:throw new Error($e.UNSUPPORTED_COLUMN_TYPE)}}var Xe,ze,Ke;function Qe(e){switch(e){case t.COLUMN_TYPE.STRING:case t.COLUMN_TYPE.DATE_TIME:return{defaultWeight:Ke.WEIGHT,defaultMetric:Xe.ONE_HOT,availableMetrics:[Xe.ONE_HOT]};case t.COLUMN_TYPE.INT:case t.COLUMN_TYPE.FLOAT:case t.COLUMN_TYPE.QNUM:return{defaultWeight:Ke.WEIGHT,defaultMetric:Xe.DIFFERENCE,availableMetrics:[Xe.DIFFERENCE,Xe.ONE_HOT]};default:throw new Error($e.UNSUPPORTED_COLUMN_TYPE)}}!function(t){t.ONE_HOT="One-hot",t.DIFFERENCE="Difference"}(Xe||(Xe={})),function(t){t.EUCLIDEAN="Euclidean",t.MANHATTAN="Manhattan"}(ze||(ze={})),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 Ze=e=>{C(`${e} dist, 100K rows, 15 cols, 75 missing vals`,()=>{return n=void 0,o=void 0,i=function*(){const n=function(e){const n=ye.length,o=[];let r=0;const i=new Map;for(let n=0;n<5;++n){const s=new Int32Array(e),a=`int #${n+1}`,l=[];for(let t=0;t<e;++t)s[t]=Math.floor(10*Math.random());for(let n=0;n<5;++n)r=Math.floor(e*Math.random()),s[r]=t.INT_NULL,l.push(r);o.push(t.Column.fromInt32Array(a,s)),i.set(a,l)}for(let n=0;n<5;++n){const s=new Float32Array(e),a=`float #${n+1}`,l=[];for(let t=0;t<e;++t)s[t]=10*Math.random();for(let n=0;n<5;++n)r=Math.floor(e*Math.random()),s[r]=t.FLOAT_NULL,l.push(r);o.push(t.Column.fromFloat32Array(a,s)),i.set(a,l)}for(let s=0;s<5;++s){const a=new Array(e),l=`str #${s+1}`,u=[];for(let t=0;t<e;++t)a[t]=ye[Math.floor(Math.random()*n)];const c=t.Column.fromStrings(l,a);for(let t=0;t<5;++t)r=Math.floor(e*Math.random()),c.set(r,null),u.push(r);o.push(c),i.set(l,u)}return{df:t.DataFrame.fromColumns(o),misValsIds:i}}(1e5),o=n.df,r=o.columns.names(),i=new Map,s=n.misValsIds;for(const t of o.columns){const e=Qe(t.type);i.set(t.name,{weight:e.defaultWeight,type:e.defaultMetric})}const a=function(e,n,o,r,i,s,a){if(s<1)throw new Error($e.INCORRECT_NEIGHBORS);if(e.rowCount<2)throw new Error($e.KNN_NOT_ENOUGH_OF_ROWS);if(0===n.length)throw new Error($e.KNN_NO_TARGET_COLUMNS);if(0===o.size)throw new Error($e.KNN_NO_FEATURE_COLUMNS);1===o.size&&n.forEach(t=>{if(o.has(t))throw new Error(`${$e.KNN_NO_FEATURE_COLUMNS} can be used for the column '${t}'`)}),n.forEach(t=>{if(!r.has(t))throw new Error(`${$e.KNN_FAILS}: ${$e.WRONG_PREDICTIONS}`)});const l=e.columns;n.forEach(t=>{if(!We.includes(l.byName(t).type))throw new Error($e.UNSUPPORTED_COLUMN_TYPE)}),o.forEach((t,n)=>{if(!We.includes(e.getCol(n).type))throw new Error($e.UNSUPPORTED_COLUMN_TYPE)});const u=new Map;return n.forEach(n=>{const c=l.byName(n),f=je(c),d=c.length,h=c.getRawData(),m=new Uint16Array(c.categories.length),p=[],g=[],v=[],y=[];o.forEach((t,e)=>{if(e!==c.name){const n=l.byName(e);switch(p.push(n.getRawData()),g.push(je(n)),t.type){case Xe.DIFFERENCE:v.push((e,n)=>t.weight*Math.abs(e-n));break;case Xe.ONE_HOT:v.push((e,n)=>t.weight*(e===n?0:1))}}});const A=p.length,w=new Uint32Array(p.length),C=new Float32Array(p.length);let E=0;const b=new Array(s);let x=0,_=0,N=0,M=0,T=0;const S=(t,e)=>{w.forEach((n,o)=>{C[o]=v[n](p[n][t],p[n][e])})},O=i===ze.EUCLIDEAN?()=>{let t=0;for(let e=0;e<E;++e)t+=C[e]*C[e];return Math.sqrt(t)}:()=>{let t=0;for(let e=0;e<E;++e)t+=Math.abs(C[e]);return Math.sqrt(t)},L=t=>{if(h[t]===f)return!1;for(let e=0;e<E;++e)if(p[w[e]][t]===g[w[e]])return!1;return!0},P=e=>{if((t=>{E=0;for(let e=0;e<A;++e)p[e][t]!==g[e]&&(w[E]=e,++E)})(e),0===E)throw new Error(`${$e.KNN_IMPOSSIBLE_IMPUTATION}: the column "${c.name}", row ${e+1}`);x=0;for(let t=0;t<d;++t)if(L(t)&&t!==e){S(e,t);const n=O();if(x<s)b[x]={index:t,dist:n},++x;else{_=0,N=b[0].dist;for(let t=1;t<x;++t)N<b[t].dist&&(N=b[t].dist,_=t);n<N&&(b[_]={index:t,dist:n})}}if(0===x)throw new Error(`${$e.KNN_IMPOSSIBLE_IMPUTATION}: the column "${c.name}", row ${e+1}`);if(c.type===t.COLUMN_TYPE.STRING)return(()=>{m.forEach((t,e,n)=>n[e]=0);let t=0;for(t=0;t<x;++t)++m[h[b[t].index]];let e=m[0],n=0;return m.forEach((t,o)=>{t>e&&(e=t,n=o)}),n})();M=0;for(let t=0;t<x;++t)M+=h[b[t].index];return T=M/x,c.type===t.COLUMN_TYPE.INT?Math.round(T):T};if(a){for(const t of r.get(n))try{h[t]=P(t)}catch(e){y.push(t),e instanceof Error||I.shell.error($e.CORE_ISSUE)}y.length>0&&u.set(n,y),c.set(0,c.get(0))}else{const t=c.clone();let o=1,i=`${n}(${He})`;for(;e.columns.contains(i);)i=`${n}(${He} ${o})`,++o;t.name=i;const s=t.getRawData();for(const t of r.get(n))try{s[t]=P(t)}catch(e){y.push(t),e instanceof Error||I.shell.error($e.CORE_ISSUE)}y.length>0&&u.set(i,y),t.set(0,t.get(0)),e.columns.add(t)}}),u}(o,r,i,s,e,5,!0);let l=0;a.forEach((t,e)=>l+=t.length),E(l,0,`Failed to impute ${l} missing values`)},new((r=void 0)||(r=Promise))(function(t,e){function s(t){try{l(i.next(t))}catch(t){e(t)}}function a(t){try{l(i.throw(t))}catch(t){e(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof r?n:new r(function(t){t(n)})).then(s,a)}l((i=i.apply(n,o||[])).next())});var n,o,r,i},{timeout:1e4,benchmark:!0})};b("Missing values imputation",()=>{Ze(ze.EUCLIDEAN),Ze(ze.MANHATTAN)});var Je,tn=s(6572);function en(t){if(t<=0||t>=1)throw new Error(Je.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 on(t,e,n){en(n);const o=nn(t),r=nn(e);return 0===o||0===r?o===r:o/r<tn.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 rn{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 o=1;o<e;++o)if(!on(n,{sum:this.sums[o],sumOfSquares:this.sumsOfSquares[o],size:this.subSampleSizes[o]},t))return!1;return!0}getOneWayAnova(){let t=0,e=0,n=0,o=this.catCount,r=o;for(let i=0;i<o;++i)0!==this.subSampleSizes[i]?(t+=this.sums[i],e+=this.sumsOfSquares[i],n+=Math.pow(this.sums[i],2)/this.subSampleSizes[i]):--r;if(o=r,1===o)throw new Error(Je.SINGLE_FACTOR);const i=this.size-this.nullsCount;if(i===o)throw new Error(Je.CATS_EQUAL_SIZE);const s=e-Math.pow(t,2)/i,a=n-Math.pow(t,2)/i,l=s-a;if(0===l)throw new Error(Je.NO_FEATURE_VARIATION_WITHIN_GROUPS);const u=o-1,c=i-o,f=a/u,d=l/c,h=f/d;return{ssBn:a,ssWn:l,ssTot:s,dfBn:u,dfWn:c,dfTot:i-1,msBn:f,msWn:d,fStat:h,pValue:1-tn.centralF.cdf(h,u,c)}}setStats(e,n,o){const r=n.type,i=n.length,s=je(n);switch(r){case t.COLUMN_TYPE.INT:case t.COLUMN_TYPE.FLOAT:const r=o;this.catCount=r,this.size=i;const a=n.getRawData(),l=e.getRawData(),u=new Float64Array(r).fill(0),c=new Float64Array(r).fill(0),f=new Int32Array(r).fill(0);let d;if(e.type==t.COLUMN_TYPE.BOOL){let t=0,e=0,n=l[0];const o=8*l.BYTES_PER_ELEMENT-1;for(let r=0;r<i;++r)d=1&n>>e,a[r]!==s?(u[d]+=a[r],c[d]+=Math.pow(a[r],2),++f[d]):++this.nullsCount,++e,e>o&&(e=0,++t,n=l[t])}else{const t=e.stats.missingValueCount>0?je(e):-1;for(let e=0;e<i;++e)d=l[e],d!==t&&a[e]!==s?(u[d]+=a[e],c[d]+=Math.pow(a[e],2),++f[d]):++this.nullsCount}this.sums=u,this.sumsOfSquares=c,this.subSampleSizes=f;break;default:throw new Error(Je.UNSUPPORTED_COLUMN_TYPE)}}}function sn(t,e,n,o=!0){en(n);const r=t.stats.uniqueCount;if(r<2)throw new Error(Je.SINGLE_FACTOR);const i=new rn(t,e,r);if(o&&!i.areVarsEqual(n))throw new Error(Je.NON_EQUAL_VARIANCES);const s=i.getOneWayAnova();return{anovaTable:s,fCritical:tn.centralF.inv(1-n,s.dfBn,s.dfWn),significance:n}}var an=function(t,e,n,o){return new(n||(n=Promise))(function(r,i){function s(t){try{l(o.next(t))}catch(t){i(t)}}function a(t){try{l(o.throw(t))}catch(t){i(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(s,a)}l((o=o.apply(t,e||[])).next())})};const ln=.05,un=!1,cn=t.Column.fromList(t.COLUMN_TYPE.INT,"features",[9,12,4,8,7,4,6,8,2,10,1,3,4,5,2]),fn=t.Column.fromStrings("features",["A","A","A","A","A","B","B","B","B","B","C","C","C","C","C"]);var dn;!function(t){t[t.DF_BN=2]="DF_BN",t[t.DF_TOT=14]="DF_TOT",t[t.DF_WN=12]="DF_WN",t[t.SS_BN=63.333]="SS_BN",t[t.SS_TOT=147.333]="SS_TOT",t[t.SS_WN=84]="SS_WN",t[t.MS_BN=31.666]="MS_BN",t[t.MS_WN=7]="MS_WN",t[t.F_STAT=4.523]="F_STAT",t[t.F_CRIT=3.885]="F_CRIT",t[t.P_VAL=.034]="P_VAL"}(dn||(dn={})),b("ANOVA",()=>{C("Performance: 1M rows demog",()=>an(void 0,void 0,void 0,function*(){const t=I.data.demo.demog(1e6),e=t.col("race"),n=t.col("height");new rn(e,n,e.stats.uniqueCount).areVarsEqual(ln),sn(e,n,ln,un)}),{timeout:4e3,benchmark:!0}),C("Correctness",()=>an(void 0,void 0,void 0,function*(){const t=sn(fn,cn,ln,un),e=t.anovaTable;E(e.dfBn,dn.DF_BN,"Incorrect degrees of freedom: dfBn"),E(e.dfTot,dn.DF_TOT,"Incorrect degrees of freedom: dfTot"),E(e.dfWn,dn.DF_WN,"Incorrect degrees of freedom: dfWn");const n=(t,e)=>Math.abs(t-e)<.01;E(n(e.ssBn,dn.SS_BN),!0,"Incorrect sum of squares: ssBn"),E(n(e.ssTot,dn.SS_TOT),!0,"Incorrect sum of squares: ssTot"),E(n(e.ssWn,dn.SS_WN),!0,"Incorrect sum of squares: ssWn"),E(n(e.msBn,dn.MS_BN),!0,"Incorrect mean squares: msBn"),E(n(e.msWn,dn.MS_WN),!0,"Incorrect mean squares: msWn"),E(n(e.fStat,dn.F_STAT),!0,"Incorrect F-statistics value"),E(n(e.pValue,dn.P_VAL),!0,"Incorrect p-value"),E(n(t.fCritical,dn.F_CRIT),!0,"Incorrect F-critical")}),{timeout:4e3})});const hn=rxjs;function mn(t){return"numerical"===t.functionType}function pn(t=1,e=0,n=1){return{functionType:"numerical",weight:t,mode:"freeform",min:e,max:n,line:[]}}function gn(t=1,e){return{functionType:"categorical",weight:t,categories:null!=e?e:[{name:"Category 1",desirability:1}]}}function vn(t){return t.functionType?t:t.categories?{...t,functionType:"categorical"}:{...t,functionType:"numerical"}}const yn=["Average","Sum","Product","Geomean","Min","Max"],An="Average";class wn{constructor(t,e=!1,n=!1){this.onChanged=new hn.Subject,this.supportsModeDialog=!0,this.desirabilityInputs=[],this.form=null,this.columnCategories=null,this._prop=t,this.design=e,this.showControls=n,this.root=ot.divV([],"statistics-mpo-cat-editor"),this.buildForm()}buildForm(){var t;const e=null!==(t=this._prop.categories)&&void 0!==t?t:[];this.form&&(ot.empty(this.root),this.form=null,this.desirabilityInputs=[]),this.design?this.buildDesignForm(e):this.buildViewForm(e)}createDesirabilityInput(t,e){var n;const o=ot.input.float(t,{value:null!==(n=e.desirability)&&void 0!==n?n:.5,min:0,max:1,format:"#0.000",onValueChanged:t=>{e.desirability=t,this.onChanged.next(this._prop)}});return this.desirabilityInputs.push(o),o}buildViewForm(t){for(const e of t)this.createDesirabilityInput(e.name,e);this.form=ot.form(this.desirabilityInputs),this.root.append(this.form)}buildDesignForm(t){const e=ot.divH([ot.divText("Name","statistics-mpo-cat-col-header statistics-mpo-cat-name"),ot.divText("Score","statistics-mpo-cat-col-header statistics-mpo-cat-desirability"),...this.showControls?[ot.div([],{style:{width:"40px"}})]:[]],"statistics-mpo-cat-row statistics-mpo-cat-header-row"),n=t.map((t,e)=>this.buildCategoryRow(t,e));this.form=ot.divV([e,...n]),this.root.append(this.form)}buildCategoryRow(t,e){const n=this.columnCategories?ot.input.choice("",{items:this.columnCategories,nullable:!0,value:t.name||null,onValueChanged:e=>{t.name=null!=e?e:"",this.onChanged.next(this._prop)}}):ot.input.string("",{value:t.name,onValueChanged:e=>{t.name=e,this.onChanged.next(this._prop)}});n.root.classList.add("statistics-mpo-cat-name");const o=this.createDesirabilityInput("",t);o.root.classList.add("statistics-mpo-cat-desirability");const r=[n.root,o.root];if(this.showControls){const t=ot.icons.add(()=>{const t={name:this.columnCategories?"":`Category ${this._prop.categories.length+1}`,desirability:1};this._prop.categories.splice(e+1,0,t),this.buildForm(),this.onChanged.next(this._prop)}),n=ot.icons.delete(()=>{this._prop.categories.splice(e,1),this.buildForm(),this.onChanged.next(this._prop)});r.push(ot.divH([t,n],"statistics-mpo-control-buttons"))}return ot.divH(r,"statistics-mpo-cat-row")}redrawAll(t=!0){this.buildForm(),t&&this.onChanged.next(this._prop)}setChoices(t){this.columnCategories=t,this.buildForm()}setColumn(t){var e,n;if(!t)return;this.columnCategories=t.isCategorical?[...t.categories]:null;const o=new Map(null!==(n=null===(e=this._prop.categories)||void 0===e?void 0:e.map(t=>[t.name,t.desirability]))&&void 0!==n?n:[]);this._prop.categories=t.categories.map(t=>{var e;return{name:t,desirability:null!==(e=o.get(t))&&void 0!==e?e:1}}),this.buildForm()}}let Cn;const En=10,bn=10,xn=20,_n=30,Nn={line:t.Color.toHtml(t.Color.filteredRows),handle:t.Color.toHtml(t.Color.selectedRows),barFill:t.Color.toHtml(t.Color.histogramBar),barStroke:t.Color.toHtml(t.Color.lightGray)};class Mn{constructor(t,e,n,o){this.minX=t,this.maxX=e,this.width=n,this.height=o,this.plotWidth=n-_n-bn,this.plotHeight=o-En-xn,this.scaleX=this.maxX-this.minX===0?1:this.plotWidth/(this.maxX-this.minX),this.scaleY=this.plotHeight}toCanvasCoords(t){return{x:_n+(t[0]-this.minX)*this.scaleX,y:En+this.plotHeight-t[1]*this.scaleY}}toDataCoords(t,e){let n=this.minX+(t-_n)/this.scaleX,o=(En+this.plotHeight-e)/this.scaleY;return n=Math.max(this.minX,Math.min(this.maxX,n)),o=Math.max(0,Math.min(1,o)),{x:n,y:o}}}class Tn{constructor(t,e,n){this.root=ot.div([],"statistics-mpo-line-editor"),this.onChanged=new hn.Subject,this.supportsModeDialog=!0,this.ignoreNextClick=!1,this.dragScaleX=0,this.dragScaleY=0,this._prop=t,this._width=e,this._height=n,this.ensureDefaultLine(),this.root.style.width=`${e}px`,this.root.style.height=`${n}px`,this.root.style.position="relative",requestAnimationFrame(()=>this.initKonva(e,n))}ensureDefaultLine(){var t,e;if(this._prop.line.length>0)return;const n=null!==(t=this._prop.min)&&void 0!==t?t:0,o=null!==(e=this._prop.max)&&void 0!==e?e:1;this._prop.line=[[n,.5],[o,.5]]}updateDragScales(){const t=this._width-_n-bn,e=this._height-En-xn;this.dragScaleX=(this.getMaxX()-this.getMinX())/t,this.dragScaleY=1/e}isInPlotArea(t,e,n){return t.x>=_n&&t.x<=e-bn&&t.y>=En&&t.y<=n-xn}async initKonva(t,e){var n;if(!this.root.parentElement)return void console.warn("Konva container not attached to DOM yet.");const o=await async function(){return Cn||(Cn=(await s.e(397).then(s.t.bind(s,5778,23))).default),Cn}();this.barsLayer=new o.Layer,this.stage=new o.Stage({container:this.root,width:t,height:e}),this.stage.add(this.barsLayer),this.layer=new o.Layer,this.stage.add(this.layer);const r=this.getMinX(),i=this.getMaxX();this.drawAxes(r,i,t,e),this.konvaLine=new o.Line({points:[],stroke:Nn.line,strokeWidth:2,lineCap:"round",lineJoin:"round"}),this.layer.add(this.konvaLine),this.pointsGroup=new o.Group,this.layer.add(this.pointsGroup),this.redrawFn=(t=!0)=>{const e=this.getMinX(),n=this.getMaxX();"freeform"===this._prop.mode&&this._prop.freeformLine&&(this._prop.line=this._prop.freeformLine),"freeform"!==this._prop.mode&&(this._prop.freeformLine||(this._prop.freeformLine=[...this._prop.line]),this._prop.line=this.computeLine()),this.pointsGroup.destroyChildren();const r=[],i=new Mn(e,n,this._width,this._height),s=[...this._prop.line.keys()].sort((t,e)=>this._prop.line[t][0]-this._prop.line[e][0]);s.map(t=>this._prop.line[t]).forEach((t,a)=>{const l=i.toCanvasCoords([t[0],t[1]]);if(r.push(l.x,l.y),"freeform"!==this._prop.mode)return;const u=new o.Circle({x:l.x,y:l.y,radius:3,fill:"white",stroke:Nn.line,strokeWidth:1,draggable:!0,hitStrokeWidth:5});u.setAttr("_dataIndex",s[a]),u.on("dragmove",t=>{const o=t.target,r=o.position(),a=o.getAttr("_dataIndex"),l=s.indexOf(a),u=l>0?this._prop.line[s[l-1]][0]:e,c=l<s.length-1?this._prop.line[s[l+1]][0]:n,f=n-e===0?0:.001*(n-e),d=i.toCanvasCoords([u+(l>0?f:0),0]).x,h=i.toCanvasCoords([c-(l<s.length-1?f:0),0]).x;r.x=Math.max(d,Math.min(h,r.x));const m=this._height-xn;r.y=Math.max(10,Math.min(m,r.y)),o.position(r);const p=i.toDataCoords(r.x,r.y);this._prop.line[a][0]=p.x,this._prop.line[a][1]=p.y;const g=this._prop.line.map((t,e)=>{if(e===a)return[r.x,r.y];{const e=i.toCanvasCoords([t[0],t[1]]);return[e.x,e.y]}}).flat();this.konvaLine.points(g),this.layer.batchDraw()}),u.on("dragend",()=>{var t;this._prop.line.sort((t,e)=>t[0]-e[0]),null===(t=this.redrawFn)||void 0===t||t.call(this)}),u.on("contextmenu",t=>{var e;if(t.evt.preventDefault(),this._prop.line.length<=2)return void I.shell.warning("Cannot remove points, minimum of 2 required.");this.ignoreNextClick=!0;const n=t.target.getAttr("_dataIndex");n>=0&&(null==this._prop.min&&(this._prop.min=this.getMinX()),null==this._prop.max&&(this._prop.max=this.getMaxX()),this._prop.line.splice(n,1),null===(e=this.redrawFn)||void 0===e||e.call(this))}),u.on("mouseenter",t=>{this.stage.container().style.cursor="pointer";const e=t.target.position(),n=i.toDataCoords(e.x,e.y),o=`X: ${n.x.toFixed(2)}, Y: ${n.y.toFixed(2)}<br><br>Drag to move, double-click to edit, right-click to delete`;ot.tooltip.show(o,t.evt.clientX,t.evt.clientY)}),u.on("mouseleave",()=>{this.stage.container().style.cursor="default",ot.tooltip.hide()}),u.on("dblclick dbltap",t=>{this.ignoreNextClick=!0,ot.tooltip.hide();const e=t.target.getAttr("_dataIndex");this.showPointEditor(e,t.evt.clientX,t.evt.clientY)}),this.pointsGroup.add(u)}),this.konvaLine.points(r),this.layer.batchDraw(),this.addSpecialHandle(this._width,this._height),t&&this.onChanged.next(this._prop.line)},this.stage.on("click tap",t=>{var e,n;if(this.ignoreNextClick)return void(this.ignoreNextClick=!1);if(t.target instanceof o.Circle||0!==t.evt.button)return;const r=null===(e=this.stage)||void 0===e?void 0:e.getPointerPosition();if(!r)return;const i=this.getMinX(),s=this.getMaxX();if(!this.isInPlotArea(r,this.stage.width(),this.stage.height()))return;const a=new Mn(i,s,this.stage.width(),this.stage.height()).toDataCoords(r.x,r.y);this._prop.line.push([a.x,a.y]),this._prop.line.sort((t,e)=>t[0]-e[0]),null===(n=this.redrawFn)||void 0===n||n.call(this)}),this.stage.on("mousemove",t=>{if(!this.stage)return;const e=this.stage.getPointerPosition();e&&"freeform"!==this._prop.mode&&(this.isInPlotArea(e,this._width,this._height)?this.stage.container().style.cursor="grab":this.stage.container().style.cursor="default")}),this.stage.on("mouseout",()=>ot.tooltip.hide()),this.enableCurveDrag(),this.updateDragScales(),ot.onSizeChanged(this.root).subscribe(t=>{const{clientWidth:e,clientHeight:n}=this.root;e>0&&n>0&&this.resize(e,n)}),this.pendingBarValues&&(this.drawBars(this.pendingBarValues),this.pendingBarValues=void 0),null===(n=this.redrawFn)||void 0===n||n.call(this,!1)}get line(){return this._prop.line}computeLine(){var t,e,n,o,r,i,s,a;if("freeform"===this._prop.mode)return this._prop.line;const l=this.getMinX(),u=this.getMaxX(),c=[];for(let f=0;f<=60;f++){const d=l+f/60*(u-l);let h=0;if("gaussian"===this._prop.mode){null!==(t=(r=this._prop).mean)&&void 0!==t||(r.mean=(l+u)/2),null!==(e=(i=this._prop).sigma)&&void 0!==e||(i.sigma=(u-l)/6);const n=(d-this._prop.mean)/this._prop.sigma;h=Math.exp(-.5*n*n)}if("sigmoid"===this._prop.mode){null!==(n=(s=this._prop).x0)&&void 0!==n||(s.x0=(l+u)/2),null!==(o=(a=this._prop).k)&&void 0!==o||(a.k=10);const t=this._prop.x0,e=this._prop.k;h=1/(1+Math.exp(-e*(d-t)))}c.push([d,h])}return c}drawAxes(t,e,n,o){const r=getComputedStyle(document.documentElement).getPropertyValue("--grey-2").trim()||"#DBDCDF";this.layer.add(new Cn.Line({points:[_n,o-xn,n-bn,o-xn],stroke:r,strokeWidth:1}),new Cn.Line({points:[_n,En,_n,o-xn],stroke:r,strokeWidth:1}),new Cn.Text({x:_n,y:o-xn+3,text:t.toFixed(1),fontSize:9,fill:"grey"}),new Cn.Text({x:n-bn-15,y:o-xn+3,text:e.toFixed(1),fontSize:9,fill:"grey"}))}getMinX(){var t,e;return null!==(e=null!==(t=this._prop.min)&&void 0!==t?t:Math.min(...this._prop.line.map(t=>t[0])))&&void 0!==e?e:0}getMaxX(){var t,e;return null!==(e=null!==(t=this._prop.max)&&void 0!==t?t:Math.max(...this._prop.line.map(t=>t[0])))&&void 0!==e?e:1}getDefaultMean(){return(this.getMinX()+this.getMaxX())/2}getDefaultSigma(){return Math.max(.01,(this.getMaxX()-this.getMinX())/6)}getDefaultX0(){return(this.getMinX()+this.getMaxX())/2}getDefaultK(){return 10}redrawAll(t=!0){if(!this.stage||!this.layer||!this.redrawFn)return;const e=this.stage.width(),n=this.stage.height(),o=this.getMinX(),r=this.getMaxX();this.layer.destroyChildren(),this.drawAxes(o,r,e,n),this.layer.add(this.konvaLine,this.pointsGroup),this.redrawFn(t),this.barValues&&this.drawBars()}resize(t,e){t===this._width&&e===this._height||(this._width=t,this._height=e,this.stage&&(this.stage.width(t),this.stage.height(e),this.updateDragScales(),this.redrawAll(!1)))}drawBars(t){var e;if(t&&(this.barValues=t),!this.barsLayer)return void(this.pendingBarValues=t);if(this.barsLayer.destroyChildren(),!this.barValues||0===this.barValues.length)return;const n=this.barsLayer.getStage();if(!n)return void(this.pendingBarValues=t);const o=n.width(),r=n.height(),i=this.getMinX(),s=this.getMaxX();if(s===i)return;const a=o-_n-bn,l=r-En-xn,u=Math.max(1e-9,(s-i)/20),c=new Array(20).fill(0);(null!==(e=this.barValues)&&void 0!==e?e:[]).forEach(t=>{const e=Math.min(Math.floor((t-i)/u),19);c[e]++});const f=Math.max(...c)||1;c.forEach((t,e)=>{const n=_n+e*u/(s-i)*a,o=u/(s-i)*a-1,r=t/f*l,c=new Cn.Rect({x:n,y:En+l-r,width:o,height:r,fill:Nn.barFill,opacity:.25,stroke:Nn.barStroke,strokeWidth:.5});this.barsLayer.add(c)}),this.barsLayer.batchDraw()}enableCurveDrag(){if(!this.stage)return;let t=!1,e=null,n=0,o=0,r=0,i=0;this.stage.on("mousedown touchstart",s=>{var a,l,u,c;if("freeform"===this._prop.mode)return;if(!s.evt)return;const f=this.stage.getPointerPosition();f&&this.isInPlotArea(f,this._width,this._height)&&(t=!0,e=f,n=null!==(a=this._prop.mean)&&void 0!==a?a:(this.getMinX()+this.getMaxX())/2,o=null!==(l=this._prop.sigma)&&void 0!==l?l:(this.getMaxX()-this.getMinX())/6,r=null!==(u=this._prop.x0)&&void 0!==u?u:(this.getMinX()+this.getMaxX())/2,i=null!==(c=this._prop.k)&&void 0!==c?c:10,this.stage.container().style.cursor="grabbing")}),this.stage.on("mousemove touchmove",s=>{var a,l;if(!t||!e)return;const u=this.stage.getPointerPosition();if(!u)return;const c=u.x-e.x,f=u.y-e.y;"gaussian"===this._prop.mode&&(this._prop.mean=n+c*this.dragScaleX,this._prop.sigma=Math.max(.01,o+-f*this.dragScaleY*(this.getMaxX()-this.getMinX()))),"sigmoid"===this._prop.mode&&(this._prop.x0=r+c*this.dragScaleX,this._prop.k=Math.max(.1,i+-f*this.dragScaleY*50)),this._prop.line=this.computeLine(),null===(a=this.redrawFn)||void 0===a||a.call(this),null===(l=this.onParamsChanged)||void 0===l||l.call(this,this._prop)}),this.stage.on("mouseup touchend",()=>{t=!1,e=null,this.stage.container().style.cursor="default"})}addSpecialHandle(t,e){var n,o;if("freeform"===this._prop.mode)return;const r=this.getMinX(),i=this.getMaxX(),s=new Mn(r,i,t,e);let a=(r+i)/2,l=.5;"gaussian"===this._prop.mode?(a=null!==(n=this._prop.mean)&&void 0!==n?n:(r+i)/2,l=1):"sigmoid"===this._prop.mode&&(a=null!==(o=this._prop.x0)&&void 0!==o?o:(r+i)/2,l=.5);const u=s.toCanvasCoords([a,l]);this.specialHandle?(this.specialHandle.getLayer()||this.layer.add(this.specialHandle),this.specialHandle.position(u)):(this.specialHandle=new Cn.Circle({x:u.x,y:u.y,radius:7,fill:Nn.handle,draggable:!0,hitStrokeWidth:15}),this.specialHandle.on("dragmove",t=>{var e,n;const o=t.target.position(),r=s.toDataCoords(o.x,o.y);var i;"gaussian"===this._prop.mode?(this._prop.mean=r.x,this._prop.sigma=Math.max(.01,Math.abs(r.y-1))):"sigmoid"===this._prop.mode&&(this._prop.x0=r.x,this._prop.k=(i=30*Math.abs(r.y-.5),Math.max(.1,Math.min(30,i)))),this._prop.line=this.computeLine(),null===(e=this.redrawFn)||void 0===e||e.call(this),null===(n=this.onParamsChanged)||void 0===n||n.call(this,this._prop)}),this.layer.add(this.specialHandle)),this.layer.batchDraw()}showPointEditor(t,e,n){const o=this._prop.line[t],r=ot.input.float("X",{value:o[0],min:this.getMinX(),max:this.getMaxX(),format:"#0.00",step:.01}),i=ot.input.float("Y",{value:o[1],min:0,max:1,format:"#0.00",step:.01}),s=()=>{u.removeEventListener("keydown",l),f.remove()},a=()=>{const e=r.value,n=i.value;null==e||null==n||isNaN(e)||isNaN(n)||(this._prop.line[t]=[e,n],this.redrawAll())},l=t=>{"Enter"===t.key&&(a(),s()),"Escape"===t.key&&s()},u=ot.inputs([r,i]);u.style.overflow="hidden",u.addEventListener("keydown",l);const c=this.root.getBoundingClientRect(),f=ot.showPopup(u,this.root,{dx:e-c.left,dy:n-c.bottom,smart:!1})}setRange(t,e){const n=this.getMinX(),o=this.getMaxX()-n,r=e-t;if(0!==o&&0!==r){const e=r/o,i=o=>t+(o-n)*e;null!=this._prop.mean&&(this._prop.mean=i(this._prop.mean)),null!=this._prop.sigma&&(this._prop.sigma*=e),null!=this._prop.x0&&(this._prop.x0=i(this._prop.x0)),null!=this._prop.k&&(this._prop.k/=e);for(const t of this._prop.line)t[0]=i(t[0]);if(this._prop.freeformLine)for(const t of this._prop.freeformLine)t[0]=i(t[0])}this._prop.min=t,this._prop.max=e,this.updateDragScales(),this.redrawAll(!1)}setColumn(t){if(!t)return;const e=t.toList();this.drawBars(e)}}class Sn{static create(t,e=300,n=80,o=!1){return mn(t)?new Tn(t,e,n):new wn(t,o,!1)}}const On=["freeform","gaussian","sigmoid"],In=["numerical","categorical"];function Ln(t){return ot.divText(t,"statistics-mpo-section-header")}class Pn{constructor(t,e,n,o,r){this.propertyName=t,this.prop=e,this.onUpdate=n,this.onTypeChanged=o,this.mappedCol=r}static strategyToLabel(t){switch(t){case"default":return"Use default score";case"skip":return"Skip property";default:return"Exclude row"}}buildDefaultScoreInput(t){const e=t.missingValues,n=ot.input.float("Default score",{value:"default"===(null==e?void 0:e.strategy)?e.score:0,min:0,max:1,format:"#0.000",onValueChanged:e=>{t.missingValues={strategy:"default",score:e},this.onUpdate({missingValues:t.missingValues})}});n.root.style.display="default"===(null==e?void 0:e.strategy)?"":"none";const o=ot.input.choice("If missing",{items:["Exclude row","Use default score","Skip property"],value:Pn.strategyToLabel(null==e?void 0:e.strategy),onValueChanged:e=>{var o;const r="Use default score"===e;t.missingValues="Skip property"===e?{strategy:"skip"}:r?{strategy:"default",score:null!==(o=n.value)&&void 0!==o?o:0}:{strategy:"exclude"},n.root.style.display=r?"":"none",this.onUpdate({missingValues:t.missingValues})}});return o.setTooltip("How to handle missing values:<br>• <b>Exclude row</b> — assign an MPO score of 0 to the row<br>• <b>Use default score</b> — use a fixed fallback desirability value<br>• <b>Skip property</b> — calculate the score from the remaining properties"),n.setTooltip("Desirability score (0–1) to use as fallback."),ot.form([o,n])}show(){const t=structuredClone(this.prop),e=ot.dialog({title:this.propertyName});e.root.classList.add("statistics-mpo-desirability-dialog");const n=ot.divV([]),o={[t.functionType]:structuredClone(t)},r=[];let i;const s=ot.input.choice("Type",{items:[...In],value:this.prop.functionType,onValueChanged:e=>{var n;if(e!==this.prop.functionType){if(o[this.prop.functionType]=structuredClone(this.prop),o[e])this.prop=structuredClone(o[e]);else if("categorical"===e){const e=(null===(n=this.mappedCol)||void 0===n?void 0:n.isCategorical)?this.mappedCol.categories.map(t=>({name:t,desirability:1})):void 0;this.prop=gn(t.weight,e)}else this.prop=pn(t.weight);c()}}}),a=()=>{var t,e,o;const s=this.prop;null!==(t=s.mode)&&void 0!==t||(s.mode="freeform");const a=new Tn(s,355,103);(null===(e=this.mappedCol)||void 0===e?void 0:e.isNumerical)&&a.setColumn(this.mappedCol);const l=ot.input.choice("Mode",{items:On,value:s.mode,onValueChanged:t=>{s.mode=t,this.onUpdate({mode:s.mode}),d(),a.redrawAll(!1)}}),u=[{key:"min",label:"Min",fallback:()=>a.getMinX()},{key:"max",label:"Max",fallback:()=>a.getMaxX()},{key:"mean",label:"Mean",fallback:()=>a.getDefaultMean()},{key:"sigma",label:"Sigma",fallback:()=>a.getDefaultSigma(),transform:t=>Math.max(.01,t)},{key:"x0",label:"x0",fallback:()=>a.getDefaultX0()},{key:"k",label:"k",fallback:()=>a.getDefaultK(),transform:t=>Math.max(.1,t)}],c=new Map;for(const t of u)c.set(t.key,ot.input.float(t.label,{value:null!==(o=s[t.key])&&void 0!==o?o:t.fallback(),format:"#0.000",onValueChanged:e=>{const n=t.transform?t.transform(null!=e?e:t.fallback()):null!=e?e:t.fallback();s[t.key]=n,this.onUpdate({[t.key]:n}),a.redrawAll(!1)}}));c.get("min").setTooltip("Minimum property value"),c.get("max").setTooltip("Maximum property value");const f=ot.form([c.get("min"),c.get("max"),c.get("mean"),c.get("sigma"),c.get("x0"),c.get("k")]);f.classList.add("statistics-mpo-param-grid");const d=()=>{c.get("mean").root.classList.toggle("statistics-mpo-hidden","gaussian"!==s.mode),c.get("sigma").root.classList.toggle("statistics-mpo-hidden","gaussian"!==s.mode),c.get("x0").root.classList.toggle("statistics-mpo-hidden","sigmoid"!==s.mode),c.get("k").root.classList.toggle("statistics-mpo-hidden","sigmoid"!==s.mode)};d(),a.onParamsChanged=t=>{Object.assign(s,t),(()=>{var t;for(const e of u)c.get(e.key).value=null!==(t=s[e.key])&&void 0!==t?t:e.fallback()})(),this.onUpdate(t)},r.push(a.onChanged.subscribe(t=>{s.line=t,"freeform"===s.mode&&this.onUpdate({line:t})})),i=l.root,a.root.classList.add("statistics-mpo-plot"),n.append(a.root,Ln("PARAMETERS"),f)},l=()=>{var t;const e=this.prop,o=new wn(e,!0,!0);(null===(t=this.mappedCol)||void 0===t?void 0:t.isCategorical)&&o.setChoices([...this.mappedCol.categories]),r.push(o.onChanged.subscribe(()=>this.onUpdate(this.prop))),n.append(Ln("CATEGORIES"),o.root)},u=()=>{for(const t of r)t.unsubscribe();r.length=0},c=()=>{u(),ot.empty(n),i=void 0,mn(this.prop)?a():l();const t=[];this.mappedCol||t.push(s.root),i&&t.push(i),t.length>0&&n.prepend(ot.divH(t,"statistics-mpo-dialog-header-row")),n.append(Ln("MISSING VALUES"),this.buildDefaultScoreInput(this.prop))};c(),e.add(n),e.onOK(()=>{var n;u(),this.prop.functionType!==t.functionType?null===(n=this.onTypeChanged)||void 0===n||n.call(this,this.prop):this.onUpdate(this.prop),e.close()}),e.onCancel(()=>{u(),this.prop=t,this.onUpdate(t),e.close()}),e.show()}}var Rn=s(5072),Fn=s.n(Rn),Dn=s(7825),Bn=s.n(Dn),kn=s(7659),Un=s.n(kn),Vn=s(5056),Gn=s.n(Vn),$n=s(540),Hn=s.n($n),qn=s(1113),Yn=s.n(qn),Wn=s(6801),jn={};jn.styleTagTransform=Yn(),jn.setAttributes=Gn(),jn.insert=Un().bind(null,"head"),jn.domAPI=Bn(),jn.insertStyleElement=Hn(),Fn()(Wn.A,jn),Wn.A&&Wn.A.locals&&Wn.A.locals;class Xn{constructor(t,e=!1,n=!1){this.root=ot.div([]),this.onChanged=new hn.Subject,this.design=!1,this.preview=!1,this.rows={},this.rowIds={},this.rowSubs=new Map,this.propertyOrder=[],this.columnMapping={},this.dataFrame=t,this.design=e,this.preview=n,this.aggregationInput=ot.input.choice("Aggregation",{items:yn,value:An,nullable:!1,onValueChanged:t=>{this.profile&&(this.profile.aggregation=t),this.emitChange()}}),this.aggregationInput.setTooltip("Score aggregation method")}newRowId(){return crypto.randomUUID()}setProfile(t){var e,n;if(t)for(const n of Object.keys(t.properties)){const o=vn(t.properties[n]);mn(o)&&(null!==(e=o.mode)&&void 0!==e||(o.mode="freeform")),t.properties[n]=o}for(const t of this.rowSubs.values())t.unsubscribe();this.rowSubs.clear(),this.profile=t,this.aggregationInput.value=null!==(n=null==t?void 0:t.aggregation)&&void 0!==n?n:An,this.columnMapping={},this.rows={},this.rowIds={},this.propertyOrder=t?Object.keys(t.properties):[];for(const t of this.propertyOrder)this.rowIds[t]=this.newRowId();this.render()}getProfile(){return this.profile}setDesignMode(t){this.design!==t&&(this.design=t,this.rows={},this.render())}setPreviewMode(t){this.preview!==t&&(this.preview=t,this.rows={},this.render())}render(){if(ot.empty(this.root),!this.profile)return this.renderEmpty("No profile specified.");const t=this.propertyOrder.map(t=>{const e=this.rowIds[t];return this.rows[e]||(this.rows[e]=this.buildRow(t,e,this.profile.properties[t])),this.rows[e]});if(!t.length)return this.preview||this.root.append(this.buildHeader()),this.design?this.renderDesignEmpty():this.renderEmpty("No properties defined.");this.preview||this.root.append(this.buildHeader()),this.root.append(ot.divV(t))}renderEmpty(t){this.root.append(ot.divText(t))}renderDesignEmpty(){const t=ot.iconFA("chart-line"),e=ot.h3("No properties yet"),n=ot.p("Select a dataset to auto-populate properties from its numerical columns, or add them manually."),o=ot.link("+ Add Property",()=>this.addProperty()),r=ot.divV([t,e,n,o],"statistics-mpo-empty-state");this.root.append(r)}addProperty(){if(!this.profile)return;const t=`NewProperty${Object.keys(this.profile.properties).length+1}`,e=this.newRowId();this.profile.properties[t]=pn(),this.rowIds[t]=e,this.propertyOrder.push(t),this.rows={},this.render(),this.emitChange()}buildHeader(){return ot.divH([ot.divText("Property","statistics-mpo-header-property"),ot.divText("Weight","statistics-mpo-header-weight"),ot.divText("Desirability","statistics-mpo-header-desirability")],"statistics-mpo-header")}buildRow(t,e,n){var o;const r=ot.divH([],"statistics-mpo-row");r.dataset.rowId=e;const i=this.resolveColumn(t);if(i){const e=this.correctPropertyType(n,i);e&&(n=e,this.profile.properties[t]=n)}const s=Sn.create(n,300,80,this.design);s.root.classList.add("statistics-mpo-editor-fill"),null===(o=this.rowSubs.get(e))||void 0===o||o.unsubscribe(),this.rowSubs.set(e,s.onChanged.subscribe(()=>this.emitChange()));const a=this.buildPropertyCell(e,t),l=this.buildWeightCell(e,n),u=this.buildColumnSelector(e,t,s),c=this.design?this.buildModeGear(e,n,s):null,f=this.design?this.buildRowControls(e):null;return r.append(ot.divV([a,u].filter(Boolean),"statistics-mpo-property-cell"),l,ot.divH([s.root,c].filter(Boolean))),f&&r.append(f),r}buildPropertyCell(t,e){if(this.dataFrame){const t=ot.divText(e);return ot.tooltip.bind(t,()=>e),t}let n=e;const o=ot.input.string("",{value:e,onValueChanged:t=>{t&&t!==n&&(this.renameProperty(n,t),n=t)}});return ot.tooltip.bind(o.input,()=>n),o.root}buildWeightCell(t,e){var n;const o=this.getPropertyNameByRowId(t),r=[],i=ot.input.float("",{value:e.weight,min:0,max:1,format:"#0.000",onValueChanged:t=>{o&&this.mutateProperty(o,e=>e.weight=Math.max(0,Math.min(1,null!=t?t:0)))}});if(i.root.classList.add("statistics-mpo-weight-input"),r.push(i.root),this.dataFrame){const t=this.getNumericalColumnNames();let s=!!e.weightColumn&&t.includes(e.weightColumn);const a=ot.input.choice("",{items:t,nullable:!0,value:null!==(n=e.weightColumn)&&void 0!==n?n:"",onValueChanged:t=>{o&&this.mutateProperty(o,e=>e.weightColumn=t||void 0)}}),l=()=>{i.root.classList.toggle("statistics-mpo-hidden",s),a.root.classList.toggle("statistics-mpo-hidden",!s),u.classList.toggle("statistics-mpo-weight-toggle-active",s)},u=ot.iconFA("columns",()=>{s=!s,l(),!s&&o?this.mutateProperty(o,t=>{delete t.weightColumn}):s&&o&&a.value&&this.mutateProperty(o,t=>t.weightColumn=a.value||void 0)});u.classList.add("statistics-mpo-weight-toggle"),ot.tooltip.bind(u,()=>s?"Switch to manual weight":"Use weight from column"),l(),r.push(a.root,u)}return ot.divH(r,"statistics-mpo-weight-cell")}buildColumnSelector(t,e,n){var o,r;if(!this.dataFrame)return null;const i=this.getEligibleColumnNames(),s=null!==(o=this.columnMapping[e])&&void 0!==o?o:null;if(s){const t=this.dataFrame.col(s);null===(r=n.setColumn)||void 0===r||r.call(n,t)}const a=ot.input.choice("",{items:i,nullable:!0,value:null!=s?s:"",onValueChanged:o=>{var r;this.columnMapping[e]=null!=o?o:null;const i=o?this.dataFrame.col(o):null;i&&this.switchPropertyType(e,t,i)||(null===(r=n.setColumn)||void 0===r||r.call(n,i),this.emitChange())}});return a.root}getEligibleColumnNames(){return this.dataFrame?Array.from(this.dataFrame.columns).filter(t=>!t.isCategorical||t.categories.length<=20).map(t=>t.name):[]}getNumericalColumnNames(){return this.dataFrame?Array.from(this.dataFrame.columns.numerical).map(t=>t.name):[]}resolveColumn(t){var e,n,o;if(!this.dataFrame)return null;const r=this.getEligibleColumnNames(),i=null!==(n=null!==(e=this.columnMapping[t])&&void 0!==e?e:r.find(e=>e.toLowerCase()===t.toLowerCase()))&&void 0!==n?n:null;return i&&(this.columnMapping[t]=i),i&&null!==(o=this.dataFrame.col(i))&&void 0!==o?o:null}correctPropertyType(t,e){if(mn(t)&&e.isCategorical){const n=e.categories.map(t=>({name:t,desirability:1}));return gn(t.weight,n)}return!mn(t)&&e.isNumerical?pn(t.weight,e.min,e.max):null}switchPropertyType(t,e,n){if(!this.profile)return!1;const o=this.correctPropertyType(this.profile.properties[t],n);return!!o&&(this.profile.properties[t]=o,this.rebuildRow(t,e),!0)}rebuildRow(t,e){const n=this.rows[e],o=this.buildRow(t,e,this.profile.properties[t]);this.rows[e]=o,(null==n?void 0:n.parentNode)&&n.replaceWith(o),this.emitChange()}buildModeGear(t,e,n){const o=ot.icons.settings(()=>{var o,r;const i=this.getPropertyNameByRowId(t);if(!i)return;const s=this.columnMapping[i],a=s&&null!==(r=null===(o=this.dataFrame)||void 0===o?void 0:o.col(s))&&void 0!==r?r:null;this.openModeDialog(i,t,e,n,a)});return o.classList.add("statistics-mpo-gear"),o}buildRowControls(t){const e=ot.icons.add(()=>this.insertRowAfterRow(t)),n=ot.icons.delete(()=>this.deleteRow(t));return ot.divH([e,n],"statistics-mpo-control-buttons")}openModeDialog(t,e,n,o,r=null){new Pn(t,n,e=>{var n;const r=null===(n=this.profile)||void 0===n?void 0:n.properties[t];r&&Object.assign(r,e),o.redrawAll()},n=>{this.profile&&(this.profile.properties[t]=n,this.rebuildRow(t,e))},r).show()}getPropertyNameByRowId(t){var e;return null===(e=Object.entries(this.rowIds).find(([,e])=>e===t))||void 0===e?void 0:e[0]}renameProperty(t,e){var n;if(!this.profile||this.profile.properties[e])return;const o=this.rowIds[t];this.profile.properties[e]=this.profile.properties[t],delete this.profile.properties[t],this.columnMapping[e]=null!==(n=this.columnMapping[t])&&void 0!==n?n:null,delete this.columnMapping[t];const r=this.propertyOrder.indexOf(t);r>=0&&(this.propertyOrder[r]=e),delete this.rowIds[t],this.rowIds[e]=o,this.emitChange()}deleteRow(t){var e;const n=this.getPropertyNameByRowId(t);if(!n||!this.profile)return;delete this.profile.properties[n],delete this.columnMapping[n],delete this.rowIds[n],null===(e=this.rowSubs.get(t))||void 0===e||e.unsubscribe(),this.rowSubs.delete(t);const o=this.propertyOrder.indexOf(n);o>=0&&this.propertyOrder.splice(o,1);const r=this.rows[t];delete this.rows[t],0===this.propertyOrder.length?this.render():null==r||r.remove(),this.emitChange()}insertRowAfterRow(t){var e;if(!this.profile)return;const n=this.getPropertyNameByRowId(t);if(!n)return;const o=`NewProperty${Object.keys(this.profile.properties).length+1}`,r=this.newRowId();this.profile.properties[o]=pn(),this.rowIds[o]=r;const i=this.propertyOrder.indexOf(n);this.propertyOrder.splice(i+1,0,o);const s=this.buildRow(o,r,this.profile.properties[o]);this.rows[r]=s,null===(e=this.rows[t])||void 0===e||e.after(s),this.emitChange()}mutateProperty(t,e){var n;const o=null===(n=this.profile)||void 0===n?void 0:n.properties[t];o&&(e(o),this.emitChange())}emitChange(){this.onChanged.next(),I.events.fireCustomEvent("grok-mpo-score-changed",{})}}var zn=s(4884),Kn={};Kn.styleTagTransform=Yn(),Kn.setAttributes=Gn(),Kn.insert=Un().bind(null,"head"),Kn.domAPI=Bn(),Kn.insertStyleElement=Hn(),Fn()(zn.A,Kn),zn.A&&zn.A.locals&&zn.A.locals;const Qn="pMPO is not applicable",Zn="Failed to compute pMPO parameters",Jn="desired",to="non-desired",eo="Mean",no="p-value",oo=new Map([["desAvg",`${eo}(${Jn})`],["desStd",`Std(${Jn})`],["nonDesAvg",`${eo}(${to})`],["nonDesStd",`Std(${to})`],["tstat","t-statistics"],["pValue",no]]),ro="Descriptor",io=ro+" Statistics",so="Selected",ao="Weight",lo="pMPO score",uo="Desirability Curve",co=.001,fo=.001,ho=.53,mo=.01,po=.05,go=.01,vo="0.000";var yo;!function(t){t.SELECTED="rgb(26, 146, 26)",t.SKIPPED="rgb(208, 57, 67)"}(yo||(yo={}));const Ao="System:AppData/Chem/mpo",wo=[0,.25,.5,1,1.5,2,2.5,3,4,5],Co=wo.slice(1).map(t=>-t).reverse().concat(wo),Eo=wo.concat([.12,.37,.63,.75,.88,1.25,1.75,2.25,2.75]).sort(),bo=Eo.slice(1).map(t=>-t).reverse().concat(Eo),xo="TPR (Sensitivity)",_o="FPR (1 - Specificity)",No=101,Mo=new Float32Array(Array.from({length:No},(t,e)=>e/100)),To="System:AppData/Eda/drugs-props-train.csv",So="System:AppData/Eda/drugs-props-train-scores.csv",Oo=new Map([["tolerance",.001],["maxIter",25],["nonZeroParam",1e-4],["initialScale",.02],["scaleReflaction",1],["scaleExpansion",2],["scaleContraction",-.5]]),Io=new Float32Array([.5,go]),Lo=new Float32Array([1,1]);var Po;!function(t){t.GREATER=">",t.LESS="<",t.GREATER_OR_EQUAL="≥",t.LESS_OR_EQUAL="≤",t.DEFAULT="≤"}(Po||(Po={}));const Ro=[Po.GREATER,Po.LESS,Po.GREATER_OR_EQUAL,Po.LESS_OR_EQUAL],Fo=["perfect","good","true","t","g","active","a","yes","y"];function Do(t,e){const n=t.groupBy([e.name]).getGroups();let o,r;for(const t in n)t.toLowerCase().includes("true")?o=n[t]:r=n[t];return{desired:o,nonDesired:r}}function Bo(t,e){const n=t.length,o=e.length;if(n<2||o<2)throw new Error(`Failed to compute the "${t.name}" descriptor statistics: \n both samples must have at least two observations.`);const r=t.stats.avg,i=e.stats.avg,s=t.stats.variance,a=e.stats.variance,l=t.stats.stdev,u=e.stats.stdev,c=Math.sqrt(s/n+a/o);if(0===c)throw new Error(`Failed to compute the "${t.name}" descriptor statistics: \n zero variance.`);const f=(r-i)/c,d=Math.pow(s/n+a/o,2)/(s*s/(n*n*(n-1))+a*a/(o*o*(o-1))),h=2*(1-tn.studentt.cdf(Math.abs(f),d));return{desAvg:r,desStd:l,desLen:n,nonDesAvg:i,nonDesStd:u,nonSesLen:o,min:Math.min(t.stats.min,e.stats.min),max:Math.max(t.stats.max,e.stats.max),tstat:f,pValue:h}}function ko(e,n,o){if(e.length!==n.length)throw new Error("Failed to compute confusion matrix: columns have different lengths.");if(e.type!==t.COLUMN_TYPE.BOOL)throw new Error("Failed to compute confusion matrix: desirability column must be boolean.");if(!n.isNumerical)throw new Error("Failed to compute confusion matrix: prediction column must be numerical.");let r=0,i=0,s=0,a=0;const l=e.getRawData(),u=n.getRawData();let c=0,f=0,d=l[0];for(let t=0;t<n.length;++t)1==(d>>>f&1)?u[t]>=o?++r:++a:u[t]>=o?++s:++i,++f,f>=32&&(f=0,++c,d=l[c]);return{TP:r,TN:i,FP:s,FN:a}}function Uo(t,e){if(t.length!==e.length)throw new Error("Failed to compute AUC: TPR and FPR arrays have different lengths.");let n=0;for(let o=1;o<t.length;++o)n+=Math.abs(e[o]-e[o-1])*((t[o]+t[o-1])/2);return n}function Vo(t,e){const n=new Float32Array(No),o=new Float32Array(No);let r=-1,i=-1,s=Mo[0];for(let a=0;a<No;++a){const l=ko(t,e,Mo[a]);n[a]=l.TP+l.FN>0?l.TP/(l.TP+l.FN):0,o[a]=l.FP+l.TN>0?l.FP/(l.FP+l.TN):0,i=n[a]-o[a],i>r&&(r=i,s=Mo[a])}return{auc:Uo(n,o),threshold:s,tpr:n,fpr:o}}var Go,$o,Ho,qo,Yo;!function(t){t.MIN="minimize",t.MAX="maximize"}(Go||(Go={})),function(t){t.OPTIMAL="optimal",t.NON_OPT="non-optimal"}($o||($o={})),function(t){t[t.FORM=.15]="FORM",t[t.VIEWER=.5]="VIEWER"}(Ho||(Ho={})),function(t){t.OPT="Pareto optimality",t.SIZE="Pareto size"}(qo||(qo={})),function(t){t[t.OPTIMAL=8]="OPTIMAL",t[t.NON_OPT=4]="NON_OPT"}(Yo||(Yo={}));const Wo=[t.Color.darkGreen,t.Color.yellow,t.Color.darkRed];function jo(t){return t===Go.MIN?[...Wo]:[...Wo].reverse()}function Xo(e,n=!0){const o=ot.label("Color scale:");o.style.paddingRight="7px";const r=[o],i=ot.label(n?"min":"worst"),s=ot.label(". . ."),a=ot.label(n?"max":"best"),l=jo(e),u=[i,s,a].map((e,n)=>(1!==n&&(e.style.fontWeight="bold",e.style.color=t.Color.toRgb(l[n])),e.style.marginRight="5px",e));return r.push(...u),ot.divH(r)}var zo=function(t,e,n,o){return new(n||(n=Promise))(function(r,i){function s(t){try{l(o.next(t))}catch(t){i(t)}}function a(t){try{l(o.throw(t))}catch(t){i(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(s,a)}l((o=o.apply(t,e||[])).next())})};function Ko(e){const n=e.size,o=new Map;oo.forEach((t,e)=>{o.set(e,new Float64Array(n))});const r=[...e.keys()],i=[t.Column.fromStrings(ro,r),t.Column.fromInt32Array(uo,new Int32Array(n)),t.Column.fromFloat32Array(ao,new Float32Array(n).fill(t.FLOAT_NULL))];r.forEach((t,n)=>{const r=e.get(t);null!=r&&oo.forEach((t,e)=>{const i=r[e];o.get(e)[n]=i})}),oo.forEach((e,n)=>{i.push(t.Column.fromFloat64Array(e,o.get(n)))});const s=t.DataFrame.fromColumns(i);return s.name=io,s}function Qo(t,e){const n=[],o=t.col(ro);if(null==o)throw new Error(`No column "${ro} in the table with descriptors statistics.`);const r=o.toList(),i=t.col(no);if(null==i)throw new Error(`No column "${no} in the table with descriptors statistics.`);const s=i.getRawData();for(let o=0;o<t.rowCount;++o)s[o]<e&&n.push(r[o]);return n}function Zo(t,e,n,o){const r=ot.div();r.classList.add("eda-pmpo-tooltip-line");const i=ot.div();i.classList.add("eda-pmpo-box"),i.style.backgroundColor=yo.SELECTED;const s=ot.span([]);s.textContent=`- ${n}`,r.appendChild(i),r.appendChild(s);const a=ot.div();a.classList.add("eda-pmpo-tooltip-line");const l=ot.div();l.classList.add("eda-pmpo-box"),l.style.backgroundColor=yo.SKIPPED;const u=ot.span([]);return u.textContent=`- ${o}`,a.appendChild(l),a.appendChild(u),ot.divV([ot.h2(t),ot.divText(e),r,a])}function Jo(t,e){const n=[];for(let o=0;o<e.length;++o)for(let r=o+1;r<e.length;++r)n.push([e[o],e[r],Math.pow(t.byName(e[o]).stats.corr(t.byName(e[r])),2)]);return n}function tr(t,e,n,o,r){const i=r.sort((t,e)=>e[2]-t[2]),s=new Set(e);return i.filter(t=>t[2]>o).forEach(t=>{const[e,o,r]=t,i=n.get(e).pValue,a=n.get(o).pValue,l=n.get(e).tstat,u=n.get(o).tstat;i>a?s.delete(e):i<a||Math.abs(l)>Math.abs(u)?s.delete(o):s.delete(e)}),[...s]}function er(t,e,n,o){const r=new Map;let i=0;return n.forEach(n=>{const s=t.rowCount,a=e.rowCount,l=t.col(n);if(null==l)throw new Error(Zn+`: no column "${n}" in the desired table.`);const u=e.col(n);if(null==u)throw new Error(Zn+`: no column "${n}" in the non-desired table.`);const c=l.stats.avg,f=l.stats.stdev*Math.sqrt((s-1)/s),d=u.stats.avg,h=u.stats.stdev*Math.sqrt((a-1)/a),m=(g=f,y=h,(p=c)<(v=d)?{cutoff:(v-p)/(g+y)*g+p,cutoffDesired:Math.max(p,v-y),cutoffNotDesired:Math.max(p+g,v)}:{cutoff:(p-v)/(g+y)*y+v,cutoffDesired:Math.min(v+y,p),cutoffNotDesired:Math.max(v,p-g)});var p,g,v,y;const A=Math.exp(-Math.pow(m.cutoff-c,2)/(2*Math.pow(f,2))),w=function(t,e,n,o){const r=1/(2*Math.pow(e,2))-1/(2*Math.pow(o,2)),i=n/Math.pow(o,2)-t/Math.pow(e,2),s=Math.pow(t,2)/(2*Math.pow(e,2))-Math.pow(n,2)/(2*Math.pow(o,2))-Math.log(o/e);if(Math.abs(r)<1e-12)return Math.abs(i)<1e-12?[]:[-s/i];const a=i*i-4*r*s;if(a<0)return[];const l=Math.sqrt(a);return[(-i+l)/(2*r),(-i-l)/(2*r)]}(c,f,d,h),C=Math.pow(A,-1)-1,E=Math.pow(o,-1)-1,b=Math.pow(10,Math.log10(E/C)/(-1*(d-m.cutoff)));let x=null;if(w.length>0){for(const t of w){const e=Math.min(c,d),n=Math.max(c,d);if(e-1e-8<=t&&t<=n+1e-8){x=t;break}}null==x&&(x=w[0])}else x=m.cutoff;const _=m.cutoffNotDesired,N=function(t,e,n,o,r=.05){let i;if(e<=0)i=n===t?1:0;else{const o=1/(e*Math.sqrt(2*Math.PI)),r=-.5*Math.pow((n-t)/e,2);i=o*Math.exp(r)}i=Math.max(i,1e-12);const s=Math.max(1/i-1,1e-12),a=1/r-1,l=o-n;let u;if(Math.abs(l)<1e-12)u=1;else{const t=a/s;if(t<=0)u=1;else try{u=Math.exp(-Math.log(t)/l)}catch(t){u=1}}return{pX0:i,b:s,c:u}}(c,f,x,_,o),M=Math.abs(c-d)/(f+h);i+=M,r.set(n,{desAvg:c,desStd:f,nonDesAvg:d,nonDesStd:h,min:Math.min(l.stats.min,u.stats.min),max:Math.max(l.stats.max,u.stats.max),cutoff:m.cutoff,cutoffDesired:m.cutoffDesired,cutoffNotDesired:m.cutoffNotDesired,pX0:N.pX0,b:C,c:b,zScore:M,weight:M,intersections:w,x0:x,xBound:_,inflection:A})}),r.forEach(t=>{t.weight=t.zScore/i}),r}function nr(t,e,n,o,r){return{type:"MPO Desirability Profile",name:n,description:o,properties:or(t,e,r)}}function or(t,e,n){const o={};return t.forEach((t,r)=>{const i=sr(t,n);o[r]={weight:t.weight,line:ir(t,e,n),min:Math.min(...i),max:Math.max(...i)}}),o}function rr(t,e,n){return function(t,e,n){return Math.exp(-Math.pow(t-e,2)/(2*Math.pow(n,2)))}(t,e.desAvg,e.desStd)*(n?function(t,e,n,o){return o>0?1/(1+n*Math.pow(o,-(t-e))):1/(1+n)}(t,e.cutoff,e.b,e.c):1)}function ir(t,e,n){return sr(t,n).map(n=>[n,rr(n,t,e)])}function sr(t,e){const n=function(t,e,n){return n?Co.map(n=>t+n*e):bo.map(n=>t+n*e)}(t.desAvg,t.desStd,e);if(e){const e=Math.min(t.min,t.desAvg-3*t.desStd),o=Math.max(t.max,t.desAvg+3*t.desStd);return n.filter(t=>e<=t&&t<=o).sort()}return n}class ar extends Error{constructor(t){super(t),this.name="PmpoError"}}function lr(t,e,n){const o=t.stats.min,r=t.stats.max;switch(n){case Po.LESS:return r>=e&&o<e;case Po.LESS_OR_EQUAL:return r>e&&o<=e;case Po.GREATER:return o<=e&&r>e;default:return o<e&&r>=e}}function ur(t){const e=t.filter(t=>Fo.includes(t));return e.length>0?e:[t[0]]}function cr(t,e,n,o){for(let r=0;r<e;r++){let i=0;for(let t=0;t<e+1;t++)t!=n&&(i+=o[t][r]);t[r]=i/e}}function fr(t,e,n,o,r,i,s,a){for(let l=0;l<i;l++)e[l]=t[l],e[l]+=r*(t[l]-o[n][l]),e[l]<s[l]?e[l]=s[l]:e[l]>a[l]&&(e[l]=a[l])}function dr(t,e,n,o,r,i){return s=this,a=void 0,u=function*(){const s=o.get("tolerance"),a=o.get("maxIter"),l=o.get("scaleReflaction"),u=o.get("scaleExpansion"),c=o.get("scaleContraction"),f=n.length+1,d=n.length,[h,m]=function(t,e,n,o,r){const i=n.length+1,s=n.length,a=e.get("nonZeroParam"),l=e.get("initialScale"),u=new Array(i),c=new Array(i);for(let e=0;e<i;e++){u[e]=new Float32Array(s);for(let t=0;t<s;t++)u[e][t]=n[t],0!=e&&e-1===t&&(0==n[t]?u[e][t]=a:u[e][t]+=l*n[e-1],u[e][t]<o[t]?u[e][t]=o[t]:u[e][t]>r[t]&&(u[e][t]=r[t]));c[e]=t(u[e])}return[u,c]}(e,o,n,r,i),p=new Array(f);for(let t=0;t<f;t++)p[t]=t;const g=p.length-1;let v=0,y=0,A=0,w=0;const C=new Float32Array(d),E=new Float32Array(d),b=new Float32Array(d),x=new Float32Array(d),_=new Array(a);if(f>1){let n=0;for(;p.sort((t,e)=>m[t]-m[e]),n=Math.min(100,Math.floor(100*v/a)),t.update(n,`Optimizing pMPO... (${n}%)`),yield new Promise(t=>setTimeout(t,1)),!(t.canceled||v>a);){if(0==v&&(y=m[0],A=2*m[p[0]]),_[v]=y,++v,y=m[p[0]],A-y>s)w=0;else if(++w,w>2*f)break;A=y,cr(C,d,p[g],h),fr(C,E,p[g],h,l,d,r,i);const t=e(E);if(t<m[p[g]]){fr(C,b,p[g],h,u,d,r,i);const n=e(b);if(n<t){m[p[g]]=n;for(let t=0;t<d;t++)h[p[g]][t]=b[t];continue}m[p[g]]=t;for(let t=0;t<d;t++)h[p[g]][t]=E[t];continue}fr(C,x,p[g],h,c,d,r,i);const n=e(x);if(!(n<m[p[g]]))break;m[p[g]]=n;for(let t=0;t<d;t++)h[p[g]][t]=x[t]}for(let t=v;t<a;t++)_[t]=m[p[0]]}return{optimalPoint:h[p[0]],iterations:v}},new((l=void 0)||(l=Promise))(function(t,e){function n(t){try{r(u.next(t))}catch(t){e(t)}}function o(t){try{r(u.throw(t))}catch(t){e(t)}}function r(e){var r;e.done?t(e.value):(r=e.value,r instanceof l?r:new l(function(t){t(r)})).then(n,o)}r((u=u.apply(s,a||[])).next())});var s,a,l,u}var hr=function(t,e,n,o){return new(n||(n=Promise))(function(r,i){function s(t){try{l(o.next(t))}catch(t){i(t)}}function a(t){try{l(o.throw(t))}catch(t){i(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(s,a)}l((o=o.apply(t,e||[])).next())})};class mr{static isApplicable(t,e,n,o,r,i=!1){const s=e.length,a=t=>{i&&I.shell.warning(Qn+t)};if(n<fo)return a(`: too small p-value threshold - ${n}, minimum - 0.001`),!1;if(o<mo)return a(`: too small R² threshold - ${o}, minimum - 0.01`),!1;if(r<go)return a(`: too small q-cutoff - ${r}, minimum - 0.01`),!1;if(s<10)return a(`: not enough of samples - ${s}, minimum - 10`),!1;if(0===e.stats.stdev)return a(`: "${e.name}" has a single category.`),!1;let l=0;for(const e of t){if(!e.isNumerical)return a(`: "${e.name}" is not numerical.`),!1;if(e.stats.missingValueCount===e.length)return a(`: "${e.name}" contains only missing values.`),!1;e.stats.stdev>0&&++l}return!(l<1&&(a(": not enough of non-constant descriptors."),1))}static isTableValid(e,n=!0){if(e.rowCount<2)return n&&I.shell.warning(Qn+`. Not enough of samples: ${e.rowCount}, minimum: 2.`),!1;let o=0;for(const n of e.columns)(n.isNumerical||n.type===t.TYPE.BOOL)&&n.stats.stdev>0&&++o;return!(o<2&&(n&&I.shell.warning(Qn+": not enough of non-constant columns."),1))}static fit(e,n,o,r,i,s,a=!0){if(a&&!mr.isApplicable(n,o,r,i,s))throw new Error("Failed to train pMPO model: the method is not applicable to the inputs");const l=n.names(),{desired:u,nonDesired:c}=Do(e,o),f=new Map;l.forEach(t=>{f.set(t,Bo(u.col(t),c.col(t)))});const d=Ko(f);!function(t,e){const n=t.col(no);if(null==n)return;const o={};o[`<${e}`]=yo.SELECTED,o[`>=${e}`]=yo.SKIPPED,n.meta.colors.setConditional(o)}(d,r);const h=Qo(d,r);if(h.length<1)throw new ar("Cannot train pMPO model: all descriptors have high p-values (not significant).");const m=Jo(n,h),p=tr(0,h,f,i,m);return function(e,n){if(n.length<1)throw new Error("Empty list of selected descriptors.");const o=e.rowCount,r=new Array(o),i=e.col(ro);if(null==i)throw new Error(`No column "${ro} in the table with descriptors statistics.`);const s=i.toList();let a=!0;const l={};for(let t=0;t<o;++t)a=n.includes(s[t]),r[t]=a,l[s[t]]=a?yo.SELECTED:yo.SKIPPED;i.colors.setCategorical(l),e.columns.add(t.Column.fromList(t.COLUMN_TYPE.BOOL,so,r))}(d,p),function(e,n,o,r){const i=new Map;n.forEach(e=>{i.set(e,new Float32Array(n.length).fill(t.FLOAT_NULL))});const s=e.col(ro).toList();o.forEach(t=>{const[e,n,o]=t;i.get(e)[s.indexOf(n)]=o,i.get(n)[s.indexOf(e)]=o,i.get(e)[s.indexOf(e)]=1,i.get(n)[s.indexOf(n)]=1}),r.forEach(n=>{e.columns.add(t.Column.fromFloat32Array(n,i.get(n)))})}(d,l,m,p),function(t,e,n){e.forEach(e=>{const o=t.col(e);if(null==o)return;const r={};r[`>=${n}`]=yo.SKIPPED,r[`<${n}`]=yo.SELECTED,o.meta.colors.setConditional(r)})}(d,l,i),{params:er(u,c,p,s),descrStatsTable:d,selectedByPvalue:h,selectedByCorr:p}}static predict(e,n,o,r){const i=e.rowCount,s=new Float64Array(i).fill(0),a=[];return n.forEach((t,n)=>{const r=e.col(n),l=t.b,u=t.c,c=t.cutoff;let f=t.weight;const d=t.desAvg,h=t.desStd,m=1/(2*Math.pow(h,2));if(null==r)throw new Error(`Failed to apply pMPO: inconsistent data, no column "${n}" in the table "${e.name}"`);r.stats.missingValueCount>0&&a.push(r);const p=r.getRawData();if(o)if(u>0)for(let t=0;t<i;++t)s[t]+=f*Math.exp(-Math.pow(p[t]-d,2)*m)/(1+l*Math.pow(u,-(p[t]-c)));else{f/=1+l;for(let t=0;t<i;++t)s[t]+=f*Math.exp(-Math.pow(p[t]-d,2)*m)}else for(let t=0;t<i;++t)s[t]+=f*Math.exp(-Math.pow(p[t]-d,2)*m)}),t.Column.fromFloat64Array(r,s)}constructor(e,n){var o;this.params=null,this.desirabilityProfile=null,this.initTable=t.DataFrame.create(),this.statGrid=t.Viewer.grid(this.initTable,{showTitle:!0,title:io}),this.predictionName=lo,this.boolPredictionName="",this.desirabilityProfileRoots=new Map,this.tresholdedColumn=null,this.threshColTooltip=null,this.rocCurve=t.Viewer.scatterPlot(this.initTable,{showTitle:!0,showSizeSelector:!1,showColorSelector:!1}),this.confusionMatrix=t.Viewer.fromType("Confusion matrix",this.initTable,{xColumnName:"control",yColumnName:"control",showTitle:!0,title:"Confusion Matrix",descriptionPosition:"Bottom",description:"Confusion matrix for the predicted vs actual desirability labels.",descriptionVisibilityMode:"Always"}),this.table=e,this.view=null!=n?n:null!==(o=I.shell.tableView(e.name))&&void 0!==o?o:I.shell.addTableView(e),this.desirabilityColumns=this.getDesirabilityColumns(),this.numericCols=this.getValidNumericCols(),this.predictionName=e.columns.getUnusedName(lo),this.missingValsIndeces=function(t){const e=new Map;for(const n of t){if(!We.includes(n.type))throw new Error($e.UNSUPPORTED_COLUMN_TYPE);if(0===n.stats.missingValueCount)continue;const t=[],o=je(n);n.getRawData().forEach((e,n)=>{e===o&&t.push(n)}),e.set(n.name,t)}return e}(this.numericCols)}setRibbons(){const t=this.view.getRibbonPanels();t.length<1||this.view.setRibbonPanels(t.slice(1))}updateStatisticsGrid(t,e,n,o){const r=this.statGrid;r.dataFrame=t,r.setOptions({showTitle:!0,title:t.name}),r.sort([so],[!1]),r.col(no).format="scientific",r.col(ro).isTextColorCoded=!0,r.col(no).isTextColorCoded=!0,e.forEach(t=>{const e=r.col(t);null!=e&&(e.isTextColorCoded=!0,e.format="0.000")}),r.onCellTooltip((t,i,s)=>{if(t.isColHeader){const n=t.tableColumn;if(null==n)return!1;const o=n.name;switch(o){case ro:return ot.tooltip.show(Zo(ro,"Use of descriptors in model construction:","selected","excluded"),i,s),!0;case uo:return ot.tooltip.show(ot.divV([ot.h2(uo),ot.divText("Desirability profile charts for each descriptor. Only profiles for selected descriptors are shown.")]),i,s),!0;case ao:return ot.tooltip.show(ot.divV([ot.h2(ao),ot.divText("Weights of selected descriptors.")]),i,s),!0;case no:return ot.tooltip.show(Zo(no,"Filtering descriptors by p-value:","selected","excluded"),i,s),!0;default:return!!e.includes(o)&&(ot.tooltip.show(Zo(o,`Correlation of ${o} with other descriptors, measured by R²:`,"weakly correlated","highly correlated"),i,s),!0)}}else if(t.isTableCell){const a=t.tableColumn;if(null==a)return!1;const l=a.name,u=t.value;if(l===ro)return o.includes(u)?ot.tooltip.show("Selected for model construction.",i,s):n.includes(u)?ot.tooltip.show("Excluded due to a high correlation with other descriptors.",i,s):ot.tooltip.show("Excluded due to a high p-value.",i,s),!0;{const o=r.cell(ro,t.gridRow).value;if(l===ao)return!this.desirabilityProfileRoots.has(o)&&(n.includes(o)?ot.tooltip.show(`No weight: <b>${o}</b> is excluded due to a high correlation with other descriptors.`,i,s):ot.tooltip.show(`No weight: <b>${o}</b> is excluded due to a high p-value.`,i,s),!0);if(e.includes(l)&&!n.includes(o))return ot.tooltip.show(`<b>${o}</b> is excluded due to a high p-value; so correlation with <b>${l}</b> is not needed.`,i,s),!0}return!1}});const i=r.col(uo);r.setOptions({rowHeight:75}),i.width=305,i.cellType="html",r.onCellPrepare(t=>{if(null==t.tableColumn)return;if(null==t.tableColumn)return;if(!t.isTableCell)return;if(t.tableColumn.name!==uo)return;const e=r.cell(ro,t.gridRow).value,o=this.desirabilityProfileRoots.get(e);if(null!=o)t.element=o;else{const o=n.includes(e),r=o?"highly correlated with other descriptors":"statistically insignificant",i=o?`No chart shown: <b>${e}</b> is excluded due to a high correlation with other descriptors.`:`No chart shown: <b>${e}</b> is excluded due to a high p-value.`,s=ot.divText(r);s.style.color=yo.SKIPPED,s.classList.add("eda-pmpo-centered-text"),ot.tooltip.bind(s,i),t.element=s}})}updateGrid(){const t=this.view.grid,e=this.predictionName;t.sort([this.predictionName],[!1]);const n=t.col(e);n.format="0.0000",n.isTextColorCoded=!0,t.onCellTooltip((t,n,o)=>{var r;if(t.isColHeader&&t.tableColumn)return t.tableColumn.name===e?(ot.tooltip.show(ot.divV([ot.h2(lo),ot.divText("Scores computed using the trained probabilistic multi-parameter optimization (pMPO) model."),Xo(Go.MAX,!1)]),n,o),!0):null!=this.tresholdedColumn&&t.tableColumn.name===this.tresholdedColumn.name&&(ot.tooltip.show(ot.markdown(null!==(r=this.threshColTooltip)&&void 0!==r?r:""),n,o),!0)})}updateDesirabilityProfileData(t,e){if(null==this.params)return;this.desirabilityProfileRoots.forEach(t=>t.remove()),this.desirabilityProfileRoots.clear();const n=nr(this.params,e,"","",!0);this.desirabilityProfile=nr(this.params,e,"","",!1);const o=t.col(ro).toList(),r=t.col(ao).getRawData(),i=n.properties,s=Object.keys(i);for(const t of s)r[o.indexOf(t)]=i[t].weight;const a=new Xn;a.setProfile(n);const l=a.root.querySelector("div.d4-flex-col.ui-div");null!=l&&l.querySelectorAll("div.d4-flex-row.ui-div.statistics-mpo-row").forEach((t,e)=>{const n=t.querySelector(".statistics-mpo-line-editor");n&&(n.style.width="100%",n.style.height="100%",this.desirabilityProfileRoots.set(s[e],n))})}updateRocCurve(e,n){const o=Vo(e,n),r=t.DataFrame.fromColumns([t.Column.fromFloat32Array("Threshold",Mo),t.Column.fromFloat32Array(_o,o.fpr),t.Column.fromFloat32Array(xo,o.tpr)]);return r.meta.formulaLines.addLine({title:"Non-informative baseline",formula:`\${${xo}} = \${${_o}}`,width:1,style:"dashed",min:0,max:1}),this.rocCurve.dataFrame=r,this.rocCurve.setOptions({xColumnName:_o,yColumnName:xo,linesOrderColumnName:_o,linesWidth:5,markerType:"dot",title:`ROC Curve (AUC = ${o.auc.toFixed(3)})`}),o.threshold}updateConfusionMatrix(t,e,n){this.confusionMatrix.dataFrame=t,this.confusionMatrix.setOptions({xColumnName:e,yColumnName:this.boolPredictionName,description:`Threshold: ${n.toFixed(3)} (optimized via Youden's J)`,title:e+" Confusion Matrix"})}getIndecesOfMissingValues(t){const e=[];return t.forEach(t=>{const n=this.missingValsIndeces.get(t);null!=n&&e.push(...n)}),e}setNulls(e,n){const o=e.getRawData();n.forEach(e=>o[e]=t.FLOAT_NULL)}fitAndUpdateViewers(e,n,o,r,i,s,a){const l=mr.fit(e,n,o,r,i,s);this.params=l.params;const u=l.descrStatsTable,c=l.selectedByPvalue,f=l.selectedByCorr,d=n.names(),h=mr.predict(e,this.params,a,this.predictionName),m=this.getIndecesOfMissingValues(f);this.setNulls(h,m),h.colors.setLinear(jo(Go.MAX),{min:h.stats.min,max:h.stats.max}),e.columns.remove(this.predictionName),e.columns.add(h),this.updateGrid(),this.updateDesirabilityProfileData(u,a),this.updateStatisticsGrid(u,d,c,f);const p=this.updateRocCurve(o,h),g=o.name;e.columns.remove(this.boolPredictionName),this.boolPredictionName=e.columns.getUnusedName(g+"(predicted)");const v=function(e,n,o){if(!e.isNumerical)throw new Error("Failed to compute confusion matrix: prediction column must be numerical.");const r=e.length,i=new Array(r),s=e.getRawData();for(let t=0;t<r;++t)i[t]=s[t]>=n;return t.Column.fromList(t.COLUMN_TYPE.BOOL,o,i)}(h,p,this.boolPredictionName);e.columns.add(v),this.updateConfusionMatrix(e,g,p),this.view.dataFrame.selection.setAll(!1,!0)}runTrainingApp(){const e=this.view.dockManager;e.dock(this.getInputForm(!0).form,t.DOCK_TYPE.LEFT,null,void 0,.1);const n=e.findNode(this.view.grid.root);if(null==n)throw new Error("Failed to train pMPO: missing a grid in the table view.");const o=e.dock(this.statGrid,t.DOCK_TYPE.DOWN,n,void 0,.5),r=e.dock(this.rocCurve,t.DOCK_TYPE.RIGHT,o,void 0,.3);e.dock(this.confusionMatrix,t.DOCK_TYPE.RIGHT,r,void 0,.2),this.setRibbons()}getPmpoAppItems(){return{statsGrid:this.statGrid,rocCurve:this.rocCurve,confusionMatrix:this.confusionMatrix,controls:this.getInputForm(!1),profile:this.desirabilityProfile}}getInputForm(e){const n=ot.form([]);n.append(ot.h2("Training data"));const o=function(e){for(const n of e)if(n.type===t.COLUMN_TYPE.BOOL&&n.stats.stdev>0)return n;for(const t of e)if(t.isNumerical&&t.stats.stdev>0)return t;return e[0]}(this.desirabilityColumns),r=()=>{if(null!=this.tresholdedColumn&&(this.table.columns.remove(this.tresholdedColumn.name),this.tresholdedColumn=null),l.value.type===t.COLUMN_TYPE.BOOL)return l.value;const e=l.value.type===t.COLUMN_TYPE.STRING?function(e,n){const o=new Array(e.length),r=e.getRawData(),i=e.categories;for(let t=0;t<e.length;++t)o[t]=n.includes(i[r[t]]);const s=i.filter(t=>!n.includes(t)),a=`✅ ${n.join(", ")}`,l=`❌ ${s.join(", ")}`;return{column:t.Column.fromList(t.COLUMN_TYPE.BOOL,"",o),tooltip:`Desirability based on the selected categories:\n\n **${a}**\n\n **${l}**`}}(l.value,h.value):function(e,n,o){const r=new Array(e.length),i=e.getRawData(),s=function(t){switch(t){case Po.LESS:return(t,e)=>t<e;case Po.LESS_OR_EQUAL:return(t,e)=>t<=e;case Po.GREATER:return(t,e)=>t>e;case Po.GREATER_OR_EQUAL:return(t,e)=>t>=e;default:throw new Error(`Unsupported sign: ${t}`)}}(o);for(let t=0;t<e.length;++t)r[t]=s(i[t],n);return{column:t.Column.fromList(t.COLUMN_TYPE.BOOL,"",r),tooltip:`Desirability based on the condition:\n\n **${e.name} ${o} ${n}**`}}(l.value,f.value,c.value);return this.tresholdedColumn=e.column,this.threshColTooltip=e.tooltip,this.tresholdedColumn.name=this.table.columns.getUnusedName("Desirability"),this.table.columns.add(this.tresholdedColumn),this.tresholdedColumn},i=()=>{if(w())try{this.fitAndUpdateViewers(this.table,t.DataFrame.fromColumns(s.value).columns,r(),b.value,x.value,_.value,g.value)}catch(t){if(t instanceof ar)I.shell.warning(t.message),ot.tooltip.bind(l.input,t.message),ot.tooltip.bind(s.input,t.message);else{const e=t instanceof Error?t.message:Zn+": the platform issue.";I.shell.error(e),ot.tooltip.bind(l.input,e),ot.tooltip.bind(s.input,e)}l.input.classList.add("d4-invalid"),s.input.classList.add("d4-invalid")}},s=ot.input.columns("Descriptors",{table:this.table,nullable:!1,available:this.numericCols.map(t=>t.name),checked:this.numericCols.filter(t=>t.name!==o.name&&t.stats.stdev>0&&t.stats.missingValueCount<t.length).map(t=>t.name),tooltipText:"Descriptor columns used for model construction.",onValueChanged:t=>{null!=t&&(y=!1,C())}});n.append(s.root),s.addValidator(()=>{if(null==s.value||s.value.length<1)return"Select at least one descriptor column.";if(null!=l.value&&s.value.includes(l.value))return"Desirability column cannot be used as a descriptor.";const t=s.value.filter(t=>0===t.stats.stdev).map(t=>t.name);if(t.length>0)return`Descriptor columns with zero variance: ${t.join(", ")}`;const e=s.value.filter(t=>t.stats.missingValueCount===t.length).map(t=>t.name);return e.length>0?`Descriptor columns with only missing values: ${e.join(", ")}`:null});const a=e=>{if(e.type===t.COLUMN_TYPE.BOOL)d.hidden=!0;else{d.hidden=!1;const n=e.type===t.COLUMN_TYPE.STRING;f.root.hidden=n,c.root.hidden=n}},l=ot.input.column("Desirability",{nullable:!1,value:o,table:this.table,filter:t=>this.desirabilityColumns.includes(t),tooltipText:"Desirability column.",onValueChanged:t=>{null!=t&&(m(),a(t),u=!0,f.value=Math.round(100*t.stats.avg)/100,u=!1,y=!1,C())}});n.append(l.root),l.addValidator(()=>{if(null==l.value)return"Select a desirability column.";if(null!=s.value&&s.value.includes(l.value))return"Desirability column cannot be used as a descriptor.";if(l.value.type===t.COLUMN_TYPE.BOOL){if(0===l.value.stats.stdev)return"All desirability values are the same - scoring is not feasible."}else if(l.value.type===t.COLUMN_TYPE.STRING){if(l.value.categories.length<2)return"String desirability column must have at least 2 categories."}else{if(0===l.value.stats.stdev)return l.value.stats.missingValueCount<l.value.length?"All desirability values are the same - scoring is not feasible.":"Empty column cannot be used as desirability column.";if(null==f.value)return"Specify non-null desirability threshold.";if(!lr(l.value,f.value,c.value))return`All compounds are either desired or non-desired for ${l.value.name} ${c.value} ${f.value}. Adjust the threshold or condition.`}return null});let u=!1;const c=ot.input.choice("Condition",{value:Po.DEFAULT,items:Ro,nullable:!1,tooltipText:"How to compare numeric Desirability column values against the threshold.",onValueChanged:t=>{y=!1,C()}}),f=ot.input.float("Threshold",{value:Math.round(100*o.stats.avg)/100,nullable:!1,tooltipText:"Boundary value that separates desired from non-desired compounds.",format:"0.00",onValueChanged:t=>{if(null!=t){if(u)return;y=!1,C()}}});f.addValidator(()=>null==l.value||l.value.type===t.COLUMN_TYPE.BOOL||l.value.type===t.COLUMN_TYPE.STRING?null:null==f.value?"Specify non-null desirability threshold.":lr(l.value,f.value,c.value)?null:"Adjust the threshold to get both desired and non-desired groups.");const d=ot.divV([c.root,f.root]);n.append(d);let h=null;const m=()=>{var e;null!=h&&(h.root.remove(),h=null),(null===(e=l.value)||void 0===e?void 0:e.type)===t.COLUMN_TYPE.STRING&&(h=ot.input.multiChoice("Preferred",{value:ur(l.value.categories),items:l.value.categories,nullable:!1,tooltipText:"Select which categories should be treated as desirable.",onValueChanged:t=>{if(null!=t){if(u)return;y=!1,C()}}}),h.addValidator(()=>null==h.value||0===h.value.length?"Select at least one preferable category.":null!=l.value&&h.value.length===l.value.categories.length?"At least one category must be non-preferable.":null),d.append(h.root))};a(l.value);const p=ot.h2("Settings");n.append(p),ot.tooltip.bind(p,"Settings of the pMPO model.");const g=ot.input.bool("σ correction",{value:!0,tooltipText:"Use the sigmoidal correction to the weighted Gaussian scores.",onValueChanged:t=>{y=!1,C()}});n.append(g.root);const v=this.table.rowCount<=1e4;let y=!1;const A=()=>hr(this,void 0,void 0,function*(){if(yield new Promise(t=>setTimeout(t,50)),w())if(y)i();else{const e=yield this.getOptimalSettings(t.DataFrame.fromColumns(s.value).columns,r(),g.value);"success"===e.state?(b.value=Math.max(e.pValTresh,fo),x.value=Math.max(e.r2Tresh,mo),_.value=Math.max(e.qCutoff,go),y=!0,i()):I.shell.warning(e.msg)}}),w=()=>{const t=[s.validate(),l.validate(),f.validate(),b.validate(),x.validate(),_.validate()];return null!=h&&t.push(h.validate()),t.every(t=>t)},C=()=>{E.value?A():i()},E=ot.input.bool("Auto-tuning",{value:!1,tooltipText:"Automatically select optimal p-value, R², and q-cutoff by maximizing AUC.",onValueChanged:t=>hr(this,void 0,void 0,function*(){N(!t),y||(t?yield A():i())})});n.append(E.root);const b=ot.input.float("p-value",{nullable:!1,min:fo,max:1,step:.001,value:co,format:vo,tooltipText:"P-value threshold. Descriptors with p-values above this threshold are excluded.",onValueChanged:t=>{E.value||(y=!1,null!=t&&t>=fo&&t<=1&&i())}});n.append(b.root),b.addValidator(()=>null==b.value?"P-value is required.":b.value<fo||b.value>1?"P-value must be between 0.001 and 1.":null);const x=ot.input.float("R²",{format:vo,nullable:!1,min:mo,value:ho,max:1,step:.01,tooltipText:"Squared correlation threshold. Descriptors with squared correlation above this threshold are considered highly correlated. Among them, the descriptor with the lower p-value is retained.",onValueChanged:t=>{E.value||(y=!1,null!=t&&t>=mo&&t<=1&&i())}});n.append(x.root),x.addValidator(()=>null==x.value?"R² is required.":x.value<mo||x.value>1?"R² must be between 0.01 and 1.":null);const _=ot.input.float("q-cutoff",{format:vo,nullable:!1,min:go,value:po,max:1,step:.01,tooltipText:"Q-cutoff for the pMPO model computation.",onValueChanged:t=>{E.value||(y=!1,null!=t&&t>=go&&t<=1&&i())}});n.append(_.root),_.addValidator(()=>null==_.value?"Q-cutoff is required.":_.value<go||_.value>1?"Q-cutoff must be between 0.01 and 1.":null);const N=t=>{b.enabled=t,x.enabled=t,_.enabled=t};setTimeout(()=>{i(),v?E.value=!0:i()},10);const M=ot.button("Save",()=>hr(this,void 0,void 0,function*(){null!=this.params?function(t,e,n){zo(this,void 0,void 0,function*(){const o=ot.input.string("Name",{value:e,nullable:!1}),r=ot.input.textArea("Description",{value:" ",nullable:!0}),i=ot.input.bool("Desirability Profile",{value:!0,tooltipText:"Save the model as an MPO Desirability Profile. If disabled, the model is saved in the pMPO format."}),s=ot.dialog({title:"Save model"}).add(o).add(r).add(i).addButton("Save",()=>zo(this,void 0,void 0,function*(){try{const e=yield I.dapi.files.list(Ao),s=new Set(e.map(t=>t.name)),a=function(t,e){return function(t,e,n){const o=n(t);if(!e.has(o))return o;let r=2;for(;e.has(n(t,r));)r++;return n(t,r)}(t.trim().replace(/[\s/\\]+/g,"-").replace(/^-|-$/g,"")||"profile",e,(t,e)=>e?`${t}-${e}.json`:`${t}.json`)}(o.value,s),l=`${Ao}/${a}`,u=JSON.stringify(i.value?nr(t,n,o.value,r.value,!1):{type:"Probabilistic MPO Model",name:o.value,description:r.value,properties:Object.fromEntries(t)},null,2);yield I.dapi.files.writeAsText(l,u),I.events.fireCustomEvent("chem-mpo-profile-changed",{}),I.shell.info(`Saved to ${l}`)}catch(t){I.shell.error(`Failed to save: ${t instanceof Error?t.message:"the platform issue"}.`)}s.close()})).show();s.getButton("Save").disabled=!o.validate(),o.onInput.subscribe(()=>s.getButton("Save").disabled=!o.validate())})}(this.params,this.table.name,g.value):I.shell.warning("Failed to save pMPO model: null parameters.")}),"Save model as platform file.");e&&n.append(M);const T=ot.div([n]);return T.classList.add("eda-pmpo-input-form"),{form:T,saveBtn:M}}static validateInputs(e){var n;const o=new Map,{descriptors:r,desirability:i,threshold:s,sign:a,desirableCategories:l,pValue:u,r2:c,qCutoff:f}=e;if(null==u||null==c||null==f)return{valid:!1,errors:o};if(u<=0||u>1||c<0||c>1||f<=0||f>1)return{valid:!1,errors:o};if(null==r||null==i)return{valid:!1,errors:o};if(r.length<1)return o.set("descriptors","Select at least one descriptor column."),{valid:!1,errors:o};if(r.includes(i)){const t="Desirability column cannot be used as a descriptor.";return o.set("descriptors",t),o.set("desirability",t),{valid:!1,errors:o}}const d=r.filter(t=>0===t.stats.stdev).map(t=>t.name);d.length>0&&o.set("descriptors",()=>ot.markdown(`Descriptor columns with zero variance cannot be used: **${d.join(", ")}**`));const h=r.filter(t=>t.stats.missingValueCount===t.length).map(t=>t.name);if(h.length>0&&o.set("descriptors",()=>ot.markdown(`Descriptor columns with only missing values cannot be used: **${h.join(", ")}**`)),i.type===t.COLUMN_TYPE.BOOL)0===i.stats.stdev&&o.set("desirability","All desirability values are the same - scoring is not feasible.");else if(i.type===t.COLUMN_TYPE.STRING){const t=i.categories.length,e=null!==(n=null==l?void 0:l.length)&&void 0!==n?n:0;t<2?o.set("desirability","String desirability column must have at least 2 categories."):0===e?o.set("desirability","Select at least one preferable category."):e===t&&o.set("desirability","At least one category must be non-preferable.")}else 0===i.stats.stdev?o.set("desirability",i.stats.missingValueCount<i.length?"All desirability values are the same - scoring is not feasible.":"Empty column cannot be used as desirability column."):null==s?o.set("desirability","Specify non-null desirability threshold."):lr(i,s,a)||(o.set("desirability",()=>ot.markdown(`All compounds are either desired or non-desired for\n <div align="center">\n **${i.name} ${a} ${s}.**\n </div>\n Adjust the threshold or condition to get both groups.`)),o.set("threshold","Adjust the threshold to get both desired and non-desired groups."));return{valid:!o.size,errors:o}}getDesirabilityColumns(){const e=[];for(const n of this.table.columns)(n.type===t.COLUMN_TYPE.BOOL||n.isNumerical||n.type===t.COLUMN_TYPE.STRING)&&e.push(n);return e}getValidNumericCols(){const t=[];for(const e of this.table.columns)e.isNumerical&&t.push(e);return t}getOptimalSettings(e,n,o){return hr(this,void 0,void 0,function*(){const r=t.TaskBarProgressIndicator.create("Optimizing... ",{cancelable:!0});try{const t=e.names(),{desired:i,nonDesired:s}=Do(this.table,n),a=new Map;t.forEach(t=>{a.set(t,Bo(i.col(t),s.col(t)))});const l=Qo(Ko(a),co);if(l.length<1)return r.close(),{pValTresh:0,r2Tresh:0,qCutoff:0,state:"failed",msg:"No descriptors passed the p-value threshold filter."};const u=Jo(e,l),c=t=>{const e=tr(0,l,a,t[0],u),r=er(i,s,e,t[1]),c=mr.predict(this.table,r,o,this.predictionName);return 1-Vo(n,c).auc},f=yield dr(r,c,new Float32Array([ho,po]),Oo,Io,Lo),d=!r.canceled;return r.close(),d?{pValTresh:co,r2Tresh:f.optimalPoint[0],qCutoff:f.optimalPoint[1],state:"success",msg:"Optimization completed successfully."}:{pValTresh:0,r2Tresh:0,qCutoff:0,state:"canceled",msg:"Auto-tuning was canceled by the user."}}catch(t){return r.close(),{pValTresh:0,r2Tresh:0,qCutoff:0,state:"failed",msg:t instanceof Error?t.message:"Optimization failed due to an unexpected error."}}})}}function pr(e){return n=this,o=arguments,i=function*(e,n=!0){const o=yield I.dapi.files.readCsv(To),r=new gr(o,"Drug","CNS","Smiles").getGenerated(e);if(!n){r.columns.add(t.Column.fromList(t.COLUMN_TYPE.BOOL,"Const bool",new Array(e).fill(!0))),r.columns.add(t.Column.fromInt32Array("Const int",new Int32Array(e).fill(1)));const n=r.columns.toList().find(t=>t.isNumerical);if(n){const e=n.clone();e.name=`${n.name} (missing)`;for(let n=0;n<Math.min(5,e.length);++n)e.set(n,t.FLOAT_NULL);r.columns.add(e)}r.columns.add(t.Column.fromFloat32Array("Nulls",new Float32Array(e).fill(t.FLOAT_NULL)));const o=function(e,n){const o=e.toList(),r=new Array(n),i=new Array(n);for(let t=0;t<n;++t)r[t]=o[t]?"active":"non-active",i[t]=o[t]?Math.random()<.5?"perfect":"good":Math.random()<.5?"bad":"worst";return[t.Column.fromList(t.COLUMN_TYPE.STRING,"CNS (strings)",r),t.Column.fromList(t.COLUMN_TYPE.STRING,"CNS (4 categories)",i),t.Column.fromList(t.COLUMN_TYPE.STRING,"Single category",new Array(n).fill("Unknown"))]}(r.col("CNS"),e);for(const t of o)r.columns.add(t)}return r},new((r=void 0)||(r=Promise))(function(t,e){function s(t){try{l(i.next(t))}catch(t){e(t)}}function a(t){try{l(i.throw(t))}catch(t){e(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof r?n:new r(function(t){t(n)})).then(s,a)}l((i=i.apply(n,o||[])).next())});var n,o,r,i}class gr{constructor(t,e,n,o){this.sourceDf=t,this.drugName=e,this.desirabilityColName=n,this.smilesColName=o;const r=t.columns.toList().filter(t=>t.isNumerical).map(t=>t.name),{desired:i,nonDesired:s}=Do(t,t.col(n));this.descriptorStats=new Map,r.forEach(t=>{this.descriptorStats.set(t,Bo(i.col(t),s.col(t)))}),this.desiredProbability=i.rowCount/t.rowCount}getGenerated(e){if(e<=1)throw new Error("Failed to generate pMPO data: sample count must be greater than 1.");let n;if(e<=this.sourceDf.rowCount){const o=t.BitSet.create(this.sourceDf.rowCount);for(let t=0;t<e;++t)o.set(t,!0);n=this.sourceDf.clone(o)}else n=this.getClonedSourceDfWithFloatNumericCols().append(this.getSyntheticTable(e-this.sourceDf.rowCount));for(const e of n.columns)if(e.type===t.COLUMN_TYPE.BOOL&&0===e.stats.stdev){let t=e.get(0);e.set(0,!t),t=e.get(1),e.set(1,!t)}return n}getSyntheticTable(e){const n=new Array(e);for(let t=0;t<e;++t)n[t]=Math.random()<this.desiredProbability;const o=[this.getDrugColumn(e),this.getSmilesColumn(e),t.Column.fromList(t.COLUMN_TYPE.BOOL,this.desirabilityColName,n)];return this.descriptorStats.forEach((r,i)=>{const s=new Float32Array(e);for(let t=0;t<e;++t)n[t]?s[t]=tn.normal.sample(r.desAvg,r.desStd):s[t]=tn.normal.sample(r.nonDesAvg,r.nonDesStd);o.push(t.Column.fromFloat32Array(i,s))}),t.DataFrame.fromColumns(o)}getDrugColumn(e){return t.Column.fromList(t.COLUMN_TYPE.STRING,this.drugName,Array.from({length:e},(t,e)=>`Synthetic drug ${e+1}`))}getSmilesColumn(e){return t.Column.fromList(t.COLUMN_TYPE.STRING,this.smilesColName,Array.from({length:e},()=>"C"))}getClonedSourceDfWithFloatNumericCols(){const e=[];this.sourceDf.columns.toList().forEach(n=>{n.isNumerical?e.push(n.clone().convertTo(t.COLUMN_TYPE.FLOAT)):e.push(n.clone())});const n=t.DataFrame.fromColumns(e);return n.name=this.sourceDf.name,n}}var vr=function(t,e,n,o){return new(n||(n=Promise))(function(r,i){function s(t){try{l(o.next(t))}catch(t){i(t)}}function a(t){try{l(o.throw(t))}catch(t){i(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(s,a)}l((o=o.apply(t,e||[])).next())})};const yr="CNS",Ar=["TPSA","TPSA_S","HBA","HBD","MW","nAtoms","cLogD_ACD_v15","mapKa","cLogP_Biobyte","mbpKa","cLogP_ACD_v15","ALogP98"],wr="Score",Cr="Drug",Er="Sigmoidal",br=[Er,"Gaussian"];function xr(e=20){const n=Math.floor(e/2),o=[],r=new Float64Array(e),i=new Float64Array(e),s=new Float64Array(e);for(let t=0;t<e;t++){o.push(t<n);const e=t<n?t:t-n,a=e/Math.max(n-1,1);r[t]=t<n?9+2*a:1+2*a,i[t]=t<n?18+4*a:3+4*a,s[t]=5+.1*e}return t.DataFrame.fromColumns([t.Column.fromList(t.COLUMN_TYPE.BOOL,"des",o),t.Column.fromFloat64Array("d1",r),t.Column.fromFloat64Array("d2",i),t.Column.fromFloat64Array("d3",s)])}function _r(e,n){return t.DataFrame.fromColumns(e.columns.byNames(n)).columns}function Nr(){const t=xr();return{descriptors:t.columns.byNames(["d1","d2"]),desirability:t.col("des"),threshold:null,sign:Po.DEFAULT,desirableCategories:null,pValue:co,r2:ho,qCutoff:po}}function Mr(t,e,n,o){if(0===n)return[];const r=t.length;if(e.length!==r)throw new Error("Sense array length must match number of dimensions");const i=new Uint32Array(n);for(let t=0;t<n;t++)i[t]=t;i.sort((n,o)=>e[0]===Go.MIN?t[0][n]-t[0][o]:t[0][o]-t[0][n]);const s=Array(n).fill(!0),a=[];null==o||o.forEach(t=>s[t]=!1);for(const n of i){if(!s[n])continue;let o=!1;for(const i of a){let s=!0,a=!1;for(let o=0;o<r;o++){const r=t[o][i],l=t[o][n];e[o]===Go.MIN?(r>l&&(s=!1),r<l&&(a=!0)):(r<l&&(s=!1),r>l&&(a=!0))}if(s&&a){o=!0;break}}o?s[n]=!1:a.push(n)}return s}b("Probabilistic MPO: Computation",()=>{br.forEach(e=>{const n=e==Er;C("Correctness: "+e,()=>vr(void 0,void 0,void 0,function*(){let o=null,r=null,i=null,s=[],a=null,l=null,u=null,c=null;try{if(o=yield I.dapi.files.readCsv(To),r=yield I.dapi.files.readCsv(So),i=o.col(yr),s=o.columns.byNames(Ar),null==i)throw new Error;const f=mr.fit(o,t.DataFrame.fromColumns(s).columns,i,co,ho,po),d=mr.predict(o,f.params,n,wr);a=o.col(Cr),l=r.col(Cr),u=r.col(e),c=function(t,e,n,o){let r=0;const i=t.toList(),s=n.toList(),a=e.getRawData(),l=o.getRawData();return i.forEach((t,e)=>{const n=s.indexOf(t);if(n<0)throw new Error(`Failed to compare pMPO scores: the "${t}" drug is missing in the reference data.`);r=Math.max(r,Math.abs(a[e]-l[n]))}),r}(a,d,l,u)}catch(t){I.shell.error(t.message)}E(null!==o,!0,"Failed to load the source data: "+To),E(null!==r,!0,"Failed to load the scores data: "+So),E(null!==i,!0,"Inconsistent source data: no column "+yr),E(s.length,Ar.length,"Inconsistent source data: no enough of columns"),E(null!==a,!0,"Inconsistent source data: no column "+Cr),E(null!==l,!0,"Inconsistent reference data: no column "+Cr),E(null!==u,!0,"Inconsistent reference data: no column "+wr),E(null!==c,!0,"Failed to compare pMPO scores with the reference data"),E(c<1e-6,!0,"Max absolute deviation of pMPO scores exceeds the threshold (0.000001)")}),{timeout:1e4})}),C("Performance: 100K drugs, "+Ar.length+" descriptors",()=>vr(void 0,void 0,void 0,function*(){let e=null,n=null,o=[];try{if(e=yield pr(1e5),n=e.col(yr),o=e.columns.byNames(Ar),null==n)throw new Error;const r=mr.fit(e,t.DataFrame.fromColumns(o).columns,n,co,ho,po);mr.predict(e,r.params,!0,wr)}catch(t){I.shell.error(t.message)}E(null!==e,!0,"Failed to load the source data: "+To),E(null!==n,!0,"Inconsistent source data: no column "+yr),E(o.length,Ar.length,"Inconsistent source data: no enough of columns")}),{timeout:1e4})}),b("Probabilistic MPO: API",()=>{C("isApplicable: rejects p-value below minimum",()=>vr(void 0,void 0,void 0,function*(){const t=xr(),e=t.col("des"),n=_r(t,["d1","d2"]);E(mr.isApplicable(n,e,1e-4,ho,po),!1)})),C("isApplicable: rejects R² below minimum",()=>vr(void 0,void 0,void 0,function*(){const t=xr(),e=t.col("des"),n=_r(t,["d1","d2"]);E(mr.isApplicable(n,e,co,.001,po),!1)})),C("isApplicable: rejects q-cutoff below minimum",()=>vr(void 0,void 0,void 0,function*(){const t=xr(),e=t.col("des"),n=_r(t,["d1","d2"]);E(mr.isApplicable(n,e,co,ho,.001),!1)})),C("isApplicable: rejects too few samples",()=>vr(void 0,void 0,void 0,function*(){const t=xr(8),e=t.col("des"),n=_r(t,["d1","d2"]);E(mr.isApplicable(n,e,co,ho,po),!1)})),C("isApplicable: rejects single-category desirability",()=>vr(void 0,void 0,void 0,function*(){const e=t.DataFrame.fromColumns([t.Column.fromList(t.COLUMN_TYPE.BOOL,"des",new Array(20).fill(!0)),t.Column.fromFloat64Array("d1",Float64Array.from({length:20},(t,e)=>e+1)),t.Column.fromFloat64Array("d2",Float64Array.from({length:20},(t,e)=>2*e))]),n=e.col("des"),o=_r(e,["d1","d2"]);E(mr.isApplicable(o,n,co,ho,po),!1)})),C("isApplicable: rejects non-numerical descriptor",()=>vr(void 0,void 0,void 0,function*(){const e=t.DataFrame.fromColumns([t.Column.fromList(t.COLUMN_TYPE.BOOL,"des",Array.from({length:20},(t,e)=>e<10)),t.Column.fromFloat64Array("d1",Float64Array.from({length:20},(t,e)=>e+1)),t.Column.fromStrings("strCol",Array.from({length:20},(t,e)=>"a"+e))]),n=e.col("des"),o=_r(e,["d1","strCol"]);E(mr.isApplicable(o,n,co,ho,po),!1)})),C("isApplicable: rejects all-constant descriptors",()=>vr(void 0,void 0,void 0,function*(){const e=t.DataFrame.fromColumns([t.Column.fromList(t.COLUMN_TYPE.BOOL,"des",Array.from({length:20},(t,e)=>e<10)),t.Column.fromFloat64Array("c1",new Float64Array(20).fill(5)),t.Column.fromFloat64Array("c2",new Float64Array(20).fill(3))]),n=e.col("des"),o=_r(e,["c1","c2"]);E(mr.isApplicable(o,n,co,ho,po),!1)})),C("isApplicable: accepts valid data at minimum sample count",()=>vr(void 0,void 0,void 0,function*(){const t=xr(10),e=t.col("des"),n=_r(t,["d1","d2"]);E(mr.isApplicable(n,e,co,ho,po),!0)})),C("isTableValid: rejects table with 1 row",()=>vr(void 0,void 0,void 0,function*(){const e=t.DataFrame.fromColumns([t.Column.fromFloat64Array("a",new Float64Array([1])),t.Column.fromFloat64Array("b",new Float64Array([2]))]);E(mr.isTableValid(e,!1),!1)})),C("isTableValid: rejects all-constant numeric columns",()=>vr(void 0,void 0,void 0,function*(){const e=t.DataFrame.fromColumns([t.Column.fromFloat64Array("a",new Float64Array(10).fill(5)),t.Column.fromFloat64Array("b",new Float64Array(10).fill(3))]);E(mr.isTableValid(e,!1),!1)})),C("isTableValid: rejects single non-constant numeric column",()=>vr(void 0,void 0,void 0,function*(){const e=t.DataFrame.fromColumns([t.Column.fromFloat64Array("a",Float64Array.from({length:10},(t,e)=>e)),t.Column.fromFloat64Array("b",new Float64Array(10).fill(3))]);E(mr.isTableValid(e,!1),!1)})),C("isTableValid: accepts two non-constant numeric columns",()=>vr(void 0,void 0,void 0,function*(){const e=t.DataFrame.fromColumns([t.Column.fromFloat64Array("a",Float64Array.from({length:10},(t,e)=>e)),t.Column.fromFloat64Array("b",Float64Array.from({length:10},(t,e)=>2*e))]);E(mr.isTableValid(e,!1),!0)})),C("fit: returns non-empty params",()=>vr(void 0,void 0,void 0,function*(){const t=xr();E(mr.fit(t,_r(t,["d1","d2"]),t.col("des"),co,ho,po).params.size>0,!0,"Expected non-empty params")})),C("fit: weights sum to 1",()=>vr(void 0,void 0,void 0,function*(){const t=xr(),e=mr.fit(t,_r(t,["d1","d2"]),t.col("des"),co,ho,po);let n=0;e.params.forEach(t=>n+=t.weight),E(Math.abs(n-1)<1e-10,!0,`Weights sum ${n} should equal 1.0`)})),C("fit: selectedByCorr is subset of selectedByPvalue",()=>vr(void 0,void 0,void 0,function*(){const t=xr(),e=mr.fit(t,_r(t,["d1","d2","d3"]),t.col("des"),co,ho,po);E(e.selectedByCorr.every(t=>e.selectedByPvalue.includes(t)),!0,"selectedByCorr must be a subset of selectedByPvalue")})),C("fit: statistics table row count matches descriptor count",()=>vr(void 0,void 0,void 0,function*(){const t=["d1","d2","d3"],e=xr();E(mr.fit(e,_r(e,t),e.col("des"),co,ho,po).descrStatsTable.rowCount,t.length)})),C("fit: throws on non-applicable data",()=>vr(void 0,void 0,void 0,function*(){const t=xr(8);let e=!1;try{mr.fit(t,_r(t,["d1","d2"]),t.col("des"),co,ho,po)}catch(t){e=!0}E(e,!0,"Expected fit to throw on non-applicable data")})),C("fit: throws when no descriptors pass p-value filter",()=>vr(void 0,void 0,void 0,function*(){const e=t.DataFrame.fromColumns([t.Column.fromList(t.COLUMN_TYPE.BOOL,"des",Array.from({length:20},(t,e)=>e<10)),t.Column.fromFloat64Array("d1",Float64Array.from({length:20},(t,e)=>e%10+1)),t.Column.fromFloat64Array("d2",Float64Array.from({length:20},(t,e)=>2*(e%10+1)))]);let n=!1;try{mr.fit(e,_r(e,["d1","d2"]),e.col("des"),co,ho,po)}catch(t){n=!0}E(n,!0,"Expected fit to throw when no descriptors pass p-value filter")})),C("predict: returns column with correct length",()=>vr(void 0,void 0,void 0,function*(){const t=xr(),e=mr.fit(t,_r(t,["d1","d2"]),t.col("des"),co,ho,po);E(mr.predict(t,e.params,!0,wr).length,t.rowCount)})),C("predict: scores are non-negative",()=>vr(void 0,void 0,void 0,function*(){const t=xr(),e=mr.fit(t,_r(t,["d1","d2"]),t.col("des"),co,ho,po),n=mr.predict(t,e.params,!0,wr).getRawData();let o=!0;for(let t=0;t<n.length;t++)if(n[t]<0){o=!1;break}E(o,!0,"All scores should be non-negative")})),C("predict: scores do not exceed 1",()=>vr(void 0,void 0,void 0,function*(){const t=xr(),e=mr.fit(t,_r(t,["d1","d2"]),t.col("des"),co,ho,po),n=mr.predict(t,e.params,!0,wr).getRawData();let o=0;for(let t=0;t<n.length;t++)o=Math.max(o,n[t]);E(o<=1+1e-10,!0,`Max score ${o} should not exceed 1.0`)})),C("predict: sigmoid and Gaussian modes produce different scores",()=>vr(void 0,void 0,void 0,function*(){const t=xr(),e=mr.fit(t,_r(t,["d1","d2"]),t.col("des"),co,ho,po),n=mr.predict(t,e.params,!0,"sig").getRawData(),o=mr.predict(t,e.params,!1,"gau").getRawData();let r=!1;for(let e=0;e<t.rowCount;e++)if(Math.abs(n[e]-o[e])>1e-12){r=!0;break}E(r,!0,"Sigmoid and Gaussian modes should produce different scores")})),C("predict: throws for missing column",()=>vr(void 0,void 0,void 0,function*(){const e=xr(),n=mr.fit(e,_r(e,["d1","d2"]),e.col("des"),co,ho,po),o=t.DataFrame.fromColumns([t.Column.fromFloat64Array("other",Float64Array.from({length:5},(t,e)=>e))]);let r=!1;try{mr.predict(o,n.params,!0,wr)}catch(t){r=!0}E(r,!0,"Expected predict to throw for missing column")})),C("validateInputs: rejects null p-value",()=>vr(void 0,void 0,void 0,function*(){const t=Nr();t.pValue=null;const e=mr.validateInputs(t);E(e.valid,!1),E(e.errors.size,0,"No input-specific errors for null settings")})),C("validateInputs: rejects null R²",()=>vr(void 0,void 0,void 0,function*(){const t=Nr();t.r2=null,E(mr.validateInputs(t).valid,!1)})),C("validateInputs: rejects null q-cutoff",()=>vr(void 0,void 0,void 0,function*(){const t=Nr();t.qCutoff=null,E(mr.validateInputs(t).valid,!1)})),C("validateInputs: rejects p-value out of range",()=>vr(void 0,void 0,void 0,function*(){const t=Nr();t.pValue=0,E(mr.validateInputs(t).valid,!1),t.pValue=1.5,E(mr.validateInputs(t).valid,!1)})),C("validateInputs: rejects R² out of range",()=>vr(void 0,void 0,void 0,function*(){const t=Nr();t.r2=-.1,E(mr.validateInputs(t).valid,!1),t.r2=1.5,E(mr.validateInputs(t).valid,!1)})),C("validateInputs: rejects q-cutoff out of range",()=>vr(void 0,void 0,void 0,function*(){const t=Nr();t.qCutoff=0,E(mr.validateInputs(t).valid,!1),t.qCutoff=1.5,E(mr.validateInputs(t).valid,!1)})),C("validateInputs: rejects null descriptors",()=>vr(void 0,void 0,void 0,function*(){const t=Nr();t.descriptors=null,E(mr.validateInputs(t).valid,!1)})),C("validateInputs: rejects null desirability",()=>vr(void 0,void 0,void 0,function*(){const t=Nr();t.desirability=null,E(mr.validateInputs(t).valid,!1)})),C("validateInputs: rejects empty descriptors",()=>vr(void 0,void 0,void 0,function*(){const t=Nr();t.descriptors=[];const e=mr.validateInputs(t);E(e.valid,!1),E(e.errors.has("descriptors"),!0)})),C("validateInputs: rejects desirability among descriptors",()=>vr(void 0,void 0,void 0,function*(){const t=xr(),e=t.col("des"),n=mr.validateInputs({descriptors:[t.col("d1"),e],desirability:e,threshold:null,sign:Po.DEFAULT,desirableCategories:null,pValue:co,r2:ho,qCutoff:po});E(n.valid,!1),E(n.errors.has("descriptors"),!0),E(n.errors.has("desirability"),!0)})),C("validateInputs: rejects zero-variance descriptors",()=>vr(void 0,void 0,void 0,function*(){const e=t.DataFrame.fromColumns([t.Column.fromList(t.COLUMN_TYPE.BOOL,"des",Array.from({length:20},(t,e)=>e<10)),t.Column.fromFloat64Array("d1",Float64Array.from({length:20},(t,e)=>e+1)),t.Column.fromFloat64Array("constCol",new Float64Array(20).fill(5))]),n=mr.validateInputs({descriptors:[e.col("d1"),e.col("constCol")],desirability:e.col("des"),threshold:null,sign:Po.DEFAULT,desirableCategories:null,pValue:co,r2:ho,qCutoff:po});E(n.valid,!1),E(n.errors.has("descriptors"),!0)})),C("validateInputs: accepts valid boolean desirability",()=>vr(void 0,void 0,void 0,function*(){const t=Nr(),e=mr.validateInputs(t);E(e.valid,!0),E(e.errors.size,0)})),C("validateInputs: rejects all-true boolean desirability",()=>vr(void 0,void 0,void 0,function*(){const e=t.DataFrame.fromColumns([t.Column.fromList(t.COLUMN_TYPE.BOOL,"des",new Array(20).fill(!0)),t.Column.fromFloat64Array("d1",Float64Array.from({length:20},(t,e)=>e+1)),t.Column.fromFloat64Array("d2",Float64Array.from({length:20},(t,e)=>2*e))]),n=mr.validateInputs({descriptors:[e.col("d1"),e.col("d2")],desirability:e.col("des"),threshold:null,sign:Po.DEFAULT,desirableCategories:null,pValue:co,r2:ho,qCutoff:po});E(n.valid,!1),E(n.errors.has("desirability"),!0)})),C("validateInputs: rejects string desirability with single category",()=>vr(void 0,void 0,void 0,function*(){const e=t.DataFrame.fromColumns([t.Column.fromStrings("des",new Array(20).fill("active")),t.Column.fromFloat64Array("d1",Float64Array.from({length:20},(t,e)=>e+1)),t.Column.fromFloat64Array("d2",Float64Array.from({length:20},(t,e)=>2*e))]),n=mr.validateInputs({descriptors:[e.col("d1"),e.col("d2")],desirability:e.col("des"),threshold:null,sign:Po.DEFAULT,desirableCategories:["active"],pValue:co,r2:ho,qCutoff:po});E(n.valid,!1),E(n.errors.has("desirability"),!0)})),C("validateInputs: rejects no selected categories",()=>vr(void 0,void 0,void 0,function*(){const e=t.DataFrame.fromColumns([t.Column.fromStrings("des",Array.from({length:20},(t,e)=>e<10?"active":"inactive")),t.Column.fromFloat64Array("d1",Float64Array.from({length:20},(t,e)=>e+1)),t.Column.fromFloat64Array("d2",Float64Array.from({length:20},(t,e)=>2*e))]),n=mr.validateInputs({descriptors:[e.col("d1"),e.col("d2")],desirability:e.col("des"),threshold:null,sign:Po.DEFAULT,desirableCategories:[],pValue:co,r2:ho,qCutoff:po});E(n.valid,!1),E(n.errors.has("desirability"),!0)})),C("validateInputs: rejects all categories selected",()=>vr(void 0,void 0,void 0,function*(){const e=t.DataFrame.fromColumns([t.Column.fromStrings("des",Array.from({length:20},(t,e)=>e<10?"active":"inactive")),t.Column.fromFloat64Array("d1",Float64Array.from({length:20},(t,e)=>e+1)),t.Column.fromFloat64Array("d2",Float64Array.from({length:20},(t,e)=>2*e))]),n=mr.validateInputs({descriptors:[e.col("d1"),e.col("d2")],desirability:e.col("des"),threshold:null,sign:Po.DEFAULT,desirableCategories:["active","inactive"],pValue:co,r2:ho,qCutoff:po});E(n.valid,!1),E(n.errors.has("desirability"),!0)})),C("validateInputs: accepts valid string desirability",()=>vr(void 0,void 0,void 0,function*(){const e=t.DataFrame.fromColumns([t.Column.fromStrings("des",Array.from({length:20},(t,e)=>e<10?"active":"inactive")),t.Column.fromFloat64Array("d1",Float64Array.from({length:20},(t,e)=>e<10?e+10:e)),t.Column.fromFloat64Array("d2",Float64Array.from({length:20},(t,e)=>e<10?3*e:e))]),n=mr.validateInputs({descriptors:[e.col("d1"),e.col("d2")],desirability:e.col("des"),threshold:null,sign:Po.DEFAULT,desirableCategories:["active"],pValue:co,r2:ho,qCutoff:po});E(n.valid,!0),E(n.errors.size,0)})),C("validateInputs: rejects constant numeric desirability",()=>vr(void 0,void 0,void 0,function*(){const e=t.DataFrame.fromColumns([t.Column.fromFloat64Array("des",new Float64Array(20).fill(5)),t.Column.fromFloat64Array("d1",Float64Array.from({length:20},(t,e)=>e+1)),t.Column.fromFloat64Array("d2",Float64Array.from({length:20},(t,e)=>2*e))]),n=mr.validateInputs({descriptors:[e.col("d1"),e.col("d2")],desirability:e.col("des"),threshold:5,sign:Po.DEFAULT,desirableCategories:null,pValue:co,r2:ho,qCutoff:po});E(n.valid,!1),E(n.errors.has("desirability"),!0)})),C("validateInputs: rejects null threshold for numeric desirability",()=>vr(void 0,void 0,void 0,function*(){const e=t.DataFrame.fromColumns([t.Column.fromFloat64Array("des",Float64Array.from({length:20},(t,e)=>e)),t.Column.fromFloat64Array("d1",Float64Array.from({length:20},(t,e)=>e+1)),t.Column.fromFloat64Array("d2",Float64Array.from({length:20},(t,e)=>2*e))]),n=mr.validateInputs({descriptors:[e.col("d1"),e.col("d2")],desirability:e.col("des"),threshold:null,sign:Po.DEFAULT,desirableCategories:null,pValue:co,r2:ho,qCutoff:po});E(n.valid,!1),E(n.errors.has("desirability"),!0)})),C("validateInputs: rejects threshold producing single group",()=>vr(void 0,void 0,void 0,function*(){const e=t.DataFrame.fromColumns([t.Column.fromFloat64Array("des",Float64Array.from({length:20},(t,e)=>e)),t.Column.fromFloat64Array("d1",Float64Array.from({length:20},(t,e)=>e+1)),t.Column.fromFloat64Array("d2",Float64Array.from({length:20},(t,e)=>2*e))]),n=mr.validateInputs({descriptors:[e.col("d1"),e.col("d2")],desirability:e.col("des"),threshold:100,sign:Po.LESS_OR_EQUAL,desirableCategories:null,pValue:co,r2:ho,qCutoff:po});E(n.valid,!1),E(n.errors.has("desirability"),!0),E(n.errors.has("threshold"),!0)})),C("validateInputs: accepts valid numeric desirability with threshold",()=>vr(void 0,void 0,void 0,function*(){const e=t.DataFrame.fromColumns([t.Column.fromFloat64Array("des",Float64Array.from({length:20},(t,e)=>e)),t.Column.fromFloat64Array("d1",Float64Array.from({length:20},(t,e)=>e+1)),t.Column.fromFloat64Array("d2",Float64Array.from({length:20},(t,e)=>2*e))]),n=mr.validateInputs({descriptors:[e.col("d1"),e.col("d2")],desirability:e.col("des"),threshold:10,sign:Po.LESS_OR_EQUAL,desirableCategories:null,pValue:co,r2:ho,qCutoff:po});E(n.valid,!0),E(n.errors.size,0)}))});var Tr=function(t,e,n,o){return new(n||(n=Promise))(function(r,i){function s(t){try{l(o.next(t))}catch(t){i(t)}}function a(t){try{l(o.throw(t))}catch(t){i(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(s,a)}l((o=o.apply(t,e||[])).next())})};const Sr=5e3,Or=1e6,Ir="1M points, 2D";function Lr(t,e,n=42){const o=[];let r=n;const i=()=>(r=(1664525*r+1013904223)%4294967296,r/4294967296);for(let n=0;n<e;n++){const e=new Float32Array(t);for(let o=0;o<t;o++)e[o]=100*i()+10*n;o.push(e)}return o}function Pr(t,e){const n=[];for(let o=0;o<t;o++)"all-min"===e?n.push(Go.MIN):"all-max"===e?n.push(Go.MAX):n.push(o%2==0?Go.MIN:Go.MAX);return n}function Rr(t,e){const n=Math.floor(t*e),o=new Set,r=Math.floor(t/n);for(let t=0;t<n;t++)o.add(t*r);return o}function Fr(t,e){if(t.length!==e)throw new Error(`Invalid mask length: expected ${e}, got ${t.length}`);const n=t.filter(t=>t).length;if(0===n)throw new Error("No optimal points found");n===e&&I.shell.warning("All points are optimal - data may be degenerate")}b("Pareto optimization",()=>{C(`Performance: ${Ir}`,()=>Tr(void 0,void 0,void 0,function*(){var t;let e=null,n=null;try{e=Mr(Lr(Or,2),Pr(2,"mixed"),Or),Fr(e,Or)}catch(t){n=t,I.shell.error(n.message)}E(null!==e,!0,"Failed to compute Pareto mask"),E(null===n,!0,null!==(t=null==n?void 0:n.message)&&void 0!==t?t:"")}),{timeout:Sr}),C(`Performance: ${Ir}, all minimize`,()=>Tr(void 0,void 0,void 0,function*(){var t;let e=null,n=null;try{e=Mr(Lr(Or,2),Pr(2,"all-min"),Or),Fr(e,Or)}catch(t){n=t,I.shell.error(n.message)}E(null!==e,!0,"Failed to compute Pareto mask"),E(null===n,!0,null!==(t=null==n?void 0:n.message)&&void 0!==t?t:"")}),{timeout:Sr}),C(`Performance: ${Ir}, all maximize`,()=>Tr(void 0,void 0,void 0,function*(){var t;let e=null,n=null;try{e=Mr(Lr(Or,2),Pr(2,"all-max"),Or),Fr(e,Or)}catch(t){n=t,I.shell.error(n.message)}E(null!==e,!0,"Failed to compute Pareto mask"),E(null===n,!0,null!==(t=null==n?void 0:n.message)&&void 0!==t?t:"")}),{timeout:Sr}),C(`Performance: ${Ir} with 10% null indices`,()=>Tr(void 0,void 0,void 0,function*(){var t;let e=null,n=null;try{const t=Lr(Or,2),n=Pr(2,"mixed"),o=Rr(Or,.1);e=Mr(t,n,Or,o),Fr(e,Or)}catch(t){n=t,I.shell.error(n.message)}E(null!==e,!0,"Failed to compute Pareto mask"),E(null===n,!0,null!==(t=null==n?void 0:n.message)&&void 0!==t?t:"")}),{timeout:Sr}),C(`Performance: ${Ir} with 25% null indices`,()=>Tr(void 0,void 0,void 0,function*(){var t;let e=null,n=null;try{const t=Lr(Or,2),n=Pr(2,"mixed"),o=Rr(Or,.25);e=Mr(t,n,Or,o),Fr(e,Or)}catch(t){n=t,I.shell.error(n.message)}E(null!==e,!0,"Failed to compute Pareto mask"),E(null===n,!0,null!==(t=null==n?void 0:n.message)&&void 0!==t?t:"")}),{timeout:Sr}),C("Edge case: Empty dataset",()=>Tr(void 0,void 0,void 0,function*(){var t;let e=null,n=null;try{e=Mr([new Float32Array(0),new Float32Array(0)],Pr(2,"mixed"),0)}catch(t){n=t,I.shell.error(n.message)}E(null!==e,!0,"Failed to compute Pareto mask"),E(e.length,0,"Empty dataset should return empty mask"),E(null===n,!0,null!==(t=null==n?void 0:n.message)&&void 0!==t?t:"")}),{timeout:Sr}),C("Edge case: Single point",()=>Tr(void 0,void 0,void 0,function*(){var t;let e=null,n=null;try{e=Mr([new Float32Array([1]),new Float32Array([2])],Pr(2,"mixed"),1)}catch(t){n=t,I.shell.error(n.message)}E(null!==e,!0,"Failed to compute Pareto mask"),E(e.length,1,"Single point dataset should return mask with one element"),E(e[0],!0,"Single point should be optimal"),E(null===n,!0,null!==(t=null==n?void 0:n.message)&&void 0!==t?t:"")}),{timeout:Sr}),C("Edge case: All identical points",()=>Tr(void 0,void 0,void 0,function*(){var t;let e=null,n=null;try{const t=100;e=Mr([new Float32Array(t).fill(5),new Float32Array(t).fill(10)],Pr(2,"mixed"),t)}catch(t){n=t,I.shell.error(n.message)}E(null!==e,!0,"Failed to compute Pareto mask"),E(e.length,100,"Should return mask with correct length"),E(e.filter(t=>t).length>0,!0,"At least some identical points should be optimal"),E(null===n,!0,null!==(t=null==n?void 0:n.message)&&void 0!==t?t:"")}),{timeout:Sr})});var Dr=function(t,e,n,o){return new(n||(n=Promise))(function(r,i){function s(t){try{l(o.next(t))}catch(t){i(t)}}function a(t){try{l(o.throw(t))}catch(t){i(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(s,a)}l((o=o.apply(t,e||[])).next())})};const Br=new t.Package;function kr(e,s,a){return Dr(this,void 0,void 0,function*(){const d=yield function(t){var e,s,a;return n(this,void 0,void 0,function*(){const d=(null==t?void 0:t.nodeOptions)?t.nodeOptions.package:grok.functions.getCurrentCall().func.package;if(!d)throw new Error("Can't run tests outside of the package");const h=null===(e=d.packageOwner)||void 0===e?void 0:e.match(/<([^>]*)>/),m=h?h[1]:"";null!=d&&(yield _(d));const p=[];console.log("Running tests..."),console.log(t),null!=t||(t={}),null!==(s=(a=t).testContext)&&void 0!==s||(a.testContext=new A),grok.shell.clearLastError();const g=function(){const t=[];return console.log=(...e)=>{t.push(...e),i(...e)},console.info=(...e)=>{t.push(...e),l(...e)},console.warn=(...e)=>{t.push(...e),u(...e)},console.error=(...e)=>{t.push(...e),c(...e)},t}();yield function(t,e){var o,r,s,a,f,h;return n(this,void 0,void 0,function*(){try{let l=null!=(null==e?void 0:e.skipToCategory),u=!1;for(const[c,g]of Object.entries(t)){if(null===(o=e.exclude)||void 0===o?void 0:o.some(t=>c.startsWith(t)))continue;if(null!=(null==e?void 0:e.category)&&!c.toLowerCase().startsWith(null==e?void 0:e.category.toLowerCase().trim()))continue;if(l)if(u)l=!1;else{if(null==(null==e?void 0:e.skipToCategory)||c.toLowerCase().trim()!==(null==e?void 0:e.skipToCategory.toLowerCase().trim()))continue;u=!0}const t=null===(r=g.tests)||void 0===r?void 0:r.every(t=>{var n;return(null===(n=t.options)||void 0===n?void 0:n.skipReason)||null!=(null==e?void 0:e.test)&&e.test.toLowerCase()!==t.name.toLowerCase()});if(!t){const t=(null!==(s=g.tests)&&void 0!==s?s:[]).filter(t=>{var n;return(null===(n=t.options)||void 0===n?void 0:n.skipReason)||null!=(null==e?void 0:e.test)&&e.test.toLowerCase()!==t.name.toLowerCase()}).length;i(`Package testing: Started {{${c}}}${t>0?` skipped {{${t}}}`:""}`),g.beforeStatus=yield v(g.before,c)}let A,w=null!==(a=g.tests)&&void 0!==a?a:[];e.stressTest&&(w=w.filter(t=>{var e;return null===(e=t.options)||void 0===e?void 0:e.stressTest}),w=T(w)),(null!==(h=null===(f=e.tags)||void 0===f?void 0:f.length)&&void 0!==h?h:0)>0&&(w=w.filter(t=>{var n,o;return null===(o=null===(n=t.options)||void 0===n?void 0:n.tags)||void 0===o?void 0:o.some(t=>{var n;return(null!==(n=null==e?void 0:e.tags)&&void 0!==n?n:[]).includes(t)})})),g.beforeStatus?(A=Array.from(w.map(t=>({date:(new Date).toISOString(),category:c,name:t.name,success:!1,result:"before() failed",ms:0,skipped:!1,logs:"",owner:m,package:d.name,widgetsDifference:0,flaking:DG.Test.isReproducing}))),A.forEach(t=>n(this,void 0,void 0,function*(){return yield grok.shell.reportTest("package",t)}))):A=yield y(g,e,l);const C=A.filter(t=>"skipped"!=t.result);if(t||(g.afterStatus=yield v(g.after,c)),g.afterStatus&&(i(`Package testing: Category after() {{${c}}} failed`),i(`Package testing: Result for {{${c}}} after: ${g.afterStatus}`),C.push({date:(new Date).toISOString(),category:c,name:"after",success:!1,result:g.afterStatus,ms:0,skipped:!1,logs:"",owner:m,package:d.name,widgetsDifference:0,flaking:DG.Test.isReproducing})),g.beforeStatus&&(i(`Package testing: Category before() {{${c}}} failed`),i(`Package testing: Result for {{${c}}} before: ${g.beforeStatus}`),C.push({date:(new Date).toISOString(),category:c,name:"before",success:!1,result:g.beforeStatus,ms:0,skipped:!1,logs:"",owner:m,package:d.name,widgetsDifference:0,flaking:DG.Test.isReproducing})),p.push(...C),e.returnOnFail&&C.some(t=>!t.success&&!t.skipped&&t.name!==e.skipToTest))break}}finally{console.log=i,console.info=l,console.warn=u,console.error=c}if(e.testContext.catchUnhandled&&!DG.Test.isInBenchmark){yield S(1e3);const t=yield grok.shell.lastError;if(null!=t){const e={logs:"",date:(new Date).toISOString(),category:"Unhandled exceptions",name:"Exception",result:null!=t?t:"",success:!t,ms:0,skipped:!1,owner:null!=m?m:"",package:d.name,widgetsDifference:0};i(`Package testing: Unhandled Exception: ${t}`),p.push(Object.assign(Object.assign({},e),{flaking:DG.Test.isReproducing&&!t})),e.package=d.name,yield grok.shell.reportTest("package",e)}}})}(f,t);for(let t of p)t.result=t.result.toString().replace(/"/g,"'"),null!=t.logs&&(t.logs=t.logs.toString().replace(/"/g,"'"));return p;function v(t,e){return n(this,void 0,void 0,function*(){let o;try{void 0!==t&&(yield O(()=>n(this,void 0,void 0,function*(){yield t()}),1e5,`before ${e}: timeout error`))}catch(t){o=yield N(t)}return o})}function y(t,e,i){var s,a,l,u,c,f,h,p,v,y,A,C,E,b,x,_,N,T;return n(this,void 0,void 0,function*(){let n=null!==(s=t.tests)&&void 0!==s?s:[];const S=[],O=w();if(t.clear){let s=i&&null!=e.skipToTest;for(let i=0;i<n.length;i++){n[i].options&&void 0===(null===(a=n[i].options)||void 0===a?void 0:a.benchmark)&&(n[i].options||(n[i].options={}),n[i].options.benchmark=null!==(l=t.benchmarks)&&void 0!==l&&l);let C=n[i];if(e.test&&e.test.toLowerCase()!==C.name.toLowerCase())continue;if(s){if(null==(null==e?void 0:e.skipToTest)||C.name.toLowerCase().trim()!==(null==e?void 0:e.skipToTest.toLowerCase().trim()))continue;s=!1}(null==C?void 0:C.options)&&(C.options.owner=null!==(h=null!==(f=null!==(c=null===(u=n[i].options)||void 0===u?void 0:u.owner)&&void 0!==c?c:null==t?void 0:t.owner)&&void 0!==f?f:m)&&void 0!==h?h:"");let E=yield M(C,null==e?void 0:e.test,g,DG.Test.isInBenchmark?null!==(v=null===(p=n[i].options)||void 0===p?void 0:p.benchmarkTimeout)&&void 0!==v?v:r:null!==(A=null===(y=n[i].options)||void 0===y?void 0:y.timeout)&&void 0!==A?A:o,d.name,e.verbose);if(E&&(S.push(Object.assign(Object.assign({},E),{widgetsDifference:w()-O})),e.returnOnFail&&e.skipToTest!==C.name&&!E.success&&!E.skipped))return S;e.nodeOptions||(grok.shell.closeAll(),DG.Balloon.closeAll())}}else{let o=i&&null!=e.skipToTest;for(let i=0;i<n.length;i++){let s=n[i];if(e.test&&e.test.toLowerCase()!==s.name.toLowerCase())continue;if(o){null!=(null==e?void 0:e.skipToTest)&&s.name.toLowerCase().trim()===(null==e?void 0:e.skipToTest.toLowerCase().trim())&&(o=!1);continue}(null==s?void 0:s.options)&&(s.options.owner=null!==(x=null!==(b=null!==(E=null===(C=n[i].options)||void 0===C?void 0:C.owner)&&void 0!==E?E:null==t?void 0:t.owner)&&void 0!==b?b:m)&&void 0!==x?x:"");let a=yield M(s,null==e?void 0:e.test,g,DG.Test.isInBenchmark?null!==(N=null===(_=n[i].options)||void 0===_?void 0:_.benchmarkTimeout)&&void 0!==N?N:r:null===(T=n[i].options)||void 0===T?void 0:T.timeout,d.name,e.verbose);if(a&&(S.push(Object.assign(Object.assign({},a),{widgetsDifference:w()-O})),e.returnOnFail&&e.skipToTest!==s.name&&!a.success&&!a.skipped))return S}}return S})}function w(){var t;if("undefined"!=typeof process)return 0;let e=-1;try{e=DG.Widget.getAll().length}catch(e){console.warn(null!==(t=e.message)&&void 0!==t?t:e)}return e}})}({category:e,test:s,testContext:a});return t.DataFrame.fromObjects(d)})}function Ur(){return Dr(this,void 0,void 0,function*(){yield _(Br,Br.getModule("package-test.js"))})}})(),eda_test=a})();
|
|
2
2
|
//# sourceMappingURL=package-test.js.map
|